@moon-x/react-native-sdk 0.23.0 → 0.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -126,7 +126,7 @@ TypeScript surface. Every op is always-fresh by construction.
126
126
 
127
127
  | Hook | What it does |
128
128
  |---|---|
129
- | `useMoonX()` | The active headless SDK instance: `{ ready, isAuthenticated, user, logout, getSessionTokens, refreshUser, ... }`. Web-only `start`, modal, and appearance methods are intentionally absent. |
129
+ | `useMoonX()` | The active headless SDK instance, including `ready`, `sessionStatus`, `sessionError`, `retrySession`, `isAuthenticated`, `user`, and session and wallet methods. Web-only `start`, modal, and appearance methods are absent. |
130
130
  | `useUser()` | Just `{ user, refreshUser }`. Re-subscribes to user changes. |
131
131
  | `useLoginWithEmail({ onComplete?, onError? })` | Headless email-OTP. Returns `{ state, sendCode, loginWithCode, reset }`. `state` is a discriminated union: `idle` / `sending` / `awaiting-code` / `verifying` / `complete` / `error`. |
132
132
  | `useLoginWithOAuth()` | Google + Apple flows via `expo-web-browser`. Returns `{ state, loginWithOAuth, reset }`. |
@@ -183,9 +183,82 @@ A `401` response from the backend becomes the stable
183
183
  `moonpay_consumer_session_invalid` error code. Do not parse HTTP status numbers
184
184
  from error messages.
185
185
 
186
- The provider revalidates its hidden-WebView session on cold start and whenever
187
- the native app returns to the foreground. `revalidatedAt` advances after each
188
- probe so shared wallet hooks refresh app-owned wallet state.
186
+ The provider revalidates its WebView session on cold start and when the native app returns to the foreground.
187
+ `revalidatedAt` advances after a confirmed session result or successful login or logout. Failed checks leave it unchanged.
188
+
189
+ #### Session restoration and retry
190
+
191
+ `ready` retains its existing WebView meaning. It does not mean that session restoration is complete.
192
+ Use `sessionStatus` to distinguish restoration from a confirmed sign-out:
193
+
194
+ | Status | Meaning |
195
+ | --- | --- |
196
+ | `restoring` | The first session check or a revalidation is pending. |
197
+ | `authenticated` | A check or login confirmed a session. The profile can still be loading. |
198
+ | `signed-out` | Logout succeeded or repeated checks confirmed no session. |
199
+ | `error` | The bounded restoration attempts failed. Authentication and the profile retain their last confirmed values. |
200
+
201
+ `sessionError` contains the last exhausted restoration error, or `null`.
202
+ `retrySession()` returns `void` and starts a new bounded check when the WebView is ready.
203
+ Repeated calls during a check share that check. Calls during an interactive auth flow wait until the flow finishes.
204
+ The method does not reload the WebView or retry signing, transaction submission, or other mutations.
205
+
206
+ ```tsx
207
+ import { useMoonX } from '@moon-x/react-native-sdk';
208
+ import { Button, Text, View } from 'react-native';
209
+
210
+ function SessionGate({ children, signIn }: {
211
+ children: React.ReactNode;
212
+ signIn: React.ReactNode;
213
+ }) {
214
+ const { ready, isAuthenticated, sessionStatus, sessionError, retrySession } = useMoonX();
215
+ if (!ready) return <Text>Connecting...</Text>;
216
+ if (isAuthenticated) {
217
+ return <View>
218
+ {sessionError && <Button title="Retry session check" onPress={retrySession} />}
219
+ {children}
220
+ </View>;
221
+ }
222
+ if (sessionStatus === 'signed-out') return <>{signIn}</>;
223
+ if (sessionStatus === 'error') {
224
+ return <Button title="Retry session check" onPress={retrySession} />;
225
+ }
226
+ return <Text>Restoring your session...</Text>;
227
+ }
228
+ ```
229
+
230
+ A failed cold-start check keeps `revalidatedAt` at zero. Do not interpret `ready && !isAuthenticated` as a confirmed sign-out.
231
+ After a background error, existing authenticated UI can remain visible. Wallet operations still require valid credentials from the WebView.
232
+ Profile-fetch errors do not invalidate an otherwise confirmed session.
233
+
234
+ #### Keep sessions when the OS clears WebView storage
235
+
236
+ iOS can delete the hidden WebView's storage, including the refresh token, while the session is still valid on the server. Users then appear signed out after reopening the app. Pass `config.sessionResumeStorage` to restore such sessions silently:
237
+
238
+ ```tsx
239
+ import * as SecureStore from 'expo-secure-store';
240
+ import { MoonXProvider, type SessionResumeStorage } from '@moon-x/react-native-sdk';
241
+
242
+ // Module scope, so the object is stable across renders.
243
+ const options = { keychainAccessible: SecureStore.WHEN_UNLOCKED_THIS_DEVICE_ONLY };
244
+ const sessionResumeStorage: SessionResumeStorage = {
245
+ getItem: (key) => SecureStore.getItemAsync(key, options),
246
+ setItem: (key, value) => SecureStore.setItemAsync(key, value, options),
247
+ removeItem: (key) => SecureStore.deleteItemAsync(key, options),
248
+ };
249
+
250
+ <MoonXProvider publishableKey="moon_pk_..." config={{ sessionResumeStorage }}>
251
+ ```
252
+
253
+ The SDK stores a P-256 private key there. After each login it binds the key's public half to the session. When a later check finds the WebView's session gone, it signs a single-use server challenge with the key and the iframe stores the restored session. `sessionStatus` stays `restoring` throughout, so the user never sees a sign-out.
254
+
255
+ **Treat the stored key as a credential.** Anything that can read it, including your app's own JavaScript and its dependencies, can resume the bound session until the session expires or is revoked. Unlike the web SDK's non-extractable WebCrypto key, React Native holds the raw key.
256
+
257
+ - Use device-only storage: `WHEN_UNLOCKED_THIS_DEVICE_ONLY` (resume runs while the app is in use), no iCloud Keychain sync, and exclude it from Android Auto Backup (see the `expo-secure-store` backup docs).
258
+ - A resumed session keeps its original expiry. Resume never extends it.
259
+ - Logout deletes the key before revoking the session, and nothing resumes again until the next successful login, even if the logout itself fails. Signing in replaces the recorded session first, so an interrupted account switch never resumes the previous account.
260
+ - A key left in the Keychain by a previous installation never resumes: the SDK ties it to this installation through AsyncStorage, which an uninstall clears.
261
+ - Session resume must be enabled for the app. Without it, the key is never bound and nothing changes.
189
262
 
