@orangecheck/auth-client 2.16.0 → 2.17.1
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 +18 -3
- package/dist/index.d.ts +18 -3
- package/dist/index.js +155 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +155 -20
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -19,12 +19,25 @@ interface OcAccount {
|
|
|
19
19
|
displayIdentity: DisplayIdentity;
|
|
20
20
|
}
|
|
21
21
|
type OcSessionStatus = 'loading' | 'authenticated' | 'anonymous' | 'error';
|
|
22
|
+
interface OcAccountSummary {
|
|
23
|
+
didOc: string;
|
|
24
|
+
displayName: string | null;
|
|
25
|
+
primaryBtc: string | null;
|
|
26
|
+
displayIdentity: DisplayIdentity;
|
|
27
|
+
lastSeenAt: string | null;
|
|
28
|
+
}
|
|
29
|
+
type OcSignOutScope = 'all' | 'current';
|
|
22
30
|
interface OcSessionState {
|
|
23
31
|
status: OcSessionStatus;
|
|
24
32
|
account: OcAccount | null;
|
|
33
|
+
roster: OcAccountSummary[];
|
|
25
34
|
error: Error | null;
|
|
26
35
|
refresh: () => Promise<void>;
|
|
27
|
-
signOut: (
|
|
36
|
+
signOut: (opts?: {
|
|
37
|
+
scope?: OcSignOutScope;
|
|
38
|
+
}) => Promise<void>;
|
|
39
|
+
switchAccount: (didOc: string) => Promise<void>;
|
|
40
|
+
addAccountUrl: (returnTo?: string) => string;
|
|
28
41
|
setDisplayIdentity: (kind: DisplayIdentityKind) => Promise<void>;
|
|
29
42
|
signInUrl: string;
|
|
30
43
|
}
|
|
@@ -36,6 +49,7 @@ interface OcAuthConfig {
|
|
|
36
49
|
}
|
|
37
50
|
declare const DEFAULT_CONFIG: Required<OcAuthConfig>;
|
|
38
51
|
declare function buildSignInUrl(cfg: Required<OcAuthConfig>, returnTo?: string): string;
|
|
52
|
+
declare function buildAddAccountUrl(cfg: Required<OcAuthConfig>, returnTo?: string): string;
|
|
39
53
|
|
|
40
54
|
interface OcSessionProviderProps {
|
|
41
55
|
children: React.ReactNode;
|
|
@@ -115,9 +129,10 @@ interface OcSignInProps {
|
|
|
115
129
|
email?: boolean;
|
|
116
130
|
};
|
|
117
131
|
linkPrompt?: boolean;
|
|
132
|
+
add?: boolean;
|
|
118
133
|
className?: string;
|
|
119
134
|
}
|
|
120
|
-
declare function OcSignIn({ audience, returnTo, onSuccess, resolveReturnTo, linkPrompt, authOrigin, initialPath, paths, className, }: OcSignInProps): React.ReactElement;
|
|
135
|
+
declare function OcSignIn({ audience, returnTo, onSuccess, resolveReturnTo, linkPrompt, add: addProp, authOrigin, initialPath, paths, className, }: OcSignInProps): React.ReactElement;
|
|
121
136
|
|
|
122
137
|
interface OcLinkedIdentity {
|
|
123
138
|
id: string;
|
|
@@ -219,4 +234,4 @@ declare function handleSudoRequired(body: {
|
|
|
219
234
|
returnTo?: string;
|
|
220
235
|
}): boolean;
|
|
221
236
|
|
|
222
|
-
export { DEFAULT_CONFIG, DISPLAY_IDENTITY_KINDS, type DisplayIdentity, type DisplayIdentityKind, type OcAccount, OcAccountChip, type OcAccountChipProps, OcAccountPill, type OcAccountPillProps, OcAddressInput, type OcAddressInputProps, type OcAuthConfig, OcLinkedIdentities, type OcLinkedIdentitiesProps, type OcLinkedIdentity, OcSessionProvider, type OcSessionState, type OcSessionStatus, OcSignIn, OcSignInButton, type OcSignInButtonProps, type OcSignInProps, type RedirectToSudoArgs, type UseOcAddressSuggestionOptions, type UseOcAddressSuggestionReturn, type UseStepUpAuthReturn, type UseWebAuthnListReturn, type UseWebAuthnRegisterReturn, type WebAuthnAssertionStatus, type WebAuthnCredentialPublic, type WebAuthnListStatus, type WebAuthnRegisterResult, type WebAuthnRegisterStatus, type WebAuthnRemoveResult, type WebAuthnRenameResult, type WebAuthnStepUpResult, buildSignInUrl, fetchOcLinkedIdentities, handleSudoRequired, redirectToSudo, useOcAddressSuggestion, useOcSession, useOptionalOcSession, useStepUpAuth, useWebAuthnList, useWebAuthnRegister };
|
|
237
|
+
export { DEFAULT_CONFIG, DISPLAY_IDENTITY_KINDS, type DisplayIdentity, type DisplayIdentityKind, type OcAccount, OcAccountChip, type OcAccountChipProps, OcAccountPill, type OcAccountPillProps, type OcAccountSummary, OcAddressInput, type OcAddressInputProps, type OcAuthConfig, OcLinkedIdentities, type OcLinkedIdentitiesProps, type OcLinkedIdentity, OcSessionProvider, type OcSessionState, type OcSessionStatus, OcSignIn, OcSignInButton, type OcSignInButtonProps, type OcSignInProps, type OcSignOutScope, type RedirectToSudoArgs, type UseOcAddressSuggestionOptions, type UseOcAddressSuggestionReturn, type UseStepUpAuthReturn, type UseWebAuthnListReturn, type UseWebAuthnRegisterReturn, type WebAuthnAssertionStatus, type WebAuthnCredentialPublic, type WebAuthnListStatus, type WebAuthnRegisterResult, type WebAuthnRegisterStatus, type WebAuthnRemoveResult, type WebAuthnRenameResult, type WebAuthnStepUpResult, buildAddAccountUrl, buildSignInUrl, fetchOcLinkedIdentities, handleSudoRequired, redirectToSudo, useOcAddressSuggestion, useOcSession, useOptionalOcSession, useStepUpAuth, useWebAuthnList, useWebAuthnRegister };
|
package/dist/index.d.ts
CHANGED
|
@@ -19,12 +19,25 @@ interface OcAccount {
|
|
|
19
19
|
displayIdentity: DisplayIdentity;
|
|
20
20
|
}
|
|
21
21
|
type OcSessionStatus = 'loading' | 'authenticated' | 'anonymous' | 'error';
|
|
22
|
+
interface OcAccountSummary {
|
|
23
|
+
didOc: string;
|
|
24
|
+
displayName: string | null;
|
|
25
|
+
primaryBtc: string | null;
|
|
26
|
+
displayIdentity: DisplayIdentity;
|
|
27
|
+
lastSeenAt: string | null;
|
|
28
|
+
}
|
|
29
|
+
type OcSignOutScope = 'all' | 'current';
|
|
22
30
|
interface OcSessionState {
|
|
23
31
|
status: OcSessionStatus;
|
|
24
32
|
account: OcAccount | null;
|
|
33
|
+
roster: OcAccountSummary[];
|
|
25
34
|
error: Error | null;
|
|
26
35
|
refresh: () => Promise<void>;
|
|
27
|
-
signOut: (
|
|
36
|
+
signOut: (opts?: {
|
|
37
|
+
scope?: OcSignOutScope;
|
|
38
|
+
}) => Promise<void>;
|
|
39
|
+
switchAccount: (didOc: string) => Promise<void>;
|
|
40
|
+
addAccountUrl: (returnTo?: string) => string;
|
|
28
41
|
setDisplayIdentity: (kind: DisplayIdentityKind) => Promise<void>;
|
|
29
42
|
signInUrl: string;
|
|
30
43
|
}
|
|
@@ -36,6 +49,7 @@ interface OcAuthConfig {
|
|
|
36
49
|
}
|
|
37
50
|
declare const DEFAULT_CONFIG: Required<OcAuthConfig>;
|
|
38
51
|
declare function buildSignInUrl(cfg: Required<OcAuthConfig>, returnTo?: string): string;
|
|
52
|
+
declare function buildAddAccountUrl(cfg: Required<OcAuthConfig>, returnTo?: string): string;
|
|
39
53
|
|
|
40
54
|
interface OcSessionProviderProps {
|
|
41
55
|
children: React.ReactNode;
|
|
@@ -115,9 +129,10 @@ interface OcSignInProps {
|
|
|
115
129
|
email?: boolean;
|
|
116
130
|
};
|
|
117
131
|
linkPrompt?: boolean;
|
|
132
|
+
add?: boolean;
|
|
118
133
|
className?: string;
|
|
119
134
|
}
|
|
120
|
-
declare function OcSignIn({ audience, returnTo, onSuccess, resolveReturnTo, linkPrompt, authOrigin, initialPath, paths, className, }: OcSignInProps): React.ReactElement;
|
|
135
|
+
declare function OcSignIn({ audience, returnTo, onSuccess, resolveReturnTo, linkPrompt, add: addProp, authOrigin, initialPath, paths, className, }: OcSignInProps): React.ReactElement;
|
|
121
136
|
|
|
122
137
|
interface OcLinkedIdentity {
|
|
123
138
|
id: string;
|
|
@@ -219,4 +234,4 @@ declare function handleSudoRequired(body: {
|
|
|
219
234
|
returnTo?: string;
|
|
220
235
|
}): boolean;
|
|
221
236
|
|
|
222
|
-
export { DEFAULT_CONFIG, DISPLAY_IDENTITY_KINDS, type DisplayIdentity, type DisplayIdentityKind, type OcAccount, OcAccountChip, type OcAccountChipProps, OcAccountPill, type OcAccountPillProps, OcAddressInput, type OcAddressInputProps, type OcAuthConfig, OcLinkedIdentities, type OcLinkedIdentitiesProps, type OcLinkedIdentity, OcSessionProvider, type OcSessionState, type OcSessionStatus, OcSignIn, OcSignInButton, type OcSignInButtonProps, type OcSignInProps, type RedirectToSudoArgs, type UseOcAddressSuggestionOptions, type UseOcAddressSuggestionReturn, type UseStepUpAuthReturn, type UseWebAuthnListReturn, type UseWebAuthnRegisterReturn, type WebAuthnAssertionStatus, type WebAuthnCredentialPublic, type WebAuthnListStatus, type WebAuthnRegisterResult, type WebAuthnRegisterStatus, type WebAuthnRemoveResult, type WebAuthnRenameResult, type WebAuthnStepUpResult, buildSignInUrl, fetchOcLinkedIdentities, handleSudoRequired, redirectToSudo, useOcAddressSuggestion, useOcSession, useOptionalOcSession, useStepUpAuth, useWebAuthnList, useWebAuthnRegister };
|
|
237
|
+
export { DEFAULT_CONFIG, DISPLAY_IDENTITY_KINDS, type DisplayIdentity, type DisplayIdentityKind, type OcAccount, OcAccountChip, type OcAccountChipProps, OcAccountPill, type OcAccountPillProps, type OcAccountSummary, OcAddressInput, type OcAddressInputProps, type OcAuthConfig, OcLinkedIdentities, type OcLinkedIdentitiesProps, type OcLinkedIdentity, OcSessionProvider, type OcSessionState, type OcSessionStatus, OcSignIn, OcSignInButton, type OcSignInButtonProps, type OcSignInProps, type OcSignOutScope, type RedirectToSudoArgs, type UseOcAddressSuggestionOptions, type UseOcAddressSuggestionReturn, type UseStepUpAuthReturn, type UseWebAuthnListReturn, type UseWebAuthnRegisterReturn, type WebAuthnAssertionStatus, type WebAuthnCredentialPublic, type WebAuthnListStatus, type WebAuthnRegisterResult, type WebAuthnRegisterStatus, type WebAuthnRemoveResult, type WebAuthnRenameResult, type WebAuthnStepUpResult, buildAddAccountUrl, buildSignInUrl, fetchOcLinkedIdentities, handleSudoRequired, redirectToSudo, useOcAddressSuggestion, useOcSession, useOptionalOcSession, useStepUpAuth, useWebAuthnList, useWebAuthnRegister };
|
package/dist/index.js
CHANGED
|
@@ -44,6 +44,11 @@ function buildSignInUrl(cfg, returnTo) {
|
|
|
44
44
|
u.searchParams.set("return_to", returnTo);
|
|
45
45
|
return u.toString();
|
|
46
46
|
}
|
|
47
|
+
function buildAddAccountUrl(cfg, returnTo) {
|
|
48
|
+
const u = new URL(buildSignInUrl(cfg, returnTo));
|
|
49
|
+
u.searchParams.set("add", "1");
|
|
50
|
+
return u.toString();
|
|
51
|
+
}
|
|
47
52
|
var SessionContext = React3__namespace.createContext(null);
|
|
48
53
|
function normalizeDisplayIdentity(raw, didOc) {
|
|
49
54
|
const di = raw.display_identity ?? raw.displayIdentity;
|
|
@@ -52,6 +57,19 @@ function normalizeDisplayIdentity(raw, didOc) {
|
|
|
52
57
|
}
|
|
53
58
|
return { kind: "did", value: didOc };
|
|
54
59
|
}
|
|
60
|
+
function normalizeRosterEntry(raw) {
|
|
61
|
+
const didOc = raw.did_oc ?? raw.didOc;
|
|
62
|
+
if (!didOc) return null;
|
|
63
|
+
const di = raw.display_identity ?? raw.displayIdentity;
|
|
64
|
+
const displayIdentity = di && typeof di === "object" && typeof di.value === "string" && di.value.length > 0 && typeof di.kind === "string" && DISPLAY_IDENTITY_KINDS.includes(di.kind) ? { kind: di.kind, value: di.value } : { kind: "did", value: didOc };
|
|
65
|
+
return {
|
|
66
|
+
didOc,
|
|
67
|
+
displayName: raw.display_name ?? raw.displayName ?? null,
|
|
68
|
+
primaryBtc: raw.primary_btc ?? raw.primaryBtc ?? null,
|
|
69
|
+
displayIdentity,
|
|
70
|
+
lastSeenAt: raw.last_seen_at ?? raw.lastSeenAt ?? null
|
|
71
|
+
};
|
|
72
|
+
}
|
|
55
73
|
function normalizeAccount(raw) {
|
|
56
74
|
if (!raw) return null;
|
|
57
75
|
const didOc = raw.did_oc ?? raw.didOc;
|
|
@@ -77,6 +95,7 @@ function OcSessionProvider({
|
|
|
77
95
|
}) {
|
|
78
96
|
const cfg = React3__namespace.useMemo(() => resolveConfig(config), [config]);
|
|
79
97
|
const [account, setAccount] = React3__namespace.useState(null);
|
|
98
|
+
const [roster, setRoster] = React3__namespace.useState([]);
|
|
80
99
|
const [status, setStatus] = React3__namespace.useState("loading");
|
|
81
100
|
const [error, setError] = React3__namespace.useState(null);
|
|
82
101
|
const refresh = React3__namespace.useCallback(async () => {
|
|
@@ -89,6 +108,7 @@ function OcSessionProvider({
|
|
|
89
108
|
});
|
|
90
109
|
if (res.status === 401) {
|
|
91
110
|
setAccount(null);
|
|
111
|
+
setRoster([]);
|
|
92
112
|
setStatus("anonymous");
|
|
93
113
|
setError(null);
|
|
94
114
|
return;
|
|
@@ -100,7 +120,9 @@ function OcSessionProvider({
|
|
|
100
120
|
}
|
|
101
121
|
const body = await res.json();
|
|
102
122
|
const acct = normalizeAccount(body.account);
|
|
123
|
+
const rosterEntries = Array.isArray(body.roster) ? body.roster.map(normalizeRosterEntry).filter((r) => r !== null) : [];
|
|
103
124
|
setAccount(acct);
|
|
125
|
+
setRoster(rosterEntries);
|
|
104
126
|
setStatus(acct ? "authenticated" : "anonymous");
|
|
105
127
|
setError(null);
|
|
106
128
|
} catch (err) {
|
|
@@ -111,23 +133,63 @@ function OcSessionProvider({
|
|
|
111
133
|
React3__namespace.useEffect(() => {
|
|
112
134
|
void refresh();
|
|
113
135
|
}, [refresh]);
|
|
114
|
-
const signOut = React3__namespace.useCallback(
|
|
115
|
-
|
|
116
|
-
|
|
136
|
+
const signOut = React3__namespace.useCallback(
|
|
137
|
+
async (opts) => {
|
|
138
|
+
const scope = opts?.scope ?? "all";
|
|
139
|
+
try {
|
|
140
|
+
const url = new URL(`${cfg.authOrigin}${cfg.logoutPath}`);
|
|
141
|
+
if (scope === "current") url.searchParams.set("scope", "current");
|
|
142
|
+
const res = await fetch(url.toString(), {
|
|
143
|
+
method: "POST",
|
|
144
|
+
credentials: "include",
|
|
145
|
+
// `keepalive` lets the logout round-trip complete even if
|
|
146
|
+
// the caller hard-navigates away in the same tick (e.g.
|
|
147
|
+
// `<OcAccountMenu>` redirects home immediately on sign-out).
|
|
148
|
+
// Without it the in-flight request is cancelled on unload
|
|
149
|
+
// and the `.ochk.io` cookie may never get cleared.
|
|
150
|
+
keepalive: true
|
|
151
|
+
});
|
|
152
|
+
if (scope === "current" && res.ok) {
|
|
153
|
+
await refresh();
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
} catch {
|
|
157
|
+
}
|
|
158
|
+
setAccount(null);
|
|
159
|
+
setRoster([]);
|
|
160
|
+
setStatus("anonymous");
|
|
161
|
+
},
|
|
162
|
+
[cfg.authOrigin, cfg.logoutPath, refresh]
|
|
163
|
+
);
|
|
164
|
+
const switchAccount = React3__namespace.useCallback(
|
|
165
|
+
async (didOc) => {
|
|
166
|
+
if (typeof window === "undefined") return;
|
|
167
|
+
const res = await fetch(`${cfg.authOrigin}/api/auth/switch`, {
|
|
117
168
|
method: "POST",
|
|
118
169
|
credentials: "include",
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
// `<OcAccountMenu>` redirects home immediately on sign-out).
|
|
122
|
-
// Without it the in-flight request is cancelled on unload
|
|
123
|
-
// and the `.ochk.io` cookie may never get cleared.
|
|
124
|
-
keepalive: true
|
|
170
|
+
headers: { "Content-Type": "application/json" },
|
|
171
|
+
body: JSON.stringify({ did_oc: didOc })
|
|
125
172
|
});
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
173
|
+
if (!res.ok) {
|
|
174
|
+
let reason = `http_${res.status}`;
|
|
175
|
+
try {
|
|
176
|
+
const body = await res.json();
|
|
177
|
+
if (body.reason) reason = body.reason;
|
|
178
|
+
} catch {
|
|
179
|
+
}
|
|
180
|
+
throw new Error(`[@orangecheck/auth-client] switchAccount failed: ${reason}`);
|
|
181
|
+
}
|
|
182
|
+
await refresh();
|
|
183
|
+
},
|
|
184
|
+
[cfg.authOrigin, refresh]
|
|
185
|
+
);
|
|
186
|
+
const addAccountUrl = React3__namespace.useCallback(
|
|
187
|
+
(returnTo) => {
|
|
188
|
+
const rt = returnTo ?? (typeof window !== "undefined" ? window.location.href : void 0);
|
|
189
|
+
return buildAddAccountUrl(cfg, rt);
|
|
190
|
+
},
|
|
191
|
+
[cfg]
|
|
192
|
+
);
|
|
131
193
|
const setDisplayIdentity = React3__namespace.useCallback(
|
|
132
194
|
async (kind) => {
|
|
133
195
|
if (typeof window === "undefined") return;
|
|
@@ -155,13 +217,28 @@ function OcSessionProvider({
|
|
|
155
217
|
return {
|
|
156
218
|
status,
|
|
157
219
|
account,
|
|
220
|
+
roster,
|
|
158
221
|
error,
|
|
159
222
|
refresh,
|
|
160
223
|
signOut,
|
|
224
|
+
switchAccount,
|
|
225
|
+
addAccountUrl,
|
|
161
226
|
setDisplayIdentity,
|
|
162
227
|
signInUrl: buildSignInUrl(cfg, returnTo)
|
|
163
228
|
};
|
|
164
|
-
}, [
|
|
229
|
+
}, [
|
|
230
|
+
status,
|
|
231
|
+
account,
|
|
232
|
+
roster,
|
|
233
|
+
error,
|
|
234
|
+
refresh,
|
|
235
|
+
signOut,
|
|
236
|
+
switchAccount,
|
|
237
|
+
addAccountUrl,
|
|
238
|
+
setDisplayIdentity,
|
|
239
|
+
cfg,
|
|
240
|
+
defaultReturnTo
|
|
241
|
+
]);
|
|
165
242
|
return /* @__PURE__ */ jsxRuntime.jsx(SessionContext.Provider, { value, children });
|
|
166
243
|
}
|
|
167
244
|
function useOcSession() {
|
|
@@ -1688,6 +1765,7 @@ function OcSignIn({
|
|
|
1688
1765
|
onSuccess,
|
|
1689
1766
|
resolveReturnTo,
|
|
1690
1767
|
linkPrompt = true,
|
|
1768
|
+
add: addProp,
|
|
1691
1769
|
authOrigin = "https://ochk.io",
|
|
1692
1770
|
initialPath = "wallet",
|
|
1693
1771
|
paths,
|
|
@@ -1696,6 +1774,15 @@ function OcSignIn({
|
|
|
1696
1774
|
const walletEnabled = paths?.wallet ?? true;
|
|
1697
1775
|
const emailEnabled = paths?.email ?? true;
|
|
1698
1776
|
const safeReturn = safeReturnTo(returnTo);
|
|
1777
|
+
const [addMode, setAddMode] = React3__namespace.useState(Boolean(addProp));
|
|
1778
|
+
React3__namespace.useEffect(() => {
|
|
1779
|
+
if (typeof window === "undefined") return;
|
|
1780
|
+
if (addProp !== void 0) {
|
|
1781
|
+
setAddMode(Boolean(addProp));
|
|
1782
|
+
return;
|
|
1783
|
+
}
|
|
1784
|
+
setAddMode(new URLSearchParams(window.location.search).get("add") === "1");
|
|
1785
|
+
}, [addProp]);
|
|
1699
1786
|
const [path, setPath] = React3__namespace.useState(initialPath);
|
|
1700
1787
|
const [signedIn, setSignedIn] = React3__namespace.useState(null);
|
|
1701
1788
|
const [linkAlso, setLinkAlso] = React3__namespace.useState(false);
|
|
@@ -1807,6 +1894,41 @@ function OcSignIn({
|
|
|
1807
1894
|
children: "That sign-in didn't complete. Please try again."
|
|
1808
1895
|
}
|
|
1809
1896
|
),
|
|
1897
|
+
addMode && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1898
|
+
"div",
|
|
1899
|
+
{
|
|
1900
|
+
"data-oc-signin-add-mode": "",
|
|
1901
|
+
style: {
|
|
1902
|
+
marginBottom: 14,
|
|
1903
|
+
padding: "0.6rem 0.75rem",
|
|
1904
|
+
border: "1px solid var(--primary, #f97316)",
|
|
1905
|
+
borderLeftWidth: 3,
|
|
1906
|
+
borderRadius: 4,
|
|
1907
|
+
background: "color-mix(in srgb, var(--primary, #f97316) 8%, transparent)",
|
|
1908
|
+
color: "var(--foreground, #fafafa)",
|
|
1909
|
+
fontFamily: "ui-monospace, SFMono-Regular, monospace",
|
|
1910
|
+
fontSize: 11,
|
|
1911
|
+
lineHeight: 1.6
|
|
1912
|
+
},
|
|
1913
|
+
children: [
|
|
1914
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1915
|
+
"strong",
|
|
1916
|
+
{
|
|
1917
|
+
style: {
|
|
1918
|
+
color: "var(--primary, #f97316)",
|
|
1919
|
+
letterSpacing: "0.12em",
|
|
1920
|
+
textTransform: "uppercase",
|
|
1921
|
+
fontSize: 10,
|
|
1922
|
+
display: "block",
|
|
1923
|
+
marginBottom: 3
|
|
1924
|
+
},
|
|
1925
|
+
children: "\xA7 adding another account"
|
|
1926
|
+
}
|
|
1927
|
+
),
|
|
1928
|
+
"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."
|
|
1929
|
+
]
|
|
1930
|
+
}
|
|
1931
|
+
),
|
|
1810
1932
|
bothEnabled && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1811
1933
|
"div",
|
|
1812
1934
|
{
|
|
@@ -1838,6 +1960,7 @@ function OcSignIn({
|
|
|
1838
1960
|
{
|
|
1839
1961
|
authOrigin,
|
|
1840
1962
|
audience,
|
|
1963
|
+
add: addMode,
|
|
1841
1964
|
onSuccess: (a, t) => void handleSuccess(a, t, "wallet")
|
|
1842
1965
|
}
|
|
1843
1966
|
),
|
|
@@ -1845,6 +1968,7 @@ function OcSignIn({
|
|
|
1845
1968
|
EmailFlow,
|
|
1846
1969
|
{
|
|
1847
1970
|
authOrigin,
|
|
1971
|
+
add: addMode,
|
|
1848
1972
|
onSuccess: (a, t) => void handleSuccess(a, t, "email")
|
|
1849
1973
|
}
|
|
1850
1974
|
)
|
|
@@ -1992,7 +2116,7 @@ function ProviderSignIn({
|
|
|
1992
2116
|
))
|
|
1993
2117
|
] });
|
|
1994
2118
|
}
|
|
1995
|
-
function WalletFlow({ authOrigin, audience, onSuccess }) {
|
|
2119
|
+
function WalletFlow({ authOrigin, audience, add, onSuccess }) {
|
|
1996
2120
|
const [address, setAddress] = React3__namespace.useState("");
|
|
1997
2121
|
const [error, setError] = React3__namespace.useState(null);
|
|
1998
2122
|
const [submitting, setSubmitting] = React3__namespace.useState(false);
|
|
@@ -2040,7 +2164,12 @@ function WalletFlow({ authOrigin, audience, onSuccess }) {
|
|
|
2040
2164
|
scheme: "bip322",
|
|
2041
2165
|
expectedNonce: challenge.nonce,
|
|
2042
2166
|
expectedAudience: audience,
|
|
2043
|
-
expectedPurpose: "login"
|
|
2167
|
+
expectedPurpose: "login",
|
|
2168
|
+
// Multi-account add-mode · the auth host preserves
|
|
2169
|
+
// the current roster_id when set, instead of minting
|
|
2170
|
+
// a fresh one. Hosts that haven't deployed the
|
|
2171
|
+
// multi-account migration silently ignore the field.
|
|
2172
|
+
...add ? { add: true } : {}
|
|
2044
2173
|
})
|
|
2045
2174
|
});
|
|
2046
2175
|
const json = await res.json();
|
|
@@ -2091,7 +2220,7 @@ function WalletFlow({ authOrigin, audience, onSuccess }) {
|
|
|
2091
2220
|
/* @__PURE__ */ jsxRuntime.jsx(Hint, { children: "Detection picks the first installed BIP-322-capable extension. Address is the one your wallet will sign for." })
|
|
2092
2221
|
] });
|
|
2093
2222
|
}
|
|
2094
|
-
function EmailFlow({ authOrigin, onSuccess }) {
|
|
2223
|
+
function EmailFlow({ authOrigin, add, onSuccess }) {
|
|
2095
2224
|
const [stage, setStage] = React3__namespace.useState("enter");
|
|
2096
2225
|
const [email, setEmail] = React3__namespace.useState("");
|
|
2097
2226
|
const [emailError, setEmailError] = React3__namespace.useState(null);
|
|
@@ -2142,7 +2271,13 @@ function EmailFlow({ authOrigin, onSuccess }) {
|
|
|
2142
2271
|
method: "POST",
|
|
2143
2272
|
credentials: "include",
|
|
2144
2273
|
headers: { "Content-Type": "application/json" },
|
|
2145
|
-
body: JSON.stringify({
|
|
2274
|
+
body: JSON.stringify({
|
|
2275
|
+
email,
|
|
2276
|
+
code,
|
|
2277
|
+
token,
|
|
2278
|
+
// Multi-account add-mode · see WalletFlow.
|
|
2279
|
+
...add ? { add: true } : {}
|
|
2280
|
+
})
|
|
2146
2281
|
});
|
|
2147
2282
|
const json = await res.json();
|
|
2148
2283
|
if (!res.ok || !("ok" in json) || !json.ok || !json.account) {
|
|
@@ -2643,6 +2778,7 @@ exports.OcLinkedIdentities = OcLinkedIdentities;
|
|
|
2643
2778
|
exports.OcSessionProvider = OcSessionProvider;
|
|
2644
2779
|
exports.OcSignIn = OcSignIn;
|
|
2645
2780
|
exports.OcSignInButton = OcSignInButton;
|
|
2781
|
+
exports.buildAddAccountUrl = buildAddAccountUrl;
|
|
2646
2782
|
exports.buildSignInUrl = buildSignInUrl;
|
|
2647
2783
|
exports.fetchOcLinkedIdentities = fetchOcLinkedIdentities;
|
|
2648
2784
|
exports.handleSudoRequired = handleSudoRequired;
|