@bskyprism/atproto-oauth-client-cloudflare-workers 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +69 -0
  3. package/lib/did-cache-kv.d.ts +18 -0
  4. package/lib/did-cache-kv.js +26 -0
  5. package/lib/did-resolver/did-cache-memory.d.ts +7 -0
  6. package/lib/did-resolver/did-cache-memory.js +10 -0
  7. package/lib/did-resolver/did-cache.d.ts +14 -0
  8. package/lib/did-resolver/did-cache.js +10 -0
  9. package/lib/did-resolver/did-method.d.ts +11 -0
  10. package/lib/did-resolver/did-method.js +1 -0
  11. package/lib/did-resolver/did-resolver-base.d.ts +9 -0
  12. package/lib/did-resolver/did-resolver-base.js +36 -0
  13. package/lib/did-resolver/did-resolver-common.d.ts +8 -0
  14. package/lib/did-resolver/did-resolver-common.js +11 -0
  15. package/lib/did-resolver/did-resolver.d.ts +6 -0
  16. package/lib/did-resolver/did-resolver.js +1 -0
  17. package/lib/did-resolver/index.d.ts +6 -0
  18. package/lib/did-resolver/index.js +7 -0
  19. package/lib/did-resolver/methods/plc.d.ts +43 -0
  20. package/lib/did-resolver/methods/plc.js +22 -0
  21. package/lib/did-resolver/methods/web.d.ts +43 -0
  22. package/lib/did-resolver/methods/web.js +42 -0
  23. package/lib/did-resolver/methods.d.ts +2 -0
  24. package/lib/did-resolver/methods.js +2 -0
  25. package/lib/did-resolver/util.d.ts +3 -0
  26. package/lib/did-resolver/util.js +1 -0
  27. package/lib/dpop-store.d.ts +21 -0
  28. package/lib/dpop-store.js +25 -0
  29. package/lib/handle-cache-kv.d.ts +17 -0
  30. package/lib/handle-cache-kv.js +31 -0
  31. package/lib/handle-resolver/atproto-doh-handle-resolver.d.ts +8 -0
  32. package/lib/handle-resolver/atproto-doh-handle-resolver.js +94 -0
  33. package/lib/handle-resolver/atproto-handle-resolver.d.ts +21 -0
  34. package/lib/handle-resolver/atproto-handle-resolver.js +46 -0
  35. package/lib/handle-resolver/cached-handle-resolver.d.ts +12 -0
  36. package/lib/handle-resolver/cached-handle-resolver.js +17 -0
  37. package/lib/handle-resolver/handle-resolver-error.d.ts +3 -0
  38. package/lib/handle-resolver/handle-resolver-error.js +6 -0
  39. package/lib/handle-resolver/index.d.ts +6 -0
  40. package/lib/handle-resolver/index.js +8 -0
  41. package/lib/handle-resolver/internal-resolvers/dns-handle-resolver.d.ts +11 -0
  42. package/lib/handle-resolver/internal-resolvers/dns-handle-resolver.js +28 -0
  43. package/lib/handle-resolver/internal-resolvers/well-known-handler-resolver.d.ts +17 -0
  44. package/lib/handle-resolver/internal-resolvers/well-known-handler-resolver.js +28 -0
  45. package/lib/handle-resolver/types.d.ts +25 -0
  46. package/lib/handle-resolver/types.js +10 -0
  47. package/lib/handle-resolver/xrpc-handle-resolver.d.ts +31 -0
  48. package/lib/handle-resolver/xrpc-handle-resolver.js +45 -0
  49. package/lib/handle-resolver.d.ts +20 -0
  50. package/lib/handle-resolver.js +19 -0
  51. package/lib/identity-resolver/atproto-identity-resolver.d.ts +20 -0
  52. package/lib/identity-resolver/atproto-identity-resolver.js +72 -0
  53. package/lib/identity-resolver/constants.d.ts +1 -0
  54. package/lib/identity-resolver/constants.js +1 -0
  55. package/lib/identity-resolver/identity-resolver-error.d.ts +3 -0
  56. package/lib/identity-resolver/identity-resolver-error.js +6 -0
  57. package/lib/identity-resolver/identity-resolver.d.ts +19 -0
  58. package/lib/identity-resolver/identity-resolver.js +1 -0
  59. package/lib/identity-resolver/index.d.ts +5 -0
  60. package/lib/identity-resolver/index.js +5 -0
  61. package/lib/identity-resolver/util.d.ts +12 -0
  62. package/lib/identity-resolver/util.js +35 -0
  63. package/lib/index.d.ts +7 -0
  64. package/lib/index.js +6 -0
  65. package/lib/oauth-client/atproto-token-response.d.ts +100 -0
  66. package/lib/oauth-client/atproto-token-response.js +15 -0
  67. package/lib/oauth-client/constants.d.ts +4 -0
  68. package/lib/oauth-client/constants.js +4 -0
  69. package/lib/oauth-client/errors/auth-method-unsatisfiable-error.d.ts +2 -0
  70. package/lib/oauth-client/errors/auth-method-unsatisfiable-error.js +2 -0
  71. package/lib/oauth-client/errors/token-invalid-error.d.ts +6 -0
  72. package/lib/oauth-client/errors/token-invalid-error.js +6 -0
  73. package/lib/oauth-client/errors/token-refresh-error.d.ts +6 -0
  74. package/lib/oauth-client/errors/token-refresh-error.js +6 -0
  75. package/lib/oauth-client/errors/token-revoked-error.d.ts +6 -0
  76. package/lib/oauth-client/errors/token-revoked-error.js +6 -0
  77. package/lib/oauth-client/fetch-dpop.d.ts +19 -0
  78. package/lib/oauth-client/fetch-dpop.js +176 -0
  79. package/lib/oauth-client/identity-resolver.d.ts +15 -0
  80. package/lib/oauth-client/identity-resolver.js +33 -0
  81. package/lib/oauth-client/index.d.ts +17 -0
  82. package/lib/oauth-client/index.js +17 -0
  83. package/lib/oauth-client/lock.d.ts +2 -0
  84. package/lib/oauth-client/lock.js +28 -0
  85. package/lib/oauth-client/oauth-authorization-server-metadata-resolver.d.ts +18 -0
  86. package/lib/oauth-client/oauth-authorization-server-metadata-resolver.js +53 -0
  87. package/lib/oauth-client/oauth-callback-error.d.ts +6 -0
  88. package/lib/oauth-client/oauth-callback-error.js +13 -0
  89. package/lib/oauth-client/oauth-client-auth.d.ts +22 -0
  90. package/lib/oauth-client/oauth-client-auth.js +127 -0
  91. package/lib/oauth-client/oauth-client.d.ts +311 -0
  92. package/lib/oauth-client/oauth-client.js +276 -0
  93. package/lib/oauth-client/oauth-protected-resource-metadata-resolver.d.ts +18 -0
  94. package/lib/oauth-client/oauth-protected-resource-metadata-resolver.js +49 -0
  95. package/lib/oauth-client/oauth-resolver-error.d.ts +6 -0
  96. package/lib/oauth-client/oauth-resolver-error.js +18 -0
  97. package/lib/oauth-client/oauth-resolver.d.ts +71 -0
  98. package/lib/oauth-client/oauth-resolver.js +117 -0
  99. package/lib/oauth-client/oauth-response-error.d.ts +10 -0
  100. package/lib/oauth-client/oauth-response-error.js +22 -0
  101. package/lib/oauth-client/oauth-server-agent.d.ts +54 -0
  102. package/lib/oauth-client/oauth-server-agent.js +250 -0
  103. package/lib/oauth-client/oauth-server-factory.d.ts +32 -0
  104. package/lib/oauth-client/oauth-server-factory.js +37 -0
  105. package/lib/oauth-client/oauth-session.d.ts +33 -0
  106. package/lib/oauth-client/oauth-session.js +122 -0
  107. package/lib/oauth-client/runtime-implementation.d.ts +16 -0
  108. package/lib/oauth-client/runtime-implementation.js +1 -0
  109. package/lib/oauth-client/runtime.d.ts +25 -0
  110. package/lib/oauth-client/runtime.js +99 -0
  111. package/lib/oauth-client/session-getter.d.ts +54 -0
  112. package/lib/oauth-client/session-getter.js +260 -0
  113. package/lib/oauth-client/state-store.d.ts +12 -0
  114. package/lib/oauth-client/state-store.js +1 -0
  115. package/lib/oauth-client/types.d.ts +1365 -0
  116. package/lib/oauth-client/types.js +8 -0
  117. package/lib/oauth-client/util.d.ts +25 -0
  118. package/lib/oauth-client/util.js +139 -0
  119. package/lib/oauth-client/validate-client-metadata.d.ts +4 -0
  120. package/lib/oauth-client/validate-client-metadata.js +68 -0
  121. package/lib/oauth-client.d.ts +27 -0
  122. package/lib/oauth-client.js +30 -0
  123. package/lib/resolve-txt-factory.d.ts +3 -0
  124. package/lib/resolve-txt-factory.js +80 -0
  125. package/lib/session-store-kv.d.ts +9 -0
  126. package/lib/session-store-kv.js +20 -0
  127. package/lib/state-store-kv.d.ts +9 -0
  128. package/lib/state-store-kv.js +20 -0
  129. package/lib/util.d.ts +18 -0
  130. package/lib/util.js +5 -0
  131. package/package.json +58 -0
