@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.
Files changed (65) hide show
  1. package/README.md +22 -5
  2. package/bin/ap-provision-gcp.mjs +91 -0
  3. package/dist/account.d.ts +1 -1
  4. package/dist/account.d.ts.map +1 -1
  5. package/dist/account.js +1 -1
  6. package/dist/account.js.map +1 -1
  7. package/dist/derive-subject.d.ts +1 -1
  8. package/dist/derive-subject.d.ts.map +1 -1
  9. package/dist/derive-subject.js +5 -5
  10. package/dist/derive-subject.js.map +1 -1
  11. package/dist/factories.d.ts +27 -1
  12. package/dist/factories.d.ts.map +1 -1
  13. package/dist/factories.js +29 -5
  14. package/dist/factories.js.map +1 -1
  15. package/dist/index.d.ts +12 -10
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +33 -9
  18. package/dist/index.js.map +1 -1
  19. package/dist/kms/gcp-transport.d.ts +36 -0
  20. package/dist/kms/gcp-transport.d.ts.map +1 -0
  21. package/dist/kms/gcp-transport.js +114 -0
  22. package/dist/kms/gcp-transport.js.map +1 -0
  23. package/dist/kms/key-map.d.ts +13 -0
  24. package/dist/kms/key-map.d.ts.map +1 -0
  25. package/dist/kms/key-map.js +65 -0
  26. package/dist/kms/key-map.js.map +1 -0
  27. package/dist/kms/kms-core.d.ts +4 -0
  28. package/dist/kms/kms-core.d.ts.map +1 -0
  29. package/dist/kms/kms-core.js +14 -0
  30. package/dist/kms/kms-core.js.map +1 -0
  31. package/dist/kms/provision-gcp.d.ts +89 -0
  32. package/dist/kms/provision-gcp.d.ts.map +1 -0
  33. package/dist/kms/provision-gcp.js +229 -0
  34. package/dist/kms/provision-gcp.js.map +1 -0
  35. package/dist/kms/secp256k1-core.d.ts +46 -0
  36. package/dist/kms/secp256k1-core.d.ts.map +1 -0
  37. package/dist/kms/secp256k1-core.js +209 -0
  38. package/dist/kms/secp256k1-core.js.map +1 -0
  39. package/dist/kms-viem-account.d.ts +1 -1
  40. package/dist/kms-viem-account.d.ts.map +1 -1
  41. package/dist/providers/aws.d.ts +4 -1
  42. package/dist/providers/aws.d.ts.map +1 -1
  43. package/dist/providers/aws.js +17 -7
  44. package/dist/providers/aws.js.map +1 -1
  45. package/dist/providers/gcp.d.ts +23 -36
  46. package/dist/providers/gcp.d.ts.map +1 -1
  47. package/dist/providers/gcp.js +89 -340
  48. package/dist/providers/gcp.js.map +1 -1
  49. package/dist/providers/local.d.ts +4 -4
  50. package/dist/providers/local.d.ts.map +1 -1
  51. package/dist/providers/local.js +17 -7
  52. package/dist/providers/local.js.map +1 -1
  53. package/dist/relay-only.d.ts +1 -1
  54. package/dist/relay-only.d.ts.map +1 -1
  55. package/dist/relay-only.js +1 -1
  56. package/dist/relay-only.js.map +1 -1
  57. package/dist/relayer-account.d.ts +44 -0
  58. package/dist/relayer-account.d.ts.map +1 -0
  59. package/dist/relayer-account.js +146 -0
  60. package/dist/relayer-account.js.map +1 -0
  61. package/dist/spend-capped-account.d.ts +71 -0
  62. package/dist/spend-capped-account.d.ts.map +1 -0
  63. package/dist/spend-capped-account.js +181 -0
  64. package/dist/spend-capped-account.js.map +1 -0
  65. package/package.json +40 -9
