@bymax-one/nest-notification 1.4.6 → 1.4.7
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/CHANGELOG.md +28 -1
- package/README.md +28 -24
- package/dist/server/index.cjs +71 -0
- package/dist/server/index.mjs +71 -0
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,32 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [1.4.7] - 2026-11-07
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- **A swallowed audit failure now leaves a warning.** With the default `audit.swallowErrors: true`
|
|
15
|
+
a failed audit write was dropped without a trace, so an audit outage, or a `tenantIdResolver`
|
|
16
|
+
that returned a blank id, emptied the audit trail, including the entries that record a recipient
|
|
17
|
+
reaching its attempt ceiling, while every send and verification kept succeeding. The OTP
|
|
18
|
+
service, the email service and the audit interceptor each log
|
|
19
|
+
`BYMAX_NOTIFICATION_AUDIT_WRITE_FAILED`, naming the channel and the failure's class or code only:
|
|
20
|
+
a `notification.` code, otherwise the error's name and code, each
|
|
21
|
+
only when it is a short token. The repository's error message is never printed, because it can
|
|
22
|
+
quote the entry it rejected, whose recipient and user id are personal data, in any form; the cause
|
|
23
|
+
is in the repository's own logs. A name or code your repository sets itself is printed when it is a short token, so do not put an identifier of the entry in one. No OTP code is ever written. At most one line is written per
|
|
24
|
+
channel per minute; the next line says how many failures it stands for. What the caller receives
|
|
25
|
+
is unchanged.
|
|
26
|
+
|
|
27
|
+
### Documentation
|
|
28
|
+
|
|
29
|
+
- The README now states the ordering behind `AUDIT_LOG_FAILED` when `audit.swallowErrors` is
|
|
30
|
+
`false`: the audit write comes after the state change, so the error says only that the audit write
|
|
31
|
+
failed and replaces the result the call would have returned. It can follow a stored, delivered or
|
|
32
|
+
accepted code, or the recording of a refusal, so the outcome cannot be inferred from it. When the
|
|
33
|
+
email channel's own audit of a send fails, `generate()` also releases the stored code and the
|
|
34
|
+
resend cooldown.
|
|
35
|
+
|
|
10
36
|
## [1.4.6] - 2026-11-01
|
|
11
37
|
|
|
12
38
|
### Fixed
|
|
@@ -1015,7 +1041,8 @@ rejected at startup rather than failing on the first send.
|
|
|
1015
1041
|
|
|
1016
1042
|
[1.0.4]: https://github.com/bymaxone/nest-notification/compare/v1.0.3...v1.0.4
|
|
1017
1043
|
[1.0.3]: https://github.com/bymaxone/nest-notification/compare/v1.0.2...v1.0.3
|
|
1018
|
-
[Unreleased]: https://github.com/bymaxone/nest-notification/compare/v1.4.
|
|
1044
|
+
[Unreleased]: https://github.com/bymaxone/nest-notification/compare/v1.4.7...HEAD
|
|
1045
|
+
[1.4.7]: https://github.com/bymaxone/nest-notification/compare/v1.4.6...v1.4.7
|
|
1019
1046
|
[1.4.6]: https://github.com/bymaxone/nest-notification/compare/v1.4.5...v1.4.6
|
|
1020
1047
|
[1.4.5]: https://github.com/bymaxone/nest-notification/compare/v1.4.4...v1.4.5
|
|
1021
1048
|
[1.4.4]: https://github.com/bymaxone/nest-notification/compare/v1.4.3...v1.4.4
|
package/README.md
CHANGED
|
@@ -514,30 +514,30 @@ if (error.code === NOTIFICATION_ERROR_CODES.OTP_MAX_ATTEMPTS_EXCEEDED) {
|
|
|
514
514
|
|
|
515
515
|
Configure via `forRoot(options)` or `forRootAsync({ useFactory })`. **At least one channel must be configured**, and configuring a channel the library does not implement throws at startup rather than failing on the first send. The full reference is in [`docs/technical_specification.md` §4](./docs/technical_specification.md); the most-used options:
|
|
516
516
|
|
|
517
|
-
| Section | Option | Default | Notes
|
|
518
|
-
| -------- | ----------------------- | ---------------- |
|
|
519
|
-
| `global` | `redisNamespace` | `'notification'` | Prefix for store keys.
|
|
520
|
-
| `global` | `defaultLocale` | `'en'` | Template locale fallback.
|
|
521
|
-
| `global` | `tenantIdResolver` | — | `(req) => tenantId`; the audit source of truth.
|
|
522
|
-
| `email` | `provider` | — (required) | Instance or class implementing `IEmailProvider`.
|
|
523
|
-
| `email` | `defaultFrom` | — (required) | Must look like an email address.
|
|
524
|
-
| `email` | `templateRenderer` | default renderer | Any `IEmailTemplateRenderer`.
|
|
525
|
-
| `email` | `maxAttachmentBytes` | `10485760` | 10 MiB attachment guard.
|
|
526
|
-
| `otp` | `storage` | — (required) | Instance or class implementing `IOtpStorage`.
|
|
527
|
-
| `otp` | `defaultLength` | `6` | 1–32.
|
|
528
|
-
| `otp` | `defaultCodeType` | `'numeric'` | `numeric` \| `alpha` \| `alphanumeric`.
|
|
529
|
-
| `otp` | `defaultTtlSeconds` | `600` | Code lifetime.
|
|
530
|
-
| `otp` | `defaultMaxAttempts` | `5` | Verify attempts before lock-out.
|
|
531
|
-
| `otp` | `codeSecret` | — | Secret (>= 32 bytes) the stored code is keyed under.
|
|
532
|
-
| `otp` | `consumeOnVerify` | `false` | `true` deletes the code when `verify()` succeeds; otherwise the entry is marked validated until `consume()` or its TTL.
|
|
533
|
-
| `email` | `defaultFromName` | — | Display name sent with `defaultFrom`.
|
|
534
|
-
| `email` | `defaultReplyTo` | — | `Reply-To` applied when a send does not set one.
|
|
535
|
-
| `email` | `defaultTags` | `[]` | Tags merged into every send, before the send's own tags.
|
|
536
|
-
| `otp` | `resendCooldownSeconds` | `60` | Anti-resend window (atomic `SET NX EX`).
|
|
537
|
-
| `otp` | `perPurpose` | `{}` | Per-purpose overrides of the above.
|
|
538
|
-
| `audit` | `repository` | — (required) | Any `INotificationLogRepository`.
|
|
539
|
-
| `audit` | `swallowErrors` | `true` | Keep audit failures out of the delivery path.
|
|
540
|
-
| `audit` | `maskRecipient` | identity | Minimize recipient PII before persisting.
|
|
517
|
+
| Section | Option | Default | Notes |
|
|
518
|
+
| -------- | ----------------------- | ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
519
|
+
| `global` | `redisNamespace` | `'notification'` | Prefix for store keys. |
|
|
520
|
+
| `global` | `defaultLocale` | `'en'` | Template locale fallback. |
|
|
521
|
+
| `global` | `tenantIdResolver` | — | `(req) => tenantId`; the audit source of truth. |
|
|
522
|
+
| `email` | `provider` | — (required) | Instance or class implementing `IEmailProvider`. |
|
|
523
|
+
| `email` | `defaultFrom` | — (required) | Must look like an email address. |
|
|
524
|
+
| `email` | `templateRenderer` | default renderer | Any `IEmailTemplateRenderer`. |
|
|
525
|
+
| `email` | `maxAttachmentBytes` | `10485760` | 10 MiB attachment guard. |
|
|
526
|
+
| `otp` | `storage` | — (required) | Instance or class implementing `IOtpStorage`. |
|
|
527
|
+
| `otp` | `defaultLength` | `6` | 1–32. |
|
|
528
|
+
| `otp` | `defaultCodeType` | `'numeric'` | `numeric` \| `alpha` \| `alphanumeric`. |
|
|
529
|
+
| `otp` | `defaultTtlSeconds` | `600` | Code lifetime. |
|
|
530
|
+
| `otp` | `defaultMaxAttempts` | `5` | Verify attempts before lock-out. |
|
|
531
|
+
| `otp` | `codeSecret` | — | Secret (>= 32 bytes) the stored code is keyed under. |
|
|
532
|
+
| `otp` | `consumeOnVerify` | `false` | `true` deletes the code when `verify()` succeeds; otherwise the entry is marked validated until `consume()` or its TTL. |
|
|
533
|
+
| `email` | `defaultFromName` | — | Display name sent with `defaultFrom`. |
|
|
534
|
+
| `email` | `defaultReplyTo` | — | `Reply-To` applied when a send does not set one. |
|
|
535
|
+
| `email` | `defaultTags` | `[]` | Tags merged into every send, before the send's own tags. |
|
|
536
|
+
| `otp` | `resendCooldownSeconds` | `60` | Anti-resend window (atomic `SET NX EX`). |
|
|
537
|
+
| `otp` | `perPurpose` | `{}` | Per-purpose overrides of the above. |
|
|
538
|
+
| `audit` | `repository` | — (required) | Any `INotificationLogRepository`. |
|
|
539
|
+
| `audit` | `swallowErrors` | `true` | Keep audit failures out of the delivery path. A swallowed failure logs `BYMAX_NOTIFICATION_AUDIT_WRITE_FAILED`, at most once a minute per channel. |
|
|
540
|
+
| `audit` | `maskRecipient` | identity | Minimize recipient PII before persisting. |
|
|
541
541
|
|
|
542
542
|
---
|
|
543
543
|
|
|
@@ -639,6 +639,10 @@ const tenantIdResolver = (req: NotificationRequest): string =>
|
|
|
639
639
|
|
|
640
640
|
A tenant id that identifies nobody is never recorded. The interceptor refuses a value that is not a string, is empty, or is whitespace-only, on every path that produces the id: what `tenantIdResolver` returns, the payload's `tenantId` when no resolver is configured, and the payload's `tenantId` when a resolver is configured but there is no HTTP request to read it from (a non-HTTP context). Your caller never sees the refusal itself. With `audit.swallowErrors: true` (the default) it is swallowed and no audit entry is written; with `false` it surfaces as `AUDIT_LOG_FAILED`, whose `cause` is a sanitized copy of the refusal. One input is ignored, not refused: an argument whose payload `tenantId` is not a string is not recognised as a dispatch at all, so it produces no audit entry and no error.
|
|
641
641
|
|
|
642
|
+
A swallowed audit failure is not silent: each channel (`otp`, `email`, the interceptor) logs one warning, `BYMAX_NOTIFICATION_AUDIT_WRITE_FAILED`, naming the channel and the failure's class or code only: a `notification.` code (such as `notification.invalid_scope_identifier` for a refused tenant id), otherwise the error's name and code, each only when it is a short token such as `Error` or `ECONNREFUSED`. The repository's error message is never printed, since it can quote the entry it rejected, whose recipient and user id are personal data, in any form; the cause is in your repository's own logs. A name or code your repository sets itself is printed when it is a short token, so do not put an identifier of the entry in one. No OTP code is ever written. At most one line is written per channel per minute; the next line says how many failures it stands for. The operation's own result is unchanged.
|
|
643
|
+
|
|
644
|
+
With `audit.swallowErrors: false` the audit write comes after the state change, so `AUDIT_LOG_FAILED` says only that the audit write failed. It does not say what the operation did, and it replaces the result the call would have returned: `generate()` can raise it after the code was stored and delivered (its resend cooldown is then held, unless the email channel's own audit of the send is the one that failed, which releases the stored code and the cooldown), or while recording a blocked cooldown or a failed delivery; `verify()` can raise it after the code was accepted (consumed, or marked validated), or while recording a wrong code, a missing code or an exhausted attempt limit. Never read it as success or as failure of the operation; check the state through your own means.
|
|
645
|
+
|
|
642
646
|
> [!NOTE]
|
|
643
647
|
> The resolver governs what the audit interceptor trusts. Service methods still take an explicit `tenantId`: resolve the tenant in your controller and pass it down — there is no hidden override of a method argument.
|
|
644
648
|
|
package/dist/server/index.cjs
CHANGED
|
@@ -626,6 +626,65 @@ var CANONICAL_EMAIL_TEMPLATES = {
|
|
|
626
626
|
MFA_DISABLED: "mfa_disabled"
|
|
627
627
|
};
|
|
628
628
|
|
|
629
|
+
// src/server/utils/audit-write-warning.ts
|
|
630
|
+
var AUDIT_WARNING_INTERVAL_MS = 6e4;
|
|
631
|
+
var WARNING_CODE = "BYMAX_NOTIFICATION_AUDIT_WRITE_FAILED";
|
|
632
|
+
var TOKEN = /^[A-Za-z0-9_.:-]{1,64}$/;
|
|
633
|
+
var LIBRARY_CODE_PREFIX = "notification.";
|
|
634
|
+
function tokenOf(value) {
|
|
635
|
+
return typeof value === "string" && TOKEN.test(value) ? value : void 0;
|
|
636
|
+
}
|
|
637
|
+
function reasonOf(error) {
|
|
638
|
+
try {
|
|
639
|
+
const source = error;
|
|
640
|
+
const code = tokenOf(source?.code);
|
|
641
|
+
if (code?.startsWith(LIBRARY_CODE_PREFIX)) {
|
|
642
|
+
return code;
|
|
643
|
+
}
|
|
644
|
+
const name = tokenOf(source?.name) ?? "Error";
|
|
645
|
+
return code === void 0 ? name : `${name} ${code}`;
|
|
646
|
+
} catch {
|
|
647
|
+
return "Error";
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
var AuditWriteWarning = class {
|
|
651
|
+
/**
|
|
652
|
+
* @param logger - Where the line goes.
|
|
653
|
+
* @param channel - The place that swallows the failure.
|
|
654
|
+
*/
|
|
655
|
+
constructor(logger, channel) {
|
|
656
|
+
this.logger = logger;
|
|
657
|
+
this.channel = channel;
|
|
658
|
+
this.suppressed = 0;
|
|
659
|
+
}
|
|
660
|
+
/**
|
|
661
|
+
* Whether `elapsed` milliseconds since the last line is still inside the interval.
|
|
662
|
+
*
|
|
663
|
+
* @internal
|
|
664
|
+
*/
|
|
665
|
+
within(elapsed) {
|
|
666
|
+
return elapsed >= 0 && elapsed < AUDIT_WARNING_INTERVAL_MS;
|
|
667
|
+
}
|
|
668
|
+
/**
|
|
669
|
+
* Logs the warning, or counts the failure when one was logged less than an interval ago.
|
|
670
|
+
*
|
|
671
|
+
* @param error - What the audit repository threw; any value, named without throwing.
|
|
672
|
+
*/
|
|
673
|
+
warn(error) {
|
|
674
|
+
const now = Date.now();
|
|
675
|
+
if (this.lastLoggedAt !== void 0 && this.within(now - this.lastLoggedAt)) {
|
|
676
|
+
this.suppressed += 1;
|
|
677
|
+
return;
|
|
678
|
+
}
|
|
679
|
+
const similar = this.suppressed > 0 ? `; ${this.suppressed} similar since the last line` : "";
|
|
680
|
+
this.lastLoggedAt = now;
|
|
681
|
+
this.suppressed = 0;
|
|
682
|
+
this.logger.warn(
|
|
683
|
+
`[${WARNING_CODE}] An audit entry could not be written by the ${this.channel} channel (${reasonOf(error)}${similar}); the operation's result is unaffected because audit.swallowErrors is true.`
|
|
684
|
+
);
|
|
685
|
+
}
|
|
686
|
+
};
|
|
687
|
+
|
|
629
688
|
// src/server/utils/delivery-status.ts
|
|
630
689
|
var MAX_SUBFIELD_DIGITS = 3;
|
|
631
690
|
var BASIC_STATUS = /(?<![\d.])([245]\d\d)(?![\d.])/g;
|
|
@@ -966,6 +1025,8 @@ exports.EmailService = class EmailService {
|
|
|
966
1025
|
this.provider = provider;
|
|
967
1026
|
this.renderer = renderer;
|
|
968
1027
|
this.auditLog = auditLog;
|
|
1028
|
+
/** @internal */
|
|
1029
|
+
this.auditWarning = new AuditWriteWarning(new common.Logger(exports.EmailService.name), "email");
|
|
969
1030
|
}
|
|
970
1031
|
/**
|
|
971
1032
|
* Whether the email channel is configured and its provider is ready.
|
|
@@ -1192,6 +1253,7 @@ exports.EmailService = class EmailService {
|
|
|
1192
1253
|
if (!this.options.audit.swallowErrors) {
|
|
1193
1254
|
throw new NotificationException("AUDIT_LOG_FAILED", void 0, { cause: error });
|
|
1194
1255
|
}
|
|
1256
|
+
this.auditWarning.warn(error);
|
|
1195
1257
|
}
|
|
1196
1258
|
}
|
|
1197
1259
|
/** Masks the recipient(s) per `audit.maskRecipient`, joining an array with `', '`. */
|
|
@@ -1358,6 +1420,8 @@ exports.OtpService = class OtpService {
|
|
|
1358
1420
|
this.warnedFailuresNotCarried = false;
|
|
1359
1421
|
/** @internal */
|
|
1360
1422
|
this.warnedTemplate = false;
|
|
1423
|
+
/** @internal */
|
|
1424
|
+
this.auditWarning = new AuditWriteWarning(this.logger, "otp");
|
|
1361
1425
|
}
|
|
1362
1426
|
/**
|
|
1363
1427
|
* Whether the OTP channel is configured and its storage is ready.
|
|
@@ -1764,6 +1828,7 @@ exports.OtpService = class OtpService {
|
|
|
1764
1828
|
if (!this.options.audit.swallowErrors) {
|
|
1765
1829
|
throw new NotificationException("AUDIT_LOG_FAILED", void 0, { cause: error });
|
|
1766
1830
|
}
|
|
1831
|
+
this.auditWarning.warn(error);
|
|
1767
1832
|
}
|
|
1768
1833
|
}
|
|
1769
1834
|
};
|
|
@@ -2213,6 +2278,11 @@ exports.NotificationAuditInterceptor = class NotificationAuditInterceptor {
|
|
|
2213
2278
|
constructor(options, auditLog) {
|
|
2214
2279
|
this.options = options;
|
|
2215
2280
|
this.auditLog = auditLog;
|
|
2281
|
+
/** @internal */
|
|
2282
|
+
this.auditWarning = new AuditWriteWarning(
|
|
2283
|
+
new common.Logger(exports.NotificationAuditInterceptor.name),
|
|
2284
|
+
"interceptor"
|
|
2285
|
+
);
|
|
2216
2286
|
}
|
|
2217
2287
|
/**
|
|
2218
2288
|
* Taps the handler stream: records `'sent'` after a successful dispatch and
|
|
@@ -2250,6 +2320,7 @@ exports.NotificationAuditInterceptor = class NotificationAuditInterceptor {
|
|
|
2250
2320
|
if (!this.options.audit.swallowErrors) {
|
|
2251
2321
|
throw new NotificationException("AUDIT_LOG_FAILED", void 0, { cause: error });
|
|
2252
2322
|
}
|
|
2323
|
+
this.auditWarning.warn(error);
|
|
2253
2324
|
}
|
|
2254
2325
|
}
|
|
2255
2326
|
/** Returns the first handler argument shaped like a {@link DispatchInput}, else `null`. */
|
package/dist/server/index.mjs
CHANGED
|
@@ -624,6 +624,65 @@ var CANONICAL_EMAIL_TEMPLATES = {
|
|
|
624
624
|
MFA_DISABLED: "mfa_disabled"
|
|
625
625
|
};
|
|
626
626
|
|
|
627
|
+
// src/server/utils/audit-write-warning.ts
|
|
628
|
+
var AUDIT_WARNING_INTERVAL_MS = 6e4;
|
|
629
|
+
var WARNING_CODE = "BYMAX_NOTIFICATION_AUDIT_WRITE_FAILED";
|
|
630
|
+
var TOKEN = /^[A-Za-z0-9_.:-]{1,64}$/;
|
|
631
|
+
var LIBRARY_CODE_PREFIX = "notification.";
|
|
632
|
+
function tokenOf(value) {
|
|
633
|
+
return typeof value === "string" && TOKEN.test(value) ? value : void 0;
|
|
634
|
+
}
|
|
635
|
+
function reasonOf(error) {
|
|
636
|
+
try {
|
|
637
|
+
const source = error;
|
|
638
|
+
const code = tokenOf(source?.code);
|
|
639
|
+
if (code?.startsWith(LIBRARY_CODE_PREFIX)) {
|
|
640
|
+
return code;
|
|
641
|
+
}
|
|
642
|
+
const name = tokenOf(source?.name) ?? "Error";
|
|
643
|
+
return code === void 0 ? name : `${name} ${code}`;
|
|
644
|
+
} catch {
|
|
645
|
+
return "Error";
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
var AuditWriteWarning = class {
|
|
649
|
+
/**
|
|
650
|
+
* @param logger - Where the line goes.
|
|
651
|
+
* @param channel - The place that swallows the failure.
|
|
652
|
+
*/
|
|
653
|
+
constructor(logger, channel) {
|
|
654
|
+
this.logger = logger;
|
|
655
|
+
this.channel = channel;
|
|
656
|
+
this.suppressed = 0;
|
|
657
|
+
}
|
|
658
|
+
/**
|
|
659
|
+
* Whether `elapsed` milliseconds since the last line is still inside the interval.
|
|
660
|
+
*
|
|
661
|
+
* @internal
|
|
662
|
+
*/
|
|
663
|
+
within(elapsed) {
|
|
664
|
+
return elapsed >= 0 && elapsed < AUDIT_WARNING_INTERVAL_MS;
|
|
665
|
+
}
|
|
666
|
+
/**
|
|
667
|
+
* Logs the warning, or counts the failure when one was logged less than an interval ago.
|
|
668
|
+
*
|
|
669
|
+
* @param error - What the audit repository threw; any value, named without throwing.
|
|
670
|
+
*/
|
|
671
|
+
warn(error) {
|
|
672
|
+
const now = Date.now();
|
|
673
|
+
if (this.lastLoggedAt !== void 0 && this.within(now - this.lastLoggedAt)) {
|
|
674
|
+
this.suppressed += 1;
|
|
675
|
+
return;
|
|
676
|
+
}
|
|
677
|
+
const similar = this.suppressed > 0 ? `; ${this.suppressed} similar since the last line` : "";
|
|
678
|
+
this.lastLoggedAt = now;
|
|
679
|
+
this.suppressed = 0;
|
|
680
|
+
this.logger.warn(
|
|
681
|
+
`[${WARNING_CODE}] An audit entry could not be written by the ${this.channel} channel (${reasonOf(error)}${similar}); the operation's result is unaffected because audit.swallowErrors is true.`
|
|
682
|
+
);
|
|
683
|
+
}
|
|
684
|
+
};
|
|
685
|
+
|
|
627
686
|
// src/server/utils/delivery-status.ts
|
|
628
687
|
var MAX_SUBFIELD_DIGITS = 3;
|
|
629
688
|
var BASIC_STATUS = /(?<![\d.])([245]\d\d)(?![\d.])/g;
|
|
@@ -964,6 +1023,8 @@ var EmailService = class {
|
|
|
964
1023
|
this.provider = provider;
|
|
965
1024
|
this.renderer = renderer;
|
|
966
1025
|
this.auditLog = auditLog;
|
|
1026
|
+
/** @internal */
|
|
1027
|
+
this.auditWarning = new AuditWriteWarning(new Logger(EmailService.name), "email");
|
|
967
1028
|
}
|
|
968
1029
|
/**
|
|
969
1030
|
* Whether the email channel is configured and its provider is ready.
|
|
@@ -1190,6 +1251,7 @@ var EmailService = class {
|
|
|
1190
1251
|
if (!this.options.audit.swallowErrors) {
|
|
1191
1252
|
throw new NotificationException("AUDIT_LOG_FAILED", void 0, { cause: error });
|
|
1192
1253
|
}
|
|
1254
|
+
this.auditWarning.warn(error);
|
|
1193
1255
|
}
|
|
1194
1256
|
}
|
|
1195
1257
|
/** Masks the recipient(s) per `audit.maskRecipient`, joining an array with `', '`. */
|
|
@@ -1356,6 +1418,8 @@ var OtpService = class {
|
|
|
1356
1418
|
this.warnedFailuresNotCarried = false;
|
|
1357
1419
|
/** @internal */
|
|
1358
1420
|
this.warnedTemplate = false;
|
|
1421
|
+
/** @internal */
|
|
1422
|
+
this.auditWarning = new AuditWriteWarning(this.logger, "otp");
|
|
1359
1423
|
}
|
|
1360
1424
|
/**
|
|
1361
1425
|
* Whether the OTP channel is configured and its storage is ready.
|
|
@@ -1762,6 +1826,7 @@ var OtpService = class {
|
|
|
1762
1826
|
if (!this.options.audit.swallowErrors) {
|
|
1763
1827
|
throw new NotificationException("AUDIT_LOG_FAILED", void 0, { cause: error });
|
|
1764
1828
|
}
|
|
1829
|
+
this.auditWarning.warn(error);
|
|
1765
1830
|
}
|
|
1766
1831
|
}
|
|
1767
1832
|
};
|
|
@@ -2211,6 +2276,11 @@ var NotificationAuditInterceptor = class {
|
|
|
2211
2276
|
constructor(options, auditLog) {
|
|
2212
2277
|
this.options = options;
|
|
2213
2278
|
this.auditLog = auditLog;
|
|
2279
|
+
/** @internal */
|
|
2280
|
+
this.auditWarning = new AuditWriteWarning(
|
|
2281
|
+
new Logger(NotificationAuditInterceptor.name),
|
|
2282
|
+
"interceptor"
|
|
2283
|
+
);
|
|
2214
2284
|
}
|
|
2215
2285
|
/**
|
|
2216
2286
|
* Taps the handler stream: records `'sent'` after a successful dispatch and
|
|
@@ -2248,6 +2318,7 @@ var NotificationAuditInterceptor = class {
|
|
|
2248
2318
|
if (!this.options.audit.swallowErrors) {
|
|
2249
2319
|
throw new NotificationException("AUDIT_LOG_FAILED", void 0, { cause: error });
|
|
2250
2320
|
}
|
|
2321
|
+
this.auditWarning.warn(error);
|
|
2251
2322
|
}
|
|
2252
2323
|
}
|
|
2253
2324
|
/** Returns the first handler argument shaped like a {@link DispatchInput}, else `null`. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bymax-one/nest-notification",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.7",
|
|
4
4
|
"description": "Multi-channel notification library for NestJS — email, OTP, SMS, push — with pluggable providers and storage, multi-tenant by design, zero runtime dependencies.",
|
|
5
5
|
"author": "Bymax One <support@bymax.one>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -81,6 +81,7 @@
|
|
|
81
81
|
},
|
|
82
82
|
"scripts": {
|
|
83
83
|
"build": "pnpm clean && tsup",
|
|
84
|
+
"check:api": "node scripts/check-api-surface.mjs",
|
|
84
85
|
"check:exports": "attw --pack .",
|
|
85
86
|
"check:mutants": "node scripts/check-mutation-directives.mjs",
|
|
86
87
|
"check:no-prisma": "grep -rq '@prisma/client' src; s=$?; [ $s -eq 1 ] && exit 0; [ $s -eq 0 ] && { echo check:no-prisma: found @prisma/client import in src/; exit 1; }; echo check:no-prisma: grep failed with exit $s; exit $s",
|