openvibers/openvibe.network Commits
Network: grant the T18 principal actor.task.create (actor-task action) (#132)
Changes
@@@ -214,6 +214,9 @@ const DEFAULT_GRANTS = [// (a usr_ subject) to Network's user id, then pushes as app 'watch' (openvibe-sdk/notifications).['watch', 'identity.subject.resolve', SELF_AUDIENCE, []],['watch', 'network.notifications.push', SELF_AUDIENCE, ['watch']],++ // Plan T18 step 6: a watch's actor-task action gives Actor a task for the watch's owner. Watch names the owner in++ // X-OV-Subject, so the task is the person's (their allowance and list) and Actor records Watch as `via`.++ ['watch', 'actor.task.create', 'openvibe.actor', []],// Plan T13: OpenVibe.Services merges every authority's resource index (ADR-048 section 3): it reads each one's// GET /api/v1/resources under that authority's <id>.resource.read, with a token for that authority's audience.['services', 'network.resource.read', SELF_AUDIENCE, []],nnew file mode 100644@@@ -0,0 +1,25 @@++/**++ * OpenVibe.Watch's grants (plan T18): it publishes its events, resolves a watch's owner and pushes them a notification++ * (step 4), and gives Actor a task for the owner (step 6, audience openvibe.actor). Each capability it holds is one++ * the pinned contracts offer, active.++ *++ * node test/t18-grants.test.js++ */++'use strict';++const assert = require('assert');++const contracts = require('openvibe-contracts');++const principals = require('../server/identity/principals');++++const rows = principals.DEFAULT_GRANTS.filter((g) => g[0] === 'watch');++const held = new Set(rows.map((g) => `${g[1]}@${g[2]}`));++for (const want of [++ '[email protected]',++ '[email protected]',++ `identity.subject.resolve@${principals.SELF_AUDIENCE}`,++ `network.notifications.push@${principals.SELF_AUDIENCE}`,++]) assert.ok(held.has(want), `watch holds ${want}`);++for (const g of rows) {++ const cap = contracts.capabilities.get(g[1]);++ assert.ok(cap && cap.status === 'active', `${g[1]} is an active capability`);++}++console.log(`t18 grants: ${rows.length}`);
@@ -214,6 +214,9 @@ const DEFAULT_GRANTS = [
@@ -214,6 +214,9 @@ const DEFAULT_GRANTS = [
// (a usr_ subject) to Network's user id, then pushes as app 'watch' (openvibe-sdk/notifications).
// (a usr_ subject) to Network's user id, then pushes as app 'watch' (openvibe-sdk/notifications).
['watch', 'identity.subject.resolve', SELF_AUDIENCE, []],
['watch', 'identity.subject.resolve', SELF_AUDIENCE, []],
['watch', 'network.notifications.push', SELF_AUDIENCE, ['watch']],
['watch', 'network.notifications.push', SELF_AUDIENCE, ['watch']],
+ // Plan T18 step 6: a watch's actor-task action gives Actor a task for the watch's owner. Watch names the owner in
+ // X-OV-Subject, so the task is the person's (their allowance and list) and Actor records Watch as `via`.
+ ['watch', 'actor.task.create', 'openvibe.actor', []],
// Plan T13: OpenVibe.Services merges every authority's resource index (ADR-048 section 3): it reads each one's
// Plan T13: OpenVibe.Services merges every authority's resource index (ADR-048 section 3): it reads each one's
// GET /api/v1/resources under that authority's <id>.resource.read, with a token for that authority's audience.
// GET /api/v1/resources under that authority's <id>.resource.read, with a token for that authority's audience.
['services', 'network.resource.read', SELF_AUDIENCE, []],
['services', 'network.resource.read', SELF_AUDIENCE, []],
new file mode 100644
new file mode 100644
@@ -0,0 +1,25 @@
@@ -0,0 +1,25 @@
+/**
+ * OpenVibe.Watch's grants (plan T18): it publishes its events, resolves a watch's owner and pushes them a notification
+ * (step 4), and gives Actor a task for the owner (step 6, audience openvibe.actor). Each capability it holds is one
+ * the pinned contracts offer, active.
+ *
+ * node test/t18-grants.test.js
+ */
+'use strict';
+const assert = require('assert');
+const contracts = require('openvibe-contracts');
+const principals = require('../server/identity/principals');
+
+const rows = principals.DEFAULT_GRANTS.filter((g) => g[0] === 'watch');
+const held = new Set(rows.map((g) => `${g[1]}@${g[2]}`));
+for (const want of [
+ '[email protected]',
+ '[email protected]',
+ `identity.subject.resolve@${principals.SELF_AUDIENCE}`,
+ `network.notifications.push@${principals.SELF_AUDIENCE}`,
+]) assert.ok(held.has(want), `watch holds ${want}`);
+for (const g of rows) {
+ const cap = contracts.capabilities.get(g[1]);
+ assert.ok(cap && cap.status === 'active', `${g[1]} is an active capability`);
+}
+console.log(`t18 grants: ${rows.length}`);