@orangecheck/me-client 0.58.0 → 0.60.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/CHANGELOG.md +42 -0
- package/README.md +3 -1
- package/dist/button-auto.js +12 -0
- package/dist/button-auto.js.map +1 -1
- package/dist/button-auto.mjs +12 -0
- package/dist/button-auto.mjs.map +1 -1
- package/dist/button.js +12 -0
- package/dist/button.js.map +1 -1
- package/dist/button.mjs +12 -0
- package/dist/button.mjs.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +0 -1
- package/dist/index.mjs.map +1 -1
- package/dist/integrator.js.map +1 -1
- package/dist/integrator.mjs.map +1 -1
- package/dist/popup.js +12 -0
- package/dist/popup.js.map +1 -1
- package/dist/popup.mjs +12 -0
- package/dist/popup.mjs.map +1 -1
- package/dist/react.js +12 -0
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +12 -0
- package/dist/react.mjs.map +1 -1
- package/dist/server.js.map +1 -1
- package/dist/server.mjs.map +1 -1
- package/package.json +1 -1
package/dist/button-auto.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../node_modules/@orangecheck/mark/src/index.ts","../src/own-options.ts","../src/popup.ts","../src/button.ts","../src/button-auto.ts"],"names":[],"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;AAO7D,IAAM,oBAAoB,EAAE,GAAA,EAAK,GAAG,IAAA,EAAM,GAAA,EAAK,OAAO,GAAA,EAAA;AAGtD,IAAM,SAAA,GAAY;EACrB,OAAA,EAAS,WAAA;EACT,MAAA,EAAQ,IAAA;EACR,IAAA,EA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ark: 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","/** The known keys `opts` holds only through its prototype, which a reader would take as the caller's. */\nexport function inheritedKeys(opts: object, known: Iterable<string>): string[] {\n return [...known].filter((k) => k in opts && !Object.prototype.hasOwnProperty.call(opts, k));\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\nimport { inheritedKeys } from './own-options';\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\n/** The account the sign-in popup hands your page, the same on every way of\n * signing in: who signed in, and nothing more. An email or a Bitcoin address\n * is never in it; your server reads those through the API, with a scope the\n * person grants and proves again. */\nexport interface OcPopupAccount {\n /** The account's id at me.ochk.io. */\n id: string;\n /** Opaque public identity, `did:oc:<32-hex>`: the same at every site and\n * stable across linking. */\n did_oc: string;\n display_name: string | null;\n nostr_npub: string | null;\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. */\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\nconst POPUP_OPTIONS: ReadonlySet<string> = new Set<keyof SignInWithOcOptions>(['popupOrigin', 'popupPath', 'features', 'signal']);\n\n/** Throw on a mistake in the call: the popup's origin decides whose answer is trusted, so it must be the caller's own. */\nfunction checkPopupOptions(options: SignInWithOcOptions): void {\n if (options === null || typeof options !== 'object') {\n throw new TypeError('@orangecheck/me-client: signInWithOc: options must be an object');\n }\n const unknown = Object.keys(options).filter((k) => !POPUP_OPTIONS.has(k));\n if (unknown.length > 0) {\n throw new TypeError(\n `@orangecheck/me-client: signInWithOc: unknown option ${unknown.join(', ')}. ` +\n `It reads only ${[...POPUP_OPTIONS].join(', ')}.`\n );\n }\n const inherited = inheritedKeys(options, POPUP_OPTIONS);\n if (inherited.length > 0) {\n throw new TypeError(\n `@orangecheck/me-client: signInWithOc: option ${inherited.join(', ')} is inherited, not set by the caller`\n );\n }\n}\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 checkPopupOptions(options);\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 { inheritedKeys } from './own-options';\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 for (const key of inheritedKeys(options, KEYS)) throw new TypeError(`sign-in button: option ${key} is inherited, not set by the caller`);\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 * Browser only, for a page that loads the sign-in button by a tag: it\n * enhances every `button[data-oc-sign-in]` when it runs and reports through\n * DOM events, so it can come from a CDN with Subresource Integrity, which\n * covers a `<script src>` but no `import` in an inline script.\n *\n * <button class=\"your-button\" data-oc-sign-in><span data-oc-mark></span>Sign in with orangecheck</button>\n * <script type=\"module\" src=\"https://cdn.jsdelivr.net/npm/@orangecheck/me-client@0.48.0/dist/button-auto.mjs\"\n * integrity=\"sha384-…\" crossorigin=\"anonymous\"></script>\n * <script>\n * document.addEventListener('oc-signed-in', (e) => e.detail.waitUntil(keepSession(e.detail.token)));\n * document.addEventListener('oc-sign-in-outcome', (e) => { note.textContent = e.detail.message; });\n * </script>\n *\n * Both events are dispatched on the button and bubble. Any script on the page\n * can fire them too, and a CustomEvent is never trusted: send only the token\n * to your server and never trust `account` from the event in the browser.\n * Your server's check (withOcAuth, checkOcToken) is the only answer.\n *\n * The button says what it should: its own words (they must say \"orangecheck\"),\n * and `data-mark` (mono, brand, tile, none), `data-appearance` (inherit,\n * brand), `data-busy-label`, `data-accessible-label`, `data-label=\"none\"`.\n *\n * @packageDocumentation\n */\n\nimport { enhanceSignInButton, OUTCOME_COPY, type EnhanceSignInButtonOptions, type OcPopupOutcome, type OcPopupResult } from './button';\n\nexport type { OcPopupOutcome, OcPopupResult } from './button';\n\n/** `oc-signed-in`: the popup's account and token. The button stays busy until every `waitUntil` promise settles. */\nexport interface OcSignedInDetail extends OcPopupResult {\n waitUntil(work: Promise<unknown>): void;\n}\n\n/** `oc-sign-in-outcome`: how the window ended, and what to tell the person (empty when there is nothing to say). */\nexport interface OcSignInOutcomeDetail {\n status: OcPopupOutcome['status'];\n message: string;\n}\n\nconst done = new WeakSet<Element>();\n\nfunction optionsOf(button: HTMLButtonElement): EnhanceSignInButtonOptions {\n const data = button.dataset;\n const options: EnhanceSignInButtonOptions = {\n onSignedIn: async ({ account, token }) => {\n const work: Promise<unknown>[] = [];\n const detail: OcSignedInDetail = { account, token, waitUntil: (p) => void work.push(Promise.resolve(p)) };\n button.dispatchEvent(new CustomEvent('oc-signed-in', { bubbles: true, detail }));\n await Promise.all(work);\n },\n onOutcome: (outcome) => {\n const message = outcome.status in OUTCOME_COPY ? OUTCOME_COPY[outcome.status as keyof typeof OUTCOME_COPY] : '';\n const detail: OcSignInOutcomeDetail = { status: outcome.status, message };\n button.dispatchEvent(new CustomEvent('oc-sign-in-outcome', { bubbles: true, detail }));\n },\n };\n if (data.mark !== undefined) options.mark = data.mark === 'none' ? false : (data.mark as EnhanceSignInButtonOptions['mark']);\n if (data.appearance !== undefined) options.appearance = data.appearance as EnhanceSignInButtonOptions['appearance'];\n if (data.busyLabel !== undefined) options.busyLabel = data.busyLabel;\n if (data.accessibleLabel !== undefined) options.accessibleLabel = data.accessibleLabel;\n return options;\n}\n\n/** Enhance every sign-in button under `root` not already enhanced. A button it cannot enhance is reported and skipped. */\nexport function enhanceAll(root: ParentNode = document): number {\n let count = 0;\n for (const button of root.querySelectorAll<HTMLButtonElement>('button[data-oc-sign-in]')) {\n if (done.has(button)) continue;\n try {\n enhanceSignInButton(button, optionsOf(button));\n done.add(button);\n count++;\n } catch (err) {\n console.error(err);\n }\n }\n return count;\n}\n\nif (typeof document !== 'undefined') {\n if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', () => enhanceAll(), { once: true });\n else enhanceAll();\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../node_modules/@orangecheck/mark/src/index.ts","../src/own-options.ts","../src/popup.ts","../src/button.ts","../src/button-auto.ts"],"names":[],"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;AAO7D,IAAM,oBAAoB,EAAE,GAAA,EAAK,GAAG,IAAA,EAAM,GAAA,EAAK,OAAO,GAAA,EAAA;AAGtD,IAAM,SAAA,GAAY;EACrB,OAAA,EAAS,WAAA;EACT,MAAA,EAAQ,IAAA;EACR,IAAA,EAAM,SAAA;EACN,SAAA,EAAW;AACf,CAAA;AAsBA,IAAM,KAAA,GAAQ,CAAC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,IACJ,SAAS,GAAA,EAAK;AACV,MAAA,OAAA,CAAQ,MAAM,GAAG,CAAA;AAAA,IACrB;AAAA,EACJ;AACA,EAAA,OAAO,KAAA;AACX;AAEA,IAAI,OAAO,aAAa,WAAA,EAAa;AACjC,EAAA,IAAI,QAAA,CAAS,UAAA,KAAe,SAAA,EAAW,QAAA,CAAS,gBAAA,CAAiB,kBAAA,EAAoB,MAAM,UAAA,EAAW,EAAG,EAAE,IAAA,EAAM,IAAA,EAAM,CAAA;AAAA,OAClH,UAAA,EAAW;AACpB","file":"button-auto.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","/** The known keys `opts` holds only through its prototype, which a reader would take as the caller's. */\nexport function inheritedKeys(opts: object, known: Iterable<string>): string[] {\n return [...known].filter((k) => k in opts && !Object.prototype.hasOwnProperty.call(opts, k));\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\nimport { inheritedKeys } from './own-options';\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/** The popup's challenge nonce: base64url, 16 to 128 characters. */\nconst CHALLENGE_NONCE = /^[A-Za-z0-9_-]{16,128}$/;\n\n/** The account the sign-in popup hands your page, the same on every way of\n * signing in: who signed in, and nothing more. An email or a Bitcoin address\n * is never in it; your server reads those through the API, with a scope the\n * person grants and proves again. */\nexport interface OcPopupAccount {\n /** The account's id at me.ochk.io. */\n id: string;\n /** Opaque public identity, `did:oc:<32-hex>`: the same at every site and\n * stable across linking. */\n did_oc: string;\n /** The name the person set, only for one of orangecheck's own sites (the\n * family origins @orangecheck/auth-core lists). Always null for any other\n * site: the popup never tells it a name. */\n display_name: string | null;\n /** The person's Nostr npub, for a family site only, like `display_name`. */\n nostr_npub: string | null;\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. */\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\nconst POPUP_OPTIONS: ReadonlySet<string> = new Set<keyof SignInWithOcOptions>(['popupOrigin', 'popupPath', 'features', 'signal']);\n\n/** Throw on a mistake in the call: the popup's origin decides whose answer is trusted, so it must be the caller's own. */\nfunction checkPopupOptions(options: SignInWithOcOptions): void {\n if (options === null || typeof options !== 'object') {\n throw new TypeError('@orangecheck/me-client: signInWithOc: options must be an object');\n }\n const unknown = Object.keys(options).filter((k) => !POPUP_OPTIONS.has(k));\n if (unknown.length > 0) {\n throw new TypeError(\n `@orangecheck/me-client: signInWithOc: unknown option ${unknown.join(', ')}. ` +\n `It reads only ${[...POPUP_OPTIONS].join(', ')}.`\n );\n }\n const inherited = inheritedKeys(options, POPUP_OPTIONS);\n if (inherited.length > 0) {\n throw new TypeError(\n `@orangecheck/me-client: signInWithOc: option ${inherited.join(', ')} is inherited, not set by the caller`\n );\n }\n}\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 checkPopupOptions(options);\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; nonce?: unknown }\n | null;\n if (data?.type === 'oc-signin-challenge') {\n answerChallenge(data.nonce);\n return;\n }\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 // The popup proves its opener is this page before it signs anything: only this page\n // receives the nonce it posts to opener_origin, so sending it back is the proof.\n function answerChallenge(nonce: unknown) {\n if (typeof nonce !== 'string' || !CHALLENGE_NONCE.test(nonce)) return;\n try {\n popup?.postMessage({ type: 'oc-signin-echo', nonce }, popupOrigin);\n } catch {\n /* the popup closed first */\n }\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 { inheritedKeys } from './own-options';\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 for (const key of inheritedKeys(options, KEYS)) throw new TypeError(`sign-in button: option ${key} is inherited, not set by the caller`);\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 * Browser only, for a page that loads the sign-in button by a tag: it\n * enhances every `button[data-oc-sign-in]` when it runs and reports through\n * DOM events, so it can come from a CDN with Subresource Integrity, which\n * covers a `<script src>` but no `import` in an inline script.\n *\n * <button class=\"your-button\" data-oc-sign-in><span data-oc-mark></span>Sign in with orangecheck</button>\n * <script type=\"module\" src=\"https://cdn.jsdelivr.net/npm/@orangecheck/me-client@0.48.0/dist/button-auto.mjs\"\n * integrity=\"sha384-…\" crossorigin=\"anonymous\"></script>\n * <script>\n * document.addEventListener('oc-signed-in', (e) => e.detail.waitUntil(keepSession(e.detail.token)));\n * document.addEventListener('oc-sign-in-outcome', (e) => { note.textContent = e.detail.message; });\n * </script>\n *\n * Both events are dispatched on the button and bubble. Any script on the page\n * can fire them too, and a CustomEvent is never trusted: send only the token\n * to your server and never trust `account` from the event in the browser.\n * Your server's check (withOcAuth, checkOcToken) is the only answer.\n *\n * The button says what it should: its own words (they must say \"orangecheck\"),\n * and `data-mark` (mono, brand, tile, none), `data-appearance` (inherit,\n * brand), `data-busy-label`, `data-accessible-label`, `data-label=\"none\"`.\n *\n * @packageDocumentation\n */\n\nimport { enhanceSignInButton, OUTCOME_COPY, type EnhanceSignInButtonOptions, type OcPopupOutcome, type OcPopupResult } from './button';\n\nexport type { OcPopupOutcome, OcPopupResult } from './button';\n\n/** `oc-signed-in`: the popup's account and token. The button stays busy until every `waitUntil` promise settles. */\nexport interface OcSignedInDetail extends OcPopupResult {\n waitUntil(work: Promise<unknown>): void;\n}\n\n/** `oc-sign-in-outcome`: how the window ended, and what to tell the person (empty when there is nothing to say). */\nexport interface OcSignInOutcomeDetail {\n status: OcPopupOutcome['status'];\n message: string;\n}\n\nconst done = new WeakSet<Element>();\n\nfunction optionsOf(button: HTMLButtonElement): EnhanceSignInButtonOptions {\n const data = button.dataset;\n const options: EnhanceSignInButtonOptions = {\n onSignedIn: async ({ account, token }) => {\n const work: Promise<unknown>[] = [];\n const detail: OcSignedInDetail = { account, token, waitUntil: (p) => void work.push(Promise.resolve(p)) };\n button.dispatchEvent(new CustomEvent('oc-signed-in', { bubbles: true, detail }));\n await Promise.all(work);\n },\n onOutcome: (outcome) => {\n const message = outcome.status in OUTCOME_COPY ? OUTCOME_COPY[outcome.status as keyof typeof OUTCOME_COPY] : '';\n const detail: OcSignInOutcomeDetail = { status: outcome.status, message };\n button.dispatchEvent(new CustomEvent('oc-sign-in-outcome', { bubbles: true, detail }));\n },\n };\n if (data.mark !== undefined) options.mark = data.mark === 'none' ? false : (data.mark as EnhanceSignInButtonOptions['mark']);\n if (data.appearance !== undefined) options.appearance = data.appearance as EnhanceSignInButtonOptions['appearance'];\n if (data.busyLabel !== undefined) options.busyLabel = data.busyLabel;\n if (data.accessibleLabel !== undefined) options.accessibleLabel = data.accessibleLabel;\n return options;\n}\n\n/** Enhance every sign-in button under `root` not already enhanced. A button it cannot enhance is reported and skipped. */\nexport function enhanceAll(root: ParentNode = document): number {\n let count = 0;\n for (const button of root.querySelectorAll<HTMLButtonElement>('button[data-oc-sign-in]')) {\n if (done.has(button)) continue;\n try {\n enhanceSignInButton(button, optionsOf(button));\n done.add(button);\n count++;\n } catch (err) {\n console.error(err);\n }\n }\n return count;\n}\n\nif (typeof document !== 'undefined') {\n if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', () => enhanceAll(), { once: true });\n else enhanceAll();\n}\n"]}
|
package/dist/button.js
CHANGED
|
@@ -73,6 +73,7 @@ function inheritedKeys(opts, known) {
|
|
|
73
73
|
var DEFAULT_POPUP_ORIGIN = "https://me.ochk.io";
|
|
74
74
|
var DEFAULT_POPUP_PATH = "/popup/signin";
|
|
75
75
|
var DEFAULT_FEATURES = "width=480,height=720,resizable=yes,scrollbars=yes";
|
|
76
|
+
var CHALLENGE_NONCE = /^[A-Za-z0-9_-]{16,128}$/;
|
|
76
77
|
var POPUP_OPTIONS = /* @__PURE__ */ new Set(["popupOrigin", "popupPath", "features", "signal"]);
|
|
77
78
|
function checkPopupOptions(options) {
|
|
78
79
|
if (options === null || typeof options !== "object") {
|
|
@@ -129,6 +130,10 @@ function signInWithOcOutcome(options = {}) {
|
|
|
129
130
|
if (event.origin !== popupOrigin) return;
|
|
130
131
|
if (event.source !== popup) return;
|
|
131
132
|
const data = event.data;
|
|
133
|
+
if (data?.type === "oc-signin-challenge") {
|
|
134
|
+
answerChallenge(data.nonce);
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
132
137
|
if (!data || data.type !== "oc-signin-success") return;
|
|
133
138
|
if (!data.account || !data.token) {
|
|
134
139
|
settle({ status: "failed" });
|
|
@@ -136,6 +141,13 @@ function signInWithOcOutcome(options = {}) {
|
|
|
136
141
|
}
|
|
137
142
|
settle({ status: "signed_in", account: data.account, token: data.token });
|
|
138
143
|
}
|
|
144
|
+
function answerChallenge(nonce) {
|
|
145
|
+
if (typeof nonce !== "string" || !CHALLENGE_NONCE.test(nonce)) return;
|
|
146
|
+
try {
|
|
147
|
+
popup?.postMessage({ type: "oc-signin-echo", nonce }, popupOrigin);
|
|
148
|
+
} catch {
|
|
149
|
+
}
|
|
150
|
+
}
|
|
139
151
|
function onAbort() {
|
|
140
152
|
settle({ status: "aborted" });
|
|
141
153
|
}
|
package/dist/button.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../node_modules/@orangecheck/mark/src/index.ts","../src/own-options.ts","../src/popup.ts","../src/button.ts"],"names":[],"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;AAO7D,IAAM,oBAAoB,EAAE,GAAA,EAAK,GAAG,IAAA,EAAM,GAAA,EAAK,OAAO,GAAA,EAAA;AAGtD,IAAM,SAAA,GAAY;EACrB,OAAA,EAAS,WAAA;EACT,MAAA,EAAQ,IAAA;EACR,IAAA,EAAM,SAAA;EACN,SAAA,EAAW;AACf,CAAA;AAsBA,IAAM,KAAA,GAAQ,CAAC,MAAA,EAAQ,OAAA,EAAS,KAAK,CAAA;AAOrC,SAAS,OAAA,CAAQ,MAA8B,IAAA,EAAuB;AAClE,EAAA,OAAO,IAAA,GAAO,CAAA,GAAI,iBAAA,CAAkB,IAAI,CAAA;AAC5C;AAWA,SAAS,SAAA,CAAU,SAAsB,KAAA,EAAuB;AAC5D,EAAA,IAAI,OAAA,KAAY,QAAQ,OAAO,KAAA;AAC/B,EAAA,MAAM,CAAA,GAAI,wBAAA,CAAyB,IAAA,CAAK,KAAA,CAAM,MAAM,CAAA;AACpD,EAAA,OAAO,CAAA,GAAI,CAAA,EAAG,MAAA,CAAO,CAAA,CAAE,CAAC,CAAC,CAAA,GAAI,CAAC,CAAA,EAAG,CAAA,CAAE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AAC3B,MAAA,IAAI,OAAA,CAAQ,MAAA,KAAW,WAAA,EAAa,MAAM,OAAA,CAAQ,UAAA,CAAW,EAAE,OAAA,EAAS,OAAA,CAAQ,OAAA,EAAS,KAAA,EAAO,OAAA,CAAQ,OAAO,CAAA;AAAA,IACnH,CAAA,SAAE;AACE,MAAA,OAAA,CAAQ,KAAK,CAAA;AAAA,IACjB;AAAA,EACJ,CAAA;AACA,EAAA,MAAA,CAAO,gBAAA,CAAiB,SAAS,OAAO,CAAA;AAExC,EAAA,OAAO,MAAM;AACT,IAAA,MAAA,CAAO,mBAAA,CAAoB,SAAS,OAAO,CAAA;AAC3C,IAAA,MAAA,CAAO,eAAA,CAAgB,GAAG,MAAA,CAAO,KAAK,CAAA;AACtC,IAAA,IAAI,MAAA,CAAO,IAAA,KAAS,IAAA,EAAM,MAAA,CAAO,gBAAgB,MAAM,CAAA;AACvD,IAAA,KAAA,MAAW,CAAA,IAAK,CAAC,iBAAA,EAAmB,iBAAA,EAAmB,iBAAiB,WAAW,CAAA,EAAG,MAAA,CAAO,eAAA,CAAgB,CAAC,CAAA;AAC9G,IAAA,IAAI,MAAA,CAAO,IAAA,KAAS,IAAA,EAAM,MAAA,CAAO,gBAAgB,YAAY,CAAA;AAAA,SACxD,MAAA,CAAO,YAAA,CAAa,YAAA,EAAc,MAAA,CAAO,IAAI,CAAA;AAClD,IAAA,IAAI,MAAA,CAAO,SAAA,KAAc,IAAA,EAAM,MAAA,CAAO,gBAAgB,YAAY,CAAA;AAAA,SAC7D,MAAA,CAAO,YAAA,CAAa,YAAA,EAAc,MAAA,CAAO,SAAS,CAAA;AAAA,EAC3D,CAAA;AACJ","file":"button.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","/** The known keys `opts` holds only through its prototype, which a reader would take as the caller's. */\nexport function inheritedKeys(opts: object, known: Iterable<string>): string[] {\n return [...known].filter((k) => k in opts && !Object.prototype.hasOwnProperty.call(opts, k));\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\nimport { inheritedKeys } from './own-options';\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\n/** The account the sign-in popup hands your page, the same on every way of\n * signing in: who signed in, and nothing more. An email or a Bitcoin address\n * is never in it; your server reads those through the API, with a scope the\n * person grants and proves again. */\nexport interface OcPopupAccount {\n /** The account's id at me.ochk.io. */\n id: string;\n /** Opaque public identity, `did:oc:<32-hex>`: the same at every site and\n * stable across linking. */\n did_oc: string;\n display_name: string | null;\n nostr_npub: string | null;\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. */\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\nconst POPUP_OPTIONS: ReadonlySet<string> = new Set<keyof SignInWithOcOptions>(['popupOrigin', 'popupPath', 'features', 'signal']);\n\n/** Throw on a mistake in the call: the popup's origin decides whose answer is trusted, so it must be the caller's own. */\nfunction checkPopupOptions(options: SignInWithOcOptions): void {\n if (options === null || typeof options !== 'object') {\n throw new TypeError('@orangecheck/me-client: signInWithOc: options must be an object');\n }\n const unknown = Object.keys(options).filter((k) => !POPUP_OPTIONS.has(k));\n if (unknown.length > 0) {\n throw new TypeError(\n `@orangecheck/me-client: signInWithOc: unknown option ${unknown.join(', ')}. ` +\n `It reads only ${[...POPUP_OPTIONS].join(', ')}.`\n );\n }\n const inherited = inheritedKeys(options, POPUP_OPTIONS);\n if (inherited.length > 0) {\n throw new TypeError(\n `@orangecheck/me-client: signInWithOc: option ${inherited.join(', ')} is inherited, not set by the caller`\n );\n }\n}\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 checkPopupOptions(options);\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 { inheritedKeys } from './own-options';\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 for (const key of inheritedKeys(options, KEYS)) throw new TypeError(`sign-in button: option ${key} is inherited, not set by the caller`);\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"]}
|
|
1
|
+
{"version":3,"sources":["../node_modules/@orangecheck/mark/src/index.ts","../src/own-options.ts","../src/popup.ts","../src/button.ts"],"names":[],"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;AAO7D,IAAM,oBAAoB,EAAE,GAAA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,OAAA,EAAS,KAAA,EAAO,OAAA,CAAQ,OAAO,CAAA;AAAA,IACnH,CAAA,SAAE;AACE,MAAA,OAAA,CAAQ,KAAK,CAAA;AAAA,IACjB;AAAA,EACJ,CAAA;AACA,EAAA,MAAA,CAAO,gBAAA,CAAiB,SAAS,OAAO,CAAA;AAExC,EAAA,OAAO,MAAM;AACT,IAAA,MAAA,CAAO,mBAAA,CAAoB,SAAS,OAAO,CAAA;AAC3C,IAAA,MAAA,CAAO,eAAA,CAAgB,GAAG,MAAA,CAAO,KAAK,CAAA;AACtC,IAAA,IAAI,MAAA,CAAO,IAAA,KAAS,IAAA,EAAM,MAAA,CAAO,gBAAgB,MAAM,CAAA;AACvD,IAAA,KAAA,MAAW,CAAA,IAAK,CAAC,iBAAA,EAAmB,iBAAA,EAAmB,iBAAiB,WAAW,CAAA,EAAG,MAAA,CAAO,eAAA,CAAgB,CAAC,CAAA;AAC9G,IAAA,IAAI,MAAA,CAAO,IAAA,KAAS,IAAA,EAAM,MAAA,CAAO,gBAAgB,YAAY,CAAA;AAAA,SACxD,MAAA,CAAO,YAAA,CAAa,YAAA,EAAc,MAAA,CAAO,IAAI,CAAA;AAClD,IAAA,IAAI,MAAA,CAAO,SAAA,KAAc,IAAA,EAAM,MAAA,CAAO,gBAAgB,YAAY,CAAA;AAAA,SAC7D,MAAA,CAAO,YAAA,CAAa,YAAA,EAAc,MAAA,CAAO,SAAS,CAAA;AAAA,EAC3D,CAAA;AACJ","file":"button.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","/** The known keys `opts` holds only through its prototype, which a reader would take as the caller's. */\nexport function inheritedKeys(opts: object, known: Iterable<string>): string[] {\n return [...known].filter((k) => k in opts && !Object.prototype.hasOwnProperty.call(opts, k));\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\nimport { inheritedKeys } from './own-options';\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/** The popup's challenge nonce: base64url, 16 to 128 characters. */\nconst CHALLENGE_NONCE = /^[A-Za-z0-9_-]{16,128}$/;\n\n/** The account the sign-in popup hands your page, the same on every way of\n * signing in: who signed in, and nothing more. An email or a Bitcoin address\n * is never in it; your server reads those through the API, with a scope the\n * person grants and proves again. */\nexport interface OcPopupAccount {\n /** The account's id at me.ochk.io. */\n id: string;\n /** Opaque public identity, `did:oc:<32-hex>`: the same at every site and\n * stable across linking. */\n did_oc: string;\n /** The name the person set, only for one of orangecheck's own sites (the\n * family origins @orangecheck/auth-core lists). Always null for any other\n * site: the popup never tells it a name. */\n display_name: string | null;\n /** The person's Nostr npub, for a family site only, like `display_name`. */\n nostr_npub: string | null;\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. */\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\nconst POPUP_OPTIONS: ReadonlySet<string> = new Set<keyof SignInWithOcOptions>(['popupOrigin', 'popupPath', 'features', 'signal']);\n\n/** Throw on a mistake in the call: the popup's origin decides whose answer is trusted, so it must be the caller's own. */\nfunction checkPopupOptions(options: SignInWithOcOptions): void {\n if (options === null || typeof options !== 'object') {\n throw new TypeError('@orangecheck/me-client: signInWithOc: options must be an object');\n }\n const unknown = Object.keys(options).filter((k) => !POPUP_OPTIONS.has(k));\n if (unknown.length > 0) {\n throw new TypeError(\n `@orangecheck/me-client: signInWithOc: unknown option ${unknown.join(', ')}. ` +\n `It reads only ${[...POPUP_OPTIONS].join(', ')}.`\n );\n }\n const inherited = inheritedKeys(options, POPUP_OPTIONS);\n if (inherited.length > 0) {\n throw new TypeError(\n `@orangecheck/me-client: signInWithOc: option ${inherited.join(', ')} is inherited, not set by the caller`\n );\n }\n}\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 checkPopupOptions(options);\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; nonce?: unknown }\n | null;\n if (data?.type === 'oc-signin-challenge') {\n answerChallenge(data.nonce);\n return;\n }\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 // The popup proves its opener is this page before it signs anything: only this page\n // receives the nonce it posts to opener_origin, so sending it back is the proof.\n function answerChallenge(nonce: unknown) {\n if (typeof nonce !== 'string' || !CHALLENGE_NONCE.test(nonce)) return;\n try {\n popup?.postMessage({ type: 'oc-signin-echo', nonce }, popupOrigin);\n } catch {\n /* the popup closed first */\n }\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 { inheritedKeys } from './own-options';\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 for (const key of inheritedKeys(options, KEYS)) throw new TypeError(`sign-in button: option ${key} is inherited, not set by the caller`);\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"]}
|
package/dist/button.mjs
CHANGED
|
@@ -71,6 +71,7 @@ function inheritedKeys(opts, known) {
|
|
|
71
71
|
var DEFAULT_POPUP_ORIGIN = "https://me.ochk.io";
|
|
72
72
|
var DEFAULT_POPUP_PATH = "/popup/signin";
|
|
73
73
|
var DEFAULT_FEATURES = "width=480,height=720,resizable=yes,scrollbars=yes";
|
|
74
|
+
var CHALLENGE_NONCE = /^[A-Za-z0-9_-]{16,128}$/;
|
|
74
75
|
var POPUP_OPTIONS = /* @__PURE__ */ new Set(["popupOrigin", "popupPath", "features", "signal"]);
|
|
75
76
|
function checkPopupOptions(options) {
|
|
76
77
|
if (options === null || typeof options !== "object") {
|
|
@@ -127,6 +128,10 @@ function signInWithOcOutcome(options = {}) {
|
|
|
127
128
|
if (event.origin !== popupOrigin) return;
|
|
128
129
|
if (event.source !== popup) return;
|
|
129
130
|
const data = event.data;
|
|
131
|
+
if (data?.type === "oc-signin-challenge") {
|
|
132
|
+
answerChallenge(data.nonce);
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
130
135
|
if (!data || data.type !== "oc-signin-success") return;
|
|
131
136
|
if (!data.account || !data.token) {
|
|
132
137
|
settle({ status: "failed" });
|
|
@@ -134,6 +139,13 @@ function signInWithOcOutcome(options = {}) {
|
|
|
134
139
|
}
|
|
135
140
|
settle({ status: "signed_in", account: data.account, token: data.token });
|
|
136
141
|
}
|
|
142
|
+
function answerChallenge(nonce) {
|
|
143
|
+
if (typeof nonce !== "string" || !CHALLENGE_NONCE.test(nonce)) return;
|
|
144
|
+
try {
|
|
145
|
+
popup?.postMessage({ type: "oc-signin-echo", nonce }, popupOrigin);
|
|
146
|
+
} catch {
|
|
147
|
+
}
|
|
148
|
+
}
|
|
137
149
|
function onAbort() {
|
|
138
150
|
settle({ status: "aborted" });
|
|
139
151
|
}
|