@logto/schemas 1.15.0 → 1.16.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.16.0-1712912361-delete-jwt-customier-with-empty-script.ts +23 -0
- package/alterations/1.16.0-1713942039-add-organization-custom-data.ts +25 -0
- package/alterations/1.16.0-1714270244-application-org-resource-scope.ts +32 -0
- package/alterations-js/1.16.0-1712912361-delete-jwt-customier-with-empty-script.d.ts +3 -0
- package/alterations-js/1.16.0-1712912361-delete-jwt-customier-with-empty-script.js +17 -0
- package/alterations-js/1.16.0-1713942039-add-organization-custom-data.d.ts +4 -0
- package/alterations-js/1.16.0-1713942039-add-organization-custom-data.js +17 -0
- package/alterations-js/1.16.0-1714270244-application-org-resource-scope.d.ts +3 -0
- package/alterations-js/1.16.0-1714270244-application-org-resource-scope.js +27 -0
- package/lib/db-entries/application-user-consent-organization-resource-scope.d.ts +24 -0
- package/lib/db-entries/application-user-consent-organization-resource-scope.js +29 -0
- package/lib/db-entries/index.d.ts +1 -0
- package/lib/db-entries/index.js +1 -0
- package/lib/db-entries/organization.d.ts +6 -2
- package/lib/db-entries/organization.js +5 -0
- package/lib/foundations/jsonb-types/hooks.d.ts +71 -3
- package/lib/foundations/jsonb-types/hooks.js +98 -7
- package/lib/types/application.d.ts +81 -0
- package/lib/types/application.js +7 -4
- package/lib/types/consent.d.ts +207 -22
- package/lib/types/consent.js +11 -7
- package/lib/types/hook.d.ts +6 -20
- package/lib/types/logto-config/index.d.ts +20 -19
- package/lib/types/logto-config/jwt-customizer.d.ts +47 -40
- package/lib/types/logto-config/jwt-customizer.js +19 -24
- package/lib/types/logto-config/jwt-customizer.test.js +10 -2
- package/lib/types/organization.d.ts +0 -1
- package/lib/types/organization.js +0 -9
- package/lib/types/system.d.ts +28 -1
- package/lib/types/system.js +16 -0
- package/lib/types/user.d.ts +7 -7
- package/package.json +7 -7
- package/tables/application_user_consent_organization_resource_scopes.sql +18 -0
- package/tables/organizations.sql +2 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { sql } from '@silverhand/slonik';
|
|
2
|
+
|
|
3
|
+
import type { AlterationScript } from '../lib/types/alteration.js';
|
|
4
|
+
|
|
5
|
+
const alteration: AlterationScript = {
|
|
6
|
+
// We are making the jwt-customizer script field mandatory
|
|
7
|
+
// Delete the records in logto_configs where key is jwt.accessToken or jwt.clientCredentials and value jsonb's script field is undefined
|
|
8
|
+
up: async (pool) => {
|
|
9
|
+
await pool.query(
|
|
10
|
+
sql`
|
|
11
|
+
delete from logto_configs
|
|
12
|
+
where key in ('jwt.accessToken', 'jwt.clientCredentials')
|
|
13
|
+
and value->>'script' is null
|
|
14
|
+
`
|
|
15
|
+
);
|
|
16
|
+
},
|
|
17
|
+
down: async () => {
|
|
18
|
+
// No down script available, this is a non-reversible operation
|
|
19
|
+
// It is fine since we have not released this feature yet
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default alteration;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { sql } from '@silverhand/slonik';
|
|
2
|
+
|
|
3
|
+
import type { AlterationScript } from '../lib/types/alteration.js';
|
|
4
|
+
|
|
5
|
+
/** The alteration script to add the `custom_data` field to the `organizations` table. */
|
|
6
|
+
const alteration: AlterationScript = {
|
|
7
|
+
up: async (pool) => {
|
|
8
|
+
await pool.query(
|
|
9
|
+
sql`
|
|
10
|
+
alter table organizations
|
|
11
|
+
add column custom_data jsonb not null default '{}'::jsonb;
|
|
12
|
+
`
|
|
13
|
+
);
|
|
14
|
+
},
|
|
15
|
+
down: async (pool) => {
|
|
16
|
+
await pool.query(
|
|
17
|
+
sql`
|
|
18
|
+
alter table organizations
|
|
19
|
+
drop column custom_data;
|
|
20
|
+
`
|
|
21
|
+
);
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export default alteration;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { sql } from '@silverhand/slonik';
|
|
2
|
+
|
|
3
|
+
import type { AlterationScript } from '../lib/types/alteration.js';
|
|
4
|
+
|
|
5
|
+
import { applyTableRls, dropTableRls } from './utils/1704934999-tables.js';
|
|
6
|
+
|
|
7
|
+
const alteration: AlterationScript = {
|
|
8
|
+
up: async (pool) => {
|
|
9
|
+
await pool.query(sql`
|
|
10
|
+
create table application_user_consent_organization_resource_scopes (
|
|
11
|
+
tenant_id varchar(21) not null
|
|
12
|
+
references tenants (id) on update cascade on delete cascade,
|
|
13
|
+
/** The globally unique identifier of the application. */
|
|
14
|
+
application_id varchar(21) not null
|
|
15
|
+
references applications (id) on update cascade on delete cascade,
|
|
16
|
+
/** The globally unique identifier of the resource scope. */
|
|
17
|
+
scope_id varchar(21) not null
|
|
18
|
+
references scopes (id) on update cascade on delete cascade,
|
|
19
|
+
primary key (application_id, scope_id)
|
|
20
|
+
);
|
|
21
|
+
`);
|
|
22
|
+
await applyTableRls(pool, 'application_user_consent_organization_resource_scopes');
|
|
23
|
+
},
|
|
24
|
+
down: async (pool) => {
|
|
25
|
+
await dropTableRls(pool, 'application_user_consent_organization_resource_scopes');
|
|
26
|
+
await pool.query(sql`
|
|
27
|
+
drop table application_user_consent_organization_resource_scopes
|
|
28
|
+
`);
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export default alteration;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { sql } from '@silverhand/slonik';
|
|
2
|
+
const alteration = {
|
|
3
|
+
// We are making the jwt-customizer script field mandatory
|
|
4
|
+
// Delete the records in logto_configs where key is jwt.accessToken or jwt.clientCredentials and value jsonb's script field is undefined
|
|
5
|
+
up: async (pool) => {
|
|
6
|
+
await pool.query(sql `
|
|
7
|
+
delete from logto_configs
|
|
8
|
+
where key in ('jwt.accessToken', 'jwt.clientCredentials')
|
|
9
|
+
and value->>'script' is null
|
|
10
|
+
`);
|
|
11
|
+
},
|
|
12
|
+
down: async () => {
|
|
13
|
+
// No down script available, this is a non-reversible operation
|
|
14
|
+
// It is fine since we have not released this feature yet
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
export default alteration;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { sql } from '@silverhand/slonik';
|
|
2
|
+
/** The alteration script to add the `custom_data` field to the `organizations` table. */
|
|
3
|
+
const alteration = {
|
|
4
|
+
up: async (pool) => {
|
|
5
|
+
await pool.query(sql `
|
|
6
|
+
alter table organizations
|
|
7
|
+
add column custom_data jsonb not null default '{}'::jsonb;
|
|
8
|
+
`);
|
|
9
|
+
},
|
|
10
|
+
down: async (pool) => {
|
|
11
|
+
await pool.query(sql `
|
|
12
|
+
alter table organizations
|
|
13
|
+
drop column custom_data;
|
|
14
|
+
`);
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
export default alteration;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { sql } from '@silverhand/slonik';
|
|
2
|
+
import { applyTableRls, dropTableRls } from './utils/1704934999-tables.js';
|
|
3
|
+
const alteration = {
|
|
4
|
+
up: async (pool) => {
|
|
5
|
+
await pool.query(sql `
|
|
6
|
+
create table application_user_consent_organization_resource_scopes (
|
|
7
|
+
tenant_id varchar(21) not null
|
|
8
|
+
references tenants (id) on update cascade on delete cascade,
|
|
9
|
+
/** The globally unique identifier of the application. */
|
|
10
|
+
application_id varchar(21) not null
|
|
11
|
+
references applications (id) on update cascade on delete cascade,
|
|
12
|
+
/** The globally unique identifier of the resource scope. */
|
|
13
|
+
scope_id varchar(21) not null
|
|
14
|
+
references scopes (id) on update cascade on delete cascade,
|
|
15
|
+
primary key (application_id, scope_id)
|
|
16
|
+
);
|
|
17
|
+
`);
|
|
18
|
+
await applyTableRls(pool, 'application_user_consent_organization_resource_scopes');
|
|
19
|
+
},
|
|
20
|
+
down: async (pool) => {
|
|
21
|
+
await dropTableRls(pool, 'application_user_consent_organization_resource_scopes');
|
|
22
|
+
await pool.query(sql `
|
|
23
|
+
drop table application_user_consent_organization_resource_scopes
|
|
24
|
+
`);
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
export default alteration;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { GeneratedSchema } from './../foundations/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* The organization resource scopes (permissions) assigned to an application's consent request. This is different from the application_user_consent_resource_scopes table, scopes in this table is granted by the organization roles.
|
|
4
|
+
*
|
|
5
|
+
* @remarks This is a type for database creation.
|
|
6
|
+
* @see {@link ApplicationUserConsentOrganizationResourceScope} for the original type.
|
|
7
|
+
*/
|
|
8
|
+
export type CreateApplicationUserConsentOrganizationResourceScope = {
|
|
9
|
+
tenantId?: string;
|
|
10
|
+
/** The globally unique identifier of the application. */
|
|
11
|
+
applicationId: string;
|
|
12
|
+
/** The globally unique identifier of the resource scope. */
|
|
13
|
+
scopeId: string;
|
|
14
|
+
};
|
|
15
|
+
/** The organization resource scopes (permissions) assigned to an application's consent request. This is different from the application_user_consent_resource_scopes table, scopes in this table is granted by the organization roles. */
|
|
16
|
+
export type ApplicationUserConsentOrganizationResourceScope = {
|
|
17
|
+
tenantId: string;
|
|
18
|
+
/** The globally unique identifier of the application. */
|
|
19
|
+
applicationId: string;
|
|
20
|
+
/** The globally unique identifier of the resource scope. */
|
|
21
|
+
scopeId: string;
|
|
22
|
+
};
|
|
23
|
+
export type ApplicationUserConsentOrganizationResourceScopeKeys = 'tenantId' | 'applicationId' | 'scopeId';
|
|
24
|
+
export declare const ApplicationUserConsentOrganizationResourceScopes: GeneratedSchema<ApplicationUserConsentOrganizationResourceScopeKeys, CreateApplicationUserConsentOrganizationResourceScope, ApplicationUserConsentOrganizationResourceScope, 'application_user_consent_organization_resource_scopes', 'application_user_consent_organization_resource_scope'>;
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
applicationId: z.string().min(1).max(21),
|
|
6
|
+
scopeId: z.string().min(1).max(21),
|
|
7
|
+
});
|
|
8
|
+
const guard = z.object({
|
|
9
|
+
tenantId: z.string().max(21),
|
|
10
|
+
applicationId: z.string().min(1).max(21),
|
|
11
|
+
scopeId: z.string().min(1).max(21),
|
|
12
|
+
});
|
|
13
|
+
export const ApplicationUserConsentOrganizationResourceScopes = Object.freeze({
|
|
14
|
+
table: 'application_user_consent_organization_resource_scopes',
|
|
15
|
+
tableSingular: 'application_user_consent_organization_resource_scope',
|
|
16
|
+
fields: {
|
|
17
|
+
tenantId: 'tenant_id',
|
|
18
|
+
applicationId: 'application_id',
|
|
19
|
+
scopeId: 'scope_id',
|
|
20
|
+
},
|
|
21
|
+
fieldKeys: [
|
|
22
|
+
'tenantId',
|
|
23
|
+
'applicationId',
|
|
24
|
+
'scopeId',
|
|
25
|
+
],
|
|
26
|
+
createGuard,
|
|
27
|
+
guard,
|
|
28
|
+
updateGuard: guard.partial(),
|
|
29
|
+
});
|
|
@@ -4,6 +4,7 @@ export * from './-after-each.js';
|
|
|
4
4
|
export * from './-before-all.js';
|
|
5
5
|
export * from './-function.js';
|
|
6
6
|
export * from './application-sign-in-experience.js';
|
|
7
|
+
export * from './application-user-consent-organization-resource-scope.js';
|
|
7
8
|
export * from './application-user-consent-organization-scope.js';
|
|
8
9
|
export * from './application-user-consent-organization.js';
|
|
9
10
|
export * from './application-user-consent-resource-scope.js';
|
package/lib/db-entries/index.js
CHANGED
|
@@ -5,6 +5,7 @@ export * from './-after-each.js';
|
|
|
5
5
|
export * from './-before-all.js';
|
|
6
6
|
export * from './-function.js';
|
|
7
7
|
export * from './application-sign-in-experience.js';
|
|
8
|
+
export * from './application-user-consent-organization-resource-scope.js';
|
|
8
9
|
export * from './application-user-consent-organization-scope.js';
|
|
9
10
|
export * from './application-user-consent-organization.js';
|
|
10
11
|
export * from './application-user-consent-resource-scope.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GeneratedSchema } from './../foundations/index.js';
|
|
1
|
+
import { JsonObject, GeneratedSchema } from './../foundations/index.js';
|
|
2
2
|
/**
|
|
3
3
|
* Organizations defined by [RFC 0001](https://github.com/logto-io/rfcs/blob/HEAD/active/0001-organization.md).
|
|
4
4
|
*
|
|
@@ -13,6 +13,8 @@ export type CreateOrganization = {
|
|
|
13
13
|
name: string;
|
|
14
14
|
/** A brief description of the organization. */
|
|
15
15
|
description?: string | null;
|
|
16
|
+
/** Additional data associated with the organization. */
|
|
17
|
+
customData?: JsonObject;
|
|
16
18
|
/** When the organization was created. */
|
|
17
19
|
createdAt?: number;
|
|
18
20
|
};
|
|
@@ -25,8 +27,10 @@ export type Organization = {
|
|
|
25
27
|
name: string;
|
|
26
28
|
/** A brief description of the organization. */
|
|
27
29
|
description: string | null;
|
|
30
|
+
/** Additional data associated with the organization. */
|
|
31
|
+
customData: JsonObject;
|
|
28
32
|
/** When the organization was created. */
|
|
29
33
|
createdAt: number;
|
|
30
34
|
};
|
|
31
|
-
export type OrganizationKeys = 'tenantId' | 'id' | 'name' | 'description' | 'createdAt';
|
|
35
|
+
export type OrganizationKeys = 'tenantId' | 'id' | 'name' | 'description' | 'customData' | 'createdAt';
|
|
32
36
|
export declare const Organizations: GeneratedSchema<OrganizationKeys, CreateOrganization, Organization, 'organizations', 'organization'>;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
+
import { jsonObjectGuard } from './../foundations/index.js';
|
|
3
4
|
const createGuard = z.object({
|
|
4
5
|
tenantId: z.string().max(21).optional(),
|
|
5
6
|
id: z.string().min(1).max(21),
|
|
6
7
|
name: z.string().min(1).max(128),
|
|
7
8
|
description: z.string().max(256).nullable().optional(),
|
|
9
|
+
customData: jsonObjectGuard.optional(),
|
|
8
10
|
createdAt: z.number().optional(),
|
|
9
11
|
});
|
|
10
12
|
const guard = z.object({
|
|
@@ -12,6 +14,7 @@ const guard = z.object({
|
|
|
12
14
|
id: z.string().min(1).max(21),
|
|
13
15
|
name: z.string().min(1).max(128),
|
|
14
16
|
description: z.string().max(256).nullable(),
|
|
17
|
+
customData: jsonObjectGuard,
|
|
15
18
|
createdAt: z.number(),
|
|
16
19
|
});
|
|
17
20
|
export const Organizations = Object.freeze({
|
|
@@ -22,6 +25,7 @@ export const Organizations = Object.freeze({
|
|
|
22
25
|
id: 'id',
|
|
23
26
|
name: 'name',
|
|
24
27
|
description: 'description',
|
|
28
|
+
customData: 'custom_data',
|
|
25
29
|
createdAt: 'created_at',
|
|
26
30
|
},
|
|
27
31
|
fieldKeys: [
|
|
@@ -29,6 +33,7 @@ export const Organizations = Object.freeze({
|
|
|
29
33
|
'id',
|
|
30
34
|
'name',
|
|
31
35
|
'description',
|
|
36
|
+
'customData',
|
|
32
37
|
'createdAt',
|
|
33
38
|
],
|
|
34
39
|
createGuard,
|
|
@@ -1,12 +1,43 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* We categorize the hook events into two types:
|
|
4
|
+
*
|
|
5
|
+
* InteractionHookEvent: The hook events that are triggered by user interactions.
|
|
6
|
+
* DataHookEvent: The hook events that are triggered by Logto data mutations.
|
|
7
|
+
*/
|
|
8
|
+
export declare enum InteractionHookEvent {
|
|
3
9
|
PostRegister = "PostRegister",
|
|
4
10
|
PostSignIn = "PostSignIn",
|
|
5
11
|
PostResetPassword = "PostResetPassword"
|
|
6
12
|
}
|
|
7
|
-
|
|
8
|
-
|
|
13
|
+
declare enum DataHookSchema {
|
|
14
|
+
User = "User",
|
|
15
|
+
Role = "Role",
|
|
16
|
+
Scope = "Scope",
|
|
17
|
+
Organization = "Organization",
|
|
18
|
+
OrganizationRole = "OrganizationRole",
|
|
19
|
+
OrganizationScope = "OrganizationScope"
|
|
20
|
+
}
|
|
21
|
+
declare enum DataHookBasicMutationType {
|
|
22
|
+
Created = "Created",
|
|
23
|
+
Deleted = "Deleted",
|
|
24
|
+
Updated = "Updated"
|
|
25
|
+
}
|
|
26
|
+
type BasicDataHookEvent = `${DataHookSchema}.${DataHookBasicMutationType}`;
|
|
27
|
+
type CustomDataHookMutableSchema = `${DataHookSchema.User}.SuspensionStatus` | `${DataHookSchema.Role}.Scopes` | `${DataHookSchema.Organization}.Membership` | `${DataHookSchema.OrganizationRole}.Scopes`;
|
|
28
|
+
type DataHookPropertyUpdateEvent = `${CustomDataHookMutableSchema}.${DataHookBasicMutationType.Updated}`;
|
|
29
|
+
export type DataHookEvent = BasicDataHookEvent | DataHookPropertyUpdateEvent;
|
|
30
|
+
/** The hook event values that can be registered. */
|
|
31
|
+
export declare const hookEvents: readonly [InteractionHookEvent.PostRegister, InteractionHookEvent.PostSignIn, InteractionHookEvent.PostResetPassword, "User.Created", "User.Deleted", "User.Updated", "User.SuspensionStatus.Updated", "Role.Created", "Role.Deleted", "Role.Updated", "Role.Scopes.Updated", "Scope.Created", "Scope.Deleted", "Scope.Updated", "Organization.Created", "Organization.Deleted", "Organization.Updated", "Organization.Membership.Updated", "OrganizationRole.Created", "OrganizationRole.Deleted", "OrganizationRole.Updated", "OrganizationRole.Scopes.Updated", "OrganizationScope.Created", "OrganizationScope.Deleted", "OrganizationScope.Updated"];
|
|
32
|
+
/** The type of hook event values that can be registered. */
|
|
33
|
+
export type HookEvent = (typeof hookEvents)[number];
|
|
34
|
+
export declare const hookEventGuard: z.ZodEnum<[InteractionHookEvent.PostRegister, InteractionHookEvent.PostSignIn, InteractionHookEvent.PostResetPassword, "User.Created", "User.Deleted", "User.Updated", "User.SuspensionStatus.Updated", "Role.Created", "Role.Deleted", "Role.Updated", "Role.Scopes.Updated", "Scope.Created", "Scope.Deleted", "Scope.Updated", "Organization.Created", "Organization.Deleted", "Organization.Updated", "Organization.Membership.Updated", "OrganizationRole.Created", "OrganizationRole.Deleted", "OrganizationRole.Updated", "OrganizationRole.Scopes.Updated", "OrganizationScope.Created", "OrganizationScope.Deleted", "OrganizationScope.Updated"]>;
|
|
35
|
+
export declare const hookEventsGuard: z.ZodArray<z.ZodEnum<[InteractionHookEvent.PostRegister, InteractionHookEvent.PostSignIn, InteractionHookEvent.PostResetPassword, "User.Created", "User.Deleted", "User.Updated", "User.SuspensionStatus.Updated", "Role.Created", "Role.Deleted", "Role.Updated", "Role.Scopes.Updated", "Scope.Created", "Scope.Deleted", "Scope.Updated", "Organization.Created", "Organization.Deleted", "Organization.Updated", "Organization.Membership.Updated", "OrganizationRole.Created", "OrganizationRole.Deleted", "OrganizationRole.Updated", "OrganizationRole.Scopes.Updated", "OrganizationScope.Created", "OrganizationScope.Deleted", "OrganizationScope.Updated"]>, "many">;
|
|
9
36
|
export type HookEvents = z.infer<typeof hookEventsGuard>;
|
|
37
|
+
export declare const interactionHookEventGuard: z.ZodNativeEnum<typeof InteractionHookEvent>;
|
|
38
|
+
/**
|
|
39
|
+
* Hook configuration for web hook.
|
|
40
|
+
*/
|
|
10
41
|
export declare const hookConfigGuard: z.ZodObject<{
|
|
11
42
|
/** We don't need `type` since v1 only has web hook */
|
|
12
43
|
/** Method fixed to `POST` */
|
|
@@ -30,3 +61,40 @@ export declare const hookConfigGuard: z.ZodObject<{
|
|
|
30
61
|
retries?: number | undefined;
|
|
31
62
|
}>;
|
|
32
63
|
export type HookConfig = z.infer<typeof hookConfigGuard>;
|
|
64
|
+
/**
|
|
65
|
+
* Management API hooks registration.
|
|
66
|
+
* Define the hook event that should be triggered when the management API is called.
|
|
67
|
+
*/
|
|
68
|
+
export declare const managementApiHooksRegistration: Readonly<{
|
|
69
|
+
'POST /users': "User.Created";
|
|
70
|
+
'DELETE /users/:userId': "User.Deleted";
|
|
71
|
+
'PATCH /users/:userId': "User.Updated";
|
|
72
|
+
'PATCH /users/:userId/custom-data': "User.Updated";
|
|
73
|
+
'PATCH /users/:userId/profile': "User.Updated";
|
|
74
|
+
'PATCH /users/:userId/password': "User.Updated";
|
|
75
|
+
'PATCH /users/:userId/is-suspended': "User.SuspensionStatus.Updated";
|
|
76
|
+
'POST /roles': "Role.Created";
|
|
77
|
+
'DELETE /roles/:id': "Role.Deleted";
|
|
78
|
+
'PATCH /roles/:id': "Role.Updated";
|
|
79
|
+
'POST /roles/:id/scopes': "Role.Scopes.Updated";
|
|
80
|
+
'DELETE /roles/:id/scopes/:scopeId': "Role.Scopes.Updated";
|
|
81
|
+
'POST /resources/:resourceId/scopes': "Scope.Created";
|
|
82
|
+
'DELETE /resources/:resourceId/scopes/:scopeId': "Scope.Deleted";
|
|
83
|
+
'PATCH /resources/:resourceId/scopes/:scopeId': "Scope.Updated";
|
|
84
|
+
'POST /organizations': "Organization.Created";
|
|
85
|
+
'DELETE /organizations/:id': "Organization.Deleted";
|
|
86
|
+
'PATCH /organizations/:id': "Organization.Updated";
|
|
87
|
+
'PUT /organizations/:id/users': "Organization.Membership.Updated";
|
|
88
|
+
'POST /organizations/:id/users': "Organization.Membership.Updated";
|
|
89
|
+
'DELETE /organizations/:id/users/:userId': "Organization.Membership.Updated";
|
|
90
|
+
'POST /organization-roles': "OrganizationRole.Created";
|
|
91
|
+
'DELETE /organization-roles/:id': "OrganizationRole.Deleted";
|
|
92
|
+
'PATCH /organization-roles/:id': "OrganizationRole.Updated";
|
|
93
|
+
'POST /organization-scopes': "OrganizationScope.Created";
|
|
94
|
+
'DELETE /organization-scopes/:id': "OrganizationScope.Deleted";
|
|
95
|
+
'PATCH /organization-scopes/:id': "OrganizationScope.Updated";
|
|
96
|
+
'PUT /organization-roles/:id/scopes': "OrganizationRole.Scopes.Updated";
|
|
97
|
+
'POST /organization-roles/:id/scopes': "OrganizationRole.Scopes.Updated";
|
|
98
|
+
'DELETE /organization-roles/:id/scopes/:organizationScopeId': "OrganizationRole.Scopes.Updated";
|
|
99
|
+
}>;
|
|
100
|
+
export {};
|
|
@@ -1,12 +1,67 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
/**
|
|
3
|
+
* We categorize the hook events into two types:
|
|
4
|
+
*
|
|
5
|
+
* InteractionHookEvent: The hook events that are triggered by user interactions.
|
|
6
|
+
* DataHookEvent: The hook events that are triggered by Logto data mutations.
|
|
7
|
+
*/
|
|
8
|
+
// InteractionHookEvent
|
|
9
|
+
export var InteractionHookEvent;
|
|
10
|
+
(function (InteractionHookEvent) {
|
|
11
|
+
InteractionHookEvent["PostRegister"] = "PostRegister";
|
|
12
|
+
InteractionHookEvent["PostSignIn"] = "PostSignIn";
|
|
13
|
+
InteractionHookEvent["PostResetPassword"] = "PostResetPassword";
|
|
14
|
+
})(InteractionHookEvent || (InteractionHookEvent = {}));
|
|
15
|
+
// DataHookEvent
|
|
16
|
+
var DataHookSchema;
|
|
17
|
+
(function (DataHookSchema) {
|
|
18
|
+
DataHookSchema["User"] = "User";
|
|
19
|
+
DataHookSchema["Role"] = "Role";
|
|
20
|
+
DataHookSchema["Scope"] = "Scope";
|
|
21
|
+
DataHookSchema["Organization"] = "Organization";
|
|
22
|
+
DataHookSchema["OrganizationRole"] = "OrganizationRole";
|
|
23
|
+
DataHookSchema["OrganizationScope"] = "OrganizationScope";
|
|
24
|
+
})(DataHookSchema || (DataHookSchema = {}));
|
|
25
|
+
var DataHookBasicMutationType;
|
|
26
|
+
(function (DataHookBasicMutationType) {
|
|
27
|
+
DataHookBasicMutationType["Created"] = "Created";
|
|
28
|
+
DataHookBasicMutationType["Deleted"] = "Deleted";
|
|
29
|
+
DataHookBasicMutationType["Updated"] = "Updated";
|
|
30
|
+
})(DataHookBasicMutationType || (DataHookBasicMutationType = {}));
|
|
31
|
+
/** The hook event values that can be registered. */
|
|
32
|
+
export const hookEvents = Object.freeze([
|
|
33
|
+
InteractionHookEvent.PostRegister,
|
|
34
|
+
InteractionHookEvent.PostSignIn,
|
|
35
|
+
InteractionHookEvent.PostResetPassword,
|
|
36
|
+
'User.Created',
|
|
37
|
+
'User.Deleted',
|
|
38
|
+
'User.Updated',
|
|
39
|
+
'User.SuspensionStatus.Updated',
|
|
40
|
+
'Role.Created',
|
|
41
|
+
'Role.Deleted',
|
|
42
|
+
'Role.Updated',
|
|
43
|
+
'Role.Scopes.Updated',
|
|
44
|
+
'Scope.Created',
|
|
45
|
+
'Scope.Deleted',
|
|
46
|
+
'Scope.Updated',
|
|
47
|
+
'Organization.Created',
|
|
48
|
+
'Organization.Deleted',
|
|
49
|
+
'Organization.Updated',
|
|
50
|
+
'Organization.Membership.Updated',
|
|
51
|
+
'OrganizationRole.Created',
|
|
52
|
+
'OrganizationRole.Deleted',
|
|
53
|
+
'OrganizationRole.Updated',
|
|
54
|
+
'OrganizationRole.Scopes.Updated',
|
|
55
|
+
'OrganizationScope.Created',
|
|
56
|
+
'OrganizationScope.Deleted',
|
|
57
|
+
'OrganizationScope.Updated',
|
|
58
|
+
]);
|
|
59
|
+
export const hookEventGuard = z.enum(hookEvents);
|
|
9
60
|
export const hookEventsGuard = hookEventGuard.array();
|
|
61
|
+
export const interactionHookEventGuard = z.nativeEnum(InteractionHookEvent);
|
|
62
|
+
/**
|
|
63
|
+
* Hook configuration for web hook.
|
|
64
|
+
*/
|
|
10
65
|
export const hookConfigGuard = z.object({
|
|
11
66
|
/** We don't need `type` since v1 only has web hook */
|
|
12
67
|
// type: 'web';
|
|
@@ -22,3 +77,39 @@ export const hookConfigGuard = z.object({
|
|
|
22
77
|
*/
|
|
23
78
|
retries: z.number().gte(0).lte(3).optional(),
|
|
24
79
|
});
|
|
80
|
+
/**
|
|
81
|
+
* Management API hooks registration.
|
|
82
|
+
* Define the hook event that should be triggered when the management API is called.
|
|
83
|
+
*/
|
|
84
|
+
export const managementApiHooksRegistration = Object.freeze({
|
|
85
|
+
'POST /users': 'User.Created',
|
|
86
|
+
'DELETE /users/:userId': 'User.Deleted',
|
|
87
|
+
'PATCH /users/:userId': 'User.Updated',
|
|
88
|
+
'PATCH /users/:userId/custom-data': 'User.Updated',
|
|
89
|
+
'PATCH /users/:userId/profile': 'User.Updated',
|
|
90
|
+
'PATCH /users/:userId/password': 'User.Updated',
|
|
91
|
+
'PATCH /users/:userId/is-suspended': 'User.SuspensionStatus.Updated',
|
|
92
|
+
'POST /roles': 'Role.Created',
|
|
93
|
+
'DELETE /roles/:id': 'Role.Deleted',
|
|
94
|
+
'PATCH /roles/:id': 'Role.Updated',
|
|
95
|
+
'POST /roles/:id/scopes': 'Role.Scopes.Updated',
|
|
96
|
+
'DELETE /roles/:id/scopes/:scopeId': 'Role.Scopes.Updated',
|
|
97
|
+
'POST /resources/:resourceId/scopes': 'Scope.Created',
|
|
98
|
+
'DELETE /resources/:resourceId/scopes/:scopeId': 'Scope.Deleted',
|
|
99
|
+
'PATCH /resources/:resourceId/scopes/:scopeId': 'Scope.Updated',
|
|
100
|
+
'POST /organizations': 'Organization.Created',
|
|
101
|
+
'DELETE /organizations/:id': 'Organization.Deleted',
|
|
102
|
+
'PATCH /organizations/:id': 'Organization.Updated',
|
|
103
|
+
'PUT /organizations/:id/users': 'Organization.Membership.Updated',
|
|
104
|
+
'POST /organizations/:id/users': 'Organization.Membership.Updated',
|
|
105
|
+
'DELETE /organizations/:id/users/:userId': 'Organization.Membership.Updated',
|
|
106
|
+
'POST /organization-roles': 'OrganizationRole.Created',
|
|
107
|
+
'DELETE /organization-roles/:id': 'OrganizationRole.Deleted',
|
|
108
|
+
'PATCH /organization-roles/:id': 'OrganizationRole.Updated',
|
|
109
|
+
'POST /organization-scopes': 'OrganizationScope.Created',
|
|
110
|
+
'DELETE /organization-scopes/:id': 'OrganizationScope.Deleted',
|
|
111
|
+
'PATCH /organization-scopes/:id': 'OrganizationScope.Updated',
|
|
112
|
+
'PUT /organization-roles/:id/scopes': 'OrganizationRole.Scopes.Updated',
|
|
113
|
+
'POST /organization-roles/:id/scopes': 'OrganizationRole.Scopes.Updated',
|
|
114
|
+
'DELETE /organization-roles/:id/scopes/:organizationScopeId': 'OrganizationRole.Scopes.Updated',
|
|
115
|
+
});
|
|
@@ -548,6 +548,62 @@ export declare const applicationUserConsentScopesResponseGuard: z.ZodObject<{
|
|
|
548
548
|
description: string | null;
|
|
549
549
|
}[];
|
|
550
550
|
}>, "many">;
|
|
551
|
+
organizationResourceScopes: z.ZodArray<z.ZodObject<{
|
|
552
|
+
resource: z.ZodObject<Pick<{
|
|
553
|
+
tenantId: z.ZodType<string, z.ZodTypeDef, string>;
|
|
554
|
+
id: z.ZodType<string, z.ZodTypeDef, string>;
|
|
555
|
+
name: z.ZodType<string, z.ZodTypeDef, string>;
|
|
556
|
+
indicator: z.ZodType<string, z.ZodTypeDef, string>;
|
|
557
|
+
isDefault: z.ZodType<boolean, z.ZodTypeDef, boolean>;
|
|
558
|
+
accessTokenTtl: z.ZodType<number, z.ZodTypeDef, number>;
|
|
559
|
+
}, "name" | "id" | "indicator">, "strip", z.ZodTypeAny, {
|
|
560
|
+
name: string;
|
|
561
|
+
id: string;
|
|
562
|
+
indicator: string;
|
|
563
|
+
}, {
|
|
564
|
+
name: string;
|
|
565
|
+
id: string;
|
|
566
|
+
indicator: string;
|
|
567
|
+
}>;
|
|
568
|
+
scopes: z.ZodArray<z.ZodObject<Pick<{
|
|
569
|
+
tenantId: z.ZodType<string, z.ZodTypeDef, string>;
|
|
570
|
+
id: z.ZodType<string, z.ZodTypeDef, string>;
|
|
571
|
+
resourceId: z.ZodType<string, z.ZodTypeDef, string>;
|
|
572
|
+
name: z.ZodType<string, z.ZodTypeDef, string>;
|
|
573
|
+
description: z.ZodType<string | null, z.ZodTypeDef, string | null>;
|
|
574
|
+
createdAt: z.ZodType<number, z.ZodTypeDef, number>;
|
|
575
|
+
}, "name" | "id" | "description">, "strip", z.ZodTypeAny, {
|
|
576
|
+
name: string;
|
|
577
|
+
id: string;
|
|
578
|
+
description: string | null;
|
|
579
|
+
}, {
|
|
580
|
+
name: string;
|
|
581
|
+
id: string;
|
|
582
|
+
description: string | null;
|
|
583
|
+
}>, "many">;
|
|
584
|
+
}, "strip", z.ZodTypeAny, {
|
|
585
|
+
resource: {
|
|
586
|
+
name: string;
|
|
587
|
+
id: string;
|
|
588
|
+
indicator: string;
|
|
589
|
+
};
|
|
590
|
+
scopes: {
|
|
591
|
+
name: string;
|
|
592
|
+
id: string;
|
|
593
|
+
description: string | null;
|
|
594
|
+
}[];
|
|
595
|
+
}, {
|
|
596
|
+
resource: {
|
|
597
|
+
name: string;
|
|
598
|
+
id: string;
|
|
599
|
+
indicator: string;
|
|
600
|
+
};
|
|
601
|
+
scopes: {
|
|
602
|
+
name: string;
|
|
603
|
+
id: string;
|
|
604
|
+
description: string | null;
|
|
605
|
+
}[];
|
|
606
|
+
}>, "many">;
|
|
551
607
|
userScopes: z.ZodArray<z.ZodNativeEnum<typeof UserScope>, "many">;
|
|
552
608
|
}, "strip", z.ZodTypeAny, {
|
|
553
609
|
organizationScopes: {
|
|
@@ -567,6 +623,18 @@ export declare const applicationUserConsentScopesResponseGuard: z.ZodObject<{
|
|
|
567
623
|
description: string | null;
|
|
568
624
|
}[];
|
|
569
625
|
}[];
|
|
626
|
+
organizationResourceScopes: {
|
|
627
|
+
resource: {
|
|
628
|
+
name: string;
|
|
629
|
+
id: string;
|
|
630
|
+
indicator: string;
|
|
631
|
+
};
|
|
632
|
+
scopes: {
|
|
633
|
+
name: string;
|
|
634
|
+
id: string;
|
|
635
|
+
description: string | null;
|
|
636
|
+
}[];
|
|
637
|
+
}[];
|
|
570
638
|
userScopes: UserScope[];
|
|
571
639
|
}, {
|
|
572
640
|
organizationScopes: {
|
|
@@ -586,11 +654,24 @@ export declare const applicationUserConsentScopesResponseGuard: z.ZodObject<{
|
|
|
586
654
|
description: string | null;
|
|
587
655
|
}[];
|
|
588
656
|
}[];
|
|
657
|
+
organizationResourceScopes: {
|
|
658
|
+
resource: {
|
|
659
|
+
name: string;
|
|
660
|
+
id: string;
|
|
661
|
+
indicator: string;
|
|
662
|
+
};
|
|
663
|
+
scopes: {
|
|
664
|
+
name: string;
|
|
665
|
+
id: string;
|
|
666
|
+
description: string | null;
|
|
667
|
+
}[];
|
|
668
|
+
}[];
|
|
589
669
|
userScopes: UserScope[];
|
|
590
670
|
}>;
|
|
591
671
|
export declare enum ApplicationUserConsentScopeType {
|
|
592
672
|
OrganizationScopes = "organization-scopes",
|
|
593
673
|
ResourceScopes = "resource-scopes",
|
|
674
|
+
OrganizationResourceScopes = "organization-resource-scopes",
|
|
594
675
|
UserScopes = "user-scopes"
|
|
595
676
|
}
|
|
596
677
|
export type ApplicationUserConsentScopesResponse = z.infer<typeof applicationUserConsentScopesResponseGuard>;
|
package/lib/types/application.js
CHANGED
|
@@ -20,18 +20,21 @@ export const applicationPatchGuard = applicationCreateGuard.partial().omit({
|
|
|
20
20
|
type: true,
|
|
21
21
|
isThirdParty: true,
|
|
22
22
|
});
|
|
23
|
+
const resourceScopesGuard = z.array(z.object({
|
|
24
|
+
resource: Resources.guard.pick({ id: true, name: true, indicator: true }),
|
|
25
|
+
scopes: z.array(Scopes.guard.pick({ id: true, name: true, description: true })),
|
|
26
|
+
}));
|
|
23
27
|
export const applicationUserConsentScopesResponseGuard = z.object({
|
|
24
28
|
organizationScopes: z.array(OrganizationScopes.guard.pick({ id: true, name: true, description: true })),
|
|
25
|
-
resourceScopes:
|
|
26
|
-
|
|
27
|
-
scopes: z.array(Scopes.guard.pick({ id: true, name: true, description: true })),
|
|
28
|
-
})),
|
|
29
|
+
resourceScopes: resourceScopesGuard,
|
|
30
|
+
organizationResourceScopes: resourceScopesGuard,
|
|
29
31
|
userScopes: z.array(z.nativeEnum(UserScope)),
|
|
30
32
|
});
|
|
31
33
|
export var ApplicationUserConsentScopeType;
|
|
32
34
|
(function (ApplicationUserConsentScopeType) {
|
|
33
35
|
ApplicationUserConsentScopeType["OrganizationScopes"] = "organization-scopes";
|
|
34
36
|
ApplicationUserConsentScopeType["ResourceScopes"] = "resource-scopes";
|
|
37
|
+
ApplicationUserConsentScopeType["OrganizationResourceScopes"] = "organization-resource-scopes";
|
|
35
38
|
ApplicationUserConsentScopeType["UserScopes"] = "user-scopes";
|
|
36
39
|
})(ApplicationUserConsentScopeType || (ApplicationUserConsentScopeType = {}));
|
|
37
40
|
export const applicationSignInExperienceCreateGuard = ApplicationSignInExperiences.createGuard
|