@logto/schemas 1.8.0 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/alterations/1.9.0-1693554904-add-possword-policy.ts +21 -0
  2. package/alterations/1.9.0-1694399696-add-type-col-to-roles-table.ts +55 -0
  3. package/alterations/1.9.0-1694418765-specify-check-role-type-function-to-be-public-schema.ts +54 -0
  4. package/alterations/1.9.0-1694484927-remove-deprecated-challenge-flag.ts +100 -0
  5. package/alterations/1.9.0-1694487524-sie-mfa.ts +26 -0
  6. package/alterations/1.9.0-1694509714-keep-existing-password-policy.ts +54 -0
  7. package/alterations/1.9.0-1694746763-user-verifications.ts +20 -0
  8. package/alterations-js/1.9.0-1693554904-add-possword-policy.d.ts +4 -0
  9. package/alterations-js/1.9.0-1693554904-add-possword-policy.js +17 -0
  10. package/alterations-js/1.9.0-1694399696-add-type-col-to-roles-table.d.ts +3 -0
  11. package/alterations-js/1.9.0-1694399696-add-type-col-to-roles-table.js +44 -0
  12. package/alterations-js/1.9.0-1694418765-specify-check-role-type-function-to-be-public-schema.d.ts +9 -0
  13. package/alterations-js/1.9.0-1694418765-specify-check-role-type-function-to-be-public-schema.js +42 -0
  14. package/alterations-js/1.9.0-1694484927-remove-deprecated-challenge-flag.d.ts +3 -0
  15. package/alterations-js/1.9.0-1694484927-remove-deprecated-challenge-flag.js +35 -0
  16. package/alterations-js/1.9.0-1694487524-sie-mfa.d.ts +3 -0
  17. package/alterations-js/1.9.0-1694487524-sie-mfa.js +21 -0
  18. package/alterations-js/1.9.0-1694509714-keep-existing-password-policy.d.ts +3 -0
  19. package/alterations-js/1.9.0-1694509714-keep-existing-password-policy.js +42 -0
  20. package/alterations-js/1.9.0-1694746763-user-verifications.d.ts +3 -0
  21. package/alterations-js/1.9.0-1694746763-user-verifications.js +16 -0
  22. package/lib/db-entries/custom-types.d.ts +4 -0
  23. package/lib/db-entries/custom-types.js +5 -0
  24. package/lib/db-entries/role.d.ts +3 -0
  25. package/lib/db-entries/role.js +5 -0
  26. package/lib/db-entries/sign-in-experience.d.ts +5 -1
  27. package/lib/db-entries/sign-in-experience.js +9 -1
  28. package/lib/db-entries/user.d.ts +3 -1
  29. package/lib/db-entries/user.js +5 -1
  30. package/lib/foundations/jsonb-types.d.ts +233 -26
  31. package/lib/foundations/jsonb-types.js +51 -21
  32. package/lib/models/tenants.d.ts +4 -4
  33. package/lib/seeds/cloud-api.d.ts +1 -1
  34. package/lib/seeds/cloud-api.js +2 -0
  35. package/lib/seeds/logto-config.js +0 -7
  36. package/lib/seeds/management-api.d.ts +2 -1
  37. package/lib/seeds/management-api.js +5 -0
  38. package/lib/seeds/sign-in-experience.js +6 -1
  39. package/lib/types/connector.d.ts +4 -4
  40. package/lib/types/hook.d.ts +13 -2
  41. package/lib/types/hook.js +4 -0
  42. package/lib/types/interactions.d.ts +1 -2
  43. package/lib/types/interactions.js +4 -5
  44. package/lib/types/logto-config.d.ts +0 -21
  45. package/lib/types/logto-config.js +0 -8
  46. package/lib/types/role.d.ts +4 -2
  47. package/lib/types/scope.d.ts +6 -6
  48. package/lib/types/system.d.ts +11 -8
  49. package/lib/types/system.js +6 -5
  50. package/lib/types/user.d.ts +195 -16
  51. package/lib/types/user.js +10 -0
  52. package/package.json +6 -6
  53. package/tables/applications_roles.sql +5 -1
  54. package/tables/roles.sql +8 -0
  55. package/tables/sign_in_experiences.sql +2 -0
  56. package/tables/users.sql +1 -0
  57. package/tables/users_roles.sql +5 -1
@@ -1,16 +1,19 @@
1
1
  // THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2
2
  import { z } from 'zod';
3
+ import { RoleType } from './custom-types.js';
3
4
  const createGuard = z.object({
4
5
  tenantId: z.string().max(21).optional(),
5
6
  id: z.string().min(1).max(21),
6
7
  name: z.string().min(1).max(128),
7
8
  description: z.string().min(1).max(128),
9
+ type: z.nativeEnum(RoleType).optional(),
8
10
  });
