@orangecheck/auth-client 2.40.1 → 2.41.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/README.md +4 -1
- package/dist/bond.mjs +4 -4
- package/dist/{chunk-S6YP5Q5X.mjs → chunk-47DAA4BV.mjs} +2 -2
- package/dist/{chunk-O45WZCJI.mjs → chunk-F7O4OREM.mjs} +2 -2
- package/dist/{chunk-JMXIH6AH.mjs → chunk-FMPBHB3Q.mjs} +2 -2
- package/dist/{chunk-FKROF5NN.mjs → chunk-JLMDCC6K.mjs} +24 -12
- package/dist/chunk-JLMDCC6K.mjs.map +1 -0
- package/dist/{chunk-A4A6OEVX.mjs → chunk-PQHFAVVM.mjs} +1 -1
- package/dist/chunk-PQHFAVVM.mjs.map +1 -0
- package/dist/{chunk-LA2VDQSE.mjs → chunk-PYQTVOVH.mjs} +25 -8
- package/dist/chunk-PYQTVOVH.mjs.map +1 -0
- package/dist/{chunk-IYK4KW6B.mjs → chunk-UBDRTV5O.mjs} +2 -2
- package/dist/{chunk-AIP3GYPO.mjs → chunk-Y2PA7VC5.mjs} +3 -3
- package/dist/components.mjs +3 -3
- package/dist/index.d.ts +11 -1
- package/dist/index.js +45 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8 -8
- package/dist/linked-identities.mjs +3 -3
- package/dist/provider.mjs +2 -2
- package/dist/signin.mjs +4 -4
- package/dist/sudo.mjs +2 -2
- package/dist/types.mjs +1 -1
- package/dist/webauthn.mjs +3 -3
- package/package.json +1 -1
- package/dist/chunk-A4A6OEVX.mjs.map +0 -1
- package/dist/chunk-FKROF5NN.mjs.map +0 -1
- package/dist/chunk-LA2VDQSE.mjs.map +0 -1
- /package/dist/{chunk-S6YP5Q5X.mjs.map → chunk-47DAA4BV.mjs.map} +0 -0
- /package/dist/{chunk-O45WZCJI.mjs.map → chunk-F7O4OREM.mjs.map} +0 -0
- /package/dist/{chunk-JMXIH6AH.mjs.map → chunk-FMPBHB3Q.mjs.map} +0 -0
- /package/dist/{chunk-IYK4KW6B.mjs.map → chunk-UBDRTV5O.mjs.map} +0 -0
- /package/dist/{chunk-AIP3GYPO.mjs.map → chunk-Y2PA7VC5.mjs.map} +0 -0
package/README.md
CHANGED
|
@@ -112,7 +112,10 @@ useOcSession(): {
|
|
|
112
112
|
account: OcAccount | null;
|
|
113
113
|
error: Error | null;
|
|
114
114
|
refresh(): Promise<void>;
|
|
115
|
-
|
|
115
|
+
// Ends the session; a refusal or no answer changes nothing locally.
|
|
116
|
+
signOut(opts?: { scope?: 'all' | 'current' }): Promise<void>;
|
|
117
|
+
// The same, resolving to { ok: true } or { ok: false, reason, status? }.
|
|
118
|
+
trySignOut(opts?: { scope?: 'all' | 'current' }): Promise<OcSignOutResult>;
|
|
116
119
|
signInUrl: string;
|
|
117
120
|
}
|
|
118
121
|
|
package/dist/bond.mjs
CHANGED
|
@@ -4,13 +4,13 @@ import {
|
|
|
4
4
|
bondFloorsText,
|
|
5
5
|
bondRefusal,
|
|
6
6
|
fetchOcBond
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-UBDRTV5O.mjs";
|
|
8
|
+
import "./chunk-FMPBHB3Q.mjs";
|
|
9
|
+
import "./chunk-F7O4OREM.mjs";
|
|
10
10
|
import "./chunk-U7IUGDLW.mjs";
|
|
11
11
|
import "./chunk-H2TXOCXH.mjs";
|
|
12
12
|
import "./chunk-7RRPIDLX.mjs";
|
|
13
|
-
import "./chunk-
|
|
13
|
+
import "./chunk-PQHFAVVM.mjs";
|
|
14
14
|
import "./chunk-JTT77LMU.mjs";
|
|
15
15
|
import "./chunk-4BOO7EQR.mjs";
|
|
16
16
|
import "./chunk-E3QI365E.mjs";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
LinkPromptStep
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-FMPBHB3Q.mjs";
|
|
4
4
|
import {
|
|
5
5
|
addressInputValue
|
|
6
6
|
} from "./chunk-U7IUGDLW.mjs";
|
|
@@ -1222,4 +1222,4 @@ export {
|
|
|
1222
1222
|
looksLikeBitcoinAddress,
|
|
1223
1223
|
OcSignIn
|
|
1224
1224
|
};
|
|
1225
|
-
//# sourceMappingURL=chunk-
|
|
1225
|
+
//# sourceMappingURL=chunk-47DAA4BV.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resolveConfig
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-PQHFAVVM.mjs";
|
|
4
4
|
import {
|
|
5
5
|
withoutFragment
|
|
6
6
|
} from "./chunk-JTT77LMU.mjs";
|
|
@@ -37,4 +37,4 @@ export {
|
|
|
37
37
|
SUDO_ACCOUNT_MISMATCH_MESSAGE,
|
|
38
38
|
isSudoAccountMismatch
|
|
39
39
|
};
|
|
40
|
-
//# sourceMappingURL=chunk-
|
|
40
|
+
//# sourceMappingURL=chunk-F7O4OREM.mjs.map
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
SUDO_ACCOUNT_MISMATCH_MESSAGE,
|
|
3
3
|
handleSudoRequired,
|
|
4
4
|
isSudoAccountMismatch
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-F7O4OREM.mjs";
|
|
6
6
|
import {
|
|
7
7
|
addressInputValue
|
|
8
8
|
} from "./chunk-U7IUGDLW.mjs";
|
|
@@ -926,4 +926,4 @@ export {
|
|
|
926
926
|
ghostBtnStyle,
|
|
927
927
|
dangerBtnStyle
|
|
928
928
|
};
|
|
929
|
-
//# sourceMappingURL=chunk-
|
|
929
|
+
//# sourceMappingURL=chunk-FMPBHB3Q.mjs.map
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
buildAddAccountUrl,
|
|
4
4
|
buildSignInUrl,
|
|
5
5
|
resolveConfig
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-PQHFAVVM.mjs";
|
|
7
7
|
import {
|
|
8
8
|
keepFragmentOnReturnLinks,
|
|
9
9
|
restoreReturnFragment
|
|
@@ -213,13 +213,14 @@ function OcSessionProvider({
|
|
|
213
213
|
() => cfg.multiAccount ? installTabLinkDecorator(cfg.authOrigin) : void 0,
|
|
214
214
|
[cfg.authOrigin, cfg.multiAccount]
|
|
215
215
|
);
|
|
216
|
-
const
|
|
216
|
+
const trySignOut = React.useCallback(
|
|
217
217
|
async (opts) => {
|
|
218
218
|
const scope = opts?.scope ?? "all";
|
|
219
|
+
let res;
|
|
219
220
|
try {
|
|
220
221
|
const url = new URL(`${cfg.authOrigin}${cfg.logoutPath}`);
|
|
221
222
|
if (scope === "current") url.searchParams.set("scope", "current");
|
|
222
|
-
|
|
223
|
+
res = await fetch(url.toString(), {
|
|
223
224
|
method: "POST",
|
|
224
225
|
credentials: "include",
|
|
225
226
|
// Per-tab · carry the pin so scope='current' signs out
|
|
@@ -233,22 +234,31 @@ function OcSessionProvider({
|
|
|
233
234
|
// and the `.ochk.io` cookie may never get cleared.
|
|
234
235
|
keepalive: true
|
|
235
236
|
});
|
|
236
|
-
clearTabSession();
|
|
237
|
-
setTabPinned(false);
|
|
238
|
-
if (scope === "current" && res.ok) {
|
|
239
|
-
await refresh();
|
|
240
|
-
return;
|
|
241
|
-
}
|
|
242
237
|
} catch {
|
|
243
|
-
|
|
244
|
-
|
|
238
|
+
return { ok: false, reason: "unreachable" };
|
|
239
|
+
}
|
|
240
|
+
if (!res.ok && res.status !== 401) {
|
|
241
|
+
return { ok: false, reason: "refused", status: res.status };
|
|
242
|
+
}
|
|
243
|
+
clearTabSession();
|
|
244
|
+
setTabPinned(false);
|
|
245
|
+
if (scope === "current" && res.ok) {
|
|
246
|
+
await refresh();
|
|
247
|
+
return { ok: true };
|
|
245
248
|
}
|
|
246
249
|
setAccount(null);
|
|
247
250
|
setRoster([]);
|
|
248
251
|
setStatus("anonymous");
|
|
252
|
+
return { ok: true };
|
|
249
253
|
},
|
|
250
254
|
[cfg.authOrigin, cfg.logoutPath, refresh]
|
|
251
255
|
);
|
|
256
|
+
const signOut = React.useCallback(
|
|
257
|
+
async (opts) => {
|
|
258
|
+
await trySignOut(opts);
|
|
259
|
+
},
|
|
260
|
+
[trySignOut]
|
|
261
|
+
);
|
|
252
262
|
const switchAccount = React.useCallback(
|
|
253
263
|
async (didOc) => {
|
|
254
264
|
if (typeof window === "undefined") return;
|
|
@@ -327,6 +337,7 @@ function OcSessionProvider({
|
|
|
327
337
|
error,
|
|
328
338
|
refresh,
|
|
329
339
|
signOut,
|
|
340
|
+
trySignOut,
|
|
330
341
|
switchAccount,
|
|
331
342
|
addAccountUrl,
|
|
332
343
|
setDisplayIdentity,
|
|
@@ -340,6 +351,7 @@ function OcSessionProvider({
|
|
|
340
351
|
error,
|
|
341
352
|
refresh,
|
|
342
353
|
signOut,
|
|
354
|
+
trySignOut,
|
|
343
355
|
switchAccount,
|
|
344
356
|
addAccountUrl,
|
|
345
357
|
setDisplayIdentity,
|
|
@@ -368,4 +380,4 @@ export {
|
|
|
368
380
|
useOcSession,
|
|
369
381
|
useOptionalOcSession
|
|
370
382
|
};
|
|
371
|
-
//# sourceMappingURL=chunk-
|
|
383
|
+
//# sourceMappingURL=chunk-JLMDCC6K.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/provider.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n buildAddAccountUrl,\n buildSignInUrl,\n DEFAULT_CONFIG,\n DISPLAY_IDENTITY_KINDS,\n resolveConfig,\n type DisplayIdentity,\n type DisplayIdentityKind,\n type OcAccount,\n type OcAccountSummary,\n type OcAuthConfig,\n type OcSessionState,\n type OcSignOutResult,\n type OcSignOutScope,\n} from './types';\nimport { keepFragmentOnReturnLinks, restoreReturnFragment } from './return-to';\nimport {\n clearTabSession,\n consumeTabAccountHint,\n consumeTabAdoptMarker,\n installTabFetchInterceptor,\n installTabLinkDecorator,\n readTabSession,\n tabSessionHeader,\n writeTabSession,\n} from './tab-session';\n\nconst SessionContext = React.createContext<OcSessionState | null>(null);\n\n/** Back and forward; a router's move renders the tree again, which reads the address again. */\nfunction onHistory(change: () => void): () => void {\n window.addEventListener('popstate', change);\n return () => window.removeEventListener('popstate', change);\n}\nconst pageAddress = () => window.location.href.split('#')[0];\n/** The server has no page, and the browser's first render must say what the server's HTML said. */\nconst noPageYet = () => undefined;\n\ntype RawSigningMethod = 'fedimint_threshold' | 'fedimint_client' | 'bip322';\n\ninterface RawRosterEntry {\n did_oc?: string;\n didOc?: string;\n display_name?: string | null;\n displayName?: string | null;\n primary_btc?: string | null;\n primaryBtc?: string | null;\n display_identity?: { kind?: string; value?: string } | null;\n displayIdentity?: { kind?: string; value?: string } | null;\n last_seen_at?: string | null;\n lastSeenAt?: string | null;\n}\n\ninterface MeResponse {\n account?: {\n id?: string;\n account_id?: string;\n accountId?: string;\n did_oc?: string;\n didOc?: string;\n primary_btc?: string | null;\n primaryBtc?: string | null;\n has_email?: boolean;\n hasEmail?: boolean;\n display_name?: string | null;\n displayName?: string | null;\n nostr_npub?: string | null;\n nostrNpub?: string | null;\n home_federation_slug?: string | null;\n homeFederation?: string | null;\n signing_method?: RawSigningMethod | null;\n signingMethod?: RawSigningMethod | null;\n is_owner?: boolean;\n isOwner?: boolean;\n display_identity?: { kind?: string; value?: string } | null;\n displayIdentity?: { kind?: string; value?: string } | null;\n };\n /** Multi-account roster · other accounts in this browser. Absent\n * on hosts that haven't deployed the multi-account migration yet\n * — treated as `[]` (single-account fallback). */\n roster?: RawRosterEntry[];\n}\n\n/**\n * Resolve the badge identity from a `/api/auth/me` account payload.\n * Total: returns the carried `{kind,value}` when well-formed, else\n * `{kind:'did',value:didOc}` — so accounts that never promoted, and\n * sessions minted before the field shipped, degrade cleanly.\n */\nfunction normalizeDisplayIdentity(\n raw: NonNullable<MeResponse['account']>,\n didOc: string\n): DisplayIdentity {\n const di = raw.display_identity ?? raw.displayIdentity;\n if (\n di &&\n typeof di === 'object' &&\n typeof di.value === 'string' &&\n di.value.length > 0 &&\n typeof di.kind === 'string' &&\n (DISPLAY_IDENTITY_KINDS as readonly string[]).includes(di.kind)\n ) {\n return { kind: di.kind as DisplayIdentityKind, value: di.value };\n }\n return { kind: 'did', value: didOc };\n}\n\n/**\n * Multi-account · normalize one roster entry from /api/auth/me. Drops\n * entries with no did_oc (defensive — the host shouldn't emit those).\n */\nfunction normalizeRosterEntry(raw: RawRosterEntry): OcAccountSummary | null {\n const didOc = raw.did_oc ?? raw.didOc;\n if (!didOc) return null;\n const di = raw.display_identity ?? raw.displayIdentity;\n const displayIdentity: DisplayIdentity =\n di &&\n typeof di === 'object' &&\n typeof di.value === 'string' &&\n di.value.length > 0 &&\n typeof di.kind === 'string' &&\n (DISPLAY_IDENTITY_KINDS as readonly string[]).includes(di.kind)\n ? { kind: di.kind as DisplayIdentityKind, value: di.value }\n : { kind: 'did', value: didOc };\n return {\n didOc,\n displayName: raw.display_name ?? raw.displayName ?? null,\n primaryBtc: raw.primary_btc ?? raw.primaryBtc ?? null,\n displayIdentity,\n lastSeenAt: raw.last_seen_at ?? raw.lastSeenAt ?? null,\n };\n}\n\n/**\n * Multi-account · fetch the roster from the AUTH HOST cross-origin.\n *\n * Consumer subdomains expose a LOCAL `/api/auth/me` that verifies the JWT\n * but has no database, so it never carries the `roster` (which is host DB\n * state). When the local /me comes back authenticated with an empty roster,\n * we source it from the host directly — the same credentialed cross-origin\n * pattern this provider already uses for logout + account PATCH, and the\n * host already serves `.ochk.io` consumers via CORS.\n *\n * Best-effort by construction: any failure resolves to `[]`, so a roster\n * fetch can never change the authenticated state derived from the local /me.\n */\n/** How long a session check may take before the page stops waiting on it. */\nexport const ME_TIMEOUT_MS = 10_000;\n\n/** `AbortSignal.timeout` where the browser has it, a timer where it does not. */\nfunction timeoutSignal(ms: number): AbortSignal {\n if (typeof AbortSignal.timeout === 'function') return AbortSignal.timeout(ms);\n const controller = new AbortController();\n setTimeout(() => controller.abort(), ms);\n return controller.signal;\n}\n\nfunction isTimeout(err: unknown): boolean {\n const name = (err as { name?: unknown } | null)?.name;\n return name === 'TimeoutError' || name === 'AbortError';\n}\n\nasync function fetchHostRoster(cfg: Required<OcAuthConfig>): Promise<OcAccountSummary[]> {\n try {\n // Per-tab · carry the pin so the host computes \"peers\" relative\n // to THIS tab's effective account, not the cookie default.\n const res = await fetch(`${cfg.authOrigin}${cfg.mePath}`, {\n method: 'GET',\n credentials: 'include',\n headers: { Accept: 'application/json', ...tabSessionHeader() },\n signal: timeoutSignal(ME_TIMEOUT_MS),\n });\n if (!res.ok) return [];\n const body = (await res.json()) as MeResponse;\n return Array.isArray(body.roster)\n ? body.roster\n .map(normalizeRosterEntry)\n .filter((r): r is OcAccountSummary => r !== null)\n : [];\n } catch {\n return [];\n }\n}\n\nfunction normalizeAccount(raw: MeResponse['account']): OcAccount | null {\n if (!raw) return null;\n const didOc = raw.did_oc ?? raw.didOc;\n const accountId = raw.id ?? raw.account_id ?? raw.accountId;\n if (!didOc || !accountId) return null;\n return {\n accountId,\n didOc,\n primaryBtc: raw.primary_btc ?? raw.primaryBtc ?? null,\n hasEmail: raw.has_email ?? raw.hasEmail ?? false,\n displayName: raw.display_name ?? raw.displayName ?? null,\n nostrNpub: raw.nostr_npub ?? raw.nostrNpub ?? null,\n homeFederation: raw.home_federation_slug ?? raw.homeFederation ?? null,\n signingMethod: raw.signing_method ?? raw.signingMethod ?? null,\n isOwner: Boolean(raw.is_owner ?? raw.isOwner ?? false),\n displayIdentity: normalizeDisplayIdentity(raw, didOc),\n };\n}\n\nexport interface OcSessionProviderProps {\n children: React.ReactNode;\n config?: OcAuthConfig;\n /**\n * Optional return URL passed to the sign-in page. Defaults to the\n * current page. Its fragment is never sent: it is kept in this tab and\n * restored on return (./return-to).\n */\n defaultReturnTo?: string;\n}\n\n/**\n * Top-level provider that exposes the cross-subdomain oc_session to every\n * component below it. Mount once, near the root of your tree.\n */\nexport function OcSessionProvider({\n children,\n config,\n defaultReturnTo,\n}: OcSessionProviderProps): React.ReactElement {\n const cfg = React.useMemo(() => resolveConfig(config), [config]);\n // Back from a sign-in or a check: put back the fragment its return\n // address left in this tab, before any page below reads the address.\n // The adoption marker the auth host appends goes first, so the fragment\n // takes its place. Children's effects run before this provider's, so\n // this happens during the first render, once; both calls are idempotent.\n React.useState(() => {\n if (typeof window !== 'undefined') {\n consumeTabAdoptMarker();\n restoreReturnFragment();\n }\n return null;\n });\n const [account, setAccount] = React.useState<OcAccount | null>(null);\n const [roster, setRoster] = React.useState<OcAccountSummary[]>([]);\n const [status, setStatus] = React.useState<OcSessionState['status']>('loading');\n const [error, setError] = React.useState<Error | null>(null);\n const [tabPinned, setTabPinned] = React.useState(false);\n\n // Per-tab · mint a pin for this tab via the host. Called once per\n // tab on first authenticated resolve, so a later switch in ANOTHER\n // tab can't yank this one — it keeps presenting its own token.\n // Best-effort: a host that predates `/api/auth/tab` (or a network\n // failure) leaves the tab unpinned, which is exactly the legacy\n // cookie-following behavior.\n const pinInFlightRef = React.useRef(false);\n const pinThisTab = React.useCallback(\n async (didOc: string) => {\n if (!cfg.multiAccount || pinInFlightRef.current || readTabSession()) return;\n pinInFlightRef.current = true;\n try {\n const res = await fetch(`${cfg.authOrigin}/api/auth/tab`, {\n method: 'POST',\n credentials: 'include',\n headers: { Accept: 'application/json' },\n });\n if (!res.ok) return;\n const body = (await res.json()) as {\n ok?: boolean;\n token?: string;\n account?: { did_oc?: string };\n };\n // Only pin when the host minted for the account this tab\n // just resolved — a cookie flip racing between our /me and\n // /tab calls must not pin the WRONG account.\n if (\n body.ok &&\n typeof body.token === 'string' &&\n body.account?.did_oc === didOc\n ) {\n writeTabSession({ token: body.token, didOc });\n setTabPinned(true);\n }\n } catch {\n // best-effort by construction\n } finally {\n pinInFlightRef.current = false;\n }\n },\n [cfg.authOrigin, cfg.multiAccount]\n );\n\n const refresh = React.useCallback(async () => {\n if (typeof window === 'undefined') return;\n try {\n let pin = readTabSession();\n // A check that never answers would leave the page loading for good;\n // past the timeout it is an error, which every site already shows.\n let res = await fetch(cfg.mePath, {\n method: 'GET',\n credentials: 'include',\n headers: { Accept: 'application/json', ...tabSessionHeader() },\n signal: timeoutSignal(ME_TIMEOUT_MS),\n });\n // Per-tab · 401 with a pin present means the pinned token is\n // dead (expired, or revoked and rejected by the host). Drop\n // the pin and retry once as the browser-default account.\n if (res.status === 401 && pin) {\n clearTabSession();\n pin = null;\n setTabPinned(false);\n res = await fetch(cfg.mePath, {\n method: 'GET',\n credentials: 'include',\n headers: { Accept: 'application/json' },\n signal: timeoutSignal(ME_TIMEOUT_MS),\n });\n }\n if (res.status === 401) {\n setAccount(null);\n setRoster([]);\n setStatus('anonymous');\n setError(null);\n return;\n }\n if (!res.ok) {\n setStatus('error');\n setError(new Error(`me endpoint returned ${res.status}`));\n return;\n }\n const body = (await res.json()) as MeResponse;\n const acct = normalizeAccount(body.account);\n // Per-tab reconciliation · the server answered as a different\n // account than the pin → it doesn't honor `x-oc-tab-session`\n // yet (pre-migration deploy). Drop the pin: the UI must never\n // display an account the server isn't acting as.\n if (acct && pin && acct.didOc !== pin.didOc) {\n clearTabSession();\n pin = null;\n }\n setTabPinned(pin !== null);\n const rosterEntries = Array.isArray(body.roster)\n ? body.roster\n .map(normalizeRosterEntry)\n .filter((r): r is OcAccountSummary => r !== null)\n : [];\n setAccount(acct);\n setRoster(rosterEntries);\n setStatus(acct ? 'authenticated' : 'anonymous');\n setError(null);\n\n // Per-tab · authenticated but unpinned → pin this tab to the\n // account it just resolved (fire-and-forget).\n if (acct && !pin) void pinThisTab(acct.didOc);\n\n // Multi-account · the local /me carried no roster (the standard\n // case on consumer subdomains, whose local /me has no DB). When\n // we're authenticated and NOT already on the auth host, source\n // the roster from the host so the §accounts switcher lights up.\n // Best-effort: never touches account/status on failure.\n const currentOrigin =\n typeof window !== 'undefined' ? window.location.origin : null;\n if (\n cfg.multiAccount &&\n acct &&\n rosterEntries.length === 0 &&\n currentOrigin !== null &&\n !cfg.authOrigin.startsWith(currentOrigin)\n ) {\n const peers = await fetchHostRoster(cfg);\n if (peers.length > 0) setRoster(peers);\n }\n } catch (err) {\n setStatus('error');\n setError(\n isTimeout(err)\n ? new Error(`me endpoint did not answer within ${ME_TIMEOUT_MS / 1000}s`)\n : err instanceof Error\n ? err\n : new Error(String(err))\n );\n }\n }, [cfg, pinThisTab]);\n\n React.useEffect(() => {\n let cancelled = false;\n // Post-ceremony adoption · the auth host appends `#oc-adopt` when\n // returning from a sign-in/add ceremony: the user expects THIS tab\n // to become the account they just authenticated, so a stale pin\n // must not survive the round trip.\n consumeTabAdoptMarker();\n void (async () => {\n // New-tab inheritance · if the opener stamped `#oc-as=<did>`,\n // adopt that account BEFORE the first /me fetch so this tab\n // resolves as the opener's account, not the cookie default.\n if (cfg.multiAccount) await consumeTabAccountHint(cfg.authOrigin);\n if (!cancelled) void refresh();\n })();\n return () => {\n cancelled = true;\n };\n }, [refresh, cfg.authOrigin, cfg.multiAccount]);\n\n // A link that brings the browser back here keeps this page's fragment\n // in the tab, since its return_to cannot carry it.\n React.useEffect(() => keepFragmentOnReturnLinks(), []);\n\n // Per-tab · attach the pin to every same-site fetch so app-level data\n // calls execute as the account this tab displays. Scoped + reversible;\n // see installTabFetchInterceptor for the conservative rules.\n React.useEffect(\n () => (cfg.multiAccount ? installTabFetchInterceptor(cfg.authOrigin) : undefined),\n [cfg.authOrigin, cfg.multiAccount]\n );\n\n // Per-tab · stamp this tab's effective account onto outgoing\n // family-origin links so a new/cross-subdomain tab inherits it\n // instead of the shared cookie default. See installTabLinkDecorator.\n React.useEffect(\n () => (cfg.multiAccount ? installTabLinkDecorator(cfg.authOrigin) : undefined),\n [cfg.authOrigin, cfg.multiAccount]\n );\n\n const trySignOut = React.useCallback(\n async (opts?: { scope?: OcSignOutScope }): Promise<OcSignOutResult> => {\n const scope: OcSignOutScope = opts?.scope ?? 'all';\n let res: Response;\n try {\n const url = new URL(`${cfg.authOrigin}${cfg.logoutPath}`);\n if (scope === 'current') url.searchParams.set('scope', 'current');\n res = await fetch(url.toString(), {\n method: 'POST',\n credentials: 'include',\n // Per-tab · carry the pin so scope='current' signs out\n // the account THIS tab is operating as, not whichever\n // account the shared cookie happens to point at.\n headers: { ...tabSessionHeader() },\n // `keepalive` lets the logout round-trip complete even if\n // the caller hard-navigates away in the same tick (e.g.\n // `<OcAccountMenu>` redirects home immediately on sign-out).\n // Without it the in-flight request is cancelled on unload\n // and the `.ochk.io` cookie may never get cleared.\n keepalive: true,\n });\n } catch {\n // The auth host never answered, so the session may well live on.\n // Nothing local changes: showing \"signed out\" here would be false.\n return { ok: false, reason: 'unreachable' };\n }\n // 401: no session reached the host, so there is none to end.\n if (!res.ok && res.status !== 401) {\n return { ok: false, reason: 'refused', status: res.status };\n }\n // The signed-out account's token is dead — the pin must not outlive it.\n clearTabSession();\n setTabPinned(false);\n // Multi-account: with scope='current', the server may have\n // switched the active session to a roster peer instead of\n // clearing the cookie. Re-fetch /api/auth/me so this\n // provider reflects the new active account; if the body\n // says `switched_to !== null`, refresh resolves to the\n // peer, otherwise it resolves to anonymous.\n if (scope === 'current' && res.ok) {\n await refresh();\n return { ok: true };\n }\n setAccount(null);\n setRoster([]);\n setStatus('anonymous');\n return { ok: true };\n },\n [cfg.authOrigin, cfg.logoutPath, refresh]\n );\n // The long-standing call: same type, but it no longer reports \"signed out\" when\n // the auth host did not end the session. trySignOut says what happened.\n const signOut = React.useCallback(\n async (opts?: { scope?: OcSignOutScope }): Promise<void> => {\n await trySignOut(opts);\n },\n [trySignOut]\n );\n\n const switchAccount = React.useCallback(\n async (didOc: string) => {\n if (typeof window === 'undefined') return;\n const res = await fetch(`${cfg.authOrigin}/api/auth/switch`, {\n method: 'POST',\n credentials: 'include',\n headers: { 'Content-Type': 'application/json', ...tabSessionHeader() },\n body: JSON.stringify({ did_oc: didOc }),\n });\n if (!res.ok) {\n let reason = `http_${res.status}`;\n try {\n const body = (await res.json()) as { reason?: string };\n if (body.reason) reason = body.reason;\n } catch {\n // keep http_ fallback\n }\n throw new Error(`[@orangecheck/auth-client] switchAccount failed: ${reason}`);\n }\n // Per-tab · pin THIS tab to the switch target using the fresh\n // JWT the host echoes in the body. The host has also flipped\n // the shared cookie — the default for FUTURE tabs — but other\n // open tabs keep their own pins and are not yanked. Pin to the\n // did the SERVER minted for (merge-graph collapse may differ\n // from the requested did).\n try {\n const body = (await res.json()) as {\n token?: string;\n account?: { did_oc?: string };\n };\n if (typeof body.token === 'string' && body.account?.did_oc) {\n writeTabSession({ token: body.token, didOc: body.account.did_oc });\n setTabPinned(true);\n }\n } catch {\n // body unreadable — cookie still flipped; refresh resolves it\n }\n // Re-fetch /me to surface the new active account + freshly\n // computed roster (the previous active account is now a peer,\n // swap is symmetric).\n await refresh();\n },\n [cfg.authOrigin, refresh]\n );\n\n const addAccountUrl = React.useCallback(\n (returnTo?: string) => {\n const rt =\n returnTo ?? (typeof window !== 'undefined' ? window.location.href : undefined);\n return buildAddAccountUrl(cfg, rt);\n },\n [cfg]\n );\n\n const setDisplayIdentity = React.useCallback(\n async (kind: DisplayIdentityKind) => {\n if (typeof window === 'undefined') return;\n // PATCH the auth host directly (family-CORS). It writes the\n // pref, re-mints the `.ochk.io` session cookie with the new\n // `display_identity` claim, and Set-Cookies it back — so the\n // choice propagates to every subdomain. Then refresh so this\n // session reflects it immediately.\n const res = await fetch(`${cfg.authOrigin}/api/auth/account`, {\n method: 'PATCH',\n credentials: 'include',\n headers: { 'Content-Type': 'application/json', ...tabSessionHeader() },\n body: JSON.stringify({ display_identity: kind }),\n });\n if (!res.ok) {\n let reason = `http_${res.status}`;\n try {\n const body = (await res.json()) as { reason?: string };\n if (body.reason) reason = body.reason;\n } catch {\n // keep the http_ fallback\n }\n throw new Error(`[@orangecheck/auth-client] setDisplayIdentity failed: ${reason}`);\n }\n // Per-tab · the PATCH re-mints; when this tab is pinned the\n // host echoes the fresh token in the body (it only rewrites\n // the shared cookie when the cookie account was the actor).\n // Re-pin so the tab carries the updated claims.\n try {\n const body = (await res.json()) as {\n token?: string;\n account?: { did_oc?: string };\n };\n const pin = readTabSession();\n if (\n pin &&\n typeof body.token === 'string' &&\n body.account?.did_oc === pin.didOc\n ) {\n writeTabSession({ token: body.token, didOc: pin.didOc });\n }\n } catch {\n // body unreadable — refresh below still reconciles state\n }\n await refresh();\n },\n [cfg.authOrigin, refresh]\n );\n\n // Read through the store, not from the window as this renders: a server-rendered\n // link keeps the server's href when hydrating, so the page is added after.\n const here = React.useSyncExternalStore(onHistory, pageAddress, noPageYet);\n const value = React.useMemo<OcSessionState>(() => {\n const returnTo = defaultReturnTo ?? here;\n return {\n status,\n account,\n roster,\n tabPinned,\n error,\n refresh,\n signOut,\n trySignOut,\n switchAccount,\n addAccountUrl,\n setDisplayIdentity,\n signInUrl: buildSignInUrl(cfg, returnTo),\n };\n }, [\n status,\n account,\n roster,\n tabPinned,\n error,\n refresh,\n signOut,\n trySignOut,\n switchAccount,\n addAccountUrl,\n setDisplayIdentity,\n cfg,\n defaultReturnTo,\n here,\n ]);\n\n return <SessionContext.Provider value={value}>{children}</SessionContext.Provider>;\n}\n\n/**\n * Access the current cross-subdomain oc_session. Must be called inside\n * an `<OcSessionProvider>`.\n */\nexport function useOcSession(): OcSessionState {\n const ctx = React.useContext(SessionContext);\n if (!ctx) {\n throw new Error(\n '[@orangecheck/auth-client] useOcSession() must be called inside <OcSessionProvider>'\n );\n }\n return ctx;\n}\n\n/**\n * Non-throwing variant — returns `null` if called outside a provider.\n * Useful for libraries that want to read the session *if it exists* but\n * shouldn't crash on apps that haven't opted in.\n */\nexport function useOptionalOcSession(): OcSessionState | null {\n return React.useContext(SessionContext);\n}\n\nexport { DEFAULT_CONFIG };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,YAAY,WAAW;AAwmBZ;AA3kBX,IAAM,iBAAuB,oBAAqC,IAAI;AAGtE,SAAS,UAAU,QAAgC;AAC/C,SAAO,iBAAiB,YAAY,MAAM;AAC1C,SAAO,MA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ACA,OAAO,KAAK,UAAU,YACtB,KAAK,SAAS,WAAW,IAAI,OAC/B;AACE,0BAAgB,EAAE,OAAO,KAAK,OAAO,OAAO,IAAI,MAAM,CAAC;AAAA,QAC3D;AAAA,MACJ,QAAQ;AAAA,MAER;AACA,YAAM,QAAQ;AAAA,IAClB;AAAA,IACA,CAAC,IAAI,YAAY,OAAO;AAAA,EAC5B;AAIA,QAAM,OAAa,2BAAqB,WAAW,aAAa,SAAS;AACzE,QAAM,QAAc,cAAwB,MAAM;AAC9C,UAAM,WAAW,mBAAmB;AACpC,WAAO;AAAA,MACH;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,WAAW,eAAe,KAAK,QAAQ;AAAA,IAC3C;AAAA,EACJ,GAAG;AAAA,IACC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACJ,CAAC;AAED,SAAO,oBAAC,eAAe,UAAf,EAAwB,OAAe,UAAS;AAC5D;AAMO,SAAS,eAA+B;AAC3C,QAAM,MAAY,iBAAW,cAAc;AAC3C,MAAI,CAAC,KAAK;AACN,UAAM,IAAI;AAAA,MACN;AAAA,IACJ;AAAA,EACJ;AACA,SAAO;AACX;AAOO,SAAS,uBAA8C;AAC1D,SAAa,iBAAW,cAAc;AAC1C;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import { stripFragment } from './return-to';\n\n/**\n * The kinds of identity a user can surface as their account-badge\n * label. `did` is the canonical `did:oc` identifier — always available\n * and the ultimate fallback; the other three are linked identities a\n * user may or may not have.\n */\nexport const DISPLAY_IDENTITY_KINDS = ['did', 'btc', 'email', 'nostr'] as const;\nexport type DisplayIdentityKind = (typeof DISPLAY_IDENTITY_KINDS)[number];\n\n/**\n * The identity a user has chosen to show in their account badge — the\n * collapsed label every family site renders instead of the raw\n * `did:oc`. Carried as a JWT claim by the auth host, so the choice is\n * consistent across every `.ochk.io` subdomain with no round-trip.\n *\n * `kind` is which identity; `value` is the full, renderable value (the\n * `did:oc`, the Bitcoin address, the email, or the npub). Integrators\n * rendering their own chip read `useOcSession().account.displayIdentity`\n * — it is always populated (it defaults to the `did`).\n */\nexport interface DisplayIdentity {\n kind: DisplayIdentityKind;\n value: string;\n}\n\nexport interface OcAccount {\n accountId: string;\n /**\n * Opaque public-facing identifier · `did:oc:<32-hex>`. The sole\n * user identifier post auth-refactor. Stable across linking\n * events. Per AUTH-REFACTOR-PLAN.md §2.1.\n */\n didOc: string;\n /**\n * Primary linked Bitcoin address, plaintext, when the user has\n * one — null for email-OTP users until they link a btc address.\n * Surfaced inline by the auth host's /api/auth/me so consumer\n * dashboards can render the user's own footprint without a\n * second round-trip through /api/auth/identities.\n */\n primaryBtc?: string | null;\n /**\n * True when the user has a primary email linked. Plaintext is\n * fetchable on demand via /api/auth/identities; not surfaced\n * here.\n */\n hasEmail?: boolean;\n displayName?: string | null;\n nostrNpub?: string | null;\n /**\n * @deprecated Always null: the auth host no longer sets it. Where a\n * person's sats sit is me.ochk.io's to say (`/api/me/balance`).\n */\n homeFederation?: string | null;\n /**\n * Whether the account signs with its own Bitcoin key, derived by the\n * auth host from its verified linked identities; no one can set it.\n * 'bip322' when a BIP-322-verified address is linked, otherwise\n * 'fedimint_threshold'. 'fedimint_client' is reserved and never set.\n * It says who holds the signing key, never who holds the sats.\n */\n signingMethod?: 'fedimint_threshold' | 'fedimint_client' | 'bip322' | null;\n /**\n * Best-effort owner-flag · true when the user's `did_oc` was on\n * the auth host's `OWNER_OC_ADDRESSES` env at the time the JWT\n * was minted. Surfaced so the family-switcher and other low-\n * stakes UX can render owner-only affordances (e.g. an\n * analytics.ochk.io entry visible only to owners).\n *\n * **NOT A SECURITY BOUNDARY.** Sensitive surfaces — including\n * analytics.ochk.io itself — re-check the live env against\n * `session.did_oc` server-side on every request. If an owner is\n * removed from the env, their JWT may keep `isOwner: true` for\n * up to the JWT lifetime (~30d) but every gated action they\n * attempt re-fails. The flag exists purely so we can show or\n * hide UX hints without an extra round-trip on every page load.\n *\n * Treat absence as `false`.\n */\n isOwner?: boolean;\n /**\n * The identity the user has chosen to show as their account-badge\n * label — `{ kind, value }`. **Always populated**: when the user\n * has never promoted an identity (and on sessions minted before\n * the feature shipped) this is `{ kind:'did', value:didOc }`.\n *\n * `<OcAccountMenu>` renders `value` (shortened) as the collapsed\n * badge label. Integrators rendering their own chip read this\n * directly; change it with `useOcSession().setDisplayIdentity()`.\n */\n displayIdentity: DisplayIdentity;\n}\n\nexport type OcSessionStatus = 'loading' | 'authenticated' | 'anonymous' | 'error';\n\n/**\n * Multi-account roster · summary of another account this browser has\n * signed into and can switch to without re-authenticating. Surfaced by\n * `<OcAccountMenu>` in the `§ accounts` section. Returned by the auth\n * host's `/api/auth/me` as `roster: [...]` (an empty array on single-\n * account or pre-multi-account sessions).\n *\n * Sessions for peer accounts stay alive in the auth host's DB for the\n * normal 30-day window; once expired, the peer falls out of the roster\n * and the user must re-authenticate to bring it back in.\n */\nexport interface OcAccountSummary {\n didOc: string;\n displayName: string | null;\n primaryBtc: string | null;\n displayIdentity: DisplayIdentity;\n /** ISO timestamp of the last verified request on this account's\n * session row, or null if never touched. */\n lastSeenAt: string | null;\n}\n\n/**\n * Scope hint for `signOut()` in a multi-account browser.\n *\n * - 'all' · sign out of every account in this browser's roster\n * (the default; matches the historical single-account\n * behavior of \"clear the cookie\").\n * - 'current' · sign out of just the active account; if the roster\n * has other accounts, the auth host hands you off to\n * the next-most-recent one without a re-auth.\n */\nexport type OcSignOutScope = 'all' | 'current';\n\n/**\n * What `signOut()` did. `ok: false` means the session may still be live: the\n * auth host did not answer (`'unreachable'`) or refused (`'refused'`, with its\n * HTTP status). The provider then changes nothing, so the page still shows the\n * signed-in account; tell the person it did not work and let them try again.\n */\nexport type OcSignOutResult =\n | { ok: true }\n | { ok: false; reason: 'unreachable' | 'refused'; status?: number };\n\nexport interface OcSessionState {\n status: OcSessionStatus;\n account: OcAccount | null;\n /**\n * Multi-account · other accounts the user has signed into in this\n * browser. `[]` for single-account sessions and for tokens minted\n * before multi-account shipped. The active account (`account`\n * above) is NOT included — these are the *switch targets*.\n */\n roster: OcAccountSummary[];\n /**\n * Per-tab pinning · `true` when this tab holds its own session\n * token (sessionStorage) and operates as `account` independently of\n * the shared `.ochk.io` cookie — i.e. switching accounts in another\n * tab will NOT change this tab's identity. `false` on hosts that\n * predate `/api/auth/tab`, in privacy modes without sessionStorage,\n * and while anonymous.\n */\n tabPinned: boolean;\n /** `null` while loading; an `Error` instance when `status === 'error'`. */\n error: Error | null;\n /** Re-fetch the session. Useful after sign-in/sign-out happens elsewhere. */\n refresh: () => Promise<void>;\n /**\n * Trigger a sign-out. By default signs out of EVERY account in the\n * roster (back-compat); pass `{ scope: 'current' }` to sign out of\n * just the active account and stay logged into the next peer. When the\n * auth host does not end the session (no answer, or an error status),\n * nothing changes locally and the account stays shown; it never rejects.\n * Use {@link trySignOut} to learn which, and tell the person.\n */\n signOut: (opts?: { scope?: OcSignOutScope }) => Promise<void>;\n /**\n * `signOut`, resolving to what the auth host did: `{ ok: true }` once the\n * session has ended, else `{ ok: false, reason }` with the session still live.\n */\n trySignOut: (opts?: { scope?: OcSignOutScope }) => Promise<OcSignOutResult>;\n /**\n * Multi-account · flip the active session to a different account\n * in the roster. Resolves once the new cookie has been set and\n * the session has been re-fetched. Throws if the target `did_oc`\n * isn't in the current roster (the user must add it via\n * {@link addAccount} first) or if the auth host is unreachable.\n */\n switchAccount: (didOc: string) => Promise<void>;\n /**\n * Multi-account · open the sign-in flow in \"add\" mode — the new\n * account joins the current browser's roster instead of replacing\n * it. Returns the URL to navigate to (so callers can mount it in\n * a popup or hard-navigate as they prefer); pass `returnTo` to\n * route back to a specific page after the add completes.\n */\n addAccountUrl: (returnTo?: string) => string;\n /**\n * Promote a linked identity to be the account-badge label across\n * every `.ochk.io` site. PATCHes the auth host, which re-mints the\n * session cookie with the new `display_identity` claim, then\n * `refresh()`es this session. Rejects if the chosen kind is not a\n * verified identity on the account (`btc` / `email` / `nostr` must\n * actually be linked; `did` is always valid).\n */\n setDisplayIdentity: (kind: DisplayIdentityKind) => Promise<void>;\n /** URL to navigate to for sign-in on the auth host. */\n signInUrl: string;\n}\n\nexport interface OcAuthConfig {\n /**\n * Origin of the auth host — the subdomain that runs the sign-in UI,\n * issues session cookies, and exposes `/api/auth/me` + `/api/auth/logout`.\n *\n * Defaults to `https://ochk.io`. Override in preview/dev.\n */\n authOrigin?: string;\n /**\n * Path on the auth host that accepts `?return_to=<url>` and drives the\n * sign-in flow. The page offers two paths in-place:\n *\n * - email + OTP (default — no wallet and no key of the user's own;\n * identity is `did:email:<sha256(email)>`)\n * - BIP-322 wallet sign (paste address → in-page wallet sign;\n * identity is the Bitcoin address itself)\n *\n * Defaults to `/signin`.\n */\n signInPath?: string;\n /**\n * Local path (same origin as the current app) that exposes the\n * crypto-verified session. If your app ships one at `/api/auth/me`,\n * leave as default. Returns 200 `{ account }` or 401.\n */\n mePath?: string;\n /**\n * Path on the auth host to hit to clear the session cookie.\n * Defaults to `/api/auth/logout`. Called with `credentials: 'include'`\n * so the `.ochk.io` cookie is sent along.\n */\n logoutPath?: string;\n /**\n * Multi-account and per-tab pinning against the auth host. Defaults to\n * `true`. A site that holds its own single session cookie (ochk.app)\n * sets `false`: no tab pins, no account hints or link stamping, and no\n * roster fetched from the host.\n */\n multiAccount?: boolean;\n}\n\nexport const DEFAULT_CONFIG: Required<OcAuthConfig> = {\n authOrigin: 'https://ochk.io',\n signInPath: '/signin',\n mePath: '/api/auth/me',\n logoutPath: '/api/auth/logout',\n multiAccount: true,\n};\n\nexport function resolveConfig(cfg: OcAuthConfig | undefined): Required<OcAuthConfig> {\n return { ...DEFAULT_CONFIG, ...(cfg ?? {}) };\n}\n\n/**\n * The sign-in URL on the auth host. `returnTo` goes without its fragment;\n * OcSessionProvider keeps the fragment when the link is followed.\n */\nexport function buildSignInUrl(cfg: Required<OcAuthConfig>, returnTo?: string): string {\n const base = `${cfg.authOrigin}${cfg.signInPath}`;\n if (!returnTo) return base;\n const u = new URL(base);\n u.searchParams.set('return_to', stripFragment(returnTo));\n return u.toString();\n}\n\n/**\n * Multi-account · build the URL for the \"add another account\" entry\n * point. Same as {@link buildSignInUrl} but appends `?add=1` so the\n * sign-in page knows to preserve the current roster (the new account\n * is appended; the previously-active account stays signed in too and\n * remains switch-target reachable).\n */\nexport function buildAddAccountUrl(cfg: Required<OcAuthConfig>, returnTo?: string): string {\n const u = new URL(buildSignInUrl(cfg, returnTo));\n u.searchParams.set('add', '1');\n return u.toString();\n}\n"],"mappings":";;;;;AAQO,IAAM,yBAAyB,CAAC,OAAO,OAAO,SAAS,OAAO;AA+O9D,IAAM,iBAAyC;AAAA,EAClD,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,cAAc;AAClB;AAEO,SAAS,cAAc,KAAuD;AACjF,SAAO,EAAE,GAAG,gBAAgB,GAAI,OAAO,CAAC,EAAG;AAC/C;AAMO,SAAS,eAAe,KAA6B,UAA2B;AACnF,QAAM,OAAO,GAAG,IAAI,UAAU,GAAG,IAAI,UAAU;AAC/C,MAAI,CAAC,SAAU,QAAO;AACtB,QAAM,IAAI,IAAI,IAAI,IAAI;AACtB,IAAE,aAAa,IAAI,aAAa,cAAc,QAAQ,CAAC;AACvD,SAAO,EAAE,SAAS;AACtB;AASO,SAAS,mBAAmB,KAA6B,UAA2B;AACvF,QAAM,IAAI,IAAI,IAAI,eAAe,KAAK,QAAQ,CAAC;AAC/C,IAAE,aAAa,IAAI,OAAO,GAAG;AAC7B,SAAO,EAAE,SAAS;AACtB;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useOcSession
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-JLMDCC6K.mjs";
|
|
4
4
|
|
|
5
5
|
// src/components.tsx
|
|
6
6
|
import * as React from "react";
|
|
@@ -30,9 +30,10 @@ function OcAccountChip({
|
|
|
30
30
|
popoverClassName,
|
|
31
31
|
menuItemClassName
|
|
32
32
|
}) {
|
|
33
|
-
const { status, account, signInUrl: sessionSignInUrl,
|
|
33
|
+
const { status, account, signInUrl: sessionSignInUrl, trySignOut } = useOcSession();
|
|
34
34
|
const signInUrl = signInUrlOverride ?? sessionSignInUrl;
|
|
35
35
|
const [open, setOpen] = React.useState(false);
|
|
36
|
+
const [signOutFailed, setSignOutFailed] = React.useState(false);
|
|
36
37
|
const wrapRef = React.useRef(null);
|
|
37
38
|
React.useEffect(() => {
|
|
38
39
|
if (!open) return;
|
|
@@ -244,7 +245,8 @@ function OcAccountChip({
|
|
|
244
245
|
role: "menuitem",
|
|
245
246
|
onClick: () => {
|
|
246
247
|
setOpen(false);
|
|
247
|
-
|
|
248
|
+
setSignOutFailed(false);
|
|
249
|
+
void trySignOut().then((r) => setSignOutFailed(!r.ok));
|
|
248
250
|
},
|
|
249
251
|
className: menuItemClassName,
|
|
250
252
|
"data-oc-account-chip-item": "",
|
|
@@ -279,11 +281,23 @@ function OcAccountChip({
|
|
|
279
281
|
] })
|
|
280
282
|
]
|
|
281
283
|
}
|
|
282
|
-
)
|
|
284
|
+
),
|
|
285
|
+
signOutFailed ? /* @__PURE__ */ jsx(SignOutFailed, {}) : null
|
|
283
286
|
]
|
|
284
287
|
}
|
|
285
288
|
);
|
|
286
289
|
}
|
|
290
|
+
function SignOutFailed() {
|
|
291
|
+
return /* @__PURE__ */ jsx(
|
|
292
|
+
"span",
|
|
293
|
+
{
|
|
294
|
+
role: "alert",
|
|
295
|
+
"data-oc-signout-failed": "",
|
|
296
|
+
style: { display: "block", marginTop: 4, fontSize: 12, color: "var(--destructive, #dc2626)" },
|
|
297
|
+
children: "Couldn\u2019t sign out. You\u2019re still signed in; try again."
|
|
298
|
+
}
|
|
299
|
+
);
|
|
300
|
+
}
|
|
287
301
|
function OcSignInButton({
|
|
288
302
|
label = "sign in",
|
|
289
303
|
eager = false,
|
|
@@ -312,7 +326,8 @@ function OcAccountPill({
|
|
|
312
326
|
className,
|
|
313
327
|
...rest
|
|
314
328
|
}) {
|
|
315
|
-
const { status, account,
|
|
329
|
+
const { status, account, trySignOut } = useOcSession();
|
|
330
|
+
const [signOutFailed, setSignOutFailed] = React.useState(false);
|
|
316
331
|
if (status !== "authenticated" || !account) return null;
|
|
317
332
|
const label = render ? render({ address: account.didOc, displayName: account.displayName }) : account.displayName ?? shortenAddress(account.didOc);
|
|
318
333
|
return /* @__PURE__ */ jsxs(
|
|
@@ -329,7 +344,8 @@ function OcAccountPill({
|
|
|
329
344
|
{
|
|
330
345
|
type: "button",
|
|
331
346
|
onClick: () => {
|
|
332
|
-
|
|
347
|
+
setSignOutFailed(false);
|
|
348
|
+
void trySignOut().then((r) => setSignOutFailed(!r.ok));
|
|
333
349
|
},
|
|
334
350
|
"aria-label": "Sign out",
|
|
335
351
|
style: {
|
|
@@ -342,7 +358,8 @@ function OcAccountPill({
|
|
|
342
358
|
},
|
|
343
359
|
children: "sign out"
|
|
344
360
|
}
|
|
345
|
-
)
|
|
361
|
+
),
|
|
362
|
+
signOutFailed ? /* @__PURE__ */ jsx(SignOutFailed, {}) : null
|
|
346
363
|
]
|
|
347
364
|
}
|
|
348
365
|
);
|
|
@@ -649,4 +666,4 @@ export {
|
|
|
649
666
|
useOcAddressSuggestion,
|
|
650
667
|
OcAddressInput
|
|
651
668
|
};
|
|
652
|
-
//# sourceMappingURL=chunk-
|
|
669
|
+
//# sourceMappingURL=chunk-PYQTVOVH.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { useOcSession } from './provider';\nimport type { OcAccount } from './types';\n\nfunction shortenAddress(addr: string): string {\n if (addr.length <= 12) return addr;\n return `${addr.slice(0, 6)}…${addr.slice(-4)}`;\n}\n\nfunction shortenAddressMid(addr: string): string {\n if (addr.length <= 16) return addr;\n return `${addr.slice(0, 8)}…${addr.slice(-6)}`;\n}\n\nfunction isPrefixOf(value: string, target: string): boolean {\n return target.toLowerCase().startsWith(value.toLowerCase());\n}\n\nlet listboxIdCounter = 0;\nfunction useUniqueId(prefix: string): string {\n const [id] = React.useState(() => `${prefix}-${++listboxIdCounter}`);\n return id;\n}\n\nexport interface OcAccountChipProps {\n /**\n * URL to the user's account dashboard. Defaults to `https://ochk.io/dashboard`,\n * the canonical family target.\n */\n dashboardUrl?: string;\n /**\n * Override the sign-in URL shown to anonymous visitors. Defaults to\n * the session's `signInUrl` (which points at the auth host's\n * /signin?return_to=… page). Set this to a local path like `'/signin'`\n * when the consumer site mounts its own in-place `<OcSignIn />` —\n * skips the redirect-bounce entirely.\n */\n signInUrl?: string;\n /**\n * Label for the sign-in link shown to anonymous visitors.\n * Defaults to `sign in`.\n */\n signInLabel?: string;\n /** className for the wrapper `<div>`. */\n className?: string;\n /** className for the trigger pill button. */\n triggerClassName?: string;\n /** className for the dropdown popover. */\n popoverClassName?: string;\n /** className for menu items (dashboard link + sign-out button). */\n menuItemClassName?: string;\n}\n\n/**\n * Single header-account affordance for every ochk.io subdomain.\n *\n * anonymous → \"sign in\" link\n * signed in → pill `bc1q…7ke3 ▾` that opens a popover with:\n * • § signed in (label)\n * • full address (monospace, break-all)\n * • → dashboard\n * • → sign out\n *\n * The popover closes on outside click or Escape. Reasonable inline styles\n * cover the dark-mode default; override per-part via the className props\n * or via the `[data-oc-account-chip-*]` data attributes.\n */\nexport function OcAccountChip({\n dashboardUrl = 'https://ochk.io/dashboard',\n signInUrl: signInUrlOverride,\n signInLabel = 'sign in',\n className,\n triggerClassName,\n popoverClassName,\n menuItemClassName,\n}: OcAccountChipProps): React.ReactElement | null {\n const { status, account, signInUrl: sessionSignInUrl, trySignOut } = useOcSession();\n const signInUrl = signInUrlOverride ?? sessionSignInUrl;\n const [open, setOpen] = React.useState(false);\n // The auth host did not end the session: say so, and keep showing the account.\n const [signOutFailed, setSignOutFailed] = React.useState(false);\n const wrapRef = React.useRef<HTMLDivElement | null>(null);\n\n React.useEffect(() => {\n if (!open) return;\n function handleClickOutside(e: MouseEvent) {\n if (wrapRef.current && !wrapRef.current.contains(e.target as Node)) {\n setOpen(false);\n }\n }\n function handleEscape(e: KeyboardEvent) {\n if (e.key === 'Escape') setOpen(false);\n }\n document.addEventListener('mousedown', handleClickOutside);\n document.addEventListener('keydown', handleEscape);\n return () => {\n document.removeEventListener('mousedown', handleClickOutside);\n document.removeEventListener('keydown', handleEscape);\n };\n }, [open]);\n\n if (status === 'loading') return null;\n\n if (status !== 'authenticated' || !account) {\n return (\n <a\n href={signInUrl}\n className={triggerClassName ?? className}\n data-oc-account-chip-signin=\"\"\n >\n {signInLabel}\n </a>\n );\n }\n\n return (\n <div\n ref={wrapRef}\n className={className}\n data-oc-account-chip=\"\"\n style={{ position: 'relative', display: 'inline-block' }}\n >\n <button\n type=\"button\"\n onClick={() => setOpen((v) => !v)}\n aria-haspopup=\"menu\"\n aria-expanded={open}\n aria-label={`Signed in as ${account.didOc}. Open account menu.`}\n className={triggerClassName}\n data-oc-account-chip-trigger=\"\"\n style={\n triggerClassName\n ? undefined\n : {\n display: 'inline-flex',\n alignItems: 'center',\n gap: '0.4rem',\n padding: '0.25rem 0.625rem',\n borderRadius: '9999px',\n border: '1px solid var(--border, #27272a)',\n background:\n 'color-mix(in oklch, var(--muted, #27272a) 40%, transparent)',\n color: 'var(--foreground, #fafafa)',\n fontFamily: 'ui-monospace, SFMono-Regular, monospace',\n fontSize: 12,\n cursor: 'pointer',\n }\n }\n >\n <span aria-hidden=\"true\" style={{ color: '#22c55e', fontSize: 8 }}>\n ●\n </span>\n <span>{account.displayName ?? shortenAddress(account.didOc)}</span>\n <svg\n width=\"9\"\n height=\"9\"\n viewBox=\"0 0 10 10\"\n aria-hidden=\"true\"\n style={{\n transition: 'transform 120ms',\n transform: open ? 'rotate(180deg)' : 'rotate(0)',\n opacity: 0.6,\n }}\n >\n <path\n d=\"M2 4 L5 7 L8 4\"\n stroke=\"currentColor\"\n strokeWidth=\"1.5\"\n fill=\"none\"\n strokeLinecap=\"round\"\n />\n </svg>\n </button>\n\n {open && (\n <div\n role=\"menu\"\n aria-label=\"Account menu\"\n className={popoverClassName}\n data-oc-account-chip-popover=\"\"\n style={\n popoverClassName\n ? { position: 'absolute', zIndex: 50, top: 'calc(100% + 6px)', right: 0 }\n : {\n position: 'absolute',\n zIndex: 50,\n top: 'calc(100% + 6px)',\n right: 0,\n minWidth: 240,\n background: 'var(--popover, #0a0a0a)',\n color: 'var(--popover-foreground, #fafafa)',\n border: '1px solid var(--border, #27272a)',\n boxShadow: '0 10px 32px -4px rgba(0,0,0,0.35)',\n fontFamily: 'ui-monospace, SFMono-Regular, monospace',\n }\n }\n >\n <div\n data-oc-account-chip-header=\"\"\n style={{\n padding: '0.75rem 0.75rem 0.625rem',\n borderBottom: '1px solid var(--border, #27272a)',\n }}\n >\n <div\n data-oc-account-chip-label=\"\"\n style={{\n color: 'var(--primary, #f97316)',\n fontSize: 10,\n letterSpacing: '0.18em',\n textTransform: 'uppercase',\n marginBottom: 4,\n }}\n >\n § signed in\n </div>\n <div\n data-oc-account-chip-address=\"\"\n style={{\n color: 'var(--popover-foreground, #fafafa)',\n fontSize: 11,\n wordBreak: 'break-all',\n lineHeight: 1.35,\n }}\n >\n {account.didOc}\n </div>\n {account.displayName ? (\n <div\n style={{\n color: 'var(--muted-foreground, #a1a1aa)',\n fontSize: 10,\n marginTop: 4,\n letterSpacing: '0.06em',\n }}\n >\n {account.displayName}\n </div>\n ) : null}\n </div>\n <div role=\"none\" style={{ padding: '0.25rem' }}>\n {dashboardUrl ? (\n <a\n role=\"menuitem\"\n href={dashboardUrl}\n onClick={() => setOpen(false)}\n className={menuItemClassName}\n data-oc-account-chip-item=\"\"\n style={\n menuItemClassName\n ? undefined\n : {\n display: 'flex',\n alignItems: 'center',\n gap: '0.5rem',\n padding: '0.5rem 0.625rem',\n fontSize: 12,\n color: 'var(--popover-foreground, #fafafa)',\n textDecoration: 'none',\n cursor: 'pointer',\n }\n }\n >\n <span\n aria-hidden=\"true\"\n style={{ color: 'var(--muted-foreground, #a1a1aa)' }}\n >\n →\n </span>\n <span style={{ flex: 1 }}>dashboard</span>\n <span\n style={{\n color: 'var(--muted-foreground, #a1a1aa)',\n fontSize: 10,\n }}\n >\n ↗\n </span>\n </a>\n ) : null}\n <button\n type=\"button\"\n role=\"menuitem\"\n onClick={() => {\n setOpen(false);\n setSignOutFailed(false);\n void trySignOut().then((r) => setSignOutFailed(!r.ok));\n }}\n className={menuItemClassName}\n data-oc-account-chip-item=\"\"\n data-oc-account-chip-signout=\"\"\n style={\n menuItemClassName\n ? undefined\n : {\n display: 'flex',\n alignItems: 'center',\n gap: '0.5rem',\n width: '100%',\n padding: '0.5rem 0.625rem',\n fontSize: 12,\n color: 'var(--popover-foreground, #fafafa)',\n background: 'transparent',\n border: 0,\n fontFamily: 'inherit',\n textAlign: 'left',\n cursor: 'pointer',\n }\n }\n >\n <span\n aria-hidden=\"true\"\n style={{ color: 'var(--muted-foreground, #a1a1aa)' }}\n >\n →\n </span>\n <span style={{ flex: 1 }}>sign out</span>\n </button>\n </div>\n </div>\n )}\n {signOutFailed ? <SignOutFailed /> : null}\n </div>\n );\n}\n\n/** Said when the auth host did not end the session, so the person is still signed in. */\nfunction SignOutFailed(): React.ReactElement {\n return (\n <span\n role=\"alert\"\n data-oc-signout-failed=\"\"\n style={{ display: 'block', marginTop: 4, fontSize: 12, color: 'var(--destructive, #dc2626)' }}\n >\n Couldn’t sign out. You’re still signed in; try again.\n </span>\n );\n}\n\nexport interface OcSignInButtonProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> {\n /** Label shown when no user is signed in. Defaults to `sign in`. */\n label?: string;\n /**\n * When `true`, render an `<a>` even while the session is loading, to\n * avoid layout shift. Defaults to `false` (renders nothing while loading).\n */\n eager?: boolean;\n /**\n * Override the destination URL. Defaults to the session's `signInUrl`\n * (the auth host's redirect-style /signin). Set this to a local path\n * like `'/signin'` when the consumer site has its own in-place\n * `<OcSignIn />` page — keeps the user in-tab.\n */\n signInUrl?: string;\n}\n\n/**\n * Drop-in sign-in button. Renders an anchor that points at either:\n *\n * - the consumer's local `/signin` page (when `signInUrl` prop is set\n * — recommended; works with `<OcSignIn />`), or\n * - the auth host's `/signin?return_to=…` (default fallback)\n *\n * When the user is already authenticated it renders nothing.\n */\nexport function OcSignInButton({\n label = 'sign in',\n eager = false,\n className,\n signInUrl: signInUrlOverride,\n ...rest\n}: OcSignInButtonProps): React.ReactElement | null {\n const { status, signInUrl: sessionSignInUrl } = useOcSession();\n const href = signInUrlOverride ?? sessionSignInUrl;\n if (status === 'authenticated') return null;\n if (!eager && status === 'loading') return null;\n\n return (\n <a\n {...rest}\n href={href}\n className={className}\n data-oc-sign-in-button=\"\"\n >\n {label}\n </a>\n );\n}\n\nexport interface OcAccountPillProps extends React.HTMLAttributes<HTMLDivElement> {\n /** URL to link the address to. Defaults to the auth origin's `/dashboard`. */\n dashboardUrl?: string;\n /** Override the display text. Defaults to the shortened address. */\n render?: (account: { address: string; displayName?: string | null }) => React.ReactNode;\n}\n\n/**\n * Shows the signed-in user as a short pill: `bc1q…abcd sign out`.\n *\n * Renders nothing while loading or when no user is signed in — pair with\n * `<OcSignInButton>` for the anonymous case.\n */\nexport function OcAccountPill({\n dashboardUrl,\n render,\n className,\n ...rest\n}: OcAccountPillProps): React.ReactElement | null {\n const { status, account, trySignOut } = useOcSession();\n // The auth host did not end the session: say so, and keep showing the account.\n const [signOutFailed, setSignOutFailed] = React.useState(false);\n\n if (status !== 'authenticated' || !account) return null;\n\n const label = render\n ? render({ address: account.didOc, displayName: account.displayName })\n : (account.displayName ?? shortenAddress(account.didOc));\n\n return (\n <div\n {...rest}\n className={className}\n data-oc-account-pill=\"\"\n style={{ display: 'inline-flex', alignItems: 'center', gap: '0.5rem', ...(rest.style ?? {}) }}\n >\n {dashboardUrl ? (\n <a href={dashboardUrl}>{label}</a>\n ) : (\n <span>{label}</span>\n )}\n <button\n type=\"button\"\n onClick={() => {\n setSignOutFailed(false);\n void trySignOut().then((r) => setSignOutFailed(!r.ok));\n }}\n aria-label=\"Sign out\"\n style={{\n background: 'none',\n border: 'none',\n cursor: 'pointer',\n color: 'inherit',\n font: 'inherit',\n padding: 0,\n }}\n >\n sign out\n </button>\n {signOutFailed ? <SignOutFailed /> : null}\n </div>\n );\n}\n\nexport interface OcAddressInputProps\n extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'value' | 'onChange'> {\n /** Controlled value. */\n value: string;\n /** Called when value changes — typed by the user OR selected from the popover. */\n onValueChange: (value: string) => void;\n /** Label shown above the suggested address in the popover. Defaults to `use your address`. */\n suggestionLabel?: string;\n /** className applied to the wrapper `<div>`. */\n wrapperClassName?: string;\n /** className applied to the suggestion popover. Style with `[data-oc-address-popover]` otherwise. */\n popoverClassName?: string;\n /** className applied to the suggestion button. Style with `[data-oc-address-suggestion]` otherwise. */\n suggestionClassName?: string;\n}\n\n/**\n * Bitcoin-address `<input>` that, when the user is signed in via `oc_session`,\n * surfaces their address as a one-click suggestion on focus.\n *\n * Behaviour:\n * - On focus, if logged-in AND the typed value is a prefix of the session\n * address (or empty), show a small popover with `bc1q…7ke3` as a clickable\n * suggestion.\n * - Click / Enter on the suggestion fills the field with the full address.\n * - Down-arrow from the input highlights the suggestion; Up-arrow clears the\n * highlight; Escape closes the popover; clicking outside closes the popover.\n * - When the user types something that's no longer a prefix of the session\n * address, the popover hides itself out of the way.\n * - When the field already contains the session address exactly, no popover.\n *\n * Style-agnostic: minimal inline styles for positioning only. Style the parts\n * via `wrapperClassName` / `popoverClassName` / `suggestionClassName`, or via\n * the `[data-oc-address-input]`, `[data-oc-address-popover]`, and\n * `[data-oc-address-suggestion]` data attributes.\n */\nexport interface UseOcAddressSuggestionOptions {\n /** Current value of the input. */\n value: string;\n /** Called when the user selects the suggestion (or you may also call it from the input's onChange). */\n onValueChange: (value: string) => void;\n /** Label shown above the suggested address in the popover. Defaults to `use your address`. */\n suggestionLabel?: string;\n /** className applied to the suggestion popover. Style with `[data-oc-address-popover]` otherwise. */\n popoverClassName?: string;\n /** className applied to the suggestion button. Style with `[data-oc-address-suggestion]` otherwise. */\n suggestionClassName?: string;\n}\n\nexport interface UseOcAddressSuggestionReturn {\n /**\n * Props to spread onto your `<input>` element. Adds focus/blur/keydown\n * handlers and the combobox ARIA attributes. Combine with your existing\n * `value`/`onChange` props — this hook does NOT control them.\n */\n inputProps: {\n onFocus: (e: React.FocusEvent<HTMLInputElement>) => void;\n onBlur: (e: React.FocusEvent<HTMLInputElement>) => void;\n onKeyDown: (e: React.KeyboardEvent<HTMLInputElement>) => void;\n role: 'combobox';\n 'aria-haspopup': 'listbox';\n 'aria-expanded': boolean;\n 'aria-controls': string | undefined;\n 'aria-activedescendant': string | undefined;\n autoComplete: 'off';\n spellCheck: false;\n };\n /**\n * The suggestion popover. Render directly after your `<input>`, inside a\n * `position: relative` container so the popover anchors below the input.\n * Returns `null` when there's no suggestion to show.\n */\n popover: React.ReactNode;\n}\n\n/**\n * Hook variant of `OcAddressInput`. Use when you want to keep your existing\n * styled `<input>` (e.g. shadcn `<Input>`) and just bolt on the\n * session-address suggestion behaviour.\n *\n * Wrap your input in a `position: relative` container, spread `inputProps`\n * onto the input, and render `{popover}` immediately after. The hook's\n * focus / blur / keydown handlers are composed via `inputProps` — they call\n * any handlers you've already passed to your input only when you wire them\n * yourself in addition to spreading `inputProps`.\n *\n * Example:\n * ```tsx\n * const { inputProps, popover } = useOcAddressSuggestion({\n * value: addr,\n * onValueChange: setAddr,\n * });\n * return (\n * <div className=\"relative\">\n * <Input\n * value={addr}\n * onChange={(e) => setAddr(e.target.value)}\n * {...inputProps}\n * placeholder=\"bc1q…\"\n * />\n * {popover}\n * </div>\n * );\n * ```\n */\n/**\n * The address to offer: the account's primary one, else the Bitcoin address it\n * shows. Consumer sites verify the session locally and have no primary address\n * (`primary_btc` is null), but a wallet sign-in shows its address.\n */\nfunction accountAddress(account: OcAccount | null | undefined): string | null {\n if (account?.primaryBtc) return account.primaryBtc;\n return account?.displayIdentity?.kind === 'btc' ? account.displayIdentity.value : null;\n}\n\nexport function useOcAddressSuggestion(\n options: UseOcAddressSuggestionOptions\n): UseOcAddressSuggestionReturn {\n const {\n value,\n onValueChange,\n suggestionLabel = 'use your address',\n popoverClassName,\n suggestionClassName,\n } = options;\n\n const { status, account } = useOcSession();\n const sessionAddress = status === 'authenticated' ? accountAddress(account) : null;\n\n const [open, setOpen] = React.useState(false);\n const [highlighted, setHighlighted] = React.useState(false);\n const blurTimer = React.useRef<number | null>(null);\n\n const listboxId = useUniqueId('oc-addr-listbox');\n const optionId = `${listboxId}-opt`;\n\n const valueMatchesSession =\n sessionAddress != null && value.toLowerCase() === sessionAddress.toLowerCase();\n const canSuggest =\n sessionAddress != null &&\n sessionAddress.length > 0 &&\n !valueMatchesSession &&\n isPrefixOf(value, sessionAddress);\n const showPopover = open && canSuggest;\n\n function selectSuggestion() {\n if (!sessionAddress) return;\n onValueChange(sessionAddress);\n setOpen(false);\n setHighlighted(false);\n }\n\n React.useEffect(() => {\n return () => {\n if (blurTimer.current != null) window.clearTimeout(blurTimer.current);\n };\n }, []);\n\n const inputProps: UseOcAddressSuggestionReturn['inputProps'] = {\n onFocus: () => {\n if (blurTimer.current != null) {\n window.clearTimeout(blurTimer.current);\n blurTimer.current = null;\n }\n setOpen(true);\n },\n onBlur: () => {\n blurTimer.current = window.setTimeout(() => {\n setOpen(false);\n setHighlighted(false);\n }, 120);\n },\n onKeyDown: (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (!showPopover) return;\n if (e.key === 'ArrowDown') {\n e.preventDefault();\n setHighlighted(true);\n } else if (e.key === 'ArrowUp') {\n e.preventDefault();\n setHighlighted(false);\n } else if (e.key === 'Escape') {\n e.preventDefault();\n setOpen(false);\n setHighlighted(false);\n } else if (e.key === 'Enter' && highlighted) {\n e.preventDefault();\n selectSuggestion();\n }\n },\n role: 'combobox',\n 'aria-haspopup': 'listbox',\n 'aria-expanded': showPopover,\n 'aria-controls': showPopover ? listboxId : undefined,\n 'aria-activedescendant': highlighted ? optionId : undefined,\n autoComplete: 'off',\n spellCheck: false,\n };\n\n const popover = showPopover && sessionAddress ? (\n <div\n id={listboxId}\n role=\"listbox\"\n data-oc-address-popover=\"\"\n className={popoverClassName}\n style={{\n position: 'absolute',\n zIndex: 50,\n top: 'calc(100% + 4px)',\n left: 0,\n right: 0,\n }}\n onMouseDown={(e) => e.preventDefault()}\n >\n <button\n type=\"button\"\n id={optionId}\n role=\"option\"\n aria-selected={highlighted}\n data-oc-address-suggestion=\"\"\n data-highlighted={highlighted ? '' : undefined}\n className={suggestionClassName}\n onClick={selectSuggestion}\n onMouseEnter={() => setHighlighted(true)}\n onMouseLeave={() => setHighlighted(false)}\n style={{\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'space-between',\n gap: '0.75rem',\n width: '100%',\n textAlign: 'left',\n cursor: 'pointer',\n font: 'inherit',\n background: 'inherit',\n color: 'inherit',\n border: 0,\n padding: 'inherit',\n }}\n >\n <span data-oc-address-suggestion-label=\"\">{suggestionLabel}</span>\n <span\n data-oc-address-suggestion-value=\"\"\n style={{ fontFamily: 'ui-monospace, monospace' }}\n >\n {shortenAddressMid(sessionAddress)}\n </span>\n </button>\n </div>\n ) : null;\n\n return { inputProps, popover };\n}\n\nexport const OcAddressInput = React.forwardRef<HTMLInputElement, OcAddressInputProps>(\n function OcAddressInput(\n {\n value,\n onValueChange,\n suggestionLabel = 'use your address',\n wrapperClassName,\n popoverClassName,\n suggestionClassName,\n onFocus,\n onBlur,\n onKeyDown,\n ...rest\n },\n forwardedRef\n ): React.ReactElement {\n const { status, account } = useOcSession();\n const sessionAddress = status === 'authenticated' ? accountAddress(account) : null;\n\n const [open, setOpen] = React.useState(false);\n const [highlighted, setHighlighted] = React.useState(false);\n\n const innerRef = React.useRef<HTMLInputElement | null>(null);\n const setRef = (node: HTMLInputElement | null) => {\n innerRef.current = node;\n if (typeof forwardedRef === 'function') forwardedRef(node);\n else if (forwardedRef) forwardedRef.current = node;\n };\n const blurTimer = React.useRef<number | null>(null);\n\n const listboxId = useUniqueId('oc-addr-listbox');\n const optionId = `${listboxId}-opt`;\n\n const valueMatchesSession =\n sessionAddress != null && value.toLowerCase() === sessionAddress.toLowerCase();\n const canSuggest =\n sessionAddress != null &&\n sessionAddress.length > 0 &&\n !valueMatchesSession &&\n isPrefixOf(value, sessionAddress);\n const showPopover = open && canSuggest;\n\n function selectSuggestion() {\n if (!sessionAddress) return;\n onValueChange(sessionAddress);\n setOpen(false);\n setHighlighted(false);\n // Re-focus so the next Tab moves on naturally.\n innerRef.current?.focus();\n }\n\n function handleFocus(e: React.FocusEvent<HTMLInputElement>) {\n if (blurTimer.current != null) {\n window.clearTimeout(blurTimer.current);\n blurTimer.current = null;\n }\n setOpen(true);\n onFocus?.(e);\n }\n\n function handleBlur(e: React.FocusEvent<HTMLInputElement>) {\n // Defer close so a click on the suggestion can register first.\n blurTimer.current = window.setTimeout(() => {\n setOpen(false);\n setHighlighted(false);\n }, 120);\n onBlur?.(e);\n }\n\n function handleKeyDown(e: React.KeyboardEvent<HTMLInputElement>) {\n if (showPopover) {\n if (e.key === 'ArrowDown') {\n e.preventDefault();\n setHighlighted(true);\n } else if (e.key === 'ArrowUp') {\n e.preventDefault();\n setHighlighted(false);\n } else if (e.key === 'Escape') {\n e.preventDefault();\n setOpen(false);\n setHighlighted(false);\n } else if (e.key === 'Enter' && highlighted) {\n e.preventDefault();\n selectSuggestion();\n }\n }\n onKeyDown?.(e);\n }\n\n React.useEffect(() => {\n return () => {\n if (blurTimer.current != null) window.clearTimeout(blurTimer.current);\n };\n }, []);\n\n return (\n <div\n data-oc-address-input=\"\"\n className={wrapperClassName}\n style={{ position: 'relative' }}\n >\n <input\n {...rest}\n ref={setRef}\n value={value}\n onChange={(e) => onValueChange(e.target.value)}\n onFocus={handleFocus}\n onBlur={handleBlur}\n onKeyDown={handleKeyDown}\n role=\"combobox\"\n aria-haspopup=\"listbox\"\n aria-expanded={showPopover}\n aria-controls={showPopover ? listboxId : undefined}\n aria-activedescendant={highlighted ? optionId : undefined}\n autoComplete=\"off\"\n spellCheck={false}\n />\n {showPopover && sessionAddress && (\n <div\n id={listboxId}\n role=\"listbox\"\n data-oc-address-popover=\"\"\n className={popoverClassName}\n style={{\n position: 'absolute',\n zIndex: 50,\n top: 'calc(100% + 4px)',\n left: 0,\n right: 0,\n }}\n // Prevent the input from blurring before the click on the suggestion lands.\n onMouseDown={(e) => e.preventDefault()}\n >\n <button\n type=\"button\"\n id={optionId}\n role=\"option\"\n aria-selected={highlighted}\n data-oc-address-suggestion=\"\"\n data-highlighted={highlighted ? '' : undefined}\n className={suggestionClassName}\n onClick={selectSuggestion}\n onMouseEnter={() => setHighlighted(true)}\n onMouseLeave={() => setHighlighted(false)}\n style={{\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'space-between',\n gap: '0.75rem',\n width: '100%',\n textAlign: 'left',\n cursor: 'pointer',\n font: 'inherit',\n background: 'inherit',\n color: 'inherit',\n border: 'inherit',\n padding: 'inherit',\n }}\n >\n <span data-oc-address-suggestion-label=\"\">{suggestionLabel}</span>\n <span\n data-oc-address-suggestion-value=\"\"\n style={{ fontFamily: 'ui-monospace, monospace' }}\n >\n {shortenAddressMid(sessionAddress)}\n </span>\n </button>\n </div>\n )}\n </div>\n );\n }\n);\n"],"mappings":";;;;;AAAA,YAAY,WAAW;AA0GX,cAiBA,YAjBA;AArGZ,SAAS,eAAe,MAAsB;AAC1C,MAAI,KAAK,UAAU,GAAI,QAAO;AAC9B,SAAO,GAAG,KAAK,MAAM,GAAG,CAAC,CAAC,SAAI,KAAK,MAAM,EAAE,CAAC;AAChD;AAEA,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;AAAA,cAEA,aAAa,CAAC,MAAM,EAAE,eAAe;AAAA,cAErC;AAAA,gBAAC;AAAA;AAAA,kBACG,MAAK;AAAA,kBACL,IAAI;AAAA,kBACJ,MAAK;AAAA,kBACL,iBAAe;AAAA,kBACf,8BAA2B;AAAA,kBAC3B,oBAAkB,cAAc,KAAK;AAAA,kBACrC,WAAW;AAAA,kBACX,SAAS;AAAA,kBACT,cAAc,MAAM,eAAe,IAAI;AAAA,kBACvC,cAAc,MAAM,eAAe,KAAK;AAAA,kBACxC,OAAO;AAAA,oBACH,SAAS;AAAA,oBACT,YAAY;AAAA,oBACZ,gBAAgB;AAAA,oBAChB,KAAK;AAAA,oBACL,OAAO;AAAA,oBACP,WAAW;AAAA,oBACX,QAAQ;AAAA,oBACR,MAAM;AAAA,oBACN,YAAY;AAAA,oBACZ,OAAO;AAAA,oBACP,QAAQ;AAAA,oBACR,SAAS;AAAA,kBACb;AAAA,kBAEA;AAAA,wCAAC,UAAK,oCAAiC,IAAI,2BAAgB;AAAA,oBAC3D;AAAA,sBAAC;AAAA;AAAA,wBACG,oCAAiC;AAAA,wBACjC,OAAO,EAAE,YAAY,0BAA0B;AAAA,wBAE9C,4BAAkB,cAAc;AAAA;AAAA,oBACrC;AAAA;AAAA;AAAA,cACJ;AAAA;AAAA,UACJ;AAAA;AAAA;AAAA,IAER;AAAA,EAER;AACJ;","names":["OcAddressInput"]}
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
inputStyle,
|
|
12
12
|
panelStyle,
|
|
13
13
|
primaryBtnStyle
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-FMPBHB3Q.mjs";
|
|
15
15
|
import {
|
|
16
16
|
addressInputValue
|
|
17
17
|
} from "./chunk-U7IUGDLW.mjs";
|
|
@@ -494,4 +494,4 @@ export {
|
|
|
494
494
|
fetchOcBond,
|
|
495
495
|
OcBond
|
|
496
496
|
};
|
|
497
|
-
//# sourceMappingURL=chunk-
|
|
497
|
+
//# sourceMappingURL=chunk-UBDRTV5O.mjs.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useOcSession
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-JLMDCC6K.mjs";
|
|
4
4
|
import {
|
|
5
5
|
resolveConfig
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-PQHFAVVM.mjs";
|
|
7
7
|
|
|
8
8
|
// src/webauthn.tsx
|
|
9
9
|
import * as React from "react";
|
|
@@ -250,4 +250,4 @@ export {
|
|
|
250
250
|
useWebAuthnList,
|
|
251
251
|
useStepUpAuth
|
|
252
252
|
};
|
|
253
|
-
//# sourceMappingURL=chunk-
|
|
253
|
+
//# sourceMappingURL=chunk-Y2PA7VC5.mjs.map
|
package/dist/components.mjs
CHANGED
|
@@ -4,9 +4,9 @@ import {
|
|
|
4
4
|
OcAddressInput,
|
|
5
5
|
OcSignInButton,
|
|
6
6
|
useOcAddressSuggestion
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-PYQTVOVH.mjs";
|
|
8
|
+
import "./chunk-JLMDCC6K.mjs";
|
|
9
|
+
import "./chunk-PQHFAVVM.mjs";
|
|
10
10
|
import "./chunk-JTT77LMU.mjs";
|
|
11
11
|
import "./chunk-4BOO7EQR.mjs";
|
|
12
12
|
export {
|
package/dist/index.d.ts
CHANGED
|
@@ -27,6 +27,13 @@ interface OcAccountSummary {
|
|
|
27
27
|
lastSeenAt: string | null;
|
|
28
28
|
}
|
|
29
29
|
type OcSignOutScope = 'all' | 'current';
|
|
30
|
+
type OcSignOutResult = {
|
|
31
|
+
ok: true;
|
|
32
|
+
} | {
|
|
33
|
+
ok: false;
|
|
34
|
+
reason: 'unreachable' | 'refused';
|
|
35
|
+
status?: number;
|
|
36
|
+
};
|
|
30
37
|
interface OcSessionState {
|
|
31
38
|
status: OcSessionStatus;
|
|
32
39
|
account: OcAccount | null;
|
|
@@ -37,6 +44,9 @@ interface OcSessionState {
|
|
|
37
44
|
signOut: (opts?: {
|
|
38
45
|
scope?: OcSignOutScope;
|
|
39
46
|
}) => Promise<void>;
|
|
47
|
+
trySignOut: (opts?: {
|
|
48
|
+
scope?: OcSignOutScope;
|
|
49
|
+
}) => Promise<OcSignOutResult>;
|
|
40
50
|
switchAccount: (didOc: string) => Promise<void>;
|
|
41
51
|
addAccountUrl: (returnTo?: string) => string;
|
|
42
52
|
setDisplayIdentity: (kind: DisplayIdentityKind) => Promise<void>;
|
|
@@ -303,4 +313,4 @@ declare function isSudoAccountMismatch(body: {
|
|
|
303
313
|
reason?: string;
|
|
304
314
|
} | null | undefined): boolean;
|
|
305
315
|
|
|
306
|
-
export { DEFAULT_CONFIG, DISPLAY_IDENTITY_KINDS, type DisplayIdentity, type DisplayIdentityKind, FRAGMENT_TTL_MS, type OcAccount, OcAccountChip, type OcAccountChipProps, OcAccountPill, type OcAccountPillProps, type OcAccountSummary, OcAddressInput, type OcAddressInputProps, type OcAuthConfig, OcBond, type OcBondProps, type OcBondView, OcLinkedIdentities, type OcLinkedIdentitiesProps, type OcLinkedIdentity, OcSessionProvider, type OcSessionState, type OcSessionStatus, OcSignIn, OcSignInButton, type OcSignInButtonProps, type OcSignInProps, type OcSignOutScope, type OcTabSession, type RedirectToSudoArgs, SUDO_ACCOUNT_MISMATCH_MESSAGE, TAB_ACCOUNT_HINT_KEY, TAB_ADOPT_HASH, TAB_SESSION_HEADER, TAB_SESSION_STORAGE_KEY, 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, bondFloorsText, buildAddAccountUrl, buildSignInUrl, clearTabSession, consumeTabAccountHint, consumeTabAdoptMarker, familyReturnTarget, fetchOcBond, fetchOcLinkedIdentities, handleSudoRequired, installTabFetchInterceptor, installTabLinkDecorator, isSudoAccountMismatch, keepFragmentOnReturnLinks, newAccountsCapText, otpNetworkCapText, readTabSession, redirectToSudo, restoreReturnFragment, returnToHere, safeReturnTo, stripFragment, tabSessionHeader, useOcAddressSuggestion, useOcSession, useOptionalOcSession, useStepUpAuth, useWebAuthnList, useWebAuthnRegister, withoutFragment, writeTabSession };
|
|
316
|
+
export { DEFAULT_CONFIG, DISPLAY_IDENTITY_KINDS, type DisplayIdentity, type DisplayIdentityKind, FRAGMENT_TTL_MS, type OcAccount, OcAccountChip, type OcAccountChipProps, OcAccountPill, type OcAccountPillProps, type OcAccountSummary, OcAddressInput, type OcAddressInputProps, type OcAuthConfig, OcBond, type OcBondProps, type OcBondView, OcLinkedIdentities, type OcLinkedIdentitiesProps, type OcLinkedIdentity, OcSessionProvider, type OcSessionState, type OcSessionStatus, OcSignIn, OcSignInButton, type OcSignInButtonProps, type OcSignInProps, type OcSignOutResult, type OcSignOutScope, type OcTabSession, type RedirectToSudoArgs, SUDO_ACCOUNT_MISMATCH_MESSAGE, TAB_ACCOUNT_HINT_KEY, TAB_ADOPT_HASH, TAB_SESSION_HEADER, TAB_SESSION_STORAGE_KEY, 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, bondFloorsText, buildAddAccountUrl, buildSignInUrl, clearTabSession, consumeTabAccountHint, consumeTabAdoptMarker, familyReturnTarget, fetchOcBond, fetchOcLinkedIdentities, handleSudoRequired, installTabFetchInterceptor, installTabLinkDecorator, isSudoAccountMismatch, keepFragmentOnReturnLinks, newAccountsCapText, otpNetworkCapText, readTabSession, redirectToSudo, restoreReturnFragment, returnToHere, safeReturnTo, stripFragment, tabSessionHeader, useOcAddressSuggestion, useOcSession, useOptionalOcSession, useStepUpAuth, useWebAuthnList, useWebAuthnRegister, withoutFragment, writeTabSession };
|