@bymax-one/nest-notification 1.1.2 → 1.2.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/CHANGELOG.md +133 -1
- package/README.md +9 -3
- package/dist/server/index.cjs +460 -61
- package/dist/server/index.d.cts +97 -5
- package/dist/server/index.d.ts +97 -5
- package/dist/server/index.mjs +460 -61
- package/package.json +1 -1
package/dist/server/index.d.cts
CHANGED
|
@@ -70,6 +70,12 @@ interface EmailSendOptions {
|
|
|
70
70
|
headers?: Record<string, string>;
|
|
71
71
|
/** Attachments. */
|
|
72
72
|
attachments?: ReadonlyArray<EmailAttachment>;
|
|
73
|
+
/**
|
|
74
|
+
* Secret values a provider must scrub from any error text it logs or throws
|
|
75
|
+
* — a relay that echoes the rejected content puts the body (and any secret
|
|
76
|
+
* inside it, e.g. an OTP code) into the transport error.
|
|
77
|
+
*/
|
|
78
|
+
redactValues?: readonly string[];
|
|
73
79
|
}
|
|
74
80
|
/** Result of a successful send. `messageId` is provider-specific; useful for audit correlation. */
|
|
75
81
|
interface EmailSendResult {
|
|
@@ -754,6 +760,11 @@ interface EmailSendInput {
|
|
|
754
760
|
attachments?: EmailSendOptions['attachments'];
|
|
755
761
|
/** Associated user id, recorded in the audit entry. */
|
|
756
762
|
userId?: string;
|
|
763
|
+
/**
|
|
764
|
+
* Secret values (e.g. an OTP code the body carries) redacted from the audit
|
|
765
|
+
* entry's `errorMessage` when a provider failure echoes them back.
|
|
766
|
+
*/
|
|
767
|
+
auditRedactValues?: readonly string[];
|
|
757
768
|
}
|
|
758
769
|
/** Input for {@link EmailService.sendTemplate} — the renderer produces the body. */
|
|
759
770
|
interface EmailSendTemplateInput {
|
|
@@ -767,6 +778,11 @@ interface EmailSendTemplateInput {
|
|
|
767
778
|
replyTo?: string;
|
|
768
779
|
tags?: ReadonlyArray<EmailTag$1>;
|
|
769
780
|
userId?: string;
|
|
781
|
+
/**
|
|
782
|
+
* Secret values (e.g. an OTP code inside `data`) redacted from the audit
|
|
783
|
+
* entry's `errorMessage` when a provider failure echoes them back.
|
|
784
|
+
*/
|
|
785
|
+
auditRedactValues?: readonly string[];
|
|
770
786
|
}
|
|
771
787
|
/** Transactional email service. */
|
|
772
788
|
declare class EmailService {
|
|
@@ -825,6 +841,16 @@ declare class EmailService {
|
|
|
825
841
|
private audit;
|
|
826
842
|
/** Masks the recipient(s) per `audit.maskRecipient`, joining an array with `', '`. */
|
|
827
843
|
private maskRecipients;
|
|
844
|
+
/**
|
|
845
|
+
* Assembles every value to scrub from a provider failure: the caller's
|
|
846
|
+
* declared secrets plus any excerpt of the rendered body the error is
|
|
847
|
+
* ECHOING — a policy/DLP relay that quotes the rejected content puts the
|
|
848
|
+
* body (and any secret inside it) into the error without the caller having
|
|
849
|
+
* declared anything. Echo detection starts from the collected excerpts so
|
|
850
|
+
* that with nothing declared and nothing echoed the list is verifiably
|
|
851
|
+
* empty and the raw error passes through untouched.
|
|
852
|
+
*/
|
|
853
|
+
private gatherRedactionValues;
|
|
828
854
|
}
|
|
829
855
|
|
|
830
856
|
/**
|
|
@@ -1453,6 +1479,26 @@ declare class ResendEmailProvider implements IEmailProvider {
|
|
|
1453
1479
|
* maps any thrown `Error` to `EMAIL_SEND_FAILED`.
|
|
1454
1480
|
*/
|
|
1455
1481
|
send(options: EmailSendOptions): Promise<EmailSendResult>;
|
|
1482
|
+
/**
|
|
1483
|
+
* Builds the failure for a rejected send, logging the scrubbed reason on the
|
|
1484
|
+
* way out — the single exit shared by the rejected-promise and `{ error }`
|
|
1485
|
+
* result shapes, so neither can surface an unscrubbed message.
|
|
1486
|
+
*
|
|
1487
|
+
* @param rawMessage - The provider's own error text, unscrubbed.
|
|
1488
|
+
* @param options - The send input whose body and declared values to scrub.
|
|
1489
|
+
* @returns The `Error` for the caller to throw.
|
|
1490
|
+
*/
|
|
1491
|
+
private sendFailure;
|
|
1492
|
+
/**
|
|
1493
|
+
* Removes the API key, the caller's declared secrets, and any echoed body
|
|
1494
|
+
* excerpt from an SDK error message — the provider cannot know which part of
|
|
1495
|
+
* the body is secret, so a detected echo is scrubbed wholesale.
|
|
1496
|
+
*
|
|
1497
|
+
* @param message - The raw SDK error message.
|
|
1498
|
+
* @param options - The send input whose body and declared values to scrub.
|
|
1499
|
+
* @returns The message with every known-secret value replaced.
|
|
1500
|
+
*/
|
|
1501
|
+
private scrubSendError;
|
|
1456
1502
|
/**
|
|
1457
1503
|
* Formats the RFC-5322 `from` header. The `Name <address>` display-name form is
|
|
1458
1504
|
* only used when a non-empty address exists — otherwise it would emit the literal
|
|
@@ -1655,6 +1701,25 @@ declare class SmtpEmailProvider implements IEmailProvider {
|
|
|
1655
1701
|
* @throws Error When the transport rejects the message.
|
|
1656
1702
|
*/
|
|
1657
1703
|
private dispatch;
|
|
1704
|
+
/**
|
|
1705
|
+
* Removes the credentials, the caller's declared secrets and any echoed body
|
|
1706
|
+
* excerpt from a transport error's text — the credential scrub alone cannot
|
|
1707
|
+
* cover content the provider does not know is secret.
|
|
1708
|
+
*
|
|
1709
|
+
* Echo detection runs against the RAW message and every value is replaced in
|
|
1710
|
+
* a single pass. Redacting credentials first would break a contiguous body
|
|
1711
|
+
* run that happens to quote one, dropping the surviving halves below the
|
|
1712
|
+
* detection window and leaving the rest of that body — and any secret inside
|
|
1713
|
+
* it — in the log line.
|
|
1714
|
+
*
|
|
1715
|
+
* @param message - The raw transport error message.
|
|
1716
|
+
* @param payload - The message that was sent, whose body is the echo reference.
|
|
1717
|
+
* @param declaredValues - The caller's declared secrets, if any.
|
|
1718
|
+
* @returns The message with every known-secret value replaced.
|
|
1719
|
+
*/
|
|
1720
|
+
private scrubTransportError;
|
|
1721
|
+
/** The configured credentials that qualify as secret material, if any. */
|
|
1722
|
+
private credentialValues;
|
|
1658
1723
|
/**
|
|
1659
1724
|
* Replaces every occurrence of either configured credential with a placeholder.
|
|
1660
1725
|
*
|
|
@@ -1667,7 +1732,10 @@ declare class SmtpEmailProvider implements IEmailProvider {
|
|
|
1667
1732
|
* public login: an SES SMTP username, for one, is itself generated secret
|
|
1668
1733
|
* material. Matching is literal and unconditional, so a short credential
|
|
1669
1734
|
* over-redacts a message rather than risking a miss — the safe direction for a
|
|
1670
|
-
* control whose other failure mode is persisting a secret.
|
|
1735
|
+
* control whose other failure mode is persisting a secret. The two credentials
|
|
1736
|
+
* can overlap — a password built from the username, say `relay` /
|
|
1737
|
+
* `relay-secret` — which {@link redactValues} handles by merging overlapping
|
|
1738
|
+
* matches into a single marker.
|
|
1671
1739
|
*
|
|
1672
1740
|
* @param message - The raw error message.
|
|
1673
1741
|
* @returns The message with both credentials removed, unchanged when none is set.
|
|
@@ -2366,12 +2434,33 @@ type NotificationErrorKey = keyof typeof NOTIFICATION_ERROR_DEFINITIONS;
|
|
|
2366
2434
|
* on `error.code` to localize the message.
|
|
2367
2435
|
*/
|
|
2368
2436
|
|
|
2437
|
+
/**
|
|
2438
|
+
* Optional construction knobs, mirroring how `HttpException` itself moved its
|
|
2439
|
+
* positional arguments into an options object.
|
|
2440
|
+
*/
|
|
2441
|
+
interface NotificationExceptionOptions {
|
|
2442
|
+
/** Replaces the catalog's default HTTP status when supplied. */
|
|
2443
|
+
status?: HttpStatus;
|
|
2444
|
+
/** Replaces the catalog's default message when supplied. */
|
|
2445
|
+
message?: string;
|
|
2446
|
+
/**
|
|
2447
|
+
* The underlying error, exposed as the native `Error.cause` so log serializers
|
|
2448
|
+
* can walk the chain. Stored as a log-safe copy — `name`, `message`, `stack`,
|
|
2449
|
+
* and the nested `cause` chain are preserved (depth-bounded); every other
|
|
2450
|
+
* property is dropped so an SDK error that retains the request payload cannot
|
|
2451
|
+
* leak an OTP-bearing body into logs. Never serialized into the HTTP response
|
|
2452
|
+
* body. A falsy value is ignored — `HttpException` only installs a truthy cause.
|
|
2453
|
+
*/
|
|
2454
|
+
cause?: unknown;
|
|
2455
|
+
}
|
|
2369
2456
|
/**
|
|
2370
2457
|
* Typed HTTP exception over the notification error catalog.
|
|
2371
2458
|
*
|
|
2372
2459
|
* @example
|
|
2373
2460
|
* ```ts
|
|
2374
2461
|
* throw new NotificationException('OTP_INVALID_LENGTH', { provided: 0, allowed: '1-32' })
|
|
2462
|
+
* // With the underlying error attached as `Error.cause`:
|
|
2463
|
+
* throw new NotificationException('EMAIL_SEND_FAILED', { providerName: 'smtp' }, { cause: error })
|
|
2375
2464
|
* ```
|
|
2376
2465
|
*/
|
|
2377
2466
|
declare class NotificationException extends HttpException {
|
|
@@ -2380,10 +2469,13 @@ declare class NotificationException extends HttpException {
|
|
|
2380
2469
|
/**
|
|
2381
2470
|
* @param key - Catalog key selecting the code, default HTTP status, and message.
|
|
2382
2471
|
* @param details - Optional structured context placed under `error.details`.
|
|
2383
|
-
* @param
|
|
2384
|
-
*
|
|
2472
|
+
* @param optionsOrStatus - An {@link NotificationExceptionOptions} object, or — kept
|
|
2473
|
+
* for backward compatibility — a bare `HttpStatus` acting as `options.status`.
|
|
2474
|
+
* @param overrideMessage - Replaces the catalog's default message when supplied;
|
|
2475
|
+
* kept for backward compatibility with the positional form. `options.message` wins
|
|
2476
|
+
* when both are given.
|
|
2385
2477
|
*/
|
|
2386
|
-
constructor(key: NotificationErrorKey, details?: Record<string, unknown>,
|
|
2478
|
+
constructor(key: NotificationErrorKey, details?: Record<string, unknown>, optionsOrStatus?: HttpStatus | NotificationExceptionOptions, overrideMessage?: string);
|
|
2387
2479
|
}
|
|
2388
2480
|
|
|
2389
2481
|
/**
|
|
@@ -2460,4 +2552,4 @@ declare const DEFAULT_TTLS: {
|
|
|
2460
2552
|
readonly OTP_GENERIC_SECONDS: 600;
|
|
2461
2553
|
};
|
|
2462
2554
|
|
|
2463
|
-
export { type AuditOptions, BYMAX_NOTIFICATION_EMAIL_PROVIDER, BYMAX_NOTIFICATION_LOG_REPOSITORY, BYMAX_NOTIFICATION_OPTIONS, BYMAX_NOTIFICATION_OTP_STORAGE, BYMAX_NOTIFICATION_PUSH_PROVIDER, BYMAX_NOTIFICATION_SMS_PROVIDER, BYMAX_NOTIFICATION_TEMPLATE_RENDERER, BymaxNotificationModule, type BymaxNotificationModuleAsyncOptions, type BymaxNotificationModuleOptions, type BymaxNotificationModuleOptionsFactory, CANONICAL_EMAIL_TEMPLATES, type CanonicalEmailTemplate, type CanonicalNotificationPurpose, type ConsumeAttemptResult, DEFAULT_TTLS, DefaultTemplateRenderer, type DefaultTemplateRendererOptions, type DispatchInput, type DispatchResult, type EmailAttachment, type EmailChannelOptions, type EmailDispatchPayload, type EmailSendInput, type EmailSendOptions, type EmailSendResult, type EmailSendTemplateInput, EmailService, type GlobalOptions, type IEmailProvider, type IEmailTemplateRenderer, type INotificationLogRepository, type IOtpStorage, type IPushProvider, type ISmsProvider, InMemoryOtpStorage, type InMemoryStorageSize, type MissingVariableMode, NOTIFICATION_ERROR_CODES, NOTIFICATION_ERROR_DEFINITIONS, NOTIFICATION_PURPOSES, NoOpEmailProvider, NoOpNotificationLogRepository, NotificationAuditInterceptor, type NotificationChannel, type NotificationErrorCode, type NotificationErrorDefinition, type NotificationErrorKey, type NotificationErrorResponse, NotificationException, type NotificationLogEntry, type NotificationLogVerb, type NotificationRequest, NotificationService, type OtpChannelOptions, type OtpConsumeInput, type OtpDispatchPayload, type OtpEntry, type OtpGenerateInput, type OtpGenerateResult, type OtpPurpose, type OtpPurposeConfig, OtpService, type OtpStatusInput, type OtpStatusResult, type OtpVerifyInput, type OtpVerifyResult, type PushChannelOptions, type PushSendOptions, type PushSendResult, type RedisLike, RedisOtpStorage, type RedisOtpStorageOptions, type RenderedEmail, ResendEmailProvider, type ResendEmailProviderOptions, type ResolvedAuditOptions, type ResolvedEmailOptions, type ResolvedGlobalOptions, type ResolvedNotificationOptions, type ResolvedOtpOptions, type SmsChannelOptions, type SmsSendOptions, type SmsSendResult, type SmtpCredentials, SmtpEmailProvider, type SmtpEmailProviderOptions, type SmtpTlsOptions, type TemplateDefinition, cooldownExpiresAt, formatCooldown, generateOtpCode, hashTenantRecipient, safeCompare, toRetryAfterHeader };
|
|
2555
|
+
export { type AuditOptions, BYMAX_NOTIFICATION_EMAIL_PROVIDER, BYMAX_NOTIFICATION_LOG_REPOSITORY, BYMAX_NOTIFICATION_OPTIONS, BYMAX_NOTIFICATION_OTP_STORAGE, BYMAX_NOTIFICATION_PUSH_PROVIDER, BYMAX_NOTIFICATION_SMS_PROVIDER, BYMAX_NOTIFICATION_TEMPLATE_RENDERER, BymaxNotificationModule, type BymaxNotificationModuleAsyncOptions, type BymaxNotificationModuleOptions, type BymaxNotificationModuleOptionsFactory, CANONICAL_EMAIL_TEMPLATES, type CanonicalEmailTemplate, type CanonicalNotificationPurpose, type ConsumeAttemptResult, DEFAULT_TTLS, DefaultTemplateRenderer, type DefaultTemplateRendererOptions, type DispatchInput, type DispatchResult, type EmailAttachment, type EmailChannelOptions, type EmailDispatchPayload, type EmailSendInput, type EmailSendOptions, type EmailSendResult, type EmailSendTemplateInput, EmailService, type GlobalOptions, type IEmailProvider, type IEmailTemplateRenderer, type INotificationLogRepository, type IOtpStorage, type IPushProvider, type ISmsProvider, InMemoryOtpStorage, type InMemoryStorageSize, type MissingVariableMode, NOTIFICATION_ERROR_CODES, NOTIFICATION_ERROR_DEFINITIONS, NOTIFICATION_PURPOSES, NoOpEmailProvider, NoOpNotificationLogRepository, NotificationAuditInterceptor, type NotificationChannel, type NotificationErrorCode, type NotificationErrorDefinition, type NotificationErrorKey, type NotificationErrorResponse, NotificationException, type NotificationExceptionOptions, type NotificationLogEntry, type NotificationLogVerb, type NotificationRequest, NotificationService, type OtpChannelOptions, type OtpConsumeInput, type OtpDispatchPayload, type OtpEntry, type OtpGenerateInput, type OtpGenerateResult, type OtpPurpose, type OtpPurposeConfig, OtpService, type OtpStatusInput, type OtpStatusResult, type OtpVerifyInput, type OtpVerifyResult, type PushChannelOptions, type PushSendOptions, type PushSendResult, type RedisLike, RedisOtpStorage, type RedisOtpStorageOptions, type RenderedEmail, ResendEmailProvider, type ResendEmailProviderOptions, type ResolvedAuditOptions, type ResolvedEmailOptions, type ResolvedGlobalOptions, type ResolvedNotificationOptions, type ResolvedOtpOptions, type SmsChannelOptions, type SmsSendOptions, type SmsSendResult, type SmtpCredentials, SmtpEmailProvider, type SmtpEmailProviderOptions, type SmtpTlsOptions, type TemplateDefinition, cooldownExpiresAt, formatCooldown, generateOtpCode, hashTenantRecipient, safeCompare, toRetryAfterHeader };
|
package/dist/server/index.d.ts
CHANGED
|
@@ -70,6 +70,12 @@ interface EmailSendOptions {
|
|
|
70
70
|
headers?: Record<string, string>;
|
|
71
71
|
/** Attachments. */
|
|
72
72
|
attachments?: ReadonlyArray<EmailAttachment>;
|
|
73
|
+
/**
|
|
74
|
+
* Secret values a provider must scrub from any error text it logs or throws
|
|
75
|
+
* — a relay that echoes the rejected content puts the body (and any secret
|
|
76
|
+
* inside it, e.g. an OTP code) into the transport error.
|
|
77
|
+
*/
|
|
78
|
+
redactValues?: readonly string[];
|
|
73
79
|
}
|
|
74
80
|
/** Result of a successful send. `messageId` is provider-specific; useful for audit correlation. */
|
|
75
81
|
interface EmailSendResult {
|
|
@@ -754,6 +760,11 @@ interface EmailSendInput {
|
|
|
754
760
|
attachments?: EmailSendOptions['attachments'];
|
|
755
761
|
/** Associated user id, recorded in the audit entry. */
|
|
756
762
|
userId?: string;
|
|
763
|
+
/**
|
|
764
|
+
* Secret values (e.g. an OTP code the body carries) redacted from the audit
|
|
765
|
+
* entry's `errorMessage` when a provider failure echoes them back.
|
|
766
|
+
*/
|
|
767
|
+
auditRedactValues?: readonly string[];
|
|
757
768
|
}
|
|
758
769
|
/** Input for {@link EmailService.sendTemplate} — the renderer produces the body. */
|
|
759
770
|
interface EmailSendTemplateInput {
|
|
@@ -767,6 +778,11 @@ interface EmailSendTemplateInput {
|
|
|
767
778
|
replyTo?: string;
|
|
768
779
|
tags?: ReadonlyArray<EmailTag$1>;
|
|
769
780
|
userId?: string;
|
|
781
|
+
/**
|
|
782
|
+
* Secret values (e.g. an OTP code inside `data`) redacted from the audit
|
|
783
|
+
* entry's `errorMessage` when a provider failure echoes them back.
|
|
784
|
+
*/
|
|
785
|
+
auditRedactValues?: readonly string[];
|
|
770
786
|
}
|
|
771
787
|
/** Transactional email service. */
|
|
772
788
|
declare class EmailService {
|
|
@@ -825,6 +841,16 @@ declare class EmailService {
|
|
|
825
841
|
private audit;
|
|
826
842
|
/** Masks the recipient(s) per `audit.maskRecipient`, joining an array with `', '`. */
|
|
827
843
|
private maskRecipients;
|
|
844
|
+
/**
|
|
845
|
+
* Assembles every value to scrub from a provider failure: the caller's
|
|
846
|
+
* declared secrets plus any excerpt of the rendered body the error is
|
|
847
|
+
* ECHOING — a policy/DLP relay that quotes the rejected content puts the
|
|
848
|
+
* body (and any secret inside it) into the error without the caller having
|
|
849
|
+
* declared anything. Echo detection starts from the collected excerpts so
|
|
850
|
+
* that with nothing declared and nothing echoed the list is verifiably
|
|
851
|
+
* empty and the raw error passes through untouched.
|
|
852
|
+
*/
|
|
853
|
+
private gatherRedactionValues;
|
|
828
854
|
}
|
|
829
855
|
|
|
830
856
|
/**
|
|
@@ -1453,6 +1479,26 @@ declare class ResendEmailProvider implements IEmailProvider {
|
|
|
1453
1479
|
* maps any thrown `Error` to `EMAIL_SEND_FAILED`.
|
|
1454
1480
|
*/
|
|
1455
1481
|
send(options: EmailSendOptions): Promise<EmailSendResult>;
|
|
1482
|
+
/**
|
|
1483
|
+
* Builds the failure for a rejected send, logging the scrubbed reason on the
|
|
1484
|
+
* way out — the single exit shared by the rejected-promise and `{ error }`
|
|
1485
|
+
* result shapes, so neither can surface an unscrubbed message.
|
|
1486
|
+
*
|
|
1487
|
+
* @param rawMessage - The provider's own error text, unscrubbed.
|
|
1488
|
+
* @param options - The send input whose body and declared values to scrub.
|
|
1489
|
+
* @returns The `Error` for the caller to throw.
|
|
1490
|
+
*/
|
|
1491
|
+
private sendFailure;
|
|
1492
|
+
/**
|
|
1493
|
+
* Removes the API key, the caller's declared secrets, and any echoed body
|
|
1494
|
+
* excerpt from an SDK error message — the provider cannot know which part of
|
|
1495
|
+
* the body is secret, so a detected echo is scrubbed wholesale.
|
|
1496
|
+
*
|
|
1497
|
+
* @param message - The raw SDK error message.
|
|
1498
|
+
* @param options - The send input whose body and declared values to scrub.
|
|
1499
|
+
* @returns The message with every known-secret value replaced.
|
|
1500
|
+
*/
|
|
1501
|
+
private scrubSendError;
|
|
1456
1502
|
/**
|
|
1457
1503
|
* Formats the RFC-5322 `from` header. The `Name <address>` display-name form is
|
|
1458
1504
|
* only used when a non-empty address exists — otherwise it would emit the literal
|
|
@@ -1655,6 +1701,25 @@ declare class SmtpEmailProvider implements IEmailProvider {
|
|
|
1655
1701
|
* @throws Error When the transport rejects the message.
|
|
1656
1702
|
*/
|
|
1657
1703
|
private dispatch;
|
|
1704
|
+
/**
|
|
1705
|
+
* Removes the credentials, the caller's declared secrets and any echoed body
|
|
1706
|
+
* excerpt from a transport error's text — the credential scrub alone cannot
|
|
1707
|
+
* cover content the provider does not know is secret.
|
|
1708
|
+
*
|
|
1709
|
+
* Echo detection runs against the RAW message and every value is replaced in
|
|
1710
|
+
* a single pass. Redacting credentials first would break a contiguous body
|
|
1711
|
+
* run that happens to quote one, dropping the surviving halves below the
|
|
1712
|
+
* detection window and leaving the rest of that body — and any secret inside
|
|
1713
|
+
* it — in the log line.
|
|
1714
|
+
*
|
|
1715
|
+
* @param message - The raw transport error message.
|
|
1716
|
+
* @param payload - The message that was sent, whose body is the echo reference.
|
|
1717
|
+
* @param declaredValues - The caller's declared secrets, if any.
|
|
1718
|
+
* @returns The message with every known-secret value replaced.
|
|
1719
|
+
*/
|
|
1720
|
+
private scrubTransportError;
|
|
1721
|
+
/** The configured credentials that qualify as secret material, if any. */
|
|
1722
|
+
private credentialValues;
|
|
1658
1723
|
/**
|
|
1659
1724
|
* Replaces every occurrence of either configured credential with a placeholder.
|
|
1660
1725
|
*
|
|
@@ -1667,7 +1732,10 @@ declare class SmtpEmailProvider implements IEmailProvider {
|
|
|
1667
1732
|
* public login: an SES SMTP username, for one, is itself generated secret
|
|
1668
1733
|
* material. Matching is literal and unconditional, so a short credential
|
|
1669
1734
|
* over-redacts a message rather than risking a miss — the safe direction for a
|
|
1670
|
-
* control whose other failure mode is persisting a secret.
|
|
1735
|
+
* control whose other failure mode is persisting a secret. The two credentials
|
|
1736
|
+
* can overlap — a password built from the username, say `relay` /
|
|
1737
|
+
* `relay-secret` — which {@link redactValues} handles by merging overlapping
|
|
1738
|
+
* matches into a single marker.
|
|
1671
1739
|
*
|
|
1672
1740
|
* @param message - The raw error message.
|
|
1673
1741
|
* @returns The message with both credentials removed, unchanged when none is set.
|
|
@@ -2366,12 +2434,33 @@ type NotificationErrorKey = keyof typeof NOTIFICATION_ERROR_DEFINITIONS;
|
|
|
2366
2434
|
* on `error.code` to localize the message.
|
|
2367
2435
|
*/
|
|
2368
2436
|
|
|
2437
|
+
/**
|
|
2438
|
+
* Optional construction knobs, mirroring how `HttpException` itself moved its
|
|
2439
|
+
* positional arguments into an options object.
|
|
2440
|
+
*/
|
|
2441
|
+
interface NotificationExceptionOptions {
|
|
2442
|
+
/** Replaces the catalog's default HTTP status when supplied. */
|
|
2443
|
+
status?: HttpStatus;
|
|
2444
|
+
/** Replaces the catalog's default message when supplied. */
|
|
2445
|
+
message?: string;
|
|
2446
|
+
/**
|
|
2447
|
+
* The underlying error, exposed as the native `Error.cause` so log serializers
|
|
2448
|
+
* can walk the chain. Stored as a log-safe copy — `name`, `message`, `stack`,
|
|
2449
|
+
* and the nested `cause` chain are preserved (depth-bounded); every other
|
|
2450
|
+
* property is dropped so an SDK error that retains the request payload cannot
|
|
2451
|
+
* leak an OTP-bearing body into logs. Never serialized into the HTTP response
|
|
2452
|
+
* body. A falsy value is ignored — `HttpException` only installs a truthy cause.
|
|
2453
|
+
*/
|
|
2454
|
+
cause?: unknown;
|
|
2455
|
+
}
|
|
2369
2456
|
/**
|
|
2370
2457
|
* Typed HTTP exception over the notification error catalog.
|
|
2371
2458
|
*
|
|
2372
2459
|
* @example
|
|
2373
2460
|
* ```ts
|
|
2374
2461
|
* throw new NotificationException('OTP_INVALID_LENGTH', { provided: 0, allowed: '1-32' })
|
|
2462
|
+
* // With the underlying error attached as `Error.cause`:
|
|
2463
|
+
* throw new NotificationException('EMAIL_SEND_FAILED', { providerName: 'smtp' }, { cause: error })
|
|
2375
2464
|
* ```
|
|
2376
2465
|
*/
|
|
2377
2466
|
declare class NotificationException extends HttpException {
|
|
@@ -2380,10 +2469,13 @@ declare class NotificationException extends HttpException {
|
|
|
2380
2469
|
/**
|
|
2381
2470
|
* @param key - Catalog key selecting the code, default HTTP status, and message.
|
|
2382
2471
|
* @param details - Optional structured context placed under `error.details`.
|
|
2383
|
-
* @param
|
|
2384
|
-
*
|
|
2472
|
+
* @param optionsOrStatus - An {@link NotificationExceptionOptions} object, or — kept
|
|
2473
|
+
* for backward compatibility — a bare `HttpStatus` acting as `options.status`.
|
|
2474
|
+
* @param overrideMessage - Replaces the catalog's default message when supplied;
|
|
2475
|
+
* kept for backward compatibility with the positional form. `options.message` wins
|
|
2476
|
+
* when both are given.
|
|
2385
2477
|
*/
|
|
2386
|
-
constructor(key: NotificationErrorKey, details?: Record<string, unknown>,
|
|
2478
|
+
constructor(key: NotificationErrorKey, details?: Record<string, unknown>, optionsOrStatus?: HttpStatus | NotificationExceptionOptions, overrideMessage?: string);
|
|
2387
2479
|
}
|
|
2388
2480
|
|
|
2389
2481
|
/**
|
|
@@ -2460,4 +2552,4 @@ declare const DEFAULT_TTLS: {
|
|
|
2460
2552
|
readonly OTP_GENERIC_SECONDS: 600;
|
|
2461
2553
|
};
|
|
2462
2554
|
|
|
2463
|
-
export { type AuditOptions, BYMAX_NOTIFICATION_EMAIL_PROVIDER, BYMAX_NOTIFICATION_LOG_REPOSITORY, BYMAX_NOTIFICATION_OPTIONS, BYMAX_NOTIFICATION_OTP_STORAGE, BYMAX_NOTIFICATION_PUSH_PROVIDER, BYMAX_NOTIFICATION_SMS_PROVIDER, BYMAX_NOTIFICATION_TEMPLATE_RENDERER, BymaxNotificationModule, type BymaxNotificationModuleAsyncOptions, type BymaxNotificationModuleOptions, type BymaxNotificationModuleOptionsFactory, CANONICAL_EMAIL_TEMPLATES, type CanonicalEmailTemplate, type CanonicalNotificationPurpose, type ConsumeAttemptResult, DEFAULT_TTLS, DefaultTemplateRenderer, type DefaultTemplateRendererOptions, type DispatchInput, type DispatchResult, type EmailAttachment, type EmailChannelOptions, type EmailDispatchPayload, type EmailSendInput, type EmailSendOptions, type EmailSendResult, type EmailSendTemplateInput, EmailService, type GlobalOptions, type IEmailProvider, type IEmailTemplateRenderer, type INotificationLogRepository, type IOtpStorage, type IPushProvider, type ISmsProvider, InMemoryOtpStorage, type InMemoryStorageSize, type MissingVariableMode, NOTIFICATION_ERROR_CODES, NOTIFICATION_ERROR_DEFINITIONS, NOTIFICATION_PURPOSES, NoOpEmailProvider, NoOpNotificationLogRepository, NotificationAuditInterceptor, type NotificationChannel, type NotificationErrorCode, type NotificationErrorDefinition, type NotificationErrorKey, type NotificationErrorResponse, NotificationException, type NotificationLogEntry, type NotificationLogVerb, type NotificationRequest, NotificationService, type OtpChannelOptions, type OtpConsumeInput, type OtpDispatchPayload, type OtpEntry, type OtpGenerateInput, type OtpGenerateResult, type OtpPurpose, type OtpPurposeConfig, OtpService, type OtpStatusInput, type OtpStatusResult, type OtpVerifyInput, type OtpVerifyResult, type PushChannelOptions, type PushSendOptions, type PushSendResult, type RedisLike, RedisOtpStorage, type RedisOtpStorageOptions, type RenderedEmail, ResendEmailProvider, type ResendEmailProviderOptions, type ResolvedAuditOptions, type ResolvedEmailOptions, type ResolvedGlobalOptions, type ResolvedNotificationOptions, type ResolvedOtpOptions, type SmsChannelOptions, type SmsSendOptions, type SmsSendResult, type SmtpCredentials, SmtpEmailProvider, type SmtpEmailProviderOptions, type SmtpTlsOptions, type TemplateDefinition, cooldownExpiresAt, formatCooldown, generateOtpCode, hashTenantRecipient, safeCompare, toRetryAfterHeader };
|
|
2555
|
+
export { type AuditOptions, BYMAX_NOTIFICATION_EMAIL_PROVIDER, BYMAX_NOTIFICATION_LOG_REPOSITORY, BYMAX_NOTIFICATION_OPTIONS, BYMAX_NOTIFICATION_OTP_STORAGE, BYMAX_NOTIFICATION_PUSH_PROVIDER, BYMAX_NOTIFICATION_SMS_PROVIDER, BYMAX_NOTIFICATION_TEMPLATE_RENDERER, BymaxNotificationModule, type BymaxNotificationModuleAsyncOptions, type BymaxNotificationModuleOptions, type BymaxNotificationModuleOptionsFactory, CANONICAL_EMAIL_TEMPLATES, type CanonicalEmailTemplate, type CanonicalNotificationPurpose, type ConsumeAttemptResult, DEFAULT_TTLS, DefaultTemplateRenderer, type DefaultTemplateRendererOptions, type DispatchInput, type DispatchResult, type EmailAttachment, type EmailChannelOptions, type EmailDispatchPayload, type EmailSendInput, type EmailSendOptions, type EmailSendResult, type EmailSendTemplateInput, EmailService, type GlobalOptions, type IEmailProvider, type IEmailTemplateRenderer, type INotificationLogRepository, type IOtpStorage, type IPushProvider, type ISmsProvider, InMemoryOtpStorage, type InMemoryStorageSize, type MissingVariableMode, NOTIFICATION_ERROR_CODES, NOTIFICATION_ERROR_DEFINITIONS, NOTIFICATION_PURPOSES, NoOpEmailProvider, NoOpNotificationLogRepository, NotificationAuditInterceptor, type NotificationChannel, type NotificationErrorCode, type NotificationErrorDefinition, type NotificationErrorKey, type NotificationErrorResponse, NotificationException, type NotificationExceptionOptions, type NotificationLogEntry, type NotificationLogVerb, type NotificationRequest, NotificationService, type OtpChannelOptions, type OtpConsumeInput, type OtpDispatchPayload, type OtpEntry, type OtpGenerateInput, type OtpGenerateResult, type OtpPurpose, type OtpPurposeConfig, OtpService, type OtpStatusInput, type OtpStatusResult, type OtpVerifyInput, type OtpVerifyResult, type PushChannelOptions, type PushSendOptions, type PushSendResult, type RedisLike, RedisOtpStorage, type RedisOtpStorageOptions, type RenderedEmail, ResendEmailProvider, type ResendEmailProviderOptions, type ResolvedAuditOptions, type ResolvedEmailOptions, type ResolvedGlobalOptions, type ResolvedNotificationOptions, type ResolvedOtpOptions, type SmsChannelOptions, type SmsSendOptions, type SmsSendResult, type SmtpCredentials, SmtpEmailProvider, type SmtpEmailProviderOptions, type SmtpTlsOptions, type TemplateDefinition, cooldownExpiresAt, formatCooldown, generateOtpCode, hashTenantRecipient, safeCompare, toRetryAfterHeader };
|