@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.mjs
CHANGED
|
@@ -1064,6 +1064,48 @@ function AttestationLink() {
|
|
|
1064
1064
|
)
|
|
1065
1065
|
] });
|
|
1066
1066
|
}
|
|
1067
|
+
function LinkPromptStep({
|
|
1068
|
+
method,
|
|
1069
|
+
didOc,
|
|
1070
|
+
authOrigin,
|
|
1071
|
+
onResolved
|
|
1072
|
+
}) {
|
|
1073
|
+
const [stage, setStage] = React3.useState("offer");
|
|
1074
|
+
if (stage === "linking") {
|
|
1075
|
+
return method === "btc" ? /* @__PURE__ */ jsx(
|
|
1076
|
+
BtcLinkForm,
|
|
1077
|
+
{
|
|
1078
|
+
authOrigin,
|
|
1079
|
+
didOc,
|
|
1080
|
+
onDone: onResolved,
|
|
1081
|
+
onCancel: () => setStage("offer")
|
|
1082
|
+
}
|
|
1083
|
+
) : /* @__PURE__ */ jsx(
|
|
1084
|
+
EmailLinkForm,
|
|
1085
|
+
{
|
|
1086
|
+
authOrigin,
|
|
1087
|
+
onDone: onResolved,
|
|
1088
|
+
onCancel: () => setStage("offer")
|
|
1089
|
+
}
|
|
1090
|
+
);
|
|
1091
|
+
}
|
|
1092
|
+
return /* @__PURE__ */ jsxs("div", { style: panelStyle("accent"), "data-oc-linkprompt": method, children: [
|
|
1093
|
+
/* @__PURE__ */ jsx(SectionLabel, { tone: "success", children: "\xA7 signed in" }),
|
|
1094
|
+
/* @__PURE__ */ 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." }),
|
|
1095
|
+
/* @__PURE__ */ jsxs(FormButtons, { children: [
|
|
1096
|
+
/* @__PURE__ */ jsx(
|
|
1097
|
+
"button",
|
|
1098
|
+
{
|
|
1099
|
+
type: "button",
|
|
1100
|
+
onClick: () => setStage("linking"),
|
|
1101
|
+
style: primaryBtnStyle(false),
|
|
1102
|
+
children: method === "btc" ? "link a Bitcoin address" : "link an email"
|
|
1103
|
+
}
|
|
1104
|
+
),
|
|
1105
|
+
/* @__PURE__ */ jsx("button", { type: "button", onClick: onResolved, style: ghostBtnStyle(false), children: "skip" })
|
|
1106
|
+
] })
|
|
1107
|
+
] });
|
|
1108
|
+
}
|
|
1067
1109
|
function EmailLinkForm({
|
|
1068
1110
|
authOrigin,
|
|
1069
1111
|
onDone,
|
|
@@ -1572,7 +1614,7 @@ function OcSignIn({
|
|
|
1572
1614
|
returnTo,
|
|
1573
1615
|
onSuccess,
|
|
1574
1616
|
resolveReturnTo,
|
|
1575
|
-
linkPrompt,
|
|
1617
|
+
linkPrompt = true,
|
|
1576
1618
|
authOrigin = "https://ochk.io",
|
|
1577
1619
|
initialPath = "wallet",
|
|
1578
1620
|
paths,
|
|
@@ -1597,18 +1639,34 @@ function OcSignIn({
|
|
|
1597
1639
|
[resolveReturnTo, safeReturn]
|
|
1598
1640
|
);
|
|
1599
1641
|
const handleSuccess = React3.useCallback(
|
|
1600
|
-
async (account, token) => {
|
|
1601
|
-
|
|
1602
|
-
onSuccess(account, token);
|
|
1642
|
+
async (account, token, via) => {
|
|
1643
|
+
const proceed = () => {
|
|
1644
|
+
if (onSuccess) onSuccess(account, token);
|
|
1645
|
+
else void navigate(account);
|
|
1646
|
+
};
|
|
1647
|
+
if (!linkPrompt) {
|
|
1648
|
+
proceed();
|
|
1603
1649
|
return;
|
|
1604
1650
|
}
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1651
|
+
try {
|
|
1652
|
+
const meRes = await fetch(`${authOrigin}/api/auth/me`, {
|
|
1653
|
+
credentials: "include",
|
|
1654
|
+
headers: { Accept: "application/json" }
|
|
1655
|
+
});
|
|
1656
|
+
const me = meRes.ok ? await meRes.json() : null;
|
|
1657
|
+
const acct = me?.account;
|
|
1658
|
+
const didOc = acct?.did_oc;
|
|
1659
|
+
const complementary = via === "email" ? "btc" : "email";
|
|
1660
|
+
const alreadyLinked = complementary === "btc" ? Boolean(acct?.primary_btc) : Boolean(acct?.has_email);
|
|
1661
|
+
if (didOc && !alreadyLinked) {
|
|
1662
|
+
setSignedIn({ method: complementary, didOc, proceed });
|
|
1663
|
+
return;
|
|
1664
|
+
}
|
|
1665
|
+
} catch {
|
|
1608
1666
|
}
|
|
1609
|
-
|
|
1667
|
+
proceed();
|
|
1610
1668
|
},
|
|
1611
|
-
[onSuccess, linkPrompt, navigate]
|
|
1669
|
+
[onSuccess, linkPrompt, navigate, authOrigin]
|
|
1612
1670
|
);
|
|
1613
1671
|
if (!walletEnabled && !emailEnabled) {
|
|
1614
1672
|
return /* @__PURE__ */ jsxs(
|
|
@@ -1639,8 +1697,10 @@ function OcSignIn({
|
|
|
1639
1697
|
return /* @__PURE__ */ jsx("div", { className, "data-oc-signin": "", children: /* @__PURE__ */ jsx(
|
|
1640
1698
|
LinkPromptStep,
|
|
1641
1699
|
{
|
|
1700
|
+
method: signedIn.method,
|
|
1701
|
+
didOc: signedIn.didOc,
|
|
1642
1702
|
authOrigin,
|
|
1643
|
-
|
|
1703
|
+
onResolved: signedIn.proceed
|
|
1644
1704
|
}
|
|
1645
1705
|
) });
|
|
1646
1706
|
}
|
|
@@ -1679,32 +1739,19 @@ function OcSignIn({
|
|
|
1679
1739
|
{
|
|
1680
1740
|
authOrigin,
|
|
1681
1741
|
audience,
|
|
1682
|
-
onSuccess: handleSuccess
|
|
1742
|
+
onSuccess: (a, t) => void handleSuccess(a, t, "wallet")
|
|
1683
1743
|
}
|
|
1684
1744
|
),
|
|
1685
|
-
showEmail && /* @__PURE__ */ jsx(
|
|
1745
|
+
showEmail && /* @__PURE__ */ jsx(
|
|
1746
|
+
EmailFlow,
|
|
1747
|
+
{
|
|
1748
|
+
authOrigin,
|
|
1749
|
+
onSuccess: (a, t) => void handleSuccess(a, t, "email")
|
|
1750
|
+
}
|
|
1751
|
+
)
|
|
1686
1752
|
] })
|
|
1687
1753
|
] });
|
|
1688
1754
|
}
|
|
1689
|
-
function LinkPromptStep({
|
|
1690
|
-
authOrigin,
|
|
1691
|
-
onContinue
|
|
1692
|
-
}) {
|
|
1693
|
-
return /* @__PURE__ */ jsxs("div", { "data-oc-signin-linkprompt": "", children: [
|
|
1694
|
-
/* @__PURE__ */ 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." }),
|
|
1695
|
-
/* @__PURE__ */ jsx(OcLinkedIdentities, { authOrigin }),
|
|
1696
|
-
/* @__PURE__ */ jsx(
|
|
1697
|
-
"button",
|
|
1698
|
-
{
|
|
1699
|
-
type: "button",
|
|
1700
|
-
onClick: onContinue,
|
|
1701
|
-
style: submitStyle(false),
|
|
1702
|
-
"data-oc-signin-continue": "",
|
|
1703
|
-
children: "continue \u2192"
|
|
1704
|
-
}
|
|
1705
|
-
)
|
|
1706
|
-
] });
|
|
1707
|
-
}
|
|
1708
1755
|
function SigninTab({
|
|
1709
1756
|
active,
|
|
1710
1757
|
onClick,
|