Skip to content

armgit / ruflo

Public Imported from GitHub
0

🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated

feat(federation): give ChatGPT Federation its own key and its own relay connection

ruv506b3b90ebac
diff --git a/.github/workflows/chatgpt-federation.yml b/.github/workflows/chatgpt-federation.yml
new file mode 100644
index 0000000000..a9fffa26fe
--- /dev/null
+++ b/.github/workflows/chatgpt-federation.yml
@@ -0,0 +1,28 @@
+name: chatgpt-federation
+
+on:
+ pull_request:
+ paths:
+ - 'plugins/ruflo-chatgpt-federation/**'
+ # The suite guards against the gateway's channel tags drifting away from
+ # this publisher's, so a gateway change must run it too.
+ - 'plugins/ruflo-x-gateway/src/channels.mjs'
+ push:
+ branches: [main]
+ paths:
+ - 'plugins/ruflo-chatgpt-federation/**'
+ - 'plugins/ruflo-x-gateway/src/channels.mjs'
+
+jobs:
+ test:
+ runs-on: ubuntu-latest
+ defaults:
+ run:
+ working-directory: plugins/ruflo-chatgpt-federation
+ steps:
+ - uses: actions/checkout@v4
+ - uses: actions/setup-node@v4
+ with:
+ node-version: '22'
+ - run: npm install --no-audit --no-fund
+ - run: npm test
diff --git a/plugins/ruflo-chatgpt-federation/.gcloudignore b/plugins/ruflo-chatgpt-federation/.gcloudignore
new file mode 100644
index 0000000000..579a419448
--- /dev/null
+++ b/plugins/ruflo-chatgpt-federation/.gcloudignore
@@ -0,0 +1,3 @@
+node_modules/
+test/
+.git/
diff --git a/plugins/ruflo-chatgpt-federation/.gitignore b/plugins/ruflo-chatgpt-federation/.gitignore
new file mode 100644
index 0000000000..c2658d7d1b
--- /dev/null
+++ b/plugins/ruflo-chatgpt-federation/.gitignore
@@ -0,0 +1 @@
+node_modules/
diff --git a/plugins/ruflo-chatgpt-federation/Dockerfile b/plugins/ruflo-chatgpt-federation/Dockerfile
new file mode 100644
index 0000000000..4ba0a997b7
--- /dev/null
+++ b/plugins/ruflo-chatgpt-federation/Dockerfile
@@ -0,0 +1,11 @@
+FROM node:22-slim
+WORKDIR /app
+COPY package.json ./
+RUN npm install --omit=dev --no-audit --no-fund
+COPY src ./src
+ENV PORT=8080
+# The signing key is NOT baked in. Cloud Run mounts it read-only at
+# /secrets/nostr/signing-key from Secret Manager; there is no build arg,
+# no env var and no image layer that carries it.
+EXPOSE 8080
+CMD ["node", "src/server.mjs"]
diff --git a/plugins/ruflo-chatgpt-federation/README.md b/plugins/ruflo-chatgpt-federation/README.md
new file mode 100644
index 0000000000..dcf8367749
--- /dev/null
+++ b/plugins/ruflo-chatgpt-federation/README.md
@@ -0,0 +1,127 @@
+# ruflo-chatgpt-federation
+
+The ChatGPT Federation connector's publisher. It holds a Nostr key, signs swarm
+events with it, and publishes them to `wss://relay.ruv.io` over a connection it
+authenticated itself.
+
+## Why this is a separate service
+
+`buzz-relay` refuses any `EVENT` whose pubkey differs from the NIP-42 identity that
+authenticated the connection:
+
+```
+invalid: event pubkey does not match authenticated identity
+```
+
+So "sign it here, let the gateway relay it for you" cannot work β€” not as a policy
+choice, as a protocol one. A participant that wants to publish must hold a key and
+must open its own authenticated socket. This service is the smallest thing that does
+that on the connector's behalf, which is why it exists rather than a new gateway tool.
+
+It is also why the x.ruv.io gateway is uninvolved here: it does not sign for this
+identity, does not hold the key, and cannot read it.
+
+## Surface
+
+Three tools, no resources.
+
+| Tool | Auth | Purpose |
+|---|---|---|
+| `federation_identity` | open | The public key this connector signs with, and its relay |
+| `channel_sync` | open | Read recent messages from a channel |
+| `channel_publish` | caller token | Sign locally, publish to a `pub:` channel |
+
+`channel_publish` returns `eventId`, `pubkey` and `authenticatedAs` so a caller can
+check the identity binding rather than trust it.
+
+Publishing is restricted to public (`pub:`) channels. A private channel needs a NIP-44
+channel key, and this service deliberately holds none β€” it can read `prv:` traffic only
+as ciphertext, exactly as the gateway can.
+
+## Key custody
+
+The signing key is a Secret Manager secret, mounted read-only as a file:
+
+| | |
+|---|---|
+| Project | `ruv-dev` |
+| Secret | `chatgpt-federation-nostr-sk` |
+| Mount | `/secrets/nostr/signing-key` |
+| Runtime SA | `[email protected]` |
+| Public identity | `a29fbf2f7299d13e1f1049f829e0d7036949133de4226d728b2f181458d56890` |
+
+`ruv-dev` rather than `cognitum-20260110` for one specific reason: cognitum grants
+`roles/secretmanager.secretAccessor` to the default compute service account at the
+project level, and the x.ruv.io gateway runs as that account. Any secret placed there
+is readable by the gateway β€” and by every other service in the project β€” regardless of
+per-secret bindings. `ruv-dev` grants the default compute account only `roles/editor`,
+which does not include `secretmanager.versions.access`.
+
+Three deliberate omissions in `signing-key.mjs`, each one load-bearing:
+
+- **No env-var key value.** Only the *path* is configurable (`CGF_SIGNING_KEY_PATH`).
+ An env var holding the secret is the exposure a secret volume exists to remove.
+- **No generate-on-missing fallback.** A fresh key is an identity the relay has never
+ admitted, so the service would report healthy and then fail every publish under a
+ second, unaudited identity. It refuses to start instead.
+- **No accessor.** `loadSigner()` returns `{ pubkey, sign }`. The bytes stay in the
+ closure; there is no path from an MCP tool to them. A test asserts this structurally.
+
+Anything shaped like key material is scrubbed from errors and logs by `redact()`.
+
+## Deploy
+
+```bash
+gcloud run deploy chatgpt-federation \
+ --project=ruv-dev --region=us-central1 --source=. \
+ --service-account=chatgpt-federation-runtime@ruv-dev.iam.gserviceaccount.com \
+ --set-secrets=/secrets/nostr/signing-key=chatgpt-federation-nostr-sk:latest,CGF_CALLER_TOKEN=chatgpt-federation-caller-token:latest \
+ --set-env-vars=CGF_RELAY_URL=wss://relay.ruv.io \
+ --allow-unauthenticated
+```
+
+`--allow-unauthenticated` is correct here: the service is reached by a ChatGPT
+connector that cannot mint a Google ID token. Authority to publish comes from the
+caller token, not from Cloud Run IAM.
+
+Send that token as **`x-caller-token`**, not `Authorization`. Cloud Run consumes the
+`Authorization` header for its own IAM check and answers `401` before the request
+reaches the container, so a token sent that way never arrives.
+
+## Rotate
+
+Secret Manager versions are immutable, so rotation is add-then-disable and every step
+is auditable.
+
+```bash
+# 1. new key β†’ new version. The value moves through a pipe; it is never written
+# to a file and never printed.
+node -e "const{generateSecretKey}=require('nostr-tools/pure');process.stdout.write(Buffer.from(generateSecretKey()).toString('hex'))" \
+ | gcloud secrets versions add chatgpt-federation-nostr-sk --project=ruv-dev --data-file=-
+
+# 2. restart onto it
+gcloud run services update chatgpt-federation --project=ruv-dev --region=us-central1 \
+ --set-secrets=/secrets/nostr/signing-key=chatgpt-federation-nostr-sk:latest,CGF_CALLER_TOKEN=chatgpt-federation-caller-token:latest
+
+# 3. read the new public identity, admit it on the relay, confirm it can publish
+curl -s https://chatgpt-federation-875130704813.us-central1.run.app/ | jq -r .pubkey
+
+# 4. only after federation continuity is confirmed
+gcloud secrets versions disable <old> --secret=chatgpt-federation-nostr-sk --project=ruv-dev
+```
+
+Step 3 is not optional. A rotated key is a **new federation identity**: the relay must
+admit the new pubkey (`federation_admit`) or every publish fails with `restricted:`,
+and readers tracking the old pubkey will see the connector go silent rather than change
+names. Disabling the old version before that is confirmed strands the connector.
+
+## Test
+
+```bash
+npm install && npm test
+```
+
+The suite runs a local NIP-42 relay that enforces the same identity binding as
+`buzz-relay`, so the publish path is exercised end to end without touching production.
+It also asserts that the gateway still tags channels on `c` β€” drift there does not fail
+loudly, it just makes every event invisible to every reader.
diff --git a/plugins/ruflo-chatgpt-federation/package-lock.json b/plugins/ruflo-chatgpt-federation/package-lock.json
new file mode 100644
index 0000000000..10fff98300
--- /dev/null
+++ b/plugins/ruflo-chatgpt-federation/package-lock.json
@@ -0,0 +1,1330 @@
+{
+ "name": "@ruflo/chatgpt-federation",
+ "version": "0.1.0",
+ "lockfileVersion": 3,
+ "requires": true,
+ "packages": {
+ "": {
+ "name": "@ruflo/chatgpt-federation",
+ "version": "0.1.0",
+ "license": "MIT",
+ "dependencies": {
+ "@modelcontextprotocol/sdk": "^1.0.0",
+ "nostr-tools": "^2.7.0",
+ "ws": "^8.18.0",
+ "zod": "^3.23.0"
+ },
+ "engines": {
+ "node": ">=20"
+ }
+ },
+ "node_modules/@hono/node-server": {
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/@hono/node-server/-/node-server-2.1.1.tgz",
+ "integrity": "sha512-ELuehkj5VCBdgEw9zs+ivkKwyzzUCSQuE96YmiPvn1ECBoZCczbFXJLeEGMTYjphP6gydh4pHMqEYPVMYUVgQg==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=20"
+ },
+ "peerDependencies": {
+ "hono": "^4"
+ }
+ },
+ "node_modules/@modelcontextprotocol/sdk": {
+ "version": "1.30.0",
+ "resolved": "https://registry.npmjs.org/@modelcontextprotocol/sdk/-/sdk-1.30.0.tgz",
+ "integrity": "sha512-xKd8OIzlqNzcqcNumGAa6g+PW2kjD5vrpcKOnfldAUPP3j7lnqMPwlTXQm8gF+UwH72z0lqaRbjr9hqGz0eITA==",
+ "license": "MIT",
+ "dependencies": {
+ "@hono/node-server": "^1.19.9 || ^2.0.5",
+ "ajv": "^8.17.1",
+ "ajv-formats": "^3.0.1",
+ "content-type": "^1.0.5",
+ "cors": "^2.8.5",
+ "cross-spawn": "^7.0.5",
+ "eventsource": "^3.0.2",
+ "eventsource-parser": "^3.0.0",
+ "express": "^5.2.1",
+ "express-rate-limit": "^8.2.1",
+ "hono": "^4.11.4",
+ "jose": "^6.1.3",
+ "json-schema-typed": "^8.0.2",
+ "pkce-challenge": "^5.0.0",
+ "raw-body": "^3.0.0",
+ "zod": "^3.25 || ^4.0",
+ "zod-to-json-schema": "^3.25.1"
+ },
+ "engines": {
+ "node": ">=18"
+ },
+ "peerDependencies": {
+ "@cfworker/json-schema": "^4.1.1",
+ "zod": "^3.25 || ^4.0"
+ },
+ "peerDependenciesMeta": {
+ "@cfworker/json-schema": {
+ "optional": true
+ },
+ "zod": {
+ "optional": false
+ }
+ }
+ },
+ "node_modules/@noble/ciphers": {
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/@noble/ciphers/-/ciphers-2.1.1.tgz",
+ "integrity": "sha512-bysYuiVfhxNJuldNXlFEitTVdNnYUc+XNJZd7Qm2a5j1vZHgY+fazadNFWFaMK/2vye0JVlxV3gHmC0WDfAOQw==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 20.19.0"
+ },
+ "funding": {
+ "url": "https://paulmillr.com/funding/"
+ }
+ },
+ "node_modules/@noble/curves": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-2.0.1.tgz",
+ "integrity": "sha512-vs1Az2OOTBiP4q0pwjW5aF0xp9n4MxVrmkFBxc6EKZc6ddYx5gaZiAsZoq0uRRXWbi3AT/sBqn05eRPtn1JCPw==",
+ "license": "MIT",
+ "dependencies": {
+ "@noble/hashes": "2.0.1"
+ },
+ "engines": {
+ "node": ">= 20.19.0"
+ },
+ "funding": {
+ "url": "https://paulmillr.com/funding/"
+ }
+ },
+ "node_modules/@noble/hashes": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-2.0.1.tgz",
+ "integrity": "sha512-XlOlEbQcE9fmuXxrVTXCTlG2nlRXa9Rj3rr5Ue/+tX+nmkgbX720YHh0VR3hBF9xDvwnb8D2shVGOwNx+ulArw==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 20.19.0"
+ },
+ "funding": {
+ "url": "https://paulmillr.com/funding/"
+ }
+ },
+ "node_modules/@scure/base": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/@scure/base/-/base-2.0.0.tgz",
+ "integrity": "sha512-3E1kpuZginKkek01ovG8krQ0Z44E3DHPjc5S2rjJw9lZn3KSQOs8S7wqikF/AH7iRanHypj85uGyxk0XAyC37w==",
+ "license": "MIT",
+ "funding": {
+ "url": "https://paulmillr.com/funding/"
+ }
+ },
+ "node_modules/@scure/bip32": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/@scure/bip32/-/bip32-2.0.1.tgz",
+ "integrity": "sha512-4Md1NI5BzoVP+bhyJaY3K6yMesEFzNS1sE/cP+9nuvE7p/b0kx9XbpDHHFl8dHtufcbdHRUUQdRqLIPHN/s7yA==",
+ "license": "MIT",
+ "dependencies": {
+ "@noble/curves": "2.0.1",
+ "@noble/hashes": "2.0.1",
+ "@scure/base": "2.0.0"
+ },
+ "funding": {
+ "url": "https://paulmillr.com/funding/"
+ }
+ },
+ "node_modules/@scure/bip39": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/@scure/bip39/-/bip39-2.0.1.tgz",
+ "integrity": "sha512-PsxdFj/d2AcJcZDX1FXN3dDgitDDTmwf78rKZq1a6c1P1Nan1X/Sxc7667zU3U+AN60g7SxxP0YCVw2H/hBycg==",
+ "license": "MIT",
+ "dependencies": {
+ "@noble/hashes": "2.0.1",
+ "@scure/base": "2.0.0"
+ },
+ "funding": {
+ "url": "https://paulmillr.com/funding/"
+ }
+ },
+ "node_modules/accepts": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/accepts/-/accepts-2.0.0.tgz",
+ "integrity": "sha512-5cvg6CtKwfgdmVqY1WIiXKc3Q1bkRqGLi+2W/6ao+6Y7gu/RCwRuAhGEzh5B4KlszSuTLgZYuqFqo5bImjNKng==",
+ "license": "MIT",
+ "dependencies": {
+ "mime-types": "^3.0.0",
+ "negotiator": "^1.0.0"
+ },
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/ajv": {
+ "version": "8.20.0",
+ "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.20.0.tgz",
+ "integrity": "sha512-Thbli+OlOj+iMPYFBVBfJ3OmCAnaSyNn4M1vz9T6Gka5Jt9ba/HIR56joy65tY6kx/FCF5VXNB819Y7/GUrBGA==",
+ "license": "MIT",
+ "dependencies": {
+ "fast-deep-equal": "^3.1.3",
+ "fast-uri": "^3.0.1",
+ "json-schema-traverse": "^1.0.0",
+ "require-from-string": "^2.0.2"
+ },
+ "funding": {
+ "type": "github",
+ "url": "https://github.com/sponsors/epoberezkin"
+ }
+ },
+ "node_modules/ajv-formats": {
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-3.0.1.tgz",
+ "integrity": "sha512-8iUql50EUR+uUcdRQ3HDqa6EVyo3docL8g5WJ3FNcWmu62IbkGUue/pEyLBW8VGKKucTPgqeks4fIU1DA4yowQ==",
+ "license": "MIT",
+ "dependencies": {
+ "ajv": "^8.0.0"
+ },
+ "peerDependencies": {
+ "ajv": "^8.0.0"
+ },
+ "peerDependenciesMeta": {
+ "ajv": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/body-parser": {
+ "version": "2.3.0",
+ "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.3.0.tgz",
+ "integrity": "sha512-2cGmJupaNgg+QUwVLAucDuWuoMZ6EX9iHDRswZ5lsNYEmwPaRknMPCLZz07yTzVq/83p4o/wzbDZbBrTvGGTIw==",
+ "license": "MIT",
+ "dependencies": {
+ "bytes": "^3.1.2",
+ "content-type": "^2.0.0",
+ "debug": "^4.4.3",
+ "http-errors": "^2.0.1",
+ "iconv-lite": "^0.7.2",
+ "on-finished": "^2.4.1",
+ "qs": "^6.15.2",
+ "raw-body": "^3.0.2",
+ "type-is": "^2.1.0"
+ },
+ "engines": {
+ "node": ">=18"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/express"
+ }
+ },
+ "node_modules/body-parser/node_modules/content-type": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/content-type/-/content-type-2.1.0.tgz",
+ "integrity": "sha512-mj7UPXE0jaqaOsukNZRUEfEi2AcL7C/vwmwcHV0O97eO1E1pxBZuyjlZrx5seTaNBg1U6+o35wpa35Qfcc+7ag==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=18"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/express"
+ }
+ },
+ "node_modules/bytes": {
+ "version": "3.1.2",
+ "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz",
+ "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "node_modules/call-bind-apply-helpers": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz",
+ "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==",
+ "license": "MIT",
+ "dependencies": {
+ "es-errors": "^1.3.0",
+ "function-bind": "^1.1.2"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ }
+ },
+ "node_modules/call-bound": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz",
+ "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==",
+ "license": "MIT",
+ "dependencies": {
+ "call-bind-apply-helpers": "^1.0.2",
+ "get-intrinsic": "^1.3.0"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
+ "node_modules/content-disposition": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-1.1.0.tgz",
+ "integrity": "sha512-5jRCH9Z/+DRP7rkvY83B+yGIGX96OYdJmzngqnw2SBSxqCFPd0w2km3s5iawpGX8krnwSGmF0FW5Nhr0Hfai3g==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=18"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/express"
+ }
+ },
+ "node_modules/content-type": {
+ "version": "1.0.5",
+ "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz",
+ "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/cookie": {
+ "version": "0.7.2",
+ "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz",
+ "integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/cookie-signature": {
+ "version": "1.2.2",
+ "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.2.2.tgz",
+ "integrity": "sha512-D76uU73ulSXrD1UXF4KE2TMxVVwhsnCgfAyTg9k8P6KGZjlXKrOLe4dJQKI3Bxi5wjesZoFXJWElNWBjPZMbhg==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=6.6.0"
+ }
+ },
+ "node_modules/cors": {
+ "version": "2.8.6",
+ "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.6.tgz",
+ "integrity": "sha512-tJtZBBHA6vjIAaF6EnIaq6laBBP9aq/Y3ouVJjEfoHbRBcHBAHYcMh/w8LDrk2PvIMMq8gmopa5D4V8RmbrxGw==",
+ "license": "MIT",
+ "dependencies": {
+ "object-assign": "^4",
+ "vary": "^1"
+ },
+ "engines": {
+ "node": ">= 0.10"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/express"
+ }
+ },
+ "node_modules/cross-spawn": {
+ "version": "7.0.6",
+ "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",
+ "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==",
+ "license": "MIT",
+ "dependencies": {
+ "path-key": "^3.1.0",
+ "shebang-command": "^2.0.0",
+ "which": "^2.0.1"
+ },
+ "engines": {
+ "node": ">= 8"
+ }
+ },
+ "node_modules/debug": {
+ "version": "4.4.3",
+ "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",
+ "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==",
+ "license": "MIT",
+ "dependencies": {
+ "ms": "^2.1.3"
+ },
+ "engines": {
+ "node": ">=6.0"
+ },
+ "peerDependenciesMeta": {
+ "supports-color": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/depd": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz",
+ "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "node_modules/dunder-proto": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",
+ "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==",
+ "license": "MIT",
+ "dependencies": {
+ "call-bind-apply-helpers": "^1.0.1",
+ "es-errors": "^1.3.0",
+ "gopd": "^1.2.0"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ }
+ },
+ "node_modules/ee-first": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
+ "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==",
+ "license": "MIT"
+ },
+ "node_modules/encodeurl": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz",
+ "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "node_modules/es-define-property": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz",
+ "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.4"
+ }
+ },
+ "node_modules/es-errors": {
+ "version": "1.3.0",
+ "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",
+ "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.4"
+ }
+ },
+ "node_modules/es-object-atoms": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.2.tgz",
+ "integrity": "sha512-HWcBoN6NileqtSydK2FqHbS/LoDd2pqrnQHLyJzBj4kOp/ky2MWMN694xOfkK8/SnUsW2DH7EfyVlydKCsm1Zw==",
+ "license": "MIT",
+ "dependencies": {
+ "es-errors": "^1.3.0"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ }
+ },
+ "node_modules/escape-html": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
+ "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==",
+ "license": "MIT"
+ },
+ "node_modules/etag": {
+ "version": "1.8.1",
+ "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
+ "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/eventsource": {
+ "version": "3.0.7",
+ "resolved": "https://registry.npmjs.org/eventsource/-/eventsource-3.0.7.tgz",
+ "integrity": "sha512-CRT1WTyuQoD771GW56XEZFQ/ZoSfWid1alKGDYMmkt2yl8UXrVR4pspqWNEcqKvVIzg6PAltWjxcSSPrboA4iA==",
+ "license": "MIT",
+ "dependencies": {
+ "eventsource-parser": "^3.0.1"
+ },
+ "engines": {
+ "node": ">=18.0.0"
+ }
+ },
+ "node_modules/eventsource-parser": {
+ "version": "3.1.1",
+ "resolved": "https://registry.npmjs.org/eventsource-parser/-/eventsource-parser-3.1.1.tgz",
+ "integrity": "sha512-EKN1vKAMcZ8MlYMpaNuxN6R9yakzH6uajHcHVTqWJzvu5pWw9DyhbP35HH8MVBQ+dZjAfDxk+A8NiR9KWaXiyQ==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=18.0.0"
+ }
+ },
+ "node_modules/express": {
+ "version": "5.2.1",
+ "resolved": "https://registry.npmjs.org/express/-/express-5.2.1.tgz",
+ "integrity": "sha512-hIS4idWWai69NezIdRt2xFVofaF4j+6INOpJlVOLDO8zXGpUVEVzIYk12UUi2JzjEzWL3IOAxcTubgz9Po0yXw==",
+ "license": "MIT",
+ "dependencies": {
+ "accepts": "^2.0.0",
+ "body-parser": "^2.2.1",
+ "content-disposition": "^1.0.0",
+ "content-type": "^1.0.5",
+ "cookie": "^0.7.1",
+ "cookie-signature": "^1.2.1",
+ "debug": "^4.4.0",
+ "depd": "^2.0.0",
+ "encodeurl": "^2.0.0",
+ "escape-html": "^1.0.3",
+ "etag": "^1.8.1",
+ "finalhandler": "^2.1.0",
+ "fresh": "^2.0.0",
+ "http-errors": "^2.0.0",
+ "merge-descriptors": "^2.0.0",
+ "mime-types": "^3.0.0",
+ "on-finished": "^2.4.1",
+ "once": "^1.4.0",
+ "parseurl": "^1.3.3",
+ "proxy-addr": "^2.0.7",
+ "qs": "^6.14.0",
+ "range-parser": "^1.2.1",
+ "router": "^2.2.0",
+ "send": "^1.1.0",
+ "serve-static": "^2.2.0",
+ "statuses": "^2.0.1",
+ "type-is": "^2.0.1",
+ "vary": "^1.1.2"
+ },
+ "engines": {
+ "node": ">= 18"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/express"
+ }
+ },
+ "node_modules/express-rate-limit": {
+ "version": "8.7.0",
+ "resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-8.7.0.tgz",
+ "integrity": "sha512-hOwV7WOxXfjRpAM1DSJWZDXx3GhplwD8IfwuwvogD8i1Qnkgosw/H45s4ZnFAUHDAhPjlY9hLBvJhKmGMyY26g==",
+ "license": "MIT",
+ "dependencies": {
+ "debug": "^4.4.3",
+ "ip-address": "^10.2.0"
+ },
+ "engines": {
+ "node": ">= 16"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/express-rate-limit"
+ },
+ "peerDependencies": {
+ "express": ">= 4.11"
+ }
+ },
+ "node_modules/fast-deep-equal": {
+ "version": "3.1.3",
+ "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
+ "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==",
+ "license": "MIT"
+ },
+ "node_modules/fast-uri": {
+ "version": "3.1.7",
+ "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.7.tgz",
+ "integrity": "sha512-dOvZVzjdZdz7phd9v6jCbwxrBW3fK6n8Rc0CtdmM4bumzMnxywBYhuph6J819RRw/ku+rLbelwfMunktuzVVHg==",
+ "funding": [
+ {
+ "type": "github",
+ "url": "https://github.com/sponsors/fastify"
+ },
+ {
+ "type": "opencollective",
+ "url": "https://opencollective.com/fastify"
+ }
+ ],
+ "license": "BSD-3-Clause"
+ },
+ "node_modules/finalhandler": {
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-2.1.1.tgz",
+ "integrity": "sha512-S8KoZgRZN+a5rNwqTxlZZePjT/4cnm0ROV70LedRHZ0p8u9fRID0hJUZQpkKLzro8LfmC8sx23bY6tVNxv8pQA==",
+ "license": "MIT",
+ "dependencies": {
+ "debug": "^4.4.0",
+ "encodeurl": "^2.0.0",
+ "escape-html": "^1.0.3",
+ "on-finished": "^2.4.1",
+ "parseurl": "^1.3.3",
+ "statuses": "^2.0.1"
+ },
+ "engines": {
+ "node": ">= 18.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/express"
+ }
+ },
+ "node_modules/forwarded": {
+ "version": "0.2.0",
+ "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
+ "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/fresh": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/fresh/-/fresh-2.0.0.tgz",
+ "integrity": "sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "node_modules/function-bind": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
+ "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",
+ "license": "MIT",
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
+ "node_modules/get-intrinsic": {
+ "version": "1.3.0",
+ "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz",
+ "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==",
+ "license": "MIT",
+ "dependencies": {
+ "call-bind-apply-helpers": "^1.0.2",
+ "es-define-property": "^1.0.1",
+ "es-errors": "^1.3.0",
+ "es-object-atoms": "^1.1.1",
+ "function-bind": "^1.1.2",
+ "get-proto": "^1.0.1",
+ "gopd": "^1.2.0",
+ "has-symbols": "^1.1.0",
+ "hasown": "^2.0.2",
+ "math-intrinsics": "^1.1.0"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
+ "node_modules/get-proto": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz",
+ "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==",
+ "license": "MIT",
+ "dependencies": {
+ "dunder-proto": "^1.0.1",
+ "es-object-atoms": "^1.0.0"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ }
+ },
+ "node_modules/gopd": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz",
+ "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.4"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
+ "node_modules/has-symbols": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz",
+ "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.4"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
+ "node_modules/hasown": {
+ "version": "2.0.4",
+ "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.4.tgz",
+ "integrity": "sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==",
+ "license": "MIT",
+ "dependencies": {
+ "function-bind": "^1.1.2"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ }
+ },
+ "node_modules/hono": {
+ "version": "4.13.7",
+ "resolved": "https://registry.npmjs.org/hono/-/hono-4.13.7.tgz",
+ "integrity": "sha512-c8/gF9ac8Y78/agExVocyLevgR+JlpNB444Py0FSX8pJoPdYUfUzRcXtYEYGwt6l19qIlVZPN5Mfsw9jFShmQQ==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=16.9.0"
+ }
+ },
+ "node_modules/http-errors": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz",
+ "integrity": "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==",
+ "license": "MIT",
+ "dependencies": {
+ "depd": "~2.0.0",
+ "inherits": "~2.0.4",
+ "setprototypeof": "~1.2.0",
+ "statuses": "~2.0.2",
+ "toidentifier": "~1.0.1"
+ },
+ "engines": {
+ "node": ">= 0.8"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/express"
+ }
+ },
+ "node_modules/iconv-lite": {
+ "version": "0.7.3",
+ "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.3.tgz",
+ "integrity": "sha512-IKXpvIzjnC9XTAUbVBcMfGS0EPaIXtW6v+zr+RRp+hqULEpo0owZax6wyRwPOJbWbzjYspQwusTsfVr0ifh4uQ==",
+ "license": "MIT",
+ "dependencies": {
+ "safer-buffer": ">= 2.1.2 < 3.0.0"
+ },
+ "engines": {
+ "node": ">=0.10.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/express"
+ }
+ },
+ "node_modules/inherits": {
+ "version": "2.0.4",
+ "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
+ "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
+ "license": "ISC"
+ },
+ "node_modules/ip-address": {
+ "version": "10.7.0",
+ "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-10.7.0.tgz",
+ "integrity": "sha512-BGFsyJd5mpXp3rK6jIdADLNgpJUK1jnjzvYF8lK+VyDab9JAmqN0YOKDdP17HlgKb2+ehPgDc8EtnRLbGCAMhA==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 12"
+ }
+ },
+ "node_modules/ipaddr.js": {
+ "version": "1.9.1",
+ "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
+ "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.10"
+ }
+ },
+ "node_modules/is-promise": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-4.0.0.tgz",
+ "integrity": "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==",
+ "license": "MIT"
+ },
+ "node_modules/isexe": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
+ "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==",
+ "license": "ISC"
+ },
+ "node_modules/jose": {
+ "version": "6.2.12",
+ "resolved": "https://registry.npmjs.org/jose/-/jose-6.2.12.tgz",
+ "integrity": "sha512-9NiFmJEex0sy2Dk58j2UGBSHgUs2ypF9eZSu4L6vjOX3Dp96Sw1F3uL+H+D1sx02jZZdzUT0HgvCy59CuvXcWw==",
+ "license": "MIT",
+ "funding": {
+ "url": "https://github.com/sponsors/panva"
+ }
+ },
+ "node_modules/json-schema-traverse": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz",
+ "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==",
+ "license": "MIT"
+ },
+ "node_modules/json-schema-typed": {
+ "version": "8.0.2",
+ "resolved": "https://registry.npmjs.org/json-schema-typed/-/json-schema-typed-8.0.2.tgz",
+ "integrity": "sha512-fQhoXdcvc3V28x7C7BMs4P5+kNlgUURe2jmUT1T//oBRMDrqy1QPelJimwZGo7Hg9VPV3EQV5Bnq4hbFy2vetA==",
+ "license": "BSD-2-Clause"
+ },
+ "node_modules/math-intrinsics": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
+ "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.4"
+ }
+ },
+ "node_modules/media-typer": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-1.1.1.tgz",
+ "integrity": "sha512-yz3xRaG20c6/BOzvYoDaGtPmGscs7YivItZEEqe6GbwNfHuxu9YNmvnEkMzKldAGY4/80pRcQRZSEnhquk9XuQ==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.8"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/express"
+ }
+ },
+ "node_modules/merge-descriptors": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-2.0.0.tgz",
+ "integrity": "sha512-Snk314V5ayFLhp3fkUREub6WtjBfPdCPY1Ln8/8munuLuiYhsABgBVWsozAG+MWMbVEvcdcpbi9R7ww22l9Q3g==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=18"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/mime-db": {
+ "version": "1.54.0",
+ "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz",
+ "integrity": "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/mime-types": {
+ "version": "3.0.2",
+ "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-3.0.2.tgz",
+ "integrity": "sha512-Lbgzdk0h4juoQ9fCKXW4by0UJqj+nOOrI9MJ1sSj4nI8aI2eo1qmvQEie4VD1glsS250n15LsWsYtCugiStS5A==",
+ "license": "MIT",
+ "dependencies": {
+ "mime-db": "^1.54.0"
+ },
+ "engines": {
+ "node": ">=18"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/express"
+ }
+ },
+ "node_modules/ms": {
+ "version": "2.1.3",
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
+ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
+ "license": "MIT"
+ },
+ "node_modules/negotiator": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-1.1.0.tgz",
+ "integrity": "sha512-NMPBRMJgiQHjbd8phG3Vebdx4kZ1H121rbl5IkMqeOsahptB9BKo/d7oJ3zTXqTgagn2bWlNSXkh0QUGM31RYg==",
+ "license": "MIT",
+ "dependencies": {
+ "content-type": "^2.1.0"
+ },
+ "engines": {
+ "node": ">=18"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/express"
+ }
+ },
+ "node_modules/negotiator/node_modules/content-type": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/content-type/-/content-type-2.1.0.tgz",
+ "integrity": "sha512-mj7UPXE0jaqaOsukNZRUEfEi2AcL7C/vwmwcHV0O97eO1E1pxBZuyjlZrx5seTaNBg1U6+o35wpa35Qfcc+7ag==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=18"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/express"
+ }
+ },
+ "node_modules/nostr-tools": {
+ "version": "2.25.2",
+ "resolved": "https://registry.npmjs.org/nostr-tools/-/nostr-tools-2.25.2.tgz",
+ "integrity": "sha512-7JAx+brEPmqGz1yzaK9MOxvis/Nl1B38j9hVsBSRDMRmxk5XSc0+5LlPEYbzeiUyk41RURBDcfuMzmaT754HAg==",
+ "license": "Unlicense",
+ "dependencies": {
+ "@noble/ciphers": "2.1.1",
+ "@noble/curves": "2.0.1",
+ "@noble/hashes": "2.0.1",
+ "@scure/base": "2.0.0",
+ "@scure/bip32": "2.0.1",
+ "@scure/bip39": "2.0.1",
+ "nostr-wasm": "0.1.0"
+ },
+ "peerDependencies": {
+ "typescript": ">=5.0.0"
+ },
+ "peerDependenciesMeta": {
+ "typescript": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/nostr-wasm": {
+ "version": "0.1.0",
+ "resolved": "https://registry.npmjs.org/nostr-wasm/-/nostr-wasm-0.1.0.tgz",
+ "integrity": "sha512-78BTryCLcLYv96ONU8Ws3Q1JzjlAt+43pWQhIl86xZmWeegYCNLPml7yQ+gG3vR6V5h4XGj+TxO+SS5dsThQIA==",
+ "license": "MIT"
+ },
+ "node_modules/object-assign": {
+ "version": "4.1.1",
+ "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
+ "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=0.10.0"
+ }
+ },
+ "node_modules/object-inspect": {
+ "version": "1.13.4",
+ "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz",
+ "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.4"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
+ "node_modules/on-finished": {
+ "version": "2.4.1",
+ "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz",
+ "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==",
+ "license": "MIT",
+ "dependencies": {
+ "ee-first": "1.1.1"
+ },
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "node_modules/once": {
+ "version": "1.4.0",
+ "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
+ "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==",
+ "license": "ISC",
+ "dependencies": {
+ "wrappy": "1"
+ }
+ },
+ "node_modules/parseurl": {
+ "version": "1.3.3",
+ "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
+ "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "node_modules/path-key": {
+ "version": "3.1.1",
+ "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz",
+ "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/path-to-regexp": {
+ "version": "8.4.2",
+ "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.4.2.tgz",
+ "integrity": "sha512-qRcuIdP69NPm4qbACK+aDogI5CBDMi1jKe0ry5rSQJz8JVLsC7jV8XpiJjGRLLol3N+R5ihGYcrPLTno6pAdBA==",
+ "license": "MIT",
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/express"
+ }
+ },
+ "node_modules/pkce-challenge": {
+ "version": "5.0.1",
+ "resolved": "https://registry.npmjs.org/pkce-challenge/-/pkce-challenge-5.0.1.tgz",
+ "integrity": "sha512-wQ0b/W4Fr01qtpHlqSqspcj3EhBvimsdh0KlHhH8HRZnMsEa0ea2fTULOXOS9ccQr3om+GcGRk4e+isrZWV8qQ==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=16.20.0"
+ }
+ },
+ "node_modules/proxy-addr": {
+ "version": "2.0.7",
+ "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz",
+ "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==",
+ "license": "MIT",
+ "dependencies": {
+ "forwarded": "0.2.0",
+ "ipaddr.js": "1.9.1"
+ },
+ "engines": {
+ "node": ">= 0.10"
+ }
+ },
+ "node_modules/qs": {
+ "version": "6.16.0",
+ "resolved": "https://registry.npmjs.org/qs/-/qs-6.16.0.tgz",
+ "integrity": "sha512-h6fhOIaRrID2CbEY2fqs+7t+UXZo+MLAnU5gRIq85uFtdiUPCdsApMlHhXogKVM4HM2DVbIjGNTTYH2OcmP1vA==",
+ "license": "BSD-3-Clause",
+ "dependencies": {
+ "es-define-property": "^1.0.1",
+ "side-channel": "^1.1.1"
+ },
+ "engines": {
+ "node": ">=0.6"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
+ "node_modules/range-parser": {
+ "version": "1.3.0",
+ "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.3.0.tgz",
+ "integrity": "sha512-hek2mFQpPuI4E1BBKrSto+BU3e3x4xuarsbiwr3+lf7p44juvFMV0XFWQAP3xUyqXA4RrXLIoaSUGbSt056ZMw==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.6"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/express"
+ }
+ },
+ "node_modules/raw-body": {
+ "version": "3.0.2",
+ "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-3.0.2.tgz",
+ "integrity": "sha512-K5zQjDllxWkf7Z5xJdV0/B0WTNqx6vxG70zJE4N0kBs4LovmEYWJzQGxC9bS9RAKu3bgM40lrd5zoLJ12MQ5BA==",
+ "license": "MIT",
+ "dependencies": {
+ "bytes": "~3.1.2",
+ "http-errors": "~2.0.1",
+ "iconv-lite": "~0.7.0",
+ "unpipe": "~1.0.0"
+ },
+ "engines": {
+ "node": ">= 0.10"
+ }
+ },
+ "node_modules/require-from-string": {
+ "version": "2.0.2",
+ "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz",
+ "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=0.10.0"
+ }
+ },
+ "node_modules/router": {
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/router/-/router-2.2.0.tgz",
+ "integrity": "sha512-nLTrUKm2UyiL7rlhapu/Zl45FwNgkZGaCpZbIHajDYgwlJCOzLSk+cIPAnsEqV955GjILJnKbdQC1nVPz+gAYQ==",
+ "license": "MIT",
+ "dependencies": {
+ "debug": "^4.4.0",
+ "depd": "^2.0.0",
+ "is-promise": "^4.0.0",
+ "parseurl": "^1.3.3",
+ "path-to-regexp": "^8.0.0"
+ },
+ "engines": {
+ "node": ">= 18"
+ }
+ },
+ "node_modules/safer-buffer": {
+ "version": "2.1.2",
+ "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
+ "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
+ "license": "MIT"
+ },
+ "node_modules/send": {
+ "version": "1.2.1",
+ "resolved": "https://registry.npmjs.org/send/-/send-1.2.1.tgz",
+ "integrity": "sha512-1gnZf7DFcoIcajTjTwjwuDjzuz4PPcY2StKPlsGAQ1+YH20IRVrBaXSWmdjowTJ6u8Rc01PoYOGHXfP1mYcZNQ==",
+ "license": "MIT",
+ "dependencies": {
+ "debug": "^4.4.3",
+ "encodeurl": "^2.0.0",
+ "escape-html": "^1.0.3",
+ "etag": "^1.8.1",
+ "fresh": "^2.0.0",
+ "http-errors": "^2.0.1",
+ "mime-types": "^3.0.2",
+ "ms": "^2.1.3",
+ "on-finished": "^2.4.1",
+ "range-parser": "^1.2.1",
+ "statuses": "^2.0.2"
+ },
+ "engines": {
+ "node": ">= 18"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/express"
+ }
+ },
+ "node_modules/serve-static": {
+ "version": "2.2.1",
+ "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-2.2.1.tgz",
+ "integrity": "sha512-xRXBn0pPqQTVQiC8wyQrKs2MOlX24zQ0POGaj0kultvoOCstBQM5yvOhAVSUwOMjQtTvsPWoNCHfPGwaaQJhTw==",
+ "license": "MIT",
+ "dependencies": {
+ "encodeurl": "^2.0.0",
+ "escape-html": "^1.0.3",
+ "parseurl": "^1.3.3",
+ "send": "^1.2.0"
+ },
+ "engines": {
+ "node": ">= 18"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/express"
+ }
+ },
+ "node_modules/setprototypeof": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
+ "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==",
+ "license": "ISC"
+ },
+ "node_modules/shebang-command": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz",
+ "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==",
+ "license": "MIT",
+ "dependencies": {
+ "shebang-regex": "^3.0.0"
+ },
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/shebang-regex": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz",
+ "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/side-channel": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.1.tgz",
+ "integrity": "sha512-6x6dK6zJdpTzF4sQeNYxwtvBzf6Eg4GtlesS94HOvTudUeyK2WXAaIfmDgsyslYrRBeFIlsi54AYsFGUuhmvrQ==",
+ "license": "MIT",
+ "dependencies": {
+ "es-errors": "^1.3.0",
+ "object-inspect": "^1.13.4",
+ "side-channel-list": "^1.0.1",
+ "side-channel-map": "^1.0.1",
+ "side-channel-weakmap": "^1.0.2"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
+ "node_modules/side-channel-list": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.1.tgz",
+ "integrity": "sha512-mjn/0bi/oUURjc5Xl7IaWi/OJJJumuoJFQJfDDyO46+hBWsfaVM65TBHq2eoZBhzl9EchxOijpkbRC8SVBQU0w==",
+ "license": "MIT",
+ "dependencies": {
+ "es-errors": "^1.3.0",
+ "object-inspect": "^1.13.4"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
+ "node_modules/side-channel-map": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz",
+ "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==",
+ "license": "MIT",
+ "dependencies": {
+ "call-bound": "^1.0.2",
+ "es-errors": "^1.3.0",
+ "get-intrinsic": "^1.2.5",
+ "object-inspect": "^1.13.3"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
+ "node_modules/side-channel-weakmap": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz",
+ "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==",
+ "license": "MIT",
+ "dependencies": {
+ "call-bound": "^1.0.2",
+ "es-errors": "^1.3.0",
+ "get-intrinsic": "^1.2.5",
+ "object-inspect": "^1.13.3",
+ "side-channel-map": "^1.0.1"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
+ "node_modules/statuses": {
+ "version": "2.0.2",
+ "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz",
+ "integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "node_modules/toidentifier": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz",
+ "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=0.6"
+ }
+ },
+ "node_modules/type-is": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/type-is/-/type-is-2.1.0.tgz",
+ "integrity": "sha512-faYHw0anBbc/kWF3zFTEnxSFOAGUX9GFbOBthvDdLsIlEoWOFOtS0zgCiQYwIskL9iGXZL3kAXD8OoZ4GmMATA==",
+ "license": "MIT",
+ "dependencies": {
+ "content-type": "^2.0.0",
+ "media-typer": "^1.1.0",
+ "mime-types": "^3.0.0"
+ },
+ "engines": {
+ "node": ">= 18"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/express"
+ }
+ },
+ "node_modules/type-is/node_modules/content-type": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/content-type/-/content-type-2.1.0.tgz",
+ "integrity": "sha512-mj7UPXE0jaqaOsukNZRUEfEi2AcL7C/vwmwcHV0O97eO1E1pxBZuyjlZrx5seTaNBg1U6+o35wpa35Qfcc+7ag==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=18"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/express"
+ }
+ },
+ "node_modules/unpipe": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
+ "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "node_modules/vary": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
+ "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "node_modules/which": {
+ "version": "2.0.2",
+ "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
+ "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
+ "license": "ISC",
+ "dependencies": {
+ "isexe": "^2.0.0"
+ },
+ "bin": {
+ "node-which": "bin/node-which"
+ },
+ "engines": {
+ "node": ">= 8"
+ }
+ },
+ "node_modules/wrappy": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
+ "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==",
+ "license": "ISC"
+ },
+ "node_modules/ws": {
+ "version": "8.21.3",
+ "resolved": "https://registry.npmjs.org/ws/-/ws-8.21.3.tgz",
+ "integrity": "sha512-201TZ/kPWxoPr/OKWjquZR1SWKXcvxdH+e1xrx89b3YbmzLMFCLfnaG1HFIgWzJOEWZ7MvpK++odZufgYR50Rw==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=10.0.0"
+ },
+ "peerDependencies": {
+ "bufferutil": "^4.0.1",
+ "utf-8-validate": ">=5.0.2"
+ },
+ "peerDependenciesMeta": {
+ "bufferutil": {
+ "optional": true
+ },
+ "utf-8-validate": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/zod": {
+ "version": "3.25.76",
+ "resolved": "https://registry.npmjs.org/zod/-/zod-3.25.76.tgz",
+ "integrity": "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==",
+ "license": "MIT",
+ "funding": {
+ "url": "https://github.com/sponsors/colinhacks"
+ }
+ },
+ "node_modules/zod-to-json-schema": {
+ "version": "3.25.2",
+ "resolved": "https://registry.npmjs.org/zod-to-json-schema/-/zod-to-json-schema-3.25.2.tgz",
+ "integrity": "sha512-O/PgfnpT1xKSDeQYSCfRI5Gy3hPf91mKVDuYLUHZJMiDFptvP41MSnWofm8dnCm0256ZNfZIM7DSzuSMAFnjHA==",
+ "license": "ISC",
+ "peerDependencies": {
+ "zod": "^3.25.28 || ^4"
+ }
+ }
+ }
+}
diff --git a/plugins/ruflo-chatgpt-federation/package.json b/plugins/ruflo-chatgpt-federation/package.json
new file mode 100644
index 0000000000..5222821dc9
--- /dev/null
+++ b/plugins/ruflo-chatgpt-federation/package.json
@@ -0,0 +1,20 @@
+{
+ "name": "@ruflo/chatgpt-federation",
+ "version": "0.1.0",
+ "private": true,
+ "type": "module",
+ "description": "ChatGPT Federation publisher β€” signs ruflo swarm events with its own Nostr key and publishes them over its own NIP-42 authenticated relay connection. The key lives in this service and never leaves it.",
+ "main": "src/server.mjs",
+ "scripts": {
+ "start": "node src/server.mjs",
+ "test": "node --test test/*.test.mjs"
+ },
+ "dependencies": {
+ "@modelcontextprotocol/sdk": "^1.0.0",
+ "nostr-tools": "^2.7.0",
+ "ws": "^8.18.0",
+ "zod": "^3.23.0"
+ },
+ "engines": { "node": ">=20" },
+ "license": "MIT"
+}
diff --git a/plugins/ruflo-chatgpt-federation/src/publisher.mjs b/plugins/ruflo-chatgpt-federation/src/publisher.mjs
new file mode 100644
index 0000000000..124292aee6
--- /dev/null
+++ b/plugins/ruflo-chatgpt-federation/src/publisher.mjs
@@ -0,0 +1,121 @@
+/**
+ * Direct-to-relay publisher.
+ *
+ * buzz-relay refuses any EVENT whose pubkey differs from the NIP-42 authenticated
+ * identity on that connection. So a "gateway relays your signed event" design is
+ * impossible by construction, and this service exists to do the only thing that
+ * works: authenticate as itself, then publish as itself, on one socket it owns.
+ */
+import WebSocket from 'ws';
+import { verifyEvent, getEventHash } from 'nostr-tools/pure';
+import { redact } from './signing-key.mjs';
+
+export const SWARM_TAG = 'ruflo-swarm';
+export const SWARM_KIND = 1;
+export const AUTH_KIND = 22242;
+export const MAX_PAYLOAD_BYTES = 32 * 1024;
+// Public channels only. Publishing into `prv:` needs a NIP-44 channel key, and this
+// service is deliberately not a channel-key holder β€” it can carry ciphertext no more
+// than the gateway can. Reading a private channel stays possible; it just stays opaque.
+export const PUBLIC_CHANNEL_RE = /^pub:[a-z0-9][a-z0-9._-]{0,63}$/;
+const MSGTYPE_RE = /^[A-Za-z][A-Za-z0-9_-]{0,63}$/;
+
+/**
+ * Tags for a swarm channel event. Must stay byte-identical to the gateway's
+ * channelTags() (ADR-386) or these events publish fine and are then invisible to
+ * every reader β€” `c`, not `h`: the relay reserves `h` for NIP-29 groups and answers
+ * a #h-filtered REQ with "restricted: not a channel member".
+ */
+export function channelTags(channelId, msgType) {
+ if (!PUBLIC_CHANNEL_RE.test(String(channelId))) throw new Error('channel must match pub:<name>');
+ if (!MSGTYPE_RE.test(String(msgType))) throw new Error('msgType must match [A-Za-z][A-Za-z0-9_-]{0,63}');
+ return [['t', SWARM_TAG], ['c', String(channelId)], ['k', String(msgType)]];
+}
+
+/** Connect and complete NIP-42. Resolves the authenticated socket. */
+export function connectAuthed(relayUrl, signer, { timeoutMs = 15000 } = {}) {
+ return new Promise((resolve, reject) => {
+ const ws = new WebSocket(relayUrl, { perMessageDeflate: false });
+ let settled = false;
+ const done = (fn, arg) => { if (settled) return; settled = true; fn(arg); };
+ const timer = setTimeout(() => { try { ws.close(); } catch {} done(reject, new Error('auth timeout')); }, timeoutMs);
+ ws.on('message', (data) => {
+ let m; try { m = JSON.parse(data.toString()); } catch { return; }
+ if (m[0] === 'AUTH' && typeof m[1] === 'string') {
+ // The relay verifies the `relay` tag strictly, so it must carry the URL we dialled.
+ const ev = signer.sign({ kind: AUTH_KIND, created_at: Math.floor(Date.now() / 1000),
+ tags: [['relay', relayUrl], ['challenge', m[1]]], content: '' });
+ ws.send(JSON.stringify(['AUTH', ev]));
+ } else if (m[0] === 'OK') {
+ clearTimeout(timer);
+ if (m[2]) done(resolve, ws);
+ else { try { ws.close(); } catch {} done(reject, new Error(redact(m[3] || 'auth rejected'))); }
+ }
+ });
+ ws.on('error', (e) => { clearTimeout(timer); done(reject, new Error(redact(e.message))); });
+ ws.on('close', () => { clearTimeout(timer); done(reject, new Error('closed before auth')); });
+ });
+}
+
+/**
+ * Sign locally, then publish over the same authenticated socket.
+ *
+ * Returns the evidence the acceptance test asks for: the event id, the pubkey that
+ * signed it, and the identity that authenticated the connection β€” which are the same
+ * value here by construction, and are reported separately so a caller can check rather
+ * than trust that.
+ */
+export async function publishToChannel(relayUrl, signer, { channel, msgType, payload }) {
+ const tags = channelTags(channel, msgType);
+ const content = JSON.stringify({ type: msgType, ts: new Date().toISOString(), ...(payload ?? {}) });
+ const bytes = Buffer.byteLength(content);
+ if (bytes > MAX_PAYLOAD_BYTES) throw new Error(`payload too large (${bytes} > ${MAX_PAYLOAD_BYTES} bytes)`);
+
+ const ws = await connectAuthed(relayUrl, signer);
+ const ev = signer.sign({ kind: SWARM_KIND, created_at: Math.floor(Date.now() / 1000), tags, content });
+
+ // Self-check before it leaves: verifyEvent() alone does NOT bind the id to the
+ // content, so a tampered body verifies true unless the hash is recomputed first.
+ if (getEventHash(ev) !== ev.id) { try { ws.close(); } catch {} throw new Error('event id does not match its content'); }
+ if (!verifyEvent(ev)) { try { ws.close(); } catch {} throw new Error('event failed signature verification'); }
+ if (ev.pubkey !== signer.pubkey) { try { ws.close(); } catch {} throw new Error('event pubkey is not the connection identity'); }
+
+ return new Promise((resolve, reject) => {
+ const timer = setTimeout(() => { try { ws.close(); } catch {} reject(new Error('publish timeout')); }, 15000);
+ ws.on('message', (data) => {
+ let m; try { m = JSON.parse(data.toString()); } catch { return; }
+ if (m[0] === 'OK' && m[1] === ev.id) {
+ clearTimeout(timer); try { ws.close(); } catch {}
+ if (!m[2]) return reject(new Error(redact(m[3] || 'publish rejected')));
+ resolve({ eventId: ev.id, pubkey: ev.pubkey, authenticatedAs: signer.pubkey,
+ channel, msgType, relay: relayUrl, verified: true });
+ }
+ });
+ ws.send(JSON.stringify(['EVENT', ev]));
+ });
+}
+
+/** Read a channel's recent events over our own authenticated connection. */
+export async function readChannel(relayUrl, signer, { channel, sinceSeconds = 3600, limit = 100 } = {}) {
+ const ws = await connectAuthed(relayUrl, signer);
+ const filter = { kinds: [SWARM_KIND], '#t': [SWARM_TAG],
+ since: Math.floor(Date.now() / 1000) - sinceSeconds, limit };
+ if (channel) filter['#c'] = [String(channel)];
+ const out = [];
+ return new Promise((resolve) => {
+ const finish = () => { try { ws.close(); } catch {} resolve(out); };
+ const timer = setTimeout(finish, 12000);
+ ws.on('message', (data) => {
+ let m; try { m = JSON.parse(data.toString()); } catch { return; }
+ if (m[0] === 'EVENT' && m[2] && getEventHash(m[2]) === m[2].id && verifyEvent(m[2])) {
+ const e = m[2];
+ const rec = { id: e.id, pubkey: e.pubkey, created_at: e.created_at,
+ channel: e.tags.find((t) => t[0] === 'c')?.[1], k: e.tags.find((t) => t[0] === 'k')?.[1] };
+ // A private channel's body stays ciphertext: we hold no channel key.
+ if (rec.k === 'enc') out.push({ ...rec, encrypted: true });
+ else { let body; try { body = JSON.parse(e.content); } catch { body = { raw: e.content }; } out.push({ ...rec, ...body }); }
+ } else if (m[0] === 'EOSE') { clearTimeout(timer); finish(); }
+ });
+ ws.send(JSON.stringify(['REQ', 'cgf-read', filter]));
+ });
+}
diff --git a/plugins/ruflo-chatgpt-federation/src/server.mjs b/plugins/ruflo-chatgpt-federation/src/server.mjs
new file mode 100644
index 0000000000..5a9028d43f
--- /dev/null
+++ b/plugins/ruflo-chatgpt-federation/src/server.mjs
@@ -0,0 +1,128 @@
+/**
+ * ChatGPT Federation publisher β€” MCP over Streamable HTTP.
+ *
+ * GET /health liveness
+ * GET / service info (pubkey is public; nothing else is)
+ * POST /mcp MCP, stateless
+ *
+ * Surface is deliberately three tools and no resources. `federation_identity` and
+ * `channel_sync` are open reads. `channel_publish` is the only write, it publishes
+ * only to `pub:` channels, and it requires the caller token β€” because that token,
+ * not the model, is what authorises speaking as this federation identity.
+ *
+ * The signing key is never an input, an output, a resource, or a log line.
+ */
+import { createServer } from 'node:http';
+import { timingSafeEqual } from 'node:crypto';
+import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
+import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
+import { z } from 'zod';
+import { loadSigner, redact } from './signing-key.mjs';
+import { publishToChannel, readChannel, PUBLIC_CHANNEL_RE } from './publisher.mjs';
+
+const VERSION = '0.1.0';
+const MAX_BODY = 256 * 1024;
+
+export function checkCaller(token, expected = process.env.CGF_CALLER_TOKEN) {
+ if (!expected) return false; // unset β‡’ writes disabled, never open
+ const a = Buffer.from(String(token ?? '')), b = Buffer.from(String(expected));
+ return a.length === b.length && timingSafeEqual(a, b);
+}
+
+function readBody(req, max = MAX_BODY) {
+ return new Promise((resolve, reject) => {
+ let n = 0; const chunks = [];
+ req.on('data', (c) => { n += c.length; if (n > max) { reject(new Error('too large')); req.destroy(); return; } chunks.push(c); });
+ req.on('end', () => resolve(Buffer.concat(chunks).toString('utf8')));
+ req.on('error', reject);
+ });
+}
+
+const buckets = new Map();
+function rateLimited(req, rate = 60) {
+ const ip = (req.headers['x-forwarded-for'] || '').split(',')[0].trim() || req.socket.remoteAddress || 'unknown';
+ const now = Date.now(), slot = Math.floor(now / 60000), b = buckets.get(ip);
+ if (!b || b.slot !== slot) { buckets.set(ip, { slot, n: 1 }); if (buckets.size > 10000) buckets.clear(); return false; }
+ return ++b.n > rate;
+}
+
+export function createPublisherService({ relay, keyPath, port } = {}) {
+ const RELAY = relay || process.env.CGF_RELAY_URL || 'wss://relay.ruv.io';
+ const signer = loadSigner(keyPath); // throws at boot if custody is wrong β€” by design
+ const text = (o) => ({ content: [{ type: 'text', text: JSON.stringify(o) }] });
+ const fail = (e) => ({ isError: true, content: [{ type: 'text', text: JSON.stringify({ error: redact(e?.message || e) }) }] });
+
+ function buildMcp(req) {
+ // A dedicated header, not Authorization: Cloud Run consumes `Authorization`
+ // for its own IAM check and answers 401 before the request reaches this
+ // container, so a token sent that way never arrives. The header is still the
+ // preferred channel β€” it stays out of the model's context and out of
+ // tool-call transcripts β€” with the argument as a fallback for clients that
+ // cannot set headers on an MCP connection.
+ const header = String(req?.headers?.['x-caller-token'] || '').trim();
+ const mcp = new McpServer({ name: 'ruflo-chatgpt-federation', version: VERSION });
+
+ mcp.tool('federation_identity',
+ 'This connector\'s federation identity: the Nostr public key it signs with, and the relay it publishes to. Use when you need to know who the federation will see as the author, or to verify a published event came from this connector. The secret key is never returned by any tool.',
+ {},
+ async () => text({ pubkey: signer.pubkey, relay: RELAY, service: 'ruflo-chatgpt-federation', version: VERSION }));
+
+ mcp.tool('channel_sync',
+ 'Read recent messages from a ruflo swarm channel (e.g. pub:announce, pub:help). Use before publishing, to see what has already been said and avoid duplicating it. Private (prv:) channels are returned as opaque ciphertext because this connector holds no channel keys.',
+ { channel: z.string().optional().describe('Channel id, e.g. "pub:announce". Omit for the whole swarm stream.'),
+ sinceSeconds: z.number().optional().describe('Look-back window in seconds (default 3600).'),
+ limit: z.number().optional().describe('Maximum events to return (default 100).') },
+ async (a) => { try { const msgs = await readChannel(RELAY, signer, a); return text({ count: msgs.length, messages: msgs }); } catch (e) { return fail(e); } });
+
+ mcp.tool('channel_publish',
+ 'Sign a message with this connector\'s own key and publish it to a public swarm channel over its own NIP-42 authenticated relay connection. Use when this connector has something the federation needs β€” a status, a finding, a result. Requires the caller token; public (pub:) channels only, because publishing to a private channel needs a channel key this connector deliberately does not hold.',
+ { channel: z.string().describe('Public channel id, e.g. "pub:announce".'),
+ msgType: z.string().describe('Message type, e.g. "Status", "Result", "Question".'),
+ payload: z.record(z.any()).describe('Message body. Never put secrets or credentials here β€” channel content is readable by every relay member.'),
+ callerToken: z.string().optional().describe('Caller token, if not supplied as an x-caller-token header.') },
+ async ({ channel, msgType, payload, callerToken }) => {
+ if (!checkCaller(callerToken ?? header)) {
+ return { isError: true, content: [{ type: 'text', text: JSON.stringify({ error: 'caller token required or invalid' }) }] };
+ }
+ if (!PUBLIC_CHANNEL_RE.test(String(channel))) return fail(new Error('channel must be a public pub:<name> channel'));
+ try { return text({ ok: true, ...(await publishToChannel(RELAY, signer, { channel, msgType, payload })) }); }
+ catch (e) { return fail(e); }
+ });
+
+ return mcp;
+ }
+
+ const server = createServer(async (req, res) => {
+ res.setHeader('x-content-type-options', 'nosniff');
+ res.setHeader('referrer-policy', 'no-referrer');
+ const url = new URL(req.url, `http://${req.headers.host || 'x'}`);
+ if (url.pathname === '/health') return res.writeHead(200).end('ok');
+ if (url.pathname === '/' && req.method === 'GET') {
+ res.writeHead(200, { 'content-type': 'application/json' });
+ return res.end(JSON.stringify({ service: 'ruflo-chatgpt-federation', version: VERSION, mcp: '/mcp',
+ relay: RELAY, pubkey: signer.pubkey,
+ tools: ['federation_identity', 'channel_sync', 'channel_publish'],
+ publishAuth: 'x-caller-token: <caller token>' }));
+ }
+ if (url.pathname === '/mcp') {
+ if (rateLimited(req)) return res.writeHead(429, { 'content-type': 'application/json' }).end('{"error":"rate limited"}');
+ let body; try { body = await readBody(req); } catch { return res.writeHead(413, { 'content-type': 'application/json' }).end('{"error":"payload too large"}'); }
+ const mcp = buildMcp(req); const transport = new StreamableHTTPServerTransport({ sessionIdGenerator: undefined });
+ res.on('close', () => { transport.close(); mcp.close(); });
+ await mcp.connect(transport);
+ let parsed; try { parsed = body ? JSON.parse(body) : undefined; } catch { return res.writeHead(400, { 'content-type': 'application/json' }).end('{"error":"invalid json"}'); }
+ return transport.handleRequest(req, res, parsed);
+ }
+ res.writeHead(404).end('not found');
+ });
+
+ return { server, pubkey: signer.pubkey, relay: RELAY,
+ listen: (p = port ?? Number(process.env.PORT || 8080)) => new Promise((r) => server.listen(p, () => r(server.address().port))) };
+}
+
+if (import.meta.url === `file://${process.argv[1]}`) {
+ const svc = createPublisherService();
+ const p = await svc.listen();
+ // pubkey is public identity; the secret has no representation in any log line.
+ console.log(`ruflo-chatgpt-federation :${p} | relay ${svc.relay} | pubkey ${svc.pubkey} | publish ${process.env.CGF_CALLER_TOKEN ? 'enabled' : 'DISABLED (CGF_CALLER_TOKEN unset)'}`);
+}
diff --git a/plugins/ruflo-chatgpt-federation/src/signing-key.mjs b/plugins/ruflo-chatgpt-federation/src/signing-key.mjs
new file mode 100644
index 0000000000..7b6f22bc32
--- /dev/null
+++ b/plugins/ruflo-chatgpt-federation/src/signing-key.mjs
@@ -0,0 +1,57 @@
+/**
+ * Custody of the ChatGPT Federation signing key.
+ *
+ * The key is a 32-byte Nostr secret, delivered ONLY as a Cloud Run secret volume
+ * mounted read-only at /secrets/nostr/signing-key (Secret Manager version, immutable
+ * and auditable). Three deliberate omissions, each one a rule from the deployment brief:
+ *
+ * - no env-var key path. `RUFLO_NOSTR_KEY_HEX`-style injection is what a secret
+ * volume exists to replace; an env var leaks into `/proc`, crash dumps, and every
+ * child process. Only the *path* is configurable, never the value.
+ * - no generate-on-missing fallback. A fresh key would be a pubkey the relay has
+ * never admitted, so every publish would fail with `restricted:` β€” after the
+ * service had already reported itself healthy under a second, unaudited identity.
+ * Refusing to start is the honest failure.
+ * - no accessor that returns the secret. `load()` hands back a signer; the bytes
+ * stay in this module's closure. There is no code path from an MCP tool to them.
+ */
+import { readFileSync } from 'node:fs';
+import { getPublicKey, finalizeEvent } from 'nostr-tools/pure';
+
+export const DEFAULT_KEY_PATH = '/secrets/nostr/signing-key';
+const HEX64 = /^[0-9a-f]{64}$/i;
+
+/**
+ * Scrub anything that looks like key material out of a string before it reaches a
+ * log line, an MCP error, or an HTTP body. Cheap, and the one place a secret would
+ * plausibly escape is an exception message quoting what it failed to parse.
+ */
+export function redact(s) {
+ return String(s ?? '').replace(/[0-9a-fA-F]{64}/g, '[redacted]');
+}
+
+/**
+ * Read the mounted key and return a signer.
+ * @returns {{ pubkey: string, sign: (template: object) => object }}
+ */
+export function loadSigner(keyPath = process.env.CGF_SIGNING_KEY_PATH || DEFAULT_KEY_PATH) {
+ let raw;
+ try {
+ raw = readFileSync(keyPath, 'utf8').trim();
+ } catch (e) {
+ // e.message contains the path, never the contents β€” but redact regardless.
+ throw new Error(`signing key unreadable at ${keyPath}: ${redact(e.code || e.message)}`);
+ }
+ // Accept hex (what Secret Manager holds) and tolerate a trailing newline the
+ // console adds when a secret is created by paste rather than by file.
+ if (!HEX64.test(raw)) {
+ throw new Error(`signing key at ${keyPath} is not 32 bytes of hex (got ${raw.length} chars)`);
+ }
+ const sk = Uint8Array.from(Buffer.from(raw, 'hex'));
+ const pubkey = getPublicKey(sk);
+ // `sk` is reachable only from the closure below. Nothing returns it.
+ return {
+ pubkey,
+ sign: (template) => finalizeEvent(template, sk),
+ };
+}
diff --git a/plugins/ruflo-chatgpt-federation/test/publisher.test.mjs b/plugins/ruflo-chatgpt-federation/test/publisher.test.mjs
new file mode 100644
index 0000000000..4d0c4ad624
--- /dev/null
+++ b/plugins/ruflo-chatgpt-federation/test/publisher.test.mjs
@@ -0,0 +1,256 @@
+import { test } from 'node:test';
+import assert from 'node:assert/strict';
+import { writeFileSync, mkdtempSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { join } from 'node:path';
+import { WebSocketServer } from 'ws';
+import { generateSecretKey, getPublicKey, verifyEvent, getEventHash } from 'nostr-tools/pure';
+import { loadSigner, redact, DEFAULT_KEY_PATH } from '../src/signing-key.mjs';
+import { publishToChannel, readChannel, channelTags, connectAuthed, PUBLIC_CHANNEL_RE } from '../src/publisher.mjs';
+import { createPublisherService, checkCaller } from '../src/server.mjs';
+
+const dir = mkdtempSync(join(tmpdir(), 'cgf-'));
+const skHex = Buffer.from(generateSecretKey()).toString('hex');
+const keyPath = join(dir, 'signing-key');
+writeFileSync(keyPath, skHex, { mode: 0o600 });
+
+// ---- custody ----
+
+test('loadSigner refuses a missing key instead of generating one', () => {
+ // A generated fallback would be an unadmitted identity that reports healthy and
+ // then fails every publish with "restricted:". Refusing to start is the honest failure.
+ assert.throws(() => loadSigner(join(dir, 'nope')), /signing key unreadable/);
+});
+
+test('loadSigner refuses a key that is not 32 bytes of hex', () => {
+ const bad = join(dir, 'bad'); writeFileSync(bad, 'not-a-key');
+ assert.throws(() => loadSigner(bad), /not 32 bytes of hex/);
+});
+
+test('loadSigner tolerates the trailing newline a console paste adds', () => {
+ const nl = join(dir, 'nl'); writeFileSync(nl, skHex + '\n');
+ assert.equal(loadSigner(nl).pubkey, getPublicKey(Uint8Array.from(Buffer.from(skHex, 'hex'))));
+});
+
+test('the signer exposes a public key and a sign function, and nothing else', () => {
+ const signer = loadSigner(keyPath);
+ // Structural, not a string match: no property may carry the secret out.
+ assert.deepEqual(Object.keys(signer).sort(), ['pubkey', 'sign']);
+ const serialized = JSON.stringify(signer);
+ assert.ok(!serialized.includes(skHex), 'secret must not survive serialization');
+});
+
+test('redact scrubs anything shaped like key material', () => {
+ assert.equal(redact(`leaked ${skHex} here`), 'leaked [redacted] here');
+ assert.equal(redact(undefined), '');
+});
+
+test('the default key path is the read-only Cloud Run secret mount', () => {
+ assert.equal(DEFAULT_KEY_PATH, '/secrets/nostr/signing-key');
+});
+
+test('no environment variable can supply the key value', async () => {
+ // Only the *path* is configurable. An env var holding the secret itself is the
+ // exposure a secret volume exists to remove, so the loader must not read one.
+ const src = await import('node:fs').then((fs) => fs.readFileSync(new URL('../src/signing-key.mjs', import.meta.url), 'utf8'));
+ const envReads = [...src.matchAll(/process\.env\.([A-Z0-9_]+)/g)].map((m) => m[1]);
+ assert.deepEqual(envReads, ['CGF_SIGNING_KEY_PATH']);
+});
+
+// ---- tag compatibility with the gateway (ADR-386) ----
+
+test('channelTags emits the ADR-386 shape', () => {
+ assert.deepEqual(channelTags('pub:announce', 'Status'),
+ [['t', 'ruflo-swarm'], ['c', 'pub:announce'], ['k', 'Status']]);
+});
+
+test('the gateway still builds channel tags the same way', async () => {
+ // Read the gateway's source rather than importing it: this guard must run in a
+ // bare checkout, and the gateway is a separate container with its own deps.
+ // Drift here does not fail loudly β€” events publish fine and become invisible to
+ // every reader, because the relay indexes `c` and reserves `h` for NIP-29 groups.
+ const fs = await import('node:fs');
+ const src = fs.readFileSync(new URL('../../ruflo-x-gateway/src/channels.mjs', import.meta.url), 'utf8');
+ const body = src.slice(src.indexOf('export function channelTags'));
+ assert.match(body, /\['t', 'ruflo-swarm'\]/, 'gateway must still tag t=ruflo-swarm');
+ assert.match(body, /\['c', String\(channelId\)\]/, 'gateway must still tag the channel on `c`, not `h`');
+});
+
+test('channelTags refuses private channels and malformed types', () => {
+ assert.throws(() => channelTags('prv:0123456789abcdef', 'Status'), /pub:/);
+ assert.throws(() => channelTags('pub:announce', 'bad type!'), /msgType/);
+ assert.ok(!PUBLIC_CHANNEL_RE.test('prv:0123456789abcdef'));
+});
+
+// ---- caller token ----
+
+test('publishing is disabled, not open, when no caller token is configured', () => {
+ assert.equal(checkCaller('anything', undefined), false);
+ assert.equal(checkCaller(undefined, undefined), false);
+});
+
+test('caller token compare accepts the match and rejects near misses', () => {
+ assert.equal(checkCaller('s3cret', 's3cret'), true);
+ assert.equal(checkCaller('s3cres', 's3cret'), false);
+ assert.equal(checkCaller('s3cret-longer', 's3cret'), false);
+});
+
+// ---- a relay that enforces what buzz-relay enforces ----
+
+/**
+ * Minimal NIP-42 relay: issues a challenge, binds the connection to the AUTH
+ * identity, and refuses any EVENT signed by a different key β€” which is the exact
+ * rule that makes a "gateway relays your signed event" design impossible.
+ */
+function fakeRelay() {
+ const wss = new WebSocketServer({ port: 0 });
+ const seen = [];
+ wss.on('connection', (ws) => {
+ let authed = null;
+ ws.send(JSON.stringify(['AUTH', 'challenge-' + Math.random().toString(36).slice(2)]));
+ ws.on('message', (raw) => {
+ const m = JSON.parse(raw.toString());
+ if (m[0] === 'AUTH') {
+ const ev = m[1];
+ const ok = ev.kind === 22242 && getEventHash(ev) === ev.id && verifyEvent(ev);
+ if (ok) authed = ev.pubkey;
+ return ws.send(JSON.stringify(['OK', ev.id, ok, ok ? '' : 'auth: bad event']));
+ }
+ if (m[0] === 'EVENT') {
+ const ev = m[1];
+ if (!authed) return ws.send(JSON.stringify(['OK', ev.id, false, 'auth-required: authenticate first']));
+ if (ev.pubkey !== authed) return ws.send(JSON.stringify(['OK', ev.id, false, 'invalid: event pubkey does not match authenticated identity']));
+ if (getEventHash(ev) !== ev.id || !verifyEvent(ev)) return ws.send(JSON.stringify(['OK', ev.id, false, 'invalid: bad signature']));
+ seen.push(ev);
+ return ws.send(JSON.stringify(['OK', ev.id, true, '']));
+ }
+ if (m[0] === 'REQ') {
+ for (const ev of seen) ws.send(JSON.stringify(['EVENT', m[1], ev]));
+ ws.send(JSON.stringify(['EOSE', m[1]]));
+ }
+ });
+ });
+ return { url: () => `ws://127.0.0.1:${wss.address().port}`, seen, close: () => wss.close() };
+}
+
+test('publish authenticates, signs locally, and the event pubkey is the authenticated identity', async () => {
+ const relay = fakeRelay();
+ try {
+ const signer = loadSigner(keyPath);
+ const r = await publishToChannel(relay.url(), signer, {
+ channel: 'pub:announce', msgType: 'Status', payload: { note: 'probe' } });
+
+ // The acceptance bar: pubkey == authenticated identity, and the event id
+ // independently verifies against the content.
+ assert.equal(r.pubkey, r.authenticatedAs);
+ assert.equal(r.pubkey, signer.pubkey);
+ const ev = relay.seen.find((e) => e.id === r.eventId);
+ assert.ok(ev, 'relay accepted and stored the event');
+ assert.equal(getEventHash(ev), ev.id);
+ assert.ok(verifyEvent(ev));
+ assert.equal(JSON.parse(ev.content).note, 'probe');
+ } finally { relay.close(); }
+});
+
+test('the relay refuses an event signed by a key other than the authenticated one', async () => {
+ // Proves the constraint this whole service exists to satisfy.
+ const relay = fakeRelay();
+ try {
+ const signer = loadSigner(keyPath);
+ const ws = await connectAuthed(relay.url(), signer);
+ const otherSk = generateSecretKey();
+ const { finalizeEvent } = await import('nostr-tools/pure');
+ const foreign = finalizeEvent({ kind: 1, created_at: Math.floor(Date.now() / 1000),
+ tags: channelTags('pub:announce', 'Status'), content: '{}' }, otherSk);
+ const reason = await new Promise((resolve) => {
+ ws.on('message', (d) => { const m = JSON.parse(d.toString()); if (m[0] === 'OK' && m[1] === foreign.id) resolve(m[3]); });
+ ws.send(JSON.stringify(['EVENT', foreign]));
+ });
+ assert.match(reason, /does not match authenticated identity/);
+ ws.close();
+ } finally { relay.close(); }
+});
+
+test('readChannel returns what was published, verified', async () => {
+ const relay = fakeRelay();
+ try {
+ const signer = loadSigner(keyPath);
+ await publishToChannel(relay.url(), signer, { channel: 'pub:help', msgType: 'Question', payload: { q: 'how' } });
+ const msgs = await readChannel(relay.url(), signer, { channel: 'pub:help' });
+ assert.equal(msgs.length, 1);
+ assert.equal(msgs[0].q, 'how');
+ assert.equal(msgs[0].pubkey, signer.pubkey);
+ } finally { relay.close(); }
+});
+
+// ---- MCP surface ----
+
+async function rpc(port, body, headers = {}) {
+ const res = await fetch(`http://127.0.0.1:${port}/mcp`, { method: 'POST',
+ headers: { 'content-type': 'application/json', accept: 'application/json, text/event-stream', ...headers },
+ body: JSON.stringify(body) });
+ const raw = await res.text();
+ const line = raw.split('\n').find((l) => l.startsWith('data: '));
+ return JSON.parse(line ? line.slice(6) : raw);
+}
+
+test('the MCP surface is exactly three tools, and none of them can return the key', async () => {
+ const relay = fakeRelay();
+ const svc = createPublisherService({ relay: relay.url(), keyPath });
+ const port = await svc.listen(0);
+ try {
+ const out = await rpc(port, { jsonrpc: '2.0', id: 1, method: 'tools/list', params: {} });
+ const names = out.result.tools.map((t) => t.name).sort();
+ assert.deepEqual(names, ['channel_publish', 'channel_sync', 'federation_identity']);
+ assert.ok(!JSON.stringify(out).includes(skHex));
+
+ const id = await rpc(port, { jsonrpc: '2.0', id: 2, method: 'tools/call',
+ params: { name: 'federation_identity', arguments: {} } });
+ const body = JSON.parse(id.result.content[0].text);
+ assert.equal(body.pubkey, svc.pubkey);
+ assert.ok(!JSON.stringify(id).includes(skHex), 'identity must not leak the secret');
+ } finally { svc.server.close(); relay.close(); }
+});
+
+test('channel_publish refuses without the caller token and publishes with it', async () => {
+ const relay = fakeRelay();
+ const prev = process.env.CGF_CALLER_TOKEN;
+ process.env.CGF_CALLER_TOKEN = 'test-caller-token';
+ const svc = createPublisherService({ relay: relay.url(), keyPath });
+ const port = await svc.listen(0);
+ try {
+ const denied = await rpc(port, { jsonrpc: '2.0', id: 1, method: 'tools/call',
+ params: { name: 'channel_publish', arguments: { channel: 'pub:announce', msgType: 'Status', payload: {} } } });
+ assert.match(denied.result.content[0].text, /caller token required/);
+
+ // Authorization is NOT the channel: Cloud Run consumes it upstream, so a
+ // client that sends the token there must be told no, not silently allowed.
+ const wrongHeader = await rpc(port, { jsonrpc: '2.0', id: 3, method: 'tools/call',
+ params: { name: 'channel_publish', arguments: { channel: 'pub:announce', msgType: 'Status', payload: {} } } },
+ { authorization: 'Bearer test-caller-token' });
+ assert.match(wrongHeader.result.content[0].text, /caller token required/);
+
+ const ok = await rpc(port, { jsonrpc: '2.0', id: 2, method: 'tools/call',
+ params: { name: 'channel_publish', arguments: { channel: 'pub:announce', msgType: 'Status', payload: { note: 'hi' } } } },
+ { 'x-caller-token': 'test-caller-token' });
+ const body = JSON.parse(ok.result.content[0].text);
+ assert.equal(body.ok, true);
+ assert.equal(body.pubkey, body.authenticatedAs);
+ assert.equal(relay.seen.length, 1);
+ } finally { svc.server.close(); relay.close(); if (prev === undefined) delete process.env.CGF_CALLER_TOKEN; else process.env.CGF_CALLER_TOKEN = prev; }
+});
+
+test('channel_publish refuses a private channel even with a valid token', async () => {
+ const relay = fakeRelay();
+ const prev = process.env.CGF_CALLER_TOKEN;
+ process.env.CGF_CALLER_TOKEN = 'test-caller-token';
+ const svc = createPublisherService({ relay: relay.url(), keyPath });
+ const port = await svc.listen(0);
+ try {
+ const out = await rpc(port, { jsonrpc: '2.0', id: 1, method: 'tools/call',
+ params: { name: 'channel_publish', arguments: { channel: 'prv:0123456789abcdef', msgType: 'Status', payload: {} } } },
+ { 'x-caller-token': 'test-caller-token' });
+ assert.match(out.result.content[0].text, /public pub:/);
+ assert.equal(relay.seen.length, 0);
+ } finally { svc.server.close(); relay.close(); if (prev === undefined) delete process.env.CGF_CALLER_TOKEN; else process.env.CGF_CALLER_TOKEN = prev; }
+});