@go-mondo/identity-sdk 0.0.2-beta.76 → 0.0.2-beta.78
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 +14 -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/cjs/customer/users/schema.d.ts +4 -4
- package/dist/cjs/customer/users/schema.d.ts.map +1 -1
- package/dist/cjs/customer/users/schema.js +7 -7
- package/dist/cjs/customer/users/schema.test.js +14 -16
- 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/dist/esm/customer/users/schema.d.ts +4 -4
- package/dist/esm/customer/users/schema.d.ts.map +1 -1
- package/dist/esm/customer/users/schema.js +7 -7
- package/dist/esm/customer/users/schema.test.js +14 -16
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.2-beta.78](https://github.com/go-mondo/identity-node-sdk/compare/identity-sdk-v0.0.2-beta.77...identity-sdk-v0.0.2-beta.78) (2026-05-07)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* reverting incorrect user schema changes ([4c25013](https://github.com/go-mondo/identity-node-sdk/commit/4c25013fb3b62bbb7fcc70466c92d957877f07dc))
|
|
9
|
+
|
|
10
|
+
## [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)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* authorization result schema ([549f07b](https://github.com/go-mondo/identity-node-sdk/commit/549f07b9b971cbd9a4e156b8baa8f86ed5c57963))
|
|
16
|
+
|
|
3
17
|
## [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
18
|
|
|
5
19
|
|
|
@@ -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'],
|
|
@@ -203,10 +203,10 @@ export type UserPayload = z.output<typeof UserPayloadSchema>;
|
|
|
203
203
|
export declare const InsertUserPayloadSchema: z.ZodObject<{
|
|
204
204
|
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> | null | undefined, Record<string, string | number | boolean> | Map<string, string | number | boolean> | null | undefined>>>;
|
|
205
205
|
roles: z.ZodOptional<z.ZodUnion<readonly [z.ZodUndefined, z.ZodArray<z.ZodString>]>>;
|
|
206
|
+
verifiedEmail: z.ZodOptional<z.ZodUnion<readonly [z.ZodEmail, z.ZodNull, z.ZodUndefined]>>;
|
|
207
|
+
verifiedPhoneNumber: z.ZodOptional<z.ZodUnion<readonly [z.ZodE164, z.ZodNull, z.ZodUndefined]>>;
|
|
206
208
|
unverifiedEmail: z.ZodOptional<z.ZodUnion<readonly [z.ZodEmail, z.ZodNull, z.ZodUndefined]>>;
|
|
207
209
|
unverifiedPhoneNumber: z.ZodOptional<z.ZodUnion<readonly [z.ZodE164, z.ZodNull, z.ZodUndefined]>>;
|
|
208
|
-
verifiedEmail: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodBoolean, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<boolean | undefined, boolean | null | undefined>>>;
|
|
209
|
-
verifiedPhoneNumber: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodBoolean, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<boolean | undefined, boolean | null | undefined>>>;
|
|
210
210
|
givenName: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<string | undefined, string | null | undefined>>>;
|
|
211
211
|
middleName: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<string | undefined, string | null | undefined>>>;
|
|
212
212
|
familyName: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<string | undefined, string | null | undefined>>>;
|
|
@@ -223,10 +223,10 @@ export type InsertUserInput = z.input<typeof InsertUserPayloadSchema>;
|
|
|
223
223
|
export type InsertUserPayload = z.output<typeof InsertUserPayloadSchema>;
|
|
224
224
|
export declare const UpdateUserPayloadSchema: z.ZodObject<{
|
|
225
225
|
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> | null | undefined, Record<string, string | number | boolean> | Map<string, string | number | boolean> | null | undefined>>>;
|
|
226
|
+
verifiedEmail: z.ZodOptional<z.ZodUnion<readonly [z.ZodEmail, z.ZodNull, z.ZodUndefined]>>;
|
|
227
|
+
verifiedPhoneNumber: z.ZodOptional<z.ZodUnion<readonly [z.ZodE164, z.ZodNull, z.ZodUndefined]>>;
|
|
226
228
|
unverifiedEmail: z.ZodOptional<z.ZodUnion<readonly [z.ZodEmail, z.ZodNull, z.ZodUndefined]>>;
|
|
227
229
|
unverifiedPhoneNumber: z.ZodOptional<z.ZodUnion<readonly [z.ZodE164, z.ZodNull, z.ZodUndefined]>>;
|
|
228
|
-
verifiedEmail: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodEmail, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<string | undefined, string | null | undefined>>>;
|
|
229
|
-
verifiedPhoneNumber: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodE164, z.ZodNull, z.ZodUndefined]>, z.ZodTransform<string | undefined, string | null | undefined>>>;
|
|
230
230
|
givenName: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodUndefined]>>;
|
|
231
231
|
middleName: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodUndefined]>>;
|
|
232
232
|
familyName: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNull, z.ZodUndefined]>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../src/customer/users/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AA2B5B,eAAO,MAAM,mBAAmB;;;CAGtB,CAAC;AAEX,MAAM,MAAM,sBAAsB,GAChC,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,OAAO,mBAAmB,CAAC,CAAC;AAEjE,eAAO,MAAM,UAAU;;;;CAIb,CAAC;AACX,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,OAAO,UAAU,CAAC,CAAC;AAEzE,eAAO,MAAM,gBAAgB;;;;EAAoC,CAAC;AAElE,eAAO,MAAM,wBAAwB;;;;;;iBAMnC,CAAC;AAGH,eAAO,MAAM,8BAA8B;;;;;;iBAMzC,CAAC;AAGH,eAAO,MAAM,oBAAoB;;iBAE/B,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAEnE,eAAO,MAAM,mBAAmB,YAAY,CAAC;AAC7C,eAAO,MAAM,yBAAyB,WAAW,CAAC;AAElD,eAAO,MAAM,oCAAoC;;;iBAG/C,CAAC;AAEH,eAAO,MAAM,sCAAsC;;;iBAKjD,CAAC;
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../src/customer/users/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AA2B5B,eAAO,MAAM,mBAAmB;;;CAGtB,CAAC;AAEX,MAAM,MAAM,sBAAsB,GAChC,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,OAAO,mBAAmB,CAAC,CAAC;AAEjE,eAAO,MAAM,UAAU;;;;CAIb,CAAC;AACX,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,OAAO,UAAU,CAAC,CAAC;AAEzE,eAAO,MAAM,gBAAgB;;;;EAAoC,CAAC;AAElE,eAAO,MAAM,wBAAwB;;;;;;iBAMnC,CAAC;AAGH,eAAO,MAAM,8BAA8B;;;;;;iBAMzC,CAAC;AAGH,eAAO,MAAM,oBAAoB;;iBAE/B,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAEnE,eAAO,MAAM,mBAAmB,YAAY,CAAC;AAC7C,eAAO,MAAM,yBAAyB,WAAW,CAAC;AAElD,eAAO,MAAM,oCAAoC;;;iBAG/C,CAAC;AAEH,eAAO,MAAM,sCAAsC;;;iBAKjD,CAAC;AASH,eAAO,MAAM,4BAA4B;;;iBAGvC,CAAC;AAEH,eAAO,MAAM,sBAAsB;;iBAEjC,CAAC;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAqBvE,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAIpB,CAAC;AACJ,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AACxD,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,UAAU,CAAC,CAAC;AAY/C,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAI3B,CAAC;AACJ,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAgB7D,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;iBAwBhC,CAAC;AACL,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AACtE,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAEzE,eAAO,MAAM,uBAAuB;;;;;;;;;;;;iBAMlC,CAAC;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AACtE,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAEzE;;GAEG;AACH,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;iBAMzC,CAAC;AACH,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAC7C,OAAO,8BAA8B,CACtC,CAAC"}
|
|
@@ -80,7 +80,9 @@ exports.UnverifiedEmailOrPhonePropertiesSchema = z.object({
|
|
|
80
80
|
unverifiedEmail: (0, schema_js_2.optionallyNullishToUndefined)(exports.RequiredEmailSchema),
|
|
81
81
|
unverifiedPhoneNumber: (0, schema_js_2.optionallyNullishToUndefined)(exports.RequiredPhoneNumberSchema),
|
|
82
82
|
});
|
|
83
|
-
const
|
|
83
|
+
const UpsertEmailOrPhonePropertiesSchema = z.object({
|
|
84
|
+
verifiedEmail: (0, schema_js_2.optionallyNullish)(exports.RequiredEmailSchema),
|
|
85
|
+
verifiedPhoneNumber: (0, schema_js_2.optionallyNullish)(exports.RequiredPhoneNumberSchema),
|
|
84
86
|
unverifiedEmail: (0, schema_js_2.optionallyNullish)(exports.RequiredEmailSchema),
|
|
85
87
|
unverifiedPhoneNumber: (0, schema_js_2.optionallyNullish)(exports.RequiredPhoneNumberSchema),
|
|
86
88
|
});
|
|
@@ -128,8 +130,8 @@ exports.UserPayloadSchema = UserPayloadSchemaBase.transform((user) => ({
|
|
|
128
130
|
phoneNumber: user.verifiedPhoneNumber,
|
|
129
131
|
}));
|
|
130
132
|
const requiredEmailOrPhoneMessage = 'At least one of verifiedEmail, verifiedPhoneNumber, unverifiedEmail, or unverifiedPhoneNumber is required';
|
|
131
|
-
const hasEmailOrPhone = (data) => data.verifiedEmail
|
|
132
|
-
data.verifiedPhoneNumber
|
|
133
|
+
const hasEmailOrPhone = (data) => data.verifiedEmail != null ||
|
|
134
|
+
data.verifiedPhoneNumber != null ||
|
|
133
135
|
data.unverifiedEmail != null ||
|
|
134
136
|
data.unverifiedPhoneNumber != null;
|
|
135
137
|
exports.InsertUserPayloadSchema = z
|
|
@@ -137,9 +139,7 @@ exports.InsertUserPayloadSchema = z
|
|
|
137
139
|
id: schema_js_3.UserIdSchema.optional(),
|
|
138
140
|
status: exports.UserStatusSchema.optional(),
|
|
139
141
|
...exports.UserNamePropertiesSchema.shape,
|
|
140
|
-
|
|
141
|
-
verifiedPhoneNumber: (0, schema_js_2.optionallyNullishToUndefined)(z.boolean()),
|
|
142
|
-
...UpsertUnverifiedEmailOrPhonePropertiesSchema.shape,
|
|
142
|
+
...UpsertEmailOrPhonePropertiesSchema.shape,
|
|
143
143
|
...exports.UserAssociationsSchema.shape,
|
|
144
144
|
...metadata_js_1.UpsertMetadataPropertyPayloadSchema.shape,
|
|
145
145
|
})
|
|
@@ -163,7 +163,7 @@ exports.UpdateUserPayloadSchema = z.object({
|
|
|
163
163
|
suspended: z.boolean().optional(),
|
|
164
164
|
...exports.UpdateUserNamePropertiesSchema.shape,
|
|
165
165
|
...exports.VerifiedEmailOrPhonePropertiesSchema.shape,
|
|
166
|
-
...
|
|
166
|
+
...UpsertEmailOrPhonePropertiesSchema.shape,
|
|
167
167
|
...metadata_js_1.UpsertMetadataPropertyPayloadSchema.shape,
|
|
168
168
|
});
|
|
169
169
|
/**
|
|
@@ -410,7 +410,7 @@ const schema_js_2 = require("./schema.js");
|
|
|
410
410
|
foo: 'bar',
|
|
411
411
|
id: (0, schema_js_1.generateUserId)(),
|
|
412
412
|
familyName: 'Foo',
|
|
413
|
-
verifiedPhoneNumber:
|
|
413
|
+
verifiedPhoneNumber: '+12025551234',
|
|
414
414
|
};
|
|
415
415
|
const result = schema_js_2.InsertUserPayloadSchema.safeParse(item);
|
|
416
416
|
(0, vitest_1.expect)(result.success).toBe(true);
|
|
@@ -422,17 +422,17 @@ const schema_js_2 = require("./schema.js");
|
|
|
422
422
|
(0, vitest_1.test)('should parse with all verified and unverified email/phone properties', async () => {
|
|
423
423
|
const item = {
|
|
424
424
|
id: (0, schema_js_1.generateUserId)(),
|
|
425
|
-
verifiedEmail:
|
|
425
|
+
verifiedEmail: 'verified@example.com',
|
|
426
426
|
unverifiedEmail: 'pending@example.com',
|
|
427
|
-
verifiedPhoneNumber:
|
|
427
|
+
verifiedPhoneNumber: '+1234567890',
|
|
428
428
|
unverifiedPhoneNumber: '+0987654321',
|
|
429
429
|
};
|
|
430
430
|
const result = schema_js_2.InsertUserPayloadSchema.safeParse(item);
|
|
431
431
|
(0, vitest_1.expect)(result.success).toBe(true);
|
|
432
432
|
if (result.success) {
|
|
433
|
-
(0, vitest_1.expect)(result.data.verifiedEmail).toBe(
|
|
433
|
+
(0, vitest_1.expect)(result.data.verifiedEmail).toBe('verified@example.com');
|
|
434
434
|
(0, vitest_1.expect)(result.data.unverifiedEmail).toBe('pending@example.com');
|
|
435
|
-
(0, vitest_1.expect)(result.data.verifiedPhoneNumber).toBe(
|
|
435
|
+
(0, vitest_1.expect)(result.data.verifiedPhoneNumber).toBe('+1234567890');
|
|
436
436
|
(0, vitest_1.expect)(result.data.unverifiedPhoneNumber).toBe('+0987654321');
|
|
437
437
|
}
|
|
438
438
|
});
|
|
@@ -440,7 +440,7 @@ const schema_js_2 = require("./schema.js");
|
|
|
440
440
|
const item = {
|
|
441
441
|
foo: 'bar',
|
|
442
442
|
id: (0, schema_js_1.generateUserId)(),
|
|
443
|
-
verifiedPhoneNumber:
|
|
443
|
+
verifiedPhoneNumber: '+12025551234',
|
|
444
444
|
metadata: new Map(),
|
|
445
445
|
};
|
|
446
446
|
const result = schema_js_2.InsertUserPayloadSchema.safeParse(item);
|
|
@@ -451,7 +451,7 @@ const schema_js_2 = require("./schema.js");
|
|
|
451
451
|
});
|
|
452
452
|
(0, vitest_1.test)('should allow optional id and status', async () => {
|
|
453
453
|
const item = {
|
|
454
|
-
verifiedEmail:
|
|
454
|
+
verifiedEmail: 'test@example.com',
|
|
455
455
|
};
|
|
456
456
|
const result = schema_js_2.InsertUserPayloadSchema.safeParse(item);
|
|
457
457
|
(0, vitest_1.expect)(result.success).toBe(true);
|
|
@@ -463,7 +463,7 @@ const schema_js_2 = require("./schema.js");
|
|
|
463
463
|
(0, vitest_1.test)('should parse with roles association', async () => {
|
|
464
464
|
const item = {
|
|
465
465
|
id: (0, schema_js_1.generateUserId)(),
|
|
466
|
-
verifiedEmail:
|
|
466
|
+
verifiedEmail: 'test@example.com',
|
|
467
467
|
roles: [
|
|
468
468
|
'rol_2NfYOTzVqhCHgWFzUL0WPfRRuhH',
|
|
469
469
|
'rol_2NfYOTzVqhCHgWFzUL0WPfRRuhI',
|
|
@@ -495,28 +495,27 @@ const schema_js_2 = require("./schema.js");
|
|
|
495
495
|
});
|
|
496
496
|
(0, vitest_1.test)('should accept with only verifiedEmail', async () => {
|
|
497
497
|
const item = {
|
|
498
|
-
verifiedEmail:
|
|
498
|
+
verifiedEmail: 'test@example.com',
|
|
499
499
|
};
|
|
500
500
|
const result = schema_js_2.InsertUserPayloadSchema.safeParse(item);
|
|
501
501
|
(0, vitest_1.expect)(result.success).toBe(true);
|
|
502
502
|
if (result.success) {
|
|
503
|
-
(0, vitest_1.expect)(result.data.verifiedEmail).toBe(
|
|
503
|
+
(0, vitest_1.expect)(result.data.verifiedEmail).toBe('test@example.com');
|
|
504
504
|
}
|
|
505
505
|
});
|
|
506
506
|
(0, vitest_1.test)('should accept with only verifiedPhoneNumber', async () => {
|
|
507
507
|
const item = {
|
|
508
|
-
verifiedPhoneNumber:
|
|
508
|
+
verifiedPhoneNumber: '+12025551234',
|
|
509
509
|
};
|
|
510
510
|
const result = schema_js_2.InsertUserPayloadSchema.safeParse(item);
|
|
511
511
|
(0, vitest_1.expect)(result.success).toBe(true);
|
|
512
512
|
if (result.success) {
|
|
513
|
-
(0, vitest_1.expect)(result.data.verifiedPhoneNumber).toBe(
|
|
513
|
+
(0, vitest_1.expect)(result.data.verifiedPhoneNumber).toBe('+12025551234');
|
|
514
514
|
}
|
|
515
515
|
});
|
|
516
516
|
(0, vitest_1.test)('should succeed with only unverifiedEmail', async () => {
|
|
517
517
|
const item = {
|
|
518
518
|
unverifiedEmail: 'test@example.com',
|
|
519
|
-
verifiedEmail: true,
|
|
520
519
|
unverifiedPhoneNumber: null,
|
|
521
520
|
};
|
|
522
521
|
const result = schema_js_2.InsertUserPayloadSchema.safeParse(item);
|
|
@@ -524,7 +523,7 @@ const schema_js_2 = require("./schema.js");
|
|
|
524
523
|
if (result.success) {
|
|
525
524
|
(0, vitest_1.expect)(result.data.unverifiedEmail).toBe('test@example.com');
|
|
526
525
|
(0, vitest_1.expect)(result.data.unverifiedPhoneNumber).toBeNull();
|
|
527
|
-
(0, vitest_1.expect)(result.data.verifiedEmail).
|
|
526
|
+
(0, vitest_1.expect)(result.data.verifiedEmail).toBeUndefined();
|
|
528
527
|
(0, vitest_1.expect)(result.data.verifiedPhoneNumber).toBeUndefined();
|
|
529
528
|
}
|
|
530
529
|
});
|
|
@@ -532,7 +531,6 @@ const schema_js_2 = require("./schema.js");
|
|
|
532
531
|
const item = {
|
|
533
532
|
unverifiedEmail: null,
|
|
534
533
|
unverifiedPhoneNumber: '+12025551234',
|
|
535
|
-
verifiedPhoneNumber: true,
|
|
536
534
|
};
|
|
537
535
|
const result = schema_js_2.InsertUserPayloadSchema.safeParse(item);
|
|
538
536
|
(0, vitest_1.expect)(result.success).toBe(true);
|
|
@@ -540,7 +538,7 @@ const schema_js_2 = require("./schema.js");
|
|
|
540
538
|
(0, vitest_1.expect)(result.data.unverifiedPhoneNumber).toBe('+12025551234');
|
|
541
539
|
(0, vitest_1.expect)(result.data.unverifiedEmail).toBeNull();
|
|
542
540
|
(0, vitest_1.expect)(result.data.verifiedEmail).toBeUndefined();
|
|
543
|
-
(0, vitest_1.expect)(result.data.verifiedPhoneNumber).
|
|
541
|
+
(0, vitest_1.expect)(result.data.verifiedPhoneNumber).toBeUndefined();
|
|
544
542
|
}
|
|
545
543
|
});
|
|
546
544
|
});
|
|
@@ -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'],
|