@swype-org/react-sdk 0.1.56 → 0.1.59

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' | 'deposit' | 'low-balance' | 'processing' | 'select-source' | 'success';
202
+ type PaymentStep = 'login' | 'otp-verify' | 'create-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. */
@@ -622,6 +622,18 @@ interface SpinnerProps {
622
622
  }
623
623
  declare function Spinner({ size, label }: SpinnerProps): react_jsx_runtime.JSX.Element;
624
624
 
625
+ interface CreatePasskeyScreenProps {
626
+ onCreatePasskey: () => void;
627
+ onBack: () => void;
628
+ creating: boolean;
629
+ error: string | null;
630
+ /** When true, direct passkey creation failed (Safari iframe restriction). */
631
+ popupFallback?: boolean;
632
+ /** Opens a pop-up window on the Swype domain for passkey registration. */
633
+ onCreatePasskeyViaPopup?: () => void;
634
+ }
635
+ declare function CreatePasskeyScreen({ onCreatePasskey, onBack, creating, error, popupFallback, onCreatePasskeyViaPopup, }: CreatePasskeyScreenProps): react_jsx_runtime.JSX.Element;
636
+
625
637
  interface SetupScreenProps {
626
638
  availableBalance: number;
627
639
  /** Number of tokens/chains available */
@@ -659,4 +671,4 @@ interface SelectSourceScreenProps {
659
671
  }
660
672
  declare function SelectSourceScreen({ choices, selectedChainName, selectedTokenSymbol, recommended, onChainChange, onTokenChange, onConfirm, onLogout, }: SelectSourceScreenProps): react_jsx_runtime.JSX.Element;
661
673
 
662
- export { type Account, type ActionExecutionResult, type AdvancedSettings, type Amount, type AuthorizationAction, type AuthorizationSession, type AuthorizationSessionDetail, type Chain, type Destination, type ErrorResponse, IconCircle, 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 };
674
+ export { type Account, type ActionExecutionResult, type AdvancedSettings, type Amount, type AuthorizationAction, type AuthorizationSession, type AuthorizationSessionDetail, type Chain, CreatePasskeyScreen, type Destination, type ErrorResponse, IconCircle, 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 };
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' | 'deposit' | 'low-balance' | 'processing' | 'select-source' | 'success';
202
+ type PaymentStep = 'login' | 'otp-verify' | 'create-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. */
@@ -622,6 +622,18 @@ interface SpinnerProps {
622
622
  }
623
623
  declare function Spinner({ size, label }: SpinnerProps): react_jsx_runtime.JSX.Element;
624
624
 
625
+ interface CreatePasskeyScreenProps {
626
+ onCreatePasskey: () => void;
627
+ onBack: () => void;
628
+ creating: boolean;
629
+ error: string | null;
630
+ /** When true, direct passkey creation failed (Safari iframe restriction). */
631
+ popupFallback?: boolean;
632
+ /** Opens a pop-up window on the Swype domain for passkey registration. */
633
+ onCreatePasskeyViaPopup?: () => void;
634
+ }
635
+ declare function CreatePasskeyScreen({ onCreatePasskey, onBack, creating, error, popupFallback, onCreatePasskeyViaPopup, }: CreatePasskeyScreenProps): react_jsx_runtime.JSX.Element;
636
+
625
637
  interface SetupScreenProps {
626
638
  availableBalance: number;
627
639
  /** Number of tokens/chains available */
@@ -659,4 +671,4 @@ interface SelectSourceScreenProps {
659
671
  }
660
672
  declare function SelectSourceScreen({ choices, selectedChainName, selectedTokenSymbol, recommended, onChainChange, onTokenChange, onConfirm, onLogout, }: SelectSourceScreenProps): react_jsx_runtime.JSX.Element;
661
673
 
662
- export { type Account, type ActionExecutionResult, type AdvancedSettings, type Amount, type AuthorizationAction, type AuthorizationSession, type AuthorizationSessionDetail, type Chain, type Destination, type ErrorResponse, IconCircle, 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 };
674
+ export { type Account, type ActionExecutionResult, type AdvancedSettings, type Amount, type AuthorizationAction, type AuthorizationSession, type AuthorizationSessionDetail, type Chain, CreatePasskeyScreen, type Destination, type ErrorResponse, IconCircle, 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 };
package/dist/index.js CHANGED
@@ -3855,6 +3855,15 @@ function OpenWalletScreen({
3855
3855
  const { tokens } = useSwypeConfig();
3856
3856
  const displayName = walletName ?? "your wallet";
3857
3857
  const logoSrc = walletName ? KNOWN_LOGOS[walletName.toLowerCase()] : void 0;
3858
+ const autoOpenedRef = useRef(null);
3859
+ useEffect(() => {
3860
+ if (loading || !deeplinkUri || autoOpenedRef.current === deeplinkUri) return;
3861
+ autoOpenedRef.current = deeplinkUri;
3862
+ const opened = window.open(deeplinkUri, "_blank");
3863
+ if (!opened && window === window.parent) {
3864
+ window.location.href = deeplinkUri;
3865
+ }
3866
+ }, [loading, deeplinkUri]);
3858
3867
  const handleOpen = useCallback(() => {
3859
3868
  const opened = window.open(deeplinkUri, "_blank");
3860
3869
  if (!opened && window === window.parent) {
@@ -3869,7 +3878,7 @@ function OpenWalletScreen({
3869
3878
  "Open ",
3870
3879
  displayName
3871
3880
  ] }),
3872
- /* @__PURE__ */ jsx("p", { style: hintStyle3(tokens.textMuted), children: loading ? "Preparing authorization..." : "Tap the button to authorize in your wallet app" })
3881
+ /* @__PURE__ */ jsx("p", { style: hintStyle3(tokens.textMuted), children: loading ? "Preparing authorization..." : "If your wallet didn't open automatically, tap the button above" })
3873
3882
  ] }),
3874
3883
  children: [
3875
3884
  /* @__PURE__ */ jsx(ScreenHeader, { right: /* @__PURE__ */ jsx(SettingsMenu, { onLogout }) }),
@@ -3932,6 +3941,98 @@ var hintStyle3 = (color) => ({
3932
3941
  color,
3933
3942
  margin: "8px 0 0"
3934
3943
  });
3944
+ function ConfirmSignScreen({
3945
+ walletName,
3946
+ signing,
3947
+ error,
3948
+ onSign,
3949
+ onLogout
3950
+ }) {
3951
+ const { tokens } = useSwypeConfig();
3952
+ const displayName = walletName ?? "your wallet";
3953
+ const logoSrc = walletName ? KNOWN_LOGOS[walletName.toLowerCase()] : void 0;
3954
+ return /* @__PURE__ */ jsxs(
3955
+ ScreenLayout,
3956
+ {
3957
+ footer: /* @__PURE__ */ jsxs(Fragment, { children: [
3958
+ /* @__PURE__ */ jsx(PrimaryButton, { onClick: onSign, disabled: signing, children: signing ? "Confirming..." : "Confirm payment" }),
3959
+ error && /* @__PURE__ */ jsx("p", { style: errorStyle2(tokens.textMuted), children: error }),
3960
+ !error && /* @__PURE__ */ jsx("p", { style: hintStyle4(tokens.textMuted), children: "You may be prompted for biometric verification" })
3961
+ ] }),
3962
+ children: [
3963
+ /* @__PURE__ */ jsx(ScreenHeader, { right: /* @__PURE__ */ jsx(SettingsMenu, { onLogout }) }),
3964
+ /* @__PURE__ */ jsxs("div", { style: contentStyle7, children: [
3965
+ logoSrc ? /* @__PURE__ */ jsx("img", { src: logoSrc, alt: displayName, style: logoStyle2 }) : /* @__PURE__ */ jsx(Spinner, { size: 48 }),
3966
+ /* @__PURE__ */ jsx("h2", { style: headingStyle9(tokens.text), children: "Wallet authorized" }),
3967
+ /* @__PURE__ */ jsxs("p", { style: subtitleStyle9(tokens.textSecondary), children: [
3968
+ displayName,
3969
+ " approved the connection. Tap below to confirm your payment."
3970
+ ] }),
3971
+ /* @__PURE__ */ jsxs("div", { style: successBadgeStyle(tokens), children: [
3972
+ /* @__PURE__ */ jsx("span", { style: checkmarkStyle, children: "\u2713" }),
3973
+ /* @__PURE__ */ jsx("span", { children: "Authorization complete" })
3974
+ ] })
3975
+ ] })
3976
+ ]
3977
+ }
3978
+ );
3979
+ }
3980
+ var contentStyle7 = {
3981
+ flex: 1,
3982
+ display: "flex",
3983
+ flexDirection: "column",
3984
+ alignItems: "center",
3985
+ justifyContent: "center",
3986
+ textAlign: "center",
3987
+ padding: "0 24px"
3988
+ };
3989
+ var logoStyle2 = {
3990
+ width: 56,
3991
+ height: 56,
3992
+ borderRadius: 14,
3993
+ objectFit: "contain"
3994
+ };
3995
+ var headingStyle9 = (color) => ({
3996
+ fontSize: "1.45rem",
3997
+ fontWeight: 700,
3998
+ letterSpacing: "-0.02em",
3999
+ color,
4000
+ margin: "20px 0 8px"
4001
+ });
4002
+ var subtitleStyle9 = (color) => ({
4003
+ fontSize: "0.9rem",
4004
+ color,
4005
+ margin: "0 0 24px",
4006
+ lineHeight: 1.5,
4007
+ maxWidth: 280
4008
+ });
4009
+ var successBadgeStyle = (tokens) => ({
4010
+ display: "inline-flex",
4011
+ alignItems: "center",
4012
+ gap: 8,
4013
+ padding: "8px 16px",
4014
+ borderRadius: 20,
4015
+ background: tokens.bgInput,
4016
+ border: `1px solid ${tokens.border}`,
4017
+ color: "#22c55e",
4018
+ fontSize: "0.82rem"
4019
+ });
4020
+ var checkmarkStyle = {
4021
+ fontWeight: 700,
4022
+ fontSize: "0.9rem"
4023
+ };
4024
+ var hintStyle4 = (color) => ({
4025
+ textAlign: "center",
4026
+ fontSize: "0.82rem",
4027
+ color,
4028
+ margin: "8px 0 0"
4029
+ });
4030
+ var errorStyle2 = (color) => ({
4031
+ textAlign: "center",
4032
+ fontSize: "0.82rem",
4033
+ color: "#ef4444",
4034
+ margin: "8px 0 0"
4035
+ });
3935
4036
  var PaymentErrorBoundary = class extends Component {
3936
4037
  constructor(props) {
3937
4038
  super(props);
@@ -3957,7 +4058,7 @@ var PaymentErrorBoundary = class extends Component {
3957
4058
  /* @__PURE__ */ jsx("path", { d: "M12 8v5", stroke: "#ef4444", strokeWidth: "1.5", strokeLinecap: "round" }),
3958
4059
  /* @__PURE__ */ jsx("circle", { cx: "12", cy: "16", r: "0.75", fill: "#ef4444" })
3959
4060
  ] }) }),
3960
- /* @__PURE__ */ jsx("h2", { style: headingStyle9, children: "Something went wrong" }),
4061
+ /* @__PURE__ */ jsx("h2", { style: headingStyle10, children: "Something went wrong" }),
3961
4062
  /* @__PURE__ */ jsx("p", { style: messageStyle, children: "An unexpected error occurred. Please try again." }),
3962
4063
  /* @__PURE__ */ jsx("button", { type: "button", onClick: this.handleReset, style: buttonStyle3, children: "Try again" })
3963
4064
  ] });
