@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.js
CHANGED
|
@@ -70,6 +70,20 @@ function normalizeRosterEntry(raw) {
|
|
|
70
70
|
lastSeenAt: raw.last_seen_at ?? raw.lastSeenAt ?? null
|
|
71
71
|
};
|
|
72
72
|
}
|
|
73
|
+
async function fetchHostRoster(cfg) {
|
|
74
|
+
try {
|
|
75
|
+
const res = await fetch(`${cfg.authOrigin}${cfg.mePath}`, {
|
|
76
|
+
method: "GET",
|
|
77
|
+
credentials: "include",
|
|
78
|
+
headers: { Accept: "application/json" }
|
|
79
|
+
});
|
|
80
|
+
if (!res.ok) return [];
|
|
81
|
+
const body = await res.json();
|
|
82
|
+
return Array.isArray(body.roster) ? body.roster.map(normalizeRosterEntry).filter((r) => r !== null) : [];
|
|
83
|
+
} catch {
|
|
84
|
+
return [];
|
|
85
|
+
}
|
|
86
|
+
}
|
|
73
87
|
function normalizeAccount(raw) {
|
|
74
88
|
if (!raw) return null;
|
|
75
89
|
const didOc = raw.did_oc ?? raw.didOc;
|
|
@@ -125,11 +139,16 @@ function OcSessionProvider({
|
|
|
125
139
|
setRoster(rosterEntries);
|
|
126
140
|
setStatus(acct ? "authenticated" : "anonymous");
|
|
127
141
|
setError(null);
|
|
142
|
+
const currentOrigin = typeof window !== "undefined" ? window.location.origin : null;
|
|
143
|
+
if (acct && rosterEntries.length === 0 && currentOrigin !== null && !cfg.authOrigin.startsWith(currentOrigin)) {
|
|
144
|
+
const peers = await fetchHostRoster(cfg);
|
|
145
|
+
if (peers.length > 0) setRoster(peers);
|
|
146
|
+
}
|
|
128
147
|
} catch (err) {
|
|
129
148
|
setStatus("error");
|
|
130
149
|
setError(err instanceof Error ? err : new Error(String(err)));
|
|
131
150
|
}
|
|
132
|
-
}, [cfg
|
|
151
|
+
}, [cfg]);
|
|
133
152
|
React3__namespace.useEffect(() => {
|
|
134
153
|
void refresh();
|
|
135
154
|
}, [refresh]);
|
|
@@ -1894,6 +1913,41 @@ function OcSignIn({
|
|
|
1894
1913
|
children: "That sign-in didn't complete. Please try again."
|
|
1895
1914
|
}
|
|
1896
1915
|
),
|
|
1916
|
+
addMode && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1917
|
+
"div",
|
|
1918
|
+
{
|
|
1919
|
+
"data-oc-signin-add-mode": "",
|
|
1920
|
+
style: {
|
|
1921
|
+
marginBottom: 14,
|
|
1922
|
+
padding: "0.6rem 0.75rem",
|
|
1923
|
+
border: "1px solid var(--primary, #f97316)",
|
|
1924
|
+
borderLeftWidth: 3,
|
|
1925
|
+
borderRadius: 4,
|
|
1926
|
+
background: "color-mix(in srgb, var(--primary, #f97316) 8%, transparent)",
|
|
1927
|
+
color: "var(--foreground, #fafafa)",
|
|
1928
|
+
fontFamily: "ui-monospace, SFMono-Regular, monospace",
|
|
1929
|
+
fontSize: 11,
|
|
1930
|
+
lineHeight: 1.6
|
|
1931
|
+
},
|
|
1932
|
+
children: [
|
|
1933
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1934
|
+
"strong",
|
|
1935
|
+
{
|
|
1936
|
+
style: {
|
|
1937
|
+
color: "var(--primary, #f97316)",
|
|
1938
|
+
letterSpacing: "0.12em",
|
|
1939
|
+
textTransform: "uppercase",
|
|
1940
|
+
fontSize: 10,
|
|
1941
|
+
display: "block",
|
|
1942
|
+
marginBottom: 3
|
|
1943
|
+
},
|
|
1944
|
+
children: "\xA7 adding another account"
|
|
1945
|
+
}
|
|
1946
|
+
),
|
|
1947
|
+
"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."
|
|
1948
|
+
]
|
|
1949
|
+
}
|
|
1950
|
+
),
|
|
1897
1951
|
bothEnabled && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1898
1952
|
"div",
|
|
1899
1953
|
{
|