@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
@@ -1,5 +1,5 @@
1
1
  {
2
- "id": "aea0fdc2-b60d-421c-b0e5-781cc7bff495",
2
+ "id": "76d222d0-6265-4529-94f0-35e5e608e4ef",
3
3
  "prevId": "00000000-0000-0000-0000-000000000000",
4
4
  "version": "7",
5
5
  "dialect": "postgresql",
@@ -13,7 +13,7 @@
13
13
  "type": "uuid",
14
14
  "primaryKey": false,
15
15
  "notNull": true,
16
- "default": "gen_random_uuid()"
16
+ "default": "uuidv7()"
17
17
  },
18
18
  "tenant_id": {
19
19
  "name": "tenant_id",
@@ -168,7 +168,7 @@
168
168
  "type": "uuid",
169
169
  "primaryKey": false,
170
170
  "notNull": true,
171
- "default": "gen_random_uuid()"
171
+ "default": "uuidv7()"
172
172
  },
173
173
  "tenant_id": {
174
174
  "name": "tenant_id",
@@ -287,7 +287,7 @@
287
287
  "type": "uuid",
288
288
  "primaryKey": false,
289
289
  "notNull": true,
290
- "default": "gen_random_uuid()"
290
+ "default": "uuidv7()"
291
291
  },
292
292
  "tenant_id": {
293
293
  "name": "tenant_id",
@@ -391,7 +391,7 @@
391
391
  "type": "uuid",
392
392
  "primaryKey": false,
393
393
  "notNull": true,
394
- "default": "gen_random_uuid()"
394
+ "default": "uuidv7()"
395
395
  },
396
396
  "tenant_id": {
397
397
  "name": "tenant_id",
@@ -509,7 +509,7 @@
509
509
  "type": "uuid",
510
510
  "primaryKey": false,
511
511
  "notNull": true,
512
- "default": "gen_random_uuid()"
512
+ "default": "uuidv7()"
513
513
  },
514
514
  "tenant_id": {
515
515
  "name": "tenant_id",
@@ -597,7 +597,7 @@
597
597
  "type": "uuid",
598
598
  "primaryKey": false,
599
599
  "notNull": true,
600
- "default": "gen_random_uuid()"
600
+ "default": "uuidv7()"
601
601
  },
602
602
  "tenant_id": {
603
603
  "name": "tenant_id",
@@ -739,7 +739,7 @@
739
739
  "type": "uuid",
740
740
  "primaryKey": false,
741
741
  "notNull": true,
742
- "default": "gen_random_uuid()"
742
+ "default": "uuidv7()"
743
743
  },
744
744
  "tenant_id": {
745
745
  "name": "tenant_id",
@@ -840,7 +840,7 @@
840
840
  "type": "uuid",
841
841
  "primaryKey": false,
842
842
  "notNull": true,
843
- "default": "gen_random_uuid()"
843
+ "default": "uuidv7()"
844
844
  },
845
845
  "tenant_id": {
846
846
  "name": "tenant_id",
@@ -995,7 +995,7 @@
995
995
  "type": "uuid",
996
996
  "primaryKey": false,
997
997
  "notNull": true,
998
- "default": "gen_random_uuid()"
998
+ "default": "uuidv7()"
999
999
  },
1000
1000
  "tenant_id": {
1001
1001
  "name": "tenant_id",
@@ -1158,7 +1158,7 @@
1158
1158
  "type": "uuid",
1159
1159
  "primaryKey": false,
1160
1160
  "notNull": true,
1161
- "default": "gen_random_uuid()"
1161
+ "default": "uuidv7()"
1162
1162
  },
1163
1163
  "tenant_id": {
1164
1164
  "name": "tenant_id",
@@ -1294,7 +1294,7 @@
1294
1294
  "type": "uuid",
1295
1295
  "primaryKey": false,
1296
1296
  "notNull": true,
1297
- "default": "gen_random_uuid()"
1297
+ "default": "uuidv7()"
1298
1298
  },
