@bymax-one/nest-notification 1.4.1 → 1.4.2
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 +171 -1
- package/README.md +168 -48
- package/dist/server/index.cjs +382 -56
- package/dist/server/index.d.cts +203 -6
- package/dist/server/index.d.ts +203 -6
- package/dist/server/index.mjs +383 -57
- package/dist/shared/index.cjs +1 -0
- package/dist/shared/index.d.cts +2 -1
- package/dist/shared/index.d.ts +2 -1
- package/dist/shared/index.mjs +1 -0
- package/dist/testing/index.cjs +207 -12
- package/dist/testing/index.d.cts +36 -7
- package/dist/testing/index.d.ts +36 -7
- package/dist/testing/index.mjs +207 -12
- package/package.json +4 -57
package/dist/server/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ModuleMetadata, FactoryProvider, DynamicModule, NestInterceptor, ExecutionContext, CallHandler, HttpStatus, HttpException } from '@nestjs/common';
|
|
1
|
+
import { ModuleMetadata, FactoryProvider, DynamicModule, OnModuleInit, NestInterceptor, ExecutionContext, CallHandler, HttpStatus, HttpException } from '@nestjs/common';
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -338,6 +338,28 @@ interface IOtpStorage {
|
|
|
338
338
|
* cancelled flow can restart immediately).
|
|
339
339
|
*/
|
|
340
340
|
clearCooldown(tenantId: string, recipient: string, purpose: string): Promise<void>;
|
|
341
|
+
/**
|
|
342
|
+
* Optional. Verification attempts counted for `(tenant, recipient, purpose)`, or `0`.
|
|
343
|
+
*
|
|
344
|
+
* Together with {@link IOtpStorage.recordFailure} and {@link IOtpStorage.clearFailures} this
|
|
345
|
+
* makes the failed-attempt count outlive a code: NIST SP 800-63B-4 §3.1.3.2 says generating a
|
|
346
|
+
* new authentication secret "SHALL NOT reset the failed authentication count". `OtpService`
|
|
347
|
+
* counts each verification attempt against a live code with `recordFailure` before comparing it and refuses
|
|
348
|
+
* once the number it returns passes the attempt ceiling; this method is the read side of the
|
|
349
|
+
* same counter. A storage that omits the three keeps a fresh budget per code, and a warning at
|
|
350
|
+
* startup names the deviation.
|
|
351
|
+
*/
|
|
352
|
+
getFailures?(tenantId: string, recipient: string, purpose: string): Promise<number>;
|
|
353
|
+
/**
|
|
354
|
+
* Optional. Atomically adds one verification attempt and (re)sets the counter's lifetime to
|
|
355
|
+
* `ttlSeconds`, returning the new count. A counter that is not touched for `ttlSeconds`
|
|
356
|
+
* lapses, which starts the count again from zero.
|
|
357
|
+
*
|
|
358
|
+
* MUST be atomic (Redis: `INCR` and `EXPIRE` in one script).
|
|
359
|
+
*/
|
|
360
|
+
recordFailure?(tenantId: string, recipient: string, purpose: string, ttlSeconds: number): Promise<number>;
|
|
361
|
+
/** Optional. Removes the failure counter. Idempotent. Called on success and on `consume()`. */
|
|
362
|
+
clearFailures?(tenantId: string, recipient: string, purpose: string): Promise<void>;
|
|
341
363
|
/** Whether the storage is configured and ready. Used during module initialization. */
|
|
342
364
|
isConfigured(): boolean;
|
|
343
365
|
/** Storage name (e.g. `'redis'`, `'memory'`, `'dynamodb'`). */
|
|
@@ -538,6 +560,15 @@ interface OtpChannelOptions {
|
|
|
538
560
|
resendCooldownSeconds?: number;
|
|
539
561
|
/** When `true`, `verify()` consumes (deletes) the OTP on success. Default: `false`. */
|
|
540
562
|
consumeOnVerify?: boolean;
|
|
563
|
+
/**
|
|
564
|
+
* Secret under which a code is stored as an HMAC-SHA-256 digest instead of in plaintext.
|
|
565
|
+
* At least 32 UTF-8 bytes, kept with the application and never in the store, so a reader
|
|
566
|
+
* of the store alone cannot recover or test a code. Omitted: codes are stored in plaintext
|
|
567
|
+
* and a warning is logged at startup. A plaintext entry written while no secret was set
|
|
568
|
+
* verifies until it expires; changing or removing the secret makes a stored digest
|
|
569
|
+
* unverifiable, so those codes must be requested again.
|
|
570
|
+
*/
|
|
571
|
+
codeSecret?: string;
|
|
541
572
|
/** Per-purpose overrides of the defaults above. */
|
|
542
573
|
perPurpose?: Record<string, Partial<OtpPurposeConfig>>;
|
|
543
574
|
}
|
|
@@ -643,6 +674,11 @@ interface BymaxNotificationModuleAsyncOptions {
|
|
|
643
674
|
*/
|
|
644
675
|
declare class BymaxNotificationModule {
|
|
645
676
|
private static readonly logger;
|
|
677
|
+
/**
|
|
678
|
+
* Logs one warning when the OTP channel stores codes in plaintext, i.e. `otp.codeSecret`
|
|
679
|
+
* is not configured. A reader of the store would see every live code.
|
|
680
|
+
*/
|
|
681
|
+
private static warnPlaintextCodes;
|
|
646
682
|
/**
|
|
647
683
|
* Registers the module synchronously from static options.
|
|
648
684
|
*
|
|
@@ -731,6 +767,12 @@ interface ResolvedOtpOptions {
|
|
|
731
767
|
defaultMaxAttempts: number;
|
|
732
768
|
resendCooldownSeconds: number;
|
|
733
769
|
consumeOnVerify: boolean;
|
|
770
|
+
/**
|
|
771
|
+
* Turns a plaintext code into the value that is stored; present only when `codeSecret`
|
|
772
|
+
* is configured. A function rather than the secret, so the secret is not a property of
|
|
773
|
+
* an object that is injected under a public token and can be logged or serialized.
|
|
774
|
+
*/
|
|
775
|
+
digestCode?: (code: string) => string;
|
|
734
776
|
/** Per-purpose overrides, each fully resolved against the OTP defaults. */
|
|
735
777
|
perPurpose: Record<string, OtpPurposeConfig>;
|
|
736
778
|
/** Effective config for a purpose: the resolved `perPurpose[purpose]`, or the OTP defaults. */
|
|
@@ -858,7 +900,8 @@ declare class EmailService {
|
|
|
858
900
|
*
|
|
859
901
|
* @param input - The message envelope and rendered body.
|
|
860
902
|
* @returns The provider's message id.
|
|
861
|
-
* @throws NotificationException `EMAIL_PROVIDER_NOT_CONFIGURED`, `
|
|
903
|
+
* @throws NotificationException `EMAIL_PROVIDER_NOT_CONFIGURED`, `INVALID_SCOPE_IDENTIFIER`
|
|
904
|
+
* (a blank tenant or one with a control character), `EMAIL_ATTACHMENTS_TOO_LARGE`,
|
|
862
905
|
* `EMAIL_SEND_FAILED`, or `AUDIT_LOG_FAILED` (only when `audit.swallowErrors` is `false`).
|
|
863
906
|
*/
|
|
864
907
|
send(input: EmailSendInput): Promise<{
|
|
@@ -1003,11 +1046,13 @@ interface OtpStatusResult {
|
|
|
1003
1046
|
validated?: boolean;
|
|
1004
1047
|
}
|
|
1005
1048
|
/** OTP generation, verification, consumption, and status. */
|
|
1006
|
-
declare class OtpService {
|
|
1049
|
+
declare class OtpService implements OnModuleInit {
|
|
1007
1050
|
private readonly options;
|
|
1008
1051
|
private readonly storage;
|
|
1009
1052
|
private readonly auditLog;
|
|
1010
1053
|
private readonly emailService?;
|
|
1054
|
+
private readonly logger;
|
|
1055
|
+
private warnedFailuresNotCarried;
|
|
1011
1056
|
/**
|
|
1012
1057
|
* @param options - The resolved, frozen module options.
|
|
1013
1058
|
* @param storage - The configured OTP storage.
|
|
@@ -1070,6 +1115,45 @@ declare class OtpService {
|
|
|
1070
1115
|
* error is re-thrown after the lock is released.
|
|
1071
1116
|
*/
|
|
1072
1117
|
private persistAndDeliver;
|
|
1118
|
+
/**
|
|
1119
|
+
* Releases the cooldown and the orphan entry after a failed persist or delivery, audits the
|
|
1120
|
+
* failure, and returns what the caller must throw.
|
|
1121
|
+
*
|
|
1122
|
+
* A failed cleanup supersedes the delivery error — the cooldown/OTP may now be orphaned,
|
|
1123
|
+
* which the caller must see — and it must NOT bypass the scrub below. The delivery error is
|
|
1124
|
+
* preserved as its cause when the cleanup error can verifiably carry one; a hostile trap
|
|
1125
|
+
* inside the attachment is contained by the helper.
|
|
1126
|
+
*
|
|
1127
|
+
* The scrub runs BEFORE the audit write and the rethrow, so neither the entry's
|
|
1128
|
+
* `errorMessage` nor the outgoing chain can carry the plaintext code. An Error chain is
|
|
1129
|
+
* scrubbed (in place, or via redacted copies when a node resists mutation); ANY other
|
|
1130
|
+
* rejection (string, object from a custom storage, number) is flattened to a redacted
|
|
1131
|
+
* string, because a raw object could carry the code in its properties and a primitive
|
|
1132
|
+
* cannot be mutated.
|
|
1133
|
+
*/
|
|
1134
|
+
private failedOutgoing;
|
|
1135
|
+
/**
|
|
1136
|
+
* Warns once when the storage cannot carry failed attempts across a re-issue, naming the
|
|
1137
|
+
* deviation from NIST SP 800-63B-4 §3.1.3.2 and the methods that remove it.
|
|
1138
|
+
*/
|
|
1139
|
+
onModuleInit(): void;
|
|
1140
|
+
/**
|
|
1141
|
+
* Counts one verification attempt against the recipient. Returns `undefined` when the storage
|
|
1142
|
+
* does not carry failures, and `null` when no code is live: a verification with no code guesses
|
|
1143
|
+
* at nothing, so it spends no budget, and the caller must answer `not_found` instead of going on
|
|
1144
|
+
* to consume an attempt from a code issued in the meantime, which would then go uncounted.
|
|
1145
|
+
*/
|
|
1146
|
+
private countAttempt;
|
|
1147
|
+
/** How a generated code reaches the recipient: by email when asked or when an email channel exists. */
|
|
1148
|
+
private deliveryOf;
|
|
1149
|
+
/**
|
|
1150
|
+
* Refuses a manual delivery while codes are stored as digests, before the cooldown is taken
|
|
1151
|
+
* or anything is stored. `generate` never returns the code and a digest cannot be handed to
|
|
1152
|
+
* a person, so the call would otherwise succeed with nothing deliverable.
|
|
1153
|
+
*
|
|
1154
|
+
* @throws NotificationException `OTP_MANUAL_DELIVERY_UNAVAILABLE`.
|
|
1155
|
+
*/
|
|
1156
|
+
private assertDeliverable;
|
|
1073
1157
|
/** Delivers the code by email when requested; throws on failure (release is handled by the caller). */
|
|
1074
1158
|
private deliverOtp;
|
|
1075
1159
|
/** Clears the cooldown and deletes the OTP — used to undo a failed delivery. */
|
|
@@ -1088,6 +1172,23 @@ declare class OtpService {
|
|
|
1088
1172
|
* @throws NotificationException `INVALID_SCOPE_IDENTIFIER` when either is blank.
|
|
1089
1173
|
*/
|
|
1090
1174
|
private assertScope;
|
|
1175
|
+
/**
|
|
1176
|
+
* Returns the input with its recipient replaced by the value the OTP state is keyed on.
|
|
1177
|
+
*
|
|
1178
|
+
* Every storage call and audit entry takes the result, so two spellings of one mailbox
|
|
1179
|
+
* share a cooldown and an attempt counter. Delivery takes the original input: the
|
|
1180
|
+
* message is addressed exactly as the caller wrote it.
|
|
1181
|
+
*/
|
|
1182
|
+
private keyed;
|
|
1183
|
+
/**
|
|
1184
|
+
* Compares a guessed code with the stored value in constant time.
|
|
1185
|
+
*
|
|
1186
|
+
* A stored digest is recomputed from the guess. A digest that cannot be recomputed (no
|
|
1187
|
+
* secret configured, or a different one) never matches, and the digest string itself is
|
|
1188
|
+
* not accepted as a code. A stored value that is not a digest is a plaintext code written
|
|
1189
|
+
* while no secret was set; it is compared directly and ages out with its TTL.
|
|
1190
|
+
*/
|
|
1191
|
+
private matchesStoredCode;
|
|
1091
1192
|
/** Returns the resolved OTP options or throws `OTP_STORAGE_NOT_CONFIGURED`. */
|
|
1092
1193
|
private requireOtpOptions;
|
|
1093
1194
|
/** Builds an OTP audit entry with the recipient masked and never the code. */
|
|
@@ -1158,9 +1259,10 @@ type DispatchResult = {
|
|
|
1158
1259
|
result: OtpGenerateResult | OtpVerifyResult | void;
|
|
1159
1260
|
};
|
|
1160
1261
|
/** Uniform façade over the configured channel services. */
|
|
1161
|
-
declare class NotificationService {
|
|
1262
|
+
declare class NotificationService implements OnModuleInit {
|
|
1162
1263
|
private readonly emailService?;
|
|
1163
1264
|
private readonly otpService?;
|
|
1265
|
+
private readonly logger;
|
|
1164
1266
|
/**
|
|
1165
1267
|
* @param emailService - The email service, present only when the email channel is configured.
|
|
1166
1268
|
* @param otpService - The OTP service, present only when the OTP channel is configured.
|
|
@@ -1195,6 +1297,15 @@ declare class NotificationService {
|
|
|
1195
1297
|
* @throws NotificationException `CHANNEL_DISABLED` when OTP is not configured.
|
|
1196
1298
|
*/
|
|
1197
1299
|
getOtp(): OtpService;
|
|
1300
|
+
/**
|
|
1301
|
+
* Warns once per channel that is configured but cannot be used, because its provider or
|
|
1302
|
+
* storage reports `isConfigured() === false`. Such a channel is absent from
|
|
1303
|
+
* {@link NotificationService.getEnabledChannels} and refused by the accessors; without this
|
|
1304
|
+
* line the first sign of it would be a failed send.
|
|
1305
|
+
*/
|
|
1306
|
+
onModuleInit(): void;
|
|
1307
|
+
/** Logs the not-usable warning for one channel. */
|
|
1308
|
+
private warnNotUsable;
|
|
1198
1309
|
/** Routes an email dispatch to `sendTemplate` (template) or `send` (raw body). */
|
|
1199
1310
|
private dispatchEmail;
|
|
1200
1311
|
/** Routes an OTP dispatch by `action`, defaulting to `generate`. */
|
|
@@ -2009,6 +2120,36 @@ declare class InMemoryOtpStorage implements IOtpStorage {
|
|
|
2009
2120
|
private readonly store;
|
|
2010
2121
|
/** Cooldown expiries (epoch ms) keyed by the same composite key. */
|
|
2011
2122
|
private readonly cooldowns;
|
|
2123
|
+
/** Failed-verification counters and their expiry (epoch ms), keyed the same way. */
|
|
2124
|
+
private readonly failures;
|
|
2125
|
+
/**
|
|
2126
|
+
* Failed verifications recorded for the scope, or `0` once the counter has lapsed.
|
|
2127
|
+
*
|
|
2128
|
+
* @param tenantId - Tenant isolation scope.
|
|
2129
|
+
* @param recipient - Pre-normalized recipient identifier.
|
|
2130
|
+
* @param purpose - OTP purpose.
|
|
2131
|
+
* @returns The count.
|
|
2132
|
+
*/
|
|
2133
|
+
getFailures(tenantId: string, recipient: string, purpose: string): Promise<number>;
|
|
2134
|
+
/**
|
|
2135
|
+
* Adds one failed verification and restarts the counter's lifetime. Synchronous
|
|
2136
|
+
* read-modify-write, so concurrent calls each see a distinct count.
|
|
2137
|
+
*
|
|
2138
|
+
* @param tenantId - Tenant isolation scope.
|
|
2139
|
+
* @param recipient - Pre-normalized recipient identifier.
|
|
2140
|
+
* @param purpose - OTP purpose.
|
|
2141
|
+
* @param ttlSeconds - How long the counter lives without another failure.
|
|
2142
|
+
* @returns The new count.
|
|
2143
|
+
*/
|
|
2144
|
+
recordFailure(tenantId: string, recipient: string, purpose: string, ttlSeconds: number): Promise<number>;
|
|
2145
|
+
/**
|
|
2146
|
+
* Removes the failure counter. Idempotent.
|
|
2147
|
+
*
|
|
2148
|
+
* @param tenantId - Tenant isolation scope.
|
|
2149
|
+
* @param recipient - Pre-normalized recipient identifier.
|
|
2150
|
+
* @param purpose - OTP purpose.
|
|
2151
|
+
*/
|
|
2152
|
+
clearFailures(tenantId: string, recipient: string, purpose: string): Promise<void>;
|
|
2012
2153
|
/** Always ready — there is nothing to configure.
|
|
2013
2154
|
*
|
|
2014
2155
|
* @returns `true`.
|
|
@@ -2097,6 +2238,8 @@ declare class InMemoryOtpStorage implements IOtpStorage {
|
|
|
2097
2238
|
* @returns The number of stored OTP entries and active cooldowns.
|
|
2098
2239
|
*/
|
|
2099
2240
|
size(): InMemoryStorageSize;
|
|
2241
|
+
/** The unexpired failure count for a key, dropping a lapsed counter. Synchronous. */
|
|
2242
|
+
private liveFailures;
|
|
2100
2243
|
/**
|
|
2101
2244
|
* Collapses the `(tenantId, recipient, purpose)` tuple into one map key.
|
|
2102
2245
|
*
|
|
@@ -2134,7 +2277,10 @@ declare class InMemoryOtpStorage implements IOtpStorage {
|
|
|
2134
2277
|
/** The slim Redis surface {@link RedisOtpStorage} relies on (ioredis is structurally compatible). */
|
|
2135
2278
|
interface RedisLike {
|
|
2136
2279
|
get(key: string): Promise<string | null>;
|
|
2137
|
-
|
|
2280
|
+
/** The cooldown lock: `SET key value EX seconds NX`. */
|
|
2281
|
+
set(key: string, value: string, expiry: 'EX', seconds: number, condition: 'NX'): Promise<'OK' | null>;
|
|
2282
|
+
/** An in-place rewrite that keeps the expiry: `SET key value KEEPTTL XX`. */
|
|
2283
|
+
set(key: string, value: string, keepTtl: 'KEEPTTL', condition: 'XX'): Promise<'OK' | null>;
|
|
2138
2284
|
setex(key: string, ttlSeconds: number, value: string): Promise<'OK'>;
|
|
2139
2285
|
del(...keys: string[]): Promise<number>;
|
|
2140
2286
|
ttl(key: string): Promise<number>;
|
|
@@ -2165,6 +2311,12 @@ declare class RedisOtpStorage implements IOtpStorage {
|
|
|
2165
2311
|
* `PTTL` is read inside the script to preserve the original expiry on rewrite.
|
|
2166
2312
|
*/
|
|
2167
2313
|
private static readonly CONSUME_ATTEMPT_LUA;
|
|
2314
|
+
/**
|
|
2315
|
+
* Atomic failure-counter primitive: one `INCR` and the lifetime refresh in a single script, so
|
|
2316
|
+
* concurrent failures each receive a distinct count and the counter never outlives its window
|
|
2317
|
+
* by a gap between the two commands.
|
|
2318
|
+
*/
|
|
2319
|
+
private static readonly RECORD_FAILURE_LUA;
|
|
2168
2320
|
/** Whether a Redis client was supplied.
|
|
2169
2321
|
*
|
|
2170
2322
|
* @returns `true` when a client is present.
|
|
@@ -2247,8 +2399,37 @@ declare class RedisOtpStorage implements IOtpStorage {
|
|
|
2247
2399
|
* @param purpose - OTP purpose.
|
|
2248
2400
|
*/
|
|
2249
2401
|
clearCooldown(tenantId: string, recipient: string, purpose: string): Promise<void>;
|
|
2402
|
+
/**
|
|
2403
|
+
* Failed verifications recorded for the scope.
|
|
2404
|
+
*
|
|
2405
|
+
* @param tenantId - Tenant isolation scope.
|
|
2406
|
+
* @param recipient - Pre-normalized recipient identifier.
|
|
2407
|
+
* @param purpose - OTP purpose.
|
|
2408
|
+
* @returns The count, or `0` when there is no counter.
|
|
2409
|
+
*/
|
|
2410
|
+
getFailures(tenantId: string, recipient: string, purpose: string): Promise<number>;
|
|
2411
|
+
/**
|
|
2412
|
+
* Adds one failed verification and restarts the counter's lifetime, atomically.
|
|
2413
|
+
*
|
|
2414
|
+
* @param tenantId - Tenant isolation scope.
|
|
2415
|
+
* @param recipient - Pre-normalized recipient identifier.
|
|
2416
|
+
* @param purpose - OTP purpose.
|
|
2417
|
+
* @param ttlSeconds - How long the counter lives without another failure.
|
|
2418
|
+
* @returns The new count.
|
|
2419
|
+
*/
|
|
2420
|
+
recordFailure(tenantId: string, recipient: string, purpose: string, ttlSeconds: number): Promise<number>;
|
|
2421
|
+
/**
|
|
2422
|
+
* Removes the failure counter. Idempotent.
|
|
2423
|
+
*
|
|
2424
|
+
* @param tenantId - Tenant isolation scope.
|
|
2425
|
+
* @param recipient - Pre-normalized recipient identifier.
|
|
2426
|
+
* @param purpose - OTP purpose.
|
|
2427
|
+
*/
|
|
2428
|
+
clearFailures(tenantId: string, recipient: string, purpose: string): Promise<void>;
|
|
2250
2429
|
/** Builds the OTP entry key: `{namespace}:otp:{purpose}:{hashTenantRecipient(...)}`. */
|
|
2251
2430
|
private otpKey;
|
|
2431
|
+
/** Builds the failure-counter key: `{namespace}:otp_fail:{purpose}:{hashTenantRecipient(...)}`. */
|
|
2432
|
+
private failureKey;
|
|
2252
2433
|
/** Builds the cooldown key: `{namespace}:otp_cd:{purpose}:{hashTenantRecipient(...)}`. */
|
|
2253
2434
|
private cooldownKey;
|
|
2254
2435
|
}
|
|
@@ -2397,7 +2578,7 @@ declare function formatCooldown(remainingSeconds: number): string;
|
|
|
2397
2578
|
* Stable error-code identifiers, keyed by their symbolic name.
|
|
2398
2579
|
*
|
|
2399
2580
|
* Values are namespaced under `notification.*` and never change once published —
|
|
2400
|
-
* consumers branch on them to localize messages. The
|
|
2581
|
+
* consumers branch on them to localize messages. The 24 entries cover the email,
|
|
2401
2582
|
* template, OTP, SMS, push, audit, channel-config and scoping failure surfaces.
|
|
2402
2583
|
*/
|
|
2403
2584
|
declare const NOTIFICATION_ERROR_CODES: {
|
|
@@ -2411,6 +2592,7 @@ declare const NOTIFICATION_ERROR_CODES: {
|
|
|
2411
2592
|
readonly TEMPLATE_RENDER_FAILED: "notification.template_render_failed";
|
|
2412
2593
|
readonly OTP_STORAGE_NOT_CONFIGURED: "notification.otp_storage_not_configured";
|
|
2413
2594
|
readonly OTP_EMAIL_DELIVERY_NOT_CONFIGURED: "notification.otp_email_delivery_not_configured";
|
|
2595
|
+
readonly OTP_MANUAL_DELIVERY_UNAVAILABLE: "notification.otp_manual_delivery_unavailable";
|
|
2414
2596
|
readonly OTP_COOLDOWN_ACTIVE: "notification.otp_cooldown_active";
|
|
2415
2597
|
readonly OTP_NOT_FOUND: "notification.otp_not_found";
|
|
2416
2598
|
readonly OTP_EXPIRED: "notification.otp_expired";
|
|
@@ -2473,6 +2655,7 @@ declare const NOTIFICATION_ERROR_DEFINITIONS: {
|
|
|
2473
2655
|
readonly status: HttpStatus.PAYLOAD_TOO_LARGE;
|
|
2474
2656
|
readonly message: "Email attachments exceed size limit";
|
|
2475
2657
|
};
|
|
2658
|
+
/** Reserved: `to` is not validated, so the library never throws this code. */
|
|
2476
2659
|
readonly EMAIL_INVALID_RECIPIENT: {
|
|
2477
2660
|
readonly code: "notification.email_invalid_recipient";
|
|
2478
2661
|
readonly status: HttpStatus.BAD_REQUEST;
|
|
@@ -2503,26 +2686,35 @@ declare const NOTIFICATION_ERROR_DEFINITIONS: {
|
|
|
2503
2686
|
readonly status: HttpStatus.INTERNAL_SERVER_ERROR;
|
|
2504
2687
|
readonly message: "OTP email delivery requested but email channel not configured";
|
|
2505
2688
|
};
|
|
2689
|
+
readonly OTP_MANUAL_DELIVERY_UNAVAILABLE: {
|
|
2690
|
+
readonly code: "notification.otp_manual_delivery_unavailable";
|
|
2691
|
+
readonly status: HttpStatus.BAD_REQUEST;
|
|
2692
|
+
readonly message: "OTP manual delivery is unavailable while otp.codeSecret is set";
|
|
2693
|
+
};
|
|
2506
2694
|
readonly OTP_COOLDOWN_ACTIVE: {
|
|
2507
2695
|
readonly code: "notification.otp_cooldown_active";
|
|
2508
2696
|
readonly status: HttpStatus.TOO_MANY_REQUESTS;
|
|
2509
2697
|
readonly message: "Resend cooldown is active";
|
|
2510
2698
|
};
|
|
2699
|
+
/** Reserved: `verify()` returns `{ valid: false, reason: 'not_found' }` instead of throwing. */
|
|
2511
2700
|
readonly OTP_NOT_FOUND: {
|
|
2512
2701
|
readonly code: "notification.otp_not_found";
|
|
2513
2702
|
readonly status: HttpStatus.NOT_FOUND;
|
|
2514
2703
|
readonly message: "OTP not found or expired";
|
|
2515
2704
|
};
|
|
2705
|
+
/** Reserved: an expired code is reported as `not_found`. */
|
|
2516
2706
|
readonly OTP_EXPIRED: {
|
|
2517
2707
|
readonly code: "notification.otp_expired";
|
|
2518
2708
|
readonly status: HttpStatus.GONE;
|
|
2519
2709
|
readonly message: "OTP code expired";
|
|
2520
2710
|
};
|
|
2711
|
+
/** Reserved: `verify()` returns `{ valid: false, reason: 'max_attempts' }` instead of throwing. */
|
|
2521
2712
|
readonly OTP_MAX_ATTEMPTS_EXCEEDED: {
|
|
2522
2713
|
readonly code: "notification.otp_max_attempts_exceeded";
|
|
2523
2714
|
readonly status: HttpStatus.TOO_MANY_REQUESTS;
|
|
2524
2715
|
readonly message: "Maximum OTP attempts exceeded";
|
|
2525
2716
|
};
|
|
2717
|
+
/** Reserved: `verify()` returns `{ valid: false, reason: 'invalid_code' }` instead of throwing. */
|
|
2526
2718
|
readonly OTP_INVALID_CODE: {
|
|
2527
2719
|
readonly code: "notification.otp_invalid_code";
|
|
2528
2720
|
readonly status: HttpStatus.UNAUTHORIZED;
|
|
@@ -2533,26 +2725,31 @@ declare const NOTIFICATION_ERROR_DEFINITIONS: {
|
|
|
2533
2725
|
readonly status: HttpStatus.BAD_REQUEST;
|
|
2534
2726
|
readonly message: "Invalid OTP length config";
|
|
2535
2727
|
};
|
|
2728
|
+
/** Reserved: the SMS channel is not implemented. */
|
|
2536
2729
|
readonly SMS_PROVIDER_NOT_CONFIGURED: {
|
|
2537
2730
|
readonly code: "notification.sms_provider_not_configured";
|
|
2538
2731
|
readonly status: HttpStatus.INTERNAL_SERVER_ERROR;
|
|
2539
2732
|
readonly message: "SMS provider not configured";
|
|
2540
2733
|
};
|
|
2734
|
+
/** Reserved: the SMS channel is not implemented. */
|
|
2541
2735
|
readonly SMS_SEND_FAILED: {
|
|
2542
2736
|
readonly code: "notification.sms_send_failed";
|
|
2543
2737
|
readonly status: HttpStatus.BAD_GATEWAY;
|
|
2544
2738
|
readonly message: "Failed to send SMS";
|
|
2545
2739
|
};
|
|
2740
|
+
/** Reserved: the SMS channel is not implemented. */
|
|
2546
2741
|
readonly SMS_INVALID_RECIPIENT: {
|
|
2547
2742
|
readonly code: "notification.sms_invalid_recipient";
|
|
2548
2743
|
readonly status: HttpStatus.BAD_REQUEST;
|
|
2549
2744
|
readonly message: "Invalid phone number";
|
|
2550
2745
|
};
|
|
2746
|
+
/** Reserved: the push channel is not implemented. */
|
|
2551
2747
|
readonly PUSH_PROVIDER_NOT_CONFIGURED: {
|
|
2552
2748
|
readonly code: "notification.push_provider_not_configured";
|
|
2553
2749
|
readonly status: HttpStatus.INTERNAL_SERVER_ERROR;
|
|
2554
2750
|
readonly message: "Push provider not configured";
|
|
2555
2751
|
};
|
|
2752
|
+
/** Reserved: the push channel is not implemented. */
|
|
2556
2753
|
readonly PUSH_SEND_FAILED: {
|
|
2557
2754
|
readonly code: "notification.push_send_failed";
|
|
2558
2755
|
readonly status: HttpStatus.BAD_GATEWAY;
|