fix: split web and native wallet connectors#233
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| @@ -1,3 +1,25 @@ | |||
| throw new Error( | |||
There was a problem hiding this comment.
what do you mean by native-on-web is it react-native-web ? If so, I think naming it react-native-web.ts would be more clear
There was a problem hiding this comment.
This has nothing to do with react-native-web. It's a file that is loaded when React Native code is imported on a Web environment and it throws an error.
Correction: it throws when the imported functions are called on the wrong platform. Not on import. This is documented in the comments in the file.
| export function originFromRpId(rpId: string): string { | ||
| return rpId.startsWith('http://') || rpId.startsWith('https://') | ||
| ? rpId | ||
| : `https://${rpId}` | ||
| } |
There was a problem hiding this comment.
Should we ever allow http without https? Maybe only if it's localhost, otherwise throw an error. Also, origin shouldn't have subpaths, e.g. https://zerodev.app/example and we currently just using it as-is.
And a nit, thinking we can rename this to sanitizeOrigin or normalizeOrigin since it's applicable more broadly.
There was a problem hiding this comment.
reverted the file
There was a problem hiding this comment.
Isn't this exactly the same as packages/core/src/utils/originFromRpId.ts?
There was a problem hiding this comment.
yes, I'll change it so we import the one from wallet-core instead
This reverts commit 8489c0f.
This PR is part of a stack created with Aviator.
mainCloses FS-2252
Summary
Origin: https://${rpId}from the connector config.rpIdas a required prop fromZeroDevExportWebView; it now reads it from the ZeroDev wagmi connector.Why
The connector now has platform-specific API needs. On React Native, consumers must provide native adapters and the SDK must send an
Originheader that matchesrpIdso Turnkey and AA requests pass ACL checks. On web, browsers own theOriginheader, so exposingfetchOptionsfor this path is misleading and does not solve the same problem.Splitting the connector keeps the public API accurate for each platform while preserving one shared implementation for the actual wagmi connector behavior. The native wrapper can require the RN-only adapter fields and derive the Origin header automatically, while the web wrapper can keep the browser API smaller and avoid exposing options that do not apply there.
If Passkeys are used
rpIdneeds to be a domain associated with the app - the KMS also enforces that the Passkey requests come from the same domain. So it makes sense to default the Origin header and the PasskeyrpIdto the same domain and have 1 source of truth.http://localhost:3000) as therpIdand that will work for basic KMS requests (OTP email, Google OAuth). To use Passkeys or OTP Magic Link the user needs to set up Universal Links (with a domain association) and then the developer should use the same domain as therpIdas well. This way requests coming from the app, on the KMS's side will look like they're coming from the associated domain (Originis set to the domain).Testing
zerodev-signer-demoon web, theexpo-exampleon both web and Android. All working.