@mcsherrylabs/evolver-mcp 0.11.0 → 0.13.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/deploy/release.json +1 -1
- package/dist/application-signer.d.ts +16 -0
- package/dist/application-signer.d.ts.map +1 -0
- package/dist/application-signer.js +55 -0
- package/dist/application-signer.js.map +1 -0
- package/dist/approved-request.d.ts +30 -0
- package/dist/approved-request.d.ts.map +1 -0
- package/dist/approved-request.js +167 -0
- package/dist/approved-request.js.map +1 -0
- package/dist/attachment-tools.d.ts +3 -0
- package/dist/attachment-tools.d.ts.map +1 -0
- package/dist/attachment-tools.js +32 -0
- package/dist/attachment-tools.js.map +1 -0
- package/dist/attachments.d.ts +41 -0
- package/dist/attachments.d.ts.map +1 -0
- package/dist/attachments.js +458 -0
- package/dist/attachments.js.map +1 -0
- package/dist/content-file-tools.d.ts +3 -0
- package/dist/content-file-tools.d.ts.map +1 -0
- package/dist/content-file-tools.js +67 -0
- package/dist/content-file-tools.js.map +1 -0
- package/dist/content-files.d.ts +32 -0
- package/dist/content-files.d.ts.map +1 -0
- package/dist/content-files.js +79 -0
- package/dist/content-files.js.map +1 -0
- package/dist/content-ranges.d.ts +41 -0
- package/dist/content-ranges.d.ts.map +1 -0
- package/dist/content-ranges.js +75 -0
- package/dist/content-ranges.js.map +1 -0
- package/dist/content.d.ts +62 -19
- package/dist/content.d.ts.map +1 -1
- package/dist/content.js +180 -25
- package/dist/content.js.map +1 -1
- package/dist/files.d.ts +60 -0
- package/dist/files.d.ts.map +1 -0
- package/dist/files.js +355 -0
- package/dist/files.js.map +1 -0
- package/dist/group-crypto-tools.d.ts +3 -0
- package/dist/group-crypto-tools.d.ts.map +1 -0
- package/dist/group-crypto-tools.js +47 -0
- package/dist/group-crypto-tools.js.map +1 -0
- package/dist/group-crypto.d.ts +24 -0
- package/dist/group-crypto.d.ts.map +1 -0
- package/dist/group-crypto.js +135 -0
- package/dist/group-crypto.js.map +1 -0
- package/dist/group-key-provider.d.ts +30 -0
- package/dist/group-key-provider.d.ts.map +1 -0
- package/dist/group-key-provider.js +72 -0
- package/dist/group-key-provider.js.map +1 -0
- package/dist/group-keys.d.ts +34 -0
- package/dist/group-keys.d.ts.map +1 -0
- package/dist/group-keys.js +88 -0
- package/dist/group-keys.js.map +1 -0
- package/dist/group-ownership.d.ts +78 -0
- package/dist/group-ownership.d.ts.map +1 -0
- package/dist/group-ownership.js +324 -0
- package/dist/group-ownership.js.map +1 -0
- package/dist/group.d.ts +2 -2
- package/dist/group.js +3 -3
- package/dist/group.js.map +1 -1
- package/dist/http-profiles.d.ts +47 -0
- package/dist/http-profiles.d.ts.map +1 -0
- package/dist/http-profiles.js +161 -0
- package/dist/http-profiles.js.map +1 -0
- package/dist/human-approval.d.ts +14 -0
- package/dist/human-approval.d.ts.map +1 -0
- package/dist/human-approval.js +34 -0
- package/dist/human-approval.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +94 -40
- package/dist/index.js.map +1 -1
- package/dist/login-profiles.d.ts +25 -0
- package/dist/login-profiles.d.ts.map +1 -0
- package/dist/login-profiles.js +77 -0
- package/dist/login-profiles.js.map +1 -0
- package/dist/login-tools.d.ts +3 -0
- package/dist/login-tools.d.ts.map +1 -0
- package/dist/login-tools.js +27 -0
- package/dist/login-tools.js.map +1 -0
- package/dist/login.d.ts +36 -0
- package/dist/login.d.ts.map +1 -0
- package/dist/login.js +144 -0
- package/dist/login.js.map +1 -0
- package/dist/mcp.d.ts +1 -0
- package/dist/mcp.d.ts.map +1 -1
- package/dist/mcp.js +22 -6
- package/dist/mcp.js.map +1 -1
- package/dist/node-transport.d.ts +14 -0
- package/dist/node-transport.d.ts.map +1 -0
- package/dist/node-transport.js +54 -0
- package/dist/node-transport.js.map +1 -0
- package/dist/p2p-tools.d.ts +3 -0
- package/dist/p2p-tools.d.ts.map +1 -0
- package/dist/p2p-tools.js +52 -0
- package/dist/p2p-tools.js.map +1 -0
- package/dist/p2p.d.ts +67 -0
- package/dist/p2p.d.ts.map +1 -0
- package/dist/p2p.js +326 -0
- package/dist/p2p.js.map +1 -0
- package/dist/proof-attempts.d.ts +19 -0
- package/dist/proof-attempts.d.ts.map +1 -0
- package/dist/proof-attempts.js +30 -0
- package/dist/proof-attempts.js.map +1 -0
- package/dist/read.d.ts +60 -1
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +97 -5
- package/dist/read.js.map +1 -1
- package/dist/signed-http-tools.d.ts +3 -0
- package/dist/signed-http-tools.d.ts.map +1 -0
- package/dist/signed-http-tools.js +33 -0
- package/dist/signed-http-tools.js.map +1 -0
- package/dist/signed-http.d.ts +30 -0
- package/dist/signed-http.d.ts.map +1 -0
- package/dist/signed-http.js +114 -0
- package/dist/signed-http.js.map +1 -0
- package/dist/tools.d.ts +27 -1
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +243 -32
- package/dist/tools.js.map +1 -1
- package/dist/transaction-interchange-tools.d.ts +3 -0
- package/dist/transaction-interchange-tools.d.ts.map +1 -0
- package/dist/transaction-interchange-tools.js +41 -0
- package/dist/transaction-interchange-tools.js.map +1 -0
- package/dist/transaction-interchange.d.ts +141 -0
- package/dist/transaction-interchange.d.ts.map +1 -0
- package/dist/transaction-interchange.js +502 -0
- package/dist/transaction-interchange.js.map +1 -0
- package/dist/transaction-policy.d.ts +32 -0
- package/dist/transaction-policy.d.ts.map +1 -0
- package/dist/transaction-policy.js +89 -0
- package/dist/transaction-policy.js.map +1 -0
- package/dist/write.d.ts +52 -13
- package/dist/write.d.ts.map +1 -1
- package/dist/write.js +95 -25
- package/dist/write.js.map +1 -1
- package/package.json +4 -3
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
// SDK-only inline crypto. No signing, submission, membership or key lifecycle mutation.
|
|
2
|
+
import { randomGroupKey, wrapGroupKey, encryptMessage, decryptMessage, edSpkiToRaw, edToX25519Pub, hexToBytes, isValidPrincipalName } from "@mcsherrylabs/evolver-client";
|
|
3
|
+
import { ok, partial } from "./result.js";
|
|
4
|
+
import { GroupKeyHandles } from "./group-keys.js";
|
|
5
|
+
import { validScope, validKeyLabel } from "./group-key-provider.js";
|
|
6
|
+
export const GROUP_MESSAGE_MAX_BYTES = 32_768;
|
|
7
|
+
// SDK0.21.1 AES-GCM message framing: 12-byte IV + plaintext + 16-byte tag.
|
|
8
|
+
export const GROUP_CIPHERTEXT_MAX_BYTES = GROUP_MESSAGE_MAX_BYTES + 28;
|
|
9
|
+
export const PLAINTEXT_CONFIRMATION = "return plaintext to this MCP client";
|
|
10
|
+
/** Canonical padded RFC4648 base64 only; bound string BEFORE decoding. No coercion/whitespace. */
|
|
11
|
+
export function groupCryptoBase64(input, minBytes, maxBytes) {
|
|
12
|
+
if (typeof input !== "string" || input.length > 4 * Math.ceil(maxBytes / 3) ||
|
|
13
|
+
!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(input))
|
|
14
|
+
throw new Error("invalid encoding or size");
|
|
15
|
+
const bytes = Buffer.from(input, "base64");
|
|
16
|
+
if (bytes.length < minBytes || bytes.length > maxBytes || bytes.toString("base64") !== input)
|
|
17
|
+
throw new Error("invalid encoding or size");
|
|
18
|
+
return bytes;
|
|
19
|
+
}
|
|
20
|
+
const base64 = (v) => Buffer.from(v).toString("base64");
|
|
21
|
+
/** One instance per stdio process/client; injected capability, no singleton cross-client store. */
|
|
22
|
+
export class GroupCrypto {
|
|
23
|
+
provider;
|
|
24
|
+
reads;
|
|
25
|
+
handles;
|
|
26
|
+
constructor(provider, reads) {
|
|
27
|
+
this.provider = provider;
|
|
28
|
+
this.reads = reads;
|
|
29
|
+
this.handles = new GroupKeyHandles(provider.identity);
|
|
30
|
+
}
|
|
31
|
+
#scope(scope) {
|
|
32
|
+
if (!validScope(scope) || !this.provider.scopes.includes(scope))
|
|
33
|
+
throw new Error("scope not authorized by host");
|
|
34
|
+
}
|
|
35
|
+
async #guard(operation) {
|
|
36
|
+
try {
|
|
37
|
+
return ok(await operation());
|
|
38
|
+
}
|
|
39
|
+
// SDK/provider/node exceptions may include supplied material. Never echo them into MCP/logs.
|
|
40
|
+
catch {
|
|
41
|
+
return partial("group crypto", "refused: invalid/unauthorized scope, recipient, handle, encoding, size or TTL; authentication failure, key unavailable or operation expired/disposed. No plaintext returned.");
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
create(scope, ttlSeconds) {
|
|
45
|
+
return this.#guard(async () => {
|
|
46
|
+
this.#scope(scope);
|
|
47
|
+
const key = randomGroupKey();
|
|
48
|
+
try {
|
|
49
|
+
return this.handles.insert(scope, key, ttlSeconds);
|
|
50
|
+
}
|
|
51
|
+
finally {
|
|
52
|
+
key.fill(0);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
wrap(scope, handle, recipient) {
|
|
57
|
+
return this.#guard(async () => {
|
|
58
|
+
this.#scope(scope);
|
|
59
|
+
if (!recipient || !isValidPrincipalName(recipient.identity) || !validKeyLabel(recipient.keyLabel) ||
|
|
60
|
+
recipient.keyType !== "Ed25519" || !this.provider.approvedRecipients.some(r => r.identity === recipient.identity && r.keyType === recipient.keyType && r.keyLabel === recipient.keyLabel))
|
|
61
|
+
throw new Error("recipient not approved or unsupported");
|
|
62
|
+
// Do not resolve against stale applied state, even when it happens to contain a matching key.
|
|
63
|
+
const state = await this.reads.nodeStatus();
|
|
64
|
+
if (!Number.isSafeInteger(state.blockHeight) || state.blockHeight < 0 ||
|
|
65
|
+
(state.appliedRound !== null && (!Number.isSafeInteger(state.appliedRound) || state.appliedRound !== state.blockHeight)))
|
|
66
|
+
throw new Error("applied-state lag or unknown freshness");
|
|
67
|
+
const rows = await this.reads.getIdentityKeys(recipient.identity);
|
|
68
|
+
if (!Array.isArray(rows))
|
|
69
|
+
throw new Error("recipient unavailable");
|
|
70
|
+
const matches = rows.filter(r => r.nodeId === recipient.identity && r.keyType === recipient.keyType && r.label === recipient.keyLabel);
|
|
71
|
+
if (matches.length !== 1)
|
|
72
|
+
throw new Error("missing or ambiguous recipient key");
|
|
73
|
+
// Strictly validate hex before SDK conversion; never guess type or manually strip SPKI.
|
|
74
|
+
const hex = matches[0].publicKeyHex;
|
|
75
|
+
if (typeof hex !== "string" || !/^(?:[a-fA-F0-9]{2}){1,128}$/.test(hex))
|
|
76
|
+
throw new Error("invalid public key");
|
|
77
|
+
const pub = edToX25519Pub(edSpkiToRaw(hexToBytes(hex)));
|
|
78
|
+
return this.handles.withKey(scope, handle, async (key) => {
|
|
79
|
+
const wrapped = await wrapGroupKey(key, pub);
|
|
80
|
+
return { scope, recipient, ephPubBase64: base64(wrapped.ephPub), blobBase64: base64(wrapped.blob) };
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
unwrap(scope, ephPubBase64, blobBase64, ttlSeconds) {
|
|
85
|
+
return this.#guard(async () => {
|
|
86
|
+
this.#scope(scope);
|
|
87
|
+
const wrapped = { ephPub: groupCryptoBase64(ephPubBase64, 32, 32), blob: groupCryptoBase64(blobBase64, 60, 60) };
|
|
88
|
+
const key = await this.provider.unwrap(wrapped);
|
|
89
|
+
try {
|
|
90
|
+
return this.handles.insert(scope, key, ttlSeconds);
|
|
91
|
+
}
|
|
92
|
+
finally {
|
|
93
|
+
key.fill(0);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
encrypt(scope, handle, plaintextBase64) {
|
|
98
|
+
return this.#guard(async () => {
|
|
99
|
+
this.#scope(scope);
|
|
100
|
+
const plaintext = groupCryptoBase64(plaintextBase64, 0, GROUP_MESSAGE_MAX_BYTES);
|
|
101
|
+
try {
|
|
102
|
+
return await this.handles.withKey(scope, handle, async (key) => ({
|
|
103
|
+
scope, ciphertextBase64: base64(await encryptMessage(key, plaintext)), plaintextBytes: plaintext.length,
|
|
104
|
+
}));
|
|
105
|
+
}
|
|
106
|
+
finally {
|
|
107
|
+
plaintext.fill(0);
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
decrypt(scope, handle, ciphertextBase64, confirmation) {
|
|
112
|
+
return this.#guard(async () => {
|
|
113
|
+
this.#scope(scope);
|
|
114
|
+
if (!this.provider.allowPlaintext || confirmation !== PLAINTEXT_CONFIRMATION)
|
|
115
|
+
throw new Error("plaintext not authorized");
|
|
116
|
+
const ciphertext = groupCryptoBase64(ciphertextBase64, 28, GROUP_CIPHERTEXT_MAX_BYTES);
|
|
117
|
+
return this.handles.withKey(scope, handle, async (key) => {
|
|
118
|
+
// SDK GCM authentication MUST complete before converting or returning any plaintext.
|
|
119
|
+
const plaintext = await decryptMessage(key, ciphertext);
|
|
120
|
+
try {
|
|
121
|
+
if (plaintext.length > GROUP_MESSAGE_MAX_BYTES)
|
|
122
|
+
throw new Error("output exceeds bound");
|
|
123
|
+
return { scope, plaintextBase64: base64(plaintext), plaintextBytes: plaintext.length };
|
|
124
|
+
}
|
|
125
|
+
finally {
|
|
126
|
+
plaintext.fill(0);
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
dispose(scope, handle) {
|
|
132
|
+
return this.#guard(async () => { this.#scope(scope); this.handles.dispose(scope, handle); return { disposed: true }; });
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=group-crypto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"group-crypto.js","sourceRoot":"","sources":["../src/group-crypto.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,WAAW,EAAE,aAAa,EAAE,UAAU,EAC3G,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAG7D,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB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ACrD,qFAAqF;gBACrF,MAAM,SAAS,GAAG,MAAM,cAAc,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;gBACxD,IAAI,CAAC;oBACH,IAAI,SAAS,CAAC,MAAM,GAAG,uBAAuB;wBAAE,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;oBACxF,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,CAAC,SAAS,CAAC,EAAE,cAAc,EAAE,SAAS,CAAC,MAAM,EAAE,CAAC;gBACzF,CAAC;wBAAS,CAAC;oBAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;gBAAC,CAAC;YAClC,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IACD,OAAO,CAAC,KAAc,EAAE,MAAc;QACpC,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1H,CAAC;CACF"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { GroupKeyUnwrapper } from "@mcsherrylabs/evolver-client";
|
|
2
|
+
export interface GroupKeyRecipient {
|
|
3
|
+
readonly identity: string;
|
|
4
|
+
readonly keyType: "Ed25519" | "X25519";
|
|
5
|
+
readonly keyLabel: string;
|
|
6
|
+
}
|
|
7
|
+
/** Host policy + SDK decryption capability. NEVER inject the private seed or a Signer here.
|
|
8
|
+
* unwrap returns a symmetric key only to host code, which immediately puts it in GroupKeyHandles.
|
|
9
|
+
* These are process-owned policies, not client-supplied authorization assertions. */
|
|
10
|
+
export interface GroupKeyProvider extends GroupKeyUnwrapper {
|
|
11
|
+
readonly identity: string;
|
|
12
|
+
readonly keyType: "Ed25519" | "X25519";
|
|
13
|
+
readonly keyLabel: string;
|
|
14
|
+
readonly scopes: readonly string[];
|
|
15
|
+
readonly approvedRecipients: readonly GroupKeyRecipient[];
|
|
16
|
+
readonly allowPlaintext: boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare const validScope: (v: unknown) => v is string;
|
|
19
|
+
export declare const validKeyLabel: (v: unknown) => v is string;
|
|
20
|
+
/** Dedicated host secret file: absolute, no symlink, owned regular file, mode 0600/0400 only,
|
|
21
|
+
* at most 128 bytes, containing a 32-byte hex Ed seed or native X25519 scalar. No persistence
|
|
22
|
+
* of AES keys. Host admins must protect ancestor directories, backups, env and process memory. */
|
|
23
|
+
export declare function loadGroupKeyProviderFromEnv(env: NodeJS.ProcessEnv, identity: string): {
|
|
24
|
+
ok: true;
|
|
25
|
+
provider?: GroupKeyProvider;
|
|
26
|
+
} | {
|
|
27
|
+
ok: false;
|
|
28
|
+
error: string;
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=group-key-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"group-key-provider.d.ts","sourceRoot":"","sources":["../src/group-key-provider.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEtE,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,SAAS,GAAG,QAAQ,CAAC;IACvC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED;;qFAEqF;AACrF,MAAM,WAAW,gBAAiB,SAAQ,iBAAiB;IACzD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,SAAS,GAAG,QAAQ,CAAC;IACvC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,QAAQ,CAAC,kBAAkB,EAAE,SAAS,iBAAiB,EAAE,CAAC;IAC1D,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;CAClC;AAED,eAAO,MAAM,UAAU,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,MAC2B,CAAC;AACzE,eAAO,MAAM,aAAa,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,MAC8B,CAAC;AAE/E;;kGAEkG;AAClG,wBAAgB,2BAA2B,CACzC,GAAG,EAAE,MAAM,CAAC,UAAU,EAAE,QAAQ,EAAE,MAAM,GACvC;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,EAAE,gBAAgB,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAgD1E"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// Explicit encryption capability, independent of Signer. This module never reads signer env.
|
|
2
|
+
import { constants, openSync, fstatSync, readFileSync, closeSync } from "node:fs";
|
|
3
|
+
import { isAbsolute } from "node:path";
|
|
4
|
+
import { edGroupKeyUnwrapper, x25519GroupKeyUnwrapper, isValidPrincipalName } from "@mcsherrylabs/evolver-client";
|
|
5
|
+
export const validScope = (v) => typeof v === "string" && /^[a-zA-Z0-9][a-zA-Z0-9._/-]{0,127}$/.test(v);
|
|
6
|
+
export const validKeyLabel = (v) => typeof v === "string" && v.length <= 128 && !/[\u0000-\u001f\u007f]/.test(v);
|
|
7
|
+
/** Dedicated host secret file: absolute, no symlink, owned regular file, mode 0600/0400 only,
|
|
8
|
+
* at most 128 bytes, containing a 32-byte hex Ed seed or native X25519 scalar. No persistence
|
|
9
|
+
* of AES keys. Host admins must protect ancestor directories, backups, env and process memory. */
|
|
10
|
+
export function loadGroupKeyProviderFromEnv(env, identity) {
|
|
11
|
+
const names = ["KEY_FILE", "KEY_TYPE", "KEY_LABEL", "SCOPES", "RECIPIENTS", "ALLOW_PLAINTEXT"];
|
|
12
|
+
if (!names.some(n => env[`EVOLVER_GROUP_CRYPTO_${n}`] !== undefined))
|
|
13
|
+
return { ok: true };
|
|
14
|
+
let fd;
|
|
15
|
+
let secret;
|
|
16
|
+
try {
|
|
17
|
+
const path = env.EVOLVER_GROUP_CRYPTO_KEY_FILE;
|
|
18
|
+
const keyType = env.EVOLVER_GROUP_CRYPTO_KEY_TYPE;
|
|
19
|
+
const keyLabel = env.EVOLVER_GROUP_CRYPTO_KEY_LABEL ?? "";
|
|
20
|
+
if (!path || !isAbsolute(path) || !["Ed25519", "X25519"].includes(keyType ?? "") ||
|
|
21
|
+
!validKeyLabel(keyLabel) || !isValidPrincipalName(identity))
|
|
22
|
+
throw new Error();
|
|
23
|
+
const scopes = JSON.parse(env.EVOLVER_GROUP_CRYPTO_SCOPES ?? "null");
|
|
24
|
+
const recipients = JSON.parse(env.EVOLVER_GROUP_CRYPTO_RECIPIENTS ?? "null");
|
|
25
|
+
if (!Array.isArray(scopes) || scopes.length < 1 || scopes.length > 32 || !scopes.every(validScope) ||
|
|
26
|
+
new Set(scopes).size !== scopes.length || !Array.isArray(recipients) || recipients.length > 64)
|
|
27
|
+
throw new Error();
|
|
28
|
+
for (const r of recipients) {
|
|
29
|
+
if (!r || typeof r !== "object" || Object.keys(r).sort().join(",") !== "identity,keyLabel,keyType" ||
|
|
30
|
+
!isValidPrincipalName(r.identity) || !["Ed25519", "X25519"].includes(r.keyType) || !validKeyLabel(r.keyLabel))
|
|
31
|
+
throw new Error();
|
|
32
|
+
}
|
|
33
|
+
const plaintext = env.EVOLVER_GROUP_CRYPTO_ALLOW_PLAINTEXT;
|
|
34
|
+
if (plaintext !== undefined && plaintext !== "0" && plaintext !== "1")
|
|
35
|
+
throw new Error();
|
|
36
|
+
fd = openSync(path, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
|
|
37
|
+
const st = fstatSync(fd);
|
|
38
|
+
if (!st.isFile() || st.size > 128 || st.uid !== process.getuid?.() || (st.mode & 0o777) & ~0o600 ||
|
|
39
|
+
!(st.mode & 0o400))
|
|
40
|
+
throw new Error();
|
|
41
|
+
secret = readFileSync(fd);
|
|
42
|
+
// Do not include file contents, paths, JSON parse errors or SDK exceptions in diagnostics.
|
|
43
|
+
const hex = secret.toString("utf8").trim();
|
|
44
|
+
if (!/^[a-fA-F0-9]{64}$/.test(hex))
|
|
45
|
+
throw new Error();
|
|
46
|
+
const seed = Buffer.from(hex, "hex");
|
|
47
|
+
let unwrapper;
|
|
48
|
+
try {
|
|
49
|
+
unwrapper = keyType === "Ed25519" ? edGroupKeyUnwrapper(seed) : x25519GroupKeyUnwrapper(new Uint8Array(seed));
|
|
50
|
+
}
|
|
51
|
+
finally {
|
|
52
|
+
seed.fill(0);
|
|
53
|
+
}
|
|
54
|
+
const provider = Object.freeze({
|
|
55
|
+
identity, keyType: keyType, keyLabel,
|
|
56
|
+
scopes: Object.freeze([...scopes]),
|
|
57
|
+
approvedRecipients: Object.freeze(recipients.map(r => Object.freeze({ ...r }))),
|
|
58
|
+
allowPlaintext: plaintext === "1",
|
|
59
|
+
unwrap: (w) => unwrapper.unwrap(w),
|
|
60
|
+
});
|
|
61
|
+
return { ok: true, provider };
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
return { ok: false, error: "invalid group encryption provider: require explicit Ed25519/X25519 KEY_TYPE, protected owned KEY_FILE, SCOPES and RECIPIENTS policy; BLS/signing keys cannot unwrap" };
|
|
65
|
+
}
|
|
66
|
+
finally {
|
|
67
|
+
secret?.fill(0);
|
|
68
|
+
if (fd !== undefined)
|
|
69
|
+
closeSync(fd);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=group-key-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"group-key-provider.js","sourceRoot":"","sources":["../src/group-key-provider.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,OAAO,EAAE,SAAS,EAAE,QAAQ,EAA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AE,OAAsC,EAAE,QAAQ;YACnE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC;YAClC,kBAAkB,EAAE,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;YAC/E,cAAc,EAAE,SAAS,KAAK,GAAG;YACjC,MAAM,EAAE,CAAC,CAA6C,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;SAC/E,CAAC,CAAC;QACH,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;IAChC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,qKAAqK,EAAE,CAAC;IACrM,CAAC;YAAS,CAAC;QACT,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;QAChB,IAAI,EAAE,KAAK,SAAS;YAAE,SAAS,CAAC,EAAE,CAAC,CAAC;IACtC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export declare const GROUP_KEY_TTL_SECONDS = 900;
|
|
2
|
+
export declare const GROUP_KEY_MAX_TTL_SECONDS = 3600;
|
|
3
|
+
export declare const GROUP_KEY_MAX_HANDLES = 128;
|
|
4
|
+
export interface GroupKeyHandle {
|
|
5
|
+
readonly handle: string;
|
|
6
|
+
readonly scope: string;
|
|
7
|
+
readonly expiresAt: number;
|
|
8
|
+
}
|
|
9
|
+
/** Host-only stream/output authorization. Never return this object or the callback key to tools.
|
|
10
|
+
* commit() is called synchronously at the output boundary after its final authorization check.
|
|
11
|
+
* A completed commit stays a truthful success even if disposal happens while returning metadata. */
|
|
12
|
+
export interface GroupKeyLease {
|
|
13
|
+
readonly signal: AbortSignal;
|
|
14
|
+
check(): void;
|
|
15
|
+
commit(): void;
|
|
16
|
+
}
|
|
17
|
+
export declare class GroupKeyHandles {
|
|
18
|
+
#private;
|
|
19
|
+
readonly owner: string;
|
|
20
|
+
private readonly now;
|
|
21
|
+
constructor(owner: string, now?: () => number);
|
|
22
|
+
insert(scope: string, key: Uint8Array, ttlSeconds?: number): GroupKeyHandle;
|
|
23
|
+
/** Never expose this callback or key to tools. It MUST NOT return key material. A temporary
|
|
24
|
+
* copy keeps asynchronous SDK calls safe from zeroization; disposal/expiry invalidates their
|
|
25
|
+
* result. All copies are wiped even on rejection. Owner is fixed by the injected store instance. */
|
|
26
|
+
withKey<T>(scope: string, handle: string, operation: (key: Uint8Array) => Promise<T>): Promise<T>;
|
|
27
|
+
/** Unlike withKey's inline-result check, a stream lease spans ACTUAL consumption and output
|
|
28
|
+
* completion. Disposal/expiry aborts pending IO; check() also observes an injected clock.
|
|
29
|
+
* Call commit ONLY after an output's final authorization check, never before async staging. */
|
|
30
|
+
withLease<T>(scope: string, handle: string, operation: (key: Uint8Array, lease: GroupKeyLease) => Promise<T>): Promise<T>;
|
|
31
|
+
dispose(scope: string, handle: string): void;
|
|
32
|
+
close(): void;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=group-keys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"group-keys.d.ts","sourceRoot":"","sources":["../src/group-keys.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,qBAAqB,MAAM,CAAC;AACzC,eAAO,MAAM,yBAAyB,OAAO,CAAC;AAC9C,eAAO,MAAM,qBAAqB,MAAM,CAAC;AACzC,MAAM,WAAW,cAAc;IAAG,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;CAAE;AAC/G;;oGAEoG;AACpG,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,KAAK,IAAI,IAAI,CAAC;IACd,MAAM,IAAI,IAAI,CAAC;CAChB;AAGD,qBAAa,eAAe;;IAGd,QAAQ,CAAC,KAAK,EAAE,MAAM;IAAE,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAnC,KAAK,EAAE,MAAM,EAAmB,GAAG,GAAE,MAAM,MAAiB;IAEjF,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,UAAU,SAAwB,GAAG,cAAc;IAa1F;;wGAEoG;IAC9F,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,GAAG,EAAE,UAAU,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAUvG;;mGAE+F;IACzF,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,aAAa,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAc/H,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAC5C,KAAK,IAAI,IAAI;CAYd"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// Process-local, owner/scope-bound opaque AES-key handles. Host-only API for inline/stream crypto.
|
|
2
|
+
import { randomUUID } from "node:crypto";
|
|
3
|
+
import { validScope } from "./group-key-provider.js";
|
|
4
|
+
export const GROUP_KEY_TTL_SECONDS = 900;
|
|
5
|
+
export const GROUP_KEY_MAX_TTL_SECONDS = 3600;
|
|
6
|
+
export const GROUP_KEY_MAX_HANDLES = 128;
|
|
7
|
+
export class GroupKeyHandles {
|
|
8
|
+
owner;
|
|
9
|
+
now;
|
|
10
|
+
#entries = new Map();
|
|
11
|
+
#closed = false;
|
|
12
|
+
constructor(owner, now = Date.now) {
|
|
13
|
+
this.owner = owner;
|
|
14
|
+
this.now = now;
|
|
15
|
+
}
|
|
16
|
+
insert(scope, key, ttlSeconds = GROUP_KEY_TTL_SECONDS) {
|
|
17
|
+
this.#sweep();
|
|
18
|
+
if (this.#closed || !validScope(scope) || key.length !== 32 || !Number.isSafeInteger(ttlSeconds) ||
|
|
19
|
+
ttlSeconds < 1 || ttlSeconds > GROUP_KEY_MAX_TTL_SECONDS || this.#entries.size >= GROUP_KEY_MAX_HANDLES)
|
|
20
|
+
throw new Error("group key store unavailable, invalid key/TTL/scope, or handle capacity reached");
|
|
21
|
+
const handle = `gk_${randomUUID()}`;
|
|
22
|
+
const expiresAt = this.now() + ttlSeconds * 1000;
|
|
23
|
+
const timer = setTimeout(() => this.#remove(handle), ttlSeconds * 1000);
|
|
24
|
+
timer.unref();
|
|
25
|
+
this.#entries.set(handle, { key: new Uint8Array(key), scope, expiresAt, timer, lifetime: new AbortController() });
|
|
26
|
+
return { handle, scope, expiresAt };
|
|
27
|
+
}
|
|
28
|
+
/** Never expose this callback or key to tools. It MUST NOT return key material. A temporary
|
|
29
|
+
* copy keeps asynchronous SDK calls safe from zeroization; disposal/expiry invalidates their
|
|
30
|
+
* result. All copies are wiped even on rejection. Owner is fixed by the injected store instance. */
|
|
31
|
+
async withKey(scope, handle, operation) {
|
|
32
|
+
const entry = this.#get(scope, handle);
|
|
33
|
+
const copy = new Uint8Array(entry.key);
|
|
34
|
+
try {
|
|
35
|
+
const result = await operation(copy);
|
|
36
|
+
if (this.#get(scope, handle) !== entry)
|
|
37
|
+
throw new Error("group key handle no longer valid");
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
40
|
+
finally {
|
|
41
|
+
copy.fill(0);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/** Unlike withKey's inline-result check, a stream lease spans ACTUAL consumption and output
|
|
45
|
+
* completion. Disposal/expiry aborts pending IO; check() also observes an injected clock.
|
|
46
|
+
* Call commit ONLY after an output's final authorization check, never before async staging. */
|
|
47
|
+
async withLease(scope, handle, operation) {
|
|
48
|
+
const entry = this.#get(scope, handle);
|
|
49
|
+
const copy = new Uint8Array(entry.key);
|
|
50
|
+
let committed = false;
|
|
51
|
+
const check = () => { if (this.#get(scope, handle) !== entry)
|
|
52
|
+
throw new Error("group key handle no longer valid"); };
|
|
53
|
+
const lease = Object.freeze({ signal: entry.lifetime.signal, check,
|
|
54
|
+
commit: () => { check(); committed = true; } });
|
|
55
|
+
try {
|
|
56
|
+
const result = await operation(copy, lease);
|
|
57
|
+
if (!committed)
|
|
58
|
+
check();
|
|
59
|
+
return result;
|
|
60
|
+
}
|
|
61
|
+
finally {
|
|
62
|
+
copy.fill(0);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
dispose(scope, handle) { this.#get(scope, handle); this.#remove(handle); }
|
|
66
|
+
close() { this.#closed = true; for (const h of this.#entries.keys())
|
|
67
|
+
this.#remove(h); }
|
|
68
|
+
#get(scope, handle) {
|
|
69
|
+
this.#sweep();
|
|
70
|
+
const entry = this.#entries.get(handle);
|
|
71
|
+
if (this.#closed || !entry || entry.scope !== scope)
|
|
72
|
+
throw new Error("invalid, expired, disposed or foreign-scope group key handle");
|
|
73
|
+
return entry;
|
|
74
|
+
}
|
|
75
|
+
#sweep() { for (const [h, e] of this.#entries)
|
|
76
|
+
if (e.expiresAt <= this.now())
|
|
77
|
+
this.#remove(h); }
|
|
78
|
+
#remove(handle) {
|
|
79
|
+
const entry = this.#entries.get(handle);
|
|
80
|
+
if (entry) {
|
|
81
|
+
clearTimeout(entry.timer);
|
|
82
|
+
entry.key.fill(0);
|
|
83
|
+
this.#entries.delete(handle);
|
|
84
|
+
entry.lifetime.abort();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=group-keys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"group-keys.js","sourceRoot":"","sources":["../src/group-keys.ts"],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CAAC,QAAQ;QAAE,IAAI,CAAC,CAAC,SAAS,IAAI,IAAI,CAAC,GAAG,EAAE;YAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACtG,OAAO,CAAC,MAAc;QACpB,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACxC,IAAI,KAAK,EAAE,CAAC;YAAC,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QAAC,CAAC;IACpH,CAAC;CACF"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { Signer } from "@mcsherrylabs/evolver-client";
|
|
2
|
+
import type { ChainReads } from "./read.js";
|
|
3
|
+
import type { ToolResult } from "./result.js";
|
|
4
|
+
import type { SignedGroup } from "./write.js";
|
|
5
|
+
export interface OwnershipDeps {
|
|
6
|
+
readonly identity: string;
|
|
7
|
+
readonly signer: Signer;
|
|
8
|
+
readonly reads: ChainReads;
|
|
9
|
+
}
|
|
10
|
+
/** Rounds of life for a two-party transfer. Longer than `DEFAULT_TTL_OFFSET` (50, sized for no
|
|
11
|
+
* human wait) because a second party must act, but never beyond the node's default
|
|
12
|
+
* `max-ttl-offset` (RoutingConfig.DefaultMaxTtlOffset = 100): a longer ttl is `ttl_too_far`, and
|
|
13
|
+
* a long-lived co-signed envelope is a bearer artefact. The default stays 10 rounds inside that
|
|
14
|
+
* bound so the two parties' nodes may disagree slightly about the tip. Expiry is final. */
|
|
15
|
+
export declare const OWNERSHIP_TTL_MAX = 100;
|
|
16
|
+
export declare const OWNERSHIP_TTL_DEFAULT = 90;
|
|
17
|
+
/** The one key type whose consent can be verified with a published SDK primitive. */
|
|
18
|
+
export declare const CONSENT_KEY_TYPE = "Ed25519";
|
|
19
|
+
export declare const INTENT_KIND = "evolver.group_ownership_intent.v1";
|
|
20
|
+
export declare const CONSENT_KIND = "evolver.group_ownership_consent.v1";
|
|
21
|
+
declare const PURPOSE = "AUTHORIZE";
|
|
22
|
+
export interface OwnershipIntent {
|
|
23
|
+
readonly kind: typeof INTENT_KIND;
|
|
24
|
+
readonly txId: string;
|
|
25
|
+
readonly ledgerId: string;
|
|
26
|
+
readonly groupName: string;
|
|
27
|
+
readonly outgoingOwner: string;
|
|
28
|
+
readonly incomingOwner: string;
|
|
29
|
+
readonly expiresAtRound: number;
|
|
30
|
+
readonly preparedAtRound: number;
|
|
31
|
+
readonly maxToll: "0";
|
|
32
|
+
readonly next: string;
|
|
33
|
+
}
|
|
34
|
+
export interface OwnershipConsent {
|
|
35
|
+
readonly kind: typeof CONSENT_KIND;
|
|
36
|
+
readonly txId: string;
|
|
37
|
+
readonly ledgerId: string;
|
|
38
|
+
readonly groupName: string;
|
|
39
|
+
readonly outgoingOwner: string;
|
|
40
|
+
readonly incomingOwner: string;
|
|
41
|
+
readonly expiresAtRound: number;
|
|
42
|
+
readonly maxToll: "0";
|
|
43
|
+
readonly auth: {
|
|
44
|
+
readonly nodeId: string;
|
|
45
|
+
readonly keyType: string;
|
|
46
|
+
readonly keyLabel: string;
|
|
47
|
+
readonly purpose: typeof PURPOSE;
|
|
48
|
+
readonly signatureHex: string;
|
|
49
|
+
};
|
|
50
|
+
readonly next: string;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* PREPARE (outgoing owner). Signs nothing; returns the public intent for the incoming owner.
|
|
54
|
+
*/
|
|
55
|
+
export declare function prepareOwnershipTransfer(deps: OwnershipDeps, params: {
|
|
56
|
+
groupName: unknown;
|
|
57
|
+
incomingOwner: unknown;
|
|
58
|
+
ttlRounds?: unknown;
|
|
59
|
+
}): Promise<ToolResult<OwnershipIntent>>;
|
|
60
|
+
/**
|
|
61
|
+
* CONSENT (incoming owner). Recomputes the intent's txId and signs it with THIS session's key.
|
|
62
|
+
*/
|
|
63
|
+
export declare function consentOwnershipTransfer(deps: OwnershipDeps, params: {
|
|
64
|
+
txId: unknown;
|
|
65
|
+
groupName: unknown;
|
|
66
|
+
outgoingOwner: unknown;
|
|
67
|
+
incomingOwner: unknown;
|
|
68
|
+
expiresAtRound: unknown;
|
|
69
|
+
}): Promise<ToolResult<OwnershipConsent>>;
|
|
70
|
+
/**
|
|
71
|
+
* FINALIZE (outgoing owner). Verifies the consent, signs as sender, assembles both auths, records.
|
|
72
|
+
*/
|
|
73
|
+
export declare function finalizeOwnershipTransfer(deps: OwnershipDeps, params: {
|
|
74
|
+
txId: unknown;
|
|
75
|
+
consent: unknown;
|
|
76
|
+
}): Promise<ToolResult<SignedGroup>>;
|
|
77
|
+
export {};
|
|
78
|
+
//# sourceMappingURL=group-ownership.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"group-ownership.d.ts","sourceRoot":"","sources":["../src/group-ownership.ts"],"names":[],"mappings":"AAoDA,OAAO,KAAK,EAAQ,MAAM,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAW9C,OAAO,KAAK,EAA4B,WAAW,EAAE,MAAM,YAAY,CAAC;AAExE,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;CAC5B;AAED;;;;4FAI4F;AAC5F,eAAO,MAAM,iBAAiB,MAAM,CAAC;AACrC,eAAO,MAAM,qBAAqB,KAAK,CAAC;AAExC,qFAAqF;AACrF,eAAO,MAAM,gBAAgB,YAAY,CAAC;AAC1C,eAAO,MAAM,WAAW,sC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