@logto/schemas 1.29.0 → 1.30.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.
- package/alterations/1.30.0-1750744685-add-triggers-to-delete-secrets-on-social-identities-deletion.ts +81 -0
- package/alterations/1.30.0-1750748516-add-enable-token-storage-column-to-connectors-table.ts +20 -0
- package/alterations/1.30.0-1751255436-split-secret-connector-relatioins-table.ts +359 -0
- package/alterations/1.30.0-1751337183-add-require-mfa-on-sign-in-to-users.ts +20 -0
- package/alterations/1.30.0-1751400000-move-require-mfa-on-sign-in-to-logto-config.ts +21 -0
- package/alterations/1.30.0-1751529530-add-enable-token-storage-column-to-sso-connectors-table.ts +20 -0
- package/alterations/1.30.0-1752630302-alterate-enable-column-default-value-in-account-centers-table.ts +20 -0
- package/alterations/1.30.0-1753669579-add-organization-user-relations-foreign-key.ts +46 -0
- package/alterations-js/1.30.0-1750744685-add-triggers-to-delete-secrets-on-social-identities-deletion.js +76 -0
- package/alterations-js/1.30.0-1750748516-add-enable-token-storage-column-to-connectors-table.js +16 -0
- package/alterations-js/1.30.0-1751255436-split-secret-connector-relatioins-table.js +338 -0
- package/alterations-js/1.30.0-1751337183-add-require-mfa-on-sign-in-to-users.js +16 -0
- package/alterations-js/1.30.0-1751400000-move-require-mfa-on-sign-in-to-logto-config.js +17 -0
- package/alterations-js/1.30.0-1751529530-add-enable-token-storage-column-to-sso-connectors-table.js +16 -0
- package/alterations-js/1.30.0-1752630302-alterate-enable-column-default-value-in-account-centers-table.js +16 -0
- package/alterations-js/1.30.0-1753669579-add-organization-user-relations-foreign-key.js +38 -0
- package/lib/consts/oidc.d.ts +9 -1
- package/lib/consts/oidc.js +5 -0
- package/lib/db-entries/connector.d.ts +5 -1
- package/lib/db-entries/connector.js +4 -0
- package/lib/db-entries/index.d.ts +2 -1
- package/lib/db-entries/index.js +2 -1
- package/lib/db-entries/secret-enterprise-sso-connector-relation.d.ts +28 -0
- package/lib/db-entries/secret-enterprise-sso-connector-relation.js +37 -0
- package/lib/db-entries/secret-social-connector-relation.d.ts +28 -0
- package/lib/db-entries/secret-social-connector-relation.js +37 -0
- package/lib/db-entries/secret.d.ts +9 -9
- package/lib/db-entries/secret.js +9 -9
- package/lib/db-entries/sso-connector.d.ts +5 -1
- package/lib/db-entries/sso-connector.js +4 -0
- package/lib/foundations/jsonb-types/custom-profile-fields.d.ts +336 -11
- package/lib/foundations/jsonb-types/custom-profile-fields.js +17 -9
- package/lib/foundations/jsonb-types/secrets.d.ts +2 -0
- package/lib/foundations/jsonb-types/secrets.js +5 -0
- package/lib/foundations/jsonb-types/sign-in-experience.d.ts +3 -1
- package/lib/foundations/jsonb-types/sign-in-experience.js +2 -0
- package/lib/foundations/jsonb-types/users.d.ts +94 -0
- package/lib/foundations/jsonb-types/users.js +11 -0
- package/lib/types/connector.d.ts +39 -0
- package/lib/types/connector.js +1 -0
- package/lib/types/consent.d.ts +40 -0
- package/lib/types/custom-profile-fields.d.ts +1410 -133
- package/lib/types/custom-profile-fields.js +51 -15
- package/lib/types/index.d.ts +2 -0
- package/lib/types/index.js +2 -0
- package/lib/types/interactions.d.ts +175 -1
- package/lib/types/interactions.js +48 -1
- package/lib/types/logto-config/index.d.ts +214 -179
- package/lib/types/logto-config/jwt-customizer.d.ts +453 -328
- package/lib/types/logto-config/jwt-customizer.js +6 -1
- package/lib/types/secrets.d.ts +436 -0
- package/lib/types/secrets.js +73 -0
- package/lib/types/sign-in-experience.d.ts +19 -1
- package/lib/types/sign-in-experience.js +3 -1
- package/lib/types/sso-connector.d.ts +5 -2
- package/lib/types/user-logto-config.d.ts +45 -0
- package/lib/types/user-logto-config.js +18 -0
- package/lib/types/user.d.ts +615 -0
- package/lib/types/user.js +14 -1
- package/lib/types/verification-records/backup-code-verification.d.ts +18 -0
- package/lib/types/verification-records/backup-code-verification.js +3 -0
- package/lib/types/verification-records/enterprise-sso-verification.d.ts +145 -0
- package/lib/types/verification-records/enterprise-sso-verification.js +5 -0
- package/lib/types/verification-records/new-password-identity-verification.d.ts +31 -0
- package/lib/types/verification-records/new-password-identity-verification.js +4 -0
- package/lib/types/verification-records/social-verification.d.ts +164 -0
- package/lib/types/verification-records/social-verification.js +6 -0
- package/lib/types/verification-records/totp-verification.d.ts +18 -0
- package/lib/types/verification-records/totp-verification.js +3 -0
- package/lib/types/verification-records/web-authn-verification.d.ts +44 -0
- package/lib/types/verification-records/web-authn-verification.js +5 -0
- package/package.json +7 -7
- package/tables/account_centers.sql +1 -1
- package/tables/connectors.sql +2 -0
- package/tables/organization_user_relations.sql +4 -1
- package/tables/secret_enterprise_sso_connector_relations.sql +60 -0
- package/tables/secret_social_connector_relations.sql +75 -0
- package/tables/secrets.sql +4 -4
- package/tables/sso_connectors.sql +2 -0
- package/tables/users.sql +2 -1
- package/lib/db-entries/secret-connector-relation.d.ts +0 -40
- package/lib/db-entries/secret-connector-relation.js +0 -49
- package/tables/secret_connector_relations.sql +0 -78
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { Users } from '../db-entries/user.js';
|
|
3
|
-
import { CustomProfileFieldType, customProfileFieldTypeGuard, userProfileAddressKeys, userProfileGuard, } from '../foundations/index.js';
|
|
3
|
+
import { CustomProfileFieldType, customProfileFieldTypeGuard, fieldPartGuard, userProfileAddressKeys, userProfileGuard, } from '../foundations/index.js';
|
|
4
|
+
import { userOnboardingDataKey } from './onboarding.js';
|
|
5
|
+
import { defaultTenantIdKey } from './tenant.js';
|
|
6
|
+
import { consoleUserPreferenceKey, guideRequestsKey } from './user.js';
|
|
4
7
|
const baseProfileFieldGuard = z.object({
|
|
5
8
|
name: z.string(),
|
|
6
9
|
type: customProfileFieldTypeGuard,
|
|
7
10
|
label: z.string(),
|
|
8
11
|
description: z.string().optional(),
|
|
9
|
-
required: z.boolean()
|
|
12
|
+
required: z.boolean(),
|
|
10
13
|
});
|
|
11
14
|
export const textProfileFieldGuard = baseProfileFieldGuard.extend({
|
|
12
15
|
type: z.literal(CustomProfileFieldType.Text),
|
|
@@ -34,6 +37,7 @@ export const dateProfileFieldGuard = baseProfileFieldGuard.extend({
|
|
|
34
37
|
.object({
|
|
35
38
|
placeholder: z.string().optional(),
|
|
36
39
|
format: z.string(),
|
|
40
|
+
customFormat: z.string().optional(),
|
|
37
41
|
})
|
|
38
42
|
.optional(),
|
|
39
43
|
});
|
|
@@ -68,13 +72,12 @@ export const regexProfileFieldGuard = baseProfileFieldGuard.extend({
|
|
|
68
72
|
export const addressProfileFieldGuard = baseProfileFieldGuard.extend({
|
|
69
73
|
type: z.literal(CustomProfileFieldType.Address),
|
|
70
74
|
config: z.object({
|
|
71
|
-
parts: z.array(
|
|
72
|
-
|
|
73
|
-
enabled: z.boolean(),
|
|
75
|
+
parts: z.array(fieldPartGuard.omit({ name: true }).extend({
|
|
76
|
+
name: z.enum(userProfileAddressKeys),
|
|
74
77
|
})),
|
|
75
78
|
}),
|
|
76
79
|
});
|
|
77
|
-
const fullnameKeys = userProfileGuard
|
|
80
|
+
export const fullnameKeys = userProfileGuard
|
|
78
81
|
.pick({
|
|
79
82
|
givenName: true,
|
|
80
83
|
middleName: true,
|
|
@@ -84,7 +87,9 @@ const fullnameKeys = userProfileGuard
|
|
|
84
87
|
export const fullnameProfileFieldGuard = baseProfileFieldGuard.extend({
|
|
85
88
|
type: z.literal(CustomProfileFieldType.Fullname),
|
|
86
89
|
config: z.object({
|
|
87
|
-
parts: z.array(
|
|
90
|
+
parts: z.array(fieldPartGuard.omit({ name: true }).extend({
|
|
91
|
+
name: z.enum(fullnameKeys),
|
|
92
|
+
})),
|
|
88
93
|
}),
|
|
89
94
|
});
|
|
90
95
|
export const customProfileFieldUnionGuard = z.discriminatedUnion('type', [
|
|
@@ -98,14 +103,14 @@ export const customProfileFieldUnionGuard = z.discriminatedUnion('type', [
|
|
|
98
103
|
addressProfileFieldGuard,
|
|
99
104
|
fullnameProfileFieldGuard,
|
|
100
105
|
]);
|
|
101
|
-
export const
|
|
102
|
-
.
|
|
103
|
-
name:
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}))
|
|
108
|
-
|
|
106
|
+
export const nameAndAvatarGuard = z
|
|
107
|
+
.object({
|
|
108
|
+
name: z.string(),
|
|
109
|
+
avatar: z.string().url().or(z.literal('')),
|
|
110
|
+
})
|
|
111
|
+
.partial();
|
|
112
|
+
export const builtInProfileGuard = nameAndAvatarGuard.merge(z.object({ profile: userProfileGuard }));
|
|
113
|
+
export const builtInCustomProfileFieldKeys = Object.freeze(builtInProfileGuard.merge(userProfileGuard).keyof().options);
|
|
109
114
|
export const updateCustomProfileFieldDataGuard = z.discriminatedUnion('type', [
|
|
110
115
|
textProfileFieldGuard.omit({ name: true }),
|
|
111
116
|
numberProfileFieldGuard.omit({ name: true }),
|
|
@@ -121,3 +126,34 @@ export const updateCustomProfileFieldSieOrderGuard = z.object({
|
|
|
121
126
|
name: z.string(),
|
|
122
127
|
sieOrder: z.number(),
|
|
123
128
|
});
|
|
129
|
+
export const signInIdentifierKeyGuard = Users.createGuard
|
|
130
|
+
.pick({
|
|
131
|
+
username: true,
|
|
132
|
+
primaryEmail: true,
|
|
133
|
+
primaryPhone: true,
|
|
134
|
+
})
|
|
135
|
+
.extend({
|
|
136
|
+
email: z.string().nullable().optional(),
|
|
137
|
+
phone: z.string().nullable().optional(),
|
|
138
|
+
});
|
|
139
|
+
export const reservedCustomDataKeyGuard = z
|
|
140
|
+
.object({
|
|
141
|
+
[userOnboardingDataKey]: z.string(),
|
|
142
|
+
[guideRequestsKey]: z.string(),
|
|
143
|
+
[consoleUserPreferenceKey]: z.string(),
|
|
144
|
+
[defaultTenantIdKey]: z.string(),
|
|
145
|
+
})
|
|
146
|
+
.partial();
|
|
147
|
+
export const reservedCustomDataKeys = Object.freeze(reservedCustomDataKeyGuard.keyof().options);
|
|
148
|
+
/**
|
|
149
|
+
* Disallow sign-in identifiers related field keys in custom profile fields, as this is conflicting
|
|
150
|
+
* with the built-in sign-in/sign-up experience flows.
|
|
151
|
+
*/
|
|
152
|
+
export const reservedSignInIdentifierKeys = Object.freeze(signInIdentifierKeyGuard.keyof().options);
|
|
153
|
+
export var supportedDateFormat;
|
|
154
|
+
(function (supportedDateFormat) {
|
|
155
|
+
supportedDateFormat["US"] = "MM/dd/yyyy";
|
|
156
|
+
supportedDateFormat["UK"] = "dd/MM/yyyy";
|
|
157
|
+
supportedDateFormat["ISO"] = "yyyy-MM-dd";
|
|
158
|
+
supportedDateFormat["Custom"] = "custom";
|
|
159
|
+
})(supportedDateFormat || (supportedDateFormat = {}));
|
package/lib/types/index.d.ts
CHANGED
package/lib/types/index.js
CHANGED
|
@@ -59,16 +59,20 @@ export declare const verificationCodeIdentifierGuard: z.ZodObject<{
|
|
|
59
59
|
export type SocialAuthorizationUrlPayload = {
|
|
60
60
|
state: string;
|
|
61
61
|
redirectUri: string;
|
|
62
|
+
scope?: string;
|
|
62
63
|
};
|
|
63
64
|
export declare const socialAuthorizationUrlPayloadGuard: z.ZodObject<{
|
|
64
65
|
state: z.ZodString;
|
|
65
66
|
redirectUri: z.ZodString;
|
|
67
|
+
scope: z.ZodOptional<z.ZodString>;
|
|
66
68
|
}, "strip", z.ZodTypeAny, {
|
|
67
69
|
redirectUri: string;
|
|
68
70
|
state: string;
|
|
71
|
+
scope?: string | undefined;
|
|
69
72
|
}, {
|
|
70
73
|
redirectUri: string;
|
|
71
74
|
state: string;
|
|
75
|
+
scope?: string | undefined;
|
|
72
76
|
}>;
|
|
73
77
|
/** Payload type for `POST /api/experience/verification/{social|sso}/:connectorId/verify`. */
|
|
74
78
|
export type SocialVerificationCallbackPayload = {
|
|
@@ -276,6 +280,15 @@ export declare const updateProfileApiPayloadGuard: z.ZodDiscriminatedUnion<"type
|
|
|
276
280
|
}, {
|
|
277
281
|
type: "social";
|
|
278
282
|
verificationId: string;
|
|
283
|
+
}>, z.ZodObject<{
|
|
284
|
+
type: z.ZodLiteral<"extraProfile">;
|
|
285
|
+
values: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
286
|
+
}, "strip", z.ZodTypeAny, {
|
|
287
|
+
type: "extraProfile";
|
|
288
|
+
values: Record<string, unknown>;
|
|
289
|
+
}, {
|
|
290
|
+
type: "extraProfile";
|
|
291
|
+
values: Record<string, unknown>;
|
|
279
292
|
}>]>;
|
|
280
293
|
export type UpdateProfileApiPayload = z.infer<typeof updateProfileApiPayloadGuard>;
|
|
281
294
|
/**
|
|
@@ -455,7 +468,8 @@ export declare enum MissingProfile {
|
|
|
455
468
|
email = "email",
|
|
456
469
|
phone = "phone",
|
|
457
470
|
password = "password",
|
|
458
|
-
emailOrPhone = "emailOrPhone"
|
|
471
|
+
emailOrPhone = "emailOrPhone",
|
|
472
|
+
extraProfile = "extraProfile"
|
|
459
473
|
}
|
|
460
474
|
export declare const bindTotpPayloadGuard: z.ZodObject<{
|
|
461
475
|
type: z.ZodLiteral<MfaFactor.TOTP>;
|
|
@@ -573,6 +587,22 @@ export declare const bindBackupCodePayloadGuard: z.ZodObject<{
|
|
|
573
587
|
type: MfaFactor.BackupCode;
|
|
574
588
|
}>;
|
|
575
589
|
export type BindBackupCodePayload = z.infer<typeof bindBackupCodePayloadGuard>;
|
|
590
|
+
export declare const bindEmailVerificationCodePayloadGuard: z.ZodObject<{
|
|
591
|
+
type: z.ZodLiteral<MfaFactor.EmailVerificationCode>;
|
|
592
|
+
}, "strip", z.ZodTypeAny, {
|
|
593
|
+
type: MfaFactor.EmailVerificationCode;
|
|
594
|
+
}, {
|
|
595
|
+
type: MfaFactor.EmailVerificationCode;
|
|
596
|
+
}>;
|
|
597
|
+
export type BindEmailVerificationCodePayload = z.infer<typeof bindEmailVerificationCodePayloadGuard>;
|
|
598
|
+
export declare const bindPhoneVerificationCodePayloadGuard: z.ZodObject<{
|
|
599
|
+
type: z.ZodLiteral<MfaFactor.PhoneVerificationCode>;
|
|
600
|
+
}, "strip", z.ZodTypeAny, {
|
|
601
|
+
type: MfaFactor.PhoneVerificationCode;
|
|
602
|
+
}, {
|
|
603
|
+
type: MfaFactor.PhoneVerificationCode;
|
|
604
|
+
}>;
|
|
605
|
+
export type BindPhoneVerificationCodePayload = z.infer<typeof bindPhoneVerificationCodePayloadGuard>;
|
|
576
606
|
export declare const bindMfaPayloadGuard: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
577
607
|
type: z.ZodLiteral<MfaFactor.TOTP>;
|
|
578
608
|
code: z.ZodString;
|
|
@@ -683,6 +713,18 @@ export declare const bindMfaPayloadGuard: z.ZodDiscriminatedUnion<"type", [z.Zod
|
|
|
683
713
|
type: MfaFactor.BackupCode;
|
|
684
714
|
}, {
|
|
685
715
|
type: MfaFactor.BackupCode;
|
|
716
|
+
}>, z.ZodObject<{
|
|
717
|
+
type: z.ZodLiteral<MfaFactor.EmailVerificationCode>;
|
|
718
|
+
}, "strip", z.ZodTypeAny, {
|
|
719
|
+
type: MfaFactor.EmailVerificationCode;
|
|
720
|
+
}, {
|
|
721
|
+
type: MfaFactor.EmailVerificationCode;
|
|
722
|
+
}>, z.ZodObject<{
|
|
723
|
+
type: z.ZodLiteral<MfaFactor.PhoneVerificationCode>;
|
|
724
|
+
}, "strip", z.ZodTypeAny, {
|
|
725
|
+
type: MfaFactor.PhoneVerificationCode;
|
|
726
|
+
}, {
|
|
727
|
+
type: MfaFactor.PhoneVerificationCode;
|
|
686
728
|
}>]>;
|
|
687
729
|
export type BindMfaPayload = z.infer<typeof bindMfaPayloadGuard>;
|
|
688
730
|
/** @deprecated Legacy interaction API use only */
|
|
@@ -819,6 +861,34 @@ export declare const backupCodeVerificationPayloadGuard: z.ZodObject<{
|
|
|
819
861
|
type: MfaFactor.BackupCode;
|
|
820
862
|
}>;
|
|
821
863
|
export type BackupCodeVerificationPayload = z.infer<typeof backupCodeVerificationPayloadGuard>;
|
|
864
|
+
export declare const emailVerificationCodeVerificationPayloadGuard: z.ZodObject<{
|
|
865
|
+
type: z.ZodLiteral<MfaFactor.EmailVerificationCode>;
|
|
866
|
+
email: z.ZodString;
|
|
867
|
+
code: z.ZodString;
|
|
868
|
+
}, "strip", z.ZodTypeAny, {
|
|
869
|
+
code: string;
|
|
870
|
+
type: MfaFactor.EmailVerificationCode;
|
|
871
|
+
email: string;
|
|
872
|
+
}, {
|
|
873
|
+
code: string;
|
|
874
|
+
type: MfaFactor.EmailVerificationCode;
|
|
875
|
+
email: string;
|
|
876
|
+
}>;
|
|
877
|
+
export type EmailVerificationCodeVerificationPayload = z.infer<typeof emailVerificationCodeVerificationPayloadGuard>;
|
|
878
|
+
export declare const phoneVerificationCodeVerificationPayloadGuard: z.ZodObject<{
|
|
879
|
+
type: z.ZodLiteral<MfaFactor.PhoneVerificationCode>;
|
|
880
|
+
phone: z.ZodString;
|
|
881
|
+
code: z.ZodString;
|
|
882
|
+
}, "strip", z.ZodTypeAny, {
|
|
883
|
+
code: string;
|
|
884
|
+
type: MfaFactor.PhoneVerificationCode;
|
|
885
|
+
phone: string;
|
|
886
|
+
}, {
|
|
887
|
+
code: string;
|
|
888
|
+
type: MfaFactor.PhoneVerificationCode;
|
|
889
|
+
phone: string;
|
|
890
|
+
}>;
|
|
891
|
+
export type PhoneVerificationCodeVerificationPayload = z.infer<typeof phoneVerificationCodeVerificationPayloadGuard>;
|
|
822
892
|
export declare const verifyMfaPayloadGuard: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
823
893
|
type: z.ZodLiteral<MfaFactor.TOTP>;
|
|
824
894
|
code: z.ZodString;
|
|
@@ -945,6 +1015,30 @@ export declare const verifyMfaPayloadGuard: z.ZodDiscriminatedUnion<"type", [z.Z
|
|
|
945
1015
|
}, {
|
|
946
1016
|
code: string;
|
|
947
1017
|
type: MfaFactor.BackupCode;
|
|
1018
|
+
}>, z.ZodObject<{
|
|
1019
|
+
type: z.ZodLiteral<MfaFactor.EmailVerificationCode>;
|
|
1020
|
+
email: z.ZodString;
|
|
1021
|
+
code: z.ZodString;
|
|
1022
|
+
}, "strip", z.ZodTypeAny, {
|
|
1023
|
+
code: string;
|
|
1024
|
+
type: MfaFactor.EmailVerificationCode;
|
|
1025
|
+
email: string;
|
|
1026
|
+
}, {
|
|
1027
|
+
code: string;
|
|
1028
|
+
type: MfaFactor.EmailVerificationCode;
|
|
1029
|
+
email: string;
|
|
1030
|
+
}>, z.ZodObject<{
|
|
1031
|
+
type: z.ZodLiteral<MfaFactor.PhoneVerificationCode>;
|
|
1032
|
+
phone: z.ZodString;
|
|
1033
|
+
code: z.ZodString;
|
|
1034
|
+
}, "strip", z.ZodTypeAny, {
|
|
1035
|
+
code: string;
|
|
1036
|
+
type: MfaFactor.PhoneVerificationCode;
|
|
1037
|
+
phone: string;
|
|
1038
|
+
}, {
|
|
1039
|
+
code: string;
|
|
1040
|
+
type: MfaFactor.PhoneVerificationCode;
|
|
1041
|
+
phone: string;
|
|
948
1042
|
}>]>;
|
|
949
1043
|
export type VerifyMfaPayload = z.infer<typeof verifyMfaPayloadGuard>;
|
|
950
1044
|
export declare const pendingTotpGuard: z.ZodObject<{
|
|
@@ -980,6 +1074,28 @@ export declare const pendingBackupCodeGuard: z.ZodObject<{
|
|
|
980
1074
|
codes: string[];
|
|
981
1075
|
}>;
|
|
982
1076
|
export type PendingBackupCode = z.infer<typeof pendingBackupCodeGuard>;
|
|
1077
|
+
export declare const pendingEmailVerificationCodeGuard: z.ZodObject<{
|
|
1078
|
+
type: z.ZodLiteral<MfaFactor.EmailVerificationCode>;
|
|
1079
|
+
email: z.ZodString;
|
|
1080
|
+
}, "strip", z.ZodTypeAny, {
|
|
1081
|
+
type: MfaFactor.EmailVerificationCode;
|
|
1082
|
+
email: string;
|
|
1083
|
+
}, {
|
|
1084
|
+
type: MfaFactor.EmailVerificationCode;
|
|
1085
|
+
email: string;
|
|
1086
|
+
}>;
|
|
1087
|
+
export type PendingEmailVerificationCode = z.infer<typeof pendingEmailVerificationCodeGuard>;
|
|
1088
|
+
export declare const pendingPhoneVerificationCodeGuard: z.ZodObject<{
|
|
1089
|
+
type: z.ZodLiteral<MfaFactor.PhoneVerificationCode>;
|
|
1090
|
+
phone: z.ZodString;
|
|
1091
|
+
}, "strip", z.ZodTypeAny, {
|
|
1092
|
+
type: MfaFactor.PhoneVerificationCode;
|
|
1093
|
+
phone: string;
|
|
1094
|
+
}, {
|
|
1095
|
+
type: MfaFactor.PhoneVerificationCode;
|
|
1096
|
+
phone: string;
|
|
1097
|
+
}>;
|
|
1098
|
+
export type PendingPhoneVerificationCode = z.infer<typeof pendingPhoneVerificationCodeGuard>;
|
|
983
1099
|
export declare const pendingMfaGuard: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
984
1100
|
type: z.ZodLiteral<MfaFactor.TOTP>;
|
|
985
1101
|
secret: z.ZodString;
|
|
@@ -1007,6 +1123,24 @@ export declare const pendingMfaGuard: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
1007
1123
|
}, {
|
|
1008
1124
|
type: MfaFactor.BackupCode;
|
|
1009
1125
|
codes: string[];
|
|
1126
|
+
}>, z.ZodObject<{
|
|
1127
|
+
type: z.ZodLiteral<MfaFactor.EmailVerificationCode>;
|
|
1128
|
+
email: z.ZodString;
|
|
1129
|
+
}, "strip", z.ZodTypeAny, {
|
|
1130
|
+
type: MfaFactor.EmailVerificationCode;
|
|
1131
|
+
email: string;
|
|
1132
|
+
}, {
|
|
1133
|
+
type: MfaFactor.EmailVerificationCode;
|
|
1134
|
+
email: string;
|
|
1135
|
+
}>, z.ZodObject<{
|
|
1136
|
+
type: z.ZodLiteral<MfaFactor.PhoneVerificationCode>;
|
|
1137
|
+
phone: z.ZodString;
|
|
1138
|
+
}, "strip", z.ZodTypeAny, {
|
|
1139
|
+
type: MfaFactor.PhoneVerificationCode;
|
|
1140
|
+
phone: string;
|
|
1141
|
+
}, {
|
|
1142
|
+
type: MfaFactor.PhoneVerificationCode;
|
|
1143
|
+
phone: string;
|
|
1010
1144
|
}>]>;
|
|
1011
1145
|
export type PendingMfa = z.infer<typeof pendingMfaGuard>;
|
|
1012
1146
|
export declare const bindTotpGuard: z.ZodObject<{
|
|
@@ -1057,6 +1191,28 @@ export declare const bindBackupCodeGuard: z.ZodObject<{
|
|
|
1057
1191
|
codes: string[];
|
|
1058
1192
|
}>;
|
|
1059
1193
|
export type BindBackupCode = z.infer<typeof bindBackupCodeGuard>;
|
|
1194
|
+
export declare const bindEmailVerificationCodeGuard: z.ZodObject<{
|
|
1195
|
+
type: z.ZodLiteral<MfaFactor.EmailVerificationCode>;
|
|
1196
|
+
email: z.ZodString;
|
|
1197
|
+
}, "strip", z.ZodTypeAny, {
|
|
1198
|
+
type: MfaFactor.EmailVerificationCode;
|
|
1199
|
+
email: string;
|
|
1200
|
+
}, {
|
|
1201
|
+
type: MfaFactor.EmailVerificationCode;
|
|
1202
|
+
email: string;
|
|
1203
|
+
}>;
|
|
1204
|
+
export type BindEmailVerificationCode = z.infer<typeof bindEmailVerificationCodeGuard>;
|
|
1205
|
+
export declare const bindPhoneVerificationCodeGuard: z.ZodObject<{
|
|
1206
|
+
type: z.ZodLiteral<MfaFactor.PhoneVerificationCode>;
|
|
1207
|
+
phone: z.ZodString;
|
|
1208
|
+
}, "strip", z.ZodTypeAny, {
|
|
1209
|
+
type: MfaFactor.PhoneVerificationCode;
|
|
1210
|
+
phone: string;
|
|
1211
|
+
}, {
|
|
1212
|
+
type: MfaFactor.PhoneVerificationCode;
|
|
1213
|
+
phone: string;
|
|
1214
|
+
}>;
|
|
1215
|
+
export type BindPhoneVerificationCode = z.infer<typeof bindPhoneVerificationCodeGuard>;
|
|
1060
1216
|
export declare const bindMfaGuard: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
1061
1217
|
type: z.ZodLiteral<MfaFactor.TOTP>;
|
|
1062
1218
|
secret: z.ZodString;
|
|
@@ -1099,6 +1255,24 @@ export declare const bindMfaGuard: z.ZodDiscriminatedUnion<"type", [z.ZodObject<
|
|
|
1099
1255
|
}, {
|
|
1100
1256
|
type: MfaFactor.BackupCode;
|
|
1101
1257
|
codes: string[];
|
|
1258
|
+
}>, z.ZodObject<{
|
|
1259
|
+
type: z.ZodLiteral<MfaFactor.EmailVerificationCode>;
|
|
1260
|
+
email: z.ZodString;
|
|
1261
|
+
}, "strip", z.ZodTypeAny, {
|
|
1262
|
+
type: MfaFactor.EmailVerificationCode;
|
|
1263
|
+
email: string;
|
|
1264
|
+
}, {
|
|
1265
|
+
type: MfaFactor.EmailVerificationCode;
|
|
1266
|
+
email: string;
|
|
1267
|
+
}>, z.ZodObject<{
|
|
1268
|
+
type: z.ZodLiteral<MfaFactor.PhoneVerificationCode>;
|
|
1269
|
+
phone: z.ZodString;
|
|
1270
|
+
}, "strip", z.ZodTypeAny, {
|
|
1271
|
+
type: MfaFactor.PhoneVerificationCode;
|
|
1272
|
+
phone: string;
|
|
1273
|
+
}, {
|
|
1274
|
+
type: MfaFactor.PhoneVerificationCode;
|
|
1275
|
+
phone: string;
|
|
1102
1276
|
}>]>;
|
|
1103
1277
|
export type BindMfa = z.infer<typeof bindMfaGuard>;
|
|
1104
1278
|
export declare const verifyMfaResultGuard: z.ZodObject<{
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable max-lines */
|
|
2
|
-
import { emailRegEx, phoneRegEx, usernameRegEx } from '@logto/core-kit';
|
|
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
5
|
import { emailVerificationCodePayloadGuard, phoneVerificationCodePayloadGuard, } from './verification-code.js';
|
|
@@ -28,6 +28,7 @@ export const verificationCodeIdentifierGuard = z.object({
|
|
|
28
28
|
export const socialAuthorizationUrlPayloadGuard = z.object({
|
|
29
29
|
state: z.string(),
|
|
30
30
|
redirectUri: z.string(),
|
|
31
|
+
scope: z.string().optional(),
|
|
31
32
|
});
|
|
32
33
|
export const socialVerificationCallbackPayloadGuard = z.object({
|
|
33
34
|
connectorData: jsonObjectGuard,
|
|
@@ -81,6 +82,10 @@ export const updateProfileApiPayloadGuard = z.discriminatedUnion('type', [
|
|
|
81
82
|
type: z.literal('social'),
|
|
82
83
|
verificationId: z.string(),
|
|
83
84
|
}),
|
|
85
|
+
z.object({
|
|
86
|
+
type: z.literal('extraProfile'),
|
|
87
|
+
values: z.record(z.string().regex(numberAndAlphabetRegEx), z.unknown()),
|
|
88
|
+
}),
|
|
84
89
|
]);
|
|
85
90
|
// ====== Experience API payload guard and types definitions end ======
|
|
86
91
|
/**
|
|
@@ -143,6 +148,7 @@ export var MissingProfile;
|
|
|
143
148
|
MissingProfile["phone"] = "phone";
|
|
144
149
|
MissingProfile["password"] = "password";
|
|
145
150
|
MissingProfile["emailOrPhone"] = "emailOrPhone";
|
|
151
|
+
MissingProfile["extraProfile"] = "extraProfile";
|
|
146
152
|
})(MissingProfile || (MissingProfile = {}));
|
|
147
153
|
export const bindTotpPayloadGuard = z.object({
|
|
148
154
|
// Unlike identifier payload which has indicator like "email",
|
|
@@ -181,10 +187,19 @@ export const bindWebAuthnPayloadGuard = z.object({
|
|
|
181
187
|
export const bindBackupCodePayloadGuard = z.object({
|
|
182
188
|
type: z.literal(MfaFactor.BackupCode),
|
|
183
189
|
});
|
|
190
|
+
// TODO @sijie: Implement binding
|
|
191
|
+
export const bindEmailVerificationCodePayloadGuard = z.object({
|
|
192
|
+
type: z.literal(MfaFactor.EmailVerificationCode),
|
|
193
|
+
});
|
|
194
|
+
export const bindPhoneVerificationCodePayloadGuard = z.object({
|
|
195
|
+
type: z.literal(MfaFactor.PhoneVerificationCode),
|
|
196
|
+
});
|
|
184
197
|
export const bindMfaPayloadGuard = z.discriminatedUnion('type', [
|
|
185
198
|
bindTotpPayloadGuard,
|
|
186
199
|
bindWebAuthnPayloadGuard,
|
|
187
200
|
bindBackupCodePayloadGuard,
|
|
201
|
+
bindEmailVerificationCodePayloadGuard,
|
|
202
|
+
bindPhoneVerificationCodePayloadGuard,
|
|
188
203
|
]);
|
|
189
204
|
/** @deprecated Legacy interaction API use only */
|
|
190
205
|
export const totpVerificationPayloadGuard = bindTotpPayloadGuard;
|
|
@@ -202,10 +217,22 @@ export const backupCodeVerificationPayloadGuard = z.object({
|
|
|
202
217
|
type: z.literal(MfaFactor.BackupCode),
|
|
203
218
|
code: z.string(),
|
|
204
219
|
});
|
|
220
|
+
export const emailVerificationCodeVerificationPayloadGuard = z.object({
|
|
221
|
+
type: z.literal(MfaFactor.EmailVerificationCode),
|
|
222
|
+
email: z.string(),
|
|
223
|
+
code: z.string(),
|
|
224
|
+
});
|
|
225
|
+
export const phoneVerificationCodeVerificationPayloadGuard = z.object({
|
|
226
|
+
type: z.literal(MfaFactor.PhoneVerificationCode),
|
|
227
|
+
phone: z.string(),
|
|
228
|
+
code: z.string(),
|
|
229
|
+
});
|
|
205
230
|
export const verifyMfaPayloadGuard = z.discriminatedUnion('type', [
|
|
206
231
|
totpVerificationPayloadGuard,
|
|
207
232
|
webAuthnVerificationPayloadGuard,
|
|
208
233
|
backupCodeVerificationPayloadGuard,
|
|
234
|
+
emailVerificationCodeVerificationPayloadGuard,
|
|
235
|
+
phoneVerificationCodeVerificationPayloadGuard,
|
|
209
236
|
]);
|
|
210
237
|
export const pendingTotpGuard = z.object({
|
|
211
238
|
type: z.literal(MfaFactor.TOTP),
|
|
@@ -219,12 +246,22 @@ export const pendingBackupCodeGuard = z.object({
|
|
|
219
246
|
type: z.literal(MfaFactor.BackupCode),
|
|
220
247
|
codes: z.array(z.string()),
|
|
221
248
|
});
|
|
249
|
+
export const pendingEmailVerificationCodeGuard = z.object({
|
|
250
|
+
type: z.literal(MfaFactor.EmailVerificationCode),
|
|
251
|
+
email: z.string(),
|
|
252
|
+
});
|
|
253
|
+
export const pendingPhoneVerificationCodeGuard = z.object({
|
|
254
|
+
type: z.literal(MfaFactor.PhoneVerificationCode),
|
|
255
|
+
phone: z.string(),
|
|
256
|
+
});
|
|
222
257
|
// Some information like TOTP secret should be generated in the backend
|
|
223
258
|
// and stored in the interaction temporarily.
|
|
224
259
|
export const pendingMfaGuard = z.discriminatedUnion('type', [
|
|
225
260
|
pendingTotpGuard,
|
|
226
261
|
pendingWebAuthnGuard,
|
|
227
262
|
pendingBackupCodeGuard,
|
|
263
|
+
pendingEmailVerificationCodeGuard,
|
|
264
|
+
pendingPhoneVerificationCodeGuard,
|
|
228
265
|
]);
|
|
229
266
|
export const bindTotpGuard = pendingTotpGuard;
|
|
230
267
|
export const bindWebAuthnGuard = z.object({
|
|
@@ -237,11 +274,21 @@ export const bindWebAuthnGuard = z.object({
|
|
|
237
274
|
name: z.string().optional(),
|
|
238
275
|
});
|
|
239
276
|
export const bindBackupCodeGuard = pendingBackupCodeGuard;
|
|
277
|
+
export const bindEmailVerificationCodeGuard = z.object({
|
|
278
|
+
type: z.literal(MfaFactor.EmailVerificationCode),
|
|
279
|
+
email: z.string(),
|
|
280
|
+
});
|
|
281
|
+
export const bindPhoneVerificationCodeGuard = z.object({
|
|
282
|
+
type: z.literal(MfaFactor.PhoneVerificationCode),
|
|
283
|
+
phone: z.string(),
|
|
284
|
+
});
|
|
240
285
|
// The type for binding new mfa verification to a user, not always equals to the pending type.
|
|
241
286
|
export const bindMfaGuard = z.discriminatedUnion('type', [
|
|
242
287
|
bindTotpGuard,
|
|
243
288
|
bindWebAuthnGuard,
|
|
244
289
|
bindBackupCodeGuard,
|
|
290
|
+
bindEmailVerificationCodeGuard,
|
|
291
|
+
bindPhoneVerificationCodeGuard,
|
|
245
292
|
]);
|
|
246
293
|
export const verifyMfaResultGuard = z.object({
|
|
247
294
|
type: z.nativeEnum(MfaFactor),
|