@agimon-ai/po-network 0.0.2-alpha.10 → 0.0.2-alpha.100
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.
|
@@ -15,11 +15,7 @@ function validCapabilityOperations(value) {
|
|
|
15
15
|
if (!Array.isArray(value) || value.length > 3) return false;
|
|
16
16
|
const scopes = /* @__PURE__ */ new Set();
|
|
17
17
|
return value.every((operation) => {
|
|
18
|
-
if (!record(operation) || !
|
|
19
|
-
"global",
|
|
20
|
-
"workspace",
|
|
21
|
-
"session"
|
|
22
|
-
].includes(String(operation.scope))) return false;
|
|
18
|
+
if (!record(operation) || !_agimon_ai_po_core.FEDERATION_OPERATION_SCOPES.includes(String(operation.scope))) return false;
|
|
23
19
|
const scope = String(operation.scope);
|
|
24
20
|
if (scopes.has(scope)) return false;
|
|
25
21
|
scopes.add(scope);
|
|
@@ -32,6 +28,7 @@ function createCapabilityManifest(input) {
|
|
|
32
28
|
networkId: input.networkId,
|
|
33
29
|
packages: input.packages,
|
|
34
30
|
templates: input.templates,
|
|
31
|
+
...input.webPlugins === void 0 ? {} : { webPlugins: input.webPlugins },
|
|
35
32
|
issuedAt: input.now,
|
|
36
33
|
expiresAt: input.now + _agimon_ai_po_web_security_browser.FEDERATION_FRESHNESS.manifest
|
|
37
34
|
});
|
|
@@ -55,13 +52,27 @@ async function verifyCapabilityManifest(envelope, roster, now) {
|
|
|
55
52
|
if (!record(pkg) || !text(pkg.name) || names.has(pkg.name) || !text(pkg.version) || !fingerprint(pkg.contractFingerprint) || !validCapabilityOperations(pkg.operations)) return void 0;
|
|
56
53
|
names.add(pkg.name);
|
|
57
54
|
}
|
|
55
|
+
if (p.webPlugins !== void 0) {
|
|
56
|
+
if (!Array.isArray(p.webPlugins) || p.webPlugins.length > 1024) return void 0;
|
|
57
|
+
const pluginPackages = /* @__PURE__ */ new Set();
|
|
58
|
+
for (const plugin of p.webPlugins) {
|
|
59
|
+
if (!record(plugin) || !text(plugin.packageName) || !text(plugin.pluginId) || !fingerprint(plugin.fingerprint) || pluginPackages.has(plugin.packageName)) return void 0;
|
|
60
|
+
pluginPackages.add(plugin.packageName);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
58
63
|
const ids = /* @__PURE__ */ new Set();
|
|
59
64
|
for (const template of p.templates) {
|
|
60
65
|
if (!record(template) || !text(template.id) || ids.has(template.id) || !fingerprint(template.fingerprint)) return void 0;
|
|
61
66
|
ids.add(template.id);
|
|
62
67
|
}
|
|
63
68
|
if (!await (0, _agimon_ai_po_web_security_browser.verifyAttestation)(host.publicKey, "po/capabilities/v1", (0, _agimon_ai_po_web_security_browser.federationEnvelopeFields)(payload), envelope.signature)) return void 0;
|
|
64
|
-
return structuredClone(
|
|
69
|
+
return structuredClone({
|
|
70
|
+
...payload,
|
|
71
|
+
packages: payload.packages.map((pkg) => ({
|
|
72
|
+
...pkg,
|
|
73
|
+
operations: (0, _agimon_ai_po_core.normalizeFederationOperations)(pkg.operations)
|
|
74
|
+
}))
|
|
75
|
+
});
|
|
65
76
|
} catch {
|
|
66
77
|
return;
|
|
67
78
|
}
|
|
@@ -16,6 +16,7 @@ export declare function createCapabilityManifest(input: {
|
|
|
16
16
|
networkId: string;
|
|
17
17
|
packages: FederationCapabilities['packages'];
|
|
18
18
|
templates: FederationCapabilities['templates'];
|
|
19
|
+
webPlugins?: FederationCapabilities['webPlugins'];
|
|
19
20
|
now: number;
|
|
20
21
|
}): FederationCapabilities;
|
|
21
22
|
/** Advisory only. Always binds the signature to the current roster key. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { splitConsentOperations } from "@agimon-ai/po-core";
|
|
1
|
+
import { FEDERATION_OPERATION_SCOPES, normalizeFederationOperations, splitConsentOperations } from "@agimon-ai/po-core";
|
|
2
2
|
import { FEDERATION_FRESHNESS, federationEnvelopeFields, verifyAttestation } from "@agimon-ai/po-web-security/browser";
|
|
3
3
|
//#region src/services/capabilities.ts
|
|
4
4
|
function record(value) {
|
|
@@ -15,11 +15,7 @@ function validCapabilityOperations(value) {
|
|
|
15
15
|
if (!Array.isArray(value) || value.length > 3) return false;
|
|
16
16
|
const scopes = /* @__PURE__ */ new Set();
|
|
17
17
|
return value.every((operation) => {
|
|
18
|
-
if (!record(operation) || !
|
|
19
|
-
"global",
|
|
20
|
-
"workspace",
|
|
21
|
-
"session"
|
|
22
|
-
].includes(String(operation.scope))) return false;
|
|
18
|
+
if (!record(operation) || !FEDERATION_OPERATION_SCOPES.includes(String(operation.scope))) return false;
|
|
23
19
|
const scope = String(operation.scope);
|
|
24
20
|
if (scopes.has(scope)) return false;
|
|
25
21
|
scopes.add(scope);
|
|
@@ -32,6 +28,7 @@ function createCapabilityManifest(input) {
|
|
|
32
28
|
networkId: input.networkId,
|
|
33
29
|
packages: input.packages,
|
|
34
30
|
templates: input.templates,
|
|
31
|
+
...input.webPlugins === void 0 ? {} : { webPlugins: input.webPlugins },
|
|
35
32
|
issuedAt: input.now,
|
|
36
33
|
expiresAt: input.now + FEDERATION_FRESHNESS.manifest
|
|
37
34
|
});
|
|
@@ -55,13 +52,27 @@ async function verifyCapabilityManifest(envelope, roster, now) {
|
|
|
55
52
|
if (!record(pkg) || !text(pkg.name) || names.has(pkg.name) || !text(pkg.version) || !fingerprint(pkg.contractFingerprint) || !validCapabilityOperations(pkg.operations)) return void 0;
|
|
56
53
|
names.add(pkg.name);
|
|
57
54
|
}
|
|
55
|
+
if (p.webPlugins !== void 0) {
|
|
56
|
+
if (!Array.isArray(p.webPlugins) || p.webPlugins.length > 1024) return void 0;
|
|
57
|
+
const pluginPackages = /* @__PURE__ */ new Set();
|
|
58
|
+
for (const plugin of p.webPlugins) {
|
|
59
|
+
if (!record(plugin) || !text(plugin.packageName) || !text(plugin.pluginId) || !fingerprint(plugin.fingerprint) || pluginPackages.has(plugin.packageName)) return void 0;
|
|
60
|
+
pluginPackages.add(plugin.packageName);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
58
63
|
const ids = /* @__PURE__ */ new Set();
|
|
59
64
|
for (const template of p.templates) {
|
|
60
65
|
if (!record(template) || !text(template.id) || ids.has(template.id) || !fingerprint(template.fingerprint)) return void 0;
|
|
61
66
|
ids.add(template.id);
|
|
62
67
|
}
|
|
63
68
|
if (!await verifyAttestation(host.publicKey, "po/capabilities/v1", federationEnvelopeFields(payload), envelope.signature)) return void 0;
|
|
64
|
-
return structuredClone(
|
|
69
|
+
return structuredClone({
|
|
70
|
+
...payload,
|
|
71
|
+
packages: payload.packages.map((pkg) => ({
|
|
72
|
+
...pkg,
|
|
73
|
+
operations: normalizeFederationOperations(pkg.operations)
|
|
74
|
+
}))
|
|
75
|
+
});
|
|
65
76
|
} catch {
|
|
66
77
|
return;
|
|
67
78
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agimon-ai/po-network",
|
|
3
|
-
"version": "0.0.2-alpha.
|
|
3
|
+
"version": "0.0.2-alpha.100",
|
|
4
4
|
"description": "Host-neutral network election core and deterministic safety simulator.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -39,11 +39,11 @@
|
|
|
39
39
|
"access": "public"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@agimon-ai/po-core": "0.0.0-alpha.
|
|
43
|
-
"@agimon-ai/po-web-security": "0.0.0-alpha.
|
|
42
|
+
"@agimon-ai/po-core": "0.0.0-alpha.153",
|
|
43
|
+
"@agimon-ai/po-web-security": "0.0.0-alpha.153"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@agimon-ai/vibe-lint-plugin-po-core": "0.0.0-alpha.
|
|
46
|
+
"@agimon-ai/vibe-lint-plugin-po-core": "0.0.0-alpha.153",
|
|
47
47
|
"@types/node": "26.4.1",
|
|
48
48
|
"tsdown": "0.23.0",
|
|
49
49
|
"typescript": "7.0.2",
|