@logto/schemas 1.28.0 → 1.29.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 (93) hide show
  1. package/alterations/1.29.0-1748832174-add-webauthn-related-origins.ts +20 -0
  2. package/alterations/1.29.0-1749005587-user-sso-identities-table-add-updated-at-column.ts +31 -0
  3. package/alterations/1.29.0-1749026308-add-oidc-session-extension-table.ts +41 -0
  4. package/alterations/1.29.0-1749523818-add-custom-profile-fields.ts +58 -0
  5. package/alterations/1.29.0-1749724664-drop-sie-order-constraint-from-custom-profile-fields.ts +20 -0
  6. package/alterations/1.29.0-1750663091-change-user-password-encrypted-length.ts +18 -0
  7. package/alterations/1.29.0-1750744518-add-secrets-table.ts +50 -0
  8. package/alterations/1.29.0-1750744539-add-secret-connector-relations-table.ts +109 -0
  9. package/alterations-js/1.29.0-1748832174-add-webauthn-related-origins.js +16 -0
  10. package/alterations-js/1.29.0-1749005587-user-sso-identities-table-add-updated-at-column.js +25 -0
  11. package/alterations-js/1.29.0-1749026308-add-oidc-session-extension-table.js +33 -0
  12. package/alterations-js/1.29.0-1749523818-add-custom-profile-fields.js +52 -0
  13. package/alterations-js/1.29.0-1749724664-drop-sie-order-constraint-from-custom-profile-fields.js +16 -0
  14. package/alterations-js/1.29.0-1750663091-change-user-password-encrypted-length.js +14 -0
  15. package/alterations-js/1.29.0-1750744518-add-secrets-table.js +42 -0
  16. package/alterations-js/1.29.0-1750744539-add-secret-connector-relations-table.js +99 -0
  17. package/lib/db-entries/account-center.d.ts +4 -2
  18. package/lib/db-entries/account-center.js +5 -1
  19. package/lib/db-entries/custom-profile-field.d.ts +32 -0
  20. package/lib/db-entries/custom-profile-field.js +58 -0
  21. package/lib/db-entries/index.d.ts +4 -0
  22. package/lib/db-entries/index.js +4 -0
  23. package/lib/db-entries/oidc-session-extension.d.ts +24 -0
  24. package/lib/db-entries/oidc-session-extension.js +42 -0
  25. package/lib/db-entries/secret-connector-relation.d.ts +40 -0
  26. package/lib/db-entries/secret-connector-relation.js +49 -0
  27. package/lib/db-entries/secret.d.ts +44 -0
  28. package/lib/db-entries/secret.js +62 -0
  29. package/lib/db-entries/user-sso-identity.d.ts +5 -1
  30. package/lib/db-entries/user-sso-identity.js +4 -0
  31. package/lib/db-entries/user.js +2 -2
  32. package/lib/foundations/jsonb-types/account-centers.d.ts +5 -0
  33. package/lib/foundations/jsonb-types/account-centers.js +2 -0
  34. package/lib/foundations/jsonb-types/custom-profile-fields.d.ts +116 -0
  35. package/lib/foundations/jsonb-types/custom-profile-fields.js +36 -0
  36. package/lib/foundations/jsonb-types/index.d.ts +2 -1
  37. package/lib/foundations/jsonb-types/index.js +2 -1
  38. package/lib/foundations/jsonb-types/secrets.d.ts +9 -0
  39. package/lib/foundations/jsonb-types/secrets.js +10 -0
  40. package/lib/foundations/jsonb-types/users.d.ts +32 -0
  41. package/lib/foundations/jsonb-types/users.js +11 -10
  42. package/lib/types/consent.d.ts +4 -0
  43. package/lib/types/custom-profile-fields.d.ts +1310 -0
  44. package/lib/types/custom-profile-fields.js +123 -0
  45. package/lib/types/index.d.ts +2 -0
  46. package/lib/types/index.js +2 -0
  47. package/lib/types/interactions.d.ts +6 -0
  48. package/lib/types/interactions.js +1 -0
  49. package/lib/types/log/interaction.d.ts +2 -1
  50. package/lib/types/logto-config/index.d.ts +1104 -18
  51. package/lib/types/logto-config/jwt-customizer.d.ts +2396 -24
  52. package/lib/types/logto-config/jwt-customizer.js +50 -1
  53. package/lib/types/logto-config/oidc-provider.d.ts +6 -6
  54. package/lib/types/mfa.d.ts +10 -10
  55. package/lib/types/sign-in-experience.d.ts +2 -2
  56. package/lib/types/sso-connector.d.ts +23 -0
  57. package/lib/types/sso-connector.js +3 -0
  58. package/lib/types/tenant.d.ts +1 -0
  59. package/lib/types/tenant.js +1 -0
  60. package/lib/types/user.d.ts +11 -0
  61. package/lib/types/user.js +3 -0
  62. package/lib/types/verification-records/backup-code-verification.d.ts +29 -0
  63. package/lib/types/verification-records/backup-code-verification.js +9 -0
  64. package/lib/types/verification-records/code-verification.d.ts +89 -0
  65. package/lib/types/verification-records/code-verification.js +22 -0
  66. package/lib/types/verification-records/enterprise-sso-verification.d.ts +68 -0
  67. package/lib/types/verification-records/enterprise-sso-verification.js +10 -0
  68. package/lib/types/verification-records/index.d.ts +16 -0
  69. package/lib/types/verification-records/index.js +16 -0
  70. package/lib/types/verification-records/new-password-identity-verification.d.ts +54 -0
  71. package/lib/types/verification-records/new-password-identity-verification.js +16 -0
  72. package/lib/types/verification-records/one-time-token-verification.d.ts +55 -0
  73. package/lib/types/verification-records/one-time-token-verification.js +13 -0
  74. package/lib/types/verification-records/password-verification.d.ts +40 -0
  75. package/lib/types/verification-records/password-verification.js +9 -0
  76. package/lib/types/verification-records/social-verification.d.ts +106 -0
  77. package/lib/types/verification-records/social-verification.js +10 -0
  78. package/lib/types/verification-records/totp-verification.d.ts +29 -0
  79. package/lib/types/verification-records/totp-verification.js +9 -0
  80. package/lib/types/verification-records/web-authn-verification.d.ts +80 -0
  81. package/lib/types/verification-records/web-authn-verification.js +12 -0
  82. package/package.json +1 -1
  83. package/tables/account_centers.sql +1 -0
  84. package/tables/connectors.sql +2 -0
  85. package/tables/custom_profile_fields.sql +31 -0
  86. package/tables/oidc_model_instances.sql +2 -0
  87. package/tables/oidc_session_extensions.sql +18 -0
  88. package/tables/secret_connector_relations.sql +78 -0
  89. package/tables/secrets.sql +26 -0
  90. package/tables/user_sso_identities.sql +8 -0
  91. package/tables/users.sql +1 -1
  92. /package/lib/{foundations/jsonb-types/verification-records.d.ts → types/verification-records/verification-type.d.ts} +0 -0
  93. /package/lib/{foundations/jsonb-types/verification-records.js → types/verification-records/verification-type.js} +0 -0
