@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.cjs CHANGED
@@ -1895,6 +1895,7 @@ var containerStyle5 = {
1895
1895
  width: "100%"
1896
1896
  };
1897
1897
  var inputStyle = (tokens, filled) => ({
1898
+ boxSizing: "border-box",
1898
1899
  width: 44,
1899
1900
  maxWidth: "calc((100% - 40px) / 6)",
1900
1901
  height: 52,
@@ -3857,6 +3858,15 @@ function OpenWalletScreen({
3857
3858
  const { tokens } = useSwypeConfig();
3858
3859
  const displayName = walletName ?? "your wallet";
3859
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]);
3860
3870
  const handleOpen = react.useCallback(() => {
3861
3871
  const opened = window.open(deeplinkUri, "_blank");
3862
3872
  if (!opened && window === window.parent) {
@@ -3871,7 +3881,7 @@ function OpenWalletScreen({
3871
3881
  "Open ",
3872
3882
  displayName
3873
3883
  ] }),
3874
- /* @__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" })
3875
3885
  ] }),
3876
3886
  children: [
3877
3887
  /* @__PURE__ */ jsxRuntime.jsx(ScreenHeader, { right: /* @__PURE__ */ jsxRuntime.jsx(SettingsMenu, { onLogout }) }),
@@ -3934,6 +3944,98 @@ var hintStyle3 = (color) => ({
3934
3944
  color,
3935
3945
  margin: "8px 0 0"
3936
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
+ });
3937
4039
  var PaymentErrorBoundary = class extends react.Component {
3938
4040
  constructor(props) {
3939
4041
  super(props);
@@ -3959,7 +4061,7 @@ var PaymentErrorBoundary = class extends react.Component {
3959
4061
  /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M12 8v5", stroke: "#ef4444", strokeWidth: "1.5", strokeLinecap: "round" }),
3960
4062
  /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "12", cy: "16", r: "0.75", fill: "#ef4444" })
3961
4063
  ] }) }),
3962
- /* @__PURE__ */ jsxRuntime.jsx("h2", { style: headingStyle9, children: "Something went wrong" }),
4064
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { style: headingStyle10, children: "Something went wrong" }),
3963
4065
  /* @__PURE__ */ jsxRuntime.jsx("p", { style: messageStyle, children: "An unexpected error occurred. Please try again." }),
3964
4066
  /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: this.handleReset, style: buttonStyle3, children: "Try again" })
3965
4067
  ] });
@@ -3979,7 +4081,7 @@ var containerStyle8 = {
3979
4081
  var iconStyle4 = {
3980
4082
  marginBottom: 20
3981
4083
  };
3982
- var headingStyle9 = {
4084
+ var headingStyle10 = {
3983
4085
  fontSize: "1.25rem",
3984
4086
  fontWeight: 700,
3985
4087
  color: "#1a1a1a",
@@ -4428,32 +4530,18 @@ function SwypePaymentInner({
4428
4530
  if (mobileSetupFlowRef.current) {
4429
4531
  mobileSetupFlowRef.current = false;
4430
4532
  clearMobileFlowState();
4431
- setMobileFlow(false);
4432
4533
  setDeeplinkUri(null);
4433
4534
  polling.stopPolling();
4434
4535
  setTransfer(polledTransfer);
4435
4536
  reloadAccounts().catch(() => {
4537
+ }).then(() => {
4538
+ setMobileFlow(false);
4539
+ setStep("deposit");
4436
4540
  });
4437
- setStep("deposit");
4438
4541
  return;
4439
4542
  }
4440
- if (transferSigning.signing) return;
4441
- if (mobileSigningTransferIdRef.current === polledTransfer.id) return;
4442
- mobileSigningTransferIdRef.current = polledTransfer.id;
4443
- const sign = async () => {
4444
- try {
4445
- const signedTransfer = await transferSigning.signTransfer(polledTransfer.id);
4446
- setTransfer(signedTransfer);
4447
- clearMobileFlowState();
4448
- setStep("processing");
4449
- } catch (err) {
4450
- mobileSigningTransferIdRef.current = null;
4451
- const msg = err instanceof Error ? err.message : "Failed to sign transfer";
4452
- setError(msg);
4453
- onError?.(msg);
4454
- }
4455
- };
4456
- void sign();
4543
+ setTransfer(polledTransfer);
4544
+ setStep("confirm-sign");
4457
4545
  }, [mobileFlow, polling.transfer, polling.stopPolling, transferSigning, onError, reloadAccounts]);
4458
4546
  react.useEffect(() => {
4459
4547
  if (!mobileFlow) return;
@@ -4804,6 +4892,20 @@ function SwypePaymentInner({
4804
4892
  setDeeplinkUri(null);
4805
4893
  resetHeadlessLogin();
4806
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]);
4807
4909
  if (!ready) {
4808
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..." }) }) });
4809
4911
  }
@@ -4885,6 +4987,19 @@ function SwypePaymentInner({
4885
4987
  }
4886
4988
  );
4887
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
+ }
4888
5003
  if (step === "deposit") {
4889
5004
  if (loadingData) {
4890
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..." }) }) });
@@ -4989,6 +5104,7 @@ function SwypePaymentInner({
4989
5104
  return null;
4990
5105
  }
4991
5106
 
5107
+ exports.CreatePasskeyScreen = CreatePasskeyScreen;
4992
5108
  exports.IconCircle = IconCircle;
4993
5109
  exports.OutlineButton = OutlineButton;
4994
5110
  exports.PasskeyIframeBlockedError = PasskeyIframeBlockedError;