@orangecheck/auth-client 2.40.1 → 2.42.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -6
- package/dist/bond.mjs +6 -5
- package/dist/{chunk-S6YP5Q5X.mjs → chunk-CVK452X3.mjs} +9 -14
- package/dist/chunk-CVK452X3.mjs.map +1 -0
- package/dist/{chunk-O45WZCJI.mjs → chunk-F7O4OREM.mjs} +2 -2
- package/dist/{chunk-JMXIH6AH.mjs → chunk-FMPBHB3Q.mjs} +2 -2
- package/dist/{chunk-FKROF5NN.mjs → chunk-JLMDCC6K.mjs} +24 -12
- package/dist/chunk-JLMDCC6K.mjs.map +1 -0
- package/dist/{chunk-AIP3GYPO.mjs → chunk-M2VUFCZU.mjs} +3 -3
- package/dist/{chunk-AIP3GYPO.mjs.map → chunk-M2VUFCZU.mjs.map} +1 -1
- package/dist/{chunk-IYK4KW6B.mjs → chunk-MK45WO7U.mjs} +12 -9
- package/dist/chunk-MK45WO7U.mjs.map +1 -0
- package/dist/chunk-OKHAVNEU.mjs +48 -0
- package/dist/chunk-OKHAVNEU.mjs.map +1 -0
- package/dist/{chunk-A4A6OEVX.mjs → chunk-PQHFAVVM.mjs} +1 -1
- package/dist/chunk-PQHFAVVM.mjs.map +1 -0
- package/dist/{chunk-LA2VDQSE.mjs → chunk-VQY7IYHV.mjs} +26 -9
- package/dist/chunk-VQY7IYHV.mjs.map +1 -0
- package/dist/components.mjs +3 -3
- package/dist/controls.mjs +9 -0
- package/dist/controls.mjs.map +1 -0
- package/dist/index.d.ts +11 -1
- package/dist/index.js +91 -30
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -9
- package/dist/linked-identities.mjs +3 -3
- package/dist/provider.mjs +2 -2
- package/dist/signin.mjs +6 -5
- package/dist/sudo.mjs +2 -2
- package/dist/types.mjs +1 -1
- package/dist/webauthn.mjs +3 -3
- package/package.json +1 -1
- package/dist/chunk-A4A6OEVX.mjs.map +0 -1
- package/dist/chunk-FKROF5NN.mjs.map +0 -1
- package/dist/chunk-IYK4KW6B.mjs.map +0 -1
- package/dist/chunk-LA2VDQSE.mjs.map +0 -1
- package/dist/chunk-S6YP5Q5X.mjs.map +0 -1
- /package/dist/{chunk-O45WZCJI.mjs.map → chunk-F7O4OREM.mjs.map} +0 -0
- /package/dist/{chunk-JMXIH6AH.mjs.map → chunk-FMPBHB3Q.mjs.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/webauthn.tsx"],"sourcesContent":["/**\n * WebAuthn / passkey hooks for OrangeCheck consumer subdomains.\n *\n * Three hooks, all routing through the auth host (rpId='ochk.io'):\n *\n * - `useWebAuthnRegister()` — bind a hardware key to the account.\n * - `useWebAuthnList()` — read + rename + revoke registered keys.\n * - `useStepUpAuth()` — prove possession of a key before a\n * sensitive action; the auth host\n * re-issues the session cookie with a\n * fresh `step_up_at` claim.\n *\n * Consumers don't talk to navigator.credentials directly — these hooks\n * own the round-trip to ochk.io + the @simplewebauthn/browser ceremony.\n *\n * Server-side gating is one import away in auth-core's\n * `verifyStepUpClaim(payload, { max_age_secs })`.\n */\n\nimport * as React from 'react';\nimport {\n startAuthentication,\n startRegistration,\n type AuthenticationResponseJSON,\n type PublicKeyCredentialCreationOptionsJSON,\n type PublicKeyCredentialRequestOptionsJSON,\n type RegistrationResponseJSON,\n} from '@simplewebauthn/browser';\n\nimport { useOcSession } from './provider';\nimport { resolveConfig, type OcAuthConfig } from './types';\n\n// ─── Shared types ───────────────────────────────────────────────────────\n\nexport interface WebAuthnCredentialPublic {\n id: string;\n label: string;\n authenticator_type: 'platform' | 'cross-platform' | 'unknown';\n transports: string[];\n user_verified: boolean;\n created_at: string;\n last_used_at: string | null;\n}\n\nexport type WebAuthnRegisterStatus =\n | 'idle'\n | 'requesting-options'\n | 'authenticating'\n | 'verifying'\n | 'success'\n | 'error';\n\nexport type WebAuthnAssertionStatus = WebAuthnRegisterStatus;\nexport type WebAuthnListStatus = 'loading' | 'ready' | 'error';\n\ninterface UseHostOptions {\n /** Override the auth host origin. Defaults to https://ochk.io.\n * Same convention as <OcSessionProvider config={{ authOrigin }} />. */\n authOrigin?: string;\n}\n\nfunction resolveAuthOrigin(opts?: UseHostOptions | OcAuthConfig): string {\n if (!opts) return resolveConfig(undefined).authOrigin;\n return resolveConfig(opts as OcAuthConfig).authOrigin;\n}\n\ninterface OptionsResponse<T> {\n ok: boolean;\n options?: T;\n challenge_token?: string;\n reason?: string;\n}\n\nfunction isAbortError(err: unknown): boolean {\n if (!(err instanceof Error)) return false;\n return /NotAllowed|aborted|cancel|user cancelled/i.test(err.message);\n}\n\n// ─── useWebAuthnRegister ────────────────────────────────────────────────\n\nexport type WebAuthnRegisterResult =\n | { ok: true; credential: WebAuthnCredentialPublic }\n | { ok: false; reason: string };\n\nexport interface UseWebAuthnRegisterReturn {\n status: WebAuthnRegisterStatus;\n error: Error | null;\n register: (args?: { label?: string }) => Promise<WebAuthnRegisterResult>;\n reset: () => void;\n}\n\nexport function useWebAuthnRegister(opts?: UseHostOptions): UseWebAuthnRegisterReturn {\n const authOrigin = resolveAuthOrigin(opts);\n const [status, setStatus] = React.useState<WebAuthnRegisterStatus>('idle');\n const [error, setError] = React.useState<Error | null>(null);\n\n const reset = React.useCallback(() => {\n setStatus('idle');\n setError(null);\n }, []);\n\n const register = React.useCallback(\n async (args?: { label?: string }): Promise<WebAuthnRegisterResult> => {\n setError(null);\n setStatus('requesting-options');\n try {\n const optsRes = await fetch(`${authOrigin}/api/auth/webauthn/register/options`, {\n method: 'POST',\n credentials: 'include',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ label: args?.label }),\n });\n const optsBody = (await optsRes.json()) as OptionsResponse<PublicKeyCredentialCreationOptionsJSON>;\n if (!optsRes.ok || !optsBody.ok || !optsBody.options || !optsBody.challenge_token) {\n const reason = optsBody.reason ?? `options_failed_${optsRes.status}`;\n setError(new Error(reason));\n setStatus('error');\n return { ok: false, reason };\n }\n setStatus('authenticating');\n let attestation: RegistrationResponseJSON;\n try {\n attestation = await startRegistration({ optionsJSON: optsBody.options });\n } catch (e) {\n const reason = isAbortError(e) ? 'cancelled' : (e as Error).message;\n setError(new Error(reason));\n setStatus('error');\n return { ok: false, reason };\n }\n setStatus('verifying');\n const verifyRes = await fetch(`${authOrigin}/api/auth/webauthn/register/verify`, {\n method: 'POST',\n credentials: 'include',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n challenge_token: optsBody.challenge_token,\n response: attestation,\n label: args?.label,\n }),\n });\n const verifyBody = (await verifyRes.json()) as {\n ok: boolean;\n credential?: WebAuthnCredentialPublic;\n reason?: string;\n };\n if (!verifyRes.ok || !verifyBody.ok || !verifyBody.credential) {\n const reason = verifyBody.reason ?? `verify_failed_${verifyRes.status}`;\n setError(new Error(reason));\n setStatus('error');\n return { ok: false, reason };\n }\n setStatus('success');\n return { ok: true, credential: verifyBody.credential };\n } catch (e) {\n const reason = e instanceof Error ? e.message : String(e);\n setError(new Error(reason));\n setStatus('error');\n return { ok: false, reason };\n }\n },\n [authOrigin]\n );\n\n return { status, error, register, reset };\n}\n\n// ─── useWebAuthnList ────────────────────────────────────────────────────\n\nexport type WebAuthnRenameResult =\n | { ok: true; credential: WebAuthnCredentialPublic }\n | { ok: false; reason: string };\n\nexport type WebAuthnRemoveResult =\n | { ok: true }\n | { ok: false; reason: string };\n\nexport interface UseWebAuthnListReturn {\n status: WebAuthnListStatus;\n credentials: WebAuthnCredentialPublic[];\n error: Error | null;\n refetch: () => Promise<void>;\n rename: (id: string, label: string) => Promise<WebAuthnRenameResult>;\n remove: (id: string) => Promise<WebAuthnRemoveResult>;\n}\n\nexport function useWebAuthnList(opts?: UseHostOptions): UseWebAuthnListReturn {\n const authOrigin = resolveAuthOrigin(opts);\n const { status: sessionStatus } = useOcSession();\n const [credentials, setCredentials] = React.useState<WebAuthnCredentialPublic[]>([]);\n const [status, setStatus] = React.useState<WebAuthnListStatus>('loading');\n const [error, setError] = React.useState<Error | null>(null);\n\n const refetch = React.useCallback(async () => {\n setError(null);\n if (sessionStatus !== 'authenticated') {\n setCredentials([]);\n setStatus('ready');\n return;\n }\n setStatus('loading');\n try {\n const r = await fetch(`${authOrigin}/api/auth/webauthn/credentials`, {\n credentials: 'include',\n });\n if (r.status === 401) {\n setCredentials([]);\n setStatus('ready');\n return;\n }\n const j = (await r.json()) as {\n ok: boolean;\n credentials?: WebAuthnCredentialPublic[];\n reason?: string;\n };\n if (!j.ok || !j.credentials) {\n throw new Error(j.reason ?? 'list_failed');\n }\n setCredentials(j.credentials);\n setStatus('ready');\n } catch (e) {\n setError(e instanceof Error ? e : new Error(String(e)));\n setStatus('error');\n }\n }, [authOrigin, sessionStatus]);\n\n React.useEffect(() => {\n void refetch();\n }, [refetch]);\n\n const rename = React.useCallback(\n async (id: string, label: string): Promise<WebAuthnRenameResult> => {\n try {\n const r = await fetch(`${authOrigin}/api/auth/webauthn/credentials/${id}`, {\n method: 'PATCH',\n credentials: 'include',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ label }),\n });\n const j = (await r.json()) as {\n ok: boolean;\n credential?: WebAuthnCredentialPublic;\n reason?: string;\n };\n if (!j.ok || !j.credential) {\n const reason = j.reason ?? `rename_failed_${r.status}`;\n setError(new Error(reason));\n return { ok: false, reason };\n }\n await refetch();\n return { ok: true, credential: j.credential };\n } catch (e) {\n const reason = e instanceof Error ? e.message : String(e);\n setError(new Error(reason));\n return { ok: false, reason };\n }\n },\n [authOrigin, refetch]\n );\n\n const remove = React.useCallback(\n async (id: string): Promise<WebAuthnRemoveResult> => {\n try {\n const r = await fetch(`${authOrigin}/api/auth/webauthn/credentials/${id}`, {\n method: 'DELETE',\n credentials: 'include',\n });\n const j = (await r.json()) as { ok: boolean; reason?: string };\n if (!j.ok) {\n const reason = j.reason ?? `delete_failed_${r.status}`;\n setError(new Error(reason));\n return { ok: false, reason };\n }\n await refetch();\n return { ok: true };\n } catch (e) {\n const reason = e instanceof Error ? e.message : String(e);\n setError(new Error(reason));\n return { ok: false, reason };\n }\n },\n [authOrigin, refetch]\n );\n\n return { status, credentials, error, refetch, rename, remove };\n}\n\n// ─── useStepUpAuth ──────────────────────────────────────────────────────\n\nexport type WebAuthnStepUpResult =\n | { ok: true; step_up_at: number }\n | { ok: false; reason: string };\n\nexport interface UseStepUpAuthReturn {\n status: WebAuthnAssertionStatus;\n error: Error | null;\n stepUp: (args: { purpose: string }) => Promise<WebAuthnStepUpResult>;\n reset: () => void;\n}\n\n/**\n * Prove possession of a registered hardware key before a sensitive\n * action. On success the auth host sets a fresh oc_session cookie\n * carrying `step_up_at = <unix-now>`; the provider re-fetches the\n * session so `verifyStepUpClaim(payload, …)` flips to true immediately.\n *\n * Throws via `error` (not via `throw`) when:\n * - the user has no credentials registered (`no_credentials_registered`)\n * - the user cancels the platform prompt (`cancelled`)\n * - the assertion fails verification on the host (`verify_failed`,\n * `cloned_authenticator`, `credential_outside_allowlist`, …)\n *\n * Caller pattern:\n *\n * const { stepUp } = useStepUpAuth();\n * const { refresh } = useOcSession();\n * const r = await stepUp({ purpose: 'spend_over_1m' });\n * if (!r) return; // user cancelled or step-up failed\n * await refresh(); // pick up the new step_up_at\n * // …proceed with the sensitive action\n */\nexport function useStepUpAuth(opts?: UseHostOptions): UseStepUpAuthReturn {\n const authOrigin = resolveAuthOrigin(opts);\n const { refresh } = useOcSession();\n const [status, setStatus] = React.useState<WebAuthnAssertionStatus>('idle');\n const [error, setError] = React.useState<Error | null>(null);\n\n const reset = React.useCallback(() => {\n setStatus('idle');\n setError(null);\n }, []);\n\n const stepUp = React.useCallback(\n async (args: { purpose: string }): Promise<WebAuthnStepUpResult> => {\n setError(null);\n setStatus('requesting-options');\n try {\n const optsRes = await fetch(`${authOrigin}/api/auth/webauthn/assertion/options`, {\n method: 'POST',\n credentials: 'include',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ purpose: args.purpose }),\n });\n const optsBody = (await optsRes.json()) as OptionsResponse<PublicKeyCredentialRequestOptionsJSON>;\n if (!optsRes.ok || !optsBody.ok || !optsBody.options || !optsBody.challenge_token) {\n const reason = optsBody.reason ?? `options_failed_${optsRes.status}`;\n setError(new Error(reason));\n setStatus('error');\n return { ok: false, reason };\n }\n setStatus('authenticating');\n let assertion: AuthenticationResponseJSON;\n try {\n assertion = await startAuthentication({ optionsJSON: optsBody.options });\n } catch (e) {\n const reason = isAbortError(e) ? 'cancelled' : (e as Error).message;\n setError(new Error(reason));\n setStatus('error');\n return { ok: false, reason };\n }\n setStatus('verifying');\n const verifyRes = await fetch(\n `${authOrigin}/api/auth/webauthn/assertion/verify`,\n {\n method: 'POST',\n credentials: 'include',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n challenge_token: optsBody.challenge_token,\n response: assertion,\n }),\n }\n );\n const verifyBody = (await verifyRes.json()) as {\n ok: boolean;\n step_up_at?: number;\n reason?: string;\n };\n if (!verifyRes.ok || !verifyBody.ok || typeof verifyBody.step_up_at !== 'number') {\n const reason = verifyBody.reason ?? `verify_failed_${verifyRes.status}`;\n setError(new Error(reason));\n setStatus('error');\n return { ok: false, reason };\n }\n // Re-fetch the session so consumers see the fresh\n // step_up_at claim without a separate `refresh()` call.\n await refresh();\n setStatus('success');\n return { ok: true, step_up_at: verifyBody.step_up_at };\n } catch (e) {\n const reason = e instanceof Error ? e.message : String(e);\n setError(new Error(reason));\n setStatus('error');\n return { ok: false, reason };\n }\n },\n [authOrigin, refresh]\n );\n\n return { status, error, stepUp, reset };\n}\n"],"mappings":";;;;;;;;AAmBA,YAAY,WAAW;AACvB;AAAA,EACI;AAAA,EACA;AAAA,OAKG;AAkCP,SAAS,kBAAkB,MAA8C;AACrE,MAAI,CAAC,KAAM,QAAO,cAAc,MAAS,EAAE;AAC3C,SAAO,cAAc,IAAoB,EAAE;AAC/C;AASA,SAAS,aAAa,KAAuB;AACzC,MAAI,EAAE,eAAe,OAAQ,QAAO;AACpC,SAAO,4CAA4C,KAAK,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U,MAAM;AACrE,mBAAS,IAAI,MAAM,MAAM,CAAC;AAC1B,oBAAU,OAAO;AACjB,iBAAO,EAAE,IAAI,OAAO,OAAO;AAAA,QAC/B;AAGA,cAAM,QAAQ;AACd,kBAAU,SAAS;AACnB,eAAO,EAAE,IAAI,MAAM,YAAY,WAAW,WAAW;AAAA,MACzD,SAAS,GAAG;AACR,cAAM,SAAS,aAAa,QAAQ,EAAE,UAAU,OAAO,CAAC;AACxD,iBAAS,IAAI,MAAM,MAAM,CAAC;AAC1B,kBAAU,OAAO;AACjB,eAAO,EAAE,IAAI,OAAO,OAAO;AAAA,MAC/B;AAAA,IACJ;AAAA,IACA,CAAC,YAAY,OAAO;AAAA,EACxB;AAEA,SAAO,EAAE,QAAQ,OAAO,QAAQ,MAAM;AAC1C;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/webauthn.tsx"],"sourcesContent":["/**\n * WebAuthn / passkey hooks for OrangeCheck consumer subdomains.\n *\n * Three hooks, all routing through the auth host (rpId='ochk.io'):\n *\n * - `useWebAuthnRegister()` — bind a hardware key to the account.\n * - `useWebAuthnList()` — read + rename + revoke registered keys.\n * - `useStepUpAuth()` — prove possession of a key before a\n * sensitive action; the auth host\n * re-issues the session cookie with a\n * fresh `step_up_at` claim.\n *\n * Consumers don't talk to navigator.credentials directly — these hooks\n * own the round-trip to ochk.io + the @simplewebauthn/browser ceremony.\n *\n * Server-side gating is one import away in auth-core's\n * `verifyStepUpClaim(payload, { max_age_secs })`.\n */\n\nimport * as React from 'react';\nimport {\n startAuthentication,\n startRegistration,\n type AuthenticationResponseJSON,\n type PublicKeyCredentialCreationOptionsJSON,\n type PublicKeyCredentialRequestOptionsJSON,\n type RegistrationResponseJSON,\n} from '@simplewebauthn/browser';\n\nimport { useOcSession } from './provider';\nimport { resolveConfig, type OcAuthConfig } from './types';\n\n// ─── Shared types ───────────────────────────────────────────────────────\n\nexport interface WebAuthnCredentialPublic {\n id: string;\n label: string;\n authenticator_type: 'platform' | 'cross-platform' | 'unknown';\n transports: string[];\n user_verified: boolean;\n created_at: string;\n last_used_at: string | null;\n}\n\nexport type WebAuthnRegisterStatus =\n | 'idle'\n | 'requesting-options'\n | 'authenticating'\n | 'verifying'\n | 'success'\n | 'error';\n\nexport type WebAuthnAssertionStatus = WebAuthnRegisterStatus;\nexport type WebAuthnListStatus = 'loading' | 'ready' | 'error';\n\ninterface UseHostOptions {\n /** Override the auth host origin. Defaults to https://ochk.io.\n * Same convention as <OcSessionProvider config={{ authOrigin }} />. */\n authOrigin?: string;\n}\n\nfunction resolveAuthOrigin(opts?: UseHostOptions | OcAuthConfig): string {\n if (!opts) return resolveConfig(undefined).authOrigin;\n return resolveConfig(opts as OcAuthConfig).authOrigin;\n}\n\ninterface OptionsResponse<T> {\n ok: boolean;\n options?: T;\n challenge_token?: string;\n reason?: string;\n}\n\nfunction isAbortError(err: unknown): boolean {\n if (!(err instanceof Error)) return false;\n return /NotAllowed|aborted|cancel|user cancelled/i.test(err.message);\n}\n\n// ─── useWebAuthnRegister ────────────────────────────────────────────────\n\nexport type WebAuthnRegisterResult =\n | { ok: true; credential: WebAuthnCredentialPublic }\n | { ok: false; reason: string };\n\nexport interface UseWebAuthnRegisterReturn {\n status: WebAuthnRegisterStatus;\n error: Error | null;\n register: (args?: { label?: string }) => Promise<WebAuthnRegisterResult>;\n reset: () => void;\n}\n\nexport function useWebAuthnRegister(opts?: UseHostOptions): UseWebAuthnRegisterReturn {\n const authOrigin = resolveAuthOrigin(opts);\n const [status, setStatus] = React.useState<WebAuthnRegisterStatus>('idle');\n const [error, setError] = React.useState<Error | null>(null);\n\n const reset = React.useCallback(() => {\n setStatus('idle');\n setError(null);\n }, []);\n\n const register = React.useCallback(\n async (args?: { label?: string }): Promise<WebAuthnRegisterResult> => {\n setError(null);\n setStatus('requesting-options');\n try {\n const optsRes = await fetch(`${authOrigin}/api/auth/webauthn/register/options`, {\n method: 'POST',\n credentials: 'include',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ label: args?.label }),\n });\n const optsBody = (await optsRes.json()) as OptionsResponse<PublicKeyCredentialCreationOptionsJSON>;\n if (!optsRes.ok || !optsBody.ok || !optsBody.options || !optsBody.challenge_token) {\n const reason = optsBody.reason ?? `options_failed_${optsRes.status}`;\n setError(new Error(reason));\n setStatus('error');\n return { ok: false, reason };\n }\n setStatus('authenticating');\n let attestation: RegistrationResponseJSON;\n try {\n attestation = await startRegistration({ optionsJSON: optsBody.options });\n } catch (e) {\n const reason = isAbortError(e) ? 'cancelled' : (e as Error).message;\n setError(new Error(reason));\n setStatus('error');\n return { ok: false, reason };\n }\n setStatus('verifying');\n const verifyRes = await fetch(`${authOrigin}/api/auth/webauthn/register/verify`, {\n method: 'POST',\n credentials: 'include',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n challenge_token: optsBody.challenge_token,\n response: attestation,\n label: args?.label,\n }),\n });\n const verifyBody = (await verifyRes.json()) as {\n ok: boolean;\n credential?: WebAuthnCredentialPublic;\n reason?: string;\n };\n if (!verifyRes.ok || !verifyBody.ok || !verifyBody.credential) {\n const reason = verifyBody.reason ?? `verify_failed_${verifyRes.status}`;\n setError(new Error(reason));\n setStatus('error');\n return { ok: false, reason };\n }\n setStatus('success');\n return { ok: true, credential: verifyBody.credential };\n } catch (e) {\n const reason = e instanceof Error ? e.message : String(e);\n setError(new Error(reason));\n setStatus('error');\n return { ok: false, reason };\n }\n },\n [authOrigin]\n );\n\n return { status, error, register, reset };\n}\n\n// ─── useWebAuthnList ────────────────────────────────────────────────────\n\nexport type WebAuthnRenameResult =\n | { ok: true; credential: WebAuthnCredentialPublic }\n | { ok: false; reason: string };\n\nexport type WebAuthnRemoveResult =\n | { ok: true }\n | { ok: false; reason: string };\n\nexport interface UseWebAuthnListReturn {\n status: WebAuthnListStatus;\n credentials: WebAuthnCredentialPublic[];\n error: Error | null;\n refetch: () => Promise<void>;\n rename: (id: string, label: string) => Promise<WebAuthnRenameResult>;\n remove: (id: string) => Promise<WebAuthnRemoveResult>;\n}\n\nexport function useWebAuthnList(opts?: UseHostOptions): UseWebAuthnListReturn {\n const authOrigin = resolveAuthOrigin(opts);\n const { status: sessionStatus } = useOcSession();\n const [credentials, setCredentials] = React.useState<WebAuthnCredentialPublic[]>([]);\n const [status, setStatus] = React.useState<WebAuthnListStatus>('loading');\n const [error, setError] = React.useState<Error | null>(null);\n\n const refetch = React.useCallback(async () => {\n setError(null);\n if (sessionStatus !== 'authenticated') {\n setCredentials([]);\n setStatus('ready');\n return;\n }\n setStatus('loading');\n try {\n const r = await fetch(`${authOrigin}/api/auth/webauthn/credentials`, {\n credentials: 'include',\n });\n if (r.status === 401) {\n setCredentials([]);\n setStatus('ready');\n return;\n }\n const j = (await r.json()) as {\n ok: boolean;\n credentials?: WebAuthnCredentialPublic[];\n reason?: string;\n };\n if (!j.ok || !j.credentials) {\n throw new Error(j.reason ?? 'list_failed');\n }\n setCredentials(j.credentials);\n setStatus('ready');\n } catch (e) {\n setError(e instanceof Error ? e : new Error(String(e)));\n setStatus('error');\n }\n }, [authOrigin, sessionStatus]);\n\n React.useEffect(() => {\n void refetch();\n }, [refetch]);\n\n const rename = React.useCallback(\n async (id: string, label: string): Promise<WebAuthnRenameResult> => {\n try {\n const r = await fetch(`${authOrigin}/api/auth/webauthn/credentials/${id}`, {\n method: 'PATCH',\n credentials: 'include',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ label }),\n });\n const j = (await r.json()) as {\n ok: boolean;\n credential?: WebAuthnCredentialPublic;\n reason?: string;\n };\n if (!j.ok || !j.credential) {\n const reason = j.reason ?? `rename_failed_${r.status}`;\n setError(new Error(reason));\n return { ok: false, reason };\n }\n await refetch();\n return { ok: true, credential: j.credential };\n } catch (e) {\n const reason = e instanceof Error ? e.message : String(e);\n setError(new Error(reason));\n return { ok: false, reason };\n }\n },\n [authOrigin, refetch]\n );\n\n const remove = React.useCallback(\n async (id: string): Promise<WebAuthnRemoveResult> => {\n try {\n const r = await fetch(`${authOrigin}/api/auth/webauthn/credentials/${id}`, {\n method: 'DELETE',\n credentials: 'include',\n });\n const j = (await r.json()) as { ok: boolean; reason?: string };\n if (!j.ok) {\n const reason = j.reason ?? `delete_failed_${r.status}`;\n setError(new Error(reason));\n return { ok: false, reason };\n }\n await refetch();\n return { ok: true };\n } catch (e) {\n const reason = e instanceof Error ? e.message : String(e);\n setError(new Error(reason));\n return { ok: false, reason };\n }\n },\n [authOrigin, refetch]\n );\n\n return { status, credentials, error, refetch, rename, remove };\n}\n\n// ─── useStepUpAuth ──────────────────────────────────────────────────────\n\nexport type WebAuthnStepUpResult =\n | { ok: true; step_up_at: number }\n | { ok: false; reason: string };\n\nexport interface UseStepUpAuthReturn {\n status: WebAuthnAssertionStatus;\n error: Error | null;\n stepUp: (args: { purpose: string }) => Promise<WebAuthnStepUpResult>;\n reset: () => void;\n}\n\n/**\n * Prove possession of a registered hardware key before a sensitive\n * action. On success the auth host sets a fresh oc_session cookie\n * carrying `step_up_at = <unix-now>`; the provider re-fetches the\n * session so `verifyStepUpClaim(payload, …)` flips to true immediately.\n *\n * Never throws. It resolves `{ ok: false, reason }`, and sets `error`, when:\n * - the user has no credentials registered (`no_credentials_registered`)\n * - the user cancels the platform prompt (`cancelled`)\n * - the assertion fails verification on the host (`verify_failed`,\n * `cloned_authenticator`, `credential_outside_allowlist`, …)\n *\n * Caller pattern. Test `ok`: the result is an object on failure too, so a\n * check like `if (!r)` never stops anything.\n *\n * const { stepUp } = useStepUpAuth();\n * const r = await stepUp({ purpose: 'spend_over_1m' });\n * if (!r.ok) return; // r.reason says why: 'cancelled', 'verify_failed', …\n * // …proceed with the sensitive action. On success stepUp has already\n * // refreshed the session, so it carries the new step_up_at.\n *\n * A server still decides with `verifyStepUpClaim`; this check only keeps the\n * page from going on after a failed step-up.\n */\nexport function useStepUpAuth(opts?: UseHostOptions): UseStepUpAuthReturn {\n const authOrigin = resolveAuthOrigin(opts);\n const { refresh } = useOcSession();\n const [status, setStatus] = React.useState<WebAuthnAssertionStatus>('idle');\n const [error, setError] = React.useState<Error | null>(null);\n\n const reset = React.useCallback(() => {\n setStatus('idle');\n setError(null);\n }, []);\n\n const stepUp = React.useCallback(\n async (args: { purpose: string }): Promise<WebAuthnStepUpResult> => {\n setError(null);\n setStatus('requesting-options');\n try {\n const optsRes = await fetch(`${authOrigin}/api/auth/webauthn/assertion/options`, {\n method: 'POST',\n credentials: 'include',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ purpose: args.purpose }),\n });\n const optsBody = (await optsRes.json()) as OptionsResponse<PublicKeyCredentialRequestOptionsJSON>;\n if (!optsRes.ok || !optsBody.ok || !optsBody.options || !optsBody.challenge_token) {\n const reason = optsBody.reason ?? `options_failed_${optsRes.status}`;\n setError(new Error(reason));\n setStatus('error');\n return { ok: false, reason };\n }\n setStatus('authenticating');\n let assertion: AuthenticationResponseJSON;\n try {\n assertion = await startAuthentication({ optionsJSON: optsBody.options });\n } catch (e) {\n const reason = isAbortError(e) ? 'cancelled' : (e as Error).message;\n setError(new Error(reason));\n setStatus('error');\n return { ok: false, reason };\n }\n setStatus('verifying');\n const verifyRes = await fetch(\n `${authOrigin}/api/auth/webauthn/assertion/verify`,\n {\n method: 'POST',\n credentials: 'include',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n challenge_token: optsBody.challenge_token,\n response: assertion,\n }),\n }\n );\n const verifyBody = (await verifyRes.json()) as {\n ok: boolean;\n step_up_at?: number;\n reason?: string;\n };\n if (!verifyRes.ok || !verifyBody.ok || typeof verifyBody.step_up_at !== 'number') {\n const reason = verifyBody.reason ?? `verify_failed_${verifyRes.status}`;\n setError(new Error(reason));\n setStatus('error');\n return { ok: false, reason };\n }\n // Re-fetch the session so consumers see the fresh\n // step_up_at claim without a separate `refresh()` call.\n await refresh();\n setStatus('success');\n return { ok: true, step_up_at: verifyBody.step_up_at };\n } catch (e) {\n const reason = e instanceof Error ? e.message : String(e);\n setError(new Error(reason));\n setStatus('error');\n return { ok: false, reason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ACI,QAAQ;AAAA,YACR,aAAa;AAAA,YACb,SAAS,EAAE,gBAAgB,mBAAmB;AAAA,YAC9C,MAAM,KAAK,UAAU;AAAA,cACjB,iBAAiB,SAAS;AAAA,cAC1B,UAAU;AAAA,YACd,CAAC;AAAA,UACL;AAAA,QACJ;AACA,cAAM,aAAc,MAAM,UAAU,KAAK;AAKzC,YAAI,CAAC,UAAU,MAAM,CAAC,WAAW,MAAM,OAAO,WAAW,eAAe,UAAU;AAC9E,gBAAM,SAAS,WAAW,UAAU,iBAAiB,UAAU,MAAM;AACrE,mBAAS,IAAI,MAAM,MAAM,CAAC;AAC1B,oBAAU,OAAO;AACjB,iBAAO,EAAE,IAAI,OAAO,OAAO;AAAA,QAC/B;AAGA,cAAM,QAAQ;AACd,kBAAU,SAAS;AACnB,eAAO,EAAE,IAAI,MAAM,YAAY,WAAW,WAAW;AAAA,MACzD,SAAS,GAAG;AACR,cAAM,SAAS,aAAa,QAAQ,EAAE,UAAU,OAAO,CAAC;AACxD,iBAAS,IAAI,MAAM,MAAM,CAAC;AAC1B,kBAAU,OAAO;AACjB,eAAO,EAAE,IAAI,OAAO,OAAO;AAAA,MAC/B;AAAA,IACJ;AAAA,IACA,CAAC,YAAY,OAAO;AAAA,EACxB;AAEA,SAAO,EAAE,QAAQ,OAAO,QAAQ,MAAM;AAC1C;","names":[]}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ownWord
|
|
3
|
+
} from "./chunk-E3QI365E.mjs";
|
|
4
|
+
import {
|
|
5
|
+
DesignRadio
|
|
6
|
+
} from "./chunk-OKHAVNEU.mjs";
|
|
1
7
|
import {
|
|
2
8
|
ErrorLine,
|
|
3
9
|
FormButtons,
|
|
@@ -11,7 +17,7 @@ import {
|
|
|
11
17
|
inputStyle,
|
|
12
18
|
panelStyle,
|
|
13
19
|
primaryBtnStyle
|
|
14
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-FMPBHB3Q.mjs";
|
|
15
21
|
import {
|
|
16
22
|
addressInputValue
|
|
17
23
|
} from "./chunk-U7IUGDLW.mjs";
|
|
@@ -22,9 +28,6 @@ import {
|
|
|
22
28
|
readTabSession,
|
|
23
29
|
writeTabSession
|
|
24
30
|
} from "./chunk-4BOO7EQR.mjs";
|
|
25
|
-
import {
|
|
26
|
-
ownWord
|
|
27
|
-
} from "./chunk-E3QI365E.mjs";
|
|
28
31
|
|
|
29
32
|
// src/bond.tsx
|
|
30
33
|
import * as React from "react";
|
|
@@ -86,6 +89,8 @@ function coinStyle(picked, young) {
|
|
|
86
89
|
background: V.card,
|
|
87
90
|
border: `1px ${young ? "dashed" : "solid"} ${picked ? V.primary : V.border}`,
|
|
88
91
|
padding: "0.75rem",
|
|
92
|
+
// The whole row is the radio's target.
|
|
93
|
+
minHeight: 44,
|
|
89
94
|
display: "flex",
|
|
90
95
|
gap: 10,
|
|
91
96
|
alignItems: "flex-start",
|
|
@@ -372,15 +377,13 @@ function BondForm({
|
|
|
372
377
|
style: coinStyle(chosen === c.outpoint, young),
|
|
373
378
|
children: [
|
|
374
379
|
/* @__PURE__ */ jsx(
|
|
375
|
-
|
|
380
|
+
DesignRadio,
|
|
376
381
|
{
|
|
377
|
-
type: "radio",
|
|
378
382
|
name: "oc-bond-coin",
|
|
379
383
|
value: c.outpoint,
|
|
380
384
|
checked: chosen === c.outpoint,
|
|
381
385
|
disabled: young,
|
|
382
|
-
onChange: () => setChosen(c.outpoint)
|
|
383
|
-
style: { accentColor: V.primary, margin: "2px 0 0" }
|
|
386
|
+
onChange: () => setChosen(c.outpoint)
|
|
384
387
|
}
|
|
385
388
|
),
|
|
386
389
|
/* @__PURE__ */ jsxs("span", { style: { display: "grid", gap: 2, minWidth: 0 }, children: [
|
|
@@ -494,4 +497,4 @@ export {
|
|
|
494
497
|
fetchOcBond,
|
|
495
498
|
OcBond
|
|
496
499
|
};
|
|
497
|
-
//# sourceMappingURL=chunk-
|
|
500
|
+
//# sourceMappingURL=chunk-MK45WO7U.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/bond.tsx"],"sourcesContent":["'use client';\n\n/**\n * OcBond · back the signed-in account with bitcoin (oc-attest-protocol\n * BOND.md). The person signs for one coin they hold. It stays in their wallet,\n * and spending it ends the backing. Apps they sign in to see floors and a\n * number unique to that app, never the coin. Optional: every account signs in\n * without one.\n *\n * Runs against the auth host's /api/auth/bond with the family cookie, like\n * OcLinkedIdentities, so any *.ochk.io site can mount it. A change re-mints\n * the session there, and a tab pinned to this account re-pins with the fresh\n * token; `onChange` lets the site refresh its session view.\n */\nimport * as React from 'react';\n\nimport { addressInputValue } from './address';\nimport { DesignRadio } from './controls';\nimport { ownWord } from './own-word';\nimport { SIGNIN_FONT } from './appearance';\nimport {\n bodyStyle,\n dangerBtnStyle,\n ErrorLine,\n FormButtons,\n ghostBtnStyle,\n hintStyle,\n inputStyle,\n LazyWalletButton,\n panelStyle,\n primaryBtnStyle,\n SectionLabel,\n V,\n} from './linked-identities';\nimport { readTabSession, writeTabSession } from './tab-session';\n\nconst DEFAULT_AUTH_ORIGIN = 'https://ochk.io';\nconst MIN_CONFIRMATIONS = 6;\n/** Smaller coins meet no floor, so the auth host refuses them (`coin_too_small`). */\nconst MIN_SATS = 1_000;\n\ninterface Floors {\n sats_floor: number;\n days_floor: number;\n}\n\n/** The account's bond as the auth host shows it to the account itself. */\nexport interface OcBondView extends Floors {\n address: string;\n outpoint: string;\n sats: number;\n confirmed_height: number;\n checked_at: string;\n checked_height: number;\n created_at: string;\n}\n\ninterface Coin extends Floors {\n outpoint: string;\n sats: number;\n age_blocks: number;\n}\n\nexport interface OcBondProps {\n /** The auth host. Default https://ochk.io; pass the current origin on ochk.io itself. */\n authOrigin?: string;\n /** After a bond is made or released, so the site can refresh its session. */\n onChange?: (bond: OcBondView | null) => void;\n className?: string;\n}\n\nconst n = (v: number) => v.toLocaleString('en-US');\n\n/** \"at least 100,000 sats, held 90 days or more\". */\nexport function bondFloorsText(f: Floors): string {\n const sats = f.sats_floor > 0 ? `at least ${n(f.sats_floor)} sats` : 'under 1,000 sats';\n const days = f.days_floor > 0 ? `held ${f.days_floor} days or more` : 'held under 7 days';\n return `${sats}, ${days}`;\n}\n\nconst short = (outpoint: string) => {\n const [txid = '', vout = ''] = outpoint.split(':');\n return `${txid.slice(0, 8)}…${txid.slice(-4)}:${vout}`;\n};\n\nconst usable = (c: Coin) => c.sats >= MIN_SATS && c.age_blocks >= MIN_CONFIRMATIONS;\n\nconst dustText = (count: number) =>\n `${n(count)} ${count === 1 ? 'coin' : 'coins'} under ${n(MIN_SATS)} sats, ` +\n 'too small to back an account';\n\nconst REFUSAL: Record<string, string> = {\n invalid_address: \"that isn't a Bitcoin address we can read\",\n chain_unavailable: \"couldn't read the chain just now · nothing changed, try again in a minute\",\n sig_invalid:\n \"that signature isn't from this coin's address · sign with the wallet that holds it\",\n bond_expired: 'the message expired · start again',\n bond_not_yet_valid: \"your device's clock looks wrong · check it and start again\",\n bond_subject_mismatch: 'that message was for another account · start again',\n bond_malformed: 'the signed message changed on the way · start again',\n bond_window_too_long: \"that message's signing window is too long · start again\",\n coin_not_found: \"that coin doesn't exist on-chain\",\n coin_address_mismatch: \"that coin isn't at this address\",\n coin_unconfirmed: \"that coin isn't confirmed yet\",\n coin_too_recent: 'that coin needs six confirmations first, about an hour',\n coin_spent: 'that coin has been spent · pick one still in your wallet',\n coin_too_small: `that coin is under ${n(MIN_SATS)} sats, too small to back an account`,\n coin_backs_another_account: 'that coin already backs another orangecheck account',\n coin_backed_another_recently:\n 'that coin backed another account until recently · ' +\n 'it can back this one 30 days after it was released',\n not_authenticated: 'your session ended · sign in again',\n rate_limited: 'too many tries · wait a minute, then try again',\n};\n\n/** A refusal from /api/auth/bond, in the component's voice. Not exported from the index. */\nexport const bondRefusal = (reason?: string): string =>\n (reason && ownWord(REFUSAL, reason)) || \"your backing didn't save · nothing changed, try again\";\n\n/* Small print stays legible: 12px or more, and never dimmed below the muted tone. */\nconst smallStyle: React.CSSProperties = { ...bodyStyle, fontSize: 12, margin: 0 };\nconst explainerStyle: React.CSSProperties = {\n ...hintStyle,\n fontSize: 12,\n lineHeight: 1.55,\n opacity: 1,\n margin: 0,\n};\nconst fieldLabelStyle: React.CSSProperties = {\n display: 'block',\n color: V.foreground,\n fontSize: 13,\n fontWeight: 500,\n margin: '0 0 4px',\n};\nconst addressStyle: React.CSSProperties = { wordBreak: 'break-all', color: V.foreground };\n\nfunction coinStyle(picked: boolean, young: boolean): React.CSSProperties {\n return {\n background: V.card,\n border: `1px ${young ? 'dashed' : 'solid'} ${picked ? V.primary : V.border}`,\n padding: '0.75rem',\n // The whole row is the radio's target.\n minHeight: 44,\n display: 'flex',\n gap: 10,\n alignItems: 'flex-start',\n cursor: young ? 'not-allowed' : 'pointer',\n };\n}\n\n/** The account's bond, or null. Throws when the auth host can't be read. */\nexport async function fetchOcBond(opts?: { authOrigin?: string }): Promise<OcBondView | null> {\n const r = await fetch(`${opts?.authOrigin ?? DEFAULT_AUTH_ORIGIN}/api/auth/bond`, {\n credentials: 'include',\n });\n const j = (await r.json().catch(() => ({}))) as { ok?: boolean; bond?: OcBondView | null };\n if (!r.ok || !j.ok) throw new Error(`http_${r.status}`);\n return j.bond ?? null;\n}\n\nexport function OcBond({\n authOrigin = DEFAULT_AUTH_ORIGIN,\n onChange,\n className,\n}: OcBondProps): React.ReactElement {\n const [bond, setBond] = React.useState<OcBondView | null | undefined>(undefined);\n const [loadErr, setLoadErr] = React.useState(false);\n const [nonce, setNonce] = React.useState(0);\n const [adding, setAdding] = React.useState(false);\n const [confirming, setConfirming] = React.useState(false);\n const [busy, setBusy] = React.useState(false);\n const [err, setErr] = React.useState<string | null>(null);\n\n React.useEffect(() => {\n let alive = true;\n fetchOcBond({ authOrigin }).then(\n (b) => alive && setBond(b),\n () => alive && setLoadErr(true)\n );\n return () => {\n alive = false;\n };\n }, [authOrigin, nonce]);\n\n const call = React.useCallback(\n async (method: string, body?: unknown) => {\n const r = await fetch(`${authOrigin}/api/auth/bond`, {\n method,\n credentials: 'include',\n headers: body ? { 'Content-Type': 'application/json' } : undefined,\n body: body ? JSON.stringify(body) : undefined,\n });\n const j = (await r.json().catch(() => ({}))) as Record<string, unknown> & {\n ok?: boolean;\n reason?: string;\n token?: unknown;\n };\n // The host minted for the account this tab shows; keep the pin current.\n const pin = readTabSession();\n if (pin && r.ok && typeof j.token === 'string') {\n writeTabSession({ token: j.token, didOc: pin.didOc });\n }\n return { ok: r.ok && j.ok === true, ...j };\n },\n [authOrigin]\n );\n\n async function release(): Promise<void> {\n setBusy(true);\n setErr(null);\n const j = await call('DELETE').catch(() => ({ ok: false, reason: 'network' }));\n setBusy(false);\n if (!j.ok) return setErr(bondRefusal(j.reason));\n setConfirming(false);\n setBond(null);\n onChange?.(null);\n }\n\n if (loadErr) {\n return (\n <div className={className} data-oc-bond=\"\" style={panelStyle('warn')} role=\"alert\">\n <p style={bodyStyle}>couldn't read your backing · nothing was changed</p>\n <button\n type=\"button\"\n style={ghostBtnStyle(false)}\n onClick={() => {\n setLoadErr(false);\n setNonce((x) => x + 1);\n }}\n >\n try again\n </button>\n </div>\n );\n }\n if (bond === undefined) {\n return (\n <div className={className} data-oc-bond=\"\" style={panelStyle()}>\n <span style={hintStyle}>reading your backing…</span>\n </div>\n );\n }\n\n return (\n <div className={className} data-oc-bond=\"\" style={{ display: 'grid', gap: 16 }}>\n {bond && !adding ? (\n <div style={panelStyle('success')}>\n <SectionLabel tone=\"success\">§ backed by bitcoin</SectionLabel>\n <p style={{ ...bodyStyle, color: V.foreground }}>\n apps see a coin {bondFloorsText(bond)}.\n </p>\n <p style={bodyStyle}>\n coin {short(bond.outpoint)}, {n(bond.sats)} sats · last found unspent at\n block {n(bond.checked_height)} · only you and orangecheck see this line\n </p>\n {confirming ? (\n <div role=\"group\" aria-label=\"stop backing\" data-oc-bond-confirm=\"\">\n <p style={{ ...bodyStyle, color: V.foreground, margin: 0 }}>\n stop backing? apps that ask for a backed account may stop letting\n you in.\n </p>\n <FormButtons>\n <button\n type=\"button\"\n style={dangerBtnStyle(busy)}\n disabled={busy}\n onClick={() => void release()}\n >\n stop backing\n </button>\n <button\n type=\"button\"\n style={ghostBtnStyle(busy)}\n disabled={busy}\n autoFocus\n onClick={() => {\n setErr(null);\n setConfirming(false);\n }}\n >\n keep\n </button>\n </FormButtons>\n </div>\n ) : (\n <FormButtons>\n <button\n type=\"button\"\n style={ghostBtnStyle(false)}\n onClick={() => {\n setErr(null);\n setAdding(true);\n }}\n >\n use another coin\n </button>\n <button\n type=\"button\"\n style={dangerBtnStyle(false)}\n onClick={() => setConfirming(true)}\n >\n stop backing\n </button>\n </FormButtons>\n )}\n {err ? <ErrorLine>{err}</ErrorLine> : null}\n </div>\n ) : null}\n {!bond && !adding ? (\n <div style={panelStyle()}>\n <SectionLabel>§ not backed</SectionLabel>\n <p style={bodyStyle}>\n your account works everywhere as it is. some apps let in only accounts\n backed by a coin you hold. it stays in your wallet, and apps never see\n which coin.\n </p>\n <button\n type=\"button\"\n style={primaryBtnStyle(false)}\n onClick={() => setAdding(true)}\n >\n back your account\n </button>\n </div>\n ) : null}\n {adding ? (\n <BondForm\n call={call}\n onCancel={() => setAdding(false)}\n onDone={(b) => {\n setBond(b);\n setAdding(false);\n onChange?.(b);\n }}\n />\n ) : null}\n <p style={explainerStyle}>\n Apps see only rough floors, like “at least 100,000 sats, held 30 days or\n more”, and a number unique to that app. Never the coin, your address or your\n balance. An app can block that number; only moving the coin gets past it, and a\n moved coin starts its age again.\n </p>\n </div>\n );\n}\n\ntype Call = (\n method: string,\n body?: unknown\n) => Promise<Record<string, unknown> & { ok: boolean; reason?: string }>;\n\nfunction BondForm({\n call,\n onCancel,\n onDone,\n}: {\n call: Call;\n onCancel: () => void;\n onDone: (bond: OcBondView) => void;\n}): React.ReactElement {\n const [address, setAddress] = React.useState('');\n const [coins, setCoins] = React.useState<Coin[] | null>(null);\n const [chosen, setChosen] = React.useState('');\n const [message, setMessage] = React.useState<string | null>(null);\n const [busy, setBusy] = React.useState(false);\n const [err, setErr] = React.useState<string | null>(null);\n const id = React.useId();\n\n const addr = address.trim();\n const canFind = addr.length >= 14;\n\n async function run(fn: () => Promise<void>): Promise<void> {\n setBusy(true);\n setErr(null);\n try {\n await fn();\n } catch {\n setErr(bondRefusal('chain_unavailable'));\n } finally {\n setBusy(false);\n }\n }\n\n const findCoins = () =>\n run(async () => {\n const j = await call('POST', { action: 'coins', address: addr });\n if (!j.ok) return setErr(bondRefusal(j.reason));\n const list = (j.coins as Coin[]) ?? [];\n setCoins(list);\n setChosen(list.find(usable)?.outpoint ?? '');\n });\n\n const getMessage = () =>\n run(async () => {\n const j = await call('POST', { action: 'message', address: addr, outpoint: chosen });\n if (!j.ok || typeof j.message !== 'string') return setErr(bondRefusal(j.reason));\n setMessage(j.message);\n });\n\n const submit = (signature: string) =>\n run(async () => {\n const j = await call('POST', { action: 'bond', message, signature });\n if (!j.ok || !j.bond) return setErr(bondRefusal(j.reason));\n onDone(j.bond as OcBondView);\n });\n\n /** Back one step: from signing to the coin list, or from the coins to the address. */\n function back(): void {\n setErr(null);\n if (message) setMessage(null);\n else setCoins(null);\n }\n\n const error = err ? <ErrorLine>{err}</ErrorLine> : null;\n const backButton = (\n <button type=\"button\" style={ghostBtnStyle(busy)} disabled={busy} onClick={back}>\n back\n </button>\n );\n const cancelButton = (\n <button type=\"button\" style={ghostBtnStyle(busy)} disabled={busy} onClick={onCancel}>\n cancel\n </button>\n );\n\n let step: React.ReactNode;\n if (message) {\n step = (\n <>\n <p style={bodyStyle}>\n sign with the wallet that holds <span style={addressStyle}>{addr}</span>.\n signing spends nothing, and the coin stays in your wallet.\n </p>\n <LazyWalletButton\n address={addr}\n message={message}\n showManual\n onSigned={(sig) => void submit(sig)}\n onError={(e) => setErr(e.message ?? 'the wallet refused to sign')}\n />\n {error}\n <FormButtons>\n {backButton}\n {cancelButton}\n </FormButtons>\n </>\n );\n } else if (coins) {\n const eligible = coins.filter((c) => c.sats >= MIN_SATS);\n const dust = coins.length - eligible.length;\n step = (\n <>\n {coins.length === 0 ? (\n <p style={bodyStyle}>\n no confirmed coins at that address · send at least {n(MIN_SATS)} sats\n there and wait for six confirmations, about an hour. the longer a coin\n sits, the more it says.\n </p>\n ) : eligible.length === 0 ? (\n <>\n <p style={{ ...bodyStyle, color: V.foreground }}>{dustText(dust)}</p>\n <p style={bodyStyle}>\n send at least {n(MIN_SATS)} sats there in one payment and wait for six\n confirmations, about an hour. coins aren't added together.\n </p>\n </>\n ) : (\n <>\n <p id={`${id}-pick`} style={bodyStyle}>\n pick one coin · coins aren't added together\n </p>\n <div\n role=\"radiogroup\"\n aria-labelledby={`${id}-pick`}\n style={{ display: 'grid', gap: 8 }}\n >\n {eligible.map((c) => {\n const young = c.age_blocks < MIN_CONFIRMATIONS;\n return (\n <label\n key={c.outpoint}\n style={coinStyle(chosen === c.outpoint, young)}\n >\n <DesignRadio\n name=\"oc-bond-coin\"\n value={c.outpoint}\n checked={chosen === c.outpoint}\n disabled={young}\n onChange={() => setChosen(c.outpoint)}\n />\n <span style={{ display: 'grid', gap: 2, minWidth: 0 }}>\n <span\n style={{\n color: young ? V.muted : V.foreground,\n fontSize: 13,\n }}\n >\n {n(c.sats)} sats, held{' '}\n {Math.floor(c.age_blocks / 144)} days\n </span>\n <span style={smallStyle}>\n {young\n ? 'too recent: needs six confirmations'\n : `apps would see ${bondFloorsText(c)}`}\n </span>\n <span\n style={{\n ...smallStyle,\n fontFamily: SIGNIN_FONT,\n wordBreak: 'break-all',\n }}\n >\n {short(c.outpoint)}\n </span>\n </span>\n </label>\n );\n })}\n </div>\n {dust > 0 ? (\n <p style={{ ...smallStyle, marginTop: 8 }}>{dustText(dust)}</p>\n ) : null}\n </>\n )}\n {error}\n <FormButtons>\n {eligible.length > 0 ? (\n <button\n type=\"button\"\n style={primaryBtnStyle(busy || !chosen)}\n disabled={busy || !chosen}\n onClick={() => void getMessage()}\n >\n continue\n </button>\n ) : null}\n {backButton}\n {cancelButton}\n </FormButtons>\n </>\n );\n } else {\n step = (\n <form\n style={{ margin: 0 }}\n onSubmit={(e) => {\n e.preventDefault();\n if (canFind && !busy) void findCoins();\n }}\n >\n <label htmlFor={`${id}-address`} style={fieldLabelStyle}>\n bitcoin address that holds the coin\n </label>\n <p id={`${id}-advice`} style={{ ...bodyStyle, margin: '0 0 8px' }}>\n use one that holds nothing else of yours: orangecheck learns its address and\n amount. apps never do.\n </p>\n <input\n data-oca-field=\"\"\n id={`${id}-address`}\n aria-describedby={`${id}-advice`}\n style={inputStyle}\n value={address}\n onChange={(e) => setAddress(addressInputValue(e.target.value))}\n placeholder=\"bc1q…\"\n spellCheck={false}\n autoComplete=\"off\"\n autoCapitalize=\"off\"\n />\n {error}\n <FormButtons>\n <button\n type=\"submit\"\n style={primaryBtnStyle(busy || !canFind)}\n disabled={busy || !canFind}\n >\n find its coins\n </button>\n {cancelButton}\n </FormButtons>\n </form>\n );\n }\n\n return (\n <div style={panelStyle('accent')} data-oc-bond-form=\"\">\n <SectionLabel>§ back your account</SectionLabel>\n {step}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,YAAY,WAAW;AA+MX,SAgNA,UA/MI,KADJ;AAzLZ,IAAM,sBAAsB;AAC5B,IAAM,oBAAoB;AAE1B,IAAM,WAAW;AAgCjB,IAAM,IAAI,CAAC,MAAc,EAAE,eAAe,OAAO;AAG1C,SAAS,eAAe,GAAmB;AAC9C,QAAM,OAAO,EAAE,aAAa,IAAI,YAAY,EAAE,EAAE,UAAU,CAAC,UAAU;AACrE,QAAM,OAAO,EAAE,aAAa,IAAI,QAAQ,EAAE,UAAU,kBAAkB;AACtE,SAAO,GAAG,IAAI,KAAK,IAAI;AAC3B;AAEA,IAAM,QAAQ,CAAC,aAAqB;AAChC,QAAM,CAAC,OAAO,IAAI,OAAO,EAAE,IAAI,SAAS,MAAM,GAAG;AACjD,SAAO,GAAG,KAAK,MAAM,GAAG,CAAC,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;AAAA,KACL;AAER;","names":[]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// src/controls.tsx
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
var WRAP = { position: "relative", display: "inline-flex", flexShrink: 0, width: 20, height: 20 };
|
|
4
|
+
var FORCED = [
|
|
5
|
+
"@media (forced-colors: active){",
|
|
6
|
+
"[data-oc-control] input{border-color:CanvasText!important;background:Canvas!important}",
|
|
7
|
+
"[data-oc-control] input[type=checkbox]:checked{border-color:Highlight!important;background:Highlight!important}",
|
|
8
|
+
"[data-oc-control] input[type=radio]:checked{border-color:Highlight!important}",
|
|
9
|
+
"[data-oc-control] svg[data-oc-check]{color:HighlightText!important}",
|
|
10
|
+
"[data-oc-control] svg[data-oc-dot]{color:Highlight!important}",
|
|
11
|
+
"[data-oc-control] input:disabled{border-color:GrayText!important}",
|
|
12
|
+
"}"
|
|
13
|
+
].join("");
|
|
14
|
+
function boxStyle(kind, checked, disabled) {
|
|
15
|
+
return {
|
|
16
|
+
appearance: "none",
|
|
17
|
+
WebkitAppearance: "none",
|
|
18
|
+
margin: 0,
|
|
19
|
+
width: 20,
|
|
20
|
+
height: 20,
|
|
21
|
+
borderRadius: kind === "radio" ? "50%" : 0,
|
|
22
|
+
border: checked ? "1px solid var(--primary, #f97316)" : "1px solid var(--input, var(--border, #52525b))",
|
|
23
|
+
background: checked && kind === "checkbox" ? "var(--primary, #f97316)" : "var(--oca-surface, var(--background, transparent))",
|
|
24
|
+
cursor: disabled ? "not-allowed" : "pointer",
|
|
25
|
+
opacity: disabled ? 0.5 : 1
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
var MARK = { position: "absolute", inset: 3, width: 14, height: 14, pointerEvents: "none" };
|
|
29
|
+
function DesignCheckbox({ checked, disabled, ...props }) {
|
|
30
|
+
return /* @__PURE__ */ jsxs("span", { "data-oc-control": "", style: WRAP, children: [
|
|
31
|
+
/* @__PURE__ */ jsx("style", { dangerouslySetInnerHTML: { __html: FORCED } }),
|
|
32
|
+
/* @__PURE__ */ jsx("input", { ...props, type: "checkbox", checked, disabled, style: boxStyle("checkbox", checked, Boolean(disabled)) }),
|
|
33
|
+
checked ? /* @__PURE__ */ jsx("svg", { "data-oc-check": "", "aria-hidden": "true", viewBox: "0 0 24 24", style: { ...MARK, color: "var(--primary-foreground, #ffffff)" }, children: /* @__PURE__ */ jsx("path", { d: "M20 6 9 17l-5-5", fill: "none", stroke: "currentColor", strokeWidth: 3, strokeLinecap: "square" }) }) : null
|
|
34
|
+
] });
|
|
35
|
+
}
|
|
36
|
+
function DesignRadio({ checked, disabled, ...props }) {
|
|
37
|
+
return /* @__PURE__ */ jsxs("span", { "data-oc-control": "", style: WRAP, children: [
|
|
38
|
+
/* @__PURE__ */ jsx("style", { dangerouslySetInnerHTML: { __html: FORCED } }),
|
|
39
|
+
/* @__PURE__ */ jsx("input", { ...props, type: "radio", checked, disabled, style: boxStyle("radio", checked, Boolean(disabled)) }),
|
|
40
|
+
checked ? /* @__PURE__ */ jsx("svg", { "data-oc-dot": "", "aria-hidden": "true", viewBox: "0 0 14 14", style: { ...MARK, color: "var(--primary, #f97316)" }, children: /* @__PURE__ */ jsx("circle", { cx: "7", cy: "7", r: "4", fill: "currentColor" }) }) : null
|
|
41
|
+
] });
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export {
|
|
45
|
+
DesignCheckbox,
|
|
46
|
+
DesignRadio
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=chunk-OKHAVNEU.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/controls.tsx"],"sourcesContent":["import * as React from 'react';\n\n/*\n * app-design 2.0's checkbox and radio, for the ceremonies here that style\n * themselves inline: a real input (its label, keyboard and form behaviour\n * unchanged), drawn 20px from the page's tokens instead of the platform's\n * control and its accent-color. The checkbox is square; the radio is round,\n * as app-design's own is, since a square radio reads as a checkbox.\n *\n * Under forced colors the fill gives way to the system's Canvas but an SVG\n * keeps its own colour, so a checked box's white mark vanished on a white\n * Canvas. A small stylesheet draws them as native controls do there: a\n * checked checkbox in Highlight with its mark in HighlightText, a chosen\n * radio's border and dot in Highlight, the rest in CanvasText. Inline styles\n * cannot say forced-colors.\n */\n\ntype BoxProps = Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type' | 'style' | 'checked'> & { checked: boolean };\n\nconst WRAP: React.CSSProperties = { position: 'relative', display: 'inline-flex', flexShrink: 0, width: 20, height: 20 };\n\nconst FORCED = [\n '@media (forced-colors: active){',\n '[data-oc-control] input{border-color:CanvasText!important;background:Canvas!important}',\n '[data-oc-control] input[type=checkbox]:checked{border-color:Highlight!important;background:Highlight!important}',\n '[data-oc-control] input[type=radio]:checked{border-color:Highlight!important}',\n '[data-oc-control] svg[data-oc-check]{color:HighlightText!important}',\n '[data-oc-control] svg[data-oc-dot]{color:Highlight!important}',\n '[data-oc-control] input:disabled{border-color:GrayText!important}',\n '}',\n].join('');\n\nfunction boxStyle(kind: 'checkbox' | 'radio', checked: boolean, disabled: boolean): React.CSSProperties {\n return {\n appearance: 'none',\n WebkitAppearance: 'none',\n margin: 0,\n width: 20,\n height: 20,\n borderRadius: kind === 'radio' ? '50%' : 0,\n border: checked ? '1px solid var(--primary, #f97316)' : '1px solid var(--input, var(--border, #52525b))',\n background: checked && kind === 'checkbox' ? 'var(--primary, #f97316)' : 'var(--oca-surface, var(--background, transparent))',\n cursor: disabled ? 'not-allowed' : 'pointer',\n opacity: disabled ? 0.5 : 1,\n };\n}\n\nconst MARK: React.CSSProperties = { position: 'absolute', inset: 3, width: 14, height: 14, pointerEvents: 'none' };\n\n/** The design checkbox: filled with --primary when checked, its mark in --primary-foreground. */\nexport function DesignCheckbox({ checked, disabled, ...props }: BoxProps) {\n return (\n <span data-oc-control=\"\" style={WRAP}>\n <style dangerouslySetInnerHTML={{ __html: FORCED }} />\n <input {...props} type=\"checkbox\" checked={checked} disabled={disabled} style={boxStyle('checkbox', checked, Boolean(disabled))} />\n {checked ? (\n <svg data-oc-check=\"\" aria-hidden=\"true\" viewBox=\"0 0 24 24\" style={{ ...MARK, color: 'var(--primary-foreground, #ffffff)' }}>\n <path d=\"M20 6 9 17l-5-5\" fill=\"none\" stroke=\"currentColor\" strokeWidth={3} strokeLinecap=\"square\" />\n </svg>\n ) : null}\n </span>\n );\n}\n\n/** The design radio: round, as app-design's RadioGroupItem is, with a dot in --primary when chosen. */\nexport function DesignRadio({ checked, disabled, ...props }: BoxProps) {\n return (\n <span data-oc-control=\"\" style={WRAP}>\n <style dangerouslySetInnerHTML={{ __html: FORCED }} />\n <input {...props} type=\"radio\" checked={checked} disabled={disabled} style={boxStyle('radio', checked, Boolean(disabled))} />\n {checked ? (\n <svg data-oc-dot=\"\" aria-hidden=\"true\" viewBox=\"0 0 14 14\" style={{ ...MARK, color: 'var(--primary, #f97316)' }}>\n <circle cx=\"7\" cy=\"7\" r=\"4\" fill=\"currentColor\" />\n </svg>\n ) : null}\n </span>\n );\n}\n"],"mappings":";AAoDQ,SACI,KADJ;AAjCR,IAAM,OAA4B,EAAE,UAAU,YAAY,SAAS,eAAe,YAAY,GAAG,OAAO,IAAI,QAAQ,GAAG;AAEvH,IAAM,SAAS;AAAA,EACX;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ,EAAE,KAAK,EAAE;AAET,SAAS,SAAS,MAA4B,SAAkB,UAAwC;AACpG,SAAO;AAAA,IACH,YAAY;AAAA,IACZ,kBAAkB;AAAA,IAClB,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,cAAc,SAAS,UAAU,QAAQ;AAAA,IACzC,QAAQ,UAAU,sCAAsC;AAAA,IACxD,YAAY,WAAW,SAAS,aAAa,4BAA4B;AAAA,IACzE,QAAQ,WAAW,gBAAgB;AAAA,IACnC,SAAS,WAAW,MAAM;AAAA,EAC9B;AACJ;AAEA,IAAM,OAA4B,EAAE,UAAU,YAAY,OAAO,GAAG,OAAO,IAAI,QAAQ,IAAI,eAAe,OAAO;AAG1G,SAAS,eAAe,EAAE,SAAS,UAAU,GAAG,MAAM,GAAa;AACtE,SACI,qBAAC,UAAK,mBAAgB,IAAG,OAAO,MAC5B;AAAA,wBAAC,WAAM,yBAAyB,EAAE,QAAQ,OAAO,GAAG;AAAA,IACpD,oBAAC,WAAO,GAAG,OAAO,MAAK,YAAW,SAAkB,UAAoB,OAAO,SAAS,YAAY,SAAS,QAAQ,QAAQ,CAAC,GAAG;AAAA,IAChI,UACG,oBAAC,SAAI,iBAAc,IAAG,eAAY,QAAO,SAAQ,aAAY,OAAO,EAAE,GAAG,MAAM,OAAO,qCAAqC,GACvH,8BAAC,UAAK,GAAE,mBAAkB,MAAK,QAAO,QAAO,gBAAe,aAAa,GAAG,eAAc,UAAS,GACvG,IACA;AAAA,KACR;AAER;AAGO,SAAS,YAAY,EAAE,SAAS,UAAU,GAAG,MAAM,GAAa;AACnE,SACI,qBAAC,UAAK,mBAAgB,IAAG,OAAO,MAC5B;AAAA,wBAAC,WAAM,yBAAyB,EAAE,QAAQ,OAAO,GAAG;AAAA,IACpD,oBAAC,WAAO,GAAG,OAAO,MAAK,SAAQ,SAAkB,UAAoB,OAAO,SAAS,SAAS,SAAS,QAAQ,QAAQ,CAAC,GAAG;AAAA,IAC1H,UACG,oBAAC,SAAI,eAAY,IAAG,eAAY,QAAO,SAAQ,aAAY,OAAO,EAAE,GAAG,MAAM,OAAO,0BAA0B,GAC1G,8BAAC,YAAO,IAAG,KAAI,IAAG,KAAI,GAAE,KAAI,MAAK,gBAAe,GACpD,IACA;AAAA,KACR;AAER;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import { stripFragment } from './return-to';\n\n/**\n * The kinds of identity a user can surface as their account-badge\n * label. `did` is the canonical `did:oc` identifier — always available\n * and the ultimate fallback; the other three are linked identities a\n * user may or may not have.\n */\nexport const DISPLAY_IDENTITY_KINDS = ['did', 'btc', 'email', 'nostr'] as const;\nexport type DisplayIdentityKind = (typeof DISPLAY_IDENTITY_KINDS)[number];\n\n/**\n * The identity a user has chosen to show in their account badge — the\n * collapsed label every family site renders instead of the raw\n * `did:oc`. Carried as a JWT claim by the auth host, so the choice is\n * consistent across every `.ochk.io` subdomain with no round-trip.\n *\n * `kind` is which identity; `value` is the full, renderable value (the\n * `did:oc`, the Bitcoin address, the email, or the npub). Integrators\n * rendering their own chip read `useOcSession().account.displayIdentity`\n * — it is always populated (it defaults to the `did`).\n */\nexport interface DisplayIdentity {\n kind: DisplayIdentityKind;\n value: string;\n}\n\nexport interface OcAccount {\n accountId: string;\n /**\n * Opaque public-facing identifier · `did:oc:<32-hex>`. The sole\n * user identifier post auth-refactor. Stable across linking\n * events. Per AUTH-REFACTOR-PLAN.md §2.1.\n */\n didOc: string;\n /**\n * Primary linked Bitcoin address, plaintext, when the user has\n * one — null for email-OTP users until they link a btc address.\n * Surfaced inline by the auth host's /api/auth/me so consumer\n * dashboards can render the user's own footprint without a\n * second round-trip through /api/auth/identities.\n */\n primaryBtc?: string | null;\n /**\n * True when the user has a primary email linked. Plaintext is\n * fetchable on demand via /api/auth/identities; not surfaced\n * here.\n */\n hasEmail?: boolean;\n displayName?: string | null;\n nostrNpub?: string | null;\n /**\n * @deprecated Always null: the auth host no longer sets it. Where a\n * person's sats sit is me.ochk.io's to say (`/api/me/balance`).\n */\n homeFederation?: string | null;\n /**\n * Whether the account signs with its own Bitcoin key, derived by the\n * auth host from its verified linked identities; no one can set it.\n * 'bip322' when a BIP-322-verified address is linked, otherwise\n * 'fedimint_threshold'. 'fedimint_client' is reserved and never set.\n * It says who holds the signing key, never who holds the sats.\n */\n signingMethod?: 'fedimint_threshold' | 'fedimint_client' | 'bip322' | null;\n /**\n * Best-effort owner-flag · true when the user's `did_oc` was on\n * the auth host's `OWNER_OC_ADDRESSES` env at the time the JWT\n * was minted. Surfaced so the family-switcher and other low-\n * stakes UX can render owner-only affordances (e.g. an\n * analytics.ochk.io entry visible only to owners).\n *\n * **NOT A SECURITY BOUNDARY.** Sensitive surfaces — including\n * analytics.ochk.io itself — re-check the live env against\n * `session.did_oc` server-side on every request. If an owner is\n * removed from the env, their JWT may keep `isOwner: true` for\n * up to the JWT lifetime (~30d) but every gated action they\n * attempt re-fails. The flag exists purely so we can show or\n * hide UX hints without an extra round-trip on every page load.\n *\n * Treat absence as `false`.\n */\n isOwner?: boolean;\n /**\n * The identity the user has chosen to show as their account-badge\n * label — `{ kind, value }`. **Always populated**: when the user\n * has never promoted an identity (and on sessions minted before\n * the feature shipped) this is `{ kind:'did', value:didOc }`.\n *\n * `<OcAccountMenu>` renders `value` (shortened) as the collapsed\n * badge label. Integrators rendering their own chip read this\n * directly; change it with `useOcSession().setDisplayIdentity()`.\n */\n displayIdentity: DisplayIdentity;\n}\n\nexport type OcSessionStatus = 'loading' | 'authenticated' | 'anonymous' | 'error';\n\n/**\n * Multi-account roster · summary of another account this browser has\n * signed into and can switch to without re-authenticating. Surfaced by\n * `<OcAccountMenu>` in the `§ accounts` section. Returned by the auth\n * host's `/api/auth/me` as `roster: [...]` (an empty array on single-\n * account or pre-multi-account sessions).\n *\n * Sessions for peer accounts stay alive in the auth host's DB for the\n * normal 30-day window; once expired, the peer falls out of the roster\n * and the user must re-authenticate to bring it back in.\n */\nexport interface OcAccountSummary {\n didOc: string;\n displayName: string | null;\n primaryBtc: string | null;\n displayIdentity: DisplayIdentity;\n /** ISO timestamp of the last verified request on this account's\n * session row, or null if never touched. */\n lastSeenAt: string | null;\n}\n\n/**\n * Scope hint for `signOut()` in a multi-account browser.\n *\n * - 'all' · sign out of every account in this browser's roster\n * (the default; matches the historical single-account\n * behavior of \"clear the cookie\").\n * - 'current' · sign out of just the active account; if the roster\n * has other accounts, the auth host hands you off to\n * the next-most-recent one without a re-auth.\n */\nexport type OcSignOutScope = 'all' | 'current';\n\n/**\n * What `signOut()` did. `ok: false` means the session may still be live: the\n * auth host did not answer (`'unreachable'`) or refused (`'refused'`, with its\n * HTTP status). The provider then changes nothing, so the page still shows the\n * signed-in account; tell the person it did not work and let them try again.\n */\nexport type OcSignOutResult =\n | { ok: true }\n | { ok: false; reason: 'unreachable' | 'refused'; status?: number };\n\nexport interface OcSessionState {\n status: OcSessionStatus;\n account: OcAccount | null;\n /**\n * Multi-account · other accounts the user has signed into in this\n * browser. `[]` for single-account sessions and for tokens minted\n * before multi-account shipped. The active account (`account`\n * above) is NOT included — these are the *switch targets*.\n */\n roster: OcAccountSummary[];\n /**\n * Per-tab pinning · `true` when this tab holds its own session\n * token (sessionStorage) and operates as `account` independently of\n * the shared `.ochk.io` cookie — i.e. switching accounts in another\n * tab will NOT change this tab's identity. `false` on hosts that\n * predate `/api/auth/tab`, in privacy modes without sessionStorage,\n * and while anonymous.\n */\n tabPinned: boolean;\n /** `null` while loading; an `Error` instance when `status === 'error'`. */\n error: Error | null;\n /** Re-fetch the session. Useful after sign-in/sign-out happens elsewhere. */\n refresh: () => Promise<void>;\n /**\n * Trigger a sign-out. By default signs out of EVERY account in the\n * roster (back-compat); pass `{ scope: 'current' }` to sign out of\n * just the active account and stay logged into the next peer. When the\n * auth host does not end the session (no answer, or an error status),\n * nothing changes locally and the account stays shown; it never rejects.\n * Use {@link trySignOut} to learn which, and tell the person.\n */\n signOut: (opts?: { scope?: OcSignOutScope }) => Promise<void>;\n /**\n * `signOut`, resolving to what the auth host did: `{ ok: true }` once the\n * session has ended, else `{ ok: false, reason }` with the session still live.\n */\n trySignOut: (opts?: { scope?: OcSignOutScope }) => Promise<OcSignOutResult>;\n /**\n * Multi-account · flip the active session to a different account\n * in the roster. Resolves once the new cookie has been set and\n * the session has been re-fetched. Throws if the target `did_oc`\n * isn't in the current roster (the user must add it via\n * {@link addAccount} first) or if the auth host is unreachable.\n */\n switchAccount: (didOc: string) => Promise<void>;\n /**\n * Multi-account · open the sign-in flow in \"add\" mode — the new\n * account joins the current browser's roster instead of replacing\n * it. Returns the URL to navigate to (so callers can mount it in\n * a popup or hard-navigate as they prefer); pass `returnTo` to\n * route back to a specific page after the add completes.\n */\n addAccountUrl: (returnTo?: string) => string;\n /**\n * Promote a linked identity to be the account-badge label across\n * every `.ochk.io` site. PATCHes the auth host, which re-mints the\n * session cookie with the new `display_identity` claim, then\n * `refresh()`es this session. Rejects if the chosen kind is not a\n * verified identity on the account (`btc` / `email` / `nostr` must\n * actually be linked; `did` is always valid).\n */\n setDisplayIdentity: (kind: DisplayIdentityKind) => Promise<void>;\n /** URL to navigate to for sign-in on the auth host. */\n signInUrl: string;\n}\n\nexport interface OcAuthConfig {\n /**\n * Origin of the auth host — the subdomain that runs the sign-in UI,\n * issues session cookies, and exposes `/api/auth/me` + `/api/auth/logout`.\n *\n * Defaults to `https://ochk.io`. Override in preview/dev.\n */\n authOrigin?: string;\n /**\n * Path on the auth host that accepts `?return_to=<url>` and drives the\n * sign-in flow. The page offers two paths in-place:\n *\n * - email + OTP (default — no wallet and no key of the user's own;\n * identity is `did:email:<sha256(email)>`)\n * - BIP-322 wallet sign (paste address → in-page wallet sign;\n * identity is the Bitcoin address itself)\n *\n * Defaults to `/signin`.\n */\n signInPath?: string;\n /**\n * Local path (same origin as the current app) that exposes the\n * crypto-verified session. If your app ships one at `/api/auth/me`,\n * leave as default. Returns 200 `{ account }` or 401.\n */\n mePath?: string;\n /**\n * Path on the auth host to hit to clear the session cookie.\n * Defaults to `/api/auth/logout`. Called with `credentials: 'include'`\n * so the `.ochk.io` cookie is sent along.\n */\n logoutPath?: string;\n /**\n * Multi-account and per-tab pinning against the auth host. Defaults to\n * `true`. A site that holds its own single session cookie (ochk.app)\n * sets `false`: no tab pins, no account hints or link stamping, and no\n * roster fetched from the host.\n */\n multiAccount?: boolean;\n}\n\nexport const DEFAULT_CONFIG: Required<OcAuthConfig> = {\n authOrigin: 'https://ochk.io',\n signInPath: '/signin',\n mePath: '/api/auth/me',\n logoutPath: '/api/auth/logout',\n multiAccount: true,\n};\n\nexport function resolveConfig(cfg: OcAuthConfig | undefined): Required<OcAuthConfig> {\n return { ...DEFAULT_CONFIG, ...(cfg ?? {}) };\n}\n\n/**\n * The sign-in URL on the auth host. `returnTo` goes without its fragment;\n * OcSessionProvider keeps the fragment when the link is followed.\n */\nexport function buildSignInUrl(cfg: Required<OcAuthConfig>, returnTo?: string): string {\n const base = `${cfg.authOrigin}${cfg.signInPath}`;\n if (!returnTo) return base;\n const u = new URL(base);\n u.searchParams.set('return_to', stripFragment(returnTo));\n return u.toString();\n}\n\n/**\n * Multi-account · build the URL for the \"add another account\" entry\n * point. Same as {@link buildSignInUrl} but appends `?add=1` so the\n * sign-in page knows to preserve the current roster (the new account\n * is appended; the previously-active account stays signed in too and\n * remains switch-target reachable).\n */\nexport function buildAddAccountUrl(cfg: Required<OcAuthConfig>, returnTo?: string): string {\n const u = new URL(buildSignInUrl(cfg, returnTo));\n u.searchParams.set('add', '1');\n return u.toString();\n}\n"],"mappings":";;;;;AAQO,IAAM,yBAAyB,CAAC,OAAO,OAAO,SAAS,OAAO;AA+O9D,IAAM,iBAAyC;AAAA,EAClD,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,cAAc;AAClB;AAEO,SAAS,cAAc,KAAuD;AACjF,SAAO,EAAE,GAAG,gBAAgB,GAAI,OAAO,CAAC,EAAG;AAC/C;AAMO,SAAS,eAAe,KAA6B,UAA2B;AACnF,QAAM,OAAO,GAAG,IAAI,UAAU,GAAG,IAAI,UAAU;AAC/C,MAAI,CAAC,SAAU,QAAO;AACtB,QAAM,IAAI,IAAI,IAAI,IAAI;AACtB,IAAE,aAAa,IAAI,aAAa,cAAc,QAAQ,CAAC;AACvD,SAAO,EAAE,SAAS;AACtB;AASO,SAAS,mBAAmB,KAA6B,UAA2B;AACvF,QAAM,IAAI,IAAI,IAAI,eAAe,KAAK,QAAQ,CAAC;AAC/C,IAAE,aAAa,IAAI,OAAO,GAAG;AAC7B,SAAO,EAAE,SAAS;AACtB;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useOcSession
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-JLMDCC6K.mjs";
|
|
4
4
|
|
|
5
5
|
// src/components.tsx
|
|
6
6
|
import * as React from "react";
|
|
@@ -22,7 +22,7 @@ function useUniqueId(prefix) {
|
|
|
22
22
|
return id;
|
|
23
23
|
}
|
|
24
24
|
function OcAccountChip({
|
|
25
|
-
dashboardUrl = "https://ochk.
|
|
25
|
+
dashboardUrl = "https://ochk.app/me/account",
|
|
26
26
|
signInUrl: signInUrlOverride,
|
|
27
27
|
signInLabel = "sign in",
|
|
28
28
|
className,
|
|
@@ -30,9 +30,10 @@ function OcAccountChip({
|
|
|
30
30
|
popoverClassName,
|
|
31
31
|
menuItemClassName
|
|
32
32
|
}) {
|
|
33
|
-
const { status, account, signInUrl: sessionSignInUrl,
|
|
33
|
+
const { status, account, signInUrl: sessionSignInUrl, trySignOut } = useOcSession();
|
|
34
34
|
const signInUrl = signInUrlOverride ?? sessionSignInUrl;
|
|
35
35
|
const [open, setOpen] = React.useState(false);
|
|
36
|
+
const [signOutFailed, setSignOutFailed] = React.useState(false);
|
|
36
37
|
const wrapRef = React.useRef(null);
|
|
37
38
|
React.useEffect(() => {
|
|
38
39
|
if (!open) return;
|
|
@@ -244,7 +245,8 @@ function OcAccountChip({
|
|
|
244
245
|
role: "menuitem",
|
|
245
246
|
onClick: () => {
|
|
246
247
|
setOpen(false);
|
|
247
|
-
|
|
248
|
+
setSignOutFailed(false);
|
|
249
|
+
void trySignOut().then((r) => setSignOutFailed(!r.ok));
|
|
248
250
|
},
|
|
249
251
|
className: menuItemClassName,
|
|
250
252
|
"data-oc-account-chip-item": "",
|
|
@@ -279,11 +281,23 @@ function OcAccountChip({
|
|
|
279
281
|
] })
|
|
280
282
|
]
|
|
281
283
|
}
|
|
282
|
-
)
|
|
284
|
+
),
|
|
285
|
+
signOutFailed ? /* @__PURE__ */ jsx(SignOutFailed, {}) : null
|
|
283
286
|
]
|
|
284
287
|
}
|
|
285
288
|
);
|
|
286
289
|
}
|
|
290
|
+
function SignOutFailed() {
|
|
291
|
+
return /* @__PURE__ */ jsx(
|
|
292
|
+
"span",
|
|
293
|
+
{
|
|
294
|
+
role: "alert",
|
|
295
|
+
"data-oc-signout-failed": "",
|
|
296
|
+
style: { display: "block", marginTop: 4, fontSize: 12, color: "var(--destructive, #dc2626)" },
|
|
297
|
+
children: "Couldn\u2019t sign out. You\u2019re still signed in; try again."
|
|
298
|
+
}
|
|
299
|
+
);
|
|
300
|
+
}
|
|
287
301
|
function OcSignInButton({
|
|
288
302
|
label = "sign in",
|
|
289
303
|
eager = false,
|
|
@@ -312,7 +326,8 @@ function OcAccountPill({
|
|
|
312
326
|
className,
|
|
313
327
|
...rest
|
|
314
328
|
}) {
|
|
315
|
-
const { status, account,
|
|
329
|
+
const { status, account, trySignOut } = useOcSession();
|
|
330
|
+
const [signOutFailed, setSignOutFailed] = React.useState(false);
|
|
316
331
|
if (status !== "authenticated" || !account) return null;
|
|
317
332
|
const label = render ? render({ address: account.didOc, displayName: account.displayName }) : account.displayName ?? shortenAddress(account.didOc);
|
|
318
333
|
return /* @__PURE__ */ jsxs(
|
|
@@ -329,7 +344,8 @@ function OcAccountPill({
|
|
|
329
344
|
{
|
|
330
345
|
type: "button",
|
|
331
346
|
onClick: () => {
|
|
332
|
-
|
|
347
|
+
setSignOutFailed(false);
|
|
348
|
+
void trySignOut().then((r) => setSignOutFailed(!r.ok));
|
|
333
349
|
},
|
|
334
350
|
"aria-label": "Sign out",
|
|
335
351
|
style: {
|
|
@@ -342,7 +358,8 @@ function OcAccountPill({
|
|
|
342
358
|
},
|
|
343
359
|
children: "sign out"
|
|
344
360
|
}
|
|
345
|
-
)
|
|
361
|
+
),
|
|
362
|
+
signOutFailed ? /* @__PURE__ */ jsx(SignOutFailed, {}) : null
|
|
346
363
|
]
|
|
347
364
|
}
|
|
348
365
|
);
|
|
@@ -649,4 +666,4 @@ export {
|
|
|
649
666
|
useOcAddressSuggestion,
|
|
650
667
|
OcAddressInput
|
|
651
668
|
};
|
|
652
|
-
//# sourceMappingURL=chunk-
|
|
669
|
+
//# sourceMappingURL=chunk-VQY7IYHV.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { useOcSession } from './provider';\nimport type { OcAccount } from './types';\n\nfunction shortenAddress(addr: string): string {\n if (addr.length <= 12) return addr;\n return `${addr.slice(0, 6)}…${addr.slice(-4)}`;\n}\n\nfunction shortenAddressMid(addr: string): string {\n if (addr.length <= 16) return addr;\n return `${addr.slice(0, 8)}…${addr.slice(-6)}`;\n}\n\nfunction isPrefixOf(value: string, target: string): boolean {\n return target.toLowerCase().startsWith(value.toLowerCase());\n}\n\nlet listboxIdCounter = 0;\nfunction useUniqueId(prefix: string): string {\n const [id] = React.useState(() => `${prefix}-${++listboxIdCounter}`);\n return id;\n}\n\nexport interface OcAccountChipProps {\n /**\n * URL to the user's account page. Defaults to `https://ochk.app/me/account`,\n * the family's account page (ochk.io/dashboard only redirects there).\n */\n dashboardUrl?: string;\n /**\n * Override the sign-in URL shown to anonymous visitors. Defaults to\n * the session's `signInUrl` (which points at the auth host's\n * /signin?return_to=… page). Set this to a local path like `'/signin'`\n * when the consumer site mounts its own in-place `<OcSignIn />` —\n * skips the redirect-bounce entirely.\n */\n signInUrl?: string;\n /**\n * Label for the sign-in link shown to anonymous visitors.\n * Defaults to `sign in`.\n */\n signInLabel?: string;\n /** className for the wrapper `<div>`. */\n className?: string;\n /** className for the trigger pill button. */\n triggerClassName?: string;\n /** className for the dropdown popover. */\n popoverClassName?: string;\n /** className for menu items (dashboard link + sign-out button). */\n menuItemClassName?: string;\n}\n\n/**\n * Single header-account affordance for every ochk.io subdomain.\n *\n * anonymous → \"sign in\" link\n * signed in → pill `bc1q…7ke3 ▾` that opens a popover with:\n * • § signed in (label)\n * • full address (monospace, break-all)\n * • → dashboard\n * • → sign out\n *\n * The popover closes on outside click or Escape. Reasonable inline styles\n * cover the dark-mode default; override per-part via the className props\n * or via the `[data-oc-account-chip-*]` data attributes.\n */\nexport function OcAccountChip({\n dashboardUrl = 'https://ochk.app/me/account',\n signInUrl: signInUrlOverride,\n signInLabel = 'sign in',\n className,\n triggerClassName,\n popoverClassName,\n menuItemClassName,\n}: OcAccountChipProps): React.ReactElement | null {\n const { status, account, signInUrl: sessionSignInUrl, trySignOut } = useOcSession();\n const signInUrl = signInUrlOverride ?? sessionSignInUrl;\n const [open, setOpen] = React.useState(false);\n // The auth host did not end the session: say so, and keep showing the account.\n const [signOutFailed, setSignOutFailed] = React.useState(false);\n const wrapRef = React.useRef<HTMLDivElement | null>(null);\n\n React.useEffect(() => {\n if (!open) return;\n function handleClickOutside(e: MouseEvent) {\n if (wrapRef.current && !wrapRef.current.contains(e.target as Node)) {\n setOpen(false);\n }\n }\n function handleEscape(e: KeyboardEvent) {\n if (e.key === 'Escape') setOpen(false);\n }\n document.addEventListener('mousedown', handleClickOutside);\n document.addEventListener('keydown', handleEscape);\n return () => {\n document.removeEventListener('mousedown', handleClickOutside);\n document.removeEventListener('keydown', handleEscape);\n };\n }, [open]);\n\n if (status === 'loading') return null;\n\n if (status !== 'authenticated' || !account) {\n return (\n <a\n href={signInUrl}\n className={triggerClassName ?? className}\n data-oc-account-chip-signin=\"\"\n >\n {signInLabel}\n </a>\n );\n }\n\n return (\n <div\n ref={wrapRef}\n className={className}\n data-oc-account-chip=\"\"\n style={{ position: 'relative', display: 'inline-block' }}\n >\n <button\n type=\"button\"\n onClick={() => setOpen((v) => !v)}\n aria-haspopup=\"menu\"\n aria-expanded={open}\n aria-label={`Signed in as ${account.didOc}. Open account menu.`}\n className={triggerClassName}\n data-oc-account-chip-trigger=\"\"\n style={\n triggerClassName\n ? undefined\n : {\n display: 'inline-flex',\n alignItems: 'center',\n gap: '0.4rem',\n padding: '0.25rem 0.625rem',\n borderRadius: '9999px',\n border: '1px solid var(--border, #27272a)',\n background:\n 'color-mix(in oklch, var(--muted, #27272a) 40%, transparent)',\n color: 'var(--foreground, #fafafa)',\n fontFamily: 'ui-monospace, SFMono-Regular, monospace',\n fontSize: 12,\n cursor: 'pointer',\n }\n }\n >\n <span aria-hidden=\"true\" style={{ color: '#22c55e', fontSize: 8 }}>\n ●\n </span>\n <span>{account.displayName ?? shortenAddress(account.didOc)}</span>\n <svg\n width=\"9\"\n height=\"9\"\n viewBox=\"0 0 10 10\"\n aria-hidden=\"true\"\n style={{\n transition: 'transform 120ms',\n transform: open ? 'rotate(180deg)' : 'rotate(0)',\n opacity: 0.6,\n }}\n >\n <path\n d=\"M2 4 L5 7 L8 4\"\n stroke=\"currentColor\"\n strokeWidth=\"1.5\"\n fill=\"none\"\n strokeLinecap=\"round\"\n />\n </svg>\n </button>\n\n {open && (\n <div\n role=\"menu\"\n aria-label=\"Account menu\"\n className={popoverClassName}\n data-oc-account-chip-popover=\"\"\n style={\n popoverClassName\n ? { position: 'absolute', zIndex: 50, top: 'calc(100% + 6px)', right: 0 }\n : {\n position: 'absolute',\n zIndex: 50,\n top: 'calc(100% + 6px)',\n right: 0,\n minWidth: 240,\n background: 'var(--popover, #0a0a0a)',\n color: 'var(--popover-foreground, #fafafa)',\n border: '1px solid var(--border, #27272a)',\n boxShadow: '0 10px 32px -4px rgba(0,0,0,0.35)',\n fontFamily: 'ui-monospace, SFMono-Regular, monospace',\n }\n }\n >\n <div\n data-oc-account-chip-header=\"\"\n style={{\n padding: '0.75rem 0.75rem 0.625rem',\n borderBottom: '1px solid var(--border, #27272a)',\n }}\n >\n <div\n data-oc-account-chip-label=\"\"\n style={{\n color: 'var(--primary, #f97316)',\n fontSize: 10,\n letterSpacing: '0.18em',\n textTransform: 'uppercase',\n marginBottom: 4,\n }}\n >\n § signed in\n </div>\n <div\n data-oc-account-chip-address=\"\"\n style={{\n color: 'var(--popover-foreground, #fafafa)',\n fontSize: 11,\n wordBreak: 'break-all',\n lineHeight: 1.35,\n }}\n >\n {account.didOc}\n </div>\n {account.displayName ? (\n <div\n style={{\n color: 'var(--muted-foreground, #a1a1aa)',\n fontSize: 10,\n marginTop: 4,\n letterSpacing: '0.06em',\n }}\n >\n {account.displayName}\n </div>\n ) : null}\n </div>\n <div role=\"none\" style={{ padding: '0.25rem' }}>\n {dashboardUrl ? (\n <a\n role=\"menuitem\"\n href={dashboardUrl}\n onClick={() => setOpen(false)}\n className={menuItemClassName}\n data-oc-account-chip-item=\"\"\n style={\n menuItemClassName\n ? undefined\n : {\n display: 'flex',\n alignItems: 'center',\n gap: '0.5rem',\n padding: '0.5rem 0.625rem',\n fontSize: 12,\n color: 'var(--popover-foreground, #fafafa)',\n textDecoration: 'none',\n cursor: 'pointer',\n }\n }\n >\n <span\n aria-hidden=\"true\"\n style={{ color: 'var(--muted-foreground, #a1a1aa)' }}\n >\n →\n </span>\n <span style={{ flex: 1 }}>dashboard</span>\n <span\n style={{\n color: 'var(--muted-foreground, #a1a1aa)',\n fontSize: 10,\n }}\n >\n ↗\n </span>\n </a>\n ) : null}\n <button\n type=\"button\"\n role=\"menuitem\"\n onClick={() => {\n setOpen(false);\n setSignOutFailed(false);\n void trySignOut().then((r) => setSignOutFailed(!r.ok));\n }}\n className={menuItemClassName}\n data-oc-account-chip-item=\"\"\n data-oc-account-chip-signout=\"\"\n style={\n menuItemClassName\n ? undefined\n : {\n display: 'flex',\n alignItems: 'center',\n gap: '0.5rem',\n width: '100%',\n padding: '0.5rem 0.625rem',\n fontSize: 12,\n color: 'var(--popover-foreground, #fafafa)',\n background: 'transparent',\n border: 0,\n fontFamily: 'inherit',\n textAlign: 'left',\n cursor: 'pointer',\n }\n }\n >\n <span\n aria-hidden=\"true\"\n style={{ color: 'var(--muted-foreground, #a1a1aa)' }}\n >\n →\n </span>\n <span style={{ flex: 1 }}>sign out</span>\n </button>\n </div>\n </div>\n )}\n {signOutFailed ? <SignOutFailed /> : null}\n </div>\n );\n}\n\n/** Said when the auth host did not end the session, so the person is still signed in. */\nfunction SignOutFailed(): React.ReactElement {\n return (\n <span\n role=\"alert\"\n data-oc-signout-failed=\"\"\n style={{ display: 'block', marginTop: 4, fontSize: 12, color: 'var(--destructive, #dc2626)' }}\n >\n Couldn’t sign out. You’re still signed in; try again.\n </span>\n );\n}\n\nexport interface OcSignInButtonProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> {\n /** Label shown when no user is signed in. Defaults to `sign in`. */\n label?: string;\n /**\n * When `true`, render an `<a>` even while the session is loading, to\n * avoid layout shift. Defaults to `false` (renders nothing while loading).\n */\n eager?: boolean;\n /**\n * Override the destination URL. Defaults to the session's `signInUrl`\n * (the auth host's redirect-style /signin). Set this to a local path\n * like `'/signin'` when the consumer site has its own in-place\n * `<OcSignIn />` page — keeps the user in-tab.\n */\n signInUrl?: string;\n}\n\n/**\n * Drop-in sign-in button. Renders an anchor that points at either:\n *\n * - the consumer's local `/signin` page (when `signInUrl` prop is set\n * — recommended; works with `<OcSignIn />`), or\n * - the auth host's `/signin?return_to=…` (default fallback)\n *\n * When the user is already authenticated it renders nothing.\n */\nexport function OcSignInButton({\n label = 'sign in',\n eager = false,\n className,\n signInUrl: signInUrlOverride,\n ...rest\n}: OcSignInButtonProps): React.ReactElement | null {\n const { status, signInUrl: sessionSignInUrl } = useOcSession();\n const href = signInUrlOverride ?? sessionSignInUrl;\n if (status === 'authenticated') return null;\n if (!eager && status === 'loading') return null;\n\n return (\n <a\n {...rest}\n href={href}\n className={className}\n data-oc-sign-in-button=\"\"\n >\n {label}\n </a>\n );\n}\n\nexport interface OcAccountPillProps extends React.HTMLAttributes<HTMLDivElement> {\n /** URL to link the address to. With none, the label is plain text. */\n dashboardUrl?: string;\n /** Override the display text. Defaults to the shortened address. */\n render?: (account: { address: string; displayName?: string | null }) => React.ReactNode;\n}\n\n/**\n * Shows the signed-in user as a short pill: `bc1q…abcd sign out`.\n *\n * Renders nothing while loading or when no user is signed in — pair with\n * `<OcSignInButton>` for the anonymous case.\n */\nexport function OcAccountPill({\n dashboardUrl,\n render,\n className,\n ...rest\n}: OcAccountPillProps): React.ReactElement | null {\n const { status, account, trySignOut } = useOcSession();\n // The auth host did not end the session: say so, and keep showing the account.\n const [signOutFailed, setSignOutFailed] = React.useState(false);\n\n if (status !== 'authenticated' || !account) return null;\n\n const label = render\n ? render({ address: account.didOc, displayName: account.displayName })\n : (account.displayName ?? shortenAddress(account.didOc));\n\n return (\n <div\n {...rest}\n className={className}\n data-oc-account-pill=\"\"\n style={{ display: 'inline-flex', alignItems: 'center', gap: '0.5rem', ...(rest.style ?? {}) }}\n >\n {dashboardUrl ? (\n <a href={dashboardUrl}>{label}</a>\n ) : (\n <span>{label}</span>\n )}\n <button\n type=\"button\"\n onClick={() => {\n setSignOutFailed(false);\n void trySignOut().then((r) => setSignOutFailed(!r.ok));\n }}\n aria-label=\"Sign out\"\n style={{\n background: 'none',\n border: 'none',\n cursor: 'pointer',\n color: 'inherit',\n font: 'inherit',\n padding: 0,\n }}\n >\n sign out\n </button>\n {signOutFailed ? <SignOutFailed /> : null}\n </div>\n );\n}\n\nexport interface OcAddressInputProps\n extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'value' | 'onChange'> {\n /** Controlled value. */\n value: string;\n /** Called when value changes — typed by the user OR selected from the popover. */\n onValueChange: (value: string) => void;\n /** Label shown above the suggested address in the popover. Defaults to `use your address`. */\n suggestionLabel?: string;\n /** className applied to the wrapper `<div>`. */\n wrapperClassName?: string;\n /** className applied to the suggestion popover. Style with `[data-oc-address-popover]` otherwise. */\n popoverClassName?: string;\n /** className applied to the suggestion button. Style with `[data-oc-address-suggestion]` otherwise. */\n suggestionClassName?: string;\n}\n\n/**\n * Bitcoin-address `<input>` that, when the user is signed in via `oc_session`,\n * surfaces their address as a one-click suggestion on focus.\n *\n * Behaviour:\n * - On focus, if logged-in AND the typed value is a prefix of the session\n * address (or empty), show a small popover with `bc1q…7ke3` as a clickable\n * suggestion.\n * - Click / Enter on the suggestion fills the field with the full address.\n * - Down-arrow from the input highlights the suggestion; Up-arrow clears the\n * highlight; Escape closes the popover; clicking outside closes the popover.\n * - When the user types something that's no longer a prefix of the session\n * address, the popover hides itself out of the way.\n * - When the field already contains the session address exactly, no popover.\n *\n * Style-agnostic: minimal inline styles for positioning only. Style the parts\n * via `wrapperClassName` / `popoverClassName` / `suggestionClassName`, or via\n * the `[data-oc-address-input]`, `[data-oc-address-popover]`, and\n * `[data-oc-address-suggestion]` data attributes.\n */\nexport interface UseOcAddressSuggestionOptions {\n /** Current value of the input. */\n value: string;\n /** Called when the user selects the suggestion (or you may also call it from the input's onChange). */\n onValueChange: (value: string) => void;\n /** Label shown above the suggested address in the popover. Defaults to `use your address`. */\n suggestionLabel?: string;\n /** className applied to the suggestion popover. Style with `[data-oc-address-popover]` otherwise. */\n popoverClassName?: string;\n /** className applied to the suggestion button. Style with `[data-oc-address-suggestion]` otherwise. */\n suggestionClassName?: string;\n}\n\nexport interface UseOcAddressSuggestionReturn {\n /**\n * Props to spread onto your `<input>` element. Adds focus/blur/keydown\n * handlers and the combobox ARIA attributes. Combine with your existing\n * `value`/`onChange` props — this hook does NOT control them.\n */\n inputProps: {\n onFocus: (e: React.FocusEvent<HTMLInputElement>) => void;\n onBlur: (e: React.FocusEvent<HTMLInputElement>) => void;\n onKeyDown: (e: React.KeyboardEvent<HTMLInputElement>) => void;\n role: 'combobox';\n 'aria-haspopup': 'listbox';\n 'aria-expanded': boolean;\n 'aria-controls': string | undefined;\n 'aria-activedescendant': string | undefined;\n autoComplete: 'off';\n spellCheck: false;\n };\n /**\n * The suggestion popover. Render directly after your `<input>`, inside a\n * `position: relative` container so the popover anchors below the input.\n * Returns `null` when there's no suggestion to show.\n */\n popover: React.ReactNode;\n}\n\n/**\n * Hook variant of `OcAddressInput`. Use when you want to keep your existing\n * styled `<input>` (e.g. shadcn `<Input>`) and just bolt on the\n * session-address suggestion behaviour.\n *\n * Wrap your input in a `position: relative` container, spread `inputProps`\n * onto the input, and render `{popover}` immediately after. The hook's\n * focus / blur / keydown handlers are composed via `inputProps` — they call\n * any handlers you've already passed to your input only when you wire them\n * yourself in addition to spreading `inputProps`.\n *\n * Example:\n * ```tsx\n * const { inputProps, popover } = useOcAddressSuggestion({\n * value: addr,\n * onValueChange: setAddr,\n * });\n * return (\n * <div className=\"relative\">\n * <Input\n * value={addr}\n * onChange={(e) => setAddr(e.target.value)}\n * {...inputProps}\n * placeholder=\"bc1q…\"\n * />\n * {popover}\n * </div>\n * );\n * ```\n */\n/**\n * The address to offer: the account's primary one, else the Bitcoin address it\n * shows. Consumer sites verify the session locally and have no primary address\n * (`primary_btc` is null), but a wallet sign-in shows its address.\n */\nfunction accountAddress(account: OcAccount | null | undefined): string | null {\n if (account?.primaryBtc) return account.primaryBtc;\n return account?.displayIdentity?.kind === 'btc' ? account.displayIdentity.value : null;\n}\n\nexport function useOcAddressSuggestion(\n options: UseOcAddressSuggestionOptions\n): UseOcAddressSuggestionReturn {\n const {\n value,\n onValueChange,\n suggestionLabel = 'use your address',\n popoverClassName,\n suggestionClassName,\n } = options;\n\n const { status, account } = useOcSession();\n const sessionAddress = status === 'authenticated' ? accountAddress(account) : null;\n\n const [open, setOpen] = React.useState(false);\n const [highlighted, setHighlighted] = React.useState(false);\n const blurTimer = React.useRef<number | null>(null);\n\n const listboxId = useUniqueId('oc-addr-listbox');\n const optionId = `${listboxId}-opt`;\n\n const valueMatchesSession =\n sessionAddress != null && value.toLowerCase() === sessionAddress.toLowerCase();\n const canSuggest =\n sessionAddress != null &&\n sessionAddress.length > 0 &&\n !valueMatchesSession &&\n isPrefixOf(value, sessionAddress);\n const showPopover = open && canSuggest;\n\n function selectSuggestion() {\n if (!sessionAddress) return;\n onValueChange(sessionAddress);\n setOpen(false);\n setHighlighted(false);\n }\n\n React.useEffect(() => {\n return () => {\n if (blurTimer.current != null) window.clearTimeout(blurTimer.current);\n };\n }, []);\n\n const inputProps: UseOcAddressSuggestionReturn['inputProps'] = {\n onFocus: () => {\n if (blurTimer.current != null) {\n window.clearTimeout(blurTimer.current);\n blurTimer.current = null;\n }\n setOpen(true);\n },\n onBlur: () => {\n blurTimer.current = window.setTimeout(() => {\n setOpen(false);\n setHighlighted(false);\n }, 120);\n },\n onKeyDown: (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (!showPopover) return;\n if (e.key === 'ArrowDown') {\n e.preventDefault();\n setHighlighted(true);\n } else if (e.key === 'ArrowUp') {\n e.preventDefault();\n setHighlighted(false);\n } else if (e.key === 'Escape') {\n e.preventDefault();\n setOpen(false);\n setHighlighted(false);\n } else if (e.key === 'Enter' && highlighted) {\n e.preventDefault();\n selectSuggestion();\n }\n },\n role: 'combobox',\n 'aria-haspopup': 'listbox',\n 'aria-expanded': showPopover,\n 'aria-controls': showPopover ? listboxId : undefined,\n 'aria-activedescendant': highlighted ? optionId : undefined,\n autoComplete: 'off',\n spellCheck: false,\n };\n\n const popover = showPopover && sessionAddress ? (\n <div\n id={listboxId}\n role=\"listbox\"\n data-oc-address-popover=\"\"\n className={popoverClassName}\n style={{\n position: 'absolute',\n zIndex: 50,\n top: 'calc(100% + 4px)',\n left: 0,\n right: 0,\n }}\n onMouseDown={(e) => e.preventDefault()}\n >\n <button\n type=\"button\"\n id={optionId}\n role=\"option\"\n aria-selected={highlighted}\n data-oc-address-suggestion=\"\"\n data-highlighted={highlighted ? '' : undefined}\n className={suggestionClassName}\n onClick={selectSuggestion}\n onMouseEnter={() => setHighlighted(true)}\n onMouseLeave={() => setHighlighted(false)}\n style={{\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'space-between',\n gap: '0.75rem',\n width: '100%',\n textAlign: 'left',\n cursor: 'pointer',\n font: 'inherit',\n background: 'inherit',\n color: 'inherit',\n border: 0,\n padding: 'inherit',\n }}\n >\n <span data-oc-address-suggestion-label=\"\">{suggestionLabel}</span>\n <span\n data-oc-address-suggestion-value=\"\"\n style={{ fontFamily: 'ui-monospace, monospace' }}\n >\n {shortenAddressMid(sessionAddress)}\n </span>\n </button>\n </div>\n ) : null;\n\n return { inputProps, popover };\n}\n\nexport const OcAddressInput = React.forwardRef<HTMLInputElement, OcAddressInputProps>(\n function OcAddressInput(\n {\n value,\n onValueChange,\n suggestionLabel = 'use your address',\n wrapperClassName,\n popoverClassName,\n suggestionClassName,\n onFocus,\n onBlur,\n onKeyDown,\n ...rest\n },\n forwardedRef\n ): React.ReactElement {\n const { status, account } = useOcSession();\n const sessionAddress = status === 'authenticated' ? accountAddress(account) : null;\n\n const [open, setOpen] = React.useState(false);\n const [highlighted, setHighlighted] = React.useState(false);\n\n const innerRef = React.useRef<HTMLInputElement | null>(null);\n const setRef = (node: HTMLInputElement | null) => {\n innerRef.current = node;\n if (typeof forwardedRef === 'function') forwardedRef(node);\n else if (forwardedRef) forwardedRef.current = node;\n };\n const blurTimer = React.useRef<number | null>(null);\n\n const listboxId = useUniqueId('oc-addr-listbox');\n const optionId = `${listboxId}-opt`;\n\n const valueMatchesSession =\n sessionAddress != null && value.toLowerCase() === sessionAddress.toLowerCase();\n const canSuggest =\n sessionAddress != null &&\n sessionAddress.length > 0 &&\n !valueMatchesSession &&\n isPrefixOf(value, sessionAddress);\n const showPopover = open && canSuggest;\n\n function selectSuggestion() {\n if (!sessionAddress) return;\n onValueChange(sessionAddress);\n setOpen(false);\n setHighlighted(false);\n // Re-focus so the next Tab moves on naturally.\n innerRef.current?.focus();\n }\n\n function handleFocus(e: React.FocusEvent<HTMLInputElement>) {\n if (blurTimer.current != null) {\n window.clearTimeout(blurTimer.current);\n blurTimer.current = null;\n }\n setOpen(true);\n onFocus?.(e);\n }\n\n function handleBlur(e: React.FocusEvent<HTMLInputElement>) {\n // Defer close so a click on the suggestion can register first.\n blurTimer.current = window.setTimeout(() => {\n setOpen(false);\n setHighlighted(false);\n }, 120);\n onBlur?.(e);\n }\n\n function handleKeyDown(e: React.KeyboardEvent<HTMLInputElement>) {\n if (showPopover) {\n if (e.key === 'ArrowDown') {\n e.preventDefault();\n setHighlighted(true);\n } else if (e.key === 'ArrowUp') {\n e.preventDefault();\n setHighlighted(false);\n } else if (e.key === 'Escape') {\n e.preventDefault();\n setOpen(false);\n setHighlighted(false);\n } else if (e.key === 'Enter' && highlighted) {\n e.preventDefault();\n selectSuggestion();\n }\n }\n onKeyDown?.(e);\n }\n\n React.useEffect(() => {\n return () => {\n if (blurTimer.current != null) window.clearTimeout(blurTimer.current);\n };\n }, []);\n\n return (\n <div\n data-oc-address-input=\"\"\n className={wrapperClassName}\n style={{ position: 'relative' }}\n >\n <input\n {...rest}\n ref={setRef}\n value={value}\n onChange={(e) => onValueChange(e.target.value)}\n onFocus={handleFocus}\n onBlur={handleBlur}\n onKeyDown={handleKeyDown}\n role=\"combobox\"\n aria-haspopup=\"listbox\"\n aria-expanded={showPopover}\n aria-controls={showPopover ? listboxId : undefined}\n aria-activedescendant={highlighted ? optionId : undefined}\n autoComplete=\"off\"\n spellCheck={false}\n />\n {showPopover && sessionAddress && (\n <div\n id={listboxId}\n role=\"listbox\"\n data-oc-address-popover=\"\"\n className={popoverClassName}\n style={{\n position: 'absolute',\n zIndex: 50,\n top: 'calc(100% + 4px)',\n left: 0,\n right: 0,\n }}\n // Prevent the input from blurring before the click on the suggestion lands.\n onMouseDown={(e) => e.preventDefault()}\n >\n <button\n type=\"button\"\n id={optionId}\n role=\"option\"\n aria-selected={highlighted}\n data-oc-address-suggestion=\"\"\n data-highlighted={highlighted ? '' : undefined}\n className={suggestionClassName}\n onClick={selectSuggestion}\n onMouseEnter={() => setHighlighted(true)}\n onMouseLeave={() => setHighlighted(false)}\n style={{\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'space-between',\n gap: '0.75rem',\n width: '100%',\n textAlign: 'left',\n cursor: 'pointer',\n font: 'inherit',\n background: 'inherit',\n color: 'inherit',\n border: 'inherit',\n padding: 'inherit',\n }}\n >\n <span data-oc-address-suggestion-label=\"\">{suggestionLabel}</span>\n <span\n data-oc-address-suggestion-value=\"\"\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|
4
4
|
OcAddressInput,
|
|
5
5
|
OcSignInButton,
|
|
6
6
|
useOcAddressSuggestion
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-VQY7IYHV.mjs";
|
|
8
|
+
import "./chunk-JLMDCC6K.mjs";
|
|
9
|
+
import "./chunk-PQHFAVVM.mjs";
|
|
10
10
|
import "./chunk-JTT77LMU.mjs";
|
|
11
11
|
import "./chunk-4BOO7EQR.mjs";
|
|
12
12
|
export {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|