@the-ai-company/cbio-node-runtime 1.45.5 → 1.47.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/dist/clients/owner/client.d.ts +10 -14
- package/dist/clients/owner/client.js +56 -182
- package/dist/clients/owner/client.js.map +1 -1
- package/dist/clients/owner/contracts.d.ts +9 -0
- package/dist/clients/owner/index.d.ts +1 -1
- package/dist/protocol/crypto.d.ts +5 -0
- package/dist/protocol/crypto.js +11 -0
- package/dist/protocol/crypto.js.map +1 -1
- package/dist/runtime/bootstrap.d.ts +14 -27
- package/dist/runtime/bootstrap.js +17 -63
- package/dist/runtime/bootstrap.js.map +1 -1
- package/dist/runtime/identity.d.ts +1 -23
- package/dist/runtime/identity.js +2 -74
- package/dist/runtime/identity.js.map +1 -1
- package/dist/runtime/index.d.ts +10 -24
- package/dist/runtime/index.js +7 -11
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/vault-metadata.d.ts +4 -16
- package/dist/runtime/vault-metadata.js +6 -41
- package/dist/runtime/vault-metadata.js.map +1 -1
- package/dist/vault-core/contracts.d.ts +3 -23
- package/dist/vault-core/contracts.js +0 -1
- package/dist/vault-core/contracts.js.map +1 -1
- package/dist/vault-core/core.d.ts +4 -4
- package/dist/vault-core/core.js +10 -76
- package/dist/vault-core/core.js.map +1 -1
- package/dist/vault-core/defaults.d.ts +4 -52
- package/dist/vault-core/defaults.js +2 -300
- package/dist/vault-core/defaults.js.map +1 -1
- package/dist/vault-core/index.d.ts +5 -5
- package/dist/vault-core/index.js +3 -3
- package/dist/vault-core/index.js.map +1 -1
- package/dist/vault-core/persistence.d.ts +5 -34
- package/dist/vault-core/persistence.js +8 -38
- package/dist/vault-core/persistence.js.map +1 -1
- package/dist/vault-core/ports.d.ts +2 -51
- package/dist/vault-ingress/index.d.ts +1 -2
- package/dist/vault-ingress/index.js +0 -5
- package/dist/vault-ingress/index.js.map +1 -1
- package/docs/api/README.md +8 -92
- package/docs/api/classes/IdentityError.md +2 -2
- package/docs/api/classes/VaultCore.md +320 -0
- package/docs/api/classes/VaultCoreError.md +1 -1
- package/docs/api/enumerations/IdentityErrorCode.md +1 -1
- package/docs/api/functions/createAgentClient.md +1 -1
- package/docs/api/functions/createIdentity.md +2 -2
- package/docs/api/functions/createOwnerHttpFlowBoundary.md +4 -4
- package/docs/api/functions/createPersistentVaultCoreDependencies.md +3 -67
- package/docs/api/functions/createStandardAcquireBoundary.md +3 -3
- package/docs/api/functions/createStandardDispatchBoundary.md +3 -3
- package/docs/api/functions/createVault.md +3 -3
- package/docs/api/functions/createVaultClient.md +2 -2
- package/docs/api/functions/createVaultCore.md +4 -4
- package/docs/api/functions/createVaultCoreDependencies.md +17 -0
- package/docs/api/functions/createVaultService.md +6 -6
- package/docs/api/functions/createWorkspaceStorage.md +1 -1
- package/docs/api/functions/deriveIdentityId.md +1 -1
- package/docs/api/functions/deriveVaultWorkingKeyFromPassword.md +24 -0
- package/docs/api/functions/getDefaultWorkspaceDir.md +1 -1
- package/docs/api/functions/handleVaultHttpDispatch.md +4 -4
- package/docs/api/functions/initializeVaultCustody.md +1 -1
- package/docs/api/functions/listVaults.md +5 -5
- package/docs/api/functions/readVaultProfile.md +3 -3
- package/docs/api/functions/recoverVault.md +4 -4
- package/docs/api/functions/recoverVaultWorkingKey.md +1 -1
- package/docs/api/functions/restoreIdentity.md +1 -1
- package/docs/api/functions/updateVaultMetadata.md +7 -7
- package/docs/api/functions/wrapVaultCoreAsVaultService.md +6 -6
- package/docs/api/functions/writeVaultProfile.md +3 -3
- package/docs/api/interfaces/AgentClient.md +3 -3
- package/docs/api/interfaces/AgentDispatchIntent.md +1 -1
- package/docs/api/interfaces/AgentDispatchTransport.md +4 -4
- package/docs/api/interfaces/AgentIdentity.md +1 -1
- package/docs/api/interfaces/AgentSigner.md +1 -1
- package/docs/api/interfaces/CbioRuntime.md +55 -396
- package/docs/api/interfaces/CreateAgentClientOptions.md +4 -4
- package/docs/api/interfaces/CreateIdentityOptions.md +1 -5
- package/docs/api/interfaces/CreatePersistentVaultCoreDependenciesOptions.md +9 -9
- package/docs/api/interfaces/CreateVaultClientOptions.md +5 -5
- package/docs/api/interfaces/CreateVaultOptions.md +16 -16
- package/docs/api/interfaces/CreatedVault.md +3 -3
- package/docs/api/interfaces/DefaultPolicyEngineOptions.md +3 -3
- package/docs/api/interfaces/IStorageProvider.md +1 -1
- package/docs/api/interfaces/InitializeVaultCustodyOptions.md +1 -1
- package/docs/api/interfaces/InitializedVaultCustody.md +1 -1
- package/docs/api/interfaces/OwnerDefineSecretTargetsInput.md +1 -1
- package/docs/api/interfaces/OwnerSecretTargetBinding.md +1 -1
- package/docs/api/interfaces/OwnerStoreSecretInput.md +1 -1
- package/docs/api/interfaces/OwnerWriteSecretInput.md +1 -1
- package/docs/api/interfaces/RecoverVaultOptions.md +10 -10
- package/docs/api/interfaces/RecoveredVault.md +3 -3
- package/docs/api/interfaces/RestoreIdentityOptions.md +1 -1
- package/docs/api/interfaces/Signer.md +1 -1
- package/docs/api/interfaces/VaultAuditQueryInput.md +1 -1
- package/docs/api/interfaces/VaultClient.md +36 -29
- package/docs/api/interfaces/{CreateDefaultVaultCoreDependenciesOptions.md → VaultCoreDependenciesOptions.md} +3 -3
- package/docs/api/interfaces/VaultCreateAgentInput.md +29 -0
- package/docs/api/interfaces/VaultDeleteSecretInput.md +1 -1
- package/docs/api/interfaces/VaultExportSecretInput.md +1 -1
- package/docs/api/interfaces/VaultGrantCapabilityInput.md +2 -2
- package/docs/api/interfaces/VaultIdentity.md +1 -1
- package/docs/api/interfaces/VaultListAgentsInput.md +1 -1
- package/docs/api/interfaces/VaultListCapabilitiesInput.md +1 -1
- package/docs/api/interfaces/{VaultPublicMetadata.md → VaultMetadata.md} +2 -2
- package/docs/api/interfaces/VaultObject.md +3 -3
- package/docs/api/interfaces/VaultProfile.md +7 -11
- package/docs/api/interfaces/VaultRegisterAgentInput.md +19 -1
- package/docs/api/interfaces/VaultRegisterFlowInput.md +7 -7
- package/docs/api/interfaces/VaultRevokeCapabilityInput.md +1 -1
- package/docs/api/interfaces/VaultSigner.md +1 -1
- package/docs/api/type-aliases/AgentCapabilityEnvelope.md +2 -2
- package/docs/api/type-aliases/CbioRuntimeModule.md +1 -1
- package/docs/api/variables/DEFAULT_VAULT_KEY_CUSTODY_BLOB_KEY.md +1 -1
- package/package.json +1 -1
- package/docs/api/classes/InMemoryReplayGuard.md +0 -45
- package/docs/api/enumerations/AuditAction.md +0 -95
- package/docs/api/enumerations/AuditOutcome.md +0 -29
- package/docs/api/enumerations/DispatchStatus.md +0 -23
- package/docs/api/functions/createChildIdentity.md +0 -25
- package/docs/api/functions/createDefaultVaultCoreDependencies.md +0 -77
- package/docs/api/functions/deriveChildIdentity.md +0 -41
- package/docs/api/functions/ensureIdentityPrivateVault.md +0 -21
- package/docs/api/functions/identityPrivateVaultChildrenKey.md +0 -17
- package/docs/api/functions/identityPrivateVaultPrefix.md +0 -17
- package/docs/api/functions/identityPrivateVaultProfileKey.md +0 -17
- package/docs/api/functions/identityPrivateVaultPublicSealedKey.md +0 -17
- package/docs/api/functions/listIdentities.md +0 -19
- package/docs/api/functions/readIdentityMetadata.md +0 -29
- package/docs/api/functions/readIdentityPrivateVaultChildrenState.md +0 -21
- package/docs/api/functions/readIdentityPrivateVaultProfile.md +0 -21
- package/docs/api/functions/readVaultPublicMetadata.md +0 -23
- package/docs/api/functions/toOwnerHttpFlowBoundary.md +0 -17
- package/docs/api/interfaces/AgentCapability.md +0 -103
- package/docs/api/interfaces/AgentIdentityRecord.md +0 -23
- package/docs/api/interfaces/AgentIdentityRegistry.md +0 -57
- package/docs/api/interfaces/AgentProof.md +0 -29
- package/docs/api/interfaces/AgentProofVerifier.md +0 -21
- package/docs/api/interfaces/AuditEntry.md +0 -89
- package/docs/api/interfaces/AuditLog.md +0 -37
- package/docs/api/interfaces/AuditQuery.md +0 -29
- package/docs/api/interfaces/CapabilityRegistry.md +0 -65
- package/docs/api/interfaces/CapabilityRevocationRegistry.md +0 -53
- package/docs/api/interfaces/ChildIdentity.md +0 -77
- package/docs/api/interfaces/Clock.md +0 -15
- package/docs/api/interfaces/CreateChildIdentityOptions.md +0 -19
- package/docs/api/interfaces/CustomHttpFlowDefinition.md +0 -71
- package/docs/api/interfaces/CustomHttpFlowRegistry.md +0 -41
- package/docs/api/interfaces/DeriveIdentityOptions.md +0 -11
- package/docs/api/interfaces/DispatchAuthorization.md +0 -35
- package/docs/api/interfaces/DispatchInstruction.md +0 -47
- package/docs/api/interfaces/DispatchRequest.md +0 -77
- package/docs/api/interfaces/DispatchResult.md +0 -53
- package/docs/api/interfaces/IdGenerator.md +0 -39
- package/docs/api/interfaces/IdentityPrivateVaultChildRecord.md +0 -35
- package/docs/api/interfaces/IdentityPrivateVaultChildrenState.md +0 -17
- package/docs/api/interfaces/IdentityPrivateVaultProfile.md +0 -35
- package/docs/api/interfaces/IssuerWriteSecretCommand.md +0 -59
- package/docs/api/interfaces/OwnerAuditRequest.md +0 -47
- package/docs/api/interfaces/OwnerDefineSecretTargetsCommand.md +0 -53
- package/docs/api/interfaces/OwnerDeleteSecretCommand.md +0 -47
- package/docs/api/interfaces/OwnerExportSecretRequest.md +0 -47
- package/docs/api/interfaces/OwnerHttpFlowBoundary.md +0 -51
- package/docs/api/interfaces/OwnerIdentityRecord.md +0 -23
- package/docs/api/interfaces/OwnerIdentityRegistry.md +0 -57
- package/docs/api/interfaces/OwnerListAgentsRequest.md +0 -41
- package/docs/api/interfaces/OwnerListCapabilitiesRequest.md +0 -47
- package/docs/api/interfaces/OwnerProof.md +0 -29
- package/docs/api/interfaces/OwnerProofVerifier.md +0 -181
- package/docs/api/interfaces/OwnerRegisterAgentIdentityCommand.md +0 -47
- package/docs/api/interfaces/OwnerRegisterCapabilityCommand.md +0 -47
- package/docs/api/interfaces/OwnerRegisterCustomHttpFlowCommand.md +0 -83
- package/docs/api/interfaces/OwnerRevokeCapabilityCommand.md +0 -53
- package/docs/api/interfaces/OwnerSecretExport.md +0 -35
- package/docs/api/interfaces/OwnerWriteSecretCommand.md +0 -65
- package/docs/api/interfaces/PolicyEngine.md +0 -81
- package/docs/api/interfaces/RateLimitStore.md +0 -33
- package/docs/api/interfaces/ReplayGuard.md +0 -21
- package/docs/api/interfaces/SecretAlias.md +0 -11
- package/docs/api/interfaces/SecretCustody.md +0 -57
- package/docs/api/interfaces/SecretId.md +0 -11
- package/docs/api/interfaces/SecretRecord.md +0 -53
- package/docs/api/interfaces/SecretRepository.md +0 -69
- package/docs/api/interfaces/SecretVersion.md +0 -11
- package/docs/api/interfaces/SignatureAgentProofVerifierOptions.md +0 -21
- package/docs/api/interfaces/TrustedExecutor.md +0 -31
- package/docs/api/interfaces/VaultAcquireSecretInput.md +0 -53
- package/docs/api/interfaces/VaultAcquireSecretResult.md +0 -41
- package/docs/api/interfaces/VaultAgentDispatchErrorResponse.md +0 -25
- package/docs/api/interfaces/VaultAgentDispatchRequest.md +0 -75
- package/docs/api/interfaces/VaultAgentDispatchResponse.md +0 -17
- package/docs/api/interfaces/VaultCore.md +0 -311
- package/docs/api/interfaces/VaultCoreDependencies.md +0 -95
- package/docs/api/interfaces/VaultCustomFlowResolver.md +0 -25
- package/docs/api/interfaces/VaultId.md +0 -11
- package/docs/api/interfaces/VaultPrincipal.md +0 -17
- package/docs/api/interfaces/VaultService.md +0 -251
- package/docs/api/interfaces/VaultTargetBinding.md +0 -35
- package/docs/api/type-aliases/IdentityPrivateVaultAccess.md +0 -7
- package/docs/api/type-aliases/RedactedResponseShape.md +0 -7
- package/docs/api/type-aliases/VaultAcquireSecretFlow.md +0 -7
- package/docs/api/type-aliases/VaultPrincipalKind.md +0 -7
- package/docs/api/type-aliases/VaultWriteSecretCommand.md +0 -7
|
@@ -1,16 +1,6 @@
|
|
|
1
|
-
import { type CreatePersistentVaultCoreDependenciesOptions,
|
|
1
|
+
import { type CreatePersistentVaultCoreDependenciesOptions, 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
|
-
import type { CreatedIdentity } from "./identity.js";
|
|
5
|
-
/**
|
|
6
|
-
* Derives the deterministic working key for a vault.
|
|
7
|
-
*
|
|
8
|
-
* @param privateKey - The owner's private key.
|
|
9
|
-
* @param vaultId - The unique ID of the vault.
|
|
10
|
-
* @returns A base64url-encoded 256-bit key.
|
|
11
|
-
* @internal Used by `createVault` and `recoverVault`.
|
|
12
|
-
*/
|
|
13
|
-
export declare function deriveVaultWorkingKey(privateKey: string, vaultId: string): string;
|
|
14
4
|
export interface VaultMetadata extends Record<string, any> {
|
|
15
5
|
nickname?: string;
|
|
16
6
|
ownerId?: string;
|
|
@@ -18,8 +8,8 @@ export interface VaultMetadata extends Record<string, any> {
|
|
|
18
8
|
export interface CreateVaultOptions extends Omit<CreatePersistentVaultCoreDependenciesOptions, "vaultWorkingKey" | "vaultId"> {
|
|
19
9
|
vaultId?: string;
|
|
20
10
|
nickname?: string;
|
|
21
|
-
|
|
22
|
-
|
|
11
|
+
metadata?: Record<string, any>;
|
|
12
|
+
password: string;
|
|
23
13
|
vault?: {
|
|
24
14
|
customFlows?: VaultCustomFlowResolver;
|
|
25
15
|
fetchImpl?: typeof fetch;
|
|
@@ -46,7 +36,7 @@ export interface VaultObject {
|
|
|
46
36
|
}
|
|
47
37
|
export interface RecoverVaultOptions extends Omit<CreatePersistentVaultCoreDependenciesOptions, "vaultWorkingKey" | "vaultId"> {
|
|
48
38
|
vaultId: string;
|
|
49
|
-
|
|
39
|
+
password: string;
|
|
50
40
|
vault?: {
|
|
51
41
|
customFlows?: VaultCustomFlowResolver;
|
|
52
42
|
fetchImpl?: typeof fetch;
|
|
@@ -58,13 +48,13 @@ export interface RecoveredVault extends VaultObject {
|
|
|
58
48
|
* Creates and bootstraps a new persistent vault.
|
|
59
49
|
*
|
|
60
50
|
* @param storage - Workspace storage (or path string) where vaults are stored.
|
|
61
|
-
* @param options - Configuration including
|
|
51
|
+
* @param options - Configuration including password and metadata.
|
|
62
52
|
* @returns A {@link CreatedVault} instance.
|
|
63
53
|
*
|
|
64
54
|
* @example
|
|
65
55
|
* ```ts
|
|
66
56
|
* const vault = await createVault({
|
|
67
|
-
*
|
|
57
|
+
* password: 'my-strong-password',
|
|
68
58
|
* nickname: 'production-secrets'
|
|
69
59
|
* });
|
|
70
60
|
* ```
|
|
@@ -80,14 +70,14 @@ export declare function createVault(options: CreateVaultOptions): Promise<Create
|
|
|
80
70
|
* Reopens an existing vault from storage.
|
|
81
71
|
*
|
|
82
72
|
* @param storage - Workspace storage where the vault was created.
|
|
83
|
-
* @param options - Recovery options (must include `vaultId` and `
|
|
73
|
+
* @param options - Recovery options (must include `vaultId` and `password`).
|
|
84
74
|
* @returns A {@link RecoveredVault} instance.
|
|
85
75
|
*
|
|
86
76
|
* @example
|
|
87
77
|
* ```ts
|
|
88
78
|
* const vault = await recoverVault({
|
|
89
79
|
* vaultId: 'vault_123',
|
|
90
|
-
*
|
|
80
|
+
* password: 'my-strong-password'
|
|
91
81
|
* });
|
|
92
82
|
* ```
|
|
93
83
|
*/
|
|
@@ -95,24 +85,21 @@ export declare function recoverVault(storage: IStorageProvider | string, options
|
|
|
95
85
|
/**
|
|
96
86
|
* Recovers an existing vault using the default workspace storage.
|
|
97
87
|
*
|
|
98
|
-
* @param options Recovery options including vaultId and
|
|
88
|
+
* @param options Recovery options including vaultId and password.
|
|
99
89
|
*/
|
|
100
90
|
export declare function recoverVault(options: RecoverVaultOptions): Promise<RecoveredVault>;
|
|
101
91
|
/**
|
|
102
|
-
* Lists all available vaults in the workspace
|
|
92
|
+
* Lists all available vaults in the workspace.
|
|
103
93
|
*
|
|
104
94
|
* @param storage - The root workspace storage provider.
|
|
105
|
-
* @returns A list of vault IDs
|
|
95
|
+
* @returns A list of vault IDs.
|
|
106
96
|
*/
|
|
107
|
-
export declare function listVaults(storage: IStorageProvider): Promise<
|
|
108
|
-
vaultId: string;
|
|
109
|
-
public: any;
|
|
110
|
-
}>>;
|
|
97
|
+
export declare function listVaults(storage: IStorageProvider): Promise<string[]>;
|
|
111
98
|
/**
|
|
112
99
|
* Updates the metadata (like nickname) of an existing vault.
|
|
113
100
|
*/
|
|
114
101
|
export declare function updateVaultMetadata(vault: CreatedVault | RecoveredVault, options: {
|
|
115
102
|
nickname?: string;
|
|
116
|
-
|
|
117
|
-
|
|
103
|
+
metadata?: Record<string, any>;
|
|
104
|
+
password: string;
|
|
118
105
|
}): Promise<void>;
|
|
@@ -1,29 +1,12 @@
|
|
|
1
1
|
import crypto from "node:crypto";
|
|
2
2
|
import { createVaultCore } from "../vault-core/core.js";
|
|
3
3
|
import { createPersistentVaultCoreDependencies, } from "../vault-core/index.js";
|
|
4
|
+
import { deriveVaultWorkingKeyFromPassword } from "../protocol/crypto.js";
|
|
4
5
|
import { wrapVaultCoreAsVaultService, } from "../vault-ingress/index.js";
|
|
5
6
|
import { createPrefixedStorage } from "../storage/prefix.js";
|
|
6
7
|
import { FsStorageProvider } from "../storage/fs.js";
|
|
7
|
-
import { readVaultProfile, writeVaultProfile
|
|
8
|
+
import { readVaultProfile, writeVaultProfile } from "./vault-metadata.js";
|
|
8
9
|
import { createWorkspaceStorage } from "./workspace-storage.js";
|
|
9
|
-
/**
|
|
10
|
-
* Derives the deterministic working key for a vault.
|
|
11
|
-
*
|
|
12
|
-
* @param privateKey - The owner's private key.
|
|
13
|
-
* @param vaultId - The unique ID of the vault.
|
|
14
|
-
* @returns A base64url-encoded 256-bit key.
|
|
15
|
-
* @internal Used by `createVault` and `recoverVault`.
|
|
16
|
-
*/
|
|
17
|
-
export function deriveVaultWorkingKey(privateKey, vaultId) {
|
|
18
|
-
return crypto
|
|
19
|
-
.createHash("sha256")
|
|
20
|
-
.update("cbio:vault-working-key:v1")
|
|
21
|
-
.update("\n")
|
|
22
|
-
.update(vaultId)
|
|
23
|
-
.update("\n")
|
|
24
|
-
.update(privateKey)
|
|
25
|
-
.digest("base64url");
|
|
26
|
-
}
|
|
27
10
|
function vaultStoragePrefix(vaultId) {
|
|
28
11
|
return `vaults/${vaultId}`;
|
|
29
12
|
}
|
|
@@ -47,33 +30,19 @@ export async function createVault(storageOrOptions, maybeOptions) {
|
|
|
47
30
|
const { storage: workspaceStorage, options } = resolveStorage(storageOrOptions, maybeOptions);
|
|
48
31
|
const vaultId = options.vaultId ?? `vault_${crypto.randomUUID()}`;
|
|
49
32
|
const storage = createPrefixedStorage(workspaceStorage, vaultStoragePrefix(vaultId));
|
|
50
|
-
const vaultWorkingKey =
|
|
33
|
+
const vaultWorkingKey = deriveVaultWorkingKeyFromPassword(options.password, vaultId);
|
|
51
34
|
const deps = createPersistentVaultCoreDependencies(storage, {
|
|
52
35
|
...options,
|
|
53
36
|
vaultId,
|
|
54
37
|
vaultWorkingKey,
|
|
55
38
|
});
|
|
56
39
|
const core = createVaultCore(deps);
|
|
57
|
-
const bootstrapOwner = {
|
|
58
|
-
vaultId: core.vaultId,
|
|
59
|
-
ownerId: options.ownerIdentity.identityId,
|
|
60
|
-
publicKey: options.ownerIdentity.publicKey,
|
|
61
|
-
};
|
|
62
|
-
await core.bootstrapOwnerIdentity(bootstrapOwner);
|
|
63
40
|
const nickname = options.nickname?.trim() ? options.nickname.trim() : undefined;
|
|
64
|
-
//
|
|
65
|
-
// 2. Discovery metadata (ownerId, nickname, custom tags) is stored in the public sealed profile for easy UI retrieval
|
|
41
|
+
// Single encrypted profile block. Hold the password to see everything.
|
|
66
42
|
await writeVaultProfile(storage, {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
},
|
|
71
|
-
sealedPublic: {
|
|
72
|
-
vaultId,
|
|
73
|
-
ownerId: options.ownerIdentity.identityId,
|
|
74
|
-
...options.publicMetadata,
|
|
75
|
-
nickname, // Nickname override takes precedence
|
|
76
|
-
}
|
|
43
|
+
vaultId,
|
|
44
|
+
nickname,
|
|
45
|
+
...options.metadata,
|
|
77
46
|
}, vaultWorkingKey, vaultId);
|
|
78
47
|
return {
|
|
79
48
|
core,
|
|
@@ -85,7 +54,7 @@ export async function createVault(storageOrOptions, maybeOptions) {
|
|
|
85
54
|
export async function recoverVault(storageOrOptions, maybeOptions) {
|
|
86
55
|
const { storage: workspaceStorage, options } = resolveStorage(storageOrOptions, maybeOptions);
|
|
87
56
|
const storage = createPrefixedStorage(workspaceStorage, vaultStoragePrefix(options.vaultId));
|
|
88
|
-
const vaultWorkingKey =
|
|
57
|
+
const vaultWorkingKey = deriveVaultWorkingKeyFromPassword(options.password, options.vaultId);
|
|
89
58
|
const deps = createPersistentVaultCoreDependencies(storage, {
|
|
90
59
|
...options,
|
|
91
60
|
vaultId: options.vaultId,
|
|
@@ -99,49 +68,34 @@ export async function recoverVault(storageOrOptions, maybeOptions) {
|
|
|
99
68
|
return {
|
|
100
69
|
core,
|
|
101
70
|
vault: wrapVaultCoreAsVaultService(core, options.vault),
|
|
102
|
-
nickname: profile.
|
|
71
|
+
nickname: profile.nickname,
|
|
103
72
|
storage,
|
|
104
73
|
};
|
|
105
74
|
}
|
|
106
75
|
/**
|
|
107
|
-
* Lists all available vaults in the workspace
|
|
76
|
+
* Lists all available vaults in the workspace.
|
|
108
77
|
*
|
|
109
78
|
* @param storage - The root workspace storage provider.
|
|
110
|
-
* @returns A list of vault IDs
|
|
79
|
+
* @returns A list of vault IDs.
|
|
111
80
|
*/
|
|
112
81
|
export async function listVaults(storage) {
|
|
113
82
|
if (!storage.list) {
|
|
114
83
|
return [];
|
|
115
84
|
}
|
|
116
|
-
|
|
117
|
-
const results = [];
|
|
118
|
-
for (const id of ids) {
|
|
119
|
-
const vaultStorage = createPrefixedStorage(storage, vaultStoragePrefix(id));
|
|
120
|
-
const publicData = await readVaultPublicMetadata(vaultStorage, id);
|
|
121
|
-
results.push({
|
|
122
|
-
vaultId: id,
|
|
123
|
-
public: publicData || {},
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
return results;
|
|
85
|
+
return await storage.list("vaults");
|
|
127
86
|
}
|
|
128
87
|
/**
|
|
129
88
|
* Updates the metadata (like nickname) of an existing vault.
|
|
130
89
|
*/
|
|
131
90
|
export async function updateVaultMetadata(vault, options) {
|
|
132
91
|
const vaultId = vault.core.vaultId.value;
|
|
133
|
-
const vaultWorkingKey =
|
|
134
|
-
// Read current profile to preserve
|
|
92
|
+
const vaultWorkingKey = deriveVaultWorkingKeyFromPassword(options.password, vaultId);
|
|
93
|
+
// Read current profile to preserve other fields
|
|
135
94
|
const current = await readVaultProfile(vault.storage, vaultWorkingKey, vaultId);
|
|
136
95
|
await writeVaultProfile(vault.storage, {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
vaultId,
|
|
141
|
-
ownerId: options.ownerIdentity.identityId, // Ensure ownerId is always populated for discovery
|
|
142
|
-
...(options.publicMetadata ?? {}), // Merge new custom fields if any
|
|
143
|
-
nickname: options.nickname ?? current?.sealedPublic.nickname,
|
|
144
|
-
}
|
|
96
|
+
...(current || {}),
|
|
97
|
+
nickname: options.nickname ?? current?.nickname,
|
|
98
|
+
...(options.metadata ?? {}),
|
|
145
99
|
}, vaultWorkingKey, vaultId);
|
|
146
100
|
}
|
|
147
101
|
//# sourceMappingURL=bootstrap.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../../src/runtime/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EACL,qCAAqC,
|
|
1
|
+
{"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../../src/runtime/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EACL,qCAAqC,GAGtC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE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OAAO,CAAC,OAAO,CAAC,CAAC;IAClF,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;IAClE,CAAC;IAED,OAAO;QACL,IAAI;QACJ,KAAK,EAAE,2BAA2B,CAAC,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC;QACvD,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,OAAO;KACR,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,OAAyB;IACxD,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;QAClB,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,MAAM,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,KAAoC,EACpC,OAAgF;IAEhF,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;IACzC,MAAM,eAAe,GAAG,iCAAiC,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAErF,gDAAgD;IAChD,MAAM,OAAO,GAAG,MAAM,gBAAgB,CAAC,KAAK,CAAC,OAAO,EAAE,eAAe,EAAE,OAAO,CAAC,CAAC;IAEhF,MAAM,iBAAiB,CAAC,KAAK,CAAC,OAAO,EAAE;QACrC,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC;QAClB,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,OAAO,EAAE,QAAQ;QAC/C,GAAG,CAAC,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAC;KAC5B,EAAE,eAAe,EAAE,OAAO,CAAC,CAAC;AAC/B,CAAC"}
|
|
@@ -7,19 +7,11 @@ export interface CreatedIdentity {
|
|
|
7
7
|
identityId: string;
|
|
8
8
|
/** A human-readable label (local only, not part of the crypto identity). */
|
|
9
9
|
nickname?: string;
|
|
10
|
-
/** The identity ID of the parent, if this is a child identity. */
|
|
11
|
-
parentIdentityId?: string;
|
|
12
|
-
/** The derivation index, if this is a child identity. */
|
|
13
|
-
childIndex?: number;
|
|
14
10
|
/** The base64url-encoded public key. */
|
|
15
11
|
publicKey: string;
|
|
16
12
|
/** The base64url-encoded Ed25519 PKCS#8 private key. */
|
|
17
13
|
privateKey: string;
|
|
18
14
|
}
|
|
19
|
-
export interface ChildIdentity extends CreatedIdentity {
|
|
20
|
-
parentIdentityId: string;
|
|
21
|
-
childIndex: number;
|
|
22
|
-
}
|
|
23
15
|
export interface CreateIdentityOptions {
|
|
24
16
|
nickname?: string;
|
|
25
17
|
}
|
|
@@ -30,7 +22,7 @@ export interface DeriveIdentityOptions {
|
|
|
30
22
|
nickname?: string;
|
|
31
23
|
}
|
|
32
24
|
/**
|
|
33
|
-
* Creates a new
|
|
25
|
+
* Creates a new identity with a fresh Ed25519 keypair.
|
|
34
26
|
*
|
|
35
27
|
* @param options - Configuration for the new identity.
|
|
36
28
|
* @returns A {@link CreatedIdentity} containing the ID and keys.
|
|
@@ -55,17 +47,3 @@ export declare function createIdentity(options?: CreateIdentityOptions): Created
|
|
|
55
47
|
* ```
|
|
56
48
|
*/
|
|
57
49
|
export declare function restoreIdentity(privateKey: string, options?: RestoreIdentityOptions): CreatedIdentity;
|
|
58
|
-
/**
|
|
59
|
-
* Deterministically derives a child identity from a parent's private key and an index.
|
|
60
|
-
*
|
|
61
|
-
* @param parent - The parent identity object or its private key string.
|
|
62
|
-
* @param childIndex - A non-negative integer for derivation.
|
|
63
|
-
* @param options - Optional nickname for the child.
|
|
64
|
-
* @returns A {@link ChildIdentity} with derivation metadata.
|
|
65
|
-
*
|
|
66
|
-
* @example
|
|
67
|
-
* ```ts
|
|
68
|
-
* const child = deriveChildIdentity(parentIdentity, 0, { nickname: 'sub-agent-0' });
|
|
69
|
-
* ```
|
|
70
|
-
*/
|
|
71
|
-
export declare function deriveChildIdentity(parent: CreatedIdentity | string, childIndex: number, options?: DeriveIdentityOptions): ChildIdentity;
|
package/dist/runtime/identity.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { createHmac, createPrivateKey, createPublicKey } from "node:crypto";
|
|
2
1
|
import { derivePublicKey, generateIdentityKeys } from "../protocol/crypto.js";
|
|
3
2
|
import { deriveIdentityId } from "../protocol/identity.js";
|
|
4
3
|
const ED25519_PKCS8_PREFIX = Buffer.from("302e020100300506032b657004220420", "hex");
|
|
@@ -17,12 +16,6 @@ function decodeEd25519Seed(privateKey) {
|
|
|
17
16
|
function encodeEd25519PrivateKey(seed) {
|
|
18
17
|
return Buffer.concat([ED25519_PKCS8_PREFIX, seed]).toString("base64url");
|
|
19
18
|
}
|
|
20
|
-
function toParentPrivateKey(parent) {
|
|
21
|
-
if (!parent) {
|
|
22
|
-
return undefined;
|
|
23
|
-
}
|
|
24
|
-
return typeof parent === "string" ? parent.trim() : parent.privateKey.trim();
|
|
25
|
-
}
|
|
26
19
|
function createRootIdentity(options = {}) {
|
|
27
20
|
const keyPair = generateIdentityKeys();
|
|
28
21
|
if (!keyPair.publicKey || !keyPair.privateKey) {
|
|
@@ -36,15 +29,8 @@ function createRootIdentity(options = {}) {
|
|
|
36
29
|
privateKey: keyPair.privateKey,
|
|
37
30
|
};
|
|
38
31
|
}
|
|
39
|
-
export function createIdentity(
|
|
40
|
-
|
|
41
|
-
(typeof parentOrOptions === "object" &&
|
|
42
|
-
parentOrOptions !== null &&
|
|
43
|
-
"privateKey" in parentOrOptions);
|
|
44
|
-
if (hasParent) {
|
|
45
|
-
throw new Error("createIdentity() only creates root identities; use createChildIdentity() or deriveChildIdentity()");
|
|
46
|
-
}
|
|
47
|
-
return createRootIdentity(parentOrOptions ?? {});
|
|
32
|
+
export function createIdentity(optionsOrParams) {
|
|
33
|
+
return createRootIdentity(optionsOrParams ?? {});
|
|
48
34
|
}
|
|
49
35
|
/**
|
|
50
36
|
* Restores an identity from an existing private key.
|
|
@@ -72,62 +58,4 @@ export function restoreIdentity(privateKey, options = {}) {
|
|
|
72
58
|
privateKey: normalizedPrivateKey,
|
|
73
59
|
};
|
|
74
60
|
}
|
|
75
|
-
function deriveIdentity(parentPrivateKey, childIndex, options = {}) {
|
|
76
|
-
const normalizedParentPrivateKey = parentPrivateKey.trim();
|
|
77
|
-
if (!normalizedParentPrivateKey) {
|
|
78
|
-
throw new Error("parent private key is required");
|
|
79
|
-
}
|
|
80
|
-
if (!Number.isInteger(childIndex) || childIndex < 0) {
|
|
81
|
-
throw new Error("childIndex must be a non-negative integer");
|
|
82
|
-
}
|
|
83
|
-
const parentSeed = decodeEd25519Seed(normalizedParentPrivateKey);
|
|
84
|
-
const childSeed = createHmac("sha256", parentSeed)
|
|
85
|
-
.update("cbio:identity:child:v1")
|
|
86
|
-
.update("\0")
|
|
87
|
-
.update(String(childIndex))
|
|
88
|
-
.digest();
|
|
89
|
-
const privateKey = encodeEd25519PrivateKey(childSeed);
|
|
90
|
-
const privateKeyObject = createPrivateKey({
|
|
91
|
-
key: Buffer.from(privateKey, "base64url"),
|
|
92
|
-
format: "der",
|
|
93
|
-
type: "pkcs8",
|
|
94
|
-
});
|
|
95
|
-
const publicKey = Buffer.from(createPublicKey(privateKeyObject).export({
|
|
96
|
-
type: "spki",
|
|
97
|
-
format: "der",
|
|
98
|
-
})).toString("base64url");
|
|
99
|
-
return {
|
|
100
|
-
identityId: deriveIdentityId(publicKey),
|
|
101
|
-
nickname: normalizeNickname(options.nickname),
|
|
102
|
-
publicKey,
|
|
103
|
-
privateKey,
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Deterministically derives a child identity from a parent's private key and an index.
|
|
108
|
-
*
|
|
109
|
-
* @param parent - The parent identity object or its private key string.
|
|
110
|
-
* @param childIndex - A non-negative integer for derivation.
|
|
111
|
-
* @param options - Optional nickname for the child.
|
|
112
|
-
* @returns A {@link ChildIdentity} with derivation metadata.
|
|
113
|
-
*
|
|
114
|
-
* @example
|
|
115
|
-
* ```ts
|
|
116
|
-
* const child = deriveChildIdentity(parentIdentity, 0, { nickname: 'sub-agent-0' });
|
|
117
|
-
* ```
|
|
118
|
-
*/
|
|
119
|
-
export function deriveChildIdentity(parent, childIndex, options = {}) {
|
|
120
|
-
const parentPrivateKey = toParentPrivateKey(parent);
|
|
121
|
-
if (!parentPrivateKey) {
|
|
122
|
-
throw new Error("parent private key is required");
|
|
123
|
-
}
|
|
124
|
-
const parentIdentity = typeof parent === "string"
|
|
125
|
-
? restoreIdentity(parentPrivateKey)
|
|
126
|
-
: parent;
|
|
127
|
-
return {
|
|
128
|
-
...deriveIdentity(parentPrivateKey, childIndex, options),
|
|
129
|
-
parentIdentityId: parentIdentity.identityId,
|
|
130
|
-
childIndex,
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
61
|
//# sourceMappingURL=identity.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../../src/runtime/identity.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../../src/runtime/identity.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AA6B3D,MAAM,oBAAoB,GAAG,MAAM,CAAC,IAAI,CAAC,kCAAkC,EAAE,KAAK,CAAC,CAAC;AACpF,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAE/B,SAAS,iBAAiB,CAAC,QAAiB;IAC1C,OAAO,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AACxD,CAAC;AAED,SAAS,iBAAiB,CAAC,UAAkB;IAC3C,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,WAA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AAI,CAAC,oBAAoB,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IACD,MAAM,SAAS,GAAG,eAAe,CAAC,oBAAoB,CAAC,CAAC;IACxD,MAAM,QAAQ,GAAG,iBAAiB,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACrD,OAAO;QACL,UAAU,EAAE,gBAAgB,CAAC,SAAS,CAAC;QACvC,QAAQ;QACR,SAAS;QACT,UAAU,EAAE,oBAAoB;KACjC,CAAC;AACJ,CAAC"}
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -1,26 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Runtime export.
|
|
3
|
-
*
|
|
3
|
+
* Main API: typed high-level runtime plus supported low-level building blocks.
|
|
4
4
|
*/
|
|
5
5
|
export { IdentityError, IdentityErrorCode } from "../errors.js";
|
|
6
|
-
export { derivePublicKey, LocalSigner, type Signer } from "../protocol/crypto.js";
|
|
6
|
+
export { derivePublicKey, LocalSigner, type Signer, deriveVaultWorkingKeyFromPassword } from "../protocol/crypto.js";
|
|
7
7
|
export { deriveIdentityId } from "../protocol/identity.js";
|
|
8
8
|
export type { IStorageProvider } from "../storage/provider.js";
|
|
9
9
|
export { FsStorageProvider } from "../storage/fs.js";
|
|
10
10
|
export { MemoryStorageProvider } from "../storage/memory.js";
|
|
11
|
-
export { createIdentity,
|
|
12
|
-
export {
|
|
13
|
-
export { readVaultProfile, writeVaultProfile, readVaultPublicMetadata, type VaultProfile, } from "./vault-metadata.js";
|
|
11
|
+
export { createIdentity, restoreIdentity, type CreateIdentityOptions, type RestoreIdentityOptions, type CreatedIdentity, } from "./identity.js";
|
|
12
|
+
export { readVaultProfile, writeVaultProfile, type VaultProfile, } from "./vault-metadata.js";
|
|
14
13
|
export { createWorkspaceStorage, getDefaultWorkspaceDir, } from "./workspace-storage.js";
|
|
15
|
-
export {
|
|
16
|
-
export {
|
|
17
|
-
export {
|
|
18
|
-
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, type VaultDeleteSecretInput, type VaultListAgentsInput, type VaultListCapabilitiesInput, type VaultRevokeCapabilityInput, } from "../clients/owner/index.js";
|
|
14
|
+
export { createVault, recoverVault, listVaults, updateVaultMetadata, type CreateVaultOptions, type CreatedVault, type RecoverVaultOptions, type RecoveredVault, type VaultObject, type VaultMetadata, } from "./bootstrap.js";
|
|
15
|
+
export { createVaultCore, VaultCore, VaultCoreError, createVaultCoreDependencies, type VaultCoreDependenciesOptions, type DefaultPolicyEngineOptions, DefaultPolicyEngine, createPersistentVaultCoreDependencies, initializeVaultCustody, recoverVaultWorkingKey, DEFAULT_VAULT_KEY_CUSTODY_BLOB_KEY, type InitializeVaultCustodyOptions, type InitializedVaultCustody, type CreatePersistentVaultCoreDependenciesOptions, PersistentVaultAgentIdentityRegistry, PersistentVaultAuditLog, PersistentVaultCapabilityRegistry, PersistentVaultCapabilityRevocationRegistry, PersistentVaultCustomHttpFlowRegistry, PersistentVaultRateLimitStore, PersistentVaultReplayGuard, PersistentVaultSecretCustody, PersistentVaultSecretRepository, } from "../vault-core/index.js";
|
|
16
|
+
export { createVaultClient, type VaultClient, type CreateVaultClientOptions, type VaultIdentity, type VaultSigner, type VaultAuditQueryInput, type OwnerDefineSecretTargetsInput, type VaultExportSecretInput, type VaultGrantCapabilityInput, type VaultRegisterFlowInput, type VaultRegisterAgentInput, type VaultCreateAgentInput, type OwnerSecretTargetBinding, type OwnerStoreSecretInput, type OwnerWriteSecretInput, type VaultDeleteSecretInput, type VaultListAgentsInput, type VaultListCapabilitiesInput, type VaultRevokeCapabilityInput, } from "../clients/owner/index.js";
|
|
19
17
|
export { createAgentClient, type AgentClient, type CreateAgentClientOptions, type AgentIdentity, type AgentCapabilityEnvelope, type AgentDispatchIntent, type AgentDispatchTransport, type AgentSigner, } from "../clients/agent/index.js";
|
|
20
|
-
export { createVaultService, wrapVaultCoreAsVaultService, createOwnerHttpFlowBoundary, createStandardAcquireBoundary, createStandardDispatchBoundary,
|
|
18
|
+
export { createVaultService, wrapVaultCoreAsVaultService, createOwnerHttpFlowBoundary, createStandardAcquireBoundary, createStandardDispatchBoundary, AgentDispatchHttpTransport, handleVaultHttpDispatch, } from "../vault-ingress/index.js";
|
|
21
19
|
export { LocalVaultTransport } from "../vault-ingress/defaults.js";
|
|
22
|
-
export { AgentDispatchHttpTransport } from "../vault-ingress/remote-transport.js";
|
|
23
|
-
export { handleVaultHttpDispatch } from "../vault-ingress/server-utils.js";
|
|
24
20
|
/**
|
|
25
21
|
* Main runtime interface.
|
|
26
22
|
*/
|
|
@@ -35,24 +31,14 @@ export interface CbioRuntime {
|
|
|
35
31
|
PersistentVaultCapabilityRevocationRegistry: typeof import("../vault-core/index.js").PersistentVaultCapabilityRevocationRegistry;
|
|
36
32
|
createIdentity: typeof import("./identity.js").createIdentity;
|
|
37
33
|
restoreIdentity: typeof import("./identity.js").restoreIdentity;
|
|
38
|
-
createChildIdentity: typeof import("./child-identity.js").createChildIdentity;
|
|
39
|
-
deriveChildIdentity: typeof import("./identity.js").deriveChildIdentity;
|
|
40
|
-
ensureIdentityPrivateVault: typeof import("./private-vault.js").ensureIdentityPrivateVault;
|
|
41
|
-
readIdentityPrivateVaultProfile: typeof import("./private-vault.js").readIdentityPrivateVaultProfile;
|
|
42
|
-
readIdentityPrivateVaultChildrenState: typeof import("./private-vault.js").readIdentityPrivateVaultChildrenState;
|
|
43
|
-
readIdentityMetadata: typeof import("./private-vault.js").readIdentityMetadata;
|
|
44
|
-
listIdentities: typeof import("./private-vault.js").listIdentities;
|
|
45
34
|
listVaults: typeof import("./bootstrap.js").listVaults;
|
|
46
35
|
createVault: typeof import("./bootstrap.js").createVault;
|
|
47
36
|
recoverVault: typeof import("./bootstrap.js").recoverVault;
|
|
48
|
-
|
|
37
|
+
deriveVaultWorkingKeyFromPassword: typeof import("../protocol/crypto.js").deriveVaultWorkingKeyFromPassword;
|
|
49
38
|
createVaultClient: typeof import("../clients/owner/index.js").createVaultClient;
|
|
50
39
|
createAgentClient: typeof import("../clients/agent/index.js").createAgentClient;
|
|
51
40
|
createVaultCore: typeof import("../vault-core/index.js").createVaultCore;
|
|
52
|
-
|
|
53
|
-
createPersistentVaultCoreDependencies: typeof import("../vault-core/index.js").createPersistentVaultCoreDependencies;
|
|
54
|
-
initializeVaultCustody: typeof import("../vault-core/index.js").initializeVaultCustody;
|
|
55
|
-
recoverVaultWorkingKey: typeof import("../vault-core/index.js").recoverVaultWorkingKey;
|
|
41
|
+
createVaultCoreDependencies: typeof import("../vault-core/index.js").createVaultCoreDependencies;
|
|
56
42
|
createVaultService: typeof import("../vault-ingress/index.js").createVaultService;
|
|
57
43
|
wrapVaultCoreAsVaultService: typeof import("../vault-ingress/index.js").wrapVaultCoreAsVaultService;
|
|
58
44
|
createOwnerHttpFlowBoundary: typeof import("../vault-ingress/index.js").createOwnerHttpFlowBoundary;
|
package/dist/runtime/index.js
CHANGED
|
@@ -1,23 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Runtime export.
|
|
3
|
-
*
|
|
3
|
+
* Main API: typed high-level runtime plus supported low-level building blocks.
|
|
4
4
|
*/
|
|
5
5
|
export { IdentityError, IdentityErrorCode } from "../errors.js";
|
|
6
|
-
export { derivePublicKey, LocalSigner } from "../protocol/crypto.js";
|
|
6
|
+
export { derivePublicKey, LocalSigner, deriveVaultWorkingKeyFromPassword } from "../protocol/crypto.js";
|
|
7
7
|
export { deriveIdentityId } from "../protocol/identity.js";
|
|
8
8
|
export { FsStorageProvider } from "../storage/fs.js";
|
|
9
9
|
export { MemoryStorageProvider } from "../storage/memory.js";
|
|
10
|
-
export { createIdentity,
|
|
11
|
-
export {
|
|
12
|
-
export { readVaultProfile, writeVaultProfile, readVaultPublicMetadata, } from "./vault-metadata.js";
|
|
10
|
+
export { createIdentity, restoreIdentity, } from "./identity.js";
|
|
11
|
+
export { readVaultProfile, writeVaultProfile, } from "./vault-metadata.js";
|
|
13
12
|
export { createWorkspaceStorage, getDefaultWorkspaceDir, } from "./workspace-storage.js";
|
|
14
|
-
export {
|
|
15
|
-
export {
|
|
16
|
-
export { createVaultCore, DefaultVaultCore, VaultCoreError, createDefaultVaultCoreDependencies, DefaultPolicyEngine, createPersistentVaultCoreDependencies, initializeVaultCustody, recoverVaultWorkingKey, DEFAULT_VAULT_KEY_CUSTODY_BLOB_KEY, PersistentVaultAgentIdentityRegistry, PersistentVaultAuditLog, PersistentVaultOwnerIdentityRegistry, 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";
|
|
13
|
+
export { createVault, recoverVault, listVaults, updateVaultMetadata, } from "./bootstrap.js";
|
|
14
|
+
export { createVaultCore, VaultCore, VaultCoreError, createVaultCoreDependencies, DefaultPolicyEngine, createPersistentVaultCoreDependencies, initializeVaultCustody, recoverVaultWorkingKey, DEFAULT_VAULT_KEY_CUSTODY_BLOB_KEY, PersistentVaultAgentIdentityRegistry, PersistentVaultAuditLog, PersistentVaultCapabilityRegistry, PersistentVaultCapabilityRevocationRegistry, PersistentVaultCustomHttpFlowRegistry, PersistentVaultRateLimitStore, PersistentVaultReplayGuard, PersistentVaultSecretCustody, PersistentVaultSecretRepository, } from "../vault-core/index.js";
|
|
17
15
|
export { createVaultClient, } from "../clients/owner/index.js";
|
|
18
16
|
export { createAgentClient, } from "../clients/agent/index.js";
|
|
19
|
-
export { createVaultService, wrapVaultCoreAsVaultService, createOwnerHttpFlowBoundary, createStandardAcquireBoundary, createStandardDispatchBoundary,
|
|
17
|
+
export { createVaultService, wrapVaultCoreAsVaultService, createOwnerHttpFlowBoundary, createStandardAcquireBoundary, createStandardDispatchBoundary, AgentDispatchHttpTransport, handleVaultHttpDispatch, } from "../vault-ingress/index.js";
|
|
20
18
|
export { LocalVaultTransport } from "../vault-ingress/defaults.js";
|
|
21
|
-
export { AgentDispatchHttpTransport } from "../vault-ingress/remote-transport.js";
|
|
22
|
-
export { handleVaultHttpDispatch } from "../vault-ingress/server-utils.js";
|
|
23
19
|
//# 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;AAChE,OAAO,EAAE,eAAe,EAAE,WAAW,EAAe,MAAM,uBAAuB,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;AAChE,OAAO,EAAE,eAAe,EAAE,WAAW,EAAe,iCAAiC,EAAE,MAAM,uBAAuB,CAAC;AACrH,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EACL,cAAc,EACd,eAAe,GAIhB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,gBAAgB,EAChB,iBAAiB,GAElB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,WAAW,EACX,YAAY,EACZ,UAAU,EACV,mBAAmB,GAOpB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,eAAe,EACf,SAAS,EACT,cAAc,EACd,2BAA2B,EAG3B,mBAAmB,EACnB,qCAAqC,EACrC,sBAAsB,EACtB,sBAAsB,EACtB,kCAAkC,EAIlC,oCAAoC,EACpC,uBAAuB,EACvB,iCAAiC,EACjC,2CAA2C,EAC3C,qCAAqC,EACrC,6BAA6B,EAC7B,0BAA0B,EAC1B,4BAA4B,EAC5B,+BAA+B,GAChC,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,iBAAiB,GAmBlB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,iBAAiB,GAQlB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,kBAAkB,EAClB,2BAA2B,EAC3B,2BAA2B,EAC3B,6BAA6B,EAC7B,8BAA8B,EAC9B,0BAA0B,EAC1B,uBAAuB,GACxB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC"}
|
|
@@ -1,18 +1,6 @@
|
|
|
1
1
|
import type { IStorageProvider } from "../storage/provider.js";
|
|
2
|
-
export interface VaultProfile {
|
|
3
|
-
|
|
4
|
-
nickname?: string;
|
|
5
|
-
};
|
|
6
|
-
sealedPrivate: Record<string, any>;
|
|
2
|
+
export interface VaultProfile extends Record<string, any> {
|
|
3
|
+
nickname?: string;
|
|
7
4
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* Used to encrypt 'public' metadata to prevent JSON tampering on disk.
|
|
11
|
-
*/
|
|
12
|
-
export declare function deriveVaultPublicWorkingKey(vaultId: string): string;
|
|
13
|
-
/**
|
|
14
|
-
* Reads the 'public' metadata of a vault. Requires vaultId but no private key.
|
|
15
|
-
*/
|
|
16
|
-
export declare function readVaultPublicMetadata(storage: IStorageProvider, vaultId: string): Promise<Record<string, any>>;
|
|
17
|
-
export declare function writeVaultProfile(storage: IStorageProvider, profile: VaultProfile, vaultWorkingKey: string, vaultId: string): Promise<void>;
|
|
18
|
-
export declare function readVaultProfile(storage: IStorageProvider, vaultWorkingKey: string, vaultId: string): Promise<VaultProfile | null>;
|
|
5
|
+
export declare function writeVaultProfile(storage: IStorageProvider, profile: VaultProfile, vaultWorkingKey: string, _vaultId: string): Promise<void>;
|
|
6
|
+
export declare function readVaultProfile(storage: IStorageProvider, vaultWorkingKey: string, _vaultId: string): Promise<VaultProfile | null>;
|
|
@@ -1,46 +1,11 @@
|
|
|
1
|
-
import { createHash } from "node:crypto";
|
|
2
1
|
import { SealedJsonRepository } from "../sealed/index.js";
|
|
3
2
|
const VAULT_SEALED_PROFILE_KEY = "vault/sealed/profile.sealed";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* Used to encrypt 'public' metadata to prevent JSON tampering on disk.
|
|
8
|
-
*/
|
|
9
|
-
export function deriveVaultPublicWorkingKey(vaultId) {
|
|
10
|
-
return createHash("sha256")
|
|
11
|
-
.update("cbio:vault-public-metadata:v1")
|
|
12
|
-
.update("\n")
|
|
13
|
-
.update(vaultId)
|
|
14
|
-
.digest("base64url");
|
|
3
|
+
export async function writeVaultProfile(storage, profile, vaultWorkingKey, _vaultId) {
|
|
4
|
+
const repo = new SealedJsonRepository(storage, VAULT_SEALED_PROFILE_KEY, vaultWorkingKey);
|
|
5
|
+
await repo.write(profile, "vault_profile");
|
|
15
6
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
export async function readVaultPublicMetadata(storage, vaultId) {
|
|
20
|
-
const publicWorkingKey = deriveVaultPublicWorkingKey(vaultId);
|
|
21
|
-
const repo = new SealedJsonRepository(storage, VAULT_PUBLIC_SEALED_PROFILE_KEY, publicWorkingKey);
|
|
22
|
-
const data = await repo.read(null).catch(() => null);
|
|
23
|
-
return data || {};
|
|
24
|
-
}
|
|
25
|
-
export async function writeVaultProfile(storage, profile, vaultWorkingKey, vaultId) {
|
|
26
|
-
// 1. Write Private Sealed Profile
|
|
27
|
-
const privateRepo = new SealedJsonRepository(storage, VAULT_SEALED_PROFILE_KEY, vaultWorkingKey);
|
|
28
|
-
await privateRepo.write(profile.sealedPrivate, "vault_profile_private");
|
|
29
|
-
// 2. Write Public Sealed Profile (encrypted for format protection, but publicly-read via side-channel)
|
|
30
|
-
const publicWorkingKey = deriveVaultPublicWorkingKey(vaultId);
|
|
31
|
-
const publicRepo = new SealedJsonRepository(storage, VAULT_PUBLIC_SEALED_PROFILE_KEY, publicWorkingKey);
|
|
32
|
-
await publicRepo.write(profile.sealedPublic, "vault_profile_public");
|
|
33
|
-
}
|
|
34
|
-
export async function readVaultProfile(storage, vaultWorkingKey, vaultId) {
|
|
35
|
-
const privateRepo = new SealedJsonRepository(storage, VAULT_SEALED_PROFILE_KEY, vaultWorkingKey);
|
|
36
|
-
const sealedPrivate = await privateRepo.read(null);
|
|
37
|
-
if (!sealedPrivate) {
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
40
|
-
const sealedPublic = await readVaultPublicMetadata(storage, vaultId);
|
|
41
|
-
return {
|
|
42
|
-
sealedPublic,
|
|
43
|
-
sealedPrivate,
|
|
44
|
-
};
|
|
7
|
+
export async function readVaultProfile(storage, vaultWorkingKey, _vaultId) {
|
|
8
|
+
const repo = new SealedJsonRepository(storage, VAULT_SEALED_PROFILE_KEY, vaultWorkingKey);
|
|
9
|
+
return await repo.read(null);
|
|
45
10
|
}
|
|
46
11
|
//# sourceMappingURL=vault-metadata.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vault-metadata.js","sourceRoot":"","sources":["../../src/runtime/vault-metadata.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"vault-metadata.js","sourceRoot":"","sources":["../../src/runtime/vault-metadata.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAM1D,MAAM,wBAAwB,GAAG,6BAA6B,CAAC;AAE/D,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,OAAyB,EACzB,OAAqB,EACrB,eAAuB,EACvB,QAAgB;IAEhB,MAAM,IAAI,GAAG,IAAI,oBAAoB,CAAe,OAAO,EAAE,wBAAwB,EAAE,eAAe,CAAC,CAAC;IACxG,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;AAC7C,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,OAAyB,EACzB,eAAuB,EACvB,QAAgB;IAEhB,MAAM,IAAI,GAAG,IAAI,oBAAoB,CAAe,OAAO,EAAE,wBAAwB,EAAE,eAAe,CAAC,CAAC;IACxG,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,IAAW,CAAC,CAAC;AACtC,CAAC"}
|