@logto/schemas 1.38.0 → 1.39.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.39.0-1774752400-add-delete-account-url.ts +20 -0
- package/alterations/1.39.0-1774770686-add-account-center-custom-css.ts +20 -0
- package/alterations/1.39.0-1776502301-add-sign-up-profile-fields.ts +20 -0
- package/alterations-js/1.39.0-1774752400-add-delete-account-url.js +16 -0
- package/alterations-js/1.39.0-1774770686-add-account-center-custom-css.js +16 -0
- package/alterations-js/1.39.0-1776502301-add-sign-up-profile-fields.js +16 -0
- package/lib/db-entries/account-center.d.ts +9 -1
- package/lib/db-entries/account-center.js +8 -0
- package/lib/db-entries/sign-in-experience.d.ts +6 -2
- package/lib/db-entries/sign-in-experience.js +5 -1
- package/lib/foundations/jsonb-types/account-centers.d.ts +1 -0
- package/lib/foundations/jsonb-types/account-centers.js +8 -0
- package/lib/foundations/jsonb-types/sign-in-experience.d.ts +26 -0
- package/lib/foundations/jsonb-types/sign-in-experience.js +4 -0
- package/lib/types/alteration.d.ts +5 -0
- package/lib/types/application.d.ts +2 -2
- package/lib/types/custom-profile-fields.d.ts +7 -13
- package/lib/types/custom-profile-fields.js +6 -13
- package/lib/types/logto-config/index.d.ts +55 -2
- package/lib/types/logto-config/index.js +22 -4
- package/lib/types/logto-config/index.test.d.ts +1 -0
- package/lib/types/logto-config/index.test.js +29 -0
- package/lib/types/logto-config/jwt-customizer.d.ts +9 -0
- package/lib/types/logto-config/jwt-customizer.js +1 -0
- package/lib/types/logto-config/jwt-customizer.test.js +14 -2
- package/lib/types/onboarding.d.ts +93 -1
- package/lib/types/onboarding.js +22 -1
- package/lib/types/sign-in-experience.d.ts +9 -2
- package/lib/types/user-logto-config.d.ts +11 -0
- package/lib/types/user-logto-config.js +6 -0
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +1 -0
- package/lib/utils/oidc-private-key.d.ts +88 -0
- package/lib/utils/oidc-private-key.js +163 -0
- package/lib/utils/oidc-private-key.test.d.ts +1 -0
- package/lib/utils/oidc-private-key.test.js +128 -0
- package/package.json +6 -6
- package/tables/account_centers.sql +4 -0
- package/tables/sign_in_experiences.sql +2 -0
|
@@ -33,11 +33,20 @@ export const oidcConfigKeyGuard = z.object({
|
|
|
33
33
|
value: z.string(),
|
|
34
34
|
createdAt: z.number(),
|
|
35
35
|
});
|
|
36
|
+
export var OidcSigningKeyStatus;
|
|
37
|
+
(function (OidcSigningKeyStatus) {
|
|
38
|
+
OidcSigningKeyStatus["Next"] = "Next";
|
|
39
|
+
OidcSigningKeyStatus["Current"] = "Current";
|
|
40
|
+
OidcSigningKeyStatus["Previous"] = "Previous";
|
|
41
|
+
})(OidcSigningKeyStatus || (OidcSigningKeyStatus = {}));
|
|
42
|
+
export const oidcPrivateKeyGuard = oidcConfigKeyGuard.extend({
|
|
43
|
+
status: z.nativeEnum(OidcSigningKeyStatus).optional(),
|
|
44
|
+
});
|
|
36
45
|
export const oidcSessionConfigGuard = z.object({
|
|
37
46
|
ttl: z.number().int().min(1).max(31_536_000).optional(),
|
|
38
47
|
});
|
|
39
48
|
export const logtoOidcConfigGuard = Object.freeze({
|
|
40
|
-
[LogtoOidcConfigKey.PrivateKeys]:
|
|
49
|
+
[LogtoOidcConfigKey.PrivateKeys]: oidcPrivateKeyGuard.array(),
|
|
41
50
|
[LogtoOidcConfigKey.CookieKeys]: oidcConfigKeyGuard.array(),
|
|
42
51
|
// Session config is optional, if not set, it will fallback to default value in core.
|
|
43
52
|
[LogtoOidcConfigKey.Session]: oidcSessionConfigGuard.nullish().transform((data) => data ?? {}),
|
|
@@ -96,6 +105,10 @@ export const extendedIdTokenClaimsGuard = z.enum(extendedIdTokenClaims);
|
|
|
96
105
|
export const idTokenConfigGuard = z.object({
|
|
97
106
|
enabledExtendedClaims: extendedIdTokenClaimsGuard.array().optional(),
|
|
98
107
|
});
|
|
108
|
+
export const signingKeyRotationStateGuard = z.object({
|
|
109
|
+
tenantCacheExpiresAt: z.number().optional(),
|
|
110
|
+
signingKeyRotationAt: z.number().optional(),
|
|
111
|
+
});
|
|
99
112
|
export var LogtoTenantConfigKey;
|
|
100
113
|
(function (LogtoTenantConfigKey) {
|
|
101
114
|
LogtoTenantConfigKey["AdminConsole"] = "adminConsole";
|
|
@@ -104,12 +117,15 @@ export var LogtoTenantConfigKey;
|
|
|
104
117
|
LogtoTenantConfigKey["SessionNotFoundRedirectUrl"] = "sessionNotFoundRedirectUrl";
|
|
105
118
|
/** ID token configuration for extended claims. */
|
|
106
119
|
LogtoTenantConfigKey["IdToken"] = "idToken";
|
|
120
|
+
/** Tenant-scoped rotation state for staged private signing key activation. */
|
|
121
|
+
LogtoTenantConfigKey["SigningKeyRotationState"] = "signingKeyRotationState";
|
|
107
122
|
})(LogtoTenantConfigKey || (LogtoTenantConfigKey = {}));
|
|
108
123
|
export const logtoTenantConfigGuard = Object.freeze({
|
|
109
124
|
[LogtoTenantConfigKey.AdminConsole]: adminConsoleDataGuard,
|
|
110
125
|
[LogtoTenantConfigKey.CloudConnection]: cloudConnectionDataGuard,
|
|
111
126
|
[LogtoTenantConfigKey.SessionNotFoundRedirectUrl]: z.object({ url: z.string() }),
|
|
112
127
|
[LogtoTenantConfigKey.IdToken]: idTokenConfigGuard,
|
|
128
|
+
[LogtoTenantConfigKey.SigningKeyRotationState]: signingKeyRotationStateGuard,
|
|
113
129
|
});
|
|
114
130
|
export const logtoConfigKeys = Object.freeze([
|
|
115
131
|
...Object.values(LogtoOidcConfigKey),
|
|
@@ -121,6 +137,8 @@ export const logtoConfigGuards = Object.freeze({
|
|
|
121
137
|
...jwtCustomizerConfigGuard,
|
|
122
138
|
...logtoTenantConfigGuard,
|
|
123
139
|
});
|
|
124
|
-
export const oidcConfigKeysResponseGuard = oidcConfigKeyGuard
|
|
125
|
-
.
|
|
126
|
-
|
|
140
|
+
export const oidcConfigKeysResponseGuard = oidcConfigKeyGuard.omit({ value: true }).merge(z.object({
|
|
141
|
+
signingKeyAlgorithm: z.nativeEnum(SupportedSigningKeyAlgorithm).optional(),
|
|
142
|
+
status: z.nativeEnum(OidcSigningKeyStatus).optional(),
|
|
143
|
+
effectiveAt: z.number().optional(),
|
|
144
|
+
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { LogtoOidcConfigKey, LogtoTenantConfigKey, OidcSigningKeyStatus, logtoOidcConfigGuard, logtoTenantConfigGuard, oidcConfigKeysResponseGuard, } from './index.js';
|
|
3
|
+
describe('logto config guards', () => {
|
|
4
|
+
it('accepts legacy private keys without status', () => {
|
|
5
|
+
const privateKeys = [
|
|
6
|
+
{
|
|
7
|
+
id: 'key_1',
|
|
8
|
+
value: 'private-key-1',
|
|
9
|
+
createdAt: 1_710_000_000_000,
|
|
10
|
+
},
|
|
11
|
+
];
|
|
12
|
+
const result = logtoOidcConfigGuard[LogtoOidcConfigKey.PrivateKeys].safeParse(privateKeys);
|
|
13
|
+
expect(result.success).toBe(true);
|
|
14
|
+
});
|
|
15
|
+
it('accepts signing key status in OIDC key responses', () => {
|
|
16
|
+
const result = oidcConfigKeysResponseGuard.safeParse({
|
|
17
|
+
id: 'key_1',
|
|
18
|
+
createdAt: 1_710_000_000_000,
|
|
19
|
+
status: OidcSigningKeyStatus.Current,
|
|
20
|
+
});
|
|
21
|
+
expect(result.success).toBe(true);
|
|
22
|
+
});
|
|
23
|
+
it('accepts partial signing key rotation state', () => {
|
|
24
|
+
const result = logtoTenantConfigGuard[LogtoTenantConfigKey.SigningKeyRotationState].safeParse({
|
|
25
|
+
signingKeyRotationAt: 1_710_000_000_000,
|
|
26
|
+
});
|
|
27
|
+
expect(result.success).toBe(true);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
@@ -10,14 +10,17 @@ export declare const jwtCustomizerGuard: z.ZodObject<{
|
|
|
10
10
|
script: z.ZodString;
|
|
11
11
|
environmentVariables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
12
12
|
contextSample: z.ZodOptional<z.ZodRecord<z.ZodString, ZodType<import("@withtyped/server/lib/types.js").Json, z.ZodTypeDef, import("@withtyped/server/lib/types.js").Json>>>;
|
|
13
|
+
blockIssuanceOnError: z.ZodOptional<z.ZodBoolean>;
|
|
13
14
|
}, "strip", z.ZodTypeAny, {
|
|
14
15
|
script: string;
|
|
15
16
|
environmentVariables?: Record<string, string> | undefined;
|
|
16
17
|
contextSample?: Record<string, import("@withtyped/server/lib/types.js").Json> | undefined;
|
|
18
|
+
blockIssuanceOnError?: boolean | undefined;
|
|
17
19
|
}, {
|
|
18
20
|
script: string;
|
|
19
21
|
environmentVariables?: Record<string, string> | undefined;
|
|
20
22
|
contextSample?: Record<string, import("@withtyped/server/lib/types.js").Json> | undefined;
|
|
23
|
+
blockIssuanceOnError?: boolean | undefined;
|
|
21
24
|
}>;
|
|
22
25
|
export declare enum LogtoJwtTokenKeyType {
|
|
23
26
|
AccessToken = "access-token",
|
|
@@ -1268,6 +1271,7 @@ export declare const jwtCustomizerApplicationContextGuard: z.ZodObject<Omit<{
|
|
|
1268
1271
|
export declare const accessTokenJwtCustomizerGuard: z.ZodObject<{
|
|
1269
1272
|
script: z.ZodString;
|
|
1270
1273
|
environmentVariables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
1274
|
+
blockIssuanceOnError: z.ZodOptional<z.ZodBoolean>;
|
|
1271
1275
|
} & {
|
|
1272
1276
|
tokenSample: z.ZodOptional<z.ZodObject<{
|
|
1273
1277
|
accountId: z.ZodOptional<z.ZodString>;
|
|
@@ -3320,6 +3324,7 @@ export declare const accessTokenJwtCustomizerGuard: z.ZodObject<{
|
|
|
3320
3324
|
signInContext?: Record<string, string> | undefined;
|
|
3321
3325
|
} | undefined;
|
|
3322
3326
|
} | undefined;
|
|
3327
|
+
blockIssuanceOnError?: boolean | undefined;
|
|
3323
3328
|
tokenSample?: {
|
|
3324
3329
|
grantId?: string | undefined;
|
|
3325
3330
|
sid?: string | undefined;
|
|
@@ -3577,6 +3582,7 @@ export declare const accessTokenJwtCustomizerGuard: z.ZodObject<{
|
|
|
3577
3582
|
signInContext?: Record<string, string> | undefined;
|
|
3578
3583
|
} | undefined;
|
|
3579
3584
|
} | undefined;
|
|
3585
|
+
blockIssuanceOnError?: boolean | undefined;
|
|
3580
3586
|
tokenSample?: {
|
|
3581
3587
|
grantId?: string | undefined;
|
|
3582
3588
|
sid?: string | undefined;
|
|
@@ -3595,6 +3601,7 @@ export type AccessTokenJwtCustomizer = z.infer<typeof accessTokenJwtCustomizerGu
|
|
|
3595
3601
|
export declare const clientCredentialsJwtCustomizerGuard: z.ZodObject<{
|
|
3596
3602
|
script: z.ZodString;
|
|
3597
3603
|
environmentVariables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
3604
|
+
blockIssuanceOnError: z.ZodOptional<z.ZodBoolean>;
|
|
3598
3605
|
} & {
|
|
3599
3606
|
tokenSample: z.ZodOptional<z.ZodObject<{
|
|
3600
3607
|
kind: z.ZodOptional<z.ZodLiteral<"ClientCredentials">>;
|
|
@@ -3973,6 +3980,7 @@ export declare const clientCredentialsJwtCustomizerGuard: z.ZodObject<{
|
|
|
3973
3980
|
isThirdParty?: boolean | undefined;
|
|
3974
3981
|
} | undefined;
|
|
3975
3982
|
} | undefined;
|
|
3983
|
+
blockIssuanceOnError?: boolean | undefined;
|
|
3976
3984
|
tokenSample?: {
|
|
3977
3985
|
jti?: string | undefined;
|
|
3978
3986
|
kind?: "ClientCredentials" | undefined;
|
|
@@ -4037,6 +4045,7 @@ export declare const clientCredentialsJwtCustomizerGuard: z.ZodObject<{
|
|
|
4037
4045
|
isThirdParty?: boolean | undefined;
|
|
4038
4046
|
} | undefined;
|
|
4039
4047
|
} | undefined;
|
|
4048
|
+
blockIssuanceOnError?: boolean | undefined;
|
|
4040
4049
|
tokenSample?: {
|
|
4041
4050
|
jti?: string | undefined;
|
|
4042
4051
|
kind?: "ClientCredentials" | undefined;
|
|
@@ -20,6 +20,7 @@ export const jwtCustomizerGuard = z.object({
|
|
|
20
20
|
script: z.string(),
|
|
21
21
|
environmentVariables: z.record(z.string()).optional(),
|
|
22
22
|
contextSample: jsonObjectGuard.optional(),
|
|
23
|
+
blockIssuanceOnError: z.boolean().optional(),
|
|
23
24
|
});
|
|
24
25
|
export var LogtoJwtTokenKeyType;
|
|
25
26
|
(function (LogtoJwtTokenKeyType) {
|
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
import { pick } from '@silverhand/essentials';
|
|
2
2
|
import { describe, expect, it } from 'vitest';
|
|
3
3
|
import { accessTokenJwtCustomizerGuard, clientCredentialsJwtCustomizerGuard, } from './jwt-customizer.js';
|
|
4
|
-
const allFields = [
|
|
4
|
+
const allFields = [
|
|
5
|
+
'script',
|
|
6
|
+
'environmentVariables',
|
|
7
|
+
'contextSample',
|
|
8
|
+
'tokenSample',
|
|
9
|
+
'blockIssuanceOnError',
|
|
10
|
+
];
|
|
5
11
|
const requiredFields = ['script'];
|
|
6
|
-
const optionalFields = [
|
|
12
|
+
const optionalFields = [
|
|
13
|
+
'environmentVariables',
|
|
14
|
+
'contextSample',
|
|
15
|
+
'tokenSample',
|
|
16
|
+
'blockIssuanceOnError',
|
|
17
|
+
];
|
|
7
18
|
const testClientCredentialsTokenPayload = {
|
|
8
19
|
script: '',
|
|
9
20
|
environmentVariables: {},
|
|
@@ -14,6 +25,7 @@ const testClientCredentialsTokenPayload = {
|
|
|
14
25
|
},
|
|
15
26
|
},
|
|
16
27
|
tokenSample: {},
|
|
28
|
+
blockIssuanceOnError: false,
|
|
17
29
|
};
|
|
18
30
|
const testAccessTokenPayload = {
|
|
19
31
|
...testClientCredentialsTokenPayload,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
export declare const userOnboardingDataKey = "onboarding";
|
|
3
|
+
export declare const ossUserOnboardingDataKey = "ossOnboarding";
|
|
3
4
|
export declare enum Project {
|
|
4
5
|
Personal = "personal",
|
|
5
6
|
Company = "company"
|
|
@@ -18,7 +19,6 @@ export declare enum Title {
|
|
|
18
19
|
Product = "product",
|
|
19
20
|
Others = "others"
|
|
20
21
|
}
|
|
21
|
-
/** @deprecated */
|
|
22
22
|
export declare enum CompanySize {
|
|
23
23
|
Scale1 = "1",
|
|
24
24
|
Scale2 = "2-49",
|
|
@@ -81,6 +81,52 @@ declare const questionnaireGuard: z.ZodObject<{
|
|
|
81
81
|
additionalFeatures?: AdditionalFeatures[] | undefined;
|
|
82
82
|
}>;
|
|
83
83
|
export type Questionnaire = z.infer<typeof questionnaireGuard>;
|
|
84
|
+
declare const ossQuestionnaireGuard: z.ZodObject<{
|
|
85
|
+
emailAddress: z.ZodOptional<z.ZodString>;
|
|
86
|
+
newsletter: z.ZodOptional<z.ZodBoolean>;
|
|
87
|
+
project: z.ZodOptional<z.ZodNativeEnum<typeof Project>>;
|
|
88
|
+
projectName: z.ZodOptional<z.ZodString>;
|
|
89
|
+
companyName: z.ZodOptional<z.ZodString>;
|
|
90
|
+
companySize: z.ZodOptional<z.ZodNativeEnum<typeof CompanySize>>;
|
|
91
|
+
}, "strip", z.ZodTypeAny, {
|
|
92
|
+
project?: Project | undefined;
|
|
93
|
+
companyName?: string | undefined;
|
|
94
|
+
companySize?: CompanySize | undefined;
|
|
95
|
+
emailAddress?: string | undefined;
|
|
96
|
+
newsletter?: boolean | undefined;
|
|
97
|
+
projectName?: string | undefined;
|
|
98
|
+
}, {
|
|
99
|
+
project?: Project | undefined;
|
|
100
|
+
companyName?: string | undefined;
|
|
101
|
+
companySize?: CompanySize | undefined;
|
|
102
|
+
emailAddress?: string | undefined;
|
|
103
|
+
newsletter?: boolean | undefined;
|
|
104
|
+
projectName?: string | undefined;
|
|
105
|
+
}>;
|
|
106
|
+
export type OssQuestionnaire = z.infer<typeof ossQuestionnaireGuard>;
|
|
107
|
+
export declare const ossSurveyReportPayloadGuard: z.ZodObject<{
|
|
108
|
+
emailAddress: z.ZodString;
|
|
109
|
+
newsletter: z.ZodOptional<z.ZodBoolean>;
|
|
110
|
+
project: z.ZodNativeEnum<typeof Project>;
|
|
111
|
+
projectName: z.ZodOptional<z.ZodString>;
|
|
112
|
+
companyName: z.ZodOptional<z.ZodString>;
|
|
113
|
+
companySize: z.ZodOptional<z.ZodNativeEnum<typeof CompanySize>>;
|
|
114
|
+
}, "strip", z.ZodTypeAny, {
|
|
115
|
+
project: Project;
|
|
116
|
+
emailAddress: string;
|
|
117
|
+
companyName?: string | undefined;
|
|
118
|
+
companySize?: CompanySize | undefined;
|
|
119
|
+
newsletter?: boolean | undefined;
|
|
120
|
+
projectName?: string | undefined;
|
|
121
|
+
}, {
|
|
122
|
+
project: Project;
|
|
123
|
+
emailAddress: string;
|
|
124
|
+
companyName?: string | undefined;
|
|
125
|
+
companySize?: CompanySize | undefined;
|
|
126
|
+
newsletter?: boolean | undefined;
|
|
127
|
+
projectName?: string | undefined;
|
|
128
|
+
}>;
|
|
129
|
+
export type OssSurveyReportPayload = z.infer<typeof ossSurveyReportPayloadGuard>;
|
|
84
130
|
export declare const userOnboardingDataGuard: z.ZodObject<{
|
|
85
131
|
questionnaire: z.ZodOptional<z.ZodObject<{
|
|
86
132
|
project: z.ZodOptional<z.ZodNativeEnum<typeof Project>>;
|
|
@@ -141,4 +187,50 @@ export declare const userOnboardingDataGuard: z.ZodObject<{
|
|
|
141
187
|
isOnboardingDone?: boolean | undefined;
|
|
142
188
|
}>;
|
|
143
189
|
export type UserOnboardingData = z.infer<typeof userOnboardingDataGuard>;
|
|
190
|
+
export declare const ossUserOnboardingDataGuard: z.ZodObject<{
|
|
191
|
+
questionnaire: z.ZodOptional<z.ZodObject<{
|
|
192
|
+
emailAddress: z.ZodOptional<z.ZodString>;
|
|
193
|
+
newsletter: z.ZodOptional<z.ZodBoolean>;
|
|
194
|
+
project: z.ZodOptional<z.ZodNativeEnum<typeof Project>>;
|
|
195
|
+
projectName: z.ZodOptional<z.ZodString>;
|
|
196
|
+
companyName: z.ZodOptional<z.ZodString>;
|
|
197
|
+
companySize: z.ZodOptional<z.ZodNativeEnum<typeof CompanySize>>;
|
|
198
|
+
}, "strip", z.ZodTypeAny, {
|
|
199
|
+
project?: Project | undefined;
|
|
200
|
+
companyName?: string | undefined;
|
|
201
|
+
companySize?: CompanySize | undefined;
|
|
202
|
+
emailAddress?: string | undefined;
|
|
203
|
+
newsletter?: boolean | undefined;
|
|
204
|
+
projectName?: string | undefined;
|
|
205
|
+
}, {
|
|
206
|
+
project?: Project | undefined;
|
|
207
|
+
companyName?: string | undefined;
|
|
208
|
+
companySize?: CompanySize | undefined;
|
|
209
|
+
emailAddress?: string | undefined;
|
|
210
|
+
newsletter?: boolean | undefined;
|
|
211
|
+
projectName?: string | undefined;
|
|
212
|
+
}>>;
|
|
213
|
+
isOnboardingDone: z.ZodOptional<z.ZodBoolean>;
|
|
214
|
+
}, "strip", z.ZodTypeAny, {
|
|
215
|
+
questionnaire?: {
|
|
216
|
+
project?: Project | undefined;
|
|
217
|
+
companyName?: string | undefined;
|
|
218
|
+
companySize?: CompanySize | undefined;
|
|
219
|
+
emailAddress?: string | undefined;
|
|
220
|
+
newsletter?: boolean | undefined;
|
|
221
|
+
projectName?: string | undefined;
|
|
222
|
+
} | undefined;
|
|
223
|
+
isOnboardingDone?: boolean | undefined;
|
|
224
|
+
}, {
|
|
225
|
+
questionnaire?: {
|
|
226
|
+
project?: Project | undefined;
|
|
227
|
+
companyName?: string | undefined;
|
|
228
|
+
companySize?: CompanySize | undefined;
|
|
229
|
+
emailAddress?: string | undefined;
|
|
230
|
+
newsletter?: boolean | undefined;
|
|
231
|
+
projectName?: string | undefined;
|
|
232
|
+
} | undefined;
|
|
233
|
+
isOnboardingDone?: boolean | undefined;
|
|
234
|
+
}>;
|
|
235
|
+
export type OssUserOnboardingData = z.infer<typeof ossUserOnboardingDataGuard>;
|
|
144
236
|
export {};
|
package/lib/types/onboarding.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
export const userOnboardingDataKey = 'onboarding';
|
|
3
|
+
export const ossUserOnboardingDataKey = 'ossOnboarding';
|
|
3
4
|
export var Project;
|
|
4
5
|
(function (Project) {
|
|
5
6
|
Project["Personal"] = "personal";
|
|
@@ -21,7 +22,6 @@ export var Title;
|
|
|
21
22
|
Title["Product"] = "product";
|
|
22
23
|
Title["Others"] = "others";
|
|
23
24
|
})(Title || (Title = {}));
|
|
24
|
-
/** @deprecated */
|
|
25
25
|
export var CompanySize;
|
|
26
26
|
(function (CompanySize) {
|
|
27
27
|
CompanySize["Scale1"] = "1";
|
|
@@ -30,6 +30,7 @@ export var CompanySize;
|
|
|
30
30
|
CompanySize["Scale4"] = "200-999";
|
|
31
31
|
CompanySize["Scale5"] = "1000+";
|
|
32
32
|
})(CompanySize || (CompanySize = {}));
|
|
33
|
+
// Kept as a shared enum for OSS onboarding and existing questionnaire payloads.
|
|
33
34
|
/** @deprecated */
|
|
34
35
|
export var Reason;
|
|
35
36
|
(function (Reason) {
|
|
@@ -69,7 +70,27 @@ const questionnaireGuard = z.object({
|
|
|
69
70
|
stage: z.nativeEnum(Stage).optional(),
|
|
70
71
|
additionalFeatures: z.array(z.nativeEnum(AdditionalFeatures)).optional(),
|
|
71
72
|
});
|
|
73
|
+
const ossQuestionnaireGuard = z.object({
|
|
74
|
+
emailAddress: z.string().optional(),
|
|
75
|
+
newsletter: z.boolean().optional(),
|
|
76
|
+
project: z.nativeEnum(Project).optional(),
|
|
77
|
+
projectName: z.string().max(200).optional(),
|
|
78
|
+
companyName: z.string().optional(),
|
|
79
|
+
companySize: z.nativeEnum(CompanySize).optional(),
|
|
80
|
+
});
|
|
81
|
+
export const ossSurveyReportPayloadGuard = z.object({
|
|
82
|
+
emailAddress: z.string().email().max(320),
|
|
83
|
+
newsletter: z.boolean().optional(),
|
|
84
|
+
project: z.nativeEnum(Project),
|
|
85
|
+
projectName: z.string().max(200).optional(),
|
|
86
|
+
companyName: z.string().max(200).optional(),
|
|
87
|
+
companySize: z.nativeEnum(CompanySize).optional(),
|
|
88
|
+
});
|
|
72
89
|
export const userOnboardingDataGuard = z.object({
|
|
73
90
|
questionnaire: questionnaireGuard.optional(),
|
|
74
91
|
isOnboardingDone: z.boolean().optional(),
|
|
75
92
|
});
|
|
93
|
+
export const ossUserOnboardingDataGuard = z.object({
|
|
94
|
+
questionnaire: ossQuestionnaireGuard.optional(),
|
|
95
|
+
isOnboardingDone: z.boolean().optional(),
|
|
96
|
+
});
|
|
@@ -143,6 +143,11 @@ export declare const fullSignInExperienceGuard: z.ZodObject<Omit<{
|
|
|
143
143
|
emailBlocklistPolicy: z.ZodType<import("../foundations/jsonb-types/sign-in-experience.js").EmailBlocklistPolicy, z.ZodTypeDef, import("../foundations/jsonb-types/sign-in-experience.js").EmailBlocklistPolicy>;
|
|
144
144
|
forgotPasswordMethods: z.ZodType<import("../foundations/jsonb-types/sign-in-experience.js").ForgotPasswordMethod[] | null, z.ZodTypeDef, import("../foundations/jsonb-types/sign-in-experience.js").ForgotPasswordMethod[] | null>;
|
|
145
145
|
passkeySignIn: z.ZodType<import("../foundations/jsonb-types/sign-in-experience.js").PasskeySignIn, z.ZodTypeDef, import("../foundations/jsonb-types/sign-in-experience.js").PasskeySignIn>;
|
|
146
|
+
signUpProfileFields: z.ZodType<{
|
|
147
|
+
name: string;
|
|
148
|
+
}[] | null, z.ZodTypeDef, {
|
|
149
|
+
name: string;
|
|
150
|
+
}[] | null>;
|
|
146
151
|
}, "forgotPasswordMethods"> & {
|
|
147
152
|
socialConnectors: z.ZodArray<z.ZodObject<Omit<{
|
|
148
153
|
id: z.ZodString;
|
|
@@ -698,9 +703,9 @@ export declare const fullSignInExperienceGuard: z.ZodObject<Omit<{
|
|
|
698
703
|
id: string;
|
|
699
704
|
tenantId: string;
|
|
700
705
|
mfa: import("../foundations/jsonb-types/sign-in-experience.js").Mfa;
|
|
706
|
+
customCss: string | null;
|
|
701
707
|
color: import("../foundations/jsonb-types/sign-in-experience.js").Color;
|
|
702
708
|
branding: import("../foundations/jsonb-types/sign-in-experience.js").Branding;
|
|
703
|
-
customCss: string | null;
|
|
704
709
|
termsOfUseUrl: string | null;
|
|
705
710
|
privacyPolicyUrl: string | null;
|
|
706
711
|
hideLogtoBranding: boolean;
|
|
@@ -723,6 +728,7 @@ export declare const fullSignInExperienceGuard: z.ZodObject<Omit<{
|
|
|
723
728
|
sentinelPolicy: import("../foundations/jsonb-types/sign-in-experience.js").SentinelPolicy;
|
|
724
729
|
emailBlocklistPolicy: import("../foundations/jsonb-types/sign-in-experience.js").EmailBlocklistPolicy;
|
|
725
730
|
passkeySignIn: import("../foundations/jsonb-types/sign-in-experience.js").PasskeySignIn;
|
|
731
|
+
signUpProfileFields: import("../foundations/jsonb-types/sign-in-experience.js").SignUpProfileFields | null;
|
|
726
732
|
socialConnectors: {
|
|
727
733
|
name: {
|
|
728
734
|
en: string;
|
|
@@ -895,9 +901,9 @@ export declare const fullSignInExperienceGuard: z.ZodObject<Omit<{
|
|
|
895
901
|
id: string;
|
|
896
902
|
tenantId: string;
|
|
897
903
|
mfa: import("../foundations/jsonb-types/sign-in-experience.js").Mfa;
|
|
904
|
+
customCss: string | null;
|
|
898
905
|
color: import("../foundations/jsonb-types/sign-in-experience.js").Color;
|
|
899
906
|
branding: import("../foundations/jsonb-types/sign-in-experience.js").Branding;
|
|
900
|
-
customCss: string | null;
|
|
901
907
|
termsOfUseUrl: string | null;
|
|
902
908
|
privacyPolicyUrl: string | null;
|
|
903
909
|
hideLogtoBranding: boolean;
|
|
@@ -920,6 +926,7 @@ export declare const fullSignInExperienceGuard: z.ZodObject<Omit<{
|
|
|
920
926
|
sentinelPolicy: import("../foundations/jsonb-types/sign-in-experience.js").SentinelPolicy;
|
|
921
927
|
emailBlocklistPolicy: import("../foundations/jsonb-types/sign-in-experience.js").EmailBlocklistPolicy;
|
|
922
928
|
passkeySignIn: import("../foundations/jsonb-types/sign-in-experience.js").PasskeySignIn;
|
|
929
|
+
signUpProfileFields: import("../foundations/jsonb-types/sign-in-experience.js").SignUpProfileFields | null;
|
|
923
930
|
socialConnectors: {
|
|
924
931
|
name: {
|
|
925
932
|
en: string;
|
|
@@ -58,6 +58,17 @@ export declare const userPasskeySignInDataGuard: z.ZodObject<{
|
|
|
58
58
|
skipped?: boolean | undefined;
|
|
59
59
|
}>;
|
|
60
60
|
export type UserPasskeySignInData = z.infer<typeof userPasskeySignInDataGuard>;
|
|
61
|
+
/**
|
|
62
|
+
* Schema for the MFA settings API response (GET/PATCH /api/my-account/mfa-settings)
|
|
63
|
+
*/
|
|
64
|
+
export declare const userMfaSettingsResponseGuard: z.ZodObject<{
|
|
65
|
+
skipMfaOnSignIn: z.ZodBoolean;
|
|
66
|
+
}, "strip", z.ZodTypeAny, {
|
|
67
|
+
skipMfaOnSignIn: boolean;
|
|
68
|
+
}, {
|
|
69
|
+
skipMfaOnSignIn: boolean;
|
|
70
|
+
}>;
|
|
71
|
+
export type UserMfaSettingsResponse = z.infer<typeof userMfaSettingsResponseGuard>;
|
|
61
72
|
/**
|
|
62
73
|
* Schema for user's logto_config field
|
|
63
74
|
*/
|
|
@@ -45,6 +45,12 @@ export const userPasskeySignInDataGuard = z.object({
|
|
|
45
45
|
*/
|
|
46
46
|
skipped: z.boolean().optional(),
|
|
47
47
|
});
|
|
48
|
+
/**
|
|
49
|
+
* Schema for the MFA settings API response (GET/PATCH /api/my-account/mfa-settings)
|
|
50
|
+
*/
|
|
51
|
+
export const userMfaSettingsResponseGuard = z.object({
|
|
52
|
+
skipMfaOnSignIn: z.boolean(),
|
|
53
|
+
});
|
|
48
54
|
/**
|
|
49
55
|
* Schema for user's logto_config field
|
|
50
56
|
*/
|
package/lib/utils/index.d.ts
CHANGED
package/lib/utils/index.js
CHANGED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { LogtoOidcConfigType, OidcPrivateKey, SigningKeyRotationState } from '../types/index.js';
|
|
2
|
+
import { OidcSigningKeyStatus } from '../types/index.js';
|
|
3
|
+
export type NormalizedOidcPrivateKey = OidcPrivateKey & {
|
|
4
|
+
status: OidcSigningKeyStatus;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Normalize OIDC private signing keys into an explicit status-based model.
|
|
8
|
+
*
|
|
9
|
+
* Legacy keys without `status` are interpreted by index order:
|
|
10
|
+
* the first key becomes `Current` and the second key becomes `Previous`.
|
|
11
|
+
* The helper also validates that the key set contains exactly one `Current`
|
|
12
|
+
* and at most one `Next` and `Previous`.
|
|
13
|
+
*/
|
|
14
|
+
export declare const normalizeOidcPrivateKeys: (privateKeys: LogtoOidcConfigType["oidc.privateKeys"]) => NormalizedOidcPrivateKey[];
|
|
15
|
+
/**
|
|
16
|
+
* Return private keys in canonical business order: `Next`, then `Current`, then `Previous`.
|
|
17
|
+
*
|
|
18
|
+
* This order is useful when the caller wants a stable persisted view of key lifecycle state.
|
|
19
|
+
*/
|
|
20
|
+
export declare const getCanonicalOidcPrivateKeys: (privateKeys: LogtoOidcConfigType["oidc.privateKeys"]) => OidcPrivateKey[];
|
|
21
|
+
/**
|
|
22
|
+
* Return the currently active signing key from a private-key set.
|
|
23
|
+
*
|
|
24
|
+
* This helper reads explicit key status rather than relying on array index.
|
|
25
|
+
*/
|
|
26
|
+
export declare const getCurrentOidcPrivateKey: (privateKeys: LogtoOidcConfigType["oidc.privateKeys"]) => OidcPrivateKey;
|
|
27
|
+
/**
|
|
28
|
+
* Return private keys in the order expected by `oidc-provider` for signing and JWKS exposure.
|
|
29
|
+
*
|
|
30
|
+
* The active `Current` key comes first, followed by `Next`, then `Previous`.
|
|
31
|
+
*/
|
|
32
|
+
export declare const getOidcProviderPrivateKeys: (privateKeys: LogtoOidcConfigType["oidc.privateKeys"]) => OidcPrivateKey[];
|
|
33
|
+
/**
|
|
34
|
+
* Normalize seeded private keys into the explicit status model used by core and CLI.
|
|
35
|
+
*
|
|
36
|
+
* Seeding only supports the legacy one-key or two-key layout, so the helper rejects
|
|
37
|
+
* larger key arrays instead of trying to infer a more complex state machine.
|
|
38
|
+
*/
|
|
39
|
+
export declare const getSeededOidcPrivateKeys: (privateKeys: LogtoOidcConfigType["oidc.privateKeys"]) => OidcPrivateKey[];
|
|
40
|
+
/**
|
|
41
|
+
* Build the persisted private-key state for immediate rotation.
|
|
42
|
+
*
|
|
43
|
+
* The new key becomes `Current`, the previous `Current` key becomes `Previous`,
|
|
44
|
+
* and any older `Previous` key is dropped.
|
|
45
|
+
*/
|
|
46
|
+
export declare const getImmediatelyRotatedOidcPrivateKeys: (privateKeys: LogtoOidcConfigType["oidc.privateKeys"], newPrivateKey: OidcPrivateKey) => OidcPrivateKey[];
|
|
47
|
+
/**
|
|
48
|
+
* Build the persisted private-key state for staged rotation.
|
|
49
|
+
*
|
|
50
|
+
* The new key becomes `Next`, the existing `Current` key stays `Current`,
|
|
51
|
+
* and the existing `Previous` key is preserved when present.
|
|
52
|
+
*/
|
|
53
|
+
export declare const getStagedRotatedOidcPrivateKeys: (privateKeys: LogtoOidcConfigType["oidc.privateKeys"], newPrivateKey: OidcPrivateKey) => OidcPrivateKey[];
|
|
54
|
+
/**
|
|
55
|
+
* Promote a staged `Next` key into `Current` and demote the previous `Current` key into `Previous`.
|
|
56
|
+
*
|
|
57
|
+
* If no staged rotation is pending, the helper returns the original key array when it already
|
|
58
|
+
* uses explicit statuses, or the normalized array when the input is still in legacy form.
|
|
59
|
+
*/
|
|
60
|
+
export declare const rotateOidcPrivateKeyStatuses: (privateKeys: LogtoOidcConfigType["oidc.privateKeys"]) => OidcPrivateKey[];
|
|
61
|
+
/**
|
|
62
|
+
* Remove a single private key from the canonical key set after delete validation has already passed.
|
|
63
|
+
*
|
|
64
|
+
* The helper keeps the remaining keys in canonical status order and does not attempt to infer
|
|
65
|
+
* new lifecycle transitions beyond dropping the deleted key.
|
|
66
|
+
*/
|
|
67
|
+
export declare const getOidcPrivateKeysAfterDeletion: (privateKeys: LogtoOidcConfigType["oidc.privateKeys"], deletedKeyId: string) => OidcPrivateKey[];
|
|
68
|
+
/**
|
|
69
|
+
* Trim one or more `Previous` private keys from the end of the normalized key set.
|
|
70
|
+
*
|
|
71
|
+
* Only `Previous` keys are trim-able; attempting to trim past the available `Previous`
|
|
72
|
+
* keys indicates an invalid operation.
|
|
73
|
+
*/
|
|
74
|
+
export declare const getTrimmedOidcPrivateKeys: (privateKeys: LogtoOidcConfigType["oidc.privateKeys"], length: number) => OidcPrivateKey[];
|
|
75
|
+
/**
|
|
76
|
+
* Build rotation state for immediate tenant cache invalidation.
|
|
77
|
+
*
|
|
78
|
+
* This records when a tenant instance should be considered stale so the next reload
|
|
79
|
+
* can pick up newly written signing key data.
|
|
80
|
+
*/
|
|
81
|
+
export declare const getRotationStateForCacheInvalidation: (currentRotationState: SigningKeyRotationState | undefined, now?: number) => SigningKeyRotationState;
|
|
82
|
+
/**
|
|
83
|
+
* Build rotation state for staged private-key rotation.
|
|
84
|
+
*
|
|
85
|
+
* In addition to immediate tenant invalidation, this records the future activation time
|
|
86
|
+
* when the staged `Next` key should be promoted to `Current`.
|
|
87
|
+
*/
|
|
88
|
+
export declare const getRotationStateForStagedRotation: (currentRotationState: SigningKeyRotationState | undefined, rotationGracePeriod: number, now?: number) => SigningKeyRotationState;
|