@orangecheck/auth-client 2.8.0 → 2.9.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 +78 -31
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +78 -31
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1086,6 +1086,48 @@ function AttestationLink() {
|
|
|
1086
1086
|
)
|
|
1087
1087
|
] });
|
|
1088
1088
|
}
|
|
1089
|
+
function LinkPromptStep({
|
|
1090
|
+
method,
|
|
1091
|
+
didOc,
|
|
1092
|
+
authOrigin,
|
|
1093
|
+
onResolved
|
|
1094
|
+
}) {
|
|
1095
|
+
const [stage, setStage] = React3__namespace.useState("offer");
|
|
1096
|
+
if (stage === "linking") {
|
|
1097
|
+
return method === "btc" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1098
|
+
BtcLinkForm,
|
|
1099
|
+
{
|
|
1100
|
+
authOrigin,
|
|
1101
|
+
didOc,
|
|
1102
|
+
onDone: onResolved,
|
|
1103
|
+
onCancel: () => setStage("offer")
|
|
1104
|
+
}
|
|
1105
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
1106
|
+
EmailLinkForm,
|
|
1107
|
+
{
|
|
1108
|
+
authOrigin,
|
|
1109
|
+
onDone: onResolved,
|
|
1110
|
+
onCancel: () => setStage("offer")
|
|
1111
|
+
}
|
|
1112
|
+
);
|
|
1113
|
+
}
|
|
1114
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: panelStyle("accent"), "data-oc-linkprompt": method, children: [
|
|
1115
|
+
/* @__PURE__ */ jsxRuntime.jsx(SectionLabel, { tone: "success", children: "\xA7 signed in" }),
|
|
1116
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { style: bodyStyle, children: method === "btc" ? "You're in. Link a Bitcoin address now \u2014 a second way to sign in, and it unlocks your on-chain footprint. You prove it with one wallet signature, right here \u2014 no separate trip to your account page." : "You're in. Add your email now \u2014 a backup way to sign in if you ever lose your wallet. You prove it with a one-time code, right here \u2014 no separate trip to your account page." }),
|
|
1117
|
+
/* @__PURE__ */ jsxRuntime.jsxs(FormButtons, { children: [
|
|
1118
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1119
|
+
"button",
|
|
1120
|
+
{
|
|
1121
|
+
type: "button",
|
|
1122
|
+
onClick: () => setStage("linking"),
|
|
1123
|
+
style: primaryBtnStyle(false),
|
|
1124
|
+
children: method === "btc" ? "link a Bitcoin address" : "link an email"
|
|
1125
|
+
}
|
|
1126
|
+
),
|
|
1127
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: onResolved, style: ghostBtnStyle(false), children: "skip" })
|
|
1128
|
+
] })
|
|
1129
|
+
] });
|
|
1130
|
+
}
|
|
1089
1131
|
function EmailLinkForm({
|
|
1090
1132
|
authOrigin,
|
|
1091
1133
|
onDone,
|
|
@@ -1594,7 +1636,7 @@ function OcSignIn({
|
|
|
1594
1636
|
returnTo,
|
|
1595
1637
|
onSuccess,
|
|
1596
1638
|
resolveReturnTo,
|
|
1597
|
-
linkPrompt,
|
|
1639
|
+
linkPrompt = true,
|
|
1598
1640
|
authOrigin = "https://ochk.io",
|
|
1599
1641
|
initialPath = "wallet",
|
|
1600
1642
|
paths,
|
|
@@ -1619,18 +1661,34 @@ function OcSignIn({
|
|
|
1619
1661
|
[resolveReturnTo, safeReturn]
|
|
1620
1662
|
);
|
|
1621
1663
|
const handleSuccess = React3__namespace.useCallback(
|
|
1622
|
-
async (account, token) => {
|
|
1623
|
-
|
|
1624
|
-
onSuccess(account, token);
|
|
1664
|
+
async (account, token, via) => {
|
|
1665
|
+
const proceed = () => {
|
|
1666
|
+
if (onSuccess) onSuccess(account, token);
|
|
1667
|
+
else void navigate(account);
|
|
1668
|
+
};
|
|
1669
|
+
if (!linkPrompt) {
|
|
1670
|
+
proceed();
|
|
1625
1671
|
return;
|
|
1626
1672
|
}
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1673
|
+
try {
|
|
1674
|
+
const meRes = await fetch(`${authOrigin}/api/auth/me`, {
|
|
1675
|
+
credentials: "include",
|
|
1676
|
+
headers: { Accept: "application/json" }
|
|
1677
|
+
});
|
|
1678
|
+
const me = meRes.ok ? await meRes.json() : null;
|
|
1679
|
+
const acct = me?.account;
|
|
1680
|
+
const didOc = acct?.did_oc;
|
|
1681
|
+
const complementary = via === "email" ? "btc" : "email";
|
|
1682
|
+
const alreadyLinked = complementary === "btc" ? Boolean(acct?.primary_btc) : Boolean(acct?.has_email);
|
|
1683
|
+
if (didOc && !alreadyLinked) {
|
|
1684
|
+
setSignedIn({ method: complementary, didOc, proceed });
|
|
1685
|
+
return;
|
|
1686
|
+
}
|
|
1687
|
+
} catch {
|
|
1630
1688
|
}
|
|
1631
|
-
|
|
1689
|
+
proceed();
|
|
1632
1690
|
},
|
|
1633
|
-
[onSuccess, linkPrompt, navigate]
|
|
1691
|
+
[onSuccess, linkPrompt, navigate, authOrigin]
|
|
1634
1692
|
);
|
|
1635
1693
|
if (!walletEnabled && !emailEnabled) {
|
|
1636
1694
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -1661,8 +1719,10 @@ function OcSignIn({
|
|
|
1661
1719
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className, "data-oc-signin": "", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1662
1720
|
LinkPromptStep,
|
|
1663
1721
|
{
|
|
1722
|
+
method: signedIn.method,
|
|
1723
|
+
didOc: signedIn.didOc,
|
|
1664
1724
|
authOrigin,
|
|
1665
|
-
|
|
1725
|
+
onResolved: signedIn.proceed
|
|
1666
1726
|
}
|
|
1667
1727
|
) });
|
|
1668
1728
|
}
|
|
@@ -1701,32 +1761,19 @@ function OcSignIn({
|
|
|
1701
1761
|
{
|
|
1702
1762
|
authOrigin,
|
|
1703
1763
|
audience,
|
|
1704
|
-
onSuccess: handleSuccess
|
|
1764
|
+
onSuccess: (a, t) => void handleSuccess(a, t, "wallet")
|
|
1705
1765
|
}
|
|
1706
1766
|
),
|
|
1707
|
-
showEmail && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1767
|
+
showEmail && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1768
|
+
EmailFlow,
|
|
1769
|
+
{
|
|
1770
|
+
authOrigin,
|
|
1771
|
+
onSuccess: (a, t) => void handleSuccess(a, t, "email")
|
|
1772
|
+
}
|
|
1773
|
+
)
|
|
1708
1774
|
] })
|
|
1709
1775
|
] });
|
|
1710
1776
|
}
|
|
1711
|
-
function LinkPromptStep({
|
|
1712
|
-
authOrigin,
|
|
1713
|
-
onContinue
|
|
1714
|
-
}) {
|
|
1715
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-oc-signin-linkprompt": "", children: [
|
|
1716
|
-
/* @__PURE__ */ jsxRuntime.jsx(FlowHeader, { label: "\xA7 signed in \xB7 add a backup", children: "You're in. Linking a second way to sign in \u2014 your email or your Bitcoin wallet \u2014 is also your recovery path: lose one, the other still gets you in. Optional; skip with continue." }),
|
|
1717
|
-
/* @__PURE__ */ jsxRuntime.jsx(OcLinkedIdentities, { authOrigin }),
|
|
1718
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1719
|
-
"button",
|
|
1720
|
-
{
|
|
1721
|
-
type: "button",
|
|
1722
|
-
onClick: onContinue,
|
|
1723
|
-
style: submitStyle(false),
|
|
1724
|
-
"data-oc-signin-continue": "",
|
|
1725
|
-
children: "continue \u2192"
|
|
1726
|
-
}
|
|
1727
|
-
)
|
|
1728
|
-
] });
|
|
1729
|
-
}
|
|
1730
1777
|
function SigninTab({
|
|
1731
1778
|
active,
|
|
1732
1779
|
onClick,
|