9
11
  const guard = z.object({
10
12
  tenantId: z.string().max(21),
11
13
  id: z.string().min(1).max(21),
12
14
  name: z.string().min(1).max(128),
13
15
  description: z.string().min(1).max(128),
16
+ type: z.nativeEnum(RoleType),
14
17
  });
15
18
  export const Roles = Object.freeze({
16
19
  table: 'roles',
@@ -20,12 +23,14 @@ export const Roles = Object.freeze({
20
23
  id: 'id',
21
24
  name: 'name',
22
25
  description: 'description',
26
+ type: 'type',
23
27
  },
24
28
  fieldKeys: [
25
29
  'tenantId',
26
30
  'id',
27
31
  'name',
28
32
  'description',
33
+ 'type',
29
34
  ],
30
35
  createGuard,
31
36
  guard,
@@ -1,4 +1,4 @@
1
- import { Color, Branding, LanguageInfo, SignIn, SignUp, ConnectorTargets, CustomContent, GeneratedSchema } from './../foundations/index.js';
1
+ import { Color, Branding, LanguageInfo, SignIn, SignUp, ConnectorTargets, CustomContent, PartialPasswordPolicy, Mfa, GeneratedSchema } from './../foundations/index.js';
2
2
  import { SignInMode } from './custom-types.js';
3
3
  export type CreateSignInExperience = {
4
4
  tenantId?: string;
@@ -14,6 +14,8 @@ export type CreateSignInExperience = {
14
14
  signInMode?: SignInMode;
15
15
  customCss?: string | null;
16
16
  customContent?: CustomContent;
17
+ passwordPolicy?: PartialPasswordPolicy;
18
+ mfa?: Mfa;
17
19
  };
18
20
  export type SignInExperience = {
19
21
  tenantId: string;
@@ -29,5 +31,7 @@ export type SignInExperience = {
29
31
  signInMode: SignInMode;
30
32
  customCss: string | null;
31
33
  customContent: CustomContent;
34
+ passwordPolicy: PartialPasswordPolicy;
35
+ mfa: Mfa;
32
36
  };
33
37
  export declare const SignInExperiences: GeneratedSchema<CreateSignInExperience, SignInExperience>;
@@ -1,6 +1,6 @@
1
1
  // THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2
2
  import { z } from 'zod';
3
- import { colorGuard, brandingGuard, languageInfoGuard, signInGuard, signUpGuard, connectorTargetsGuard, customContentGuard } from './../foundations/index.js';
3
+ import { colorGuard, brandingGuard, languageInfoGuard, signInGuard, signUpGuard, connectorTargetsGuard, customContentGuard, partialPasswordPolicyGuard, mfaGuard } from './../foundations/index.js';
4
4
  import { SignInMode } from './custom-types.js';
5
5
  const createGuard = z.object({
6
6
  tenantId: z.string().max(21).optional(),
@@ -16,6 +16,8 @@ const createGuard = z.object({
16
16
  signInMode: z.nativeEnum(SignInMode).optional(),
17
17
  customCss: z.string().nullable().optional(),
18
18
  customContent: customContentGuard.optional(),
19
+ passwordPolicy: partialPasswordPolicyGuard.optional(),
20
+ mfa: mfaGuard.optional(),
19
21
  });
20
22
  const guard = z.object({
21
23
  tenantId: z.string().max(21),
@@ -31,6 +33,8 @@ const guard = z.object({
31
33
  signInMode: z.nativeEnum(SignInMode),
32
34
  customCss: z.string().nullable(),
33
35
  customContent: customContentGuard,
36
+ passwordPolicy: partialPasswordPolicyGuard,
37
+ mfa: mfaGuard,
34
38
  });
35
39
  export const SignInExperiences = Object.freeze({
36
40
  table: 'sign_in_experiences',
@@ -49,6 +53,8 @@ export const SignInExperiences = Object.freeze({
49
53
  signInMode: 'sign_in_mode',
50
54
  customCss: 'custom_css',
51
55
  customContent: 'custom_content',
56
+ passwordPolicy: 'password_policy',
57
+ mfa: 'mfa',
52
58
  },
53
59
  fieldKeys: [
54
60
  'tenantId',
@@ -64,6 +70,8 @@ export const SignInExperiences = Object.freeze({
64
70
  'signInMode',
65
71
  'customCss',
66
72
  'customContent',
73
+ 'passwordPolicy',
74
+ 'mfa',
67
75
  ],
68
76
  createGuard,
69
77
  guard,
@@ -1,4 +1,4 @@
1
- import { Identities, JsonObject, GeneratedSchema } from './../foundations/index.js';
1
+ import { Identities, JsonObject, MfaVerifications, GeneratedSchema } from './../foundations/index.js';
2
2
  import { UsersPasswordEncryptionMethod } from './custom-types.js';
3
3
  export type CreateUser = {
4
4
  tenantId?: string;
@@ -13,6 +13,7 @@ export type CreateUser = {
13
13
  applicationId?: string | null;
14
14
  identities?: Identities;
15
15
  customData?: JsonObject;
16
+ mfaVerifications?: MfaVerifications;
16
17
  isSuspended?: boolean;
17
18
  lastSignInAt?: number | null;
18
19
  createdAt?: number;
@@ -30,6 +31,7 @@ export type User = {
30
31
  applicationId: string | null;
31
32
  identities: Identities;
32
33
  customData: JsonObject;
34
+ mfaVerifications: MfaVerifications;
33
35
  isSuspended: boolean;
34
36
  lastSignInAt: number | null;
35
37
  createdAt: number;
@@ -1,6 +1,6 @@
1
1
  // THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2
2
  import { z } from 'zod';
3
- import { identitiesGuard, jsonObjectGuard } from './../foundations/index.js';
3
+ import { identitiesGuard, jsonObjectGuard, mfaVerificationsGuard } from './../foundations/index.js';
4
4
  import { UsersPasswordEncryptionMethod } from './custom-types.js';
5
5
  const createGuard = z.object({
6
6
  tenantId: z.string().max(21).optional(),
@@ -15,6 +15,7 @@ const createGuard = z.object({
15
15
  applicationId: z.string().max(21).nullable().optional(),
16
16
  identities: identitiesGuard.optional(),
17
17
  customData: jsonObjectGuard.optional(),
18
+ mfaVerifications: mfaVerificationsGuard.optional(),
18
19
  isSuspended: z.boolean().optional(),
19
20
  lastSignInAt: z.number().nullable().optional(),
20
21
  createdAt: z.number().optional(),
@@ -32,6 +33,7 @@ const guard = z.object({
32
33
  applicationId: z.string().max(21).nullable(),
33
34
  identities: identitiesGuard,
34
35
  customData: jsonObjectGuard,
36
+ mfaVerifications: mfaVerificationsGuard,
35
37
  isSuspended: z.boolean(),
36
38
  lastSignInAt: z.number().nullable(),
37
39
  createdAt: z.number(),
@@ -52,6 +54,7 @@ export const Users = Object.freeze({
52
54
  applicationId: 'application_id',
53
55
  identities: 'identities',
54
56
  customData: 'custom_data',
57
+ mfaVerifications: 'mfa_verifications',
55
58
  isSuspended: 'is_suspended',
56
59
  lastSignInAt: 'last_sign_in_at',
57
60
  createdAt: 'created_at',
@@ -69,6 +72,7 @@ export const Users = Object.freeze({
69
72
  'applicationId',
70
73
  'identities',
71
74
  'customData',
75
+ 'mfaVerifications',
72
76
  'isSuspended',
73
77
  'lastSignInAt',
74
78
  'createdAt',
@@ -1,3 +1,5 @@
1
+ import { type PasswordPolicy } from '@logto/core-kit';
2
+ import { type DeepPartial } from '@silverhand/essentials';
1
3
  import type { Json } from '@withtyped/server';
2
4
  import { z } from 'zod';
3
5
  export { configurableConnectorMetadataGuard, type ConfigurableConnectorMetadata, } from '@logto/connector-kit';
@@ -20,9 +22,6 @@ export declare const oidcModelInstancePayloadGuard: z.ZodObject<{
20
22
  grantId?: string | undefined;
21
23
  }>;
22
24
  export type OidcModelInstancePayload = z.infer<typeof oidcModelInstancePayloadGuard>;
23
- export declare const webRedirectUriProtocolRegEx: RegExp;
24
- export declare const mobileUriSchemeProtocolRegEx: RegExp;
25
- export declare const validateRedirectUrl: (urlString: string, type: 'web' | 'mobile') => boolean;
26
25
  export declare const oidcClientMetadataGuard: z.ZodObject<{
27
26
  redirectUris: z.ZodArray<z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodString, string, string>]>, "many">;
28
27
  postLogoutRedirectUris: z.ZodArray<z.ZodString, "many">;
@@ -88,29 +87,6 @@ export declare const customClientMetadataGuard: z.ZodObject<{
88
87
  * @see {@link CustomClientMetadataKey} for key descriptions.
89
88
  */
90
89
  export type CustomClientMetadata = z.infer<typeof customClientMetadataGuard>;
91
- export declare const roleNamesGuard: z.ZodArray<z.ZodString, "many">;
92
- declare const identityGuard: z.ZodObject<{
93
- userId: z.ZodString;
94
- details: z.ZodOptional<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>;
95
- }, "strip", z.ZodTypeAny, {
96
- details?: {} | undefined;
97
- userId: string;
98
- }, {
99
- details?: {} | undefined;
100
- userId: string;
101
- }>;
102
- export declare const identitiesGuard: z.ZodRecord<z.ZodString, z.ZodObject<{
103
- userId: z.ZodString;
104
- details: z.ZodOptional<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>;
105
- }, "strip", z.ZodTypeAny, {
106
- details?: {} | undefined;
107
- userId: string;
108
- }, {
109
- details?: {} | undefined;
110
- userId: string;
111
- }>>;
112
- export type Identity = z.infer<typeof identityGuard>;
113
- export type Identities = z.infer<typeof identitiesGuard>;
114
90
  export declare const colorGuard: z.ZodObject<{
115
91
  primaryColor: z.ZodString;
116
92
  isDarkModeEnabled: z.ZodBoolean;
@@ -206,6 +182,173 @@ export declare const connectorTargetsGuard: z.ZodArray<z.ZodString, "many">;
206
182
  export type ConnectorTargets = z.infer<typeof connectorTargetsGuard>;
207
183
  export declare const customContentGuard: z.ZodRecord<z.ZodString, z.ZodString>;
208
184
  export type CustomContent = z.infer<typeof customContentGuard>;
185
+ export declare enum MfaFactor {
186
+ TOTP = "TOTP",
187
+ WebAuthn = "WebAuthn",
188
+ BackupCode = "BackupCode"
189
+ }
190
+ export declare const mfaFactorsGuard: z.ZodArray<z.ZodNativeEnum<typeof MfaFactor>, "many">;
191
+ export type MfaFactors = z.infer<typeof mfaFactorsGuard>;
192
+ export declare enum MfaPolicy {
193
+ UserControlled = "UserControlled",
194
+ Mandatory = "Mandatory"
195
+ }
196
+ export declare const mfaGuard: z.ZodObject<{
197
+ factors: z.ZodArray<z.ZodNativeEnum<typeof MfaFactor>, "many">;
198
+ policy: z.ZodNativeEnum<typeof MfaPolicy>;
199
+ }, "strip", z.ZodTypeAny, {
200
+ factors: MfaFactor[];
201
+ policy: MfaPolicy;
202
+ }, {
203
+ factors: MfaFactor[];
204
+ policy: MfaPolicy;
205
+ }>;
206
+ export type Mfa = z.infer<typeof mfaGuard>;
207
+ export declare const roleNamesGuard: z.ZodArray<z.ZodString, "many">;
208
+ declare const identityGuard: z.ZodObject<{
209
+ userId: z.ZodString;
210
+ details: z.ZodOptional<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>;
211
+ }, "strip", z.ZodTypeAny, {
212
+ details?: {} | undefined;
213
+ userId: string;
214
+ }, {
215
+ details?: {} | undefined;
216
+ userId: string;
217
+ }>;
218
+ export declare const identitiesGuard: z.ZodRecord<z.ZodString, z.ZodObject<{
219
+ userId: z.ZodString;
220
+ details: z.ZodOptional<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>>;
221
+ }, "strip", z.ZodTypeAny, {
222
+ details?: {} | undefined;
223
+ userId: string;
224
+ }, {
225
+ details?: {} | undefined;
226
+ userId: string;
227
+ }>>;
228
+ export type Identity = z.infer<typeof identityGuard>;
229
+ export type Identities = z.infer<typeof identitiesGuard>;
230
+ export declare const baseMfaVerification: {
231
+ id: z.ZodString;
232
+ createdAt: z.ZodString;
233
+ };
234
+ export declare const mfaVerificationGuard: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
235
+ key: z.ZodString;
236
+ id: z.ZodString;
237
+ createdAt: z.ZodString;
238
+ type: z.ZodLiteral<MfaFactor.TOTP>;
239
+ }, "strip", z.ZodTypeAny, {
240
+ type: MfaFactor.TOTP;
241
+ key: string;
242
+ id: string;
243
+ createdAt: string;
244
+ }, {
245
+ type: MfaFactor.TOTP;
246
+ key: string;
247
+ id: string;
248
+ createdAt: string;
249
+ }>, z.ZodObject<{
250
+ credentialId: z.ZodString;
251
+ publicKey: z.ZodString;
252
+ counter: z.ZodNumber;
253
+ agent: z.ZodString;
254
+ id: z.ZodString;
255
+ createdAt: z.ZodString;
256
+ type: z.ZodLiteral<MfaFactor.WebAuthn>;
257
+ }, "strip", z.ZodTypeAny, {
258
+ type: MfaFactor.WebAuthn;
259
+ id: string;
260
+ createdAt: string;
261
+ credentialId: string;
262
+ publicKey: string;
263
+ counter: number;
264
+ agent: string;
265
+ }, {
266
+ type: MfaFactor.WebAuthn;
267
+ id: string;
268
+ createdAt: string;
269
+ credentialId: string;
270
+ publicKey: string;
271
+ counter: number;
272
+ agent: string;
273
+ }>, z.ZodObject<{
274
+ code: z.ZodString;
275
+ usedAt: z.ZodOptional<z.ZodDate>;
276
+ id: z.ZodString;
277
+ createdAt: z.ZodString;
278
+ type: z.ZodLiteral<MfaFactor.BackupCode>;
279
+ }, "strip", z.ZodTypeAny, {
280
+ usedAt?: Date | undefined;
281
+ code: string;
282
+ type: MfaFactor.BackupCode;
283
+ id: string;
284
+ createdAt: string;
285
+ }, {
286
+ usedAt?: Date | undefined;
287
+ code: string;
288
+ type: MfaFactor.BackupCode;
289
+ id: string;
290
+ createdAt: string;
291
+ }>]>;
292
+ export type MfaVerification = z.infer<typeof mfaVerificationGuard>;
293
+ export declare const mfaVerificationsGuard: z.ZodArray<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
294
+ key: z.ZodString;
295
+ id: z.ZodString;
296
+ createdAt: z.ZodString;
297
+ type: z.ZodLiteral<MfaFactor.TOTP>;
298
+ }, "strip", z.ZodTypeAny, {
299
+ type: MfaFactor.TOTP;
300
+ key: string;
301
+ id: string;
302
+ createdAt: string;
303
+ }, {
304
+ type: MfaFactor.TOTP;
305
+ key: string;
306
+ id: string;
307
+ createdAt: string;
308
+ }>, z.ZodObject<{
309
+ credentialId: z.ZodString;
310
+ publicKey: z.ZodString;
311
+ counter: z.ZodNumber;
312
+ agent: z.ZodString;
313
+ id: z.ZodString;
314
+ createdAt: z.ZodString;
315
+ type: z.ZodLiteral<MfaFactor.WebAuthn>;
316
+ }, "strip", z.ZodTypeAny, {
317
+ type: MfaFactor.WebAuthn;
318
+ id: string;
319
+ createdAt: string;
320
+ credentialId: string;
321
+ publicKey: string;
322
+ counter: number;
323
+ agent: string;
324
+ }, {
325
+ type: MfaFactor.WebAuthn;
326
+ id: string;
327
+ createdAt: string;
328
+ credentialId: string;
329
+ publicKey: string;
330
+ counter: number;
331
+ agent: string;
332
+ }>, z.ZodObject<{
333
+ code: z.ZodString;
334
+ usedAt: z.ZodOptional<z.ZodDate>;
335
+ id: z.ZodString;
336
+ createdAt: z.ZodString;
337
+ type: z.ZodLiteral<MfaFactor.BackupCode>;
338
+ }, "strip", z.ZodTypeAny, {
339
+ usedAt?: Date | undefined;
340
+ code: string;
341
+ type: MfaFactor.BackupCode;
342
+ id: string;
343
+ createdAt: string;
344
+ }, {
345
+ usedAt?: Date | undefined;
346
+ code: string;
347
+ type: MfaFactor.BackupCode;
348
+ id: string;
349
+ createdAt: string;
350
+ }>]>, "many">;
351
+ export type MfaVerifications = z.infer<typeof mfaVerificationsGuard>;
209
352
  export type Translation = {
210
353
  [key: string]: string | Translation;
211
354
  };
@@ -244,6 +387,70 @@ export declare const logContextPayloadGuard: z.ZodObject<{
244
387
  key: string;
245
388
  result: LogResult;
246
389
  }>;
390
+ export type PartialPasswordPolicy = DeepPartial<PasswordPolicy>;
391
+ export declare const partialPasswordPolicyGuard: z.ZodObject<{
392
+ length: z.ZodOptional<z.ZodDefault<z.ZodObject<{
393
+ min: z.ZodDefault<z.ZodNumber>;
394
+ max: z.ZodDefault<z.ZodNumber>;
395
+ }, "strip", z.ZodTypeAny, {
396
+ min: number;
397
+ max: number;
398
+ }, {
399
+ min?: number | undefined;
400
+ max?: number | undefined;
401
+ }>>>;
402
+ characterTypes: z.ZodOptional<z.ZodDefault<z.ZodObject<{
403
+ min: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
404
+ }, "strip", z.ZodTypeAny, {
405
+ min: number;
406
+ }, {
407
+ min?: number | undefined;
408
+ }>>>;
409
+ rejects: z.ZodOptional<z.ZodDefault<z.ZodObject<{
410
+ pwned: z.ZodDefault<z.ZodBoolean>;
411
+ repetitionAndSequence: z.ZodDefault<z.ZodBoolean>;
412
+ userInfo: z.ZodDefault<z.ZodBoolean>;
413
+ words: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
414
+ }, "strip", z.ZodTypeAny, {
415
+ pwned: boolean;
416
+ repetitionAndSequence: boolean;
417
+ userInfo: boolean;
418
+ words: string[];
419
+ }, {
420
+ pwned?: boolean | undefined;
421
+ repetitionAndSequence?: boolean | undefined;
422
+ userInfo?: boolean | undefined;
423
+ words?: string[] | undefined;
424
+ }>>>;
425
+ }, "strip", z.ZodTypeAny, {
426
+ length?: {
427
+ min: number;
428
+ max: number;
429
+ } | undefined;
430
+ characterTypes?: {
431
+ min: number;
432
+ } | undefined;
433
+ rejects?: {
434
+ pwned: boolean;
435
+ repetitionAndSequence: boolean;
436
+ userInfo: boolean;
437
+ words: string[];
438
+ } | undefined;
439
+ }, {
440
+ length?: {
441
+ min?: number | undefined;
442
+ max?: number | undefined;
443
+ } | undefined;
444
+ characterTypes?: {
445
+ min?: number | undefined;
446
+ } | undefined;
447
+ rejects?: {
448
+ pwned?: boolean | undefined;
449
+ repetitionAndSequence?: boolean | undefined;
450
+ userInfo?: boolean | undefined;
451
+ words?: string[] | undefined;
452
+ } | undefined;
453
+ }>;
247
454
  /**
248
455
  * The basic log context type. It's more about a type hint instead of forcing the log shape.
249
456
  *
@@ -1,4 +1,4 @@
1
- import { hexColorRegEx } from '@logto/core-kit';
1
+ import { hexColorRegEx, passwordPolicyGuard, validateRedirectUrl, } from '@logto/core-kit';
2
2
  import { languageTagGuard } from '@logto/language-kit';
3
3
  import { z } from 'zod';
4
4
  export { configurableConnectorMetadataGuard, } from '@logto/connector-kit';
@@ -19,19 +19,6 @@ export const oidcModelInstancePayloadGuard = z
19
19
  * https://github.com/colinhacks/zod/issues/452
20
20
  */
21
21
  .catchall(z.unknown());
22
- // Import from @logto/core-kit later, pending for new version publish
23
- export const webRedirectUriProtocolRegEx = /^https?:$/;
24
- export const mobileUriSchemeProtocolRegEx = /^[a-z][\d_a-z]*(\.[\d_a-z]+)+:$/;
25
- export const validateRedirectUrl = (urlString, type) => {
26
- try {
27
- const { protocol } = new URL(urlString);
28
- const protocolRegEx = type === 'mobile' ? mobileUriSchemeProtocolRegEx : webRedirectUriProtocolRegEx;
29
- return protocolRegEx.test(protocol);
30
- }
31
- catch {
32
- return false;
33
- }
34
- };
35
22
  export const oidcClientMetadataGuard = z.object({
36
23
  redirectUris: z
37
24
  .string()
@@ -73,13 +60,6 @@ export const customClientMetadataGuard = z.object({
73
60
  [CustomClientMetadataKey.AlwaysIssueRefreshToken]: z.boolean().optional(),
74
61
  [CustomClientMetadataKey.RotateRefreshToken]: z.boolean().optional(),
75
62
  });
76
- /* === Users === */
77
- export const roleNamesGuard = z.string().array();
78
- const identityGuard = z.object({
79
- userId: z.string(),
80
- details: z.object({}).optional(), // Connector's userinfo details, schemaless
81
- });
82
- export const identitiesGuard = z.record(identityGuard);
83
63
  /* === SignIn Experiences === */
84
64
  export const colorGuard = z.object({
85
65
  primaryColor: z.string().regex(hexColorRegEx),
@@ -118,6 +98,55 @@ export const signInGuard = z.object({
118
98
  });
119
99
  export const connectorTargetsGuard = z.string().array();
120
100
  export const customContentGuard = z.record(z.string());
101
+ export var MfaFactor;
102
+ (function (MfaFactor) {
103
+ MfaFactor["TOTP"] = "TOTP";
104
+ MfaFactor["WebAuthn"] = "WebAuthn";
105
+ MfaFactor["BackupCode"] = "BackupCode";
106
+ })(MfaFactor || (MfaFactor = {}));
107
+ export const mfaFactorsGuard = z.nativeEnum(MfaFactor).array();
108
+ export var MfaPolicy;
109
+ (function (MfaPolicy) {
110
+ MfaPolicy["UserControlled"] = "UserControlled";
111
+ MfaPolicy["Mandatory"] = "Mandatory";
112
+ })(MfaPolicy || (MfaPolicy = {}));
113
+ export const mfaGuard = z.object({
114
+ factors: mfaFactorsGuard,
115
+ policy: z.nativeEnum(MfaPolicy),
116
+ });
117
+ /* === Users === */
118
+ export const roleNamesGuard = z.string().array();
119
+ const identityGuard = z.object({
120
+ userId: z.string(),
121
+ details: z.object({}).optional(), // Connector's userinfo details, schemaless
122
+ });
123
+ export const identitiesGuard = z.record(identityGuard);
124
+ export const baseMfaVerification = {
125
+ id: z.string(),
126
+ createdAt: z.string(),
127
+ };
128
+ export const mfaVerificationGuard = z.discriminatedUnion('type', [
129
+ z.object({
130
+ type: z.literal(MfaFactor.TOTP),
131
+ ...baseMfaVerification,
132
+ key: z.string(),
133
+ }),
134
+ z.object({
135
+ type: z.literal(MfaFactor.WebAuthn),
136
+ ...baseMfaVerification,
137
+ credentialId: z.string(),
138
+ publicKey: z.string(),
139
+ counter: z.number(),
140
+ agent: z.string(),
141
+ }),
142
+ z.object({
143
+ type: z.literal(MfaFactor.BackupCode),
144
+ ...baseMfaVerification,
145
+ code: z.string(),
146
+ usedAt: z.date().optional(),
147
+ }),
148
+ ]);
149
+ export const mfaVerificationsGuard = mfaVerificationGuard.array();
121
150
  export const translationGuard = z.lazy(() => z.record(z.string().or(translationGuard)));
122
151
  /* === Logs === */
123
152
  export var LogResult;
@@ -137,6 +166,7 @@ export const logContextPayloadGuard = z
137
166
  sessionId: z.string().optional(),
138
167
  })
139
168
  .catchall(z.unknown());
169
+ export const partialPasswordPolicyGuard = passwordPolicyGuard.deepPartial();
140
170
  /* === Hooks === */
141
171
  export var HookEvent;
142
172
  (function (HookEvent) {
@@ -13,7 +13,7 @@ export declare const Tenants: import("@withtyped/server/model").default<"tenants
13
13
  tag: TenantTag;
14
14
  createdAt: Date;
15
15
  isSuspended: boolean;
16
- }, "name" | "createdAt" | "isSuspended" | "tag", "createdAt">;
16
+ }, "createdAt" | "name" | "isSuspended" | "tag", "createdAt">;
17
17
  export type TenantModel = InferModelType<typeof Tenants>;
18
18
  export declare const tenantInfoGuard: z.ZodObject<z.extendShape<Pick<{
19
19
  id: z.ZodType<string, z.ZodTypeDef, string>;
@@ -23,17 +23,17 @@ export declare const tenantInfoGuard: z.ZodObject<z.extendShape<Pick<{
23
23
  tag: z.ZodType<TenantTag, z.ZodTypeDef, TenantTag>;
24
24
  createdAt: z.ZodType<Date, z.ZodTypeDef, Date>;
25
25
  isSuspended: z.ZodType<boolean, z.ZodTypeDef, boolean>;
26
- }, "name" | "id" | "isSuspended" | "tag">, {
26
+ }, "id" | "name" | "isSuspended" | "tag">, {
27
27
  indicator: z.ZodString;
28
28
  }>, "strip", z.ZodTypeAny, {
29
- name: string;
30
29
  id: string;
30
+ name: string;
31
31
  indicator: string;
32
32
  isSuspended: boolean;
33
33
  tag: TenantTag;
34
34
  }, {
35
- name: string;
36
35
  id: string;
36
+ name: string;
37
37
  indicator: string;
38
38
  isSuspended: boolean;
39
39
  tag: TenantTag;
@@ -1,4 +1,4 @@
1
- import type { CreateScope, Role } from '../index.js';
1
+ import type { CreateScope, Role } from '../db-entries/index.js';
2
2
  import type { UpdateAdminData } from './management-api.js';
3
3
  /** The API Resource Indicator for Logto Cloud. It's only useful when domain-based multi-tenancy is enabled. */
4
4
  export declare const cloudApiIndicator = "https://cloud.logto.io/api";
@@ -1,4 +1,5 @@
1
1
  import { generateStandardId } from '@logto/shared/universal';
2
+ import { RoleType } from '../db-entries/index.js';
2
3
  import { AdminTenantRole } from '../types/index.js';
3
4
  import { adminTenantId } from './tenant.js';
4
5
  /** The API Resource Indicator for Logto Cloud. It's only useful when domain-based multi-tenancy is enabled. */
@@ -56,4 +57,5 @@ export const createTenantApplicationRole = () => ({
56
57
  id: generateStandardId(),
57
58
  name: AdminTenantRole.TenantApplication,
58
59
  description: 'The role for M2M applications that represent a user tenant and send requests to Logto Cloud.',
60
+ type: RoleType.MachineToMachine,
59
61
  });
@@ -4,14 +4,7 @@ export const createDefaultAdminConsoleConfig = (forTenantId) => Object.freeze({
4
4
  tenantId: forTenantId,
5
5
  key: LogtoTenantConfigKey.AdminConsole,
6
6
  value: {
7
- livePreviewChecked: false,
8
- applicationCreated: false,
9
7
  signInExperienceCustomized: false,
10
- passwordlessConfigured: false,
11
- furtherReadingsChecked: false,
12
- roleCreated: false,
13
- communityChecked: false,
14
- m2mApplicationCreated: false,
15
8
  },
16
9
  });
17
10
  export const createCloudConnectionConfig = (forTenantId, appId, appSecret) => Object.freeze({
@@ -1,4 +1,4 @@
1
- import type { CreateResource, CreateRole, CreateScope } from '../db-entries/index.js';
1
+ import { RoleType, type CreateResource, type CreateRole, type CreateScope } from '../db-entries/index.js';
2
2
  import { PredefinedScope, InternalRole } from '../types/index.js';
3
3
  export type AdminData = {
4
4
  resource: CreateResource;
@@ -38,6 +38,7 @@ export declare const defaultManagementApi: Readonly<{
38
38
  id: string;
39
39
  name: InternalRole;
40
40
  description: string;
41
+ type: RoleType.MachineToMachine;
41
42
  };
42
43
  }>;
43
44
  export declare function getManagementApiResourceIndicator<TenantId extends string>(tenantId: TenantId): `https://${TenantId}.logto.app/api`;
@@ -1,4 +1,5 @@
1
1
  import { generateStandardId } from '@logto/shared/universal';
2
+ import { RoleType, } from '../db-entries/index.js';
2
3
  import { PredefinedScope, InternalRole, AdminTenantRole } from '../types/index.js';
3
4
  import { adminTenantId, defaultTenantId } from './tenant.js';
4
5
  // Consider remove the dependency of IDs
@@ -36,6 +37,7 @@ export const defaultManagementApi = Object.freeze({
36
37
  id: 'admin-role',
37
38
  name: InternalRole.Admin,
38
39
  description: `Internal admin role for Logto tenant ${defaultTenantId}.`,
40
+ type: RoleType.MachineToMachine,
39
41
  },
40
42
  });
41
43
  export function getManagementApiResourceIndicator(tenantId, path = 'api') {
@@ -66,6 +68,7 @@ export const createAdminData = (tenantId) => {
66
68
  id: generateStandardId(),
67
69
  name: InternalRole.Admin,
68
70
  description: `Internal admin role for Logto tenant ${defaultTenantId}.`,
71
+ type: RoleType.MachineToMachine,
69
72
  },
70
73
  });
71
74
  };
@@ -93,6 +96,7 @@ export const createAdminDataInAdminTenant = (tenantId) => {
93
96
  id: generateStandardId(),
94
97
  name: getManagementApiAdminName(tenantId),
95
98
  description: `Admin tenant admin role for Logto tenant ${tenantId}.`,
99
+ type: RoleType.User,
96
100
  },
97
101
  });
98
102
  };
@@ -119,6 +123,7 @@ export const createMeApiInAdminTenant = () => {
119
123
  id: generateStandardId(),
120
124
  name: AdminTenantRole.User,
121
125
  description: 'Default role for admin tenant.',
126
+ type: RoleType.User,
122
127
  },
123
128
  });
124
129
  };