@orangecheck/auth-client 2.36.1 → 2.37.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/bond.mjs +4 -4
- package/dist/{chunk-EFMTFRCS.mjs → chunk-4YHFT5SR.mjs} +2 -2
- package/dist/{chunk-XCZVSE7M.mjs → chunk-AHGVGINO.mjs} +2 -2
- package/dist/{chunk-BMMNHG74.mjs → chunk-BSZCD5YA.mjs} +2 -2
- package/dist/{chunk-E2XQ7YED.mjs → chunk-DRRU6M5Z.mjs} +12 -4
- package/dist/chunk-DRRU6M5Z.mjs.map +1 -0
- package/dist/{chunk-MKE33INV.mjs → chunk-J32TKDC5.mjs} +19 -8
- package/dist/chunk-J32TKDC5.mjs.map +1 -0
- package/dist/{chunk-EZKAMTG7.mjs → chunk-KNUHQUTI.mjs} +2 -2
- package/dist/{chunk-ASL3DS3Q.mjs → chunk-YUJNANKB.mjs} +3 -3
- package/dist/{chunk-VRLFZAGK.mjs → chunk-Z3HVBT5Q.mjs} +1 -1
- package/dist/chunk-Z3HVBT5Q.mjs.map +1 -0
- package/dist/components.mjs +3 -3
- package/dist/index.js +27 -8
- 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-E2XQ7YED.mjs.map +0 -1
- package/dist/chunk-MKE33INV.mjs.map +0 -1
- package/dist/chunk-VRLFZAGK.mjs.map +0 -1
- /package/dist/{chunk-EFMTFRCS.mjs.map → chunk-4YHFT5SR.mjs.map} +0 -0
- /package/dist/{chunk-XCZVSE7M.mjs.map → chunk-AHGVGINO.mjs.map} +0 -0
- /package/dist/{chunk-BMMNHG74.mjs.map → chunk-BSZCD5YA.mjs.map} +0 -0
- /package/dist/{chunk-EZKAMTG7.mjs.map → chunk-KNUHQUTI.mjs.map} +0 -0
- /package/dist/{chunk-ASL3DS3Q.mjs.map → chunk-YUJNANKB.mjs.map} +0 -0
package/dist/index.mjs
CHANGED
|
@@ -2,47 +2,47 @@ import {
|
|
|
2
2
|
OcSignIn,
|
|
3
3
|
familyReturnTarget,
|
|
4
4
|
safeReturnTo
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-J32TKDC5.mjs";
|
|
6
6
|
import {
|
|
7
7
|
useStepUpAuth,
|
|
8
8
|
useWebAuthnList,
|
|
9
9
|
useWebAuthnRegister
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-YUJNANKB.mjs";
|
|
11
11
|
import {
|
|
12
12
|
OcBond,
|
|
13
13
|
bondFloorsText,
|
|
14
14
|
fetchOcBond
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-4YHFT5SR.mjs";
|
|
16
16
|
import {
|
|
17
17
|
OcAccountChip,
|
|
18
18
|
OcAccountPill,
|
|
19
19
|
OcAddressInput,
|
|
20
20
|
OcSignInButton,
|
|
21
21
|
useOcAddressSuggestion
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-KNUHQUTI.mjs";
|
|
23
23
|
import {
|
|
24
24
|
OcLinkedIdentities,
|
|
25
25
|
fetchOcLinkedIdentities
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-BSZCD5YA.mjs";
|
|
27
27
|
import {
|
|
28
28
|
SUDO_ACCOUNT_MISMATCH_MESSAGE,
|
|
29
29
|
handleSudoRequired,
|
|
30
30
|
isSudoAccountMismatch,
|
|
31
31
|
redirectToSudo
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-AHGVGINO.mjs";
|
|
33
33
|
import "./chunk-U7IUGDLW.mjs";
|
|
34
34
|
import "./chunk-H2TXOCXH.mjs";
|
|
35
35
|
import {
|
|
36
36
|
OcSessionProvider,
|
|
37
37
|
useOcSession,
|
|
38
38
|
useOptionalOcSession
|
|
39
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-DRRU6M5Z.mjs";
|
|
40
40
|
import {
|
|
41
41
|
DEFAULT_CONFIG,
|
|
42
42
|
DISPLAY_IDENTITY_KINDS,
|
|
43
43
|
buildAddAccountUrl,
|
|
44
44
|
buildSignInUrl
|
|
45
|
-
} from "./chunk-
|
|
45
|
+
} from "./chunk-Z3HVBT5Q.mjs";
|
|
46
46
|
import {
|
|
47
47
|
FRAGMENT_TTL_MS,
|
|
48
48
|
keepFragmentOnReturnLinks,
|
|
@@ -15,11 +15,11 @@ import {
|
|
|
15
15
|
inputStyle,
|
|
16
16
|
panelStyle,
|
|
17
17
|
primaryBtnStyle
|
|
18
|
-
} from "./chunk-
|
|
19
|
-
import "./chunk-
|
|
18
|
+
} from "./chunk-BSZCD5YA.mjs";
|
|
19
|
+
import "./chunk-AHGVGINO.mjs";
|
|
20
20
|
import "./chunk-U7IUGDLW.mjs";
|
|
21
21
|
import "./chunk-H2TXOCXH.mjs";
|
|
22
|
-
import "./chunk-
|
|
22
|
+
import "./chunk-Z3HVBT5Q.mjs";
|
|
23
23
|
import "./chunk-CYR7J4UY.mjs";
|
|
24
24
|
import "./chunk-TJJNTITX.mjs";
|
|
25
25
|
export {
|
package/dist/provider.mjs
CHANGED
|
@@ -3,10 +3,10 @@ import {
|
|
|
3
3
|
OcSessionProvider,
|
|
4
4
|
useOcSession,
|
|
5
5
|
useOptionalOcSession
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-DRRU6M5Z.mjs";
|
|
7
7
|
import {
|
|
8
8
|
DEFAULT_CONFIG
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-Z3HVBT5Q.mjs";
|
|
10
10
|
import "./chunk-CYR7J4UY.mjs";
|
|
11
11
|
import "./chunk-TJJNTITX.mjs";
|
|
12
12
|
export {
|
package/dist/signin.mjs
CHANGED
|
@@ -5,12 +5,12 @@ import {
|
|
|
5
5
|
looksLikeBitcoinAddress,
|
|
6
6
|
networkError,
|
|
7
7
|
safeReturnTo
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
8
|
+
} from "./chunk-J32TKDC5.mjs";
|
|
9
|
+
import "./chunk-BSZCD5YA.mjs";
|
|
10
|
+
import "./chunk-AHGVGINO.mjs";
|
|
11
11
|
import "./chunk-U7IUGDLW.mjs";
|
|
12
12
|
import "./chunk-H2TXOCXH.mjs";
|
|
13
|
-
import "./chunk-
|
|
13
|
+
import "./chunk-Z3HVBT5Q.mjs";
|
|
14
14
|
import "./chunk-CYR7J4UY.mjs";
|
|
15
15
|
import "./chunk-TJJNTITX.mjs";
|
|
16
16
|
export {
|
package/dist/sudo.mjs
CHANGED
|
@@ -3,8 +3,8 @@ import {
|
|
|
3
3
|
handleSudoRequired,
|
|
4
4
|
isSudoAccountMismatch,
|
|
5
5
|
redirectToSudo
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-AHGVGINO.mjs";
|
|
7
|
+
import "./chunk-Z3HVBT5Q.mjs";
|
|
8
8
|
import "./chunk-CYR7J4UY.mjs";
|
|
9
9
|
import "./chunk-TJJNTITX.mjs";
|
|
10
10
|
export {
|
package/dist/types.mjs
CHANGED
package/dist/webauthn.mjs
CHANGED
|
@@ -2,9 +2,9 @@ import {
|
|
|
2
2
|
useStepUpAuth,
|
|
3
3
|
useWebAuthnList,
|
|
4
4
|
useWebAuthnRegister
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-YUJNANKB.mjs";
|
|
6
|
+
import "./chunk-DRRU6M5Z.mjs";
|
|
7
|
+
import "./chunk-Z3HVBT5Q.mjs";
|
|
8
8
|
import "./chunk-CYR7J4UY.mjs";
|
|
9
9
|
import "./chunk-TJJNTITX.mjs";
|
|
10
10
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orangecheck/auth-client",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.37.1",
|
|
4
4
|
"description": "React hooks and components for the cross-subdomain oc_session. Drop-in sign-in button, account chip with dashboard link, session-aware address input, and useOcSession() hook.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"orangecheck",
|
|
@@ -1 +0,0 @@
|
|
|
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 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\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 signOut = React.useCallback(\n async (opts?: { scope?: OcSignOutScope }) => {\n const scope: OcSignOutScope = opts?.scope ?? 'all';\n try {\n const url = new URL(`${cfg.authOrigin}${cfg.logoutPath}`);\n if (scope === 'current') url.searchParams.set('scope', 'current');\n const 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 // The signed-out account's token is dead either way — the\n // 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 and the\n // setState below is redundant-but-harmless.\n if (scope === 'current' && res.ok) {\n await refresh();\n return;\n }\n } catch {\n // fall through — we still clear local state so the UI reflects\n // the user's intent even if the server round-trip fails.\n clearTabSession();\n setTabPinned(false);\n }\n setAccount(null);\n setRoster([]);\n setStatus('anonymous');\n },\n [cfg.authOrigin, cfg.logoutPath, refresh]\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 const value = React.useMemo<OcSessionState>(() => {\n const returnTo =\n defaultReturnTo ?? (typeof window !== 'undefined' ? window.location.href : undefined);\n return {\n status,\n account,\n roster,\n tabPinned,\n error,\n refresh,\n signOut,\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 switchAccount,\n addAccountUrl,\n setDisplayIdentity,\n cfg,\n defaultReturnTo,\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,YA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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,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":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/signin.tsx"],"sourcesContent":["/**\n * @orangecheck/auth-client · OcSignIn\n *\n * In-place dual-path signin component for every `X.ochk.io` consumer site.\n * Calls the cross-subdomain auth host (`ochk.io`) via family-CORS so the\n * `.ochk.io` session cookie lands without any redirect.\n *\n * Two paths, one component:\n *\n * 1. Bitcoin wallet · BIP-322\n * - Paste address, in-page wallet extension signs a challenge\n * - POSTs { message, signature, expectedNonce, expectedAudience,\n * expectedPurpose } to ochk.io/api/auth/signin\n * - Identity is `did:oc:<rand>` linked to the BTC address\n *\n * 2. Email · OTP\n * - Enter email → ochk.io/api/auth/email-otp/start delivers a code\n * - Enter code → ochk.io/api/auth/email-otp/verify lands the cookie\n * - Identity is `did:oc:<rand>`. No wallet is created here: a Fedimint\n * wallet is provisioned client-side on first /me visit, and its sats\n * are held by the FEDERATION'S GUARDIANS — not by OrangeCheck, which\n * coordinates and never custodies (see oc-www's email-otp/verify\n * route). Naming the custodian is family invariant 8; the old wording\n * here and in the form copy said \"a custodial wallet\" with no subject,\n * which reads as OC holding it and contradicts the charter.\n *\n * **Both paths resolve to the same did:oc canonical identity** via the\n * auth host's account-linking logic — a user who started with email can\n * later link their BTC address (and vice versa). One identity, two doors,\n * persistent across every family subdomain.\n *\n * On success, the component **hard-navigates** (window.location.assign)\n * rather than calling onSuccess + relying on the consumer to route. This\n * is non-negotiable: OcSessionProvider does not auto-refetch /api/auth/me\n * on client-side route changes, so a soft redirect leaves it with stale\n * `status: 'anonymous'`. Hard nav forces the provider to remount with\n * the fresh cookie. Override via onSuccess if you must.\n */\n\nimport * as React from 'react';\n\nimport { addressInputValue } from './address';\nimport { LinkPromptStep } from './linked-identities';\nimport { stripFragment } from './return-to';\nimport { clearTabSession } from './tab-session';\nimport type { OcAccount } from './types';\nimport {\n SIGNIN_ARROW,\n SIGNIN_BUTTON_RADIUS,\n SIGNIN_CASE,\n SIGNIN_FONT,\n SIGNIN_STRONG,\n signinRadius,\n signinRoleSize,\n signinSize,\n signinTracking,\n} from './appearance';\n\n/* --- props --- */\n\ninterface OcSignInBaseProps {\n /**\n * Consumer-site audience URL passed as `expectedAudience` on the\n * BIP-322 challenge. e.g. `'https://vault.ochk.io'`. Required —\n * the challenge nonce is bound to this audience.\n */\n audience: string;\n /**\n * Where to navigate after success. Defaults to `'/'`.\n * Open-redirect-safe: a same-origin path (must start with `/`, NOT\n * `//`) or an absolute `https://` URL on `ochk.io` / `*.ochk.io` —\n * the add-another-account flow starts on a consumer subdomain and\n * must round-trip back to it, including through the OAuth provider\n * hop. Anything else is ignored. When omitted, the component reads\n * `?return_to=` (or `?next=`) from the page URL — so the auth\n * host's `/signin?add=1&return_to=…` entry point Just Works, the\n * same way the `add` prop auto-detects `?add=1`.\n */\n returnTo?: string;\n /**\n * Override the default hard-navigation behavior. When provided,\n * called with the account and the session JWT. The component will\n * NOT navigate — the caller is responsible. Use for custom\n * post-signin routing — e.g. /popup/signin postMessages\n * `{ account, token }` to its opener so a cross-domain integrator\n * (different eTLD+1 from .ochk.io, which the HttpOnly cookie can't\n * reach) can verify the session via JWKS.\n */\n onSuccess?: (account: OcAccount, token?: string) => void;\n /**\n * Async post-success routing. When provided (and `onSuccess` is\n * not), the component awaits `resolveReturnTo(account)` and\n * hard-navigates to the result instead of the static `returnTo`.\n *\n * This is the seam that lets a site keep persona-aware routing\n * without forking the ceremony — e.g. me.ochk.io resolves\n * `/api/me/intent` and routes to `/me/developer` | `/me/operator`\n * | `/me`. The returned value is open-redirect-checked exactly\n * like `returnTo` (same-origin paths only); on a resolver throw\n * the component falls back to the static `returnTo`.\n */\n resolveReturnTo?: (account: OcAccount) => string | Promise<string>;\n /**\n * Override the auth host. Defaults to `'https://ochk.io'`. For\n * preview / dev / staging only.\n */\n authOrigin?: string;\n /**\n * Initial visible tab. Defaults to `'email'` (since {@link providersFirst}\n * is on by default); resolves to `'wallet'` only when\n * `providersFirst={false}` and this is left unspecified.\n */\n initialPath?: 'wallet' | 'email';\n /**\n * Re-order the ceremony so the third-party providers (Google / GitHub)\n * render **above** the wallet + email panel, and the email path is the\n * default active tab. **On by default — the family standard.** A\n * first-time, non-Bitcoiner visitor sees the most familiar on-ramp\n * (Google / GitHub / email one-time code) first; the BIP-322 wallet path\n * stays one tab away, reframed as the most-sovereign option.\n *\n * Pass `providersFirst={false}` for the legacy bitcoin-first ordering.\n * Honors family rule #3 — email / OAuth is the easy bridge, the Bitcoin\n * address remains the canonical identity it resolves to.\n */\n providersFirst?: boolean;\n /**\n * Disable one of the two paths. Default is both enabled.\n * Useful for B2B-only sites that don't want to expose email-OTP.\n */\n paths?: { wallet?: boolean; email?: boolean };\n /**\n * Whether to show the \"also link my other identity\" checkbox on the\n * sign-in form. **On by default.** The checkbox is optional and\n * unchecked by default; it is shown on both the wallet and email\n * paths. If the user ticks it, the complementary identity's link\n * ceremony (BIP-322 for a wallet, OTP for an email) runs inline\n * immediately after a successful sign-in — before `onSuccess` /\n * `returnTo`, so it composes with custom routing — because the\n * sign-in just proved one credential and the link ceremony proves\n * the second. Pass `linkPrompt={false}` to omit the checkbox.\n */\n linkPrompt?: boolean;\n /**\n * Multi-account · when `true`, the sign-in is performed in \"add\"\n * mode: the resulting session is appended to the browser's existing\n * roster instead of replacing it. The previously-active account\n * stays signed in and remains a switch target on the auth host. Off\n * by default (back-compat). The component also reads `?add=1` from\n * the URL search params and treats it the same — so the auth host's\n * `/signin?add=1` entry point Just Works without any extra prop.\n *\n * The `add` flag is forwarded as a body field to the host's\n * `/api/auth/signin` and `/api/auth/email-otp/verify`; if the host\n * hasn't deployed the multi-account migration yet it silently\n * ignores the field and the call falls back to ordinary signin.\n */\n add?: boolean;\n /** className for the outer container. */\n className?: string;\n}\n\n/**\n * Where the ceremony's session goes.\n *\n * `family` (default): a `*.ochk.io` site. The auth host sets the shared\n * `.ochk.io` cookie and the component navigates.\n *\n * `first-party`: orangecheck's own site on another domain (ochk.app). Every\n * call to the auth host omits credentials, so the family cookie is neither\n * sent nor set; the host answers with a token bound to `audience`, handed to\n * `onSuccess` for the site to turn into its own cookie. No add-account or\n * link prompts (there is no family session to add to), and provider buttons\n * appear only when `providerHref` says where the site starts each one.\n */\nexport type OcSignInProps = OcSignInBaseProps &\n (\n | { mode?: 'family'; providerHref?: undefined }\n | {\n mode: 'first-party';\n onSuccess: (account: OcAccount, token?: string) => void;\n /** The site's own start URL for a provider (`google`, `github`). */\n providerHref?: (providerId: string) => string;\n }\n );\n\n/* --- shared types --- */\n\ninterface SigninJsonOk {\n ok: true;\n account: OcAccount;\n /**\n * The session JWT, echoed alongside the `Set-Cookie`. Cross-domain\n * integrators capture this to verify the session via JWKS — the\n * HttpOnly `.ochk.io` cookie never reaches their origin. Family\n * `.ochk.io` sites ignore it and rely on the cookie.\n */\n token?: string;\n}\n\ninterface SigninJsonErr {\n ok?: false;\n reason?: string;\n error?: string;\n issues?: unknown;\n}\n\ntype SigninJson = SigninJsonOk | SigninJsonErr;\n\n/* --- helpers --- */\n\n/**\n * A relative path is same-origin only if it RESOLVES to this origin.\n *\n * Prefix checks are not enough. `startsWith('/') && !startsWith('//')` accepts\n * `/\\evil.example`, and the WHATWG URL parser treats a backslash as a slash in\n * special schemes, so the browser resolves it to `https://evil.example/`:\n *\n * new URL('/\\evil.example', 'https://attest.ochk.io').href\n * -> 'https://evil.example/'\n *\n * Since hardNavigate() below hands its argument to window.location.assign,\n * that was a post-authentication open redirect on every consumer of this\n * package — the user completes a real sign-in on a real ochk.io domain and\n * lands on an attacker's page. `\\t`, `\\n` and `\\r` are stripped by the parser\n * too, so `/\\t/evil.example` is the same trick with different bytes.\n *\n * So instead of blacklisting characters, resolve and compare: whatever the URL\n * parser makes of the input is what the browser will navigate to, and that is\n * the thing that has to be same-origin.\n */\nfunction isSameOriginPath(candidate: string, origin: string): boolean {\n try {\n return new URL(candidate, origin).origin === origin;\n } catch {\n return false;\n }\n}\n\n/** Origin to resolve relative candidates against. Any absolute https origin\n * works for the comparison; on the server there is no window to read. */\nfunction resolutionOrigin(): string {\n return typeof window === 'undefined' ? 'https://ochk.io' : window.location.origin;\n}\n\nexport function safeReturnTo(input: string | undefined): string {\n const candidate = input ?? '/';\n if (typeof candidate !== 'string') return '/';\n if (!candidate.startsWith('/')) return '/';\n return isSameOriginPath(candidate, resolutionOrigin()) ? candidate : '/';\n}\n\n/**\n * Family-aware return target. Accepts a same-origin relative path\n * (exactly like {@link safeReturnTo}) OR an absolute `https://` URL on\n * `ochk.io` / `*.ochk.io` — mirroring the auth host's own post-signin\n * redirect allowlist. Returns `undefined` when the input is neither, so\n * callers can layer fallbacks.\n */\nexport function familyReturnTarget(input: string | undefined | null): string | undefined {\n if (typeof input !== 'string' || input.length === 0) return undefined;\n // Same-origin relative path — resolved, not prefix-matched. See\n // isSameOriginPath for why `/\\evil.example` defeated the old check.\n if (input.startsWith('/') && isSameOriginPath(input, resolutionOrigin())) {\n return input;\n }\n try {\n const u = new URL(input);\n if (u.protocol !== 'https:') return undefined;\n const host = u.hostname.toLowerCase();\n if (host === 'ochk.io' || host.endsWith('.ochk.io')) return u.toString();\n } catch {\n // not an absolute URL either\n }\n return undefined;\n}\n\nfunction hardNavigate(target: string): void {\n if (typeof window === 'undefined') return;\n window.location.assign(target);\n}\n\n/* --- failures people can act on --- */\n\n/**\n * The auth host answers with machine reasons. Its /api/auth/signin says it\n * exposes them \"so the /signin UI can give an actionable message\", and this\n * form printed them verbatim instead: typing \"hello\" as an address showed\n * `bad_request`. Each reason maps to what happened and what to do next.\n */\nconst SIGNIN_ERRORS: Record<string, string> = {\n bad_request: \"That doesn't look like a Bitcoin address.\",\n invalid_challenge:\n \"That signature doesn't match this address. Sign with the wallet that holds it.\",\n sig_invalid: \"That signature doesn't match this address. Sign with the wallet that holds it.\",\n sig_unsupported_scheme:\n \"We can't check this wallet's signature format yet. Try another wallet, or use email.\",\n expired: 'That request timed out. Try again for a fresh one.',\n not_yet_valid: 'That request is not valid yet. Check your device clock, then try again.',\n nonce_mismatch: \"That request didn't match. Try again for a fresh one.\",\n audience_mismatch: \"That request didn't match this site. Reload the page and try again.\",\n purpose_mismatch: \"That request didn't match. Try again for a fresh one.\",\n malformed: \"That signature couldn't be read. Copy it again, whole.\",\n cross_site_blocked: 'Your browser blocked this request. Reload the page and try again.',\n rate_limited: 'Too many tries. Wait a minute, then try again.',\n invalid_email: \"That email address doesn't look right.\",\n mailer_unavailable: \"We couldn't send the email right now. Try again in a minute.\",\n mailer_error: \"We couldn't send the email right now. Try again in a minute.\",\n wrong_code: \"That code isn't right. Check the newest email from us.\",\n replay: 'That code was already used. Send a new one.',\n invalid_token: 'That code is no longer valid. Send a new one.',\n email_mismatch: 'That code was sent to a different address. Send a new one.',\n};\n\nconst EMAIL_ERRORS: Record<string, string> = {\n expired: 'That code expired. Send a new one.',\n};\n\n/**\n * `bad_request` means the host's body schema failed. Fetching a challenge\n * that is the address; submitting a signature it is the pasted signature\n * (under 10 characters, say), which is not an address problem at all.\n */\nconst SUBMIT_ERRORS: Record<string, string> = {\n bad_request: \"That signature couldn't be read. Copy it again, whole.\",\n};\n\n/** The auth host by name, so an outage reads as theirs and not the page's. */\nexport function networkError(authOrigin: string): string {\n let host = authOrigin;\n try {\n host = new URL(authOrigin).host;\n } catch {\n // not a URL: name it as given\n }\n return `We couldn't reach the orangecheck sign-in service at ${host}. Check your connection, then try again.`;\n}\n\nexport function humanSigninError(\n reason: string,\n path: 'wallet' | 'email',\n step: 'challenge' | 'submit' = 'challenge'\n): string {\n // A reason that is not a code is already a sentence.\n if (!/^[a-z0-9_]+$/.test(reason)) return reason;\n if (path === 'wallet' && step === 'submit' && SUBMIT_ERRORS[reason]) return SUBMIT_ERRORS[reason];\n if (path === 'email' && EMAIL_ERRORS[reason]) return EMAIL_ERRORS[reason];\n return (\n SIGNIN_ERRORS[reason] ??\n (path === 'email'\n ? \"That didn't work. Try again, or send a new code.\"\n : \"That didn't work. Try again.\")\n );\n}\n\n/**\n * A failed fetch (\"Failed to fetch\") or an HTML error page parsed as JSON\n * (a SyntaxError) is not prose meant for a person; everything else thrown\n * here carries a host reason code. A wallet's failure never comes here.\n */\nfunction failureMessage(\n err: unknown,\n path: 'wallet' | 'email',\n step: 'challenge' | 'submit',\n authOrigin: string\n): string {\n if (err instanceof TypeError || err instanceof SyntaxError) return networkError(authOrigin);\n return humanSigninError(err instanceof Error ? err.message : 'failed', path, step);\n}\n\nconst BECH32_ADDRESS = /^(bc1|tb1|bcrt1)[qpzry9x8gf2tvdw0s3jn54khce6mua7l]{8,87}$/i;\nconst BASE58_ADDRESS = /^[123mn][1-9A-HJ-NP-Za-km-z]{25,34}$/;\n\n/**\n * Shape check only, so a typo fails here with a clear message instead of\n * fetching a challenge for it and then blaming a missing wallet extension.\n * The host still verifies the signature against the real address.\n */\nexport function looksLikeBitcoinAddress(input: string): boolean {\n const s = input.trim();\n // BIP-173: bech32 is all lowercase or all uppercase, never mixed.\n if (BECH32_ADDRESS.test(s)) return s === s.toLowerCase() || s === s.toUpperCase();\n return BASE58_ADDRESS.test(s);\n}\n\n/* --- main component --- */\n\nexport function OcSignIn({\n audience,\n returnTo,\n onSuccess,\n resolveReturnTo,\n linkPrompt: linkPromptProp = true,\n add: addProp,\n authOrigin = 'https://ochk.io',\n initialPath,\n providersFirst = true,\n paths,\n className,\n mode,\n providerHref,\n}: OcSignInProps): React.ReactElement {\n const walletEnabled = paths?.wallet ?? true;\n const emailEnabled = paths?.email ?? true;\n const firstParty = mode === 'first-party';\n // First-party: the family cookie must be neither sent nor set.\n const credentials: RequestCredentials = firstParty ? 'omit' : 'include';\n const linkPrompt = linkPromptProp && !firstParty;\n\n // Return target · prop wins; otherwise honor `?return_to=` / `?next=`\n // from the URL — the auth host's `/signin?add=1&return_to=…` entry\n // point needs the OAuth provider hop to carry the same target the\n // embedding page honors (the add-another-account fix: a vault user\n // adding an account via Google must land back on vault, not on the\n // host's homepage). Absolute https://*.ochk.io URLs are allowed;\n // everything else clamps to `/`.\n const [resolvedReturn, setResolvedReturn] = React.useState<string>(\n () => familyReturnTarget(returnTo) ?? safeReturnTo(returnTo)\n );\n React.useEffect(() => {\n const fromProp = familyReturnTarget(returnTo);\n if (fromProp) {\n setResolvedReturn(fromProp);\n return;\n }\n if (typeof window === 'undefined') return;\n const q = new URLSearchParams(window.location.search);\n const fromQuery =\n familyReturnTarget(q.get('return_to')) ?? familyReturnTarget(q.get('next'));\n setResolvedReturn(fromQuery ?? '/');\n }, [returnTo]);\n\n // Multi-account · prop wins; otherwise honor `?add=1` from the URL\n // so the auth host's /signin?add=1 entry point doesn't need any\n // extra wiring on every consumer's sign-in page.\n const [addMode, setAddMode] = React.useState<boolean>(Boolean(addProp) && !firstParty);\n React.useEffect(() => {\n if (typeof window === 'undefined') return;\n if (firstParty) {\n setAddMode(false);\n return;\n }\n if (addProp !== undefined) {\n setAddMode(Boolean(addProp));\n return;\n }\n setAddMode(new URLSearchParams(window.location.search).get('add') === '1');\n }, [addProp, firstParty]);\n\n // When providers lead the ceremony (ochk.io homepage), the email path\n // is the friendlier default tab; otherwise the canonical bitcoin-first\n // default holds. An explicit `initialPath` always wins.\n const [path, setPath] = React.useState<'wallet' | 'email'>(\n initialPath ?? (providersFirst ? 'email' : 'wallet')\n );\n // The two methods are one tablist: one Tab stop, arrows and Home/End move\n // between them, and moving selects (both are always offered).\n const tabsId = React.useId();\n const tabOrder: Array<'wallet' | 'email'> = providersFirst\n ? ['email', 'wallet']\n : ['wallet', 'email'];\n const tabRefs = React.useRef<Partial<Record<'wallet' | 'email', HTMLButtonElement | null>>>({});\n const onTabKey = (e: React.KeyboardEvent<HTMLButtonElement>) => {\n const i = tabOrder.indexOf(path);\n const last = tabOrder.length - 1;\n const to =\n e.key === 'ArrowRight' ? (i + 1) % tabOrder.length\n : e.key === 'ArrowLeft' ? (i + last) % tabOrder.length\n : e.key === 'Home' ? 0\n : e.key === 'End' ? last\n : -1;\n if (to < 0) return;\n e.preventDefault();\n const next = tabOrder[to]!;\n setPath(next);\n tabRefs.current[next]?.focus();\n };\n // Set once sign-in succeeds and the account is missing its\n // complementary identity — the component then renders the focused\n // link step (LinkPromptStep) before running `proceed`.\n const [signedIn, setSignedIn] = React.useState<{\n method: 'btc' | 'email';\n didOc: string;\n proceed: () => void;\n } | null>(null);\n // The optional \"also link my other identity\" checkbox on the form.\n const [linkAlso, setLinkAlso] = React.useState(false);\n // Set when the user is bounced back here after a failed provider\n // (e.g. Google) sign-in — the auth host redirects to\n // `/signin?oauth_error=…`.\n const [oauthError, setOauthError] = React.useState(false);\n React.useEffect(() => {\n if (typeof window === 'undefined') return;\n if (new URLSearchParams(window.location.search).has('oauth_error')) {\n setOauthError(true);\n }\n }, []);\n\n const navigate = React.useCallback(\n async (account: OcAccount) => {\n if (resolveReturnTo) {\n try {\n const resolved = familyReturnTarget(await resolveReturnTo(account));\n hardNavigate(resolved ?? resolvedReturn);\n return;\n } catch {\n // resolver failed — fall through to the static returnTo\n }\n }\n hardNavigate(resolvedReturn);\n },\n [resolveReturnTo, resolvedReturn]\n );\n\n const handleSuccess = React.useCallback(\n async (account: OcAccount, token: string | undefined, via: 'wallet' | 'email') => {\n // The post-sign-in handoff — custom `onSuccess`, else navigation.\n const proceed = () => {\n // Per-tab · the user just completed a ceremony IN this tab —\n // it must adopt the new identity, not keep a stale pin.\n clearTabSession();\n if (onSuccess) onSuccess(account, token);\n else void navigate(account);\n };\n\n // Linking is opt-in via the form checkbox. Unchecked (or the\n // checkbox suppressed) → ordinary sign-in.\n if (!linkPrompt || !linkAlso) {\n proceed();\n return;\n }\n\n // Checked: run the complementary identity's link ceremony now.\n // /api/auth/me resolves the did:oc the BIP-322 link challenge is\n // bound to; a failure here must not strand the signed-in user.\n try {\n const meRes = await fetch(`${authOrigin}/api/auth/me`, {\n credentials: 'include',\n headers: { Accept: 'application/json' },\n });\n const me = meRes.ok\n ? ((await meRes.json()) as { account?: { did_oc?: string } })\n : null;\n const didOc = me?.account?.did_oc;\n if (didOc) {\n setSignedIn({\n method: via === 'email' ? 'btc' : 'email',\n didOc,\n proceed,\n });\n return;\n }\n } catch {\n // /api/auth/me unreachable — proceed without the link step.\n }\n proceed();\n },\n [onSuccess, linkPrompt, linkAlso, navigate, authOrigin]\n );\n\n if (!walletEnabled && !emailEnabled) {\n return (\n <div\n className={className}\n data-oc-signin=\"\"\n style={{\n padding: '1rem',\n border: '1px solid var(--border, #27272a)',\n color: 'var(--foreground, #fafafa)',\n fontFamily: SIGNIN_FONT,\n fontSize: signinSize(12),\n }}\n >\n no signin paths enabled — set <code>paths.wallet</code> or{' '}\n <code>paths.email</code> to <code>true</code>\n </div>\n );\n }\n\n if (signedIn) {\n return (\n <div className={className} data-oc-signin=\"\">\n <LinkPromptStep\n method={signedIn.method}\n didOc={signedIn.didOc}\n authOrigin={authOrigin}\n onResolved={signedIn.proceed}\n />\n </div>\n );\n }\n\n const showWallet = walletEnabled && (path === 'wallet' || !emailEnabled);\n const showEmail = emailEnabled && (path === 'email' || !walletEnabled);\n const bothEnabled = walletEnabled && emailEnabled;\n // The method the user will actually sign in with — the active tab,\n // clamped when only one path is enabled. Drives the checkbox wording.\n const activeMethod: 'wallet' | 'email' = !emailEnabled\n ? 'wallet'\n : !walletEnabled\n ? 'email'\n : path;\n\n return (\n <div className={className} data-oc-signin=\"\">\n {oauthError && (\n <div\n data-oc-signin-oauth-error=\"\"\n style={{\n marginBottom: 14,\n padding: '0.6rem 0.75rem',\n border: '1px solid var(--destructive, #ef4444)',\n borderRadius: signinRadius(6),\n color: 'var(--destructive, #ef4444)',\n fontFamily: SIGNIN_FONT,\n fontSize: signinRoleSize('text', signinSize(11)),\n }}\n >\n That sign-in didn't finish. Try again, or use another way below.\n </div>\n )}\n {addMode && (\n <div\n data-oc-signin-add-mode=\"\"\n style={{\n marginBottom: 14,\n padding: '0.6rem 0.75rem',\n border: '1px solid var(--primary, #f97316)',\n borderLeftWidth: 3,\n borderRadius: signinRadius(4),\n background: 'color-mix(in srgb, var(--primary, #f97316) 8%, transparent)',\n color: 'var(--foreground, #fafafa)',\n fontFamily: SIGNIN_FONT,\n fontSize: signinRoleSize('text', signinSize(11)),\n lineHeight: 1.6,\n }}\n >\n <strong\n style={{\n color: 'var(--primary, #f97316)',\n letterSpacing: signinTracking('0.12em'),\n textTransform: SIGNIN_CASE,\n fontSize: signinSize(10),\n display: 'block',\n marginBottom: 3,\n }}\n >\n § adding another account\n </strong>\n Your current OrangeCheck account stays signed in. The new account joins your\n browser's roster; you can switch between them anytime from the account\n menu.\n </div>\n )}\n {/* Providers-first (ochk.io homepage): the familiar Google /\n GitHub on-ramp leads, with the wallet/email panel below the\n divider. Everywhere else this block stays at the bottom. */}\n {providersFirst && (\n <ProviderSignIn\n authOrigin={authOrigin}\n returnTo={resolvedReturn}\n add={addMode}\n credentials={credentials}\n firstParty={firstParty}\n providerHref={providerHref}\n first\n />\n )}\n {bothEnabled && (\n <div\n role=\"tablist\"\n aria-label=\"Sign-in method\"\n data-oc-signin-tabs=\"\"\n style={{\n display: 'flex',\n gap: 8,\n marginBottom: 16,\n borderBottom: '1px solid var(--border, #27272a)',\n }}\n >\n {/* When providers lead, the easy email path reads first\n and the wallet path sits beside it as the upgrade. */}\n {tabOrder.map((p) => (\n <SigninTab\n key={p}\n id={`${tabsId}-${p}`}\n controls={`${tabsId}-panel`}\n active={path === p}\n onClick={() => setPath(p)}\n onKeyDown={onTabKey}\n ref={(el) => {\n tabRefs.current[p] = el;\n }}\n >\n {p === 'email' ? 'Email' : 'Bitcoin wallet'}\n </SigninTab>\n ))}\n </div>\n )}\n\n <div\n data-oc-signin-panel=\"\"\n {...(bothEnabled\n ? {\n id: `${tabsId}-panel`,\n role: 'tabpanel',\n 'aria-labelledby': `${tabsId}-${path}`,\n }\n : {})}\n >\n {showWallet && (\n <WalletFlow\n authOrigin={authOrigin}\n audience={audience}\n add={addMode}\n credentials={credentials}\n onSuccess={(a, t) => void handleSuccess(a, t, 'wallet')}\n />\n )}\n {showEmail && (\n <EmailFlow\n authOrigin={authOrigin}\n add={addMode}\n credentials={credentials}\n onSuccess={(a, t) => void handleSuccess(a, t, 'email')}\n />\n )}\n </div>\n\n {!providersFirst && (\n <ProviderSignIn\n authOrigin={authOrigin}\n returnTo={resolvedReturn}\n add={addMode}\n credentials={credentials}\n firstParty={firstParty}\n providerHref={providerHref}\n />\n )}\n\n {linkPrompt && (\n <label data-oc-signin-linkalso=\"\" style={linkAlsoStyle}>\n <input\n type=\"checkbox\"\n checked={linkAlso}\n onChange={(e) => setLinkAlso(e.target.checked)}\n style={{ margin: 0, accentColor: 'var(--primary, #f97316)' }}\n />\n <span>\n After signing in, also link{' '}\n {activeMethod === 'email' ? 'a Bitcoin wallet' : 'an email'}{' '}\n <span>— optional, one more signature.</span>\n </span>\n </label>\n )}\n </div>\n );\n}\n\n/* --- tab --- */\n\nconst SigninTab = React.forwardRef<\n HTMLButtonElement,\n {\n id: string;\n controls: string;\n active: boolean;\n onClick: () => void;\n onKeyDown: (e: React.KeyboardEvent<HTMLButtonElement>) => void;\n children: React.ReactNode;\n }\n>(function SigninTab({ id, controls, active, onClick, onKeyDown, children }, ref) {\n return (\n <button\n ref={ref}\n type=\"button\"\n role=\"tab\"\n id={id}\n aria-selected={active}\n aria-controls={controls}\n tabIndex={active ? 0 : -1}\n onClick={onClick}\n onKeyDown={onKeyDown}\n data-oc-signin-tab={active ? 'active' : 'inactive'}\n style={{\n minHeight: 44,\n padding: '0.6rem 0.875rem',\n background: 'transparent',\n border: 'none',\n borderBottom: active\n ? '2px solid var(--primary, #f97316)'\n : '2px solid transparent',\n color: active\n ? 'var(--foreground, #fafafa)'\n : 'var(--muted-foreground, #a1a1aa)',\n fontFamily: SIGNIN_FONT,\n fontSize: signinRoleSize('label', signinSize(11)),\n letterSpacing: signinTracking('0.12em'),\n textTransform: SIGNIN_CASE,\n cursor: 'pointer',\n marginBottom: -1,\n }}\n >\n {children}\n </button>\n );\n});\n\n/* --- third-party provider sign-in --- */\n\ninterface OAuthProviderEntry {\n id: string;\n label: string;\n}\n\n/**\n * Brand glyph for a known OAuth provider — rendered inside the\n * provider button so each entry is visually recognisable, but drawn\n * in `currentColor` so it picks up the OC muted-foreground theme\n * (the family palette wins over each vendor's brand colours by\n * design). Unknown providers fall through to no icon — the button\n * still renders, just text-only, so the registry is forward-compatible.\n */\nfunction ProviderIcon({ id }: { id: string }): React.ReactElement | null {\n const common = {\n width: 14,\n height: 14,\n viewBox: '0 0 24 24',\n fill: 'currentColor',\n 'aria-hidden': true,\n style: { flex: '0 0 auto' } as React.CSSProperties,\n } as const;\n if (id === 'google') {\n return (\n <svg {...common}>\n <path d=\"M12.48 10.92v3.28h7.84c-.24 1.84-.853 3.187-1.787 4.133-1.147 1.147-2.933 2.4-6.053 2.4-4.827 0-8.6-3.893-8.6-8.72s3.773-8.72 8.6-8.72c2.6 0 4.507 1.027 5.907 2.347l2.307-2.307C18.747 1.44 16.133 0 12.48 0 5.867 0 .307 5.387.307 12s5.56 12 12.173 12c3.573 0 6.267-1.173 8.373-3.36 2.16-2.16 2.84-5.213 2.84-7.667 0-.76-.053-1.467-.173-2.053H12.48z\" />\n </svg>\n );\n }\n if (id === 'github') {\n return (\n <svg {...common}>\n <path d=\"M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12\" />\n </svg>\n );\n }\n return null;\n}\n\n/**\n * The secondary sign-in block — rendered below BIP-322 and email-OTP,\n * visibly less prominent. Each button is a plain navigation to the\n * auth host, which runs the OAuth dance and mints the family\n * `.ochk.io` session.\n *\n * The provider list is fetched from the auth host's\n * `/api/auth/providers` — a button appears only once that provider's\n * credentials are configured host-side. So enabling GitHub / Apple\n * later is a host env change, not a redeploy of every consumer site.\n * With no providers configured the whole block renders nothing.\n */\nfunction ProviderSignIn({\n authOrigin,\n returnTo,\n add,\n credentials,\n firstParty,\n providerHref,\n first = false,\n}: {\n authOrigin: string;\n returnTo: string;\n add: boolean;\n credentials: RequestCredentials;\n /** See OcSignInProps.mode: buttons only where the site starts them. */\n firstParty: boolean;\n providerHref?: (providerId: string) => string;\n /**\n * Render this block at the TOP of the ceremony (above the wallet/email\n * panel) rather than the default bottom. The \"or\" divider then sits\n * below the provider buttons, and the block reserves space beneath\n * itself instead of above. Set by {@link OcSignIn} when\n * `providersFirst` is on.\n */\n first?: boolean;\n}): React.ReactElement | null {\n // null while the list loads; [] once the host says none are configured.\n const [providers, setProviders] = React.useState<OAuthProviderEntry[] | null>(null);\n // A provider sign-in redirects THROUGH the auth host, so its final\n // redirect must carry an ABSOLUTE return target — a bare path would\n // resolve against ochk.io and strand a subdomain user there. The\n // origin is only knowable client-side.\n const [origin, setOrigin] = React.useState('');\n // A first-party site with no start route of its own has no provider path.\n const hidden = firstParty && !providerHref;\n\n React.useEffect(() => {\n setOrigin(window.location.origin);\n if (hidden) return;\n let cancelled = false;\n fetch(`${authOrigin}/api/auth/providers`, { credentials })\n .then((r) => (r.ok ? (r.json() as Promise<{ providers?: OAuthProviderEntry[] }>) : null))\n .then((body) => {\n if (!cancelled) setProviders(body?.providers ?? []);\n })\n .catch(() => {\n // auth host unreachable — no provider buttons; the\n // BIP-322 / email-OTP paths are unaffected.\n if (!cancelled) setProviders([]);\n });\n return () => {\n cancelled = true;\n };\n }, [authOrigin, credentials, hidden]);\n\n if (hidden) return null;\n if (providers !== null && providers.length === 0) return null;\n\n // An absolute family URL (the add-another-account round trip back to\n // a consumer subdomain) is carried verbatim through the OAuth hop;\n // a relative path is anchored to THIS page's origin.\n // It rides in the provider's start URL, so never with its fragment.\n const providerReturnTo = stripFragment(\n returnTo.startsWith('/') ? (origin ? `${origin}${returnTo}` : returnTo) : returnTo\n );\n const line = { flex: 1, height: 1, background: 'var(--border, #27272a)' } as const;\n // Vertical rhythm. The \"or\" divider is a horizontal rule between two\n // blocks, so it must sit EQUIDISTANT from both — otherwise it reads as\n // belonging to whichever block it is closer to. It previously ran\n // 14px above / 4px below (plus 4px of container margin), which glued the\n // rule to the panel beneath it and left the provider buttons floating.\n // BLOCK_GAP matches the tab row's own 16px marginBottom so the whole\n // ceremony sits on one 4px-scale rhythm rather than an ad-hoc\n // 0/4/8/14/16/20 mix.\n const BLOCK_GAP = 16;\n const BUTTON_GAP = 8; // siblings group tighter than blocks separate\n const divider = (\n <div\n style={{\n display: 'flex',\n alignItems: 'center',\n gap: 10,\n // Symmetric in both orderings: in `first` mode the divider\n // owns the gap on both sides; at the bottom the container's\n // marginTop owns the gap above, so the divider only pads below.\n margin: first ? `${BLOCK_GAP}px 0` : `0 0 ${BLOCK_GAP}px`,\n color: 'var(--muted-foreground, #a1a1aa)',\n fontFamily: SIGNIN_FONT,\n fontSize: signinRoleSize('hint', signinSize(10)),\n letterSpacing: signinTracking('0.16em'),\n textTransform: SIGNIN_CASE,\n }}\n >\n <span style={line} />\n or\n <span style={line} />\n </div>\n );\n const buttonStyle = (i: number): React.CSSProperties => ({\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n gap: 10,\n boxSizing: 'border-box',\n width: '100%',\n minHeight: 44,\n marginTop: i === 0 ? 0 : BUTTON_GAP,\n padding: '0.6rem 0.875rem',\n border: '1px solid var(--border, #27272a)',\n borderRadius: SIGNIN_BUTTON_RADIUS,\n background: 'transparent',\n color: 'var(--muted-foreground, #a1a1aa)',\n fontFamily: SIGNIN_FONT,\n fontSize: signinSize(12),\n textDecoration: 'none',\n });\n // While the list loads, hold the space two buttons will take. Rendering\n // nothing and then inserting them above the form pushed it down after\n // first paint: most of /signin?add=1's CLS (0.11 at 390).\n if (providers === null) {\n if (!first) return null;\n return (\n <div data-oc-signin-providers=\"\" aria-hidden=\"true\">\n {[0, 1].map((i) => (\n <div key={i} style={{ ...buttonStyle(i), visibility: 'hidden' }}>\n \n </div>\n ))}\n {divider}\n </div>\n );\n }\n const buttons = providers.map((p, i) => (\n <a\n key={p.id}\n href={\n providerHref\n ? providerHref(p.id)\n : `${authOrigin}/api/auth/${p.id}/start?return_to=${encodeURIComponent(\n providerReturnTo\n )}${add ? '&add=1' : ''}`\n }\n data-oc-signin-provider={p.id}\n style={buttonStyle(i)}\n >\n <ProviderIcon id={p.id} />\n <span>{p.label}</span>\n </a>\n ));\n // first → providers lead: buttons, then the \"or\" divider before the\n // wallet/email panel below. Otherwise the canonical bottom placement:\n // divider, then buttons.\n return (\n <div\n data-oc-signin-providers=\"\"\n style={first ? { marginBottom: 0 } : { marginTop: BLOCK_GAP }}\n >\n {first ? (\n <>\n {buttons}\n {divider}\n </>\n ) : (\n <>\n {divider}\n {buttons}\n </>\n )}\n </div>\n );\n}\n\n/* --- wallet flow --- */\n\ninterface FlowProps {\n authOrigin: string;\n /** Multi-account add-mode · see OcSignIn.add. */\n add?: boolean;\n /** `omit` in first-party mode · see OcSignInProps.mode. */\n credentials: RequestCredentials;\n onSuccess: (account: OcAccount, token?: string) => void;\n}\n\ninterface WalletFlowProps extends FlowProps {\n audience: string;\n}\n\ntype AdapterShape = {\n detectWallets: () => Array<{ id: string; name: string; detected: boolean }>;\n getSigner: (id: string, opts: { address: string }) => (message: string) => Promise<string>;\n walletFailureText: (err: unknown, opts?: { paste?: boolean }) => string;\n};\n\nasync function loadAdapter(): Promise<AdapterShape> {\n // A dependency, not an optional peer: this is a *static* dynamic import, so\n // the consumer's bundler must resolve it at build time and a missing package\n // fails the build. The old `Function('m','return import(m)')` trick produced\n // a runtime bare-specifier `import()` the browser cannot resolve without an\n // import map — which is what broke sign-in everywhere.\n return (await import('@orangecheck/wallet-adapter')) as unknown as AdapterShape;\n}\n\ntype DetectedWallet = { id: string; name: string };\n\nasync function detectBrowserWallets(): Promise<DetectedWallet[]> {\n return (await loadAdapter())\n .detectWallets()\n .filter((w) => w.detected && w.id !== 'manual')\n .map((w) => ({ id: w.id, name: w.name }));\n}\n\nfunction WalletFlow({\n authOrigin,\n audience,\n add,\n credentials,\n onSuccess,\n}: WalletFlowProps): React.ReactElement {\n const uid = React.useId();\n const ids = {\n address: `${uid}-address`,\n wallet: `${uid}-wallet`,\n message: `${uid}-message`,\n signature: `${uid}-signature`,\n };\n const [address, setAddress] = React.useState('');\n const [error, setError] = React.useState<string | null>(null);\n const [submitting, setSubmitting] = React.useState(false);\n // Browser wallets on this device; null until the adapter has loaded.\n const [wallets, setWallets] = React.useState<DetectedWallet[] | null>(null);\n const [walletId, setWalletId] = React.useState<string | null>(null);\n // No browser wallet (every phone, Sparrow, hardware wallets): show the\n // challenge to sign elsewhere and take the signature back. This used to\n // end in \"no BIP-322 wallet extension detected · install one and refresh\".\n const [manual, setManual] = React.useState<{ message: string; nonce: string } | null>(null);\n const [pasted, setPasted] = React.useState('');\n const [copied, setCopied] = React.useState<'idle' | 'copied' | 'failed'>('idle');\n\n React.useEffect(() => {\n let cancelled = false;\n detectBrowserWallets()\n .then((found) => {\n if (cancelled) return;\n setWallets(found);\n setWalletId(found[0]?.id ?? null);\n })\n .catch(() => {\n if (!cancelled) setWallets([]);\n });\n return () => {\n cancelled = true;\n };\n }, []);\n\n async function fetchChallenge(addr: string): Promise<{ message: string; nonce: string }> {\n const res = await fetch(\n `${authOrigin}/api/challenge?addr=${encodeURIComponent(addr)}&audience=${encodeURIComponent(audience)}&purpose=login`\n );\n const json = (await res.json()) as { message?: string; nonce?: string; error?: string };\n if (!res.ok || !json.message || !json.nonce) {\n throw new Error(json.error ?? 'challenge_failed');\n }\n return { message: json.message, nonce: json.nonce };\n }\n\n /**\n * POST the signature. A browser wallet signs BIP-322, so that path names\n * the scheme; a pasted one may be legacy BIP-137, so the manual path names\n * none. The host decides from the signature's bytes either way.\n */\n async function submitSignature(\n message: string,\n nonce: string,\n signature: string,\n scheme: 'bip322' | undefined\n ): Promise<void> {\n // Family-CORS lets the .ochk.io session cookie land cross-origin.\n const res = await fetch(`${authOrigin}/api/auth/signin`, {\n method: 'POST',\n credentials,\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n message,\n signature,\n ...(scheme ? { scheme } : {}),\n expectedNonce: nonce,\n expectedAudience: audience,\n expectedPurpose: 'login',\n // Multi-account add-mode · the auth host preserves the current\n // roster_id when set, instead of minting a fresh one.\n ...(add ? { add: true } : {}),\n }),\n });\n const json = (await res.json()) as SigninJson;\n if (!res.ok || !('ok' in json) || !json.ok || !json.account) {\n throw new Error(\n ('reason' in json && json.reason) ||\n ('error' in json && json.error) ||\n 'verify_failed'\n );\n }\n onSuccess(json.account, json.token);\n }\n\n async function signIn(e: React.FormEvent): Promise<void> {\n e.preventDefault();\n const addr = address.trim();\n if (!addr) {\n setError('Paste your Bitcoin address.');\n return;\n }\n if (!looksLikeBitcoinAddress(addr)) {\n setError(humanSigninError('bad_request', 'wallet'));\n return;\n }\n setError(null);\n setSubmitting(true);\n let step: 'challenge' | 'submit' = 'challenge';\n try {\n // Submitting before detection finished must not send someone with\n // an extension to the paste-a-signature path.\n let id = walletId;\n if (wallets === null) {\n const found = await detectBrowserWallets().catch(() => []);\n setWallets(found);\n id = found[0]?.id ?? null;\n setWalletId(id);\n }\n const challenge = await fetchChallenge(addr);\n if (!id) {\n setManual(challenge);\n setSubmitting(false);\n return;\n }\n const adapter = await loadAdapter();\n let signature: string;\n try {\n signature = await adapter.getSigner(id, { address: addr })(challenge.message);\n } catch (err) {\n // The wallet's own words never reach a person; the adapter names the cause.\n setError(adapter.walletFailureText(err));\n setSubmitting(false);\n return;\n }\n step = 'submit';\n await submitSignature(challenge.message, challenge.nonce, signature, 'bip322');\n } catch (err) {\n setError(failureMessage(err, 'wallet', step, authOrigin));\n setSubmitting(false);\n }\n }\n\n async function signInManual(e: React.FormEvent): Promise<void> {\n e.preventDefault();\n if (!manual) return;\n const sig = pasted.trim();\n if (!sig) {\n setError('Paste the signature your wallet gave you.');\n return;\n }\n setError(null);\n setSubmitting(true);\n try {\n await submitSignature(manual.message, manual.nonce, sig, undefined);\n } catch (err) {\n setError(failureMessage(err, 'wallet', 'submit', authOrigin));\n setSubmitting(false);\n }\n }\n\n async function copyMessage(): Promise<void> {\n if (!manual) return;\n try {\n await navigator.clipboard.writeText(manual.message);\n setCopied('copied');\n } catch {\n setCopied('failed');\n }\n }\n\n if (manual) {\n return (\n <form onSubmit={signInManual} data-oc-signin-wallet-manual=\"\">\n <FlowHeader>\n In your wallet, use “sign message” (BIP-322) with {address.trim()}, sign the\n text below, and paste the signature back here. Nothing is spent.\n </FlowHeader>\n <Label htmlFor={ids.message}>Message to sign</Label>\n <textarea\n data-oca-field=\"\"\n id={ids.message}\n readOnly\n value={manual.message}\n rows={5}\n onFocus={(e) => e.currentTarget.select()}\n style={{ ...inputStyle, resize: 'vertical' }}\n />\n <button type=\"button\" onClick={() => void copyMessage()} style={linkButtonStyle}>\n {copied === 'copied' ? 'Copied' : 'Copy message'}\n </button>\n {copied === 'failed' && (\n <Hint>Couldn't copy here. Select the text above and copy it.</Hint>\n )}\n <div style={{ marginTop: 14 }}>\n <Label htmlFor={ids.signature}>Signature</Label>\n <textarea\n data-oca-field=\"\"\n id={ids.signature}\n value={pasted}\n onChange={(e) => {\n setPasted(e.target.value);\n if (error) setError(null);\n }}\n rows={3}\n placeholder=\"paste the signature\"\n spellCheck={false}\n autoFocus\n aria-invalid={error ? true : undefined}\n style={{ ...inputStyle, resize: 'vertical' }}\n />\n </div>\n {error && <ErrorLine>{error}</ErrorLine>}\n <button\n type=\"submit\"\n disabled={submitting || !pasted.trim()}\n style={submitStyle(submitting || !pasted.trim())}\n >\n {submitting ? 'Checking…' : <Submit>Sign me in</Submit>}\n </button>\n <button\n type=\"button\"\n onClick={() => {\n setManual(null);\n setPasted('');\n setError(null);\n setCopied('idle');\n }}\n style={linkButtonStyle}\n >\n Use a different address\n </button>\n </form>\n );\n }\n\n const noBrowserWallet = wallets !== null && wallets.length === 0;\n return (\n <form onSubmit={signIn} data-oc-signin-wallet=\"\">\n <FlowHeader>\n Your wallet signs a short message to prove you hold the address. Nothing is spent\n and your key never leaves the wallet. Works with browser wallets, or any wallet that\n can sign a message, like Sparrow.\n </FlowHeader>\n <Label htmlFor={ids.address}>Bitcoin address</Label>\n <input\n data-oca-field=\"\"\n id={ids.address}\n type=\"text\"\n value={address}\n onChange={(e) => {\n setAddress(addressInputValue(e.target.value));\n if (error) setError(null);\n }}\n placeholder=\"bc1q… · 3… · 1…\"\n autoComplete=\"off\"\n autoCapitalize=\"none\"\n spellCheck={false}\n required\n aria-invalid={error ? true : undefined}\n style={inputStyle}\n />\n {wallets && wallets.length > 1 && (\n <div style={{ marginTop: 12 }}>\n <Label htmlFor={ids.wallet}>Sign with</Label>\n <select\n id={ids.wallet}\n value={walletId ?? ''}\n onChange={(e) => setWalletId(e.target.value)}\n style={inputStyle}\n >\n {wallets.map((w) => (\n <option key={w.id} value={w.id}>\n {w.name}\n </option>\n ))}\n </select>\n </div>\n )}\n {error && <ErrorLine>{error}</ErrorLine>}\n <button\n type=\"submit\"\n disabled={submitting || !address.trim()}\n style={submitStyle(submitting || !address.trim())}\n >\n {submitting\n ? 'Waiting for wallet…'\n : noBrowserWallet\n ? <Submit>Get the message to sign</Submit>\n : <Submit>Sign in with wallet</Submit>}\n </button>\n {noBrowserWallet && (\n <Hint>No browser wallet found here. You can sign with any wallet and paste.</Hint>\n )}\n </form>\n );\n}\n\n/* --- email flow --- */\n\ntype EmailStage = 'enter' | 'code';\n\nfunction EmailFlow({ authOrigin, add, credentials, onSuccess }: FlowProps): React.ReactElement {\n const uid = React.useId();\n const [stage, setStage] = React.useState<EmailStage>('enter');\n const [email, setEmail] = React.useState('');\n const [emailError, setEmailError] = React.useState<string | null>(null);\n const [code, setCode] = React.useState('');\n const [codeError, setCodeError] = React.useState<string | null>(null);\n const [token, setToken] = React.useState<string | null>(null);\n const [submitting, setSubmitting] = React.useState(false);\n const [resent, setResent] = React.useState(false);\n\n /** Ask the host to email a code. Returns a human error, or null on success. */\n async function sendCode(address: string): Promise<string | null> {\n try {\n const res = await fetch(`${authOrigin}/api/auth/email-otp/start`, {\n method: 'POST',\n credentials,\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ email: address }),\n });\n const json = (await res.json()) as { ok?: boolean; token?: string; reason?: string };\n if (!res.ok || !json.token) return humanSigninError(json.reason ?? 'server_error', 'email');\n setToken(json.token);\n return null;\n } catch {\n return networkError(authOrigin);\n }\n }\n\n async function start(e: React.FormEvent): Promise<void> {\n e.preventDefault();\n const trimmed = email.trim().toLowerCase();\n if (!trimmed || !/.+@.+\\..+/.test(trimmed)) {\n setEmailError(humanSigninError('invalid_email', 'email'));\n return;\n }\n setEmailError(null);\n setSubmitting(true);\n const err = await sendCode(trimmed);\n setSubmitting(false);\n if (err) {\n setEmailError(err);\n return;\n }\n setEmail(trimmed);\n setStage('code');\n }\n\n async function resend(): Promise<void> {\n setCodeError(null);\n setResent(false);\n setSubmitting(true);\n const err = await sendCode(email);\n setSubmitting(false);\n setCode('');\n if (err) setCodeError(err);\n else setResent(true);\n }\n\n async function verify(e: React.FormEvent): Promise<void> {\n e.preventDefault();\n if (!token) return;\n if (code.length !== 6) {\n setCodeError('The code is 6 digits.');\n return;\n }\n setCodeError(null);\n setSubmitting(true);\n try {\n const res = await fetch(`${authOrigin}/api/auth/email-otp/verify`, {\n method: 'POST',\n credentials,\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n email,\n code,\n token,\n // Multi-account add-mode · see WalletFlow.\n ...(add ? { add: true } : {}),\n }),\n });\n const json = (await res.json()) as SigninJson;\n if (!res.ok || !('ok' in json) || !json.ok || !json.account) {\n throw new Error(\n ('reason' in json && json.reason) ||\n ('error' in json && json.error) ||\n 'server_error'\n );\n }\n onSuccess(json.account, json.token);\n } catch (err) {\n setCodeError(failureMessage(err, 'email', 'submit', authOrigin));\n } finally {\n setSubmitting(false);\n }\n }\n\n if (stage === 'enter') {\n return (\n <form onSubmit={start} data-oc-signin-email=\"\">\n <FlowHeader>\n We email you a 6-digit code. No password, and no wallet needed to start. Add a\n Bitcoin address any time: a way in that only you hold.\n </FlowHeader>\n <Label htmlFor={`${uid}-email`}>Email</Label>\n <input\n data-oca-field=\"\"\n id={`${uid}-email`}\n type=\"email\"\n autoComplete=\"email\"\n value={email}\n onChange={(e) => {\n setEmail(e.target.value);\n if (emailError) setEmailError(null);\n }}\n placeholder=\"you@example.com\"\n required\n aria-invalid={emailError ? true : undefined}\n style={inputStyle}\n />\n {emailError && <ErrorLine>{emailError}</ErrorLine>}\n <button type=\"submit\" disabled={submitting} style={submitStyle(submitting)}>\n {submitting ? 'Sending…' : <Submit>Send one-time code</Submit>}\n </button>\n </form>\n );\n }\n\n return (\n <form onSubmit={verify} data-oc-signin-email-verify=\"\">\n <FlowHeader>\n {resent ? 'Sent a new code to ' : 'Sent a 6-digit code to '}\n <span style={{ color: 'var(--foreground, #fafafa)' }}>{email}</span>. It expires in\n 10 minutes.\n </FlowHeader>\n <Label htmlFor={`${uid}-code`}>One-time code</Label>\n <input\n data-oca-field=\"\"\n id={`${uid}-code`}\n type=\"text\"\n inputMode=\"numeric\"\n pattern=\"\\d{6}\"\n maxLength={6}\n autoComplete=\"one-time-code\"\n value={code}\n onChange={(e) => {\n setCode(e.target.value.replace(/\\D/g, '').slice(0, 6));\n if (codeError) setCodeError(null);\n }}\n placeholder=\"6 digits\"\n required\n autoFocus\n aria-invalid={codeError ? true : undefined}\n style={{ ...inputStyle, letterSpacing: '0.4em', fontSize: 16 }}\n />\n {codeError && <ErrorLine>{codeError}</ErrorLine>}\n <button\n type=\"submit\"\n disabled={submitting || code.length !== 6}\n style={submitStyle(submitting || code.length !== 6)}\n >\n {submitting ? 'Verifying…' : <Submit>Verify · sign me in</Submit>}\n </button>\n <div>\n <button\n type=\"button\"\n onClick={() => void resend()}\n disabled={submitting}\n style={linkButtonStyle}\n >\n Send a new code\n </button>\n <button\n type=\"button\"\n onClick={() => {\n setStage('enter');\n setCode('');\n setToken(null);\n setResent(false);\n }}\n style={linkButtonStyle}\n >\n Use a different email\n </button>\n </div>\n </form>\n );\n}\n\n/* --- shared subcomponents --- */\n\n/** A submit label and its arrow, which a site can hide (--oc-signin-arrow). */\nfunction Submit({ children }: { children: string }): React.ReactElement {\n return (\n <>\n {children}\n <span aria-hidden=\"true\" style={{ display: SIGNIN_ARROW }}>\n {' →'}\n </span>\n </>\n );\n}\n\nfunction FlowHeader({\n label,\n children,\n}: {\n /** Omitted where the active tab already names the method. */\n label?: string;\n children: React.ReactNode;\n}): React.ReactElement {\n return (\n <div style={{ marginBottom: 16 }}>\n {label && (\n <div\n style={{\n color: 'var(--primary, #f97316)',\n fontFamily: SIGNIN_FONT,\n fontSize: signinSize(10),\n letterSpacing: signinTracking('0.18em'),\n textTransform: SIGNIN_CASE,\n marginBottom: 6,\n }}\n >\n {label}\n </div>\n )}\n <p\n style={{\n color: 'var(--muted-foreground, #a1a1aa)',\n fontSize: signinRoleSize('text', '13px'),\n lineHeight: 1.55,\n margin: 0,\n }}\n >\n {children}\n </p>\n </div>\n );\n}\n\nconst linkButtonStyle: React.CSSProperties = {\n display: 'inline-flex',\n alignItems: 'center',\n minHeight: 44,\n marginTop: 4,\n marginRight: 16,\n background: 'transparent',\n border: 'none',\n color: 'var(--muted-foreground, #a1a1aa)',\n fontFamily: SIGNIN_FONT,\n fontSize: signinRoleSize('button', signinSize(11)),\n letterSpacing: signinTracking('0.12em'),\n textTransform: SIGNIN_CASE,\n cursor: 'pointer',\n padding: 0,\n};\n\nfunction Label({\n htmlFor,\n children,\n}: {\n htmlFor: string;\n children: React.ReactNode;\n}): React.ReactElement {\n return (\n <label\n htmlFor={htmlFor}\n style={{\n display: 'block',\n color: 'var(--foreground, #fafafa)',\n fontFamily: SIGNIN_FONT,\n fontSize: signinRoleSize('label', signinSize(11)),\n letterSpacing: signinTracking('0.12em'),\n textTransform: SIGNIN_CASE,\n marginBottom: 6,\n }}\n >\n {children}\n </label>\n );\n}\n\nconst inputStyle: React.CSSProperties = {\n width: '100%',\n padding: '0.55rem 0.75rem',\n background: 'var(--background, #0a0a0a)',\n color: 'var(--foreground, #fafafa)',\n border: '1px solid var(--input, #27272a)',\n borderRadius: signinRadius(6),\n fontFamily: SIGNIN_FONT,\n // 16px — never below it. A sub-16px font-size makes iOS Safari\n // auto-zoom the viewport on focus; the family rule is >=16px on\n // every form field. Desktop reads fine at 16 too.\n fontSize: 16,\n};\n\nconst linkAlsoStyle: React.CSSProperties = {\n display: 'flex',\n alignItems: 'center',\n // The whole row is the checkbox's hit area; the 13px box alone was not.\n minHeight: 44,\n gap: 8,\n marginTop: 16,\n paddingTop: 14,\n borderTop: '1px solid var(--border, #27272a)',\n color: 'var(--muted-foreground, #a1a1aa)',\n fontFamily: SIGNIN_FONT,\n fontSize: signinRoleSize('text', signinSize(12)),\n lineHeight: 1.5,\n cursor: 'pointer',\n};\n\nfunction submitStyle(disabled: boolean): React.CSSProperties {\n return {\n marginTop: 12,\n padding: '0.6rem 1rem',\n background: 'var(--primary, #f97316)',\n color: 'var(--primary-foreground, #0a0a0a)',\n border: 'none',\n borderRadius: SIGNIN_BUTTON_RADIUS,\n fontFamily: SIGNIN_FONT,\n fontSize: signinRoleSize('button', signinSize(11)),\n letterSpacing: signinTracking('0.14em'),\n textTransform: SIGNIN_CASE,\n fontWeight: SIGNIN_STRONG,\n cursor: disabled ? 'not-allowed' : 'pointer',\n opacity: disabled ? 0.5 : 1,\n width: '100%',\n };\n}\n\nfunction ErrorLine({ children }: { children: React.ReactNode }): React.ReactElement {\n return (\n <p\n role=\"alert\"\n style={{\n marginTop: 6,\n marginBottom: 0,\n color: 'var(--destructive, #ef4444)',\n fontFamily: SIGNIN_FONT,\n fontSize: signinRoleSize('hint', signinSize(11)),\n letterSpacing: '0.04em',\n }}\n >\n {children}\n </p>\n );\n}\n\nfunction Hint({ children }: { children: React.ReactNode }): React.ReactElement {\n return (\n <p\n style={{\n marginTop: 12,\n marginBottom: 0,\n color: 'var(--muted-foreground, #a1a1aa)',\n fontFamily: SIGNIN_FONT,\n fontSize: signinRoleSize('hint', '10.5px'),\n lineHeight: 1.55,\n }}\n >\n {children}\n </p>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,YAAY,WAAW;AA2gBX,SAwcI,UA7b8B,KAXlC;AA3UZ,SAAS,iBAAiB,WAAmB,QAAyB;AAClE,MAAI;AACA,WAAO,IAAI,IAAI,WAAW,MAAM,EAAE,WAAW;AAAA,EACjD,QAAQ;AACJ,WAAO;AAAA,EACX;AACJ;AAIA,SAAS,mBAA2B;AAChC,SAAO,OAAO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AAW,EAAE,CAAC;AAAA,QAC/C,eAAe;AAAA,MACnB;AAAA,MAEC;AAAA;AAAA,EACL;AAER;AAEA,SAAS,KAAK,EAAE,SAAS,GAAsD;AAC3E,SACI;AAAA,IAAC;AAAA;AAAA,MACG,OAAO;AAAA,QACH,WAAW;AAAA,QACX,cAAc;AAAA,QACd,OAAO;AAAA,QACP,YAAY;AAAA,QACZ,UAAU,eAAe,QAAQ,QAAQ;AAAA,QACzC,YAAY;AAAA,MAChB;AAAA,MAEC;AAAA;AAAA,EACL;AAER;","names":["SigninTab"]}
|
|
@@ -1 +0,0 @@
|
|
|
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 * Slug of the federation this user is bound to (their \"home\"\n * federation). Multi-federation routing reads this; null/undefined\n * means \"not yet bound — fall back to the directory default at\n * /api/federations\". v1 has one live federation, so this is set on\n * first signin and rarely changes.\n */\n homeFederation?: string | null;\n /**\n * Where this user is on the custody-state graph:\n *\n * - 'fedimint_threshold' — federation custody (OC-introduced)\n * - 'fedimint_client' — federation custody (user-picked)\n * - 'bip322' — full self-custody\n *\n * Graduation is the product thesis. Treat undefined as\n * 'fedimint_threshold' for `did:email:` addresses and 'bip322' for\n * Bitcoin addresses (the default-by-construction mapping for\n * tokens minted before this field shipped).\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\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.\n */\n signOut: (opts?: { scope?: OcSignOutScope }) => Promise<void>;\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;AAqO9D,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":[]}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|