@go-mondo/identity-sdk 0.0.2-beta.76 → 0.0.2-beta.77
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/.release-please-manifest.json +1 -1
- package/.tsbuildinfo/cjs.json +1 -1
- package/.tsbuildinfo/esm.json +1 -1
- package/CHANGELOG.md +7 -0
- package/dist/cjs/app/authorization/schema.d.ts +10 -10
- package/dist/cjs/app/authorization/schema.d.ts.map +1 -1
- package/dist/cjs/app/authorization/schema.js +10 -10
- package/dist/cjs/app/authorization/schema.test.js +34 -4
- package/dist/esm/app/authorization/schema.d.ts +10 -10
- package/dist/esm/app/authorization/schema.d.ts.map +1 -1
- package/dist/esm/app/authorization/schema.js +6 -6
- package/dist/esm/app/authorization/schema.test.js +34 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.2-beta.77](https://github.com/go-mondo/identity-node-sdk/compare/identity-sdk-v0.0.2-beta.76...identity-sdk-v0.0.2-beta.77) (2026-05-06)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* authorization result schema ([549f07b](https://github.com/go-mondo/identity-node-sdk/commit/549f07b9b971cbd9a4e156b8baa8f86ed5c57963))
|
|
9
|
+
|
|
3
10
|
## [0.0.2-beta.76](https://github.com/go-mondo/identity-node-sdk/compare/identity-sdk-v0.0.2-beta.75...identity-sdk-v0.0.2-beta.76) (2026-05-06)
|
|
4
11
|
|
|
5
12
|
|
|
@@ -4,7 +4,6 @@ export declare const AuthorizationSchema: z.ZodObject<{
|
|
|
4
4
|
metadata: z.ZodPipe<z.ZodUnion<readonly [z.ZodUndefined, z.ZodNull, z.ZodCustom<Map<string, string | number | boolean>, Map<string, string | number | boolean>>, z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>]>, z.ZodTransform<Map<string, string | number | boolean>, Record<string, string | number | boolean> | Map<string, string | number | boolean> | null | undefined>>;
|
|
5
5
|
deactivatedAt: z.ZodOptional<z.ZodUnion<readonly [z.ZodDate, z.ZodPipe<z.ZodString, z.ZodTransform<Date, string>>]>>;
|
|
6
6
|
deletedAt: z.ZodOptional<z.ZodUnion<readonly [z.ZodDate, z.ZodPipe<z.ZodString, z.ZodTransform<Date, string>>]>>;
|
|
7
|
-
loginUri: z.ZodOptional<z.ZodUnion<readonly [z.ZodUnion<[z.ZodPipe<z.ZodURL, z.ZodTransform<URL, string>>, z.ZodCustom<URL, URL>]>, z.ZodUndefined]>>;
|
|
8
7
|
callbackUrls: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodUndefined, z.ZodPipe<z.ZodArray<z.ZodUnion<[z.ZodPipe<z.ZodURL, z.ZodTransform<URL, string>>, z.ZodCustom<URL, URL>]>>, z.ZodTransform<URL[], URL[]>>, z.ZodCustom<Set<URL>, Set<URL>>]>, z.ZodTransform<Set<URL> | undefined, Set<URL> | URL[] | undefined>>>;
|
|
9
8
|
availableAudiences: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodUndefined, z.ZodPipe<z.ZodArray<z.ZodString>, z.ZodTransform<string[], string[]>>, z.ZodSet<z.ZodString>]>, z.ZodTransform<Set<string> | undefined, Set<string> | string[] | undefined>>>;
|
|
10
9
|
availableGrants: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodUndefined, z.ZodArray<z.ZodEnum<{
|
|
@@ -15,9 +14,9 @@ export declare const AuthorizationSchema: z.ZodObject<{
|
|
|
15
14
|
}>>, z.ZodCustom<Set<AnyGrantType>, Set<AnyGrantType>>]>, z.ZodTransform<Set<AnyGrantType> | undefined, Set<AnyGrantType> | ("client_credentials" | "authorization_code" | "implicit" | "refresh_token")[] | undefined>>>;
|
|
16
15
|
defaultAudience: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodUndefined]>>;
|
|
17
16
|
updatedAt: z.ZodOptional<z.ZodUnion<readonly [z.ZodDate, z.ZodPipe<z.ZodString, z.ZodTransform<Date, string>>]>>;
|
|
18
|
-
refreshTokenDuration: z.ZodOptional<z.ZodNumber
|
|
19
|
-
accessTokenDuration: z.ZodOptional<z.ZodNumber
|
|
20
|
-
accessTokenSignatureAlgorithm: z.ZodOptional<z.ZodEnum<{
|
|
17
|
+
refreshTokenDuration: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<number | undefined, number | null | undefined>>>;
|
|
18
|
+
accessTokenDuration: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<number | undefined, number | null | undefined>>>;
|
|
19
|
+
accessTokenSignatureAlgorithm: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodEnum<{
|
|
21
20
|
RS256: "RS256";
|
|
22
21
|
RS384: "RS384";
|
|
23
22
|
RS512: "RS512";
|
|
@@ -27,7 +26,8 @@ export declare const AuthorizationSchema: z.ZodObject<{
|
|
|
27
26
|
PS256: "PS256";
|
|
28
27
|
PS384: "PS384";
|
|
29
28
|
PS512: "PS512";
|
|
30
|
-
}
|
|
29
|
+
}>, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<NonNullable<"RS256" | "RS384" | "RS512" | "ES256" | "ES384" | "ES512" | "PS256" | "PS384" | "PS512"> | undefined, "RS256" | "RS384" | "RS512" | "ES256" | "ES384" | "ES512" | "PS256" | "PS384" | "PS512" | null | undefined>>>;
|
|
30
|
+
loginUri: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodUnion<[z.ZodPipe<z.ZodCustom<URL, URL>, z.ZodTransform<string, URL>>, z.ZodURL]>, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<string | undefined, string | null | undefined>>>;
|
|
31
31
|
}, z.core.$strip>;
|
|
32
32
|
export type AuthorizationProperties = z.input<typeof AuthorizationSchema>;
|
|
33
33
|
export type Authorization = z.output<typeof AuthorizationSchema>;
|
|
@@ -35,7 +35,6 @@ export declare const AuthorizationPayloadSchema: z.ZodObject<{
|
|
|
35
35
|
metadata: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodUndefined, z.ZodNull, z.ZodCustom<Map<string, string | number | boolean>, Map<string, string | number | boolean>>, z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>]>, z.ZodTransform<Record<string, string | number | boolean> | undefined, Record<string, string | number | boolean> | Map<string, string | number | boolean> | null | undefined>>>;
|
|
36
36
|
deactivatedAt: z.ZodOptional<z.ZodPipe<z.ZodOptional<z.ZodUnion<readonly [z.ZodDate, z.ZodPipe<z.ZodString, z.ZodTransform<Date, string>>]>>, z.ZodTransform<string | undefined, Date | undefined>>>;
|
|
37
37
|
deletedAt: z.ZodOptional<z.ZodPipe<z.ZodOptional<z.ZodUnion<readonly [z.ZodDate, z.ZodPipe<z.ZodString, z.ZodTransform<Date, string>>]>>, z.ZodTransform<string | undefined, Date | undefined>>>;
|
|
38
|
-
loginUri: z.ZodOptional<z.ZodUnion<readonly [z.ZodUnion<[z.ZodPipe<z.ZodCustom<URL, URL>, z.ZodTransform<string, URL>>, z.ZodURL]>, z.ZodUndefined]>>;
|
|
39
38
|
callbackUrls: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodUndefined, z.ZodPipe<z.ZodArray<z.ZodUnion<[z.ZodPipe<z.ZodURL, z.ZodTransform<URL, string>>, z.ZodCustom<URL, URL>]>>, z.ZodTransform<URL[], URL[]>>, z.ZodCustom<Set<URL>, Set<URL>>]>, z.ZodTransform<string[] | undefined, Set<URL> | URL[] | undefined>>>;
|
|
40
39
|
availableAudiences: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodUndefined, z.ZodPipe<z.ZodArray<z.ZodString>, z.ZodTransform<string[], string[]>>, z.ZodSet<z.ZodString>]>, z.ZodTransform<string[] | undefined, Set<string> | string[] | undefined>>>;
|
|
41
40
|
availableGrants: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodUndefined, z.ZodArray<z.ZodEnum<{
|
|
@@ -46,9 +45,9 @@ export declare const AuthorizationPayloadSchema: z.ZodObject<{
|
|
|
46
45
|
}>>, z.ZodCustom<Set<AnyGrantType>, Set<AnyGrantType>>]>, z.ZodTransform<("client_credentials" | "authorization_code" | "implicit" | "refresh_token")[] | undefined, Set<AnyGrantType> | ("client_credentials" | "authorization_code" | "implicit" | "refresh_token")[] | undefined>>>;
|
|
47
46
|
defaultAudience: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodUndefined]>>;
|
|
48
47
|
updatedAt: z.ZodOptional<z.ZodPipe<z.ZodOptional<z.ZodUnion<readonly [z.ZodDate, z.ZodPipe<z.ZodString, z.ZodTransform<Date, string>>]>>, z.ZodTransform<string | undefined, Date | undefined>>>;
|
|
49
|
-
refreshTokenDuration: z.ZodOptional<z.ZodNumber
|
|
50
|
-
accessTokenDuration: z.ZodOptional<z.ZodNumber
|
|
51
|
-
accessTokenSignatureAlgorithm: z.ZodOptional<z.ZodEnum<{
|
|
48
|
+
refreshTokenDuration: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<number | undefined, number | null | undefined>>>;
|
|
49
|
+
accessTokenDuration: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<number | undefined, number | null | undefined>>>;
|
|
50
|
+
accessTokenSignatureAlgorithm: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodEnum<{
|
|
52
51
|
RS256: "RS256";
|
|
53
52
|
RS384: "RS384";
|
|
54
53
|
RS512: "RS512";
|
|
@@ -58,7 +57,8 @@ export declare const AuthorizationPayloadSchema: z.ZodObject<{
|
|
|
58
57
|
PS256: "PS256";
|
|
59
58
|
PS384: "PS384";
|
|
60
59
|
PS512: "PS512";
|
|
61
|
-
}
|
|
60
|
+
}>, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<NonNullable<"RS256" | "RS384" | "RS512" | "ES256" | "ES384" | "ES512" | "PS256" | "PS384" | "PS512"> | undefined, "RS256" | "RS384" | "RS512" | "ES256" | "ES384" | "ES512" | "PS256" | "PS384" | "PS512" | null | undefined>>>;
|
|
61
|
+
loginUri: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodUnion<[z.ZodPipe<z.ZodCustom<URL, URL>, z.ZodTransform<string, URL>>, z.ZodURL]>, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<string | undefined, string | null | undefined>>>;
|
|
62
62
|
}, z.core.$strip>;
|
|
63
63
|
export type AuthorizationPayload = z.output<typeof AuthorizationPayloadSchema>;
|
|
64
64
|
export declare const UpsertAuthorizationPayloadSchema: z.ZodObject<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../src/app/authorization/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAyB5B,OAAO,EAAE,KAAK,YAAY,EAAa,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../src/app/authorization/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAyB5B,OAAO,EAAE,KAAK,YAAY,EAAa,MAAM,8BAA8B,CAAC;AA6B5E,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAU9B,CAAC;AACH,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAC1E,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEjE,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAUrC,CAAC;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAE/E,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;iBAU3C,CAAC;AACH,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAC5C,OAAO,gCAAgC,CACxC,CAAC;AACF,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,MAAM,CAC/C,OAAO,gCAAgC,CACxC,CAAC"}
|
|
@@ -38,17 +38,18 @@ const z = __importStar(require("zod/v4"));
|
|
|
38
38
|
const dates_js_1 = require("../../common/schema/dates.js");
|
|
39
39
|
const jwt_js_1 = require("../../common/schema/jwt.js");
|
|
40
40
|
const metadata_js_1 = require("../../common/schema/metadata.js");
|
|
41
|
+
const schema_js_1 = require("../../common/schema/schema.js");
|
|
41
42
|
const sets_js_1 = require("../../common/schema/sets.js");
|
|
42
43
|
const url_js_1 = require("../../common/schema/url.js");
|
|
43
|
-
const
|
|
44
|
+
const schema_js_2 = require("../../oauth/common/schema.js");
|
|
44
45
|
const AudienceArraySchema = sets_js_1.UniqueStringArraySchema;
|
|
45
46
|
const AudienceSetSchema = sets_js_1.UniqueStringSetSchema;
|
|
46
47
|
const GrantSetSchema = z.instanceof((Set));
|
|
47
48
|
const GrantArraySchema = z.array(z.enum([
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
schema_js_2.GrantType.AUTHORIZATION_CODE,
|
|
50
|
+
schema_js_2.GrantType.CLIENT_CREDENTIALS,
|
|
51
|
+
schema_js_2.GrantType.IMPLICIT,
|
|
52
|
+
schema_js_2.GrantType.REFRESH_TOKEN,
|
|
52
53
|
]));
|
|
53
54
|
const AvailableGrantSetSchema = z
|
|
54
55
|
.union([z.undefined(), GrantArraySchema, GrantSetSchema])
|
|
@@ -57,13 +58,13 @@ const AvailableGrantArraySchema = z
|
|
|
57
58
|
.union([z.undefined(), GrantArraySchema, GrantSetSchema])
|
|
58
59
|
.pipe(z.transform((v) => (v instanceof Set ? Array.from(v.values()) : v)));
|
|
59
60
|
const BaseAuthorization = z.object({
|
|
60
|
-
refreshTokenDuration: z.number()
|
|
61
|
-
accessTokenDuration: z.number()
|
|
62
|
-
accessTokenSignatureAlgorithm: jwt_js_1.AlgorithmSchema
|
|
61
|
+
refreshTokenDuration: (0, schema_js_1.optionallyNullishToUndefined)(z.number()),
|
|
62
|
+
accessTokenDuration: (0, schema_js_1.optionallyNullishToUndefined)(z.number()),
|
|
63
|
+
accessTokenSignatureAlgorithm: (0, schema_js_1.optionallyNullishToUndefined)(jwt_js_1.AlgorithmSchema),
|
|
64
|
+
loginUri: (0, schema_js_1.optionallyNullishToUndefined)(url_js_1.WebUrlStringSchema),
|
|
63
65
|
});
|
|
64
66
|
exports.AuthorizationSchema = z.object({
|
|
65
67
|
...BaseAuthorization.shape,
|
|
66
|
-
loginUri: z.union([url_js_1.WebUrlObjectSchema, z.undefined()]).optional(),
|
|
67
68
|
callbackUrls: url_js_1.UniqueWebUrlObjectSetSchema.optional(),
|
|
68
69
|
availableAudiences: AudienceSetSchema.optional(),
|
|
69
70
|
availableGrants: AvailableGrantSetSchema.optional(),
|
|
@@ -75,7 +76,6 @@ exports.AuthorizationSchema = z.object({
|
|
|
75
76
|
});
|
|
76
77
|
exports.AuthorizationPayloadSchema = z.object({
|
|
77
78
|
...BaseAuthorization.shape,
|
|
78
|
-
loginUri: z.union([url_js_1.WebUrlStringSchema, z.undefined()]).optional(),
|
|
79
79
|
callbackUrls: url_js_1.UniqueWebUrlStringArraySchema.optional(),
|
|
80
80
|
availableAudiences: AudienceArraySchema.optional(),
|
|
81
81
|
availableGrants: AvailableGrantArraySchema.optional(),
|
|
@@ -8,7 +8,7 @@ const schema_js_1 = require("./schema.js");
|
|
|
8
8
|
const authorization = {
|
|
9
9
|
refreshTokenDuration: 3600,
|
|
10
10
|
accessTokenDuration: 900,
|
|
11
|
-
accessTokenSignatureAlgorithm: '
|
|
11
|
+
accessTokenSignatureAlgorithm: 'RS256',
|
|
12
12
|
loginUri: 'https://app.example.com/login',
|
|
13
13
|
callbackUrls: [
|
|
14
14
|
'https://app.example.com/callback',
|
|
@@ -145,12 +145,25 @@ const schema_js_1 = require("./schema.js");
|
|
|
145
145
|
const result = schema_js_1.AuthorizationSchema.safeParse(authorization);
|
|
146
146
|
(0, vitest_1.expect)(result.success).toBe(false);
|
|
147
147
|
});
|
|
148
|
-
(0, vitest_1.test)('should
|
|
148
|
+
(0, vitest_1.test)('should transform null removable fields to undefined', () => {
|
|
149
149
|
const authorization = {
|
|
150
150
|
loginUri: null,
|
|
151
151
|
refreshTokenDuration: null,
|
|
152
152
|
accessTokenDuration: null,
|
|
153
153
|
accessTokenSignatureAlgorithm: null,
|
|
154
|
+
metadata: {},
|
|
155
|
+
};
|
|
156
|
+
const result = schema_js_1.AuthorizationSchema.safeParse(authorization);
|
|
157
|
+
(0, vitest_1.expect)(result.success).toBe(true);
|
|
158
|
+
if (result.success) {
|
|
159
|
+
(0, vitest_1.expect)(result.data.loginUri).toBeUndefined();
|
|
160
|
+
(0, vitest_1.expect)(result.data.refreshTokenDuration).toBeUndefined();
|
|
161
|
+
(0, vitest_1.expect)(result.data.accessTokenDuration).toBeUndefined();
|
|
162
|
+
(0, vitest_1.expect)(result.data.accessTokenSignatureAlgorithm).toBeUndefined();
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
(0, vitest_1.test)('should reject null values for non-removable fields', () => {
|
|
166
|
+
const authorization = {
|
|
154
167
|
defaultAudience: null,
|
|
155
168
|
metadata: {},
|
|
156
169
|
};
|
|
@@ -163,7 +176,7 @@ const schema_js_1 = require("./schema.js");
|
|
|
163
176
|
const payload = {
|
|
164
177
|
refreshTokenDuration: 3600,
|
|
165
178
|
accessTokenDuration: 900,
|
|
166
|
-
accessTokenSignatureAlgorithm: '
|
|
179
|
+
accessTokenSignatureAlgorithm: 'RS256',
|
|
167
180
|
loginUri: 'https://app.example.com/login',
|
|
168
181
|
callbackUrls: ['https://app.example.com/callback'],
|
|
169
182
|
availableAudiences: ['api.example.com'],
|
|
@@ -278,13 +291,30 @@ const schema_js_1 = require("./schema.js");
|
|
|
278
291
|
const result = schema_js_1.AuthorizationPayloadSchema.safeParse(payload);
|
|
279
292
|
(0, vitest_1.expect)(result.success).toBe(false);
|
|
280
293
|
});
|
|
294
|
+
(0, vitest_1.test)('should transform null removable fields to undefined', () => {
|
|
295
|
+
const payload = {
|
|
296
|
+
loginUri: null,
|
|
297
|
+
refreshTokenDuration: null,
|
|
298
|
+
accessTokenDuration: null,
|
|
299
|
+
accessTokenSignatureAlgorithm: null,
|
|
300
|
+
metadata: {},
|
|
301
|
+
};
|
|
302
|
+
const result = schema_js_1.AuthorizationPayloadSchema.safeParse(payload);
|
|
303
|
+
(0, vitest_1.expect)(result.success).toBe(true);
|
|
304
|
+
if (result.success) {
|
|
305
|
+
(0, vitest_1.expect)(result.data.loginUri).toBeUndefined();
|
|
306
|
+
(0, vitest_1.expect)(result.data.refreshTokenDuration).toBeUndefined();
|
|
307
|
+
(0, vitest_1.expect)(result.data.accessTokenDuration).toBeUndefined();
|
|
308
|
+
(0, vitest_1.expect)(result.data.accessTokenSignatureAlgorithm).toBeUndefined();
|
|
309
|
+
}
|
|
310
|
+
});
|
|
281
311
|
});
|
|
282
312
|
(0, vitest_1.describe)('UpsertAuthorizationPayloadSchema', () => {
|
|
283
313
|
(0, vitest_1.test)('should accept upsert with all fields', () => {
|
|
284
314
|
const payload = {
|
|
285
315
|
refreshTokenDuration: 3600,
|
|
286
316
|
accessTokenDuration: 900,
|
|
287
|
-
accessTokenSignatureAlgorithm: '
|
|
317
|
+
accessTokenSignatureAlgorithm: 'RS256',
|
|
288
318
|
loginUri: 'https://updated.example.com/login',
|
|
289
319
|
callbackUrls: ['https://updated.example.com/callback'],
|
|
290
320
|
availableAudiences: ['updated-api.example.com'],
|
|
@@ -4,7 +4,6 @@ export declare const AuthorizationSchema: z.ZodObject<{
|
|
|
4
4
|
metadata: z.ZodPipe<z.ZodUnion<readonly [z.ZodUndefined, z.ZodNull, z.ZodCustom<Map<string, string | number | boolean>, Map<string, string | number | boolean>>, z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>]>, z.ZodTransform<Map<string, string | number | boolean>, Record<string, string | number | boolean> | Map<string, string | number | boolean> | null | undefined>>;
|
|
5
5
|
deactivatedAt: z.ZodOptional<z.ZodUnion<readonly [z.ZodDate, z.ZodPipe<z.ZodString, z.ZodTransform<Date, string>>]>>;
|
|
6
6
|
deletedAt: z.ZodOptional<z.ZodUnion<readonly [z.ZodDate, z.ZodPipe<z.ZodString, z.ZodTransform<Date, string>>]>>;
|
|
7
|
-
loginUri: z.ZodOptional<z.ZodUnion<readonly [z.ZodUnion<[z.ZodPipe<z.ZodURL, z.ZodTransform<URL, string>>, z.ZodCustom<URL, URL>]>, z.ZodUndefined]>>;
|
|
8
7
|
callbackUrls: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodUndefined, z.ZodPipe<z.ZodArray<z.ZodUnion<[z.ZodPipe<z.ZodURL, z.ZodTransform<URL, string>>, z.ZodCustom<URL, URL>]>>, z.ZodTransform<URL[], URL[]>>, z.ZodCustom<Set<URL>, Set<URL>>]>, z.ZodTransform<Set<URL> | undefined, Set<URL> | URL[] | undefined>>>;
|
|
9
8
|
availableAudiences: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodUndefined, z.ZodPipe<z.ZodArray<z.ZodString>, z.ZodTransform<string[], string[]>>, z.ZodSet<z.ZodString>]>, z.ZodTransform<Set<string> | undefined, Set<string> | string[] | undefined>>>;
|
|
10
9
|
availableGrants: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodUndefined, z.ZodArray<z.ZodEnum<{
|
|
@@ -15,9 +14,9 @@ export declare const AuthorizationSchema: z.ZodObject<{
|
|
|
15
14
|
}>>, z.ZodCustom<Set<AnyGrantType>, Set<AnyGrantType>>]>, z.ZodTransform<Set<AnyGrantType> | undefined, Set<AnyGrantType> | ("client_credentials" | "authorization_code" | "implicit" | "refresh_token")[] | undefined>>>;
|
|
16
15
|
defaultAudience: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodUndefined]>>;
|
|
17
16
|
updatedAt: z.ZodOptional<z.ZodUnion<readonly [z.ZodDate, z.ZodPipe<z.ZodString, z.ZodTransform<Date, string>>]>>;
|
|
18
|
-
refreshTokenDuration: z.ZodOptional<z.ZodNumber
|
|
19
|
-
accessTokenDuration: z.ZodOptional<z.ZodNumber
|
|
20
|
-
accessTokenSignatureAlgorithm: z.ZodOptional<z.ZodEnum<{
|
|
17
|
+
refreshTokenDuration: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<number | undefined, number | null | undefined>>>;
|
|
18
|
+
accessTokenDuration: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<number | undefined, number | null | undefined>>>;
|
|
19
|
+
accessTokenSignatureAlgorithm: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodEnum<{
|
|
21
20
|
RS256: "RS256";
|
|
22
21
|
RS384: "RS384";
|
|
23
22
|
RS512: "RS512";
|
|
@@ -27,7 +26,8 @@ export declare const AuthorizationSchema: z.ZodObject<{
|
|
|
27
26
|
PS256: "PS256";
|
|
28
27
|
PS384: "PS384";
|
|
29
28
|
PS512: "PS512";
|
|
30
|
-
}
|
|
29
|
+
}>, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<NonNullable<"RS256" | "RS384" | "RS512" | "ES256" | "ES384" | "ES512" | "PS256" | "PS384" | "PS512"> | undefined, "RS256" | "RS384" | "RS512" | "ES256" | "ES384" | "ES512" | "PS256" | "PS384" | "PS512" | null | undefined>>>;
|
|
30
|
+
loginUri: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodUnion<[z.ZodPipe<z.ZodCustom<URL, URL>, z.ZodTransform<string, URL>>, z.ZodURL]>, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<string | undefined, string | null | undefined>>>;
|
|
31
31
|
}, z.core.$strip>;
|
|
32
32
|
export type AuthorizationProperties = z.input<typeof AuthorizationSchema>;
|
|
33
33
|
export type Authorization = z.output<typeof AuthorizationSchema>;
|
|
@@ -35,7 +35,6 @@ export declare const AuthorizationPayloadSchema: z.ZodObject<{
|
|
|
35
35
|
metadata: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodUndefined, z.ZodNull, z.ZodCustom<Map<string, string | number | boolean>, Map<string, string | number | boolean>>, z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>]>, z.ZodTransform<Record<string, string | number | boolean> | undefined, Record<string, string | number | boolean> | Map<string, string | number | boolean> | null | undefined>>>;
|
|
36
36
|
deactivatedAt: z.ZodOptional<z.ZodPipe<z.ZodOptional<z.ZodUnion<readonly [z.ZodDate, z.ZodPipe<z.ZodString, z.ZodTransform<Date, string>>]>>, z.ZodTransform<string | undefined, Date | undefined>>>;
|
|
37
37
|
deletedAt: z.ZodOptional<z.ZodPipe<z.ZodOptional<z.ZodUnion<readonly [z.ZodDate, z.ZodPipe<z.ZodString, z.ZodTransform<Date, string>>]>>, z.ZodTransform<string | undefined, Date | undefined>>>;
|
|
38
|
-
loginUri: z.ZodOptional<z.ZodUnion<readonly [z.ZodUnion<[z.ZodPipe<z.ZodCustom<URL, URL>, z.ZodTransform<string, URL>>, z.ZodURL]>, z.ZodUndefined]>>;
|
|
39
38
|
callbackUrls: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodUndefined, z.ZodPipe<z.ZodArray<z.ZodUnion<[z.ZodPipe<z.ZodURL, z.ZodTransform<URL, string>>, z.ZodCustom<URL, URL>]>>, z.ZodTransform<URL[], URL[]>>, z.ZodCustom<Set<URL>, Set<URL>>]>, z.ZodTransform<string[] | undefined, Set<URL> | URL[] | undefined>>>;
|
|
40
39
|
availableAudiences: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodUndefined, z.ZodPipe<z.ZodArray<z.ZodString>, z.ZodTransform<string[], string[]>>, z.ZodSet<z.ZodString>]>, z.ZodTransform<string[] | undefined, Set<string> | string[] | undefined>>>;
|
|
41
40
|
availableGrants: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodUndefined, z.ZodArray<z.ZodEnum<{
|
|
@@ -46,9 +45,9 @@ export declare const AuthorizationPayloadSchema: z.ZodObject<{
|
|
|
46
45
|
}>>, z.ZodCustom<Set<AnyGrantType>, Set<AnyGrantType>>]>, z.ZodTransform<("client_credentials" | "authorization_code" | "implicit" | "refresh_token")[] | undefined, Set<AnyGrantType> | ("client_credentials" | "authorization_code" | "implicit" | "refresh_token")[] | undefined>>>;
|
|
47
46
|
defaultAudience: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodUndefined]>>;
|
|
48
47
|
updatedAt: z.ZodOptional<z.ZodPipe<z.ZodOptional<z.ZodUnion<readonly [z.ZodDate, z.ZodPipe<z.ZodString, z.ZodTransform<Date, string>>]>>, z.ZodTransform<string | undefined, Date | undefined>>>;
|
|
49
|
-
refreshTokenDuration: z.ZodOptional<z.ZodNumber
|
|
50
|
-
accessTokenDuration: z.ZodOptional<z.ZodNumber
|
|
51
|
-
accessTokenSignatureAlgorithm: z.ZodOptional<z.ZodEnum<{
|
|
48
|
+
refreshTokenDuration: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<number | undefined, number | null | undefined>>>;
|
|
49
|
+
accessTokenDuration: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<number | undefined, number | null | undefined>>>;
|
|
50
|
+
accessTokenSignatureAlgorithm: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodEnum<{
|
|
52
51
|
RS256: "RS256";
|
|
53
52
|
RS384: "RS384";
|
|
54
53
|
RS512: "RS512";
|
|
@@ -58,7 +57,8 @@ export declare const AuthorizationPayloadSchema: z.ZodObject<{
|
|
|
58
57
|
PS256: "PS256";
|
|
59
58
|
PS384: "PS384";
|
|
60
59
|
PS512: "PS512";
|
|
61
|
-
}
|
|
60
|
+
}>, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<NonNullable<"RS256" | "RS384" | "RS512" | "ES256" | "ES384" | "ES512" | "PS256" | "PS384" | "PS512"> | undefined, "RS256" | "RS384" | "RS512" | "ES256" | "ES384" | "ES512" | "PS256" | "PS384" | "PS512" | null | undefined>>>;
|
|
61
|
+
loginUri: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodUnion<[z.ZodPipe<z.ZodCustom<URL, URL>, z.ZodTransform<string, URL>>, z.ZodURL]>, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<string | undefined, string | null | undefined>>>;
|
|
62
62
|
}, z.core.$strip>;
|
|
63
63
|
export type AuthorizationPayload = z.output<typeof AuthorizationPayloadSchema>;
|
|
64
64
|
export declare const UpsertAuthorizationPayloadSchema: z.ZodObject<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../src/app/authorization/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAyB5B,OAAO,EAAE,KAAK,YAAY,EAAa,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../src/app/authorization/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAyB5B,OAAO,EAAE,KAAK,YAAY,EAAa,MAAM,8BAA8B,CAAC;AA6B5E,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAU9B,CAAC;AACH,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAC1E,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEjE,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAUrC,CAAC;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAE/E,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;iBAU3C,CAAC;AACH,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAC5C,OAAO,gCAAgC,CACxC,CAAC;AACF,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,MAAM,CAC/C,OAAO,gCAAgC,CACxC,CAAC"}
|
|
@@ -2,8 +2,9 @@ import * as z from 'zod/v4';
|
|
|
2
2
|
import { DeactivatedAtPropertyPayloadSchema, DeactivatedAtPropertySchema, DeletedAtPropertyPayloadSchema, DeletedAtPropertySchema, OptionalDatePayloadSchema, OptionalDateSchema, } from '../../common/schema/dates.js';
|
|
3
3
|
import { AlgorithmSchema } from '../../common/schema/jwt.js';
|
|
4
4
|
import { MetadataMapPropertySchema, MetadataPayloadPropertySchema, UpsertMetadataPropertyPayloadSchema, } from '../../common/schema/metadata.js';
|
|
5
|
+
import { optionallyNullishToUndefined } from '../../common/schema/schema.js';
|
|
5
6
|
import { UniqueStringArraySchema, UniqueStringSetSchema, } from '../../common/schema/sets.js';
|
|
6
|
-
import { UniqueWebUrlObjectSetSchema, UniqueWebUrlStringArraySchema,
|
|
7
|
+
import { UniqueWebUrlObjectSetSchema, UniqueWebUrlStringArraySchema, WebUrlStringSchema, } from '../../common/schema/url.js';
|
|
7
8
|
import { GrantType } from '../../oauth/common/schema.js';
|
|
8
9
|
const AudienceArraySchema = UniqueStringArraySchema;
|
|
9
10
|
const AudienceSetSchema = UniqueStringSetSchema;
|
|
@@ -21,13 +22,13 @@ const AvailableGrantArraySchema = z
|
|
|
21
22
|
.union([z.undefined(), GrantArraySchema, GrantSetSchema])
|
|
22
23
|
.pipe(z.transform((v) => (v instanceof Set ? Array.from(v.values()) : v)));
|
|
23
24
|
const BaseAuthorization = z.object({
|
|
24
|
-
refreshTokenDuration: z.number()
|
|
25
|
-
accessTokenDuration: z.number()
|
|
26
|
-
accessTokenSignatureAlgorithm: AlgorithmSchema
|
|
25
|
+
refreshTokenDuration: optionallyNullishToUndefined(z.number()),
|
|
26
|
+
accessTokenDuration: optionallyNullishToUndefined(z.number()),
|
|
27
|
+
accessTokenSignatureAlgorithm: optionallyNullishToUndefined(AlgorithmSchema),
|
|
28
|
+
loginUri: optionallyNullishToUndefined(WebUrlStringSchema),
|
|
27
29
|
});
|
|
28
30
|
export const AuthorizationSchema = z.object({
|
|
29
31
|
...BaseAuthorization.shape,
|
|
30
|
-
loginUri: z.union([WebUrlObjectSchema, z.undefined()]).optional(),
|
|
31
32
|
callbackUrls: UniqueWebUrlObjectSetSchema.optional(),
|
|
32
33
|
availableAudiences: AudienceSetSchema.optional(),
|
|
33
34
|
availableGrants: AvailableGrantSetSchema.optional(),
|
|
@@ -39,7 +40,6 @@ export const AuthorizationSchema = z.object({
|
|
|
39
40
|
});
|
|
40
41
|
export const AuthorizationPayloadSchema = z.object({
|
|
41
42
|
...BaseAuthorization.shape,
|
|
42
|
-
loginUri: z.union([WebUrlStringSchema, z.undefined()]).optional(),
|
|
43
43
|
callbackUrls: UniqueWebUrlStringArraySchema.optional(),
|
|
44
44
|
availableAudiences: AudienceArraySchema.optional(),
|
|
45
45
|
availableGrants: AvailableGrantArraySchema.optional(),
|
|
@@ -6,7 +6,7 @@ describe('App Authorization - Schema', () => {
|
|
|
6
6
|
const authorization = {
|
|
7
7
|
refreshTokenDuration: 3600,
|
|
8
8
|
accessTokenDuration: 900,
|
|
9
|
-
accessTokenSignatureAlgorithm: '
|
|
9
|
+
accessTokenSignatureAlgorithm: 'RS256',
|
|
10
10
|
loginUri: 'https://app.example.com/login',
|
|
11
11
|
callbackUrls: [
|
|
12
12
|
'https://app.example.com/callback',
|
|
@@ -143,12 +143,25 @@ describe('App Authorization - Schema', () => {
|
|
|
143
143
|
const result = AuthorizationSchema.safeParse(authorization);
|
|
144
144
|
expect(result.success).toBe(false);
|
|
145
145
|
});
|
|
146
|
-
test('should
|
|
146
|
+
test('should transform null removable fields to undefined', () => {
|
|
147
147
|
const authorization = {
|
|
148
148
|
loginUri: null,
|
|
149
149
|
refreshTokenDuration: null,
|
|
150
150
|
accessTokenDuration: null,
|
|
151
151
|
accessTokenSignatureAlgorithm: null,
|
|
152
|
+
metadata: {},
|
|
153
|
+
};
|
|
154
|
+
const result = AuthorizationSchema.safeParse(authorization);
|
|
155
|
+
expect(result.success).toBe(true);
|
|
156
|
+
if (result.success) {
|
|
157
|
+
expect(result.data.loginUri).toBeUndefined();
|
|
158
|
+
expect(result.data.refreshTokenDuration).toBeUndefined();
|
|
159
|
+
expect(result.data.accessTokenDuration).toBeUndefined();
|
|
160
|
+
expect(result.data.accessTokenSignatureAlgorithm).toBeUndefined();
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
test('should reject null values for non-removable fields', () => {
|
|
164
|
+
const authorization = {
|
|
152
165
|
defaultAudience: null,
|
|
153
166
|
metadata: {},
|
|
154
167
|
};
|
|
@@ -161,7 +174,7 @@ describe('App Authorization - Schema', () => {
|
|
|
161
174
|
const payload = {
|
|
162
175
|
refreshTokenDuration: 3600,
|
|
163
176
|
accessTokenDuration: 900,
|
|
164
|
-
accessTokenSignatureAlgorithm: '
|
|
177
|
+
accessTokenSignatureAlgorithm: 'RS256',
|
|
165
178
|
loginUri: 'https://app.example.com/login',
|
|
166
179
|
callbackUrls: ['https://app.example.com/callback'],
|
|
167
180
|
availableAudiences: ['api.example.com'],
|
|
@@ -276,13 +289,30 @@ describe('App Authorization - Schema', () => {
|
|
|
276
289
|
const result = AuthorizationPayloadSchema.safeParse(payload);
|
|
277
290
|
expect(result.success).toBe(false);
|
|
278
291
|
});
|
|
292
|
+
test('should transform null removable fields to undefined', () => {
|
|
293
|
+
const payload = {
|
|
294
|
+
loginUri: null,
|
|
295
|
+
refreshTokenDuration: null,
|
|
296
|
+
accessTokenDuration: null,
|
|
297
|
+
accessTokenSignatureAlgorithm: null,
|
|
298
|
+
metadata: {},
|
|
299
|
+
};
|
|
300
|
+
const result = AuthorizationPayloadSchema.safeParse(payload);
|
|
301
|
+
expect(result.success).toBe(true);
|
|
302
|
+
if (result.success) {
|
|
303
|
+
expect(result.data.loginUri).toBeUndefined();
|
|
304
|
+
expect(result.data.refreshTokenDuration).toBeUndefined();
|
|
305
|
+
expect(result.data.accessTokenDuration).toBeUndefined();
|
|
306
|
+
expect(result.data.accessTokenSignatureAlgorithm).toBeUndefined();
|
|
307
|
+
}
|
|
308
|
+
});
|
|
279
309
|
});
|
|
280
310
|
describe('UpsertAuthorizationPayloadSchema', () => {
|
|
281
311
|
test('should accept upsert with all fields', () => {
|
|
282
312
|
const payload = {
|
|
283
313
|
refreshTokenDuration: 3600,
|
|
284
314
|
accessTokenDuration: 900,
|
|
285
|
-
accessTokenSignatureAlgorithm: '
|
|
315
|
+
accessTokenSignatureAlgorithm: 'RS256',
|
|
286
316
|
loginUri: 'https://updated.example.com/login',
|
|
287
317
|
callbackUrls: ['https://updated.example.com/callback'],
|
|
288
318
|
availableAudiences: ['updated-api.example.com'],
|