@swype-org/react-sdk 0.1.83 → 0.1.85

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/dist/index.d.cts CHANGED
@@ -199,7 +199,7 @@ interface UserConfig {
199
199
  /** Theme mode */
200
200
  type ThemeMode = 'light' | 'dark';
201
201
  /** Steps in the payment flow */
202
- type PaymentStep = 'login' | 'otp-verify' | 'create-passkey' | 'wallet-picker' | 'open-wallet' | 'confirm-sign' | 'deposit' | 'low-balance' | 'processing' | 'select-source' | 'success';
202
+ type PaymentStep = 'login' | 'otp-verify' | 'create-passkey' | 'verify-passkey' | 'wallet-picker' | 'open-wallet' | 'confirm-sign' | 'deposit' | 'low-balance' | 'processing' | 'select-source' | 'success';
203
203
  /** User-selected advanced settings for chain/asset override */
204
204
  interface AdvancedSettings {
205
205
  /** Override asset (e.g. 'USDC', 'USDT'). Null = let backend decide. */
@@ -422,6 +422,10 @@ interface PasskeyPopupOptions {
422
422
  timeout?: number;
423
423
  /** Populated by `createPasskeyViaPopup`; not set by callers. */
424
424
  channelId?: string;
425
+ /** Privy JWT so the popup can register the passkey server-side. */
426
+ authToken?: string;
427
+ /** Core API base URL for server-side passkey registration. */
428
+ apiBaseUrl?: string;
425
429
  }
426
430
  /**
427
431
  * Opens a same-origin pop-up window on the Swype domain to perform
@@ -433,15 +437,46 @@ interface PasskeyPopupOptions {
433
437
  * Falls back to `window.postMessage` for browsers that preserve the
434
438
  * opener reference.
435
439
  *
440
+ * When both client-side channels are blocked (Safari ITP partitions
441
+ * BroadcastChannel by top-level origin), the popup registers the
442
+ * passkey directly with the backend. On popup close, this function
443
+ * checks the server for newly registered passkeys as a final fallback.
444
+ *
436
445
  * Must be called from a user-gesture handler (e.g. button click) to
437
446
  * avoid the browser's pop-up blocker.
447
+ *
448
+ * @param existingCredentialIds - Credential IDs known before the popup
449
+ * opens. Used to diff against server state when the popup closes
450
+ * without delivering a client-side result.
438
451
  */
439
- declare function createPasskeyViaPopup(options: PasskeyPopupOptions): Promise<{
452
+ declare function createPasskeyViaPopup(options: PasskeyPopupOptions, existingCredentialIds?: string[]): Promise<{
440
453
  credentialId: string;
441
454
  publicKey: string;
442
455
  }>;
456
+ interface PasskeyVerifyPopupOptions {
457
+ credentialIds: string[];
458
+ rpId: string;
459
+ /** Populated by `findDevicePasskeyViaPopup`; not set by callers. */
460
+ channelId?: string;
461
+ }
462
+ /**
463
+ * Opens a same-origin pop-up window on the Swype domain to check whether
464
+ * any of the given passkey credential IDs exist on this device.
465
+ *
466
+ * Used as a fallback when Safari blocks `navigator.credentials.get()`
467
+ * inside a cross-origin iframe. The popup runs on the Swype domain where
468
+ * the rpId matches, so WebAuthn works.
469
+ *
470
+ * Must be called from a user-gesture handler (e.g. button click) to
471
+ * avoid the browser's pop-up blocker.
472
+ *
473
+ * @returns The matching credential ID, or `null` if none matched or the
474
+ * popup was closed before completing.
475
+ */
476
+ declare function findDevicePasskeyViaPopup(options: PasskeyVerifyPopupOptions): Promise<string | null>;
443
477
 
444
478
  type AccessTokenGetter = () => Promise<string | null | undefined>;
479
+ declare function resolvePasskeyRpId(): string;
445
480
  /**
446
481
  * Creates a WebAuthn passkey credential.
447
482
  * Used for upfront passkey registration before the authorization flow.
@@ -464,10 +499,16 @@ declare function createPasskeyCredential(params: {
464
499
  * Builds the {@link PasskeyPopupOptions} for a user. Called by the UI
465
500
  * layer when it needs to open the passkey creation pop-up after
466
501
  * `createPasskeyCredential` throws {@link PasskeyIframeBlockedError}.
502
+ *
503
+ * @param params.authToken - Privy JWT so the popup can register the
504
+ * passkey server-side (Safari fallback when BroadcastChannel is blocked).
505
+ * @param params.apiBaseUrl - Core API base URL for server-side registration.
467
506
  */
468
507
  declare function buildPasskeyPopupOptions(params: {
469
508
  userId: string;
470
509
  displayName: string;
510
+ authToken?: string;
511
+ apiBaseUrl?: string;
471
512
  }): PasskeyPopupOptions;
472
513
  /**
473
514
  * @deprecated Use {@link findDevicePasskey} instead, which checks all
@@ -707,4 +748,4 @@ interface AdvancedSourceScreenProps {
707
748
  }
708
749
  declare function AdvancedSourceScreen({ choices, selectedChainName, selectedTokenSymbol, onSelectSource, onBack, }: AdvancedSourceScreenProps): react_jsx_runtime.JSX.Element;
709
750
 
710
- export { type Account, type ActionExecutionResult, type AdvancedSettings, AdvancedSourceScreen, type Amount, type AuthorizationAction, type AuthorizationSession, type AuthorizationSessionDetail, type Chain, CreatePasskeyScreen, type Destination, type ErrorResponse, IconCircle, InfoBanner, type ListResponse, type MerchantAuthorization, type MerchantPublicKey, OutlineButton, PasskeyIframeBlockedError, type PaymentStep, PoweredByFooter, PrimaryButton, type Provider, ScreenHeader, ScreenLayout, SelectSourceScreen, SettingsMenu, SetupScreen, type SourceOption, type SourceSelection, type SourceType, Spinner, type StepItem, StepList, SwypePayment, type SwypePaymentProps, SwypeProvider, type SwypeProviderProps, type ThemeMode, type ThemeTokens, type TokenBalance, type Transfer, type TransferDestination, type UserConfig, type Wallet, type WalletSource, type WalletToken, buildPasskeyPopupOptions, createPasskeyCredential, createPasskeyViaPopup, darkTheme, deviceHasPasskey, findDevicePasskey, getTheme, lightTheme, api as swypeApi, useAuthorizationExecutor, useSwypeConfig, useSwypeDepositAmount, useTransferPolling, useTransferSigning };
751
+ export { type Account, type ActionExecutionResult, type AdvancedSettings, AdvancedSourceScreen, type Amount, type AuthorizationAction, type AuthorizationSession, type AuthorizationSessionDetail, type Chain, CreatePasskeyScreen, type Destination, type ErrorResponse, IconCircle, InfoBanner, type ListResponse, type MerchantAuthorization, type MerchantPublicKey, OutlineButton, PasskeyIframeBlockedError, type PaymentStep, PoweredByFooter, PrimaryButton, type Provider, ScreenHeader, ScreenLayout, SelectSourceScreen, SettingsMenu, SetupScreen, type SourceOption, type SourceSelection, type SourceType, Spinner, type StepItem, StepList, SwypePayment, type SwypePaymentProps, SwypeProvider, type SwypeProviderProps, type ThemeMode, type ThemeTokens, type TokenBalance, type Transfer, type TransferDestination, type UserConfig, type Wallet, type WalletSource, type WalletToken, buildPasskeyPopupOptions, createPasskeyCredential, createPasskeyViaPopup, darkTheme, deviceHasPasskey, findDevicePasskey, findDevicePasskeyViaPopup, getTheme, lightTheme, resolvePasskeyRpId, api as swypeApi, useAuthorizationExecutor, useSwypeConfig, useSwypeDepositAmount, useTransferPolling, useTransferSigning };
package/dist/index.d.ts CHANGED
@@ -199,7 +199,7 @@ interface UserConfig {
199
199
  /** Theme mode */
200
200
  type ThemeMode = 'light' | 'dark';
201
201
  /** Steps in the payment flow */
202
- type PaymentStep = 'login' | 'otp-verify' | 'create-passkey' | 'wallet-picker' | 'open-wallet' | 'confirm-sign' | 'deposit' | 'low-balance' | 'processing' | 'select-source' | 'success';
202
+ type PaymentStep = 'login' | 'otp-verify' | 'create-passkey' | 'verify-passkey' | 'wallet-picker' | 'open-wallet' | 'confirm-sign' | 'deposit' | 'low-balance' | 'processing' | 'select-source' | 'success';
203
203
  /** User-selected advanced settings for chain/asset override */
204
204
  interface AdvancedSettings {
205
205
  /** Override asset (e.g. 'USDC', 'USDT'). Null = let backend decide. */
@@ -422,6 +422,10 @@ interface PasskeyPopupOptions {
422
422
  timeout?: number;
423
423
  /** Populated by `createPasskeyViaPopup`; not set by callers. */
424
424
  channelId?: string;
425
+ /** Privy JWT so the popup can register the passkey server-side. */
426
+ authToken?: string;
427
+ /** Core API base URL for server-side passkey registration. */
428
+ apiBaseUrl?: string;
425
429
  }
426
430
  /**
427
431
  * Opens a same-origin pop-up window on the Swype domain to perform
@@ -433,15 +437,46 @@ interface PasskeyPopupOptions {
433
437
  * Falls back to `window.postMessage` for browsers that preserve the
434
438
  * opener reference.
435
439
  *
440
+ * When both client-side channels are blocked (Safari ITP partitions
441
+ * BroadcastChannel by top-level origin), the popup registers the
442
+ * passkey directly with the backend. On popup close, this function
443
+ * checks the server for newly registered passkeys as a final fallback.
444
+ *
436
445
  * Must be called from a user-gesture handler (e.g. button click) to
437
446
  * avoid the browser's pop-up blocker.
447
+ *
448
+ * @param existingCredentialIds - Credential IDs known before the popup
449
+ * opens. Used to diff against server state when the popup closes
450
+ * without delivering a client-side result.
438
451
  */
439
- declare function createPasskeyViaPopup(options: PasskeyPopupOptions): Promise<{
452
+ declare function createPasskeyViaPopup(options: PasskeyPopupOptions, existingCredentialIds?: string[]): Promise<{
440
453
  credentialId: string;
441
454
  publicKey: string;
442
455
  }>;
456
+ interface PasskeyVerifyPopupOptions {
457
+ credentialIds: string[];
458
+ rpId: string;
459
+ /** Populated by `findDevicePasskeyViaPopup`; not set by callers. */
460
+ channelId?: string;
461
+ }
462
+ /**
463
+ * Opens a same-origin pop-up window on the Swype domain to check whether
464
+ * any of the given passkey credential IDs exist on this device.
465
+ *
466
+ * Used as a fallback when Safari blocks `navigator.credentials.get()`
467
+ * inside a cross-origin iframe. The popup runs on the Swype domain where
468
+ * the rpId matches, so WebAuthn works.
469
+ *
470
+ * Must be called from a user-gesture handler (e.g. button click) to
471
+ * avoid the browser's pop-up blocker.
472
+ *
473
+ * @returns The matching credential ID, or `null` if none matched or the
474
+ * popup was closed before completing.
475
+ */
476
+ declare function findDevicePasskeyViaPopup(options: PasskeyVerifyPopupOptions): Promise<string | null>;
443
477
 
444
478
  type AccessTokenGetter = () => Promise<string | null | undefined>;
479
+ declare function resolvePasskeyRpId(): string;
445
480
  /**
446
481
  * Creates a WebAuthn passkey credential.
447
482
  * Used for upfront passkey registration before the authorization flow.
@@ -464,10 +499,16 @@ declare function createPasskeyCredential(params: {
464
499
  * Builds the {@link PasskeyPopupOptions} for a user. Called by the UI
465
500
  * layer when it needs to open the passkey creation pop-up after
466
501
  * `createPasskeyCredential` throws {@link PasskeyIframeBlockedError}.
502
+ *
503
+ * @param params.authToken - Privy JWT so the popup can register the
504
+ * passkey server-side (Safari fallback when BroadcastChannel is blocked).
505
+ * @param params.apiBaseUrl - Core API base URL for server-side registration.
467
506
  */
468
507
  declare function buildPasskeyPopupOptions(params: {
469
508
  userId: string;
470
509
  displayName: string;
510
+ authToken?: string;
511
+ apiBaseUrl?: string;
471
512
  }): PasskeyPopupOptions;
472
513
  /**
473
514
  * @deprecated Use {@link findDevicePasskey} instead, which checks all
@@ -707,4 +748,4 @@ interface AdvancedSourceScreenProps {
707
748
  }
708
749
  declare function AdvancedSourceScreen({ choices, selectedChainName, selectedTokenSymbol, onSelectSource, onBack, }: AdvancedSourceScreenProps): react_jsx_runtime.JSX.Element;
709
750
 
710
- export { type Account, type ActionExecutionResult, type AdvancedSettings, AdvancedSourceScreen, type Amount, type AuthorizationAction, type AuthorizationSession, type AuthorizationSessionDetail, type Chain, CreatePasskeyScreen, type Destination, type ErrorResponse, IconCircle, InfoBanner, type ListResponse, type MerchantAuthorization, type MerchantPublicKey, OutlineButton, PasskeyIframeBlockedError, type PaymentStep, PoweredByFooter, PrimaryButton, type Provider, ScreenHeader, ScreenLayout, SelectSourceScreen, SettingsMenu, SetupScreen, type SourceOption, type SourceSelection, type SourceType, Spinner, type StepItem, StepList, SwypePayment, type SwypePaymentProps, SwypeProvider, type SwypeProviderProps, type ThemeMode, type ThemeTokens, type TokenBalance, type Transfer, type TransferDestination, type UserConfig, type Wallet, type WalletSource, type WalletToken, buildPasskeyPopupOptions, createPasskeyCredential, createPasskeyViaPopup, darkTheme, deviceHasPasskey, findDevicePasskey, getTheme, lightTheme, api as swypeApi, useAuthorizationExecutor, useSwypeConfig, useSwypeDepositAmount, useTransferPolling, useTransferSigning };
751
+ export { type Account, type ActionExecutionResult, type AdvancedSettings, AdvancedSourceScreen, type Amount, type AuthorizationAction, type AuthorizationSession, type AuthorizationSessionDetail, type Chain, CreatePasskeyScreen, type Destination, type ErrorResponse, IconCircle, InfoBanner, type ListResponse, type MerchantAuthorization, type MerchantPublicKey, OutlineButton, PasskeyIframeBlockedError, type PaymentStep, PoweredByFooter, PrimaryButton, type Provider, ScreenHeader, ScreenLayout, SelectSourceScreen, SettingsMenu, SetupScreen, type SourceOption, type SourceSelection, type SourceType, Spinner, type StepItem, StepList, SwypePayment, type SwypePaymentProps, SwypeProvider, type SwypeProviderProps, type ThemeMode, type ThemeTokens, type TokenBalance, type Transfer, type TransferDestination, type UserConfig, type Wallet, type WalletSource, type WalletToken, buildPasskeyPopupOptions, createPasskeyCredential, createPasskeyViaPopup, darkTheme, deviceHasPasskey, findDevicePasskey, findDevicePasskeyViaPopup, getTheme, lightTheme, resolvePasskeyRpId, api as swypeApi, useAuthorizationExecutor, useSwypeConfig, useSwypeDepositAmount, useTransferPolling, useTransferSigning };