@logto/schemas 1.10.0 → 1.10.1

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.
Files changed (144) hide show
  1. package/alterations/1.10.1-1695647183-update-private-key-type.ts +108 -0
  2. package/alterations/1.10.1-1696657546-organization-tables.ts +150 -0
  3. package/alterations/1.10.1-1697683802-add-sso-connectors-table.ts +66 -0
  4. package/alterations/1.10.1-1698646271-add-organization-created-flag.ts +75 -0
  5. package/alterations/1.10.1-1698820410-add-user-sso-identities-table.ts +61 -0
  6. package/alterations/1.10.1-1698910485-user-logto-data.ts +20 -0
  7. package/alterations-js/1.10.1-1695647183-update-private-key-type.d.ts +3 -0
  8. package/alterations-js/1.10.1-1695647183-update-private-key-type.js +50 -0
  9. package/alterations-js/1.10.1-1696657546-organization-tables.d.ts +3 -0
  10. package/alterations-js/1.10.1-1696657546-organization-tables.js +136 -0
  11. package/alterations-js/1.10.1-1697683802-add-sso-connectors-table.d.ts +3 -0
  12. package/alterations-js/1.10.1-1697683802-add-sso-connectors-table.js +58 -0
  13. package/alterations-js/1.10.1-1698646271-add-organization-created-flag.d.ts +3 -0
  14. package/alterations-js/1.10.1-1698646271-add-organization-created-flag.js +26 -0
  15. package/alterations-js/1.10.1-1698820410-add-user-sso-identities-table.d.ts +4 -0
  16. package/alterations-js/1.10.1-1698820410-add-user-sso-identities-table.js +53 -0
  17. package/alterations-js/1.10.1-1698910485-user-logto-data.d.ts +3 -0
  18. package/alterations-js/1.10.1-1698910485-user-logto-data.js +16 -0
  19. package/lib/db-entries/application.d.ts +7 -1
  20. package/lib/db-entries/application.js +1 -0
  21. package/lib/db-entries/applications-role.d.ts +7 -1
  22. package/lib/db-entries/applications-role.js +1 -0
  23. package/lib/db-entries/connector.d.ts +7 -1
  24. package/lib/db-entries/connector.js +1 -0
  25. package/lib/db-entries/custom-phrase.d.ts +7 -1
  26. package/lib/db-entries/custom-phrase.js +1 -0
  27. package/lib/db-entries/daily-active-user.d.ts +7 -1
  28. package/lib/db-entries/daily-active-user.js +1 -0
  29. package/lib/db-entries/domain.d.ts +7 -1
  30. package/lib/db-entries/domain.js +1 -0
  31. package/lib/db-entries/hook.d.ts +7 -1
  32. package/lib/db-entries/hook.js +1 -0
  33. package/lib/db-entries/index.d.ts +8 -0
  34. package/lib/db-entries/index.js +8 -0
  35. package/lib/db-entries/log.d.ts +7 -1
  36. package/lib/db-entries/log.js +1 -0
  37. package/lib/db-entries/logto-config.d.ts +10 -4
  38. package/lib/db-entries/logto-config.js +4 -3
  39. package/lib/db-entries/oidc-model-instance.d.ts +7 -1
  40. package/lib/db-entries/oidc-model-instance.js +1 -0
  41. package/lib/db-entries/organization-role-scope-relation.d.ts +20 -0
  42. package/lib/db-entries/organization-role-scope-relation.js +29 -0
  43. package/lib/db-entries/organization-role-user-relation.d.ts +22 -0
  44. package/lib/db-entries/organization-role-user-relation.js +33 -0
  45. package/lib/db-entries/organization-role.d.ts +28 -0
  46. package/lib/db-entries/organization-role.js +33 -0
  47. package/lib/db-entries/organization-scope.d.ts +28 -0
  48. package/lib/db-entries/organization-scope.js +33 -0
  49. package/lib/db-entries/organization-user-relation.d.ts +20 -0
  50. package/lib/db-entries/organization-user-relation.js +29 -0
  51. package/lib/db-entries/organization.d.ts +32 -0
  52. package/lib/db-entries/organization.js +37 -0
  53. package/lib/db-entries/passcode.d.ts +7 -1
  54. package/lib/db-entries/passcode.js +1 -0
  55. package/lib/db-entries/resource.d.ts +7 -1
  56. package/lib/db-entries/resource.js +1 -0
  57. package/lib/db-entries/role.d.ts +7 -1
  58. package/lib/db-entries/role.js +1 -0
  59. package/lib/db-entries/roles-scope.d.ts +7 -1
  60. package/lib/db-entries/roles-scope.js +1 -0
  61. package/lib/db-entries/scope.d.ts +7 -1
  62. package/lib/db-entries/scope.js +1 -0
  63. package/lib/db-entries/sentinel-activity.d.ts +7 -1
  64. package/lib/db-entries/sentinel-activity.js +1 -0
  65. package/lib/db-entries/service-log.d.ts +7 -1
  66. package/lib/db-entries/service-log.js +1 -0
  67. package/lib/db-entries/sign-in-experience.d.ts +7 -1
  68. package/lib/db-entries/sign-in-experience.js +1 -0
  69. package/lib/db-entries/sso-connector.d.ts +50 -0
  70. package/lib/db-entries/sso-connector.js +58 -0
  71. package/lib/db-entries/system.d.ts +7 -1
  72. package/lib/db-entries/system.js +1 -0
  73. package/lib/db-entries/user-sso-identity.d.ts +30 -0
  74. package/lib/db-entries/user-sso-identity.js +46 -0
  75. package/lib/db-entries/user.d.ts +9 -1
  76. package/lib/db-entries/user.js +5 -0
  77. package/lib/db-entries/users-role.d.ts +7 -1
  78. package/lib/db-entries/users-role.js +1 -0
  79. package/lib/db-entries/verification-status.d.ts +7 -1
  80. package/lib/db-entries/verification-status.js +1 -0
  81. package/lib/foundations/index.d.ts +1 -1
  82. package/lib/foundations/index.js +1 -1
  83. package/lib/foundations/jsonb-types/custom-domain.d.ts +134 -0
  84. package/lib/foundations/jsonb-types/custom-domain.js +36 -0
  85. package/lib/foundations/jsonb-types/hooks.d.ts +32 -0
  86. package/lib/foundations/jsonb-types/hooks.js +24 -0
  87. package/lib/foundations/jsonb-types/index.d.ts +15 -0
  88. package/lib/foundations/jsonb-types/index.js +16 -0
  89. package/lib/foundations/jsonb-types/logs.d.ts +106 -0
  90. package/lib/foundations/jsonb-types/logs.js +20 -0
  91. package/lib/foundations/jsonb-types/oidc-module.d.ts +80 -0
  92. package/lib/foundations/jsonb-types/oidc-module.js +54 -0
  93. package/lib/foundations/jsonb-types/phrases.d.ts +5 -0
  94. package/lib/foundations/jsonb-types/phrases.js +2 -0
  95. package/lib/foundations/jsonb-types/sentinel.d.ts +27 -0
  96. package/lib/foundations/jsonb-types/sentinel.js +28 -0
  97. package/lib/foundations/jsonb-types/sign-in-experience.d.ts +118 -0
  98. package/lib/foundations/jsonb-types/sign-in-experience.js +56 -0
  99. package/lib/foundations/jsonb-types/sso-connector.d.ts +14 -0
  100. package/lib/foundations/jsonb-types/sso-connector.js +6 -0
  101. package/lib/foundations/jsonb-types/users.d.ts +285 -0
  102. package/lib/foundations/jsonb-types/users.js +47 -0
  103. package/lib/foundations/schemas.d.ts +11 -13
  104. package/lib/models/tenants.d.ts +7 -11
  105. package/lib/seeds/logto-config.js +1 -0
  106. package/lib/types/application.d.ts +51 -1
  107. package/lib/types/application.js +7 -1
  108. package/lib/types/connector.d.ts +516 -2360
  109. package/lib/types/domain.d.ts +65 -27
  110. package/lib/types/hook.d.ts +15 -16
  111. package/lib/types/index.d.ts +3 -0
  112. package/lib/types/index.js +3 -0
  113. package/lib/types/interactions.d.ts +502 -10
  114. package/lib/types/interactions.js +83 -5
  115. package/lib/types/log/interaction.d.ts +4 -3
  116. package/lib/types/log/interaction.js +1 -0
  117. package/lib/types/logto-config.d.ts +50 -2
  118. package/lib/types/logto-config.js +30 -3
  119. package/lib/types/mfa.d.ts +211 -0
  120. package/lib/types/mfa.js +62 -0
  121. package/lib/types/organization.d.ts +44 -0
  122. package/lib/types/organization.js +20 -0
  123. package/lib/types/role.d.ts +5 -3
  124. package/lib/types/scope.d.ts +12 -27
  125. package/lib/types/sso-connector.d.ts +21 -0
  126. package/lib/types/sso-connector.js +10 -0
  127. package/lib/types/system.d.ts +26 -7
  128. package/lib/types/system.js +8 -0
  129. package/lib/types/user-assets.d.ts +2 -2
  130. package/lib/types/user.d.ts +209 -66
  131. package/lib/types/user.js +8 -2
  132. package/package.json +6 -6
  133. package/tables/logto_configs.sql +1 -1
  134. package/tables/organization_role_scope_relations.sql +12 -0
  135. package/tables/organization_role_user_relations.sql +14 -0
  136. package/tables/organization_roles.sql +19 -0
  137. package/tables/organization_scopes.sql +19 -0
  138. package/tables/organization_user_relations.sql +12 -0
  139. package/tables/organizations.sql +19 -0
  140. package/tables/sso_connectors.sql +29 -0
  141. package/tables/user_sso_identities.sql +17 -0
  142. package/tables/users.sql +1 -0
  143. package/lib/foundations/jsonb-types.d.ts +0 -673
  144. package/lib/foundations/jsonb-types.js +0 -260
