Skip to content

Dev#54

Merged
calebtuttle merged 3 commits into
mainfrom
dev
Jun 15, 2026
Merged

Dev#54
calebtuttle merged 3 commits into
mainfrom
dev

Conversation

@calebtuttle

Copy link
Copy Markdown
Contributor

No description provided.

calebtuttle and others added 3 commits June 15, 2026 10:40
…fication

When an iDenfy verification token EXPIRES, lazily mint a fresh iDenfy session
for the same already-paid parent session instead of dead-ending the user on the
expired token. Fixes the resume loop where the parent Session stays IN_PROGRESS
and the frontend keeps routing back to the same expired /idenfy/verify URL.

- getIdenfyStatusForSession: treat EXPIRED as recoverable (not terminal) from
  both the cached-webhook path and a fresh /api/v2/status poll; route into
  recreateExpiredIdenfySession which re-mints in place (new authToken/scanRef,
  status reset to in_progress) reusing clientId=createdBySessionId (no re-pay).
- Anti-flash contract: never surface EXPIRED while re-creation is viable; the
  lock-loser returns a pending status with the stale token withheld.
- Valkey lock (idenfy:recreate-lock:<id>, SET NX EX 30s) held ONLY around the
  iDenfy token API call, serializing concurrent pollers (host + external tab).
- recreationCount cap (10) bounds iDenfy verification-credit cost/abuse.
- Shared by gov-id and Clean Hands (AML) flows via getIdenfyStatusForSession;
  no flow-specific fork.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Addresses ce-code-review findings on PR #53:

- Check updateOne result on re-mint: when matchedCount===0 (TTL-overrun
  duplicate mint already advanced the scanRef), return the persisted/peer
  state instead of the orphaned, never-recorded billed token whose webhook
  would 404. (P1)
- Persist an EXPIRED sentinel (verification-status only, not status:"failed")
  on the freshly-fetched-EXPIRED path before recovery, so a lock-losing peer
  no longer hands back the stale expired token and a capped row stops
  re-polling /api/v2/status every cycle. (P1)
- Introduce IdenfySessionView return type with nullable token fields; annotate
  getIdenfyStatusForSession/recreateExpiredIdenfySession and drop the
  `as unknown as` casts that hid null fields typed as string. (P1, type-only)
- Add tests: 0-match re-mint returns peer state, fresh-fetch sentinel write,
  and SUSPECTED terminal regression guard.

Skipped (accepted tradeoff): graceful degradation when Valkey is down — a
cache outage 500s EXPIRED status polls rather than degrading.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…sion-recreation

fix(idenfy): recreate expired iDenfy session so users can resume verification
@calebtuttle calebtuttle merged commit 6628b18 into main Jun 15, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant