@orangecheck/auth-client 2.17.0 → 2.17.2
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 +55 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +55 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -48,6 +48,20 @@ function normalizeRosterEntry(raw) {
|
|
|
48
48
|
lastSeenAt: raw.last_seen_at ?? raw.lastSeenAt ?? null
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
|
+
async function fetchHostRoster(cfg) {
|
|
52
|
+
try {
|
|
53
|
+
const res = await fetch(`${cfg.authOrigin}${cfg.mePath}`, {
|
|
54
|
+
method: "GET",
|
|
55
|
+
credentials: "include",
|
|
56
|
+
headers: { Accept: "application/json" }
|
|
57
|
+
});
|
|
58
|
+
if (!res.ok) return [];
|
|
59
|
+
const body = await res.json();
|
|
60
|
+
return Array.isArray(body.roster) ? body.roster.map(normalizeRosterEntry).filter((r) => r !== null) : [];
|
|
61
|
+
} catch {
|
|
62
|
+
return [];
|
|
63
|
+
}
|
|
64
|
+
}
|
|
51
65
|
function normalizeAccount(raw) {
|
|
52
66
|
if (!raw) return null;
|
|
53
67
|
const didOc = raw.did_oc ?? raw.didOc;
|
|
@@ -103,11 +117,16 @@ function OcSessionProvider({
|
|
|
103
117
|
setRoster(rosterEntries);
|
|
104
118
|
setStatus(acct ? "authenticated" : "anonymous");
|
|
105
119
|
setError(null);
|
|
120
|
+
const currentOrigin = typeof window !== "undefined" ? window.location.origin : null;
|
|
121
|
+
if (acct && rosterEntries.length === 0 && currentOrigin !== null && !cfg.authOrigin.startsWith(currentOrigin)) {
|
|
122
|
+
const peers = await fetchHostRoster(cfg);
|
|
123
|
+
if (peers.length > 0) setRoster(peers);
|
|
124
|
+
}
|
|
106
125
|
} catch (err) {
|
|
107
126
|
setStatus("error");
|
|
108
127
|
setError(err instanceof Error ? err : new Error(String(err)));
|
|
109
128
|
}
|
|
110
|
-
}, [cfg
|
|
129
|
+
}, [cfg]);
|
|
111
130
|
React3.useEffect(() => {
|
|
112
131
|
void refresh();
|
|
113
132
|
}, [refresh]);
|
|
@@ -1872,6 +1891,41 @@ function OcSignIn({
|
|
|
1872
1891
|
children: "That sign-in didn't complete. Please try again."
|
|
1873
1892
|
}
|
|
1874
1893
|
),
|
|
1894
|
+
addMode && /* @__PURE__ */ jsxs(
|
|
1895
|
+
"div",
|
|
1896
|
+
{
|
|
1897
|
+
"data-oc-signin-add-mode": "",
|
|
1898
|
+
style: {
|
|
1899
|
+
marginBottom: 14,
|
|
1900
|
+
padding: "0.6rem 0.75rem",
|
|
1901
|
+
border: "1px solid var(--primary, #f97316)",
|
|
1902
|
+
borderLeftWidth: 3,
|
|
1903
|
+
borderRadius: 4,
|
|
1904
|
+
background: "color-mix(in srgb, var(--primary, #f97316) 8%, transparent)",
|
|
1905
|
+
color: "var(--foreground, #fafafa)",
|
|
1906
|
+
fontFamily: "ui-monospace, SFMono-Regular, monospace",
|
|
1907
|
+
fontSize: 11,
|
|
1908
|
+
lineHeight: 1.6
|
|
1909
|
+
},
|
|
1910
|
+
children: [
|
|
1911
|
+
/* @__PURE__ */ jsx(
|
|
1912
|
+
"strong",
|
|
1913
|
+
{
|
|
1914
|
+
style: {
|
|
1915
|
+
color: "var(--primary, #f97316)",
|
|
1916
|
+
letterSpacing: "0.12em",
|
|
1917
|
+
textTransform: "uppercase",
|
|
1918
|
+
fontSize: 10,
|
|
1919
|
+
display: "block",
|
|
1920
|
+
marginBottom: 3
|
|
1921
|
+
},
|
|
1922
|
+
children: "\xA7 adding another account"
|
|
1923
|
+
}
|
|
1924
|
+
),
|
|
1925
|
+
"Your current OrangeCheck account stays signed in. The new account joins your browser's roster; you can switch between them anytime from the account menu."
|
|
1926
|
+
]
|
|
1927
|
+
}
|
|
1928
|
+
),
|
|
1875
1929
|
bothEnabled && /* @__PURE__ */ jsxs(
|
|
1876
1930
|
"div",
|
|
1877
1931
|
{
|