@bymax-one/nest-notification 1.0.0

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 ADDED
@@ -0,0 +1,70 @@
1
+ # Changelog
2
+
3
+ All notable changes to `@bymax-one/nest-notification` will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [1.0.0] - 2026-07-30
11
+
12
+ First public release. Email + OTP channels, multi-tenant by design, pluggable
13
+ providers and storage, zero runtime dependencies, and never an `@prisma/client`
14
+ import.
15
+
16
+ ### Added
17
+
18
+ - **`BymaxNotificationModule`** — dynamic NestJS 11 module with `forRoot` and
19
+ `forRootAsync` (`useFactory`). Conditional provider registration: only the channels
20
+ you configure are wired into the container; configuring an unconfigured channel throws
21
+ at startup.
22
+ - **Email channel** — `EmailService` plus the `IEmailProvider` contract. Bundled
23
+ `ResendEmailProvider` (Resend) and `NoOpEmailProvider` (dev/test — logs subject and
24
+ recipient only, never the body). Attachment size guard (`maxAttachmentBytes`, default
25
+ 10 MiB).
26
+ - **OTP channel** — `OtpService` (`generate` / `verify` / `consume` / status) plus the
27
+ `IOtpStorage` contract. Codes via `node:crypto.randomInt` (numeric / alpha /
28
+ alphanumeric, built character-by-character to preserve leading zeros and avoid integer
29
+ overflow); verification via `crypto.timingSafeEqual`. **Atomic** attempt counting
30
+ (`consumeAttempt`) and resend cooldown (`tryAcquireCooldown`, `SET NX EX`) so
31
+ `maxAttempts` and anti-resend cannot be bypassed under concurrency.
32
+ - **Reference storages** — `RedisOtpStorage` (keys hashed `sha256(tenantId:recipient)`,
33
+ Lua-atomic primitives) and `InMemoryOtpStorage` (single-threaded atomicity for dev/test).
34
+ - **Templating** — `IEmailTemplateRenderer` plus the bundled `DefaultTemplateRenderer`
35
+ (`{{var}}` interpolation with automatic HTML escaping in the HTML body; subject and
36
+ plaintext left raw). `CANONICAL_EMAIL_TEMPLATES` constant for stable template names.
37
+ - **Multi-tenant** — every operation scoped by `tenantId`; SHA-256 store keys;
38
+ `tenantIdResolver` (anti-spoofing) read by the audit interceptor as the trusted source.
39
+ - **Audit log** — opt-in `INotificationLogRepository` (fire-and-forget,
40
+ `swallowErrors: true` by default; optional `maskRecipient`) and a
41
+ `NotificationAuditInterceptor` for HTTP-level `sent` / `failed` entries. OTP codes are
42
+ never written to any audit entry.
43
+ - **`NotificationService`** — uniform dispatch façade over the configured channels.
44
+ - **`NotificationException`** + a 22-entry error catalog (`NOTIFICATION_ERROR_DEFINITIONS`)
45
+ with stable codes and HTTP statuses; response shape `{ error: { code, message, details } }`.
46
+ - **`./shared` subpath** — zero-dependency types and constants (`NOTIFICATION_ERROR_CODES`,
47
+ `DEFAULT_TTLS`, `OtpPurpose`, `NotificationChannel`) importable in any environment.
48
+ - **`./react` subpath** — `useOtpInput` (multi-slot input with paste, Backspace, and
49
+ Arrow navigation) and `useOtpCountdown` (expiry countdown) hooks. UX/state only — no
50
+ HTTP client, no Node builtins.
51
+ - **Adapter examples** — Handlebars, MJML, and React Email renderers
52
+ (`docs/templates/`); a Prisma `INotificationLogRepository` and schema fragment
53
+ (`docs/schemas/`). Not imported by the library.
54
+ - **Supply chain** — published with npm provenance (OIDC); CodeQL `security-extended`,
55
+ OpenSSF Scorecard, and a `check:no-prisma` CI gate.
56
+
57
+ ### Not implemented
58
+
59
+ The interfaces below ship so you can plan your dispatch code paths against them,
60
+ but the services behind them do not exist yet and configuring those channels is
61
+ rejected at startup rather than failing on the first send.
62
+
63
+ - **SMS channel** — `ISmsProvider` is declared; configuring the `sms` channel throws.
64
+ - **Push channel** — `IPushProvider` is declared on the same terms; configuring the
65
+ `push` channel throws.
66
+ - **`forRootAsync` `useClass` / `useExisting`** — only `useFactory` is wired.
67
+ - **Multi-provider failover and routing.**
68
+
69
+ [Unreleased]: https://github.com/bymaxone/nest-notification/compare/v1.0.0...HEAD
70
+ [1.0.0]: https://github.com/bymaxone/nest-notification/releases/tag/v1.0.0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Bymax One
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.