@moon-x/react-sdk 0.1.0 → 0.2.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
@@ -238,4 +238,4 @@ For React Native apps, use [`@moon-x/react-native-sdk`](https://www.npmjs.com/pa
238
238
 
239
239
  ## License
240
240
 
241
- MIT.
241
+ UNLICENSED. All rights reserved.
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
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';
2
+ import { WalletListEntry, AuthAppearance, PrefillConfig, WalletChainType, MoonKeyThemeConfig, PasskeyEnrollConfig, SignMessageConfig, ExportKeyConfig, SignTransactionConfig, SendTransactionConfig, Chain, LogoutResponse, EmailOtpFlowState, SendEmailOtpResponse, Wallet } from '@moon-x/core/types';
3
3
  export { Chain, Factor, IdpProvider, Network, PublicEthereumWallet, PublicWallet, WalletConnectConfig, WalletListEntry } from '@moon-x/core/types';
4
4
  import React$1, { ReactNode } from 'react';
5
5
  export { e as ethereum } from './ethereum-DobH9IQl.mjs';
@@ -150,7 +150,6 @@ interface MoonKeyConfig {
150
150
  theme?: MoonKeyThemeConfig;
151
151
  emailConfig?: {
152
152
  skipVerifiedSuccess?: boolean;
153
- expiresIn?: number;
154
153
  verifiedDisplayTime?: number;
155
154
  verifyEmailTitle?: string;
156
155
  verifyEmailResendTitle?: string;
@@ -212,6 +211,29 @@ interface MoonKeyInstance {
212
211
  refreshToken: string;
213
212
  expiresAt: number;
214
213
  } | null>;
214
+ /**
215
+ * Run a passkey-asserted step-up ceremony and return a short-lived
216
+ * presence token. The token (JWT, `tt:"presence"`) is signed with
217
+ * the app's JWKS key and intended to be passed to your backend in a
218
+ * header (e.g. `X-MoonX-Presence`) on high-risk routes. Your backend
219
+ * verifies it via `@moon-x/node-sdk`'s
220
+ * `client.auth.verifyPresenceToken(token)`.
221
+ *
222
+ * Must be invoked synchronously from a click handler — WebAuthn
223
+ * requires transient activation. Throws if the user has no
224
+ * enrolled passkey or cancels the prompt.
225
+ *
226
+ * @example
227
+ * const { presenceToken } = await getPresenceToken();
228
+ * await fetch('/api/sensitive', {
229
+ * method: 'POST',
230
+ * headers: { 'X-MoonX-Presence': presenceToken },
231
+ * });
232
+ */
233
+ getPresenceToken: () => Promise<{
234
+ presenceToken: string;
235
+ expiresAt: number;
236
+ }>;
215
237
  /**
216
238
  * Start authentication flow (UI-based)
217
239
  * @param params - Optional configuration to override provider-level config
@@ -241,10 +263,15 @@ interface MoonKeyInstance {
241
263
  */
242
264
  setAppearance: (appearance: AuthAppearance) => void;
243
265
  publishableKey: string;
266
+ /**
267
+ * Send the OTP. Returns the platform response — including the
268
+ * authoritative `expires_at` (unix seconds) so headless consumers
269
+ * can render an accurate countdown without inventing their own TTL.
270
+ */
244
271
  sendCode: (params: {
245
272
  email: string;
246
273
  disableSignup?: boolean;
247
- }) => Promise<void>;
274
+ }) => Promise<SendEmailOtpResponse>;
248
275
  loginWithCode: (params: {
249
276
  code: string;
250
277
  }) => Promise<void>;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
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';
2
+ import { WalletListEntry, AuthAppearance, PrefillConfig, WalletChainType, MoonKeyThemeConfig, PasskeyEnrollConfig, SignMessageConfig, ExportKeyConfig, SignTransactionConfig, SendTransactionConfig, Chain, LogoutResponse, EmailOtpFlowState, SendEmailOtpResponse, Wallet } from '@moon-x/core/types';
3
3
  export { Chain, Factor, IdpProvider, Network, PublicEthereumWallet, PublicWallet, WalletConnectConfig, WalletListEntry } from '@moon-x/core/types';
4
4
  import React$1, { ReactNode } from 'react';
5
5
  export { e as ethereum } from './ethereum-BRGKpUFH.js';
@@ -150,7 +150,6 @@ interface MoonKeyConfig {
150
150
  theme?: MoonKeyThemeConfig;
151
151
  emailConfig?: {
152
152
  skipVerifiedSuccess?: boolean;
153
- expiresIn?: number;
154
153
  verifiedDisplayTime?: number;
155
154
  verifyEmailTitle?: string;
156
155
  verifyEmailResendTitle?: string;
@@ -212,6 +211,29 @@ interface MoonKeyInstance {
212
211
  refreshToken: string;
213
212
  expiresAt: number;
214
213
  } | null>;
214
+ /**
215
+ * Run a passkey-asserted step-up ceremony and return a short-lived
216
+ * presence token. The token (JWT, `tt:"presence"`) is signed with
217
+ * the app's JWKS key and intended to be passed to your backend in a
218
+ * header (e.g. `X-MoonX-Presence`) on high-risk routes. Your backend
219
+ * verifies it via `@moon-x/node-sdk`'s
220
+ * `client.auth.verifyPresenceToken(token)`.
221
+ *
222
+ * Must be invoked synchronously from a click handler — WebAuthn
223
+ * requires transient activation. Throws if the user has no
224
+ * enrolled passkey or cancels the prompt.
225
+ *
226
+ * @example
227
+ * const { presenceToken } = await getPresenceToken();
228
+ * await fetch('/api/sensitive', {
229
+ * method: 'POST',
230
+ * headers: { 'X-MoonX-Presence': presenceToken },
231
+ * });
232
+ */
233
+ getPresenceToken: () => Promise<{
234
+ presenceToken: string;
235
+ expiresAt: number;
236
+ }>;
215
237
  /**
216
238
  * Start authentication flow (UI-based)
217
239
  * @param params - Optional configuration to override provider-level config
@@ -241,10 +263,15 @@ interface MoonKeyInstance {
241
263
  */
242
264
  setAppearance: (appearance: AuthAppearance) => void;
243
265
  publishableKey: string;
266
+ /**
267
+ * Send the OTP. Returns the platform response — including the
268
+ * authoritative `expires_at` (unix seconds) so headless consumers
269
+ * can render an accurate countdown without inventing their own TTL.
270
+ */
244
271
  sendCode: (params: {
245
272
  email: string;
246
273
  disableSignup?: boolean;
247
- }) => Promise<void>;
274
+ }) => Promise<SendEmailOtpResponse>;
248
275
  loginWithCode: (params: {
249
276
  code: string;
250
277
  }) => Promise<void>;