@moon-x/react-native-sdk 0.16.0 → 0.18.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 +55 -1
- package/dist/index.d.mts +20 -3
- package/dist/index.d.ts +20 -3
- package/dist/index.js +6 -1
- package/dist/index.mjs +5 -1
- package/package.json +2 -2
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.
|
|
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 { 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';
|
|
@@ -8,7 +8,7 @@ import { PublicWallet, WalletImportSource, PrepareFundingParams, FundingSession,
|
|
|
8
8
|
export { Chain, EphemeralSigner, EphemeralSignerChain, EphemeralSignerScheme, EphemeralSignerWallet, EthereumGetBalanceParams, EthereumGetBalanceResult, EthereumSendTransactionParams, EthereumSendTransactionResult, EthereumSign7702AuthorizationParams, EthereumSign7702AuthorizationResult, EthereumSignHashParams, EthereumSignHashResult, EthereumSignMessageParams, EthereumSignMessageResult, EthereumSignTransactionParams, EthereumSignTransactionResult, EthereumSignTypedDataParams, EthereumSignTypedDataResult, FundingSession, ListEphemeralSignersResult, Network, PrepareFundingParams, 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';
|
|
11
|
-
export { LinkEmailResult, LinkEmailState, LoginWithEmailState, UseEphemeralSignerResult, UseLinkEmailCallbacks, UseLoginWithEmailCallbacks, useAddPasskey, useCreateWallet, useEphemeralSigner, useImportKey, useLinkEmail, useLogout, usePasskeyStatus, useRegisterPasskey, useRemovePasskey, useUser, useWallets } from '@moon-x/core/react';
|
|
11
|
+
export { LinkEmailResult, LinkEmailState, LoginWithEmailState, UseEphemeralSignerResult, UseLinkEmailCallbacks, UseLoginWithEmailCallbacks, useAddPasskey, useBulkImport, useCreateWallet, useEphemeralSigner, useImportKey, useLinkEmail, useLogout, usePasskeyStatus, useRegisterPasskey, useRemovePasskey, useUser, useWallets } from '@moon-x/core/react';
|
|
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
|
|
|
@@ -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>;
|
|
@@ -110,6 +120,13 @@ interface RNAuthSDK {
|
|
|
110
120
|
importKey: (walletType: "solana" | "ethereum" | "tron", source: string | WalletImportSource) => Promise<{
|
|
111
121
|
wallet: PublicWallet;
|
|
112
122
|
}>;
|
|
123
|
+
bulkImport: (keys: Array<{
|
|
124
|
+
chain: "solana" | "ethereum" | "tron";
|
|
125
|
+
source: string | WalletImportSource;
|
|
126
|
+
}>) => Promise<{
|
|
127
|
+
wallets: PublicWallet[];
|
|
128
|
+
failures: BulkImportFailure[];
|
|
129
|
+
}>;
|
|
113
130
|
getWallets: (walletType: "solana" | "ethereum" | "tron") => Promise<{
|
|
114
131
|
wallets: any[];
|
|
115
132
|
walletType: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
|
-
import { 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';
|
|
@@ -8,7 +8,7 @@ import { PublicWallet, WalletImportSource, PrepareFundingParams, FundingSession,
|
|
|
8
8
|
export { Chain, EphemeralSigner, EphemeralSignerChain, EphemeralSignerScheme, EphemeralSignerWallet, EthereumGetBalanceParams, EthereumGetBalanceResult, EthereumSendTransactionParams, EthereumSendTransactionResult, EthereumSign7702AuthorizationParams, EthereumSign7702AuthorizationResult, EthereumSignHashParams, EthereumSignHashResult, EthereumSignMessageParams, EthereumSignMessageResult, EthereumSignTransactionParams, EthereumSignTransactionResult, EthereumSignTypedDataParams, EthereumSignTypedDataResult, FundingSession, ListEphemeralSignersResult, Network, PrepareFundingParams, 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';
|
|
11
|
-
export { LinkEmailResult, LinkEmailState, LoginWithEmailState, UseEphemeralSignerResult, UseLinkEmailCallbacks, UseLoginWithEmailCallbacks, useAddPasskey, useCreateWallet, useEphemeralSigner, useImportKey, useLinkEmail, useLogout, usePasskeyStatus, useRegisterPasskey, useRemovePasskey, useUser, useWallets } from '@moon-x/core/react';
|
|
11
|
+
export { LinkEmailResult, LinkEmailState, LoginWithEmailState, UseEphemeralSignerResult, UseLinkEmailCallbacks, UseLoginWithEmailCallbacks, useAddPasskey, useBulkImport, useCreateWallet, useEphemeralSigner, useImportKey, useLinkEmail, useLogout, usePasskeyStatus, useRegisterPasskey, useRemovePasskey, useUser, useWallets } from '@moon-x/core/react';
|
|
12
12
|
export { E as ExportKeyResult, u as useExportKey } from './use-export-key-BIz_tV0k.js';
|
|
13
13
|
import { WalletConnectClientLike, WalletConnectSessionLike } from '@moon-x/core/lib';
|
|
14
14
|
|
|
@@ -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>;
|
|
@@ -110,6 +120,13 @@ interface RNAuthSDK {
|
|
|
110
120
|
importKey: (walletType: "solana" | "ethereum" | "tron", source: string | WalletImportSource) => Promise<{
|
|
111
121
|
wallet: PublicWallet;
|
|
112
122
|
}>;
|
|
123
|
+
bulkImport: (keys: Array<{
|
|
124
|
+
chain: "solana" | "ethereum" | "tron";
|
|
125
|
+
source: string | WalletImportSource;
|
|
126
|
+
}>) => Promise<{
|
|
127
|
+
wallets: PublicWallet[];
|
|
128
|
+
failures: BulkImportFailure[];
|
|
129
|
+
}>;
|
|
113
130
|
getWallets: (walletType: "solana" | "ethereum" | "tron") => Promise<{
|
|
114
131
|
wallets: any[];
|
|
115
132
|
walletType: string;
|
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,
|
|
@@ -40,6 +41,7 @@ __export(index_exports, {
|
|
|
40
41
|
useAddPasskey: () => import_react8.useAddPasskey,
|
|
41
42
|
useAppConfig: () => useAppConfig,
|
|
42
43
|
useAttachOAuth: () => useAttachOAuth,
|
|
44
|
+
useBulkImport: () => import_react8.useBulkImport,
|
|
43
45
|
useCreateWallet: () => import_react8.useCreateWallet,
|
|
44
46
|
useDetachOAuth: () => useDetachOAuth,
|
|
45
47
|
useEphemeralSigner: () => import_react8.useEphemeralSigner,
|
|
@@ -735,7 +737,7 @@ var createSessionRevalidationGate = () => {
|
|
|
735
737
|
|
|
736
738
|
// src/provider.tsx
|
|
737
739
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
738
|
-
var DEFAULT_IFRAME_URL = "https://iframe.
|
|
740
|
+
var DEFAULT_IFRAME_URL = "https://x-iframe.moonpay.com";
|
|
739
741
|
var MoonXContext = (0, import_react.createContext)(null);
|
|
740
742
|
var MoonXProvider = ({
|
|
741
743
|
publishableKey,
|
|
@@ -1864,9 +1866,11 @@ var restoreWalletConnectSession = (options) => {
|
|
|
1864
1866
|
};
|
|
1865
1867
|
|
|
1866
1868
|
// src/index.ts
|
|
1869
|
+
var import_sdk9 = require("@moon-x/core/sdk");
|
|
1867
1870
|
var import_utils10 = require("@moon-x/core/utils");
|
|
1868
1871
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1869
1872
|
0 && (module.exports = {
|
|
1873
|
+
MOONPAY_CONSUMER_SESSION_ERROR_CODES,
|
|
1870
1874
|
MoonKeyProvider,
|
|
1871
1875
|
MoonXProvider,
|
|
1872
1876
|
PostMessageMethod,
|
|
@@ -1877,6 +1881,7 @@ var import_utils10 = require("@moon-x/core/utils");
|
|
|
1877
1881
|
useAddPasskey,
|
|
1878
1882
|
useAppConfig,
|
|
1879
1883
|
useAttachOAuth,
|
|
1884
|
+
useBulkImport,
|
|
1880
1885
|
useCreateWallet,
|
|
1881
1886
|
useDetachOAuth,
|
|
1882
1887
|
useEphemeralSigner,
|
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.
|
|
712
|
+
var DEFAULT_IFRAME_URL = "https://x-iframe.moonpay.com";
|
|
713
713
|
var MoonXContext = createContext(null);
|
|
714
714
|
var MoonXProvider = ({
|
|
715
715
|
publishableKey,
|
|
@@ -1179,6 +1179,7 @@ var styles = StyleSheet.create({
|
|
|
1179
1179
|
// src/hooks/index.ts
|
|
1180
1180
|
import {
|
|
1181
1181
|
useAddPasskey,
|
|
1182
|
+
useBulkImport,
|
|
1182
1183
|
useCreateWallet,
|
|
1183
1184
|
useEphemeralSigner,
|
|
1184
1185
|
useImportKey,
|
|
@@ -1858,8 +1859,10 @@ var restoreWalletConnectSession = (options) => {
|
|
|
1858
1859
|
};
|
|
1859
1860
|
|
|
1860
1861
|
// src/index.ts
|
|
1862
|
+
import { MOONPAY_CONSUMER_SESSION_ERROR_CODES } from "@moon-x/core/sdk";
|
|
1861
1863
|
import { PostMessageMethod as PostMessageMethod9, PostMessageType as PostMessageType9 } from "@moon-x/core/utils";
|
|
1862
1864
|
export {
|
|
1865
|
+
MOONPAY_CONSUMER_SESSION_ERROR_CODES,
|
|
1863
1866
|
MoonXProvider as MoonKeyProvider,
|
|
1864
1867
|
MoonXProvider,
|
|
1865
1868
|
PostMessageMethod9 as PostMessageMethod,
|
|
@@ -1870,6 +1873,7 @@ export {
|
|
|
1870
1873
|
useAddPasskey,
|
|
1871
1874
|
useAppConfig,
|
|
1872
1875
|
useAttachOAuth,
|
|
1876
|
+
useBulkImport,
|
|
1873
1877
|
useCreateWallet,
|
|
1874
1878
|
useDetachOAuth,
|
|
1875
1879
|
useEphemeralSigner,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moon-x/react-native-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
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.
|
|
60
|
+
"@moon-x/core": "0.24.0"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
63
|
"@expo/config-plugins": ">=10.0.0",
|