@@ -15,6 +15,7 @@ export var StorageProvider;
15
15
  (function (StorageProvider) {
16
16
  StorageProvider["AzureStorage"] = "AzureStorage";
17
17
  StorageProvider["S3Storage"] = "S3Storage";
18
+ StorageProvider["GoogleStorage"] = "GoogleStorage";
18
19
  })(StorageProvider || (StorageProvider = {}));
19
20
  const basicConfig = {
20
21
  publicUrl: z.string().optional(),
@@ -35,6 +36,13 @@ export const storageProviderDataGuard = z.discriminatedUnion('provider', [
35
36
  accessSecretKey: z.string(),
36
37
  ...basicConfig,
37
38
  }),
39
+ z.object({
40
+ provider: z.literal(StorageProvider.GoogleStorage),
41
+ projectId: z.string(),
42
+ keyFilename: z.string(),
43
+ bucketName: z.string(),
44
+ ...basicConfig,
45
+ }),
38
46
  ]);
39
47
  export var StorageProviderKey;
40
48
  (function (StorageProviderKey) {
@@ -8,13 +8,13 @@ export declare const userAssetsServiceStatusGuard: z.ZodObject<{
8
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">>;
9
9
  maxUploadFileSize: z.ZodOptional<z.ZodNumber>;
10
10
  }, "strip", z.ZodTypeAny, {
11
+ status: "ready" | "not_configured";
11
12
  allowUploadMimeTypes?: ("image/jpeg" | "image/png" | "image/gif" | "image/vnd.microsoft.icon" | "image/svg+xml" | "image/tiff" | "image/webp" | "image/bmp")[] | undefined;
12
13
  maxUploadFileSize?: number | undefined;
13
- status: "ready" | "not_configured";
14
14
  }, {
15
+ status: "ready" | "not_configured";
15
16
  allowUploadMimeTypes?: ("image/jpeg" | "image/png" | "image/gif" | "image/vnd.microsoft.icon" | "image/svg+xml" | "image/tiff" | "image/webp" | "image/bmp")[] | undefined;
16
17
  maxUploadFileSize?: number | undefined;
17
- status: "ready" | "not_configured";
18
18
  }>;
19
19
  export type UserAssetsServiceStatus = z.infer<typeof userAssetsServiceStatusGuard>;
20
20
  export declare const userAssetsGuard: z.ZodObject<{
@@ -1,5 +1,6 @@
1
1
  import { z } from 'zod';
2
- import { MfaFactor } from '../foundations/jsonb-types.js';
2
+ import { type User } from '../db-entries/index.js';
3
+ import { MfaFactor } from '../foundations/index.js';
3
4
  export declare const userInfoSelectFields: readonly ["id", "username", "primaryEmail", "primaryPhone", "name", "avatar", "customData", "identities", "lastSignInAt", "createdAt", "applicationId", "isSuspended"];
4
5
  export declare const userInfoGuard: z.ZodObject<Pick<{
5
6
  tenantId: z.ZodType<string, z.ZodTypeDef, string>;
@@ -13,18 +14,20 @@ export declare const userInfoGuard: z.ZodObject<Pick<{
13
14
  avatar: z.ZodType<string | null, z.ZodTypeDef, string | null>;
14
15
  applicationId: z.ZodType<string | null, z.ZodTypeDef, string | null>;
15
16
  identities: z.ZodType<Record<string, {
16
- details?: {} | undefined;
17
17
  userId: string;
18
- }>, z.ZodTypeDef, Record<string, {
19
18
  details?: {} | undefined;
19
+ }>, z.ZodTypeDef, Record<string, {
20
20
  userId: string;
21
+ details?: {} | undefined;
21
22
  }>>;
22
- customData: z.ZodType<import("../foundations/jsonb-types.js").JsonObject, z.ZodTypeDef, import("../foundations/jsonb-types.js").JsonObject>;
23
+ customData: z.ZodType<import("../foundations/index.js").JsonObject, z.ZodTypeDef, import("../foundations/index.js").JsonObject>;
24
+ logtoConfig: z.ZodType<import("../foundations/index.js").JsonObject, z.ZodTypeDef, import("../foundations/index.js").JsonObject>;
23
25
  mfaVerifications: z.ZodType<({
24
26
  type: MfaFactor.TOTP;
25
- key: string;
26
27
  id: string;
28
+ key: string;
27
29
  createdAt: string;
30
+ lastUsedAt?: string | undefined;
28
31
  } | {
29
32
  type: MfaFactor.WebAuthn;
30
33
  id: string;
@@ -33,17 +36,23 @@ export declare const userInfoGuard: z.ZodObject<Pick<{
33
36
  publicKey: string;
34
37
  counter: number;
35
38
  agent: string;
39
+ transports?: ("usb" | "nfc" | "ble" | "internal" | "cable" | "hybrid" | "smart-card")[] | undefined;
40
+ lastUsedAt?: string | undefined;
36
41
  } | {
37
- usedAt?: string | undefined;
38
- code: string;
39
42
  type: MfaFactor.BackupCode;
40
43
  id: string;
41
44
  createdAt: string;
45
+ codes: {
46
+ code: string;
47
+ usedAt?: string | undefined;
48
+ }[];
49
+ lastUsedAt?: string | undefined;
42
50
  })[], z.ZodTypeDef, ({
43
51
  type: MfaFactor.TOTP;
44
- key: string;
45
52
  id: string;
53
+ key: string;
46
54
  createdAt: string;
55
+ lastUsedAt?: string | undefined;
47
56
  } | {
48
57
  type: MfaFactor.WebAuthn;
49
58
  id: string;
@@ -52,38 +61,45 @@ export declare const userInfoGuard: z.ZodObject<Pick<{
52
61
  publicKey: string;
53
62
  counter: number;
54
63
  agent: string;
64
+ transports?: ("usb" | "nfc" | "ble" | "internal" | "cable" | "hybrid" | "smart-card")[] | undefined;
65
+ lastUsedAt?: string | undefined;
55
66
  } | {
56
- usedAt?: string | undefined;
57
- code: string;
58
67
  type: MfaFactor.BackupCode;
59
68
  id: string;
60
69
  createdAt: string;
70
+ codes: {
71
+ code: string;
72
+ usedAt?: string | undefined;
73
+ }[];
74
+ lastUsedAt?: string | undefined;
61
75
  })[]>;
62
76
  isSuspended: z.ZodType<boolean, z.ZodTypeDef, boolean>;
63
77
  lastSignInAt: z.ZodType<number | null, z.ZodTypeDef, number | null>;
64
78
  createdAt: z.ZodType<number, z.ZodTypeDef, number>;
65
- }, "tenantId" | "username" | "id" | "createdAt" | "applicationId" | "name" | "primaryEmail" | "primaryPhone" | "passwordEncrypted" | "passwordEncryptionMethod" | "avatar" | "identities" | "customData" | "mfaVerifications" | "isSuspended" | "lastSignInAt">, "strip", z.ZodTypeAny, {
79
+ }, "name" | "id" | "applicationId" | "tenantId" | "username" | "createdAt" | "primaryEmail" | "primaryPhone" | "passwordEncrypted" | "passwordEncryptionMethod" | "avatar" | "identities" | "customData" | "logtoConfig" | "mfaVerifications" | "isSuspended" | "lastSignInAt">, "strip", z.ZodTypeAny, {
80
+ name: string | null;
81
+ id: string;
82
+ applicationId: string | null;
66
83
  tenantId: string;
67
84
  username: string | null;
68
- id: string;
69
85
  createdAt: number;
70
- applicationId: string | null;
71
- name: string | null;
72
86
  primaryEmail: string | null;
73
87
  primaryPhone: string | null;
74
88
  passwordEncrypted: string | null;
75
89
  passwordEncryptionMethod: import("../db-entries/custom-types.js").UsersPasswordEncryptionMethod | null;
76
90
  avatar: string | null;
77
91
  identities: Record<string, {
78
- details?: {} | undefined;
79
92
  userId: string;
93
+ details?: {} | undefined;
80
94
  }>;
81
- customData: import("../foundations/jsonb-types.js").JsonObject;
95
+ customData: import("../foundations/index.js").JsonObject;
96
+ logtoConfig: import("../foundations/index.js").JsonObject;
82
97
  mfaVerifications: ({
83
98
  type: MfaFactor.TOTP;
84
- key: string;
85
99
  id: string;
100
+ key: string;
86
101
  createdAt: string;
102
+ lastUsedAt?: string | undefined;
87
103
  } | {
88
104
  type: MfaFactor.WebAuthn;
89
105
  id: string;
@@ -92,37 +108,44 @@ export declare const userInfoGuard: z.ZodObject<Pick<{
92
108
  publicKey: string;
93
109
  counter: number;
94
110
  agent: string;
111
+ transports?: ("usb" | "nfc" | "ble" | "internal" | "cable" | "hybrid" | "smart-card")[] | undefined;
112
+ lastUsedAt?: string | undefined;
95
113
  } | {
96
- usedAt?: string | undefined;
97
- code: string;
98
114
  type: MfaFactor.BackupCode;
99
115
  id: string;
100
116
  createdAt: string;
117
+ codes: {
118
+ code: string;
119
+ usedAt?: string | undefined;
120
+ }[];
121
+ lastUsedAt?: string | undefined;
101
122
  })[];
102
123
  isSuspended: boolean;
103
124
  lastSignInAt: number | null;
104
125
  }, {
126
+ name: string | null;
127
+ id: string;
128
+ applicationId: string | null;
105
129
  tenantId: string;
106
130
  username: string | null;
107
- id: string;
108
131
  createdAt: number;
109
- applicationId: string | null;
110
- name: string | null;
111
132
  primaryEmail: string | null;
112
133
  primaryPhone: string | null;
113
134
  passwordEncrypted: string | null;
114
135
  passwordEncryptionMethod: import("../db-entries/custom-types.js").UsersPasswordEncryptionMethod | null;
115
136
  avatar: string | null;
116
137
  identities: Record<string, {
117
- details?: {} | undefined;
118
138
  userId: string;
139
+ details?: {} | undefined;
119
140
  }>;
120
- customData: import("../foundations/jsonb-types.js").JsonObject;
141
+ customData: import("../foundations/index.js").JsonObject;
142
+ logtoConfig: import("../foundations/index.js").JsonObject;
121
143
  mfaVerifications: ({
122
144
  type: MfaFactor.TOTP;
123
- key: string;
124
145
  id: string;
146
+ key: string;
125
147
  createdAt: string;
148
+ lastUsedAt?: string | undefined;
126
149
  } | {
127
150
  type: MfaFactor.WebAuthn;
128
151
  id: string;
@@ -131,41 +154,49 @@ export declare const userInfoGuard: z.ZodObject<Pick<{
131
154
  publicKey: string;
132
155
  counter: number;
133
156
  agent: string;
157
+ transports?: ("usb" | "nfc" | "ble" | "internal" | "cable" | "hybrid" | "smart-card")[] | undefined;
158
+ lastUsedAt?: string | undefined;
134
159
  } | {
135
- usedAt?: string | undefined;
136
- code: string;
137
160
  type: MfaFactor.BackupCode;
138
161
  id: string;
139
162
  createdAt: string;
163
+ codes: {
164
+ code: string;
165
+ usedAt?: string | undefined;
166
+ }[];
167
+ lastUsedAt?: string | undefined;
140
168
  })[];
141
169
  isSuspended: boolean;
142
170
  lastSignInAt: number | null;
143
171
  }>;
144
172
  export type UserInfo = z.infer<typeof userInfoGuard>;
145
- export declare const userProfileResponseGuard: z.ZodObject<z.extendShape<Pick<{
146
- tenantId: z.ZodType<string, z.ZodTypeDef, string>;
173
+ export declare const userProfileResponseGuard: z.ZodObject<{
174
+ name: z.ZodType<string | null, z.ZodTypeDef, string | null>;
147
175
  id: z.ZodType<string, z.ZodTypeDef, string>;
176
+ applicationId: z.ZodType<string | null, z.ZodTypeDef, string | null>;
177
+ tenantId: z.ZodType<string, z.ZodTypeDef, string>;
148
178
  username: z.ZodType<string | null, z.ZodTypeDef, string | null>;
179
+ createdAt: z.ZodType<number, z.ZodTypeDef, number>;
149
180
  primaryEmail: z.ZodType<string | null, z.ZodTypeDef, string | null>;
150
181
  primaryPhone: z.ZodType<string | null, z.ZodTypeDef, string | null>;
151
182
  passwordEncrypted: z.ZodType<string | null, z.ZodTypeDef, string | null>;
152
183
  passwordEncryptionMethod: z.ZodType<import("../db-entries/custom-types.js").UsersPasswordEncryptionMethod | null, z.ZodTypeDef, import("../db-entries/custom-types.js").UsersPasswordEncryptionMethod | null>;
153
- name: z.ZodType<string | null, z.ZodTypeDef, string | null>;
154
184
  avatar: z.ZodType<string | null, z.ZodTypeDef, string | null>;
155
- applicationId: z.ZodType<string | null, z.ZodTypeDef, string | null>;
156
185
  identities: z.ZodType<Record<string, {
157
- details?: {} | undefined;
158
186
  userId: string;
159
- }>, z.ZodTypeDef, Record<string, {
160
187
  details?: {} | undefined;
188
+ }>, z.ZodTypeDef, Record<string, {
161
189
  userId: string;
190
+ details?: {} | undefined;
162
191
  }>>;
163
- customData: z.ZodType<import("../foundations/jsonb-types.js").JsonObject, z.ZodTypeDef, import("../foundations/jsonb-types.js").JsonObject>;
192
+ customData: z.ZodType<import("../foundations/index.js").JsonObject, z.ZodTypeDef, import("../foundations/index.js").JsonObject>;
193
+ logtoConfig: z.ZodType<import("../foundations/index.js").JsonObject, z.ZodTypeDef, import("../foundations/index.js").JsonObject>;
164
194
  mfaVerifications: z.ZodType<({
165
195
  type: MfaFactor.TOTP;
166
- key: string;
167
196
  id: string;
197
+ key: string;
168
198
  createdAt: string;
199
+ lastUsedAt?: string | undefined;
169
200
  } | {
170
201
  type: MfaFactor.WebAuthn;
171
202
  id: string;
@@ -174,17 +205,23 @@ export declare const userProfileResponseGuard: z.ZodObject<z.extendShape<Pick<{
174
205
  publicKey: string;
175
206
  counter: number;
176
207
  agent: string;
208
+ transports?: ("usb" | "nfc" | "ble" | "internal" | "cable" | "hybrid" | "smart-card")[] | undefined;
209
+ lastUsedAt?: string | undefined;
177
210
  } | {
178
- usedAt?: string | undefined;
179
- code: string;
180
211
  type: MfaFactor.BackupCode;
181
212
  id: string;
182
213
  createdAt: string;
214
+ codes: {
215
+ code: string;
216
+ usedAt?: string | undefined;
217
+ }[];
218
+ lastUsedAt?: string | undefined;
183
219
  })[], z.ZodTypeDef, ({
184
220
  type: MfaFactor.TOTP;
185
- key: string;
186
221
  id: string;
222
+ key: string;
187
223
  createdAt: string;
224
+ lastUsedAt?: string | undefined;
188
225
  } | {
189
226
  type: MfaFactor.WebAuthn;
190
227
  id: string;
@@ -193,41 +230,45 @@ export declare const userProfileResponseGuard: z.ZodObject<z.extendShape<Pick<{
193
230
  publicKey: string;
194
231
  counter: number;
195
232
  agent: string;
233
+ transports?: ("usb" | "nfc" | "ble" | "internal" | "cable" | "hybrid" | "smart-card")[] | undefined;
234
+ lastUsedAt?: string | undefined;
196
235
  } | {
197
- usedAt?: string | undefined;
198
- code: string;
199
236
  type: MfaFactor.BackupCode;
200
237
  id: string;
201
238
  createdAt: string;
239
+ codes: {
240
+ code: string;
241
+ usedAt?: string | undefined;
242
+ }[];
243
+ lastUsedAt?: string | undefined;
202
244
  })[]>;
203
245
  isSuspended: z.ZodType<boolean, z.ZodTypeDef, boolean>;
204
246
  lastSignInAt: z.ZodType<number | null, z.ZodTypeDef, number | null>;
205
- createdAt: z.ZodType<number, z.ZodTypeDef, number>;
206
- }, "tenantId" | "username" | "id" | "createdAt" | "applicationId" | "name" | "primaryEmail" | "primaryPhone" | "passwordEncrypted" | "passwordEncryptionMethod" | "avatar" | "identities" | "customData" | "mfaVerifications" | "isSuspended" | "lastSignInAt">, {
207
247
  hasPassword: z.ZodOptional<z.ZodBoolean>;
208
- }>, "strip", z.ZodTypeAny, {
209
- hasPassword?: boolean | undefined;
248
+ }, "strip", z.ZodTypeAny, {
249
+ name: string | null;
250
+ id: string;
251
+ applicationId: string | null;
210
252
  tenantId: string;
211
253
  username: string | null;
212
- id: string;
213
254
  createdAt: number;
214
- applicationId: string | null;
215
- name: string | null;
216
255
  primaryEmail: string | null;
217
256
  primaryPhone: string | null;
218
257
  passwordEncrypted: string | null;
219
258
  passwordEncryptionMethod: import("../db-entries/custom-types.js").UsersPasswordEncryptionMethod | null;
220
259
  avatar: string | null;
221
260
  identities: Record<string, {
222
- details?: {} | undefined;
223
261
  userId: string;
262
+ details?: {} | undefined;
224
263
  }>;
225
- customData: import("../foundations/jsonb-types.js").JsonObject;
264
+ customData: import("../foundations/index.js").JsonObject;
265
+ logtoConfig: import("../foundations/index.js").JsonObject;
226
266
  mfaVerifications: ({
227
267
  type: MfaFactor.TOTP;
228
- key: string;
229
268
  id: string;
269
+ key: string;
230
270
  createdAt: string;
271
+ lastUsedAt?: string | undefined;
231
272
  } | {
232
273
  type: MfaFactor.WebAuthn;
233
274
  id: string;
@@ -236,38 +277,45 @@ export declare const userProfileResponseGuard: z.ZodObject<z.extendShape<Pick<{
236
277
  publicKey: string;
237
278
  counter: number;
238
279
  agent: string;
280
+ transports?: ("usb" | "nfc" | "ble" | "internal" | "cable" | "hybrid" | "smart-card")[] | undefined;
281
+ lastUsedAt?: string | undefined;
239
282
  } | {
240
- usedAt?: string | undefined;
241
- code: string;
242
283
  type: MfaFactor.BackupCode;
243
284
  id: string;
244
285
  createdAt: string;
286
+ codes: {
287
+ code: string;
288
+ usedAt?: string | undefined;
289
+ }[];
290
+ lastUsedAt?: string | undefined;
245
291
  })[];
246
292
  isSuspended: boolean;
247
293
  lastSignInAt: number | null;
248
- }, {
249
294
  hasPassword?: boolean | undefined;
295
+ }, {
296
+ name: string | null;
297
+ id: string;
298
+ applicationId: string | null;
250
299
  tenantId: string;
251
300
  username: string | null;
252
- id: string;
253
301
  createdAt: number;
254
- applicationId: string | null;
255
- name: string | null;
256
302
  primaryEmail: string | null;
257
303
  primaryPhone: string | null;
258
304
  passwordEncrypted: string | null;
259
305
  passwordEncryptionMethod: import("../db-entries/custom-types.js").UsersPasswordEncryptionMethod | null;
260
306
  avatar: string | null;
261
307
  identities: Record<string, {
262
- details?: {} | undefined;
263
308
  userId: string;
309
+ details?: {} | undefined;
264
310
  }>;
265
- customData: import("../foundations/jsonb-types.js").JsonObject;
311
+ customData: import("../foundations/index.js").JsonObject;
312
+ logtoConfig: import("../foundations/index.js").JsonObject;
266
313
  mfaVerifications: ({
267
314
  type: MfaFactor.TOTP;
268
- key: string;
269
315
  id: string;
316
+ key: string;
270
317
  createdAt: string;
318
+ lastUsedAt?: string | undefined;
271
319
  } | {
272
320
  type: MfaFactor.WebAuthn;
273
321
  id: string;
@@ -276,15 +324,21 @@ export declare const userProfileResponseGuard: z.ZodObject<z.extendShape<Pick<{
276
324
  publicKey: string;
277
325
  counter: number;
278
326
  agent: string;
327
+ transports?: ("usb" | "nfc" | "ble" | "internal" | "cable" | "hybrid" | "smart-card")[] | undefined;
328
+ lastUsedAt?: string | undefined;
279
329
  } | {
280
- usedAt?: string | undefined;
281
- code: string;
282
330
  type: MfaFactor.BackupCode;
283
331
  id: string;
284
332
  createdAt: string;
333
+ codes: {
334
+ code: string;
335
+ usedAt?: string | undefined;
336
+ }[];
337
+ lastUsedAt?: string | undefined;
285
338
  })[];
286
339
  isSuspended: boolean;
287
340
  lastSignInAt: number | null;
341
+ hasPassword?: boolean | undefined;
288
342
  }>;
289
343
  export type UserProfileResponse = z.infer<typeof userProfileResponseGuard>;
290
344
  export declare const userMfaVerificationResponseGuard: z.ZodArray<z.ZodObject<{
@@ -292,19 +346,19 @@ export declare const userMfaVerificationResponseGuard: z.ZodArray<z.ZodObject<{
292
346
  createdAt: z.ZodString;
293
347
  type: z.ZodNativeEnum<typeof MfaFactor>;
294
348
  agent: z.ZodOptional<z.ZodString>;
295
- used: z.ZodOptional<z.ZodBoolean>;
349
+ remainCodes: z.ZodOptional<z.ZodNumber>;
296
350
  }, "strip", z.ZodTypeAny, {
297
- agent?: string | undefined;
298
- used?: boolean | undefined;
299
351
  type: MfaFactor;
300
352
  id: string;
301
353
  createdAt: string;
302
- }, {
303
354
  agent?: string | undefined;
304
- used?: boolean | undefined;
355
+ remainCodes?: number | undefined;
356
+ }, {
305
357
  type: MfaFactor;
306
358
  id: string;
307
359
  createdAt: string;
360
+ agent?: string | undefined;
361
+ remainCodes?: number | undefined;
308
362
  }>, "many">;
309
363
  export type UserMfaVerificationResponse = z.infer<typeof userMfaVerificationResponseGuard>;
310
364
  /** Internal read-only roles for user tenants. */
@@ -326,3 +380,92 @@ export declare enum AdminTenantRole {
326
380
  export declare enum PredefinedScope {
327
381
  All = "all"
328
382
  }
383
+ /**
384
+ * A user that is featured for display. Usually used in a list of resources that are related to
385
+ * a group of users.
386
+ */
387
+ export type FeaturedUser = Pick<User, 'id' | 'avatar' | 'name'>;
388
+ /** The guard for {@link FeaturedUser}. */
389
+ export declare const featuredUserGuard: z.ZodObject<Pick<{
390
+ tenantId: z.ZodType<string, z.ZodTypeDef, string>;
391
+ id: z.ZodType<string, z.ZodTypeDef, string>;
392
+ username: z.ZodType<string | null, z.ZodTypeDef, string | null>;
393
+ primaryEmail: z.ZodType<string | null, z.ZodTypeDef, string | null>;
394
+ primaryPhone: z.ZodType<string | null, z.ZodTypeDef, string | null>;
395
+ passwordEncrypted: z.ZodType<string | null, z.ZodTypeDef, string | null>;
396
+ passwordEncryptionMethod: z.ZodType<import("../db-entries/custom-types.js").UsersPasswordEncryptionMethod | null, z.ZodTypeDef, import("../db-entries/custom-types.js").UsersPasswordEncryptionMethod | null>;
397
+ name: z.ZodType<string | null, z.ZodTypeDef, string | null>;
398
+ avatar: z.ZodType<string | null, z.ZodTypeDef, string | null>;
399
+ applicationId: z.ZodType<string | null, z.ZodTypeDef, string | null>;
400
+ identities: z.ZodType<Record<string, {
401
+ userId: string;
402
+ details?: {} | undefined;
403
+ }>, z.ZodTypeDef, Record<string, {
404
+ userId: string;
405
+ details?: {} | undefined;
406
+ }>>;
407
+ customData: z.ZodType<import("../foundations/index.js").JsonObject, z.ZodTypeDef, import("../foundations/index.js").JsonObject>;
408
+ logtoConfig: z.ZodType<import("../foundations/index.js").JsonObject, z.ZodTypeDef, import("../foundations/index.js").JsonObject>;
409
+ mfaVerifications: z.ZodType<({
410
+ type: MfaFactor.TOTP;
411
+ id: string;
412
+ key: string;
413
+ createdAt: string;
414
+ lastUsedAt?: string | undefined;
415
+ } | {
416
+ type: MfaFactor.WebAuthn;
417
+ id: string;
418
+ createdAt: string;
419
+ credentialId: string;
420
+ publicKey: string;
421
+ counter: number;
422
+ agent: string;
423
+ transports?: ("usb" | "nfc" | "ble" | "internal" | "cable" | "hybrid" | "smart-card")[] | undefined;
424
+ lastUsedAt?: string | undefined;
425
+ } | {
426
+ type: MfaFactor.BackupCode;
427
+ id: string;
428
+ createdAt: string;
429
+ codes: {
430
+ code: string;
431
+ usedAt?: string | undefined;
432
+ }[];
433
+ lastUsedAt?: string | undefined;
434
+ })[], z.ZodTypeDef, ({
435
+ type: MfaFactor.TOTP;
436
+ id: string;
437
+ key: string;
438
+ createdAt: string;
439
+ lastUsedAt?: string | undefined;
440
+ } | {
441
+ type: MfaFactor.WebAuthn;
442
+ id: string;
443
+ createdAt: string;
444
+ credentialId: string;
445
+ publicKey: string;
446
+ counter: number;
447
+ agent: string;
448
+ transports?: ("usb" | "nfc" | "ble" | "internal" | "cable" | "hybrid" | "smart-card")[] | undefined;
449
+ lastUsedAt?: string | undefined;
450
+ } | {
451
+ type: MfaFactor.BackupCode;
452
+ id: string;
453
+ createdAt: string;
454
+ codes: {
455
+ code: string;
456
+ usedAt?: string | undefined;
457
+ }[];
458
+ lastUsedAt?: string | undefined;
459
+ })[]>;
460
+ isSuspended: z.ZodType<boolean, z.ZodTypeDef, boolean>;
461
+ lastSignInAt: z.ZodType<number | null, z.ZodTypeDef, number | null>;
462
+ createdAt: z.ZodType<number, z.ZodTypeDef, number>;
463
+ }, "name" | "id" | "avatar">, "strip", z.ZodTypeAny, {
464
+ name: string | null;
465
+ id: string;
466
+ avatar: string | null;
467
+ }, {
468
+ name: string | null;
469
+ id: string;
470
+ avatar: string | null;
471
+ }>;
package/lib/types/user.js CHANGED
@@ -1,6 +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
+ import { MfaFactor } from '../foundations/index.js';
4
4
  export const userInfoSelectFields = Object.freeze([
5
5
  'id',
6
6
  'username',
@@ -25,7 +25,7 @@ export const userMfaVerificationResponseGuard = z
25
25
  createdAt: z.string(),
26
26
  type: z.nativeEnum(MfaFactor),
27
27
  agent: z.string().optional(),
28
- used: z.boolean().optional(),
28
+ remainCodes: z.number().optional(),
29
29
  })
30
30
  .array();
31
31
  /** Internal read-only roles for user tenants. */
@@ -50,3 +50,9 @@ export var PredefinedScope;
50
50
  (function (PredefinedScope) {
51
51
  PredefinedScope["All"] = "all";
52
52
  })(PredefinedScope || (PredefinedScope = {}));
53
+ /** The guard for {@link FeaturedUser}. */
54
+ export const featuredUserGuard = Users.guard.pick({
55
+ id: true,
56
+ avatar: true,
57
+ name: true,
58
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logto/schemas",
3
- "version": "1.10.0",
3
+ "version": "1.10.1",
4
4
  "author": "Silverhand Inc. <contact@silverhand.io>",
5
5
  "license": "MPL-2.0",
6
6
  "type": "module",
@@ -30,12 +30,12 @@
30
30
  "@types/inquirer": "^9.0.0",
31
31
  "@types/jest": "^29.4.0",
32
32
  "@types/node": "^18.11.18",
33
- "@types/pluralize": "^0.0.29",
33
+ "@types/pluralize": "^0.0.32",
34
34
  "camelcase": "^8.0.0",
35
35
  "chalk": "^5.0.0",
36
36
  "eslint": "^8.44.0",
37
37
  "jest": "^29.5.0",
38
- "lint-staged": "^14.0.0",
38
+ "lint-staged": "^15.0.0",
39
39
  "pluralize": "^8.0.0",
40
40
  "prettier": "^3.0.0",
41
41
  "roarr": "^7.11.0",
@@ -64,16 +64,16 @@
64
64
  },
65
65
  "prettier": "@silverhand/eslint-config/.prettierrc",
66
66
  "dependencies": {
67
- "@logto/connector-kit": "^1.1.1",
67
+ "@logto/connector-kit": "^2.0.0",
68
68
  "@logto/core-kit": "^2.2.0",
69
69
  "@logto/language-kit": "^1.0.0",
70
- "@logto/phrases": "^1.5.0",
70
+ "@logto/phrases": "^1.6.0",
71
71
  "@logto/phrases-experience": "^1.3.1",
72
72
  "@logto/shared": "^3.0.0",
73
73
  "@withtyped/server": "^0.12.9"
74
74
  },
75
75
  "peerDependencies": {
76
- "zod": "^3.20.2"
76
+ "zod": "^3.22.3"
77
77
  },
78
78
  "scripts": {
79
79
  "precommit": "lint-staged",
@@ -2,6 +2,6 @@ create table logto_configs (
2
2
  tenant_id varchar(21) not null
3
3
  references tenants (id) on update cascade on delete cascade,
4
4
  key varchar(256) not null,
5
- value jsonb /* @use JsonObject */ not null default '{}'::jsonb,
5
+ value jsonb /* @use Json */ not null default '{}'::jsonb,
6
6
  primary key (tenant_id, key)
7
7
  );
@@ -0,0 +1,12 @@
1
+ /* init_order = 2 */
2
+
3
+ /** The relations between organization roles and organization scopes. It indicates which organization scopes are available to which organization roles. */
4
+ create table organization_role_scope_relations (
5
+ tenant_id varchar(21) not null
6
+ references tenants (id) on update cascade on delete cascade,
7
+ organization_role_id varchar(21) not null
8
+ references organization_roles (id) on update cascade on delete cascade,
9
+ organization_scope_id varchar(21) not null
10
+ references organization_scopes (id) on update cascade on delete cascade,
11
+ primary key (tenant_id, organization_role_id, organization_scope_id)
12
+ );
@@ -0,0 +1,14 @@
1
+ /* init_order = 2 */
2
+
3
+ /** The relations between organizations, organization roles, and users. A relation means that a user has a role in an organization. */
4
+ create table organization_role_user_relations (
5
+ tenant_id varchar(21) not null
6
+ references tenants (id) on update cascade on delete cascade,
7
+ organization_id varchar(21) not null
8
+ references organizations (id) on update cascade on delete cascade,
9
+ organization_role_id varchar(21) not null
10
+ references organization_roles (id) on update cascade on delete cascade,
11
+ user_id varchar(21) not null
12
+ references users (id) on update cascade on delete cascade,
13
+ primary key (tenant_id, organization_id, organization_role_id, user_id)
14
+ );
@@ -0,0 +1,19 @@
1
+ /* init_order = 1 */
2
+
3
+ /** The roles defined by the organization template. */
4
+ create table organization_roles (
5
+ tenant_id varchar(21) not null
6
+ references tenants (id) on update cascade on delete cascade,
7
+ /** The globally unique identifier of the organization role. */
8
+ id varchar(21) not null,
9
+ /** The organization role's name, unique within the organization template. */
10
+ name varchar(128) not null,
11
+ /** A brief description of the organization role. */
12
+ description varchar(256),
13
+ primary key (id),
14
+ constraint organization_roles__name
15
+ unique (tenant_id, name)
16
+ );
17
+
18
+ create index organization_roles__id
19
+ on organization_roles (tenant_id, id);