@logto/schemas 1.8.0 → 1.9.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.9.0-1693554904-add-possword-policy.ts +21 -0
- package/alterations/1.9.0-1694399696-add-type-col-to-roles-table.ts +55 -0
- package/alterations/1.9.0-1694418765-specify-check-role-type-function-to-be-public-schema.ts +54 -0
- package/alterations/1.9.0-1694484927-remove-deprecated-challenge-flag.ts +100 -0
- package/alterations/1.9.0-1694487524-sie-mfa.ts +26 -0
- package/alterations/1.9.0-1694509714-keep-existing-password-policy.ts +54 -0
- package/alterations/1.9.0-1694746763-user-verifications.ts +20 -0
- package/alterations-js/1.9.0-1693554904-add-possword-policy.d.ts +4 -0
- package/alterations-js/1.9.0-1693554904-add-possword-policy.js +17 -0
- package/alterations-js/1.9.0-1694399696-add-type-col-to-roles-table.d.ts +3 -0
- package/alterations-js/1.9.0-1694399696-add-type-col-to-roles-table.js +44 -0
- package/alterations-js/1.9.0-1694418765-specify-check-role-type-function-to-be-public-schema.d.ts +9 -0
- package/alterations-js/1.9.0-1694418765-specify-check-role-type-function-to-be-public-schema.js +42 -0
- package/alterations-js/1.9.0-1694484927-remove-deprecated-challenge-flag.d.ts +3 -0
- package/alterations-js/1.9.0-1694484927-remove-deprecated-challenge-flag.js +35 -0
- package/alterations-js/1.9.0-1694487524-sie-mfa.d.ts +3 -0
- package/alterations-js/1.9.0-1694487524-sie-mfa.js +21 -0
- package/alterations-js/1.9.0-1694509714-keep-existing-password-policy.d.ts +3 -0
- package/alterations-js/1.9.0-1694509714-keep-existing-password-policy.js +42 -0
- package/alterations-js/1.9.0-1694746763-user-verifications.d.ts +3 -0
- package/alterations-js/1.9.0-1694746763-user-verifications.js +16 -0
- package/lib/db-entries/custom-types.d.ts +4 -0
- package/lib/db-entries/custom-types.js +5 -0
- package/lib/db-entries/role.d.ts +3 -0
- package/lib/db-entries/role.js +5 -0
- package/lib/db-entries/sign-in-experience.d.ts +5 -1
- package/lib/db-entries/sign-in-experience.js +9 -1
- package/lib/db-entries/user.d.ts +3 -1
- package/lib/db-entries/user.js +5 -1
- package/lib/foundations/jsonb-types.d.ts +233 -26
- package/lib/foundations/jsonb-types.js +51 -21
- package/lib/models/tenants.d.ts +4 -4
- package/lib/seeds/cloud-api.d.ts +1 -1
- package/lib/seeds/cloud-api.js +2 -0
- package/lib/seeds/logto-config.js +0 -7
- package/lib/seeds/management-api.d.ts +2 -1
- package/lib/seeds/management-api.js +5 -0
- package/lib/seeds/sign-in-experience.js +6 -1
- package/lib/types/connector.d.ts +4 -4
- package/lib/types/hook.d.ts +13 -2
- package/lib/types/hook.js +4 -0
- package/lib/types/interactions.d.ts +1 -2
- package/lib/types/interactions.js +4 -5
- package/lib/types/logto-config.d.ts +0 -21
- package/lib/types/logto-config.js +0 -8
- package/lib/types/role.d.ts +4 -2
- package/lib/types/scope.d.ts +6 -6
- package/lib/types/system.d.ts +11 -8
- package/lib/types/system.js +6 -5
- package/lib/types/user.d.ts +195 -16
- package/lib/types/user.js +10 -0
- package/package.json +6 -6
- package/tables/applications_roles.sql +5 -1
- package/tables/roles.sql +8 -0
- package/tables/sign_in_experiences.sql +2 -0
- package/tables/users.sql +1 -0
- package/tables/users_roles.sql +5 -1
package/lib/types/user.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { Users } from '../db-entries/index.js';
|
|
3
|
+
import { MfaFactor } from '../foundations/jsonb-types.js';
|
|
3
4
|
export const userInfoSelectFields = Object.freeze([
|
|
4
5
|
'id',
|
|
5
6
|
'username',
|
|
@@ -18,6 +19,15 @@ export const userInfoGuard = Users.guard.pick(Object.fromEntries(userInfoSelectF
|
|
|
18
19
|
export const userProfileResponseGuard = userInfoGuard.extend({
|
|
19
20
|
hasPassword: z.boolean().optional(),
|
|
20
21
|
});
|
|
22
|
+
export const userMfaVerificationResponseGuard = z
|
|
23
|
+
.object({
|
|
24
|
+
id: z.string(),
|
|
25
|
+
createdAt: z.string(),
|
|
26
|
+
type: z.nativeEnum(MfaFactor),
|
|
27
|
+
agent: z.string().optional(),
|
|
28
|
+
used: z.boolean().optional(),
|
|
29
|
+
})
|
|
30
|
+
.array();
|
|
21
31
|
/** Internal read-only roles for user tenants. */
|
|
22
32
|
export var InternalRole;
|
|
23
33
|
(function (InternalRole) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logto/schemas",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"author": "Silverhand Inc. <contact@silverhand.io>",
|
|
5
5
|
"license": "MPL-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@silverhand/eslint-config": "4.0.1",
|
|
28
|
-
"@silverhand/essentials": "^2.
|
|
28
|
+
"@silverhand/essentials": "^2.8.4",
|
|
29
29
|
"@silverhand/ts-config": "4.0.0",
|
|
30
30
|
"@types/inquirer": "^9.0.0",
|
|
31
31
|
"@types/jest": "^29.4.0",
|
|
@@ -65,11 +65,11 @@
|
|
|
65
65
|
"prettier": "@silverhand/eslint-config/.prettierrc",
|
|
66
66
|
"dependencies": {
|
|
67
67
|
"@logto/connector-kit": "^1.1.1",
|
|
68
|
-
"@logto/core-kit": "^2.0
|
|
68
|
+
"@logto/core-kit": "^2.1.0",
|
|
69
69
|
"@logto/language-kit": "^1.0.0",
|
|
70
|
-
"@logto/phrases": "^1.
|
|
71
|
-
"@logto/phrases-
|
|
72
|
-
"@logto/shared": "^2.0.
|
|
70
|
+
"@logto/phrases": "^1.5.0",
|
|
71
|
+
"@logto/phrases-experience": "^1.3.0",
|
|
72
|
+
"@logto/shared": "^2.0.1",
|
|
73
73
|
"@withtyped/server": "^0.12.9"
|
|
74
74
|
},
|
|
75
75
|
"peerDependencies": {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/* init_order = 2 */
|
|
2
|
+
|
|
1
3
|
create table applications_roles (
|
|
2
4
|
tenant_id varchar(21) not null
|
|
3
5
|
references tenants (id) on update cascade on delete cascade,
|
|
@@ -8,7 +10,9 @@ create table applications_roles (
|
|
|
8
10
|
references roles (id) on update cascade on delete cascade,
|
|
9
11
|
primary key (id),
|
|
10
12
|
constraint applications_roles__application_id_role_id
|
|
11
|
-
unique (tenant_id, application_id, role_id)
|
|
13
|
+
unique (tenant_id, application_id, role_id),
|
|
14
|
+
constraint applications_roles__role_type
|
|
15
|
+
check (public.check_role_type(role_id, 'MachineToMachine'))
|
|
12
16
|
);
|
|
13
17
|
|
|
14
18
|
create index applications_roles__id
|
package/tables/roles.sql
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
/* init_order = 1 */
|
|
2
2
|
|
|
3
|
+
create type role_type as enum ('User', 'MachineToMachine');
|
|
4
|
+
|
|
3
5
|
create table roles (
|
|
4
6
|
tenant_id varchar(21) not null
|
|
5
7
|
references tenants (id) on update cascade on delete cascade,
|
|
6
8
|
id varchar(21) not null,
|
|
7
9
|
name varchar(128) not null,
|
|
8
10
|
description varchar(128) not null,
|
|
11
|
+
type role_type not null default 'User',
|
|
9
12
|
primary key (id),
|
|
10
13
|
constraint roles__name
|
|
11
14
|
unique (tenant_id, name)
|
|
@@ -13,3 +16,8 @@ create table roles (
|
|
|
13
16
|
|
|
14
17
|
create index roles__id
|
|
15
18
|
on roles (tenant_id, id);
|
|
19
|
+
|
|
20
|
+
create function public.check_role_type(role_id varchar(21), target_type role_type) returns boolean as
|
|
21
|
+
$$ begin
|
|
22
|
+
return (select type from public.roles where id = role_id) = target_type;
|
|
23
|
+
end; $$ language plpgsql;
|
|
@@ -15,5 +15,7 @@ create table sign_in_experiences (
|
|
|
15
15
|
sign_in_mode sign_in_mode not null default 'SignInAndRegister',
|
|
16
16
|
custom_css text,
|
|
17
17
|
custom_content jsonb /* @use CustomContent */ not null default '{}'::jsonb,
|
|
18
|
+
password_policy jsonb /* @use PartialPasswordPolicy */ not null default '{}'::jsonb,
|
|
19
|
+
mfa jsonb /* @use Mfa */ not null default '{}'::jsonb,
|
|
18
20
|
primary key (tenant_id, id)
|
|
19
21
|
);
|
package/tables/users.sql
CHANGED
|
@@ -16,6 +16,7 @@ create table users (
|
|
|
16
16
|
application_id varchar(21),
|
|
17
17
|
identities jsonb /* @use Identities */ not null default '{}'::jsonb,
|
|
18
18
|
custom_data jsonb /* @use JsonObject */ not null default '{}'::jsonb,
|
|
19
|
+
mfa_verifications jsonb /* @use MfaVerifications */ not null default '[]'::jsonb,
|
|
19
20
|
is_suspended boolean not null default false,
|
|
20
21
|
last_sign_in_at timestamptz,
|
|
21
22
|
created_at timestamptz not null default (now()),
|
package/tables/users_roles.sql
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/* init_order = 2 */
|
|
2
|
+
|
|
1
3
|
create table users_roles (
|
|
2
4
|
tenant_id varchar(21) not null
|
|
3
5
|
references tenants (id) on update cascade on delete cascade,
|
|
@@ -8,7 +10,9 @@ create table users_roles (
|
|
|
8
10
|
references roles (id) on update cascade on delete cascade,
|
|
9
11
|
primary key (id),
|
|
10
12
|
constraint users_roles__user_id_role_id
|
|
11
|
-
unique (tenant_id, user_id, role_id)
|
|
13
|
+
unique (tenant_id, user_id, role_id),
|
|
14
|
+
constraint users_roles__role_type
|
|
15
|
+
check (public.check_role_type(role_id, 'User'))
|
|
12
16
|
);
|
|
13
17
|
|
|
14
18
|
create index users_roles__id
|