1299
1299
  "tenant_id": {
1300
1300
  "name": "tenant_id",
@@ -1410,7 +1410,7 @@
1410
1410
  "type": "uuid",
1411
1411
  "primaryKey": false,
1412
1412
  "notNull": true,
1413
- "default": "gen_random_uuid()"
1413
+ "default": "uuidv7()"
1414
1414
  },
1415
1415
  "tenant_id": {
1416
1416
  "name": "tenant_id",
@@ -1487,7 +1487,7 @@
1487
1487
  "type": "uuid",
1488
1488
  "primaryKey": false,
1489
1489
  "notNull": true,
1490
- "default": "gen_random_uuid()"
1490
+ "default": "uuidv7()"
1491
1491
  },
1492
1492
  "tenant_id": {
1493
1493
  "name": "tenant_id",
@@ -1567,7 +1567,7 @@
1567
1567
  "type": "uuid",
1568
1568
  "primaryKey": false,
1569
1569
  "notNull": true,
1570
- "default": "gen_random_uuid()"
1570
+ "default": "uuidv7()"
1571
1571
  },
1572
1572
  "tenant_id": {
1573
1573
  "name": "tenant_id",
@@ -1687,7 +1687,7 @@
1687
1687
  "type": "uuid",
1688
1688
  "primaryKey": false,
1689
1689
  "notNull": true,
1690
- "default": "gen_random_uuid()"
1690
+ "default": "uuidv7()"
1691
1691
  },
1692
1692
  "tenant_id": {
1693
1693
  "name": "tenant_id",
@@ -1805,7 +1805,7 @@
1805
1805
  "type": "uuid",
1806
1806
  "primaryKey": false,
1807
1807
  "notNull": true,
1808
- "default": "gen_random_uuid()"
1808
+ "default": "uuidv7()"
1809
1809
  },
1810
1810
  "tenant_id": {
1811
1811
  "name": "tenant_id",
@@ -1925,7 +1925,7 @@
1925
1925
  "type": "uuid",
1926
1926
  "primaryKey": false,
1927
1927
  "notNull": true,
1928
- "default": "gen_random_uuid()"
1928
+ "default": "uuidv7()"
1929
1929
  },
1930
1930
  "tenant_id": {
1931
1931
  "name": "tenant_id",
@@ -2061,7 +2061,7 @@
2061
2061
  "type": "uuid",
2062
2062
  "primaryKey": false,
2063
2063
  "notNull": true,
2064
- "default": "gen_random_uuid()"
2064
+ "default": "uuidv7()"
2065
2065
  },
2066
2066
  "tenant_id": {
2067
2067
  "name": "tenant_id",
@@ -2150,7 +2150,7 @@
2150
2150
  "type": "uuid",
2151
2151
  "primaryKey": false,
2152
2152
  "notNull": true,
2153
- "default": "gen_random_uuid()"
2153
+ "default": "uuidv7()"
2154
2154
  },
2155
2155
  "tenant_id": {
2156
2156
  "name": "tenant_id",
@@ -2302,7 +2302,7 @@
2302
2302
  "type": "uuid",
2303
2303
  "primaryKey": false,
2304
2304
  "notNull": true,
2305
- "default": "gen_random_uuid()"
2305
+ "default": "uuidv7()"
2306
2306
  },
2307
2307
  "tenant_id": {
2308
2308
  "name": "tenant_id",
@@ -2422,7 +2422,7 @@
2422
2422
  "type": "uuid",
2423
2423
  "primaryKey": false,
2424
2424
  "notNull": true,
2425
- "default": "gen_random_uuid()"
2425
+ "default": "uuidv7()"
2426
2426
  },
2427
2427
  "tenant_id": {
2428
2428
  "name": "tenant_id",
@@ -5,8 +5,8 @@
5
5
  {
6
6
  "idx": 0,
7
7
  "version": "7",
8
- "when": 1770841279177,
9
- "tag": "0000_curious_nighthawk",
8
+ "when": 1774646422189,
9
+ "tag": "0000_sharp_scream",
10
10
  "breakpoints": true
11
11
  }
12
12
  ]
@@ -6,6 +6,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
6
6
  };
