@logto/schemas 1.35.0 → 1.37.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 (85) hide show
  1. package/alterations/1.36.0-1767193412-allow-token-exchange.ts +34 -0
  2. package/alterations/1.36.0-1767859553-passkey-sign-in.ts +21 -0
  3. package/alterations/1.36.0-1768192304-enable-account-center-for-admin-tenant.ts +32 -0
  4. package/alterations/1.36.0-1768464306-enable-mfa-for-admin-tenant.ts +30 -0
  5. package/alterations/1.36.0-1768758295-add-user-geo-location.ts +32 -0
  6. package/alterations/1.36.0-1768891516-add-user-sign-in-countries-table.ts +33 -0
  7. package/alterations/1.36.0-1769067642-add-adaptive-mfa-configuration.ts +19 -0
  8. package/alterations/1.36.0-1769172677-enable-organization-mfa-policy-for-admin-tenant.ts +31 -0
  9. package/alterations/1.37.0-1770295353-add-default-id-token-config.ts +30 -0
  10. package/alterations/1.37.0-1770361004-add-oidc-model-instances-session-account-id-indexes.ts +37 -0
  11. package/alterations/1.37.0-1770362227-add-client-id-column-to-oidc-session-extensions-table.ts +20 -0
  12. package/alterations-js/1.36.0-1767193412-allow-token-exchange.js +30 -0
  13. package/alterations-js/1.36.0-1767859553-passkey-sign-in.js +17 -0
  14. package/alterations-js/1.36.0-1768192304-enable-account-center-for-admin-tenant.js +27 -0
  15. package/alterations-js/1.36.0-1768464306-enable-mfa-for-admin-tenant.js +25 -0
  16. package/alterations-js/1.36.0-1768758295-add-user-geo-location.js +27 -0
  17. package/alterations-js/1.36.0-1768891516-add-user-sign-in-countries-table.js +28 -0
  18. package/alterations-js/1.36.0-1769067642-add-adaptive-mfa-configuration.js +15 -0
  19. package/alterations-js/1.36.0-1769172677-enable-organization-mfa-policy-for-admin-tenant.js +26 -0
  20. package/alterations-js/1.37.0-1770295353-add-default-id-token-config.js +23 -0
  21. package/alterations-js/1.37.0-1770361004-add-oidc-model-instances-session-account-id-indexes.js +31 -0
  22. package/alterations-js/1.37.0-1770362227-add-client-id-column-to-oidc-session-extensions-table.js +16 -0
  23. package/lib/db-entries/index.d.ts +2 -0
  24. package/lib/db-entries/index.js +2 -0
  25. package/lib/db-entries/oidc-session-extension.d.ts +3 -1
  26. package/lib/db-entries/oidc-session-extension.js +4 -0
  27. package/lib/db-entries/sign-in-experience.d.ts +6 -2
  28. package/lib/db-entries/sign-in-experience.js +9 -1
  29. package/lib/db-entries/user-geo-location.d.ts +24 -0
  30. package/lib/db-entries/user-geo-location.js +37 -0
  31. package/lib/db-entries/user-sign-in-country.d.ts +24 -0
  32. package/lib/db-entries/user-sign-in-country.js +33 -0
  33. package/lib/foundations/jsonb-types/account-centers.d.ts +3 -0
  34. package/lib/foundations/jsonb-types/account-centers.js +1 -0
  35. package/lib/foundations/jsonb-types/custom-profile-fields.d.ts +8 -8
  36. package/lib/foundations/jsonb-types/hooks.d.ts +4 -3
  37. package/lib/foundations/jsonb-types/hooks.js +2 -0
  38. package/lib/foundations/jsonb-types/logs.d.ts +700 -0
  39. package/lib/foundations/jsonb-types/logs.js +51 -0
  40. package/lib/foundations/jsonb-types/oidc-module.d.ts +343 -3
  41. package/lib/foundations/jsonb-types/oidc-module.js +57 -3
  42. package/lib/foundations/jsonb-types/saml-application-configs.d.ts +1 -1
  43. package/lib/foundations/jsonb-types/sentinel.d.ts +13 -1
  44. package/lib/foundations/jsonb-types/sentinel.js +12 -0
  45. package/lib/foundations/jsonb-types/sign-in-experience.d.ts +59 -0
  46. package/lib/foundations/jsonb-types/sign-in-experience.js +11 -0
  47. package/lib/seeds/account-center.d.ts +6 -0
  48. package/lib/seeds/account-center.js +24 -0
  49. package/lib/seeds/cloud-api.d.ts +3 -1
  50. package/lib/seeds/cloud-api.js +2 -0
  51. package/lib/seeds/logto-config.d.ts +6 -1
  52. package/lib/seeds/logto-config.js +11 -0
  53. package/lib/seeds/sign-in-experience.js +6 -1
  54. package/lib/types/application.d.ts +6 -0
  55. package/lib/types/consent.d.ts +4 -0
  56. package/lib/types/custom-profile-fields.d.ts +36 -36
  57. package/lib/types/hook.d.ts +2 -2
  58. package/lib/types/index.d.ts +1 -0
  59. package/lib/types/index.js +1 -0
  60. package/lib/types/log/index.d.ts +12 -6
  61. package/lib/types/log/interaction.d.ts +5 -1
  62. package/lib/types/logto-config/index.d.ts +1190 -91
  63. package/lib/types/logto-config/index.js +9 -0
  64. package/lib/types/logto-config/jwt-customizer.d.ts +2059 -136
  65. package/lib/types/logto-config/jwt-customizer.js +22 -2
  66. package/lib/types/logto-config/jwt-customizer.test.js +27 -1
  67. package/lib/types/logto-config/oidc-provider.d.ts +8 -8
  68. package/lib/types/saml-application.d.ts +7 -7
  69. package/lib/types/sign-in-experience.d.ts +6 -0
  70. package/lib/types/user-logto-config.d.ts +49 -0
  71. package/lib/types/user-logto-config.js +23 -0
  72. package/lib/types/user-sessions.d.ts +3208 -0
  73. package/lib/types/user-sessions.js +26 -0
  74. package/lib/types/user.d.ts +7 -7
  75. package/lib/types/verification-records/verification-type.d.ts +1 -0
  76. package/lib/types/verification-records/verification-type.js +1 -0
  77. package/lib/types/verification-records/web-authn-verification.d.ts +145 -8
  78. package/lib/types/verification-records/web-authn-verification.js +17 -3
  79. package/package.json +5 -5
  80. package/tables/oidc_model_instances.sql +7 -0
  81. package/tables/oidc_session_extensions.sql +1 -0
  82. package/tables/sign_in_experiences.sql +2 -0
  83. package/tables/user_geo_locations.sql +14 -0
  84. package/tables/user_sign_in_countries.sql +16 -0
  85. package/tables/users.sql +3 -0
