@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 +105 -5
- package/dist/ethereum.js +91 -15
- package/dist/ethereum.mjs +105 -14
- package/dist/index.d.mts +113 -4
- package/dist/index.d.ts +113 -4
- package/dist/index.js +1117 -254
- package/dist/index.mjs +1091 -213
- package/dist/solana.js +91 -15
- package/dist/solana.mjs +105 -14
- package/dist/tron.js +91 -15
- package/dist/tron.mjs +105 -14
- package/package.json +3 -2
package/dist/index.d.ts
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.js';
|
|
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:
|
|
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 };
|