@logto/schemas 1.42.0 → 1.44.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 (189) hide show
  1. package/alterations/1.43.0-1785393731-add-oidc-model-instances-account-id-partial-index.ts +33 -0
  2. package/alterations/1.43.0-1785481546-add-tenant-aware-scope-indexes.ts +33 -0
  3. package/alterations/1.43.0-1785488115-add-cimd-permission-ceiling-tables.ts +77 -0
  4. package/alterations/1.43.0-1785722831-add-oidc-session-extensions-account-id-index.ts +27 -0
  5. package/alterations/1.43.0-1785835991-add-cimd-client-identifier-columns.ts +31 -0
  6. package/alterations/1.43.0-1786325989-add-cimd-grant-organizations-table.ts +54 -0
  7. package/alterations/1.43.0-1786333495-add-trusted-devices.ts +57 -0
  8. package/alterations/1.43.0-1786373004-tighten-cimd-grant-organizations-pkey.ts +28 -0
  9. package/alterations/1.43.0-1786414712-add-service-logs-email-indexes.ts +34 -0
  10. package/alterations/1.43.0-1786431364-add-cimd-grant-client-snapshots-table.ts +43 -0
  11. package/alterations/1.44.0-1788946735-add-saml-authn-request-config.ts +18 -0
  12. package/alterations/1.44.0-1789000000-extend-user-id-length.ts +61 -0
  13. package/alterations-js/1.43.0-1785393731-add-oidc-model-instances-account-id-partial-index.js +28 -0
  14. package/alterations-js/1.43.0-1785481546-add-tenant-aware-scope-indexes.js +28 -0
  15. package/alterations-js/1.43.0-1785488115-add-cimd-permission-ceiling-tables.js +69 -0
  16. package/alterations-js/1.43.0-1785722831-add-oidc-session-extensions-account-id-index.js +23 -0
  17. package/alterations-js/1.43.0-1785835991-add-cimd-client-identifier-columns.js +27 -0
  18. package/alterations-js/1.43.0-1786325989-add-cimd-grant-organizations-table.js +49 -0
  19. package/alterations-js/1.43.0-1786333495-add-trusted-devices.js +50 -0
  20. package/alterations-js/1.43.0-1786373004-tighten-cimd-grant-organizations-pkey.js +24 -0
  21. package/alterations-js/1.43.0-1786414712-add-service-logs-email-indexes.js +30 -0
  22. package/alterations-js/1.43.0-1786431364-add-cimd-grant-client-snapshots-table.js +38 -0
  23. package/alterations-js/1.44.0-1788946735-add-saml-authn-request-config.js +14 -0
  24. package/alterations-js/1.44.0-1789000000-extend-user-id-length.js +47 -0
  25. package/lib/consts/experience.d.ts +3 -0
  26. package/lib/consts/experience.js +3 -0
  27. package/lib/consts/index.d.ts +2 -0
  28. package/lib/consts/index.js +2 -0
  29. package/lib/consts/license.d.ts +222 -0
  30. package/lib/consts/license.js +81 -0
  31. package/lib/consts/license.test.d.ts +1 -0
  32. package/lib/consts/license.test.js +96 -0
  33. package/lib/consts/oidc.d.ts +15 -1
  34. package/lib/consts/oidc.js +11 -0
  35. package/lib/consts/oidc.test.d.ts +1 -0
  36. package/lib/consts/oidc.test.js +15 -0
  37. package/lib/consts/product-event.d.ts +5 -1
  38. package/lib/consts/product-event.js +4 -0
  39. package/lib/consts/social-state.d.ts +12 -0
  40. package/lib/consts/social-state.js +12 -0
  41. package/lib/consts/subscriptions.d.ts +13 -1
  42. package/lib/consts/subscriptions.js +12 -0
  43. package/lib/db-entries/aggregated-daily-active-user.js +2 -2
  44. package/lib/db-entries/application-access-control-user-relation.js +2 -2
  45. package/lib/db-entries/application-user-consent-organization.js +2 -2
  46. package/lib/db-entries/cimd-grant-client-snapshot.d.ts +32 -0
  47. package/lib/db-entries/cimd-grant-client-snapshot.js +45 -0
  48. package/lib/db-entries/cimd-grant-organization.d.ts +30 -0
  49. package/lib/db-entries/cimd-grant-organization.js +37 -0
  50. package/lib/db-entries/cimd-organization-resource-scope.d.ts +20 -0
  51. package/lib/db-entries/cimd-organization-resource-scope.js +25 -0
  52. package/lib/db-entries/cimd-organization-scope.d.ts +20 -0
  53. package/lib/db-entries/cimd-organization-scope.js +25 -0
  54. package/lib/db-entries/cimd-resource-scope.d.ts +20 -0
  55. package/lib/db-entries/cimd-resource-scope.js +25 -0
  56. package/lib/db-entries/cimd-user-scope.d.ts +20 -0
  57. package/lib/db-entries/cimd-user-scope.js +25 -0
  58. package/lib/db-entries/daily-active-user.js +2 -2
  59. package/lib/db-entries/index.d.ts +7 -0
  60. package/lib/db-entries/index.js +7 -0
  61. package/lib/db-entries/oidc-session-extension.d.ts +3 -1
  62. package/lib/db-entries/oidc-session-extension.js +6 -2
  63. package/lib/db-entries/organization-invitation.js +4 -4
  64. package/lib/db-entries/organization-role-user-relation.js +2 -2
  65. package/lib/db-entries/organization-user-relation.js +2 -2
  66. package/lib/db-entries/organization.d.ts +5 -1
  67. package/lib/db-entries/organization.js +4 -0
  68. package/lib/db-entries/personal-access-token.js +2 -2
  69. package/lib/db-entries/saml-application-config.d.ts +4 -2
  70. package/lib/db-entries/saml-application-config.js +5 -1
  71. package/lib/db-entries/secret.js +2 -2
  72. package/lib/db-entries/sign-in-experience.d.ts +4 -2
  73. package/lib/db-entries/sign-in-experience.js +5 -1
  74. package/lib/db-entries/subject-token.js +2 -2
  75. package/lib/db-entries/trusted-device.d.ts +36 -0
  76. package/lib/db-entries/trusted-device.js +62 -0
  77. package/lib/db-entries/user-geo-location.js +2 -2
  78. package/lib/db-entries/user-sign-in-country.js +2 -2
  79. package/lib/db-entries/user-sso-identity.js +2 -2
  80. package/lib/db-entries/user.d.ts +3 -1
  81. package/lib/db-entries/user.js +6 -2
  82. package/lib/db-entries/users-role.js +2 -2
  83. package/lib/db-entries/verification-record.js +2 -2
  84. package/lib/db-entries/verification-status.js +2 -2
  85. package/lib/foundations/jsonb-types/account-centers.d.ts +3 -0
  86. package/lib/foundations/jsonb-types/account-centers.js +1 -0
  87. package/lib/foundations/jsonb-types/account-centers.test.d.ts +1 -0
  88. package/lib/foundations/jsonb-types/account-centers.test.js +13 -0
  89. package/lib/foundations/jsonb-types/captcha.d.ts +47 -1
  90. package/lib/foundations/jsonb-types/captcha.js +20 -0
  91. package/lib/foundations/jsonb-types/hooks.d.ts +5 -4
  92. package/lib/foundations/jsonb-types/hooks.js +3 -0
  93. package/lib/foundations/jsonb-types/logs.d.ts +18 -0
  94. package/lib/foundations/jsonb-types/logs.js +6 -0
  95. package/lib/foundations/jsonb-types/saml-application-configs.d.ts +23 -0
  96. package/lib/foundations/jsonb-types/saml-application-configs.js +16 -0
  97. package/lib/foundations/jsonb-types/saml-application-configs.test.js +24 -1
  98. package/lib/foundations/jsonb-types/sign-in-experience.d.ts +23 -3
  99. package/lib/foundations/jsonb-types/sign-in-experience.js +9 -0
  100. package/lib/foundations/jsonb-types/sign-in-experience.test.js +17 -1
  101. package/lib/types/authentication-context.d.ts +224 -0
  102. package/lib/types/authentication-context.js +238 -0
  103. package/lib/types/authentication-context.test.d.ts +1 -0
  104. package/lib/types/authentication-context.test.js +186 -0
  105. package/lib/types/connector.d.ts +8 -0
  106. package/lib/types/consent.d.ts +16 -190
  107. package/lib/types/consent.js +10 -1
  108. package/lib/types/cookie.d.ts +4 -0
  109. package/lib/types/cookie.js +6 -1
  110. package/lib/types/custom-profile-fields.d.ts +1 -0
  111. package/lib/types/hook.d.ts +31 -6
  112. package/lib/types/index.d.ts +2 -0
  113. package/lib/types/index.js +2 -0
  114. package/lib/types/interactions.d.ts +161 -0
  115. package/lib/types/interactions.js +23 -0
  116. package/lib/types/log/index.d.ts +5 -2
  117. package/lib/types/log/index.js +1 -0
  118. package/lib/types/log/interaction.d.ts +15 -2
  119. package/lib/types/log/interaction.js +5 -0
  120. package/lib/types/log/trusted-device.d.ts +7 -0
  121. package/lib/types/log/trusted-device.js +6 -0
  122. package/lib/types/logto-config/action.d.ts +1 -1
  123. package/lib/types/logto-config/action.js +1 -1
  124. package/lib/types/logto-config/index.d.ts +83 -7
  125. package/lib/types/logto-config/index.js +14 -0
  126. package/lib/types/logto-config/index.test.js +23 -0
  127. package/lib/types/logto-config/jwt-customizer.d.ts +123 -10
  128. package/lib/types/logto-config/jwt-customizer.js +1 -1
  129. package/lib/types/logto-config/oidc-provider.d.ts +2 -2
  130. package/lib/types/saml-application.d.ts +55 -1
  131. package/lib/types/saml-application.js +7 -1
  132. package/lib/types/service-log.d.ts +14 -1
  133. package/lib/types/service-log.js +13 -0
  134. package/lib/types/sign-in-experience.d.ts +20 -6
  135. package/lib/types/sign-in-experience.js +1 -0
  136. package/lib/types/ssr.d.ts +2 -0
  137. package/lib/types/system.d.ts +59 -7
  138. package/lib/types/system.js +36 -0
  139. package/lib/types/system.test.d.ts +1 -0
  140. package/lib/types/system.test.js +26 -0
  141. package/lib/types/trusted-device.d.ts +67 -0
  142. package/lib/types/trusted-device.js +16 -0
  143. package/lib/types/user-sessions.d.ts +195 -209
  144. package/lib/types/user-sessions.js +9 -4
  145. package/lib/types/user.d.ts +10 -3
  146. package/lib/types/user.js +1 -0
  147. package/lib/types/verification-records/code-verification.d.ts +17 -0
  148. package/lib/types/verification-records/code-verification.js +1 -0
  149. package/lib/utils/cimd.d.ts +14 -0
  150. package/lib/utils/cimd.js +14 -0
  151. package/lib/utils/cimd.test.d.ts +1 -0
  152. package/lib/utils/cimd.test.js +9 -0
  153. package/lib/utils/index.d.ts +1 -0
  154. package/lib/utils/index.js +1 -0
  155. package/lib/utils/oidc-private-key.test.js +44 -0
  156. package/package.json +9 -9
  157. package/tables/aggregated_daily_active_users.sql +1 -1
  158. package/tables/application_access_control_user_relations.sql +1 -1
  159. package/tables/application_user_consent_organizations.sql +1 -1
  160. package/tables/cimd_grant_client_snapshots.sql +27 -0
  161. package/tables/cimd_grant_organizations.sql +38 -0
  162. package/tables/cimd_organization_resource_scopes.sql +16 -0
  163. package/tables/cimd_organization_scopes.sql +15 -0
  164. package/tables/cimd_resource_scopes.sql +15 -0
  165. package/tables/cimd_user_scopes.sql +13 -0
  166. package/tables/daily_active_users.sql +1 -1
  167. package/tables/oidc_model_instances.sql +5 -0
  168. package/tables/oidc_session_extensions.sql +6 -1
  169. package/tables/organization_invitations.sql +2 -2
  170. package/tables/organization_role_user_relations.sql +1 -1
  171. package/tables/organization_scopes.sql +4 -0
  172. package/tables/organization_user_relations.sql +1 -1
  173. package/tables/organizations.sql +2 -0
  174. package/tables/personal_access_tokens.sql +1 -1
  175. package/tables/saml_application_configs.sql +1 -0
  176. package/tables/scopes.sql +4 -0
  177. package/tables/secrets.sql +1 -1
  178. package/tables/service_logs.sql +14 -0
  179. package/tables/sign_in_experiences.sql +1 -0
  180. package/tables/subject_tokens.sql +1 -1
  181. package/tables/trusted_devices.sql +25 -0
  182. package/tables/user_geo_locations.sql +1 -1
  183. package/tables/user_sign_in_countries.sql +1 -1
  184. package/tables/user_sso_identities.sql +1 -1
  185. package/tables/users.sql +2 -1
  186. package/tables/users_roles.sql +1 -1
  187. package/tables/verification_records.sql +1 -1
  188. package/tables/verification_statuses.sql +1 -1
  189. package/LICENSE +0 -373
