@atcute/oauth-types 0.1.0

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 (158) hide show
  1. package/LICENSE +14 -0
  2. package/README.md +48 -0
  3. package/dist/build-client-metadata.d.ts +168 -0
  4. package/dist/build-client-metadata.d.ts.map +1 -0
  5. package/dist/build-client-metadata.js +53 -0
  6. package/dist/build-client-metadata.js.map +1 -0
  7. package/dist/constants.d.ts +5 -0
  8. package/dist/constants.d.ts.map +1 -0
  9. package/dist/constants.js +5 -0
  10. package/dist/constants.js.map +1 -0
  11. package/dist/index.d.ts +31 -0
  12. package/dist/index.d.ts.map +1 -0
  13. package/dist/index.js +37 -0
  14. package/dist/index.js.map +1 -0
  15. package/dist/schemas/atcute-confidential-client-metadata.d.ts +21 -0
  16. package/dist/schemas/atcute-confidential-client-metadata.d.ts.map +1 -0
  17. package/dist/schemas/atcute-confidential-client-metadata.js +112 -0
  18. package/dist/schemas/atcute-confidential-client-metadata.js.map +1 -0
  19. package/dist/schemas/atproto-authorization-server-metadata.d.ts +55 -0
  20. package/dist/schemas/atproto-authorization-server-metadata.d.ts.map +1 -0
  21. package/dist/schemas/atproto-authorization-server-metadata.js +25 -0
  22. package/dist/schemas/atproto-authorization-server-metadata.js.map +1 -0
  23. package/dist/schemas/atproto-oauth-scope.d.ts +8 -0
  24. package/dist/schemas/atproto-oauth-scope.d.ts.map +1 -0
  25. package/dist/schemas/atproto-oauth-scope.js +12 -0
  26. package/dist/schemas/atproto-oauth-scope.js.map +1 -0
  27. package/dist/schemas/atproto-oauth-token-response.d.ts +19 -0
  28. package/dist/schemas/atproto-oauth-token-response.d.ts.map +1 -0
  29. package/dist/schemas/atproto-oauth-token-response.js +16 -0
  30. package/dist/schemas/atproto-oauth-token-response.js.map +1 -0
  31. package/dist/schemas/atproto-protected-resource-metadata.d.ts +21 -0
  32. package/dist/schemas/atproto-protected-resource-metadata.d.ts.map +1 -0
  33. package/dist/schemas/atproto-protected-resource-metadata.js +18 -0
  34. package/dist/schemas/atproto-protected-resource-metadata.js.map +1 -0
  35. package/dist/schemas/jwk.d.ts +241 -0
  36. package/dist/schemas/jwk.d.ts.map +1 -0
  37. package/dist/schemas/jwk.js +138 -0
  38. package/dist/schemas/jwk.js.map +1 -0
  39. package/dist/schemas/jwks.d.ts +242 -0
  40. package/dist/schemas/jwks.d.ts.map +1 -0
  41. package/dist/schemas/jwks.js +34 -0
  42. package/dist/schemas/jwks.js.map +1 -0
  43. package/dist/schemas/oauth-authorization-details.d.ts +64 -0
  44. package/dist/schemas/oauth-authorization-details.d.ts.map +1 -0
  45. package/dist/schemas/oauth-authorization-details.js +37 -0
  46. package/dist/schemas/oauth-authorization-details.js.map +1 -0
  47. package/dist/schemas/oauth-authorization-server-metadata.d.ts +96 -0
  48. package/dist/schemas/oauth-authorization-server-metadata.d.ts.map +1 -0
  49. package/dist/schemas/oauth-authorization-server-metadata.js +81 -0
  50. package/dist/schemas/oauth-authorization-server-metadata.js.map +1 -0
  51. package/dist/schemas/oauth-client-id-discoverable.d.ts +6 -0
  52. package/dist/schemas/oauth-client-id-discoverable.d.ts.map +1 -0
  53. package/dist/schemas/oauth-client-id-discoverable.js +43 -0
  54. package/dist/schemas/oauth-client-id-discoverable.js.map +1 -0
  55. package/dist/schemas/oauth-client-id.d.ts +5 -0
  56. package/dist/schemas/oauth-client-id.d.ts.map +1 -0
  57. package/dist/schemas/oauth-client-id.js +4 -0
  58. package/dist/schemas/oauth-client-id.js.map +1 -0
  59. package/dist/schemas/oauth-client-metadata.d.ts +164 -0
  60. package/dist/schemas/oauth-client-metadata.d.ts.map +1 -0
  61. package/dist/schemas/oauth-client-metadata.js +74 -0
  62. package/dist/schemas/oauth-client-metadata.js.map +1 -0
  63. package/dist/schemas/oauth-code-challenge-method.d.ts +4 -0
  64. package/dist/schemas/oauth-code-challenge-method.d.ts.map +1 -0
  65. package/dist/schemas/oauth-code-challenge-method.js +3 -0
  66. package/dist/schemas/oauth-code-challenge-method.js.map +1 -0
  67. package/dist/schemas/oauth-endpoint-auth-method.d.ts +4 -0
  68. package/dist/schemas/oauth-endpoint-auth-method.d.ts.map +1 -0
  69. package/dist/schemas/oauth-endpoint-auth-method.js +3 -0
  70. package/dist/schemas/oauth-endpoint-auth-method.js.map +1 -0
  71. package/dist/schemas/oauth-grant-type.d.ts +4 -0
  72. package/dist/schemas/oauth-grant-type.d.ts.map +1 -0
  73. package/dist/schemas/oauth-grant-type.js +4 -0
  74. package/dist/schemas/oauth-grant-type.js.map +1 -0
  75. package/dist/schemas/oauth-issuer-identifier.d.ts +4 -0
  76. package/dist/schemas/oauth-issuer-identifier.d.ts.map +1 -0
  77. package/dist/schemas/oauth-issuer-identifier.js +21 -0
  78. package/dist/schemas/oauth-issuer-identifier.js.map +1 -0
  79. package/dist/schemas/oauth-par-response.d.ts +7 -0
  80. package/dist/schemas/oauth-par-response.d.ts.map +1 -0
  81. package/dist/schemas/oauth-par-response.js +7 -0
  82. package/dist/schemas/oauth-par-response.js.map +1 -0
  83. package/dist/schemas/oauth-prompt.d.ts +13 -0
  84. package/dist/schemas/oauth-prompt.d.ts.map +1 -0
  85. package/dist/schemas/oauth-prompt.js +12 -0
  86. package/dist/schemas/oauth-prompt.js.map +1 -0
  87. package/dist/schemas/oauth-protected-resource-metadata.d.ts +66 -0
  88. package/dist/schemas/oauth-protected-resource-metadata.d.ts.map +1 -0
  89. package/dist/schemas/oauth-protected-resource-metadata.js +71 -0
  90. package/dist/schemas/oauth-protected-resource-metadata.js.map +1 -0
  91. package/dist/schemas/oauth-redirect-uri.d.ts +20 -0
  92. package/dist/schemas/oauth-redirect-uri.d.ts.map +1 -0
  93. package/dist/schemas/oauth-redirect-uri.js +32 -0
  94. package/dist/schemas/oauth-redirect-uri.js.map +1 -0
  95. package/dist/schemas/oauth-response-mode.d.ts +4 -0
  96. package/dist/schemas/oauth-response-mode.d.ts.map +1 -0
  97. package/dist/schemas/oauth-response-mode.js +3 -0
  98. package/dist/schemas/oauth-response-mode.js.map +1 -0
  99. package/dist/schemas/oauth-response-type.d.ts +4 -0
  100. package/dist/schemas/oauth-response-type.d.ts.map +1 -0
  101. package/dist/schemas/oauth-response-type.js +8 -0
  102. package/dist/schemas/oauth-response-type.js.map +1 -0
  103. package/dist/schemas/oauth-scope.d.ts +12 -0
  104. package/dist/schemas/oauth-scope.d.ts.map +1 -0
  105. package/dist/schemas/oauth-scope.js +14 -0
  106. package/dist/schemas/oauth-scope.js.map +1 -0
  107. package/dist/schemas/oauth-token-response.d.ts +22 -0
  108. package/dist/schemas/oauth-token-response.d.ts.map +1 -0
  109. package/dist/schemas/oauth-token-response.js +19 -0
  110. package/dist/schemas/oauth-token-response.js.map +1 -0
  111. package/dist/schemas/oauth-token-type.d.ts +5 -0
  112. package/dist/schemas/oauth-token-type.d.ts.map +1 -0
  113. package/dist/schemas/oauth-token-type.js +13 -0
  114. package/dist/schemas/oauth-token-type.js.map +1 -0
  115. package/dist/schemas/uri.d.ts +18 -0
  116. package/dist/schemas/uri.d.ts.map +1 -0
  117. package/dist/schemas/uri.js +81 -0
  118. package/dist/schemas/uri.js.map +1 -0
  119. package/dist/schemas/utils.d.ts +32 -0
  120. package/dist/schemas/utils.d.ts.map +1 -0
  121. package/dist/schemas/utils.js +94 -0
  122. package/dist/schemas/utils.js.map +1 -0
  123. package/dist/scope.d.ts +84 -0
  124. package/dist/scope.d.ts.map +1 -0
  125. package/dist/scope.js +102 -0
  126. package/dist/scope.js.map +1 -0
  127. package/lib/build-client-metadata.ts +72 -0
  128. package/lib/constants.ts +5 -0
  129. package/lib/index.ts +116 -0
  130. package/lib/schemas/atcute-confidential-client-metadata.ts +139 -0
  131. package/lib/schemas/atproto-authorization-server-metadata.ts +32 -0
  132. package/lib/schemas/atproto-oauth-scope.ts +18 -0
  133. package/lib/schemas/atproto-oauth-token-response.ts +20 -0
  134. package/lib/schemas/atproto-protected-resource-metadata.ts +24 -0
  135. package/lib/schemas/jwk.ts +189 -0
  136. package/lib/schemas/jwks.ts +45 -0
  137. package/lib/schemas/oauth-authorization-details.ts +43 -0
  138. package/lib/schemas/oauth-authorization-server-metadata.ts +101 -0
  139. package/lib/schemas/oauth-client-id-discoverable.ts +53 -0
  140. package/lib/schemas/oauth-client-id.ts +6 -0
  141. package/lib/schemas/oauth-client-metadata.ts +83 -0
  142. package/lib/schemas/oauth-code-challenge-method.ts +5 -0
  143. package/lib/schemas/oauth-endpoint-auth-method.ts +13 -0
  144. package/lib/schemas/oauth-grant-type.ts +13 -0
  145. package/lib/schemas/oauth-issuer-identifier.ts +30 -0
  146. package/lib/schemas/oauth-par-response.ts +10 -0
  147. package/lib/schemas/oauth-prompt.ts +20 -0
  148. package/lib/schemas/oauth-protected-resource-metadata.ts +89 -0
  149. package/lib/schemas/oauth-redirect-uri.ts +42 -0
  150. package/lib/schemas/oauth-response-mode.ts +9 -0
  151. package/lib/schemas/oauth-response-type.ts +17 -0
  152. package/lib/schemas/oauth-scope.ts +18 -0
  153. package/lib/schemas/oauth-token-response.ts +22 -0
  154. package/lib/schemas/oauth-token-type.ts +15 -0
  155. package/lib/schemas/uri.ts +100 -0
  156. package/lib/schemas/utils.ts +113 -0
  157. package/lib/scope.ts +187 -0
  158. package/package.json +38 -0
