@moon-x/react-native-sdk 0.3.0 → 0.5.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 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;
@@ -61,8 +62,14 @@ interface RNAuthSDK {
61
62
  * over JWKS to gate high-risk routes. Must be invoked synchronously
62
63
  * from a press handler — WebAuthn requires transient activation.
63
64
  * Throws if the user has no enrolled passkey or cancels the prompt.
65
+ *
66
+ * Pass `expiresInSecs` to request a custom token lifetime. Omitted
67
+ * uses the server default (5 min); the server caps it at 1 h and
68
+ * rejects larger values.
64
69
  */
65
- getPresenceToken: () => Promise<{
70
+ getPresenceToken: (options?: {
71
+ expiresInSecs?: number;
72
+ }) => Promise<{
66
73
  presenceToken: string;
67
74
  expiresAt: number;
68
75
  }>;
@@ -102,6 +109,7 @@ interface RNAuthSDK {
102
109
  displayName?: string;
103
110
  }) => Promise<{
104
111
  credential_id: string;
112
+ passkey_registered: true;
105
113
  }>;
106
114
  signEthereumMessageHeadless: (params: EthereumSignMessageParams) => Promise<EthereumSignMessageResult>;
107
115
  signEthereumTransactionHeadless: (params: EthereumSignTransactionParams) => Promise<EthereumSignTransactionResult>;
@@ -130,18 +138,17 @@ interface MoonKeyConfig {
130
138
  */
131
139
  oauthRedirectUri?: string;
132
140
  /**
133
- * **Required** for sensitive operations. The host app's effective
134
- * WebAuthn relying-party origin (e.g. `"https://wallet.acme.com"`
135
- * for an associated-domain config). The SDK threads this into the
136
- * internal presence-token orchestrator at `/auth/passkey/presence/begin`
137
- * so the backend can rebuild the per-app WebAuthn RP config that the
138
- * native authenticator will assert against.
141
+ * **Optional override** for the host app's WebAuthn relying-party
142
+ * origin (e.g. `"https://wallet.acme.com"`). The SDK threads this into
143
+ * the internal presence-token orchestrator at
144
+ * `/auth/passkey/presence/begin` so the backend can rebuild the
145
+ * per-app WebAuthn RP config the native authenticator asserts against.
139
146
  *
140
- * Without it, the orchestrator submits an empty origin to the
141
- * server, which rejects with `invalid_relying_party_origin` — i.e.
142
- * sensitive operations (sign / send / create / import / export /
143
- * addPasskey / removePasskey) will fail. The MoonKeyProvider will
144
- * log a warning at mount time if this is omitted.
147
+ * Leave it unset in the common case: the SDK derives the origin
148
+ * automatically from the app's server-configured `rp_id` (fetched via
149
+ * the iframe) as `https://<rp_id>`, matching what the native passkey
150
+ * ceremony uses. Set this only if your app needs an origin that
151
+ * differs from the configured `rp_id`.
145
152
  */
146
153
  relyingPartyOrigin?: string;
147
154
  /**
@@ -196,7 +203,7 @@ interface SensitiveFlowMountApi {
196
203
  interface MoonKeyContextValue {
197
204
  sdk: RNAuthSDK;
198
205
  _bridge: WebViewBridge;
199
- _relyingPartyOrigin: string;
206
+ _relyingPartyOrigin: RelyingPartyOriginInput;
200
207
  _runSensitiveFlow: (options: SensitiveFlowOptions) => Promise<void>;
201
208
  _oauthRedirectUri?: string;
202
209
  }
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;
@@ -61,8 +62,14 @@ interface RNAuthSDK {
61
62
  * over JWKS to gate high-risk routes. Must be invoked synchronously
62
63
  * from a press handler — WebAuthn requires transient activation.
63
64
  * Throws if the user has no enrolled passkey or cancels the prompt.
65
+ *
66
+ * Pass `expiresInSecs` to request a custom token lifetime. Omitted
67
+ * uses the server default (5 min); the server caps it at 1 h and
68
+ * rejects larger values.
64
69
  */
65
- getPresenceToken: () => Promise<{
70
+ getPresenceToken: (options?: {
71
+ expiresInSecs?: number;
72
+ }) => Promise<{
66
73
  presenceToken: string;
67
74
  expiresAt: number;
68
75
  }>;
@@ -102,6 +109,7 @@ interface RNAuthSDK {
102
109
  displayName?: string;
103
110
  }) => Promise<{
104
111
  credential_id: string;
112
+ passkey_registered: true;
105
113
  }>;
106
114
  signEthereumMessageHeadless: (params: EthereumSignMessageParams) => Promise<EthereumSignMessageResult>;
107
115
  signEthereumTransactionHeadless: (params: EthereumSignTransactionParams) => Promise<EthereumSignTransactionResult>;
@@ -130,18 +138,17 @@ interface MoonKeyConfig {
130
138
  */
131
139
  oauthRedirectUri?: string;
132
140
  /**
133
- * **Required** for sensitive operations. The host app's effective
134
- * WebAuthn relying-party origin (e.g. `"https://wallet.acme.com"`
135
- * for an associated-domain config). The SDK threads this into the
136
- * internal presence-token orchestrator at `/auth/passkey/presence/begin`
137
- * so the backend can rebuild the per-app WebAuthn RP config that the
138
- * native authenticator will assert against.
141
+ * **Optional override** for the host app's WebAuthn relying-party
142
+ * origin (e.g. `"https://wallet.acme.com"`). The SDK threads this into
143
+ * the internal presence-token orchestrator at
144
+ * `/auth/passkey/presence/begin` so the backend can rebuild the
145
+ * per-app WebAuthn RP config the native authenticator asserts against.
139
146
  *
140
- * Without it, the orchestrator submits an empty origin to the
141
- * server, which rejects with `invalid_relying_party_origin` — i.e.
142
- * sensitive operations (sign / send / create / import / export /
143
- * addPasskey / removePasskey) will fail. The MoonKeyProvider will
144
- * log a warning at mount time if this is omitted.
147
+ * Leave it unset in the common case: the SDK derives the origin
148
+ * automatically from the app's server-configured `rp_id` (fetched via
149
+ * the iframe) as `https://<rp_id>`, matching what the native passkey
150
+ * ceremony uses. Set this only if your app needs an origin that
151
+ * differs from the configured `rp_id`.
145
152
  */
146
153
  relyingPartyOrigin?: string;
147
154
  /**
@@ -196,7 +203,7 @@ interface SensitiveFlowMountApi {
196
203
  interface MoonKeyContextValue {
197
204
  sdk: RNAuthSDK;
198
205
  _bridge: WebViewBridge;
199
- _relyingPartyOrigin: string;
206
+ _relyingPartyOrigin: RelyingPartyOriginInput;
200
207
  _runSensitiveFlow: (options: SensitiveFlowOptions) => Promise<void>;
201
208
  _oauthRedirectUri?: string;
202
209
  }
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: () => import_utils7.PostMessageMethod,
35
- PostMessageType: () => import_utils7.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)({
@@ -246,7 +250,7 @@ var getPasskeyMethods = (bridge, publishableKey) => ({
246
250
  }
247
251
  );
248
252
  }
249
- return { credential_id: credential.rawId };
253
+ return { credential_id: credential.rawId, passkey_registered: true };
250
254
  },
251
255
  // Parent-side passkey step-up. Mirrors the web SDK's
252
256
  // `sdk.getPresenceToken()` — orchestrator is platform-agnostic; only
@@ -261,7 +265,7 @@ var getPasskeyMethods = (bridge, publishableKey) => ({
261
265
  // app's configured rp_id (fetched via the iframe's GET_DEK_INFO) —
262
266
  // RN has no window.location.origin to use. Same pattern as
263
267
  // sdk-passkey-methods.ts::registerPasskey.
264
- getPresenceToken: async () => {
268
+ getPresenceToken: async (options) => {
265
269
  const dekInfo = await bridge.send(
266
270
  import_utils.PostMessageType.AUTH,
267
271
  import_utils.PostMessageMethod.GET_DEK_INFO,
@@ -274,7 +278,8 @@ var getPasskeyMethods = (bridge, publishableKey) => ({
274
278
  transport: bridge,
275
279
  passkey: createRNPasskey(),
276
280
  publishableKey,
277
- relyingPartyOrigin: `https://${dekInfo.rp_id}`
281
+ relyingPartyOrigin: `https://${dekInfo.rp_id}`,
282
+ expiresInSecs: options?.expiresInSecs
278
283
  });
279
284
  }
280
285
  });
@@ -301,6 +306,22 @@ var getSolanaSDKMethods = (bridge, publishableKey, relyingPartyOrigin) => (0, im
301
306
  });
302
307
 
303
308
  // src/sdk/create-sdk-instance.ts
309
+ var makeRelyingPartyOriginResolver = (bridge, publishableKey, configuredOrigin) => {
310
+ let cached = configuredOrigin || null;
311
+ return async () => {
312
+ if (cached) return cached;
313
+ const dekInfo = await bridge.send(
314
+ import_utils2.PostMessageType.AUTH,
315
+ import_utils2.PostMessageMethod.GET_DEK_INFO,
316
+ { publishableKey }
317
+ );
318
+ if (!dekInfo.rp_id) {
319
+ throw new Error("webauthn_rp_id_not_configured");
320
+ }
321
+ cached = `https://${dekInfo.rp_id}`;
322
+ return cached;
323
+ };
324
+ };
304
325
  var createSdkInstance = ({
305
326
  bridge,
306
327
  publishableKey,
@@ -336,10 +357,10 @@ var createSdkInstance = ({
336
357
  });
337
358
 
338
359
  // src/provider.tsx
339
- var import_utils3 = require("@moon-x/core/utils");
360
+ var import_utils4 = require("@moon-x/core/utils");
340
361
 
341
362
  // src/transport/webview-bridge.ts
342
- var import_utils2 = require("@moon-x/core/utils");
363
+ var import_utils3 = require("@moon-x/core/utils");
343
364
  var REQUEST_TIMEOUT_MS = 3e4;
344
365
  var generateUUID = () => {
345
366
  if (typeof crypto !== "undefined" && crypto.randomUUID) {
@@ -415,7 +436,7 @@ var WebViewBridge = class {
415
436
  resolver.resolve(message.data);
416
437
  } else {
417
438
  const err = new Error(message.error || "WebView bridge error");
418
- for (const key of import_utils2.FORWARDED_ERROR_FIELDS) {
439
+ for (const key of import_utils3.FORWARDED_ERROR_FIELDS) {
419
440
  const value = message[key];
420
441
  if (value !== void 0) {
421
442
  err[key] = value;
@@ -514,11 +535,6 @@ var MoonKeyProvider = ({
514
535
  }) => {
515
536
  const iframeUrl = config?.iframeUrl ?? DEFAULT_IFRAME_URL;
516
537
  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
538
  const webViewRef = (0, import_react.useRef)(null);
523
539
  const bridge = (0, import_react.useMemo)(
524
540
  () => new WebViewBridge(
@@ -526,6 +542,10 @@ var MoonKeyProvider = ({
526
542
  ),
527
543
  []
528
544
  );
545
+ const relyingPartyOriginResolver = (0, import_react.useMemo)(
546
+ () => makeRelyingPartyOriginResolver(bridge, publishableKey, relyingPartyOrigin),
547
+ [bridge, publishableKey, relyingPartyOrigin]
548
+ );
529
549
  const [sensitiveVisible, setSensitiveVisible] = (0, import_react.useState)(false);
530
550
  const cancelRef = (0, import_react.useRef)(null);
531
551
  const [ready, setReady] = (0, import_react.useState)(false);
@@ -611,13 +631,12 @@ var MoonKeyProvider = ({
611
631
  () => createSdkInstance({
612
632
  bridge,
613
633
  publishableKey,
614
- // Host-app WebAuthn relying-party origin. Supplied via
615
- // MoonKeyProviderProps.config.relyingPartyOrigin; the mount-time
616
- // warning above flags the empty case. Threaded into every
617
- // sensitive op's call to getInternalPresenceTokens, which
618
- // forwards it on /presence/begin so the server can rebuild the
619
- // per-app WebAuthn RP config.
620
- relyingPartyOrigin,
634
+ // Shared resolver — empty in the common case, then derives
635
+ // `https://<rp_id>` from the iframe at the first sensitive op and
636
+ // threads it into getInternalPresenceTokens, which forwards it on
637
+ // /presence/begin so the server can rebuild the per-app WebAuthn
638
+ // RP config.
639
+ relyingPartyOrigin: relyingPartyOriginResolver,
621
640
  isAuthenticated,
622
641
  user,
623
642
  ready,
@@ -628,7 +647,7 @@ var MoonKeyProvider = ({
628
647
  [
629
648
  bridge,
630
649
  publishableKey,
631
- relyingPartyOrigin,
650
+ relyingPartyOriginResolver,
632
651
  isAuthenticated,
633
652
  user,
634
653
  ready,
@@ -647,8 +666,8 @@ var MoonKeyProvider = ({
647
666
  (0, import_react.useEffect)(() => {
648
667
  let cancelled = false;
649
668
  const unregister = bridge.register(
650
- import_utils3.PostMessageType.INIT,
651
- import_utils3.PostMessageMethod.READY,
669
+ import_utils4.PostMessageType.INIT,
670
+ import_utils4.PostMessageMethod.READY,
652
671
  () => {
653
672
  if (!cancelled) setReady(true);
654
673
  }
@@ -702,14 +721,14 @@ var MoonKeyProvider = ({
702
721
  () => ({
703
722
  sdk,
704
723
  _bridge: bridge,
705
- _relyingPartyOrigin: relyingPartyOrigin,
724
+ _relyingPartyOrigin: relyingPartyOriginResolver,
706
725
  _runSensitiveFlow: runSensitiveFlow,
707
726
  _oauthRedirectUri: config?.oauthRedirectUri
708
727
  }),
709
728
  [
710
729
  sdk,
711
730
  bridge,
712
- relyingPartyOrigin,
731
+ relyingPartyOriginResolver,
713
732
  runSensitiveFlow,
714
733
  config?.oauthRedirectUri
715
734
  ]
@@ -859,7 +878,7 @@ var styles = import_react_native.StyleSheet.create({
859
878
  var import_react5 = require("@moon-x/core/react");
860
879
 
861
880
  // src/hooks/use-attach-oauth.ts
862
- var import_utils4 = require("@moon-x/core/utils");
881
+ var import_utils5 = require("@moon-x/core/utils");
863
882
  var import_react3 = require("react");
864
883
 
865
884
  // src/lib/oauth-deep-link.ts
@@ -910,8 +929,8 @@ var useAttachOAuth = (params) => {
910
929
  const redirectUri = params?.redirectUri || _oauthRedirectUri;
911
930
  if (!redirectUri) throw new Error("oauth_redirect_uri_missing");
912
931
  const startResult = await _bridge.send(
913
- import_utils4.PostMessageType.AUTH,
914
- import_utils4.PostMessageMethod.START_OAUTH,
932
+ import_utils5.PostMessageType.AUTH,
933
+ import_utils5.PostMessageMethod.START_OAUTH,
915
934
  {
916
935
  publishableKey: sdk.publishableKey,
917
936
  provider,
@@ -931,8 +950,8 @@ var useAttachOAuth = (params) => {
931
950
  if (parsed.error) throw new Error(parsed.error);
932
951
  setState({ status: "verifying" });
933
952
  await _bridge.send(
934
- import_utils4.PostMessageType.AUTH,
935
- import_utils4.PostMessageMethod.ATTACH_OAUTH,
953
+ import_utils5.PostMessageType.AUTH,
954
+ import_utils5.PostMessageMethod.ATTACH_OAUTH,
936
955
  {
937
956
  publishableKey: sdk.publishableKey,
938
957
  provider,
@@ -953,14 +972,14 @@ var useAttachOAuth = (params) => {
953
972
  };
954
973
 
955
974
  // src/hooks/use-detach-oauth.ts
956
- var import_utils5 = require("@moon-x/core/utils");
975
+ var import_utils6 = require("@moon-x/core/utils");
957
976
  var useDetachOAuth = () => {
958
977
  const { sdk, _bridge } = useMoonKeyContext();
959
978
  return {
960
979
  detachOAuth: async (idpUserId) => {
961
980
  await _bridge.send(
962
- import_utils5.PostMessageType.AUTH,
963
- import_utils5.PostMessageMethod.DETACH_OAUTH,
981
+ import_utils6.PostMessageType.AUTH,
982
+ import_utils6.PostMessageMethod.DETACH_OAUTH,
964
983
  { publishableKey: sdk.publishableKey, idpUserId }
965
984
  );
966
985
  }
@@ -1004,7 +1023,7 @@ var useExportKey = () => {
1004
1023
  };
1005
1024
 
1006
1025
  // src/hooks/use-login-with-oauth.ts
1007
- var import_utils6 = require("@moon-x/core/utils");
1026
+ var import_utils7 = require("@moon-x/core/utils");
1008
1027
  var import_react4 = require("react");
1009
1028
  var useLoginWithOAuth = (params) => {
1010
1029
  const { sdk, _bridge, _oauthRedirectUri } = useMoonKeyContext();
@@ -1019,8 +1038,8 @@ var useLoginWithOAuth = (params) => {
1019
1038
  throw new Error("oauth_redirect_uri_missing");
1020
1039
  }
1021
1040
  const startResult = await _bridge.send(
1022
- import_utils6.PostMessageType.AUTH,
1023
- import_utils6.PostMessageMethod.START_OAUTH,
1041
+ import_utils7.PostMessageType.AUTH,
1042
+ import_utils7.PostMessageMethod.START_OAUTH,
1024
1043
  {
1025
1044
  publishableKey: sdk.publishableKey,
1026
1045
  provider,
@@ -1062,7 +1081,7 @@ var useLoginWithOAuth = (params) => {
1062
1081
  var useMoonKey = () => useMoonKeyContext().sdk;
1063
1082
 
1064
1083
  // src/index.ts
1065
- var import_utils7 = require("@moon-x/core/utils");
1084
+ var import_utils8 = require("@moon-x/core/utils");
1066
1085
  // Annotate the CommonJS export names for ESM import in node:
1067
1086
  0 && (module.exports = {
1068
1087
  MoonKeyProvider,
@@ -1072,6 +1091,7 @@ var import_utils7 = require("@moon-x/core/utils");
1072
1091
  useAttachOAuth,
1073
1092
  useCreateWallet,
1074
1093
  useDetachOAuth,
1094
+ useEphemeralSigner,
1075
1095
  useExportKey,
1076
1096
  useImportKey,
1077
1097
  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 { getHeadlessEthereumMethods } from "@moon-x/core/sdk";
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";
@@ -212,7 +217,7 @@ var getPasskeyMethods = (bridge, publishableKey) => ({
212
217
  }
213
218
  );
214
219
  }
215
- return { credential_id: credential.rawId };
220
+ return { credential_id: credential.rawId, passkey_registered: true };
216
221
  },
217
222
  // Parent-side passkey step-up. Mirrors the web SDK's
218
223
  // `sdk.getPresenceToken()` — orchestrator is platform-agnostic; only
@@ -227,7 +232,7 @@ var getPasskeyMethods = (bridge, publishableKey) => ({
227
232
  // app's configured rp_id (fetched via the iframe's GET_DEK_INFO) —
228
233
  // RN has no window.location.origin to use. Same pattern as
229
234
  // sdk-passkey-methods.ts::registerPasskey.
230
- getPresenceToken: async () => {
235
+ getPresenceToken: async (options) => {
231
236
  const dekInfo = await bridge.send(
232
237
  PostMessageType.AUTH,
233
238
  PostMessageMethod.GET_DEK_INFO,
@@ -240,13 +245,16 @@ var getPasskeyMethods = (bridge, publishableKey) => ({
240
245
  transport: bridge,
241
246
  passkey: createRNPasskey(),
242
247
  publishableKey,
243
- relyingPartyOrigin: `https://${dekInfo.rp_id}`
248
+ relyingPartyOrigin: `https://${dekInfo.rp_id}`,
249
+ expiresInSecs: options?.expiresInSecs
244
250
  });
245
251
  }
246
252
  });
247
253
 
248
254
  // src/sdk/sdk-methods.ts
249
- import { getHeadlessGeneralMethods } from "@moon-x/core/sdk";
255
+ import {
256
+ getHeadlessGeneralMethods
257
+ } from "@moon-x/core/sdk";
250
258
  var getSDKMethods = (bridge, publishableKey, relyingPartyOrigin, setIsAuthenticated, setUser) => getHeadlessGeneralMethods({
251
259
  transport: bridge,
252
260
  passkey: createRNPasskey(),
@@ -258,7 +266,9 @@ var getSDKMethods = (bridge, publishableKey, relyingPartyOrigin, setIsAuthentica
258
266
  });
259
267
 
260
268
  // src/sdk/sdk-solana-methods.ts
261
- import { getHeadlessSolanaMethods } from "@moon-x/core/sdk";
269
+ import {
270
+ getHeadlessSolanaMethods
271
+ } from "@moon-x/core/sdk";
262
272
  var getSolanaSDKMethods = (bridge, publishableKey, relyingPartyOrigin) => getHeadlessSolanaMethods({
263
273
  transport: bridge,
264
274
  passkey: createRNPasskey(),
@@ -267,6 +277,22 @@ var getSolanaSDKMethods = (bridge, publishableKey, relyingPartyOrigin) => getHea
267
277
  });
268
278
 
269
279
  // src/sdk/create-sdk-instance.ts
280
+ var makeRelyingPartyOriginResolver = (bridge, publishableKey, configuredOrigin) => {
281
+ let cached = configuredOrigin || null;
282
+ return async () => {
283
+ if (cached) return cached;
284
+ const dekInfo = await bridge.send(
285
+ PostMessageType2.AUTH,
286
+ PostMessageMethod2.GET_DEK_INFO,
287
+ { publishableKey }
288
+ );
289
+ if (!dekInfo.rp_id) {
290
+ throw new Error("webauthn_rp_id_not_configured");
291
+ }
292
+ cached = `https://${dekInfo.rp_id}`;
293
+ return cached;
294
+ };
295
+ };
270
296
  var createSdkInstance = ({
271
297
  bridge,
272
298
  publishableKey,
@@ -302,7 +328,7 @@ var createSdkInstance = ({
302
328
  });
303
329
 
304
330
  // src/provider.tsx
305
- import { PostMessageMethod as PostMessageMethod2, PostMessageType as PostMessageType2 } from "@moon-x/core/utils";
331
+ import { PostMessageMethod as PostMessageMethod3, PostMessageType as PostMessageType3 } from "@moon-x/core/utils";
306
332
 
307
333
  // src/transport/webview-bridge.ts
308
334
  import {
@@ -482,11 +508,6 @@ var MoonKeyProvider = ({
482
508
  }) => {
483
509
  const iframeUrl = config?.iframeUrl ?? DEFAULT_IFRAME_URL;
484
510
  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
511
  const webViewRef = useRef(null);
491
512
  const bridge = useMemo(
492
513
  () => new WebViewBridge(
@@ -494,6 +515,10 @@ var MoonKeyProvider = ({
494
515
  ),
495
516
  []
496
517
  );
518
+ const relyingPartyOriginResolver = useMemo(
519
+ () => makeRelyingPartyOriginResolver(bridge, publishableKey, relyingPartyOrigin),
520
+ [bridge, publishableKey, relyingPartyOrigin]
521
+ );
497
522
  const [sensitiveVisible, setSensitiveVisible] = useState(false);
498
523
  const cancelRef = useRef(null);
499
524
  const [ready, setReady] = useState(false);
@@ -579,13 +604,12 @@ var MoonKeyProvider = ({
579
604
  () => createSdkInstance({
580
605
  bridge,
581
606
  publishableKey,
582
- // Host-app WebAuthn relying-party origin. Supplied via
583
- // MoonKeyProviderProps.config.relyingPartyOrigin; the mount-time
584
- // warning above flags the empty case. Threaded into every
585
- // sensitive op's call to getInternalPresenceTokens, which
586
- // forwards it on /presence/begin so the server can rebuild the
587
- // per-app WebAuthn RP config.
588
- relyingPartyOrigin,
607
+ // Shared resolver — empty in the common case, then derives
608
+ // `https://<rp_id>` from the iframe at the first sensitive op and
609
+ // threads it into getInternalPresenceTokens, which forwards it on
610
+ // /presence/begin so the server can rebuild the per-app WebAuthn
611
+ // RP config.
612
+ relyingPartyOrigin: relyingPartyOriginResolver,
589
613
  isAuthenticated,
590
614
  user,
591
615
  ready,
@@ -596,7 +620,7 @@ var MoonKeyProvider = ({
596
620
  [
597
621
  bridge,
598
622
  publishableKey,
599
- relyingPartyOrigin,
623
+ relyingPartyOriginResolver,
600
624
  isAuthenticated,
601
625
  user,
602
626
  ready,
@@ -615,8 +639,8 @@ var MoonKeyProvider = ({
615
639
  useEffect(() => {
616
640
  let cancelled = false;
617
641
  const unregister = bridge.register(
618
- PostMessageType2.INIT,
619
- PostMessageMethod2.READY,
642
+ PostMessageType3.INIT,
643
+ PostMessageMethod3.READY,
620
644
  () => {
621
645
  if (!cancelled) setReady(true);
622
646
  }
@@ -670,14 +694,14 @@ var MoonKeyProvider = ({
670
694
  () => ({
671
695
  sdk,
672
696
  _bridge: bridge,
673
- _relyingPartyOrigin: relyingPartyOrigin,
697
+ _relyingPartyOrigin: relyingPartyOriginResolver,
674
698
  _runSensitiveFlow: runSensitiveFlow,
675
699
  _oauthRedirectUri: config?.oauthRedirectUri
676
700
  }),
677
701
  [
678
702
  sdk,
679
703
  bridge,
680
- relyingPartyOrigin,
704
+ relyingPartyOriginResolver,
681
705
  runSensitiveFlow,
682
706
  config?.oauthRedirectUri
683
707
  ]
@@ -827,6 +851,7 @@ var styles = StyleSheet.create({
827
851
  import {
828
852
  useAddPasskey,
829
853
  useCreateWallet,
854
+ useEphemeralSigner,
830
855
  useImportKey,
831
856
  useLoginWithEmail,
832
857
  useLogout,
@@ -838,7 +863,7 @@ import {
838
863
  } from "@moon-x/core/react";
839
864
 
840
865
  // src/hooks/use-attach-oauth.ts
841
- import { PostMessageMethod as PostMessageMethod3, PostMessageType as PostMessageType3 } from "@moon-x/core/utils";
866
+ import { PostMessageMethod as PostMessageMethod4, PostMessageType as PostMessageType4 } from "@moon-x/core/utils";
842
867
  import { useState as useState2 } from "react";
843
868
 
844
869
  // src/lib/oauth-deep-link.ts
@@ -889,8 +914,8 @@ var useAttachOAuth = (params) => {
889
914
  const redirectUri = params?.redirectUri || _oauthRedirectUri;
890
915
  if (!redirectUri) throw new Error("oauth_redirect_uri_missing");
891
916
  const startResult = await _bridge.send(
892
- PostMessageType3.AUTH,
893
- PostMessageMethod3.START_OAUTH,
917
+ PostMessageType4.AUTH,
918
+ PostMessageMethod4.START_OAUTH,
894
919
  {
895
920
  publishableKey: sdk.publishableKey,
896
921
  provider,
@@ -910,8 +935,8 @@ var useAttachOAuth = (params) => {
910
935
  if (parsed.error) throw new Error(parsed.error);
911
936
  setState({ status: "verifying" });
912
937
  await _bridge.send(
913
- PostMessageType3.AUTH,
914
- PostMessageMethod3.ATTACH_OAUTH,
938
+ PostMessageType4.AUTH,
939
+ PostMessageMethod4.ATTACH_OAUTH,
915
940
  {
916
941
  publishableKey: sdk.publishableKey,
917
942
  provider,
@@ -932,14 +957,14 @@ var useAttachOAuth = (params) => {
932
957
  };
933
958
 
934
959
  // src/hooks/use-detach-oauth.ts
935
- import { PostMessageMethod as PostMessageMethod4, PostMessageType as PostMessageType4 } from "@moon-x/core/utils";
960
+ import { PostMessageMethod as PostMessageMethod5, PostMessageType as PostMessageType5 } from "@moon-x/core/utils";
936
961
  var useDetachOAuth = () => {
937
962
  const { sdk, _bridge } = useMoonKeyContext();
938
963
  return {
939
964
  detachOAuth: async (idpUserId) => {
940
965
  await _bridge.send(
941
- PostMessageType4.AUTH,
942
- PostMessageMethod4.DETACH_OAUTH,
966
+ PostMessageType5.AUTH,
967
+ PostMessageMethod5.DETACH_OAUTH,
943
968
  { publishableKey: sdk.publishableKey, idpUserId }
944
969
  );
945
970
  }
@@ -983,7 +1008,7 @@ var useExportKey = () => {
983
1008
  };
984
1009
 
985
1010
  // src/hooks/use-login-with-oauth.ts
986
- import { PostMessageMethod as PostMessageMethod5, PostMessageType as PostMessageType5 } from "@moon-x/core/utils";
1011
+ import { PostMessageMethod as PostMessageMethod6, PostMessageType as PostMessageType6 } from "@moon-x/core/utils";
987
1012
  import { useState as useState3 } from "react";
988
1013
  var useLoginWithOAuth = (params) => {
989
1014
  const { sdk, _bridge, _oauthRedirectUri } = useMoonKeyContext();
@@ -998,8 +1023,8 @@ var useLoginWithOAuth = (params) => {
998
1023
  throw new Error("oauth_redirect_uri_missing");
999
1024
  }
1000
1025
  const startResult = await _bridge.send(
1001
- PostMessageType5.AUTH,
1002
- PostMessageMethod5.START_OAUTH,
1026
+ PostMessageType6.AUTH,
1027
+ PostMessageMethod6.START_OAUTH,
1003
1028
  {
1004
1029
  publishableKey: sdk.publishableKey,
1005
1030
  provider,
@@ -1041,15 +1066,16 @@ var useLoginWithOAuth = (params) => {
1041
1066
  var useMoonKey = () => useMoonKeyContext().sdk;
1042
1067
 
1043
1068
  // src/index.ts
1044
- import { PostMessageMethod as PostMessageMethod6, PostMessageType as PostMessageType6 } from "@moon-x/core/utils";
1069
+ import { PostMessageMethod as PostMessageMethod7, PostMessageType as PostMessageType7 } from "@moon-x/core/utils";
1045
1070
  export {
1046
1071
  MoonKeyProvider,
1047
- PostMessageMethod6 as PostMessageMethod,
1048
- PostMessageType6 as PostMessageType,
1072
+ PostMessageMethod7 as PostMessageMethod,
1073
+ PostMessageType7 as PostMessageType,
1049
1074
  useAddPasskey,
1050
1075
  useAttachOAuth,
1051
1076
  useCreateWallet,
1052
1077
  useDetachOAuth,
1078
+ useEphemeralSigner,
1053
1079
  useExportKey,
1054
1080
  useImportKey,
1055
1081
  useLoginWithEmail,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moon-x/react-native-sdk",
3
- "version": "0.3.0",
3
+ "version": "0.5.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.4.0"
52
+ "@moon-x/core": "0.7.0"
53
53
  },
54
54
  "peerDependencies": {
55
55
  "@expo/config-plugins": ">=10.0.0",