7
7
  import sharp, {} from 'sharp';
8
8
  import { match } from 'ts-pattern';
9
+ import { digest } from '../../../cryptography/index.js';
9
10
  import { ForbiddenError } from '../../../errors/forbidden.error.js';
10
11
  import { NotImplementedError } from '../../../errors/not-implemented.error.js';
11
12
  import { getMimeType, getMimeTypeExtensions, mimeTypes } from '../../../file/index.js';
@@ -15,7 +16,6 @@ import { Transactional } from '../../../orm/server/index.js';
15
16
  import { pdfToImage } from '../../../pdf/index.js';
16
17
  import { Alphabet } from '../../../utils/alphabet.js';
17
18
  import { encodeDataUrl } from '../../../utils/base64.js';
18
- import { digest } from '../../../utils/cryptography.js';
19
19
  import { currentTimestamp } from '../../../utils/date-time.js';
20
20
  import { getRandomString } from '../../../utils/random.js';
21
21
  import { readableStreamFromPromise, readBinaryStream } from '../../../utils/stream/index.js';
@@ -1,4 +1,4 @@
1
- import type { SecretRequirementsError } from '../authentication/index.js';
1
+ import type { PasswordRequirementsError } from '../authentication/index.js';
2
2
  import { type HttpError, HttpErrorReason } from '../http/http.error.js';
3
3
  import { type Localization, type LocalizeItem } from '../text/localization.service.js';
4
4
  import type { Enumeration } from '../types/index.js';
@@ -43,7 +43,7 @@ type TstdlErrors = [
43
43
  typeof TimeoutError,
44
44
  typeof UnauthorizedError,
45
45
  typeof HttpError,
46
- typeof SecretRequirementsError
46
+ typeof PasswordRequirementsError
47
47
  ];
48
48
  export declare const tstdlErrorsLocalizationKeys: import("../text/localization.service.js").ProxyLocalizationKeys<{
49
49
  errors: ErrorsLocalizationEntries<CustomErrorStatic<CustomError>[]>;
@@ -61,7 +61,7 @@ export const germanTstdlErrorsLocalization = {
61
61
  : 'Verbindungsfehler'),
62
62
  message: getHttpErrorMessage,
63
63
  },
64
- SecretRequirementsError: {
64
+ PasswordRequirementsError: {
65
65
  header: 'Passwort zu schwach',
66
66
  message: getErrorMessage,
67
67
  },
@@ -140,7 +140,7 @@ export const englishTstdlErrorsLocalization = {
140
140
  : 'Connection Error'),
141
141
  message: getHttpErrorMessage,
142
142
  },
