@git-stunts/git-cas 6.0.0 → 6.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -3,19 +3,55 @@
3
3
  * Content Addressable Store — Managed blob storage in Git.
4
4
  */
5
5
 
6
- import Manifest 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
- import Chunk from "./src/domain/value-objects/Chunk.js";
9
- import CasService from "./src/domain/services/CasService.js";
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";
6
+ import Manifest from './src/domain/value-objects/Manifest.js';
7
+ import type {
8
+ EncryptionMeta,
9
+ ManifestData,
10
+ CompressionMeta,
11
+ KdfParams,
12
+ SubManifestRef,
13
+ RecipientEntry,
14
+ EncryptionScheme,
15
+ } from './src/domain/value-objects/Manifest.js';
16
+ import Chunk from './src/domain/value-objects/Chunk.js';
17
+ import CasService from './src/domain/services/CasService.js';
18
+ import CasError from './src/domain/errors/CasError.js';
19
+ import type {
20
+ CryptoPort,
21
+ CodecPort,
22
+ GitPersistencePort,
23
+ ObservabilityPort,
24
+ CasServiceOptions,
25
+ DeriveKeyOptions,
26
+ DeriveKeyResult,
27
+ StoreEncryptionOptions,
28
+ VerifyIntegrityOptions,
29
+ } from './src/domain/services/CasService.js';
12
30
 
13
31
  export { CasService, CasError, Manifest, Chunk };
14
32
  /** Type alias mapping the runtime `CompressionPort` export to its base class declaration. */
15
33
  export type CompressionPort = CompressionPortBase;
16
34
 
17
- export type { EncryptionMeta, ManifestData, CompressionMeta, KdfParams, SubManifestRef, RecipientEntry, EncryptionScheme };
18
- export type { CryptoPort, CodecPort, GitPersistencePort, ObservabilityPort, CasServiceOptions, DeriveKeyOptions, DeriveKeyResult, StoreEncryptionOptions, VerifyIntegrityOptions };
35
+ export type {
36
+ EncryptionMeta,
37
+ ManifestData,
38
+ CompressionMeta,
39
+ KdfParams,
40
+ SubManifestRef,
41
+ RecipientEntry,
42
+ EncryptionScheme,
43
+ };
44
+ export type {
45
+ CryptoPort,
46
+ CodecPort,
47
+ GitPersistencePort,
48
+ ObservabilityPort,
49
+ CasServiceOptions,
50
+ DeriveKeyOptions,
51
+ DeriveKeyResult,
52
+ StoreEncryptionOptions,
53
+ VerifyIntegrityOptions,
54
+ };
19
55
 
20
56
  /** Abstract port for compression and decompression of buffers and streams. */
21
57
  export declare class CompressionPortBase {
@@ -38,7 +74,7 @@ export declare class ChunkingPort {
38
74
  /** Fixed-size chunking adapter. */
39
75
  export declare class FixedChunker extends ChunkingPort {
40
76
  constructor(options?: { chunkSize?: number });
41
- get strategy(): "fixed";
77
+ get strategy(): 'fixed';
42
78
  get params(): { chunkSize: number };
43
79
  }
44
80
 
@@ -50,7 +86,7 @@ export declare class CdcChunker extends ChunkingPort {
50
86
  targetChunkSize?: number;
51
87
  normalized?: boolean;
52
88
  });
53
- get strategy(): "cdc";
89
+ get strategy(): 'cdc';
54
90
  get params(): { target: number; min: number; max: number; normalized: boolean };
55
91
  }
56
92
 
