@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.cjs CHANGED
@@ -3858,6 +3858,15 @@ function OpenWalletScreen({
3858
3858
  const { tokens } = useSwypeConfig();
3859
3859
  const displayName = walletName ?? "your wallet";
3860
3860
  const logoSrc = walletName ? KNOWN_LOGOS[walletName.toLowerCase()] : void 0;
3861
+ const autoOpenedRef = react.useRef(null);
3862
+ react.useEffect(() => {
3863
+ if (loading || !deeplinkUri || autoOpenedRef.current === deeplinkUri) return;
3864
+ autoOpenedRef.current = deeplinkUri;
3865
+ const opened = window.open(deeplinkUri, "_blank");
3866
+ if (!opened && window === window.parent) {
3867
+ window.location.href = deeplinkUri;
3868
+ }
3869
+ }, [loading, deeplinkUri]);
3861
3870
  const handleOpen = react.useCallback(() => {
3862
3871
  const opened = window.open(deeplinkUri, "_blank");
3863
3872
  if (!opened && window === window.parent) {
@@ -3872,7 +3881,7 @@ function OpenWalletScreen({
3872
3881
  "Open ",
3873
3882
  displayName
3874
3883
  ] }),
3875
- /* @__PURE__ */ jsxRuntime.jsx("p", { style: hintStyle3(tokens.textMuted), children: loading ? "Preparing authorization..." : "Tap the button to authorize in your wallet app" })
3884
+ /* @__PURE__ */ jsxRuntime.jsx("p", { style: hintStyle3(tokens.textMuted), children: loading ? "Preparing authorization..." : "If your wallet didn't open automatically, tap the button above" })
3876
3885
  ] }),
3877
3886
  children: [
3878
3887
  /* @__PURE__ */ jsxRuntime.jsx(ScreenHeader, { right: /* @__PURE__ */ jsxRuntime.jsx(SettingsMenu, { onLogout }) }),
@@ -3935,6 +3944,98 @@ var hintStyle3 = (color) => ({
3935
3944
  color,
3936
3945
  margin: "8px 0 0"
3937
3946
  });
3947
+ function ConfirmSignScreen({
3948
+ walletName,
3949
+ signing,
3950
+ error,
3951
+ onSign,
3952
+ onLogout
3953
+ }) {
3954
+ const { tokens } = useSwypeConfig();
3955
+ const displayName = walletName ?? "your wallet";
3956
+ const logoSrc = walletName ? KNOWN_LOGOS[walletName.toLowerCase()] : void 0;
3957
+ return /* @__PURE__ */ jsxRuntime.jsxs(
3958
+ ScreenLayout,
3959
+ {
3960
+ footer: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3961
+ /* @__PURE__ */ jsxRuntime.jsx(PrimaryButton, { onClick: onSign, disabled: signing, children: signing ? "Confirming..." : "Confirm payment" }),
3962
+ error && /* @__PURE__ */ jsxRuntime.jsx("p", { style: errorStyle2(tokens.textMuted), children: error }),
3963
+ !error && /* @__PURE__ */ jsxRuntime.jsx("p", { style: hintStyle4(tokens.textMuted), children: "You may be prompted for biometric verification" })
3964
+ ] }),
3965
+ children: [
3966
+ /* @__PURE__ */ jsxRuntime.jsx(ScreenHeader, { right: /* @__PURE__ */ jsxRuntime.jsx(SettingsMenu, { onLogout }) }),
3967
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: contentStyle7, children: [
3968
+ logoSrc ? /* @__PURE__ */ jsxRuntime.jsx("img", { src: logoSrc, alt: displayName, style: logoStyle2 }) : /* @__PURE__ */ jsxRuntime.jsx(Spinner, { size: 48 }),
3969
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { style: headingStyle9(tokens.text), children: "Wallet authorized" }),
3970
+ /* @__PURE__ */ jsxRuntime.jsxs("p", { style: subtitleStyle9(tokens.textSecondary), children: [
3971
+ displayName,
3972
+ " approved the connection. Tap below to confirm your payment."
3973
+ ] }),
3974
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: successBadgeStyle(tokens), children: [
3975
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: checkmarkStyle, children: "\u2713" }),
3976
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Authorization complete" })
3977
+ ] })
3978
+ ] })
3979
+ ]
3980
+ }
3981
+ );
3982
+ }
3983
+ var contentStyle7 = {
3984
+ flex: 1,
3985
+ display: "flex",
3986
+ flexDirection: "column",
3987
+ alignItems: "center",
3988
+ justifyContent: "center",
3989
+ textAlign: "center",
3990
+ padding: "0 24px"
3991
+ };
3992
+ var logoStyle2 = {
3993
+ width: 56,
3994
+ height: 56,
3995
+ borderRadius: 14,
3996
+ objectFit: "contain"
3997
+ };
3998
+ var headingStyle9 = (color) => ({
3999
+ fontSize: "1.45rem",
4000
+ fontWeight: 700,
4001
+ letterSpacing: "-0.02em",
4002
+ color,
4003
+ margin: "20px 0 8px"
4004
+ });
4005
+ var subtitleStyle9 = (color) => ({
4006
+ fontSize: "0.9rem",
4007
+ color,
4008
+ margin: "0 0 24px",
4009
+ lineHeight: 1.5,
4010
+ maxWidth: 280
4011
+ });
4012
+ var successBadgeStyle = (tokens) => ({
4013
+ display: "inline-flex",
4014
+ alignItems: "center",
4015
+ gap: 8,
4016
+ padding: "8px 16px",
4017
+ borderRadius: 20,
4018
+ background: tokens.bgInput,
4019
+ border: `1px solid ${tokens.border}`,
4020
+ color: "#22c55e",
4021
+ fontSize: "0.82rem"
4022
+ });
4023
+ var checkmarkStyle = {
4024
+ fontWeight: 700,
4025
+ fontSize: "0.9rem"
4026
+ };
4027
+ var hintStyle4 = (color) => ({
4028
+ textAlign: "center",
4029
+ fontSize: "0.82rem",
4030
+ color,
4031
+ margin: "8px 0 0"
4032
+ });
4033
+ var errorStyle2 = (color) => ({
4034
+ textAlign: "center",
4035
+ fontSize: "0.82rem",
4036
+ color: "#ef4444",
4037
+ margin: "8px 0 0"
4038
+ });
3938
4039
  var PaymentErrorBoundary = class extends react.Component {
3939
4040
  constructor(props) {
3940
4041
  super(props);
@@ -3960,7 +4061,7 @@ var PaymentErrorBoundary = class extends react.Component {
3960
4061
  /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M12 8v5", stroke: "#ef4444", strokeWidth: "1.5", strokeLinecap: "round" }),
3961
4062
  /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "12", cy: "16", r: "0.75", fill: "#ef4444" })
3962
4063
  ] }) }),
