agents
Version:
A home for your AI agents
141 lines (139 loc) • 4.73 kB
TypeScript
import {
OAuthClientInformationContext,
OAuthClientMetadata,
OAuthClientProvider,
OAuthDiscoveryState,
StoredOAuthClientInformation,
StoredOAuthTokens
} from "@modelcontextprotocol/client";
//#region src/mcp/client/do-oauth-client-provider.d.ts
interface AgentMcpOAuthProvider extends OAuthClientProvider {
authUrl: string | undefined;
clientId: string | undefined;
serverId: string | undefined;
checkState(state: string): Promise<{
valid: boolean;
serverId?: string;
error?: string;
}>;
consumeState(state: string): Promise<void>;
runWithCodeVerifierState?<T>(
state: string,
callback: () => Promise<T>
): Promise<T>;
deleteCodeVerifier(): Promise<void>;
}
/**
* @deprecated Use {@link AgentMcpOAuthProvider} instead.
*/
type AgentsOAuthProvider = AgentMcpOAuthProvider;
interface DurableObjectOAuthClientProviderOptions {
/**
* HTTPS URL of this client's OAuth Client ID Metadata Document.
*
* When an authorization server advertises
* `client_id_metadata_document_supported`, the client uses this URL as its
* `client_id` instead of dynamic client registration. Other servers still
* use dynamic client registration. Serve
* {@link DurableObjectOAuthClientProvider.clientMetadataDocument} at this
* URL, and use a stable `callbackPath` so the document's `redirect_uris`
* match every authorization request.
*/
clientMetadataUrl?: string;
}
declare class DurableObjectOAuthClientProvider implements AgentMcpOAuthProvider {
storage: DurableObjectStorage;
clientName: string;
baseRedirectUrl: string;
private _authUrl_;
private _serverId_;
private _clientId_;
readonly clientMetadataUrl: string | undefined;
constructor(
storage: DurableObjectStorage,
clientName: string,
baseRedirectUrl: string,
options?: DurableObjectOAuthClientProviderOptions
);
/**
* The Client ID Metadata Document to serve at `clientMetadataUrl`.
* Throws when the provider has no `clientMetadataUrl`.
*/
get clientMetadataDocument(): OAuthClientMetadata & {
client_id: string;
};
get clientMetadata(): OAuthClientMetadata;
get clientUri(): string;
get redirectUrl(): string;
get clientId(): string;
set clientId(clientId_: string);
get serverId(): string;
set serverId(serverId_: string);
keyPrefix(clientId: string): string;
clientInfoKey(clientId: string): string;
discoveryStateKey(): string;
saveDiscoveryState(state: OAuthDiscoveryState): Promise<void>;
discoveryState(): Promise<OAuthDiscoveryState | undefined>;
clientInformation(
_context?: OAuthClientInformationContext
): Promise<StoredOAuthClientInformation | undefined>;
saveClientInformation(
clientInformation: StoredOAuthClientInformation,
_context?: OAuthClientInformationContext
): Promise<void>;
tokenKey(clientId: string): string;
tokens(
_context?: OAuthClientInformationContext
): Promise<StoredOAuthTokens | undefined>;
saveTokens(
tokens: StoredOAuthTokens,
_context?: OAuthClientInformationContext
): Promise<void>;
get authUrl(): string | undefined;
stateKey(nonce: string): string;
state(): Promise<string>;
checkState(state: string): Promise<{
valid: boolean;
serverId?: string;
error?: string;
}>;
consumeState(state: string): Promise<void>;
redirectToAuthorization(authUrl: URL): Promise<void>;
invalidateCredentials(
scope: "all" | "client" | "tokens" | "verifier" | "discovery"
): Promise<void>;
/**
* Delete every key this provider stores for its server: tokens and client
* info for any client ID, verifiers, pending states and discovery state.
* Used when the server is removed. Other servers' keys are untouched.
*/
clearServerStorage(): Promise<void>;
codeVerifierKey(clientId: string): string;
stateCodeVerifierPrefix(clientId: string): string;
stateCodeVerifierKey(clientId: string, nonce: string): string;
challengeCodeVerifierPrefix(clientId: string): string;
challengeCodeVerifierKey(clientId: string, codeChallenge: string): string;
codeVerifierKeys(
clientId: string,
options?: {
includeChallengeKeys?: boolean;
}
): Promise<string[]>;
saveCodeVerifier(verifier: string): Promise<void>;
private deleteExpiredChallengeCodeVerifiers;
codeVerifier(): Promise<string>;
private codeVerifierForState;
runWithCodeVerifierState<T>(
state: string,
callback: () => Promise<T>
): Promise<T>;
deleteCodeVerifier(): Promise<void>;
}
//#endregion
export {
DurableObjectOAuthClientProviderOptions as i,
AgentsOAuthProvider as n,
DurableObjectOAuthClientProvider as r,
AgentMcpOAuthProvider as t
};
//# sourceMappingURL=do-oauth-client-provider-DtNqv7oj.d.ts.map