190
263
  ### Passkeys
191
264
 
@@ -315,7 +388,34 @@ Both methods use the configured `relyingPartyOrigin` when they need a passkey as
315
388
 
316
389
  `registerPasskey()` and `addPasskey()` can add the first passkey to an existing identity-backed wallet. This upgrade requires email OTP presence before native registration. The SDK then stores a passkey wrap for the existing DEK. It does not replace the DEK or create another wallet.
317
390
 
318
- Register the host app OTP UI with `registerPresenceOtpCodeProvider`, exported from `@moon-x/react-native-sdk`. The provider receives a `PresenceOtpCodeRequest` and returns a promise for the entered code. Reject the promise when the user cancels. Call the returned cleanup function when the provider is no longer needed.
391
+ `MoonXProvider` shows a built-in prompt for the emailed code, so no wiring is needed. It draws nothing until a call needs a code, reprompts after a wrong code (up to five attempts on the same email), and closes when the code expires. Rejections to handle: `presence_otp_cancelled` (the user closed it) and `presence_otp_expired`.
392
+
393
+ Restyle or translate it through `config.presenceOtpPrompt`:
394
+
395
+ ```tsx
396
+ <MoonXProvider
397
+ publishableKey="moon_pk_..."
398
+ config={{
399
+ presenceOtpPrompt: {
400
+ copy: { title: "Revisa tu correo", verify: "Verificar" },
401
+ colors: { background: "#ffffff", text: "#111111", accent: "#7c3aed" },
402
+ },
403
+ }}
404
+ >
405
+ ```
406
+
407
+ To use your own UI everywhere, set `presenceOtpPrompt: false` and register a provider with `registerPresenceOtpCodeProvider`, exported from `@moon-x/react-native-sdk`. The provider receives a `PresenceOtpCodeRequest` and returns a promise for the entered code. Reject the promise when the user cancels. Call the returned cleanup function when the provider is no longer needed.
408
+
409
+ `registerPasskey` and `addPasskey` also accept `requestOtpCode`, to collect the code in the screen that started enrollment. It has the same signature and takes precedence over both the built-in prompt and a registered provider. Other operations that need a code, such as exporting a key or removing a passkey, always use the built-in prompt or the registered provider:
410
+
411
+ ```tsx
412
+ await addPasskey({
413
+ displayName: "My app",
414
+ requestOtpCode: ({ attempt, error }) => promptForEmailCode({ attempt, error }),
415
+ });
416
+ ```
417
+
418
+ `requestOtpCode` is called again with `error: "invalid code"` after a wrong code. With the built-in prompt turned off and no provider or `requestOtpCode`, the call rejects with `presence_otp_code_provider_required` before any email is sent.
319
419
 
320
420
  The OTP path requires a verified email address. Initial identity-backed setup and eligible ephemeral-signer actions do not require this OTP provider. `registerPasskey({ createWallets: ... })` rejects a KMS-only upgrade with `register_create_unavailable_for_kms_upgrade`.
321
421
 
package/dist/ethereum.js CHANGED
@@ -47,12 +47,12 @@ module.exports = __toCommonJS(ethereum_exports);
47
47
  var import_ethereum = require("@moon-x/core/react/ethereum");
48
48
 
49
49
  // src/hooks/use-export-key.ts
50
- var import_sdk9 = require("@moon-x/core/sdk");
51
- var import_utils5 = require("@moon-x/core/utils");
50
+ var import_sdk11 = require("@moon-x/core/sdk");
51
+ var import_utils6 = require("@moon-x/core/utils");
52
52
 
53
53
  // src/provider.tsx
54
- var import_react = require("react");
55
- var import_react_native = require("react-native");
54
+ var import_react2 = require("react");
55
+ var import_react_native2 = require("react-native");
56
56
  var import_react_native_webview = require("react-native-webview");
