isomorphic-git 1.32.1 → 1.32.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -389,7 +389,8 @@ Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds
389
389
  <td align="center"><a href="https://tomlarkworthy.endpointservices.net/"><img src="https://avatars.githubusercontent.com/u/1848162?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Tom Larkworthy</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=tomlarkworthy" title="Documentation">📖</a></td>
390
390
  <td align="center"><a href="https://github.com/kofta999"><img src="https://avatars.githubusercontent.com/u/99273340?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Mostafa Mahmoud</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=kofta999" title="Code">💻</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=kofta999" title="Tests">⚠️</a> <a href="#question-kofta999" title="Answering Questions">💬</a></td>
391
391
  <td align="center"><a href="https://github.com/ARBhosale"><img src="https://avatars.githubusercontent.com/u/26981417?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Aniket Bhosale</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=ARBhosale" title="Code">💻</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=ARBhosale" title="Documentation">📖</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=ARBhosale" title="Tests">⚠️</a></td>
392
- <td align="center"><a href="https://github.com/gnillev"><img src="https://avatars.githubusercontent.com/u/8965094?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Mathias Nisted Velling</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=gnillev" title="Code">💻</a><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=gnillev" title="Tests">⚠️</a></td>
392
+ <td align="center"><a href="https://github.com/gnillev"><img src="https://avatars.githubusercontent.com/u/8965094?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Mathias Nisted Velling</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=gnillev" title="Code">💻</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=gnillev" title="Tests">⚠️</a></td>
393
+ <td align="center"><a href="https://github.com/acandoo"><img src="https://avatars.githubusercontent.com/u/117209328?v=4?s=60" width="60px;" alt=""/><br /><sub><b>acandoo</b></sub></a><br /><a href="#platform-acandoo" title="Packaging/porting to new platform">📦</a> <a href="#userTesting-acandoo" title="User Testing">📓</a></td>
393
394
  </tr>
394
395
  </table>
395
396
 
