@tstdl/base 0.93.178 → 0.93.180

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 (207) hide show
  1. package/api/response.js +4 -3
  2. package/api/server/gateway.js +9 -3
  3. package/audit/auditor.d.ts +1 -2
  4. package/audit/drizzle/{0000_lumpy_thunderball.sql → 0000_shallow_elektra.sql} +1 -1
  5. package/audit/drizzle/meta/0000_snapshot.json +2 -2
  6. package/audit/drizzle/meta/_journal.json +2 -2
  7. package/authentication/README.md +87 -42
  8. package/authentication/authentication.api.d.ts +392 -53
  9. package/authentication/authentication.api.js +133 -28
  10. package/authentication/client/api.client.d.ts +3 -3
  11. package/authentication/client/api.client.js +4 -4
  12. package/authentication/client/authentication.service.d.ts +93 -23
  13. package/authentication/client/authentication.service.js +113 -28
  14. package/authentication/client/http-client.middleware.d.ts +1 -1
  15. package/authentication/client/http-client.middleware.js +5 -4
  16. package/authentication/client/module.d.ts +1 -1
  17. package/authentication/client/module.js +2 -2
  18. package/authentication/errors/index.d.ts +1 -1
  19. package/authentication/errors/index.js +1 -1
  20. package/authentication/errors/password-requirements.error.d.ts +5 -0
  21. package/authentication/errors/{secret-requirements.error.js → password-requirements.error.js} +2 -2
  22. package/authentication/models/authentication-password.model.d.ts +8 -0
  23. package/authentication/models/{authentication-credentials.model.js → authentication-password.model.js} +11 -17
  24. package/authentication/models/authentication-session.model.d.ts +0 -2
  25. package/authentication/models/authentication-session.model.js +1 -7
  26. package/authentication/models/authentication-totp-recovery-code.model.d.ts +6 -0
  27. package/authentication/models/authentication-totp-recovery-code.model.js +34 -0
  28. package/authentication/models/authentication-totp.model.d.ts +19 -0
  29. package/authentication/models/authentication-totp.model.js +51 -0
  30. package/authentication/models/authentication-used-totp-token.model.d.ts +5 -0
  31. package/authentication/models/authentication-used-totp-token.model.js +32 -0
  32. package/authentication/models/index.d.ts +6 -3
  33. package/authentication/models/index.js +6 -3
  34. package/authentication/models/{init-secret-reset-data.model.d.ts → init-password-reset-data.model.d.ts} +3 -3
  35. package/authentication/models/{init-secret-reset-data.model.js → init-password-reset-data.model.js} +5 -5
  36. package/authentication/models/password-check-result.model.d.ts +3 -0
  37. package/authentication/models/{secret-check-result.model.js → password-check-result.model.js} +6 -6
  38. package/authentication/models/subject.model.d.ts +0 -6
  39. package/authentication/models/subject.model.js +0 -6
  40. package/authentication/models/token.model.d.ts +16 -2
  41. package/authentication/server/authentication-ancillary.service.d.ts +6 -6
  42. package/authentication/server/authentication-ancillary.service.js +1 -1
  43. package/authentication/server/authentication-password-requirements.validator.d.ts +55 -0
  44. package/authentication/server/{authentication-secret-requirements.validator.js → authentication-password-requirements.validator.js} +22 -22
  45. package/authentication/server/authentication.api-controller.d.ts +55 -27
  46. package/authentication/server/authentication.api-controller.js +214 -39
  47. package/authentication/server/authentication.audit.d.ts +42 -5
  48. package/authentication/server/authentication.service.d.ts +182 -93
  49. package/authentication/server/authentication.service.js +628 -206
  50. package/authentication/server/drizzle/{0000_soft_tag.sql → 0000_odd_echo.sql} +59 -13
  51. package/authentication/server/drizzle/meta/0000_snapshot.json +345 -32
  52. package/authentication/server/drizzle/meta/_journal.json +2 -2
  53. package/authentication/server/helper.d.ts +16 -16
  54. package/authentication/server/helper.js +33 -34
  55. package/authentication/server/index.d.ts +1 -1
  56. package/authentication/server/index.js +1 -1
  57. package/authentication/server/module.d.ts +2 -2
  58. package/authentication/server/module.js +4 -2
  59. package/authentication/server/schemas.d.ts +11 -7
  60. package/authentication/server/schemas.js +7 -3
  61. package/authentication/tests/authentication-password-requirements.validator.test.js +29 -0
  62. package/authentication/tests/authentication.api-controller.test.js +49 -15
  63. package/authentication/tests/authentication.client-error-handling.test.js +3 -2
  64. package/authentication/tests/authentication.client-middleware.test.js +5 -5
  65. package/authentication/tests/authentication.client-service-methods.test.js +28 -14
  66. package/authentication/tests/authentication.client-service-refresh.test.js +7 -6
  67. package/authentication/tests/authentication.client-service.test.js +10 -8
  68. package/authentication/tests/authentication.service.test.js +37 -29
  69. package/authentication/tests/authentication.test-ancillary-service.d.ts +1 -1
  70. package/authentication/tests/authentication.test-ancillary-service.js +1 -1
  71. package/authentication/tests/brute-force-protection.test.js +211 -0
  72. package/authentication/tests/helper.test.js +25 -21
  73. package/authentication/tests/password-requirements.error.test.js +14 -0
  74. package/authentication/tests/remember.api.test.js +22 -14
  75. package/authentication/tests/remember.service.test.js +23 -16
  76. package/authentication/tests/subject.service.test.js +2 -2
  77. package/authentication/tests/suspended-subject.test.d.ts +1 -0
  78. package/authentication/tests/suspended-subject.test.js +120 -0
  79. package/authentication/tests/totp.enrollment.test.d.ts +1 -0
  80. package/authentication/tests/totp.enrollment.test.js +123 -0
  81. package/authentication/tests/totp.login.test.d.ts +1 -0
  82. package/authentication/tests/totp.login.test.js +213 -0
  83. package/authentication/tests/totp.recovery-codes.test.d.ts +1 -0
  84. package/authentication/tests/totp.recovery-codes.test.js +97 -0
  85. package/authentication/tests/totp.status.test.d.ts +1 -0
  86. package/authentication/tests/totp.status.test.js +72 -0
  87. package/circuit-breaker/postgres/drizzle/{0000_cooing_korath.sql → 0000_same_captain_cross.sql} +1 -1
  88. package/circuit-breaker/postgres/drizzle/meta/0000_snapshot.json +2 -2
  89. package/circuit-breaker/postgres/drizzle/meta/_journal.json +2 -2
  90. package/cryptography/cryptography.d.ts +336 -0
  91. package/cryptography/cryptography.js +328 -0
  92. package/cryptography/index.d.ts +4 -0
  93. package/cryptography/index.js +4 -0
  94. package/{utils → cryptography}/jwt.d.ts +22 -4
  95. package/{utils → cryptography}/jwt.js +36 -18
  96. package/cryptography/module.d.ts +35 -0
  97. package/cryptography/module.js +148 -0
  98. package/cryptography/tests/cryptography.test.d.ts +1 -0
  99. package/cryptography/tests/cryptography.test.js +175 -0
  100. package/cryptography/tests/jwt.test.d.ts +1 -0
  101. package/cryptography/tests/jwt.test.js +54 -0
  102. package/cryptography/tests/modern.test.d.ts +1 -0
  103. package/cryptography/tests/modern.test.js +105 -0
  104. package/cryptography/tests/module.test.d.ts +1 -0
  105. package/cryptography/tests/module.test.js +100 -0
  106. package/cryptography/tests/totp.test.d.ts +1 -0
  107. package/cryptography/tests/totp.test.js +108 -0
  108. package/cryptography/totp.d.ts +96 -0
  109. package/cryptography/totp.js +123 -0
  110. package/document-management/server/drizzle/{0000_curious_nighthawk.sql → 0000_sharp_scream.sql} +21 -21
  111. package/document-management/server/drizzle/meta/0000_snapshot.json +22 -22
  112. package/document-management/server/drizzle/meta/_journal.json +2 -2
  113. package/document-management/server/services/document-file.service.js +1 -1
  114. package/errors/errors.localization.d.ts +2 -2
  115. package/errors/errors.localization.js +2 -2
  116. package/errors/index.d.ts +1 -0
  117. package/errors/index.js +1 -0
  118. package/errors/too-many-requests.error.d.ts +5 -0
  119. package/errors/too-many-requests.error.js +7 -0
  120. package/examples/api/authentication.js +5 -5
  121. package/examples/api/custom-authentication.js +4 -3
  122. package/file/server/mime-type.js +1 -1
  123. package/http/http-body.d.ts +1 -0
  124. package/http/http-body.js +3 -0
  125. package/image-service/imgproxy/imgproxy-image-service.d.ts +0 -1
  126. package/image-service/imgproxy/imgproxy-image-service.js +9 -27
  127. package/key-value-store/postgres/drizzle/{0000_shocking_slipstream.sql → 0000_moaning_calypso.sql} +1 -1
  128. package/key-value-store/postgres/drizzle/meta/0000_snapshot.json +2 -2
  129. package/key-value-store/postgres/drizzle/meta/_journal.json +2 -2
  130. package/lock/postgres/drizzle/{0000_busy_tattoo.sql → 0000_nappy_wraith.sql} +1 -1
  131. package/lock/postgres/drizzle/meta/0000_snapshot.json +2 -2
  132. package/lock/postgres/drizzle/meta/_journal.json +2 -2
  133. package/logger/formatters/json.js +1 -1
  134. package/logger/formatters/pretty-print.js +1 -1
  135. package/mail/drizzle/{0000_numerous_the_watchers.sql → 0000_cultured_quicksilver.sql} +2 -2
  136. package/mail/drizzle/meta/0000_snapshot.json +4 -4
  137. package/mail/drizzle/meta/_journal.json +2 -9
  138. package/notification/server/drizzle/{0000_wise_pyro.sql → 0000_new_tenebrous.sql} +6 -6
  139. package/notification/server/drizzle/meta/0000_snapshot.json +7 -7
  140. package/notification/server/drizzle/meta/_journal.json +2 -2
  141. package/notification/tests/notification-flow.test.js +1 -8
  142. package/notification/tests/notification-type.service.test.js +3 -3
  143. package/openid-connect/oidc.service.js +2 -3
  144. package/orm/data-types/common.js +1 -1
  145. package/orm/server/drizzle/schema-converter.js +9 -4
  146. package/orm/server/encryption.js +1 -1
  147. package/orm/server/module.d.ts +0 -1
  148. package/orm/server/module.js +0 -4
  149. package/orm/server/repository.d.ts +2 -1
  150. package/orm/server/repository.js +7 -10
  151. package/orm/tests/encryption.test.js +4 -6
  152. package/orm/tests/repository-extra-coverage.test.js +0 -2
  153. package/orm/tests/repository-regression.test.js +0 -3
  154. package/package.json +9 -8
  155. package/password/README.md +1 -1
  156. package/password/have-i-been-pwned.js +1 -1
  157. package/rate-limit/postgres/drizzle/{0000_watery_rage.sql → 0000_serious_sauron.sql} +1 -1
  158. package/rate-limit/postgres/drizzle/meta/0000_snapshot.json +2 -2
  159. package/rate-limit/postgres/drizzle/meta/_journal.json +2 -2
  160. package/rate-limit/postgres/postgres-rate-limiter.d.ts +1 -1
  161. package/rate-limit/postgres/postgres-rate-limiter.js +1 -1
  162. package/rate-limit/rate-limiter.d.ts +1 -1
  163. package/rpc/tests/rpc.integration.test.js +25 -31
  164. package/supports.d.ts +1 -0
  165. package/supports.js +1 -0
  166. package/task-queue/postgres/drizzle/{0000_faithful_daimon_hellstrom.sql → 0000_dark_ronan.sql} +5 -5
  167. package/task-queue/postgres/drizzle/meta/0000_snapshot.json +10 -10
  168. package/task-queue/postgres/drizzle/meta/_journal.json +2 -9
  169. package/task-queue/postgres/task-queue.js +2 -2
  170. package/task-queue/tests/coverage-enhancement.test.js +2 -2
  171. package/test/drizzle/{0000_natural_cannonball.sql → 0000_organic_gamora.sql} +2 -2
  172. package/test/drizzle/meta/0000_snapshot.json +3 -4
  173. package/test/drizzle/meta/_journal.json +2 -9
  174. package/testing/integration-setup.d.ts +7 -3
  175. package/testing/integration-setup.js +119 -96
  176. package/utils/alphabet.d.ts +1 -0
  177. package/utils/alphabet.js +1 -0
  178. package/utils/base32.d.ts +4 -0
  179. package/utils/base32.js +49 -0
  180. package/utils/base64.d.ts +0 -2
  181. package/utils/base64.js +6 -70
  182. package/utils/equals.d.ts +13 -3
  183. package/utils/equals.js +29 -9
  184. package/utils/index.d.ts +1 -2
  185. package/utils/index.js +1 -2
  186. package/utils/random.d.ts +1 -0
  187. package/utils/random.js +14 -8
  188. package/authentication/errors/secret-requirements.error.d.ts +0 -5
  189. package/authentication/models/authentication-credentials.model.d.ts +0 -10
  190. package/authentication/models/secret-check-result.model.d.ts +0 -3
  191. package/authentication/server/authentication-secret-requirements.validator.d.ts +0 -55
  192. package/authentication/tests/authentication-ancillary.service.test.js +0 -13
  193. package/authentication/tests/authentication-secret-requirements.validator.test.js +0 -29
  194. package/authentication/tests/secret-requirements.error.test.js +0 -14
  195. package/mail/drizzle/0001_married_tarantula.sql +0 -12
  196. package/mail/drizzle/meta/0001_snapshot.json +0 -69
  197. package/orm/server/tokens.d.ts +0 -1
  198. package/orm/server/tokens.js +0 -2
  199. package/task-queue/postgres/drizzle/0001_rapid_infant_terrible.sql +0 -16
  200. package/task-queue/postgres/drizzle/meta/0001_snapshot.json +0 -753
  201. package/test/drizzle/0001_closed_the_captain.sql +0 -2
  202. package/test/drizzle/meta/0001_snapshot.json +0 -117
  203. package/utils/cryptography.d.ts +0 -137
  204. package/utils/cryptography.js +0 -201
  205. /package/authentication/tests/{authentication-ancillary.service.test.d.ts → authentication-password-requirements.validator.test.d.ts} +0 -0
  206. /package/authentication/tests/{authentication-secret-requirements.validator.test.d.ts → brute-force-protection.test.d.ts} +0 -0
  207. /package/authentication/tests/{secret-requirements.error.test.d.ts → password-requirements.error.test.d.ts} +0 -0
