@moon-x/react-native-sdk 0.17.0 → 0.18.1

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
@@ -78,7 +78,7 @@ export default function Root() {
78
78
  <MoonXProvider
79
79
  publishableKey={process.env.EXPO_PUBLIC_MOONX_PUBLISHABLE_KEY!}
80
80
  config={{
81
- iframeUrl: "https://iframe.moonx-dev.com",
81
+ iframeUrl: "https://x-iframe.moonpay.com",
82
82
  oauthRedirectUri: "myapp://oauth-callback",
83
83
  }}
84
84
  >
@@ -143,6 +143,46 @@ failures. Callers that poll it directly should catch those failures and retain
143
143
  their last-known auth state rather than treating an unavailable WebView as a
144
144
  logout. This distinction was introduced with `@moon-x/core` 0.15.0.
145
145
 
146
+ #### MoonPay Consumer session exchange
147
+
148
+ Use `loginWithMoonPayCustomerToken` when the native application already has a
149
+ MoonPay Consumer `customerToken`. The SDK exchanges the token for a MoonX
150
+ session. The WebView stores the session credentials. The method returns only
151
+ `userCreated`.
152
+
153
+ ```ts
154
+ import {
155
+ MOONPAY_CONSUMER_SESSION_ERROR_CODES,
156
+ type MoonPayConsumerSessionError,
157
+ useMoonX,
158
+ } from "@moon-x/react-native-sdk";
159
+
160
+ const { loginWithMoonPayCustomerToken } = useMoonX();
161
+
162
+ try {
163
+ const { userCreated } = await loginWithMoonPayCustomerToken({
164
+ customerToken,
165
+ });
166
+ } catch (error) {
167
+ const code = (error as MoonPayConsumerSessionError).error_code;
168
+ if (code === MOONPAY_CONSUMER_SESSION_ERROR_CODES.SESSION_INVALID) {
169
+ // Get a new Consumer token and try again.
170
+ }
171
+ }
172
+ ```
173
+
174
+ The promise resolves after the MoonX session is stored. At that time,
175
+ `isAuthenticated` is `true`. The SDK then loads the user profile in the
176
+ background. Thus, `user` can be `null` for a short time. It can also stay
177
+ `null` if the profile request fails. Use `refreshUser` when the application
178
+ must have the profile.
179
+
180
+ The WebView uses its configured publishable key for the backend exchange. It
181
+ rejects the request if the key in the native message does not match that key.
182
+ A `401` response from the backend becomes the stable
183
+ `moonpay_consumer_session_invalid` error code. Do not parse HTTP status numbers
184
+ from error messages.
185
+
146
186
  The provider revalidates its hidden-WebView session on cold start and whenever
147
187
  the native app returns to the foreground. `revalidatedAt` advances after each
148
188
  probe so shared wallet hooks refresh app-owned wallet state.
@@ -235,6 +275,20 @@ const ethereumWallet = await importEthereum(privateKey);
235
275
  await exportEthereum({ wallet: ethereumWallet });
236
276
  ```
237
277
 
278
+ ### Ephemeral signer list status
279
+
280
+ `useEphemeralSigner().signers` includes non-revoked signers with status `active`,
281
+ `needs_reauth`, or `expired`. Expired signers remain visible and can be revoked.
282
+ Provision a fresh signer for `needs_reauth` or `expired`.
283
+
284
+ Older backends can omit `status`. The SDK preserves their responses. Inspect
285
+ `expires_at` and handle signing errors instead of treating a missing status as
286
+ proof that a signer is usable.
287
+
288
+ Before the backend starts returning `expired`, update exhaustive status handling
289
+ and runtime validators in your application. Updating the SDK alone does not change
290
+ application logic. Rebuild and distribute the updated mobile application to its users.
291
+
238
292
  ### Per-chain wallets and signing — `/ethereum`, `/solana`, and `/tron`
239
293
 
240
294
  Chain-aware hooks live under subpaths so they don't pull in the other chain's adapters if you only use one — same pattern as `@moon-x/react-sdk`:
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import React, { ReactNode } from 'react';
2
- import { BulkImportFailure, RegisterCreateWalletSpec, RegisterCreatedWallet, RelyingPartyOriginInput } from '@moon-x/core/sdk';
3
- export { RegisterCreateWalletSpec, RegisterCreatedWallet } from '@moon-x/core/sdk';
2
+ import { LoginWithMoonPayCustomerTokenResult, BulkImportFailure, RegisterCreateWalletSpec, RegisterCreatedWallet, RelyingPartyOriginInput } from '@moon-x/core/sdk';
3
+ export { LoginWithMoonPayCustomerTokenResult, MOONPAY_CONSUMER_SESSION_ERROR_CODES, MoonPayConsumerSessionError, MoonPayConsumerSessionErrorCode, RegisterCreateWalletSpec, RegisterCreatedWallet } 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';
@@ -55,6 +55,16 @@ interface RNAuthSDK {
55
55
  loginWithCode: (params: {
56
56
  code: string;
57
57
  }) => Promise<void>;
58
+ /**
59
+ * Exchange a MoonPay Consumer token for a MoonX session.
60
+ *
61
+ * The promise resolves after the session is stored and
62
+ * `isAuthenticated` is true. The user profile loads separately, so `user`
63
+ * can be null for a short time or until a later profile retry succeeds.
64
+ */
65
+ loginWithMoonPayCustomerToken: (params: {
66
+ customerToken: string;
67
+ }) => Promise<LoginWithMoonPayCustomerTokenResult>;
58
68
  sendEmailLinkCode: (params: {
59
69
  email: string;
60
70
  }) => Promise<_moon_x_core_types.LinkEmailBeginResponse>;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import React, { ReactNode } from 'react';
2
- import { BulkImportFailure, RegisterCreateWalletSpec, RegisterCreatedWallet, RelyingPartyOriginInput } from '@moon-x/core/sdk';
3
- export { RegisterCreateWalletSpec, RegisterCreatedWallet } from '@moon-x/core/sdk';
2
+ import { LoginWithMoonPayCustomerTokenResult, BulkImportFailure, RegisterCreateWalletSpec, RegisterCreatedWallet, RelyingPartyOriginInput } from '@moon-x/core/sdk';
3
+ export { LoginWithMoonPayCustomerTokenResult, MOONPAY_CONSUMER_SESSION_ERROR_CODES, MoonPayConsumerSessionError, MoonPayConsumerSessionErrorCode, RegisterCreateWalletSpec, RegisterCreatedWallet } 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';
@@ -55,6 +55,16 @@ interface RNAuthSDK {
55
55
  loginWithCode: (params: {
56
56
  code: string;
57
57
  }) => Promise<void>;
58
+ /**
59
+ * Exchange a MoonPay Consumer token for a MoonX session.
60
+ *
61
+ * The promise resolves after the session is stored and
62
+ * `isAuthenticated` is true. The user profile loads separately, so `user`
63
+ * can be null for a short time or until a later profile retry succeeds.
64
+ */
65
+ loginWithMoonPayCustomerToken: (params: {
66
+ customerToken: string;
67
+ }) => Promise<LoginWithMoonPayCustomerTokenResult>;
58
68
  sendEmailLinkCode: (params: {
59
69
  email: string;
60
70
  }) => Promise<_moon_x_core_types.LinkEmailBeginResponse>;
package/dist/index.js CHANGED
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.ts
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
+ MOONPAY_CONSUMER_SESSION_ERROR_CODES: () => import_sdk9.MOONPAY_CONSUMER_SESSION_ERROR_CODES,
33
34
  MoonKeyProvider: () => MoonXProvider,
34
35
  MoonXProvider: () => MoonXProvider,
35
36
  PostMessageMethod: () => import_utils10.PostMessageMethod,
@@ -736,7 +737,7 @@ var createSessionRevalidationGate = () => {
736
737
 
737
738
  // src/provider.tsx
738
739
  var import_jsx_runtime = require("react/jsx-runtime");
739
- var DEFAULT_IFRAME_URL = "https://iframe.moonx-dev.com";
740
+ var DEFAULT_IFRAME_URL = "https://x-iframe.moonpay.com";
740
741
  var MoonXContext = (0, import_react.createContext)(null);
741
742
  var MoonXProvider = ({
742
743
  publishableKey,
@@ -1865,9 +1866,11 @@ var restoreWalletConnectSession = (options) => {
1865
1866
  };
1866
1867
 
1867
1868
  // src/index.ts
1869
+ var import_sdk9 = require("@moon-x/core/sdk");
1868
1870
  var import_utils10 = require("@moon-x/core/utils");
1869
1871
  // Annotate the CommonJS export names for ESM import in node:
1870
1872
  0 && (module.exports = {
1873
+ MOONPAY_CONSUMER_SESSION_ERROR_CODES,
1871
1874
  MoonKeyProvider,
1872
1875
  MoonXProvider,
1873
1876
  PostMessageMethod,
package/dist/index.mjs CHANGED
@@ -709,7 +709,7 @@ var createSessionRevalidationGate = () => {
709
709
 
710
710
  // src/provider.tsx
711
711
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
712
- var DEFAULT_IFRAME_URL = "https://iframe.moonx-dev.com";
712
+ var DEFAULT_IFRAME_URL = "https://x-iframe.moonpay.com";
713
713
  var MoonXContext = createContext(null);
714
714
  var MoonXProvider = ({
715
715
  publishableKey,
@@ -1859,8 +1859,10 @@ var restoreWalletConnectSession = (options) => {
1859
1859
  };
1860
1860
 
1861
1861
  // src/index.ts
1862
+ import { MOONPAY_CONSUMER_SESSION_ERROR_CODES } from "@moon-x/core/sdk";
1862
1863
  import { PostMessageMethod as PostMessageMethod9, PostMessageType as PostMessageType9 } from "@moon-x/core/utils";
1863
1864
  export {
1865
+ MOONPAY_CONSUMER_SESSION_ERROR_CODES,
1864
1866
  MoonXProvider as MoonKeyProvider,
1865
1867
  MoonXProvider,
1866
1868
  PostMessageMethod9 as PostMessageMethod,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moon-x/react-native-sdk",
3
- "version": "0.17.0",
3
+ "version": "0.18.1",
4
4
  "description": "Headless MoonX React Native SDK with WebView-backed transport, native passkeys, and app-owned UI.",
5
5
  "license": "UNLICENSED",
6
6
  "main": "dist/index.js",
@@ -57,7 +57,7 @@
57
57
  "vitest": "4.1.0"
58
58
  },
59
59
  "dependencies": {
60
- "@moon-x/core": "0.21.0"
60
+ "@moon-x/core": "0.25.0"
61
61
  },
62
62
  "peerDependencies": {
63
63
  "@expo/config-plugins": ">=10.0.0",