Communication protocol
Blocking a site from shared sign-in
Shared sign-in is open to every origin, and Web3Auth bills the shared project for every site's users. To take it away from one site without turning it off for everyone (SHARED_MODE_ON), block that site's origin. Its page then gets SIGNER_HELLO.oauth === "none" and the warning SHARED_BLOCKED; extension and bunker sign-in keep working there. Entries are origins (https://evil.example) or *.example.com for every subdomain of a host.
Without a deploy (preferred): publish a list signed with the registry root key. The signer reads the newest one from the registry relays, in shared mode only, while Web3Auth starts (at most 3 s; without an answer it uses the built-in list only). Each publish replaces the whole list:
bashROOT_PRIVATE_KEY_HEX=<hex or nsec> node scripts/publish-blocklist.mjs https://evil.example '*.bad.example' ROOT_PRIVATE_KEY_HEX=<hex or nsec> node scripts/publish-blocklist.mjs --clear # unblock every site--dry-runprints the signed event without publishing;--relays wss://a,wss://b(orREGISTRY_RELAYS) picks the relays, by default the signer'sDEFAULT_REGISTRY_RELAYS. Use the same key the registrar holds asROOT_PRIVATE_KEY_HEX. The event is kind 30078 withd=nostr-shard-signer:shared-blocked; the colon keeps it apart from registry entries, since the registrar refuses colons in a clientId.Built in:
SHARED_BLOCKED_ORIGINSinbunker/src/lib/shared.ts, orVITE_SHARED_BLOCKED_ORIGINS(comma-separated) at build time. Needs a deploy; applies even when the relays can't be reached.
What it can't do: the embedding origin is known reliably (ancestorOrigins), but a blocked operator can move to another domain. Counting users per site (#32) is what makes limits real.
Watching the shared project
Whoever can edit the shared project's Web3Auth allowlist could add a page of their own and obtain shared-mode users' keys. Two checks read the project's public configuration (the one Web3Auth's SDK reads: allowlist and key export):
- In the signer (canary): before a new shared sign-in, in the widget and in the sign-in window, the signer reads the configuration once per page. If the allowlist lists a site other than the signer's own address (and
VITE_SHARED_EXPECTED_ORIGINS, comma-separated, at build time), or key export is off, it shows "Sign-in paused" and starts no sign-in. Sites already signed in keep working. If the configuration can't be read within 5 s, sign-in goes on. Previews only log it (their test project also lists the check kit), unless built withVITE_CANARY=enforce. - Outside (monitor): the workflow
Shared project monitorrunsscripts/checkSharedProject.mjsevery 6 hours and fails, so GitHub emails you, when a project's allowlist differs fromscripts/sharedProjectExpected.json(a site added or missing), key export is off, or a listed sign-in connection changed or another joined its group (a new sign-in method in a group of its own is only reported: it gives new accounts). It checks the production project (SHARED_CLIENT_ID) and the preview's (PREVIEW_SHARED_CLIENT_ID), each skipped while unset. Change the expected list in the same PR as an intended allowlist change. Scheduled workflows run from the default branch only. In a fork, turn them on in the Actions tab. GitHub turns them off after 60 days without commits in a public repository; turn the workflow back on there.
Versioning
The bridge passes its protocol version in the iframe URL (signer.html?protocol=1&…; bridges from before the handshake send none and speak 1). The signer answers { type: "SIGNER_HELLO", protocol }, or, for a version it doesn't support, shows an error and posts SIGNER_ERROR with code PROTOCOL_UNSUPPORTED. Bump PROTOCOL_VERSION in nostr-bridge.js on breaking message changes, and keep the old version in the signer's SUPPORTED_PROTOCOLS while bridges speaking it may still be pinned or cached (jsDelivr, copies, older npm loaders on self-hosted signers).
Separately, NostrBridge.apiVersion versions the page-facing API that nostr-bridge.d.ts describes; the npm package's loader warns when it differs from the version its types describe.
UI/State (custom schema, iframe → parent)
| Message | When sent |
|---|---|
{ type: "SIGNER_PING", nonce: string } | Firefox only, before anything else: the signer checks that this page embeds it. nostr-bridge.js answers { type: "SIGNER_PONG", nonce }; a page that loads the signer some other way must too, within 2 s, or the signer reports NOT_EMBEDDED |
{ type: "SIGNER_HELLO", protocol: number, oauth: "own"|"shared"|"none" } | On load, once the protocol is accepted. oauth: the page's own clientId, shared sign-in, or no Google/Apple/X sign-in (signers from before shared sign-in don't send it) |
{ type: "AUTH_STATE", loggedIn: bool, pubkey: string|null } | On iframe load (passive session check) |
{ type: "AUTH_SUCCESS", pubkey: string } | After user completes OAuth flow |
{ type: "RESIZE", state: "button"|"avatar"|"modal" } | On every view transition |
{ type: "EVOLUSTR_SIGN", requestId, event } | Extension/bunker mode: the signer asks the bridge to sign its Evolustr vault (kind 30078, d starting evolustr:v1:signer:); the bridge answers { type: "EVOLUSTR_SIGN_RESULT", requestId, event | error } |
UI control (custom schema, parent → iframe)
| Message | Sent by | Effect |
|---|---|---|
{ type: "OPEN_LOGIN" } | NostrBridge.login() | Opens the sign-in modal (as the button does) |
{ type: "LOGOUT" } | NostrBridge.logout() | Logs out of Web3Auth, replies AUTH_STATE |
Crypto requests (NIP-46 RPC, parent → iframe)
// Request
{ "id": "req_0", "method": "sign_event", "params": ["<stringified_unsigned_event>"] }
// Success response
{ "id": "req_0", "result": "<stringified_signed_event>", "error": null }
// Rejection
{ "id": "req_0", "result": null, "error": "User rejected request" }Supported methods: get_public_key, sign_event, nip04_encrypt, nip04_decrypt, nip44_encrypt, nip44_decrypt, and the Evolustr methods evolustr_capabilities, evolustr_get_wrap_key, evolustr_enroll_passkey (no timeout; they may wait for a click in the signer)
Evolustr: app data keys
The signer implements the Evolustr Signer API (its SPEC §5): window.nostr.evolustr gives each app its own key for its encrypted data, derived in the signer iframe from a secret the app never sees. Other apps can't read that data, even with permission to sign or decrypt. It works with Web3Auth login and with an extension or bunker.
- The app is the page's origin (
event.originin the iframe), never anything the page sends. Apps on a known nsite gateway (<npub>.nsite.lol) are identified by their npub. - The user approves each app in the signer, once per site; Settings → App data keys lists them. With an extension or bunker, the list also follows the user to other devices: it is kept in Evolu under a key the signer derives from its own Evolustr secret (Evolustr's host secret for
nostr-shard-signer/v1/settings, which no app can obtain), and comes back once the signer passkey unlocks that secret. Forgetting an app forgets it on every device. - Protection of the signer's secret: with Web3Auth, the user chooses on first use between their login (the nsec; the owner of the Web3Auth project could then derive the app keys too) and a passkey. With an extension or bunker, a passkey is required, and the signer's encrypted vault event is signed by the extension or bunker through the bridge.
- App keys don't depend on the signer's address (#154): the signer's vault and every app wrap are bound to a fixed name,
https://signer.shardsigner.com(signerKey,lib/signerKey.ts), on every origin of the hosted signer, so a second origin (#92) opens the same app data. A self-hosted copy uses its own origin, orVITE_SIGNER_KEY. Passkeys do depend on it (rpId): on another origin, users add a passkey again. - Passkeys run inside the iframe where the browser allows it (the bridge sets
allow="publickey-credentials-get; publickey-credentials-create"), otherwise in a popup on the signer's origin, opened from a click in the signer. - Auto-approve never signs Evolustr vault events (kind 30078 with a
dtag startingevolustr:), even with App data turned on. With an extension or bunker, the extension signs them, not the signer (the page'ssignEventgoes to it), so its own permissions decide: an extension told to always allow a site lets that site replace the user's vault event without asking, which can lock the user out of their app data (it still can't read app keys, which need the signer passkey). The widget's profile panel warns these users, under App data keys (#205). Refusing these events in the bridge wouldn't help: Evolustr has to keep working with extensions, and a hostile page can call the extension directly.
The code comes from npm: @evolustr/signer and @evolustr/core, pinned to an exact version in bunker/package.json (#53). It runs next to the user's keys, so read each update's changes before merging it; Dependabot opens them one by one, outside the grouped updates.
Auto-approve policy
Approval settings are stored per host site. Confirmations are queued and shown one at a time.
| Action | Behaviour |
|---|---|
| Kinds 1, 7, 1111, 30818, 10003, 30003, 31922, 31923, 30078 | Auto-approved by default (user can untick) |
Kind 27235 (NIP-98) for https://nostr.build and its subdomains | Auto-approved by default (user can untick) |
| Kinds 6, 42 | Confirmation modal (user can tick) |
| Kind 0 (profile), 3 (follows), 10002 (relays), 5 (deletion), 27235 for other hosts | Always a confirmation modal |
Kind 30078 with a d tag starting evolustr: (Evolustr data keys) | Always a confirmation modal |
Other kinds (zaps, DMs, unknown kinds), nip04_encrypt, any decrypt | Confirmation modal |
get_public_key, nip44_encrypt | No confirmation |
| Kind 22242 (relay auth), 24242 (Blossom auth), 62 (request to vanish, with its own warning) | Always a confirmation modal |
| Any event dated more than 5 minutes in the future | Refused |
Kind 5 aimed (a tag) at an Evolustr vault or at another key's address (the signer's own records) | Refused |
An event whose pubkey is another identity than the active one | Refused |
Replaceable and addressable data (lists, bookmarks, app data, kinds 10000–19999 and 30000–39999) is signed without asking only when the site may replace what's there (#61):
- nothing exists yet at that address, or the event now on the relays (the signer's and the user's NIP-65 write relays) is the one this site signed last; if the relays don't answer, it asks;
- lists (NIP-51) may only add entries, or remove entries this site added itself (an entry already in the list doesn't count); private entries are decrypted and compared, and it asks if they can't be;
- mute lists, block lists and follow sets, and any
expirationtag, always ask; - bookmarks that keep the same content and only add tags are fine.