@swype-org/react-sdk 0.1.55 → 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
@@ -1892,6 +1892,7 @@ var containerStyle5 = {
1892
1892
  width: "100%"
1893
1893
  };
1894
1894
  var inputStyle = (tokens, filled) => ({
1895
+ boxSizing: "border-box",
1895
1896
  width: 44,
1896
1897
  maxWidth: "calc((100% - 40px) / 6)",
1897
1898
  height: 52,
@@ -3854,6 +3855,15 @@ function OpenWalletScreen({
3854
3855
  const { tokens } = useSwypeConfig();
3855
3856
  const displayName = walletName ?? "your wallet";
3856
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]);
3857
3867
  const handleOpen = useCallback(() => {
3858
3868
  const opened = window.open(deeplinkUri, "_blank");
3859
3869
  if (!opened && window === window.parent) {
@@ -3868,7 +3878,7 @@ function OpenWalletScreen({
3868
3878
  "Open ",
3869
3879
  displayName
3870
3880
  ] }),
3871
- /* @__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" })
3872
3882
  ] }),
3873
3883
  children: [
3874
3884
  /* @__PURE__ */ jsx(ScreenHeader, { right: /* @__PURE__ */ jsx(SettingsMenu, { onLogout }) }),
@@ -3931,6 +3941,98 @@ var hintStyle3 = (color) => ({
3931
3941
  color,
3932
3942
  margin: "8px 0 0"
3933
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
+ });
3934
4036
  var PaymentErrorBoundary = class extends Component {
3935
4037
  constructor(props) {
3936
4038
  super(props);
@@ -3956,7 +4058,7 @@ var PaymentErrorBoundary = class extends Component {
3956
4058
  /* @__PURE__ */ jsx("path", { d: "M12 8v5", stroke: "#ef4444", strokeWidth: "1.5", strokeLinecap: "round" }),
3957
4059
  /* @__PURE__ */ jsx("circle", { cx: "12", cy: "16", r: "0.75", fill: "#ef4444" })
3958
4060
  ] }) }),
3959
- /* @__PURE__ */ jsx("h2", { style: headingStyle9, children: "Something went wrong" }),
4061
+ /* @__PURE__ */ jsx("h2", { style: headingStyle10, children: "Something went wrong" }),
3960
4062
  /* @__PURE__ */ jsx("p", { style: messageStyle, children: "An unexpected error occurred. Please try again." }),
3961
4063
  /* @__PURE__ */ jsx("button", { type: "button", onClick: this.handleReset, style: buttonStyle3, children: "Try again" })
3962
4064
  ] });
@@ -3976,7 +4078,7 @@ var containerStyle8 = {
3976
4078
  var iconStyle4 = {
3977
4079
  marginBottom: 20
3978
4080
  };
3979
- var headingStyle9 = {
4081
+ var headingStyle10 = {
3980
4082
  fontSize: "1.25rem",
3981
4083
  fontWeight: 700,
3982
4084
  color: "#1a1a1a",
@@ -4425,32 +4527,18 @@ function SwypePaymentInner({
4425
4527
  if (mobileSetupFlowRef.current) {
4426
4528
  mobileSetupFlowRef.current = false;
4427
4529
  clearMobileFlowState();
4428
- setMobileFlow(false);
4429
4530
  setDeeplinkUri(null);
4430
4531
  polling.stopPolling();
4431
4532
  setTransfer(polledTransfer);
4432
4533
  reloadAccounts().catch(() => {
4534
+ }).then(() => {
4535
+ setMobileFlow(false);
4536
+ setStep("deposit");
4433
4537
  });
4434
- setStep("deposit");
4435
4538
  return;
4436
4539
  }
4437
- if (transferSigning.signing) return;
4438
- if (mobileSigningTransferIdRef.current === polledTransfer.id) return;
4439
- mobileSigningTransferIdRef.current = polledTransfer.id;
4440
- const sign = async () => {
4441
- try {
4442
- const signedTransfer = await transferSigning.signTransfer(polledTransfer.id);
4443
- setTransfer(signedTransfer);
4444
- clearMobileFlowState();
4445
- setStep("processing");
4446
- } catch (err) {
4447
- mobileSigningTransferIdRef.current = null;
4448
- const msg = err instanceof Error ? err.message : "Failed to sign transfer";
4449
- setError(msg);
4450
- onError?.(msg);
4451
- }
4452
- };
4453
- void sign();
4540
+ setTransfer(polledTransfer);
4541
+ setStep("confirm-sign");
4454
4542
  }, [mobileFlow, polling.transfer, polling.stopPolling, transferSigning, onError, reloadAccounts]);
4455
4543
  useEffect(() => {
4456
4544
  if (!mobileFlow) return;
@@ -4801,6 +4889,20 @@ function SwypePaymentInner({
4801
4889
  setDeeplinkUri(null);
4802
4890
  resetHeadlessLogin();
4803
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]);
4804
4906
  if (!ready) {
4805
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..." }) }) });
4806
4908
  }
@@ -4882,6 +4984,19 @@ function SwypePaymentInner({
4882
4984
  }
4883
4985
  );
4884
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
+ }
4885
5000
  if (step === "deposit") {
4886
5001
  if (loadingData) {
4887
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..." }) }) });
@@ -4986,6 +5101,6 @@ function SwypePaymentInner({
4986
5101
  return null;
4987
5102
  }
4988
5103
 
4989
- 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 };
4990
5105
  //# sourceMappingURL=index.js.map
4991
5106
  //# sourceMappingURL=index.js.map