RuneStone 1.0.0

This commit is contained in:
Knotty Wyvern
2026-11-03 00:23:07 -07:00
commit 5557443ed1
818 changed files with 239368 additions and 0 deletions
+18
View File
@@ -0,0 +1,18 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { AgentController } from '../src/agent.mjs';
test('agent grants bind profile, tab, document and expiry', () => {
let now = 100;
const tabs = new Map([['a', { profileId: 'agent', epoch: 1 }], ['p', { profileId: 'personal', epoch: 1 }]]);
const agent = new AgentController(id => tabs.get(id), () => now);
assert.throws(() => agent.grant('p', 'agent'));
const token = agent.grant('a', 'agent');
assert.throws(() => agent.authorized(token, 'p'));
assert.equal(agent.authorized(token, 'a'), tabs.get('a'));
tabs.get('a').epoch++;
assert.throws(() => agent.authorized(token, 'a'));
const next = agent.grant('a', 'agent'); now += 300_001;
assert.throws(() => agent.authorized(next, 'a'));
const last = agent.grant('a', 'agent'); agent.revokeAll();
assert.throws(() => agent.authorized(last, 'a'));
});