openvibers/openvibe.network Commits

Grant the tools service billing.usage.record on the Billing audience

OP OpenVibers committed 4 Oct 2026 · 2a86229703 · 2 files, +4 −0

Asked: Follow-up of https://github.com/OpenVibers/OpenVibe.Tools/pull/11 (Post one Billing usage reading per ended tool job): its review asked for a change in OpenVibe.Network that the PR cannot make from OpenVibe.Tools. The review said: VERDICT: FIX
Harness job network-follow-up-of-https-github-com-op-165959.

Changes

ddiff --git a/server/identity/principals.js b/server/identity/principals.js
iindex 08b8a6fe..57df9a12 100644
---- a/server/identity/principals.js
++++ b/server/identity/principals.js
@@@ -245,6 +245,8 @@ const DEFAULT_GRANTS = [
...['live', 'chat', 'community'].flatMap(c => ['tools.tool.run', 'tools.job.read'].map(cap => [c, cap, 'openvibe.tools', []])),
// Tools indexes its own tool pages in Search through the owner API (owner tools only).
['tools', 'search.document.write', 'openvibe.search', []],
++ // Plan T5 step 7: Tools posts one usage reading per ended tool job to Billing (POST /api/v1/usage).
++ ['tools', 'billing.usage.record', 'openvibe.billing', []],
];
// Grants withdrawn by decision; applied at every boot so an old default can't come back.
ddiff --git a/test/principals.test.js b/test/principals.test.js
iindex 8fc7b1be..93b2c91e 100644
---- a/test/principals.test.js
++++ b/test/principals.test.js
@@@ -162,6 +162,8 @@ const server = http.createServer(app);
await db.prepare("UPDATE oauth_clients SET client_secret = 'tools-secret' WHERE client_id = 'tools'").run();
const ts = await token({ client_id: 'tools', client_secret: 'tools-secret', audience: 'openvibe.search' });
assert.strictEqual(ts.body.scope, 'search.document.write', 'Tools indexes its tools in Search');
++ const tb = await token({ client_id: 'tools', client_secret: 'tools-secret', audience: 'openvibe.billing' });
++ assert.strictEqual(tb.body.scope, 'billing.usage.record', 'Tools posts usage readings to Billing and holds no money capability');
// Coupons subscribes to its Events sources with its own token (OpenVibe.Coupons scripts/subscribe.js).
await db.prepare("UPDATE oauth_clients SET client_secret = 'coupons-secret' WHERE client_id = 'coupons'").run();
const cps = await token({ client_id: 'coupons', client_secret: 'coupons-secret', audience: 'openvibe.events', scope: 'events.subscription.manage' });