@the-ai-company/cbio-node-runtime 1.4.0 → 1.6.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 CHANGED
@@ -8,6 +8,7 @@ Node.js vault runtime with a hard-cut architecture: vault core first, explicit c
8
8
 
9
9
  - [English](README.md)
10
10
  - [Custody Model](docs/CUSTODY_MODEL.md)
11
+ - [Identity Model](docs/IDENTITY_MODEL.md)
11
12
  - [中文](docs/zh/README.md)
12
13
  - [日本語](docs/ja/README.md)
13
14
  - [한국어](docs/ko/README.md)
@@ -40,8 +41,9 @@ npm install @the-ai-company/cbio-node-runtime
40
41
  import {
41
42
  createVaultService,
42
43
  createDefaultVaultCoreDependencies,
43
- initializePersistentVault,
44
- recoverPersistentVault,
44
+ createIdentity,
45
+ createVault,
46
+ recoverVault,
45
47
  createOwnerHttpFlowBoundary,
46
48
  createStandardAcquireBoundary,
47
49
  createStandardDispatchBoundary,
@@ -54,6 +56,21 @@ import {
54
56
 
55
57
  ## Architecture
56
58
 
59
+ Core terms:
60
+
61
+ - `identity`
62
+ An external principal represented by a public/private keypair.
63
+ - `owner`
64
+ The single admin role that a vault binds to one identity.
65
+ - `agent`
66
+ A delegated role that a vault binds to an identity registered by the owner.
67
+
68
+ Important role rule:
69
+
70
+ - outside the vault there are only identities
71
+ - inside a specific vault, those identities may be bound to roles such as `owner` or `agent`
72
+ - identities are independent; they do not imply parent/child lineage or inheritance by default
73
+
57
74
  The public runtime surface follows four hard rules:
58
75
 
59
76
  1. Secret plaintext lives only in vault core.
@@ -116,10 +133,12 @@ This package now exposes the production local vault runtime surface as the prima
116
133
  ## Example Shape
117
134
 
118
135
  ```ts
136
+ const ownerIdentity = createIdentity({ nickname: 'owner-main' });
137
+ const agentIdentity = createIdentity({ nickname: 'agent-worker' });
119
138
  const vault = createVaultService(createDefaultVaultCoreDependencies());
120
- const owner = createOwnerClient(ownerIdentity, vault, ownerSigner, clock);
139
+ const owner = createOwnerClient({ ownerId: ownerIdentity.identityId }, vault, new LocalSigner(ownerIdentity), clock);
121
140
  const transport = new LocalVaultTransport(vault, capability.capabilityId);
122
- const agent = createAgentClient(agentIdentity, capability, signer, transport, clock);
141
+ const agent = createAgentClient({ agentId: agentIdentity.identityId }, capability, new LocalSigner(agentIdentity), transport, clock);
123
142
  ```
124
143
 
125
144
  Capability example:
@@ -183,22 +202,19 @@ console.log(exported.plaintext);
183
202
  Persistent custody bootstrap example:
184
203
 
185
204
  ```ts
205
+ const ownerIdentity = createIdentity({ nickname: 'owner-main' });
186
206
  const storage = new FsStorageProvider('/tmp/cbio-vault');
187
- const initializedVault = await initializePersistentVault(storage, {
207
+ const createdVault = await createVault(storage, {
188
208
  vaultId: 'vault-persistent',
189
- bootstrapOwner: {
190
- vaultId: { value: 'vault-persistent' },
191
- ownerId: 'owner-1',
192
- publicKey: ownerPublicKey,
193
- },
209
+ ownerIdentity,
194
210
  });
195
211
 
196
212
  // Show once to the owner and let them store it offline.
197
- console.log(initializedVault.initializedCustody.vaultRecoveryKey);
213
+ console.log(createdVault.initializedCustody.vaultRecoveryKey);
198
214
 
199
- const recoveredVault = await recoverPersistentVault(storage, {
215
+ const recoveredVault = await recoverVault(storage, {
200
216
  vaultId: 'vault-persistent',
201
- vaultRecoveryKey: initializedVault.initializedCustody.vaultRecoveryKey,
217
+ vaultRecoveryKey: createdVault.initializedCustody.vaultRecoveryKey,
202
218
  });
203
219
  ```
204
220
 
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Vault secret naming for child identities. CHILD_KEY_PREFIX, getChildIdentitySecretName.
3
+ * Not protocol objects. Protocol talks about public identities and signatures,
4
+ * not local secret names or internal storage prefixes.
5
+ */
6
+ export declare const CHILD_KEY_PREFIX: "cbio:child:";
7
+ export declare function getChildIdentitySecretName(publicKey: string): string;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Vault secret naming for child identities. CHILD_KEY_PREFIX, getChildIdentitySecretName.
3
+ * Not protocol objects. Protocol talks about public identities and signatures,
4
+ * not local secret names or internal storage prefixes.
5
+ */
6
+ import * as crypto from 'node:crypto';
7
+ export const CHILD_KEY_PREFIX = 'cbio:child:';
8
+ export function getChildIdentitySecretName(publicKey) {
9
+ const hash = crypto.createHash('sha256').update(publicKey).digest('hex').substring(0, 12);
10
+ return CHILD_KEY_PREFIX + hash;
11
+ }
12
+ //# sourceMappingURL=childSecretNaming.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"childSecretNaming.js","sourceRoot":"","sources":["../../src/protocol/childSecretNaming.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAEtC,MAAM,CAAC,MAAM,gBAAgB,GAAG,aAAsB,CAAC;AAEvD,MAAM,UAAU,0BAA0B,CAAC,SAAiB;IACxD,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC1F,OAAO,gBAAgB,GAAG,IAAI,CAAC;AACnC,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Claw-biometric Core Identity. Runtime utilities over protocol primitives.
3
+ * getVaultPath (runtime). Re-exports protocol for consumers.
4
+ */
5
+ import { deriveRootAgentId } from '@the-ai-company/cbio-protocol';
6
+ import { getChildIdentitySecretName, CHILD_KEY_PREFIX } from './childSecretNaming.js';
7
+ export { deriveRootAgentId, getChildIdentitySecretName, CHILD_KEY_PREFIX };
8
+ export declare function getVaultPath(publicKey: string): string;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Claw-biometric Core Identity. Runtime utilities over protocol primitives.
3
+ * getVaultPath (runtime). Re-exports protocol for consumers.
4
+ */
5
+ import * as os from 'node:os';
6
+ import * as path from 'node:path';
7
+ import * as crypto from 'node:crypto';
8
+ import { deriveRootAgentId } from '@the-ai-company/cbio-protocol';
9
+ import { getChildIdentitySecretName, CHILD_KEY_PREFIX } from './childSecretNaming.js';
10
+ export { deriveRootAgentId, getChildIdentitySecretName, CHILD_KEY_PREFIX };
11
+ export function getVaultPath(publicKey) {
12
+ const hash = crypto.createHash('sha256').update(publicKey).digest('hex').substring(0, 12);
13
+ const baseDir = process.env.C_BIO_VAULT_DIR || path.join(os.homedir(), '.c-bio');
14
+ return path.join(baseDir, `vault_${hash}.enc`);
15
+ }
16
+ //# sourceMappingURL=identity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity.js","sourceRoot":"","sources":["../../src/protocol/identity.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,0BAA0B,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAEtF,OAAO,EAAE,iBAAiB,EAAE,0BAA0B,EAAE,gBAAgB,EAAE,CAAC;AAE3E,MAAM,UAAU,YAAY,CAAC,SAAiB;IAC1C,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC1F,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,QAAQ,CAAC,CAAC;IACjF,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,SAAS,IAAI,MAAM,CAAC,CAAC;AACnD,CAAC"}
@@ -1,20 +1,21 @@
1
- import { type CreatePersistentVaultCoreDependenciesOptions, type InitializedVaultCustody, type InitializeVaultCustodyOptions, type OwnerIdentityRecord, type VaultCore } from "../vault-core/index.js";
1
+ import { type CreatePersistentVaultCoreDependenciesOptions, type InitializedVaultCustody, type InitializeVaultCustodyOptions, type VaultCore } from "../vault-core/index.js";
2
2
  import { type VaultService, type VaultCustomFlowResolver } from "../vault-ingress/index.js";
3
3
  import type { IStorageProvider } from "../storage/provider.js";
4
- export interface InitializePersistentVaultOptions extends Omit<CreatePersistentVaultCoreDependenciesOptions, "vaultWorkingKey"> {
4
+ import type { CreatedIdentity } from "./identity.js";
5
+ export interface CreateVaultOptions extends Omit<CreatePersistentVaultCoreDependenciesOptions, "vaultWorkingKey"> {
5
6
  custody?: InitializeVaultCustodyOptions;
6
- bootstrapOwner: OwnerIdentityRecord;
7
+ ownerIdentity: CreatedIdentity;
7
8
  vault?: {
8
9
  customFlows?: VaultCustomFlowResolver;
9
10
  fetchImpl?: typeof fetch;
10
11
  };
11
12
  }
12
- export interface InitializedPersistentVault {
13
+ export interface CreatedVault {
13
14
  initializedCustody: InitializedVaultCustody;
14
15
  core: VaultCore;
15
16
  vault: VaultService;
16
17
  }
17
- export interface RecoverPersistentVaultOptions extends Omit<CreatePersistentVaultCoreDependenciesOptions, "vaultWorkingKey"> {
18
+ export interface RecoverVaultOptions extends Omit<CreatePersistentVaultCoreDependenciesOptions, "vaultWorkingKey"> {
18
19
  vaultRecoveryKey: string;
19
20
  custodyStorageKey?: string;
20
21
  vault?: {
@@ -22,10 +23,10 @@ export interface RecoverPersistentVaultOptions extends Omit<CreatePersistentVaul
22
23
  fetchImpl?: typeof fetch;
23
24
  };
24
25
  }
25
- export interface RecoveredPersistentVault {
26
+ export interface RecoveredVault {
26
27
  vaultWorkingKey: string;
27
28
  core: VaultCore;
28
29
  vault: VaultService;
29
30
  }
30
- export declare function initializePersistentVault(storage: IStorageProvider, options: InitializePersistentVaultOptions): Promise<InitializedPersistentVault>;
31
- export declare function recoverPersistentVault(storage: IStorageProvider, options: RecoverPersistentVaultOptions): Promise<RecoveredPersistentVault>;
31
+ export declare function createVault(storage: IStorageProvider, options: CreateVaultOptions): Promise<CreatedVault>;
32
+ export declare function recoverVault(storage: IStorageProvider, options: RecoverVaultOptions): Promise<RecoveredVault>;
@@ -1,21 +1,26 @@
1
1
  import { createVaultCore } from "../vault-core/core.js";
2
2
  import { createPersistentVaultCoreDependencies, initializeVaultCustody, recoverVaultWorkingKey, } from "../vault-core/index.js";
3
3
  import { wrapVaultCoreAsVaultService, } from "../vault-ingress/index.js";
4
- export async function initializePersistentVault(storage, options) {
4
+ export async function createVault(storage, options) {
5
5
  const initializedCustody = await initializeVaultCustody(storage, options.custody);
6
6
  const deps = createPersistentVaultCoreDependencies(storage, {
7
7
  ...options,
8
8
  vaultWorkingKey: initializedCustody.vaultWorkingKey,
9
9
  });
10
10
  const core = createVaultCore(deps);
11
- await core.bootstrapOwnerIdentity(options.bootstrapOwner);
11
+ const bootstrapOwner = {
12
+ vaultId: core.vaultId,
13
+ ownerId: options.ownerIdentity.identityId,
14
+ publicKey: options.ownerIdentity.publicKey,
15
+ };
16
+ await core.bootstrapOwnerIdentity(bootstrapOwner);
12
17
  return {
13
18
  initializedCustody,
14
19
  core,
15
20
  vault: wrapVaultCoreAsVaultService(core, options.vault),
16
21
  };
17
22
  }
18
- export async function recoverPersistentVault(storage, options) {
23
+ export async function recoverVault(storage, options) {
19
24
  const vaultWorkingKey = await recoverVaultWorkingKey(storage, options.vaultRecoveryKey, options.custodyStorageKey);
20
25
  const deps = createPersistentVaultCoreDependencies(storage, {
21
26
  ...options,
@@ -1 +1 @@
1
- {"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../../src/runtime/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EACL,qCAAqC,EACrC,sBAAsB,EACtB,sBAAsB,GAMvB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,2BAA2B,GAG5B,MAAM,2BAA2B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: string;
3
+ nickname?: string;
4
+ publicKey: string;
5
+ privateKey: string;
6
+ }
7
+ export interface CreateIdentityOptions {
8
+ nickname?: string;
9
+ }
10
+ export declare function createIdentity(options?: CreateIdentityOptions): CreatedIdentity;
@@ -0,0 +1,16 @@
1
+ import { generateIdentityKeys } from "../protocol/crypto.js";
2
+ import { deriveRootAgentId } from "../protocol/identity.js";
3
+ export function createIdentity(options = {}) {
4
+ const keyPair = generateIdentityKeys();
5
+ if (!keyPair.publicKey || !keyPair.privateKey) {
6
+ throw new Error("identity generation failed");
7
+ }
8
+ const nickname = options.nickname?.trim() ? options.nickname.trim() : undefined;
9
+ return {
10
+ identityId: deriveRootAgentId(keyPair.publicKey),
11
+ nickname,
12
+ publicKey: keyPair.publicKey,
13
+ privateKey: keyPair.privateKey,
14
+ };
15
+ }
16
+ //# sourceMappingURL=identity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity.js","sourceRoot":"","sources":["../../src/runtime/identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAa5D,MAAM,UAAU,cAAc,CAAC,UAAiC,EAAE;IAChE,MAAM,OAAO,GAAG,oBAAoB,EAAE,CAAC;IACvC,IAAI,CAAC,OAAO,CAAC,SAAS,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;QAC9C,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;IAChD,CAAC;IACD,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IAChF,OAAO;QACL,UAAU,EAAE,iBAAiB,CAAC,OAAO,CAAC,SAAS,CAAC;QAChD,QAAQ;QACR,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,UAAU,EAAE,OAAO,CAAC,UAAU;KAC/B,CAAC;AACJ,CAAC"}
@@ -3,11 +3,12 @@
3
3
  * Hard-cut public surface: vault core plus explicit clients only.
4
4
  */
5
5
  export { IdentityError, IdentityErrorCode } from "../errors.js";
6
- export { generateIdentityKeys, derivePublicKey, LocalSigner } from "../protocol/crypto.js";
6
+ export { derivePublicKey, LocalSigner } from "../protocol/crypto.js";
7
7
  export type { IStorageProvider } from "../storage/provider.js";
8
8
  export { FsStorageProvider } from "../storage/fs.js";
9
9
  export { MemoryStorageProvider } from "../storage/memory.js";
10
- export { initializePersistentVault, recoverPersistentVault, type InitializePersistentVaultOptions, type InitializedPersistentVault, type RecoverPersistentVaultOptions, type RecoveredPersistentVault, } from "./bootstrap.js";
10
+ export { createIdentity, type CreateIdentityOptions, type CreatedIdentity, } from "./identity.js";
11
+ export { createVault, recoverVault, type CreateVaultOptions, type CreatedVault, type RecoverVaultOptions, type RecoveredVault, } from "./bootstrap.js";
11
12
  export { createVaultCore, DefaultVaultCore, VaultCoreError, createDefaultVaultCoreDependencies, type CreateDefaultVaultCoreDependenciesOptions, type DefaultPolicyEngineOptions, DefaultPolicyEngine, createPersistentVaultCoreDependencies, initializeVaultCustody, recoverVaultWorkingKey, DEFAULT_VAULT_KEY_CUSTODY_BLOB_KEY, type InitializeVaultCustodyOptions, type InitializedVaultCustody, type CreatePersistentVaultCoreDependenciesOptions, PersistentVaultAuditLog, PersistentVaultCapabilityRegistry, PersistentVaultCapabilityRevocationRegistry, PersistentVaultCustomHttpFlowRegistry, PersistentVaultRateLimitStore, PersistentVaultReplayGuard, PersistentVaultSecretCustody, PersistentVaultSecretRepository, HttpDispatchExecutor, InMemoryAgentIdentityRegistry, InMemoryCapabilityRegistry, InMemoryCapabilityRevocationRegistry, InMemoryCustomHttpFlowRegistry, InMemoryRateLimitStore, InMemoryReplayGuard, InMemoryAuditLog, InMemoryOwnerIdentityRegistry, InMemorySecretCustody, InMemorySecretRepository, RandomIdGenerator, SignatureOwnerProofVerifier, type SignatureAgentProofVerifierOptions, SignatureAgentProofVerifier, SystemClock, type AgentCapability, type AgentIdentityRecord, type AgentProof, type OwnerAuditRequest, type OwnerExportSecretRequest, type OwnerRegisterCapabilityCommand, type OwnerRegisterAgentIdentityCommand, type OwnerRegisterCustomHttpFlowCommand, type OwnerSecretExport, type OwnerIdentityRecord, type CustomHttpFlowDefinition, type OwnerProof, type AuditEntry, type AuditLog, type AuditQuery, type Clock, type DispatchAuthorization, type DispatchInstruction, type DispatchRequest, type DispatchResult, type IdGenerator, type OwnerIdentityRegistry, type OwnerProofVerifier, type PolicyEngine, type RateLimitStore, type ReplayGuard, type CustomHttpFlowRegistry, type SecretAlias, type SecretCustody, type SecretId, type SecretRecord, type SecretRepository, type SecretVersion, type TrustedExecutor, type VaultCore, type VaultCoreDependencies, type VaultPrincipal, type VaultPrincipalKind, type VaultTargetBinding, type VaultWriteSecretCommand, type VaultId, type AgentIdentityRegistry, type AgentProofVerifier, type CapabilityRevocationRegistry, type CapabilityRegistry, } from "../vault-core/index.js";
12
13
  export { createOwnerClient, type OwnerClient, type OwnerIdentity, type OwnerSigner, type OwnerAuditQueryInput, type OwnerExportSecretInput, type OwnerRegisterCapabilityInput, type OwnerRegisterCustomHttpFlowInput, type OwnerRegisterAgentIdentityInput, type OwnerSecretTargetBinding, type OwnerWriteSecretInput, } from "../clients/owner/index.js";
13
14
  export { createAgentClient, type AgentClient, type AgentIdentity, type AgentCapabilityEnvelope, type AgentDispatchIntent, type AgentDispatchTransport, type AgentSigner, } from "../clients/agent/index.js";
@@ -3,10 +3,11 @@
3
3
  * Hard-cut public surface: vault core plus explicit clients only.
4
4
  */
5
5
  export { IdentityError, IdentityErrorCode } from "../errors.js";
6
- export { generateIdentityKeys, derivePublicKey, LocalSigner } from "../protocol/crypto.js";
6
+ export { derivePublicKey, LocalSigner } from "../protocol/crypto.js";
7
7
  export { FsStorageProvider } from "../storage/fs.js";
8
8
  export { MemoryStorageProvider } from "../storage/memory.js";
9
- export { initializePersistentVault, recoverPersistentVault, } from "./bootstrap.js";
9
+ export { createIdentity, } from "./identity.js";
10
+ export { createVault, recoverVault, } from "./bootstrap.js";
10
11
  export { createVaultCore, DefaultVaultCore, VaultCoreError, createDefaultVaultCoreDependencies, DefaultPolicyEngine, createPersistentVaultCoreDependencies, initializeVaultCustody, recoverVaultWorkingKey, DEFAULT_VAULT_KEY_CUSTODY_BLOB_KEY, PersistentVaultAuditLog, PersistentVaultCapabilityRegistry, PersistentVaultCapabilityRevocationRegistry, PersistentVaultCustomHttpFlowRegistry, PersistentVaultRateLimitStore, PersistentVaultReplayGuard, PersistentVaultSecretCustody, PersistentVaultSecretRepository, HttpDispatchExecutor, InMemoryAgentIdentityRegistry, InMemoryCapabilityRegistry, InMemoryCapabilityRevocationRegistry, InMemoryCustomHttpFlowRegistry, InMemoryRateLimitStore, InMemoryReplayGuard, InMemoryAuditLog, InMemoryOwnerIdentityRegistry, InMemorySecretCustody, InMemorySecretRepository, RandomIdGenerator, SignatureOwnerProofVerifier, SignatureAgentProofVerifier, SystemClock, } from "../vault-core/index.js";
11
12
  export { createOwnerClient, } from "../clients/owner/index.js";
12
13
  export { createAgentClient, } from "../clients/agent/index.js";
@@ -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;AAChE,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAE3F,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EACL,yBAAyB,EACzB,sBAAsB,GAKvB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,kCAAkC,EAGlC,m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ACnB,qCAAqC,EACrC,sBAAsB,EACtB,sBAAsB,EACtB,kCAAkC,EAIlC,uBAAuB,EACvB,iCAAiC,EACjC,2CAA2C,EAC3C,qCAAqC,EACrC,6BAA6B,EAC7B,0BAA0B,EAC1B,4BAA4B,EAC5B,+BAA+B,EAC/B,oBAAoB,EACpB,6BAA6B,EAC7B,0BAA0B,EAC1B,oCAAoC,EACpC,8BAA8B,EAC9B,sBAAsB,EACtB,mBAAmB,EACnB,gBAAgB,EAChB,6BAA6B,EAC7B,qBAAqB,EACrB,wBAAwB,EACxB,iBAAiB,EACjB,2BAA2B,EAE3B,2BAA2B,EAC3B,WAAW,GA8CZ,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,iBAAiB,GAWlB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,iBAAiB,GAOlB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,kBAAkB,EAClB,2BAA2B,EAC3B,2BAA2B,EAC3B,6BAA6B,EAC7B,8BAA8B,EAC9B,uBAAuB,GAWxB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,mBAAmB,GACpB,MAAM,8BAA8B,CAAC"}
@@ -5,11 +5,30 @@ Current product architecture is vault-first.
5
5
  Related design note:
6
6
 
7
7
  - [Custody Model](CUSTODY_MODEL.md)
8
+ - [Identity Model](IDENTITY_MODEL.md)
8
9
 
9
10
  Recommended persistent-vault lifecycle:
10
11
 
11
- - initialize through `initializePersistentVault(...)`
12
- - recover through `recoverPersistentVault(...)`
12
+ - create through `createVault(...)`
13
+ - recover through `recoverVault(...)`
14
+
15
+ ## Identity And Roles
16
+
17
+ The runtime distinguishes external identities from vault-local roles.
18
+
19
+ - `identity`
20
+ An external principal represented by a public/private keypair.
21
+ - `owner`
22
+ The single admin role that a vault binds to one identity.
23
+ - `agent`
24
+ A delegated role that a vault binds to an identity registered by the owner.
25
+
26
+ This means:
27
+
28
+ - outside the vault there are only identities
29
+ - inside a specific vault, identities are bound to roles such as `owner` or `agent`
30
+ - identities are independent; there is no built-in parent/child lineage between identities
31
+ - an identity may be the `owner` of one vault and an `agent` in another vault
13
32
 
14
33
  ## Public Modules
15
34
 
@@ -144,8 +144,8 @@ Future hardening such as MFA/TOTP may be added on top of this model, but it does
144
144
 
145
145
  The runtime now includes:
146
146
 
147
- 1. formal persistent-vault initialization through `initializePersistentVault(...)`
148
- 2. formal recovery-key based re-entry through `recoverPersistentVault(...)`
147
+ 1. formal vault creation through `createVault(...)`
148
+ 2. formal recovery-key based re-entry through `recoverVault(...)`
149
149
  3. explicit `vaultWorkingKey` terminology in the persistent dependency surface
150
150
  4. continued support for explicit owner export through `exportSecret(...)`
151
151
 
@@ -0,0 +1,122 @@
1
+ # Identity Model
2
+
3
+ This document defines the runtime's current identity model.
4
+
5
+ Its purpose is to separate three things that are easy to confuse:
6
+
7
+ - cryptographic identity
8
+ - human-readable naming
9
+ - vault-local role assignment
10
+
11
+ ## Core Rule
12
+
13
+ Outside the vault, there are only identities.
14
+
15
+ Inside a specific vault, identities may be bound to roles such as `owner` or `agent`.
16
+
17
+ This means:
18
+
19
+ - `owner` is not a different species of identity
20
+ - `agent` is not a different species of identity
21
+ - role comes from vault-local authorization state, not from the keypair itself
22
+
23
+ ## Identity
24
+
25
+ An `identity` is an external principal represented by a public/private keypair.
26
+
27
+ Properties:
28
+
29
+ - independent by default
30
+ - no built-in parent/child lineage
31
+ - no built-in inheritance
32
+ - no built-in "owner creates agent identity" relationship
33
+
34
+ An identity may participate in multiple vaults, and may hold different roles in different vaults.
35
+
36
+ Example:
37
+
38
+ - the same identity may be `owner` in vault A
39
+ - and `agent` in vault B
40
+
41
+ ## Identity Material
42
+
43
+ The runtime treats public/private keys as the cryptographic identity material.
44
+
45
+ - `publicKey`
46
+ used for verification and binding
47
+ - `privateKey`
48
+ held outside the vault by the identity holder
49
+
50
+ The vault should not treat a display label as the root identity truth.
51
+
52
+ ## Stable Identity ID
53
+
54
+ The runtime already has a stable public-key-derived identity primitive available through `deriveRootAgentId(...)`.
55
+
56
+ That derived value is useful for:
57
+
58
+ - stable machine identity
59
+ - local naming
60
+ - deterministic display-independent references
61
+
62
+ It should not, by itself, determine vault-local role.
63
+
64
+ ## Labels And Human-Readable Names
65
+
66
+ Human-friendly names are still useful.
67
+
68
+ Examples:
69
+
70
+ - `owner-1`
71
+ - `agent-prod`
72
+ - `crawler`
73
+ - `alice`
74
+
75
+ These should be treated as labels, aliases, or local names rather than the deepest identity truth.
76
+
77
+ The runtime now exposes this concept directly as optional `nickname` on `createIdentity(...)`.
78
+
79
+ In other words:
80
+
81
+ - public key or a stable derived id answers "who is this cryptographically"
82
+ - label answers "what do humans call this identity here"
83
+
84
+ ## Vault Roles
85
+
86
+ Vault roles are authorization bindings applied to identities inside a specific vault.
87
+
88
+ Current role model:
89
+
90
+ - `owner`
91
+ the single admin role for one vault
92
+ - `agent`
93
+ a delegated role registered and authorized by the owner
94
+
95
+ These roles are vault-local.
96
+
97
+ So:
98
+
99
+ - an identity does not become globally `owner`
100
+ - an identity does not become globally `agent`
101
+ - the same identity may appear with different roles in different vaults
102
+
103
+ ## Current Runtime Reality
104
+
105
+ Today the runtime API still uses fields such as:
106
+
107
+ - `ownerId`
108
+ - `agentId`
109
+
110
+ In practice, these currently behave closer to role-bound local identifiers or labels than to the deepest cryptographic identity root.
111
+
112
+ The long-term intended direction is:
113
+
114
+ 1. keep cryptographic identity separate from labels
115
+ 2. keep vault-local role separate from both
116
+ 3. avoid treating naming conventions such as prefixes as identity truth
117
+
118
+ ## Non-Goals
119
+
120
+ This model does not require every current API field to be renamed immediately.
121
+
122
+ Its purpose is to define the correct semantics first, so later API changes can converge on one stable interpretation.
package/docs/REFERENCE.md CHANGED
@@ -17,8 +17,9 @@ The main constructors are:
17
17
 
18
18
  - `createVaultCore(...)`
19
19
  - `createVaultService(...)`
20
- - `initializePersistentVault(...)`
21
- - `recoverPersistentVault(...)`
20
+ - `createIdentity(...)`
21
+ - `createVault(...)`
22
+ - `recoverVault(...)`
22
23
  - `createOwnerClient(...)`
23
24
  - `createAgentClient(...)`
24
25
  - `LocalVaultTransport`
@@ -29,14 +30,41 @@ Related design note:
29
30
 
30
31
  Recommended persistent-vault entrypoints:
31
32
 
32
- - `initializePersistentVault(...)`
33
- - `recoverPersistentVault(...)`
33
+ - `createVault(...)`
34
+ - `recoverVault(...)`
34
35
 
35
36
  Lower-level custody helpers:
36
37
 
37
38
  - `initializeVaultCustody(...)`
38
39
  - `recoverVaultWorkingKey(...)`
39
40
 
41
+ ## Terms
42
+
43
+ - `identity`
44
+ An external principal represented by a public/private keypair.
45
+ - `owner`
46
+ The single admin role that a vault binds to one identity.
47
+ - `agent`
48
+ A delegated role that a vault binds to an identity registered by the owner.
49
+
50
+ Role rules:
51
+
52
+ - outside the vault there are only identities
53
+ - inside a vault, identities are bound to roles such as `owner` or `agent`
54
+ - identities are independent; there is no built-in lineage or inheritance between identities
55
+ - the same identity may be `owner` in one vault and `agent` in another
56
+
57
+ ## Identity Creation
58
+
59
+ `createIdentity(...)` returns:
60
+
61
+ - `identityId`
62
+ - `publicKey`
63
+ - `privateKey`
64
+ - optional `nickname`
65
+
66
+ `nickname` is human-readable only. It does not affect the derived `identityId`, cryptographic verification, or vault-local role binding.
67
+
40
68
  ## Secret-Flow Model
41
69
 
42
70
  The current HTTP-facing API supports two explicit secret-flow classes:
@@ -93,7 +121,7 @@ The runtime treats this first owner as the single vault admin. Additional princi
93
121
 
94
122
  ## Owner Client
95
123
 
96
- `clients/owner` is the owner-facing caller surface.
124
+ `clients/owner` is the caller surface for the identity currently bound to the vault's single owner role.
97
125
 
98
126
  Current owner operations:
99
127
 
@@ -142,7 +170,7 @@ const exportedSecret = await owner.exportSecret({
142
170
 
143
171
  ## Agent Client
144
172
 
145
- `clients/agent` creates signed dispatch requests. It never receives plaintext secrets.
173
+ `clients/agent` creates signed dispatch requests for an identity currently bound to an agent role in that vault. It never receives plaintext secrets.
146
174
 
147
175
  Current dispatch capabilities use `dispatch_http` as the explicit secret-send operation.
148
176
  It is intended for standard secret-backed resource access, not for token mint / refresh / exchange / registration-finalize style acquisition flows.
@@ -294,8 +322,9 @@ If the custom flow mode includes secret acquisition, the owner also defines a re
294
322
  - persistent replay guard
295
323
  - persistent rate-limit state
296
324
  - persistent capability revocation state
297
-
298
- It still expects caller-provided identity registries unless you supply your own persistent registry adapters.
325
+ - persistent owner identity record
326
+ - persistent agent identity registry
327
+ - persistent capability registry
299
328
 
300
329
  ## Storage Provider
301
330
 
package/docs/es/README.md CHANGED
@@ -19,8 +19,9 @@ npm install @the-ai-company/cbio-node-runtime
19
19
  ```ts
20
20
  import {
21
21
  createVaultService,
22
- initializePersistentVault,
23
- recoverPersistentVault,
22
+ createIdentity,
23
+ createVault,
24
+ recoverVault,
24
25
  LocalVaultTransport,
25
26
  createOwnerClient,
26
27
  createAgentClient,
@@ -37,8 +38,8 @@ import {
37
38
 
38
39
  Ruta principal recomendada para vault persistente:
39
40
 
40
- - inicializar el vault persistente con `initializePersistentVault(...)`
41
- - recuperar el vault persistente con `recoverPersistentVault(...)` usando la recovery key
41
+ - crear el vault persistente con `createVault(...)`
42
+ - recuperar el vault persistente con `recoverVault(...)` usando la recovery key
42
43
 
43
44
  La API antigua centrada en `CbioIdentity` ya no es la superficie principal del producto.
44
45
 
package/docs/fr/README.md CHANGED
@@ -19,8 +19,9 @@ npm install @the-ai-company/cbio-node-runtime
19
19
  ```ts
20
20
  import {
21
21
  createVaultService,
22
- initializePersistentVault,
23
- recoverPersistentVault,
22
+ createIdentity,
23
+ createVault,
24
+ recoverVault,
24
25
  LocalVaultTransport,
25
26
  createOwnerClient,
26
27
  createAgentClient,
@@ -37,8 +38,8 @@ import {
37
38
 
38
39
  Chemin principal recommande pour un vault persistant :
39
40
 
40
- - initialiser le vault persistant avec `initializePersistentVault(...)`
41
- - restaurer le vault persistant avec `recoverPersistentVault(...)` via la recovery key
41
+ - creer le vault persistant avec `createVault(...)`
42
+ - restaurer le vault persistant avec `recoverVault(...)` via la recovery key
42
43
 
43
44
  L'ancienne API centree sur `CbioIdentity` n'est plus la surface principale du produit.
44
45
 
package/docs/ja/README.md CHANGED
@@ -19,8 +19,9 @@ npm install @the-ai-company/cbio-node-runtime
19
19
  ```ts
20
20
  import {
21
21
  createVaultService,
22
- initializePersistentVault,
23
- recoverPersistentVault,
22
+ createIdentity,
23
+ createVault,
24
+ recoverVault,
24
25
  LocalVaultTransport,
25
26
  createOwnerClient,
26
27
  createAgentClient,
@@ -37,8 +38,8 @@ import {
37
38
 
38
39
  推奨される persistent-vault の主経路:
39
40
 
40
- - `initializePersistentVault(...)` で persistent vault を初期化する
41
- - `recoverPersistentVault(...)` で recovery key を使って persistent vault を復旧する
41
+ - `createVault(...)` で persistent vault を作成する
42
+ - `recoverVault(...)` で recovery key を使って persistent vault を復旧する
42
43
 
43
44
  旧 `CbioIdentity` 中心 API は、もはや主要な公開面ではありません。
44
45
 
package/docs/ko/README.md CHANGED
@@ -19,8 +19,9 @@ npm install @the-ai-company/cbio-node-runtime
19
19
  ```ts
20
20
  import {
21
21
  createVaultService,
22
- initializePersistentVault,
23
- recoverPersistentVault,
22
+ createIdentity,
23
+ createVault,
24
+ recoverVault,
24
25
  LocalVaultTransport,
25
26
  createOwnerClient,
26
27
  createAgentClient,
@@ -37,8 +38,8 @@ import {
37
38
 
38
39
  권장되는 persistent-vault 주 경로:
39
40
 
40
- - `initializePersistentVault(...)` 로 persistent vault 를 초기화합니다
41
- - `recoverPersistentVault(...)` 로 recovery key 를 사용해 persistent vault 를 복구합니다
41
+ - `createVault(...)` 로 persistent vault 를 생성합니다
42
+ - `recoverVault(...)` 로 recovery key 를 사용해 persistent vault 를 복구합니다
42
43
 
43
44
  이전 `CbioIdentity` 중심 API 는 더 이상 주요 제품 표면이 아닙니다.
44
45
 
package/docs/pt/README.md CHANGED
@@ -19,8 +19,9 @@ npm install @the-ai-company/cbio-node-runtime
19
19
  ```ts
20
20
  import {
21
21
  createVaultService,
22
- initializePersistentVault,
23
- recoverPersistentVault,
22
+ createIdentity,
23
+ createVault,
24
+ recoverVault,
24
25
  LocalVaultTransport,
25
26
  createOwnerClient,
26
27
  createAgentClient,
@@ -37,8 +38,8 @@ import {
37
38
 
38
39
  Caminho principal recomendado para vault persistente:
39
40
 
40
- - inicializar o vault persistente com `initializePersistentVault(...)`
41
- - recuperar o vault persistente com `recoverPersistentVault(...)` usando a recovery key
41
+ - criar o vault persistente com `createVault(...)`
42
+ - recuperar o vault persistente com `recoverVault(...)` usando a recovery key
42
43
 
43
44
  A antiga API centrada em `CbioIdentity` nao e mais a superficie principal do produto.
44
45
 
package/docs/zh/README.md CHANGED
@@ -19,8 +19,9 @@ npm install @the-ai-company/cbio-node-runtime
19
19
  ```ts
20
20
  import {
21
21
  createVaultService,
22
- initializePersistentVault,
23
- recoverPersistentVault,
22
+ createIdentity,
23
+ createVault,
24
+ recoverVault,
24
25
  LocalVaultTransport,
25
26
  createOwnerClient,
26
27
  createAgentClient,
@@ -37,8 +38,8 @@ import {
37
38
 
38
39
  推荐的持久化主路径:
39
40
 
40
- - 通过 `initializePersistentVault(...)` 初始化持久化 vault
41
- - 通过 `recoverPersistentVault(...)` 用 recovery key 恢复持久化 vault
41
+ - 通过 `createVault(...)` 创建持久化 vault
42
+ - 通过 `recoverVault(...)` 用 recovery key 恢复持久化 vault
42
43
 
43
44
  ## 构建
44
45
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@the-ai-company/cbio-node-runtime",
3
- "version": "1.4.0",
3
+ "version": "1.6.0",
4
4
  "description": "Node.js runtime for cbio identity and credential vault. Library only, no CLI or TUI.",
5
5
  "type": "module",
6
6
  "main": "./dist/runtime/index.js",