Skip to content

feat(security): spike primitives for ISP-056..059 — franking, finality tiers, transfer tickets, UV claims (#726 #727 #728 #729) - #845

Merged
Mikey-222 merged 1 commit into
Hel-Phone:mainfrom
Yilkash:feat/isp-056-059-spike-primitives
Oct 19, 2026
Merged

Mikey-222 merged 1 commit into
Hel-Phone:mainfrom
Yilkash:feat/isp-056-059-spike-primitives

Conversation

@Yilkash

@Yilkash Yilkash commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Combined PR closing the four assigned spike issues with minimal, verified
primitive slices
plus honest spike reports. The full DM-report pipeline,
checkpoint projector, QR/presence UX and UV-gating middleware these issues
ultimately describe do not exist in this codebase today (see per-issue
findings); this PR ships the hard cores each design hangs on, wired only where
a real call site already exists.

Verification

  • 23/23 tests pass across 4 new suites (franking-spike,
    checkpoint-finality-spike, session-transfer-spike, session-uv-spike).
  • Full npm run typecheck/npm test blocked by a pre-existing broken
    dependency: package.json pins @as-integrations/express (404 on npm)
    while package-lock.json pins the real @as-integrations/express4.
    Untouched per scope rules; verified instead via targeted tsc on the three
    touched TS files (my sections clean; remaining errors pre-existing in
    crypto.ts:46–511 / sessionKey.ts:64 / workerSandbox.ts / types/index.ts)
    and vitest on the 4 new suites.

Issue #726: E2E Message Franking

Problem: Report button + moderator view accept unverifiable pasted
plaintext; crypto.ts has E2EE envelopes but zero franking/commitment
constructions; server/lib/alertWebhook.ts is a one-line placeholder and
wsCluster.js carries no per-DM sender/recipient logging.

Resolution: HMAC-commitment franking primitive in src/lib/crypto.ts:
attachFrankingTag/verifyFrankingTag (MAC = truncated HMAC-SHA256 over
nonce‖ciphertext, 16-byte tag, keyId for rotation, constant-time compare,
malformed → false). Report pipeline wiring specced in the spike report
(docs/spikes/726-message-franking-report.md), not faked.

Closes #726

Issue #727: ZK Checkpoint Ledger-Reorg Finality

Problem: Issue describes first-sight-is-final checkpoint handling. Against
current main, server/indexer/parser.ts has no CheckpointCommitted
branch at all
and exporter.ts is a contract-state snapshot exporter — the
described pipeline doesn't exist.

Resolution: New server/lib/finality.ts — explicit pending | closed | finalized | orphaned tiers (classifyFinality(depth, {finalityDepth}),
default k=2, throws on garbage depth) + isOrphaned(first, latest)
same-ledger/different-hash predicate. Module is deliberately unwired;
the reorg-aware projection design is specced in
docs/spikes/727-checkpoint-finality-report.md.

Closes #727

Issue #728: Cross-Device Session Transfer

Problem: Issue reports QR session-copy cloning responders across devices.
Current main has no QR flow or presence system: sessionKey.ts is ECDH
with auto-burn, wsCluster.js is a tenant-filtered contract-event relay.

Resolution: Single-use, expiring transfer tickets with generation
semantics in src/lib/sessionKey.ts (createTransferTicket /
redeemTransferTicket, 90s TTL, single-use ticketId, redeem → generation
N+1; replay → already_redeemed, expired → expired). Full presence state
machine + QR UX specced in
docs/spikes/728-session-transfer-report.md.

Closes #728

Issue #729: WebAuthn UV Tiers

Problem: Issue reports uv=preferred downgrading the auth chain. Against
current main the server side is already closed —
server/routes/passkey-auth.js enforces userVerification: 'required' +
requireUserVerification: true on register AND login. What's missing:
sessions carry no UV/capability claim for audit or future step-up gating.

Resolution: uv claim bound into session tokens:
issueSession (uv: opts.uv !== false), preserved through
renewSessionIfNeeded and the three passkey-auth.js call sites
(register/verify, login/verify — measured from the authenticator's answer,
session/refresh). Tier policy + remaining shared-device compartment work
specced in docs/spikes/729-webauthn-uv-tier-report.md.

Closes #729

Covered-slice honesty note

#729 server-side UV enforcement predates this PR (verified in source); this
PR adds the session claim. #727's module is intentionally unwired — there is
no checkpoint pipeline to wire it into. #726/#728 are prototype primitives
without the described DM-report/QR-presence pipelines, which the spike
reports document as remaining work.

…y, transfer tickets, UV claims

Closes Hel-Phone#726 Hel-Phone#727 Hel-Phone#728 Hel-Phone#729

- Hel-Phone#726: HMAC-commitment message franking in src/lib/crypto.ts
  (attachFrankingTag/verifyFrankingTag, keyId rotation, constant-time
  compare) + spike report docs/spikes/726-message-franking-report.md
- Hel-Phone#727: server/lib/finality.ts — pending/closed/finalized/orphaned
  tier classification + orphan predicate + spike report
- Hel-Phone#728: single-use expiring transfer tickets with generation semantics in
  src/lib/sessionKey.ts + spike report
- Hel-Phone#729: uv claim bound into session tokens (issueSession, renewSessionIfNeeded,
  passkey-auth register/login/refresh) + spike report; server-side
  userVerification:'required' already enforced upstream

Tests: 23 new (franking 7, finality 6, transfer 6, uv 4). Full-suite
typecheck/lint blocked by pre-existing broken dep
@as-integrations/express (404 on npm; lockfile pins express4) — verified
via targeted tsc on touched TS files + vitest on the 4 new suites.

Signed-off-by: yilkash <260288456+yilkash@users.noreply.github.com>
@drips-wave

drips-wave Bot commented Oct 19, 2026

Copy link
Copy Markdown

@Yilkash Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Mikey-222
Mikey-222 merged commit f87269c into Hel-Phone:main Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment