just-git 1.5.0 → 1.5.2

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.
@@ -1,5 +1,5 @@
1
- import { g as GitRepo, Z as RefEntry, e as Commit, a3 as TreeEntry, i as ObjectId, h as Identity, a4 as TreeDiffEntry, d as GitContext, F as FileSystem } from '../hooks-C7c_BLqp.js';
2
- export { B as BuildCommitOptions, C as CommitAuthor, a as CommitIdentity, b as CommitOptions, c as CommitResult, d as CreateAnnotatedTagOptions, e as CreateCommitOptions, T as TreeEntryInput, f as TreeUpdate, g as buildCommit, h as commit, i as createAnnotatedTag, j as createCommit, u as updateTree, w as writeBlob, k as writeTree } from '../writing-CnM1ufDP.js';
1
+ import { g as GitRepo, Z as RefEntry, e as Commit, a3 as TreeEntry, i as ObjectId, h as Identity, a4 as TreeDiffEntry, d as GitContext, F as FileSystem } from '../hooks-CimfP56a.js';
2
+ export { B as BuildCommitOptions, C as CommitAuthor, a as CommitIdentity, b as CommitOptions, c as CommitResult, d as CreateAnnotatedTagOptions, e as CreateCommitOptions, T as TreeEntryInput, f as TreeUpdate, g as buildCommit, h as commit, i as createAnnotatedTag, j as createCommit, u as updateTree, w as writeBlob, k as writeTree } from '../writing-IwfRRrts.js';
3
3
 
4
4
  /**
5
5
  * Core grep matching logic shared by the `git grep` command and the
@@ -1,5 +1,5 @@
1
- import { i as ObjectId, W as RawObject, X as Ref, g as GitRepo, $ as Rejection, N as NetworkPolicy } from '../hooks-C7c_BLqp.js';
2
- import { b as CommitOptions, c as CommitResult } from '../writing-CnM1ufDP.js';
1
+ import { i as ObjectId, W as RawObject, X as Ref, g as GitRepo, $ as Rejection, N as NetworkPolicy } from '../hooks-CimfP56a.js';
2
+ import { b as CommitOptions, c as CommitResult } from '../writing-IwfRRrts.js';
3
3
 
4
4
  /** Shallow boundary delta: what to add/remove from `.git/shallow`. */
5
5
  interface ShallowUpdate {
@@ -350,6 +350,47 @@ interface GitServerConfig<A = Auth> {
350
350
  /** Delta window size (default 10). Smaller = faster, worse compression ratio. */
351
351
  deltaWindow?: number;
352
352
  };
353
+ /**
354
+ * Safety limits for incoming receive-pack requests.
355
+ *
356
+ * These bounds are enforced on buffered HTTP bodies and on pack ingestion
357
+ * for both HTTP and SSH push paths.
358
+ */
359
+ receiveLimits?: {
360
+ /** Maximum compressed/raw HTTP request body size in bytes. */
361
+ maxRequestBytes?: number;
362
+ /**
363
+ * Maximum decompressed HTTP request body size in bytes.
364
+ *
365
+ * Guards against gzip decompression bombs (`Content-Encoding: gzip`).
366
+ * Only applies to HTTP — SSH has no application-layer compression,
367
+ * so `maxRequestBytes` alone is sufficient there.
368
+ */
369
+ maxInflatedBytes?: number;
370
+ /** Maximum pack payload size in bytes. */
371
+ maxPackBytes?: number;
372
+ /** Maximum number of objects declared by a received pack. */
373
+ maxPackObjects?: number;
374
+ };
375
+ /**
376
+ * Safety limits for incoming upload-pack (fetch/clone) requests.
377
+ *
378
+ * Upload-pack request bodies contain only pkt-line want/have lists,
379
+ * so they are much smaller than receive-pack bodies. Defaults are
380
+ * tighter than receiveLimits (10 MB raw, 20 MB inflated).
381
+ */
382
+ fetchLimits?: {
383
+ /** Maximum compressed/raw HTTP request body size in bytes. */
384
+ maxRequestBytes?: number;
385
+ /**
386
+ * Maximum decompressed HTTP request body size in bytes.
387
+ *
388
+ * Guards against gzip decompression bombs (`Content-Encoding: gzip`).
389
+ * Only applies to HTTP — SSH has no application-layer compression,
390
+ * so `maxRequestBytes` alone is sufficient there.
391
+ */
392
+ maxInflatedBytes?: number;
393
+ };
353
394
  /**
354
395
  * Called when the server catches an unhandled error.
355
396
  *
@@ -903,37 +944,52 @@ interface UploadPackOptions {
903
944
  /** Delta window size (default 10). Ignored when noDelta is true. */
904
945
  deltaWindow?: number;
905
946
  }
