@logto/schemas 1.12.0 → 1.13.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.13.0-1702274830-add-new-third-party-column-to-applications-table.ts +20 -0
- package/alterations/1.13.0-1702372401-add-application-permissions-tables.ts +93 -0
- package/alterations/1.13.0-1702544178-sync-tenant-orgs.ts +296 -0
- package/alterations/1.13.0-1702871078-protected-application-type.ts +24 -0
- package/alterations/1.13.0-1702877515-protected-app-configs.ts +18 -0
- package/alterations/1.13.0-1702978120-application-sign-in-experience-table.ts +61 -0
- package/alterations/1.13.0-1703229996-daily-token-usage.ts +62 -0
- package/alterations/1.13.0-1703230000-update-tenant-roles.ts +94 -0
- package/alterations/1.13.0-1704692973-remove-legacy-resources.ts +147 -0
- package/alterations/1.13.0-1704934999-add-magic-links-table.ts +37 -0
- package/alterations/1.13.0-1704935001-add-organization-invitation-tables.ts +78 -0
- package/alterations/1.13.0-1705288654-add-application-user-consent-organizations-table.ts +62 -0
- package/alterations/1.13.0-1705991158-update-invitation-indices.ts +32 -0
- package/alterations/1.13.0-1706449174-update-organization-invitation-column.ts +24 -0
- package/alterations/1.13.0-1706510290-protected-app-host-index.ts +21 -0
- package/alterations/1.13.0-1706512952-restore-get-started-page.ts +17 -0
- package/alterations/1.13.0-1706528755-remove-magic-links.ts +46 -0
- package/alterations/1.13.0-1706585206-protected-app-custom-domain-unique.ts +21 -0
- package/alterations/utils/1704934999-tables.ts +49 -0
- package/alterations/utils/README.md +9 -0
- package/alterations-js/1.13.0-1702274830-add-new-third-party-column-to-applications-table.d.ts +3 -0
- package/alterations-js/1.13.0-1702274830-add-new-third-party-column-to-applications-table.js +16 -0
- package/alterations-js/1.13.0-1702372401-add-application-permissions-tables.d.ts +3 -0
- package/alterations-js/1.13.0-1702372401-add-application-permissions-tables.js +79 -0
- package/alterations-js/1.13.0-1702544178-sync-tenant-orgs.d.ts +18 -0
- package/alterations-js/1.13.0-1702544178-sync-tenant-orgs.js +225 -0
- package/alterations-js/1.13.0-1702871078-protected-application-type.d.ts +3 -0
- package/alterations-js/1.13.0-1702871078-protected-application-type.js +20 -0
- package/alterations-js/1.13.0-1702877515-protected-app-configs.d.ts +3 -0
- package/alterations-js/1.13.0-1702877515-protected-app-configs.js +14 -0
- package/alterations-js/1.13.0-1702978120-application-sign-in-experience-table.d.ts +3 -0
- package/alterations-js/1.13.0-1702978120-application-sign-in-experience-table.js +51 -0
- package/alterations-js/1.13.0-1703229996-daily-token-usage.d.ts +3 -0
- package/alterations-js/1.13.0-1703229996-daily-token-usage.js +51 -0
- package/alterations-js/1.13.0-1703230000-update-tenant-roles.d.ts +11 -0
- package/alterations-js/1.13.0-1703230000-update-tenant-roles.js +87 -0
- package/alterations-js/1.13.0-1704692973-remove-legacy-resources.d.ts +3 -0
- package/alterations-js/1.13.0-1704692973-remove-legacy-resources.js +124 -0
- package/alterations-js/1.13.0-1704934999-add-magic-links-table.d.ts +3 -0
- package/alterations-js/1.13.0-1704934999-add-magic-links-table.js +32 -0
- package/alterations-js/1.13.0-1704935001-add-organization-invitation-tables.d.ts +3 -0
- package/alterations-js/1.13.0-1704935001-add-organization-invitation-tables.js +72 -0
- package/alterations-js/1.13.0-1705288654-add-application-user-consent-organizations-table.d.ts +3 -0
- package/alterations-js/1.13.0-1705288654-add-application-user-consent-organizations-table.js +52 -0
- package/alterations-js/1.13.0-1705991158-update-invitation-indices.d.ts +7 -0
- package/alterations-js/1.13.0-1705991158-update-invitation-indices.js +27 -0
- package/alterations-js/1.13.0-1706449174-update-organization-invitation-column.d.ts +3 -0
- package/alterations-js/1.13.0-1706449174-update-organization-invitation-column.js +20 -0
- package/alterations-js/1.13.0-1706510290-protected-app-host-index.d.ts +3 -0
- package/alterations-js/1.13.0-1706510290-protected-app-host-index.js +17 -0
- package/alterations-js/1.13.0-1706512952-restore-get-started-page.d.ts +3 -0
- package/alterations-js/1.13.0-1706512952-restore-get-started-page.js +13 -0
- package/alterations-js/1.13.0-1706528755-remove-magic-links.d.ts +3 -0
- package/alterations-js/1.13.0-1706528755-remove-magic-links.js +41 -0
- package/alterations-js/1.13.0-1706585206-protected-app-custom-domain-unique.d.ts +3 -0
- package/alterations-js/1.13.0-1706585206-protected-app-custom-domain-unique.js +17 -0
- package/alterations-js/utils/1704934999-tables.d.ts +11 -0
- package/alterations-js/utils/1704934999-tables.js +43 -0
- package/lib/db-entries/application-sign-in-experience.d.ts +26 -0
- package/lib/db-entries/application-sign-in-experience.js +42 -0
- package/lib/db-entries/application-user-consent-organization-scope.d.ts +24 -0
- package/lib/db-entries/application-user-consent-organization-scope.js +29 -0
- package/lib/db-entries/application-user-consent-organization.d.ts +22 -0
- package/lib/db-entries/application-user-consent-organization.js +33 -0
- package/lib/db-entries/application-user-consent-resource-scope.d.ts +24 -0
- package/lib/db-entries/application-user-consent-resource-scope.js +29 -0
- package/lib/db-entries/application-user-consent-user-scope.d.ts +24 -0
- package/lib/db-entries/application-user-consent-user-scope.js +29 -0
- package/lib/db-entries/application.d.ts +6 -2
- package/lib/db-entries/application.js +9 -1
- package/lib/db-entries/custom-types.d.ts +8 -1
- package/lib/db-entries/custom-types.js +8 -0
- package/lib/db-entries/daily-token-usage.d.ts +20 -0
- package/lib/db-entries/daily-token-usage.js +33 -0
- package/lib/db-entries/index.d.ts +8 -0
- package/lib/db-entries/index.js +8 -0
- package/lib/db-entries/organization-invitation-role-relation.d.ts +24 -0
- package/lib/db-entries/organization-invitation-role-relation.js +29 -0
- package/lib/db-entries/organization-invitation.d.ts +53 -0
- package/lib/db-entries/organization-invitation.js +58 -0
- package/lib/foundations/jsonb-types/applications.d.ts +380 -0
- package/lib/foundations/jsonb-types/applications.js +29 -0
- package/lib/foundations/jsonb-types/custom-domain.d.ts +37 -89
- package/lib/foundations/jsonb-types/custom-domain.js +4 -9
- package/lib/foundations/jsonb-types/index.d.ts +1 -0
- package/lib/foundations/jsonb-types/index.js +1 -0
- package/lib/models/tenants.d.ts +1 -1
- package/lib/seeds/application.d.ts +1 -1
- package/lib/seeds/application.js +3 -1
- package/lib/seeds/cloud-api.d.ts +0 -2
- package/lib/seeds/cloud-api.js +0 -3
- package/lib/seeds/management-api.d.ts +77 -6
- package/lib/seeds/management-api.js +14 -10
- package/lib/types/application.d.ts +576 -1
- package/lib/types/application.js +42 -1
- package/lib/types/connector.js +1 -1
- package/lib/types/consent.d.ts +568 -0
- package/lib/types/consent.js +47 -0
- package/lib/types/domain.d.ts +21 -65
- package/lib/types/index.d.ts +3 -0
- package/lib/types/index.js +3 -0
- package/lib/types/interactions.d.ts +6 -6
- package/lib/types/logto-config.d.ts +32 -6
- package/lib/types/logto-config.js +12 -2
- package/lib/types/mapi-proxy.d.ts +30 -0
- package/lib/types/mapi-proxy.js +49 -0
- package/lib/types/organization.d.ts +10 -1
- package/lib/types/organization.js +4 -1
- package/lib/types/sso-connector.d.ts +9 -9
- package/lib/types/sso-connector.js +1 -1
- package/lib/types/system.d.ts +28 -1
- package/lib/types/system.js +17 -0
- package/lib/types/tenant-organization.d.ts +107 -0
- package/lib/types/tenant-organization.js +145 -0
- package/lib/types/tenant.d.ts +0 -1
- package/lib/types/tenant.js +2 -4
- package/lib/types/user-assets.d.ts +5 -5
- package/lib/types/user-assets.js +1 -0
- package/lib/types/user.d.ts +14 -15
- package/lib/types/user.js +0 -1
- package/package.json +14 -14
- package/tables/application_sign_in_experiences.sql +15 -0
- package/tables/application_user_consent_organization_scopes.sql +14 -0
- package/tables/application_user_consent_organizations.sql +16 -0
- package/tables/application_user_consent_resource_scopes.sql +14 -0
- package/tables/application_user_consent_user_scopes.sql +13 -0
- package/tables/applications.sql +16 -1
- package/tables/daily_token_usage.sql +11 -0
- package/tables/organization_invitation_role_relations.sql +14 -0
- package/tables/organization_invitations.sql +36 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview
|
|
3
|
+
* Tenant organizations are organizations in the admin tenant that represent tenants. They are
|
|
4
|
+
* created when a tenant is created, and are used to define the roles and scopes for the users in
|
|
5
|
+
* the tenant.
|
|
6
|
+
*
|
|
7
|
+
* This module provides utilities to manage tenant organizations.
|
|
8
|
+
*/
|
|
9
|
+
import { adminTenantId } from '../seeds/tenant.js';
|
|
10
|
+
/** Given a tenant ID, return the corresponding organization ID in the admin tenant. */
|
|
11
|
+
export const getTenantOrganizationId = (tenantId) => `t-${tenantId}`;
|
|
12
|
+
/**
|
|
13
|
+
* Given a tenant ID, return the organization create data for the admin tenant. It follows a
|
|
14
|
+
* convention to generate the organization ID and name which can be used across the system.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* const tenantId = 'test-tenant';
|
|
19
|
+
* const createData = getCreateData(tenantId);
|
|
20
|
+
*
|
|
21
|
+
* expect(createData).toEqual({
|
|
22
|
+
* tenantId: 'admin',
|
|
23
|
+
* id: 't-test-tenant',
|
|
24
|
+
* name: 'Tenant test-tenant',
|
|
25
|
+
* });
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @see {@link getId} for the convention of generating the organization ID.
|
|
29
|
+
*/
|
|
30
|
+
export const getTenantOrganizationCreateData = (tenantId) => Object.freeze({
|
|
31
|
+
tenantId: adminTenantId,
|
|
32
|
+
id: getTenantOrganizationId(tenantId),
|
|
33
|
+
name: `Tenant ${tenantId}`,
|
|
34
|
+
});
|
|
35
|
+
/**
|
|
36
|
+
* Scope names in organization template for managing tenants.
|
|
37
|
+
*
|
|
38
|
+
* @remarks
|
|
39
|
+
* Should sync JSDoc descriptions with {@link tenantScopeDescriptions}.
|
|
40
|
+
*/
|
|
41
|
+
export var TenantScope;
|
|
42
|
+
(function (TenantScope) {
|
|
43
|
+
/** Read the tenant data. */
|
|
44
|
+
TenantScope["ReadData"] = "read:data";
|
|
45
|
+
/** Write the tenant data, including creating and updating the tenant. */
|
|
46
|
+
TenantScope["WriteData"] = "write:data";
|
|
47
|
+
/** Delete data of the tenant. */
|
|
48
|
+
TenantScope["DeleteData"] = "delete:data";
|
|
49
|
+
/** Invite members to the tenant. */
|
|
50
|
+
TenantScope["InviteMember"] = "invite:member";
|
|
51
|
+
/** Remove members from the tenant. */
|
|
52
|
+
TenantScope["RemoveMember"] = "remove:member";
|
|
53
|
+
/** Update the role of a member in the tenant. */
|
|
54
|
+
TenantScope["UpdateMemberRole"] = "update:member:role";
|
|
55
|
+
/** Manage the tenant settings, including name, billing, etc. */
|
|
56
|
+
TenantScope["ManageTenant"] = "manage:tenant";
|
|
57
|
+
})(TenantScope || (TenantScope = {}));
|
|
58
|
+
const allTenantScopes = Object.freeze(Object.values(TenantScope));
|
|
59
|
+
/**
|
|
60
|
+
* Given a tenant scope, return the corresponding organization scope data in the admin tenant.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* const scope = TenantScope.ReadData; // 'read:data'
|
|
65
|
+
* const scopeData = getTenantScope(scope);
|
|
66
|
+
*
|
|
67
|
+
* expect(scopeData).toEqual({
|
|
68
|
+
* tenantId: 'admin',
|
|
69
|
+
* id: 'read-data',
|
|
70
|
+
* name: 'read:data',
|
|
71
|
+
* description: 'Read the tenant data.',
|
|
72
|
+
* });
|
|
73
|
+
* ```
|
|
74
|
+
*
|
|
75
|
+
* @see {@link tenantScopeDescriptions} for scope descriptions of each scope.
|
|
76
|
+
*/
|
|
77
|
+
export const getTenantScope = (scope) => Object.freeze({
|
|
78
|
+
tenantId: adminTenantId,
|
|
79
|
+
id: scope.replaceAll(':', '-'),
|
|
80
|
+
name: scope,
|
|
81
|
+
description: tenantScopeDescriptions[scope],
|
|
82
|
+
});
|
|
83
|
+
const tenantScopeDescriptions = Object.freeze({
|
|
84
|
+
[TenantScope.ReadData]: 'Read the tenant data.',
|
|
85
|
+
[TenantScope.WriteData]: 'Write the tenant data, including creating and updating the tenant.',
|
|
86
|
+
[TenantScope.DeleteData]: 'Delete data of the tenant.',
|
|
87
|
+
[TenantScope.InviteMember]: 'Invite members to the tenant.',
|
|
88
|
+
[TenantScope.RemoveMember]: 'Remove members from the tenant.',
|
|
89
|
+
[TenantScope.UpdateMemberRole]: 'Update the role of a member in the tenant.',
|
|
90
|
+
[TenantScope.ManageTenant]: 'Manage the tenant settings, including name, billing, etc.',
|
|
91
|
+
});
|
|
92
|
+
/**
|
|
93
|
+
* Role names in organization template for managing tenants.
|
|
94
|
+
*
|
|
95
|
+
* @remarks
|
|
96
|
+
* Should sync JSDoc descriptions with {@link tenantRoleDescriptions}.
|
|
97
|
+
*/
|
|
98
|
+
export var TenantRole;
|
|
99
|
+
(function (TenantRole) {
|
|
100
|
+
/** Admin of the tenant, who has all permissions. */
|
|
101
|
+
TenantRole["Admin"] = "admin";
|
|
102
|
+
/** Member of the tenant, who has permissions to operate the tenant data, but not the tenant settings. */
|
|
103
|
+
TenantRole["Member"] = "member";
|
|
104
|
+
})(TenantRole || (TenantRole = {}));
|
|
105
|
+
const tenantRoleDescriptions = Object.freeze({
|
|
106
|
+
[TenantRole.Admin]: 'Admin of the tenant, who has all permissions.',
|
|
107
|
+
[TenantRole.Member]: 'Member of the tenant, who has permissions to operate the tenant data, but not the tenant settings.',
|
|
108
|
+
});
|
|
109
|
+
/**
|
|
110
|
+
* Given a tenant role, return the corresponding organization role data in the admin tenant.
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```ts
|
|
114
|
+
* const role = TenantRole.Member; // 'member'
|
|
115
|
+
* const roleData = getTenantRole(role);
|
|
116
|
+
*
|
|
117
|
+
* expect(roleData).toEqual({
|
|
118
|
+
* tenantId: 'admin',
|
|
119
|
+
* id: 'member',
|
|
120
|
+
* name: 'member',
|
|
121
|
+
* description: 'Member of the tenant, who has permissions to operate the tenant data, but not the tenant settings.',
|
|
122
|
+
* });
|
|
123
|
+
* ```
|
|
124
|
+
*
|
|
125
|
+
* @see {@link tenantRoleDescriptions} for scope descriptions of each role.
|
|
126
|
+
*/
|
|
127
|
+
export const getTenantRole = (role) => Object.freeze({
|
|
128
|
+
tenantId: adminTenantId,
|
|
129
|
+
id: role,
|
|
130
|
+
name: role,
|
|
131
|
+
description: tenantRoleDescriptions[role],
|
|
132
|
+
});
|
|
133
|
+
/**
|
|
134
|
+
* The dictionary of tenant roles and their corresponding scopes.
|
|
135
|
+
* @see {TenantRole} for scope descriptions of each role.
|
|
136
|
+
*/
|
|
137
|
+
export const tenantRoleScopes = Object.freeze({
|
|
138
|
+
[TenantRole.Admin]: allTenantScopes,
|
|
139
|
+
[TenantRole.Member]: [
|
|
140
|
+
TenantScope.ReadData,
|
|
141
|
+
TenantScope.WriteData,
|
|
142
|
+
TenantScope.DeleteData,
|
|
143
|
+
TenantScope.InviteMember,
|
|
144
|
+
],
|
|
145
|
+
});
|
package/lib/types/tenant.d.ts
CHANGED
package/lib/types/tenant.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
export var TenantTag;
|
|
2
2
|
(function (TenantTag) {
|
|
3
|
-
/* Development tenants are free to use but are not meant to be used as production environment */
|
|
3
|
+
/* Development tenants are free to use but are not meant to be used as production environment. */
|
|
4
4
|
TenantTag["Development"] = "development";
|
|
5
|
-
/*
|
|
6
|
-
TenantTag["Staging"] = "staging";
|
|
7
|
-
/* A production tenant must have an associated subscription plan, even if it's a free plan */
|
|
5
|
+
/* A production tenant must have an associated subscription plan, even if it's a free plan. */
|
|
8
6
|
TenantTag["Production"] = "production";
|
|
9
7
|
})(TenantTag || (TenantTag = {}));
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
export declare const maxUploadFileSize: number;
|
|
3
|
-
export declare const allowUploadMimeTypes: readonly ["image/jpeg", "image/png", "image/gif", "image/vnd.microsoft.icon", "image/svg+xml", "image/tiff", "image/webp", "image/bmp"];
|
|
4
|
-
declare const allowUploadMimeTypeGuard: z.ZodEnum<["image/jpeg", "image/png", "image/gif", "image/vnd.microsoft.icon", "image/svg+xml", "image/tiff", "image/webp", "image/bmp"]>;
|
|
3
|
+
export declare const allowUploadMimeTypes: readonly ["image/jpeg", "image/png", "image/gif", "image/vnd.microsoft.icon", "image/x-icon", "image/svg+xml", "image/tiff", "image/webp", "image/bmp"];
|
|
4
|
+
declare const allowUploadMimeTypeGuard: z.ZodEnum<["image/jpeg", "image/png", "image/gif", "image/vnd.microsoft.icon", "image/x-icon", "image/svg+xml", "image/tiff", "image/webp", "image/bmp"]>;
|
|
5
5
|
export type AllowedUploadMimeType = z.infer<typeof allowUploadMimeTypeGuard>;
|
|
6
6
|
export declare const userAssetsServiceStatusGuard: z.ZodObject<{
|
|
7
7
|
status: z.ZodUnion<[z.ZodLiteral<"ready">, z.ZodLiteral<"not_configured">]>;
|
|
8
|
-
allowUploadMimeTypes: z.ZodOptional<z.ZodArray<z.ZodEnum<["image/jpeg", "image/png", "image/gif", "image/vnd.microsoft.icon", "image/svg+xml", "image/tiff", "image/webp", "image/bmp"]>, "many">>;
|
|
8
|
+
allowUploadMimeTypes: z.ZodOptional<z.ZodArray<z.ZodEnum<["image/jpeg", "image/png", "image/gif", "image/vnd.microsoft.icon", "image/x-icon", "image/svg+xml", "image/tiff", "image/webp", "image/bmp"]>, "many">>;
|
|
9
9
|
maxUploadFileSize: z.ZodOptional<z.ZodNumber>;
|
|
10
10
|
}, "strip", z.ZodTypeAny, {
|
|
11
11
|
status: "ready" | "not_configured";
|
|
12
|
-
allowUploadMimeTypes?: ("image/jpeg" | "image/png" | "image/gif" | "image/vnd.microsoft.icon" | "image/svg+xml" | "image/tiff" | "image/webp" | "image/bmp")[] | undefined;
|
|
12
|
+
allowUploadMimeTypes?: ("image/jpeg" | "image/png" | "image/gif" | "image/vnd.microsoft.icon" | "image/x-icon" | "image/svg+xml" | "image/tiff" | "image/webp" | "image/bmp")[] | undefined;
|
|
13
13
|
maxUploadFileSize?: number | undefined;
|
|
14
14
|
}, {
|
|
15
15
|
status: "ready" | "not_configured";
|
|
16
|
-
allowUploadMimeTypes?: ("image/jpeg" | "image/png" | "image/gif" | "image/vnd.microsoft.icon" | "image/svg+xml" | "image/tiff" | "image/webp" | "image/bmp")[] | undefined;
|
|
16
|
+
allowUploadMimeTypes?: ("image/jpeg" | "image/png" | "image/gif" | "image/vnd.microsoft.icon" | "image/x-icon" | "image/svg+xml" | "image/tiff" | "image/webp" | "image/bmp")[] | undefined;
|
|
17
17
|
maxUploadFileSize?: number | undefined;
|
|
18
18
|
}>;
|
|
19
19
|
export type UserAssetsServiceStatus = z.infer<typeof userAssetsServiceStatusGuard>;
|
package/lib/types/user-assets.js
CHANGED
package/lib/types/user.d.ts
CHANGED
|
@@ -20,8 +20,8 @@ export declare const userInfoGuard: z.ZodObject<Pick<{
|
|
|
20
20
|
userId: string;
|
|
21
21
|
details?: Record<string, unknown> | undefined;
|
|
22
22
|
}>>;
|
|
23
|
-
customData: z.ZodType<import("
|
|
24
|
-
logtoConfig: z.ZodType<import("
|
|
23
|
+
customData: z.ZodType<import("@withtyped/server/lib/types.js").JsonObject, z.ZodTypeDef, import("@withtyped/server/lib/types.js").JsonObject>;
|
|
24
|
+
logtoConfig: z.ZodType<import("@withtyped/server/lib/types.js").JsonObject, z.ZodTypeDef, import("@withtyped/server/lib/types.js").JsonObject>;
|
|
25
25
|
mfaVerifications: z.ZodType<({
|
|
26
26
|
type: MfaFactor.TOTP;
|
|
27
27
|
id: string;
|
|
@@ -92,8 +92,8 @@ export declare const userInfoGuard: z.ZodObject<Pick<{
|
|
|
92
92
|
userId: string;
|
|
93
93
|
details?: Record<string, unknown> | undefined;
|
|
94
94
|
}>;
|
|
95
|
-
customData: import("
|
|
96
|
-
logtoConfig: import("
|
|
95
|
+
customData: import("@withtyped/server/lib/types.js").JsonObject;
|
|
96
|
+
logtoConfig: import("@withtyped/server/lib/types.js").JsonObject;
|
|
97
97
|
mfaVerifications: ({
|
|
98
98
|
type: MfaFactor.TOTP;
|
|
99
99
|
id: string;
|
|
@@ -138,8 +138,8 @@ export declare const userInfoGuard: z.ZodObject<Pick<{
|
|
|
138
138
|
userId: string;
|
|
139
139
|
details?: Record<string, unknown> | undefined;
|
|
140
140
|
}>;
|
|
141
|
-
customData: import("
|
|
142
|
-
logtoConfig: import("
|
|
141
|
+
customData: import("@withtyped/server/lib/types.js").JsonObject;
|
|
142
|
+
logtoConfig: import("@withtyped/server/lib/types.js").JsonObject;
|
|
143
143
|
mfaVerifications: ({
|
|
144
144
|
type: MfaFactor.TOTP;
|
|
145
145
|
id: string;
|
|
@@ -189,8 +189,8 @@ export declare const userProfileResponseGuard: z.ZodObject<{
|
|
|
189
189
|
userId: string;
|
|
190
190
|
details?: Record<string, unknown> | undefined;
|
|
191
191
|
}>>;
|
|
192
|
-
customData: z.ZodType<import("
|
|
193
|
-
logtoConfig: z.ZodType<import("
|
|
192
|
+
customData: z.ZodType<import("@withtyped/server/lib/types.js").JsonObject, z.ZodTypeDef, import("@withtyped/server/lib/types.js").JsonObject>;
|
|
193
|
+
logtoConfig: z.ZodType<import("@withtyped/server/lib/types.js").JsonObject, z.ZodTypeDef, import("@withtyped/server/lib/types.js").JsonObject>;
|
|
194
194
|
mfaVerifications: z.ZodType<({
|
|
195
195
|
type: MfaFactor.TOTP;
|
|
196
196
|
id: string;
|
|
@@ -262,8 +262,8 @@ export declare const userProfileResponseGuard: z.ZodObject<{
|
|
|
262
262
|
userId: string;
|
|
263
263
|
details?: Record<string, unknown> | undefined;
|
|
264
264
|
}>;
|
|
265
|
-
customData: import("
|
|
266
|
-
logtoConfig: import("
|
|
265
|
+
customData: import("@withtyped/server/lib/types.js").JsonObject;
|
|
266
|
+
logtoConfig: import("@withtyped/server/lib/types.js").JsonObject;
|
|
267
267
|
mfaVerifications: ({
|
|
268
268
|
type: MfaFactor.TOTP;
|
|
269
269
|
id: string;
|
|
@@ -310,8 +310,8 @@ export declare const userProfileResponseGuard: z.ZodObject<{
|
|
|
310
310
|
userId: string;
|
|
311
311
|
details?: Record<string, unknown> | undefined;
|
|
312
312
|
}>;
|
|
313
|
-
customData: import("
|
|
314
|
-
logtoConfig: import("
|
|
313
|
+
customData: import("@withtyped/server/lib/types.js").JsonObject;
|
|
314
|
+
logtoConfig: import("@withtyped/server/lib/types.js").JsonObject;
|
|
315
315
|
mfaVerifications: ({
|
|
316
316
|
type: MfaFactor.TOTP;
|
|
317
317
|
id: string;
|
|
@@ -374,7 +374,6 @@ export declare enum InternalRole {
|
|
|
374
374
|
Admin = "#internal:admin"
|
|
375
375
|
}
|
|
376
376
|
export declare enum AdminTenantRole {
|
|
377
|
-
Admin = "admin",
|
|
378
377
|
/** Common user role in admin tenant. */
|
|
379
378
|
User = "user",
|
|
380
379
|
/** The role for machine to machine applications that represent a user tenant and send requests to Logto Cloud. */
|
|
@@ -407,8 +406,8 @@ export declare const featuredUserGuard: z.ZodObject<Pick<{
|
|
|
407
406
|
userId: string;
|
|
408
407
|
details?: Record<string, unknown> | undefined;
|
|
409
408
|
}>>;
|
|
410
|
-
customData: z.ZodType<import("
|
|
411
|
-
logtoConfig: z.ZodType<import("
|
|
409
|
+
customData: z.ZodType<import("@withtyped/server/lib/types.js").JsonObject, z.ZodTypeDef, import("@withtyped/server/lib/types.js").JsonObject>;
|
|
410
|
+
logtoConfig: z.ZodType<import("@withtyped/server/lib/types.js").JsonObject, z.ZodTypeDef, import("@withtyped/server/lib/types.js").JsonObject>;
|
|
412
411
|
mfaVerifications: z.ZodType<({
|
|
413
412
|
type: MfaFactor.TOTP;
|
|
414
413
|
id: string;
|
package/lib/types/user.js
CHANGED
|
@@ -41,7 +41,6 @@ export var InternalRole;
|
|
|
41
41
|
})(InternalRole || (InternalRole = {}));
|
|
42
42
|
export var AdminTenantRole;
|
|
43
43
|
(function (AdminTenantRole) {
|
|
44
|
-
AdminTenantRole["Admin"] = "admin";
|
|
45
44
|
/** Common user role in admin tenant. */
|
|
46
45
|
AdminTenantRole["User"] = "user";
|
|
47
46
|
/** The role for machine to machine applications that represent a user tenant and send requests to Logto Cloud. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logto/schemas",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.0",
|
|
4
4
|
"author": "Silverhand Inc. <contact@silverhand.io>",
|
|
5
5
|
"license": "MPL-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -21,27 +21,27 @@
|
|
|
21
21
|
"access": "public"
|
|
22
22
|
},
|
|
23
23
|
"engines": {
|
|
24
|
-
"node": "^
|
|
24
|
+
"node": "^20.9.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@silverhand/eslint-config": "
|
|
28
|
-
"@silverhand/essentials": "^2.
|
|
29
|
-
"@silverhand/ts-config": "
|
|
27
|
+
"@silverhand/eslint-config": "5.0.0",
|
|
28
|
+
"@silverhand/essentials": "^2.9.0",
|
|
29
|
+
"@silverhand/ts-config": "5.0.0",
|
|
30
30
|
"@types/inquirer": "^9.0.0",
|
|
31
31
|
"@types/jest": "^29.4.0",
|
|
32
|
-
"@types/node": "^
|
|
32
|
+
"@types/node": "^20.9.5",
|
|
33
33
|
"@types/pluralize": "^0.0.33",
|
|
34
34
|
"camelcase": "^8.0.0",
|
|
35
35
|
"chalk": "^5.0.0",
|
|
36
36
|
"eslint": "^8.44.0",
|
|
37
|
-
"jest": "^29.
|
|
37
|
+
"jest": "^29.7.0",
|
|
38
38
|
"lint-staged": "^15.0.0",
|
|
39
39
|
"pluralize": "^8.0.0",
|
|
40
40
|
"prettier": "^3.0.0",
|
|
41
41
|
"roarr": "^7.11.0",
|
|
42
42
|
"slonik": "^30.0.0",
|
|
43
43
|
"slonik-sql-tag-raw": "^1.1.4",
|
|
44
|
-
"typescript": "^5.
|
|
44
|
+
"typescript": "^5.3.3"
|
|
45
45
|
},
|
|
46
46
|
"eslintConfig": {
|
|
47
47
|
"extends": "@silverhand",
|
|
@@ -64,12 +64,12 @@
|
|
|
64
64
|
},
|
|
65
65
|
"prettier": "@silverhand/eslint-config/.prettierrc",
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@logto/connector-kit": "^2.
|
|
68
|
-
"@logto/core-kit": "^2.
|
|
69
|
-
"@logto/language-kit": "^1.
|
|
70
|
-
"@logto/phrases": "^1.
|
|
71
|
-
"@logto/phrases-experience": "^1.
|
|
72
|
-
"@logto/shared": "^3.
|
|
67
|
+
"@logto/connector-kit": "^2.1.0",
|
|
68
|
+
"@logto/core-kit": "^2.3.0",
|
|
69
|
+
"@logto/language-kit": "^1.1.0",
|
|
70
|
+
"@logto/phrases": "^1.9.0",
|
|
71
|
+
"@logto/phrases-experience": "^1.6.0",
|
|
72
|
+
"@logto/shared": "^3.1.0",
|
|
73
73
|
"@withtyped/server": "^0.12.9"
|
|
74
74
|
},
|
|
75
75
|
"peerDependencies": {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/* init_order = 2 */
|
|
2
|
+
|
|
3
|
+
/** Application level sign-in experience configuration. */
|
|
4
|
+
create table application_sign_in_experiences (
|
|
5
|
+
tenant_id varchar(21) not null
|
|
6
|
+
references tenants (id) on update cascade on delete cascade,
|
|
7
|
+
application_id varchar(21) not null
|
|
8
|
+
references applications (id) on update cascade on delete cascade,
|
|
9
|
+
branding jsonb /* @use Branding */ not null default '{}'::jsonb,
|
|
10
|
+
terms_of_use_url varchar(2048),
|
|
11
|
+
privacy_policy_url varchar(2048),
|
|
12
|
+
display_name varchar(256),
|
|
13
|
+
|
|
14
|
+
primary key (tenant_id, application_id)
|
|
15
|
+
);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/* init_order = 2 */
|
|
2
|
+
|
|
3
|
+
/** The organization scopes (permissions) assigned to an application. */
|
|
4
|
+
create table application_user_consent_organization_scopes (
|
|
5
|
+
tenant_id varchar(21) not null
|
|
6
|
+
references tenants (id) on update cascade on delete cascade,
|
|
7
|
+
/** The globally unique identifier of the application. */
|
|
8
|
+
application_id varchar(21) not null
|
|
9
|
+
references applications (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
|
+
references organization_scopes (id) on update cascade on delete cascade,
|
|
13
|
+
primary key (application_id, organization_scope_id)
|
|
14
|
+
);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/* init_order = 3 */
|
|
2
|
+
|
|
3
|
+
/** The relations between applications, users and organizations. A relation means that a user has consented to an application to access data in an organization. */
|
|
4
|
+
create table application_user_consent_organizations (
|
|
5
|
+
tenant_id varchar(21) not null
|
|
6
|
+
references tenants (id) on update cascade on delete cascade,
|
|
7
|
+
application_id varchar(21) not null
|
|
8
|
+
references applications (id) on update cascade on delete cascade,
|
|
9
|
+
organization_id varchar(21) not null,
|
|
10
|
+
user_id varchar(21) not null,
|
|
11
|
+
primary key (tenant_id, application_id, organization_id, user_id),
|
|
12
|
+
/** User's consent to an application should be synchronized with the user's membership in the organization. */
|
|
13
|
+
foreign key (tenant_id, organization_id, user_id)
|
|
14
|
+
references organization_user_relations (tenant_id, organization_id, user_id)
|
|
15
|
+
on update cascade on delete cascade
|
|
16
|
+
)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/* init_order = 3 */
|
|
2
|
+
|
|
3
|
+
/** The resource scopes (permissions) assigned to an application's consent request. */
|
|
4
|
+
create table application_user_consent_resource_scopes (
|
|
5
|
+
tenant_id varchar(21) not null
|
|
6
|
+
references tenants (id) on update cascade on delete cascade,
|
|
7
|
+
/** The globally unique identifier of the application. */
|
|
8
|
+
application_id varchar(21) not null
|
|
9
|
+
references applications (id) on update cascade on delete cascade,
|
|
10
|
+
/** The globally unique identifier of the resource scope. */
|
|
11
|
+
scope_id varchar(21) not null
|
|
12
|
+
references scopes (id) on update cascade on delete cascade,
|
|
13
|
+
primary key (application_id, scope_id)
|
|
14
|
+
);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/* init_order = 2 */
|
|
2
|
+
|
|
3
|
+
/** The user scopes (permissions) assigned to an application */
|
|
4
|
+
create table application_user_consent_user_scopes (
|
|
5
|
+
tenant_id varchar(21) not null
|
|
6
|
+
references tenants (id) on update cascade on delete cascade,
|
|
7
|
+
/** The globally unique identifier of the application. */
|
|
8
|
+
application_id varchar(21) not null
|
|
9
|
+
references applications (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 (application_id, user_scope)
|
|
13
|
+
);
|
package/tables/applications.sql
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* init_order = 1 */
|
|
2
2
|
|
|
3
|
-
create type application_type as enum ('Native', 'SPA', 'Traditional', 'MachineToMachine');
|
|
3
|
+
create type application_type as enum ('Native', 'SPA', 'Traditional', 'MachineToMachine', 'Protected');
|
|
4
4
|
|
|
5
5
|
create table applications (
|
|
6
6
|
tenant_id varchar(21) not null
|
|
@@ -12,9 +12,24 @@ create table applications (
|
|
|
12
12
|
type application_type not null,
|
|
13
13
|
oidc_client_metadata jsonb /* @use OidcClientMetadata */ not null,
|
|
14
14
|
custom_client_metadata jsonb /* @use CustomClientMetadata */ not null default '{}'::jsonb,
|
|
15
|
+
protected_app_metadata jsonb /* @use ProtectedAppMetadata */,
|
|
16
|
+
is_third_party boolean not null default false,
|
|
15
17
|
created_at timestamptz not null default(now()),
|
|
16
18
|
primary key (id)
|
|
17
19
|
);
|
|
18
20
|
|
|
19
21
|
create index applications__id
|
|
20
22
|
on applications (tenant_id, id);
|
|
23
|
+
|
|
24
|
+
create index applications__is_third_party
|
|
25
|
+
on applications (tenant_id, is_third_party);
|
|
26
|
+
|
|
27
|
+
create unique index applications__protected_app_metadata_host
|
|
28
|
+
on applications (
|
|
29
|
+
(protected_app_metadata->>'host')
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
create unique index applications__protected_app_metadata_custom_domain
|
|
33
|
+
on applications (
|
|
34
|
+
(protected_app_metadata->'customDomains'->0->>'domain')
|
|
35
|
+
);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
create table daily_token_usage (
|
|
2
|
+
id varchar(21) not null,
|
|
3
|
+
tenant_id varchar(21) not null
|
|
4
|
+
references tenants (id) on update cascade on delete cascade,
|
|
5
|
+
usage bigint not null default(0),
|
|
6
|
+
date timestamptz not null,
|
|
7
|
+
primary key (id)
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
create unique index daily_token_usage__date
|
|
11
|
+
on daily_token_usage (tenant_id, date);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/* init_order = 4 */
|
|
2
|
+
|
|
3
|
+
/** The organization roles that will be assigned to a user when they accept an invitation. */
|
|
4
|
+
create table organization_invitation_role_relations (
|
|
5
|
+
tenant_id varchar(21) not null
|
|
6
|
+
references tenants (id) on update cascade on delete cascade,
|
|
7
|
+
/** The ID of the invitation. */
|
|
8
|
+
organization_invitation_id varchar(21) not null
|
|
9
|
+
references organization_invitations (id) on update cascade on delete cascade,
|
|
10
|
+
/** The ID of the organization role. */
|
|
11
|
+
organization_role_id varchar(21) not null
|
|
12
|
+
references organization_roles (id) on update cascade on delete cascade,
|
|
13
|
+
primary key (tenant_id, organization_invitation_id, organization_role_id)
|
|
14
|
+
);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/* init_order = 3 */
|
|
2
|
+
|
|
3
|
+
create type organization_invitation_status as enum ('Pending', 'Accepted', 'Expired', 'Revoked');
|
|
4
|
+
|
|
5
|
+
/** The invitation entry defined in RFC 0003. It stores the invitation information for a user to join an organization. */
|
|
6
|
+
create table organization_invitations (
|
|
7
|
+
tenant_id varchar(21) not null
|
|
8
|
+
references tenants (id) on update cascade on delete cascade,
|
|
9
|
+
/** The unique identifier of the invitation. */
|
|
10
|
+
id varchar(21) not null,
|
|
11
|
+
/** The user ID who sent the invitation. */
|
|
12
|
+
inviter_id varchar(21)
|
|
13
|
+
references users (id) on update cascade on delete cascade,
|
|
14
|
+
/** The email address or other identifier of the invitee. */
|
|
15
|
+
invitee varchar(256) not null,
|
|
16
|
+
/** The user ID of who accepted the invitation. */
|
|
17
|
+
accepted_user_id varchar(21)
|
|
18
|
+
references users (id) on update cascade on delete cascade,
|
|
19
|
+
/** The ID of the organization to which the invitee is invited. */
|
|
20
|
+
organization_id varchar(21) not null
|
|
21
|
+
references organizations (id) on update cascade on delete cascade,
|
|
22
|
+
/** The status of the invitation. */
|
|
23
|
+
status organization_invitation_status not null,
|
|
24
|
+
/** The time when the invitation was created. */
|
|
25
|
+
created_at timestamptz not null default (now()),
|
|
26
|
+
/** The time when the invitation status was last updated. */
|
|
27
|
+
updated_at timestamptz not null default (now()),
|
|
28
|
+
/** The time when the invitation expires. */
|
|
29
|
+
expires_at timestamptz not null,
|
|
30
|
+
primary key (id)
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
-- Ensure there is only one pending invitation for a given invitee and organization.
|
|
34
|
+
create unique index organization_invitations__invitee_organization_id
|
|
35
|
+
on organization_invitations (tenant_id, invitee, organization_id)
|
|
36
|
+
where status = 'Pending';
|