143
- SecretRequirementsError: {
143
+ PasswordRequirementsError: {
144
144
  header: 'Password Is Too Weak',
145
145
  message: getErrorMessage,
146
146
  },
package/errors/index.d.ts CHANGED
@@ -20,6 +20,7 @@ export * from './not-found.error.js';
20
20
  export * from './not-implemented.error.js';
21
21
  export * from './not-supported.error.js';
22
22
  export * from './timeout.error.js';
23
+ export * from './too-many-requests.error.js';
23
24
  export * from './unauthorized.error.js';
24
25
  export * from './unsupported-media-type.error.js';
25
26
  export * from './utils.js';
package/errors/index.js CHANGED
@@ -20,6 +20,7 @@ export * from './not-found.error.js';
20
20
  export * from './not-implemented.error.js';
21
21
  export * from './not-supported.error.js';
22
22
  export * from './timeout.error.js';
23
+ export * from './too-many-requests.error.js';
23
24
  export * from './unauthorized.error.js';
24
25
  export * from './unsupported-media-type.error.js';
25
26
  export * from './utils.js';
@@ -0,0 +1,5 @@
1
+ import { CustomError } from './custom.error.js';
2
+ export declare class TooManyRequestsError extends CustomError {
3
+ static readonly errorName = "TooManyRequestsError";
4
+ constructor(message?: string);
5
+ }
@@ -0,0 +1,7 @@
1
+ import { CustomError } from './custom.error.js';
2
+ export class TooManyRequestsError extends CustomError {
3
+ static errorName = 'TooManyRequestsError';
4
+ constructor(message = 'Too many requests.') {
5
+ super({ message });
6
+ }
7
+ }
@@ -6,6 +6,7 @@ import { provideInitializer, provideModule, provideSignalHandler } from '../../a
6
6
  import { AuthenticationApiClient } from '../../authentication/client/api.client.js';
7
7
  import { AuthenticationClientService, configureAuthenticationClient } from '../../authentication/client/index.js';
8
8
  import { AuthenticationApiController, AuthenticationService as AuthenticationServerService, configureAuthenticationServer } from '../../authentication/server/index.js';
9
+ import { configureSecrets } from '../../cryptography/module.js';
9
10
  import { configureUndiciHttpClientAdapter } from '../../http/client/adapters/undici.adapter.js';
10
11
  import { configureHttpClient } from '../../http/client/module.js';
11
12
  import { configureNodeHttpServer } from '../../http/server/node/module.js';
@@ -18,13 +19,13 @@ import { Agent } from 'undici';
18
19
  async function serverTest() {
19
20
  const authenticationService = await injectAsync(AuthenticationServerService);
20
21
  const subject = await authenticationService.resolveSubject({ subject: 'foobar' });
21
- await authenticationService.setCredentials(subject, 'mysuperdupersecret-fvhc54w');
22
+ await authenticationService.setPassword(subject, 'mysuperdupersecret-fvhc54w');
22
23
  }
23
24
  async function clientTest() {
24
25
  const authenticationService = inject(AuthenticationClientService);
25
26
  authenticationService.initialize();
26
27
  await timeout(250); // allow server to initialize
27
- const passwordCheckResult = await authenticationService.checkSecret('123456');
28
+ const passwordCheckResult = await authenticationService.checkPassword('123456');
28
29
  console.log({ 'password check for "123456"': passwordCheckResult });
29
30
  await authenticationService.login({ subject: 'foobar' }, 'mysuperdupersecret-fvhc54w');
30
31
  authenticationService.token$.subscribe((token) => console.log({ token }));
@@ -39,9 +40,8 @@ async function test() {
39
40
  }
40
41
  function bootstrap() {
41
42
  configureDefaultSignalsImplementation();
42
- configureAuthenticationServer({
43
- serviceOptions: { secret: 'djp0fq23576aq' },
44
- });
43
+ configureSecrets({ key: 'djp0fq23576aq' });
44
+ configureAuthenticationServer();
45
45
  configureLocalMessageBus();
46
46
  configureAuthenticationClient({
47
47
  authenticationApiClient: AuthenticationApiClient,
@@ -15,6 +15,7 @@ import { Application } from '../../application/application.js';
15
15
  import { provideInitializer, provideModule, provideSignalHandler } from '../../application/index.js';
16
16
  import { AuthenticationClientService, configureAuthenticationClient, getAuthenticationApiClient } from '../../authentication/index.js';
17
17
  import { AuthenticationAncillaryService, AuthenticationApiController, AuthenticationService as AuthenticationServerService, configureAuthenticationServer } from '../../authentication/server/index.js';
18
+ import { configureSecrets } from '../../cryptography/module.js';
18
19
  import { configureUndiciHttpClientAdapter } from '../../http/client/adapters/undici.adapter.js';
19
20
  import { configureHttpClient } from '../../http/client/module.js';
20
21
  import { configureNodeHttpServer } from '../../http/server/node/module.js';
@@ -75,7 +76,7 @@ let CustomAuthenticationAncillaryService = class CustomAuthenticationAncillarySe
75
76
  canImpersonate(_token, _subject, _authenticationData) {
76
77
  throw new Error('Method not implemented.');
77
78
  }
78
- handleInitSecretReset() {
79
+ handleInitPasswordReset() {
79
80
  // send mail
80
81
  }
81
82
  };
@@ -85,7 +86,7 @@ CustomAuthenticationAncillaryService = __decorate([
85
86
  async function serverTest() {
86
87
  const authenticationService = await injectAsync(AuthenticationServerService);
87
88
  const subject = await authenticationService.resolveSubject({ subject: 'foobar' });
88
- await authenticationService.setCredentials(subject, 'supersecret-dupidupudoo9275');
89
+ await authenticationService.setPassword(subject, 'supersecret-dupidupudoo9275');
89
90
  }
90
91
  async function clientTest(application) {
91
92
  const authenticationService = inject(AuthenticationClientService);
@@ -105,8 +106,8 @@ async function test() {
105
106
  }
106
107
  function bootstrap() {
107
108
  configureDefaultSignalsImplementation();
109
+ configureSecrets({ key: 'djp0fq23576aq' });
108
110
  configureAuthenticationServer({
109
- serviceOptions: { secret: 'djp0fq23576aq' },
110
111
  authenticationAncillaryService: CustomAuthenticationAncillaryService,
111
112
  });
112
113
  configureLocalMessageBus();
@@ -1,4 +1,4 @@
1
- import { fileTypeFromFile } from 'file-type/node';
1
+ import { fileTypeFromFile } from 'file-type';
2
2
  export async function getMimeTypeFromFile(path, fallback) {
3
3
  const result = await fileTypeFromFile(path);
4
4
  return result?.mime ?? fallback;
@@ -10,6 +10,7 @@ export declare class HttpBody {
10
10
  get available(): boolean;
11
11
  get byteLength(): number | undefined;
12
12
  constructor(body: HttpBodySource, headers: HttpHeaders);
13
+ static from(body: HttpBodySource, headers: HttpHeaders): HttpBody;
13
14
  readAsBuffer(options?: ReadBodyOptions): Promise<Uint8Array<ArrayBuffer>>;
14
15
  readAsText(options?: ReadBodyOptions): Promise<string>;
15
16
  readAsJson<T = UndefinableJson>(options?: ReadBodyOptions): Promise<T>;
package/http/http-body.js CHANGED
@@ -15,6 +15,9 @@ export class HttpBody {
15
15
  this.headers = headers;
16
16
  this.bodyAlreadyRead = false;
17
17
  }
18
+ static from(body, headers) {
19
+ return new HttpBody(body, headers);
20
+ }
18
21
  async readAsBuffer(options) {
19
22
  this.prepareBodyRead();
20
23
  return await readBodyAsBuffer(this.body, this.headers, options);
@@ -12,7 +12,6 @@ export declare class ImgproxyImageService extends ImageService implements Resolv
12
12
  #private;
13
13
  readonly endpoint: string;
14
14
  readonly [resolveArgumentType]: ImgproxyImageServiceConfig;
15
- constructor(endpoint: string, key: string, salt: string, signatureSize: number);
16
15
  getUrl(resourceUri: string, options?: ImageOptions): Promise<string>;
17
16
  }
18
17
  /**
@@ -4,33 +4,20 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
4
4
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
- var __metadata = (this && this.__metadata) || function (k, v) {
8
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
- };
10
- var __param = (this && this.__param) || function (paramIndex, decorator) {
11
- return function (target, key) { decorator(target, key, paramIndex); }
12
- };
13
- import { InjectArg, Singleton, injectionToken, resolveArgumentType } from '../../injector/index.js';
7
+ import { importHmacKey, sign } from '../../cryptography/index.js';
8
+ import { Singleton, injectArgument, injectionToken, resolveArgumentType } from '../../injector/index.js';
14
9
  import { Injector } from '../../injector/injector.js';
15
10
  import { encodeBase64Url } from '../../utils/base64.js';
16
11
  import { concatArrayBufferViews } from '../../utils/binary.js';
17
- import { importHmacKey, sign } from '../../utils/cryptography.js';
18
12
  import { decodeHex, encodeUtf8 } from '../../utils/encoding.js';
19
13
  import { isDefined } from '../../utils/type-guards.js';
20
14
  import { ImageOrigin, ImageService } from '../image-service.js';
21
15
  export const IMGPROXY_IMAGE_SERVICE_CONFIG = injectionToken('ImgproxyImageServiceConfig');
22
16
  let ImgproxyImageService = class ImgproxyImageService extends ImageService {
23
- #keyBytes;
24
- #saltBytes;
25
- #signatureSize;
26
- endpoint;
27
- constructor(endpoint, key, salt, signatureSize) {
28
- super();
29
- this.endpoint = endpoint;
30
- this.#signatureSize = signatureSize;
31
- this.#keyBytes = decodeHex(key);
32
- this.#saltBytes = decodeHex(salt);
33
- }
17
+ #keyBytes = decodeHex(injectArgument(this).key);
18
+ #saltBytes = decodeHex(injectArgument(this).salt);
19
+ #signatureSize = injectArgument(this).signatureSize;
20
+ endpoint = injectArgument(this).endpoint;
34
21
  async getUrl(resourceUri, options = {}) {
35
22
  const encodedResourceUri = encodeBase64Url(encodeUtf8(resourceUri));
36
23
  const processingOptions = [];
@@ -59,18 +46,13 @@ let ImgproxyImageService = class ImgproxyImageService extends ImageService {
59
46
  ImgproxyImageService = __decorate([
60
47
  Singleton({
61
48
  defaultArgumentProvider: (context) => context.resolve(IMGPROXY_IMAGE_SERVICE_CONFIG),
62
- }),
63
- __param(0, InjectArg('endpoint')),
64
- __param(1, InjectArg('key')),
65
- __param(2, InjectArg('salt')),
66
- __param(3, InjectArg('signatureSize')),
67
- __metadata("design:paramtypes", [String, String, String, Number])
49
+ })
68
50
  ], ImgproxyImageService);
69
51
  export { ImgproxyImageService };
70
52
  async function signString(keyBytes, saltBytes, target, size = 32) {
71
- const hmacKey = await importHmacKey('SHA-256', keyBytes, false);
53
+ const hmacKey = await importHmacKey('raw', 'SHA-256', keyBytes, false);
72
54
  const targetBytes = concatArrayBufferViews([saltBytes, encodeUtf8(target)]);
73
- const base64Signature = await sign('HMAC', hmacKey, targetBytes).toBuffer();
55
+ const base64Signature = await sign({ name: 'HMAC', hash: 'SHA-256' }, hmacKey, targetBytes).toBuffer();
74
56
  return encodeBase64Url(base64Signature.slice(0, size));
75
57
  }
76
58
  function convertOrigin(origin) {
@@ -1,5 +1,5 @@
1
1
  CREATE TABLE "key_value_store"."key_value" (
2
- "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
2
+ "id" uuid PRIMARY KEY DEFAULT uuidv7() NOT NULL,
3
3
  "module" text NOT NULL,
4
4
  "key" text NOT NULL,
5
5
  "value" jsonb NOT NULL,
@@ -1,5 +1,5 @@
1
1
  {
2
- "id": "9aad7b6a-d248-42fa-90ca-a7119748e2e4",
2
+ "id": "f49a6cf6-6c0b-43b2-b3aa-f5629cba2362",
3
3
  "prevId": "00000000-0000-0000-0000-000000000000",
4
4
  "version": "7",
5
5
  "dialect": "postgresql",
@@ -13,7 +13,7 @@
13
13
  "type": "uuid",
14
14
  "primaryKey": true,
15
15
  "notNull": true,
16
- "default": "gen_random_uuid()"
16
+ "default": "uuidv7()"
17
17
  },
18
18
  "module": {
19
19
  "name": "module",
@@ -5,8 +5,8 @@
5
5
  {
6
6
  "idx": 0,
7
7
  "version": "7",
8
- "when": 1749405256053,
9
- "tag": "0000_shocking_slipstream",
8
+ "when": 1774646422589,
9
+ "tag": "0000_moaning_calypso",
10
10
  "breakpoints": true
11
11
  }
12
12
  ]
@@ -1,5 +1,5 @@
1
1
  CREATE TABLE "lock"."lock" (
2
- "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
2
+ "id" uuid PRIMARY KEY DEFAULT uuidv7() NOT NULL,
3
3
  "resource" text NOT NULL,
4
4
  "key" text NOT NULL,
5
5
  "expiration" timestamp with time zone NOT NULL,
@@ -1,5 +1,5 @@
1
1
  {
2
- "id": "2d26f59a-2c92-4d3c-aea3-93aa48a91d5f",
2
+ "id": "922ad578-40d5-4adb-a2d5-2d37865337a3",
3
3
  "prevId": "00000000-0000-0000-0000-000000000000",
4
4
  "version": "7",
5
5
  "dialect": "postgresql",
@@ -13,7 +13,7 @@
13
13
  "type": "uuid",
14
14
  "primaryKey": true,
15
15
  "notNull": true,
16
- "default": "gen_random_uuid()"
16
+ "default": "uuidv7()"
17
17
  },
18
18
  "resource": {
19
19
  "name": "resource",
@@ -5,8 +5,8 @@
5
5
  {
6
6
  "idx": 0,
7
7
  "version": "7",
8
- "when": 1756898177209,
9
- "tag": "0000_busy_tattoo",
8
+ "when": 1774646420138,
9
+ "tag": "0000_nappy_wraith",
10
10
  "breakpoints": true
11
11
  }
12
12
  ]
@@ -4,9 +4,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
4
4
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
+ import { formatError } from '../../errors/format.js';
7
8
  import { Singleton } from '../../injector/decorators.js';
8
9
  import { enumValueName } from '../../utils/enum.js';
9
- import { formatError } from '../../errors/index.js';
10
10
  import { isNotNullOrUndefined } from '../../utils/type-guards.js';
11
11
  import { LogFormatter } from '../formatter.js';
12
12
  import { LogLevel } from '../level.js';
@@ -4,7 +4,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
4
4
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
- import { formatError } from '../../errors/index.js';
7
+ import { formatError } from '../../errors/format.js';
8
8
  import { Singleton } from '../../injector/decorators.js';
9
9
  import { supportsColoredStdout } from '../../supports.js';
10
10
  import { enumValueName } from '../../utils/enum.js';
@@ -1,8 +1,8 @@
1
1
  CREATE TABLE "mail"."log" (
2
- "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
2
+ "id" uuid PRIMARY KEY DEFAULT uuidv7() NOT NULL,
3
3
  "timestamp" timestamp with time zone NOT NULL,
4
4
  "template" text,
5
5
  "data" jsonb NOT NULL,
6
6
  "send_result" jsonb,
7
- "errors" text[]
7
+ "errors" jsonb NOT NULL
8
8
  );
@@ -1,5 +1,5 @@
1
1
  {
2
- "id": "0c48afa4-9ab0-4965-a93e-05a6c1b88e58",
2
+ "id": "140fb348-3178-4349-8dd3-4fb4974c8ca2",
3
3
  "prevId": "00000000-0000-0000-0000-000000000000",
4
4
  "version": "7",
5
5
  "dialect": "postgresql",
@@ -13,7 +13,7 @@
13
13
  "type": "uuid",
14
14
  "primaryKey": true,
15
15
  "notNull": true,
16
- "default": "gen_random_uuid()"
16
+ "default": "uuidv7()"
17
17
  },
18
18
  "timestamp": {
19
19
  "name": "timestamp",
@@ -41,9 +41,9 @@
41
41
  },
42
42
  "errors": {
43
43
  "name": "errors",
44
- "type": "text[]",
44
+ "type": "jsonb",
45
45
  "primaryKey": false,
46
- "notNull": false
46
+ "notNull": true
47
47
  }
48
48
  },
49
49
  "indexes": {},
@@ -5,15 +5,8 @@
5
5
  {
6
6
  "idx": 0,
7
7
  "version": "7",
8
- "when": 1771240070681,
9
- "tag": "0000_numerous_the_watchers",
10
- "breakpoints": true
11
- },
12
- {
13
- "idx": 1,
14
- "version": "7",
15
- "when": 1774305325041,
16
- "tag": "0001_married_tarantula",
8
+ "when": 1774646423450,
9
+ "tag": "0000_cultured_quicksilver",
17
10
  "breakpoints": true
18
11
  }
19
12
  ]