web-agent-bridge 3.14.0 → 3.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "web-agent-bridge",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.15.0",
|
|
4
4
|
"description": "Agent Transaction Bridge — the trust + transaction layer for agentic commerce. Signed intent contracts, idempotent transactions, Ed25519-verifiable receipts, explicit compensation. Plus the original WAB stack: sovereign browser, ShieldQR, SSL health, DNS discovery, agent mesh, and unified gateway for safe AI–website interaction.",
|
|
5
5
|
"author": "Web Agent Bridge <dev@webagentbridge.com>",
|
|
6
6
|
"main": "server/index.js",
|
package/server/routes/network.js
CHANGED
|
@@ -1,25 +1,46 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Network-effect public endpoints (v3.14.0).
|
|
4
|
+
* Network-effect public endpoints (v3.14.0 + signed snapshots v3.15.0).
|
|
5
5
|
*
|
|
6
|
-
* GET /api/trusted-domains.json — snapshot of currently-attested,
|
|
6
|
+
* GET /api/trusted-domains.json — signed snapshot of currently-attested,
|
|
7
7
|
* non-revoked WAB sites. Cached 1 hour. Designed for agent bootstrap
|
|
8
8
|
* and third-party crawlers building "verified web" indexes.
|
|
9
9
|
* GET /api/trusted-domains.txt — same data, newline-separated domains.
|
|
10
|
-
* GET /api/
|
|
11
|
-
* GET /api/
|
|
10
|
+
* GET /api/trusted-domains/archive.json — manifest of available daily snapshots.
|
|
11
|
+
* GET /api/trusted-domains/:date.json — historical signed snapshot.
|
|
12
|
+
* GET /api/transparency/feed.json — JSON Feed 1.1 of the transparency log.
|
|
13
|
+
* GET /api/transparency/feed.xml — Atom 1.0 of the transparency log.
|
|
14
|
+
* GET /api/operator-key.json — operator Ed25519 public key (b64 + JWK).
|
|
12
15
|
*
|
|
13
16
|
* Mounted at /api in server/index.js.
|
|
14
17
|
*/
|
|
15
18
|
|
|
16
19
|
const express = require('express');
|
|
20
|
+
const fs = require('fs');
|
|
21
|
+
const path = require('path');
|
|
22
|
+
const crypto = require('crypto');
|
|
17
23
|
const router = express.Router();
|
|
18
24
|
const { db } = require('../models/db');
|
|
25
|
+
const { canonicalize } = require('../services/canonical-json');
|
|
26
|
+
const signer = require('../services/operator-signer');
|
|
19
27
|
|
|
20
28
|
const SNAPSHOT_TTL_MS = 60 * 60 * 1000; // 1h
|
|
29
|
+
const ARCHIVE_DIR = process.env.WAB_SNAPSHOT_DIR ||
|
|
30
|
+
path.join(__dirname, '..', '..',
|
|
31
|
+
(process.env.NODE_ENV === 'test' ? 'data-test' : 'data'),
|
|
32
|
+
'snapshots');
|
|
33
|
+
|
|
21
34
|
let _snapshotCache = { ts: 0, data: null };
|
|
22
35
|
|
|
36
|
+
function _ensureArchiveDir() {
|
|
37
|
+
try { fs.mkdirSync(ARCHIVE_DIR, { recursive: true }); } catch (_) { /* ignore */ }
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function _todayUtc() {
|
|
41
|
+
return new Date().toISOString().slice(0, 10); // YYYY-MM-DD
|
|
42
|
+
}
|
|
43
|
+
|
|
23
44
|
function buildSnapshot() {
|
|
24
45
|
// Active sites that have no active blocking revocation.
|
|
25
46
|
let rows = [];
|
|
@@ -37,16 +58,18 @@ function buildSnapshot() {
|
|
|
37
58
|
ORDER BY s.created_at ASC
|
|
38
59
|
`).all();
|
|
39
60
|
} catch (_) {
|
|
40
|
-
// site_revocations may not yet exist on a very first boot
|
|
41
61
|
rows = db.prepare(`
|
|
42
62
|
SELECT id, domain, name, description, tier, created_at
|
|
43
63
|
FROM sites WHERE active = 1 ORDER BY created_at ASC
|
|
44
64
|
`).all();
|
|
45
65
|
}
|
|
46
66
|
|
|
47
|
-
|
|
67
|
+
const generated_at = new Date().toISOString();
|
|
68
|
+
const date = generated_at.slice(0, 10);
|
|
69
|
+
const payload = {
|
|
48
70
|
schema: 'wab-trusted-domains/v1',
|
|
49
|
-
generated_at
|
|
71
|
+
generated_at,
|
|
72
|
+
date,
|
|
50
73
|
total: rows.length,
|
|
51
74
|
domains: rows.map(r => ({
|
|
52
75
|
domain: r.domain,
|
|
@@ -57,6 +80,29 @@ function buildSnapshot() {
|
|
|
57
80
|
badge_url: 'https://webagentbridge.com/api/discovery/badge/' + r.domain + '.svg'
|
|
58
81
|
}))
|
|
59
82
|
};
|
|
83
|
+
|
|
84
|
+
// Hash + sign over the canonical bytes of `payload` (without signature fields).
|
|
85
|
+
const canonical = canonicalize(payload);
|
|
86
|
+
const content_hash = 'sha256:' + crypto.createHash('sha256').update(canonical, 'utf8').digest('hex');
|
|
87
|
+
const signature = signer.sign(payload);
|
|
88
|
+
|
|
89
|
+
const out = Object.assign({}, payload, {
|
|
90
|
+
content_hash,
|
|
91
|
+
signature: signature
|
|
92
|
+
? { alg: signer.ALGORITHM, value: signature, key_url: '/api/operator-key.json' }
|
|
93
|
+
: null,
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
// Persist today's snapshot to disk for time-machine queries (idempotent overwrite).
|
|
97
|
+
try {
|
|
98
|
+
_ensureArchiveDir();
|
|
99
|
+
const file = path.join(ARCHIVE_DIR, date + '.json');
|
|
100
|
+
fs.writeFileSync(file, JSON.stringify(out, null, 2) + '\n', 'utf8');
|
|
101
|
+
} catch (e) {
|
|
102
|
+
console.warn('[network] snapshot archive write failed (non-fatal):', e.message);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return out;
|
|
60
106
|
}
|
|
61
107
|
|
|
62
108
|
function getSnapshot() {
|
|
@@ -73,6 +119,8 @@ router.get('/trusted-domains.json', (req, res) => {
|
|
|
73
119
|
const snap = getSnapshot();
|
|
74
120
|
res.set('Cache-Control', 'public, max-age=3600, s-maxage=3600');
|
|
75
121
|
res.set('X-WAB-Snapshot-Schema', snap.schema);
|
|
122
|
+
res.set('X-WAB-Snapshot-Hash', snap.content_hash);
|
|
123
|
+
if (snap.signature) res.set('X-WAB-Snapshot-Signature', snap.signature.value);
|
|
76
124
|
res.json(snap);
|
|
77
125
|
});
|
|
78
126
|
|
|
@@ -83,6 +131,75 @@ router.get('/trusted-domains.txt', (req, res) => {
|
|
|
83
131
|
res.send(snap.domains.map(d => d.domain).join('\n') + '\n');
|
|
84
132
|
});
|
|
85
133
|
|
|
134
|
+
// ── Daily archive ────────────────────────────────────────────────────
|
|
135
|
+
|
|
136
|
+
function _listArchiveDates() {
|
|
137
|
+
try {
|
|
138
|
+
_ensureArchiveDir();
|
|
139
|
+
return fs.readdirSync(ARCHIVE_DIR)
|
|
140
|
+
.filter(f => /^\d{4}-\d{2}-\d{2}\.json$/.test(f))
|
|
141
|
+
.map(f => f.replace(/\.json$/, ''))
|
|
142
|
+
.sort();
|
|
143
|
+
} catch (_) { return []; }
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
router.get('/trusted-domains/archive.json', (req, res) => {
|
|
147
|
+
// Touch today's snapshot to ensure at least today is archived.
|
|
148
|
+
getSnapshot();
|
|
149
|
+
const dates = _listArchiveDates();
|
|
150
|
+
const manifest = {
|
|
151
|
+
schema: 'wab-trusted-domains-archive/v1',
|
|
152
|
+
generated_at: new Date().toISOString(),
|
|
153
|
+
total: dates.length,
|
|
154
|
+
snapshots: dates.map(d => ({
|
|
155
|
+
date: d,
|
|
156
|
+
url: '/api/trusted-domains/' + d + '.json',
|
|
157
|
+
})),
|
|
158
|
+
};
|
|
159
|
+
const sig = signer.sign(manifest);
|
|
160
|
+
if (sig) manifest.signature = { alg: signer.ALGORITHM, value: sig, key_url: '/api/operator-key.json' };
|
|
161
|
+
res.set('Cache-Control', 'public, max-age=3600, s-maxage=3600');
|
|
162
|
+
res.json(manifest);
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
router.get('/trusted-domains/:date.json', (req, res) => {
|
|
166
|
+
const date = req.params.date;
|
|
167
|
+
if (!/^\d{4}-\d{2}-\d{2}$/.test(date)) {
|
|
168
|
+
return res.status(400).json({ error: 'invalid_date', hint: 'Use YYYY-MM-DD.' });
|
|
169
|
+
}
|
|
170
|
+
// Serve today live (so a fresh boot doesn't return 404 before the first snapshot).
|
|
171
|
+
if (date === _todayUtc()) {
|
|
172
|
+
return res.json(getSnapshot());
|
|
173
|
+
}
|
|
174
|
+
_ensureArchiveDir();
|
|
175
|
+
const file = path.join(ARCHIVE_DIR, date + '.json');
|
|
176
|
+
if (!fs.existsSync(file)) {
|
|
177
|
+
return res.status(404).json({ error: 'snapshot_not_found', date });
|
|
178
|
+
}
|
|
179
|
+
res.set('Cache-Control', 'public, max-age=86400, s-maxage=86400, immutable');
|
|
180
|
+
res.type('application/json; charset=utf-8');
|
|
181
|
+
res.send(fs.readFileSync(file, 'utf8'));
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
// ── Operator public key ──────────────────────────────────────────────
|
|
185
|
+
|
|
186
|
+
router.get('/operator-key.json', (req, res) => {
|
|
187
|
+
const pub = signer.publicKey();
|
|
188
|
+
if (!pub) {
|
|
189
|
+
return res.status(503).json({ error: 'signing_not_configured' });
|
|
190
|
+
}
|
|
191
|
+
res.set('Cache-Control', 'public, max-age=86400, s-maxage=86400');
|
|
192
|
+
res.json({
|
|
193
|
+
schema: 'wab-operator-key/v1',
|
|
194
|
+
alg: signer.ALGORITHM,
|
|
195
|
+
public_key_b64: pub.b64,
|
|
196
|
+
jwk: pub.jwk,
|
|
197
|
+
issued_at: new Date().toISOString(),
|
|
198
|
+
notice: 'Use this key to verify signatures on /api/trusted-domains.json and /api/trusted-domains/*.json.',
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
|
|
86
203
|
// ── Revocation feeds ─────────────────────────────────────────────────
|
|
87
204
|
|
|
88
205
|
function listRecentRevocations(limit) {
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Operator signing service — Ed25519 + RFC 8785.
|
|
5
|
+
*
|
|
6
|
+
* Loads WAB_OPERATOR_ED25519_PRIV (PKCS8 base64-DER) once and exposes:
|
|
7
|
+
* sign(payload) — returns base64 Ed25519 signature over canonicalize(payload).
|
|
8
|
+
* publicKey() — returns the operator's public key as {b64, jwk} (raw 32-byte b64 + JWK).
|
|
9
|
+
* isConfigured() — whether a signing key is available.
|
|
10
|
+
* ALGORITHM — 'ed25519' constant.
|
|
11
|
+
*
|
|
12
|
+
* The same private key is already used by services/revocations.js to sign revocation
|
|
13
|
+
* decisions; this module unifies usage so other surfaces (snapshots, manifests) can
|
|
14
|
+
* sign with the same identity.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const crypto = require('crypto');
|
|
18
|
+
const { canonicalize } = require('./canonical-json');
|
|
19
|
+
|
|
20
|
+
const ALGORITHM = 'ed25519';
|
|
21
|
+
const PRIV_B64 = process.env.WAB_OPERATOR_ED25519_PRIV || '';
|
|
22
|
+
|
|
23
|
+
let _priv = null;
|
|
24
|
+
let _pub = null;
|
|
25
|
+
|
|
26
|
+
function _load() {
|
|
27
|
+
if (_priv || !PRIV_B64) return;
|
|
28
|
+
try {
|
|
29
|
+
const der = Buffer.from(PRIV_B64, 'base64');
|
|
30
|
+
_priv = crypto.createPrivateKey({ key: der, format: 'der', type: 'pkcs8' });
|
|
31
|
+
const pubKey = crypto.createPublicKey(_priv);
|
|
32
|
+
const rawDer = pubKey.export({ format: 'der', type: 'spki' });
|
|
33
|
+
// SPKI for Ed25519 is 44 bytes; raw key is the last 32.
|
|
34
|
+
const raw = rawDer.slice(-32);
|
|
35
|
+
_pub = {
|
|
36
|
+
b64: raw.toString('base64'),
|
|
37
|
+
jwk: {
|
|
38
|
+
kty: 'OKP',
|
|
39
|
+
crv: 'Ed25519',
|
|
40
|
+
x: raw.toString('base64url'),
|
|
41
|
+
alg: 'EdDSA',
|
|
42
|
+
use: 'sig',
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
} catch (e) {
|
|
46
|
+
console.warn('[operator-signer] key load failed (non-fatal):', e.message);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function isConfigured() {
|
|
51
|
+
_load();
|
|
52
|
+
return !!_priv;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function sign(payload) {
|
|
56
|
+
_load();
|
|
57
|
+
if (!_priv) return null;
|
|
58
|
+
try {
|
|
59
|
+
const sig = crypto.sign(null, Buffer.from(canonicalize(payload), 'utf8'), _priv);
|
|
60
|
+
return sig.toString('base64');
|
|
61
|
+
} catch (e) {
|
|
62
|
+
console.warn('[operator-signer] sign failed:', e.message);
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function publicKey() {
|
|
68
|
+
_load();
|
|
69
|
+
return _pub;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Verify a signature against a payload using the operator's public key.
|
|
74
|
+
* Returns true/false. Convenience helper for tests and self-verification.
|
|
75
|
+
*/
|
|
76
|
+
function verify(payload, signatureB64) {
|
|
77
|
+
_load();
|
|
78
|
+
if (!_pub) return false;
|
|
79
|
+
try {
|
|
80
|
+
const der = Buffer.from(PRIV_B64, 'base64');
|
|
81
|
+
const priv = crypto.createPrivateKey({ key: der, format: 'der', type: 'pkcs8' });
|
|
82
|
+
const pubKey = crypto.createPublicKey(priv);
|
|
83
|
+
return crypto.verify(
|
|
84
|
+
null,
|
|
85
|
+
Buffer.from(canonicalize(payload), 'utf8'),
|
|
86
|
+
pubKey,
|
|
87
|
+
Buffer.from(signatureB64, 'base64')
|
|
88
|
+
);
|
|
89
|
+
} catch (_) { return false; }
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
module.exports = {
|
|
93
|
+
ALGORITHM,
|
|
94
|
+
sign,
|
|
95
|
+
verify,
|
|
96
|
+
publicKey,
|
|
97
|
+
isConfigured,
|
|
98
|
+
};
|