@orangecheck/auth-client 2.26.0 → 2.28.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.d.mts +11 -2
- package/dist/index.d.ts +11 -2
- package/dist/index.js +145 -94
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +145 -94
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -47,6 +47,7 @@ interface OcAuthConfig {
|
|
|
47
47
|
signInPath?: string;
|
|
48
48
|
mePath?: string;
|
|
49
49
|
logoutPath?: string;
|
|
50
|
+
multiAccount?: boolean;
|
|
50
51
|
}
|
|
51
52
|
declare const DEFAULT_CONFIG: Required<OcAuthConfig>;
|
|
52
53
|
declare function buildSignInUrl(cfg: Required<OcAuthConfig>, returnTo?: string): string;
|
|
@@ -118,7 +119,7 @@ interface UseOcAddressSuggestionReturn {
|
|
|
118
119
|
declare function useOcAddressSuggestion(options: UseOcAddressSuggestionOptions): UseOcAddressSuggestionReturn;
|
|
119
120
|
declare const OcAddressInput: React.ForwardRefExoticComponent<OcAddressInputProps & React.RefAttributes<HTMLInputElement>>;
|
|
120
121
|
|
|
121
|
-
interface
|
|
122
|
+
interface OcSignInBaseProps {
|
|
122
123
|
audience: string;
|
|
123
124
|
returnTo?: string;
|
|
124
125
|
onSuccess?: (account: OcAccount, token?: string) => void;
|
|
@@ -134,9 +135,17 @@ interface OcSignInProps {
|
|
|
134
135
|
add?: boolean;
|
|
135
136
|
className?: string;
|
|
136
137
|
}
|
|
138
|
+
type OcSignInProps = OcSignInBaseProps & ({
|
|
139
|
+
mode?: 'family';
|
|
140
|
+
providerHref?: undefined;
|
|
141
|
+
} | {
|
|
142
|
+
mode: 'first-party';
|
|
143
|
+
onSuccess: (account: OcAccount, token?: string) => void;
|
|
144
|
+
providerHref?: (providerId: string) => string;
|
|
145
|
+
});
|
|
137
146
|
declare function safeReturnTo(input: string | undefined): string;
|
|
138
147
|
declare function familyReturnTarget(input: string | undefined | null): string | undefined;
|
|
139
|
-
declare function OcSignIn({ audience, returnTo, onSuccess, resolveReturnTo, linkPrompt, add: addProp, authOrigin, initialPath, providersFirst, paths, className, }: OcSignInProps): React.ReactElement;
|
|
148
|
+
declare function OcSignIn({ audience, returnTo, onSuccess, resolveReturnTo, linkPrompt: linkPromptProp, add: addProp, authOrigin, initialPath, providersFirst, paths, className, mode, providerHref, }: OcSignInProps): React.ReactElement;
|
|
140
149
|
|
|
141
150
|
interface OcLinkedIdentity {
|
|
142
151
|
id: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -47,6 +47,7 @@ interface OcAuthConfig {
|
|
|
47
47
|
signInPath?: string;
|
|
48
48
|
mePath?: string;
|
|
49
49
|
logoutPath?: string;
|
|
50
|
+
multiAccount?: boolean;
|
|
50
51
|
}
|
|
51
52
|
declare const DEFAULT_CONFIG: Required<OcAuthConfig>;
|
|
52
53
|
declare function buildSignInUrl(cfg: Required<OcAuthConfig>, returnTo?: string): string;
|
|
@@ -118,7 +119,7 @@ interface UseOcAddressSuggestionReturn {
|
|
|
118
119
|
declare function useOcAddressSuggestion(options: UseOcAddressSuggestionOptions): UseOcAddressSuggestionReturn;
|
|
119
120
|
declare const OcAddressInput: React.ForwardRefExoticComponent<OcAddressInputProps & React.RefAttributes<HTMLInputElement>>;
|
|
120
121
|
|
|
121
|
-
interface
|
|
122
|
+
interface OcSignInBaseProps {
|
|
122
123
|
audience: string;
|
|
123
124
|
returnTo?: string;
|
|
124
125
|
onSuccess?: (account: OcAccount, token?: string) => void;
|
|
@@ -134,9 +135,17 @@ interface OcSignInProps {
|
|
|
134
135
|
add?: boolean;
|
|
135
136
|
className?: string;
|
|
136
137
|
}
|
|
138
|
+
type OcSignInProps = OcSignInBaseProps & ({
|
|
139
|
+
mode?: 'family';
|
|
140
|
+
providerHref?: undefined;
|
|
141
|
+
} | {
|
|
142
|
+
mode: 'first-party';
|
|
143
|
+
onSuccess: (account: OcAccount, token?: string) => void;
|
|
144
|
+
providerHref?: (providerId: string) => string;
|
|
145
|
+
});
|
|
137
146
|
declare function safeReturnTo(input: string | undefined): string;
|
|
138
147
|
declare function familyReturnTarget(input: string | undefined | null): string | undefined;
|
|
139
|
-
declare function OcSignIn({ audience, returnTo, onSuccess, resolveReturnTo, linkPrompt, add: addProp, authOrigin, initialPath, providersFirst, paths, className, }: OcSignInProps): React.ReactElement;
|
|
148
|
+
declare function OcSignIn({ audience, returnTo, onSuccess, resolveReturnTo, linkPrompt: linkPromptProp, add: addProp, authOrigin, initialPath, providersFirst, paths, className, mode, providerHref, }: OcSignInProps): React.ReactElement;
|
|
140
149
|
|
|
141
150
|
interface OcLinkedIdentity {
|
|
142
151
|
id: string;
|
package/dist/index.js
CHANGED
|
@@ -32,7 +32,8 @@ var DEFAULT_CONFIG = {
|
|
|
32
32
|
authOrigin: "https://ochk.io",
|
|
33
33
|
signInPath: "/signin",
|
|
34
34
|
mePath: "/api/auth/me",
|
|
35
|
-
logoutPath: "/api/auth/logout"
|
|
35
|
+
logoutPath: "/api/auth/logout",
|
|
36
|
+
multiAccount: true
|
|
36
37
|
};
|
|
37
38
|
function resolveConfig(cfg) {
|
|
38
39
|
return { ...DEFAULT_CONFIG, ...cfg ?? {} };
|
|
@@ -288,7 +289,7 @@ function OcSessionProvider({
|
|
|
288
289
|
const pinInFlightRef = React4__namespace.useRef(false);
|
|
289
290
|
const pinThisTab = React4__namespace.useCallback(
|
|
290
291
|
async (didOc) => {
|
|
291
|
-
if (pinInFlightRef.current || readTabSession()) return;
|
|
292
|
+
if (!cfg.multiAccount || pinInFlightRef.current || readTabSession()) return;
|
|
292
293
|
pinInFlightRef.current = true;
|
|
293
294
|
try {
|
|
294
295
|
const res = await fetch(`${cfg.authOrigin}/api/auth/tab`, {
|
|
@@ -307,7 +308,7 @@ function OcSessionProvider({
|
|
|
307
308
|
pinInFlightRef.current = false;
|
|
308
309
|
}
|
|
309
310
|
},
|
|
310
|
-
[cfg.authOrigin]
|
|
311
|
+
[cfg.authOrigin, cfg.multiAccount]
|
|
311
312
|
);
|
|
312
313
|
const refresh = React4__namespace.useCallback(async () => {
|
|
313
314
|
if (typeof window === "undefined") return;
|
|
@@ -354,7 +355,7 @@ function OcSessionProvider({
|
|
|
354
355
|
setError(null);
|
|
355
356
|
if (acct && !pin) void pinThisTab(acct.didOc);
|
|
356
357
|
const currentOrigin = typeof window !== "undefined" ? window.location.origin : null;
|
|
357
|
-
if (acct && rosterEntries.length === 0 && currentOrigin !== null && !cfg.authOrigin.startsWith(currentOrigin)) {
|
|
358
|
+
if (cfg.multiAccount && acct && rosterEntries.length === 0 && currentOrigin !== null && !cfg.authOrigin.startsWith(currentOrigin)) {
|
|
358
359
|
const peers = await fetchHostRoster(cfg);
|
|
359
360
|
if (peers.length > 0) setRoster(peers);
|
|
360
361
|
}
|
|
@@ -367,15 +368,21 @@ function OcSessionProvider({
|
|
|
367
368
|
let cancelled = false;
|
|
368
369
|
consumeTabAdoptMarker();
|
|
369
370
|
void (async () => {
|
|
370
|
-
await consumeTabAccountHint(cfg.authOrigin);
|
|
371
|
+
if (cfg.multiAccount) await consumeTabAccountHint(cfg.authOrigin);
|
|
371
372
|
if (!cancelled) void refresh();
|
|
372
373
|
})();
|
|
373
374
|
return () => {
|
|
374
375
|
cancelled = true;
|
|
375
376
|
};
|
|
376
|
-
}, [refresh, cfg.authOrigin]);
|
|
377
|
-
React4__namespace.useEffect(
|
|
378
|
-
|
|
377
|
+
}, [refresh, cfg.authOrigin, cfg.multiAccount]);
|
|
378
|
+
React4__namespace.useEffect(
|
|
379
|
+
() => cfg.multiAccount ? installTabFetchInterceptor(cfg.authOrigin) : void 0,
|
|
380
|
+
[cfg.authOrigin, cfg.multiAccount]
|
|
381
|
+
);
|
|
382
|
+
React4__namespace.useEffect(
|
|
383
|
+
() => cfg.multiAccount ? installTabLinkDecorator(cfg.authOrigin) : void 0,
|
|
384
|
+
[cfg.authOrigin, cfg.multiAccount]
|
|
385
|
+
);
|
|
379
386
|
const signOut = React4__namespace.useCallback(
|
|
380
387
|
async (opts) => {
|
|
381
388
|
const scope = opts?.scope ?? "all";
|
|
@@ -1180,6 +1187,15 @@ var SUDO_ACCOUNT_MISMATCH_MESSAGE = "Switch this tab to that account first \u201
|
|
|
1180
1187
|
function isSudoAccountMismatch(body) {
|
|
1181
1188
|
return body?.reason === "sudo_account_mismatch";
|
|
1182
1189
|
}
|
|
1190
|
+
|
|
1191
|
+
// src/appearance.ts
|
|
1192
|
+
var SIGNIN_FONT = "var(--oc-signin-font, ui-monospace, SFMono-Regular, monospace)";
|
|
1193
|
+
var SIGNIN_CASE = "var(--oc-signin-case, uppercase)";
|
|
1194
|
+
var signinTracking = (em) => `var(--oc-signin-tracking, ${em})`;
|
|
1195
|
+
var signinSize = (px) => `calc(${px}px * var(--oc-signin-scale, 1))`;
|
|
1196
|
+
var signinRadius = (px) => `var(--oc-signin-radius, ${px}px)`;
|
|
1197
|
+
var SIGNIN_BUTTON_RADIUS = "var(--oc-signin-button-radius, 6px)";
|
|
1198
|
+
var SIGNIN_STRONG = "var(--oc-signin-strong, 600)";
|
|
1183
1199
|
var DEFAULT_AUTH_ORIGIN = "https://ochk.io";
|
|
1184
1200
|
async function fetchOcLinkedIdentities(opts) {
|
|
1185
1201
|
const authOrigin = opts?.authOrigin ?? DEFAULT_AUTH_ORIGIN;
|
|
@@ -1394,8 +1410,8 @@ function IdentityRow({
|
|
|
1394
1410
|
style: {
|
|
1395
1411
|
marginTop: 4,
|
|
1396
1412
|
color: V.foreground,
|
|
1397
|
-
fontFamily:
|
|
1398
|
-
fontSize: 12,
|
|
1413
|
+
fontFamily: SIGNIN_FONT,
|
|
1414
|
+
fontSize: signinSize(12),
|
|
1399
1415
|
wordBreak: "break-all"
|
|
1400
1416
|
},
|
|
1401
1417
|
children: display
|
|
@@ -1473,8 +1489,8 @@ function ConsolidationPanel({ entries }) {
|
|
|
1473
1489
|
gap: 8,
|
|
1474
1490
|
padding: "8px 0",
|
|
1475
1491
|
borderTop: `1px solid ${V.border}`,
|
|
1476
|
-
fontFamily:
|
|
1477
|
-
fontSize: 11
|
|
1492
|
+
fontFamily: SIGNIN_FONT,
|
|
1493
|
+
fontSize: signinSize(11)
|
|
1478
1494
|
},
|
|
1479
1495
|
children: [
|
|
1480
1496
|
/* @__PURE__ */ jsxRuntime.jsx("code", { style: { color: V.foreground, wordBreak: "break-all" }, children: e.did_oc }),
|
|
@@ -1777,7 +1793,7 @@ function BtcLinkForm({
|
|
|
1777
1793
|
placeholder: "bc1q\u2026",
|
|
1778
1794
|
autoCapitalize: "none",
|
|
1779
1795
|
spellCheck: false,
|
|
1780
|
-
style: { ...inputStyle, fontFamily:
|
|
1796
|
+
style: { ...inputStyle, fontFamily: SIGNIN_FONT }
|
|
1781
1797
|
}
|
|
1782
1798
|
),
|
|
1783
1799
|
err && /* @__PURE__ */ jsxRuntime.jsx(ErrorLine, { children: err }),
|
|
@@ -1807,7 +1823,7 @@ function BtcLinkForm({
|
|
|
1807
1823
|
/* @__PURE__ */ jsxRuntime.jsxs("p", { style: bodyStyle, children: [
|
|
1808
1824
|
"Sign the challenge with the wallet that controls",
|
|
1809
1825
|
" ",
|
|
1810
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontFamily:
|
|
1826
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontFamily: SIGNIN_FONT, wordBreak: "break-all" }, children: addr }),
|
|
1811
1827
|
"."
|
|
1812
1828
|
] }),
|
|
1813
1829
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1915,10 +1931,10 @@ function SectionLabel({
|
|
|
1915
1931
|
{
|
|
1916
1932
|
style: {
|
|
1917
1933
|
color,
|
|
1918
|
-
fontFamily:
|
|
1919
|
-
fontSize: 10,
|
|
1920
|
-
letterSpacing: "0.18em",
|
|
1921
|
-
textTransform:
|
|
1934
|
+
fontFamily: SIGNIN_FONT,
|
|
1935
|
+
fontSize: signinSize(10),
|
|
1936
|
+
letterSpacing: signinTracking("0.18em"),
|
|
1937
|
+
textTransform: SIGNIN_CASE,
|
|
1922
1938
|
marginBottom: 8
|
|
1923
1939
|
},
|
|
1924
1940
|
children
|
|
@@ -1933,8 +1949,8 @@ function ErrorLine({ children }) {
|
|
|
1933
1949
|
style: {
|
|
1934
1950
|
margin: "8px 0 0",
|
|
1935
1951
|
color: V.destructive,
|
|
1936
|
-
fontFamily:
|
|
1937
|
-
fontSize: 11
|
|
1952
|
+
fontFamily: SIGNIN_FONT,
|
|
1953
|
+
fontSize: signinSize(11)
|
|
1938
1954
|
},
|
|
1939
1955
|
children
|
|
1940
1956
|
}
|
|
@@ -1943,7 +1959,6 @@ function ErrorLine({ children }) {
|
|
|
1943
1959
|
function FormButtons({ children }) {
|
|
1944
1960
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "flex", flexWrap: "wrap", gap: 8, marginTop: 12 }, children });
|
|
1945
1961
|
}
|
|
1946
|
-
var MONO = "ui-monospace, SFMono-Regular, monospace";
|
|
1947
1962
|
var V = {
|
|
1948
1963
|
primary: "var(--primary, #f97316)",
|
|
1949
1964
|
foreground: "var(--foreground, #fafafa)",
|
|
@@ -1975,8 +1990,8 @@ var bodyStyle = {
|
|
|
1975
1990
|
};
|
|
1976
1991
|
var hintStyle = {
|
|
1977
1992
|
color: V.muted,
|
|
1978
|
-
fontFamily:
|
|
1979
|
-
fontSize: 10.5,
|
|
1993
|
+
fontFamily: SIGNIN_FONT,
|
|
1994
|
+
fontSize: signinSize(10.5),
|
|
1980
1995
|
opacity: 0.8
|
|
1981
1996
|
};
|
|
1982
1997
|
var rowStyle = {
|
|
@@ -1989,10 +2004,10 @@ var rowStyle = {
|
|
|
1989
2004
|
};
|
|
1990
2005
|
var rowLabelStyle = {
|
|
1991
2006
|
color: V.foreground,
|
|
1992
|
-
fontFamily:
|
|
1993
|
-
fontSize: 10.5,
|
|
1994
|
-
letterSpacing: "0.12em",
|
|
1995
|
-
textTransform:
|
|
2007
|
+
fontFamily: SIGNIN_FONT,
|
|
2008
|
+
fontSize: signinSize(10.5),
|
|
2009
|
+
letterSpacing: signinTracking("0.12em"),
|
|
2010
|
+
textTransform: SIGNIN_CASE,
|
|
1996
2011
|
opacity: 0.8
|
|
1997
2012
|
};
|
|
1998
2013
|
var inputStyle = {
|
|
@@ -2001,8 +2016,8 @@ var inputStyle = {
|
|
|
2001
2016
|
background: V.background,
|
|
2002
2017
|
color: V.foreground,
|
|
2003
2018
|
border: `1px solid ${V.border}`,
|
|
2004
|
-
borderRadius: 6,
|
|
2005
|
-
fontFamily:
|
|
2019
|
+
borderRadius: signinRadius(6),
|
|
2020
|
+
fontFamily: SIGNIN_FONT,
|
|
2006
2021
|
// 16px — never lower · suppresses iOS Safari focus auto-zoom.
|
|
2007
2022
|
fontSize: 16,
|
|
2008
2023
|
outline: "none",
|
|
@@ -2011,11 +2026,11 @@ var inputStyle = {
|
|
|
2011
2026
|
function btnBase(disabled) {
|
|
2012
2027
|
return {
|
|
2013
2028
|
padding: "0.5rem 0.875rem",
|
|
2014
|
-
borderRadius:
|
|
2015
|
-
fontFamily:
|
|
2016
|
-
fontSize: 10.5,
|
|
2017
|
-
letterSpacing: "0.12em",
|
|
2018
|
-
textTransform:
|
|
2029
|
+
borderRadius: SIGNIN_BUTTON_RADIUS,
|
|
2030
|
+
fontFamily: SIGNIN_FONT,
|
|
2031
|
+
fontSize: signinSize(10.5),
|
|
2032
|
+
letterSpacing: signinTracking("0.12em"),
|
|
2033
|
+
textTransform: SIGNIN_CASE,
|
|
2019
2034
|
cursor: disabled ? "not-allowed" : "pointer",
|
|
2020
2035
|
opacity: disabled ? 0.5 : 1
|
|
2021
2036
|
};
|
|
@@ -2134,16 +2149,21 @@ function OcSignIn({
|
|
|
2134
2149
|
returnTo,
|
|
2135
2150
|
onSuccess,
|
|
2136
2151
|
resolveReturnTo,
|
|
2137
|
-
linkPrompt = true,
|
|
2152
|
+
linkPrompt: linkPromptProp = true,
|
|
2138
2153
|
add: addProp,
|
|
2139
2154
|
authOrigin = "https://ochk.io",
|
|
2140
2155
|
initialPath,
|
|
2141
2156
|
providersFirst = true,
|
|
2142
2157
|
paths,
|
|
2143
|
-
className
|
|
2158
|
+
className,
|
|
2159
|
+
mode,
|
|
2160
|
+
providerHref
|
|
2144
2161
|
}) {
|
|
2145
2162
|
const walletEnabled = paths?.wallet ?? true;
|
|
2146
2163
|
const emailEnabled = paths?.email ?? true;
|
|
2164
|
+
const firstParty = mode === "first-party";
|
|
2165
|
+
const credentials = firstParty ? "omit" : "include";
|
|
2166
|
+
const linkPrompt = linkPromptProp && !firstParty;
|
|
2147
2167
|
const [resolvedReturn, setResolvedReturn] = React4__namespace.useState(
|
|
2148
2168
|
() => familyReturnTarget(returnTo) ?? safeReturnTo(returnTo)
|
|
2149
2169
|
);
|
|
@@ -2158,15 +2178,19 @@ function OcSignIn({
|
|
|
2158
2178
|
const fromQuery = familyReturnTarget(q.get("return_to")) ?? familyReturnTarget(q.get("next"));
|
|
2159
2179
|
setResolvedReturn(fromQuery ?? "/");
|
|
2160
2180
|
}, [returnTo]);
|
|
2161
|
-
const [addMode, setAddMode] = React4__namespace.useState(Boolean(addProp));
|
|
2181
|
+
const [addMode, setAddMode] = React4__namespace.useState(Boolean(addProp) && !firstParty);
|
|
2162
2182
|
React4__namespace.useEffect(() => {
|
|
2163
2183
|
if (typeof window === "undefined") return;
|
|
2184
|
+
if (firstParty) {
|
|
2185
|
+
setAddMode(false);
|
|
2186
|
+
return;
|
|
2187
|
+
}
|
|
2164
2188
|
if (addProp !== void 0) {
|
|
2165
2189
|
setAddMode(Boolean(addProp));
|
|
2166
2190
|
return;
|
|
2167
2191
|
}
|
|
2168
2192
|
setAddMode(new URLSearchParams(window.location.search).get("add") === "1");
|
|
2169
|
-
}, [addProp]);
|
|
2193
|
+
}, [addProp, firstParty]);
|
|
2170
2194
|
const [path, setPath] = React4__namespace.useState(
|
|
2171
2195
|
initialPath ?? (providersFirst ? "email" : "wallet")
|
|
2172
2196
|
);
|
|
@@ -2235,8 +2259,8 @@ function OcSignIn({
|
|
|
2235
2259
|
padding: "1rem",
|
|
2236
2260
|
border: "1px solid var(--border, #27272a)",
|
|
2237
2261
|
color: "var(--foreground, #fafafa)",
|
|
2238
|
-
fontFamily:
|
|
2239
|
-
fontSize: 12
|
|
2262
|
+
fontFamily: SIGNIN_FONT,
|
|
2263
|
+
fontSize: signinSize(12)
|
|
2240
2264
|
},
|
|
2241
2265
|
children: [
|
|
2242
2266
|
"no signin paths enabled \u2014 set ",
|
|
@@ -2274,10 +2298,10 @@ function OcSignIn({
|
|
|
2274
2298
|
marginBottom: 14,
|
|
2275
2299
|
padding: "0.6rem 0.75rem",
|
|
2276
2300
|
border: "1px solid var(--destructive, #ef4444)",
|
|
2277
|
-
borderRadius: 6,
|
|
2301
|
+
borderRadius: signinRadius(6),
|
|
2278
2302
|
color: "var(--destructive, #ef4444)",
|
|
2279
|
-
fontFamily:
|
|
2280
|
-
fontSize: 11
|
|
2303
|
+
fontFamily: SIGNIN_FONT,
|
|
2304
|
+
fontSize: signinSize(11)
|
|
2281
2305
|
},
|
|
2282
2306
|
children: "That sign-in didn't finish. Try again, or use another way below."
|
|
2283
2307
|
}
|
|
@@ -2291,11 +2315,11 @@ function OcSignIn({
|
|
|
2291
2315
|
padding: "0.6rem 0.75rem",
|
|
2292
2316
|
border: "1px solid var(--primary, #f97316)",
|
|
2293
2317
|
borderLeftWidth: 3,
|
|
2294
|
-
borderRadius: 4,
|
|
2318
|
+
borderRadius: signinRadius(4),
|
|
2295
2319
|
background: "color-mix(in srgb, var(--primary, #f97316) 8%, transparent)",
|
|
2296
2320
|
color: "var(--foreground, #fafafa)",
|
|
2297
|
-
fontFamily:
|
|
2298
|
-
fontSize: 11,
|
|
2321
|
+
fontFamily: SIGNIN_FONT,
|
|
2322
|
+
fontSize: signinSize(11),
|
|
2299
2323
|
lineHeight: 1.6
|
|
2300
2324
|
},
|
|
2301
2325
|
children: [
|
|
@@ -2304,9 +2328,9 @@ function OcSignIn({
|
|
|
2304
2328
|
{
|
|
2305
2329
|
style: {
|
|
2306
2330
|
color: "var(--primary, #f97316)",
|
|
2307
|
-
letterSpacing: "0.12em",
|
|
2308
|
-
textTransform:
|
|
2309
|
-
fontSize: 10,
|
|
2331
|
+
letterSpacing: signinTracking("0.12em"),
|
|
2332
|
+
textTransform: SIGNIN_CASE,
|
|
2333
|
+
fontSize: signinSize(10),
|
|
2310
2334
|
display: "block",
|
|
2311
2335
|
marginBottom: 3
|
|
2312
2336
|
},
|
|
@@ -2323,6 +2347,9 @@ function OcSignIn({
|
|
|
2323
2347
|
authOrigin,
|
|
2324
2348
|
returnTo: resolvedReturn,
|
|
2325
2349
|
add: addMode,
|
|
2350
|
+
credentials,
|
|
2351
|
+
firstParty,
|
|
2352
|
+
providerHref,
|
|
2326
2353
|
first: true
|
|
2327
2354
|
}
|
|
2328
2355
|
),
|
|
@@ -2382,6 +2409,7 @@ function OcSignIn({
|
|
|
2382
2409
|
authOrigin,
|
|
2383
2410
|
audience,
|
|
2384
2411
|
add: addMode,
|
|
2412
|
+
credentials,
|
|
2385
2413
|
onSuccess: (a, t) => void handleSuccess(a, t, "wallet")
|
|
2386
2414
|
}
|
|
2387
2415
|
),
|
|
@@ -2390,11 +2418,22 @@ function OcSignIn({
|
|
|
2390
2418
|
{
|
|
2391
2419
|
authOrigin,
|
|
2392
2420
|
add: addMode,
|
|
2421
|
+
credentials,
|
|
2393
2422
|
onSuccess: (a, t) => void handleSuccess(a, t, "email")
|
|
2394
2423
|
}
|
|
2395
2424
|
)
|
|
2396
2425
|
] }),
|
|
2397
|
-
!providersFirst && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2426
|
+
!providersFirst && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2427
|
+
ProviderSignIn,
|
|
2428
|
+
{
|
|
2429
|
+
authOrigin,
|
|
2430
|
+
returnTo: resolvedReturn,
|
|
2431
|
+
add: addMode,
|
|
2432
|
+
credentials,
|
|
2433
|
+
firstParty,
|
|
2434
|
+
providerHref
|
|
2435
|
+
}
|
|
2436
|
+
),
|
|
2398
2437
|
linkPrompt && /* @__PURE__ */ jsxRuntime.jsxs("label", { "data-oc-signin-linkalso": "", style: linkAlsoStyle, children: [
|
|
2399
2438
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2400
2439
|
"input",
|
|
@@ -2435,10 +2474,10 @@ function SigninTab({
|
|
|
2435
2474
|
border: "none",
|
|
2436
2475
|
borderBottom: active ? "2px solid var(--primary, #f97316)" : "2px solid transparent",
|
|
2437
2476
|
color: active ? "var(--foreground, #fafafa)" : "var(--muted-foreground, #a1a1aa)",
|
|
2438
|
-
fontFamily:
|
|
2439
|
-
fontSize: 11,
|
|
2440
|
-
letterSpacing: "0.12em",
|
|
2441
|
-
textTransform:
|
|
2477
|
+
fontFamily: SIGNIN_FONT,
|
|
2478
|
+
fontSize: signinSize(11),
|
|
2479
|
+
letterSpacing: signinTracking("0.12em"),
|
|
2480
|
+
textTransform: SIGNIN_CASE,
|
|
2442
2481
|
cursor: "pointer",
|
|
2443
2482
|
marginBottom: -1
|
|
2444
2483
|
},
|
|
@@ -2467,14 +2506,19 @@ function ProviderSignIn({
|
|
|
2467
2506
|
authOrigin,
|
|
2468
2507
|
returnTo,
|
|
2469
2508
|
add,
|
|
2509
|
+
credentials,
|
|
2510
|
+
firstParty,
|
|
2511
|
+
providerHref,
|
|
2470
2512
|
first = false
|
|
2471
2513
|
}) {
|
|
2472
2514
|
const [providers, setProviders] = React4__namespace.useState(null);
|
|
2473
2515
|
const [origin, setOrigin] = React4__namespace.useState("");
|
|
2516
|
+
const hidden = firstParty && !providerHref;
|
|
2474
2517
|
React4__namespace.useEffect(() => {
|
|
2475
2518
|
setOrigin(window.location.origin);
|
|
2519
|
+
if (hidden) return;
|
|
2476
2520
|
let cancelled = false;
|
|
2477
|
-
fetch(`${authOrigin}/api/auth/providers`, { credentials
|
|
2521
|
+
fetch(`${authOrigin}/api/auth/providers`, { credentials }).then((r) => r.ok ? r.json() : null).then((body) => {
|
|
2478
2522
|
if (!cancelled) setProviders(body?.providers ?? []);
|
|
2479
2523
|
}).catch(() => {
|
|
2480
2524
|
if (!cancelled) setProviders([]);
|
|
@@ -2482,7 +2526,8 @@ function ProviderSignIn({
|
|
|
2482
2526
|
return () => {
|
|
2483
2527
|
cancelled = true;
|
|
2484
2528
|
};
|
|
2485
|
-
}, [authOrigin]);
|
|
2529
|
+
}, [authOrigin, credentials, hidden]);
|
|
2530
|
+
if (hidden) return null;
|
|
2486
2531
|
if (providers !== null && providers.length === 0) return null;
|
|
2487
2532
|
const providerReturnTo = returnTo.startsWith("/") ? origin ? `${origin}${returnTo}` : returnTo : returnTo;
|
|
2488
2533
|
const line = { flex: 1, height: 1, background: "var(--border, #27272a)" };
|
|
@@ -2500,10 +2545,10 @@ function ProviderSignIn({
|
|
|
2500
2545
|
// marginTop owns the gap above, so the divider only pads below.
|
|
2501
2546
|
margin: first ? `${BLOCK_GAP}px 0` : `0 0 ${BLOCK_GAP}px`,
|
|
2502
2547
|
color: "var(--muted-foreground, #a1a1aa)",
|
|
2503
|
-
fontFamily:
|
|
2504
|
-
fontSize: 10,
|
|
2505
|
-
letterSpacing: "0.16em",
|
|
2506
|
-
textTransform:
|
|
2548
|
+
fontFamily: SIGNIN_FONT,
|
|
2549
|
+
fontSize: signinSize(10),
|
|
2550
|
+
letterSpacing: signinTracking("0.16em"),
|
|
2551
|
+
textTransform: SIGNIN_CASE
|
|
2507
2552
|
},
|
|
2508
2553
|
children: [
|
|
2509
2554
|
/* @__PURE__ */ jsxRuntime.jsx("span", { style: line }),
|
|
@@ -2523,11 +2568,11 @@ function ProviderSignIn({
|
|
|
2523
2568
|
marginTop: i === 0 ? 0 : BUTTON_GAP,
|
|
2524
2569
|
padding: "0.6rem 0.875rem",
|
|
2525
2570
|
border: "1px solid var(--border, #27272a)",
|
|
2526
|
-
borderRadius:
|
|
2571
|
+
borderRadius: SIGNIN_BUTTON_RADIUS,
|
|
2527
2572
|
background: "transparent",
|
|
2528
2573
|
color: "var(--muted-foreground, #a1a1aa)",
|
|
2529
|
-
fontFamily:
|
|
2530
|
-
fontSize: 12,
|
|
2574
|
+
fontFamily: SIGNIN_FONT,
|
|
2575
|
+
fontSize: signinSize(12),
|
|
2531
2576
|
textDecoration: "none"
|
|
2532
2577
|
});
|
|
2533
2578
|
if (providers === null) {
|
|
@@ -2540,7 +2585,7 @@ function ProviderSignIn({
|
|
|
2540
2585
|
const buttons = providers.map((p, i) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2541
2586
|
"a",
|
|
2542
2587
|
{
|
|
2543
|
-
href: `${authOrigin}/api/auth/${p.id}/start?return_to=${encodeURIComponent(
|
|
2588
|
+
href: providerHref ? providerHref(p.id) : `${authOrigin}/api/auth/${p.id}/start?return_to=${encodeURIComponent(
|
|
2544
2589
|
providerReturnTo
|
|
2545
2590
|
)}${add ? "&add=1" : ""}`,
|
|
2546
2591
|
"data-oc-signin-provider": p.id,
|
|
@@ -2573,7 +2618,13 @@ async function loadAdapter() {
|
|
|
2573
2618
|
async function detectBrowserWallets() {
|
|
2574
2619
|
return (await loadAdapter()).detectWallets().filter((w) => w.detected && w.id !== "manual").map((w) => ({ id: w.id, name: w.name }));
|
|
2575
2620
|
}
|
|
2576
|
-
function WalletFlow({
|
|
2621
|
+
function WalletFlow({
|
|
2622
|
+
authOrigin,
|
|
2623
|
+
audience,
|
|
2624
|
+
add,
|
|
2625
|
+
credentials,
|
|
2626
|
+
onSuccess
|
|
2627
|
+
}) {
|
|
2577
2628
|
const uid = React4__namespace.useId();
|
|
2578
2629
|
const ids = {
|
|
2579
2630
|
address: `${uid}-address`,
|
|
@@ -2615,7 +2666,7 @@ function WalletFlow({ authOrigin, audience, add, onSuccess }) {
|
|
|
2615
2666
|
async function submitSignature(message, nonce, signature, scheme) {
|
|
2616
2667
|
const res = await fetch(`${authOrigin}/api/auth/signin`, {
|
|
2617
2668
|
method: "POST",
|
|
2618
|
-
credentials
|
|
2669
|
+
credentials,
|
|
2619
2670
|
headers: { "Content-Type": "application/json" },
|
|
2620
2671
|
body: JSON.stringify({
|
|
2621
2672
|
message,
|
|
@@ -2816,7 +2867,7 @@ function WalletFlow({ authOrigin, audience, add, onSuccess }) {
|
|
|
2816
2867
|
noBrowserWallet && /* @__PURE__ */ jsxRuntime.jsx(Hint, { children: "No browser wallet found here. You can sign with any wallet and paste." })
|
|
2817
2868
|
] });
|
|
2818
2869
|
}
|
|
2819
|
-
function EmailFlow({ authOrigin, add, onSuccess }) {
|
|
2870
|
+
function EmailFlow({ authOrigin, add, credentials, onSuccess }) {
|
|
2820
2871
|
const uid = React4__namespace.useId();
|
|
2821
2872
|
const [stage, setStage] = React4__namespace.useState("enter");
|
|
2822
2873
|
const [email, setEmail] = React4__namespace.useState("");
|
|
@@ -2830,7 +2881,7 @@ function EmailFlow({ authOrigin, add, onSuccess }) {
|
|
|
2830
2881
|
try {
|
|
2831
2882
|
const res = await fetch(`${authOrigin}/api/auth/email-otp/start`, {
|
|
2832
2883
|
method: "POST",
|
|
2833
|
-
credentials
|
|
2884
|
+
credentials,
|
|
2834
2885
|
headers: { "Content-Type": "application/json" },
|
|
2835
2886
|
body: JSON.stringify({ email: address })
|
|
2836
2887
|
});
|
|
@@ -2882,7 +2933,7 @@ function EmailFlow({ authOrigin, add, onSuccess }) {
|
|
|
2882
2933
|
try {
|
|
2883
2934
|
const res = await fetch(`${authOrigin}/api/auth/email-otp/verify`, {
|
|
2884
2935
|
method: "POST",
|
|
2885
|
-
credentials
|
|
2936
|
+
credentials,
|
|
2886
2937
|
headers: { "Content-Type": "application/json" },
|
|
2887
2938
|
body: JSON.stringify({
|
|
2888
2939
|
email,
|
|
@@ -3006,10 +3057,10 @@ function FlowHeader({
|
|
|
3006
3057
|
{
|
|
3007
3058
|
style: {
|
|
3008
3059
|
color: "var(--primary, #f97316)",
|
|
3009
|
-
fontFamily:
|
|
3010
|
-
fontSize: 10,
|
|
3011
|
-
letterSpacing: "0.18em",
|
|
3012
|
-
textTransform:
|
|
3060
|
+
fontFamily: SIGNIN_FONT,
|
|
3061
|
+
fontSize: signinSize(10),
|
|
3062
|
+
letterSpacing: signinTracking("0.18em"),
|
|
3063
|
+
textTransform: SIGNIN_CASE,
|
|
3013
3064
|
marginBottom: 6
|
|
3014
3065
|
},
|
|
3015
3066
|
children: label
|
|
@@ -3038,10 +3089,10 @@ var linkButtonStyle = {
|
|
|
3038
3089
|
background: "transparent",
|
|
3039
3090
|
border: "none",
|
|
3040
3091
|
color: "var(--muted-foreground, #a1a1aa)",
|
|
3041
|
-
fontFamily:
|
|
3042
|
-
fontSize: 11,
|
|
3043
|
-
letterSpacing: "0.12em",
|
|
3044
|
-
textTransform:
|
|
3092
|
+
fontFamily: SIGNIN_FONT,
|
|
3093
|
+
fontSize: signinSize(11),
|
|
3094
|
+
letterSpacing: signinTracking("0.12em"),
|
|
3095
|
+
textTransform: SIGNIN_CASE,
|
|
3045
3096
|
cursor: "pointer",
|
|
3046
3097
|
padding: 0
|
|
3047
3098
|
};
|
|
@@ -3056,10 +3107,10 @@ function Label({
|
|
|
3056
3107
|
style: {
|
|
3057
3108
|
display: "block",
|
|
3058
3109
|
color: "var(--foreground, #fafafa)",
|
|
3059
|
-
fontFamily:
|
|
3060
|
-
fontSize: 11,
|
|
3061
|
-
letterSpacing: "0.12em",
|
|
3062
|
-
textTransform:
|
|
3110
|
+
fontFamily: SIGNIN_FONT,
|
|
3111
|
+
fontSize: signinSize(11),
|
|
3112
|
+
letterSpacing: signinTracking("0.12em"),
|
|
3113
|
+
textTransform: SIGNIN_CASE,
|
|
3063
3114
|
marginBottom: 6
|
|
3064
3115
|
},
|
|
3065
3116
|
children
|
|
@@ -3072,8 +3123,8 @@ var inputStyle2 = {
|
|
|
3072
3123
|
background: "var(--background, #0a0a0a)",
|
|
3073
3124
|
color: "var(--foreground, #fafafa)",
|
|
3074
3125
|
border: "1px solid var(--input, #27272a)",
|
|
3075
|
-
borderRadius: 6,
|
|
3076
|
-
fontFamily:
|
|
3126
|
+
borderRadius: signinRadius(6),
|
|
3127
|
+
fontFamily: SIGNIN_FONT,
|
|
3077
3128
|
// 16px — never below it. A sub-16px font-size makes iOS Safari
|
|
3078
3129
|
// auto-zoom the viewport on focus; the family rule is >=16px on
|
|
3079
3130
|
// every form field. Desktop reads fine at 16 too.
|
|
@@ -3090,8 +3141,8 @@ var linkAlsoStyle = {
|
|
|
3090
3141
|
paddingTop: 14,
|
|
3091
3142
|
borderTop: "1px solid var(--border, #27272a)",
|
|
3092
3143
|
color: "var(--muted-foreground, #a1a1aa)",
|
|
3093
|
-
fontFamily:
|
|
3094
|
-
fontSize: 12,
|
|
3144
|
+
fontFamily: SIGNIN_FONT,
|
|
3145
|
+
fontSize: signinSize(12),
|
|
3095
3146
|
lineHeight: 1.5,
|
|
3096
3147
|
cursor: "pointer"
|
|
3097
3148
|
};
|
|
@@ -3102,12 +3153,12 @@ function submitStyle(disabled) {
|
|
|
3102
3153
|
background: "var(--primary, #f97316)",
|
|
3103
3154
|
color: "var(--primary-foreground, #0a0a0a)",
|
|
3104
3155
|
border: "none",
|
|
3105
|
-
borderRadius:
|
|
3106
|
-
fontFamily:
|
|
3107
|
-
fontSize: 11,
|
|
3108
|
-
letterSpacing: "0.14em",
|
|
3109
|
-
textTransform:
|
|
3110
|
-
fontWeight:
|
|
3156
|
+
borderRadius: SIGNIN_BUTTON_RADIUS,
|
|
3157
|
+
fontFamily: SIGNIN_FONT,
|
|
3158
|
+
fontSize: signinSize(11),
|
|
3159
|
+
letterSpacing: signinTracking("0.14em"),
|
|
3160
|
+
textTransform: SIGNIN_CASE,
|
|
3161
|
+
fontWeight: SIGNIN_STRONG,
|
|
3111
3162
|
cursor: disabled ? "not-allowed" : "pointer",
|
|
3112
3163
|
opacity: disabled ? 0.5 : 1,
|
|
3113
3164
|
width: "100%"
|
|
@@ -3122,8 +3173,8 @@ function ErrorLine2({ children }) {
|
|
|
3122
3173
|
marginTop: 6,
|
|
3123
3174
|
marginBottom: 0,
|
|
3124
3175
|
color: "var(--destructive, #ef4444)",
|
|
3125
|
-
fontFamily:
|
|
3126
|
-
fontSize: 11,
|
|
3176
|
+
fontFamily: SIGNIN_FONT,
|
|
3177
|
+
fontSize: signinSize(11),
|
|
3127
3178
|
letterSpacing: "0.04em"
|
|
3128
3179
|
},
|
|
3129
3180
|
children
|
|
@@ -3138,7 +3189,7 @@ function Hint({ children }) {
|
|
|
3138
3189
|
marginTop: 12,
|
|
3139
3190
|
marginBottom: 0,
|
|
3140
3191
|
color: "var(--muted-foreground, #a1a1aa)",
|
|
3141
|
-
fontFamily:
|
|
3192
|
+
fontFamily: SIGNIN_FONT,
|
|
3142
3193
|
fontSize: 10.5,
|
|
3143
3194
|
lineHeight: 1.55
|
|
3144
3195
|
},
|