ipfs-utils
Advanced tools
Comparing version 9.0.6 to 9.0.7
@@ -1,8 +0,6 @@ | ||
declare const _exports: { | ||
default: any; | ||
Headers: any; | ||
Request: any; | ||
Response: any; | ||
}; | ||
declare const _exports: any; | ||
export = _exports; | ||
export type Headers = globalThis.Headers; | ||
export type Request = globalThis.Request; | ||
export type Response = globalThis.Response; | ||
//# sourceMappingURL=fetch.d.ts.map |
@@ -49,3 +49,3 @@ /// <reference types="node" /> | ||
type HTTPOptions = import('./types').HTTPOptions; | ||
import { Request } from "./http/fetch.browser"; | ||
import { Request } from "./http/fetch"; | ||
type ExtendedResponse = import('./types').ExtendedResponse; | ||
@@ -52,0 +52,0 @@ import { HTTPError } from "./http/error"; |
@@ -8,5 +8,5 @@ export type FetchOptions = import('../types').FetchOptions; | ||
declare function fetchWith(url: string | Request, options?: FetchOptions): any; | ||
import { Request } from "native-fetch"; | ||
import { Headers } from "native-fetch"; | ||
import { Request } from "../fetch"; | ||
import { Headers } from "../fetch"; | ||
export { fetchWith as fetch, Request, Headers }; | ||
//# sourceMappingURL=fetch.browser.d.ts.map |
@@ -1,7 +0,13 @@ | ||
declare const _exports: { | ||
fetch: (url: string | Request, options?: import("../types").FetchOptions) => any; | ||
Request: any; | ||
Headers: any; | ||
export = fetch; | ||
/** @type {fetchImpl} */ | ||
declare const fetch: fetchImpl; | ||
declare namespace fetch { | ||
export { fetchImpl }; | ||
} | ||
type fetchImpl = { | ||
fetch: typeof globalThis.fetch; | ||
Request: globalThis.Request; | ||
Response: globalThis.Response; | ||
Headers: globalThis.Headers; | ||
}; | ||
export = _exports; | ||
//# sourceMappingURL=fetch.d.ts.map |
@@ -16,6 +16,6 @@ export type NodeReadableStream = import('stream').Readable; | ||
export function fetch(url: string | Request, options?: import("../types").FetchOptions | undefined): Promise<Response>; | ||
import { Request } from "native-fetch"; | ||
import { Headers } from "native-fetch"; | ||
import { Response } from "native-fetch"; | ||
import { Request } from "../fetch"; | ||
import { Headers } from "../fetch"; | ||
import { Response } from "../fetch"; | ||
export { Request, Headers }; | ||
//# sourceMappingURL=fetch.node.d.ts.map |
@@ -8,5 +8,5 @@ export type FetchOptions = import('../types').FetchOptions; | ||
declare function fetchWith(url: string | Request, options?: FetchOptions): any; | ||
import { Request } from "native-fetch"; | ||
import { Headers } from "native-fetch"; | ||
export class ResponseWithURL { | ||
import { Request } from "../fetch"; | ||
import { Headers } from "../fetch"; | ||
export class ResponseWithURL extends globalThis.Response { | ||
/** | ||
@@ -13,0 +13,0 @@ * @param {string} url |
{ | ||
"name": "ipfs-utils", | ||
"version": "9.0.6", | ||
"version": "9.0.7", | ||
"description": "Package to aggregate shared logic and dependencies for the IPFS ecosystem", | ||
@@ -18,2 +18,3 @@ "main": "src/index.js", | ||
"./src/path-join.js": "./src/path-join.browser.js", | ||
"./src/fetch.js": "./src/fetch.browser.js", | ||
"./src/files/glob-source.js": false, | ||
@@ -20,0 +21,0 @@ "./test/files/glob-source.spec.js": false, |
@@ -10,6 +10,6 @@ 'use strict' | ||
const IS_ELECTRON_RENDERER = IS_ELECTRON && IS_ENV_WITH_DOM | ||
const IS_NODE = typeof require === 'function' && typeof globalThis.process !== 'undefined' && typeof globalThis.process.release !== 'undefined' && globalThis.process.release.name === 'node' && !IS_ELECTRON | ||
const IS_NODE = typeof require === 'function' && typeof process !== 'undefined' && typeof process.release !== 'undefined' && process.release.name === 'node' && !IS_ELECTRON | ||
// @ts-ignore - we either ignore worker scope or dom scope | ||
const IS_WEBWORKER = typeof importScripts === 'function' && typeof self !== 'undefined' && typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope | ||
const IS_TEST = typeof globalThis.process !== 'undefined' && typeof globalThis.process.env !== 'undefined' && globalThis.process.env.NODE_ENV === 'test' | ||
const IS_TEST = typeof process !== 'undefined' && typeof process.env !== 'undefined' && process.env.NODE_ENV === 'test' | ||
const IS_REACT_NATIVE = typeof navigator !== 'undefined' && navigator.product === 'ReactNative' | ||
@@ -16,0 +16,0 @@ |
'use strict' | ||
/** | ||
* @typedef {globalThis.Headers} Headers | ||
* @typedef {globalThis.Request} Request | ||
* @typedef {globalThis.Response} Response | ||
*/ | ||
const { isElectronMain } = require('./env') | ||
// use window.fetch if it is available, fall back to node-fetch if not | ||
let impl = 'native-fetch' | ||
if (isElectronMain) { | ||
module.exports = require('electron-fetch') | ||
} else { | ||
// use window.fetch if it is available, fall back to node-fetch if not | ||
module.exports = require('native-fetch') | ||
impl = 'electron-fetch' | ||
} | ||
module.exports = require(impl) |
@@ -94,5 +94,7 @@ /* eslint-disable no-undef */ | ||
const opts = merge(this.opts, options) | ||
// @ts-expect-error | ||
const headers = new Headers(opts.headers) | ||
// validate resource type | ||
// @ts-expect-error | ||
if (typeof resource !== 'string' && !(resource instanceof URL || resource instanceof Request)) { | ||
@@ -129,2 +131,4 @@ throw new TypeError('`resource` must be a string, URL, or Request') | ||
/** @type {ExtendedResponse} */ | ||
// @ts-expect-error additional fields are assigned below | ||
const response = await timeout( | ||
@@ -136,2 +140,3 @@ fetch( | ||
signal, | ||
// @ts-expect-error non-browser fetch implementations may take extra options | ||
timeout: undefined, | ||
@@ -152,4 +157,4 @@ headers | ||
response.iterator = function () { | ||
return fromStream(response.body) | ||
response.iterator = async function * () { | ||
yield * fromStream(response.body) | ||
} | ||
@@ -156,0 +161,0 @@ |
'use strict' | ||
const { TimeoutError, AbortError } = require('./error') | ||
// @ts-expect-error | ||
const { Response, Request, Headers, default: fetch } = require('../fetch') | ||
@@ -5,0 +6,0 @@ |
'use strict' | ||
/** | ||
* @typedef {object} fetchImpl | ||
* @property {globalThis.fetch} fetchImpl.fetch | ||
* @property {globalThis.Request} fetchImpl.Request | ||
* @property {globalThis.Response} fetchImpl.Response | ||
* @property {globalThis.Headers} fetchImpl.Headers | ||
*/ | ||
let implName = './fetch.node' | ||
if (typeof XMLHttpRequest === 'function') { | ||
// Electron has `XMLHttpRequest` and should get the browser implementation | ||
// instead of node. | ||
module.exports = require('./fetch.browser') | ||
} else { | ||
module.exports = require('./fetch.node') | ||
implName = './fetch.browser' | ||
} | ||
/** @type {fetchImpl} */ | ||
const fetch = require(implName) | ||
module.exports = fetch |
@@ -36,3 +36,5 @@ 'use strict' | ||
// @ts-expect-error this is node-fetch | ||
const rsp = new Response(content) | ||
// @ts-expect-error this is node-fetch | ||
const source = iterateBodyWithProgress(/** @type {NodeReadableStream} */(rsp.body), onUploadProgress) | ||
@@ -39,0 +41,0 @@ return { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
53341
60
1271
8
6