@agenticprimitives/agent-naming 1.0.0-alpha.4 → 1.0.0-alpha.41
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/AUDIT.md +15 -4
- package/CLAUDE.md +40 -53
- package/README.md +57 -54
- package/dist/abis.d.ts +641 -0
- package/dist/abis.d.ts.map +1 -1
- package/dist/abis.js +96 -0
- package/dist/abis.js.map +1 -1
- package/dist/claim.d.ts +71 -0
- package/dist/claim.d.ts.map +1 -0
- package/dist/claim.js +73 -0
- package/dist/claim.js.map +1 -0
- package/dist/client.d.ts +36 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +197 -10
- package/dist/client.js.map +1 -1
- package/dist/constants.d.ts +55 -5
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +128 -4
- package/dist/constants.js.map +1 -1
- package/dist/custody.d.ts +54 -2
- package/dist/custody.d.ts.map +1 -1
- package/dist/custody.js +140 -4
- package/dist/custody.js.map +1 -1
- package/dist/dns.d.ts +91 -0
- package/dist/dns.d.ts.map +1 -0
- package/dist/dns.js +196 -0
- package/dist/dns.js.map +1 -0
- package/dist/federated.d.ts +31 -0
- package/dist/federated.d.ts.map +1 -0
- package/dist/federated.js +54 -0
- package/dist/federated.js.map +1 -0
- package/dist/grammar.d.ts +62 -0
- package/dist/grammar.d.ts.map +1 -0
- package/dist/grammar.js +165 -0
- package/dist/grammar.js.map +1 -0
- package/dist/hash.d.ts +14 -0
- package/dist/hash.d.ts.map +1 -0
- package/dist/hash.js +22 -0
- package/dist/hash.js.map +1 -0
- package/dist/index.d.ts +17 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -8
- package/dist/index.js.map +1 -1
- package/dist/issuance.d.ts +70 -0
- package/dist/issuance.d.ts.map +1 -0
- package/dist/issuance.js +65 -0
- package/dist/issuance.js.map +1 -0
- package/dist/label.d.ts +10 -0
- package/dist/label.d.ts.map +1 -0
- package/dist/label.js +39 -0
- package/dist/label.js.map +1 -0
- package/dist/namehash.d.ts +12 -24
- package/dist/namehash.d.ts.map +1 -1
- package/dist/namehash.js +13 -36
- package/dist/namehash.js.map +1 -1
- package/dist/normalize.d.ts +9 -17
- package/dist/normalize.d.ts.map +1 -1
- package/dist/normalize.js +11 -48
- package/dist/normalize.js.map +1 -1
- package/dist/price.d.ts +74 -0
- package/dist/price.d.ts.map +1 -0
- package/dist/price.js +58 -0
- package/dist/price.js.map +1 -0
- package/dist/records.d.ts +44 -3
- package/dist/records.d.ts.map +1 -1
- package/dist/records.js +203 -4
- package/dist/records.js.map +1 -1
- package/dist/types.d.ts +108 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/vertical.d.ts +43 -0
- package/dist/vertical.d.ts.map +1 -0
- package/dist/vertical.js +40 -0
- package/dist/vertical.js.map +1 -0
- package/docs/api.md +15 -3
- package/docs/concepts.md +1 -1
- package/docs/migration.md +1 -1
- package/package.json +24 -15
package/dist/custody.js
CHANGED
|
@@ -16,8 +16,14 @@
|
|
|
16
16
|
* walletClient submission on top.
|
|
17
17
|
*/
|
|
18
18
|
import { encodeFunctionData } from 'viem';
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
19
|
+
import { normalizeLabel } from './normalize.js';
|
|
20
|
+
import { agentNameAttributeResolverAbi, agentNameRegistryAbi, permissionlessSubregistryAbi, } from './abis.js';
|
|
21
|
+
import { PREDICATE_ID, AGENT_KIND_ID, AGENT_TYPE_ID, encodeAccounts } from './records.js';
|
|
22
|
+
import { agentProfileResolverTypeAbi } from './abis.js';
|
|
23
|
+
import { rootClassForDerivedType } from '@agenticprimitives/types';
|
|
24
|
+
import { parseAgentName } from './grammar.js';
|
|
25
|
+
import { ROLE_TYPED } from './claim.js';
|
|
26
|
+
import { derivedTypeForTld } from './constants.js';
|
|
21
27
|
// ─── Registry writes ───────────────────────────────────────────────
|
|
22
28
|
/**
|
|
23
29
|
* Build a call to register `<label>.<parent>` under the parent
|
|
@@ -25,6 +31,8 @@ import { PREDICATE_ID, AGENT_KIND_ID } from './records';
|
|
|
25
31
|
* delegate (msg.sender check on chain).
|
|
26
32
|
*/
|
|
27
33
|
export function buildRegisterSubnameCall(args) {
|
|
34
|
+
// AN-1: normalize + reject on the WRITE path (homoglyph/case/zero-width squat defense).
|
|
35
|
+
const label = normalizeLabel(args.label);
|
|
28
36
|
return {
|
|
29
37
|
to: args.registry,
|
|
30
38
|
value: 0n,
|
|
@@ -33,7 +41,7 @@ export function buildRegisterSubnameCall(args) {
|
|
|
33
41
|
functionName: 'register',
|
|
34
42
|
args: [
|
|
35
43
|
args.parentNode,
|
|
36
|
-
|
|
44
|
+
label,
|
|
37
45
|
args.newOwner,
|
|
38
46
|
args.resolver ?? '0x0000000000000000000000000000000000000000',
|
|
39
47
|
args.expiry ?? 0n,
|
|
@@ -118,6 +126,21 @@ export function buildSetStringAttributeCall(args) {
|
|
|
118
126
|
};
|
|
119
127
|
}
|
|
120
128
|
/** Build a typed `setAddressAttribute(node, predicate, value)` call. */
|
|
129
|
+
/**
|
|
130
|
+
* `string[]` attribute write (`atl:accounts` — spec 346 §3.8 / ap-federation spec 440 §C). The resolver validates the
|
|
131
|
+
* predicate's datatype on chain; the caller validates the VALUES with `encodeAccounts` first, as `buildRecordCalls` does.
|
|
132
|
+
*/
|
|
133
|
+
export function buildSetStringArrayAttributeCall(args) {
|
|
134
|
+
return {
|
|
135
|
+
to: args.resolver,
|
|
136
|
+
value: 0n,
|
|
137
|
+
data: encodeFunctionData({
|
|
138
|
+
abi: agentNameAttributeResolverAbi,
|
|
139
|
+
functionName: 'setStringArrayAttribute',
|
|
140
|
+
args: [args.node, args.predicate, [...args.values]],
|
|
141
|
+
}),
|
|
142
|
+
};
|
|
143
|
+
}
|
|
121
144
|
export function buildSetAddressAttributeCall(args) {
|
|
122
145
|
return {
|
|
123
146
|
to: args.resolver,
|
|
@@ -172,6 +195,21 @@ export function buildRecordCalls(args) {
|
|
|
172
195
|
if (records.mcpEndpoint !== undefined) {
|
|
173
196
|
out.push(buildSetStringAttributeCall({ resolver, node, predicate: PREDICATE_ID.mcpEndpoint, value: records.mcpEndpoint }));
|
|
174
197
|
}
|
|
198
|
+
if (records.appContext !== undefined) {
|
|
199
|
+
out.push(buildSetStringAttributeCall({ resolver, node, predicate: PREDICATE_ID.appContext, value: records.appContext }));
|
|
200
|
+
}
|
|
201
|
+
if (records.orgRole !== undefined) {
|
|
202
|
+
out.push(buildSetStringAttributeCall({ resolver, node, predicate: PREDICATE_ID.orgRole, value: records.orgRole }));
|
|
203
|
+
}
|
|
204
|
+
if (records.serviceUrl !== undefined) {
|
|
205
|
+
out.push(buildSetStringAttributeCall({ resolver, node, predicate: PREDICATE_ID.serviceUrl, value: records.serviceUrl }));
|
|
206
|
+
}
|
|
207
|
+
if (records.siteUrl !== undefined) {
|
|
208
|
+
out.push(buildSetStringAttributeCall({ resolver, node, predicate: PREDICATE_ID.siteUrl, value: records.siteUrl }));
|
|
209
|
+
}
|
|
210
|
+
if (records.description !== undefined) {
|
|
211
|
+
out.push(buildSetStringAttributeCall({ resolver, node, predicate: PREDICATE_ID.description, value: records.description }));
|
|
212
|
+
}
|
|
175
213
|
if (records.metadataUri !== undefined) {
|
|
176
214
|
out.push(buildSetStringAttributeCall({ resolver, node, predicate: PREDICATE_ID.metadataUri, value: records.metadataUri }));
|
|
177
215
|
}
|
|
@@ -187,6 +225,17 @@ export function buildRecordCalls(args) {
|
|
|
187
225
|
if (records.nativeId !== undefined) {
|
|
188
226
|
out.push(buildSetStringAttributeCall({ resolver, node, predicate: PREDICATE_ID.nativeId, value: records.nativeId }));
|
|
189
227
|
}
|
|
228
|
+
// One account per chain, CAIP-10, sorted — validated by `encodeAccounts` BEFORE any signature (mirrors `encodeRecords`).
|
|
229
|
+
if (records.accounts !== undefined) {
|
|
230
|
+
out.push(buildSetStringArrayAttributeCall({ resolver, node, predicate: PREDICATE_ID.accounts, values: encodeAccounts(records.accounts) }));
|
|
231
|
+
}
|
|
232
|
+
// spec 347 §8.3 — released A2A card publication records (mirrors `encodeRecords`).
|
|
233
|
+
if (records.cardDigest !== undefined) {
|
|
234
|
+
out.push(buildSetBytes32AttributeCall({ resolver, node, predicate: PREDICATE_ID.cardDigest, value: records.cardDigest }));
|
|
235
|
+
}
|
|
236
|
+
if (records.cardUri !== undefined) {
|
|
237
|
+
out.push(buildSetStringAttributeCall({ resolver, node, predicate: PREDICATE_ID.cardUri, value: records.cardUri }));
|
|
238
|
+
}
|
|
190
239
|
return out;
|
|
191
240
|
}
|
|
192
241
|
// ─── PermissionlessSubregistry ─────────────────────────────────────
|
|
@@ -201,14 +250,101 @@ export function buildRecordCalls(args) {
|
|
|
201
250
|
* has previously claimed a name through this subregistry instance.
|
|
202
251
|
*/
|
|
203
252
|
export function buildSubregistryRegisterCall(args) {
|
|
253
|
+
// AN-1: normalize + reject on the WRITE path (homoglyph/case/zero-width squat defense).
|
|
254
|
+
const label = normalizeLabel(args.label);
|
|
204
255
|
return {
|
|
205
256
|
to: args.subregistry,
|
|
206
257
|
value: 0n,
|
|
207
258
|
data: encodeFunctionData({
|
|
208
259
|
abi: permissionlessSubregistryAbi,
|
|
209
260
|
functionName: 'register',
|
|
210
|
-
args: [
|
|
261
|
+
args: [label, args.newOwner],
|
|
211
262
|
}),
|
|
212
263
|
};
|
|
213
264
|
}
|
|
265
|
+
// ─── Typed naming (spec 346) ────────────────────────────────────────
|
|
266
|
+
/**
|
|
267
|
+
* Step 1b of the bootstrap (spec 346 §3.6): declare the SA's derived type on its OWN profile subject.
|
|
268
|
+
* `msg.sender` MUST be the SA (`AgentProfileResolver.onlyAgent`) — compose these into the SA's execute
|
|
269
|
+
* batch. Registers the profile mirror first when `registered` is false (the typed setters require it),
|
|
270
|
+
* writing the ROOT kind there; then `atl:agentType` (+ `atl:serviceRole` when given, REQUIRED and equal
|
|
271
|
+
* to the type name for `workspace` and `registry`).
|
|
272
|
+
*/
|
|
273
|
+
export function buildDeclareAgentTypeCalls(args) {
|
|
274
|
+
if (ROLE_TYPED.has(args.agentType) && args.serviceRole !== args.agentType) {
|
|
275
|
+
throw new Error(`[agent-naming] ${args.agentType} requires serviceRole = '${args.agentType}'`);
|
|
276
|
+
}
|
|
277
|
+
const calls = [];
|
|
278
|
+
if (!args.registered) {
|
|
279
|
+
calls.push({
|
|
280
|
+
to: args.profileResolver,
|
|
281
|
+
value: 0n,
|
|
282
|
+
data: encodeFunctionData({
|
|
283
|
+
abi: agentProfileResolverTypeAbi,
|
|
284
|
+
functionName: 'register',
|
|
285
|
+
args: [args.agent, args.displayName ?? '', '', AGENT_KIND_ID[rootClassForDerivedType(args.agentType)], ''],
|
|
286
|
+
}),
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
calls.push({
|
|
290
|
+
to: args.profileResolver,
|
|
291
|
+
value: 0n,
|
|
292
|
+
data: encodeFunctionData({
|
|
293
|
+
abi: agentProfileResolverTypeAbi,
|
|
294
|
+
functionName: 'setBytes32Property',
|
|
295
|
+
args: [args.agent, PREDICATE_ID.agentType, AGENT_TYPE_ID[args.agentType]],
|
|
296
|
+
}),
|
|
297
|
+
});
|
|
298
|
+
if (args.serviceRole !== undefined) {
|
|
299
|
+
calls.push({
|
|
300
|
+
to: args.profileResolver,
|
|
301
|
+
value: 0n,
|
|
302
|
+
data: encodeFunctionData({
|
|
303
|
+
abi: agentProfileResolverTypeAbi,
|
|
304
|
+
functionName: 'setStringProperty',
|
|
305
|
+
args: [args.agent, PREDICATE_ID.serviceRole, args.serviceRole],
|
|
306
|
+
}),
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
if (args.subtype !== undefined) {
|
|
310
|
+
calls.push({
|
|
311
|
+
to: args.profileResolver,
|
|
312
|
+
value: 0n,
|
|
313
|
+
data: encodeFunctionData({
|
|
314
|
+
abi: agentProfileResolverTypeAbi,
|
|
315
|
+
functionName: 'setStringProperty',
|
|
316
|
+
args: [args.agent, PREDICATE_ID.agentSubtype, args.subtype],
|
|
317
|
+
}),
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
return calls;
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Steps 2–3 of the bootstrap for a CANONICAL (root-level) typed name (spec 346 §3.3): claim
|
|
324
|
+
* `<label>.<tld>` through that root's `PermissionlessSubregistry`, write the root kind + optional records
|
|
325
|
+
* on the new node, and set the primary name. The caller MUST have run `validateTypedClaim` (or
|
|
326
|
+
* `AgentNamingClient.checkTypedName`) — this builder only refuses a suffix/type disagreement it can see
|
|
327
|
+
* locally. `setPrimaryName` requires `msg.sender == owner`; the subregistry claim may be sent by anyone.
|
|
328
|
+
*/
|
|
329
|
+
export function buildTypedClaimCalls(args) {
|
|
330
|
+
const p = parseAgentName(args.name);
|
|
331
|
+
if (p.kind !== 'canonical') {
|
|
332
|
+
throw new Error(`[agent-naming] buildTypedClaimCalls handles canonical names only (got ${p.kind} "${p.normalized}")`);
|
|
333
|
+
}
|
|
334
|
+
const expected = derivedTypeForTld(p.handle.tld);
|
|
335
|
+
if (expected !== args.agentType) {
|
|
336
|
+
throw new Error(`[agent-naming] type_mismatch: ".${p.handle.tld}" names ${expected}, subject declares ${args.agentType}`);
|
|
337
|
+
}
|
|
338
|
+
const subregistry = args.subregistries[p.handle.tld];
|
|
339
|
+
if (!subregistry)
|
|
340
|
+
throw new Error(`[agent-naming] no PermissionlessSubregistry configured for ".${p.handle.tld}"`);
|
|
341
|
+
const claim = buildSubregistryRegisterCall({ subregistry, label: p.handle.label, newOwner: args.owner });
|
|
342
|
+
const records = buildRecordCalls({
|
|
343
|
+
resolver: args.resolver,
|
|
344
|
+
node: p.node,
|
|
345
|
+
records: { ...(args.records ?? {}), addr: args.owner, agentKind: rootClassForDerivedType(args.agentType) },
|
|
346
|
+
});
|
|
347
|
+
const primaryName = buildSetPrimaryNameCall({ registry: args.registry, node: p.node });
|
|
348
|
+
return { claim, records, primaryName, node: p.node };
|
|
349
|
+
}
|
|
214
350
|
//# sourceMappingURL=custody.js.map
|
package/dist/custody.js.map
CHAN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AAC,CAAC,MAAO,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;IAC1G,MAAM,OAAO,GAAG,gBAAgB,CAAC;QAC/B,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,IAAI,EAAE,CAAC,CAAC,IAAI;QACZ,OAAO,EAAE,EAAE,GAAG,CAAC,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,EAAE,SAAS,EAAE,uBAAuB,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;KAC3G,CAAC,CAAC;IACH,MAAM,WAAW,GAAG,uBAAuB,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IACvF,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;AACvD,CAAC"}
|
package/dist/dns.d.ts
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DNS subdomain + A2A endpoint convention (spec 346 §5) — a PURE projection of a handle onto a zone
|
|
3
|
+
* the caller supplies. No hostname, zone or provider is baked in (ADR-0021): packages own the two
|
|
4
|
+
* protocol paths; apps/deployments own the zone.
|
|
5
|
+
*
|
|
6
|
+
* | handle | host | rule |
|
|
7
|
+
* | richcanvas.org | richcanvas.org | org = zone apex |
|
|
8
|
+
* | rpedersen.me (ownsDomain) | rpedersen.me | the real .me domain |
|
|
9
|
+
* | rpedersen.me (hosted) | rpedersen.<homeZone> | <label>.<home-zone> |
|
|
10
|
+
* | rpedersen.me@richcanvas.org | rpedersen.richcanvas.org | <person-label>.<zone> — no type |
|
|
11
|
+
* | architecture.team@richcanvas.org | architecture-team.richcanvas.org | <label>-<type>.<zone> |
|
|
12
|
+
* | northern-colorado.team (root) | northern-colorado-team.<zone> | hosted under the registry/governor zone |
|
|
13
|
+
*
|
|
14
|
+
* THE TYPE IS A HYPHENATED SUFFIX ON ONE LABEL, NOT ITS OWN LABEL (changed 2026-08-30). A DNS wildcard
|
|
15
|
+
* matches exactly one label, so `<label>.<type>.<zone>` needs a wildcard per type — and a cert per type,
|
|
16
|
+
* which public CAs (Cloudflare Universal SSL included) do not issue below `*.zone` without a paid add-on.
|
|
17
|
+
* Every agent under a zone at `<label>-<type>.<zone>` is covered by the one `*.<zone>` wildcard the zone
|
|
18
|
+
* already has. Folding the type into the label instead of dropping it keeps two properties the dotted form
|
|
19
|
+
* had: the type is legible in the host, and the projection stays REVERSIBLE — `alice.me` and `alice.org`
|
|
20
|
+
* would both want `alice.<zone>` if the type were simply dropped, forcing an inbound host to guess which
|
|
21
|
+
* root it meant. Persons and legacy roots keep the bare `<label>.<zone>` form, so a label ending in
|
|
22
|
+
* `-<agent-type>` is refused for them at claim time (`validateTypedClaim`) — the ambiguity is removed by
|
|
23
|
+
* construction rather than resolved by precedence.
|
|
24
|
+
*
|
|
25
|
+
* The type in DNS is still a fixed projection of the suffix and is NEVER parsed as authority.
|
|
26
|
+
*/
|
|
27
|
+
import { type ParsedAgentName } from './grammar.js';
|
|
28
|
+
/** A2A JSON-RPC path (must equal `@agenticprimitives/a2a` `A2A_JSONRPC_PATH` — golden-vector tested, no import edge). */
|
|
29
|
+
export declare const A2A_JSONRPC_PATH: "/api/a2a";
|
|
30
|
+
/** A2A agent-card discovery path (origin-scoped — why every agent gets its own host). */
|
|
31
|
+
export declare const A2A_AGENT_CARD_PATH: "/.well-known/agent-card.json";
|
|
32
|
+
export interface DnsHostOptions {
|
|
33
|
+
/** The zone the context principal controls: an org apex (`richcanvas.org`) or a Home/registry zone. */
|
|
34
|
+
zone: string;
|
|
35
|
+
/** For hosted persons: the Home zone (e.g. `home.example`). Defaults to `zone`. */
|
|
36
|
+
homeZone?: string;
|
|
37
|
+
/** The person owns the real `.me` domain matching the handle — the host IS the handle. */
|
|
38
|
+
ownsDomain?: boolean;
|
|
39
|
+
}
|
|
40
|
+
/** Project a handle onto a DNS host per the §5 table. Root / type-node / legacy names have no host. */
|
|
41
|
+
export declare function dnsHostForHandle(name: string | ParsedAgentName, opts: DnsHostOptions): string;
|
|
42
|
+
/**
|
|
43
|
+
* The inverse of `dnsHostForHandle` for a hosted zone: `<label>-<type>.<zone>` → `<label>.<type>`, and a
|
|
44
|
+
* bare `<label>.<zone>` → null (a person/legacy label, whose root the deployment decides from its ordered
|
|
45
|
+
* root list). Pure; never guesses a type that is not in the closed suffix set.
|
|
46
|
+
*/
|
|
47
|
+
export declare function handleForDnsHost(host: string, zone: string): {
|
|
48
|
+
label: string;
|
|
49
|
+
tld: string;
|
|
50
|
+
name: string;
|
|
51
|
+
} | null;
|
|
52
|
+
export declare function agentCardUrlForHost(host: string): string;
|
|
53
|
+
export declare function a2aEndpointForHost(host: string): string;
|
|
54
|
+
/** Edge-addressed alternative (spec 346 §5): `POST <edge>/api/a2a/<handle>` when a zone cannot mint subdomains. */
|
|
55
|
+
export declare function edgeA2aPathForHandle(edgeBase: string, name: string | ParsedAgentName): string;
|
|
56
|
+
/**
|
|
57
|
+
* The single-label subdomain of `zone`: `alice.<zone>` → `alice`. The apex, deeper nesting, a non-matching host
|
|
58
|
+
* and any label in `exclude` (a Home passes `['www']`) → null. Port suffixes are ignored.
|
|
59
|
+
*/
|
|
60
|
+
export declare function parseSubdomainLabel(hostname: string | undefined, zone: string, exclude?: readonly string[]): string | null;
|
|
61
|
+
/** `<label>-<type>` → the typed name it projects (`alice-home-church` → `alice-home.church`), or null when the
|
|
62
|
+
* label carries no known type suffix. A CANDIDATE — the caller resolves it against the chain. */
|
|
63
|
+
export declare function typedNameForLabel(rest: string): string | null;
|
|
64
|
+
/**
|
|
65
|
+
* The inbound host → the name it projects, for the two shapes ONE base zone serves:
|
|
66
|
+
* `<label>.<zone>` → `<label>-<type>` reads as `<label>.<type>`; otherwise `<label>.<legacyParent>`
|
|
67
|
+
* `<label>.<type>.<zone>` → `<label>.<type>` — the dotted form served until 2026-08-30, kept because cards
|
|
68
|
+
* published under it carry that URL in signed bytes; nothing emits it (`hostForName`).
|
|
69
|
+
* The DNS label is returned RAW as `label`: a label may read BOTH ways (`alice-home-church` is `alice-home.church`
|
|
70
|
+
* and also the legacy `alice-home-church.<legacyParent>`), so the choice belongs to the caller, which resolves an
|
|
71
|
+
* ORDERED candidate set against the chain — one mechanism, ordered candidates, not a fallback (ADR-0013).
|
|
72
|
+
* Apex, deeper nesting, an unknown type level → null.
|
|
73
|
+
*/
|
|
74
|
+
export declare function parseTypedAgentHost(hostname: string | undefined, zone: string, legacyParent: string): {
|
|
75
|
+
label: string;
|
|
76
|
+
name: string;
|
|
77
|
+
} | null;
|
|
78
|
+
/**
|
|
79
|
+
* The inverse: the public host a deployment serves an on-chain name at. `<label>.<parent>` for any parent in
|
|
80
|
+
* `legacyParents` (the ordered person / legacy roots an estate serves — a list, because an estate mid-migration
|
|
81
|
+
* serves several) → `<label>.<zone>`; `<label>.<tld>` for any other agent type → `<label>-<tld>.<zone>`. Deeper or
|
|
82
|
+
* untyped → null (no host to publish at). A projection of the name, never authority.
|
|
83
|
+
*/
|
|
84
|
+
export declare function hostForName(name: string, zone: string, legacyParents: readonly string[]): string | null;
|
|
85
|
+
/**
|
|
86
|
+
* The on-chain name for an explicit handle (an edge path `POST /api/a2a/<handle>`, an injected subdomain header).
|
|
87
|
+
* A bare label is `<label>.<legacyParent>`; a typed handle (`x.t`, `x.t@c.u`, `c.u/x.t`) or a legacy dotted name
|
|
88
|
+
* is parsed by the grammar. Root and type-node forms name no subject → null. One grammar, no guessing.
|
|
89
|
+
*/
|
|
90
|
+
export declare function agentNameForHandle(handle: string, legacyParent: string): string | null;
|
|
91
|
+
//# sourceMappingURL=dns.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dns.d.ts","sourceRoot":"","sources":["../src/dns.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;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gB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAU5I;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,GAAG,IAAI,CAOvG;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAWtF"}
|
package/dist/dns.js
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DNS subdomain + A2A endpoint convention (spec 346 §5) — a PURE projection of a handle onto a zone
|
|
3
|
+
* the caller supplies. No hostname, zone or provider is baked in (ADR-0021): packages own the two
|
|
4
|
+
* protocol paths; apps/deployments own the zone.
|
|
5
|
+
*
|
|
6
|
+
* | handle | host | rule |
|
|
7
|
+
* | richcanvas.org | richcanvas.org | org = zone apex |
|
|
8
|
+
* | rpedersen.me (ownsDomain) | rpedersen.me | the real .me domain |
|
|
9
|
+
* | rpedersen.me (hosted) | rpedersen.<homeZone> | <label>.<home-zone> |
|
|
10
|
+
* | rpedersen.me@richcanvas.org | rpedersen.richcanvas.org | <person-label>.<zone> — no type |
|
|
11
|
+
* | architecture.team@richcanvas.org | architecture-team.richcanvas.org | <label>-<type>.<zone> |
|
|
12
|
+
* | northern-colorado.team (root) | northern-colorado-team.<zone> | hosted under the registry/governor zone |
|
|
13
|
+
*
|
|
14
|
+
* THE TYPE IS A HYPHENATED SUFFIX ON ONE LABEL, NOT ITS OWN LABEL (changed 2026-08-30). A DNS wildcard
|
|
15
|
+
* matches exactly one label, so `<label>.<type>.<zone>` needs a wildcard per type — and a cert per type,
|
|
16
|
+
* which public CAs (Cloudflare Universal SSL included) do not issue below `*.zone` without a paid add-on.
|
|
17
|
+
* Every agent under a zone at `<label>-<type>.<zone>` is covered by the one `*.<zone>` wildcard the zone
|
|
18
|
+
* already has. Folding the type into the label instead of dropping it keeps two properties the dotted form
|
|
19
|
+
* had: the type is legible in the host, and the projection stays REVERSIBLE — `alice.me` and `alice.org`
|
|
20
|
+
* would both want `alice.<zone>` if the type were simply dropped, forcing an inbound host to guess which
|
|
21
|
+
* root it meant. Persons and legacy roots keep the bare `<label>.<zone>` form, so a label ending in
|
|
22
|
+
* `-<agent-type>` is refused for them at claim time (`validateTypedClaim`) — the ambiguity is removed by
|
|
23
|
+
* construction rather than resolved by precedence.
|
|
24
|
+
*
|
|
25
|
+
* The type in DNS is still a fixed projection of the suffix and is NEVER parsed as authority.
|
|
26
|
+
*/
|
|
27
|
+
import { parseAgentName } from './grammar.js';
|
|
28
|
+
import { allAgentTlds, derivedTypeForTld, isAgentTld } from './constants.js';
|
|
29
|
+
import { InvalidNameError } from './errors.js';
|
|
30
|
+
/** A2A JSON-RPC path (must equal `@agenticprimitives/a2a` `A2A_JSONRPC_PATH` — golden-vector tested, no import edge). */
|
|
31
|
+
export const A2A_JSONRPC_PATH = '/api/a2a';
|
|
32
|
+
/** A2A agent-card discovery path (origin-scoped — why every agent gets its own host). */
|
|
33
|
+
export const A2A_AGENT_CARD_PATH = '/.well-known/agent-card.json';
|
|
34
|
+
const HOSTNAME_RE = /^(?=.{1,253}$)([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z][a-z0-9-]{0,62}$/;
|
|
35
|
+
function assertZone(zone, what) {
|
|
36
|
+
const z = zone.trim().toLowerCase().replace(/\.$/, '');
|
|
37
|
+
if (!HOSTNAME_RE.test(z))
|
|
38
|
+
throw new InvalidNameError(zone, `${what} must be a DNS zone (got "${zone}")`);
|
|
39
|
+
return z;
|
|
40
|
+
}
|
|
41
|
+
/** Project a handle onto a DNS host per the §5 table. Root / type-node / legacy names have no host. */
|
|
42
|
+
export function dnsHostForHandle(name, opts) {
|
|
43
|
+
const p = typeof name === 'string' ? parseAgentName(name) : name;
|
|
44
|
+
const zone = assertZone(opts.zone, 'zone');
|
|
45
|
+
if (p.kind !== 'canonical' && p.kind !== 'scoped') {
|
|
46
|
+
throw new InvalidNameError(p.normalized, `no DNS host for a ${p.kind} name`);
|
|
47
|
+
}
|
|
48
|
+
const { label, tld } = p.handle;
|
|
49
|
+
const type = p.derivedType;
|
|
50
|
+
if (p.kind === 'canonical') {
|
|
51
|
+
if (type === 'org')
|
|
52
|
+
return zone;
|
|
53
|
+
if (type === 'person') {
|
|
54
|
+
if (opts.ownsDomain)
|
|
55
|
+
return `${label}.${tld}`;
|
|
56
|
+
return `${label}.${assertZone(opts.homeZone ?? opts.zone, 'homeZone')}`;
|
|
57
|
+
}
|
|
58
|
+
return `${label}-${tld}.${zone}`;
|
|
59
|
+
}
|
|
60
|
+
// scoped / contextual
|
|
61
|
+
if (type === 'person')
|
|
62
|
+
return `${label}.${zone}`;
|
|
63
|
+
return `${label}-${tld}.${zone}`;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* The inverse of `dnsHostForHandle` for a hosted zone: `<label>-<type>.<zone>` → `<label>.<type>`, and a
|
|
67
|
+
* bare `<label>.<zone>` → null (a person/legacy label, whose root the deployment decides from its ordered
|
|
68
|
+
* root list). Pure; never guesses a type that is not in the closed suffix set.
|
|
69
|
+
*/
|
|
70
|
+
export function handleForDnsHost(host, zone) {
|
|
71
|
+
const h = host.trim().toLowerCase().replace(/\.$/, '');
|
|
72
|
+
const z = zone.trim().toLowerCase().replace(/\.$/, '');
|
|
73
|
+
if (!h.endsWith(`.${z}`))
|
|
74
|
+
return null;
|
|
75
|
+
const rest = h.slice(0, h.length - z.length - 1);
|
|
76
|
+
if (!rest || rest.includes('.'))
|
|
77
|
+
return null;
|
|
78
|
+
for (const tld of allAgentTlds()) {
|
|
79
|
+
const suffix = `-${tld}`;
|
|
80
|
+
if (rest.endsWith(suffix) && rest.length > suffix.length) {
|
|
81
|
+
const label = rest.slice(0, -suffix.length);
|
|
82
|
+
const canonical = derivedTypeForTld(tld) === null ? tld : tld;
|
|
83
|
+
return { label, tld: canonical, name: `${label}.${canonical}` };
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
export function agentCardUrlForHost(host) {
|
|
89
|
+
return `https://${assertZone(host, 'host')}${A2A_AGENT_CARD_PATH}`;
|
|
90
|
+
}
|
|
91
|
+
export function a2aEndpointForHost(host) {
|
|
92
|
+
return `https://${assertZone(host, 'host')}${A2A_JSONRPC_PATH}`;
|
|
93
|
+
}
|
|
94
|
+
/** Edge-addressed alternative (spec 346 §5): `POST <edge>/api/a2a/<handle>` when a zone cannot mint subdomains. */
|
|
95
|
+
export function edgeA2aPathForHandle(edgeBase, name) {
|
|
96
|
+
const p = typeof name === 'string' ? parseAgentName(name) : name;
|
|
97
|
+
if (p.kind !== 'canonical' && p.kind !== 'scoped') {
|
|
98
|
+
throw new InvalidNameError(p.normalized, `no edge path for a ${p.kind} name`);
|
|
99
|
+
}
|
|
100
|
+
return `${edgeBase.replace(/\/+$/, '')}${A2A_JSONRPC_PATH}/${p.normalized}`;
|
|
101
|
+
}
|
|
102
|
+
// ── The deployment-zone projection (spec 346 §5, promoted from the agent runtime's host-context in spec 399
|
|
103
|
+
// §4): a Home and its runtime both serve names under ONE base zone and both had a copy of these — the Card
|
|
104
|
+
// Studio's "MUST match hostForName in demo-a2a" comment was the two-literal drift this closes. Every zone, root
|
|
105
|
+
// and parent is a PARAMETER; the deployment binds its own (ADR-0021). None of these is authority: a host is a
|
|
106
|
+
// projection of a name, and an inbound label is a CANDIDATE the caller resolves against the chain. ──────────
|
|
107
|
+
/**
|
|
108
|
+
* The single-label subdomain of `zone`: `alice.<zone>` → `alice`. The apex, deeper nesting, a non-matching host
|
|
109
|
+
* and any label in `exclude` (a Home passes `['www']`) → null. Port suffixes are ignored.
|
|
110
|
+
*/
|
|
111
|
+
export function parseSubdomainLabel(hostname, zone, exclude = []) {
|
|
112
|
+
if (!hostname)
|
|
113
|
+
return null;
|
|
114
|
+
const host = (hostname.split(':')[0] ?? '').toLowerCase();
|
|
115
|
+
const base = zone.trim().toLowerCase().replace(/\.$/, '');
|
|
116
|
+
if (host === base || !host.endsWith('.' + base))
|
|
117
|
+
return null;
|
|
118
|
+
const label = host.slice(0, host.length - base.length - 1);
|
|
119
|
+
if (!label || label.includes('.') || exclude.includes(label))
|
|
120
|
+
return null;
|
|
121
|
+
return label;
|
|
122
|
+
}
|
|
123
|
+
/** `<label>-<type>` → the typed name it projects (`alice-home-church` → `alice-home.church`), or null when the
|
|
124
|
+
* label carries no known type suffix. A CANDIDATE — the caller resolves it against the chain. */
|
|
125
|
+
export function typedNameForLabel(rest) {
|
|
126
|
+
for (const tld of allAgentTlds()) {
|
|
127
|
+
const suffix = `-${tld}`;
|
|
128
|
+
if (rest.endsWith(suffix) && rest.length > suffix.length)
|
|
129
|
+
return `${rest.slice(0, -suffix.length)}.${tld}`;
|
|
130
|
+
}
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* The inbound host → the name it projects, for the two shapes ONE base zone serves:
|
|
135
|
+
* `<label>.<zone>` → `<label>-<type>` reads as `<label>.<type>`; otherwise `<label>.<legacyParent>`
|
|
136
|
+
* `<label>.<type>.<zone>` → `<label>.<type>` — the dotted form served until 2026-08-30, kept because cards
|
|
137
|
+
* published under it carry that URL in signed bytes; nothing emits it (`hostForName`).
|
|
138
|
+
* The DNS label is returned RAW as `label`: a label may read BOTH ways (`alice-home-church` is `alice-home.church`
|
|
139
|
+
* and also the legacy `alice-home-church.<legacyParent>`), so the choice belongs to the caller, which resolves an
|
|
140
|
+
* ORDERED candidate set against the chain — one mechanism, ordered candidates, not a fallback (ADR-0013).
|
|
141
|
+
* Apex, deeper nesting, an unknown type level → null.
|
|
142
|
+
*/
|
|
143
|
+
export function parseTypedAgentHost(hostname, zone, legacyParent) {
|
|
144
|
+
if (!hostname)
|
|
145
|
+
return null;
|
|
146
|
+
const host = (hostname.split(':')[0] ?? '').toLowerCase();
|
|
147
|
+
const base = zone.trim().toLowerCase().replace(/\.$/, '');
|
|
148
|
+
if (host === base || !host.endsWith('.' + base))
|
|
149
|
+
return null;
|
|
150
|
+
const rest = host.slice(0, host.length - base.length - 1);
|
|
151
|
+
const parts = rest.split('.');
|
|
152
|
+
if (parts.length === 1 && parts[0])
|
|
153
|
+
return { label: parts[0], name: typedNameForLabel(parts[0]) ?? `${parts[0]}.${legacyParent}` };
|
|
154
|
+
if (parts.length === 2 && parts[0] && isAgentTld(parts[1]))
|
|
155
|
+
return { label: `${parts[0]}.${parts[1]}`, name: `${parts[0]}.${parts[1]}` };
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* The inverse: the public host a deployment serves an on-chain name at. `<label>.<parent>` for any parent in
|
|
160
|
+
* `legacyParents` (the ordered person / legacy roots an estate serves — a list, because an estate mid-migration
|
|
161
|
+
* serves several) → `<label>.<zone>`; `<label>.<tld>` for any other agent type → `<label>-<tld>.<zone>`. Deeper or
|
|
162
|
+
* untyped → null (no host to publish at). A projection of the name, never authority.
|
|
163
|
+
*/
|
|
164
|
+
export function hostForName(name, zone, legacyParents) {
|
|
165
|
+
const parts = name.trim().toLowerCase().split('.');
|
|
166
|
+
if (parts.length !== 2 || !parts[0] || !parts[1])
|
|
167
|
+
return null;
|
|
168
|
+
const [label, tld] = parts;
|
|
169
|
+
if (legacyParents.includes(tld))
|
|
170
|
+
return `${label}.${zone}`;
|
|
171
|
+
if (isAgentTld(tld))
|
|
172
|
+
return `${label}-${tld}.${zone}`;
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* The on-chain name for an explicit handle (an edge path `POST /api/a2a/<handle>`, an injected subdomain header).
|
|
177
|
+
* A bare label is `<label>.<legacyParent>`; a typed handle (`x.t`, `x.t@c.u`, `c.u/x.t`) or a legacy dotted name
|
|
178
|
+
* is parsed by the grammar. Root and type-node forms name no subject → null. One grammar, no guessing.
|
|
179
|
+
*/
|
|
180
|
+
export function agentNameForHandle(handle, legacyParent) {
|
|
181
|
+
const h = handle.trim().toLowerCase();
|
|
182
|
+
if (!h)
|
|
183
|
+
return null;
|
|
184
|
+
if (!h.includes('.') && !h.includes('@') && !h.includes('/'))
|
|
185
|
+
return `${h}.${legacyParent}`;
|
|
186
|
+
try {
|
|
187
|
+
const p = parseAgentName(h);
|
|
188
|
+
return p.kind === 'canonical' || p.kind === 'scoped' || p.kind === 'legacy' ? p.normalized : null;
|
|
189
|
+
}
|
|
190
|
+
catch (e) {
|
|
191
|
+
if (e instanceof InvalidNameError)
|
|
192
|
+
return null;
|
|
193
|
+
throw e;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
//# sourceMappingURL=dns.js.map
|
package/dist/dns.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dns.js","sourceRoot":"","sources":["../src/dns.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,EAAE,cAAc,EAAwB,MAAM,cAAc,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,yHAAyH;AACzH,MAAM,CAAC,MAAM,gBAAgB,GAAG,UAAmB,CAAC;AACpD,yFAAyF;AACzF,MAAM,CAAC,MAAM,mBAAmB,GAAG,8BAAuC,CAAC;AAW3E,MAAM,WAAW,GAAG,4EAA4E,CAAC;AAEjG,SAAS,UAAU,CAAC,IAAY,EAAE,IAAY;IAC5C,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,OAAO,CA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/** CAIP-2 for an EVM chain: `eip155:<chainId>`. */
|
|
2
|
+
export type Caip2Chain = `eip155:${number}`;
|
|
3
|
+
export interface FederatedAgentNameV1 {
|
|
4
|
+
type: 'FederatedAgentNameV1';
|
|
5
|
+
/** The canonical display form the grammar produces (`alice.me`, `vault.svc@richcanvas.org`). */
|
|
6
|
+
name: string;
|
|
7
|
+
/** The chain of the registry that holds the name (CAIP-2). */
|
|
8
|
+
chain: Caip2Chain;
|
|
9
|
+
}
|
|
10
|
+
export declare const caip2ForChainId: (chainId: number) => Caip2Chain;
|
|
11
|
+
export declare function chainIdOfCaip2(chain: string): number;
|
|
12
|
+
/**
|
|
13
|
+
* Build the pair. The name is parsed (so a chain written into it, a reserved label or an unknown suffix is
|
|
14
|
+
* refused with the grammar's own reason) and normalized to its canonical display form.
|
|
15
|
+
*/
|
|
16
|
+
export declare function federatedAgentName(name: string, chainId: number): FederatedAgentNameV1;
|
|
17
|
+
export interface DisplayAgentNameOptions {
|
|
18
|
+
/** The chain the viewer is standing in. Absent = no town (a federation surface): always qualified. */
|
|
19
|
+
viewerChainId?: number;
|
|
20
|
+
/** A human label for the name's town, when the caller knows it (`faithchain`). Shown beside the chain. */
|
|
21
|
+
townLabel?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The never-bare rule. `alice.me` inside its home chain; `alice.me · faithchain (eip155:34348)` anywhere else.
|
|
25
|
+
* The separator is a middle dot so the result can never be re-parsed as a name (a dot-handle never contains
|
|
26
|
+
* spaces), which is the point: a qualified display is for eyes, not for `parseAgentName`.
|
|
27
|
+
*/
|
|
28
|
+
export declare function displayAgentName(ref: FederatedAgentNameV1, opts?: DisplayAgentNameOptions): string;
|
|
29
|
+
/** Two references name the same record iff both halves agree. A label alone never does (naming doc N4). */
|
|
30
|
+
export declare function sameFederatedName(a: FederatedAgentNameV1, b: FederatedAgentNameV1): boolean;
|
|
31
|
+
//# sourceMappingURL=federated.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"federated.d.ts","sourceRoot":"","sources":["../src/federated.ts"],"names":[],"mappings":"AAkBA,mDAAmD;AACnD,MAAM,MAAM,UAAU,GAAG,UAAU,MAAM,EAAE,CAAC;AAE5C,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,sBAAsB,CAAC;IAC7B,gGAAgG;IAChG,IAAI,EAAE,MAAM,CAAC;IACb,8DAA8D;IAC9D,KAAK,EAAE,UAAU,CAAC;CACnB;AAED,eAAO,MAAM,eAAe,YAAa,MAAM,KAAG,UAGjD,CAAC;AAEF,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAIpD;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,oBAAoB,CAItF;AAED,MAAM,WAAW,uBAAuB;IACtC,sGAAsG;IACtG,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,0GAA0G;IAC1G,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,oBAAoB,EAAE,IAAI,GAAE,uBAA4B,GAAG,MAAM,CAItG;AAED,2GAA2G;AAC3G,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,oBAAoB,EAAE,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAE3F"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The federated reference (ap-federation spec 440 §C / naming doc N4; spec 346 §3.7). PURE — no I/O.
|
|
3
|
+
*
|
|
4
|
+
* A name that crosses a town boundary travels as the PAIR { name, chain }: the typed handle exactly as the
|
|
5
|
+
* grammar accepts it, and the CAIP-2 chain of the registry that holds it. The chain is a RECORD beside the
|
|
6
|
+
* name and never a component of it — `alice.me@faithchain` is refused by the grammar (`@` means context,
|
|
7
|
+
* spec 346 §3), and ERC-7828's `name@chain` was refused for the same reason (Ring 0 chains-and-estates §5.1).
|
|
8
|
+
*
|
|
9
|
+
* The display rule: inside its home chain a handle is bare; anywhere else it carries its chain (and the
|
|
10
|
+
* town's label when the caller supplies one). A viewer that is in no town — a federation site, a log, a
|
|
11
|
+
* receipt — prints every name qualified. This is ENSIP-19's rule (show a primary name only where it round
|
|
12
|
+
* trips) and the petname-system rule (a label you did not issue is shown with its issuer) applied to towns.
|
|
13
|
+
*
|
|
14
|
+
* Nothing here resolves anything: the pair is a reference, the display is a string, and neither is authority.
|
|
15
|
+
*/
|
|
16
|
+
import { parseAgentName, formatAgentName } from './grammar.js';
|
|
17
|
+
import { InvalidNameError } from './errors.js';
|
|
18
|
+
export const caip2ForChainId = (chainId) => {
|
|
19
|
+
if (!Number.isInteger(chainId) || chainId <= 0)
|
|
20
|
+
throw new InvalidNameError(String(chainId), 'chain_id: a positive integer chain id');
|
|
21
|
+
return `eip155:${chainId}`;
|
|
22
|
+
};
|
|
23
|
+
export function chainIdOfCaip2(chain) {
|
|
24
|
+
const m = /^eip155:(\d+)$/.exec(chain);
|
|
25
|
+
if (!m)
|
|
26
|
+
throw new InvalidNameError(chain, 'caip2: expected eip155:<chainId>');
|
|
27
|
+
return Number(m[1]);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Build the pair. The name is parsed (so a chain written into it, a reserved label or an unknown suffix is
|
|
31
|
+
* refused with the grammar's own reason) and normalized to its canonical display form.
|
|
32
|
+
*/
|
|
33
|
+
export function federatedAgentName(name, chainId) {
|
|
34
|
+
const p = parseAgentName(name);
|
|
35
|
+
if (p.kind === 'root' || p.kind === 'type-node')
|
|
36
|
+
throw new InvalidNameError(name, `not_a_handle: a ${p.kind} node is not an agent's name`);
|
|
37
|
+
return { type: 'FederatedAgentNameV1', name: formatAgentName(p), chain: caip2ForChainId(chainId) };
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The never-bare rule. `alice.me` inside its home chain; `alice.me · faithchain (eip155:34348)` anywhere else.
|
|
41
|
+
* The separator is a middle dot so the result can never be re-parsed as a name (a dot-handle never contains
|
|
42
|
+
* spaces), which is the point: a qualified display is for eyes, not for `parseAgentName`.
|
|
43
|
+
*/
|
|
44
|
+
export function displayAgentName(ref, opts = {}) {
|
|
45
|
+
const home = opts.viewerChainId !== undefined && caip2ForChainId(opts.viewerChainId) === ref.chain;
|
|
46
|
+
if (home)
|
|
47
|
+
return ref.name;
|
|
48
|
+
return opts.townLabel ? `${ref.name} · ${opts.townLabel} (${ref.chain})` : `${ref.name} · ${ref.chain}`;
|
|
49
|
+
}
|
|
50
|
+
/** Two references name the same record iff both halves agree. A label alone never does (naming doc N4). */
|
|
51
|
+
export function sameFederatedName(a, b) {
|
|
52
|
+
return a.name === b.name && a.chain === b.chain;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=federated.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"federated.js","sourceRoot":"","sources":["../src/federated.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAa/C,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,OAAe,EAAc,EAAE;IAC7D,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,OAAO,IAAI,CAAC;QAAE,MAAM,IAAI,gBAAgB,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,uCAAuC,CAAC,CAAC;IACrI,OAAO,UAAU,OAAO,EAAE,CAAC;AAC7B,CAAC,CAAC;AAEF,MAAM,UAAU,cAAc,CAAC,KAAa;IAC1C,MAAM,CAAC,GAAG,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACvC,IAAI,CAAC,CAAC;QAAE,MAAM,IAAI,gBAAgB,CAAC,KAAK,EAAE,kCAAkC,CAAC,CAAC;IAC9E,O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