@moon-x/react-native-sdk 0.3.0 → 0.4.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 +1 -0
- package/dist/index.d.mts +14 -14
- package/dist/index.d.ts +14 -14
- package/dist/index.js +53 -34
- package/dist/index.mjs +60 -35
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -155,6 +155,7 @@ TypeScript surface. Every op is always-fresh by construction.
|
|
|
155
155
|
| `useCreateWallet()` | Mint a new MPC wallet. Pass `{ walletType: "ethereum" \| "solana" }`. |
|
|
156
156
|
| `useImportKey()` | Bring-your-own-key flow. |
|
|
157
157
|
| `useExportKey()` | Show the user their private key via the visible-WebView modal pattern (see below). Plaintext never leaves the WebView's DOM. |
|
|
158
|
+
| `useEphemeralSigner()` | Manage the user's WaaS ephemeral signers (SES) end-to-end. Returns `{ signers, isLoading, refresh, provision, revoke, lastProvisioned, error, reset, ... }`. Auto-refreshes the list after provision/revoke. |
|
|
158
159
|
|
|
159
160
|
### Per-chain signing — `/ethereum` and `/solana` subpaths
|
|
160
161
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
|
+
import { RelyingPartyOriginInput } from '@moon-x/core/sdk';
|
|
2
3
|
import { PostMessageType, PostMessageMethod } from '@moon-x/core/utils';
|
|
3
4
|
export { PostMessageMethod, PostMessageType } from '@moon-x/core/utils';
|
|
4
5
|
import * as _moon_x_core_types from '@moon-x/core/types';
|
|
5
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';
|
|
6
|
-
export { Chain, EthereumGetBalanceParams, EthereumGetBalanceResult, EthereumSendTransactionParams, EthereumSendTransactionResult, EthereumSign7702AuthorizationParams, EthereumSign7702AuthorizationResult, EthereumSignHashParams, EthereumSignHashResult, EthereumSignMessageParams, EthereumSignMessageResult, EthereumSignTransactionParams, EthereumSignTransactionResult, EthereumSignTypedDataParams, EthereumSignTypedDataResult, Network, PublicWallet, SolanaGetBalanceParams, SolanaGetBalanceResult, SolanaSendTransactionParams, SolanaSendTransactionResult, SolanaSignMessageParams, SolanaSignMessageResult, SolanaSignTransactionParams, SolanaSignTransactionResult, WalletConnectConfig } from '@moon-x/core/types';
|
|
7
|
-
export { useAddPasskey, useCreateWallet, useImportKey, useLoginWithEmail, useLogout, usePasskeyStatus, useRegisterPasskey, useRemovePasskey, useUser, useWallets } from '@moon-x/core/react';
|
|
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';
|
|
8
9
|
|
|
9
10
|
interface WebViewRefLike {
|
|
10
11
|
injectJavaScript: (script: string) => void;
|
|
@@ -130,18 +131,17 @@ interface MoonKeyConfig {
|
|
|
130
131
|
*/
|
|
131
132
|
oauthRedirectUri?: string;
|
|
132
133
|
/**
|
|
133
|
-
* **
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
* native authenticator will assert against.
|
|
134
|
+
* **Optional override** for the host app's WebAuthn relying-party
|
|
135
|
+
* origin (e.g. `"https://wallet.acme.com"`). The SDK threads this into
|
|
136
|
+
* the internal presence-token orchestrator at
|
|
137
|
+
* `/auth/passkey/presence/begin` so the backend can rebuild the
|
|
138
|
+
* per-app WebAuthn RP config the native authenticator asserts against.
|
|
139
139
|
*
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
*
|
|
140
|
+
* Leave it unset in the common case: the SDK derives the origin
|
|
141
|
+
* automatically from the app's server-configured `rp_id` (fetched via
|
|
142
|
+
* the iframe) as `https://<rp_id>`, matching what the native passkey
|
|
143
|
+
* ceremony uses. Set this only if your app needs an origin that
|
|
144
|
+
* differs from the configured `rp_id`.
|
|
145
145
|
*/
|
|
146
146
|
relyingPartyOrigin?: string;
|
|
147
147
|
/**
|
|
@@ -196,7 +196,7 @@ interface SensitiveFlowMountApi {
|
|
|
196
196
|
interface MoonKeyContextValue {
|
|
197
197
|
sdk: RNAuthSDK;
|
|
198
198
|
_bridge: WebViewBridge;
|
|
199
|
-
_relyingPartyOrigin:
|
|
199
|
+
_relyingPartyOrigin: RelyingPartyOriginInput;
|
|
200
200
|
_runSensitiveFlow: (options: SensitiveFlowOptions) => Promise<void>;
|
|
201
201
|
_oauthRedirectUri?: string;
|
|
202
202
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
|
+
import { RelyingPartyOriginInput } from '@moon-x/core/sdk';
|
|
2
3
|
import { PostMessageType, PostMessageMethod } from '@moon-x/core/utils';
|
|
3
4
|
export { PostMessageMethod, PostMessageType } from '@moon-x/core/utils';
|
|
4
5
|
import * as _moon_x_core_types from '@moon-x/core/types';
|
|
5
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';
|
|
6
|
-
export { Chain, EthereumGetBalanceParams, EthereumGetBalanceResult, EthereumSendTransactionParams, EthereumSendTransactionResult, EthereumSign7702AuthorizationParams, EthereumSign7702AuthorizationResult, EthereumSignHashParams, EthereumSignHashResult, EthereumSignMessageParams, EthereumSignMessageResult, EthereumSignTransactionParams, EthereumSignTransactionResult, EthereumSignTypedDataParams, EthereumSignTypedDataResult, Network, PublicWallet, SolanaGetBalanceParams, SolanaGetBalanceResult, SolanaSendTransactionParams, SolanaSendTransactionResult, SolanaSignMessageParams, SolanaSignMessageResult, SolanaSignTransactionParams, SolanaSignTransactionResult, WalletConnectConfig } from '@moon-x/core/types';
|
|
7
|
-
export { useAddPasskey, useCreateWallet, useImportKey, useLoginWithEmail, useLogout, usePasskeyStatus, useRegisterPasskey, useRemovePasskey, useUser, useWallets } from '@moon-x/core/react';
|
|
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';
|
|
8
9
|
|
|
9
10
|
interface WebViewRefLike {
|
|
10
11
|
injectJavaScript: (script: string) => void;
|
|
@@ -130,18 +131,17 @@ interface MoonKeyConfig {
|
|
|
130
131
|
*/
|
|
131
132
|
oauthRedirectUri?: string;
|
|
132
133
|
/**
|
|
133
|
-
* **
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
* native authenticator will assert against.
|
|
134
|
+
* **Optional override** for the host app's WebAuthn relying-party
|
|
135
|
+
* origin (e.g. `"https://wallet.acme.com"`). The SDK threads this into
|
|
136
|
+
* the internal presence-token orchestrator at
|
|
137
|
+
* `/auth/passkey/presence/begin` so the backend can rebuild the
|
|
138
|
+
* per-app WebAuthn RP config the native authenticator asserts against.
|
|
139
139
|
*
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
*
|
|
140
|
+
* Leave it unset in the common case: the SDK derives the origin
|
|
141
|
+
* automatically from the app's server-configured `rp_id` (fetched via
|
|
142
|
+
* the iframe) as `https://<rp_id>`, matching what the native passkey
|
|
143
|
+
* ceremony uses. Set this only if your app needs an origin that
|
|
144
|
+
* differs from the configured `rp_id`.
|
|
145
145
|
*/
|
|
146
146
|
relyingPartyOrigin?: string;
|
|
147
147
|
/**
|
|
@@ -196,7 +196,7 @@ interface SensitiveFlowMountApi {
|
|
|
196
196
|
interface MoonKeyContextValue {
|
|
197
197
|
sdk: RNAuthSDK;
|
|
198
198
|
_bridge: WebViewBridge;
|
|
199
|
-
_relyingPartyOrigin:
|
|
199
|
+
_relyingPartyOrigin: RelyingPartyOriginInput;
|
|
200
200
|
_runSensitiveFlow: (options: SensitiveFlowOptions) => Promise<void>;
|
|
201
201
|
_oauthRedirectUri?: string;
|
|
202
202
|
}
|
package/dist/index.js
CHANGED
|
@@ -31,12 +31,13 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
MoonKeyProvider: () => MoonKeyProvider,
|
|
34
|
-
PostMessageMethod: () =>
|
|
35
|
-
PostMessageType: () =>
|
|
34
|
+
PostMessageMethod: () => import_utils8.PostMessageMethod,
|
|
35
|
+
PostMessageType: () => import_utils8.PostMessageType,
|
|
36
36
|
useAddPasskey: () => import_react5.useAddPasskey,
|
|
37
37
|
useAttachOAuth: () => useAttachOAuth,
|
|
38
38
|
useCreateWallet: () => import_react5.useCreateWallet,
|
|
39
39
|
useDetachOAuth: () => useDetachOAuth,
|
|
40
|
+
useEphemeralSigner: () => import_react5.useEphemeralSigner,
|
|
40
41
|
useExportKey: () => useExportKey,
|
|
41
42
|
useImportKey: () => import_react5.useImportKey,
|
|
42
43
|
useLoginWithEmail: () => import_react5.useLoginWithEmail,
|
|
@@ -57,6 +58,9 @@ var import_react = require("react");
|
|
|
57
58
|
var import_react_native = require("react-native");
|
|
58
59
|
var import_react_native_webview = require("react-native-webview");
|
|
59
60
|
|
|
61
|
+
// src/sdk/create-sdk-instance.ts
|
|
62
|
+
var import_utils2 = require("@moon-x/core/utils");
|
|
63
|
+
|
|
60
64
|
// src/sdk/sdk-authentication-methods.ts
|
|
61
65
|
var import_sdk = require("@moon-x/core/sdk");
|
|
62
66
|
var getAuthenticationMethods = (bridge, publishableKey, setIsAuthenticated, setUser) => (0, import_sdk.getHeadlessAuthenticationMethods)({
|
|
@@ -301,6 +305,22 @@ var getSolanaSDKMethods = (bridge, publishableKey, relyingPartyOrigin) => (0, im
|
|
|
301
305
|
});
|
|
302
306
|
|
|
303
307
|
// src/sdk/create-sdk-instance.ts
|
|
308
|
+
var makeRelyingPartyOriginResolver = (bridge, publishableKey, configuredOrigin) => {
|
|
309
|
+
let cached = configuredOrigin || null;
|
|
310
|
+
return async () => {
|
|
311
|
+
if (cached) return cached;
|
|
312
|
+
const dekInfo = await bridge.send(
|
|
313
|
+
import_utils2.PostMessageType.AUTH,
|
|
314
|
+
import_utils2.PostMessageMethod.GET_DEK_INFO,
|
|
315
|
+
{ publishableKey }
|
|
316
|
+
);
|
|
317
|
+
if (!dekInfo.rp_id) {
|
|
318
|
+
throw new Error("webauthn_rp_id_not_configured");
|
|
319
|
+
}
|
|
320
|
+
cached = `https://${dekInfo.rp_id}`;
|
|
321
|
+
return cached;
|
|
322
|
+
};
|
|
323
|
+
};
|
|
304
324
|
var createSdkInstance = ({
|
|
305
325
|
bridge,
|
|
306
326
|
publishableKey,
|
|
@@ -336,10 +356,10 @@ var createSdkInstance = ({
|
|
|
336
356
|
});
|
|
337
357
|
|
|
338
358
|
// src/provider.tsx
|
|
339
|
-
var
|
|
359
|
+
var import_utils4 = require("@moon-x/core/utils");
|
|
340
360
|
|
|
341
361
|
// src/transport/webview-bridge.ts
|
|
342
|
-
var
|
|
362
|
+
var import_utils3 = require("@moon-x/core/utils");
|
|
343
363
|
var REQUEST_TIMEOUT_MS = 3e4;
|
|
344
364
|
var generateUUID = () => {
|
|
345
365
|
if (typeof crypto !== "undefined" && crypto.randomUUID) {
|
|
@@ -415,7 +435,7 @@ var WebViewBridge = class {
|
|
|
415
435
|
resolver.resolve(message.data);
|
|
416
436
|
} else {
|
|
417
437
|
const err = new Error(message.error || "WebView bridge error");
|
|
418
|
-
for (const key of
|
|
438
|
+
for (const key of import_utils3.FORWARDED_ERROR_FIELDS) {
|
|
419
439
|
const value = message[key];
|
|
420
440
|
if (value !== void 0) {
|
|
421
441
|
err[key] = value;
|
|
@@ -514,11 +534,6 @@ var MoonKeyProvider = ({
|
|
|
514
534
|
}) => {
|
|
515
535
|
const iframeUrl = config?.iframeUrl ?? DEFAULT_IFRAME_URL;
|
|
516
536
|
const relyingPartyOrigin = config?.relyingPartyOrigin ?? "";
|
|
517
|
-
if (!relyingPartyOrigin && typeof console !== "undefined") {
|
|
518
|
-
console.warn(
|
|
519
|
-
"[MoonKey] config.relyingPartyOrigin is empty \u2014 every sensitive op (sign / send / createWallet / importKey / exportKey / addPasskey / removePasskey) will fail until this is set to your host app's WebAuthn relying-party origin (e.g. https://wallet.acme.com)."
|
|
520
|
-
);
|
|
521
|
-
}
|
|
522
537
|
const webViewRef = (0, import_react.useRef)(null);
|
|
523
538
|
const bridge = (0, import_react.useMemo)(
|
|
524
539
|
() => new WebViewBridge(
|
|
@@ -526,6 +541,10 @@ var MoonKeyProvider = ({
|
|
|
526
541
|
),
|
|
527
542
|
[]
|
|
528
543
|
);
|
|
544
|
+
const relyingPartyOriginResolver = (0, import_react.useMemo)(
|
|
545
|
+
() => makeRelyingPartyOriginResolver(bridge, publishableKey, relyingPartyOrigin),
|
|
546
|
+
[bridge, publishableKey, relyingPartyOrigin]
|
|
547
|
+
);
|
|
529
548
|
const [sensitiveVisible, setSensitiveVisible] = (0, import_react.useState)(false);
|
|
530
549
|
const cancelRef = (0, import_react.useRef)(null);
|
|
531
550
|
const [ready, setReady] = (0, import_react.useState)(false);
|
|
@@ -611,13 +630,12 @@ var MoonKeyProvider = ({
|
|
|
611
630
|
() => createSdkInstance({
|
|
612
631
|
bridge,
|
|
613
632
|
publishableKey,
|
|
614
|
-
//
|
|
615
|
-
//
|
|
616
|
-
//
|
|
617
|
-
//
|
|
618
|
-
//
|
|
619
|
-
|
|
620
|
-
relyingPartyOrigin,
|
|
633
|
+
// Shared resolver — empty in the common case, then derives
|
|
634
|
+
// `https://<rp_id>` from the iframe at the first sensitive op and
|
|
635
|
+
// threads it into getInternalPresenceTokens, which forwards it on
|
|
636
|
+
// /presence/begin so the server can rebuild the per-app WebAuthn
|
|
637
|
+
// RP config.
|
|
638
|
+
relyingPartyOrigin: relyingPartyOriginResolver,
|
|
621
639
|
isAuthenticated,
|
|
622
640
|
user,
|
|
623
641
|
ready,
|
|
@@ -628,7 +646,7 @@ var MoonKeyProvider = ({
|
|
|
628
646
|
[
|
|
629
647
|
bridge,
|
|
630
648
|
publishableKey,
|
|
631
|
-
|
|
649
|
+
relyingPartyOriginResolver,
|
|
632
650
|
isAuthenticated,
|
|
633
651
|
user,
|
|
634
652
|
ready,
|
|
@@ -647,8 +665,8 @@ var MoonKeyProvider = ({
|
|
|
647
665
|
(0, import_react.useEffect)(() => {
|
|
648
666
|
let cancelled = false;
|
|
649
667
|
const unregister = bridge.register(
|
|
650
|
-
|
|
651
|
-
|
|
668
|
+
import_utils4.PostMessageType.INIT,
|
|
669
|
+
import_utils4.PostMessageMethod.READY,
|
|
652
670
|
() => {
|
|
653
671
|
if (!cancelled) setReady(true);
|
|
654
672
|
}
|
|
@@ -702,14 +720,14 @@ var MoonKeyProvider = ({
|
|
|
702
720
|
() => ({
|
|
703
721
|
sdk,
|
|
704
722
|
_bridge: bridge,
|
|
705
|
-
_relyingPartyOrigin:
|
|
723
|
+
_relyingPartyOrigin: relyingPartyOriginResolver,
|
|
706
724
|
_runSensitiveFlow: runSensitiveFlow,
|
|
707
725
|
_oauthRedirectUri: config?.oauthRedirectUri
|
|
708
726
|
}),
|
|
709
727
|
[
|
|
710
728
|
sdk,
|
|
711
729
|
bridge,
|
|
712
|
-
|
|
730
|
+
relyingPartyOriginResolver,
|
|
713
731
|
runSensitiveFlow,
|
|
714
732
|
config?.oauthRedirectUri
|
|
715
733
|
]
|
|
@@ -859,7 +877,7 @@ var styles = import_react_native.StyleSheet.create({
|
|
|
859
877
|
var import_react5 = require("@moon-x/core/react");
|
|
860
878
|
|
|
861
879
|
// src/hooks/use-attach-oauth.ts
|
|
862
|
-
var
|
|
880
|
+
var import_utils5 = require("@moon-x/core/utils");
|
|
863
881
|
var import_react3 = require("react");
|
|
864
882
|
|
|
865
883
|
// src/lib/oauth-deep-link.ts
|
|
@@ -910,8 +928,8 @@ var useAttachOAuth = (params) => {
|
|
|
910
928
|
const redirectUri = params?.redirectUri || _oauthRedirectUri;
|
|
911
929
|
if (!redirectUri) throw new Error("oauth_redirect_uri_missing");
|
|
912
930
|
const startResult = await _bridge.send(
|
|
913
|
-
|
|
914
|
-
|
|
931
|
+
import_utils5.PostMessageType.AUTH,
|
|
932
|
+
import_utils5.PostMessageMethod.START_OAUTH,
|
|
915
933
|
{
|
|
916
934
|
publishableKey: sdk.publishableKey,
|
|
917
935
|
provider,
|
|
@@ -931,8 +949,8 @@ var useAttachOAuth = (params) => {
|
|
|
931
949
|
if (parsed.error) throw new Error(parsed.error);
|
|
932
950
|
setState({ status: "verifying" });
|
|
933
951
|
await _bridge.send(
|
|
934
|
-
|
|
935
|
-
|
|
952
|
+
import_utils5.PostMessageType.AUTH,
|
|
953
|
+
import_utils5.PostMessageMethod.ATTACH_OAUTH,
|
|
936
954
|
{
|
|
937
955
|
publishableKey: sdk.publishableKey,
|
|
938
956
|
provider,
|
|
@@ -953,14 +971,14 @@ var useAttachOAuth = (params) => {
|
|
|
953
971
|
};
|
|
954
972
|
|
|
955
973
|
// src/hooks/use-detach-oauth.ts
|
|
956
|
-
var
|
|
974
|
+
var import_utils6 = require("@moon-x/core/utils");
|
|
957
975
|
var useDetachOAuth = () => {
|
|
958
976
|
const { sdk, _bridge } = useMoonKeyContext();
|
|
959
977
|
return {
|
|
960
978
|
detachOAuth: async (idpUserId) => {
|
|
961
979
|
await _bridge.send(
|
|
962
|
-
|
|
963
|
-
|
|
980
|
+
import_utils6.PostMessageType.AUTH,
|
|
981
|
+
import_utils6.PostMessageMethod.DETACH_OAUTH,
|
|
964
982
|
{ publishableKey: sdk.publishableKey, idpUserId }
|
|
965
983
|
);
|
|
966
984
|
}
|
|
@@ -1004,7 +1022,7 @@ var useExportKey = () => {
|
|
|
1004
1022
|
};
|
|
1005
1023
|
|
|
1006
1024
|
// src/hooks/use-login-with-oauth.ts
|
|
1007
|
-
var
|
|
1025
|
+
var import_utils7 = require("@moon-x/core/utils");
|
|
1008
1026
|
var import_react4 = require("react");
|
|
1009
1027
|
var useLoginWithOAuth = (params) => {
|
|
1010
1028
|
const { sdk, _bridge, _oauthRedirectUri } = useMoonKeyContext();
|
|
@@ -1019,8 +1037,8 @@ var useLoginWithOAuth = (params) => {
|
|
|
1019
1037
|
throw new Error("oauth_redirect_uri_missing");
|
|
1020
1038
|
}
|
|
1021
1039
|
const startResult = await _bridge.send(
|
|
1022
|
-
|
|
1023
|
-
|
|
1040
|
+
import_utils7.PostMessageType.AUTH,
|
|
1041
|
+
import_utils7.PostMessageMethod.START_OAUTH,
|
|
1024
1042
|
{
|
|
1025
1043
|
publishableKey: sdk.publishableKey,
|
|
1026
1044
|
provider,
|
|
@@ -1062,7 +1080,7 @@ var useLoginWithOAuth = (params) => {
|
|
|
1062
1080
|
var useMoonKey = () => useMoonKeyContext().sdk;
|
|
1063
1081
|
|
|
1064
1082
|
// src/index.ts
|
|
1065
|
-
var
|
|
1083
|
+
var import_utils8 = require("@moon-x/core/utils");
|
|
1066
1084
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1067
1085
|
0 && (module.exports = {
|
|
1068
1086
|
MoonKeyProvider,
|
|
@@ -1072,6 +1090,7 @@ var import_utils7 = require("@moon-x/core/utils");
|
|
|
1072
1090
|
useAttachOAuth,
|
|
1073
1091
|
useCreateWallet,
|
|
1074
1092
|
useDetachOAuth,
|
|
1093
|
+
useEphemeralSigner,
|
|
1075
1094
|
useExportKey,
|
|
1076
1095
|
useImportKey,
|
|
1077
1096
|
useLoginWithEmail,
|
package/dist/index.mjs
CHANGED
|
@@ -19,6 +19,9 @@ import {
|
|
|
19
19
|
} from "react-native";
|
|
20
20
|
import { WebView } from "react-native-webview";
|
|
21
21
|
|
|
22
|
+
// src/sdk/create-sdk-instance.ts
|
|
23
|
+
import { PostMessageMethod as PostMessageMethod2, PostMessageType as PostMessageType2 } from "@moon-x/core/utils";
|
|
24
|
+
|
|
22
25
|
// src/sdk/sdk-authentication-methods.ts
|
|
23
26
|
import { getHeadlessAuthenticationMethods } from "@moon-x/core/sdk";
|
|
24
27
|
var getAuthenticationMethods = (bridge, publishableKey, setIsAuthenticated, setUser) => getHeadlessAuthenticationMethods({
|
|
@@ -29,7 +32,9 @@ var getAuthenticationMethods = (bridge, publishableKey, setIsAuthenticated, setU
|
|
|
29
32
|
});
|
|
30
33
|
|
|
31
34
|
// src/sdk/sdk-ethereum-methods.ts
|
|
32
|
-
import {
|
|
35
|
+
import {
|
|
36
|
+
getHeadlessEthereumMethods
|
|
37
|
+
} from "@moon-x/core/sdk";
|
|
33
38
|
|
|
34
39
|
// src/platform/async-storage-kv.ts
|
|
35
40
|
import AsyncStorage from "@react-native-async-storage/async-storage";
|
|
@@ -246,7 +251,9 @@ var getPasskeyMethods = (bridge, publishableKey) => ({
|
|
|
246
251
|
});
|
|
247
252
|
|
|
248
253
|
// src/sdk/sdk-methods.ts
|
|
249
|
-
import {
|
|
254
|
+
import {
|
|
255
|
+
getHeadlessGeneralMethods
|
|
256
|
+
} from "@moon-x/core/sdk";
|
|
250
257
|
var getSDKMethods = (bridge, publishableKey, relyingPartyOrigin, setIsAuthenticated, setUser) => getHeadlessGeneralMethods({
|
|
251
258
|
transport: bridge,
|
|
252
259
|
passkey: createRNPasskey(),
|
|
@@ -258,7 +265,9 @@ var getSDKMethods = (bridge, publishableKey, relyingPartyOrigin, setIsAuthentica
|
|
|
258
265
|
});
|
|
259
266
|
|
|
260
267
|
// src/sdk/sdk-solana-methods.ts
|
|
261
|
-
import {
|
|
268
|
+
import {
|
|
269
|
+
getHeadlessSolanaMethods
|
|
270
|
+
} from "@moon-x/core/sdk";
|
|
262
271
|
var getSolanaSDKMethods = (bridge, publishableKey, relyingPartyOrigin) => getHeadlessSolanaMethods({
|
|
263
272
|
transport: bridge,
|
|
264
273
|
passkey: createRNPasskey(),
|
|
@@ -267,6 +276,22 @@ var getSolanaSDKMethods = (bridge, publishableKey, relyingPartyOrigin) => getHea
|
|
|
267
276
|
});
|
|
268
277
|
|
|
269
278
|
// src/sdk/create-sdk-instance.ts
|
|
279
|
+
var makeRelyingPartyOriginResolver = (bridge, publishableKey, configuredOrigin) => {
|
|
280
|
+
let cached = configuredOrigin || null;
|
|
281
|
+
return async () => {
|
|
282
|
+
if (cached) return cached;
|
|
283
|
+
const dekInfo = await bridge.send(
|
|
284
|
+
PostMessageType2.AUTH,
|
|
285
|
+
PostMessageMethod2.GET_DEK_INFO,
|
|
286
|
+
{ publishableKey }
|
|
287
|
+
);
|
|
288
|
+
if (!dekInfo.rp_id) {
|
|
289
|
+
throw new Error("webauthn_rp_id_not_configured");
|
|
290
|
+
}
|
|
291
|
+
cached = `https://${dekInfo.rp_id}`;
|
|
292
|
+
return cached;
|
|
293
|
+
};
|
|
294
|
+
};
|
|
270
295
|
var createSdkInstance = ({
|
|
271
296
|
bridge,
|
|
272
297
|
publishableKey,
|
|
@@ -302,7 +327,7 @@ var createSdkInstance = ({
|
|
|
302
327
|
});
|
|
303
328
|
|
|
304
329
|
// src/provider.tsx
|
|
305
|
-
import { PostMessageMethod as
|
|
330
|
+
import { PostMessageMethod as PostMessageMethod3, PostMessageType as PostMessageType3 } from "@moon-x/core/utils";
|
|
306
331
|
|
|
307
332
|
// src/transport/webview-bridge.ts
|
|
308
333
|
import {
|
|
@@ -482,11 +507,6 @@ var MoonKeyProvider = ({
|
|
|
482
507
|
}) => {
|
|
483
508
|
const iframeUrl = config?.iframeUrl ?? DEFAULT_IFRAME_URL;
|
|
484
509
|
const relyingPartyOrigin = config?.relyingPartyOrigin ?? "";
|
|
485
|
-
if (!relyingPartyOrigin && typeof console !== "undefined") {
|
|
486
|
-
console.warn(
|
|
487
|
-
"[MoonKey] config.relyingPartyOrigin is empty \u2014 every sensitive op (sign / send / createWallet / importKey / exportKey / addPasskey / removePasskey) will fail until this is set to your host app's WebAuthn relying-party origin (e.g. https://wallet.acme.com)."
|
|
488
|
-
);
|
|
489
|
-
}
|
|
490
510
|
const webViewRef = useRef(null);
|
|
491
511
|
const bridge = useMemo(
|
|
492
512
|
() => new WebViewBridge(
|
|
@@ -494,6 +514,10 @@ var MoonKeyProvider = ({
|
|
|
494
514
|
),
|
|
495
515
|
[]
|
|
496
516
|
);
|
|
517
|
+
const relyingPartyOriginResolver = useMemo(
|
|
518
|
+
() => makeRelyingPartyOriginResolver(bridge, publishableKey, relyingPartyOrigin),
|
|
519
|
+
[bridge, publishableKey, relyingPartyOrigin]
|
|
520
|
+
);
|
|
497
521
|
const [sensitiveVisible, setSensitiveVisible] = useState(false);
|
|
498
522
|
const cancelRef = useRef(null);
|
|
499
523
|
const [ready, setReady] = useState(false);
|
|
@@ -579,13 +603,12 @@ var MoonKeyProvider = ({
|
|
|
579
603
|
() => createSdkInstance({
|
|
580
604
|
bridge,
|
|
581
605
|
publishableKey,
|
|
582
|
-
//
|
|
583
|
-
//
|
|
584
|
-
//
|
|
585
|
-
//
|
|
586
|
-
//
|
|
587
|
-
|
|
588
|
-
relyingPartyOrigin,
|
|
606
|
+
// Shared resolver — empty in the common case, then derives
|
|
607
|
+
// `https://<rp_id>` from the iframe at the first sensitive op and
|
|
608
|
+
// threads it into getInternalPresenceTokens, which forwards it on
|
|
609
|
+
// /presence/begin so the server can rebuild the per-app WebAuthn
|
|
610
|
+
// RP config.
|
|
611
|
+
relyingPartyOrigin: relyingPartyOriginResolver,
|
|
589
612
|
isAuthenticated,
|
|
590
613
|
user,
|
|
591
614
|
ready,
|
|
@@ -596,7 +619,7 @@ var MoonKeyProvider = ({
|
|
|
596
619
|
[
|
|
597
620
|
bridge,
|
|
598
621
|
publishableKey,
|
|
599
|
-
|
|
622
|
+
relyingPartyOriginResolver,
|
|
600
623
|
isAuthenticated,
|
|
601
624
|
user,
|
|
602
625
|
ready,
|
|
@@ -615,8 +638,8 @@ var MoonKeyProvider = ({
|
|
|
615
638
|
useEffect(() => {
|
|
616
639
|
let cancelled = false;
|
|
617
640
|
const unregister = bridge.register(
|
|
618
|
-
|
|
619
|
-
|
|
641
|
+
PostMessageType3.INIT,
|
|
642
|
+
PostMessageMethod3.READY,
|
|
620
643
|
() => {
|
|
621
644
|
if (!cancelled) setReady(true);
|
|
622
645
|
}
|
|
@@ -670,14 +693,14 @@ var MoonKeyProvider = ({
|
|
|
670
693
|
() => ({
|
|
671
694
|
sdk,
|
|
672
695
|
_bridge: bridge,
|
|
673
|
-
_relyingPartyOrigin:
|
|
696
|
+
_relyingPartyOrigin: relyingPartyOriginResolver,
|
|
674
697
|
_runSensitiveFlow: runSensitiveFlow,
|
|
675
698
|
_oauthRedirectUri: config?.oauthRedirectUri
|
|
676
699
|
}),
|
|
677
700
|
[
|
|
678
701
|
sdk,
|
|
679
702
|
bridge,
|
|
680
|
-
|
|
703
|
+
relyingPartyOriginResolver,
|
|
681
704
|
runSensitiveFlow,
|
|
682
705
|
config?.oauthRedirectUri
|
|
683
706
|
]
|
|
@@ -827,6 +850,7 @@ var styles = StyleSheet.create({
|
|
|
827
850
|
import {
|
|
828
851
|
useAddPasskey,
|
|
829
852
|
useCreateWallet,
|
|
853
|
+
useEphemeralSigner,
|
|
830
854
|
useImportKey,
|
|
831
855
|
useLoginWithEmail,
|
|
832
856
|
useLogout,
|
|
@@ -838,7 +862,7 @@ import {
|
|
|
838
862
|
} from "@moon-x/core/react";
|
|
839
863
|
|
|
840
864
|
// src/hooks/use-attach-oauth.ts
|
|
841
|
-
import { PostMessageMethod as
|
|
865
|
+
import { PostMessageMethod as PostMessageMethod4, PostMessageType as PostMessageType4 } from "@moon-x/core/utils";
|
|
842
866
|
import { useState as useState2 } from "react";
|
|
843
867
|
|
|
844
868
|
// src/lib/oauth-deep-link.ts
|
|
@@ -889,8 +913,8 @@ var useAttachOAuth = (params) => {
|
|
|
889
913
|
const redirectUri = params?.redirectUri || _oauthRedirectUri;
|
|
890
914
|
if (!redirectUri) throw new Error("oauth_redirect_uri_missing");
|
|
891
915
|
const startResult = await _bridge.send(
|
|
892
|
-
|
|
893
|
-
|
|
916
|
+
PostMessageType4.AUTH,
|
|
917
|
+
PostMessageMethod4.START_OAUTH,
|
|
894
918
|
{
|
|
895
919
|
publishableKey: sdk.publishableKey,
|
|
896
920
|
provider,
|
|
@@ -910,8 +934,8 @@ var useAttachOAuth = (params) => {
|
|
|
910
934
|
if (parsed.error) throw new Error(parsed.error);
|
|
911
935
|
setState({ status: "verifying" });
|
|
912
936
|
await _bridge.send(
|
|
913
|
-
|
|
914
|
-
|
|
937
|
+
PostMessageType4.AUTH,
|
|
938
|
+
PostMessageMethod4.ATTACH_OAUTH,
|
|
915
939
|
{
|
|
916
940
|
publishableKey: sdk.publishableKey,
|
|
917
941
|
provider,
|
|
@@ -932,14 +956,14 @@ var useAttachOAuth = (params) => {
|
|
|
932
956
|
};
|
|
933
957
|
|
|
934
958
|
// src/hooks/use-detach-oauth.ts
|
|
935
|
-
import { PostMessageMethod as
|
|
959
|
+
import { PostMessageMethod as PostMessageMethod5, PostMessageType as PostMessageType5 } from "@moon-x/core/utils";
|
|
936
960
|
var useDetachOAuth = () => {
|
|
937
961
|
const { sdk, _bridge } = useMoonKeyContext();
|
|
938
962
|
return {
|
|
939
963
|
detachOAuth: async (idpUserId) => {
|
|
940
964
|
await _bridge.send(
|
|
941
|
-
|
|
942
|
-
|
|
965
|
+
PostMessageType5.AUTH,
|
|
966
|
+
PostMessageMethod5.DETACH_OAUTH,
|
|
943
967
|
{ publishableKey: sdk.publishableKey, idpUserId }
|
|
944
968
|
);
|
|
945
969
|
}
|
|
@@ -983,7 +1007,7 @@ var useExportKey = () => {
|
|
|
983
1007
|
};
|
|
984
1008
|
|
|
985
1009
|
// src/hooks/use-login-with-oauth.ts
|
|
986
|
-
import { PostMessageMethod as
|
|
1010
|
+
import { PostMessageMethod as PostMessageMethod6, PostMessageType as PostMessageType6 } from "@moon-x/core/utils";
|
|
987
1011
|
import { useState as useState3 } from "react";
|
|
988
1012
|
var useLoginWithOAuth = (params) => {
|
|
989
1013
|
const { sdk, _bridge, _oauthRedirectUri } = useMoonKeyContext();
|
|
@@ -998,8 +1022,8 @@ var useLoginWithOAuth = (params) => {
|
|
|
998
1022
|
throw new Error("oauth_redirect_uri_missing");
|
|
999
1023
|
}
|
|
1000
1024
|
const startResult = await _bridge.send(
|
|
1001
|
-
|
|
1002
|
-
|
|
1025
|
+
PostMessageType6.AUTH,
|
|
1026
|
+
PostMessageMethod6.START_OAUTH,
|
|
1003
1027
|
{
|
|
1004
1028
|
publishableKey: sdk.publishableKey,
|
|
1005
1029
|
provider,
|
|
@@ -1041,15 +1065,16 @@ var useLoginWithOAuth = (params) => {
|
|
|
1041
1065
|
var useMoonKey = () => useMoonKeyContext().sdk;
|
|
1042
1066
|
|
|
1043
1067
|
// src/index.ts
|
|
1044
|
-
import { PostMessageMethod as
|
|
1068
|
+
import { PostMessageMethod as PostMessageMethod7, PostMessageType as PostMessageType7 } from "@moon-x/core/utils";
|
|
1045
1069
|
export {
|
|
1046
1070
|
MoonKeyProvider,
|
|
1047
|
-
|
|
1048
|
-
|
|
1071
|
+
PostMessageMethod7 as PostMessageMethod,
|
|
1072
|
+
PostMessageType7 as PostMessageType,
|
|
1049
1073
|
useAddPasskey,
|
|
1050
1074
|
useAttachOAuth,
|
|
1051
1075
|
useCreateWallet,
|
|
1052
1076
|
useDetachOAuth,
|
|
1077
|
+
useEphemeralSigner,
|
|
1053
1078
|
useExportKey,
|
|
1054
1079
|
useImportKey,
|
|
1055
1080
|
useLoginWithEmail,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moon-x/react-native-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.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.6.0"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
55
|
"@expo/config-plugins": ">=10.0.0",
|