@logto/schemas 1.36.0 → 1.37.1

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 (44) hide show
  1. package/alterations/1.37.0-1770295353-add-default-id-token-config.ts +30 -0
  2. package/alterations/1.37.0-1770361004-add-oidc-model-instances-session-account-id-indexes.ts +37 -0
  3. package/alterations/1.37.0-1770362227-add-client-id-column-to-oidc-session-extensions-table.ts +20 -0
  4. package/alterations-js/1.37.0-1770295353-add-default-id-token-config.js +23 -0
  5. package/alterations-js/1.37.0-1770361004-add-oidc-model-instances-session-account-id-indexes.js +31 -0
  6. package/alterations-js/1.37.0-1770362227-add-client-id-column-to-oidc-session-extensions-table.js +16 -0
  7. package/lib/db-entries/oidc-session-extension.d.ts +3 -1
  8. package/lib/db-entries/oidc-session-extension.js +4 -0
  9. package/lib/foundations/jsonb-types/account-centers.d.ts +5 -2
  10. package/lib/foundations/jsonb-types/account-centers.js +1 -0
  11. package/lib/foundations/jsonb-types/custom-profile-fields.d.ts +8 -8
  12. package/lib/foundations/jsonb-types/hooks.d.ts +4 -3
  13. package/lib/foundations/jsonb-types/hooks.js +2 -0
  14. package/lib/foundations/jsonb-types/logs.d.ts +0 -3
  15. package/lib/foundations/jsonb-types/logs.js +0 -1
  16. package/lib/foundations/jsonb-types/oidc-module.d.ts +328 -0
  17. package/lib/foundations/jsonb-types/oidc-module.js +42 -0
  18. package/lib/foundations/jsonb-types/saml-application-configs.d.ts +1 -1
  19. package/lib/foundations/jsonb-types/sentinel.d.ts +1 -1
  20. package/lib/foundations/jsonb-types/sentinel.js +1 -1
  21. package/lib/seeds/logto-config.d.ts +6 -1
  22. package/lib/seeds/logto-config.js +11 -0
  23. package/lib/types/custom-profile-fields.d.ts +39 -39
  24. package/lib/types/index.d.ts +1 -0
  25. package/lib/types/index.js +1 -0
  26. package/lib/types/interactions.d.ts +2 -2
  27. package/lib/types/logto-config/index.d.ts +1181 -82
  28. package/lib/types/logto-config/index.js +9 -0
  29. package/lib/types/logto-config/jwt-customizer.d.ts +2039 -116
  30. package/lib/types/logto-config/jwt-customizer.js +22 -2
  31. package/lib/types/logto-config/jwt-customizer.test.js +27 -1
  32. package/lib/types/logto-config/oidc-provider.d.ts +8 -8
  33. package/lib/types/saml-application.d.ts +7 -7
  34. package/lib/types/user-logto-config.d.ts +49 -0
  35. package/lib/types/user-logto-config.js +23 -0
  36. package/lib/types/user-sessions.d.ts +3208 -0
  37. package/lib/types/user-sessions.js +26 -0
  38. package/lib/types/verification-records/verification-type.d.ts +1 -0
  39. package/lib/types/verification-records/verification-type.js +1 -0
  40. package/lib/types/verification-records/web-authn-verification.d.ts +145 -8
  41. package/lib/types/verification-records/web-authn-verification.js +17 -3
  42. package/package.json +5 -5
  43. package/tables/oidc_model_instances.sql +7 -0
  44. package/tables/oidc_session_extensions.sql +1 -0
