@orangecheck/auth-client 2.9.1 → 2.11.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,43 @@ 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
+ const what = method === "btc" ? "a Bitcoin address" : "an email";
1096
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-oc-linkprompt": method, children: [
1097
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { ...panelStyle("success"), marginBottom: 16 }, children: [
1098
+ /* @__PURE__ */ jsxRuntime.jsx(SectionLabel, { tone: "success", children: "\xA7 signed in" }),
1099
+ /* @__PURE__ */ jsxRuntime.jsxs("p", { style: { ...bodyStyle, margin: 0 }, children: [
1100
+ "You chose to also link ",
1101
+ what,
1102
+ ". Complete it below \u2014 or skip for now; it is entirely optional and changes nothing about the sign-in you just completed."
1103
+ ] })
1104
+ ] }),
1105
+ method === "btc" ? /* @__PURE__ */ jsxRuntime.jsx(
1106
1106
  BtcLinkForm,
1107
1107
  {
1108
1108
  authOrigin,
1109
1109
  didOc,
1110
1110
  onDone: onResolved,
1111
- onCancel: () => setStage("offer")
1111
+ onCancel: onResolved
1112
1112
  }
1113
- ) : /* @__PURE__ */ jsxRuntime.jsx(
1114
- EmailLinkForm,
1113
+ ) : /* @__PURE__ */ jsxRuntime.jsx(EmailLinkForm, { authOrigin, onDone: onResolved, onCancel: onResolved }),
1114
+ /* @__PURE__ */ jsxRuntime.jsxs(
1115
+ "div",
1115
1116
  {
1116
- authOrigin,
1117
- onDone: onResolved,
1118
- onCancel: () => setStage("offer")
1117
+ "data-oc-linkprompt-skip": "",
1118
+ style: { marginTop: 14, paddingTop: 14, borderTop: `1px solid ${V.border}` },
1119
+ children: [
1120
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: onResolved, style: ghostBtnStyle(false), children: "skip \u2014 I'll do this later" }),
1121
+ /* @__PURE__ */ jsxRuntime.jsxs("p", { style: { ...hintStyle, marginTop: 8 }, children: [
1122
+ "> ",
1123
+ "Changed your mind? Skipping continues you straight on \u2014 your sign-in is unaffected. You can link ",
1124
+ what,
1125
+ " anytime later from your identity page,",
1126
+ " ",
1127
+ "me.ochk.io/me/identity."
1128
+ ] })
1129
+ ]
1119
1130
  }
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
- ] })
1131
+ )
1137
1132
  ] });
1138
1133
  }
1139
1134
  function EmailLinkForm({
@@ -1655,6 +1650,7 @@ function OcSignIn({
1655
1650
  const safeReturn = safeReturnTo(returnTo);
1656
1651
  const [path, setPath] = React3__namespace.useState(initialPath);
1657
1652
  const [signedIn, setSignedIn] = React3__namespace.useState(null);
1653
+ const [linkAlso, setLinkAlso] = React3__namespace.useState(false);
1658
1654
  const navigate = React3__namespace.useCallback(
1659
1655
  async (account) => {
1660
1656
  if (resolveReturnTo) {
@@ -1674,12 +1670,7 @@ function OcSignIn({
1674
1670
  if (onSuccess) onSuccess(account, token);
1675
1671
  else void navigate(account);
1676
1672
  };
1677
- let declined = false;
1678
- try {
1679
- declined = Boolean(window.localStorage.getItem(LINK_PROMPT_DISMISS_KEY));
1680
- } catch {
1681
- }
1682
- if (!linkPrompt || declined) {
1673
+ if (!linkPrompt || !linkAlso) {
1683
1674
  proceed();
1684
1675
  return;
1685
1676
  }
@@ -1689,19 +1680,20 @@ function OcSignIn({
1689
1680
  headers: { Accept: "application/json" }
1690
1681
  });
1691
1682
  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 });
1683
+ const didOc = me?.account?.did_oc;
1684
+ if (didOc) {
1685
+ setSignedIn({
1686
+ method: via === "email" ? "btc" : "email",
1687
+ didOc,
1688
+ proceed
1689
+ });
1698
1690
  return;
1699
1691
  }
1700
1692
  } catch {
1701
1693
  }
1702
1694
  proceed();
1703
1695
  },
1704
- [onSuccess, linkPrompt, navigate, authOrigin]
1696
+ [onSuccess, linkPrompt, linkAlso, navigate, authOrigin]
1705
1697
  );
1706
1698
  if (!walletEnabled && !emailEnabled) {
1707
1699
  return /* @__PURE__ */ jsxRuntime.jsxs(
@@ -1742,6 +1734,7 @@ function OcSignIn({
1742
1734
  const showWallet = walletEnabled && (path === "wallet" || !emailEnabled);
1743
1735
  const showEmail = emailEnabled && (path === "email" || !walletEnabled);
1744
1736
  const bothEnabled = walletEnabled && emailEnabled;
1737
+ const activeMethod = !emailEnabled ? "wallet" : !walletEnabled ? "email" : path;
1745
1738
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className, "data-oc-signin": "", children: [
1746
1739
  bothEnabled && /* @__PURE__ */ jsxRuntime.jsxs(
1747
1740
  "div",
@@ -1784,6 +1777,24 @@ function OcSignIn({
1784
1777
  onSuccess: (a, t) => void handleSuccess(a, t, "email")
1785
1778
  }
1786
1779
  )
1780
+ ] }),
1781
+ linkPrompt && /* @__PURE__ */ jsxRuntime.jsxs("label", { "data-oc-signin-linkalso": "", style: linkAlsoStyle, children: [
1782
+ /* @__PURE__ */ jsxRuntime.jsx(
1783
+ "input",
1784
+ {
1785
+ type: "checkbox",
1786
+ checked: linkAlso,
1787
+ onChange: (e) => setLinkAlso(e.target.checked),
1788
+ style: { marginTop: 2, accentColor: "var(--primary, #f97316)" }
1789
+ }
1790
+ ),
1791
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
1792
+ "After signing in, also link",
1793
+ " ",
1794
+ activeMethod === "email" ? "a Bitcoin wallet" : "an email",
1795
+ " ",
1796
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: { opacity: 0.65 }, children: "\u2014 optional, one more signature." })
1797
+ ] })
1787
1798
  ] })
1788
1799
  ] });
1789
1800
  }
@@ -2135,6 +2146,19 @@ var inputStyle2 = {
2135
2146
  fontSize: 16,
2136
2147
  outline: "none"
2137
2148
  };
2149
+ var linkAlsoStyle = {
2150
+ display: "flex",
2151
+ alignItems: "flex-start",
2152
+ gap: 8,
2153
+ marginTop: 16,
2154
+ paddingTop: 14,
2155
+ borderTop: "1px solid var(--border, #27272a)",
2156
+ color: "var(--muted-foreground, #a1a1aa)",
2157
+ fontFamily: "ui-monospace, SFMono-Regular, monospace",
2158
+ fontSize: 12,
2159
+ lineHeight: 1.5,
2160
+ cursor: "pointer"
2161
+ };
2138
2162
  function submitStyle(disabled) {
2139
2163
  return {
2140
2164
  marginTop: 12,