@@ -0,0 +1,209 @@
1
+ // secp256k1 KMS signing core — the CONSUMER-SAFE, peer-dependency-free surface (spec 276 KCS-D1).
2
+ //
3
+ // This module contains the raw cryptography for turning a Cloud-KMS-style
4
+ // secp256k1 asymmetric signature into an Ethereum-compatible 65-byte
5
+ // `(r,s,v)` signature, plus SPKI public-key → address derivation. It is the
6
+ // extract that lets an external consumer import the primitive instead of
7
+ // inlining a copy (the demo-validator `kms-signer.ts` problem).
8
+ //
9
+ // HARD CONSTRAINT (enforced by test/unit/kms-core-import-graph.test.ts):
10
+ // This file and everything it imports MUST depend ONLY on `@noble/curves`,
11
+ // `@noble/hashes`, and Web/Node built-ins. NO `viem`, NO `@agenticprimitives/*`.
12
+ // That is the entire point — a standalone external app can import
13
+ // `@agenticprimitives/key-custody/kms-core` with no viem / audit / connect-auth peer install.
14
+ //
15
+ // The audited, viem-typed `GcpKmsSigner` (providers/gcp.ts) is a thin wrapper
16
+ // over this core — one implementation, two surfaces (no second KMS path).
17
+ import { secp256k1 } from '@noble/curves/secp256k1.js';
18
+ import { keccak_256 } from '@noble/hashes/sha3.js';
19
+ // ── secp256k1 constants ──────────────────────────────────────────────
20
+ const SECP256K1_N = secp256k1.Point.Fn.ORDER;
21
+ const SECP256K1_HALF_N = SECP256K1_N >> 1n;
22
+ // ── hex / base64 / PEM helpers (viem-free) ───────────────────────────
23
+ /** Bytes → `0x`-prefixed lowercase hex. Byte-for-byte compatible with viem's `bytesToHex`. */
24
+ export function bytesToHex(bytes) {
25
+ let h = '';
26
+ for (let i = 0; i < bytes.length; i++)
27
+ h += bytes[i].toString(16).padStart(2, '0');
28
+ return `0x${h}`;
29
+ }
30
+ export function base64UrlEncode(bytes) {
31
+ let str = '';
32
+ for (let i = 0; i < bytes.length; i++)
33
+ str += String.fromCharCode(bytes[i]);
34
+ return btoa(str).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
35
+ }
36
+ export function base64Decode(s) {
37
+ const binary = atob(s);
38
+ const out = new Uint8Array(binary.length);
39
+ for (let i = 0; i < binary.length; i++)
40
+ out[i] = binary.charCodeAt(i);
41
+ return out;
42
+ }
43
+ export function base64Encode(bytes) {
44
+ let str = '';
45
+ for (let i = 0; i < bytes.length; i++)
46
+ str += String.fromCharCode(bytes[i]);
47
+ return btoa(str);
48
+ }
49
+ export function pemToDer(pem) {
50
+ const lines = pem
51
+ .split('\n')
52
+ .filter((l) => !l.startsWith('-----') && l.trim().length > 0)
53
+ .join('');
54
+ return base64Decode(lines);
55
+ }
56
+ // ── bigint <-> bytes ─────────────────────────────────────────────────
57
+ function bytesToBigInt(bytes) {
58
+ let n = 0n;
59
+ for (const b of bytes)
60
+ n = (n << 8n) | BigInt(b);
61
+ return n;
62
+ }
63
+ export function bigIntTo32Bytes(n) {
64
+ const out = new Uint8Array(32);
65
+ let v = n;
66
+ for (let i = 31; i >= 0; i--) {
67
+ out[i] = Number(v & 0xffn);
68
+ v >>= 8n;
69
+ }
70
+ return out;
71
+ }
72
+ // ── DER ECDSA signature parsing ──────────────────────────────────────
73
+ /** Parse a DER-encoded ECDSA signature → `(r, s)`. Range-validates `0 < r,s < n`
74
+ * (audit F-7): a degenerate KMS response (r/s = 0 or ≥ n) is never valid — fail closed. */
75
+ export function parseDerEcdsa(der) {
76
+ const at = (idx) => {
77
+ const b = der[idx];
78
+ if (b === undefined)
79
+ throw new Error(`DER: unexpected end of buffer at offset ${idx}`);
80
+ return b;
81
+ };
82
+ let i = 0;
83
+ if (at(i++) !== 0x30)
84
+ throw new Error('DER: expected SEQUENCE tag (0x30)');
85
+ // Skip length. Handle short and long form.
86
+ const lenByte = at(i++);
87
+ if (lenByte & 0x80) {
88
+ const lenBytes = lenByte & 0x7f;
89
+ i += lenBytes;
90
+ }
91
+ if (at(i++) !== 0x02)
92
+ throw new Error('DER: expected INTEGER tag for r');
93
+ const rLen = at(i++);
94
+ const rBytes = der.slice(i, i + rLen);
95
+ i += rLen;
96
+ if (at(i++) !== 0x02)
97
+ throw new Error('DER: expected INTEGER tag for s');
98
+ const sLen = at(i++);
99
+ const sBytes = der.slice(i, i + sLen);
100
+ const r = bytesToBigInt(rBytes);
101
+ const s = bytesToBigInt(sBytes);
102
+ if (r <= 0n || r >= SECP256K1_N || s <= 0n || s >= SECP256K1_N) {
103
+ throw new Error('DER: r/s out of range (require 0 < r,s < n)');
104
+ }
105
+ return { r, s };
106
+ }
107
+ /** spec-276 alias for {@link parseDerEcdsa}. */
108
+ export const parseDerEcdsaSignature = parseDerEcdsa;
109
+ /** Normalize `s` to its low-s form (EIP-2): malleability-canonical signatures only. */
110
+ export function normalizeLowS(s) {
111
+ return s > SECP256K1_HALF_N ? SECP256K1_N - s : s;
112
+ }
113
+ /** spec-276 alias for {@link normalizeLowS}. */
114
+ export const toLowS = normalizeLowS;
115
+ // ── SPKI public-key parsing + address derivation ─────────────────────
116
+ /** Extract the trailing 65-byte uncompressed secp256k1 point (`0x04||X||Y`) from an SPKI DER blob. */
117
+ export function parseSpkiUncompressedSecp256k1PubKey(spkiDer) {
118
+ if (spkiDer.length < 66) {
119
+ throw new Error(`SPKI too short to contain uncompressed secp256k1 pubkey: ${spkiDer.length} bytes`);
120
+ }
121
+ const tail = spkiDer.slice(spkiDer.length - 65);
122
+ const marker = tail[0];
123
+ if (marker !== 0x04) {
124
+ throw new Error(`SPKI does not end with uncompressed point marker (0x04). Wrong key algorithm? ` +
125
+ `Found 0x${(marker ?? 0).toString(16).padStart(2, '0')} at position ${spkiDer.length - 65}.`);
126
+ }
127
+ return tail;
128
+ }
129
+ /** `0x04||X||Y` (65 bytes) → EVM address (`keccak256(X||Y)[-20:]`). */
130
+ export function publicKeyToAddress(pubKey65) {
131
+ const raw = pubKey65.slice(1);
132
+ const hash = keccak_256(raw);
133
+ return bytesToHex(hash.slice(12));
134
+ }
135
+ /** Convenience: SPKI PEM (the Cloud KMS `publicKey` response) → EVM address. */
136
+ export function addressFromSpkiPem(pem) {
137
+ return publicKeyToAddress(parseSpkiUncompressedSecp256k1PubKey(pemToDer(pem)));
138
+ }
139
+ // ── recovery-byte search ─────────────────────────────────────────────
140
+ function bytesEqual(a, b) {
141
+ if (a.length !== b.length)
142
+ return false;
143
+ for (let i = 0; i < a.length; i++)
144
+ if (a[i] !== b[i])
145
+ return false;
146
+ return true;
147
+ }
148
+ /** Cloud KMS does not return the recovery bit; recover it by trying v∈{27,28}
149
+ * against the known uncompressed public key. Throws (redacted error) if neither matches. */
150
+ export function findRecoveryByte(r, s, digest, knownPubKey65) {
151
+ const rBytes = bigIntTo32Bytes(r);
152
+ const sBytes = bigIntTo32Bytes(s);
153
+ const compact = new Uint8Array(64);
154
+ compact.set(rBytes, 0);
155
+ compact.set(sBytes, 32);
156
+ const attempts = [];
157
+ for (let recovery = 0; recovery < 2; recovery++) {
158
+ try {
159
+ const sig = secp256k1.Signature.fromBytes(compact).addRecoveryBit(recovery);
160
+ const recovered = sig.recoverPublicKey(digest).toBytes(false);
161
+ attempts.push(`v=${recovery + 27} recovered=${bytesToHex(recovered)}`);
162
+ if (bytesEqual(recovered, knownPubKey65))
163
+ return recovery + 27;
164
+ }
165
+ catch (e) {
166
+ attempts.push(`v=${recovery + 27} threw ${e instanceof Error ? e.message : String(e)}`);
167
+ }
168
+ }
169
+ // Redact operational fingerprints (digest/pubkey are chain-correlatable / long-lived
170
+ // identity) to keccak-prefix-8 — still actionable, no raw values leaked (PKG-KEY-CUSTODY-004).
171
+ const tag = (label, b) => `${label}=${bytesToHex(keccak_256(b)).slice(0, 8)}`;
172
+ // eslint-disable-next-line no-console
173
+ console.error('[gcp-kms findRecoveryByte] mismatch:', {
174
+ digestTag: tag('k', digest),
175
+ rTag: tag('k', rBytes),
176
+ sTag: tag('k', sBytes),
177
+ knownPubKeyTag: tag('k', knownPubKey65),
178
+ attempts,
179
+ });
180
+ throw new Error('Recovery byte search failed: neither v=27 nor v=28 recovers the known public key. ' + attempts.join(' | '));
181
+ }
182
+ /** spec-276 ordering of {@link findRecoveryByte}: `(digest, r, s, knownPubKey65)`. */
183
+ export function recoverV(digest, r, s, knownPubKey65) {
184
+ return findRecoveryByte(r, s, digest, knownPubKey65);
185
+ }
186
+ /** Assemble an Ethereum 65-byte `(r,s,v)` signature as 0x hex. */
187
+ export function assembleEthSignature(r, s, v) {
188
+ const sig65 = new Uint8Array(65);
189
+ sig65.set(bigIntTo32Bytes(r), 0);
190
+ sig65.set(bigIntTo32Bytes(s), 32);
191
+ sig65[64] = v;
192
+ return bytesToHex(sig65);
193
+ }
194
+ // ── high-level: digest → eth signature, transport injected ───────────
195
+ /** Turn a raw KMS asymmetric-sign (DER output) into an Ethereum `(r,s,v)` signature.
196
+ * Transport is INJECTED (`asymmetricSign`) so this stays peer-dependency-free and
197
+ * testable: the caller supplies however it reaches Cloud KMS. Returns 0x-hex 65 bytes. */
198
+ export async function signDigestWithKms(opts) {
199
+ if (opts.digest.length !== 32) {
200
+ throw new Error(`signDigestWithKms expects a 32-byte digest; got ${opts.digest.length}.`);
201
+ }
202
+ const pub65 = parseSpkiUncompressedSecp256k1PubKey(pemToDer(opts.publicKeyPem));
203
+ const der = await opts.asymmetricSign(opts.digest);
204
+ const { r, s: rawS } = parseDerEcdsa(der);
205
+ const s = normalizeLowS(rawS);
206
+ const v = recoverV(opts.digest, r, s, pub65);
207
+ return assembleEthSignature(r, s, v);
208
+ }
209
+ //# sourceMappingURL=secp256k1-core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secp256k1-core.js","sourceRoot":"","sources":["../../src/kms/secp256k1-core.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG,EAAE;AACF,0EAA0E;AAC1E,qEAAqE;AACrE,4EAA4E;AAC5E,yEAAyE;AACzE,gEAAgE;AAChE,EAAE;AACF,yEAAyE;AACzE,6EAA6E;AAC7E,mFAAmF;AACnF,oEAAoE;AACpE,gGAAgG;AAChG,EAAE;AACF,8EAA8E;AAC9E,0EAA0E;AAE1E,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,wEAAwE;AACxE,MAAM,WAAW,GAAG,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC;AAC7C,MAAM,gBAAgB,GAAG,WAAW,IAAI,EAAE,CAAC;AAK3C,wEAAwE;AAExE,8FAA8F;AAC9F,MAAM,UAAU,UAAU,CAAC,KAAiB;IAC1C,IAAI,CAAC,GAAG,EAAE,CAAC;IACX,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE;QAAE,CAAC,IAAI,KAAK,CAAC,CAAC,CAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CA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AE,CAAS;IAClE,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;IACjC,KAAK,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACjC,KAAK,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAClC,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IACd,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC;AAC3B,CAAC;AAED,wEAAwE;AAExE;;2FAE2F;AAC3F,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,IAOvC;IACC,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,EAAE,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CAAC,mDAAmD,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;IAC5F,CAAC;IACD,MAAM,KAAK,GAAG,oCAAoC,CAAC,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;IAChF,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACnD,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;IAC1C,MAAM,CAAC,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;IAC9B,MAAM,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;IAC7C,OAAO,oBAAoB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AACvC,CAAC"}
@@ -1,4 +1,4 @@
1
1
  import { type LocalAccount } from 'viem';
