@atproto/oauth-types 0.2.7 → 0.2.8
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/CHANGELOG.md +9 -0
- package/LICENSE.txt +1 -1
- package/dist/oauth-authorization-request-par.d.ts +19 -19
- package/dist/oauth-authorization-request-parameters.d.ts +22 -19
- package/dist/oauth-authorization-request-parameters.d.ts.map +1 -1
- package/dist/oauth-authorization-request-parameters.js +9 -3
- package/dist/oauth-authorization-request-parameters.js.map +1 -1
- package/dist/oauth-authorization-request-query.d.ts +19 -19
- package/dist/util.d.ts +2 -0
- package/dist/util.d.ts.map +1 -1
- package/dist/util.js +22 -0
- package/dist/util.js.map +1 -1
- package/package.json +2 -2
- package/src/oauth-authorization-request-parameters.ts +15 -6
- package/src/util.ts +20 -0
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
# @atproto/oauth-types
|
2
2
|
|
3
|
+
## 0.2.8
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- [#3919](https://github.com/bluesky-social/atproto/pull/3919) [`a3b24ca77`](https://github.com/bluesky-social/atproto/commit/a3b24ca77ca24ac19b17cf9ee2a5ca9612ccf96c) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Parse JSON encoded Authorization Request Parameters
|
8
|
+
|
9
|
+
- Updated dependencies [[`3fa2ee3b6`](https://github.com/bluesky-social/atproto/commit/3fa2ee3b6a382709b10921da53e69a901bccbb05)]:
|
10
|
+
- @atproto/jwk@0.2.0
|
11
|
+
|
3
12
|
## 0.2.7
|
4
13
|
|
5
14
|
### Patch Changes
|
package/LICENSE.txt
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Dual MIT/Apache-2.0 License
|
2
2
|
|
3
|
-
Copyright (c) 2022-2025 Bluesky PBC, and Contributors
|
3
|
+
Copyright (c) 2022-2025 Bluesky Social PBC, and Contributors
|
4
4
|
|
5
5
|
Except as otherwise noted in individual files, this software is licensed under the MIT license (<http://opensource.org/licenses/MIT>), or the Apache License, Version 2.0 (<http://www.apache.org/licenses/LICENSE-2.0>).
|
6
6
|
|
@@ -10,8 +10,8 @@ export declare const oauthAuthorizationRequestParSchema: z.ZodUnion<[z.ZodObject
|
|
10
10
|
dpop_jkt: z.ZodOptional<z.ZodString>;
|
11
11
|
response_mode: z.ZodOptional<z.ZodEnum<["query", "fragment", "form_post"]>>;
|
12
12
|
nonce: z.ZodOptional<z.ZodString>;
|
13
|
-
max_age: z.ZodOptional<z.ZodNumber
|
14
|
-
claims: z.ZodOptional<z.ZodRecord<z.ZodEnum<["userinfo", "id_token"]>, z.ZodRecord<z.ZodEnum<["auth_time", "nonce", "acr", "name", "family_name", "given_name", "middle_name", "nickname", "preferred_username", "gender", "picture", "profile", "website", "birthdate", "zoneinfo", "locale", "updated_at", "email", "email_verified", "phone_number", "phone_number_verified", "address"]>, z.ZodUnion<[z.ZodLiteral<null>, z.ZodObject<{
|
13
|
+
max_age: z.ZodOptional<z.ZodEffects<z.ZodNumber, number, unknown>>;
|
14
|
+
claims: z.ZodOptional<z.ZodEffects<z.ZodRecord<z.ZodEnum<["userinfo", "id_token"]>, z.ZodRecord<z.ZodEnum<["auth_time", "nonce", "acr", "name", "family_name", "given_name", "middle_name", "nickname", "preferred_username", "gender", "picture", "profile", "website", "birthdate", "zoneinfo", "locale", "updated_at", "email", "email_verified", "phone_number", "phone_number_verified", "address"]>, z.ZodUnion<[z.ZodLiteral<null>, z.ZodObject<{
|
15
15
|
essential: z.ZodOptional<z.ZodBoolean>;
|
16
16
|
value: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
17
17
|
values: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>, "many">>;
|
@@ -23,13 +23,17 @@ export declare const oauthAuthorizationRequestParSchema: z.ZodUnion<[z.ZodObject
|
|
23
23
|
value?: string | number | boolean | undefined;
|
24
24
|
values?: (string | number | boolean)[] | undefined;
|
25
25
|
essential?: boolean | undefined;
|
26
|
-
}>]
|
26
|
+
}>]>>>, Partial<Record<"id_token" | "userinfo", Partial<Record<"email" | "auth_time" | "nonce" | "acr" | "name" | "family_name" | "given_name" | "middle_name" | "nickname" | "preferred_username" | "gender" | "picture" | "profile" | "website" | "birthdate" | "zoneinfo" | "locale" | "updated_at" | "email_verified" | "phone_number" | "phone_number_verified" | "address", {
|
27
|
+
value?: string | number | boolean | undefined;
|
28
|
+
values?: (string | number | boolean)[] | undefined;
|
29
|
+
essential?: boolean | undefined;
|
30
|
+
} | null>>>>, unknown>>;
|
27
31
|
login_hint: z.ZodOptional<z.ZodString>;
|
28
32
|
ui_locales: z.ZodOptional<z.ZodString>;
|
29
33
|
id_token_hint: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, `${string}.${string}.${string}`, string>>;
|
30
34
|
display: z.ZodOptional<z.ZodEnum<["page", "popup", "touch", "wap"]>>;
|
31
35
|
prompt: z.ZodOptional<z.ZodEnum<["none", "login", "consent", "select_account"]>>;
|
32
|
-
authorization_details: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
36
|
+
authorization_details: z.ZodOptional<z.ZodEffects<z.ZodArray<z.ZodObject<{
|
33
37
|
type: z.ZodString;
|
34
38
|
locations: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, `${string}:${string}`, string>, "many">>;
|
35
39
|
actions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
@@ -50,7 +54,14 @@ export declare const oauthAuthorizationRequestParSchema: z.ZodUnion<[z.ZodObject
|
|
50
54
|
datatypes?: string[] | undefined;
|
51
55
|
identifier?: string | undefined;
|
52
56
|
privileges?: string[] | undefined;
|
53
|
-
}>, "many"
|
57
|
+
}>, "many">, {
|
58
|
+
type: string;
|
59
|
+
locations?: `${string}:${string}`[] | undefined;
|
60
|
+
actions?: string[] | undefined;
|
61
|
+
datatypes?: string[] | undefined;
|
62
|
+
identifier?: string | undefined;
|
63
|
+
privileges?: string[] | undefined;
|
64
|
+
}[], unknown>>;
|
54
65
|
}, "strip", z.ZodTypeAny, {
|
55
66
|
client_id: string;
|
56
67
|
response_type: "code" | "none" | "token" | "code id_token token" | "code id_token" | "code token" | "id_token token" | "id_token";
|
@@ -92,25 +103,14 @@ export declare const oauthAuthorizationRequestParSchema: z.ZodUnion<[z.ZodObject
|
|
92
103
|
code_challenge_method?: "S256" | "plain" | undefined;
|
93
104
|
dpop_jkt?: string | undefined;
|
94
105
|
response_mode?: "query" | "fragment" | "form_post" | undefined;
|
95
|
-
max_age?:
|
96
|
-
claims?:
|
97
|
-
value?: string | number | boolean | undefined;
|
98
|
-
values?: (string | number | boolean)[] | undefined;
|
99
|
-
essential?: boolean | undefined;
|
100
|
-
} | null>>>> | undefined;
|
106
|
+
max_age?: unknown;
|
107
|
+
claims?: unknown;
|
101
108
|
login_hint?: string | undefined;
|
102
109
|
ui_locales?: string | undefined;
|
103
110
|
id_token_hint?: string | undefined;
|
104
111
|
display?: "page" | "popup" | "touch" | "wap" | undefined;
|
105
112
|
prompt?: "none" | "login" | "consent" | "select_account" | undefined;
|
106
|
-
authorization_details?:
|
107
|
-
type: string;
|
108
|
-
locations?: string[] | undefined;
|
109
|
-
actions?: string[] | undefined;
|
110
|
-
datatypes?: string[] | undefined;
|
111
|
-
identifier?: string | undefined;
|
112
|
-
privileges?: string[] | undefined;
|
113
|
-
}[] | undefined;
|
113
|
+
authorization_details?: unknown;
|
114
114
|
}>, z.ZodObject<{
|
115
115
|
request: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, `${string}.${string}.${string}`, string>, z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, `${string}.${string}`, string>]>;
|
116
116
|
}, "strip", z.ZodTypeAny, {
|
@@ -1,5 +1,8 @@
|
|
1
1
|
import { z } from 'zod';
|
2
2
|
/**
|
3
|
+
* @note non string parameters will be converted from their string
|
4
|
+
* representation since oauth request parameters are typically sent as URL
|
5
|
+
* encoded form data or URL encoded query string.
|
3
6
|
* @see {@link https://openid.net/specs/openid-connect-core-1_0.html#AuthRequest | OIDC}
|
4
7
|
*/
|
5
8
|
export declare const oauthAuthorizationRequestParametersSchema: z.ZodObject<{
|
@@ -13,8 +16,8 @@ export declare const oauthAuthorizationRequestParametersSchema: z.ZodObject<{
|
|
13
16
|
dpop_jkt: z.ZodOptional<z.ZodString>;
|
14
17
|
response_mode: z.ZodOptional<z.ZodEnum<["query", "fragment", "form_post"]>>;
|
15
18
|
nonce: z.ZodOptional<z.ZodString>;
|
16
|
-
max_age: z.ZodOptional<z.ZodNumber
|
17
|
-
claims: z.ZodOptional<z.ZodRecord<z.ZodEnum<["userinfo", "id_token"]>, z.ZodRecord<z.ZodEnum<["auth_time", "nonce", "acr", "name", "family_name", "given_name", "middle_name", "nickname", "preferred_username", "gender", "picture", "profile", "website", "birthdate", "zoneinfo", "locale", "updated_at", "email", "email_verified", "phone_number", "phone_number_verified", "address"]>, z.ZodUnion<[z.ZodLiteral<null>, z.ZodObject<{
|
19
|
+
max_age: z.ZodOptional<z.ZodEffects<z.ZodNumber, number, unknown>>;
|
20
|
+
claims: z.ZodOptional<z.ZodEffects<z.ZodRecord<z.ZodEnum<["userinfo", "id_token"]>, z.ZodRecord<z.ZodEnum<["auth_time", "nonce", "acr", "name", "family_name", "given_name", "middle_name", "nickname", "preferred_username", "gender", "picture", "profile", "website", "birthdate", "zoneinfo", "locale", "updated_at", "email", "email_verified", "phone_number", "phone_number_verified", "address"]>, z.ZodUnion<[z.ZodLiteral<null>, z.ZodObject<{
|
18
21
|
essential: z.ZodOptional<z.ZodBoolean>;
|
19
22
|
value: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
20
23
|
values: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>, "many">>;
|
@@ -26,7 +29,11 @@ export declare const oauthAuthorizationRequestParametersSchema: z.ZodObject<{
|
|
26
29
|
value?: string | number | boolean | undefined;
|
27
30
|
values?: (string | number | boolean)[] | undefined;
|
28
31
|
essential?: boolean | undefined;
|
29
|
-
}>]
|
32
|
+
}>]>>>, Partial<Record<"id_token" | "userinfo", Partial<Record<"email" | "auth_time" | "nonce" | "acr" | "name" | "family_name" | "given_name" | "middle_name" | "nickname" | "preferred_username" | "gender" | "picture" | "profile" | "website" | "birthdate" | "zoneinfo" | "locale" | "updated_at" | "email_verified" | "phone_number" | "phone_number_verified" | "address", {
|
33
|
+
value?: string | number | boolean | undefined;
|
34
|
+
values?: (string | number | boolean)[] | undefined;
|
35
|
+
essential?: boolean | undefined;
|
36
|
+
} | null>>>>, unknown>>;
|
30
37
|
login_hint: z.ZodOptional<z.ZodString>;
|
31
38
|
ui_locales: z.ZodOptional<z.ZodString>;
|
32
39
|
id_token_hint: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, `${string}.${string}.${string}`, string>>;
|
@@ -38,7 +45,7 @@ export declare const oauthAuthorizationRequestParametersSchema: z.ZodObject<{
|
|
38
45
|
* - "select_account" will force the user to select an account
|
39
46
|
*/
|
40
47
|
prompt: z.ZodOptional<z.ZodEnum<["none", "login", "consent", "select_account"]>>;
|
41
|
-
authorization_details: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
48
|
+
authorization_details: z.ZodOptional<z.ZodEffects<z.ZodArray<z.ZodObject<{
|
42
49
|
type: z.ZodString;
|
43
50
|
locations: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, `${string}:${string}`, string>, "many">>;
|
44
51
|
actions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
@@ -59,7 +66,14 @@ export declare const oauthAuthorizationRequestParametersSchema: z.ZodObject<{
|
|
59
66
|
datatypes?: string[] | undefined;
|
60
67
|
identifier?: string | undefined;
|
61
68
|
privileges?: string[] | undefined;
|
62
|
-
}>, "many"
|
69
|
+
}>, "many">, {
|
70
|
+
type: string;
|
71
|
+
locations?: `${string}:${string}`[] | undefined;
|
72
|
+
actions?: string[] | undefined;
|
73
|
+
datatypes?: string[] | undefined;
|
74
|
+
identifier?: string | undefined;
|
75
|
+
privileges?: string[] | undefined;
|
76
|
+
}[], unknown>>;
|
63
77
|
}, "strip", z.ZodTypeAny, {
|
64
78
|
client_id: string;
|
65
79
|
response_type: "code" | "none" | "token" | "code id_token token" | "code id_token" | "code token" | "id_token token" | "id_token";
|
@@ -101,25 +115,14 @@ export declare const oauthAuthorizationRequestParametersSchema: z.ZodObject<{
|
|
101
115
|
code_challenge_method?: "S256" | "plain" | undefined;
|
102
116
|
dpop_jkt?: string | undefined;
|
103
117
|
response_mode?: "query" | "fragment" | "form_post" | undefined;
|
104
|
-
max_age?:
|
105
|
-
claims?:
|
106
|
-
value?: string | number | boolean | undefined;
|
107
|
-
values?: (string | number | boolean)[] | undefined;
|
108
|
-
essential?: boolean | undefined;
|
109
|
-
} | null>>>> | undefined;
|
118
|
+
max_age?: unknown;
|
119
|
+
claims?: unknown;
|
110
120
|
login_hint?: string | undefined;
|
111
121
|
ui_locales?: string | undefined;
|
112
122
|
id_token_hint?: string | undefined;
|
113
123
|
display?: "page" | "popup" | "touch" | "wap" | undefined;
|
114
124
|
prompt?: "none" | "login" | "consent" | "select_account" | undefined;
|
115
|
-
authorization_details?:
|
116
|
-
type: string;
|
117
|
-
locations?: string[] | undefined;
|
118
|
-
actions?: string[] | undefined;
|
119
|
-
datatypes?: string[] | undefined;
|
120
|
-
identifier?: string | undefined;
|
121
|
-
privileges?: string[] | undefined;
|
122
|
-
}[] | undefined;
|
125
|
+
authorization_details?: unknown;
|
123
126
|
}>;
|
124
127
|
/**
|
125
128
|
* @see {oauthAuthorizationRequestParametersSchema}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"oauth-authorization-request-parameters.d.ts","sourceRoot":"","sources":["../src/oauth-authorization-request-parameters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;
|
1
|
+
{"version":3,"file":"oauth-authorization-request-parameters.d.ts","sourceRoot":"","sources":["../src/oauth-authorization-request-parameters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAcvB;;;;;GAKG;AACH,eAAO,MAAM,yCAAyC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAiEpD;;;;;OAKG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAOH,CAAA;AAEF;;GAEG;AACH,MAAM,MAAM,mCAAmC,GAAG,CAAC,CAAC,KAAK,CACvD,OAAO,yCAAyC,CACjD,CAAA"}
|
@@ -13,7 +13,11 @@ const oauth_scope_js_1 = require("./oauth-scope.js");
|
|
13
13
|
const oidc_claims_parameter_js_1 = require("./oidc-claims-parameter.js");
|
14
14
|
const oidc_claims_properties_js_1 = require("./oidc-claims-properties.js");
|
15
15
|
const oidc_entity_type_js_1 = require("./oidc-entity-type.js");
|
16
|
+
const util_js_1 = require("./util.js");
|
16
17
|
/**
|
18
|
+
* @note non string parameters will be converted from their string
|
19
|
+
* representation since oauth request parameters are typically sent as URL
|
20
|
+
* encoded form data or URL encoded query string.
|
17
21
|
* @see {@link https://openid.net/specs/openid-connect-core-1_0.html#AuthRequest | OIDC}
|
18
22
|
*/
|
19
23
|
exports.oauthAuthorizationRequestParametersSchema = zod_1.z.object({
|
@@ -41,9 +45,9 @@ exports.oauthAuthorizationRequestParametersSchema = zod_1.z.object({
|
|
41
45
|
// PAPE [OpenID.PAPE] max_auth_age request parameter.) When max_age is used,
|
42
46
|
// the ID Token returned MUST include an auth_time Claim Value. Note that
|
43
47
|
// max_age=0 is equivalent to prompt=login.
|
44
|
-
max_age: zod_1.z.number().int().min(0).optional(),
|
48
|
+
max_age: zod_1.z.preprocess(util_js_1.numberPreprocess, zod_1.z.number().int().min(0)).optional(),
|
45
49
|
claims: zod_1.z
|
46
|
-
.record(oidc_entity_type_js_1.oidcEntityTypeSchema, zod_1.z.record(oidc_claims_parameter_js_1.oidcClaimsParameterSchema, zod_1.z.union([zod_1.z.literal(null), oidc_claims_properties_js_1.oidcClaimsPropertiesSchema])))
|
50
|
+
.preprocess(util_js_1.jsonObjectPreprocess, zod_1.z.record(oidc_entity_type_js_1.oidcEntityTypeSchema, zod_1.z.record(oidc_claims_parameter_js_1.oidcClaimsParameterSchema, zod_1.z.union([zod_1.z.literal(null), oidc_claims_properties_js_1.oidcClaimsPropertiesSchema]))))
|
47
51
|
.optional(),
|
48
52
|
// https://openid.net/specs/openid-connect-core-1_0.html#RegistrationParameter
|
49
53
|
// Not supported by this library (yet?)
|
@@ -65,6 +69,8 @@ exports.oauthAuthorizationRequestParametersSchema = zod_1.z.object({
|
|
65
69
|
*/
|
66
70
|
prompt: zod_1.z.enum(['none', 'login', 'consent', 'select_account']).optional(),
|
67
71
|
// https://datatracker.ietf.org/doc/html/rfc9396
|
68
|
-
authorization_details:
|
72
|
+
authorization_details: zod_1.z
|
73
|
+
.preprocess(util_js_1.jsonObjectPreprocess, oauth_authorization_details_js_1.oauthAuthorizationDetailsSchema)
|
74
|
+
.optional(),
|
69
75
|
});
|
70
76
|
//# sourceMappingURL=oauth-authorization-request-parameters.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"oauth-authorization-request-parameters.js","sourceRoot":"","sources":["../src/oauth-authorization-request-parameters.ts"],"names":[],"mappings":";;;AAAA,6BAAuB;AACvB,sCAA8C;AAC9C,qFAAkF;AAClF,6DAA0D;AAC1D,qFAAiF;AACjF,mEAAgE;AAChE,qEAAkE;AAClE,qEAAkE;AAClE,qDAAmD;AACnD,yEAAsE;AACtE,2EAAwE;AACxE,+DAA4D;
|
1
|
+
{"version":3,"file":"oauth-authorization-request-parameters.js","sourceRoot":"","sources":["../src/oauth-authorization-request-parameters.ts"],"names":[],"mappings":";;;AAAA,6BAAuB;AACvB,sCA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AAC,CAAC,OAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,sDAA0B,CAAC,CAAC,CACvD,CACF,CACF;SACA,QAAQ,EAAE;IAEb,8EAA8E;IAC9E,uCAAuC;IACvC,iDAAiD;IAEjD,UAAU,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IAExC,UAAU,EAAE,OAAC;SACV,MAAM,EAAE;SACR,KAAK,CAAC,oDAAoD,CAAC,CAAC,cAAc;SAC1E,QAAQ,EAAE;IAEb,iEAAiE;IACjE,aAAa,EAAE,qBAAe,CAAC,QAAQ,EAAE;IAEzC,oCAAoC;IACpC,OAAO,EAAE,OAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,QAAQ,EAAE;IAE7D;;;;;OAKG;IACH,MAAM,EAAE,OAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,gBAAgB,CAAC,CAAC,CAAC,QAAQ,EAAE;IAEzE,gDAAgD;IAChD,qBAAqB,EAAE,OAAC;SACrB,UAAU,CAAC,8BAAoB,EAAE,gEAA+B,CAAC;SACjE,QAAQ,EAAE;CACd,CAAC,CAAA"}
|
@@ -10,8 +10,8 @@ export declare const oauthAuthorizationRequestQuerySchema: z.ZodUnion<[z.ZodObje
|
|
10
10
|
dpop_jkt: z.ZodOptional<z.ZodString>;
|
11
11
|
response_mode: z.ZodOptional<z.ZodEnum<["query", "fragment", "form_post"]>>;
|
12
12
|
nonce: z.ZodOptional<z.ZodString>;
|
13
|
-
max_age: z.ZodOptional<z.ZodNumber
|
14
|
-
claims: z.ZodOptional<z.ZodRecord<z.ZodEnum<["userinfo", "id_token"]>, z.ZodRecord<z.ZodEnum<["auth_time", "nonce", "acr", "name", "family_name", "given_name", "middle_name", "nickname", "preferred_username", "gender", "picture", "profile", "website", "birthdate", "zoneinfo", "locale", "updated_at", "email", "email_verified", "phone_number", "phone_number_verified", "address"]>, z.ZodUnion<[z.ZodLiteral<null>, z.ZodObject<{
|
13
|
+
max_age: z.ZodOptional<z.ZodEffects<z.ZodNumber, number, unknown>>;
|
14
|
+
claims: z.ZodOptional<z.ZodEffects<z.ZodRecord<z.ZodEnum<["userinfo", "id_token"]>, z.ZodRecord<z.ZodEnum<["auth_time", "nonce", "acr", "name", "family_name", "given_name", "middle_name", "nickname", "preferred_username", "gender", "picture", "profile", "website", "birthdate", "zoneinfo", "locale", "updated_at", "email", "email_verified", "phone_number", "phone_number_verified", "address"]>, z.ZodUnion<[z.ZodLiteral<null>, z.ZodObject<{
|
15
15
|
essential: z.ZodOptional<z.ZodBoolean>;
|
16
16
|
value: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
17
17
|
values: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>, "many">>;
|
@@ -23,13 +23,17 @@ export declare const oauthAuthorizationRequestQuerySchema: z.ZodUnion<[z.ZodObje
|
|
23
23
|
value?: string | number | boolean | undefined;
|
24
24
|
values?: (string | number | boolean)[] | undefined;
|
25
25
|
essential?: boolean | undefined;
|
26
|
-
}>]
|
26
|
+
}>]>>>, Partial<Record<"id_token" | "userinfo", Partial<Record<"email" | "auth_time" | "nonce" | "acr" | "name" | "family_name" | "given_name" | "middle_name" | "nickname" | "preferred_username" | "gender" | "picture" | "profile" | "website" | "birthdate" | "zoneinfo" | "locale" | "updated_at" | "email_verified" | "phone_number" | "phone_number_verified" | "address", {
|
27
|
+
value?: string | number | boolean | undefined;
|
28
|
+
values?: (string | number | boolean)[] | undefined;
|
29
|
+
essential?: boolean | undefined;
|
30
|
+
} | null>>>>, unknown>>;
|
27
31
|
login_hint: z.ZodOptional<z.ZodString>;
|
28
32
|
ui_locales: z.ZodOptional<z.ZodString>;
|
29
33
|
id_token_hint: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, `${string}.${string}.${string}`, string>>;
|
30
34
|
display: z.ZodOptional<z.ZodEnum<["page", "popup", "touch", "wap"]>>;
|
31
35
|
prompt: z.ZodOptional<z.ZodEnum<["none", "login", "consent", "select_account"]>>;
|
32
|
-
authorization_details: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
36
|
+
authorization_details: z.ZodOptional<z.ZodEffects<z.ZodArray<z.ZodObject<{
|
33
37
|
type: z.ZodString;
|
34
38
|
locations: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, `${string}:${string}`, string>, "many">>;
|
35
39
|
actions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
@@ -50,7 +54,14 @@ export declare const oauthAuthorizationRequestQuerySchema: z.ZodUnion<[z.ZodObje
|
|
50
54
|
datatypes?: string[] | undefined;
|
51
55
|
identifier?: string | undefined;
|
52
56
|
privileges?: string[] | undefined;
|
53
|
-
}>, "many"
|
57
|
+
}>, "many">, {
|
58
|
+
type: string;
|
59
|
+
locations?: `${string}:${string}`[] | undefined;
|
60
|
+
actions?: string[] | undefined;
|
61
|
+
datatypes?: string[] | undefined;
|
62
|
+
identifier?: string | undefined;
|
63
|
+
privileges?: string[] | undefined;
|
64
|
+
}[], unknown>>;
|
54
65
|
}, "strip", z.ZodTypeAny, {
|
55
66
|
client_id: string;
|
56
67
|
response_type: "code" | "none" | "token" | "code id_token token" | "code id_token" | "code token" | "id_token token" | "id_token";
|
@@ -92,25 +103,14 @@ export declare const oauthAuthorizationRequestQuerySchema: z.ZodUnion<[z.ZodObje
|
|
92
103
|
code_challenge_method?: "S256" | "plain" | undefined;
|
93
104
|
dpop_jkt?: string | undefined;
|
94
105
|
response_mode?: "query" | "fragment" | "form_post" | undefined;
|
95
|
-
max_age?:
|
96
|
-
claims?:
|
97
|
-
value?: string | number | boolean | undefined;
|
98
|
-
values?: (string | number | boolean)[] | undefined;
|
99
|
-
essential?: boolean | undefined;
|
100
|
-
} | null>>>> | undefined;
|
106
|
+
max_age?: unknown;
|
107
|
+
claims?: unknown;
|
101
108
|
login_hint?: string | undefined;
|
102
109
|
ui_locales?: string | undefined;
|
103
110
|
id_token_hint?: string | undefined;
|
104
111
|
display?: "page" | "popup" | "touch" | "wap" | undefined;
|
105
112
|
prompt?: "none" | "login" | "consent" | "select_account" | undefined;
|
106
|
-
authorization_details?:
|
107
|
-
type: string;
|
108
|
-
locations?: string[] | undefined;
|
109
|
-
actions?: string[] | undefined;
|
110
|
-
datatypes?: string[] | undefined;
|
111
|
-
identifier?: string | undefined;
|
112
|
-
privileges?: string[] | undefined;
|
113
|
-
}[] | undefined;
|
113
|
+
authorization_details?: unknown;
|
114
114
|
}>, z.ZodObject<{
|
115
115
|
request: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, `${string}.${string}.${string}`, string>, z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, `${string}.${string}`, string>]>;
|
116
116
|
}, "strip", z.ZodTypeAny, {
|
package/dist/util.d.ts
CHANGED
@@ -4,4 +4,6 @@ export declare function isLoopbackHost(host: unknown): host is LoopbackHost;
|
|
4
4
|
export declare function isLoopbackUrl(input: URL | string): boolean;
|
5
5
|
export declare function safeUrl(input: URL | string): URL | null;
|
6
6
|
export declare function extractUrlPath(url: any): any;
|
7
|
+
export declare const jsonObjectPreprocess: (val: unknown) => any;
|
8
|
+
export declare const numberPreprocess: (val: unknown) => unknown;
|
7
9
|
//# sourceMappingURL=util.d.ts.map
|
package/dist/util.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,WAQ5C;AAED,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG,WAAW,GAAG,OAAO,CAAA;AAE9D,wBAAgB,cAAc,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,YAAY,CAElE;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,GAAG,GAAG,MAAM,GAAG,OAAO,CAG1D;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,GAAG,GAAG,MAAM,GAAG,GAAG,GAAG,IAAI,CAMvD;AAED,wBAAgB,cAAc,CAAC,GAAG,KAAA,OAsCjC"}
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,WAQ5C;AAED,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG,WAAW,GAAG,OAAO,CAAA;AAE9D,wBAAgB,cAAc,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,YAAY,CAElE;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,GAAG,GAAG,MAAM,GAAG,OAAO,CAG1D;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,GAAG,GAAG,MAAM,GAAG,GAAG,GAAG,IAAI,CAMvD;AAED,wBAAgB,cAAc,CAAC,GAAG,KAAA,OAsCjC;AAED,eAAO,MAAM,oBAAoB,GAAI,KAAK,OAAO,QAUhD,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAI,KAAK,OAAO,KAAG,OAM/C,CAAA"}
|
package/dist/util.js
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.numberPreprocess = exports.jsonObjectPreprocess = void 0;
|
3
4
|
exports.isHostnameIP = isHostnameIP;
|
4
5
|
exports.isLoopbackHost = isLoopbackHost;
|
5
6
|
exports.isLoopbackUrl = isLoopbackUrl;
|
@@ -59,4 +60,25 @@ function extractUrlPath(url) {
|
|
59
60
|
}
|
60
61
|
return url.substring(pathStart, pathEnd);
|
61
62
|
}
|
63
|
+
const jsonObjectPreprocess = (val) => {
|
64
|
+
if (typeof val === 'string' && val.startsWith('{') && val.endsWith('}')) {
|
65
|
+
try {
|
66
|
+
return JSON.parse(val);
|
67
|
+
}
|
68
|
+
catch {
|
69
|
+
return val;
|
70
|
+
}
|
71
|
+
}
|
72
|
+
return val;
|
73
|
+
};
|
74
|
+
exports.jsonObjectPreprocess = jsonObjectPreprocess;
|
75
|
+
const numberPreprocess = (val) => {
|
76
|
+
if (typeof val === 'string') {
|
77
|
+
const number = Number(val);
|
78
|
+
if (!Number.isNaN(number))
|
79
|
+
return number;
|
80
|
+
}
|
81
|
+
return val;
|
82
|
+
};
|
83
|
+
exports.numberPreprocess = numberPreprocess;
|
62
84
|
//# sourceMappingURL=util.js.map
|
package/dist/util.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;;AAAA,oCAQC;AAID,wCAEC;AAED,sCAGC;AAED,0BAMC;AAED,wCAsCC;AAnED,SAAgB,YAAY,CAAC,QAAgB;IAC3C,OAAO;IACP,IAAI,QAAQ,CAAC,KAAK,CAAC,sBAAsB,CAAC;QAAE,OAAO,IAAI,CAAA;IAEvD,OAAO;IACP,IAAI,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,CAAA;IAEnE,OAAO,KAAK,CAAA;AACd,CAAC;AAID,SAAgB,cAAc,CAAC,IAAa;IAC1C,OAAO,IAAI,KAAK,WAAW,IAAI,IAAI,KAAK,WAAW,IAAI,IAAI,KAAK,OAAO,CAAA;AACzE,CAAC;AAED,SAAgB,aAAa,CAAC,KAAmB;IAC/C,MAAM,GAAG,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAA;IAC9D,OAAO,cAAc,CAAC,GAAG,C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uth typing & validation library",
|
6
6
|
"keywords": [
|
@@ -26,7 +26,7 @@
|
|
26
26
|
},
|
27
27
|
"dependencies": {
|
28
28
|
"zod": "^3.23.8",
|
29
|
-
"@atproto/jwk": "0.
|
29
|
+
"@atproto/jwk": "0.2.0"
|
30
30
|
},
|
31
31
|
"devDependencies": {
|
32
32
|
"typescript": "^5.6.3"
|
@@ -10,8 +10,12 @@ import { oauthScopeSchema } from './oauth-scope.js'
|
|
10
10
|
import { oidcClaimsParameterSchema } from './oidc-claims-parameter.js'
|
11
11
|
import { oidcClaimsPropertiesSchema } from './oidc-claims-properties.js'
|
12
12
|
import { oidcEntityTypeSchema } from './oidc-entity-type.js'
|
13
|
+
import { jsonObjectPreprocess, numberPreprocess } from './util.js'
|
13
14
|
|
14
15
|
/**
|
16
|
+
* @note non string parameters will be converted from their string
|
17
|
+
* representation since oauth request parameters are typically sent as URL
|
18
|
+
* encoded form data or URL encoded query string.
|
15
19
|
* @see {@link https://openid.net/specs/openid-connect-core-1_0.html#AuthRequest | OIDC}
|
16
20
|
*/
|
17
21
|
export const oauthAuthorizationRequestParametersSchema = z.object({
|
@@ -47,14 +51,17 @@ export const oauthAuthorizationRequestParametersSchema = z.object({
|
|
47
51
|
// PAPE [OpenID.PAPE] max_auth_age request parameter.) When max_age is used,
|
48
52
|
// the ID Token returned MUST include an auth_time Claim Value. Note that
|
49
53
|
// max_age=0 is equivalent to prompt=login.
|
50
|
-
max_age: z.number().int().min(0).optional(),
|
54
|
+
max_age: z.preprocess(numberPreprocess, z.number().int().min(0)).optional(),
|
51
55
|
|
52
56
|
claims: z
|
53
|
-
.
|
54
|
-
|
57
|
+
.preprocess(
|
58
|
+
jsonObjectPreprocess,
|
55
59
|
z.record(
|
56
|
-
|
57
|
-
z.
|
60
|
+
oidcEntityTypeSchema,
|
61
|
+
z.record(
|
62
|
+
oidcClaimsParameterSchema,
|
63
|
+
z.union([z.literal(null), oidcClaimsPropertiesSchema]),
|
64
|
+
),
|
58
65
|
),
|
59
66
|
)
|
60
67
|
.optional(),
|
@@ -85,7 +92,9 @@ export const oauthAuthorizationRequestParametersSchema = z.object({
|
|
85
92
|
prompt: z.enum(['none', 'login', 'consent', 'select_account']).optional(),
|
86
93
|
|
87
94
|
// https://datatracker.ietf.org/doc/html/rfc9396
|
88
|
-
authorization_details:
|
95
|
+
authorization_details: z
|
96
|
+
.preprocess(jsonObjectPreprocess, oauthAuthorizationDetailsSchema)
|
97
|
+
.optional(),
|
89
98
|
})
|
90
99
|
|
91
100
|
/**
|
package/src/util.ts
CHANGED
@@ -66,3 +66,23 @@ export function extractUrlPath(url) {
|
|
66
66
|
|
67
67
|
return url.substring(pathStart, pathEnd)
|
68
68
|
}
|
69
|
+
|
70
|
+
export const jsonObjectPreprocess = (val: unknown) => {
|
71
|
+
if (typeof val === 'string' && val.startsWith('{') && val.endsWith('}')) {
|
72
|
+
try {
|
73
|
+
return JSON.parse(val)
|
74
|
+
} catch {
|
75
|
+
return val
|
76
|
+
}
|
77
|
+
}
|
78
|
+
|
79
|
+
return val
|
80
|
+
}
|
81
|
+
|
82
|
+
export const numberPreprocess = (val: unknown): unknown => {
|
83
|
+
if (typeof val === 'string') {
|
84
|
+
const number = Number(val)
|
85
|
+
if (!Number.isNaN(number)) return number
|
86
|
+
}
|
87
|
+
return val
|
88
|
+
}
|