947
+ interface AuthorizedFetchSet {
948
+ allowedRefHashes: Map<string, string>;
949
+ allowedWantHashes: Set<string>;
950
+ }
951
+ interface ReceivePackLimitOptions {
952
+ maxPackBytes?: number;
953
+ maxPackObjects?: number;
954
+ }
906
955
  /**
907
956
  * Handle a `POST /git-upload-pack` request.
908
957
  *
909
958
  * Returns `Uint8Array` for buffered responses (cache hits, deltified packs)
910
959
  * or `ReadableStream<Uint8Array>` for streaming no-delta responses.
911
960
  */
912
- declare function handleUploadPack(repo: GitRepo, requestBody: Uint8Array, options?: UploadPackOptions): Promise<Uint8Array | ReadableStream<Uint8Array>>;
961
+ declare function handleUploadPack(repo: GitRepo, requestBody: Uint8Array, options?: UploadPackOptions & {
962
+ authorizedFetchSet?: AuthorizedFetchSet;
963
+ }): Promise<Uint8Array | ReadableStream<Uint8Array> | Rejection>;
913
964
  interface ReceivePackResult {
914
965
  updates: RefUpdate[];
915
966
  unpackOk: boolean;
916
967
  capabilities: string[];
917
968
  /** Whether the request body contained a valid pkt-line flush packet. */
918
969
  sawFlush: boolean;
970
+ /** Hashes of objects ingested from the pack (for rollback on hook rejection). Only populated when the object store supports deferred ingestion (server-backed stores). Undefined for VFS-backed stores. */
971
+ ingestedHashes?: string[];
919
972
  }
920
973
  /**
921
974
  * Ingest a receive-pack request: parse commands, ingest the packfile,
922
975
  * and compute enriched RefUpdate objects. Does NOT apply ref updates —
923
976
  * call `applyReceivePack` to run hooks and apply refs.
977
+ *
978
+ * Objects are persisted immediately (needed by `buildRefUpdates` for
979
+ * ancestry checks). If hooks later reject the push, `applyReceivePack`
980
+ * rolls back the ingested objects.
924
981
  */
925
- declare function ingestReceivePack(repo: GitRepo, requestBody: Uint8Array): Promise<ReceivePackResult>;
982
+ declare function ingestReceivePack(repo: GitRepo, requestBody: Uint8Array, limits?: ReceivePackLimitOptions): Promise<ReceivePackResult>;
926
983
  /**
927
984
  * Streaming variant of `ingestReceivePack`. Accepts pre-parsed push
928
- * commands and a raw pack byte stream. Uses `readPackStreaming`
929
- * `ingestPackStream` so pack bytes are consumed incrementally without
930
- * buffering the entire pack in memory.
985
+ * commands and a raw pack byte stream. Uses `readPackStreaming` for
986
+ * incremental consumption.
931
987
  *
932
988
  * The HTTP handler continues using `ingestReceivePack` (runtime buffers
933
989
  * POST bodies anyway). The SSH handler calls this directly after parsing
934
990
  * pkt-line commands.
935
991
  */
936
- declare function ingestReceivePackFromStream(repo: GitRepo, commands: PushCommand[], capabilities: string[], packStream: AsyncIterable<Uint8Array>, sawFlush?: boolean): Promise<ReceivePackResult>;
992
+ declare function ingestReceivePackFromStream(repo: GitRepo, commands: PushCommand[], capabilities: string[], packStream: AsyncIterable<Uint8Array>, sawFlush?: boolean, limits?: ReceivePackLimitOptions): Promise<ReceivePackResult>;
937
993
  /**
938
994
  * Apply ref updates with CAS protection only — no hooks.
939
995
  *
@@ -979,7 +1035,9 @@ declare function handleLsRefs<A>(repo: GitRepo, repoId: string, args: string[],
979
1035
  * enumeration and pack building via the shared pipeline, then
980
1036
  * builds a v2 section-based response.
981
1037
  */
982
- declare function handleV2Fetch(repo: GitRepo, args: string[], options?: UploadPackOptions): Promise<Uint8Array | ReadableStream<Uint8Array>>;
1038
+ declare function handleV2Fetch(repo: GitRepo, args: string[], options?: UploadPackOptions & {
1039
+ authorizedFetchSet?: AuthorizedFetchSet;
1040
+ }): Promise<Uint8Array | ReadableStream<Uint8Array> | Rejection>;
983
1041
 
984
1042
  /**
985
1043
  * In-memory storage backend with multi-repo support.