@certen.io/sdk 0.14.0 → 0.15.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/CHANGELOG.md +13 -0
- package/dist/agent/core.d.ts +7 -0
- package/dist/agent/core.d.ts.map +1 -0
- package/dist/agent/core.js +7 -0
- package/dist/agent/core.js.map +1 -0
- package/dist/agent/mandate.d.ts +141 -0
- package/dist/agent/mandate.d.ts.map +1 -0
- package/dist/agent/mandate.js +158 -0
- package/dist/agent/mandate.js.map +1 -0
- package/dist/agent-enrollment.d.ts +83 -0
- package/dist/agent-enrollment.d.ts.map +1 -0
- package/dist/agent-enrollment.js +102 -0
- package/dist/agent-enrollment.js.map +1 -0
- package/dist/core/bytes.d.ts +38 -0
- package/dist/core/bytes.d.ts.map +1 -0
- package/dist/core/bytes.js +161 -0
- package/dist/core/bytes.js.map +1 -0
- package/dist/core/grant-profile.d.ts +133 -0
- package/dist/core/grant-profile.d.ts.map +1 -0
- package/dist/core/grant-profile.js +323 -0
- package/dist/core/grant-profile.js.map +1 -0
- package/dist/core/hashes.d.ts +59 -0
- package/dist/core/hashes.d.ts.map +1 -0
- package/dist/core/hashes.js +128 -0
- package/dist/core/hashes.js.map +1 -0
- package/dist/core/jcs.d.ts +29 -0
- package/dist/core/jcs.d.ts.map +1 -0
- package/dist/core/jcs.js +371 -0
- package/dist/core/jcs.js.map +1 -0
- package/dist/core/registry-profile.d.ts +47 -0
- package/dist/core/registry-profile.d.ts.map +1 -0
- package/dist/core/registry-profile.js +119 -0
- package/dist/core/registry-profile.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/principal-entries.d.ts +109 -0
- package/dist/principal-entries.d.ts.map +1 -0
- package/dist/principal-entries.js +237 -0
- package/dist/principal-entries.js.map +1 -0
- package/dist/principal-intervention.d.ts +97 -0
- package/dist/principal-intervention.d.ts.map +1 -0
- package/dist/principal-intervention.js +139 -0
- package/dist/principal-intervention.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changelog — @certen.io/sdk
|
|
2
2
|
|
|
3
|
+
## 0.15.0 — a principal's agent: enrollment, Grant, mandate, revoke, cancel by reject vote and replace (2026-11-21)
|
|
4
|
+
|
|
5
|
+
Requires `@certen.io/proof-verify` `^0.4.1` (an executed agent payment's evidence pack must name its destination transaction).
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
- **Agent enrollment state** — `agentEnrollmentState`, `agentAuthorityOperation`, `agentBookDisableOperation`, `isUnderAdi`: the steps that put the principal's book on the agent's ADI and key book as a required authority and disable the agent's own book, judged from the chain.
|
|
9
|
+
- **Principal entries** — `registerAgent`, `issueGrant`, `issueMandate` (and `buildPrincipalEntry`, `writePrincipalEntry`, `entryHash`, `entryTag`, `envelopeDigestHex`, `canonicalJson`, `coreVerdict`): the principal registers its agent, issues the Grant and signs the mandate through the gateway's data operations, each judged with pinned copies of the core profile functions before anything is signed (`PRINCIPAL_ENTRY_REFUSED_BY_CORE`).
|
|
10
|
+
- **Intervention** — `revokeGrant`, `revokeAgentKey`, `agentKeyRemoval`, `revocationOf`, `cancelByRejectVote`, `replaceAgent`: revoke (the Grant superseded with ended validity, the agent's key replaced by the owner's), cancel a pending intent by a required authority's reject vote, and replace the agent under the same Grant lineage. `EXPOSURE_WINDOW_STATEMENT` is the sentence every revocation surface carries: a payment already certified before a revocation can still execute inside its window.
|
|
11
|
+
|
|
12
|
+
## 0.14.1 — requires the verifier that reads the initiating-signature member (2026-11-13)
|
|
13
|
+
|
|
14
|
+
No change to the SDK's own code. The floor of `@certen.io/proof-verify` is raised to `^0.3.1` so a fresh install cannot keep 0.3.0 in the tree: `verifyEvidence` (and `./verify`) judge evidence 2.1 with it, and 0.3.0 ignores the member `initiatingSignature` that rules v16 of the validators add, so for a transaction initiated by a separate, non-voting initiator it reports the role as declared (`g1_initiator_signature_not_carried`) and does not verify S3. 0.3.1 proves the member or refuses the document by name.
|
|
15
|
+
|
|
3
16
|
## 0.14.0 — evidence 2.1 through `verifyEvidence`, body-less POSTs, and proof-cycle timing that matches the gateway (2026-11-06)
|
|
4
17
|
|
|
5
18
|
Needs `@certen.io/proof-verify` with the 2.1 layer report (same release).
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This package's OWN shim for the copied mandate shape (scripts/sync-core.mjs): src/agent/mandate.ts imports the core only through
|
|
3
|
+
* './core.js', and here that is this package's pinned copy of the core (src/core, src/core/PIN.json). Not copied, not pinned.
|
|
4
|
+
*/
|
|
5
|
+
export { canonicalize } from '../core/jcs.js';
|
|
6
|
+
export { digestHex, taggedPreimage } from '../core/hashes.js';
|
|
7
|
+
//# sourceMappingURL=core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/agent/core.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This package's OWN shim for the copied mandate shape (scripts/sync-core.mjs): src/agent/mandate.ts imports the core only through
|
|
3
|
+
* './core.js', and here that is this package's pinned copy of the core (src/core, src/core/PIN.json). Not copied, not pinned.
|
|
4
|
+
*/
|
|
5
|
+
export { canonicalize } from '../core/jcs.js';
|
|
6
|
+
export { digestHex, taggedPreimage } from '../core/hashes.js';
|
|
7
|
+
//# sourceMappingURL=core.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../src/agent/core.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
export declare const MANDATE_TAG = "certen:mandate:v1";
|
|
2
|
+
export declare const MANDATE_SCHEMA = "certen.mandate/v1";
|
|
3
|
+
export declare const isAcc: (s: unknown) => s is string;
|
|
4
|
+
export declare const isAmount: (s: unknown) => s is string;
|
|
5
|
+
/** The URL is the ADI, a path under it, or a sub-ADI of it (GRANT.md GR-36 reading); a name sharing only a prefix is not. */
|
|
6
|
+
export declare function underAdi(url: unknown, adi: unknown): boolean;
|
|
7
|
+
export interface Mandate {
|
|
8
|
+
schema: string;
|
|
9
|
+
mandateId: string;
|
|
10
|
+
version: number;
|
|
11
|
+
priorHash: string | null;
|
|
12
|
+
principal: {
|
|
13
|
+
adi: string;
|
|
14
|
+
keyBook: string;
|
|
15
|
+
};
|
|
16
|
+
agent: {
|
|
17
|
+
adi: string;
|
|
18
|
+
};
|
|
19
|
+
grant: {
|
|
20
|
+
grantId: string;
|
|
21
|
+
version: number;
|
|
22
|
+
hash: string;
|
|
23
|
+
};
|
|
24
|
+
purpose: string;
|
|
25
|
+
limits: {
|
|
26
|
+
asset: {
|
|
27
|
+
chainId: number;
|
|
28
|
+
token: string;
|
|
29
|
+
};
|
|
30
|
+
perPayment: string;
|
|
31
|
+
cumulative: {
|
|
32
|
+
amount: string;
|
|
33
|
+
periodSeconds: number;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
beneficiaries: Array<{
|
|
37
|
+
chainId: number;
|
|
38
|
+
address: string;
|
|
39
|
+
}>;
|
|
40
|
+
validity: {
|
|
41
|
+
notBefore: number;
|
|
42
|
+
notAfter: number;
|
|
43
|
+
};
|
|
44
|
+
issuedAt: number;
|
|
45
|
+
}
|
|
46
|
+
/** null when the mandate is well formed, else the member that is not (the refusal detail). */
|
|
47
|
+
export declare function mandateShape(m: unknown): string | null;
|
|
48
|
+
/** SHA-256( lp("certen:mandate:v1") || lp(canonical mandate) ), canonical form RFC 8785. */
|
|
49
|
+
export declare const mandateHash: (m: unknown) => string;
|
|
50
|
+
export interface MandateLineage {
|
|
51
|
+
headHash: string;
|
|
52
|
+
headWithdrawn?: boolean;
|
|
53
|
+
ambiguous?: boolean;
|
|
54
|
+
}
|
|
55
|
+
export interface GrantHeadFacts {
|
|
56
|
+
grantId: string;
|
|
57
|
+
version: number;
|
|
58
|
+
hash: string;
|
|
59
|
+
subject: string;
|
|
60
|
+
grantor: string;
|
|
61
|
+
validity: {
|
|
62
|
+
notBefore: number;
|
|
63
|
+
notAfter: number;
|
|
64
|
+
};
|
|
65
|
+
perTransaction: string;
|
|
66
|
+
cumulative: {
|
|
67
|
+
amount: string;
|
|
68
|
+
periodSeconds: number;
|
|
69
|
+
};
|
|
70
|
+
beneficiaries: Array<{
|
|
71
|
+
chainId: number;
|
|
72
|
+
address: string;
|
|
73
|
+
}>;
|
|
74
|
+
}
|
|
75
|
+
export interface MandatePayment {
|
|
76
|
+
beneficiary: {
|
|
77
|
+
chainId: number;
|
|
78
|
+
address: string;
|
|
79
|
+
};
|
|
80
|
+
asset: {
|
|
81
|
+
chainId: number;
|
|
82
|
+
token: string;
|
|
83
|
+
};
|
|
84
|
+
amount: string;
|
|
85
|
+
at: number;
|
|
86
|
+
}
|
|
87
|
+
export interface CheckMandateInput {
|
|
88
|
+
mandate: unknown;
|
|
89
|
+
signerBook: unknown;
|
|
90
|
+
lineage: unknown;
|
|
91
|
+
grantHead: unknown;
|
|
92
|
+
payment: unknown;
|
|
93
|
+
usage?: unknown;
|
|
94
|
+
lift?: unknown;
|
|
95
|
+
}
|
|
96
|
+
export type MandateResult = {
|
|
97
|
+
ok: true;
|
|
98
|
+
mandateHash: string;
|
|
99
|
+
liftedPerPayment: boolean;
|
|
100
|
+
} | {
|
|
101
|
+
ok: false;
|
|
102
|
+
reason: string;
|
|
103
|
+
detail?: string;
|
|
104
|
+
};
|
|
105
|
+
/** AGENT-GRANT.md section 3.3: the refusal order is fixed. Fail closed on anything not established. */
|
|
106
|
+
export declare function checkMandate(input: CheckMandateInput): MandateResult;
|
|
107
|
+
export type MandateRecheck = {
|
|
108
|
+
ok: true;
|
|
109
|
+
outcome: 'unchanged';
|
|
110
|
+
} | {
|
|
111
|
+
ok: true;
|
|
112
|
+
outcome: 'denied';
|
|
113
|
+
reason: string;
|
|
114
|
+
} | {
|
|
115
|
+
ok: true;
|
|
116
|
+
outcome: 'exposure_window_open';
|
|
117
|
+
until: number;
|
|
118
|
+
} | {
|
|
119
|
+
ok: true;
|
|
120
|
+
outcome: 'window_closed';
|
|
121
|
+
} | {
|
|
122
|
+
ok: false;
|
|
123
|
+
reason: 'recheck_malformed';
|
|
124
|
+
};
|
|
125
|
+
/** INTERVENTION.md section 4a: a pending item is re-judged; a certified one is never re-decided (DE-21). */
|
|
126
|
+
export declare function recheckMandate(input: {
|
|
127
|
+
item: unknown;
|
|
128
|
+
world: unknown;
|
|
129
|
+
}): MandateRecheck;
|
|
130
|
+
/** EVIDENCE-AGT.md section 2: the agent C5 record binds the signed mandate hash, never the agent's own stated intent. */
|
|
131
|
+
export declare function checkInstructionBinding(input: {
|
|
132
|
+
record: unknown;
|
|
133
|
+
mandate: unknown;
|
|
134
|
+
agentIntentHash?: unknown;
|
|
135
|
+
}): {
|
|
136
|
+
ok: true;
|
|
137
|
+
} | {
|
|
138
|
+
ok: false;
|
|
139
|
+
reason: string;
|
|
140
|
+
};
|
|
141
|
+
//# sourceMappingURL=mandate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mandate.d.ts","sourceRoot":"","sources":["../../src/agent/mandate.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,WAAW,sBAAsB,CAAC;AAC/C,eAAO,MAAM,cAAc,sBAAsB,CAAC;AAKlD,eAAO,MAAM,KAAK,GAAI,GAAG,OAAO,KAAG,C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 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* certen.mandate/v1 (docs/agentic/AGENT-GRANT.md section 3): the principal-signed instruction an agent payment must lie inside.
|
|
3
|
+
* Written independently of docs/agentic/vectors/lib-agt.mjs; the vectors are the judge (agent.vectors.test.ts).
|
|
4
|
+
*/
|
|
5
|
+
import { canonicalize, digestHex, taggedPreimage } from './core.js';
|
|
6
|
+
export const MANDATE_TAG = 'certen:mandate:v1';
|
|
7
|
+
export const MANDATE_SCHEMA = 'certen.mandate/v1';
|
|
8
|
+
const isObj = (o) => o !== null && typeof o === 'object' && !Array.isArray(o);
|
|
9
|
+
const ACC = /^acc:\/\/[a-z0-9][a-z0-9.-]*\.acme(\/[a-z0-9._-]+)*$/;
|
|
10
|
+
export const isAcc = (s) => typeof s === 'string' && ACC.test(s);
|
|
11
|
+
const isAddr = (s) => typeof s === 'string' && /^0x[0-9a-f]{40}$/.test(s);
|
|
12
|
+
const isHash = (s) => typeof s === 'string' && /^0x[0-9a-f]{64}$/.test(s);
|
|
13
|
+
export const isAmount = (s) => typeof s === 'string' && /^(0|[1-9][0-9]{0,77})$/.test(s);
|
|
14
|
+
const isInt = (n, min = 0) => typeof n === 'number' && Number.isSafeInteger(n) && n >= min;
|
|
15
|
+
const exactKeys = (o, keys) => isObj(o) && Object.keys(o).length === keys.length && keys.every((k) => k in o);
|
|
16
|
+
const hostOf = (u) => u.replace(/^acc:\/\//, '').split('/')[0];
|
|
17
|
+
/** The URL is the ADI, a path under it, or a sub-ADI of it (GRANT.md GR-36 reading); a name sharing only a prefix is not. */
|
|
18
|
+
export function underAdi(url, adi) {
|
|
19
|
+
if (!isAcc(url) || !isAcc(adi))
|
|
20
|
+
return false;
|
|
21
|
+
const h = hostOf(url);
|
|
22
|
+
const a = hostOf(adi);
|
|
23
|
+
return h === a || h.endsWith(`.${a}`);
|
|
24
|
+
}
|
|
25
|
+
const KEYS = ['schema', 'mandateId', 'version', 'priorHash', 'principal', 'agent', 'grant', 'purpose', 'limits', 'beneficiaries', 'validity', 'issuedAt'];
|
|
26
|
+
/** null when the mandate is well formed, else the member that is not (the refusal detail). */
|
|
27
|
+
export function mandateShape(m) {
|
|
28
|
+
if (!exactKeys(m, KEYS))
|
|
29
|
+
return 'members';
|
|
30
|
+
if (m.schema !== MANDATE_SCHEMA)
|
|
31
|
+
return 'schema';
|
|
32
|
+
if (typeof m.mandateId !== 'string' || !/^[a-z0-9][a-z0-9._-]{0,62}$/.test(m.mandateId))
|
|
33
|
+
return 'mandateId';
|
|
34
|
+
if (!isInt(m.version, 1))
|
|
35
|
+
return 'version';
|
|
36
|
+
if (m.version === 1 ? m.priorHash !== null : !isHash(m.priorHash))
|
|
37
|
+
return 'priorHash';
|
|
38
|
+
const p = m.principal;
|
|
39
|
+
if (!exactKeys(p, ['adi', 'keyBook']) || !isAcc(p.adi) || !isAcc(p.keyBook))
|
|
40
|
+
return 'principal';
|
|
41
|
+
if (!p.keyBook.startsWith(`${p.adi}/`))
|
|
42
|
+
return 'principal.keyBook';
|
|
43
|
+
if (!exactKeys(m.agent, ['adi']) || !isAcc(m.agent.adi))
|
|
44
|
+
return 'agent';
|
|
45
|
+
const g = m.grant;
|
|
46
|
+
if (!exactKeys(g, ['grantId', 'version', 'hash']) || typeof g.grantId !== 'string' || !isInt(g.version, 1) || !isHash(g.hash))
|
|
47
|
+
return 'grant';
|
|
48
|
+
if (m.purpose !== 'vendor-payment')
|
|
49
|
+
return 'purpose';
|
|
50
|
+
const l = m.limits;
|
|
51
|
+
if (!exactKeys(l, ['asset', 'perPayment', 'cumulative']) || !exactKeys(l.asset, ['chainId', 'token']) || !isInt(l.asset.chainId, 1)
|
|
52
|
+
|| !(isAddr(l.asset.token) || l.asset.token === 'native') || !isAmount(l.perPayment)
|
|
53
|
+
|| !exactKeys(l.cumulative, ['amount', 'periodSeconds']) || !isAmount(l.cumulative.amount) || !isInt(l.cumulative.periodSeconds, 60)
|
|
54
|
+
|| BigInt(l.cumulative.amount) < BigInt(l.perPayment))
|
|
55
|
+
return 'limits';
|
|
56
|
+
const b = m.beneficiaries;
|
|
57
|
+
if (!Array.isArray(b) || b.length < 1 || b.length > 64 || !b.every((x) => exactKeys(x, ['chainId', 'address']) && isInt(x.chainId, 1) && isAddr(x.address)))
|
|
58
|
+
return 'beneficiaries';
|
|
59
|
+
const v = m.validity;
|
|
60
|
+
if (!exactKeys(v, ['notBefore', 'notAfter']) || !isInt(v.notBefore) || !isInt(v.notAfter))
|
|
61
|
+
return 'validity';
|
|
62
|
+
if (v.notAfter < v.notBefore || (m.version === 1 && v.notAfter === v.notBefore))
|
|
63
|
+
return 'validity';
|
|
64
|
+
if (!isInt(m.issuedAt))
|
|
65
|
+
return 'issuedAt';
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
const utf8 = (s) => new TextEncoder().encode(s);
|
|
69
|
+
/** SHA-256( lp("certen:mandate:v1") || lp(canonical mandate) ), canonical form RFC 8785. */
|
|
70
|
+
export const mandateHash = (m) => digestHex(taggedPreimage(MANDATE_TAG, [utf8(canonicalize(m))]));
|
|
71
|
+
const no = (reason, detail) => (detail === undefined ? { ok: false, reason } : { ok: false, reason, detail });
|
|
72
|
+
/** AGENT-GRANT.md section 3.3: the refusal order is fixed. Fail closed on anything not established. */
|
|
73
|
+
export function checkMandate(input) {
|
|
74
|
+
const d = mandateShape(input.mandate);
|
|
75
|
+
if (d)
|
|
76
|
+
return no('mandate_malformed', d);
|
|
77
|
+
const m = input.mandate;
|
|
78
|
+
if (!isAcc(input.signerBook))
|
|
79
|
+
return no('mandate_unsigned');
|
|
80
|
+
if (underAdi(input.signerBook, m.agent.adi))
|
|
81
|
+
return no('mandate_signed_by_agent');
|
|
82
|
+
if (input.signerBook !== m.principal.keyBook)
|
|
83
|
+
return no('mandate_signer_not_principal');
|
|
84
|
+
if (underAdi(m.principal.adi, m.agent.adi))
|
|
85
|
+
return no('mandate_principal_is_agent');
|
|
86
|
+
const lin = input.lineage;
|
|
87
|
+
if (!isObj(lin) || typeof lin.headHash !== 'string')
|
|
88
|
+
return no('mandate_lineage_unreadable');
|
|
89
|
+
if (lin.ambiguous === true)
|
|
90
|
+
return no('mandate_lineage_ambiguous');
|
|
91
|
+
if (mandateHash(m) !== lin.headHash)
|
|
92
|
+
return no(lin.headWithdrawn === true ? 'mandate_withdrawn' : 'mandate_superseded');
|
|
93
|
+
if (m.validity.notAfter === m.validity.notBefore)
|
|
94
|
+
return no('mandate_withdrawn');
|
|
95
|
+
const gh = input.grantHead;
|
|
96
|
+
if (!isObj(gh) || m.agent.adi !== gh.subject || m.principal.adi !== gh.grantor)
|
|
97
|
+
return no('mandate_grant_party_mismatch');
|
|
98
|
+
if (m.grant.grantId !== gh.grantId || m.grant.version !== gh.version || m.grant.hash !== gh.hash)
|
|
99
|
+
return no('mandate_grant_not_head');
|
|
100
|
+
if (!isObj(gh.validity) || !isAmount(gh.perTransaction) || !isObj(gh.cumulative) || !isAmount(gh.cumulative.amount) || !Array.isArray(gh.beneficiaries))
|
|
101
|
+
return no('mandate_grant_unreadable');
|
|
102
|
+
if (m.validity.notBefore < gh.validity.notBefore || m.validity.notAfter > gh.validity.notAfter
|
|
103
|
+
|| BigInt(m.limits.perPayment) > BigInt(gh.perTransaction)
|
|
104
|
+
|| m.limits.cumulative.periodSeconds !== gh.cumulative.periodSeconds || BigInt(m.limits.cumulative.amount) > BigInt(gh.cumulative.amount)
|
|
105
|
+
|| !m.beneficiaries.every((b) => gh.beneficiaries.some((g) => g.chainId === b.chainId && g.address === b.address)))
|
|
106
|
+
return no('mandate_exceeds_grant');
|
|
107
|
+
const p = input.payment;
|
|
108
|
+
if (!isObj(p) || !isInt(p.at) || !isObj(p.asset) || !isObj(p.beneficiary) || !isAmount(p.amount))
|
|
109
|
+
return no('mandate_payment_malformed');
|
|
110
|
+
if (p.at < m.validity.notBefore)
|
|
111
|
+
return no('mandate_not_yet_valid');
|
|
112
|
+
if (p.at >= m.validity.notAfter)
|
|
113
|
+
return no('mandate_expired');
|
|
114
|
+
if (p.asset.chainId !== m.limits.asset.chainId || p.asset.token !== m.limits.asset.token)
|
|
115
|
+
return no('mandate_asset_mismatch');
|
|
116
|
+
if (!m.beneficiaries.some((b) => b.chainId === p.beneficiary.chainId && b.address === p.beneficiary.address))
|
|
117
|
+
return no('mandate_beneficiary_not_listed');
|
|
118
|
+
const usage = input.usage === undefined ? { cumulative: '0' } : input.usage;
|
|
119
|
+
if (!isObj(usage) || !isAmount(usage.cumulative))
|
|
120
|
+
return no('mandate_usage_malformed');
|
|
121
|
+
const lifted = input.lift === 'exact';
|
|
122
|
+
if (!lifted && BigInt(p.amount) > BigInt(m.limits.perPayment))
|
|
123
|
+
return no('mandate_per_payment_exceeded');
|
|
124
|
+
if (BigInt(usage.cumulative) + BigInt(p.amount) > BigInt(m.limits.cumulative.amount))
|
|
125
|
+
return no('mandate_cumulative_exceeded');
|
|
126
|
+
return { ok: true, mandateHash: mandateHash(m), liftedPerPayment: lifted };
|
|
127
|
+
}
|
|
128
|
+
/** INTERVENTION.md section 4a: a pending item is re-judged; a certified one is never re-decided (DE-21). */
|
|
129
|
+
export function recheckMandate(input) {
|
|
130
|
+
const { item, world } = input;
|
|
131
|
+
if (!isObj(item) || !isObj(world))
|
|
132
|
+
return { ok: false, reason: 'recheck_malformed' };
|
|
133
|
+
if (item.certified === true) {
|
|
134
|
+
if (!isInt(item.windowUntil) || !isInt(world.now))
|
|
135
|
+
return { ok: false, reason: 'recheck_malformed' };
|
|
136
|
+
return world.now < item.windowUntil ? { ok: true, outcome: 'exposure_window_open', until: item.windowUntil } : { ok: true, outcome: 'window_closed' };
|
|
137
|
+
}
|
|
138
|
+
if (!isObj(item.check) || !isObj(item.check.payment))
|
|
139
|
+
return { ok: false, reason: 'recheck_malformed' };
|
|
140
|
+
const c = item.check;
|
|
141
|
+
const r = checkMandate({ ...c, lineage: world.lineage, payment: { ...c.payment, at: world.now }, usage: world.usage });
|
|
142
|
+
return r.ok ? { ok: true, outcome: 'unchanged' } : { ok: true, outcome: 'denied', reason: r.reason };
|
|
143
|
+
}
|
|
144
|
+
/** EVIDENCE-AGT.md section 2: the agent C5 record binds the signed mandate hash, never the agent's own stated intent. */
|
|
145
|
+
export function checkInstructionBinding(input) {
|
|
146
|
+
const rec = input.record;
|
|
147
|
+
const h = isObj(rec) && isObj(rec.instruction) ? rec.instruction.hash : undefined;
|
|
148
|
+
if (!isHash(h))
|
|
149
|
+
return { ok: false, reason: 'evidence_instruction_missing' };
|
|
150
|
+
if (mandateShape(input.mandate))
|
|
151
|
+
return { ok: false, reason: 'evidence_mandate_malformed' };
|
|
152
|
+
if (input.agentIntentHash !== undefined && input.agentIntentHash !== null && h === input.agentIntentHash)
|
|
153
|
+
return { ok: false, reason: 'evidence_instruction_not_mandate' };
|
|
154
|
+
if (h !== mandateHash(input.mandate))
|
|
155
|
+
return { ok: false, reason: 'evidence_instruction_mismatch' };
|
|
156
|
+
return { ok: true };
|
|
157
|
+
}
|
|
158
|
+
//# sourceMappingURL=mandate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mandate.js","sourceRoot":"","sources":["../../src/agent/mandate.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEpE,MAAM,CAAC,MAAM,WAAW,GAAG,mBAAmB,CAAC;AAC/C,MAAM,CAAC,MAAM,cAAc,GAAG,mBAAmB,CAAC;AAGlD,MAAM,KAAK,GAAG,CAAC,CAAU,EAAY,EAAE,CAAC,CAAC,KAAK,IAAI,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AACjG,MAAM,GAAG,GAAG,sDAAsD,CAAC;AACnE,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,CAAU,EAAe,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,GAAG,CAAC,IAAI,CAAC,CA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AC,KAAK,CAAC,OAAO,CAAC;QAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,+BAA+B,EAAE,CAAC;IACpG,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent enrollment (AGT-2 WP1; specification transaction-controls docs/agentic/AGENT-IDENTITY.md section 3, AGENT-GRANT.md).
|
|
3
|
+
*
|
|
4
|
+
* An agent is enrolled only when EVERY step holds on chain, in the ceremony order:
|
|
5
|
+
* 1. the principal's book is an active required authority on the agent ADI,
|
|
6
|
+
* 2. ... and on the agent's KEY BOOK (seats and thresholds then need the principal too),
|
|
7
|
+
* each added authority ACCEPTED by the principal's book: Accumulate keeps an addAuthority pending until a key of the
|
|
8
|
+
* added book signs (fact F3), and a pending acceptance is NOT enrolled,
|
|
9
|
+
* 3. the principal's registry resolves the agent as `type: agent` (GR-62) with the agent's acceptance in force - never a
|
|
10
|
+
* name or a name prefix (finding AGT-F6),
|
|
11
|
+
* 4. the Grant and the mandate are each signed by the PRINCIPAL's book, and the agent's book is in neither the signers nor
|
|
12
|
+
* the authority set of the account that holds them.
|
|
13
|
+
*
|
|
14
|
+
* This module decides the state from facts read off the chain and plans the next step; it holds no key and signs nothing.
|
|
15
|
+
* Whoever carries out a step signs with its own key: the agent for the addAuthority it proposes, the principal for the
|
|
16
|
+
* acceptance, the registration, the Grant and the mandate.
|
|
17
|
+
*/
|
|
18
|
+
export interface AuthorityEntry {
|
|
19
|
+
url: string;
|
|
20
|
+
disabled: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface SignedDocumentFacts {
|
|
23
|
+
/** the key book whose page the verified envelope signature resolved to (null when the document is absent or unverified) */
|
|
24
|
+
signerBook: string | null;
|
|
25
|
+
/** the authority set of the data account that holds the document */
|
|
26
|
+
accountAuthorities: AuthorityEntry[];
|
|
27
|
+
}
|
|
28
|
+
export interface AgentEnrollmentFacts {
|
|
29
|
+
agentAdi: string;
|
|
30
|
+
principalAdi: string;
|
|
31
|
+
principalBook: string;
|
|
32
|
+
adiAuthorities: AuthorityEntry[];
|
|
33
|
+
keyBookAuthorities: AuthorityEntry[];
|
|
34
|
+
/** addAuthority transactions naming the principal's book that Accumulate still holds pending (awaiting the principal's signature) */
|
|
35
|
+
pendingAuthorityAdds: {
|
|
36
|
+
adi?: string;
|
|
37
|
+
keyBook?: string;
|
|
38
|
+
};
|
|
39
|
+
/** the registry resolution through the principal's registry (gateway / core resolveSubject answer) */
|
|
40
|
+
registryResolve: {
|
|
41
|
+
ok: true;
|
|
42
|
+
subject: {
|
|
43
|
+
adi: string;
|
|
44
|
+
type: string;
|
|
45
|
+
};
|
|
46
|
+
} | {
|
|
47
|
+
ok: false;
|
|
48
|
+
reason: string;
|
|
49
|
+
};
|
|
50
|
+
grant: SignedDocumentFacts;
|
|
51
|
+
mandate: SignedDocumentFacts;
|
|
52
|
+
}
|
|
53
|
+
export type AgentEnrollmentState = 'enrolled' | 'enrollment_input_malformed' | 'enrollment_owner_is_agent' | 'enrollment_owner_not_on_adi' | 'enrollment_acceptance_pending' | 'enrollment_owner_not_on_keybook' | 'enrollment_subject_unproven' | 'enrollment_subject_mismatch' | 'enrollment_agent_book_not_disabled_on_keybook' | 'enrollment_disable_pending' | 'grant_not_signed_by_principal' | 'grant_authority_includes_agent' | 'mandate_not_signed_by_principal' | 'mandate_authority_includes_agent';
|
|
54
|
+
export interface AgentEnrollmentStep {
|
|
55
|
+
step: 'add_authority' | 'accept_authority' | 'disable_agent_book' | 'accept_disable' | 'register_subject' | 'issue_grant' | 'issue_mandate';
|
|
56
|
+
/** who must sign this step */
|
|
57
|
+
signer: 'agent' | 'principal';
|
|
58
|
+
account?: 'identity' | 'book';
|
|
59
|
+
/** the pending Accumulate transaction the principal accepts */
|
|
60
|
+
pendingTx?: string;
|
|
61
|
+
}
|
|
62
|
+
export interface AgentEnrollmentVerdict {
|
|
63
|
+
enrolled: boolean;
|
|
64
|
+
state: AgentEnrollmentState;
|
|
65
|
+
cause?: string;
|
|
66
|
+
next: AgentEnrollmentStep | null;
|
|
67
|
+
}
|
|
68
|
+
/** the URL is the ADI, a path under it, or a sub-ADI of it (GR-36 reading) */
|
|
69
|
+
export declare function isUnderAdi(url: string, adi: string): boolean;
|
|
70
|
+
/** The enrollment state from chain facts, and the next step to carry out (null when enrolled). Fail closed on any malformed fact. */
|
|
71
|
+
export declare function agentEnrollmentState(f: AgentEnrollmentFacts): AgentEnrollmentVerdict;
|
|
72
|
+
/**
|
|
73
|
+
* The governance operation for an `add_authority` step, in the gateway's governance shape (types.ts: add_authority with
|
|
74
|
+
* `authority_url`, and `account_url` for the key book). Only the agent-side step has an operation: the acceptance is the
|
|
75
|
+
* principal's signature on the pending transaction, never an operation the agent can submit.
|
|
76
|
+
*/
|
|
77
|
+
export declare function agentBookDisableOperation(agentAdi: string): Record<string, string>;
|
|
78
|
+
/**
|
|
79
|
+
* The governance operation for an `add_authority` step (above: the `disable_agent_book` step's operation, which the agent submits and the
|
|
80
|
+
* principal co-signs; UpdateAccountAuth needs every authority's vote).
|
|
81
|
+
*/
|
|
82
|
+
export declare function agentAuthorityOperation(f: Pick<AgentEnrollmentFacts, 'agentAdi' | 'principalBook'>, account: 'identity' | 'book'): Record<string, string>;
|
|
83
|
+
//# sourceMappingURL=agent-enrollment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-enrollment.d.ts","sourceRoot":"","sources":["../src/agent-enrollment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,MAAM,WAAW,cAAc;IAAG,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAA;CAAE;AAElE,MAAM,WAAW,mBAAmB;IAClC,2HAA2H;IAC3H,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,oEAAoE;IACpE,kBAAkB,EAAE,cAAc,EAAE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,CAAC;IAClB,KAAK,EAAE,oBAAoB,CAAC;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,mBAAmB,GAAG,IAAI,CAAC;CAClC;AAID,8EAA8E;AAC9E,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAK5D;AAaD,qIAAqI;AACrI,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,oBAAoB,GAAG,sBAAsB,CAoCpF;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAGlF;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,EAAE,IAAI,CAAC,oBAAoB,EAAE,UAAU,GAAG,eAAe,CAAC,EAAE,OAAO,EAAE,UAAU,GAAG,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAKzJ"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent enrollment (AGT-2 WP1; specification transaction-controls docs/agentic/AGENT-IDENTITY.md section 3, AGENT-GRANT.md).
|
|
3
|
+
*
|
|
4
|
+
* An agent is enrolled only when EVERY step holds on chain, in the ceremony order:
|
|
5
|
+
* 1. the principal's book is an active required authority on the agent ADI,
|
|
6
|
+
* 2. ... and on the agent's KEY BOOK (seats and thresholds then need the principal too),
|
|
7
|
+
* each added authority ACCEPTED by the principal's book: Accumulate keeps an addAuthority pending until a key of the
|
|
8
|
+
* added book signs (fact F3), and a pending acceptance is NOT enrolled,
|
|
9
|
+
* 3. the principal's registry resolves the agent as `type: agent` (GR-62) with the agent's acceptance in force - never a
|
|
10
|
+
* name or a name prefix (finding AGT-F6),
|
|
11
|
+
* 4. the Grant and the mandate are each signed by the PRINCIPAL's book, and the agent's book is in neither the signers nor
|
|
12
|
+
* the authority set of the account that holds them.
|
|
13
|
+
*
|
|
14
|
+
* This module decides the state from facts read off the chain and plans the next step; it holds no key and signs nothing.
|
|
15
|
+
* Whoever carries out a step signs with its own key: the agent for the addAuthority it proposes, the principal for the
|
|
16
|
+
* acceptance, the registration, the Grant and the mandate.
|
|
17
|
+
*/
|
|
18
|
+
const ACC = /^acc:\/\/[a-z0-9][a-z0-9.-]*\.acme(\/[a-z0-9._-]+)*$/;
|
|
19
|
+
const hostOf = (u) => u.replace(/^acc:\/\//, '').split('/')[0];
|
|
20
|
+
/** the URL is the ADI, a path under it, or a sub-ADI of it (GR-36 reading) */
|
|
21
|
+
export function isUnderAdi(url, adi) {
|
|
22
|
+
if (!ACC.test(url) || !ACC.test(adi))
|
|
23
|
+
return false;
|
|
24
|
+
const h = hostOf(url);
|
|
25
|
+
const a = hostOf(adi);
|
|
26
|
+
return h === a || h.endsWith(`.${a}`);
|
|
27
|
+
}
|
|
28
|
+
const active = (list, url) => list.some((a) => a.url === url && a.disabled === false);
|
|
29
|
+
const validList = (l) => Array.isArray(l) && l.every((a) => a !== null && typeof a === 'object' && typeof a.url === 'string' && typeof a.disabled === 'boolean');
|
|
30
|
+
function documentState(doc, f, kind) {
|
|
31
|
+
if (!doc || !validList(doc.accountAuthorities))
|
|
32
|
+
return 'enrollment_input_malformed';
|
|
33
|
+
if (doc.accountAuthorities.some((a) => a.disabled === false && isUnderAdi(a.url, f.agentAdi)))
|
|
34
|
+
return `${kind}_authority_includes_agent`;
|
|
35
|
+
if (doc.signerBook === null || doc.signerBook !== f.principalBook || isUnderAdi(doc.signerBook, f.agentAdi))
|
|
36
|
+
return `${kind}_not_signed_by_principal`;
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
/** The enrollment state from chain facts, and the next step to carry out (null when enrolled). Fail closed on any malformed fact. */
|
|
40
|
+
export function agentEnrollmentState(f) {
|
|
41
|
+
const no = (state, next, cause) => ({ enrolled: false, state, next, ...(cause !== undefined ? { cause } : {}) });
|
|
42
|
+
if (!f || typeof f.agentAdi !== 'string' || !ACC.test(f.agentAdi) || typeof f.principalAdi !== 'string' || !ACC.test(f.principalAdi)
|
|
43
|
+
|| typeof f.principalBook !== 'string' || !f.principalBook.startsWith(`${f.principalAdi}/`)
|
|
44
|
+
|| !validList(f.adiAuthorities) || !validList(f.keyBookAuthorities) || f.pendingAuthorityAdds === null || typeof f.pendingAuthorityAdds !== 'object'
|
|
45
|
+
|| !f.registryResolve || typeof f.registryResolve.ok !== 'boolean')
|
|
46
|
+
return no('enrollment_input_malformed', null);
|
|
47
|
+
if (isUnderAdi(f.principalBook, f.agentAdi) || isUnderAdi(f.principalAdi, f.agentAdi))
|
|
48
|
+
return no('enrollment_owner_is_agent', null);
|
|
49
|
+
if (!active(f.adiAuthorities, f.principalBook)) {
|
|
50
|
+
return f.pendingAuthorityAdds.adi
|
|
51
|
+
? no('enrollment_acceptance_pending', { step: 'accept_authority', signer: 'principal', account: 'identity', pendingTx: f.pendingAuthorityAdds.adi })
|
|
52
|
+
: no('enrollment_owner_not_on_adi', { step: 'add_authority', signer: 'agent', account: 'identity' });
|
|
53
|
+
}
|
|
54
|
+
if (!active(f.keyBookAuthorities, f.principalBook)) {
|
|
55
|
+
return f.pendingAuthorityAdds.keyBook
|
|
56
|
+
? no('enrollment_acceptance_pending', { step: 'accept_authority', signer: 'principal', account: 'book', pendingTx: f.pendingAuthorityAdds.keyBook })
|
|
57
|
+
: no('enrollment_owner_not_on_keybook', { step: 'add_authority', signer: 'agent', account: 'book' });
|
|
58
|
+
}
|
|
59
|
+
// AGT-F28: the agent's own book DISABLED on its key book, so a key-page change (the owner's revocation) needs the principal alone.
|
|
60
|
+
// Accumulate v1.4.6: readiness counts enabled authorities only (internal/core/execute/v2/block/transaction.go:207-224); the disable is
|
|
61
|
+
// UpdateAccountAuth `disable` {authority} (protocol/types_gen.go:334), which needs both books' votes (protocol/access_control.go:13).
|
|
62
|
+
if (f.keyBookAuthorities.some((a) => a.disabled === false && isUnderAdi(a.url, f.agentAdi))) {
|
|
63
|
+
const pend = f.pendingAuthorityAdds.disableAgentBook;
|
|
64
|
+
return pend
|
|
65
|
+
? no('enrollment_disable_pending', { step: 'accept_disable', signer: 'principal', account: 'book', pendingTx: pend })
|
|
66
|
+
: no('enrollment_agent_book_not_disabled_on_keybook', { step: 'disable_agent_book', signer: 'agent', account: 'book' });
|
|
67
|
+
}
|
|
68
|
+
const r = f.registryResolve;
|
|
69
|
+
if (r.ok !== true)
|
|
70
|
+
return no('enrollment_subject_unproven', { step: 'register_subject', signer: 'principal' }, r.reason);
|
|
71
|
+
if (r.subject.adi !== f.agentAdi || r.subject.type !== 'agent')
|
|
72
|
+
return no('enrollment_subject_mismatch', null);
|
|
73
|
+
const g = documentState(f.grant, f, 'grant');
|
|
74
|
+
if (g)
|
|
75
|
+
return no(g, g === 'enrollment_input_malformed' ? null : { step: 'issue_grant', signer: 'principal' });
|
|
76
|
+
const m = documentState(f.mandate, f, 'mandate');
|
|
77
|
+
if (m)
|
|
78
|
+
return no(m, m === 'enrollment_input_malformed' ? null : { step: 'issue_mandate', signer: 'principal' });
|
|
79
|
+
return { enrolled: true, state: 'enrolled', next: null };
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* The governance operation for an `add_authority` step, in the gateway's governance shape (types.ts: add_authority with
|
|
83
|
+
* `authority_url`, and `account_url` for the key book). Only the agent-side step has an operation: the acceptance is the
|
|
84
|
+
* principal's signature on the pending transaction, never an operation the agent can submit.
|
|
85
|
+
*/
|
|
86
|
+
export function agentBookDisableOperation(agentAdi) {
|
|
87
|
+
if (!ACC.test(agentAdi) || agentAdi.split('/').length !== 3)
|
|
88
|
+
throw new Error('agent_authority_operation_malformed');
|
|
89
|
+
return { type: 'disable_authority', authority_url: `${agentAdi}/book`, account_url: `${agentAdi}/book` };
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* The governance operation for an `add_authority` step (above: the `disable_agent_book` step's operation, which the agent submits and the
|
|
93
|
+
* principal co-signs; UpdateAccountAuth needs every authority's vote).
|
|
94
|
+
*/
|
|
95
|
+
export function agentAuthorityOperation(f, account) {
|
|
96
|
+
if (!ACC.test(f.agentAdi) || !ACC.test(f.principalBook) || isUnderAdi(f.principalBook, f.agentAdi))
|
|
97
|
+
throw new Error('agent_authority_operation_malformed');
|
|
98
|
+
return account === 'book'
|
|
99
|
+
? { type: 'add_authority', authority_url: f.principalBook, account_url: `${f.agentAdi}/book` }
|
|
100
|
+
: { type: 'add_authority', authority_url: f.principalBook };
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=agent-enrollment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-enrollment.js","sourceRoot":"","sources":["../src/agent-enrollment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAyDH,MAAM,GAAG,GAAG,sDAAsD,CAAC;AACnE,MAAM,MAAM,GAAG,CAAC,CAAS,EAAU,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/E,8EAA8E;AAC9E,MAAM,UAAU,UAAU,CAAC,GAAW,EAAE,GAAW;IACjD,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,KAAK,CAAC;IACnD,MAAM,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IACtB,MAAM,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IACtB,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACxC,CAAC;AAED,MAAM,MAAM,GAAG,CAAC,IAAsB,EAAE,GAAW,EAAW,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,GAA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,CAAC,CAAC,MAAM,KAAK,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACpH,OAAO,EAAE,IAAI,EAAE,mBAAmB,EAAE,aAAa,EAAE,GAAG,QAAQ,OAAO,EAAE,WAAW,EAAE,GAAG,QAAQ,OAAO,EAAE,CAAC;AAC3G,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CAAC,CAA2D,EAAE,OAA4B;IAC/H,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC,CAAC,QAAQ,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;IAC3J,OAAO,OAAO,KAAK,MAAM;QACvB,CAAC,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,aAAa,EAAE,CAAC,CAAC,aAAa,EAAE,WAAW,EAAE,GAAG,CAAC,CAAC,QAAQ,OAAO,EAAE;QAC9F,CAAC,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,aAAa,EAAE,CAAC,CAAC,aAAa,EAAE,CAAC;AAChE,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export type Json = null | boolean | number | string | Json[] | {
|
|
2
|
+
[key: string]: Json;
|
|
3
|
+
};
|
|
4
|
+
/** Every refusal that a pure helper raises is a CoreError with a stable machine-readable code (never prose). */
|
|
5
|
+
export declare class CoreError extends Error {
|
|
6
|
+
readonly code: string;
|
|
7
|
+
readonly detail: string | undefined;
|
|
8
|
+
constructor(code: string, detail?: string);
|
|
9
|
+
}
|
|
10
|
+
export declare const HASH_RE: RegExp;
|
|
11
|
+
export declare const ADDRESS_RE: RegExp;
|
|
12
|
+
export declare const AMOUNT_RE: RegExp;
|
|
13
|
+
export declare const MAX_UINT256: bigint;
|
|
14
|
+
export declare function hasLoneSurrogate(s: string): boolean;
|
|
15
|
+
/** UTF-8 of a string; a lone surrogate is refused instead of being silently replaced. */
|
|
16
|
+
export declare function utf8(s: string): Uint8Array;
|
|
17
|
+
/** Number of bytes a string takes in UTF-8 (a lone surrogate counts as the three bytes of its replacement). */
|
|
18
|
+
export declare function utf8Length(s: string): number;
|
|
19
|
+
/** Strict UTF-8 decode: invalid sequences are refused, a byte order mark is kept (and so refused by the JSON parser). */
|
|
20
|
+
export declare function utf8Decode(bytes: Uint8Array): string;
|
|
21
|
+
export declare function toHex(bytes: Uint8Array): string;
|
|
22
|
+
/** Lowercase hex only, even length; anything else is refused. */
|
|
23
|
+
export declare function fromHex(s: string): Uint8Array;
|
|
24
|
+
export declare function sha256(data: Uint8Array): Uint8Array;
|
|
25
|
+
export declare function concat(...parts: Uint8Array[]): Uint8Array;
|
|
26
|
+
/** Big-endian unsigned 64-bit integer. */
|
|
27
|
+
export declare function be64(n: number | bigint): Uint8Array;
|
|
28
|
+
/** lp(x): the four-byte big-endian length of x followed by x (proof v2 convention). */
|
|
29
|
+
export declare function lp(x: Uint8Array): Uint8Array;
|
|
30
|
+
/** `0x` plus 64 lowercase hex digits to its 32 bytes. */
|
|
31
|
+
export declare function hash32(s: unknown, what: string): Uint8Array;
|
|
32
|
+
/** `0x` plus 40 lowercase hex digits to its 20 bytes. */
|
|
33
|
+
export declare function address20(s: unknown, what: string): Uint8Array;
|
|
34
|
+
/** Decimal unsigned integer text with no sign and no leading zero, at most 2^256-1. */
|
|
35
|
+
export declare function isAmount(s: unknown): s is string;
|
|
36
|
+
export declare function isPlainObject(v: unknown): v is Record<string, unknown>;
|
|
37
|
+
export declare function bytesEqual(a: Uint8Array, b: Uint8Array): boolean;
|
|
38
|
+
//# sourceMappingURL=bytes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bytes.d.ts","sourceRoot":"","sources":["../../src/core/bytes.ts"],"names":[],"mappings":"AAMA,MAAM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