@logto/schemas 1.29.0 → 1.30.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.
- 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 +6 -6
- 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
|
@@ -7,3 +7,6 @@ export const backupCodeVerificationRecordDataGuard = z.object({
|
|
|
7
7
|
code: z.string().optional(),
|
|
8
8
|
backupCodes: z.string().array().optional(),
|
|
9
9
|
});
|
|
10
|
+
export const sanitizedBackupCodeVerificationRecordDataGuard = backupCodeVerificationRecordDataGuard.omit({
|
|
11
|
+
backupCodes: true,
|
|
12
|
+
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import { type EncryptedTokenSet } from '../secrets.js';
|
|
2
3
|
import { type ExtendedSocialUserInfo } from '../sso-connector.js';
|
|
3
4
|
import { VerificationType } from './verification-type.js';
|
|
4
5
|
/** The JSON data type for the EnterpriseSsoVerification record stored in the interaction storage */
|
|
@@ -10,6 +11,7 @@ export type EnterpriseSsoVerificationRecordData = {
|
|
|
10
11
|
* The enterprise SSO identity returned by the connector.
|
|
11
12
|
*/
|
|
12
13
|
enterpriseSsoUserInfo?: ExtendedSocialUserInfo;
|
|
14
|
+
encryptedTokenSet?: EncryptedTokenSet;
|
|
13
15
|
issuer?: string;
|
|
14
16
|
};
|
|
15
17
|
export declare const enterpriseSsoVerificationRecordDataGuard: z.ZodObject<{
|
|
@@ -38,6 +40,41 @@ export declare const enterpriseSsoVerificationRecordDataGuard: z.ZodObject<{
|
|
|
38
40
|
avatar: z.ZodOptional<z.ZodString>;
|
|
39
41
|
rawData: z.ZodOptional<z.ZodType<import("@withtyped/server").Json, z.ZodTypeDef, import("@withtyped/server").Json>>;
|
|
40
42
|
}, z.ZodUnknown, "strip">>>;
|
|
43
|
+
encryptedTokenSet: z.ZodOptional<z.ZodObject<{
|
|
44
|
+
encryptedTokenSetBase64: z.ZodString;
|
|
45
|
+
metadata: z.ZodObject<{
|
|
46
|
+
scope: z.ZodOptional<z.ZodString>;
|
|
47
|
+
expiresAt: z.ZodOptional<z.ZodNumber>;
|
|
48
|
+
tokenType: z.ZodOptional<z.ZodString>;
|
|
49
|
+
hasRefreshToken: z.ZodBoolean;
|
|
50
|
+
}, "strip", z.ZodTypeAny, {
|
|
51
|
+
hasRefreshToken: boolean;
|
|
52
|
+
scope?: string | undefined;
|
|
53
|
+
expiresAt?: number | undefined;
|
|
54
|
+
tokenType?: string | undefined;
|
|
55
|
+
}, {
|
|
56
|
+
hasRefreshToken: boolean;
|
|
57
|
+
scope?: string | undefined;
|
|
58
|
+
expiresAt?: number | undefined;
|
|
59
|
+
tokenType?: string | undefined;
|
|
60
|
+
}>;
|
|
61
|
+
}, "strip", z.ZodTypeAny, {
|
|
62
|
+
metadata: {
|
|
63
|
+
hasRefreshToken: boolean;
|
|
64
|
+
scope?: string | undefined;
|
|
65
|
+
expiresAt?: number | undefined;
|
|
66
|
+
tokenType?: string | undefined;
|
|
67
|
+
};
|
|
68
|
+
encryptedTokenSetBase64: string;
|
|
69
|
+
}, {
|
|
70
|
+
metadata: {
|
|
71
|
+
hasRefreshToken: boolean;
|
|
72
|
+
scope?: string | undefined;
|
|
73
|
+
expiresAt?: number | undefined;
|
|
74
|
+
tokenType?: string | undefined;
|
|
75
|
+
};
|
|
76
|
+
encryptedTokenSetBase64: string;
|
|
77
|
+
}>>;
|
|
41
78
|
issuer: z.ZodOptional<z.ZodString>;
|
|
42
79
|
}, "strip", z.ZodTypeAny, {
|
|
43
80
|
type: VerificationType.EnterpriseSso;
|
|
@@ -52,6 +89,114 @@ export declare const enterpriseSsoVerificationRecordDataGuard: z.ZodObject<{
|
|
|
52
89
|
avatar: z.ZodOptional<z.ZodString>;
|
|
53
90
|
rawData: z.ZodOptional<z.ZodType<import("@withtyped/server").Json, z.ZodTypeDef, import("@withtyped/server").Json>>;
|
|
54
91
|
}, z.ZodUnknown, "strip"> | undefined;
|
|
92
|
+
encryptedTokenSet?: {
|
|
93
|
+
metadata: {
|
|
94
|
+
hasRefreshToken: boolean;
|
|
95
|
+
scope?: string | undefined;
|
|
96
|
+
expiresAt?: number | undefined;
|
|
97
|
+
tokenType?: string | undefined;
|
|
98
|
+
};
|
|
99
|
+
encryptedTokenSetBase64: string;
|
|
100
|
+
} | undefined;
|
|
101
|
+
}, {
|
|
102
|
+
type: VerificationType.EnterpriseSso;
|
|
103
|
+
id: string;
|
|
104
|
+
connectorId: string;
|
|
105
|
+
issuer?: string | undefined;
|
|
106
|
+
enterpriseSsoUserInfo?: z.objectInputType<{
|
|
107
|
+
id: z.ZodString;
|
|
108
|
+
email: z.ZodOptional<z.ZodString>;
|
|
109
|
+
phone: z.ZodOptional<z.ZodString>;
|
|
110
|
+
name: z.ZodOptional<z.ZodString>;
|
|
111
|
+
avatar: z.ZodOptional<z.ZodString>;
|
|
112
|
+
rawData: z.ZodOptional<z.ZodType<import("@withtyped/server").Json, z.ZodTypeDef, import("@withtyped/server").Json>>;
|
|
113
|
+
}, z.ZodUnknown, "strip"> | undefined;
|
|
114
|
+
encryptedTokenSet?: {
|
|
115
|
+
metadata: {
|
|
116
|
+
hasRefreshToken: boolean;
|
|
117
|
+
scope?: string | undefined;
|
|
118
|
+
expiresAt?: number | undefined;
|
|
119
|
+
tokenType?: string | undefined;
|
|
120
|
+
};
|
|
121
|
+
encryptedTokenSetBase64: string;
|
|
122
|
+
} | undefined;
|
|
123
|
+
}>;
|
|
124
|
+
export type SanitizedEnterpriseSsoVerificationRecordData = Omit<EnterpriseSsoVerificationRecordData, 'encryptedTokenSet'>;
|
|
125
|
+
export declare const sanitizedEnterpriseSsoVerificationRecordDataGuard: z.ZodObject<Omit<{
|
|
126
|
+
id: z.ZodString;
|
|
127
|
+
connectorId: z.ZodString;
|
|
128
|
+
type: z.ZodLiteral<VerificationType.EnterpriseSso>;
|
|
129
|
+
enterpriseSsoUserInfo: z.ZodOptional<z.ZodObject<{
|
|
130
|
+
id: z.ZodString;
|
|
131
|
+
email: z.ZodOptional<z.ZodString>;
|
|
132
|
+
phone: z.ZodOptional<z.ZodString>;
|
|
133
|
+
name: z.ZodOptional<z.ZodString>;
|
|
134
|
+
avatar: z.ZodOptional<z.ZodString>;
|
|
135
|
+
rawData: z.ZodOptional<z.ZodType<import("@withtyped/server").Json, z.ZodTypeDef, import("@withtyped/server").Json>>;
|
|
136
|
+
}, "strip", z.ZodUnknown, z.objectOutputType<{
|
|
137
|
+
id: z.ZodString;
|
|
138
|
+
email: z.ZodOptional<z.ZodString>;
|
|
139
|
+
phone: z.ZodOptional<z.ZodString>;
|
|
140
|
+
name: z.ZodOptional<z.ZodString>;
|
|
141
|
+
avatar: z.ZodOptional<z.ZodString>;
|
|
142
|
+
rawData: z.ZodOptional<z.ZodType<import("@withtyped/server").Json, z.ZodTypeDef, import("@withtyped/server").Json>>;
|
|
143
|
+
}, z.ZodUnknown, "strip">, z.objectInputType<{
|
|
144
|
+
id: z.ZodString;
|
|
145
|
+
email: z.ZodOptional<z.ZodString>;
|
|
146
|
+
phone: z.ZodOptional<z.ZodString>;
|
|
147
|
+
name: z.ZodOptional<z.ZodString>;
|
|
148
|
+
avatar: z.ZodOptional<z.ZodString>;
|
|
149
|
+
rawData: z.ZodOptional<z.ZodType<import("@withtyped/server").Json, z.ZodTypeDef, import("@withtyped/server").Json>>;
|
|
150
|
+
}, z.ZodUnknown, "strip">>>;
|
|
151
|
+
encryptedTokenSet: z.ZodOptional<z.ZodObject<{
|
|
152
|
+
encryptedTokenSetBase64: z.ZodString;
|
|
153
|
+
metadata: z.ZodObject<{
|
|
154
|
+
scope: z.ZodOptional<z.ZodString>;
|
|
155
|
+
expiresAt: z.ZodOptional<z.ZodNumber>;
|
|
156
|
+
tokenType: z.ZodOptional<z.ZodString>;
|
|
157
|
+
hasRefreshToken: z.ZodBoolean;
|
|
158
|
+
}, "strip", z.ZodTypeAny, {
|
|
159
|
+
hasRefreshToken: boolean;
|
|
160
|
+
scope?: string | undefined;
|
|
161
|
+
expiresAt?: number | undefined;
|
|
162
|
+
tokenType?: string | undefined;
|
|
163
|
+
}, {
|
|
164
|
+
hasRefreshToken: boolean;
|
|
165
|
+
scope?: string | undefined;
|
|
166
|
+
expiresAt?: number | undefined;
|
|
167
|
+
tokenType?: string | undefined;
|
|
168
|
+
}>;
|
|
169
|
+
}, "strip", z.ZodTypeAny, {
|
|
170
|
+
metadata: {
|
|
171
|
+
hasRefreshToken: boolean;
|
|
172
|
+
scope?: string | undefined;
|
|
173
|
+
expiresAt?: number | undefined;
|
|
174
|
+
tokenType?: string | undefined;
|
|
175
|
+
};
|
|
176
|
+
encryptedTokenSetBase64: string;
|
|
177
|
+
}, {
|
|
178
|
+
metadata: {
|
|
179
|
+
hasRefreshToken: boolean;
|
|
180
|
+
scope?: string | undefined;
|
|
181
|
+
expiresAt?: number | undefined;
|
|
182
|
+
tokenType?: string | undefined;
|
|
183
|
+
};
|
|
184
|
+
encryptedTokenSetBase64: string;
|
|
185
|
+
}>>;
|
|
186
|
+
issuer: z.ZodOptional<z.ZodString>;
|
|
187
|
+
}, "encryptedTokenSet">, "strip", z.ZodTypeAny, {
|
|
188
|
+
type: VerificationType.EnterpriseSso;
|
|
189
|
+
id: string;
|
|
190
|
+
connectorId: string;
|
|
191
|
+
issuer?: string | undefined;
|
|
192
|
+
enterpriseSsoUserInfo?: z.objectOutputType<{
|
|
193
|
+
id: z.ZodString;
|
|
194
|
+
email: z.ZodOptional<z.ZodString>;
|
|
195
|
+
phone: z.ZodOptional<z.ZodString>;
|
|
196
|
+
name: z.ZodOptional<z.ZodString>;
|
|
197
|
+
avatar: z.ZodOptional<z.ZodString>;
|
|
198
|
+
rawData: z.ZodOptional<z.ZodType<import("@withtyped/server").Json, z.ZodTypeDef, import("@withtyped/server").Json>>;
|
|
199
|
+
}, z.ZodUnknown, "strip"> | undefined;
|
|
55
200
|
}, {
|
|
56
201
|
type: VerificationType.EnterpriseSso;
|
|
57
202
|
id: string;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import { encryptedTokenSetGuard } from '../secrets.js';
|
|
2
3
|
import { extendedSocialUserInfoGuard } from '../sso-connector.js';
|
|
3
4
|
import { VerificationType } from './verification-type.js';
|
|
4
5
|
export const enterpriseSsoVerificationRecordDataGuard = z.object({
|
|
@@ -6,5 +7,9 @@ export const enterpriseSsoVerificationRecordDataGuard = z.object({
|
|
|
6
7
|
connectorId: z.string(),
|
|
7
8
|
type: z.literal(VerificationType.EnterpriseSso),
|
|
8
9
|
enterpriseSsoUserInfo: extendedSocialUserInfoGuard.optional(),
|
|
10
|
+
encryptedTokenSet: encryptedTokenSetGuard.optional(),
|
|
9
11
|
issuer: z.string().optional(),
|
|
10
12
|
});
|
|
13
|
+
export const sanitizedEnterpriseSsoVerificationRecordDataGuard = enterpriseSsoVerificationRecordDataGuard.omit({
|
|
14
|
+
encryptedTokenSet: true,
|
|
15
|
+
});
|
|
@@ -52,3 +52,34 @@ export declare const newPasswordIdentityVerificationRecordDataGuard: z.ZodObject
|
|
|
52
52
|
passwordEncrypted?: string | undefined;
|
|
53
53
|
passwordEncryptionMethod?: UsersPasswordEncryptionMethod.Argon2i | undefined;
|
|
54
54
|
}>;
|
|
55
|
+
export type SanitizedNewPasswordIdentityVerificationRecordData = Omit<NewPasswordIdentityVerificationRecordData, 'passwordEncrypted' | 'passwordEncryptionMethod'>;
|
|
56
|
+
export declare const sanitizedNewPasswordIdentityVerificationRecordDataGuard: z.ZodObject<Omit<{
|
|
57
|
+
id: z.ZodString;
|
|
58
|
+
type: z.ZodLiteral<VerificationType.NewPasswordIdentity>;
|
|
59
|
+
identifier: z.ZodObject<{
|
|
60
|
+
type: z.ZodNativeEnum<typeof import("../../index.js").SignInIdentifier>;
|
|
61
|
+
value: z.ZodString;
|
|
62
|
+
}, "strip", z.ZodTypeAny, {
|
|
63
|
+
value: string;
|
|
64
|
+
type: import("../../index.js").SignInIdentifier;
|
|
65
|
+
}, {
|
|
66
|
+
value: string;
|
|
67
|
+
type: import("../../index.js").SignInIdentifier;
|
|
68
|
+
}>;
|
|
69
|
+
passwordEncrypted: z.ZodOptional<z.ZodString>;
|
|
70
|
+
passwordEncryptionMethod: z.ZodOptional<z.ZodLiteral<UsersPasswordEncryptionMethod.Argon2i>>;
|
|
71
|
+
}, "passwordEncrypted" | "passwordEncryptionMethod">, "strip", z.ZodTypeAny, {
|
|
72
|
+
type: VerificationType.NewPasswordIdentity;
|
|
73
|
+
id: string;
|
|
74
|
+
identifier: {
|
|
75
|
+
value: string;
|
|
76
|
+
type: import("../../index.js").SignInIdentifier;
|
|
77
|
+
};
|
|
78
|
+
}, {
|
|
79
|
+
type: VerificationType.NewPasswordIdentity;
|
|
80
|
+
id: string;
|
|
81
|
+
identifier: {
|
|
82
|
+
value: string;
|
|
83
|
+
type: import("../../index.js").SignInIdentifier;
|
|
84
|
+
};
|
|
85
|
+
}>;
|
|
@@ -14,3 +14,7 @@ export const newPasswordIdentityVerificationRecordDataGuard = z.object({
|
|
|
14
14
|
passwordEncrypted: z.string().optional(),
|
|
15
15
|
passwordEncryptionMethod: z.literal(UsersPasswordEncryptionMethod.Argon2i).optional(),
|
|
16
16
|
});
|
|
17
|
+
export const sanitizedNewPasswordIdentityVerificationRecordDataGuard = newPasswordIdentityVerificationRecordDataGuard.omit({
|
|
18
|
+
passwordEncrypted: true,
|
|
19
|
+
passwordEncryptionMethod: true,
|
|
20
|
+
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type ConnectorSession, type SocialUserInfo } from '@logto/connector-kit';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
+
import { type EncryptedTokenSet } from '../secrets.js';
|
|
3
4
|
import { VerificationType } from './verification-type.js';
|
|
4
5
|
/** The JSON data type for the SocialVerification record stored in the interaction storage */
|
|
5
6
|
export type SocialVerificationRecordData = {
|
|
@@ -10,6 +11,7 @@ export type SocialVerificationRecordData = {
|
|
|
10
11
|
* The social identity returned by the connector.
|
|
11
12
|
*/
|
|
12
13
|
socialUserInfo?: SocialUserInfo;
|
|
14
|
+
encryptedTokenSet?: EncryptedTokenSet;
|
|
13
15
|
/**
|
|
14
16
|
* The connector session result
|
|
15
17
|
*/
|
|
@@ -41,6 +43,41 @@ export declare const socialVerificationRecordDataGuard: z.ZodObject<{
|
|
|
41
43
|
avatar?: string | undefined;
|
|
42
44
|
rawData?: import("@withtyped/server").Json | undefined;
|
|
43
45
|
}>>;
|
|
46
|
+
encryptedTokenSet: z.ZodOptional<z.ZodObject<{
|
|
47
|
+
encryptedTokenSetBase64: z.ZodString;
|
|
48
|
+
metadata: z.ZodObject<{
|
|
49
|
+
scope: z.ZodOptional<z.ZodString>;
|
|
50
|
+
expiresAt: z.ZodOptional<z.ZodNumber>;
|
|
51
|
+
tokenType: z.ZodOptional<z.ZodString>;
|
|
52
|
+
hasRefreshToken: z.ZodBoolean;
|
|
53
|
+
}, "strip", z.ZodTypeAny, {
|
|
54
|
+
hasRefreshToken: boolean;
|
|
55
|
+
scope?: string | undefined;
|
|
56
|
+
expiresAt?: number | undefined;
|
|
57
|
+
tokenType?: string | undefined;
|
|
58
|
+
}, {
|
|
59
|
+
hasRefreshToken: boolean;
|
|
60
|
+
scope?: string | undefined;
|
|
61
|
+
expiresAt?: number | undefined;
|
|
62
|
+
tokenType?: string | undefined;
|
|
63
|
+
}>;
|
|
64
|
+
}, "strip", z.ZodTypeAny, {
|
|
65
|
+
metadata: {
|
|
66
|
+
hasRefreshToken: boolean;
|
|
67
|
+
scope?: string | undefined;
|
|
68
|
+
expiresAt?: number | undefined;
|
|
69
|
+
tokenType?: string | undefined;
|
|
70
|
+
};
|
|
71
|
+
encryptedTokenSetBase64: string;
|
|
72
|
+
}, {
|
|
73
|
+
metadata: {
|
|
74
|
+
hasRefreshToken: boolean;
|
|
75
|
+
scope?: string | undefined;
|
|
76
|
+
expiresAt?: number | undefined;
|
|
77
|
+
tokenType?: string | undefined;
|
|
78
|
+
};
|
|
79
|
+
encryptedTokenSetBase64: string;
|
|
80
|
+
}>>;
|
|
44
81
|
connectorSession: z.ZodOptional<z.ZodObject<{
|
|
45
82
|
nonce: z.ZodOptional<z.ZodString>;
|
|
46
83
|
redirectUri: z.ZodOptional<z.ZodString>;
|
|
@@ -67,6 +104,15 @@ export declare const socialVerificationRecordDataGuard: z.ZodObject<{
|
|
|
67
104
|
type: VerificationType.Social;
|
|
68
105
|
id: string;
|
|
69
106
|
connectorId: string;
|
|
107
|
+
encryptedTokenSet?: {
|
|
108
|
+
metadata: {
|
|
109
|
+
hasRefreshToken: boolean;
|
|
110
|
+
scope?: string | undefined;
|
|
111
|
+
expiresAt?: number | undefined;
|
|
112
|
+
tokenType?: string | undefined;
|
|
113
|
+
};
|
|
114
|
+
encryptedTokenSetBase64: string;
|
|
115
|
+
} | undefined;
|
|
70
116
|
socialUserInfo?: {
|
|
71
117
|
id: string;
|
|
72
118
|
name?: string | undefined;
|
|
@@ -87,6 +133,15 @@ export declare const socialVerificationRecordDataGuard: z.ZodObject<{
|
|
|
87
133
|
type: VerificationType.Social;
|
|
88
134
|
id: string;
|
|
89
135
|
connectorId: string;
|
|
136
|
+
encryptedTokenSet?: {
|
|
137
|
+
metadata: {
|
|
138
|
+
hasRefreshToken: boolean;
|
|
139
|
+
scope?: string | undefined;
|
|
140
|
+
expiresAt?: number | undefined;
|
|
141
|
+
tokenType?: string | undefined;
|
|
142
|
+
};
|
|
143
|
+
encryptedTokenSetBase64: string;
|
|
144
|
+
} | undefined;
|
|
90
145
|
socialUserInfo?: {
|
|
91
146
|
id: string;
|
|
92
147
|
name?: string | undefined;
|
|
@@ -104,3 +159,112 @@ export declare const socialVerificationRecordDataGuard: z.ZodObject<{
|
|
|
104
159
|
state: z.ZodOptional<z.ZodString>;
|
|
105
160
|
}, z.ZodUnknown, "strip"> | undefined;
|
|
106
161
|
}>;
|
|
162
|
+
export type SanitizedSocialVerificationRecordData = Omit<SocialVerificationRecordData, 'encryptedTokenSet' | 'connectorSession'>;
|
|
163
|
+
export declare const sanitizedSocialVerificationRecordDataGuard: z.ZodObject<Omit<{
|
|
164
|
+
id: z.ZodString;
|
|
165
|
+
connectorId: z.ZodString;
|
|
166
|
+
type: z.ZodLiteral<VerificationType.Social>;
|
|
167
|
+
socialUserInfo: z.ZodOptional<z.ZodObject<{
|
|
168
|
+
id: z.ZodString;
|
|
169
|
+
email: z.ZodOptional<z.ZodString>;
|
|
170
|
+
phone: z.ZodOptional<z.ZodString>;
|
|
171
|
+
name: z.ZodOptional<z.ZodString>;
|
|
172
|
+
avatar: z.ZodOptional<z.ZodString>;
|
|
173
|
+
rawData: z.ZodOptional<z.ZodType<import("@withtyped/server").Json, z.ZodTypeDef, import("@withtyped/server").Json>>;
|
|
174
|
+
}, "strip", z.ZodTypeAny, {
|
|
175
|
+
id: string;
|
|
176
|
+
name?: string | undefined;
|
|
177
|
+
email?: string | undefined;
|
|
178
|
+
phone?: string | undefined;
|
|
179
|
+
avatar?: string | undefined;
|
|
180
|
+
rawData?: import("@withtyped/server").Json | undefined;
|
|
181
|
+
}, {
|
|
182
|
+
id: string;
|
|
183
|
+
name?: string | undefined;
|
|
184
|
+
email?: string | undefined;
|
|
185
|
+
phone?: string | undefined;
|
|
186
|
+
avatar?: string | undefined;
|
|
187
|
+
rawData?: import("@withtyped/server").Json | undefined;
|
|
188
|
+
}>>;
|
|
189
|
+
encryptedTokenSet: z.ZodOptional<z.ZodObject<{
|
|
190
|
+
encryptedTokenSetBase64: z.ZodString;
|
|
191
|
+
metadata: z.ZodObject<{
|
|
192
|
+
scope: z.ZodOptional<z.ZodString>;
|
|
193
|
+
expiresAt: z.ZodOptional<z.ZodNumber>;
|
|
194
|
+
tokenType: z.ZodOptional<z.ZodString>;
|
|
195
|
+
hasRefreshToken: z.ZodBoolean;
|
|
196
|
+
}, "strip", z.ZodTypeAny, {
|
|
197
|
+
hasRefreshToken: boolean;
|
|
198
|
+
scope?: string | undefined;
|
|
199
|
+
expiresAt?: number | undefined;
|
|
200
|
+
tokenType?: string | undefined;
|
|
201
|
+
}, {
|
|
202
|
+
hasRefreshToken: boolean;
|
|
203
|
+
scope?: string | undefined;
|
|
204
|
+
expiresAt?: number | undefined;
|
|
205
|
+
tokenType?: string | undefined;
|
|
206
|
+
}>;
|
|
207
|
+
}, "strip", z.ZodTypeAny, {
|
|
208
|
+
metadata: {
|
|
209
|
+
hasRefreshToken: boolean;
|
|
210
|
+
scope?: string | undefined;
|
|
211
|
+
expiresAt?: number | undefined;
|
|
212
|
+
tokenType?: string | undefined;
|
|
213
|
+
};
|
|
214
|
+
encryptedTokenSetBase64: string;
|
|
215
|
+
}, {
|
|
216
|
+
metadata: {
|
|
217
|
+
hasRefreshToken: boolean;
|
|
218
|
+
scope?: string | undefined;
|
|
219
|
+
expiresAt?: number | undefined;
|
|
220
|
+
tokenType?: string | undefined;
|
|
221
|
+
};
|
|
222
|
+
encryptedTokenSetBase64: string;
|
|
223
|
+
}>>;
|
|
224
|
+
connectorSession: z.ZodOptional<z.ZodObject<{
|
|
225
|
+
nonce: z.ZodOptional<z.ZodString>;
|
|
226
|
+
redirectUri: z.ZodOptional<z.ZodString>;
|
|
227
|
+
connectorId: z.ZodOptional<z.ZodString>;
|
|
228
|
+
connectorFactoryId: z.ZodOptional<z.ZodString>;
|
|
229
|
+
jti: z.ZodOptional<z.ZodString>;
|
|
230
|
+
state: z.ZodOptional<z.ZodString>;
|
|
231
|
+
}, "strip", z.ZodUnknown, z.objectOutputType<{
|
|
232
|
+
nonce: z.ZodOptional<z.ZodString>;
|
|
233
|
+
redirectUri: z.ZodOptional<z.ZodString>;
|
|
234
|
+
connectorId: z.ZodOptional<z.ZodString>;
|
|
235
|
+
connectorFactoryId: z.ZodOptional<z.ZodString>;
|
|
236
|
+
jti: z.ZodOptional<z.ZodString>;
|
|
237
|
+
state: z.ZodOptional<z.ZodString>;
|
|
238
|
+
}, z.ZodUnknown, "strip">, z.objectInputType<{
|
|
239
|
+
nonce: z.ZodOptional<z.ZodString>;
|
|
240
|
+
redirectUri: z.ZodOptional<z.ZodString>;
|
|
241
|
+
connectorId: z.ZodOptional<z.ZodString>;
|
|
242
|
+
connectorFactoryId: z.ZodOptional<z.ZodString>;
|
|
243
|
+
jti: z.ZodOptional<z.ZodString>;
|
|
244
|
+
state: z.ZodOptional<z.ZodString>;
|
|
245
|
+
}, z.ZodUnknown, "strip">>>;
|
|
246
|
+
}, "encryptedTokenSet" | "connectorSession">, "strip", z.ZodTypeAny, {
|
|
247
|
+
type: VerificationType.Social;
|
|
248
|
+
id: string;
|
|
249
|
+
connectorId: string;
|
|
250
|
+
socialUserInfo?: {
|
|
251
|
+
id: string;
|
|
252
|
+
name?: string | undefined;
|
|
253
|
+
email?: string | undefined;
|
|
254
|
+
phone?: string | undefined;
|
|
255
|
+
avatar?: string | undefined;
|
|
256
|
+
rawData?: import("@withtyped/server").Json | undefined;
|
|
257
|
+
} | undefined;
|
|
258
|
+
}, {
|
|
259
|
+
type: VerificationType.Social;
|
|
260
|
+
id: string;
|
|
261
|
+
connectorId: string;
|
|
262
|
+
socialUserInfo?: {
|
|
263
|
+
id: string;
|
|
264
|
+
name?: string | undefined;
|
|
265
|
+
email?: string | undefined;
|
|
266
|
+
phone?: string | undefined;
|
|
267
|
+
avatar?: string | undefined;
|
|
268
|
+
rawData?: import("@withtyped/server").Json | undefined;
|
|
269
|
+
} | undefined;
|
|
270
|
+
}>;
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import { connectorSessionGuard, socialUserInfoGuard, } from '@logto/connector-kit';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
+
import { encryptedTokenSetGuard } from '../secrets.js';
|
|
3
4
|
import { VerificationType } from './verification-type.js';
|
|
4
5
|
export const socialVerificationRecordDataGuard = z.object({
|
|
5
6
|
id: z.string(),
|
|
6
7
|
connectorId: z.string(),
|
|
7
8
|
type: z.literal(VerificationType.Social),
|
|
8
9
|
socialUserInfo: socialUserInfoGuard.optional(),
|
|
10
|
+
encryptedTokenSet: encryptedTokenSetGuard.optional(),
|
|
9
11
|
connectorSession: connectorSessionGuard.optional(),
|
|
10
12
|
});
|
|
13
|
+
export const sanitizedSocialVerificationRecordDataGuard = socialVerificationRecordDataGuard.omit({
|
|
14
|
+
encryptedTokenSet: true,
|
|
15
|
+
connectorSession: true,
|
|
16
|
+
});
|
|
@@ -27,3 +27,21 @@ export declare const totpVerificationRecordDataGuard: z.ZodObject<{
|
|
|
27
27
|
verified: boolean;
|
|
28
28
|
secret?: string | undefined;
|
|
29
29
|
}>;
|
|
30
|
+
export type SanitizedTotpVerificationRecordData = Omit<TotpVerificationRecordData, 'secret'>;
|
|
31
|
+
export declare const sanitizedTotpVerificationRecordDataGuard: z.ZodObject<Omit<{
|
|
32
|
+
id: z.ZodString;
|
|
33
|
+
type: z.ZodLiteral<VerificationType.TOTP>;
|
|
34
|
+
userId: z.ZodString;
|
|
35
|
+
secret: z.ZodOptional<z.ZodString>;
|
|
36
|
+
verified: z.ZodBoolean;
|
|
37
|
+
}, "secret">, "strip", z.ZodTypeAny, {
|
|
38
|
+
type: VerificationType.TOTP;
|
|
39
|
+
id: string;
|
|
40
|
+
userId: string;
|
|
41
|
+
verified: boolean;
|
|
42
|
+
}, {
|
|
43
|
+
type: VerificationType.TOTP;
|
|
44
|
+
id: string;
|
|
45
|
+
userId: string;
|
|
46
|
+
verified: boolean;
|
|
47
|
+
}>;
|
|
@@ -78,3 +78,47 @@ export declare const webAuthnVerificationRecordDataGuard: z.ZodObject<{
|
|
|
78
78
|
name?: string | undefined;
|
|
79
79
|
} | undefined;
|
|
80
80
|
}>;
|
|
81
|
+
export type SanitizedWebAuthnVerificationRecordData = Omit<WebAuthnVerificationRecordData, 'registrationInfo' | 'registrationChallenge' | 'authenticationChallenge'>;
|
|
82
|
+
export declare const sanitizedWebAuthnVerificationRecordDataGuard: z.ZodObject<Omit<{
|
|
83
|
+
id: z.ZodString;
|
|
84
|
+
type: z.ZodLiteral<VerificationType.WebAuthn>;
|
|
85
|
+
userId: z.ZodString;
|
|
86
|
+
verified: z.ZodBoolean;
|
|
87
|
+
registrationChallenge: z.ZodOptional<z.ZodString>;
|
|
88
|
+
authenticationChallenge: z.ZodOptional<z.ZodString>;
|
|
89
|
+
registrationInfo: z.ZodOptional<z.ZodObject<{
|
|
90
|
+
type: z.ZodLiteral<import("../../index.js").MfaFactor.WebAuthn>;
|
|
91
|
+
credentialId: z.ZodString;
|
|
92
|
+
publicKey: z.ZodString;
|
|
93
|
+
transports: z.ZodArray<z.ZodEnum<["usb", "nfc", "ble", "internal", "cable", "hybrid", "smart-card"]>, "many">;
|
|
94
|
+
counter: z.ZodNumber;
|
|
95
|
+
agent: z.ZodString;
|
|
96
|
+
name: z.ZodOptional<z.ZodString>;
|
|
97
|
+
}, "strip", z.ZodTypeAny, {
|
|
98
|
+
type: import("../../index.js").MfaFactor.WebAuthn;
|
|
99
|
+
credentialId: string;
|
|
100
|
+
publicKey: string;
|
|
101
|
+
transports: ("usb" | "nfc" | "ble" | "internal" | "cable" | "hybrid" | "smart-card")[];
|
|
102
|
+
counter: number;
|
|
103
|
+
agent: string;
|
|
104
|
+
name?: string | undefined;
|
|
105
|
+
}, {
|
|
106
|
+
type: import("../../index.js").MfaFactor.WebAuthn;
|
|
107
|
+
credentialId: string;
|
|
108
|
+
publicKey: string;
|
|
109
|
+
transports: ("usb" | "nfc" | "ble" | "internal" | "cable" | "hybrid" | "smart-card")[];
|
|
110
|
+
counter: number;
|
|
111
|
+
agent: string;
|
|
112
|
+
name?: string | undefined;
|
|
113
|
+
}>>;
|
|
114
|
+
}, "registrationChallenge" | "authenticationChallenge" | "registrationInfo">, "strip", z.ZodTypeAny, {
|
|
115
|
+
type: VerificationType.WebAuthn;
|
|
116
|
+
id: string;
|
|
117
|
+
userId: string;
|
|
118
|
+
verified: boolean;
|
|
119
|
+
}, {
|
|
120
|
+
type: VerificationType.WebAuthn;
|
|
121
|
+
id: string;
|
|
122
|
+
userId: string;
|
|
123
|
+
verified: boolean;
|
|
124
|
+
}>;
|
|
@@ -10,3 +10,8 @@ export const webAuthnVerificationRecordDataGuard = z.object({
|
|
|
10
10
|
authenticationChallenge: z.string().optional(),
|
|
11
11
|
registrationInfo: bindWebAuthnGuard.optional(),
|
|
12
12
|
});
|
|
13
|
+
export const sanitizedWebAuthnVerificationRecordDataGuard = webAuthnVerificationRecordDataGuard.omit({
|
|
14
|
+
registrationInfo: true,
|
|
15
|
+
registrationChallenge: true,
|
|
16
|
+
authenticationChallenge: true,
|
|
17
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logto/schemas",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.30.0",
|
|
4
4
|
"author": "Silverhand Inc. <contact@silverhand.io>",
|
|
5
5
|
"license": "MPL-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -63,14 +63,14 @@
|
|
|
63
63
|
},
|
|
64
64
|
"prettier": "@silverhand/eslint-config/.prettierrc",
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@
|
|
66
|
+
"@withtyped/server": "^0.14.0",
|
|
67
|
+
"nanoid": "^5.0.9",
|
|
68
|
+
"@logto/connector-kit": "^4.4.0",
|
|
67
69
|
"@logto/core-kit": "^2.6.0",
|
|
68
70
|
"@logto/language-kit": "^1.2.0",
|
|
69
|
-
"@logto/phrases": "^1.19.0",
|
|
70
|
-
"@logto/phrases-experience": "^1.10.0",
|
|
71
71
|
"@logto/shared": "^3.3.0",
|
|
72
|
-
"@
|
|
73
|
-
"
|
|
72
|
+
"@logto/phrases": "^1.19.0",
|
|
73
|
+
"@logto/phrases-experience": "^1.10.0"
|
|
74
74
|
},
|
|
75
75
|
"peerDependencies": {
|
|
76
76
|
"zod": "3.24.3"
|
|
@@ -3,7 +3,7 @@ create table account_centers (
|
|
|
3
3
|
references tenants (id) on update cascade on delete cascade,
|
|
4
4
|
id varchar(21) not null,
|
|
5
5
|
/** The whole feature can be disabled */
|
|
6
|
-
enabled boolean not null default
|
|
6
|
+
enabled boolean not null default true,
|
|
7
7
|
/** Control each fields */
|
|
8
8
|
fields jsonb /* @use AccountCenterFieldControl */ not null default '{}'::jsonb,
|
|
9
9
|
webauthn_related_origins jsonb /* @use WebauthnRelatedOrigins */ not null default '[]'::jsonb,
|
package/tables/connectors.sql
CHANGED
|
@@ -5,6 +5,8 @@ create table connectors (
|
|
|
5
5
|
references tenants (id) on update cascade on delete cascade,
|
|
6
6
|
id varchar(128) not null,
|
|
7
7
|
sync_profile boolean not null default FALSE,
|
|
8
|
+
/** Whether the token storage is enabled for this connector. Only applied for OAuth2/OIDC social connectors. */
|
|
9
|
+
enable_token_storage boolean not null default FALSE,
|
|
8
10
|
connector_id varchar(128) not null,
|
|
9
11
|
config jsonb /* @use JsonObject */ not null default '{}'::jsonb,
|
|
10
12
|
metadata jsonb /* @use ConfigurableConnectorMetadata */ not null default '{}'::jsonb,
|
|
@@ -8,5 +8,8 @@ create table organization_user_relations (
|
|
|
8
8
|
references organizations (id) on update cascade on delete cascade,
|
|
9
9
|
user_id varchar(21) not null
|
|
10
10
|
references users (id) on update cascade on delete cascade,
|
|
11
|
-
primary key (tenant_id, organization_id, user_id)
|
|
11
|
+
primary key (tenant_id, organization_id, user_id),
|
|
12
|
+
constraint organization_user_relations__user_id__fk
|
|
13
|
+
foreign key (tenant_id, user_id)
|
|
14
|
+
references users (tenant_id, id) on update cascade on delete cascade
|
|
12
15
|
);
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/* init_order = 3 */
|
|
2
|
+
|
|
3
|
+
create table secret_enterprise_sso_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
|
+
/** 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.*/
|
|
9
|
+
sso_connector_id varchar(128) not null
|
|
10
|
+
references sso_connectors (id) on update cascade,
|
|
11
|
+
/** User SSO connector issuer. Only present for secrets that store SSO connector tokens. */
|
|
12
|
+
issuer varchar(256) not null,
|
|
13
|
+
/** User SSO identity ID. Only present for secrets that store SSO identity tokens. */
|
|
14
|
+
identity_id varchar(128) not null,
|
|
15
|
+
primary key (tenant_id, secret_id),
|
|
16
|
+
/** Ensures that each SSO identity is associated with only one secret. */
|
|
17
|
+
foreign key (tenant_id, issuer, identity_id)
|
|
18
|
+
references user_sso_identities (tenant_id, issuer, identity_id) on update cascade
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
/** Trigger function to delete secrets when the SSO connector is deleted. */
|
|
22
|
+
create function delete_secrets_on_sso_connector_delete()
|
|
23
|
+
returns trigger as $$
|
|
24
|
+
begin
|
|
25
|
+
delete from secrets
|
|
26
|
+
where id in (
|
|
27
|
+
select secret_id from secret_enterprise_sso_connector_relations
|
|
28
|
+
where tenant_id = old.tenant_id and sso_connector_id = old.id
|
|
29
|
+
);
|
|
30
|
+
return old;
|
|
31
|
+
end;
|
|
32
|
+
$$ language plpgsql;
|
|
33
|
+
|
|
34
|
+
create trigger delete_secrets_before_sso_connector_delete
|
|
35
|
+
before delete on sso_connectors
|
|
36
|
+
for each row
|
|
37
|
+
execute procedure delete_secrets_on_sso_connector_delete();
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
/** Trigger function to delete secret when the SSO identity is deleted. */
|
|
41
|
+
create function delete_secret_on_sso_identity_delete()
|
|
42
|
+
returns trigger as $$
|
|
43
|
+
begin
|
|
44
|
+
delete from secrets
|
|
45
|
+
where id in (
|
|
46
|
+
select secret_id from secret_enterprise_sso_connector_relations
|
|
47
|
+
where tenant_id = old.tenant_id
|
|
48
|
+
and issuer = old.issuer
|
|
49
|
+
and identity_id = old.identity_id
|
|
50
|
+
)
|
|
51
|
+
-- we also need to ensure that the secret is associated with the correct user
|
|
52
|
+
and user_id = old.user_id;
|
|
53
|
+
return old;
|
|
54
|
+
end;
|
|
55
|
+
$$ language plpgsql;
|
|
56
|
+
|
|
57
|
+
create trigger delete_secret_before_sso_identity_delete
|
|
58
|
+
before delete on user_sso_identities
|
|
59
|
+
for each row
|
|
60
|
+
execute procedure delete_secret_on_sso_identity_delete();
|