@atcute/oauth-types 0.1.1 → 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 +5 -320
- package/dist/build-client-metadata.d.ts.map +1 -1
- package/dist/build-client-metadata.js +3 -2
- package/dist/build-client-metadata.js.map +1 -1
- package/dist/index.d.ts +31 -31
- 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 +75 -35
- package/dist/schemas/atcute-public-client-metadata.d.ts.map +1 -1
- package/dist/schemas/atcute-public-client-metadata.js +25 -110
- package/dist/schemas/atcute-public-client-metadata.js.map +1 -1
- 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 +9 -7
- package/lib/index.ts +31 -31
- 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 +70 -166
- 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,11 +1,11 @@
|
|
|
1
|
-
import * as v from '
|
|
1
|
+
import * as v from 'valibot';
|
|
2
2
|
import { oauthIssuerIdentifierSchema } from './oauth-issuer-identifier.js';
|
|
3
3
|
import { webUriSchema } from './uri.js';
|
|
4
|
-
export const oauthBearerMethodSchema = v.
|
|
4
|
+
export const oauthBearerMethodSchema = v.picklist(['header', 'body', 'query']);
|
|
5
5
|
/**
|
|
6
6
|
* @see {@link https://www.rfc-editor.org/rfc/rfc9728.html#section-3.2}
|
|
7
7
|
*/
|
|
8
|
-
export const oauthProtectedResourceMetadataSchema = v.
|
|
8
|
+
export const oauthProtectedResourceMetadataSchema = v.looseObject({
|
|
9
9
|
/**
|
|
10
10
|
* REQUIRED. the protected resource's resource identifier, which is a URL that
|
|
11
11
|
* uses the https scheme and has no query or fragment components.
|
|
@@ -16,56 +16,44 @@ export const oauthProtectedResourceMetadataSchema = v.object({
|
|
|
16
16
|
* identifiers, as defined in RFC8414, for authorization servers that can be
|
|
17
17
|
* used with this protected resource.
|
|
18
18
|
*/
|
|
19
|
-
authorization_servers: v.array(oauthIssuerIdentifierSchema)
|
|
19
|
+
authorization_servers: v.optional(v.array(oauthIssuerIdentifierSchema)),
|
|
20
20
|
/**
|
|
21
21
|
* OPTIONAL. URL of the protected resource's JWK Set document.
|
|
22
22
|
*/
|
|
23
|
-
jwks_uri:
|
|
23
|
+
jwks_uri: v.optional(webUriSchema),
|
|
24
24
|
/**
|
|
25
25
|
* RECOMMENDED. JSON array containing a list of the OAuth 2.0 scope values that
|
|
26
26
|
* are used in authorization requests to request access to this protected resource.
|
|
27
27
|
*/
|
|
28
|
-
scopes_supported: v.array(v.string())
|
|
28
|
+
scopes_supported: v.optional(v.array(v.string())),
|
|
29
29
|
/**
|
|
30
30
|
* OPTIONAL. JSON array containing a list of the supported methods of sending
|
|
31
31
|
* an OAuth 2.0 Bearer Token to the protected resource.
|
|
32
32
|
*/
|
|
33
|
-
bearer_methods_supported: v.array(oauthBearerMethodSchema)
|
|
33
|
+
bearer_methods_supported: v.optional(v.array(oauthBearerMethodSchema)),
|
|
34
34
|
/**
|
|
35
35
|
* OPTIONAL. JSON array containing a list of the JWS signing algorithms
|
|
36
36
|
* supported by the protected resource for signing resource responses.
|
|
37
37
|
*/
|
|
38
|
-
resource_signing_alg_values_supported: v.array(v.string())
|
|
38
|
+
resource_signing_alg_values_supported: v.optional(v.array(v.string())),
|
|
39
39
|
/**
|
|
40
40
|
* OPTIONAL. URL of a page containing human-readable information that
|
|
41
41
|
* developers might want or need to know when using the protected resource.
|
|
42
42
|
*/
|
|
43
|
-
resource_documentation:
|
|
43
|
+
resource_documentation: v.optional(webUriSchema),
|
|
44
44
|
/**
|
|
45
45
|
* OPTIONAL. URL that the protected resource provides to read about the
|
|
46
46
|
* protected resource's requirements on how the client can use the data.
|
|
47
47
|
*/
|
|
48
|
-
resource_policy_uri:
|
|
48
|
+
resource_policy_uri: v.optional(webUriSchema),
|
|
49
49
|
/**
|
|
50
50
|
* OPTIONAL. URL that the protected resource provides to read about the
|
|
51
51
|
* protected resource's terms of service.
|
|
52
52
|
*/
|
|
53
|
-
resource_tos_uri:
|
|
53
|
+
resource_tos_uri: v.optional(webUriSchema),
|
|
54
54
|
});
|
|
55
|
-
export const oauthProtectedResourceMetadataValidator = oauthProtectedResourceMetadataSchema.
|
|
55
|
+
export const oauthProtectedResourceMetadataValidator = v.pipe(oauthProtectedResourceMetadataSchema, v.forward(v.check((data) => {
|
|
56
56
|
const url = new URL(data.resource);
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
message: `resource URL must not contain query parameters`,
|
|
60
|
-
path: ['resource'],
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
if (url.hash) {
|
|
64
|
-
return v.err({
|
|
65
|
-
message: `resource URL must not contain a fragment`,
|
|
66
|
-
path: ['resource'],
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
return v.ok(data);
|
|
70
|
-
});
|
|
57
|
+
return !url.search && !url.hash;
|
|
58
|
+
}, `resource URL must not contain query parameters or a fragment`), ['resource']));
|
|
71
59
|
//# sourceMappingURL=oauth-protected-resource-metadata.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth-protected-resource-metadata.js","sourceRoot":"","sources":["../../lib/schemas/oauth-protected-resource-metadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"oauth-protected-resource-metadata.js","sourceRoot":"","sources":["../../lib/schemas/oauth-protected-resource-metadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAE7B,OAAO,EAAE,2BAA2B,EAAE,MAAM,8BAA8B,CAAC;AAC3E,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAI/E;;GAEG;AACH,MAAM,CAAC,MAAM,oCAAoC,GAAG,CAAC,CAAC,WAAW,CAAC;IACjE;;;OAGG;IACH,QAAQ,EAAE,YAAY;IAEtB;;;;OAIG;IACH,qBAAqB,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAC;IAEvE;;OAEG;IACH,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,YAAY,CAAC;IAElC;;;OAGG;IACH,gBAAgB,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;IAEjD;;;OAGG;IACH,wBAAwB,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAEtE;;;OAGG;IACH,qCAAqC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;IAEtE;;;OAGG;IACH,sBAAsB,EAAE,CAAC,CAAC,QAAQ,CAAC,YAAY,CAAC;IAEhD;;;OAGG;IACH,mBAAmB,EAAE,CAAC,CAAC,QAAQ,CAAC,YAAY,CAAC;IAE7C;;;OAGG;IACH,gBAAgB,EAAE,CAAC,CAAC,QAAQ,CAAC,YAAY,CAAC;CAC1C,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,uCAAuC,GAAG,CAAC,CAAC,IAAI,CAC5D,oCAAoC,EACpC,CAAC,CAAC,OAAO,CACR,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE;IAChB,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACnC,OAAO,CAAC,GAAG,CAAC,MAAM,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC;AACjC,CAAC,EAAE,8DAA8D,CAAC,EAClE,CAAC,UAAU,CAAC,CACZ,CACD,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as v from '
|
|
1
|
+
import * as v from 'valibot';
|
|
2
2
|
/**
|
|
3
3
|
* this is a loopback URI with the additional restriction that the hostname
|
|
4
4
|
* `localhost` is not allowed.
|
|
@@ -13,8 +13,8 @@ import * as v from '@badrap/valita';
|
|
|
13
13
|
* > than the loopback interface. It is also less susceptible to client-side
|
|
14
14
|
* > firewalls and misconfigured host name resolution on the user's device.
|
|
15
15
|
*/
|
|
16
|
-
export declare const loopbackRedirectUriSchema: v.
|
|
17
|
-
export type LoopbackRedirectUri = v.
|
|
18
|
-
export declare const oauthRedirectUriSchema: v.
|
|
19
|
-
export type OAuthRedirectUri = v.
|
|
16
|
+
export declare const loopbackRedirectUriSchema: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "must be a valid url">]>, v.RawCheckAction<string>]>, v.CheckAction<string, "use of \"localhost\" hostname is not allowed (RFC 8252), use a loopback IP such as \"127.0.0.1\" instead">]>;
|
|
17
|
+
export type LoopbackRedirectUri = v.InferOutput<typeof loopbackRedirectUriSchema>;
|
|
18
|
+
export declare const oauthRedirectUriSchema: v.UnionSchema<[v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "must be a valid url">]>, v.RawCheckAction<string>]>, v.CheckAction<string, "use of \"localhost\" hostname is not allowed (RFC 8252), use a loopback IP such as \"127.0.0.1\" instead">]>, v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "must be a valid url">]>, v.RawCheckAction<string>]>, v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "must be a valid url">]>, v.RawCheckAction<string>]>], "url must use http: loopback, https:, or a private-use scheme">;
|
|
19
|
+
export type OAuthRedirectUri = v.InferOutput<typeof oauthRedirectUriSchema>;
|
|
20
20
|
//# sourceMappingURL=oauth-redirect-uri.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth-redirect-uri.d.ts","sourceRoot":"","sources":["../../lib/schemas/oauth-redirect-uri.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"oauth-redirect-uri.d.ts","sourceRoot":"","sources":["../../lib/schemas/oauth-redirect-uri.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAI7B;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,yBAAyB,6TAMrC,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAElF,eAAO,MAAM,sBAAsB,wsBAGlC,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,sBAAsB,CAAC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as v from '
|
|
1
|
+
import * as v from 'valibot';
|
|
2
2
|
import { httpsUriSchema, loopbackUriSchema, privateUseUriSchema } from './uri.js';
|
|
3
3
|
/**
|
|
4
4
|
* this is a loopback URI with the additional restriction that the hostname
|
|
@@ -14,19 +14,6 @@ import { httpsUriSchema, loopbackUriSchema, privateUseUriSchema } from './uri.js
|
|
|
14
14
|
* > than the loopback interface. It is also less susceptible to client-side
|
|
15
15
|
* > firewalls and misconfigured host name resolution on the user's device.
|
|
16
16
|
*/
|
|
17
|
-
export const loopbackRedirectUriSchema = loopbackUriSchema.
|
|
18
|
-
|
|
19
|
-
return v.err(`use of "localhost" hostname is not allowed (RFC 8252), use a loopback IP such as "127.0.0.1" instead`);
|
|
20
|
-
}
|
|
21
|
-
return v.ok(input);
|
|
22
|
-
});
|
|
23
|
-
export const oauthRedirectUriSchema = v.string().chain((input, options) => {
|
|
24
|
-
if (input.startsWith('http://')) {
|
|
25
|
-
return loopbackRedirectUriSchema.try(input, options);
|
|
26
|
-
}
|
|
27
|
-
if (input.startsWith('https://')) {
|
|
28
|
-
return httpsUriSchema.try(input, options);
|
|
29
|
-
}
|
|
30
|
-
return privateUseUriSchema.try(input, options);
|
|
31
|
-
});
|
|
17
|
+
export const loopbackRedirectUriSchema = v.pipe(loopbackUriSchema, v.check((input) => !input.startsWith('http://localhost'), `use of "localhost" hostname is not allowed (RFC 8252), use a loopback IP such as "127.0.0.1" instead`));
|
|
18
|
+
export const oauthRedirectUriSchema = v.union([loopbackRedirectUriSchema, httpsUriSchema, privateUseUriSchema], `url must use http: loopback, https:, or a private-use scheme`);
|
|
32
19
|
//# sourceMappingURL=oauth-redirect-uri.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth-redirect-uri.js","sourceRoot":"","sources":["../../lib/schemas/oauth-redirect-uri.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"oauth-redirect-uri.js","sourceRoot":"","sources":["../../lib/schemas/oauth-redirect-uri.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAE7B,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAElF;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC,IAAI,CAC9C,iBAAiB,EACjB,CAAC,CAAC,KAAK,CACN,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,kBAAkB,CAAC,EAChD,sGAAsG,CACtG,CACD,CAAC;AAIF,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAC5C,CAAC,yBAAyB,EAAE,cAAc,EAAE,mBAAmB,CAAC,EAChE,8DAA8D,CAC9D,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as v from '
|
|
2
|
-
export declare const oauthResponseModeSchema: v.
|
|
3
|
-
export type OAuthResponseMode = v.
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
export declare const oauthResponseModeSchema: v.PicklistSchema<["query", "fragment", "form_post"], undefined>;
|
|
3
|
+
export type OAuthResponseMode = v.InferOutput<typeof oauthResponseModeSchema>;
|
|
4
4
|
//# sourceMappingURL=oauth-response-mode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth-response-mode.d.ts","sourceRoot":"","sources":["../../lib/schemas/oauth-response-mode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"oauth-response-mode.d.ts","sourceRoot":"","sources":["../../lib/schemas/oauth-response-mode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAE7B,eAAO,MAAM,uBAAuB,iEAAiD,CAAC;AAEtF,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,uBAAuB,CAAC,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import * as v from '
|
|
2
|
-
export const oauthResponseModeSchema = v.
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
export const oauthResponseModeSchema = v.picklist(['query', 'fragment', 'form_post']);
|
|
3
3
|
//# sourceMappingURL=oauth-response-mode.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth-response-mode.js","sourceRoot":"","sources":["../../lib/schemas/oauth-response-mode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"oauth-response-mode.js","sourceRoot":"","sources":["../../lib/schemas/oauth-response-mode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAE7B,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,OAAO,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as v from '
|
|
2
|
-
export declare const oauthResponseTypeSchema: v.
|
|
3
|
-
export type OAuthResponseType = v.
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
export declare const oauthResponseTypeSchema: v.PicklistSchema<["code", "token", "none", "code id_token token", "code id_token", "code token", "id_token token", "id_token"], undefined>;
|
|
3
|
+
export type OAuthResponseType = v.InferOutput<typeof oauthResponseTypeSchema>;
|
|
4
4
|
//# sourceMappingURL=oauth-response-type.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth-response-type.d.ts","sourceRoot":"","sources":["../../lib/schemas/oauth-response-type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"oauth-response-type.d.ts","sourceRoot":"","sources":["../../lib/schemas/oauth-response-type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAE7B,eAAO,MAAM,uBAAuB,4IAYlC,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,uBAAuB,CAAC,CAAC"}
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
import * as v from '
|
|
2
|
-
export const oauthResponseTypeSchema = v.
|
|
3
|
-
// OAuth2 (https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-10#section-4.1.1)
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
// OIDC (https://openid.net/specs/oauth-v2-multiple-response-types-1_0.html)
|
|
7
|
-
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
export const oauthResponseTypeSchema = v.picklist([
|
|
3
|
+
// OAuth2 (https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-10#section-4.1.1)
|
|
4
|
+
'code', // Authorization Code Grant
|
|
5
|
+
'token', // Implicit Grant
|
|
6
|
+
// OIDC (https://openid.net/specs/oauth-v2-multiple-response-types-1_0.html)
|
|
7
|
+
'none',
|
|
8
|
+
'code id_token token',
|
|
9
|
+
'code id_token',
|
|
10
|
+
'code token',
|
|
11
|
+
'id_token token',
|
|
12
|
+
'id_token',
|
|
13
|
+
]);
|
|
8
14
|
//# sourceMappingURL=oauth-response-type.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth-response-type.js","sourceRoot":"","sources":["../../lib/schemas/oauth-response-type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"oauth-response-type.js","sourceRoot":"","sources":["../../lib/schemas/oauth-response-type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAE7B,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC,QAAQ,CAAC;IACjD,wFAAwF;IACxF,MAAM,EAAE,2BAA2B;IACnC,OAAO,EAAE,iBAAiB;IAE1B,4EAA4E;IAC5E,MAAM;IACN,qBAAqB;IACrB,eAAe;IACf,YAAY;IACZ,gBAAgB;IAChB,UAAU;CACV,CAAC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as v from '
|
|
1
|
+
import * as v from 'valibot';
|
|
2
2
|
export declare const OAUTH_SCOPE_REGEXP: RegExp;
|
|
3
3
|
export declare const isOAuthScope: (input: string) => boolean;
|
|
4
4
|
/**
|
|
@@ -7,6 +7,6 @@ export declare const isOAuthScope: (input: string) => boolean;
|
|
|
7
7
|
*
|
|
8
8
|
* @see {@link https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-11#section-1.4.1}
|
|
9
9
|
*/
|
|
10
|
-
export declare const oauthScopeSchema: v.
|
|
11
|
-
export type OAuthScope = v.
|
|
10
|
+
export declare const oauthScopeSchema: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "invalid OAuth scope">]>;
|
|
11
|
+
export type OAuthScope = v.InferOutput<typeof oauthScopeSchema>;
|
|
12
12
|
//# sourceMappingURL=oauth-scope.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth-scope.d.ts","sourceRoot":"","sources":["../../lib/schemas/oauth-scope.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"oauth-scope.d.ts","sourceRoot":"","sources":["../../lib/schemas/oauth-scope.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAK7B,eAAO,MAAM,kBAAkB,QAA+D,CAAC;AAE/F,eAAO,MAAM,YAAY,UAAW,MAAM,KAAG,OAAyC,CAAC;AAEvF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,sGAAmE,CAAC;AAEjG,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,gBAAgB,CAAC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as v from '
|
|
1
|
+
import * as v from 'valibot';
|
|
2
2
|
// scope = scope-token *( SP scope-token )
|
|
3
3
|
// scope-token = 1*( %x21 / %x23-5B / %x5D-7E )
|
|
4
4
|
// https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-11#section-1.4.1
|
|
@@ -10,5 +10,5 @@ export const isOAuthScope = (input) => OAUTH_SCOPE_REGEXP.test(input);
|
|
|
10
10
|
*
|
|
11
11
|
* @see {@link https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-11#section-1.4.1}
|
|
12
12
|
*/
|
|
13
|
-
export const oauthScopeSchema = v.string().
|
|
13
|
+
export const oauthScopeSchema = v.pipe(v.string(), v.check(isOAuthScope, `invalid OAuth scope`));
|
|
14
14
|
//# sourceMappingURL=oauth-scope.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth-scope.js","sourceRoot":"","sources":["../../lib/schemas/oauth-scope.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"oauth-scope.js","sourceRoot":"","sources":["../../lib/schemas/oauth-scope.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAE7B,gDAAgD;AAChD,+CAA+C;AAC/C,+EAA+E;AAC/E,MAAM,CAAC,MAAM,kBAAkB,GAAG,4DAA4D,CAAC;AAE/F,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAa,EAAW,EAAE,CAAC,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAEvF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,YAAY,EAAE,qBAAqB,CAAC,CAAC,CAAC"}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import * as v from '
|
|
1
|
+
import * as v from 'valibot';
|
|
2
2
|
/**
|
|
3
3
|
* @see {@link https://www.rfc-editor.org/rfc/rfc6749.html#section-5.1 | RFC 6749 (OAuth2), Section 5.1}
|
|
4
4
|
*/
|
|
5
|
-
export declare const oauthTokenResponseSchema: v.
|
|
6
|
-
access_token: v.
|
|
7
|
-
token_type: v.
|
|
8
|
-
scope: v.
|
|
9
|
-
refresh_token: v.
|
|
10
|
-
expires_in: v.
|
|
11
|
-
id_token: v.
|
|
12
|
-
authorization_details: v.
|
|
13
|
-
type:
|
|
14
|
-
locations
|
|
15
|
-
actions
|
|
16
|
-
datatypes
|
|
17
|
-
identifier
|
|
18
|
-
privileges
|
|
19
|
-
}
|
|
5
|
+
export declare const oauthTokenResponseSchema: v.LooseObjectSchema<{
|
|
6
|
+
readonly access_token: v.StringSchema<undefined>;
|
|
7
|
+
readonly token_type: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RawTransformAction<string, "Bearer" | "DPoP">]>;
|
|
8
|
+
readonly scope: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
9
|
+
readonly refresh_token: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
10
|
+
readonly expires_in: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
|
|
11
|
+
readonly id_token: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
12
|
+
readonly authorization_details: v.OptionalSchema<v.ArraySchema<v.LooseObjectSchema<{
|
|
13
|
+
readonly type: v.StringSchema<undefined>;
|
|
14
|
+
readonly locations: v.OptionalSchema<v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "must be a valid url">]>, undefined>, undefined>;
|
|
15
|
+
readonly actions: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
16
|
+
readonly datatypes: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
17
|
+
readonly identifier: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
18
|
+
readonly privileges: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
19
|
+
}, undefined>, undefined>, undefined>;
|
|
20
20
|
}, undefined>;
|
|
21
|
-
export type OAuthTokenResponse = v.
|
|
21
|
+
export type OAuthTokenResponse = v.InferOutput<typeof oauthTokenResponseSchema>;
|
|
22
22
|
//# sourceMappingURL=oauth-token-response.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth-token-response.d.ts","sourceRoot":"","sources":["../../lib/schemas/oauth-token-response.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"oauth-token-response.d.ts","sourceRoot":"","sources":["../../lib/schemas/oauth-token-response.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAK7B;;GAEG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;aAWnC,CAAC;AAEH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,wBAAwB,CAAC,CAAC"}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import * as v from '
|
|
1
|
+
import * as v from 'valibot';
|
|
2
2
|
import { oauthAuthorizationDetailsSchema } from './oauth-authorization-details.js';
|
|
3
3
|
import { oauthTokenTypeSchema } from './oauth-token-type.js';
|
|
4
4
|
/**
|
|
5
5
|
* @see {@link https://www.rfc-editor.org/rfc/rfc6749.html#section-5.1 | RFC 6749 (OAuth2), Section 5.1}
|
|
6
6
|
*/
|
|
7
|
-
export const oauthTokenResponseSchema = v.
|
|
7
|
+
export const oauthTokenResponseSchema = v.looseObject({
|
|
8
8
|
// https://www.rfc-editor.org/rfc/rfc6749.html#section-5.1
|
|
9
9
|
access_token: v.string(),
|
|
10
10
|
token_type: oauthTokenTypeSchema,
|
|
11
|
-
scope: v.
|
|
12
|
-
refresh_token: v.
|
|
13
|
-
expires_in: v.
|
|
11
|
+
scope: v.optional(v.string()),
|
|
12
|
+
refresh_token: v.optional(v.string()),
|
|
13
|
+
expires_in: v.optional(v.number()),
|
|
14
14
|
// https://openid.net/specs/openid-connect-core-1_0.html#TokenResponse
|
|
15
|
-
id_token: v.
|
|
15
|
+
id_token: v.optional(v.string()),
|
|
16
16
|
// https://datatracker.ietf.org/doc/html/rfc9396#name-enriched-authorization-deta
|
|
17
|
-
authorization_details:
|
|
17
|
+
authorization_details: v.optional(oauthAuthorizationDetailsSchema),
|
|
18
18
|
});
|
|
19
19
|
//# sourceMappingURL=oauth-token-response.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth-token-response.js","sourceRoot":"","sources":["../../lib/schemas/oauth-token-response.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"oauth-token-response.js","sourceRoot":"","sources":["../../lib/schemas/oauth-token-response.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAE7B,OAAO,EAAE,+BAA+B,EAAE,MAAM,kCAAkC,CAAC;AACnF,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAE7D;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,WAAW,CAAC;IACrD,0DAA0D;IAC1D,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE;IACxB,UAAU,EAAE,oBAAoB;IAChC,KAAK,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAC7B,aAAa,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IACrC,UAAU,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAClC,sEAAsE;IACtE,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAChC,iFAAiF;IACjF,qBAAqB,EAAE,CAAC,CAAC,QAAQ,CAAC,+BAA+B,CAAC;CAClE,CAAC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as v from '
|
|
1
|
+
import * as v from 'valibot';
|
|
2
2
|
/** token type (case-insensitive input, normalized output) */
|
|
3
|
-
export declare const oauthTokenTypeSchema: v.
|
|
4
|
-
export type OAuthTokenType = v.
|
|
3
|
+
export declare const oauthTokenTypeSchema: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RawTransformAction<string, "Bearer" | "DPoP">]>;
|
|
4
|
+
export type OAuthTokenType = v.InferOutput<typeof oauthTokenTypeSchema>;
|
|
5
5
|
//# sourceMappingURL=oauth-token-type.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth-token-type.d.ts","sourceRoot":"","sources":["../../lib/schemas/oauth-token-type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"oauth-token-type.d.ts","sourceRoot":"","sources":["../../lib/schemas/oauth-token-type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAE7B,6DAA6D;AAC7D,eAAO,MAAM,oBAAoB,yGAahC,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import * as v from '
|
|
1
|
+
import * as v from 'valibot';
|
|
2
2
|
/** token type (case-insensitive input, normalized output) */
|
|
3
|
-
export const oauthTokenTypeSchema = v.string().
|
|
4
|
-
const lower =
|
|
3
|
+
export const oauthTokenTypeSchema = v.pipe(v.string(), v.rawTransform(({ dataset, addIssue, NEVER }) => {
|
|
4
|
+
const lower = dataset.value.toLowerCase();
|
|
5
5
|
if (lower === 'dpop') {
|
|
6
|
-
return
|
|
6
|
+
return 'DPoP';
|
|
7
7
|
}
|
|
8
8
|
if (lower === 'bearer') {
|
|
9
|
-
return
|
|
9
|
+
return 'Bearer';
|
|
10
10
|
}
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
addIssue({ message: `must be "DPoP" or "Bearer"` });
|
|
12
|
+
return NEVER;
|
|
13
|
+
}));
|
|
13
14
|
//# sourceMappingURL=oauth-token-type.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth-token-type.js","sourceRoot":"","sources":["../../lib/schemas/oauth-token-type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"oauth-token-type.js","sourceRoot":"","sources":["../../lib/schemas/oauth-token-type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAE7B,6DAA6D;AAC7D,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,IAAI,CACzC,CAAC,CAAC,MAAM,EAAE,EACV,CAAC,CAAC,YAAY,CAA4B,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,EAAE;IAC1E,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;IAC1C,IAAI,KAAK,KAAK,MAAM,EAAE,CAAC;QACtB,OAAO,MAAM,CAAC;IACf,CAAC;IACD,IAAI,KAAK,KAAK,QAAQ,EAAE,CAAC;QACxB,OAAO,QAAQ,CAAC;IACjB,CAAC;IACD,QAAQ,CAAC,EAAE,OAAO,EAAE,4BAA4B,EAAE,CAAC,CAAC;IACpD,OAAO,KAAK,CAAC;AACd,CAAC,CAAC,CACF,CAAC"}
|
package/dist/schemas/uri.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import * as v from '
|
|
1
|
+
import * as v from 'valibot';
|
|
2
2
|
/**
|
|
3
3
|
* valid, but potentially dangerous URL (`data:`, `file:`, `javascript:`, etc.).
|
|
4
4
|
*
|
|
5
5
|
* any value that matches this schema is safe to parse using `new URL()`.
|
|
6
6
|
*/
|
|
7
|
-
export declare const urlSchema: v.
|
|
7
|
+
export declare const urlSchema: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "must be a valid url">]>;
|
|
8
8
|
/** loopback URL (http://localhost, http://127.0.0.1, http://[::1]) */
|
|
9
|
-
export declare const loopbackUriSchema: v.
|
|
9
|
+
export declare const loopbackUriSchema: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "must be a valid url">]>, v.RawCheckAction<string>]>;
|
|
10
10
|
/** HTTPS URL with additional restrictions */
|
|
11
|
-
export declare const httpsUriSchema: v.
|
|
11
|
+
export declare const httpsUriSchema: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "must be a valid url">]>, v.RawCheckAction<string>]>;
|
|
12
12
|
/** web URL (either loopback http or https) */
|
|
13
|
-
export declare const webUriSchema: v.
|
|
13
|
+
export declare const webUriSchema: v.UnionSchema<[v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "must be a valid url">]>, v.RawCheckAction<string>]>, v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "must be a valid url">]>, v.RawCheckAction<string>]>], "url must use http: or https: protocol">;
|
|
14
14
|
/** web URL with a non-local hostname */
|
|
15
|
-
export declare const nonLocalWebUriSchema: v.
|
|
15
|
+
export declare const nonLocalWebUriSchema: v.SchemaWithPipe<readonly [v.UnionSchema<[v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "must be a valid url">]>, v.RawCheckAction<string>]>, v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "must be a valid url">]>, v.RawCheckAction<string>]>], "url must use http: or https: protocol">, v.CheckAction<string, "hostname is invalid">]>;
|
|
16
16
|
/** private-use URI scheme (e.g., com.example.app:/callback) */
|
|
17
|
-
export declare const privateUseUriSchema: v.
|
|
17
|
+
export declare const privateUseUriSchema: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "must be a valid url">]>, v.RawCheckAction<string>]>;
|
|
18
18
|
//# sourceMappingURL=uri.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uri.d.ts","sourceRoot":"","sources":["../../lib/schemas/uri.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"uri.d.ts","sourceRoot":"","sources":["../../lib/schemas/uri.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAI7B;;;;GAIG;AACH,eAAO,MAAM,SAAS,sGAGrB,CAAC;AAEF,sEAAsE;AACtE,eAAO,MAAM,iBAAiB,6JAe7B,CAAC;AAEF,6CAA6C;AAC7C,eAAO,MAAM,cAAc,6JA6B1B,CAAC;AAEF,8CAA8C;AAC9C,eAAO,MAAM,YAAY,oXAGxB,CAAC;AAEF,wCAAwC;AACxC,eAAO,MAAM,oBAAoB,+bAGhC,CAAC;AAEF,+DAA+D;AAC/D,eAAO,MAAM,mBAAmB,6JAmC/B,CAAC"}
|
package/dist/schemas/uri.js
CHANGED
|
@@ -1,81 +1,81 @@
|
|
|
1
|
-
import * as v from '
|
|
1
|
+
import * as v from 'valibot';
|
|
2
2
|
import { isHostnameIP, isLocalHostname, isLoopbackHost } from './utils.js';
|
|
3
3
|
/**
|
|
4
4
|
* valid, but potentially dangerous URL (`data:`, `file:`, `javascript:`, etc.).
|
|
5
5
|
*
|
|
6
6
|
* any value that matches this schema is safe to parse using `new URL()`.
|
|
7
7
|
*/
|
|
8
|
-
export const urlSchema = v.string().
|
|
9
|
-
if (input.includes(':') && URL.canParse(input)) {
|
|
10
|
-
return v.ok(input);
|
|
11
|
-
}
|
|
12
|
-
return v.err(`must be a valid url`);
|
|
13
|
-
});
|
|
8
|
+
export const urlSchema = v.pipe(v.string(), v.check((input) => input.includes(':') && URL.canParse(input), `must be a valid url`));
|
|
14
9
|
/** loopback URL (http://localhost, http://127.0.0.1, http://[::1]) */
|
|
15
|
-
export const loopbackUriSchema = urlSchema.
|
|
10
|
+
export const loopbackUriSchema = v.pipe(urlSchema, v.rawCheck(({ dataset, addIssue }) => {
|
|
11
|
+
if (!dataset.typed) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const input = dataset.value;
|
|
16
15
|
if (!input.startsWith('http://')) {
|
|
17
|
-
|
|
16
|
+
addIssue({ message: `loopback url must use http: protocol` });
|
|
17
|
+
return;
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return v.err(`loopback url must use localhost, 127.0.0.1, or [::1] as hostname`);
|
|
19
|
+
if (!isLoopbackHost(new URL(input).hostname)) {
|
|
20
|
+
addIssue({ message: `loopback url must use localhost, 127.0.0.1, or [::1] as hostname` });
|
|
22
21
|
}
|
|
23
|
-
|
|
24
|
-
});
|
|
22
|
+
}));
|
|
25
23
|
/** HTTPS URL with additional restrictions */
|
|
26
|
-
export const httpsUriSchema = urlSchema.
|
|
24
|
+
export const httpsUriSchema = v.pipe(urlSchema, v.rawCheck(({ dataset, addIssue }) => {
|
|
25
|
+
if (!dataset.typed) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const input = dataset.value;
|
|
27
29
|
if (!input.startsWith('https://')) {
|
|
28
|
-
|
|
30
|
+
addIssue({ message: `url must use https: protocol` });
|
|
31
|
+
return;
|
|
29
32
|
}
|
|
30
33
|
const url = new URL(input);
|
|
31
34
|
if (isLoopbackHost(url.hostname)) {
|
|
32
|
-
|
|
35
|
+
addIssue({ message: `https url must not use a loopback host` });
|
|
36
|
+
return;
|
|
33
37
|
}
|
|
34
38
|
if (!isHostnameIP(url.hostname)) {
|
|
35
39
|
if (!url.hostname.includes('.')) {
|
|
36
|
-
|
|
40
|
+
addIssue({ message: `domain name must contain at least two segments` });
|
|
41
|
+
return;
|
|
37
42
|
}
|
|
38
43
|
if (url.hostname.endsWith('.local')) {
|
|
39
|
-
|
|
44
|
+
addIssue({ message: `domain name must not end with .local` });
|
|
40
45
|
}
|
|
41
46
|
}
|
|
42
|
-
|
|
43
|
-
});
|
|
47
|
+
}));
|
|
44
48
|
/** web URL (either loopback http or https) */
|
|
45
|
-
export const webUriSchema =
|
|
46
|
-
if (input.startsWith('http://')) {
|
|
47
|
-
return loopbackUriSchema.try(input, options);
|
|
48
|
-
}
|
|
49
|
-
if (input.startsWith('https://')) {
|
|
50
|
-
return httpsUriSchema.try(input, options);
|
|
51
|
-
}
|
|
52
|
-
return v.err(`url must use http: or https: protocol`);
|
|
53
|
-
});
|
|
49
|
+
export const webUriSchema = v.union([loopbackUriSchema, httpsUriSchema], `url must use http: or https: protocol`);
|
|
54
50
|
/** web URL with a non-local hostname */
|
|
55
|
-
export const nonLocalWebUriSchema = webUriSchema.
|
|
56
|
-
const url = new URL(input);
|
|
57
|
-
if (isLocalHostname(url.hostname)) {
|
|
58
|
-
return v.err(`hostname is invalid`);
|
|
59
|
-
}
|
|
60
|
-
return v.ok(input);
|
|
61
|
-
});
|
|
51
|
+
export const nonLocalWebUriSchema = v.pipe(webUriSchema, v.check((input) => !isLocalHostname(new URL(input).hostname), `hostname is invalid`));
|
|
62
52
|
/** private-use URI scheme (e.g., com.example.app:/callback) */
|
|
63
|
-
export const privateUseUriSchema = urlSchema.
|
|
53
|
+
export const privateUseUriSchema = v.pipe(urlSchema, v.rawCheck(({ dataset, addIssue }) => {
|
|
54
|
+
if (!dataset.typed) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const input = dataset.value;
|
|
64
58
|
const dotIdx = input.indexOf('.');
|
|
65
59
|
const colonIdx = input.indexOf(':');
|
|
66
60
|
if (dotIdx === -1 || colonIdx === -1 || dotIdx > colonIdx) {
|
|
67
|
-
|
|
61
|
+
addIssue({ message: `private-use uri scheme must contain a dot in the protocol` });
|
|
62
|
+
return;
|
|
68
63
|
}
|
|
69
64
|
const url = new URL(input);
|
|
70
65
|
const scheme = url.protocol.slice(0, -1);
|
|
66
|
+
// oxlint-disable-next-line unicorn/no-array-reverse -- split already clones
|
|
71
67
|
const domain = scheme.split('.').reverse().join('.');
|
|
72
68
|
if (isLocalHostname(domain)) {
|
|
73
|
-
|
|
69
|
+
addIssue({ message: `private-use uri scheme must not be a local hostname` });
|
|
70
|
+
return;
|
|
74
71
|
}
|
|
75
72
|
// RFC 8252: private-use URIs must use single slash after scheme
|
|
76
|
-
if (url.href.startsWith(`${url.protocol}//`) ||
|
|
77
|
-
|
|
73
|
+
if (url.href.startsWith(`${url.protocol}//`) ||
|
|
74
|
+
url.username ||
|
|
75
|
+
url.password ||
|
|
76
|
+
url.hostname ||
|
|
77
|
+
url.port) {
|
|
78
|
+
addIssue({ message: `private-use uri must be in the form scheme:/<path>` });
|
|
78
79
|
}
|
|
79
|
-
|
|
80
|
-
});
|
|
80
|
+
}));
|
|
81
81
|
//# sourceMappingURL=uri.js.map
|
package/dist/schemas/uri.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uri.js","sourceRoot":"","sources":["../../lib/schemas/uri.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"uri.js","sourceRoot":"","sources":["../../lib/schemas/uri.ts"],"names":[],"mappings":"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"}
|