@atcute/oauth-types 0.1.0 → 1.0.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.
- package/README.md +6 -5
- package/dist/build-client-metadata.d.ts +18 -160
- package/dist/build-client-metadata.d.ts.map +1 -1
- package/dist/build-client-metadata.js +73 -3
- package/dist/build-client-metadata.js.map +1 -1
- package/dist/index.d.ts +31 -30
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/schemas/atcute-client-shared.d.ts +8 -0
- package/dist/schemas/atcute-client-shared.d.ts.map +1 -0
- package/dist/schemas/atcute-client-shared.js +15 -0
- package/dist/schemas/atcute-client-shared.js.map +1 -0
- package/dist/schemas/atcute-confidential-client-metadata.d.ts +228 -4
- package/dist/schemas/atcute-confidential-client-metadata.d.ts.map +1 -1
- package/dist/schemas/atcute-confidential-client-metadata.js +48 -88
- package/dist/schemas/atcute-confidential-client-metadata.js.map +1 -1
- package/dist/schemas/atcute-public-client-metadata.d.ts +95 -0
- package/dist/schemas/atcute-public-client-metadata.d.ts.map +1 -0
- package/dist/schemas/atcute-public-client-metadata.js +74 -0
- package/dist/schemas/atcute-public-client-metadata.js.map +1 -0
- package/dist/schemas/atproto-authorization-server-metadata.d.ts +786 -4
- package/dist/schemas/atproto-authorization-server-metadata.d.ts.map +1 -1
- package/dist/schemas/atproto-authorization-server-metadata.js +2 -18
- package/dist/schemas/atproto-authorization-server-metadata.js.map +1 -1
- package/dist/schemas/atproto-oauth-scope.d.ts +3 -3
- package/dist/schemas/atproto-oauth-scope.d.ts.map +1 -1
- package/dist/schemas/atproto-oauth-scope.js +2 -2
- package/dist/schemas/atproto-oauth-scope.js.map +1 -1
- package/dist/schemas/atproto-oauth-token-response.d.ts +17 -17
- package/dist/schemas/atproto-oauth-token-response.d.ts.map +1 -1
- package/dist/schemas/atproto-oauth-token-response.js +6 -6
- package/dist/schemas/atproto-oauth-token-response.js.map +1 -1
- package/dist/schemas/atproto-protected-resource-metadata.d.ts +100 -4
- package/dist/schemas/atproto-protected-resource-metadata.d.ts.map +1 -1
- package/dist/schemas/atproto-protected-resource-metadata.js +2 -11
- package/dist/schemas/atproto-protected-resource-metadata.js.map +1 -1
- package/dist/schemas/jwk.d.ts +4289 -42
- package/dist/schemas/jwk.d.ts.map +1 -1
- package/dist/schemas/jwk.js +58 -91
- package/dist/schemas/jwk.js.map +1 -1
- package/dist/schemas/jwks.d.ts +87 -42
- package/dist/schemas/jwks.d.ts.map +1 -1
- package/dist/schemas/jwks.js +13 -29
- package/dist/schemas/jwks.js.map +1 -1
- package/dist/schemas/oauth-authorization-details.d.ts +18 -18
- package/dist/schemas/oauth-authorization-details.d.ts.map +1 -1
- package/dist/schemas/oauth-authorization-details.js +7 -7
- package/dist/schemas/oauth-authorization-details.js.map +1 -1
- package/dist/schemas/oauth-authorization-server-metadata.d.ts +462 -48
- package/dist/schemas/oauth-authorization-server-metadata.d.ts.map +1 -1
- package/dist/schemas/oauth-authorization-server-metadata.js +46 -65
- package/dist/schemas/oauth-authorization-server-metadata.js.map +1 -1
- package/dist/schemas/oauth-client-id-discoverable.d.ts +2 -2
- package/dist/schemas/oauth-client-id-discoverable.d.ts.map +1 -1
- package/dist/schemas/oauth-client-id-discoverable.js +20 -22
- package/dist/schemas/oauth-client-id-discoverable.js.map +1 -1
- package/dist/schemas/oauth-client-id.d.ts +3 -3
- package/dist/schemas/oauth-client-id.d.ts.map +1 -1
- package/dist/schemas/oauth-client-id.js +2 -2
- package/dist/schemas/oauth-client-id.js.map +1 -1
- package/dist/schemas/oauth-client-metadata.d.ts +73 -51
- package/dist/schemas/oauth-client-metadata.d.ts.map +1 -1
- package/dist/schemas/oauth-client-metadata.js +33 -40
- package/dist/schemas/oauth-client-metadata.js.map +1 -1
- package/dist/schemas/oauth-code-challenge-method.d.ts +3 -3
- package/dist/schemas/oauth-code-challenge-method.d.ts.map +1 -1
- package/dist/schemas/oauth-code-challenge-method.js +2 -2
- package/dist/schemas/oauth-code-challenge-method.js.map +1 -1
- package/dist/schemas/oauth-endpoint-auth-method.d.ts +3 -3
- package/dist/schemas/oauth-endpoint-auth-method.d.ts.map +1 -1
- package/dist/schemas/oauth-endpoint-auth-method.js +10 -2
- package/dist/schemas/oauth-endpoint-auth-method.js.map +1 -1
- package/dist/schemas/oauth-grant-type.d.ts +3 -3
- package/dist/schemas/oauth-grant-type.d.ts.map +1 -1
- package/dist/schemas/oauth-grant-type.js +10 -3
- package/dist/schemas/oauth-grant-type.js.map +1 -1
- package/dist/schemas/oauth-issuer-identifier.d.ts +3 -3
- package/dist/schemas/oauth-issuer-identifier.d.ts.map +1 -1
- package/dist/schemas/oauth-issuer-identifier.js +16 -9
- package/dist/schemas/oauth-issuer-identifier.js.map +1 -1
- package/dist/schemas/oauth-par-response.d.ts +5 -5
- package/dist/schemas/oauth-par-response.d.ts.map +1 -1
- package/dist/schemas/oauth-par-response.js +3 -3
- package/dist/schemas/oauth-par-response.js.map +1 -1
- package/dist/schemas/oauth-prompt.d.ts +3 -3
- package/dist/schemas/oauth-prompt.d.ts.map +1 -1
- package/dist/schemas/oauth-prompt.js +2 -2
- package/dist/schemas/oauth-prompt.js.map +1 -1
- package/dist/schemas/oauth-protected-resource-metadata.d.ts +88 -16
- package/dist/schemas/oauth-protected-resource-metadata.d.ts.map +1 -1
- package/dist/schemas/oauth-protected-resource-metadata.js +14 -26
- package/dist/schemas/oauth-protected-resource-metadata.js.map +1 -1
- package/dist/schemas/oauth-redirect-uri.d.ts +5 -5
- package/dist/schemas/oauth-redirect-uri.d.ts.map +1 -1
- package/dist/schemas/oauth-redirect-uri.js +3 -16
- package/dist/schemas/oauth-redirect-uri.js.map +1 -1
- package/dist/schemas/oauth-response-mode.d.ts +3 -3
- package/dist/schemas/oauth-response-mode.d.ts.map +1 -1
- package/dist/schemas/oauth-response-mode.js +2 -2
- package/dist/schemas/oauth-response-mode.js.map +1 -1
- package/dist/schemas/oauth-response-type.d.ts +3 -3
- package/dist/schemas/oauth-response-type.d.ts.map +1 -1
- package/dist/schemas/oauth-response-type.js +13 -7
- package/dist/schemas/oauth-response-type.js.map +1 -1
- package/dist/schemas/oauth-scope.d.ts +3 -3
- package/dist/schemas/oauth-scope.d.ts.map +1 -1
- package/dist/schemas/oauth-scope.js +2 -2
- package/dist/schemas/oauth-scope.js.map +1 -1
- package/dist/schemas/oauth-token-response.d.ts +17 -17
- package/dist/schemas/oauth-token-response.d.ts.map +1 -1
- package/dist/schemas/oauth-token-response.js +7 -7
- package/dist/schemas/oauth-token-response.js.map +1 -1
- package/dist/schemas/oauth-token-type.d.ts +3 -3
- package/dist/schemas/oauth-token-type.d.ts.map +1 -1
- package/dist/schemas/oauth-token-type.js +8 -7
- package/dist/schemas/oauth-token-type.js.map +1 -1
- package/dist/schemas/uri.d.ts +7 -7
- package/dist/schemas/uri.d.ts.map +1 -1
- package/dist/schemas/uri.js +44 -44
- package/dist/schemas/uri.js.map +1 -1
- package/dist/schemas/utils.d.ts.map +1 -1
- package/dist/schemas/utils.js.map +1 -1
- package/dist/scope.d.ts.map +1 -1
- package/dist/scope.js.map +1 -1
- package/lib/build-client-metadata.ts +92 -6
- package/lib/index.ts +38 -30
- package/lib/schemas/atcute-client-shared.ts +25 -0
- package/lib/schemas/atcute-confidential-client-metadata.ts +81 -111
- package/lib/schemas/atcute-public-client-metadata.ts +101 -0
- package/lib/schemas/atproto-authorization-server-metadata.ts +22 -23
- package/lib/schemas/atproto-oauth-scope.ts +8 -5
- package/lib/schemas/atproto-oauth-token-response.ts +10 -9
- package/lib/schemas/atproto-protected-resource-metadata.ts +15 -15
- package/lib/schemas/jwk.ts +104 -120
- package/lib/schemas/jwks.ts +28 -40
- package/lib/schemas/oauth-authorization-details.ts +10 -10
- package/lib/schemas/oauth-authorization-server-metadata.ts +72 -74
- package/lib/schemas/oauth-client-id-discoverable.ts +43 -48
- package/lib/schemas/oauth-client-id.ts +3 -3
- package/lib/schemas/oauth-client-metadata.ts +45 -49
- package/lib/schemas/oauth-code-challenge-method.ts +3 -3
- package/lib/schemas/oauth-endpoint-auth-method.ts +11 -11
- package/lib/schemas/oauth-grant-type.ts +11 -11
- package/lib/schemas/oauth-issuer-identifier.ts +35 -27
- package/lib/schemas/oauth-par-response.ts +4 -4
- package/lib/schemas/oauth-prompt.ts +3 -9
- package/lib/schemas/oauth-protected-resource-metadata.ts +26 -35
- package/lib/schemas/oauth-redirect-uri.ts +15 -23
- package/lib/schemas/oauth-response-mode.ts +3 -7
- package/lib/schemas/oauth-response-type.ts +12 -12
- package/lib/schemas/oauth-scope.ts +3 -3
- package/lib/schemas/oauth-token-response.ts +10 -10
- package/lib/schemas/oauth-token-type.ts +16 -12
- package/lib/schemas/uri.ts +89 -76
- package/package.json +9 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../lib/schemas/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,cAAc
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../lib/schemas/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,cAAc,aAAc,MAAM,KAAG,OAEjD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,aAAc,MAAM,KAAG,OAU/C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,eAAe,aAAc,MAAM,KAAG,OAQlD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,cAAc,QAAS,MAAM,KAAG,MA4B5C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAAI,CAAC,QAAQ,CAAC,SAAS,MAAM,SAAS,SAAS,CAAC,EAAE,KAAG,OAEjF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,UAAW,MAAM,SAAS,MAAM,KAAG,OA2BpE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../lib/schemas/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,QAAgB,EAAW,EAAE
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../lib/schemas/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,QAAgB,EAAW,EAAE;IAC3D,OAAO,QAAQ,KAAK,WAAW,IAAI,QAAQ,KAAK,WAAW,IAAI,QAAQ,KAAK,OAAO,CAAC;AACrF,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,QAAgB,EAAW,EAAE;IACzD,OAAO;IACP,IAAI,sBAAsB,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC3C,OAAO,IAAI,CAAC;IACb,CAAC;IACD,OAAO;IACP,IAAI,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QACxD,OAAO,IAAI,CAAC;IACb,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,QAAgB,EAAW,EAAE;IAC5D,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAClC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,OAAO,IAAI,CAAC;IACb,CAAC;IAED,MAAM,GAAG,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAE,CAAC,WAAW,EAAE,CAAC;IACxC,OAAO,GAAG,KAAK,MAAM,IAAI,GAAG,KAAK,OAAO,IAAI,GAAG,KAAK,WAAW,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,SAAS,CAAC;AAC3G,CAAC,CAAC;A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|
package/dist/scope.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../lib/scope.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAErE,0BAA0B;AAC1B,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAExD,yBAAyB;AACzB,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC;AAEtD,sBAAsB;AACtB,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,QAAQ,CAAC;AAE9C,0BAA0B;AAC1B,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,GAAG,CAAC;AAE1C,8CAA8C;AAC9C,MAAM,MAAM,eAAe,GAAG,IAAI,GAAG,GAAG,CAAC;AAEzC,kDAAkD;AAClD,MAAM,MAAM,QAAQ,GAAG,IAAI,GAAG,GAAG,CAAC;AAElC,wDAAwD;AACxD,MAAM,MAAM,QAAQ,GAAG,eAAe,GAAG,GAAG,CAAC;AAE7C,MAAM,WAAW,WAAW;IAC3B,wCAAwC;IACxC,UAAU,EAAE,eAAe,EAAE,CAAC;IAC9B,gEAAgE;IAChE,MAAM,CAAC,EAAE,UAAU,EAAE,CAAC;CACtB;AAED;;;;GAIG;AACH,eAAO,MAAM,IAAI,
|
|
1
|
+
{"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../lib/scope.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAErE,0BAA0B;AAC1B,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAExD,yBAAyB;AACzB,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC;AAEtD,sBAAsB;AACtB,MAAM,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AM,WAAW,cAAc;IAC9B,mBAAmB;IACnB,IAAI,EAAE,IAAI,CAAC;IACX,iCAAiC;IACjC,GAAG,CAAC,EAAE,eAAe,CAAC;CACtB;AAED;;;;GAIG;AACH,eAAO,MAAM,OAAO,YAAa,cAAc,KAAG,MAWjD,CAAC"}
|
package/dist/scope.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scope.js","sourceRoot":"","sources":["../lib/scope.ts"],"names":[],"mappings":"AA8BA;;;;GAIG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,OAAoB,EAAU,EAAE
|
|
1
|
+
{"version":3,"file":"scope.js","sourceRoot":"","sources":["../lib/scope.ts"],"names":[],"mappings":"AA8BA;;;;GAIG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,OAAoB,EAAU,EAAE;IACpD,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC;IAE5C,MAAM,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;IACrC,KAAK,MAAM,CAAC,IAAI,UAAU,EAAE,CAAC;QAC5B,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;IAChC,CAAC;IAED,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;QACxB,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;IAC5B,CAAC;IAED,OAAO,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AACpC,CAAC,CAAC;AASF;;;;GAIG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,OAAmB,EAAU,EAAE;IAClD,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;IAE7B,MAAM,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;IACrC,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAEvB,KAAK,MAAM,CAA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CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
import type { Keyset } from '@atcute/oauth-keyset';
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import * as v from 'valibot';
|
|
4
|
+
|
|
5
|
+
import { FALLBACK_ALG } from './constants.ts';
|
|
4
6
|
import {
|
|
5
7
|
confidentialClientMetadataSchema,
|
|
6
8
|
type ConfidentialClientMetadata,
|
|
7
|
-
} from './schemas/atcute-confidential-client-metadata.
|
|
8
|
-
import
|
|
9
|
+
} from './schemas/atcute-confidential-client-metadata.ts';
|
|
10
|
+
import {
|
|
11
|
+
publicClientMetadataSchema,
|
|
12
|
+
type PublicClientMetadata,
|
|
13
|
+
} from './schemas/atcute-public-client-metadata.ts';
|
|
14
|
+
import { DEFAULT_ATPROTO_OAUTH_SCOPE } from './schemas/atproto-oauth-scope.ts';
|
|
15
|
+
import type { OAuthClientMetadata } from './schemas/oauth-client-metadata.ts';
|
|
9
16
|
|
|
10
17
|
/**
|
|
11
|
-
* builds an atproto client metadata
|
|
12
|
-
*
|
|
18
|
+
* builds an atproto client metadata for a confidential client.
|
|
13
19
|
*
|
|
14
20
|
* @param input client metadata
|
|
15
21
|
* @param keyset available keys
|
|
@@ -20,7 +26,7 @@ export const buildClientMetadata = (
|
|
|
20
26
|
keyset: Keyset,
|
|
21
27
|
): OAuthClientMetadata => {
|
|
22
28
|
// validate user-facing schema is correct
|
|
23
|
-
const conf =
|
|
29
|
+
const conf = v.parse(confidentialClientMetadataSchema, input);
|
|
24
30
|
|
|
25
31
|
// build full OAuth client metadata (atproto defaults and requirements)
|
|
26
32
|
const metadata: OAuthClientMetadata = {
|
|
@@ -70,3 +76,83 @@ export const buildClientMetadata = (
|
|
|
70
76
|
|
|
71
77
|
return metadata;
|
|
72
78
|
};
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* builds a loopback client_id from redirect_uris and scope.
|
|
82
|
+
*
|
|
83
|
+
* @param redirectUris loopback redirect URIs
|
|
84
|
+
* @param scope OAuth scope string
|
|
85
|
+
* @returns loopback client_id URL
|
|
86
|
+
*/
|
|
87
|
+
const buildLoopbackClientId = (redirectUris: readonly string[], scope: string): string => {
|
|
88
|
+
const params = new URLSearchParams();
|
|
89
|
+
|
|
90
|
+
// only include scope if not the default
|
|
91
|
+
if (scope !== DEFAULT_ATPROTO_OAUTH_SCOPE) {
|
|
92
|
+
params.set('scope', scope);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// include redirect URIs
|
|
96
|
+
for (const uri of redirectUris) {
|
|
97
|
+
params.append('redirect_uri', uri);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (params.size > 0) {
|
|
101
|
+
return `http://localhost?${params.toString()}`;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return 'http://localhost';
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* builds an atproto client metadata for a public client.
|
|
109
|
+
*
|
|
110
|
+
* public clients use `token_endpoint_auth_method: 'none'` and don't require a keyset.
|
|
111
|
+
* per AT Protocol spec, they have shorter token lifetimes and cannot use silent sign-in.
|
|
112
|
+
*
|
|
113
|
+
* - if `client_id` is omitted: loopback client (client_id built from redirect_uris/scope)
|
|
114
|
+
* - if `client_id` is provided: discoverable public client
|
|
115
|
+
*
|
|
116
|
+
* @param input public client metadata
|
|
117
|
+
* @returns built client metadata
|
|
118
|
+
*/
|
|
119
|
+
export const buildPublicClientMetadata = (input: PublicClientMetadata): OAuthClientMetadata => {
|
|
120
|
+
const parsed = v.parse(publicClientMetadataSchema, input);
|
|
121
|
+
const scope = Array.isArray(parsed.scope) ? parsed.scope.join(' ') : parsed.scope;
|
|
122
|
+
|
|
123
|
+
if (parsed.client_id === undefined) {
|
|
124
|
+
// loopback client - server generates metadata from client_id URL
|
|
125
|
+
return {
|
|
126
|
+
client_id: buildLoopbackClientId(parsed.redirect_uris, scope),
|
|
127
|
+
redirect_uris: parsed.redirect_uris,
|
|
128
|
+
scope,
|
|
129
|
+
|
|
130
|
+
application_type: 'native',
|
|
131
|
+
response_types: ['code'],
|
|
132
|
+
grant_types: ['authorization_code', 'refresh_token'],
|
|
133
|
+
|
|
134
|
+
token_endpoint_auth_method: 'none',
|
|
135
|
+
dpop_bound_access_tokens: true,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// discoverable public client
|
|
140
|
+
return {
|
|
141
|
+
client_id: parsed.client_id,
|
|
142
|
+
client_name: parsed.client_name,
|
|
143
|
+
client_uri: parsed.client_uri,
|
|
144
|
+
policy_uri: parsed.policy_uri,
|
|
145
|
+
tos_uri: parsed.tos_uri,
|
|
146
|
+
logo_uri: parsed.logo_uri,
|
|
147
|
+
redirect_uris: parsed.redirect_uris,
|
|
148
|
+
scope,
|
|
149
|
+
|
|
150
|
+
application_type: parsed.application_type ?? 'web',
|
|
151
|
+
subject_type: 'public',
|
|
152
|
+
response_types: ['code'],
|
|
153
|
+
grant_types: ['authorization_code', 'refresh_token'],
|
|
154
|
+
|
|
155
|
+
token_endpoint_auth_method: 'none',
|
|
156
|
+
dpop_bound_access_tokens: true,
|
|
157
|
+
};
|
|
158
|
+
};
|
package/lib/index.ts
CHANGED
|
@@ -1,19 +1,27 @@
|
|
|
1
|
-
export { buildClientMetadata } from './build-client-metadata.
|
|
2
|
-
export { CLIENT_ASSERTION_TYPE_JWT_BEARER, FALLBACK_ALG } from './constants.
|
|
1
|
+
export { buildClientMetadata, buildPublicClientMetadata } from './build-client-metadata.ts';
|
|
2
|
+
export { CLIENT_ASSERTION_TYPE_JWT_BEARER, FALLBACK_ALG } from './constants.ts';
|
|
3
3
|
|
|
4
|
-
export * as scope from './scope.
|
|
4
|
+
export * as scope from './scope.ts';
|
|
5
5
|
|
|
6
6
|
// schemas
|
|
7
7
|
export {
|
|
8
8
|
confidentialClientMetadataSchema,
|
|
9
9
|
type ConfidentialClientMetadata,
|
|
10
|
-
} from './schemas/atcute-confidential-client-metadata.
|
|
10
|
+
} from './schemas/atcute-confidential-client-metadata.ts';
|
|
11
|
+
export {
|
|
12
|
+
discoverablePublicClientMetadataSchema,
|
|
13
|
+
loopbackClientMetadataSchema,
|
|
14
|
+
publicClientMetadataSchema,
|
|
15
|
+
type DiscoverablePublicClientMetadata,
|
|
16
|
+
type LoopbackClientMetadata,
|
|
17
|
+
type PublicClientMetadata,
|
|
18
|
+
} from './schemas/atcute-public-client-metadata.ts';
|
|
11
19
|
export {
|
|
12
20
|
atprotoOAuthScopeSchema,
|
|
13
21
|
ATPROTO_SCOPE_VALUE,
|
|
14
22
|
DEFAULT_ATPROTO_OAUTH_SCOPE,
|
|
15
23
|
type AtprotoOAuthScope,
|
|
16
|
-
} from './schemas/atproto-oauth-scope.
|
|
24
|
+
} from './schemas/atproto-oauth-scope.ts';
|
|
17
25
|
export {
|
|
18
26
|
jwkPubSchema,
|
|
19
27
|
jwkSchema,
|
|
@@ -22,29 +30,29 @@ export {
|
|
|
22
30
|
type Jwk,
|
|
23
31
|
type JwkPub,
|
|
24
32
|
type KeyUsage,
|
|
25
|
-
} from './schemas/jwk.
|
|
26
|
-
export { jwksPubSchema, jwksSchema, type Jwks, type JwksPub } from './schemas/jwks.
|
|
27
|
-
export { oauthClientIdDiscoverableSchema } from './schemas/oauth-client-id-discoverable.
|
|
28
|
-
export { oauthClientIdSchema, type OAuthClientId } from './schemas/oauth-client-id.
|
|
29
|
-
export { oauthClientMetadataSchema, type OAuthClientMetadata } from './schemas/oauth-client-metadata.
|
|
33
|
+
} from './schemas/jwk.ts';
|
|
34
|
+
export { jwksPubSchema, jwksSchema, type Jwks, type JwksPub } from './schemas/jwks.ts';
|
|
35
|
+
export { oauthClientIdDiscoverableSchema } from './schemas/oauth-client-id-discoverable.ts';
|
|
36
|
+
export { oauthClientIdSchema, type OAuthClientId } from './schemas/oauth-client-id.ts';
|
|
37
|
+
export { oauthClientMetadataSchema, type OAuthClientMetadata } from './schemas/oauth-client-metadata.ts';
|
|
30
38
|
export {
|
|
31
39
|
oauthEndpointAuthMethodSchema,
|
|
32
40
|
type OAuthEndpointAuthMethod,
|
|
33
|
-
} from './schemas/oauth-endpoint-auth-method.
|
|
34
|
-
export { oauthGrantTypeSchema, type OAuthGrantType } from './schemas/oauth-grant-type.
|
|
41
|
+
} from './schemas/oauth-endpoint-auth-method.ts';
|
|
42
|
+
export { oauthGrantTypeSchema, type OAuthGrantType } from './schemas/oauth-grant-type.ts';
|
|
35
43
|
export {
|
|
36
44
|
loopbackRedirectUriSchema,
|
|
37
45
|
oauthRedirectUriSchema,
|
|
38
46
|
type LoopbackRedirectUri,
|
|
39
47
|
type OAuthRedirectUri,
|
|
40
|
-
} from './schemas/oauth-redirect-uri.
|
|
41
|
-
export { oauthResponseTypeSchema, type OAuthResponseType } from './schemas/oauth-response-type.
|
|
48
|
+
} from './schemas/oauth-redirect-uri.ts';
|
|
49
|
+
export { oauthResponseTypeSchema, type OAuthResponseType } from './schemas/oauth-response-type.ts';
|
|
42
50
|
export {
|
|
43
51
|
isOAuthScope,
|
|
44
52
|
OAUTH_SCOPE_REGEXP,
|
|
45
53
|
oauthScopeSchema,
|
|
46
54
|
type OAuthScope,
|
|
47
|
-
} from './schemas/oauth-scope.
|
|
55
|
+
} from './schemas/oauth-scope.ts';
|
|
48
56
|
export {
|
|
49
57
|
httpsUriSchema,
|
|
50
58
|
loopbackUriSchema,
|
|
@@ -52,7 +60,7 @@ export {
|
|
|
52
60
|
privateUseUriSchema,
|
|
53
61
|
urlSchema,
|
|
54
62
|
webUriSchema,
|
|
55
|
-
} from './schemas/uri.
|
|
63
|
+
} from './schemas/uri.ts';
|
|
56
64
|
export {
|
|
57
65
|
extractUrlPath,
|
|
58
66
|
isHostnameIP,
|
|
@@ -60,24 +68,24 @@ export {
|
|
|
60
68
|
isLocalHostname,
|
|
61
69
|
isLoopbackHost,
|
|
62
70
|
isSpaceSeparatedValue,
|
|
63
|
-
} from './schemas/utils.
|
|
71
|
+
} from './schemas/utils.ts';
|
|
64
72
|
|
|
65
73
|
// token schemas
|
|
66
|
-
export { oauthTokenTypeSchema, type OAuthTokenType } from './schemas/oauth-token-type.
|
|
67
|
-
export { oauthTokenResponseSchema, type OAuthTokenResponse } from './schemas/oauth-token-response.
|
|
74
|
+
export { oauthTokenTypeSchema, type OAuthTokenType } from './schemas/oauth-token-type.ts';
|
|
75
|
+
export { oauthTokenResponseSchema, type OAuthTokenResponse } from './schemas/oauth-token-response.ts';
|
|
68
76
|
export {
|
|
69
77
|
atprotoOAuthTokenResponseSchema,
|
|
70
78
|
type AtprotoOAuthTokenResponse,
|
|
71
|
-
} from './schemas/atproto-oauth-token-response.
|
|
79
|
+
} from './schemas/atproto-oauth-token-response.ts';
|
|
72
80
|
|
|
73
81
|
// PAR schemas
|
|
74
|
-
export { oauthParResponseSchema, type OAuthParResponse } from './schemas/oauth-par-response.
|
|
82
|
+
export { oauthParResponseSchema, type OAuthParResponse } from './schemas/oauth-par-response.ts';
|
|
75
83
|
export {
|
|
76
84
|
oauthCodeChallengeMethodSchema,
|
|
77
85
|
type OAuthCodeChallengeMethod,
|
|
78
|
-
} from './schemas/oauth-code-challenge-method.
|
|
79
|
-
export { oauthResponseModeSchema, type OAuthResponseMode } from './schemas/oauth-response-mode.
|
|
80
|
-
export { oauthPromptSchema, type OAuthPrompt } from './schemas/oauth-prompt.
|
|
86
|
+
} from './schemas/oauth-code-challenge-method.ts';
|
|
87
|
+
export { oauthResponseModeSchema, type OAuthResponseMode } from './schemas/oauth-response-mode.ts';
|
|
88
|
+
export { oauthPromptSchema, type OAuthPrompt } from './schemas/oauth-prompt.ts';
|
|
81
89
|
|
|
82
90
|
// authorization details
|
|
83
91
|
export {
|
|
@@ -85,22 +93,22 @@ export {
|
|
|
85
93
|
oauthAuthorizationDetailsSchema,
|
|
86
94
|
type OAuthAuthorizationDetail,
|
|
87
95
|
type OAuthAuthorizationDetails,
|
|
88
|
-
} from './schemas/oauth-authorization-details.
|
|
96
|
+
} from './schemas/oauth-authorization-details.ts';
|
|
89
97
|
|
|
90
98
|
// server metadata
|
|
91
99
|
export {
|
|
92
100
|
oauthIssuerIdentifierSchema,
|
|
93
101
|
type OAuthIssuerIdentifier,
|
|
94
|
-
} from './schemas/oauth-issuer-identifier.
|
|
102
|
+
} from './schemas/oauth-issuer-identifier.ts';
|
|
95
103
|
export {
|
|
96
104
|
oauthAuthorizationServerMetadataSchema,
|
|
97
105
|
oauthAuthorizationServerMetadataValidator,
|
|
98
106
|
type OAuthAuthorizationServerMetadata,
|
|
99
|
-
} from './schemas/oauth-authorization-server-metadata.
|
|
107
|
+
} from './schemas/oauth-authorization-server-metadata.ts';
|
|
100
108
|
export {
|
|
101
109
|
atprotoAuthorizationServerMetadataValidator,
|
|
102
110
|
type AtprotoAuthorizationServerMetadata,
|
|
103
|
-
} from './schemas/atproto-authorization-server-metadata.
|
|
111
|
+
} from './schemas/atproto-authorization-server-metadata.ts';
|
|
104
112
|
|
|
105
113
|
// protected resource metadata
|
|
106
114
|
export {
|
|
@@ -109,8 +117,8 @@ export {
|
|
|
109
117
|
oauthProtectedResourceMetadataValidator,
|
|
110
118
|
type OAuthBearerMethod,
|
|
111
119
|
type OAuthProtectedResourceMetadata,
|
|
112
|
-
} from './schemas/oauth-protected-resource-metadata.
|
|
120
|
+
} from './schemas/oauth-protected-resource-metadata.ts';
|
|
113
121
|
export {
|
|
114
122
|
atprotoProtectedResourceMetadataValidator,
|
|
115
123
|
type AtprotoProtectedResourceMetadata,
|
|
116
|
-
} from './schemas/atproto-protected-resource-metadata.
|
|
124
|
+
} from './schemas/atproto-protected-resource-metadata.ts';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
|
|
3
|
+
import { atprotoOAuthScopeSchema } from './atproto-oauth-scope.ts';
|
|
4
|
+
import { isLastOccurrence } from './utils.ts';
|
|
5
|
+
|
|
6
|
+
const SINGLE_SCOPE_RE = /^[\x21\x23-\x5B\x5D-\x7E]+$/;
|
|
7
|
+
|
|
8
|
+
const singleScopeSchema = v.pipe(v.string(), v.regex(SINGLE_SCOPE_RE, `invalid OAuth scope`));
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* OAuth scope - either:
|
|
12
|
+
* - a space-separated string (must include "atproto")
|
|
13
|
+
* - an array of scope strings ('atproto' is added automatically)
|
|
14
|
+
*/
|
|
15
|
+
export const scopeSchema = v.union([
|
|
16
|
+
v.pipe(
|
|
17
|
+
atprotoOAuthScopeSchema,
|
|
18
|
+
v.check((input) => input.split(/\s+/).every(isLastOccurrence), `duplicate scope`),
|
|
19
|
+
),
|
|
20
|
+
v.pipe(
|
|
21
|
+
v.array(singleScopeSchema),
|
|
22
|
+
v.transform((input) => (input.includes('atproto') ? input : ['atproto', ...input])),
|
|
23
|
+
v.checkItems(isLastOccurrence, `duplicate scope`),
|
|
24
|
+
),
|
|
25
|
+
]);
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import * as v from '
|
|
1
|
+
import * as v from 'valibot';
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import { oauthClientIdDiscoverableSchema } from './oauth-client-id-discoverable.
|
|
5
|
-
import { httpsUriSchema, nonLocalWebUriSchema, webUriSchema } from './uri.
|
|
6
|
-
import { isLocalHostname } from './utils.
|
|
7
|
-
|
|
8
|
-
const SINGLE_SCOPE_RE = /^[\x21\x23-\x5B\x5D-\x7E]+$/;
|
|
9
|
-
|
|
10
|
-
const singleScopeSchema = v.string().assert((input) => SINGLE_SCOPE_RE.test(input), `invalid OAuth scope`);
|
|
3
|
+
import { scopeSchema } from './atcute-client-shared.ts';
|
|
4
|
+
import { oauthClientIdDiscoverableSchema } from './oauth-client-id-discoverable.ts';
|
|
5
|
+
import { httpsUriSchema, nonLocalWebUriSchema, webUriSchema } from './uri.ts';
|
|
6
|
+
import { isLocalHostname } from './utils.ts';
|
|
11
7
|
|
|
12
8
|
/**
|
|
13
9
|
* user-facing client metadata for configuring a confidential OAuth client.
|
|
@@ -16,124 +12,98 @@ const singleScopeSchema = v.string().assert((input) => SINGLE_SCOPE_RE.test(inpu
|
|
|
16
12
|
* the library will fill in atproto-required values like `dpop_bound_access_tokens`,
|
|
17
13
|
* `token_endpoint_auth_method`, and default `grant_types` / `response_types`.
|
|
18
14
|
*/
|
|
19
|
-
export const confidentialClientMetadataSchema = v
|
|
20
|
-
.
|
|
15
|
+
export const confidentialClientMetadataSchema = v.pipe(
|
|
16
|
+
v.looseObject({
|
|
21
17
|
/** discoverable https client_id URL (where metadata is hosted) */
|
|
22
18
|
client_id: oauthClientIdDiscoverableSchema,
|
|
23
19
|
|
|
24
20
|
/** redirect URIs for authorization responses (must be https) */
|
|
25
|
-
redirect_uris: v
|
|
26
|
-
.array(httpsUriSchema)
|
|
27
|
-
.
|
|
28
|
-
.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return true;
|
|
36
|
-
}, `redirect URIs must not contain credentials`),
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* OAuth scope - either:
|
|
40
|
-
* - a space-separated string (must include "atproto")
|
|
41
|
-
* - an array of scope strings ('atproto' is added automatically)
|
|
42
|
-
*/
|
|
43
|
-
scope: v.union(
|
|
44
|
-
atprotoOAuthScopeSchema.chain((input) => {
|
|
45
|
-
const scopes = input.split(/\s+/);
|
|
46
|
-
|
|
47
|
-
for (let i = 0, len = scopes.length; i < len; i++) {
|
|
48
|
-
const aka = scopes[i];
|
|
49
|
-
|
|
50
|
-
for (let j = 0; j < i; j++) {
|
|
51
|
-
if (aka === scopes[j]) {
|
|
52
|
-
return v.err(`duplicate "${aka}" scope`);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return v.ok(input);
|
|
58
|
-
}),
|
|
59
|
-
v.array(singleScopeSchema).chain((input) => {
|
|
60
|
-
if (!input.includes('atproto')) {
|
|
61
|
-
input = ['atproto', ...input];
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
for (let i = 0, len = input.length; i < len; i++) {
|
|
65
|
-
const aka = input[i];
|
|
66
|
-
|
|
67
|
-
for (let j = 0; j < i; j++) {
|
|
68
|
-
if (aka === input[j]) {
|
|
69
|
-
return v.err(`duplicate "${aka}" scope`);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return v.ok(input);
|
|
75
|
-
}),
|
|
21
|
+
redirect_uris: v.pipe(
|
|
22
|
+
v.array(httpsUriSchema),
|
|
23
|
+
v.minLength(1, `must have at least one redirect URI`),
|
|
24
|
+
v.checkItems((uri) => {
|
|
25
|
+
const url = new URL(uri);
|
|
26
|
+
return !url.username && !url.password;
|
|
27
|
+
}, `redirect URI must not contain credentials`),
|
|
76
28
|
),
|
|
77
29
|
|
|
30
|
+
scope: scopeSchema,
|
|
31
|
+
|
|
78
32
|
/** optional client homepage */
|
|
79
|
-
client_uri:
|
|
33
|
+
client_uri: v.optional(webUriSchema),
|
|
80
34
|
/** optional display name */
|
|
81
|
-
client_name: v.
|
|
35
|
+
client_name: v.optional(v.string()),
|
|
82
36
|
/** optional policy url */
|
|
83
|
-
policy_uri:
|
|
37
|
+
policy_uri: v.optional(nonLocalWebUriSchema),
|
|
84
38
|
/** optional terms of service url */
|
|
85
|
-
tos_uri:
|
|
39
|
+
tos_uri: v.optional(nonLocalWebUriSchema),
|
|
86
40
|
/** optional logo url */
|
|
87
|
-
logo_uri:
|
|
41
|
+
logo_uri: v.optional(nonLocalWebUriSchema),
|
|
88
42
|
|
|
89
43
|
/** optional JWKS URL; if omitted, the library will inline jwks from the keyset */
|
|
90
|
-
jwks_uri:
|
|
91
|
-
})
|
|
92
|
-
.
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
44
|
+
jwks_uri: v.optional(httpsUriSchema),
|
|
45
|
+
}),
|
|
46
|
+
v.forward(
|
|
47
|
+
v.check((input) => !isLocalHostname(new URL(input.client_id).hostname), `client_id hostname is invalid`),
|
|
48
|
+
['client_id'],
|
|
49
|
+
),
|
|
50
|
+
v.forward(
|
|
51
|
+
v.check((input) => {
|
|
52
|
+
if (!input.jwks_uri) {
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
99
55
|
const jwksUrl = new URL(input.jwks_uri);
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
56
|
+
return !(jwksUrl.username || jwksUrl.password);
|
|
57
|
+
}, `jwks_uri must not contain credentials`),
|
|
58
|
+
['jwks_uri'],
|
|
59
|
+
),
|
|
60
|
+
v.forward(
|
|
61
|
+
v.check((input) => {
|
|
62
|
+
if (!input.jwks_uri) {
|
|
63
|
+
return true;
|
|
103
64
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
65
|
+
return !isLocalHostname(new URL(input.jwks_uri).hostname);
|
|
66
|
+
}, `jwks_uri hostname is invalid`),
|
|
67
|
+
['jwks_uri'],
|
|
68
|
+
),
|
|
69
|
+
v.forward(
|
|
70
|
+
v.check((input) => {
|
|
71
|
+
if (!input.client_uri) {
|
|
72
|
+
return true;
|
|
107
73
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
if (
|
|
115
|
-
return
|
|
74
|
+
return !isLocalHostname(new URL(input.client_uri).hostname);
|
|
75
|
+
}, `client_uri hostname is invalid`),
|
|
76
|
+
['client_uri'],
|
|
77
|
+
),
|
|
78
|
+
v.forward(
|
|
79
|
+
v.check((input) => {
|
|
80
|
+
if (!input.client_uri) {
|
|
81
|
+
return true;
|
|
116
82
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
83
|
+
const clientUriUrl = new URL(input.client_uri);
|
|
84
|
+
const clientIdUrl = new URL(input.client_id);
|
|
85
|
+
return clientUriUrl.origin === clientIdUrl.origin;
|
|
86
|
+
}, `client_uri must have the same origin as the client_id`),
|
|
87
|
+
['client_uri'],
|
|
88
|
+
),
|
|
89
|
+
v.forward(
|
|
90
|
+
v.check((input) => {
|
|
91
|
+
if (!input.client_uri) {
|
|
92
|
+
return true;
|
|
123
93
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
if (!clientIdUrl.pathname.startsWith(prefix)) {
|
|
131
|
-
return v.err({ message: `client_uri must be a parent URL of the client_id`, path: ['client_uri'] });
|
|
132
|
-
}
|
|
94
|
+
// for discoverable clients, client_uri (if provided) must be same-origin parent of client_id
|
|
95
|
+
const clientUriUrl = new URL(input.client_uri);
|
|
96
|
+
const clientIdUrl = new URL(input.client_id);
|
|
97
|
+
if (clientIdUrl.pathname === clientUriUrl.pathname) {
|
|
98
|
+
return true;
|
|
133
99
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
100
|
+
const prefix = clientUriUrl.pathname.endsWith('/')
|
|
101
|
+
? clientUriUrl.pathname
|
|
102
|
+
: `${clientUriUrl.pathname}/`;
|
|
103
|
+
return clientIdUrl.pathname.startsWith(prefix);
|
|
104
|
+
}, `client_uri must be a parent URL of the client_id`),
|
|
105
|
+
['client_uri'],
|
|
106
|
+
),
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
export type ConfidentialClientMetadata = v.InferOutput<typeof confidentialClientMetadataSchema>;
|