@@ -122,3 +122,331 @@ export declare const customClientMetadataGuard: z.ZodObject<{
122
122
  * @see {@link CustomClientMetadataKey} for key descriptions.
123
123
  */
124
124
  export type CustomClientMetadata = z.infer<typeof customClientMetadataGuard>;
125
+ export declare const oidcSessionAuthorizationDetailsGuard: z.ZodObject<{
126
+ /**
127
+ * The `sid` (session ID) Claim associated with the session for the current client.
128
+ *
129
+ * @remarks
130
+ * Mark optional to make the guard more robust.
131
+ * Should always be present in the session authorization details
132
+ */
133
+ sid: z.ZodOptional<z.ZodString>;
134
+ /**
135
+ * The grantId associated with the session for the current client.
136
+ *
137
+ * @remarks
138
+ * Mark optional to make the guard more robust.
139
+ * Should always be present in the session authorization details when the session is authorized with a grant.
140
+ */
141
+ grantId: z.ZodOptional<z.ZodString>;
142
+ /**
143
+ * Whether the grant associated with the session should be persisted after the session is terminated.
144
+ *
145
+ * @remarks
146
+ * Mark optional to make the guard more robust.
147
+ */
148
+ persistsLogout: z.ZodOptional<z.ZodBoolean>;
149
+ }, "strip", z.ZodUnknown, z.objectOutputType<{
150
+ /**
151
+ * The `sid` (session ID) Claim associated with the session for the current client.
152
+ *
153
+ * @remarks
154
+ * Mark optional to make the guard more robust.
155
+ * Should always be present in the session authorization details
156
+ */
157
+ sid: z.ZodOptional<z.ZodString>;
158
+ /**
159
+ * The grantId associated with the session for the current client.
160
+ *
161
+ * @remarks
162
+ * Mark optional to make the guard more robust.
163
+ * Should always be present in the session authorization details when the session is authorized with a grant.
164
+ */
165
+ grantId: z.ZodOptional<z.ZodString>;
166
+ /**
167
+ * Whether the grant associated with the session should be persisted after the session is terminated.
168
+ *
169
+ * @remarks
170
+ * Mark optional to make the guard more robust.
171
+ */
172
+ persistsLogout: z.ZodOptional<z.ZodBoolean>;
173
+ }, z.ZodUnknown, "strip">, z.objectInputType<{
174
+ /**
175
+ * The `sid` (session ID) Claim associated with the session for the current client.
176
+ *
177
+ * @remarks
178
+ * Mark optional to make the guard more robust.
179
+ * Should always be present in the session authorization details
180
+ */
181
+ sid: z.ZodOptional<z.ZodString>;
182
+ /**
183
+ * The grantId associated with the session for the current client.
184
+ *
185
+ * @remarks
186
+ * Mark optional to make the guard more robust.
187
+ * Should always be present in the session authorization details when the session is authorized with a grant.
188
+ */
189
+ grantId: z.ZodOptional<z.ZodString>;
190
+ /**
191
+ * Whether the grant associated with the session should be persisted after the session is terminated.
192
+ *
193
+ * @remarks
194
+ * Mark optional to make the guard more robust.
195
+ */
196
+ persistsLogout: z.ZodOptional<z.ZodBoolean>;
197
+ }, z.ZodUnknown, "strip">>;
198
+ export type OidcSessionAuthorizationDetails = z.infer<typeof oidcSessionAuthorizationDetailsGuard>;
199
+ export declare const oidcSessionInstancePayloadGuard: z.ZodObject<{
200
+ exp: z.ZodNumber;
201
+ iat: z.ZodNumber;
202
+ jti: z.ZodString;
203
+ uid: z.ZodString;
204
+ kind: z.ZodLiteral<"Session">;
205
+ loginTs: z.ZodNumber;
206
+ accountId: z.ZodString;
207
+ /**
208
+ * A map of client_id to session authorization details. @see OidcSessionAuthorizationDetails
209
+ */
210
+ authorizations: z.ZodRecord<z.ZodString, z.ZodObject<{
211
+ /**
212
+ * The `sid` (session ID) Claim associated with the session for the current client.
213
+ *
214
+ * @remarks
215
+ * Mark optional to make the guard more robust.
216
+ * Should always be present in the session authorization details
217
+ */
218
+ sid: z.ZodOptional<z.ZodString>;
219
+ /**
220
+ * The grantId associated with the session for the current client.
221
+ *
222
+ * @remarks
223
+ * Mark optional to make the guard more robust.
224
+ * Should always be present in the session authorization details when the session is authorized with a grant.
225
+ */
226
+ grantId: z.ZodOptional<z.ZodString>;
227
+ /**
228
+ * Whether the grant associated with the session should be persisted after the session is terminated.
229
+ *
230
+ * @remarks
231
+ * Mark optional to make the guard more robust.
232
+ */
233
+ persistsLogout: z.ZodOptional<z.ZodBoolean>;
234
+ }, "strip", z.ZodUnknown, z.objectOutputType<{
235
+ /**
236
+ * The `sid` (session ID) Claim associated with the session for the current client.
237
+ *
238
+ * @remarks
239
+ * Mark optional to make the guard more robust.
240
+ * Should always be present in the session authorization details
241
+ */
242
+ sid: z.ZodOptional<z.ZodString>;
243
+ /**
244
+ * The grantId associated with the session for the current client.
245
+ *
246
+ * @remarks
247
+ * Mark optional to make the guard more robust.
248
+ * Should always be present in the session authorization details when the session is authorized with a grant.
249
+ */
250
+ grantId: z.ZodOptional<z.ZodString>;
251
+ /**
252
+ * Whether the grant associated with the session should be persisted after the session is terminated.
253
+ *
254
+ * @remarks
255
+ * Mark optional to make the guard more robust.
256
+ */
257
+ persistsLogout: z.ZodOptional<z.ZodBoolean>;
258
+ }, z.ZodUnknown, "strip">, z.objectInputType<{
259
+ /**
260
+ * The `sid` (session ID) Claim associated with the session for the current client.
261
+ *
262
+ * @remarks
263
+ * Mark optional to make the guard more robust.
264
+ * Should always be present in the session authorization details
265
+ */
266
+ sid: z.ZodOptional<z.ZodString>;
267
+ /**
268
+ * The grantId associated with the session for the current client.
269
+ *
270
+ * @remarks
271
+ * Mark optional to make the guard more robust.
272
+ * Should always be present in the session authorization details when the session is authorized with a grant.
273
+ */
274
+ grantId: z.ZodOptional<z.ZodString>;
275
+ /**
276
+ * Whether the grant associated with the session should be persisted after the session is terminated.
277
+ *
278
+ * @remarks
279
+ * Mark optional to make the guard more robust.
280
+ */
281
+ persistsLogout: z.ZodOptional<z.ZodBoolean>;
282
+ }, z.ZodUnknown, "strip">>>;
283
+ }, "strip", z.ZodUnknown, z.objectOutputType<{
284
+ exp: z.ZodNumber;
285
+ iat: z.ZodNumber;
286
+ jti: z.ZodString;
287
+ uid: z.ZodString;
288
+ kind: z.ZodLiteral<"Session">;
289
+ loginTs: z.ZodNumber;
290
+ accountId: z.ZodString;
291
+ /**
292
+ * A map of client_id to session authorization details. @see OidcSessionAuthorizationDetails
293
+ */
294
+ authorizations: z.ZodRecord<z.ZodString, z.ZodObject<{
295
+ /**
296
+ * The `sid` (session ID) Claim associated with the session for the current client.
297
+ *
298
+ * @remarks
299
+ * Mark optional to make the guard more robust.
300
+ * Should always be present in the session authorization details
301
+ */
302
+ sid: z.ZodOptional<z.ZodString>;
303
+ /**
304
+ * The grantId associated with the session for the current client.
305
+ *
306
+ * @remarks
307
+ * Mark optional to make the guard more robust.
308
+ * Should always be present in the session authorization details when the session is authorized with a grant.
309
+ */
310
+ grantId: z.ZodOptional<z.ZodString>;
311
+ /**
312
+ * Whether the grant associated with the session should be persisted after the session is terminated.
313
+ *
314
+ * @remarks
315
+ * Mark optional to make the guard more robust.
316
+ */
317
+ persistsLogout: z.ZodOptional<z.ZodBoolean>;
318
+ }, "strip", z.ZodUnknown, z.objectOutputType<{
319
+ /**
320
+ * The `sid` (session ID) Claim associated with the session for the current client.
321
+ *
322
+ * @remarks
323
+ * Mark optional to make the guard more robust.
324
+ * Should always be present in the session authorization details
325
+ */
326
+ sid: z.ZodOptional<z.ZodString>;
327
+ /**
328
+ * The grantId associated with the session for the current client.
329
+ *
330
+ * @remarks
331
+ * Mark optional to make the guard more robust.
332
+ * Should always be present in the session authorization details when the session is authorized with a grant.
333
+ */
334
+ grantId: z.ZodOptional<z.ZodString>;
335
+ /**
336
+ * Whether the grant associated with the session should be persisted after the session is terminated.
337
+ *
338
+ * @remarks
339
+ * Mark optional to make the guard more robust.
340
+ */
341
+ persistsLogout: z.ZodOptional<z.ZodBoolean>;
342
+ }, z.ZodUnknown, "strip">, z.objectInputType<{
343
+ /**
344
+ * The `sid` (session ID) Claim associated with the session for the current client.
345
+ *
346
+ * @remarks
347
+ * Mark optional to make the guard more robust.
348
+ * Should always be present in the session authorization details
349
+ */
350
+ sid: z.ZodOptional<z.ZodString>;
351
+ /**
352
+ * The grantId associated with the session for the current client.
353
+ *
354
+ * @remarks
355
+ * Mark optional to make the guard more robust.
356
+ * Should always be present in the session authorization details when the session is authorized with a grant.
357
+ */
358
+ grantId: z.ZodOptional<z.ZodString>;
359
+ /**
360
+ * Whether the grant associated with the session should be persisted after the session is terminated.
361
+ *
362
+ * @remarks
363
+ * Mark optional to make the guard more robust.
364
+ */
365
+ persistsLogout: z.ZodOptional<z.ZodBoolean>;
366
+ }, z.ZodUnknown, "strip">>>;
367
+ }, z.ZodUnknown, "strip">, z.objectInputType<{
368
+ exp: z.ZodNumber;
369
+ iat: z.ZodNumber;
370
+ jti: z.ZodString;
371
+ uid: z.ZodString;
372
+ kind: z.ZodLiteral<"Session">;
373
+ loginTs: z.ZodNumber;
374
+ accountId: z.ZodString;
375
+ /**
376
+ * A map of client_id to session authorization details. @see OidcSessionAuthorizationDetails
377
+ */
378
+ authorizations: z.ZodRecord<z.ZodString, z.ZodObject<{
379
+ /**
380
+ * The `sid` (session ID) Claim associated with the session for the current client.
381
+ *
382
+ * @remarks
383
+ * Mark optional to make the guard more robust.
384
+ * Should always be present in the session authorization details
385
+ */
386
+ sid: z.ZodOptional<z.ZodString>;
387
+ /**
388
+ * The grantId associated with the session for the current client.
389
+ *
390
+ * @remarks
391
+ * Mark optional to make the guard more robust.
392
+ * Should always be present in the session authorization details when the session is authorized with a grant.
393
+ */
394
+ grantId: z.ZodOptional<z.ZodString>;
395
+ /**
396
+ * Whether the grant associated with the session should be persisted after the session is terminated.
397
+ *
398
+ * @remarks
399
+ * Mark optional to make the guard more robust.
400
+ */
401
+ persistsLogout: z.ZodOptional<z.ZodBoolean>;
402
+ }, "strip", z.ZodUnknown, z.objectOutputType<{
403
+ /**
404
+ * The `sid` (session ID) Claim associated with the session for the current client.
405
+ *
406
+ * @remarks
407
+ * Mark optional to make the guard more robust.
408
+ * Should always be present in the session authorization details
409
+ */
410
+ sid: z.ZodOptional<z.ZodString>;
411
+ /**
412
+ * The grantId associated with the session for the current client.
413
+ *
414
+ * @remarks
415
+ * Mark optional to make the guard more robust.
416
+ * Should always be present in the session authorization details when the session is authorized with a grant.
417
+ */
418
+ grantId: z.ZodOptional<z.ZodString>;
419
+ /**
420
+ * Whether the grant associated with the session should be persisted after the session is terminated.
421
+ *
422
+ * @remarks
423
+ * Mark optional to make the guard more robust.
424
+ */
425
+ persistsLogout: z.ZodOptional<z.ZodBoolean>;
426
+ }, z.ZodUnknown, "strip">, z.objectInputType<{
427
+ /**
428
+ * The `sid` (session ID) Claim associated with the session for the current client.
429
+ *
430
+ * @remarks
431
+ * Mark optional to make the guard more robust.
432
+ * Should always be present in the session authorization details
433
+ */
434
+ sid: z.ZodOptional<z.ZodString>;
435
+ /**
436
+ * The grantId associated with the session for the current client.
437
+ *
438
+ * @remarks
439
+ * Mark optional to make the guard more robust.
440
+ * Should always be present in the session authorization details when the session is authorized with a grant.
441
+ */
442
+ grantId: z.ZodOptional<z.ZodString>;
443
+ /**
444
+ * Whether the grant associated with the session should be persisted after the session is terminated.
445
+ *
446
+ * @remarks
447
+ * Mark optional to make the guard more robust.
448
+ */
449
+ persistsLogout: z.ZodOptional<z.ZodBoolean>;
450
+ }, z.ZodUnknown, "strip">>>;
451
+ }, z.ZodUnknown, "strip">>;
452
+ export type OidcSessionInstancePayload = z.infer<typeof oidcSessionInstancePayloadGuard>;
@@ -66,3 +66,45 @@ export const customClientMetadataGuard = z.object({
66
66
  [CustomClientMetadataKey.RotateRefreshToken]: z.boolean().optional(),
67
67
  [CustomClientMetadataKey.AllowTokenExchange]: z.boolean().optional(),
68
68
  });
69
+ export const oidcSessionAuthorizationDetailsGuard = z
70
+ .object({
71
+ /**
72
+ * The `sid` (session ID) Claim associated with the session for the current client.
73
+ *
74
+ * @remarks
75
+ * Mark optional to make the guard more robust.
76
+ * Should always be present in the session authorization details
77
+ */
78
+ sid: z.string().optional(),
79
+ /**
80
+ * The grantId associated with the session for the current client.
81
+ *
82
+ * @remarks
83
+ * Mark optional to make the guard more robust.
84
+ * Should always be present in the session authorization details when the session is authorized with a grant.
85
+ */
86
+ grantId: z.string().optional(),
87
+ /**
88
+ * Whether the grant associated with the session should be persisted after the session is terminated.
89
+ *
90
+ * @remarks
91
+ * Mark optional to make the guard more robust.
92
+ */
93
+ persistsLogout: z.boolean().optional(),
94
+ })
95
+ .catchall(z.unknown());
96
+ export const oidcSessionInstancePayloadGuard = z
97
+ .object({
98
+ exp: z.number(),
99
+ iat: z.number(),
100
+ jti: z.string(),
101
+ uid: z.string(),
102
+ kind: z.literal('Session'),
103
+ loginTs: z.number(),
104
+ accountId: z.string(),
105
+ /**
106
+ * A map of client_id to session authorization details. @see OidcSessionAuthorizationDetails
107
+ */
108
+ authorizations: z.record(z.string(), oidcSessionAuthorizationDetailsGuard),
109
+ })
110
+ .catchall(z.unknown());
@@ -1,7 +1,7 @@
1
1
  import { type UserClaim } from '@logto/core-kit';
2
2
  import { z } from 'zod';
3
3
  export type SamlAttributeMapping = Partial<Record<UserClaim | 'sub', string>>;
4
- export declare const samlAttributeMappingKeys: readonly ("name" | "email" | "username" | "sub" | "nickname" | "profile" | "website" | "gender" | "birthdate" | "zoneinfo" | "locale" | "address" | "given_name" | "family_name" | "middle_name" | "preferred_username" | "picture" | "email_verified" | "phone_number" | "phone_number_verified" | "updated_at" | "roles" | "organizations" | "organization_data" | "organization_roles" | "custom_data" | "identities" | "sso_identities" | "created_at")[];
4
+ export declare const samlAttributeMappingKeys: readonly ("name" | "username" | "email" | "sub" | "nickname" | "profile" | "website" | "gender" | "birthdate" | "zoneinfo" | "locale" | "address" | "given_name" | "family_name" | "middle_name" | "preferred_username" | "picture" | "email_verified" | "phone_number" | "phone_number_verified" | "updated_at" | "created_at" | "custom_data" | "identities" | "sso_identities" | "roles" | "organizations" | "organization_data" | "organization_roles")[];
5
5
  export declare const samlAttributeMappingGuard: z.ZodObject<{
6
6
  [x: string]: z.ZodOptional<z.ZodString>;
7
7
  }, "strip", z.ZodTypeAny, {
@@ -35,7 +35,7 @@ export declare enum SentinelActivityAction {
35
35
  /**
36
36
  * The subject tries to pass a WebAuthn MFA verification.
37
37
  */
38
- MfaWebAuthn = "MfaWebAuthn",
38
+ WebAuthn = "WebAuthn",
39
39
  /**
40
40
  * The subject tries to pass a backup code MFA verification.
41
41
  */
@@ -37,7 +37,7 @@ export var SentinelActivityAction;
37
37
  /**
38
38
  * The subject tries to pass a WebAuthn MFA verification.
39
39
  */
40
- SentinelActivityAction["MfaWebAuthn"] = "MfaWebAuthn";
40
+ SentinelActivityAction["WebAuthn"] = "WebAuthn";
41
41
  /**
42
42
  * The subject tries to pass a backup code MFA verification.
43
43
  */
@@ -1,4 +1,4 @@
1
- import type { AdminConsoleData, CloudConnectionData } from '../types/index.js';
1
+ import type { AdminConsoleData, CloudConnectionData, IdTokenConfig } from '../types/index.js';
2
2
  import { LogtoTenantConfigKey } from '../types/index.js';
3
3
  export declare const createDefaultAdminConsoleConfig: (forTenantId: string) => Readonly<{
4
4
  tenantId: string;
@@ -10,3 +10,8 @@ export declare const createCloudConnectionConfig: (forTenantId: string, appId: s
10
10
  key: LogtoTenantConfigKey;
11
11
  value: CloudConnectionData;
12
12
  }>;
13
+ export declare const createDefaultIdTokenConfig: (forTenantId: string) => Readonly<{
14
+ tenantId: string;
15
+ key: LogtoTenantConfigKey;
16
+ value: IdTokenConfig;
17
+ }>;
@@ -17,3 +17,14 @@ export const createCloudConnectionConfig = (forTenantId, appId, appSecret) => Ob
17
17
  resource: cloudApiIndicator,
18
18
  },
19
19
  });
20
+ export const createDefaultIdTokenConfig = (forTenantId) => Object.freeze({
21
+ tenantId: forTenantId,
22
+ key: LogtoTenantConfigKey.IdToken,
23
+ value: {
24
+ enabledExtendedClaims: [
25
+ 'roles',
26
+ 'organizations',
27
+ 'organization_roles',
28
+ ],
29
+ },
30
+ });