isomorphic-git 1.40.8 → 1.41.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/http/node/index.cjs +5 -0
- package/http/node/index.d.cts +5 -1
- package/http/node/index.d.ts +5 -1
- package/http/node/index.js +5 -0
- package/http/web/index.cjs +7 -1
- package/http/web/index.d.cts +5 -1
- package/http/web/index.d.ts +5 -1
- package/http/web/index.js +7 -1
- package/http/web/index.umd.js +7 -1
- package/index.cjs +67 -11
- package/index.d.cts +5 -0
- package/index.d.ts +5 -0
- package/index.js +67 -11
- package/index.umd.min.d.ts +5 -0
- package/index.umd.min.js +1 -1
- package/index.umd.min.js.map +1 -1
- package/managers/index.cjs +65 -9
- package/managers/index.d.cts +4 -0
- package/managers/index.d.ts +4 -0
- package/managers/index.js +65 -9
- package/managers/index.umd.min.js +1 -1
- package/managers/index.umd.min.js.map +1 -1
- package/package.json +1 -1
package/http/node/index.cjs
CHANGED
|
@@ -28,6 +28,7 @@ var get = _interopDefault(require('simple-get'));
|
|
|
28
28
|
* @property {AsyncIterableIterator<Uint8Array>} [body] - An async iterator of Uint8Arrays that make up the body of POST requests
|
|
29
29
|
* @property {ProgressCallback} [onProgress] - Reserved for future use (emitting `GitProgressEvent`s)
|
|
30
30
|
* @property {object} [signal] - Reserved for future use (canceling a request)
|
|
31
|
+
* @property {Object} [fetchOptions={}] - Additional options to pass to fetch (Web) or simple-get (Node)
|
|
31
32
|
*/
|
|
32
33
|
|
|
33
34
|
/**
|
|
@@ -94,6 +95,7 @@ async function forAwait(iterable, cb) {
|
|
|
94
95
|
}
|
|
95
96
|
|
|
96
97
|
function asyncIteratorToStream(iter) {
|
|
98
|
+
// @ts-expect-error: readable-stream has PassThrough at runtime, types mismatch
|
|
97
99
|
const { PassThrough } = require('readable-stream');
|
|
98
100
|
const stream = new PassThrough();
|
|
99
101
|
setTimeout(async () => {
|
|
@@ -194,10 +196,12 @@ async function request({
|
|
|
194
196
|
method = 'GET',
|
|
195
197
|
headers = {},
|
|
196
198
|
agent,
|
|
199
|
+
fetchOptions = {},
|
|
197
200
|
body,
|
|
198
201
|
}) {
|
|
199
202
|
// If we can, we should send it as a single buffer so it sets a Content-Length header.
|
|
200
203
|
if (body && Array.isArray(body)) {
|
|
204
|
+
// @ts-expect-error
|
|
201
205
|
body = Buffer.from(await collect(body));
|
|
202
206
|
} else if (body) {
|
|
203
207
|
body = asyncIteratorToStream(body);
|
|
@@ -205,6 +209,7 @@ async function request({
|
|
|
205
209
|
return new Promise((resolve, reject) => {
|
|
206
210
|
get(
|
|
207
211
|
{
|
|
212
|
+
...fetchOptions,
|
|
208
213
|
url,
|
|
209
214
|
method,
|
|
210
215
|
headers,
|
package/http/node/index.d.cts
CHANGED
|
@@ -37,6 +37,10 @@ export type GitHttpRequest = {
|
|
|
37
37
|
* - Reserved for future use (canceling a request)
|
|
38
38
|
*/
|
|
39
39
|
signal?: object;
|
|
40
|
+
/**
|
|
41
|
+
* - Additional options to pass to fetch (Web) or simple-get (Node)
|
|
42
|
+
*/
|
|
43
|
+
fetchOptions?: any;
|
|
40
44
|
};
|
|
41
45
|
export type GitHttpResponse = {
|
|
42
46
|
/**
|
|
@@ -79,4 +83,4 @@ declare namespace index {
|
|
|
79
83
|
* @param {GitHttpRequest} request
|
|
80
84
|
* @returns {Promise<GitHttpResponse>}
|
|
81
85
|
*/
|
|
82
|
-
export function request({ onProgress, url, method, headers, agent, body, }: GitHttpRequest): Promise<GitHttpResponse>;
|
|
86
|
+
export function request({ onProgress, url, method, headers, agent, fetchOptions, body, }: GitHttpRequest): Promise<GitHttpResponse>;
|
package/http/node/index.d.ts
CHANGED
|
@@ -36,6 +36,10 @@ export type GitHttpRequest = {
|
|
|
36
36
|
* - Reserved for future use (canceling a request)
|
|
37
37
|
*/
|
|
38
38
|
signal?: object;
|
|
39
|
+
/**
|
|
40
|
+
* - Additional options to pass to fetch (Web) or simple-get (Node)
|
|
41
|
+
*/
|
|
42
|
+
fetchOptions?: any;
|
|
39
43
|
};
|
|
40
44
|
export type GitHttpResponse = {
|
|
41
45
|
/**
|
|
@@ -78,4 +82,4 @@ declare namespace index {
|
|
|
78
82
|
* @param {GitHttpRequest} request
|
|
79
83
|
* @returns {Promise<GitHttpResponse>}
|
|
80
84
|
*/
|
|
81
|
-
export function request({ onProgress, url, method, headers, agent, body, }: GitHttpRequest): Promise<GitHttpResponse>;
|
|
85
|
+
export function request({ onProgress, url, method, headers, agent, fetchOptions, body, }: GitHttpRequest): Promise<GitHttpResponse>;
|
package/http/node/index.js
CHANGED
|
@@ -22,6 +22,7 @@ import get from 'simple-get';
|
|
|
22
22
|
* @property {AsyncIterableIterator<Uint8Array>} [body] - An async iterator of Uint8Arrays that make up the body of POST requests
|
|
23
23
|
* @property {ProgressCallback} [onProgress] - Reserved for future use (emitting `GitProgressEvent`s)
|
|
24
24
|
* @property {object} [signal] - Reserved for future use (canceling a request)
|
|
25
|
+
* @property {Object} [fetchOptions={}] - Additional options to pass to fetch (Web) or simple-get (Node)
|
|
25
26
|
*/
|
|
26
27
|
|
|
27
28
|
/**
|
|
@@ -88,6 +89,7 @@ async function forAwait(iterable, cb) {
|
|
|
88
89
|
}
|
|
89
90
|
|
|
90
91
|
function asyncIteratorToStream(iter) {
|
|
92
|
+
// @ts-expect-error: readable-stream has PassThrough at runtime, types mismatch
|
|
91
93
|
const { PassThrough } = require('readable-stream');
|
|
92
94
|
const stream = new PassThrough();
|
|
93
95
|
setTimeout(async () => {
|
|
@@ -188,10 +190,12 @@ async function request({
|
|
|
188
190
|
method = 'GET',
|
|
189
191
|
headers = {},
|
|
190
192
|
agent,
|
|
193
|
+
fetchOptions = {},
|
|
191
194
|
body,
|
|
192
195
|
}) {
|
|
193
196
|
// If we can, we should send it as a single buffer so it sets a Content-Length header.
|
|
194
197
|
if (body && Array.isArray(body)) {
|
|
198
|
+
// @ts-expect-error
|
|
195
199
|
body = Buffer.from(await collect(body));
|
|
196
200
|
} else if (body) {
|
|
197
201
|
body = asyncIteratorToStream(body);
|
|
@@ -199,6 +203,7 @@ async function request({
|
|
|
199
203
|
return new Promise((resolve, reject) => {
|
|
200
204
|
get(
|
|
201
205
|
{
|
|
206
|
+
...fetchOptions,
|
|
202
207
|
url,
|
|
203
208
|
method,
|
|
204
209
|
headers,
|
package/http/web/index.cjs
CHANGED
|
@@ -24,6 +24,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
24
24
|
* @property {AsyncIterableIterator<Uint8Array>} [body] - An async iterator of Uint8Arrays that make up the body of POST requests
|
|
25
25
|
* @property {ProgressCallback} [onProgress] - Reserved for future use (emitting `GitProgressEvent`s)
|
|
26
26
|
* @property {object} [signal] - Reserved for future use (canceling a request)
|
|
27
|
+
* @property {Object} [fetchOptions={}] - Additional options to pass to fetch (Web) or simple-get (Node)
|
|
27
28
|
*/
|
|
28
29
|
|
|
29
30
|
/**
|
|
@@ -139,24 +140,29 @@ async function request({
|
|
|
139
140
|
url,
|
|
140
141
|
method = 'GET',
|
|
141
142
|
headers = {},
|
|
143
|
+
fetchOptions = {},
|
|
142
144
|
body,
|
|
143
145
|
}) {
|
|
144
146
|
// streaming uploads aren't possible yet in the browser
|
|
145
147
|
if (body) {
|
|
148
|
+
// @ts-expect-error
|
|
146
149
|
body = await collect(body);
|
|
147
150
|
}
|
|
148
|
-
const res = await fetch(url, { method, headers, body });
|
|
151
|
+
const res = await fetch(url, { ...fetchOptions, method, headers, body });
|
|
149
152
|
const iter =
|
|
153
|
+
// @ts-expect-error
|
|
150
154
|
res.body && res.body.getReader
|
|
151
155
|
? fromStream(res.body)
|
|
152
156
|
: [new Uint8Array(await res.arrayBuffer())];
|
|
153
157
|
// convert Header object to ordinary JSON
|
|
154
158
|
headers = {};
|
|
159
|
+
// @ts-expect-error
|
|
155
160
|
for (const [key, value] of res.headers.entries()) {
|
|
156
161
|
headers[key] = value;
|
|
157
162
|
}
|
|
158
163
|
return {
|
|
159
164
|
url: res.url,
|
|
165
|
+
// @ts-expect-error
|
|
160
166
|
method: res.method,
|
|
161
167
|
statusCode: res.status,
|
|
162
168
|
statusMessage: res.statusText,
|
package/http/web/index.d.cts
CHANGED
|
@@ -37,6 +37,10 @@ export type GitHttpRequest = {
|
|
|
37
37
|
* - Reserved for future use (canceling a request)
|
|
38
38
|
*/
|
|
39
39
|
signal?: object;
|
|
40
|
+
/**
|
|
41
|
+
* - Additional options to pass to fetch (Web) or simple-get (Node)
|
|
42
|
+
*/
|
|
43
|
+
fetchOptions?: any;
|
|
40
44
|
};
|
|
41
45
|
export type GitHttpResponse = {
|
|
42
46
|
/**
|
|
@@ -79,4 +83,4 @@ declare namespace index {
|
|
|
79
83
|
* @param {GitHttpRequest} request
|
|
80
84
|
* @returns {Promise<GitHttpResponse>}
|
|
81
85
|
*/
|
|
82
|
-
export function request({ onProgress, url, method, headers, body, }: GitHttpRequest): Promise<GitHttpResponse>;
|
|
86
|
+
export function request({ onProgress, url, method, headers, fetchOptions, body, }: GitHttpRequest): Promise<GitHttpResponse>;
|
package/http/web/index.d.ts
CHANGED
|
@@ -36,6 +36,10 @@ export type GitHttpRequest = {
|
|
|
36
36
|
* - Reserved for future use (canceling a request)
|
|
37
37
|
*/
|
|
38
38
|
signal?: object;
|
|
39
|
+
/**
|
|
40
|
+
* - Additional options to pass to fetch (Web) or simple-get (Node)
|
|
41
|
+
*/
|
|
42
|
+
fetchOptions?: any;
|
|
39
43
|
};
|
|
40
44
|
export type GitHttpResponse = {
|
|
41
45
|
/**
|
|
@@ -78,4 +82,4 @@ declare namespace index {
|
|
|
78
82
|
* @param {GitHttpRequest} request
|
|
79
83
|
* @returns {Promise<GitHttpResponse>}
|
|
80
84
|
*/
|
|
81
|
-
export function request({ onProgress, url, method, headers, body, }: GitHttpRequest): Promise<GitHttpResponse>;
|
|
85
|
+
export function request({ onProgress, url, method, headers, fetchOptions, body, }: GitHttpRequest): Promise<GitHttpResponse>;
|
package/http/web/index.js
CHANGED
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
* @property {AsyncIterableIterator<Uint8Array>} [body] - An async iterator of Uint8Arrays that make up the body of POST requests
|
|
21
21
|
* @property {ProgressCallback} [onProgress] - Reserved for future use (emitting `GitProgressEvent`s)
|
|
22
22
|
* @property {object} [signal] - Reserved for future use (canceling a request)
|
|
23
|
+
* @property {Object} [fetchOptions={}] - Additional options to pass to fetch (Web) or simple-get (Node)
|
|
23
24
|
*/
|
|
24
25
|
|
|
25
26
|
/**
|
|
@@ -135,24 +136,29 @@ async function request({
|
|
|
135
136
|
url,
|
|
136
137
|
method = 'GET',
|
|
137
138
|
headers = {},
|
|
139
|
+
fetchOptions = {},
|
|
138
140
|
body,
|
|
139
141
|
}) {
|
|
140
142
|
// streaming uploads aren't possible yet in the browser
|
|
141
143
|
if (body) {
|
|
144
|
+
// @ts-expect-error
|
|
142
145
|
body = await collect(body);
|
|
143
146
|
}
|
|
144
|
-
const res = await fetch(url, { method, headers, body });
|
|
147
|
+
const res = await fetch(url, { ...fetchOptions, method, headers, body });
|
|
145
148
|
const iter =
|
|
149
|
+
// @ts-expect-error
|
|
146
150
|
res.body && res.body.getReader
|
|
147
151
|
? fromStream(res.body)
|
|
148
152
|
: [new Uint8Array(await res.arrayBuffer())];
|
|
149
153
|
// convert Header object to ordinary JSON
|
|
150
154
|
headers = {};
|
|
155
|
+
// @ts-expect-error
|
|
151
156
|
for (const [key, value] of res.headers.entries()) {
|
|
152
157
|
headers[key] = value;
|
|
153
158
|
}
|
|
154
159
|
return {
|
|
155
160
|
url: res.url,
|
|
161
|
+
// @ts-expect-error
|
|
156
162
|
method: res.method,
|
|
157
163
|
statusCode: res.status,
|
|
158
164
|
statusMessage: res.statusText,
|
package/http/web/index.umd.js
CHANGED
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
* @property {AsyncIterableIterator<Uint8Array>} [body] - An async iterator of Uint8Arrays that make up the body of POST requests
|
|
27
27
|
* @property {ProgressCallback} [onProgress] - Reserved for future use (emitting `GitProgressEvent`s)
|
|
28
28
|
* @property {object} [signal] - Reserved for future use (canceling a request)
|
|
29
|
+
* @property {Object} [fetchOptions={}] - Additional options to pass to fetch (Web) or simple-get (Node)
|
|
29
30
|
*/
|
|
30
31
|
|
|
31
32
|
/**
|
|
@@ -141,24 +142,29 @@
|
|
|
141
142
|
url,
|
|
142
143
|
method = 'GET',
|
|
143
144
|
headers = {},
|
|
145
|
+
fetchOptions = {},
|
|
144
146
|
body,
|
|
145
147
|
}) {
|
|
146
148
|
// streaming uploads aren't possible yet in the browser
|
|
147
149
|
if (body) {
|
|
150
|
+
// @ts-expect-error
|
|
148
151
|
body = await collect(body);
|
|
149
152
|
}
|
|
150
|
-
const res = await fetch(url, { method, headers, body });
|
|
153
|
+
const res = await fetch(url, { ...fetchOptions, method, headers, body });
|
|
151
154
|
const iter =
|
|
155
|
+
// @ts-expect-error
|
|
152
156
|
res.body && res.body.getReader
|
|
153
157
|
? fromStream(res.body)
|
|
154
158
|
: [new Uint8Array(await res.arrayBuffer())];
|
|
155
159
|
// convert Header object to ordinary JSON
|
|
156
160
|
headers = {};
|
|
161
|
+
// @ts-expect-error
|
|
157
162
|
for (const [key, value] of res.headers.entries()) {
|
|
158
163
|
headers[key] = value;
|
|
159
164
|
}
|
|
160
165
|
return {
|
|
161
166
|
url: res.url,
|
|
167
|
+
// @ts-expect-error
|
|
162
168
|
method: res.method,
|
|
163
169
|
statusCode: res.status,
|
|
164
170
|
statusMessage: res.statusText,
|
package/index.cjs
CHANGED
|
@@ -36,6 +36,7 @@ var diff3Merge = _interopDefault(require('diff3'));
|
|
|
36
36
|
* @property {AsyncIterableIterator<Uint8Array>} [body] - An async iterator of Uint8Arrays that make up the body of POST requests
|
|
37
37
|
* @property {ProgressCallback} [onProgress] - Reserved for future use (emitting `GitProgressEvent`s)
|
|
38
38
|
* @property {object} [signal] - Reserved for future use (canceling a request)
|
|
39
|
+
* @property {Object} [fetchOptions={}] - Additional options to pass to fetch (Web) or simple-get (Node)
|
|
39
40
|
*/
|
|
40
41
|
|
|
41
42
|
/**
|
|
@@ -8973,21 +8974,76 @@ async function collect(iterable) {
|
|
|
8973
8974
|
return result
|
|
8974
8975
|
}
|
|
8975
8976
|
|
|
8977
|
+
// The `@` that ends the credentials is the last one in the authority, and the
|
|
8978
|
+
// scheme is matched case-insensitively: `HTTPS://user:pass@host/x` is a URL
|
|
8979
|
+
// like any other, and leaving the credentials in it is what `fetch` rejects.
|
|
8980
|
+
// The authority ends at the first `/`, `?` or `#`, so an `@` that lives in a
|
|
8981
|
+
// query or a fragment is left where it is.
|
|
8982
|
+
const CREDENTIALS = /^(https?:\/\/)([^/?#]+)@/i;
|
|
8983
|
+
|
|
8976
8984
|
function extractAuthFromUrl(url) {
|
|
8977
8985
|
// For whatever reason, the `fetch` API does not convert credentials embedded in the URL
|
|
8978
8986
|
// into Basic Authentication headers automatically. Instead it throws an error!
|
|
8979
8987
|
// So we must manually parse the URL, rip out the user:password portion if it is present
|
|
8980
8988
|
// and compute the Authorization header.
|
|
8981
|
-
|
|
8982
|
-
let userpass = url.match(/^https?:\/\/([^/]+)@/);
|
|
8989
|
+
const credentials = url.match(CREDENTIALS);
|
|
8983
8990
|
// No credentials, return the url unmodified and an empty auth object
|
|
8984
|
-
if (
|
|
8985
|
-
|
|
8986
|
-
|
|
8987
|
-
//
|
|
8988
|
-
|
|
8989
|
-
//
|
|
8990
|
-
return {
|
|
8991
|
+
if (credentials == null) return { url, auth: {} }
|
|
8992
|
+
// Has credentials, return the fetch-safe URL and the parsed credentials.
|
|
8993
|
+
// The credentials are cut out of the original string rather than read back
|
|
8994
|
+
// off the parsed URL: serializing that one would also drop an explicit
|
|
8995
|
+
// `:443` and append a slash to a URL that has no path, and this return value
|
|
8996
|
+
// is what the request goes out against.
|
|
8997
|
+
return {
|
|
8998
|
+
url: url.replace(CREDENTIALS, '$1'),
|
|
8999
|
+
auth: parseUserinfo(url, credentials[2]),
|
|
9000
|
+
}
|
|
9001
|
+
}
|
|
9002
|
+
|
|
9003
|
+
function parseUserinfo(url, userpass) {
|
|
9004
|
+
// `URL` splits the two halves the way the platform does, so the first colon
|
|
9005
|
+
// separates them and any later one stays in the password. Only the split is
|
|
9006
|
+
// taken from it, for the reason above.
|
|
9007
|
+
const parsed = parseUrl(url);
|
|
9008
|
+
// A password is absent, not empty, when no colon was written at all. `URL`
|
|
9009
|
+
// reports `''` for both, and the difference is worth keeping.
|
|
9010
|
+
const hasPassword = userpass.indexOf(':') !== -1;
|
|
9011
|
+
|
|
9012
|
+
if (parsed !== null) {
|
|
9013
|
+
return {
|
|
9014
|
+
username: decodeUserinfo(parsed.username),
|
|
9015
|
+
password: hasPassword ? decodeUserinfo(parsed.password) : undefined,
|
|
9016
|
+
}
|
|
9017
|
+
}
|
|
9018
|
+
|
|
9019
|
+
// No `URL` to parse with, or it rejected a string the expression above
|
|
9020
|
+
// accepted. Split on the first colon by hand, without the percent-decoding.
|
|
9021
|
+
const separatorIndex = userpass.indexOf(':');
|
|
9022
|
+
return {
|
|
9023
|
+
username: hasPassword ? userpass.slice(0, separatorIndex) : userpass,
|
|
9024
|
+
password: hasPassword ? userpass.slice(separatorIndex + 1) : undefined,
|
|
9025
|
+
}
|
|
9026
|
+
}
|
|
9027
|
+
|
|
9028
|
+
function parseUrl(url) {
|
|
9029
|
+
if (typeof URL !== 'function') return null
|
|
9030
|
+
try {
|
|
9031
|
+
return new URL(url)
|
|
9032
|
+
} catch (_) {
|
|
9033
|
+
return null
|
|
9034
|
+
}
|
|
9035
|
+
}
|
|
9036
|
+
|
|
9037
|
+
// `URL` hands back the userinfo still percent-encoded, so `p:ss` arrives as
|
|
9038
|
+
// `p%3Ass` and has to be decoded before it reaches the Authorization header. A
|
|
9039
|
+
// lone `%` is not something the parser encodes, and it makes the decode throw,
|
|
9040
|
+
// so the raw value stands in whenever the decode fails.
|
|
9041
|
+
function decodeUserinfo(value) {
|
|
9042
|
+
try {
|
|
9043
|
+
return decodeURIComponent(value)
|
|
9044
|
+
} catch (_) {
|
|
9045
|
+
return value
|
|
9046
|
+
}
|
|
8991
9047
|
}
|
|
8992
9048
|
|
|
8993
9049
|
function padHex(b, n) {
|
|
@@ -9629,8 +9685,8 @@ function filterCapabilities(server, client) {
|
|
|
9629
9685
|
|
|
9630
9686
|
const pkg = {
|
|
9631
9687
|
name: 'isomorphic-git',
|
|
9632
|
-
version: '1.
|
|
9633
|
-
agent: 'git/isomorphic-git@1.
|
|
9688
|
+
version: '1.41.1',
|
|
9689
|
+
agent: 'git/isomorphic-git@1.41.1',
|
|
9634
9690
|
};
|
|
9635
9691
|
|
|
9636
9692
|
class FIFO {
|
package/index.d.cts
CHANGED
|
@@ -305,6 +305,10 @@ export type GitHttpRequest = {
|
|
|
305
305
|
* - Reserved for future use (canceling a request)
|
|
306
306
|
*/
|
|
307
307
|
signal?: object;
|
|
308
|
+
/**
|
|
309
|
+
* - Additional options to pass to fetch (Web) or simple-get (Node)
|
|
310
|
+
*/
|
|
311
|
+
fetchOptions?: any;
|
|
308
312
|
};
|
|
309
313
|
export type GitHttpResponse = {
|
|
310
314
|
/**
|
|
@@ -4501,6 +4505,7 @@ declare namespace NoCommitError {
|
|
|
4501
4505
|
* @property {AsyncIterableIterator<Uint8Array>} [body] - An async iterator of Uint8Arrays that make up the body of POST requests
|
|
4502
4506
|
* @property {ProgressCallback} [onProgress] - Reserved for future use (emitting `GitProgressEvent`s)
|
|
4503
4507
|
* @property {object} [signal] - Reserved for future use (canceling a request)
|
|
4508
|
+
* @property {Object} [fetchOptions={}] - Additional options to pass to fetch (Web) or simple-get (Node)
|
|
4504
4509
|
*/
|
|
4505
4510
|
/**
|
|
4506
4511
|
* @typedef {Object} GitHttpResponse
|
package/index.d.ts
CHANGED
|
@@ -304,6 +304,10 @@ export type GitHttpRequest = {
|
|
|
304
304
|
* - Reserved for future use (canceling a request)
|
|
305
305
|
*/
|
|
306
306
|
signal?: object;
|
|
307
|
+
/**
|
|
308
|
+
* - Additional options to pass to fetch (Web) or simple-get (Node)
|
|
309
|
+
*/
|
|
310
|
+
fetchOptions?: any;
|
|
307
311
|
};
|
|
308
312
|
export type GitHttpResponse = {
|
|
309
313
|
/**
|
|
@@ -4500,6 +4504,7 @@ declare namespace NoCommitError {
|
|
|
4500
4504
|
* @property {AsyncIterableIterator<Uint8Array>} [body] - An async iterator of Uint8Arrays that make up the body of POST requests
|
|
4501
4505
|
* @property {ProgressCallback} [onProgress] - Reserved for future use (emitting `GitProgressEvent`s)
|
|
4502
4506
|
* @property {object} [signal] - Reserved for future use (canceling a request)
|
|
4507
|
+
* @property {Object} [fetchOptions={}] - Additional options to pass to fetch (Web) or simple-get (Node)
|
|
4503
4508
|
*/
|
|
4504
4509
|
/**
|
|
4505
4510
|
* @typedef {Object} GitHttpResponse
|
package/index.js
CHANGED
|
@@ -29,6 +29,7 @@ import diff3Merge from 'diff3';
|
|
|
29
29
|
* @property {AsyncIterableIterator<Uint8Array>} [body] - An async iterator of Uint8Arrays that make up the body of POST requests
|
|
30
30
|
* @property {ProgressCallback} [onProgress] - Reserved for future use (emitting `GitProgressEvent`s)
|
|
31
31
|
* @property {object} [signal] - Reserved for future use (canceling a request)
|
|
32
|
+
* @property {Object} [fetchOptions={}] - Additional options to pass to fetch (Web) or simple-get (Node)
|
|
32
33
|
*/
|
|
33
34
|
|
|
34
35
|
/**
|
|
@@ -8960,21 +8961,76 @@ async function collect(iterable) {
|
|
|
8960
8961
|
return result
|
|
8961
8962
|
}
|
|
8962
8963
|
|
|
8964
|
+
// The `@` that ends the credentials is the last one in the authority, and the
|
|
8965
|
+
// scheme is matched case-insensitively: `HTTPS://user:pass@host/x` is a URL
|
|
8966
|
+
// like any other, and leaving the credentials in it is what `fetch` rejects.
|
|
8967
|
+
// The authority ends at the first `/`, `?` or `#`, so an `@` that lives in a
|
|
8968
|
+
// query or a fragment is left where it is.
|
|
8969
|
+
const CREDENTIALS = /^(https?:\/\/)([^/?#]+)@/i;
|
|
8970
|
+
|
|
8963
8971
|
function extractAuthFromUrl(url) {
|
|
8964
8972
|
// For whatever reason, the `fetch` API does not convert credentials embedded in the URL
|
|
8965
8973
|
// into Basic Authentication headers automatically. Instead it throws an error!
|
|
8966
8974
|
// So we must manually parse the URL, rip out the user:password portion if it is present
|
|
8967
8975
|
// and compute the Authorization header.
|
|
8968
|
-
|
|
8969
|
-
let userpass = url.match(/^https?:\/\/([^/]+)@/);
|
|
8976
|
+
const credentials = url.match(CREDENTIALS);
|
|
8970
8977
|
// No credentials, return the url unmodified and an empty auth object
|
|
8971
|
-
if (
|
|
8972
|
-
|
|
8973
|
-
|
|
8974
|
-
//
|
|
8975
|
-
|
|
8976
|
-
//
|
|
8977
|
-
return {
|
|
8978
|
+
if (credentials == null) return { url, auth: {} }
|
|
8979
|
+
// Has credentials, return the fetch-safe URL and the parsed credentials.
|
|
8980
|
+
// The credentials are cut out of the original string rather than read back
|
|
8981
|
+
// off the parsed URL: serializing that one would also drop an explicit
|
|
8982
|
+
// `:443` and append a slash to a URL that has no path, and this return value
|
|
8983
|
+
// is what the request goes out against.
|
|
8984
|
+
return {
|
|
8985
|
+
url: url.replace(CREDENTIALS, '$1'),
|
|
8986
|
+
auth: parseUserinfo(url, credentials[2]),
|
|
8987
|
+
}
|
|
8988
|
+
}
|
|
8989
|
+
|
|
8990
|
+
function parseUserinfo(url, userpass) {
|
|
8991
|
+
// `URL` splits the two halves the way the platform does, so the first colon
|
|
8992
|
+
// separates them and any later one stays in the password. Only the split is
|
|
8993
|
+
// taken from it, for the reason above.
|
|
8994
|
+
const parsed = parseUrl(url);
|
|
8995
|
+
// A password is absent, not empty, when no colon was written at all. `URL`
|
|
8996
|
+
// reports `''` for both, and the difference is worth keeping.
|
|
8997
|
+
const hasPassword = userpass.indexOf(':') !== -1;
|
|
8998
|
+
|
|
8999
|
+
if (parsed !== null) {
|
|
9000
|
+
return {
|
|
9001
|
+
username: decodeUserinfo(parsed.username),
|
|
9002
|
+
password: hasPassword ? decodeUserinfo(parsed.password) : undefined,
|
|
9003
|
+
}
|
|
9004
|
+
}
|
|
9005
|
+
|
|
9006
|
+
// No `URL` to parse with, or it rejected a string the expression above
|
|
9007
|
+
// accepted. Split on the first colon by hand, without the percent-decoding.
|
|
9008
|
+
const separatorIndex = userpass.indexOf(':');
|
|
9009
|
+
return {
|
|
9010
|
+
username: hasPassword ? userpass.slice(0, separatorIndex) : userpass,
|
|
9011
|
+
password: hasPassword ? userpass.slice(separatorIndex + 1) : undefined,
|
|
9012
|
+
}
|
|
9013
|
+
}
|
|
9014
|
+
|
|
9015
|
+
function parseUrl(url) {
|
|
9016
|
+
if (typeof URL !== 'function') return null
|
|
9017
|
+
try {
|
|
9018
|
+
return new URL(url)
|
|
9019
|
+
} catch (_) {
|
|
9020
|
+
return null
|
|
9021
|
+
}
|
|
9022
|
+
}
|
|
9023
|
+
|
|
9024
|
+
// `URL` hands back the userinfo still percent-encoded, so `p:ss` arrives as
|
|
9025
|
+
// `p%3Ass` and has to be decoded before it reaches the Authorization header. A
|
|
9026
|
+
// lone `%` is not something the parser encodes, and it makes the decode throw,
|
|
9027
|
+
// so the raw value stands in whenever the decode fails.
|
|
9028
|
+
function decodeUserinfo(value) {
|
|
9029
|
+
try {
|
|
9030
|
+
return decodeURIComponent(value)
|
|
9031
|
+
} catch (_) {
|
|
9032
|
+
return value
|
|
9033
|
+
}
|
|
8978
9034
|
}
|
|
8979
9035
|
|
|
8980
9036
|
function padHex(b, n) {
|
|
@@ -9616,8 +9672,8 @@ function filterCapabilities(server, client) {
|
|
|
9616
9672
|
|
|
9617
9673
|
const pkg = {
|
|
9618
9674
|
name: 'isomorphic-git',
|
|
9619
|
-
version: '1.
|
|
9620
|
-
agent: 'git/isomorphic-git@1.
|
|
9675
|
+
version: '1.41.1',
|
|
9676
|
+
agent: 'git/isomorphic-git@1.41.1',
|
|
9621
9677
|
};
|
|
9622
9678
|
|
|
9623
9679
|
class FIFO {
|
package/index.umd.min.d.ts
CHANGED
|
@@ -304,6 +304,10 @@ export type GitHttpRequest = {
|
|
|
304
304
|
* - Reserved for future use (canceling a request)
|
|
305
305
|
*/
|
|
306
306
|
signal?: object;
|
|
307
|
+
/**
|
|
308
|
+
* - Additional options to pass to fetch (Web) or simple-get (Node)
|
|
309
|
+
*/
|
|
310
|
+
fetchOptions?: any;
|
|
307
311
|
};
|
|
308
312
|
export type GitHttpResponse = {
|
|
309
313
|
/**
|
|
@@ -4500,6 +4504,7 @@ declare namespace NoCommitError {
|
|
|
4500
4504
|
* @property {AsyncIterableIterator<Uint8Array>} [body] - An async iterator of Uint8Arrays that make up the body of POST requests
|
|
4501
4505
|
* @property {ProgressCallback} [onProgress] - Reserved for future use (emitting `GitProgressEvent`s)
|
|
4502
4506
|
* @property {object} [signal] - Reserved for future use (canceling a request)
|
|
4507
|
+
* @property {Object} [fetchOptions={}] - Additional options to pass to fetch (Web) or simple-get (Node)
|
|
4503
4508
|
*/
|
|
4504
4509
|
/**
|
|
4505
4510
|
* @typedef {Object} GitHttpResponse
|