@logto/schemas 1.41.0 → 1.42.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/alterations/1.42.0-1783916980-add-domain-verification-files.ts +20 -0
  2. package/alterations/1.42.0-1784619793-add-service-logs-created-at-index.ts +33 -0
  3. package/alterations/1.42.0-1784620000-add-saml-sso-connector-signing-keys-table.ts +38 -0
  4. package/alterations/utils/1704934999-tables.ts +22 -1
  5. package/alterations-js/1.42.0-1783916980-add-domain-verification-files.js +16 -0
  6. package/alterations-js/1.42.0-1784619793-add-service-logs-created-at-index.js +29 -0
  7. package/alterations-js/1.42.0-1784620000-add-saml-sso-connector-signing-keys-table.js +33 -0
  8. package/alterations-js/utils/1704934999-tables.js +19 -1
  9. package/lib/consts/experience.d.ts +1 -0
  10. package/lib/consts/experience.js +1 -0
  11. package/lib/db-entries/domain.d.ts +4 -2
  12. package/lib/db-entries/domain.js +5 -1
  13. package/lib/db-entries/index.d.ts +1 -0
  14. package/lib/db-entries/index.js +1 -0
  15. package/lib/db-entries/saml-sso-connector-signing-key.d.ts +32 -0
  16. package/lib/db-entries/saml-sso-connector-signing-key.js +49 -0
  17. package/lib/foundations/jsonb-types/custom-domain.d.ts +57 -0
  18. package/lib/foundations/jsonb-types/custom-domain.js +51 -0
  19. package/lib/foundations/jsonb-types/custom-domain.test.d.ts +1 -0
  20. package/lib/foundations/jsonb-types/custom-domain.test.js +38 -0
  21. package/lib/foundations/jsonb-types/hooks.d.ts +4 -4
  22. package/lib/foundations/jsonb-types/hooks.js +1 -0
  23. package/lib/foundations/jsonb-types/one-time-tokens.d.ts +5 -0
  24. package/lib/foundations/jsonb-types/one-time-tokens.js +2 -0
  25. package/lib/foundations/jsonb-types/sign-in-experience.d.ts +16 -1
  26. package/lib/foundations/jsonb-types/sign-in-experience.js +1 -0
  27. package/lib/types/application.d.ts +131 -1
  28. package/lib/types/application.js +8 -0
  29. package/lib/types/custom-profile-fields.d.ts +1 -1
  30. package/lib/types/domain.d.ts +9 -0
  31. package/lib/types/hook.d.ts +9 -2
  32. package/lib/types/interaction-event.d.ts +11 -0
  33. package/lib/types/interaction-event.js +12 -0
  34. package/lib/types/interactions.d.ts +2 -11
  35. package/lib/types/interactions.js +2 -11
  36. package/lib/types/log/action.d.ts +7 -0
  37. package/lib/types/log/action.js +6 -0
  38. package/lib/types/log/index.d.ts +5 -2
  39. package/lib/types/log/index.js +1 -0
  40. package/lib/types/logto-config/action.d.ts +963 -0
  41. package/lib/types/logto-config/action.js +77 -0
  42. package/lib/types/logto-config/index.d.ts +32 -19
  43. package/lib/types/logto-config/index.js +7 -7
  44. package/lib/types/logto-config/index.test.js +9 -9
  45. package/lib/types/logto-config/jwt-customizer.d.ts +29 -0
  46. package/lib/types/organization.d.ts +136 -1
  47. package/lib/types/organization.js +3 -2
  48. package/lib/types/sign-in-experience.d.ts +2 -4
  49. package/lib/types/sign-in-experience.js +1 -1
  50. package/lib/types/sso-connector.d.ts +58 -0
  51. package/lib/types/sso-connector.js +12 -0
  52. package/lib/types/user-sessions.d.ts +78 -29
  53. package/lib/types/verification-records/one-time-token-verification.d.ts +5 -0
  54. package/package.json +5 -5
  55. package/tables/domains.sql +1 -0
  56. package/tables/saml_sso_connector_signing_keys.sql +21 -0
  57. package/tables/service_logs.sql +5 -0
  58. package/lib/types/logto-config/inline-hook.d.ts +0 -76
  59. package/lib/types/logto-config/inline-hook.js +0 -25
@@ -0,0 +1,21 @@
1
+ /* init_order = 2 */
2
+
3
+ create table saml_sso_connector_signing_keys (
4
+ id varchar(21) not null,
5
+ tenant_id varchar(21) not null
6
+ references tenants (id) on update cascade on delete cascade,
7
+ sso_connector_id varchar(128) not null
8
+ references sso_connectors (id) on update cascade on delete cascade,
9
+ /** The SP private key (plaintext PEM) used to sign the SAML AuthnRequest. Tenant-isolated by RLS and never returned by the API. */
10
+ private_key text not null,
11
+ /** The PEM-encoded self-signed SP certificate matching the private key. Public and safe to expose. */
12
+ certificate text not null,
13
+ created_at timestamptz not null default now(),
14
+ expires_at timestamptz not null,
15
+ active boolean not null,
16
+ primary key (tenant_id, sso_connector_id, id)
17
+ );
18
+
19
+ create unique index saml_sso_connector_signing_keys__unique_active
20
+ on saml_sso_connector_signing_keys (tenant_id, sso_connector_id, active)
21
+ where active;
@@ -13,4 +13,9 @@ create index service_logs__id
13
13
  create index service_logs__tenant_id__type__created_at
14
14
  on service_logs (tenant_id, type, created_at);
