@pnpm/network.fetch 1100.0.1 → 1100.0.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 +3 -3
- package/lib/fetchFromRegistry.d.ts +14 -0
- package/lib/fetchFromRegistry.js +14 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/package.json +7 -6
package/README.md
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
# @pnpm/fetch
|
|
1
|
+
# @pnpm/network.fetch
|
|
2
2
|
|
|
3
3
|
> node-fetch with retries
|
|
4
4
|
|
|
5
5
|
<!--@shields('npm')-->
|
|
6
|
-
[](https://
|
|
6
|
+
[](https://npmx.dev/package/@pnpm/network.fetch)
|
|
7
7
|
<!--/@-->
|
|
8
8
|
|
|
9
9
|
## Installation
|
|
10
10
|
|
|
11
11
|
```sh
|
|
12
|
-
pnpm add @pnpm/fetch
|
|
12
|
+
pnpm add @pnpm/network.fetch
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
## License
|
|
@@ -7,6 +7,20 @@ export interface FetchWithDispatcherOptions extends RequestInit {
|
|
|
7
7
|
dispatcherOptions: DispatcherOptions;
|
|
8
8
|
}
|
|
9
9
|
export declare function fetchWithDispatcher(url: string | URL, opts: FetchWithDispatcherOptions): Promise<Response>;
|
|
10
|
+
export interface CreateDispatchedFetchOptions extends DispatcherOptions {
|
|
11
|
+
/**
|
|
12
|
+
* Per-registry config (TLS, auth, etc.). When set, the matching TLS entries
|
|
13
|
+
* are automatically extracted into `clientCertificates` so callers don't
|
|
14
|
+
* have to do it themselves.
|
|
15
|
+
*/
|
|
16
|
+
configByUri?: Record<string, RegistryConfig>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Returns a {@link fetch} pre-bound to the given dispatcher options, so callers
|
|
20
|
+
* that need a fetch function (rather than a one-shot call) can route their
|
|
21
|
+
* requests through the configured proxy / TLS / local-address settings.
|
|
22
|
+
*/
|
|
23
|
+
export declare function createDispatchedFetch(opts: CreateDispatchedFetchOptions): (url: string | URL, opts?: RequestInit) => Promise<Response>;
|
|
10
24
|
export type { DispatcherOptions };
|
|
11
25
|
export interface CreateFetchFromRegistryOptions extends DispatcherOptions {
|
|
12
26
|
userAgent?: string;
|
package/lib/fetchFromRegistry.js
CHANGED
|
@@ -17,7 +17,20 @@ export function fetchWithDispatcher(url, opts) {
|
|
|
17
17
|
dispatcher,
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Returns a {@link fetch} pre-bound to the given dispatcher options, so callers
|
|
22
|
+
* that need a fetch function (rather than a one-shot call) can route their
|
|
23
|
+
* requests through the configured proxy / TLS / local-address settings.
|
|
24
|
+
*/
|
|
25
|
+
export function createDispatchedFetch(opts) {
|
|
26
|
+
const dispatcherOptions = {
|
|
27
|
+
...opts,
|
|
28
|
+
clientCertificates: opts.clientCertificates ?? extractTlsConfigs(opts.configByUri),
|
|
29
|
+
};
|
|
30
|
+
return (url, fetchOpts) => fetchWithDispatcher(url, { ...fetchOpts, dispatcherOptions });
|
|
31
|
+
}
|
|
20
32
|
export function createFetchFromRegistry(defaultOpts) {
|
|
33
|
+
const clientCertificates = extractTlsConfigs(defaultOpts.configByUri);
|
|
21
34
|
return async (url, opts) => {
|
|
22
35
|
const headers = {
|
|
23
36
|
'user-agent': USER_AGENT,
|
|
@@ -51,7 +64,7 @@ export function createFetchFromRegistry(defaultOpts) {
|
|
|
51
64
|
...defaultOpts,
|
|
52
65
|
...opts,
|
|
53
66
|
strictSsl: defaultOpts.strictSsl ?? true,
|
|
54
|
-
clientCertificates
|
|
67
|
+
clientCertificates,
|
|
55
68
|
};
|
|
56
69
|
const response = await fetchWithDispatcher(urlObject, {
|
|
57
70
|
dispatcherOptions,
|
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { clearDispatcherCache, getDispatcher } from './dispatcher.js';
|
|
2
2
|
export { fetch, isRedirect, type RetryTimeoutOptions } from './fetch.js';
|
|
3
|
-
export { createFetchFromRegistry, type CreateFetchFromRegistryOptions, type DispatcherOptions, fetchWithDispatcher } from './fetchFromRegistry.js';
|
|
3
|
+
export { createDispatchedFetch, type CreateDispatchedFetchOptions, createFetchFromRegistry, type CreateFetchFromRegistryOptions, type DispatcherOptions, fetchWithDispatcher } from './fetchFromRegistry.js';
|
|
4
4
|
export type { FetchFromRegistry } from '@pnpm/fetching.types';
|
package/lib/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { clearDispatcherCache, getDispatcher } from './dispatcher.js';
|
|
2
2
|
export { fetch, isRedirect } from './fetch.js';
|
|
3
|
-
export { createFetchFromRegistry, fetchWithDispatcher } from './fetchFromRegistry.js';
|
|
3
|
+
export { createDispatchedFetch, createFetchFromRegistry, fetchWithDispatcher } from './fetchFromRegistry.js';
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pnpm/network.fetch",
|
|
3
|
-
"version": "1100.0.
|
|
3
|
+
"version": "1100.0.3",
|
|
4
4
|
"description": "Native fetch with retries",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pnpm",
|
|
@@ -31,18 +31,19 @@
|
|
|
31
31
|
"lru-cache": "^11.2.7",
|
|
32
32
|
"socks": "^2.8.1",
|
|
33
33
|
"undici": "^7.2.0",
|
|
34
|
-
"@pnpm/core-loggers": "1100.0.1",
|
|
35
34
|
"@pnpm/error": "1100.0.0",
|
|
36
|
-
"@pnpm/
|
|
37
|
-
"@pnpm/
|
|
35
|
+
"@pnpm/core-loggers": "1100.0.2",
|
|
36
|
+
"@pnpm/types": "1101.1.0",
|
|
37
|
+
"@pnpm/fetching.types": "1100.0.1"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"@pnpm/logger": ">=1001.0.0 <1002.0.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
+
"@jest/globals": "30.3.0",
|
|
43
44
|
"https-proxy-server-express": "0.1.2",
|
|
44
|
-
"@pnpm/
|
|
45
|
-
"@pnpm/
|
|
45
|
+
"@pnpm/network.fetch": "1100.0.3",
|
|
46
|
+
"@pnpm/logger": "1100.0.0"
|
|
46
47
|
},
|
|
47
48
|
"engines": {
|
|
48
49
|
"node": ">=22.13"
|