@agenticprimitives/agent-naming 1.0.0-alpha.5 → 1.0.0-alpha.50
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 +52 -2
- package/CLAUDE.md +43 -64
- package/README.md +57 -54
- package/dist/abis.d.ts +1113 -11
- package/dist/abis.d.ts.map +1 -1
- package/dist/abis.js +184 -0
- package/dist/abis.js.map +1 -1
- package/dist/claim.d.ts +103 -0
- package/dist/claim.d.ts.map +1 -0
- package/dist/claim.js +131 -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 +75 -5
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +156 -4
- package/dist/constants.js.map +1 -1
- package/dist/custody.d.ts +149 -10
- package/dist/custody.d.ts.map +1 -1
- package/dist/custody.js +243 -13
- package/dist/custody.js.map +1 -1
- package/dist/dns.d.ts +186 -0
- package/dist/dns.d.ts.map +1 -0
- package/dist/dns.js +296 -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 +23 -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 +10 -23
- package/dist/namehash.d.ts.map +1 -1
- package/dist/namehash.js +11 -35
- 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 +65 -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 +44 -0
- package/dist/vertical.js.map +1 -0
- package/docs/api.md +15 -1
- package/package.json +22 -13
package/dist/constants.js
CHANGED
|
@@ -1,7 +1,159 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Typed TLD registry (ADR-0061 / spec 346 §3–§4).
|
|
3
|
+
*
|
|
4
|
+
* Every canonical suffix names a DERIVED agent type; resolution maps suffix → derived type → root.
|
|
5
|
+
* The name string never encodes hierarchy, a role, or a technology. The suffix is a CLAIM — the
|
|
6
|
+
* on-chain `atl:agentType` record on the SA subject is the authority (spec 346 §2.3).
|
|
7
|
+
*
|
|
8
|
+
* `.ws` is a package-level alias normalizing to `workspace`; it is not an on-chain root.
|
|
9
|
+
* `.agent` is the one UNTYPED LEGACY root: it resolves, it is not validated, and it closes to new claims once
|
|
10
|
+
* the owning apps migrate (spec 346 §3.5). A word in neither list is an unknown root and is refused (`unknown_tld`);
|
|
11
|
+
* a retired root is not kept as an alias (test/grammar.test.ts, "a retired root fails closed").
|
|
5
12
|
*/
|
|
6
|
-
|
|
13
|
+
import { keccak256, toHex } from 'viem';
|
|
14
|
+
import { rootClassForDerivedType } from '@agenticprimitives/types';
|
|
15
|
+
import { verticalAgentTypeForTld, verticalAgentTlds, verticalRootKindForTld } from './vertical.js';
|
|
16
|
+
/** The ten registry-canonical suffixes, in canonical order (`.registry` names the Service Agent that OPERATES a registry;
|
|
17
|
+
* `.church` / `.circle` are organization-class kinds — ADR-0061 amendment 2026-08-30; `.household` the family's own
|
|
18
|
+
* organization-class agent — amendment 2026-09-07, spec 368). */
|
|
19
|
+
export const AGENT_TLDS = ['me', 'org', 'team', 'svc', 'workspace', 'treasury', 'registry', 'church', 'circle', 'household'];
|
|
20
|
+
/** Package-level aliases applied during normalization (never on-chain roots). */
|
|
21
|
+
export const AGENT_TLD_ALIASES = Object.freeze({ ws: 'workspace' });
|
|
22
|
+
/** Untyped legacy roots — resolvable, never suffix-validated, closed to new claims after app adoption. `.agent` only. */
|
|
23
|
+
export const LEGACY_TLDS = ['agent'];
|
|
24
|
+
/**
|
|
25
|
+
* Labels that MUST NOT be claimed under any root or inside any context: the type words (they would
|
|
26
|
+
* collide with the DNS type level `<label>.<type>.<zone>`, spec 346 §5), the alias, and the fixed
|
|
27
|
+
* infrastructure hosts (`mtls.<host>` is ADR-0057's hostname).
|
|
28
|
+
*/
|
|
29
|
+
export const RESERVED_LABELS = Object.freeze([
|
|
30
|
+
...AGENT_TLDS,
|
|
31
|
+
'ws',
|
|
32
|
+
'www',
|
|
33
|
+
'mtls',
|
|
34
|
+
'edge',
|
|
35
|
+
'api',
|
|
36
|
+
'well-known',
|
|
37
|
+
]);
|
|
38
|
+
/**
|
|
39
|
+
* The labels `AgentNameRegistry` reserves in its constructor (spec 445 / generation 4 / B2, NAME-8): exactly the
|
|
40
|
+
* non-type words of `RESERVED_LABELS`. The chain reserves a TYPE word only once that root is initialized
|
|
41
|
+
* (`isTypedRootLabel`); the SDK reserves all of them statically, so it stays the stricter pre-check.
|
|
42
|
+
*/
|
|
43
|
+
export const CHAIN_SEEDED_RESERVED_LABELS = Object.freeze(['ws', 'www', 'mtls', 'edge', 'api', 'well-known']);
|
|
44
|
+
const TLD_TO_DERIVED = Object.freeze({
|
|
45
|
+
me: 'person',
|
|
46
|
+
org: 'org',
|
|
47
|
+
team: 'team',
|
|
48
|
+
svc: 'service',
|
|
49
|
+
workspace: 'workspace',
|
|
50
|
+
treasury: 'treasury',
|
|
51
|
+
registry: 'registry',
|
|
52
|
+
church: 'church',
|
|
53
|
+
circle: 'circle',
|
|
54
|
+
household: 'household',
|
|
55
|
+
});
|
|
56
|
+
const DERIVED_TO_TLD = Object.freeze({
|
|
57
|
+
person: 'me',
|
|
58
|
+
org: 'org',
|
|
59
|
+
team: 'team',
|
|
60
|
+
service: 'svc',
|
|
61
|
+
workspace: 'workspace',
|
|
62
|
+
treasury: 'treasury',
|
|
63
|
+
registry: 'registry',
|
|
64
|
+
church: 'church',
|
|
65
|
+
circle: 'circle',
|
|
66
|
+
household: 'household',
|
|
67
|
+
});
|
|
68
|
+
/** Derived-type CURIE-style names used for the per-root `rootKind` tag (`namespace:<Type>`). */
|
|
69
|
+
const DERIVED_ROOT_KIND_NAME = Object.freeze({
|
|
70
|
+
person: 'namespace:Person',
|
|
71
|
+
org: 'namespace:Organization',
|
|
72
|
+
team: 'namespace:Team',
|
|
73
|
+
service: 'namespace:Service',
|
|
74
|
+
workspace: 'namespace:Workspace',
|
|
75
|
+
treasury: 'namespace:Treasury',
|
|
76
|
+
registry: 'namespace:Registry',
|
|
77
|
+
church: 'namespace:Church',
|
|
78
|
+
circle: 'namespace:Circle',
|
|
79
|
+
household: 'namespace:Household',
|
|
80
|
+
});
|
|
81
|
+
export function isAgentTld(v) {
|
|
82
|
+
return AGENT_TLDS.includes(v);
|
|
83
|
+
}
|
|
84
|
+
export function isKnownAgentTld(v) {
|
|
85
|
+
return isAgentTld(v) || verticalAgentTypeForTld(v) !== null;
|
|
86
|
+
}
|
|
87
|
+
export function isLegacyTld(v) {
|
|
88
|
+
return LEGACY_TLDS.includes(v);
|
|
89
|
+
}
|
|
90
|
+
/** Resolve an alias (`ws`) to its canonical suffix; canonical and registered vertical suffixes pass through; others null. */
|
|
91
|
+
export function canonicalTld(v) {
|
|
92
|
+
if (isAgentTld(v))
|
|
93
|
+
return v;
|
|
94
|
+
const a = AGENT_TLD_ALIASES[v];
|
|
95
|
+
if (a)
|
|
96
|
+
return a;
|
|
97
|
+
return verticalAgentTypeForTld(v) ? v : null;
|
|
98
|
+
}
|
|
99
|
+
/** `me → person`, `org → org`, `team → team`, `svc → service`, `workspace → workspace`, `treasury → treasury`,
|
|
100
|
+
* `registry → registry`; a vertical suffix → the GENERIC derived type it refines (its subtype is `subtypeForTld`). */
|
|
101
|
+
export function derivedTypeForTld(tld) {
|
|
102
|
+
if (isAgentTld(tld))
|
|
103
|
+
return TLD_TO_DERIVED[tld];
|
|
104
|
+
const v = verticalAgentTypeForTld(tld);
|
|
105
|
+
if (!v)
|
|
106
|
+
throw new Error(`[agent-naming] unknown tld "${tld}"`);
|
|
107
|
+
return v.derivedType;
|
|
108
|
+
}
|
|
109
|
+
/** The vertical subtype a suffix names (`null` for the seven generic suffixes). */
|
|
110
|
+
export function subtypeForTld(tld) {
|
|
111
|
+
return isAgentTld(tld) ? null : (verticalAgentTypeForTld(tld)?.subtype ?? null);
|
|
112
|
+
}
|
|
113
|
+
/** Every suffix this process knows: the seven generic + registered vertical ones. */
|
|
114
|
+
export function allAgentTlds() {
|
|
115
|
+
return [...AGENT_TLDS, ...verticalAgentTlds()];
|
|
116
|
+
}
|
|
117
|
+
export function tldForDerivedType(t) {
|
|
118
|
+
return DERIVED_TO_TLD[t];
|
|
119
|
+
}
|
|
120
|
+
/** Re-exported for callers that only import agent-naming: derived type → closed root (ADR-0046). */
|
|
121
|
+
export { rootClassForDerivedType };
|
|
122
|
+
/**
|
|
123
|
+
* Is `label` one that names no agent anywhere — a type word, the alias, a registered vertical suffix or a fixed
|
|
124
|
+
* infrastructure host (spec 346 §3.1)? Stated once so the grammar, the claim helpers and the DNS projection agree.
|
|
125
|
+
*/
|
|
126
|
+
export function isReservedLabel(label) {
|
|
127
|
+
return RESERVED_LABELS.includes(label) || canonicalTld(label) !== null;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* The type suffix a single label ENDS in — `alice-home-church` → `church` — or null. The suffix is the segment
|
|
131
|
+
* after the LAST hyphen, compared with the closed suffix set (a suffix never contains a hyphen: the ten generic
|
|
132
|
+
* ones do not, and `registerVerticalAgentTypes` refuses one that does), so the split is unique: a label reads as
|
|
133
|
+
* at most one `<label>-<type>`. Spec 445 / audit NAME-8: this one function decides both which bare labels have no
|
|
134
|
+
* DNS host and how a host is read back, so the two cannot drift.
|
|
135
|
+
*/
|
|
136
|
+
export function typeSuffixOfLabel(label) {
|
|
137
|
+
const i = label.lastIndexOf('-');
|
|
138
|
+
if (i <= 0 || i === label.length - 1)
|
|
139
|
+
return null;
|
|
140
|
+
const tail = label.slice(i + 1);
|
|
141
|
+
return allAgentTlds().includes(tail) ? tail : null;
|
|
142
|
+
}
|
|
143
|
+
/** Root class a suffix resolves to (`suffix → derived type → root`). */
|
|
144
|
+
export function rootClassForTld(tld) {
|
|
145
|
+
return rootClassForDerivedType(derivedTypeForTld(tld));
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* The per-root `rootKind` tag written by `AgentNameRegistry.initializeRoot` for a typed root:
|
|
149
|
+
* `keccak256("namespace:<DerivedType>")`. Opaque on chain; mirrored here so deploy scripts and the SDK
|
|
150
|
+
* agree (golden-vector tested). The legacy roots carry `keccak256("namespace:Agent")` (`KIND_AGENT`).
|
|
151
|
+
*/
|
|
152
|
+
export function rootKindForTld(tld) {
|
|
153
|
+
if (!isAgentTld(tld))
|
|
154
|
+
return verticalRootKindForTld(tld);
|
|
155
|
+
return keccak256(toHex(DERIVED_ROOT_KIND_NAME[derivedTypeForTld(tld)]));
|
|
156
|
+
}
|
|
157
|
+
/** `KIND_AGENT` — the `rootKind` of the untyped legacy roots. */
|
|
158
|
+
export const ROOT_KIND_AGENT = keccak256(toHex('namespace:Agent'));
|
|
7
159
|
//# sourceMappingURL=constants.js.map
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,SAAS,EAAE,KAAK,EAAY,MAAM,MAAM,CAAC;AAElD,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAEnG;;kEAEkE;AAClE,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,CAAU,CAAC;AAGtI,iFAAiF;AACjF,MAAM,CAAC,MAAM,iBAAiB,GAAuC,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,WAAW,EAAE,CAAC,CAAC;AAExG,yHAAyH;AACzH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,OAAO,CAAU,CAAC;AAG9C;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAsB,MAAM,CAAC,MAAM,CAAC;IAC9D,GAAG,UAAU;IACb,IAAI;IACJ,KAAK;IACL,MAAM;IACN,MAAM;IACN,KAAK;IACL,YAAY;CACb,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAsB,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC;AAEjI,MAAM,c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Ae,CAAC,KAAa;IAC3C,OAAO,eAAe,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,YAAY,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC;AACzE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAa;IAC7C,MAAM,CAAC,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IACjC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IAClD,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAChC,OAAO,YAAY,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;AACrD,CAAC;AAED,wEAAwE;AACxE,MAAM,UAAU,eAAe,CAAC,GAAgB;IAC9C,OAAO,uBAAuB,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC;AACzD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,GAAgB;IAC7C,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,sBAAsB,CAAC,GAAG,CAAC,CAAC;IACzD,OAAO,SAAS,CAAC,KAAK,CAAC,sBAAsB,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AAC1E,CAAC;AAED,iEAAiE;AACjE,MAAM,CAAC,MAAM,eAAe,GAAQ,SAAS,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,CAAC"}
|
package/dist/custody.d.ts
CHANGED
|
@@ -16,7 +16,9 @@
|
|
|
16
16
|
* walletClient submission on top.
|
|
17
17
|
*/
|
|
18
18
|
import type { Address, Hex } from '@agenticprimitives/types';
|
|
19
|
-
import { type EncodedRecord } from './records';
|
|
19
|
+
import { type EncodedRecord } from './records.js';
|
|
20
|
+
import { type DerivedAgentType } from '@agenticprimitives/types';
|
|
21
|
+
import type { AgentNameRecords } from './types.js';
|
|
20
22
|
/** Minimal call-shape: the standard `{ to, value, data }` triple. */
|
|
21
23
|
export interface ContractCall {
|
|
22
24
|
to: Address;
|
|
@@ -27,6 +29,11 @@ export interface ContractCall {
|
|
|
27
29
|
* Build a call to register `<label>.<parent>` under the parent
|
|
28
30
|
* namespace. Caller MUST be the parent's owner OR subregistry
|
|
29
31
|
* delegate (msg.sender check on chain).
|
|
32
|
+
*
|
|
33
|
+
* Spec 445 / NAME-8: when `parentNode` is a ROOT this process knows (a typed, legacy or vertical root) the label is
|
|
34
|
+
* an agent's and the claim rule applies (`labelClaimViolation`): reserved labels refused, and under a bare-host
|
|
35
|
+
* root a label ending in `-<type>` refused. Any other parent (a context registering its type-nodes, an app's own
|
|
36
|
+
* subtree) is not judged here — a type word IS the label of a type-node.
|
|
30
37
|
*/
|
|
31
38
|
export declare function buildRegisterSubnameCall(args: {
|
|
32
39
|
registry: Address;
|
|
@@ -38,7 +45,13 @@ export declare function buildRegisterSubnameCall(args: {
|
|
|
38
45
|
}): ContractCall;
|
|
39
46
|
/**
|
|
40
47
|
* Build a call to rotate the owner Smart Agent for a name.
|
|
41
|
-
* Caller MUST be the current owner.
|
|
48
|
+
* Caller MUST be the current owner, and the name must not be expired (`NameExpired`).
|
|
49
|
+
*
|
|
50
|
+
* Spec 445 / generation 4 / B2 (REG-4): RECORDS DO NOT CARRY OVER. Moving the name to a DIFFERENT owner bumps its
|
|
51
|
+
* record epoch (`RecordEpochBumped`), and `AgentNameAttributeResolver` keys every record by `(node, epoch)` — so
|
|
52
|
+
* after this call `atl:addr`, `atl:agentType` and every other record of the node read empty, and transferring back
|
|
53
|
+
* does not resurrect them. The new owner writes its own records. The `resolver` and `subregistry` POINTERS are not
|
|
54
|
+
* reset: a receiver of a transferred name must check them.
|
|
42
55
|
*/
|
|
43
56
|
export declare function buildRotateNameOwnerCall(args: {
|
|
44
57
|
registry: Address;
|
|
@@ -82,6 +95,16 @@ export declare function buildSetStringAttributeCall(args: {
|
|
|
82
95
|
value: string;
|
|
83
96
|
}): ContractCall;
|
|
84
97
|
/** Build a typed `setAddressAttribute(node, predicate, value)` call. */
|
|
98
|
+
/**
|
|
99
|
+
* `string[]` attribute write (`atl:accounts` — spec 346 §3.8 / ap-federation spec 440 §C). The resolver validates the
|
|
100
|
+
* predicate's datatype on chain; the caller validates the VALUES with `encodeAccounts` first, as `buildRecordCalls` does.
|
|
101
|
+
*/
|
|
102
|
+
export declare function buildSetStringArrayAttributeCall(args: {
|
|
103
|
+
resolver: Address;
|
|
104
|
+
node: Hex;
|
|
105
|
+
predicate: Hex;
|
|
106
|
+
values: readonly string[];
|
|
107
|
+
}): ContractCall;
|
|
85
108
|
export declare function buildSetAddressAttributeCall(args: {
|
|
86
109
|
resolver: Address;
|
|
87
110
|
node: Hex;
|
|
@@ -106,23 +129,139 @@ export declare function buildSetBytes32AttributeCall(args: {
|
|
|
106
129
|
export declare function buildRecordCalls(args: {
|
|
107
130
|
resolver: Address;
|
|
108
131
|
node: Hex;
|
|
109
|
-
records: import('./types').AgentNameRecords;
|
|
132
|
+
records: import('./types.js').AgentNameRecords;
|
|
110
133
|
}): ContractCall[];
|
|
111
134
|
/**
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
|
|
135
|
+
* Spec 445 / generation 4 / B2 (REG-5) — the PermissionlessSubregistry claim is COMMIT-REVEAL. The two windows are
|
|
136
|
+
* contract constants (`MIN_COMMIT_AGE()` / `MAX_COMMIT_AGE()`); they are mirrored here so a client can schedule the
|
|
137
|
+
* reveal without a read, and a test pins them to the contract.
|
|
138
|
+
*/
|
|
139
|
+
export declare const SUBREGISTRY_MIN_COMMIT_AGE_SECONDS = 10;
|
|
140
|
+
export declare const SUBREGISTRY_MAX_COMMIT_AGE_SECONDS = 86400;
|
|
141
|
+
/** 32 fresh random bytes for one claim. The CLIENT keeps it between the commit and the reveal, and never sends it
|
|
142
|
+
* anywhere before the reveal — whoever learns it before the reveal can reveal for the same owner, nothing more
|
|
143
|
+
* (the commitment binds `newOwner`, so a copied secret never yields the name to anyone else). */
|
|
144
|
+
export declare function generateClaimSecret(): Hex;
|
|
145
|
+
/**
|
|
146
|
+
* The commitment `PermissionlessSubregistry.makeCommitment(label, newOwner, secret)` computes, off chain:
|
|
147
|
+
* `keccak256(abi.encode(subregistry, chainId, keccak256(bytes(label)), newOwner, secret))`. The label is normalized
|
|
148
|
+
* first — the reveal sends the normalized label, so the commitment must be over the same bytes.
|
|
149
|
+
*/
|
|
150
|
+
export declare function subregistryCommitment(args: {
|
|
151
|
+
subregistry: Address;
|
|
152
|
+
chainId: number | bigint;
|
|
153
|
+
label: string;
|
|
154
|
+
newOwner: Address;
|
|
155
|
+
secret: Hex;
|
|
156
|
+
}): Hex;
|
|
157
|
+
/**
|
|
158
|
+
* STEP 1 of a PermissionlessSubregistry claim: `commit(commitment)`. The label is NOT visible on chain until the
|
|
159
|
+
* reveal, so a watcher of the mempool cannot take the name first.
|
|
160
|
+
*
|
|
161
|
+
* THE WAITING PERIOD. The reveal (`buildSubregistryRegisterCall`, same label / owner / secret) must land in a LATER
|
|
162
|
+
* transaction at least `SUBREGISTRY_MIN_COMMIT_AGE_SECONDS` (10 s of chain time) after this one is mined, and no more
|
|
163
|
+
* than `SUBREGISTRY_MAX_COMMIT_AGE_SECONDS` (1 day) after it — too early reverts `CommitmentTooNew(commitment,
|
|
164
|
+
* matureAt)`, too late `CommitmentExpired`. Both calls therefore can NOT share one user operation or one batch: a
|
|
165
|
+
* flow that claimed a name in one transaction is now two, with a wait between. The commitment is single-use, and a
|
|
166
|
+
* live one cannot be re-committed (`CommitmentPending`); after it expires, commit again (a fresh secret is best).
|
|
116
167
|
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
|
|
168
|
+
* The label is validated here exactly as at the reveal (normalization + NAME-8), so a claim the reveal would refuse
|
|
169
|
+
* never spends a commit.
|
|
170
|
+
*/
|
|
171
|
+
export declare function buildSubregistryCommitCall(args: {
|
|
172
|
+
subregistry: Address;
|
|
173
|
+
chainId: number | bigint;
|
|
174
|
+
label: string;
|
|
175
|
+
newOwner: Address;
|
|
176
|
+
secret: Hex;
|
|
177
|
+
/** As in `buildSubregistryRegisterCall`: the root this subregistry serves; omitted ⇒ judged as a bare-host root. */
|
|
178
|
+
root?: string;
|
|
179
|
+
}): ContractCall & {
|
|
180
|
+
commitment: Hex;
|
|
181
|
+
};
|
|
182
|
+
/**
|
|
183
|
+
* STEP 2 — the REVEAL: `register(label, newOwner, secret)` through a deployed PermissionlessSubregistry. It succeeds
|
|
184
|
+
* only against a MATURED commitment from `buildSubregistryCommitCall` with the same label, owner and secret (see the
|
|
185
|
+
* waiting period there). The caller pays gas; any account may send the reveal (a relayer) — the name goes to
|
|
186
|
+
* `newOwner`, which the commitment fixed.
|
|
187
|
+
*
|
|
188
|
+
* One reveal per `msg.sender` is enforced on chain (`AlreadyClaimed(existingNode)`) — a courtesy limit, not sybil
|
|
189
|
+
* resistance. The chain also refuses reserved labels (`ReservedLabel`) and, under a bare-host root, labels that read
|
|
190
|
+
* as a typed name (`LabelReadsAsTypedName`); the same rule is checked here first.
|
|
120
191
|
*/
|
|
121
192
|
export declare function buildSubregistryRegisterCall(args: {
|
|
122
193
|
subregistry: Address;
|
|
123
194
|
label: string;
|
|
124
195
|
newOwner: Address;
|
|
196
|
+
/** The secret the matching commitment was made with. */
|
|
197
|
+
secret: Hex;
|
|
198
|
+
/**
|
|
199
|
+
* The root this subregistry serves (`'me'`, `'team'`, a legacy root…). Spec 445 / NAME-8: a subregistry address
|
|
200
|
+
* does not say which root it is, so an OMITTED root is judged as a bare-host root — a label ending in `-<type>`
|
|
201
|
+
* is refused. A caller claiming `somali-corridor-team` under `.team` says `root: 'team'`.
|
|
202
|
+
*/
|
|
203
|
+
root?: string;
|
|
204
|
+
}): ContractCall;
|
|
205
|
+
/**
|
|
206
|
+
* `renew(node, newExpiry)` — spec 445 / generation 4 / B2 (REG-6). Expiry is the PARENT's term: the caller MUST be
|
|
207
|
+
* the parent authority (the parent node's owner or its subregistry), never the name's holder. Extension only:
|
|
208
|
+
* `newExpiry` is `0` (make permanent) or later than both the current expiry and now, else `ExpiryNotExtended()`. A
|
|
209
|
+
* root has no parent and cannot be renewed. Every shipped path registers permanent names (expiry 0).
|
|
210
|
+
*/
|
|
211
|
+
export declare function buildRenewNameCall(args: {
|
|
212
|
+
registry: Address;
|
|
213
|
+
node: Hex;
|
|
214
|
+
newExpiry: bigint | number;
|
|
125
215
|
}): ContractCall;
|
|
216
|
+
/**
|
|
217
|
+
* Step 1b of the bootstrap (spec 346 §3.6): declare the SA's derived type on its OWN profile subject.
|
|
218
|
+
* `msg.sender` MUST be the SA (`AgentProfileResolver.onlyAgent`) — compose these into the SA's execute
|
|
219
|
+
* batch. Registers the profile mirror first when `registered` is false (the typed setters require it),
|
|
220
|
+
* writing the ROOT kind there; then `atl:agentType` (+ `atl:serviceRole` when given, REQUIRED and equal
|
|
221
|
+
* to the type name for `workspace` and `registry`).
|
|
222
|
+
*/
|
|
223
|
+
export declare function buildDeclareAgentTypeCalls(args: {
|
|
224
|
+
profileResolver: Address;
|
|
225
|
+
agent: Address;
|
|
226
|
+
agentType: DerivedAgentType;
|
|
227
|
+
serviceRole?: string;
|
|
228
|
+
/** Vertical subtype (spec 346 §2.4) — written to `atl:agentSubtype`; REQUIRED for a vertical suffix claim. */
|
|
229
|
+
subtype?: string;
|
|
230
|
+
/** Whether `AgentProfileResolver.isRegistered(agent)` is already true. */
|
|
231
|
+
registered: boolean;
|
|
232
|
+
/** Used only when registering the profile mirror. */
|
|
233
|
+
displayName?: string;
|
|
234
|
+
}): ContractCall[];
|
|
235
|
+
/**
|
|
236
|
+
* Steps 2–3 of the bootstrap for a CANONICAL (root-level) typed name (spec 346 §3.3): claim
|
|
237
|
+
* `<label>.<tld>` through that root's `PermissionlessSubregistry`, write the root kind + optional records
|
|
238
|
+
* on the new node, and set the primary name. The caller MUST have run `validateTypedClaim` (or
|
|
239
|
+
* `AgentNamingClient.checkTypedName`) — this builder only refuses a suffix/type disagreement it can see
|
|
240
|
+
* locally. `setPrimaryName` requires `msg.sender == owner`; the subregistry claim may be sent by anyone.
|
|
241
|
+
*
|
|
242
|
+
* Spec 445 / generation 4 / B2 (REG-5): the claim is TWO transactions. Send `commit` first; after it is mined, wait
|
|
243
|
+
* at least `SUBREGISTRY_MIN_COMMIT_AGE_SECONDS` (and at most a day — see `buildSubregistryCommitCall`), then send
|
|
244
|
+
* `claim` (the reveal) followed by `records` and `primaryName`. `secret` is the client's (`generateClaimSecret()`),
|
|
245
|
+
* kept between the two; `chainId` is the subregistry's chain, part of the commitment.
|
|
246
|
+
*/
|
|
247
|
+
export declare function buildTypedClaimCalls(args: {
|
|
248
|
+
name: string;
|
|
249
|
+
owner: Address;
|
|
250
|
+
registry: Address;
|
|
251
|
+
resolver: Address;
|
|
252
|
+
subregistries: Partial<Record<string, Address>>;
|
|
253
|
+
agentType: DerivedAgentType;
|
|
254
|
+
chainId: number | bigint;
|
|
255
|
+
secret: Hex;
|
|
256
|
+
records?: Omit<AgentNameRecords, 'agentKind' | 'addr'>;
|
|
257
|
+
}): {
|
|
258
|
+
commit: ContractCall;
|
|
259
|
+
commitment: Hex;
|
|
260
|
+
claim: ContractCall;
|
|
261
|
+
records: ContractCall[];
|
|
262
|
+
primaryName: ContractCall;
|
|
263
|
+
node: Hex;
|
|
264
|
+
};
|
|
126
265
|
/**
|
|
127
266
|
* Convenience: re-export the encoded-record shape from records.ts so
|
|
128
267
|
* downstream callers can pick whichever level of abstraction fits
|
package/dist/custody.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custody.d.ts","sourceRoot":"","sources":["../src/custody.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM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