backend-manager 5.6.0 → 5.6.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/.claude/scheduled_tasks.lock +1 -0
- package/CHANGELOG.md +21 -0
- package/CLAUDE.md +1 -0
- package/docs/audit.md +70 -0
- package/docs/build-system.md +2 -0
- package/docs/email-system.md +1 -1
- package/docs/test-boot-layer.md +2 -0
- package/package.json +10 -4
- package/test/email/validation.js +103 -11
- package/test/routes/marketing/webhook.js +70 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"sessionId":"c926cd91-919f-483f-bb49-db72f77f9e2e","pid":30061,"procStart":"Thu Jun 11 11:57:09 2026","acquiredAt":1781179809978}
|
package/CHANGELOG.md
CHANGED
|
@@ -14,6 +14,23 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|
|
14
14
|
- `Fixed` for any bug fixes.
|
|
15
15
|
- `Security` in case of vulnerabilities.
|
|
16
16
|
|
|
17
|
+
# [5.6.2] - 2026-06-11
|
|
18
|
+
|
|
19
|
+
### Fixed
|
|
20
|
+
- **4 stale framework tests aligned with shipped v5.5.4–v5.5.6 validation behavior.** The default `npx mgr test` run failed 4 tests whose expectations predated intentional source changes: `test/email/validation.js` still expected all-numeric (`123456@`) and short letter+number (`a123@`) local parts to be blocked (both patterns were removed in v5.5.6 after NeverBounce confirmed real users — QQ emails, real Gmail accounts — were being blocked; tests renamed `localpart-all-numeric-allowed` / `localpart-letter-plus-numbers-allowed`) and expected the pre-v5.5.5 `DEFAULT_CHECKS`/`ALL_CHECKS` lists (now include `typo`, and `dns` in `ALL_CHECKS`); `test/routes/marketing/webhook.js`'s bounce test sent no `bounce_classification`, which v5.5.4 deliberately skips (renamed `sendgrid-hard-bounce-event-handled`, now sends `'Invalid Address'`).
|
|
21
|
+
|
|
22
|
+
### Added
|
|
23
|
+
- **Suite coverage for the v5.5.5 `typo` + `dns` email validation checks** (previously only covered by the standalone `validation.test.js` script): typo-domain blocking (`gamil.com`, `gmail.con`) + correct-domain pass-through, dns-not-in-default-checks, an offline-safe dns positive (network errors skip, never block), and an extended-gated (`TEST_EXTENDED_MODE`) dns negative for nonexistent domains.
|
|
24
|
+
- **Suite coverage for the v5.5.4 bounce-classification filter**: `dropped` + `'Invalid Address'` revokes, technical bounce (`'Technical Failure'`) skipped, and unclassified bounce skipped — locking in that sender-side bounces never revoke recipient consent.
|
|
25
|
+
|
|
26
|
+
# [5.6.1] - 2026-06-11
|
|
27
|
+
|
|
28
|
+
### Added
|
|
29
|
+
- **`docs/audit.md` — full-audit check catalog (`/omega:bem audit`).** ID'd, severity-graded checks with scope auto-detect (consumer vs framework via `functions/package.json`): mirrored universal checks (U-01..U-14 — tests at every surface, sanitization, secrets incl. `service-account.json`, config canon, doc parity, dead/legacy patterns, dep health, …), BEM-specific checks (BEM-01..BEM-09 — name-matched context-object schemas, the required-vs-default footgun, ownership checks + `assistant.respond()`, index.js/rewrites wiring, Firestore canon, usage helper + rate limits, composite indexes, auth gates, rules coverage), and framework-repo checks (F-01..F-04). Findings persist to `functions/.temp/audit/claude-audit.md`; fixes run as a severity-ordered TodoWrite loop ending with a green `npx mgr test`. Wired to the `omega:bem` router's Audit process; `docs/audit.md` is mirrored across UJM/BXM/EM. Indexed in CLAUDE.md.
|
|
30
|
+
|
|
31
|
+
### Changed
|
|
32
|
+
- **package.json `keywords` corrected** — replaced the thin generic set (`cli`, `backend manager`, `firebase`) with accurate, discovery-oriented ones (`firebase`, `firebase-functions`, `cloud-functions`, `firestore`, `backend`, `serverless`, `api`, `express`, `cli`). npm-listing metadata only; no behavior change. Mirrored across UJM/BXM/EM.
|
|
33
|
+
|
|
17
34
|
# [5.6.0] - 2026-06-11
|
|
18
35
|
|
|
19
36
|
### Added
|
|
@@ -31,6 +48,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|
|
31
48
|
- **`docs/testing.md` renamed `docs/test-framework.md`** (H1 `# Testing` → `# Test Framework`) for cross-framework doc-file parity — EM/BXM/UJM all name their test reference `docs/test-framework.md`, and the mirrored docs must match down to the file name. All references updated (`CLAUDE.md`, `README.md`, `docs/*.md` cross-links, `src/defaults/CLAUDE.md`, `src/defaults/test/_init.js`, historical CHANGELOG links).
|
|
32
49
|
- **Log files renamed for cross-framework parity.** `functions/serve.log` → `functions/dev.log` (the `npx mgr serve` dev-server output) and `functions/logs.log` → `functions/production.log` (the `npx mgr logs` Cloud Logging output). The `dev`/`test` names now match EM/BXM/UJM; `emulator.log` and `test.log` are unchanged. BEM logs still live in `functions/` (not `logs/`) — that directory is a deliberate exception so they sit beside firebase-tools' own `*-debug.log` files. The watcher reset sentinel `serve.log.reset` is correspondingly `dev.log.reset` (internal, in `.temp/`).
|
|
33
50
|
|
|
51
|
+
### Fixed
|
|
52
|
+
- **`npm publish` vs the fixture's runtime symlinks.** New `prepublishOnly` script removes `src/test/fixtures/firebase-project/functions/node_modules` before packing — the self-test's `backend-manager` symlink points back at the repo root, and prepare-package's publish-time cleanup walk (`jetpack.find` with a top-level-only `!node_modules/**` exclusion) followed the cycle until `ENAMETOOLONG`. The symlinks are throwaway runtime artifacts; the next self-test run regenerates them via `linkFixtureDeps()`.
|
|
53
|
+
- **Fixture `.firebaserc` re-included over the global `.gitignore` rule** (`!src/test/fixtures/firebase-project/.firebaserc`) — the emulator boots with no `--project` flag and resolves the demo project from `.firebaserc`, so a fresh clone's self-test would have failed without it.
|
|
54
|
+
|
|
34
55
|
# [5.5.4] - 2026-06-09
|
|
35
56
|
|
|
36
57
|
### Fixed
|
package/CLAUDE.md
CHANGED
|
@@ -135,6 +135,7 @@ Deep references live in `docs/`. **Whenever you make a behavioral change, update
|
|
|
135
135
|
- [docs/code-patterns.md](docs/code-patterns.md) — short-circuit returns, logical operators on new lines, Firestore shorthand, template-string requires, fs-jetpack preference
|
|
136
136
|
- [docs/file-naming.md](docs/file-naming.md) — naming table for routes, schemas, API commands, events, cron jobs, hooks
|
|
137
137
|
- [docs/common-mistakes.md](docs/common-mistakes.md) — anti-pattern checklist (don't modify Manager internals, always await, increment-before-update, etc.)
|
|
138
|
+
- [docs/audit.md](docs/audit.md) — full-audit check catalog (U-xx universal / BEM-xx / F-xx IDs with severity + scope), protocol + fix loop
|
|
138
139
|
- [docs/key-files.md](docs/key-files.md) — quick lookup for the most-touched files (Manager, helpers, auth events, cron, payment processors, CLI commands)
|
|
139
140
|
- [docs/cli-output.md](docs/cli-output.md) — shared CLI styling module (`src/cli/utils/ui.js`): OMEGA-style banner/dividers/sections/status symbols + the `Summary` block; used by `setup`, adoptable by other commands
|
|
140
141
|
- [docs/environment-detection.md](docs/environment-detection.md) — `getEnvironment()` returns `'development' | 'testing' | 'production'` (mutually exclusive); gate side effects on the INTENTIONAL check (`isProduction()` for prod-only, `isDevelopment() || isTesting()` for local-or-test) — never `!isDevelopment()`. Plus the URL helper convention (always `Manager.getApiUrl()` — auto-resolves local in dev+test, never read `project.apiUrl`)
|
package/docs/audit.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Audit Workflow
|
|
2
|
+
|
|
3
|
+
Full-project audit for BEM — runs against a CONSUMER backend or the FRAMEWORK repo itself (scope auto-detected). Invoked via the `omega:bem` skill (`/omega:bem audit`) or any "audit this backend/project" request.
|
|
4
|
+
|
|
5
|
+
Every check has a stable ID, a severity, and a scope. Findings are reported as `ID @ file:line`, fixed one at a time, then re-verified. The tables below do NOT restate the rules — each check links to the doc that owns the rule and the fix.
|
|
6
|
+
|
|
7
|
+
## Protocol
|
|
8
|
+
|
|
9
|
+
1. **Detect scope** — read `package.json` (consumer: `functions/package.json`): `name` is `backend-manager` → **framework audit** (U + BEM + F checks); `backend-manager` in (dev)dependencies → **consumer audit** (U + BEM checks).
|
|
10
|
+
2. **Run the catalog** — every check matching the scope. Search with Grep/Glob/Read over `functions/` (`routes/`, `schemas/`, `hooks/`, `index.js`), `test/`, and config files; ALWAYS exclude `node_modules/`, `dist/`, `_legacy/`, `_backup/`. Record each finding as `ID @ file:line` + a one-line description.
|
|
11
|
+
3. **Persist the report** — write the findings list to `functions/.temp/audit/claude-audit.md` (BEM's `functions/`-local convention, like its logs) so a long fix loop survives session breaks. Summarize counts by severity in chat.
|
|
12
|
+
4. **Fix loop** — TodoWrite per finding, highest severity first, ONE at a time: mark in-progress → root cause → fix → verify → complete. Ask before structural or destructive fixes (file deletions, schema reshapes, data migrations).
|
|
13
|
+
5. **Re-verify** — re-run every check that produced findings until clean; finish with `npx mgr test` from `functions/` (must be green — it auto-starts its own emulator if needed).
|
|
14
|
+
6. **Doc parity** — if fixes changed behavior, update README / CLAUDE.md / `docs/<topic>.md` / CHANGELOG in the same change set.
|
|
15
|
+
|
|
16
|
+
Severity: **CRIT** security or broken functionality · **HIGH** hard-rule violation · **MED** convention drift · **LOW** optional improvement.
|
|
17
|
+
Scope: **C** consumer · **F** framework repo · **B** both.
|
|
18
|
+
|
|
19
|
+
## Universal checks (U-xx)
|
|
20
|
+
|
|
21
|
+
Mirrored across all four OMEGA frameworks (UJM / BEM / BXM / EM) — same ID means the same check everywhere.
|
|
22
|
+
|
|
23
|
+
| ID | Sev | Scope | Check |
|
|
24
|
+
|----|-----|-------|-------|
|
|
25
|
+
| U-01 | HIGH | B | Every feature has tests at EVERY surface it exposes — handler suites + `http.as(...)` route round-trips + rules suites; never mocked, real emulator only ([test-framework.md](test-framework.md)) |
|
|
26
|
+
| U-02 | HIGH | B | Test hygiene — side-effect tests use dedicated `journey-*` accounts; real-external-API tests gated behind `TEST_EXTENDED_MODE` in-source (not mocked); files export `{ description, type, tests }` (no raw Mocha); no trailing cleanup steps ([test-framework.md](test-framework.md)) |
|
|
27
|
+
| U-03 | CRIT | B | Sanitization — middleware is trim-only by default; HTML strip via opt-in `{ sanitize: true }`; every HTML-insertion site calls `utilities.sanitize()` ([sanitization.md](sanitization.md)) |
|
|
28
|
+
| U-04 | HIGH | B | Firebase ownership — server code uses `firebase-admin` via Manager (correct here); NO client `firebase` SDK in functions code; consuming frontends go through web-manager ([CLAUDE.md](../CLAUDE.md) §Dependency Resolution) |
|
|
29
|
+
| U-05 | HIGH | C | No BEM transitive deps installed directly in `functions/package.json` — use `Manager.require(name)` ([CLAUDE.md](../CLAUDE.md) §Dependency Resolution) |
|
|
30
|
+
| U-06 | HIGH | B | Env behavior gated on the INTENTIONAL check — `isProduction()` or `isDevelopment() \|\| isTesting()`, never `!isDevelopment()`; always `Manager.getApiUrl()`, never the cached `Manager.project.apiUrl` ([environment-detection.md](environment-detection.md)) |
|
|
31
|
+
| U-07 | HIGH | B | Config canon — `backend-manager-config.json` matches the documented shape; canonical cross-framework blocks (`brand`, payment products, …) not reinvented ([architecture.md](architecture.md), [payment-system.md](payment-system.md)) |
|
|
32
|
+
| U-08 | CRIT | B | No private credentials committed — `service-account.json`, `.env` secrets, API keys (Stripe `sk_`, SendGrid `SG.`, …); `.gitignore` covers them. (The Firebase WEB `apiKey` is public by design — do NOT flag it.) |
|
|
33
|
+
| U-09 | HIGH | B | Source discipline — no live code referencing `_legacy/` / `_backup/`; framework edits in `src/` (never `dist/`) ([common-mistakes.md](common-mistakes.md)) |
|
|
34
|
+
| U-10 | MED | B | Doc parity — README / CLAUDE.md / `docs/` / CHANGELOG match shipped behavior; CLAUDE.md < 250 lines; the docs index lists every `docs/*.md`; no stale names for renamed commands/patterns |
|
|
35
|
+
| U-11 | MED | B | SSOT/DRY — no duplicated constants/config/logic; one authoritative home per value, imported everywhere else |
|
|
36
|
+
| U-12 | MED | B | JS conventions — file structure, JSDoc, short-circuit returns, leading logical operators, `fs-jetpack`, one `module.exports` per file ([code-patterns.md](code-patterns.md) + global `js:patterns` skill) |
|
|
37
|
+
| U-13 | MED | B | Dead code & stale patterns — no orphaned files nothing imports; no leftovers of migrated-away formats (constructor routes, tiered schemas, `Manager.config.*` reads — [migration.md](migration.md)); inventory TODO/FIXME (report only) |
|
|
38
|
+
| U-14 | LOW | B | Dependency health — review `npm outdated` / `npm audit` (in `functions/`); apply fixes via the `general:update-packages` workflow (includes supply-chain checks) |
|
|
39
|
+
|
|
40
|
+
## BEM-specific checks
|
|
41
|
+
|
|
42
|
+
| ID | Sev | Scope | Check |
|
|
43
|
+
|----|-----|-------|-------|
|
|
44
|
+
| BEM-01 | HIGH | B | Every custom route has a name-matched schema; handlers are context-object exports (`async ({ Manager, assistant, … }) => {}`) — no legacy constructor routes ([routes.md](routes.md), [schemas.md](schemas.md)) |
|
|
45
|
+
| BEM-02 | HIGH | B | Schema field rules — never `required: true` + `default` together (required is checked BEFORE defaults; use `min: 1` for path-extracted IDs); flat schema with in-function plan branching, no tier arrays ([schemas.md](schemas.md)) |
|
|
46
|
+
| BEM-03 | HIGH | B | Route handlers — ownership checks on PUT/DELETE; plural-noun route names; `assistant.respond()` only (never `res.send()`) ([routes.md](routes.md), [common-operations.md](common-operations.md)) |
|
|
47
|
+
| BEM-04 | HIGH | C | Wiring — every route exported in `functions/index.js`; `firebase.json` rewrites use bracket syntax, ordered most-specific-first ([routes.md](routes.md)) |
|
|
48
|
+
| BEM-05 | HIGH | B | Firestore canon — NO subcollections; path-string `.doc('users/abc')`; batched collection reads (~500, cursor pagination); timestamps under `metadata.{created,updated}`; mirror-the-doc responses; delete-don't-redact ([firestore.md](firestore.md)) |
|
|
49
|
+
| BEM-06 | HIGH | B | Usage — never read/write `{doc}.usage.*` manually, always the `usage` helper; expensive/abusable routes carry usage validation or rate limiting ([usage-rate-limiting.md](usage-rate-limiting.md)) |
|
|
50
|
+
| BEM-07 | MED | B | Composite indexes — every compound query (`where` + `orderBy`, multiple `where`s) is registered in the required-indexes SSOT ([CLAUDE.md](../CLAUDE.md) §File Conventions) |
|
|
51
|
+
| BEM-08 | HIGH | B | Auth gates — routes resolve the caller via `assistant`/`user` before acting; admin-only routes verify admin status ([common-operations.md](common-operations.md), [routes.md](routes.md)) |
|
|
52
|
+
| BEM-09 | HIGH | B | Rules coverage — `firestore.rules` changes ship a rules suite (`rules.asAccount` / `expectSuccess` / `expectFailure`) ([test-framework.md](test-framework.md)) |
|
|
53
|
+
|
|
54
|
+
## Framework-repo checks (F-xx)
|
|
55
|
+
|
|
56
|
+
Only when auditing the BEM repo itself. Mirrored across the four frameworks.
|
|
57
|
+
|
|
58
|
+
| ID | Sev | Check |
|
|
59
|
+
|----|-----|-------|
|
|
60
|
+
| F-01 | MED | Sister parity — mirrored sections (config shapes, test contract, CLAUDE.md skeleton, shared env/test conventions) in sync with UJM / BXM / EM; deviations are deliberate and documented |
|
|
61
|
+
| F-02 | HIGH | Consumer-shipped defaults in sync — what `npx mgr setup` scaffolds matches current conventions and docs |
|
|
62
|
+
| F-03 | MED | Docs completeness — every `docs/*.md` indexed in CLAUDE.md; every subsystem has a doc; no "(planned)" links for things that have shipped |
|
|
63
|
+
| F-04 | HIGH | `npx mgr test mgr:` green before treating the audit as complete |
|
|
64
|
+
|
|
65
|
+
## See also
|
|
66
|
+
|
|
67
|
+
- [schemas.md](schemas.md) — the required-vs-default footgun behind BEM-02
|
|
68
|
+
- [firestore.md](firestore.md) — the data canon behind BEM-05
|
|
69
|
+
- [migration.md](migration.md) — the legacy formats U-13 hunts for
|
|
70
|
+
- [test-framework.md](test-framework.md) — the surfaces behind U-01 / U-02 / BEM-09
|
package/docs/build-system.md
CHANGED
|
@@ -16,6 +16,8 @@ There are no build modes — environment behavior is governed by emulator vs pro
|
|
|
16
16
|
|
|
17
17
|
The BEM library itself has one build step: `npm run prepare` copies `src/` → `dist/` via prepare-package (`npm run prepare:watch` for watch mode). Consumers always require from `dist/`. This mirrors the framework-side prepare step in EM/BXM/UJM.
|
|
18
18
|
|
|
19
|
+
At publish time, a `prepublishOnly` script first removes the self-test fixture's runtime `node_modules` (`src/test/fixtures/firebase-project/functions/node_modules`) — its `backend-manager` symlink points back at the repo root, which would send prepare-package's publish-time cleanup walk into an infinite cycle. The symlinks are throwaway; the next `npx mgr test` self-test regenerates them (see [test-boot-layer.md](test-boot-layer.md)).
|
|
20
|
+
|
|
19
21
|
## Log files
|
|
20
22
|
|
|
21
23
|
CLI commands tee output to `functions/*.log` (`dev.log`, `emulator.log`, `test.log`, `production.log`). Full reference: [logging.md](logging.md).
|
package/docs/email-system.md
CHANGED
|
@@ -284,7 +284,7 @@ All email tests live under `test/email/`, mirroring the source at `src/manager/l
|
|
|
284
284
|
|---|---|---|
|
|
285
285
|
| `templates.js` | MJML rendering for all 4 email templates (11 tests) | No |
|
|
286
286
|
| `transactional.js` | Transactional email building (assertions on output shape) | No |
|
|
287
|
-
| `validation.js` | Email format/disposable/corporate/local-part/typo/dns checks (
|
|
287
|
+
| `validation.js` | Email format/disposable/corporate/local-part/typo/dns checks (52 tests) | No |
|
|
288
288
|
| `transactional-send.js` | Single transactional email send via SendGrid | Yes |
|
|
289
289
|
| `campaign-send.js` | Marketing campaign send with title + CTA + discount code | Yes |
|
|
290
290
|
| `feedback-and-plain-send.js` | Feedback + plain template visual test sends | Yes |
|
package/docs/test-boot-layer.md
CHANGED
|
@@ -44,6 +44,8 @@ module.exports = {
|
|
|
44
44
|
|
|
45
45
|
**Runtime-only, gitignored** (never committed): before boot, the test command symlinks the local `backend-manager` (+ `firebase-admin`/`firebase-functions` from BEM's own `node_modules`) into the fixture's `functions/node_modules`, injects the fixture admin keys into the env, and generates a **throwaway RSA `service-account.json`** (emulator-only — a `demo-` project never authenticates against Google). All of this lives in `setupSelfTest()` / `linkFixtureDeps()` / `ensureFixtureServiceAccount()` in [src/cli/commands/test.js](../src/cli/commands/test.js).
|
|
46
46
|
|
|
47
|
+
Two packaging details keep the fixture sound: the fixture's `.firebaserc` is **re-included over the repo's global `.firebaserc` ignore** (the emulator boots with no `--project` flag, so it resolves `demo-backend-manager` from that file — a fresh clone needs it), and a `prepublishOnly` script **removes the runtime symlinks before `npm publish`** (the `backend-manager` symlink points back at the repo root, which would loop prepare-package's publish-time tree walk; the next self-test run relinks them).
|
|
48
|
+
|
|
47
49
|
## `BEM_TEST_BOOT_PROJECT`
|
|
48
50
|
|
|
49
51
|
| Env | Purpose |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "backend-manager",
|
|
3
|
-
"version": "5.6.
|
|
3
|
+
"version": "5.6.2",
|
|
4
4
|
"description": "Quick tools for developing Firebase functions",
|
|
5
5
|
"main": "src/manager/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -30,9 +30,15 @@
|
|
|
30
30
|
"url": "git+https://github.com/itw-creative-works/backend-manager.git"
|
|
31
31
|
},
|
|
32
32
|
"keywords": [
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
33
|
+
"firebase",
|
|
34
|
+
"firebase-functions",
|
|
35
|
+
"cloud-functions",
|
|
36
|
+
"firestore",
|
|
37
|
+
"backend",
|
|
38
|
+
"serverless",
|
|
39
|
+
"api",
|
|
40
|
+
"express",
|
|
41
|
+
"cli"
|
|
36
42
|
],
|
|
37
43
|
"author": "ITW Creative Works",
|
|
38
44
|
"license": "ISC",
|
package/test/email/validation.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Test: Email validation library (libraries/email/validation.js)
|
|
3
|
-
* Unit tests for format, local part, disposable domain, and mailbox checks
|
|
3
|
+
* Unit tests for format, local part, disposable domain, corporate domain, typo domain, DNS, and mailbox checks
|
|
4
4
|
*
|
|
5
|
-
* Format, local part, and
|
|
5
|
+
* Format, local part, disposable, corporate, and typo tests always run (free, sync, offline-safe).
|
|
6
|
+
* DNS negative tests require TEST_EXTENDED_MODE (live DNS resolution).
|
|
6
7
|
* Mailbox verification tests require TEST_EXTENDED_MODE + NEVERBOUNCE_API_KEY or ZEROBOUNCE_API_KEY.
|
|
7
8
|
*/
|
|
8
9
|
const { validate, isDisposable, isCorporate, DEFAULT_CHECKS, ALL_CHECKS } = require('../../src/manager/libraries/email/validation.js');
|
|
@@ -115,15 +116,17 @@ module.exports = {
|
|
|
115
116
|
},
|
|
116
117
|
|
|
117
118
|
{
|
|
118
|
-
name: 'localpart-all-numeric-
|
|
119
|
+
name: 'localpart-all-numeric-allowed',
|
|
119
120
|
timeout: 5000,
|
|
120
121
|
|
|
121
122
|
async run({ assert }) {
|
|
123
|
+
// All-numeric local parts are legitimate (QQ emails like 1549482839@qq.com,
|
|
124
|
+
// student IDs) — the ^\d+$ pattern was removed in v5.5.6 after NeverBounce
|
|
125
|
+
// confirmed real users were being blocked.
|
|
122
126
|
const result = await validate('123456@gmail.com');
|
|
123
127
|
|
|
124
|
-
assert.equal(result.valid,
|
|
125
|
-
assert.propertyEquals(result, 'checks.localPart.
|
|
126
|
-
assert.propertyEquals(result, 'checks.localPart.reason', 'Matches junk pattern', 'Should match junk pattern');
|
|
128
|
+
assert.equal(result.valid, true, 'All-numeric local part should be allowed');
|
|
129
|
+
assert.propertyEquals(result, 'checks.localPart.valid', true, 'localPart check should pass');
|
|
127
130
|
},
|
|
128
131
|
},
|
|
129
132
|
|
|
@@ -164,14 +167,17 @@ module.exports = {
|
|
|
164
167
|
},
|
|
165
168
|
|
|
166
169
|
{
|
|
167
|
-
name: 'localpart-letter-plus-numbers-
|
|
170
|
+
name: 'localpart-letter-plus-numbers-allowed',
|
|
168
171
|
timeout: 5000,
|
|
169
172
|
|
|
170
173
|
async run({ assert }) {
|
|
174
|
+
// Short letter + numbers local parts are legitimate (real Gmail users like
|
|
175
|
+
// mi1925973, hk9526802) — the ^[a-z]{1,2}\d+$ pattern was removed in v5.5.6
|
|
176
|
+
// after NeverBounce confirmed real users were being blocked.
|
|
171
177
|
const result = await validate('a123@gmail.com');
|
|
172
178
|
|
|
173
|
-
assert.equal(result.valid,
|
|
174
|
-
assert.propertyEquals(result, 'checks.localPart.
|
|
179
|
+
assert.equal(result.valid, true, 'Single letter + numbers should be allowed');
|
|
180
|
+
assert.propertyEquals(result, 'checks.localPart.valid', true, 'localPart check should pass');
|
|
175
181
|
},
|
|
176
182
|
},
|
|
177
183
|
|
|
@@ -370,6 +376,49 @@ module.exports = {
|
|
|
370
376
|
},
|
|
371
377
|
},
|
|
372
378
|
|
|
379
|
+
// --- Typo domain checks ---
|
|
380
|
+
|
|
381
|
+
{
|
|
382
|
+
name: 'typo-gamil-blocked',
|
|
383
|
+
timeout: 5000,
|
|
384
|
+
|
|
385
|
+
async run({ assert }) {
|
|
386
|
+
const result = await validate('rachel.greene@gamil.com');
|
|
387
|
+
|
|
388
|
+
assert.equal(result.valid, false, 'gamil.com should be blocked as a typo of gmail.com');
|
|
389
|
+
assert.propertyEquals(result, 'checks.typo.valid', false, 'Typo check should fail');
|
|
390
|
+
assert.propertyEquals(result, 'checks.typo.matchedPrefix', 'gamil.', 'Should report the matched prefix');
|
|
391
|
+
assert.propertyEquals(result, 'checks.typo.reason', 'Likely misspelled domain', 'Should have human-readable reason');
|
|
392
|
+
},
|
|
393
|
+
},
|
|
394
|
+
|
|
395
|
+
{
|
|
396
|
+
name: 'typo-gmail-con-blocked',
|
|
397
|
+
timeout: 5000,
|
|
398
|
+
|
|
399
|
+
async run({ assert }) {
|
|
400
|
+
const result = await validate('rachel.greene@gmail.con');
|
|
401
|
+
|
|
402
|
+
assert.equal(result.valid, false, 'gmail.con should be blocked as a typo TLD');
|
|
403
|
+
assert.propertyEquals(result, 'checks.typo.valid', false, 'Typo check should fail');
|
|
404
|
+
},
|
|
405
|
+
},
|
|
406
|
+
|
|
407
|
+
{
|
|
408
|
+
name: 'typo-correct-domains-pass',
|
|
409
|
+
timeout: 5000,
|
|
410
|
+
|
|
411
|
+
async run({ assert }) {
|
|
412
|
+
const gmail = await validate('rachel.greene@gmail.com');
|
|
413
|
+
const hotmail = await validate('rachel.greene@hotmail.com');
|
|
414
|
+
|
|
415
|
+
assert.equal(gmail.valid, true, 'gmail.com should pass');
|
|
416
|
+
assert.propertyEquals(gmail, 'checks.typo.valid', true, 'Typo check should pass for gmail.com');
|
|
417
|
+
assert.equal(hotmail.valid, true, 'hotmail.com should pass');
|
|
418
|
+
assert.propertyEquals(hotmail, 'checks.typo.valid', true, 'Typo check should pass for hotmail.com');
|
|
419
|
+
},
|
|
420
|
+
},
|
|
421
|
+
|
|
373
422
|
// --- isCorporate helper ---
|
|
374
423
|
|
|
375
424
|
{
|
|
@@ -529,8 +578,51 @@ module.exports = {
|
|
|
529
578
|
timeout: 5000,
|
|
530
579
|
|
|
531
580
|
async run({ assert }) {
|
|
532
|
-
assert.deepEqual(DEFAULT_CHECKS, ['format', 'disposable', 'corporate', 'localPart'], 'DEFAULT_CHECKS should be
|
|
533
|
-
assert.deepEqual(ALL_CHECKS, ['format', 'disposable', 'corporate', 'localPart', 'mailbox'], 'ALL_CHECKS should
|
|
581
|
+
assert.deepEqual(DEFAULT_CHECKS, ['format', 'disposable', 'corporate', 'localPart', 'typo'], 'DEFAULT_CHECKS should be all free sync checks (no dns/mailbox)');
|
|
582
|
+
assert.deepEqual(ALL_CHECKS, ['format', 'disposable', 'corporate', 'localPart', 'typo', 'dns', 'mailbox'], 'ALL_CHECKS should add dns + mailbox');
|
|
583
|
+
},
|
|
584
|
+
},
|
|
585
|
+
|
|
586
|
+
// --- DNS check behavior ---
|
|
587
|
+
|
|
588
|
+
{
|
|
589
|
+
name: 'dns-not-in-default-checks',
|
|
590
|
+
timeout: 5000,
|
|
591
|
+
|
|
592
|
+
async run({ assert }) {
|
|
593
|
+
const result = await validate('rachel.greene@gmail.com');
|
|
594
|
+
|
|
595
|
+
assert.equal(result.valid, true, 'Should be valid');
|
|
596
|
+
assert.equal(result.checks.dns, undefined, 'DNS should not run with default checks (async/slow — opt-in)');
|
|
597
|
+
},
|
|
598
|
+
},
|
|
599
|
+
|
|
600
|
+
{
|
|
601
|
+
name: 'dns-valid-domain-passes',
|
|
602
|
+
timeout: 15000,
|
|
603
|
+
|
|
604
|
+
async run({ assert }) {
|
|
605
|
+
// Offline-safe: on network errors the dns check is skipped (valid stays true);
|
|
606
|
+
// only definitive no-MX/NXDOMAIN answers block.
|
|
607
|
+
const result = await validate('rachel.greene@gmail.com', { checks: ['format', 'dns'] });
|
|
608
|
+
|
|
609
|
+
assert.equal(result.valid, true, 'gmail.com should pass the DNS check');
|
|
610
|
+
assert.hasProperty(result, 'checks.dns', 'Should have dns check result');
|
|
611
|
+
},
|
|
612
|
+
},
|
|
613
|
+
|
|
614
|
+
{
|
|
615
|
+
name: 'dns-nonexistent-domain-fails',
|
|
616
|
+
timeout: 15000,
|
|
617
|
+
skip: !process.env.TEST_EXTENDED_MODE
|
|
618
|
+
? 'TEST_EXTENDED_MODE not set (requires live DNS resolution)'
|
|
619
|
+
: false,
|
|
620
|
+
|
|
621
|
+
async run({ assert }) {
|
|
622
|
+
const result = await validate('rachel.greene@thisdomaindoesnotexist99887766.com', { checks: ['format', 'dns'] });
|
|
623
|
+
|
|
624
|
+
assert.equal(result.valid, false, 'Nonexistent domain should fail the DNS check');
|
|
625
|
+
assert.propertyEquals(result, 'checks.dns.valid', false, 'DNS check should fail');
|
|
534
626
|
},
|
|
535
627
|
},
|
|
536
628
|
|
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
*
|
|
13
13
|
* SendGrid processor tests:
|
|
14
14
|
* - Various event types (group_unsubscribe, unsubscribe, spamreport, bounce, dropped)
|
|
15
|
+
* - bounce/dropped only revoke on bounce_classification='Invalid Address' (hard bounce);
|
|
16
|
+
* technical bounces are sender-side issues and must NOT revoke consent
|
|
15
17
|
* - Email lookup → user doc mutation with source='sendgrid'
|
|
16
18
|
* - Silent skip when email doesn't map to a user (shared SendGrid account scenario)
|
|
17
19
|
* - Batched events processed independently
|
|
@@ -25,13 +27,14 @@ function sgEventId(name) {
|
|
|
25
27
|
}
|
|
26
28
|
|
|
27
29
|
// Helper — build a SendGrid event payload
|
|
28
|
-
function sgEvent({ id, type, email, timestamp, asmGroupId }) {
|
|
30
|
+
function sgEvent({ id, type, email, timestamp, asmGroupId, bounceClassification }) {
|
|
29
31
|
return {
|
|
30
32
|
sg_event_id: id,
|
|
31
33
|
event: type,
|
|
32
34
|
email,
|
|
33
35
|
timestamp: timestamp || Math.floor(Date.now() / 1000),
|
|
34
36
|
...(asmGroupId !== undefined ? { asm_group_id: asmGroupId } : {}),
|
|
37
|
+
...(bounceClassification !== undefined ? { bounce_classification: bounceClassification } : {}),
|
|
35
38
|
};
|
|
36
39
|
}
|
|
37
40
|
|
|
@@ -167,20 +170,43 @@ module.exports = {
|
|
|
167
170
|
},
|
|
168
171
|
|
|
169
172
|
{
|
|
170
|
-
name: 'sendgrid-bounce-event-handled',
|
|
173
|
+
name: 'sendgrid-hard-bounce-event-handled',
|
|
171
174
|
auth: 'none',
|
|
172
175
|
async run({ http, firestore, assert, accounts }) {
|
|
173
176
|
const uid = accounts.basic.uid;
|
|
174
177
|
const email = accounts.basic.email;
|
|
175
|
-
const eventId = sgEventId('bounce');
|
|
178
|
+
const eventId = sgEventId('hard-bounce');
|
|
176
179
|
|
|
180
|
+
// Only hard bounces (bounce_classification='Invalid Address') revoke consent.
|
|
177
181
|
const response = await http.as('none').post(
|
|
178
182
|
`backend-manager/marketing/webhook?provider=sendgrid&key=${process.env.BACKEND_MANAGER_WEBHOOK_KEY}`,
|
|
179
|
-
[sgEvent({ id: eventId, type: 'bounce', email })]
|
|
183
|
+
[sgEvent({ id: eventId, type: 'bounce', email, bounceClassification: 'Invalid Address' })]
|
|
184
|
+
);
|
|
185
|
+
|
|
186
|
+
assert.isSuccess(response);
|
|
187
|
+
assert.propertyEquals(response, 'data.processed', 1, 'Hard bounce should be treated as a revoke');
|
|
188
|
+
|
|
189
|
+
const userDoc = await firestore.get(`users/${uid}`);
|
|
190
|
+
assert.equal(userDoc?.consent?.marketing?.status, 'revoked');
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
|
|
194
|
+
{
|
|
195
|
+
name: 'sendgrid-dropped-hard-bounce-handled',
|
|
196
|
+
auth: 'none',
|
|
197
|
+
async run({ http, firestore, assert, accounts }) {
|
|
198
|
+
const uid = accounts.basic.uid;
|
|
199
|
+
const email = accounts.basic.email;
|
|
200
|
+
const eventId = sgEventId('dropped');
|
|
201
|
+
|
|
202
|
+
// 'dropped' follows the same classification filter as 'bounce'.
|
|
203
|
+
const response = await http.as('none').post(
|
|
204
|
+
`backend-manager/marketing/webhook?provider=sendgrid&key=${process.env.BACKEND_MANAGER_WEBHOOK_KEY}`,
|
|
205
|
+
[sgEvent({ id: eventId, type: 'dropped', email, bounceClassification: 'Invalid Address' })]
|
|
180
206
|
);
|
|
181
207
|
|
|
182
208
|
assert.isSuccess(response);
|
|
183
|
-
assert.propertyEquals(response, 'data.processed', 1, '
|
|
209
|
+
assert.propertyEquals(response, 'data.processed', 1, 'Dropped with Invalid Address should be treated as a revoke');
|
|
184
210
|
|
|
185
211
|
const userDoc = await firestore.get(`users/${uid}`);
|
|
186
212
|
assert.equal(userDoc?.consent?.marketing?.status, 'revoked');
|
|
@@ -189,6 +215,45 @@ module.exports = {
|
|
|
189
215
|
|
|
190
216
|
// ─── SendGrid processor — events we ignore ───
|
|
191
217
|
|
|
218
|
+
{
|
|
219
|
+
name: 'sendgrid-technical-bounce-ignored',
|
|
220
|
+
auth: 'none',
|
|
221
|
+
async run({ http, assert, accounts }) {
|
|
222
|
+
const email = accounts.basic.email;
|
|
223
|
+
const eventId = sgEventId('technical-bounce');
|
|
224
|
+
|
|
225
|
+
// Technical bounces (DMARC, TLS, DNS) are sender-side issues — the recipient's
|
|
226
|
+
// mailbox is still valid, so consent must NOT be revoked.
|
|
227
|
+
const response = await http.as('none').post(
|
|
228
|
+
`backend-manager/marketing/webhook?provider=sendgrid&key=${process.env.BACKEND_MANAGER_WEBHOOK_KEY}`,
|
|
229
|
+
[sgEvent({ id: eventId, type: 'bounce', email, bounceClassification: 'Technical Failure' })]
|
|
230
|
+
);
|
|
231
|
+
|
|
232
|
+
assert.isSuccess(response, 'Should accept the request (not error) but ignore the event');
|
|
233
|
+
assert.propertyEquals(response, 'data.processed', 0, 'Technical bounce should not be processed');
|
|
234
|
+
assert.propertyEquals(response, 'data.skipped', 1, '1 event should be skipped');
|
|
235
|
+
},
|
|
236
|
+
},
|
|
237
|
+
|
|
238
|
+
{
|
|
239
|
+
name: 'sendgrid-bounce-without-classification-ignored',
|
|
240
|
+
auth: 'none',
|
|
241
|
+
async run({ http, assert, accounts }) {
|
|
242
|
+
const email = accounts.basic.email;
|
|
243
|
+
const eventId = sgEventId('unclassified-bounce');
|
|
244
|
+
|
|
245
|
+
// No bounce_classification — can't confirm a hard bounce, so skip.
|
|
246
|
+
const response = await http.as('none').post(
|
|
247
|
+
`backend-manager/marketing/webhook?provider=sendgrid&key=${process.env.BACKEND_MANAGER_WEBHOOK_KEY}`,
|
|
248
|
+
[sgEvent({ id: eventId, type: 'bounce', email })]
|
|
249
|
+
);
|
|
250
|
+
|
|
251
|
+
assert.isSuccess(response, 'Should accept the request (not error) but ignore the event');
|
|
252
|
+
assert.propertyEquals(response, 'data.processed', 0, 'Unclassified bounce should not be processed');
|
|
253
|
+
assert.propertyEquals(response, 'data.skipped', 1, '1 event should be skipped');
|
|
254
|
+
},
|
|
255
|
+
},
|
|
256
|
+
|
|
192
257
|
{
|
|
193
258
|
name: 'sendgrid-delivered-event-ignored',
|
|
194
259
|
auth: 'none',
|