@orangecheck/me-client 0.46.0 → 0.47.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/react.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../node_modules/@orangecheck/mark/src/index.ts","../node_modules/@orangecheck/mark/src/react.tsx","../src/popup.ts","../src/button.ts","../src/react.tsx"],"names":["ORDER","jsx","useState","jsxs"],"mappings":";;;;;;AASO,IAAM,WAAA,GAAc;EACvB,GAAA,EAAK,2BAAA;EACL,IAAA,EAAM,iBAAA;EACN,KAAA,EAAO;AACX,CAAA;AAEO,IAAM,YAAA,GAAe,UAAA;AAGrB,IAAM,aAAa,EAAE,GAAA,EAAK,WAAW,IAAA,EAAM,SAAA,EAAW,OAAO,SAAA,EAAA;AAG7D,IAAM,oBAAoB,EAAE,GAAA,EAAK,GAAG,IAAA,EAAM,GAAA,EAAK,OAAO,IAAA,EAAA;AAGtD,IAAM,SAAA,GAAY;EACrB,OAAA,EAAS,WAAA;EACT,MAAA,EAAQ,IAAA;EACR,IAAA,EAAM,SAAA;EACN,SAAA,EAAW;AACf,CAAA;ACZA,IAAMA,MAAAA,GAAQ,CAAC,MAAA,EAAQ,OAAA,EAAS,KAAK,CAAA;AAErC,SAAS,KAAK,IAAA,EAAwC;AAClD,EAAA,IAAI,OAAO,IAAA,KAAS,QAAA,EAAU,OAAO,IAAA,GAAO,CAAA;AAC5C,EAAA,MAAM,CAAA,GAAI,wBAAA,CAAyB,IAAA,CAAK,IAAA,CAAK,MAAM,CAAA;AACnD,EAAA,OAAO,CAAA,GAAI,CAAA,EAAG,MAAA,CAAO,CAAA,CAAE,CAAC,CAAC,CAAA,GAAI,CAAC,CAAA,EAAG,CAAA,CAAE,CAAC,CAAC,CAAA,CAAA,GAAK,MAAA;AAC9C;AAGO,SAAS,eAAA,CAAgB,EAAE,OAAA,GAAU,MAAA,EAAQ,KAAA,EAAO,MAAM,KAAA,GAAQ,cAAA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,eAAS,KAAK,CAAA;AAEtC,EAAA,eAAe,OAAA,GAAU;AACrB,IAAA,IAAI,QAAQ,QAAA,EAAU;AACtB,IAAA,OAAA,CAAQ,IAAI,CAAA;AAEZ,IAAA,MAAM,OAAA,GAAU,oBAAoB,KAAK,CAAA;AACzC,IAAA,IAAI;AACA,MAAA,MAAM,UAAU,MAAM,OAAA;AACtB,MAAA,SAAA,GAAY,OAAO,CAAA;AACnB,MAAA,IAAI,OAAA,CAAQ,MAAA,KAAW,WAAA,EAAa,MAAM,UAAA,CAAW,EAAE,OAAA,EAAS,OAAA,CAAQ,OAAA,EAAS,KAAA,EAAO,OAAA,CAAQ,KAAA,EAAO,CAAA;AAAA,IAC3G,CAAA,SAAE;AACE,MAAA,OAAA,CAAQ,KAAK,CAAA;AAAA,IACjB;AAAA,EACJ;AAEA,EAAA,uBACIC,eAAAA;AAAA,IAAC,QAAA;AAAA,IAAA;AAAA,MACI,GAAG,IAAA;AAAA,MACJ,IAAA,EAAK,QAAA;AAAA,MACL,QAAA;AAAA,MACA,iBAAA,EAAgB,EAAA;AAAA,MAChB,mBAAiB,OAAA,CAAQ,UAAA;AAAA,MACzB,iBAAe,IAAA,IAAQ,MAAA;AAAA,MACvB,aAAW,IAAA,IAAQ,MAAA;AAAA,MACnB,OAAA,EAAS,MAAM,KAAK,OAAA,EAAQ;AAAA,MAE3B,QAAA,EAAA;AAAA,QAAA,OAAA,CAAQ,uBAAOF,cAAAA,CAAC,mBAAgB,OAAA,EAAS,OAAA,CAAQ,MAAM,CAAA,GAAK,IAAA;AAAA,wBAC7DA,eAAC,MAAA,EAAA,EAAK,eAAA,EAAc,IAAI,QAAA,EAAA,IAAA,GAAO,kBAAA,GAAqB,QAAQ,KAAA,EAAM;AAAA;AAAA;AAAA,GACtE;AAER","file":"react.js","sourcesContent":["/**\n * The orangecheck mark: an isometric check on a 16×8 grid, three faces.\n *\n * Framework-free and dependency-free: SVG strings for any page, a data URI\n * for CSS and images, and the geometry for a renderer that draws its own.\n * The React component is in `@orangecheck/mark/react`.\n */\n\n/** The three faces as SVG points in the 16×8 box. */\nexport const MARK_POINTS = {\n top: '0,3 2,2 6,4 14,0 16,1 6,6',\n left: '0,3 6,6 6,8 0,5',\n right: '6,6 16,1 16,3 6,8',\n} as const;\n\nexport const MARK_VIEWBOX = '0 0 16 8';\n\n/** The faces as drawn. For dark grounds only: the top face is about 1.3:1 on white. */\nexport const MARK_FACES = { top: '#FED8AB', left: '#FB933C', right: '#EA580B' } as const;\n\n/** One colour, three weights: the check at full strength, the sides as depth. */\nexport const MARK_MONO_OPACITY = { top: 1, left: 0.7, right: 0.45 } as const;\n\n/** The tile: the faces on an ink square with rounded corners, 24×24. Reads on any ground. */\nexport const MARK_TILE = {\n viewBox: '0 0 24 24',\n radius: 6.25,\n fill: '#0A0A0A',\n transform: 'translate(4.25 8.1) scale(0.97)',\n} as const;\n\n/** Smallest width the bare mark may be drawn at, in CSS pixels (the tile: the same, square). */\nexport const MARK_MIN_PX = 16;\n\n/** `mono`: the host's text colour. `brand`: as drawn, on dark grounds. `tile`: the faces on their own ink tile. */\nexport type MarkVariant = 'mono' | 'brand' | 'tile';\n\nexport interface MarkSvgOptions {\n variant?: MarkVariant;\n /** An accessible name. Without one the mark is decoration, hidden from assistive technology. */\n title?: string;\n /** Width as a CSS length, `1.5em` by default (the tile `1.25em`); the height follows. Overridable from CSS. */\n width?: string;\n /** The mono colour. Default `currentColor`; a data URI needs a real colour, since an image inherits none. */\n color?: string;\n /** Added to the `<svg>` element. */\n className?: string;\n}\n\nconst ORDER = ['left', 'right', 'top'] as const;\n\nfunction escape(s: string): string {\n return s.replace(/[&<>\"']/g, (c) => `&#${c.charCodeAt(0)};`);\n}\n\nfunction faces(variant: MarkVariant, color: string): string {\n return ORDER.map((face) =>\n variant === 'mono'\n ? `<polygon points=\"${MARK_POINTS[face]}\" fill=\"${escape(color)}\"${MARK_MONO_OPACITY[face] === 1 ? '' : ` fill-opacity=\"${MARK_MONO_OPACITY[face]}\"`}/>`\n : `<polygon points=\"${MARK_POINTS[face]}\" fill=\"${MARK_FACES[face]}\"/>`\n ).join('');\n}\n\n/** The height that keeps a CSS length's aspect for the variant: half for the mark, equal for the tile. */\nfunction heightFor(variant: MarkVariant, width: string): string {\n if (variant === 'tile') return width;\n const m = /^(-?[\\d.]+)([a-z%]*)$/i.exec(width.trim());\n return m ? `${Number(m[1]) / 2}${m[2]}` : 'auto';\n}\n\n/**\n * The mark as an SVG string. Sized in em by default, so it follows the\n * font size of the text beside it; a stylesheet can still set its size,\n * since width and height are attributes, not inline styles (no CSP needed).\n */\nexport function markSvg(options: MarkSvgOptions = {}): string {\n const variant = options.variant ?? 'mono';\n if (variant !== 'mono' && variant !== 'brand' && variant !== 'tile') throw new TypeError(`markSvg: unknown variant ${String(variant)}`);\n const width = options.width ?? (variant === 'tile' ? '1.25em' : '1.5em');\n const color = options.color ?? 'currentColor';\n const label = options.title ? `<title>${escape(options.title)}</title>` : '';\n const a11y = options.title ? 'role=\"img\"' : 'aria-hidden=\"true\" focusable=\"false\"';\n const cls = options.className ? ` class=\"${escape(options.className)}\"` : '';\n const size = `width=\"${escape(width)}\" height=\"${escape(heightFor(variant, width))}\"`;\n if (variant === 'tile') {\n return (\n `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"${MARK_TILE.viewBox}\" ${size} ${a11y} data-oc-mark=\"tile\"${cls}>${label}` +\n `<rect width=\"24\" height=\"24\" rx=\"${MARK_TILE.radius}\" fill=\"${MARK_TILE.fill}\"/>` +\n `<g transform=\"${MARK_TILE.transform}\">${faces('brand', color)}</g></svg>`\n );\n }\n return `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"${MARK_VIEWBOX}\" ${size} ${a11y} data-oc-mark=\"${variant}\"${cls}>${label}${faces(variant, color)}</svg>`;\n}\n\n/** The mark as a `data:image/svg+xml` URI, for CSS backgrounds and `<img>`. Mono needs an explicit `color`. */\nexport function markDataUri(options: MarkSvgOptions = {}): string {\n if ((options.variant ?? 'mono') === 'mono' && (!options.color || options.color === 'currentColor')) {\n throw new TypeError('markDataUri: a mono mark in an image needs a colour; an image inherits none');\n }\n return `data:image/svg+xml,${encodeURIComponent(markSvg({ ...options, width: options.width ?? '16' }))}`;\n}\n\nconst SVG_NS = 'http://www.w3.org/2000/svg';\n\n/**\n * The mark as an `<svg>` element, built node by node: no HTML parsing, so\n * it works under Trusted Types and any Content-Security-Policy. Same\n * drawing and attributes as markSvg.\n */\nexport function markElement(doc: Document, options: Omit<MarkSvgOptions, 'className'> & { className?: string } = {}): SVGSVGElement {\n const variant = options.variant ?? 'mono';\n if (variant !== 'mono' && variant !== 'brand' && variant !== 'tile') throw new TypeError(`markElement: unknown variant ${String(variant)}`);\n const width = options.width ?? (variant === 'tile' ? '1.25em' : '1.5em');\n const color = options.color ?? 'currentColor';\n const el = <K extends keyof SVGElementTagNameMap>(tag: K, attrs: Record<string, string>) => {\n const node = doc.createElementNS(SVG_NS, tag);\n for (const [k, v] of Object.entries(attrs)) node.setAttribute(k, v);\n return node;\n };\n const svg = el('svg', {\n viewBox: variant === 'tile' ? MARK_TILE.viewBox : MARK_VIEWBOX,\n width,\n height: heightFor(variant, width),\n 'data-oc-mark': variant,\n });\n if (options.className) svg.setAttribute('class', options.className);\n if (options.title) {\n svg.setAttribute('role', 'img');\n const title = el('title', {});\n title.textContent = options.title;\n svg.append(title);\n } else {\n svg.setAttribute('aria-hidden', 'true');\n svg.setAttribute('focusable', 'false');\n }\n const parent = variant === 'tile' ? el('g', { transform: MARK_TILE.transform }) : svg;\n if (variant === 'tile') svg.append(el('rect', { width: '24', height: '24', rx: String(MARK_TILE.radius), fill: MARK_TILE.fill }), parent);\n for (const face of ORDER) {\n const attrs: Record<string, string> = { points: MARK_POINTS[face] };\n if (variant === 'mono') {\n attrs.fill = color;\n if (MARK_MONO_OPACITY[face] !== 1) attrs['fill-opacity'] = String(MARK_MONO_OPACITY[face]);\n } else attrs.fill = MARK_FACES[face];\n parent.append(el('polygon', attrs));\n }\n return svg;\n}\n","import type { SVGProps } from 'react';\n\nimport { MARK_FACES, MARK_MONO_OPACITY, MARK_POINTS, MARK_TILE, MARK_VIEWBOX, type MarkVariant } from './index';\n\nexport { MARK_FACES, MARK_MIN_PX, MARK_MONO_OPACITY, MARK_POINTS, MARK_TILE, MARK_VIEWBOX, markDataUri, markElement, markSvg } from './index';\nexport type { MarkSvgOptions, MarkVariant } from './index';\n\nexport interface OrangecheckMarkProps extends Omit<SVGProps<SVGSVGElement>, 'children' | 'width' | 'height'> {\n variant?: MarkVariant;\n /** An accessible name. Without one the mark is decoration, hidden from assistive technology. */\n title?: string;\n /** Width as a CSS length or px number, `1.5em` by default (the tile `1.25em`); the height follows. */\n size?: string | number;\n /** The mono colour, `currentColor` by default. */\n color?: string;\n}\n\nconst ORDER = ['left', 'right', 'top'] as const;\n\nfunction half(size: string | number): string | number {\n if (typeof size === 'number') return size / 2;\n const m = /^(-?[\\d.]+)([a-z%]*)$/i.exec(size.trim());\n return m ? `${Number(m[1]) / 2}${m[2]}` : 'auto';\n}\n\n/** The orangecheck mark. Mono takes the text colour; brand is for dark grounds; the tile reads anywhere. */\nexport function OrangecheckMark({ variant = 'mono', title, size, color = 'currentColor', ...rest }: OrangecheckMarkProps) {\n const width = size ?? (variant === 'tile' ? '1.25em' : '1.5em');\n const a11y = title ? { role: 'img' } : { 'aria-hidden': true, focusable: false };\n const polys = ORDER.map((face) =>\n variant === 'mono' ? (\n <polygon key={face} points={MARK_POINTS[face]} fill={color} fillOpacity={MARK_MONO_OPACITY[face] === 1 ? undefined : MARK_MONO_OPACITY[face]} />\n ) : (\n <polygon key={face} points={MARK_POINTS[face]} fill={MARK_FACES[face]} />\n )\n );\n if (variant === 'tile') {\n return (\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox={MARK_TILE.viewBox} width={width} height={width} data-oc-mark=\"tile\" {...a11y} {...rest}>\n {title ? <title>{title}</title> : null}\n <rect width=\"24\" height=\"24\" rx={MARK_TILE.radius} fill={MARK_TILE.fill} />\n <g transform={MARK_TILE.transform}>{polys}</g>\n </svg>\n );\n }\n return (\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox={MARK_VIEWBOX} width={width} height={half(width)} data-oc-mark={variant} {...a11y} {...rest}>\n {title ? <title>{title}</title> : null}\n {polys}\n </svg>\n );\n}\n","/**\n * Browser only: `signInWithOc` opens the orangecheck sign-in popup and resolves\n * with a token bound to your origin; `signInWithOcOutcome` says why when it\n * does not. Verify the token on your server with\n * [`@orangecheck/me-client/server`](/sdk/me-client/server/README).\n *\n * @packageDocumentation\n */\n\n/**\n * @orangecheck/me-client/popup\n *\n * Browser-side helper that opens the OC sign-in popup, listens for the\n * postMessage from me.ochk.io, and resolves with the verified session.\n *\n * import { signInWithOc } from '@orangecheck/me-client/popup';\n *\n * document.querySelector('#oc-signin')!.addEventListener('click', async () => {\n * const result = await signInWithOc();\n * if (!result) return;\n * // Your server verifies it and keeps it in an httpOnly cookie.\n * const r = await fetch('/api/auth/session', {\n * method: 'POST',\n * headers: { 'Content-Type': 'application/json' },\n * body: JSON.stringify({ token: result.token }),\n * });\n * if (r.ok) location.assign('/app');\n * });\n *\n * Why this lives in a separate entry point: it's browser-only (uses\n * window.open / addEventListener) and integrators that only need the\n * server-side verifier shouldn't pull popup orchestration into their\n * server bundle.\n */\n\nconst DEFAULT_POPUP_ORIGIN = 'https://me.ochk.io';\nconst DEFAULT_POPUP_PATH = '/popup/signin';\nconst DEFAULT_FEATURES = 'width=480,height=720,resizable=yes,scrollbars=yes';\n\nexport interface OcPopupAccount {\n id?: string;\n /** Opaque public identity · `did:oc:<32-hex>`. Stable across linking\n * events. The canonical identifier post auth-refactor (Dec 2025\n * +). */\n did_oc?: string;\n /** Primary linked Bitcoin address, if the user has one and is\n * surfacing it (same-origin family integrators get it inline;\n * cross-domain integrators need the bitcoin_address scope). */\n primary_btc?: string | null;\n /** Whether the user has a primary email linked (plaintext stays\n * on auth host; only the boolean reaches integrators). */\n has_email?: boolean;\n /** Legacy fields kept for back-compat with pre-refactor consumers.\n * Prefer did_oc + primary_btc. Removed in a future major. */\n address?: string;\n btc_address?: string;\n display_name?: string | null;\n nostr_npub?: string | null;\n wallet_provisioned?: boolean;\n email?: string;\n}\n\nexport interface OcPopupResult {\n /** Account payload from the auth host, unsigned: trust only the\n * verified token. `did_oc` is the account's opaque identifier, the\n * same at every site; the email and Bitcoin address stay private\n * unless the user grants a scope. */\n account: OcPopupAccount;\n /** The session JWT, bound to your origin. Hand it once to your own\n * server, which verifies it and keeps it in an httpOnly cookie; never\n * in localStorage, where any script on the page can read it. Family\n * sites (*.ochk.io) can ignore it: the Domain=.ochk.io cookie rides\n * home on its own. */\n token: string;\n}\n\nexport interface SignInWithOcOptions {\n /** Origin of the OC popup page. Defaults to https://me.ochk.io.\n * Override only for staging / preview environments. */\n popupOrigin?: string;\n /** Path on the popup origin. Defaults to /popup/signin. */\n popupPath?: string;\n /** window.open features string. Defaults to a 480x720 resizable\n * popup with scrollbars. */\n features?: string;\n /** AbortSignal that cancels the wait and closes the popup. */\n signal?: AbortSignal;\n}\n\n/**\n * How a sign-in popup ended:\n * - `signed_in` · the person signed in; `account` and `token` as from signInWithOc.\n * - `blocked` · the browser refused to open the window. Ask the person to\n * allow pop-ups for your site, then try again from a click.\n * - `closed` · the person closed the window without signing in.\n * - `aborted` · your AbortSignal fired.\n * - `failed` · not in a browser, or the popup's answer was malformed.\n */\nexport type OcPopupOutcome =\n | ({ status: 'signed_in' } & OcPopupResult)\n | { status: 'blocked' }\n | { status: 'closed' }\n | { status: 'aborted' }\n | { status: 'failed' };\n\n/**\n * Open the OC signin popup and resolve with how it ended (OcPopupOutcome),\n * so a blocked window and a closed one can be told apart.\n *\n * MUST be called inside a user-gesture handler (e.g. a button onClick).\n * Browsers block `window.open` outside of user gestures.\n */\nexport function signInWithOcOutcome(options: SignInWithOcOptions = {}): Promise<OcPopupOutcome> {\n const popupOrigin = options.popupOrigin ?? DEFAULT_POPUP_ORIGIN;\n const popupPath = options.popupPath ?? DEFAULT_POPUP_PATH;\n const features = options.features ?? DEFAULT_FEATURES;\n\n return new Promise((resolve) => {\n if (typeof window === 'undefined') {\n resolve({ status: 'failed' });\n return;\n }\n\n const url = new URL(popupPath, popupOrigin);\n url.searchParams.set('opener_origin', window.location.origin);\n const popup = window.open(url.toString(), 'oc-signin', features);\n if (!popup) {\n resolve({ status: 'blocked' });\n return;\n }\n popup.focus();\n\n let settled = false;\n const cleanup = () => {\n window.removeEventListener('message', onMessage);\n clearInterval(closedTimer);\n if (options.signal) options.signal.removeEventListener('abort', onAbort);\n };\n\n function settle(value: OcPopupOutcome) {\n if (settled) return;\n settled = true;\n cleanup();\n try {\n if (popup && !popup.closed) popup.close();\n } catch {\n /* popup may have closed itself first */\n }\n resolve(value);\n }\n\n function onMessage(event: MessageEvent) {\n // Origin pinning is necessary but not sufficient — same-origin\n // pages other than our popup can post the same shape. Pin both\n // origin AND source window so only the popup we opened can\n // settle this promise.\n if (event.origin !== popupOrigin) return;\n if (event.source !== popup) return;\n const data = event.data as\n | { type?: string; account?: OcPopupAccount; token?: string }\n | null;\n if (!data || data.type !== 'oc-signin-success') return;\n if (!data.account || !data.token) {\n settle({ status: 'failed' });\n return;\n }\n settle({ status: 'signed_in', account: data.account, token: data.token });\n }\n\n function onAbort() {\n settle({ status: 'aborted' });\n }\n\n window.addEventListener('message', onMessage);\n if (options.signal) {\n if (options.signal.aborted) {\n settle({ status: 'aborted' });\n return;\n }\n options.signal.addEventListener('abort', onAbort);\n }\n\n // Detect the person closing the popup without completing signin.\n const closedTimer = setInterval(() => {\n if (popup && popup.closed) settle({ status: 'closed' });\n }, 500);\n });\n}\n\n/**\n * Open the OC signin popup and resolve with the session result. Returns\n * `null` if the user closed the popup without completing signin, if the\n * browser blocked it, or if the AbortSignal fired. To tell those apart,\n * use signInWithOcOutcome.\n *\n * MUST be called inside a user-gesture handler (e.g. a button onClick).\n * Browsers block `window.open` outside of user gestures.\n */\nexport async function signInWithOc(options: SignInWithOcOptions = {}): Promise<OcPopupResult | null> {\n const outcome = await signInWithOcOutcome(options);\n return outcome.status === 'signed_in' ? { account: outcome.account, token: outcome.token } : null;\n}\n","/**\n * Browser only, no framework: a \"Sign in with orangecheck\" button that keeps\n * your site's own look. Write your button as you write every other one, add\n * `data-oc-sign-in`, and enhance it: this adds the orangecheck mark and the\n * label, opens the sign-in popup inside the click, holds the busy state, and\n * says how the popup ended. Optional stylesheet: `@orangecheck/me-client/button.css`.\n *\n * <button class=\"cta ghost\" data-oc-sign-in>Sign in with orangecheck</button>\n *\n * import { enhanceSignInButton } from '@orangecheck/me-client/button';\n * enhanceSignInButton(document.querySelector('[data-oc-sign-in]'), {\n * onSignedIn: async ({ token }) => { … },\n * });\n *\n * The file has no imports at run time (the mark and the popup are bundled\n * in), so it can be copied onto your own origin under a strict CSP.\n *\n * @packageDocumentation\n */\n\nimport { markElement, type MarkVariant } from '@orangecheck/mark';\n\nimport { signInWithOcOutcome, type OcPopupOutcome, type OcPopupResult, type SignInWithOcOptions } from './popup';\n\nexport type { MarkVariant } from '@orangecheck/mark';\nexport type { OcPopupOutcome, OcPopupResult, SignInWithOcOptions } from './popup';\n\n/** The labels a sign-in button may carry. \"orangecheck\" is always lowercase, never \"OC\". */\nexport const SIGN_IN_LABELS = {\n signIn: 'Sign in with orangecheck',\n continue: 'Continue with orangecheck',\n signUp: 'Sign up with orangecheck',\n} as const;\nexport type SignInLabel = (typeof SIGN_IN_LABELS)[keyof typeof SIGN_IN_LABELS];\n\n/** What the button says while the sign-in window is open. */\nexport const SIGN_IN_BUSY_LABEL = 'Signing in…';\n\n/** What to tell the person when the window did not end in a sign-in. Show it near the button. */\nexport const OUTCOME_COPY = {\n blocked: 'Your browser blocked the sign-in window. Allow pop-ups for this site, then try again.',\n closed: 'The sign-in window closed before you finished.',\n failed: \"Sign-in didn't finish. Try again.\",\n} as const;\n\n/** `inherit`: no colour, font or radius of its own; your classes draw it. `brand`: orangecheck's button, themed by --oc-* properties. */\nexport type SignInAppearance = 'inherit' | 'brand';\n\nexport interface EnhanceSignInButtonOptions {\n /** Called with the popup's account and token once the person signs in; the button stays busy until it settles. */\n onSignedIn: (result: OcPopupResult) => void | Promise<void>;\n /** Called with how every popup ended, sign-in included. Use OUTCOME_COPY for the words. */\n onOutcome?: (outcome: OcPopupOutcome) => void;\n /** The mark beside the label: `mono` (your text colour, the default), `brand` (dark buttons), `tile`, or `false` for none. */\n mark?: MarkVariant | false;\n /** One of SIGN_IN_LABELS. Default \"Sign in with orangecheck\". */\n label?: SignInLabel;\n appearance?: SignInAppearance;\n /** Passed to the popup (a preview origin, say). */\n popup?: Omit<SignInWithOcOptions, 'signal'>;\n}\n\nconst LABELS = new Set<string>(Object.values(SIGN_IN_LABELS));\nconst MARKS = new Set<unknown>(['mono', 'brand', 'tile', false]);\nconst KEYS = new Set(['onSignedIn', 'onOutcome', 'mark', 'label', 'appearance', 'popup']);\n\n/** The options, checked: a misspelt key or a label outside the approved set fails loudly, not quietly. */\nexport function checkSignInOptions(options: EnhanceSignInButtonOptions): Required<Pick<EnhanceSignInButtonOptions, 'mark' | 'label' | 'appearance'>> {\n for (const key of Object.keys(options)) if (!KEYS.has(key)) throw new TypeError(`sign-in button: unknown option ${key}`);\n if (typeof options.onSignedIn !== 'function') throw new TypeError('sign-in button: onSignedIn is required');\n const label = options.label ?? SIGN_IN_LABELS.signIn;\n if (!LABELS.has(label)) throw new TypeError(`sign-in button: \"${label}\" is not an approved label; use one of SIGN_IN_LABELS`);\n const mark = options.mark ?? 'mono';\n if (!MARKS.has(mark)) throw new TypeError(`sign-in button: unknown mark ${String(mark)}`);\n const appearance = options.appearance ?? 'inherit';\n if (appearance !== 'inherit' && appearance !== 'brand') throw new TypeError(`sign-in button: unknown appearance ${String(appearance)}`);\n return { label, mark, appearance };\n}\n\n/**\n * Make `button` an orangecheck sign-in button. Its classes and styles stay\n * yours; its content becomes the mark and the label. While the window is\n * open it is `aria-disabled` and `aria-busy`, and still focusable. Returns a\n * function that undoes it.\n */\nexport function enhanceSignInButton(button: HTMLButtonElement, options: EnhanceSignInButtonOptions): () => void {\n if (!button || button.tagName !== 'BUTTON') throw new TypeError('sign-in button: pass a <button> element');\n const { label, mark, appearance } = checkSignInOptions(options);\n const before = { nodes: [...button.childNodes], type: button.getAttribute('type') };\n const doc = button.ownerDocument;\n\n if (!before.type) button.type = 'button';\n button.setAttribute('data-oc-sign-in', '');\n button.setAttribute('data-appearance', appearance);\n // Built node by node: no HTML is parsed, so Trusted Types and strict CSPs allow it.\n const text = doc.createElement('span');\n text.setAttribute('data-oc-label', '');\n text.textContent = label;\n button.replaceChildren(...(mark ? [markElement(doc, { variant: mark })] : []), text);\n\n let busy = false;\n const setBusy = (on: boolean) => {\n busy = on;\n text.textContent = on ? SIGN_IN_BUSY_LABEL : label;\n if (on) {\n button.setAttribute('aria-disabled', 'true');\n button.setAttribute('aria-busy', 'true');\n } else {\n button.removeAttribute('aria-disabled');\n button.removeAttribute('aria-busy');\n }\n };\n\n const onClick = async (event: MouseEvent) => {\n event.preventDefault();\n if (busy || button.disabled) return;\n setBusy(true);\n // Opened before anything is awaited: a window opened later is blocked.\n const pending = signInWithOcOutcome(options.popup);\n try {\n const outcome = await pending;\n options.onOutcome?.(outcome);\n if (outcome.status === 'signed_in') await options.onSignedIn({ account: outcome.account, token: outcome.token });\n } finally {\n setBusy(false);\n }\n };\n button.addEventListener('click', onClick);\n\n return () => {\n button.removeEventListener('click', onClick);\n button.replaceChildren(...before.nodes);\n if (before.type === null) button.removeAttribute('type');\n for (const a of ['data-oc-sign-in', 'data-appearance', 'aria-disabled', 'aria-busy']) button.removeAttribute(a);\n };\n}\n","/**\n * React: `<SignInWithOrangecheck>`, a native `<button>` that keeps your site's\n * look (appearance `inherit`, the default) or wears orangecheck's (appearance\n * `brand`, themed by --oc-* custom properties in `@orangecheck/me-client/button.css`).\n * It carries the mark and an approved label, opens the popup inside the\n * click, and holds the busy state. `react` is an optional peer: no other\n * entry of this package loads it.\n *\n * @packageDocumentation\n */\n\nimport type { ButtonHTMLAttributes } from 'react';\n\nimport { OrangecheckMark } from '@orangecheck/mark/react';\nimport { useState } from 'react';\n\nimport { checkSignInOptions, SIGN_IN_BUSY_LABEL, type EnhanceSignInButtonOptions } from './button';\nimport { signInWithOcOutcome } from './popup';\n\nexport { OUTCOME_COPY, SIGN_IN_BUSY_LABEL, SIGN_IN_LABELS } from './button';\nexport type { EnhanceSignInButtonOptions, MarkVariant, OcPopupOutcome, OcPopupResult, SignInAppearance, SignInLabel } from './button';\n\nexport type SignInWithOrangecheckProps = EnhanceSignInButtonOptions &\n Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onClick' | 'children' | 'type'>;\n\n/** A \"Sign in with orangecheck\" button. Your className and style draw it; it brings the mark, the words and the popup. */\nexport function SignInWithOrangecheck({ onSignedIn, onOutcome, mark, label, appearance, popup, disabled, ...rest }: SignInWithOrangecheckProps) {\n const options = checkSignInOptions({ onSignedIn, onOutcome, mark, label, appearance, popup });\n const [busy, setBusy] = useState(false);\n\n async function onClick() {\n if (busy || disabled) return;\n setBusy(true);\n // Opened before anything is awaited: a window opened later is blocked.\n const pending = signInWithOcOutcome(popup);\n try {\n const outcome = await pending;\n onOutcome?.(outcome);\n if (outcome.status === 'signed_in') await onSignedIn({ account: outcome.account, token: outcome.token });\n } finally {\n setBusy(false);\n }\n }\n\n return (\n <button\n {...rest}\n type=\"button\"\n disabled={disabled}\n data-oc-sign-in=\"\"\n data-appearance={options.appearance}\n aria-disabled={busy || undefined}\n aria-busy={busy || undefined}\n onClick={() => void onClick()}\n >\n {options.mark ? <OrangecheckMark variant={options.mark} /> : null}\n <span data-oc-label=\"\">{busy ? SIGN_IN_BUSY_LABEL : options.label}</span>\n </button>\n );\n}\n"]}
1
+ {"version":3,"sources":["../node_modules/@orangecheck/mark/src/index.ts","../node_modules/@orangecheck/mark/src/react.tsx","../src/popup.ts","../src/button.ts","../src/react.tsx"],"names":["ORDER","jsx","useState","useRef","jsxs"],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;AAER","file":"react.js","sourcesContent":["/**\n * The orangecheck mark: an isometric check on a 16×8 grid, three faces.\n *\n * Framework-free and dependency-free: SVG strings for any page, a data URI\n * for CSS and images, and the geometry for a renderer that draws its own.\n * The React component is in `@orangecheck/mark/react`.\n */\n\n/** The three faces as SVG points in the 16×8 box. */\nexport const MARK_POINTS = {\n top: '0,3 2,2 6,4 14,0 16,1 6,6',\n left: '0,3 6,6 6,8 0,5',\n right: '6,6 16,1 16,3 6,8',\n} as const;\n\nexport const MARK_VIEWBOX = '0 0 16 8';\n\n/** The faces as drawn. For dark grounds only: the top face is about 1.3:1 on white. */\nexport const MARK_FACES = { top: '#FED8AB', left: '#FB933C', right: '#EA580B' } as const;\n\n/**\n * One colour, three weights: the check at full strength, the sides as depth.\n * Chosen for the widest smallest step between neighbouring faces and the\n * ground across light, dark and mid-tone (amber, brown) buttons.\n */\nexport const MARK_MONO_OPACITY = { top: 1, left: 0.6, right: 0.3 } as const;\n\n/** The tile: the faces on an ink square with rounded corners, 24×24. Reads on any ground. */\nexport const MARK_TILE = {\n viewBox: '0 0 24 24',\n radius: 6.25,\n fill: '#0A0A0A',\n transform: 'translate(4.25 8.1) scale(0.97)',\n} as const;\n\n/** Smallest width the bare mark may be drawn at, in CSS pixels (the tile: the same, square). */\nexport const MARK_MIN_PX = 16;\n\n/** `mono`: the host's text colour. `brand`: as drawn, on dark grounds. `tile`: the faces on their own ink tile. */\nexport type MarkVariant = 'mono' | 'brand' | 'tile';\n\nexport interface MarkSvgOptions {\n variant?: MarkVariant;\n /** An accessible name. Without one the mark is decoration, hidden from assistive technology. */\n title?: string;\n /** Width as a CSS length, `1.75em` by default (the tile `1.25em`); the height follows. Overridable from CSS. */\n width?: string;\n /** Mono only: every face at full strength, one flat shape. For forced colours and anything that cannot shade. */\n flat?: boolean;\n /** The mono colour. Default `currentColor`; a data URI needs a real colour, since an image inherits none. */\n color?: string;\n /** Added to the `<svg>` element. */\n className?: string;\n}\n\nconst ORDER = ['left', 'right', 'top'] as const;\n\nfunction escape(s: string): string {\n return s.replace(/[&<>\"']/g, (c) => `&#${c.charCodeAt(0)};`);\n}\n\n/** A face's opacity in mono: stepped, or full for a flat mark. */\nfunction opacity(face: (typeof ORDER)[number], flat: boolean): number {\n return flat ? 1 : MARK_MONO_OPACITY[face];\n}\n\nfunction faces(variant: MarkVariant, color: string, flat = false): string {\n return ORDER.map((face) =>\n variant === 'mono'\n ? `<polygon points=\"${MARK_POINTS[face]}\" fill=\"${escape(color)}\"${opacity(face, flat) === 1 ? '' : ` fill-opacity=\"${opacity(face, flat)}\"`}/>`\n : `<polygon points=\"${MARK_POINTS[face]}\" fill=\"${MARK_FACES[face]}\"/>`\n ).join('');\n}\n\n/** The height that keeps a CSS length's aspect for the variant: half for the mark, equal for the tile. */\nfunction heightFor(variant: MarkVariant, width: string): string {\n if (variant === 'tile') return width;\n const m = /^(-?[\\d.]+)([a-z%]*)$/i.exec(width.trim());\n return m ? `${Number(m[1]) / 2}${m[2]}` : 'auto';\n}\n\n/**\n * The mark as an SVG string. Sized in em by default, so it follows the\n * font size of the text beside it; a stylesheet can still set its size,\n * since width and height are attributes, not inline styles (no CSP needed).\n */\nexport function markSvg(options: MarkSvgOptions = {}): string {\n const variant = options.variant ?? 'mono';\n if (variant !== 'mono' && variant !== 'brand' && variant !== 'tile') throw new TypeError(`markSvg: unknown variant ${String(variant)}`);\n const width = options.width ?? (variant === 'tile' ? '1.25em' : '1.75em');\n const color = options.color ?? 'currentColor';\n const label = options.title ? `<title>${escape(options.title)}</title>` : '';\n const a11y = options.title ? 'role=\"img\"' : 'aria-hidden=\"true\" focusable=\"false\"';\n const cls = options.className ? ` class=\"${escape(options.className)}\"` : '';\n const size = `width=\"${escape(width)}\" height=\"${escape(heightFor(variant, width))}\"`;\n if (variant === 'tile') {\n return (\n `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"${MARK_TILE.viewBox}\" ${size} ${a11y} data-oc-mark=\"tile\"${cls}>${label}` +\n `<rect width=\"24\" height=\"24\" rx=\"${MARK_TILE.radius}\" fill=\"${MARK_TILE.fill}\"/>` +\n `<g transform=\"${MARK_TILE.transform}\">${faces('brand', color)}</g></svg>`\n );\n }\n return `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"${MARK_VIEWBOX}\" ${size} ${a11y} data-oc-mark=\"${variant}\"${cls}>${label}${faces(variant, color, options.flat)}</svg>`;\n}\n\n/** The mark as a `data:image/svg+xml` URI, for CSS backgrounds and `<img>`. Mono needs an explicit `color`. */\nexport function markDataUri(options: MarkSvgOptions = {}): string {\n if ((options.variant ?? 'mono') === 'mono' && (!options.color || options.color === 'currentColor')) {\n throw new TypeError('markDataUri: a mono mark in an image needs a colour; an image inherits none');\n }\n return `data:image/svg+xml,${encodeURIComponent(markSvg({ ...options, width: options.width ?? '16' }))}`;\n}\n\nconst SVG_NS = 'http://www.w3.org/2000/svg';\n\n/**\n * The mark as an `<svg>` element, built node by node: no HTML parsing, so\n * it works under Trusted Types and any Content-Security-Policy. Same\n * drawing and attributes as markSvg.\n */\nexport function markElement(doc: Document, options: Omit<MarkSvgOptions, 'className'> & { className?: string } = {}): SVGSVGElement {\n const variant = options.variant ?? 'mono';\n if (variant !== 'mono' && variant !== 'brand' && variant !== 'tile') throw new TypeError(`markElement: unknown variant ${String(variant)}`);\n const width = options.width ?? (variant === 'tile' ? '1.25em' : '1.75em');\n const color = options.color ?? 'currentColor';\n const el = <K extends keyof SVGElementTagNameMap>(tag: K, attrs: Record<string, string>) => {\n const node = doc.createElementNS(SVG_NS, tag);\n for (const [k, v] of Object.entries(attrs)) node.setAttribute(k, v);\n return node;\n };\n const svg = el('svg', {\n viewBox: variant === 'tile' ? MARK_TILE.viewBox : MARK_VIEWBOX,\n width,\n height: heightFor(variant, width),\n 'data-oc-mark': variant,\n });\n if (options.className) svg.setAttribute('class', options.className);\n if (options.title) {\n svg.setAttribute('role', 'img');\n const title = el('title', {});\n title.textContent = options.title;\n svg.append(title);\n } else {\n svg.setAttribute('aria-hidden', 'true');\n svg.setAttribute('focusable', 'false');\n }\n const parent = variant === 'tile' ? el('g', { transform: MARK_TILE.transform }) : svg;\n if (variant === 'tile') svg.append(el('rect', { width: '24', height: '24', rx: String(MARK_TILE.radius), fill: MARK_TILE.fill }), parent);\n for (const face of ORDER) {\n const attrs: Record<string, string> = { points: MARK_POINTS[face] };\n if (variant === 'mono') {\n attrs.fill = color;\n if (opacity(face, !!options.flat) !== 1) attrs['fill-opacity'] = String(opacity(face, !!options.flat));\n } else attrs.fill = MARK_FACES[face];\n parent.append(el('polygon', attrs));\n }\n return svg;\n}\n","import type { SVGProps } from 'react';\n\nimport { MARK_FACES, MARK_MONO_OPACITY, MARK_POINTS, MARK_TILE, MARK_VIEWBOX, type MarkVariant } from './index';\n\nexport { MARK_FACES, MARK_MIN_PX, MARK_MONO_OPACITY, MARK_POINTS, MARK_TILE, MARK_VIEWBOX, markDataUri, markElement, markSvg } from './index';\nexport type { MarkSvgOptions, MarkVariant } from './index';\n\nexport interface OrangecheckMarkProps extends Omit<SVGProps<SVGSVGElement>, 'children' | 'width' | 'height'> {\n variant?: MarkVariant;\n /** An accessible name. Without one the mark is decoration, hidden from assistive technology. */\n title?: string;\n /** Width as a CSS length or px number, `1.75em` by default (the tile `1.25em`); the height follows. */\n size?: string | number;\n /** Mono only: every face at full strength, one flat shape (forced colours). */\n flat?: boolean;\n /** The mono colour, `currentColor` by default. */\n color?: string;\n}\n\nconst ORDER = ['left', 'right', 'top'] as const;\n\nfunction half(size: string | number): string | number {\n if (typeof size === 'number') return size / 2;\n const m = /^(-?[\\d.]+)([a-z%]*)$/i.exec(size.trim());\n return m ? `${Number(m[1]) / 2}${m[2]}` : 'auto';\n}\n\n/** The orangecheck mark. Mono takes the text colour; brand is for dark grounds; the tile reads anywhere. */\nexport function OrangecheckMark({ variant = 'mono', title, size, color = 'currentColor', flat = false, ...rest }: OrangecheckMarkProps) {\n const width = size ?? (variant === 'tile' ? '1.25em' : '1.75em');\n const a11y = title ? { role: 'img' } : { 'aria-hidden': true, focusable: false };\n const polys = ORDER.map((face) =>\n variant === 'mono' ? (\n <polygon key={face} points={MARK_POINTS[face]} fill={color} fillOpacity={flat || MARK_MONO_OPACITY[face] === 1 ? undefined : MARK_MONO_OPACITY[face]} />\n ) : (\n <polygon key={face} points={MARK_POINTS[face]} fill={MARK_FACES[face]} />\n )\n );\n if (variant === 'tile') {\n return (\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox={MARK_TILE.viewBox} width={width} height={width} data-oc-mark=\"tile\" {...a11y} {...rest}>\n {title ? <title>{title}</title> : null}\n <rect width=\"24\" height=\"24\" rx={MARK_TILE.radius} fill={MARK_TILE.fill} />\n <g transform={MARK_TILE.transform}>{polys}</g>\n </svg>\n );\n }\n return (\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox={MARK_VIEWBOX} width={width} height={half(width)} data-oc-mark={variant} {...a11y} {...rest}>\n {title ? <title>{title}</title> : null}\n {polys}\n </svg>\n );\n}\n","/**\n * Browser only: `signInWithOc` opens the orangecheck sign-in popup and resolves\n * with a token bound to your origin; `signInWithOcOutcome` says why when it\n * does not. Verify the token on your server with\n * [`@orangecheck/me-client/server`](/sdk/me-client/server/README).\n *\n * @packageDocumentation\n */\n\n/**\n * @orangecheck/me-client/popup\n *\n * Browser-side helper that opens the OC sign-in popup, listens for the\n * postMessage from me.ochk.io, and resolves with the verified session.\n *\n * import { signInWithOc } from '@orangecheck/me-client/popup';\n *\n * document.querySelector('#oc-signin')!.addEventListener('click', async () => {\n * const result = await signInWithOc();\n * if (!result) return;\n * // Your server verifies it and keeps it in an httpOnly cookie.\n * const r = await fetch('/api/auth/session', {\n * method: 'POST',\n * headers: { 'Content-Type': 'application/json' },\n * body: JSON.stringify({ token: result.token }),\n * });\n * if (r.ok) location.assign('/app');\n * });\n *\n * Why this lives in a separate entry point: it's browser-only (uses\n * window.open / addEventListener) and integrators that only need the\n * server-side verifier shouldn't pull popup orchestration into their\n * server bundle.\n */\n\nconst DEFAULT_POPUP_ORIGIN = 'https://me.ochk.io';\nconst DEFAULT_POPUP_PATH = '/popup/signin';\nconst DEFAULT_FEATURES = 'width=480,height=720,resizable=yes,scrollbars=yes';\n\nexport interface OcPopupAccount {\n id?: string;\n /** Opaque public identity · `did:oc:<32-hex>`. Stable across linking\n * events. The canonical identifier post auth-refactor (Dec 2025\n * +). */\n did_oc?: string;\n /** Primary linked Bitcoin address, if the user has one and is\n * surfacing it (same-origin family integrators get it inline;\n * cross-domain integrators need the bitcoin_address scope). */\n primary_btc?: string | null;\n /** Whether the user has a primary email linked (plaintext stays\n * on auth host; only the boolean reaches integrators). */\n has_email?: boolean;\n /** Legacy fields kept for back-compat with pre-refactor consumers.\n * Prefer did_oc + primary_btc. Removed in a future major. */\n address?: string;\n btc_address?: string;\n display_name?: string | null;\n nostr_npub?: string | null;\n wallet_provisioned?: boolean;\n email?: string;\n}\n\nexport interface OcPopupResult {\n /** Account payload from the auth host, unsigned: trust only the\n * verified token. `did_oc` is the account's opaque identifier, the\n * same at every site; the email and Bitcoin address stay private\n * unless the user grants a scope. */\n account: OcPopupAccount;\n /** The session JWT, bound to your origin. Hand it once to your own\n * server, which verifies it and keeps it in an httpOnly cookie; never\n * in localStorage, where any script on the page can read it. Family\n * sites (*.ochk.io) can ignore it: the Domain=.ochk.io cookie rides\n * home on its own. */\n token: string;\n}\n\nexport interface SignInWithOcOptions {\n /** Origin of the OC popup page. Defaults to https://me.ochk.io.\n * Override only for staging / preview environments. */\n popupOrigin?: string;\n /** Path on the popup origin. Defaults to /popup/signin. */\n popupPath?: string;\n /** window.open features string. Defaults to a 480x720 resizable\n * popup with scrollbars. */\n features?: string;\n /** AbortSignal that cancels the wait and closes the popup. */\n signal?: AbortSignal;\n}\n\n/**\n * How a sign-in popup ended:\n * - `signed_in` · the person signed in; `account` and `token` as from signInWithOc.\n * - `blocked` · the browser refused to open the window. Ask the person to\n * allow pop-ups for your site, then try again from a click.\n * - `closed` · the person closed the window without signing in.\n * - `aborted` · your AbortSignal fired.\n * - `failed` · not in a browser, or the popup's answer was malformed.\n */\nexport type OcPopupOutcome =\n | ({ status: 'signed_in' } & OcPopupResult)\n | { status: 'blocked' }\n | { status: 'closed' }\n | { status: 'aborted' }\n | { status: 'failed' };\n\n/**\n * Open the OC signin popup and resolve with how it ended (OcPopupOutcome),\n * so a blocked window and a closed one can be told apart.\n *\n * MUST be called inside a user-gesture handler (e.g. a button onClick).\n * Browsers block `window.open` outside of user gestures.\n */\nexport function signInWithOcOutcome(options: SignInWithOcOptions = {}): Promise<OcPopupOutcome> {\n const popupOrigin = options.popupOrigin ?? DEFAULT_POPUP_ORIGIN;\n const popupPath = options.popupPath ?? DEFAULT_POPUP_PATH;\n const features = options.features ?? DEFAULT_FEATURES;\n\n return new Promise((resolve) => {\n if (typeof window === 'undefined') {\n resolve({ status: 'failed' });\n return;\n }\n\n const url = new URL(popupPath, popupOrigin);\n url.searchParams.set('opener_origin', window.location.origin);\n const popup = window.open(url.toString(), 'oc-signin', features);\n if (!popup) {\n resolve({ status: 'blocked' });\n return;\n }\n popup.focus();\n\n let settled = false;\n const cleanup = () => {\n window.removeEventListener('message', onMessage);\n clearInterval(closedTimer);\n if (options.signal) options.signal.removeEventListener('abort', onAbort);\n };\n\n function settle(value: OcPopupOutcome) {\n if (settled) return;\n settled = true;\n cleanup();\n try {\n if (popup && !popup.closed) popup.close();\n } catch {\n /* popup may have closed itself first */\n }\n resolve(value);\n }\n\n function onMessage(event: MessageEvent) {\n // Origin pinning is necessary but not sufficient — same-origin\n // pages other than our popup can post the same shape. Pin both\n // origin AND source window so only the popup we opened can\n // settle this promise.\n if (event.origin !== popupOrigin) return;\n if (event.source !== popup) return;\n const data = event.data as\n | { type?: string; account?: OcPopupAccount; token?: string }\n | null;\n if (!data || data.type !== 'oc-signin-success') return;\n if (!data.account || !data.token) {\n settle({ status: 'failed' });\n return;\n }\n settle({ status: 'signed_in', account: data.account, token: data.token });\n }\n\n function onAbort() {\n settle({ status: 'aborted' });\n }\n\n window.addEventListener('message', onMessage);\n if (options.signal) {\n if (options.signal.aborted) {\n settle({ status: 'aborted' });\n return;\n }\n options.signal.addEventListener('abort', onAbort);\n }\n\n // Detect the person closing the popup without completing signin.\n const closedTimer = setInterval(() => {\n if (popup && popup.closed) settle({ status: 'closed' });\n }, 500);\n });\n}\n\n/**\n * Open the OC signin popup and resolve with the session result. Returns\n * `null` if the user closed the popup without completing signin, if the\n * browser blocked it, or if the AbortSignal fired. To tell those apart,\n * use signInWithOcOutcome.\n *\n * MUST be called inside a user-gesture handler (e.g. a button onClick).\n * Browsers block `window.open` outside of user gestures.\n */\nexport async function signInWithOc(options: SignInWithOcOptions = {}): Promise<OcPopupResult | null> {\n const outcome = await signInWithOcOutcome(options);\n return outcome.status === 'signed_in' ? { account: outcome.account, token: outcome.token } : null;\n}\n","/**\n * Browser only, no framework: a \"Sign in with orangecheck\" button that keeps\n * your site's own look. Write your button as you write every other one, add\n * `data-oc-sign-in`, and enhance it: this adds the orangecheck mark and the\n * label, opens the sign-in popup inside the click, holds the busy state, and\n * says how the popup ended. Optional stylesheet: `@orangecheck/me-client/button.css`.\n *\n * <button class=\"cta ghost\" data-oc-sign-in>Sign in with orangecheck</button>\n *\n * import { enhanceSignInButton } from '@orangecheck/me-client/button';\n * enhanceSignInButton(document.querySelector('[data-oc-sign-in]'), {\n * onSignedIn: async ({ token }) => { … },\n * });\n *\n * The file has no imports at run time (the mark and the popup are bundled\n * in), so it can be copied onto your own origin under a strict CSP.\n *\n * @packageDocumentation\n */\n\nimport { markElement, type MarkVariant } from '@orangecheck/mark';\n\nimport { signInWithOcOutcome, type OcPopupOutcome, type OcPopupResult, type SignInWithOcOptions } from './popup';\n\nexport type { MarkVariant } from '@orangecheck/mark';\nexport type { OcPopupOutcome, OcPopupResult, SignInWithOcOptions } from './popup';\n\n/**\n * The approved English labels. A label in another language is fine too, as\n * long as it keeps the word \"orangecheck\", lowercase, as written.\n */\nexport const SIGN_IN_LABELS = {\n signIn: 'Sign in with orangecheck',\n continue: 'Continue with orangecheck',\n signUp: 'Sign up with orangecheck',\n} as const;\nexport type SignInLabel = string;\n\n/** What the button says while the sign-in window is open (the default; `busyLabel` sets your own). */\nexport const SIGN_IN_BUSY_LABEL = 'Signing in…';\n\n/** What to tell the person when the window did not end in a sign-in. Show it near the button. */\nexport const OUTCOME_COPY = {\n blocked: 'Your browser blocked the sign-in window. Allow pop-ups for this site, then try again.',\n closed: 'The sign-in window closed before you finished.',\n failed: \"Sign-in didn't finish. Try again.\",\n} as const;\n\n/** `inherit`: no colour, font or radius of its own; your classes draw it. `brand`: orangecheck's button, themed by --oc-* properties. */\nexport type SignInAppearance = 'inherit' | 'brand';\n\nexport interface EnhanceSignInButtonOptions {\n /** Called with the popup's account and token once the person signs in; the button stays busy until it settles. */\n onSignedIn: (result: OcPopupResult) => void | Promise<void>;\n /** Called with how every popup ended, sign-in included. Use OUTCOME_COPY for the words. */\n onOutcome?: (outcome: OcPopupOutcome) => void;\n /** The mark beside the label: `mono` (your text colour, the default), `brand` (dark buttons), `tile`, or `false` for none. */\n mark?: MarkVariant | false;\n /**\n * The words: one of SIGN_IN_LABELS (default \"Sign in with orangecheck\"), or\n * the same in your language, keeping \"orangecheck\" as written. `false` draws\n * the mark alone, square, named by `accessibleLabel`.\n */\n label?: SignInLabel | false;\n /** What it says while the window is open. Default \"Signing in…\". */\n busyLabel?: string;\n /** The accessible name of a mark-only button (`label: false`). Default \"Sign in with orangecheck\". */\n accessibleLabel?: string;\n appearance?: SignInAppearance;\n /** Passed to the popup (a preview origin, say). */\n popup?: Omit<SignInWithOcOptions, 'signal'>;\n}\n\nconst MARKS = new Set<unknown>(['mono', 'brand', 'tile', false]);\nconst KEYS = new Set(['onSignedIn', 'onOutcome', 'mark', 'label', 'busyLabel', 'accessibleLabel', 'appearance', 'popup']);\n/** The name, as written: lowercase, a word of its own. */\nconst NAMED = /(^|[^\\p{L}\\p{N}])orangecheck($|[^\\p{L}\\p{N}])/u;\n\nexport interface CheckedSignInOptions {\n mark: MarkVariant | false;\n label: string | false;\n busyLabel: string;\n accessibleLabel: string;\n appearance: SignInAppearance;\n}\n\n/** The options, checked: a misspelt key, or words without \"orangecheck\" in them, fail loudly, not quietly. */\nexport function checkSignInOptions(options: EnhanceSignInButtonOptions): CheckedSignInOptions {\n for (const key of Object.keys(options)) if (!KEYS.has(key)) throw new TypeError(`sign-in button: unknown option ${key}`);\n if (typeof options.onSignedIn !== 'function') throw new TypeError('sign-in button: onSignedIn is required');\n const label = options.label ?? SIGN_IN_LABELS.signIn;\n if (label !== false && (typeof label !== 'string' || !NAMED.test(label))) {\n throw new TypeError(`sign-in button: \"${String(label)}\" must say \"orangecheck\", lowercase, as written; see SIGN_IN_LABELS`);\n }\n const accessibleLabel = options.accessibleLabel ?? SIGN_IN_LABELS.signIn;\n if (!NAMED.test(accessibleLabel)) throw new TypeError(`sign-in button: accessibleLabel \"${accessibleLabel}\" must say \"orangecheck\"`);\n const busyLabel = options.busyLabel ?? SIGN_IN_BUSY_LABEL;\n if (typeof busyLabel !== 'string' || !busyLabel.trim()) throw new TypeError('sign-in button: busyLabel must be words');\n const mark = options.mark ?? 'mono';\n if (!MARKS.has(mark)) throw new TypeError(`sign-in button: unknown mark ${String(mark)}`);\n if (label === false && mark === false) throw new TypeError('sign-in button: with no label it needs the mark');\n const appearance = options.appearance ?? 'inherit';\n if (appearance !== 'inherit' && appearance !== 'brand') throw new TypeError(`sign-in button: unknown appearance ${String(appearance)}`);\n return { label, mark, busyLabel, accessibleLabel, appearance };\n}\n\n/**\n * Holds the button's width while its words change, so nothing beside it moves.\n * Set through the CSS object model, which no Content-Security-Policy blocks.\n */\nexport function holdWidth(button: HTMLElement): () => void {\n const { width: was, minWidth: wasMin } = button.style;\n const width = button.getBoundingClientRect().width;\n // The minimum too: shorter words would otherwise let a flex row shrink it.\n if (width > 0) button.style.width = button.style.minWidth = `${width}px`;\n return () => {\n button.style.width = was;\n button.style.minWidth = wasMin;\n };\n}\n\n/**\n * Make `button` an orangecheck sign-in button. Its classes and styles stay\n * yours; its content becomes the mark and the label. A `[data-oc-mark]`\n * already in the button (a placeholder `<span>`, sized by button.css exactly as\n * the mark is) is replaced by the mark, so the button's size does not change as\n * it is drawn; its value, if any, names the variant. With no\n * `label` given, words already in the button that say \"orangecheck\" are kept.\n * While the window is open it is `aria-disabled` and `aria-busy`, still\n * focusable, and holds its width. Returns a function that undoes it.\n */\nexport function enhanceSignInButton(button: HTMLButtonElement, options: EnhanceSignInButtonOptions): () => void {\n if (!button || button.tagName !== 'BUTTON') throw new TypeError('sign-in button: pass a <button> element');\n const doc = button.ownerDocument;\n const own = (button.querySelector('[data-oc-label]')?.textContent ?? button.textContent ?? '').trim();\n const iconOnly = options.label === false || (options.label === undefined && button.getAttribute('data-label') === 'none');\n const written = options.label === undefined && !iconOnly && NAMED.test(own) ? own : options.label;\n // A placeholder may name the variant: <span data-oc-mark=\"brand\"></span>.\n const hinted = button.querySelector('[data-oc-mark]')?.getAttribute('data-oc-mark');\n const variant = options.mark === undefined && hinted && MARKS.has(hinted) ? (hinted as MarkVariant) : options.mark;\n const checked = checkSignInOptions({ ...options, mark: variant, label: iconOnly ? false : written });\n const { label, mark, appearance, busyLabel, accessibleLabel } = checked;\n const before = {\n nodes: [...button.childNodes],\n type: button.getAttribute('type'),\n aria: button.getAttribute('aria-label'),\n dataLabel: button.getAttribute('data-label'),\n };\n\n if (!before.type) button.type = 'button';\n button.setAttribute('data-oc-sign-in', '');\n button.setAttribute('data-appearance', appearance);\n // Built node by node: no HTML is parsed, so Trusted Types and strict CSPs allow it.\n const markEl = mark ? markElement(doc, { variant: mark }) : null;\n const text = doc.createElement('span');\n text.setAttribute('data-oc-label', '');\n if (label === false) {\n button.setAttribute('data-label', 'none');\n button.setAttribute('aria-label', accessibleLabel);\n button.replaceChildren(markEl!);\n } else {\n text.textContent = label;\n button.replaceChildren(...(markEl ? [markEl] : []), text);\n }\n\n let busy = false;\n let release: (() => void) | null = null;\n const setBusy = (on: boolean) => {\n busy = on;\n if (on) {\n release = holdWidth(button);\n if (label !== false) text.textContent = busyLabel;\n button.setAttribute('aria-disabled', 'true');\n button.setAttribute('aria-busy', 'true');\n } else {\n if (label !== false) text.textContent = label;\n button.removeAttribute('aria-disabled');\n button.removeAttribute('aria-busy');\n release?.();\n release = null;\n }\n };\n\n const onClick = async (event: MouseEvent) => {\n event.preventDefault();\n if (busy || button.disabled) return;\n // Opened before anything is awaited: a window opened later is blocked.\n const pending = signInWithOcOutcome(options.popup);\n setBusy(true);\n try {\n const outcome = await pending;\n options.onOutcome?.(outcome);\n if (outcome.status === 'signed_in') await options.onSignedIn({ account: outcome.account, token: outcome.token });\n } finally {\n setBusy(false);\n }\n };\n button.addEventListener('click', onClick);\n\n return () => {\n button.removeEventListener('click', onClick);\n button.replaceChildren(...before.nodes);\n if (before.type === null) button.removeAttribute('type');\n for (const a of ['data-oc-sign-in', 'data-appearance', 'aria-disabled', 'aria-busy']) button.removeAttribute(a);\n if (before.aria === null) button.removeAttribute('aria-label');\n else button.setAttribute('aria-label', before.aria);\n if (before.dataLabel === null) button.removeAttribute('data-label');\n else button.setAttribute('data-label', before.dataLabel);\n };\n}\n","/**\n * React: `<SignInWithOrangecheck>`, a native `<button>` that keeps your site's\n * look (appearance `inherit`, the default) or wears orangecheck's (appearance\n * `brand`, themed by --oc-* custom properties in `@orangecheck/me-client/button.css`).\n * It carries the mark and the words, opens the popup inside the click, and\n * holds the busy state at the same width. `react` is an optional peer: no\n * other entry of this package loads it.\n *\n * @packageDocumentation\n */\n\nimport type { ButtonHTMLAttributes } from 'react';\n\nimport { OrangecheckMark } from '@orangecheck/mark/react';\nimport { useRef, useState } from 'react';\n\nimport { checkSignInOptions, holdWidth, type EnhanceSignInButtonOptions } from './button';\nimport { signInWithOcOutcome } from './popup';\n\nexport { OUTCOME_COPY, SIGN_IN_BUSY_LABEL, SIGN_IN_LABELS } from './button';\nexport type { EnhanceSignInButtonOptions, MarkVariant, OcPopupOutcome, OcPopupResult, SignInAppearance, SignInLabel } from './button';\n\nexport type SignInWithOrangecheckProps = EnhanceSignInButtonOptions &\n Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onClick' | 'children' | 'type'>;\n\n/** A \"Sign in with orangecheck\" button. Your className and style draw it; it brings the mark, the words and the popup. */\nexport function SignInWithOrangecheck({\n onSignedIn,\n onOutcome,\n mark,\n label,\n busyLabel,\n accessibleLabel,\n appearance,\n popup,\n disabled,\n ...rest\n}: SignInWithOrangecheckProps) {\n const options = checkSignInOptions({ onSignedIn, onOutcome, mark, label, busyLabel, accessibleLabel, appearance, popup });\n const [busy, setBusy] = useState(false);\n const ref = useRef<HTMLButtonElement>(null);\n\n async function onClick() {\n if (busy || disabled) return;\n // Opened before anything is awaited: a window opened later is blocked.\n const pending = signInWithOcOutcome(popup);\n const release = ref.current ? holdWidth(ref.current) : () => {};\n setBusy(true);\n try {\n const outcome = await pending;\n onOutcome?.(outcome);\n if (outcome.status === 'signed_in') await onSignedIn({ account: outcome.account, token: outcome.token });\n } finally {\n setBusy(false);\n release();\n }\n }\n\n const iconOnly = options.label === false;\n return (\n <button\n {...rest}\n ref={ref}\n type=\"button\"\n disabled={disabled}\n data-oc-sign-in=\"\"\n data-appearance={options.appearance}\n data-label={iconOnly ? 'none' : undefined}\n aria-label={iconOnly ? options.accessibleLabel : rest['aria-label']}\n aria-disabled={busy || undefined}\n aria-busy={busy || undefined}\n onClick={() => void onClick()}\n >\n {options.mark ? <OrangecheckMark variant={options.mark} /> : null}\n {iconOnly ? null : <span data-oc-label=\"\">{busy ? options.busyLabel : options.label}</span>}\n </button>\n );\n}\n"]}
package/dist/react.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { jsxs, jsx } from 'react/jsx-runtime';
2
- import { useState } from 'react';
2
+ import { useState, useRef } from 'react';
3
3
 
4
4
  // node_modules/@orangecheck/mark/dist/react.mjs
5
5
  var MARK_POINTS = {
@@ -9,7 +9,7 @@ var MARK_POINTS = {
9
9
  };
10
10
  var MARK_VIEWBOX = "0 0 16 8";
11
11
  var MARK_FACES = { top: "#FED8AB", left: "#FB933C", right: "#EA580B" };
12
- var MARK_MONO_OPACITY = { top: 1, left: 0.7, right: 0.45 };
12
+ var MARK_MONO_OPACITY = { top: 1, left: 0.6, right: 0.3 };
13
13
  var MARK_TILE = {
14
14
  viewBox: "0 0 24 24",
15
15
  radius: 6.25,
@@ -22,11 +22,11 @@ function half(size) {
22
22
  const m = /^(-?[\d.]+)([a-z%]*)$/i.exec(size.trim());
23
23
  return m ? `${Number(m[1]) / 2}${m[2]}` : "auto";
24
24
  }
25
- function OrangecheckMark({ variant = "mono", title, size, color = "currentColor", ...rest }) {
26
- const width = size ?? (variant === "tile" ? "1.25em" : "1.5em");
25
+ function OrangecheckMark({ variant = "mono", title, size, color = "currentColor", flat = false, ...rest }) {
26
+ const width = size ?? (variant === "tile" ? "1.25em" : "1.75em");
27
27
  const a11y = title ? { role: "img" } : { "aria-hidden": true, focusable: false };
28
28
  const polys = ORDER2.map(
29
- (face) => variant === "mono" ? /* @__PURE__ */ jsx("polygon", { points: MARK_POINTS[face], fill: color, fillOpacity: MARK_MONO_OPACITY[face] === 1 ? void 0 : MARK_MONO_OPACITY[face] }, face) : /* @__PURE__ */ jsx("polygon", { points: MARK_POINTS[face], fill: MARK_FACES[face] }, face)
29
+ (face) => variant === "mono" ? /* @__PURE__ */ jsx("polygon", { points: MARK_POINTS[face], fill: color, fillOpacity: flat || MARK_MONO_OPACITY[face] === 1 ? void 0 : MARK_MONO_OPACITY[face] }, face) : /* @__PURE__ */ jsx("polygon", { points: MARK_POINTS[face], fill: MARK_FACES[face] }, face)
30
30
  );
31
31
  if (variant === "tile") {
32
32
  return /* @__PURE__ */ jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: MARK_TILE.viewBox, width, height: width, "data-oc-mark": "tile", ...a11y, ...rest, children: [
@@ -118,49 +118,84 @@ var OUTCOME_COPY = {
118
118
  closed: "The sign-in window closed before you finished.",
119
119
  failed: "Sign-in didn't finish. Try again."
120
120
  };
121
- var LABELS = new Set(Object.values(SIGN_IN_LABELS));
122
121
  var MARKS = /* @__PURE__ */ new Set(["mono", "brand", "tile", false]);
123
- var KEYS = /* @__PURE__ */ new Set(["onSignedIn", "onOutcome", "mark", "label", "appearance", "popup"]);
122
+ var KEYS = /* @__PURE__ */ new Set(["onSignedIn", "onOutcome", "mark", "label", "busyLabel", "accessibleLabel", "appearance", "popup"]);
123
+ var NAMED = /(^|[^\p{L}\p{N}])orangecheck($|[^\p{L}\p{N}])/u;
124
124
  function checkSignInOptions(options) {
125
125
  for (const key of Object.keys(options)) if (!KEYS.has(key)) throw new TypeError(`sign-in button: unknown option ${key}`);
126
126
  if (typeof options.onSignedIn !== "function") throw new TypeError("sign-in button: onSignedIn is required");
127
127
  const label = options.label ?? SIGN_IN_LABELS.signIn;
128
- if (!LABELS.has(label)) throw new TypeError(`sign-in button: "${label}" is not an approved label; use one of SIGN_IN_LABELS`);
128
+ if (label !== false && (typeof label !== "string" || !NAMED.test(label))) {
129
+ throw new TypeError(`sign-in button: "${String(label)}" must say "orangecheck", lowercase, as written; see SIGN_IN_LABELS`);
130
+ }
131
+ const accessibleLabel = options.accessibleLabel ?? SIGN_IN_LABELS.signIn;
132
+ if (!NAMED.test(accessibleLabel)) throw new TypeError(`sign-in button: accessibleLabel "${accessibleLabel}" must say "orangecheck"`);
133
+ const busyLabel = options.busyLabel ?? SIGN_IN_BUSY_LABEL;
134
+ if (typeof busyLabel !== "string" || !busyLabel.trim()) throw new TypeError("sign-in button: busyLabel must be words");
129
135
  const mark = options.mark ?? "mono";
130
136
  if (!MARKS.has(mark)) throw new TypeError(`sign-in button: unknown mark ${String(mark)}`);
137
+ if (label === false && mark === false) throw new TypeError("sign-in button: with no label it needs the mark");
131
138
  const appearance = options.appearance ?? "inherit";
132
139
  if (appearance !== "inherit" && appearance !== "brand") throw new TypeError(`sign-in button: unknown appearance ${String(appearance)}`);
133
- return { label, mark, appearance };
140
+ return { label, mark, busyLabel, accessibleLabel, appearance };
141
+ }
142
+ function holdWidth(button) {
143
+ const { width: was, minWidth: wasMin } = button.style;
144
+ const width = button.getBoundingClientRect().width;
145
+ if (width > 0) button.style.width = button.style.minWidth = `${width}px`;
146
+ return () => {
147
+ button.style.width = was;
148
+ button.style.minWidth = wasMin;
149
+ };
134
150
  }
135
- function SignInWithOrangecheck({ onSignedIn, onOutcome, mark, label, appearance, popup, disabled, ...rest }) {
136
- const options = checkSignInOptions({ onSignedIn, onOutcome, mark, label, appearance, popup });
151
+ function SignInWithOrangecheck({
152
+ onSignedIn,
153
+ onOutcome,
154
+ mark,
155
+ label,
156
+ busyLabel,
157
+ accessibleLabel,
158
+ appearance,
159
+ popup,
160
+ disabled,
161
+ ...rest
162
+ }) {
163
+ const options = checkSignInOptions({ onSignedIn, onOutcome, mark, label, busyLabel, accessibleLabel, appearance, popup });
137
164
  const [busy, setBusy] = useState(false);
165
+ const ref = useRef(null);
138
166
  async function onClick() {
139
167
  if (busy || disabled) return;
140
- setBusy(true);
141
168
  const pending = signInWithOcOutcome(popup);
169
+ const release = ref.current ? holdWidth(ref.current) : () => {
170
+ };
171
+ setBusy(true);
142
172
  try {
143
173
  const outcome = await pending;
144
174
  onOutcome?.(outcome);
145
175
  if (outcome.status === "signed_in") await onSignedIn({ account: outcome.account, token: outcome.token });
146
176
  } finally {
147
177
  setBusy(false);
178
+ release();
148
179
  }
149
180
  }
181
+ const iconOnly = options.label === false;
150
182
  return /* @__PURE__ */ jsxs(
151
183
  "button",
152
184
  {
153
185
  ...rest,
186
+ ref,
154
187
  type: "button",
155
188
  disabled,
156
189
  "data-oc-sign-in": "",
157
190
  "data-appearance": options.appearance,
191
+ "data-label": iconOnly ? "none" : void 0,
192
+ "aria-label": iconOnly ? options.accessibleLabel : rest["aria-label"],
158
193
  "aria-disabled": busy || void 0,
159
194
  "aria-busy": busy || void 0,
160
195
  onClick: () => void onClick(),
161
196
  children: [
162
197
  options.mark ? /* @__PURE__ */ jsx(OrangecheckMark, { variant: options.mark }) : null,
163
- /* @__PURE__ */ jsx("span", { "data-oc-label": "", children: busy ? SIGN_IN_BUSY_LABEL : options.label })
198
+ iconOnly ? null : /* @__PURE__ */ jsx("span", { "data-oc-label": "", children: busy ? options.busyLabel : options.label })
164
199
  ]
165
200
  }
166
201
  );
@@ -1 +1 @@
1
- {"version":3,"sources":["../node_modules/@orangecheck/mark/src/index.ts","../node_modules/@orangecheck/mark/src/react.tsx","../src/popup.ts","../src/button.ts","../src/react.tsx"],"names":["ORDER","jsxs","jsx"],"mappings":";;;;AASO,IAAM,WAAA,GAAc;EACvB,GAAA,EAAK,2BAAA;EACL,IAAA,EAAM,iBAAA;EACN,KAAA,EAAO;AACX,CAAA;AAEO,IAAM,YAAA,GAAe,UAAA;AAGrB,IAAM,aAAa,EAAE,GAAA,EAAK,WAAW,IAAA,EAAM,SAAA,EAAW,OAAO,SAAA,EAAA;AAG7D,IAAM,oBAAoB,EAAE,GAAA,EAAK,GAAG,IAAA,EAAM,GAAA,EAAK,OAAO,IAAA,EAAA;AAGtD,IAAM,SAAA,GAAY;EACrB,OAAA,EAAS,WAAA;EACT,MAAA,EAAQ,IAAA;EACR,IAAA,EAAM,SAAA;EACN,SAAA,EAAW;AACf,CAAA;ACZA,IAAMA,MAAAA,GAAQ,CAAC,MAAA,EAAQ,OAAA,EAAS,KAAK,CAAA;AAErC,SAAS,KAAK,IAAA,EAAwC;AAClD,EAAA,IAAI,OAAO,IAAA,KAAS,QAAA,EAAU,OAAO,IAAA,GAAO,CAAA;AAC5C,EAAA,MAAM,CAAA,GAAI,wBAAA,CAAyB,IAAA,CAAK,IAAA,CAAK,MAAM,CAAA;AACnD,EAAA,OAAO,CAAA,GAAI,CAAA,EAAG,MAAA,CAAO,CAAA,CAAE,CAAC,CAAC,CAAA,GAAI,CAAC,CAAA,EAAG,CAAA,CAAE,CAAC,CAAC,CAAA,CAAA,GAAK,MAAA;AAC9C;AAGO,SAAS,eAAA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, three faces.\n *\n * Framework-free and dependency-free: SVG strings for any page, a data URI\n * for CSS and images, and the geometry for a renderer that draws its own.\n * The React component is in `@orangecheck/mark/react`.\n */\n\n/** The three faces as SVG points in the 16×8 box. */\nexport const MARK_POINTS = {\n top: '0,3 2,2 6,4 14,0 16,1 6,6',\n left: '0,3 6,6 6,8 0,5',\n right: '6,6 16,1 16,3 6,8',\n} as const;\n\nexport const MARK_VIEWBOX = '0 0 16 8';\n\n/** The faces as drawn. For dark grounds only: the top face is about 1.3:1 on white. */\nexport const MARK_FACES = { top: '#FED8AB', left: '#FB933C', right: '#EA580B' } as const;\n\n/** One colour, three weights: the check at full strength, the sides as depth. */\nexport const MARK_MONO_OPACITY = { top: 1, left: 0.7, right: 0.45 } as const;\n\n/** The tile: the faces on an ink square with rounded corners, 24×24. Reads on any ground. */\nexport const MARK_TILE = {\n viewBox: '0 0 24 24',\n radius: 6.25,\n fill: '#0A0A0A',\n transform: 'translate(4.25 8.1) scale(0.97)',\n} as const;\n\n/** Smallest width the bare mark may be drawn at, in CSS pixels (the tile: the same, square). */\nexport const MARK_MIN_PX = 16;\n\n/** `mono`: the host's text colour. `brand`: as drawn, on dark grounds. `tile`: the faces on their own ink tile. */\nexport type MarkVariant = 'mono' | 'brand' | 'tile';\n\nexport interface MarkSvgOptions {\n variant?: MarkVariant;\n /** An accessible name. Without one the mark is decoration, hidden from assistive technology. */\n title?: string;\n /** Width as a CSS length, `1.5em` by default (the tile `1.25em`); the height follows. Overridable from CSS. */\n width?: string;\n /** The mono colour. Default `currentColor`; a data URI needs a real colour, since an image inherits none. */\n color?: string;\n /** Added to the `<svg>` element. */\n className?: string;\n}\n\nconst ORDER = ['left', 'right', 'top'] as const;\n\nfunction escape(s: string): string {\n return s.replace(/[&<>\"']/g, (c) => `&#${c.charCodeAt(0)};`);\n}\n\nfunction faces(variant: MarkVariant, color: string): string {\n return ORDER.map((face) =>\n variant === 'mono'\n ? `<polygon points=\"${MARK_POINTS[face]}\" fill=\"${escape(color)}\"${MARK_MONO_OPACITY[face] === 1 ? '' : ` fill-opacity=\"${MARK_MONO_OPACITY[face]}\"`}/>`\n : `<polygon points=\"${MARK_POINTS[face]}\" fill=\"${MARK_FACES[face]}\"/>`\n ).join('');\n}\n\n/** The height that keeps a CSS length's aspect for the variant: half for the mark, equal for the tile. */\nfunction heightFor(variant: MarkVariant, width: string): string {\n if (variant === 'tile') return width;\n const m = /^(-?[\\d.]+)([a-z%]*)$/i.exec(width.trim());\n return m ? `${Number(m[1]) / 2}${m[2]}` : 'auto';\n}\n\n/**\n * The mark as an SVG string. Sized in em by default, so it follows the\n * font size of the text beside it; a stylesheet can still set its size,\n * since width and height are attributes, not inline styles (no CSP needed).\n */\nexport function markSvg(options: MarkSvgOptions = {}): string {\n const variant = options.variant ?? 'mono';\n if (variant !== 'mono' && variant !== 'brand' && variant !== 'tile') throw new TypeError(`markSvg: unknown variant ${String(variant)}`);\n const width = options.width ?? (variant === 'tile' ? '1.25em' : '1.5em');\n const color = options.color ?? 'currentColor';\n const label = options.title ? `<title>${escape(options.title)}</title>` : '';\n const a11y = options.title ? 'role=\"img\"' : 'aria-hidden=\"true\" focusable=\"false\"';\n const cls = options.className ? ` class=\"${escape(options.className)}\"` : '';\n const size = `width=\"${escape(width)}\" height=\"${escape(heightFor(variant, width))}\"`;\n if (variant === 'tile') {\n return (\n `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"${MARK_TILE.viewBox}\" ${size} ${a11y} data-oc-mark=\"tile\"${cls}>${label}` +\n `<rect width=\"24\" height=\"24\" rx=\"${MARK_TILE.radius}\" fill=\"${MARK_TILE.fill}\"/>` +\n `<g transform=\"${MARK_TILE.transform}\">${faces('brand', color)}</g></svg>`\n );\n }\n return `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"${MARK_VIEWBOX}\" ${size} ${a11y} data-oc-mark=\"${variant}\"${cls}>${label}${faces(variant, color)}</svg>`;\n}\n\n/** The mark as a `data:image/svg+xml` URI, for CSS backgrounds and `<img>`. Mono needs an explicit `color`. */\nexport function markDataUri(options: MarkSvgOptions = {}): string {\n if ((options.variant ?? 'mono') === 'mono' && (!options.color || options.color === 'currentColor')) {\n throw new TypeError('markDataUri: a mono mark in an image needs a colour; an image inherits none');\n }\n return `data:image/svg+xml,${encodeURIComponent(markSvg({ ...options, width: options.width ?? '16' }))}`;\n}\n\nconst SVG_NS = 'http://www.w3.org/2000/svg';\n\n/**\n * The mark as an `<svg>` element, built node by node: no HTML parsing, so\n * it works under Trusted Types and any Content-Security-Policy. Same\n * drawing and attributes as markSvg.\n */\nexport function markElement(doc: Document, options: Omit<MarkSvgOptions, 'className'> & { className?: string } = {}): SVGSVGElement {\n const variant = options.variant ?? 'mono';\n if (variant !== 'mono' && variant !== 'brand' && variant !== 'tile') throw new TypeError(`markElement: unknown variant ${String(variant)}`);\n const width = options.width ?? (variant === 'tile' ? '1.25em' : '1.5em');\n const color = options.color ?? 'currentColor';\n const el = <K extends keyof SVGElementTagNameMap>(tag: K, attrs: Record<string, string>) => {\n const node = doc.createElementNS(SVG_NS, tag);\n for (const [k, v] of Object.entries(attrs)) node.setAttribute(k, v);\n return node;\n };\n const svg = el('svg', {\n viewBox: variant === 'tile' ? MARK_TILE.viewBox : MARK_VIEWBOX,\n width,\n height: heightFor(variant, width),\n 'data-oc-mark': variant,\n });\n if (options.className) svg.setAttribute('class', options.className);\n if (options.title) {\n svg.setAttribute('role', 'img');\n const title = el('title', {});\n title.textContent = options.title;\n svg.append(title);\n } else {\n svg.setAttribute('aria-hidden', 'true');\n svg.setAttribute('focusable', 'false');\n }\n const parent = variant === 'tile' ? el('g', { transform: MARK_TILE.transform }) : svg;\n if (variant === 'tile') svg.append(el('rect', { width: '24', height: '24', rx: String(MARK_TILE.radius), fill: MARK_TILE.fill }), parent);\n for (const face of ORDER) {\n const attrs: Record<string, string> = { points: MARK_POINTS[face] };\n if (variant === 'mono') {\n attrs.fill = color;\n if (MARK_MONO_OPACITY[face] !== 1) attrs['fill-opacity'] = String(MARK_MONO_OPACITY[face]);\n } else attrs.fill = MARK_FACES[face];\n parent.append(el('polygon', attrs));\n }\n return svg;\n}\n","import type { SVGProps } from 'react';\n\nimport { MARK_FACES, MARK_MONO_OPACITY, MARK_POINTS, MARK_TILE, MARK_VIEWBOX, type MarkVariant } from './index';\n\nexport { MARK_FACES, MARK_MIN_PX, MARK_MONO_OPACITY, MARK_POINTS, MARK_TILE, MARK_VIEWBOX, markDataUri, markElement, markSvg } from './index';\nexport type { MarkSvgOptions, MarkVariant } from './index';\n\nexport interface OrangecheckMarkProps extends Omit<SVGProps<SVGSVGElement>, 'children' | 'width' | 'height'> {\n variant?: MarkVariant;\n /** An accessible name. Without one the mark is decoration, hidden from assistive technology. */\n title?: string;\n /** Width as a CSS length or px number, `1.5em` by default (the tile `1.25em`); the height follows. */\n size?: string | number;\n /** The mono colour, `currentColor` by default. */\n color?: string;\n}\n\nconst ORDER = ['left', 'right', 'top'] as const;\n\nfunction half(size: string | number): string | number {\n if (typeof size === 'number') return size / 2;\n const m = /^(-?[\\d.]+)([a-z%]*)$/i.exec(size.trim());\n return m ? `${Number(m[1]) / 2}${m[2]}` : 'auto';\n}\n\n/** The orangecheck mark. Mono takes the text colour; brand is for dark grounds; the tile reads anywhere. */\nexport function OrangecheckMark({ variant = 'mono', title, size, color = 'currentColor', ...rest }: OrangecheckMarkProps) {\n const width = size ?? (variant === 'tile' ? '1.25em' : '1.5em');\n const a11y = title ? { role: 'img' } : { 'aria-hidden': true, focusable: false };\n const polys = ORDER.map((face) =>\n variant === 'mono' ? (\n <polygon key={face} points={MARK_POINTS[face]} fill={color} fillOpacity={MARK_MONO_OPACITY[face] === 1 ? undefined : MARK_MONO_OPACITY[face]} />\n ) : (\n <polygon key={face} points={MARK_POINTS[face]} fill={MARK_FACES[face]} />\n )\n );\n if (variant === 'tile') {\n return (\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox={MARK_TILE.viewBox} width={width} height={width} data-oc-mark=\"tile\" {...a11y} {...rest}>\n {title ? <title>{title}</title> : null}\n <rect width=\"24\" height=\"24\" rx={MARK_TILE.radius} fill={MARK_TILE.fill} />\n <g transform={MARK_TILE.transform}>{polys}</g>\n </svg>\n );\n }\n return (\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox={MARK_VIEWBOX} width={width} height={half(width)} data-oc-mark={variant} {...a11y} {...rest}>\n {title ? <title>{title}</title> : null}\n {polys}\n </svg>\n );\n}\n","/**\n * Browser only: `signInWithOc` opens the orangecheck sign-in popup and resolves\n * with a token bound to your origin; `signInWithOcOutcome` says why when it\n * does not. Verify the token on your server with\n * [`@orangecheck/me-client/server`](/sdk/me-client/server/README).\n *\n * @packageDocumentation\n */\n\n/**\n * @orangecheck/me-client/popup\n *\n * Browser-side helper that opens the OC sign-in popup, listens for the\n * postMessage from me.ochk.io, and resolves with the verified session.\n *\n * import { signInWithOc } from '@orangecheck/me-client/popup';\n *\n * document.querySelector('#oc-signin')!.addEventListener('click', async () => {\n * const result = await signInWithOc();\n * if (!result) return;\n * // Your server verifies it and keeps it in an httpOnly cookie.\n * const r = await fetch('/api/auth/session', {\n * method: 'POST',\n * headers: { 'Content-Type': 'application/json' },\n * body: JSON.stringify({ token: result.token }),\n * });\n * if (r.ok) location.assign('/app');\n * });\n *\n * Why this lives in a separate entry point: it's browser-only (uses\n * window.open / addEventListener) and integrators that only need the\n * server-side verifier shouldn't pull popup orchestration into their\n * server bundle.\n */\n\nconst DEFAULT_POPUP_ORIGIN = 'https://me.ochk.io';\nconst DEFAULT_POPUP_PATH = '/popup/signin';\nconst DEFAULT_FEATURES = 'width=480,height=720,resizable=yes,scrollbars=yes';\n\nexport interface OcPopupAccount {\n id?: string;\n /** Opaque public identity · `did:oc:<32-hex>`. Stable across linking\n * events. The canonical identifier post auth-refactor (Dec 2025\n * +). */\n did_oc?: string;\n /** Primary linked Bitcoin address, if the user has one and is\n * surfacing it (same-origin family integrators get it inline;\n * cross-domain integrators need the bitcoin_address scope). */\n primary_btc?: string | null;\n /** Whether the user has a primary email linked (plaintext stays\n * on auth host; only the boolean reaches integrators). */\n has_email?: boolean;\n /** Legacy fields kept for back-compat with pre-refactor consumers.\n * Prefer did_oc + primary_btc. Removed in a future major. */\n address?: string;\n btc_address?: string;\n display_name?: string | null;\n nostr_npub?: string | null;\n wallet_provisioned?: boolean;\n email?: string;\n}\n\nexport interface OcPopupResult {\n /** Account payload from the auth host, unsigned: trust only the\n * verified token. `did_oc` is the account's opaque identifier, the\n * same at every site; the email and Bitcoin address stay private\n * unless the user grants a scope. */\n account: OcPopupAccount;\n /** The session JWT, bound to your origin. Hand it once to your own\n * server, which verifies it and keeps it in an httpOnly cookie; never\n * in localStorage, where any script on the page can read it. Family\n * sites (*.ochk.io) can ignore it: the Domain=.ochk.io cookie rides\n * home on its own. */\n token: string;\n}\n\nexport interface SignInWithOcOptions {\n /** Origin of the OC popup page. Defaults to https://me.ochk.io.\n * Override only for staging / preview environments. */\n popupOrigin?: string;\n /** Path on the popup origin. Defaults to /popup/signin. */\n popupPath?: string;\n /** window.open features string. Defaults to a 480x720 resizable\n * popup with scrollbars. */\n features?: string;\n /** AbortSignal that cancels the wait and closes the popup. */\n signal?: AbortSignal;\n}\n\n/**\n * How a sign-in popup ended:\n * - `signed_in` · the person signed in; `account` and `token` as from signInWithOc.\n * - `blocked` · the browser refused to open the window. Ask the person to\n * allow pop-ups for your site, then try again from a click.\n * - `closed` · the person closed the window without signing in.\n * - `aborted` · your AbortSignal fired.\n * - `failed` · not in a browser, or the popup's answer was malformed.\n */\nexport type OcPopupOutcome =\n | ({ status: 'signed_in' } & OcPopupResult)\n | { status: 'blocked' }\n | { status: 'closed' }\n | { status: 'aborted' }\n | { status: 'failed' };\n\n/**\n * Open the OC signin popup and resolve with how it ended (OcPopupOutcome),\n * so a blocked window and a closed one can be told apart.\n *\n * MUST be called inside a user-gesture handler (e.g. a button onClick).\n * Browsers block `window.open` outside of user gestures.\n */\nexport function signInWithOcOutcome(options: SignInWithOcOptions = {}): Promise<OcPopupOutcome> {\n const popupOrigin = options.popupOrigin ?? DEFAULT_POPUP_ORIGIN;\n const popupPath = options.popupPath ?? DEFAULT_POPUP_PATH;\n const features = options.features ?? DEFAULT_FEATURES;\n\n return new Promise((resolve) => {\n if (typeof window === 'undefined') {\n resolve({ status: 'failed' });\n return;\n }\n\n const url = new URL(popupPath, popupOrigin);\n url.searchParams.set('opener_origin', window.location.origin);\n const popup = window.open(url.toString(), 'oc-signin', features);\n if (!popup) {\n resolve({ status: 'blocked' });\n return;\n }\n popup.focus();\n\n let settled = false;\n const cleanup = () => {\n window.removeEventListener('message', onMessage);\n clearInterval(closedTimer);\n if (options.signal) options.signal.removeEventListener('abort', onAbort);\n };\n\n function settle(value: OcPopupOutcome) {\n if (settled) return;\n settled = true;\n cleanup();\n try {\n if (popup && !popup.closed) popup.close();\n } catch {\n /* popup may have closed itself first */\n }\n resolve(value);\n }\n\n function onMessage(event: MessageEvent) {\n // Origin pinning is necessary but not sufficient — same-origin\n // pages other than our popup can post the same shape. Pin both\n // origin AND source window so only the popup we opened can\n // settle this promise.\n if (event.origin !== popupOrigin) return;\n if (event.source !== popup) return;\n const data = event.data as\n | { type?: string; account?: OcPopupAccount; token?: string }\n | null;\n if (!data || data.type !== 'oc-signin-success') return;\n if (!data.account || !data.token) {\n settle({ status: 'failed' });\n return;\n }\n settle({ status: 'signed_in', account: data.account, token: data.token });\n }\n\n function onAbort() {\n settle({ status: 'aborted' });\n }\n\n window.addEventListener('message', onMessage);\n if (options.signal) {\n if (options.signal.aborted) {\n settle({ status: 'aborted' });\n return;\n }\n options.signal.addEventListener('abort', onAbort);\n }\n\n // Detect the person closing the popup without completing signin.\n const closedTimer = setInterval(() => {\n if (popup && popup.closed) settle({ status: 'closed' });\n }, 500);\n });\n}\n\n/**\n * Open the OC signin popup and resolve with the session result. Returns\n * `null` if the user closed the popup without completing signin, if the\n * browser blocked it, or if the AbortSignal fired. To tell those apart,\n * use signInWithOcOutcome.\n *\n * MUST be called inside a user-gesture handler (e.g. a button onClick).\n * Browsers block `window.open` outside of user gestures.\n */\nexport async function signInWithOc(options: SignInWithOcOptions = {}): Promise<OcPopupResult | null> {\n const outcome = await signInWithOcOutcome(options);\n return outcome.status === 'signed_in' ? { account: outcome.account, token: outcome.token } : null;\n}\n","/**\n * Browser only, no framework: a \"Sign in with orangecheck\" button that keeps\n * your site's own look. Write your button as you write every other one, add\n * `data-oc-sign-in`, and enhance it: this adds the orangecheck mark and the\n * label, opens the sign-in popup inside the click, holds the busy state, and\n * says how the popup ended. Optional stylesheet: `@orangecheck/me-client/button.css`.\n *\n * <button class=\"cta ghost\" data-oc-sign-in>Sign in with orangecheck</button>\n *\n * import { enhanceSignInButton } from '@orangecheck/me-client/button';\n * enhanceSignInButton(document.querySelector('[data-oc-sign-in]'), {\n * onSignedIn: async ({ token }) => { … },\n * });\n *\n * The file has no imports at run time (the mark and the popup are bundled\n * in), so it can be copied onto your own origin under a strict CSP.\n *\n * @packageDocumentation\n */\n\nimport { markElement, type MarkVariant } from '@orangecheck/mark';\n\nimport { signInWithOcOutcome, type OcPopupOutcome, type OcPopupResult, type SignInWithOcOptions } from './popup';\n\nexport type { MarkVariant } from '@orangecheck/mark';\nexport type { OcPopupOutcome, OcPopupResult, SignInWithOcOptions } from './popup';\n\n/** The labels a sign-in button may carry. \"orangecheck\" is always lowercase, never \"OC\". */\nexport const SIGN_IN_LABELS = {\n signIn: 'Sign in with orangecheck',\n continue: 'Continue with orangecheck',\n signUp: 'Sign up with orangecheck',\n} as const;\nexport type SignInLabel = (typeof SIGN_IN_LABELS)[keyof typeof SIGN_IN_LABELS];\n\n/** What the button says while the sign-in window is open. */\nexport const SIGN_IN_BUSY_LABEL = 'Signing in…';\n\n/** What to tell the person when the window did not end in a sign-in. Show it near the button. */\nexport const OUTCOME_COPY = {\n blocked: 'Your browser blocked the sign-in window. Allow pop-ups for this site, then try again.',\n closed: 'The sign-in window closed before you finished.',\n failed: \"Sign-in didn't finish. Try again.\",\n} as const;\n\n/** `inherit`: no colour, font or radius of its own; your classes draw it. `brand`: orangecheck's button, themed by --oc-* properties. */\nexport type SignInAppearance = 'inherit' | 'brand';\n\nexport interface EnhanceSignInButtonOptions {\n /** Called with the popup's account and token once the person signs in; the button stays busy until it settles. */\n onSignedIn: (result: OcPopupResult) => void | Promise<void>;\n /** Called with how every popup ended, sign-in included. Use OUTCOME_COPY for the words. */\n onOutcome?: (outcome: OcPopupOutcome) => void;\n /** The mark beside the label: `mono` (your text colour, the default), `brand` (dark buttons), `tile`, or `false` for none. */\n mark?: MarkVariant | false;\n /** One of SIGN_IN_LABELS. Default \"Sign in with orangecheck\". */\n label?: SignInLabel;\n appearance?: SignInAppearance;\n /** Passed to the popup (a preview origin, say). */\n popup?: Omit<SignInWithOcOptions, 'signal'>;\n}\n\nconst LABELS = new Set<string>(Object.values(SIGN_IN_LABELS));\nconst MARKS = new Set<unknown>(['mono', 'brand', 'tile', false]);\nconst KEYS = new Set(['onSignedIn', 'onOutcome', 'mark', 'label', 'appearance', 'popup']);\n\n/** The options, checked: a misspelt key or a label outside the approved set fails loudly, not quietly. */\nexport function checkSignInOptions(options: EnhanceSignInButtonOptions): Required<Pick<EnhanceSignInButtonOptions, 'mark' | 'label' | 'appearance'>> {\n for (const key of Object.keys(options)) if (!KEYS.has(key)) throw new TypeError(`sign-in button: unknown option ${key}`);\n if (typeof options.onSignedIn !== 'function') throw new TypeError('sign-in button: onSignedIn is required');\n const label = options.label ?? SIGN_IN_LABELS.signIn;\n if (!LABELS.has(label)) throw new TypeError(`sign-in button: \"${label}\" is not an approved label; use one of SIGN_IN_LABELS`);\n const mark = options.mark ?? 'mono';\n if (!MARKS.has(mark)) throw new TypeError(`sign-in button: unknown mark ${String(mark)}`);\n const appearance = options.appearance ?? 'inherit';\n if (appearance !== 'inherit' && appearance !== 'brand') throw new TypeError(`sign-in button: unknown appearance ${String(appearance)}`);\n return { label, mark, appearance };\n}\n\n/**\n * Make `button` an orangecheck sign-in button. Its classes and styles stay\n * yours; its content becomes the mark and the label. While the window is\n * open it is `aria-disabled` and `aria-busy`, and still focusable. Returns a\n * function that undoes it.\n */\nexport function enhanceSignInButton(button: HTMLButtonElement, options: EnhanceSignInButtonOptions): () => void {\n if (!button || button.tagName !== 'BUTTON') throw new TypeError('sign-in button: pass a <button> element');\n const { label, mark, appearance } = checkSignInOptions(options);\n const before = { nodes: [...button.childNodes], type: button.getAttribute('type') };\n const doc = button.ownerDocument;\n\n if (!before.type) button.type = 'button';\n button.setAttribute('data-oc-sign-in', '');\n button.setAttribute('data-appearance', appearance);\n // Built node by node: no HTML is parsed, so Trusted Types and strict CSPs allow it.\n const text = doc.createElement('span');\n text.setAttribute('data-oc-label', '');\n text.textContent = label;\n button.replaceChildren(...(mark ? [markElement(doc, { variant: mark })] : []), text);\n\n let busy = false;\n const setBusy = (on: boolean) => {\n busy = on;\n text.textContent = on ? SIGN_IN_BUSY_LABEL : label;\n if (on) {\n button.setAttribute('aria-disabled', 'true');\n button.setAttribute('aria-busy', 'true');\n } else {\n button.removeAttribute('aria-disabled');\n button.removeAttribute('aria-busy');\n }\n };\n\n const onClick = async (event: MouseEvent) => {\n event.preventDefault();\n if (busy || button.disabled) return;\n setBusy(true);\n // Opened before anything is awaited: a window opened later is blocked.\n const pending = signInWithOcOutcome(options.popup);\n try {\n const outcome = await pending;\n options.onOutcome?.(outcome);\n if (outcome.status === 'signed_in') await options.onSignedIn({ account: outcome.account, token: outcome.token });\n } finally {\n setBusy(false);\n }\n };\n button.addEventListener('click', onClick);\n\n return () => {\n button.removeEventListener('click', onClick);\n button.replaceChildren(...before.nodes);\n if (before.type === null) button.removeAttribute('type');\n for (const a of ['data-oc-sign-in', 'data-appearance', 'aria-disabled', 'aria-busy']) button.removeAttribute(a);\n };\n}\n","/**\n * React: `<SignInWithOrangecheck>`, a native `<button>` that keeps your site's\n * look (appearance `inherit`, the default) or wears orangecheck's (appearance\n * `brand`, themed by --oc-* custom properties in `@orangecheck/me-client/button.css`).\n * It carries the mark and an approved label, opens the popup inside the\n * click, and holds the busy state. `react` is an optional peer: no other\n * entry of this package loads it.\n *\n * @packageDocumentation\n */\n\nimport type { ButtonHTMLAttributes } from 'react';\n\nimport { OrangecheckMark } from '@orangecheck/mark/react';\nimport { useState } from 'react';\n\nimport { checkSignInOptions, SIGN_IN_BUSY_LABEL, type EnhanceSignInButtonOptions } from './button';\nimport { signInWithOcOutcome } from './popup';\n\nexport { OUTCOME_COPY, SIGN_IN_BUSY_LABEL, SIGN_IN_LABELS } from './button';\nexport type { EnhanceSignInButtonOptions, MarkVariant, OcPopupOutcome, OcPopupResult, SignInAppearance, SignInLabel } from './button';\n\nexport type SignInWithOrangecheckProps = EnhanceSignInButtonOptions &\n Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onClick' | 'children' | 'type'>;\n\n/** A \"Sign in with orangecheck\" button. Your className and style draw it; it brings the mark, the words and the popup. */\nexport function SignInWithOrangecheck({ onSignedIn, onOutcome, mark, label, appearance, popup, disabled, ...rest }: SignInWithOrangecheckProps) {\n const options = checkSignInOptions({ onSignedIn, onOutcome, mark, label, appearance, popup });\n const [busy, setBusy] = useState(false);\n\n async function onClick() {\n if (busy || disabled) return;\n setBusy(true);\n // Opened before anything is awaited: a window opened later is blocked.\n const pending = signInWithOcOutcome(popup);\n try {\n const outcome = await pending;\n onOutcome?.(outcome);\n if (outcome.status === 'signed_in') await onSignedIn({ account: outcome.account, token: outcome.token });\n } finally {\n setBusy(false);\n }\n }\n\n return (\n <button\n {...rest}\n type=\"button\"\n disabled={disabled}\n data-oc-sign-in=\"\"\n data-appearance={options.appearance}\n aria-disabled={busy || undefined}\n aria-busy={busy || undefined}\n onClick={() => void onClick()}\n >\n {options.mark ? <OrangecheckMark variant={options.mark} /> : null}\n <span data-oc-label=\"\">{busy ? SIGN_IN_BUSY_LABEL : options.label}</span>\n </button>\n );\n}\n"]}
1
+ {"version":3,"sources":["../node_modules/@orangecheck/mark/src/index.ts","../node_modules/@orangecheck/mark/src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,GAAY,OAAA,CAAQ,KAAA,EAAM;AAAA;AAAA;AAAA,GACxF;AAER","file":"react.mjs","sourcesContent":["/**\n * The orangecheck mark: an isometric check on a 16×8 grid, three faces.\n *\n * Framework-free and dependency-free: SVG strings for any page, a data URI\n * for CSS and images, and the geometry for a renderer that draws its own.\n * The React component is in `@orangecheck/mark/react`.\n */\n\n/** The three faces as SVG points in the 16×8 box. */\nexport const MARK_POINTS = {\n top: '0,3 2,2 6,4 14,0 16,1 6,6',\n left: '0,3 6,6 6,8 0,5',\n right: '6,6 16,1 16,3 6,8',\n} as const;\n\nexport const MARK_VIEWBOX = '0 0 16 8';\n\n/** The faces as drawn. For dark grounds only: the top face is about 1.3:1 on white. */\nexport const MARK_FACES = { top: '#FED8AB', left: '#FB933C', right: '#EA580B' } as const;\n\n/**\n * One colour, three weights: the check at full strength, the sides as depth.\n * Chosen for the widest smallest step between neighbouring faces and the\n * ground across light, dark and mid-tone (amber, brown) buttons.\n */\nexport const MARK_MONO_OPACITY = { top: 1, left: 0.6, right: 0.3 } as const;\n\n/** The tile: the faces on an ink square with rounded corners, 24×24. Reads on any ground. */\nexport const MARK_TILE = {\n viewBox: '0 0 24 24',\n radius: 6.25,\n fill: '#0A0A0A',\n transform: 'translate(4.25 8.1) scale(0.97)',\n} as const;\n\n/** Smallest width the bare mark may be drawn at, in CSS pixels (the tile: the same, square). */\nexport const MARK_MIN_PX = 16;\n\n/** `mono`: the host's text colour. `brand`: as drawn, on dark grounds. `tile`: the faces on their own ink tile. */\nexport type MarkVariant = 'mono' | 'brand' | 'tile';\n\nexport interface MarkSvgOptions {\n variant?: MarkVariant;\n /** An accessible name. Without one the mark is decoration, hidden from assistive technology. */\n title?: string;\n /** Width as a CSS length, `1.75em` by default (the tile `1.25em`); the height follows. Overridable from CSS. */\n width?: string;\n /** Mono only: every face at full strength, one flat shape. For forced colours and anything that cannot shade. */\n flat?: boolean;\n /** The mono colour. Default `currentColor`; a data URI needs a real colour, since an image inherits none. */\n color?: string;\n /** Added to the `<svg>` element. */\n className?: string;\n}\n\nconst ORDER = ['left', 'right', 'top'] as const;\n\nfunction escape(s: string): string {\n return s.replace(/[&<>\"']/g, (c) => `&#${c.charCodeAt(0)};`);\n}\n\n/** A face's opacity in mono: stepped, or full for a flat mark. */\nfunction opacity(face: (typeof ORDER)[number], flat: boolean): number {\n return flat ? 1 : MARK_MONO_OPACITY[face];\n}\n\nfunction faces(variant: MarkVariant, color: string, flat = false): string {\n return ORDER.map((face) =>\n variant === 'mono'\n ? `<polygon points=\"${MARK_POINTS[face]}\" fill=\"${escape(color)}\"${opacity(face, flat) === 1 ? '' : ` fill-opacity=\"${opacity(face, flat)}\"`}/>`\n : `<polygon points=\"${MARK_POINTS[face]}\" fill=\"${MARK_FACES[face]}\"/>`\n ).join('');\n}\n\n/** The height that keeps a CSS length's aspect for the variant: half for the mark, equal for the tile. */\nfunction heightFor(variant: MarkVariant, width: string): string {\n if (variant === 'tile') return width;\n const m = /^(-?[\\d.]+)([a-z%]*)$/i.exec(width.trim());\n return m ? `${Number(m[1]) / 2}${m[2]}` : 'auto';\n}\n\n/**\n * The mark as an SVG string. Sized in em by default, so it follows the\n * font size of the text beside it; a stylesheet can still set its size,\n * since width and height are attributes, not inline styles (no CSP needed).\n */\nexport function markSvg(options: MarkSvgOptions = {}): string {\n const variant = options.variant ?? 'mono';\n if (variant !== 'mono' && variant !== 'brand' && variant !== 'tile') throw new TypeError(`markSvg: unknown variant ${String(variant)}`);\n const width = options.width ?? (variant === 'tile' ? '1.25em' : '1.75em');\n const color = options.color ?? 'currentColor';\n const label = options.title ? `<title>${escape(options.title)}</title>` : '';\n const a11y = options.title ? 'role=\"img\"' : 'aria-hidden=\"true\" focusable=\"false\"';\n const cls = options.className ? ` class=\"${escape(options.className)}\"` : '';\n const size = `width=\"${escape(width)}\" height=\"${escape(heightFor(variant, width))}\"`;\n if (variant === 'tile') {\n return (\n `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"${MARK_TILE.viewBox}\" ${size} ${a11y} data-oc-mark=\"tile\"${cls}>${label}` +\n `<rect width=\"24\" height=\"24\" rx=\"${MARK_TILE.radius}\" fill=\"${MARK_TILE.fill}\"/>` +\n `<g transform=\"${MARK_TILE.transform}\">${faces('brand', color)}</g></svg>`\n );\n }\n return `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"${MARK_VIEWBOX}\" ${size} ${a11y} data-oc-mark=\"${variant}\"${cls}>${label}${faces(variant, color, options.flat)}</svg>`;\n}\n\n/** The mark as a `data:image/svg+xml` URI, for CSS backgrounds and `<img>`. Mono needs an explicit `color`. */\nexport function markDataUri(options: MarkSvgOptions = {}): string {\n if ((options.variant ?? 'mono') === 'mono' && (!options.color || options.color === 'currentColor')) {\n throw new TypeError('markDataUri: a mono mark in an image needs a colour; an image inherits none');\n }\n return `data:image/svg+xml,${encodeURIComponent(markSvg({ ...options, width: options.width ?? '16' }))}`;\n}\n\nconst SVG_NS = 'http://www.w3.org/2000/svg';\n\n/**\n * The mark as an `<svg>` element, built node by node: no HTML parsing, so\n * it works under Trusted Types and any Content-Security-Policy. Same\n * drawing and attributes as markSvg.\n */\nexport function markElement(doc: Document, options: Omit<MarkSvgOptions, 'className'> & { className?: string } = {}): SVGSVGElement {\n const variant = options.variant ?? 'mono';\n if (variant !== 'mono' && variant !== 'brand' && variant !== 'tile') throw new TypeError(`markElement: unknown variant ${String(variant)}`);\n const width = options.width ?? (variant === 'tile' ? '1.25em' : '1.75em');\n const color = options.color ?? 'currentColor';\n const el = <K extends keyof SVGElementTagNameMap>(tag: K, attrs: Record<string, string>) => {\n const node = doc.createElementNS(SVG_NS, tag);\n for (const [k, v] of Object.entries(attrs)) node.setAttribute(k, v);\n return node;\n };\n const svg = el('svg', {\n viewBox: variant === 'tile' ? MARK_TILE.viewBox : MARK_VIEWBOX,\n width,\n height: heightFor(variant, width),\n 'data-oc-mark': variant,\n });\n if (options.className) svg.setAttribute('class', options.className);\n if (options.title) {\n svg.setAttribute('role', 'img');\n const title = el('title', {});\n title.textContent = options.title;\n svg.append(title);\n } else {\n svg.setAttribute('aria-hidden', 'true');\n svg.setAttribute('focusable', 'false');\n }\n const parent = variant === 'tile' ? el('g', { transform: MARK_TILE.transform }) : svg;\n if (variant === 'tile') svg.append(el('rect', { width: '24', height: '24', rx: String(MARK_TILE.radius), fill: MARK_TILE.fill }), parent);\n for (const face of ORDER) {\n const attrs: Record<string, string> = { points: MARK_POINTS[face] };\n if (variant === 'mono') {\n attrs.fill = color;\n if (opacity(face, !!options.flat) !== 1) attrs['fill-opacity'] = String(opacity(face, !!options.flat));\n } else attrs.fill = MARK_FACES[face];\n parent.append(el('polygon', attrs));\n }\n return svg;\n}\n","import type { SVGProps } from 'react';\n\nimport { MARK_FACES, MARK_MONO_OPACITY, MARK_POINTS, MARK_TILE, MARK_VIEWBOX, type MarkVariant } from './index';\n\nexport { MARK_FACES, MARK_MIN_PX, MARK_MONO_OPACITY, MARK_POINTS, MARK_TILE, MARK_VIEWBOX, markDataUri, markElement, markSvg } from './index';\nexport type { MarkSvgOptions, MarkVariant } from './index';\n\nexport interface OrangecheckMarkProps extends Omit<SVGProps<SVGSVGElement>, 'children' | 'width' | 'height'> {\n variant?: MarkVariant;\n /** An accessible name. Without one the mark is decoration, hidden from assistive technology. */\n title?: string;\n /** Width as a CSS length or px number, `1.75em` by default (the tile `1.25em`); the height follows. */\n size?: string | number;\n /** Mono only: every face at full strength, one flat shape (forced colours). */\n flat?: boolean;\n /** The mono colour, `currentColor` by default. */\n color?: string;\n}\n\nconst ORDER = ['left', 'right', 'top'] as const;\n\nfunction half(size: string | number): string | number {\n if (typeof size === 'number') return size / 2;\n const m = /^(-?[\\d.]+)([a-z%]*)$/i.exec(size.trim());\n return m ? `${Number(m[1]) / 2}${m[2]}` : 'auto';\n}\n\n/** The orangecheck mark. Mono takes the text colour; brand is for dark grounds; the tile reads anywhere. */\nexport function OrangecheckMark({ variant = 'mono', title, size, color = 'currentColor', flat = false, ...rest }: OrangecheckMarkProps) {\n const width = size ?? (variant === 'tile' ? '1.25em' : '1.75em');\n const a11y = title ? { role: 'img' } : { 'aria-hidden': true, focusable: false };\n const polys = ORDER.map((face) =>\n variant === 'mono' ? (\n <polygon key={face} points={MARK_POINTS[face]} fill={color} fillOpacity={flat || MARK_MONO_OPACITY[face] === 1 ? undefined : MARK_MONO_OPACITY[face]} />\n ) : (\n <polygon key={face} points={MARK_POINTS[face]} fill={MARK_FACES[face]} />\n )\n );\n if (variant === 'tile') {\n return (\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox={MARK_TILE.viewBox} width={width} height={width} data-oc-mark=\"tile\" {...a11y} {...rest}>\n {title ? <title>{title}</title> : null}\n <rect width=\"24\" height=\"24\" rx={MARK_TILE.radius} fill={MARK_TILE.fill} />\n <g transform={MARK_TILE.transform}>{polys}</g>\n </svg>\n );\n }\n return (\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox={MARK_VIEWBOX} width={width} height={half(width)} data-oc-mark={variant} {...a11y} {...rest}>\n {title ? <title>{title}</title> : null}\n {polys}\n </svg>\n );\n}\n","/**\n * Browser only: `signInWithOc` opens the orangecheck sign-in popup and resolves\n * with a token bound to your origin; `signInWithOcOutcome` says why when it\n * does not. Verify the token on your server with\n * [`@orangecheck/me-client/server`](/sdk/me-client/server/README).\n *\n * @packageDocumentation\n */\n\n/**\n * @orangecheck/me-client/popup\n *\n * Browser-side helper that opens the OC sign-in popup, listens for the\n * postMessage from me.ochk.io, and resolves with the verified session.\n *\n * import { signInWithOc } from '@orangecheck/me-client/popup';\n *\n * document.querySelector('#oc-signin')!.addEventListener('click', async () => {\n * const result = await signInWithOc();\n * if (!result) return;\n * // Your server verifies it and keeps it in an httpOnly cookie.\n * const r = await fetch('/api/auth/session', {\n * method: 'POST',\n * headers: { 'Content-Type': 'application/json' },\n * body: JSON.stringify({ token: result.token }),\n * });\n * if (r.ok) location.assign('/app');\n * });\n *\n * Why this lives in a separate entry point: it's browser-only (uses\n * window.open / addEventListener) and integrators that only need the\n * server-side verifier shouldn't pull popup orchestration into their\n * server bundle.\n */\n\nconst DEFAULT_POPUP_ORIGIN = 'https://me.ochk.io';\nconst DEFAULT_POPUP_PATH = '/popup/signin';\nconst DEFAULT_FEATURES = 'width=480,height=720,resizable=yes,scrollbars=yes';\n\nexport interface OcPopupAccount {\n id?: string;\n /** Opaque public identity · `did:oc:<32-hex>`. Stable across linking\n * events. The canonical identifier post auth-refactor (Dec 2025\n * +). */\n did_oc?: string;\n /** Primary linked Bitcoin address, if the user has one and is\n * surfacing it (same-origin family integrators get it inline;\n * cross-domain integrators need the bitcoin_address scope). */\n primary_btc?: string | null;\n /** Whether the user has a primary email linked (plaintext stays\n * on auth host; only the boolean reaches integrators). */\n has_email?: boolean;\n /** Legacy fields kept for back-compat with pre-refactor consumers.\n * Prefer did_oc + primary_btc. Removed in a future major. */\n address?: string;\n btc_address?: string;\n display_name?: string | null;\n nostr_npub?: string | null;\n wallet_provisioned?: boolean;\n email?: string;\n}\n\nexport interface OcPopupResult {\n /** Account payload from the auth host, unsigned: trust only the\n * verified token. `did_oc` is the account's opaque identifier, the\n * same at every site; the email and Bitcoin address stay private\n * unless the user grants a scope. */\n account: OcPopupAccount;\n /** The session JWT, bound to your origin. Hand it once to your own\n * server, which verifies it and keeps it in an httpOnly cookie; never\n * in localStorage, where any script on the page can read it. Family\n * sites (*.ochk.io) can ignore it: the Domain=.ochk.io cookie rides\n * home on its own. */\n token: string;\n}\n\nexport interface SignInWithOcOptions {\n /** Origin of the OC popup page. Defaults to https://me.ochk.io.\n * Override only for staging / preview environments. */\n popupOrigin?: string;\n /** Path on the popup origin. Defaults to /popup/signin. */\n popupPath?: string;\n /** window.open features string. Defaults to a 480x720 resizable\n * popup with scrollbars. */\n features?: string;\n /** AbortSignal that cancels the wait and closes the popup. */\n signal?: AbortSignal;\n}\n\n/**\n * How a sign-in popup ended:\n * - `signed_in` · the person signed in; `account` and `token` as from signInWithOc.\n * - `blocked` · the browser refused to open the window. Ask the person to\n * allow pop-ups for your site, then try again from a click.\n * - `closed` · the person closed the window without signing in.\n * - `aborted` · your AbortSignal fired.\n * - `failed` · not in a browser, or the popup's answer was malformed.\n */\nexport type OcPopupOutcome =\n | ({ status: 'signed_in' } & OcPopupResult)\n | { status: 'blocked' }\n | { status: 'closed' }\n | { status: 'aborted' }\n | { status: 'failed' };\n\n/**\n * Open the OC signin popup and resolve with how it ended (OcPopupOutcome),\n * so a blocked window and a closed one can be told apart.\n *\n * MUST be called inside a user-gesture handler (e.g. a button onClick).\n * Browsers block `window.open` outside of user gestures.\n */\nexport function signInWithOcOutcome(options: SignInWithOcOptions = {}): Promise<OcPopupOutcome> {\n const popupOrigin = options.popupOrigin ?? DEFAULT_POPUP_ORIGIN;\n const popupPath = options.popupPath ?? DEFAULT_POPUP_PATH;\n const features = options.features ?? DEFAULT_FEATURES;\n\n return new Promise((resolve) => {\n if (typeof window === 'undefined') {\n resolve({ status: 'failed' });\n return;\n }\n\n const url = new URL(popupPath, popupOrigin);\n url.searchParams.set('opener_origin', window.location.origin);\n const popup = window.open(url.toString(), 'oc-signin', features);\n if (!popup) {\n resolve({ status: 'blocked' });\n return;\n }\n popup.focus();\n\n let settled = false;\n const cleanup = () => {\n window.removeEventListener('message', onMessage);\n clearInterval(closedTimer);\n if (options.signal) options.signal.removeEventListener('abort', onAbort);\n };\n\n function settle(value: OcPopupOutcome) {\n if (settled) return;\n settled = true;\n cleanup();\n try {\n if (popup && !popup.closed) popup.close();\n } catch {\n /* popup may have closed itself first */\n }\n resolve(value);\n }\n\n function onMessage(event: MessageEvent) {\n // Origin pinning is necessary but not sufficient — same-origin\n // pages other than our popup can post the same shape. Pin both\n // origin AND source window so only the popup we opened can\n // settle this promise.\n if (event.origin !== popupOrigin) return;\n if (event.source !== popup) return;\n const data = event.data as\n | { type?: string; account?: OcPopupAccount; token?: string }\n | null;\n if (!data || data.type !== 'oc-signin-success') return;\n if (!data.account || !data.token) {\n settle({ status: 'failed' });\n return;\n }\n settle({ status: 'signed_in', account: data.account, token: data.token });\n }\n\n function onAbort() {\n settle({ status: 'aborted' });\n }\n\n window.addEventListener('message', onMessage);\n if (options.signal) {\n if (options.signal.aborted) {\n settle({ status: 'aborted' });\n return;\n }\n options.signal.addEventListener('abort', onAbort);\n }\n\n // Detect the person closing the popup without completing signin.\n const closedTimer = setInterval(() => {\n if (popup && popup.closed) settle({ status: 'closed' });\n }, 500);\n });\n}\n\n/**\n * Open the OC signin popup and resolve with the session result. Returns\n * `null` if the user closed the popup without completing signin, if the\n * browser blocked it, or if the AbortSignal fired. To tell those apart,\n * use signInWithOcOutcome.\n *\n * MUST be called inside a user-gesture handler (e.g. a button onClick).\n * Browsers block `window.open` outside of user gestures.\n */\nexport async function signInWithOc(options: SignInWithOcOptions = {}): Promise<OcPopupResult | null> {\n const outcome = await signInWithOcOutcome(options);\n return outcome.status === 'signed_in' ? { account: outcome.account, token: outcome.token } : null;\n}\n","/**\n * Browser only, no framework: a \"Sign in with orangecheck\" button that keeps\n * your site's own look. Write your button as you write every other one, add\n * `data-oc-sign-in`, and enhance it: this adds the orangecheck mark and the\n * label, opens the sign-in popup inside the click, holds the busy state, and\n * says how the popup ended. Optional stylesheet: `@orangecheck/me-client/button.css`.\n *\n * <button class=\"cta ghost\" data-oc-sign-in>Sign in with orangecheck</button>\n *\n * import { enhanceSignInButton } from '@orangecheck/me-client/button';\n * enhanceSignInButton(document.querySelector('[data-oc-sign-in]'), {\n * onSignedIn: async ({ token }) => { … },\n * });\n *\n * The file has no imports at run time (the mark and the popup are bundled\n * in), so it can be copied onto your own origin under a strict CSP.\n *\n * @packageDocumentation\n */\n\nimport { markElement, type MarkVariant } from '@orangecheck/mark';\n\nimport { signInWithOcOutcome, type OcPopupOutcome, type OcPopupResult, type SignInWithOcOptions } from './popup';\n\nexport type { MarkVariant } from '@orangecheck/mark';\nexport type { OcPopupOutcome, OcPopupResult, SignInWithOcOptions } from './popup';\n\n/**\n * The approved English labels. A label in another language is fine too, as\n * long as it keeps the word \"orangecheck\", lowercase, as written.\n */\nexport const SIGN_IN_LABELS = {\n signIn: 'Sign in with orangecheck',\n continue: 'Continue with orangecheck',\n signUp: 'Sign up with orangecheck',\n} as const;\nexport type SignInLabel = string;\n\n/** What the button says while the sign-in window is open (the default; `busyLabel` sets your own). */\nexport const SIGN_IN_BUSY_LABEL = 'Signing in…';\n\n/** What to tell the person when the window did not end in a sign-in. Show it near the button. */\nexport const OUTCOME_COPY = {\n blocked: 'Your browser blocked the sign-in window. Allow pop-ups for this site, then try again.',\n closed: 'The sign-in window closed before you finished.',\n failed: \"Sign-in didn't finish. Try again.\",\n} as const;\n\n/** `inherit`: no colour, font or radius of its own; your classes draw it. `brand`: orangecheck's button, themed by --oc-* properties. */\nexport type SignInAppearance = 'inherit' | 'brand';\n\nexport interface EnhanceSignInButtonOptions {\n /** Called with the popup's account and token once the person signs in; the button stays busy until it settles. */\n onSignedIn: (result: OcPopupResult) => void | Promise<void>;\n /** Called with how every popup ended, sign-in included. Use OUTCOME_COPY for the words. */\n onOutcome?: (outcome: OcPopupOutcome) => void;\n /** The mark beside the label: `mono` (your text colour, the default), `brand` (dark buttons), `tile`, or `false` for none. */\n mark?: MarkVariant | false;\n /**\n * The words: one of SIGN_IN_LABELS (default \"Sign in with orangecheck\"), or\n * the same in your language, keeping \"orangecheck\" as written. `false` draws\n * the mark alone, square, named by `accessibleLabel`.\n */\n label?: SignInLabel | false;\n /** What it says while the window is open. Default \"Signing in…\". */\n busyLabel?: string;\n /** The accessible name of a mark-only button (`label: false`). Default \"Sign in with orangecheck\". */\n accessibleLabel?: string;\n appearance?: SignInAppearance;\n /** Passed to the popup (a preview origin, say). */\n popup?: Omit<SignInWithOcOptions, 'signal'>;\n}\n\nconst MARKS = new Set<unknown>(['mono', 'brand', 'tile', false]);\nconst KEYS = new Set(['onSignedIn', 'onOutcome', 'mark', 'label', 'busyLabel', 'accessibleLabel', 'appearance', 'popup']);\n/** The name, as written: lowercase, a word of its own. */\nconst NAMED = /(^|[^\\p{L}\\p{N}])orangecheck($|[^\\p{L}\\p{N}])/u;\n\nexport interface CheckedSignInOptions {\n mark: MarkVariant | false;\n label: string | false;\n busyLabel: string;\n accessibleLabel: string;\n appearance: SignInAppearance;\n}\n\n/** The options, checked: a misspelt key, or words without \"orangecheck\" in them, fail loudly, not quietly. */\nexport function checkSignInOptions(options: EnhanceSignInButtonOptions): CheckedSignInOptions {\n for (const key of Object.keys(options)) if (!KEYS.has(key)) throw new TypeError(`sign-in button: unknown option ${key}`);\n if (typeof options.onSignedIn !== 'function') throw new TypeError('sign-in button: onSignedIn is required');\n const label = options.label ?? SIGN_IN_LABELS.signIn;\n if (label !== false && (typeof label !== 'string' || !NAMED.test(label))) {\n throw new TypeError(`sign-in button: \"${String(label)}\" must say \"orangecheck\", lowercase, as written; see SIGN_IN_LABELS`);\n }\n const accessibleLabel = options.accessibleLabel ?? SIGN_IN_LABELS.signIn;\n if (!NAMED.test(accessibleLabel)) throw new TypeError(`sign-in button: accessibleLabel \"${accessibleLabel}\" must say \"orangecheck\"`);\n const busyLabel = options.busyLabel ?? SIGN_IN_BUSY_LABEL;\n if (typeof busyLabel !== 'string' || !busyLabel.trim()) throw new TypeError('sign-in button: busyLabel must be words');\n const mark = options.mark ?? 'mono';\n if (!MARKS.has(mark)) throw new TypeError(`sign-in button: unknown mark ${String(mark)}`);\n if (label === false && mark === false) throw new TypeError('sign-in button: with no label it needs the mark');\n const appearance = options.appearance ?? 'inherit';\n if (appearance !== 'inherit' && appearance !== 'brand') throw new TypeError(`sign-in button: unknown appearance ${String(appearance)}`);\n return { label, mark, busyLabel, accessibleLabel, appearance };\n}\n\n/**\n * Holds the button's width while its words change, so nothing beside it moves.\n * Set through the CSS object model, which no Content-Security-Policy blocks.\n */\nexport function holdWidth(button: HTMLElement): () => void {\n const { width: was, minWidth: wasMin } = button.style;\n const width = button.getBoundingClientRect().width;\n // The minimum too: shorter words would otherwise let a flex row shrink it.\n if (width > 0) button.style.width = button.style.minWidth = `${width}px`;\n return () => {\n button.style.width = was;\n button.style.minWidth = wasMin;\n };\n}\n\n/**\n * Make `button` an orangecheck sign-in button. Its classes and styles stay\n * yours; its content becomes the mark and the label. A `[data-oc-mark]`\n * already in the button (a placeholder `<span>`, sized by button.css exactly as\n * the mark is) is replaced by the mark, so the button's size does not change as\n * it is drawn; its value, if any, names the variant. With no\n * `label` given, words already in the button that say \"orangecheck\" are kept.\n * While the window is open it is `aria-disabled` and `aria-busy`, still\n * focusable, and holds its width. Returns a function that undoes it.\n */\nexport function enhanceSignInButton(button: HTMLButtonElement, options: EnhanceSignInButtonOptions): () => void {\n if (!button || button.tagName !== 'BUTTON') throw new TypeError('sign-in button: pass a <button> element');\n const doc = button.ownerDocument;\n const own = (button.querySelector('[data-oc-label]')?.textContent ?? button.textContent ?? '').trim();\n const iconOnly = options.label === false || (options.label === undefined && button.getAttribute('data-label') === 'none');\n const written = options.label === undefined && !iconOnly && NAMED.test(own) ? own : options.label;\n // A placeholder may name the variant: <span data-oc-mark=\"brand\"></span>.\n const hinted = button.querySelector('[data-oc-mark]')?.getAttribute('data-oc-mark');\n const variant = options.mark === undefined && hinted && MARKS.has(hinted) ? (hinted as MarkVariant) : options.mark;\n const checked = checkSignInOptions({ ...options, mark: variant, label: iconOnly ? false : written });\n const { label, mark, appearance, busyLabel, accessibleLabel } = checked;\n const before = {\n nodes: [...button.childNodes],\n type: button.getAttribute('type'),\n aria: button.getAttribute('aria-label'),\n dataLabel: button.getAttribute('data-label'),\n };\n\n if (!before.type) button.type = 'button';\n button.setAttribute('data-oc-sign-in', '');\n button.setAttribute('data-appearance', appearance);\n // Built node by node: no HTML is parsed, so Trusted Types and strict CSPs allow it.\n const markEl = mark ? markElement(doc, { variant: mark }) : null;\n const text = doc.createElement('span');\n text.setAttribute('data-oc-label', '');\n if (label === false) {\n button.setAttribute('data-label', 'none');\n button.setAttribute('aria-label', accessibleLabel);\n button.replaceChildren(markEl!);\n } else {\n text.textContent = label;\n button.replaceChildren(...(markEl ? [markEl] : []), text);\n }\n\n let busy = false;\n let release: (() => void) | null = null;\n const setBusy = (on: boolean) => {\n busy = on;\n if (on) {\n release = holdWidth(button);\n if (label !== false) text.textContent = busyLabel;\n button.setAttribute('aria-disabled', 'true');\n button.setAttribute('aria-busy', 'true');\n } else {\n if (label !== false) text.textContent = label;\n button.removeAttribute('aria-disabled');\n button.removeAttribute('aria-busy');\n release?.();\n release = null;\n }\n };\n\n const onClick = async (event: MouseEvent) => {\n event.preventDefault();\n if (busy || button.disabled) return;\n // Opened before anything is awaited: a window opened later is blocked.\n const pending = signInWithOcOutcome(options.popup);\n setBusy(true);\n try {\n const outcome = await pending;\n options.onOutcome?.(outcome);\n if (outcome.status === 'signed_in') await options.onSignedIn({ account: outcome.account, token: outcome.token });\n } finally {\n setBusy(false);\n }\n };\n button.addEventListener('click', onClick);\n\n return () => {\n button.removeEventListener('click', onClick);\n button.replaceChildren(...before.nodes);\n if (before.type === null) button.removeAttribute('type');\n for (const a of ['data-oc-sign-in', 'data-appearance', 'aria-disabled', 'aria-busy']) button.removeAttribute(a);\n if (before.aria === null) button.removeAttribute('aria-label');\n else button.setAttribute('aria-label', before.aria);\n if (before.dataLabel === null) button.removeAttribute('data-label');\n else button.setAttribute('data-label', before.dataLabel);\n };\n}\n","/**\n * React: `<SignInWithOrangecheck>`, a native `<button>` that keeps your site's\n * look (appearance `inherit`, the default) or wears orangecheck's (appearance\n * `brand`, themed by --oc-* custom properties in `@orangecheck/me-client/button.css`).\n * It carries the mark and the words, opens the popup inside the click, and\n * holds the busy state at the same width. `react` is an optional peer: no\n * other entry of this package loads it.\n *\n * @packageDocumentation\n */\n\nimport type { ButtonHTMLAttributes } from 'react';\n\nimport { OrangecheckMark } from '@orangecheck/mark/react';\nimport { useRef, useState } from 'react';\n\nimport { checkSignInOptions, holdWidth, type EnhanceSignInButtonOptions } from './button';\nimport { signInWithOcOutcome } from './popup';\n\nexport { OUTCOME_COPY, SIGN_IN_BUSY_LABEL, SIGN_IN_LABELS } from './button';\nexport type { EnhanceSignInButtonOptions, MarkVariant, OcPopupOutcome, OcPopupResult, SignInAppearance, SignInLabel } from './button';\n\nexport type SignInWithOrangecheckProps = EnhanceSignInButtonOptions &\n Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onClick' | 'children' | 'type'>;\n\n/** A \"Sign in with orangecheck\" button. Your className and style draw it; it brings the mark, the words and the popup. */\nexport function SignInWithOrangecheck({\n onSignedIn,\n onOutcome,\n mark,\n label,\n busyLabel,\n accessibleLabel,\n appearance,\n popup,\n disabled,\n ...rest\n}: SignInWithOrangecheckProps) {\n const options = checkSignInOptions({ onSignedIn, onOutcome, mark, label, busyLabel, accessibleLabel, appearance, popup });\n const [busy, setBusy] = useState(false);\n const ref = useRef<HTMLButtonElement>(null);\n\n async function onClick() {\n if (busy || disabled) return;\n // Opened before anything is awaited: a window opened later is blocked.\n const pending = signInWithOcOutcome(popup);\n const release = ref.current ? holdWidth(ref.current) : () => {};\n setBusy(true);\n try {\n const outcome = await pending;\n onOutcome?.(outcome);\n if (outcome.status === 'signed_in') await onSignedIn({ account: outcome.account, token: outcome.token });\n } finally {\n setBusy(false);\n release();\n }\n }\n\n const iconOnly = options.label === false;\n return (\n <button\n {...rest}\n ref={ref}\n type=\"button\"\n disabled={disabled}\n data-oc-sign-in=\"\"\n data-appearance={options.appearance}\n data-label={iconOnly ? 'none' : undefined}\n aria-label={iconOnly ? options.accessibleLabel : rest['aria-label']}\n aria-disabled={busy || undefined}\n aria-busy={busy || undefined}\n onClick={() => void onClick()}\n >\n {options.mark ? <OrangecheckMark variant={options.mark} /> : null}\n {iconOnly ? null : <span data-oc-label=\"\">{busy ? options.busyLabel : options.label}</span>}\n </button>\n );\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orangecheck/me-client",
3
- "version": "0.46.0",
3
+ "version": "0.47.0",
4
4
  "description": "Server and browser client for orangecheck sign-in and paying your users: withOcAuth for Next.js, ocAuthExpress and ocAuthHono (no env vars, no JWK handling), signInWithOc() popup, events, webhooks and the price taxonomy. No React.",
5
5
  "keywords": [
6
6
  "orangecheck",
@@ -97,7 +97,7 @@
97
97
  },
98
98
  "devDependencies": {
99
99
  "@orangecheck/auth-client": "^2.6.0",
100
- "@orangecheck/mark": "^0.1.0",
100
+ "@orangecheck/mark": "^0.2.0",
101
101
  "@testing-library/react": "^16.3.2",
102
102
  "@types/node": "^22.0.0",
103
103
  "@types/react": "^18.3.12",