@agenticprimitives/key-custody 0.1.0-alpha.3 → 1.0.0-alpha.11
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/README.md +22 -5
- package/bin/ap-provision-gcp.mjs +91 -0
- package/dist/account.d.ts +1 -1
- package/dist/account.d.ts.map +1 -1
- package/dist/account.js +1 -1
- package/dist/account.js.map +1 -1
- package/dist/derive-subject.d.ts +1 -1
- package/dist/derive-subject.d.ts.map +1 -1
- package/dist/derive-subject.js +5 -5
- package/dist/derive-subject.js.map +1 -1
- package/dist/factories.d.ts +27 -1
- package/dist/factories.d.ts.map +1 -1
- package/dist/factories.js +29 -5
- package/dist/factories.js.map +1 -1
- package/dist/index.d.ts +12 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +33 -9
- package/dist/index.js.map +1 -1
- package/dist/kms/gcp-transport.d.ts +36 -0
- package/dist/kms/gcp-transport.d.ts.map +1 -0
- package/dist/kms/gcp-transport.js +114 -0
- package/dist/kms/gcp-transport.js.map +1 -0
- package/dist/kms/key-map.d.ts +13 -0
- package/dist/kms/key-map.d.ts.map +1 -0
- package/dist/kms/key-map.js +65 -0
- package/dist/kms/key-map.js.map +1 -0
- package/dist/kms/kms-core.d.ts +4 -0
- package/dist/kms/kms-core.d.ts.map +1 -0
- package/dist/kms/kms-core.js +14 -0
- package/dist/kms/kms-core.js.map +1 -0
- package/dist/kms/provision-gcp.d.ts +89 -0
- package/dist/kms/provision-gcp.d.ts.map +1 -0
- package/dist/kms/provision-gcp.js +229 -0
- package/dist/kms/provision-gcp.js.map +1 -0
- package/dist/kms/secp256k1-core.d.ts +46 -0
- package/dist/kms/secp256k1-core.d.ts.map +1 -0
- package/dist/kms/secp256k1-core.js +209 -0
- package/dist/kms/secp256k1-core.js.map +1 -0
- package/dist/kms-viem-account.d.ts +1 -1
- package/dist/kms-viem-account.d.ts.map +1 -1
- package/dist/providers/aws.d.ts +4 -1
- package/dist/providers/aws.d.ts.map +1 -1
- package/dist/providers/aws.js +17 -7
- package/dist/providers/aws.js.map +1 -1
- package/dist/providers/gcp.d.ts +23 -36
- package/dist/providers/gcp.d.ts.map +1 -1
- package/dist/providers/gcp.js +89 -340
- package/dist/providers/gcp.js.map +1 -1
- package/dist/providers/local.d.ts +4 -4
- package/dist/providers/local.d.ts.map +1 -1
- package/dist/providers/local.js +17 -7
- package/dist/providers/local.js.map +1 -1
- package/dist/relay-only.d.ts +1 -1
- package/dist/relay-only.d.ts.map +1 -1
- package/dist/relay-only.js +1 -1
- package/dist/relay-only.js.map +1 -1
- package/dist/relayer-account.d.ts +44 -0
- package/dist/relayer-account.d.ts.map +1 -0
- package/dist/relayer-account.js +146 -0
- package/dist/relayer-account.js.map +1 -0
- package/dist/spend-capped-account.d.ts +71 -0
- package/dist/spend-capped-account.d.ts.map +1 -0
- package/dist/spend-capped-account.js +181 -0
- package/dist/spend-capped-account.js.map +1 -0
- package/package.json +40 -9
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ServiceAccount } from './gcp-transport.js';
|
|
2
|
+
/** Parse Google service-account credentials from a raw JSON string, base64-encoded
|
|
3
|
+
* JSON, or an already-parsed object. Fail closed if `client_email`/`private_key` are absent. */
|
|
4
|
+
export declare function parseServiceAccountJson(input: string | object): ServiceAccount;
|
|
5
|
+
/** A validated `identity → cryptoKeyVersion resource name` map. */
|
|
6
|
+
export type SignerKeyMap = Record<string, string>;
|
|
7
|
+
/** Parse + validate a signer key-map (JSON string, base64-JSON, or object). Every value MUST be a
|
|
8
|
+
* full `…/cryptoKeyVersions/<N>` resource name — a bare key name would fail at first sign with a
|
|
9
|
+
* confusing error, so reject it here, loudly. Rejects an empty map. */
|
|
10
|
+
export declare function parseSignerKeyMap(input: string | object): SignerKeyMap;
|
|
11
|
+
/** True iff `name` is a full Cloud KMS key VERSION resource name. */
|
|
12
|
+
export declare function isCryptoKeyVersionName(name: string): boolean;
|
|
13
|
+
//# sourceMappingURL=key-map.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"key-map.d.ts","sourceRoot":"","sources":["../../src/kms/key-map.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAuBzD;iGACiG;AACjG,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,cAAc,CAU9E;AAED,mEAAmE;AACnE,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAElD;;wEAEwE;AACxE,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,YAAY,CAetE;AAED,qEAAqE;AACrE,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE5D"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// Loose service-account + signer-key-map parsing (spec 276 KCS-D4). Peer-dep-free.
|
|
2
|
+
//
|
|
3
|
+
// External apps hand-rolled both of these and got the failure modes subtly
|
|
4
|
+
// wrong (silent defaults, accepting a key NAME where a key VERSION is required).
|
|
5
|
+
// They are generic, so they live here — one parse path, loud failure (ADR-0013).
|
|
6
|
+
/** A full Cloud KMS key VERSION resource name (what a signer needs — not the bare key). */
|
|
7
|
+
const KEY_VERSION_RE = /^projects\/[^/]+\/locations\/[^/]+\/keyRings\/[^/]+\/cryptoKeys\/[^/]+\/cryptoKeyVersions\/\d+$/;
|
|
8
|
+
function coerceJsonObject(input, label) {
|
|
9
|
+
if (typeof input === 'object' && input !== null)
|
|
10
|
+
return input;
|
|
11
|
+
if (typeof input !== 'string')
|
|
12
|
+
throw new Error(`${label}: expected a JSON string or object`);
|
|
13
|
+
const s = input.trim();
|
|
14
|
+
if (!s)
|
|
15
|
+
throw new Error(`${label}: empty input`);
|
|
16
|
+
try {
|
|
17
|
+
return JSON.parse(s);
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
// The common second shape: base64-encoded JSON (env vars / secret stores).
|
|
21
|
+
try {
|
|
22
|
+
return JSON.parse(atob(s));
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
throw new Error(`${label}: not valid JSON or base64-encoded JSON`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/** Parse Google service-account credentials from a raw JSON string, base64-encoded
|
|
30
|
+
* JSON, or an already-parsed object. Fail closed if `client_email`/`private_key` are absent. */
|
|
31
|
+
export function parseServiceAccountJson(input) {
|
|
32
|
+
const obj = coerceJsonObject(input, 'parseServiceAccountJson');
|
|
33
|
+
if (typeof obj.client_email !== 'string' || typeof obj.private_key !== 'string') {
|
|
34
|
+
throw new Error('parseServiceAccountJson: missing client_email or private_key');
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
client_email: obj.client_email,
|
|
38
|
+
private_key: obj.private_key,
|
|
39
|
+
project_id: typeof obj.project_id === 'string' ? obj.project_id : undefined,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/** Parse + validate a signer key-map (JSON string, base64-JSON, or object). Every value MUST be a
|
|
43
|
+
* full `…/cryptoKeyVersions/<N>` resource name — a bare key name would fail at first sign with a
|
|
44
|
+
* confusing error, so reject it here, loudly. Rejects an empty map. */
|
|
45
|
+
export function parseSignerKeyMap(input) {
|
|
46
|
+
const obj = coerceJsonObject(input, 'parseSignerKeyMap');
|
|
47
|
+
if (Array.isArray(obj))
|
|
48
|
+
throw new Error('parseSignerKeyMap: expected an object map, got an array');
|
|
49
|
+
const out = {};
|
|
50
|
+
for (const [identity, value] of Object.entries(obj)) {
|
|
51
|
+
if (typeof value !== 'string' || !KEY_VERSION_RE.test(value)) {
|
|
52
|
+
throw new Error(`parseSignerKeyMap: identity "${identity}" must map to a full ` +
|
|
53
|
+
`projects/.../cryptoKeyVersions/<N> resource name; got ${JSON.stringify(value)}`);
|
|
54
|
+
}
|
|
55
|
+
out[identity] = value;
|
|
56
|
+
}
|
|
57
|
+
if (Object.keys(out).length === 0)
|
|
58
|
+
throw new Error('parseSignerKeyMap: empty map');
|
|
59
|
+
return out;
|
|
60
|
+
}
|
|
61
|
+
/** True iff `name` is a full Cloud KMS key VERSION resource name. */
|
|
62
|
+
export function isCryptoKeyVersionName(name) {
|
|
63
|
+
return KEY_VERSION_RE.test(name);
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=key-map.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"key-map.js","sourceRoot":"","sources":["../../src/kms/key-map.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,EAAE;AACF,2EAA2E;AAC3E,iFAAiF;AACjF,iFAAiF;AAIjF,2FAA2F;AAC3F,MAAM,cAAc,GAClB,iGAAiG,CAAC;AAEpG,SAAS,gBAAgB,CAAC,KAAsB,EAAE,KAAa;IAC7D,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,KAAgC,CAAC;IACzF,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,oCAAoC,CAAC,CAAC;IAC7F,MAAM,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IACvB,IAAI,CAAC,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,eAAe,CAAC,CAAC;IACjD,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAA4B,CAAC;IAClD,CAAC;IAAC,MAAM,CAAC;QACP,2EAA2E;QAC3E,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAA4B,CAAC;QACxD,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,yCAAyC,CAAC,CAAC;QACrE,CAAC;IACH,CAAC;AACH,CAAC;AAED;iGACiG;AACjG,MAAM,UA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AM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;IACnF,OAAO,GAAG,CAAC;AACb,CAAC;AAED,qEAAqE;AACrE,MAAM,UAAU,sBAAsB,CAAC,IAAY;IACjD,OAAO,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { type Hex, bytesToHex, base64UrlEncode, base64Decode, base64Encode, pemToDer, bigIntTo32Bytes, parseDerEcdsa, parseDerEcdsaSignature, normalizeLowS, toLowS, parseSpkiUncompressedSecp256k1PubKey, publicKeyToAddress, addressFromSpkiPem, findRecoveryByte, recoverV, assembleEthSignature, signDigestWithKms, } from './secp256k1-core.js';
|
|
2
|
+
export { type ServiceAccount, type CachedToken, type GcpKmsTransport, signJwt, fetchAccessToken, callKms, createGcpKmsTransport, gcpSignDigest, } from './gcp-transport.js';
|
|
3
|
+
export { type SignerKeyMap, parseServiceAccountJson, parseSignerKeyMap, isCryptoKeyVersionName, } from './key-map.js';
|
|
4
|
+
//# sourceMappingURL=kms-core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kms-core.d.ts","sourceRoot":"","sources":["../../src/kms/kms-core.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,KAAK,GAAG,EACR,UAAU,EACV,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,eAAe,EACf,aAAa,EACb,sBAAsB,EACtB,aAAa,EACb,MAAM,EACN,oCAAoC,EACpC,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,QAAQ,EACR,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,OAAO,EACP,gBAAgB,EAChB,OAAO,EACP,qBAAqB,EACrB,aAAa,GACd,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,KAAK,YAAY,EACjB,uBAAuB,EACvB,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// @agenticprimitives/key-custody/kms-core — the consumer-safe KMS signing surface (spec 276).
|
|
2
|
+
//
|
|
3
|
+
// Import this (NOT the package barrel) when you only need to sign a digest with
|
|
4
|
+
// a Cloud KMS secp256k1 key. Its transitive deps are ONLY `@noble/curves` +
|
|
5
|
+
// `@noble/hashes` — no `viem`, no `@agenticprimitives/audit`/`connect-auth`
|
|
6
|
+
// peers. This exists so apps never inline the KMS signer again (the
|
|
7
|
+
// demo-validator `kms-signer.ts` problem; ADR-0013 — one primitive, not copies).
|
|
8
|
+
//
|
|
9
|
+
// The audited, viem-typed `GcpKmsSigner` (the package barrel) is a thin wrapper
|
|
10
|
+
// over exactly this code.
|
|
11
|
+
export { bytesToHex, base64UrlEncode, base64Decode, base64Encode, pemToDer, bigIntTo32Bytes, parseDerEcdsa, parseDerEcdsaSignature, normalizeLowS, toLowS, parseSpkiUncompressedSecp256k1PubKey, publicKeyToAddress, addressFromSpkiPem, findRecoveryByte, recoverV, assembleEthSignature, signDigestWithKms, } from './secp256k1-core.js';
|
|
12
|
+
export { signJwt, fetchAccessToken, callKms, createGcpKmsTransport, gcpSignDigest, } from './gcp-transport.js';
|
|
13
|
+
export { parseServiceAccountJson, parseSignerKeyMap, isCryptoKeyVersionName, } from './key-map.js';
|
|
14
|
+
//# sourceMappingURL=kms-core.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kms-core.js","sourceRoot":"","sources":["../../src/kms/kms-core.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAC9F,EAAE;AACF,gFAAgF;AAChF,4EAA4E;AAC5E,4EAA4E;AAC5E,oEAAoE;AACpE,iFAAiF;AACjF,EAAE;AACF,gFAAgF;AAChF,0BAA0B;AAE1B,OAAO,EAEL,UAAU,EACV,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,eAAe,EACf,aAAa,EACb,sBAAsB,EACtB,aAAa,EACb,MAAM,EACN,oCAAoC,EACpC,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,QAAQ,EACR,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAIL,OAAO,EACP,gBAAgB,EAChB,OAAO,EACP,qBAAqB,EACrB,aAAa,GACd,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAEL,uBAAuB,EACvB,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { type Hex } from './secp256k1-core.js';
|
|
2
|
+
/** Key purpose. `asymmetric-signing` = secp256k1 EVM signer (default). `encrypt-decrypt` =
|
|
3
|
+
* symmetric KEK for envelope wrapping (spec 277/278 per-person vault key). */
|
|
4
|
+
export type KeyPurpose = 'asymmetric-signing' | 'encrypt-decrypt';
|
|
5
|
+
export interface ProvisionPlan {
|
|
6
|
+
project: string;
|
|
7
|
+
location: string;
|
|
8
|
+
keyRing: string;
|
|
9
|
+
/** Signing/KEK identity labels — arbitrary (dotted agent names ok); sanitized to key ids (B2). */
|
|
10
|
+
identities: string[];
|
|
11
|
+
/** Service-account email to grant the per-key IAM role. */
|
|
12
|
+
runtimeServiceAccount: string;
|
|
13
|
+
/** secp256k1 requires HSM; SOFTWARE is rejected by GCP for that curve. Default HSM. */
|
|
14
|
+
protectionLevel?: 'HSM' | 'SOFTWARE';
|
|
15
|
+
/** Default `asymmetric-signing`. `encrypt-decrypt` mints a symmetric KEK (spec 278 vault key). */
|
|
16
|
+
purpose?: KeyPurpose;
|
|
17
|
+
/** Per-key IAM role (B3). Default: `roles/cloudkms.signerVerifier` for signing,
|
|
18
|
+
* `roles/cloudkms.cryptoKeyEncrypterDecrypter` for encrypt-decrypt. */
|
|
19
|
+
iamRole?: string;
|
|
20
|
+
}
|
|
21
|
+
export type StepKind = 'create-keyring' | 'create-key' | 'grant-iam';
|
|
22
|
+
/** REST-executor parameters carried alongside the gcloud `argv` so both executors work. */
|
|
23
|
+
export interface ProvisionStepRest {
|
|
24
|
+
project: string;
|
|
25
|
+
location: string;
|
|
26
|
+
keyRing: string;
|
|
27
|
+
keyId?: string;
|
|
28
|
+
purpose?: KeyPurpose;
|
|
29
|
+
protectionLevel?: 'HSM' | 'SOFTWARE';
|
|
30
|
+
role?: string;
|
|
31
|
+
member?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface ProvisionStep {
|
|
34
|
+
id: string;
|
|
35
|
+
kind: StepKind;
|
|
36
|
+
description: string;
|
|
37
|
+
/** argv for `gcloud` (no shell string — avoids injection). */
|
|
38
|
+
argv: string[];
|
|
39
|
+
/** The ORIGINAL identity label (create-key / grant-iam). */
|
|
40
|
+
identity?: string;
|
|
41
|
+
/** The sanitized GCP key id used in the resource name. */
|
|
42
|
+
keyId?: string;
|
|
43
|
+
/** The key resource this step targets (create-key / grant-iam). */
|
|
44
|
+
cryptoKeyName?: string;
|
|
45
|
+
/** Structured params the REST executor uses (the gcloud executor uses `argv`). */
|
|
46
|
+
rest: ProvisionStepRest;
|
|
47
|
+
}
|
|
48
|
+
/** @deprecated name — kept for back-compat; use `ProvisionStep`. */
|
|
49
|
+
export type GcloudStep = ProvisionStep;
|
|
50
|
+
export interface StepExecutor {
|
|
51
|
+
/** Run a planned step. Return `{ alreadyExists: true }` for an idempotent skip; throw on real failure. */
|
|
52
|
+
run(step: ProvisionStep): Promise<{
|
|
53
|
+
stdout: string;
|
|
54
|
+
alreadyExists?: boolean;
|
|
55
|
+
}>;
|
|
56
|
+
/** Fetch a key version's SPKI PEM (asymmetric keys only — for address verification). */
|
|
57
|
+
getPublicKeyPem(cryptoKeyVersionName: string): Promise<string>;
|
|
58
|
+
}
|
|
59
|
+
export interface ProvisionResult {
|
|
60
|
+
/** identity (ORIGINAL label) → key resource: `…/cryptoKeyVersions/1` for signing keys,
|
|
61
|
+
* the version-less `…/cryptoKeys/<id>` for encrypt-decrypt KEKs (what the provider wants). */
|
|
62
|
+
keyMap: Record<string, string>;
|
|
63
|
+
/** identity → derived EVM address (signing keys only; verify BEFORE wiring env). */
|
|
64
|
+
addresses: Record<string, Hex>;
|
|
65
|
+
granted: Array<{
|
|
66
|
+
key: string;
|
|
67
|
+
member: string;
|
|
68
|
+
role: string;
|
|
69
|
+
}>;
|
|
70
|
+
/** Step ids skipped because the resource already existed (idempotent re-run). */
|
|
71
|
+
alreadyExisted: string[];
|
|
72
|
+
}
|
|
73
|
+
/** Sanitize an arbitrary identity label to a GCP cryptoKey id ([a-zA-Z0-9_-], ≤63) (B2). */
|
|
74
|
+
export declare function sanitizeKeyId(identity: string): string;
|
|
75
|
+
/** First key version GCP creates (asymmetric keys — the version is what you sign with). */
|
|
76
|
+
export declare function keyVersionName(plan: ProvisionPlan, keyId: string): string;
|
|
77
|
+
/** Emit the ordered steps for a provisioning plan. Pure — no execution. */
|
|
78
|
+
export declare function planGcpProvision(plan: ProvisionPlan): ProvisionStep[];
|
|
79
|
+
/** Execute a provisioning plan through an injected executor. Idempotent: steps whose resource
|
|
80
|
+
* already exists are skipped + reported. For asymmetric keys, fetches each key's public key and
|
|
81
|
+
* derives its EVM address (verify before wiring); encrypt-decrypt KEKs have no public key, so the
|
|
82
|
+
* keyMap points at the version-less cryptoKey resource and no address is derived. */
|
|
83
|
+
export declare function executeGcpProvision(plan: ProvisionPlan, exec: StepExecutor): Promise<ProvisionResult>;
|
|
84
|
+
/** Build a Cloud KMS REST StepExecutor from a service-account JSON (single-line or base64 — B4).
|
|
85
|
+
* Zero gcloud dependency; SA-JWT → KMS REST. Idempotent (409 ALREADY_EXISTS → skip). */
|
|
86
|
+
export declare function createGcpRestStepExecutor(opts: {
|
|
87
|
+
serviceAccountJson: string | object;
|
|
88
|
+
}): StepExecutor;
|
|
89
|
+
//# sourceMappingURL=provision-gcp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1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CA8B3G;AASD;yFACyF;AACzF,wBAAgB,yBAAyB,CAAC,IAAI,EAAE;IAAE,kBAAkB,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,GAAG,YAAY,CAyDrG"}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
// GCP Cloud KMS provisioning helper (spec 276 KCS-D3 + upstream backlog B1/B2/B3).
|
|
2
|
+
//
|
|
3
|
+
// PURE PLANNING + INJECTED EXECUTION: `planGcpProvision` emits the ordered steps;
|
|
4
|
+
// `executeGcpProvision` runs them through a `StepExecutor`. Two executors ship:
|
|
5
|
+
// - `createGcpRestStepExecutor` — gcloud-FREE: SA-JWT → Cloud KMS REST (B1).
|
|
6
|
+
// Works on Workers (no gRPC SDK); a "drop the SA key and run" path.
|
|
7
|
+
// - the CLI (`bin/ap-provision-gcp.mjs`) supplies a Node child_process gcloud runner.
|
|
8
|
+
//
|
|
9
|
+
// B2: `identities` are arbitrary labels (dotted agent names ok); each is sanitized to a
|
|
10
|
+
// GCP key id internally, and the result maps are keyed by the ORIGINAL label.
|
|
11
|
+
// B3: the granted IAM role is configurable (default derives from the key purpose).
|
|
12
|
+
// Per-key (not per-keyring) IAM enforces master-key separation (CLAUDE.md invariant).
|
|
13
|
+
import { addressFromSpkiPem } from './secp256k1-core.js';
|
|
14
|
+
import { fetchAccessToken, callKms } from './gcp-transport.js';
|
|
15
|
+
import { parseServiceAccountJson } from './key-map.js';
|
|
16
|
+
/** Sanitize an arbitrary identity label to a GCP cryptoKey id ([a-zA-Z0-9_-], ≤63) (B2). */
|
|
17
|
+
export function sanitizeKeyId(identity) {
|
|
18
|
+
// Trim leading/trailing '-' with linear string ops — NOT a regex. The `/^-+|-+$/g`
|
|
19
|
+
// alternation is ReDoS-prone (polynomial on a long run of '-'); a scan is O(n).
|
|
20
|
+
const collapsed = identity.replace(/[^a-zA-Z0-9_-]/g, '-');
|
|
21
|
+
let start = 0;
|
|
22
|
+
let end = collapsed.length;
|
|
23
|
+
while (start < end && collapsed[start] === '-')
|
|
24
|
+
start++;
|
|
25
|
+
while (end > start && collapsed[end - 1] === '-')
|
|
26
|
+
end--;
|
|
27
|
+
const id = collapsed.slice(start, end).slice(0, 63);
|
|
28
|
+
if (!id)
|
|
29
|
+
throw new Error(`sanitizeKeyId: identity "${identity}" sanitizes to an empty key id`);
|
|
30
|
+
return id;
|
|
31
|
+
}
|
|
32
|
+
function keyResourceName(plan, keyId) {
|
|
33
|
+
return `projects/${plan.project}/locations/${plan.location}/keyRings/${plan.keyRing}/cryptoKeys/${keyId}`;
|
|
34
|
+
}
|
|
35
|
+
/** First key version GCP creates (asymmetric keys — the version is what you sign with). */
|
|
36
|
+
export function keyVersionName(plan, keyId) {
|
|
37
|
+
return `${keyResourceName(plan, keyId)}/cryptoKeyVersions/1`;
|
|
38
|
+
}
|
|
39
|
+
function defaultRole(purpose) {
|
|
40
|
+
return purpose === 'encrypt-decrypt'
|
|
41
|
+
? 'roles/cloudkms.cryptoKeyEncrypterDecrypter'
|
|
42
|
+
: 'roles/cloudkms.signerVerifier';
|
|
43
|
+
}
|
|
44
|
+
/** Emit the ordered steps for a provisioning plan. Pure — no execution. */
|
|
45
|
+
export function planGcpProvision(plan) {
|
|
46
|
+
if (!plan.project || !plan.location || !plan.keyRing) {
|
|
47
|
+
throw new Error('planGcpProvision: project, location, and keyRing are required');
|
|
48
|
+
}
|
|
49
|
+
if (!plan.runtimeServiceAccount.includes('@')) {
|
|
50
|
+
throw new Error('planGcpProvision: runtimeServiceAccount must be a service-account email');
|
|
51
|
+
}
|
|
52
|
+
if (plan.identities.length === 0)
|
|
53
|
+
throw new Error('planGcpProvision: at least one identity is required');
|
|
54
|
+
const dupes = plan.identities.filter((id, i) => plan.identities.indexOf(id) !== i);
|
|
55
|
+
if (dupes.length)
|
|
56
|
+
throw new Error(`planGcpProvision: duplicate identities: ${[...new Set(dupes)].join(', ')}`);
|
|
57
|
+
const purpose = plan.purpose ?? 'asymmetric-signing';
|
|
58
|
+
const protection = (plan.protectionLevel ?? 'HSM').toLowerCase();
|
|
59
|
+
const role = plan.iamRole ?? defaultRole(purpose);
|
|
60
|
+
const gcloudPurpose = purpose === 'encrypt-decrypt' ? 'encryption' : 'asymmetric-signing';
|
|
61
|
+
const gcloudAlgo = purpose === 'encrypt-decrypt' ? 'google-symmetric-encryption' : 'ec-sign-secp256k1-sha256';
|
|
62
|
+
// B2: map ORIGINAL identity → sanitized keyId; reject collisions (two labels → one key id).
|
|
63
|
+
const keyIdByIdentity = new Map();
|
|
64
|
+
const seen = new Map();
|
|
65
|
+
for (const identity of plan.identities) {
|
|
66
|
+
const keyId = sanitizeKeyId(identity);
|
|
67
|
+
const prior = seen.get(keyId);
|
|
68
|
+
if (prior && prior !== identity) {
|
|
69
|
+
throw new Error(`planGcpProvision: identities "${prior}" and "${identity}" both sanitize to key id "${keyId}"`);
|
|
70
|
+
}
|
|
71
|
+
seen.set(keyId, identity);
|
|
72
|
+
keyIdByIdentity.set(identity, keyId);
|
|
73
|
+
}
|
|
74
|
+
const steps = [
|
|
75
|
+
{
|
|
76
|
+
id: 'keyring',
|
|
77
|
+
kind: 'create-keyring',
|
|
78
|
+
description: `Create key ring ${plan.keyRing} in ${plan.location}`,
|
|
79
|
+
argv: ['kms', 'keyrings', 'create', plan.keyRing, '--location', plan.location, '--project', plan.project],
|
|
80
|
+
rest: { project: plan.project, location: plan.location, keyRing: plan.keyRing },
|
|
81
|
+
},
|
|
82
|
+
];
|
|
83
|
+
for (const identity of plan.identities) {
|
|
84
|
+
const keyId = keyIdByIdentity.get(identity);
|
|
85
|
+
const cryptoKeyName = keyResourceName(plan, keyId);
|
|
86
|
+
steps.push({
|
|
87
|
+
id: `key:${identity}`,
|
|
88
|
+
kind: 'create-key',
|
|
89
|
+
identity,
|
|
90
|
+
keyId,
|
|
91
|
+
cryptoKeyName,
|
|
92
|
+
description: `Create ${protection.toUpperCase()} ${purpose} key ${keyId} (for "${identity}")`,
|
|
93
|
+
argv: [
|
|
94
|
+
'kms', 'keys', 'create', keyId,
|
|
95
|
+
'--keyring', plan.keyRing,
|
|
96
|
+
'--location', plan.location,
|
|
97
|
+
'--project', plan.project,
|
|
98
|
+
'--purpose', gcloudPurpose,
|
|
99
|
+
'--default-algorithm', gcloudAlgo,
|
|
100
|
+
'--protection-level', protection,
|
|
101
|
+
],
|
|
102
|
+
rest: { project: plan.project, location: plan.location, keyRing: plan.keyRing, keyId, purpose, protectionLevel: plan.protectionLevel ?? 'HSM' },
|
|
103
|
+
});
|
|
104
|
+
steps.push({
|
|
105
|
+
id: `iam:${identity}`,
|
|
106
|
+
kind: 'grant-iam',
|
|
107
|
+
identity,
|
|
108
|
+
keyId,
|
|
109
|
+
cryptoKeyName,
|
|
110
|
+
description: `Grant ${role} on ${keyId} to ${plan.runtimeServiceAccount}`,
|
|
111
|
+
argv: [
|
|
112
|
+
'kms', 'keys', 'add-iam-policy-binding', keyId,
|
|
113
|
+
'--keyring', plan.keyRing,
|
|
114
|
+
'--location', plan.location,
|
|
115
|
+
'--project', plan.project,
|
|
116
|
+
'--member', `serviceAccount:${plan.runtimeServiceAccount}`,
|
|
117
|
+
'--role', role,
|
|
118
|
+
],
|
|
119
|
+
rest: { project: plan.project, location: plan.location, keyRing: plan.keyRing, keyId, role, member: plan.runtimeServiceAccount },
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
return steps;
|
|
123
|
+
}
|
|
124
|
+
/** Execute a provisioning plan through an injected executor. Idempotent: steps whose resource
|
|
125
|
+
* already exists are skipped + reported. For asymmetric keys, fetches each key's public key and
|
|
126
|
+
* derives its EVM address (verify before wiring); encrypt-decrypt KEKs have no public key, so the
|
|
127
|
+
* keyMap points at the version-less cryptoKey resource and no address is derived. */
|
|
128
|
+
export async function executeGcpProvision(plan, exec) {
|
|
129
|
+
const purpose = plan.purpose ?? 'asymmetric-signing';
|
|
130
|
+
const role = plan.iamRole ?? defaultRole(purpose);
|
|
131
|
+
const steps = planGcpProvision(plan);
|
|
132
|
+
const alreadyExisted = [];
|
|
133
|
+
const granted = [];
|
|
134
|
+
for (const step of steps) {
|
|
135
|
+
const r = await exec.run(step);
|
|
136
|
+
if (r.alreadyExists)
|
|
137
|
+
alreadyExisted.push(step.id);
|
|
138
|
+
if (step.kind === 'grant-iam' && step.cryptoKeyName) {
|
|
139
|
+
granted.push({ key: step.cryptoKeyName, member: `serviceAccount:${plan.runtimeServiceAccount}`, role });
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
const keyMap = {};
|
|
143
|
+
const addresses = {};
|
|
144
|
+
for (const identity of plan.identities) {
|
|
145
|
+
const keyId = sanitizeKeyId(identity);
|
|
146
|
+
if (purpose === 'encrypt-decrypt') {
|
|
147
|
+
// The envelope provider's `kmsKeyRef` is the version-less cryptoKey resource.
|
|
148
|
+
keyMap[identity] = keyResourceName(plan, keyId);
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
const versionName = keyVersionName(plan, keyId);
|
|
152
|
+
keyMap[identity] = versionName;
|
|
153
|
+
addresses[identity] = addressFromSpkiPem(await exec.getPublicKeyPem(versionName));
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return { keyMap, addresses, granted, alreadyExisted };
|
|
157
|
+
}
|
|
158
|
+
// ─── B1: gcloud-free REST StepExecutor ─────────────────────────────────────
|
|
159
|
+
const GCP_PURPOSE = { 'asymmetric-signing': 'ASYMMETRIC_SIGN', 'encrypt-decrypt': 'ENCRYPT_DECRYPT' };
|
|
160
|
+
const GCP_ALGORITHM = { 'asymmetric-signing': 'EC_SIGN_SECP256K1_SHA256', 'encrypt-decrypt': 'GOOGLE_SYMMETRIC_ENCRYPTION' };
|
|
161
|
+
/** Build a Cloud KMS REST StepExecutor from a service-account JSON (single-line or base64 — B4).
|
|
162
|
+
* Zero gcloud dependency; SA-JWT → KMS REST. Idempotent (409 ALREADY_EXISTS → skip). */
|
|
163
|
+
export function createGcpRestStepExecutor(opts) {
|
|
164
|
+
const sa = parseServiceAccountJson(opts.serviceAccountJson);
|
|
165
|
+
let cached;
|
|
166
|
+
async function token() {
|
|
167
|
+
const now = Math.floor(Date.now() / 1000);
|
|
168
|
+
if (!cached || cached.expiresAt <= now)
|
|
169
|
+
cached = await fetchAccessToken(sa);
|
|
170
|
+
return cached.accessToken;
|
|
171
|
+
}
|
|
172
|
+
const isConflict = (e) => e instanceof Error && /HTTP 409|ALREADY_EXISTS/i.test(e.message);
|
|
173
|
+
return {
|
|
174
|
+
async run(step) {
|
|
175
|
+
const t = await token();
|
|
176
|
+
const r = step.rest;
|
|
177
|
+
const loc = `projects/${r.project}/locations/${r.location}`;
|
|
178
|
+
if (step.kind === 'create-keyring') {
|
|
179
|
+
try {
|
|
180
|
+
await callKms(t, `${loc}/keyRings?keyRingId=${encodeURIComponent(r.keyRing)}`, { method: 'POST', body: {} });
|
|
181
|
+
return { stdout: 'keyring created' };
|
|
182
|
+
}
|
|
183
|
+
catch (e) {
|
|
184
|
+
if (isConflict(e))
|
|
185
|
+
return { stdout: 'keyring exists', alreadyExists: true };
|
|
186
|
+
throw e;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
if (step.kind === 'create-key') {
|
|
190
|
+
const purpose = r.purpose ?? 'asymmetric-signing';
|
|
191
|
+
try {
|
|
192
|
+
await callKms(t, `${loc}/keyRings/${encodeURIComponent(r.keyRing)}/cryptoKeys?cryptoKeyId=${encodeURIComponent(r.keyId)}`, {
|
|
193
|
+
method: 'POST',
|
|
194
|
+
body: {
|
|
195
|
+
purpose: GCP_PURPOSE[purpose],
|
|
196
|
+
versionTemplate: { algorithm: GCP_ALGORITHM[purpose], protectionLevel: (r.protectionLevel ?? 'HSM') },
|
|
197
|
+
},
|
|
198
|
+
});
|
|
199
|
+
return { stdout: 'key created' };
|
|
200
|
+
}
|
|
201
|
+
catch (e) {
|
|
202
|
+
if (isConflict(e))
|
|
203
|
+
return { stdout: 'key exists', alreadyExists: true };
|
|
204
|
+
throw e;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
// grant-iam: read-modify-write the key's IAM policy (idempotent; member added once).
|
|
208
|
+
const keyPath = `${loc}/keyRings/${encodeURIComponent(r.keyRing)}/cryptoKeys/${encodeURIComponent(r.keyId)}`;
|
|
209
|
+
const policy = await callKms(t, `${keyPath}:getIamPolicy`, { method: 'GET' });
|
|
210
|
+
const member = `serviceAccount:${r.member}`;
|
|
211
|
+
const bindings = policy.bindings ?? [];
|
|
212
|
+
let binding = bindings.find((b) => b.role === r.role);
|
|
213
|
+
if (!binding) {
|
|
214
|
+
binding = { role: r.role, members: [] };
|
|
215
|
+
bindings.push(binding);
|
|
216
|
+
}
|
|
217
|
+
if (binding.members.includes(member))
|
|
218
|
+
return { stdout: 'iam binding already present', alreadyExists: true };
|
|
219
|
+
binding.members.push(member);
|
|
220
|
+
await callKms(t, `${keyPath}:setIamPolicy`, { method: 'POST', body: { policy: { ...policy, bindings } } });
|
|
221
|
+
return { stdout: 'iam granted' };
|
|
222
|
+
},
|
|
223
|
+
async getPublicKeyPem(cryptoKeyVersionName) {
|
|
224
|
+
const res = await callKms(await token(), `${cryptoKeyVersionName}/publicKey`, { method: 'GET' });
|
|
225
|
+
return res.pem;
|
|
226
|
+
},
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
//# sourceMappingURL=provision-gcp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provision-gcp.js","sourceRoot":"","sources":["../../src/kms/provision-gcp.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,EAAE;AACF,kFAAkF;AAClF,gFAAgF;AAChF,+EAA+E;AAC/E,wEAAwE;AACxE,wFAAwF;AACxF,EAAE;AACF,wFAAwF;AACxF,8EAA8E;AAC9E,mFAAmF;AACnF,sFAAsF;AAEtF,OAAO,EAAE,kBAAkB,EAAY,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAoB,MAAM,oBAAoB,CAAC;AACjF,OAAO,EAAE,uBAAuB,E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AAO,CAAC,CAAC,EAAE,GAAG,OAAO,eAAe,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,EAAE,GAAG,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC;YAC3G,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC;QACnC,CAAC;QACD,KAAK,CAAC,eAAe,CAAC,oBAA4B;YAChD,MAAM,GAAG,GAAG,MAAM,OAAO,CAAkB,MAAM,KAAK,EAAE,EAAE,GAAG,oBAAoB,YAAY,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;YAClH,OAAO,GAAG,CAAC,GAAG,CAAC;QACjB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/** A 0x-prefixed lowercase hex string (structurally compatible with viem's `Hex`/`Address`). */
|
|
2
|
+
export type Hex = `0x${string}`;
|
|
3
|
+
/** Bytes → `0x`-prefixed lowercase hex. Byte-for-byte compatible with viem's `bytesToHex`. */
|
|
4
|
+
export declare function bytesToHex(bytes: Uint8Array): Hex;
|
|
5
|
+
export declare function base64UrlEncode(bytes: Uint8Array): string;
|
|
6
|
+
export declare function base64Decode(s: string): Uint8Array;
|
|
7
|
+
export declare function base64Encode(bytes: Uint8Array): string;
|
|
8
|
+
export declare function pemToDer(pem: string): Uint8Array;
|
|
9
|
+
export declare function bigIntTo32Bytes(n: bigint): Uint8Array;
|
|
10
|
+
/** Parse a DER-encoded ECDSA signature → `(r, s)`. Range-validates `0 < r,s < n`
|
|
11
|
+
* (audit F-7): a degenerate KMS response (r/s = 0 or ≥ n) is never valid — fail closed. */
|
|
12
|
+
export declare function parseDerEcdsa(der: Uint8Array): {
|
|
13
|
+
r: bigint;
|
|
14
|
+
s: bigint;
|
|
15
|
+
};
|
|
16
|
+
/** spec-276 alias for {@link parseDerEcdsa}. */
|
|
17
|
+
export declare const parseDerEcdsaSignature: typeof parseDerEcdsa;
|
|
18
|
+
/** Normalize `s` to its low-s form (EIP-2): malleability-canonical signatures only. */
|
|
19
|
+
export declare function normalizeLowS(s: bigint): bigint;
|
|
20
|
+
/** spec-276 alias for {@link normalizeLowS}. */
|
|
21
|
+
export declare const toLowS: typeof normalizeLowS;
|
|
22
|
+
/** Extract the trailing 65-byte uncompressed secp256k1 point (`0x04||X||Y`) from an SPKI DER blob. */
|
|
23
|
+
export declare function parseSpkiUncompressedSecp256k1PubKey(spkiDer: Uint8Array): Uint8Array;
|
|
24
|
+
/** `0x04||X||Y` (65 bytes) → EVM address (`keccak256(X||Y)[-20:]`). */
|
|
25
|
+
export declare function publicKeyToAddress(pubKey65: Uint8Array): Hex;
|
|
26
|
+
/** Convenience: SPKI PEM (the Cloud KMS `publicKey` response) → EVM address. */
|
|
27
|
+
export declare function addressFromSpkiPem(pem: string): Hex;
|
|
28
|
+
/** Cloud KMS does not return the recovery bit; recover it by trying v∈{27,28}
|
|
29
|
+
* against the known uncompressed public key. Throws (redacted error) if neither matches. */
|
|
30
|
+
export declare function findRecoveryByte(r: bigint, s: bigint, digest: Uint8Array, knownPubKey65: Uint8Array): number;
|
|
31
|
+
/** spec-276 ordering of {@link findRecoveryByte}: `(digest, r, s, knownPubKey65)`. */
|
|
32
|
+
export declare function recoverV(digest: Uint8Array, r: bigint, s: bigint, knownPubKey65: Uint8Array): 27 | 28;
|
|
33
|
+
/** Assemble an Ethereum 65-byte `(r,s,v)` signature as 0x hex. */
|
|
34
|
+
export declare function assembleEthSignature(r: bigint, s: bigint, v: number): Hex;
|
|
35
|
+
/** Turn a raw KMS asymmetric-sign (DER output) into an Ethereum `(r,s,v)` signature.
|
|
36
|
+
* Transport is INJECTED (`asymmetricSign`) so this stays peer-dependency-free and
|
|
37
|
+
* testable: the caller supplies however it reaches Cloud KMS. Returns 0x-hex 65 bytes. */
|
|
38
|
+
export declare function signDigestWithKms(opts: {
|
|
39
|
+
/** The 32-byte keccak digest to sign. */
|
|
40
|
+
digest: Uint8Array;
|
|
41
|
+
/** The signing key's SPKI PEM (the Cloud KMS `publicKey` response `.pem`). Cached by the caller. */
|
|
42
|
+
publicKeyPem: string;
|
|
43
|
+
/** Calls Cloud KMS `:asymmetricSign` for the digest; returns the DER-encoded signature bytes. */
|
|
44
|
+
asymmetricSign: (digest: Uint8Array) => Promise<Uint8Array>;
|
|
45
|
+
}): Promise<Hex>;
|
|
46
|
+
//# sourceMappingURL=secp256k1-core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secp256k1-core.d.ts","sourceRoot":"","sources":["../../src/kms/secp256k1-core.ts"],"names":[],"mappings":"AAwBA,gGAAgG;AAChG,MAAM,MAAM,GAAG,GAAG,KAAK,MAAM,EAAE,CAAC;AAIhC,8FAA8F;AAC9F,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,GAAG,CAIjD;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAIzD;AAED,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,GAAG,UAAU,CAKlD;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAItD;AAED,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAMhD;AAUD,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,GAAG,UAAU,CAQrD;AAID;4FAC4F;AAC5F,wBAAgB,aAAa,CAAC,GAAG,EAAE,UAAU,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CA2BvE;AAED,gDAAgD;AAChD,eAAO,MAAM,sBAAsB,sBAAgB,CAAC;AAEpD,uFAAuF;AACvF,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED,gDAAgD;AAChD,eAAO,MAAM,MAAM,sBAAgB,CAAC;AAIpC,sGAAsG;AACtG,wBAAgB,oCA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