package/LICENSE ADDED
@@ -0,0 +1,14 @@
1
+ BSD Zero Clause License
2
+
3
+ Copyright (c) 2025 Mary
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted.
7
+
8
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
9
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
11
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14
+ PERFORMANCE OF THIS SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,48 @@
1
+ # @atcute/oauth-types
2
+
3
+ OAuth types and schemas for AT Protocol.
4
+
5
+ ```sh
6
+ npm install @atcute/oauth-types
7
+ ```
8
+
9
+ ## usage
10
+
11
+ ### building client metadata
12
+
13
+ ```ts
14
+ import { buildClientMetadata } from '@atcute/oauth-types';
15
+ import { Keyset } from '@atcute/oauth-keyset';
16
+
17
+ const metadata = buildClientMetadata(
18
+ {
19
+ client_id: 'https://example.com/client-metadata.json',
20
+ redirect_uris: ['https://example.com/callback'],
21
+ scope: 'atproto transition:generic',
22
+ client_name: 'my app',
23
+ },
24
+ keyset,
25
+ );
26
+ ```
27
+
28
+ ### validating data
29
+
30
+ ```ts
31
+ import {
32
+ confidentialClientMetadataSchema,
33
+ oauthTokenResponseSchema,
34
+ atprotoAuthorizationServerMetadataSchema,
35
+ } from '@atcute/oauth-types';
36
+
37
+ // validate client metadata
38
+ const result = confidentialClientMetadataSchema.try(input);
39
+ if (result.ok) {
40
+ console.log(result.value);
41
+ }
42
+
43
+ // validate token response
44
+ const tokenResult = oauthTokenResponseSchema.try(response);
45
+
46
+ // validate authorization server metadata
47
+ const asResult = atprotoAuthorizationServerMetadataSchema.try(metadata);
48
+ ```
@@ -0,0 +1,168 @@
1
+ import type { Keyset } from '@atcute/oauth-keyset';
2
+ /**
3
+ * builds an atproto client metadata
4
+ *
5
+ *
6
+ * @param input client metadata
7
+ * @param keyset available keys
8
+ * @returns built client metadata
9
+ */
10
+ export declare const buildClientMetadata: (input: {
11
+ client_id: string;
12
+ redirect_uris: string[];
13
+ scope: string | string[];
14
+ client_uri?: string | undefined;
15
+ client_name?: string | undefined;
16
+ policy_uri?: string | undefined;
17
+ tos_uri?: string | undefined;
18
+ logo_uri?: string | undefined;
19
+ jwks_uri?: string | undefined;
20
+ }, keyset: Keyset) => {
21
+ redirect_uris: string[];
22
+ response_types?: ("code" | "code id_token" | "code id_token token" | "code token" | "id_token" | "id_token token" | "none" | "token")[] | undefined;
23
+ grant_types?: ("authorization_code" | "client_credentials" | "implicit" | "password" | "refresh_token" | "urn:ietf:params:oauth:grant-type:jwt-bearer" | "urn:ietf:params:oauth:grant-type:saml2-bearer")[] | undefined;
24
+ scope?: string | undefined;
25
+ 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" | undefined;
26
+ token_endpoint_auth_signing_alg?: string | undefined;
27
+ userinfo_signed_response_alg?: string | undefined;
28
+ userinfo_encrypted_response_alg?: string | undefined;
29
+ jwks_uri?: string | undefined;
30
+ jwks?: {
31
+ keys: ({
32
+ kid?: string | undefined;
33
+ use?: "enc" | "sig" | undefined;
34
+ key_ops?: ("decrypt" | "deriveBits" | "deriveKey" | "encrypt" | "sign" | "unwrapKey" | "verify" | "wrapKey")[] | undefined;
35
+ x5c?: string[] | undefined;
36
+ x5t?: string | undefined;
37
+ 'x5t#S256'?: string | undefined;
38
+ x5u?: string | undefined;
39
+ ext?: boolean | undefined;
40
+ iat?: number | undefined;
41
+ exp?: number | undefined;
42
+ nbf?: number | undefined;
43
+ revoked?: {
44
+ revoked_at: number;
45
+ reason?: string | undefined;
46
+ } | undefined;
47
+ kty: "RSA";
48
+ alg?: "PS256" | "PS384" | "PS512" | "RS256" | "RS384" | "RS512" | undefined;
49
+ n: string;
50
+ e: string;
51
+ d?: string | undefined;
52
+ p?: string | undefined;
53
+ q?: string | undefined;
54
+ dp?: string | undefined;
55
+ dq?: string | undefined;
56
+ qi?: string | undefined;
57
+ oth?: {
58
+ r?: string | undefined;
59
+ d?: string | undefined;
60
+ t?: string | undefined;
61
+ }[] | undefined;
62
+ } | {
63
+ kid?: string | undefined;
64
+ use?: "enc" | "sig" | undefined;
65
+ key_ops?: ("decrypt" | "deriveBits" | "deriveKey" | "encrypt" | "sign" | "unwrapKey" | "verify" | "wrapKey")[] | undefined;
66
+ x5c?: string[] | undefined;
67
+ x5t?: string | undefined;
68
+ 'x5t#S256'?: string | undefined;
69
+ x5u?: string | undefined;
70
+ ext?: boolean | undefined;
71
+ iat?: number | undefined;
72
+ exp?: number | undefined;
73
+ nbf?: number | undefined;
74
+ revoked?: {
75
+ revoked_at: number;
76
+ reason?: string | undefined;
77
+ } | undefined;
78
+ kty: "EC";
79
+ alg?: "ES256" | "ES384" | "ES512" | undefined;
80
+ crv: "P-256" | "P-384" | "P-521";
81
+ x: string;
82
+ y: string;
83
+ d?: string | undefined;
84
+ } | {
85
+ kid?: string | undefined;
86
+ use?: "enc" | "sig" | undefined;
87
+ key_ops?: ("decrypt" | "deriveBits" | "deriveKey" | "encrypt" | "sign" | "unwrapKey" | "verify" | "wrapKey")[] | undefined;
88
+ x5c?: string[] | undefined;
89
+ x5t?: string | undefined;
90
+ 'x5t#S256'?: string | undefined;
91
+ x5u?: string | undefined;
92
+ ext?: boolean | undefined;
93
+ iat?: number | undefined;
94
+ exp?: number | undefined;
95
+ nbf?: number | undefined;
96
+ revoked?: {
97
+ revoked_at: number;
98
+ reason?: string | undefined;
99
+ } | undefined;
100
+ kty: "EC";
101
+ alg?: "ES256K" | undefined;
102
+ crv: "secp256k1";
103
+ x: string;
104
+ y: string;
105
+ d?: string | undefined;
106
+ } | {
107
+ kid?: string | undefined;
108
+ use?: "enc" | "sig" | undefined;
109
+ key_ops?: ("decrypt" | "deriveBits" | "deriveKey" | "encrypt" | "sign" | "unwrapKey" | "verify" | "wrapKey")[] | undefined;
110
+ x5c?: string[] | undefined;
111
+ x5t?: string | undefined;
112
+ 'x5t#S256'?: string | undefined;
113
+ x5u?: string | undefined;
114
+ ext?: boolean | undefined;
115
+ iat?: number | undefined;
116
+ exp?: number | undefined;
117
+ nbf?: number | undefined;
118
+ revoked?: {
119
+ revoked_at: number;
120
+ reason?: string | undefined;
121
+ } | undefined;
122
+ kty: "OKP";
123
+ alg?: "EdDSA" | undefined;
124
+ crv: "Ed25519" | "Ed448";
125
+ x: string;
126
+ d?: string | undefined;
127
+ } | {
128
+ kid?: string | undefined;
129
+ use?: "enc" | "sig" | undefined;
130
+ key_ops?: ("decrypt" | "deriveBits" | "deriveKey" | "encrypt" | "sign" | "unwrapKey" | "verify" | "wrapKey")[] | undefined;
131
+ x5c?: string[] | undefined;
132
+ x5t?: string | undefined;
133
+ 'x5t#S256'?: string | undefined;
134
+ x5u?: string | undefined;
135
+ ext?: boolean | undefined;
136
+ iat?: number | undefined;
137
+ exp?: number | undefined;
138
+ nbf?: number | undefined;
139
+ revoked?: {
140
+ revoked_at: number;
141
+ reason?: string | undefined;
142
+ } | undefined;
143
+ kty: "oct";
144
+ alg?: "HS256" | "HS384" | "HS512" | undefined;
145
+ k: string;
146
+ })[];
147
+ } | undefined;
148
+ application_type?: "native" | "web" | undefined;
149
+ subject_type?: "pairwise" | "public" | undefined;
150
+ request_object_signing_alg?: string | undefined;
151
+ id_token_signed_response_alg?: string | undefined;
152
+ authorization_signed_response_alg?: string | undefined;
153
+ authorization_encrypted_response_enc?: "A128CBC-HS256" | undefined;
154
+ authorization_encrypted_response_alg?: string | undefined;
155
+ client_id?: string | undefined;
156
+ client_name?: string | undefined;
157
+ client_uri?: string | undefined;
158
+ policy_uri?: string | undefined;
159
+ tos_uri?: string | undefined;
160
+ logo_uri?: string | undefined;
161
+ default_max_age?: number | undefined;
162
+ require_auth_time?: boolean | undefined;
163
+ contacts?: string[] | undefined;
164
+ tls_client_certificate_bound_access_tokens?: boolean | undefined;
165
+ dpop_bound_access_tokens?: boolean | undefined;
166
+ authorization_details_types?: string[] | undefined;
167
+ };
168
+ //# sourceMappingURL=build-client-metadata.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-client-metadata.d.ts","sourceRoot":"","sources":["../lib/build-client-metadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AASnD;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsD/B,CAAC"}
@@ -0,0 +1,53 @@
1
+ import { FALLBACK_ALG } from './constants.js';
2
+ import { confidentialClientMetadataSchema, } from './schemas/atcute-confidential-client-metadata.js';
3
+ /**
4
+ * builds an atproto client metadata
5
+ *
6
+ *
7
+ * @param input client metadata
8
+ * @param keyset available keys
9
+ * @returns built client metadata
10
+ */
11
+ export const buildClientMetadata = (input, keyset) => {
12
+ // validate user-facing schema is correct
13
+ const conf = confidentialClientMetadataSchema.parse(input, { mode: 'passthrough' });
14
+ // build full OAuth client metadata (atproto defaults and requirements)
15
+ const metadata = {
16
+ client_id: conf.client_id,
17
+ client_name: conf.client_name,
18
+ client_uri: conf.client_uri,
19
+ policy_uri: conf.policy_uri,
20
+ tos_uri: conf.tos_uri,
21
+ logo_uri: conf.logo_uri,
22
+ redirect_uris: conf.redirect_uris,
23
+ scope: Array.isArray(conf.scope) ? conf.scope.join(' ') : conf.scope,
24
+ application_type: 'web',
25
+ subject_type: 'public',
26
+ response_types: ['code'],
27
+ grant_types: ['authorization_code', 'refresh_token'],
28
+ token_endpoint_auth_method: 'private_key_jwt',
29
+ token_endpoint_auth_signing_alg: FALLBACK_ALG,
30
+ dpop_bound_access_tokens: true,
31
+ jwks_uri: conf.jwks_uri,
32
+ jwks: conf.jwks_uri ? undefined : keyset.publicJwks,
33
+ };
34
+ // ensure at least one key supports the fallback algorithm
35
+ const signingKeys = Array.from(keyset);
36
+ if (!signingKeys.some((key) => key.alg === FALLBACK_ALG)) {
37
+ throw new TypeError(`"private_key_jwt" requires at least one "${FALLBACK_ALG}" signing key`);
38
+ }
39
+ // if jwks provided inline, ensure ALL signing keys are present
40
+ if (metadata.jwks) {
41
+ const jwksKids = new Set(metadata.jwks.keys
42
+ .filter((k) => !k.revoked)
43
+ .map((k) => k.kid)
44
+ .filter(Boolean));
45
+ for (const key of signingKeys) {
46
+ if (!jwksKids.has(key.kid)) {
47
+ throw new TypeError(`signing key "${key.kid}" not found in jwks`);
48
+ }
49
+ }
50
+ }
51
+ return metadata;
52
+ };
53
+ //# sourceMappingURL=build-client-metadata.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-client-metadata.js","sourceRoot":"","sources":["../lib/build-client-metadata.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EACN,gCAAgC,GAEhC,MAAM,kDAAkD,CAAC;AAG1D;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAClC,KAAiC,EACjC,MAAc,EACQ,EAAE,CAAC;IACzB,yCAAyC;IACzC,MAAM,IAAI,GAAG,gCAAgC,CAAC,KAAK,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,CAAC;IAEpF,uEAAuE;IACvE,MAAM,QAAQ,GAAwB;QACrC,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,aAAa,EAAE,IAAI,CAAC,aAAa;QACjC,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK;QAEpE,gBAAgB,EAAE,K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B,CAAC"}
@@ -0,0 +1,5 @@
1
+ /** default algorithm per atproto spec */
2
+ export declare const FALLBACK_ALG = "ES256";
3
+ /** JWT bearer assertion type for `private_key_jwt` authentication */
4
+ export declare const CLIENT_ASSERTION_TYPE_JWT_BEARER = "urn:ietf:params:oauth:client-assertion-type:jwt-bearer";
5
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../lib/constants.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,eAAO,MAAM,YAAY,UAAU,CAAC;AAEpC,qEAAqE;AACrE,eAAO,MAAM,gCAAgC,2DAA2D,CAAC"}
@@ -0,0 +1,5 @@
1
+ /** default algorithm per atproto spec */
2
+ export const FALLBACK_ALG = 'ES256';
3
+ /** JWT bearer assertion type for `private_key_jwt` authentication */
4
+ export const CLIENT_ASSERTION_TYPE_JWT_BEARER = 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer';
5
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../lib/constants.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,MAAM,CAAC,MAAM,YAAY,GAAG,OAAO,CAAC;AAEpC,qEAAqE;AACrE,MAAM,CAAC,MAAM,gCAAgC,GAAG,wDAAwD,CAAC"}
@@ -0,0 +1,31 @@
1
+ export { buildClientMetadata } from './build-client-metadata.js';
2
+ export { CLIENT_ASSERTION_TYPE_JWT_BEARER, FALLBACK_ALG } from './constants.js';
3
+ export * as scope from './scope.js';
4
+ export { confidentialClientMetadataSchema, type ConfidentialClientMetadata, } from './schemas/atcute-confidential-client-metadata.js';
5
+ export { atprotoOAuthScopeSchema, ATPROTO_SCOPE_VALUE, DEFAULT_ATPROTO_OAUTH_SCOPE, type AtprotoOAuthScope, } from './schemas/atproto-oauth-scope.js';
6
+ export { jwkPubSchema, jwkSchema, keyUsageSchema, publicKeyUsageSchema, type Jwk, type JwkPub, type KeyUsage, } from './schemas/jwk.js';
7
+ export { jwksPubSchema, jwksSchema, type Jwks, type JwksPub } from './schemas/jwks.js';
8
+ export { oauthClientIdDiscoverableSchema } from './schemas/oauth-client-id-discoverable.js';
9
+ export { oauthClientIdSchema, type OAuthClientId } from './schemas/oauth-client-id.js';
10
+ export { oauthClientMetadataSchema, type OAuthClientMetadata } from './schemas/oauth-client-metadata.js';
11
+ export { oauthEndpointAuthMethodSchema, type OAuthEndpointAuthMethod, } from './schemas/oauth-endpoint-auth-method.js';
12
+ export { oauthGrantTypeSchema, type OAuthGrantType } from './schemas/oauth-grant-type.js';
13
+ export { loopbackRedirectUriSchema, oauthRedirectUriSchema, type LoopbackRedirectUri, type OAuthRedirectUri, } from './schemas/oauth-redirect-uri.js';
14
+ export { oauthResponseTypeSchema, type OAuthResponseType } from './schemas/oauth-response-type.js';
15
+ export { isOAuthScope, OAUTH_SCOPE_REGEXP, oauthScopeSchema, type OAuthScope, } from './schemas/oauth-scope.js';
16
+ export { httpsUriSchema, loopbackUriSchema, nonLocalWebUriSchema, privateUseUriSchema, urlSchema, webUriSchema, } from './schemas/uri.js';
17
+ export { extractUrlPath, isHostnameIP, isLastOccurrence, isLocalHostname, isLoopbackHost, isSpaceSeparatedValue, } from './schemas/utils.js';
18
+ export { oauthTokenTypeSchema, type OAuthTokenType } from './schemas/oauth-token-type.js';
19
+ export { oauthTokenResponseSchema, type OAuthTokenResponse } from './schemas/oauth-token-response.js';
20
+ export { atprotoOAuthTokenResponseSchema, type AtprotoOAuthTokenResponse, } from './schemas/atproto-oauth-token-response.js';
21
+ export { oauthParResponseSchema, type OAuthParResponse } from './schemas/oauth-par-response.js';
22
+ export { oauthCodeChallengeMethodSchema, type OAuthCodeChallengeMethod, } from './schemas/oauth-code-challenge-method.js';
23
+ export { oauthResponseModeSchema, type OAuthResponseMode } from './schemas/oauth-response-mode.js';
24
+ export { oauthPromptSchema, type OAuthPrompt } from './schemas/oauth-prompt.js';
25
+ export { oauthAuthorizationDetailSchema, oauthAuthorizationDetailsSchema, type OAuthAuthorizationDetail, type OAuthAuthorizationDetails, } from './schemas/oauth-authorization-details.js';
26
+ export { oauthIssuerIdentifierSchema, type OAuthIssuerIdentifier, } from './schemas/oauth-issuer-identifier.js';
27
+ export { oauthAuthorizationServerMetadataSchema, oauthAuthorizationServerMetadataValidator, type OAuthAuthorizationServerMetadata, } from './schemas/oauth-authorization-server-metadata.js';
28
+ export { atprotoAuthorizationServerMetadataValidator, type AtprotoAuthorizationServerMetadata, } from './schemas/atproto-authorization-server-metadata.js';
29
+ export { oauthBearerMethodSchema, oauthProtectedResourceMetadataSchema, oauthProtectedResourceMetadataValidator, type OAuthBearerMethod, type OAuthProtectedResourceMetadata, } from './schemas/oauth-protected-resource-metadata.js';
30
+ export { atprotoProtectedResourceMetadataValidator, type AtprotoProtectedResourceMetadata, } from './schemas/atproto-protected-resource-metadata.js';
31
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,gCAAgC,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEhF,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AAGpC,OAAO,EACN,gCAAgC,EAChC,KAAK,0BAA0B,GAC/B,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EACN,uBAAuB,EACvB,mBAAmB,EACnB,2BAA2B,EAC3B,KAAK,iBAAiB,GACtB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACN,YAAY,EACZ,SAAS,EACT,cAAc,EACd,oBAAoB,EACpB,KAAK,GAAG,EACR,KAAK,MAAM,EACX,KAAK,QAAQ,GACb,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,KAAK,IAAI,EAAE,KAAK,OAA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0CAA0C,CAAC;AAClD,OAAO,EAAE,uBAAuB,EAAE,KAAK,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACnG,OAAO,EAAE,iBAAiB,EAAE,KAAK,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAGhF,OAAO,EACN,8BAA8B,EAC9B,+BAA+B,EAC/B,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,GAC9B,MAAM,0CAA0C,CAAC;AAGlD,OAAO,EACN,2BAA2B,EAC3B,KAAK,qBAAqB,GAC1B,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACN,sCAAsC,EACtC,yCAAyC,EACzC,KAAK,gCAAgC,GACrC,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EACN,2CAA2C,EAC3C,KAAK,kCAAkC,GACvC,MAAM,oDAAoD,CAAC;AAG5D,OAAO,EACN,uBAAuB,EACvB,oCAAoC,EACpC,uCAAuC,EACvC,KAAK,iBAAiB,EACtB,KAAK,8BAA8B,GACnC,MAAM,gDAAgD,CAAC;AACxD,OAAO,EACN,yCAAyC,EACzC,KAAK,gCAAgC,GACrC,MAAM,kDAAkD,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,37 @@
1
+ export { buildClientMetadata } from './build-client-metadata.js';
2
+ export { CLIENT_ASSERTION_TYPE_JWT_BEARER, FALLBACK_ALG } from './constants.js';
3
+ export * as scope from './scope.js';
4
+ // schemas
5
+ export { confidentialClientMetadataSchema, } from './schemas/atcute-confidential-client-metadata.js';
6
+ export { atprotoOAuthScopeSchema, ATPROTO_SCOPE_VALUE, DEFAULT_ATPROTO_OAUTH_SCOPE, } from './schemas/atproto-oauth-scope.js';
7
+ export { jwkPubSchema, jwkSchema, keyUsageSchema, publicKeyUsageSchema, } from './schemas/jwk.js';
8
+ export { jwksPubSchema, jwksSchema } from './schemas/jwks.js';
9
+ export { oauthClientIdDiscoverableSchema } from './schemas/oauth-client-id-discoverable.js';
10
+ export { oauthClientIdSchema } from './schemas/oauth-client-id.js';
11
+ export { oauthClientMetadataSchema } from './schemas/oauth-client-metadata.js';
12
+ export { oauthEndpointAuthMethodSchema, } from './schemas/oauth-endpoint-auth-method.js';
13
+ export { oauthGrantTypeSchema } from './schemas/oauth-grant-type.js';
14
+ export { loopbackRedirectUriSchema, oauthRedirectUriSchema, } from './schemas/oauth-redirect-uri.js';
15
+ export { oauthResponseTypeSchema } from './schemas/oauth-response-type.js';
16
+ export { isOAuthScope, OAUTH_SCOPE_REGEXP, oauthScopeSchema, } from './schemas/oauth-scope.js';
17
+ export { httpsUriSchema, loopbackUriSchema, nonLocalWebUriSchema, privateUseUriSchema, urlSchema, webUriSchema, } from './schemas/uri.js';
18
+ export { extractUrlPath, isHostnameIP, isLastOccurrence, isLocalHostname, isLoopbackHost, isSpaceSeparatedValue, } from './schemas/utils.js';
19
+ // token schemas
20
+ export { oauthTokenTypeSchema } from './schemas/oauth-token-type.js';
21
+ export { oauthTokenResponseSchema } from './schemas/oauth-token-response.js';
22
+ export { atprotoOAuthTokenResponseSchema, } from './schemas/atproto-oauth-token-response.js';
23
+ // PAR schemas
24
+ export { oauthParResponseSchema } from './schemas/oauth-par-response.js';
25
+ export { oauthCodeChallengeMethodSchema, } from './schemas/oauth-code-challenge-method.js';
26
+ export { oauthResponseModeSchema } from './schemas/oauth-response-mode.js';
27
+ export { oauthPromptSchema } from './schemas/oauth-prompt.js';
28
+ // authorization details
29
+ export { oauthAuthorizationDetailSchema, oauthAuthorizationDetailsSchema, } from './schemas/oauth-authorization-details.js';
30
+ // server metadata
31
+ export { oauthIssuerIdentifierSchema, } from './schemas/oauth-issuer-identifier.js';
32
+ export { oauthAuthorizationServerMetadataSchema, oauthAuthorizationServerMetadataValidator, } from './schemas/oauth-authorization-server-metadata.js';
33
+ export { atprotoAuthorizationServerMetadataValidator, } from './schemas/atproto-authorization-server-metadata.js';
34
+ // protected resource metadata
35
+ export { oauthBearerMethodSchema, oauthProtectedResourceMetadataSchema, oauthProtectedResourceMetadataValidator, } from './schemas/oauth-protected-resource-metadata.js';
36
+ export { atprotoProtectedResourceMetadataValidator, } from './schemas/atproto-protected-resource-metadata.js';
37
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,gCAAgC,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEhF,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AAEpC,UAAU;AACV,OAAO,EACN,gCAAgC,GAEhC,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EACN,uBAAuB,EACvB,mBAAmB,EACnB,2BAA2B,GAE3B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACN,YAAY,EACZ,SAAS,EACT,cAAc,EACd,oBAAoB,GAIpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,UAAU,EAA2B,MAAM,mBAAmB,CAAC;AACvF,OAAO,EAAE,+BAA+B,EAAE,MAAM,2CAA2C,CAAC;AAC5F,OAAO,EAAE,mBAAmB,EAAsB,MAAM,8BAA8B,CAAC;AACvF,OAAO,EAAE,yBAAyB,EAA4B,MAAM,oCAAoC,CAAC;AACzG,OAAO,EACN,6BAA6B,GAE7B,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAuB,MAAM,+BAA+B,CAAC;AAC1F,OAAO,EACN,yBAAyB,EACzB,sBAAsB,GAGtB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,uBAAuB,EAA0B,MAAM,kCAAkC,CAAC;AACnG,OAAO,EACN,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,GAEhB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACN,cAAc,EACd,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,EACnB,SAAS,EACT,YAAY,GACZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,qBAAqB,GACrB,MAAM,oBAAoB,CAAC;AAE5B,gBAAgB;AAChB,OAAO,EAAE,oBAAoB,EAAuB,MAAM,+BAA+B,CAAC;AAC1F,OAAO,EAAE,wBAAwB,EAA2B,MAAM,mCAAmC,CAAC;AACtG,OAAO,EACN,+BAA+B,GAE/B,MAAM,2CAA2C,CAAC;AAEnD,cAAc;AACd,OAAO,EAAE,sBAAsB,EAAyB,MAAM,iCAAiC,CAAC;AAChG,OAAO,EACN,8BAA8B,GAE9B,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAE,uBAAuB,EAA0B,MAAM,kCAAkC,CAAC;AACnG,OAAO,EAAE,iBAAiB,EAAoB,MAAM,2BAA2B,CAAC;AAEhF,wBAAwB;AACxB,OAAO,EACN,8BAA8B,EAC9B,+BAA+B,GAG/B,MAAM,0CAA0C,CAAC;AAElD,kBAAkB;AAClB,OAAO,EACN,2BAA2B,GAE3B,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACN,sCAAsC,EACtC,yCAAyC,GAEzC,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EACN,2CAA2C,GAE3C,MAAM,oDAAoD,CAAC;AAE5D,8BAA8B;AAC9B,OAAO,EACN,uBAAuB,EACvB,oCAAoC,EACpC,uCAAuC,GAGvC,MAAM,gDAAgD,CAAC;AACxD,OAAO,EACN,yCAAyC,GAEzC,MAAM,kDAAkD,CAAC"}
@@ -0,0 +1,21 @@
1
+ import * as v from '@badrap/valita';
2
+ /**
3
+ * user-facing client metadata for configuring a confidential OAuth client.
4
+ *
5
+ * this is a lean subset of OAuth client metadata, focused on what you actually provide.
6
+ * the library will fill in atproto-required values like `dpop_bound_access_tokens`,
7
+ * `token_endpoint_auth_method`, and default `grant_types` / `response_types`.
8
+ */
9
+ export declare const confidentialClientMetadataSchema: v.Type<{
10
+ client_id: string;
11
+ redirect_uris: string[];
12
+ scope: string | string[];
13
+ client_uri?: string | undefined;
14
+ client_name?: string | undefined;
15
+ policy_uri?: string | undefined;
16
+ tos_uri?: string | undefined;
17
+ logo_uri?: string | undefined;
18
+ jwks_uri?: string | undefined;
19
+ }>;
20
+ export type ConfidentialClientMetadata = v.Infer<typeof confidentialClientMetadataSchema>;
21
+ //# sourceMappingURL=atcute-confidential-client-metadata.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"atcute-confidential-client-metadata.d.ts","sourceRoot":"","sources":["../../lib/schemas/atcute-confidential-client-metadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,gBAAgB,CAAC;AAWpC;;;;;;GAMG;AACH,eAAO,MAAM,gCAAgC;;;;;;;;;;EAsH1C,CAAC;AAEJ,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAgC,CAAC,CAAC"}
@@ -0,0 +1,112 @@
1
+ import * as v from '@badrap/valita';
2
+ import { atprotoOAuthScopeSchema } from './atproto-oauth-scope.js';
3
+ import { oauthClientIdDiscoverableSchema } from './oauth-client-id-discoverable.js';
4
+ import { httpsUriSchema, nonLocalWebUriSchema, webUriSchema } from './uri.js';
5
+ import { isLocalHostname } from './utils.js';
6
+ const SINGLE_SCOPE_RE = /^[\x21\x23-\x5B\x5D-\x7E]+$/;
7
+ const singleScopeSchema = v.string().assert((input) => SINGLE_SCOPE_RE.test(input), `invalid OAuth scope`);
8
+ /**
9
+ * user-facing client metadata for configuring a confidential OAuth client.
10
+ *
11
+ * this is a lean subset of OAuth client metadata, focused on what you actually provide.
12
+ * the library will fill in atproto-required values like `dpop_bound_access_tokens`,
13
+ * `token_endpoint_auth_method`, and default `grant_types` / `response_types`.
14
+ */
15
+ export const confidentialClientMetadataSchema = v
16
+ .object({
17
+ /** discoverable https client_id URL (where metadata is hosted) */
18
+ client_id: oauthClientIdDiscoverableSchema,
19
+ /** redirect URIs for authorization responses (must be https) */
20
+ redirect_uris: v
21
+ .array(httpsUriSchema)
22
+ .assert((arr) => arr.length > 0, `must have at least one redirect URI`)
23
+ .assert((arr) => {
24
+ for (const uri of arr) {
25
+ const url = new URL(uri);
26
+ if (url.username || url.password) {
27
+ return false;
28
+ }
29
+ }
30
+ return true;
31
+ }, `redirect URIs must not contain credentials`),
32
+ /**
33
+ * OAuth scope - either:
34
+ * - a space-separated string (must include "atproto")
35
+ * - an array of scope strings ('atproto' is added automatically)
36
+ */
37
+ scope: v.union(atprotoOAuthScopeSchema.chain((input) => {
38
+ const scopes = input.split(/\s+/);
39
+ for (let i = 0, len = scopes.length; i < len; i++) {
40
+ const aka = scopes[i];
41
+ for (let j = 0; j < i; j++) {
42
+ if (aka === scopes[j]) {
43
+ return v.err(`duplicate "${aka}" scope`);
44
+ }
45
+ }
46
+ }
47
+ return v.ok(input);
48
+ }), v.array(singleScopeSchema).chain((input) => {
49
+ if (!input.includes('atproto')) {
50
+ input = ['atproto', ...input];
51
+ }
52
+ for (let i = 0, len = input.length; i < len; i++) {
53
+ const aka = input[i];
54
+ for (let j = 0; j < i; j++) {
55
+ if (aka === input[j]) {
56
+ return v.err(`duplicate "${aka}" scope`);
57
+ }
58
+ }
59
+ }
60
+ return v.ok(input);
61
+ })),
62
+ /** optional client homepage */
63
+ client_uri: webUriSchema.optional(),
64
+ /** optional display name */
65
+ client_name: v.string().optional(),
66
+ /** optional policy url */
67
+ policy_uri: nonLocalWebUriSchema.optional(),
68
+ /** optional terms of service url */
69
+ tos_uri: nonLocalWebUriSchema.optional(),
70
+ /** optional logo url */
71
+ logo_uri: nonLocalWebUriSchema.optional(),
72
+ /** optional JWKS URL; if omitted, the library will inline jwks from the keyset */
73
+ jwks_uri: httpsUriSchema.optional(),
74
+ })
75
+ .chain((input) => {
76
+ const clientIdUrl = new URL(input.client_id);
77
+ if (isLocalHostname(clientIdUrl.hostname)) {
78
+ return v.err({ message: `client_id hostname is invalid`, path: ['client_id'] });
79
+ }
80
+ if (input.jwks_uri) {
81
+ const jwksUrl = new URL(input.jwks_uri);
82
+ if (jwksUrl.username || jwksUrl.password) {
83
+ return v.err({ message: `jwks_uri must not contain credentials`, path: ['jwks_uri'] });
84
+ }
85
+ if (isLocalHostname(jwksUrl.hostname)) {
86
+ return v.err({ message: `jwks_uri hostname is invalid`, path: ['jwks_uri'] });
87
+ }
88
+ }
89
+ // for discoverable clients, client_uri (if provided) must be same-origin parent of client_id
90
+ if (input.client_uri) {
91
+ const clientUriUrl = new URL(input.client_uri);
92
+ if (isLocalHostname(clientUriUrl.hostname)) {
93
+ return v.err({ message: `client_uri hostname is invalid`, path: ['client_uri'] });
94
+ }
95
+ if (clientUriUrl.origin !== clientIdUrl.origin) {
96
+ return v.err({
97
+ message: `client_uri must have the same origin as the client_id`,
98
+ path: ['client_uri'],
99
+ });
100
+ }
101
+ if (clientIdUrl.pathname !== clientUriUrl.pathname) {
102
+ const prefix = clientUriUrl.pathname.endsWith('/')
103
+ ? clientUriUrl.pathname
104
+ : `${clientUriUrl.pathname}/`;
105
+ if (!clientIdUrl.pathname.startsWith(prefix)) {
106
+ return v.err({ message: `client_uri must be a parent URL of the client_id`, path: ['client_uri'] });
107
+ }
108
+ }
109
+ }
110
+ return v.ok(input);
111
+ });
112
+ //# sourceMappingURL=atcute-confidential-client-metadata.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"atcute-confidential-client-metadata.js","sourceRoot":"","sources":["../../lib/schemas/atcute-confidential-client-metadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,gBAAgB,CAAC;AAEpC,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,+BAA+B,EAAE,MAAM,mCAAmC,CAAC;AACpF,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC9E,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,MAAM,eAAe,GAAG,6BAA6B,CAAC;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EAAE,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;QACnF,CAAC;QAED,IAAI,YAAY,CAAC,MAAM,KAAK,WAAW,CAAC,MAAM,EAAE,CAAC;YAChD,OAAO,CAAC,CAAC,GAAG,CAAC;gBACZ,OAAO,EAAE,uDAAuD;gBAChE,IAAI,EAAE,CAAC,YAAY,CAAC;aACpB,CAAC,CAAC;QACJ,CAAC;QAED,IAAI,WAAW,CAAC,QAAQ,KAAK,YAAY,CAAC,QAAQ,EAAE,CAAC;YACpD,MAAM,MAAM,GAAG,YAAY,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC;gBACjD,CAAC,CAAC,YAAY,CAAC,QAAQ;gBACvB,CAAC,CAAC,GAAG,YAAY,CAAC,QAAQ,GAAG,CAAC;YAE/B,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;gBAC9C,OAAO,CAAC,CAAC,GAAG,CAAC,EAAE,OAAO,EAAE,kDAAkD,EAAE,IAAI,EAAE,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;YACrG,CAAC;QACF,CAAC;IACF,CAAC;IAED,OAAO,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;AAAA,CACnB,CAAC,CAAC"}
@@ -0,0 +1,55 @@
1
+ import * as v from '@badrap/valita';
2
+ /**
3
+ * AT Protocol authorization server metadata with required fields and assertions.
4
+ *
5
+ * @see {@link https://atproto.com/specs/oauth}
6
+ */
7
+ export declare const atprotoAuthorizationServerMetadataValidator: v.Type<{
8
+ issuer: string;
9
+ claims_supported?: string[] | undefined;
10
+ claims_locales_supported?: string[] | undefined;
11
+ claims_parameter_supported?: boolean | undefined;
12
+ request_parameter_supported?: boolean | undefined;
13
+ request_uri_parameter_supported?: boolean | undefined;
14
+ require_request_uri_registration?: boolean | undefined;
15
+ scopes_supported?: string[] | undefined;
16
+ subject_types_supported?: string[] | undefined;
17
+ response_types_supported?: string[] | undefined;
18
+ response_modes_supported?: string[] | undefined;
19
+ grant_types_supported?: string[] | undefined;
20
+ code_challenge_methods_supported?: ("S256" | "plain")[] | undefined;
21
+ ui_locales_supported?: string[] | undefined;
22
+ id_token_signing_alg_values_supported?: string[] | undefined;
23
+ display_values_supported?: string[] | undefined;
24
+ prompt_values_supported?: ("consent" | "create" | "login" | "none" | "select_account")[] | undefined;
25
+ request_object_signing_alg_values_supported?: string[] | undefined;
26
+ authorization_response_iss_parameter_supported?: boolean | undefined;
27
+ authorization_details_types_supported?: string[] | undefined;
28
+ request_object_encryption_alg_values_supported?: string[] | undefined;
29
+ request_object_encryption_enc_values_supported?: string[] | undefined;
30
+ jwks_uri?: string | undefined;
31
+ authorization_endpoint: string;
32
+ token_endpoint: string;
33
+ token_endpoint_auth_methods_supported?: string[] | undefined;
34
+ token_endpoint_auth_signing_alg_values_supported?: string[] | undefined;
35
+ revocation_endpoint?: string | undefined;
36
+ revocation_endpoint_auth_methods_supported?: string[] | undefined;
37
+ revocation_endpoint_auth_signing_alg_values_supported?: string[] | undefined;
38
+ introspection_endpoint?: string | undefined;
39
+ introspection_endpoint_auth_methods_supported?: string[] | undefined;
40
+ introspection_endpoint_auth_signing_alg_values_supported?: string[] | undefined;
41
+ pushed_authorization_request_endpoint?: string | undefined;
42
+ pushed_authorization_request_endpoint_auth_methods_supported?: string[] | undefined;
43
+ pushed_authorization_request_endpoint_auth_signing_alg_values_supported?: string[] | undefined;
44
+ require_pushed_authorization_requests?: boolean | undefined;
45
+ userinfo_endpoint?: string | undefined;
46
+ end_session_endpoint?: string | undefined;
47
+ registration_endpoint?: string | undefined;
48
+ dpop_signing_alg_values_supported?: string[] | undefined;
49
+ protected_resources?: string[] | undefined;
50
+ client_id_metadata_document_supported?: boolean | undefined;
51
+ } & {
52
+ pushed_authorization_request_endpoint: string;
53
+ }>;
54
+ export type AtprotoAuthorizationServerMetadata = v.Infer<typeof atprotoAuthorizationServerMetadataValidator>;
55
+ //# sourceMappingURL=atproto-authorization-server-metadata.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"atproto-authorization-server-metadata.d.ts","sourceRoot":"","sources":["../../lib/schemas/atproto-authorization-server-metadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,gBAAgB,CAAC;AAIpC;;;;GAIG;AACH,eAAO,MAAM,2CAA2C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoBvD,CAAC;AAEF,MAAM,MAAM,kCAAkC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2CAA2C,CAAC,CAAC"}
@@ -0,0 +1,25 @@
1
+ import * as v from '@badrap/valita';
2
+ import { oauthAuthorizationServerMetadataValidator } from './oauth-authorization-server-metadata.js';
3
+ /**
4
+ * AT Protocol authorization server metadata with required fields and assertions.
5
+ *
6
+ * @see {@link https://atproto.com/specs/oauth}
7
+ */
8
+ export const atprotoAuthorizationServerMetadataValidator = oauthAuthorizationServerMetadataValidator.chain((data) => {
9
+ // atproto requires client_id_metadata_document support
10
+ if (data.client_id_metadata_document_supported !== true) {
11
+ return v.err({
12
+ message: `atproto requires client_id_metadata_document_supported to be true`,
13
+ path: ['client_id_metadata_document_supported'],
14
+ });
15
+ }
16
+ // atproto requires PAR
17
+ if (!data.pushed_authorization_request_endpoint) {
18
+ return v.err({
19
+ message: `atproto requires pushed_authorization_request_endpoint to be true`,
20
+ path: ['pushed_authorization_request_endpoint'],
21
+ });
22
+ }
23
+ return v.ok(data);
24
+ });
25
+ //# sourceMappingURL=atproto-authorization-server-metadata.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"atproto-authorization-server-metadata.js","sourceRoot":"","sources":["../../lib/schemas/atproto-authorization-server-metadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,gBAAgB,CAAC;AAEpC,OAAO,EAAE,yCAAyC,EAAE,MAAM,0CAA0C,CAAC;AAErG;;;;GAIG;AACH,MAAM,CAAC,MAAM,2CAA2C,GAAG,yCAAyC,CAAC,KAAK,CACzG,CAAC,IAAI,EAAE,EAAE,CAAC;IACT,uDAAuD;IACvD,IAAI,IAAI,CAAC,qCAAqC,KAAK,IAAI,EAAE,CAAC;QACzD,OAAO,CAAC,CAAC,GAAG,CAAC;YACZ,OAAO,EAAE,mEAAmE;YAC5E,IAAI,EAAE,CAAC,uCAAuC,CAAC;SAC/C,CAAC,CAAC;IACJ,CAAC;IAED,uBAAuB;IACvB,IAAI,CAAC,IAAI,CAAC,qCAAqC,EAAE,CAAC;QACjD,OAAO,CAAC,CAAC,GAAG,CAAC;YACZ,OAAO,EAAE,mEAAmE;YAC5E,IAAI,EAAE,CAAC,uCAAuC,CAAC;SAC/C,CAAC,CAAC;IACJ,CAAC;IAED,OAAO,CAAC,CAAC,EAAE,CAAC,IAAuE,CAAC,CAAC;AAAA,CACrF,CACD,CAAC"}