@the-ai-company/cbio-node-runtime 1.15.1 → 1.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -28
- package/dist/clients/agent/client.d.ts +12 -2
- package/dist/clients/agent/client.js +37 -3
- package/dist/clients/agent/client.js.map +1 -1
- package/dist/clients/agent/contracts.d.ts +1 -20
- package/dist/clients/agent/index.d.ts +1 -1
- package/dist/clients/owner/client.d.ts +12 -4
- package/dist/clients/owner/client.js +90 -4
- package/dist/clients/owner/client.js.map +1 -1
- package/dist/clients/owner/contracts.d.ts +10 -0
- package/dist/clients/owner/index.d.ts +2 -2
- package/dist/runtime/index.d.ts +6 -11
- package/dist/runtime/index.js +4 -9
- package/dist/runtime/index.js.map +1 -1
- package/dist/vault-core/contracts.d.ts +12 -1
- package/dist/vault-core/core.d.ts +2 -1
- package/dist/vault-core/core.js +37 -1
- package/dist/vault-core/core.js.map +1 -1
- package/dist/vault-core/defaults.d.ts +2 -0
- package/dist/vault-core/defaults.js +41 -1
- package/dist/vault-core/defaults.js.map +1 -1
- package/dist/vault-core/index.d.ts +1 -1
- package/dist/vault-core/ports.d.ts +4 -1
- package/dist/vault-ingress/defaults.d.ts +1 -2
- package/dist/vault-ingress/defaults.js +2 -4
- package/dist/vault-ingress/defaults.js.map +1 -1
- package/dist/vault-ingress/index.d.ts +1 -0
- package/dist/vault-ingress/index.js +3 -0
- package/dist/vault-ingress/index.js.map +1 -1
- package/docs/REFERENCE.md +43 -47
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -22,10 +22,10 @@ Node.js vault runtime with a hard-cut architecture: vault core first, explicit c
|
|
|
22
22
|
- No TUI
|
|
23
23
|
|
|
24
24
|
Main export now centers on:
|
|
25
|
-
-
|
|
26
|
-
-
|
|
27
|
-
-
|
|
28
|
-
-
|
|
25
|
+
- identity creation and recovery
|
|
26
|
+
- persistent vault bootstrap and recovery
|
|
27
|
+
- owner and agent clients
|
|
28
|
+
- owner flow-boundary helpers
|
|
29
29
|
|
|
30
30
|
## Install
|
|
31
31
|
|
|
@@ -39,8 +39,6 @@ npm install @the-ai-company/cbio-node-runtime
|
|
|
39
39
|
|
|
40
40
|
```ts
|
|
41
41
|
import {
|
|
42
|
-
createVaultService,
|
|
43
|
-
createDefaultVaultCoreDependencies,
|
|
44
42
|
createChildIdentity,
|
|
45
43
|
createIdentity,
|
|
46
44
|
createWorkspaceStorage,
|
|
@@ -50,12 +48,9 @@ import {
|
|
|
50
48
|
recoverVault,
|
|
51
49
|
createOwnerHttpFlowBoundary,
|
|
52
50
|
createStandardAcquireBoundary,
|
|
53
|
-
createStandardDispatchBoundary,
|
|
54
51
|
createVaultClient,
|
|
55
52
|
createAgentClient,
|
|
56
53
|
FsStorageProvider,
|
|
57
|
-
LocalVaultTransport,
|
|
58
|
-
LocalSigner,
|
|
59
54
|
} from '@the-ai-company/cbio-node-runtime';
|
|
60
55
|
```
|
|
61
56
|
|
|
@@ -159,20 +154,6 @@ An owner-defined exception path also exists for non-standard but intentional int
|
|
|
159
154
|
- agent may only invoke the registered `customFlowId`
|
|
160
155
|
- this is an explicit escape hatch, not the default path
|
|
161
156
|
|
|
162
|
-
## Modules
|
|
163
|
-
|
|
164
|
-
- `vault-core`
|
|
165
|
-
The vault kernel. Stores plaintext, authorizes writes, authorizes dispatch, executes dispatch, appends audit.
|
|
166
|
-
|
|
167
|
-
- `vault-ingress`
|
|
168
|
-
Vault boundary/facade. Accepts request-shaped calls, handles trusted acquisition paths, and keeps capability resolution plus dispatch ingress inside the vault trust boundary.
|
|
169
|
-
|
|
170
|
-
- `clients/owner`
|
|
171
|
-
Owner-facing client. The owner is the single vault admin. It writes secrets, exports plaintext secrets, manages agents/capabilities, and reads audit.
|
|
172
|
-
|
|
173
|
-
- `clients/agent`
|
|
174
|
-
Agent-facing client. Creates signed dispatch requests. Never handles plaintext secret.
|
|
175
|
-
|
|
176
157
|
## Status
|
|
177
158
|
|
|
178
159
|
The old identity-centric runtime is no longer the intended public architecture.
|
|
@@ -183,19 +164,41 @@ This package now exposes the production local vault runtime surface as the prima
|
|
|
183
164
|
```ts
|
|
184
165
|
const ownerIdentity = createIdentity({ nickname: 'owner-main' });
|
|
185
166
|
const agentIdentity = createIdentity({ nickname: 'agent-worker' });
|
|
186
|
-
const
|
|
187
|
-
const client = createVaultClient({
|
|
188
|
-
const
|
|
189
|
-
const agent = createAgentClient({ agentId: agentIdentity.identityId }, capability, new LocalSigner(agentIdentity), transport, clock);
|
|
167
|
+
const createdVault = await createVault({ ownerIdentity });
|
|
168
|
+
const client = createVaultClient({ ownerIdentity, vault: createdVault.vault });
|
|
169
|
+
const agent = createAgentClient({ agentIdentity, capability, vault: createdVault.vault });
|
|
190
170
|
```
|
|
191
171
|
|
|
172
|
+
Owner API example:
|
|
173
|
+
|
|
174
|
+
```ts
|
|
175
|
+
const storedSecret = await client.storeSecret({
|
|
176
|
+
alias: 'api-token',
|
|
177
|
+
plaintext: 'secret-value',
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
await client.defineSecretTargets({
|
|
181
|
+
alias: storedSecret.alias.value,
|
|
182
|
+
targetBindings: [
|
|
183
|
+
{
|
|
184
|
+
kind: 'site',
|
|
185
|
+
targetId: 'api.example.com',
|
|
186
|
+
targetUrl: 'https://api.example.com/endpoint',
|
|
187
|
+
methods: ['POST'],
|
|
188
|
+
},
|
|
189
|
+
],
|
|
190
|
+
});
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
`writeSecret(...)` is the one-step variant and requires `targetBindings`.
|
|
194
|
+
|
|
192
195
|
Capability example:
|
|
193
196
|
|
|
194
197
|
```ts
|
|
195
198
|
const capability = {
|
|
196
199
|
vaultId: vault.vaultId,
|
|
197
200
|
capabilityId: 'cap-1',
|
|
198
|
-
agentId:
|
|
201
|
+
agentId: agentIdentity.identityId,
|
|
199
202
|
secretAliases: ['api-token'],
|
|
200
203
|
operation: 'dispatch_http',
|
|
201
204
|
allowedTargets: ['https://api.example.com/endpoint'],
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CreatedIdentity } from "../../runtime/identity.js";
|
|
2
|
+
import { type Clock } from "../../vault-core/index.js";
|
|
3
|
+
import type { VaultService } from "../../vault-ingress/index.js";
|
|
2
4
|
import type { AgentCapabilityEnvelope, AgentDispatchIntent, AgentDispatchTransport, AgentSigner } from "./contracts.js";
|
|
3
5
|
export interface AgentIdentity {
|
|
4
6
|
agentId: string;
|
|
@@ -6,4 +8,12 @@ export interface AgentIdentity {
|
|
|
6
8
|
export interface AgentClient {
|
|
7
9
|
dispatch(intent: AgentDispatchIntent): Promise<import("../../vault-core/index.js").DispatchResult>;
|
|
8
10
|
}
|
|
9
|
-
export
|
|
11
|
+
export interface CreateAgentClientOptions {
|
|
12
|
+
agentIdentity: CreatedIdentity | AgentIdentity;
|
|
13
|
+
capability: AgentCapabilityEnvelope;
|
|
14
|
+
vault?: VaultService;
|
|
15
|
+
transport?: AgentDispatchTransport;
|
|
16
|
+
signer?: AgentSigner;
|
|
17
|
+
clock?: Clock;
|
|
18
|
+
}
|
|
19
|
+
export declare function createAgentClient(options: CreateAgentClientOptions): AgentClient;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { LocalSigner } from "../../protocol/crypto.js";
|
|
2
|
+
import { SystemClock } from "../../vault-core/index.js";
|
|
3
|
+
import { LocalVaultTransport } from "../../vault-ingress/defaults.js";
|
|
1
4
|
function createDispatchBinding(requestId, requestedAt, agentId, capabilityId, secretAlias, targetUrl, method, body) {
|
|
2
5
|
return JSON.stringify({
|
|
3
6
|
requestId,
|
|
@@ -26,7 +29,6 @@ class DefaultAgentClient {
|
|
|
26
29
|
async dispatch(intent) {
|
|
27
30
|
const requestedAt = intent.requestedAt ?? this._clock.nowIso();
|
|
28
31
|
const requestId = `${this._identity.agentId}:${requestedAt}:${intent.secretAlias ?? "no-secret"}:${intent.method}`;
|
|
29
|
-
const publicKey = await this._signer.getPublicKey();
|
|
30
32
|
const signature = await this._signer.sign(createDispatchBinding(requestId, requestedAt, this._identity.agentId, this._capability.capabilityId, intent.secretAlias, intent.targetUrl, intent.method, intent.body));
|
|
31
33
|
return this._transport.dispatch({
|
|
32
34
|
vaultId: this._capability.vaultId,
|
|
@@ -66,7 +68,39 @@ class DefaultAgentClient {
|
|
|
66
68
|
});
|
|
67
69
|
}
|
|
68
70
|
}
|
|
69
|
-
|
|
70
|
-
return
|
|
71
|
+
function isCreateAgentClientOptions(value) {
|
|
72
|
+
return typeof value === "object" && value !== null && "agentIdentity" in value && "capability" in value;
|
|
73
|
+
}
|
|
74
|
+
function isCreatedIdentity(value) {
|
|
75
|
+
return "privateKey" in value && "publicKey" in value;
|
|
76
|
+
}
|
|
77
|
+
function resolveAgentSigner(identity, signer) {
|
|
78
|
+
if (signer) {
|
|
79
|
+
return signer;
|
|
80
|
+
}
|
|
81
|
+
if (isCreatedIdentity(identity)) {
|
|
82
|
+
return new LocalSigner(identity);
|
|
83
|
+
}
|
|
84
|
+
throw new Error("createAgentClient() requires signer when agentIdentity does not include keys");
|
|
85
|
+
}
|
|
86
|
+
function resolveAgentIdentity(options) {
|
|
87
|
+
return "agentId" in options.agentIdentity
|
|
88
|
+
? options.agentIdentity
|
|
89
|
+
: { agentId: options.agentIdentity.identityId };
|
|
90
|
+
}
|
|
91
|
+
function resolveAgentTransport(options) {
|
|
92
|
+
if (options.transport) {
|
|
93
|
+
return options.transport;
|
|
94
|
+
}
|
|
95
|
+
if (options.vault) {
|
|
96
|
+
return new LocalVaultTransport(options.vault);
|
|
97
|
+
}
|
|
98
|
+
throw new Error("createAgentClient() requires transport or vault");
|
|
99
|
+
}
|
|
100
|
+
export function createAgentClient(options) {
|
|
101
|
+
if (!isCreateAgentClientOptions(options)) {
|
|
102
|
+
throw new Error("createAgentClient() requires a single options object");
|
|
103
|
+
}
|
|
104
|
+
return new DefaultAgentClient(resolveAgentIdentity(options), options.capability, resolveAgentSigner(options.agentIdentity, options.signer), resolveAgentTransport(options), options.clock ?? new SystemClock());
|
|
71
105
|
}
|
|
72
106
|
//# sourceMappingURL=client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/clients/agent/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/clients/agent/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,EAAE,WAAW,EAAc,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AA0BtE,SAAS,qBAAqB,CAC5B,SAAiB,EACjB,WAAmB,EACnB,OAAe,EACf,YAAoB,EACpB,WAA+B,EAC/B,SAAiB,EACjB,MAAc,EACd,IAAa;IAEb,OAAO,IAAI,CAAC,SAAS,CAAC;QACpB,SAAS;QACT,WAAW;QACX,OAAO;QACP,YAAY;QACZ,WAAW,EAAE,WAAW,IAAI,IAAI;QAChC,SAAS;QACT,MAAM;QACN,IAAI,EAAE,IAAI,IAAI,IAAI;KACnB,CAAC,CAAC;AACL,CAAC;AAED,MAAM,kBAAkB;IAEH;IACA;IACA;IACA;IACA;IALnB,YACmB,SAAwB,EACxB,WAAoC,EACpC,OAAoB,EACpB,UAAkC,EAClC,MAAa;QAJb,cAAS,GAAT,SAAS,CAAe;QACxB,gBAAW,GAAX,WAAW,CAAyB;QACpC,YAAO,GAAP,OAAO,CAAa;QACpB,eAAU,GAAV,UAAU,CAAwB;QAClC,WAAM,GAAN,MAAM,CAAO;IAC7B,CAAC;IAEJ,KAAK,CAAC,QAAQ,CAAC,MAA2B;QACxC,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QAC/D,MAAM,SAAS,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,IAAI,WAAW,IA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AO,CAAC,SAAS,CAAC;IAC3B,CAAC;IACD,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;QAClB,OAAO,IAAI,mBAAmB,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAChD,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;AACrE,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,OAAiC;IACjE,IAAI,CAAC,0BAA0B,CAAC,OAAO,CAAC,EAAE,CAAC;QACzC,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;IAC1E,CAAC;IACD,OAAO,IAAI,kBAAkB,CAC3B,oBAAoB,CAAC,OAAO,CAAC,EAC7B,OAAO,CAAC,UAAU,EAClB,kBAAkB,CAAC,OAAO,CAAC,aAAa,EAAE,OAAO,CAAC,MAAM,CAAC,EACzD,qBAAqB,CAAC,OAAO,CAAC,EAC9B,OAAO,CAAC,KAAK,IAAI,IAAI,WAAW,EAAE,CACnC,CAAC;AACJ,CAAC"}
|
|
@@ -6,27 +6,8 @@ export interface AgentDispatchIntent {
|
|
|
6
6
|
body?: string;
|
|
7
7
|
requestedAt?: string;
|
|
8
8
|
}
|
|
9
|
-
export
|
|
10
|
-
vaultId: import("../../vault-core/index.js").VaultId;
|
|
11
|
-
capabilityId: string;
|
|
12
|
-
agentId: string;
|
|
13
|
-
secretIds?: readonly string[];
|
|
14
|
-
secretAliases?: readonly string[];
|
|
15
|
-
operation: "dispatch_http";
|
|
16
|
-
allowedTargets: readonly string[];
|
|
17
|
-
allowedMethods: readonly string[];
|
|
18
|
-
allowedPaths?: readonly string[];
|
|
19
|
-
issuedAt: string;
|
|
20
|
-
expiresAt?: string;
|
|
21
|
-
revocationVersion?: number;
|
|
22
|
-
rateLimit?: {
|
|
23
|
-
maxRequests: number;
|
|
24
|
-
windowMs: number;
|
|
25
|
-
};
|
|
26
|
-
auditRequired?: boolean;
|
|
27
|
-
}
|
|
9
|
+
export type AgentCapabilityEnvelope = import("../../vault-core/index.js").AgentCapability;
|
|
28
10
|
export interface AgentSigner {
|
|
29
|
-
getPublicKey(): Promise<string>;
|
|
30
11
|
sign(input: string): Promise<string>;
|
|
31
12
|
}
|
|
32
13
|
export interface AgentDispatchTransport {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { createAgentClient } from "./client.js";
|
|
2
|
-
export type { AgentClient, AgentIdentity, } from "./client.js";
|
|
2
|
+
export type { AgentClient, CreateAgentClientOptions, AgentIdentity, } from "./client.js";
|
|
3
3
|
export type { AgentCapabilityEnvelope, AgentDispatchIntent, AgentDispatchTransport, AgentSigner, } from "./contracts.js";
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CreatedIdentity } from "../../runtime/identity.js";
|
|
2
|
+
import { type Clock } from "../../vault-core/index.js";
|
|
2
3
|
import type { VaultService } from "../../vault-ingress/index.js";
|
|
3
|
-
import type { VaultAuditQueryInput, VaultExportSecretInput, VaultGrantCapabilityInput, VaultRegisterFlowInput, VaultRegisterAgentInput, OwnerWriteSecretInput } from "./contracts.js";
|
|
4
|
+
import type { VaultAuditQueryInput, OwnerDefineSecretTargetsInput, VaultExportSecretInput, VaultGrantCapabilityInput, VaultRegisterFlowInput, VaultRegisterAgentInput, OwnerStoreSecretInput, OwnerWriteSecretInput } from "./contracts.js";
|
|
4
5
|
export interface VaultIdentity {
|
|
5
6
|
identityId: string;
|
|
6
7
|
}
|
|
7
8
|
export interface VaultSigner {
|
|
8
|
-
getPublicKey(): Promise<string>;
|
|
9
9
|
sign(input: string): Promise<string>;
|
|
10
10
|
}
|
|
11
11
|
export interface VaultClient {
|
|
12
|
+
storeSecret(input: OwnerStoreSecretInput): Promise<import("../../vault-core/index.js").SecretRecord>;
|
|
13
|
+
defineSecretTargets(input: OwnerDefineSecretTargetsInput): Promise<import("../../vault-core/index.js").SecretRecord>;
|
|
12
14
|
writeSecret(input: OwnerWriteSecretInput): Promise<import("../../vault-core/index.js").SecretRecord>;
|
|
13
15
|
exportSecret(input: VaultExportSecretInput): Promise<import("../../vault-core/index.js").OwnerSecretExport>;
|
|
14
16
|
grantCapability(input: VaultGrantCapabilityInput): Promise<void>;
|
|
@@ -16,4 +18,10 @@ export interface VaultClient {
|
|
|
16
18
|
registerAgent(input: VaultRegisterAgentInput): Promise<void>;
|
|
17
19
|
registerFlow(input: VaultRegisterFlowInput): Promise<void>;
|
|
18
20
|
}
|
|
19
|
-
export
|
|
21
|
+
export interface CreateVaultClientOptions {
|
|
22
|
+
ownerIdentity: CreatedIdentity | VaultIdentity;
|
|
23
|
+
vault: VaultService;
|
|
24
|
+
signer?: VaultSigner;
|
|
25
|
+
clock?: Clock;
|
|
26
|
+
}
|
|
27
|
+
export declare function createVaultClient(options: CreateVaultClientOptions): VaultClient;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { LocalSigner } from "../../protocol/crypto.js";
|
|
2
|
+
import { SystemClock } from "../../vault-core/index.js";
|
|
1
3
|
class DefaultVaultClient {
|
|
2
4
|
_identity;
|
|
3
5
|
_vault;
|
|
@@ -9,16 +11,77 @@ class DefaultVaultClient {
|
|
|
9
11
|
this._signer = _signer;
|
|
10
12
|
this._clock = _clock;
|
|
11
13
|
}
|
|
14
|
+
async storeSecret(input) {
|
|
15
|
+
const requestedAt = input.requestedAt ?? this._clock.nowIso();
|
|
16
|
+
const requestId = `${this._identity.identityId}:${requestedAt}:${input.alias}:write_secret`;
|
|
17
|
+
const signature = await this._signer.sign(JSON.stringify({
|
|
18
|
+
requestId,
|
|
19
|
+
requestedAt,
|
|
20
|
+
ownerId: this._identity.identityId,
|
|
21
|
+
alias: input.alias,
|
|
22
|
+
plaintext: input.plaintext,
|
|
23
|
+
targetBindings: [],
|
|
24
|
+
}));
|
|
25
|
+
return this._vault.writeSecret({
|
|
26
|
+
kind: "owner.write_secret",
|
|
27
|
+
vaultId: this._vault.vaultId,
|
|
28
|
+
requestId,
|
|
29
|
+
owner: {
|
|
30
|
+
kind: "owner",
|
|
31
|
+
id: this._identity.identityId,
|
|
32
|
+
},
|
|
33
|
+
alias: input.alias,
|
|
34
|
+
plaintext: input.plaintext,
|
|
35
|
+
targetBindings: [],
|
|
36
|
+
requestedAt,
|
|
37
|
+
proof: {
|
|
38
|
+
ownerId: this._identity.identityId,
|
|
39
|
+
signature,
|
|
40
|
+
requestId,
|
|
41
|
+
requestedAt,
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
async defineSecretTargets(input) {
|
|
46
|
+
const requestedAt = input.requestedAt ?? this._clock.nowIso();
|
|
47
|
+
const requestId = `${this._identity.identityId}:${requestedAt}:${input.alias}:define_secret_targets`;
|
|
48
|
+
const targetBindings = [...input.targetBindings];
|
|
49
|
+
const signature = await this._signer.sign(JSON.stringify({
|
|
50
|
+
requestId,
|
|
51
|
+
requestedAt,
|
|
52
|
+
ownerId: this._identity.identityId,
|
|
53
|
+
alias: input.alias,
|
|
54
|
+
targetBindings,
|
|
55
|
+
}));
|
|
56
|
+
return this._vault.defineSecretTargets({
|
|
57
|
+
vaultId: this._vault.vaultId,
|
|
58
|
+
requestId,
|
|
59
|
+
owner: {
|
|
60
|
+
kind: "owner",
|
|
61
|
+
id: this._identity.identityId,
|
|
62
|
+
},
|
|
63
|
+
alias: input.alias,
|
|
64
|
+
targetBindings,
|
|
65
|
+
requestedAt,
|
|
66
|
+
proof: {
|
|
67
|
+
ownerId: this._identity.identityId,
|
|
68
|
+
signature,
|
|
69
|
+
requestId,
|
|
70
|
+
requestedAt,
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
}
|
|
12
74
|
async writeSecret(input) {
|
|
13
75
|
const requestedAt = input.requestedAt ?? this._clock.nowIso();
|
|
14
76
|
const requestId = `${this._identity.identityId}:${requestedAt}:${input.alias}:write_secret`;
|
|
77
|
+
const targetBindings = [...input.targetBindings];
|
|
15
78
|
const signature = await this._signer.sign(JSON.stringify({
|
|
16
79
|
requestId,
|
|
17
80
|
requestedAt,
|
|
18
81
|
ownerId: this._identity.identityId,
|
|
19
82
|
alias: input.alias,
|
|
20
83
|
plaintext: input.plaintext,
|
|
21
|
-
targetBindings
|
|
84
|
+
targetBindings,
|
|
22
85
|
}));
|
|
23
86
|
return this._vault.writeSecret({
|
|
24
87
|
kind: "owner.write_secret",
|
|
@@ -30,7 +93,7 @@ class DefaultVaultClient {
|
|
|
30
93
|
},
|
|
31
94
|
alias: input.alias,
|
|
32
95
|
plaintext: input.plaintext,
|
|
33
|
-
targetBindings
|
|
96
|
+
targetBindings,
|
|
34
97
|
requestedAt,
|
|
35
98
|
proof: {
|
|
36
99
|
ownerId: this._identity.identityId,
|
|
@@ -188,7 +251,30 @@ class DefaultVaultClient {
|
|
|
188
251
|
});
|
|
189
252
|
}
|
|
190
253
|
}
|
|
191
|
-
|
|
192
|
-
return
|
|
254
|
+
function isCreateVaultClientOptions(value) {
|
|
255
|
+
return typeof value === "object" && value !== null && "ownerIdentity" in value && "vault" in value;
|
|
256
|
+
}
|
|
257
|
+
function isCreatedIdentity(value) {
|
|
258
|
+
return "privateKey" in value && "publicKey" in value;
|
|
259
|
+
}
|
|
260
|
+
function resolveVaultSigner(identity, signer) {
|
|
261
|
+
if (signer) {
|
|
262
|
+
return signer;
|
|
263
|
+
}
|
|
264
|
+
if (isCreatedIdentity(identity)) {
|
|
265
|
+
return new LocalSigner(identity);
|
|
266
|
+
}
|
|
267
|
+
throw new Error("createVaultClient() requires signer when ownerIdentity does not include keys");
|
|
268
|
+
}
|
|
269
|
+
function resolveVaultIdentity(options) {
|
|
270
|
+
return {
|
|
271
|
+
identityId: options.ownerIdentity.identityId,
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
export function createVaultClient(options) {
|
|
275
|
+
if (!isCreateVaultClientOptions(options)) {
|
|
276
|
+
throw new Error("createVaultClient() requires a single options object");
|
|
277
|
+
}
|
|
278
|
+
return new DefaultVaultClient(resolveVaultIdentity(options), options.vault, resolveVaultSigner(options.ownerIdentity, options.signer), options.clock ?? new SystemClock());
|
|
193
279
|
}
|
|
194
280
|
//# sourceMappingURL=client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/clients/owner/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/clients/owner/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,EAAE,WAAW,EAAc,MAAM,2BAA2B,CAAC;AAuCpE,MAAM,kBAAkB;IAEH;IACA;IACA;IACA;IAJnB,YACmB,SAAwB,EACxB,MAAoB,EACpB,OAAoB,EACpB,MAAa;QAHb,cAAS,GAAT,SAAS,CAAe;QACxB,WAAM,GAAN,MAAM,CAAc;QACpB,YAAO,GAAP,OAAO,CAAa;QACpB,WAAM,GAAN,MAAM,CAAO;IAC7B,CAAC;IAEJ,KAAK,CAAC,WAAW,CAAC,KAA4B;QAC5C,MAAM,WAAW,GAAG,KAAK,CAAC,WAAW,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QAC9D,MAAM,SAAS,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,IAAI,WAAW,IAAI,KAAK,CAAC,KAAK,eAAe,CAAC;QAC5F,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC;YACvD,SAAS;YACT,WAAW;YACX,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,UAAU;YAClC,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,cAAc,EAAE,EAAE;SACnB,CAAC,CAAC,CAAC;QACJ,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;YAC7B,IAAI,EAAE,oBAAoB;YAC1B,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO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K,CAAC,8EAA8E,CAAC,CAAC;AAClG,CAAC;AAED,SAAS,oBAAoB,CAAC,OAAiC;IAC7D,OAAO;QACL,UAAU,EAAE,OAAO,CAAC,aAAa,CAAC,UAAU;KAC7C,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,OAAiC;IACjE,IAAI,CAAC,0BAA0B,CAAC,OAAO,CAAC,EAAE,CAAC;QACzC,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;IAC1E,CAAC;IACD,OAAO,IAAI,kBAAkB,CAC3B,oBAAoB,CAAC,OAAO,CAAC,EAC7B,OAAO,CAAC,KAAK,EACb,kBAAkB,CAAC,OAAO,CAAC,aAAa,EAAE,OAAO,CAAC,MAAM,CAAC,EACzD,OAAO,CAAC,KAAK,IAAI,IAAI,WAAW,EAAE,CACnC,CAAC;AACJ,CAAC"}
|
|
@@ -12,6 +12,16 @@ export interface OwnerWriteSecretInput {
|
|
|
12
12
|
targetBindings: readonly OwnerSecretTargetBinding[];
|
|
13
13
|
requestedAt?: string;
|
|
14
14
|
}
|
|
15
|
+
export interface OwnerStoreSecretInput {
|
|
16
|
+
alias: string;
|
|
17
|
+
plaintext: string;
|
|
18
|
+
requestedAt?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface OwnerDefineSecretTargetsInput {
|
|
21
|
+
alias: string;
|
|
22
|
+
targetBindings: readonly OwnerSecretTargetBinding[];
|
|
23
|
+
requestedAt?: string;
|
|
24
|
+
}
|
|
15
25
|
export interface VaultAuditQueryInput {
|
|
16
26
|
actorId?: string;
|
|
17
27
|
secretAlias?: string;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { createVaultClient } from "./client.js";
|
|
2
|
-
export type { VaultClient, VaultIdentity, VaultSigner, } from "./client.js";
|
|
3
|
-
export type { VaultAuditQueryInput, VaultExportSecretInput, VaultGrantCapabilityInput, VaultRegisterFlowInput, VaultRegisterAgentInput, OwnerSecretTargetBinding, OwnerWriteSecretInput, } from "./contracts.js";
|
|
2
|
+
export type { VaultClient, CreateVaultClientOptions, VaultIdentity, VaultSigner, } from "./client.js";
|
|
3
|
+
export type { VaultAuditQueryInput, OwnerDefineSecretTargetsInput, VaultExportSecretInput, VaultGrantCapabilityInput, VaultRegisterFlowInput, VaultRegisterAgentInput, OwnerSecretTargetBinding, OwnerStoreSecretInput, OwnerWriteSecretInput, } from "./contracts.js";
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -1,21 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Runtime export.
|
|
3
|
-
*
|
|
3
|
+
* Public surface: high-level runtime and client APIs only.
|
|
4
4
|
*/
|
|
5
5
|
export { IdentityError, IdentityErrorCode } from "../errors.js";
|
|
6
|
-
export { derivePublicKey, LocalSigner } from "../protocol/crypto.js";
|
|
7
|
-
export { deriveIdentityId } from "../protocol/identity.js";
|
|
8
6
|
export type { IStorageProvider } from "../storage/provider.js";
|
|
9
7
|
export { FsStorageProvider } from "../storage/fs.js";
|
|
10
|
-
export { MemoryStorageProvider } from "../storage/memory.js";
|
|
11
8
|
export { createIdentity, deriveChildIdentity, restoreIdentity, type CreateIdentityOptions, type RestoreIdentityOptions, type CreatedIdentity, } from "./identity.js";
|
|
12
9
|
export { createChildIdentity, type CreateChildIdentityOptions, } from "./child-identity.js";
|
|
13
|
-
export { readVaultProfile, writeVaultProfile, type VaultProfile, } from "./vault-metadata.js";
|
|
14
10
|
export { createWorkspaceStorage, getDefaultWorkspaceDir, } from "./workspace-storage.js";
|
|
15
|
-
export { ensurePrivateVault,
|
|
11
|
+
export { ensurePrivateVault, } from "./private-vault.js";
|
|
16
12
|
export { createVault, recoverVault, type CreateVaultOptions, type CreatedVault, type RecoverVaultOptions, type RecoveredVault, } from "./bootstrap.js";
|
|
17
|
-
export {
|
|
18
|
-
export { createVaultClient, type VaultClient, type VaultIdentity, type VaultSigner, type VaultAuditQueryInput, type VaultExportSecretInput, type VaultGrantCapabilityInput, type VaultRegisterFlowInput, type VaultRegisterAgentInput, type OwnerSecretTargetBinding, type OwnerWriteSecretInput, } from "../clients/owner/index.js";
|
|
19
|
-
export { createAgentClient, type AgentClient, type AgentIdentity, type AgentCapabilityEnvelope, type AgentDispatchIntent, type AgentDispatchTransport, type AgentSigner, } from "../clients/agent/index.js";
|
|
20
|
-
export {
|
|
21
|
-
export { LocalVaultTransport, } from "../vault-ingress/defaults.js";
|
|
13
|
+
export { VaultCoreError, type AgentCapability, type SecretRecord } from "../vault-core/index.js";
|
|
14
|
+
export { createVaultClient, type VaultClient, type CreateVaultClientOptions, type VaultIdentity, type VaultSigner, type VaultAuditQueryInput, type OwnerDefineSecretTargetsInput, type VaultExportSecretInput, type VaultGrantCapabilityInput, type VaultRegisterFlowInput, type VaultRegisterAgentInput, type OwnerSecretTargetBinding, type OwnerStoreSecretInput, type OwnerWriteSecretInput, } from "../clients/owner/index.js";
|
|
15
|
+
export { createAgentClient, type AgentClient, type CreateAgentClientOptions, type AgentIdentity, type AgentCapabilityEnvelope, type AgentDispatchIntent, type AgentDispatchTransport, type AgentSigner, } from "../clients/agent/index.js";
|
|
16
|
+
export { createOwnerHttpFlowBoundary, createStandardAcquireBoundary, createStandardDispatchBoundary, type OwnerHttpFlowBoundary, } from "../vault-ingress/index.js";
|
package/dist/runtime/index.js
CHANGED
|
@@ -1,21 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Runtime export.
|
|
3
|
-
*
|
|
3
|
+
* Public surface: high-level runtime and client APIs only.
|
|
4
4
|
*/
|
|
5
5
|
export { IdentityError, IdentityErrorCode } from "../errors.js";
|
|
6
|
-
export { derivePublicKey, LocalSigner } from "../protocol/crypto.js";
|
|
7
|
-
export { deriveIdentityId } from "../protocol/identity.js";
|
|
8
6
|
export { FsStorageProvider } from "../storage/fs.js";
|
|
9
|
-
export { MemoryStorageProvider } from "../storage/memory.js";
|
|
10
7
|
export { createIdentity, deriveChildIdentity, restoreIdentity, } from "./identity.js";
|
|
11
8
|
export { createChildIdentity, } from "./child-identity.js";
|
|
12
|
-
export { readVaultProfile, writeVaultProfile, } from "./vault-metadata.js";
|
|
13
9
|
export { createWorkspaceStorage, getDefaultWorkspaceDir, } from "./workspace-storage.js";
|
|
14
|
-
export { ensurePrivateVault,
|
|
10
|
+
export { ensurePrivateVault, } from "./private-vault.js";
|
|
15
11
|
export { createVault, recoverVault, } from "./bootstrap.js";
|
|
16
|
-
export {
|
|
12
|
+
export { VaultCoreError } from "../vault-core/index.js";
|
|
17
13
|
export { createVaultClient, } from "../clients/owner/index.js";
|
|
18
14
|
export { createAgentClient, } from "../clients/agent/index.js";
|
|
19
|
-
export {
|
|
20
|
-
export { LocalVaultTransport, } from "../vault-ingress/defaults.js";
|
|
15
|
+
export { createOwnerHttpFlowBoundary, createStandardAcquireBoundary, createStandardDispatchBoundary, } from "../vault-ingress/index.js";
|
|
21
16
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEhE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,eAAe,GAIhB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,mBAAmB,GAEpB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,kBAAkB,GACnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,WAAW,EACX,YAAY,GAKb,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,cAAc,EAA2C,MAAM,wBAAwB,CAAC;AAEjG,OAAO,EACL,iBAAiB,GAclB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,iBAAiB,GAQlB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,2BAA2B,EAC3B,6BAA6B,EAC7B,8BAA8B,GAE/B,MAAM,2BAA2B,CAAC"}
|
|
@@ -41,6 +41,17 @@ export interface OwnerWriteSecretCommand {
|
|
|
41
41
|
};
|
|
42
42
|
alias: string;
|
|
43
43
|
plaintext: string;
|
|
44
|
+
targetBindings?: readonly VaultTargetBinding[];
|
|
45
|
+
requestedAt: string;
|
|
46
|
+
proof: OwnerProof;
|
|
47
|
+
}
|
|
48
|
+
export interface OwnerDefineSecretTargetsCommand {
|
|
49
|
+
vaultId: VaultId;
|
|
50
|
+
requestId: string;
|
|
51
|
+
owner: VaultPrincipal & {
|
|
52
|
+
kind: "owner";
|
|
53
|
+
};
|
|
54
|
+
alias: string;
|
|
44
55
|
targetBindings: readonly VaultTargetBinding[];
|
|
45
56
|
requestedAt: string;
|
|
46
57
|
proof: OwnerProof;
|
|
@@ -198,7 +209,7 @@ export interface AuditEntry {
|
|
|
198
209
|
occurredAt: string;
|
|
199
210
|
vaultId: string;
|
|
200
211
|
actor: VaultPrincipal;
|
|
201
|
-
action: "bootstrap_owner_identity" | "register_agent_identity" | "register_custom_flow" | "register_capability" | "write_secret" | "export_secret" | "reassign_alias" | "authorize_dispatch" | "dispatch_secret" | "read_audit";
|
|
212
|
+
action: "bootstrap_owner_identity" | "register_agent_identity" | "register_custom_flow" | "register_capability" | "write_secret" | "define_secret_targets" | "export_secret" | "reassign_alias" | "authorize_dispatch" | "dispatch_secret" | "read_audit";
|
|
202
213
|
requestId?: string;
|
|
203
214
|
capabilityId?: string;
|
|
204
215
|
operation?: AgentCapability["operation"] | AuditEntry["action"];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AuditEntry, AuditQuery, CustomHttpFlowDefinition, DispatchAuthorization, DispatchRequest, DispatchResult, OwnerExportSecretRequest, OwnerRegisterCapabilityCommand, OwnerRegisterAgentIdentityCommand, OwnerRegisterCustomHttpFlowCommand, OwnerSecretExport, SecretRecord, VaultPrincipal, VaultWriteSecretCommand } from "./contracts.js";
|
|
1
|
+
import type { AuditEntry, AuditQuery, CustomHttpFlowDefinition, DispatchAuthorization, DispatchRequest, DispatchResult, OwnerDefineSecretTargetsCommand, OwnerExportSecretRequest, OwnerRegisterCapabilityCommand, OwnerRegisterAgentIdentityCommand, OwnerRegisterCustomHttpFlowCommand, OwnerSecretExport, SecretRecord, VaultPrincipal, VaultWriteSecretCommand } from "./contracts.js";
|
|
2
2
|
import type { VaultCore, VaultCoreDependencies } from "./ports.js";
|
|
3
3
|
export declare class DefaultVaultCore implements VaultCore {
|
|
4
4
|
private readonly _deps;
|
|
@@ -13,6 +13,7 @@ export declare class DefaultVaultCore implements VaultCore {
|
|
|
13
13
|
registerCustomFlow(command: OwnerRegisterCustomHttpFlowCommand): Promise<void>;
|
|
14
14
|
storeCustomFlowSecret(flow: CustomHttpFlowDefinition, alias: string, plaintext: string): Promise<SecretRecord>;
|
|
15
15
|
writeSecret(command: VaultWriteSecretCommand): Promise<SecretRecord>;
|
|
16
|
+
defineSecretTargets(command: OwnerDefineSecretTargetsCommand): Promise<SecretRecord>;
|
|
16
17
|
authorizeDispatch(request: DispatchRequest): Promise<DispatchAuthorization>;
|
|
17
18
|
dispatchSecret(request: DispatchRequest): Promise<DispatchResult>;
|
|
18
19
|
getAudit(actor: VaultPrincipal & {
|
package/dist/vault-core/core.js
CHANGED
|
@@ -26,7 +26,7 @@ function buildSecretRecord(deps, command) {
|
|
|
26
26
|
issuerId: command.kind === "issuer.write_secret" ? command.issuerSiteId : null,
|
|
27
27
|
targetBindings: command.kind === "issuer.write_secret"
|
|
28
28
|
? [...(command.targetBindings ?? [{ kind: "site", targetId: command.issuerSiteId }])]
|
|
29
|
-
: [...command.targetBindings],
|
|
29
|
+
: [...(command.targetBindings ?? [])],
|
|
30
30
|
createdAt: now,
|
|
31
31
|
updatedAt: now,
|
|
32
32
|
};
|
|
@@ -246,6 +246,42 @@ export class DefaultVaultCore {
|
|
|
246
246
|
}
|
|
247
247
|
return record;
|
|
248
248
|
}
|
|
249
|
+
async defineSecretTargets(command) {
|
|
250
|
+
if (command.vaultId.value !== this._deps.vaultId.value) {
|
|
251
|
+
throw new VaultCoreError("write vault mismatch", "VAULT_WRITE_DENIED");
|
|
252
|
+
}
|
|
253
|
+
try {
|
|
254
|
+
await this._deps.ownerProofVerifier.verifyDefineSecretTargets(command);
|
|
255
|
+
await this._deps.policy.authorizeDefineSecretTargets(command);
|
|
256
|
+
}
|
|
257
|
+
catch (error) {
|
|
258
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
259
|
+
await this.appendAudit(toAuditEntry(this._deps, command.owner, "define_secret_targets", "denied", detail, {
|
|
260
|
+
secretAlias: command.alias,
|
|
261
|
+
}));
|
|
262
|
+
throw error;
|
|
263
|
+
}
|
|
264
|
+
const existing = await this._deps.secrets.getByAlias({ value: command.alias });
|
|
265
|
+
if (!existing) {
|
|
266
|
+
const error = new VaultCoreError("secret not found", "VAULT_SECRET_NOT_FOUND");
|
|
267
|
+
await this.appendAudit(toAuditEntry(this._deps, command.owner, "define_secret_targets", "denied", error.message, {
|
|
268
|
+
secretAlias: command.alias,
|
|
269
|
+
}));
|
|
270
|
+
throw error;
|
|
271
|
+
}
|
|
272
|
+
const nextRecord = {
|
|
273
|
+
...existing,
|
|
274
|
+
targetBindings: [...command.targetBindings],
|
|
275
|
+
updatedAt: this._deps.clock.nowIso(),
|
|
276
|
+
};
|
|
277
|
+
await this._deps.secrets.save(nextRecord);
|
|
278
|
+
await this.appendAudit(toAuditEntry(this._deps, command.owner, "define_secret_targets", "succeeded", "secret targets defined", {
|
|
279
|
+
requestId: command.requestId,
|
|
280
|
+
secretAlias: nextRecord.alias.value,
|
|
281
|
+
secretId: nextRecord.secretId.value,
|
|
282
|
+
}));
|
|
283
|
+
return nextRecord;
|
|
284
|
+
}
|
|
249
285
|
async authorizeDispatch(request) {
|
|
250
286
|
if (request.vaultId.value !== this._deps.vaultId.value) {
|
|
251
287
|
throw new VaultCoreError("request vault mismatch", "VAULT_DISPATCH_DENIED");
|