@@ -0,0 +1,22 @@
1
+ import { Keyset } from "@atproto/jwk";
2
+ import { OAuthAuthorizationServerMetadata, OAuthClientCredentials } from "@atproto/oauth-types";
3
+ import { Runtime } from "./runtime.js";
4
+ import { ClientMetadata } from "./types.js";
5
+ import { Awaitable } from "./util.js";
6
+ export type ClientAuthMethod = {
7
+ method: "none";
8
+ } | {
9
+ method: "private_key_jwt";
10
+ kid: string;
11
+ };
12
+ export declare function negotiateClientAuthMethod(serverMetadata: OAuthAuthorizationServerMetadata, clientMetadata: ClientMetadata, keyset?: Keyset): ClientAuthMethod;
13
+ export type ClientCredentialsFactory = () => Awaitable<{
14
+ headers?: Record<string, string>;
15
+ payload?: OAuthClientCredentials;
16
+ }>;
17
+ /**
18
+ * @throws {AuthMethodUnsatisfiableError} if the authentication method is no
19
+ * long usable (either because the AS changed, of because the key is no longer
20
+ * available in the keyset).
21
+ */
22
+ export declare function createClientCredentialsFactory(authMethod: ClientAuthMethod, serverMetadata: OAuthAuthorizationServerMetadata, clientMetadata: ClientMetadata, runtime: Runtime, keyset?: Keyset): ClientCredentialsFactory;
@@ -0,0 +1,127 @@
1
+ import { CLIENT_ASSERTION_TYPE_JWT_BEARER, } from "@atproto/oauth-types";
2
+ import { FALLBACK_ALG } from "./constants.js";
3
+ import { AuthMethodUnsatisfiableError } from "./errors/auth-method-unsatisfiable-error.js";
4
+ export function negotiateClientAuthMethod(serverMetadata, clientMetadata, keyset) {
5
+ const method = clientMetadata.token_endpoint_auth_method;
6
+ // @NOTE ATproto spec requires that AS support both "none" and
7
+ // "private_key_jwt", and that clients use one of the other. The following
8
+ // check ensures that the AS is indeed compliant with this client's
9
+ // configuration.
10
+ const methods = supportedMethods(serverMetadata);
11
+ if (!methods.includes(method)) {
12
+ throw new Error(`The server does not support "${method}" authentication. Supported methods are: ${methods.join(", ")}.`);
13
+ }
14
+ if (method === "private_key_jwt") {
15
+ // Invalid client configuration. This should not happen as
16
+ // "validateClientMetadata" already check this.
17
+ if (!keyset)
18
+ throw new Error("A keyset is required for private_key_jwt");
19
+ const alg = supportedAlgs(serverMetadata);
20
+ // @NOTE we can't use `keyset.findPrivateKey` here because we can't enforce
21
+ // that the returned key contains a "kid". The following implementation is
22
+ // more robust against keysets containing keys without a "kid" property.
23
+ for (const key of keyset.list({ use: "sig", alg })) {
24
+ // Return the first key from the key set that matches the server's
25
+ // supported algorithms.
26
+ if (key.isPrivate && key.kid) {
27
+ return { method: "private_key_jwt", kid: key.kid };
28
+ }
29
+ }
30
+ throw new Error(alg.includes(FALLBACK_ALG)
31
+ ? `Client authentication method "${method}" requires at least one "${FALLBACK_ALG}" signing key with a "kid" property`
32
+ : // AS is not compliant with the ATproto OAuth spec.
33
+ `Authorization server requires "${method}" authentication method, but does not support "${FALLBACK_ALG}" algorithm.`);
34
+ }
35
+ if (method === "none") {
36
+ return { method: "none" };
37
+ }
38
+ throw new Error(`The ATProto OAuth spec requires that client use either "none" or "private_key_jwt" authentication method.` +
39
+ (method === "client_secret_basic"
40
+ ? ' You might want to explicitly set "token_endpoint_auth_method" to one of those values in the client metadata document.'
41
+ : ` You set "${method}" which is not allowed.`));
42
+ }
43
+ /**
44
+ * @throws {AuthMethodUnsatisfiableError} if the authentication method is no
45
+ * long usable (either because the AS changed, of because the key is no longer
46
+ * available in the keyset).
47
+ */
48
+ export function createClientCredentialsFactory(authMethod, serverMetadata, clientMetadata, runtime, keyset) {
49
+ // Ensure the AS still supports the auth method.
50
+ if (!supportedMethods(serverMetadata).includes(authMethod.method)) {
51
+ throw new AuthMethodUnsatisfiableError(`Client authentication method "${authMethod.method}" no longer supported`);
52
+ }
53
+ if (authMethod.method === "none") {
54
+ return () => ({
55
+ payload: {
56
+ client_id: clientMetadata.client_id,
57
+ },
58
+ });
59
+ }
60
+ if (authMethod.method === "private_key_jwt") {
61
+ try {
62
+ // The client used to be a confidential client but no longer has a keyset.
63
+ if (!keyset)
64
+ throw new Error("A keyset is required for private_key_jwt");
65
+ // @NOTE throws if no matching key can be found
66
+ const { key, alg } = keyset.findPrivateKey({
67
+ use: "sig",
68
+ kid: authMethod.kid,
69
+ alg: supportedAlgs(serverMetadata),
70
+ });
71
+ // https://www.rfc-editor.org/rfc/rfc7523.html#section-3
72
+ return async () => ({
73
+ payload: {
74
+ client_id: clientMetadata.client_id,
75
+ client_assertion_type: CLIENT_ASSERTION_TYPE_JWT_BEARER,
76
+ client_assertion: await key.createJwt({ alg }, {
77
+ // > The JWT MUST contain an "iss" (issuer) claim that contains a
78
+ // > unique identifier for the entity that issued the JWT.
79
+ iss: clientMetadata.client_id,
80
+ // > For client authentication, the subject MUST be the
81
+ // > "client_id" of the OAuth client.
82
+ sub: clientMetadata.client_id,
83
+ // > The JWT MUST contain an "aud" (audience) claim containing a value
84
+ // > that identifies the authorization server as an intended audience.
85
+ // > The token endpoint URL of the authorization server MAY be used as a
86
+ // > value for an "aud" element to identify the authorization server as an
87
+ // > intended audience of the JWT.
88
+ aud: serverMetadata.issuer,
89
+ // > The JWT MAY contain a "jti" (JWT ID) claim that provides a
90
+ // > unique identifier for the token.
91
+ jti: await runtime.generateNonce(),
92
+ // > The JWT MAY contain an "iat" (issued at) claim that
93
+ // > identifies the time at which the JWT was issued.
94
+ iat: Math.floor(Date.now() / 1000),
95
+ // > The JWT MUST contain an "exp" (expiration time) claim that
96
+ // > limits the time window during which the JWT can be used.
97
+ exp: Math.floor(Date.now() / 1000) + 60, // 1 minute
98
+ }),
99
+ },
100
+ });
101
+ }
102
+ catch (cause) {
103
+ console.error(cause);
104
+ throw new AuthMethodUnsatisfiableError("Failed to load private key", {
105
+ cause,
106
+ });
107
+ }
108
+ }
109
+ throw new AuthMethodUnsatisfiableError(
110
+ // @ts-expect-error
111
+ `Unsupported auth method ${authMethod.method}`);
112
+ }
113
+ function supportedMethods(serverMetadata) {
114
+ return serverMetadata["token_endpoint_auth_methods_supported"];
115
+ }
116
+ function supportedAlgs(serverMetadata) {
117
+ return (serverMetadata["token_endpoint_auth_signing_alg_values_supported"] ?? [
118
+ // @NOTE If not specified, assume that the server supports the ES256
119
+ // algorithm, as prescribed by the spec:
120
+ //
121
+ // > Clients and Authorization Servers currently must support the ES256
122
+ // > cryptographic system [for client authentication].
123
+ //
124
+ // https://atproto.com/specs/oauth#confidential-client-authentication
125
+ FALLBACK_ALG,
126
+ ]);
127
+ }
@@ -0,0 +1,311 @@
1
+ import { Key, Keyset } from "@atproto/jwk";
2
+ import { OAuthClientIdDiscoverable, OAuthClientMetadata, OAuthClientMetadataInput, OAuthResponseMode } from "@atproto/oauth-types";
3
+ import { AtprotoDid } from "@atproto/did";
4
+ import { DidCache } from "#did-resolver";
5
+ import { Fetch } from "@atproto-labs/fetch";
6
+ import { HandleCache, HandleResolver } from "#handle-resolver";
7
+ import { IdentityResolverOptions } from "./identity-resolver.js";
8
+ import { AuthorizationServerMetadataCache } from "./oauth-authorization-server-metadata-resolver.js";
9
+ import { ProtectedResourceMetadataCache } from "./oauth-protected-resource-metadata-resolver.js";
10
+ import { OAuthResolver } from "./oauth-resolver.js";
11
+ import { DpopNonceCache, OAuthServerAgent } from "./oauth-server-agent.js";
12
+ import { OAuthServerFactory } from "./oauth-server-factory.js";
13
+ import { OAuthSession } from "./oauth-session.js";
14
+ import { RuntimeImplementation } from "./runtime-implementation.js";
15
+ import { Runtime } from "./runtime.js";
16
+ import { SessionEventMap, SessionGetter, SessionStore } from "./session-getter.js";
17
+ import { InternalStateData, StateStore } from "./state-store.js";
18
+ import { AuthorizeOptions, ClientMetadata } from "./types.js";
19
+ import { CustomEventTarget } from "./util.js";
20
+ export { type AuthorizationServerMetadataCache, type DidCache, type DpopNonceCache, type Fetch, type HandleCache, type HandleResolver, type InternalStateData, Key, Keyset, type OAuthClientMetadata, type OAuthClientMetadataInput, type OAuthResponseMode, type ProtectedResourceMetadataCache, type RuntimeImplementation, type SessionStore, type StateStore, };
21
+ export type OAuthClientOptions = IdentityResolverOptions & {
22
+ responseMode: OAuthResponseMode;
23
+ clientMetadata: Readonly<OAuthClientMetadataInput>;
24
+ keyset?: Keyset | Iterable<Key | undefined | null | false>;
25
+ /**
26
+ * Determines if the client will allow communicating with the OAuth Servers
27
+ * (Authorization & Resource), or to retrieve "did:web" documents, over
28
+ * unsafe HTTP connections. It is recommended to set this to `true` only for
29
+ * development purposes.
30
+ *
31
+ * @note This does not affect the identity resolution mechanism, which will
32
+ * allow HTTP connections to the PLC Directory (if the provided directory url
33
+ * is "http:" based).
34
+ * @default false
35
+ * @see {@link OAuthProtectedResourceMetadataResolver.allowHttpResource}
36
+ * @see {@link OAuthAuthorizationServerMetadataResolver.allowHttpIssuer}
37
+ * @see {@link DidResolverCommonOptions.allowHttp}
38
+ */
39
+ allowHttp?: boolean;
40
+ stateStore: StateStore;
41
+ sessionStore: SessionStore;
42
+ authorizationServerMetadataCache?: AuthorizationServerMetadataCache;
43
+ protectedResourceMetadataCache?: ProtectedResourceMetadataCache;
44
+ dpopNonceCache?: DpopNonceCache;
45
+ runtimeImplementation: RuntimeImplementation;
46
+ fetch?: Fetch;
47
+ };
48
+ export type OAuthClientEventMap = SessionEventMap;
49
+ export type OAuthClientFetchMetadataOptions = {
50
+ clientId: OAuthClientIdDiscoverable;
51
+ fetch?: Fetch;
52
+ signal?: AbortSignal;
53
+ };
54
+ export declare class OAuthClient extends CustomEventTarget<OAuthClientEventMap> {
55
+ static fetchMetadata({ clientId, fetch, signal, }: OAuthClientFetchMetadataOptions): Promise<{
56
+ redirect_uris: [`http://[::1]${string}` | "http://127.0.0.1" | `http://127.0.0.1#${string}` | `http://127.0.0.1?${string}` | `http://127.0.0.1/${string}` | `http://127.0.0.1:${string}` | `https://${string}` | `${string}.${string}:/${string}`, ...(`http://[::1]${string}` | "http://127.0.0.1" | `http://127.0.0.1#${string}` | `http://127.0.0.1?${string}` | `http://127.0.0.1/${string}` | `http://127.0.0.1:${string}` | `https://${string}` | `${string}.${string}:/${string}`)[]];
57
+ response_types: ["code" | "none" | "token" | "code id_token token" | "code id_token" | "code token" | "id_token token" | "id_token", ...("code" | "none" | "token" | "code id_token token" | "code id_token" | "code token" | "id_token token" | "id_token")[]];
58
+ grant_types: ["authorization_code" | "implicit" | "refresh_token" | "password" | "client_credentials" | "urn:ietf:params:oauth:grant-type:jwt-bearer" | "urn:ietf:params:oauth:grant-type:saml2-bearer", ...("authorization_code" | "implicit" | "refresh_token" | "password" | "client_credentials" | "urn:ietf:params:oauth:grant-type:jwt-bearer" | "urn:ietf:params:oauth:grant-type:saml2-bearer")[]];
59
+ token_endpoint_auth_method: "client_secret_basic" | "client_secret_jwt" | "client_secret_post" | "none" | "private_key_jwt" | "self_signed_tls_client_auth" | "tls_client_auth";
60
+ application_type: "web" | "native";
61
+ subject_type: "public" | "pairwise";
62
+ authorization_signed_response_alg: string;
63
+ scope?: string | undefined;
64
+ token_endpoint_auth_signing_alg?: string | undefined;
65
+ userinfo_signed_response_alg?: string | undefined;
66
+ userinfo_encrypted_response_alg?: string | undefined;
67
+ jwks_uri?: `http://[::1]${string}` | "http://localhost" | `http://localhost#${string}` | `http://localhost?${string}` | `http://localhost/${string}` | `http://localhost:${string}` | "http://127.0.0.1" | `http://127.0.0.1#${string}` | `http://127.0.0.1?${string}` | `http://127.0.0.1/${string}` | `http://127.0.0.1:${string}` | `https://${string}` | undefined;
68
+ jwks?: {
69
+ keys: ({
70
+ kty: "RSA";
71
+ n: string;
72
+ e: string;
73
+ alg?: "RS256" | "RS384" | "RS512" | "PS256" | "PS384" | "PS512" | undefined;
74
+ kid?: string | undefined;
75
+ ext?: boolean | undefined;
76
+ use?: "sig" | "enc" | undefined;
77
+ key_ops?: ("sign" | "verify" | "encrypt" | "decrypt" | "wrapKey" | "unwrapKey" | "deriveKey" | "deriveBits")[] | undefined;
78
+ x5c?: string[] | undefined;
79
+ x5t?: string | undefined;
80
+ "x5t#S256"?: string | undefined;
81
+ x5u?: string | undefined;
82
+ d?: string | undefined;
83
+ p?: string | undefined;
84
+ q?: string | undefined;
85
+ dp?: string | undefined;
86
+ dq?: string | undefined;
87
+ qi?: string | undefined;
88
+ oth?: [{
89
+ d?: string | undefined;
90
+ r?: string | undefined;
91
+ t?: string | undefined;
92
+ }, ...{
93
+ d?: string | undefined;
94
+ r?: string | undefined;
95
+ t?: string | undefined;
96
+ }[]] | undefined;
97
+ } | {
98
+ kty: "EC";
99
+ crv: "P-256" | "P-384" | "P-521";
100
+ x: string;
101
+ y: string;
102
+ alg?: "ES256" | "ES384" | "ES512" | undefined;
103
+ kid?: string | undefined;
104
+ ext?: boolean | undefined;
105
+ use?: "sig" | "enc" | undefined;
106
+ key_ops?: ("sign" | "verify" | "encrypt" | "decrypt" | "wrapKey" | "unwrapKey" | "deriveKey" | "deriveBits")[] | undefined;
107
+ x5c?: string[] | undefined;
108
+ x5t?: string | undefined;
109
+ "x5t#S256"?: string | undefined;
110
+ x5u?: string | undefined;
111
+ d?: string | undefined;
112
+ } | {
113
+ kty: "EC";
114
+ crv: "secp256k1";
115
+ x: string;
116
+ y: string;
117
+ alg?: "ES256K" | undefined;
118
+ kid?: string | undefined;
119
+ ext?: boolean | undefined;
120
+ use?: "sig" | "enc" | undefined;
121
+ key_ops?: ("sign" | "verify" | "encrypt" | "decrypt" | "wrapKey" | "unwrapKey" | "deriveKey" | "deriveBits")[] | undefined;
122
+ x5c?: string[] | undefined;
123
+ x5t?: string | undefined;
124
+ "x5t#S256"?: string | undefined;
125
+ x5u?: string | undefined;
126
+ d?: string | undefined;
127
+ } | {
128
+ kty: "OKP";
129
+ crv: "Ed25519" | "Ed448";
130
+ x: string;
131
+ alg?: "EdDSA" | undefined;
132
+ kid?: string | undefined;
133
+ ext?: boolean | undefined;
134
+ use?: "sig" | "enc" | undefined;
135
+ key_ops?: ("sign" | "verify" | "encrypt" | "decrypt" | "wrapKey" | "unwrapKey" | "deriveKey" | "deriveBits")[] | undefined;
136
+ x5c?: string[] | undefined;
137
+ x5t?: string | undefined;
138
+ "x5t#S256"?: string | undefined;
139
+ x5u?: string | undefined;
140
+ d?: string | undefined;
141
+ } | {
142
+ kty: "oct";
143
+ k: string;
144
+ alg?: "HS256" | "HS384" | "HS512" | undefined;
145
+ kid?: string | undefined;
146
+ ext?: boolean | undefined;
147
+ use?: "sig" | "enc" | undefined;
148
+ key_ops?: ("sign" | "verify" | "encrypt" | "decrypt" | "wrapKey" | "unwrapKey" | "deriveKey" | "deriveBits")[] | undefined;
149
+ x5c?: string[] | undefined;
150
+ x5t?: string | undefined;
151
+ "x5t#S256"?: string | undefined;
152
+ x5u?: string | undefined;
153
+ } | {
154
+ kty: string;
155
+ alg?: string | undefined;
156
+ kid?: string | undefined;
157
+ ext?: boolean | undefined;
158
+ use?: "sig" | "enc" | undefined;
159
+ key_ops?: ("sign" | "verify" | "encrypt" | "decrypt" | "wrapKey" | "unwrapKey" | "deriveKey" | "deriveBits")[] | undefined;
160
+ x5c?: string[] | undefined;
161
+ x5t?: string | undefined;
162
+ "x5t#S256"?: string | undefined;
163
+ x5u?: string | undefined;
164
+ })[];
165
+ } | undefined;
166
+ request_object_signing_alg?: string | undefined;
167
+ id_token_signed_response_alg?: string | undefined;
168
+ authorization_encrypted_response_enc?: "A128CBC-HS256" | undefined;
169
+ authorization_encrypted_response_alg?: string | undefined;
170
+ client_id?: string | undefined;
171
+ client_name?: string | undefined;
172
+ client_uri?: `http://[::1]${string}` | "http://localhost" | `http://localhost#${string}` | `http://localhost?${string}` | `http://localhost/${string}` | `http://localhost:${string}` | "http://127.0.0.1" | `http://127.0.0.1#${string}` | `http://127.0.0.1?${string}` | `http://127.0.0.1/${string}` | `http://127.0.0.1:${string}` | `https://${string}` | undefined;
173
+ policy_uri?: `http://[::1]${string}` | "http://localhost" | `http://localhost#${string}` | `http://localhost?${string}` | `http://localhost/${string}` | `http://localhost:${string}` | "http://127.0.0.1" | `http://127.0.0.1#${string}` | `http://127.0.0.1?${string}` | `http://127.0.0.1/${string}` | `http://127.0.0.1:${string}` | `https://${string}` | undefined;
174
+ tos_uri?: `http://[::1]${string}` | "http://localhost" | `http://localhost#${string}` | `http://localhost?${string}` | `http://localhost/${string}` | `http://localhost:${string}` | "http://127.0.0.1" | `http://127.0.0.1#${string}` | `http://127.0.0.1?${string}` | `http://127.0.0.1/${string}` | `http://127.0.0.1:${string}` | `https://${string}` | undefined;
175
+ logo_uri?: `http://[::1]${string}` | "http://localhost" | `http://localhost#${string}` | `http://localhost?${string}` | `http://localhost/${string}` | `http://localhost:${string}` | "http://127.0.0.1" | `http://127.0.0.1#${string}` | `http://127.0.0.1?${string}` | `http://127.0.0.1/${string}` | `http://127.0.0.1:${string}` | `https://${string}` | undefined;
176
+ default_max_age?: number | undefined;
177
+ require_auth_time?: boolean | undefined;
178
+ contacts?: string[] | undefined;
179
+ tls_client_certificate_bound_access_tokens?: boolean | undefined;
180
+ dpop_bound_access_tokens?: boolean | undefined;
181
+ authorization_details_types?: string[] | undefined;
182
+ }>;
183
+ readonly clientMetadata: ClientMetadata;
184
+ readonly responseMode: OAuthResponseMode;
185
+ readonly keyset?: Keyset;
186
+ readonly runtime: Runtime;
187
+ readonly fetch: Fetch;
188
+ readonly oauthResolver: OAuthResolver;
189
+ readonly serverFactory: OAuthServerFactory;
190
+ protected readonly sessionGetter: SessionGetter;
191
+ protected readonly stateStore: StateStore;
192
+ constructor(options: OAuthClientOptions);
193
+ get identityResolver(): import("#identity-resolver").IdentityResolver;
194
+ get jwks(): {
195
+ readonly keys: readonly ({
196
+ readonly kty: "RSA";
197
+ readonly n: string;
198
+ readonly e: string;
199
+ readonly alg?: "RS256" | "RS384" | "RS512" | "PS256" | "PS384" | "PS512" | undefined | undefined;
200
+ readonly kid?: string | undefined | undefined;
201
+ readonly ext?: boolean | undefined | undefined;
202
+ readonly use?: "sig" | "enc" | undefined | undefined;
203
+ readonly key_ops?: readonly ("sign" | "verify" | "encrypt" | "decrypt" | "wrapKey" | "unwrapKey" | "deriveKey" | "deriveBits")[] | undefined;
204
+ readonly x5c?: readonly string[] | undefined;
205
+ readonly x5t?: string | undefined | undefined;
206
+ readonly 'x5t#S256'?: string | undefined | undefined;
207
+ readonly x5u?: string | undefined | undefined;
208
+ readonly d?: string | undefined | undefined;
209
+ readonly p?: string | undefined | undefined;
210
+ readonly q?: string | undefined | undefined;
211
+ readonly dp?: string | undefined | undefined;
212
+ readonly dq?: string | undefined | undefined;
213
+ readonly qi?: string | undefined | undefined;
214
+ readonly oth?: readonly [{
215
+ readonly d?: string | undefined | undefined;
216
+ readonly r?: string | undefined | undefined;
217
+ readonly t?: string | undefined | undefined;
218
+ }, ...{
219
+ readonly d?: string | undefined | undefined;
220
+ readonly r?: string | undefined | undefined;
221
+ readonly t?: string | undefined | undefined;
222
+ }[]] | undefined;
223
+ } | {
224
+ readonly kty: "EC";
225
+ readonly crv: "P-256" | "P-384" | "P-521";
226
+ readonly x: string;
227
+ readonly y: string;
228
+ readonly alg?: "ES256" | "ES384" | "ES512" | undefined | undefined;
229
+ readonly kid?: string | undefined | undefined;
230
+ readonly ext?: boolean | undefined | undefined;
231
+ readonly use?: "sig" | "enc" | undefined | undefined;
232
+ readonly key_ops?: readonly ("sign" | "verify" | "encrypt" | "decrypt" | "wrapKey" | "unwrapKey" | "deriveKey" | "deriveBits")[] | undefined;
233
+ readonly x5c?: readonly string[] | undefined;
234
+ readonly x5t?: string | undefined | undefined;
235
+ readonly 'x5t#S256'?: string | undefined | undefined;
236
+ readonly x5u?: string | undefined | undefined;
237
+ readonly d?: string | undefined | undefined;
238
+ } | {
239
+ readonly kty: "EC";
240
+ readonly crv: "secp256k1";
241
+ readonly x: string;
242
+ readonly y: string;
243
+ readonly alg?: "ES256K" | undefined | undefined;
244
+ readonly kid?: string | undefined | undefined;
245
+ readonly ext?: boolean | undefined | undefined;
246
+ readonly use?: "sig" | "enc" | undefined | undefined;
247
+ readonly key_ops?: readonly ("sign" | "verify" | "encrypt" | "decrypt" | "wrapKey" | "unwrapKey" | "deriveKey" | "deriveBits")[] | undefined;
248
+ readonly x5c?: readonly string[] | undefined;
249
+ readonly x5t?: string | undefined | undefined;
250
+ readonly 'x5t#S256'?: string | undefined | undefined;
251
+ readonly x5u?: string | undefined | undefined;
252
+ readonly d?: string | undefined | undefined;
253
+ } | {
254
+ readonly kty: "OKP";
255
+ readonly crv: "Ed25519" | "Ed448";
256
+ readonly x: string;
257
+ readonly alg?: "EdDSA" | undefined | undefined;
258
+ readonly kid?: string | undefined | undefined;
259
+ readonly ext?: boolean | undefined | undefined;
260
+ readonly use?: "sig" | "enc" | undefined | undefined;
261
+ readonly key_ops?: readonly ("sign" | "verify" | "encrypt" | "decrypt" | "wrapKey" | "unwrapKey" | "deriveKey" | "deriveBits")[] | undefined;
262
+ readonly x5c?: readonly string[] | undefined;
263
+ readonly x5t?: string | undefined | undefined;
264
+ readonly 'x5t#S256'?: string | undefined | undefined;
265
+ readonly x5u?: string | undefined | undefined;
266
+ readonly d?: string | undefined | undefined;
267
+ } | {
268
+ readonly kty: "oct";
269
+ readonly k: string;
270
+ readonly alg?: "HS256" | "HS384" | "HS512" | undefined | undefined;
271
+ readonly kid?: string | undefined | undefined;
272
+ readonly ext?: boolean | undefined | undefined;
273
+ readonly use?: "sig" | "enc" | undefined | undefined;
274
+ readonly key_ops?: readonly ("sign" | "verify" | "encrypt" | "decrypt" | "wrapKey" | "unwrapKey" | "deriveKey" | "deriveBits")[] | undefined;
275
+ readonly x5c?: readonly string[] | undefined;
276
+ readonly x5t?: string | undefined | undefined;
277
+ readonly 'x5t#S256'?: string | undefined | undefined;
278
+ readonly x5u?: string | undefined | undefined;
279
+ } | {
280
+ readonly kty: string;
281
+ readonly alg?: string | undefined | undefined;
282
+ readonly kid?: string | undefined | undefined;
283
+ readonly ext?: boolean | undefined | undefined;
284
+ readonly use?: "sig" | "enc" | undefined | undefined;
285
+ readonly key_ops?: readonly ("sign" | "verify" | "encrypt" | "decrypt" | "wrapKey" | "unwrapKey" | "deriveKey" | "deriveBits")[] | undefined;
286
+ readonly x5c?: readonly string[] | undefined;
287
+ readonly x5t?: string | undefined | undefined;
288
+ readonly 'x5t#S256'?: string | undefined | undefined;
289
+ readonly x5u?: string | undefined | undefined;
290
+ })[];
291
+ };
292
+ authorize(input: string, { signal, ...options }?: AuthorizeOptions): Promise<URL>;
293
+ /**
294
+ * This method allows the client to proactively revoke the request_uri it
295
+ * created through PAR.
296
+ */
297
+ abortRequest(authorizeUrl: URL): Promise<void>;
298
+ callback(params: URLSearchParams): Promise<{
299
+ session: OAuthSession;
300
+ state: string | null;
301
+ }>;
302
+ /**
303
+ * Load a stored session. This will refresh the token only if needed (about to
304
+ * expire) by default.
305
+ *
306
+ * @param refresh See {@link SessionGetter.getSession}
307
+ */
308
+ restore(sub: string, refresh?: boolean | "auto"): Promise<OAuthSession>;
309
+ revoke(sub: string): Promise<void>;
310
+ protected createSession(server: OAuthServerAgent, sub: AtprotoDid): OAuthSession;
311
+ }