Files
thePR0M3TH3ANandClaude Opus 4.8 b8b19599e0 widget: headless signer — restore + sign without the custom element
The element was the only way to sign, so a host that renders its own UI, a
background job, or a headless test couldn't sign without mounting
<bitlogin-auth>. Add @bitlogin/widget/headless: createHeadlessSigner() → a
DOM-free wrapper over the crypto worker exposing restore, getPublicKey,
signEvent, nip44Encrypt/Decrypt, isUnlocked, logout, destroy.

It restores the cached session and signs with no element and no window.nostr.
It deliberately cannot interactively log in (that needs the password UI):
restore() returns null when nothing is cached, at which point the host mounts
<bitlogin-auth> once; after that the headless signer works across reloads.

New bitlogin-headless.js build entry + @bitlogin/widget/headless export
(also re-exported from @bitlogin/widget). Covered by headless.test.ts with a
scripted worker; README gains "Signing without the widget (headless)".

Addresses the "headless session-restore API" item of the Tessera integration
feedback (docs/TODO.md).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01BXQCvJPA6sVSQ5j8uBd9bB
2026-08-11 22:54:14 -04:00

40 lines
1.1 KiB
JSON

{
"name": "@bitlogin/widget",
"version": "0.1.0",
"private": true,
"license": "MIT",
"type": "module",
"description": "BitLogin embeddable login widget: a <bitlogin-auth> custom element plus a window.nostr NIP-07-compatible provider, backed by a dedicated crypto Web Worker.",
"main": "./dist/bitlogin.js",
"types": "./dist-types/index.d.ts",
"exports": {
".": {
"types": "./dist-types/index.d.ts",
"default": "./dist/bitlogin.js"
},
"./session": {
"types": "./dist-types/session.d.ts",
"default": "./dist/bitlogin-session.js"
},
"./headless": {
"types": "./dist-types/headless.d.ts",
"default": "./dist/bitlogin-headless.js"
}
},
"scripts": {
"build": "vite build && npm run build:types",
"build:types": "tsc -p tsconfig.types.json",
"dev": "vite build --watch",
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@bitlogin/core": "*",
"@getalby/bitcoin-connect": "3.12.3",
"qrcode-generator": "^2.0.4"
},
"devDependencies": {
"typescript": "^5.7.3",
"vite": "^6.1.0"
}
}