@moon-x/react-native-sdk 0.24.0 → 0.26.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 +120 -4
- package/dist/index.d.ts +120 -4
- package/dist/index.js +1127 -254
- package/dist/index.mjs +1101 -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,5 +1,5 @@
|
|
|
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';
|
|
@@ -8,10 +8,35 @@ import { GetSessionTokensOptions, PublicWallet, WalletImportSource, CustodyState
|
|
|
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';
|
|
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';
|
|
11
|
+
export { ChangeEmailResult, ChangeEmailState, ChangeEmailStep, LinkEmailResult, LinkEmailState, LoginWithEmailState, UseChangeEmailCallbacks, UseEphemeralSignerResult, UseLinkEmailCallbacks, UseLoginWithEmailCallbacks, useAddPasskey, useBulkImport, useChangeEmail, 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
|
|
|
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;
|
|
@@ -72,12 +99,26 @@ interface RNAuthSDK {
|
|
|
72
99
|
email: string;
|
|
73
100
|
code: string;
|
|
74
101
|
}) => Promise<_moon_x_core_types.LinkEmailVerifyResponse>;
|
|
102
|
+
sendEmailChangeCode: (params: {
|
|
103
|
+
email: string;
|
|
104
|
+
}) => Promise<_moon_x_core_types.ChangeEmailStepResponse>;
|
|
105
|
+
confirmEmailChangeCurrentCode: (params: {
|
|
106
|
+
code: string;
|
|
107
|
+
}) => Promise<_moon_x_core_types.ChangeEmailStepResponse>;
|
|
108
|
+
confirmEmailChangeNewCode: (params: {
|
|
109
|
+
code: string;
|
|
110
|
+
}) => Promise<_moon_x_core_types.ChangeEmailVerifyResponse>;
|
|
75
111
|
verifyOAuth: (params: {
|
|
76
112
|
provider: "google" | "apple";
|
|
77
113
|
code?: string;
|
|
78
114
|
token?: string;
|
|
79
115
|
state?: string;
|
|
80
116
|
}) => Promise<any>;
|
|
117
|
+
/** The latest session check. Errors preserve the last confirmed authentication state. */
|
|
118
|
+
sessionStatus: SessionStatus;
|
|
119
|
+
sessionError: Error | null;
|
|
120
|
+
/** Restart bounded restoration attempts. Repeated calls share an active check. */
|
|
121
|
+
retrySession: () => void;
|
|
81
122
|
isAuthenticated: boolean;
|
|
82
123
|
user: any | null;
|
|
83
124
|
revalidatedAt: number;
|
|
@@ -168,6 +209,7 @@ interface RNAuthSDK {
|
|
|
168
209
|
registerPasskey: (params?: {
|
|
169
210
|
displayName?: string;
|
|
170
211
|
createWallets?: RegisterCreateWalletSpec[];
|
|
212
|
+
requestOtpCode?: PresenceOtpCodeProvider;
|
|
171
213
|
}) => Promise<{
|
|
172
214
|
credential_id: string;
|
|
173
215
|
passkey_registered: true;
|
|
@@ -176,6 +218,7 @@ interface RNAuthSDK {
|
|
|
176
218
|
}>;
|
|
177
219
|
addPasskey: (params?: {
|
|
178
220
|
displayName?: string;
|
|
221
|
+
requestOtpCode?: PresenceOtpCodeProvider;
|
|
179
222
|
}) => Promise<{
|
|
180
223
|
credential_id: string;
|
|
181
224
|
passkey_registered: true;
|
|
@@ -210,6 +253,61 @@ interface RNAuthSDK {
|
|
|
210
253
|
getBitcoinUtxos: (params: BitcoinGetUtxosParams) => Promise<BitcoinGetUtxosResult>;
|
|
211
254
|
}
|
|
212
255
|
|
|
256
|
+
interface NativeSessionSnapshot {
|
|
257
|
+
isAuthenticated: boolean;
|
|
258
|
+
user: unknown | null;
|
|
259
|
+
revalidatedAt: number;
|
|
260
|
+
sessionStatus: SessionStatus;
|
|
261
|
+
sessionError: Error | null;
|
|
262
|
+
}
|
|
263
|
+
interface SessionReads {
|
|
264
|
+
getCurrentSession: () => Promise<unknown>;
|
|
265
|
+
getUser: () => Promise<unknown>;
|
|
266
|
+
/**
|
|
267
|
+
* Tries to bring back a session the iframe lost. True when the iframe now
|
|
268
|
+
* has one, false when resume does not apply. Throws on transient failures.
|
|
269
|
+
*/
|
|
270
|
+
resume?: () => Promise<boolean>;
|
|
271
|
+
}
|
|
272
|
+
/** Owns native restoration and the eligibility of asynchronous state writes. */
|
|
273
|
+
declare function createNativeSession(reads: SessionReads): {
|
|
274
|
+
getSnapshot: () => NativeSessionSnapshot;
|
|
275
|
+
subscribe: (listener: () => void) => () => void;
|
|
276
|
+
mount: () => void;
|
|
277
|
+
unmount: () => void;
|
|
278
|
+
setReady: (value: boolean) => void;
|
|
279
|
+
retrySession: () => void;
|
|
280
|
+
/** Replaces an active check: a suspended WebView can drop requests it had in flight. */
|
|
281
|
+
restartSession: () => void;
|
|
282
|
+
beginAuthFlow: ({ replaceSession }?: {
|
|
283
|
+
replaceSession?: boolean;
|
|
284
|
+
}) => (() => void) & {
|
|
285
|
+
assertCurrent: () => void;
|
|
286
|
+
};
|
|
287
|
+
captureUserWrite: () => (user: unknown) => void;
|
|
288
|
+
captureUserRefresh: () => () => Promise<void>;
|
|
289
|
+
refreshUser: () => Promise<void>;
|
|
290
|
+
beginAuthOperation: () => {
|
|
291
|
+
finish: (() => void) & {
|
|
292
|
+
assertCurrent: () => void;
|
|
293
|
+
};
|
|
294
|
+
setIsAuthenticated: (value: boolean) => void;
|
|
295
|
+
refreshUser: () => Promise<void>;
|
|
296
|
+
};
|
|
297
|
+
};
|
|
298
|
+
type NativeSession = ReturnType<typeof createNativeSession>;
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Secure key-value storage for the resume key, such as expo-secure-store or
|
|
302
|
+
* react-native-keychain. Values are small strings. The stored key can resume
|
|
303
|
+
* the session, so use device-only storage: not synced, not backed up.
|
|
304
|
+
*/
|
|
305
|
+
interface SessionResumeStorage {
|
|
306
|
+
getItem: (key: string) => Promise<string | null>;
|
|
307
|
+
setItem: (key: string, value: string) => Promise<void>;
|
|
308
|
+
removeItem: (key: string) => Promise<void>;
|
|
309
|
+
}
|
|
310
|
+
|
|
213
311
|
interface MoonXConfig {
|
|
214
312
|
/**
|
|
215
313
|
* Iframe URL the WebView loads. Optional — defaults to the MoonX
|
|
@@ -244,6 +342,14 @@ interface MoonXConfig {
|
|
|
244
342
|
sensitiveModalCopy?: {
|
|
245
343
|
closeLabel?: string;
|
|
246
344
|
};
|
|
345
|
+
/**
|
|
346
|
+
* Built-in prompt for the emailed step-up code that identity-backed users
|
|
347
|
+
* without a passkey need for lifecycle operations (add a passkey, export a
|
|
348
|
+
* key). Pass copy or colors to restyle it, or `false` when the app
|
|
349
|
+
* registers its own provider with `registerPresenceOtpCodeProvider`.
|
|
350
|
+
* A method call with `requestOtpCode` always bypasses it.
|
|
351
|
+
*/
|
|
352
|
+
presenceOtpPrompt?: false | PresenceOtpPromptOptions;
|
|
247
353
|
/**
|
|
248
354
|
* Reserved for future per-app security knobs. Currently no fields —
|
|
249
355
|
* the previously-configurable `assertionCacheTtlMs` was removed
|
|
@@ -251,6 +357,16 @@ interface MoonXConfig {
|
|
|
251
357
|
* now drives a fresh WebAuthn ceremony, no cache to configure).
|
|
252
358
|
*/
|
|
253
359
|
security?: Record<string, never>;
|
|
360
|
+
/**
|
|
361
|
+
* Secure storage that lets the SDK restore a session the WebView lost.
|
|
362
|
+
* iOS can delete WebView storage, including the refresh token, while the
|
|
363
|
+
* session is still valid. With this set, the SDK keeps a resume key here
|
|
364
|
+
* (never a token) and silently restores the session on the next launch,
|
|
365
|
+
* within its original expiry. Pass an adapter over Keychain/Keystore, such
|
|
366
|
+
* as expo-secure-store; keep the object stable across renders. Requires
|
|
367
|
+
* session resume to be enabled for the app.
|
|
368
|
+
*/
|
|
369
|
+
sessionResumeStorage?: SessionResumeStorage;
|
|
254
370
|
}
|
|
255
371
|
interface MoonXProviderProps {
|
|
256
372
|
publishableKey: string;
|
|
@@ -301,7 +417,7 @@ interface MoonXContextValue {
|
|
|
301
417
|
_relyingPartyOrigin: RelyingPartyOriginInput;
|
|
302
418
|
_runSensitiveFlow: (options: SensitiveFlowOptions) => Promise<SensitiveFlowResult>;
|
|
303
419
|
_oauthRedirectUri?: string;
|
|
304
|
-
_beginAuthFlow:
|
|
420
|
+
_beginAuthFlow: NativeSession["beginAuthFlow"];
|
|
305
421
|
}
|
|
306
422
|
declare const MoonXProvider: React.FC<MoonXProviderProps>;
|
|
307
423
|
declare const useMoonXContext: () => MoonXContextValue;
|
|
@@ -484,4 +600,4 @@ declare const restoreWalletConnectSession: (options: Omit<ConnectWalletConnectOp
|
|
|
484
600
|
topic: string;
|
|
485
601
|
}) => ConnectedExternalWallet;
|
|
486
602
|
|
|
487
|
-
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 };
|
|
603
|
+
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 };
|