openvibers/openvibe.network Commits
Connect may publish its own events (CON-15 hooks) (#540)
Changes
@@@ -668,6 +668,9 @@ const DEFAULT_GRANTS = [// OpenVibe Connect (contracts 0.279.0, Website Connect v0): its account-event subscriptions at boot. It publishes// nothing yet; export and deletion are above.['connect', 'events.subscription.manage', 'openvibe.events', []],++ // Hooks that wait for your computer (CON-15, contracts 0.282.0): Connect publishes connect.hook.received, a++ // pointer to a webhook it keeps, and consumes it through its own subscription (retried up to seven days).++ ['connect', 'events.event.publish', 'openvibe.events', []],// "Tell me when it's back" (CON-17, 11-02): one notification, as app connect, to a person who asked when a share's// computer connects again. Nothing else of Network's notifications.['connect', 'network.notifications.push', SELF_AUDIENCE, ['connect']],nnew file mode 100644@@@ -0,0 +1,16 @@++/**++ * OpenVibe Connect's Events grants (CON-15, hooks that wait for your computer): Connect manages its own subscriptions++ * and publishes its own events (connect.hook.received, contracts 0.282.0), and holds nothing else of Events.++ *++ * node test/connect-hooks-grant.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] === 'connect' && g[2] === 'openvibe.events');++assert.deepStrictEqual(rows.map((g) => [g[1], g[3]]).sort(), [['events.event.publish', []], ['events.subscription.manage', []]], 'publish and its own subscriptions; never delivery admin or another service\'s reads');++const cap = contracts.capabilities.get('events.event.publish');++assert.ok(cap && cap.status === 'active', 'an active capability');++console.log('connect hooks grant: ok');
@@ -668,6 +668,9 @@ const DEFAULT_GRANTS = [
@@ -668,6 +668,9 @@ const DEFAULT_GRANTS = [
// OpenVibe Connect (contracts 0.279.0, Website Connect v0): its account-event subscriptions at boot. It publishes
// OpenVibe Connect (contracts 0.279.0, Website Connect v0): its account-event subscriptions at boot. It publishes
// nothing yet; export and deletion are above.
// nothing yet; export and deletion are above.
['connect', 'events.subscription.manage', 'openvibe.events', []],
['connect', 'events.subscription.manage', 'openvibe.events', []],
+ // Hooks that wait for your computer (CON-15, contracts 0.282.0): Connect publishes connect.hook.received, a
+ // pointer to a webhook it keeps, and consumes it through its own subscription (retried up to seven days).
+ ['connect', 'events.event.publish', 'openvibe.events', []],
// "Tell me when it's back" (CON-17, 11-02): one notification, as app connect, to a person who asked when a share's
// "Tell me when it's back" (CON-17, 11-02): one notification, as app connect, to a person who asked when a share's
// computer connects again. Nothing else of Network's notifications.
// computer connects again. Nothing else of Network's notifications.
['connect', 'network.notifications.push', SELF_AUDIENCE, ['connect']],
['connect', 'network.notifications.push', SELF_AUDIENCE, ['connect']],
new file mode 100644
new file mode 100644
@@ -0,0 +1,16 @@
@@ -0,0 +1,16 @@
+/**
+ * OpenVibe Connect's Events grants (CON-15, hooks that wait for your computer): Connect manages its own subscriptions
+ * and publishes its own events (connect.hook.received, contracts 0.282.0), and holds nothing else of Events.
+ *
+ * node test/connect-hooks-grant.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] === 'connect' && g[2] === 'openvibe.events');
+assert.deepStrictEqual(rows.map((g) => [g[1], g[3]]).sort(), [['events.event.publish', []], ['events.subscription.manage', []]], 'publish and its own subscriptions; never delivery admin or another service\'s reads');
+const cap = contracts.capabilities.get('events.event.publish');
+assert.ok(cap && cap.status === 'active', 'an active capability');
+console.log('connect hooks grant: ok');