@@ -3977,7 +4078,7 @@ var containerStyle8 = {
3977
4078
  var iconStyle4 = {
3978
4079
  marginBottom: 20
3979
4080
  };
3980
- var headingStyle9 = {
4081
+ var headingStyle10 = {
3981
4082
  fontSize: "1.25rem",
3982
4083
  fontWeight: 700,
3983
4084
  color: "#1a1a1a",
@@ -4436,23 +4537,8 @@ function SwypePaymentInner({
4436
4537
  });
4437
4538
  return;
4438
4539
  }
4439
- if (transferSigning.signing) return;
4440
- if (mobileSigningTransferIdRef.current === polledTransfer.id) return;
4441
- mobileSigningTransferIdRef.current = polledTransfer.id;
4442
- const sign = async () => {
4443
- try {
4444
- const signedTransfer = await transferSigning.signTransfer(polledTransfer.id);
4445
- setTransfer(signedTransfer);
4446
- clearMobileFlowState();
4447
- setStep("processing");
4448
- } catch (err) {
4449
- mobileSigningTransferIdRef.current = null;
4450
- const msg = err instanceof Error ? err.message : "Failed to sign transfer";
4451
- setError(msg);
4452
- onError?.(msg);
4453
- }
4454
- };
4455
- void sign();
4540
+ setTransfer(polledTransfer);
4541
+ setStep("confirm-sign");
4456
4542
  }, [mobileFlow, polling.transfer, polling.stopPolling, transferSigning, onError, reloadAccounts]);