3963
- /* @__PURE__ */ jsxRuntime.jsx("h2", { style: headingStyle9, children: "Something went wrong" }),
4064
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { style: headingStyle10, children: "Something went wrong" }),
3964
4065
  /* @__PURE__ */ jsxRuntime.jsx("p", { style: messageStyle, children: "An unexpected error occurred. Please try again." }),
3965
4066
  /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: this.handleReset, style: buttonStyle3, children: "Try again" })
3966
4067
  ] });
@@ -3980,7 +4081,7 @@ var containerStyle8 = {
3980
4081
  var iconStyle4 = {
3981
4082
  marginBottom: 20
3982
4083
  };
3983
- var headingStyle9 = {
4084
+ var headingStyle10 = {
3984
4085
  fontSize: "1.25rem",
3985
4086
  fontWeight: 700,
3986
4087
  color: "#1a1a1a",
@@ -4439,23 +4540,8 @@ function SwypePaymentInner({
4439
4540
  });
4440
4541
  return;
4441
4542
  }
4442
- if (transferSigning.signing) return;
4443
- if (mobileSigningTransferIdRef.current === polledTransfer.id) return;
4444
- mobileSigningTransferIdRef.current = polledTransfer.id;
4445
- const sign = async () => {
4446
- try {
4447
- const signedTransfer = await transferSigning.signTransfer(polledTransfer.id);
4448
- setTransfer(signedTransfer);
4449
- clearMobileFlowState();
4450
- setStep("processing");
4451
- } catch (err) {
4452
- mobileSigningTransferIdRef.current = null;
4453
- const msg = err instanceof Error ? err.message : "Failed to sign transfer";
4454
- setError(msg);
4455
- onError?.(msg);
4456
- }
4457
- };
4458
- void sign();
4543
+ setTransfer(polledTransfer);
4544
+ setStep("confirm-sign");
4459
4545
  }, [mobileFlow, polling.transfer, polling.stopPolling, transferSigning, onError, reloadAccounts]);
