Expose generateKey() and getPublicKey() in CryptoAdapter surface#1849
Expose generateKey() and getPublicKey() in CryptoAdapter surface#1849transphorm merged 5 commits intodevfrom
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant BridgeCryptoAdapter
participant NativeBridge
participant NativeKeychain
rect rgba(100, 150, 255, 0.5)
Note over Client,NativeKeychain: generateKey Flow
Client->>BridgeCryptoAdapter: generateKey(keyRef)
BridgeCryptoAdapter->>NativeBridge: request('crypto', { action: 'generateKey', params: { keyRef } })
NativeBridge->>NativeKeychain: create key & store
NativeKeychain-->>NativeBridge: { keyRef }
NativeBridge-->>BridgeCryptoAdapter: { success: true, keyRef }
BridgeCryptoAdapter-->>Client: { keyRef }
end
rect rgba(150, 200, 100, 0.5)
Note over Client,NativeKeychain: getPublicKey Flow
Client->>BridgeCryptoAdapter: getPublicKey(keyRef)
BridgeCryptoAdapter->>NativeBridge: request('crypto', { action: 'getPublicKey', params: { keyRef } })
NativeBridge->>NativeKeychain: extract public key
NativeKeychain-->>NativeBridge: { publicKey: base64String }
NativeBridge-->>BridgeCryptoAdapter: { success: true, publicKey: base64String }
BridgeCryptoAdapter->>BridgeCryptoAdapter: decode base64 -> Uint8Array
BridgeCryptoAdapter-->>Client: Uint8Array
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/webview-bridge/src/adapters/crypto.ts`:
- Around line 42-49: The generateKey function currently ignores result.success
and always returns a keyRef even when native generation failed; update
generateKey (in packages/webview-bridge/src/adapters/crypto.ts) to check the
bridge.request response (result.success) and throw/reject when success is false
or undefined instead of returning { keyRef }, otherwise return the keyRef only
when result.success is true; reference the generateKey function and the
bridge.request('crypto','generateKey', ...) call when making the change.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: c54a795d-c061-4e79-aa22-9355407e4fe3
📒 Files selected for processing (11)
packages/mobile-sdk-alpha/src/adapters/browser/crypto.tspackages/mobile-sdk-alpha/src/adapters/react-native/crypto.tspackages/mobile-sdk-alpha/src/types/public.tspackages/mobile-sdk-alpha/tests/adapters/browser/crypto.test.tspackages/mobile-sdk-alpha/tests/client.test.tspackages/mobile-sdk-alpha/tests/documents/utils.test.tspackages/mobile-sdk-alpha/tests/utils/testHelpers.tspackages/webview-bridge/src/__tests__/adapters.test.tspackages/webview-bridge/src/adapters/crypto.tsspecs/projects/sdk/workstreams/sdk-core/SPEC.mdspecs/projects/sdk/workstreams/sdk-core/plans/SC-02-crypto-bridge-surface.md
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/webview-bridge/src/adapters/crypto.ts`:
- Around line 54-61: The getPublicKey implementation decodes bridge.request
result.publicKey without validating it; update getPublicKey to fail closed by
explicitly checking that result and result.publicKey are present, are non-empty
strings, and match an expected base64 pattern before calling base64ToUint8Array,
and if any check fails throw a clear error (e.g., "Invalid or empty publicKey
from bridge") rather than returning an empty array or letting decode errors
leak; wrap the base64ToUint8Array call in a try/catch and rethrow a normalized
error on decode failure so callers see a consistent failure mode.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: e1a4be61-9caf-4a13-9f71-3359038ebe66
📒 Files selected for processing (3)
app/src/providers/selfClientProvider.tsxpackages/webview-bridge/src/__tests__/adapters.test.tspackages/webview-bridge/src/adapters/crypto.ts
Summary
Test plan
Native Consolidation Checklist
cd app && yarn jest:run/yarn workspace @selfxyz/rn-sdk-test-app test)Summary by CodeRabbit
New Features
Behavior
Tests
Documentation