4457
4543
  useEffect(() => {
4458
4544
  if (!mobileFlow) return;
@@ -4803,6 +4889,20 @@ function SwypePaymentInner({
4803
4889
  setDeeplinkUri(null);
4804
4890
  resetHeadlessLogin();
4805
4891
  }, [logout, polling, depositAmount, resetHeadlessLogin]);
4892
+ const handleConfirmSign = useCallback(async () => {
4893
+ const t = transfer ?? polling.transfer;
4894
+ if (!t) return;
4895
+ try {
4896
+ const signedTransfer = await transferSigning.signTransfer(t.id);
4897
+ setTransfer(signedTransfer);
4898
+ clearMobileFlowState();
4899
+ setStep("processing");
4900
+ } catch (err) {
4901
+ const msg = err instanceof Error ? err.message : "Failed to sign transfer";
4902
+ setError(msg);
4903
+ onError?.(msg);
4904
+ }
4905
+ }, [transfer, polling.transfer, transferSigning, onError]);
4806
4906
  if (!ready) {
4807
4907
  return /* @__PURE__ */ jsx(ScreenLayout, { children: /* @__PURE__ */ jsx("div", { style: { textAlign: "center", padding: "48px 0", flex: 1, display: "flex", alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ jsx(Spinner, { label: "Initializing..." }) }) });
4808
4908
  }
@@ -4884,6 +4984,19 @@ function SwypePaymentInner({
4884
4984
  }
4885
4985
  );
4886
4986
  }
4987
+ if (step === "confirm-sign") {
4988
+ const providerName = providers.find((p) => p.id === selectedProviderId)?.name ?? null;
4989
+ return /* @__PURE__ */ jsx(
4990
+ ConfirmSignScreen,
4991
+ {
4992
+ walletName: providerName,
4993
+ signing: transferSigning.signing,
4994
+ error: error || transferSigning.error,
4995
+ onSign: handleConfirmSign,
4996
+ onLogout: handleLogout
4997
+ }
4998
+ );
4999
+ }
4887
5000
  if (step === "deposit") {
4888
5001
  if (loadingData) {
4889
5002
  return /* @__PURE__ */ jsx(ScreenLayout, { children: /* @__PURE__ */ jsx("div", { style: { textAlign: "center", padding: "48px 0", flex: 1, display: "flex", alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ jsx(Spinner, { label: "Loading..." }) }) });
@@ -4988,6 +5101,6 @@ function SwypePaymentInner({
4988
5101
  return null;
4989
5102
  }
4990
5103
 
4991
- export { IconCircle, OutlineButton, PasskeyIframeBlockedError, PoweredByFooter, PrimaryButton, ScreenHeader, ScreenLayout, SelectSourceScreen, SettingsMenu, SetupScreen, Spinner, StepList, SwypePayment, SwypeProvider, buildPasskeyPopupOptions, createPasskeyCredential, createPasskeyViaPopup, darkTheme, deviceHasPasskey, findDevicePasskey, getTheme, lightTheme, api_exports as swypeApi, useAuthorizationExecutor, useSwypeConfig, useSwypeDepositAmount, useTransferPolling, useTransferSigning };
5104
+ export { CreatePasskeyScreen, IconCircle, OutlineButton, PasskeyIframeBlockedError, PoweredByFooter, PrimaryButton, ScreenHeader, ScreenLayout, SelectSourceScreen, SettingsMenu, SetupScreen, Spinner, StepList, SwypePayment, SwypeProvider, buildPasskeyPopupOptions, createPasskeyCredential, createPasskeyViaPopup, darkTheme, deviceHasPasskey, findDevicePasskey, getTheme, lightTheme, api_exports as swypeApi, useAuthorizationExecutor, useSwypeConfig, useSwypeDepositAmount, useTransferPolling, useTransferSigning };
4992
5105
  //# sourceMappingURL=index.js.map
4993
5106
  //# sourceMappingURL=index.js.map