@moon-x/react-native-sdk 0.8.0 → 0.10.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 +5 -5
- package/dist/index.d.mts +8 -7
- package/dist/index.d.ts +8 -7
- package/dist/index.js +69 -12
- package/dist/index.mjs +67 -10
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -70,11 +70,11 @@ opted into JSC, add `text-encoding` and `base-64` polyfills here too.
|
|
|
70
70
|
## Provider
|
|
71
71
|
|
|
72
72
|
```tsx
|
|
73
|
-
import {
|
|
73
|
+
import { MoonXProvider } from "@moon-x/react-native-sdk";
|
|
74
74
|
|
|
75
75
|
export default function Root() {
|
|
76
76
|
return (
|
|
77
|
-
<
|
|
77
|
+
<MoonXProvider
|
|
78
78
|
publishableKey={process.env.EXPO_PUBLIC_MOONKEY_PUBLISHABLE_KEY!}
|
|
79
79
|
config={{
|
|
80
80
|
iframeUrl: "https://iframe.moonx-dev.com",
|
|
@@ -82,7 +82,7 @@ export default function Root() {
|
|
|
82
82
|
}}
|
|
83
83
|
>
|
|
84
84
|
<App />
|
|
85
|
-
</
|
|
85
|
+
</MoonXProvider>
|
|
86
86
|
);
|
|
87
87
|
}
|
|
88
88
|
```
|
|
@@ -131,7 +131,7 @@ TypeScript surface. Every op is always-fresh by construction.
|
|
|
131
131
|
|
|
132
132
|
| Hook | What it does |
|
|
133
133
|
|---|---|
|
|
134
|
-
| `
|
|
134
|
+
| `useMoonX()` | The big one. `{ ready, isAuthenticated, user, start, logout, setAppearance, getSessionTokens, refreshUser, ... }` + every SDK method on the same instance. |
|
|
135
135
|
| `useUser()` | Just `{ user, refreshUser }`. Re-subscribes to user changes. |
|
|
136
136
|
| `useLoginWithEmail({ onComplete?, onError? })` | Headless email-OTP. Returns `{ state, sendCode, loginWithCode, reset }`. `state` is a discriminated union: `idle` / `sending` / `awaiting-code` / `verifying` / `complete` / `error`. |
|
|
137
137
|
| `useLoginWithOAuth()` | Google + Apple flows via `expo-web-browser`. Returns `{ state, loginWithOAuth, reset }`. |
|
|
@@ -186,7 +186,7 @@ Same return shapes as the web SDK — the wire contract is identical.
|
|
|
186
186
|
### Mobile-specific notes
|
|
187
187
|
|
|
188
188
|
- **No `useConnectWallet`.** External-wallet connection (MetaMask, Phantom, WalletConnect) is web-only — MoonX wallets are the only thing you can sign with from the RN SDK.
|
|
189
|
-
- **`useExportKey` is a top-level hook on RN.** On web the same operation hangs off `
|
|
189
|
+
- **`useExportKey` is a top-level hook on RN.** On web the same operation hangs off `useMoonX().exportKey()` inside a parent-side modal; on RN it toggles the always-mounted WebView into a full-screen visible state so the iframe-app renders the key UI itself.
|
|
190
190
|
|
|
191
191
|
## Visible-WebView pattern (sensitive flows)
|
|
192
192
|
|
package/dist/index.d.mts
CHANGED
|
@@ -27,6 +27,7 @@ declare class WebViewBridge {
|
|
|
27
27
|
register<Payload>(type: PostMessageType, method: PostMessageMethod | string, handler: IncomingMessageHandler<Payload>): () => void;
|
|
28
28
|
isReady(): boolean;
|
|
29
29
|
send<Payload, Response>(type: PostMessageType, method: PostMessageMethod | string, payload?: Payload): Promise<Response>;
|
|
30
|
+
private sendOnce;
|
|
30
31
|
sendOneWay<Payload>(type: PostMessageType, method: PostMessageMethod | string, payload?: Payload): void;
|
|
31
32
|
cleanup(reason?: string): void;
|
|
32
33
|
}
|
|
@@ -124,7 +125,7 @@ interface RNAuthSDK {
|
|
|
124
125
|
getSolanaBalance: (params: SolanaGetBalanceParams) => Promise<SolanaGetBalanceResult>;
|
|
125
126
|
}
|
|
126
127
|
|
|
127
|
-
interface
|
|
128
|
+
interface MoonXConfig {
|
|
128
129
|
/**
|
|
129
130
|
* Iframe URL the WebView loads. Optional — defaults to the MoonX
|
|
130
131
|
* production iframe. Override this for staging / preview / local
|
|
@@ -166,9 +167,9 @@ interface MoonKeyConfig {
|
|
|
166
167
|
*/
|
|
167
168
|
security?: Record<string, never>;
|
|
168
169
|
}
|
|
169
|
-
interface
|
|
170
|
+
interface MoonXProviderProps {
|
|
170
171
|
publishableKey: string;
|
|
171
|
-
config?:
|
|
172
|
+
config?: MoonXConfig;
|
|
172
173
|
children: ReactNode;
|
|
173
174
|
}
|
|
174
175
|
interface SensitiveFlowOptions {
|
|
@@ -207,7 +208,7 @@ interface MoonKeyContextValue {
|
|
|
207
208
|
_runSensitiveFlow: (options: SensitiveFlowOptions) => Promise<void>;
|
|
208
209
|
_oauthRedirectUri?: string;
|
|
209
210
|
}
|
|
210
|
-
declare const
|
|
211
|
+
declare const MoonXProvider: React.FC<MoonXProviderProps>;
|
|
211
212
|
declare const useMoonKeyContext: () => MoonKeyContextValue;
|
|
212
213
|
|
|
213
214
|
type State$1 = {
|
|
@@ -277,9 +278,9 @@ declare const useLoginWithOAuth: (params?: {
|
|
|
277
278
|
|
|
278
279
|
/**
|
|
279
280
|
* Returns the active RN AuthSDK instance. Mirrors the web SDK's
|
|
280
|
-
* `
|
|
281
|
+
* `useMoonX()` shape so app code can be moved between web and RN
|
|
281
282
|
* with a 1-line import swap.
|
|
282
283
|
*/
|
|
283
|
-
declare const
|
|
284
|
+
declare const useMoonX: () => RNAuthSDK;
|
|
284
285
|
|
|
285
|
-
export { type
|
|
286
|
+
export { type MoonXConfig, MoonXProvider, type MoonXProviderProps, type RNAuthSDK, useAttachOAuth, useDetachOAuth, useExportKey, useLoginWithOAuth, useMoonKeyContext, useMoonX };
|
package/dist/index.d.ts
CHANGED
|
@@ -27,6 +27,7 @@ declare class WebViewBridge {
|
|
|
27
27
|
register<Payload>(type: PostMessageType, method: PostMessageMethod | string, handler: IncomingMessageHandler<Payload>): () => void;
|
|
28
28
|
isReady(): boolean;
|
|
29
29
|
send<Payload, Response>(type: PostMessageType, method: PostMessageMethod | string, payload?: Payload): Promise<Response>;
|
|
30
|
+
private sendOnce;
|
|
30
31
|
sendOneWay<Payload>(type: PostMessageType, method: PostMessageMethod | string, payload?: Payload): void;
|
|
31
32
|
cleanup(reason?: string): void;
|
|
32
33
|
}
|
|
@@ -124,7 +125,7 @@ interface RNAuthSDK {
|
|
|
124
125
|
getSolanaBalance: (params: SolanaGetBalanceParams) => Promise<SolanaGetBalanceResult>;
|
|
125
126
|
}
|
|
126
127
|
|
|
127
|
-
interface
|
|
128
|
+
interface MoonXConfig {
|
|
128
129
|
/**
|
|
129
130
|
* Iframe URL the WebView loads. Optional — defaults to the MoonX
|
|
130
131
|
* production iframe. Override this for staging / preview / local
|
|
@@ -166,9 +167,9 @@ interface MoonKeyConfig {
|
|
|
166
167
|
*/
|
|
167
168
|
security?: Record<string, never>;
|
|
168
169
|
}
|
|
169
|
-
interface
|
|
170
|
+
interface MoonXProviderProps {
|
|
170
171
|
publishableKey: string;
|
|
171
|
-
config?:
|
|
172
|
+
config?: MoonXConfig;
|
|
172
173
|
children: ReactNode;
|
|
173
174
|
}
|
|
174
175
|
interface SensitiveFlowOptions {
|
|
@@ -207,7 +208,7 @@ interface MoonKeyContextValue {
|
|
|
207
208
|
_runSensitiveFlow: (options: SensitiveFlowOptions) => Promise<void>;
|
|
208
209
|
_oauthRedirectUri?: string;
|
|
209
210
|
}
|
|
210
|
-
declare const
|
|
211
|
+
declare const MoonXProvider: React.FC<MoonXProviderProps>;
|
|
211
212
|
declare const useMoonKeyContext: () => MoonKeyContextValue;
|
|
212
213
|
|
|
213
214
|
type State$1 = {
|
|
@@ -277,9 +278,9 @@ declare const useLoginWithOAuth: (params?: {
|
|
|
277
278
|
|
|
278
279
|
/**
|
|
279
280
|
* Returns the active RN AuthSDK instance. Mirrors the web SDK's
|
|
280
|
-
* `
|
|
281
|
+
* `useMoonX()` shape so app code can be moved between web and RN
|
|
281
282
|
* with a 1-line import swap.
|
|
282
283
|
*/
|
|
283
|
-
declare const
|
|
284
|
+
declare const useMoonX: () => RNAuthSDK;
|
|
284
285
|
|
|
285
|
-
export { type
|
|
286
|
+
export { type MoonXConfig, MoonXProvider, type MoonXProviderProps, type RNAuthSDK, useAttachOAuth, useDetachOAuth, useExportKey, useLoginWithOAuth, useMoonKeyContext, useMoonX };
|
package/dist/index.js
CHANGED
|
@@ -30,7 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
|
-
|
|
33
|
+
MoonXProvider: () => MoonXProvider,
|
|
34
34
|
PostMessageMethod: () => import_utils8.PostMessageMethod,
|
|
35
35
|
PostMessageType: () => import_utils8.PostMessageType,
|
|
36
36
|
useAddPasskey: () => import_react5.useAddPasskey,
|
|
@@ -43,8 +43,8 @@ __export(index_exports, {
|
|
|
43
43
|
useLoginWithEmail: () => import_react5.useLoginWithEmail,
|
|
44
44
|
useLoginWithOAuth: () => useLoginWithOAuth,
|
|
45
45
|
useLogout: () => import_react5.useLogout,
|
|
46
|
-
useMoonKey: () => useMoonKey,
|
|
47
46
|
useMoonKeyContext: () => useMoonKeyContext,
|
|
47
|
+
useMoonX: () => useMoonX,
|
|
48
48
|
usePasskeyStatus: () => import_react5.usePasskeyStatus,
|
|
49
49
|
useRegisterPasskey: () => import_react5.useRegisterPasskey,
|
|
50
50
|
useRemovePasskey: () => import_react5.useRemovePasskey,
|
|
@@ -361,6 +361,28 @@ var import_utils4 = require("@moon-x/core/utils");
|
|
|
361
361
|
// src/transport/webview-bridge.ts
|
|
362
362
|
var import_utils3 = require("@moon-x/core/utils");
|
|
363
363
|
var REQUEST_TIMEOUT_MS = 3e4;
|
|
364
|
+
var RETRYABLE_METHODS = /* @__PURE__ */ new Set([
|
|
365
|
+
"GET_APP_CONFIG",
|
|
366
|
+
"GET_BALANCE",
|
|
367
|
+
"GET_CURRENT_SESSION",
|
|
368
|
+
"GET_TOKEN_ACCOUNTS_BY_OWNER",
|
|
369
|
+
"GET_USER",
|
|
370
|
+
"GET_WALLET",
|
|
371
|
+
"GET_WALLETS",
|
|
372
|
+
"IS_AUTHENTICATED",
|
|
373
|
+
"GET_PASSKEY_STATUS",
|
|
374
|
+
"GET_DEK_INFO",
|
|
375
|
+
"LIST_EPHEMERAL_SIGNERS"
|
|
376
|
+
]);
|
|
377
|
+
var RETRY_ATTEMPT_TIMEOUTS_MS = [5e3, 1e4, REQUEST_TIMEOUT_MS];
|
|
378
|
+
var RETRY_BACKOFF_MS = [200, 400];
|
|
379
|
+
var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
380
|
+
var TimeoutError = class extends Error {
|
|
381
|
+
constructor(message) {
|
|
382
|
+
super(message);
|
|
383
|
+
this.name = "TimeoutError";
|
|
384
|
+
}
|
|
385
|
+
};
|
|
364
386
|
var generateUUID = () => {
|
|
365
387
|
if (typeof crypto !== "undefined" && crypto.randomUUID) {
|
|
366
388
|
return crypto.randomUUID();
|
|
@@ -470,7 +492,36 @@ var WebViewBridge = class {
|
|
|
470
492
|
return !!this.webViewRef.current;
|
|
471
493
|
}
|
|
472
494
|
// Request/response. Same envelope as @moon-x/core PostMessageClient.
|
|
473
|
-
|
|
495
|
+
// Idempotent reads (see RETRYABLE_METHODS) are auto-retried on timeout to
|
|
496
|
+
// ride out the iframe-app mount race; everything else makes a single attempt.
|
|
497
|
+
async send(type, method, payload) {
|
|
498
|
+
if (!RETRYABLE_METHODS.has(method)) {
|
|
499
|
+
return this.sendOnce(
|
|
500
|
+
type,
|
|
501
|
+
method,
|
|
502
|
+
payload,
|
|
503
|
+
REQUEST_TIMEOUT_MS
|
|
504
|
+
);
|
|
505
|
+
}
|
|
506
|
+
let lastError;
|
|
507
|
+
for (let attempt = 0; attempt < RETRY_ATTEMPT_TIMEOUTS_MS.length; attempt++) {
|
|
508
|
+
try {
|
|
509
|
+
return await this.sendOnce(
|
|
510
|
+
type,
|
|
511
|
+
method,
|
|
512
|
+
payload,
|
|
513
|
+
RETRY_ATTEMPT_TIMEOUTS_MS[attempt]
|
|
514
|
+
);
|
|
515
|
+
} catch (error) {
|
|
516
|
+
lastError = error;
|
|
517
|
+
if (!(error instanceof TimeoutError)) throw error;
|
|
518
|
+
const backoff = RETRY_BACKOFF_MS[attempt];
|
|
519
|
+
if (backoff !== void 0) await sleep(backoff);
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
throw lastError;
|
|
523
|
+
}
|
|
524
|
+
sendOnce(type, method, payload, timeoutMs) {
|
|
474
525
|
const ref = this.webViewRef.current;
|
|
475
526
|
if (!ref) {
|
|
476
527
|
return Promise.reject(new Error("webview_not_ready"));
|
|
@@ -479,8 +530,12 @@ var WebViewBridge = class {
|
|
|
479
530
|
return new Promise((resolve, reject) => {
|
|
480
531
|
const timeoutId = setTimeout(() => {
|
|
481
532
|
this.pending.delete(id);
|
|
482
|
-
reject(
|
|
483
|
-
|
|
533
|
+
reject(
|
|
534
|
+
new TimeoutError(
|
|
535
|
+
`Timeout: no response from WebView for ${type}:${method} after ${timeoutMs}ms`
|
|
536
|
+
)
|
|
537
|
+
);
|
|
538
|
+
}, timeoutMs);
|
|
484
539
|
this.pending.set(id, {
|
|
485
540
|
resolve,
|
|
486
541
|
reject,
|
|
@@ -527,7 +582,7 @@ var import_react2 = require("@moon-x/core/react");
|
|
|
527
582
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
528
583
|
var DEFAULT_IFRAME_URL = "https://iframe.moonx-dev.com";
|
|
529
584
|
var MoonKeyContext = (0, import_react.createContext)(null);
|
|
530
|
-
var
|
|
585
|
+
var MoonXProvider = ({
|
|
531
586
|
publishableKey,
|
|
532
587
|
config,
|
|
533
588
|
children
|
|
@@ -798,7 +853,7 @@ var MoonKeyProvider = ({
|
|
|
798
853
|
var useMoonKeyContext = () => {
|
|
799
854
|
const ctx = (0, import_react.useContext)(MoonKeyContext);
|
|
800
855
|
if (!ctx) {
|
|
801
|
-
throw new Error("
|
|
856
|
+
throw new Error("useMoonX must be used within a MoonXProvider");
|
|
802
857
|
}
|
|
803
858
|
return ctx;
|
|
804
859
|
};
|
|
@@ -1002,14 +1057,16 @@ var useExportKey = () => {
|
|
|
1002
1057
|
const params = new URLSearchParams({
|
|
1003
1058
|
publishableKey: sdk.publishableKey,
|
|
1004
1059
|
wallet_id: wallet.id ?? "",
|
|
1005
|
-
wallet_type: wallet.wallet_type ?? ""
|
|
1060
|
+
wallet_type: wallet.wallet_type ?? ""
|
|
1061
|
+
});
|
|
1062
|
+
const secrets = new URLSearchParams({
|
|
1006
1063
|
user_handle_b64url: userHandleB64url,
|
|
1007
1064
|
credential_id_b64url: credentialIdB64url,
|
|
1008
1065
|
keyshare_read_token: keyshareReadToken
|
|
1009
1066
|
});
|
|
1010
1067
|
await _runSensitiveFlow({
|
|
1011
1068
|
title: "Export key",
|
|
1012
|
-
flowPath: `/export-key?${params.toString()}`,
|
|
1069
|
+
flowPath: `/export-key?${params.toString()}#${secrets.toString()}`,
|
|
1013
1070
|
// No completion postMessage in v1 — the user-tap-Done path
|
|
1014
1071
|
// resolves the promise via the modal's cancel handler. The
|
|
1015
1072
|
// promise simply waits for runSensitiveFlow to settle, which
|
|
@@ -1076,13 +1133,13 @@ var useLoginWithOAuth = (params) => {
|
|
|
1076
1133
|
};
|
|
1077
1134
|
|
|
1078
1135
|
// src/hooks/use-moonkey.ts
|
|
1079
|
-
var
|
|
1136
|
+
var useMoonX = () => useMoonKeyContext().sdk;
|
|
1080
1137
|
|
|
1081
1138
|
// src/index.ts
|
|
1082
1139
|
var import_utils8 = require("@moon-x/core/utils");
|
|
1083
1140
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1084
1141
|
0 && (module.exports = {
|
|
1085
|
-
|
|
1142
|
+
MoonXProvider,
|
|
1086
1143
|
PostMessageMethod,
|
|
1087
1144
|
PostMessageType,
|
|
1088
1145
|
useAddPasskey,
|
|
@@ -1095,8 +1152,8 @@ var import_utils8 = require("@moon-x/core/utils");
|
|
|
1095
1152
|
useLoginWithEmail,
|
|
1096
1153
|
useLoginWithOAuth,
|
|
1097
1154
|
useLogout,
|
|
1098
|
-
useMoonKey,
|
|
1099
1155
|
useMoonKeyContext,
|
|
1156
|
+
useMoonX,
|
|
1100
1157
|
usePasskeyStatus,
|
|
1101
1158
|
useRegisterPasskey,
|
|
1102
1159
|
useRemovePasskey,
|
package/dist/index.mjs
CHANGED
|
@@ -335,6 +335,28 @@ import {
|
|
|
335
335
|
FORWARDED_ERROR_FIELDS
|
|
336
336
|
} from "@moon-x/core/utils";
|
|
337
337
|
var REQUEST_TIMEOUT_MS = 3e4;
|
|
338
|
+
var RETRYABLE_METHODS = /* @__PURE__ */ new Set([
|
|
339
|
+
"GET_APP_CONFIG",
|
|
340
|
+
"GET_BALANCE",
|
|
341
|
+
"GET_CURRENT_SESSION",
|
|
342
|
+
"GET_TOKEN_ACCOUNTS_BY_OWNER",
|
|
343
|
+
"GET_USER",
|
|
344
|
+
"GET_WALLET",
|
|
345
|
+
"GET_WALLETS",
|
|
346
|
+
"IS_AUTHENTICATED",
|
|
347
|
+
"GET_PASSKEY_STATUS",
|
|
348
|
+
"GET_DEK_INFO",
|
|
349
|
+
"LIST_EPHEMERAL_SIGNERS"
|
|
350
|
+
]);
|
|
351
|
+
var RETRY_ATTEMPT_TIMEOUTS_MS = [5e3, 1e4, REQUEST_TIMEOUT_MS];
|
|
352
|
+
var RETRY_BACKOFF_MS = [200, 400];
|
|
353
|
+
var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
354
|
+
var TimeoutError = class extends Error {
|
|
355
|
+
constructor(message) {
|
|
356
|
+
super(message);
|
|
357
|
+
this.name = "TimeoutError";
|
|
358
|
+
}
|
|
359
|
+
};
|
|
338
360
|
var generateUUID = () => {
|
|
339
361
|
if (typeof crypto !== "undefined" && crypto.randomUUID) {
|
|
340
362
|
return crypto.randomUUID();
|
|
@@ -444,7 +466,36 @@ var WebViewBridge = class {
|
|
|
444
466
|
return !!this.webViewRef.current;
|
|
445
467
|
}
|
|
446
468
|
// Request/response. Same envelope as @moon-x/core PostMessageClient.
|
|
447
|
-
|
|
469
|
+
// Idempotent reads (see RETRYABLE_METHODS) are auto-retried on timeout to
|
|
470
|
+
// ride out the iframe-app mount race; everything else makes a single attempt.
|
|
471
|
+
async send(type, method, payload) {
|
|
472
|
+
if (!RETRYABLE_METHODS.has(method)) {
|
|
473
|
+
return this.sendOnce(
|
|
474
|
+
type,
|
|
475
|
+
method,
|
|
476
|
+
payload,
|
|
477
|
+
REQUEST_TIMEOUT_MS
|
|
478
|
+
);
|
|
479
|
+
}
|
|
480
|
+
let lastError;
|
|
481
|
+
for (let attempt = 0; attempt < RETRY_ATTEMPT_TIMEOUTS_MS.length; attempt++) {
|
|
482
|
+
try {
|
|
483
|
+
return await this.sendOnce(
|
|
484
|
+
type,
|
|
485
|
+
method,
|
|
486
|
+
payload,
|
|
487
|
+
RETRY_ATTEMPT_TIMEOUTS_MS[attempt]
|
|
488
|
+
);
|
|
489
|
+
} catch (error) {
|
|
490
|
+
lastError = error;
|
|
491
|
+
if (!(error instanceof TimeoutError)) throw error;
|
|
492
|
+
const backoff = RETRY_BACKOFF_MS[attempt];
|
|
493
|
+
if (backoff !== void 0) await sleep(backoff);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
throw lastError;
|
|
497
|
+
}
|
|
498
|
+
sendOnce(type, method, payload, timeoutMs) {
|
|
448
499
|
const ref = this.webViewRef.current;
|
|
449
500
|
if (!ref) {
|
|
450
501
|
return Promise.reject(new Error("webview_not_ready"));
|
|
@@ -453,8 +504,12 @@ var WebViewBridge = class {
|
|
|
453
504
|
return new Promise((resolve, reject) => {
|
|
454
505
|
const timeoutId = setTimeout(() => {
|
|
455
506
|
this.pending.delete(id);
|
|
456
|
-
reject(
|
|
457
|
-
|
|
507
|
+
reject(
|
|
508
|
+
new TimeoutError(
|
|
509
|
+
`Timeout: no response from WebView for ${type}:${method} after ${timeoutMs}ms`
|
|
510
|
+
)
|
|
511
|
+
);
|
|
512
|
+
}, timeoutMs);
|
|
458
513
|
this.pending.set(id, {
|
|
459
514
|
resolve,
|
|
460
515
|
reject,
|
|
@@ -501,7 +556,7 @@ import { SDKProvider } from "@moon-x/core/react";
|
|
|
501
556
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
502
557
|
var DEFAULT_IFRAME_URL = "https://iframe.moonx-dev.com";
|
|
503
558
|
var MoonKeyContext = createContext(null);
|
|
504
|
-
var
|
|
559
|
+
var MoonXProvider = ({
|
|
505
560
|
publishableKey,
|
|
506
561
|
config,
|
|
507
562
|
children
|
|
@@ -772,7 +827,7 @@ var MoonKeyProvider = ({
|
|
|
772
827
|
var useMoonKeyContext = () => {
|
|
773
828
|
const ctx = useContext(MoonKeyContext);
|
|
774
829
|
if (!ctx) {
|
|
775
|
-
throw new Error("
|
|
830
|
+
throw new Error("useMoonX must be used within a MoonXProvider");
|
|
776
831
|
}
|
|
777
832
|
return ctx;
|
|
778
833
|
};
|
|
@@ -988,14 +1043,16 @@ var useExportKey = () => {
|
|
|
988
1043
|
const params = new URLSearchParams({
|
|
989
1044
|
publishableKey: sdk.publishableKey,
|
|
990
1045
|
wallet_id: wallet.id ?? "",
|
|
991
|
-
wallet_type: wallet.wallet_type ?? ""
|
|
1046
|
+
wallet_type: wallet.wallet_type ?? ""
|
|
1047
|
+
});
|
|
1048
|
+
const secrets = new URLSearchParams({
|
|
992
1049
|
user_handle_b64url: userHandleB64url,
|
|
993
1050
|
credential_id_b64url: credentialIdB64url,
|
|
994
1051
|
keyshare_read_token: keyshareReadToken
|
|
995
1052
|
});
|
|
996
1053
|
await _runSensitiveFlow({
|
|
997
1054
|
title: "Export key",
|
|
998
|
-
flowPath: `/export-key?${params.toString()}`,
|
|
1055
|
+
flowPath: `/export-key?${params.toString()}#${secrets.toString()}`,
|
|
999
1056
|
// No completion postMessage in v1 — the user-tap-Done path
|
|
1000
1057
|
// resolves the promise via the modal's cancel handler. The
|
|
1001
1058
|
// promise simply waits for runSensitiveFlow to settle, which
|
|
@@ -1062,12 +1119,12 @@ var useLoginWithOAuth = (params) => {
|
|
|
1062
1119
|
};
|
|
1063
1120
|
|
|
1064
1121
|
// src/hooks/use-moonkey.ts
|
|
1065
|
-
var
|
|
1122
|
+
var useMoonX = () => useMoonKeyContext().sdk;
|
|
1066
1123
|
|
|
1067
1124
|
// src/index.ts
|
|
1068
1125
|
import { PostMessageMethod as PostMessageMethod7, PostMessageType as PostMessageType7 } from "@moon-x/core/utils";
|
|
1069
1126
|
export {
|
|
1070
|
-
|
|
1127
|
+
MoonXProvider,
|
|
1071
1128
|
PostMessageMethod7 as PostMessageMethod,
|
|
1072
1129
|
PostMessageType7 as PostMessageType,
|
|
1073
1130
|
useAddPasskey,
|
|
@@ -1080,8 +1137,8 @@ export {
|
|
|
1080
1137
|
useLoginWithEmail,
|
|
1081
1138
|
useLoginWithOAuth,
|
|
1082
1139
|
useLogout,
|
|
1083
|
-
useMoonKey,
|
|
1084
1140
|
useMoonKeyContext,
|
|
1141
|
+
useMoonX,
|
|
1085
1142
|
usePasskeyStatus,
|
|
1086
1143
|
useRegisterPasskey,
|
|
1087
1144
|
useRemovePasskey,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moon-x/react-native-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "MoonX React Native SDK — WebView-backed transport, react-native-passkeys, AsyncStorage. Mobile parity with @moon-x/react-sdk + @moon-x/core-sdk.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"typescript": "5.9.3"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@moon-x/core": "0.
|
|
52
|
+
"@moon-x/core": "0.12.0"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
55
|
"@expo/config-plugins": ">=10.0.0",
|