@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
@@ -1,5 +1,10 @@
1
1
  import { Identities, JsonObject, MfaVerifications, GeneratedSchema } from './../foundations/index.js';
2
2
  import { UsersPasswordEncryptionMethod } from './custom-types.js';
3
+ /**
4
+ *
5
+ * @remarks This is a type for database creation.
6
+ * @see {@link User} for the original type.
7
+ */
3
8
  export type CreateUser = {
4
9
  tenantId?: string;
5
10
  id: string;
@@ -13,6 +18,7 @@ export type CreateUser = {
13
18
  applicationId?: string | null;
14
19
  identities?: Identities;
15
20
  customData?: JsonObject;
21
+ logtoConfig?: JsonObject;
16
22
  mfaVerifications?: MfaVerifications;
17
23
  isSuspended?: boolean;
18
24
  lastSignInAt?: number | null;
@@ -31,9 +37,11 @@ export type User = {
31
37
  applicationId: string | null;
32
38
  identities: Identities;
33
39
  customData: JsonObject;
40
+ logtoConfig: JsonObject;
34
41
  mfaVerifications: MfaVerifications;
35
42
  isSuspended: boolean;
36
43
  lastSignInAt: number | null;
37
44
  createdAt: number;
38
45
  };
39
- export declare const Users: GeneratedSchema<CreateUser, User>;
46
+ export type UserKeys = 'tenantId' | 'id' | 'username' | 'primaryEmail' | 'primaryPhone' | 'passwordEncrypted' | 'passwordEncryptionMethod' | 'name' | 'avatar' | 'applicationId' | 'identities' | 'customData' | 'logtoConfig' | 'mfaVerifications' | 'isSuspended' | 'lastSignInAt' | 'createdAt';
47
+ export declare const Users: GeneratedSchema<UserKeys, CreateUser, User, 'users', 'user'>;
@@ -15,6 +15,7 @@ const createGuard = z.object({
15
15
  applicationId: z.string().max(21).nullable().optional(),
16
16
  identities: identitiesGuard.optional(),
17
17
  customData: jsonObjectGuard.optional(),
18
+ logtoConfig: jsonObjectGuard.optional(),
18
19
  mfaVerifications: mfaVerificationsGuard.optional(),
19
20
  isSuspended: z.boolean().optional(),
20
21
  lastSignInAt: z.number().nullable().optional(),
@@ -33,6 +34,7 @@ const guard = z.object({
33
34
  applicationId: z.string().max(21).nullable(),
34
35
  identities: identitiesGuard,
35
36
  customData: jsonObjectGuard,
37
+ logtoConfig: jsonObjectGuard,
36
38
  mfaVerifications: mfaVerificationsGuard,
37
39
  isSuspended: z.boolean(),
38
40
  lastSignInAt: z.number().nullable(),
@@ -54,6 +56,7 @@ export const Users = Object.freeze({
54
56
  applicationId: 'application_id',
55
57
  identities: 'identities',
56
58
  customData: 'custom_data',
59
+ logtoConfig: 'logto_config',
57
60
  mfaVerifications: 'mfa_verifications',
58
61
  isSuspended: 'is_suspended',
59
62
  lastSignInAt: 'last_sign_in_at',
@@ -72,6 +75,7 @@ export const Users = Object.freeze({
72
75
  'applicationId',
73
76
  'identities',
74
77
  'customData',
78
+ 'logtoConfig',
75
79
  'mfaVerifications',
76
80
  'isSuspended',
77
81
  'lastSignInAt',
@@ -79,4 +83,5 @@ export const Users = Object.freeze({
79
83
  ],
80
84
  createGuard,
81
85
  guard,
86
+ updateGuard: guard.partial(),
82
87
  });
@@ -1,4 +1,9 @@
1
1
  import { GeneratedSchema } from './../foundations/index.js';
2
+ /**
3
+ *
4
+ * @remarks This is a type for database creation.
5
+ * @see {@link UsersRole} for the original type.
6
+ */
2
7
  export type CreateUsersRole = {
3
8
  tenantId?: string;
4
9
  id: string;
@@ -11,4 +16,5 @@ export type UsersRole = {
11
16
  userId: string;
12
17
  roleId: string;
13
18
  };
14
- export declare const UsersRoles: GeneratedSchema<CreateUsersRole, UsersRole>;
19
+ export type UsersRoleKeys = 'tenantId' | 'id' | 'userId' | 'roleId';
20
+ export declare const UsersRoles: GeneratedSchema<UsersRoleKeys, CreateUsersRole, UsersRole, 'users_roles', 'users_role'>;
@@ -29,4 +29,5 @@ export const UsersRoles = Object.freeze({
29
29
  ],
30
30
  createGuard,
31
31
  guard,
32
+ updateGuard: guard.partial(),
32
33
  });
@@ -1,4 +1,9 @@
1
1
  import { GeneratedSchema } from './../foundations/index.js';
2
+ /**
3
+ *
4
+ * @remarks This is a type for database creation.
5
+ * @see {@link VerificationStatus} for the original type.
6
+ */
2
7
  export type CreateVerificationStatus = {
3
8
  tenantId?: string;
4
9
  id: string;
@@ -11,4 +16,5 @@ export type VerificationStatus = {
11
16
  userId: string;
12
17
  createdAt: number;
13
18
  };
14
- export declare const VerificationStatuses: GeneratedSchema<CreateVerificationStatus, VerificationStatus>;
19
+ export type VerificationStatusKeys = 'tenantId' | 'id' | 'userId' | 'createdAt';
20
+ export declare const VerificationStatuses: GeneratedSchema<VerificationStatusKeys, CreateVerificationStatus, VerificationStatus, 'verification_statuses', 'verification_status'>;
@@ -29,4 +29,5 @@ export const VerificationStatuses = Object.freeze({
29
29
  ],
30
30
  createGuard,
31
31
  guard,
32
+ updateGuard: guard.partial(),
32
33
  });
@@ -1,2 +1,2 @@
1
1
  export * from './schemas.js';
2
- export * from './jsonb-types.js';
2
+ export * from './jsonb-types/index.js';
@@ -1,2 +1,2 @@
1
1
  export * from './schemas.js';
2
- export * from './jsonb-types.js';
2
+ export * from './jsonb-types/index.js';
@@ -0,0 +1,134 @@
1
+ import { z } from 'zod';
2
+ export declare const domainDnsRecordGuard: z.ZodObject<{
3
+ name: z.ZodString;
4
+ type: z.ZodString;
5
+ value: z.ZodString;
6
+ }, "strip", z.ZodTypeAny, {
7
+ type: string;
8
+ value: string;
9
+ name: string;
10
+ }, {
11
+ type: string;
12
+ value: string;
13
+ name: string;
14
+ }>;
15
+ export type DomainDnsRecord = z.infer<typeof domainDnsRecordGuard>;
16
+ export declare const domainDnsRecordsGuard: z.ZodArray<z.ZodObject<{
17
+ name: z.ZodString;
18
+ type: z.ZodString;
19
+ value: z.ZodString;
20
+ }, "strip", z.ZodTypeAny, {
21
+ type: string;
22
+ value: string;
23
+ name: string;
24
+ }, {
25
+ type: string;
26
+ value: string;
27
+ name: string;
28
+ }>, "many">;
29
+ export type DomainDnsRecords = z.infer<typeof domainDnsRecordsGuard>;
30
+ export declare const cloudflareDataGuard: z.ZodObject<{
31
+ id: z.ZodString;
32
+ status: z.ZodString;
33
+ ssl: z.ZodObject<{
34
+ status: z.ZodString;
35
+ validation_errors: z.ZodOptional<z.ZodArray<z.ZodObject<{
36
+ message: z.ZodString;
37
+ }, "strip", z.ZodUnknown, z.objectOutputType<{
38
+ message: z.ZodString;
39
+ }, z.ZodUnknown, "strip">, z.objectInputType<{
40
+ message: z.ZodString;
41
+ }, z.ZodUnknown, "strip">>, "many">>;
42
+ }, "strip", z.ZodUnknown, z.objectOutputType<{
43
+ status: z.ZodString;
44
+ validation_errors: z.ZodOptional<z.ZodArray<z.ZodObject<{
45
+ message: z.ZodString;
46
+ }, "strip", z.ZodUnknown, z.objectOutputType<{
47
+ message: z.ZodString;
48
+ }, z.ZodUnknown, "strip">, z.objectInputType<{
49
+ message: z.ZodString;
50
+ }, z.ZodUnknown, "strip">>, "many">>;
51
+ }, z.ZodUnknown, "strip">, z.objectInputType<{
52
+ status: z.ZodString;
53
+ validation_errors: z.ZodOptional<z.ZodArray<z.ZodObject<{
54
+ message: z.ZodString;
55
+ }, "strip", z.ZodUnknown, z.objectOutputType<{
56
+ message: z.ZodString;
57
+ }, z.ZodUnknown, "strip">, z.objectInputType<{
58
+ message: z.ZodString;
59
+ }, z.ZodUnknown, "strip">>, "many">>;
60
+ }, z.ZodUnknown, "strip">>;
61
+ verification_errors: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
62
+ }, "strip", z.ZodUnknown, z.objectOutputType<{
63
+ id: z.ZodString;
64
+ status: z.ZodString;
65
+ ssl: z.ZodObject<{
66
+ status: z.ZodString;
67
+ validation_errors: z.ZodOptional<z.ZodArray<z.ZodObject<{
68
+ message: z.ZodString;
69
+ }, "strip", z.ZodUnknown, z.objectOutputType<{
70
+ message: z.ZodString;
71
+ }, z.ZodUnknown, "strip">, z.objectInputType<{
72
+ message: z.ZodString;
73
+ }, z.ZodUnknown, "strip">>, "many">>;
74
+ }, "strip", z.ZodUnknown, z.objectOutputType<{
75
+ status: z.ZodString;
76
+ validation_errors: z.ZodOptional<z.ZodArray<z.ZodObject<{
77
+ message: z.ZodString;
78
+ }, "strip", z.ZodUnknown, z.objectOutputType<{
79
+ message: z.ZodString;
80
+ }, z.ZodUnknown, "strip">, z.objectInputType<{
81
+ message: z.ZodString;
82
+ }, z.ZodUnknown, "strip">>, "many">>;
83
+ }, z.ZodUnknown, "strip">, z.objectInputType<{
84
+ status: z.ZodString;
85
+ validation_errors: z.ZodOptional<z.ZodArray<z.ZodObject<{
86
+ message: z.ZodString;
87
+ }, "strip", z.ZodUnknown, z.objectOutputType<{
88
+ message: z.ZodString;
89
+ }, z.ZodUnknown, "strip">, z.objectInputType<{
90
+ message: z.ZodString;
91
+ }, z.ZodUnknown, "strip">>, "many">>;
92
+ }, z.ZodUnknown, "strip">>;
93
+ verification_errors: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
94
+ }, z.ZodUnknown, "strip">, z.objectInputType<{
95
+ id: z.ZodString;
96
+ status: z.ZodString;
97
+ ssl: z.ZodObject<{
98
+ status: z.ZodString;
99
+ validation_errors: z.ZodOptional<z.ZodArray<z.ZodObject<{
100
+ message: z.ZodString;
101
+ }, "strip", z.ZodUnknown, z.objectOutputType<{
102
+ message: z.ZodString;
103
+ }, z.ZodUnknown, "strip">, z.objectInputType<{
104
+ message: z.ZodString;
105
+ }, z.ZodUnknown, "strip">>, "many">>;
106
+ }, "strip", z.ZodUnknown, z.objectOutputType<{
107
+ status: z.ZodString;
108
+ validation_errors: z.ZodOptional<z.ZodArray<z.ZodObject<{
109
+ message: z.ZodString;
110
+ }, "strip", z.ZodUnknown, z.objectOutputType<{
111
+ message: z.ZodString;
112
+ }, z.ZodUnknown, "strip">, z.objectInputType<{
113
+ message: z.ZodString;
114
+ }, z.ZodUnknown, "strip">>, "many">>;
115
+ }, z.ZodUnknown, "strip">, z.objectInputType<{
116
+ status: z.ZodString;
117
+ validation_errors: z.ZodOptional<z.ZodArray<z.ZodObject<{
118
+ message: z.ZodString;
119
+ }, "strip", z.ZodUnknown, z.objectOutputType<{
120
+ message: z.ZodString;
121
+ }, z.ZodUnknown, "strip">, z.objectInputType<{
122
+ message: z.ZodString;
123
+ }, z.ZodUnknown, "strip">>, "many">>;
124
+ }, z.ZodUnknown, "strip">>;
125
+ verification_errors: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
126
+ }, z.ZodUnknown, "strip">>;
127
+ export type CloudflareData = z.infer<typeof cloudflareDataGuard>;
128
+ export declare enum DomainStatus {
129
+ PendingVerification = "PendingVerification",
130
+ PendingSsl = "PendingSsl",
131
+ Active = "Active",
132
+ Error = "Error"
133
+ }
134
+ export declare const domainStatusGuard: z.ZodNativeEnum<typeof DomainStatus>;
@@ -0,0 +1,36 @@
1
+ import { z } from 'zod';
2
+ export const domainDnsRecordGuard = z.object({
3
+ name: z.string(),
4
+ type: z.string(),
5
+ value: z.string(),
6
+ });
7
+ export const domainDnsRecordsGuard = domainDnsRecordGuard.array();
8
+ // https://developers.cloudflare.com/api/operations/custom-hostname-for-a-zone-list-custom-hostnames#Responses
9
+ // Predefine the "useful" fields
10
+ export const cloudflareDataGuard = z
11
+ .object({
12
+ id: z.string(),
13
+ status: z.string(),
14
+ ssl: z
15
+ .object({
16
+ status: z.string(),
17
+ validation_errors: z
18
+ .object({
19
+ message: z.string(),
20
+ })
21
+ .catchall(z.unknown())
22
+ .array()
23
+ .optional(),
24
+ })
25
+ .catchall(z.unknown()),
26
+ verification_errors: z.string().array().optional(),
27
+ })
28
+ .catchall(z.unknown());
29
+ export var DomainStatus;
30
+ (function (DomainStatus) {
31
+ DomainStatus["PendingVerification"] = "PendingVerification";
32
+ DomainStatus["PendingSsl"] = "PendingSsl";
33
+ DomainStatus["Active"] = "Active";
34
+ DomainStatus["Error"] = "Error";
35
+ })(DomainStatus || (DomainStatus = {}));
36
+ export const domainStatusGuard = z.nativeEnum(DomainStatus);
@@ -0,0 +1,32 @@
1
+ import { z } from 'zod';
2
+ export declare enum HookEvent {
3
+ PostRegister = "PostRegister",
4
+ PostSignIn = "PostSignIn",
5
+ PostResetPassword = "PostResetPassword"
6
+ }
7
+ export declare const hookEventGuard: z.ZodType<HookEvent>;
8
+ export declare const hookEventsGuard: z.ZodArray<z.ZodType<HookEvent, z.ZodTypeDef, HookEvent>, "many">;
9
+ export type HookEvents = z.infer<typeof hookEventsGuard>;
10
+ export declare const hookConfigGuard: z.ZodObject<{
11
+ /** We don't need `type` since v1 only has web hook */
12
+ /** Method fixed to `POST` */
13
+ url: z.ZodString;
14
+ /** Additional headers that attach to the request */
15
+ headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
16
+ /**
17
+ * @deprecated
18
+ * Retry times when hook response status >= 500.
19
+ * Now the retry times is fixed to 3.
20
+ * Keep for backward compatibility.
21
+ */
22
+ retries: z.ZodOptional<z.ZodNumber>;
23
+ }, "strip", z.ZodTypeAny, {
24
+ url: string;
25
+ headers?: Record<string, string> | undefined;
26
+ retries?: number | undefined;
27
+ }, {
28
+ url: string;
29
+ headers?: Record<string, string> | undefined;
30
+ retries?: number | undefined;
31
+ }>;
32
+ export type HookConfig = z.infer<typeof hookConfigGuard>;
@@ -0,0 +1,24 @@
1
+ import { z } from 'zod';
2
+ export var HookEvent;
3
+ (function (HookEvent) {
4
+ HookEvent["PostRegister"] = "PostRegister";
5
+ HookEvent["PostSignIn"] = "PostSignIn";
6
+ HookEvent["PostResetPassword"] = "PostResetPassword";
7
+ })(HookEvent || (HookEvent = {}));
8
+ export const hookEventGuard = z.nativeEnum(HookEvent);
9
+ export const hookEventsGuard = hookEventGuard.array();
10
+ export const hookConfigGuard = z.object({
11
+ /** We don't need `type` since v1 only has web hook */
12
+ // type: 'web';
13
+ /** Method fixed to `POST` */
14
+ url: z.string(),
15
+ /** Additional headers that attach to the request */
16
+ headers: z.record(z.string()).optional(),
17
+ /**
18
+ * @deprecated
19
+ * Retry times when hook response status >= 500.
20
+ * Now the retry times is fixed to 3.
21
+ * Keep for backward compatibility.
22
+ */
23
+ retries: z.number().gte(0).lte(3).optional(),
24
+ });
@@ -0,0 +1,15 @@
1
+ import type { Json } from '@withtyped/server';
2
+ import { z } from 'zod';
3
+ export * from './custom-domain.js';
4
+ export * from './hooks.js';
5
+ export * from './logs.js';
6
+ export * from './oidc-module.js';
7
+ export * from './phrases.js';
8
+ export * from './sign-in-experience.js';
9
+ export * from './sentinel.js';
10
+ export * from './users.js';
11
+ export * from './sso-connector.js';
12
+ export { configurableConnectorMetadataGuard, type ConfigurableConnectorMetadata, } from '@logto/connector-kit';
13
+ export type { Json, JsonObject } from '@withtyped/server';
14
+ export declare const jsonGuard: z.ZodType<Json>;
15
+ export declare const jsonObjectGuard: z.ZodRecord<z.ZodString, z.ZodType<Json, z.ZodTypeDef, Json>>;
@@ -0,0 +1,16 @@
1
+ import { z } from 'zod';
2
+ export * from './custom-domain.js';
3
+ export * from './hooks.js';
4
+ export * from './logs.js';
5
+ export * from './oidc-module.js';
6
+ export * from './phrases.js';
7
+ export * from './sign-in-experience.js';
8
+ export * from './sentinel.js';
9
+ export * from './users.js';
10
+ export * from './sso-connector.js';
11
+ export { configurableConnectorMetadataGuard, } from '@logto/connector-kit';
12
+ /* === Commonly Used === */
13
+ // Copied from https://github.com/colinhacks/zod#json-type
14
+ const literalSchema = z.union([z.string(), z.number(), z.boolean(), z.null()]);
15
+ export const jsonGuard = z.lazy(() => z.union([literalSchema, z.array(jsonGuard), z.record(jsonGuard)]));
16
+ export const jsonObjectGuard = z.record(jsonGuard);
@@ -0,0 +1,106 @@
1
+ import { type PasswordPolicy } from '@logto/core-kit';
2
+ import { type DeepPartial } from '@silverhand/essentials';
3
+ import { z } from 'zod';
4
+ export declare enum LogResult {
5
+ Success = "Success",
6
+ Error = "Error"
7
+ }
8
+ export declare const logContextPayloadGuard: z.ZodObject<{
9
+ key: z.ZodString;
10
+ result: z.ZodNativeEnum<typeof LogResult>;
11
+ error: z.ZodOptional<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodString]>>;
12
+ ip: z.ZodOptional<z.ZodString>;
13
+ userAgent: z.ZodOptional<z.ZodString>;
14
+ userId: z.ZodOptional<z.ZodString>;
15
+ applicationId: z.ZodOptional<z.ZodString>;
16
+ sessionId: z.ZodOptional<z.ZodString>;
17
+ }, "strip", z.ZodUnknown, z.objectOutputType<{
18
+ key: z.ZodString;
19
+ result: z.ZodNativeEnum<typeof LogResult>;
20
+ error: z.ZodOptional<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodString]>>;
21
+ ip: z.ZodOptional<z.ZodString>;
22
+ userAgent: z.ZodOptional<z.ZodString>;
23
+ userId: z.ZodOptional<z.ZodString>;
24
+ applicationId: z.ZodOptional<z.ZodString>;
25
+ sessionId: z.ZodOptional<z.ZodString>;
26
+ }, z.ZodUnknown, "strip">, z.objectInputType<{
27
+ key: z.ZodString;
28
+ result: z.ZodNativeEnum<typeof LogResult>;
29
+ error: z.ZodOptional<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodString]>>;
30
+ ip: z.ZodOptional<z.ZodString>;
31
+ userAgent: z.ZodOptional<z.ZodString>;
32
+ userId: z.ZodOptional<z.ZodString>;
33
+ applicationId: z.ZodOptional<z.ZodString>;
34
+ sessionId: z.ZodOptional<z.ZodString>;
35
+ }, z.ZodUnknown, "strip">>;
36
+ export type PartialPasswordPolicy = DeepPartial<PasswordPolicy>;
37
+ export declare const partialPasswordPolicyGuard: z.ZodObject<{
38
+ length: z.ZodOptional<z.ZodDefault<z.ZodObject<{
39
+ min: z.ZodDefault<z.ZodNumber>;
40
+ max: z.ZodDefault<z.ZodNumber>;
41
+ }, "strip", z.ZodTypeAny, {
42
+ min: number;
43
+ max: number;
44
+ }, {
45
+ min?: number | undefined;
46
+ max?: number | undefined;
47
+ }>>>;
48
+ characterTypes: z.ZodOptional<z.ZodDefault<z.ZodObject<{
49
+ min: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
50
+ }, "strip", z.ZodTypeAny, {
51
+ min: number;
52
+ }, {
53
+ min?: number | undefined;
54
+ }>>>;
55
+ rejects: z.ZodOptional<z.ZodDefault<z.ZodObject<{
56
+ pwned: z.ZodDefault<z.ZodBoolean>;
57
+ repetitionAndSequence: z.ZodDefault<z.ZodBoolean>;
58
+ userInfo: z.ZodDefault<z.ZodBoolean>;
59
+ words: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
60
+ }, "strip", z.ZodTypeAny, {
61
+ pwned: boolean;
62
+ repetitionAndSequence: boolean;
63
+ userInfo: boolean;
64
+ words: string[];
65
+ }, {
66
+ pwned?: boolean | undefined;
67
+ repetitionAndSequence?: boolean | undefined;
68
+ userInfo?: boolean | undefined;
69
+ words?: string[] | undefined;
70
+ }>>>;
71
+ }, "strip", z.ZodTypeAny, {
72
+ length?: {
73
+ min: number;
74
+ max: number;
75
+ } | undefined;
76
+ characterTypes?: {
77
+ min: number;
78
+ } | undefined;
79
+ rejects?: {
80
+ pwned: boolean;
81
+ repetitionAndSequence: boolean;
82
+ userInfo: boolean;
83
+ words: string[];
84
+ } | undefined;
85
+ }, {
86
+ length?: {
87
+ min?: number | undefined;
88
+ max?: number | undefined;
89
+ } | undefined;
90
+ characterTypes?: {
91
+ min?: number | undefined;
92
+ } | undefined;
93
+ rejects?: {
94
+ pwned?: boolean | undefined;
95
+ repetitionAndSequence?: boolean | undefined;
96
+ userInfo?: boolean | undefined;
97
+ words?: string[] | undefined;
98
+ } | undefined;
99
+ }>;
100
+ /**
101
+ * The basic log context type. It's more about a type hint instead of forcing the log shape.
102
+ *
103
+ * Note when setting up a log function, the type of log key in function arguments should be `LogKey`.
104
+ * Here we use `string` to make it compatible with the Zod guard.
105
+ **/
106
+ export type LogContextPayload = z.infer<typeof logContextPayloadGuard>;
@@ -0,0 +1,20 @@
1
+ import { passwordPolicyGuard } from '@logto/core-kit';
2
+ import { z } from 'zod';
3
+ export var LogResult;
4
+ (function (LogResult) {
5
+ LogResult["Success"] = "Success";
6
+ LogResult["Error"] = "Error";
7
+ })(LogResult || (LogResult = {}));
8
+ export const logContextPayloadGuard = z
9
+ .object({
10
+ key: z.string(),
11
+ result: z.nativeEnum(LogResult),
12
+ error: z.record(z.string(), z.unknown()).or(z.string()).optional(),
13
+ ip: z.string().optional(),
14
+ userAgent: z.string().optional(),
15
+ userId: z.string().optional(),
16
+ applicationId: z.string().optional(),
17
+ sessionId: z.string().optional(),
18
+ })
19
+ .catchall(z.unknown());
20
+ export const partialPasswordPolicyGuard = passwordPolicyGuard.deepPartial();
@@ -0,0 +1,80 @@
1
+ import { z } from 'zod';
2
+ export declare const oidcModelInstancePayloadGuard: z.ZodObject<{
3
+ userCode: z.ZodOptional<z.ZodString>;
4
+ uid: z.ZodOptional<z.ZodString>;
5
+ grantId: z.ZodOptional<z.ZodString>;
6
+ }, "strip", z.ZodUnknown, z.objectOutputType<{
7
+ userCode: z.ZodOptional<z.ZodString>;
8
+ uid: z.ZodOptional<z.ZodString>;
9
+ grantId: z.ZodOptional<z.ZodString>;
10
+ }, z.ZodUnknown, "strip">, z.objectInputType<{
11
+ userCode: z.ZodOptional<z.ZodString>;
12
+ uid: z.ZodOptional<z.ZodString>;
13
+ grantId: z.ZodOptional<z.ZodString>;
14
+ }, z.ZodUnknown, "strip">>;
15
+ export type OidcModelInstancePayload = z.infer<typeof oidcModelInstancePayloadGuard>;
16
+ export declare const oidcClientMetadataGuard: z.ZodObject<{
17
+ redirectUris: z.ZodArray<z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodString, string, string>]>, "many">;
18
+ postLogoutRedirectUris: z.ZodArray<z.ZodString, "many">;
19
+ logoUri: z.ZodOptional<z.ZodString>;
20
+ }, "strip", z.ZodTypeAny, {
21
+ redirectUris: string[];
22
+ postLogoutRedirectUris: string[];
23
+ logoUri?: string | undefined;
24
+ }, {
25
+ redirectUris: string[];
26
+ postLogoutRedirectUris: string[];
27
+ logoUri?: string | undefined;
28
+ }>;
29
+ export type OidcClientMetadata = z.infer<typeof oidcClientMetadataGuard>;
30
+ export declare enum CustomClientMetadataKey {
31
+ CorsAllowedOrigins = "corsAllowedOrigins",
32
+ IdTokenTtl = "idTokenTtl",
33
+ /** @deprecated Use {@link RefreshTokenTtlInDays} instead. */
34
+ RefreshTokenTtl = "refreshTokenTtl",
35
+ RefreshTokenTtlInDays = "refreshTokenTtlInDays",
36
+ TenantId = "tenantId",
37
+ /**
38
+ * Enabling this configuration will allow Logto to always issue Refresh Tokens, regardless of whether `prompt=consent` is presented in the authentication request.
39
+ *
40
+ * It only works for web applications when the client allowed grant types includes `refresh_token`.
41
+ *
42
+ * This config is for the third-party integrations that do not strictly follow OpenID Connect standards due to some reasons (e.g. they only know OAuth, but requires a Refresh Token to be returned anyway).
43
+ */
44
+ AlwaysIssueRefreshToken = "alwaysIssueRefreshToken",
45
+ /**
46
+ * When enabled (default), Logto will issue a new Refresh Token for token requests when 70% of the original Time to Live (TTL) has passed.
47
+ *
48
+ * It can be turned off for only traditional web apps for enhanced security.
49
+ */
50
+ RotateRefreshToken = "rotateRefreshToken"
51
+ }
52
+ export declare const customClientMetadataGuard: z.ZodObject<{
53
+ corsAllowedOrigins: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
54
+ idTokenTtl: z.ZodOptional<z.ZodNumber>;
55
+ refreshTokenTtl: z.ZodOptional<z.ZodNumber>;
56
+ refreshTokenTtlInDays: z.ZodOptional<z.ZodNumber>;
57
+ tenantId: z.ZodOptional<z.ZodString>;
58
+ alwaysIssueRefreshToken: z.ZodOptional<z.ZodBoolean>;
59
+ rotateRefreshToken: z.ZodOptional<z.ZodBoolean>;
60
+ }, "strip", z.ZodTypeAny, {
61
+ corsAllowedOrigins?: string[] | undefined;
62
+ idTokenTtl?: number | undefined;
63
+ refreshTokenTtl?: number | undefined;
64
+ refreshTokenTtlInDays?: number | undefined;
65
+ tenantId?: string | undefined;
66
+ alwaysIssueRefreshToken?: boolean | undefined;
67
+ rotateRefreshToken?: boolean | undefined;
68
+ }, {
69
+ corsAllowedOrigins?: string[] | undefined;
70
+ idTokenTtl?: number | undefined;
71
+ refreshTokenTtl?: number | undefined;
72
+ refreshTokenTtlInDays?: number | undefined;
73
+ tenantId?: string | undefined;
74
+ alwaysIssueRefreshToken?: boolean | undefined;
75
+ rotateRefreshToken?: boolean | undefined;
76
+ }>;
77
+ /**
78
+ * @see {@link CustomClientMetadataKey} for key descriptions.
79
+ */
80
+ export type CustomClientMetadata = z.infer<typeof customClientMetadataGuard>;
@@ -0,0 +1,54 @@
1
+ import { validateRedirectUrl } from '@logto/core-kit';
2
+ import { z } from 'zod';
3
+ export const oidcModelInstancePayloadGuard = z
4
+ .object({
5
+ userCode: z.string().optional(),
6
+ uid: z.string().optional(),
7
+ grantId: z.string().optional(),
8
+ })
9
+ /**
10
+ * Try to use `.passthrough()` if type has been fixed.
11
+ * https://github.com/colinhacks/zod/issues/452
12
+ */
13
+ .catchall(z.unknown());
14
+ export const oidcClientMetadataGuard = z.object({
15
+ redirectUris: z
16
+ .string()
17
+ .refine((url) => validateRedirectUrl(url, 'web'))
18
+ .or(z.string().refine((url) => validateRedirectUrl(url, 'mobile')))
19
+ .array(),
20
+ postLogoutRedirectUris: z.string().url().array(),
21
+ logoUri: z.string().optional(),
22
+ });
23
+ export var CustomClientMetadataKey;
24
+ (function (CustomClientMetadataKey) {
25
+ CustomClientMetadataKey["CorsAllowedOrigins"] = "corsAllowedOrigins";
26
+ CustomClientMetadataKey["IdTokenTtl"] = "idTokenTtl";
27
+ /** @deprecated Use {@link RefreshTokenTtlInDays} instead. */
28
+ CustomClientMetadataKey["RefreshTokenTtl"] = "refreshTokenTtl";
29
+ CustomClientMetadataKey["RefreshTokenTtlInDays"] = "refreshTokenTtlInDays";
30
+ CustomClientMetadataKey["TenantId"] = "tenantId";
31
+ /**
32
+ * Enabling this configuration will allow Logto to always issue Refresh Tokens, regardless of whether `prompt=consent` is presented in the authentication request.
33
+ *
34
+ * It only works for web applications when the client allowed grant types includes `refresh_token`.
35
+ *
36
+ * This config is for the third-party integrations that do not strictly follow OpenID Connect standards due to some reasons (e.g. they only know OAuth, but requires a Refresh Token to be returned anyway).
37
+ */
38
+ CustomClientMetadataKey["AlwaysIssueRefreshToken"] = "alwaysIssueRefreshToken";
39
+ /**
40
+ * When enabled (default), Logto will issue a new Refresh Token for token requests when 70% of the original Time to Live (TTL) has passed.
41
+ *
42
+ * It can be turned off for only traditional web apps for enhanced security.
43
+ */
44
+ CustomClientMetadataKey["RotateRefreshToken"] = "rotateRefreshToken";
45
+ })(CustomClientMetadataKey || (CustomClientMetadataKey = {}));
46
+ export const customClientMetadataGuard = z.object({
47
+ [CustomClientMetadataKey.CorsAllowedOrigins]: z.string().min(1).array().optional(),
48
+ [CustomClientMetadataKey.IdTokenTtl]: z.number().optional(),
49
+ [CustomClientMetadataKey.RefreshTokenTtl]: z.number().optional(),
50
+ [CustomClientMetadataKey.RefreshTokenTtlInDays]: z.number().int().min(1).max(90).optional(),
51
+ [CustomClientMetadataKey.TenantId]: z.string().optional(),
52
+ [CustomClientMetadataKey.AlwaysIssueRefreshToken]: z.boolean().optional(),
53
+ [CustomClientMetadataKey.RotateRefreshToken]: z.boolean().optional(),
54
+ });
@@ -0,0 +1,5 @@
1
+ import { z } from 'zod';
2
+ export type Translation = {
3
+ [key: string]: string | Translation;
4
+ };
5
+ export declare const translationGuard: z.ZodType<Translation>;
@@ -0,0 +1,2 @@
1
+ import { z } from 'zod';
2
+ export const translationGuard = z.lazy(() => z.record(z.string().or(translationGuard)));