Fix/explicit rpid config - #585
Conversation
…e .well-known files for passkeys
…C_RP_ID / NEXT_PUBLIC_ORIGIN)
|
@rhoggs-bot-test-account is attempting to deploy a commit to the miracle656's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Needs a rebase onto |
|
Apologies — this sat unreviewed for a month while What happened: PR #508 (
And the domain-association files are now hosted for real, not as examples: So the gap you were closing is closed. I have checked One part of this is NOT superseded, and it is worth salvaging. Your change to rpId: process.env.NEXT_PUBLIC_RP_ID?.trim() || undefined,
origin: process.env.NEXT_PUBLIC_ORIGIN?.trim() || undefined,
Two thoughts if you want to re-open it as a small focused PR:
So: the three Expo/well-known files here are superseded, but those two lines are not. A PR with just them, plus a note in the env documentation about the preview-URL case, would land. Not closing this. Sorry for the month. |
# Conflicts: # frontend/wallet/lib/network.ts
…eded Kept: explicit rpId and origin on walletConfig, sourced from NEXT_PUBLIC_RP_ID / NEXT_PUBLIC_ORIGIN and undefined when unset, so the SDK's window.location fallback still applies to the web build. Same addition in the Next.js example. Merged as a union with main rather than either side winning: the storage adapter that Miracle656#659 added to walletConfig and these two fields are unrelated additions to the same object literal. Dropped frontend/mobile/app.config.js and examples/expo/.well-known/* -- the same files this author's Miracle656#584 carried, and superseded for the same reasons. main's app.config.ts already claims both applinks: and webcredentials: per domain and carries the bundle id, intent filters, plugins and EAS project id; a second Expo config alongside it is at best dead and at worst silently wins and drops all of that. The real .well-known files under frontend/wallet/public/ carry the actual package name and certificate fingerprint. Verified: wallet tsc clean, 17 of 18 suites passing (feeBump.test.ts fails identically on main -- TextEncoder undefined in jsdom).
Miracle656
left a comment
There was a problem hiding this comment.
Approved and merging — rebased and reduced on your branch (59e51bb).
The change itself is right and I kept it as written. Explicit rpId and origin on walletConfig, from NEXT_PUBLIC_RP_ID / NEXT_PUBLIC_ORIGIN, defaulting to undefined when unset.
That last detail is what makes it safe: undefined leaves the SDK's window.location.hostname fallback intact, so the web build behaves exactly as before and only a deployment that opts in changes. Coercing to an empty string instead would have set the relying-party ID to '' on every existing deploy and broken WebAuthn everywhere — a one-character difference between a no-op and an outage.
The reason it's needed is worth stating plainly: on a native build there is no window.location to fall back to, so the relying-party ID has to come from configuration or the ceremony cannot name a relying party at all. Same addition in the Next.js example, which is the right place for a consumer to see it.
On the merge: walletConfig had gained a storage adapter from #659 since this branch was cut, so I resolved that as a union rather than letting either side win — two unrelated additions to one object literal, both wanted.
What I dropped: frontend/mobile/app.config.js and examples/expo/.well-known/*, the same files your #584 carried and superseded for the same reasons. main's app.config.ts already claims both applinks: and webcredentials: per domain and carries the bundle identifier, Android intent filters, plugins and EAS project id — a second Expo config beside it is at best dead, and at worst wins and silently drops all of that. Full reasoning on #584, which is merged.
Verified: wallet tsc --noEmit clean, 17 of 18 suites passing. The exception is feeBump.test.ts, which fails identically on main (TextEncoder is not defined in jsdom, from the stellar-sdk browser bundle) — checked against a stashed tree, not assumed.
Thanks.
Summary
Supply the Relying Party ID (rpId) and origin explicitly in the wallet configuration so native builds do not fall back to
localhost.Changes
frontend/wallet/lib/network.tsrpIdandoriginfields towalletConfig, read fromNEXT_PUBLIC_RP_IDandNEXT_PUBLIC_ORIGIN.examples/nextjs/src/lib/network.tsrpId/originadditions for the example app.Why
Native apps (Expo / React Native) lack
window.location.hostname, causing the SDK to default tolocalhost. That breaks passkey binding on real devices because the relying-party id must match the production domain. ReadingrpIdandoriginfrom environment variables allows CI and device builds to set the correct production values without changing source.Notes for maintainers / operators
NEXT_PUBLIC_RP_ID(e.g.veil.app) andNEXT_PUBLIC_ORIGIN(e.g.https://veil.app) in your environment/CI before building production artifacts.Testing / Verification
NEXT_PUBLIC_RP_ID=veil.appandNEXT_PUBLIC_ORIGIN=https://veil.appset and verifywalletConfigpassed touseInvisibleWallet()contains those values.localhost).Closes #442