2
- import type { KmsAccountBackend } from './types';
2
+ import type { KmsAccountBackend } from './types.js';
3
3
  export declare function createKmsViemAccount(backend: KmsAccountBackend): Promise<LocalAccount>;
4
4
  //# sourceMappingURL=kms-viem-account.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"kms-viem-account.d.ts","sourceRoot":"","sources":["../src/kms-viem-account.ts"],"names":[],"mappings":"AAqBA,OAAO,EASL,KAAK,YAAY,EAElB,MAAM,MAAM,CAAC;AACd,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AA0BjD,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,YAAY,CAAC,CAwC5F"}
1
+ {"version":3,"file":"kms-viem-account.d.ts","sourceRoot":"","sources":["../src/kms-viem-account.ts"],"names":[],"mappings":"AAqBA,OAAO,EASL,KAAK,YAAY,EAElB,MAAM,MAAM,CAAC;AACd,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AA0BpD,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,YAAY,CAAC,CAwC5F"}
@@ -1,12 +1,15 @@
1
- import type { A2AKeyProvider, KmsAccountBackend } from '../types';
1
+ import type { A2AKeyProvider, KmsAccountBackend } from '../types.js';
2
2
  import type { Address } from '@agenticprimitives/types';
3
+ export declare const AWS_KMS_NOT_IMPLEMENTED: string;
3
4
  export declare class AwsKmsProvider implements A2AKeyProvider {
4
5
  readonly keyVersion = "aws-kms:not-implemented";
6
+ constructor();
5
7
  generateSessionDataKey(): Promise<never>;
6
8
  decryptSessionDataKey(): Promise<never>;
7
9
  }
