chore(types): typed secret storage key cache; drop the cryptoCallbacks cast (#210) #468

Merged
jared merged 1 commits from chore/typing-hygiene into lotus 2026-10-25 20:33:51 -04:00
Owner

Part of #210 (typing hygiene).

Problem: src/client/secretStorageKeys.js was untyped JS and reached createClient behind cryptoCallbacks as any. That cast hid a real mismatch: getSecretStorageKey returned undefined when no key is cached, but the SDK's CryptoCallbacks type says null.

Change

  • The module is now TypeScript, typed against the SDK's CryptoCallbacks, and the cast is gone.
  • It returns null when no key is cached.
  • storePrivateKey accepts any Uint8Array and keeps its own copy, on a plain ArrayBuffer, which is what the callback type requires.
  • Behaviour is otherwise unchanged.

Survey of the remaining as any in app code (14 left, excluding tests): most are single, documented boundary casts that each keep their call sites typed: account data with custom event types, sendStateEvent for custom state, and the correlated generic in useRoomsListener. The partial fake event in local message search is the same kind. I left them as they are.

Tested

  • New unit test for the key cache: null when unknown, the key once stored, the input is copied, clearSecretStorageKeys works, and invalid input is rejected.
  • 1,441 unit tests pass, and tsc is clean.
  • Build succeeds.
  • Playwright, 9/9: key-upload-recovery (recovery-key unlock), security-nudge and boot.

🤖 Generated with Claude Code

https://claude.ai/code/session_017PCb59uY3UKqDqt7B6hzd5

Part of #210 (typing hygiene). **Problem:** `src/client/secretStorageKeys.js` was untyped JS and reached `createClient` behind `cryptoCallbacks as any`. That cast hid a real mismatch: `getSecretStorageKey` returned `undefined` when no key is cached, but the SDK's `CryptoCallbacks` type says `null`. **Change** - The module is now TypeScript, typed against the SDK's `CryptoCallbacks`, and the cast is gone. - It returns `null` when no key is cached. - `storePrivateKey` accepts any `Uint8Array` and keeps its own copy, on a plain `ArrayBuffer`, which is what the callback type requires. - Behaviour is otherwise unchanged. **Survey of the remaining `as any` in app code** (14 left, excluding tests): most are single, documented boundary casts that each keep their call sites typed: account data with custom event types, `sendStateEvent` for custom state, and the correlated generic in `useRoomsListener`. The partial fake event in local message search is the same kind. I left them as they are. **Tested** - New unit test for the key cache: `null` when unknown, the key once stored, the input is copied, `clearSecretStorageKeys` works, and invalid input is rejected. - 1,441 unit tests pass, and tsc is clean. - Build succeeds. - Playwright, 9/9: key-upload-recovery (recovery-key unlock), security-nudge and boot. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_017PCb59uY3UKqDqt7B6hzd5
jared added 1 commit 2026-10-25 19:39:28 -04:00
chore(types): typed secret storage key cache; drop the cryptoCallbacks cast (#210)
CI / Build & Quality Checks (push) Skipped
CI / Secret scan (gitleaks) (push) Skipped
CI / Playwright smoke (e2e) (push) Skipped
CI / Build & Quality Checks (pull_request) Successful in 3m32s
CI / Trigger Desktop Build (pull_request) Skipped
CI / Docker image build & smoke test (pull_request) Skipped
CI / Secret scan (gitleaks) (pull_request) Successful in 16s
CI / Playwright smoke (e2e) (pull_request) Successful in 24m32s
b944456ab5
secretStorageKeys was untyped JS, passed to createClient behind `as any`,
which hid that getSecretStorageKey returned undefined where the SDK type
says null. Now TypeScript against the SDK's CryptoCallbacks, returns null,
and storePrivateKey keeps its own copy of the key. Unit test added.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017PCb59uY3UKqDqt7B6hzd5
jared scheduled this pull request to auto merge when all checks succeed 2026-10-25 19:40:22 -04:00
jared merged commit 185970bc5a into lotus 2026-10-25 20:33:51 -04:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: LotusGuild/cinny#468