@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,55 +0,0 @@
1
- import type { SecretCheckResult } from '../models/secret-check-result.model.js';
2
- export type SecretTestResult = {
3
- success: true;
4
- reason?: undefined;
5
- } | {
6
- success: false;
7
- reason: string;
8
- };
9
- export declare abstract class AuthenticationSecretRequirementsValidator {
10
- /**
11
- * Checks the secret against the requirements.
12
- * @param secret The secret to check.
13
- * @returns The result of the check.
14
- */
15
- abstract checkSecretRequirements(secret: string): Promise<SecretCheckResult>;
16
- /**
17
- * Tests the secret against the requirements.
18
- * @param secret The secret to test.
19
- * @returns The result of the test.
20
- */
21
- abstract testSecretRequirements(secret: string): Promise<SecretTestResult>;
22
- /**
23
- * Validates the secret against the requirements. Throws an error if the requirements are not met.
24
- * @param secret The secret to validate.
25
- * @throws {SecretRequirementsError} If the secret does not meet the requirements.
26
- */
27
- abstract validateSecretRequirements(secret: string): Promise<void>;
28
- }
29
- /**
30
- * Default validator for secret requirements.
31
- *
32
- * Checks for pwned passwords and password strength.
33
- * - Pwned passwords are not allowed.
34
- * - Password strength must be at least 'medium'.
35
- */
36
- export declare class DefaultAuthenticationSecretRequirementsValidator extends AuthenticationSecretRequirementsValidator {
37
- /**
38
- * Checks the secret against the requirements.
39
- * @param secret The secret to check.
40
- * @returns The result of the check.
41
- */
42
- checkSecretRequirements(secret: string): Promise<SecretCheckResult>;
43
- /**
44
- * Tests the secret against the requirements.
45
- * @param secret The secret to test.
46
- * @returns The result of the test.
47
- */
48
- testSecretRequirements(secret: string): Promise<SecretTestResult>;
49
- /**
50
- * Validates the secret against the requirements. Throws an error if the requirements are not met.
51
- * @param secret The secret to validate.
52
- * @throws {SecretRequirementsError} If the secret does not meet the requirements.
53
- */
54
- validateSecretRequirements(secret: string): Promise<void>;
55
- }
@@ -1,13 +0,0 @@
1
- import { describe, expect, test } from 'vitest';
2
- import { runInInjectionContext } from '../../injector/index.js';
3
- import { setupIntegrationTest } from '../../testing/index.js';
4
- import { DefaultAuthenticationAncillaryService } from './authentication.test-ancillary-service.js';
5
- describe('AuthenticationAncillaryService', () => {
6
- test('default implementation should be abstract or have defaults', async () => {
7
- const { injector } = await setupIntegrationTest({ modules: { authentication: true } });
8
- await runInInjectionContext(injector, async () => {
9
- const service = await injector.resolveAsync(DefaultAuthenticationAncillaryService);
10
- expect(await service.canImpersonate({}, {}, {})).toBe(true);
11
- });
12
- });
13
- });
@@ -1,29 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { SecretRequirementsError } from '../errors/secret-requirements.error.js';
3
- import { DefaultAuthenticationSecretRequirementsValidator } from '../server/authentication-secret-requirements.validator.js';
4
- describe('DefaultAuthenticationSecretRequirementsValidator', () => {
5
- const validator = new DefaultAuthenticationSecretRequirementsValidator();
6
- it('should return success when password is strong and not pwned', async () => {
7
- // A very long random string is unlikely to be pwned and will be strong
8
- const result = await validator.testSecretRequirements('Very-Strong-And-Long-Password-2026!@#$%^&*()');
9
- expect(result.success).toBe(true);
10
- });
11
- it('should return failure when password is pwned', async () => {
12
- // "password" is definitely pwned
13
- const result = await validator.testSecretRequirements('password');
14
- expect(result.success).toBe(false);
15
- expect(result.reason).toContain('exposed in data breach');
16
- });
17
- it('should return failure when password is too weak', async () => {
18
- // "abc" is too weak (and likely pwned)
19
- const result = await validator.testSecretRequirements('abc');
20
- expect(result.success).toBe(false);
21
- expect(result.reason).toBeDefined();
22
- });
23
- it('should throw SecretRequirementsError on validation failure', async () => {
24
- await expect(validator.validateSecretRequirements('abc')).rejects.toThrow(SecretRequirementsError);
25
- });
26
- it('should not throw on validation success', async () => {
27
- await expect(validator.validateSecretRequirements('Very-Strong-And-Long-Password-2026!@#$%^&*()')).resolves.not.toThrow();
28
- });
29
- });
@@ -1,14 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { SecretRequirementsError } from '../errors/secret-requirements.error.js';
3
- describe('SecretRequirementsError', () => {
4
- it('should create an error with the given message', () => {
5
- const message = 'Password is too weak.';
6
- const error = new SecretRequirementsError(message);
7
- expect(error.message).toBe(message);
8
- expect(error.name).toBe('SecretRequirementsError');
9
- });
10
- it('should have the correct name', () => {
11
- const error = new SecretRequirementsError('any message');
12
- expect(error.name).toBe('SecretRequirementsError');
13
- });
14
- });
@@ -1,12 +0,0 @@
1
- CREATE OR REPLACE FUNCTION mail.map_errors_to_jsonb(text_array text[])
2
- RETURNS jsonb AS $$
3
- SELECT COALESCE(jsonb_agg(jsonb_build_object('message', err)), '[]'::jsonb)
4
- FROM unnest(text_array) AS err;
5
- $$ LANGUAGE sql IMMUTABLE;
6
-
7
- ALTER TABLE "mail"."log"
8
- ALTER COLUMN "errors" SET DATA TYPE jsonb
9
- USING mail.map_errors_to_jsonb("errors");
10
-
11
- ALTER TABLE "mail"."log" ALTER COLUMN "errors" SET NOT NULL;
12
- DROP FUNCTION mail.map_errors_to_jsonb(text[]);
@@ -1,69 +0,0 @@
1
- {
2
- "id": "c74f667f-8acf-42e7-ad58-3aea45df3743",
3
- "prevId": "0c48afa4-9ab0-4965-a93e-05a6c1b88e58",
4
- "version": "7",
5
- "dialect": "postgresql",
6
- "tables": {
7
- "mail.log": {
8
- "name": "log",
9
- "schema": "mail",
10
- "columns": {
11
- "id": {
12
- "name": "id",
13
- "type": "uuid",
14
- "primaryKey": true,
15
- "notNull": true,
16
- "default": "gen_random_uuid()"
17
- },
18
- "timestamp": {
19
- "name": "timestamp",
20
- "type": "timestamp with time zone",
21
- "primaryKey": false,
22
- "notNull": true
23
- },
24
- "template": {
25
- "name": "template",
26
- "type": "text",
27
- "primaryKey": false,
28
- "notNull": false
29
- },
30
- "data": {
31
- "name": "data",
32
- "type": "jsonb",
33
- "primaryKey": false,
34
- "notNull": true
35
- },
36
- "send_result": {
37
- "name": "send_result",
38
- "type": "jsonb",
39
- "primaryKey": false,
40
- "notNull": false
41
- },
42
- "errors": {
43
- "name": "errors",
44
- "type": "jsonb",
45
- "primaryKey": false,
46
- "notNull": true
47
- }
48
- },
49
- "indexes": {},
50
- "foreignKeys": {},
51
- "compositePrimaryKeys": {},
52
- "uniqueConstraints": {},
53
- "policies": {},
54
- "checkConstraints": {},
55
- "isRLSEnabled": false
56
- }
57
- },
58
- "enums": {},
59
- "schemas": {},
60
- "sequences": {},
61
- "roles": {},
62
- "policies": {},
63
- "views": {},
64
- "_meta": {
65
- "columns": {},
66
- "schemas": {},
67
- "tables": {}
68
- }
69
- }
@@ -1 +0,0 @@
1
- export declare const ENCRYPTION_SECRET: import("../../injector/token.js").InjectionToken<Uint8Array<ArrayBuffer>, never>;
@@ -1,2 +0,0 @@
1
- import { injectionToken } from '../../injector/token.js';
2
- export const ENCRYPTION_SECRET = injectionToken('EncryptionSecret');
@@ -1,16 +0,0 @@
1
- ALTER TABLE "task_queue"."task" RENAME COLUMN "error" TO "errors";--> statement-breakpoint
2
- ALTER TABLE "task_queue"."task" ALTER COLUMN "errors" SET DATA TYPE jsonb USING (
3
- CASE
4
- WHEN "errors" IS NULL THEN '[]'::jsonb
5
- ELSE jsonb_build_array("errors")
6
- END
7
- );--> statement-breakpoint
8
- ALTER TABLE "task_queue"."task" ALTER COLUMN "errors" SET NOT NULL;--> statement-breakpoint
9
- ALTER TABLE "task_queue"."task_archive" RENAME COLUMN "error" TO "errors";--> statement-breakpoint
10
- ALTER TABLE "task_queue"."task_archive" ALTER COLUMN "errors" SET DATA TYPE jsonb USING (
11
- CASE
12
- WHEN "errors" IS NULL THEN '[]'::jsonb
13
- ELSE jsonb_build_array("errors")
14
- END
15
- );--> statement-breakpoint
16
- ALTER TABLE "task_queue"."task_archive" ALTER COLUMN "errors" SET NOT NULL;