@@ -2,8 +2,10 @@
2
2
  import { emailRegEx, numberAndAlphabetRegEx, phoneRegEx, usernameRegEx } from '@logto/core-kit';
3
3
  import { z } from 'zod';
4
4
  import { AdditionalIdentifier, MfaFactor, SignInIdentifier, jsonObjectGuard, webAuthnTransportGuard, } from '../foundations/index.js';
5
+ import { requestedAuthenticationContextGuard, } from './authentication-context.js';
5
6
  import { InteractionEvent } from './interaction-event.js';
6
7
  import { emailVerificationCodePayloadGuard, phoneVerificationCodePayloadGuard, } from './verification-code.js';
8
+ import { VerificationType } from './verification-records/verification-type.js';
7
9
  export { eventGuard, InteractionEvent } from './interaction-event.js';
8
10
  export const verificationIdentifierGuard = z.object({
9
11
  type: z.union([z.nativeEnum(SignInIdentifier), z.nativeEnum(AdditionalIdentifier)]),
@@ -25,6 +27,14 @@ export const verificationCodeIdentifierGuard = z.discriminatedUnion('type', [
25
27
  value: z.string().regex(phoneRegEx),
26
28
  }),
27
29
  ]);
30
+ export const subjectVerificationCodeIdentifierGuard = z.object({
31
+ type: z.enum([SignInIdentifier.Email, SignInIdentifier.Phone]),
32
+ value: z.undefined(),
33
+ });
34
+ export const verificationCodeIdentifierPayloadGuard = z.union([
35
+ verificationCodeIdentifierGuard,
36
+ subjectVerificationCodeIdentifierGuard,
37
+ ]);
28
38
  export const socialAuthorizationUrlPayloadGuard = z.object({
29
39
  state: z.string(),
30
40
  redirectUri: z.string(),
@@ -38,6 +48,10 @@ export const passwordVerificationPayloadGuard = z.object({
38
48
  identifier: interactionIdentifierGuard,
39
49
  password: z.string().min(1),
40
50
  });
51
+ export const subjectPasswordVerificationPayloadGuard = z.object({
52
+ identifier: z.undefined(),
53
+ password: z.string().min(1),
54
+ });
41
55
  export const totpVerificationVerifyPayloadGuard = z.object({
42
56
  code: z.string().min(1),
43
57
  verificationId: z.string().optional(),
@@ -149,6 +163,15 @@ export var MissingProfile;
149
163
  MissingProfile["emailOrPhone"] = "emailOrPhone";
150
164
  MissingProfile["extraProfile"] = "extraProfile";
151
165
  })(MissingProfile || (MissingProfile = {}));
166
+ export const interactionAuthenticationContextGuard = requestedAuthenticationContextGuard.extend({
167
+ availableMethods: z.nativeEnum(VerificationType).array(),
168
+ establishableMethods: z.nativeEnum(MissingProfile).array(),
169
+ enrollableFactors: z.nativeEnum(MfaFactor).array(),
170
+ subjectProofConnectors: z
171
+ .object({ type: z.enum(['social', 'sso']), connectorId: z.string() })
172
+ .array(),
173
+ maskedIdentifiers: z.object({ email: z.string().optional(), phone: z.string().optional() }),
174
+ });
152
175
  export const bindTotpPayloadGuard = z.object({
153
176
  // Unlike identifier payload which has indicator like "email",
154
177
  // mfa payload must have an additional type field to indicate type
@@ -4,12 +4,14 @@ import type * as interaction from './interaction.js';
4
4
  import type * as jwtCustomizer from './jwt-customizer.js';
5
5
  import type * as saml from './saml.js';
6
6
  import type * as token from './token.js';
7
+ import type * as trustedDevice from './trusted-device.js';
7
8
  export * as interaction from './interaction.js';
8
9
  export * as token from './token.js';
9
10
  export * as hook from './hook.js';
10
11
  export * as action from './action.js';
11
12
  export * as jwtCustomizer from './jwt-customizer.js';
12
13
  export * as saml from './saml.js';
14
+ export * as trustedDevice from './trusted-device.js';
13
15
  /** Fallback for empty or unrecognized log keys. */
14
16
  export declare const LogKeyUnknown = "Unknown";
15
17
  export type InteractionLogKey = interaction.LogKey;
@@ -18,17 +20,18 @@ export type WebhookLogKey = hook.LogKey;
18
20
  export type ActionLogKey = action.LogKey;
19
21
  export type JwtCustomizerLogKey = jwtCustomizer.LogKey;
20
22
  export type SamlLogKey = saml.LogKey;
23
+ export type TrustedDeviceLogKey = trustedDevice.LogKey;
21
24
  /**
22
25
  * The union type of all available audit log keys.
23
26
  *
24
27
  * - All user-facing audit log keys should be included here.
25
28
  * - Webhook log keys are excluded.
26
29
  */
27
- export type AuditLogKey = typeof LogKeyUnknown | InteractionLogKey | TokenLogKey | SamlLogKey | ActionLogKey | JwtCustomizerLogKey;
30
+ export type AuditLogKey = typeof LogKeyUnknown | InteractionLogKey | TokenLogKey | SamlLogKey | ActionLogKey | JwtCustomizerLogKey | TrustedDeviceLogKey;
28
31
  /**
29
32
  * The union type of all available log keys.
30
33
  * Note duplicate keys are allowed but should be avoided.
31
34
  **/
32
35
  export type LogKey = AuditLogKey | WebhookLogKey;
33
- export type AuditLogPrefix = interaction.Prefix | token.Type | saml.Prefix | action.Prefix | jwtCustomizer.Prefix | typeof LogKeyUnknown;
36
+ export type AuditLogPrefix = interaction.Prefix | token.Type | saml.Prefix | action.Prefix | jwtCustomizer.Prefix | trustedDevice.Prefix | typeof LogKeyUnknown;
34
37
  export type WebhookLogPrefix = hook.Type;
@@ -4,5 +4,6 @@ export * as hook from './hook.js';
4
4
  export * as action from './action.js';
5
5
  export * as jwtCustomizer from './jwt-customizer.js';
6
6
  export * as saml from './saml.js';
7
+ export * as trustedDevice from './trusted-device.js';
7
8
  /** Fallback for empty or unrecognized log keys. */
8
9
  export const LogKeyUnknown = 'Unknown';
@@ -13,7 +13,12 @@ export declare enum Field {
13
13
  Mfa = "Mfa",
14
14
  Verification = "Verification",
15
15
  Captcha = "Captcha",
16
- SignInPasskey = "SignInPasskey"
16
+ SignInPasskey = "SignInPasskey",
17
+ /**
18
+ * A pure step-up submission: an authenticated session re-proved its subject to reach a requested
19
+ * authentication context class. Not a sign-in, so it never shares `SignIn.Submit`.
20
+ */
21
+ StepUp = "StepUp"
17
22
  }
18
23
  /** Method to verify the identifier */
19
24
  export declare enum Method {
@@ -74,5 +79,13 @@ export type DeprecatedInteractionLogKey = `${Prefix}.${InteractionEvent}.${Field
74
79
  * - Indicates an identifier method is being created or submitted to an interaction.
75
80
  * - When {@link Method} is `VerificationCode`, {@link Action} can be `Create` (generate and send a code) or `Submit` (verify and submit to the identifiers);
76
81
  * - Otherwise, {@link Action} is fixed to `Submit` (other methods can be verified on submitting).
82
+ *
83
+ * ```ts
84
+ * `Interaction.${InteractionEvent}.${Field.StepUp}.${Action.Submit}`
85
+ * ```
86
+ *
87
+ * - Indicates a pure step-up interaction is submitted: an authenticated session re-proved its
88
+ * subject to reach the requested authentication context class. Its payload records the requested
89
+ * and achieved classes and the factor families that were proved, never a credential.
77
90
  */
78
- export type LogKey = `${Prefix}.${Action.Create | Action.End}` | `${Prefix}.${Action.Create}.${Field.Captcha}` | `${Prefix}.${InteractionEvent}.${Action.Create | Action.Update | Action.Submit}` | `${Prefix}.${InteractionEvent}.${Field.Profile}.${Action.Update}` | `${Prefix}.${InteractionEvent}.${Field.BindMfa}.${MfaFactor}.${Action.Submit}` | `${Prefix}.${InteractionEvent}.${Field.SignInPasskey}.${Action.Submit}` | `${Prefix}.${InteractionEvent}.${Field.Verification}.${VerificationType}.${Action}` | `${Prefix}.${InteractionEvent}.${Field.Identifier}.${Action.Submit}` | `${Prefix}.${InteractionEvent.SignIn}.${Field.Verification}.IdpInitiatedSso.${Action.Create}` | DeprecatedInteractionLogKey;
91
+ export type LogKey = `${Prefix}.${Action.Create | Action.End}` | `${Prefix}.${Action.Create}.${Field.Captcha}` | `${Prefix}.${InteractionEvent}.${Action.Create | Action.Update | Action.Submit}` | `${Prefix}.${InteractionEvent}.${Field.Profile}.${Action.Update}` | `${Prefix}.${InteractionEvent}.${Field.BindMfa}.${MfaFactor}.${Action.Submit}` | `${Prefix}.${InteractionEvent}.${Field.SignInPasskey}.${Action.Submit}` | `${Prefix}.${InteractionEvent}.${Field.Verification}.${VerificationType}.${Action}` | `${Prefix}.${InteractionEvent}.${Field.Identifier}.${Action.Submit}` | `${Prefix}.${InteractionEvent}.${Field.StepUp}.${Action.Submit}` | `${Prefix}.${InteractionEvent.SignIn}.${Field.Verification}.IdpInitiatedSso.${Action.Create}` | DeprecatedInteractionLogKey;
@@ -11,6 +11,11 @@ export var Field;
11
11
  Field["Verification"] = "Verification";
12
12
  Field["Captcha"] = "Captcha";
13
13
  Field["SignInPasskey"] = "SignInPasskey";
14
+ /**
15
+ * A pure step-up submission: an authenticated session re-proved its subject to reach a requested
16
+ * authentication context class. Not a sign-in, so it never shares `SignIn.Submit`.
17
+ */
18
+ Field["StepUp"] = "StepUp";
14
19
  })(Field || (Field = {}));
15
20
  /** Method to verify the identifier */
16
21
  export var Method;
@@ -0,0 +1,7 @@
1
+ export type Prefix = 'TrustedDevice';
2
+ export declare const prefix: Prefix;
3
+ export declare enum Type {
4
+ Created = "Created",
5
+ Used = "Used"
6
+ }
7
+ export type LogKey = `${Prefix}.${Type}`;
@@ -0,0 +1,6 @@
1
+ export const prefix = 'TrustedDevice';
2
+ export var Type;
3
+ (function (Type) {
4
+ Type["Created"] = "Created";
5
+ Type["Used"] = "Used";
6
+ })(Type || (Type = {}));
@@ -39,7 +39,7 @@ export declare const logtoActionGuard: z.ZodObject<{
39
39
  }>;
40
40
  /**
41
41
  * Shared execution payload for production Actions and Management API dry runs.
42
- * Cloud remote execution and the local VM runner both accept this shape.
42
+ * Cloud remote execution and the local runner both accept this shape.
43
43
  */
44
44
  export declare const actionExecutionRequestBodyGuard: z.ZodObject<{
45
45
  script: z.ZodString;
@@ -21,7 +21,7 @@ export const logtoActionGuard = z
21
21
  .strict();
22
22
  /**
23
23
  * Shared execution payload for production Actions and Management API dry runs.
24
- * Cloud remote execution and the local VM runner both accept this shape.
24
+ * Cloud remote execution and the local runner both accept this shape.
25
25
  */
26
26
  export const actionExecutionRequestBodyGuard = z
27
27
  .object({