@certen.io/sdk 0.14.1 → 0.16.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 +44 -0
- package/README.md +20 -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 +112 -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 +175 -0
- package/dist/principal-intervention.d.ts.map +1 -0
- package/dist/principal-intervention.js +247 -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
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type { CertenClient } from './client.js';
|
|
2
|
+
export declare const ENTRY_TAGS: {
|
|
3
|
+
readonly grant: "certen:grant:v1";
|
|
4
|
+
readonly subject: "certen:subject:v1";
|
|
5
|
+
readonly subject2: "certen:subject:v2";
|
|
6
|
+
readonly mandate: "certen:mandate:v1";
|
|
7
|
+
readonly envelopeSig: "certen:envelope-sig:v1";
|
|
8
|
+
};
|
|
9
|
+
export declare const PRINCIPAL_ACCOUNTS: {
|
|
10
|
+
readonly registration: "certen-subjects";
|
|
11
|
+
readonly grant: "certen-grants";
|
|
12
|
+
readonly mandate: "certen-mandates";
|
|
13
|
+
};
|
|
14
|
+
export type PrincipalEntryKind = keyof typeof PRINCIPAL_ACCOUNTS;
|
|
15
|
+
/** A refusal before anything is sent or signed. */
|
|
16
|
+
export declare const PRINCIPAL_ENTRY_MALFORMED = "PRINCIPAL_ENTRY_MALFORMED";
|
|
17
|
+
export declare const PRINCIPAL_ENTRY_NOT_PRINCIPALS = "PRINCIPAL_ENTRY_NOT_PRINCIPALS";
|
|
18
|
+
export declare const PRINCIPAL_PAGE_INVALID = "PRINCIPAL_PAGE_INVALID";
|
|
19
|
+
export declare const PRINCIPAL_WRITE_UNSIGNED = "PRINCIPAL_WRITE_UNSIGNED";
|
|
20
|
+
/** The core's profile function refused the document; `details` carries the core's {reason, detail}. */
|
|
21
|
+
export declare const PRINCIPAL_ENTRY_REFUSED_BY_CORE = "PRINCIPAL_ENTRY_REFUSED_BY_CORE";
|
|
22
|
+
/**
|
|
23
|
+
* RFC 8785 canonical text of a JSON value: object members sorted by UTF-16 code units, no whitespace, strings and integers in their
|
|
24
|
+
* ECMAScript serialization. Refused (PRINCIPAL_ENTRY_MALFORMED): a number that is not a safe integer, a lone surrogate, undefined, a
|
|
25
|
+
* function, a Date / Map / typed array or any other non-plain object, and nesting deeper than 64.
|
|
26
|
+
*/
|
|
27
|
+
export declare function canonicalJson(value: unknown): string;
|
|
28
|
+
/** lp(tag) || lp(field) || ... */
|
|
29
|
+
export declare function taggedPreimage(tag: string, fields: Uint8Array[]): Uint8Array;
|
|
30
|
+
/** The tag a document is hashed and signed under: by its kind, and for a registration by its schema. */
|
|
31
|
+
export declare function entryTag(kind: PrincipalEntryKind, document: Record<string, unknown>): string;
|
|
32
|
+
/** The payload hash of a document: SHA-256(lp(tag) || lp(canonical text)), 0x + lowercase hex. */
|
|
33
|
+
export declare function entryHash(kind: PrincipalEntryKind, document: Record<string, unknown>): string;
|
|
34
|
+
/** What a key signs for an envelope: SHA-256(lp("certen:envelope-sig:v1") || lp(tag) || lp(hash bytes) || lp(page)), as hex. */
|
|
35
|
+
export declare function envelopeDigestHex(payloadTag: string, payloadHash: string, page: string): string;
|
|
36
|
+
/** The principal's signing key: an ed25519 key on the principal's page. `sign` signs 32 bytes given as hex and returns 64 bytes as hex. */
|
|
37
|
+
export interface PrincipalSigner {
|
|
38
|
+
publicKey: string;
|
|
39
|
+
sign(hashHex: string): string;
|
|
40
|
+
}
|
|
41
|
+
export interface PrincipalEntry {
|
|
42
|
+
kind: PrincipalEntryKind;
|
|
43
|
+
account: string;
|
|
44
|
+
tag: string;
|
|
45
|
+
hash: string;
|
|
46
|
+
/** element 0 (the document) and element 1 (the envelope), canonical text */
|
|
47
|
+
texts: [string, string];
|
|
48
|
+
/** the same two elements as lowercase hex of their UTF-8 bytes: what write_data carries and what is hashed on chain */
|
|
49
|
+
elements: [string, string];
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Build the entry the principal writes: the canonical document, and an envelope over it signed by the principal's key for the principal's
|
|
53
|
+
* page. Refused before anything is signed: an unknown schema, a document that is not the principal's (its principal book is not the book
|
|
54
|
+
* of the signing page), a page outside the principal's ADI, a key that is not hex.
|
|
55
|
+
*/
|
|
56
|
+
export declare function buildPrincipalEntry(a: {
|
|
57
|
+
kind: PrincipalEntryKind;
|
|
58
|
+
principal: string;
|
|
59
|
+
page: string;
|
|
60
|
+
document: unknown;
|
|
61
|
+
signer: PrincipalSigner;
|
|
62
|
+
}): PrincipalEntry;
|
|
63
|
+
/** The core profile verdict of a document: null when the core accepts it, else the core's reason and detail. Never throws. */
|
|
64
|
+
export declare function coreVerdict(kind: PrincipalEntryKind, document: unknown): {
|
|
65
|
+
reason: string;
|
|
66
|
+
detail?: string;
|
|
67
|
+
} | null;
|
|
68
|
+
export interface PrincipalWriteResult {
|
|
69
|
+
entry: PrincipalEntry;
|
|
70
|
+
/** true when this call created the account; false when it already existed (DATA_ACCOUNT_EXISTS) */
|
|
71
|
+
accountCreated: boolean;
|
|
72
|
+
createTx?: string;
|
|
73
|
+
writeTx?: string;
|
|
74
|
+
writeOperationId: string;
|
|
75
|
+
/** who signed the entry's write: `principal` (this call signed and submitted it with the principal's key) or `provider` (the identity is
|
|
76
|
+
* provider-signed: the gateway signs and submits it, and `writeTx` is absent until the gateway returns one) */
|
|
77
|
+
writeSignedBy: 'principal' | 'provider';
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Write one of the principal's entries: create its account when absent (authority set: the principal's own book alone), then write the
|
|
81
|
+
* entry. Every signature is the principal's key on the principal's page. A gateway answer of DATA_ACCOUNT_EXISTS means the account is
|
|
82
|
+
* there and is written to as it is (its authority set is judged by the readers of the entry, GRANT.md section 4a).
|
|
83
|
+
*/
|
|
84
|
+
export declare function writePrincipalEntry(client: CertenClient, a: {
|
|
85
|
+
kind: PrincipalEntryKind;
|
|
86
|
+
principal: string;
|
|
87
|
+
page: string;
|
|
88
|
+
document: unknown;
|
|
89
|
+
signer: PrincipalSigner;
|
|
90
|
+
}): Promise<PrincipalWriteResult>;
|
|
91
|
+
/** The agent's GR-62 registration in the principal's registry (subject type agent). */
|
|
92
|
+
export declare const registerAgent: (client: CertenClient, a: {
|
|
93
|
+
principal: string;
|
|
94
|
+
page: string;
|
|
95
|
+
registration: unknown;
|
|
96
|
+
signer: PrincipalSigner;
|
|
97
|
+
}) => Promise<PrincipalWriteResult>;
|
|
98
|
+
/** The Grant the principal issues (certen:grant:v1). */
|
|
99
|
+
export declare const issueGrant: (client: CertenClient, a: {
|
|
100
|
+
principal: string;
|
|
101
|
+
page: string;
|
|
102
|
+
grant: unknown;
|
|
103
|
+
signer: PrincipalSigner;
|
|
104
|
+
}) => Promise<PrincipalWriteResult>;
|
|
105
|
+
/** The mandate the principal signs (certen.mandate/v1, AGENT-GRANT.md section 3). */
|
|
106
|
+
export declare const issueMandate: (client: CertenClient, a: {
|
|
107
|
+
principal: string;
|
|
108
|
+
page: string;
|
|
109
|
+
mandate: unknown;
|
|
110
|
+
signer: PrincipalSigner;
|
|
111
|
+
}) => Promise<PrincipalWriteResult>;
|
|
112
|
+
//# sourceMappingURL=principal-entries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"principal-entries.d.ts","sourceRoot":"","sources":["../src/principal-entries.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAMhD,eAAO,MAAM,UAAU;;;;;;CAMb,CAAC;AAEX,eAAO,MAAM,kBAAkB;;;;CAAmG,CAAC;AACnI,MAAM,MAAM,kBAAkB,GAAG,MAAM,OAAO,kBAAkB,CAAC;AAQjE,mDAAmD;AACnD,eAAO,MAAM,yBAAyB,8BAA8B,CAAC;AACrE,eAAO,MAAM,8BAA8B,mCAAmC,CAAC;AAC/E,eAAO,MAAM,sBAAsB,2BAA2B,CAAC;AAC/D,eAAO,MAAM,wBAAwB,6BAA6B,CAAC;AACnE,uGAAuG;AACvG,eAAO,MAAM,+BAA+B,oCAAoC,CAAC;AAKjF;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEpD;AAkCD,kCAAkC;AAClC,wBAA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AAE,eAAe,CAAA;CAAE,kCACL,CAAC"}
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The principal's own CERTEN entries (AGT-2 WP1, finding AGT-F20): the subject registration (GR-62 registry, subject type agent), the
|
|
3
|
+
* Grant (certen.grant/v1) and the mandate (certen.mandate/v1), each written to the principal's own data account
|
|
4
|
+
* (`<principal>/certen-subjects`, `certen-grants`, `certen-mandates`) through the gateway's two-phase governance route
|
|
5
|
+
* (`create_data_account`, `write_data`). Every Accumulate transaction is signed by the principal's own key page, and every entry carries an
|
|
6
|
+
* envelope the principal's key signed: nothing is signed by the gateway or the bridge.
|
|
7
|
+
*
|
|
8
|
+
* The bytes are the core's (transaction-controls packages/core and packages/agent): element 0 is the RFC 8785 canonical text of the
|
|
9
|
+
* document, element 1 the canonical text of its envelope {payloadTag, payloadHash, signatures}; payloadHash = SHA-256(lp(tag) ||
|
|
10
|
+
* lp(canonical text)) and a key signs SHA-256(lp("certen:envelope-sig:v1") || lp(tag) || lp(hash bytes) || lp(page)), lp = 4-byte
|
|
11
|
+
* big-endian length then the bytes. The cross-repo vector test (test/principal-entries.vectors.test.ts) holds these to the tcl vectors.
|
|
12
|
+
*
|
|
13
|
+
* Before anything is signed or sent, every document is judged by the CORE's own profile functions (AGT-F25): validateGrant,
|
|
14
|
+
* validateRegistration and the mandate shape (mandateShape), byte-pinned copies of transaction-controls in src/core and src/agent
|
|
15
|
+
* (scripts/sync-core.mjs, src/core/PIN.json; src/agent/core.ts is this package's own unpinned shim). A refusal is
|
|
16
|
+
* PRINCIPAL_ENTRY_REFUSED_BY_CORE with the core's reason; nothing of the profile is re-implemented here.
|
|
17
|
+
*/
|
|
18
|
+
import { CertenError } from './errors.js';
|
|
19
|
+
import { bytesToHex, concatBytes, hexToBytes, utf8 } from './bytes.js';
|
|
20
|
+
import { sha256 } from './sha256.js';
|
|
21
|
+
import { checkGovernanceSigning } from './signing-check.js';
|
|
22
|
+
import { parseGrantTextUnhashed, validateGrant } from './core/grant-profile.js';
|
|
23
|
+
import { parseRegistrationTextUnhashed, validateRegistration } from './core/registry-profile.js';
|
|
24
|
+
import { canonicalize } from './core/jcs.js';
|
|
25
|
+
import { mandateShape } from './agent/mandate.js';
|
|
26
|
+
export const ENTRY_TAGS = {
|
|
27
|
+
grant: 'certen:grant:v1',
|
|
28
|
+
subject: 'certen:subject:v1',
|
|
29
|
+
subject2: 'certen:subject:v2',
|
|
30
|
+
mandate: 'certen:mandate:v1',
|
|
31
|
+
envelopeSig: 'certen:envelope-sig:v1',
|
|
32
|
+
};
|
|
33
|
+
export const PRINCIPAL_ACCOUNTS = { registration: 'certen-subjects', grant: 'certen-grants', mandate: 'certen-mandates' };
|
|
34
|
+
const SCHEMAS = {
|
|
35
|
+
registration: ['certen.subject/v2'],
|
|
36
|
+
grant: ['certen.grant/v1'],
|
|
37
|
+
mandate: ['certen.mandate/v1'],
|
|
38
|
+
};
|
|
39
|
+
/** A refusal before anything is sent or signed. */
|
|
40
|
+
export const PRINCIPAL_ENTRY_MALFORMED = 'PRINCIPAL_ENTRY_MALFORMED';
|
|
41
|
+
export const PRINCIPAL_ENTRY_NOT_PRINCIPALS = 'PRINCIPAL_ENTRY_NOT_PRINCIPALS';
|
|
42
|
+
export const PRINCIPAL_PAGE_INVALID = 'PRINCIPAL_PAGE_INVALID';
|
|
43
|
+
export const PRINCIPAL_WRITE_UNSIGNED = 'PRINCIPAL_WRITE_UNSIGNED';
|
|
44
|
+
/** The core's profile function refused the document; `details` carries the core's {reason, detail}. */
|
|
45
|
+
export const PRINCIPAL_ENTRY_REFUSED_BY_CORE = 'PRINCIPAL_ENTRY_REFUSED_BY_CORE';
|
|
46
|
+
const refuse = (code, message) => { throw new CertenError(message, 0, code); };
|
|
47
|
+
// ── RFC 8785 canonical JSON (the subset the core's documents use) ─────────────────────────────────────────
|
|
48
|
+
/**
|
|
49
|
+
* RFC 8785 canonical text of a JSON value: object members sorted by UTF-16 code units, no whitespace, strings and integers in their
|
|
50
|
+
* ECMAScript serialization. Refused (PRINCIPAL_ENTRY_MALFORMED): a number that is not a safe integer, a lone surrogate, undefined, a
|
|
51
|
+
* function, a Date / Map / typed array or any other non-plain object, and nesting deeper than 64.
|
|
52
|
+
*/
|
|
53
|
+
export function canonicalJson(value) {
|
|
54
|
+
return canon(value, 0);
|
|
55
|
+
}
|
|
56
|
+
function canon(v, depth) {
|
|
57
|
+
if (depth > 64)
|
|
58
|
+
refuse(PRINCIPAL_ENTRY_MALFORMED, 'nested more than 64 levels');
|
|
59
|
+
if (v === null)
|
|
60
|
+
return 'null';
|
|
61
|
+
if (typeof v === 'boolean')
|
|
62
|
+
return v ? 'true' : 'false';
|
|
63
|
+
if (typeof v === 'number') {
|
|
64
|
+
if (!Number.isSafeInteger(v))
|
|
65
|
+
refuse(PRINCIPAL_ENTRY_MALFORMED, `the number ${String(v)} is not a safe integer`);
|
|
66
|
+
return Object.is(v, -0) ? '0' : String(v);
|
|
67
|
+
}
|
|
68
|
+
if (typeof v === 'string') {
|
|
69
|
+
if (/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/.test(v))
|
|
70
|
+
refuse(PRINCIPAL_ENTRY_MALFORMED, 'a string holds a lone surrogate');
|
|
71
|
+
return JSON.stringify(v);
|
|
72
|
+
}
|
|
73
|
+
if (Array.isArray(v))
|
|
74
|
+
return `[${v.map((x) => canon(x, depth + 1)).join(',')}]`;
|
|
75
|
+
if (typeof v === 'object' && Object.prototype.toString.call(v) === '[object Object]') {
|
|
76
|
+
const o = v;
|
|
77
|
+
const keys = Object.keys(o).sort();
|
|
78
|
+
return `{${keys.map((k) => {
|
|
79
|
+
if (o[k] === undefined)
|
|
80
|
+
refuse(PRINCIPAL_ENTRY_MALFORMED, `member ${k} is undefined`);
|
|
81
|
+
return `${canon(k, depth + 1)}:${canon(o[k], depth + 1)}`;
|
|
82
|
+
}).join(',')}}`;
|
|
83
|
+
}
|
|
84
|
+
return refuse(PRINCIPAL_ENTRY_MALFORMED, `a ${typeof v} is not JSON`);
|
|
85
|
+
}
|
|
86
|
+
// ── the core's tagged hashes ──────────────────────────────────────────────────────────────────────────────
|
|
87
|
+
const lp = (b) => {
|
|
88
|
+
const n = new Uint8Array(4);
|
|
89
|
+
new DataView(n.buffer).setUint32(0, b.length, false);
|
|
90
|
+
return concatBytes(n, b);
|
|
91
|
+
};
|
|
92
|
+
/** lp(tag) || lp(field) || ... */
|
|
93
|
+
export function taggedPreimage(tag, fields) {
|
|
94
|
+
return concatBytes(lp(utf8(tag)), ...fields.map(lp));
|
|
95
|
+
}
|
|
96
|
+
const hex0x = (b) => '0x' + bytesToHex(b);
|
|
97
|
+
/** The tag a document is hashed and signed under: by its kind, and for a registration by its schema. */
|
|
98
|
+
export function entryTag(kind, document) {
|
|
99
|
+
if (kind === 'grant')
|
|
100
|
+
return ENTRY_TAGS.grant;
|
|
101
|
+
if (kind === 'mandate')
|
|
102
|
+
return ENTRY_TAGS.mandate;
|
|
103
|
+
return document.schema === 'certen.subject/v2' ? ENTRY_TAGS.subject2 : ENTRY_TAGS.subject;
|
|
104
|
+
}
|
|
105
|
+
/** The payload hash of a document: SHA-256(lp(tag) || lp(canonical text)), 0x + lowercase hex. */
|
|
106
|
+
export function entryHash(kind, document) {
|
|
107
|
+
return hex0x(sha256(taggedPreimage(entryTag(kind, document), [utf8(canonicalJson(document))])));
|
|
108
|
+
}
|
|
109
|
+
/** What a key signs for an envelope: SHA-256(lp("certen:envelope-sig:v1") || lp(tag) || lp(hash bytes) || lp(page)), as hex. */
|
|
110
|
+
export function envelopeDigestHex(payloadTag, payloadHash, page) {
|
|
111
|
+
if (!/^0x[0-9a-f]{64}$/.test(payloadHash))
|
|
112
|
+
refuse(PRINCIPAL_ENTRY_MALFORMED, 'payloadHash must be 0x + 64 lowercase hex');
|
|
113
|
+
return bytesToHex(sha256(taggedPreimage(ENTRY_TAGS.envelopeSig, [utf8(payloadTag), hexToBytes(payloadHash.slice(2)), utf8(page)])));
|
|
114
|
+
}
|
|
115
|
+
const ACC = /^acc:\/\/[a-z0-9][a-z0-9._-]*\.acme(\/[a-z0-9][a-z0-9._-]*)*$/;
|
|
116
|
+
const isObj = (o) => o !== null && typeof o === 'object' && !Array.isArray(o);
|
|
117
|
+
/** The principal's book a document names: grant.grantor.keyBook, mandate.principal.keyBook, registration.principal.keyBook. */
|
|
118
|
+
function principalBookOf(kind, d) {
|
|
119
|
+
const holder = kind === 'grant' ? d.grantor : d.principal;
|
|
120
|
+
return isObj(holder) ? holder.keyBook : undefined;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Build the entry the principal writes: the canonical document, and an envelope over it signed by the principal's key for the principal's
|
|
124
|
+
* page. Refused before anything is signed: an unknown schema, a document that is not the principal's (its principal book is not the book
|
|
125
|
+
* of the signing page), a page outside the principal's ADI, a key that is not hex.
|
|
126
|
+
*/
|
|
127
|
+
export function buildPrincipalEntry(a) {
|
|
128
|
+
const { kind } = a;
|
|
129
|
+
if (!(kind in PRINCIPAL_ACCOUNTS))
|
|
130
|
+
refuse(PRINCIPAL_ENTRY_MALFORMED, `unknown entry kind ${String(kind)}`);
|
|
131
|
+
const adi = typeof a.principal === 'string' ? a.principal.toLowerCase().replace(/\/+$/, '') : '';
|
|
132
|
+
if (!ACC.test(adi) || adi.split('/').length !== 3)
|
|
133
|
+
refuse(PRINCIPAL_PAGE_INVALID, 'the principal must be an ADI URL');
|
|
134
|
+
const page = typeof a.page === 'string' ? a.page.toLowerCase() : '';
|
|
135
|
+
const book = page.replace(/\/[0-9]+$/, '');
|
|
136
|
+
if (!ACC.test(page) || !/\/[0-9]+$/.test(page) || !book.startsWith(adi + '/'))
|
|
137
|
+
refuse(PRINCIPAL_PAGE_INVALID, 'the signing page must be a key page of the principal\'s own book');
|
|
138
|
+
if (!isObj(a.document))
|
|
139
|
+
refuse(PRINCIPAL_ENTRY_MALFORMED, 'the document must be a JSON object');
|
|
140
|
+
const d = a.document;
|
|
141
|
+
if (!SCHEMAS[kind].includes(String(d.schema)))
|
|
142
|
+
refuse(PRINCIPAL_ENTRY_MALFORMED, `a ${kind} entry must carry schema ${SCHEMAS[kind].join(' or ')}`);
|
|
143
|
+
if (principalBookOf(kind, d) !== book)
|
|
144
|
+
refuse(PRINCIPAL_ENTRY_NOT_PRINCIPALS, `the ${kind} names another principal book than ${book}, the book of the signing page`);
|
|
145
|
+
if (kind === 'registration' && d.type !== 'agent')
|
|
146
|
+
refuse(PRINCIPAL_ENTRY_MALFORMED, 'an agent registration carries subject type agent');
|
|
147
|
+
// The core's own judgement of the document, before any key is used or anything is sent (AGT-F25).
|
|
148
|
+
const core = coreVerdict(kind, d);
|
|
149
|
+
if (core !== null)
|
|
150
|
+
throw new CertenError(`the core refuses this ${kind}: ${core.reason}${core.detail ? ` (${core.detail})` : ''}`, 0, PRINCIPAL_ENTRY_REFUSED_BY_CORE, { details: core });
|
|
151
|
+
if (!/^[0-9a-f]{64}$/.test(String(a.signer?.publicKey ?? '')))
|
|
152
|
+
refuse(PRINCIPAL_ENTRY_MALFORMED, 'the signer\'s public key must be 32 bytes of lowercase hex (ed25519)');
|
|
153
|
+
const text = canonicalJson(d);
|
|
154
|
+
const tag = entryTag(kind, d);
|
|
155
|
+
const hash = entryHash(kind, d);
|
|
156
|
+
const signature = String(a.signer.sign(envelopeDigestHex(tag, hash, page))).replace(/^0x/, '').toLowerCase();
|
|
157
|
+
if (!/^[0-9a-f]{128}$/.test(signature))
|
|
158
|
+
refuse(PRINCIPAL_WRITE_UNSIGNED, 'the signer returned no 64-byte signature');
|
|
159
|
+
const envelope = canonicalJson({ payloadTag: tag, payloadHash: hash, signatures: [{ alg: 'ed25519', page, publicKey: a.signer.publicKey, signature }] });
|
|
160
|
+
return { kind, account: `${adi}/${PRINCIPAL_ACCOUNTS[kind]}`, tag, hash, texts: [text, envelope], elements: [bytesToHex(utf8(text)), bytesToHex(utf8(envelope))] };
|
|
161
|
+
}
|
|
162
|
+
/** The core profile verdict of a document: null when the core accepts it, else the core's reason and detail. Never throws. */
|
|
163
|
+
export function coreVerdict(kind, document) {
|
|
164
|
+
try {
|
|
165
|
+
// A Grant or registration is judged as the core judges it AND as every reader will read the entry: the profile, then the canonical
|
|
166
|
+
// text the entry carries through the core's own text parse (its size bound and number rules live there).
|
|
167
|
+
if (kind === 'grant') {
|
|
168
|
+
const v = validateGrant(document);
|
|
169
|
+
if (!v.ok)
|
|
170
|
+
return { reason: v.reason, ...(v.detail ? { detail: v.detail } : {}) };
|
|
171
|
+
const t = parseGrantTextUnhashed(canonicalize(document));
|
|
172
|
+
return t.ok ? null : { reason: t.reason, ...(t.detail ? { detail: t.detail } : {}) };
|
|
173
|
+
}
|
|
174
|
+
if (kind === 'registration') {
|
|
175
|
+
const v = validateRegistration(document);
|
|
176
|
+
if (!v.ok)
|
|
177
|
+
return { reason: v.reason, ...(v.detail ? { detail: v.detail } : {}) };
|
|
178
|
+
const t = parseRegistrationTextUnhashed(canonicalize(document));
|
|
179
|
+
return t.ok ? null : { reason: t.reason, ...(t.detail ? { detail: t.detail } : {}) };
|
|
180
|
+
}
|
|
181
|
+
const shape = mandateShape(document);
|
|
182
|
+
return shape === null ? null : { reason: 'mandate_malformed', detail: shape };
|
|
183
|
+
}
|
|
184
|
+
catch (e) {
|
|
185
|
+
return { reason: 'core_check_failed', detail: e instanceof Error ? e.message.slice(0, 120) : 'non-error throw' };
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
/** One governance operation, checked and signed by the principal's own key, or by the provider when the identity is provider-signed. */
|
|
189
|
+
async function signedOperation(client, a) {
|
|
190
|
+
const created = await client.governance.create({ identity: a.principal, operations: [a.operation], signerKeyPage: a.page, signerPublicKey: a.signer.publicKey });
|
|
191
|
+
if (created.signing_mode === 'provider' || !created.signing_data)
|
|
192
|
+
return { id: created.governance_op_id, ...(created.tx_hash ? { tx: created.tx_hash } : {}), signedBy: 'provider' };
|
|
193
|
+
// Rebuild the transaction the gateway returned and match it to exactly what was asked: nothing is signed on a mismatch.
|
|
194
|
+
await checkGovernanceSigning(created.signing_data, { adiUrl: a.principal, operations: [a.expected], signerPublicKey: a.signer.publicKey, signerKeyPage: a.page });
|
|
195
|
+
const hash = String(created.signing_data.hash_to_sign ?? '');
|
|
196
|
+
const submitted = await client.governance.submitSignature(created.governance_op_id, { signature: a.signer.sign(hash), publicKey: a.signer.publicKey });
|
|
197
|
+
return { id: created.governance_op_id, ...(submitted.tx_hash ? { tx: submitted.tx_hash } : {}), signedBy: 'principal' };
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Write one of the principal's entries: create its account when absent (authority set: the principal's own book alone), then write the
|
|
201
|
+
* entry. Every signature is the principal's key on the principal's page. A gateway answer of DATA_ACCOUNT_EXISTS means the account is
|
|
202
|
+
* there and is written to as it is (its authority set is judged by the readers of the entry, GRANT.md section 4a).
|
|
203
|
+
*/
|
|
204
|
+
export async function writePrincipalEntry(client, a) {
|
|
205
|
+
const entry = buildPrincipalEntry(a);
|
|
206
|
+
const principal = a.principal.toLowerCase().replace(/\/+$/, '');
|
|
207
|
+
const page = a.page.toLowerCase();
|
|
208
|
+
const book = page.replace(/\/[0-9]+$/, '');
|
|
209
|
+
let accountCreated = false;
|
|
210
|
+
let createTx;
|
|
211
|
+
try {
|
|
212
|
+
const c = await signedOperation(client, {
|
|
213
|
+
principal, page, signer: a.signer,
|
|
214
|
+
operation: { type: 'create_data_account', account_url: entry.account },
|
|
215
|
+
expected: { type: 'create_data_account', account_url: entry.account, authorities: [book] },
|
|
216
|
+
});
|
|
217
|
+
accountCreated = true;
|
|
218
|
+
createTx = c.tx;
|
|
219
|
+
}
|
|
220
|
+
catch (e) {
|
|
221
|
+
if (!(e instanceof CertenError && e.code === 'DATA_ACCOUNT_EXISTS'))
|
|
222
|
+
throw e;
|
|
223
|
+
}
|
|
224
|
+
const w = await signedOperation(client, {
|
|
225
|
+
principal, page, signer: a.signer,
|
|
226
|
+
operation: { type: 'write_data', account_url: entry.account, entries: entry.elements },
|
|
227
|
+
expected: { type: 'write_data', account_url: entry.account, entries: entry.elements },
|
|
228
|
+
});
|
|
229
|
+
return { entry, accountCreated, ...(createTx ? { createTx } : {}), ...(w.tx ? { writeTx: w.tx } : {}), writeOperationId: w.id, writeSignedBy: w.signedBy };
|
|
230
|
+
}
|
|
231
|
+
/** The agent's GR-62 registration in the principal's registry (subject type agent). */
|
|
232
|
+
export const registerAgent = (client, a) => writePrincipalEntry(client, { kind: 'registration', principal: a.principal, page: a.page, document: a.registration, signer: a.signer });
|
|
233
|
+
/** The Grant the principal issues (certen:grant:v1). */
|
|
234
|
+
export const issueGrant = (client, a) => writePrincipalEntry(client, { kind: 'grant', principal: a.principal, page: a.page, document: a.grant, signer: a.signer });
|
|
235
|
+
/** The mandate the principal signs (certen.mandate/v1, AGENT-GRANT.md section 3). */
|
|
236
|
+
export const issueMandate = (client, a) => writePrincipalEntry(client, { kind: 'mandate', principal: a.principal, page: a.page, document: a.mandate, signer: a.signer });
|
|
237
|
+
//# sourceMappingURL=principal-entries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"principal-entries.js","sourceRoot":"","sources":["../src/principal-entries.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACvE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,OAAO,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAChF,OAAO,EAAE,6BAA6B,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AACjG,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE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,CAAC,CAAC,YAAY,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;AAC1I,wDAAwD;AACxD,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,MAAoB,EAAE,CAA+E,EAAE,EAAE,CAClI,mBAAmB,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,CAAC,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;AAC5H,qFAAqF;AACrF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,MAAoB,EAAE,CAAiF,EAAE,EAAE,CACtI,mBAAmB,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,CAAC,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { type PrincipalSigner, type PrincipalWriteResult } from './principal-entries.js';
|
|
2
|
+
import type { CertenClient } from './client.js';
|
|
3
|
+
import type { SignResponse } from './types.js';
|
|
4
|
+
/** The revocation model in force (DEC-2), verbatim. Every revoke or cancel result carries it. */
|
|
5
|
+
export declare const EXPOSURE_WINDOW_STATEMENT = "Before final approval, a required authority's reject vote or key removal stops the action. After certification, exposure is limited to the exact approved action inside its window. No on-chain cancel.";
|
|
6
|
+
export declare const INTERVENTION_MALFORMED = "INTERVENTION_MALFORMED";
|
|
7
|
+
/** Where the named person submits a seat record (certen-approval-console src/web/app.ts). */
|
|
8
|
+
export declare const SEAT_RECORD_ROUTE = "POST /agents/interventions";
|
|
9
|
+
/** The sentence every intervention result carries next to `seatRecord`. */
|
|
10
|
+
export declare const SEAT_RECORD_STATEMENT = "This act is recorded in the seat's decision log only when the named person submits seatRecord at the seat (POST /agents/interventions) in a person session; the SDK holds no person session and has not recorded it, and the Console records only an act it reads on chain.";
|
|
11
|
+
/** The Console's acts: `revoke` (the Grant ended, with the key half), `replace` (the registration retired), `reject` (a reject vote). */
|
|
12
|
+
export type InterventionAct = 'revoke' | 'replace' | 'reject';
|
|
13
|
+
/**
|
|
14
|
+
* Why a transaction hash is absent from a seat record:
|
|
15
|
+
* provider_signing_pending the identity is provider-signed and the gateway has not returned the transaction hash yet;
|
|
16
|
+
* gateway_returned_none the SDK signed and submitted and the gateway's answer named no transaction hash;
|
|
17
|
+
* tx_hash_unreadable the gateway's value is neither a 64-hex transaction hash nor a TxID `acc://<hash>@<account>`;
|
|
18
|
+
* grant_write_not_in_this_call revokeAgentKey performs the key half only; a revoke's txHash is the Grant write (revokeSeatRecord joins them).
|
|
19
|
+
*/
|
|
20
|
+
export type SeatRecordAbsenceCode = 'provider_signing_pending' | 'gateway_returned_none' | 'tx_hash_unreadable' | 'grant_write_not_in_this_call';
|
|
21
|
+
export interface SeatRecordAbsence {
|
|
22
|
+
field: 'txHash' | 'keyTxHash';
|
|
23
|
+
code: SeatRecordAbsenceCode;
|
|
24
|
+
detail: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The form POST /agents/interventions takes: act, subject (the agent ADI), seat, reason, txHash (64 hex: the Accumulate transaction that IS
|
|
28
|
+
* the act), keyTxHash (revoke: the key operation), replacedBy (replace: the successor agent ADI). `absent` is present only when a hash is
|
|
29
|
+
* missing and names which and why; the Console reads only the form's own fields.
|
|
30
|
+
*/
|
|
31
|
+
export interface SeatRecord {
|
|
32
|
+
act: InterventionAct;
|
|
33
|
+
subject: string;
|
|
34
|
+
seat: string;
|
|
35
|
+
reason: string;
|
|
36
|
+
txHash?: string;
|
|
37
|
+
keyTxHash?: string;
|
|
38
|
+
replacedBy?: string;
|
|
39
|
+
absent?: SeatRecordAbsence[];
|
|
40
|
+
}
|
|
41
|
+
/** What every intervention result adds: the record for the named person, and that it is not recorded yet. */
|
|
42
|
+
export interface SeatRecordPart {
|
|
43
|
+
seatRecord: SeatRecord;
|
|
44
|
+
recordedAtSeat: false;
|
|
45
|
+
seatRecordStatement: string;
|
|
46
|
+
}
|
|
47
|
+
/** The superseding version of a Grant: version + 1, prior hash = the head's hash, an EMPTY validity starting where the head's starts. */
|
|
48
|
+
export declare function revocationOf(head: unknown, issuedAt: number): Record<string, unknown>;
|
|
49
|
+
export interface RevokeGrantResult extends PrincipalWriteResult, SeatRecordPart {
|
|
50
|
+
seat: string;
|
|
51
|
+
reason: string;
|
|
52
|
+
exposureWindow: string;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Revoke the agent's Grant: write the superseding version with an empty validity (the core judges it; the principal's page signs).
|
|
56
|
+
* `seatRecord`: act revoke, subject the Grant's agent, txHash the Grant write. With the key half (revokeAgentKey), join the two results with
|
|
57
|
+
* revokeSeatRecord into the one record the seat takes.
|
|
58
|
+
*/
|
|
59
|
+
export declare function revokeGrant(client: CertenClient, a: {
|
|
60
|
+
principal: string;
|
|
61
|
+
page: string;
|
|
62
|
+
head: unknown;
|
|
63
|
+
issuedAt?: number;
|
|
64
|
+
signer: PrincipalSigner;
|
|
65
|
+
seat: string;
|
|
66
|
+
reason: string;
|
|
67
|
+
}): Promise<RevokeGrantResult>;
|
|
68
|
+
/**
|
|
69
|
+
* The key half of a revocation (AGT-F32): ONE updateKeyPage that ADDS the owner-held revocation key and then REMOVES the agent's key.
|
|
70
|
+
* Accumulate refuses to delete the last key of a book's page 1 (internal/core/execute/v2/chain/update_key_page.go:248), so a remove
|
|
71
|
+
* alone fails on chain for a one-key agent page; with the owner's key added first the page stays usable.
|
|
72
|
+
*/
|
|
73
|
+
export declare function agentKeyRemoval(keyHash: string, revocationKeyHash: string): Array<{
|
|
74
|
+
type: 'add_key' | 'remove_key';
|
|
75
|
+
public_key_hash: string;
|
|
76
|
+
}>;
|
|
77
|
+
export interface RevokeKeyResult extends SeatRecordPart {
|
|
78
|
+
governanceOperationId: string;
|
|
79
|
+
txHash?: string;
|
|
80
|
+
agentPage: string;
|
|
81
|
+
seat: string;
|
|
82
|
+
reason: string;
|
|
83
|
+
exposureWindow: string;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Remove the agent's key from the agent's key page, signed by the OWNER's page. The signing data is rebuilt and must be exactly an
|
|
87
|
+
* updateKeyPage of the agent's page removing exactly that key, signed by the owner's key on the owner's page; nothing is signed otherwise.
|
|
88
|
+
* `seatRecord`: act revoke, subject the agent page's ADI, keyTxHash this key operation; its txHash is ABSENT (grant_write_not_in_this_call)
|
|
89
|
+
* because a revoke's txHash is the Grant write: join this result with revokeGrant's through revokeSeatRecord.
|
|
90
|
+
*/
|
|
91
|
+
export declare function revokeAgentKey(client: CertenClient, a: {
|
|
92
|
+
principal: string;
|
|
93
|
+
page: string;
|
|
94
|
+
agentPage: string;
|
|
95
|
+
keyHash: string;
|
|
96
|
+
revocationKeyHash: string;
|
|
97
|
+
signer: PrincipalSigner;
|
|
98
|
+
seat: string;
|
|
99
|
+
reason: string;
|
|
100
|
+
}): Promise<RevokeKeyResult>;
|
|
101
|
+
/**
|
|
102
|
+
* The ONE seat record of a revoke done in two calls (revokeGrant, then revokeAgentKey): txHash from the Grant write, keyTxHash from the key
|
|
103
|
+
* operation, each half's absence carried by name. The halves must be one act: the same agent, seat and reason (refused otherwise).
|
|
104
|
+
*/
|
|
105
|
+
export declare function revokeSeatRecord(grantResult: RevokeGrantResult, keyResult: RevokeKeyResult): SeatRecordPart;
|
|
106
|
+
export interface RejectVoteOpened extends SeatRecordPart {
|
|
107
|
+
created: SignResponse;
|
|
108
|
+
txHash: string;
|
|
109
|
+
seat: string;
|
|
110
|
+
reason: string;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* The first half of a cancel by reject vote, shared by cancelByRejectVote (which then checks and signs with the key it holds) and the MCP tool
|
|
114
|
+
* certen_agent_cancel_by_reject_vote (which holds no key and returns the signing data to be signed elsewhere): the named seat and reason, the
|
|
115
|
+
* agent (`subject`), the pending transaction and the signing page are checked, the REJECT sign request is opened for `publicKey`, and the seat
|
|
116
|
+
* record is built. Nothing is signed here; the caller checks `created.signing_data` against the transaction, the vote and the signer before any
|
|
117
|
+
* signature exists.
|
|
118
|
+
*/
|
|
119
|
+
export declare function openRejectVote(client: CertenClient, a: {
|
|
120
|
+
identity: string;
|
|
121
|
+
subject: string;
|
|
122
|
+
txHash: string;
|
|
123
|
+
signerUrl: string;
|
|
124
|
+
publicKey: string;
|
|
125
|
+
seat: string;
|
|
126
|
+
reason: string;
|
|
127
|
+
}): Promise<RejectVoteOpened>;
|
|
128
|
+
export interface CancelResult extends SeatRecordPart {
|
|
129
|
+
signRequestId: string;
|
|
130
|
+
status: string;
|
|
131
|
+
txHash: string;
|
|
132
|
+
vote: 'reject';
|
|
133
|
+
seat: string;
|
|
134
|
+
reason: string;
|
|
135
|
+
exposureWindow: string;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Cancel by reject vote: a required authority's REJECT on the pending transaction. The reject is a verdict only when the book can no
|
|
139
|
+
* longer reach its threshold; then Accumulate rejects the transaction and nothing executes. It stops an action only before final approval.
|
|
140
|
+
* `subject` is the agent ADI whose pending transaction is rejected (the seat record's subject; required). `seatRecord`: act reject, txHash the
|
|
141
|
+
* pending transaction. In provider signing mode the gateway casts the vote; the Console records the act only once it reads the vote on chain.
|
|
142
|
+
*/
|
|
143
|
+
export declare function cancelByRejectVote(client: CertenClient, a: {
|
|
144
|
+
identity: string;
|
|
145
|
+
subject: string;
|
|
146
|
+
txHash: string;
|
|
147
|
+
signerUrl: string;
|
|
148
|
+
signer: PrincipalSigner;
|
|
149
|
+
seat: string;
|
|
150
|
+
reason: string;
|
|
151
|
+
}): Promise<CancelResult>;
|
|
152
|
+
export interface ReplaceResult extends SeatRecordPart {
|
|
153
|
+
retired: PrincipalWriteResult;
|
|
154
|
+
registered: PrincipalWriteResult;
|
|
155
|
+
grant: PrincipalWriteResult;
|
|
156
|
+
seat: string;
|
|
157
|
+
reason: string;
|
|
158
|
+
exposureWindow: string;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Replace: the old agent's registration goes to `retired` (its next version), the new agent is registered under the same principal, and
|
|
162
|
+
* its own Grant is issued (a new grantId: GR-22 keeps a lineage's subject). Each document is judged by the core before anything is signed.
|
|
163
|
+
* `seatRecord`: act replace, subject the retired agent, txHash the retirement's write, replacedBy the new agent ADI.
|
|
164
|
+
*/
|
|
165
|
+
export declare function replaceAgent(client: CertenClient, a: {
|
|
166
|
+
principal: string;
|
|
167
|
+
page: string;
|
|
168
|
+
signer: PrincipalSigner;
|
|
169
|
+
retiredRegistration: unknown;
|
|
170
|
+
newRegistration: unknown;
|
|
171
|
+
newGrant: unknown;
|
|
172
|
+
seat: string;
|
|
173
|
+
reason: string;
|
|
174
|
+
}): Promise<ReplaceResult>;
|
|
175
|
+
//# sourceMappingURL=principal-intervention.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"principal-intervention.d.ts","sourceRoot":"","sources":["../src/principal-intervention.ts"],"names":[],"mappings":"AAyBA,OAAO,EAA6B,KAAK,eAAe,EAAE,KAAK,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACpH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,iGAAiG;AACjG,eAAO,MAAM,yBAAyB,4MACsK,CAAC;AAE7M,eAAO,MAAM,sBAAsB,2BAA2B,CAAC;AAM/D,6FAA6F;AAC7F,eAAO,MAAM,iBAAiB,+BAA+B,CAAC;AAE9D,2EAA2E;AAC3E,eAAO,MAAM,qBAAqB,gRAC8O,CAAC;AAEjR,yIAAyI;AACzI,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,SAAS,GAA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