@logto/schemas 1.42.0 → 1.43.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.43.0-1785393731-add-oidc-model-instances-account-id-partial-index.ts +33 -0
- package/alterations/1.43.0-1785481546-add-tenant-aware-scope-indexes.ts +33 -0
- package/alterations/1.43.0-1785488115-add-cimd-permission-ceiling-tables.ts +77 -0
- package/alterations/1.43.0-1785722831-add-oidc-session-extensions-account-id-index.ts +27 -0
- package/alterations/1.43.0-1785835991-add-cimd-client-identifier-columns.ts +31 -0
- package/alterations/1.43.0-1786325989-add-cimd-grant-organizations-table.ts +54 -0
- package/alterations/1.43.0-1786333495-add-trusted-devices.ts +57 -0
- package/alterations/1.43.0-1786373004-tighten-cimd-grant-organizations-pkey.ts +28 -0
- package/alterations/1.43.0-1786414712-add-service-logs-email-indexes.ts +34 -0
- package/alterations/1.43.0-1786431364-add-cimd-grant-client-snapshots-table.ts +43 -0
- package/alterations-js/1.43.0-1785393731-add-oidc-model-instances-account-id-partial-index.js +28 -0
- package/alterations-js/1.43.0-1785481546-add-tenant-aware-scope-indexes.js +28 -0
- package/alterations-js/1.43.0-1785488115-add-cimd-permission-ceiling-tables.js +69 -0
- package/alterations-js/1.43.0-1785722831-add-oidc-session-extensions-account-id-index.js +23 -0
- package/alterations-js/1.43.0-1785835991-add-cimd-client-identifier-columns.js +27 -0
- package/alterations-js/1.43.0-1786325989-add-cimd-grant-organizations-table.js +49 -0
- package/alterations-js/1.43.0-1786333495-add-trusted-devices.js +50 -0
- package/alterations-js/1.43.0-1786373004-tighten-cimd-grant-organizations-pkey.js +24 -0
- package/alterations-js/1.43.0-1786414712-add-service-logs-email-indexes.js +30 -0
- package/alterations-js/1.43.0-1786431364-add-cimd-grant-client-snapshots-table.js +38 -0
- package/lib/consts/index.d.ts +1 -0
- package/lib/consts/index.js +1 -0
- package/lib/consts/product-event.d.ts +5 -1
- package/lib/consts/product-event.js +4 -0
- package/lib/consts/social-state.d.ts +12 -0
- package/lib/consts/social-state.js +12 -0
- package/lib/db-entries/cimd-grant-client-snapshot.d.ts +32 -0
- package/lib/db-entries/cimd-grant-client-snapshot.js +45 -0
- package/lib/db-entries/cimd-grant-organization.d.ts +30 -0
- package/lib/db-entries/cimd-grant-organization.js +37 -0
- package/lib/db-entries/cimd-organization-resource-scope.d.ts +20 -0
- package/lib/db-entries/cimd-organization-resource-scope.js +25 -0
- package/lib/db-entries/cimd-organization-scope.d.ts +20 -0
- package/lib/db-entries/cimd-organization-scope.js +25 -0
- package/lib/db-entries/cimd-resource-scope.d.ts +20 -0
- package/lib/db-entries/cimd-resource-scope.js +25 -0
- package/lib/db-entries/cimd-user-scope.d.ts +20 -0
- package/lib/db-entries/cimd-user-scope.js +25 -0
- package/lib/db-entries/index.d.ts +7 -0
- package/lib/db-entries/index.js +7 -0
- package/lib/db-entries/oidc-session-extension.d.ts +3 -1
- package/lib/db-entries/oidc-session-extension.js +4 -0
- package/lib/db-entries/organization.d.ts +5 -1
- package/lib/db-entries/organization.js +4 -0
- package/lib/db-entries/sign-in-experience.d.ts +4 -2
- package/lib/db-entries/sign-in-experience.js +5 -1
- package/lib/db-entries/trusted-device.d.ts +36 -0
- package/lib/db-entries/trusted-device.js +62 -0
- package/lib/db-entries/user.d.ts +3 -1
- package/lib/db-entries/user.js +4 -0
- package/lib/foundations/jsonb-types/account-centers.d.ts +3 -0
- package/lib/foundations/jsonb-types/account-centers.js +1 -0
- package/lib/foundations/jsonb-types/account-centers.test.d.ts +1 -0
- package/lib/foundations/jsonb-types/account-centers.test.js +13 -0
- package/lib/foundations/jsonb-types/hooks.d.ts +8 -4
- package/lib/foundations/jsonb-types/hooks.js +7 -0
- package/lib/foundations/jsonb-types/logs.d.ts +18 -0
- package/lib/foundations/jsonb-types/logs.js +6 -0
- package/lib/foundations/jsonb-types/sign-in-experience.d.ts +23 -3
- package/lib/foundations/jsonb-types/sign-in-experience.js +9 -0
- package/lib/foundations/jsonb-types/sign-in-experience.test.js +17 -1
- package/lib/types/connector.d.ts +8 -0
- package/lib/types/consent.d.ts +16 -190
- package/lib/types/consent.js +10 -1
- package/lib/types/custom-profile-fields.d.ts +1 -0
- package/lib/types/hook.d.ts +31 -6
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.js +1 -0
- package/lib/types/log/index.d.ts +5 -2
- package/lib/types/log/index.js +1 -0
- package/lib/types/log/trusted-device.d.ts +7 -0
- package/lib/types/log/trusted-device.js +6 -0
- package/lib/types/logto-config/action.d.ts +1 -1
- package/lib/types/logto-config/action.js +1 -1
- package/lib/types/logto-config/index.d.ts +36 -7
- package/lib/types/logto-config/index.js +13 -0
- package/lib/types/logto-config/index.test.js +23 -0
- package/lib/types/logto-config/jwt-customizer.d.ts +31 -10
- package/lib/types/logto-config/jwt-customizer.js +1 -1
- package/lib/types/logto-config/oidc-provider.d.ts +2 -2
- package/lib/types/service-log.d.ts +14 -1
- package/lib/types/service-log.js +13 -0
- package/lib/types/sign-in-experience.d.ts +18 -8
- package/lib/types/sign-in-experience.js +2 -1
- package/lib/types/system.d.ts +2 -2
- package/lib/types/trusted-device.d.ts +67 -0
- package/lib/types/trusted-device.js +16 -0
- package/lib/types/user-sessions.d.ts +39 -209
- package/lib/types/user-sessions.js +9 -4
- package/lib/types/user.d.ts +10 -3
- package/lib/types/user.js +1 -0
- package/lib/utils/cimd.d.ts +14 -0
- package/lib/utils/cimd.js +14 -0
- package/lib/utils/cimd.test.d.ts +1 -0
- package/lib/utils/cimd.test.js +9 -0
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +1 -0
- package/package.json +7 -7
- package/tables/cimd_grant_client_snapshots.sql +27 -0
- package/tables/cimd_grant_organizations.sql +38 -0
- package/tables/cimd_organization_resource_scopes.sql +16 -0
- package/tables/cimd_organization_scopes.sql +15 -0
- package/tables/cimd_resource_scopes.sql +15 -0
- package/tables/cimd_user_scopes.sql +13 -0
- package/tables/oidc_model_instances.sql +5 -0
- package/tables/oidc_session_extensions.sql +5 -0
- package/tables/organization_scopes.sql +4 -0
- package/tables/organizations.sql +2 -0
- package/tables/scopes.sql +4 -0
- package/tables/service_logs.sql +14 -0
- package/tables/sign_in_experiences.sql +1 -0
- package/tables/trusted_devices.sql +25 -0
- package/tables/users.sql +1 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/* init_order = 2 */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
The client identity a user approved at consent time for a client ID metadata document (CIMD)
|
|
5
|
+
client, captured per Grant. CIMD clients are unregistered URL identities without an
|
|
6
|
+
`applications` row, and an unvetted client can rewrite its hosted document at any time — so the
|
|
7
|
+
grant list renders this snapshot instead of refetching the document.
|
|
8
|
+
*/
|
|
9
|
+
create table cimd_grant_client_snapshots (
|
|
10
|
+
tenant_id varchar(21) not null
|
|
11
|
+
references tenants (id) on update cascade on delete cascade,
|
|
12
|
+
/** The ID of the Grant row in `oidc_model_instances`. */
|
|
13
|
+
grant_id varchar(128) not null,
|
|
14
|
+
/** Fixed discriminator so the composite foreign key can target Grant rows in the polymorphic `oidc_model_instances` table. */
|
|
15
|
+
grant_model_name varchar(64) not null default 'Grant',
|
|
16
|
+
client_id varchar(2048) not null,
|
|
17
|
+
name varchar(256),
|
|
18
|
+
logo_uri varchar(2048),
|
|
19
|
+
created_at timestamptz not null default(now()),
|
|
20
|
+
primary key (tenant_id, grant_id),
|
|
21
|
+
constraint cimd_grant_client_snapshots__grant_model_name
|
|
22
|
+
check (grant_model_name = 'Grant'),
|
|
23
|
+
/** Revoking the grant hard-deletes the Grant row, which erases the snapshot with it. */
|
|
24
|
+
foreign key (tenant_id, grant_model_name, grant_id)
|
|
25
|
+
references oidc_model_instances (tenant_id, model_name, id)
|
|
26
|
+
on update cascade on delete cascade
|
|
27
|
+
);
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/* init_order = 3 */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
The organization authorized on a single OIDC Grant for a client ID metadata document (CIMD) client.
|
|
5
|
+
CIMD clients are unregistered URL identities with no deletion lifecycle and transferable ownership,
|
|
6
|
+
so organization access follows the single authorization instead of a long-lived cross-grant
|
|
7
|
+
relation: rows cascade away with the Grant row and with the user's organization membership.
|
|
8
|
+
*/
|
|
9
|
+
create table cimd_grant_organizations (
|
|
10
|
+
tenant_id varchar(21) not null
|
|
11
|
+
references tenants (id) on update cascade on delete cascade,
|
|
12
|
+
/** The ID of the Grant row in `oidc_model_instances`. */
|
|
13
|
+
grant_id varchar(128) not null,
|
|
14
|
+
/** Fixed discriminator so the composite foreign key can target Grant rows in the polymorphic `oidc_model_instances` table. */
|
|
15
|
+
grant_model_name varchar(64) not null default 'Grant',
|
|
16
|
+
organization_id varchar(21) not null,
|
|
17
|
+
/** The user the grant was issued to and the membership FK's target. Must match the Grant payload's `accountId` (unreachable by FK) — the consent write enforces the pairing. */
|
|
18
|
+
user_id varchar(21) not null,
|
|
19
|
+
primary key (tenant_id, grant_id),
|
|
20
|
+
constraint cimd_grant_organizations__grant_model_name
|
|
21
|
+
check (grant_model_name = 'Grant'),
|
|
22
|
+
/** Revoking the grant hard-deletes the Grant row, which erases the organization authorization with it. */
|
|
23
|
+
foreign key (tenant_id, grant_model_name, grant_id)
|
|
24
|
+
references oidc_model_instances (tenant_id, model_name, id)
|
|
25
|
+
on update cascade on delete cascade,
|
|
26
|
+
/** Leaving the organization revokes the authorization. */
|
|
27
|
+
foreign key (tenant_id, organization_id, user_id)
|
|
28
|
+
references organization_user_relations (tenant_id, organization_id, user_id)
|
|
29
|
+
on update cascade on delete cascade
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
Backs the membership FK's cascade lookup: rows live as long as the Grant row (not the grant's
|
|
34
|
+
validity), so membership deletions would otherwise scan the tenant's whole row set per deleted
|
|
35
|
+
membership, amplified by member count on organization deletion.
|
|
36
|
+
*/
|
|
37
|
+
create index cimd_grant_organizations__organization_id_user_id
|
|
38
|
+
on cimd_grant_organizations (tenant_id, organization_id, user_id);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/* init_order = 3 */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
The organization API resource scopes (permissions) that client ID metadata document (CIMD) clients of
|
|
5
|
+
the tenant can request. The scopes are granted to users through organization roles.
|
|
6
|
+
Rows are an allowlist: an empty table allows nothing (deny-all), and an unrestricted state is not expressible.
|
|
7
|
+
*/
|
|
8
|
+
create table cimd_organization_resource_scopes (
|
|
9
|
+
tenant_id varchar(21) not null
|
|
10
|
+
references tenants (id) on update cascade on delete cascade,
|
|
11
|
+
/** The globally unique identifier of the API resource scope. */
|
|
12
|
+
scope_id varchar(21) not null,
|
|
13
|
+
primary key (tenant_id, scope_id),
|
|
14
|
+
foreign key (tenant_id, scope_id)
|
|
15
|
+
references scopes (tenant_id, id) on update cascade on delete cascade
|
|
16
|
+
);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/* init_order = 2 */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
The organization scopes (permissions) that client ID metadata document (CIMD) clients of the tenant can request.
|
|
5
|
+
Rows are an allowlist: an empty table allows nothing (deny-all), and an unrestricted state is not expressible.
|
|
6
|
+
*/
|
|
7
|
+
create table cimd_organization_scopes (
|
|
8
|
+
tenant_id varchar(21) not null
|
|
9
|
+
references tenants (id) on update cascade on delete cascade,
|
|
10
|
+
/** The globally unique identifier of the organization scope. */
|
|
11
|
+
organization_scope_id varchar(21) not null,
|
|
12
|
+
primary key (tenant_id, organization_scope_id),
|
|
13
|
+
foreign key (tenant_id, organization_scope_id)
|
|
14
|
+
references organization_scopes (tenant_id, id) on update cascade on delete cascade
|
|
15
|
+
);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/* init_order = 3 */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
The API resource scopes (permissions) that client ID metadata document (CIMD) clients of the tenant can request.
|
|
5
|
+
Rows are an allowlist: an empty table allows nothing (deny-all), and an unrestricted state is not expressible.
|
|
6
|
+
*/
|
|
7
|
+
create table cimd_resource_scopes (
|
|
8
|
+
tenant_id varchar(21) not null
|
|
9
|
+
references tenants (id) on update cascade on delete cascade,
|
|
10
|
+
/** The globally unique identifier of the API resource scope. */
|
|
11
|
+
scope_id varchar(21) not null,
|
|
12
|
+
primary key (tenant_id, scope_id),
|
|
13
|
+
foreign key (tenant_id, scope_id)
|
|
14
|
+
references scopes (tenant_id, id) on update cascade on delete cascade
|
|
15
|
+
);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/* init_order = 2 */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
The user scopes (permissions) that client ID metadata document (CIMD) clients of the tenant can request.
|
|
5
|
+
Rows are an allowlist: an empty table allows nothing (deny-all), and an unrestricted state is not expressible.
|
|
6
|
+
*/
|
|
7
|
+
create table cimd_user_scopes (
|
|
8
|
+
tenant_id varchar(21) not null
|
|
9
|
+
references tenants (id) on update cascade on delete cascade,
|
|
10
|
+
/** The unique UserScope enum value @see (@logto/core-kit/open-id.js) for more details */
|
|
11
|
+
user_scope varchar(64) not null,
|
|
12
|
+
primary key (tenant_id, user_scope)
|
|
13
|
+
);
|
|
@@ -42,6 +42,11 @@ create index oidc_model_instances__grant_payload_account_id_expires_at
|
|
|
42
42
|
on oidc_model_instances (tenant_id, (payload->>'accountId'), expires_at)
|
|
43
43
|
WHERE model_name = 'Grant';
|
|
44
44
|
|
|
45
|
+
/* Partial on payload key existence so rows without accountId (e.g. client credentials tokens) stay out of the index. The parameter-free predicate stays provable under generic query plans, but matching queries must include the payload ? 'accountId' clause. */
|
|
46
|
+
create index oidc_model_instances__model_name_payload_account_id_partial
|
|
47
|
+
on oidc_model_instances (tenant_id, model_name, (payload->>'accountId'))
|
|
48
|
+
where payload ? 'accountId';
|
|
49
|
+
|
|
45
50
|
alter table oidc_model_instances set (
|
|
46
51
|
autovacuum_vacuum_scale_factor = 0.05,
|
|
47
52
|
autovacuum_analyze_scale_factor = 0.02,
|
|
@@ -8,11 +8,16 @@ create table oidc_session_extensions (
|
|
|
8
8
|
references users (id) on update cascade on delete cascade,
|
|
9
9
|
last_submission jsonb /* @use JsonObject */ not null default '{}'::jsonb,
|
|
10
10
|
client_id varchar(21) null,
|
|
11
|
+
cimd_client_id varchar(2048) null,
|
|
11
12
|
created_at timestamptz not null default(now()),
|
|
12
13
|
updated_at timestamptz not null default(now()),
|
|
13
14
|
primary key (tenant_id, session_uid)
|
|
14
15
|
);
|
|
15
16
|
|
|
17
|
+
/* Leads with account_id instead of tenant_id so the cascades from the users table can use it (users.id is globally unique, so a tenant_id prefix adds no selectivity). */
|
|
18
|
+
create index oidc_session_extensions__account_id
|
|
19
|
+
on oidc_session_extensions (account_id);
|
|
20
|
+
|
|
16
21
|
create trigger set_updated_at
|
|
17
22
|
before update on oidc_session_extensions
|
|
18
23
|
for each row
|
|
@@ -17,3 +17,7 @@ create table organization_scopes (
|
|
|
17
17
|
|
|
18
18
|
create index organization_scopes__id
|
|
19
19
|
on organization_scopes (tenant_id, id);
|
|
20
|
+
|
|
21
|
+
/** Supports tenant-aware foreign keys from tenant-owned organization scope relations. */
|
|
22
|
+
create unique index organization_scopes__tenant_id_id
|
|
23
|
+
on organization_scopes (tenant_id, id);
|
package/tables/organizations.sql
CHANGED
|
@@ -14,6 +14,8 @@ create table organizations (
|
|
|
14
14
|
custom_data jsonb /* @use JsonObject */ not null default '{}'::jsonb,
|
|
15
15
|
/** Whether multi-factor authentication configuration is required for the members of the organization. */
|
|
16
16
|
is_mfa_required boolean not null default false,
|
|
17
|
+
/** Whether trusted devices are allowed for members of the organization. */
|
|
18
|
+
is_trusted_device_allowed boolean not null default true,
|
|
17
19
|
/** The organization's branding color configuration. */
|
|
18
20
|
color jsonb /* @use PartialColor */ not null default '{}'::jsonb,
|
|
19
21
|
/** The organization's branding configuration. */
|
package/tables/scopes.sql
CHANGED
package/tables/service_logs.sql
CHANGED
|
@@ -18,4 +18,18 @@ create index service_logs__tenant_id__type__created_at
|
|
|
18
18
|
create index service_logs__created_at
|
|
19
19
|
on service_logs (created_at);
|
|
20
20
|
|
|
21
|
+
/* Cloud email-logs read path: streams a tenant's sent + failed hosted-email rows in
|
|
22
|
+
(created_at desc, id desc) keyset order (in the composite index above `type` sits between
|
|
23
|
+
`tenant_id` and `created_at`, so a read spanning both email types cannot stream in time order
|
|
24
|
+
and needs a full top-N sort) */
|
|
25
|
+
create index service_logs__email__tenant_id__created_at__id
|
|
26
|
+
on service_logs (tenant_id, created_at desc, id desc)
|
|
27
|
+
where type in ('sendEmail', 'sendEmailFailed');
|
|
28
|
+
|
|
29
|
+
/* Cloud email-logs recipient filter: case-insensitive exact recipient lookups in the same
|
|
30
|
+
keyset order, without inspecting every email-log payload of the tenant */
|
|
31
|
+
create index service_logs__email__tenant_id__recipient__created_at__id
|
|
32
|
+
on service_logs (tenant_id, lower(payload->'data'->>'to'), created_at desc, id desc)
|
|
33
|
+
where type in ('sendEmail', 'sendEmailFailed');
|
|
34
|
+
|
|
21
35
|
/* no_after_each */
|
|
@@ -25,6 +25,7 @@ create table sign_in_experiences (
|
|
|
25
25
|
password_policy jsonb /* @use PartialPasswordPolicy */ not null default '{}'::jsonb,
|
|
26
26
|
mfa jsonb /* @use Mfa */ not null default '{}'::jsonb,
|
|
27
27
|
adaptive_mfa jsonb /* @use AdaptiveMfa */ not null default '{}'::jsonb,
|
|
28
|
+
trusted_device jsonb /* @use TrustedDevicePolicy */ not null default '{}'::jsonb,
|
|
28
29
|
single_sign_on_enabled boolean not null default false,
|
|
29
30
|
support_email text,
|
|
30
31
|
support_website_url text,
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/* init_order = 2 */
|
|
2
|
+
|
|
3
|
+
/** A revocable server-side credential that can fulfill sign-in MFA for a user. */
|
|
4
|
+
create table trusted_devices (
|
|
5
|
+
tenant_id varchar(21) not null
|
|
6
|
+
references tenants (id) on update cascade on delete cascade,
|
|
7
|
+
id varchar(21) not null,
|
|
8
|
+
user_id varchar(12) not null
|
|
9
|
+
references users (id) on update cascade on delete cascade,
|
|
10
|
+
secret_hash bytea /* @use BufferLike */ not null,
|
|
11
|
+
user_agent text,
|
|
12
|
+
ip text,
|
|
13
|
+
country varchar(16),
|
|
14
|
+
city text,
|
|
15
|
+
created_at timestamptz not null default(now()),
|
|
16
|
+
last_used_at timestamptz not null default(now()),
|
|
17
|
+
expires_at timestamptz not null,
|
|
18
|
+
primary key (id)
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
create index trusted_devices__tenant_user_expires_at
|
|
22
|
+
on trusted_devices (tenant_id, user_id, expires_at);
|
|
23
|
+
|
|
24
|
+
create index trusted_devices__tenant_expires_at
|
|
25
|
+
on trusted_devices (tenant_id, expires_at);
|
package/tables/users.sql
CHANGED
|
@@ -17,6 +17,7 @@ create table users (
|
|
|
17
17
|
/** Additional OpenID Connect standard claims that are not included in user's properties. */
|
|
18
18
|
profile jsonb /* @use UserProfile */ not null default '{}'::jsonb,
|
|
19
19
|
application_id varchar(21),
|
|
20
|
+
cimd_client_id varchar(2048),
|
|
20
21
|
identities jsonb /* @use Identities */ not null default '{}'::jsonb,
|
|
21
22
|
custom_data jsonb /* @use JsonObject */ not null default '{}'::jsonb,
|
|
22
23
|
logto_config jsonb /* @use JsonObject */ not null default '{}'::jsonb,
|