Self-hosting
Deployment
Rule for everything on the signer's origin: never serve a page from the signer's origin that loads script from a URL the visitor can influence (query string, fragment, document.referrer, postMessage data). Such a script runs as the signer: it can start Web3Auth with any clientId that allowlists this origin, use the signer's passkeys, and read its stored sessions. tests/static.spec.js checks examples/ and portal/ for this.
Self-host the signer on Vercel (one click)
For a signer of your own, for your sites with their own Web3Auth clientId and for extension and bunker users. The button copies this repository to your GitHub account and deploys the signer only (vercel.json: scripts/assemble-signer.sh), with no portal or examples on its origin.
Deploy with the button. Your signer is then at
https://<project>.vercel.app/nostr-shard-signer(use a custom domain of its own if you can: the origin holds your users' data, see #60).In your Web3Auth project, add
https://<project>.vercel.appto the Allowlist URLs.In your app, load the bridge from your signer and point it there:
html<script src="https://<project>.vercel.app/nostr-shard-signer/nostr-bridge.js"></script> <script type="module"> await NostrBridge.init({ clientId: "YOUR_WEB3AUTH_CLIENT_ID", bunkerOrigin: "https://<project>.vercel.app/nostr-shard-signer" }); </script>
Optional settings (Vercel → Project → Settings → Environment Variables, then redeploy):
VITE_ROOT_PUBKEY_HEX: a registry root key, if you run your own registrar (below). Without it, your signer accepts the origins in your Web3Auth allowlist only.VITE_REGISTRY_RELAYS: that registry's relays, comma-separated.VITE_POPUP_CONFIRM=always: sensitive prompts in a window on the signer's origin for every site.VITE_SHARED_CLIENT_ID: your own Web3Auth project for shared sign-in (below).VITE_SIGNER_KEY: the name your users' Evolustr app keys are bound to (default: your signer's origin). Set it before anyone uses app keys, never change it afterwards, and give every origin of your signer the same one.
Shared sign-in (Google/Apple/X with no clientId) is off in your copy until you set VITE_SHARED_CLIENT_ID to a Web3Auth project of your own (Sapphire Mainnet, key export on, its allowlist listing only your signer's origin), with the safeguards in Watching the shared project. The hosted signer's project (SHARED_CLIENT_ID in bunker/src/lib/shared.ts) applies only on the hosted signer's own origins.
Who can obtain your users' keys: everyone who can change what your Vercel project serves: your GitHub and Vercel accounts, and the build's dependencies. Every push to your copy redeploys it, so protect both accounts with 2FA.
Users with a signer of their own ("Use my own signer")
A user who runs their own copy of this signer, with their own Web3Auth project as its shared project (VITE_SHARED_CLIENT_ID), can use it on any site that embeds the bridge (#72). Under Web3Auth's sign-in panel, the widget offers "Use my own signer": the user enters their signer's address, the page reloads, and from then on the bridge frames their signer on that site instead of the site's.
- Kept per site, in the page's
localStorage(nostr-bridge:signer), until the user logs out of their signer there: the page then reloads with the site's signer, so the next person on a shared browser doesn't sign in through someone else's signer. - Visible: while signed out and during sign-in, the bridge draws a bar above the widget, "Signer:
<host>", with "Use site's" to go back. The bridge draws it, not the chosen signer, so it shows even if that signer is old, broken or hostile. The user's signer also offers "Use this site's signer" under its sign-in panel. - The site's
clientIdandglobalLoginaren't sent to it: it signs in with the user's own project, so they get their own keys there. - Not on Nostr-only pages (
nostrOnly), which offer no Google/Apple/X sign-in. - A signer that doesn't answer within 15 s (a mistyped address, or it's down) is forgotten, and the page reloads with the site's signer.
- Safe for the user by design: a page or signer that points them to a fake address gets no key, because Web3Auth starts only on the origins in the user's own project's allowlist. Only
https:addresses are accepted (plainhttp:onlocalhost). - Not yet: a way to keep strangers from using your signer and your Web3Auth quota (a PIN or passkey before sign-in, allowed sites only, alerts): #72 part 2. Only the block list applies today.
1. One-time setup
a. Generate the root keypair
The root keypair signs all NIP-33 registry events. Keep the private key secret; only the public key is built into signer.html.
node -e "
const {generateSecretKey, getPublicKey} = require('nostr-tools');
const sk = generateSecretKey();
const pk = getPublicKey(sk);
const skHex = Buffer.from(sk).toString('hex');
console.log('ROOT_PRIVATE_KEY_HEX =', skHex);
console.log('ROOT_PUBKEY_HEX =', pk);
"b. Configure the bunker
The root public key is built into the signer; no page can change it. In Settings → Secrets and variables → Actions → Variables, add:
| Variable | Value |
|---|---|
ROOT_PUBKEY_HEX | The root public key (hex), the pubkey from your registrar's GET /pubkey. Required: the deploy fails without it |
REGISTRY_RELAYS | Optional, comma-separated relays that host your NIP-33 events. Defaults to DEFAULT_REGISTRY_RELAYS in bunker/src/lib/nostr.ts |
POPUP_CONFIRM | Optional. always shows sensitive prompts (decrypts, profile and list replacements, deletions, Evolustr app keys, key export) in a popup on the signer's origin for every page, not only in shared sign-in. Pages with their own clientId keep them in the iframe otherwise |
The workflows pass them to the build as VITE_ROOT_PUBKEY_HEX, VITE_REGISTRY_RELAYS and VITE_POPUP_CONFIRM. A signer built without a valid root key authorizes domains through the Web3Auth allowlist only, and reports MISSING_ROOT_PUBKEY for the others.
DEFAULT_PUBLISH_RELAYS in bunker/src/lib/nostr.ts sets the relays that profiles are read from and profile updates are sent to (the user can change them in Settings). Each identity's own write relays from its relay list (NIP-65, kind 10002) are added to both (#170), up to 10.
The bunker is a Vite + React + TypeScript app. Build it with:
cd bunker && npm install && VITE_ROOT_PUBKEY_HEX=<hex> npm run buildThe deploy workflow builds it with SIGNER_BASE=/ and publishes it (scripts/assemble-signer.sh) to its own Cloudflare Pages project, shardsigner (SIGNER_PAGES_PROJECT in deploy.yml), whose custom domain is the signer's origin. Other builds keep the path /nostr-shard-signer/.
c. Create the Cloudflare KV namespaces (once)
cd registrar
npm install
wrangler kv:namespace create "REGISTRY_KV"
# → Copy the returned id into wrangler.toml binding = "REGISTRY_KV"
wrangler kv:namespace create "CHALLENGES_KV"
# → Copy the returned id into wrangler.toml binding = "CHALLENGES_KV"
# Store the private key as a Cloudflare secret — never commit it
wrangler secret put ROOT_PRIVATE_KEY_HEX
# → Paste ROOT_PRIVATE_KEY_HEX when promptedd. Add GitHub repository secrets
In Settings → Secrets → Actions, add:
| Secret | Value |
|---|---|
CLOUDFLARE_API_TOKEN | Cloudflare API token with Workers:Edit and Cloudflare Pages: Edit permissions |
CLOUDFLARE_ACCOUNT_ID | Your Cloudflare account ID |
e. Enable GitHub Pages
In Settings → Pages, set source to GitHub Actions.
f. Update the portal registrar URL and client ID
In site-config.js (used by the portal and examples/evolustr.html), set your Worker URL, the portal's own Web3Auth client ID and your signer's origin:
registrarUrl: "https://nostr-shard-registrar.__ACCOUNT__.workers.dev",
portalClientId: "YOUR_PORTAL_CLIENT_ID",
signerOrigin: "https://signer.example.com",g. The signer's domain
After the first deploy, open the Cloudflare Pages project shardsigner → Custom domains and add the signer's hostname (a domain used only for the signer and its own static pages, #92). Then list https://<that hostname> in the Web3Auth allowlists: the shared project's (only that), the portal's and every own clientId's, and set DEFAULT_SIGNER_ORIGIN in registrar/registrar-worker.js (or SIGNER_ORIGIN) and DEFAULT_BUNKER_ORIGIN in nostr-bridge.js and npm/index.js.
2. Automated deploy (push to main)
After the one-time setup, every push to main automatically:
- Deploys the signer (
signer.html,/restore, their assets andnostr-bridge.js) to the Cloudflare Pages projectshardsigner - Then publishes the portal, docs, examples,
site-config.jsand a copy ofnostr-bridge.jsto GitHub Pages;signer.htmlandrestore/there only say where the signer went - Deploys
registrar-worker.jsto Cloudflare Workers
https://signer.shardsigner.com/nostr-bridge.js ← the bridge
https://signer.shardsigner.com/signer.html ← the signer
https://<user>.github.io/nostr-shard-signer/portal/ ← developer portalPR previews
Pull requests from this repo are built and deployed to Cloudflare Pages (.github/workflows/preview.yml) at one shared https URL, which the workflow posts as a PR comment. A preview serves the signer and the site together under /nostr-shard-signer/, with a test Web3Auth project for shared sign-in: never add a preview origin to a production clientId's allowlist or to the shared project. The registry refuses localhost, so use this URL to test signer changes. One-time setup:
- Give
CLOUDFLARE_API_TOKENthe Cloudflare Pages: Edit permission as well. - Add the preview origin to every clientId you test with, including the portal's own: use the portal's Register tab with the same clientId, signed in with the key that owns it. That adds the domain. Don't use Update Domains, which replaces the whole list. Also add the origin to the Web3Auth Allowlist URLs.
All PRs share the URL, so the most recent push wins. The preview uses the production registrar Worker.