@orangecheck/auth-client 2.9.1 → 2.10.0

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.js CHANGED
@@ -771,7 +771,6 @@ var OcAddressInput = React3__namespace.forwardRef(
771
771
  }
772
772
  );
773
773
  var DEFAULT_AUTH_ORIGIN = "https://ochk.io";
774
- var LINK_PROMPT_DISMISS_KEY = "oc:linkprompt-dismissed";
775
774
  function OcLinkedIdentities({
776
775
  authOrigin = DEFAULT_AUTH_ORIGIN,
777
776
  className,
@@ -1093,47 +1092,24 @@ function LinkPromptStep({
1093
1092
  authOrigin,
1094
1093
  onResolved
1095
1094
  }) {
1096
- const [stage, setStage] = React3__namespace.useState("offer");
1097
- function decline() {
1098
- try {
1099
- window.localStorage.setItem(LINK_PROMPT_DISMISS_KEY, String(Date.now()));
1100
- } catch {
1101
- }
1102
- onResolved();
1103
- }
1104
- if (stage === "linking") {
1105
- return method === "btc" ? /* @__PURE__ */ jsxRuntime.jsx(
1095
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-oc-linkprompt": method, children: [
1096
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { ...panelStyle("success"), marginBottom: 16 }, children: [
1097
+ /* @__PURE__ */ jsxRuntime.jsx(SectionLabel, { tone: "success", children: "\xA7 signed in" }),
1098
+ /* @__PURE__ */ jsxRuntime.jsxs("p", { style: { ...bodyStyle, margin: 0 }, children: [
1099
+ "You asked to also link ",
1100
+ method === "btc" ? "a Bitcoin address" : "an email",
1101
+ " \u2014 here it is. Finish below, or cancel to head straight on."
1102
+ ] })
1103
+ ] }),
1104
+ method === "btc" ? /* @__PURE__ */ jsxRuntime.jsx(
1106
1105
  BtcLinkForm,
1107
1106
  {
1108
1107
  authOrigin,
1109
1108
  didOc,
1110
1109
  onDone: onResolved,
1111
- onCancel: () => setStage("offer")
1112
- }
1113
- ) : /* @__PURE__ */ jsxRuntime.jsx(
1114
- EmailLinkForm,
1115
- {
1116
- authOrigin,
1117
- onDone: onResolved,
1118
- onCancel: () => setStage("offer")
1110
+ onCancel: onResolved
1119
1111
  }
1120
- );
1121
- }
1122
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: panelStyle("accent"), "data-oc-linkprompt": method, children: [
1123
- /* @__PURE__ */ jsxRuntime.jsx(SectionLabel, { tone: "success", children: "\xA7 you're signed in" }),
1124
- /* @__PURE__ */ jsxRuntime.jsx("p", { style: bodyStyle, children: method === "btc" ? "Optional \u2014 link a Bitcoin address and it becomes a second way to sign in, and unlocks your on-chain footprint. One wallet signature, right here. No pressure: you can always do this later from your account page." : "Optional \u2014 add your email as a backup way to sign in if you ever lose your wallet. One six-digit code, right here. No pressure: you can always do this later from your account page." }),
1125
- /* @__PURE__ */ jsxRuntime.jsxs(FormButtons, { children: [
1126
- /* @__PURE__ */ jsxRuntime.jsx(
1127
- "button",
1128
- {
1129
- type: "button",
1130
- onClick: () => setStage("linking"),
1131
- style: primaryBtnStyle(false),
1132
- children: method === "btc" ? "link a Bitcoin address" : "link an email"
1133
- }
1134
- ),
1135
- /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: decline, style: ghostBtnStyle(false), children: "not now" })
1136
- ] })
1112
+ ) : /* @__PURE__ */ jsxRuntime.jsx(EmailLinkForm, { authOrigin, onDone: onResolved, onCancel: onResolved })
1137
1113
  ] });
1138
1114
  }
