@moon-x/react-sdk 0.1.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 +241 -0
- package/dist/assets/Sons-Black.ttf +0 -0
- package/dist/assets/Sons-Bold.ttf +0 -0
- package/dist/assets/Sons-Extrabold.ttf +0 -0
- package/dist/assets/Sons-Light.ttf +0 -0
- package/dist/assets/Sons-Medium.ttf +0 -0
- package/dist/assets/Sons-Regular.ttf +0 -0
- package/dist/assets/Sons-Semibold.ttf +0 -0
- package/dist/assets/Sons-Thin.ttf +0 -0
- package/dist/base-wallet-CzJLpndu.d.mts +119 -0
- package/dist/base-wallet-CzJLpndu.d.ts +119 -0
- package/dist/chunk-73TEXNFX.js +1018 -0
- package/dist/chunk-7BCQAHO6.mjs +1561 -0
- package/dist/chunk-CDSNBPXB.js +1988 -0
- package/dist/chunk-MYWXMCMO.mjs +662 -0
- package/dist/chunk-PCEN5CH6.mjs +169 -0
- package/dist/chunk-SPXMMQ7Z.js +248 -0
- package/dist/ethereum-BRGKpUFH.d.ts +311 -0
- package/dist/ethereum-DobH9IQl.d.mts +311 -0
- package/dist/index.css +169 -0
- package/dist/index.d.mts +298 -0
- package/dist/index.d.ts +298 -0
- package/dist/index.js +24365 -0
- package/dist/index.mjs +18194 -0
- package/dist/solana-CzXRbze_.d.mts +236 -0
- package/dist/solana-D7BgQ4c0.d.ts +236 -0
- package/dist/style.css +169 -0
- package/dist/wallets/ethereum.d.mts +4 -0
- package/dist/wallets/ethereum.d.ts +4 -0
- package/dist/wallets/ethereum.js +21 -0
- package/dist/wallets/ethereum.mjs +4 -0
- package/dist/wallets/solana.d.mts +4 -0
- package/dist/wallets/solana.d.ts +4 -0
- package/dist/wallets/solana.js +17 -0
- package/dist/wallets/solana.mjs +4 -0
- package/package.json +70 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
export { LoginWithEmailState, PasskeyStatusEntry, RegisterPasskeyResult, UseAddPasskeyResult, UseLoginWithEmailCallbacks, UsePasskeyStatusResult, UseRemovePasskeyResult, useAddPasskey, useLoginWithEmail, usePasskeyStatus, useRegisterPasskey, useRemovePasskey, useUser } from '@moon-x/core/react';
|
|
2
|
+
import { WalletListEntry, AuthAppearance, PrefillConfig, WalletChainType, MoonKeyThemeConfig, PasskeyEnrollConfig, SignMessageConfig, ExportKeyConfig, SignTransactionConfig, SendTransactionConfig, Chain, LogoutResponse, EmailOtpFlowState, Wallet } from '@moon-x/core/types';
|
|
3
|
+
export { Chain, Factor, IdpProvider, Network, PublicEthereumWallet, PublicWallet, WalletConnectConfig, WalletListEntry } from '@moon-x/core/types';
|
|
4
|
+
import React$1, { ReactNode } from 'react';
|
|
5
|
+
export { e as ethereum } from './ethereum-BRGKpUFH.js';
|
|
6
|
+
export { s as solana } from './solana-D7BgQ4c0.js';
|
|
7
|
+
export { estimateEvmGas, estimateEvmGasReserve, getChainById, getDefaultChain, getEvmGasPrice, getEvmMaxPriorityFeePerGas, getEvmNonce, getRpcUrl, isChainSupported, setChainRpcUrl, validateChainConfig } from '@moon-x/core/lib';
|
|
8
|
+
export { arbitrum, arbitrumSepolia, avalanche, avalancheFuji, base, baseSepolia, bsc, bscTestnet, goerli, holesky, mainnet, optimism, optimismSepolia, polygon, polygonAmoy, sepolia } from 'viem/chains';
|
|
9
|
+
import './base-wallet-CzJLpndu.js';
|
|
10
|
+
import '@moon-x/core';
|
|
11
|
+
|
|
12
|
+
type OAuthProvider$1 = "google" | "apple";
|
|
13
|
+
interface OAuthAttachResult {
|
|
14
|
+
created_at: number;
|
|
15
|
+
expires_at: number;
|
|
16
|
+
last_active_at: number;
|
|
17
|
+
publishable_key: string;
|
|
18
|
+
access_token: string;
|
|
19
|
+
refresh_token: string;
|
|
20
|
+
user_id: string;
|
|
21
|
+
}
|
|
22
|
+
interface AttachOAuthState {
|
|
23
|
+
status: "initial" | "loading" | "done" | "error";
|
|
24
|
+
error: Error | null;
|
|
25
|
+
result: OAuthAttachResult | null;
|
|
26
|
+
}
|
|
27
|
+
interface UseAttachOAuthCallbacks {
|
|
28
|
+
onSuccess?: (result: OAuthAttachResult) => void;
|
|
29
|
+
onError?: (error: Error) => void;
|
|
30
|
+
}
|
|
31
|
+
interface UseAttachOAuth {
|
|
32
|
+
state: AttachOAuthState;
|
|
33
|
+
ready: boolean;
|
|
34
|
+
attachOAuth: (options: {
|
|
35
|
+
provider: OAuthProvider$1;
|
|
36
|
+
}) => Promise<void>;
|
|
37
|
+
}
|
|
38
|
+
declare function useAttachOAuth(options?: UseAttachOAuthCallbacks): UseAttachOAuth;
|
|
39
|
+
|
|
40
|
+
interface BaseConnectedEthereumWallet {
|
|
41
|
+
public_address: string;
|
|
42
|
+
wallet_type: "ethereum";
|
|
43
|
+
chain_id?: string;
|
|
44
|
+
connector?: any;
|
|
45
|
+
}
|
|
46
|
+
interface BaseConnectedSolanaWallet {
|
|
47
|
+
public_address: string;
|
|
48
|
+
wallet_type: "solana";
|
|
49
|
+
chain_id?: string;
|
|
50
|
+
}
|
|
51
|
+
interface ConnectWalletParams {
|
|
52
|
+
description?: string;
|
|
53
|
+
walletList?: WalletListEntry[];
|
|
54
|
+
walletChainType?: "ethereum" | "solana" | "ethereum-and-solana";
|
|
55
|
+
mode?: "signIn" | "link";
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
interface ConnectWalletCallbacks {
|
|
59
|
+
onSuccess?: (params: {
|
|
60
|
+
wallet: BaseConnectedEthereumWallet | BaseConnectedSolanaWallet;
|
|
61
|
+
}) => void;
|
|
62
|
+
onError?: (error: Error) => void;
|
|
63
|
+
onClose?: () => void;
|
|
64
|
+
}
|
|
65
|
+
interface UseConnectWallet {
|
|
66
|
+
connectWallet: (params?: ConnectWalletParams) => Promise<void>;
|
|
67
|
+
isConnecting: boolean;
|
|
68
|
+
}
|
|
69
|
+
declare function useConnectWallet(callbacks?: ConnectWalletCallbacks): UseConnectWallet;
|
|
70
|
+
|
|
71
|
+
interface DetachOAuthResult {
|
|
72
|
+
success: boolean;
|
|
73
|
+
message?: string;
|
|
74
|
+
}
|
|
75
|
+
interface DetachOAuthState {
|
|
76
|
+
status: "initial" | "loading" | "done" | "error";
|
|
77
|
+
error: Error | null;
|
|
78
|
+
result: DetachOAuthResult | null;
|
|
79
|
+
}
|
|
80
|
+
interface UseDetachOAuthCallbacks {
|
|
81
|
+
onSuccess?: (result: DetachOAuthResult) => void;
|
|
82
|
+
onError?: (error: Error) => void;
|
|
83
|
+
}
|
|
84
|
+
interface UseDetachOAuth {
|
|
85
|
+
state: DetachOAuthState;
|
|
86
|
+
loading: boolean;
|
|
87
|
+
detachOAuth: (idpUserId: string) => Promise<void>;
|
|
88
|
+
}
|
|
89
|
+
declare function useDetachOAuth(options?: UseDetachOAuthCallbacks): UseDetachOAuth;
|
|
90
|
+
|
|
91
|
+
type OAuthProvider = "google" | "apple";
|
|
92
|
+
interface OAuthUser {
|
|
93
|
+
created_at: number;
|
|
94
|
+
expires_at: number;
|
|
95
|
+
last_active_at: number;
|
|
96
|
+
publishable_key: string;
|
|
97
|
+
access_token: string;
|
|
98
|
+
refresh_token: string;
|
|
99
|
+
user_id: string;
|
|
100
|
+
}
|
|
101
|
+
interface OAuthState {
|
|
102
|
+
status: "initial" | "loading" | "done" | "error";
|
|
103
|
+
error: Error | null;
|
|
104
|
+
user: OAuthUser | null;
|
|
105
|
+
}
|
|
106
|
+
interface UseLoginWithOAuthCallbacks {
|
|
107
|
+
onSuccess?: (result: OAuthUser) => void;
|
|
108
|
+
onError?: (error: Error) => void;
|
|
109
|
+
}
|
|
110
|
+
interface UseLoginWithOAuth {
|
|
111
|
+
state: OAuthState;
|
|
112
|
+
ready: boolean;
|
|
113
|
+
initOAuth: (options: {
|
|
114
|
+
provider: OAuthProvider;
|
|
115
|
+
}) => Promise<void>;
|
|
116
|
+
}
|
|
117
|
+
declare function useLoginWithOAuth(options?: UseLoginWithOAuthCallbacks): UseLoginWithOAuth;
|
|
118
|
+
|
|
119
|
+
interface MoonKeyConfig {
|
|
120
|
+
appearance?: AuthAppearance;
|
|
121
|
+
loginMethods?: ("email" | "google" | "apple" | "wallet")[];
|
|
122
|
+
/**
|
|
123
|
+
* Security-policy knobs. Safe defaults (the entire `security` object
|
|
124
|
+
* can be omitted for the strictest posture).
|
|
125
|
+
*/
|
|
126
|
+
security?: {
|
|
127
|
+
/**
|
|
128
|
+
* TTL in milliseconds for the parent-side passkey assertion cache.
|
|
129
|
+
*
|
|
130
|
+
* Default: 0 (no cache — every sensitive op forces a fresh
|
|
131
|
+
* biometric prompt). This is the safe-by-default posture; the raw
|
|
132
|
+
* userHandle (the AES-GCM KEK that unwraps the user's DEK) never
|
|
133
|
+
* lingers in the parent JS heap past the moment of use.
|
|
134
|
+
*
|
|
135
|
+
* Set to a positive number (e.g. 5 * 60 * 1000) only if the
|
|
136
|
+
* integrating app has a UX that genuinely benefits from skipping
|
|
137
|
+
* the OS passkey prompt on routine ops within a window. The
|
|
138
|
+
* trade-off: during the warm window, parent-coresident JS that
|
|
139
|
+
* can reach the SDK can drive wallet ops without re-prompting.
|
|
140
|
+
*
|
|
141
|
+
* Sensitive operations (export, addPasskey, removePasskey, and
|
|
142
|
+
* any call passing `requireFreshAssertion: true`) bypass the
|
|
143
|
+
* cache regardless of this setting.
|
|
144
|
+
*/
|
|
145
|
+
assertionCacheTtlMs?: number;
|
|
146
|
+
};
|
|
147
|
+
prefill?: PrefillConfig;
|
|
148
|
+
walletChainType?: WalletChainType;
|
|
149
|
+
isDark?: boolean;
|
|
150
|
+
theme?: MoonKeyThemeConfig;
|
|
151
|
+
emailConfig?: {
|
|
152
|
+
skipVerifiedSuccess?: boolean;
|
|
153
|
+
expiresIn?: number;
|
|
154
|
+
verifiedDisplayTime?: number;
|
|
155
|
+
verifyEmailTitle?: string;
|
|
156
|
+
verifyEmailResendTitle?: string;
|
|
157
|
+
resendCodeTime?: number;
|
|
158
|
+
verifiedNewUserMessage?: string;
|
|
159
|
+
verifiedExistingUserMessage?: string;
|
|
160
|
+
verifiedSuccessMessage?: string;
|
|
161
|
+
};
|
|
162
|
+
passkeyEnrollConfig?: PasskeyEnrollConfig;
|
|
163
|
+
signMessageConfig?: SignMessageConfig;
|
|
164
|
+
exportKeyConfig?: ExportKeyConfig;
|
|
165
|
+
signTransactionConfig?: SignTransactionConfig;
|
|
166
|
+
sendTransactionConfig?: SendTransactionConfig;
|
|
167
|
+
walletConnect?: {
|
|
168
|
+
projectId: string;
|
|
169
|
+
};
|
|
170
|
+
defaultChain?: Chain;
|
|
171
|
+
supportedChains?: Chain[];
|
|
172
|
+
solana?: {
|
|
173
|
+
rpcs: {
|
|
174
|
+
[key: string]: {
|
|
175
|
+
rpc: string;
|
|
176
|
+
rpcSubscriptions?: string;
|
|
177
|
+
};
|
|
178
|
+
};
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
interface MoonKeyProviderProps$1 {
|
|
182
|
+
publishableKey: string;
|
|
183
|
+
config?: MoonKeyConfig;
|
|
184
|
+
children: React.ReactNode;
|
|
185
|
+
onClose?: () => void;
|
|
186
|
+
}
|
|
187
|
+
interface MoonKeyInstance {
|
|
188
|
+
ready: boolean;
|
|
189
|
+
isAuthenticated: boolean;
|
|
190
|
+
user: any | null;
|
|
191
|
+
getCurrentSession: () => Promise<any>;
|
|
192
|
+
getUser: () => Promise<any>;
|
|
193
|
+
logout: () => Promise<LogoutResponse>;
|
|
194
|
+
flowState: EmailOtpFlowState;
|
|
195
|
+
/**
|
|
196
|
+
* Get the current user's three-token bundle from IndexedDB. The access
|
|
197
|
+
* token is short-lived (~1h, ES256-signed, JWKS-verifiable by your
|
|
198
|
+
* backend). The identity token carries linked-account metadata. The
|
|
199
|
+
* refresh token is opaque and rotates on every use.
|
|
200
|
+
* @returns Promise with the bundle, or null if not authenticated
|
|
201
|
+
* @example
|
|
202
|
+
* const tokens = await getSessionTokens();
|
|
203
|
+
* if (tokens) {
|
|
204
|
+
* fetch('/api/protected', {
|
|
205
|
+
* headers: { 'X-MoonX-Access-Token': tokens.accessToken }
|
|
206
|
+
* });
|
|
207
|
+
* }
|
|
208
|
+
*/
|
|
209
|
+
getSessionTokens: () => Promise<{
|
|
210
|
+
accessToken: string;
|
|
211
|
+
identityToken: string;
|
|
212
|
+
refreshToken: string;
|
|
213
|
+
expiresAt: number;
|
|
214
|
+
} | null>;
|
|
215
|
+
/**
|
|
216
|
+
* Start authentication flow (UI-based)
|
|
217
|
+
* @param params - Optional configuration to override provider-level config
|
|
218
|
+
* @param params.loginMethods - Login methods to show in UI
|
|
219
|
+
* @param params.prefill - Pre-fill email/phone in UI
|
|
220
|
+
* @param params.disableSignup - Disable signup for new users
|
|
221
|
+
* @param params.walletChainType - Which wallet type to create on login
|
|
222
|
+
*/
|
|
223
|
+
start: (params?: {
|
|
224
|
+
loginMethods?: ("email" | "google" | "apple" | "wallet")[];
|
|
225
|
+
prefill?: {
|
|
226
|
+
type: "email" | "phone";
|
|
227
|
+
value: string;
|
|
228
|
+
};
|
|
229
|
+
disableSignup?: boolean;
|
|
230
|
+
walletChainType?: "ethereum" | "solana" | "ethereum-or-solana";
|
|
231
|
+
}) => Promise<any>;
|
|
232
|
+
onError: (callback: (error: Error) => void) => void;
|
|
233
|
+
onClose: (callback: () => void) => void;
|
|
234
|
+
/**
|
|
235
|
+
* Dynamically update the appearance configuration
|
|
236
|
+
* @param appearance - Appearance configuration including displayMode, backgroundColor, and accentColor
|
|
237
|
+
* @example
|
|
238
|
+
* const { setAppearance } = useMoonKey();
|
|
239
|
+
* const colorScheme = useColorScheme(); // React Native
|
|
240
|
+
* setAppearance({ displayMode: colorScheme === 'dark' ? 'dark' : 'light' });
|
|
241
|
+
*/
|
|
242
|
+
setAppearance: (appearance: AuthAppearance) => void;
|
|
243
|
+
publishableKey: string;
|
|
244
|
+
sendCode: (params: {
|
|
245
|
+
email: string;
|
|
246
|
+
disableSignup?: boolean;
|
|
247
|
+
}) => Promise<void>;
|
|
248
|
+
loginWithCode: (params: {
|
|
249
|
+
code: string;
|
|
250
|
+
}) => Promise<void>;
|
|
251
|
+
}
|
|
252
|
+
interface WalletInstance {
|
|
253
|
+
wallets: () => Promise<Wallet[]>;
|
|
254
|
+
signMessage: (message: string) => Promise<any>;
|
|
255
|
+
getAddress: () => Promise<string>;
|
|
256
|
+
getBalance: () => Promise<string>;
|
|
257
|
+
}
|
|
258
|
+
interface WalletConfig {
|
|
259
|
+
network: "mainnet" | "testnet" | "devnet";
|
|
260
|
+
rpcUrl?: string;
|
|
261
|
+
}
|
|
262
|
+
type WalletType = "solana" | "ethereum";
|
|
263
|
+
|
|
264
|
+
declare const useMoonKey: () => MoonKeyInstance;
|
|
265
|
+
|
|
266
|
+
interface UseOAuthCompletionOptions {
|
|
267
|
+
onSuccess?: (data: any) => void;
|
|
268
|
+
onError?: (error: Error) => void;
|
|
269
|
+
}
|
|
270
|
+
declare function useOAuthCompletion(options?: UseOAuthCompletionOptions): void;
|
|
271
|
+
|
|
272
|
+
interface MoonKeyProviderProps {
|
|
273
|
+
publishableKey: string;
|
|
274
|
+
embeddableId?: string;
|
|
275
|
+
config?: MoonKeyConfig;
|
|
276
|
+
children: ReactNode;
|
|
277
|
+
}
|
|
278
|
+
declare const MoonKeyProvider: React$1.FC<MoonKeyProviderProps>;
|
|
279
|
+
|
|
280
|
+
declare class SessionExpiredError extends Error {
|
|
281
|
+
walletType: string;
|
|
282
|
+
walletAddress?: string;
|
|
283
|
+
requiresReconnection: boolean;
|
|
284
|
+
constructor(walletType: string, walletAddress?: string, message?: string);
|
|
285
|
+
}
|
|
286
|
+
declare class SessionNotFoundError extends Error {
|
|
287
|
+
walletType: string;
|
|
288
|
+
walletAddress?: string;
|
|
289
|
+
requiresReconnection: boolean;
|
|
290
|
+
constructor(walletType: string, walletAddress?: string, message?: string);
|
|
291
|
+
}
|
|
292
|
+
declare const requiresReconnection: (error: any) => boolean;
|
|
293
|
+
declare const getReconnectionInfo: (error: any) => {
|
|
294
|
+
walletType?: string;
|
|
295
|
+
walletAddress?: string;
|
|
296
|
+
} | null;
|
|
297
|
+
|
|
298
|
+
export { type AttachOAuthState, type BaseConnectedEthereumWallet, type BaseConnectedSolanaWallet, type ConnectWalletCallbacks, type ConnectWalletParams, type DetachOAuthResult, type DetachOAuthState, type MoonKeyConfig, type MoonKeyInstance, MoonKeyProvider, type MoonKeyProviderProps$1 as MoonKeyProviderProps, type OAuthAttachResult, type OAuthProvider, type OAuthState, type OAuthUser, SessionExpiredError, SessionNotFoundError, type UseAttachOAuth, type UseAttachOAuthCallbacks, type UseConnectWallet, type UseDetachOAuth, type UseDetachOAuthCallbacks, type UseLoginWithOAuth, type UseLoginWithOAuthCallbacks, type WalletConfig, type WalletInstance, type WalletType, getReconnectionInfo, requiresReconnection, useAttachOAuth, useConnectWallet, useDetachOAuth, useLoginWithOAuth, useMoonKey, useOAuthCompletion };
|