Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/client/src/client/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1206,6 +1206,7 @@ export async function refreshAuthorization(
* @throws {Error} When provider doesn't implement prepareTokenRequest or token fetch fails
*
* @example
* ```typescript
* // Provider for client_credentials:
* class MyProvider implements OAuthClientProvider {
* prepareTokenRequest(scope) {
Expand All @@ -1217,6 +1218,7 @@ export async function refreshAuthorization(
* }
*
* const tokens = await fetchToken(provider, authServerUrl, { metadata });
* ```
*/
export async function fetchToken(
provider: OAuthClientProvider,
Expand Down
12 changes: 9 additions & 3 deletions packages/client/src/client/authExtensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ import type { AddClientAuthentication, OAuthClientProvider } from './auth.js';
/**
* Helper to produce a private_key_jwt client authentication function.
*
* Usage:
* const addClientAuth = createPrivateKeyJwtAuth({ issuer, subject, privateKey, alg, audience? });
* // pass addClientAuth as provider.addClientAuthentication implementation
* @example
* ```typescript
* const addClientAuth = createPrivateKeyJwtAuth({ issuer, subject, privateKey, alg, audience? });
* // pass addClientAuth as provider.addClientAuthentication implementation
* ```
*/
export function createPrivateKeyJwtAuth(options: {
issuer: string;
Expand Down Expand Up @@ -114,6 +116,7 @@ export interface ClientCredentialsProviderOptions {
* the client authenticates using a client_id and client_secret.
*
* @example
* ```typescript
* const provider = new ClientCredentialsProvider({
* clientId: 'my-client',
* clientSecret: 'my-secret'
Expand All @@ -122,6 +125,7 @@ export interface ClientCredentialsProviderOptions {
* const transport = new StreamableHTTPClientTransport(serverUrl, {
* authProvider: provider
* });
* ```
*/
export class ClientCredentialsProvider implements OAuthClientProvider {
private _tokens?: OAuthTokens;
Expand Down Expand Up @@ -222,6 +226,7 @@ export interface PrivateKeyJwtProviderOptions {
* the client authenticates using a signed JWT assertion (RFC 7523 Section 2.2).
*
* @example
* ```typescript
* const provider = new PrivateKeyJwtProvider({
* clientId: 'my-client',
* privateKey: pemEncodedPrivateKey,
Expand All @@ -231,6 +236,7 @@ export interface PrivateKeyJwtProviderOptions {
* const transport = new StreamableHTTPClientTransport(serverUrl, {
* authProvider: provider
* });
* ```
*/
export class PrivateKeyJwtProvider implements OAuthClientProvider {
private _tokens?: OAuthTokens;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ export function localhostAllowedHostnames(): string[] {
/**
* Web-standard Request helper for DNS rebinding protection.
* @example
* ```typescript
* const result = validateHostHeader(req.headers.get('host'), ['localhost'])
* ```
*/
export function hostHeaderValidationResponse(req: Request, allowedHostnames: string[]): Response | undefined {
const result = validateHostHeader(req.headers.get('host'), allowedHostnames);
Expand Down
Loading