@git-stunts/git-cas 5.3.2 → 6.0.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/ADVANCED_GUIDE.md +1006 -0
- package/ARCHITECTURE.md +514 -0
- package/CHANGELOG.md +393 -5
- package/CODE_OF_CONDUCT.md +33 -0
- package/GUIDE.md +872 -0
- package/README.md +219 -325
- package/SECURITY.md +993 -0
- package/SUPPORT.md +54 -0
- package/UPGRADING.md +299 -0
- package/bin/actions.js +70 -21
- package/bin/agent/cli.js +51 -0
- package/bin/agent/commands/doctor.js +99 -0
- package/bin/agent/commands/index.js +1489 -0
- package/bin/agent/input.js +619 -0
- package/bin/agent/passphrase-source.js +123 -0
- package/bin/agent/protocol.js +193 -0
- package/bin/build-version.js +64 -0
- package/bin/credentials.js +425 -0
- package/bin/git-cas.js +595 -449
- package/bin/passphrase-source.js +266 -0
- package/bin/restore-output-target.js +28 -0
- package/bin/ui/blocks/asset-card.js +109 -0
- package/bin/ui/blocks/health-dashboard.js +149 -0
- package/bin/ui/blocks/heatmap-block.js +67 -0
- package/bin/ui/blocks/merkle-explorer.js +163 -0
- package/bin/ui/blocks/operation-feed.js +176 -0
- package/bin/ui/blocks/wizard-block.js +168 -0
- package/bin/ui/components/short-sha.js +36 -0
- package/bin/ui/context.js +56 -1
- package/bin/ui/dashboard-cmds.js +1578 -13
- package/bin/ui/dashboard-view.js +612 -145
- package/bin/ui/dashboard.js +998 -214
- package/bin/ui/encryption-card.js +69 -26
- package/bin/ui/heatmap.js +26 -54
- package/bin/ui/history-timeline.js +51 -19
- package/bin/ui/manifest-view.js +115 -60
- package/bin/ui/merkle-dag.js +83 -0
- package/bin/ui/progress.js +15 -9
- package/bin/ui/repo-treemap.js +328 -0
- package/bin/ui/shaders/bak-sneppen.js +180 -0
- package/bin/ui/shaders/fractal-zoom.js +99 -0
- package/bin/ui/shaders/merkle-tree.js +142 -0
- package/bin/ui/shaders/organic-flow.js +96 -0
- package/bin/ui/shaders/phase-portrait.js +93 -0
- package/bin/ui/store-wizard.js +296 -0
- package/bin/ui/theme.js +155 -0
- package/bin/ui/vault-report.js +495 -0
- package/build-info.json +4 -0
- package/docs/API.md +2224 -0
- package/docs/ENCRYPTION_MODES.md +33 -0
- package/docs/EXTENDING.md +174 -0
- package/docs/STORE_RESTORE_PIPELINE.md +199 -0
- package/docs/THREAT_MODEL.md +269 -0
- package/docs/VAULT_INTERNALS.md +251 -0
- package/docs/WALKTHROUGH.md +1868 -0
- package/docs/demo.gif +0 -0
- package/docs/releases/v6.0.0.md +104 -0
- package/examples/README.md +260 -0
- package/index.d.ts +208 -65
- package/index.js +163 -54
- package/package.json +35 -6
- package/scripts/migrate-encryption.js +680 -0
- package/src/domain/bytes/ByteLayout.js +96 -0
- package/src/domain/encoding/base64.js +91 -0
- package/src/domain/encoding/hex.js +14 -0
- package/src/domain/encoding/utf8.js +123 -0
- package/src/domain/encryption/schemes.js +132 -0
- package/src/domain/errors/CannotRemoveLastRecipientError.js +10 -0
- package/src/domain/errors/CasError.d.ts +28 -0
- package/src/domain/errors/CasError.js +43 -6
- package/src/domain/errors/Codes.js +54 -0
- package/src/domain/errors/DekUnwrapFailedError.js +10 -0
- package/src/domain/errors/GitError.js +10 -0
- package/src/domain/errors/GitPlumbingInitializationError.js +10 -0
- package/src/domain/errors/IntegrityError.js +10 -0
- package/src/domain/errors/InvalidChunkingStrategyError.js +10 -0
- package/src/domain/errors/InvalidOidError.js +10 -0
- package/src/domain/errors/InvalidOptionsError.js +10 -0
- package/src/domain/errors/ManifestIntegrityError.js +10 -0
- package/src/domain/errors/ManifestNotFoundError.js +10 -0
- package/src/domain/errors/NoMatchingRecipientError.js +10 -0
- package/src/domain/errors/PersistenceCapabilityRequiredError.js +10 -0
- package/src/domain/errors/PortNotImplementedError.js +10 -0
- package/src/domain/errors/RecipientAlreadyExistsError.js +10 -0
- package/src/domain/errors/RecipientNotFoundError.js +10 -0
- package/src/domain/errors/RestoreTooLargeError.js +10 -0
- package/src/domain/errors/RotationNotSupportedError.js +10 -0
- package/src/domain/errors/createCasError.js +68 -0
- package/src/domain/errors/index.js +20 -0
- package/src/domain/helpers/buildKdfMetadata.js +4 -2
- package/src/domain/helpers/codecBytes.js +34 -0
- package/src/domain/helpers/gitRefErrors.js +84 -0
- package/src/domain/helpers/scryptMaxmem.js +22 -0
- package/src/domain/outcomes/RestoreFailure.js +15 -0
- package/src/domain/outcomes/RestoreOutcome.js +11 -0
- package/src/domain/outcomes/RestoreSuccess.js +34 -0
- package/src/domain/outcomes/StoreFailure.js +15 -0
- package/src/domain/outcomes/StoreOutcome.js +11 -0
- package/src/domain/outcomes/StoreSuccess.js +17 -0
- package/src/domain/schemas/ManifestSchema.d.ts +40 -9
- package/src/domain/schemas/ManifestSchema.js +67 -13
- package/src/domain/services/CasService.d.ts +123 -38
- package/src/domain/services/CasService.js +298 -834
- package/src/domain/services/ChunkRepository.js +230 -0
- package/src/domain/services/CompressionStreams.js +72 -0
- package/src/domain/services/ConvergentEncryption.js +128 -0
- package/src/domain/services/GitTreeBuilder.js +86 -0
- package/src/domain/services/IntegrityVerifier.js +199 -0
- package/src/domain/services/KeyResolver.js +49 -42
- package/src/domain/services/ManifestDiff.js +56 -0
- package/src/domain/services/ManifestRepository.js +286 -0
- package/src/domain/services/PrefetchWindow.js +48 -0
- package/src/domain/services/RecipientService.js +157 -0
- package/src/domain/services/RedactingObservability.js +169 -0
- package/src/domain/services/RestorePipeline.js +68 -0
- package/src/domain/services/StorePipeline.js +201 -0
- package/src/domain/services/VaultKeyVerifier.js +101 -0
- package/src/domain/services/VaultMetadataCodec.js +206 -0
- package/src/domain/services/VaultMutationRetryPolicy.js +105 -0
- package/src/domain/services/VaultPersistence.js +410 -0
- package/src/domain/services/VaultPrivacyIndex.js +191 -0
- package/src/domain/services/VaultService.js +749 -251
- package/src/domain/services/VaultStateCache.js +225 -0
- package/src/domain/services/VaultTreeCodec.js +121 -0
- package/src/domain/services/rotateVaultPassphrase.js +37 -20
- package/src/domain/strategies/Aad.js +39 -0
- package/src/domain/strategies/FramedRecordCodec.js +204 -0
- package/src/domain/strategies/RestoreCompressed.js +40 -0
- package/src/domain/strategies/RestoreConvergent.js +44 -0
- package/src/domain/strategies/RestoreFramed.js +55 -0
- package/src/domain/strategies/RestorePlain.js +37 -0
- package/src/domain/strategies/RestoreStrategy.js +35 -0
- package/src/domain/strategies/RestoreWhole.js +135 -0
- package/src/domain/strategies/StoreConvergent.js +28 -0
- package/src/domain/strategies/StoreFramed.js +39 -0
- package/src/domain/strategies/StorePlain.js +20 -0
- package/src/domain/strategies/StoreStrategy.js +61 -0
- package/src/domain/strategies/StoreWhole.js +34 -0
- package/src/domain/value-objects/Chunk.js +1 -2
- package/src/domain/value-objects/EncryptionMetadata.js +87 -0
- package/src/domain/value-objects/Manifest.d.ts +40 -4
- package/src/domain/value-objects/Manifest.js +61 -20
- package/src/domain/value-objects/Oid.js +45 -0
- package/src/domain/value-objects/Slug.js +124 -0
- package/src/domain/value-objects/StoreEncryptionConfig.js +114 -0
- package/src/helpers/aesGcmMeta.js +55 -0
- package/src/helpers/canonicalBase64.js +1 -0
- package/src/helpers/kdfPolicy.js +194 -0
- package/src/infrastructure/adapters/BunCryptoAdapter.js +124 -8
- package/src/infrastructure/adapters/FileIOHelper.js +178 -13
- package/src/infrastructure/adapters/GitPersistenceAdapter.js +235 -42
- package/src/infrastructure/adapters/GitPlumbingFactoryAdapter.js +62 -0
- package/src/infrastructure/adapters/GitRefAdapter.js +19 -6
- package/src/infrastructure/adapters/NodeCompressionAdapter.js +64 -0
- package/src/infrastructure/adapters/NodeCryptoAdapter.js +130 -10
- package/src/infrastructure/adapters/WebCryptoAdapter.js +187 -77
- package/src/infrastructure/chunkers/CdcChunker.js +53 -19
- package/src/infrastructure/chunkers/FixedChunker.js +15 -7
- package/src/infrastructure/chunkers/resolveChunker.js +3 -1
- package/src/infrastructure/codecs/CborCodec.js +3 -3
- package/src/infrastructure/codecs/JsonCodec.js +5 -5
- package/src/infrastructure/createGitPlumbing.js +22 -0
- package/src/package-version.js +1 -0
- package/src/ports/ChunkingPort.js +3 -3
- package/src/ports/CodecPort.js +4 -4
- package/src/ports/CompressionPort.js +57 -0
- package/src/ports/CryptoPort.js +138 -50
- package/src/ports/GitPersistencePort.js +32 -2
- package/src/ports/GitPlumbingFactoryPort.js +16 -0
- package/src/ports/GitRefPort.js +1 -1
- package/src/types/ambient.d.ts +10 -5
- package/test/CONVENTIONS.md +94 -0
- package/test/cycles/README.md +13 -0
package/index.d.ts
CHANGED
|
@@ -4,27 +4,35 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import Manifest from "./src/domain/value-objects/Manifest.js";
|
|
7
|
-
import type { EncryptionMeta, ManifestData, CompressionMeta, KdfParams, SubManifestRef, RecipientEntry } from "./src/domain/value-objects/Manifest.js";
|
|
7
|
+
import type { EncryptionMeta, ManifestData, CompressionMeta, KdfParams, SubManifestRef, RecipientEntry, EncryptionScheme } from "./src/domain/value-objects/Manifest.js";
|
|
8
8
|
import Chunk from "./src/domain/value-objects/Chunk.js";
|
|
9
9
|
import CasService from "./src/domain/services/CasService.js";
|
|
10
|
-
import
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
export
|
|
10
|
+
import CasError from "./src/domain/errors/CasError.js";
|
|
11
|
+
import type { CryptoPort, CodecPort, GitPersistencePort, ObservabilityPort, CasServiceOptions, DeriveKeyOptions, DeriveKeyResult, StoreEncryptionOptions, VerifyIntegrityOptions } from "./src/domain/services/CasService.js";
|
|
12
|
+
|
|
13
|
+
export { CasService, CasError, Manifest, Chunk };
|
|
14
|
+
/** Type alias mapping the runtime `CompressionPort` export to its base class declaration. */
|
|
15
|
+
export type CompressionPort = CompressionPortBase;
|
|
16
|
+
|
|
17
|
+
export type { EncryptionMeta, ManifestData, CompressionMeta, KdfParams, SubManifestRef, RecipientEntry, EncryptionScheme };
|
|
18
|
+
export type { CryptoPort, CodecPort, GitPersistencePort, ObservabilityPort, CasServiceOptions, DeriveKeyOptions, DeriveKeyResult, StoreEncryptionOptions, VerifyIntegrityOptions };
|
|
19
|
+
|
|
20
|
+
/** Abstract port for compression and decompression of buffers and streams. */
|
|
21
|
+
export declare class CompressionPortBase {
|
|
22
|
+
compressBuffer(buffer: Uint8Array): Promise<Uint8Array>;
|
|
23
|
+
decompressBuffer(buffer: Uint8Array): Promise<Uint8Array>;
|
|
24
|
+
compressStream(source: AsyncIterable<Uint8Array>): AsyncIterable<Uint8Array>;
|
|
25
|
+
decompressStream(source: AsyncIterable<Uint8Array>): AsyncIterable<Uint8Array>;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Node.js compression adapter using gzip/gunzip. */
|
|
29
|
+
export declare class NodeCompressionAdapter extends CompressionPortBase {}
|
|
22
30
|
|
|
23
31
|
/** Abstract port for splitting a byte stream into chunks. */
|
|
24
32
|
export declare class ChunkingPort {
|
|
25
33
|
get strategy(): string;
|
|
26
34
|
get params(): Record<string, unknown>;
|
|
27
|
-
chunk(source: AsyncIterable<
|
|
35
|
+
chunk(source: AsyncIterable<Uint8Array>): AsyncIterable<Uint8Array>;
|
|
28
36
|
}
|
|
29
37
|
|
|
30
38
|
/** Fixed-size chunking adapter. */
|
|
@@ -40,35 +48,61 @@ export declare class CdcChunker extends ChunkingPort {
|
|
|
40
48
|
minChunkSize?: number;
|
|
41
49
|
maxChunkSize?: number;
|
|
42
50
|
targetChunkSize?: number;
|
|
51
|
+
normalized?: boolean;
|
|
43
52
|
});
|
|
44
53
|
get strategy(): "cdc";
|
|
45
|
-
get params(): { target: number; min: number; max: number };
|
|
54
|
+
get params(): { target: number; min: number; max: number; normalized: boolean };
|
|
46
55
|
}
|
|
47
56
|
|
|
48
57
|
/** Abstract port for cryptographic operations. */
|
|
49
58
|
export declare class CryptoPortBase {
|
|
50
|
-
sha256(buf:
|
|
51
|
-
randomBytes(n: number):
|
|
59
|
+
sha256(buf: Uint8Array): Promise<string>;
|
|
60
|
+
randomBytes(n: number): Uint8Array;
|
|
52
61
|
encryptBuffer(
|
|
53
|
-
buffer:
|
|
54
|
-
key:
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
62
|
+
buffer: Uint8Array,
|
|
63
|
+
key: Uint8Array,
|
|
64
|
+
aad?: Uint8Array,
|
|
65
|
+
): { buf: Uint8Array; meta: EncryptionMeta } | Promise<{ buf: Uint8Array; meta: EncryptionMeta }>;
|
|
66
|
+
decryptBuffer(buffer: Uint8Array, key: Uint8Array, meta: EncryptionMeta, aad?: Uint8Array): Uint8Array | Promise<Uint8Array>;
|
|
67
|
+
createEncryptionStream(key: Uint8Array, aad?: Uint8Array): {
|
|
68
|
+
encrypt: (source: AsyncIterable<Uint8Array>) => AsyncIterable<Uint8Array>;
|
|
59
69
|
finalize: () => EncryptionMeta;
|
|
60
70
|
};
|
|
71
|
+
createDecryptionStream(key: Uint8Array, meta: EncryptionMeta, aad?: Uint8Array): {
|
|
72
|
+
decrypt: (source: AsyncIterable<Uint8Array>) => AsyncIterable<Uint8Array>;
|
|
73
|
+
};
|
|
74
|
+
hmacSha256(key: Uint8Array, data: Uint8Array): Uint8Array | Promise<Uint8Array>;
|
|
75
|
+
encryptBufferWithNonce(
|
|
76
|
+
buffer: Uint8Array,
|
|
77
|
+
key: Uint8Array,
|
|
78
|
+
nonce: Uint8Array,
|
|
79
|
+
): { buf: Uint8Array; tag: Uint8Array } | Promise<{ buf: Uint8Array; tag: Uint8Array }>;
|
|
80
|
+
decryptBufferWithNonceTag(
|
|
81
|
+
buffer: Uint8Array,
|
|
82
|
+
key: Uint8Array,
|
|
83
|
+
nonce: Uint8Array,
|
|
84
|
+
tag: Uint8Array,
|
|
85
|
+
): Uint8Array | Promise<Uint8Array>;
|
|
61
86
|
deriveKey(options: DeriveKeyOptions): Promise<DeriveKeyResult>;
|
|
62
87
|
}
|
|
63
88
|
|
|
64
89
|
/** Abstract port for persisting data to Git's object database. */
|
|
65
90
|
export declare class GitPersistencePortBase {
|
|
66
|
-
writeBlob(content:
|
|
91
|
+
writeBlob(content: Uint8Array): Promise<string>;
|
|
67
92
|
writeTree(entries: string[]): Promise<string>;
|
|
68
|
-
readBlob(oid: string): Promise<
|
|
93
|
+
readBlob(oid: string): Promise<Uint8Array>;
|
|
94
|
+
readBlobStream(oid: string): Promise<AsyncIterable<Uint8Array>>;
|
|
69
95
|
readTree(
|
|
70
96
|
treeOid: string,
|
|
71
97
|
): Promise<Array<{ mode: string; type: string; oid: string; name: string }>>;
|
|
98
|
+
readTreeEntry(
|
|
99
|
+
treeOid: string,
|
|
100
|
+
treePath: string,
|
|
101
|
+
): Promise<{ mode: string; type: string; oid: string; name: string } | null>;
|
|
102
|
+
iterateTree(
|
|
103
|
+
treeOid: string,
|
|
104
|
+
): AsyncIterable<{ mode: string; type: string; oid: string; name: string }>;
|
|
105
|
+
setMaxBlobSize?(maxBlobSize: number): void;
|
|
72
106
|
}
|
|
73
107
|
|
|
74
108
|
/** Abstract port for Git ref and commit operations. */
|
|
@@ -83,6 +117,7 @@ export declare class GitRefPortBase {
|
|
|
83
117
|
updateRef(options: {
|
|
84
118
|
ref: string;
|
|
85
119
|
newOid: string;
|
|
120
|
+
/** Expected current OID for CAS; null means the ref must not exist. */
|
|
86
121
|
expectedOldOid?: string | null;
|
|
87
122
|
}): Promise<void>;
|
|
88
123
|
}
|
|
@@ -90,6 +125,7 @@ export declare class GitRefPortBase {
|
|
|
90
125
|
/** Git-backed implementation of the persistence port. */
|
|
91
126
|
export declare class GitPersistenceAdapter extends GitPersistencePortBase {
|
|
92
127
|
constructor(options: { plumbing: unknown; policy?: unknown });
|
|
128
|
+
setMaxBlobSize(maxBlobSize: number): void;
|
|
93
129
|
}
|
|
94
130
|
|
|
95
131
|
/** Git-backed implementation of the ref port. */
|
|
@@ -104,8 +140,8 @@ export declare class NodeCryptoAdapter extends CryptoPortBase {
|
|
|
104
140
|
|
|
105
141
|
/** Abstract codec interface for manifest serialization. */
|
|
106
142
|
export declare class CodecPortBase {
|
|
107
|
-
encode(data: object):
|
|
108
|
-
decode(buffer:
|
|
143
|
+
encode(data: object): Uint8Array;
|
|
144
|
+
decode(buffer: Uint8Array): object;
|
|
109
145
|
get extension(): string;
|
|
110
146
|
}
|
|
111
147
|
|
|
@@ -171,16 +207,38 @@ export interface ContentAddressableStoreOptions {
|
|
|
171
207
|
concurrency?: number;
|
|
172
208
|
chunking?: ChunkingConfig;
|
|
173
209
|
chunker?: ChunkingPort;
|
|
210
|
+
/** Compression adapter (default NodeCompressionAdapter). */
|
|
211
|
+
compressionAdapter?: CompressionPortBase;
|
|
174
212
|
/** Maximum bytes to buffer during encrypted/compressed restore. @default 536870912 (512 MiB) */
|
|
175
213
|
maxRestoreBufferSize?: number;
|
|
214
|
+
/** Safety limit for readBlob metadata in bytes. @default 10485760 (10 MiB) */
|
|
215
|
+
maxBlobSize?: number;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/** Options for {@link ContentAddressableStore.open}. */
|
|
219
|
+
export interface ContentAddressableStoreOpenOptions extends Omit<ContentAddressableStoreOptions, "plumbing"> {
|
|
220
|
+
/** Git working directory used to construct the default Git plumbing adapter. @default "." */
|
|
221
|
+
cwd?: string;
|
|
222
|
+
/** Optional shell-runner environment override for Git plumbing. */
|
|
223
|
+
env?: string;
|
|
176
224
|
}
|
|
177
225
|
|
|
226
|
+
/** Options for codec-specific facade factories. */
|
|
227
|
+
export type ContentAddressableStoreCodecFactoryOptions = Omit<ContentAddressableStoreOptions, "codec">;
|
|
228
|
+
|
|
178
229
|
/** A single vault entry. */
|
|
179
230
|
export interface VaultEntry {
|
|
180
231
|
slug: string;
|
|
181
232
|
treeOid: string;
|
|
182
233
|
}
|
|
183
234
|
|
|
235
|
+
/** Encrypted vault key verifier stored in .vault.json. */
|
|
236
|
+
export interface VaultEncryptionVerifier {
|
|
237
|
+
version: 1;
|
|
238
|
+
ciphertext: string;
|
|
239
|
+
meta: EncryptionMeta;
|
|
240
|
+
}
|
|
241
|
+
|
|
184
242
|
/** Vault metadata stored in .vault.json. */
|
|
185
243
|
export interface VaultMetadata {
|
|
186
244
|
version: number;
|
|
@@ -197,6 +255,14 @@ export interface VaultMetadata {
|
|
|
197
255
|
parallelization?: number;
|
|
198
256
|
keyLength: number;
|
|
199
257
|
};
|
|
258
|
+
/** Encrypted verifier used to authenticate an empty encrypted vault. */
|
|
259
|
+
verifier?: VaultEncryptionVerifier;
|
|
260
|
+
};
|
|
261
|
+
/** Privacy mode configuration. When enabled, vault slugs are HMAC-masked in the Git tree. */
|
|
262
|
+
privacy?: {
|
|
263
|
+
enabled: boolean;
|
|
264
|
+
/** Encryption metadata for the privacy index blob. */
|
|
265
|
+
indexMeta?: { nonce: string; tag: string };
|
|
200
266
|
};
|
|
201
267
|
}
|
|
202
268
|
|
|
@@ -224,7 +290,10 @@ export declare class VaultService {
|
|
|
224
290
|
validateSlug(slug: string): void;
|
|
225
291
|
|
|
226
292
|
/** Reads the current vault state from refs/cas/vault. */
|
|
227
|
-
readState(
|
|
293
|
+
readState(options?: {
|
|
294
|
+
/** Vault encryption key (required when privacy mode is enabled). */
|
|
295
|
+
encryptionKey?: Uint8Array;
|
|
296
|
+
}): Promise<VaultState>;
|
|
228
297
|
|
|
229
298
|
/** Writes a new vault commit and updates the ref atomically. */
|
|
230
299
|
writeCommit(options: {
|
|
@@ -232,12 +301,16 @@ export declare class VaultService {
|
|
|
232
301
|
metadata: VaultMetadata;
|
|
233
302
|
parentCommitOid: string | null;
|
|
234
303
|
message: string;
|
|
304
|
+
/** Vault encryption key (required when privacy mode is enabled). */
|
|
305
|
+
encryptionKey?: Uint8Array;
|
|
235
306
|
}): Promise<{ commitOid: string }>;
|
|
236
307
|
|
|
237
|
-
/** Initializes the vault, optionally with encryption. */
|
|
308
|
+
/** Initializes the vault, optionally with encryption and privacy mode. */
|
|
238
309
|
initVault(options?: {
|
|
239
310
|
passphrase?: string;
|
|
240
311
|
kdfOptions?: Omit<DeriveKeyOptions, "passphrase">;
|
|
312
|
+
/** Enable privacy mode (requires passphrase/encryption). */
|
|
313
|
+
privacy?: boolean;
|
|
241
314
|
}): Promise<{ commitOid: string }>;
|
|
242
315
|
|
|
243
316
|
/** Adds or updates an entry in the vault. */
|
|
@@ -245,23 +318,70 @@ export declare class VaultService {
|
|
|
245
318
|
slug: string;
|
|
246
319
|
treeOid: string;
|
|
247
320
|
force?: boolean;
|
|
321
|
+
/** Vault encryption key (required when privacy mode is enabled). */
|
|
322
|
+
encryptionKey?: Uint8Array;
|
|
248
323
|
}): Promise<{ commitOid: string }>;
|
|
249
324
|
|
|
250
325
|
/** Lists all vault entries sorted by slug. */
|
|
251
|
-
listVault(
|
|
326
|
+
listVault(options?: {
|
|
327
|
+
/** Vault encryption key (required when privacy mode is enabled). */
|
|
328
|
+
encryptionKey?: Uint8Array;
|
|
329
|
+
}): Promise<VaultEntry[]>;
|
|
330
|
+
|
|
331
|
+
/** Streams vault entries without forcing a slug map allocation. */
|
|
332
|
+
iterateVault(options?: {
|
|
333
|
+
/** Vault encryption key (required when privacy mode is enabled). */
|
|
334
|
+
encryptionKey?: Uint8Array;
|
|
335
|
+
}): AsyncIterable<VaultEntry>;
|
|
252
336
|
|
|
253
337
|
/** Removes an entry from the vault. */
|
|
254
338
|
removeFromVault(options: {
|
|
255
339
|
slug: string;
|
|
340
|
+
/** Vault encryption key (required when privacy mode is enabled). */
|
|
341
|
+
encryptionKey?: Uint8Array;
|
|
256
342
|
}): Promise<{ commitOid: string; removedTreeOid: string }>;
|
|
257
343
|
|
|
258
344
|
/** Resolves a vault entry slug to its tree OID. */
|
|
259
|
-
resolveVaultEntry(options: {
|
|
345
|
+
resolveVaultEntry(options: {
|
|
346
|
+
slug: string;
|
|
347
|
+
/** Vault encryption key (required when privacy mode is enabled). */
|
|
348
|
+
encryptionKey?: Uint8Array;
|
|
349
|
+
}): Promise<string>;
|
|
350
|
+
|
|
351
|
+
/** Verifies a vault encryption key when verifier metadata exists. */
|
|
352
|
+
verifyVaultKey(options: {
|
|
353
|
+
encryptionKey: Uint8Array;
|
|
354
|
+
}): Promise<{ verified: boolean; requiresMigration: boolean }>;
|
|
260
355
|
|
|
261
356
|
/** Returns the vault metadata, or null if no vault exists. */
|
|
262
357
|
getVaultMetadata(): Promise<VaultMetadata | null>;
|
|
263
358
|
}
|
|
264
359
|
|
|
360
|
+
/** Result of comparing two manifests by chunk digest. */
|
|
361
|
+
export interface ManifestDiffResult {
|
|
362
|
+
added: Chunk[];
|
|
363
|
+
removed: Chunk[];
|
|
364
|
+
unchanged: Chunk[];
|
|
365
|
+
summary: {
|
|
366
|
+
addedCount: number;
|
|
367
|
+
removedCount: number;
|
|
368
|
+
unchangedCount: number;
|
|
369
|
+
addedBytes: number;
|
|
370
|
+
removedBytes: number;
|
|
371
|
+
unchangedBytes: number;
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
/** Compares two manifests by chunk digest, returning added/removed/unchanged chunks. */
|
|
376
|
+
export function diffManifests(oldManifest: Manifest, newManifest: Manifest): ManifestDiffResult;
|
|
377
|
+
|
|
378
|
+
/** Encryption scheme constant for whole-object encryption. */
|
|
379
|
+
export const SCHEME_WHOLE: 'whole';
|
|
380
|
+
/** Encryption scheme constant for framed streaming encryption. */
|
|
381
|
+
export const SCHEME_FRAMED: 'framed';
|
|
382
|
+
/** Encryption scheme constant for convergent (dedup-preserving) encryption. */
|
|
383
|
+
export const SCHEME_CONVERGENT: 'convergent';
|
|
384
|
+
|
|
265
385
|
/**
|
|
266
386
|
* High-level facade for the Content Addressable Store library.
|
|
267
387
|
*
|
|
@@ -276,73 +396,74 @@ export default class ContentAddressableStore {
|
|
|
276
396
|
getService(): Promise<CasService>;
|
|
277
397
|
getVaultService(): Promise<VaultService>;
|
|
278
398
|
|
|
279
|
-
static
|
|
280
|
-
plumbing: unknown;
|
|
281
|
-
chunkSize?: number;
|
|
282
|
-
policy?: unknown;
|
|
283
|
-
}): ContentAddressableStore;
|
|
399
|
+
static open(options?: ContentAddressableStoreOpenOptions): Promise<ContentAddressableStore>;
|
|
284
400
|
|
|
285
|
-
static
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
401
|
+
static createJson(options: ContentAddressableStoreCodecFactoryOptions): ContentAddressableStore;
|
|
402
|
+
|
|
403
|
+
static createCbor(options: ContentAddressableStoreCodecFactoryOptions): ContentAddressableStore;
|
|
404
|
+
|
|
405
|
+
static diffManifests(oldManifest: Manifest, newManifest: Manifest): ManifestDiffResult;
|
|
290
406
|
|
|
291
407
|
encrypt(options: {
|
|
292
|
-
buffer:
|
|
293
|
-
key:
|
|
294
|
-
}): Promise<{ buf:
|
|
408
|
+
buffer: Uint8Array;
|
|
409
|
+
key: Uint8Array;
|
|
410
|
+
}): Promise<{ buf: Uint8Array; meta: EncryptionMeta }>;
|
|
295
411
|
|
|
296
412
|
decrypt(options: {
|
|
297
|
-
buffer:
|
|
298
|
-
key:
|
|
413
|
+
buffer: Uint8Array;
|
|
414
|
+
key: Uint8Array;
|
|
299
415
|
meta: EncryptionMeta;
|
|
300
|
-
}): Promise<
|
|
416
|
+
}): Promise<Uint8Array>;
|
|
301
417
|
|
|
302
418
|
storeFile(options: {
|
|
303
419
|
filePath: string;
|
|
304
420
|
slug: string;
|
|
305
421
|
filename?: string;
|
|
306
|
-
encryptionKey?:
|
|
422
|
+
encryptionKey?: Uint8Array;
|
|
307
423
|
passphrase?: string;
|
|
424
|
+
encryption?: StoreEncryptionOptions;
|
|
308
425
|
kdfOptions?: Omit<DeriveKeyOptions, "passphrase">;
|
|
309
426
|
compression?: { algorithm: "gzip" };
|
|
310
|
-
recipients?: Array<{ label: string; key:
|
|
427
|
+
recipients?: Array<{ label: string; key: Uint8Array }>;
|
|
428
|
+
merkleThreshold?: number;
|
|
311
429
|
}): Promise<Manifest>;
|
|
312
430
|
|
|
313
431
|
store(options: {
|
|
314
|
-
source: AsyncIterable<
|
|
432
|
+
source: AsyncIterable<Uint8Array>;
|
|
315
433
|
slug: string;
|
|
316
434
|
filename: string;
|
|
317
|
-
encryptionKey?:
|
|
435
|
+
encryptionKey?: Uint8Array;
|
|
318
436
|
passphrase?: string;
|
|
437
|
+
encryption?: StoreEncryptionOptions;
|
|
319
438
|
kdfOptions?: Omit<DeriveKeyOptions, "passphrase">;
|
|
320
439
|
compression?: { algorithm: "gzip" };
|
|
321
|
-
recipients?: Array<{ label: string; key:
|
|
440
|
+
recipients?: Array<{ label: string; key: Uint8Array }>;
|
|
441
|
+
merkleThreshold?: number;
|
|
322
442
|
}): Promise<Manifest>;
|
|
323
443
|
|
|
324
444
|
restoreFile(options: {
|
|
325
445
|
manifest: Manifest;
|
|
326
|
-
encryptionKey?:
|
|
446
|
+
encryptionKey?: Uint8Array;
|
|
327
447
|
passphrase?: string;
|
|
328
448
|
outputPath: string;
|
|
449
|
+
baseDirectory: string;
|
|
329
450
|
}): Promise<{ bytesWritten: number }>;
|
|
330
451
|
|
|
331
452
|
restore(options: {
|
|
332
453
|
manifest: Manifest;
|
|
333
|
-
encryptionKey?:
|
|
454
|
+
encryptionKey?: Uint8Array;
|
|
334
455
|
passphrase?: string;
|
|
335
|
-
}): Promise<{ buffer:
|
|
456
|
+
}): Promise<{ buffer: Uint8Array; bytesWritten: number }>;
|
|
336
457
|
|
|
337
458
|
restoreStream(options: {
|
|
338
459
|
manifest: Manifest;
|
|
339
|
-
encryptionKey?:
|
|
460
|
+
encryptionKey?: Uint8Array;
|
|
340
461
|
passphrase?: string;
|
|
341
|
-
}): AsyncIterable<
|
|
462
|
+
}): AsyncIterable<Uint8Array>;
|
|
342
463
|
|
|
343
|
-
createTree(options: { manifest: Manifest }): Promise<string>;
|
|
464
|
+
createTree(options: { manifest: Manifest; merkleThreshold?: number }): Promise<string>;
|
|
344
465
|
|
|
345
|
-
verifyIntegrity(manifest: Manifest): Promise<boolean>;
|
|
466
|
+
verifyIntegrity(manifest: Manifest, options?: VerifyIntegrityOptions): Promise<boolean>;
|
|
346
467
|
|
|
347
468
|
readManifest(options: { treeOid: string }): Promise<Manifest>;
|
|
348
469
|
|
|
@@ -368,8 +489,8 @@ export default class ContentAddressableStore {
|
|
|
368
489
|
|
|
369
490
|
addRecipient(options: {
|
|
370
491
|
manifest: Manifest;
|
|
371
|
-
existingKey:
|
|
372
|
-
newRecipientKey:
|
|
492
|
+
existingKey: Uint8Array;
|
|
493
|
+
newRecipientKey: Uint8Array;
|
|
373
494
|
label: string;
|
|
374
495
|
}): Promise<Manifest>;
|
|
375
496
|
|
|
@@ -382,8 +503,8 @@ export default class ContentAddressableStore {
|
|
|
382
503
|
|
|
383
504
|
rotateKey(options: {
|
|
384
505
|
manifest: Manifest;
|
|
385
|
-
oldKey:
|
|
386
|
-
newKey:
|
|
506
|
+
oldKey: Uint8Array;
|
|
507
|
+
newKey: Uint8Array;
|
|
387
508
|
label?: string;
|
|
388
509
|
}): Promise<Manifest>;
|
|
389
510
|
|
|
@@ -394,21 +515,43 @@ export default class ContentAddressableStore {
|
|
|
394
515
|
initVault(options?: {
|
|
395
516
|
passphrase?: string;
|
|
396
517
|
kdfOptions?: Omit<DeriveKeyOptions, "passphrase">;
|
|
518
|
+
/** Enable privacy mode (requires passphrase/encryption). */
|
|
519
|
+
privacy?: boolean;
|
|
397
520
|
}): Promise<{ commitOid: string }>;
|
|
398
521
|
|
|
399
522
|
addToVault(options: {
|
|
400
523
|
slug: string;
|
|
401
524
|
treeOid: string;
|
|
402
525
|
force?: boolean;
|
|
526
|
+
/** Vault encryption key (required when privacy mode is enabled). */
|
|
527
|
+
encryptionKey?: Uint8Array;
|
|
403
528
|
}): Promise<{ commitOid: string }>;
|
|
404
529
|
|
|
405
|
-
listVault(
|
|
530
|
+
listVault(options?: {
|
|
531
|
+
/** Vault encryption key (required when privacy mode is enabled). */
|
|
532
|
+
encryptionKey?: Uint8Array;
|
|
533
|
+
}): Promise<VaultEntry[]>;
|
|
534
|
+
|
|
535
|
+
iterateVault(options?: {
|
|
536
|
+
/** Vault encryption key (required when privacy mode is enabled). */
|
|
537
|
+
encryptionKey?: Uint8Array;
|
|
538
|
+
}): AsyncIterable<VaultEntry>;
|
|
406
539
|
|
|
407
540
|
removeFromVault(options: {
|
|
408
541
|
slug: string;
|
|
542
|
+
/** Vault encryption key (required when privacy mode is enabled). */
|
|
543
|
+
encryptionKey?: Uint8Array;
|
|
409
544
|
}): Promise<{ commitOid: string; removedTreeOid: string }>;
|
|
410
545
|
|
|
411
|
-
resolveVaultEntry(options: {
|
|
546
|
+
resolveVaultEntry(options: {
|
|
547
|
+
slug: string;
|
|
548
|
+
/** Vault encryption key (required when privacy mode is enabled). */
|
|
549
|
+
encryptionKey?: Uint8Array;
|
|
550
|
+
}): Promise<string>;
|
|
551
|
+
|
|
552
|
+
verifyVaultKey(options: {
|
|
553
|
+
encryptionKey: Uint8Array;
|
|
554
|
+
}): Promise<{ verified: boolean; requiresMigration: boolean }>;
|
|
412
555
|
|
|
413
556
|
getVaultMetadata(): Promise<VaultMetadata | null>;
|
|
414
557
|
|