@@ -0,0 +1,26 @@
1
+ import { z } from 'zod';
2
+ import { OidcModelInstances } from '../db-entries/oidc-model-instance.js';
3
+ import { oidcSessionInstancePayloadGuard } from '../foundations/index.js';
4
+ import { jwtCustomizerUserInteractionContextGuard } from './logto-config/jwt-customizer.js';
5
+ export const userSessionSignInContextGuard = z
6
+ .object({
7
+ ip: z.string().optional(),
8
+ userAgent: z.string().optional(),
9
+ country: z.string().optional(),
10
+ city: z.string().optional(),
11
+ latitude: z.string().optional(),
12
+ longitude: z.string().optional(),
13
+ botScore: z.string().optional(),
14
+ botVerified: z.string().optional(),
15
+ })
16
+ .catchall(z.string());
17
+ export const userExtendedSessionGuard = OidcModelInstances.guard.extend({
18
+ payload: oidcSessionInstancePayloadGuard,
19
+ lastSubmission: jwtCustomizerUserInteractionContextGuard.nullable(),
20
+ clientId: z.string().nullable(),
21
+ accountId: z.string().nullable(),
22
+ });
23
+ export const getUserSessionsResponseGuard = z.object({
24
+ sessions: z.array(userExtendedSessionGuard),
25
+ });
26
+ export const getUserSessionResponseGuard = userExtendedSessionGuard;
@@ -1,7 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  import { type User } from '../db-entries/index.js';
3
3
  import { MfaFactor } from '../foundations/index.js';