@@ -0,0 +1,54 @@
1
+ /**
2
+ * @deprecated
3
+ * This verification record type is deprecated.
4
+ * DO NOT use this verification record type in new code.
5
+ */
6
+ import { z } from 'zod';
7
+ import { UsersPasswordEncryptionMethod } from '../../db-entries/custom-types.js';
8
+ import { type InteractionIdentifier } from '../interactions.js';
9
+ import { VerificationType } from './verification-type.js';
10
+ export type NewPasswordIdentityVerificationRecordData = {
11
+ id: string;
12
+ type: VerificationType.NewPasswordIdentity;
13
+ /**
14
+ * For now we only support username identifier for new password identity registration.
15
+ * For email and phone new identity registration, a `CodeVerification` record is required.
16
+ */
17
+ identifier: InteractionIdentifier;
18
+ passwordEncrypted?: string;
19
+ passwordEncryptionMethod?: UsersPasswordEncryptionMethod.Argon2i;
20
+ };
21
+ export declare const newPasswordIdentityVerificationRecordDataGuard: z.ZodObject<{
22
+ id: z.ZodString;
23
+ type: z.ZodLiteral<VerificationType.NewPasswordIdentity>;
24
+ identifier: z.ZodObject<{
25
+ type: z.ZodNativeEnum<typeof import("../../index.js").SignInIdentifier>;
26
+ value: z.ZodString;
27
+ }, "strip", z.ZodTypeAny, {
28
+ value: string;
29
+ type: import("../../index.js").SignInIdentifier;
30
+ }, {
31
+ value: string;
32
+ type: import("../../index.js").SignInIdentifier;
33
+ }>;
34
+ passwordEncrypted: z.ZodOptional<z.ZodString>;
35
+ passwordEncryptionMethod: z.ZodOptional<z.ZodLiteral<UsersPasswordEncryptionMethod.Argon2i>>;
36
+ }, "strip", z.ZodTypeAny, {
37
+ type: VerificationType.NewPasswordIdentity;
38
+ id: string;
39
+ identifier: {
40
+ value: string;
41
+ type: import("../../index.js").SignInIdentifier;
42
+ };
43
+ passwordEncrypted?: string | undefined;
44
+ passwordEncryptionMethod?: UsersPasswordEncryptionMethod.Argon2i | undefined;
45
+ }, {
46
+ type: VerificationType.NewPasswordIdentity;
47
+ id: string;
48
+ identifier: {
49
+ value: string;
50
+ type: import("../../index.js").SignInIdentifier;
51
+ };
52
+ passwordEncrypted?: string | undefined;
53
+ passwordEncryptionMethod?: UsersPasswordEncryptionMethod.Argon2i | undefined;
54
+ }>;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @deprecated
3
+ * This verification record type is deprecated.
4
+ * DO NOT use this verification record type in new code.
5
+ */
6
+ import { z } from 'zod';
7
+ import { UsersPasswordEncryptionMethod } from '../../db-entries/custom-types.js';
8
+ import { interactionIdentifierGuard } from '../interactions.js';
9
+ import { VerificationType } from './verification-type.js';
10
+ export const newPasswordIdentityVerificationRecordDataGuard = z.object({
11
+ id: z.string(),
12
+ type: z.literal(VerificationType.NewPasswordIdentity),
13
+ identifier: interactionIdentifierGuard,
14
+ passwordEncrypted: z.string().optional(),
15
+ passwordEncryptionMethod: z.literal(UsersPasswordEncryptionMethod.Argon2i).optional(),
16
+ });
@@ -0,0 +1,55 @@
1
+ import { z } from 'zod';
2
+ import { type OneTimeTokenContext, SignInIdentifier } from '../../foundations/index.js';
3
+ import { type InteractionIdentifier } from '../interactions.js';
4
+ import { VerificationType } from './verification-type.js';
5
+ export type OneTimeTokenVerificationRecordData = {
6
+ id: string;
7
+ type: VerificationType.OneTimeToken;
8
+ identifier: InteractionIdentifier<SignInIdentifier.Email>;
9
+ verified: boolean;
10
+ oneTimeTokenContext?: OneTimeTokenContext;
11
+ };
12
+ export declare const oneTimeTokenVerificationRecordDataGuard: z.ZodObject<{
13
+ id: z.ZodString;
14
+ type: z.ZodLiteral<VerificationType.OneTimeToken>;
15
+ verified: z.ZodBoolean;
16
+ identifier: z.ZodObject<{
17
+ type: z.ZodLiteral<SignInIdentifier.Email>;
18
+ value: z.ZodString;
19
+ }, "strip", z.ZodTypeAny, {
20
+ value: string;
21
+ type: SignInIdentifier.Email;
22
+ }, {
23
+ value: string;
24
+ type: SignInIdentifier.Email;
25
+ }>;
26
+ oneTimeTokenContext: z.ZodOptional<z.ZodObject<{
27
+ jitOrganizationIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
28
+ }, "strip", z.ZodTypeAny, {
29
+ jitOrganizationIds?: string[] | undefined;
30
+ }, {
31
+ jitOrganizationIds?: string[] | undefined;
32
+ }>>;
33
+ }, "strip", z.ZodTypeAny, {
34
+ type: VerificationType.OneTimeToken;
35
+ id: string;
36
+ identifier: {
37
+ value: string;
38
+ type: SignInIdentifier.Email;
39
+ };
40
+ verified: boolean;
41
+ oneTimeTokenContext?: {
42
+ jitOrganizationIds?: string[] | undefined;
43
+ } | undefined;
44
+ }, {
45
+ type: VerificationType.OneTimeToken;
46
+ id: string;
47
+ identifier: {
48
+ value: string;
49
+ type: SignInIdentifier.Email;
50
+ };
51
+ verified: boolean;
52
+ oneTimeTokenContext?: {
53
+ jitOrganizationIds?: string[] | undefined;
54
+ } | undefined;
55
+ }>;
@@ -0,0 +1,13 @@
1
+ import { z } from 'zod';
2
+ import { oneTimeTokenContextGuard, SignInIdentifier, } from '../../foundations/index.js';
3
+ import { VerificationType } from './verification-type.js';
4
+ export const oneTimeTokenVerificationRecordDataGuard = z.object({
5
+ id: z.string(),
6
+ type: z.literal(VerificationType.OneTimeToken),
7
+ verified: z.boolean(),
8
+ identifier: z.object({
9
+ type: z.literal(SignInIdentifier.Email),
10
+ value: z.string(),
11
+ }),
12
+ oneTimeTokenContext: oneTimeTokenContextGuard.optional(),
13
+ });
@@ -0,0 +1,40 @@
1
+ import { z } from 'zod';
2
+ import { type VerificationIdentifier } from '../interactions.js';
3
+ import { VerificationType } from './verification-type.js';
4
+ export type PasswordVerificationRecordData = {
5
+ id: string;
6
+ type: VerificationType.Password;
7
+ identifier: VerificationIdentifier;
8
+ verified: boolean;
9
+ };
10
+ export declare const passwordVerificationRecordDataGuard: z.ZodObject<{
11
+ id: z.ZodString;
12
+ type: z.ZodLiteral<VerificationType.Password>;
13
+ identifier: z.ZodObject<{
14
+ type: z.ZodUnion<[z.ZodNativeEnum<typeof import("../../index.js").SignInIdentifier>, z.ZodNativeEnum<typeof import("../../index.js").AdditionalIdentifier>]>;
15
+ value: z.ZodString;
16
+ }, "strip", z.ZodTypeAny, {
17
+ value: string;
18
+ type: import("../../index.js").SignInIdentifier | import("../../index.js").AdditionalIdentifier;
19
+ }, {
20
+ value: string;
21
+ type: import("../../index.js").SignInIdentifier | import("../../index.js").AdditionalIdentifier;
22
+ }>;
23
+ verified: z.ZodBoolean;
24
+ }, "strip", z.ZodTypeAny, {
25
+ type: VerificationType.Password;
26
+ id: string;
27
+ identifier: {
28
+ value: string;
29
+ type: import("../../index.js").SignInIdentifier | import("../../index.js").AdditionalIdentifier;
30
+ };
31
+ verified: boolean;
32
+ }, {
33
+ type: VerificationType.Password;
34
+ id: string;
35
+ identifier: {
36
+ value: string;
37
+ type: import("../../index.js").SignInIdentifier | import("../../index.js").AdditionalIdentifier;
38
+ };
39
+ verified: boolean;
40
+ }>;
@@ -0,0 +1,9 @@
1
+ import { z } from 'zod';
2
+ import { verificationIdentifierGuard } from '../interactions.js';
3
+ import { VerificationType } from './verification-type.js';
4
+ export const passwordVerificationRecordDataGuard = z.object({
5
+ id: z.string(),
6
+ type: z.literal(VerificationType.Password),
7
+ identifier: verificationIdentifierGuard,
8
+ verified: z.boolean(),
9
+ });
@@ -0,0 +1,106 @@
1
+ import { type ConnectorSession, type SocialUserInfo } from '@logto/connector-kit';
2
+ import { z } from 'zod';
3
+ import { VerificationType } from './verification-type.js';
4
+ /** The JSON data type for the SocialVerification record stored in the interaction storage */
5
+ export type SocialVerificationRecordData = {
6
+ id: string;
7
+ connectorId: string;
8
+ type: VerificationType.Social;
9
+ /**
10
+ * The social identity returned by the connector.
11
+ */
12
+ socialUserInfo?: SocialUserInfo;
13
+ /**
14
+ * The connector session result
15
+ */
16
+ connectorSession?: ConnectorSession;
17
+ };
18
+ export declare const socialVerificationRecordDataGuard: z.ZodObject<{
19
+ id: z.ZodString;
20
+ connectorId: z.ZodString;
21
+ type: z.ZodLiteral<VerificationType.Social>;
22
+ socialUserInfo: z.ZodOptional<z.ZodObject<{
23
+ id: z.ZodString;
24
+ email: z.ZodOptional<z.ZodString>;
25
+ phone: z.ZodOptional<z.ZodString>;
26
+ name: z.ZodOptional<z.ZodString>;
27
+ avatar: z.ZodOptional<z.ZodString>;
28
+ rawData: z.ZodOptional<z.ZodType<import("@withtyped/server").Json, z.ZodTypeDef, import("@withtyped/server").Json>>;
29
+ }, "strip", z.ZodTypeAny, {
30
+ id: string;
31
+ name?: string | undefined;
32
+ email?: string | undefined;
33
+ phone?: string | undefined;
34
+ avatar?: string | undefined;
35
+ rawData?: import("@withtyped/server").Json | undefined;
36
+ }, {
37
+ id: string;
38
+ name?: string | undefined;
39
+ email?: string | undefined;
40
+ phone?: string | undefined;
41
+ avatar?: string | undefined;
42
+ rawData?: import("@withtyped/server").Json | undefined;
43
+ }>>;
44
+ connectorSession: z.ZodOptional<z.ZodObject<{
45
+ nonce: z.ZodOptional<z.ZodString>;
46
+ redirectUri: z.ZodOptional<z.ZodString>;
47
+ connectorId: z.ZodOptional<z.ZodString>;
48
+ connectorFactoryId: z.ZodOptional<z.ZodString>;
49
+ jti: z.ZodOptional<z.ZodString>;
50
+ state: z.ZodOptional<z.ZodString>;
51
+ }, "strip", z.ZodUnknown, z.objectOutputType<{
52
+ nonce: z.ZodOptional<z.ZodString>;
53
+ redirectUri: z.ZodOptional<z.ZodString>;
54
+ connectorId: z.ZodOptional<z.ZodString>;
55
+ connectorFactoryId: z.ZodOptional<z.ZodString>;
56
+ jti: z.ZodOptional<z.ZodString>;
57
+ state: z.ZodOptional<z.ZodString>;
58
+ }, z.ZodUnknown, "strip">, z.objectInputType<{
59
+ nonce: z.ZodOptional<z.ZodString>;
60
+ redirectUri: z.ZodOptional<z.ZodString>;
61
+ connectorId: z.ZodOptional<z.ZodString>;
62
+ connectorFactoryId: z.ZodOptional<z.ZodString>;
63
+ jti: z.ZodOptional<z.ZodString>;
64
+ state: z.ZodOptional<z.ZodString>;
65
+ }, z.ZodUnknown, "strip">>>;
66
+ }, "strip", z.ZodTypeAny, {
67
+ type: VerificationType.Social;
68
+ id: string;
69
+ connectorId: string;
70
+ socialUserInfo?: {
71
+ id: string;
72
+ name?: string | undefined;
73
+ email?: string | undefined;
74
+ phone?: string | undefined;
75
+ avatar?: string | undefined;
76
+ rawData?: import("@withtyped/server").Json | undefined;
77
+ } | undefined;
78
+ connectorSession?: z.objectOutputType<{
79
+ nonce: z.ZodOptional<z.ZodString>;
80
+ redirectUri: z.ZodOptional<z.ZodString>;
81
+ connectorId: z.ZodOptional<z.ZodString>;
82
+ connectorFactoryId: z.ZodOptional<z.ZodString>;
83
+ jti: z.ZodOptional<z.ZodString>;
84
+ state: z.ZodOptional<z.ZodString>;
85
+ }, z.ZodUnknown, "strip"> | undefined;
86
+ }, {
87
+ type: VerificationType.Social;
88
+ id: string;
89
+ connectorId: string;
90
+ socialUserInfo?: {
91
+ id: string;
92
+ name?: string | undefined;
93
+ email?: string | undefined;
94
+ phone?: string | undefined;
95
+ avatar?: string | undefined;
96
+ rawData?: import("@withtyped/server").Json | undefined;
97
+ } | undefined;
98
+ connectorSession?: z.objectInputType<{
99
+ nonce: z.ZodOptional<z.ZodString>;
100
+ redirectUri: z.ZodOptional<z.ZodString>;
101
+ connectorId: z.ZodOptional<z.ZodString>;
102
+ connectorFactoryId: z.ZodOptional<z.ZodString>;
103
+ jti: z.ZodOptional<z.ZodString>;
104
+ state: z.ZodOptional<z.ZodString>;
105
+ }, z.ZodUnknown, "strip"> | undefined;
106
+ }>;
@@ -0,0 +1,10 @@
1
+ import { connectorSessionGuard, socialUserInfoGuard, } from '@logto/connector-kit';
2
+ import { z } from 'zod';
3
+ import { VerificationType } from './verification-type.js';
4
+ export const socialVerificationRecordDataGuard = z.object({
5
+ id: z.string(),
6
+ connectorId: z.string(),
7
+ type: z.literal(VerificationType.Social),
8
+ socialUserInfo: socialUserInfoGuard.optional(),
9
+ connectorSession: connectorSessionGuard.optional(),
10
+ });
@@ -0,0 +1,29 @@
1
+ import { z } from 'zod';
2
+ import { VerificationType } from './verification-type.js';
3
+ export type TotpVerificationRecordData = {
4
+ id: string;
5
+ type: VerificationType.TOTP;
6
+ /** UserId is required for verifying or binding new TOTP */
7
+ userId: string;
8
+ secret?: string;
9
+ verified: boolean;
10
+ };
11
+ export declare const totpVerificationRecordDataGuard: z.ZodObject<{
12
+ id: z.ZodString;
13
+ type: z.ZodLiteral<VerificationType.TOTP>;
14
+ userId: z.ZodString;
15
+ secret: z.ZodOptional<z.ZodString>;
16
+ verified: z.ZodBoolean;
17
+ }, "strip", z.ZodTypeAny, {
18
+ type: VerificationType.TOTP;
19
+ id: string;
20
+ userId: string;
21
+ verified: boolean;
22
+ secret?: string | undefined;
23
+ }, {
24
+ type: VerificationType.TOTP;
25
+ id: string;
26
+ userId: string;
27
+ verified: boolean;
28
+ secret?: string | undefined;
29
+ }>;
@@ -0,0 +1,9 @@
1
+ import { z } from 'zod';
2
+ import { VerificationType } from './verification-type.js';
3
+ export const totpVerificationRecordDataGuard = z.object({
4
+ id: z.string(),
5
+ type: z.literal(VerificationType.TOTP),
6
+ userId: z.string(),
7
+ secret: z.string().optional(),
8
+ verified: z.boolean(),
9
+ });
@@ -0,0 +1,80 @@
1
+ import { z } from 'zod';
2
+ import { type BindWebAuthn } from '../interactions.js';
3
+ import { VerificationType } from './verification-type.js';
4
+ export type WebAuthnVerificationRecordData = {
5
+ id: string;
6
+ type: VerificationType.WebAuthn;
7
+ /** UserId is required for verifying or binding new TOTP */
8
+ userId: string;
9
+ verified: boolean;
10
+ /** The challenge generated for the WebAuthn registration */
11
+ registrationChallenge?: string;
12
+ /** The challenge generated for the WebAuthn authentication */
13
+ authenticationChallenge?: string;
14
+ registrationInfo?: BindWebAuthn;
15
+ };
16
+ export declare const webAuthnVerificationRecordDataGuard: z.ZodObject<{
17
+ id: z.ZodString;
18
+ type: z.ZodLiteral<VerificationType.WebAuthn>;
19
+ userId: z.ZodString;
20
+ verified: z.ZodBoolean;
21
+ registrationChallenge: z.ZodOptional<z.ZodString>;
22
+ authenticationChallenge: z.ZodOptional<z.ZodString>;
23
+ registrationInfo: z.ZodOptional<z.ZodObject<{
24
+ type: z.ZodLiteral<import("../../index.js").MfaFactor.WebAuthn>;
25
+ credentialId: z.ZodString;
26
+ publicKey: z.ZodString;
27
+ transports: z.ZodArray<z.ZodEnum<["usb", "nfc", "ble", "internal", "cable", "hybrid", "smart-card"]>, "many">;
28
+ counter: z.ZodNumber;
29
+ agent: z.ZodString;
30
+ name: z.ZodOptional<z.ZodString>;
31
+ }, "strip", z.ZodTypeAny, {
32
+ type: import("../../index.js").MfaFactor.WebAuthn;
33
+ credentialId: string;
34
+ publicKey: string;
35
+ transports: ("usb" | "nfc" | "ble" | "internal" | "cable" | "hybrid" | "smart-card")[];
36
+ counter: number;
37
+ agent: string;
38
+ name?: string | undefined;
39
+ }, {
40
+ type: import("../../index.js").MfaFactor.WebAuthn;
41
+ credentialId: string;
42
+ publicKey: string;
43
+ transports: ("usb" | "nfc" | "ble" | "internal" | "cable" | "hybrid" | "smart-card")[];
44
+ counter: number;
45
+ agent: string;
46
+ name?: string | undefined;
47
+ }>>;
48
+ }, "strip", z.ZodTypeAny, {
49
+ type: VerificationType.WebAuthn;
50
+ id: string;
51
+ userId: string;
52
+ verified: boolean;
53
+ registrationChallenge?: string | undefined;
54
+ authenticationChallenge?: string | undefined;
55
+ registrationInfo?: {
56
+ type: import("../../index.js").MfaFactor.WebAuthn;
57
+ credentialId: string;
58
+ publicKey: string;
59
+ transports: ("usb" | "nfc" | "ble" | "internal" | "cable" | "hybrid" | "smart-card")[];
60
+ counter: number;
61
+ agent: string;
62
+ name?: string | undefined;
63
+ } | undefined;
64
+ }, {
65
+ type: VerificationType.WebAuthn;
66
+ id: string;
67
+ userId: string;
68
+ verified: boolean;
69
+ registrationChallenge?: string | undefined;
70
+ authenticationChallenge?: string | undefined;
71
+ registrationInfo?: {
72
+ type: import("../../index.js").MfaFactor.WebAuthn;
73
+ credentialId: string;
74
+ publicKey: string;
75
+ transports: ("usb" | "nfc" | "ble" | "internal" | "cable" | "hybrid" | "smart-card")[];
76
+ counter: number;
77
+ agent: string;
78
+ name?: string | undefined;
79
+ } | undefined;
80
+ }>;
@@ -0,0 +1,12 @@
1
+ import { z } from 'zod';
2
+ import { bindWebAuthnGuard } from '../interactions.js';
3
+ import { VerificationType } from './verification-type.js';
4
+ export const webAuthnVerificationRecordDataGuard = z.object({
5
+ id: z.string(),
6
+ type: z.literal(VerificationType.WebAuthn),
7
+ userId: z.string(),
8
+ verified: z.boolean(),
9
+ registrationChallenge: z.string().optional(),
10
+ authenticationChallenge: z.string().optional(),
11
+ registrationInfo: bindWebAuthnGuard.optional(),
12
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logto/schemas",
3
- "version": "1.28.0",
3
+ "version": "1.29.0",
4
4
  "author": "Silverhand Inc. <contact@silverhand.io>",
5
5
  "license": "MPL-2.0",
6
6
  "type": "module",
@@ -6,5 +6,6 @@ create table account_centers (
6
6
  enabled boolean not null default false,
7
7
  /** Control each fields */
8
8
  fields jsonb /* @use AccountCenterFieldControl */ not null default '{}'::jsonb,
9
+ webauthn_related_origins jsonb /* @use WebauthnRelatedOrigins */ not null default '[]'::jsonb,
9
10
  primary key (tenant_id, id)
10
11
  );
@@ -1,3 +1,5 @@
1
+ /* init_order = 1 */
2
+
1
3
  create table connectors (
2
4
  tenant_id varchar(21) not null
3
5
  references tenants (id) on update cascade on delete cascade,
@@ -0,0 +1,31 @@
1
+ create table custom_profile_fields (
2
+ tenant_id varchar(21) not null
3
+ references tenants (id) on update cascade on delete cascade,
4
+ id varchar(21) not null,
5
+ name varchar(128) not null,
6
+ type varchar(128) not null /* @use CustomProfileFieldType */,
7
+ label varchar(128) not null default '',
8
+ description varchar(256),
9
+ required boolean not null default false,
10
+ config jsonb /* @use CustomProfileFieldConfig */ not null default '{}'::jsonb,
11
+ created_at timestamptz not null default(now()),
12
+ sie_order int2 not null default 0,
13
+ primary key (id),
14
+ constraint custom_profile_fields__name
15
+ unique (tenant_id, name)
16
+ );
17
+
18
+ create or replace function custom_profile_fields__increment_sie_order() returns trigger as
19
+ $$ begin
20
+ new.sie_order = (
21
+ select coalesce(max(sie_order), 0)
22
+ from custom_profile_fields
23
+ where tenant_id = (
24
+ select id from tenants where db_user = current_user
25
+ )
26
+ ) + 1;
27
+ return new;
28
+ end; $$ language plpgsql;
29
+
30
+ create trigger custom_profile_fields__increment_sie_order before insert on custom_profile_fields
31
+ for each row execute procedure custom_profile_fields__increment_sie_order();
@@ -1,3 +1,5 @@
1
+ /* init_order = 1 */
2
+
1
3
  create table oidc_model_instances (
2
4
  tenant_id varchar(21) not null
3
5
  references tenants (id) on update cascade on delete cascade,
@@ -0,0 +1,18 @@
1
+ /* init_order = 2 */
2
+
3
+ create table oidc_session_extensions (
4
+ tenant_id varchar(21) not null
5
+ references tenants (id) on update cascade on delete cascade,
6
+ session_uid varchar(128) not null,
7
+ account_id varchar(12) not null
8
+ references users (id) on update cascade on delete cascade,
9
+ last_submission jsonb /* @use JsonObject */ not null default '{}'::jsonb,
10
+ created_at timestamptz not null default(now()),
11
+ updated_at timestamptz not null default(now()),
12
+ primary key (tenant_id, session_uid)
13
+ );
14
+
15
+ create trigger set_updated_at
16
+ before update on oidc_session_extensions
17
+ for each row
18
+ execute procedure set_updated_at();
@@ -0,0 +1,78 @@
1
+ /* init_order = 3 */
2
+
3
+ create table secret_connector_relations (
4
+ tenant_id varchar(21) not null
5
+ references tenants (id) on update cascade on delete cascade,
6
+ secret_id varchar(21) not null
7
+ references secrets (id) on update cascade on delete cascade,
8
+ /** Social connector ID foreign reference. Only present for secrets that store social connector tokens. Note: avoid directly cascading deletes here, need to delete the secrets first.*/
9
+ connector_id varchar(128)
10
+ references connectors (id) on update cascade,
11
+ /** SSO connector ID foreign reference. Only present for secrets that store SSO connector tokens. Note: avoid directly cascading deletes here, need to delete the secrets first.*/
12
+ sso_connector_id varchar(128)
13
+ references sso_connectors (id) on update cascade,
14
+ /** The target of the social connector. e.g. 'github', 'google', etc. */
15
+ social_connector_target varchar(256),
16
+ /** User social identity ID foreign reference. Only present for secrets that store social identity tokens. */
17
+ social_identity_id varchar(128),
18
+ /** User sso connector issuer. Only present for secrets that store SSO connector tokens. */
19
+ sso_connector_issuer varchar(256),
20
+ /** User SSO identity ID. Only present for secrets that store SSO identity tokens. */
21
+ sso_identity_id varchar(128),
22
+ primary key (tenant_id, secret_id),
23
+ /** Ensures that each social identity is associated with only one secret. */
24
+ constraint secret_connector_relations__target__social_identity_id
25
+ unique (tenant_id, social_connector_target, social_identity_id),
26
+ /** Ensures that each SSO identity is associated with only one secret. */
27
+ foreign key (tenant_id, sso_connector_issuer, sso_identity_id)
28
+ references user_sso_identities (tenant_id, issuer, identity_id) on update cascade,
29
+ /** Ensure that each secret is associated with a social connector or SSO connector, but not both at the same time. */
30
+ constraint secret_connector_relations__connector_id__sso_connector_id
31
+ check (
32
+ (
33
+ connector_id is not null and social_connector_target is not null and social_identity_id is not null and
34
+ sso_connector_id is null and sso_identity_id is null
35
+ ) or (
36
+ connector_id is null and social_connector_target is null and social_identity_id is null and
37
+ sso_connector_id is not null and sso_identity_id is not null
38
+ )
39
+ )
40
+ );
41
+
42
+
43
+ /** Trigger function to delete secrets when the social connector is deleted. */
44
+ create function delete_secrets_on_social_connector_delete()
45
+ returns trigger as $$
46
+ begin
47
+ delete from secrets
48
+ where id in (
49
+ select secret_id from secret_connector_relations
50
+ where tenant_id = old.tenant_id and connector_id = old.id
51
+ );
52
+ return old;
53
+ end;
54
+ $$ language plpgsql;
55
+
56
+ create trigger delete_secrets_before_social_connector_delete
57
+ before delete on connectors
58
+ for each row
59
+ execute procedure delete_secrets_on_social_connector_delete();
60
+
61
+
62
+ /** Trigger function to delete secrets when the SSO connector is deleted. */
63
+ create function delete_secrets_on_sso_connector_delete()
64
+ returns trigger as $$
65
+ begin
66
+ delete from secrets
67
+ where id in (
68
+ select secret_id from secret_connector_relations
69
+ where tenant_id = old.tenant_id and sso_connector_id = old.id
70
+ );
71
+ return old;
72
+ end;
73
+ $$ language plpgsql;
74
+
75
+ create trigger delete_secrets_before_sso_connector_delete
76
+ before delete on sso_connectors
77
+ for each row
78
+ execute procedure delete_secrets_on_sso_connector_delete();
@@ -0,0 +1,26 @@
1
+ /* init_order = 2 */
2
+ create table secrets (
3
+ tenant_id varchar(21) not null
4
+ references tenants (id) on update cascade on delete cascade,
5
+ id varchar(21) not null primary key,
6
+ user_id varchar(21) not null
7
+ references users (id) on update cascade on delete cascade,
8
+ type varchar(256) /* @use SecretType */ not null,
9
+ /** Encrypted data encryption key (DEK) for the secret. */
10
+ encrypted_dek bytea not null,
11
+ /** Initialization vector for the secret encryption. */
12
+ iv bytea not null,
13
+ /** Authentication tag for the secret encryption. */
14
+ auth_tag bytea not null,
15
+ /** The encrypted secret data. e.g. { access_token, refresh_token } */
16
+ ciphertext bytea not null,
17
+ /** The metadata associated with the secret. */
18
+ metadata jsonb /* @use JsonObject */ not null default '{}'::jsonb,
19
+ created_at timestamptz not null default(now()),
20
+ updated_at timestamptz not null default(now())
21
+ );
22
+
23
+ create trigger set_updated_at
24
+ before update on secrets
25
+ for each row
26
+ execute procedure set_updated_at();
@@ -10,7 +10,9 @@ create table user_sso_identities (
10
10
  /** Provider user identity id*/
11
11
  identity_id varchar(128) not null,
12
12
  detail jsonb /* @use JsonObject */ not null default '{}'::jsonb,
13
+ /** Known issue: created_at uses timestamp instead of timestamptz */
13
14
  created_at timestamp not null default(now()),
15
+ updated_at timestamptz not null default(now()),
14
16
  sso_connector_id
15
17
  varchar(128) not null
16
18
  references sso_connectors (id) on update cascade on delete cascade,
@@ -18,3 +20,9 @@ create table user_sso_identities (
18
20
  constraint user_sso_identities__issuer__identity_id
19
21
  unique (tenant_id, issuer, identity_id)
20
22
  );
23
+
24
+
25
+ create trigger set_updated_at
26
+ before update on user_sso_identities
27
+ for each row
28
+ execute procedure set_updated_at();
package/tables/users.sql CHANGED
@@ -9,7 +9,7 @@ create table users (
9
9
  username varchar(128),
10
10
  primary_email varchar(128),
11
11
  primary_phone varchar(128),
12
- password_encrypted varchar(128),
12
+ password_encrypted varchar(256),
13
13
  password_encryption_method users_password_encryption_method,
14
14
  name varchar(128),
15
15
  /** The URL that points to the user's profile picture. Mapped to OpenID Connect's `picture` claim. */