4460
4546
  react.useEffect(() => {
4461
4547
  if (!mobileFlow) return;
@@ -4806,6 +4892,20 @@ function SwypePaymentInner({
4806
4892
  setDeeplinkUri(null);
4807
4893
  resetHeadlessLogin();
4808
4894
  }, [logout, polling, depositAmount, resetHeadlessLogin]);
4895
+ const handleConfirmSign = react.useCallback(async () => {
4896
+ const t = transfer ?? polling.transfer;
4897
+ if (!t) return;
4898
+ try {
4899
+ const signedTransfer = await transferSigning.signTransfer(t.id);
4900
+ setTransfer(signedTransfer);
4901
+ clearMobileFlowState();
4902
+ setStep("processing");
4903
+ } catch (err) {
4904
+ const msg = err instanceof Error ? err.message : "Failed to sign transfer";
4905
+ setError(msg);
4906
+ onError?.(msg);
4907
+ }
4908
+ }, [transfer, polling.transfer, transferSigning, onError]);
4809
4909
  if (!ready) {
4810
4910
  return /* @__PURE__ */ jsxRuntime.jsx(ScreenLayout, { children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: { textAlign: "center", padding: "48px 0", flex: 1, display: "flex", alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ jsxRuntime.jsx(Spinner, { label: "Initializing..." }) }) });
4811
4911
  }
@@ -4887,6 +4987,19 @@ function SwypePaymentInner({
4887
4987
  }
4888
4988
  );
4889
4989
  }
4990
+ if (step === "confirm-sign") {
4991
+ const providerName = providers.find((p) => p.id === selectedProviderId)?.name ?? null;
4992
+ return /* @__PURE__ */ jsxRuntime.jsx(
4993
+ ConfirmSignScreen,
4994
+ {
4995
+ walletName: providerName,
4996
+ signing: transferSigning.signing,
4997
+ error: error || transferSigning.error,
4998
+ onSign: handleConfirmSign,
4999
+ onLogout: handleLogout
5000
+ }
5001
+ );
5002
+ }
4890
5003
  if (step === "deposit") {
4891
5004
  if (loadingData) {
4892
5005
  return /* @__PURE__ */ jsxRuntime.jsx(ScreenLayout, { children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: { textAlign: "center", padding: "48px 0", flex: 1, display: "flex", alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ jsxRuntime.jsx(Spinner, { label: "Loading..." }) }) });
@@ -4991,6 +5104,7 @@ function SwypePaymentInner({
4991
5104
  return null;
4992
5105
  }
4993
5106
 
5107
+ exports.CreatePasskeyScreen = CreatePasskeyScreen;
4994
5108
  exports.IconCircle = IconCircle;
4995
5109
  exports.OutlineButton = OutlineButton;
4996
5110
  exports.PasskeyIframeBlockedError = PasskeyIframeBlockedError;