@@ -2,23 +2,23 @@ import { type ApiDefinition, type ApiEndpointsDefinition } from '../api/types.js
2
2
  import { type ObjectSchema, type ObjectSchemaOrType } from '../schema/index.js';
3
3
  import type { SchemaTestable } from '../schema/schema.js';
4
4
  import type { Record } from '../types/index.js';
5
- import type { TokenPayload } from './index.js';
6
- import { SecretCheckResult } from './models/secret-check-result.model.js';
5
+ import { type TokenPayload } from './models/index.js';
6
+ import { PasswordCheckResult } from './models/password-check-result.model.js';
7
7
  /**
8
8
  * Can be provided in {@link ApiEndpointDefinition} data property to signal that the request does not need a valid token.
9
9
  * Useful for login, refresh, etc. endpoints.
10
10
  */
11
11
  export declare const dontWaitForValidToken: unique symbol;
12
- type GetAuthenticationApiEndpointsDefinition<AdditionalTokenPayload extends Record = Record<never>, AuthenticationData = void, AdditionalInitSecretResetData = void> = typeof getAuthenticationApiEndpointsDefinition<AdditionalTokenPayload, AuthenticationData, AdditionalInitSecretResetData>;
13
- type AuthenticationApiEndpointsDefinition<AdditionalTokenPayload extends Record = Record<never>, AuthenticationData = void, AdditionalInitSecretResetData = void> = ReturnType<GetAuthenticationApiEndpointsDefinition<AdditionalTokenPayload, AuthenticationData, AdditionalInitSecretResetData>>;
12
+ type GetAuthenticationApiEndpointsDefinition<AdditionalTokenPayload extends Record = Record<never>, AuthenticationData = void, AdditionalInitPasswordResetData = void> = typeof getAuthenticationApiEndpointsDefinition<AdditionalTokenPayload, AuthenticationData, AdditionalInitPasswordResetData>;
13
+ type AuthenticationApiEndpointsDefinition<AdditionalTokenPayload extends Record = Record<never>, AuthenticationData = void, AdditionalInitPasswordResetData = void> = ReturnType<GetAuthenticationApiEndpointsDefinition<AdditionalTokenPayload, AuthenticationData, AdditionalInitPasswordResetData>>;
14
14
  /**
15
15
  * Authentication REST API definition
16
16
  *
17
17
  * @template AdditionalTokenPayload Type of additional token payload
18
18
  * @template AuthenticationData Type of additional authentication data
19
- * @template AdditionalInitSecretResetData Type of additional secret reset data
19
+ * @template AdditionalInitPasswordResetData Type of additional password reset data
20
20
  */