4
- export declare const userInfoSelectFields: readonly ("name" | "id" | "applicationId" | "username" | "createdAt" | "profile" | "avatar" | "customData" | "identities" | "updatedAt" | "primaryEmail" | "primaryPhone" | "isSuspended" | "lastSignInAt")[];
4
+ export declare const userInfoSelectFields: readonly ("name" | "id" | "applicationId" | "username" | "createdAt" | "profile" | "avatar" | "customData" | "identities" | "updatedAt" | "lastSignInAt" | "primaryEmail" | "primaryPhone" | "isSuspended")[];
5
5
  export declare const userInfoGuard: z.ZodObject<Pick<{
6
6
  tenantId: z.ZodType<string, z.ZodTypeDef, string>;
7
7
  id: z.ZodType<string, z.ZodTypeDef, string>;
@@ -122,7 +122,7 @@ export declare const userInfoGuard: z.ZodObject<Pick<{
122
122
  lastSignInAt: z.ZodType<number | null, z.ZodTypeDef, number | null>;
123
123
  createdAt: z.ZodType<number, z.ZodTypeDef, number>;
124
124
  updatedAt: z.ZodType<number, z.ZodTypeDef, number>;
125
- }, "name" | "id" | "applicationId" | "username" | "createdAt" | "profile" | "avatar" | "customData" | "identities" | "updatedAt" | "primaryEmail" | "primaryPhone" | "isSuspended" | "lastSignInAt">, "strip", z.ZodTypeAny, {
125
+ }, "name" | "id" | "applicationId" | "username" | "createdAt" | "profile" | "avatar" | "customData" | "identities" | "updatedAt" | "lastSignInAt" | "primaryEmail" | "primaryPhone" | "isSuspended">, "strip", z.ZodTypeAny, {
126
126
  name: string | null;
127
127
  id: string;
128
128
  applicationId: string | null;
@@ -133,10 +133,10 @@ export declare const userInfoGuard: z.ZodObject<Pick<{
133
133
  customData: import("@withtyped/server/lib/types.js").JsonObject;
134
134
  identities: import("../foundations/index.js").Identities;
135
135
  updatedAt: number;
136
+ lastSignInAt: number | null;
136
137
  primaryEmail: string | null;
137
138
  primaryPhone: string | null;
138
139
  isSuspended: boolean;
139
- lastSignInAt: number | null;
140
140
  }, {
141
141
  name: string | null;
142
142
  id: string;
@@ -148,10 +148,10 @@ export declare const userInfoGuard: z.ZodObject<Pick<{
148
148
  customData: import("@withtyped/server/lib/types.js").JsonObject;
149
149
  identities: import("../foundations/index.js").Identities;
150
150
  updatedAt: number;
151
+ lastSignInAt: number | null;
151
152
  primaryEmail: string | null;
152
153
  primaryPhone: string | null;
153
154
  isSuspended: boolean;
154
- lastSignInAt: number | null;
155
155
  }>;
156
156
  export type UserInfo = z.infer<typeof userInfoGuard>;
157
157
  export declare const userProfileResponseGuard: z.ZodObject<Pick<{
@@ -274,7 +274,7 @@ export declare const userProfileResponseGuard: z.ZodObject<Pick<{
274
274
  lastSignInAt: z.ZodType<number | null, z.ZodTypeDef, number | null>;
275
275
  createdAt: z.ZodType<number, z.ZodTypeDef, number>;
276
276
  updatedAt: z.ZodType<number, z.ZodTypeDef, number>;
277
- }, "name" | "id" | "applicationId" | "username" | "createdAt" | "profile" | "avatar" | "customData" | "identities" | "updatedAt" | "primaryEmail" | "primaryPhone" | "isSuspended" | "lastSignInAt"> & {
277
+ }, "name" | "id" | "applicationId" | "username" | "createdAt" | "profile" | "avatar" | "customData" | "identities" | "updatedAt" | "lastSignInAt" | "primaryEmail" | "primaryPhone" | "isSuspended"> & {
278
278
  hasPassword: z.ZodOptional<z.ZodBoolean>;
279
279
  ssoIdentities: z.ZodOptional<z.ZodArray<import("../foundations/schemas.js").Guard<import("../db-entries/user-sso-identity.js").UserSsoIdentity>, "many">>;
280
280
  }, "strip", z.ZodTypeAny, {
@@ -288,10 +288,10 @@ export declare const userProfileResponseGuard: z.ZodObject<Pick<{
288
288
  customData: import("@withtyped/server/lib/types.js").JsonObject;
289
289
  identities: import("../foundations/index.js").Identities;
290
290
  updatedAt: number;
291
+ lastSignInAt: number | null;
291
292
  primaryEmail: string | null;
292
293
  primaryPhone: string | null;
293
294
  isSuspended: boolean;
294
- lastSignInAt: number | null;
295
295
  hasPassword?: boolean | undefined;
296
296
  ssoIdentities?: import("../db-entries/user-sso-identity.js").UserSsoIdentity[] | undefined;
297
297
  }, {
@@ -305,10 +305,10 @@ export declare const userProfileResponseGuard: z.ZodObject<Pick<{
305
305
  customData: import("@withtyped/server/lib/types.js").JsonObject;
306
306
  identities: import("../foundations/index.js").Identities;
307
307
  updatedAt: number;
308
+ lastSignInAt: number | null;
308
309
  primaryEmail: string | null;
309
310
  primaryPhone: string | null;
310
311
  isSuspended: boolean;
311
- lastSignInAt: number | null;
312
312
  hasPassword?: boolean | undefined;
313
313
  ssoIdentities?: import("../db-entries/user-sso-identity.js").UserSsoIdentity[] | undefined;
314
314
  }>;
@@ -9,6 +9,7 @@ export declare enum VerificationType {
9
9
  EnterpriseSso = "EnterpriseSso",
10
10
  TOTP = "Totp",
11
11
  WebAuthn = "WebAuthn",
12
+ SignInWebAuthn = "SignInWebAuthn",
12
13
  BackupCode = "BackupCode",
13
14
  NewPasswordIdentity = "NewPasswordIdentity",
14
15
  OneTimeToken = "OneTimeToken"
@@ -10,6 +10,7 @@ export var VerificationType;
10
10
  VerificationType["EnterpriseSso"] = "EnterpriseSso";
11
11
  VerificationType["TOTP"] = "Totp";
12
12
  VerificationType["WebAuthn"] = "WebAuthn";
13
+ VerificationType["SignInWebAuthn"] = "SignInWebAuthn";
13
14
  VerificationType["BackupCode"] = "BackupCode";
14
15
  VerificationType["NewPasswordIdentity"] = "NewPasswordIdentity";
15
16
  VerificationType["OneTimeToken"] = "OneTimeToken";
@@ -1,11 +1,8 @@
1
1
  import { z } from 'zod';
2
2
  import { type BindWebAuthn } from '../interactions.js';
3
3
  import { VerificationType } from './verification-type.js';
4
- export type WebAuthnVerificationRecordData = {
4
+ type BaseWebAuthnVerificationRecordData = {
5
5
  id: string;
6
- type: VerificationType.WebAuthn;
7
- /** UserId is required for verifying or binding new TOTP */
8
- userId: string;
9
6
  verified: boolean;
10
7
  /** The challenge generated for the WebAuthn registration */
11
8
  registrationChallenge?: string;
@@ -15,10 +12,12 @@ export type WebAuthnVerificationRecordData = {
15
12
  authenticationChallenge?: string;
16
13
  registrationInfo?: BindWebAuthn;
17
14
  };
15
+ export type WebAuthnVerificationRecordData = BaseWebAuthnVerificationRecordData & {
16
+ type: VerificationType.WebAuthn;
17
+ userId: string;
18
+ };
18
19
  export declare const webAuthnVerificationRecordDataGuard: z.ZodObject<{
19
20
  id: z.ZodString;
20
- type: z.ZodLiteral<VerificationType.WebAuthn>;
21
- userId: z.ZodString;
22
21
  verified: z.ZodBoolean;
23
22
  registrationChallenge: z.ZodOptional<z.ZodString>;
24
23
  registrationRpId: z.ZodOptional<z.ZodString>;
@@ -51,6 +50,9 @@ export declare const webAuthnVerificationRecordDataGuard: z.ZodObject<{
51
50
  agent: string;
52
51
  name?: string | undefined;
53
52
  }>>;
53
+ } & {
54
+ type: z.ZodLiteral<VerificationType.WebAuthn>;
55
+ userId: z.ZodString;
54
56
  }, "strip", z.ZodTypeAny, {
55
57
  type: VerificationType.WebAuthn;
56
58
  id: string;
@@ -91,8 +93,6 @@ export declare const webAuthnVerificationRecordDataGuard: z.ZodObject<{
91
93
  export type SanitizedWebAuthnVerificationRecordData = Omit<WebAuthnVerificationRecordData, 'registrationInfo' | 'registrationChallenge' | 'registrationRpId' | 'authenticationChallenge'>;
92
94
  export declare const sanitizedWebAuthnVerificationRecordDataGuard: z.ZodObject<Omit<{
93
95
  id: z.ZodString;
94
- type: z.ZodLiteral<VerificationType.WebAuthn>;
95
- userId: z.ZodString;
96
96
  verified: z.ZodBoolean;
97
97
  registrationChallenge: z.ZodOptional<z.ZodString>;
98
98
  registrationRpId: z.ZodOptional<z.ZodString>;
@@ -125,6 +125,9 @@ export declare const sanitizedWebAuthnVerificationRecordDataGuard: z.ZodObject<O
125
125
  agent: string;
126
126
  name?: string | undefined;
127
127
  }>>;
128
+ } & {
129
+ type: z.ZodLiteral<VerificationType.WebAuthn>;
130
+ userId: z.ZodString;
128
131
  }, "registrationChallenge" | "registrationRpId" | "authenticationChallenge" | "registrationInfo">, "strip", z.ZodTypeAny, {
129
132
  type: VerificationType.WebAuthn;
130
133
  id: string;
@@ -136,3 +139,137 @@ export declare const sanitizedWebAuthnVerificationRecordDataGuard: z.ZodObject<O
136
139
  userId: string;
137
140
  verified: boolean;
138
141
  }>;
142
+ export type SignInWebAuthnVerificationRecordData = BaseWebAuthnVerificationRecordData & {
143
+ type: VerificationType.SignInWebAuthn;
144
+ userId?: string;
145
+ /** The rpId used when generating the authentication options */
146
+ authenticationRpId?: string;
147
+ };
148
+ export declare const signInWebAuthnVerificationRecordDataGuard: z.ZodObject<{
149
+ id: z.ZodString;
150
+ verified: z.ZodBoolean;
151
+ registrationChallenge: z.ZodOptional<z.ZodString>;
152
+ registrationRpId: z.ZodOptional<z.ZodString>;
153
+ authenticationChallenge: z.ZodOptional<z.ZodString>;
154
+ registrationInfo: z.ZodOptional<z.ZodObject<{
155
+ type: z.ZodLiteral<import("../../index.js").MfaFactor.WebAuthn>;
156
+ rpId: z.ZodString;
157
+ credentialId: z.ZodString;
158
+ publicKey: z.ZodString;
159
+ transports: z.ZodArray<z.ZodEnum<["usb", "nfc", "ble", "internal", "cable", "hybrid", "smart-card"]>, "many">;
160
+ counter: z.ZodNumber;
161
+ agent: z.ZodString;
162
+ name: z.ZodOptional<z.ZodString>;
163
+ }, "strip", z.ZodTypeAny, {
164
+ type: import("../../index.js").MfaFactor.WebAuthn;
165
+ rpId: string;
166
+ credentialId: string;
167
+ publicKey: string;
168
+ transports: ("usb" | "nfc" | "ble" | "internal" | "cable" | "hybrid" | "smart-card")[];
169
+ counter: number;
170
+ agent: string;
171
+ name?: string | undefined;
172
+ }, {
173
+ type: import("../../index.js").MfaFactor.WebAuthn;
174
+ rpId: string;
175
+ credentialId: string;
176
+ publicKey: string;
177
+ transports: ("usb" | "nfc" | "ble" | "internal" | "cable" | "hybrid" | "smart-card")[];
178
+ counter: number;
179
+ agent: string;
180
+ name?: string | undefined;
181
+ }>>;
182
+ } & {
183
+ type: z.ZodLiteral<VerificationType.SignInWebAuthn>;
184
+ userId: z.ZodOptional<z.ZodString>;
185
+ authenticationRpId: z.ZodOptional<z.ZodString>;
186
+ }, "strip", z.ZodTypeAny, {
187
+ type: VerificationType.SignInWebAuthn;
188
+ id: string;
189
+ verified: boolean;
190
+ userId?: string | undefined;
191
+ registrationChallenge?: string | undefined;
192
+ registrationRpId?: string | undefined;
193
+ authenticationChallenge?: string | undefined;
194
+ registrationInfo?: {
195
+ type: import("../../index.js").MfaFactor.WebAuthn;
196
+ rpId: string;
197
+ credentialId: string;
198
+ publicKey: string;
199
+ transports: ("usb" | "nfc" | "ble" | "internal" | "cable" | "hybrid" | "smart-card")[];
200
+ counter: number;
201
+ agent: string;
202
+ name?: string | undefined;
203
+ } | undefined;
204
+ authenticationRpId?: string | undefined;
205
+ }, {
206
+ type: VerificationType.SignInWebAuthn;
207
+ id: string;
208
+ verified: boolean;
209
+ userId?: string | undefined;
210
+ registrationChallenge?: string | undefined;
211
+ registrationRpId?: string | undefined;
212
+ authenticationChallenge?: string | undefined;
213
+ registrationInfo?: {
214
+ type: import("../../index.js").MfaFactor.WebAuthn;
215
+ rpId: string;
216
+ credentialId: string;
217
+ publicKey: string;
218
+ transports: ("usb" | "nfc" | "ble" | "internal" | "cable" | "hybrid" | "smart-card")[];
219
+ counter: number;
220
+ agent: string;
221
+ name?: string | undefined;
222
+ } | undefined;
223
+ authenticationRpId?: string | undefined;
224
+ }>;
225
+ export type SanitizedSignInWebAuthnVerificationRecordData = Omit<SignInWebAuthnVerificationRecordData, 'registrationInfo' | 'registrationChallenge' | 'registrationRpId' | 'authenticationChallenge' | 'authenticationRpId'>;
226
+ export declare const sanitizedSignInWebAuthnVerificationRecordDataGuard: z.ZodObject<Omit<{
227
+ id: z.ZodString;
228
+ verified: z.ZodBoolean;
229
+ registrationChallenge: z.ZodOptional<z.ZodString>;
230
+ registrationRpId: z.ZodOptional<z.ZodString>;
231
+ authenticationChallenge: z.ZodOptional<z.ZodString>;
232
+ registrationInfo: z.ZodOptional<z.ZodObject<{
233
+ type: z.ZodLiteral<import("../../index.js").MfaFactor.WebAuthn>;
234
+ rpId: z.ZodString;
235
+ credentialId: z.ZodString;
236
+ publicKey: z.ZodString;
237
+ transports: z.ZodArray<z.ZodEnum<["usb", "nfc", "ble", "internal", "cable", "hybrid", "smart-card"]>, "many">;
238
+ counter: z.ZodNumber;
239
+ agent: z.ZodString;
240
+ name: z.ZodOptional<z.ZodString>;
241
+ }, "strip", z.ZodTypeAny, {
242
+ type: import("../../index.js").MfaFactor.WebAuthn;
243
+ rpId: string;
244
+ credentialId: string;
245
+ publicKey: string;
246
+ transports: ("usb" | "nfc" | "ble" | "internal" | "cable" | "hybrid" | "smart-card")[];
247
+ counter: number;
248
+ agent: string;
249
+ name?: string | undefined;
250
+ }, {
251
+ type: import("../../index.js").MfaFactor.WebAuthn;
252
+ rpId: string;
253
+ credentialId: string;
254
+ publicKey: string;
255
+ transports: ("usb" | "nfc" | "ble" | "internal" | "cable" | "hybrid" | "smart-card")[];
256
+ counter: number;
257
+ agent: string;
258
+ name?: string | undefined;
259
+ }>>;
260
+ } & {
261
+ type: z.ZodLiteral<VerificationType.SignInWebAuthn>;
262
+ userId: z.ZodOptional<z.ZodString>;
263
+ authenticationRpId: z.ZodOptional<z.ZodString>;
264
+ }, "registrationChallenge" | "registrationRpId" | "authenticationChallenge" | "registrationInfo" | "authenticationRpId">, "strip", z.ZodTypeAny, {
265
+ type: VerificationType.SignInWebAuthn;
266
+ id: string;
267
+ verified: boolean;
268
+ userId?: string | undefined;
269
+ }, {
270
+ type: VerificationType.SignInWebAuthn;
271
+ id: string;
272
+ verified: boolean;
273
+ userId?: string | undefined;
274
+ }>;
275
+ export {};
@@ -1,19 +1,33 @@
1
1
  import { z } from 'zod';
2
2
  import { bindWebAuthnGuard } from '../interactions.js';
3
3
  import { VerificationType } from './verification-type.js';
4
- export const webAuthnVerificationRecordDataGuard = z.object({
4
+ const baseWebAuthnVerificationRecordDataGuard = z.object({
5
5
  id: z.string(),
6
- type: z.literal(VerificationType.WebAuthn),
7
- userId: z.string(),
8
6
  verified: z.boolean(),
9
7
  registrationChallenge: z.string().optional(),
10
8
  registrationRpId: z.string().optional(),
11
9
  authenticationChallenge: z.string().optional(),
12
10
  registrationInfo: bindWebAuthnGuard.optional(),
13
11
  });
12
+ export const webAuthnVerificationRecordDataGuard = baseWebAuthnVerificationRecordDataGuard.extend({
13
+ type: z.literal(VerificationType.WebAuthn),
14
+ userId: z.string(),
15
+ });
14
16
  export const sanitizedWebAuthnVerificationRecordDataGuard = webAuthnVerificationRecordDataGuard.omit({
15
17
  registrationInfo: true,
16
18
  registrationChallenge: true,
17
19
  registrationRpId: true,
18
20
  authenticationChallenge: true,
19
21
  });
22
+ export const signInWebAuthnVerificationRecordDataGuard = baseWebAuthnVerificationRecordDataGuard.extend({
23
+ type: z.literal(VerificationType.SignInWebAuthn),
24
+ userId: z.string().optional(),
25
+ authenticationRpId: z.string().optional(),
26
+ });
27
+ export const sanitizedSignInWebAuthnVerificationRecordDataGuard = signInWebAuthnVerificationRecordDataGuard.omit({
28
+ registrationInfo: true,
29
+ registrationChallenge: true,
30
+ registrationRpId: true,
31
+ authenticationChallenge: true,
32
+ authenticationRpId: true,
33
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logto/schemas",
3
- "version": "1.35.0",
3
+ "version": "1.37.0",
4
4
  "author": "Silverhand Inc. <contact@silverhand.io>",
5
5
  "license": "MPL-2.0",
6
6
  "type": "module",
@@ -66,11 +66,11 @@
66
66
  "@withtyped/server": "^0.14.0",
67
67
  "nanoid": "^5.0.9",
68
68
  "@logto/connector-kit": "^4.7.0",
69
- "@logto/core-kit": "^2.6.1",
70
- "@logto/phrases": "^1.24.0",
71
- "@logto/phrases-experience": "^1.12.0",
69
+ "@logto/core-kit": "^2.7.0",
72
70
  "@logto/language-kit": "^1.2.0",
73
- "@logto/shared": "^3.3.0"
71
+ "@logto/phrases": "^1.26.0",
72
+ "@logto/phrases-experience": "^1.12.1",
73
+ "@logto/shared": "^3.3.1"
74
74
  },
75
75
  "peerDependencies": {
76
76
  "zod": "3.24.3"
@@ -33,3 +33,10 @@ create index oidc_model_instances__model_name_payload_grant_id
33
33
  model_name,
34
34
  (payload->>'grantId')
35
35
  );
36
+
37
+ create index oidc_model_instances__expires_at
38
+ on oidc_model_instances (tenant_id, expires_at);
39
+
40
+ create index oidc_model_instances__session_payload_account_id_expires_at
41
+ on oidc_model_instances (tenant_id, (payload->>'accountId'), expires_at)
42
+ WHERE model_name = 'Session';
@@ -7,6 +7,7 @@ create table oidc_session_extensions (
7
7
  account_id varchar(12) not null
8
8
  references users (id) on update cascade on delete cascade,
9
9
  last_submission jsonb /* @use JsonObject */ not null default '{}'::jsonb,
10
+ client_id varchar(21) null,
10
11
  created_at timestamptz not null default(now()),
11
12
  updated_at timestamptz not null default(now()),
12
13
  primary key (tenant_id, session_uid)
@@ -23,6 +23,7 @@ create table sign_in_experiences (
23
23
  custom_ui_assets jsonb /* @use CustomUiAssets */,
24
24
  password_policy jsonb /* @use PartialPasswordPolicy */ not null default '{}'::jsonb,
25
25
  mfa jsonb /* @use Mfa */ not null default '{}'::jsonb,
26
+ adaptive_mfa jsonb /* @use AdaptiveMfa */ not null default '{}'::jsonb,
26
27
  single_sign_on_enabled boolean not null default false,
27
28
  support_email text,
28
29
  support_website_url text,
@@ -31,5 +32,6 @@ create table sign_in_experiences (
31
32
  sentinel_policy jsonb /* @use SentinelPolicy */ not null default '{}'::jsonb,
32
33
  email_blocklist_policy jsonb /* @use EmailBlocklistPolicy */ not null default '{}'::jsonb,
33
34
  forgot_password_methods jsonb /* @use ForgotPasswordMethods */ default '[]'::jsonb,
35
+ passkey_sign_in jsonb /* @use PasskeySignIn */ not null default '{}'::jsonb,
34
36
  primary key (tenant_id, id)
35
37
  );
@@ -0,0 +1,14 @@
1
+ /* init_order = 2 */
2
+
3
+ /** The last known geo coordinates per user for geo-velocity checks. */
4
+ create table user_geo_locations (
5
+ tenant_id varchar(21) not null
6
+ references tenants (id) on update cascade on delete cascade,
7
+ user_id varchar(12) not null
8
+ references users (id) on update cascade on delete cascade,
9
+ latitude numeric(9,6),
10
+ longitude numeric(9,6),
11
+ updated_at timestamptz not null default now(),
12
+ primary key (tenant_id, user_id),
13
+ check ((latitude is null) = (longitude is null))
14
+ );
@@ -0,0 +1,16 @@
1
+ /* init_order = 2 */
2
+
3
+ /** Tracks per-user sign-in countries for adaptive MFA rules. */
4
+ create table user_sign_in_countries (
5
+ tenant_id varchar(21) not null
6
+ references tenants (id) on update cascade on delete cascade,
7
+ user_id varchar(12) not null
8
+ references users (id) on update cascade on delete cascade,
9
+ /** ISO 3166-1 alpha-2 country code (2 chars), stored up to 16 chars for robustness. */
10
+ country varchar(16) not null,
11
+ last_sign_in_at timestamptz not null default(now()),
12
+ primary key (tenant_id, user_id, country)
13
+ );
14
+
15
+ create index user_sign_in_countries__tenant_user_last_sign_in_at
16
+ on user_sign_in_countries (tenant_id, user_id, last_sign_in_at desc);
package/tables/users.sql CHANGED
@@ -41,6 +41,9 @@ create unique index users__id
41
41
  create index users__name
42
42
  on users (tenant_id, name);
43
43
 
44
+ create index users_mfa_verifications_gin
45
+ on users using gin (mfa_verifications jsonb_path_ops);
46
+
44
47
  create trigger set_updated_at
45
48
  before update on users
46
49
  for each row