From 41df4aee740679eaee62b591278824e11dedf27d Mon Sep 17 00:00:00 2001 From: _david Date: Wed, 18 Nov 2026 16:00:50 +0700 Subject: [PATCH 1/7] refactor(candidate): hide password at schema level with select: false - models/candidate.model.ts: password gets select: false, so no query returns the hash unless it opts in - auth/auth.service.ts: handlerLogin (only hash reader) opts in with .select('+password'); reset writes via updateOne, unchanged - tests: login mocks chain .select and assert '+password'; new models/candidatePassword.test.ts asserts a plain findById() sends projection { password: 0 } (red without the fix) npm test: Test Suites: 73 passed, 73 total; Tests: 784 passed, 784 total npm run build: exit 0 (tsc typecheck); lint 274 = baseline, 0 new Node: hide-password-select-false (SEALED) Evidence: agent-hub/evidence/verifier/2026-11-18/hide-password-select-false-seal.md Closes #459 Co-Authored-By: Claude Sonnet 5 --- .../2026-11-18/hide-password-select-false.md | 144 ++++++++++++++++++ .../hide-password-select-false-seal.md | 37 +++++ agent-hub/evidence/worker-runs.log | 1 + agent-hub/haven/diagrams/dev-loop-archive.md | 1 + .../haven/diagrams/dev-loop.prime-mermaid.md | 2 +- src/__tests__/auth/auth.service.test.ts | 16 +- .../models/candidatePassword.test.ts | 15 ++ src/auth/auth.service.ts | 2 +- src/models/candidate.model.ts | 3 +- 9 files changed, 214 insertions(+), 7 deletions(-) create mode 100644 agent-hub/evidence/implementer/2026-11-18/hide-password-select-false.md create mode 100644 agent-hub/evidence/verifier/2026-11-18/hide-password-select-false-seal.md create mode 100644 src/__tests__/models/candidatePassword.test.ts diff --git a/agent-hub/evidence/implementer/2026-11-18/hide-password-select-false.md b/agent-hub/evidence/implementer/2026-11-18/hide-password-select-false.md new file mode 100644 index 00000000..3748d658 --- /dev/null +++ b/agent-hub/evidence/implementer/2026-11-18/hide-password-select-false.md @@ -0,0 +1,144 @@ +# 2026-11-18 - hide-password-select-false +Worker: implementer · Version: 0.1.0 · Node: `hide-password-select-false` (`haven/diagrams/dev-loop.prime-mermaid.md`, PENDING, row added this pass on branch `refactor/459-hide-password-select`) · Issue: #459 +Task: `#459 Candidate model: hide password at schema level (select: false) — password in src/models/candidate.model.ts:25 returned by default; set select:false and opt in with .select('+password') only where compared/updated (login, change/reset password). Acceptance: every query path needing the hash uses +password; login/reset still work; test: plain CandidateModel.findById() result has no password.` + +## Hub bytes before: 97857 + +## Feature doc: doctrine/features/auth-register-login.md +Behavior #5/#6 (login: wrong password and unknown email → same 401; success → 200 with tokens) — unchanged by this diff; the 4 `handlerLogin` tests that encode it stay green. Password reset (`auth-password-reset.md`) writes via `updateOne` and never reads the hash — no code change there. + +## Acceptance criteria clarified +Issue: "every query path that needs the hash uses `+password`" → grep of every `password` read in `src/` (non-test): the only reader of the hash is `handlerLogin` (`src/auth/auth.service.ts:99-100`, `bcryptCompareHash`). Reset (`auth.service.ts:162`) is `updateOne` (write, needs no select). No change-password endpoint exists. Node criteria rewritten with exact test commands (see diagram row). + +## Diff +| File | Why | +|---|---| +| `src/models/candidate.model.ts` | `password` gets `select: false` + 1-line `//` WHY comment | +| `src/auth/auth.service.ts` | `handlerLogin`: `CandidateModel.findOne({ email }).select('+password')` — the only hash reader | +| `src/__tests__/auth/auth.service.test.ts` | `handlerLogin` mocks now chain `.select` (`mockLoginFind` helper, 4 call sites) + asserts `select('+password')` on the success test | +| `src/__tests__/models/candidatePassword.test.ts` | New: spies `CandidateModel.collection.findOne`, runs the real Mongoose query pipeline: plain `findById()` sends `projection: { password: 0 }`; `.select('+password')` does not exclude it | + +Left as-is on purpose (`SmallestDiff`, now redundant but harmless defense in depth): `candidate.service.ts:60,68` `.select('-password')`, `candidate_me/index.ts:171` `delete dataResult.password`. + +## Command +From `/Users/_david/Workspace/Project/resume/resume-nodejs-api` (per `doctrine/MEMORY.md`): +- `npx jest src/__tests__/auth/auth.service.test.ts src/__tests__/models/candidatePassword.test.ts` +- `npm test` +- `npm run build` (Typecheck row = `inside Build`) +- `npm run lint`, plus `npx eslint -f json` on this branch vs `git stash` (staging) +- Negative check: `select: false` temporarily removed via `sed`, `npx jest src/__tests__/models/candidatePassword.test.ts`, then restored (`grep -n "select: false"` confirms line 26) + +## Output +Targeted: +``` + ✓ is excluded from a plain findById() unless selected with +password (5 ms) + +PASS src/__tests__/auth/auth.service.test.ts + auth.service + isEmailAlreadyExists + ✓ should return true if email exists (3 ms) + ✓ should return false if email does not exist + handlerRegister + ✓ should register successfully with new email (1 ms) + ✓ should fail if email already exists (1 ms) + handlerLogin + ✓ should login successfully with correct credentials (1 ms) + ✓ should fail if user not found + ✓ should fail if password incorrect + ✓ localizes the invalid-credentials message to the request lang + handlerForgotPassword + ✓ creates a reset token when the email exists + ✓ returns the same generic success message when the email does not exist (no user enumeration) + handlerResetPassword + ✓ updates the password when the reset token is valid + ✓ fails without touching the password when the token is invalid/expired (1 ms) + handlerVerifyEmail + ✓ marks emailVerified true when the verification token is valid + ✓ fails without touching the candidate when the token is invalid/expired + +Test Suites: 2 passed, 2 total +Tests: 15 passed, 15 total +Snapshots: 0 total +Time: 2.841 s +``` +Negative check (fix removed): +``` + ✕ is excluded from a plain findById() unless selected with +password (5 ms) +Tests: 1 failed, 1 total +``` +After restore: `26: password: { type: String, default: '', select: false, required: [false, 'Password is required'] },` + +`npm test` (tail): +``` +A worker process has failed to exit gracefully and has been force exited. This is likely caused by tests leaking due to improper teardown. Try running with --detectOpenHandles to find leaks. Active timers can also cause this, ensure that .unref() was called on them. +Test Suites: 73 passed, 73 total +Tests: 784 passed, 784 total +Snapshots: 0 total +Time: 20.274 s +Ran all test suites. +``` +`npm run build` (tail): +``` +> resume-nodejs-api@2.9.0 copy +> cp -R ./src/public ./dist/ + +build exit 0 +``` +`npm run lint` (tail): +``` +✖ 274 problems (274 errors, 0 warnings) + 20 errors and 0 warnings potentially fixable with the `--fix` option. +``` +Touched files, this branch (`file line rule`): +``` +src/__tests__/auth/auth.service.test.ts 47 @typescript-eslint/unbound-method +src/__tests__/auth/auth.service.test.ts 84 @typescript-eslint/unbound-method +src/__tests__/auth/auth.service.test.ts 86 @typescript-eslint/unbound-method +src/__tests__/auth/auth.service.test.ts 92 @typescript-eslint/unbound-method +src/__tests__/auth/auth.service.test.ts 136 @typescript-eslint/unbound-method +src/__tests__/auth/auth.service.test.ts 206 @typescript-eslint/unbound-method +src/__tests__/auth/auth.service.test.ts 232 @typescript-eslint/unbound-method +src/__tests__/auth/auth.service.test.ts 247 @typescript-eslint/unbound-method +src/__tests__/auth/auth.service.test.ts 260 @typescript-eslint/unbound-method +src/__tests__/auth/auth.service.test.ts 273 @typescript-eslint/unbound-method +``` +Same files on staging (stash): +``` +src/__tests__/auth/auth.service.test.ts 47 @typescript-eslint/unbound-method +src/__tests__/auth/auth.service.test.ts 84 @typescript-eslint/unbound-method +src/__tests__/auth/auth.service.test.ts 86 @typescript-eslint/unbound-method +src/__tests__/auth/auth.service.test.ts 92 @typescript-eslint/unbound-method +src/__tests__/auth/auth.service.test.ts 129 @typescript-eslint/unbound-method +src/__tests__/auth/auth.service.test.ts 198 @typescript-eslint/unbound-method +src/__tests__/auth/auth.service.test.ts 224 @typescript-eslint/unbound-method +src/__tests__/auth/auth.service.test.ts 239 @typescript-eslint/unbound-method +src/__tests__/auth/auth.service.test.ts 252 @typescript-eslint/unbound-method +src/__tests__/auth/auth.service.test.ts 265 @typescript-eslint/unbound-method +``` +Same 10 pre-existing errors, lines after 108 shifted by +7/+8 (the added helper/assert); 0 in `candidate.model.ts`, `auth.service.ts`, `candidatePassword.test.ts`. + +## Acceptance +| Criterion | Evidence | +|---|---| +| (1) login reads the hash via `+password`; login still works | `auth.service.ts:95` diff; `handlerLogin` 4/4 ✓ incl. `expect(select).toHaveBeenCalledWith('+password')`; "Tests: 15 passed, 15 total" | +| reset still works | `handlerResetPassword` 2/2 ✓ (same run); writes via `updateOne`, no read | +| (2) plain `findById()` has no `password` | `candidatePassword.test.ts` ✓; red without the fix ("Tests: 1 failed, 1 total") | +| (3) full suite + typecheck | "Tests: 784 passed, 784 total"; build exit 0 | +| lint ≤ baseline, none new in changed files | 274 = baseline 274; touched-file errors identical set to staging (above) | +| comments per code-comments.md | 1 `//` WHY in `candidate.model.ts:25` (why hidden + how to opt in, no issue ref); 1 `//` WHY in test helper (why the mock chains). Nothing else touched | + +## Review +`/code-review medium` + `/security-review` (label `security`) done inline — touched files in full + callers: +- Every Candidate write is `create`/`updateOne` with `$set` semantics (grep: no `replaceOne`/`findOneAndReplace`/`overwrite`/candidate `.save()`), so a doc loaded without `password` can never wipe the hash. +- `candidateQuerySafe` select allow-list (`utils/querySafe.ts:40-54`) has no `password`, so `handlerUpdate`'s `whitelistSelect(Object.keys(value))` cannot opt it back in from client input. +- v2 `/login` routes to the same `authLogin` → `handlerLogin`. +- Other `findOne` callers (`auth.service.ts:25,69,136`, `candidate_me` ats-check/index/search, `slug.ts`) never read `password` — they now just stop receiving it (strict improvement). +- No correctness/security findings. + +## Supersedes: none +Only this row cites #459. + +## Noticed, not done +- `haven/diagrams/dev-loop.prime-mermaid.md:63` still shows `fix-candidate-password-leak` (#152) as PENDING, while `dev-loop-archive.md:59` has it SEALED — stale active row; PM status is the verifier's call. +- Redundant `.select('-password')` (`candidate.service.ts:60,68`) and `delete dataResult.password` (`candidate_me/index.ts:171`) can be dropped in a later cleanup; kept here for SmallestDiff. +- Jest "worker process has failed to exit gracefully" warning — pre-existing, not from this diff. diff --git a/agent-hub/evidence/verifier/2026-11-18/hide-password-select-false-seal.md b/agent-hub/evidence/verifier/2026-11-18/hide-password-select-false-seal.md new file mode 100644 index 00000000..92bf7ad5 --- /dev/null +++ b/agent-hub/evidence/verifier/2026-11-18/hide-password-select-false-seal.md @@ -0,0 +1,37 @@ +# 2026-11-18 - hide-password-select-false - SEAL +Worker: verifier · Version: 0.1.0 · Node: `hide-password-select-false` (`haven/diagrams/dev-loop.prime-mermaid.md`, issue #459, branch `refactor/459-hide-password-select`) · New PM status: SEALED +Note audited: `evidence/implementer/2026-11-18/hide-password-select-false.md` + +## Isolation proof +Fresh Agent-tool spawn, `spawn=fresh`. Task string this context received: "You are the agent-hub VERIFIER worker ... run `verify_seal` on Evidence note: agent-hub/evidence/implementer/2026-11-18/hide-password-select-false.md, Node: `hide-password-select-false` ... changes are uncommitted in the working tree". This context has no implementer reasoning; it did not write any part of the diff (self-check step 1: not mine). + +## Reasoning +Node criteria (diagram row 84): +| Criterion | Evidence (cited from note) | Verdict | +|---|---|---| +| (1) login reads hash via `+password`, `auth.service.test.ts` green | `handlerLogin` 4/4 ✓ incl. new `expect(select).toHaveBeenCalledWith('+password')`; "Test Suites: 2 passed, 2 total / Tests: 15 passed, 15 total" | met | +| (2) new test: plain `findById()` sends projection excluding `password` | `candidatePassword.test.ts` ✓ in the same run; negative check with `select: false` removed: "Tests: 1 failed, 1 total"; restore confirmed by grep at line 26 | met | +| (3) `npm test` + `npm run build` green, lint ≤ baseline, none in changed files | "Tests: 784 passed, 784 total", "Test Suites: 73 passed, 73 total"; build tail shows `npm run copy` ran (only after `tsc` succeeds) + "build exit 0"; lint "✖ 274 problems" = baseline 274; touched-file errors are the same 10 pre-existing `unbound-method` in `auth.service.test.ts` as on staging (line-shifted), 0 in the other 3 files | met | +| comments per code-comments.md | 2 `//` one-sentence WHY comments (model field, test helper), no `(#N)` refs | met | + +Doctrine checks: +- Step 4: commands match `doctrine/MEMORY.md` (Test, Test one file, Build, Lint with baseline cited); Typecheck row = `inside Build`, build output cited. OK. +- Step 5: outputs are summary tails with totals intact; the targeted block opens mid-output (PASS header of the models suite not shown) but suite/test totals are verbatim and consistent (2 suites, 14 + 1 = 15). Not hiding a failure. OK. +- Step 6 open rows: only this row cites #459; `## Supersedes: none` present. OK. +- Step 6b feature doc: `doctrine/features/auth-register-login.md` cited (fix → Behavior #5/#6). Login unknown-email / wrong-password → same 401 and success → tokens: covered by the 4 green `handlerLogin` tests. Doc status left `verified` (fix SEAL, step 11e). No `## Feature doc changed`. OK. +- Step 6b2 review: `## Review` present with `/code-review medium` + `/security-review` (label `security`), no findings; the write-path argument (no `replaceOne`/`.save()`, so a doc loaded without the hash can't wipe it) and the `candidateQuerySafe` allow-list argument are stated. OK. +- Step 6c doctrine proposal: none. +- Step 7 forbidden states: `ADHOC_WORK` no (node on diagram, issue-linked branch) · `NO_EVIDENCE` no · `EDIT_UNVERIFIED` no (test + typecheck cited, red-then-green shown) · `CODE_IN_HAVEN` no (only the diagram `.md` changed in `haven/`) · `DIAGRAM_DRIFT` resolved by this SEAL. +- Step 8 seal gate: nothing outward-facing (uncommitted working tree). Note has no `## Seal gate` section (format gap, not a gate breach; nothing to approve). +- Step 9 proportionality: `git status --short` / `git diff --stat` show exactly the 4 files the note lists (3 modified + 1 untracked test) plus the diagram row; +16/-6 in `src/`. Proportionate. + +Cross-check (dispatcher asked for an audit against the real diff): read `git diff -- src/` + the new test file; matches the note line for line (`auth.service.ts:95` `.select('+password')`, model line 26 `select: false`). Grep of `src/` non-test for hash readers: only `bcryptCompareHash` in `handlerLogin` (line 100), so no other query path needs `+password`. Redundant `.select('-password')` (`candidate.service.ts:60,68`) mixes fine with schema `select: false`. + +## Re-run +none — audit-only. Note outputs are verbatim with totals, commands match doctrine, criteria all covered; not outward-facing, not a `/release` gate, and `doctrine/domains/PROJECT.md` lists no re-run class for this change. (Read the diff and grepped `src/` as a cross-check; no build/lint/test re-run.) + +## PM status +Row archived verbatim (state SEALED) to `haven/diagrams/dev-loop-archive.md`; active row replaced by a pointer. Pointer rows hit 21 → oldest (`linkedin-unparseable-end-date`, 2026-11-08, already in archive) deleted. + +## Noticed, not done +- Active diagram still holds `fix-candidate-password-leak` (#152) as PENDING while the archive has it SEALED (2026-09-28). Not this node's row; left for a separate pass. diff --git a/agent-hub/evidence/worker-runs.log b/agent-hub/evidence/worker-runs.log index 9d478451..ecfea64d 100644 --- a/agent-hub/evidence/worker-runs.log +++ b/agent-hub/evidence/worker-runs.log @@ -1,2 +1,3 @@ 2026-11-17T08:37:32Z role=verifier outcome=SEAL node=logout-refresh-token-header rerun=none spawn=fresh hub_bytes_before=97847 hub_bytes_after=97849 2026-11-17T08:46:36Z role=verifier outcome=SEAL node=auth-service-throw-apperror rerun=none spawn=fresh hub_bytes_before=97847 hub_bytes_after=97849 +2026-11-18T09:00:21Z role=verifier outcome=SEAL node=hide-password-select-false rerun=none spawn=fresh hub_bytes_before=97857 hub_bytes_after=97851 diff --git a/agent-hub/haven/diagrams/dev-loop-archive.md b/agent-hub/haven/diagrams/dev-loop-archive.md index 12eb02bb..bc2285f4 100644 --- a/agent-hub/haven/diagrams/dev-loop-archive.md +++ b/agent-hub/haven/diagrams/dev-loop-archive.md @@ -187,3 +187,4 @@ | `contributing-kit-template` | SEALED | #480, via `/todo`, branch `chore/480-contributing-kit-template`. Docs-only: operator-authored rewrite of `CONTRIBUTING.md` onto the kit contributor template, adopted by the implementer. Acceptance: (1) every factual claim in `CONTRIBUTING.md` (commands, CI job steps, branch names/protection settings, `/release`/`/ship`/`/issues-ls` behavior, file paths) matches the repo (`.github/workflows/node.js.yml`, `.claude/skills/*`, `doctrine/MEMORY.md`, `doctrine/domains/PROJECT.md`) — cited grep per claim group; (2) no rule from the previous `CONTRIBUTING.md` (branch from staging, PR into staging, release-only `main`, protection + review-count 0 rationale, required checks rationale, merge-not-squash, issue close on default branch) is lost; (3) `npm test` + `npm run build` green. | | `auth-service-throw-apperror` | SEALED | #460 — `src/auth/auth.service.ts` returns `{ success:false }` (register/verify-email/login/reset-password) instead of throwing `AppError` subclasses; controller branches on it. Acceptance: (1) `grep -n "success: false" src/auth/auth.service.ts` empty and the controller no longer branches on a service `success` flag; (2) contract tests assert `{ success:false, error:{ code, message } }` + status for invalid reset/verify tokens (400 `BAD_REQUEST`); (3) behavior per `features/auth-register-login.md` #2/#5 and `features/auth-password-reset.md` (409 `EMAIL_EXISTS`, 401 `INVALID_CREDENTIALS`, 400 on bad token) unchanged; (4) `npm test` + `npm run build` green, lint ≤ baseline with none in touched files. Plan: `evidence/implementer/2026-11-17/auth-service-throw-apperror-plan.md`. | | `logout-refresh-token-header` | SEALED | #475 — `authLogout` (`src/auth/auth.controller.ts`) looks up `refreshToken` via `extractTokenFromRequest`, which returns the `Authorization` header first, so it blacklists the access token twice and the real refresh token stays valid. Fix: that lookup skips the header (body/query/cookie only); `/auth/refresh` keeps header support (operator, 2026-11-17). Acceptance: new unit test logout with `Bearer ` + body `refreshToken` blacklists both; `npm test` + `npm run build` green; lint ≤ baseline, none in touched files; matches `features/auth-session-tokens.md` Behavior #7 (as amended). | +| `hide-password-select-false` | SEALED | GitHub issue #459. `src/models/candidate.model.ts:25` — `password` returned by default, every query must remember `.select('-password')` (#152 regressed exactly this). Fix: `select: false` on the schema; opt in with `.select('+password')` only where the hash is compared (`auth.service.ts` `handlerLogin`; reset writes via `updateOne`, needs no read). Acceptance: (1) login reads the hash via `+password` — `npx jest src/__tests__/auth/auth.service.test.ts` green; (2) new test: a plain `CandidateModel.findById()` query sends a projection excluding `password` — `npx jest src/__tests__/models/candidatePassword.test.ts` green; (3) `npm test` + `npm run build` green, lint ≤ baseline with none in changed files. SEALED 2026-11-18 after independent verifier pass (audit-only, no re-run). Evidence: `evidence/implementer/2026-11-18/hide-password-select-false.md`, `evidence/verifier/2026-11-18/hide-password-select-false-seal.md`. | diff --git a/agent-hub/haven/diagrams/dev-loop.prime-mermaid.md b/agent-hub/haven/diagrams/dev-loop.prime-mermaid.md index e46bdca1..b5beb8ea 100644 --- a/agent-hub/haven/diagrams/dev-loop.prime-mermaid.md +++ b/agent-hub/haven/diagrams/dev-loop.prime-mermaid.md @@ -64,7 +64,6 @@ flowchart TD | `fix-refresh-token-expiry-unused` | PENDING | `TOKEN_EXP_IN` (`.env`, already exported in config) is never used at any `jwtSign()` call site (`auth.service.ts`, `auth.controller.ts`, `api/v1/auth/services/login.ts`) — access and refresh tokens always share the same default 1h expiry, so the refresh token is pointless. | | `ci-lint-ratchet` | SEALED | 2026-11-16 — archived, see `haven/diagrams/dev-loop-archive.md`. Evidence: `evidence/verifier/2026-11-16/ci-lint-ratchet-seal.md`. | | `job-applications-status-transitions` | SEALED | 2026-11-15 — archived, see `haven/diagrams/dev-loop-archive.md`. Evidence: `evidence/verifier/2026-11-15/job-applications-status-transitions-seal.md`. | -| `linkedin-unparseable-end-date` | SEALED | 2026-11-08 — archived, see `haven/diagrams/dev-loop-archive.md`. Evidence: `evidence/verifier/2026-11-08/linkedin-unparseable-end-date-seal.md`. | | `parsed-entries-bulk-shape` | SEALED | 2026-11-08 — archived, see `haven/diagrams/dev-loop-archive.md`. Evidence: `evidence/verifier/2026-11-08/parsed-entries-bulk-shape-seal.md`. | | `short-values-validation` | SEALED | 2026-11-08 — archived, see `haven/diagrams/dev-loop-archive.md`. Evidence: `evidence/verifier/2026-11-08/short-values-validation-seal-r2.md`. | | `paginate-visits` | SEALED | 2026-11-09 — archived, see `haven/diagrams/dev-loop-archive.md`. Evidence: `evidence/verifier/2026-11-09/paginate-visits-seal.md`. | @@ -81,3 +80,4 @@ flowchart TD | `translate-vietnamese-docs` | SEALED | 2026-11-16 — archived, see `haven/diagrams/dev-loop-archive.md`. Evidence: `evidence/verifier/2026-11-16/translate-vietnamese-docs-seal.md`. | | `contributing-kit-template` | SEALED | 2026-11-16 — archived, see `haven/diagrams/dev-loop-archive.md`. Evidence: `evidence/verifier/2026-11-16/contributing-kit-template-seal.md`. | | `auth-service-throw-apperror` | SEALED | 2026-11-17 — archived, see `haven/diagrams/dev-loop-archive.md`. Evidence: `evidence/verifier/2026-11-17/auth-service-throw-apperror-seal.md`. | +| `hide-password-select-false` | SEALED | 2026-11-18 — archived, see `haven/diagrams/dev-loop-archive.md`. Evidence: `evidence/verifier/2026-11-18/hide-password-select-false-seal.md`. | diff --git a/src/__tests__/auth/auth.service.test.ts b/src/__tests__/auth/auth.service.test.ts index 05452bb6..b46da04f 100644 --- a/src/__tests__/auth/auth.service.test.ts +++ b/src/__tests__/auth/auth.service.test.ts @@ -108,6 +108,13 @@ describe('auth.service', () => { }); describe('handlerLogin', () => { + // Login reads the hash via `.findOne(...).select('+password')`, so the mock has to chain. + const mockLoginFind = (user: unknown) => { + const select = jest.fn().mockResolvedValue(user); + (CandidateModel.findOne as jest.Mock).mockReturnValue({ select }); + return select; + }; + it('should login successfully with correct credentials', async () => { const mockUser = { _id: 'user_id', @@ -120,13 +127,14 @@ describe('auth.service', () => { const mockToken = 'access_token'; const mockRefresh = 'refresh_token'; - (CandidateModel.findOne as jest.Mock).mockResolvedValue(mockUser); + const select = mockLoginFind(mockUser); (bcrypt.bcryptCompareHash as jest.Mock).mockResolvedValue(mockCompareResult); (jwt.jwtSign as jest.Mock).mockReturnValueOnce(mockToken).mockReturnValueOnce(mockRefresh); const result = await handlerLogin({ email: 'test@example.com', password: 'correctpass' }); expect(CandidateModel.findOne).toHaveBeenCalledWith({ email: 'test@example.com' }); + expect(select).toHaveBeenCalledWith('+password'); expect(bcrypt.bcryptCompareHash).toHaveBeenCalledWith('correctpass', mockUser.password); expect(jwt.jwtSign).toHaveBeenNthCalledWith(1, { data: { _id: 'user_id' }, @@ -153,7 +161,7 @@ describe('auth.service', () => { }); it('should fail if user not found', async () => { - (CandidateModel.findOne as jest.Mock).mockResolvedValue(null); + mockLoginFind(null); await expect(handlerLogin({ email: 'nonexistent@example.com', password: 'pass' })).rejects.toMatchObject({ errorCode: ErrorCode.INVALID_CREDENTIALS, @@ -166,7 +174,7 @@ describe('auth.service', () => { it('should fail if password incorrect', async () => { const mockUser = { _id: 'user_id', email: 'test@example.com', password: 'hash' }; - (CandidateModel.findOne as jest.Mock).mockResolvedValue(mockUser); + mockLoginFind(mockUser); (bcrypt.bcryptCompareHash as jest.Mock).mockResolvedValue(false); // Same error as the unknown-email case, so login can't enumerate registered emails. @@ -178,7 +186,7 @@ describe('auth.service', () => { }); it('localizes the invalid-credentials message to the request lang', async () => { - (CandidateModel.findOne as jest.Mock).mockResolvedValue(null); + mockLoginFind(null); await expect(handlerLogin({ email: 'nonexistent@example.com', password: 'pass' }, 'en')).rejects.toMatchObject({ errorCode: ErrorCode.INVALID_CREDENTIALS, diff --git a/src/__tests__/models/candidatePassword.test.ts b/src/__tests__/models/candidatePassword.test.ts new file mode 100644 index 00000000..13e62774 --- /dev/null +++ b/src/__tests__/models/candidatePassword.test.ts @@ -0,0 +1,15 @@ +import CandidateModel from '@/models/candidate.model'; + +describe('Candidate password', () => { + afterEach(() => jest.restoreAllMocks()); + + it('is excluded from a plain findById() unless selected with +password', async () => { + const findOne = jest.spyOn(CandidateModel.collection, 'findOne').mockResolvedValue(null); + + await CandidateModel.findById('507f1f77bcf86cd799439011').exec(); + expect(findOne.mock.calls[0]?.[1]).toMatchObject({ projection: { password: 0 } }); + + await CandidateModel.findById('507f1f77bcf86cd799439011').select('+password').exec(); + expect(findOne.mock.calls[1]?.[1]?.projection ?? {}).not.toHaveProperty('password', 0); + }); +}); diff --git a/src/auth/auth.service.ts b/src/auth/auth.service.ts index beaab071..d865a90a 100644 --- a/src/auth/auth.service.ts +++ b/src/auth/auth.service.ts @@ -92,7 +92,7 @@ export const handlerVerifyEmail = async (token: string, lang: string = DEFAULT_L export const handlerLogin = async (data: Auth, lang: string = DEFAULT_LANG) => { const { email, password } = data; - const _user = await CandidateModel.findOne({ email }); + const _user = await CandidateModel.findOne({ email }).select('+password'); // Same answer for an unknown email and a wrong password, so login can't be used to probe which emails are registered. if (!_user) throw new InvalidCredentialsError(t('auth.invalidCredentials', lang)); diff --git a/src/models/candidate.model.ts b/src/models/candidate.model.ts index d083ad7b..e905d746 100644 --- a/src/models/candidate.model.ts +++ b/src/models/candidate.model.ts @@ -22,7 +22,8 @@ const schema = new Schema( sparse: true, index: true, }, - password: { type: String, default: '', required: [false, 'Password is required'] }, + // Hidden from every query by default; only code that compares the hash opts in with `.select('+password')`. + password: { type: String, default: '', select: false, required: [false, 'Password is required'] }, firstName: { type: String, default: '', required: false }, lastName: { type: String, default: '', required: false }, From f942b99f7d528cf202fac7113a72145ac44dc9c1 Mon Sep 17 00:00:00 2001 From: _david Date: Wed, 18 Nov 2026 16:36:51 +0700 Subject: [PATCH 2/7] test(auth): add HTTP-level integration tests for the auth flow - src/server.ts: extract the middleware chain into exported createApp(); startServer() and the unhandledRejection handler run only when the file is the entry point (require.main === module) - src/__tests__/integration/auth.http.test.ts: supertest + mongodb-memory-server over the real chain (register/login/GET/refresh/logout with token rejected after; rotated refresh reuse after 10s grace revokes all sessions; cookie-only POST without CSRF -> 403; client candidateId ignored; unknown route -> 404 standard shape; Redis absent -> in-memory fallback) - package.json/package-lock.json: dev deps supertest, @types/supertest, mongodb-memory-server - CLAUDE.md: middleware order now lives in createApp npm test: Test Suites: 74 passed, 74 total / Tests: 790 passed, 790 total npm run build: exit 0 (tsc exit 0); lint 273 problems (<= 274 baseline), none new in changed files Node: auth-http-integration-tests (SEALED) Evidence: agent-hub/evidence/verifier/2026-11-18/auth-http-integration-tests-seal.md Closes #463 Co-Authored-By: Claude Sonnet 5 --- CLAUDE.md | 2 +- .../auth-http-integration-tests-diff.md | 141 ++ .../auth-http-integration-tests-plan.md | 25 + .../auth-http-integration-tests-seal.md | 41 + agent-hub/evidence/worker-runs.log | 1 + agent-hub/haven/diagrams/dev-loop-archive.md | 1 + .../haven/diagrams/dev-loop.prime-mermaid.md | 2 +- package-lock.json | 1177 +++++++++++++---- package.json | 3 + src/__tests__/integration/auth.http.test.ts | 124 ++ src/server.ts | 23 +- 11 files changed, 1293 insertions(+), 247 deletions(-) create mode 100644 agent-hub/evidence/implementer/2026-11-18/auth-http-integration-tests-diff.md create mode 100644 agent-hub/evidence/implementer/2026-11-18/auth-http-integration-tests-plan.md create mode 100644 agent-hub/evidence/verifier/2026-11-18/auth-http-integration-tests-seal.md create mode 100644 src/__tests__/integration/auth.http.test.ts diff --git a/CLAUDE.md b/CLAUDE.md index 94d21577..936176ff 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -62,7 +62,7 @@ TRUST_PROXY_HOPS=1 # optional; proxy hops in front of the app (1 on Re ## Conventions - Always import via the `@/` alias (`@/utils/helper`) — `src/*` in dev (tsconfig-paths), `dist/*` in prod (module-alias, `src/alias.ts`). -- Middleware order is `runServer` in `src/server.ts`. `/health` and `/api-docs` are registered before the rate limiter on purpose (exempt). +- Middleware order is `createApp` in `src/server.ts`. `/health` and `/api-docs` are registered before the rate limiter on purpose (exempt). - New CV section → `src/candidate_profile/
/` controller + service + validate, built on `createCrudService()` (`BaseService.ts`) and `BaseController.ts`, like the existing sections. - CV-section models + `Application` + `Profile` soft-delete via nullable `deletedAt` (`Visit` doesn't). Localized free-text fields use `localizedTextSchema` (`{ vi, en }`), resolved per request by `?lang=`. - Errors: services throw `AppError` subclasses (`src/errors/`), never return `{ success:false }`. Every status comes from the `ERROR_STATUS` map in `errors/AppError.ts`; `withTimeout` throws `SERVICE_UNAVAILABLE` (503) on a DB/Redis timeout. diff --git a/agent-hub/evidence/implementer/2026-11-18/auth-http-integration-tests-diff.md b/agent-hub/evidence/implementer/2026-11-18/auth-http-integration-tests-diff.md new file mode 100644 index 00000000..dd1500e4 --- /dev/null +++ b/agent-hub/evidence/implementer/2026-11-18/auth-http-integration-tests-diff.md @@ -0,0 +1,141 @@ +# 2026-11-18 - auth-http-integration-tests (diff) +Worker: implementer · Version: 0.1.0 · Node: `haven/diagrams/dev-loop.prime-mermaid.md` → `auth-http-integration-tests` · Task: `/todo #463` — "Add HTTP-level integration tests for the auth flow (supertest + in-memory Mongo)" · Branch: `chore/463-auth-integration-tests` (cut from `staging` @ 33fcfb1) +Plan: `evidence/implementer/2026-11-18/auth-http-integration-tests-plan.md` + +## Hub bytes before: 97851 + +## Feature doc: doctrine/features/auth-session-tokens.md, doctrine/features/auth-register-login.md +Unchanged — tests assert their Behavior; no behavior change. Not a `feat` (operator chose branch type `chore`), so the docs' own `## Acceptance criteria` aren't this node's; the Behavior items exercised: +| Doc · Behavior | Test (Acceptance row) | +|---|---| +| register-login #1 (valid register body), #3 (register → 201) | `beforeAll` asserts `[201, 201, 201, 201]` | +| register-login #6 (login 200 + `token`/`tokenRefresh` + cookies) | `login()` helper asserts 200, reads both tokens + `set-cookie` (used by criterion 3) | +| session #3 (cookie-only non-GET without `x-csrf-token` → 403 `CSRF_TOKEN_INVALID`) | criterion 3 | +| session #4 (`req.body.candidateId` overwritten) | criterion 4 | +| session #5 (refresh → new pair; rotated token unusable) | criteria 1, 2 | +| session #6 (reuse > 10s → all sessions revoked, same 401) | criterion 2 | +| session #7 (logout blacklists access + body `refreshToken`; later refresh → 401 `TOKEN_REVOKED`) | criterion 1 | +| session #2 (blacklisted / pre-revocation token → 401) | criteria 1, 2 | +| session #9 (Redis absent → memory fallback) | criterion 6 | +| session doc acceptance row "After logout, same access token → 401 `TOKEN_REVOKED`" | criterion 1 | + +## Diff +| File | Why | +|---|---| +| `src/server.ts` | Middleware chain moved verbatim from `runServer` into exported `createApp()` (returns the app); `runServer` calls it. `startServer()` + the `unhandledRejection` handler now run only under `if (require.main === module)`, so importing the module (tests) has no Mongo/listen/process-handler side effects. `void` added to the startup call. | +| `src/__tests__/integration/auth.http.test.ts` (new) | 6 supertest tests over `createApp()` with `mongodb-memory-server`: Redis-absent precondition; register→login→GET→refresh→GET→logout → GET 401 `TOKEN_REVOKED` + refresh with logged-out refresh 401; rotated refresh reuse with `Date.now` +11s → 401, original + rotated access tokens 401, rotated refresh 401; cookie-only `POST /profile/create` without `x-csrf-token` → 403 `CSRF_TOKEN_INVALID`, nothing written; `candidateId` of another user in body → profile stored under the caller (IDOR); unknown route → 404 `{ success:false, error:{ code:'ROUTE_NOT_FOUND', message } }`. Logger mocked (`jest.mock('@/logger')`, as other suites); `memStore.clear()` per test. | +| `package.json` / `package-lock.json` | devDependencies `supertest@^7.3.2`, `@types/supertest@^7.2.1`, `mongodb-memory-server@^11.3.0`. Lockfile also re-hoists/dedupes transitive entries (npm's own rewrite); `npm ls --all` → exit 0. | +| `CLAUDE.md` | Conventions line "Middleware order is `runServer`" → `createApp` (would be stale after the move). | + +## Command +From `/Users/_david/Workspace/Project/resume/resume-nodejs-api` (copied from `doctrine/MEMORY.md`): +- `npx jest src/__tests__/integration/auth.http.test.ts` +- `npm test` +- `npm run build` (Typecheck row = `inside Build`); also `npx tsc --noEmit` +- `npm run lint`; plus `npx eslint src/server.ts src/__tests__/integration/auth.http.test.ts` and the same on `git show staging:src/server.ts` via `--stdin` for the before count +- Entry-point smoke: `MONGO_URI=mongodb://127.0.0.1:1/x NODE_ENV=development LOCAL_PORT=3999 perl -e 'alarm 50; exec @ARGV' node dist/server.js` and `node -e "require('./dist/server.js'); console.log('imported, no start')"` + +## Output (final run, after review fixes) +``` +PASS src/__tests__/integration/auth.http.test.ts (5.121 s) + ✓ runs with Redis absent (in-memory blacklist/revocation fallback) + ✓ register → login → authenticated GET → refresh → logout, then the logged-out token is rejected (269 ms) + ✓ reusing a rotated refresh token after the 10s grace window revokes every session (238 ms) + ✓ rejects a cookie-only state-changing request without the CSRF header (236 ms) + ✓ ignores a client-supplied candidateId (IDOR) (235 ms) + ✓ answers an unknown route with 404 in the standard error shape (5 ms) + +Test Suites: 1 passed, 1 total +Tests: 6 passed, 6 total +Snapshots: 0 total +Time: 5.186 s +Ran all test suites matching /src\/__tests__\/integration\/auth.http.test.ts/i. +Jest did not exit one second after the test run has completed. +``` +`npm test`: +``` +Test Suites: 74 passed, 74 total +Tests: 790 passed, 790 total +``` +(no `FAIL` lines in the grep of `^(Tests:|Test Suites:|FAIL)`) + +Build / typecheck: +``` +build exit 0 +tsc exit 0 +``` +Lint: +``` +✖ 273 problems (273 errors, 0 warnings) +``` +Changed files (`npx eslint src/server.ts src/__tests__/integration/auth.http.test.ts`): +``` + 7:1 error A `require()` style import is forbidden @typescript-eslint/no-require-imports + 8:1 error A `require()` style import is forbidden @typescript-eslint/no-require-imports + 146:5 error Promises must be awaited, ... @typescript-eslint/no-floating-promises + 146:5 error Expected an assignment or function call and instead saw an expression @typescript-eslint/no-unused-expressions +✖ 4 problems (4 errors, 0 warnings) +``` +Same file on `staging` (before): +``` + 7:1 error ... no-require-imports + 8:1 error ... no-require-imports + 144:5 error ... no-floating-promises + 144:5 error ... no-unused-expressions + 150:1 error ... no-floating-promises +✖ 5 problems (5 errors, 0 warnings) +``` +→ all 4 remaining are pre-existing (lines 7/8 module-alias requires, `isConnected && runServer(...)` moved 144→146); the 5th (`startServer();` floating) is gone. Test file: 0 problems. + +Smoke: +``` +[MongoDB] Connect failed !!! MongooseServerSelectionError: connect ECONNREFUSED 127.0.0.1:1 +``` +(direct run still reaches `startServer` → `connectMongo`) +``` +imported, no start +``` +(import alone starts nothing) + +First run (before fixing the test itself) failed 2/6 — CSRF test got 401 (same-second access-token collision with a token blacklisted by the logout test, see Noticed #1) and IDOR create got 400 `_id` required (Joi `_id` is required-but-nullable → body sends `_id: null`). Both were test-setup errors, fixed by one user per flow + `_id: null`; no app code changed for them. + +## Acceptance +| Criterion | Evidence | +|---|---| +| 1. register→login→GET→refresh→logout, token rejected after | `✓ register → login → authenticated GET → refresh → logout, then the logged-out token is rejected` (asserts GET 401 `TOKEN_REVOKED`, refresh 401 `TOKEN_REVOKED`) | +| 2. rotated refresh reuse after grace revokes all sessions | `✓ reusing a rotated refresh token after the 10s grace window revokes every session` (reuse 401; both access tokens 401; rotated refresh 401 `TOKEN_REVOKED`) | +| 3. cookie-only state-changing request w/o CSRF → 403 | `✓ rejects a cookie-only state-changing request without the CSRF header` (403 `CSRF_TOKEN_INVALID`, `countDocuments` 0) | +| 4. client `candidateId` ignored | `✓ ignores a client-supplied candidateId (IDOR)` (stored `candidateId` = caller's id, not the body's) | +| 5. unknown route → 404 standard shape | `✓ answers an unknown route with 404 in the standard error shape` | +| 6. Redis absent → in-memory fallback | `✓ runs with Redis absent ...` (`isRedisAvailable()` false) + criteria 1–3 pass with no Redis initialised | +| Full suite green | `Tests: 790 passed, 790 total` | +| Typecheck (`inside Build`) | `build exit 0`, `tsc exit 0` | +| Lint ≤ 274, none new in changed files | `✖ 273 problems`; changed files 4 vs 5 on staging, all pre-existing | +| Entry point unchanged | smoke: direct run → `[MongoDB] Connect failed ... ECONNREFUSED 127.0.0.1:1`; import → `imported, no start` | +| comments per code-comments.md | Added: `/** */` JSDoc on exported `createApp` (WHY: tests drive it); `//` on the `require.main` guard (WHY: import must not connect/bind/install handlers); test `//` notes on one-user-per-flow (jti trap), `memStore.clear()` (shared 127.0.0.1 bucket), revocation predating. Moved unchanged: the `unhandledRejection` safety-net comment. No `(#N)` refs. | + +## Supersedes: none +`grep "#463"` on the active diagram → only this node. + +## Still open: none + +## Review +`/code-review medium` (background fork) — 9 findings: +1. Access tokens lack `jti` → same-second tokens identical, logout blacklists another session → real pre-existing prod bug, not introduced here → `## Noticed, not done` #1. +2. Reuse test didn't assert the rotated refresh token is rejected → **fixed** (added refresh with `newRefresh` → 401 `TOKEN_REVOKED`). +3. Tests sat just under the shared authLimiter bucket → **fixed** (`beforeEach(() => memStore.clear())`, `memStore` already exported). +4. Real Winston logger writes to `logs/` and floods console → **fixed** (`jest.mock('@/logger')`, same as `errors.test.ts`). +5. Importing `server.ts` runs `dotenv.config()` + registers `unhandledRejection` → handler **fixed** (moved under the `require.main` guard); dotenv part false positive — `src/config/process.config.ts:6` already `import 'dotenv/config'` on any import, so moving server's call changes nothing. +6. Redis-absent assertion is tautological → kept intentionally as a precondition guard: it fails if `createApp()` ever starts initialising Redis, which would silently stop the suite from covering the fallback path the issue asks for. +7. `mongodb-memory-server` postinstall downloads a mongod binary on `npm ci` (Docker deps stage, CI) → `## Noticed, not done` #2. +8. `CLAUDE.md` names `runServer` for middleware order → **fixed** (`createApp`). +9. Sequential bcrypt registers → **fixed** (`Promise.all`). +Re-ran step 5 after fixes (Output above is the post-fix run). No `security` label → no `/security-review`. + +## Noticed, not done +1. **Access tokens have no `jti`** (`src/auth/auth.service.ts` `handlerLogin`, `src/auth/auth.controller.ts:167` `authRefreshToken`): two access tokens for one candidate signed in the same second are byte-identical, so logout on one device (or a refresh in the same second as login) blacklists the other device's token → 401 `TOKEN_REVOKED`. Reproduced by this suite's first run. Fix = `jti: crypto.randomUUID()` in the access payload like refresh tokens. Suggest its own issue/node (`fix-access-token-jti`). +2. `mongodb-memory-server` has a postinstall that downloads mongod on `npm ci` (CI, Docker `deps` stage). Locally it was blocked by npm `allow-scripts` and the binary downloaded lazily on first `MongoMemoryServer.create()`. Option: `MONGOMS_DISABLE_POSTINSTALL=1` in the Dockerfile deps stage, or `mongodb-memory-server-core`. CI run on GitHub not observed yet. +3. `withTimeout` (`src/utils/timeout.ts:21`) never clears its timer when no `signal` is passed → each DB call leaves a 5s timer; cause of Jest's "did not exit one second after" (process exits within ~5s). Pre-existing. + +## Seal gate +No outward-facing action (no commit/push). `gh issue develop` created the remote branch ref as part of `/todo` Step 0. diff --git a/agent-hub/evidence/implementer/2026-11-18/auth-http-integration-tests-plan.md b/agent-hub/evidence/implementer/2026-11-18/auth-http-integration-tests-plan.md new file mode 100644 index 00000000..f45afebd --- /dev/null +++ b/agent-hub/evidence/implementer/2026-11-18/auth-http-integration-tests-plan.md @@ -0,0 +1,25 @@ +# 2026-11-18 - auth-http-integration-tests (plan) +Worker: implementer · Version: 0.1.0 · Node: `haven/diagrams/dev-loop.prime-mermaid.md` → `auth-http-integration-tests` · Task: `/todo #463` — "Add HTTP-level integration tests for the auth flow (supertest + in-memory Mongo)" + +## Hub bytes before: 97851 + +## Feature doc: doctrine/features/auth-session-tokens.md (Behavior #2, #3, #4, #5, #6, #7, #9), doctrine/features/auth-register-login.md (Behavior #1, #3, #5, #6) +Spec only — tests assert the documented behavior, no behavior change. + +## Task type +Operator picked branch type `chore` (2026-11-18, AskUserQuestion) → not a `feat`; pass 0 analyst skipped (auth area already has verified docs in `doctrine/features/INDEX.md`). + +## Acceptance (node criteria) +1. register → login → authenticated GET → refresh → logout; the logged-out access token → 401 `TOKEN_REVOKED` (session Behavior #7, acceptance row "After logout…"). +2. Reuse of a rotated refresh token > 10s after rotation → 401 and every session of that candidate revoked (Behavior #6). +3. Cookie-only state-changing request without `x-csrf-token` → 403 `CSRF_TOKEN_INVALID` (Behavior #3). +4. Client-supplied `candidateId` ignored on create (Behavior #4). +5. Unknown route → 404 `{ success:false, error:{ code:'ROUTE_NOT_FOUND', message } }`. +6. Redis never initialised → `isRedisAvailable()` false, flows above pass on the in-memory fallback (Behavior #9). +Commands: `npx jest src/__tests__/integration/auth.http.test.ts`, `npm test`, `npm run build`, `npm run lint` (≤ 274). + +## Anchors +- `src/server.ts` — `runServer` builds the app inline and `startServer()` runs on import → factor the middleware chain into exported `createApp()`, guard `startServer()` with `require.main === module`. +- `src/routers/api/v1/auth.route.ts`, `src/auth/auth.controller.ts` (refresh reuse grace `REFRESH_REUSE_GRACE_SECONDS`), `src/middlewares/verifyToken.middleware.ts`, `src/utils/tokenBlacklist.ts`, `src/utils/sessionRevocation.ts`, `src/middlewares/errors.middleware.ts` (`notFoundHandler`). +- IDOR target: `POST /api/v1/profile/create` (only `name` required). +- New dev deps: `supertest`, `@types/supertest`, `mongodb-memory-server`. diff --git a/agent-hub/evidence/verifier/2026-11-18/auth-http-integration-tests-seal.md b/agent-hub/evidence/verifier/2026-11-18/auth-http-integration-tests-seal.md new file mode 100644 index 00000000..b82394fb --- /dev/null +++ b/agent-hub/evidence/verifier/2026-11-18/auth-http-integration-tests-seal.md @@ -0,0 +1,41 @@ +# auth-http-integration-tests — verify: SEAL + +- Worker: verifier 0.1.0 · Node: `auth-http-integration-tests` (#463, branch `chore/463-auth-integration-tests`) on `haven/diagrams/dev-loop.prime-mermaid.md` +- Notes graded: `evidence/implementer/2026-11-18/auth-http-integration-tests-plan.md`, `evidence/implementer/2026-11-18/auth-http-integration-tests-diff.md` +- New PM status: **SEALED** + +## Isolation proof +Agent-tool spawn, description "verify_seal auth-http-integration-tests", dispatched by `/todo #463` pass 2 on 2026-11-18, spawn=fresh. Did not write the diff; graded the notes only (diff itself not opened). + +## Reasoning +Commands match `doctrine/MEMORY.md` (Test one file, Test, Build = Typecheck `inside Build`, Lint with baseline 274), all run from the repo root. + +| Criterion | Evidence in note | OK | +|---|---|---| +| 1. register→login→GET→refresh→logout, logged-out token rejected | `✓ register → login → authenticated GET → refresh → logout, then the logged-out token is rejected` (GET 401 `TOKEN_REVOKED`, refresh 401 `TOKEN_REVOKED`) | yes | +| 2. rotated refresh reuse >10s revokes all sessions | `✓ reusing a rotated refresh token after the 10s grace window revokes every session` (reuse 401, both access tokens 401, rotated refresh 401) | yes | +| 3. cookie-only POST without CSRF → 403 | `✓ rejects a cookie-only state-changing request without the CSRF header` (403 `CSRF_TOKEN_INVALID`, nothing written) | yes | +| 4. client `candidateId` ignored (IDOR) | `✓ ignores a client-supplied candidateId (IDOR)` | yes | +| 5. unknown route → 404 standard shape | `✓ answers an unknown route with 404 in the standard error shape` | yes | +| 6. Redis absent → in-memory fallback | `✓ runs with Redis absent (in-memory blacklist/revocation fallback)`; criteria 1-3 pass with Redis never initialised | yes | +| One-file test green | `Tests: 6 passed, 6 total` | yes | +| `npm test` green | `Test Suites: 74 passed, 74 total` / `Tests: 790 passed, 790 total` | yes | +| `npm run build` green (typecheck) | `build exit 0`, `tsc exit 0` | yes | +| Lint ≤ 274, none in changed files | `✖ 273 problems`. Changed files: test file 0; `src/server.ts` 4, all pre-existing (5 on `staging`: lines 7/8 module-alias `require`, `isConnected && runServer(...)` 144→146; the floating `startServer();` is gone). Read as "none introduced": clearing pre-existing errors would be out of scope (`SmallestDiff`). Confirmed by re-run below. | yes | +| comments per code-comments.md | row present: JSDoc on `createApp`, WHY comment on `require.main` guard, test WHY notes, no `(#N)` refs | yes | +| Feature docs (`auth-session-tokens.md` #2-#7, #9; `auth-register-login.md` #1, #3, #5, #6) | Behavior → test mapping table in the diff note; I read both docs' Behavior sections, the mapping matches. Chore, not `feat` → doc Status untouched. | yes | +| Entry point unchanged | smoke: direct run reaches `connectMongo` (`ECONNREFUSED 127.0.0.1:1`); import → `imported, no start` | yes | + +- Supersedes / Still open: `none` (grep `#463` → only this node). OK. +- Review: `/code-review medium`, 9 findings, each fixed or justified (jti bug + postinstall download moved to Noticed). No `security` label → no `/security-review` required. OK. +- Doctrine proposal: none. +- Forbidden states (5): none hit. Node exists on the active diagram; evidence present; no code in `haven/`; no own work graded; PM status only moves forward. +- Seal gate: no outward-facing action (no commit/push). OK. +- Proportionality: `src/server.ts` refactor (`createApp()` + `require.main` guard) is the minimum needed to import the app in tests; `CLAUDE.md` one-line rename keeps the doc accurate; dev deps are the three the plan names. Lockfile churn is npm's rewrite (`npm ls --all` exit 0). OK. + +## Noted for the operator (not blocking) +- Diff note "Noticed, not done" #1, access tokens have no `jti`: same-second tokens are identical, so logout on one device can revoke another device's session. This is a real pre-existing prod bug and should get its own node/issue. +- #2: the `mongodb-memory-server` postinstall downloads mongod on `npm ci` (CI and the Docker deps stage). No GitHub CI run observed yet. + +## Re-run: partial +`npx eslint src/server.ts src/__tests__/integration/auth.http.test.ts` and `git show staging:src/server.ts | npx eslint --stdin --stdin-filename src/server.ts`. Reason: the note shortened the lint messages with `...` (the output looks cut). Result matches the note exactly: after = 4 problems (7:1, 8:1, 146:5 ×2), test file clean; before = 5 problems (7:1, 8:1, 144:5 ×2, 150:1). Tests, build and full lint were not re-run. diff --git a/agent-hub/evidence/worker-runs.log b/agent-hub/evidence/worker-runs.log index ecfea64d..94b4446e 100644 --- a/agent-hub/evidence/worker-runs.log +++ b/agent-hub/evidence/worker-runs.log @@ -1,3 +1,4 @@ 2026-11-17T08:37:32Z role=verifier outcome=SEAL node=logout-refresh-token-header rerun=none spawn=fresh hub_bytes_before=97847 hub_bytes_after=97849 2026-11-17T08:46:36Z role=verifier outcome=SEAL node=auth-service-throw-apperror rerun=none spawn=fresh hub_bytes_before=97847 hub_bytes_after=97849 2026-11-18T09:00:21Z role=verifier outcome=SEAL node=hide-password-select-false rerun=none spawn=fresh hub_bytes_before=97857 hub_bytes_after=97851 +2026-11-18T09:36:07Z role=verifier outcome=SEAL node=auth-http-integration-tests rerun=partial spawn=fresh hub_bytes_before=97851 hub_bytes_after=97855 diff --git a/agent-hub/haven/diagrams/dev-loop-archive.md b/agent-hub/haven/diagrams/dev-loop-archive.md index bc2285f4..772ee9b6 100644 --- a/agent-hub/haven/diagrams/dev-loop-archive.md +++ b/agent-hub/haven/diagrams/dev-loop-archive.md @@ -188,3 +188,4 @@ | `auth-service-throw-apperror` | SEALED | #460 — `src/auth/auth.service.ts` returns `{ success:false }` (register/verify-email/login/reset-password) instead of throwing `AppError` subclasses; controller branches on it. Acceptance: (1) `grep -n "success: false" src/auth/auth.service.ts` empty and the controller no longer branches on a service `success` flag; (2) contract tests assert `{ success:false, error:{ code, message } }` + status for invalid reset/verify tokens (400 `BAD_REQUEST`); (3) behavior per `features/auth-register-login.md` #2/#5 and `features/auth-password-reset.md` (409 `EMAIL_EXISTS`, 401 `INVALID_CREDENTIALS`, 400 on bad token) unchanged; (4) `npm test` + `npm run build` green, lint ≤ baseline with none in touched files. Plan: `evidence/implementer/2026-11-17/auth-service-throw-apperror-plan.md`. | | `logout-refresh-token-header` | SEALED | #475 — `authLogout` (`src/auth/auth.controller.ts`) looks up `refreshToken` via `extractTokenFromRequest`, which returns the `Authorization` header first, so it blacklists the access token twice and the real refresh token stays valid. Fix: that lookup skips the header (body/query/cookie only); `/auth/refresh` keeps header support (operator, 2026-11-17). Acceptance: new unit test logout with `Bearer ` + body `refreshToken` blacklists both; `npm test` + `npm run build` green; lint ≤ baseline, none in touched files; matches `features/auth-session-tokens.md` Behavior #7 (as amended). | | `hide-password-select-false` | SEALED | GitHub issue #459. `src/models/candidate.model.ts:25` — `password` returned by default, every query must remember `.select('-password')` (#152 regressed exactly this). Fix: `select: false` on the schema; opt in with `.select('+password')` only where the hash is compared (`auth.service.ts` `handlerLogin`; reset writes via `updateOne`, needs no read). Acceptance: (1) login reads the hash via `+password` — `npx jest src/__tests__/auth/auth.service.test.ts` green; (2) new test: a plain `CandidateModel.findById()` query sends a projection excluding `password` — `npx jest src/__tests__/models/candidatePassword.test.ts` green; (3) `npm test` + `npm run build` green, lint ≤ baseline with none in changed files. SEALED 2026-11-18 after independent verifier pass (audit-only, no re-run). Evidence: `evidence/implementer/2026-11-18/hide-password-select-false.md`, `evidence/verifier/2026-11-18/hide-password-select-false-seal.md`. | +| `auth-http-integration-tests` | SEALED | #463 — HTTP-level supertest + mongodb-memory-server tests over the real `runServer` middleware chain (`src/server.ts`, app factored into an exported `createApp()`): register→login→GET→refresh→logout (token rejected after); rotated refresh reuse >10s revokes all sessions; cookie-only POST without CSRF → 403; client `candidateId` ignored (IDOR); unknown route → 404 standard error shape; Redis absent (in-memory fallback). Accept: `npx jest src/__tests__/integration/auth.http.test.ts` + `npm test` + `npm run build` green; lint ≤ 274 baseline, none in changed files. SEALED 2026-11-18 after independent verifier pass (partial re-run: eslint on changed files). Evidence: `evidence/implementer/2026-11-18/auth-http-integration-tests-diff.md`, `evidence/verifier/2026-11-18/auth-http-integration-tests-seal.md`. | diff --git a/agent-hub/haven/diagrams/dev-loop.prime-mermaid.md b/agent-hub/haven/diagrams/dev-loop.prime-mermaid.md index b5beb8ea..c553722f 100644 --- a/agent-hub/haven/diagrams/dev-loop.prime-mermaid.md +++ b/agent-hub/haven/diagrams/dev-loop.prime-mermaid.md @@ -64,7 +64,6 @@ flowchart TD | `fix-refresh-token-expiry-unused` | PENDING | `TOKEN_EXP_IN` (`.env`, already exported in config) is never used at any `jwtSign()` call site (`auth.service.ts`, `auth.controller.ts`, `api/v1/auth/services/login.ts`) — access and refresh tokens always share the same default 1h expiry, so the refresh token is pointless. | | `ci-lint-ratchet` | SEALED | 2026-11-16 — archived, see `haven/diagrams/dev-loop-archive.md`. Evidence: `evidence/verifier/2026-11-16/ci-lint-ratchet-seal.md`. | | `job-applications-status-transitions` | SEALED | 2026-11-15 — archived, see `haven/diagrams/dev-loop-archive.md`. Evidence: `evidence/verifier/2026-11-15/job-applications-status-transitions-seal.md`. | -| `parsed-entries-bulk-shape` | SEALED | 2026-11-08 — archived, see `haven/diagrams/dev-loop-archive.md`. Evidence: `evidence/verifier/2026-11-08/parsed-entries-bulk-shape-seal.md`. | | `short-values-validation` | SEALED | 2026-11-08 — archived, see `haven/diagrams/dev-loop-archive.md`. Evidence: `evidence/verifier/2026-11-08/short-values-validation-seal-r2.md`. | | `paginate-visits` | SEALED | 2026-11-09 — archived, see `haven/diagrams/dev-loop-archive.md`. Evidence: `evidence/verifier/2026-11-09/paginate-visits-seal.md`. | | `search-in-profile-only` | SEALED | 2026-11-09 — archived, see `haven/diagrams/dev-loop-archive.md`. Evidence: `evidence/verifier/2026-11-09/search-in-profile-only-seal.md`. | @@ -81,3 +80,4 @@ flowchart TD | `contributing-kit-template` | SEALED | 2026-11-16 — archived, see `haven/diagrams/dev-loop-archive.md`. Evidence: `evidence/verifier/2026-11-16/contributing-kit-template-seal.md`. | | `auth-service-throw-apperror` | SEALED | 2026-11-17 — archived, see `haven/diagrams/dev-loop-archive.md`. Evidence: `evidence/verifier/2026-11-17/auth-service-throw-apperror-seal.md`. | | `hide-password-select-false` | SEALED | 2026-11-18 — archived, see `haven/diagrams/dev-loop-archive.md`. Evidence: `evidence/verifier/2026-11-18/hide-password-select-false-seal.md`. | +| `auth-http-integration-tests` | SEALED | 2026-11-18 — archived, see `haven/diagrams/dev-loop-archive.md`. Evidence: `evidence/verifier/2026-11-18/auth-http-integration-tests-seal.md`. | diff --git a/package-lock.json b/package-lock.json index 2e81fe52..f0081410 100644 --- a/package-lock.json +++ b/package-lock.json @@ -48,11 +48,14 @@ "@types/multer": "^2.2.0", "@types/node": "^20.14.12", "@types/pdf-parse": "^1.1.5", + "@types/supertest": "^7.2.1", "@types/swagger-jsdoc": "^6.0.4", "@types/swagger-ui-express": "^4.1.8", "eslint": "^9.39.5", "jest": "^29.7.0", + "mongodb-memory-server": "^11.3.0", "nodemon": "^3.1.0", + "supertest": "^7.3.2", "ts-jest": "^29.2.5", "ts-node": "^10.9.2", "tsconfig-paths": "^4.2.0", @@ -1475,30 +1478,6 @@ "node-pre-gyp": "bin/node-pre-gyp" } }, - "node_modules/@mapbox/node-pre-gyp/node_modules/make-dir": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", - "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", - "license": "MIT", - "dependencies": { - "semver": "^6.0.0" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/@mapbox/node-pre-gyp/node_modules/make-dir/node_modules/semver": { - "version": "6.3.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", - "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", - "license": "ISC", - "bin": { - "semver": "bin/semver.js" - } - }, "node_modules/@mapbox/node-pre-gyp/node_modules/semver": { "version": "7.6.3", "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", @@ -1512,14 +1491,37 @@ } }, "node_modules/@mongodb-js/saslprep": { - "version": "1.1.9", - "resolved": "https://registry.npmjs.org/@mongodb-js/saslprep/-/saslprep-1.1.9.tgz", - "integrity": "sha512-tVkljjeEaAhCqTzajSdgbQ6gE6f3oneVwa3iXR6csiEwXXOFsiC6Uh9iAjAhXPtqa/XMDHWjjeNH/77m/Yq2dw==", + "version": "1.6.3", + "resolved": "https://registry.npmjs.org/@mongodb-js/saslprep/-/saslprep-1.6.3.tgz", + "integrity": "sha512-aHGFvT95c82CoQ7hb6qXpz8Hcc5PJb3ZtQ+P01QDBbyQday0mjcrJPeNJOHCgWe0pGX0zKmKP+1mWi/I/BCX9Q==", "license": "MIT", "dependencies": { "sparse-bitfield": "^3.0.3" } }, + "node_modules/@noble/hashes": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.8.0.tgz", + "integrity": "sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^14.21.3 || >=16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@paralleldrive/cuid2": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/@paralleldrive/cuid2/-/cuid2-2.3.1.tgz", + "integrity": "sha512-XO7cAxhnTZl0Yggq6jOgjiOHhbgcO4NqFqwSmQpjK3b6TEE6Uj/jfSk6wzYyemh3+I0sHirKSetjQwn5cZktFw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@noble/hashes": "^1.1.5" + } + }, "node_modules/@pdf-lib/standard-fonts": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/@pdf-lib/standard-fonts/-/standard-fonts-1.0.0.tgz", @@ -1844,6 +1846,13 @@ "@types/express": "*" } }, + "node_modules/@types/cookiejar": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/@types/cookiejar/-/cookiejar-2.1.5.tgz", + "integrity": "sha512-he+DHOWReW0nghN24E1WUqM0efK4kI9oTqDm6XmK8ZPe2djZ90BSNdGnIyCLzCPw7/pogPlGbzI2wHGGmi4O/Q==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/cors": { "version": "2.8.17", "resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.17.tgz", @@ -1965,6 +1974,13 @@ "@types/node": "*" } }, + "node_modules/@types/methods": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/@types/methods/-/methods-1.1.4.tgz", + "integrity": "sha512-ymXWVrDiCxTBE3+RIrrP533E70eA+9qu7zdWoHuOmGujkYtzf4HQF96b8nwHLqhuf4ykX61IGRIB38CC6/sImQ==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/mime": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/@types/mime/-/mime-1.3.5.tgz", @@ -2046,6 +2062,30 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/superagent": { + "version": "8.1.11", + "resolved": "https://registry.npmjs.org/@types/superagent/-/superagent-8.1.11.tgz", + "integrity": "sha512-KA7srSW/HENDtOw9DOqaFLgWuMqN9WgjEw62lh9dpvRaZDkhdOkazASd7X7i2eMUYLHa1U37ZttnePsH5zTDHw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/cookiejar": "^2.1.5", + "@types/methods": "^1.1.4", + "@types/node": "*", + "form-data": "^4.0.0" + } + }, + "node_modules/@types/supertest": { + "version": "7.2.1", + "resolved": "https://registry.npmjs.org/@types/supertest/-/supertest-7.2.1.tgz", + "integrity": "sha512-4CbBvoYVLHL7+yhbYrZET0vsvuyXTC05aRe7dNQkwMzm56auceoy6Yu3K50uZmwfHna1os3CMSgM/3QVkUtPTw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/methods": "^1.1.4", + "@types/superagent": "^8.1.0" + } + }, "node_modules/@types/swagger-jsdoc": { "version": "6.0.4", "resolved": "https://registry.npmjs.org/@types/swagger-jsdoc/-/swagger-jsdoc-6.0.4.tgz", @@ -2599,6 +2639,13 @@ "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==", "license": "MIT" }, + "node_modules/asap": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", + "integrity": "sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA==", + "dev": true, + "license": "MIT" + }, "node_modules/ast-types": { "version": "0.13.4", "resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.13.4.tgz", @@ -2617,11 +2664,36 @@ "integrity": "sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==", "license": "MIT" }, + "node_modules/async-mutex": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/async-mutex/-/async-mutex-0.5.0.tgz", + "integrity": "sha512-1A94B18jkJ3DYq284ohPxoXbfTA5HsQ7/Mf4DEhcyLx3Bz27Rh59iScbB6EPiP+B+joue6YCxcMXSbFC1tZKwA==", + "dev": true, + "license": "MIT", + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", + "dev": true, + "license": "MIT" + }, "node_modules/b4a": { - "version": "1.6.7", - "resolved": "https://registry.npmjs.org/b4a/-/b4a-1.6.7.tgz", - "integrity": "sha512-OnAYlL5b7LEkALw87fUVafQw5rVR9RjwGd4KUwNQ6DrrNmaVaUCgLipfVlzrPQ4tWOR9P0IXGNOx50jYCCdSJg==", - "license": "Apache-2.0" + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/b4a/-/b4a-1.9.0.tgz", + "integrity": "sha512-dpfcF9fDNR6++cthXR67iyhgqWy9CBouAvIWhIntzBG6cvK/cnIPiZQjBwi/ZqjjBEDGfoNDtmB0kTjroOJ3pQ==", + "license": "Apache-2.0", + "peerDependencies": { + "react-native-b4a": "*" + }, + "peerDependenciesMeta": { + "react-native-b4a": { + "optional": true + } + } }, "node_modules/babel-jest": { "version": "29.7.0", @@ -2755,12 +2827,28 @@ "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", "license": "MIT" }, + "node_modules/bare-buffer": { + "version": "3.7.3", + "resolved": "https://registry.npmjs.org/bare-buffer/-/bare-buffer-3.7.3.tgz", + "integrity": "sha512-77owW16RX6YgdOzddHtM0oGz8wsd0/F9k/0coz6TPmjUHnr/9FwWODVMNKwyYWM/a/ESdTum855nfQxnsKUygA==", + "license": "Apache-2.0", + "engines": { + "bare": ">=1.20.0" + } + }, "node_modules/bare-events": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/bare-events/-/bare-events-2.5.0.tgz", - "integrity": "sha512-/E8dDe9dsbLyh2qrZ64PEPadOQ0F4gbl1sUJOrmph7xOiIxfY8vwab/4bFLh4Y88/Hk/ujKcrQKc+ps0mv873A==", + "version": "2.9.2", + "resolved": "https://registry.npmjs.org/bare-events/-/bare-events-2.9.2.tgz", + "integrity": "sha512-AIPKioV7/Y/8KfZ3AAhjPJxLLbY49S64Ym5DakZlUg75qQiTgUq9hEJoEwa4eUezPUlXRy/i5NpsKvo9jgKmoA==", "license": "Apache-2.0", - "optional": true + "peerDependencies": { + "bare-abort-controller": "*" + }, + "peerDependenciesMeta": { + "bare-abort-controller": { + "optional": true + } + } }, "node_modules/bare-fs": { "version": "2.3.5", @@ -2792,15 +2880,48 @@ } }, "node_modules/bare-stream": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/bare-stream/-/bare-stream-2.3.2.tgz", - "integrity": "sha512-EFZHSIBkDgSHIwj2l2QZfP4U5OcD4xFAOwhSb/vlr9PIqyGJGvB/nfClJbcnh3EY4jtPE4zsb5ztae96bVF79A==", + "version": "2.13.4", + "resolved": "https://registry.npmjs.org/bare-stream/-/bare-stream-2.13.4.tgz", + "integrity": "sha512-PcrQ8lVLbiJscNm1Kez+Yp4Gy4AHGcN1lzwjvf5NybWen7VvEgUfyfnXYJ2zNqWnzOfCb1Abq6lH8ti0syQszA==", + "license": "Apache-2.0", + "dependencies": { + "b4a": "^1.8.1", + "streamx": "^2.25.0", + "teex": "^1.0.1" + }, + "peerDependencies": { + "bare-abort-controller": "*", + "bare-buffer": "*", + "bare-events": "*" + }, + "peerDependenciesMeta": { + "bare-abort-controller": { + "optional": true + }, + "bare-buffer": { + "optional": true + }, + "bare-events": { + "optional": true + } + } + }, + "node_modules/bare-url": { + "version": "2.5.8", + "resolved": "https://registry.npmjs.org/bare-url/-/bare-url-2.5.8.tgz", + "integrity": "sha512-G5KTe5Bj6z5pqIxcn3lWlIFIv0rkXbccx0T0Xuf7t4RapfSWvFlcVbrwYXxFZ00PC4lp57OCIk6uXP/r3GbpDw==", "license": "Apache-2.0", - "optional": true, "dependencies": { - "streamx": "^2.20.0" + "bare-buffer": "^3.0.0", + "bare-path": "^3.0.0" } }, + "node_modules/bare-url/node_modules/bare-path": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/bare-path/-/bare-path-3.1.3.tgz", + "integrity": "sha512-8r+FVU/o4zcFmpCDqbqAYhHHbtXPP+cyZKo7DRGRWc7OLlNs4TMaSQEpXL/sIdzyEG0M7RHw4B7xYMGrTc+qrg==", + "license": "Apache-2.0" + }, "node_modules/base64-js": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", @@ -3049,17 +3170,27 @@ "node": ">= 0.8" } }, - "node_modules/call-bind": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.7.tgz", - "integrity": "sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w==", + "node_modules/call-bind-apply-helpers": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", + "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", "license": "MIT", "dependencies": { - "es-define-property": "^1.0.0", "es-errors": "^1.3.0", - "function-bind": "^1.1.2", - "get-intrinsic": "^1.2.4", - "set-function-length": "^1.2.1" + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/call-bound": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz", + "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "get-intrinsic": "^1.3.0" }, "engines": { "node": ">= 0.4" @@ -3334,6 +3465,36 @@ "node": ">=12.20" } }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dev": true, + "license": "MIT", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/commondir": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", + "integrity": "sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==", + "dev": true, + "license": "MIT" + }, + "node_modules/component-emitter": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.1.tgz", + "integrity": "sha512-T0+barUSQRTUQASh8bx02dl+DhF54GtIDY13Y3m9oWTklKbb3Wv974meRpeZ3lp1JpLVECWWNHC4vaG2XHXouQ==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -3426,6 +3587,13 @@ "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==", "license": "MIT" }, + "node_modules/cookiejar": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.4.tgz", + "integrity": "sha512-LDx6oHrK+PhzLKJU9j5S7/Y3jM/mUHvD/DeI1WQmJn652iPC5Y4TBzC9l+5OMOXlyTTA+SmVUPm0HQUwpD5Jqw==", + "dev": true, + "license": "MIT" + }, "node_modules/core-util-is": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", @@ -3584,23 +3752,6 @@ "node": ">=0.10.0" } }, - "node_modules/define-data-property": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz", - "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==", - "license": "MIT", - "dependencies": { - "es-define-property": "^1.0.0", - "es-errors": "^1.3.0", - "gopd": "^1.0.1" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/degenerator": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/degenerator/-/degenerator-5.0.1.tgz", @@ -3615,6 +3766,16 @@ "node": ">= 14" } }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.4.0" + } + }, "node_modules/delegates": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", @@ -3665,6 +3826,17 @@ "integrity": "sha512-DPnhUXvmvKT2dFA/j7B+riVLUt9Q6RKJlcppojL5CoRywJJKLDYnRlw0gTFKfgDPHP5E04UoB71SxoJlVZy8FA==", "license": "BSD-3-Clause" }, + "node_modules/dezalgo": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/dezalgo/-/dezalgo-1.0.4.tgz", + "integrity": "sha512-rXSP0bf+5n0Qonsb+SVVfNfIsimO4HEtmnIpPHY8Q1UCzKlQrDMfdobr8nJOOsRgWCyMRqeSBQzmWUMq7zvVig==", + "dev": true, + "license": "ISC", + "dependencies": { + "asap": "^2.0.0", + "wrappy": "1" + } + }, "node_modules/diff": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", @@ -3741,6 +3913,20 @@ "url": "https://dotenvx.com" } }, + "node_modules/dunder-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", + "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "es-errors": "^1.3.0", + "gopd": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/ecdsa-sig-formatter": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz", @@ -3841,13 +4027,10 @@ } }, "node_modules/es-define-property": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.0.tgz", - "integrity": "sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", + "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", "license": "MIT", - "dependencies": { - "get-intrinsic": "^1.2.4" - }, "engines": { "node": ">= 0.4" } @@ -3861,6 +4044,34 @@ "node": ">= 0.4" } }, + "node_modules/es-object-atoms": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.2.tgz", + "integrity": "sha512-HWcBoN6NileqtSydK2FqHbS/LoDd2pqrnQHLyJzBj4kOp/ky2MWMN694xOfkK8/SnUsW2DH7EfyVlydKCsm1Zw==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-set-tostringtag": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz", + "integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.6", + "has-tostringtag": "^1.0.2", + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/escalade": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", @@ -4141,6 +4352,15 @@ "node": ">= 0.6" } }, + "node_modules/events-universal": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/events-universal/-/events-universal-1.0.1.tgz", + "integrity": "sha512-LUd5euvbMLpwOF8m6ivPCbhQeSiYVNb8Vs0fQ8QjXo0JTkEHpz8pxdQf0gStltaPpw0Cca8b39KxvK9cfKRiAw==", + "license": "Apache-2.0", + "dependencies": { + "bare-events": "^2.7.0" + } + }, "node_modules/execa": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/execa/-/execa-5.1.1.tgz", @@ -4334,6 +4554,13 @@ "dev": true, "license": "MIT" }, + "node_modules/fast-safe-stringify": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.1.1.tgz", + "integrity": "sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==", + "dev": true, + "license": "MIT" + }, "node_modules/fast-uri": { "version": "3.1.5", "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.5.tgz", @@ -4476,6 +4703,24 @@ "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", "license": "MIT" }, + "node_modules/find-cache-dir": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-3.3.2.tgz", + "integrity": "sha512-wXZV5emFEjrridIgED11OoUKLxiYjAcqot/NJdAkOhlJ+vGzwhOAfcG5OX1jP+S0PcjEn8bdMJv+g2jwQ3Onig==", + "dev": true, + "license": "MIT", + "dependencies": { + "commondir": "^1.0.1", + "make-dir": "^3.0.2", + "pkg-dir": "^4.1.0" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/avajs/find-cache-dir?sponsor=1" + } + }, "node_modules/find-up": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", @@ -4520,6 +4765,27 @@ "integrity": "sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw==", "license": "MIT" }, + "node_modules/follow-redirects": { + "version": "1.16.3", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.16.3.tgz", + "integrity": "sha512-toOSoqN6d51Wjf1aOFJYcoVv1aND9rj/CwjLU0Vz40oDuSpWDayCeKe4JpL5NL0WdFvoOOCI3BRo69HahjbR1A==", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "license": "MIT", + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, "node_modules/foreground-child": { "version": "3.3.1", "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.3.1.tgz", @@ -4548,6 +4814,41 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/form-data": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.6.tgz", + "integrity": "sha512-vKatAh4SlVfgbv+YtmhiRjhEMJsYpsG1Y2rMQtR+SVSbytsSD1YGzDIcrAJmdFec88u/+VoGmxnl+80gL1tRCQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "es-set-tostringtag": "^2.1.0", + "hasown": "^2.0.4", + "mime-types": "^2.1.35" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/formidable": { + "version": "3.5.4", + "resolved": "https://registry.npmjs.org/formidable/-/formidable-3.5.4.tgz", + "integrity": "sha512-YikH+7CUTOtP44ZTnUhR7Ic2UASBPOqmaRkRKxRbywPTe5VxF7RRCck4af9wutiZ/QKM5nME9Bie2fFaPz5Gug==", + "dev": true, + "license": "MIT", + "dependencies": { + "@paralleldrive/cuid2": "^2.2.2", + "dezalgo": "^1.0.4", + "once": "^1.4.0" + }, + "engines": { + "node": ">=14.0.0" + }, + "funding": { + "url": "https://ko-fi.com/tunnckoCore/commissions" + } + }, "node_modules/forwarded": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", @@ -4750,16 +5051,21 @@ } }, "node_modules/get-intrinsic": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.4.tgz", - "integrity": "sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", + "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", "license": "MIT", "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", "function-bind": "^1.1.2", - "has-proto": "^1.0.1", - "has-symbols": "^1.0.3", - "hasown": "^2.0.0" + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "math-intrinsics": "^1.1.0" }, "engines": { "node": ">= 0.4" @@ -4778,7 +5084,20 @@ "node": ">=8.0.0" } }, - "node_modules/get-stream": { + "node_modules/get-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", + "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/get-stream": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz", "integrity": "sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==", @@ -4853,12 +5172,12 @@ } }, "node_modules/gopd": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz", - "integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", "license": "MIT", - "dependencies": { - "get-intrinsic": "^1.1.3" + "engines": { + "node": ">= 0.4" }, "funding": { "url": "https://github.com/sponsors/ljharb" @@ -4879,22 +5198,10 @@ "node": ">=8" } }, - "node_modules/has-property-descriptors": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz", - "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==", - "license": "MIT", - "dependencies": { - "es-define-property": "^1.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/has-proto": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.3.tgz", - "integrity": "sha512-SJ1amZAJUiZS+PhsVLf5tGydlaVB8EdFpaSO4gmiUKUOxk8qzn5AIy4ZeJUmh22znIdk/uMAUT2pl3FxzVUH+Q==", + "node_modules/has-symbols": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", "license": "MIT", "engines": { "node": ">= 0.4" @@ -4903,11 +5210,15 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/has-symbols": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", - "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==", + "node_modules/has-tostringtag": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz", + "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==", + "dev": true, "license": "MIT", + "dependencies": { + "has-symbols": "^1.0.3" + }, "engines": { "node": ">= 0.4" }, @@ -4932,9 +5243,9 @@ } }, "node_modules/hasown": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", - "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.4.tgz", + "integrity": "sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==", "license": "MIT", "dependencies": { "function-bind": "^1.1.2" @@ -5123,75 +5434,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/import-local/node_modules/find-up": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", - "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", - "dev": true, - "license": "MIT", - "dependencies": { - "locate-path": "^5.0.0", - "path-exists": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/import-local/node_modules/locate-path": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", - "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", - "dev": true, - "license": "MIT", - "dependencies": { - "p-locate": "^4.1.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/import-local/node_modules/p-limit": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", - "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", - "dev": true, - "license": "MIT", - "dependencies": { - "p-try": "^2.0.0" - }, - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/import-local/node_modules/p-locate": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", - "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", - "dev": true, - "license": "MIT", - "dependencies": { - "p-limit": "^2.2.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/import-local/node_modules/pkg-dir": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", - "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "find-up": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/imurmurhash": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", @@ -5220,14 +5462,10 @@ "license": "ISC" }, "node_modules/ip-address": { - "version": "9.0.5", - "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-9.0.5.tgz", - "integrity": "sha512-zHtQzGojZXTwZTHQqra+ETKd4Sn3vgi7uBmlPoXVWZqYvuKmtI0l/VZTjqGmJY9x88GGOaZ9+G9ES8hC4T4X8g==", + "version": "10.7.6", + "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-10.7.6.tgz", + "integrity": "sha512-00LYkM6byILa9eQIx6qoaXCM40xTLd56AZ4vyaPW3YTyb49VZYPo5xsiAq4tuQ54GH4R7gVdYScJ1B7B77PuTg==", "license": "MIT", - "dependencies": { - "jsbn": "1.1.0", - "sprintf-js": "^1.1.3" - }, "engines": { "node": ">= 12" } @@ -6575,6 +6813,21 @@ "yallist": "^3.0.2" } }, + "node_modules/make-dir": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", + "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", + "license": "MIT", + "dependencies": { + "semver": "^6.0.0" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/make-error": { "version": "1.3.6", "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", @@ -6592,6 +6845,15 @@ "tmpl": "1.0.5" } }, + "node_modules/math-intrinsics": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", + "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, "node_modules/media-typer": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", @@ -6846,6 +7108,226 @@ "whatwg-url": "^13.0.0" } }, + "node_modules/mongodb-memory-server": { + "version": "11.3.0", + "resolved": "https://registry.npmjs.org/mongodb-memory-server/-/mongodb-memory-server-11.3.0.tgz", + "integrity": "sha512-8ZCDrraqKqmAikoeKuEq+16jeWdVKwjtEAuMxxeQctHiGSGYt17W9LmoRzV1Nwnz7owyxwDKMhow4IVkNYYRKw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "dependencies": { + "mongodb-memory-server-core": "11.3.0", + "tslib": "^2.8.1" + }, + "engines": { + "node": ">=20.19.0" + } + }, + "node_modules/mongodb-memory-server-core": { + "version": "11.3.0", + "resolved": "https://registry.npmjs.org/mongodb-memory-server-core/-/mongodb-memory-server-core-11.3.0.tgz", + "integrity": "sha512-QBu/RsRpBfcNd5CrBDfCzqcaFPaYpivUzGYUy9YgVc3up78ff0gIHQVD9PLmBLOOxFX6BM9hU6YT0HocZH+s1g==", + "dev": true, + "license": "MIT", + "dependencies": { + "async-mutex": "^0.5.0", + "camelcase": "^6.3.0", + "debug": "^4.4.3", + "find-cache-dir": "^3.3.2", + "follow-redirects": "^1.16.0", + "https-proxy-agent": "^7.0.6", + "mongodb": "~7.5.0", + "new-find-package-json": "^2.0.0", + "semver": "^7.8.5", + "tar-stream": "^3.2.1", + "tslib": "^2.8.1", + "yauzl": "^3.4.0" + }, + "engines": { + "node": ">=20.19.0" + } + }, + "node_modules/mongodb-memory-server-core/node_modules/@types/whatwg-url": { + "version": "13.0.0", + "resolved": "https://registry.npmjs.org/@types/whatwg-url/-/whatwg-url-13.0.0.tgz", + "integrity": "sha512-N8WXpbE6Wgri7KUSvrmQcqrMllKZ9uxkYWMt+mCSGwNc0Hsw9VQTW7ApqI4XNrx6/SaM2QQJCzMPDEXE058s+Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/webidl-conversions": "*" + } + }, + "node_modules/mongodb-memory-server-core/node_modules/agent-base": { + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.4.tgz", + "integrity": "sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 14" + } + }, + "node_modules/mongodb-memory-server-core/node_modules/bson": { + "version": "7.3.4", + "resolved": "https://registry.npmjs.org/bson/-/bson-7.3.4.tgz", + "integrity": "sha512-eb33j2Ha6xgygjJ8bhI3sYaI9cLAbSaopZLRJQ5/rxk32XyBSoVVcbeHIzVGJx1SyQpyyoElkoEZgQrg+RVVoA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=20.19.0" + } + }, + "node_modules/mongodb-memory-server-core/node_modules/camelcase": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", + "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/mongodb-memory-server-core/node_modules/https-proxy-agent": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.6.tgz", + "integrity": "sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==", + "dev": true, + "license": "MIT", + "dependencies": { + "agent-base": "^7.1.2", + "debug": "4" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/mongodb-memory-server-core/node_modules/mongodb": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-7.5.0.tgz", + "integrity": "sha512-5FnrEDLnvp6ycUOGLNLLU33BfCx2qmp2mJjGPDwKLruYsVzXVSK5fsGpoDXvsXJwBfBsD7ebMRdawbDxC2814g==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@mongodb-js/saslprep": "^1.4.11", + "bson": "^7.2.0", + "mongodb-connection-string-url": "^7.0.1" + }, + "engines": { + "node": ">=20.19.0" + }, + "peerDependencies": { + "@aws-sdk/credential-providers": "^3.806.0", + "@mongodb-js/zstd": "^7.0.0", + "gcp-metadata": "^7.0.1", + "kerberos": "^7.0.0", + "mongodb-client-encryption": "^7.2.0", + "snappy": "^7.3.2", + "socks": "^2.8.6" + }, + "peerDependenciesMeta": { + "@aws-sdk/credential-providers": { + "optional": true + }, + "@mongodb-js/zstd": { + "optional": true + }, + "gcp-metadata": { + "optional": true + }, + "kerberos": { + "optional": true + }, + "mongodb-client-encryption": { + "optional": true + }, + "snappy": { + "optional": true + }, + "socks": { + "optional": true + } + } + }, + "node_modules/mongodb-memory-server-core/node_modules/mongodb-connection-string-url": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/mongodb-connection-string-url/-/mongodb-connection-string-url-7.0.3.tgz", + "integrity": "sha512-5I/pX3C2gPEz1EDdYMdZwBx1b/jE/f+J+KItSUJ02uQZ66bbe7kHKjv2uqCHJWaMCagem3dyfWqoAcv+XYZ6aw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@types/whatwg-url": "^13.0.0", + "whatwg-url": "^15.0.1" + }, + "engines": { + "node": ">=20.19.0" + } + }, + "node_modules/mongodb-memory-server-core/node_modules/semver": { + "version": "7.8.6", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.6.tgz", + "integrity": "sha512-9lpSSU4Mly3mrtruwLs1eLK6+gzbzqeBFwRNjIjE+9LuDpWdYctrQlQ3ej1Ilgi7gknpsTRnPoLP8DpCHqHIJw==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/mongodb-memory-server-core/node_modules/tr46": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-6.0.0.tgz", + "integrity": "sha512-bLVMLPtstlZ4iMQHpFHTR7GAGj2jxi8Dg0s2h2MafAE4uSWF98FC/3MomU51iQAMf8/qDUbKWf5GxuvvVcXEhw==", + "dev": true, + "license": "MIT", + "dependencies": { + "punycode": "^2.3.1" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/mongodb-memory-server-core/node_modules/webidl-conversions": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-8.0.1.tgz", + "integrity": "sha512-BMhLD/Sw+GbJC21C/UgyaZX41nPt8bUTg+jWyDeg7e7YN4xOM05YPSIXceACnXVtqyEw/LMClUQMtMZ+PGGpqQ==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=20" + } + }, + "node_modules/mongodb-memory-server-core/node_modules/whatwg-url": { + "version": "15.1.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-15.1.0.tgz", + "integrity": "sha512-2ytDk0kiEj/yu90JOAp44PVPUkO9+jVhyf+SybKlRHSDlvOOZhdPIrr7xTH64l4WixO2cP+wQIcgujkGBPPz6g==", + "dev": true, + "license": "MIT", + "dependencies": { + "tr46": "^6.0.0", + "webidl-conversions": "^8.0.0" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/mongodb-memory-server-core/node_modules/yauzl": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-3.4.0.tgz", + "integrity": "sha512-jIH9yLR9wqr0wOS0TpBvo/g/2UgZH5qePVbjgRliiF0BYvOZyaBknKsF+x9Iht0O6sqgnB93rCICdOZFecJuDw==", + "dev": true, + "license": "MIT", + "dependencies": { + "pend": "~1.2.0" + }, + "engines": { + "node": ">=12" + } + }, "node_modules/mongoose": { "version": "8.8.1", "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-8.8.1.tgz", @@ -6957,6 +7439,19 @@ "node": ">= 0.4.0" } }, + "node_modules/new-find-package-json": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/new-find-package-json/-/new-find-package-json-2.0.0.tgz", + "integrity": "sha512-lDcBsjBSMlj3LXH2v/FW3txlh2pYTjmbOXPYJD93HI5EwuLzI11tdHSIpUMmfq/IOsldj4Ps8M8flhm+pCK4Ew==", + "dev": true, + "license": "MIT", + "dependencies": { + "debug": "^4.3.4" + }, + "engines": { + "node": ">=12.22.0" + } + }, "node_modules/node-addon-api": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-5.1.0.tgz", @@ -7160,9 +7655,9 @@ } }, "node_modules/object-inspect": { - "version": "1.13.3", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.3.tgz", - "integrity": "sha512-kDCGIbxkDSXE3euJZZXzc6to7fCrKHNI/hSRQnRuQ+BWjFNzZwiFF8fj/6o2t2G9/jTj8PSIYTfCLelLZEeRpA==", + "version": "1.13.4", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz", + "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==", "license": "MIT", "engines": { "node": ">= 0.4" @@ -7502,6 +7997,75 @@ "node": ">= 6" } }, + "node_modules/pkg-dir": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", + "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "find-up": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/pkg-dir/node_modules/find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "license": "MIT", + "dependencies": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/pkg-dir/node_modules/locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-locate": "^4.1.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/pkg-dir/node_modules/p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-try": "^2.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/pkg-dir/node_modules/p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-limit": "^2.2.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/prelude-ls": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", @@ -7734,12 +8298,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/queue-tick": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/queue-tick/-/queue-tick-1.0.1.tgz", - "integrity": "sha512-kJt5qhMxoszgU/62PLP1CJytzd2NKetjSRnyuj31fDd3Rlcz3fzlFdFLD1SItunPwyqEOkca6GbV612BWfaBag==", - "license": "MIT" - }, "node_modules/range-parser": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", @@ -7957,7 +8515,6 @@ "version": "6.3.1", "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", - "dev": true, "license": "ISC", "bin": { "semver": "bin/semver.js" @@ -8032,23 +8589,6 @@ "integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==", "license": "ISC" }, - "node_modules/set-function-length": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz", - "integrity": "sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==", - "license": "MIT", - "dependencies": { - "define-data-property": "^1.1.4", - "es-errors": "^1.3.0", - "function-bind": "^1.1.2", - "get-intrinsic": "^1.2.4", - "gopd": "^1.0.1", - "has-property-descriptors": "^1.0.2" - }, - "engines": { - "node": ">= 0.4" - } - }, "node_modules/setimmediate": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz", @@ -8083,15 +8623,69 @@ } }, "node_modules/side-channel": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.6.tgz", - "integrity": "sha512-fDW/EZ6Q9RiO8eFG8Hj+7u/oW+XrPTIChwCOM2+th2A6OblDtYYIpve9m+KvI9Z4C9qSEXlaGR6bTEYHReuglA==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.1.tgz", + "integrity": "sha512-6x6dK6zJdpTzF4sQeNYxwtvBzf6Eg4GtlesS94HOvTudUeyK2WXAaIfmDgsyslYrRBeFIlsi54AYsFGUuhmvrQ==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.4", + "side-channel-list": "^1.0.1", + "side-channel-map": "^1.0.1", + "side-channel-weakmap": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-list": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.1.tgz", + "integrity": "sha512-mjn/0bi/oUURjc5Xl7IaWi/OJJJumuoJFQJfDDyO46+hBWsfaVM65TBHq2eoZBhzl9EchxOijpkbRC8SVBQU0w==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.4" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-map": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz", + "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-weakmap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz", + "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==", "license": "MIT", "dependencies": { - "call-bind": "^1.0.7", + "call-bound": "^1.0.2", "es-errors": "^1.3.0", - "get-intrinsic": "^1.2.4", - "object-inspect": "^1.13.1" + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3", + "side-channel-map": "^1.0.1" }, "engines": { "node": ">= 0.4" @@ -8156,12 +8750,12 @@ } }, "node_modules/socks": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/socks/-/socks-2.8.3.tgz", - "integrity": "sha512-l5x7VUUWbjVFbafGLxPWkYsHIhEvmF85tbIeFZWc8ZPtoMyybuEhL7Jye/ooC4/d48FgOjSJXgsF/AJPYCW8Zw==", + "version": "2.8.10", + "resolved": "https://registry.npmjs.org/socks/-/socks-2.8.10.tgz", + "integrity": "sha512-e0VyvkVTwVYViNovRkZ9aodhxVlyoMn7eJhVUPxZ+eK9P/7CBkxvvsBOHqFPEH416726W8tLXXXjKwqgTErrCQ==", "license": "MIT", "dependencies": { - "ip-address": "^9.0.5", + "ip-address": "^10.1.1", "smart-buffer": "^4.2.0" }, "engines": { @@ -8214,12 +8808,6 @@ "memory-pager": "^1.0.2" } }, - "node_modules/sprintf-js": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.3.tgz", - "integrity": "sha512-Oo+0REFV59/rz3gfJNKQiBlwfHaSESl1pcGyABQsnnIfWOFt6JNj5gCog2U6MLZ//IGYD+nA8nI+mTShREReaA==", - "license": "BSD-3-Clause" - }, "node_modules/stack-trace": { "version": "0.0.10", "resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz", @@ -8270,17 +8858,14 @@ } }, "node_modules/streamx": { - "version": "2.20.2", - "resolved": "https://registry.npmjs.org/streamx/-/streamx-2.20.2.tgz", - "integrity": "sha512-aDGDLU+j9tJcUdPGOaHmVF1u/hhI+CsGkT02V3OKlHDV7IukOI+nTWAGkiZEKCO35rWN1wIr4tS7YFr1f4qSvA==", + "version": "2.28.1", + "resolved": "https://registry.npmjs.org/streamx/-/streamx-2.28.1.tgz", + "integrity": "sha512-zEzXb0s5Cds7tqMH6rhZ05lcJydCWiQPEwiNngVqzsxCc962vLY4Uw+mW7od8kDH258k2Uz/JrOkdIAAhSh9VA==", "license": "MIT", "dependencies": { + "events-universal": "^1.0.0", "fast-fifo": "^1.3.2", - "queue-tick": "^1.0.1", "text-decoder": "^1.1.0" - }, - "optionalDependencies": { - "bare-events": "^2.2.0" } }, "node_modules/string_decoder": { @@ -8365,6 +8950,82 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/superagent": { + "version": "10.4.2", + "resolved": "https://registry.npmjs.org/superagent/-/superagent-10.4.2.tgz", + "integrity": "sha512-u+PFV+VKiAKKzJqnCvveNya3N+pR/8jUZs/ek6jRfE41fpSCNdFY61L7NYmSgB6I9TTFM50ywoPXRKgw2k3wKw==", + "dev": true, + "license": "MIT", + "dependencies": { + "component-emitter": "^1.3.1", + "cookiejar": "^2.1.4", + "debug": "^4.3.7", + "fast-safe-stringify": "^2.1.1", + "form-data": "^4.0.6", + "formidable": "^3.5.4", + "methods": "^1.1.2", + "mime": "2.6.0", + "qs": "^6.17.1" + }, + "engines": { + "node": ">=14.18.0" + } + }, + "node_modules/superagent/node_modules/mime": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-2.6.0.tgz", + "integrity": "sha512-USPkMeET31rOMiarsBNIHZKLGgvKc/LrjofAnBlOttf5ajRvqiRA8QsenbcooctK6d6Ts6aqZXBA+XbkKthiQg==", + "dev": true, + "license": "MIT", + "bin": { + "mime": "cli.js" + }, + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/superagent/node_modules/qs": { + "version": "6.17.1", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.17.1.tgz", + "integrity": "sha512-jd3COkaKVgGUW+ZHyEHCG9bH7RoaaiWuMgzsIBjUMVjLAaWGWpoUAVwljVvBHxRu/2qEHnadLGZrkutYUBPQJA==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "es-define-property": "^1.0.1", + "side-channel": "^1.1.1" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/supertest": { + "version": "7.3.2", + "resolved": "https://registry.npmjs.org/supertest/-/supertest-7.3.2.tgz", + "integrity": "sha512-hR0dKRUE+PwZhHLdq/GRhf97HbUQte+AhbpWBQ9nh02tpjujVJj0GY4aygd1dAKdNZ7UZexWHpeItyJi/jLsgw==", + "dev": true, + "license": "MIT", + "dependencies": { + "cookie-signature": "^1.2.2", + "methods": "^1.1.2", + "superagent": "^10.4.1" + }, + "engines": { + "node": ">=14.18.0" + } + }, + "node_modules/supertest/node_modules/cookie-signature": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.2.2.tgz", + "integrity": "sha512-D76uU73ulSXrD1UXF4KE2TMxVVwhsnCgfAyTg9k8P6KGZjlXKrOLe4dJQKI3Bxi5wjesZoFXJWElNWBjPZMbhg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.6.0" + } + }, "node_modules/supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", @@ -8569,22 +9230,62 @@ } }, "node_modules/tar-stream": { - "version": "3.1.7", - "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-3.1.7.tgz", - "integrity": "sha512-qJj60CXt7IU1Ffyc3NJMjh6EkuCFej46zUqJ4J7pqYlThyd9bO0XBTmcOIhSzZJVWfsLks0+nle/j538YAW9RQ==", + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-3.2.2.tgz", + "integrity": "sha512-+8NeqHRjQWH9nYlwo2gamAMImZCVzI4UoEgDpWorBt9OEfppiZn+uSkskzQKPWIZyji/C8fpWO7u69G0DX0tbg==", "license": "MIT", "dependencies": { - "b4a": "^1.6.4", - "fast-fifo": "^1.2.0", - "streamx": "^2.15.0" + "b4a": "^1.9.0", + "bare-fs": "^4.8.2", + "fast-fifo": "^1.3.2", + "streamx": "^2.28.1" + } + }, + "node_modules/tar-stream/node_modules/bare-fs": { + "version": "4.8.4", + "resolved": "https://registry.npmjs.org/bare-fs/-/bare-fs-4.8.4.tgz", + "integrity": "sha512-MPC2eyrpbk3A873sK4y6rk+Iv4o2enxTjHZ8zH3HO0mjrpm5XjnguY2XmfidIsDV6vnjpbMBKUAJpV0ISD2SsQ==", + "license": "Apache-2.0", + "dependencies": { + "bare-events": "^2.5.4", + "bare-path": "^3.0.0", + "bare-stream": "^2.6.4", + "bare-url": "^2.2.2", + "fast-fifo": "^1.3.2" + }, + "engines": { + "bare": ">=1.28.0" + }, + "peerDependencies": { + "bare-buffer": "*" + }, + "peerDependenciesMeta": { + "bare-buffer": { + "optional": true + } } }, + "node_modules/tar-stream/node_modules/bare-path": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/bare-path/-/bare-path-3.1.3.tgz", + "integrity": "sha512-8r+FVU/o4zcFmpCDqbqAYhHHbtXPP+cyZKo7DRGRWc7OLlNs4TMaSQEpXL/sIdzyEG0M7RHw4B7xYMGrTc+qrg==", + "license": "Apache-2.0" + }, "node_modules/tar/node_modules/yallist": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", "license": "ISC" }, + "node_modules/teex": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/teex/-/teex-1.0.1.tgz", + "integrity": "sha512-eYE6iEI62Ni1H8oIa7KlDU6uQBtqr4Eajni3wX7rpfXD8ysFx8z0+dri+KWEPWpBsxXfxu58x/0jvTVT1ekOSg==", + "license": "MIT", + "dependencies": { + "streamx": "^2.12.5" + } + }, "node_modules/test-exclude": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz", diff --git a/package.json b/package.json index 28ff8bd3..809f6cfb 100644 --- a/package.json +++ b/package.json @@ -67,11 +67,14 @@ "@types/multer": "^2.2.0", "@types/node": "^20.14.12", "@types/pdf-parse": "^1.1.5", + "@types/supertest": "^7.2.1", "@types/swagger-jsdoc": "^6.0.4", "@types/swagger-ui-express": "^4.1.8", "eslint": "^9.39.5", "jest": "^29.7.0", + "mongodb-memory-server": "^11.3.0", "nodemon": "^3.1.0", + "supertest": "^7.3.2", "ts-jest": "^29.2.5", "ts-node": "^10.9.2", "tsconfig-paths": "^4.2.0", diff --git a/src/__tests__/integration/auth.http.test.ts b/src/__tests__/integration/auth.http.test.ts new file mode 100644 index 00000000..8603c92b --- /dev/null +++ b/src/__tests__/integration/auth.http.test.ts @@ -0,0 +1,124 @@ +import mongoose from 'mongoose'; +import request from 'supertest'; +import { MongoMemoryServer } from 'mongodb-memory-server'; +import type { Express } from 'express'; + +import { createApp } from '@/server'; +import { isRedisAvailable } from '@/services/redis'; +import { Candidate } from '@/models'; +import Profile from '@/models/profile.model'; +import { memStore } from '@/middlewares/rateLimit.middleware'; + +jest.mock('@/logger'); + +const PASSWORD = 'Str0ng!Passw0rd'; + +let mongo: MongoMemoryServer; +let app: Express; + +const register = (email: string) => request(app).post('/api/v1/auth/register').send({ email, password: PASSWORD, repassword: PASSWORD }); + +const login = async (email: string) => { + const res = await request(app).post('/api/v1/auth/login').send({ email, password: PASSWORD }); + expect(res.status).toBe(200); + return { token: res.body.data.token as string, tokenRefresh: res.body.data.tokenRefresh as string, cookies: res.headers['set-cookie'] as unknown as string[] }; +}; + +const getProfiles = (token: string) => request(app).get('/api/v1/profile').set('Authorization', `Bearer ${token}`); + +beforeAll(async () => { + mongo = await MongoMemoryServer.create(); + await mongoose.connect(mongo.getUri()); + app = createApp(); + + // One user per flow: access tokens carry no jti, so a same-second login would mint a token another flow already blacklisted. + const results = await Promise.all(['alice@example.com', 'bob@example.com', 'carol@example.com', 'dave@example.com'].map(register)); + expect(results.map((r) => r.status)).toEqual([201, 201, 201, 201]); +}, 120_000); + +afterAll(async () => { + await mongoose.disconnect(); + await mongo.stop(); +}); + +// Every request comes from 127.0.0.1, so without this the flows share one 10-request authLimiter bucket. +beforeEach(() => memStore.clear()); + +afterEach(() => jest.restoreAllMocks()); + +it('runs with Redis absent (in-memory blacklist/revocation fallback)', () => { + expect(isRedisAvailable()).toBe(false); +}); + +it('register → login → authenticated GET → refresh → logout, then the logged-out token is rejected', async () => { + const first = await login('alice@example.com'); + expect((await getProfiles(first.token)).status).toBe(200); + + const refreshed = await request(app).post('/api/v1/auth/refresh').send({ refreshToken: first.tokenRefresh }); + expect(refreshed.status).toBe(200); + const { token, tokenRefresh } = refreshed.body.data as { token: string; tokenRefresh: string }; + expect((await getProfiles(token)).status).toBe(200); + + const logout = await request(app).post('/api/v1/auth/logout').set('Authorization', `Bearer ${token}`).send({ refreshToken: tokenRefresh }); + expect(logout.status).toBe(200); + + const after = await getProfiles(token); + expect(after.status).toBe(401); + expect(after.body.error.code).toBe('TOKEN_REVOKED'); + + const refreshAfter = await request(app).post('/api/v1/auth/refresh').send({ refreshToken: tokenRefresh }); + expect(refreshAfter.status).toBe(401); + expect(refreshAfter.body.error.code).toBe('TOKEN_REVOKED'); +}); + +it('reusing a rotated refresh token after the 10s grace window revokes every session', async () => { + const session = await login('bob@example.com'); + const rotated = await request(app).post('/api/v1/auth/refresh').send({ refreshToken: session.tokenRefresh }); + expect(rotated.status).toBe(200); + const { token: newToken, tokenRefresh: newRefresh } = rotated.body.data as { token: string; tokenRefresh: string }; + + const realNow = Date.now.bind(Date); + jest.spyOn(Date, 'now').mockImplementation(() => realNow() + 11_000); + + const reuse = await request(app).post('/api/v1/auth/refresh').send({ refreshToken: session.tokenRefresh }); + expect(reuse.status).toBe(401); + expect(reuse.body.error.code).toBe('TOKEN_REVOKED'); + + // Both the original and the freshly rotated access token predate the revocation. + expect((await getProfiles(session.token)).status).toBe(401); + expect((await getProfiles(newToken)).status).toBe(401); + + const refreshWithRotated = await request(app).post('/api/v1/auth/refresh').send({ refreshToken: newRefresh }); + expect(refreshWithRotated.status).toBe(401); + expect(refreshWithRotated.body.error.code).toBe('TOKEN_REVOKED'); +}); + +it('rejects a cookie-only state-changing request without the CSRF header', async () => { + const { cookies } = await login('carol@example.com'); + + const res = await request(app).post('/api/v1/profile/create').set('Cookie', cookies).send({ _id: null, name: 'No CSRF' }); + expect(res.status).toBe(403); + expect(res.body.error.code).toBe('CSRF_TOKEN_INVALID'); + expect(await Profile.countDocuments({ name: 'No CSRF' })).toBe(0); +}); + +it('ignores a client-supplied candidateId (IDOR)', async () => { + const { token } = await login('dave@example.com'); + const dave = await Candidate.findOne({ email: 'dave@example.com' }); + const bob = await Candidate.findOne({ email: 'bob@example.com' }); + + const res = await request(app) + .post('/api/v1/profile/create') + .set('Authorization', `Bearer ${token}`) + .send({ _id: null, name: 'Spoofed owner', candidateId: String(bob?._id) }); + expect(res.status).toBe(201); + + const created = await Profile.findOne({ name: 'Spoofed owner' }); + expect(String(created?.candidateId)).toBe(String(dave?._id)); +}); + +it('answers an unknown route with 404 in the standard error shape', async () => { + const res = await request(app).get('/api/v1/does-not-exist'); + expect(res.status).toBe(404); + expect(res.body).toEqual({ success: false, error: expect.objectContaining({ code: 'ROUTE_NOT_FOUND', message: expect.any(String) }) }); +}); diff --git a/src/server.ts b/src/server.ts index bd237536..58230922 100644 --- a/src/server.ts +++ b/src/server.ts @@ -25,12 +25,8 @@ import { moveLegacyCvUploads } from '@/middlewares/uploadCV.middleware'; dotenv.config(); -// Last safety net: Node ≥15 exits on an unhandled rejection; asyncHandler should make this unreachable. -process.on('unhandledRejection', (reason) => { - logger.error('Unhandled promise rejection', { error: reason instanceof Error ? reason.message : String(reason), stack: reason instanceof Error ? reason.stack : undefined }); -}); - -const runServer = async ({ portNumber }: { portNumber: number }) => { +/** The full middleware chain without listen/Redis/cleanup side effects, so the HTTP integration tests can drive it through supertest. */ +export const createApp = () => { const app = express(); // req.ip (rate-limit key) must be the real client, not Render's proxy. @@ -97,6 +93,12 @@ const runServer = async ({ portNumber }: { portNumber: number }) => { app.use(notFoundHandler); app.use(errorsMiddleware); + return app; +}; + +const runServer = async ({ portNumber }: { portNumber: number }) => { + const app = createApp(); + const _env = process.env['NODE_ENV'] || 'development'; /** * Respect LOCAL_PORT whenever it's actually set, in every environment — @@ -147,4 +149,11 @@ const startServer = async () => { } }; -startServer(); +// Importing this module (tests) must not connect to Mongo, bind a port or install process-wide handlers. +if (require.main === module) { + // Last safety net: Node ≥15 exits on an unhandled rejection; asyncHandler should make this unreachable. + process.on('unhandledRejection', (reason) => { + logger.error('Unhandled promise rejection', { error: reason instanceof Error ? reason.message : String(reason), stack: reason instanceof Error ? reason.stack : undefined }); + }); + void startServer(); +} From df91bcc65c6dbbb3eb302410aa4fc19008fcc1e1 Mon Sep 17 00:00:00 2001 From: _david Date: Wed, 18 Nov 2026 16:51:00 +0700 Subject: [PATCH 3/7] fix(auth): give every JWT a unique jti so same-second sessions don't collide Access tokens were signed with { _id } only, so two issued for one candidate in the same second were byte-identical and logging out one session blacklisted the other. - src/utils/jwt.ts: jwtSign sets jwtid: crypto.randomUUID() on every token (access and refresh) - src/auth/auth.service.ts, src/auth/auth.controller.ts: drop the hand-built refresh jti (jsonwebtoken rejects payload jti + jwtid) and the now-unused crypto import - tests: new src/__tests__/utils/jwt.test.ts; integration test for two same-second logins where logout of one leaves the other at 200; caller unit tests and refreshTokenReuse helper adjusted - .claude/rules/api.md: auth flow payload now { _id, jti } - agent-hub: ship note for auth-http-integration-tests npm test: Test Suites: 75 passed, 75 total / Tests: 792 passed, 792 total npm run build: exit 0 (tsc exit 0); lint 273 problems (<= 274 baseline), none new in changed files Node: fix-access-token-jti (SEALED) Evidence: agent-hub/evidence/verifier/2026-11-18/fix-access-token-jti-seal.md Closes #490 Co-Authored-By: Claude Sonnet 5 --- .claude/rules/api.md | 4 +- .../2026-11-18/fix-access-token-jti-diff.md | 110 ++++++++++++++++++ .../2026-11-18/fix-access-token-jti-plan.md | 19 +++ .../auth-http-integration-tests-ship.md | 64 ++++++++++ .../2026-11-18/fix-access-token-jti-seal.md | 36 ++++++ agent-hub/evidence/worker-runs.log | 1 + agent-hub/haven/diagrams/dev-loop-archive.md | 1 + .../haven/diagrams/dev-loop.prime-mermaid.md | 2 +- src/__tests__/auth/auth.service.test.ts | 3 +- src/__tests__/auth/refreshToken.test.ts | 2 +- src/__tests__/auth/refreshTokenReuse.test.ts | 2 +- src/__tests__/integration/auth.http.test.ts | 21 +++- src/__tests__/utils/jwt.test.ts | 19 +++ src/auth/auth.controller.ts | 4 +- src/auth/auth.service.ts | 4 +- src/utils/jwt.ts | 4 +- 16 files changed, 279 insertions(+), 17 deletions(-) create mode 100644 agent-hub/evidence/implementer/2026-11-18/fix-access-token-jti-diff.md create mode 100644 agent-hub/evidence/implementer/2026-11-18/fix-access-token-jti-plan.md create mode 100644 agent-hub/evidence/ship/2026-11-18/auth-http-integration-tests-ship.md create mode 100644 agent-hub/evidence/verifier/2026-11-18/fix-access-token-jti-seal.md create mode 100644 src/__tests__/utils/jwt.test.ts diff --git a/.claude/rules/api.md b/.claude/rules/api.md index 662ede59..34e54ba8 100644 --- a/.claude/rules/api.md +++ b/.claude/rules/api.md @@ -86,8 +86,8 @@ best-effort — each item validated/created independently via the same ## Auth flow 1. `POST /auth/register` → validate Joi → check duplicate email → bcrypt(password, 12) → create Candidate doc -2. `POST /auth/login` → find by email → bcryptCompare → sign `accessToken` (TOKEN_SECRET) + `refreshToken` (TOKEN_REFRESH) with payload `{ _id: candidateId }` → set as httpOnly cookies (`utils/authCookies.ts`) and returned in the response body +2. `POST /auth/login` → find by email → bcryptCompare → sign `accessToken` (TOKEN_SECRET) + `refreshToken` (TOKEN_REFRESH) with payload `{ _id: candidateId, jti }` (random `jti` per token, so two signed in the same second never collide) → set as httpOnly cookies (`utils/authCookies.ts`) and returned in the response body 3. All protected requests → `verifyToken` middleware → extract token (Bearer header, cookie, body, or query via `extractTokenWithSource`) → `jwtVerify` → check blacklist → check per-candidate session-revocation timestamp (`sessionRevocation.ts`) → if the request authenticated purely off the cookie, require a valid double-submit CSRF token → attach `req.user._id` and force `req.body.candidateId` to it -4. `POST /auth/refresh` → CSRF-checked → if the token was already rotated away: 403, and if that rotation was more than 10s ago (not a concurrent refresh) treat it as theft → `invalidateAllSessions` (once — a token already predating the last revocation doesn't re-trigger it) → otherwise verify refresh token → blacklist old refresh token with a rotated-at marker → issue new pair (refresh tokens carry a random `jti` so two issued in the same second never collide) +4. `POST /auth/refresh` → CSRF-checked → if the token was already rotated away: 403, and if that rotation was more than 10s ago (not a concurrent refresh) treat it as theft → `invalidateAllSessions` (once — a token already predating the last revocation doesn't re-trigger it) → otherwise verify refresh token → blacklist old refresh token with a rotated-at marker → issue new pair (both carry a fresh random `jti`) 5. `POST /auth/logout` → CSRF-checked → add token to blacklist (Redis TTL = token remaining exp; mem fallback) 6. `POST /auth/logout-all` → bump the candidate's session-invalidated-at timestamp so every token issued before now is rejected on next use, even if not individually blacklisted or expired diff --git a/agent-hub/evidence/implementer/2026-11-18/fix-access-token-jti-diff.md b/agent-hub/evidence/implementer/2026-11-18/fix-access-token-jti-diff.md new file mode 100644 index 00000000..fe183b0b --- /dev/null +++ b/agent-hub/evidence/implementer/2026-11-18/fix-access-token-jti-diff.md @@ -0,0 +1,110 @@ +# 2026-11-18 - fix-access-token-jti (diff) +Worker: implementer · Version: 0.1.0 · Node: `haven/diagrams/dev-loop.prime-mermaid.md` → `fix-access-token-jti` · Task: `/todo "add jti to access tokens"` → issue #490 (label `bug`) · Branch: `fix/490-access-token-jti` (cut from `staging` @ de5fd4f) +Plan: `evidence/implementer/2026-11-18/fix-access-token-jti-plan.md` + +## Hub bytes before: 98675 + +## Feature doc: doctrine/features/auth-session-tokens.md (Behavior #7, #2), doctrine/features/auth-register-login.md (Behavior #6) +Fix restores session Behavior #7 (logout blacklists *the token sent*, not another same-second session's token). register-login #6 ("each refresh token carries a unique `jti`") still holds — now every token does; additive, no contradiction → doc not edited. + +## Acceptance criteria clarified +(2) before: "unit tests assert the access payload carries a `jti` at both sign sites (`auth.service.test.ts`, `refreshToken.test.ts`)" → after: "`jwtSign` unit test: same payload, same second → different tokens with distinct `jti` (`npx jest src/__tests__/utils/jwt.test.ts`), and the auth unit tests still pass (`npx jest src/__tests__/auth`)". Reason: `/code-review` finding #1 — the fix belongs once in the shared signer, so callers no longer build a `jti` and the per-site assertion no longer exists. Node row updated in place. + +## Diff +| File | Why | +|---|---| +| `src/utils/jwt.ts` | `jwt.sign(data, secretKey, { expiresIn, jwtid: crypto.randomUUID() })` — every token gets a fresh `jti` claim; WHY comment moved here. | +| `src/auth/auth.service.ts` | `handlerLogin`: refresh payload back to `{ _id }` (jsonwebtoken throws if payload `jti` and `jwtid` are both set); old refresh-only comment + now-unused `crypto` import removed. | +| `src/auth/auth.controller.ts` | `authRefreshToken`: same as above for the rotated pair. | +| `src/__tests__/utils/jwt.test.ts` (new) | Same payload signed twice with `Date.now` pinned → tokens differ, same `iat`, distinct string `jti`, `_id` kept. | +| `src/__tests__/integration/auth.http.test.ts` | New: two `erin` logins with `Date.now` pinned only for the logins → tokens differ; logout phone → phone 401, laptop 200. 5th user registered; setup comment no longer claims tokens lack `jti`. | +| `src/__tests__/auth/auth.service.test.ts`, `refreshToken.test.ts` | Caller-side expectations now `data: { _id }` (jti asserted in `jwt.test.ts` instead). | +| `src/__tests__/auth/refreshTokenReuse.test.ts` | Helper stops passing its own `jti` to the real `jwtSign` (would now throw "payload already has a jti"). | +| `.claude/rules/api.md` | Auth flow steps 2 and 4: payload `{ _id: candidateId, jti }`, both tokens carry a fresh `jti`. | + +## Command +From `/Users/_david/Workspace/Project/resume/resume-nodejs-api` (copied from `doctrine/MEMORY.md`): +- `npx jest src/__tests__/integration/auth.http.test.ts src/__tests__/utils/jwt.test.ts src/__tests__/auth` +- `npm test` +- `npm run build` (Typecheck = `inside Build`); also `npx tsc --noEmit` +- `npm run lint`; per touched file `npx eslint ` vs `git show staging: | npx eslint --stdin --stdin-filename ` +- Red-before check: `git stash push -- src/utils/jwt.ts` → `npx jest src/__tests__/integration/auth.http.test.ts src/__tests__/utils/jwt.test.ts` → `git stash pop` + +## Output +Red-before (fix stashed, old `jwtSign`): +``` + ✕ gives every token its own jti, so the same payload signed in the same second never repeats (7 ms) + ✕ logging out one session leaves another session signed in the same second working (459 ms) +Tests: 2 failed, 6 passed, 8 total +``` +(earlier, pre-review shape, same red: `Expected: not "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2YWZkNzMxYzk1YmQ2NTc1NmEyMjcyYzEiLCJpYXQiOjE3OTQ5OTQ5NzIsImV4cCI6MTc5NTU5OTc3Mn0.hc4v…"` — identical tokens, payload `{_id, iat, exp}` only) + +Targeted (fix applied): +``` +PASS src/__tests__/utils/jwt.test.ts +PASS src/__tests__/auth/v2AuthRoute.test.ts (5.136 s) +PASS src/__tests__/auth/auth.validate.test.ts +PASS src/__tests__/auth/tokenExpiry.test.ts +PASS src/__tests__/auth/auth.service.test.ts +PASS src/__tests__/auth/v1AuthRoute.test.ts (6.694 s) +PASS src/__tests__/auth/refreshToken.test.ts (6.869 s) +PASS src/__tests__/auth/refreshTokenReuse.test.ts (6.852 s) +PASS src/__tests__/auth/auth.controller.test.ts (6.983 s) +PASS src/__tests__/integration/auth.http.test.ts (11.081 s) +Test Suites: 10 passed, 10 total +Tests: 77 passed, 77 total +``` +`npm test`: +``` +Test Suites: 75 passed, 75 total +Tests: 792 passed, 792 total +``` +Build / typecheck: +``` +build exit 0 +tsc exit 0 +``` +Lint: +``` +✖ 273 problems (273 errors, 0 warnings) +src/utils/jwt.ts before=0 after=0 +src/auth/auth.service.ts before=0 after=0 +src/auth/auth.controller.ts before=19 after=19 +src/__tests__/auth/auth.service.test.ts before=10 after=10 +src/__tests__/auth/refreshToken.test.ts before=1 after=1 +src/__tests__/auth/refreshTokenReuse.test.ts before=0 after=0 +src/__tests__/integration/auth.http.test.ts before=0 after=0 +src/__tests__/utils/jwt.test.ts new=0 +``` +(the error line ranges in the two touched files with errors are pre-existing — counts identical to `staging`; none on changed lines) + +## Acceptance +| Criterion | Evidence | +|---|---| +| (1) same-second logins → distinct tokens; logout one → other still 200 | `PASS src/__tests__/integration/auth.http.test.ts`; red-before `✕ logging out one session leaves another session signed in the same second working` | +| (2) `jwtSign` same payload/same second → distinct `jti`; auth unit tests pass | `PASS src/__tests__/utils/jwt.test.ts` (red-before `✕ gives every token its own jti…`); 9 `src/__tests__/auth` suites PASS, `Tests: 77 passed, 77 total` | +| (3) `npm test` + build green | `Tests: 792 passed, 792 total`; `build exit 0`, `tsc exit 0` | +| (3) lint ≤ 274, none new in changed files | `✖ 273 problems`; per-file before = after for every touched file, new test 0 | +| Feature doc session #7 restored | criterion (1) — logout revokes only the sent token | +| comments per code-comments.md | Added `//` WHY on `jwt.sign` (`src/utils/jwt.ts`); removed two caller comments that would be stale; test `//` comments explain the clock pin and one-user-per-flow; no `(#N)` refs. | + +## Supersedes: none +`grep "#490"` on the active diagram → only this node. (`fix-refresh-token-expiry-unused` PENDING row is a different issue — `TOKEN_EXP_IN` usage — untouched.) + +## Still open: none + +## Review +`/code-review medium` (background fork), first pass on the per-call-site version — 0 correctness bugs, 4 findings: +1. `jti` added by hand at 4 call sites instead of once in `jwtSign` → **fixed** (moved into `jwtSign` via `jwtid`; callers, comments and tests adjusted; criterion 2 clarified above). Re-ran step 5 afterwards — Output above is the post-fix run. +2. `isSessionRevoked` uses `iat < invalidatedAt` (whole seconds) → a token minted in the same second as logout-all / theft revocation survives it → real, pre-existing, separate → `## Noticed, not done` #1. +3. Blacklist keyed on full JWT instead of `jti` → efficiency, out of scope → `## Noticed, not done` #2. +4. New integration test froze `Date.now` for the whole flow → **fixed** (`clock.mockRestore()` right after the two logins). +Not `security`-labeled → no `/security-review`. Second review pass not run on the moved version (diff is the same logic, one site; covered by the red-before/green-after tests). + +## Noticed, not done +1. **Same-second revocation gap** — `src/utils/sessionRevocation.ts` `isSessionRevoked`: `iat < invalidatedAt` at second precision, so a token issued in the same second as logout-all (or a theft-triggered `invalidateAllSessions`) stays valid. Candidate fix: `iat <= invalidatedAt` (then decide how a login in that same second after logout-all is treated). Own issue/node suggested. +2. Blacklist key is the whole JWT (`blacklist:{token}`, Redis and in-memory Map); with a `jti` on every token it could key on `jti` (36 chars). Efficiency only. +3. Tokens issued before deploy have no `jti`; they still verify (nothing reads `jti`) and age out by `exp` — no migration needed. + +## Seal gate +No outward-facing action (no commit/push). `gh issue create` (#490), `gh issue edit --add-label bug`, `gh issue develop` (branch) ran as `/todo` Step 0. diff --git a/agent-hub/evidence/implementer/2026-11-18/fix-access-token-jti-plan.md b/agent-hub/evidence/implementer/2026-11-18/fix-access-token-jti-plan.md new file mode 100644 index 00000000..7e1ad6ba --- /dev/null +++ b/agent-hub/evidence/implementer/2026-11-18/fix-access-token-jti-plan.md @@ -0,0 +1,19 @@ +# 2026-11-18 - fix-access-token-jti (plan) +Worker: implementer · Version: 0.1.0 · Node: `haven/diagrams/dev-loop.prime-mermaid.md` → `fix-access-token-jti` · Task: `/todo "add jti to access tokens"` → issue #490 "add jti to access tokens" (body = same line), label `bug` + +## Hub bytes before: 98675 + +## Feature doc: doctrine/features/auth-session-tokens.md (Behavior #7, #2), doctrine/features/auth-register-login.md (Behavior #6) +Task type: operator chose `fix` (2026-11-18, AskUserQuestion) → pass 0 analyst skipped (INDEX row exists for auth session tokens). Spec: session Behavior #7 — logout blacklists *the access token sent with the request*; today it also revokes any other session whose access token was minted in the same second for the same candidate (byte-identical JWT), which the doc does not allow. register-login #6 says refresh tokens carry a unique `jti`; extending that to access tokens adds, doesn't contradict → no doc edit. + +## Acceptance (node criteria) +1. Two logins of one candidate in the same second → different access tokens; logout with one → protected GET with the other still 200 (`npx jest src/__tests__/integration/auth.http.test.ts`). +2. Unit tests assert the access payload carries a `jti` at both sign sites (`npx jest src/__tests__/auth/auth.service.test.ts src/__tests__/auth/refreshToken.test.ts`). +3. `npm test` + `npm run build` green; `npm run lint` ≤ 274, none new in changed files. + +## Anchors +- `src/auth/auth.service.ts:103` (`handlerLogin` access sign), `:104` comment covering refresh `jti`. +- `src/auth/auth.controller.ts:167` (`authRefreshToken` access sign), `:168` comment. +- `src/__tests__/auth/auth.service.test.ts:139` (exact `data: { _id }` expectation), `src/__tests__/auth/refreshToken.test.ts:84`. +- `src/__tests__/integration/auth.http.test.ts:34` comment "access tokens carry no jti" becomes false. +- Consumers of the access payload: `verifyToken` reads `_id`/`iat` only (`grep jti src` → only the sign sites). diff --git a/agent-hub/evidence/ship/2026-11-18/auth-http-integration-tests-ship.md b/agent-hub/evidence/ship/2026-11-18/auth-http-integration-tests-ship.md new file mode 100644 index 00000000..94df317f --- /dev/null +++ b/agent-hub/evidence/ship/2026-11-18/auth-http-integration-tests-ship.md @@ -0,0 +1,64 @@ +# Ship — auth-http-integration-tests +- Node: `auth-http-integration-tests` (SEALED, `agent-hub/evidence/verifier/2026-11-18/auth-http-integration-tests-seal.md`) · Branch: `chore/463-auth-integration-tests` · Remote: `https://github.com/datvt243/resume-nodejs-api.git` + +## Commands +- `git commit -m "test(auth): add HTTP-level integration tests for the auth flow + +- src/server.ts: extract the middleware chain into exported createApp(); startServer() and the unhandledRejection handler run only when the file is the entry point (require.main === module) +- src/__tests__/integration/auth.http.test.ts: supertest + mongodb-memory-server over the real chain (register/login/GET/refresh/logout with token rejected after; rotated refresh reuse after 10s grace revokes all sessions; cookie-only POST without CSRF -> 403; client candidateId ignored; unknown route -> 404 standard shape; Redis absent -> in-memory fallback) +- package.json/package-lock.json: dev deps supertest, @types/supertest, mongodb-memory-server +- CLAUDE.md: middleware order now lives in createApp + +npm test: Test Suites: 74 passed, 74 total / Tests: 790 passed, 790 total +npm run build: exit 0 (tsc exit 0); lint 273 problems (<= 274 baseline), none new in changed files + +Node: auth-http-integration-tests (SEALED) +Evidence: agent-hub/evidence/verifier/2026-11-18/auth-http-integration-tests-seal.md + +Closes #463 + +Co-Authored-By: Claude Sonnet 5 "` +- `git push -u origin chore/463-auth-integration-tests` +- `gh pr create --base staging --head chore/463-auth-integration-tests (reuse an open one)` +- `gh pr checks --watch --required` +- `gh pr merge --merge` +- `git checkout staging` +- `git pull --ff-only origin staging` + +## Output +Commit: `f942b99` +``` +$ git commit -m test(auth): add HTTP-level integration tests for the auth flow + +- src/server.ts: extract the middleware chain into exported createApp(); startServer() and the unhandledRejection handler run only when the file is the entry point (require.main === module) +- src/__tests__/integration/auth.http.test.ts: supertest + mongodb-memory-server over the real chain (register/login/GET/refresh/logout with token rejected after; rotated refresh reuse after 10s grace revokes all sessions; cookie-only POST without CSRF -> 403; client candidateId ignored; unknown route -> 404 standard shape; Redis absent -> in-memory fallback) +- package.json/package-lock.json: dev deps supertest, @types/supertest, mongodb-memory-server +- CLAUDE.md: middleware order now lives in createApp + +npm test: Test Suites: 74 passed, 74 total / Tests: 790 passed, 790 total +npm run build: exit 0 (tsc exit 0); lint 273 problems (<= 274 baseline), none new in changed files + +Node: auth-http-integration-tests (SEALED) +Evidence: agent-hub/evidence/verifier/2026-11-18/auth-http-integration-tests-seal.md + +Closes #463 + +Co-Authored-By: Claude Sonnet 5 +[chore/463-auth-integration-tests f942b99] test(auth): add HTTP-level integration tests for the auth flow + 11 files changed, 1293 insertions(+), 247 deletions(-) + create mode 100644 agent-hub/evidence/implementer/2026-11-18/auth-http-integration-tests-diff.md + create mode 100644 agent-hub/evidence/implementer/2026-11-18/auth-http-integration-tests-plan.md + create mode 100644 agent-hub/evidence/verifier/2026-11-18/auth-http-integration-tests-seal.md + create mode 100644 src/__tests__/integration/auth.http.test.ts +$ git push -u origin chore/463-auth-integration-tests +To https://github.com/datvt243/resume-nodejs-api.git + 33fcfb1..f942b99 chore/463-auth-integration-tests -> chore/463-auth-integration-tests +branch 'chore/463-auth-integration-tests' set up to track 'origin/chore/463-auth-integration-tests'. +PR: https://github.com/datvt243/resume-nodejs-api/pull/489 +build (20.x) pass 2m4s https://github.com/datvt243/resume-nodejs-api/actions/runs/44277592330/job/134709638410 +build (22.x) pass 1m59s https://github.com/datvt243/resume-nodejs-api/actions/runs/44277592330/job/134709639854 +$ gh pr merge 489 --merge +``` + +## Seal gate +Approved by the operator invoking /ship (AutoCommitNoGate), covering the whole chain above. diff --git a/agent-hub/evidence/verifier/2026-11-18/fix-access-token-jti-seal.md b/agent-hub/evidence/verifier/2026-11-18/fix-access-token-jti-seal.md new file mode 100644 index 00000000..45148972 --- /dev/null +++ b/agent-hub/evidence/verifier/2026-11-18/fix-access-token-jti-seal.md @@ -0,0 +1,36 @@ +# 2026-11-18 - fix-access-token-jti (seal) +Worker: verifier · Version: 0.1.0 · Node: `haven/diagrams/dev-loop.prime-mermaid.md` → `fix-access-token-jti` (#490, branch `fix/490-access-token-jti`) · New PM status: SEALED + +Notes graded: `evidence/implementer/2026-11-18/fix-access-token-jti-plan.md`, `evidence/implementer/2026-11-18/fix-access-token-jti-diff.md` + +## Isolation proof +Agent-tool spawn, description "verify_seal fix-access-token-jti", dispatched by `/todo "add jti to access tokens"` (issue #490) pass 2 on 2026-11-18 — fresh subagent context, no access to the implementer pass; diff not opened, only the notes. + +## Reasoning +| Criterion (node row, as clarified) | Evidence cited in note | Result | +|---|---|---| +| (1) two same-second logins → distinct access tokens; logout one → other still 200 | `PASS src/__tests__/integration/auth.http.test.ts (11.081 s)`; red-before with old `jwtSign`: `✕ logging out one session leaves another session signed in the same second working (459 ms)` | met | +| (2) `jwtSign` same payload/same second → distinct `jti` | `PASS src/__tests__/utils/jwt.test.ts`; red-before `✕ gives every token its own jti, so the same payload signed in the same second never repeats (7 ms)`, `Tests: 2 failed, 6 passed, 8 total` | met | +| (2) auth unit tests still pass | 9 `src/__tests__/auth/*` suites PASS; `Test Suites: 10 passed, 10 total` / `Tests: 77 passed, 77 total` | met | +| (3) `npm test` green | `Test Suites: 75 passed, 75 total` / `Tests: 792 passed, 792 total` | met | +| (3) build green + Typecheck (`inside Build`, MEMORY.md) | `build exit 0`, `tsc exit 0` (same exit-code form accepted on prior seals) | met | +| (3) lint ≤ 274 baseline, none new in changed files | `✖ 273 problems (273 errors, 0 warnings)`; per-file before=after for all 7 touched files, new test `new=0` | met | +| comments per code-comments.md | row present: one WHY `//` on `jwt.sign`, two stale caller comments removed, no `(#N)` refs | met | +| Feature doc `auth-session-tokens.md` Behavior #7 (logout blacklists only the sent token) / #2 (blacklisted → 401) | criterion (1) test: phone 401 after its logout, laptop 200 | met | +| Feature doc `auth-register-login.md` Behavior #6 (refresh carries unique `jti`) | now set for every token in shared `jwtSign`; `refreshToken.test.ts`, `refreshTokenReuse.test.ts` PASS | met | + +- Commands (step 4): `npm test`, `npx jest `, `npm run build`, `npm run lint` — all match `doctrine/MEMORY.md`, run from repo root. +- Output (step 5): verbatim result lines; the `hc4v…` token abbreviation sits only in a parenthetical about the superseded pre-review shape, not in evidence for any criterion. +- Criteria rewrite: `## Acceptance criteria clarified` line present (sanctioned by `pick_next` step 5), reason = `/code-review` finding #1 (fix moved into the shared signer). +- Supersedes/Still open: `none`, grep of `#490` on active diagram confirms only this node. +- Review (6b2): `/code-review medium` — 4 findings, #1 and #4 fixed, #2/#3 moved to `## Noticed, not done` with reasons; label `bug`, not `security` → no `/security-review` required. +- Doctrine proposal (6c): none in note. +- Forbidden states (7): ADHOC_WORK no (node existed PENDING) · NO_EVIDENCE no · EDIT_UNVERIFIED no · CODE_IN_HAVEN no · DIAGRAM_DRIFT no (status updated by this verdict). +- Seal gate (8): no outward-facing action in the diff; `/todo` step 0 `gh` calls recorded. +- Proportionality (9): shared signer + caller cleanup + tests + `.claude/rules/api.md` auth-flow doc sync — matches the node's stated fix, nothing extra. + +## Re-run +none — audit-only; note's output verbatim, commands match doctrine, every criterion cited; no Re-run-scope exception applies (not outward-facing, not a `/release` gate). + +## Follow-ups (not blocking) +Noticed-not-done #1 (`isSessionRevoked` second-precision `iat < invalidatedAt`) deserves its own node/issue. diff --git a/agent-hub/evidence/worker-runs.log b/agent-hub/evidence/worker-runs.log index 94b4446e..abd49df5 100644 --- a/agent-hub/evidence/worker-runs.log +++ b/agent-hub/evidence/worker-runs.log @@ -2,3 +2,4 @@ 2026-11-17T08:46:36Z role=verifier outcome=SEAL node=auth-service-throw-apperror rerun=none spawn=fresh hub_bytes_before=97847 hub_bytes_after=97849 2026-11-18T09:00:21Z role=verifier outcome=SEAL node=hide-password-select-false rerun=none spawn=fresh hub_bytes_before=97857 hub_bytes_after=97851 2026-11-18T09:36:07Z role=verifier outcome=SEAL node=auth-http-integration-tests rerun=partial spawn=fresh hub_bytes_before=97851 hub_bytes_after=97855 +2026-11-18T09:50:12Z role=verifier outcome=SEAL node=fix-access-token-jti rerun=none spawn=fresh hub_bytes_before=98675 hub_bytes_after=97846 diff --git a/agent-hub/haven/diagrams/dev-loop-archive.md b/agent-hub/haven/diagrams/dev-loop-archive.md index 772ee9b6..06ac3847 100644 --- a/agent-hub/haven/diagrams/dev-loop-archive.md +++ b/agent-hub/haven/diagrams/dev-loop-archive.md @@ -189,3 +189,4 @@ | `logout-refresh-token-header` | SEALED | #475 — `authLogout` (`src/auth/auth.controller.ts`) looks up `refreshToken` via `extractTokenFromRequest`, which returns the `Authorization` header first, so it blacklists the access token twice and the real refresh token stays valid. Fix: that lookup skips the header (body/query/cookie only); `/auth/refresh` keeps header support (operator, 2026-11-17). Acceptance: new unit test logout with `Bearer ` + body `refreshToken` blacklists both; `npm test` + `npm run build` green; lint ≤ baseline, none in touched files; matches `features/auth-session-tokens.md` Behavior #7 (as amended). | | `hide-password-select-false` | SEALED | GitHub issue #459. `src/models/candidate.model.ts:25` — `password` returned by default, every query must remember `.select('-password')` (#152 regressed exactly this). Fix: `select: false` on the schema; opt in with `.select('+password')` only where the hash is compared (`auth.service.ts` `handlerLogin`; reset writes via `updateOne`, needs no read). Acceptance: (1) login reads the hash via `+password` — `npx jest src/__tests__/auth/auth.service.test.ts` green; (2) new test: a plain `CandidateModel.findById()` query sends a projection excluding `password` — `npx jest src/__tests__/models/candidatePassword.test.ts` green; (3) `npm test` + `npm run build` green, lint ≤ baseline with none in changed files. SEALED 2026-11-18 after independent verifier pass (audit-only, no re-run). Evidence: `evidence/implementer/2026-11-18/hide-password-select-false.md`, `evidence/verifier/2026-11-18/hide-password-select-false-seal.md`. | | `auth-http-integration-tests` | SEALED | #463 — HTTP-level supertest + mongodb-memory-server tests over the real `runServer` middleware chain (`src/server.ts`, app factored into an exported `createApp()`): register→login→GET→refresh→logout (token rejected after); rotated refresh reuse >10s revokes all sessions; cookie-only POST without CSRF → 403; client `candidateId` ignored (IDOR); unknown route → 404 standard error shape; Redis absent (in-memory fallback). Accept: `npx jest src/__tests__/integration/auth.http.test.ts` + `npm test` + `npm run build` green; lint ≤ 274 baseline, none in changed files. SEALED 2026-11-18 after independent verifier pass (partial re-run: eslint on changed files). Evidence: `evidence/implementer/2026-11-18/auth-http-integration-tests-diff.md`, `evidence/verifier/2026-11-18/auth-http-integration-tests-seal.md`. | +| `fix-access-token-jti` | SEALED | #490 — access tokens are signed with `{ _id }` only (`src/auth/auth.service.ts` `handlerLogin`, `src/auth/auth.controller.ts` `authRefreshToken`), so two issued for one candidate in the same second are byte-identical and logout on one session blacklists the other (found by #463 integration tests). Fix (root cause, shared signer): `src/utils/jwt.ts` `jwtSign` sets `jwtid: crypto.randomUUID()` on every token; callers stop adding their own refresh `jti`. Accept: (1) two same-second logins → different access tokens, logout one → the other still 200 on a protected GET (`npx jest src/__tests__/integration/auth.http.test.ts`); (2) `jwtSign` unit test: same payload, same second → different tokens with distinct `jti` (`npx jest src/__tests__/utils/jwt.test.ts`), and the auth unit tests still pass (`npx jest src/__tests__/auth`); (3) `npm test` + `npm run build` green; lint ≤ 274, none new in changed files. | diff --git a/agent-hub/haven/diagrams/dev-loop.prime-mermaid.md b/agent-hub/haven/diagrams/dev-loop.prime-mermaid.md index c553722f..fcf8d58a 100644 --- a/agent-hub/haven/diagrams/dev-loop.prime-mermaid.md +++ b/agent-hub/haven/diagrams/dev-loop.prime-mermaid.md @@ -64,7 +64,6 @@ flowchart TD | `fix-refresh-token-expiry-unused` | PENDING | `TOKEN_EXP_IN` (`.env`, already exported in config) is never used at any `jwtSign()` call site (`auth.service.ts`, `auth.controller.ts`, `api/v1/auth/services/login.ts`) — access and refresh tokens always share the same default 1h expiry, so the refresh token is pointless. | | `ci-lint-ratchet` | SEALED | 2026-11-16 — archived, see `haven/diagrams/dev-loop-archive.md`. Evidence: `evidence/verifier/2026-11-16/ci-lint-ratchet-seal.md`. | | `job-applications-status-transitions` | SEALED | 2026-11-15 — archived, see `haven/diagrams/dev-loop-archive.md`. Evidence: `evidence/verifier/2026-11-15/job-applications-status-transitions-seal.md`. | -| `short-values-validation` | SEALED | 2026-11-08 — archived, see `haven/diagrams/dev-loop-archive.md`. Evidence: `evidence/verifier/2026-11-08/short-values-validation-seal-r2.md`. | | `paginate-visits` | SEALED | 2026-11-09 — archived, see `haven/diagrams/dev-loop-archive.md`. Evidence: `evidence/verifier/2026-11-09/paginate-visits-seal.md`. | | `search-in-profile-only` | SEALED | 2026-11-09 — archived, see `haven/diagrams/dev-loop-archive.md`. Evidence: `evidence/verifier/2026-11-09/search-in-profile-only-seal.md`. | | `dedup-visits` | SEALED | 2026-11-09 — archived, see `haven/diagrams/dev-loop-archive.md`. Evidence: `evidence/verifier/2026-11-09/dedup-visits-seal.md`. | @@ -81,3 +80,4 @@ flowchart TD | `auth-service-throw-apperror` | SEALED | 2026-11-17 — archived, see `haven/diagrams/dev-loop-archive.md`. Evidence: `evidence/verifier/2026-11-17/auth-service-throw-apperror-seal.md`. | | `hide-password-select-false` | SEALED | 2026-11-18 — archived, see `haven/diagrams/dev-loop-archive.md`. Evidence: `evidence/verifier/2026-11-18/hide-password-select-false-seal.md`. | | `auth-http-integration-tests` | SEALED | 2026-11-18 — archived, see `haven/diagrams/dev-loop-archive.md`. Evidence: `evidence/verifier/2026-11-18/auth-http-integration-tests-seal.md`. | +| `fix-access-token-jti` | SEALED | 2026-11-18 — archived, see `haven/diagrams/dev-loop-archive.md`. Evidence: `evidence/verifier/2026-11-18/fix-access-token-jti-seal.md`. | diff --git a/src/__tests__/auth/auth.service.test.ts b/src/__tests__/auth/auth.service.test.ts index b46da04f..ebf0e2bc 100644 --- a/src/__tests__/auth/auth.service.test.ts +++ b/src/__tests__/auth/auth.service.test.ts @@ -141,8 +141,7 @@ describe('auth.service', () => { secretKey: expect.any(String), props: expect.objectContaining({ expiresIn: expect.any(String) }), }); - // A fresh `jti` per refresh token, so two logins in the same second never produce the same token. - expect(jwt.jwtSign).toHaveBeenNthCalledWith(2, expect.objectContaining({ data: { _id: 'user_id', jti: expect.any(String) } })); + expect(jwt.jwtSign).toHaveBeenNthCalledWith(2, expect.objectContaining({ data: { _id: 'user_id' } })); expect(result).toEqual({ success: true, message: 'Đăng nhập thành công', diff --git a/src/__tests__/auth/refreshToken.test.ts b/src/__tests__/auth/refreshToken.test.ts index 8a676d16..0ad14b61 100644 --- a/src/__tests__/auth/refreshToken.test.ts +++ b/src/__tests__/auth/refreshToken.test.ts @@ -81,7 +81,7 @@ describe('authRefreshToken controller', () => { await authRefreshToken(req, res, next); expect(mockedClaimRotation).toHaveBeenCalledWith('oldRefresh', expect.any(Number)); - expect(mockedJwtSign).toHaveBeenNthCalledWith(2, expect.objectContaining({ data: { _id: 'user1', jti: expect.any(String) } })); + expect(mockedJwtSign).toHaveBeenNthCalledWith(2, expect.objectContaining({ data: { _id: 'user1' } })); expect(mockedInvalidateAllSessions).not.toHaveBeenCalled(); expect(res.status).toHaveBeenCalledWith(200); expect(res.status().json).toHaveBeenCalledWith(expect.objectContaining({ success: true })); diff --git a/src/__tests__/auth/refreshTokenReuse.test.ts b/src/__tests__/auth/refreshTokenReuse.test.ts index 39eb8d06..8bb33d49 100644 --- a/src/__tests__/auth/refreshTokenReuse.test.ts +++ b/src/__tests__/auth/refreshTokenReuse.test.ts @@ -13,7 +13,7 @@ import { TOKEN_REFRESH, TOKEN_SECRET } from '@/config/process.config'; const T0 = Date.UTC(2026, 9, 16, 9, 0, 0); const loginRefreshToken = (candidateId: string) => - jwtSign({ data: { _id: candidateId, jti: `login-${Date.now()}` }, secretKey: TOKEN_REFRESH, props: { expiresIn: '7d' } }); + jwtSign({ data: { _id: candidateId }, secretKey: TOKEN_REFRESH, props: { expiresIn: '7d' } }); const refresh = async (refreshToken: string) => { const json = jest.fn(); diff --git a/src/__tests__/integration/auth.http.test.ts b/src/__tests__/integration/auth.http.test.ts index 8603c92b..e6a430f6 100644 --- a/src/__tests__/integration/auth.http.test.ts +++ b/src/__tests__/integration/auth.http.test.ts @@ -31,9 +31,9 @@ beforeAll(async () => { await mongoose.connect(mongo.getUri()); app = createApp(); - // One user per flow: access tokens carry no jti, so a same-second login would mint a token another flow already blacklisted. - const results = await Promise.all(['alice@example.com', 'bob@example.com', 'carol@example.com', 'dave@example.com'].map(register)); - expect(results.map((r) => r.status)).toEqual([201, 201, 201, 201]); + // One user per flow, so one flow's logout or session revocation can't leak into another. + const results = await Promise.all(['alice@example.com', 'bob@example.com', 'carol@example.com', 'dave@example.com', 'erin@example.com'].map(register)); + expect(results.map((r) => r.status)).toEqual([201, 201, 201, 201, 201]); }, 120_000); afterAll(async () => { @@ -93,6 +93,21 @@ it('reusing a rotated refresh token after the 10s grace window revokes every ses expect(refreshWithRotated.body.error.code).toBe('TOKEN_REVOKED'); }); +it('logging out one session leaves another session signed in the same second working', async () => { + // Pin the clock only for the two logins, so both tokens get the same iat — the case where a jti-less payload would collide. + const clock = jest.spyOn(Date, 'now').mockReturnValue(Date.now()); + const phone = await login('erin@example.com'); + const laptop = await login('erin@example.com'); + clock.mockRestore(); + expect(laptop.token).not.toBe(phone.token); + + const logout = await request(app).post('/api/v1/auth/logout').set('Authorization', `Bearer ${phone.token}`).send({ refreshToken: phone.tokenRefresh }); + expect(logout.status).toBe(200); + + expect((await getProfiles(phone.token)).status).toBe(401); + expect((await getProfiles(laptop.token)).status).toBe(200); +}); + it('rejects a cookie-only state-changing request without the CSRF header', async () => { const { cookies } = await login('carol@example.com'); diff --git a/src/__tests__/utils/jwt.test.ts b/src/__tests__/utils/jwt.test.ts new file mode 100644 index 00000000..73d90aeb --- /dev/null +++ b/src/__tests__/utils/jwt.test.ts @@ -0,0 +1,19 @@ +import jwt from 'jsonwebtoken'; +import { jwtSign } from '@/utils/jwt'; + +describe('jwtSign', () => { + it('gives every token its own jti, so the same payload signed in the same second never repeats', () => { + jest.spyOn(Date, 'now').mockReturnValue(Date.UTC(2026, 10, 18, 9, 0, 0)); + const a = jwtSign({ data: { _id: 'u1' }, secretKey: 'secret' }); + const b = jwtSign({ data: { _id: 'u1' }, secretKey: 'secret' }); + jest.restoreAllMocks(); + + expect(a).not.toBe(b); + const decodedA = jwt.decode(a) as { _id: string; jti: string; iat: number }; + const decodedB = jwt.decode(b) as { jti: string; iat: number }; + expect(decodedA._id).toBe('u1'); + expect(decodedA.iat).toBe(decodedB.iat); + expect(decodedA.jti).toEqual(expect.any(String)); + expect(decodedA.jti).not.toBe(decodedB.jti); + }); +}); diff --git a/src/auth/auth.controller.ts b/src/auth/auth.controller.ts index 146b21c6..d7446721 100644 --- a/src/auth/auth.controller.ts +++ b/src/auth/auth.controller.ts @@ -3,7 +3,6 @@ * @see https://github.com/datvt243 */ -import crypto from 'crypto'; import { Request, Response, NextFunction } from 'express'; import { StatusCodes } from 'http-status-codes'; import { validateSchema, formatReturn, handleError, setAuthCookies, clearAuthCookies } from '@/utils'; @@ -165,8 +164,7 @@ export const authRefreshToken = async (req: Request, res: Response, next: NextFu } const newAccess = jwtSign({ data: { _id }, secretKey: TOKEN_SECRET, props: { expiresIn: TOKEN_EXP_IN || '1h' } }); - // Unique `jti`, same reason as handlerLogin: a same-second copy of the rotated token would read as reuse. - const newRefresh = jwtSign({ data: { _id, jti: crypto.randomUUID() }, secretKey: TOKEN_REFRESH, props: { expiresIn: TOKEN_REFRESH_EXP_IN } }); + const newRefresh = jwtSign({ data: { _id }, secretKey: TOKEN_REFRESH, props: { expiresIn: TOKEN_REFRESH_EXP_IN } }); // Rotate the httpOnly cookies to match the rotated tokens setAuthCookies(res, { token: newAccess, tokenRefresh: newRefresh }); diff --git a/src/auth/auth.service.ts b/src/auth/auth.service.ts index d865a90a..a7fe4782 100644 --- a/src/auth/auth.service.ts +++ b/src/auth/auth.service.ts @@ -3,7 +3,6 @@ * @see https://github.com/datvt243 */ -import crypto from 'crypto'; import CandidateModel from '@/models/candidate.model'; import { bcryptGenerateSalt, bcryptCompareHash, jwtSign } from '@/utils'; import { TOKEN_SECRET, TOKEN_REFRESH, TOKEN_EXP_IN, TOKEN_REFRESH_EXP_IN } from '@/config/process.config'; @@ -101,8 +100,7 @@ export const handlerLogin = async (data: Auth, lang: string = DEFAULT_LANG) => { if (!comparePwd) throw new InvalidCredentialsError(t('auth.invalidCredentials', lang)); const token = jwtSign({ data: { _id }, secretKey: TOKEN_SECRET, props: { expiresIn: TOKEN_EXP_IN || '1h' } }); - // `jti` keeps refresh tokens unique: two signed in the same second would otherwise be byte-identical, and an identical copy of a rotated token reads as reuse. - const tokenRefresh = jwtSign({ data: { _id, jti: crypto.randomUUID() }, secretKey: TOKEN_REFRESH, props: { expiresIn: TOKEN_REFRESH_EXP_IN } }); + const tokenRefresh = jwtSign({ data: { _id }, secretKey: TOKEN_REFRESH, props: { expiresIn: TOKEN_REFRESH_EXP_IN } }); return { success: true, diff --git a/src/utils/jwt.ts b/src/utils/jwt.ts index 966ad113..de63a452 100644 --- a/src/utils/jwt.ts +++ b/src/utils/jwt.ts @@ -5,6 +5,7 @@ * @see https://github.com/datvt243 */ +import crypto from 'crypto'; import jwt from 'jsonwebtoken'; export const jwtSign = ({ @@ -23,7 +24,8 @@ export const jwtSign = ({ } const { expiresIn = '1d' } = props; - const token = jwt.sign(data, secretKey, { expiresIn }); + // Fresh `jti` on every token: two signed in the same second would otherwise be byte-identical, so logging out one session would revoke the other and an identical copy of a rotated refresh token would read as reuse. + const token = jwt.sign(data, secretKey, { expiresIn, jwtid: crypto.randomUUID() }); return token; }; From 1a808c3f32c45f06c621f9d48ffe1df886c86d02 Mon Sep 17 00:00:00 2001 From: _david Date: Thu, 19 Nov 2026 16:31:20 +0700 Subject: [PATCH 4/7] =?UTF-8?q?chore(agent-hub):=20sync=20kit=20af32868=20?= =?UTF-8?q?=E2=86=92=20e900251=20(verifier=20on=20Sonnet,=20batched=20look?= =?UTF-8?q?ups,=20worker-runs=20rotation)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - agent-hub/: CLAUDE.md batch-lookup rule, verifier manifest reads evidence/README.md, verify_seal re-run scope / one-call reads / pointer cap / worker-runs rotation (13b), evidence README coverage-claim rule; PROJECT.md branch naming marked "kept over kit default" (operator approved); ship notes for fix-access-token-jti and hide-password-select-false (2026-11-18) left uncommitted by ship.sh - .claude/skills/: hub-health grep/loop/report fixes, worker verifier on Sonnet, "Use when" descriptions, issues-ls description - Kit mechanism only, no code — no node, no test run needed Co-Authored-By: Claude Sonnet 5 --- .claude/skills/browser-debugger/SKILL.md | 2 +- .claude/skills/hub-health/SKILL.md | 11 +-- .claude/skills/issue-create/SKILL.md | 2 +- .claude/skills/issues-ls/SKILL.md | 2 +- .claude/skills/persona-load/SKILL.md | 2 +- .claude/skills/release/SKILL.md | 2 +- .claude/skills/ship/SKILL.md | 2 +- .claude/skills/spec-backfill/SKILL.md | 2 +- .claude/skills/todo/SKILL.md | 2 +- .claude/skills/worker/SKILL.md | 8 ++- agent-hub/.kit-version | 2 +- agent-hub/CLAUDE.md | 3 + agent-hub/doctrine/domains/PROJECT.md | 2 +- agent-hub/evidence/README.md | 7 +- .../2026-11-18/fix-access-token-jti-ship.md | 71 +++++++++++++++++++ .../hide-password-select-false-ship.md | 69 ++++++++++++++++++ .../haven/workers/verifier/manifest.yaml | 2 +- .../workers/verifier/recipes/verify_seal.md | 30 ++++++-- 18 files changed, 196 insertions(+), 25 deletions(-) create mode 100644 agent-hub/evidence/ship/2026-11-18/fix-access-token-jti-ship.md create mode 100644 agent-hub/evidence/ship/2026-11-18/hide-password-select-false-ship.md diff --git a/.claude/skills/browser-debugger/SKILL.md b/.claude/skills/browser-debugger/SKILL.md index ebc570e5..a543a836 100644 --- a/.claude/skills/browser-debugger/SKILL.md +++ b/.claude/skills/browser-debugger/SKILL.md @@ -1,6 +1,6 @@ --- name: browser-debugger -description: "Open a browser (Chrome/Firefox/Edge) with remote-debugging port 9888 so Claude can inspect/control it — optionally starting `npm run dev` first and pointing the browser at it. Usage: /browser-debugger [--browser=chrome|firefox|edge] [--run-dev]. Read-only dev utility, no code changes, no seal gate." +description: "Open a browser (Chrome/Firefox/Edge) with remote-debugging port 9888 so Claude can inspect/control it — optionally starting `npm run dev` first and pointing the browser at it. Usage: /browser-debugger [--browser=chrome|firefox|edge] [--run-dev]. Read-only dev utility, no code changes, no seal gate. Use when Claude needs to inspect or drive a live browser page." argument-hint: "[--browser=chrome|firefox|edge] [--run-dev]" --- diff --git a/.claude/skills/hub-health/SKILL.md b/.claude/skills/hub-health/SKILL.md index 6645a50a..0bbbed8f 100644 --- a/.claude/skills/hub-health/SKILL.md +++ b/.claude/skills/hub-health/SKILL.md @@ -99,8 +99,8 @@ echo "FLAGS:" DIAG_FILE="$HUB/haven/diagrams/dev-loop.prime-mermaid.md" if [ -f "$DIAG_FILE" ]; then DB=$(wc -c < "$DIAG_FILE") - FULL_SEALED=$(grep -cE '\| SEALED \|' "$DIAG_FILE" 2>/dev/null) - POINTER_SEALED=$(grep -cE '— archived, see' "$DIAG_FILE" 2>/dev/null) + FULL_SEALED=$(grep -cE '^\| .*\| SEALED \|' "$DIAG_FILE" 2>/dev/null) + POINTER_SEALED=$(grep -cE '^\| .*— archived, see' "$DIAG_FILE" 2>/dev/null) REAL_SEALED=$(( FULL_SEALED - POINTER_SEALED )) check_threshold_bytes "dev-loop.prime-mermaid.md" "$DB" 15360 \ "$REAL_SEALED full SEALED entries not yet archived ($POINTER_SEALED pointers; verify_seal step 11 should keep these at 0 full / <=20 pointers — a backlog here predates that rule or means step 11 was skipped), see rows below" @@ -213,7 +213,7 @@ def add(key, path): k = (inp.get("file_path"), inp.get("offset"), inp.get("limit")) reads.setdefault(k, []).append(size) if name == "Bash" and err: - k = " ".join(str(inp.get("command", "")).split())[:120] + k = " ".join(str(inp.get("command", "")).split()) # full command: a long shared prefix (S=…) isn't "the same command" fails[k] = fails.get(k, 0) + 1 if size > 40000: big.append((size, key, name, str(inp.get("file_path") or inp.get("command") or inp.get("description") or "")[:90])) @@ -253,7 +253,7 @@ for fp, (n, ch) in top: print(f" {n:>4}x {'image' if not ch else f'~{ch // 4} tok':>12} {fp}") print(f" failing Bash command repeated >=3x in one run: {len(loops)}") for cmd, n in sorted(loops.items(), key=lambda x: -x[1])[:5]: - print(f" {n:>4}x {cmd}") + print(f" {n:>4}x {cmd[:120]}") print(f" tool results >40k chars (~10k tok): {len(big)}") for size, who, name, what in sorted(big, reverse=True)[:5]: print(f" ~{size // 4:>7} tok {who:15} {name}: {what}") @@ -319,7 +319,8 @@ PY `/improvements/report/-#-hub-health-.md` — `` and the filename follow that repo's `.claude/rules/improvements-naming.md` (read it first; next number - = highest `#` among `report/` filenames + 1, 2 digits). Sections: + per its rule, including its number floor — `report/` may be empty or + missing, create it). Sections: `- **Recorded:**`, `- **Context:**` (project, kit version from `agent-hub/.kit-version`, window), `- **Status:** unverified`, `## Baseline` (output verbatim), `## Findings` (numbered: what, diff --git a/.claude/skills/issue-create/SKILL.md b/.claude/skills/issue-create/SKILL.md index 1e57097a..8975cbe4 100644 --- a/.claude/skills/issue-create/SKILL.md +++ b/.claude/skills/issue-create/SKILL.md @@ -1,6 +1,6 @@ --- name: issue-create -description: "Create a GitHub issue in this repo. Drafts title/body, shows the exact gh command, waits for approval before creating." +description: "Create a GitHub issue in this repo. Drafts title/body, shows the exact gh command, waits for approval before creating. Use when the user wants a new issue filed." argument-hint: "\"\" [--label x] [--assignee @me] [--yes]" disable-model-invocation: true --- diff --git a/.claude/skills/issues-ls/SKILL.md b/.claude/skills/issues-ls/SKILL.md index 352e085d..8a67e1f6 100644 --- a/.claude/skills/issues-ls/SKILL.md +++ b/.claude/skills/issues-ls/SKILL.md @@ -1,6 +1,6 @@ --- name: issues-ls -description: "List open GitHub issues for this repo, if it's hosted on GitHub. Read-only, no side effects." +description: "List open GitHub issues for this repo, if it's hosted on GitHub. Read-only, no side effects. Use when picking the next task or reviewing the backlog." argument-hint: "[--group] [--state open|closed|all] [gh issue list flags...]" --- diff --git a/.claude/skills/persona-load/SKILL.md b/.claude/skills/persona-load/SKILL.md index be533dcb..31ff9c24 100644 --- a/.claude/skills/persona-load/SKILL.md +++ b/.claude/skills/persona-load/SKILL.md @@ -1,6 +1,6 @@ --- name: persona-load -description: "Load an on-demand expert-persona or a named panel from this project's own persona library (outside agent-hub/), printing the loader's SEALED output for the current worker session to read. Advisory only, read-only, no side effects." +description: "Load an on-demand expert-persona or a named panel from this project's own persona library (outside agent-hub/), printing the loader's SEALED output for the current worker session to read. Advisory only, read-only, no side effects. Use when a worker needs domain-expert guidance for the current task." argument-hint: "/ | -p | -l [category]" --- diff --git a/.claude/skills/release/SKILL.md b/.claude/skills/release/SKILL.md index 143ab01d..51d14de2 100644 --- a/.claude/skills/release/SKILL.md +++ b/.claude/skills/release/SKILL.md @@ -1,6 +1,6 @@ --- name: release -description: "Promote staging into main by running the bundled release.sh: build/test gate, real merge commit (no squash), semver bump + tag vX.Y.Z, deploy via DEPLOY_HOOK_URL or report the deploy workflow run, sync the bump back to staging, close shipped issues (Closes #n in the release PR, read from the merged PRs). Usage: /release [patch|minor|major]. Invoking this skill IS the operator's go-ahead — no separate confirmation prompt." +description: "Promote staging into main by running the bundled release.sh: build/test gate, real merge commit (no squash), semver bump + tag vX.Y.Z, deploy via DEPLOY_HOOK_URL or report the deploy workflow run, sync the bump back to staging, close shipped issues (Closes #n in the release PR, read from the merged PRs). Usage: /release [patch|minor|major]. Invoking this skill IS the operator's go-ahead — no separate confirmation prompt. Use when staging is ready to go to production." argument-hint: "[patch|minor|major]" disable-model-invocation: true --- diff --git a/.claude/skills/ship/SKILL.md b/.claude/skills/ship/SKILL.md index 1624b3f5..0f797672 100644 --- a/.claude/skills/ship/SKILL.md +++ b/.claude/skills/ship/SKILL.md @@ -1,6 +1,6 @@ --- name: ship -description: "Commit + push a SEALED node via the bundled ship.sh — the outward-facing gate at the end of the loop. Usage: /ship \"[note]\" or /ship \"[note]\" --merge[=branch] to also merge into a target branch (directly, or through a GitHub PR + required CI when ship.env sets SHIP_MERGE_VIA=pr). Prints the exact git commands, then runs them at once — invoking /ship is the approval. Never --force/--no-verify." +description: "Commit + push a SEALED node via the bundled ship.sh — the outward-facing gate at the end of the loop. Usage: /ship \"[note]\" or /ship \"[note]\" --merge[=branch] to also merge into a target branch (directly, or through a GitHub PR + required CI when ship.env sets SHIP_MERGE_VIA=pr). Prints the exact git commands, then runs them at once — invoking /ship is the approval. Never --force/--no-verify. Use when a node is SEALED and the work should be committed." argument-hint: "[note] [--merge[=]]" --- diff --git a/.claude/skills/spec-backfill/SKILL.md b/.claude/skills/spec-backfill/SKILL.md index fe2914de..4cbc50d6 100644 --- a/.claude/skills/spec-backfill/SKILL.md +++ b/.claude/skills/spec-backfill/SKILL.md @@ -1,6 +1,6 @@ --- name: spec-backfill -description: "Bulk-backfill draft feature docs (doctrine/features/) for features that already exist in the code. Writes only agent-hub docs, never code. Docs stay draft until confirmed via /worker analyst." +description: "Bulk-backfill draft feature docs (doctrine/features/) for features that already exist in the code. Writes only agent-hub docs, never code. Docs stay draft until confirmed via /worker analyst. Use when adopting agent-hub in a codebase whose existing features have no docs." argument-hint: "[]" --- diff --git a/.claude/skills/todo/SKILL.md b/.claude/skills/todo/SKILL.md index 7a904839..e2b7454f 100644 --- a/.claude/skills/todo/SKILL.md +++ b/.claude/skills/todo/SKILL.md @@ -1,6 +1,6 @@ --- name: todo -description: "Resolve/create a GitHub issue + check out that issue's own branch, then combine /worker analyst (feature, or a bug with no feature doc yet), /worker implementer and /worker verifier into 1 typed command for a task — still runs 2 separate passes inside, looping automatically on REOPEN. Usage: /todo \"[task]\"|#[issue-number] [--ship]" +description: "Resolve/create a GitHub issue + check out that issue's own branch, then combine /worker analyst (feature, or a bug with no feature doc yet), /worker implementer and /worker verifier into 1 typed command for a task — still runs 2 separate passes inside, looping automatically on REOPEN. Usage: /todo \"[task]\"|#[issue-number] [--ship] Use when running any feat or fix task end-to-end." argument-hint: "|# [--ship]" disable-model-invocation: true --- diff --git a/.claude/skills/worker/SKILL.md b/.claude/skills/worker/SKILL.md index 9b345c2d..1cbc1bd1 100644 --- a/.claude/skills/worker/SKILL.md +++ b/.claude/skills/worker/SKILL.md @@ -1,6 +1,6 @@ --- name: worker -description: "Become an agent-hub worker (analyst, implementer or verifier) and carry out one task following exactly that worker's recipe. Usage: /worker [analyst|implementer|verifier] \"[task]\"" +description: "Become an agent-hub worker (analyst, implementer or verifier) and carry out one task following exactly that worker's recipe. Usage: /worker [analyst|implementer|verifier] \"[task]\" Use when running one loop role by hand instead of /todo." argument-hint: "" --- @@ -53,6 +53,12 @@ argument-hint: "" `recipes/verify_seal.md` step 1b makes the verifier record its own spawn proof in the `## Isolation proof` line of the verdict note, so a later audit can detect a skipped context split. (kit 2026-11-07) + Spawn it with `model: "sonnet"` (it checks cited evidence against + criteria, doesn't design). The spawn prompt names the absolute hub + path, the note path(s) and node slug(s) — never make the subagent + `ls` around to find its inputs, and never add re-run instructions + ("re-run the checks yourself") — `verify_seal.md`'s "Re-run scope" + alone decides. (kit 2026-11-18) Only exception to a fresh spawn: `/todo`'s REOPEN rounds resume the same verifier subagent (`todo` step 3) — still never the implementer's context. diff --git a/agent-hub/.kit-version b/agent-hub/.kit-version index 42d48985..511d91ff 100644 --- a/agent-hub/.kit-version +++ b/agent-hub/.kit-version @@ -1 +1 @@ -af32868 +e900251 diff --git a/agent-hub/CLAUDE.md b/agent-hub/CLAUDE.md index 1b7294af..f2b31bfd 100644 --- a/agent-hub/CLAUDE.md +++ b/agent-hub/CLAUDE.md @@ -94,6 +94,9 @@ its content/diff into the session, even the first time a file is created. Just report one line "📝 agent-hub: updated" and move on; report done when finished. Real diffs/code (outside `agent-hub/`) still display normally — that's what the operator actually needs to see. +Every tool call re-sends the whole context: batch independent read-only +lookups (greps, file reads, `ls`) into ONE Bash call instead of one call +each. ## Master Equation **Aligned = Purpose × Evidence × Care** — a multiplication, not an diff --git a/agent-hub/doctrine/domains/PROJECT.md b/agent-hub/doctrine/domains/PROJECT.md index 3cf71df2..0ac06a68 100644 --- a/agent-hub/doctrine/domains/PROJECT.md +++ b/agent-hub/doctrine/domains/PROJECT.md @@ -30,7 +30,7 @@ Repo: `github.com/datvt243/resume-nodejs-api`. Author: DatVT. `npm run build`. ## Branch naming -Branch naming: `/-` — type = `feature`/`fix`/`hotfix`/`refactor`/`perf`/`chore`, desc = at most 3 kebab-case words (e.g. `fix/408-general-info-confirm`). Changed 2026-11-16 from `-` (operator request). Pick type from the issue: label `bug` → `fix` (`hotfix` if it must skip the normal release cadence), `enhancement`/`feature` → `feature`, else the title's leading verb (refactor/perf/chore…); unclear → ask. +Branch naming: `/-` — type = `feature`/`fix`/`hotfix`/`refactor`/`perf`/`chore`, desc = at most 3 kebab-case words (e.g. `fix/408-general-info-confirm`); kept over kit default). Changed 2026-11-16 from `-` (operator request). Pick type from the issue: label `bug` → `fix` (`hotfix` if it must skip the normal release cadence), `enhancement`/`feature` → `feature`, else the title's leading verb (refactor/perf/chore…); unclear → ask. ## Diagram-first The diagram (`haven/diagrams/`) is the source of truth for progress — code diff --git a/agent-hub/evidence/README.md b/agent-hub/evidence/README.md index e2926495..5fafa2b8 100644 --- a/agent-hub/evidence/README.md +++ b/agent-hub/evidence/README.md @@ -29,7 +29,9 @@ Date in `YYYY-mm-dd` format, slug in kebab-case taken from the task name. - `## Acceptance` — a table | Criterion | Evidence | (evidence points to a specific line of output — never a bare "tests pass", must cite "Tests: 42 passed, 42 total"); always has a "comments per - code-comments.md" row + code-comments.md" row. A coverage claim ("only caller", "no other + path reads X") cites the exact search command + its output, so the + verifier audits it without re-searching - `## Supersedes` / `## Still open` — other not-yet-SEALED rows for the same issue: retired by this node on SEAL, or kept open with a reason (`recipes/implement.md` step 7b); `none` if @@ -111,7 +113,8 @@ Date in `YYYY-mm-dd` format, slug in kebab-case taken from the task name. move lines older than the current work session to `evidence/worker-runs-archive.log` (same directory, plain append, create it lazily on first use) — copy each line VERBATIM, never - reformat/summarize. Checked by `/hub-health`. Same "delete nothing" + reformat/summarize. Done by `verify_seal` step 13b; `/hub-health` + flags a miss. Same "delete nothing" rule as the active file — this is a move, not a cleanup. ## Format — ship note diff --git a/agent-hub/evidence/ship/2026-11-18/fix-access-token-jti-ship.md b/agent-hub/evidence/ship/2026-11-18/fix-access-token-jti-ship.md new file mode 100644 index 00000000..f2d38dd6 --- /dev/null +++ b/agent-hub/evidence/ship/2026-11-18/fix-access-token-jti-ship.md @@ -0,0 +1,71 @@ +# Ship — fix-access-token-jti +- Node: `fix-access-token-jti` (SEALED, `agent-hub/evidence/verifier/2026-11-18/fix-access-token-jti-seal.md`) · Branch: `fix/490-access-token-jti` · Remote: `https://github.com/datvt243/resume-nodejs-api.git` + +## Commands +- `git commit -m "fix(auth): give every JWT a unique jti so same-second sessions don't collide + +Access tokens were signed with { _id } only, so two issued for one candidate in the same second were byte-identical and logging out one session blacklisted the other. + +- src/utils/jwt.ts: jwtSign sets jwtid: crypto.randomUUID() on every token (access and refresh) +- src/auth/auth.service.ts, src/auth/auth.controller.ts: drop the hand-built refresh jti (jsonwebtoken rejects payload jti + jwtid) and the now-unused crypto import +- tests: new src/__tests__/utils/jwt.test.ts; integration test for two same-second logins where logout of one leaves the other at 200; caller unit tests and refreshTokenReuse helper adjusted +- .claude/rules/api.md: auth flow payload now { _id, jti } +- agent-hub: ship note for auth-http-integration-tests + +npm test: Test Suites: 75 passed, 75 total / Tests: 792 passed, 792 total +npm run build: exit 0 (tsc exit 0); lint 273 problems (<= 274 baseline), none new in changed files + +Node: fix-access-token-jti (SEALED) +Evidence: agent-hub/evidence/verifier/2026-11-18/fix-access-token-jti-seal.md + +Closes #490 + +Co-Authored-By: Claude Sonnet 5 "` +- `git push -u origin fix/490-access-token-jti` +- `gh pr create --base staging --head fix/490-access-token-jti (reuse an open one)` +- `gh pr checks --watch --required` +- `gh pr merge --merge` +- `git checkout staging` +- `git pull --ff-only origin staging` + +## Output +Commit: `df91bcc` +``` +$ git commit -m fix(auth): give every JWT a unique jti so same-second sessions don't collide + +Access tokens were signed with { _id } only, so two issued for one candidate in the same second were byte-identical and logging out one session blacklisted the other. + +- src/utils/jwt.ts: jwtSign sets jwtid: crypto.randomUUID() on every token (access and refresh) +- src/auth/auth.service.ts, src/auth/auth.controller.ts: drop the hand-built refresh jti (jsonwebtoken rejects payload jti + jwtid) and the now-unused crypto import +- tests: new src/__tests__/utils/jwt.test.ts; integration test for two same-second logins where logout of one leaves the other at 200; caller unit tests and refreshTokenReuse helper adjusted +- .claude/rules/api.md: auth flow payload now { _id, jti } +- agent-hub: ship note for auth-http-integration-tests + +npm test: Test Suites: 75 passed, 75 total / Tests: 792 passed, 792 total +npm run build: exit 0 (tsc exit 0); lint 273 problems (<= 274 baseline), none new in changed files + +Node: fix-access-token-jti (SEALED) +Evidence: agent-hub/evidence/verifier/2026-11-18/fix-access-token-jti-seal.md + +Closes #490 + +Co-Authored-By: Claude Sonnet 5 +[fix/490-access-token-jti df91bcc] fix(auth): give every JWT a unique jti so same-second sessions don't collide + 16 files changed, 279 insertions(+), 17 deletions(-) + create mode 100644 agent-hub/evidence/implementer/2026-11-18/fix-access-token-jti-diff.md + create mode 100644 agent-hub/evidence/implementer/2026-11-18/fix-access-token-jti-plan.md + create mode 100644 agent-hub/evidence/ship/2026-11-18/auth-http-integration-tests-ship.md + create mode 100644 agent-hub/evidence/verifier/2026-11-18/fix-access-token-jti-seal.md + create mode 100644 src/__tests__/utils/jwt.test.ts +$ git push -u origin fix/490-access-token-jti +To https://github.com/datvt243/resume-nodejs-api.git + de5fd4f..df91bcc fix/490-access-token-jti -> fix/490-access-token-jti +branch 'fix/490-access-token-jti' set up to track 'origin/fix/490-access-token-jti'. +PR: https://github.com/datvt243/resume-nodejs-api/pull/491 +build (20.x) pass 1m12s https://github.com/datvt243/resume-nodejs-api/actions/runs/44279792722/job/134717130395 +build (22.x) pass 1m5s https://github.com/datvt243/resume-nodejs-api/actions/runs/44279792722/job/134717130906 +$ gh pr merge 491 --merge +``` + +## Seal gate +Approved by the operator invoking /ship (AutoCommitNoGate), covering the whole chain above. diff --git a/agent-hub/evidence/ship/2026-11-18/hide-password-select-false-ship.md b/agent-hub/evidence/ship/2026-11-18/hide-password-select-false-ship.md new file mode 100644 index 00000000..7f082f8b --- /dev/null +++ b/agent-hub/evidence/ship/2026-11-18/hide-password-select-false-ship.md @@ -0,0 +1,69 @@ +# Ship — hide-password-select-false +- Node: `hide-password-select-false` (SEALED, `agent-hub/evidence/verifier/2026-11-18/hide-password-select-false-seal.md`) · Branch: `refactor/459-hide-password-select` · Remote: `https://github.com/datvt243/resume-nodejs-api.git` + +## Commands +- `git commit -m "refactor(candidate): hide password at schema level with select: false + +- models/candidate.model.ts: password gets select: false, so no query + returns the hash unless it opts in +- auth/auth.service.ts: handlerLogin (only hash reader) opts in with + .select('+password'); reset writes via updateOne, unchanged +- tests: login mocks chain .select and assert '+password'; new + models/candidatePassword.test.ts asserts a plain findById() sends + projection { password: 0 } (red without the fix) + +npm test: Test Suites: 73 passed, 73 total; Tests: 784 passed, 784 total +npm run build: exit 0 (tsc typecheck); lint 274 = baseline, 0 new + +Node: hide-password-select-false (SEALED) +Evidence: agent-hub/evidence/verifier/2026-11-18/hide-password-select-false-seal.md + +Closes #459 + +Co-Authored-By: Claude Sonnet 5 "` +- `git push -u origin refactor/459-hide-password-select` +- `gh pr create --base staging --head refactor/459-hide-password-select (reuse an open one)` +- `gh pr checks --watch --required` +- `gh pr merge --merge` +- `git checkout staging` +- `git pull --ff-only origin staging` + +## Output +Commit: `41df4ae` +``` +$ git commit -m refactor(candidate): hide password at schema level with select: false + +- models/candidate.model.ts: password gets select: false, so no query + returns the hash unless it opts in +- auth/auth.service.ts: handlerLogin (only hash reader) opts in with + .select('+password'); reset writes via updateOne, unchanged +- tests: login mocks chain .select and assert '+password'; new + models/candidatePassword.test.ts asserts a plain findById() sends + projection { password: 0 } (red without the fix) + +npm test: Test Suites: 73 passed, 73 total; Tests: 784 passed, 784 total +npm run build: exit 0 (tsc typecheck); lint 274 = baseline, 0 new + +Node: hide-password-select-false (SEALED) +Evidence: agent-hub/evidence/verifier/2026-11-18/hide-password-select-false-seal.md + +Closes #459 + +Co-Authored-By: Claude Sonnet 5 +[refactor/459-hide-password-select 41df4ae] refactor(candidate): hide password at schema level with select: false + 9 files changed, 214 insertions(+), 7 deletions(-) + create mode 100644 agent-hub/evidence/implementer/2026-11-18/hide-password-select-false.md + create mode 100644 agent-hub/evidence/verifier/2026-11-18/hide-password-select-false-seal.md + create mode 100644 src/__tests__/models/candidatePassword.test.ts +$ git push -u origin refactor/459-hide-password-select +To https://github.com/datvt243/resume-nodejs-api.git + b1ea2be..41df4ae refactor/459-hide-password-select -> refactor/459-hide-password-select +branch 'refactor/459-hide-password-select' set up to track 'origin/refactor/459-hide-password-select'. +PR: https://github.com/datvt243/resume-nodejs-api/pull/488 +build (20.x) pass 1m36s https://github.com/datvt243/resume-nodejs-api/actions/runs/44271973245/job/134690561564 +build (22.x) pass 1m5s https://github.com/datvt243/resume-nodejs-api/actions/runs/44271973245/job/134690562088 +$ gh pr merge 488 --merge +``` + +## Seal gate +Approved by the operator invoking /ship (AutoCommitNoGate), covering the whole chain above. diff --git a/agent-hub/haven/workers/verifier/manifest.yaml b/agent-hub/haven/workers/verifier/manifest.yaml index b3f62b93..b5e9da8f 100644 --- a/agent-hub/haven/workers/verifier/manifest.yaml +++ b/agent-hub/haven/workers/verifier/manifest.yaml @@ -12,7 +12,7 @@ hard_rules: - EvidenceOnly # never trust reasoning in place of real evidence - NeverVerifyOwnWork # never grade a diff you wrote yourself - RatchetOnly # PM status only moves forward, never backward -reads: [evidence/implementer/, haven/diagrams/, doctrine/MEMORY.md, CLAUDE.md] +reads: [evidence/implementer/, evidence/README.md, haven/diagrams/, doctrine/MEMORY.md, CLAUDE.md] # doctrine/MEMORY.md: recipe step 4 needs to check the command in the note. # No NORTHSTAR.md — the recipe never uses it, a wasted read on every subagent spawn. # + the ONE doctrine/features/.md the note's `## Feature doc` line cites. diff --git a/agent-hub/haven/workers/verifier/recipes/verify_seal.md b/agent-hub/haven/workers/verifier/recipes/verify_seal.md index fb9c1494..8abdf39e 100644 --- a/agent-hub/haven/workers/verifier/recipes/verify_seal.md +++ b/agent-hub/haven/workers/verifier/recipes/verify_seal.md @@ -55,8 +55,11 @@ Only re-run (partially or fully) when: command doesn't match doctrine → REOPEN immediately per steps 4-5, don't waste effort re-running an already-broken note "to be sure" — REOPEN and let the implementer write a correct note. -- The node is outward-facing or is a `/release` gate — higher risk than - an ordinary diff, worth the cost of an independent confirmation. +- The node itself performs an outward-facing action (the SEAL GATE list + in `CLAUDE.md`: push, publish, deploy, external API call...) or is a + `/release` gate — higher risk than an ordinary diff, worth the cost of + an independent confirmation. Code that reaches production later + through `/ship` does NOT count — on a website that's every change. - `doctrine/domains/PROJECT.md` explicitly lists this class of change as needing independent re-running (a per-project decision, not the kit's default). @@ -96,7 +99,12 @@ so every hub doesn't reason about it differently. a later audit that the subagent-spawn rule in `worker/SKILL.md` was skipped this round. 2. [LOOP STARTS HERE FOR EACH NODE if batch] Read the NOTE — only the - note, do NOT open the diff itself directly. (`EvidenceOnly`) + note, do NOT open the diff itself directly. (`EvidenceOnly`) One Bash + call: the note + the node row (`grep -n ''` on the active + diagram) + `doctrine/MEMORY.md` + `evidence/README.md`; the cited + feature doc (step 6b) in at most one more. A claim the note backs + with a cited search is audited from that citation — never re-run the + search. 3. Read the NODE — get the acceptance criteria from `haven/diagrams/`, the forbidden states from `CLAUDE.md`. [GUARD] Don't `Read agent-hub/CLAUDE.md` separately for this — same mechanism @@ -115,7 +123,9 @@ so every hub doesn't reason about it differently. 6. Go through the acceptance criteria ONE BY ONE — any missing evidence = REOPEN, state it clearly under "missing". Always includes the "comments per code-comments.md" row (see that standard's - Enforcement), even if the node's own criteria don't list it. Also: an open row for the same issue exists on the + Enforcement), even if the node's own criteria don't list it. A + coverage claim ("only caller", "no other path reads X") without its + exact search command + output = missing evidence. Also: an open row for the same issue exists on the active diagram but the note has no `## Supersedes`/`## Still open` line for it → REOPEN (implement step 7b skipped). 6b. Feature doc: the note has no `## Feature doc` line → REOPEN @@ -145,8 +155,11 @@ so every hub doesn't reason about it differently. `haven/diagrams/dev-loop-archive.md` (create it from §9️⃣.5 if absent); (b) replace the active row with `| node | SEALED | — archived, see dev-loop-archive.md. - Evidence: |`; (c) if the active PM status - now holds more than 20 such pointer rows, delete the oldest ones + Evidence: |`; (c) after (b) — always, also + when (b) replaced a PENDING row in place (that adds a pointer too) — + `grep -cE '^\| .*— archived, see'` the active file (table rows only); + more than 20 → delete the + oldest pointer lines until 20 remain (their full row already lives in the archive) — delete the whole line, leave no blank line; the table stays the file's last block (diagram PM status note); (d) for each row the @@ -196,6 +209,11 @@ so every hub doesn't reason about it differently. on how it's invoked, since it lives directly in this recipe, not in `/todo`. NEVER edit/delete an old line in this file, only append (the same principle as every other file in `evidence/`). +13b. After the append: `worker-runs.log` over 15KB (`wc -c`) → move + every line dated before today to `evidence/worker-runs-archive.log` + (`>>`, verbatim, create it lazily), keep today's lines — the + `evidence/README.md` TOKEN DISCIPLINE move, the only removal this + file allows. ## Hard rules honored `NeverVerifyOwnWork` | `EvidenceOnly` | `VerdictOnly` | `RatchetOnly` From 32cbe39a232c7eef6761796d5059642573ba3b51 Mon Sep 17 00:00:00 2001 From: _david Date: Thu, 19 Nov 2026 16:53:51 +0700 Subject: [PATCH 5/7] feat(auth): email reset/verify links over SMTP instead of logging tokens Reset and verification links carried live tokens in logger.info, so anyone with log access could take over an account. - src/services/mail.ts (new): sendAuthLinkEmail via Nodemailer SMTP (SMTP_HOST/PORT/USER/PASS, MAIL_FROM, APP_URL), plain text in the ?lang= language, 10s SMTP timeouts; SMTP_HOST or APP_URL unset -> dev logs the link, prod warns without it and sends nothing - src/auth/auth.service.ts: register and forgot-password email the link fire-and-forget (no response-time difference for registered emails, a failed send keeps the generic response and is logged by message only); prod forgot-password logs only the candidate id - src/locales/vi.ts, en.ts: mail subject/body strings - src/utils/passwordReset.ts, emailVerification.ts, src/routers/api/v1/auth.route.ts: stale stub comments/summaries updated - tests: auth.service.test.ts mocks the mail module (send asserted, no token in prod logs, failure path, no await); new services/mail.test.ts with nodemailer mocked - package.json/package-lock.json: nodemailer ^10.6.0 (6.x had open high advisories), @types/nodemailer - .env.example, CLAUDE.md, .claude/rules/api.md, README.md: new env vars, stub wording removed npm test: Test Suites: 76 passed, 76 total / Tests: 801 passed, 801 total npm run build: exit 0 (tsc typecheck); lint 273 problems (<= 274 baseline), none new in changed files Node: email-auth-links (SEALED) Evidence: agent-hub/evidence/verifier/2026-11-19/email-auth-links-seal.md Closes #461 Co-Authored-By: Claude Sonnet 5 --- .claude/rules/api.md | 4 +- .env.example | 11 ++ CLAUDE.md | 6 + README.md | 2 +- agent-hub/doctrine/features/INDEX.md | 4 +- .../doctrine/features/auth-password-reset.md | 64 ++++++++++- .../doctrine/features/auth-register-login.md | 26 ++++- .../2026-11-19/password-reset-email-spec.md | 47 ++++++++ .../2026-11-19/email-auth-links-diff.md | 107 ++++++++++++++++++ .../2026-11-19/email-auth-links-plan.md | 20 ++++ .../2026-11-19/email-auth-links-seal.md | 33 ++++++ agent-hub/evidence/worker-runs.log | 1 + agent-hub/haven/diagrams/dev-loop-archive.md | 2 + .../haven/diagrams/dev-loop.prime-mermaid.md | 2 +- package-lock.json | 21 ++++ package.json | 2 + src/__tests__/auth/auth.service.test.ts | 86 ++++++++++++-- src/__tests__/services/mail.test.ts | 81 +++++++++++++ src/auth/auth.service.ts | 31 +++-- src/locales/en.ts | 10 ++ src/locales/vi.ts | 10 ++ src/routers/api/v1/auth.route.ts | 4 +- src/services/mail.ts | 49 ++++++++ src/utils/emailVerification.ts | 4 +- src/utils/passwordReset.ts | 4 +- 25 files changed, 591 insertions(+), 40 deletions(-) create mode 100644 agent-hub/evidence/analyst/2026-11-19/password-reset-email-spec.md create mode 100644 agent-hub/evidence/implementer/2026-11-19/email-auth-links-diff.md create mode 100644 agent-hub/evidence/implementer/2026-11-19/email-auth-links-plan.md create mode 100644 agent-hub/evidence/verifier/2026-11-19/email-auth-links-seal.md create mode 100644 src/__tests__/services/mail.test.ts create mode 100644 src/services/mail.ts diff --git a/.claude/rules/api.md b/.claude/rules/api.md index 34e54ba8..b887abf0 100644 --- a/.claude/rules/api.md +++ b/.claude/rules/api.md @@ -27,9 +27,9 @@ state-changing requests must also pass the double-submit CSRF check (see Securit | POST | `/logout` | Blacklist current token (CSRF-checked) | | POST | `/logout-all` | Revoke every token issued to this candidate up to now | | POST | `/refresh` | Rotate tokens; blacklist old refresh token (CSRF-checked); reuse of a rotated token > 10s later revokes all sessions | -| POST | `/forgot-password` | Request password reset (stub — logged, not emailed) | +| POST | `/forgot-password` | Request password reset (link emailed via SMTP, `services/mail.ts`) | | POST | `/reset-password` | Reset password using a reset token | -| GET | `/verify-email` | Verify email using a token issued on register (stub) | +| GET | `/verify-email` | Verify email using the token emailed on register | `api/v2/auth` mirrors `/register` and `/login` only — still WIP. diff --git a/.env.example b/.env.example index b30cbb6d..bd4b3c39 100644 --- a/.env.example +++ b/.env.example @@ -30,3 +30,14 @@ TOKEN_EXP_IN=7d # caller's origin; unset in production blocks every cross-origin request. CORS_ORIGIN=https://your-frontend-domain.example + +# Email (password reset + email verification links), Nodemailer over SMTP. +# SMTP_HOST or APP_URL unset: development logs the link instead of sending; +# production logs a warning and sends nothing. SMTP_PORT 465 = implicit TLS. +SMTP_HOST= +SMTP_PORT=587 +SMTP_USER= +SMTP_PASS= +MAIL_FROM= +# Frontend base URL the emailed links open (/reset-password, /verify-email) +APP_URL= diff --git a/CLAUDE.md b/CLAUDE.md index 936176ff..19613941 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -57,6 +57,12 @@ CORS_ORIGIN=... # comma-separated allow-list; required for the http TOKEN_REFRESH_EXP_IN=7d # optional; refresh token lifetime (default 7d) TRUST_PROXY_HOPS=1 # optional; proxy hops in front of the app (1 on Render) so req.ip / rate limit # key on the real client; unset = trust none (no proxy) +SMTP_HOST=... # optional; reset/verify links emailed via Nodemailer (services/mail.ts) +SMTP_PORT=587 # optional; 465 = implicit TLS +SMTP_USER=... / SMTP_PASS=... +MAIL_FROM=... # From address +APP_URL=... # frontend base URL for the emailed links; SMTP_HOST or APP_URL unset → + # dev logs the link, prod warns and sends nothing (never logs the token) ``` ## Conventions diff --git a/README.md b/README.md index c333c1b7..2cf9518c 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ REST API (Node.js + TypeScript) for managing candidate profiles (CVs): JWT login ## Features -- **Authentication** — JWT access/refresh (httpOnly cookie or Bearer), bcrypt, CSRF, token blacklist, log out of every device, refresh-token reuse detection, forgot/reset password (stub, no real email sent yet) +- **Authentication** — JWT access/refresh (httpOnly cookie or Bearer), bcrypt, CSRF, token blacklist, log out of every device, refresh-token reuse detection, forgot/reset password and email verification (links emailed over SMTP) - **CV profile** — candidate information, education, experience (with career breaks), projects, awards, certificates, references; soft delete and restore - **Multiple CV versions** — each version is a subset of the entries, with its own public link and PDF - **Public profile** — custom slug, public profile search, view statistics (country, traffic source, CV version) diff --git a/agent-hub/doctrine/features/INDEX.md b/agent-hub/doctrine/features/INDEX.md index f83571be..f23ac3fd 100644 --- a/agent-hub/doctrine/features/INDEX.md +++ b/agent-hub/doctrine/features/INDEX.md @@ -10,9 +10,9 @@ | Feature | Doc | Status | Area / anchors | Issues | |---|---|---|---|---| -| Register, login and email verification | auth-register-login.md | verified — confirmed by operator 2026-11-07, see `evidence/analyst/2026-11-07/auth-register-login-spec.md` | auth / `src/auth/`, `src/routers/api/v1/auth.route.ts`, `src/routers/api/v2/auth.route.ts` | #385, #387, #389, #390 | +| Register, login and email verification | auth-register-login.md | verified — confirmed by operator 2026-11-07, see `evidence/analyst/2026-11-07/auth-register-login-spec.md`; #461 additions draft | auth / `src/auth/`, `src/routers/api/v1/auth.route.ts`, `src/routers/api/v2/auth.route.ts` | #385, #387, #389, #390, #461 | | Session tokens: refresh, logout, logout-all | auth-session-tokens.md | verified — confirmed by operator 2026-11-07, see `evidence/analyst/2026-11-07/auth-session-tokens-spec.md` | auth / `src/middlewares/verifyToken.middleware.ts`, `src/utils/tokenBlacklist.ts`, `src/utils/sessionRevocation.ts`, `src/utils/csrf.ts` | #391, #392 | -| Password reset | auth-password-reset.md | verified — confirmed by operator 2026-11-07, see `evidence/analyst/2026-11-07/auth-password-reset-spec.md` | auth / `src/auth/auth.service.ts`, `src/utils/passwordReset.ts` | #385, #387, #393 | +| Password reset | auth-password-reset.md | verified — confirmed by operator 2026-11-07, see `evidence/analyst/2026-11-07/auth-password-reset-spec.md`; #461 additions draft | auth / `src/auth/auth.service.ts`, `src/utils/passwordReset.ts` | #385, #387, #393, #461 | | Candidate account | candidate-account.md | verified — confirmed by operator 2026-11-07, see `evidence/analyst/2026-11-07/candidate-account-spec.md` | candidate / `src/candidate/candidate.service.ts`, `src/routers/api/v1/candidate.route.ts` | #380, #394, #395 | | CV section CRUD (education, experience, award, certificate, project, reference) | cv-section-crud.md | verified — confirmed by operator 2026-11-07, see `evidence/analyst/2026-11-07/cv-section-crud-spec.md` | cv sections / `src/candidate_profile/BaseController.ts`, `src/candidate_profile/BaseService.ts`, `src/services/index.ts`, `src/candidate_me/index.ts` | #381, #402, #403, #404, #413 (manual order, verified by `evidence/verifier/2026-11-14/education-project-manual-order-seal.md`) | | General information | general-information.md | verified — confirmed by operator 2026-11-07, see `evidence/analyst/2026-11-07/general-information-spec.md` | cv sections / `src/candidate_profile/general_information/` | #408 | diff --git a/agent-hub/doctrine/features/auth-password-reset.md b/agent-hub/doctrine/features/auth-password-reset.md index 6f315e8f..94b1ba19 100644 --- a/agent-hub/doctrine/features/auth-password-reset.md +++ b/agent-hub/doctrine/features/auth-password-reset.md @@ -1,9 +1,9 @@ # Password reset -- Status: verified — confirmed by operator 2026-11-07, see `evidence/analyst/2026-11-07/auth-password-reset-spec.md` +- Status: verified — confirmed by operator 2026-11-07, see `evidence/analyst/2026-11-07/auth-password-reset-spec.md` (rules 1–6); rules 7–11 draft for #461 - Source: backfill from code -- Issues: #385, #387, #393 -- Anchors: `src/routers/api/v1/auth.route.ts`, `src/auth/auth.controller.ts`, `src/auth/auth.service.ts`, `src/auth/auth.validate.ts`, `src/utils/passwordReset.ts` +- Issues: #385, #387, #393, #461 +- Anchors: `src/routers/api/v1/auth.route.ts`, `src/auth/auth.controller.ts`, `src/auth/auth.service.ts`, `src/auth/auth.validate.ts`, `src/utils/passwordReset.ts`, `src/__tests__/auth/auth.service.test.ts` ## Goal A candidate who forgot their password can set a new one through a @@ -31,17 +31,59 @@ single-use reset link. register/login: 10 requests per 15 minutes per client IP; the 11th → 429 `RATE_LIMITED`. +### #461 — deliver the link by email, never log the token (draft) +7. When `NODE_ENV=production`, forgot-password never writes the reset + token, the link, or the email address to any log. For a registered + email it logs only that a reset was requested, with the candidate id. +8. If the email exists, the system emails that address a plain-text + message (no HTML) containing `/reset-password?token=`, + sent with Nodemailer over SMTP (`SMTP_HOST`, `SMTP_PORT`, `SMTP_USER`, + `SMTP_PASS`), `From` = `MAIL_FROM`. The message is in the request's + `?lang=` language (`vi`/`en`, default as today). +9. The mail service is a single module that tests replace with a mock + (`jest.mock`); `npm test` makes no real SMTP connection. +10. The forgot-password response stays exactly as rule 1 (200, same + generic message) in every case, including a failed send. A failed + send is logged as an error without the token or link. +11. SMTP not configured: + - `NODE_ENV !== production` → the full link is logged to the console + as today, nothing is sent. + - `NODE_ENV=production` → a warning without the token is logged and + sending is skipped; the app still starts and the response is still + rule 1's 200. + ## Acceptance criteria - `npx jest src/__tests__/auth/auth.service.test.ts` passes. - forgot-password for a registered and an unregistered email → both HTTP 200 with identical `message`. - reset-password reusing the same token a second time → HTTP 400. +- (#461) `npx jest src/__tests__/auth/auth.service.test.ts` has a + forgot-password test that asserts the mocked mail service was called + exactly once with the registered email and a link containing the + token, and not called for an unregistered email. +- (#461) A test with `NODE_ENV=production` asserts no `logger` call + argument contains the reset token value (`'raw-token'` in the existing + fixture). +- (#461) A test with the mail mock rejecting → forgot-password still + resolves `{ success: true }` with the generic message, and the logged + error contains no token. +- (#461) A test with `NODE_ENV=production` and no `SMTP_HOST` → mail + service not called (or no-op), a `logger.warn` is called, no logger + argument contains the token. +- (#461) `npm run build` passes (typecheck incl. the new mail module). ## Edge cases - Token presented after 15 minutes → 400. - Redis down → token kept in process memory, lost on restart. +- (#461) Unregistered email → no mail sent, no token created, same 200. +- (#461) SMTP env missing → rule 11 (dev: log link; prod: warn, skip, 200). +- (#461) SMTP send error/timeout → rule 10 (200, error logged without token). +- (#461) `APP_URL` missing → open question Q9. +- (#461) `?lang=` absent or unsupported → same default language the API already uses for `t()` messages. ## Out of scope -- Sending real emails (stub logs the link). +- ~~Sending real emails (stub logs the link).~~ → in scope from #461. +- (#461) HTML email design, bounce/complaint handling, a mail queue/retry + worker, per-email resend throttling beyond the auth limit (#387). ## Open questions - A successful reset does not revoke existing sessions (no logout-all), so a stolen session survives a password change. Intended? → **Answer (operator 2026-11-07):** Change: reset revokes all sessions — #393 @@ -49,6 +91,18 @@ single-use reset link. - forgot-password has no per-email throttle beyond the global auth rate limit. Enough? → **Answer (operator 2026-11-07):** covered by #387 - With Redis, `consumeResetToken` does `GET` then `DEL` (not atomic, `utils/passwordReset.ts`), so two concurrent resets with the same token can both succeed — single-use is not guaranteed under concurrency (same pattern in `utils/emailVerification.ts`). Use `GETDEL`? → **Answer (operator 2026-11-07):** Bug — #385 +### #461 (answered by operator 2026-11-19, round 2) +- Q1. Provider? → **Answer:** Nodemailer over SMTP, configured by `SMTP_HOST`/`SMTP_PORT`/`SMTP_USER`/`SMTP_PASS` (provider-agnostic). +- Q2. Sender? → **Answer:** `From` from env `MAIL_FROM`. +- Q3. Link base URL? → **Answer:** env `APP_URL`; reset link = `APP_URL/reset-password?token=...`. +- Q4. Language/format? → **Answer:** follows request `?lang=` (vi/en); plain text only. +- Q5. Send failure? → **Answer:** still the generic 200; log the error without the token. +- Q6. Prod log on reset request? → **Answer:** candidate id only (no email/PII). +- Q7. No SMTP configured? → **Answer:** non-production → keep logging the full link to console as today; production → log a warning (no token), skip sending, do not fail startup. + +### #461 — left for the implementer (does not change Behavior) +- Q9. `APP_URL` unset while SMTP is set: not specified by the operator. Treat as rule 11 ("not configured" — dev logs the link, prod warns and skips) unless the operator says otherwise; implementer must not send a link without a base URL. + ## Changelog | Date | Change | Why | Node | |---|---|---|---| @@ -57,3 +111,5 @@ single-use reset link. | 2026-11-07 | Operator confirmed Behavior + answered all open questions; Status → verified | analyst backfill re-check, see `evidence/analyst/2026-11-07/auth-password-reset-spec.md` | - | | 2026-11-07 | Behavior 4: reset also revokes every session | operator answer #393 | reset-revokes-sessions | | 2026-11-08 | Behavior 6: auth limit 10/15 min shared with register/login | operator answer #387 | auth-credential-limit | +| 2026-11-19 | Rules 7–10 + criteria/edge cases/out-of-scope + Q1–Q7 for emailing the link and not logging the token (draft) | #461 | - | +| 2026-11-19 | Operator answered Q1–Q7; rules 7–11 made concrete (SMTP env, MAIL_FROM, APP_URL, lang, failure + no-SMTP handling) | #461 round 2 | - | diff --git a/agent-hub/doctrine/features/auth-register-login.md b/agent-hub/doctrine/features/auth-register-login.md index c74162c4..208c9127 100644 --- a/agent-hub/doctrine/features/auth-register-login.md +++ b/agent-hub/doctrine/features/auth-register-login.md @@ -1,8 +1,8 @@ # Register, login and email verification -- Status: verified — confirmed by operator 2026-11-07, see `evidence/analyst/2026-11-07/auth-register-login-spec.md` +- Status: verified — confirmed by operator 2026-11-07, see `evidence/analyst/2026-11-07/auth-register-login-spec.md` (rules 1–9); rules 10–11 draft for #461 - Source: backfill from code -- Issues: #385, #387, #389, #390 +- Issues: #385, #387, #389, #390, #461 - Anchors: `src/routers/api/v1/auth.route.ts`, `src/routers/api/v2/auth.route.ts`, `src/auth/auth.controller.ts`, `src/auth/auth.service.ts`, `src/auth/auth.validate.ts`, `src/utils/emailVerification.ts`, `src/utils/slug.ts`, `src/utils/authCookies.ts` ## Goal @@ -46,6 +46,16 @@ API tokens, and can confirm their email address. routes (`/refresh`, `/logout`, `/logout-all`, `/verify-email`) only have the global limit. +### #461 — email the verification link, never log the token (draft) +10. When `NODE_ENV=production`, register never writes the verification + token or link to any log. +11. On register, the new address is emailed a plain-text message with + `/verify-email?token=` (a frontend page that calls + `GET /api/v1/auth/verify-email`), through the same mail service, + SMTP/`MAIL_FROM`/`?lang=` rules, failure handling and no-SMTP + handling as `auth-password-reset` rules 8–11. Register's response + stays as rule 3 (201, `data: null`) even when the send fails. + ## Acceptance criteria - `npx jest src/__tests__/auth/auth.controller.test.ts` passes. - `npx jest src/__tests__/auth/auth.service.test.ts` passes. @@ -53,6 +63,9 @@ API tokens, and can confirm their email address. - Register twice with the same email → second response is HTTP 409. - `npx jest src/__tests__/auth/auth.validate.test.ts` passes (login accepts a short legacy password; register still rejects it). - Login with a wrong password and with an unknown email → both HTTP 401, identical `error.message`. +- (#461) `npx jest src/__tests__/auth/auth.service.test.ts` has a register test asserting the mocked mail service is called once with the new email and a link containing the verification token. +- (#461) A test with `NODE_ENV=production` asserts no `logger` call argument contains the verification token value. +- (#461) A register test with the mail mock rejecting → still `{ success: true }` (201 path). ## Edge cases - `repassword` missing or different → 400. @@ -60,7 +73,8 @@ API tokens, and can confirm their email address. - Redis down → tokens stored in process memory (lost on restart). ## Out of scope -- Actually sending emails (stub logs the link). +- ~~Actually sending emails (stub logs the link).~~ → in scope from #461. +- (#461) A re-send-verification endpoint (still out of scope, per the 2026-11-07 answer). - Blocking unverified accounts. ## Open questions @@ -72,6 +86,10 @@ API tokens, and can confirm their email address. - Login re-applies the register password rules, so an account whose password predates the current rules (e.g. < 12 chars) gets 400 and can never log in. Intended? → **Answer (operator 2026-11-07):** Bug: login should only require a non-empty password — #390 - The v2 auth router has no `authLimiter` (only v1 does); and since the global limiter (100/15 min) is stricter than `authLimiter` (150/15 min), the auth limiter never binds. Intended? → **Answer (operator 2026-11-07):** Bug — #387; limit (operator 2026-11-08): 10 / 15 min on login/register/forgot/reset, v1 + v2 +### #461 (answered by operator 2026-11-19, round 2) +- Q8. Verification link target? → **Answer:** frontend `APP_URL/verify-email?token=...`. +- Provider, sender, language, failure and no-SMTP handling: see `auth-password-reset.md` Q1–Q7 answers. + ## Changelog | Date | Change | Why | Node | |---|---|---|---| @@ -82,3 +100,5 @@ API tokens, and can confirm their email address. | 2026-11-07 | Behavior 5: GET /auth/login removed (POST only) | operator answer #389 | remove-get-login | | 2026-11-08 | Behavior 9: auth limit 10/15 min on credential routes, v1 + v2 | operator answer #387 | auth-credential-limit | | 2026-11-08 | Behavior 5: login password = non-empty string ≤ 128, strength rules on register/reset only | operator answer #390 | login-password-any-length | +| 2026-11-19 | Rules 10–11 + criteria + Q8: email the verification link, never log the token in prod (draft) | #461 | - | +| 2026-11-19 | Operator answered Q8 (frontend link); rule 11 made concrete; send failure keeps 201 | #461 round 2 | - | diff --git a/agent-hub/evidence/analyst/2026-11-19/password-reset-email-spec.md b/agent-hub/evidence/analyst/2026-11-19/password-reset-email-spec.md new file mode 100644 index 00000000..f7888e94 --- /dev/null +++ b/agent-hub/evidence/analyst/2026-11-19/password-reset-email-spec.md @@ -0,0 +1,47 @@ +# Analyst spec — #461 password reset / verify email by mail + +## Task (verbatim) +Title: Password reset / email verify: tokens are written to logs instead of being emailed +Body: +## Problem +`handlerForgotPassword` (`src/auth/auth.service.ts:139`) logs the full reset link including the token (`logger.info`). Anyone with log access (log files, Render log stream) can reset any account's password. Verify-email is the same stub. +## Proposal +1. Short term: never log the token when `NODE_ENV=production` (log only that a reset was requested). +2. Add a small mail service (provider TBD — Nodemailer/SMTP or a transactional API) and send the reset/verify links. +## Acceptance +- No token value appears in prod logs +- Mail service is mockable in tests; forgot-password test asserts a send call + +## Docs (updated, not new — existing INDEX rows match) +- `doctrine/features/auth-password-reset.md` — rules 7–10, criteria, edge cases, out of scope, Q1–Q7, changelog +- `doctrine/features/auth-register-login.md` — rules 10–11, criteria, Q8, changelog +- `doctrine/features/INDEX.md` — both rows: `#461 additions draft`, issue added +Rules 1–6 / 1–9 stay verified; only the #461 additions are draft. + +## Sources read +- `doctrine/domains/PROJECT.md`, `doctrine/MEMORY.md`, `doctrine/features/INDEX.md` +- `src/auth/auth.service.ts` (lines 55–80 register log at :71, 128–142 forgot-password log at :138) +- `src/__tests__/auth/auth.service.test.ts` (logger + passwordReset/emailVerification mocks, forgot-password tests :197–218) +- `src/routers/api/v1/auth.route.ts` (reset-password POST :223, verify-email GET :251) +- `src/config/process.config.ts` (NODE_ENV), `package.json` (no mail dependency), grep for a frontend/base-URL env var (none found) + +## Questions + answers (round 1 — all unanswered) +Q1 provider · Q2 sender/env var · Q3 link base URL + env var · Q4 language/format · Q5 send-failure response · Q6 prod log content · Q7 no-provider behavior (dev + prod) · Q8 verify link target (API vs frontend). Full text in the two docs. + +## Isolation proof +Spawned as a separate analyst subagent with only the issue text + bundle paths; no implementer reasoning, diff or plan was provided. Everything above came from files read in this spawn. + +## Round 2 — operator answers (2026-11-19, via coordinator, verbatim) +Q1: Nodemailer over SMTP (config via SMTP_HOST/SMTP_PORT/SMTP_USER/SMTP_PASS; provider-agnostic). +Q2: From address from env MAIL_FROM. +Q3: Frontend base URL from env APP_URL; reset link = APP_URL/reset-password?token=... +Q4: Language follows request ?lang= (vi/en); plain text only. +Q5: Send failure → still return the generic 200; log the error without the token. +Q6: Prod log on reset request: candidate id only (no email/PII). +Q7: Non-production with no SMTP configured → keep logging the full link to console as today. Production with no SMTP configured → log a warning (no token) and skip sending; do not fail startup. +Q8: Verification link → frontend APP_URL/verify-email?token=... + +Folded into both docs; Q1–Q8 closed. Residual note Q9 (`APP_URL` unset while SMTP set → treat as not configured) recorded as implementer guidance, does not change Behavior. Register send failure keeps 201 (derived from Q5, same principle). + +## Status +needs_input (round 1) → spec_ready (round 2) diff --git a/agent-hub/evidence/implementer/2026-11-19/email-auth-links-diff.md b/agent-hub/evidence/implementer/2026-11-19/email-auth-links-diff.md new file mode 100644 index 00000000..fcc2759f --- /dev/null +++ b/agent-hub/evidence/implementer/2026-11-19/email-auth-links-diff.md @@ -0,0 +1,107 @@ +# 2026-11-19 - email-auth-links (diff) +Worker: implementer · Version: 0.1.0 · Node: `haven/diagrams/dev-loop.prime-mermaid.md` → `email-auth-links` · Task: `/todo #461` (labels `enhancement`, `security`) · Branch: `feature/461-password-reset-email` (cut from `staging` @ 7e704be) +Plan: `evidence/implementer/2026-11-19/email-auth-links-plan.md` + +## Hub bytes before: 99127 + +## Feature doc: doctrine/features/auth-password-reset.md (rules 7–11), doctrine/features/auth-register-login.md (rules 10–11) +Written by the analyst pass 0 (`evidence/analyst/2026-11-19/password-reset-email-spec.md`), all open questions answered by the operator; Q9 (`APP_URL` unset with SMTP set → "not configured") and "register send failure → still 201" confirmed by the operator 2026-11-19 in the main session (AskUserQuestion). Implementation follows the doc; doc not edited by the implementer. + +## Diff +- `src/services/mail.ts` (new): `sendAuthLinkEmail(to, kind, path, lang)` — env read per call (`SMTP_HOST/PORT/USER/PASS`, `MAIL_FROM`, `APP_URL`, `NODE_ENV`). `SMTP_HOST` or `APP_URL` unset → production: `logger.warn` without link, no send; otherwise `logger.info` with the link (rule 11 / Q9). Else Nodemailer `createTransport` (`secure` iff port 465, 10s connection/greeting/socket timeouts, auth only if `SMTP_USER`) → `sendMail` plain `text` only, subject/body from `t('mail..*', lang)`, link = `APP_URL` (trailing `/` stripped) + path, inserted with a replacer function. Rejects on send failure. +- `src/auth/auth.service.ts`: local `emailAuthLink` = fire-and-forget `sendAuthLinkEmail(...).catch(logger.error(message only))`. `handlerRegister`: token log line → `emailAuthLink(email,'verifyEmail','/verify-email?token=…',lang)`. `handlerForgotPassword`: token log line → `logger.info('Reset requested for candidate ')` + `emailAuthLink(email,'resetPassword','/reset-password?token=…',lang)`. STUB comments removed/rewritten. +- `src/locales/vi.ts`, `src/locales/en.ts`: `mail.resetPassword|verifyEmail.{subject,body}` (body has `{link}`). +- `src/utils/passwordReset.ts`, `src/utils/emailVerification.ts`: stale "no email infra" header NOTE → one line pointing at `services/mail.ts`. +- `src/routers/api/v1/auth.route.ts`: two swagger `summary` lines no longer say "stub". +- Tests: `src/__tests__/auth/auth.service.test.ts` (mail module mocked, logger mock gains `warn`, `loggedText()`/`flushPromises()` helpers; register: send asserted + prod/no-token/failure test; forgot-password: send asserted with exact path + `en`, not sent for unknown email, prod logs only candidate id and never token/email, does not wait for send, failure → generic message + error log without token). New `src/__tests__/services/mail.test.ts` (nodemailer mocked: transport opts + plain text + lang + trailing slash; send failure rejects; prod with SMTP_HOST / APP_URL missing → warn once, no transport, no token; dev no SMTP → link logged). +- Deps: `nodemailer@^10.6.0`, dev `@types/nodemailer@^8.0.2`. First installed `nodemailer@6.10.1` → `npm audit` listed 22 advisories on `nodemailer <=10.1.3` (high) → upgraded to 10.6.0 (`engines node >=20`, CJS main) → `npm audit`: nodemailer clean. +- Docs: `.env.example` (SMTP_*, MAIL_FROM, APP_URL, empty values), root `CLAUDE.md` env block, `.claude/rules/api.md` (forgot/verify rows), `README.md` feature line. `.env.development`/`.env.production` not touched (hold real values). + +## Command +From `/Users/_david/Workspace/Project/resume/resume-nodejs-api` (copied from `doctrine/MEMORY.md`): +- `npx jest src/__tests__/auth/auth.service.test.ts src/__tests__/services/mail.test.ts` +- `npm test` +- `npm run build` (Typecheck = `inside Build`) +- `npm run lint`; touched files `npx eslint ` vs base (`git stash`) +- Red-before: `git stash push -- src/auth/auth.service.ts` → `npx jest src/__tests__/auth/auth.service.test.ts` → `git stash pop` + +## Output +Targeted (post-review): +``` + ✓ sends a plain-text email with the APP_URL link in the requested language (4 ms) + ✓ rejects when the SMTP send fails, so the caller decides how to handle it (4 ms) + ✓ in production with SMTP_HOST missing: warns without the token and sends nothing (1 ms) + ✓ in production with APP_URL missing: warns without the token and sends nothing + ✓ outside production with no SMTP configured: logs the full link instead of sending (1 ms) + ✓ should register successfully with new email (1 ms) + ✓ never logs the verification token in production and still succeeds when the email fails (1 ms) + ✓ creates a reset token and emails the link when the email exists + ✓ returns the same generic success message when the email does not exist (no user enumeration) (1 ms) + ✓ never logs the reset token in production, only the candidate id + ✓ responds without waiting for the SMTP send, so a registered email is not slower to answer + ✓ still returns the generic message when sending fails, logging the error without the token +Tests: 23 passed, 23 total +``` +Full: +``` +BUILD_EXIT=0 +Test Suites: 76 passed, 76 total +Tests: 801 passed, 801 total +✖ 273 problems (273 errors, 0 warnings) +``` +Touched files lint: `✖ 10 problems (10 errors, 0 warnings)`, all `10 @typescript-eslint/unbound-method` in `src/__tests__/auth/auth.service.test.ts`; base (stashed) same 2 files: `✖ 10 problems (10 errors, 0 warnings)`, same rule (`expect(CandidateModel.findOne)` pattern, pre-existing). New files 0. +Red-before (base `auth.service.ts`, new tests): +``` + ✕ should register successfully with new email (1 ms) + ✕ never logs the verification token in production and still succeeds when the email fails (1 ms) + ✕ creates a reset token and emails the link when the email exists + ✕ never logs the reset token in production, only the candidate id (1 ms) + ✕ still returns the generic message when sending fails, logging the error without the token (2 ms) +Tests: 5 failed, 13 passed, 18 total +``` +("responds without waiting" passes on base trivially — base sends nothing; it is red against the intermediate awaited version, which is what it guards.) + +## Acceptance +| Criterion | Evidence | +|---|---| +| reset: mail mock called once with registered email + link containing token; not for unregistered | `✓ creates a reset token and emails the link…` (`toHaveBeenCalledTimes(1)`, `('test@example.com','resetPassword','/reset-password?token=raw-token','en')`); `✓ returns the same generic…` (`not.toHaveBeenCalled`) | +| reset: prod → no logger arg contains `raw-token` | `✓ never logs the reset token in production, only the candidate id` (also no email address; info has `user_id`) | +| reset: mail rejects → generic success, error log without token | `✓ still returns the generic message when sending fails…` | +| reset: prod + no SMTP_HOST → no send, warn, no token | mail.test `✓ in production with SMTP_HOST missing…` (+ APP_URL missing, Q9) | +| register: mail called once with new email + link with token | `✓ should register successfully with new email` (`expect.stringContaining('verify-token')`, `'vi'`) | +| register: prod → no token in logs; mail rejects → still success | `✓ never logs the verification token in production and still succeeds when the email fails` | +| mail module mockable, no real SMTP in `npm test` | `jest.mock('@/services/mail')` / `jest.mock('nodemailer')`; full run 801 passed, no network | +| plain text only, `?lang=` language, `From`=`MAIL_FROM` | mail.test `✓ sends a plain-text email…` (subject `Reset your password` for `en`, `from`, `not.toHaveProperty('html')`) | +| dev no SMTP → link logged as today | mail.test `✓ outside production with no SMTP configured…` | +| `npm test` + `npm run build` green | `Tests: 801 passed`, `BUILD_EXIT=0` | +| lint ≤ 274, none new in touched files | `273`; touched before = after (10, same rule), new files 0 | +| comments per code-comments.md | `mail.ts`: file overview JSDoc + `/** */` on exported fn (WHY: never logs link in prod), `//` WHY on per-call env read and on timeouts; `auth.service.ts`: `/** */` WHY on `emailAuthLink` (timing + failure), rewritten register comment, STUB text removed; utils headers trimmed to 1 pointer line; tests: `//` WHY on `flushPromises` and trailing slash. No `(#N)` refs. | + +## Supersedes: none +`grep "#461"` on the active diagram → only this node. + +## Still open: none + +## Review +`/code-review medium` (forked; it could not run `git diff`, reviewed files directly) — 8 findings: +1. forgot-password awaited SMTP → registered emails slower (timing enumeration) → **fixed**: `emailAuthLink` is fire-and-forget; new test `✓ responds without waiting…`. +2. No SMTP timeouts → **fixed** (10s connection/greeting/socket). +3. register awaited SMTP → **fixed** by #1. +4. Link logged whenever `NODE_ENV !== 'production'` (staging with NODE_ENV unset would log live tokens) → per spec rule 11 (operator Q7 answer) → kept; `## Noticed, not done` #1. +5. `String.replace` `$`-pattern expansion → **fixed** (replacer function). +6. Trailing slash on `APP_URL` → **fixed** (stripped; asserted in mail.test). +7. Transport built per email → not done (sends off the request path, low volume) → Noticed #2. +8. Stale "no email infra" comments → **fixed** in `utils/passwordReset.ts`, `utils/emailVerification.ts`; `auth.forgotPasswordRequested` text ("has been generated") left — many tests pin the exact string, Noticed #3. +`/security-review` (issue labeled `security`, subagent on the working-tree diff): no finding ≥ 8. Closest (7): the same timing gap as #1 → fixed. Rejected candidates: tokens in prod logs (only dev fallback logs link; Nodemailer errors carry SMTP reply, not body), CRLF via `to` (Joi email + TLD allow-list, exact DB match), host injection (`APP_URL` env only), `lang` keys (fixed by `kind` union), STARTTLS not required on 587 (hardening) → Noticed #4; SMTP reject reply may quote the address in the error log → Noticed #5. +Step 5 re-run after fixes — Output above is the post-fix run. + +## Noticed, not done +1. Non-production fallback logs the live link for any `NODE_ENV` other than `production` (e.g. a staging deploy with SMTP unset). Per spec rule 11; if staging deploys exist, set `NODE_ENV=production` there or add SMTP. +2. One Nodemailer transport per send (new TCP/TLS each time). Cache it if volume grows. +3. `auth.forgotPasswordRequested` still says "link has been generated" / "đã được tạo" — could say "sent"; pinned by several tests. +4. `requireTLS` not set: on 587 a network attacker could strip STARTTLS and read the link. `requireTLS: true` would break plain local SMTP catchers (Mailpit) — operator call. +5. Nodemailer error messages can quote the recipient address (e.g. `550 rejected`) → `logger.error` in prod may contain an email address (no token). Rule 7 is about forgot-password's own log line; flag if strict. +6. `createResetToken` still runs only for registered emails (one Redis write) — pre-existing, small timing difference. + +## Seal gate +No outward-facing action (no commit/push). `npm install` (local deps) ran; `gh issue develop` (branch) ran as `/todo` Step 0. diff --git a/agent-hub/evidence/implementer/2026-11-19/email-auth-links-plan.md b/agent-hub/evidence/implementer/2026-11-19/email-auth-links-plan.md new file mode 100644 index 00000000..3ec1bf5f --- /dev/null +++ b/agent-hub/evidence/implementer/2026-11-19/email-auth-links-plan.md @@ -0,0 +1,20 @@ +# 2026-11-19 - email-auth-links (plan) +Worker: implementer · Version: 0.1.0 · Node: `haven/diagrams/dev-loop.prime-mermaid.md` → `email-auth-links` · Task: `/todo #461` "Password reset / email verify: tokens are written to logs instead of being emailed", labels `enhancement`, `security` + +## Hub bytes before: 99127 + +## Feature doc: doctrine/features/auth-password-reset.md (rules 7–11), doctrine/features/auth-register-login.md (rules 10–11) +Pass 0 analyst ran (spec mode, 2 rounds) → `spec_ready`, evidence `evidence/analyst/2026-11-19/password-reset-email-spec.md`. Q1–Q8 answered by operator. Analyst's two filled-in points confirmed by operator 2026-11-19 (AskUserQuestion, main session): register send failure → still 201; `APP_URL` unset while SMTP set → treated as "not configured" (Q9). No open question left. + +## Acceptance (node criteria) +1. auth-password-reset #461 criteria (forgot-password: mail mock called once with registered email + link containing token, not called for unregistered; prod → no logger arg contains `raw-token`; mail failure → still generic success, error log without token; prod + no SMTP_HOST → warn, no send, no token in logs). +2. auth-register-login #461 criteria (register: mail mock called once with new email + link with token; prod → no token in logs; mail failure → still `{ success: true }`). +3. `npx jest src/__tests__/auth/auth.service.test.ts src/__tests__/services/mail.test.ts` pass. +4. `npm test` + `npm run build` green (pre-existing local failures excepted, cited); `npm run lint` ≤ 274, none in touched files. + +## Anchors +- `src/auth/auth.service.ts:71` (verify link log), `:138` (reset link log), STUB comments `:50-67`, `:130-131`. +- `src/locales/vi.ts`, `src/locales/en.ts` (mail subject/body per lang). +- New `src/services/mail.ts`; tests `src/__tests__/auth/auth.service.test.ts`, new `src/__tests__/services/mail.test.ts`. +- New dep `nodemailer` (+ `@types/nodemailer` dev) — none present today. +- Env docs: `CLAUDE.md` env block, `.env.example`. diff --git a/agent-hub/evidence/verifier/2026-11-19/email-auth-links-seal.md b/agent-hub/evidence/verifier/2026-11-19/email-auth-links-seal.md new file mode 100644 index 00000000..361b71c2 --- /dev/null +++ b/agent-hub/evidence/verifier/2026-11-19/email-auth-links-seal.md @@ -0,0 +1,33 @@ +# 2026-11-19 - email-auth-links - verdict: SEAL +Worker: verifier · Node: `email-auth-links` (#461) · Notes: `evidence/implementer/2026-11-19/email-auth-links-plan.md`, `...-diff.md` + +## Isolation proof +Fresh Agent-tool subagent spawned by `/todo` pass 2, spawn=fresh, round 1; task string "agent-hub VERIFIER worker, a fresh independent pass (you never saw the implementer's session)". No prior context of the implement pass. + +## Re-run +none — audit-only: verbatim output, commands match `doctrine/MEMORY.md`, node is not outward-facing (no push/deploy; code only, no mail sent). + +## Criteria (each cited from the note) +- reset: mail mock called once with email + link containing token; not called for unregistered — `✓ creates a reset token and emails the link…`, `✓ returns the same generic…`. +- reset: prod → no logger arg has `raw-token` — `✓ never logs the reset token in production…`. +- reset: mail rejects → generic success, error log without token — `✓ still returns the generic message when sending fails…`. +- reset: prod + no SMTP_HOST → warn, no send, no token — mail.test `✓ in production with SMTP_HOST missing…` (+ APP_URL missing, Q9). +- register: mail called once with new email + token link; prod no token; failure → still success — `✓ should register successfully…`, `✓ never logs the verification token in production and still succeeds…`. +- Targeted jest 23 passed; `npm test` 801 passed / 76 suites; `npm run build` BUILD_EXIT=0 (Typecheck = inside Build, per MEMORY). +- Lint: 273 ≤ baseline 274 (cited); touched files 10 before = 10 after (same pre-existing `unbound-method`), new files 0. +- Red-before shown: 5 new tests fail on base `auth.service.ts`. +- Comments per code-comments.md: row present with touched comments cited; spot-read `src/services/mail.ts` (file overview, `/** */` WHY on export, `//` WHY on env read and timeouts) consistent. +- Feature doc line present (auth-password-reset 7–11, auth-register-login 10–11); doc unchanged by implementer, operator answers recorded (Q9, register 201). +- Review present: `/code-review medium` 8 findings each fixed or stated reason; `/security-review` run (issue labeled security), no finding >= 8. Noticed-not-done items listed. +- Supersedes none / Still open none; `grep "#461"` shows only this node. +- Seal gate: no outward-facing action; proportionality OK (mail module, 2 call sites, locales, tests, env docs, dep with audit upgrade to 10.6.0). + +## Forbidden states +None hit. Node exists on the diagram (PENDING, ratchet forward only); no code in `haven/`; evidence real; single SEAL verdict. + +## Non-blocking observations +- Feature docs still say "(draft)" and the edge case "`APP_URL` missing → open question Q9"; Q9 is answered (not configured). Analyst follow-up; doc Status left unchanged (rules 7–11 / 10–11 are a fix to an already verified doc, per recipe 11e only a `feat` implementing a `draft` doc flips status; these additions remain operator-confirmed drafts). +- Implementer's Noticed #1, #4, #5 (staging NODE_ENV, requireTLS, address in SMTP error log) are operator calls. + +## PM status +`email-auth-links` PENDING → SEALED, archived to `haven/diagrams/dev-loop-archive.md`. diff --git a/agent-hub/evidence/worker-runs.log b/agent-hub/evidence/worker-runs.log index abd49df5..7014de5d 100644 --- a/agent-hub/evidence/worker-runs.log +++ b/agent-hub/evidence/worker-runs.log @@ -3,3 +3,4 @@ 2026-11-18T09:00:21Z role=verifier outcome=SEAL node=hide-password-select-false rerun=none spawn=fresh hub_bytes_before=97857 hub_bytes_after=97851 2026-11-18T09:36:07Z role=verifier outcome=SEAL node=auth-http-integration-tests rerun=partial spawn=fresh hub_bytes_before=97851 hub_bytes_after=97855 2026-11-18T09:50:12Z role=verifier outcome=SEAL node=fix-access-token-jti rerun=none spawn=fresh hub_bytes_before=98675 hub_bytes_after=97846 +2026-11-19T09:52:11Z role=verifier outcome=SEAL node=email-auth-links rerun=none spawn=fresh hub_bytes_before=99127 hub_bytes_after=99105 diff --git a/agent-hub/haven/diagrams/dev-loop-archive.md b/agent-hub/haven/diagrams/dev-loop-archive.md index 06ac3847..076fffe4 100644 --- a/agent-hub/haven/diagrams/dev-loop-archive.md +++ b/agent-hub/haven/diagrams/dev-loop-archive.md @@ -190,3 +190,5 @@ | `hide-password-select-false` | SEALED | GitHub issue #459. `src/models/candidate.model.ts:25` — `password` returned by default, every query must remember `.select('-password')` (#152 regressed exactly this). Fix: `select: false` on the schema; opt in with `.select('+password')` only where the hash is compared (`auth.service.ts` `handlerLogin`; reset writes via `updateOne`, needs no read). Acceptance: (1) login reads the hash via `+password` — `npx jest src/__tests__/auth/auth.service.test.ts` green; (2) new test: a plain `CandidateModel.findById()` query sends a projection excluding `password` — `npx jest src/__tests__/models/candidatePassword.test.ts` green; (3) `npm test` + `npm run build` green, lint ≤ baseline with none in changed files. SEALED 2026-11-18 after independent verifier pass (audit-only, no re-run). Evidence: `evidence/implementer/2026-11-18/hide-password-select-false.md`, `evidence/verifier/2026-11-18/hide-password-select-false-seal.md`. | | `auth-http-integration-tests` | SEALED | #463 — HTTP-level supertest + mongodb-memory-server tests over the real `runServer` middleware chain (`src/server.ts`, app factored into an exported `createApp()`): register→login→GET→refresh→logout (token rejected after); rotated refresh reuse >10s revokes all sessions; cookie-only POST without CSRF → 403; client `candidateId` ignored (IDOR); unknown route → 404 standard error shape; Redis absent (in-memory fallback). Accept: `npx jest src/__tests__/integration/auth.http.test.ts` + `npm test` + `npm run build` green; lint ≤ 274 baseline, none in changed files. SEALED 2026-11-18 after independent verifier pass (partial re-run: eslint on changed files). Evidence: `evidence/implementer/2026-11-18/auth-http-integration-tests-diff.md`, `evidence/verifier/2026-11-18/auth-http-integration-tests-seal.md`. | | `fix-access-token-jti` | SEALED | #490 — access tokens are signed with `{ _id }` only (`src/auth/auth.service.ts` `handlerLogin`, `src/auth/auth.controller.ts` `authRefreshToken`), so two issued for one candidate in the same second are byte-identical and logout on one session blacklists the other (found by #463 integration tests). Fix (root cause, shared signer): `src/utils/jwt.ts` `jwtSign` sets `jwtid: crypto.randomUUID()` on every token; callers stop adding their own refresh `jti`. Accept: (1) two same-second logins → different access tokens, logout one → the other still 200 on a protected GET (`npx jest src/__tests__/integration/auth.http.test.ts`); (2) `jwtSign` unit test: same payload, same second → different tokens with distinct `jti` (`npx jest src/__tests__/utils/jwt.test.ts`), and the auth unit tests still pass (`npx jest src/__tests__/auth`); (3) `npm test` + `npm run build` green; lint ≤ 274, none new in changed files. | + +| `email-auth-links` | SEALED | #461 — reset (`handlerForgotPassword`) and verify (`handlerRegister`) links are logged with the token (`src/auth/auth.service.ts:71`, `:138`) instead of emailed. Fix: Nodemailer SMTP mail module (`src/services/mail.ts`, mocked in tests); prod logs never carry the token. Acceptance = `features/auth-password-reset.md` #461 criteria + `features/auth-register-login.md` #461 criteria; `npm test` + `npm run build` green; `npm run lint` ≤ 274, none in touched files. Plan: `evidence/implementer/2026-11-19/email-auth-links-plan.md`. | diff --git a/agent-hub/haven/diagrams/dev-loop.prime-mermaid.md b/agent-hub/haven/diagrams/dev-loop.prime-mermaid.md index fcf8d58a..c6133587 100644 --- a/agent-hub/haven/diagrams/dev-loop.prime-mermaid.md +++ b/agent-hub/haven/diagrams/dev-loop.prime-mermaid.md @@ -59,7 +59,6 @@ flowchart TD | Node | State | Notes | |---|---|---| -| `logout-refresh-token-header` | SEALED | 2026-11-17 — archived, see `haven/diagrams/dev-loop-archive.md`. Evidence: `evidence/verifier/2026-11-17/logout-refresh-token-header-seal.md`. | | `fix-candidate-password-leak` | PENDING | `src/candidate/candidate.service.ts` — `handlerGetInformationByEmail` has no `.select()` at all; `handlerGetInformationById` double-wraps `whitelistSelect([select])`, making the select a permanent no-op. Result: `GET /api/v1/candidate/:email` and `PUT/PATCH /candidate/update` return the raw bcrypt password hash in the response. | | `fix-refresh-token-expiry-unused` | PENDING | `TOKEN_EXP_IN` (`.env`, already exported in config) is never used at any `jwtSign()` call site (`auth.service.ts`, `auth.controller.ts`, `api/v1/auth/services/login.ts`) — access and refresh tokens always share the same default 1h expiry, so the refresh token is pointless. | | `ci-lint-ratchet` | SEALED | 2026-11-16 — archived, see `haven/diagrams/dev-loop-archive.md`. Evidence: `evidence/verifier/2026-11-16/ci-lint-ratchet-seal.md`. | @@ -81,3 +80,4 @@ flowchart TD | `hide-password-select-false` | SEALED | 2026-11-18 — archived, see `haven/diagrams/dev-loop-archive.md`. Evidence: `evidence/verifier/2026-11-18/hide-password-select-false-seal.md`. | | `auth-http-integration-tests` | SEALED | 2026-11-18 — archived, see `haven/diagrams/dev-loop-archive.md`. Evidence: `evidence/verifier/2026-11-18/auth-http-integration-tests-seal.md`. | | `fix-access-token-jti` | SEALED | 2026-11-18 — archived, see `haven/diagrams/dev-loop-archive.md`. Evidence: `evidence/verifier/2026-11-18/fix-access-token-jti-seal.md`. | +| `email-auth-links` | SEALED | 2026-11-19 — archived, see `haven/diagrams/dev-loop-archive.md`. Evidence: `evidence/verifier/2026-11-19/email-auth-links-seal.md`. | diff --git a/package-lock.json b/package-lock.json index f0081410..3c7b2216 100644 --- a/package-lock.json +++ b/package-lock.json @@ -26,6 +26,7 @@ "module-alias": "^2.2.3", "mongoose": "^8.4.0", "multer": "^2.3.0", + "nodemailer": "^10.6.0", "pdf-lib": "^1.17.1", "pdf-parse": "^1.1.4", "puppeteer": "^22.13.1", @@ -47,6 +48,7 @@ "@types/jsonwebtoken": "^9.0.6", "@types/multer": "^2.2.0", "@types/node": "^20.14.12", + "@types/nodemailer": "^8.0.2", "@types/pdf-parse": "^1.1.5", "@types/supertest": "^7.2.1", "@types/swagger-jsdoc": "^6.0.4", @@ -2008,6 +2010,16 @@ "undici-types": "~6.19.2" } }, + "node_modules/@types/nodemailer": { + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/@types/nodemailer/-/nodemailer-8.0.2.tgz", + "integrity": "sha512-c7M5ox8p0nEOfbJ2E9Qcmt8/QCu/VzsiAhzBiZbvky2PhKZDHpKB3sQHBM5MEZNkCfBOaS6S9//AGPRTNB7IaA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@types/pdf-parse": { "version": "1.1.5", "resolved": "https://registry.npmjs.org/@types/pdf-parse/-/pdf-parse-1.1.5.tgz", @@ -7520,6 +7532,15 @@ "dev": true, "license": "MIT" }, + "node_modules/nodemailer": { + "version": "10.6.0", + "resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-10.6.0.tgz", + "integrity": "sha512-jWanL7D9GD3jvUDYKmoC5rWTiG8MnBgnN2yV68bgMKip1zUJhiSTyz7Eg+18y8sk5OvdVDzws5nZK5arSI4f5Q==", + "license": "MIT-0", + "engines": { + "node": ">=20.0.0" + } + }, "node_modules/nodemon": { "version": "3.1.7", "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.1.7.tgz", diff --git a/package.json b/package.json index 809f6cfb..440fdffb 100644 --- a/package.json +++ b/package.json @@ -45,6 +45,7 @@ "module-alias": "^2.2.3", "mongoose": "^8.4.0", "multer": "^2.3.0", + "nodemailer": "^10.6.0", "pdf-lib": "^1.17.1", "pdf-parse": "^1.1.4", "puppeteer": "^22.13.1", @@ -66,6 +67,7 @@ "@types/jsonwebtoken": "^9.0.6", "@types/multer": "^2.2.0", "@types/node": "^20.14.12", + "@types/nodemailer": "^8.0.2", "@types/pdf-parse": "^1.1.5", "@types/supertest": "^7.2.1", "@types/swagger-jsdoc": "^6.0.4", diff --git a/src/__tests__/auth/auth.service.test.ts b/src/__tests__/auth/auth.service.test.ts index ebf0e2bc..386a5f61 100644 --- a/src/__tests__/auth/auth.service.test.ts +++ b/src/__tests__/auth/auth.service.test.ts @@ -10,6 +10,8 @@ import { createResetToken, consumeResetToken } from '@/utils/passwordReset'; import { createVerificationToken, consumeVerificationToken } from '@/utils/emailVerification'; import { invalidateAllSessions } from '@/utils/sessionRevocation'; import { ErrorCode } from '@/errors'; +import { sendAuthLinkEmail } from '@/services/mail'; +import { logger } from '@/logger'; // Mock modules jest.mock('@/models/candidate.model'); @@ -30,12 +32,20 @@ jest.mock('@/utils/emailVerification', () => ({ })); jest.mock('@/utils/sessionRevocation', () => ({ invalidateAllSessions: jest.fn().mockResolvedValue(true) })); jest.mock('@/logger', () => ({ - logger: { info: jest.fn(), error: jest.fn() }, + logger: { info: jest.fn(), warn: jest.fn(), error: jest.fn() }, })); +jest.mock('@/services/mail', () => ({ sendAuthLinkEmail: jest.fn().mockResolvedValue(undefined) })); + +// The send is fire-and-forget; let its .catch handler run before asserting on logs. +const flushPromises = () => new Promise((resolve) => setImmediate(resolve)); + +const loggedText = () => + [logger.info, logger.warn, logger.error].flatMap((fn) => (fn as jest.Mock).mock.calls.flat().map((arg) => JSON.stringify(arg))).join('\n'); describe('auth.service', () => { beforeEach(() => { jest.clearAllMocks(); + (createVerificationToken as jest.Mock).mockResolvedValue('verify-token'); }); describe('isEmailAlreadyExists', () => { @@ -90,11 +100,34 @@ describe('auth.service', () => { slug: expect.stringMatching(/^new-[a-z0-9]+$/), }); expect(CandidateModel.findOne).toHaveBeenNthCalledWith(3, { email: 'new@example.com' }); - // issue #71 — a verification token is created (stub: logged, not emailed) expect(createVerificationToken).toHaveBeenCalledWith('new_id'); + expect(sendAuthLinkEmail).toHaveBeenCalledTimes(1); + expect(sendAuthLinkEmail).toHaveBeenCalledWith('new@example.com', 'verifyEmail', expect.stringContaining('verify-token'), 'vi'); expect(result).toEqual({ success: true, message: 'Đăng ký thành công' }); }); + it('never logs the verification token in production and still succeeds when the email fails', async () => { + const prevEnv = process.env['NODE_ENV']; + process.env['NODE_ENV'] = 'production'; + (CandidateModel.findOne as jest.Mock) + .mockResolvedValueOnce(null) + .mockReturnValueOnce({ select: () => ({ exec: () => Promise.resolve(null) }) }) + .mockResolvedValueOnce({ _id: 'new_id', email: 'new@example.com' }); + (CandidateModel.create as jest.Mock).mockResolvedValue({ _id: null, email: 'new@example.com' }); + (sendAuthLinkEmail as jest.Mock).mockRejectedValueOnce(new Error('smtp down')); + + try { + const result = await handlerRegister({ email: 'new@example.com', password: 'pass123' }); + await flushPromises(); + + expect(result).toEqual({ success: true, message: 'Đăng ký thành công' }); + expect(logger.error).toHaveBeenCalledWith(expect.stringContaining('smtp down')); + expect(loggedText()).not.toContain('verify-token'); + } finally { + process.env['NODE_ENV'] = prevEnv; + } + }); + it('should fail if email already exists', async () => { (CandidateModel.findOne as jest.Mock).mockResolvedValue({ email: 'existing@example.com' }); @@ -195,16 +228,21 @@ describe('auth.service', () => { }); describe('handlerForgotPassword', () => { - it('creates a reset token when the email exists', async () => { - const mockUser = { _id: { toString: () => 'user_id' }, email: 'test@example.com' }; - (CandidateModel.findOne as jest.Mock).mockResolvedValue(mockUser); + const GENERIC = { success: true, message: 'Nếu email tồn tại, liên kết đặt lại mật khẩu đã được tạo' }; + + beforeEach(() => { + (CandidateModel.findOne as jest.Mock).mockResolvedValue({ _id: { toString: () => 'user_id' }, email: 'test@example.com' }); (createResetToken as jest.Mock).mockResolvedValue('raw-token'); + }); - const result = await handlerForgotPassword('test@example.com'); + it('creates a reset token and emails the link when the email exists', async () => { + const result = await handlerForgotPassword('test@example.com', 'en'); expect(CandidateModel.findOne).toHaveBeenCalledWith({ email: 'test@example.com' }); expect(createResetToken).toHaveBeenCalledWith('user_id'); - expect(result).toEqual({ success: true, message: 'Nếu email tồn tại, liên kết đặt lại mật khẩu đã được tạo' }); + expect(sendAuthLinkEmail).toHaveBeenCalledTimes(1); + expect(sendAuthLinkEmail).toHaveBeenCalledWith('test@example.com', 'resetPassword', '/reset-password?token=raw-token', 'en'); + expect(result).toEqual({ success: true, message: 'If the email exists, a password reset link has been generated' }); }); it('returns the same generic success message when the email does not exist (no user enumeration)', async () => { @@ -213,7 +251,39 @@ describe('auth.service', () => { const result = await handlerForgotPassword('nonexistent@example.com'); expect(createResetToken).not.toHaveBeenCalled(); - expect(result).toEqual({ success: true, message: 'Nếu email tồn tại, liên kết đặt lại mật khẩu đã được tạo' }); + expect(sendAuthLinkEmail).not.toHaveBeenCalled(); + expect(result).toEqual(GENERIC); + }); + + it('never logs the reset token in production, only the candidate id', async () => { + const prevEnv = process.env['NODE_ENV']; + process.env['NODE_ENV'] = 'production'; + try { + await handlerForgotPassword('test@example.com'); + + expect(logger.info).toHaveBeenCalledWith(expect.stringContaining('user_id')); + expect(loggedText()).not.toContain('raw-token'); + expect(loggedText()).not.toContain('test@example.com'); + } finally { + process.env['NODE_ENV'] = prevEnv; + } + }); + + it('responds without waiting for the SMTP send, so a registered email is not slower to answer', async () => { + (sendAuthLinkEmail as jest.Mock).mockReturnValueOnce(new Promise(() => undefined)); + + await expect(handlerForgotPassword('test@example.com')).resolves.toEqual(GENERIC); + }); + + it('still returns the generic message when sending fails, logging the error without the token', async () => { + (sendAuthLinkEmail as jest.Mock).mockRejectedValueOnce(new Error('smtp timeout')); + + const result = await handlerForgotPassword('test@example.com'); + await flushPromises(); + + expect(result).toEqual(GENERIC); + expect(logger.error).toHaveBeenCalledWith(expect.stringContaining('smtp timeout')); + expect(loggedText()).not.toContain('raw-token'); }); }); diff --git a/src/__tests__/services/mail.test.ts b/src/__tests__/services/mail.test.ts new file mode 100644 index 00000000..e607f3f3 --- /dev/null +++ b/src/__tests__/services/mail.test.ts @@ -0,0 +1,81 @@ +/** + * Tests for services/mail.ts — nodemailer is mocked, no real SMTP connection. + */ + +import { createTransport } from 'nodemailer'; +import { sendAuthLinkEmail } from '@/services/mail'; +import { logger } from '@/logger'; + +const sendMail = jest.fn().mockResolvedValue({}); +jest.mock('nodemailer', () => ({ createTransport: jest.fn(() => ({ sendMail })) })); +jest.mock('@/logger', () => ({ logger: { info: jest.fn(), warn: jest.fn(), error: jest.fn() } })); + +const PATH = '/reset-password?token=raw-token'; +const MAIL_ENV = ['NODE_ENV', 'SMTP_HOST', 'SMTP_PORT', 'SMTP_USER', 'SMTP_PASS', 'MAIL_FROM', 'APP_URL'] as const; + +const loggedText = () => + [logger.info, logger.warn, logger.error].flatMap((fn) => (fn as jest.Mock).mock.calls.flat().map((arg) => JSON.stringify(arg))).join('\n'); + +describe('sendAuthLinkEmail', () => { + const saved = Object.fromEntries(MAIL_ENV.map((key) => [key, process.env[key]])); + + beforeEach(() => { + jest.clearAllMocks(); + MAIL_ENV.forEach((key) => delete process.env[key]); + }); + + afterAll(() => { + MAIL_ENV.forEach((key) => { + const value = saved[key]; + if (value === undefined) delete process.env[key]; + else process.env[key] = value; + }); + }); + + it('sends a plain-text email with the APP_URL link in the requested language', async () => { + Object.assign(process.env, { SMTP_HOST: 'smtp.test', SMTP_PORT: '465', SMTP_USER: 'u', SMTP_PASS: 'p', MAIL_FROM: 'Resume ', APP_URL: 'https://app.test/' }); + + await sendAuthLinkEmail('a@test.com', 'resetPassword', PATH, 'en'); + + expect(createTransport).toHaveBeenCalledWith( + expect.objectContaining({ host: 'smtp.test', port: 465, secure: true, auth: { user: 'u', pass: 'p' }, socketTimeout: 10_000 }), + ); + expect(sendMail).toHaveBeenCalledWith({ + from: 'Resume ', + to: 'a@test.com', + subject: 'Reset your password', + // Trailing slash on APP_URL dropped, so the frontend route still matches. + text: expect.stringContaining(`\nhttps://app.test${PATH}\n`), + }); + expect(sendMail.mock.calls[0][0]).not.toHaveProperty('html'); + }); + + it('rejects when the SMTP send fails, so the caller decides how to handle it', async () => { + Object.assign(process.env, { SMTP_HOST: 'smtp.test', APP_URL: 'https://app.test' }); + sendMail.mockRejectedValueOnce(new Error('smtp down')); + + await expect(sendAuthLinkEmail('a@test.com', 'verifyEmail', PATH)).rejects.toThrow('smtp down'); + }); + + it.each([ + ['SMTP_HOST missing', { APP_URL: 'https://app.test' }], + ['APP_URL missing', { SMTP_HOST: 'smtp.test' }], + ])('in production with %s: warns without the token and sends nothing', async (_label, env) => { + Object.assign(process.env, { NODE_ENV: 'production', ...env }); + + await sendAuthLinkEmail('a@test.com', 'resetPassword', PATH); + + expect(createTransport).not.toHaveBeenCalled(); + expect(logger.warn).toHaveBeenCalledTimes(1); + expect(loggedText()).not.toContain('raw-token'); + }); + + it('outside production with no SMTP configured: logs the full link instead of sending', async () => { + Object.assign(process.env, { NODE_ENV: 'development' }); + + await sendAuthLinkEmail('a@test.com', 'resetPassword', PATH); + + expect(createTransport).not.toHaveBeenCalled(); + expect(logger.info).toHaveBeenCalledWith(expect.stringContaining(PATH)); + }); +}); diff --git a/src/auth/auth.service.ts b/src/auth/auth.service.ts index a7fe4782..54f127b9 100644 --- a/src/auth/auth.service.ts +++ b/src/auth/auth.service.ts @@ -11,6 +11,7 @@ import { createResetToken, consumeResetToken } from '@/utils/passwordReset'; import { invalidateAllSessions } from '@/utils/sessionRevocation'; import { createVerificationToken, consumeVerificationToken } from '@/utils/emailVerification'; import { generateUniqueCandidateSlug } from '@/utils/slug'; +import { sendAuthLinkEmail, AuthMailKind } from '@/services/mail'; import { logger } from '@/logger'; import { AppError, BadRequestError, ErrorCode, InvalidCredentialsError } from '@/errors'; @@ -20,6 +21,18 @@ interface Auth { repassword?: string; } +/** + * Fire-and-forget: awaiting the SMTP round-trip would make a registered + * email answer measurably slower than an unknown one, and a failed send must + * not change the response either — so it is only logged, by message alone, + * since the mail options carry the token. + */ +const emailAuthLink = (email: string, kind: AuthMailKind, path: string, lang: string): void => { + sendAuthLinkEmail(email, kind, path, lang).catch((err: unknown) => { + logger.error(`[mail] ${kind} email failed: ${err instanceof Error ? err.message : String(err)}`); + }); +}; + export const isEmailAlreadyExists = async (email: string) => { const find = await CandidateModel.findOne({ email }); return !!find; @@ -48,11 +61,8 @@ export const handlerRegister = async (item: Auth, lang: string = DEFAULT_LANG) = }); /** - * STUB: no email-sending infra exists yet — log the verification link - * instead of emailing it. Does NOT block - * registration or login (product decision, operator-confirmed via - * AskUserQuestion): `emailVerified` stays false until this link is - * visited, but the account is usable immediately either way. + * Verification is not required to log in: `emailVerified` stays false + * until the emailed link is visited, but the account is usable at once. * * Re-fetch by email instead of using CandidateModel.create()'s own * return value — passing `_id: null` explicitly (as above) makes @@ -68,7 +78,7 @@ export const handlerRegister = async (item: Auth, lang: string = DEFAULT_LANG) = const savedDocument = await CandidateModel.findOne({ email }); if (savedDocument && savedDocument._id) { const verifyToken = await createVerificationToken(savedDocument._id.toString()); - logger.info(`[emailVerification] Verification link for ${email}: /verify-email?token=${verifyToken}`); + emailAuthLink(email, 'verifyEmail', `/verify-email?token=${verifyToken}`, lang); } return { success: true, message: t('auth.registerSuccess', lang) }; @@ -126,16 +136,15 @@ export const handlerLogin = async (data: Auth, lang: string = DEFAULT_LANG) => { * * Luôn trả về message chung chung dù email có tồn tại hay không, để * tránh lộ thông tin email nào đã đăng ký (user enumeration). - * - * STUB: chưa có hạ tầng gửi email trong project — log link reset thay vì - * gửi email thật. Thay bằng mailer thật khi chọn được provider. */ export const handlerForgotPassword = async (email: string, lang: string = DEFAULT_LANG) => { const user = await CandidateModel.findOne({ email }); if (user && user._id) { - const token = await createResetToken(user._id.toString()); - logger.info(`[passwordReset] Reset link for ${email}: /reset-password?token=${token}`); + const candidateId = user._id.toString(); + const token = await createResetToken(candidateId); + logger.info(`[passwordReset] Reset requested for candidate ${candidateId}`); + emailAuthLink(email, 'resetPassword', `/reset-password?token=${token}`, lang); } return { success: true, message: t('auth.forgotPasswordRequested', lang) }; diff --git a/src/locales/en.ts b/src/locales/en.ts index 1bbf43cd..d8055589 100644 --- a/src/locales/en.ts +++ b/src/locales/en.ts @@ -31,6 +31,16 @@ export default { tokenExpired: 'Token has expired', invalidToken: 'Invalid token', }, + mail: { + resetPassword: { + subject: 'Reset your password', + body: 'Open this link to reset your password (expires in 15 minutes):\n{link}\n\nIf you did not request this, ignore this email.', + }, + verifyEmail: { + subject: 'Verify your email', + body: 'Open this link to verify your email (expires in 24 hours):\n{link}\n\nIf you did not create an account, ignore this email.', + }, + }, validation: { hasErrors: 'Validation has errors', invalidSchema: 'Invalid schema', diff --git a/src/locales/vi.ts b/src/locales/vi.ts index 8caee3d0..ed90b5f6 100644 --- a/src/locales/vi.ts +++ b/src/locales/vi.ts @@ -31,6 +31,16 @@ export default { tokenExpired: 'Token đã hết hạn', invalidToken: 'Token không hợp lệ', }, + mail: { + resetPassword: { + subject: 'Đặt lại mật khẩu', + body: 'Mở liên kết sau để đặt lại mật khẩu (hết hạn sau 15 phút):\n{link}\n\nNếu bạn không yêu cầu, hãy bỏ qua email này.', + }, + verifyEmail: { + subject: 'Xác thực email', + body: 'Mở liên kết sau để xác thực email của bạn (hết hạn sau 24 giờ):\n{link}\n\nNếu bạn không đăng ký tài khoản, hãy bỏ qua email này.', + }, + }, validation: { hasErrors: 'Dữ liệu không hợp lệ', invalidSchema: 'Schema không hợp lệ', diff --git a/src/routers/api/v1/auth.route.ts b/src/routers/api/v1/auth.route.ts index 935d9815..5b82d5e0 100644 --- a/src/routers/api/v1/auth.route.ts +++ b/src/routers/api/v1/auth.route.ts @@ -165,7 +165,7 @@ router.post('/refresh', verifyCsrf('refreshToken'), asyncHandler(authRefreshToke * /api/v1/auth/forgot-password: * post: * tags: [Auth] - * summary: Request a password reset (stub — no email is actually sent yet) + * summary: Request a password reset (the link is emailed if the address is registered) * requestBody: * required: true * content: @@ -227,7 +227,7 @@ router.post('/reset-password', authLimiter, asyncHandler(authResetPassword)); * /api/v1/auth/verify-email: * get: * tags: [Auth] - * summary: Verify a candidate's email using the token sent (stub — logged, not emailed) on register + * summary: Verify a candidate's email using the token emailed on register * parameters: * - in: query * name: token diff --git a/src/services/mail.ts b/src/services/mail.ts new file mode 100644 index 00000000..52f33953 --- /dev/null +++ b/src/services/mail.ts @@ -0,0 +1,49 @@ +/** + * Transactional email over SMTP (Nodemailer), configured by SMTP_HOST, + * SMTP_PORT, SMTP_USER, SMTP_PASS, MAIL_FROM and APP_URL (the frontend + * base URL the links point to). + * + * @author Đạt Võ + * @see https://github.com/datvt243 + */ + +import { createTransport } from 'nodemailer'; +import { logger } from '@/logger'; +import { t, DEFAULT_LANG } from '@/utils/i18n'; + +export type AuthMailKind = 'resetPassword' | 'verifyEmail'; + +/** + * Emails `` to `to` as plain text; rejects if the SMTP send + * fails. Without SMTP_HOST or APP_URL nothing is sent: outside production + * the link is logged so local dev still works; production logs only a + * warning, since the link carries a live token. + */ +export const sendAuthLinkEmail = async (to: string, kind: AuthMailKind, path: string, lang: string = DEFAULT_LANG): Promise => { + // Read per call, not at import, so tests can switch env between cases. + const { NODE_ENV, SMTP_HOST, SMTP_PORT, SMTP_USER, SMTP_PASS, MAIL_FROM, APP_URL } = process.env; + + if (!SMTP_HOST || !APP_URL) { + if (NODE_ENV === 'production') logger.warn(`[mail] SMTP_HOST or APP_URL not set, ${kind} email not sent`); + else logger.info(`[mail] ${kind} link for ${to}: ${APP_URL ?? ''}${path}`); + return; + } + + const port = Number(SMTP_PORT) || 587; + const link = `${APP_URL.replace(/\/+$/, '')}${path}`; + await createTransport({ + host: SMTP_HOST, + port, + secure: port === 465, + // Nodemailer's defaults (2 min connect, 10 min socket) would keep a dead SMTP host's sends pending for minutes. + connectionTimeout: 10_000, + greetingTimeout: 10_000, + socketTimeout: 10_000, + ...(SMTP_USER && { auth: { user: SMTP_USER, pass: SMTP_PASS ?? '' } }), + }).sendMail({ + ...(MAIL_FROM && { from: MAIL_FROM }), + to, + subject: t(`mail.${kind}.subject`, lang), + text: t(`mail.${kind}.body`, lang).replace('{link}', () => link), + }); +}; diff --git a/src/utils/emailVerification.ts b/src/utils/emailVerification.ts index 27d8e984..3ef1cdb2 100644 --- a/src/utils/emailVerification.ts +++ b/src/utils/emailVerification.ts @@ -3,9 +3,7 @@ * Redis-with-in-memory-fallback pattern as utils/passwordReset.ts / * utils/tokenBlacklist.ts. * - * NOTE: no email-sending infra exists in this project yet. The - * verification link is logged instead of emailed, a stand-in until a - * mail provider is chosen. See auth.service.ts's handlerRegister. + * The link is emailed by services/mail.ts (see auth.service.ts). * * @author Đạt Võ * @see https://github.com/datvt243 diff --git a/src/utils/passwordReset.ts b/src/utils/passwordReset.ts index faba3189..9f365073 100644 --- a/src/utils/passwordReset.ts +++ b/src/utils/passwordReset.ts @@ -2,9 +2,7 @@ * Single-use, short-lived password reset tokens. Same * Redis-with-in-memory-fallback TTL pattern as utils/tokenBlacklist.ts. * - * NOTE: no email-sending infra exists in this project yet. The reset - * link is logged instead of emailed — a stand-in until a mail provider - * is chosen. See auth.service.ts's handlerForgotPassword. + * The link is emailed by services/mail.ts (see auth.service.ts). * * @author Đạt Võ * @see https://github.com/datvt243 From 703572357ec46bf7bd64819a7b8c7c5bafd86713 Mon Sep 17 00:00:00 2001 From: _david Date: Thu, 19 Nov 2026 17:40:29 +0700 Subject: [PATCH 6/7] chore(agent-hub): ship note for email-auth-links Co-Authored-By: Claude Opus 5.5 --- .../ship/2026-11-19/email-auth-links-ship.md | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 agent-hub/evidence/ship/2026-11-19/email-auth-links-ship.md diff --git a/agent-hub/evidence/ship/2026-11-19/email-auth-links-ship.md b/agent-hub/evidence/ship/2026-11-19/email-auth-links-ship.md new file mode 100644 index 00000000..ec2ff776 --- /dev/null +++ b/agent-hub/evidence/ship/2026-11-19/email-auth-links-ship.md @@ -0,0 +1,76 @@ +# Ship — email-auth-links +- Node: `email-auth-links` (SEALED, `agent-hub/evidence/verifier/2026-11-19/email-auth-links-seal.md`) · Branch: `feature/461-password-reset-email` · Remote: `https://github.com/datvt243/resume-nodejs-api.git` + +## Commands +- `git commit -m "feat(auth): email reset/verify links over SMTP instead of logging tokens + +Reset and verification links carried live tokens in logger.info, so anyone with log access could take over an account. + +- src/services/mail.ts (new): sendAuthLinkEmail via Nodemailer SMTP (SMTP_HOST/PORT/USER/PASS, MAIL_FROM, APP_URL), plain text in the ?lang= language, 10s SMTP timeouts; SMTP_HOST or APP_URL unset -> dev logs the link, prod warns without it and sends nothing +- src/auth/auth.service.ts: register and forgot-password email the link fire-and-forget (no response-time difference for registered emails, a failed send keeps the generic response and is logged by message only); prod forgot-password logs only the candidate id +- src/locales/vi.ts, en.ts: mail subject/body strings +- src/utils/passwordReset.ts, emailVerification.ts, src/routers/api/v1/auth.route.ts: stale stub comments/summaries updated +- tests: auth.service.test.ts mocks the mail module (send asserted, no token in prod logs, failure path, no await); new services/mail.test.ts with nodemailer mocked +- package.json/package-lock.json: nodemailer ^10.6.0 (6.x had open high advisories), @types/nodemailer +- .env.example, CLAUDE.md, .claude/rules/api.md, README.md: new env vars, stub wording removed + +npm test: Test Suites: 76 passed, 76 total / Tests: 801 passed, 801 total +npm run build: exit 0 (tsc typecheck); lint 273 problems (<= 274 baseline), none new in changed files + +Node: email-auth-links (SEALED) +Evidence: agent-hub/evidence/verifier/2026-11-19/email-auth-links-seal.md + +Closes #461 + +Co-Authored-By: Claude Sonnet 5 "` +- `git push -u origin feature/461-password-reset-email` +- `gh pr create --base staging --head feature/461-password-reset-email (reuse an open one)` +- `gh pr checks --watch --required` +- `gh pr merge --merge` +- `git checkout staging` +- `git pull --ff-only origin staging` + +## Output +Commit: `32cbe39` +``` +$ git commit -m feat(auth): email reset/verify links over SMTP instead of logging tokens + +Reset and verification links carried live tokens in logger.info, so anyone with log access could take over an account. + +- src/services/mail.ts (new): sendAuthLinkEmail via Nodemailer SMTP (SMTP_HOST/PORT/USER/PASS, MAIL_FROM, APP_URL), plain text in the ?lang= language, 10s SMTP timeouts; SMTP_HOST or APP_URL unset -> dev logs the link, prod warns without it and sends nothing +- src/auth/auth.service.ts: register and forgot-password email the link fire-and-forget (no response-time difference for registered emails, a failed send keeps the generic response and is logged by message only); prod forgot-password logs only the candidate id +- src/locales/vi.ts, en.ts: mail subject/body strings +- src/utils/passwordReset.ts, emailVerification.ts, src/routers/api/v1/auth.route.ts: stale stub comments/summaries updated +- tests: auth.service.test.ts mocks the mail module (send asserted, no token in prod logs, failure path, no await); new services/mail.test.ts with nodemailer mocked +- package.json/package-lock.json: nodemailer ^10.6.0 (6.x had open high advisories), @types/nodemailer +- .env.example, CLAUDE.md, .claude/rules/api.md, README.md: new env vars, stub wording removed + +npm test: Test Suites: 76 passed, 76 total / Tests: 801 passed, 801 total +npm run build: exit 0 (tsc typecheck); lint 273 problems (<= 274 baseline), none new in changed files + +Node: email-auth-links (SEALED) +Evidence: agent-hub/evidence/verifier/2026-11-19/email-auth-links-seal.md + +Closes #461 + +Co-Authored-By: Claude Sonnet 5 +[feature/461-password-reset-email 32cbe39] feat(auth): email reset/verify links over SMTP instead of logging tokens + 25 files changed, 591 insertions(+), 40 deletions(-) + create mode 100644 agent-hub/evidence/analyst/2026-11-19/password-reset-email-spec.md + create mode 100644 agent-hub/evidence/implementer/2026-11-19/email-auth-links-diff.md + create mode 100644 agent-hub/evidence/implementer/2026-11-19/email-auth-links-plan.md + create mode 100644 agent-hub/evidence/verifier/2026-11-19/email-auth-links-seal.md + create mode 100644 src/__tests__/services/mail.test.ts + create mode 100644 src/services/mail.ts +$ git push -u origin feature/461-password-reset-email +To https://github.com/datvt243/resume-nodejs-api.git + 7e704be..32cbe39 feature/461-password-reset-email -> feature/461-password-reset-email +branch 'feature/461-password-reset-email' set up to track 'origin/feature/461-password-reset-email'. +PR: https://github.com/datvt243/resume-nodejs-api/pull/493 +build (20.x) pass 2m4s https://github.com/datvt243/resume-nodejs-api/actions/runs/44500655348/job/135479229892 +build (22.x) pass 1m35s https://github.com/datvt243/resume-nodejs-api/actions/runs/44500655348/job/135479230383 +$ gh pr merge 493 --merge +``` + +## Seal gate +Approved by the operator invoking /ship (AutoCommitNoGate), covering the whole chain above. From 63e56a21c704bc47b7360ea0c9cdacdd488017b4 Mon Sep 17 00:00:00 2001 From: _david Date: Thu, 19 Nov 2026 17:42:40 +0700 Subject: [PATCH 7/7] chore: release v2.10.0 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3c7b2216..95022021 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "resume-nodejs-api", - "version": "2.9.0", + "version": "2.10.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "resume-nodejs-api", - "version": "2.9.0", + "version": "2.10.0", "license": "ISC", "dependencies": { "adm-zip": "^0.6.1", diff --git a/package.json b/package.json index 440fdffb..e69ae903 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "resume-nodejs-api", "main": "src/server.ts", "private": true, - "version": "2.9.0", + "version": "2.10.0", "description": "Resume API backend with rate limiting and Redis support", "scripts": { "dev-node": "ts-node -r tsconfig-paths/register src/server.ts",