@logto/schemas 1.37.1 → 1.38.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.38.0-1772615848-add-oidc-model-instances-grant-id-partial-index.ts +26 -0
- package/alterations/1.38.0-1772619963-tune-oidc-model-instances-autovacuum.ts +28 -0
- package/alterations/1.38.0-1772621060-add-oidc-model-instances-grant-account-id-index.ts +26 -0
- package/alterations-js/1.38.0-1772615848-add-oidc-model-instances-grant-id-partial-index.js +22 -0
- package/alterations-js/1.38.0-1772619963-tune-oidc-model-instances-autovacuum.js +24 -0
- package/alterations-js/1.38.0-1772621060-add-oidc-model-instances-grant-account-id-index.js +22 -0
- package/lib/consts/cookie.d.ts +1 -0
- package/lib/consts/cookie.js +1 -0
- package/lib/consts/experience.d.ts +1 -0
- package/lib/consts/experience.js +1 -0
- package/lib/consts/oidc.d.ts +3 -0
- package/lib/consts/oidc.js +3 -0
- package/lib/consts/system.d.ts +4 -0
- package/lib/consts/system.js +4 -0
- package/lib/foundations/jsonb-types/oidc-module.d.ts +26 -7
- package/lib/foundations/jsonb-types/oidc-module.js +16 -1
- package/lib/foundations/jsonb-types/sign-in-experience.d.ts +10 -6
- package/lib/foundations/jsonb-types/sign-in-experience.js +6 -2
- package/lib/seeds/application.d.ts +3 -1
- package/lib/seeds/application.js +26 -1
- package/lib/types/application.d.ts +12 -0
- package/lib/types/connector.d.ts +8 -0
- package/lib/types/consent.d.ts +11 -3
- package/lib/types/consent.js +2 -1
- package/lib/types/log/interaction.d.ts +4 -2
- package/lib/types/log/interaction.js +2 -0
- package/lib/types/log/token.d.ts +5 -3
- package/lib/types/log/token.js +2 -0
- package/lib/types/logto-config/index.d.ts +276 -13
- package/lib/types/logto-config/index.js +6 -0
- package/lib/types/logto-config/jwt-customizer.d.ts +778 -253
- package/lib/types/logto-config/jwt-customizer.js +7 -3
- package/lib/types/oidc-config.d.ts +2 -1
- package/lib/types/oidc-config.js +1 -0
- package/lib/types/sign-in-experience.d.ts +6 -2
- package/lib/types/user-logto-config.d.ts +38 -0
- package/lib/types/user-logto-config.js +13 -0
- package/lib/types/user-sessions.d.ts +712 -112
- package/lib/types/user-sessions.js +33 -2
- package/lib/types/verification-records/verification-type.d.ts +1 -1
- package/lib/types/verification-records/verification-type.js +1 -1
- package/lib/types/verification-records/web-authn-verification.d.ts +11 -11
- package/lib/types/verification-records/web-authn-verification.js +3 -3
- package/package.json +8 -7
- package/tables/oidc_model_instances.sql +16 -0
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { OidcModelInstances } from '../db-entries/oidc-model-instance.js';
|
|
3
2
|
import { oidcSessionInstancePayloadGuard } from '../foundations/index.js';
|
|
4
3
|
import { jwtCustomizerUserInteractionContextGuard } from './logto-config/jwt-customizer.js';
|
|
5
4
|
export const userSessionSignInContextGuard = z
|
|
@@ -14,13 +13,45 @@ export const userSessionSignInContextGuard = z
|
|
|
14
13
|
botVerified: z.string().optional(),
|
|
15
14
|
})
|
|
16
15
|
.catchall(z.string());
|
|
17
|
-
export
|
|
16
|
+
export var SessionGrantRevokeTarget;
|
|
17
|
+
(function (SessionGrantRevokeTarget) {
|
|
18
|
+
SessionGrantRevokeTarget["All"] = "all";
|
|
19
|
+
SessionGrantRevokeTarget["FirstParty"] = "firstParty";
|
|
20
|
+
})(SessionGrantRevokeTarget || (SessionGrantRevokeTarget = {}));
|
|
21
|
+
/**
|
|
22
|
+
* Public session shape for session management APIs.
|
|
23
|
+
*
|
|
24
|
+
* We intentionally expose only fields needed by management/account-center session views and actions.
|
|
25
|
+
* Internal OIDC storage fields (e.g. `tenantId`, `id`, `consumedAt`) are omitted on purpose.
|
|
26
|
+
*/
|
|
27
|
+
export const userExtendedSessionGuard = z.object({
|
|
18
28
|
payload: oidcSessionInstancePayloadGuard,
|
|
19
29
|
lastSubmission: jwtCustomizerUserInteractionContextGuard.nullable(),
|
|
20
30
|
clientId: z.string().nullable(),
|
|
21
31
|
accountId: z.string().nullable(),
|
|
32
|
+
expiresAt: z.number(),
|
|
22
33
|
});
|
|
23
34
|
export const getUserSessionsResponseGuard = z.object({
|
|
24
35
|
sessions: z.array(userExtendedSessionGuard),
|
|
25
36
|
});
|
|
26
37
|
export const getUserSessionResponseGuard = userExtendedSessionGuard;
|
|
38
|
+
export const userApplicationGrantPayloadGuard = z
|
|
39
|
+
.object({
|
|
40
|
+
/** Expiration time of the grant in seconds since the epoch */
|
|
41
|
+
exp: z.number(),
|
|
42
|
+
/** Issued at time of the grant in seconds since the epoch */
|
|
43
|
+
iat: z.number(),
|
|
44
|
+
jti: z.string(),
|
|
45
|
+
kind: z.literal('Grant'),
|
|
46
|
+
clientId: z.string(),
|
|
47
|
+
accountId: z.string(),
|
|
48
|
+
})
|
|
49
|
+
.catchall(z.unknown());
|
|
50
|
+
export const userApplicationGrantGuard = z.object({
|
|
51
|
+
id: z.string(),
|
|
52
|
+
payload: userApplicationGrantPayloadGuard,
|
|
53
|
+
expiresAt: z.number(),
|
|
54
|
+
});
|
|
55
|
+
export const getUserApplicationGrantsResponseGuard = z.object({
|
|
56
|
+
grants: z.array(userApplicationGrantGuard),
|
|
57
|
+
});
|
|
@@ -9,7 +9,7 @@ export declare enum VerificationType {
|
|
|
9
9
|
EnterpriseSso = "EnterpriseSso",
|
|
10
10
|
TOTP = "Totp",
|
|
11
11
|
WebAuthn = "WebAuthn",
|
|
12
|
-
|
|
12
|
+
SignInPasskey = "SignInPasskey",
|
|
13
13
|
BackupCode = "BackupCode",
|
|
14
14
|
NewPasswordIdentity = "NewPasswordIdentity",
|
|
15
15
|
OneTimeToken = "OneTimeToken"
|
|
@@ -10,7 +10,7 @@ export var VerificationType;
|
|
|
10
10
|
VerificationType["EnterpriseSso"] = "EnterpriseSso";
|
|
11
11
|
VerificationType["TOTP"] = "Totp";
|
|
12
12
|
VerificationType["WebAuthn"] = "WebAuthn";
|
|
13
|
-
VerificationType["
|
|
13
|
+
VerificationType["SignInPasskey"] = "SignInPasskey";
|
|
14
14
|
VerificationType["BackupCode"] = "BackupCode";
|
|
15
15
|
VerificationType["NewPasswordIdentity"] = "NewPasswordIdentity";
|
|
16
16
|
VerificationType["OneTimeToken"] = "OneTimeToken";
|
|
@@ -139,13 +139,13 @@ export declare const sanitizedWebAuthnVerificationRecordDataGuard: z.ZodObject<O
|
|
|
139
139
|
userId: string;
|
|
140
140
|
verified: boolean;
|
|
141
141
|
}>;
|
|
142
|
-
export type
|
|
143
|
-
type: VerificationType.
|
|
142
|
+
export type SignInPasskeyVerificationRecordData = BaseWebAuthnVerificationRecordData & {
|
|
143
|
+
type: VerificationType.SignInPasskey;
|
|
144
144
|
userId?: string;
|
|
145
145
|
/** The rpId used when generating the authentication options */
|
|
146
146
|
authenticationRpId?: string;
|
|
147
147
|
};
|
|
148
|
-
export declare const
|
|
148
|
+
export declare const signInPasskeyVerificationRecordDataGuard: z.ZodObject<{
|
|
149
149
|
id: z.ZodString;
|
|
150
150
|
verified: z.ZodBoolean;
|
|
151
151
|
registrationChallenge: z.ZodOptional<z.ZodString>;
|
|
@@ -180,11 +180,11 @@ export declare const signInWebAuthnVerificationRecordDataGuard: z.ZodObject<{
|
|
|
180
180
|
name?: string | undefined;
|
|
181
181
|
}>>;
|
|
182
182
|
} & {
|
|
183
|
-
type: z.ZodLiteral<VerificationType.
|
|
183
|
+
type: z.ZodLiteral<VerificationType.SignInPasskey>;
|
|
184
184
|
userId: z.ZodOptional<z.ZodString>;
|
|
185
185
|
authenticationRpId: z.ZodOptional<z.ZodString>;
|
|
186
186
|
}, "strip", z.ZodTypeAny, {
|
|
187
|
-
type: VerificationType.
|
|
187
|
+
type: VerificationType.SignInPasskey;
|
|
188
188
|
id: string;
|
|
189
189
|
verified: boolean;
|
|
190
190
|
userId?: string | undefined;
|
|
@@ -203,7 +203,7 @@ export declare const signInWebAuthnVerificationRecordDataGuard: z.ZodObject<{
|
|
|
203
203
|
} | undefined;
|
|
204
204
|
authenticationRpId?: string | undefined;
|
|
205
205
|
}, {
|
|
206
|
-
type: VerificationType.
|
|
206
|
+
type: VerificationType.SignInPasskey;
|
|
207
207
|
id: string;
|
|
208
208
|
verified: boolean;
|
|
209
209
|
userId?: string | undefined;
|
|
@@ -222,8 +222,8 @@ export declare const signInWebAuthnVerificationRecordDataGuard: z.ZodObject<{
|
|
|
222
222
|
} | undefined;
|
|
223
223
|
authenticationRpId?: string | undefined;
|
|
224
224
|
}>;
|
|
225
|
-
export type
|
|
226
|
-
export declare const
|
|
225
|
+
export type SanitizedSignInPasskeyVerificationRecordData = Omit<SignInPasskeyVerificationRecordData, 'registrationInfo' | 'registrationChallenge' | 'registrationRpId' | 'authenticationChallenge' | 'authenticationRpId'>;
|
|
226
|
+
export declare const sanitizedSignInPasskeyVerificationRecordDataGuard: z.ZodObject<Omit<{
|
|
227
227
|
id: z.ZodString;
|
|
228
228
|
verified: z.ZodBoolean;
|
|
229
229
|
registrationChallenge: z.ZodOptional<z.ZodString>;
|
|
@@ -258,16 +258,16 @@ export declare const sanitizedSignInWebAuthnVerificationRecordDataGuard: z.ZodOb
|
|
|
258
258
|
name?: string | undefined;
|
|
259
259
|
}>>;
|
|
260
260
|
} & {
|
|
261
|
-
type: z.ZodLiteral<VerificationType.
|
|
261
|
+
type: z.ZodLiteral<VerificationType.SignInPasskey>;
|
|
262
262
|
userId: z.ZodOptional<z.ZodString>;
|
|
263
263
|
authenticationRpId: z.ZodOptional<z.ZodString>;
|
|
264
264
|
}, "registrationChallenge" | "registrationRpId" | "authenticationChallenge" | "registrationInfo" | "authenticationRpId">, "strip", z.ZodTypeAny, {
|
|
265
|
-
type: VerificationType.
|
|
265
|
+
type: VerificationType.SignInPasskey;
|
|
266
266
|
id: string;
|
|
267
267
|
verified: boolean;
|
|
268
268
|
userId?: string | undefined;
|
|
269
269
|
}, {
|
|
270
|
-
type: VerificationType.
|
|
270
|
+
type: VerificationType.SignInPasskey;
|
|
271
271
|
id: string;
|
|
272
272
|
verified: boolean;
|
|
273
273
|
userId?: string | undefined;
|
|
@@ -19,12 +19,12 @@ export const sanitizedWebAuthnVerificationRecordDataGuard = webAuthnVerification
|
|
|
19
19
|
registrationRpId: true,
|
|
20
20
|
authenticationChallenge: true,
|
|
21
21
|
});
|
|
22
|
-
export const
|
|
23
|
-
type: z.literal(VerificationType.
|
|
22
|
+
export const signInPasskeyVerificationRecordDataGuard = baseWebAuthnVerificationRecordDataGuard.extend({
|
|
23
|
+
type: z.literal(VerificationType.SignInPasskey),
|
|
24
24
|
userId: z.string().optional(),
|
|
25
25
|
authenticationRpId: z.string().optional(),
|
|
26
26
|
});
|
|
27
|
-
export const
|
|
27
|
+
export const sanitizedSignInPasskeyVerificationRecordDataGuard = signInPasskeyVerificationRecordDataGuard.omit({
|
|
28
28
|
registrationInfo: true,
|
|
29
29
|
registrationChallenge: true,
|
|
30
30
|
registrationRpId: true,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logto/schemas",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.38.0",
|
|
4
4
|
"author": "Silverhand Inc. <contact@silverhand.io>",
|
|
5
5
|
"license": "MPL-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -65,12 +65,12 @@
|
|
|
65
65
|
"dependencies": {
|
|
66
66
|
"@withtyped/server": "^0.14.0",
|
|
67
67
|
"nanoid": "^5.0.9",
|
|
68
|
-
"@logto/
|
|
69
|
-
"@logto/core-kit": "^2.
|
|
70
|
-
"@logto/
|
|
71
|
-
"@logto/phrases": "^1.26.0",
|
|
68
|
+
"@logto/language-kit": "^1.3.0",
|
|
69
|
+
"@logto/core-kit": "^2.8.0",
|
|
70
|
+
"@logto/phrases": "^1.27.0",
|
|
72
71
|
"@logto/shared": "^3.3.1",
|
|
73
|
-
"@logto/
|
|
72
|
+
"@logto/connector-kit": "^5.0.0",
|
|
73
|
+
"@logto/phrases-experience": "^1.13.0"
|
|
74
74
|
},
|
|
75
75
|
"peerDependencies": {
|
|
76
76
|
"zod": "3.24.3"
|
|
@@ -85,7 +85,8 @@
|
|
|
85
85
|
"dev": "tsc -p tsconfig.build.json --watch --preserveWatchOutput --incremental",
|
|
86
86
|
"lint": "eslint --ext .ts src",
|
|
87
87
|
"lint:report": "pnpm lint --format json --output-file report.json",
|
|
88
|
-
"test": "vitest src",
|
|
88
|
+
"test": "vitest run src",
|
|
89
|
+
"test:watch": "vitest src --watch",
|
|
89
90
|
"test:ci": "pnpm run test --silent --coverage"
|
|
90
91
|
}
|
|
91
92
|
}
|
|
@@ -27,6 +27,7 @@ create index oidc_model_instances__model_name_payload_uid
|
|
|
27
27
|
(payload->>'uid')
|
|
28
28
|
);
|
|
29
29
|
|
|
30
|
+
/* TODO: Consider dropping this full data index if the partial index proves to be effective and safe. */
|
|
30
31
|
create index oidc_model_instances__model_name_payload_grant_id
|
|
31
32
|
on oidc_model_instances (
|
|
32
33
|
tenant_id,
|
|
@@ -34,9 +35,24 @@ create index oidc_model_instances__model_name_payload_grant_id
|
|
|
34
35
|
(payload->>'grantId')
|
|
35
36
|
);
|
|
36
37
|
|
|
38
|
+
create index oidc_model_instances__model_name_payload_grant_id_partial
|
|
39
|
+
on oidc_model_instances (tenant_id, model_name, (payload->>'grantId'))
|
|
40
|
+
where payload ? 'grantId';
|
|
41
|
+
|
|
37
42
|
create index oidc_model_instances__expires_at
|
|
38
43
|
on oidc_model_instances (tenant_id, expires_at);
|
|
39
44
|
|
|
40
45
|
create index oidc_model_instances__session_payload_account_id_expires_at
|
|
41
46
|
on oidc_model_instances (tenant_id, (payload->>'accountId'), expires_at)
|
|
42
47
|
WHERE model_name = 'Session';
|
|
48
|
+
|
|
49
|
+
create index oidc_model_instances__grant_payload_account_id_expires_at
|
|
50
|
+
on oidc_model_instances (tenant_id, (payload->>'accountId'), expires_at)
|
|
51
|
+
WHERE model_name = 'Grant';
|
|
52
|
+
|
|
53
|
+
alter table oidc_model_instances set (
|
|
54
|
+
autovacuum_vacuum_scale_factor = 0.05,
|
|
55
|
+
autovacuum_analyze_scale_factor = 0.02,
|
|
56
|
+
autovacuum_vacuum_threshold = 5000,
|
|
57
|
+
autovacuum_analyze_threshold = 2000
|
|
58
|
+
);
|