@logto/schemas 1.28.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.29.0-1748832174-add-webauthn-related-origins.ts +20 -0
- package/alterations/1.29.0-1749005587-user-sso-identities-table-add-updated-at-column.ts +31 -0
- package/alterations/1.29.0-1749026308-add-oidc-session-extension-table.ts +41 -0
- package/alterations/1.29.0-1749523818-add-custom-profile-fields.ts +58 -0
- package/alterations/1.29.0-1749724664-drop-sie-order-constraint-from-custom-profile-fields.ts +20 -0
- package/alterations/1.29.0-1750663091-change-user-password-encrypted-length.ts +18 -0
- package/alterations/1.29.0-1750744518-add-secrets-table.ts +50 -0
- package/alterations/1.29.0-1750744539-add-secret-connector-relations-table.ts +109 -0
- 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.29.0-1748832174-add-webauthn-related-origins.js +16 -0
- package/alterations-js/1.29.0-1749005587-user-sso-identities-table-add-updated-at-column.js +25 -0
- package/alterations-js/1.29.0-1749026308-add-oidc-session-extension-table.js +33 -0
- package/alterations-js/1.29.0-1749523818-add-custom-profile-fields.js +52 -0
- package/alterations-js/1.29.0-1749724664-drop-sie-order-constraint-from-custom-profile-fields.js +16 -0
- package/alterations-js/1.29.0-1750663091-change-user-password-encrypted-length.js +14 -0
- package/alterations-js/1.29.0-1750744518-add-secrets-table.js +42 -0
- package/alterations-js/1.29.0-1750744539-add-secret-connector-relations-table.js +99 -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/account-center.d.ts +4 -2
- package/lib/db-entries/account-center.js +5 -1
- package/lib/db-entries/connector.d.ts +5 -1
- package/lib/db-entries/connector.js +4 -0
- package/lib/db-entries/custom-profile-field.d.ts +32 -0
- package/lib/db-entries/custom-profile-field.js +58 -0
- package/lib/db-entries/index.d.ts +5 -0
- package/lib/db-entries/index.js +5 -0
- package/lib/db-entries/oidc-session-extension.d.ts +24 -0
- package/lib/db-entries/oidc-session-extension.js +42 -0
- 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 +44 -0
- package/lib/db-entries/secret.js +62 -0
- package/lib/db-entries/sso-connector.d.ts +5 -1
- package/lib/db-entries/sso-connector.js +4 -0
- package/lib/db-entries/user-sso-identity.d.ts +5 -1
- package/lib/db-entries/user-sso-identity.js +4 -0
- package/lib/db-entries/user.js +2 -2
- package/lib/foundations/jsonb-types/account-centers.d.ts +5 -0
- package/lib/foundations/jsonb-types/account-centers.js +2 -0
- package/lib/foundations/jsonb-types/custom-profile-fields.d.ts +441 -0
- package/lib/foundations/jsonb-types/custom-profile-fields.js +44 -0
- package/lib/foundations/jsonb-types/index.d.ts +2 -1
- package/lib/foundations/jsonb-types/index.js +2 -1
- package/lib/foundations/jsonb-types/secrets.d.ts +11 -0
- package/lib/foundations/jsonb-types/secrets.js +15 -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 +126 -0
- package/lib/foundations/jsonb-types/users.js +22 -10
- package/lib/types/connector.d.ts +39 -0
- package/lib/types/connector.js +1 -0
- package/lib/types/consent.d.ts +44 -0
- package/lib/types/custom-profile-fields.d.ts +2587 -0
- package/lib/types/custom-profile-fields.js +159 -0
- package/lib/types/index.d.ts +4 -0
- package/lib/types/index.js +4 -0
- package/lib/types/interactions.d.ts +181 -1
- package/lib/types/interactions.js +49 -1
- package/lib/types/log/interaction.d.ts +2 -1
- package/lib/types/logto-config/index.d.ts +1139 -18
- package/lib/types/logto-config/jwt-customizer.d.ts +2529 -32
- package/lib/types/logto-config/jwt-customizer.js +55 -1
- package/lib/types/logto-config/oidc-provider.d.ts +6 -6
- package/lib/types/mfa.d.ts +10 -10
- package/lib/types/secrets.d.ts +436 -0
- package/lib/types/secrets.js +73 -0
- package/lib/types/sign-in-experience.d.ts +21 -3
- package/lib/types/sign-in-experience.js +3 -1
- package/lib/types/sso-connector.d.ts +28 -2
- package/lib/types/sso-connector.js +3 -0
- package/lib/types/tenant.d.ts +1 -0
- package/lib/types/tenant.js +1 -0
- 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 +626 -0
- package/lib/types/user.js +17 -1
- package/lib/types/verification-records/backup-code-verification.d.ts +47 -0
- package/lib/types/verification-records/backup-code-verification.js +12 -0
- package/lib/types/verification-records/code-verification.d.ts +89 -0
- package/lib/types/verification-records/code-verification.js +22 -0
- package/lib/types/verification-records/enterprise-sso-verification.d.ts +213 -0
- package/lib/types/verification-records/enterprise-sso-verification.js +15 -0
- package/lib/types/verification-records/index.d.ts +16 -0
- package/lib/types/verification-records/index.js +16 -0
- package/lib/types/verification-records/new-password-identity-verification.d.ts +85 -0
- package/lib/types/verification-records/new-password-identity-verification.js +20 -0
- package/lib/types/verification-records/one-time-token-verification.d.ts +55 -0
- package/lib/types/verification-records/one-time-token-verification.js +13 -0
- package/lib/types/verification-records/password-verification.d.ts +40 -0
- package/lib/types/verification-records/password-verification.js +9 -0
- package/lib/types/verification-records/social-verification.d.ts +270 -0
- package/lib/types/verification-records/social-verification.js +16 -0
- package/lib/types/verification-records/totp-verification.d.ts +47 -0
- package/lib/types/verification-records/totp-verification.js +12 -0
- package/lib/types/verification-records/web-authn-verification.d.ts +124 -0
- package/lib/types/verification-records/web-authn-verification.js +17 -0
- package/package.json +6 -6
- package/tables/account_centers.sql +2 -1
- package/tables/connectors.sql +4 -0
- package/tables/custom_profile_fields.sql +31 -0
- package/tables/oidc_model_instances.sql +2 -0
- package/tables/oidc_session_extensions.sql +18 -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 +26 -0
- package/tables/sso_connectors.sql +2 -0
- package/tables/user_sso_identities.sql +8 -0
- package/tables/users.sql +3 -2
- /package/lib/{foundations/jsonb-types/verification-records.d.ts → types/verification-records/verification-type.d.ts} +0 -0
- /package/lib/{foundations/jsonb-types/verification-records.js → types/verification-records/verification-type.js} +0 -0
|
@@ -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();
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/* init_order = 3 */
|
|
2
|
+
|
|
3
|
+
create table secret_social_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
|
+
/** Social connector ID foreign reference. Only present for secrets that store social connector tokens. Note: avoid directly cascading deletes here, need to delete the secrets first.*/
|
|
9
|
+
connector_id varchar(128) not null
|
|
10
|
+
references connectors (id) on update cascade,
|
|
11
|
+
/** The target of the social connector. e.g. 'github', 'google', etc. */
|
|
12
|
+
target varchar(256) not null,
|
|
13
|
+
/** User social identity ID foreign reference. Only present for secrets that store social identity tokens. */
|
|
14
|
+
identity_id varchar(128) not null,
|
|
15
|
+
primary key (tenant_id, secret_id),
|
|
16
|
+
/** Ensures that each social identity is associated with only one secret. */
|
|
17
|
+
constraint secret_social_connector_relations__target__identity_id
|
|
18
|
+
unique (tenant_id, target, identity_id)
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
/** Trigger function to delete secrets when the social connector is deleted. */
|
|
22
|
+
create function delete_secrets_on_social_connector_delete()
|
|
23
|
+
returns trigger as $$
|
|
24
|
+
begin
|
|
25
|
+
delete from secrets
|
|
26
|
+
where id in (
|
|
27
|
+
select secret_id from secret_social_connector_relations
|
|
28
|
+
where tenant_id = old.tenant_id and connector_id = old.id
|
|
29
|
+
);
|
|
30
|
+
return old;
|
|
31
|
+
end;
|
|
32
|
+
$$ language plpgsql;
|
|
33
|
+
|
|
34
|
+
create trigger delete_secrets_before_social_connector_delete
|
|
35
|
+
before delete on connectors
|
|
36
|
+
for each row
|
|
37
|
+
execute procedure delete_secrets_on_social_connector_delete();
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
/** Trigger function to delete associated secrets when social identities are deleted. */
|
|
41
|
+
create function delete_secrets_on_social_identity_delete()
|
|
42
|
+
returns trigger as $$
|
|
43
|
+
declare
|
|
44
|
+
identity_target text;
|
|
45
|
+
old_identity jsonb;
|
|
46
|
+
new_identity jsonb;
|
|
47
|
+
begin
|
|
48
|
+
-- Loop over old identities to detect deletions or modifications
|
|
49
|
+
for identity_target in select jsonb_object_keys(old.identities)
|
|
50
|
+
loop
|
|
51
|
+
old_identity := old.identities -> identity_target;
|
|
52
|
+
new_identity := new.identities -> identity_target;
|
|
53
|
+
|
|
54
|
+
-- If the identity was deleted or modified, delete the associated secret
|
|
55
|
+
if new_identity is null or (new_identity->>'userId') is distinct from (old_identity->>'userId') then
|
|
56
|
+
-- Identity was removed or changed, delete the corresponding secrets
|
|
57
|
+
delete from secrets
|
|
58
|
+
using secret_social_connector_relations
|
|
59
|
+
where secrets.id = secret_social_connector_relations.secret_id
|
|
60
|
+
-- Ensure we are deleting the correct social identity
|
|
61
|
+
and secret_social_connector_relations.target = identity_target
|
|
62
|
+
and secret_social_connector_relations.identity_id = old_identity->>'userId'
|
|
63
|
+
-- Ensure we delete the correct user's secret
|
|
64
|
+
and secrets.user_id = old.id;
|
|
65
|
+
end if;
|
|
66
|
+
end loop;
|
|
67
|
+
|
|
68
|
+
return new;
|
|
69
|
+
end;
|
|
70
|
+
$$ language plpgsql;
|
|
71
|
+
|
|
72
|
+
create trigger delete_secrets_before_social_identity_delete
|
|
73
|
+
before update of identities on users
|
|
74
|
+
for each row
|
|
75
|
+
execute procedure delete_secrets_on_social_identity_delete();
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/* init_order = 2 */
|
|
2
|
+
create table secrets (
|
|
3
|
+
tenant_id varchar(21) not null
|
|
4
|
+
references tenants (id) on update cascade on delete cascade,
|
|
5
|
+
id varchar(21) not null primary key,
|
|
6
|
+
user_id varchar(21) not null
|
|
7
|
+
references users (id) on update cascade on delete cascade,
|
|
8
|
+
type varchar(256) /* @use SecretType */ not null,
|
|
9
|
+
/** Encrypted data encryption key (DEK) for the secret. */
|
|
10
|
+
encrypted_dek bytea /* @use BufferLike */ not null,
|
|
11
|
+
/** Initialization vector for the secret encryption. */
|
|
12
|
+
iv bytea /* @use BufferLike */ not null,
|
|
13
|
+
/** Authentication tag for the secret encryption. */
|
|
14
|
+
auth_tag bytea /* @use BufferLike */ not null,
|
|
15
|
+
/** The encrypted secret data. e.g. { access_token, refresh_token } */
|
|
16
|
+
ciphertext bytea /* @use BufferLike */ not null,
|
|
17
|
+
/** The metadata associated with the secret. */
|
|
18
|
+
metadata jsonb /* @use JsonObject */ not null default '{}'::jsonb,
|
|
19
|
+
created_at timestamptz not null default(now()),
|
|
20
|
+
updated_at timestamptz not null default(now())
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
create trigger set_updated_at
|
|
24
|
+
before update on secrets
|
|
25
|
+
for each row
|
|
26
|
+
execute procedure set_updated_at();
|
|
@@ -16,6 +16,8 @@ create table sso_connectors (
|
|
|
16
16
|
branding jsonb /* @use SsoBranding */ not null default '{}'::jsonb,
|
|
17
17
|
/** Determines whether to synchronize the user's profile on each login. */
|
|
18
18
|
sync_profile boolean not null default FALSE,
|
|
19
|
+
/** Whether the token storage is enabled for this connector. Only applied for OAuth2/OIDC SSO connectors. */
|
|
20
|
+
enable_token_storage boolean not null default FALSE,
|
|
19
21
|
/** When the SSO connector was created. */
|
|
20
22
|
created_at timestamptz not null default(now()),
|
|
21
23
|
primary key (id),
|
|
@@ -10,7 +10,9 @@ create table user_sso_identities (
|
|
|
10
10
|
/** Provider user identity id*/
|
|
11
11
|
identity_id varchar(128) not null,
|
|
12
12
|
detail jsonb /* @use JsonObject */ not null default '{}'::jsonb,
|
|
13
|
+
/** Known issue: created_at uses timestamp instead of timestamptz */
|
|
13
14
|
created_at timestamp not null default(now()),
|
|
15
|
+
updated_at timestamptz not null default(now()),
|
|
14
16
|
sso_connector_id
|
|
15
17
|
varchar(128) not null
|
|
16
18
|
references sso_connectors (id) on update cascade on delete cascade,
|
|
@@ -18,3 +20,9 @@ create table user_sso_identities (
|
|
|
18
20
|
constraint user_sso_identities__issuer__identity_id
|
|
19
21
|
unique (tenant_id, issuer, identity_id)
|
|
20
22
|
);
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
create trigger set_updated_at
|
|
26
|
+
before update on user_sso_identities
|
|
27
|
+
for each row
|
|
28
|
+
execute procedure set_updated_at();
|
package/tables/users.sql
CHANGED
|
@@ -9,7 +9,7 @@ create table users (
|
|
|
9
9
|
username varchar(128),
|
|
10
10
|
primary_email varchar(128),
|
|
11
11
|
primary_phone varchar(128),
|
|
12
|
-
password_encrypted varchar(
|
|
12
|
+
password_encrypted varchar(256),
|
|
13
13
|
password_encryption_method users_password_encryption_method,
|
|
14
14
|
name varchar(128),
|
|
15
15
|
/** The URL that points to the user's profile picture. Mapped to OpenID Connect's `picture` claim. */
|
|
@@ -34,7 +34,8 @@ create table users (
|
|
|
34
34
|
unique (tenant_id, primary_phone)
|
|
35
35
|
);
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
/* Unique index on (tenant_id, id) required for foreign key constraint in organization_user_relations table. */
|
|
38
|
+
create unique index users__id
|
|
38
39
|
on users (tenant_id, id);
|
|
39
40
|
|
|
40
41
|
create index users__name
|
|
File without changes
|
|
File without changes
|