8
10
  export declare class AwsKmsSigner implements KmsAccountBackend {
9
11
  readonly provider: "aws-kms";
12
+ constructor();
10
13
  signA2AAction(): Promise<never>;
11
14
  getSignerAddress(): Promise<Address>;
12
15
  }
@@ -1 +1 @@
1
- {"version":3,"file":"aws.d.ts","sourceRoot":"","sources":["../../src/providers/aws.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAClE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAIxD,qBAAa,cAAe,YAAW,cAAc;IACnD,QAAQ,CAAC,UAAU,6BAA6B;IAC1C,sBAAsB,IAAI,OAAO,CAAC,KAAK,CAAC;IACxC,qBAAqB,IAAI,OAAO,CAAC,KAAK,CAAC;CAC9C;AAED,qBAAa,YAAa,YAAW,iBAAiB;IACpD,QAAQ,CAAC,QAAQ,EAAG,SAAS,CAAU;IACjC,aAAa,IAAI,OAAO,CAAC,KAAK,CAAC;IAC/B,gBAAgB,IAAI,OAAO,CAAC,OAAO,CAAC;CAC3C"}
1
+ {"version":3,"file":"aws.d.ts","sourceRoot":"","sources":["../../src/providers/aws.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAExD,eAAO,MAAM,uBAAuB,QAEyE,CAAC;AAE9G,qBAAa,cAAe,YAAW,cAAc;IACnD,QAAQ,CAAC,UAAU,6BAA6B;;IAG1C,sBAAsB,IAAI,OAAO,CAAC,KAAK,CAAC;IACxC,qBAAqB,IAAI,OAAO,CAAC,KAAK,CAAC;CAC9C;AAED,qBAAa,YAAa,YAAW,iBAAiB;IACpD,QAAQ,CAAC,QAAQ,EAAG,SAAS,CAAU;;IAGjC,aAAa,IAAI,OAAO,CAAC,KAAK,CAAC;IAC/B,gBAAgB,IAAI,OAAO,CAAC,OAAO,CAAC;CAC3C"}
@@ -1,14 +1,24 @@
1
- // AwsKmsProvider / AwsKmsSigner — production AWS KMS backends.
2
- // Stubs in v0 demo; full implementation lands in v0.1.
3
- const NOT_IMPLEMENTED = 'AwsKmsProvider / AwsKmsSigner not yet implemented in v0; use LocalAesProvider for the demo.';
1
+ // AwsKmsProvider / AwsKmsSigner — AWS KMS backend (NOT YET IMPLEMENTED).
2
+ //
3
+ // AUDIT N-2: these must FAIL FAST. Previously the classes constructed cleanly and threw only on the
4
+ // first signing/encryption call — a deferred-failure footgun: an operator who selects `aws-kms` for a
5
+ // real deployment boots fine and explodes on the first hot-path op. Per the package's "fail-closed at
6
+ // boot" invariant (CLAUDE.md security invariants), construction now throws. Only `gcp-kms` is
7
+ // production-ready (spec 214 §5 is single-chain GCP-KMS); `aws-kms` is reserved, not wired.
8
+ export const AWS_KMS_NOT_IMPLEMENTED = '[key-custody] aws-kms backend is not implemented. Use backend "gcp-kms" for real deploys ' +
9
+ '(the only production-ready KMS, spec 214 §5) or "local-aes" for dev. `aws-kms` is reserved but not wired.';
4
10
  export class AwsKmsProvider {
5
11
  keyVersion = 'aws-kms:not-implemented';
6
- async generateSessionDataKey() { throw new Error(NOT_IMPLEMENTED); }
7
- async decryptSessionDataKey() { throw new Error(NOT_IMPLEMENTED); }
12
+ // Fail fast at construction (N-2) rather than on the first generate/decrypt call.
13
+ constructor() { throw new Error(AWS_KMS_NOT_IMPLEMENTED); }
14
+ async generateSessionDataKey() { throw new Error(AWS_KMS_NOT_IMPLEMENTED); }
15
+ async decryptSessionDataKey() { throw new Error(AWS_KMS_NOT_IMPLEMENTED); }
8
16
  }
9
17
  export class AwsKmsSigner {
10
18
  provider = 'aws-kms';
11
- async signA2AAction() { throw new Error(NOT_IMPLEMENTED); }
12
- async getSignerAddress() { throw new Error(NOT_IMPLEMENTED); }
19
+ // Fail fast at construction (N-2) rather than on the first sign/getSignerAddress call.
20
+ constructor() { throw new Error(AWS_KMS_NOT_IMPLEMENTED); }
21
+ async signA2AAction() { throw new Error(AWS_KMS_NOT_IMPLEMENTED); }
22
+ async getSignerAddress() { throw new Error(AWS_KMS_NOT_IMPLEMENTED); }
13
23
  }
14
24
  //# sourceMappingURL=aws.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"aws.js","sourceRoot":"","sources":["../../src/providers/aws.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,uDAAuD;AAKvD,MAAM,eAAe,GAAG,6FAA6F,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AAI,KAAK,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC;IACnF,KAAK,CAAC,gBAAgB,KAAuB,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC;CACzF"}
@@ -1,17 +1,8 @@
1
- import { type Address } from 'viem';
1
+ import type { Address } from 'viem';
2
2
  import { type AuditSink } from '@agenticprimitives/audit';
3
- import type { A2AKeyProvider, KmsAccountBackend } from '../types';
4
- interface ServiceAccount {
5
- client_email: string;
6
- /** PEM-encoded PKCS#8 RSA private key. */
7
- private_key: string;
8
- project_id?: string;
9
- }
10
- interface CachedToken {
11
- accessToken: string;
12
- /** Unix seconds at which the token must be refreshed (already minus buffer). */
13
- expiresAt: number;
14
- }
3
+ import type { A2AKeyProvider, KmsAccountBackend } from '../types.js';
4
+ export { base64UrlEncode, pemToDer, parseDerEcdsa, normalizeLowS, bigIntTo32Bytes, parseSpkiUncompressedSecp256k1PubKey, publicKeyToAddress, findRecoveryByte, } from '../kms/secp256k1-core.js';
5
+ export { signJwt, fetchAccessToken } from '../kms/gcp-transport.js';
15
6
  export interface GcpKmsSignerOpts {
16
7
  /**
17
8
  * Full Cloud KMS resource name of the key version to sign with, e.g.
@@ -22,31 +13,16 @@ export interface GcpKmsSignerOpts {
22
13
  /** Raw JSON string of the service-account key file. */
23
14
  serviceAccountJson: string;
24
15
  }
25
- export declare function base64UrlEncode(bytes: Uint8Array): string;
26
- export declare function pemToDer(pem: string): Uint8Array;
27
- export declare function signJwt(serviceAccount: ServiceAccount, scope: string): Promise<string>;
28
- export declare function fetchAccessToken(serviceAccount: ServiceAccount): Promise<CachedToken>;
29
- export declare function parseSpkiUncompressedSecp256k1PubKey(spkiDer: Uint8Array): Uint8Array;
30
- export declare function publicKeyToAddress(pubKey65: Uint8Array): Address;
31
- export declare function parseDerEcdsa(der: Uint8Array): {
32
- r: bigint;
33
- s: bigint;
34
- };
35
- export declare function bigIntTo32Bytes(n: bigint): Uint8Array;
36
- export declare function normalizeLowS(s: bigint): bigint;
37
- export declare function findRecoveryByte(r: bigint, s: bigint, digest: Uint8Array, knownPubKey65: Uint8Array): number;
38
16
  export declare class GcpKmsSigner implements KmsAccountBackend {
39
17
  readonly provider: "gcp-kms";
40
18
  private readonly keyName;
41
- private readonly serviceAccount;
19
+ private readonly transport;
42
20
  private readonly auditSink?;
43
- private cachedToken?;
44
21
  private cachedPubKey65?;
45
22
  private cachedAddress?;
46
23
  constructor(opts?: Partial<GcpKmsSignerOpts> & {
47
24
  auditSink?: AuditSink;
48
25
  });
49
- private getAccessToken;
50
26
  private getPublicKeyBytes;
51
27
  getSignerAddress(): Promise<Address>;
52
28
  signA2AAction(input: {
@@ -71,18 +47,30 @@ export interface GcpKmsProviderOpts {
71
47
  cryptoKeyName: string;
72
48
  /** Raw JSON string of the service-account key file. */
73
49
  serviceAccountJson: string;
74
- }
75
- export declare class GcpKmsProvider implements A2AKeyProvider {
76
50
  /**
77
- * H7-F.4: this default is now ONLY used when the GCP encrypt response
78
- * doesn't carry a `name` field (test fixtures + offline mocks). Real
79
- * runs derive `keyVersion` from the response per call.
51
+ * Optional audit sink (spec 278 P0). When set, each envelope op emits a
52
+ * `key-custody.envelope.{wrap,unwrap}` row carrying refs/hashes ONLY
53
+ * (`keyId`, `keyVersion`, `aadHash`) — never the data key or plaintext.
54
+ * Fail-soft: an audit failure never breaks the crypto op.
80
55
  */
56
+ auditSink?: AuditSink;
57
+ }
58
+ export declare class GcpKmsProvider implements A2AKeyProvider {
59
+ /** Only used when the GCP encrypt response doesn't carry a `name` (test fixtures). */
81
60
  readonly keyVersion = "gcp-kms:unknown";
82
61
  private readonly keyName;
83
62
  private readonly serviceAccount;
63
+ private readonly auditSink?;
84
64
  private cachedToken?;
85
- constructor(opts?: Partial<GcpKmsProviderOpts>);
65
+ constructor(opts?: Partial<GcpKmsProviderOpts> & {
66
+ auditSink?: AuditSink;
67
+ });
68
+ /**
69
+ * Emit an envelope-op audit row (spec 278 P0). Refs/hashes ONLY — the AAD is
70
+ * hashed (never logged raw, since it can carry owner/resource identifiers),
71
+ * and the data key / plaintext never appear. Fail-soft.
72
+ */
73
+ private emitEnvelopeAudit;
86
74
  private getAccessToken;
87
75
  generateSessionDataKey(input: {
88
76
  aadContext: Record<string, string>;
@@ -99,5 +87,4 @@ export declare class GcpKmsProvider implements A2AKeyProvider {
99
87
  keyVersion: string;
100
88
  }): Promise<Uint8Array>;
101
89
  }
102
- export {};
103
90
  //# sourceMappingURL=gcp.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"gcp.d.ts","sourceRoot":"","sources":["../../src/providers/gcp.ts"],"names":[],"mappings":"AA6BA,OAAO,EAAc,KAAK,OAAO,EAAE,MAAM,MAAM,CAAC;AAChD,OAAO,EAAc,KAAK,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAkBlE,UAAU,cAAc;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,0CAA0C;IAC1C,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,UAAU,WAAW;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,gFAAgF;IAChF,SAAS,EAAE,MAAM,CAAC;CACnB;AAYD,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,oBAAoB,EAAE,MAAM,CAAC;IAC7B,uDAAuD;IACvD,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAMD,wBAAgB,eAAe,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAIzD;AAeD,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAMhD;AAMD,wBAAsB,OAAO,CAAC,cAAc,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAiC5F;AAED,wBAAsB,gBAAgB,CAAC,cAAc,EAAE,cAAc,GAAG,OA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