@@ -1,7 +1,7 @@
1
1
  [
2
2
  "Chrome Headless 79.0.3945.0 (Linux x86_64)",
3
- "Firefox 139.0 (Linux x86_64)",
4
- "Chrome 135.0.0.0 (Android 10)",
3
+ "Firefox 141.0 (Linux x86_64)",
4
+ "Chrome 137.0.0.0 (Android 10)",
5
5
  "Edge 79.0.309.65 (Windows 10)",
6
6
  "Mobile Safari 14.0 (iOS 14.0.1)",
7
7
  "Safari 14.1 (Mac OS 10.15.7)"
@@ -0,0 +1,82 @@
1
+ export const __esModule: boolean;
2
+ export default index;
3
+ export type GitProgressEvent = {
4
+ phase: string;
5
+ loaded: number;
6
+ total: number;
7
+ };
8
+ export type ProgressCallback = (progress: GitProgressEvent) => void | Promise<void>;
9
+ export type GitHttpRequest = {
10
+ /**
11
+ * - The URL to request
12
+ */
13
+ url: string;
14
+ /**
15
+ * - The HTTP method to use
16
+ */
17
+ method?: string | undefined;
18
+ /**
19
+ * - Headers to include in the HTTP request
20
+ */
21
+ headers?: {
22
+ [x: string]: string;
23
+ } | undefined;
24
+ /**
25
+ * - An HTTP or HTTPS agent that manages connections for the HTTP client (Node.js only)
26
+ */
27
+ agent?: any;
28
+ /**
29
+ * - An async iterator of Uint8Arrays that make up the body of POST requests
30
+ */
31
+ body?: AsyncIterableIterator<Uint8Array>;
32
+ /**
33
+ * - Reserved for future use (emitting `GitProgressEvent`s)
34
+ */
35
+ onProgress?: ProgressCallback | undefined;
36
+ /**
37
+ * - Reserved for future use (canceling a request)
38
+ */
39
+ signal?: object;
40
+ };
41
+ export type GitHttpResponse = {
42
+ /**
43
+ * - The final URL that was fetched after any redirects
44
+ */
45
+ url: string;
46
+ /**
47
+ * - The HTTP method that was used
48
+ */
49
+ method?: string | undefined;
50
+ /**
51
+ * - HTTP response headers
52
+ */
53
+ headers?: {
54
+ [x: string]: string;
55
+ } | undefined;
56
+ /**
57
+ * - An async iterator of Uint8Arrays that make up the body of the response
58
+ */
59
+ body?: AsyncIterableIterator<Uint8Array>;
60
+ /**
61
+ * - The HTTP status code
62
+ */
63
+ statusCode: number;
64
+ /**
65
+ * - The HTTP status message
66
+ */
67
+ statusMessage: string;
68
+ };
69
+ export type HttpFetch = (request: GitHttpRequest) => Promise<GitHttpResponse>;
70
+ export type HttpClient = {
71
+ request: HttpFetch;
72
+ };
73
+ declare namespace index {
74
+ export { request };
75
+ }
76
+ /**
77
+ * HttpClient
78
+ *
79
+ * @param {GitHttpRequest} request
80
+ * @returns {Promise<GitHttpResponse>}
81
+ */
82
+ export function request({ onProgress, url, method, headers, agent, body, }: GitHttpRequest): Promise<GitHttpResponse>;
@@ -0,0 +1,82 @@
1
+ export const __esModule: boolean;
2
+ export default index;
3
+ export type GitProgressEvent = {
4
+ phase: string;
5
+ loaded: number;
6
+ total: number;
7
+ };
8
+ export type ProgressCallback = (progress: GitProgressEvent) => void | Promise<void>;
9
+ export type GitHttpRequest = {
10
+ /**
11
+ * - The URL to request
12
+ */
13
+ url: string;
14
+ /**
15
+ * - The HTTP method to use
16
+ */
17
+ method?: string | undefined;
18
+ /**
19
+ * - Headers to include in the HTTP request
20
+ */
21
+ headers?: {
22
+ [x: string]: string;
23
+ } | undefined;
24
+ /**
25
+ * - An HTTP or HTTPS agent that manages connections for the HTTP client (Node.js only)
26
+ */
27
+ agent?: any;
28
+ /**
29
+ * - An async iterator of Uint8Arrays that make up the body of POST requests
30
+ */
31
+ body?: AsyncIterableIterator<Uint8Array>;
32
+ /**
33
+ * - Reserved for future use (emitting `GitProgressEvent`s)
34
+ */
35
+ onProgress?: ProgressCallback | undefined;
36
+ /**
37
+ * - Reserved for future use (canceling a request)
38
+ */
39
+ signal?: object;
40
+ };
41
+ export type GitHttpResponse = {
42
+ /**
43
+ * - The final URL that was fetched after any redirects
44
+ */
45
+ url: string;
46
+ /**
47
+ * - The HTTP method that was used
48
+ */
49
+ method?: string | undefined;
50
+ /**
51
+ * - HTTP response headers
52
+ */
53
+ headers?: {
54
+ [x: string]: string;
55
+ } | undefined;
56
+ /**
57
+ * - An async iterator of Uint8Arrays that make up the body of the response
58
+ */
59
+ body?: AsyncIterableIterator<Uint8Array>;
60
+ /**
61
+ * - The HTTP status code
62
+ */
63
+ statusCode: number;
64
+ /**
65
+ * - The HTTP status message
66
+ */
67
+ statusMessage: string;
68
+ };
69
+ export type HttpFetch = (request: GitHttpRequest) => Promise<GitHttpResponse>;
70
+ export type HttpClient = {
71
+ request: HttpFetch;
72
+ };
73
+ declare namespace index {
74
+ export { request };
75
+ }
76
+ /**
77
+ * HttpClient
78
+ *
79
+ * @param {GitHttpRequest} request
80
+ * @returns {Promise<GitHttpResponse>}
81
+ */
82
+ export function request({ onProgress, url, method, headers, body, }: GitHttpRequest): Promise<GitHttpResponse>;
package/index.cjs CHANGED
@@ -644,7 +644,7 @@ async function testSubtleSHA1() {
644
644
  // some browsers that have crypto.subtle.digest don't actually implement SHA-1.
645
645
  try {
646
646
  const hash = await subtleSHA1(new Uint8Array([]));
647
- if (hash === 'da39a3ee5e6b4b0d3255bfef95601890afd80709') return true
647
+ return hash === 'da39a3ee5e6b4b0d3255bfef95601890afd80709'
648
648
  } catch (_) {
649
649
  // no bother
650
650
  }
@@ -2301,14 +2301,41 @@ class GitTree {
2301
2301
  }
2302
2302
  }
2303
2303
 
2304
+ /**
2305
+ * Represents a Git object and provides methods to wrap and unwrap Git objects
2306
+ * according to the Git object format.
2307
+ */
2304
2308
  class GitObject {
2309
+ /**
2310
+ * Wraps a raw object with a Git header.
2311
+ *
2312
+ * @param {Object} params - The parameters for wrapping.
2313
+ * @param {string} params.type - The type of the Git object (e.g., 'blob', 'tree', 'commit').
2314
+ * @param {Uint8Array} params.object - The raw object data to wrap.
2315
+ * @returns {Uint8Array} The wrapped Git object as a single buffer.
2316
+ */
2305
2317
  static wrap({ type, object }) {
2306
- return Buffer.concat([
2307
- Buffer.from(`${type} ${object.byteLength.toString()}\x00`),
2308
- Buffer.from(object),
2309
- ])
2318
+ const header = `${type} ${object.length}\x00`;
2319
+ const headerLen = header.length;
2320
+ const totalLength = headerLen + object.length;
2321
+
2322
+ // Allocate a single buffer for the header and object, rather than create multiple buffers
2323
+ const wrappedObject = new Uint8Array(totalLength);
2324
+ for (let i = 0; i < headerLen; i++) {
2325
+ wrappedObject[i] = header.charCodeAt(i);
2326
+ }
2327
+ wrappedObject.set(object, headerLen);
2328
+
2329
+ return wrappedObject
2310
2330
  }
2311
2331
 
2332
+ /**
2333
+ * Unwraps a Git object buffer into its type and raw object data.
2334
+ *
2335
+ * @param {Buffer|Uint8Array} buffer - The buffer containing the wrapped Git object.
2336
+ * @returns {{ type: string, object: Buffer }} An object containing the type and the raw object data.
2337
+ * @throws {InternalError} If the length specified in the header does not match the actual object length.
2338
+ */
2312
2339
  static unwrap(buffer) {
2313
2340
  const s = buffer.indexOf(32); // first space
2314
2341
  const i = buffer.indexOf(0); // first null value
@@ -7776,8 +7803,8 @@ function filterCapabilities(server, client) {
7776
7803
 
7777
7804
  const pkg = {
7778
7805
  name: 'isomorphic-git',
7779
- version: '1.32.1',
7780
- agent: 'git/isomorphic-git@1.32.1',
7806
+ version: '1.32.3',
7807
+ agent: 'git/isomorphic-git@1.32.3',
7781
7808
  };
7782
7809
 
7783
7810
  class FIFO {
@@ -10752,17 +10779,18 @@ async function hashBlob({ object }) {
10752
10779
  // Convert object to buffer
10753
10780
  if (typeof object === 'string') {
10754
10781
  object = Buffer.from(object, 'utf8');
10755
- } else {
10756
- object = Buffer.from(object);
10782
+ } else if (!(object instanceof Uint8Array)) {
10783
+ object = new Uint8Array(object);
10757
10784
  }
10758
10785
 
10759
10786
  const type = 'blob';
10760
10787
  const { oid, object: _object } = await hashObject({
10761
- type: 'blob',
10788
+ type,
10762
10789
  format: 'content',
10763
10790
  object,
10764
10791
  });
10765
- return { oid, type, object: new Uint8Array(_object), format: 'wrapped' }
10792
+
10793
+ return { oid, type, object: _object, format: 'wrapped' }
10766
10794
  } catch (err) {
10767
10795
  err.caller = 'git.hashBlob';
10768
10796
  throw err