ajp-protocol 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/publish.yml +33 -1
- package/README.md +52 -24
- package/cli/index.js +43 -26
- package/cli/package.json +18 -4
- package/examples/agent-to-agent/example.js +14 -11
- package/examples/orchestrator/example.js +1 -1
- package/package.json +5 -5
- package/spec/SPEC.md +44 -18
- package/src/client.js +18 -30
- package/src/index.js +6 -2
- package/src/server.js +55 -8
- package/src/trust.js +132 -49
- package/src/utils.js +38 -5
- package/test/resolution.test.mjs +117 -0
- package/test/trust.test.mjs +12 -3
package/test/trust.test.mjs
CHANGED
|
@@ -34,9 +34,18 @@ const resolve = declarationKeyResolver({ fetchText });
|
|
|
34
34
|
const ok1 = await resolve(ALICE, { declaration_url: ALICE_URL });
|
|
35
35
|
t('honest sender resolves offline', ok1.publicKey === alice.publicKey && !!ok1.fingerprint);
|
|
36
36
|
|
|
37
|
-
// 2. No declaration_url -> refused with a specific code.
|
|
38
|
-
try { await resolve(
|
|
39
|
-
catch (e) { t('
|
|
37
|
+
// 2. No declaration_url and no standard location -> refused with a specific code.
|
|
38
|
+
try { await resolve('provenance:npm:some-agent', {}); t('no declaration_url and no standard location refused', false); }
|
|
39
|
+
catch (e) { t('no declaration_url and no standard location refused', e.code === 'NO_DECLARATION_URL', e.code); }
|
|
40
|
+
|
|
41
|
+
// 2b. No declaration_url, but the id names a standard location -> that is fetched.
|
|
42
|
+
{
|
|
43
|
+
const std = 'https://raw.githubusercontent.com/alice/research-agent/HEAD/PROVENANCE.yml';
|
|
44
|
+
net.set(std, JSON.stringify(aliceDecl));
|
|
45
|
+
const r = await resolve(ALICE, {});
|
|
46
|
+
t('falls back to the standard location for its id', r.publicKey === alice.publicKey && r.source === std);
|
|
47
|
+
net.delete(std);
|
|
48
|
+
}
|
|
40
49
|
|
|
41
50
|
// 3. Impostor re-hosts Alice's genuine declaration on their own server.
|
|
42
51
|
const EVIL_URL = 'https://evil.example/copied/PROVENANCE.json';
|