@moon-x/react-native-sdk 0.24.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 +110 -3
- package/dist/index.d.ts +110 -3
- 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,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';
|
|
@@ -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;
|
|
@@ -210,6 +244,61 @@ interface RNAuthSDK {
|
|
|
210
244
|
getBitcoinUtxos: (params: BitcoinGetUtxosParams) => Promise<BitcoinGetUtxosResult>;
|
|
211
245
|
}
|
|
212
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
|
+
|
|
213
302
|
interface MoonXConfig {
|
|
214
303
|
/**
|
|
215
304
|
* Iframe URL the WebView loads. Optional — defaults to the MoonX
|
|
@@ -244,6 +333,14 @@ interface MoonXConfig {
|
|
|
244
333
|
sensitiveModalCopy?: {
|
|
245
334
|
closeLabel?: string;
|
|
246
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;
|
|
247
344
|
/**
|
|
248
345
|
* Reserved for future per-app security knobs. Currently no fields —
|
|
249
346
|
* the previously-configurable `assertionCacheTtlMs` was removed
|
|
@@ -251,6 +348,16 @@ interface MoonXConfig {
|
|
|
251
348
|
* now drives a fresh WebAuthn ceremony, no cache to configure).
|
|
252
349
|
*/
|
|
253
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;
|
|
254
361
|
}
|
|
255
362
|
interface MoonXProviderProps {
|
|
256
363
|
publishableKey: string;
|
|
@@ -301,7 +408,7 @@ interface MoonXContextValue {
|
|
|
301
408
|
_relyingPartyOrigin: RelyingPartyOriginInput;
|
|
302
409
|
_runSensitiveFlow: (options: SensitiveFlowOptions) => Promise<SensitiveFlowResult>;
|
|
303
410
|
_oauthRedirectUri?: string;
|
|
304
|
-
_beginAuthFlow:
|
|
411
|
+
_beginAuthFlow: NativeSession["beginAuthFlow"];
|
|
305
412
|
}
|
|
306
413
|
declare const MoonXProvider: React.FC<MoonXProviderProps>;
|
|
307
414
|
declare const useMoonXContext: () => MoonXContextValue;
|
|
@@ -484,4 +591,4 @@ declare const restoreWalletConnectSession: (options: Omit<ConnectWalletConnectOp
|
|
|
484
591
|
topic: string;
|
|
485
592
|
}) => ConnectedExternalWallet;
|
|
486
593
|
|
|
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 };
|
|
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 };
|