@agenticprimitives/ap-kms 0.0.0-alpha.1
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/LICENSE +21 -0
- package/README.md +52 -0
- package/bin/ap-kms.mjs +53 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/manifest.d.ts +74 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/manifest.js +48 -0
- package/dist/manifest.js.map +1 -0
- package/dist/node/bindings.d.ts +3 -0
- package/dist/node/bindings.d.ts.map +1 -0
- package/dist/node/bindings.js +17 -0
- package/dist/node/bindings.js.map +1 -0
- package/dist/node/gcp.d.ts +11 -0
- package/dist/node/gcp.d.ts.map +1 -0
- package/dist/node/gcp.js +34 -0
- package/dist/node/gcp.js.map +1 -0
- package/dist/node/index.d.ts +5 -0
- package/dist/node/index.d.ts.map +1 -0
- package/dist/node/index.js +12 -0
- package/dist/node/index.js.map +1 -0
- package/dist/node/naming.d.ts +4 -0
- package/dist/node/naming.d.ts.map +1 -0
- package/dist/node/naming.js +20 -0
- package/dist/node/naming.js.map +1 -0
- package/dist/node/runtime.d.ts +14 -0
- package/dist/node/runtime.d.ts.map +1 -0
- package/dist/node/runtime.js +36 -0
- package/dist/node/runtime.js.map +1 -0
- package/dist/node/targets.d.ts +8 -0
- package/dist/node/targets.d.ts.map +1 -0
- package/dist/node/targets.js +81 -0
- package/dist/node/targets.js.map +1 -0
- package/dist/orchestrator.d.ts +52 -0
- package/dist/orchestrator.d.ts.map +1 -0
- package/dist/orchestrator.js +135 -0
- package/dist/orchestrator.js.map +1 -0
- package/package.json +69 -0
- package/spec.md +38 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Agentic Trust Labs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# @agenticprimitives/ap-kms
|
|
2
|
+
|
|
3
|
+
Manifest-driven managed-KMS orchestrator. One declarative `kms.manifest.json` is the single source of
|
|
4
|
+
truth for an app's signing identities; `ap-kms apply` then does every step to get Cloud-KMS signing working:
|
|
5
|
+
|
|
6
|
+
1. **Provision** the keyring + a per-identity HSM secp256k1 signing key + per-key IAM (gcloud-free REST, via
|
|
7
|
+
`@agenticprimitives/key-custody/provision-gcp`). Idempotent.
|
|
8
|
+
2. **Derive + report** each key's EVM address (verify it before wiring).
|
|
9
|
+
3. **Resolve** each agent-naming name → its Smart Agent address (`@agenticprimitives/agent-naming`).
|
|
10
|
+
4. **Wire** the minimal runtime secrets to each deploy target via an **app-supplied secret writer** with no
|
|
11
|
+
terminal echo — `--write`. The orchestrator is provider-agnostic; concrete deploy-platform code
|
|
12
|
+
(Cloudflare/Vercel/…) lives in the app and is injected as `writeSecret` (ADR-0020).
|
|
13
|
+
|
|
14
|
+
The one human step it never does is the **owner-signed delegation leaf** (Smart Agent → KMS key), produced
|
|
15
|
+
by the content-signer ceremony. `ap-kms apply` reports per-identity whether it's bound; `ap-kms verify`
|
|
16
|
+
confirms each agent's *live* KMS delegate (derived from the key) still equals the *owner-authorized* delegate
|
|
17
|
+
stored in the deployment's bindings, and that the stored SA matches the name's on-chain resolution.
|
|
18
|
+
|
|
19
|
+
## Design
|
|
20
|
+
|
|
21
|
+
The core (`@agenticprimitives/ap-kms`) is **pure** — the provisioner, name resolver, address derivation,
|
|
22
|
+
stored-bindings reader, and secret writer are all **injected** (`KmsOrchestratorDeps`). This keeps
|
|
23
|
+
`key-custody` a leaf and the orchestration testable. The node wiring (`@agenticprimitives/ap-kms/node`)
|
|
24
|
+
assembles the provider-agnostic implementations (provisioner / derivation / resolver / bindings reader) and
|
|
25
|
+
the fs manifest loader; the **deploy-platform secret writer stays in the app** and is injected:
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import { applyKmsManifest } from '@agenticprimitives/ap-kms';
|
|
29
|
+
import { loadManifest, makeNodeDeps } from '@agenticprimitives/ap-kms/node';
|
|
30
|
+
import { writeSecret } from './my-app-secret-writers.js'; // app-owned: switches on deployment.platform
|
|
31
|
+
|
|
32
|
+
const manifest = loadManifest('kms.manifest.json');
|
|
33
|
+
await applyKmsManifest(manifest, makeNodeDeps(manifest, { writeSecret }), { write: true });
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
`deployment.platform` is an opaque tag; the app's `writeSecret(deployment, name, value)` decides how to
|
|
37
|
+
push the secret (e.g. a worker secret CLI, a hosting-provider REST API). No provider hostnames or
|
|
38
|
+
provider-specific code live in this package.
|
|
39
|
+
|
|
40
|
+
## CLI
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
ap-kms apply # provision + IAM + derive + resolve SA + REPORT (no secret writes)
|
|
44
|
+
ap-kms apply --write --writers ./w.js # also push runtime secrets via the app-supplied writer module
|
|
45
|
+
ap-kms apply --dry-run # print the plan only (no GCP mutations)
|
|
46
|
+
ap-kms verify # read-only drift check vs. stored owner-authorized delegations
|
|
47
|
+
ap-kms <cmd> --manifest path/to/kms.manifest.json
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
`--writers <module>` is dynamically imported and must export `writeSecret(deployment, name, value)` (or
|
|
51
|
+
default-export it). The naming RPC URL comes from the env var named by `manifest.naming.rpcUrlEnv` (kept out
|
|
52
|
+
of the manifest because it carries an API key).
|
package/bin/ap-kms.mjs
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// ap-kms — manifest-driven managed-KMS orchestrator CLI.
|
|
3
|
+
//
|
|
4
|
+
// ap-kms apply # provision + IAM + derive + resolve SA + REPORT (no secret writes)
|
|
5
|
+
// ap-kms apply --write --writers ./w # also push runtime secrets via the app-supplied writer module
|
|
6
|
+
// ap-kms apply --dry-run # print the plan only (no GCP mutations)
|
|
7
|
+
// ap-kms verify # read-only: live KMS delegate == stored owner-authorized delegate
|
|
8
|
+
// ap-kms <cmd> --manifest path/to/kms.manifest.json
|
|
9
|
+
//
|
|
10
|
+
// The manifest is the single source of truth. Adding a KMS-backed app = one identity/target entry + re-run.
|
|
11
|
+
//
|
|
12
|
+
// `--write` needs an app-supplied secret writer: `--writers <module>` is dynamically imported and must
|
|
13
|
+
// export `writeSecret(deployment, name, value)` (or default-export it). Concrete deploy-platform code
|
|
14
|
+
// (Cloudflare/Vercel/...) lives in the app, never in this package (ADR-0020).
|
|
15
|
+
import { applyKmsManifest, verifyKmsManifest } from '../dist/index.js';
|
|
16
|
+
import { loadManifest, makeNodeDeps } from '../dist/node/index.js';
|
|
17
|
+
|
|
18
|
+
const argv = process.argv.slice(2);
|
|
19
|
+
const cmd = argv.find((a) => !a.startsWith('--')) ?? 'apply';
|
|
20
|
+
const flag = (n) => argv.includes(`--${n}`);
|
|
21
|
+
const opt = (n) => { const i = argv.indexOf(`--${n}`); return i >= 0 ? argv[i + 1] : undefined; };
|
|
22
|
+
|
|
23
|
+
async function loadWriter(spec) {
|
|
24
|
+
if (!spec) return undefined;
|
|
25
|
+
const mod = await import(spec.startsWith('.') ? new URL(spec, `file://${process.cwd()}/`).href : spec);
|
|
26
|
+
const fn = mod.writeSecret ?? mod.default;
|
|
27
|
+
if (typeof fn !== 'function') throw new Error(`--writers module "${spec}" must export writeSecret(deployment, name, value)`);
|
|
28
|
+
return fn;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async function main() {
|
|
32
|
+
if (cmd !== 'apply' && cmd !== 'verify') {
|
|
33
|
+
console.error('usage: ap-kms <apply|verify> [--write] [--dry-run] [--writers <module>] [--manifest path]');
|
|
34
|
+
process.exit(2);
|
|
35
|
+
}
|
|
36
|
+
const manifest = loadManifest(opt('manifest'));
|
|
37
|
+
if (cmd === 'verify') {
|
|
38
|
+
const problems = await verifyKmsManifest(manifest, makeNodeDeps(manifest));
|
|
39
|
+
process.exit(problems === 0 ? 0 : 1);
|
|
40
|
+
}
|
|
41
|
+
const write = flag('write');
|
|
42
|
+
const writeSecret = write ? await loadWriter(opt('writers')) : undefined;
|
|
43
|
+
if (write && !writeSecret) {
|
|
44
|
+
console.error('ap-kms: --write requires --writers <module> exporting writeSecret(deployment, name, value) (provider code lives in the app, ADR-0020)');
|
|
45
|
+
process.exit(2);
|
|
46
|
+
}
|
|
47
|
+
await applyKmsManifest(manifest, makeNodeDeps(manifest, { writeSecret }), { write, dryRun: flag('dry-run') });
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
main().catch((e) => {
|
|
51
|
+
console.error('FATAL:', e instanceof Error ? e.message : String(e));
|
|
52
|
+
process.exit(1);
|
|
53
|
+
});
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const PACKAGE_NAME = "@agenticprimitives/ap-kms";
|
|
2
|
+
export declare const PACKAGE_STATUS: "experimental";
|
|
3
|
+
export declare const SPEC_REF = "packages/ap-kms/spec.md";
|
|
4
|
+
export { type WireSpec, type Deployment, type IdentityTarget, type Identity, type NamingConfig, type KmsManifest, keyIdFor, validateManifest, buildPlan, } from './manifest.js';
|
|
5
|
+
export { type ServiceAccountInfo, type StoredBinding, type KmsOrchestratorDeps, type ApplyOptions, applyKmsManifest, verifyKmsManifest, } from './orchestrator.js';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,YAAY,8BAA8B,CAAC;AACxD,eAAO,MAAM,cAAc,EAAG,cAAuB,CAAC;AACtD,eAAO,MAAM,QAAQ,4BAA4B,CAAC;AAElD,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,QAAQ,EACb,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,QAAQ,EACR,gBAAgB,EAChB,SAAS,GACV,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,YAAY,EACjB,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// @agenticprimitives/ap-kms — manifest-driven managed-KMS orchestrator (PURE core).
|
|
2
|
+
//
|
|
3
|
+
// The core provisions per-identity Cloud-KMS HSM signing keys, resolves each agent's Smart Agent, derives +
|
|
4
|
+
// verifies the EVM delegate address, and pushes the minimal runtime secrets to deploy targets — with the
|
|
5
|
+
// provisioner / name resolver / address derivation / secret writers all INJECTED (see the `/node` subpath
|
|
6
|
+
// for the wired node implementations + `loadManifest`, and `bin/ap-kms.mjs` for the CLI).
|
|
7
|
+
//
|
|
8
|
+
// See:
|
|
9
|
+
// - spec.md — the contract
|
|
10
|
+
// - the `@agenticprimitives/ap-kms/node` subpath — fs loader + agent-naming / key-custody / target wiring
|
|
11
|
+
export const PACKAGE_NAME = '@agenticprimitives/ap-kms';
|
|
12
|
+
export const PACKAGE_STATUS = 'experimental';
|
|
13
|
+
export const SPEC_REF = 'packages/ap-kms/spec.md';
|
|
14
|
+
export { keyIdFor, validateManifest, buildPlan, } from './manifest.js';
|
|
15
|
+
export { applyKmsManifest, verifyKmsManifest, } from './orchestrator.js';
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,EAAE;AACF,4GAA4G;AAC5G,yGAAyG;AACzG,0GAA0G;AAC1G,0FAA0F;AAC1F,EAAE;AACF,OAAO;AACP,6BAA6B;AAC7B,4GAA4G;AAE5G,MAAM,CAAC,MAAM,YAAY,GAAG,2BAA2B,CAAC;AACxD,MAAM,CAAC,MAAM,cAAc,GAAG,cAAuB,CAAC;AACtD,MAAM,CAAC,MAAM,QAAQ,GAAG,yBAAyB,CAAC;AAElD,OAAO,EAOL,QAAQ,EACR,gBAAgB,EAChB,SAAS,GACV,MAAM,eAAe,CAAC;AAEvB,OAAO,EAKL,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { type ProvisionPlan } from '@agenticprimitives/key-custody/provision-gcp';
|
|
2
|
+
export interface WireSpec {
|
|
3
|
+
/** Cloudflare: aggregate all identities sharing this secret into ONE name→keyVersion JSON map. */
|
|
4
|
+
keyMapSecret?: string;
|
|
5
|
+
/** Single-key targets (e.g. a validator): the secret holding this identity's cryptoKeyVersion path. */
|
|
6
|
+
keySecret?: string;
|
|
7
|
+
/** Secret holding the identity's resolved Smart Agent address. */
|
|
8
|
+
saSecret?: string;
|
|
9
|
+
/** Secret holding the owner-signed delegation leaf (produced by the content-signer ceremony — the one
|
|
10
|
+
* human step; this tool reports it but never fabricates it). */
|
|
11
|
+
leafSecret?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface Deployment {
|
|
14
|
+
/** Opaque deploy-platform tag (e.g. `"worker"`, `"serverless"`). The provider-specific secret writer is
|
|
15
|
+
* app-supplied (injected as `writeSecret`) and switches on this tag — concrete provider code stays in
|
|
16
|
+
* the app layer (ADR-0020); the orchestrator core never names a hosting provider. */
|
|
17
|
+
platform: string;
|
|
18
|
+
/** App directory of the deploy unit (so a provider CLI can resolve its config), if the writer needs it. */
|
|
19
|
+
dir?: string;
|
|
20
|
+
/** Worker/app name, if the writer needs it. */
|
|
21
|
+
worker?: string;
|
|
22
|
+
/** Project name or id, if the writer needs it. */
|
|
23
|
+
project?: string;
|
|
24
|
+
/** Deploy target / environment (e.g. `production`). */
|
|
25
|
+
env: string;
|
|
26
|
+
/** Any extra writer-specific config the app's `writeSecret` reads. */
|
|
27
|
+
[key: string]: unknown;
|
|
28
|
+
}
|
|
29
|
+
export interface IdentityTarget {
|
|
30
|
+
/** Key into `KmsManifest.deployments`. */
|
|
31
|
+
deployment: string;
|
|
32
|
+
wire: WireSpec;
|
|
33
|
+
}
|
|
34
|
+
export interface Identity {
|
|
35
|
+
/** Agent-naming name (e.g. `fbsb.impact`) — resolves to the identity's Smart Agent. */
|
|
36
|
+
name: string;
|
|
37
|
+
/** One signing key, wired into one or more deploy targets (e.g. a validator key that ALSO appears in an
|
|
38
|
+
* MCP's CONTENT_SIGNER_KEYS map for address lookup). */
|
|
39
|
+
targets: IdentityTarget[];
|
|
40
|
+
}
|
|
41
|
+
export interface NamingConfig {
|
|
42
|
+
/** Env var name holding the RPC URL (kept OUT of the manifest — it carries an API key). */
|
|
43
|
+
rpcUrlEnv: string;
|
|
44
|
+
chainId: number;
|
|
45
|
+
registry: string;
|
|
46
|
+
universalResolver: string;
|
|
47
|
+
}
|
|
48
|
+
export interface KmsManifest {
|
|
49
|
+
project: string;
|
|
50
|
+
location: string;
|
|
51
|
+
keyRing: string;
|
|
52
|
+
/** Path to the admin/runtime service-account JSON (used to provision AND written as the runtime secret). */
|
|
53
|
+
runtimeServiceAccountFile: string;
|
|
54
|
+
/** The secret name each runtime expects the SA JSON under (written canonical single-line, no echo). */
|
|
55
|
+
saSecretName: string;
|
|
56
|
+
naming: NamingConfig;
|
|
57
|
+
/** Base URL exposing the stored content-signer bindings (POST /tools/list_content_signers) — used by
|
|
58
|
+
* `verify` to compare each agent's live KMS delegate against its stored, owner-authorized delegate. */
|
|
59
|
+
bindingsUrl?: string;
|
|
60
|
+
deployments: Record<string, Deployment>;
|
|
61
|
+
identities: Identity[];
|
|
62
|
+
}
|
|
63
|
+
/** Map a (possibly dotted) identity name → the GCP cryptoKey id used by the provisioner (B2). */
|
|
64
|
+
export declare const keyIdFor: (name: string) => string;
|
|
65
|
+
/** Fail-closed structural validation: every identity target must point at a declared deployment, and each
|
|
66
|
+
* declared deployment must carry the fields its platform needs. Throws on the first problem. */
|
|
67
|
+
export declare function validateManifest(m: KmsManifest): KmsManifest;
|
|
68
|
+
/** The upstream provisioning plan derived from the manifest + admin SA (dotted identity names ok — B2;
|
|
69
|
+
* defaults: HSM, asymmetric-signing, per-key `roles/cloudkms.signerVerifier` — B3). */
|
|
70
|
+
export declare function buildPlan(m: KmsManifest, sa: {
|
|
71
|
+
project_id: string;
|
|
72
|
+
client_email: string;
|
|
73
|
+
}): ProvisionPlan;
|
|
74
|
+
//# sourceMappingURL=manifest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAQA,OAAO,EAAiB,KAAK,aAAa,EAAE,MAAM,8CAA8C,CAAC;AAEj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AAC,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACxC,UAAU,EAAE,QAAQ,EAAE,CAAC;CACxB;AAED,iGAAiG;AACjG,eAAO,MAAM,QAAQ,SAAU,MAAM,KAAG,MAA6B,CAAC;AAEtE;iGACiG;AACjG,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,WAAW,GAAG,WAAW,CAgB5D;AAED;wFACwF;AACxF,wBAAgB,SAAS,CAAC,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,GAAG,aAAa,CAQzG"}
|
package/dist/manifest.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// Manifest types + pure validation/plan helpers for the managed-KMS orchestrator.
|
|
2
|
+
//
|
|
3
|
+
// One declarative manifest is the single source of truth: which signing identities exist, where each
|
|
4
|
+
// runtime reads its KMS config, and how to reach GCP + agent-naming. Adding a KMS-backed app = one
|
|
5
|
+
// identity/target entry + a re-run of `ap-kms apply`.
|
|
6
|
+
//
|
|
7
|
+
// This module is PURE (no fs / network / child_process) so the orchestrator core stays portable and
|
|
8
|
+
// testable. The fs loader + the node clients live in the `@agenticprimitives/ap-kms/node` subpath.
|
|
9
|
+
import { sanitizeKeyId } from '@agenticprimitives/key-custody/provision-gcp';
|
|
10
|
+
/** Map a (possibly dotted) identity name → the GCP cryptoKey id used by the provisioner (B2). */
|
|
11
|
+
export const keyIdFor = (name) => sanitizeKeyId(name);
|
|
12
|
+
/** Fail-closed structural validation: every identity target must point at a declared deployment, and each
|
|
13
|
+
* declared deployment must carry the fields its platform needs. Throws on the first problem. */
|
|
14
|
+
export function validateManifest(m) {
|
|
15
|
+
if (!m.project || !m.location || !m.keyRing)
|
|
16
|
+
throw new Error('manifest: project, location and keyRing are required');
|
|
17
|
+
if (!m.saSecretName)
|
|
18
|
+
throw new Error('manifest: saSecretName is required');
|
|
19
|
+
for (const [name, dep] of Object.entries(m.deployments)) {
|
|
20
|
+
// Provider-agnostic: require only platform + env. Provider-specific field requirements (e.g. which of
|
|
21
|
+
// dir/worker/project a given writer needs) are enforced by the app-supplied `writeSecret` (ADR-0020).
|
|
22
|
+
if (!dep.platform)
|
|
23
|
+
throw new Error(`deployment "${name}" missing "platform"`);
|
|
24
|
+
if (!dep.env)
|
|
25
|
+
throw new Error(`deployment "${name}" missing "env"`);
|
|
26
|
+
}
|
|
27
|
+
for (const id of m.identities) {
|
|
28
|
+
if (!id.name)
|
|
29
|
+
throw new Error('manifest: identity missing "name"');
|
|
30
|
+
for (const t of id.targets) {
|
|
31
|
+
if (!m.deployments[t.deployment])
|
|
32
|
+
throw new Error(`identity "${id.name}" → unknown deployment "${t.deployment}"`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return m;
|
|
36
|
+
}
|
|
37
|
+
/** The upstream provisioning plan derived from the manifest + admin SA (dotted identity names ok — B2;
|
|
38
|
+
* defaults: HSM, asymmetric-signing, per-key `roles/cloudkms.signerVerifier` — B3). */
|
|
39
|
+
export function buildPlan(m, sa) {
|
|
40
|
+
return {
|
|
41
|
+
project: sa.project_id,
|
|
42
|
+
location: m.location,
|
|
43
|
+
keyRing: m.keyRing,
|
|
44
|
+
identities: m.identities.map((i) => i.name),
|
|
45
|
+
runtimeServiceAccount: sa.client_email,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=manifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.js","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,EAAE;AACF,qGAAqG;AACrG,mGAAmG;AACnG,sDAAsD;AACtD,EAAE;AACF,oGAAoG;AACpG,mGAAmG;AACnG,OAAO,EAAE,aAAa,EAAsB,MAAM,8CAA8C,CAAC;AAqEjG,iGAAiG;AACjG,MAAM,CAAC,M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OAAO,EAAE,EAAE,CAAC,UAAU;QACtB,QAAQ,EAAE,CAAC,CAAC,QAAQ;QACpB,OAAO,EAAE,CAAC,CAAC,OAAO;QAClB,UAAU,EAAE,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;QAC3C,qBAAqB,EAAE,EAAE,CAAC,YAAY;KACvC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bindings.d.ts","sourceRoot":"","sources":["../../src/node/bindings.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CAcrG"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export function makeReadStoredBindings(bindingsUrl) {
|
|
2
|
+
return async () => {
|
|
3
|
+
const out = new Map();
|
|
4
|
+
const res = await fetch(`${bindingsUrl}/tools/list_content_signers`, {
|
|
5
|
+
method: 'POST',
|
|
6
|
+
headers: { 'content-type': 'application/json' },
|
|
7
|
+
body: '{}',
|
|
8
|
+
});
|
|
9
|
+
const j = (await res.json());
|
|
10
|
+
for (const r of j.rows ?? j.signers ?? []) {
|
|
11
|
+
if (r.issuer_name)
|
|
12
|
+
out.set(r.issuer_name, { issuer_sa: r.issuer_sa, delegate_key: r.delegate_key });
|
|
13
|
+
}
|
|
14
|
+
return out;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=bindings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bindings.js","sourceRoot":"","sources":["../../src/node/bindings.ts"],"names":[],"mappings":"AAKA,MAAM,UAAU,sBAAsB,CAAC,WAAmB;IACxD,OAAO,KAAK,IAAI,EAAE;QAChB,MAAM,GAAG,GAAG,IAAI,GAAG,EAAyB,CAAC;QAC7C,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,WAAW,6BAA6B,EAAE;YACnE,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;YAC/C,IAAI,EAAE,IAAI;SACX,CAAC,CAAC;QACH,MAAM,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAsF,CAAC;QAClH,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,OAAO,IAAI,EAAE,EAAE,CAAC;YAC1C,IAAI,CAAC,CAAC,WAAW;gBAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,WAAW,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC,SAAU,EAAE,YAAY,EAAE,CAAC,CAAC,YAAa,EAAE,CAAC,CAAC;QACxG,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type ProvisionPlan, type ProvisionResult } from '@agenticprimitives/key-custody/provision-gcp';
|
|
2
|
+
import type { Address } from '@agenticprimitives/types';
|
|
3
|
+
import type { ServiceAccountInfo } from '../orchestrator.js';
|
|
4
|
+
/** Load + parse the admin/runtime service account JSON file. Throws if it has no project_id. */
|
|
5
|
+
export declare function loadServiceAccount(file: string): ServiceAccountInfo;
|
|
6
|
+
/** Build the injected `provision` dep: run the plan through the upstream gcloud-free REST executor. */
|
|
7
|
+
export declare function makeProvision(saRaw: string): (plan: ProvisionPlan) => Promise<ProvisionResult>;
|
|
8
|
+
/** Build the injected `deriveAddress` dep: derive a KMS key version's EVM address from its SPKI public key
|
|
9
|
+
* (read-only; resolves to null if the key is absent / not ENABLED). */
|
|
10
|
+
export declare function makeDeriveAddress(saRaw: string): (keyVersionName: string) => Promise<Address | null>;
|
|
11
|
+
//# sourceMappingURL=gcp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gcp.d.ts","sourceRoot":"","sources":["../../src/node/gcp.ts"],"names":[],"mappings":"AAKA,OAAO,EAAkD,KAAK,aAAa,EAAE,KAAK,eAAe,EAAE,MAAM,8CAA8C,CAAC;AACxJ,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7D,gGAAgG;AAChG,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,CAMnE;AAED,uGAAuG;AACvG,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,CAAC,IAAI,EAAE,aAAa,KAAK,OAAO,CAAC,eAAe,CAAC,CAE9F;AAED;wEACwE;AACxE,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,CAAC,cAAc,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CASpG"}
|
package/dist/node/gcp.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// GCP wiring (node) for the orchestrator: load the admin SA, build the gcloud-free provisioner, and do the
|
|
2
|
+
// read-only address derivation that `verify` needs. Provisioning itself (keyring/keys + per-key IAM) lives
|
|
3
|
+
// upstream in @agenticprimitives/key-custody/provision-gcp; this only composes it.
|
|
4
|
+
import { readFileSync } from 'node:fs';
|
|
5
|
+
import { addressFromSpkiPem, createGcpKmsTransport, parseServiceAccountJson } from '@agenticprimitives/key-custody/kms-core';
|
|
6
|
+
import { createGcpRestStepExecutor, executeGcpProvision } from '@agenticprimitives/key-custody/provision-gcp';
|
|
7
|
+
/** Load + parse the admin/runtime service account JSON file. Throws if it has no project_id. */
|
|
8
|
+
export function loadServiceAccount(file) {
|
|
9
|
+
const raw = readFileSync(file, 'utf8').trim();
|
|
10
|
+
const sa = parseServiceAccountJson(raw);
|
|
11
|
+
if (!sa.client_email)
|
|
12
|
+
throw new Error(`service account ${file} missing client_email`);
|
|
13
|
+
if (!sa.project_id)
|
|
14
|
+
throw new Error(`service account ${file} missing project_id`);
|
|
15
|
+
return { raw, client_email: sa.client_email, project_id: sa.project_id };
|
|
16
|
+
}
|
|
17
|
+
/** Build the injected `provision` dep: run the plan through the upstream gcloud-free REST executor. */
|
|
18
|
+
export function makeProvision(saRaw) {
|
|
19
|
+
return (plan) => executeGcpProvision(plan, createGcpRestStepExecutor({ serviceAccountJson: saRaw }));
|
|
20
|
+
}
|
|
21
|
+
/** Build the injected `deriveAddress` dep: derive a KMS key version's EVM address from its SPKI public key
|
|
22
|
+
* (read-only; resolves to null if the key is absent / not ENABLED). */
|
|
23
|
+
export function makeDeriveAddress(saRaw) {
|
|
24
|
+
const transport = createGcpKmsTransport(parseServiceAccountJson(saRaw));
|
|
25
|
+
return async (keyVersionName) => {
|
|
26
|
+
try {
|
|
27
|
+
return addressFromSpkiPem(await transport.getPublicKeyPem(keyVersionName));
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=gcp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gcp.js","sourceRoot":"","sources":["../../src/node/gcp.ts"],"names":[],"mappings":"AAAA,2GAA2G;AAC3G,2GAA2G;AAC3G,mFAAmF;AACnF,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAC7H,OAAO,EAAE,yBAAyB,EAAE,mBAAmB,EAA4C,MAAM,8CAA8C,CAAC;AAIxJ,gGAAgG;AAChG,MAAM,UAAU,kBAAkB,CAAC,IAAY;IAC7C,MAAM,GAAG,GAAG,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;IAC9C,MAAM,EAAE,GAAG,uBAAuB,CAAC,GAAG,CAAkD,CAAC;IACzF,IAAI,CAAC,EAAE,CAAC,YAAY;QAAE,MAAM,IAAI,KAAK,CAAC,mBAAmB,IAAI,uBAAuB,CAAC,CAAC;IACtF,IAAI,CAAC,EAAE,CAAC,UAAU;QAAE,MAAM,IAAI,KAAK,CAAC,mBAAmB,IAAI,qBAAqB,CAAC,CAAC;IAClF,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,EAAE,CAAC,YAAY,EAAE,UAAU,EAAE,EAAE,CAAC,UAAU,EAAE,CAAC;AAC3E,CAAC;AAED,uGAAuG;AACvG,MAAM,UAAU,aAAa,CAAC,KAAa;IACzC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,mBAAmB,CAAC,IAAI,EAAE,yBAAyB,CAAC,EAAE,kBAAkB,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;AACvG,CAAC;AAED;wEACwE;AACxE,MAAM,UAAU,iBAAiB,CAAC,KAAa;IAC7C,MAAM,SAAS,GAAG,qBAAqB,CAAC,uBAAuB,CAAC,KAAK,CAAC,CAAC,CAAC;IACxE,OAAO,KAAK,EAAE,cAAc,EAAE,EAAE;QAC9B,IAAI,CAAC;YACH,OAAO,kBAAkB,CAAC,MAAM,SAAS,CAAC,eAAe,CAAC,cAAc,CAAC,CAAY,CAAC;QACxF,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { loadManifest, makeNodeDeps } from './runtime.js';
|
|
2
|
+
export { loadServiceAccount, makeProvision, makeDeriveAddress } from './gcp.js';
|
|
3
|
+
export { makeResolveName } from './naming.js';
|
|
4
|
+
export { makeReadStoredBindings } from './bindings.js';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// @agenticprimitives/ap-kms/node — provider-agnostic node wiring for the orchestrator core: fs manifest
|
|
2
|
+
// loader + the injected deps (key-custody provisioner / address derivation, agent-naming resolver,
|
|
3
|
+
// stored-bindings reader). Import the pure orchestrator (applyKmsManifest / verifyKmsManifest) from
|
|
4
|
+
// `@agenticprimitives/ap-kms` and drive it with `makeNodeDeps(loadManifest(), { writeSecret })`.
|
|
5
|
+
//
|
|
6
|
+
// NOTE: deploy-platform secret WRITERS are intentionally NOT shipped here — concrete provider code lives in
|
|
7
|
+
// the app layer (ADR-0020). The app passes its own `writeSecret(deployment, name, value)` into `makeNodeDeps`.
|
|
8
|
+
export { loadManifest, makeNodeDeps } from './runtime.js';
|
|
9
|
+
export { loadServiceAccount, makeProvision, makeDeriveAddress } from './gcp.js';
|
|
10
|
+
export { makeResolveName } from './naming.js';
|
|
11
|
+
export { makeReadStoredBindings } from './bindings.js';
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAAA,wGAAwG;AACxG,mGAAmG;AACnG,oGAAoG;AACpG,iGAAiG;AACjG,EAAE;AACF,4GAA4G;AAC5G,+GAA+G;AAC/G,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"naming.d.ts","sourceRoot":"","sources":["../../src/node/naming.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD,wBAAgB,eAAe,CAAC,MAAM,EAAE,YAAY,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAa/F"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// agent-naming wiring (node): build the injected `resolveName` dep that resolves an agent name → its Smart
|
|
2
|
+
// Agent address via the on-chain universal resolver. The RPC URL is read from the env var named by the
|
|
3
|
+
// manifest (kept out of the manifest because it carries an API key); if unset, resolution yields null and
|
|
4
|
+
// the orchestrator skips writing SA-dependent secrets (fail-soft, reported).
|
|
5
|
+
import { AgentNamingClient } from '@agenticprimitives/agent-naming';
|
|
6
|
+
export function makeResolveName(naming) {
|
|
7
|
+
const rpcUrl = process.env[naming.rpcUrlEnv];
|
|
8
|
+
if (!rpcUrl) {
|
|
9
|
+
console.warn(`! ${naming.rpcUrlEnv} not set — name→SA resolution disabled (SA-dependent secrets will be skipped)`);
|
|
10
|
+
return async () => null;
|
|
11
|
+
}
|
|
12
|
+
const client = new AgentNamingClient({
|
|
13
|
+
rpcUrl,
|
|
14
|
+
chainId: naming.chainId,
|
|
15
|
+
registry: naming.registry,
|
|
16
|
+
universalResolver: naming.universalResolver,
|
|
17
|
+
});
|
|
18
|
+
return (name) => client.resolveName(name);
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=naming.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"naming.js","sourceRoot":"","sources":["../../src/node/naming.ts"],"names":[],"mappings":"AAAA,2GAA2G;AAC3G,uGAAuG;AACvG,0GAA0G;AAC1G,6EAA6E;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAIpE,MAAM,UAAU,eAAe,CAAC,MAAoB;IAClD,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IAC7C,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,CAAC,IAAI,CAAC,KAAK,MAAM,CAAC,SAAS,+EAA+E,CAAC,CAAC;QACnH,OAAO,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC;IAC1B,CAAC;IACD,MAAM,MAAM,GAAG,IAAI,iBAAiB,CAAC;QACnC,MAAM;QACN,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,QAAQ,EAAE,MAAM,CAAC,QAAmB;QACpC,iBAAiB,EAAE,MAAM,CAAC,iBAA4B;KACvD,CAAC,CAAC;IACH,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;AAC5C,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type Deployment, type KmsManifest } from '../manifest.js';
|
|
2
|
+
import type { KmsOrchestratorDeps } from '../orchestrator.js';
|
|
3
|
+
/** Read + structurally validate the manifest from disk (expanding `~` in the SA file path). */
|
|
4
|
+
export declare function loadManifest(path?: string): KmsManifest;
|
|
5
|
+
export interface NodeDepsOptions {
|
|
6
|
+
/** App-supplied deploy-platform secret writer (provider-specific code stays in the app — ADR-0020).
|
|
7
|
+
* Required only for `applyKmsManifest(..., { write: true })`; without it the write step throws. */
|
|
8
|
+
writeSecret?: (deployment: Deployment, name: string, value: string) => Promise<void>;
|
|
9
|
+
log?: (msg: string) => void;
|
|
10
|
+
}
|
|
11
|
+
/** Assemble the injected deps for a manifest: load the admin SA, then wire provisioning, name resolution,
|
|
12
|
+
* address derivation, and the stored-bindings reader. The secret writer is injected by the caller. */
|
|
13
|
+
export declare function makeNodeDeps(m: KmsManifest, opts?: NodeDepsOptions): KmsOrchestratorDeps;
|
|
14
|
+
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/node/runtime.ts"],"names":[],"mappings":"AAMA,OAAO,EAAoB,KAAK,UAAU,EAAE,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACrF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAO9D,+FAA+F;AAC/F,wBAAgB,YAAY,CAAC,IAAI,SAAsB,GAAG,WAAW,CAKpE;AAED,MAAM,WAAW,eAAe;IAC9B;wGACoG;IACpG,WAAW,CAAC,EAAE,CAAC,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACrF,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7B;AAED;uGACuG;AACvG,wBAAgB,YAAY,CAAC,CAAC,EAAE,WAAW,EAAE,IAAI,GAAE,eAAoB,GAAG,mBAAmB,CAe5F"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// Node runtime wiring: load the manifest from disk and assemble the (provider-agnostic) `KmsOrchestratorDeps`
|
|
2
|
+
// — provisioner, name resolver, address derivation, stored-bindings reader — for the pure core to drive.
|
|
3
|
+
// The deploy-platform secret WRITER is app-supplied (ADR-0020): pass it as `opts.writeSecret`.
|
|
4
|
+
import { readFileSync } from 'node:fs';
|
|
5
|
+
import { homedir } from 'node:os';
|
|
6
|
+
import { isAbsolute, join } from 'node:path';
|
|
7
|
+
import { validateManifest } from '../manifest.js';
|
|
8
|
+
import { makeReadStoredBindings } from './bindings.js';
|
|
9
|
+
import { loadServiceAccount, makeDeriveAddress, makeProvision } from './gcp.js';
|
|
10
|
+
import { makeResolveName } from './naming.js';
|
|
11
|
+
const expandHome = (p) => (p.startsWith('~') ? join(homedir(), p.slice(1)) : p);
|
|
12
|
+
/** Read + structurally validate the manifest from disk (expanding `~` in the SA file path). */
|
|
13
|
+
export function loadManifest(path = 'kms.manifest.json') {
|
|
14
|
+
const abs = isAbsolute(path) ? path : join(process.cwd(), path);
|
|
15
|
+
const m = validateManifest(JSON.parse(readFileSync(abs, 'utf8')));
|
|
16
|
+
m.runtimeServiceAccountFile = expandHome(m.runtimeServiceAccountFile);
|
|
17
|
+
return m;
|
|
18
|
+
}
|
|
19
|
+
/** Assemble the injected deps for a manifest: load the admin SA, then wire provisioning, name resolution,
|
|
20
|
+
* address derivation, and the stored-bindings reader. The secret writer is injected by the caller. */
|
|
21
|
+
export function makeNodeDeps(m, opts = {}) {
|
|
22
|
+
const serviceAccount = loadServiceAccount(m.runtimeServiceAccountFile);
|
|
23
|
+
return {
|
|
24
|
+
serviceAccount,
|
|
25
|
+
provision: makeProvision(serviceAccount.raw),
|
|
26
|
+
resolveName: makeResolveName(m.naming),
|
|
27
|
+
deriveAddress: makeDeriveAddress(serviceAccount.raw),
|
|
28
|
+
readStoredBindings: m.bindingsUrl ? makeReadStoredBindings(m.bindingsUrl) : undefined,
|
|
29
|
+
writeSecret: opts.writeSecret ??
|
|
30
|
+
(() => {
|
|
31
|
+
throw new Error('ap-kms: no writeSecret injected — pass an app-supplied secret writer to makeNodeDeps (provider code lives in the app, ADR-0020)');
|
|
32
|
+
}),
|
|
33
|
+
log: opts.log,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../src/node/runtime.ts"],"names":[],"mappings":"AAAA,8GAA8G;AAC9G,yGAAyG;AACzG,+FAA+F;AAC/F,OAAO,E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AC,cAAc,CAAC,GAAG,CAAC;QAC5C,WAAW,EAAE,eAAe,CAAC,CAAC,CAAC,MAAM,CAAC;QACtC,aAAa,EAAE,iBAAiB,CAAC,cAAc,CAAC,GAAG,CAAC;QACpD,kBAAkB,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS;QACrF,WAAW,EACT,IAAI,CAAC,WAAW;YAChB,CAAC,GAAG,EAAE;gBACJ,MAAM,IAAI,KAAK,CAAC,iIAAiI,CAAC,CAAC;YACrJ,CAAC,CAAC;QACJ,GAAG,EAAE,IAAI,CAAC,GAAG;KACd,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Deployment } from '../manifest.js';
|
|
2
|
+
/** Pipe a secret value into `wrangler secret put <name> --env <env>` from the worker's dir (no echo). */
|
|
3
|
+
export declare function writeCloudflareSecret(dir: string, env: string, name: string, value: string): Promise<void>;
|
|
4
|
+
/** Upsert an encrypted env var on a Vercel project for the given target (delete any existing, then create). */
|
|
5
|
+
export declare function writeVercelSecret(project: string, target: string, name: string, value: string): Promise<void>;
|
|
6
|
+
/** Dispatch a secret write to whichever platform the deployment declares (used to wire `deps.writeSecret`). */
|
|
7
|
+
export declare function writeSecretToTarget(dep: Deployment, name: string, value: string): Promise<void>;
|
|
8
|
+
//# sourceMappingURL=targets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"targets.d.ts","sourceRoot":"","sources":["../../src/node/targets.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD,yGAAyG;AACzG,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAU1G;AA+BD,+GAA+G;AAC/G,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAWnH;AAED,+GAA+G;AAC/G,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAOrG"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// Deploy-target secret writers (node) — write a named secret to Cloudflare or Vercel with NO terminal echo
|
|
2
|
+
// and no copy/paste. Cloudflare: pipe into `wrangler secret put`. Vercel: REST API (`vercel env add` from
|
|
3
|
+
// stdin is unreliable — observed storing empty). Values are passed in-memory; never logged.
|
|
4
|
+
//
|
|
5
|
+
// A deploy-platform secret writer is repo/ops tooling, not a generic trust primitive (ADR-0021) — but the
|
|
6
|
+
// managed-KMS orchestrator that COMPOSES these writers is a published external concern (ADR-0037), so they
|
|
7
|
+
// ship here behind the `/node` subpath and are injected into the pure core via `writeSecret`.
|
|
8
|
+
import { spawn } from 'node:child_process';
|
|
9
|
+
import { readFileSync } from 'node:fs';
|
|
10
|
+
import { homedir } from 'node:os';
|
|
11
|
+
import { join } from 'node:path';
|
|
12
|
+
/** Pipe a secret value into `wrangler secret put <name> --env <env>` from the worker's dir (no echo). */
|
|
13
|
+
export function writeCloudflareSecret(dir, env, name, value) {
|
|
14
|
+
return new Promise((resolve, reject) => {
|
|
15
|
+
const child = spawn('npx', ['wrangler', 'secret', 'put', name, '--env', env], { cwd: dir, stdio: ['pipe', 'pipe', 'pipe'] });
|
|
16
|
+
let err = '';
|
|
17
|
+
child.stderr.on('data', (d) => (err += d));
|
|
18
|
+
child.on('error', reject);
|
|
19
|
+
child.on('close', (code) => (code === 0 ? resolve() : reject(new Error(`wrangler secret put ${name} failed (${code}): ${err.slice(-300)}`))));
|
|
20
|
+
child.stdin.write(value.endsWith('\n') ? value : value + '\n');
|
|
21
|
+
child.stdin.end();
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
// ── Vercel REST ──
|
|
25
|
+
/** Resolve the Vercel API token: `VERCEL_TOKEN` env first, then the CLI's stored token. */
|
|
26
|
+
function vercelToken() {
|
|
27
|
+
if (process.env.VERCEL_TOKEN)
|
|
28
|
+
return process.env.VERCEL_TOKEN;
|
|
29
|
+
try {
|
|
30
|
+
const j = JSON.parse(readFileSync(join(homedir(), '.local/share/com.vercel.cli/auth.json'), 'utf8'));
|
|
31
|
+
if (j.token)
|
|
32
|
+
return j.token;
|
|
33
|
+
}
|
|
34
|
+
catch { /* fall through */ }
|
|
35
|
+
throw new Error('no Vercel token — set VERCEL_TOKEN or run `vercel login`');
|
|
36
|
+
}
|
|
37
|
+
async function vercelProjectId(token, project) {
|
|
38
|
+
const h = { authorization: `Bearer ${token}` };
|
|
39
|
+
const teamId = process.env.VERCEL_TEAM_ID;
|
|
40
|
+
if (teamId) {
|
|
41
|
+
const r = await fetch(`https://api.vercel.com/v9/projects/${project}?teamId=${teamId}`, { headers: h });
|
|
42
|
+
if (r.ok)
|
|
43
|
+
return { id: (await r.json()).id, teamId };
|
|
44
|
+
}
|
|
45
|
+
const r = await fetch(`https://api.vercel.com/v9/projects/${project}`, { headers: h });
|
|
46
|
+
if (r.ok)
|
|
47
|
+
return { id: (await r.json()).id, teamId: null };
|
|
48
|
+
const teams = (await (await fetch('https://api.vercel.com/v2/teams', { headers: h })).json());
|
|
49
|
+
for (const t of teams.teams ?? []) {
|
|
50
|
+
const rr = await fetch(`https://api.vercel.com/v9/projects/${project}?teamId=${t.id}`, { headers: h });
|
|
51
|
+
if (rr.ok)
|
|
52
|
+
return { id: (await rr.json()).id, teamId: t.id };
|
|
53
|
+
}
|
|
54
|
+
throw new Error(`Vercel project not found: ${project}`);
|
|
55
|
+
}
|
|
56
|
+
/** Upsert an encrypted env var on a Vercel project for the given target (delete any existing, then create). */
|
|
57
|
+
export async function writeVercelSecret(project, target, name, value) {
|
|
58
|
+
const token = vercelToken();
|
|
59
|
+
const { id, teamId } = await vercelProjectId(token, project);
|
|
60
|
+
const q = teamId ? `?teamId=${teamId}` : '';
|
|
61
|
+
const h = { authorization: `Bearer ${token}`, 'content-type': 'application/json' };
|
|
62
|
+
const list = (await (await fetch(`https://api.vercel.com/v9/projects/${id}/env${q}`, { headers: h })).json());
|
|
63
|
+
for (const e of (list.envs ?? []).filter((e) => e.key === name && (e.target ?? []).includes(target))) {
|
|
64
|
+
await fetch(`https://api.vercel.com/v9/projects/${id}/env/${e.id}${q}`, { method: 'DELETE', headers: h });
|
|
65
|
+
}
|
|
66
|
+
const c = await fetch(`https://api.vercel.com/v10/projects/${id}/env${q}`, { method: 'POST', headers: h, body: JSON.stringify({ key: name, value, type: 'encrypted', target: [target] }) });
|
|
67
|
+
if (!c.ok)
|
|
68
|
+
throw new Error(`Vercel env create ${name} failed: ${c.status} ${(await c.text()).slice(0, 200)}`);
|
|
69
|
+
}
|
|
70
|
+
/** Dispatch a secret write to whichever platform the deployment declares (used to wire `deps.writeSecret`). */
|
|
71
|
+
export async function writeSecretToTarget(dep, name, value) {
|
|
72
|
+
if (dep.platform === 'cloudflare') {
|
|
73
|
+
if (!dep.dir)
|
|
74
|
+
throw new Error('cloudflare deployment missing "dir"');
|
|
75
|
+
return writeCloudflareSecret(dep.dir, dep.env, name, value);
|
|
76
|
+
}
|
|
77
|
+
if (!dep.project)
|
|
78
|
+
throw new Error('vercel deployment missing "project"');
|
|
79
|
+
return writeVercelSecret(dep.project, dep.env, name, value);
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=targets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"targets.js","sourceRoot":"","sources":["../../src/node/targets.ts"],"names":[],"mappings":"AAAA,2GAA2G;AAC3G,0GAA0G;AAC1G,4FAA4F;AAC5F,EAAE;AACF,0GAA0G;A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AG;YAAE,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;QACrE,OAAO,qBAAqB,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IAC9D,CAAC;IACD,IAAI,CAAC,GAAG,CAAC,OAAO;QAAE,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACzE,OAAO,iBAAiB,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;AAC9D,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { type ProvisionPlan, type ProvisionResult } from '@agenticprimitives/key-custody/provision-gcp';
|
|
2
|
+
import type { Address } from '@agenticprimitives/types';
|
|
3
|
+
import { type Deployment, type Identity, type KmsManifest } from './manifest.js';
|
|
4
|
+
/** The admin/runtime service account, already loaded + parsed (the node subpath reads it from disk). */
|
|
5
|
+
export interface ServiceAccountInfo {
|
|
6
|
+
/** Canonical single-line JSON — passed to the provisioner AND written as the runtime SA secret. */
|
|
7
|
+
raw: string;
|
|
8
|
+
client_email: string;
|
|
9
|
+
project_id: string;
|
|
10
|
+
}
|
|
11
|
+
/** A stored, owner-authorized binding for an identity (from the bindings endpoint), used by `verify`. */
|
|
12
|
+
export interface StoredBinding {
|
|
13
|
+
issuer_sa: string;
|
|
14
|
+
delegate_key: string;
|
|
15
|
+
}
|
|
16
|
+
/** Everything the orchestrator touches the outside world through. Injected — see `/node` for the wiring. */
|
|
17
|
+
export interface KmsOrchestratorDeps {
|
|
18
|
+
serviceAccount: ServiceAccountInfo;
|
|
19
|
+
/** Provision the keyring + per-identity HSM keys + per-key IAM, and derive each EVM address (idempotent). */
|
|
20
|
+
provision(plan: ProvisionPlan): Promise<ProvisionResult>;
|
|
21
|
+
/** Resolve an agent-naming name → its Smart Agent address (null if unresolvable). */
|
|
22
|
+
resolveName(name: string): Promise<Address | null>;
|
|
23
|
+
/** Read-only: derive a KMS key version's EVM address from its public key (null if absent). */
|
|
24
|
+
deriveAddress(keyVersionName: string): Promise<Address | null>;
|
|
25
|
+
/** Read the stored, owner-authorized bindings (issuer SA + delegate key) keyed by identity name. */
|
|
26
|
+
readStoredBindings?(): Promise<Map<string, StoredBinding>>;
|
|
27
|
+
/** Write a named secret to a deploy target with no echo. */
|
|
28
|
+
writeSecret(deployment: Deployment, name: string, value: string): Promise<void>;
|
|
29
|
+
/** Optional progress sink (defaults to console.log). */
|
|
30
|
+
log?: (msg: string) => void;
|
|
31
|
+
}
|
|
32
|
+
export interface ApplyOptions {
|
|
33
|
+
/** Push the runtime secrets to the deploy targets. Without it, apply provisions + reports only. */
|
|
34
|
+
write?: boolean;
|
|
35
|
+
/** Print the plan and return WITHOUT mutating GCP. */
|
|
36
|
+
dryRun?: boolean;
|
|
37
|
+
}
|
|
38
|
+
interface Resolved {
|
|
39
|
+
name: string;
|
|
40
|
+
targets: Identity['targets'];
|
|
41
|
+
keyVersionName: string;
|
|
42
|
+
address: Address;
|
|
43
|
+
sa: Address | null;
|
|
44
|
+
}
|
|
45
|
+
/** Provision + (optionally) wire every identity in the manifest. Returns the resolved per-identity state. */
|
|
46
|
+
export declare function applyKmsManifest(manifest: KmsManifest, deps: KmsOrchestratorDeps, opts?: ApplyOptions): Promise<Resolved[]>;
|
|
47
|
+
/** Read-only verification that each agent is still hooked to its own KMS key: the LIVE KMS delegate (derived
|
|
48
|
+
* from the key's public key) must equal the owner-AUTHORIZED delegate stored in the bindings, and the stored
|
|
49
|
+
* SA must equal the name's on-chain resolution. Returns the count of drifted/unbound identities. */
|
|
50
|
+
export declare function verifyKmsManifest(manifest: KmsManifest, deps: KmsOrchestratorDeps): Promise<number>;
|
|
51
|
+
export {};
|
|
52
|
+
//# sourceMappingURL=orchestrator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orchestrator.d.ts","sourceRoot":"","sources":["../src/orchestr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,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,sDAAsD;IACtD,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,UAAU,QAAQ;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC;IAC7B,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,EAAE,EAAE,OAAO,GAAG,IAAI,CAAC;CACpB;AAqBD,6GAA6G;AAC7G,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,WAAW,EACrB,IAAI,EAAE,mBAAmB,EACzB,IAAI,GAAE,YAAiB,GACtB,OAAO,CAAC,QAAQ,EAAE,CAAC,CAkErB;AAED;;qGAEqG;AACrG,wBAAsB,iBAAiB,CAAC,QAAQ,EAAE,WAAW,EAAE,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC,CA2BzG"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
// ap-kms orchestrator core — manifest-driven KMS apply/verify. PURE of fs/network/child_process: the
|
|
2
|
+
// provisioner (key-custody/provision-gcp), the name→SA resolver (agent-naming), the read-only address
|
|
3
|
+
// derivation (key-custody/kms-core), the stored-bindings reader, and the deploy-target secret writers are
|
|
4
|
+
// all INJECTED (the `@agenticprimitives/ap-kms/node` subpath wires the real implementations). This keeps
|
|
5
|
+
// key-custody a leaf and the orchestrator testable.
|
|
6
|
+
//
|
|
7
|
+
// Once the smart agents are configured, `applyKmsManifest` runs every step to get Cloud-KMS signing working
|
|
8
|
+
// for each app: provision the HSM key + per-key IAM, derive + verify the EVM address, resolve the agent SA,
|
|
9
|
+
// and (with `write`) push the minimal runtime secrets to each deploy target with no echo. Idempotent.
|
|
10
|
+
//
|
|
11
|
+
// The owner-signed delegation leaf (SA → KMS key) is the ONE human step — produced by the content-signer
|
|
12
|
+
// ceremony. This tool REPORTS per-identity whether it's bound; it never fabricates authorization.
|
|
13
|
+
import { keyVersionName } from '@agenticprimitives/key-custody/provision-gcp';
|
|
14
|
+
import { buildPlan, keyIdFor, validateManifest } from './manifest.js';
|
|
15
|
+
const lower = (s) => s.toLowerCase();
|
|
16
|
+
async function resolveSAs(deps, names, log) {
|
|
17
|
+
const out = new Map();
|
|
18
|
+
for (const n of names) {
|
|
19
|
+
try {
|
|
20
|
+
out.set(n, await deps.resolveName(n));
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
out.set(n, null);
|
|
24
|
+
log(` ! ${n}: name resolution failed`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return out;
|
|
28
|
+
}
|
|
29
|
+
/** Provision + (optionally) wire every identity in the manifest. Returns the resolved per-identity state. */
|
|
30
|
+
export async function applyKmsManifest(manifest, deps, opts = {}) {
|
|
31
|
+
const m = validateManifest(manifest);
|
|
32
|
+
const log = deps.log ?? ((s) => console.log(s));
|
|
33
|
+
log(`KMS apply — project=${m.project} location=${m.location} keyRing=${m.keyRing} | ${m.identities.length} identities | write=${!!opts.write} dryRun=${!!opts.dryRun}\n`);
|
|
34
|
+
if (opts.dryRun) {
|
|
35
|
+
for (const id of m.identities) {
|
|
36
|
+
log(` plan: ${id.name} → key "${keyIdFor(id.name)}" → ${id.targets.map((t) => `${t.deployment} (${m.deployments[t.deployment].platform})`).join(', ')}`);
|
|
37
|
+
}
|
|
38
|
+
return [];
|
|
39
|
+
}
|
|
40
|
+
// 1–3. Provision keyring + per-identity HSM keys + per-key IAM, and derive each EVM address — via the
|
|
41
|
+
// injected (gcloud-free REST) provisioner. keyMap/addresses are keyed by the ORIGINAL dotted name.
|
|
42
|
+
const plan = buildPlan(m, deps.serviceAccount);
|
|
43
|
+
const result = await deps.provision(plan);
|
|
44
|
+
const resolved = m.identities.map((id) => ({
|
|
45
|
+
name: id.name,
|
|
46
|
+
targets: id.targets,
|
|
47
|
+
keyVersionName: result.keyMap[id.name],
|
|
48
|
+
address: result.addresses[id.name],
|
|
49
|
+
sa: null,
|
|
50
|
+
}));
|
|
51
|
+
for (const r of resolved)
|
|
52
|
+
log(` ✓ ${r.name.padEnd(26)} → ${r.address}`);
|
|
53
|
+
log(` (provisioned ${m.identities.length} keys; ${result.alreadyExisted.length} step(s) already existed, ${result.granted.length} IAM grant(s))`);
|
|
54
|
+
// 4. Resolve agent SAs (agent-naming).
|
|
55
|
+
const saByName = await resolveSAs(deps, resolved.map((r) => r.name), log);
|
|
56
|
+
for (const r of resolved)
|
|
57
|
+
r.sa = saByName.get(r.name) ?? null;
|
|
58
|
+
// 5. Wire secrets per deployment (only with `write`).
|
|
59
|
+
const saValue = JSON.stringify(JSON.parse(deps.serviceAccount.raw)); // canonical single-line JSON
|
|
60
|
+
for (const [depName, dep] of Object.entries(m.deployments)) {
|
|
61
|
+
const here = resolved.flatMap((r) => r.targets.filter((t) => t.deployment === depName).map((t) => ({ r, wire: t.wire })));
|
|
62
|
+
if (here.length === 0)
|
|
63
|
+
continue;
|
|
64
|
+
const writes = [{ name: m.saSecretName, value: saValue, note: 'SA JSON' }];
|
|
65
|
+
// Aggregate every identity sharing a keyMapSecret into one name→keyVersion JSON map (one secret).
|
|
66
|
+
const keyMapSecret = here.find((h) => h.wire.keyMapSecret)?.wire.keyMapSecret;
|
|
67
|
+
if (keyMapSecret) {
|
|
68
|
+
const map = Object.fromEntries(here.filter((h) => h.wire.keyMapSecret === keyMapSecret).map((h) => [h.r.name, h.r.keyVersionName]));
|
|
69
|
+
writes.push({ name: keyMapSecret, value: JSON.stringify(map), note: `${Object.keys(map).length} keys` });
|
|
70
|
+
}
|
|
71
|
+
// Single-key targets (e.g. a validator): per-identity key path + resolved SA.
|
|
72
|
+
for (const h of here) {
|
|
73
|
+
if (h.wire.keySecret)
|
|
74
|
+
writes.push({ name: h.wire.keySecret, value: h.r.keyVersionName });
|
|
75
|
+
if (h.wire.saSecret && h.r.sa)
|
|
76
|
+
writes.push({ name: h.wire.saSecret, value: h.r.sa });
|
|
77
|
+
if (h.wire.saSecret && !h.r.sa)
|
|
78
|
+
log(` ! ${h.r.name}: SA unresolved → cannot wire ${h.wire.saSecret}`);
|
|
79
|
+
}
|
|
80
|
+
log(`\n ${depName} (${dep.platform}): ${writes.map((w) => w.name + (w.note ? ` [${w.note}]` : '')).join(', ')}`);
|
|
81
|
+
if (!opts.write) {
|
|
82
|
+
log(' (dry — pass write:true to push these secrets)');
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
for (const w of writes) {
|
|
86
|
+
await deps.writeSecret(dep, w.name, w.value);
|
|
87
|
+
log(` ✓ wrote ${w.name}`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
// 6. Report the ceremony gap (the one human step).
|
|
91
|
+
const pendingLeaf = resolved.flatMap((r) => r.targets.filter((t) => t.wire.leafSecret).map((t) => ({ r, leafSecret: t.wire.leafSecret })));
|
|
92
|
+
if (pendingLeaf.length) {
|
|
93
|
+
log(`\n ⚠ delegation leaf (owner-signed SA→key) is the ceremony step — NOT written by this tool:`);
|
|
94
|
+
for (const { r, leafSecret } of pendingLeaf)
|
|
95
|
+
log(` - ${r.name}: authorize ${r.address} for SA ${r.sa ?? '(unresolved)'} via the content-signer ceremony, then set ${leafSecret}`);
|
|
96
|
+
}
|
|
97
|
+
log('\nDone.');
|
|
98
|
+
return resolved;
|
|
99
|
+
}
|
|
100
|
+
/** Read-only verification that each agent is still hooked to its own KMS key: the LIVE KMS delegate (derived
|
|
101
|
+
* from the key's public key) must equal the owner-AUTHORIZED delegate stored in the bindings, and the stored
|
|
102
|
+
* SA must equal the name's on-chain resolution. Returns the count of drifted/unbound identities. */
|
|
103
|
+
export async function verifyKmsManifest(manifest, deps) {
|
|
104
|
+
const m = validateManifest(manifest);
|
|
105
|
+
const log = deps.log ?? ((s) => console.log(s));
|
|
106
|
+
log(`KMS verify — ${m.identities.length} identities\n`);
|
|
107
|
+
const plan = buildPlan(m, deps.serviceAccount);
|
|
108
|
+
const stored = deps.readStoredBindings ? await deps.readStoredBindings() : new Map();
|
|
109
|
+
if (!deps.readStoredBindings)
|
|
110
|
+
log('! no stored-bindings reader (manifest.bindingsUrl) — cannot compare against stored delegations\n');
|
|
111
|
+
const saByName = await resolveSAs(deps, m.identities.map((i) => i.name), log);
|
|
112
|
+
let problems = 0;
|
|
113
|
+
for (const id of m.identities) {
|
|
114
|
+
const live = await deps.deriveAddress(keyVersionName(plan, keyIdFor(id.name)));
|
|
115
|
+
const resolvedSA = saByName.get(id.name) ?? null;
|
|
116
|
+
const b = stored.get(id.name);
|
|
117
|
+
const issues = [];
|
|
118
|
+
if (!live)
|
|
119
|
+
issues.push('KMS key missing / not ENABLED');
|
|
120
|
+
if (!b && stored.size > 0)
|
|
121
|
+
issues.push('no stored delegation (ceremony not run)');
|
|
122
|
+
else if (b) {
|
|
123
|
+
if (live && lower(b.delegate_key) !== lower(live))
|
|
124
|
+
issues.push(`stored delegate ${b.delegate_key} ≠ live KMS ${live}`);
|
|
125
|
+
if (resolvedSA && lower(b.issuer_sa) !== lower(resolvedSA))
|
|
126
|
+
issues.push(`stored SA ${b.issuer_sa} ≠ resolved SA ${resolvedSA}`);
|
|
127
|
+
}
|
|
128
|
+
if (issues.length)
|
|
129
|
+
problems++;
|
|
130
|
+
log(` ${issues.length ? '✗' : '✓'} ${id.name.padEnd(26)} live=${live ?? '-'} SA=${resolvedSA ?? '(unresolved)'}${issues.length ? ' — ' + issues.join('; ') : ' bound'}`);
|
|
131
|
+
}
|
|
132
|
+
log(problems === 0 ? '\n✓ all identities bound — live KMS delegate === owner-authorized delegate' : `\n✗ ${problems} identity/identities drifted or unbound`);
|
|
133
|
+
return problems;
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=orchestrator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orchestrator.js","sourceRoot":"","sources":["../src/orchestrator.ts"],"names":[],"mappings":"AAAA,qGAAqG;AACrG,sGAAsG;AACtG,0GAA0G;AAC1G,yGAAyG;AACzG,oDAAoD;AACpD,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IACD,GAAG,CAAC,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,4EAA4E,CAAC,CAAC,CAAC,OAAO,QAAQ,yCAAyC,CAAC,CAAC;IAC9J,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@agenticprimitives/ap-kms",
|
|
3
|
+
"version": "0.0.0-alpha.1",
|
|
4
|
+
"description": "Manifest-driven managed-KMS orchestrator: provision per-identity Cloud-KMS HSM signing keys + per-key IAM, resolve each agent's Smart Agent (agent-naming), derive + verify the EVM delegate address, and push the minimal runtime secrets to deploy targets (Cloudflare/Vercel) with no echo. Vertical-agnostic; the naming resolver, provisioner, and secret writers are injected so key-custody stays a leaf.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/agentictrustlabs/agenticprimitives.git",
|
|
9
|
+
"directory": "packages/ap-kms"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/agentictrustlabs/agenticprimitives/tree/master/packages/ap-kms",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/agentictrustlabs/agenticprimitives/issues"
|
|
14
|
+
},
|
|
15
|
+
"type": "module",
|
|
16
|
+
"main": "./dist/index.js",
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"bin": {
|
|
19
|
+
"ap-kms": "./bin/ap-kms.mjs"
|
|
20
|
+
},
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"import": "./dist/index.js"
|
|
25
|
+
},
|
|
26
|
+
"./node": {
|
|
27
|
+
"types": "./dist/node/index.d.ts",
|
|
28
|
+
"import": "./dist/node/index.js"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"LICENSE",
|
|
33
|
+
"dist",
|
|
34
|
+
"bin",
|
|
35
|
+
"spec.md",
|
|
36
|
+
"README.md"
|
|
37
|
+
],
|
|
38
|
+
"publishConfig": {
|
|
39
|
+
"access": "public"
|
|
40
|
+
},
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"viem": "^2.52.2",
|
|
43
|
+
"@agenticprimitives/types": "1.0.0-alpha.11",
|
|
44
|
+
"@agenticprimitives/key-custody": "1.0.0-alpha.11",
|
|
45
|
+
"@agenticprimitives/agent-naming": "1.0.0-alpha.11"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"vitest": "^4.1.8",
|
|
49
|
+
"viem": "^2.52.2"
|
|
50
|
+
},
|
|
51
|
+
"keywords": [
|
|
52
|
+
"agentic",
|
|
53
|
+
"primitives",
|
|
54
|
+
"ap-kms",
|
|
55
|
+
"kms",
|
|
56
|
+
"orchestrator",
|
|
57
|
+
"provisioning",
|
|
58
|
+
"cloud-kms",
|
|
59
|
+
"delegation"
|
|
60
|
+
],
|
|
61
|
+
"scripts": {
|
|
62
|
+
"build": "tsc -p tsconfig.build.json",
|
|
63
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
64
|
+
"test": "vitest run",
|
|
65
|
+
"test:unit": "vitest run test/unit --passWithNoTests",
|
|
66
|
+
"test:watch": "vitest",
|
|
67
|
+
"clean": "rm -rf dist"
|
|
68
|
+
}
|
|
69
|
+
}
|
package/spec.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# ap-kms — managed-KMS orchestrator (contract)
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
Make a signing identity's Cloud-KMS configuration reproducible and declarative. A manifest names the signing
|
|
6
|
+
identities (by agent-naming name) and where each runtime reads its KMS config; the orchestrator provisions
|
|
7
|
+
keys, derives + verifies addresses, resolves Smart Agents, and writes runtime secrets — idempotently.
|
|
8
|
+
|
|
9
|
+
## Manifest (`KmsManifest`)
|
|
10
|
+
|
|
11
|
+
- `project` / `location` / `keyRing` — GCP KMS location of the keyring.
|
|
12
|
+
- `runtimeServiceAccountFile` — admin/runtime SA JSON; used BOTH to provision and as the runtime SA secret.
|
|
13
|
+
- `saSecretName` — the secret name each runtime expects the SA JSON under.
|
|
14
|
+
- `naming` — `{ rpcUrlEnv, chainId, registry, universalResolver }`. The RPC URL is an env var (carries a key).
|
|
15
|
+
- `bindingsUrl?` — base URL exposing `POST /tools/list_content_signers` (the stored owner-authorized bindings).
|
|
16
|
+
- `deployments` — map of `{ platform: 'cloudflare' | 'vercel', dir?/worker?/project?, env }`.
|
|
17
|
+
- `identities` — each `{ name, targets: [{ deployment, wire }] }`, where `wire` is one of:
|
|
18
|
+
- `keyMapSecret` — Cloudflare: identities sharing this secret aggregate into one `name → keyVersion` map.
|
|
19
|
+
- `keySecret` — single-key target: the secret holding this identity's cryptoKeyVersion path.
|
|
20
|
+
- `saSecret` — the secret holding the resolved Smart Agent address.
|
|
21
|
+
- `leafSecret` — the owner-signed delegation leaf (ceremony output; reported, never written by this tool).
|
|
22
|
+
|
|
23
|
+
## Guarantees
|
|
24
|
+
|
|
25
|
+
- **Idempotent** — re-running `apply` skips already-existing keyring/keys/IAM (reports the skips).
|
|
26
|
+
- **Fail-closed validation** — every identity target must point at a declared deployment; platform-required
|
|
27
|
+
deployment fields are checked before any mutation.
|
|
28
|
+
- **No echo** — secret values are passed in-memory and never logged or placed on argv.
|
|
29
|
+
- **Authorization is never fabricated** — the SA→key delegation leaf is the ceremony's job; this tool only
|
|
30
|
+
provisions infra + reports binding status. `verify` is read-only.
|
|
31
|
+
- **Injected boundary** — the core depends only on injected functions (provision / resolveName /
|
|
32
|
+
deriveAddress / readStoredBindings / writeSecret); `key-custody` stays a leaf (ADR-0021/0037).
|
|
33
|
+
|
|
34
|
+
## `verify`
|
|
35
|
+
|
|
36
|
+
For each identity: derive the LIVE KMS delegate from the key's public key; compare to the stored
|
|
37
|
+
owner-authorized `delegate_key`, and compare the name's on-chain resolution to the stored `issuer_sa`.
|
|
38
|
+
Returns the count of drifted/unbound identities (non-zero → exit 1).
|