@logto/schemas 1.29.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.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.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/connector.d.ts +5 -1
- package/lib/db-entries/connector.js +4 -0
- package/lib/db-entries/index.d.ts +2 -1
- package/lib/db-entries/index.js +2 -1
- 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 +9 -9
- package/lib/db-entries/secret.js +9 -9
- package/lib/db-entries/sso-connector.d.ts +5 -1
- package/lib/db-entries/sso-connector.js +4 -0
- package/lib/foundations/jsonb-types/custom-profile-fields.d.ts +336 -11
- package/lib/foundations/jsonb-types/custom-profile-fields.js +17 -9
- package/lib/foundations/jsonb-types/secrets.d.ts +2 -0
- package/lib/foundations/jsonb-types/secrets.js +5 -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 +94 -0
- package/lib/foundations/jsonb-types/users.js +11 -0
- package/lib/types/connector.d.ts +39 -0
- package/lib/types/connector.js +1 -0
- package/lib/types/consent.d.ts +40 -0
- package/lib/types/custom-profile-fields.d.ts +1410 -133
- package/lib/types/custom-profile-fields.js +51 -15
- package/lib/types/index.d.ts +2 -0
- package/lib/types/index.js +2 -0
- package/lib/types/interactions.d.ts +175 -1
- package/lib/types/interactions.js +48 -1
- package/lib/types/logto-config/index.d.ts +214 -179
- package/lib/types/logto-config/jwt-customizer.d.ts +453 -328
- package/lib/types/logto-config/jwt-customizer.js +6 -1
- package/lib/types/secrets.d.ts +436 -0
- package/lib/types/secrets.js +73 -0
- package/lib/types/sign-in-experience.d.ts +19 -1
- package/lib/types/sign-in-experience.js +3 -1
- package/lib/types/sso-connector.d.ts +5 -2
- 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 +615 -0
- package/lib/types/user.js +14 -1
- package/lib/types/verification-records/backup-code-verification.d.ts +18 -0
- package/lib/types/verification-records/backup-code-verification.js +3 -0
- package/lib/types/verification-records/enterprise-sso-verification.d.ts +145 -0
- package/lib/types/verification-records/enterprise-sso-verification.js +5 -0
- package/lib/types/verification-records/new-password-identity-verification.d.ts +31 -0
- package/lib/types/verification-records/new-password-identity-verification.js +4 -0
- package/lib/types/verification-records/social-verification.d.ts +164 -0
- package/lib/types/verification-records/social-verification.js +6 -0
- package/lib/types/verification-records/totp-verification.d.ts +18 -0
- package/lib/types/verification-records/totp-verification.js +3 -0
- package/lib/types/verification-records/web-authn-verification.d.ts +44 -0
- package/lib/types/verification-records/web-authn-verification.js +5 -0
- package/package.json +6 -6
- package/tables/account_centers.sql +1 -1
- package/tables/connectors.sql +2 -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 +4 -4
- package/tables/sso_connectors.sql +2 -0
- package/tables/users.sql +2 -1
- package/lib/db-entries/secret-connector-relation.d.ts +0 -40
- package/lib/db-entries/secret-connector-relation.js +0 -49
- package/tables/secret_connector_relations.sql +0 -78
|
@@ -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();
|
package/tables/secrets.sql
CHANGED
|
@@ -7,13 +7,13 @@ create table secrets (
|
|
|
7
7
|
references users (id) on update cascade on delete cascade,
|
|
8
8
|
type varchar(256) /* @use SecretType */ not null,
|
|
9
9
|
/** Encrypted data encryption key (DEK) for the secret. */
|
|
10
|
-
encrypted_dek bytea not null,
|
|
10
|
+
encrypted_dek bytea /* @use BufferLike */ not null,
|
|
11
11
|
/** Initialization vector for the secret encryption. */
|
|
12
|
-
iv bytea not null,
|
|
12
|
+
iv bytea /* @use BufferLike */ not null,
|
|
13
13
|
/** Authentication tag for the secret encryption. */
|
|
14
|
-
auth_tag bytea not null,
|
|
14
|
+
auth_tag bytea /* @use BufferLike */ not null,
|
|
15
15
|
/** The encrypted secret data. e.g. { access_token, refresh_token } */
|
|
16
|
-
ciphertext bytea not null,
|
|
16
|
+
ciphertext bytea /* @use BufferLike */ not null,
|
|
17
17
|
/** The metadata associated with the secret. */
|
|
18
18
|
metadata jsonb /* @use JsonObject */ not null default '{}'::jsonb,
|
|
19
19
|
created_at timestamptz not null default(now()),
|
|
@@ -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),
|
package/tables/users.sql
CHANGED
|
@@ -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
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { GeneratedSchema } from './../foundations/index.js';
|
|
2
|
-
/**
|
|
3
|
-
*
|
|
4
|
-
* @remarks This is a type for database creation.
|
|
5
|
-
* @see {@link SecretConnectorRelation} for the original type.
|
|
6
|
-
*/
|
|
7
|
-
export type CreateSecretConnectorRelation = {
|
|
8
|
-
tenantId?: string;
|
|
9
|
-
secretId: string;
|
|
10
|
-
/** 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. */
|
|
11
|
-
connectorId?: string | null;
|
|
12
|
-
/** 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. */
|
|
13
|
-
ssoConnectorId?: string | null;
|
|
14
|
-
/** The target of the social connector. e.g. 'github', 'google', etc. */
|
|
15
|
-
socialConnectorTarget?: string | null;
|
|
16
|
-
/** User social identity ID foreign reference. Only present for secrets that store social identity tokens. */
|
|
17
|
-
socialIdentityId?: string | null;
|
|
18
|
-
/** User sso connector issuer. Only present for secrets that store SSO connector tokens. */
|
|
19
|
-
ssoConnectorIssuer?: string | null;
|
|
20
|
-
/** User SSO identity ID. Only present for secrets that store SSO identity tokens. */
|
|
21
|
-
ssoIdentityId?: string | null;
|
|
22
|
-
};
|
|
23
|
-
export type SecretConnectorRelation = {
|
|
24
|
-
tenantId: string;
|
|
25
|
-
secretId: string;
|
|
26
|
-
/** 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. */
|
|
27
|
-
connectorId: string | null;
|
|
28
|
-
/** 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. */
|
|
29
|
-
ssoConnectorId: string | null;
|
|
30
|
-
/** The target of the social connector. e.g. 'github', 'google', etc. */
|
|
31
|
-
socialConnectorTarget: string | null;
|
|
32
|
-
/** User social identity ID foreign reference. Only present for secrets that store social identity tokens. */
|
|
33
|
-
socialIdentityId: string | null;
|
|
34
|
-
/** User sso connector issuer. Only present for secrets that store SSO connector tokens. */
|
|
35
|
-
ssoConnectorIssuer: string | null;
|
|
36
|
-
/** User SSO identity ID. Only present for secrets that store SSO identity tokens. */
|
|
37
|
-
ssoIdentityId: string | null;
|
|
38
|
-
};
|
|
39
|
-
export type SecretConnectorRelationKeys = 'tenantId' | 'secretId' | 'connectorId' | 'ssoConnectorId' | 'socialConnectorTarget' | 'socialIdentityId' | 'ssoConnectorIssuer' | 'ssoIdentityId';
|
|
40
|
-
export declare const SecretConnectorRelations: GeneratedSchema<SecretConnectorRelationKeys, CreateSecretConnectorRelation, SecretConnectorRelation, 'secret_connector_relations', 'secret_connector_relation'>;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
const createGuard = z.object({
|
|
4
|
-
tenantId: z.string().max(21).optional(),
|
|
5
|
-
secretId: z.string().min(1).max(21),
|
|
6
|
-
connectorId: z.string().max(128).nullable().optional(),
|
|
7
|
-
ssoConnectorId: z.string().max(128).nullable().optional(),
|
|
8
|
-
socialConnectorTarget: z.string().max(256).nullable().optional(),
|
|
9
|
-
socialIdentityId: z.string().max(128).nullable().optional(),
|
|
10
|
-
ssoConnectorIssuer: z.string().max(256).nullable().optional(),
|
|
11
|
-
ssoIdentityId: z.string().max(128).nullable().optional(),
|
|
12
|
-
});
|
|
13
|
-
const guard = z.object({
|
|
14
|
-
tenantId: z.string().max(21),
|
|
15
|
-
secretId: z.string().min(1).max(21),
|
|
16
|
-
connectorId: z.string().max(128).nullable(),
|
|
17
|
-
ssoConnectorId: z.string().max(128).nullable(),
|
|
18
|
-
socialConnectorTarget: z.string().max(256).nullable(),
|
|
19
|
-
socialIdentityId: z.string().max(128).nullable(),
|
|
20
|
-
ssoConnectorIssuer: z.string().max(256).nullable(),
|
|
21
|
-
ssoIdentityId: z.string().max(128).nullable(),
|
|
22
|
-
});
|
|
23
|
-
export const SecretConnectorRelations = Object.freeze({
|
|
24
|
-
table: 'secret_connector_relations',
|
|
25
|
-
tableSingular: 'secret_connector_relation',
|
|
26
|
-
fields: {
|
|
27
|
-
tenantId: 'tenant_id',
|
|
28
|
-
secretId: 'secret_id',
|
|
29
|
-
connectorId: 'connector_id',
|
|
30
|
-
ssoConnectorId: 'sso_connector_id',
|
|
31
|
-
socialConnectorTarget: 'social_connector_target',
|
|
32
|
-
socialIdentityId: 'social_identity_id',
|
|
33
|
-
ssoConnectorIssuer: 'sso_connector_issuer',
|
|
34
|
-
ssoIdentityId: 'sso_identity_id',
|
|
35
|
-
},
|
|
36
|
-
fieldKeys: [
|
|
37
|
-
'tenantId',
|
|
38
|
-
'secretId',
|
|
39
|
-
'connectorId',
|
|
40
|
-
'ssoConnectorId',
|
|
41
|
-
'socialConnectorTarget',
|
|
42
|
-
'socialIdentityId',
|
|
43
|
-
'ssoConnectorIssuer',
|
|
44
|
-
'ssoIdentityId',
|
|
45
|
-
],
|
|
46
|
-
createGuard,
|
|
47
|
-
guard,
|
|
48
|
-
updateGuard: guard.partial(),
|
|
49
|
-
});
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
/* init_order = 3 */
|
|
2
|
-
|
|
3
|
-
create table secret_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)
|
|
10
|
-
references connectors (id) on update cascade,
|
|
11
|
-
/** 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.*/
|
|
12
|
-
sso_connector_id varchar(128)
|
|
13
|
-
references sso_connectors (id) on update cascade,
|
|
14
|
-
/** The target of the social connector. e.g. 'github', 'google', etc. */
|
|
15
|
-
social_connector_target varchar(256),
|
|
16
|
-
/** User social identity ID foreign reference. Only present for secrets that store social identity tokens. */
|
|
17
|
-
social_identity_id varchar(128),
|
|
18
|
-
/** User sso connector issuer. Only present for secrets that store SSO connector tokens. */
|
|
19
|
-
sso_connector_issuer varchar(256),
|
|
20
|
-
/** User SSO identity ID. Only present for secrets that store SSO identity tokens. */
|
|
21
|
-
sso_identity_id varchar(128),
|
|
22
|
-
primary key (tenant_id, secret_id),
|
|
23
|
-
/** Ensures that each social identity is associated with only one secret. */
|
|
24
|
-
constraint secret_connector_relations__target__social_identity_id
|
|
25
|
-
unique (tenant_id, social_connector_target, social_identity_id),
|
|
26
|
-
/** Ensures that each SSO identity is associated with only one secret. */
|
|
27
|
-
foreign key (tenant_id, sso_connector_issuer, sso_identity_id)
|
|
28
|
-
references user_sso_identities (tenant_id, issuer, identity_id) on update cascade,
|
|
29
|
-
/** Ensure that each secret is associated with a social connector or SSO connector, but not both at the same time. */
|
|
30
|
-
constraint secret_connector_relations__connector_id__sso_connector_id
|
|
31
|
-
check (
|
|
32
|
-
(
|
|
33
|
-
connector_id is not null and social_connector_target is not null and social_identity_id is not null and
|
|
34
|
-
sso_connector_id is null and sso_identity_id is null
|
|
35
|
-
) or (
|
|
36
|
-
connector_id is null and social_connector_target is null and social_identity_id is null and
|
|
37
|
-
sso_connector_id is not null and sso_identity_id is not null
|
|
38
|
-
)
|
|
39
|
-
)
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
/** Trigger function to delete secrets when the social connector is deleted. */
|
|
44
|
-
create function delete_secrets_on_social_connector_delete()
|
|
45
|
-
returns trigger as $$
|
|
46
|
-
begin
|
|
47
|
-
delete from secrets
|
|
48
|
-
where id in (
|
|
49
|
-
select secret_id from secret_connector_relations
|
|
50
|
-
where tenant_id = old.tenant_id and connector_id = old.id
|
|
51
|
-
);
|
|
52
|
-
return old;
|
|
53
|
-
end;
|
|
54
|
-
$$ language plpgsql;
|
|
55
|
-
|
|
56
|
-
create trigger delete_secrets_before_social_connector_delete
|
|
57
|
-
before delete on connectors
|
|
58
|
-
for each row
|
|
59
|
-
execute procedure delete_secrets_on_social_connector_delete();
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
/** Trigger function to delete secrets when the SSO connector is deleted. */
|
|
63
|
-
create function delete_secrets_on_sso_connector_delete()
|
|
64
|
-
returns trigger as $$
|
|
65
|
-
begin
|
|
66
|
-
delete from secrets
|
|
67
|
-
where id in (
|
|
68
|
-
select secret_id from secret_connector_relations
|
|
69
|
-
where tenant_id = old.tenant_id and sso_connector_id = old.id
|
|
70
|
-
);
|
|
71
|
-
return old;
|
|
72
|
-
end;
|
|
73
|
-
$$ language plpgsql;
|
|
74
|
-
|
|
75
|
-
create trigger delete_secrets_before_sso_connector_delete
|
|
76
|
-
before delete on sso_connectors
|
|
77
|
-
for each row
|
|
78
|
-
execute procedure delete_secrets_on_sso_connector_delete();
|