openvibers/openvibe.live Commits

agent.json: what an id in a Live address is and where it goes (AGT-4) (#598)

OP OpenVibers committed 10 days ago · c6fcb040fb · 2 files, +29 −0

policy.stableIds: /@{username} (a renamed channel's old name 301s to the current one; never a bare
/{username}), /vod/{id} and /clip/{id} (Media's ids, 301 to their watch pages on OpenVibe.Video,
whose manifest states the rule). The test ties the claims to page-status.js and video-url.js.

Changes

ddiff --git a/server/agent-descriptor.js b/server/agent-descriptor.js
iindex 4b9b6208..74ad5ee8 100644
---- a/server/agent-descriptor.js
++++ b/server/agent-descriptor.js
@@@ -14,5 +14,11 @@ module.exports = {
policy: {
auth: ['none', 'Network OIDC'],
rateLimit: '900 GET/HEAD API requests a minute per address, 180 writes; sign-in and registration attempts are limited to 20 per 15 minutes',
++ // What an id in a page's address is, and where it goes (AGT-4; server/web/page-status.js, video-handover.js).
++ stableIds: [
++ { kind: 'channel', url: 'https://openvibe.live/@{username}', id: 'the streamer\'s OpenVibe username (never a bare /{username}); a renamed channel\'s old name answers 301 to the current one', gone: 'a name no one has answers 404' },
++ { kind: 'recording', url: 'https://openvibe.live/vod/{id}', id: 'OpenVibe.Media\'s recording id; answers 301 to its watch page, https://openvibe.video/v/{id}, whose manifest has the rule' },
++ { kind: 'clip', url: 'https://openvibe.live/clip/{id}', id: 'OpenVibe.Media\'s clip id; answers 301 to https://openvibe.video/c/{id}' },
++ ],
},
};
ddiff --git a/test/agent-stable-ids.test.js b/test/agent-stable-ids.test.js
nnew file mode 100644
iindex 00000000..49ba2fa8
---- /dev/null
++++ b/test/agent-stable-ids.test.js
@@@ -0,0 +1,23 @@
++'use strict';
++// AGT-4: agent.json says what an id in a Live address is and where it goes, as the routes really behave.
++const assert = require('assert');
++const fs = require('fs');
++const path = require('path');
++const { agentManifest } = require('openvibe-shared/agent-layer');
++
++const m = agentManifest(require('../server/agent-descriptor'));
++const ids = m.policy.stableIds;
++assert.deepStrictEqual(ids.map((x) => [x.kind, x.url]), [
++ ['channel', 'https://openvibe.live/@{username}'],
++ ['recording', 'https://openvibe.live/vod/{id}'],
++ ['clip', 'https://openvibe.live/clip/{id}'],
++]);
++// The claims are the routes': a renamed channel's old name 301s to the current one, and a numeric VOD or clip id 301s
++// to OpenVibe.Video's watch page.
++const status = fs.readFileSync(path.join(__dirname, '..', 'server', 'web', 'page-status.js'), 'utf8');
++assert.match(status, /a renamed one's old name\s*\n\s*\*\s+answers 301 → \/@current/);
++assert.match(status, /\/vod\/:id\s+\/clip\/:id\s+a numeric id 301s to OpenVibe\.Video/);
++const { videoUrl } = require('../server/web/video-url');
++assert.strictEqual(videoUrl('vod', 12), 'https://openvibe.video/v/12');
++assert.strictEqual(videoUrl('clip', 12), 'https://openvibe.video/c/12');
++console.log('agent stable ids: ok');