fix(core): add CommunicationAdapter abstraction for cross-platform transport#124
Open
anthony23991 wants to merge 4 commits intomainfrom
Open
fix(core): add CommunicationAdapter abstraction for cross-platform transport#124anthony23991 wants to merge 4 commits intomainfrom
anthony23991 wants to merge 4 commits intomainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 3 Skipped Deployments
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem: CrossPlatformSigner directly depended on the Communicator class, which uses window.open() / postMessage for browser popup communication. React Native has no popup windows, so the signing flow
couldn't work on mobile.
Solution: Extract a CommunicationAdapter interface, wrap the existing Communicator in a WebCommunicationAdapter, and make CrossPlatformSigner + JAWProvider depend on the interface instead of the concrete
class. Mobile apps can now provide their own adapter (e.g., deep links) by passing communicationAdapter in the SDK preference.
New files:
onMessage(), disconnect()
Core refactor:
for adapters that need configuration. Added defensive guards in decryptResponseMessage() for malformed responses
Supporting changes:
Tests:
Zero breaking changes for web consumers. WebCommunicationAdapter is created automatically when no custom adapter is provided. All existing SDK usage (JAW.create(), Mode.CrossPlatform, etc.) works exactly
as before.
Usage:
import { JAW, Mode } from '@jaw.id/core';
const sdk = JAW.create({
apiKey: 'key',
appName: 'My App',
preference: {
mode: Mode.CrossPlatform,
communicationAdapter: new MobileCommunicationAdapter(), // from @jaw/ui-native
},
});