1139
1115
  function EmailLinkForm({
@@ -1655,6 +1631,7 @@ function OcSignIn({
1655
1631
  const safeReturn = safeReturnTo(returnTo);
1656
1632
  const [path, setPath] = React3__namespace.useState(initialPath);
1657
1633
  const [signedIn, setSignedIn] = React3__namespace.useState(null);
1634
+ const [linkAlso, setLinkAlso] = React3__namespace.useState(false);
1658
1635
  const navigate = React3__namespace.useCallback(
1659
1636
  async (account) => {
1660
1637
  if (resolveReturnTo) {
@@ -1674,12 +1651,7 @@ function OcSignIn({
1674
1651
  if (onSuccess) onSuccess(account, token);
1675
1652
  else void navigate(account);
1676
1653
  };
1677
- let declined = false;
1678
- try {
1679
- declined = Boolean(window.localStorage.getItem(LINK_PROMPT_DISMISS_KEY));
1680
- } catch {
1681
- }
1682
- if (!linkPrompt || declined) {
1654
+ if (!linkPrompt || !linkAlso) {
1683
1655
  proceed();
1684
1656
  return;
1685
1657
  }
@@ -1689,19 +1661,20 @@ function OcSignIn({
1689
1661
  headers: { Accept: "application/json" }
1690
1662
  });
1691
1663
  const me = meRes.ok ? await meRes.json() : null;
1692
- const acct = me?.account;
1693
- const didOc = acct?.did_oc;
1694
- const complementary = via === "email" ? "btc" : "email";
1695
- const alreadyLinked = complementary === "btc" ? Boolean(acct?.primary_btc) : Boolean(acct?.has_email);
1696
- if (didOc && !alreadyLinked) {
1697
- setSignedIn({ method: complementary, didOc, proceed });
1664
+ const didOc = me?.account?.did_oc;
1665
+ if (didOc) {
1666
+ setSignedIn({
1667
+ method: via === "email" ? "btc" : "email",
1668
+ didOc,
1669
+ proceed
1670
+ });
1698
1671
  return;
1699
1672
  }
1700
1673
  } catch {
1701
1674
  }
1702
1675
  proceed();
1703
1676
  },
1704
- [onSuccess, linkPrompt, navigate, authOrigin]
1677
+ [onSuccess, linkPrompt, linkAlso, navigate, authOrigin]
1705
1678
  );
1706
1679
  if (!walletEnabled && !emailEnabled) {
1707
1680
  return /* @__PURE__ */ jsxRuntime.jsxs(
@@ -1742,6 +1715,7 @@ function OcSignIn({
1742
1715
  const showWallet = walletEnabled && (path === "wallet" || !emailEnabled);
1743
1716
  const showEmail = emailEnabled && (path === "email" || !walletEnabled);
1744
1717
  const bothEnabled = walletEnabled && emailEnabled;
1718
+ const activeMethod = !emailEnabled ? "wallet" : !walletEnabled ? "email" : path;
1745
1719
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, "data-oc-signin": "", children: [
1746
1720
  bothEnabled && /* @__PURE__ */ jsxRuntime.jsxs(
1747
1721
  "div",
@@ -1784,6 +1758,24 @@ function OcSignIn({
1784
1758
  onSuccess: (a, t) => void handleSuccess(a, t, "email")
1785
1759
  }
1786
1760
  )
1761
+ ] }),
1762
+ linkPrompt && /* @__PURE__ */ jsxRuntime.jsxs("label", { "data-oc-signin-linkalso": "", style: linkAlsoStyle, children: [
1763
+ /* @__PURE__ */ jsxRuntime.jsx(
1764
+ "input",
1765
+ {
1766
+ type: "checkbox",
1767
+ checked: linkAlso,
1768
+ onChange: (e) => setLinkAlso(e.target.checked),
1769
+ style: { marginTop: 2, accentColor: "var(--primary, #f97316)" }
1770
+ }
1771
+ ),
1772
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
1773
+ "After signing in, also link",
1774
+ " ",
1775
+ activeMethod === "email" ? "a Bitcoin wallet" : "an email",
1776
+ " ",
1777
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: { opacity: 0.65 }, children: "\u2014 optional, one more signature." })
1778
+ ] })
1787
1779
  ] })
1788
1780
  ] });
1789
1781
  }
@@ -2135,6 +2127,19 @@ var inputStyle2 = {
2135
2127
  fontSize: 16,
2136
2128
  outline: "none"
2137
2129
  };
2130
+ var linkAlsoStyle = {
2131
+ display: "flex",
2132
+ alignItems: "flex-start",
2133
+ gap: 8,
2134
+ marginTop: 16,
2135
+ paddingTop: 14,
2136
+ borderTop: "1px solid var(--border, #27272a)",
2137
+ color: "var(--muted-foreground, #a1a1aa)",
2138
+ fontFamily: "ui-monospace, SFMono-Regular, monospace",
2139
+ fontSize: 12,
2140
+ lineHeight: 1.5,
2141
+ cursor: "pointer"
2142
+ };
2138
2143
  function submitStyle(disabled) {
2139
2144
  return {
2140
2145
  marginTop: 12,