@agenticprimitives/admission 0.0.0-alpha.23 → 0.0.0-alpha.24

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/dist/wimse.js ADDED
@@ -0,0 +1,90 @@
1
+ // The WIMSE identifier of an agent (spec 450 §5.1, `draft-ietf-wimse-identifier-04` §4).
2
+ //
3
+ // wimse://<trust-domain>/agent/eip155/<chainId>/<address, lower-case hex>
4
+ //
5
+ // A PROJECTION of the canonical address (ADR-0010), never an identity of its own: a pure function of the address
6
+ // and the trust domain of the estate that is the agent's Home. It is derived, never recorded on chain; a peer that
7
+ // holds it reads the address back out of its path. One spelling per agent: the address is lower-case hex (an EIP-55
8
+ // checksum would give a second spelling) and sits in its own path segments (no CAIP-10 colons for parsers to
9
+ // disagree about). The trust domain is app-supplied configuration — no package names one (ADR-0021).
10
+ //
11
+ // The parser REJECTS before it normalizes: userinfo, a port, a query, a fragment, an empty or dot segment, a
12
+ // percent-escape, or anything outside the grammar is refused, and only then are the scheme and the trust domain
13
+ // compared in lower case.
14
+ const LABEL = /^(?!-)[a-z0-9-]{1,63}(?<!-)$/;
15
+ const CHAIN_ID = /^[1-9][0-9]{0,31}$/;
16
+ const LOWER_ADDRESS = /^0x[0-9a-f]{40}$/;
17
+ const CAIP10_EIP155 = /^eip155:([0-9]+):(0x[0-9a-fA-F]{40})$/;
18
+ /**
19
+ * Is `td` a trust domain this profile accepts: an FQDN in A-label form (lower-case ASCII letters, digits and hyphens;
20
+ * at least two labels; each label 1–63 octets, no leading or trailing hyphen; ≤ 253 octets in all)? A U-label, an IP
21
+ * literal, a port, a trailing dot or any upper case is refused — the caller supplies the normalized form.
22
+ */
23
+ export function isWimseTrustDomain(td) {
24
+ if (typeof td !== 'string' || td.length === 0 || td.length > 253)
25
+ return false;
26
+ const labels = td.split('.');
27
+ if (labels.length < 2)
28
+ return false;
29
+ if (!labels.every((l) => LABEL.test(l)))
30
+ return false;
31
+ // The last label of a DNS name is not all digits; refusing it keeps IPv4 literals out.
32
+ return !/^[0-9]+$/.test(labels[labels.length - 1]);
33
+ }
34
+ /**
35
+ * The one WIMSE identifier of `agent` under `trustDomain`. `agent` is a CAIP-10 `eip155` id; any other namespace, or
36
+ * a trust domain this profile does not accept, throws — there is no lenient form.
37
+ */
38
+ export function workloadIdentifierFor(agent, trustDomain) {
39
+ const m = CAIP10_EIP155.exec(agent);
40
+ if (!m)
41
+ throw new TypeError('workloadIdentifierFor: the agent must be a CAIP-10 eip155 id (eip155:<chainId>:<address>)');
42
+ const chainId = m[1];
43
+ if (!CHAIN_ID.test(chainId))
44
+ throw new TypeError('workloadIdentifierFor: the chain id must be a decimal with no leading zero');
45
+ if (!isWimseTrustDomain(trustDomain))
46
+ throw new TypeError('workloadIdentifierFor: the trust domain must be a lower-case A-label FQDN');
47
+ return {
48
+ type: 'WimseIdentifier',
49
+ value: `wimse://${trustDomain}/agent/eip155/${chainId}/${m[2].toLowerCase()}`,
50
+ };
51
+ }
52
+ /**
53
+ * Read an agent's WIMSE identifier back to its trust domain and canonical agent id, or `null` when it is not one.
54
+ * Byte-for-byte comparison of two identifiers is valid only between values this function accepted.
55
+ */
56
+ export function parseWimseAgentIdentifier(value) {
57
+ if (typeof value !== 'string')
58
+ return null;
59
+ // Reject first (identifier-04 §7.1): characters a WIMSE agent identifier never carries.
60
+ if (/[?#@%\s\\]/.test(value))
61
+ return null;
62
+ const SCHEME = 'wimse://';
63
+ if (value.slice(0, SCHEME.length).toLowerCase() !== SCHEME)
64
+ return null;
65
+ const rest = value.slice(SCHEME.length);
66
+ const slash = rest.indexOf('/');
67
+ if (slash <= 0)
68
+ return null;
69
+ const authority = rest.slice(0, slash);
70
+ if (authority.includes(':'))
71
+ return null; // a port
72
+ const segments = rest.slice(slash + 1).split('/');
73
+ if (segments.length !== 4)
74
+ return null;
75
+ if (segments.some((s) => s === '' || s === '.' || s === '..'))
76
+ return null;
77
+ const [kind, namespace, chainId, address] = segments;
78
+ if (kind !== 'agent' || namespace !== 'eip155')
79
+ return null;
80
+ if (!CHAIN_ID.test(chainId))
81
+ return null;
82
+ if (!LOWER_ADDRESS.test(address))
83
+ return null; // one spelling: lower-case hex only
84
+ // Then normalize: the trust domain compares case-insensitively (a DNS name), and must be an A-label FQDN.
85
+ const trustDomain = authority.toLowerCase();
86
+ if (!isWimseTrustDomain(trustDomain))
87
+ return null;
88
+ return { trustDomain, agentId: `eip155:${chainId}:${address}`, chainId, address: address };
89
+ }
90
+ //# sourceMappingURL=wimse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wimse.js","sourceRoot":"","sources":["../src/wimse.ts"],"names":[],"mappings":"AAAA,yFAAyF;AACzF,EAAE;AACF,4EAA4E;AAC5E,EAAE;AACF,iHAAiH;AACjH,mHAAmH;AACnH,oHAAoH;AACpH,6GAA6G;AAC7G,qGAAqG;AACrG,EAAE;AACF,6GAA6G;AAC7G,gHAAgH;AAChH,0BAA0B;AAa1B,MAAM,KAAK,GAAG,8BAA8B,CAAC;AAC7C,MAAM,QAAQ,GAAG,oBAAoB,CAAC;AACtC,MAAM,aAAa,GAAG,kBAAkB,CAAC;AACzC,MAAM,aAAa,GAAG,uCAAuC,CAAC;AAE9D;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,EAAU;IAC3C,IAAI,OAAO,EAAE,KAAK,QAAQ,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,GAAG;QAAE,OAAO,KAAK,CAAC;IAC/E,MAAM,MAAM,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC7B,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,KAAK,CAAC;IACpC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAAE,OAAO,KAAK,CAAC;IACtD,uFAAuF;IACvF,OA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@agenticprimitives/admission",
3
- "version": "0.0.0-alpha.23",
3
+ "version": "0.0.0-alpha.24",
4
4
  "description": "Agentic Primitives Edge admission contracts: transport evidence, application authentication, canonical actor resolution, admission grants, and exact MCP invocation authorization. Zero runtime dependencies; admission is never authority.",
5
5
  "homepage": "https://agenticprimitives.dev",
6
6
  "bugs": {
@@ -35,8 +35,11 @@
35
35
  },
36
36
  "devDependencies": {
37
37
  "vitest": "^4.1.11",
38
- "@agenticprimitives/types": "1.0.0-alpha.49",
39
- "@agenticprimitives/estate-projection": "0.0.0-alpha.24"
38
+ "viem": "^2.52.2",
39
+ "@agenticprimitives/types": "1.0.0-alpha.50",
40
+ "@agenticprimitives/estate-projection": "0.0.0-alpha.25",
41
+ "@agenticprimitives/agent-profile": "1.0.0-alpha.50",
42
+ "@agenticprimitives/chain-state": "0.0.0-alpha.5"
40
43
  },
41
44
  "keywords": [
42
45
  "agentic",
@@ -52,7 +55,7 @@
52
55
  "agentic-trust"
53
56
  ],
54
57
  "peerDependencies": {
55
- "@agenticprimitives/types": "^1.0.0-alpha.49"
58
+ "@agenticprimitives/types": "^1.0.0-alpha.50"
56
59
  },
57
60
  "scripts": {
58
61
  "build": "tsc -p tsconfig.build.json",