@@ -61,27 +97,39 @@ export declare class CryptoPortBase {
61
97
  encryptBuffer(
62
98
  buffer: Uint8Array,
63
99
  key: Uint8Array,
64
- aad?: Uint8Array,
100
+ aad?: Uint8Array
65
101
  ): { 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): {
102
+ decryptBuffer(
103
+ buffer: Uint8Array,
104
+ key: Uint8Array,
105
+ meta: EncryptionMeta,
106
+ aad?: Uint8Array
107
+ ): Uint8Array | Promise<Uint8Array>;
108
+ createEncryptionStream(
109
+ key: Uint8Array,
110
+ aad?: Uint8Array
111
+ ): {
68
112
  encrypt: (source: AsyncIterable<Uint8Array>) => AsyncIterable<Uint8Array>;
69
113
  finalize: () => EncryptionMeta;
70
114
  };
71
- createDecryptionStream(key: Uint8Array, meta: EncryptionMeta, aad?: Uint8Array): {
115
+ createDecryptionStream(
116
+ key: Uint8Array,
117
+ meta: EncryptionMeta,
118
+ aad?: Uint8Array
119
+ ): {
72
120
  decrypt: (source: AsyncIterable<Uint8Array>) => AsyncIterable<Uint8Array>;
73
121
  };
74
122
  hmacSha256(key: Uint8Array, data: Uint8Array): Uint8Array | Promise<Uint8Array>;
75
123
  encryptBufferWithNonce(
76
124
  buffer: Uint8Array,
77
125
  key: Uint8Array,
78
- nonce: Uint8Array,
126
+ nonce: Uint8Array
79
127
  ): { buf: Uint8Array; tag: Uint8Array } | Promise<{ buf: Uint8Array; tag: Uint8Array }>;
80
128
  decryptBufferWithNonceTag(
81
129
  buffer: Uint8Array,
82
130
  key: Uint8Array,
83
131
  nonce: Uint8Array,
84
- tag: Uint8Array,
132
+ tag: Uint8Array
85
133
  ): Uint8Array | Promise<Uint8Array>;
86
134
  deriveKey(options: DeriveKeyOptions): Promise<DeriveKeyResult>;
87
135
  }
@@ -93,14 +141,14 @@ export declare class GitPersistencePortBase {
93
141
  readBlob(oid: string): Promise<Uint8Array>;
94
142
  readBlobStream(oid: string): Promise<AsyncIterable<Uint8Array>>;
95
143
  readTree(
96
- treeOid: string,
144
+ treeOid: string
97
145
  ): Promise<Array<{ mode: string; type: string; oid: string; name: string }>>;
98
146
  readTreeEntry(
99
147
  treeOid: string,
100
- treePath: string,
148
+ treePath: string
101
149
  ): Promise<{ mode: string; type: string; oid: string; name: string } | null>;
102
150
  iterateTree(
103
- treeOid: string,
151
+ treeOid: string
104
152
  ): AsyncIterable<{ mode: string; type: string; oid: string; name: string }>;
105
153
  setMaxBlobSize?(maxBlobSize: number): void;
106
154
  }
@@ -188,11 +236,12 @@ export declare class StatsCollector {
188
236
 
189
237
  /** Declarative chunking strategy configuration. */
190
238
  export interface ChunkingConfig {
191
- strategy: "fixed" | "cdc";
239
+ strategy: 'fixed' | 'cdc';
192
240
  chunkSize?: number;
193
241
  targetChunkSize?: number;
194
242
  minChunkSize?: number;
195
243
  maxChunkSize?: number;
244
+ normalized?: boolean;
196
245
  }
197
246
 
198
247
  /** Constructor options for {@link ContentAddressableStore}. */
@@ -216,7 +265,10 @@ export interface ContentAddressableStoreOptions {
216
265
  }
217
266
 
218
267
  /** Options for {@link ContentAddressableStore.open}. */
219
- export interface ContentAddressableStoreOpenOptions extends Omit<ContentAddressableStoreOptions, "plumbing"> {
268
+ export interface ContentAddressableStoreOpenOptions extends Omit<
269
+ ContentAddressableStoreOptions,
270
+ 'plumbing'
271
+ > {
220
272
  /** Git working directory used to construct the default Git plumbing adapter. @default "." */
221
273
  cwd?: string;
222
274
  /** Optional shell-runner environment override for Git plumbing. */
@@ -224,7 +276,10 @@ export interface ContentAddressableStoreOpenOptions extends Omit<ContentAddressa
224
276
  }
225
277
 
226
278
  /** Options for codec-specific facade factories. */
227
- export type ContentAddressableStoreCodecFactoryOptions = Omit<ContentAddressableStoreOptions, "codec">;
279
+ export type ContentAddressableStoreCodecFactoryOptions = Omit<
280
+ ContentAddressableStoreOptions,
281
+ 'codec'
282
+ >;
228
283
 
229
284
  /** A single vault entry. */
230
285
  export interface VaultEntry {
@@ -308,7 +363,7 @@ export declare class VaultService {
308
363
  /** Initializes the vault, optionally with encryption and privacy mode. */
309
364
  initVault(options?: {
310
365
  passphrase?: string;
311
- kdfOptions?: Omit<DeriveKeyOptions, "passphrase">;
366
+ kdfOptions?: Omit<DeriveKeyOptions, 'passphrase'>;
312
367
  /** Enable privacy mode (requires passphrase/encryption). */
313
368
  privacy?: boolean;
314
369
  }): Promise<{ commitOid: string }>;
@@ -422,10 +477,11 @@ export default class ContentAddressableStore {
422
477
  encryptionKey?: Uint8Array;
423
478
  passphrase?: string;
424
479
  encryption?: StoreEncryptionOptions;
425
- kdfOptions?: Omit<DeriveKeyOptions, "passphrase">;
426
- compression?: { algorithm: "gzip" };
480
+ kdfOptions?: Omit<DeriveKeyOptions, 'passphrase'>;
481
+ compression?: { algorithm: 'gzip' };
427
482
  recipients?: Array<{ label: string; key: Uint8Array }>;
428
483
  merkleThreshold?: number;
484
+ chunking?: ChunkingConfig;
429
485
  }): Promise<Manifest>;
430
486
 
431
487
  store(options: {
@@ -435,10 +491,11 @@ export default class ContentAddressableStore {
435
491
  encryptionKey?: Uint8Array;
436
492
  passphrase?: string;
437
493
  encryption?: StoreEncryptionOptions;
438
- kdfOptions?: Omit<DeriveKeyOptions, "passphrase">;
439
- compression?: { algorithm: "gzip" };
494
+ kdfOptions?: Omit<DeriveKeyOptions, 'passphrase'>;
495
+ compression?: { algorithm: 'gzip' };
440
496
  recipients?: Array<{ label: string; key: Uint8Array }>;
441
497
  merkleThreshold?: number;
498
+ chunking?: ChunkingConfig;
442
499
  }): Promise<Manifest>;
443
500
 
444
501
  restoreFile(options: {
@@ -467,14 +524,10 @@ export default class ContentAddressableStore {
467
524
 
468
525
  readManifest(options: { treeOid: string }): Promise<Manifest>;
469
526
 
470
- inspectAsset(options: {
471
- treeOid: string;
472
- }): Promise<{ slug: string; chunksOrphaned: number }>;
527
+ inspectAsset(options: { treeOid: string }): Promise<{ slug: string; chunksOrphaned: number }>;
473
528
 
474
529
  /** @deprecated Use {@link inspectAsset} instead. */
475
- deleteAsset(options: {
476
- treeOid: string;
477
- }): Promise<{ slug: string; chunksOrphaned: number }>;
530
+ deleteAsset(options: { treeOid: string }): Promise<{ slug: string; chunksOrphaned: number }>;
478
531
 
479
532
  collectReferencedChunks(options: {
480
533
  treeOids: string[];
@@ -494,10 +547,7 @@ export default class ContentAddressableStore {
494
547
  label: string;
495
548
  }): Promise<Manifest>;
496
549
 
497
- removeRecipient(options: {
498
- manifest: Manifest;
499
- label: string;
500
- }): Promise<Manifest>;
550
+ removeRecipient(options: { manifest: Manifest; label: string }): Promise<Manifest>;
501
551
 
502
552
  listRecipients(manifest: Manifest): Promise<string[]>;
503
553
 
@@ -514,7 +564,7 @@ export default class ContentAddressableStore {
514
564
 
515
565
  initVault(options?: {
516
566
  passphrase?: string;
517
- kdfOptions?: Omit<DeriveKeyOptions, "passphrase">;
567
+ kdfOptions?: Omit<DeriveKeyOptions, 'passphrase'>;
518
568
  /** Enable privacy mode (requires passphrase/encryption). */
519
569
  privacy?: boolean;
520
570
  }): Promise<{ commitOid: string }>;
@@ -558,7 +608,7 @@ export default class ContentAddressableStore {
558
608
  rotateVaultPassphrase(options: {
559
609
  oldPassphrase: string;
560
610
  newPassphrase: string;
561
- kdfOptions?: Omit<DeriveKeyOptions, "passphrase">;
611
+ kdfOptions?: Omit<DeriveKeyOptions, 'passphrase'>;
562
612
  /** Maximum optimistic-concurrency retries on VAULT_CONFLICT. @default 3 */
563
613
  maxRetries?: number;
564
614
  /** Base delay in ms for exponential backoff between retries. @default 50 */
package/index.js CHANGED
@@ -26,8 +26,23 @@ import { PACKAGE_VERSION } from './src/package-version.js';
26
26
  /** @typedef {import('./src/domain/value-objects/Manifest.js').default} Manifest */
27
27
 
28
28
  const PKG_VERSION = PACKAGE_VERSION;
29
- const RESTORE_FILE_DOCS_URL =
30
- `https://github.com/git-stunts/git-cas/blob/v${PKG_VERSION}/docs/API.md#restorefile`;
29
+ const FIXED_CHUNKING_STRATEGY = 'fixed';
30
+ const RESTORE_FILE_DOCS_URL = `https://github.com/git-stunts/git-cas/blob/v${PKG_VERSION}/docs/API.md#restorefile`;
31
+
32
+ function withOperationChunker(options) {
33
+ const { chunking, ...rest } = options;
34
+ if (!chunking) {
35
+ return rest;
36
+ }
37
+ const chunker = resolveChunker({ chunking });
38
+ if (chunker) {
39
+ return { ...rest, chunker };
40
+ }
41
+ if (chunking.strategy === FIXED_CHUNKING_STRATEGY && chunking.chunkSize === undefined) {
42
+ return { ...rest, chunker: new FixedChunker() };
43
+ }
44
+ return rest;
45
+ }
31
46
 
32
47
  // ---------------------------------------------------------------------------
33
48
  // Re-exports — modules used in the class body
@@ -78,14 +93,42 @@ export default class ContentAddressableStore {
78
93
  * @param {import('@git-stunts/alfred').Policy} [options.policy] - Resilience policy for Git I/O.
79
94
  * @param {number} [options.merkleThreshold=1000] - Chunk count threshold for Merkle manifests.
80
95
  * @param {number} [options.concurrency=1] - Maximum parallel chunk I/O operations.
81
- * @param {{ strategy: string, chunkSize?: number, targetChunkSize?: number, minChunkSize?: number, maxChunkSize?: number }} [options.chunking] - Chunking strategy config.
96
+ * @param {{ strategy: string, chunkSize?: number, targetChunkSize?: number, minChunkSize?: number, maxChunkSize?: number, normalized?: boolean }} [options.chunking] - Chunking strategy config.
82
97
  * @param {import('./src/ports/ChunkingPort.js').default} [options.chunker] - Pre-built ChunkingPort instance (advanced).
83
98
  * @param {number} [options.maxRestoreBufferSize=536870912] - Max buffered restore size in bytes for encrypted/compressed restores (default 512 MiB).
84
99
  * @param {number} [options.maxBlobSize=10485760] - Safety limit for readBlob metadata in bytes (default 10 MiB).
85
100
  * @param {import('./src/ports/CompressionPort.js').default} [options.compressionAdapter] - Compression adapter (default NodeCompressionAdapter).
86
101
  */
87
- constructor({ plumbing, chunkSize, codec, policy, crypto, observability, merkleThreshold, concurrency, chunking, chunker, maxRestoreBufferSize, maxBlobSize, compressionAdapter }) {
88
- this.#config = { plumbing, chunkSize, codec, policy, crypto, observability, merkleThreshold, concurrency, chunking, chunker, maxRestoreBufferSize, maxBlobSize, compressionAdapter };
102
+ constructor({
103
+ plumbing,
104
+ chunkSize,
105
+ codec,
106
+ policy,
107
+ crypto,
108
+ observability,
109
+ merkleThreshold,
110
+ concurrency,
111
+ chunking,
112
+ chunker,
113
+ maxRestoreBufferSize,
114
+ maxBlobSize,
115
+ compressionAdapter,
116
+ }) {
117
+ this.#config = {
118
+ plumbing,
119
+ chunkSize,
120
+ codec,
121
+ policy,
122
+ crypto,
123
+ observability,
124
+ merkleThreshold,
125
+ concurrency,
126
+ chunking,
127
+ chunker,
128
+ maxRestoreBufferSize,
129
+ maxBlobSize,
130
+ compressionAdapter,
131
+ };
89
132
  this.service = null;
90
133
  this.#servicePromise = null;
91
134
  }
@@ -119,10 +162,11 @@ export default class ContentAddressableStore {
119
162
  plumbing: cfg.plumbing,
120
163
  policy: cfg.policy,
121
164
  });
122
- const crypto = cfg.crypto || await createCryptoAdapter();
165
+ const crypto = cfg.crypto || (await createCryptoAdapter());
123
166
  const chunkSize = cfg.chunkSize || 256 * 1024;
124
- const chunker = resolveChunker({ chunker: cfg.chunker, chunking: cfg.chunking })
125
- || new FixedChunker({ chunkSize });
167
+ const chunker =
168
+ resolveChunker({ chunker: cfg.chunker, chunking: cfg.chunking }) ||
169
+ new FixedChunker({ chunkSize });
126
170
  this.service = new CasService({
127
171
  persistence,
128
172
  chunkSize,
@@ -142,7 +186,12 @@ export default class ContentAddressableStore {
142
186
  plumbing: cfg.plumbing,
143
187
  policy: cfg.policy,
144
188
  });
145
- this.#vault = new VaultService({ persistence, ref, crypto, observability: this.service.observability });
189
+ this.#vault = new VaultService({
190
+ persistence,
191
+ ref,
192
+ crypto,
193
+ observability: this.service.observability,
194
+ });
146
195
 
147
196
  return this.service;
148
197
  }
@@ -189,7 +238,7 @@ export default class ContentAddressableStore {
189
238
  * @param {import('./src/ports/ObservabilityPort.js').default} [options.observability] - Observability adapter.
190
239
  * @param {number} [options.merkleThreshold=1000] - Chunk count threshold for Merkle manifests.
191
240
  * @param {number} [options.concurrency=1] - Maximum parallel chunk I/O operations.
192
- * @param {{ strategy: string, chunkSize?: number, targetChunkSize?: number, minChunkSize?: number, maxChunkSize?: number }} [options.chunking] - Chunking strategy config.
241
+ * @param {{ strategy: string, chunkSize?: number, targetChunkSize?: number, minChunkSize?: number, maxChunkSize?: number, normalized?: boolean }} [options.chunking] - Chunking strategy config.
193
242
  * @param {import('./src/ports/ChunkingPort.js').default} [options.chunker] - Pre-built ChunkingPort instance.
194
243
  * @param {number} [options.maxRestoreBufferSize=536870912] - Max buffered restore size in bytes.
195
244
  * @param {number} [options.maxBlobSize=10485760] - Safety limit for readBlob metadata in bytes.
@@ -213,7 +262,7 @@ export default class ContentAddressableStore {
213
262
  * @param {import('./src/ports/ObservabilityPort.js').default} [options.observability] - Observability adapter.
214
263
  * @param {number} [options.merkleThreshold=1000] - Chunk count threshold for Merkle manifests.
215
264
  * @param {number} [options.concurrency=1] - Maximum parallel chunk I/O operations.
216
- * @param {{ strategy: string, chunkSize?: number, targetChunkSize?: number, minChunkSize?: number, maxChunkSize?: number }} [options.chunking] - Chunking strategy config.
265
+ * @param {{ strategy: string, chunkSize?: number, targetChunkSize?: number, minChunkSize?: number, maxChunkSize?: number, normalized?: boolean }} [options.chunking] - Chunking strategy config.
217
266
  * @param {import('./src/ports/ChunkingPort.js').default} [options.chunker] - Pre-built ChunkingPort instance.
218
267
  * @param {number} [options.maxRestoreBufferSize=536870912] - Max buffered restore size in bytes.
219
268
  * @param {number} [options.maxBlobSize=10485760] - Safety limit for readBlob metadata in bytes.
@@ -234,7 +283,7 @@ export default class ContentAddressableStore {
234
283
  * @param {import('./src/ports/ObservabilityPort.js').default} [options.observability] - Observability adapter.
235
284
  * @param {number} [options.merkleThreshold=1000] - Chunk count threshold for Merkle manifests.
236
285
  * @param {number} [options.concurrency=1] - Maximum parallel chunk I/O operations.
237
- * @param {{ strategy: string, chunkSize?: number, targetChunkSize?: number, minChunkSize?: number, maxChunkSize?: number }} [options.chunking] - Chunking strategy config.
286
+ * @param {{ strategy: string, chunkSize?: number, targetChunkSize?: number, minChunkSize?: number, maxChunkSize?: number, normalized?: boolean }} [options.chunking] - Chunking strategy config.
238
287
  * @param {import('./src/ports/ChunkingPort.js').default} [options.chunker] - Pre-built ChunkingPort instance.
239
288
  * @param {number} [options.maxRestoreBufferSize=536870912] - Max buffered restore size in bytes.
240
289
  * @param {number} [options.maxBlobSize=10485760] - Safety limit for readBlob metadata in bytes.
@@ -291,11 +340,12 @@ export default class ContentAddressableStore {
291
340
  * @param {{ algorithm: 'gzip' }} [options.compression] - Enable compression.
292
341
  * @param {Array<{label: string, key: Uint8Array}>} [options.recipients] - Envelope recipients (mutually exclusive with encryptionKey/passphrase).
293
342
  * @param {number} [options.merkleThreshold] - Per-operation chunk count threshold for Merkle tree publication.
343
+ * @param {{ strategy: string, chunkSize?: number, targetChunkSize?: number, minChunkSize?: number, maxChunkSize?: number, normalized?: boolean }} [options.chunking] - Per-operation chunking strategy config.
294
344
  * @returns {Promise<Manifest>} The resulting manifest.
295
345
  */
296
346
  async storeFile(options) {
297
347
  const service = await this.#getService();
298
- return await storeFile(service, options);
348
+ return await storeFile(service, withOperationChunker(options));
299
349
  }
300
350
 
301
351
  /**
@@ -311,11 +361,12 @@ export default class ContentAddressableStore {
311
361
  * @param {{ algorithm: 'gzip' }} [options.compression] - Enable compression.
312
362
  * @param {Array<{label: string, key: Uint8Array}>} [options.recipients] - Envelope recipients (mutually exclusive with encryptionKey/passphrase).
313
363
  * @param {number} [options.merkleThreshold] - Per-operation chunk count threshold for Merkle tree publication.
364
+ * @param {{ strategy: string, chunkSize?: number, targetChunkSize?: number, minChunkSize?: number, maxChunkSize?: number, normalized?: boolean }} [options.chunking] - Per-operation chunking strategy config.
314
365
  * @returns {Promise<Manifest>} The resulting manifest.
315
366
  */
316
367
  async store(options) {
317
368
  const service = await this.#getService();
318
- return await service.store(options);
369
+ return await service.store(withOperationChunker(options));
319
370
  }
320
371
 
321
372
  /**
@@ -331,7 +382,8 @@ export default class ContentAddressableStore {
331
382
  async restoreFile(options) {
332
383
  if (!options?.baseDirectory) {
333
384
  throw createCasError({
334
- message: 'baseDirectory is required for safe restoration. If you are restoring in a trusted local environment, pass baseDirectory: process.cwd().',
385
+ message:
386
+ 'baseDirectory is required for safe restoration. If you are restoring in a trusted local environment, pass baseDirectory: process.cwd().',
335
387
  code: ErrorCodes.INVALID_OPTIONS,
336
388
  meta: { option: 'baseDirectory' },
337
389
  documentationUrl: RESTORE_FILE_DOCS_URL,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@git-stunts/git-cas",
3
- "version": "6.0.0",
3
+ "version": "6.0.1",
4
4
  "description": "Content-addressed storage backed by Git's object database, with optional encryption and pluggable codecs",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -3,8 +3,13 @@
3
3
  * Domain service for Content Addressable Storage operations.
4
4
  */
5
5
 
6
- import Manifest, { type EncryptionMeta, type CompressionMeta, type KdfParams, type EncryptionScheme } from "../value-objects/Manifest.js";
7
- import Chunk from "../value-objects/Chunk.js";
6
+ import Manifest, {
7
+ type EncryptionMeta,
8
+ type CompressionMeta,
9
+ type KdfParams,
10
+ type EncryptionScheme,
11
+ } from '../value-objects/Manifest.js';
12
+ import Chunk from '../value-objects/Chunk.js';
8
13
 
9
14
  /** Port interface for cryptographic operations (hashing, encryption, random bytes). */
10
15
  export interface CryptoPort {
@@ -13,27 +18,39 @@ export interface CryptoPort {
13
18
  encryptBuffer(
14
19
  buffer: Uint8Array,
15
20
  key: Uint8Array,
16
- aad?: Uint8Array,
21
+ aad?: Uint8Array
17
22
  ): { buf: Uint8Array; meta: EncryptionMeta } | Promise<{ buf: Uint8Array; meta: EncryptionMeta }>;
18
- decryptBuffer(buffer: Uint8Array, key: Uint8Array, meta: EncryptionMeta, aad?: Uint8Array): Uint8Array | Promise<Uint8Array>;
19
- createEncryptionStream(key: Uint8Array, aad?: Uint8Array): {
23
+ decryptBuffer(
24
+ buffer: Uint8Array,
25
+ key: Uint8Array,
26
+ meta: EncryptionMeta,
27
+ aad?: Uint8Array
28
+ ): Uint8Array | Promise<Uint8Array>;
29
+ createEncryptionStream(
30
+ key: Uint8Array,
31
+ aad?: Uint8Array
32
+ ): {
20
33
  encrypt: (source: AsyncIterable<Uint8Array>) => AsyncIterable<Uint8Array>;
21
34
  finalize: () => EncryptionMeta;
22
35
  };
23
- createDecryptionStream(key: Uint8Array, meta: EncryptionMeta, aad?: Uint8Array): {
36
+ createDecryptionStream(
37
+ key: Uint8Array,
38
+ meta: EncryptionMeta,
39
+ aad?: Uint8Array
40
+ ): {
24
41
  decrypt: (source: AsyncIterable<Uint8Array>) => AsyncIterable<Uint8Array>;
25
42
  };
26
43
  hmacSha256(key: Uint8Array, data: Uint8Array): Uint8Array | Promise<Uint8Array>;
27
44
  encryptBufferWithNonce(
28
45
  buffer: Uint8Array,
29
46
  key: Uint8Array,
30
- nonce: Uint8Array,
47
+ nonce: Uint8Array
31
48
  ): { buf: Uint8Array; tag: Uint8Array } | Promise<{ buf: Uint8Array; tag: Uint8Array }>;
32
49
  decryptBufferWithNonceTag(
33
50
  buffer: Uint8Array,
34
51
  key: Uint8Array,
35
52
  nonce: Uint8Array,
36
- tag: Uint8Array,
53
+ tag: Uint8Array
37
54
  ): Uint8Array | Promise<Uint8Array>;
38
55
  deriveKey(options: DeriveKeyOptions): Promise<DeriveKeyResult>;
39
56
  }
@@ -52,14 +69,14 @@ export interface GitPersistencePort {
52
69
  readBlob(oid: string): Promise<Uint8Array>;
53
70
  readBlobStream(oid: string): Promise<AsyncIterable<Uint8Array>>;
54
71
  readTree(
55
- treeOid: string,
72
+ treeOid: string
56
73
  ): Promise<Array<{ mode: string; type: string; oid: string; name: string }>>;
57
74
  readTreeEntry(
58
75
  treeOid: string,
59
- treePath: string,
76
+ treePath: string
60
77
  ): Promise<{ mode: string; type: string; oid: string; name: string } | null>;
61
78
  iterateTree(
62
- treeOid: string,
79
+ treeOid: string
63
80
  ): AsyncIterable<{ mode: string; type: string; oid: string; name: string }>;
64
81
  setMaxBlobSize?(maxBlobSize: number): void;
65
82
  }
@@ -67,7 +84,11 @@ export interface GitPersistencePort {
67
84
  /** Port interface for observability (metrics, logging, tracing). */
68
85
  export interface ObservabilityPort {
69
86
  metric(channel: string, data: Record<string, unknown>): void;
70
- log(level: "debug" | "info" | "warn" | "error", msg: string, meta?: Record<string, unknown>): void;
87
+ log(
88
+ level: 'debug' | 'info' | 'warn' | 'error',
89
+ msg: string,
90
+ meta?: Record<string, unknown>
91
+ ): void;
71
92
  span(name: string): { end(meta?: Record<string, unknown>): void };
72
93
  }
73
94
 
@@ -108,7 +129,7 @@ export interface CasServiceOptions {
108
129
  export interface DeriveKeyOptions {
109
130
  passphrase: string;
110
131
  salt?: Uint8Array;
111
- algorithm?: "pbkdf2" | "scrypt";
132
+ algorithm?: 'pbkdf2' | 'scrypt';
112
133
  iterations?: number;
113
134
  cost?: number;
114
135
  blockSize?: number;
@@ -136,7 +157,7 @@ export interface StoreEncryptionOptions {
136
157
  }
137
158
 
138
159
  export interface FileRestorePlan {
139
- mode: "stream" | "bounded-file";
160
+ mode: 'stream' | 'bounded-file';
140
161
  source: AsyncIterable<Uint8Array>;
141
162
  encryptionMeta?: EncryptionMeta;
142
163
  }
@@ -178,10 +199,11 @@ export default class CasService {
178
199
  encryptionKey?: Uint8Array;
179
200
  passphrase?: string;
180
201
  encryption?: StoreEncryptionOptions;
181
- kdfOptions?: Omit<DeriveKeyOptions, "passphrase">;
182
- compression?: { algorithm: "gzip" };
202
+ kdfOptions?: Omit<DeriveKeyOptions, 'passphrase'>;
203
+ compression?: { algorithm: 'gzip' };
183
204
  recipients?: Array<{ label: string; key: Uint8Array }>;
184
205
  merkleThreshold?: number;
206
+ chunker?: ChunkingPort;
185
207
  }): Promise<Manifest>;
186
208
 
187
209
  createTree(options: { manifest: Manifest; merkleThreshold?: number }): Promise<string>;
@@ -209,14 +231,10 @@ export default class CasService {
209
231
  /** Reads a raw manifest without scheme assertion or Manifest construction. */
210
232
  readManifestRaw(options: { treeOid: string }): Promise<Record<string, unknown>>;
211
233
 
212
- inspectAsset(options: {
213
- treeOid: string;
214
- }): Promise<{ slug: string; chunksOrphaned: number }>;
234
+ inspectAsset(options: { treeOid: string }): Promise<{ slug: string; chunksOrphaned: number }>;
215
235
 
216
236
  /** @deprecated Use {@link inspectAsset} instead. */
217
- deleteAsset(options: {
218
- treeOid: string;
219
- }): Promise<{ slug: string; chunksOrphaned: number }>;
237
+ deleteAsset(options: { treeOid: string }): Promise<{ slug: string; chunksOrphaned: number }>;
220
238
 
221
239
  collectReferencedChunks(options: {
222
240
  treeOids: string[];
@@ -234,10 +252,7 @@ export default class CasService {
234
252
  label: string;
235
253
  }): Promise<Manifest>;
236
254
 
237
- removeRecipient(options: {
238
- manifest: Manifest;
239
- label: string;
240
- }): Promise<Manifest>;
255
+ removeRecipient(options: { manifest: Manifest; label: string }): Promise<Manifest>;
241
256
 
242
257
  listRecipients(manifest: Manifest): string[];
243
258