openvibers/openvibe.network Commits
Grant the tools service billing.usage.record on the Billing audience
Changes
@@@ -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.@@@ -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' });
@@ -245,6 +245,8 @@ const DEFAULT_GRANTS = [
@@ -245,6 +245,8 @@ const DEFAULT_GRANTS = [
...['live', 'chat', 'community'].flatMap(c => ['tools.tool.run', 'tools.job.read'].map(cap => [c, cap, 'openvibe.tools', []])),
...['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 indexes its own tool pages in Search through the owner API (owner tools only).
['tools', 'search.document.write', 'openvibe.search', []],
['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.
// Grants withdrawn by decision; applied at every boot so an old default can't come back.
@@ -162,6 +162,8 @@ const server = http.createServer(app);
@@ -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();
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' });
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');
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).
// 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();
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' });
const cps = await token({ client_id: 'coupons', client_secret: 'coupons-secret', audience: 'openvibe.events', scope: 'events.subscription.manage' });