57
57
 
58
58
  // src/sdk/create-sdk-instance.ts
@@ -161,24 +161,100 @@ var import_sdk7 = require("@moon-x/core/sdk");
161
161
  var import_sdk8 = require("@moon-x/core/sdk");
162
162
 
163
163
  // src/provider.tsx
164
- var import_utils4 = require("@moon-x/core/utils");
164
+ var import_utils5 = require("@moon-x/core/utils");
165
+
166
+ // src/components/presence-otp-prompt.tsx
167
+ var import_react = require("react");
168
+ var import_react_native = require("react-native");
169
+ var import_sdk9 = require("@moon-x/core/sdk");
170
+ var import_jsx_runtime = require("react/jsx-runtime");
171
+ var styles = import_react_native.StyleSheet.create({
172
+ backdrop: {
173
+ flex: 1,
174
+ alignItems: "center",
175
+ justifyContent: "center",
176
+ padding: 16,
177
+ backgroundColor: "rgba(0, 0, 0, 0.45)"
178
+ },
179
+ card: {
180
+ width: "100%",
181
+ maxWidth: 384,
182
+ padding: 24,
183
+ borderRadius: 14
184
+ },
185
+ title: {
186
+ fontSize: 20,
187
+ fontWeight: "600"
188
+ },
189
+ body: {
190
+ fontSize: 14,
191
+ marginTop: 8
192
+ },
193
+ input: {
194
+ marginTop: 16,
195
+ paddingVertical: 12,
196
+ paddingHorizontal: 16,
197
+ borderRadius: 12,
198
+ borderWidth: import_react_native.StyleSheet.hairlineWidth,
199
+ fontSize: 24,
200
+ letterSpacing: 8,
201
+ textAlign: "center"
202
+ },
203
+ error: {
204
+ fontSize: 13,
205
+ marginTop: 8
206
+ },
207
+ primaryButton: {
208
+ marginTop: 16,
209
+ paddingVertical: 12,
210
+ borderRadius: 12,
211
+ alignItems: "center"
212
+ },
213
+ primaryButtonDisabled: {
214
+ opacity: 0.5
215
+ },
216
+ primaryButtonText: {
217
+ fontSize: 16,
218
+ fontWeight: "600"
219
+ },
220
+ ghostButton: {
221
+ marginTop: 8,
222
+ paddingVertical: 12,
223
+ alignItems: "center"
224
+ },
225
+ ghostButtonText: {
226
+ fontSize: 15,
227
+ fontWeight: "500"
228
+ },
229
+ hint: {
230
+ fontSize: 12,
231
+ marginTop: 4,
232
+ textAlign: "center"
233
+ }
234
+ });
165
235
 
166
236
  // src/transport/webview-bridge.ts
167
237
  var import_utils3 = require("@moon-x/core/utils");
168
238
 
169
239
  // src/provider.tsx
170
- var import_react2 = require("@moon-x/core/react");
240
+ var import_react3 = require("@moon-x/core/react");
171
241
  var import_lib2 = require("@moon-x/core/lib");
172
- var import_jsx_runtime = require("react/jsx-runtime");
173
- var MoonXContext = (0, import_react.createContext)(null);
242
+
243
+ // src/session-resume.ts
244
+ var import_sdk10 = require("@moon-x/core/sdk");
245
+ var import_utils4 = require("@moon-x/core/utils");
246
+
247
+ // src/provider.tsx
248
+ var import_jsx_runtime2 = require("react/jsx-runtime");
249
+ var MoonXContext = (0, import_react2.createContext)(null);
174
250
  var useMoonXContext = () => {
175
- const ctx = (0, import_react.useContext)(MoonXContext);
251
+ const ctx = (0, import_react2.useContext)(MoonXContext);
176
252
  if (!ctx) {
177
253
  throw new Error("useMoonX must be used within a MoonXProvider");
178
254
  }
179
255
  return ctx;
180
256
  };
