@ddd-ts-kit/redis 0.82.0 → 0.83.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.fr.md +14 -6
- package/README.md +13 -5
- package/package.json +6 -6
package/README.fr.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
[English](README.md) · **Français**
|
|
2
|
-
<!-- translation-of: README.md sha256:
|
|
2
|
+
<!-- translation-of: README.md sha256:bd773581b708e4c3 -->
|
|
3
3
|
|
|
4
4
|
# @ddd-ts-kit/redis
|
|
5
5
|
|
|
@@ -471,7 +471,7 @@ passe par heure) dépend du port `RateLimiter` du noyau et reçoit l'adaptateur
|
|
|
471
471
|
|
|
472
472
|
<!-- checked sample -->
|
|
473
473
|
```ts
|
|
474
|
-
import { Command,
|
|
474
|
+
import { Command, DomainRefusal, FixedClock, InMemoryRateLimiter, RateLimiter, type CommandHandler } from '@ddd-ts-kit/kernel';
|
|
475
475
|
|
|
476
476
|
export class RequestPasswordReset extends Command {
|
|
477
477
|
constructor(readonly accountId: string) {
|
|
@@ -479,9 +479,17 @@ export class RequestPasswordReset extends Command {
|
|
|
479
479
|
}
|
|
480
480
|
}
|
|
481
481
|
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
482
|
+
// domain/errors/codes.ts
|
|
483
|
+
export const IdentityCodes = {
|
|
484
|
+
PasswordResetsExhausted: 'PASSWORD_RESETS_EXHAUSTED',
|
|
485
|
+
} as const;
|
|
486
|
+
|
|
487
|
+
// domain/errors/password-resets-exhausted.error.ts
|
|
488
|
+
export class PasswordResetsExhausted extends DomainRefusal {
|
|
489
|
+
readonly code = IdentityCodes.PasswordResetsExhausted;
|
|
490
|
+
|
|
491
|
+
static withRetryAfter(retryAfterMs: number) {
|
|
492
|
+
return PasswordResetsExhausted.refusal('Three password resets per hour at most.', { retryAfterMs });
|
|
485
493
|
}
|
|
486
494
|
}
|
|
487
495
|
|
|
@@ -492,7 +500,7 @@ export class RequestPasswordResetHandler implements CommandHandler<RequestPasswo
|
|
|
492
500
|
const decision = await this.limiter.consume(`password-reset:${accountId}`, { limit: 3, windowMs: 3_600_000 });
|
|
493
501
|
|
|
494
502
|
if (!decision.allowed) {
|
|
495
|
-
throw
|
|
503
|
+
throw PasswordResetsExhausted.withRetryAfter(decision.retryAfterMs);
|
|
496
504
|
}
|
|
497
505
|
|
|
498
506
|
// envoyer le lien
|
package/README.md
CHANGED
|
@@ -459,7 +459,7 @@ written in the use case:
|
|
|
459
459
|
|
|
460
460
|
<!-- checked sample -->
|
|
461
461
|
```ts
|
|
462
|
-
import { Command,
|
|
462
|
+
import { Command, DomainRefusal, FixedClock, InMemoryRateLimiter, RateLimiter, type CommandHandler } from '@ddd-ts-kit/kernel';
|
|
463
463
|
|
|
464
464
|
export class RequestPasswordReset extends Command {
|
|
465
465
|
constructor(readonly accountId: string) {
|
|
@@ -467,9 +467,17 @@ export class RequestPasswordReset extends Command {
|
|
|
467
467
|
}
|
|
468
468
|
}
|
|
469
469
|
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
470
|
+
// domain/errors/codes.ts
|
|
471
|
+
export const IdentityCodes = {
|
|
472
|
+
PasswordResetsExhausted: 'PASSWORD_RESETS_EXHAUSTED',
|
|
473
|
+
} as const;
|
|
474
|
+
|
|
475
|
+
// domain/errors/password-resets-exhausted.error.ts
|
|
476
|
+
export class PasswordResetsExhausted extends DomainRefusal {
|
|
477
|
+
readonly code = IdentityCodes.PasswordResetsExhausted;
|
|
478
|
+
|
|
479
|
+
static withRetryAfter(retryAfterMs: number) {
|
|
480
|
+
return PasswordResetsExhausted.refusal('Three password resets per hour at most.', { retryAfterMs });
|
|
473
481
|
}
|
|
474
482
|
}
|
|
475
483
|
|
|
@@ -480,7 +488,7 @@ export class RequestPasswordResetHandler implements CommandHandler<RequestPasswo
|
|
|
480
488
|
const decision = await this.limiter.consume(`password-reset:${accountId}`, { limit: 3, windowMs: 3_600_000 });
|
|
481
489
|
|
|
482
490
|
if (!decision.allowed) {
|
|
483
|
-
throw
|
|
491
|
+
throw PasswordResetsExhausted.withRetryAfter(decision.retryAfterMs);
|
|
484
492
|
}
|
|
485
493
|
|
|
486
494
|
// send the link
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ddd-ts-kit/redis",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.83.1",
|
|
4
4
|
"description": "Adapters of the kernel ports on the Redis protocol (Redis, Dragonfly, Valkey): cache, distributed lock, rate limiter, relay wake-up signal, a background job store, and an integration event provider on Redis Streams.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ddd",
|
|
@@ -48,12 +48,12 @@
|
|
|
48
48
|
"dist"
|
|
49
49
|
],
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@ddd-ts-kit/kernel": "0.
|
|
52
|
-
"@ddd-ts-kit/scheduling": "0.
|
|
51
|
+
"@ddd-ts-kit/kernel": "0.83.1",
|
|
52
|
+
"@ddd-ts-kit/scheduling": "0.83.1"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
55
|
"ioredis": "^5.0.0 || ^6.0.0",
|
|
56
|
-
"@ddd-ts-kit/testing": "0.
|
|
56
|
+
"@ddd-ts-kit/testing": "0.83.1"
|
|
57
57
|
},
|
|
58
58
|
"peerDependenciesMeta": {
|
|
59
59
|
"@ddd-ts-kit/testing": {
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"ioredis": "^6.0.0",
|
|
65
|
-
"@ddd-ts-kit/events": "0.
|
|
66
|
-
"@ddd-ts-kit/testing": "0.
|
|
65
|
+
"@ddd-ts-kit/events": "0.83.1",
|
|
66
|
+
"@ddd-ts-kit/testing": "0.83.1"
|
|
67
67
|
}
|
|
68
68
|
}
|