Dev app in this repo for exercising @abstraxn/signer-core-react-native directly (no @abstraxn/signer-react-native). App-local WalletProvider / useWallet in src/WalletContext.jsx replace the old SDK provider; email OTP uses custom src/EmailOtpModal.jsx. OAuth, passkeys, and demo sign buttons live in App.js / components/.
WalletProvider— wrapsAbstraxnWallet(core) and exposesuseWallet()useWallet— OAuth URL helpers, callbacks, OTP, and passkey flows viawallet- OAuth — opening provider URLs and completing redirects (including deep-link style handling)
- Passkeys — login and signup patterns aligned with the SDK
- Signing — local demo components built with SDK hooks
Implementation lives mainly in App.js. The sections below describe what this repo actually does so you can map UI behavior to SDK calls.
| File | Role |
|---|---|
index.js |
Imports react-native-get-random-values first so crypto.getRandomValues exists before other code (required for the signing stack / viem-style usage). |
App.js |
WalletProvider at the root, all screens and auth logic in WalletSection. |
The default export wraps the app in WalletProvider with a config object:
apiKey— Your Abstraxn API key (declared as a constant at the top ofApp.js; replace with your own).autoConnect—trueso a returning user can restore a session when appropriate.rpId— Relying Party ID for WebAuthn / passkeys (must match your Abstraxn passkey configuration).
WalletSection is the child that calls useWallet() and renders either the sign-in UI or the connected wallet UI.
WalletSection destructures these from the app hook:
| API | How this app uses it |
|---|---|
isConnected, address, loading, disconnecting |
Drive “signed in” vs sign-in screen; show wallet address; disable actions while loading. |
disconnect |
“Log out” clears the session and resets local OAuth dedupe state so the next login can run cleanly. |
wallet |
Passkey flows: wallet.loginWithPasskey(), wallet.signupWithPasskey({ organizationName: 'MyAbstraxnApp' }). |
loginWithOTP, verifyOTP |
Used by custom EmailOtpModal (src/EmailOtpModal.jsx). |
getGoogleAuthUrl, getDiscordAuthUrl, getTwitterAuthUrl |
Each social button asks the SDK for the provider URL, passing the app’s OAuth redirect scheme (same constant used in native URL scheme config). |
handleGoogleCallback, handleDiscordCallback, handleTwitterCallback |
Called when the redirect URL contains code and state (authorization-code flow); the SDK exchanges them with the backend. |
completeOAuthFromDeepLink |
Used when the backend redirects to the custom scheme with success=true and token-style params (accessToken, refreshToken, user, optional turnkeyPublicKey). |
completeOAuthReturnFromUrl |
Used for another success path that completes OAuth by parsing the full return URL (e.g. web-parity / loginCode-style flows). |
This app does not stop at “get URL and open it.” It implements a full mobile loop:
- Open the provider — Google and Discord use
react-native-inappbrowser-rebornwhen available (in-app browser); X (Twitter) usesLinking.openURLto the system browser (fewer fragile embedded-session issues on some devices). - Listen for returns —
Linking.addEventListener('url', …)(andLinking.getInitialURL()for cold start) inspect incoming URLs. - Filter — Only URLs that match the app’s custom scheme or known HTTPS callback paths are handled (see
isOAuthRedirectUrland path constants near the top ofApp.js). - Dismiss in-app browser — When the URL uses the custom scheme,
InAppBrowser.close()runs so the Safari / Chrome custom tab does not stay on screen after return. - Complete sign-in with the SDK — Depending on what the backend puts in the URL:
- Token bundle →
completeOAuthFromDeepLink({ accessToken, refreshToken, user, turnkeyPublicKey }) - Alternate URL completion →
completeOAuthReturnFromUrl(url, provider) - Code + state →
handleGoogleCallback/handleDiscordCallback/handleTwitterCallback(with special cases: e.g. opening certain HTTPS callback URLs again so the server can finish and redirect to the app).
- Token bundle →
- Dedupe — Authorization codes are single-use. A
useReftracks the last processed callback so the same code is not sent twice (avoidsinvalid_grantand duplicate sessions).
There is also a Twitter fallback (buildOAuthFallbackUrl) if the initial getTwitterAuthUrl request fails on some Android network edge cases.
- Sign up —
wallet.signupWithPasskey({ organizationName: 'MyAbstraxnApp' })with a small retry path for flaky native errors. - Sign in —
wallet.loginWithPasskey()after a shortrequestAnimationFramedelay (helps reliability on Android).
The “Test Passkey.get” control is not an SDK API: it calls react-native-passkey’s Passkey.get with a random challenge to verify native passkey / WebAuthn behavior on a device (debugging aid).
When isConnected is true, the app shows:
DemoSignTransactionButton— app-local component (components/DemoSignTransactionButton.js) for signing.DemoSignAndSendTransactionButton— app-local component (components/DemoSignAndSendTransactionButton.js) usinguseSignAndSendTxn.
WalletProvider(config)
└── WalletSection
useWallet() → UI buttons call get*AuthUrl / wallet.* / handle*Callback / completeOAuth*
EmailOtpModal (custom)
Linking 'url' events → finish OAuth with completeOAuth* or handle*Callback
isConnected → local demo signing buttons, disconnect
For generic integration patterns (button-to-method mapping, loading states, production checklist), keep SDK_FRONTEND_GUIDE.md open alongside App.js.
- Node.js ≥ 22.11 (see
package.json→engines) - React Native toolchain for iOS and Android (Xcode / Android Studio as usual)
Abstraxn API key (required): In App.js, set APP_API_KEY to your Abstraxn API key from your Abstraxn / project dashboard — replace the placeholder YOUR_ABSTRAXN_API_KEY. Without a valid key, sign-in and SDK calls will not work.
cd MyAbstraxnApp
npm installiOS (first time or after native dependency changes):
cd ios && pod install && cd ..Run:
npm start
# in another terminal
npm run ios
# or
npm run androidPublished package:
npm install @abstraxn/signer-core-react-nativeIf this checkout uses a local file: dependency in package.json, adjust it to match your layout or switch to the npm package above.
- API key — Set your Abstraxn API key in the app config (this demo uses constants near the top of
App.js). Replace any placeholder with your own key. - Passkeys — Set
rpIdto the Relying Party ID that matches your Abstraxn / passkey setup (seeSDK_FRONTEND_GUIDE.md). - OAuth redirects — Align your redirect URL scheme with your app’s deep linking and your Abstraxn dashboard settings (this demo uses a custom scheme constant in
App.js). - Android release signing — Copy
android/keystore.properties.exampletoandroid/keystore.properties, set your keystore credentials, and keep it out of git.
Do not commit production secrets to a public repository. Treat API keys like passwords.
This section summarizes what was checked for a public demo repo.
| Topic | Status / note |
|---|---|
| API key in source | The app uses the placeholder YOUR_ABSTRAXN_API_KEY in App.js. Replace it locally to run the app; never commit a real key. If an old key was ever committed, rotate it in the Abstraxn dashboard. |
.env files |
.gitignore ignores .env and .env.* so local secrets are not committed. See .env.example if you add env-based loading later. |
| OAuth / debug logging | App.js logs redirect URLs and OAuth debug lines ([OAuth], [Passkey.get test]). Fine for a sample; for production, strip or gate behind __DEV__ so tokens and URLs are not logged. |
package.json SDK path |
A file:../abstraxn-sdks/... dependency only works inside your monorepo. Public clones should use npm install @abstraxn/signer-core-react-native (and may need a simpler metro.config.js than the monorepo version). |
| Android debug signing | Default debug keystore passwords in Gradle are the usual React Native android values — not production signing. |
| Demo transaction | Amoy testnet RPC and a sample to address are public test data, not secrets. |
| Resource | Purpose |
|---|---|
| SDK_FRONTEND_GUIDE.md | Step-by-step integration guide: provider setup, button → SDK method mapping, loading/error patterns, production checklist |
| Script | Command |
|---|---|
| Start Metro | npm start |
| Run iOS | npm run ios |
| Run Android | npm run android |
| Lint | npm run lint |
| Tests | npm test |
| Build release APK | npm run android:apk |
Abstraxn — this demo is provided to illustrate SDK usage; adapt patterns, naming, and security practices to your product.