@moon-x/react-native-sdk 0.11.0 → 0.13.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 +138 -32
- package/dist/ethereum.d.mts +10 -2
- package/dist/ethereum.d.ts +10 -2
- package/dist/ethereum.js +296 -2
- package/dist/ethereum.mjs +316 -2
- package/dist/index.d.mts +156 -21
- package/dist/index.d.ts +156 -21
- package/dist/index.js +695 -121
- package/dist/index.mjs +678 -102
- package/dist/solana.d.mts +10 -1
- package/dist/solana.d.ts +10 -1
- package/dist/solana.js +298 -2
- package/dist/solana.mjs +318 -2
- package/dist/tron.d.mts +11 -0
- package/dist/tron.d.ts +11 -0
- package/dist/tron.js +330 -0
- package/dist/tron.mjs +327 -0
- package/dist/use-chain-export-key-C4vTffjx.d.mts +11 -0
- package/dist/use-chain-export-key-C7zBt98X.d.ts +11 -0
- package/dist/use-export-key-BIz_tV0k.d.mts +23 -0
- package/dist/use-export-key-BIz_tV0k.d.ts +23 -0
- package/package.json +12 -4
package/dist/index.d.ts
CHANGED
|
@@ -3,9 +3,13 @@ import { RelyingPartyOriginInput } from '@moon-x/core/sdk';
|
|
|
3
3
|
import { PostMessageType, PostMessageMethod } from '@moon-x/core/utils';
|
|
4
4
|
export { PostMessageMethod, PostMessageType } from '@moon-x/core/utils';
|
|
5
5
|
import * as _moon_x_core_types from '@moon-x/core/types';
|
|
6
|
-
import { PublicWallet, EthereumSignMessageParams, EthereumSignMessageResult, EthereumSignTransactionParams, EthereumSignTransactionResult, EthereumSignTypedDataParams, EthereumSignTypedDataResult, EthereumSignHashParams, EthereumSignHashResult, EthereumSign7702AuthorizationParams, EthereumSign7702AuthorizationResult, EthereumSendTransactionParams, EthereumSendTransactionResult, EthereumGetBalanceParams, EthereumGetBalanceResult, SolanaSignMessageParams, SolanaSignMessageResult, SolanaSignTransactionParams, SolanaSignTransactionResult, SolanaSendTransactionParams, SolanaSendTransactionResult, SolanaGetBalanceParams, SolanaGetBalanceResult } from '@moon-x/core/types';
|
|
7
|
-
export { Chain, EphemeralSigner, EphemeralSignerChain, EphemeralSignerScheme, EphemeralSignerWallet, EthereumGetBalanceParams, EthereumGetBalanceResult, EthereumSendTransactionParams, EthereumSendTransactionResult, EthereumSign7702AuthorizationParams, EthereumSign7702AuthorizationResult, EthereumSignHashParams, EthereumSignHashResult, EthereumSignMessageParams, EthereumSignMessageResult, EthereumSignTransactionParams, EthereumSignTransactionResult, EthereumSignTypedDataParams, EthereumSignTypedDataResult, ListEphemeralSignersResult, Network, ProvisionEphemeralSignerParams, ProvisionEphemeralSignerResult, PublicWallet, RevokeEphemeralSignerParams, SolanaGetBalanceParams, SolanaGetBalanceResult, SolanaSendTransactionParams, SolanaSendTransactionResult, SolanaSignMessageParams, SolanaSignMessageResult, SolanaSignTransactionParams, SolanaSignTransactionResult, WalletConnectConfig } from '@moon-x/core/types';
|
|
8
|
-
|
|
6
|
+
import { PublicWallet, 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, AppConfigResponse } from '@moon-x/core/types';
|
|
7
|
+
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';
|
|
8
|
+
import * as _moon_x_core_react from '@moon-x/core/react';
|
|
9
|
+
import { UseLoginWithEmailCallbacks } from '@moon-x/core/react';
|
|
10
|
+
export { LoginWithEmailState, UseEphemeralSignerResult, UseLoginWithEmailCallbacks, useAddPasskey, useCreateWallet, useEphemeralSigner, useImportKey, useLogout, usePasskeyStatus, useRegisterPasskey, useRemovePasskey, useUser, useWallets } from '@moon-x/core/react';
|
|
11
|
+
export { E as ExportKeyResult, u as useExportKey } from './use-export-key-BIz_tV0k.js';
|
|
12
|
+
import { WalletConnectClientLike, WalletConnectSessionLike } from '@moon-x/core/lib';
|
|
9
13
|
|
|
10
14
|
interface WebViewRefLike {
|
|
11
15
|
injectJavaScript: (script: string) => void;
|
|
@@ -50,12 +54,15 @@ interface RNAuthSDK {
|
|
|
50
54
|
}) => Promise<any>;
|
|
51
55
|
isAuthenticated: boolean;
|
|
52
56
|
user: any | null;
|
|
57
|
+
revalidatedAt: number;
|
|
58
|
+
/** Returns null only for an authoritative no-session response; transport failures reject. */
|
|
53
59
|
getCurrentSession: () => Promise<any>;
|
|
54
60
|
getUser: () => Promise<any>;
|
|
55
61
|
refreshUser: () => Promise<void>;
|
|
56
62
|
getSessionTokens: () => Promise<{
|
|
57
|
-
refreshToken: string;
|
|
58
63
|
accessToken: string;
|
|
64
|
+
identityToken: string;
|
|
65
|
+
expiresAt: number;
|
|
59
66
|
} | null>;
|
|
60
67
|
/**
|
|
61
68
|
* Run a passkey-asserted step-up ceremony and return a short-lived
|
|
@@ -78,16 +85,16 @@ interface RNAuthSDK {
|
|
|
78
85
|
success: boolean;
|
|
79
86
|
message: string;
|
|
80
87
|
}>;
|
|
81
|
-
createWallet: (walletType: "solana" | "ethereum", options?: {
|
|
88
|
+
createWallet: (walletType: "solana" | "ethereum" | "tron", options?: {
|
|
82
89
|
createAdditional?: boolean;
|
|
83
90
|
walletIndex?: number;
|
|
84
91
|
}) => Promise<{
|
|
85
92
|
wallet: PublicWallet;
|
|
86
93
|
}>;
|
|
87
|
-
importKey: (walletType: "solana" | "ethereum", key: string) => Promise<{
|
|
94
|
+
importKey: (walletType: "solana" | "ethereum" | "tron", key: string) => Promise<{
|
|
88
95
|
wallet: PublicWallet;
|
|
89
96
|
}>;
|
|
90
|
-
getWallets: (walletType: "solana" | "ethereum") => Promise<{
|
|
97
|
+
getWallets: (walletType: "solana" | "ethereum" | "tron") => Promise<{
|
|
91
98
|
wallets: any[];
|
|
92
99
|
walletType: string;
|
|
93
100
|
}>;
|
|
@@ -112,6 +119,13 @@ interface RNAuthSDK {
|
|
|
112
119
|
credential_id: string;
|
|
113
120
|
passkey_registered: true;
|
|
114
121
|
}>;
|
|
122
|
+
addPasskey: (params?: {
|
|
123
|
+
displayName?: string;
|
|
124
|
+
}) => Promise<{
|
|
125
|
+
credential_id: string;
|
|
126
|
+
passkey_registered: true;
|
|
127
|
+
}>;
|
|
128
|
+
prepareFunding: (params: PrepareFundingParams) => Promise<FundingSession>;
|
|
115
129
|
signEthereumMessageHeadless: (params: EthereumSignMessageParams) => Promise<EthereumSignMessageResult>;
|
|
116
130
|
signEthereumTransactionHeadless: (params: EthereumSignTransactionParams) => Promise<EthereumSignTransactionResult>;
|
|
117
131
|
signEthereumTypedDataHeadless: (params: EthereumSignTypedDataParams) => Promise<EthereumSignTypedDataResult>;
|
|
@@ -123,6 +137,11 @@ interface RNAuthSDK {
|
|
|
123
137
|
signSolanaTransactionHeadless: (params: SolanaSignTransactionParams) => Promise<SolanaSignTransactionResult>;
|
|
124
138
|
sendSolanaTransactionHeadless: (params: SolanaSendTransactionParams) => Promise<SolanaSendTransactionResult>;
|
|
125
139
|
getSolanaBalance: (params: SolanaGetBalanceParams) => Promise<SolanaGetBalanceResult>;
|
|
140
|
+
getSolanaTokenAccountsByOwner: (params: SolanaGetTokenAccountsByOwnerParams) => Promise<SolanaGetTokenAccountsByOwnerResult>;
|
|
141
|
+
signTronMessageHeadless: (params: TronSignMessageParams) => Promise<TronSignMessageResult>;
|
|
142
|
+
signTronTransactionHeadless: (params: TronSignTransactionParams) => Promise<TronSignTransactionResult>;
|
|
143
|
+
sendTronTransactionHeadless: (params: TronSendTransactionParams) => Promise<TronSendTransactionResult>;
|
|
144
|
+
getTronBalance: (params: TronGetBalanceParams) => Promise<TronGetBalanceResult>;
|
|
126
145
|
}
|
|
127
146
|
|
|
128
147
|
interface MoonXConfig {
|
|
@@ -195,22 +214,55 @@ interface SensitiveFlowOptions {
|
|
|
195
214
|
* 3. Toggling sensitiveVisible → false on resolve / cancel
|
|
196
215
|
* 4. Navigating the WebView back to the main `iframeUrl`
|
|
197
216
|
*/
|
|
198
|
-
onMount: (api: SensitiveFlowMountApi) => Promise<void> | void;
|
|
217
|
+
onMount: (api: SensitiveFlowMountApi) => Promise<void | (() => void)> | void | (() => void);
|
|
199
218
|
}
|
|
219
|
+
type SensitiveFlowResult = {
|
|
220
|
+
status: "completed";
|
|
221
|
+
} | {
|
|
222
|
+
status: "cancelled";
|
|
223
|
+
} | {
|
|
224
|
+
status: "failed";
|
|
225
|
+
error: string;
|
|
226
|
+
};
|
|
200
227
|
interface SensitiveFlowMountApi {
|
|
201
228
|
bridge: WebViewBridge;
|
|
202
|
-
|
|
229
|
+
/** Record a terminal outcome while leaving the sensitive view visible. */
|
|
230
|
+
setResult: (result: SensitiveFlowResult) => void;
|
|
203
231
|
}
|
|
204
232
|
interface MoonXContextValue {
|
|
205
233
|
sdk: RNAuthSDK;
|
|
206
234
|
_bridge: WebViewBridge;
|
|
207
235
|
_relyingPartyOrigin: RelyingPartyOriginInput;
|
|
208
|
-
_runSensitiveFlow: (options: SensitiveFlowOptions) => Promise<
|
|
236
|
+
_runSensitiveFlow: (options: SensitiveFlowOptions) => Promise<SensitiveFlowResult>;
|
|
209
237
|
_oauthRedirectUri?: string;
|
|
238
|
+
_beginAuthFlow: () => () => void;
|
|
210
239
|
}
|
|
211
240
|
declare const MoonXProvider: React.FC<MoonXProviderProps>;
|
|
212
241
|
declare const useMoonXContext: () => MoonXContextValue;
|
|
213
242
|
|
|
243
|
+
interface UseAppConfigReturn {
|
|
244
|
+
appConfig: AppConfigResponse | null;
|
|
245
|
+
isLoading: boolean;
|
|
246
|
+
error: string | null;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Fetch the per-app config (`sdk_settings`, terms/privacy URLs, logo,
|
|
250
|
+
* ...) over the WebView bridge and return the whole `AppConfigResponse`
|
|
251
|
+
* alongside `{ isLoading, error }`.
|
|
252
|
+
*
|
|
253
|
+
* Deliberately mirrors the web SDK's `useAppConfig`
|
|
254
|
+
* (`@moon-x/react-sdk`'s `internal/use-app-config.ts`) return shape so
|
|
255
|
+
* app code that gates login methods on `sdk_settings` or renders a
|
|
256
|
+
* terms-acceptance footer moves between web and RN with a 1-line import
|
|
257
|
+
* swap — same philosophy as `useMoonX`. We return the full response
|
|
258
|
+
* rather than destructuring convenience fields for exactly that reason.
|
|
259
|
+
*
|
|
260
|
+
* `publishableKey` is optional (unlike web, where the consumer always
|
|
261
|
+
* threads it): the RN provider already holds the key, so we default to
|
|
262
|
+
* `sdk.publishableKey`. Pass it only to override.
|
|
263
|
+
*/
|
|
264
|
+
declare const useAppConfig: (publishableKey?: string) => UseAppConfigReturn;
|
|
265
|
+
|
|
214
266
|
type State$1 = {
|
|
215
267
|
status: "idle";
|
|
216
268
|
} | {
|
|
@@ -237,16 +289,22 @@ declare const useDetachOAuth: () => {
|
|
|
237
289
|
detachOAuth: (idpUserId: string) => Promise<void>;
|
|
238
290
|
};
|
|
239
291
|
|
|
240
|
-
/**
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
292
|
+
/** Headless funding hook. The host app presents `session.url`. */
|
|
293
|
+
declare const useFundWallet: () => {
|
|
294
|
+
fundWallet: (params: PrepareFundingParams) => Promise<FundingSession>;
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
/** RN wrapper that prevents foreground revalidation racing OTP verification. */
|
|
298
|
+
declare const useLoginWithEmail: (callbacks?: UseLoginWithEmailCallbacks) => {
|
|
299
|
+
loginWithCode: (params: {
|
|
300
|
+
code: string;
|
|
301
|
+
}) => Promise<void>;
|
|
302
|
+
state: _moon_x_core_react.LoginWithEmailState;
|
|
303
|
+
sendCode: (params: {
|
|
304
|
+
email: string;
|
|
305
|
+
disableSignup?: boolean;
|
|
306
|
+
}) => Promise<void>;
|
|
307
|
+
reset: () => void;
|
|
250
308
|
};
|
|
251
309
|
|
|
252
310
|
type State = {
|
|
@@ -283,4 +341,81 @@ declare const useLoginWithOAuth: (params?: {
|
|
|
283
341
|
*/
|
|
284
342
|
declare const useMoonX: () => RNAuthSDK;
|
|
285
343
|
|
|
286
|
-
|
|
344
|
+
type ExternalWalletChain = "ethereum" | "solana";
|
|
345
|
+
interface ExternalWalletAccount {
|
|
346
|
+
address: string;
|
|
347
|
+
chain: ExternalWalletChain;
|
|
348
|
+
chainId?: string;
|
|
349
|
+
}
|
|
350
|
+
interface ExternalWalletInfo {
|
|
351
|
+
id: string;
|
|
352
|
+
name: string;
|
|
353
|
+
icon?: string;
|
|
354
|
+
chain: ExternalWalletChain;
|
|
355
|
+
available: boolean;
|
|
356
|
+
connectVia: "native" | "walletconnect" | "custom";
|
|
357
|
+
}
|
|
358
|
+
interface ConnectedExternalWallet {
|
|
359
|
+
id: string;
|
|
360
|
+
name: string;
|
|
361
|
+
chain: ExternalWalletChain;
|
|
362
|
+
walletClientType: string;
|
|
363
|
+
accounts: ExternalWalletAccount[];
|
|
364
|
+
/** Null after the underlying wallet session disconnects or expires. */
|
|
365
|
+
activeAccount: ExternalWalletAccount | null;
|
|
366
|
+
request<Result = unknown>(method: string, params: unknown, chainId?: string): Promise<Result>;
|
|
367
|
+
signMessage?: (message: string | Uint8Array) => Promise<string>;
|
|
368
|
+
signTypedData?: (typedData: unknown) => Promise<string>;
|
|
369
|
+
signTransaction?: (transaction: unknown) => Promise<unknown>;
|
|
370
|
+
sendTransaction?: (transaction: unknown) => Promise<unknown>;
|
|
371
|
+
switchAccount: (address: string, chainId?: string) => Promise<ExternalWalletAccount>;
|
|
372
|
+
subscribeAccounts?: (listener: (accounts: ExternalWalletAccount[], activeAccount: ExternalWalletAccount | null) => void) => () => void;
|
|
373
|
+
disconnect: () => Promise<void>;
|
|
374
|
+
raw: unknown;
|
|
375
|
+
}
|
|
376
|
+
/** Host-supplied adapter for native wallet SDKs other than WalletConnect. */
|
|
377
|
+
interface ExternalWalletConnector {
|
|
378
|
+
info: Omit<ExternalWalletInfo, "available">;
|
|
379
|
+
isAvailable?: () => boolean | Promise<boolean>;
|
|
380
|
+
connect: () => Promise<ConnectedExternalWallet>;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
type ExternalWalletStatus = "idle" | "connecting" | "connected" | "error";
|
|
384
|
+
/**
|
|
385
|
+
* Headless connector orchestration for native wallet SDKs. The host supplies
|
|
386
|
+
* connectors and owns every picker, deep link, QR code, and navigation step.
|
|
387
|
+
*/
|
|
388
|
+
declare const useExternalWallets: (connectors: ExternalWalletConnector[]) => {
|
|
389
|
+
wallets: ExternalWalletInfo[];
|
|
390
|
+
connected: ConnectedExternalWallet | null;
|
|
391
|
+
status: ExternalWalletStatus;
|
|
392
|
+
error: Error | null;
|
|
393
|
+
connect: (id: string) => Promise<ConnectedExternalWallet>;
|
|
394
|
+
disconnect: () => Promise<void>;
|
|
395
|
+
switchAccount: (address: string, chainId?: string) => Promise<void>;
|
|
396
|
+
refresh: () => void;
|
|
397
|
+
};
|
|
398
|
+
|
|
399
|
+
interface ConnectWalletConnectOptions {
|
|
400
|
+
client: WalletConnectClientLike;
|
|
401
|
+
requiredNamespaces?: Parameters<WalletConnectClientLike["connect"]>[0]["requiredNamespaces"];
|
|
402
|
+
optionalNamespaces?: Parameters<WalletConnectClientLike["connect"]>[0]["optionalNamespaces"];
|
|
403
|
+
walletClientType?: string;
|
|
404
|
+
/** Select an approved chain/account instead of the first session account. */
|
|
405
|
+
chain?: ExternalWalletChain;
|
|
406
|
+
address?: string;
|
|
407
|
+
}
|
|
408
|
+
interface WalletConnectPairing {
|
|
409
|
+
/** Undefined when WalletConnect can approve without a new pairing URI. */
|
|
410
|
+
uri?: string;
|
|
411
|
+
approval: () => Promise<ConnectedExternalWallet>;
|
|
412
|
+
}
|
|
413
|
+
/** Begin a headless WalletConnect pairing. The host presents `uri`. */
|
|
414
|
+
declare const connectWalletConnect: (options: ConnectWalletConnectOptions) => Promise<WalletConnectPairing>;
|
|
415
|
+
/** Discover already-approved sessions for restoration after app restart. */
|
|
416
|
+
declare const listWalletConnectSessions: (client: WalletConnectClientLike) => WalletConnectSessionLike[];
|
|
417
|
+
declare const restoreWalletConnectSession: (options: Omit<ConnectWalletConnectOptions, "requiredNamespaces" | "optionalNamespaces"> & {
|
|
418
|
+
topic: string;
|
|
419
|
+
}) => ConnectedExternalWallet;
|
|
420
|
+
|
|
421
|
+
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 };
|