15
15
 
16
+ /* Global oldest-first scan for the age-based retention prune (the composite index above leads with
17
+ `tenant_id`, so it can't drive a tenant-agnostic `created_at` range scan). */
18
+ create index service_logs__created_at
19
+ on service_logs (created_at);
20
+
16
21
  /* no_after_each */
@@ -1,76 +0,0 @@
1
- import { z } from 'zod';
2
- import type { Json } from '../../foundations/index.js';
3
- import type { InteractionEvent, InteractionIdentifier } from '../interactions.js';
4
- import type { UserInfo } from '../user.js';
5
- export declare enum LogtoInlineHookKey {
6
- PostFirstFactorVerification = "inlineHook.postFirstFactorVerification",
7
- PostSignIn = "inlineHook.postSignIn"
8
- }
9
- export declare const inlineHookExecutionErrorPolicies: readonly ["block", "allow"];
10
- export type InlineHookExecutionErrorPolicy = (typeof inlineHookExecutionErrorPolicies)[number];
11
- export type InlineHook = {
12
- script: string;
13
- environmentVariables?: Record<string, string>;
14
- contextSample?: Json;
15
- enabled?: boolean;
16
- onExecutionError?: InlineHookExecutionErrorPolicy;
17
- };
18
- export declare const inlineHookGuard: z.ZodObject<{
19
- script: z.ZodString;
20
- environmentVariables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
21
- contextSample: z.ZodOptional<z.ZodType<Json, z.ZodTypeDef, Json>>;
22
- enabled: z.ZodOptional<z.ZodBoolean>;
23
- onExecutionError: z.ZodOptional<z.ZodEnum<["block", "allow"]>>;
24
- }, "strict", z.ZodTypeAny, {
25
- script: string;
26
- enabled?: boolean | undefined;
27
- environmentVariables?: Record<string, string> | undefined;
28
- contextSample?: Json | undefined;
29
- onExecutionError?: "block" | "allow" | undefined;
30
- }, {
31
- script: string;
32
- enabled?: boolean | undefined;
33
- environmentVariables?: Record<string, string> | undefined;
34
- contextSample?: Json | undefined;
35
- onExecutionError?: "block" | "allow" | undefined;
36
- }>;
37
- export declare const inlineHookTestRequestBodyGuard: z.ZodObject<{
38
- script: z.ZodString;
39
- hookType: z.ZodNativeEnum<typeof LogtoInlineHookKey>;
40
- event: z.ZodType<Json, z.ZodTypeDef, Json>;
41
- environmentVariables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
42
- }, "strict", z.ZodTypeAny, {
43
- event: Json;
44
- script: string;
45
- hookType: LogtoInlineHookKey;
46
- environmentVariables?: Record<string, string> | undefined;
47
- }, {
48
- event: Json;
49
- script: string;
50
- hookType: LogtoInlineHookKey;
51
- environmentVariables?: Record<string, string> | undefined;
52
- }>;
53
- export type InlineHookTestRequestBody = z.infer<typeof inlineHookTestRequestBodyGuard>;
54
- export type HookUser = Pick<UserInfo, 'id' | 'username' | 'primaryEmail' | 'primaryPhone' | 'name' | 'avatar' | 'customData' | 'profile' | 'applicationId' | 'isSuspended'>;
55
- export type HookUserPatch = Partial<Omit<HookUser, 'id'>>;
56
- export type PostFirstFactorVerificationEvent = {
57
- key: LogtoInlineHookKey.PostFirstFactorVerification;
58
- interactionEvent: InteractionEvent.SignIn;
59
- identifier: InteractionIdentifier;
60
- /** Sensitive credential provided for inline hook controlled password verification. */
61
- password: string;
62
- };
63
- export type PostSignInEvent = {
64
- key: LogtoInlineHookKey.PostSignIn;
65
- interactionEvent: InteractionEvent.SignIn;
66
- user: HookUser;
67
- };
68
- export type PostFirstFactorVerificationResult = {
69
- action: 'createUser' | 'updateUser';
70
- user: HookUserPatch;
71
- passwordVerified: true;
72
- };
73
- export type PostSignInResult = {
74
- action: 'updateUser';
75
- user?: HookUserPatch;
76
- };
@@ -1,25 +0,0 @@
1
- import { jsonGuard } from '@logto/connector-kit';
2
- import { z } from 'zod';
3
- export var LogtoInlineHookKey;
4
- (function (LogtoInlineHookKey) {
5
- LogtoInlineHookKey["PostFirstFactorVerification"] = "inlineHook.postFirstFactorVerification";
6
- LogtoInlineHookKey["PostSignIn"] = "inlineHook.postSignIn";
7
- })(LogtoInlineHookKey || (LogtoInlineHookKey = {}));
8
- export const inlineHookExecutionErrorPolicies = Object.freeze(['block', 'allow']);
9
- export const inlineHookGuard = z
10
- .object({
11
- script: z.string(),
12
- environmentVariables: z.record(z.string()).optional(),
13
- contextSample: jsonGuard.optional(),
14
- enabled: z.boolean().optional(),
15
- onExecutionError: z.enum(inlineHookExecutionErrorPolicies).optional(),
16
- })
17
- .strict();
18
- export const inlineHookTestRequestBodyGuard = z
19
- .object({
20
- script: z.string(),
21
- hookType: z.nativeEnum(LogtoInlineHookKey),
22
- event: jsonGuard,
23
- environmentVariables: z.record(z.string()).optional(),
24
- })
25
- .strict();