@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/dist/ethereum.mjs CHANGED
@@ -1,19 +1,333 @@
1
1
  // src/ethereum.ts
2
2
  import {
3
+ useCreateWallet,
3
4
  useGetBalance,
5
+ useImportKey,
4
6
  useSendTransaction,
5
7
  useSign7702Authorization,
6
8
  useSignHash,
7
9
  useSignMessage,
8
10
  useSignTransaction,
9
- useSignTypedData
11
+ useSignTypedData,
12
+ useWallets
10
13
  } from "@moon-x/core/react/ethereum";
14
+
15
+ // src/hooks/use-export-key.ts
16
+ import { getInternalPresenceTokens as getInternalPresenceTokens2, SCOPES_EXPORT_KEY } from "@moon-x/core/sdk";
17
+ import { PostMessageMethod as PostMessageMethod4, PostMessageType as PostMessageType4 } from "@moon-x/core/utils";
18
+
19
+ // src/provider.tsx
20
+ import {
21
+ createContext,
22
+ useCallback,
23
+ useContext,
24
+ useEffect,
25
+ useMemo,
26
+ useRef,
27
+ useState
28
+ } from "react";
29
+ import {
30
+ Animated,
31
+ AppState,
32
+ Platform,
33
+ Pressable,
34
+ StyleSheet,
35
+ Text,
36
+ useWindowDimensions,
37
+ View
38
+ } from "react-native";
39
+ import { WebView } from "react-native-webview";
40
+
41
+ // src/sdk/create-sdk-instance.ts
42
+ import { PostMessageMethod as PostMessageMethod2, PostMessageType as PostMessageType2 } from "@moon-x/core/utils";
43
+
44
+ // src/sdk/sdk-authentication-methods.ts
45
+ import { getHeadlessAuthenticationMethods } from "@moon-x/core/sdk";
46
+
47
+ // src/sdk/sdk-ethereum-methods.ts
48
+ import {
49
+ getHeadlessEthereumMethods
50
+ } from "@moon-x/core/sdk";
51
+
52
+ // src/platform/async-storage-kv.ts
53
+ import AsyncStorage from "@react-native-async-storage/async-storage";
54
+
55
+ // src/platform/rn-passkey.ts
56
+ import { get as passkeyGet } from "react-native-passkeys";
57
+ var createRNPasskey = () => ({
58
+ assert: async ({ rpId, challenge }) => {
59
+ const credential = await passkeyGet({
60
+ challenge,
61
+ rpId,
62
+ allowCredentials: [],
63
+ userVerification: "preferred"
64
+ });
65
+ if (!credential) throw new Error("passkey_assertion_cancelled");
66
+ const userHandle = credential.response.userHandle;
67
+ if (!userHandle) throw new Error("user_handle_missing");
68
+ return {
69
+ rawIdB64url: credential.rawId,
70
+ userHandleB64url: userHandle
71
+ };
72
+ },
73
+ assertForServer: async ({ optionsJSON }) => {
74
+ const credential = await passkeyGet({
75
+ challenge: optionsJSON.challenge,
76
+ rpId: optionsJSON.rpId,
77
+ allowCredentials: optionsJSON.allowCredentials ?? [],
78
+ userVerification: optionsJSON.userVerification ?? "preferred"
79
+ });
80
+ if (!credential) throw new Error("passkey_assertion_cancelled");
81
+ const sanitized = {
82
+ id: credential.id ?? credential.rawId,
83
+ rawId: credential.rawId,
84
+ type: credential.type ?? "public-key",
85
+ response: {
86
+ clientDataJSON: credential.response.clientDataJSON,
87
+ authenticatorData: credential.response.authenticatorData,
88
+ signature: credential.response.signature,
89
+ userHandle: void 0
90
+ },
91
+ clientExtensionResults: credential.clientExtensionResults ?? {},
92
+ authenticatorAttachment: credential.authenticatorAttachment
93
+ };
94
+ return sanitized;
95
+ },
96
+ assertForInternalPresence: async ({ optionsJSON }) => {
97
+ const credential = await passkeyGet({
98
+ challenge: optionsJSON.challenge,
99
+ rpId: optionsJSON.rpId,
100
+ allowCredentials: [],
101
+ userVerification: optionsJSON.userVerification ?? "preferred"
102
+ });
103
+ if (!credential) throw new Error("passkey_assertion_cancelled");
104
+ const userHandle = credential.response.userHandle;
105
+ if (!userHandle) throw new Error("user_handle_missing");
106
+ const sanitized = {
107
+ id: credential.id ?? credential.rawId,
108
+ rawId: credential.rawId,
109
+ type: credential.type ?? "public-key",
110
+ response: {
111
+ clientDataJSON: credential.response.clientDataJSON,
112
+ authenticatorData: credential.response.authenticatorData,
113
+ signature: credential.response.signature,
114
+ userHandle: void 0
115
+ },
116
+ clientExtensionResults: credential.clientExtensionResults ?? {},
117
+ authenticatorAttachment: credential.authenticatorAttachment
118
+ };
119
+ return {
120
+ response: sanitized,
121
+ userHandleB64url: userHandle,
122
+ credentialIdB64url: credential.rawId
123
+ };
124
+ }
125
+ });
126
+
127
+ // src/sdk/sdk-funding-methods.ts
128
+ import { getHeadlessFundingMethods } from "@moon-x/core/sdk";
129
+
130
+ // src/sdk/sdk-passkey-methods.ts
131
+ import { generatePasskeyUserId, toB64url } from "@moon-x/core/lib";
132
+ import {
133
+ flattenPresenceTokens,
134
+ getInternalPresenceTokens,
135
+ getPresenceToken,
136
+ SCOPES_ADD_PASSKEY
137
+ } from "@moon-x/core/sdk";
138
+ import { PostMessageMethod, PostMessageType } from "@moon-x/core/utils";
139
+ import { create as passkeyCreate } from "react-native-passkeys";
140
+
141
+ // src/sdk/sdk-methods.ts
142
+ import {
143
+ getHeadlessGeneralMethods
144
+ } from "@moon-x/core/sdk";
145
+
146
+ // src/sdk/sdk-solana-methods.ts
147
+ import {
148
+ getHeadlessSolanaMethods
149
+ } from "@moon-x/core/sdk";
150
+
151
+ // src/sdk/sdk-tron-methods.ts
152
+ import {
153
+ getHeadlessTronMethods
154
+ } from "@moon-x/core/sdk";
155
+
156
+ // src/provider.tsx
157
+ import { PostMessageMethod as PostMessageMethod3, PostMessageType as PostMessageType3 } from "@moon-x/core/utils";
158
+
159
+ // src/transport/webview-bridge.ts
160
+ import {
161
+ FORWARDED_ERROR_FIELDS
162
+ } from "@moon-x/core/utils";
163
+
164
+ // src/provider.tsx
165
+ import { SDKProvider } from "@moon-x/core/react";
166
+ import { jsx, jsxs } from "react/jsx-runtime";
167
+ var MoonXContext = createContext(null);
168
+ var useMoonXContext = () => {
169
+ const ctx = useContext(MoonXContext);
170
+ if (!ctx) {
171
+ throw new Error("useMoonX must be used within a MoonXProvider");
172
+ }
173
+ return ctx;
174
+ };
175
+ var styles = StyleSheet.create({
176
+ backdrop: {
177
+ position: "absolute",
178
+ top: 0,
179
+ bottom: 0,
180
+ left: 0,
181
+ right: 0,
182
+ backgroundColor: "#000",
183
+ zIndex: 999
184
+ },
185
+ // Sheet-style container: rendered as a card that slides up from the
186
+ // bottom. `top` is set inline by the provider to leave room above
187
+ // for the host app's content visible through the dimmed backdrop.
188
+ // `bottom: 0` so the WebView fills the remaining height.
189
+ sheetContainer: {
190
+ position: "absolute",
191
+ bottom: 0,
192
+ left: 0,
193
+ right: 0,
194
+ backgroundColor: "#0a0a0a",
195
+ borderTopLeftRadius: 14,
196
+ borderTopRightRadius: 14,
197
+ overflow: "hidden",
198
+ zIndex: 1e3,
199
+ shadowColor: "#000",
200
+ shadowOpacity: 0.4,
201
+ shadowRadius: 20,
202
+ shadowOffset: { width: 0, height: -4 },
203
+ elevation: 16
204
+ },
205
+ sheetGrabber: {
206
+ width: 36,
207
+ height: 4,
208
+ borderRadius: 2,
209
+ backgroundColor: "#333",
210
+ alignSelf: "center",
211
+ marginTop: 8,
212
+ marginBottom: 4
213
+ },
214
+ webView: {
215
+ flex: 1
216
+ },
217
+ modalChrome: {
218
+ flexDirection: "row",
219
+ alignItems: "center",
220
+ justifyContent: "space-between",
221
+ paddingTop: 8,
222
+ paddingBottom: 12,
223
+ paddingHorizontal: 16,
224
+ backgroundColor: "#0a0a0a",
225
+ borderBottomWidth: StyleSheet.hairlineWidth,
226
+ borderBottomColor: "#222"
227
+ },
228
+ // Empty flex spacer keeps the close button right-aligned without
229
+ // a title taking up the left side. The iframe-app's flow page
230
+ // renders its own header inside the WebView, so a duplicate title
231
+ // here was redundant.
232
+ modalTitleSpacer: {
233
+ flex: 1
234
+ },
235
+ closeButton: {
236
+ paddingHorizontal: 8,
237
+ paddingVertical: 4
238
+ },
239
+ closeButtonText: {
240
+ color: "#3b82f6",
241
+ fontSize: 17,
242
+ fontWeight: "600"
243
+ }
244
+ });
245
+
246
+ // src/hooks/use-export-key.ts
247
+ var parseExportKeyResult = (value) => {
248
+ if (!value || typeof value !== "object" || !("status" in value)) {
249
+ return { status: "failed", error: "invalid_export_key_result" };
250
+ }
251
+ const candidate = value;
252
+ if (candidate.status === "completed" || candidate.status === "cancelled") {
253
+ return { status: candidate.status };
254
+ }
255
+ if (candidate.status === "failed" && typeof candidate.error === "string") {
256
+ return { status: "failed", error: candidate.error };
257
+ }
258
+ return { status: "failed", error: "invalid_export_key_result" };
259
+ };
260
+ var useExportKey = () => {
261
+ const { sdk, _bridge, _relyingPartyOrigin, _runSensitiveFlow } = useMoonXContext();
262
+ return {
263
+ exportKey: async (wallet) => {
264
+ try {
265
+ const { userHandleB64url, credentialIdB64url, tokens } = await getInternalPresenceTokens2({
266
+ transport: _bridge,
267
+ passkey: createRNPasskey(),
268
+ publishableKey: sdk.publishableKey,
269
+ relyingPartyOrigin: _relyingPartyOrigin,
270
+ scopes: SCOPES_EXPORT_KEY
271
+ });
272
+ const keyshareReadToken = tokens.keyshare_read?.token ?? "";
273
+ const params = new URLSearchParams({
274
+ publishableKey: sdk.publishableKey,
275
+ wallet_id: wallet.id ?? "",
276
+ wallet_type: wallet.wallet_type ?? ""
277
+ });
278
+ const secrets = new URLSearchParams({
279
+ user_handle_b64url: userHandleB64url,
280
+ credential_id_b64url: credentialIdB64url,
281
+ keyshare_read_token: keyshareReadToken
282
+ });
283
+ return await _runSensitiveFlow({
284
+ title: "Export key",
285
+ flowPath: `/export-key?${params.toString()}#${secrets.toString()}`,
286
+ onMount: ({ bridge, setResult }) => bridge.register(
287
+ PostMessageType4.WALLET,
288
+ PostMessageMethod4.EXPORT_KEY_RESULT,
289
+ (result) => {
290
+ setResult(parseExportKeyResult(result));
291
+ }
292
+ )
293
+ });
294
+ } catch (error) {
295
+ const message = error instanceof Error ? error.message : "export_key_failed";
296
+ return /cancel/i.test(message) ? { status: "cancelled" } : { status: "failed", error: message };
297
+ }
298
+ }
299
+ };
300
+ };
301
+
302
+ // src/hooks/use-chain-export-key.ts
303
+ var useChainExportKey = () => {
304
+ const { exportKey } = useExportKey();
305
+ return {
306
+ exportKey: ({ wallet }) => exportKey(wallet)
307
+ };
308
+ };
309
+
310
+ // src/hooks/use-chain-fund-wallet.ts
311
+ var createUseFundWallet = (walletType) => function useFundWallet2() {
312
+ const { sdk } = useMoonXContext();
313
+ return {
314
+ fundWallet: (address, options) => sdk.prepareFunding({ address, walletType, options })
315
+ };
316
+ };
317
+
318
+ // src/ethereum.ts
319
+ var useFundWallet = createUseFundWallet("ethereum");
11
320
  export {
321
+ useCreateWallet,
322
+ useChainExportKey as useExportKey,
323
+ useFundWallet,
12
324
  useGetBalance,
325
+ useImportKey,
13
326
  useSendTransaction,
14
327
  useSign7702Authorization,
15
328
  useSignHash,
16
329
  useSignMessage,
17
330
  useSignTransaction,
18
- useSignTypedData
331
+ useSignTypedData,
332
+ useWallets
19
333
  };
package/dist/index.d.mts 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
- export { UseEphemeralSignerResult, useAddPasskey, useCreateWallet, useEphemeralSigner, useImportKey, useLoginWithEmail, useLogout, usePasskeyStatus, useRegisterPasskey, useRemovePasskey, useUser, useWallets } from '@moon-x/core/react';
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.mjs';
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
- cancel: () => void;
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<void>;
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
- * Trigger the export-key flow. The plaintext private key never leaves
242
- * the WebView's DOM — the iframe-app's `/export-key` route renders the
243
- * UI inside the WebView, which is presented full-screen during the
244
- * flow. The RN-side promise resolves when the user dismisses the
245
- * modal (the only v1 completion signal — an iframe-app-emitted
246
- * EXPORT_COMPLETE one-way is a planned enhancement).
247
- */
248
- declare const useExportKey: () => {
249
- exportKey: (wallet: PublicWallet) => Promise<void>;
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
- export { type MoonXConfig, MoonXProvider, type MoonXProviderProps, type RNAuthSDK, useAttachOAuth, useDetachOAuth, useExportKey, useLoginWithOAuth, useMoonX, useMoonXContext };
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 };