21
- export type AuthenticationApiDefinition<AdditionalTokenPayload extends Record = Record<never>, AuthenticationData = void, AdditionalInitSecretResetData = void> = ApiDefinition<string, AuthenticationApiEndpointsDefinition<AdditionalTokenPayload, AuthenticationData, AdditionalInitSecretResetData>>;
21
+ export type AuthenticationApiDefinition<AdditionalTokenPayload extends Record = Record<never>, AuthenticationData = void, AdditionalInitPasswordResetData = void> = ApiDefinition<string, AuthenticationApiEndpointsDefinition<AdditionalTokenPayload, AuthenticationData, AdditionalInitPasswordResetData>>;
22
22
  /** Default authentication API definition */
23
23
  export declare const authenticationApiDefinition: {
24
24
  resource: string;
@@ -29,16 +29,115 @@ export declare const authenticationApiDefinition: {
29
29
  parameters: ObjectSchema<{
30
30
  readonly tenantId: string | undefined;
31
31
  readonly subject: string;
32
- readonly secret: string;
32
+ readonly password: string;
33
33
  readonly remember: boolean;
34
34
  readonly data: undefined;
35
35
  }>;
36
- result: ObjectSchema<TokenPayload<import("type-fest").EmptyObject>>;
36
+ result: import("../schema/index.js").UnionSchema<[ObjectSchema<{
37
+ type: "success";
38
+ result: TokenPayload<import("type-fest").EmptyObject>;
39
+ lowRecoveryCodesWarning?: boolean | undefined;
40
+ }>, ObjectSchema<{
41
+ type: "totp";
42
+ challengeToken: string;
43
+ }>]>;
44
+ credentials: true;
45
+ data: {
46
+ [dontWaitForValidToken]: boolean;
47
+ };
48
+ };
49
+ loginVerifyTotp: {
50
+ resource: string;
51
+ method: "POST";
52
+ parameters: ObjectSchema<{
53
+ readonly challengeToken: string;
54
+ readonly token: string;
55
+ }>;
56
+ result: ObjectSchema<{
57
+ type: "success";
58
+ result: TokenPayload<import("type-fest").EmptyObject>;
59
+ lowRecoveryCodesWarning?: boolean | undefined;
60
+ }>;
61
+ credentials: true;
62
+ data: {
63
+ [dontWaitForValidToken]: boolean;
64
+ };
65
+ };
66
+ loginRecovery: {
67
+ resource: string;
68
+ method: "POST";
69
+ parameters: ObjectSchema<{
70
+ challengeToken: string;
71
+ recoveryCode: string;
72
+ }>;
73
+ result: ObjectSchema<{
74
+ type: "success";
75
+ result: TokenPayload<import("type-fest").EmptyObject>;
76
+ lowRecoveryCodesWarning?: boolean | undefined;
77
+ }>;
37
78
  credentials: true;
38
79
  data: {
39
80
  [dontWaitForValidToken]: boolean;
40
81
  };
41
82
  };
83
+ initEnrollTotp: {
84
+ resource: string;
85
+ method: "POST";
86
+ result: ObjectSchema<{
87
+ secret: string;
88
+ uri: string;
89
+ }>;
90
+ credentials: true;
91
+ };
92
+ completeEnrollTotp: {
93
+ resource: string;
94
+ method: "POST";
95
+ parameters: ObjectSchema<{
96
+ token: string;
97
+ }>;
98
+ result: ObjectSchema<{
99
+ recoveryCodes: string[];
100
+ }>;
101
+ credentials: true;
102
+ };
103
+ disableTotp: {
104
+ resource: string;
105
+ method: "POST";
106
+ parameters: ObjectSchema<{
107
+ token: string;
108
+ }>;
109
+ result: import("../schema/index.js").LiteralSchema<"ok">;
110
+ credentials: true;
111
+ };
112
+ disableTotpWithRecoveryCode: {
113
+ resource: string;
114
+ method: "POST";
115
+ parameters: ObjectSchema<{
116
+ recoveryCode: string;
117
+ }>;
118
+ result: import("../schema/index.js").LiteralSchema<"ok">;
119
+ credentials: true;
120
+ };
121
+ regenerateRecoveryCodes: {
122
+ resource: string;
123
+ method: "POST";
124
+ parameters: ObjectSchema<{
125
+ token: string;
126
+ invalidateOtherSessions?: boolean | undefined;
127
+ }>;
128
+ result: ObjectSchema<{
129
+ recoveryCodes: string[];
130
+ }>;
131
+ credentials: true;
132
+ };
133
+ getTotpStatus: {
134
+ resource: string;
135
+ method: "GET";
136
+ result: ObjectSchema<{
137
+ active: boolean;
138
+ }>;
139
+ credentials: true;
140
+ };
42
141
  refresh: {
43
142
  resource: string;
44
143
  method: "POST";
@@ -85,19 +184,17 @@ export declare const authenticationApiDefinition: {
85
184
  [dontWaitForValidToken]: boolean;
86
185
  };
87
186
  };
88
- changeSecret: {
187
+ changePassword: {
89
188
  resource: string;
90
189
  method: "POST";
91
190
  parameters: ObjectSchema<{
92
- readonly tenantId: string | undefined;
93
- readonly subject: string;
94
- readonly currentSecret: string;
95
- readonly newSecret: string;
191
+ currentPassword: string;
192
+ newPassword: string;
96
193
  }>;
97
194
  result: import("../schema/index.js").LiteralSchema<"ok">;
98
195
  credentials: true;
99
196
  };
100
- initSecretReset: {
197
+ initPasswordReset: {
101
198
  resource: string;
102
199
  method: "POST";
103
200
  parameters: ObjectSchema<{
@@ -107,22 +204,22 @@ export declare const authenticationApiDefinition: {
107
204
  }>;
108
205
  result: import("../schema/index.js").LiteralSchema<"ok">;
109
206
  };
110
- resetSecret: {
207
+ resetPassword: {
111
208
  resource: string;
112
209
  method: "POST";
113
210
  parameters: ObjectSchema<{
114
211
  token: string;
115
- newSecret: string;
212
+ newPassword: string;
116
213
  }>;
117
214
  result: import("../schema/index.js").LiteralSchema<"ok">;
118
215
  };
119
- checkSecret: {
216
+ checkPassword: {
120
217
  resource: string;
121
218
  method: "POST";
122
219
  parameters: ObjectSchema<{
123
- secret: string;
220
+ password: string;
124
221
  }>;
125
- result: typeof SecretCheckResult;
222
+ result: typeof PasswordCheckResult;
126
223
  };
127
224
  timestamp: {
128
225
  resource: string;
@@ -131,22 +228,38 @@ export declare const authenticationApiDefinition: {
131
228
  [dontWaitForValidToken]: boolean;
132
229
  };
133
230
  };
231
+ listSessions: {
232
+ resource: string;
233
+ method: "GET";
234
+ result: import("../schema/index.js").ArraySchema<{
235
+ id: import("../orm/types.js").IsPrimaryKey<import("../orm/types.js").HasDefault<import("../orm/types.js").Uuid>>;
236
+ begin: import("../orm/types.js").Timestamp;
237
+ end: import("../orm/types.js").Timestamp;
238
+ }>;
239
+ credentials: true;
240
+ };
241
+ invalidateAllOtherSessions: {
242
+ resource: string;
243
+ method: "POST";
244
+ result: import("../schema/index.js").LiteralSchema<"ok">;
245
+ credentials: true;
246
+ };
134
247
  };
135
248
  };
136
249
  /**
137
250
  * Get authentication REST API definition
138
251
  * @param additionalTokenPayloadSchema Schema for additional token payload
139
252
  * @param authenticationDataSchema Schema for additional authentication data
140
- * @param initSecretResetDataSchema Schema for additional secret reset data
253
+ * @param initPasswordResetDataSchema Schema for additional password reset data
141
254
  * @param resource Resource name (default: 'auth')
142
255
  * @param additionalEndpoints Additional endpoints to add to the API definition
143
256
  * @returns Authentication REST API definition
144
257
  * @template AdditionalTokenPayload Type of additional token payload
145
258
  * @template AuthenticationData Type of additional authentication data
146
- * @template AdditionalInitSecretResetData Type of additional secret reset data
259
+ * @template AdditionalInitPasswordResetData Type of additional password reset data
147
260
  * @template AdditionalEndpoints Type of additional endpoints
148
261
  */
149
- export declare function getAuthenticationApiDefinition<AdditionalTokenPayload extends Record, AuthenticationData, AdditionalInitSecretResetData, AdditionalEndpoints extends ApiEndpointsDefinition>(additionalTokenPayloadSchema: ObjectSchemaOrType<AdditionalTokenPayload>, authenticationDataSchema: SchemaTestable<AuthenticationData>, initSecretResetDataSchema: SchemaTestable<AdditionalInitSecretResetData>, resource?: string, additionalEndpoints?: AdditionalEndpoints): {
262
+ export declare function getAuthenticationApiDefinition<AdditionalTokenPayload extends Record, AuthenticationData, AdditionalInitPasswordResetData, AdditionalEndpoints extends ApiEndpointsDefinition>(additionalTokenPayloadSchema: ObjectSchemaOrType<AdditionalTokenPayload>, authenticationDataSchema: SchemaTestable<AuthenticationData>, initPasswordResetDataSchema: SchemaTestable<AdditionalInitPasswordResetData>, resource?: string, additionalEndpoints?: AdditionalEndpoints): {
150
263
  resource: string;
151
264
  endpoints: {
152
265
  login: {
@@ -155,16 +268,115 @@ export declare function getAuthenticationApiDefinition<AdditionalTokenPayload ex
155
268
  parameters: ObjectSchema<{
156
269
  readonly tenantId: string | undefined;
157
270
  readonly subject: string;
158
- readonly secret: string;
271
+ readonly password: string;
159
272
  readonly remember: boolean;
160
273
  readonly data: AuthenticationData;
161
274
  }>;
162
- result: ObjectSchema<TokenPayload<AdditionalTokenPayload>>;
275
+ result: import("../schema/index.js").UnionSchema<[ObjectSchema<{
276
+ type: "success";
277
+ result: import("../schema/schema.js").SchemaOutput<ObjectSchema<TokenPayload<AdditionalTokenPayload>>>;
278
+ lowRecoveryCodesWarning?: boolean | undefined;
279
+ }>, ObjectSchema<{
280
+ type: "totp";
281
+ challengeToken: string;
282
+ }>]>;
163
283
  credentials: true;
164
284
  data: {
165
285
  [dontWaitForValidToken]: boolean;
166
286
  };
167
287
  };
288
+ loginVerifyTotp: {
289
+ resource: string;
290
+ method: "POST";
291
+ parameters: ObjectSchema<{
292
+ readonly challengeToken: string;
293
+ readonly token: string;
294
+ }>;
295
+ result: ObjectSchema<{
296
+ type: "success";
297
+ result: import("../schema/schema.js").SchemaOutput<ObjectSchema<TokenPayload<AdditionalTokenPayload>>>;
298
+ lowRecoveryCodesWarning?: boolean | undefined;
299
+ }>;
300
+ credentials: true;
301
+ data: {
302
+ [dontWaitForValidToken]: boolean;
303
+ };
304
+ };
305
+ loginRecovery: {
306
+ resource: string;
307
+ method: "POST";
308
+ parameters: ObjectSchema<{
309
+ challengeToken: string;
310
+ recoveryCode: string;
311
+ }>;
312
+ result: ObjectSchema<{
313
+ type: "success";
314
+ result: import("../schema/schema.js").SchemaOutput<ObjectSchema<TokenPayload<AdditionalTokenPayload>>>;
315
+ lowRecoveryCodesWarning?: boolean | undefined;
316
+ }>;
317
+ credentials: true;
318
+ data: {
319
+ [dontWaitForValidToken]: boolean;
320
+ };
321
+ };
322
+ initEnrollTotp: {
323
+ resource: string;
324
+ method: "POST";
325
+ result: ObjectSchema<{
326
+ secret: string;
327
+ uri: string;
328
+ }>;
329
+ credentials: true;
330
+ };
331
+ completeEnrollTotp: {
332
+ resource: string;
333
+ method: "POST";
334
+ parameters: ObjectSchema<{
335
+ token: string;
336
+ }>;
337
+ result: ObjectSchema<{
338
+ recoveryCodes: string[];
339
+ }>;
340
+ credentials: true;
341
+ };
342
+ disableTotp: {
343
+ resource: string;
344
+ method: "POST";
345
+ parameters: ObjectSchema<{
346
+ token: string;
347
+ }>;
348
+ result: import("../schema/index.js").LiteralSchema<"ok">;
349
+ credentials: true;
350
+ };
351
+ disableTotpWithRecoveryCode: {
352
+ resource: string;
353
+ method: "POST";
354
+ parameters: ObjectSchema<{
355
+ recoveryCode: string;
356
+ }>;
357
+ result: import("../schema/index.js").LiteralSchema<"ok">;
358
+ credentials: true;
359
+ };
360
+ regenerateRecoveryCodes: {
361
+ resource: string;
362
+ method: "POST";
363
+ parameters: ObjectSchema<{
364
+ token: string;
365
+ invalidateOtherSessions?: boolean | undefined;
366
+ }>;
367
+ result: ObjectSchema<{
368
+ recoveryCodes: string[];
369
+ }>;
370
+ credentials: true;
371
+ };
372
+ getTotpStatus: {
373
+ resource: string;
374
+ method: "GET";
375
+ result: ObjectSchema<{
376
+ active: boolean;
377
+ }>;
378
+ credentials: true;
379
+ };
168
380
  refresh: {
169
381
  resource: string;
170
382
  method: "POST";
@@ -211,44 +423,42 @@ export declare function getAuthenticationApiDefinition<AdditionalTokenPayload ex
211
423
  [dontWaitForValidToken]: boolean;
212
424
  };
213
425
  };
214
- changeSecret: {
426
+ changePassword: {
215
427
  resource: string;
216
428
  method: "POST";
217
429
  parameters: ObjectSchema<{
218
- readonly tenantId: string | undefined;
219
- readonly subject: string;
220
- readonly currentSecret: string;
221
- readonly newSecret: string;
430
+ currentPassword: string;
431
+ newPassword: string;
222
432
  }>;
223
433
  result: import("../schema/index.js").LiteralSchema<"ok">;
224
434
  credentials: true;
225
435
  };
226
- initSecretReset: {
436
+ initPasswordReset: {
227
437
  resource: string;
228
438
  method: "POST";
229
439
  parameters: ObjectSchema<{
230
440
  readonly tenantId: string | undefined;
231
441
  readonly subject: string;
232
- readonly data: AdditionalInitSecretResetData;
442
+ readonly data: AdditionalInitPasswordResetData;
233
443
  }>;
234
444
  result: import("../schema/index.js").LiteralSchema<"ok">;
235
445
  };
236
- resetSecret: {
446
+ resetPassword: {
237
447
  resource: string;
238
448
  method: "POST";
239
449
  parameters: ObjectSchema<{
240
450
  token: string;
241
- newSecret: string;
451
+ newPassword: string;
242
452
  }>;
243
453
  result: import("../schema/index.js").LiteralSchema<"ok">;
244
454
  };
245
- checkSecret: {
455
+ checkPassword: {
246
456
  resource: string;
247
457
  method: "POST";
248
458
  parameters: ObjectSchema<{
249
- secret: string;
459
+ password: string;
250
460
  }>;
251
- result: typeof SecretCheckResult;
461
+ result: typeof PasswordCheckResult;
252
462
  };
253
463
  timestamp: {
254
464
  resource: string;
@@ -257,35 +467,150 @@ export declare function getAuthenticationApiDefinition<AdditionalTokenPayload ex
257
467
  [dontWaitForValidToken]: boolean;
258
468
  };
259
469
  };
470
+ listSessions: {
471
+ resource: string;
472
+ method: "GET";
473
+ result: import("../schema/index.js").ArraySchema<{
474
+ id: import("../orm/types.js").IsPrimaryKey<import("../orm/types.js").HasDefault<import("../orm/types.js").Uuid>>;
475
+ begin: import("../orm/types.js").Timestamp;
476
+ end: import("../orm/types.js").Timestamp;
477
+ }>;
478
+ credentials: true;
479
+ };
480
+ invalidateAllOtherSessions: {
481
+ resource: string;
482
+ method: "POST";
483
+ result: import("../schema/index.js").LiteralSchema<"ok">;
484
+ credentials: true;
485
+ };
260
486
  };
261
487
  };
262
488
  /**
263
489
  * Get authentication REST API endpoints definition
264
490
  * @param additionalTokenPayloadSchema Schema for additional token payload
265
491
  * @param authenticationDataSchema Schema for additional authentication data
266
- * @param additionalInitSecretResetDataSchema Schema for additional secret reset data
492
+ * @param additionalInitPasswordResetDataSchema Schema for additional password reset data
267
493
  * @returns Authentication REST API endpoints definition
268
494
  * @template AdditionalTokenPayload Type of additional token payload
269
495
  * @template AuthenticationData Type of additional authentication data
270
- * @template AdditionalInitSecretResetData Type of additional secret reset data
496
+ * @template AdditionalInitPasswordResetData Type of additional password reset data
271
497
  */
272
- export declare function getAuthenticationApiEndpointsDefinition<AdditionalTokenPayload extends Record, AuthenticationData, AdditionalInitSecretResetData>(additionalTokenPayloadSchema: ObjectSchemaOrType<AdditionalTokenPayload>, authenticationDataSchema: SchemaTestable<AuthenticationData>, additionalInitSecretResetDataSchema: SchemaTestable<AdditionalInitSecretResetData>): {
498
+ export declare function getAuthenticationApiEndpointsDefinition<AdditionalTokenPayload extends Record, AuthenticationData, AdditionalInitPasswordResetData>(additionalTokenPayloadSchema: ObjectSchemaOrType<AdditionalTokenPayload>, authenticationDataSchema: SchemaTestable<AuthenticationData>, additionalInitPasswordResetDataSchema: SchemaTestable<AdditionalInitPasswordResetData>): {
273
499
  login: {
274
500
  resource: string;
275
501
  method: "POST";
276
502
  parameters: ObjectSchema<{
277
503
  readonly tenantId: string | undefined;
278
504
  readonly subject: string;
279
- readonly secret: string;
505
+ readonly password: string;
280
506
  readonly remember: boolean;
281
507
  readonly data: AuthenticationData;
282
508
  }>;
283
- result: ObjectSchema<TokenPayload<AdditionalTokenPayload>>;
509
+ result: import("../schema/index.js").UnionSchema<[ObjectSchema<{
510
+ type: "success";
511
+ result: import("../schema/schema.js").SchemaOutput<ObjectSchema<TokenPayload<AdditionalTokenPayload>>>;
512
+ lowRecoveryCodesWarning?: boolean | undefined;
513
+ }>, ObjectSchema<{
514
+ type: "totp";
515
+ challengeToken: string;
516
+ }>]>;
517
+ credentials: true;
518
+ data: {
519
+ [dontWaitForValidToken]: boolean;
520
+ };
521
+ };
522
+ loginVerifyTotp: {
523
+ resource: string;
524
+ method: "POST";
525
+ parameters: ObjectSchema<{
526
+ readonly challengeToken: string;
527
+ readonly token: string;
528
+ }>;
529
+ result: ObjectSchema<{
530
+ type: "success";
531
+ result: import("../schema/schema.js").SchemaOutput<ObjectSchema<TokenPayload<AdditionalTokenPayload>>>;
532
+ lowRecoveryCodesWarning?: boolean | undefined;
533
+ }>;
284
534
  credentials: true;
285
535
  data: {
286
536
  [dontWaitForValidToken]: boolean;
287
537
  };
288
538
  };
539
+ loginRecovery: {
540
+ resource: string;
541
+ method: "POST";
542
+ parameters: ObjectSchema<{
543
+ challengeToken: string;
544
+ recoveryCode: string;
545
+ }>;
546
+ result: ObjectSchema<{
547
+ type: "success";
548
+ result: import("../schema/schema.js").SchemaOutput<ObjectSchema<TokenPayload<AdditionalTokenPayload>>>;
549
+ lowRecoveryCodesWarning?: boolean | undefined;
550
+ }>;
551
+ credentials: true;
552
+ data: {
553
+ [dontWaitForValidToken]: boolean;
554
+ };
555
+ };
556
+ initEnrollTotp: {
557
+ resource: string;
558
+ method: "POST";
559
+ result: ObjectSchema<{
560
+ secret: string;
561
+ uri: string;
562
+ }>;
563
+ credentials: true;
564
+ };
565
+ completeEnrollTotp: {
566
+ resource: string;
567
+ method: "POST";
568
+ parameters: ObjectSchema<{
569
+ token: string;
570
+ }>;
571
+ result: ObjectSchema<{
572
+ recoveryCodes: string[];
573
+ }>;
574
+ credentials: true;
575
+ };
576
+ disableTotp: {
577
+ resource: string;
578
+ method: "POST";
579
+ parameters: ObjectSchema<{
580
+ token: string;
581
+ }>;
582
+ result: import("../schema/index.js").LiteralSchema<"ok">;
583
+ credentials: true;
584
+ };
585
+ disableTotpWithRecoveryCode: {
586
+ resource: string;
587
+ method: "POST";
588
+ parameters: ObjectSchema<{
589
+ recoveryCode: string;
590
+ }>;
591
+ result: import("../schema/index.js").LiteralSchema<"ok">;
592
+ credentials: true;
593
+ };
594
+ regenerateRecoveryCodes: {
595
+ resource: string;
596
+ method: "POST";
597
+ parameters: ObjectSchema<{
598
+ token: string;
599
+ invalidateOtherSessions?: boolean | undefined;
600
+ }>;
601
+ result: ObjectSchema<{
602
+ recoveryCodes: string[];
603
+ }>;
604
+ credentials: true;
605
+ };
606
+ getTotpStatus: {
607
+ resource: string;
608
+ method: "GET";
609
+ result: ObjectSchema<{
610
+ active: boolean;
611
+ }>;
612
+ credentials: true;
613
+ };
289
614
  refresh: {
290
615
  resource: string;
291
616
  method: "POST";
@@ -332,44 +657,42 @@ export declare function getAuthenticationApiEndpointsDefinition<AdditionalTokenP
332
657
  [dontWaitForValidToken]: boolean;
333
658
  };
334
659
  };
335
- changeSecret: {
660
+ changePassword: {
336
661
  resource: string;
337
662
  method: "POST";
338
663
  parameters: ObjectSchema<{
339
- readonly tenantId: string | undefined;
340
- readonly subject: string;
341
- readonly currentSecret: string;
342
- readonly newSecret: string;
664
+ currentPassword: string;
665
+ newPassword: string;
343
666
  }>;
344
667
  result: import("../schema/index.js").LiteralSchema<"ok">;
345
668
  credentials: true;
346
669
  };
347
- initSecretReset: {
670
+ initPasswordReset: {
348
671
  resource: string;
349
672
  method: "POST";
350
673
  parameters: ObjectSchema<{
351
674
  readonly tenantId: string | undefined;
352
675
  readonly subject: string;
353
- readonly data: AdditionalInitSecretResetData;
676
+ readonly data: AdditionalInitPasswordResetData;
354
677
  }>;
355
678
  result: import("../schema/index.js").LiteralSchema<"ok">;
356
679
  };
357
- resetSecret: {
680
+ resetPassword: {
358
681
  resource: string;
359
682
  method: "POST";
360
683
  parameters: ObjectSchema<{
361
684
  token: string;
362
- newSecret: string;
685
+ newPassword: string;
363
686
  }>;
364
687
  result: import("../schema/index.js").LiteralSchema<"ok">;
365
688
  };
366
- checkSecret: {
689
+ checkPassword: {
367
690
  resource: string;
368
691
  method: "POST";
369
692
  parameters: ObjectSchema<{
370
- secret: string;
693
+ password: string;
371
694
  }>;
372
- result: typeof SecretCheckResult;
695
+ result: typeof PasswordCheckResult;
373
696
  };
374
697
  timestamp: {
375
698
  resource: string;
@@ -378,5 +701,21 @@ export declare function getAuthenticationApiEndpointsDefinition<AdditionalTokenP
378
701
  [dontWaitForValidToken]: boolean;
379
702
  };
380
703
  };
704
+ listSessions: {
705
+ resource: string;
706
+ method: "GET";
707
+ result: import("../schema/index.js").ArraySchema<{
708
+ id: import("../orm/types.js").IsPrimaryKey<import("../orm/types.js").HasDefault<import("../orm/types.js").Uuid>>;
709
+ begin: import("../orm/types.js").Timestamp;
710
+ end: import("../orm/types.js").Timestamp;
711
+ }>;
712
+ credentials: true;
713
+ };
714
+ invalidateAllOtherSessions: {
715
+ resource: string;
716
+ method: "POST";
717
+ result: import("../schema/index.js").LiteralSchema<"ok">;
718
+ credentials: true;
719
+ };
381
720
  };
382
721
  export {};