Skip to content

Route every lazy keym-v2 and Shamir import through its typed loader - #211

Merged
404SecNotFound merged 2 commits into
claude/trusting-fermi-rx5kxvfrom
claude/serene-carson-0739mv
Sep 25, 2026
Merged

404SecNotFound merged 2 commits into
claude/trusting-fermi-rx5kxvfrom
claude/serene-carson-0739mv

Conversation

@404SecNotFound

@404SecNotFound 404SecNotFound commented Sep 24, 2026 •

Copy link
Copy Markdown
Owner

Summary

Stacked on #210 (claude/trusting-fermi-rx5kxv). Merge #210 first, and GitHub then retargets this one to main.

#210 typed the failure when the KEYM v2 or Shamir module cannot load (finding 6), in keymaker-crypto.ts and addShamirSlotKeym2. Twenty-one other lazy imports of the same two modules still used a bare import().

  • 16 in encryptor-tool.tsx
  • 2 in crypto-client.ts (the no-worker fallback)
  • 2 in crypto-worker.ts
  • 1 Shamir import in encryptor-tool.tsx

None of them can fail today. The page already imports keym-v2 statically, the fallback's imports run after encryptContainer has loaded the module, and the worker is a single IIFE bundle. They would bring the untyped "wrong password" failure back if any of that changed, so this PR closes the gap now.

Changes

  • loadKeym2 (keymaker-crypto.ts) and loadShamir (keym-v2.ts) are exported, and all 21 sites use them.
  • scripts/secret-erase-core-test.mjs scans src and fails on any bare import() of either module outside those two loaders. It also checks that its pattern recognises the forms it guards against and ignores typeof import().
  • CHANGELOG Unreleased notes the change.

While the static import is in place no call can model the failure, which is why the guard is a source check.

Test plan

  • Negative controls. A bare import put back in crypto-client.ts fails with 1 offender, and the bare Shamir import put back in the page fails with 1 (both type-checked first). The three files as they are on the base branch fail with 21.
  • On 862bda2, npm run typecheck, all 37 npm run test:* scripts except test:browser, and keym.py selftest
  • On e212b37 (after merging the base branch's WebKit test fix), typecheck, test:secret-erase-core, build with no base path, and npx playwright test --project=chromium --workers=2. 304 passed, 5 skipped, exit 0.
  • CI on e212b37, all 15 checks green, including Firefox and WebKit.

Finding 6 typed the module-load failure in keymaker-crypto.ts and in
addShamirSlotKeym2. Twenty-one other sites still used a bare import():
16 of keym-v2 and 1 of keym-v2-shamir in encryptor-tool.tsx, and 2 each of
keym-v2 in crypto-client.ts (the no-worker fallback) and crypto-worker.ts.

None can fail today. The page imports keym-v2 statically, the fallback's
imports run after encryptContainer has loaded it, and the worker is one IIFE
bundle. Each would bring back the untyped "wrong password" failure if that
stopped being true.

- loadKeym2 (keymaker-crypto.ts) and loadShamir (keym-v2.ts) are exported and
  all 21 sites use them.
- secret-erase-core-test.mjs scans src and fails on any bare import() of either
  module outside the two loaders, and checks its own pattern against the
  forms it guards and a type-only import().

No call can model the failure while the static import is there, so the guard
is a source check. Controls, each type-checked: one bare import back in
crypto-client.ts fails with 1 offender; the bare Shamir import back in the
page fails with 1; the three files as they were fail with 21.
@404SecNotFound
404SecNotFound merged commit 8308d3f into claude/trusting-fermi-rx5kxv Sep 25, 2026
15 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