181
- var styles = import_react_native.StyleSheet.create({
257
+ var styles2 = import_react_native2.StyleSheet.create({
182
258
  backdrop: {
183
259
  position: "absolute",
184
260
  top: 0,
@@ -228,7 +304,7 @@ var styles = import_react_native.StyleSheet.create({
228
304
  paddingBottom: 12,
229
305
  paddingHorizontal: 16,
230
306
  backgroundColor: "#0a0a0a",
231
- borderBottomWidth: import_react_native.StyleSheet.hairlineWidth,
307
+ borderBottomWidth: import_react_native2.StyleSheet.hairlineWidth,
232
308
  borderBottomColor: "#222"
233
309
  },
234
310
  // Empty flex spacer keeps the close button right-aligned without
@@ -268,12 +344,12 @@ var useExportKey = () => {
268
344
  return {
269
345
  exportKey: async (wallet) => {
270
346
  try {
271
- const { userHandleB64url, credentialIdB64url, tokens } = await (0, import_sdk9.getInternalPresenceTokens)({
347
+ const { userHandleB64url, credentialIdB64url, tokens } = await (0, import_sdk11.getInternalPresenceTokens)({
272
348
  transport: _bridge,
273
349
  passkey: createRNPasskey(),
274
350
  publishableKey: sdk.publishableKey,
275
351
  relyingPartyOrigin: _relyingPartyOrigin,
276
- scopes: import_sdk9.SCOPES_EXPORT_KEY
352
+ scopes: import_sdk11.SCOPES_EXPORT_KEY
277
353
  });
278
354
  const keyshareReadToken = tokens.keyshare_read?.token ?? "";
279
355
  const keyExportToken = tokens.key_export?.token ?? "";
@@ -293,8 +369,8 @@ var useExportKey = () => {
293
369
  title: "Export key",
294
370
  flowPath: `/export-key?${params.toString()}#${secrets.toString()}`,
295
371
  onMount: ({ bridge, setResult }) => bridge.register(
296
- import_utils5.PostMessageType.WALLET,
297
- import_utils5.PostMessageMethod.EXPORT_KEY_RESULT,
372
+ import_utils6.PostMessageType.WALLET,
373
+ import_utils6.PostMessageMethod.EXPORT_KEY_RESULT,
298
374
  (result) => {
299
375
  setResult(parseExportKeyResult(result));
300
376
  }
package/dist/ethereum.mjs CHANGED
@@ -14,28 +14,30 @@ import {
14
14
 
15
15
  // src/hooks/use-export-key.ts
16
16
  import { getInternalPresenceTokens as getInternalPresenceTokens2, SCOPES_EXPORT_KEY } from "@moon-x/core/sdk";
17
- import { PostMessageMethod as PostMessageMethod4, PostMessageType as PostMessageType4 } from "@moon-x/core/utils";
17
+ import { PostMessageMethod as PostMessageMethod5, PostMessageType as PostMessageType5 } from "@moon-x/core/utils";
18
18
 
19
19
  // src/provider.tsx
20
20
  import {
21
21
  createContext,
22
22
  useCallback,
23
23
  useContext,
24
- useEffect,
24
+ useEffect as useEffect2,
25
+ useLayoutEffect,
25
26
  useMemo,
26
27
  useReducer,
27
- useRef,
28
- useState
28
+ useRef as useRef2,
29
+ useState as useState2,
30
+ useSyncExternalStore
29
31
  } from "react";
30
32
  import {
31
33
  Animated,
32
34
  AppState,
33
35
  Platform,
34
- Pressable,
35
- StyleSheet,
36
- Text,
36
+ Pressable as Pressable2,
37
+ StyleSheet as StyleSheet2,
38
+ Text as Text2,
37
39
  useWindowDimensions,
38
- View
40
+ View as View2
39
41
  } from "react-native";
40
42
  import { WebView } from "react-native-webview";
41
43
 
@@ -168,7 +170,84 @@ import {
168
170
  } from "@moon-x/core/sdk";
169
171
 
170
172
  // src/provider.tsx
171
- import { PostMessageMethod as PostMessageMethod3, PostMessageType as PostMessageType3 } from "@moon-x/core/utils";
173
+ import { PostMessageMethod as PostMessageMethod4, PostMessageType as PostMessageType4 } from "@moon-x/core/utils";
174
+
175
+ // src/components/presence-otp-prompt.tsx
176
+ import { useEffect, useRef, useState } from "react";
177
+ import {
178
+ Modal,
179
+ Pressable,
180
+ StyleSheet,
181
+ Text,
182
+ TextInput,
183
+ View
184
+ } from "react-native";
185
+ import { registerPresenceOtpCodeProvider } from "@moon-x/core/sdk";
186
+ import { jsx, jsxs } from "react/jsx-runtime";
187
+ var styles = StyleSheet.create({
188
+ backdrop: {
189
+ flex: 1,
190
+ alignItems: "center",
191
+ justifyContent: "center",
192
+ padding: 16,
193
+ backgroundColor: "rgba(0, 0, 0, 0.45)"
194
+ },
195
+ card: {
196
+ width: "100%",
197
+ maxWidth: 384,
198
+ padding: 24,
199
+ borderRadius: 14
200
+ },
201
+ title: {
202
+ fontSize: 20,
203
+ fontWeight: "600"
204
+ },
205
+ body: {
206
+ fontSize: 14,
207
+ marginTop: 8
208
+ },
209
+ input: {
210
+ marginTop: 16,
211
+ paddingVertical: 12,
212
+ paddingHorizontal: 16,
213
+ borderRadius: 12,
214
+ borderWidth: StyleSheet.hairlineWidth,
215
+ fontSize: 24,
216
+ letterSpacing: 8,
217
+ textAlign: "center"
218
+ },
219
+ error: {
220
+ fontSize: 13,
221
+ marginTop: 8
222
+ },
223
+ primaryButton: {
224
+ marginTop: 16,
225
+ paddingVertical: 12,
226
+ borderRadius: 12,
227
+ alignItems: "center"
228
+ },
229
+ primaryButtonDisabled: {
230
+ opacity: 0.5
231
+ },
232
+ primaryButtonText: {
233
+ fontSize: 16,
234
+ fontWeight: "600"
235
+ },
236
+ ghostButton: {
237
+ marginTop: 8,
238
+ paddingVertical: 12,
239
+ alignItems: "center"
240
+ },
241
+ ghostButtonText: {
242
+ fontSize: 15,
243
+ fontWeight: "500"
244
+ },
245
+ hint: {
246
+ fontSize: 12,
247
+ marginTop: 4,
248
+ textAlign: "center"
249
+ }
250
+ });
172
251
 
173
252
  // src/transport/webview-bridge.ts
174
253
  import {
@@ -180,7 +259,19 @@ import {
180
259
  // src/provider.tsx
181
260
  import { SDKProvider } from "@moon-x/core/react";
182
261
  import { validatePublishableKey } from "@moon-x/core/lib";
183
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
262
+
263
+ // src/session-resume.ts
264
+ import {
265
+ createSessionResumeKeyPair,
266
+ SESSION_RESUME_CHALLENGE_PATTERN,
267
+ SESSION_RESUME_SESSION_ID_PATTERN,
268
+ sessionResumePublicKeyOf,
269
+ signSessionResume
270
+ } from "@moon-x/core/sdk";
271
+ import { PostMessageMethod as PostMessageMethod3, PostMessageType as PostMessageType3 } from "@moon-x/core/utils";
272
+
273
+ // src/provider.tsx
274
+ import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
184
275
  var MoonXContext = createContext(null);
185
276
  var useMoonXContext = () => {
186
277
  const ctx = useContext(MoonXContext);
@@ -189,7 +280,7 @@ var useMoonXContext = () => {
189
280
  }
190
281
  return ctx;
191
282
  };
192
- var styles = StyleSheet.create({
283
+ var styles2 = StyleSheet2.create({
193
284
  backdrop: {
194
285
  position: "absolute",
195
286
  top: 0,
@@ -239,7 +330,7 @@ var styles = StyleSheet.create({
239
330
  paddingBottom: 12,
240
331
  paddingHorizontal: 16,
241
332
  backgroundColor: "#0a0a0a",
242
- borderBottomWidth: StyleSheet.hairlineWidth,
333
+ borderBottomWidth: StyleSheet2.hairlineWidth,
243
334
  borderBottomColor: "#222"
244
335
  },
245
336
  // Empty flex spacer keeps the close button right-aligned without
@@ -304,8 +395,8 @@ var useExportKey = () => {
304
395
  title: "Export key",
305
396
  flowPath: `/export-key?${params.toString()}#${secrets.toString()}`,
306
397
  onMount: ({ bridge, setResult }) => bridge.register(
307
- PostMessageType4.WALLET,
308
- PostMessageMethod4.EXPORT_KEY_RESULT,
398
+ PostMessageType5.WALLET,
399
+ PostMessageMethod5.EXPORT_KEY_RESULT,
309
400
  (result) => {
310
401
  setResult(parseExportKeyResult(result));
311
402
  }
package/dist/index.d.mts CHANGED
@@ -1,10 +1,10 @@
1
1
  import React, { ReactNode } from 'react';
2
- import { LoginWithMoonPayCustomerTokenResult, BulkImportKeySpec, BulkImportFailure, RegisterCreateWalletSpec, RegisterCreatedWallet, RelyingPartyOriginInput } from '@moon-x/core/sdk';
2
+ import { LoginWithMoonPayCustomerTokenResult, BulkImportKeySpec, BulkImportFailure, RegisterCreateWalletSpec, PresenceOtpCodeProvider, RegisterCreatedWallet, RelyingPartyOriginInput } from '@moon-x/core/sdk';
3
3
  export { LoginWithMoonPayCustomerTokenResult, MOONPAY_CONSUMER_SESSION_ERROR_CODES, MoonPayConsumerSessionError, MoonPayConsumerSessionErrorCode, PresenceOtpCodeProvider, PresenceOtpCodeRequest, RegisterCreateWalletSpec, RegisterCreatedWallet, registerPresenceOtpCodeProvider } from '@moon-x/core/sdk';
4
4
  import { PostMessageType, PostMessageMethod } from '@moon-x/core/utils';
5
5
  export { PostMessageMethod, PostMessageType } from '@moon-x/core/utils';
6
6
  import * as _moon_x_core_types from '@moon-x/core/types';
7
- import { GetSessionTokensOptions, PublicWallet, WalletImportSource, CustodyStateResult, PrepareSigningParams, PrepareSigningResult, PrepareFundingParams, FundingSession, EthereumSignMessageParams, EthereumSignMessageResult, EthereumSignTransactionParams, EthereumSignTransactionResult, EthereumSignTypedDataParams, EthereumSignTypedDataResult, EthereumSignHashParams, EthereumSignHashResult, EthereumSign7702AuthorizationParams, EthereumSign7702AuthorizationResult, EthereumSendTransactionParams, EthereumSendTransactionResult, EthereumGetBalanceParams, EthereumGetBalanceResult, SolanaSignMessageParams, SolanaSignMessageResult, SolanaSignTransactionParams, SolanaSignTransactionResult, SolanaSendTransactionParams, SolanaSendTransactionResult, SolanaGetBalanceParams, SolanaGetBalanceResult, SolanaGetTokenAccountsByOwnerParams, SolanaGetTokenAccountsByOwnerResult, TronSignMessageParams, TronSignMessageResult, TronSignTransactionParams, TronSignTransactionResult, TronSendTransactionParams, TronSendTransactionResult, TronGetBalanceParams, TronGetBalanceResult, BitcoinSignMessageParams, BitcoinSignMessageResult, BitcoinSignTransactionParams, BitcoinSignTransactionResult, BitcoinSendTransactionParams, BitcoinSendTransactionResult, BitcoinGetBalanceParams, BitcoinGetBalanceResult, BitcoinGetUtxosParams, BitcoinGetUtxosResult, AppConfigResponse } from '@moon-x/core/types';
7
+ import { GetSessionTokensOptions, PublicWallet, WalletImportSource, CustodyStateResult, PrepareSigningParams, PrepareSigningResult, PrepareFundingParams, FundingSession, EthereumSignMessageParams, EthereumSignMessageResult, EthereumSignTransactionParams, EthereumSignTransactionResult, EthereumSignTypedDataParams, EthereumSignTypedDataResult, EthereumSignHashParams, EthereumSignHashResult, EthereumSign7702AuthorizationParams, EthereumSign7702AuthorizationResult, EthereumSendTransactionParams, EthereumSendTransactionResult, EthereumSendTransactionsParams, EthereumSendTransactionsResult, EthereumSendBatchAtomicParams, EthereumSendBatchAtomicResult, EthereumGetBalanceParams, EthereumGetBalanceResult, SolanaSignMessageParams, SolanaSignMessageResult, SolanaSignTransactionParams, SolanaSignTransactionResult, SolanaSendTransactionParams, SolanaSendTransactionResult, SolanaGetBalanceParams, SolanaGetBalanceResult, SolanaGetTokenAccountsByOwnerParams, SolanaGetTokenAccountsByOwnerResult, TronSignMessageParams, TronSignMessageResult, TronSignTransactionParams, TronSignTransactionResult, TronSendTransactionParams, TronSendTransactionResult, TronGetBalanceParams, TronGetBalanceResult, BitcoinSignMessageParams, BitcoinSignMessageResult, BitcoinSignTransactionParams, BitcoinSignTransactionResult, BitcoinSendTransactionParams, BitcoinSendTransactionResult, BitcoinGetBalanceParams, BitcoinGetBalanceResult, BitcoinGetUtxosParams, BitcoinGetUtxosResult, AppConfigResponse } from '@moon-x/core/types';
8
8
  export { BitcoinGetBalanceParams, BitcoinGetBalanceResult, BitcoinGetUtxosParams, BitcoinGetUtxosResult, BitcoinSendTransactionParams, BitcoinSendTransactionResult, BitcoinSignMessageParams, BitcoinSignMessageResult, BitcoinSignTransactionParams, BitcoinSignTransactionResult, BitcoinTransactionPreview, BitcoinUtxo, Chain, EphemeralSigner, EphemeralSignerChain, EphemeralSignerScheme, EphemeralSignerWallet, EthereumGetBalanceParams, EthereumGetBalanceResult, EthereumSendTransactionParams, EthereumSendTransactionResult, EthereumSign7702AuthorizationParams, EthereumSign7702AuthorizationResult, EthereumSignHashParams, EthereumSignHashResult, EthereumSignMessageParams, EthereumSignMessageResult, EthereumSignTransactionParams, EthereumSignTransactionResult, EthereumSignTypedDataParams, EthereumSignTypedDataResult, FundingSession, ListEphemeralSignersResult, Network, PrepareFundingParams, PrepareSigningParams, PrepareSigningResult, PrepareSigningWalletResult, PrepareSigningWalletStatus, ProvisionEphemeralSignerParams, ProvisionEphemeralSignerResult, PublicWallet, RevokeEphemeralSignerParams, SolanaGetBalanceParams, SolanaGetBalanceResult, SolanaGetTokenAccountsByOwnerParams, SolanaGetTokenAccountsByOwnerResult, SolanaSendTransactionParams, SolanaSendTransactionResult, SolanaSignMessageParams, SolanaSignMessageResult, SolanaSignTransactionParams, SolanaSignTransactionResult, TronGetBalanceParams, TronGetBalanceResult, TronSendTransactionParams, TronSendTransactionResult, TronSignMessageParams, TronSignMessageResult, TronSignTransactionParams, TronSignTransactionResult, TronTransactionJson, WalletConnectConfig } from '@moon-x/core/types';
9
9
  import * as _moon_x_core_react from '@moon-x/core/react';
10
10
  import { UseLoginWithEmailCallbacks } from '@moon-x/core/react';
@@ -12,6 +12,31 @@ export { LinkEmailResult, LinkEmailState, LoginWithEmailState, UseEphemeralSigne
12
12
  export { E as ExportKeyResult, u as useExportKey } from './use-export-key-BIz_tV0k.mjs';
13
13
  import { WalletConnectClientLike, WalletConnectSessionLike } from '@moon-x/core/lib';
14
14
 
15
+ interface PresenceOtpPromptCopy {
16
+ title?: string;
17
+ description?: string;
18
+ hint?: string;
19
+ verify?: string;
20
+ verifying?: string;
21
+ cancel?: string;
22
+ invalidCode?: string;
23
+ incompleteCode?: string;
24
+ }
25
+ interface PresenceOtpPromptColors {
26
+ background?: string;
27
+ surface?: string;
28
+ border?: string;
29
+ text?: string;
30
+ mutedText?: string;
31
+ accent?: string;
32
+ accentText?: string;
33
+ error?: string;
34
+ }
35
+ interface PresenceOtpPromptOptions {
36
+ copy?: PresenceOtpPromptCopy;
37
+ colors?: PresenceOtpPromptColors;
38
+ }
39
+
15
40
  type ResponseErrorListener = (error: Error, context: {
16
41
  type: PostMessageType;
17
42
  method: string;
@@ -45,6 +70,8 @@ declare class WebViewBridge {
45
70
  cleanup(reason?: string): void;
46
71
  }
47
72
 
73
+ /** Session restoration outcome, independent of WebView readiness. */
74
+ type SessionStatus = "restoring" | "authenticated" | "signed-out" | "error";
48
75
  interface RNAuthSDK {
49
76
  publishableKey: string;
50
77
  ready: boolean;
@@ -78,6 +105,11 @@ interface RNAuthSDK {
78
105
  token?: string;
79
106
  state?: string;
80
107
  }) => Promise<any>;
108
+ /** The latest session check. Errors preserve the last confirmed authentication state. */
109
+ sessionStatus: SessionStatus;
110
+ sessionError: Error | null;
111
+ /** Restart bounded restoration attempts. Repeated calls share an active check. */
112
+ retrySession: () => void;
81
113
  isAuthenticated: boolean;
82
114
  user: any | null;
83
115
  revalidatedAt: number;
@@ -168,6 +200,7 @@ interface RNAuthSDK {
168
200
  registerPasskey: (params?: {
169
201
  displayName?: string;
170
202
  createWallets?: RegisterCreateWalletSpec[];
203
+ requestOtpCode?: PresenceOtpCodeProvider;
171
204
  }) => Promise<{
172
205
  credential_id: string;
173
206
  passkey_registered: true;
@@ -176,6 +209,7 @@ interface RNAuthSDK {
176
209
  }>;
177
210
  addPasskey: (params?: {
178
211
  displayName?: string;
212
+ requestOtpCode?: PresenceOtpCodeProvider;
179
213
  }) => Promise<{
180
214
  credential_id: string;
181
215
  passkey_registered: true;
@@ -191,6 +225,8 @@ interface RNAuthSDK {
191
225
  signEthereumHashHeadless: (params: EthereumSignHashParams) => Promise<EthereumSignHashResult>;
192
226
  signEthereum7702AuthorizationHeadless: (params: EthereumSign7702AuthorizationParams) => Promise<EthereumSign7702AuthorizationResult>;
193
227
  sendEthereumTransactionHeadless: (params: EthereumSendTransactionParams) => Promise<EthereumSendTransactionResult>;
228
+ sendEthereumTransactionsHeadless: (params: EthereumSendTransactionsParams) => Promise<EthereumSendTransactionsResult>;
229
+ sendEthereumBatchAtomicHeadless: (params: EthereumSendBatchAtomicParams) => Promise<EthereumSendBatchAtomicResult>;
194
230
  getEthereumBalance: (params: EthereumGetBalanceParams) => Promise<EthereumGetBalanceResult>;
195
231
  signSolanaMessageHeadless: (params: SolanaSignMessageParams) => Promise<SolanaSignMessageResult>;
196
232
  signSolanaTransactionHeadless: (params: SolanaSignTransactionParams) => Promise<SolanaSignTransactionResult>;
@@ -208,6 +244,61 @@ interface RNAuthSDK {
208
244
  getBitcoinUtxos: (params: BitcoinGetUtxosParams) => Promise<BitcoinGetUtxosResult>;
209
245
  }
210
246
 
247
+ interface NativeSessionSnapshot {
248
+ isAuthenticated: boolean;
249
+ user: unknown | null;
250
+ revalidatedAt: number;
251
+ sessionStatus: SessionStatus;
252
+ sessionError: Error | null;
253
+ }
254
+ interface SessionReads {
255
+ getCurrentSession: () => Promise<unknown>;
256
+ getUser: () => Promise<unknown>;
257
+ /**
258
+ * Tries to bring back a session the iframe lost. True when the iframe now
259
+ * has one, false when resume does not apply. Throws on transient failures.
260
+ */
261
+ resume?: () => Promise<boolean>;
262
+ }
263
+ /** Owns native restoration and the eligibility of asynchronous state writes. */
264
+ declare function createNativeSession(reads: SessionReads): {
265
+ getSnapshot: () => NativeSessionSnapshot;
266
+ subscribe: (listener: () => void) => () => void;
267
+ mount: () => void;
268
+ unmount: () => void;
269
+ setReady: (value: boolean) => void;
270
+ retrySession: () => void;
271
+ /** Replaces an active check: a suspended WebView can drop requests it had in flight. */
272
+ restartSession: () => void;
273
+ beginAuthFlow: ({ replaceSession }?: {
274
+ replaceSession?: boolean;
275
+ }) => (() => void) & {
276
+ assertCurrent: () => void;
277
+ };
278
+ captureUserWrite: () => (user: unknown) => void;
279
+ captureUserRefresh: () => () => Promise<void>;
280
+ refreshUser: () => Promise<void>;
281
+ beginAuthOperation: () => {
282
+ finish: (() => void) & {
283
+ assertCurrent: () => void;
284
+ };
285
+ setIsAuthenticated: (value: boolean) => void;
286
+ refreshUser: () => Promise<void>;
287
+ };
288
+ };
289
+ type NativeSession = ReturnType<typeof createNativeSession>;
290
+
291
+ /**
292
+ * Secure key-value storage for the resume key, such as expo-secure-store or
293
+ * react-native-keychain. Values are small strings. The stored key can resume
294
+ * the session, so use device-only storage: not synced, not backed up.
295
+ */
296
+ interface SessionResumeStorage {
297
+ getItem: (key: string) => Promise<string | null>;
298
+ setItem: (key: string, value: string) => Promise<void>;
299
+ removeItem: (key: string) => Promise<void>;
300
+ }
301
+
211
302
  interface MoonXConfig {
212
303
  /**
213
304
  * Iframe URL the WebView loads. Optional — defaults to the MoonX
@@ -242,6 +333,14 @@ interface MoonXConfig {
242
333
  sensitiveModalCopy?: {
243
334
  closeLabel?: string;
244
335
  };
336
+ /**
337
+ * Built-in prompt for the emailed step-up code that identity-backed users
338
+ * without a passkey need for lifecycle operations (add a passkey, export a
339
+ * key). Pass copy or colors to restyle it, or `false` when the app
340
+ * registers its own provider with `registerPresenceOtpCodeProvider`.
341
+ * A method call with `requestOtpCode` always bypasses it.
342
+ */
343
+ presenceOtpPrompt?: false | PresenceOtpPromptOptions;
245
344
  /**
246
345
  * Reserved for future per-app security knobs. Currently no fields —
247
346
  * the previously-configurable `assertionCacheTtlMs` was removed
@@ -249,6 +348,16 @@ interface MoonXConfig {
249
348
  * now drives a fresh WebAuthn ceremony, no cache to configure).
250
349
  */
251
350
  security?: Record<string, never>;
351
+ /**
352
+ * Secure storage that lets the SDK restore a session the WebView lost.
353
+ * iOS can delete WebView storage, including the refresh token, while the
354
+ * session is still valid. With this set, the SDK keeps a resume key here
355
+ * (never a token) and silently restores the session on the next launch,
356
+ * within its original expiry. Pass an adapter over Keychain/Keystore, such
357
+ * as expo-secure-store; keep the object stable across renders. Requires
358
+ * session resume to be enabled for the app.
359
+ */
360
+ sessionResumeStorage?: SessionResumeStorage;
252
361
  }
253
362
  interface MoonXProviderProps {
254
363
  publishableKey: string;
@@ -299,7 +408,7 @@ interface MoonXContextValue {
299
408
  _relyingPartyOrigin: RelyingPartyOriginInput;
300
409
  _runSensitiveFlow: (options: SensitiveFlowOptions) => Promise<SensitiveFlowResult>;
301
410
  _oauthRedirectUri?: string;
302
- _beginAuthFlow: () => () => void;
411
+ _beginAuthFlow: NativeSession["beginAuthFlow"];
303
412
  }
304
413
  declare const MoonXProvider: React.FC<MoonXProviderProps>;
305
414
  declare const useMoonXContext: () => MoonXContextValue;
@@ -482,4 +591,4 @@ declare const restoreWalletConnectSession: (options: Omit<ConnectWalletConnectOp
482
591
  topic: string;
483
592
  }) => ConnectedExternalWallet;
484
593
 
485
- export { type ConnectWalletConnectOptions, type ConnectedExternalWallet, type ExternalWalletAccount, type ExternalWalletChain, type ExternalWalletConnector, type ExternalWalletInfo, type ExternalWalletStatus, MoonXProvider as MoonKeyProvider, type MoonXConfig, MoonXProvider, type MoonXProviderProps, type RNAuthSDK, type WalletConnectPairing, connectWalletConnect, listWalletConnectSessions, restoreWalletConnectSession, useAppConfig, useAttachOAuth, useDetachOAuth, useExternalWallets, useFundWallet, useLoginWithEmail, useLoginWithOAuth, useMoonX as useMoonKey, useMoonX, useMoonXContext };
594
+ export { type ConnectWalletConnectOptions, type ConnectedExternalWallet, type ExternalWalletAccount, type ExternalWalletChain, type ExternalWalletConnector, type ExternalWalletInfo, type ExternalWalletStatus, MoonXProvider as MoonKeyProvider, type MoonXConfig, MoonXProvider, type MoonXProviderProps, type PresenceOtpPromptColors, type PresenceOtpPromptCopy, type PresenceOtpPromptOptions, type RNAuthSDK, type SessionResumeStorage, type SessionStatus, type WalletConnectPairing, connectWalletConnect, listWalletConnectSessions, restoreWalletConnectSession, useAppConfig, useAttachOAuth, useDetachOAuth, useExternalWallets, useFundWallet, useLoginWithEmail, useLoginWithOAuth, useMoonX as useMoonKey, useMoonX, useMoonXContext };