From f83444708097f39679f27fb3ab3535240a71c741 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Wed, 4 Sep 2024 12:26:30 -0400 Subject: [PATCH] ? --- dist/index.js | 5249 +----------------------------------------------- package.json | 4 +- pnpm-lock.yaml | 49 +- 3 files changed, 72 insertions(+), 5230 deletions(-) diff --git a/dist/index.js b/dist/index.js index c45fa4e..ccaec10 100644 --- a/dist/index.js +++ b/dist/index.js @@ -91501,7 +91501,7 @@ const nodeImports = {}; ;// CONCATENATED MODULE: ./node_modules/.pnpm/get-stream@9.0.1/node_modules/get-stream/source/contents.js -const contents_getStreamContents = async (stream, {init, convertChunk, getSize, truncateChunk, addChunk, getFinalChunk, finalize}, {maxBuffer = Number.POSITIVE_INFINITY} = {}) => { +const getStreamContents = async (stream, {init, convertChunk, getSize, truncateChunk, addChunk, getFinalChunk, finalize}, {maxBuffer = Number.POSITIVE_INFINITY} = {}) => { const asyncIterable = getAsyncIterable(stream); const state = init(); @@ -91639,7 +91639,7 @@ const getLengthProperty = convertedChunk => convertedChunk.length; async function getStreamAsArrayBuffer(stream, options) { - return contents_getStreamContents(stream, arrayBufferMethods, options); + return getStreamContents(stream, arrayBufferMethods, options); } const initArrayBuffer = () => ({contents: new ArrayBuffer(0)}); @@ -96403,9 +96403,7 @@ const external_node_dns_promises_namespaceObject = __WEBPACK_EXTERNAL_createRequ var cache = __nccwpck_require__(6878); ;// CONCATENATED MODULE: external "node:child_process" const external_node_child_process_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:child_process"); -;// CONCATENATED MODULE: external "node:stream/promises" -const external_node_stream_promises_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:stream/promises"); -;// CONCATENATED MODULE: ./node_modules/.pnpm/github.com+DeterminateSystems+detsys-ts@817e4d4123b6fb4eae5aa557658f25f8539e7240_cyq6j27kjpra3jtdpg5422ffka/node_modules/detsys-ts/dist/index.js +;// CONCATENATED MODULE: ./node_modules/.pnpm/github.com+DeterminateSystems+detsys-ts@b32eaff5853519dc6c92a63bac86f5169bc07112_yhfhaezty374j2ssralz6bnlie/node_modules/detsys-ts/dist/index.js var __defProp = Object.defineProperty; var __export = (target, all) => { for (var name in all) @@ -96879,7 +96877,7 @@ var ALLOWED_SUFFIXES = [ ]; var DEFAULT_IDS_HOST = "https://install.determinate.systems"; var LOOKUP = process.env["IDS_LOOKUP"] ?? DEFAULT_LOOKUP; -var DEFAULT_TIMEOUT = 3e4; +var DEFAULT_TIMEOUT = 1e4; var IdsHost = class { constructor(idsProjectName, diagnosticsSuffix, runtimeDiagnosticsUrl) { this.idsProjectName = idsProjectName; @@ -96894,7 +96892,7 @@ var IdsHost = class { request: DEFAULT_TIMEOUT }, retry: { - limit: (await this.getUrlsByPreference()).length, + limit: Math.max((await this.getUrlsByPreference()).length, 3), methods: ["GET", "HEAD"] }, hooks: { @@ -96904,7 +96902,7 @@ var IdsHost = class { this.markCurrentHostBroken(); const nextUrl = await this.getRootUrl(); if (recordFailoverCallback !== void 0) { - recordFailoverCallback(prevUrl, nextUrl); + recordFailoverCallback(error3, prevUrl, nextUrl); } core.info( `Retrying after error ${error3.code}, retry #: ${retryCount}` @@ -97290,8 +97288,8 @@ var STATE_KEY_NIX_NOT_FOUND = "detsys_action_nix_not_found"; var STATE_NOT_FOUND = "not-found"; var STATE_KEY_CROSS_PHASE_ID = "detsys_cross_phase_id"; var STATE_BACKTRACE_START_TIMESTAMP = "detsys_backtrace_start_timestamp"; -var DIAGNOSTIC_ENDPOINT_TIMEOUT_MS = 3e4; -var CHECK_IN_ENDPOINT_TIMEOUT_MS = 5e3; +var DIAGNOSTIC_ENDPOINT_TIMEOUT_MS = 1e3; +var CHECK_IN_ENDPOINT_TIMEOUT_MS = 1e3; var DetSysAction = class { determineExecutionPhase() { const currentPhase = core.getState(STATE_KEY_EXECUTION_PHASE); @@ -97515,12 +97513,15 @@ var DetSysAction = class { } } async getClient() { - return await this.idsHost.getGot((prevUrl, nextUrl) => { - this.recordEvent("ids-failover", { - previousUrl: prevUrl.toString(), - nextUrl: nextUrl.toString() - }); - }); + return await this.idsHost.getGot( + (incitingError, prevUrl, nextUrl) => { + this.recordPlausibleTimeout(incitingError); + this.recordEvent("ids-failover", { + previousUrl: prevUrl.toString(), + nextUrl: nextUrl.toString() + }); + } + ); } async checkIn() { const checkin = await this.requestCheckIn(); @@ -97604,12 +97605,22 @@ var DetSysAction = class { } }).json(); } catch (e) { + this.recordPlausibleTimeout(e); core.debug(`Error checking in: ${stringifyError2(e)}`); this.idsHost.markCurrentHostBroken(); } } return void 0; } + recordPlausibleTimeout(e) { + if (e instanceof TimeoutError && Object.hasOwn(e, "timings") && Object.hasOwn(e, "request")) { + this.recordEvent("timeout", { + timings: e.timings, + url: e.request.requestUrl, + retry_count: e.request.retryCount + }); + } + } /** * Fetch an artifact, such as a tarball, from the location determined by the * `source-*` inputs. If `source-binary` is specified, this will return a path @@ -97653,14 +97664,7 @@ var DetSysAction = class { `No match from the cache, re-fetching from the redirect: ${versionCheckup.url}` ); const destFile = this.getTemporaryName(); - const fetchStream = (await this.getClient()).stream(versionCheckup.url); - await (0,external_node_stream_promises_namespaceObject.pipeline)( - fetchStream, - (0,external_node_fs_namespaceObject.createWriteStream)(destFile, { - encoding: "binary", - mode: 493 - }) - ); + const fetchStream = await this.downloadFile(destFile, versionCheckup.url); if (fetchStream.response?.headers.etag) { const v = fetchStream.response.headers.etag; try { @@ -97670,6 +97674,9 @@ var DetSysAction = class { } } return destFile; + } catch (e) { + this.recordPlausibleTimeout(e); + throw e; } finally { core.endGroup(); } @@ -97683,6 +97690,36 @@ var DetSysAction = class { core.setFailed(`strict mode failure: ${msg}`); } } + async downloadFile(url, destination) { + const client = await this.getClient(); + return new Promise((resolve, reject) => { + let writeStream; + let failed = false; + const retry = (stream) => { + if (writeStream) { + writeStream.destroy(); + } + writeStream = (0,external_node_fs_namespaceObject.createWriteStream)(destination, { + encoding: "binary", + mode: 493 + }); + writeStream.once("error", (error3) => { + failed = true; + reject(error3); + }); + writeStream.on("finish", () => { + if (!failed) { + resolve(stream); + } + }); + stream.once("retry", (_count, _error, createRetryStream) => { + retry(createRetryStream()); + }); + stream.pipe(writeStream); + }; + retry(client.stream(url)); + }); + } async complete() { this.recordEvent(`complete_${this.executionPhase}`); await this.submitEvents(); @@ -97906,6 +97943,7 @@ var DetSysAction = class { } }); } catch (err) { + this.recordPlausibleTimeout(err); core.debug( `Error submitting diagnostics event to ${diagnosticsUrl}: ${stringifyError2(err)}` ); @@ -97947,5167 +97985,6 @@ function makeOptionsConfident(actionOptions) { * Copyright (c) 2018-2020 [Samuel Carreira] */ //# sourceMappingURL=index.js.map -;// CONCATENATED MODULE: ./node_modules/.pnpm/@sindresorhus+is@6.3.1/node_modules/@sindresorhus/is/dist/index.js -const dist_typedArrayTypeNames = [ - 'Int8Array', - 'Uint8Array', - 'Uint8ClampedArray', - 'Int16Array', - 'Uint16Array', - 'Int32Array', - 'Uint32Array', - 'Float32Array', - 'Float64Array', - 'BigInt64Array', - 'BigUint64Array', -]; -function dist_isTypedArrayName(name) { - return dist_typedArrayTypeNames.includes(name); -} -const dist_objectTypeNames = [ - 'Function', - 'Generator', - 'AsyncGenerator', - 'GeneratorFunction', - 'AsyncGeneratorFunction', - 'AsyncFunction', - 'Observable', - 'Array', - 'Buffer', - 'Blob', - 'Object', - 'RegExp', - 'Date', - 'Error', - 'Map', - 'Set', - 'WeakMap', - 'WeakSet', - 'WeakRef', - 'ArrayBuffer', - 'SharedArrayBuffer', - 'DataView', - 'Promise', - 'URL', - 'FormData', - 'URLSearchParams', - 'HTMLElement', - 'NaN', - ...dist_typedArrayTypeNames, -]; -function dist_isObjectTypeName(name) { - return dist_objectTypeNames.includes(name); -} -const dist_primitiveTypeNames = [ - 'null', - 'undefined', - 'string', - 'number', - 'bigint', - 'boolean', - 'symbol', -]; -function dist_isPrimitiveTypeName(name) { - return dist_primitiveTypeNames.includes(name); -} -const dist_assertionTypeDescriptions = [ - 'positive number', - 'negative number', - 'Class', - 'string with a number', - 'null or undefined', - 'Iterable', - 'AsyncIterable', - 'native Promise', - 'EnumCase', - 'string with a URL', - 'truthy', - 'falsy', - 'primitive', - 'integer', - 'plain object', - 'TypedArray', - 'array-like', - 'tuple-like', - 'Node.js Stream', - 'infinite number', - 'empty array', - 'non-empty array', - 'empty string', - 'empty string or whitespace', - 'non-empty string', - 'non-empty string and not whitespace', - 'empty object', - 'non-empty object', - 'empty set', - 'non-empty set', - 'empty map', - 'non-empty map', - 'PropertyKey', - 'even integer', - 'odd integer', - 'T', - 'in range', - 'predicate returns truthy for any value', - 'predicate returns truthy for all values', - 'valid Date', - 'valid length', - 'whitespace string', - ...dist_objectTypeNames, - ...dist_primitiveTypeNames, -]; -const dist_getObjectType = (value) => { - const objectTypeName = Object.prototype.toString.call(value).slice(8, -1); - if (/HTML\w+Element/.test(objectTypeName) && dist_isHtmlElement(value)) { - return 'HTMLElement'; - } - if (dist_isObjectTypeName(objectTypeName)) { - return objectTypeName; - } - return undefined; -}; -function dist_detect(value) { - if (value === null) { - return 'null'; - } - switch (typeof value) { - case 'undefined': { - return 'undefined'; - } - case 'string': { - return 'string'; - } - case 'number': { - return Number.isNaN(value) ? 'NaN' : 'number'; - } - case 'boolean': { - return 'boolean'; - } - case 'function': { - return 'Function'; - } - case 'bigint': { - return 'bigint'; - } - case 'symbol': { - return 'symbol'; - } - default: - } - if (dist_isObservable(value)) { - return 'Observable'; - } - if (dist_isArray(value)) { - return 'Array'; - } - if (dist_isBuffer(value)) { - return 'Buffer'; - } - const tagType = dist_getObjectType(value); - if (tagType) { - return tagType; - } - if (value instanceof String || value instanceof Boolean || value instanceof Number) { - throw new TypeError('Please don\'t use object wrappers for primitive types'); - } - return 'Object'; -} -function dist_hasPromiseApi(value) { - return dist_isFunction(value?.then) && dist_isFunction(value?.catch); -} -const dist_is = Object.assign(dist_detect, { - all: dist_isAll, - any: dist_isAny, - array: dist_isArray, - arrayBuffer: dist_isArrayBuffer, - arrayLike: dist_isArrayLike, - asyncFunction: dist_isAsyncFunction, - asyncGenerator: dist_isAsyncGenerator, - asyncGeneratorFunction: dist_isAsyncGeneratorFunction, - asyncIterable: dist_isAsyncIterable, - bigint: dist_isBigint, - bigInt64Array: dist_isBigInt64Array, - bigUint64Array: dist_isBigUint64Array, - blob: dist_isBlob, - boolean: dist_isBoolean, - boundFunction: dist_isBoundFunction, - buffer: dist_isBuffer, - class: dist_isClass, - /** @deprecated Renamed to `class`. */ - class_: dist_isClass, - dataView: dist_isDataView, - date: dist_isDate, - detect: dist_detect, - directInstanceOf: dist_isDirectInstanceOf, - /** @deprecated Renamed to `htmlElement` */ - domElement: dist_isHtmlElement, - emptyArray: dist_isEmptyArray, - emptyMap: dist_isEmptyMap, - emptyObject: dist_isEmptyObject, - emptySet: dist_isEmptySet, - emptyString: dist_isEmptyString, - emptyStringOrWhitespace: dist_isEmptyStringOrWhitespace, - enumCase: dist_isEnumCase, - error: dist_isError, - evenInteger: dist_isEvenInteger, - falsy: dist_isFalsy, - float32Array: dist_isFloat32Array, - float64Array: dist_isFloat64Array, - formData: dist_isFormData, - function: dist_isFunction, - /** @deprecated Renamed to `function`. */ - function_: dist_isFunction, - generator: dist_isGenerator, - generatorFunction: dist_isGeneratorFunction, - htmlElement: dist_isHtmlElement, - infinite: dist_isInfinite, - inRange: dist_isInRange, - int16Array: dist_isInt16Array, - int32Array: dist_isInt32Array, - int8Array: dist_isInt8Array, - integer: dist_isInteger, - iterable: dist_isIterable, - map: dist_isMap, - nan: dist_isNan, - nativePromise: dist_isNativePromise, - negativeNumber: dist_isNegativeNumber, - nodeStream: dist_isNodeStream, - nonEmptyArray: dist_isNonEmptyArray, - nonEmptyMap: dist_isNonEmptyMap, - nonEmptyObject: dist_isNonEmptyObject, - nonEmptySet: dist_isNonEmptySet, - nonEmptyString: dist_isNonEmptyString, - nonEmptyStringAndNotWhitespace: dist_isNonEmptyStringAndNotWhitespace, - null: dist_isNull, - /** @deprecated Renamed to `null`. */ - null_: dist_isNull, - nullOrUndefined: dist_isNullOrUndefined, - number: dist_isNumber, - numericString: dist_isNumericString, - object: dist_isObject, - observable: dist_isObservable, - oddInteger: dist_isOddInteger, - plainObject: dist_isPlainObject, - positiveNumber: dist_isPositiveNumber, - primitive: dist_isPrimitive, - promise: dist_isPromise, - propertyKey: dist_isPropertyKey, - regExp: dist_isRegExp, - safeInteger: dist_isSafeInteger, - set: dist_isSet, - sharedArrayBuffer: dist_isSharedArrayBuffer, - string: dist_isString, - symbol: dist_isSymbol, - truthy: dist_isTruthy, - tupleLike: dist_isTupleLike, - typedArray: dist_isTypedArray, - uint16Array: dist_isUint16Array, - uint32Array: dist_isUint32Array, - uint8Array: dist_isUint8Array, - uint8ClampedArray: dist_isUint8ClampedArray, - undefined: dist_isUndefined, - urlInstance: dist_isUrlInstance, - urlSearchParams: dist_isUrlSearchParams, - urlString: dist_isUrlString, - validDate: dist_isValidDate, - validLength: dist_isValidLength, - weakMap: dist_isWeakMap, - weakRef: dist_isWeakRef, - weakSet: dist_isWeakSet, - whitespaceString: dist_isWhitespaceString, -}); -function isAbsoluteMod2(remainder) { - return (value) => dist_isInteger(value) && Math.abs(value % 2) === remainder; -} -function dist_isAll(predicate, ...values) { - return dist_predicateOnArray(Array.prototype.every, predicate, values); -} -function dist_isAny(predicate, ...values) { - const predicates = dist_isArray(predicate) ? predicate : [predicate]; - return predicates.some(singlePredicate => dist_predicateOnArray(Array.prototype.some, singlePredicate, values)); -} -function dist_isArray(value, assertion) { - if (!Array.isArray(value)) { - return false; - } - if (!dist_isFunction(assertion)) { - return true; - } - // eslint-disable-next-line @typescript-eslint/no-unsafe-argument - return value.every(element => assertion(element)); -} -function dist_isArrayBuffer(value) { - return dist_getObjectType(value) === 'ArrayBuffer'; -} -function dist_isArrayLike(value) { - return !dist_isNullOrUndefined(value) && !dist_isFunction(value) && dist_isValidLength(value.length); -} -function dist_isAsyncFunction(value) { - return dist_getObjectType(value) === 'AsyncFunction'; -} -function dist_isAsyncGenerator(value) { - return dist_isAsyncIterable(value) && dist_isFunction(value.next) && dist_isFunction(value.throw); -} -function dist_isAsyncGeneratorFunction(value) { - return dist_getObjectType(value) === 'AsyncGeneratorFunction'; -} -function dist_isAsyncIterable(value) { - return dist_isFunction(value?.[Symbol.asyncIterator]); -} -function dist_isBigint(value) { - return typeof value === 'bigint'; -} -function dist_isBigInt64Array(value) { - return dist_getObjectType(value) === 'BigInt64Array'; -} -function dist_isBigUint64Array(value) { - return dist_getObjectType(value) === 'BigUint64Array'; -} -function dist_isBlob(value) { - return dist_getObjectType(value) === 'Blob'; -} -function dist_isBoolean(value) { - return value === true || value === false; -} -// eslint-disable-next-line @typescript-eslint/ban-types -function dist_isBoundFunction(value) { - return dist_isFunction(value) && !Object.prototype.hasOwnProperty.call(value, 'prototype'); -} -function dist_isBuffer(value) { - // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call - return value?.constructor?.isBuffer?.(value) ?? false; -} -function dist_isClass(value) { - return dist_isFunction(value) && value.toString().startsWith('class '); -} -function dist_isDataView(value) { - return dist_getObjectType(value) === 'DataView'; -} -function dist_isDate(value) { - return dist_getObjectType(value) === 'Date'; -} -function dist_isDirectInstanceOf(instance, class_) { - if (instance === undefined || instance === null) { - return false; - } - return Object.getPrototypeOf(instance) === class_.prototype; -} -function dist_isEmptyArray(value) { - return dist_isArray(value) && value.length === 0; -} -function dist_isEmptyMap(value) { - return dist_isMap(value) && value.size === 0; -} -function dist_isEmptyObject(value) { - return dist_isObject(value) && !dist_isMap(value) && !dist_isSet(value) && Object.keys(value).length === 0; -} -function dist_isEmptySet(value) { - return dist_isSet(value) && value.size === 0; -} -function dist_isEmptyString(value) { - return dist_isString(value) && value.length === 0; -} -function dist_isEmptyStringOrWhitespace(value) { - return dist_isEmptyString(value) || dist_isWhitespaceString(value); -} -function dist_isEnumCase(value, targetEnum) { - // eslint-disable-next-line @typescript-eslint/no-unsafe-argument - return Object.values(targetEnum).includes(value); -} -function dist_isError(value) { - return dist_getObjectType(value) === 'Error'; -} -function dist_isEvenInteger(value) { - return isAbsoluteMod2(0)(value); -} -// Example: `is.falsy = (value: unknown): value is (not true | 0 | '' | undefined | null) => Boolean(value);` -function dist_isFalsy(value) { - return !value; -} -function dist_isFloat32Array(value) { - return dist_getObjectType(value) === 'Float32Array'; -} -function dist_isFloat64Array(value) { - return dist_getObjectType(value) === 'Float64Array'; -} -function dist_isFormData(value) { - return dist_getObjectType(value) === 'FormData'; -} -// eslint-disable-next-line @typescript-eslint/ban-types -function dist_isFunction(value) { - return typeof value === 'function'; -} -function dist_isGenerator(value) { - return dist_isIterable(value) && dist_isFunction(value?.next) && dist_isFunction(value?.throw); -} -function dist_isGeneratorFunction(value) { - return dist_getObjectType(value) === 'GeneratorFunction'; -} -// eslint-disable-next-line @typescript-eslint/naming-convention -const dist_NODE_TYPE_ELEMENT = 1; -// eslint-disable-next-line @typescript-eslint/naming-convention -const dist_DOM_PROPERTIES_TO_CHECK = [ - 'innerHTML', - 'ownerDocument', - 'style', - 'attributes', - 'nodeValue', -]; -function dist_isHtmlElement(value) { - return dist_isObject(value) - && value.nodeType === dist_NODE_TYPE_ELEMENT - && dist_isString(value.nodeName) - && !dist_isPlainObject(value) - && dist_DOM_PROPERTIES_TO_CHECK.every(property => property in value); -} -function dist_isInfinite(value) { - return value === Number.POSITIVE_INFINITY || value === Number.NEGATIVE_INFINITY; -} -function dist_isInRange(value, range) { - if (dist_isNumber(range)) { - return value >= Math.min(0, range) && value <= Math.max(range, 0); - } - if (dist_isArray(range) && range.length === 2) { - return value >= Math.min(...range) && value <= Math.max(...range); - } - throw new TypeError(`Invalid range: ${JSON.stringify(range)}`); -} -function dist_isInt16Array(value) { - return dist_getObjectType(value) === 'Int16Array'; -} -function dist_isInt32Array(value) { - return dist_getObjectType(value) === 'Int32Array'; -} -function dist_isInt8Array(value) { - return dist_getObjectType(value) === 'Int8Array'; -} -function dist_isInteger(value) { - return Number.isInteger(value); -} -function dist_isIterable(value) { - return dist_isFunction(value?.[Symbol.iterator]); -} -function dist_isMap(value) { - return dist_getObjectType(value) === 'Map'; -} -function dist_isNan(value) { - return Number.isNaN(value); -} -function dist_isNativePromise(value) { - return dist_getObjectType(value) === 'Promise'; -} -function dist_isNegativeNumber(value) { - return dist_isNumber(value) && value < 0; -} -function dist_isNodeStream(value) { - return dist_isObject(value) && dist_isFunction(value.pipe) && !dist_isObservable(value); -} -function dist_isNonEmptyArray(value) { - return dist_isArray(value) && value.length > 0; -} -function dist_isNonEmptyMap(value) { - return dist_isMap(value) && value.size > 0; -} -// TODO: Use `not` operator here to remove `Map` and `Set` from type guard: -// - https://github.com/Microsoft/TypeScript/pull/29317 -function dist_isNonEmptyObject(value) { - return dist_isObject(value) && !dist_isMap(value) && !dist_isSet(value) && Object.keys(value).length > 0; -} -function dist_isNonEmptySet(value) { - return dist_isSet(value) && value.size > 0; -} -// TODO: Use `not ''` when the `not` operator is available. -function dist_isNonEmptyString(value) { - return dist_isString(value) && value.length > 0; -} -// TODO: Use `not ''` when the `not` operator is available. -function dist_isNonEmptyStringAndNotWhitespace(value) { - return dist_isString(value) && !dist_isEmptyStringOrWhitespace(value); -} -// eslint-disable-next-line @typescript-eslint/ban-types -function dist_isNull(value) { - return value === null; -} -// eslint-disable-next-line @typescript-eslint/ban-types -function dist_isNullOrUndefined(value) { - return dist_isNull(value) || dist_isUndefined(value); -} -function dist_isNumber(value) { - return typeof value === 'number' && !Number.isNaN(value); -} -function dist_isNumericString(value) { - return dist_isString(value) && !dist_isEmptyStringOrWhitespace(value) && !Number.isNaN(Number(value)); -} -// eslint-disable-next-line @typescript-eslint/ban-types -function dist_isObject(value) { - return !dist_isNull(value) && (typeof value === 'object' || dist_isFunction(value)); -} -function dist_isObservable(value) { - if (!value) { - return false; - } - // eslint-disable-next-line no-use-extend-native/no-use-extend-native, @typescript-eslint/no-unsafe-call - if (value === value[Symbol.observable]?.()) { - return true; - } - // eslint-disable-next-line @typescript-eslint/no-unsafe-call - if (value === value['@@observable']?.()) { - return true; - } - return false; -} -function dist_isOddInteger(value) { - return isAbsoluteMod2(1)(value); -} -function dist_isPlainObject(value) { - // From: https://github.com/sindresorhus/is-plain-obj/blob/main/index.js - if (typeof value !== 'object' || value === null) { - return false; - } - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment - const prototype = Object.getPrototypeOf(value); - return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in value) && !(Symbol.iterator in value); -} -function dist_isPositiveNumber(value) { - return dist_isNumber(value) && value > 0; -} -function dist_isPrimitive(value) { - return dist_isNull(value) || dist_isPrimitiveTypeName(typeof value); -} -function dist_isPromise(value) { - return dist_isNativePromise(value) || dist_hasPromiseApi(value); -} -// `PropertyKey` is any value that can be used as an object key (string, number, or symbol) -function dist_isPropertyKey(value) { - return dist_isAny([dist_isString, dist_isNumber, dist_isSymbol], value); -} -function dist_isRegExp(value) { - return dist_getObjectType(value) === 'RegExp'; -} -function dist_isSafeInteger(value) { - return Number.isSafeInteger(value); -} -function dist_isSet(value) { - return dist_getObjectType(value) === 'Set'; -} -function dist_isSharedArrayBuffer(value) { - return dist_getObjectType(value) === 'SharedArrayBuffer'; -} -function dist_isString(value) { - return typeof value === 'string'; -} -function dist_isSymbol(value) { - return typeof value === 'symbol'; -} -// Example: `is.truthy = (value: unknown): value is (not false | not 0 | not '' | not undefined | not null) => Boolean(value);` -// eslint-disable-next-line unicorn/prefer-native-coercion-functions -function dist_isTruthy(value) { - return Boolean(value); -} -function dist_isTupleLike(value, guards) { - if (dist_isArray(guards) && dist_isArray(value) && guards.length === value.length) { - return guards.every((guard, index) => guard(value[index])); - } - return false; -} -function dist_isTypedArray(value) { - return dist_isTypedArrayName(dist_getObjectType(value)); -} -function dist_isUint16Array(value) { - return dist_getObjectType(value) === 'Uint16Array'; -} -function dist_isUint32Array(value) { - return dist_getObjectType(value) === 'Uint32Array'; -} -function dist_isUint8Array(value) { - return dist_getObjectType(value) === 'Uint8Array'; -} -function dist_isUint8ClampedArray(value) { - return dist_getObjectType(value) === 'Uint8ClampedArray'; -} -function dist_isUndefined(value) { - return value === undefined; -} -function dist_isUrlInstance(value) { - return dist_getObjectType(value) === 'URL'; -} -// eslint-disable-next-line unicorn/prevent-abbreviations -function dist_isUrlSearchParams(value) { - return dist_getObjectType(value) === 'URLSearchParams'; -} -function dist_isUrlString(value) { - if (!dist_isString(value)) { - return false; - } - try { - new URL(value); // eslint-disable-line no-new - return true; - } - catch { - return false; - } -} -function dist_isValidDate(value) { - return dist_isDate(value) && !dist_isNan(Number(value)); -} -function dist_isValidLength(value) { - return dist_isSafeInteger(value) && value >= 0; -} -// eslint-disable-next-line @typescript-eslint/ban-types -function dist_isWeakMap(value) { - return dist_getObjectType(value) === 'WeakMap'; -} -// eslint-disable-next-line @typescript-eslint/ban-types -function dist_isWeakRef(value) { - return dist_getObjectType(value) === 'WeakRef'; -} -// eslint-disable-next-line @typescript-eslint/ban-types -function dist_isWeakSet(value) { - return dist_getObjectType(value) === 'WeakSet'; -} -function dist_isWhitespaceString(value) { - return dist_isString(value) && /^\s+$/.test(value); -} -function dist_predicateOnArray(method, predicate, values) { - if (!dist_isFunction(predicate)) { - throw new TypeError(`Invalid predicate: ${JSON.stringify(predicate)}`); - } - if (values.length === 0) { - throw new TypeError('Invalid number of values'); - } - return method.call(values, predicate); -} -function dist_typeErrorMessage(description, value) { - return `Expected value which is \`${description}\`, received value of type \`${dist_is(value)}\`.`; -} -function dist_unique(values) { - // eslint-disable-next-line unicorn/prefer-spread - return Array.from(new Set(values)); -} -const dist_andFormatter = new Intl.ListFormat('en', { style: 'long', type: 'conjunction' }); -const dist_orFormatter = new Intl.ListFormat('en', { style: 'long', type: 'disjunction' }); -function dist_typeErrorMessageMultipleValues(expectedType, values) { - const uniqueExpectedTypes = dist_unique((dist_isArray(expectedType) ? expectedType : [expectedType]).map(value => `\`${value}\``)); - const uniqueValueTypes = dist_unique(values.map(value => `\`${dist_is(value)}\``)); - return `Expected values which are ${dist_orFormatter.format(uniqueExpectedTypes)}. Received values of type${uniqueValueTypes.length > 1 ? 's' : ''} ${dist_andFormatter.format(uniqueValueTypes)}.`; -} -const dist_assert = { - all: dist_assertAll, - any: dist_assertAny, - array: dist_assertArray, - arrayBuffer: dist_assertArrayBuffer, - arrayLike: dist_assertArrayLike, - asyncFunction: dist_assertAsyncFunction, - asyncGenerator: dist_assertAsyncGenerator, - asyncGeneratorFunction: dist_assertAsyncGeneratorFunction, - asyncIterable: dist_assertAsyncIterable, - bigint: dist_assertBigint, - bigInt64Array: dist_assertBigInt64Array, - bigUint64Array: dist_assertBigUint64Array, - blob: dist_assertBlob, - boolean: dist_assertBoolean, - boundFunction: dist_assertBoundFunction, - buffer: dist_assertBuffer, - class: dist_assertClass, - class_: dist_assertClass, - dataView: dist_assertDataView, - date: dist_assertDate, - directInstanceOf: dist_assertDirectInstanceOf, - domElement: dist_assertHtmlElement, - emptyArray: dist_assertEmptyArray, - emptyMap: dist_assertEmptyMap, - emptyObject: dist_assertEmptyObject, - emptySet: dist_assertEmptySet, - emptyString: dist_assertEmptyString, - emptyStringOrWhitespace: dist_assertEmptyStringOrWhitespace, - enumCase: dist_assertEnumCase, - error: dist_assertError, - evenInteger: dist_assertEvenInteger, - falsy: dist_assertFalsy, - float32Array: dist_assertFloat32Array, - float64Array: dist_assertFloat64Array, - formData: dist_assertFormData, - function: dist_assertFunction, - function_: dist_assertFunction, - generator: dist_assertGenerator, - generatorFunction: dist_assertGeneratorFunction, - htmlElement: dist_assertHtmlElement, - infinite: dist_assertInfinite, - inRange: dist_assertInRange, - int16Array: dist_assertInt16Array, - int32Array: dist_assertInt32Array, - int8Array: dist_assertInt8Array, - integer: dist_assertInteger, - iterable: dist_assertIterable, - map: dist_assertMap, - nan: dist_assertNan, - nativePromise: dist_assertNativePromise, - negativeNumber: dist_assertNegativeNumber, - nodeStream: dist_assertNodeStream, - nonEmptyArray: dist_assertNonEmptyArray, - nonEmptyMap: dist_assertNonEmptyMap, - nonEmptyObject: dist_assertNonEmptyObject, - nonEmptySet: dist_assertNonEmptySet, - nonEmptyString: dist_assertNonEmptyString, - nonEmptyStringAndNotWhitespace: dist_assertNonEmptyStringAndNotWhitespace, - null: dist_assertNull, - null_: dist_assertNull, - nullOrUndefined: dist_assertNullOrUndefined, - number: dist_assertNumber, - numericString: dist_assertNumericString, - object: dist_assertObject, - observable: dist_assertObservable, - oddInteger: dist_assertOddInteger, - plainObject: dist_assertPlainObject, - positiveNumber: dist_assertPositiveNumber, - primitive: dist_assertPrimitive, - promise: dist_assertPromise, - propertyKey: dist_assertPropertyKey, - regExp: dist_assertRegExp, - safeInteger: dist_assertSafeInteger, - set: dist_assertSet, - sharedArrayBuffer: dist_assertSharedArrayBuffer, - string: dist_assertString, - symbol: dist_assertSymbol, - truthy: dist_assertTruthy, - tupleLike: dist_assertTupleLike, - typedArray: dist_assertTypedArray, - uint16Array: dist_assertUint16Array, - uint32Array: dist_assertUint32Array, - uint8Array: dist_assertUint8Array, - uint8ClampedArray: dist_assertUint8ClampedArray, - undefined: dist_assertUndefined, - urlInstance: dist_assertUrlInstance, - urlSearchParams: dist_assertUrlSearchParams, - urlString: dist_assertUrlString, - validDate: dist_assertValidDate, - validLength: dist_assertValidLength, - weakMap: dist_assertWeakMap, - weakRef: dist_assertWeakRef, - weakSet: dist_assertWeakSet, - whitespaceString: dist_assertWhitespaceString, -}; -const dist_methodTypeMap = { - isArray: 'Array', - isArrayBuffer: 'ArrayBuffer', - isArrayLike: 'array-like', - isAsyncFunction: 'AsyncFunction', - isAsyncGenerator: 'AsyncGenerator', - isAsyncGeneratorFunction: 'AsyncGeneratorFunction', - isAsyncIterable: 'AsyncIterable', - isBigint: 'bigint', - isBigInt64Array: 'BigInt64Array', - isBigUint64Array: 'BigUint64Array', - isBlob: 'Blob', - isBoolean: 'boolean', - isBoundFunction: 'Function', - isBuffer: 'Buffer', - isClass: 'Class', - isDataView: 'DataView', - isDate: 'Date', - isDirectInstanceOf: 'T', - /** @deprecated */ - isDomElement: 'HTMLElement', - isEmptyArray: 'empty array', - isEmptyMap: 'empty map', - isEmptyObject: 'empty object', - isEmptySet: 'empty set', - isEmptyString: 'empty string', - isEmptyStringOrWhitespace: 'empty string or whitespace', - isEnumCase: 'EnumCase', - isError: 'Error', - isEvenInteger: 'even integer', - isFalsy: 'falsy', - isFloat32Array: 'Float32Array', - isFloat64Array: 'Float64Array', - isFormData: 'FormData', - isFunction: 'Function', - isGenerator: 'Generator', - isGeneratorFunction: 'GeneratorFunction', - isHtmlElement: 'HTMLElement', - isInfinite: 'infinite number', - isInRange: 'in range', - isInt16Array: 'Int16Array', - isInt32Array: 'Int32Array', - isInt8Array: 'Int8Array', - isInteger: 'integer', - isIterable: 'Iterable', - isMap: 'Map', - isNan: 'NaN', - isNativePromise: 'native Promise', - isNegativeNumber: 'negative number', - isNodeStream: 'Node.js Stream', - isNonEmptyArray: 'non-empty array', - isNonEmptyMap: 'non-empty map', - isNonEmptyObject: 'non-empty object', - isNonEmptySet: 'non-empty set', - isNonEmptyString: 'non-empty string', - isNonEmptyStringAndNotWhitespace: 'non-empty string and not whitespace', - isNull: 'null', - isNullOrUndefined: 'null or undefined', - isNumber: 'number', - isNumericString: 'string with a number', - isObject: 'Object', - isObservable: 'Observable', - isOddInteger: 'odd integer', - isPlainObject: 'plain object', - isPositiveNumber: 'positive number', - isPrimitive: 'primitive', - isPromise: 'Promise', - isPropertyKey: 'PropertyKey', - isRegExp: 'RegExp', - isSafeInteger: 'integer', - isSet: 'Set', - isSharedArrayBuffer: 'SharedArrayBuffer', - isString: 'string', - isSymbol: 'symbol', - isTruthy: 'truthy', - isTupleLike: 'tuple-like', - isTypedArray: 'TypedArray', - isUint16Array: 'Uint16Array', - isUint32Array: 'Uint32Array', - isUint8Array: 'Uint8Array', - isUint8ClampedArray: 'Uint8ClampedArray', - isUndefined: 'undefined', - isUrlInstance: 'URL', - isUrlSearchParams: 'URLSearchParams', - isUrlString: 'string with a URL', - isValidDate: 'valid Date', - isValidLength: 'valid length', - isWeakMap: 'WeakMap', - isWeakRef: 'WeakRef', - isWeakSet: 'WeakSet', - isWhitespaceString: 'whitespace string', -}; -function dist_keysOf(value) { - return Object.keys(value); -} -const dist_isMethodNames = dist_keysOf(dist_methodTypeMap); -function dist_isIsMethodName(value) { - return dist_isMethodNames.includes(value); -} -function dist_assertAll(predicate, ...values) { - if (!dist_isAll(predicate, ...values)) { - const expectedType = dist_isIsMethodName(predicate.name) ? dist_methodTypeMap[predicate.name] : 'predicate returns truthy for all values'; - throw new TypeError(dist_typeErrorMessageMultipleValues(expectedType, values)); - } -} -function dist_assertAny(predicate, ...values) { - if (!dist_isAny(predicate, ...values)) { - const predicates = dist_isArray(predicate) ? predicate : [predicate]; - const expectedTypes = predicates.map(predicate => dist_isIsMethodName(predicate.name) ? dist_methodTypeMap[predicate.name] : 'predicate returns truthy for any value'); - throw new TypeError(dist_typeErrorMessageMultipleValues(expectedTypes, values)); - } -} -function dist_assertArray(value, assertion, message) { - if (!dist_isArray(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('Array', value)); - } - if (assertion) { - // eslint-disable-next-line unicorn/no-array-for-each, unicorn/no-array-callback-reference - value.forEach(assertion); - } -} -function dist_assertArrayBuffer(value, message) { - if (!dist_isArrayBuffer(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('ArrayBuffer', value)); - } -} -function dist_assertArrayLike(value, message) { - if (!dist_isArrayLike(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('array-like', value)); - } -} -// eslint-disable-next-line @typescript-eslint/ban-types -function dist_assertAsyncFunction(value, message) { - if (!dist_isAsyncFunction(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('AsyncFunction', value)); - } -} -function dist_assertAsyncGenerator(value, message) { - if (!dist_isAsyncGenerator(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('AsyncGenerator', value)); - } -} -function dist_assertAsyncGeneratorFunction(value, message) { - if (!dist_isAsyncGeneratorFunction(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('AsyncGeneratorFunction', value)); - } -} -function dist_assertAsyncIterable(value, message) { - if (!dist_isAsyncIterable(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('AsyncIterable', value)); - } -} -function dist_assertBigint(value, message) { - if (!dist_isBigint(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('bigint', value)); - } -} -function dist_assertBigInt64Array(value, message) { - if (!dist_isBigInt64Array(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('BigInt64Array', value)); - } -} -function dist_assertBigUint64Array(value, message) { - if (!dist_isBigUint64Array(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('BigUint64Array', value)); - } -} -function dist_assertBlob(value, message) { - if (!dist_isBlob(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('Blob', value)); - } -} -function dist_assertBoolean(value, message) { - if (!dist_isBoolean(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('boolean', value)); - } -} -// eslint-disable-next-line @typescript-eslint/ban-types -function dist_assertBoundFunction(value, message) { - if (!dist_isBoundFunction(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('Function', value)); - } -} -function dist_assertBuffer(value, message) { - if (!dist_isBuffer(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('Buffer', value)); - } -} -function dist_assertClass(value, message) { - if (!dist_isClass(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('Class', value)); - } -} -function dist_assertDataView(value, message) { - if (!dist_isDataView(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('DataView', value)); - } -} -function dist_assertDate(value, message) { - if (!dist_isDate(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('Date', value)); - } -} -function dist_assertDirectInstanceOf(instance, class_, message) { - if (!dist_isDirectInstanceOf(instance, class_)) { - throw new TypeError(message ?? dist_typeErrorMessage('T', instance)); - } -} -function dist_assertEmptyArray(value, message) { - if (!dist_isEmptyArray(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('empty array', value)); - } -} -function dist_assertEmptyMap(value, message) { - if (!dist_isEmptyMap(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('empty map', value)); - } -} -function dist_assertEmptyObject(value, message) { - if (!dist_isEmptyObject(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('empty object', value)); - } -} -function dist_assertEmptySet(value, message) { - if (!dist_isEmptySet(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('empty set', value)); - } -} -function dist_assertEmptyString(value, message) { - if (!dist_isEmptyString(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('empty string', value)); - } -} -function dist_assertEmptyStringOrWhitespace(value, message) { - if (!dist_isEmptyStringOrWhitespace(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('empty string or whitespace', value)); - } -} -function dist_assertEnumCase(value, targetEnum, message) { - if (!dist_isEnumCase(value, targetEnum)) { - throw new TypeError(message ?? dist_typeErrorMessage('EnumCase', value)); - } -} -function dist_assertError(value, message) { - if (!dist_isError(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('Error', value)); - } -} -function dist_assertEvenInteger(value, message) { - if (!dist_isEvenInteger(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('even integer', value)); - } -} -function dist_assertFalsy(value, message) { - if (!dist_isFalsy(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('falsy', value)); - } -} -function dist_assertFloat32Array(value, message) { - if (!dist_isFloat32Array(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('Float32Array', value)); - } -} -function dist_assertFloat64Array(value, message) { - if (!dist_isFloat64Array(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('Float64Array', value)); - } -} -function dist_assertFormData(value, message) { - if (!dist_isFormData(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('FormData', value)); - } -} -// eslint-disable-next-line @typescript-eslint/ban-types -function dist_assertFunction(value, message) { - if (!dist_isFunction(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('Function', value)); - } -} -function dist_assertGenerator(value, message) { - if (!dist_isGenerator(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('Generator', value)); - } -} -function dist_assertGeneratorFunction(value, message) { - if (!dist_isGeneratorFunction(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('GeneratorFunction', value)); - } -} -function dist_assertHtmlElement(value, message) { - if (!dist_isHtmlElement(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('HTMLElement', value)); - } -} -function dist_assertInfinite(value, message) { - if (!dist_isInfinite(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('infinite number', value)); - } -} -function dist_assertInRange(value, range, message) { - if (!dist_isInRange(value, range)) { - throw new TypeError(message ?? dist_typeErrorMessage('in range', value)); - } -} -function dist_assertInt16Array(value, message) { - if (!dist_isInt16Array(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('Int16Array', value)); - } -} -function dist_assertInt32Array(value, message) { - if (!dist_isInt32Array(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('Int32Array', value)); - } -} -function dist_assertInt8Array(value, message) { - if (!dist_isInt8Array(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('Int8Array', value)); - } -} -function dist_assertInteger(value, message) { - if (!dist_isInteger(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('integer', value)); - } -} -function dist_assertIterable(value, message) { - if (!dist_isIterable(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('Iterable', value)); - } -} -function dist_assertMap(value, message) { - if (!dist_isMap(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('Map', value)); - } -} -function dist_assertNan(value, message) { - if (!dist_isNan(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('NaN', value)); - } -} -function dist_assertNativePromise(value, message) { - if (!dist_isNativePromise(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('native Promise', value)); - } -} -function dist_assertNegativeNumber(value, message) { - if (!dist_isNegativeNumber(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('negative number', value)); - } -} -function dist_assertNodeStream(value, message) { - if (!dist_isNodeStream(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('Node.js Stream', value)); - } -} -function dist_assertNonEmptyArray(value, message) { - if (!dist_isNonEmptyArray(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('non-empty array', value)); - } -} -function dist_assertNonEmptyMap(value, message) { - if (!dist_isNonEmptyMap(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('non-empty map', value)); - } -} -function dist_assertNonEmptyObject(value, message) { - if (!dist_isNonEmptyObject(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('non-empty object', value)); - } -} -function dist_assertNonEmptySet(value, message) { - if (!dist_isNonEmptySet(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('non-empty set', value)); - } -} -function dist_assertNonEmptyString(value, message) { - if (!dist_isNonEmptyString(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('non-empty string', value)); - } -} -function dist_assertNonEmptyStringAndNotWhitespace(value, message) { - if (!dist_isNonEmptyStringAndNotWhitespace(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('non-empty string and not whitespace', value)); - } -} -// eslint-disable-next-line @typescript-eslint/ban-types -function dist_assertNull(value, message) { - if (!dist_isNull(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('null', value)); - } -} -// eslint-disable-next-line @typescript-eslint/ban-types -function dist_assertNullOrUndefined(value, message) { - if (!dist_isNullOrUndefined(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('null or undefined', value)); - } -} -function dist_assertNumber(value, message) { - if (!dist_isNumber(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('number', value)); - } -} -function dist_assertNumericString(value, message) { - if (!dist_isNumericString(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('string with a number', value)); - } -} -// eslint-disable-next-line @typescript-eslint/ban-types -function dist_assertObject(value, message) { - if (!dist_isObject(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('Object', value)); - } -} -function dist_assertObservable(value, message) { - if (!dist_isObservable(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('Observable', value)); - } -} -function dist_assertOddInteger(value, message) { - if (!dist_isOddInteger(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('odd integer', value)); - } -} -function dist_assertPlainObject(value, message) { - if (!dist_isPlainObject(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('plain object', value)); - } -} -function dist_assertPositiveNumber(value, message) { - if (!dist_isPositiveNumber(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('positive number', value)); - } -} -function dist_assertPrimitive(value, message) { - if (!dist_isPrimitive(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('primitive', value)); - } -} -function dist_assertPromise(value, message) { - if (!dist_isPromise(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('Promise', value)); - } -} -function dist_assertPropertyKey(value, message) { - if (!dist_isPropertyKey(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('PropertyKey', value)); - } -} -function dist_assertRegExp(value, message) { - if (!dist_isRegExp(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('RegExp', value)); - } -} -function dist_assertSafeInteger(value, message) { - if (!dist_isSafeInteger(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('integer', value)); - } -} -function dist_assertSet(value, message) { - if (!dist_isSet(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('Set', value)); - } -} -function dist_assertSharedArrayBuffer(value, message) { - if (!dist_isSharedArrayBuffer(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('SharedArrayBuffer', value)); - } -} -function dist_assertString(value, message) { - if (!dist_isString(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('string', value)); - } -} -function dist_assertSymbol(value, message) { - if (!dist_isSymbol(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('symbol', value)); - } -} -function dist_assertTruthy(value, message) { - if (!dist_isTruthy(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('truthy', value)); - } -} -function dist_assertTupleLike(value, guards, message) { - if (!dist_isTupleLike(value, guards)) { - throw new TypeError(message ?? dist_typeErrorMessage('tuple-like', value)); - } -} -function dist_assertTypedArray(value, message) { - if (!dist_isTypedArray(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('TypedArray', value)); - } -} -function dist_assertUint16Array(value, message) { - if (!dist_isUint16Array(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('Uint16Array', value)); - } -} -function dist_assertUint32Array(value, message) { - if (!dist_isUint32Array(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('Uint32Array', value)); - } -} -function dist_assertUint8Array(value, message) { - if (!dist_isUint8Array(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('Uint8Array', value)); - } -} -function dist_assertUint8ClampedArray(value, message) { - if (!dist_isUint8ClampedArray(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('Uint8ClampedArray', value)); - } -} -function dist_assertUndefined(value, message) { - if (!dist_isUndefined(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('undefined', value)); - } -} -function dist_assertUrlInstance(value, message) { - if (!dist_isUrlInstance(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('URL', value)); - } -} -// eslint-disable-next-line unicorn/prevent-abbreviations -function dist_assertUrlSearchParams(value, message) { - if (!dist_isUrlSearchParams(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('URLSearchParams', value)); - } -} -function dist_assertUrlString(value, message) { - if (!dist_isUrlString(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('string with a URL', value)); - } -} -function dist_assertValidDate(value, message) { - if (!dist_isValidDate(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('valid Date', value)); - } -} -function dist_assertValidLength(value, message) { - if (!dist_isValidLength(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('valid length', value)); - } -} -// eslint-disable-next-line @typescript-eslint/ban-types -function dist_assertWeakMap(value, message) { - if (!dist_isWeakMap(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('WeakMap', value)); - } -} -// eslint-disable-next-line @typescript-eslint/ban-types -function dist_assertWeakRef(value, message) { - if (!dist_isWeakRef(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('WeakRef', value)); - } -} -// eslint-disable-next-line @typescript-eslint/ban-types -function dist_assertWeakSet(value, message) { - if (!dist_isWeakSet(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('WeakSet', value)); - } -} -function dist_assertWhitespaceString(value, message) { - if (!dist_isWhitespaceString(value)) { - throw new TypeError(message ?? dist_typeErrorMessage('whitespace string', value)); - } -} -/* harmony default export */ const is_dist = (dist_is); - -;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.3.0/node_modules/got/dist/source/core/errors.js - -// A hacky check to prevent circular references. -function errors_isRequest(x) { - return is_dist.object(x) && '_onResponse' in x; -} -/** -An error to be thrown when a request fails. -Contains a `code` property with error class code, like `ECONNREFUSED`. -*/ -class errors_RequestError extends Error { - input; - code; - stack; - response; - request; - timings; - constructor(message, error, self) { - super(message, { cause: error }); - Error.captureStackTrace(this, this.constructor); - this.name = 'RequestError'; - this.code = error.code ?? 'ERR_GOT_REQUEST_ERROR'; - this.input = error.input; - if (errors_isRequest(self)) { - Object.defineProperty(this, 'request', { - enumerable: false, - value: self, - }); - Object.defineProperty(this, 'response', { - enumerable: false, - value: self.response, - }); - this.options = self.options; - } - else { - this.options = self; - } - this.timings = this.request?.timings; - // Recover the original stacktrace - if (is_dist.string(error.stack) && is_dist.string(this.stack)) { - const indexOfMessage = this.stack.indexOf(this.message) + this.message.length; - const thisStackTrace = this.stack.slice(indexOfMessage).split('\n').reverse(); - const errorStackTrace = error.stack.slice(error.stack.indexOf(error.message) + error.message.length).split('\n').reverse(); - // Remove duplicated traces - while (errorStackTrace.length > 0 && errorStackTrace[0] === thisStackTrace[0]) { - thisStackTrace.shift(); - } - this.stack = `${this.stack.slice(0, indexOfMessage)}${thisStackTrace.reverse().join('\n')}${errorStackTrace.reverse().join('\n')}`; - } - } -} -/** -An error to be thrown when the server redirects you more than ten times. -Includes a `response` property. -*/ -class errors_MaxRedirectsError extends errors_RequestError { - constructor(request) { - super(`Redirected ${request.options.maxRedirects} times. Aborting.`, {}, request); - this.name = 'MaxRedirectsError'; - this.code = 'ERR_TOO_MANY_REDIRECTS'; - } -} -/** -An error to be thrown when the server response code is not 2xx nor 3xx if `options.followRedirect` is `true`, but always except for 304. -Includes a `response` property. -*/ -// TODO: Change `HTTPError` to `HTTPError` in the next major version to enforce type usage. -// eslint-disable-next-line @typescript-eslint/naming-convention -class errors_HTTPError extends errors_RequestError { - constructor(response) { - super(`Response code ${response.statusCode} (${response.statusMessage})`, {}, response.request); - this.name = 'HTTPError'; - this.code = 'ERR_NON_2XX_3XX_RESPONSE'; - } -} -/** -An error to be thrown when a cache method fails. -For example, if the database goes down or there's a filesystem error. -*/ -class errors_CacheError extends errors_RequestError { - constructor(error, request) { - super(error.message, error, request); - this.name = 'CacheError'; - this.code = this.code === 'ERR_GOT_REQUEST_ERROR' ? 'ERR_CACHE_ACCESS' : this.code; - } -} -/** -An error to be thrown when the request body is a stream and an error occurs while reading from that stream. -*/ -class errors_UploadError extends errors_RequestError { - constructor(error, request) { - super(error.message, error, request); - this.name = 'UploadError'; - this.code = this.code === 'ERR_GOT_REQUEST_ERROR' ? 'ERR_UPLOAD' : this.code; - } -} -/** -An error to be thrown when the request is aborted due to a timeout. -Includes an `event` and `timings` property. -*/ -class errors_TimeoutError extends errors_RequestError { - timings; - event; - constructor(error, timings, request) { - super(error.message, error, request); - this.name = 'TimeoutError'; - this.event = error.event; - this.timings = timings; - } -} -/** -An error to be thrown when reading from response stream fails. -*/ -class errors_ReadError extends errors_RequestError { - constructor(error, request) { - super(error.message, error, request); - this.name = 'ReadError'; - this.code = this.code === 'ERR_GOT_REQUEST_ERROR' ? 'ERR_READING_RESPONSE_STREAM' : this.code; - } -} -/** -An error which always triggers a new retry when thrown. -*/ -class errors_RetryError extends errors_RequestError { - constructor(request) { - super('Retrying', {}, request); - this.name = 'RetryError'; - this.code = 'ERR_RETRYING'; - } -} -/** -An error to be thrown when the request is aborted by AbortController. -*/ -class errors_AbortError extends errors_RequestError { - constructor(request) { - super('This operation was aborted.', {}, request); - this.code = 'ERR_ABORTED'; - this.name = 'AbortError'; - } -} - -;// CONCATENATED MODULE: ./node_modules/.pnpm/get-stream@8.0.1/node_modules/get-stream/source/contents.js -const source_contents_getStreamContents = async (stream, {init, convertChunk, getSize, truncateChunk, addChunk, getFinalChunk, finalize}, {maxBuffer = Number.POSITIVE_INFINITY} = {}) => { - if (!contents_isAsyncIterable(stream)) { - throw new Error('The first argument must be a Readable, a ReadableStream, or an async iterable.'); - } - - const state = init(); - state.length = 0; - - try { - for await (const chunk of stream) { - const chunkType = contents_getChunkType(chunk); - const convertedChunk = convertChunk[chunkType](chunk, state); - contents_appendChunk({convertedChunk, state, getSize, truncateChunk, addChunk, maxBuffer}); - } - - contents_appendFinalChunk({state, convertChunk, getSize, truncateChunk, addChunk, getFinalChunk, maxBuffer}); - return finalize(state); - } catch (error) { - error.bufferedData = finalize(state); - throw error; - } -}; - -const contents_appendFinalChunk = ({state, getSize, truncateChunk, addChunk, getFinalChunk, maxBuffer}) => { - const convertedChunk = getFinalChunk(state); - if (convertedChunk !== undefined) { - contents_appendChunk({convertedChunk, state, getSize, truncateChunk, addChunk, maxBuffer}); - } -}; - -const contents_appendChunk = ({convertedChunk, state, getSize, truncateChunk, addChunk, maxBuffer}) => { - const chunkSize = getSize(convertedChunk); - const newLength = state.length + chunkSize; - - if (newLength <= maxBuffer) { - contents_addNewChunk(convertedChunk, state, addChunk, newLength); - return; - } - - const truncatedChunk = truncateChunk(convertedChunk, maxBuffer - state.length); - - if (truncatedChunk !== undefined) { - contents_addNewChunk(truncatedChunk, state, addChunk, maxBuffer); - } - - throw new contents_MaxBufferError(); -}; - -const contents_addNewChunk = (convertedChunk, state, addChunk, newLength) => { - state.contents = addChunk(convertedChunk, state, newLength); - state.length = newLength; -}; - -const contents_isAsyncIterable = stream => typeof stream === 'object' && stream !== null && typeof stream[Symbol.asyncIterator] === 'function'; - -const contents_getChunkType = chunk => { - const typeOfChunk = typeof chunk; - - if (typeOfChunk === 'string') { - return 'string'; - } - - if (typeOfChunk !== 'object' || chunk === null) { - return 'others'; - } - - // eslint-disable-next-line n/prefer-global/buffer - if (globalThis.Buffer?.isBuffer(chunk)) { - return 'buffer'; - } - - const prototypeName = contents_objectToString.call(chunk); - - if (prototypeName === '[object ArrayBuffer]') { - return 'arrayBuffer'; - } - - if (prototypeName === '[object DataView]') { - return 'dataView'; - } - - if ( - Number.isInteger(chunk.byteLength) - && Number.isInteger(chunk.byteOffset) - && contents_objectToString.call(chunk.buffer) === '[object ArrayBuffer]' - ) { - return 'typedArray'; - } - - return 'others'; -}; - -const {toString: contents_objectToString} = Object.prototype; - -class contents_MaxBufferError extends Error { - name = 'MaxBufferError'; - - constructor() { - super('maxBuffer exceeded'); - } -} - -;// CONCATENATED MODULE: ./node_modules/.pnpm/get-stream@8.0.1/node_modules/get-stream/source/utils.js -const utils_identity = value => value; - -const utils_noop = () => undefined; - -const getContentsProp = ({contents}) => contents; - -const utils_throwObjectStream = chunk => { - throw new Error(`Streams in object mode are not supported: ${String(chunk)}`); -}; - -const getLengthProp = convertedChunk => convertedChunk.length; - -;// CONCATENATED MODULE: ./node_modules/.pnpm/get-stream@8.0.1/node_modules/get-stream/source/array.js - - - -async function getStreamAsArray(stream, options) { - return getStreamContents(stream, arrayMethods, options); -} - -const initArray = () => ({contents: []}); - -const increment = () => 1; - -const addArrayChunk = (convertedChunk, {contents}) => { - contents.push(convertedChunk); - return contents; -}; - -const arrayMethods = { - init: initArray, - convertChunk: { - string: utils_identity, - buffer: utils_identity, - arrayBuffer: utils_identity, - dataView: utils_identity, - typedArray: utils_identity, - others: utils_identity, - }, - getSize: increment, - truncateChunk: utils_noop, - addChunk: addArrayChunk, - getFinalChunk: utils_noop, - finalize: getContentsProp, -}; - -;// CONCATENATED MODULE: ./node_modules/.pnpm/get-stream@8.0.1/node_modules/get-stream/source/array-buffer.js - - - -async function array_buffer_getStreamAsArrayBuffer(stream, options) { - return source_contents_getStreamContents(stream, array_buffer_arrayBufferMethods, options); -} - -const array_buffer_initArrayBuffer = () => ({contents: new ArrayBuffer(0)}); - -const array_buffer_useTextEncoder = chunk => array_buffer_textEncoder.encode(chunk); -const array_buffer_textEncoder = new TextEncoder(); - -const array_buffer_useUint8Array = chunk => new Uint8Array(chunk); - -const array_buffer_useUint8ArrayWithOffset = chunk => new Uint8Array(chunk.buffer, chunk.byteOffset, chunk.byteLength); - -const array_buffer_truncateArrayBufferChunk = (convertedChunk, chunkSize) => convertedChunk.slice(0, chunkSize); - -// `contents` is an increasingly growing `Uint8Array`. -const array_buffer_addArrayBufferChunk = (convertedChunk, {contents, length: previousLength}, length) => { - const newContents = array_buffer_hasArrayBufferResize() ? array_buffer_resizeArrayBuffer(contents, length) : array_buffer_resizeArrayBufferSlow(contents, length); - new Uint8Array(newContents).set(convertedChunk, previousLength); - return newContents; -}; - -// Without `ArrayBuffer.resize()`, `contents` size is always a power of 2. -// This means its last bytes are zeroes (not stream data), which need to be -// trimmed at the end with `ArrayBuffer.slice()`. -const array_buffer_resizeArrayBufferSlow = (contents, length) => { - if (length <= contents.byteLength) { - return contents; - } - - const arrayBuffer = new ArrayBuffer(array_buffer_getNewContentsLength(length)); - new Uint8Array(arrayBuffer).set(new Uint8Array(contents), 0); - return arrayBuffer; -}; - -// With `ArrayBuffer.resize()`, `contents` size matches exactly the size of -// the stream data. It does not include extraneous zeroes to trim at the end. -// The underlying `ArrayBuffer` does allocate a number of bytes that is a power -// of 2, but those bytes are only visible after calling `ArrayBuffer.resize()`. -const array_buffer_resizeArrayBuffer = (contents, length) => { - if (length <= contents.maxByteLength) { - contents.resize(length); - return contents; - } - - const arrayBuffer = new ArrayBuffer(length, {maxByteLength: array_buffer_getNewContentsLength(length)}); - new Uint8Array(arrayBuffer).set(new Uint8Array(contents), 0); - return arrayBuffer; -}; - -// Retrieve the closest `length` that is both >= and a power of 2 -const array_buffer_getNewContentsLength = length => array_buffer_SCALE_FACTOR ** Math.ceil(Math.log(length) / Math.log(array_buffer_SCALE_FACTOR)); - -const array_buffer_SCALE_FACTOR = 2; - -const array_buffer_finalizeArrayBuffer = ({contents, length}) => array_buffer_hasArrayBufferResize() ? contents : contents.slice(0, length); - -// `ArrayBuffer.slice()` is slow. When `ArrayBuffer.resize()` is available -// (Node >=20.0.0, Safari >=16.4 and Chrome), we can use it instead. -// eslint-disable-next-line no-warning-comments -// TODO: remove after dropping support for Node 20. -// eslint-disable-next-line no-warning-comments -// TODO: use `ArrayBuffer.transferToFixedLength()` instead once it is available -const array_buffer_hasArrayBufferResize = () => 'resize' in ArrayBuffer.prototype; - -const array_buffer_arrayBufferMethods = { - init: array_buffer_initArrayBuffer, - convertChunk: { - string: array_buffer_useTextEncoder, - buffer: array_buffer_useUint8Array, - arrayBuffer: array_buffer_useUint8Array, - dataView: array_buffer_useUint8ArrayWithOffset, - typedArray: array_buffer_useUint8ArrayWithOffset, - others: utils_throwObjectStream, - }, - getSize: getLengthProp, - truncateChunk: array_buffer_truncateArrayBufferChunk, - addChunk: array_buffer_addArrayBufferChunk, - getFinalChunk: utils_noop, - finalize: array_buffer_finalizeArrayBuffer, -}; - -;// CONCATENATED MODULE: ./node_modules/.pnpm/get-stream@8.0.1/node_modules/get-stream/source/buffer.js - - -async function buffer_getStreamAsBuffer(stream, options) { - if (!('Buffer' in globalThis)) { - throw new Error('getStreamAsBuffer() is only supported in Node.js'); - } - - try { - return buffer_arrayBufferToNodeBuffer(await array_buffer_getStreamAsArrayBuffer(stream, options)); - } catch (error) { - if (error.bufferedData !== undefined) { - error.bufferedData = buffer_arrayBufferToNodeBuffer(error.bufferedData); - } - - throw error; - } -} - -// eslint-disable-next-line n/prefer-global/buffer -const buffer_arrayBufferToNodeBuffer = arrayBuffer => globalThis.Buffer.from(arrayBuffer); - -;// CONCATENATED MODULE: ./node_modules/.pnpm/get-stream@8.0.1/node_modules/get-stream/source/string.js - - - -async function getStreamAsString(stream, options) { - return getStreamContents(stream, stringMethods, options); -} - -const initString = () => ({contents: '', textDecoder: new TextDecoder()}); - -const useTextDecoder = (chunk, {textDecoder}) => textDecoder.decode(chunk, {stream: true}); - -const addStringChunk = (convertedChunk, {contents}) => contents + convertedChunk; - -const truncateStringChunk = (convertedChunk, chunkSize) => convertedChunk.slice(0, chunkSize); - -const getFinalStringChunk = ({textDecoder}) => { - const finalChunk = textDecoder.decode(); - return finalChunk === '' ? undefined : finalChunk; -}; - -const stringMethods = { - init: initString, - convertChunk: { - string: utils_identity, - buffer: useTextDecoder, - arrayBuffer: useTextDecoder, - dataView: useTextDecoder, - typedArray: useTextDecoder, - others: utils_throwObjectStream, - }, - getSize: getLengthProp, - truncateChunk: truncateStringChunk, - addChunk: addStringChunk, - getFinalChunk: getFinalStringChunk, - finalize: getContentsProp, -}; - -;// CONCATENATED MODULE: ./node_modules/.pnpm/get-stream@8.0.1/node_modules/get-stream/source/index.js - - - - - - -;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.3.0/node_modules/got/dist/source/core/utils/is-form-data.js - -function utils_is_form_data_isFormData(body) { - return is_dist.nodeStream(body) && is_dist.function_(body.getBoundary); -} - -;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.3.0/node_modules/got/dist/source/core/utils/get-body-size.js - - - - -async function get_body_size_getBodySize(body, headers) { - if (headers && 'content-length' in headers) { - return Number(headers['content-length']); - } - if (!body) { - return 0; - } - if (is_dist.string(body)) { - return external_node_buffer_namespaceObject.Buffer.byteLength(body); - } - if (is_dist.buffer(body)) { - return body.length; - } - if (utils_is_form_data_isFormData(body)) { - return (0,external_node_util_.promisify)(body.getLength.bind(body))(); - } - return undefined; -} - -;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.3.0/node_modules/got/dist/source/core/utils/proxy-events.js -function proxy_events_proxyEvents(from, to, events) { - const eventFunctions = {}; - for (const event of events) { - const eventFunction = (...arguments_) => { - to.emit(event, ...arguments_); - }; - eventFunctions[event] = eventFunction; - from.on(event, eventFunction); - } - return () => { - for (const [event, eventFunction] of Object.entries(eventFunctions)) { - from.off(event, eventFunction); - } - }; -} - -;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.3.0/node_modules/got/dist/source/core/utils/unhandle.js -// When attaching listeners, it's very easy to forget about them. -// Especially if you do error handling and set timeouts. -// So instead of checking if it's proper to throw an error on every timeout ever, -// use this simple tool which will remove all listeners you have attached. -function unhandle_unhandle() { - const handlers = []; - return { - once(origin, event, function_) { - origin.once(event, function_); - handlers.push({ origin, event, fn: function_ }); - }, - unhandleAll() { - for (const handler of handlers) { - const { origin, event, fn } = handler; - origin.removeListener(event, fn); - } - handlers.length = 0; - }, - }; -} - -;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.3.0/node_modules/got/dist/source/core/timed-out.js - - -const timed_out_reentry = Symbol('reentry'); -const core_timed_out_noop = () => { }; -class core_timed_out_TimeoutError extends Error { - event; - code; - constructor(threshold, event) { - super(`Timeout awaiting '${event}' for ${threshold}ms`); - this.event = event; - this.name = 'TimeoutError'; - this.code = 'ETIMEDOUT'; - } -} -function timed_out_timedOut(request, delays, options) { - if (timed_out_reentry in request) { - return core_timed_out_noop; - } - request[timed_out_reentry] = true; - const cancelers = []; - const { once, unhandleAll } = unhandle_unhandle(); - const addTimeout = (delay, callback, event) => { - const timeout = setTimeout(callback, delay, delay, event); - timeout.unref?.(); - const cancel = () => { - clearTimeout(timeout); - }; - cancelers.push(cancel); - return cancel; - }; - const { host, hostname } = options; - const timeoutHandler = (delay, event) => { - request.destroy(new core_timed_out_TimeoutError(delay, event)); - }; - const cancelTimeouts = () => { - for (const cancel of cancelers) { - cancel(); - } - unhandleAll(); - }; - request.once('error', error => { - cancelTimeouts(); - // Save original behavior - /* istanbul ignore next */ - if (request.listenerCount('error') === 0) { - throw error; - } - }); - if (delays.request !== undefined) { - const cancelTimeout = addTimeout(delays.request, timeoutHandler, 'request'); - once(request, 'response', (response) => { - once(response, 'end', cancelTimeout); - }); - } - if (delays.socket !== undefined) { - const { socket } = delays; - const socketTimeoutHandler = () => { - timeoutHandler(socket, 'socket'); - }; - request.setTimeout(socket, socketTimeoutHandler); - // `request.setTimeout(0)` causes a memory leak. - // We can just remove the listener and forget about the timer - it's unreffed. - // See https://github.com/sindresorhus/got/issues/690 - cancelers.push(() => { - request.removeListener('timeout', socketTimeoutHandler); - }); - } - const hasLookup = delays.lookup !== undefined; - const hasConnect = delays.connect !== undefined; - const hasSecureConnect = delays.secureConnect !== undefined; - const hasSend = delays.send !== undefined; - if (hasLookup || hasConnect || hasSecureConnect || hasSend) { - once(request, 'socket', (socket) => { - const { socketPath } = request; - /* istanbul ignore next: hard to test */ - if (socket.connecting) { - const hasPath = Boolean(socketPath ?? external_node_net_namespaceObject.isIP(hostname ?? host ?? '') !== 0); - if (hasLookup && !hasPath && socket.address().address === undefined) { - const cancelTimeout = addTimeout(delays.lookup, timeoutHandler, 'lookup'); - once(socket, 'lookup', cancelTimeout); - } - if (hasConnect) { - const timeConnect = () => addTimeout(delays.connect, timeoutHandler, 'connect'); - if (hasPath) { - once(socket, 'connect', timeConnect()); - } - else { - once(socket, 'lookup', (error) => { - if (error === null) { - once(socket, 'connect', timeConnect()); - } - }); - } - } - if (hasSecureConnect && options.protocol === 'https:') { - once(socket, 'connect', () => { - const cancelTimeout = addTimeout(delays.secureConnect, timeoutHandler, 'secureConnect'); - once(socket, 'secureConnect', cancelTimeout); - }); - } - } - if (hasSend) { - const timeRequest = () => addTimeout(delays.send, timeoutHandler, 'send'); - /* istanbul ignore next: hard to test */ - if (socket.connecting) { - once(socket, 'connect', () => { - once(request, 'upload-complete', timeRequest()); - }); - } - else { - once(request, 'upload-complete', timeRequest()); - } - } - }); - } - if (delays.response !== undefined) { - once(request, 'upload-complete', () => { - const cancelTimeout = addTimeout(delays.response, timeoutHandler, 'response'); - once(request, 'response', cancelTimeout); - }); - } - if (delays.read !== undefined) { - once(request, 'response', (response) => { - const cancelTimeout = addTimeout(delays.read, timeoutHandler, 'read'); - once(response, 'end', cancelTimeout); - }); - } - return cancelTimeouts; -} - -;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.3.0/node_modules/got/dist/source/core/utils/url-to-options.js - -function url_to_options_urlToOptions(url) { - // Cast to URL - url = url; - const options = { - protocol: url.protocol, - hostname: is_dist.string(url.hostname) && url.hostname.startsWith('[') ? url.hostname.slice(1, -1) : url.hostname, - host: url.host, - hash: url.hash, - search: url.search, - pathname: url.pathname, - href: url.href, - path: `${url.pathname || ''}${url.search || ''}`, - }; - if (is_dist.string(url.port) && url.port.length > 0) { - options.port = Number(url.port); - } - if (url.username || url.password) { - options.auth = `${url.username || ''}:${url.password || ''}`; - } - return options; -} - -;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.3.0/node_modules/got/dist/source/core/utils/weakable-map.js -class weakable_map_WeakableMap { - weakMap; - map; - constructor() { - this.weakMap = new WeakMap(); - this.map = new Map(); - } - set(key, value) { - if (typeof key === 'object') { - this.weakMap.set(key, value); - } - else { - this.map.set(key, value); - } - } - get(key) { - if (typeof key === 'object') { - return this.weakMap.get(key); - } - return this.map.get(key); - } - has(key) { - if (typeof key === 'object') { - return this.weakMap.has(key); - } - return this.map.has(key); - } -} - -;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.3.0/node_modules/got/dist/source/core/calculate-retry-delay.js -const calculate_retry_delay_calculateRetryDelay = ({ attemptCount, retryOptions, error, retryAfter, computedValue, }) => { - if (error.name === 'RetryError') { - return 1; - } - if (attemptCount > retryOptions.limit) { - return 0; - } - const hasMethod = retryOptions.methods.includes(error.options.method); - const hasErrorCode = retryOptions.errorCodes.includes(error.code); - const hasStatusCode = error.response && retryOptions.statusCodes.includes(error.response.statusCode); - if (!hasMethod || (!hasErrorCode && !hasStatusCode)) { - return 0; - } - if (error.response) { - if (retryAfter) { - // In this case `computedValue` is `options.request.timeout` - if (retryAfter > computedValue) { - return 0; - } - return retryAfter; - } - if (error.response.statusCode === 413) { - return 0; - } - } - const noise = Math.random() * retryOptions.noise; - return Math.min(((2 ** (attemptCount - 1)) * 1000), retryOptions.backoffLimit) + noise; -}; -/* harmony default export */ const core_calculate_retry_delay = (calculate_retry_delay_calculateRetryDelay); - -;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.3.0/node_modules/got/dist/source/core/parse-link-header.js -function parse_link_header_parseLinkHeader(link) { - const parsed = []; - const items = link.split(','); - for (const item of items) { - // https://tools.ietf.org/html/rfc5988#section-5 - const [rawUriReference, ...rawLinkParameters] = item.split(';'); - const trimmedUriReference = rawUriReference.trim(); - // eslint-disable-next-line @typescript-eslint/prefer-string-starts-ends-with - if (trimmedUriReference[0] !== '<' || trimmedUriReference.at(-1) !== '>') { - throw new Error(`Invalid format of the Link header reference: ${trimmedUriReference}`); - } - const reference = trimmedUriReference.slice(1, -1); - const parameters = {}; - if (rawLinkParameters.length === 0) { - throw new Error(`Unexpected end of Link header parameters: ${rawLinkParameters.join(';')}`); - } - for (const rawParameter of rawLinkParameters) { - const trimmedRawParameter = rawParameter.trim(); - const center = trimmedRawParameter.indexOf('='); - if (center === -1) { - throw new Error(`Failed to parse Link header: ${link}`); - } - const name = trimmedRawParameter.slice(0, center).trim(); - const value = trimmedRawParameter.slice(center + 1).trim(); - parameters[name] = value; - } - parsed.push({ - reference, - parameters, - }); - } - return parsed; -} - -;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.3.0/node_modules/got/dist/source/core/options.js - - - -// DO NOT use destructuring for `https.request` and `http.request` as it's not compatible with `nock`. - - - - - - - - -const [options_major, options_minor] = external_node_process_.versions.node.split('.').map(Number); -function options_validateSearchParameters(searchParameters) { - // eslint-disable-next-line guard-for-in - for (const key in searchParameters) { - const value = searchParameters[key]; - dist_assert.any([is_dist.string, is_dist.number, is_dist.boolean, is_dist.null_, is_dist.undefined], value); - } -} -const options_globalCache = new Map(); -let options_globalDnsCache; -const options_getGlobalDnsCache = () => { - if (options_globalDnsCache) { - return options_globalDnsCache; - } - options_globalDnsCache = new CacheableLookup(); - return options_globalDnsCache; -}; -const options_defaultInternals = { - request: undefined, - agent: { - http: undefined, - https: undefined, - http2: undefined, - }, - h2session: undefined, - decompress: true, - timeout: { - connect: undefined, - lookup: undefined, - read: undefined, - request: undefined, - response: undefined, - secureConnect: undefined, - send: undefined, - socket: undefined, - }, - prefixUrl: '', - body: undefined, - form: undefined, - json: undefined, - cookieJar: undefined, - ignoreInvalidCookies: false, - searchParams: undefined, - dnsLookup: undefined, - dnsCache: undefined, - context: {}, - hooks: { - init: [], - beforeRequest: [], - beforeError: [], - beforeRedirect: [], - beforeRetry: [], - afterResponse: [], - }, - followRedirect: true, - maxRedirects: 10, - cache: undefined, - throwHttpErrors: true, - username: '', - password: '', - http2: false, - allowGetBody: false, - headers: { - 'user-agent': 'got (https://github.com/sindresorhus/got)', - }, - methodRewriting: false, - dnsLookupIpVersion: undefined, - parseJson: JSON.parse, - stringifyJson: JSON.stringify, - retry: { - limit: 2, - methods: [ - 'GET', - 'PUT', - 'HEAD', - 'DELETE', - 'OPTIONS', - 'TRACE', - ], - statusCodes: [ - 408, - 413, - 429, - 500, - 502, - 503, - 504, - 521, - 522, - 524, - ], - errorCodes: [ - 'ETIMEDOUT', - 'ECONNRESET', - 'EADDRINUSE', - 'ECONNREFUSED', - 'EPIPE', - 'ENOTFOUND', - 'ENETUNREACH', - 'EAI_AGAIN', - ], - maxRetryAfter: undefined, - calculateDelay: ({ computedValue }) => computedValue, - backoffLimit: Number.POSITIVE_INFINITY, - noise: 100, - }, - localAddress: undefined, - method: 'GET', - createConnection: undefined, - cacheOptions: { - shared: undefined, - cacheHeuristic: undefined, - immutableMinTimeToLive: undefined, - ignoreCargoCult: undefined, - }, - https: { - alpnProtocols: undefined, - rejectUnauthorized: undefined, - checkServerIdentity: undefined, - certificateAuthority: undefined, - key: undefined, - certificate: undefined, - passphrase: undefined, - pfx: undefined, - ciphers: undefined, - honorCipherOrder: undefined, - minVersion: undefined, - maxVersion: undefined, - signatureAlgorithms: undefined, - tlsSessionLifetime: undefined, - dhparam: undefined, - ecdhCurve: undefined, - certificateRevocationLists: undefined, - }, - encoding: undefined, - resolveBodyOnly: false, - isStream: false, - responseType: 'text', - url: undefined, - pagination: { - transform(response) { - if (response.request.options.responseType === 'json') { - return response.body; - } - return JSON.parse(response.body); - }, - paginate({ response }) { - const rawLinkHeader = response.headers.link; - if (typeof rawLinkHeader !== 'string' || rawLinkHeader.trim() === '') { - return false; - } - const parsed = parse_link_header_parseLinkHeader(rawLinkHeader); - const next = parsed.find(entry => entry.parameters.rel === 'next' || entry.parameters.rel === '"next"'); - if (next) { - return { - url: new URL(next.reference, response.url), - }; - } - return false; - }, - filter: () => true, - shouldContinue: () => true, - countLimit: Number.POSITIVE_INFINITY, - backoff: 0, - requestLimit: 10_000, - stackAllItems: false, - }, - setHost: true, - maxHeaderSize: undefined, - signal: undefined, - enableUnixSockets: false, -}; -const options_cloneInternals = (internals) => { - const { hooks, retry } = internals; - const result = { - ...internals, - context: { ...internals.context }, - cacheOptions: { ...internals.cacheOptions }, - https: { ...internals.https }, - agent: { ...internals.agent }, - headers: { ...internals.headers }, - retry: { - ...retry, - errorCodes: [...retry.errorCodes], - methods: [...retry.methods], - statusCodes: [...retry.statusCodes], - }, - timeout: { ...internals.timeout }, - hooks: { - init: [...hooks.init], - beforeRequest: [...hooks.beforeRequest], - beforeError: [...hooks.beforeError], - beforeRedirect: [...hooks.beforeRedirect], - beforeRetry: [...hooks.beforeRetry], - afterResponse: [...hooks.afterResponse], - }, - searchParams: internals.searchParams ? new URLSearchParams(internals.searchParams) : undefined, - pagination: { ...internals.pagination }, - }; - if (result.url !== undefined) { - result.prefixUrl = ''; - } - return result; -}; -const options_cloneRaw = (raw) => { - const { hooks, retry } = raw; - const result = { ...raw }; - if (is_dist.object(raw.context)) { - result.context = { ...raw.context }; - } - if (is_dist.object(raw.cacheOptions)) { - result.cacheOptions = { ...raw.cacheOptions }; - } - if (is_dist.object(raw.https)) { - result.https = { ...raw.https }; - } - if (is_dist.object(raw.cacheOptions)) { - result.cacheOptions = { ...result.cacheOptions }; - } - if (is_dist.object(raw.agent)) { - result.agent = { ...raw.agent }; - } - if (is_dist.object(raw.headers)) { - result.headers = { ...raw.headers }; - } - if (is_dist.object(retry)) { - result.retry = { ...retry }; - if (is_dist.array(retry.errorCodes)) { - result.retry.errorCodes = [...retry.errorCodes]; - } - if (is_dist.array(retry.methods)) { - result.retry.methods = [...retry.methods]; - } - if (is_dist.array(retry.statusCodes)) { - result.retry.statusCodes = [...retry.statusCodes]; - } - } - if (is_dist.object(raw.timeout)) { - result.timeout = { ...raw.timeout }; - } - if (is_dist.object(hooks)) { - result.hooks = { - ...hooks, - }; - if (is_dist.array(hooks.init)) { - result.hooks.init = [...hooks.init]; - } - if (is_dist.array(hooks.beforeRequest)) { - result.hooks.beforeRequest = [...hooks.beforeRequest]; - } - if (is_dist.array(hooks.beforeError)) { - result.hooks.beforeError = [...hooks.beforeError]; - } - if (is_dist.array(hooks.beforeRedirect)) { - result.hooks.beforeRedirect = [...hooks.beforeRedirect]; - } - if (is_dist.array(hooks.beforeRetry)) { - result.hooks.beforeRetry = [...hooks.beforeRetry]; - } - if (is_dist.array(hooks.afterResponse)) { - result.hooks.afterResponse = [...hooks.afterResponse]; - } - } - // TODO: raw.searchParams - if (is_dist.object(raw.pagination)) { - result.pagination = { ...raw.pagination }; - } - return result; -}; -const options_getHttp2TimeoutOption = (internals) => { - const delays = [internals.timeout.socket, internals.timeout.connect, internals.timeout.lookup, internals.timeout.request, internals.timeout.secureConnect].filter(delay => typeof delay === 'number'); - if (delays.length > 0) { - return Math.min(...delays); - } - return undefined; -}; -const options_init = (options, withOptions, self) => { - const initHooks = options.hooks?.init; - if (initHooks) { - for (const hook of initHooks) { - hook(withOptions, self); - } - } -}; -class options_Options { - _unixOptions; - _internals; - _merging; - _init; - constructor(input, options, defaults) { - dist_assert.any([is_dist.string, is_dist.urlInstance, is_dist.object, is_dist.undefined], input); - dist_assert.any([is_dist.object, is_dist.undefined], options); - dist_assert.any([is_dist.object, is_dist.undefined], defaults); - if (input instanceof options_Options || options instanceof options_Options) { - throw new TypeError('The defaults must be passed as the third argument'); - } - this._internals = options_cloneInternals(defaults?._internals ?? defaults ?? options_defaultInternals); - this._init = [...(defaults?._init ?? [])]; - this._merging = false; - this._unixOptions = undefined; - // This rule allows `finally` to be considered more important. - // Meaning no matter the error thrown in the `try` block, - // if `finally` throws then the `finally` error will be thrown. - // - // Yes, we want this. If we set `url` first, then the `url.searchParams` - // would get merged. Instead we set the `searchParams` first, then - // `url.searchParams` is overwritten as expected. - // - /* eslint-disable no-unsafe-finally */ - try { - if (is_dist.plainObject(input)) { - try { - this.merge(input); - this.merge(options); - } - finally { - this.url = input.url; - } - } - else { - try { - this.merge(options); - } - finally { - if (options?.url !== undefined) { - if (input === undefined) { - this.url = options.url; - } - else { - throw new TypeError('The `url` option is mutually exclusive with the `input` argument'); - } - } - else if (input !== undefined) { - this.url = input; - } - } - } - } - catch (error) { - error.options = this; - throw error; - } - /* eslint-enable no-unsafe-finally */ - } - merge(options) { - if (!options) { - return; - } - if (options instanceof options_Options) { - for (const init of options._init) { - this.merge(init); - } - return; - } - options = options_cloneRaw(options); - options_init(this, options, this); - options_init(options, options, this); - this._merging = true; - // Always merge `isStream` first - if ('isStream' in options) { - this.isStream = options.isStream; - } - try { - let push = false; - for (const key in options) { - // `got.extend()` options - if (key === 'mutableDefaults' || key === 'handlers') { - continue; - } - // Never merge `url` - if (key === 'url') { - continue; - } - if (!(key in this)) { - throw new Error(`Unexpected option: ${key}`); - } - // @ts-expect-error Type 'unknown' is not assignable to type 'never'. - const value = options[key]; - if (value === undefined) { - continue; - } - // @ts-expect-error Type 'unknown' is not assignable to type 'never'. - this[key] = value; - push = true; - } - if (push) { - this._init.push(options); - } - } - finally { - this._merging = false; - } - } - /** - Custom request function. - The main purpose of this is to [support HTTP2 using a wrapper](https://github.com/szmarczak/http2-wrapper). - - @default http.request | https.request - */ - get request() { - return this._internals.request; - } - set request(value) { - dist_assert.any([is_dist.function_, is_dist.undefined], value); - this._internals.request = value; - } - /** - An object representing `http`, `https` and `http2` keys for [`http.Agent`](https://nodejs.org/api/http.html#http_class_http_agent), [`https.Agent`](https://nodejs.org/api/https.html#https_class_https_agent) and [`http2wrapper.Agent`](https://github.com/szmarczak/http2-wrapper#new-http2agentoptions) instance. - This is necessary because a request to one protocol might redirect to another. - In such a scenario, Got will switch over to the right protocol agent for you. - - If a key is not present, it will default to a global agent. - - @example - ``` - import got from 'got'; - import HttpAgent from 'agentkeepalive'; - - const {HttpsAgent} = HttpAgent; - - await got('https://sindresorhus.com', { - agent: { - http: new HttpAgent(), - https: new HttpsAgent() - } - }); - ``` - */ - get agent() { - return this._internals.agent; - } - set agent(value) { - dist_assert.plainObject(value); - // eslint-disable-next-line guard-for-in - for (const key in value) { - if (!(key in this._internals.agent)) { - throw new TypeError(`Unexpected agent option: ${key}`); - } - // @ts-expect-error - No idea why `value[key]` doesn't work here. - dist_assert.any([is_dist.object, is_dist.undefined], value[key]); - } - if (this._merging) { - Object.assign(this._internals.agent, value); - } - else { - this._internals.agent = { ...value }; - } - } - get h2session() { - return this._internals.h2session; - } - set h2session(value) { - this._internals.h2session = value; - } - /** - Decompress the response automatically. - - This will set the `accept-encoding` header to `gzip, deflate, br` unless you set it yourself. - - If this is disabled, a compressed response is returned as a `Buffer`. - This may be useful if you want to handle decompression yourself or stream the raw compressed data. - - @default true - */ - get decompress() { - return this._internals.decompress; - } - set decompress(value) { - dist_assert.boolean(value); - this._internals.decompress = value; - } - /** - Milliseconds to wait for the server to end the response before aborting the request with `got.TimeoutError` error (a.k.a. `request` property). - By default, there's no timeout. - - This also accepts an `object` with the following fields to constrain the duration of each phase of the request lifecycle: - - - `lookup` starts when a socket is assigned and ends when the hostname has been resolved. - Does not apply when using a Unix domain socket. - - `connect` starts when `lookup` completes (or when the socket is assigned if lookup does not apply to the request) and ends when the socket is connected. - - `secureConnect` starts when `connect` completes and ends when the handshaking process completes (HTTPS only). - - `socket` starts when the socket is connected. See [request.setTimeout](https://nodejs.org/api/http.html#http_request_settimeout_timeout_callback). - - `response` starts when the request has been written to the socket and ends when the response headers are received. - - `send` starts when the socket is connected and ends with the request has been written to the socket. - - `request` starts when the request is initiated and ends when the response's end event fires. - */ - get timeout() { - // We always return `Delays` here. - // It has to be `Delays | number`, otherwise TypeScript will error because the getter and the setter have incompatible types. - return this._internals.timeout; - } - set timeout(value) { - dist_assert.plainObject(value); - // eslint-disable-next-line guard-for-in - for (const key in value) { - if (!(key in this._internals.timeout)) { - throw new Error(`Unexpected timeout option: ${key}`); - } - // @ts-expect-error - No idea why `value[key]` doesn't work here. - dist_assert.any([is_dist.number, is_dist.undefined], value[key]); - } - if (this._merging) { - Object.assign(this._internals.timeout, value); - } - else { - this._internals.timeout = { ...value }; - } - } - /** - When specified, `prefixUrl` will be prepended to `url`. - The prefix can be any valid URL, either relative or absolute. - A trailing slash `/` is optional - one will be added automatically. - - __Note__: `prefixUrl` will be ignored if the `url` argument is a URL instance. - - __Note__: Leading slashes in `input` are disallowed when using this option to enforce consistency and avoid confusion. - For example, when the prefix URL is `https://example.com/foo` and the input is `/bar`, there's ambiguity whether the resulting URL would become `https://example.com/foo/bar` or `https://example.com/bar`. - The latter is used by browsers. - - __Tip__: Useful when used with `got.extend()` to create niche-specific Got instances. - - __Tip__: You can change `prefixUrl` using hooks as long as the URL still includes the `prefixUrl`. - If the URL doesn't include it anymore, it will throw. - - @example - ``` - import got from 'got'; - - await got('unicorn', {prefixUrl: 'https://cats.com'}); - //=> 'https://cats.com/unicorn' - - const instance = got.extend({ - prefixUrl: 'https://google.com' - }); - - await instance('unicorn', { - hooks: { - beforeRequest: [ - options => { - options.prefixUrl = 'https://cats.com'; - } - ] - } - }); - //=> 'https://cats.com/unicorn' - ``` - */ - get prefixUrl() { - // We always return `string` here. - // It has to be `string | URL`, otherwise TypeScript will error because the getter and the setter have incompatible types. - return this._internals.prefixUrl; - } - set prefixUrl(value) { - dist_assert.any([is_dist.string, is_dist.urlInstance], value); - if (value === '') { - this._internals.prefixUrl = ''; - return; - } - value = value.toString(); - if (!value.endsWith('/')) { - value += '/'; - } - if (this._internals.prefixUrl && this._internals.url) { - const { href } = this._internals.url; - this._internals.url.href = value + href.slice(this._internals.prefixUrl.length); - } - this._internals.prefixUrl = value; - } - /** - __Note #1__: The `body` option cannot be used with the `json` or `form` option. - - __Note #2__: If you provide this option, `got.stream()` will be read-only. - - __Note #3__: If you provide a payload with the `GET` or `HEAD` method, it will throw a `TypeError` unless the method is `GET` and the `allowGetBody` option is set to `true`. - - __Note #4__: This option is not enumerable and will not be merged with the instance defaults. - - The `content-length` header will be automatically set if `body` is a `string` / `Buffer` / [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData) / [`form-data` instance](https://github.com/form-data/form-data), and `content-length` and `transfer-encoding` are not manually set in `options.headers`. - - Since Got 12, the `content-length` is not automatically set when `body` is a `fs.createReadStream`. - */ - get body() { - return this._internals.body; - } - set body(value) { - dist_assert.any([is_dist.string, is_dist.buffer, is_dist.nodeStream, is_dist.generator, is_dist.asyncGenerator, lib_isFormData, is_dist.undefined], value); - if (is_dist.nodeStream(value)) { - dist_assert.truthy(value.readable); - } - if (value !== undefined) { - dist_assert.undefined(this._internals.form); - dist_assert.undefined(this._internals.json); - } - this._internals.body = value; - } - /** - The form body is converted to a query string using [`(new URLSearchParams(object)).toString()`](https://nodejs.org/api/url.html#url_constructor_new_urlsearchparams_obj). - - If the `Content-Type` header is not present, it will be set to `application/x-www-form-urlencoded`. - - __Note #1__: If you provide this option, `got.stream()` will be read-only. - - __Note #2__: This option is not enumerable and will not be merged with the instance defaults. - */ - get form() { - return this._internals.form; - } - set form(value) { - dist_assert.any([is_dist.plainObject, is_dist.undefined], value); - if (value !== undefined) { - dist_assert.undefined(this._internals.body); - dist_assert.undefined(this._internals.json); - } - this._internals.form = value; - } - /** - JSON body. If the `Content-Type` header is not set, it will be set to `application/json`. - - __Note #1__: If you provide this option, `got.stream()` will be read-only. - - __Note #2__: This option is not enumerable and will not be merged with the instance defaults. - */ - get json() { - return this._internals.json; - } - set json(value) { - if (value !== undefined) { - dist_assert.undefined(this._internals.body); - dist_assert.undefined(this._internals.form); - } - this._internals.json = value; - } - /** - The URL to request, as a string, a [`https.request` options object](https://nodejs.org/api/https.html#https_https_request_options_callback), or a [WHATWG `URL`](https://nodejs.org/api/url.html#url_class_url). - - Properties from `options` will override properties in the parsed `url`. - - If no protocol is specified, it will throw a `TypeError`. - - __Note__: The query string is **not** parsed as search params. - - @example - ``` - await got('https://example.com/?query=a b'); //=> https://example.com/?query=a%20b - await got('https://example.com/', {searchParams: {query: 'a b'}}); //=> https://example.com/?query=a+b - - // The query string is overridden by `searchParams` - await got('https://example.com/?query=a b', {searchParams: {query: 'a b'}}); //=> https://example.com/?query=a+b - ``` - */ - get url() { - return this._internals.url; - } - set url(value) { - dist_assert.any([is_dist.string, is_dist.urlInstance, is_dist.undefined], value); - if (value === undefined) { - this._internals.url = undefined; - return; - } - if (is_dist.string(value) && value.startsWith('/')) { - throw new Error('`url` must not start with a slash'); - } - const urlString = `${this.prefixUrl}${value.toString()}`; - const url = new URL(urlString); - this._internals.url = url; - if (url.protocol === 'unix:') { - url.href = `http://unix${url.pathname}${url.search}`; - } - if (url.protocol !== 'http:' && url.protocol !== 'https:') { - const error = new Error(`Unsupported protocol: ${url.protocol}`); - error.code = 'ERR_UNSUPPORTED_PROTOCOL'; - throw error; - } - if (this._internals.username) { - url.username = this._internals.username; - this._internals.username = ''; - } - if (this._internals.password) { - url.password = this._internals.password; - this._internals.password = ''; - } - if (this._internals.searchParams) { - url.search = this._internals.searchParams.toString(); - this._internals.searchParams = undefined; - } - if (url.hostname === 'unix') { - if (!this._internals.enableUnixSockets) { - throw new Error('Using UNIX domain sockets but option `enableUnixSockets` is not enabled'); - } - const matches = /(?.+?):(?.+)/.exec(`${url.pathname}${url.search}`); - if (matches?.groups) { - const { socketPath, path } = matches.groups; - this._unixOptions = { - socketPath, - path, - host: '', - }; - } - else { - this._unixOptions = undefined; - } - return; - } - this._unixOptions = undefined; - } - /** - Cookie support. You don't have to care about parsing or how to store them. - - __Note__: If you provide this option, `options.headers.cookie` will be overridden. - */ - get cookieJar() { - return this._internals.cookieJar; - } - set cookieJar(value) { - dist_assert.any([is_dist.object, is_dist.undefined], value); - if (value === undefined) { - this._internals.cookieJar = undefined; - return; - } - let { setCookie, getCookieString } = value; - dist_assert.function_(setCookie); - dist_assert.function_(getCookieString); - /* istanbul ignore next: Horrible `tough-cookie` v3 check */ - if (setCookie.length === 4 && getCookieString.length === 0) { - setCookie = (0,external_node_util_.promisify)(setCookie.bind(value)); - getCookieString = (0,external_node_util_.promisify)(getCookieString.bind(value)); - this._internals.cookieJar = { - setCookie, - getCookieString: getCookieString, - }; - } - else { - this._internals.cookieJar = value; - } - } - /** - You can abort the `request` using [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController). - - @example - ``` - import got from 'got'; - - const abortController = new AbortController(); - - const request = got('https://httpbin.org/anything', { - signal: abortController.signal - }); - - setTimeout(() => { - abortController.abort(); - }, 100); - ``` - */ - get signal() { - return this._internals.signal; - } - set signal(value) { - dist_assert.object(value); - this._internals.signal = value; - } - /** - Ignore invalid cookies instead of throwing an error. - Only useful when the `cookieJar` option has been set. Not recommended. - - @default false - */ - get ignoreInvalidCookies() { - return this._internals.ignoreInvalidCookies; - } - set ignoreInvalidCookies(value) { - dist_assert.boolean(value); - this._internals.ignoreInvalidCookies = value; - } - /** - Query string that will be added to the request URL. - This will override the query string in `url`. - - If you need to pass in an array, you can do it using a `URLSearchParams` instance. - - @example - ``` - import got from 'got'; - - const searchParams = new URLSearchParams([['key', 'a'], ['key', 'b']]); - - await got('https://example.com', {searchParams}); - - console.log(searchParams.toString()); - //=> 'key=a&key=b' - ``` - */ - get searchParams() { - if (this._internals.url) { - return this._internals.url.searchParams; - } - if (this._internals.searchParams === undefined) { - this._internals.searchParams = new URLSearchParams(); - } - return this._internals.searchParams; - } - set searchParams(value) { - dist_assert.any([is_dist.string, is_dist.object, is_dist.undefined], value); - const url = this._internals.url; - if (value === undefined) { - this._internals.searchParams = undefined; - if (url) { - url.search = ''; - } - return; - } - const searchParameters = this.searchParams; - let updated; - if (is_dist.string(value)) { - updated = new URLSearchParams(value); - } - else if (value instanceof URLSearchParams) { - updated = value; - } - else { - options_validateSearchParameters(value); - updated = new URLSearchParams(); - // eslint-disable-next-line guard-for-in - for (const key in value) { - const entry = value[key]; - if (entry === null) { - updated.append(key, ''); - } - else if (entry === undefined) { - searchParameters.delete(key); - } - else { - updated.append(key, entry); - } - } - } - if (this._merging) { - // These keys will be replaced - for (const key of updated.keys()) { - searchParameters.delete(key); - } - for (const [key, value] of updated) { - searchParameters.append(key, value); - } - } - else if (url) { - url.search = searchParameters.toString(); - } - else { - this._internals.searchParams = searchParameters; - } - } - get searchParameters() { - throw new Error('The `searchParameters` option does not exist. Use `searchParams` instead.'); - } - set searchParameters(_value) { - throw new Error('The `searchParameters` option does not exist. Use `searchParams` instead.'); - } - get dnsLookup() { - return this._internals.dnsLookup; - } - set dnsLookup(value) { - dist_assert.any([is_dist.function_, is_dist.undefined], value); - this._internals.dnsLookup = value; - } - /** - An instance of [`CacheableLookup`](https://github.com/szmarczak/cacheable-lookup) used for making DNS lookups. - Useful when making lots of requests to different *public* hostnames. - - `CacheableLookup` uses `dns.resolver4(..)` and `dns.resolver6(...)` under the hood and fall backs to `dns.lookup(...)` when the first two fail, which may lead to additional delay. - - __Note__: This should stay disabled when making requests to internal hostnames such as `localhost`, `database.local` etc. - - @default false - */ - get dnsCache() { - return this._internals.dnsCache; - } - set dnsCache(value) { - dist_assert.any([is_dist.object, is_dist.boolean, is_dist.undefined], value); - if (value === true) { - this._internals.dnsCache = options_getGlobalDnsCache(); - } - else if (value === false) { - this._internals.dnsCache = undefined; - } - else { - this._internals.dnsCache = value; - } - } - /** - User data. `context` is shallow merged and enumerable. If it contains non-enumerable properties they will NOT be merged. - - @example - ``` - import got from 'got'; - - const instance = got.extend({ - hooks: { - beforeRequest: [ - options => { - if (!options.context || !options.context.token) { - throw new Error('Token required'); - } - - options.headers.token = options.context.token; - } - ] - } - }); - - const context = { - token: 'secret' - }; - - const response = await instance('https://httpbin.org/headers', {context}); - - // Let's see the headers - console.log(response.body); - ``` - */ - get context() { - return this._internals.context; - } - set context(value) { - dist_assert.object(value); - if (this._merging) { - Object.assign(this._internals.context, value); - } - else { - this._internals.context = { ...value }; - } - } - /** - Hooks allow modifications during the request lifecycle. - Hook functions may be async and are run serially. - */ - get hooks() { - return this._internals.hooks; - } - set hooks(value) { - dist_assert.object(value); - // eslint-disable-next-line guard-for-in - for (const knownHookEvent in value) { - if (!(knownHookEvent in this._internals.hooks)) { - throw new Error(`Unexpected hook event: ${knownHookEvent}`); - } - const typedKnownHookEvent = knownHookEvent; - const hooks = value[typedKnownHookEvent]; - dist_assert.any([is_dist.array, is_dist.undefined], hooks); - if (hooks) { - for (const hook of hooks) { - dist_assert.function_(hook); - } - } - if (this._merging) { - if (hooks) { - // @ts-expect-error FIXME - this._internals.hooks[typedKnownHookEvent].push(...hooks); - } - } - else { - if (!hooks) { - throw new Error(`Missing hook event: ${knownHookEvent}`); - } - // @ts-expect-error FIXME - this._internals.hooks[knownHookEvent] = [...hooks]; - } - } - } - /** - Whether redirect responses should be followed automatically. - - Optionally, pass a function to dynamically decide based on the response object. - - Note that if a `303` is sent by the server in response to any request type (`POST`, `DELETE`, etc.), Got will automatically request the resource pointed to in the location header via `GET`. - This is in accordance with [the spec](https://tools.ietf.org/html/rfc7231#section-6.4.4). You can optionally turn on this behavior also for other redirect codes - see `methodRewriting`. - - @default true - */ - get followRedirect() { - return this._internals.followRedirect; - } - set followRedirect(value) { - dist_assert.any([is_dist.boolean, is_dist.function_], value); - this._internals.followRedirect = value; - } - get followRedirects() { - throw new TypeError('The `followRedirects` option does not exist. Use `followRedirect` instead.'); - } - set followRedirects(_value) { - throw new TypeError('The `followRedirects` option does not exist. Use `followRedirect` instead.'); - } - /** - If exceeded, the request will be aborted and a `MaxRedirectsError` will be thrown. - - @default 10 - */ - get maxRedirects() { - return this._internals.maxRedirects; - } - set maxRedirects(value) { - dist_assert.number(value); - this._internals.maxRedirects = value; - } - /** - A cache adapter instance for storing cached response data. - - @default false - */ - get cache() { - return this._internals.cache; - } - set cache(value) { - dist_assert.any([is_dist.object, is_dist.string, is_dist.boolean, is_dist.undefined], value); - if (value === true) { - this._internals.cache = options_globalCache; - } - else if (value === false) { - this._internals.cache = undefined; - } - else { - this._internals.cache = value; - } - } - /** - Determines if a `got.HTTPError` is thrown for unsuccessful responses. - - If this is disabled, requests that encounter an error status code will be resolved with the `response` instead of throwing. - This may be useful if you are checking for resource availability and are expecting error responses. - - @default true - */ - get throwHttpErrors() { - return this._internals.throwHttpErrors; - } - set throwHttpErrors(value) { - dist_assert.boolean(value); - this._internals.throwHttpErrors = value; - } - get username() { - const url = this._internals.url; - const value = url ? url.username : this._internals.username; - return decodeURIComponent(value); - } - set username(value) { - dist_assert.string(value); - const url = this._internals.url; - const fixedValue = encodeURIComponent(value); - if (url) { - url.username = fixedValue; - } - else { - this._internals.username = fixedValue; - } - } - get password() { - const url = this._internals.url; - const value = url ? url.password : this._internals.password; - return decodeURIComponent(value); - } - set password(value) { - dist_assert.string(value); - const url = this._internals.url; - const fixedValue = encodeURIComponent(value); - if (url) { - url.password = fixedValue; - } - else { - this._internals.password = fixedValue; - } - } - /** - If set to `true`, Got will additionally accept HTTP2 requests. - - It will choose either HTTP/1.1 or HTTP/2 depending on the ALPN protocol. - - __Note__: This option requires Node.js 15.10.0 or newer as HTTP/2 support on older Node.js versions is very buggy. - - __Note__: Overriding `options.request` will disable HTTP2 support. - - @default false - - @example - ``` - import got from 'got'; - - const {headers} = await got('https://nghttp2.org/httpbin/anything', {http2: true}); - - console.log(headers.via); - //=> '2 nghttpx' - ``` - */ - get http2() { - return this._internals.http2; - } - set http2(value) { - dist_assert.boolean(value); - this._internals.http2 = value; - } - /** - Set this to `true` to allow sending body for the `GET` method. - However, the [HTTP/2 specification](https://tools.ietf.org/html/rfc7540#section-8.1.3) says that `An HTTP GET request includes request header fields and no payload body`, therefore when using the HTTP/2 protocol this option will have no effect. - This option is only meant to interact with non-compliant servers when you have no other choice. - - __Note__: The [RFC 7231](https://tools.ietf.org/html/rfc7231#section-4.3.1) doesn't specify any particular behavior for the GET method having a payload, therefore __it's considered an [anti-pattern](https://en.wikipedia.org/wiki/Anti-pattern)__. - - @default false - */ - get allowGetBody() { - return this._internals.allowGetBody; - } - set allowGetBody(value) { - dist_assert.boolean(value); - this._internals.allowGetBody = value; - } - /** - Request headers. - - Existing headers will be overwritten. Headers set to `undefined` will be omitted. - - @default {} - */ - get headers() { - return this._internals.headers; - } - set headers(value) { - dist_assert.plainObject(value); - if (this._merging) { - Object.assign(this._internals.headers, lowercaseKeys(value)); - } - else { - this._internals.headers = lowercaseKeys(value); - } - } - /** - Specifies if the HTTP request method should be [rewritten as `GET`](https://tools.ietf.org/html/rfc7231#section-6.4) on redirects. - - As the [specification](https://tools.ietf.org/html/rfc7231#section-6.4) prefers to rewrite the HTTP method only on `303` responses, this is Got's default behavior. - Setting `methodRewriting` to `true` will also rewrite `301` and `302` responses, as allowed by the spec. This is the behavior followed by `curl` and browsers. - - __Note__: Got never performs method rewriting on `307` and `308` responses, as this is [explicitly prohibited by the specification](https://www.rfc-editor.org/rfc/rfc7231#section-6.4.7). - - @default false - */ - get methodRewriting() { - return this._internals.methodRewriting; - } - set methodRewriting(value) { - dist_assert.boolean(value); - this._internals.methodRewriting = value; - } - /** - Indicates which DNS record family to use. - - Values: - - `undefined`: IPv4 (if present) or IPv6 - - `4`: Only IPv4 - - `6`: Only IPv6 - - @default undefined - */ - get dnsLookupIpVersion() { - return this._internals.dnsLookupIpVersion; - } - set dnsLookupIpVersion(value) { - if (value !== undefined && value !== 4 && value !== 6) { - throw new TypeError(`Invalid DNS lookup IP version: ${value}`); - } - this._internals.dnsLookupIpVersion = value; - } - /** - A function used to parse JSON responses. - - @example - ``` - import got from 'got'; - import Bourne from '@hapi/bourne'; - - const parsed = await got('https://example.com', { - parseJson: text => Bourne.parse(text) - }).json(); - - console.log(parsed); - ``` - */ - get parseJson() { - return this._internals.parseJson; - } - set parseJson(value) { - dist_assert.function_(value); - this._internals.parseJson = value; - } - /** - A function used to stringify the body of JSON requests. - - @example - ``` - import got from 'got'; - - await got.post('https://example.com', { - stringifyJson: object => JSON.stringify(object, (key, value) => { - if (key.startsWith('_')) { - return; - } - - return value; - }), - json: { - some: 'payload', - _ignoreMe: 1234 - } - }); - ``` - - @example - ``` - import got from 'got'; - - await got.post('https://example.com', { - stringifyJson: object => JSON.stringify(object, (key, value) => { - if (typeof value === 'number') { - return value.toString(); - } - - return value; - }), - json: { - some: 'payload', - number: 1 - } - }); - ``` - */ - get stringifyJson() { - return this._internals.stringifyJson; - } - set stringifyJson(value) { - dist_assert.function_(value); - this._internals.stringifyJson = value; - } - /** - An object representing `limit`, `calculateDelay`, `methods`, `statusCodes`, `maxRetryAfter` and `errorCodes` fields for maximum retry count, retry handler, allowed methods, allowed status codes, maximum [`Retry-After`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After) time and allowed error codes. - - Delays between retries counts with function `1000 * Math.pow(2, retry) + Math.random() * 100`, where `retry` is attempt number (starts from 1). - - The `calculateDelay` property is a `function` that receives an object with `attemptCount`, `retryOptions`, `error` and `computedValue` properties for current retry count, the retry options, error and default computed value. - The function must return a delay in milliseconds (or a Promise resolving with it) (`0` return value cancels retry). - - By default, it retries *only* on the specified methods, status codes, and on these network errors: - - - `ETIMEDOUT`: One of the [timeout](#timeout) limits were reached. - - `ECONNRESET`: Connection was forcibly closed by a peer. - - `EADDRINUSE`: Could not bind to any free port. - - `ECONNREFUSED`: Connection was refused by the server. - - `EPIPE`: The remote side of the stream being written has been closed. - - `ENOTFOUND`: Couldn't resolve the hostname to an IP address. - - `ENETUNREACH`: No internet connection. - - `EAI_AGAIN`: DNS lookup timed out. - - __Note__: If `maxRetryAfter` is set to `undefined`, it will use `options.timeout`. - __Note__: If [`Retry-After`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After) header is greater than `maxRetryAfter`, it will cancel the request. - */ - get retry() { - return this._internals.retry; - } - set retry(value) { - dist_assert.plainObject(value); - dist_assert.any([is_dist.function_, is_dist.undefined], value.calculateDelay); - dist_assert.any([is_dist.number, is_dist.undefined], value.maxRetryAfter); - dist_assert.any([is_dist.number, is_dist.undefined], value.limit); - dist_assert.any([is_dist.array, is_dist.undefined], value.methods); - dist_assert.any([is_dist.array, is_dist.undefined], value.statusCodes); - dist_assert.any([is_dist.array, is_dist.undefined], value.errorCodes); - dist_assert.any([is_dist.number, is_dist.undefined], value.noise); - if (value.noise && Math.abs(value.noise) > 100) { - throw new Error(`The maximum acceptable retry noise is +/- 100ms, got ${value.noise}`); - } - for (const key in value) { - if (!(key in this._internals.retry)) { - throw new Error(`Unexpected retry option: ${key}`); - } - } - if (this._merging) { - Object.assign(this._internals.retry, value); - } - else { - this._internals.retry = { ...value }; - } - const { retry } = this._internals; - retry.methods = [...new Set(retry.methods.map(method => method.toUpperCase()))]; - retry.statusCodes = [...new Set(retry.statusCodes)]; - retry.errorCodes = [...new Set(retry.errorCodes)]; - } - /** - From `http.RequestOptions`. - - The IP address used to send the request from. - */ - get localAddress() { - return this._internals.localAddress; - } - set localAddress(value) { - dist_assert.any([is_dist.string, is_dist.undefined], value); - this._internals.localAddress = value; - } - /** - The HTTP method used to make the request. - - @default 'GET' - */ - get method() { - return this._internals.method; - } - set method(value) { - dist_assert.string(value); - this._internals.method = value.toUpperCase(); - } - get createConnection() { - return this._internals.createConnection; - } - set createConnection(value) { - dist_assert.any([is_dist.function_, is_dist.undefined], value); - this._internals.createConnection = value; - } - /** - From `http-cache-semantics` - - @default {} - */ - get cacheOptions() { - return this._internals.cacheOptions; - } - set cacheOptions(value) { - dist_assert.plainObject(value); - dist_assert.any([is_dist.boolean, is_dist.undefined], value.shared); - dist_assert.any([is_dist.number, is_dist.undefined], value.cacheHeuristic); - dist_assert.any([is_dist.number, is_dist.undefined], value.immutableMinTimeToLive); - dist_assert.any([is_dist.boolean, is_dist.undefined], value.ignoreCargoCult); - for (const key in value) { - if (!(key in this._internals.cacheOptions)) { - throw new Error(`Cache option \`${key}\` does not exist`); - } - } - if (this._merging) { - Object.assign(this._internals.cacheOptions, value); - } - else { - this._internals.cacheOptions = { ...value }; - } - } - /** - Options for the advanced HTTPS API. - */ - get https() { - return this._internals.https; - } - set https(value) { - dist_assert.plainObject(value); - dist_assert.any([is_dist.boolean, is_dist.undefined], value.rejectUnauthorized); - dist_assert.any([is_dist.function_, is_dist.undefined], value.checkServerIdentity); - dist_assert.any([is_dist.string, is_dist.object, is_dist.array, is_dist.undefined], value.certificateAuthority); - dist_assert.any([is_dist.string, is_dist.object, is_dist.array, is_dist.undefined], value.key); - dist_assert.any([is_dist.string, is_dist.object, is_dist.array, is_dist.undefined], value.certificate); - dist_assert.any([is_dist.string, is_dist.undefined], value.passphrase); - dist_assert.any([is_dist.string, is_dist.buffer, is_dist.array, is_dist.undefined], value.pfx); - dist_assert.any([is_dist.array, is_dist.undefined], value.alpnProtocols); - dist_assert.any([is_dist.string, is_dist.undefined], value.ciphers); - dist_assert.any([is_dist.string, is_dist.buffer, is_dist.undefined], value.dhparam); - dist_assert.any([is_dist.string, is_dist.undefined], value.signatureAlgorithms); - dist_assert.any([is_dist.string, is_dist.undefined], value.minVersion); - dist_assert.any([is_dist.string, is_dist.undefined], value.maxVersion); - dist_assert.any([is_dist.boolean, is_dist.undefined], value.honorCipherOrder); - dist_assert.any([is_dist.number, is_dist.undefined], value.tlsSessionLifetime); - dist_assert.any([is_dist.string, is_dist.undefined], value.ecdhCurve); - dist_assert.any([is_dist.string, is_dist.buffer, is_dist.array, is_dist.undefined], value.certificateRevocationLists); - for (const key in value) { - if (!(key in this._internals.https)) { - throw new Error(`HTTPS option \`${key}\` does not exist`); - } - } - if (this._merging) { - Object.assign(this._internals.https, value); - } - else { - this._internals.https = { ...value }; - } - } - /** - [Encoding](https://nodejs.org/api/buffer.html#buffer_buffers_and_character_encodings) to be used on `setEncoding` of the response data. - - To get a [`Buffer`](https://nodejs.org/api/buffer.html), you need to set `responseType` to `buffer` instead. - Don't set this option to `null`. - - __Note__: This doesn't affect streams! Instead, you need to do `got.stream(...).setEncoding(encoding)`. - - @default 'utf-8' - */ - get encoding() { - return this._internals.encoding; - } - set encoding(value) { - if (value === null) { - throw new TypeError('To get a Buffer, set `options.responseType` to `buffer` instead'); - } - dist_assert.any([is_dist.string, is_dist.undefined], value); - this._internals.encoding = value; - } - /** - When set to `true` the promise will return the Response body instead of the Response object. - - @default false - */ - get resolveBodyOnly() { - return this._internals.resolveBodyOnly; - } - set resolveBodyOnly(value) { - dist_assert.boolean(value); - this._internals.resolveBodyOnly = value; - } - /** - Returns a `Stream` instead of a `Promise`. - This is equivalent to calling `got.stream(url, options?)`. - - @default false - */ - get isStream() { - return this._internals.isStream; - } - set isStream(value) { - dist_assert.boolean(value); - this._internals.isStream = value; - } - /** - The parsing method. - - The promise also has `.text()`, `.json()` and `.buffer()` methods which return another Got promise for the parsed body. - - It's like setting the options to `{responseType: 'json', resolveBodyOnly: true}` but without affecting the main Got promise. - - __Note__: When using streams, this option is ignored. - - @example - ``` - const responsePromise = got(url); - const bufferPromise = responsePromise.buffer(); - const jsonPromise = responsePromise.json(); - - const [response, buffer, json] = Promise.all([responsePromise, bufferPromise, jsonPromise]); - // `response` is an instance of Got Response - // `buffer` is an instance of Buffer - // `json` is an object - ``` - - @example - ``` - // This - const body = await got(url).json(); - - // is semantically the same as this - const body = await got(url, {responseType: 'json', resolveBodyOnly: true}); - ``` - */ - get responseType() { - return this._internals.responseType; - } - set responseType(value) { - if (value === undefined) { - this._internals.responseType = 'text'; - return; - } - if (value !== 'text' && value !== 'buffer' && value !== 'json') { - throw new Error(`Invalid \`responseType\` option: ${value}`); - } - this._internals.responseType = value; - } - get pagination() { - return this._internals.pagination; - } - set pagination(value) { - dist_assert.object(value); - if (this._merging) { - Object.assign(this._internals.pagination, value); - } - else { - this._internals.pagination = value; - } - } - get auth() { - throw new Error('Parameter `auth` is deprecated. Use `username` / `password` instead.'); - } - set auth(_value) { - throw new Error('Parameter `auth` is deprecated. Use `username` / `password` instead.'); - } - get setHost() { - return this._internals.setHost; - } - set setHost(value) { - dist_assert.boolean(value); - this._internals.setHost = value; - } - get maxHeaderSize() { - return this._internals.maxHeaderSize; - } - set maxHeaderSize(value) { - dist_assert.any([is_dist.number, is_dist.undefined], value); - this._internals.maxHeaderSize = value; - } - get enableUnixSockets() { - return this._internals.enableUnixSockets; - } - set enableUnixSockets(value) { - dist_assert.boolean(value); - this._internals.enableUnixSockets = value; - } - // eslint-disable-next-line @typescript-eslint/naming-convention - toJSON() { - return { ...this._internals }; - } - [Symbol.for('nodejs.util.inspect.custom')](_depth, options) { - return (0,external_node_util_.inspect)(this._internals, options); - } - createNativeRequestOptions() { - const internals = this._internals; - const url = internals.url; - let agent; - if (url.protocol === 'https:') { - agent = internals.http2 ? internals.agent : internals.agent.https; - } - else { - agent = internals.agent.http; - } - const { https } = internals; - let { pfx } = https; - if (is_dist.array(pfx) && is_dist.plainObject(pfx[0])) { - pfx = pfx.map(object => ({ - buf: object.buffer, - passphrase: object.passphrase, - })); - } - return { - ...internals.cacheOptions, - ...this._unixOptions, - // HTTPS options - // eslint-disable-next-line @typescript-eslint/naming-convention - ALPNProtocols: https.alpnProtocols, - ca: https.certificateAuthority, - cert: https.certificate, - key: https.key, - passphrase: https.passphrase, - pfx: https.pfx, - rejectUnauthorized: https.rejectUnauthorized, - checkServerIdentity: https.checkServerIdentity ?? external_node_tls_namespaceObject.checkServerIdentity, - ciphers: https.ciphers, - honorCipherOrder: https.honorCipherOrder, - minVersion: https.minVersion, - maxVersion: https.maxVersion, - sigalgs: https.signatureAlgorithms, - sessionTimeout: https.tlsSessionLifetime, - dhparam: https.dhparam, - ecdhCurve: https.ecdhCurve, - crl: https.certificateRevocationLists, - // HTTP options - lookup: internals.dnsLookup ?? internals.dnsCache?.lookup, - family: internals.dnsLookupIpVersion, - agent, - setHost: internals.setHost, - method: internals.method, - maxHeaderSize: internals.maxHeaderSize, - localAddress: internals.localAddress, - headers: internals.headers, - createConnection: internals.createConnection, - timeout: internals.http2 ? options_getHttp2TimeoutOption(internals) : undefined, - // HTTP/2 options - h2session: internals.h2session, - }; - } - getRequestFunction() { - const url = this._internals.url; - const { request } = this._internals; - if (!request && url) { - return this.getFallbackRequestFunction(); - } - return request; - } - getFallbackRequestFunction() { - const url = this._internals.url; - if (!url) { - return; - } - if (url.protocol === 'https:') { - if (this._internals.http2) { - if (options_major < 15 || (options_major === 15 && options_minor < 10)) { - const error = new Error('To use the `http2` option, install Node.js 15.10.0 or above'); - error.code = 'EUNSUPPORTED'; - throw error; - } - return http2_wrapper_source.auto; - } - return external_node_https_namespaceObject.request; - } - return external_node_http_namespaceObject.request; - } - freeze() { - const options = this._internals; - Object.freeze(options); - Object.freeze(options.hooks); - Object.freeze(options.hooks.afterResponse); - Object.freeze(options.hooks.beforeError); - Object.freeze(options.hooks.beforeRedirect); - Object.freeze(options.hooks.beforeRequest); - Object.freeze(options.hooks.beforeRetry); - Object.freeze(options.hooks.init); - Object.freeze(options.https); - Object.freeze(options.cacheOptions); - Object.freeze(options.agent); - Object.freeze(options.headers); - Object.freeze(options.timeout); - Object.freeze(options.retry); - Object.freeze(options.retry.errorCodes); - Object.freeze(options.retry.methods); - Object.freeze(options.retry.statusCodes); - } -} - -;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.3.0/node_modules/got/dist/source/core/response.js - -const response_isResponseOk = (response) => { - const { statusCode } = response; - const { followRedirect } = response.request.options; - const shouldFollow = typeof followRedirect === 'function' ? followRedirect(response) : followRedirect; - const limitStatusCode = shouldFollow ? 299 : 399; - return (statusCode >= 200 && statusCode <= limitStatusCode) || statusCode === 304; -}; -/** -An error to be thrown when server response code is 2xx, and parsing body fails. -Includes a `response` property. -*/ -class response_ParseError extends errors_RequestError { - constructor(error, response) { - const { options } = response.request; - super(`${error.message} in "${options.url.toString()}"`, error, response.request); - this.name = 'ParseError'; - this.code = 'ERR_BODY_PARSE_FAILURE'; - } -} -const response_parseBody = (response, responseType, parseJson, encoding) => { - const { rawBody } = response; - try { - if (responseType === 'text') { - return rawBody.toString(encoding); - } - if (responseType === 'json') { - return rawBody.length === 0 ? '' : parseJson(rawBody.toString(encoding)); - } - if (responseType === 'buffer') { - return rawBody; - } - } - catch (error) { - throw new response_ParseError(error, response); - } - throw new response_ParseError({ - message: `Unknown body type '${responseType}'`, - name: 'Error', - }, response); -}; - -;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.3.0/node_modules/got/dist/source/core/utils/is-client-request.js -function is_client_request_isClientRequest(clientRequest) { - return clientRequest.writable && !clientRequest.writableEnded; -} -/* harmony default export */ const utils_is_client_request = (is_client_request_isClientRequest); - -;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.3.0/node_modules/got/dist/source/core/utils/is-unix-socket-url.js -// eslint-disable-next-line @typescript-eslint/naming-convention -function is_unix_socket_url_isUnixSocketURL(url) { - return url.protocol === 'unix:' || url.hostname === 'unix'; -} - -;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.3.0/node_modules/got/dist/source/core/index.js - - - - - - - - - - - - - - - - - - - - - - -const core_supportsBrotli = is_dist.string(external_node_process_.versions.brotli); -const core_methodsWithoutBody = new Set(['GET', 'HEAD']); -const core_cacheableStore = new weakable_map_WeakableMap(); -const core_redirectCodes = new Set([300, 301, 302, 303, 304, 307, 308]); -const core_proxiedRequestEvents = [ - 'socket', - 'connect', - 'continue', - 'information', - 'upgrade', -]; -const source_core_noop = () => { }; -class core_Request extends external_node_stream_.Duplex { - // @ts-expect-error - Ignoring for now. - ['constructor']; - _noPipe; - // @ts-expect-error https://github.com/microsoft/TypeScript/issues/9568 - options; - response; - requestUrl; - redirectUrls; - retryCount; - _stopRetry; - _downloadedSize; - _uploadedSize; - _stopReading; - _pipedServerResponses; - _request; - _responseSize; - _bodySize; - _unproxyEvents; - _isFromCache; - _cannotHaveBody; - _triggerRead; - _cancelTimeouts; - _removeListeners; - _nativeResponse; - _flushed; - _aborted; - // We need this because `this._request` if `undefined` when using cache - _requestInitialized; - constructor(url, options, defaults) { - super({ - // Don't destroy immediately, as the error may be emitted on unsuccessful retry - autoDestroy: false, - // It needs to be zero because we're just proxying the data to another stream - highWaterMark: 0, - }); - this._downloadedSize = 0; - this._uploadedSize = 0; - this._stopReading = false; - this._pipedServerResponses = new Set(); - this._cannotHaveBody = false; - this._unproxyEvents = source_core_noop; - this._triggerRead = false; - this._cancelTimeouts = source_core_noop; - this._removeListeners = source_core_noop; - this._jobs = []; - this._flushed = false; - this._requestInitialized = false; - this._aborted = false; - this.redirectUrls = []; - this.retryCount = 0; - this._stopRetry = source_core_noop; - this.on('pipe', (source) => { - if (source?.headers) { - Object.assign(this.options.headers, source.headers); - } - }); - this.on('newListener', event => { - if (event === 'retry' && this.listenerCount('retry') > 0) { - throw new Error('A retry listener has been attached already.'); - } - }); - try { - this.options = new options_Options(url, options, defaults); - if (!this.options.url) { - if (this.options.prefixUrl === '') { - throw new TypeError('Missing `url` property'); - } - this.options.url = ''; - } - this.requestUrl = this.options.url; - } - catch (error) { - const { options } = error; - if (options) { - this.options = options; - } - this.flush = async () => { - this.flush = async () => { }; - this.destroy(error); - }; - return; - } - // Important! If you replace `body` in a handler with another stream, make sure it's readable first. - // The below is run only once. - const { body } = this.options; - if (is_dist.nodeStream(body)) { - body.once('error', error => { - if (this._flushed) { - this._beforeError(new errors_UploadError(error, this)); - } - else { - this.flush = async () => { - this.flush = async () => { }; - this._beforeError(new errors_UploadError(error, this)); - }; - } - }); - } - if (this.options.signal) { - const abort = () => { - this.destroy(new errors_AbortError(this)); - }; - if (this.options.signal.aborted) { - abort(); - } - else { - this.options.signal.addEventListener('abort', abort); - this._removeListeners = () => { - this.options.signal?.removeEventListener('abort', abort); - }; - } - } - } - async flush() { - if (this._flushed) { - return; - } - this._flushed = true; - try { - await this._finalizeBody(); - if (this.destroyed) { - return; - } - await this._makeRequest(); - if (this.destroyed) { - this._request?.destroy(); - return; - } - // Queued writes etc. - for (const job of this._jobs) { - job(); - } - // Prevent memory leak - this._jobs.length = 0; - this._requestInitialized = true; - } - catch (error) { - this._beforeError(error); - } - } - _beforeError(error) { - if (this._stopReading) { - return; - } - const { response, options } = this; - const attemptCount = this.retryCount + (error.name === 'RetryError' ? 0 : 1); - this._stopReading = true; - if (!(error instanceof errors_RequestError)) { - error = new errors_RequestError(error.message, error, this); - } - const typedError = error; - void (async () => { - // Node.js parser is really weird. - // It emits post-request Parse Errors on the same instance as previous request. WTF. - // Therefore, we need to check if it has been destroyed as well. - // - // Furthermore, Node.js 16 `response.destroy()` doesn't immediately destroy the socket, - // but makes the response unreadable. So we additionally need to check `response.readable`. - if (response?.readable && !response.rawBody && !this._request?.socket?.destroyed) { - // @types/node has incorrect typings. `setEncoding` accepts `null` as well. - response.setEncoding(this.readableEncoding); - const success = await this._setRawBody(response); - if (success) { - response.body = response.rawBody.toString(); - } - } - if (this.listenerCount('retry') !== 0) { - let backoff; - try { - let retryAfter; - if (response && 'retry-after' in response.headers) { - retryAfter = Number(response.headers['retry-after']); - if (Number.isNaN(retryAfter)) { - retryAfter = Date.parse(response.headers['retry-after']) - Date.now(); - if (retryAfter <= 0) { - retryAfter = 1; - } - } - else { - retryAfter *= 1000; - } - } - const retryOptions = options.retry; - backoff = await retryOptions.calculateDelay({ - attemptCount, - retryOptions, - error: typedError, - retryAfter, - computedValue: core_calculate_retry_delay({ - attemptCount, - retryOptions, - error: typedError, - retryAfter, - computedValue: retryOptions.maxRetryAfter ?? options.timeout.request ?? Number.POSITIVE_INFINITY, - }), - }); - } - catch (error_) { - void this._error(new errors_RequestError(error_.message, error_, this)); - return; - } - if (backoff) { - await new Promise(resolve => { - const timeout = setTimeout(resolve, backoff); - this._stopRetry = () => { - clearTimeout(timeout); - resolve(); - }; - }); - // Something forced us to abort the retry - if (this.destroyed) { - return; - } - try { - for (const hook of this.options.hooks.beforeRetry) { - // eslint-disable-next-line no-await-in-loop - await hook(typedError, this.retryCount + 1); - } - } - catch (error_) { - void this._error(new errors_RequestError(error_.message, error, this)); - return; - } - // Something forced us to abort the retry - if (this.destroyed) { - return; - } - this.destroy(); - this.emit('retry', this.retryCount + 1, error, (updatedOptions) => { - const request = new core_Request(options.url, updatedOptions, options); - request.retryCount = this.retryCount + 1; - external_node_process_.nextTick(() => { - void request.flush(); - }); - return request; - }); - return; - } - } - void this._error(typedError); - })(); - } - _read() { - this._triggerRead = true; - const { response } = this; - if (response && !this._stopReading) { - // We cannot put this in the `if` above - // because `.read()` also triggers the `end` event - if (response.readableLength) { - this._triggerRead = false; - } - let data; - while ((data = response.read()) !== null) { - this._downloadedSize += data.length; // eslint-disable-line @typescript-eslint/restrict-plus-operands - const progress = this.downloadProgress; - if (progress.percent < 1) { - this.emit('downloadProgress', progress); - } - this.push(data); - } - } - } - _write(chunk, encoding, callback) { - const write = () => { - this._writeRequest(chunk, encoding, callback); - }; - if (this._requestInitialized) { - write(); - } - else { - this._jobs.push(write); - } - } - _final(callback) { - const endRequest = () => { - // We need to check if `this._request` is present, - // because it isn't when we use cache. - if (!this._request || this._request.destroyed) { - callback(); - return; - } - this._request.end((error) => { - // The request has been destroyed before `_final` finished. - // See https://github.com/nodejs/node/issues/39356 - if (this._request._writableState?.errored) { - return; - } - if (!error) { - this._bodySize = this._uploadedSize; - this.emit('uploadProgress', this.uploadProgress); - this._request.emit('upload-complete'); - } - callback(error); - }); - }; - if (this._requestInitialized) { - endRequest(); - } - else { - this._jobs.push(endRequest); - } - } - _destroy(error, callback) { - this._stopReading = true; - this.flush = async () => { }; - // Prevent further retries - this._stopRetry(); - this._cancelTimeouts(); - this._removeListeners(); - if (this.options) { - const { body } = this.options; - if (is_dist.nodeStream(body)) { - body.destroy(); - } - } - if (this._request) { - this._request.destroy(); - } - if (error !== null && !is_dist.undefined(error) && !(error instanceof errors_RequestError)) { - error = new errors_RequestError(error.message, error, this); - } - callback(error); - } - pipe(destination, options) { - if (destination instanceof external_node_http_namespaceObject.ServerResponse) { - this._pipedServerResponses.add(destination); - } - return super.pipe(destination, options); - } - unpipe(destination) { - if (destination instanceof external_node_http_namespaceObject.ServerResponse) { - this._pipedServerResponses.delete(destination); - } - super.unpipe(destination); - return this; - } - async _finalizeBody() { - const { options } = this; - const { headers } = options; - const isForm = !is_dist.undefined(options.form); - // eslint-disable-next-line @typescript-eslint/naming-convention - const isJSON = !is_dist.undefined(options.json); - const isBody = !is_dist.undefined(options.body); - const cannotHaveBody = core_methodsWithoutBody.has(options.method) && !(options.method === 'GET' && options.allowGetBody); - this._cannotHaveBody = cannotHaveBody; - if (isForm || isJSON || isBody) { - if (cannotHaveBody) { - throw new TypeError(`The \`${options.method}\` method cannot be used with a body`); - } - // Serialize body - const noContentType = !is_dist.string(headers['content-type']); - if (isBody) { - // Body is spec-compliant FormData - if (lib_isFormData(options.body)) { - const encoder = new FormDataEncoder(options.body); - if (noContentType) { - headers['content-type'] = encoder.headers['Content-Type']; - } - if ('Content-Length' in encoder.headers) { - headers['content-length'] = encoder.headers['Content-Length']; - } - options.body = encoder.encode(); - } - // Special case for https://github.com/form-data/form-data - if (utils_is_form_data_isFormData(options.body) && noContentType) { - headers['content-type'] = `multipart/form-data; boundary=${options.body.getBoundary()}`; - } - } - else if (isForm) { - if (noContentType) { - headers['content-type'] = 'application/x-www-form-urlencoded'; - } - const { form } = options; - options.form = undefined; - options.body = (new URLSearchParams(form)).toString(); - } - else { - if (noContentType) { - headers['content-type'] = 'application/json'; - } - const { json } = options; - options.json = undefined; - options.body = options.stringifyJson(json); - } - const uploadBodySize = await get_body_size_getBodySize(options.body, options.headers); - // See https://tools.ietf.org/html/rfc7230#section-3.3.2 - // A user agent SHOULD send a Content-Length in a request message when - // no Transfer-Encoding is sent and the request method defines a meaning - // for an enclosed payload body. For example, a Content-Length header - // field is normally sent in a POST request even when the value is 0 - // (indicating an empty payload body). A user agent SHOULD NOT send a - // Content-Length header field when the request message does not contain - // a payload body and the method semantics do not anticipate such a - // body. - if (is_dist.undefined(headers['content-length']) && is_dist.undefined(headers['transfer-encoding']) && !cannotHaveBody && !is_dist.undefined(uploadBodySize)) { - headers['content-length'] = String(uploadBodySize); - } - } - if (options.responseType === 'json' && !('accept' in options.headers)) { - options.headers.accept = 'application/json'; - } - this._bodySize = Number(headers['content-length']) || undefined; - } - async _onResponseBase(response) { - // This will be called e.g. when using cache so we need to check if this request has been aborted. - if (this.isAborted) { - return; - } - const { options } = this; - const { url } = options; - this._nativeResponse = response; - if (options.decompress) { - response = decompress_response(response); - } - const statusCode = response.statusCode; - const typedResponse = response; - typedResponse.statusMessage = typedResponse.statusMessage ?? external_node_http_namespaceObject.STATUS_CODES[statusCode]; - typedResponse.url = options.url.toString(); - typedResponse.requestUrl = this.requestUrl; - typedResponse.redirectUrls = this.redirectUrls; - typedResponse.request = this; - typedResponse.isFromCache = this._nativeResponse.fromCache ?? false; - typedResponse.ip = this.ip; - typedResponse.retryCount = this.retryCount; - typedResponse.ok = response_isResponseOk(typedResponse); - this._isFromCache = typedResponse.isFromCache; - this._responseSize = Number(response.headers['content-length']) || undefined; - this.response = typedResponse; - response.once('end', () => { - this._responseSize = this._downloadedSize; - this.emit('downloadProgress', this.downloadProgress); - }); - response.once('error', (error) => { - this._aborted = true; - // Force clean-up, because some packages don't do this. - // TODO: Fix decompress-response - response.destroy(); - this._beforeError(new errors_ReadError(error, this)); - }); - response.once('aborted', () => { - this._aborted = true; - this._beforeError(new errors_ReadError({ - name: 'Error', - message: 'The server aborted pending request', - code: 'ECONNRESET', - }, this)); - }); - this.emit('downloadProgress', this.downloadProgress); - const rawCookies = response.headers['set-cookie']; - if (is_dist.object(options.cookieJar) && rawCookies) { - let promises = rawCookies.map(async (rawCookie) => options.cookieJar.setCookie(rawCookie, url.toString())); - if (options.ignoreInvalidCookies) { - // eslint-disable-next-line @typescript-eslint/no-floating-promises - promises = promises.map(async (promise) => { - try { - await promise; - } - catch { } - }); - } - try { - await Promise.all(promises); - } - catch (error) { - this._beforeError(error); - return; - } - } - // The above is running a promise, therefore we need to check if this request has been aborted yet again. - if (this.isAborted) { - return; - } - if (response.headers.location && core_redirectCodes.has(statusCode)) { - // We're being redirected, we don't care about the response. - // It'd be best to abort the request, but we can't because - // we would have to sacrifice the TCP connection. We don't want that. - const shouldFollow = typeof options.followRedirect === 'function' ? options.followRedirect(typedResponse) : options.followRedirect; - if (shouldFollow) { - response.resume(); - this._cancelTimeouts(); - this._unproxyEvents(); - if (this.redirectUrls.length >= options.maxRedirects) { - this._beforeError(new errors_MaxRedirectsError(this)); - return; - } - this._request = undefined; - const updatedOptions = new options_Options(undefined, undefined, this.options); - const serverRequestedGet = statusCode === 303 && updatedOptions.method !== 'GET' && updatedOptions.method !== 'HEAD'; - const canRewrite = statusCode !== 307 && statusCode !== 308; - const userRequestedGet = updatedOptions.methodRewriting && canRewrite; - if (serverRequestedGet || userRequestedGet) { - updatedOptions.method = 'GET'; - updatedOptions.body = undefined; - updatedOptions.json = undefined; - updatedOptions.form = undefined; - delete updatedOptions.headers['content-length']; - } - try { - // We need this in order to support UTF-8 - const redirectBuffer = external_node_buffer_namespaceObject.Buffer.from(response.headers.location, 'binary').toString(); - const redirectUrl = new URL(redirectBuffer, url); - if (!is_unix_socket_url_isUnixSocketURL(url) && is_unix_socket_url_isUnixSocketURL(redirectUrl)) { - this._beforeError(new errors_RequestError('Cannot redirect to UNIX socket', {}, this)); - return; - } - // Redirecting to a different site, clear sensitive data. - if (redirectUrl.hostname !== url.hostname || redirectUrl.port !== url.port) { - if ('host' in updatedOptions.headers) { - delete updatedOptions.headers.host; - } - if ('cookie' in updatedOptions.headers) { - delete updatedOptions.headers.cookie; - } - if ('authorization' in updatedOptions.headers) { - delete updatedOptions.headers.authorization; - } - if (updatedOptions.username || updatedOptions.password) { - updatedOptions.username = ''; - updatedOptions.password = ''; - } - } - else { - redirectUrl.username = updatedOptions.username; - redirectUrl.password = updatedOptions.password; - } - this.redirectUrls.push(redirectUrl); - updatedOptions.prefixUrl = ''; - updatedOptions.url = redirectUrl; - for (const hook of updatedOptions.hooks.beforeRedirect) { - // eslint-disable-next-line no-await-in-loop - await hook(updatedOptions, typedResponse); - } - this.emit('redirect', updatedOptions, typedResponse); - this.options = updatedOptions; - await this._makeRequest(); - } - catch (error) { - this._beforeError(error); - return; - } - return; - } - } - // `HTTPError`s always have `error.response.body` defined. - // Therefore, we cannot retry if `options.throwHttpErrors` is false. - // On the last retry, if `options.throwHttpErrors` is false, we would need to return the body, - // but that wouldn't be possible since the body would be already read in `error.response.body`. - if (options.isStream && options.throwHttpErrors && !response_isResponseOk(typedResponse)) { - this._beforeError(new errors_HTTPError(typedResponse)); - return; - } - response.on('readable', () => { - if (this._triggerRead) { - this._read(); - } - }); - this.on('resume', () => { - response.resume(); - }); - this.on('pause', () => { - response.pause(); - }); - response.once('end', () => { - this.push(null); - }); - if (this._noPipe) { - const success = await this._setRawBody(); - if (success) { - this.emit('response', response); - } - return; - } - this.emit('response', response); - for (const destination of this._pipedServerResponses) { - if (destination.headersSent) { - continue; - } - // eslint-disable-next-line guard-for-in - for (const key in response.headers) { - const isAllowed = options.decompress ? key !== 'content-encoding' : true; - const value = response.headers[key]; - if (isAllowed) { - destination.setHeader(key, value); - } - } - destination.statusCode = statusCode; - } - } - async _setRawBody(from = this) { - if (from.readableEnded) { - return false; - } - try { - // Errors are emitted via the `error` event - const rawBody = await buffer_getStreamAsBuffer(from); - // TODO: Switch to this: - // let rawBody = await from.toArray(); - // rawBody = Buffer.concat(rawBody); - // On retry Request is destroyed with no error, therefore the above will successfully resolve. - // So in order to check if this was really successfull, we need to check if it has been properly ended. - if (!this.isAborted) { - this.response.rawBody = rawBody; - return true; - } - } - catch { } - return false; - } - async _onResponse(response) { - try { - await this._onResponseBase(response); - } - catch (error) { - /* istanbul ignore next: better safe than sorry */ - this._beforeError(error); - } - } - _onRequest(request) { - const { options } = this; - const { timeout, url } = options; - dist_source(request); - if (this.options.http2) { - // Unset stream timeout, as the `timeout` option was used only for connection timeout. - request.setTimeout(0); - } - this._cancelTimeouts = timed_out_timedOut(request, timeout, url); - const responseEventName = options.cache ? 'cacheableResponse' : 'response'; - request.once(responseEventName, (response) => { - void this._onResponse(response); - }); - request.once('error', (error) => { - this._aborted = true; - // Force clean-up, because some packages (e.g. nock) don't do this. - request.destroy(); - error = error instanceof core_timed_out_TimeoutError ? new errors_TimeoutError(error, this.timings, this) : new errors_RequestError(error.message, error, this); - this._beforeError(error); - }); - this._unproxyEvents = proxy_events_proxyEvents(request, this, core_proxiedRequestEvents); - this._request = request; - this.emit('uploadProgress', this.uploadProgress); - this._sendBody(); - this.emit('request', request); - } - async _asyncWrite(chunk) { - return new Promise((resolve, reject) => { - super.write(chunk, error => { - if (error) { - reject(error); - return; - } - resolve(); - }); - }); - } - _sendBody() { - // Send body - const { body } = this.options; - const currentRequest = this.redirectUrls.length === 0 ? this : this._request ?? this; - if (is_dist.nodeStream(body)) { - body.pipe(currentRequest); - } - else if (is_dist.generator(body) || is_dist.asyncGenerator(body)) { - (async () => { - try { - for await (const chunk of body) { - await this._asyncWrite(chunk); - } - super.end(); - } - catch (error) { - this._beforeError(error); - } - })(); - } - else if (!is_dist.undefined(body)) { - this._writeRequest(body, undefined, () => { }); - currentRequest.end(); - } - else if (this._cannotHaveBody || this._noPipe) { - currentRequest.end(); - } - } - _prepareCache(cache) { - if (!core_cacheableStore.has(cache)) { - const cacheableRequest = new dist(((requestOptions, handler) => { - const result = requestOptions._request(requestOptions, handler); - // TODO: remove this when `cacheable-request` supports async request functions. - if (is_dist.promise(result)) { - // We only need to implement the error handler in order to support HTTP2 caching. - // The result will be a promise anyway. - // @ts-expect-error ignore - result.once = (event, handler) => { - if (event === 'error') { - (async () => { - try { - await result; - } - catch (error) { - handler(error); - } - })(); - } - else if (event === 'abort') { - // The empty catch is needed here in case when - // it rejects before it's `await`ed in `_makeRequest`. - (async () => { - try { - const request = (await result); - request.once('abort', handler); - } - catch { } - })(); - } - else { - /* istanbul ignore next: safety check */ - throw new Error(`Unknown HTTP2 promise event: ${event}`); - } - return result; - }; - } - return result; - }), cache); - core_cacheableStore.set(cache, cacheableRequest.request()); - } - } - async _createCacheableRequest(url, options) { - return new Promise((resolve, reject) => { - // TODO: Remove `utils/url-to-options.ts` when `cacheable-request` is fixed - Object.assign(options, url_to_options_urlToOptions(url)); - let request; - // TODO: Fix `cacheable-response`. This is ugly. - const cacheRequest = core_cacheableStore.get(options.cache)(options, async (response) => { - response._readableState.autoDestroy = false; - if (request) { - const fix = () => { - if (response.req) { - response.complete = response.req.res.complete; - } - }; - response.prependOnceListener('end', fix); - fix(); - (await request).emit('cacheableResponse', response); - } - resolve(response); - }); - cacheRequest.once('error', reject); - cacheRequest.once('request', async (requestOrPromise) => { - request = requestOrPromise; - resolve(request); - }); - }); - } - async _makeRequest() { - const { options } = this; - const { headers, username, password } = options; - const cookieJar = options.cookieJar; - for (const key in headers) { - if (is_dist.undefined(headers[key])) { - // eslint-disable-next-line @typescript-eslint/no-dynamic-delete - delete headers[key]; - } - else if (is_dist.null_(headers[key])) { - throw new TypeError(`Use \`undefined\` instead of \`null\` to delete the \`${key}\` header`); - } - } - if (options.decompress && is_dist.undefined(headers['accept-encoding'])) { - headers['accept-encoding'] = core_supportsBrotli ? 'gzip, deflate, br' : 'gzip, deflate'; - } - if (username || password) { - const credentials = external_node_buffer_namespaceObject.Buffer.from(`${username}:${password}`).toString('base64'); - headers.authorization = `Basic ${credentials}`; - } - // Set cookies - if (cookieJar) { - const cookieString = await cookieJar.getCookieString(options.url.toString()); - if (is_dist.nonEmptyString(cookieString)) { - headers.cookie = cookieString; - } - } - // Reset `prefixUrl` - options.prefixUrl = ''; - let request; - for (const hook of options.hooks.beforeRequest) { - // eslint-disable-next-line no-await-in-loop - const result = await hook(options); - if (!is_dist.undefined(result)) { - // @ts-expect-error Skip the type mismatch to support abstract responses - request = () => result; - break; - } - } - request ||= options.getRequestFunction(); - const url = options.url; - this._requestOptions = options.createNativeRequestOptions(); - if (options.cache) { - this._requestOptions._request = request; - this._requestOptions.cache = options.cache; - this._requestOptions.body = options.body; - this._prepareCache(options.cache); - } - // Cache support - const function_ = options.cache ? this._createCacheableRequest : request; - try { - // We can't do `await fn(...)`, - // because stream `error` event can be emitted before `Promise.resolve()`. - let requestOrResponse = function_(url, this._requestOptions); - if (is_dist.promise(requestOrResponse)) { - requestOrResponse = await requestOrResponse; - } - // Fallback - if (is_dist.undefined(requestOrResponse)) { - requestOrResponse = options.getFallbackRequestFunction()(url, this._requestOptions); - if (is_dist.promise(requestOrResponse)) { - requestOrResponse = await requestOrResponse; - } - } - if (utils_is_client_request(requestOrResponse)) { - this._onRequest(requestOrResponse); - } - else if (this.writable) { - this.once('finish', () => { - void this._onResponse(requestOrResponse); - }); - this._sendBody(); - } - else { - void this._onResponse(requestOrResponse); - } - } - catch (error) { - if (error instanceof types_CacheError) { - throw new errors_CacheError(error, this); - } - throw error; - } - } - async _error(error) { - try { - if (error instanceof errors_HTTPError && !this.options.throwHttpErrors) { - // This branch can be reached only when using the Promise API - // Skip calling the hooks on purpose. - // See https://github.com/sindresorhus/got/issues/2103 - } - else { - for (const hook of this.options.hooks.beforeError) { - // eslint-disable-next-line no-await-in-loop - error = await hook(error); - } - } - } - catch (error_) { - error = new errors_RequestError(error_.message, error_, this); - } - this.destroy(error); - } - _writeRequest(chunk, encoding, callback) { - if (!this._request || this._request.destroyed) { - // Probably the `ClientRequest` instance will throw - return; - } - this._request.write(chunk, encoding, (error) => { - // The `!destroyed` check is required to prevent `uploadProgress` being emitted after the stream was destroyed - if (!error && !this._request.destroyed) { - this._uploadedSize += external_node_buffer_namespaceObject.Buffer.byteLength(chunk, encoding); - const progress = this.uploadProgress; - if (progress.percent < 1) { - this.emit('uploadProgress', progress); - } - } - callback(error); - }); - } - /** - The remote IP address. - */ - get ip() { - return this.socket?.remoteAddress; - } - /** - Indicates whether the request has been aborted or not. - */ - get isAborted() { - return this._aborted; - } - get socket() { - return this._request?.socket ?? undefined; - } - /** - Progress event for downloading (receiving a response). - */ - get downloadProgress() { - let percent; - if (this._responseSize) { - percent = this._downloadedSize / this._responseSize; - } - else if (this._responseSize === this._downloadedSize) { - percent = 1; - } - else { - percent = 0; - } - return { - percent, - transferred: this._downloadedSize, - total: this._responseSize, - }; - } - /** - Progress event for uploading (sending a request). - */ - get uploadProgress() { - let percent; - if (this._bodySize) { - percent = this._uploadedSize / this._bodySize; - } - else if (this._bodySize === this._uploadedSize) { - percent = 1; - } - else { - percent = 0; - } - return { - percent, - transferred: this._uploadedSize, - total: this._bodySize, - }; - } - /** - The object contains the following properties: - - - `start` - Time when the request started. - - `socket` - Time when a socket was assigned to the request. - - `lookup` - Time when the DNS lookup finished. - - `connect` - Time when the socket successfully connected. - - `secureConnect` - Time when the socket securely connected. - - `upload` - Time when the request finished uploading. - - `response` - Time when the request fired `response` event. - - `end` - Time when the response fired `end` event. - - `error` - Time when the request fired `error` event. - - `abort` - Time when the request fired `abort` event. - - `phases` - - `wait` - `timings.socket - timings.start` - - `dns` - `timings.lookup - timings.socket` - - `tcp` - `timings.connect - timings.lookup` - - `tls` - `timings.secureConnect - timings.connect` - - `request` - `timings.upload - (timings.secureConnect || timings.connect)` - - `firstByte` - `timings.response - timings.upload` - - `download` - `timings.end - timings.response` - - `total` - `(timings.end || timings.error || timings.abort) - timings.start` - - If something has not been measured yet, it will be `undefined`. - - __Note__: The time is a `number` representing the milliseconds elapsed since the UNIX epoch. - */ - get timings() { - return this._request?.timings; - } - /** - Whether the response was retrieved from the cache. - */ - get isFromCache() { - return this._isFromCache; - } - get reusedSocket() { - return this._request?.reusedSocket; - } -} - -;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.3.0/node_modules/got/dist/source/as-promise/types.js - -/** -An error to be thrown when the request is aborted with `.cancel()`. -*/ -class as_promise_types_CancelError extends errors_RequestError { - constructor(request) { - super('Promise was canceled', {}, request); - this.name = 'CancelError'; - this.code = 'ERR_CANCELED'; - } - /** - Whether the promise is canceled. - */ - get isCanceled() { - return true; - } -} - -;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.3.0/node_modules/got/dist/source/as-promise/index.js - - - - - - - - -const source_as_promise_proxiedRequestEvents = [ - 'request', - 'response', - 'redirect', - 'uploadProgress', - 'downloadProgress', -]; -function as_promise_asPromise(firstRequest) { - let globalRequest; - let globalResponse; - let normalizedOptions; - const emitter = new external_node_events_.EventEmitter(); - const promise = new PCancelable((resolve, reject, onCancel) => { - onCancel(() => { - globalRequest.destroy(); - }); - onCancel.shouldReject = false; - onCancel(() => { - reject(new as_promise_types_CancelError(globalRequest)); - }); - const makeRequest = (retryCount) => { - // Errors when a new request is made after the promise settles. - // Used to detect a race condition. - // See https://github.com/sindresorhus/got/issues/1489 - onCancel(() => { }); - const request = firstRequest ?? new core_Request(undefined, undefined, normalizedOptions); - request.retryCount = retryCount; - request._noPipe = true; - globalRequest = request; - request.once('response', async (response) => { - // Parse body - const contentEncoding = (response.headers['content-encoding'] ?? '').toLowerCase(); - const isCompressed = contentEncoding === 'gzip' || contentEncoding === 'deflate' || contentEncoding === 'br'; - const { options } = request; - if (isCompressed && !options.decompress) { - response.body = response.rawBody; - } - else { - try { - response.body = response_parseBody(response, options.responseType, options.parseJson, options.encoding); - } - catch (error) { - // Fall back to `utf8` - try { - response.body = response.rawBody.toString(); - } - catch (error) { - request._beforeError(new response_ParseError(error, response)); - return; - } - if (response_isResponseOk(response)) { - request._beforeError(error); - return; - } - } - } - try { - const hooks = options.hooks.afterResponse; - for (const [index, hook] of hooks.entries()) { - // @ts-expect-error TS doesn't notice that CancelableRequest is a Promise - // eslint-disable-next-line no-await-in-loop - response = await hook(response, async (updatedOptions) => { - options.merge(updatedOptions); - options.prefixUrl = ''; - if (updatedOptions.url) { - options.url = updatedOptions.url; - } - // Remove any further hooks for that request, because we'll call them anyway. - // The loop continues. We don't want duplicates (asPromise recursion). - options.hooks.afterResponse = options.hooks.afterResponse.slice(0, index); - throw new errors_RetryError(request); - }); - if (!(is_dist.object(response) && is_dist.number(response.statusCode) && !is_dist.nullOrUndefined(response.body))) { - throw new TypeError('The `afterResponse` hook returned an invalid value'); - } - } - } - catch (error) { - request._beforeError(error); - return; - } - globalResponse = response; - if (!response_isResponseOk(response)) { - request._beforeError(new errors_HTTPError(response)); - return; - } - request.destroy(); - resolve(request.options.resolveBodyOnly ? response.body : response); - }); - const onError = (error) => { - if (promise.isCanceled) { - return; - } - const { options } = request; - if (error instanceof errors_HTTPError && !options.throwHttpErrors) { - const { response } = error; - request.destroy(); - resolve(request.options.resolveBodyOnly ? response.body : response); - return; - } - reject(error); - }; - request.once('error', onError); - const previousBody = request.options?.body; - request.once('retry', (newRetryCount, error) => { - firstRequest = undefined; - const newBody = request.options.body; - if (previousBody === newBody && is_dist.nodeStream(newBody)) { - error.message = 'Cannot retry with consumed body stream'; - onError(error); - return; - } - // This is needed! We need to reuse `request.options` because they can get modified! - // For example, by calling `promise.json()`. - normalizedOptions = request.options; - makeRequest(newRetryCount); - }); - proxy_events_proxyEvents(request, emitter, source_as_promise_proxiedRequestEvents); - if (is_dist.undefined(firstRequest)) { - void request.flush(); - } - }; - makeRequest(0); - }); - promise.on = (event, function_) => { - emitter.on(event, function_); - return promise; - }; - promise.off = (event, function_) => { - emitter.off(event, function_); - return promise; - }; - const shortcut = (responseType) => { - const newPromise = (async () => { - // Wait until downloading has ended - await promise; - const { options } = globalResponse.request; - return response_parseBody(globalResponse, responseType, options.parseJson, options.encoding); - })(); - // eslint-disable-next-line @typescript-eslint/no-floating-promises - Object.defineProperties(newPromise, Object.getOwnPropertyDescriptors(promise)); - return newPromise; - }; - promise.json = () => { - if (globalRequest.options) { - const { headers } = globalRequest.options; - if (!globalRequest.writableFinished && !('accept' in headers)) { - headers.accept = 'application/json'; - } - } - return shortcut('json'); - }; - promise.buffer = () => shortcut('buffer'); - promise.text = () => shortcut('text'); - return promise; -} - -;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.3.0/node_modules/got/dist/source/create.js - - - - -// The `delay` package weighs 10KB (!) -const create_delay = async (ms) => new Promise(resolve => { - setTimeout(resolve, ms); -}); -const create_isGotInstance = (value) => is_dist.function_(value); -const create_aliases = [ - 'get', - 'post', - 'put', - 'patch', - 'head', - 'delete', -]; -const create_create = (defaults) => { - defaults = { - options: new options_Options(undefined, undefined, defaults.options), - handlers: [...defaults.handlers], - mutableDefaults: defaults.mutableDefaults, - }; - Object.defineProperty(defaults, 'mutableDefaults', { - enumerable: true, - configurable: false, - writable: false, - }); - // Got interface - const got = ((url, options, defaultOptions = defaults.options) => { - const request = new core_Request(url, options, defaultOptions); - let promise; - const lastHandler = (normalized) => { - // Note: `options` is `undefined` when `new Options(...)` fails - request.options = normalized; - request._noPipe = !normalized.isStream; - void request.flush(); - if (normalized.isStream) { - return request; - } - promise ||= as_promise_asPromise(request); - return promise; - }; - let iteration = 0; - const iterateHandlers = (newOptions) => { - const handler = defaults.handlers[iteration++] ?? lastHandler; - const result = handler(newOptions, iterateHandlers); - if (is_dist.promise(result) && !request.options.isStream) { - promise ||= as_promise_asPromise(request); - if (result !== promise) { - const descriptors = Object.getOwnPropertyDescriptors(promise); - for (const key in descriptors) { - if (key in result) { - // eslint-disable-next-line @typescript-eslint/no-dynamic-delete - delete descriptors[key]; - } - } - // eslint-disable-next-line @typescript-eslint/no-floating-promises - Object.defineProperties(result, descriptors); - result.cancel = promise.cancel; - } - } - return result; - }; - return iterateHandlers(request.options); - }); - got.extend = (...instancesOrOptions) => { - const options = new options_Options(undefined, undefined, defaults.options); - const handlers = [...defaults.handlers]; - let mutableDefaults; - for (const value of instancesOrOptions) { - if (create_isGotInstance(value)) { - options.merge(value.defaults.options); - handlers.push(...value.defaults.handlers); - mutableDefaults = value.defaults.mutableDefaults; - } - else { - options.merge(value); - if (value.handlers) { - handlers.push(...value.handlers); - } - mutableDefaults = value.mutableDefaults; - } - } - return create_create({ - options, - handlers, - mutableDefaults: Boolean(mutableDefaults), - }); - }; - // Pagination - const paginateEach = (async function* (url, options) { - let normalizedOptions = new options_Options(url, options, defaults.options); - normalizedOptions.resolveBodyOnly = false; - const { pagination } = normalizedOptions; - dist_assert.function_(pagination.transform); - dist_assert.function_(pagination.shouldContinue); - dist_assert.function_(pagination.filter); - dist_assert.function_(pagination.paginate); - dist_assert.number(pagination.countLimit); - dist_assert.number(pagination.requestLimit); - dist_assert.number(pagination.backoff); - const allItems = []; - let { countLimit } = pagination; - let numberOfRequests = 0; - while (numberOfRequests < pagination.requestLimit) { - if (numberOfRequests !== 0) { - // eslint-disable-next-line no-await-in-loop - await create_delay(pagination.backoff); - } - // eslint-disable-next-line no-await-in-loop - const response = (await got(undefined, undefined, normalizedOptions)); - // eslint-disable-next-line no-await-in-loop - const parsed = await pagination.transform(response); - const currentItems = []; - dist_assert.array(parsed); - for (const item of parsed) { - if (pagination.filter({ item, currentItems, allItems })) { - if (!pagination.shouldContinue({ item, currentItems, allItems })) { - return; - } - yield item; - if (pagination.stackAllItems) { - allItems.push(item); - } - currentItems.push(item); - if (--countLimit <= 0) { - return; - } - } - } - const optionsToMerge = pagination.paginate({ - response, - currentItems, - allItems, - }); - if (optionsToMerge === false) { - return; - } - if (optionsToMerge === response.request.options) { - normalizedOptions = response.request.options; - } - else { - normalizedOptions.merge(optionsToMerge); - dist_assert.any([is_dist.urlInstance, is_dist.undefined], optionsToMerge.url); - if (optionsToMerge.url !== undefined) { - normalizedOptions.prefixUrl = ''; - normalizedOptions.url = optionsToMerge.url; - } - } - numberOfRequests++; - } - }); - got.paginate = paginateEach; - got.paginate.all = (async (url, options) => { - const results = []; - for await (const item of paginateEach(url, options)) { - results.push(item); - } - return results; - }); - // For those who like very descriptive names - got.paginate.each = paginateEach; - // Stream API - got.stream = ((url, options) => got(url, { ...options, isStream: true })); - // Shortcuts - for (const method of create_aliases) { - got[method] = ((url, options) => got(url, { ...options, method })); - got.stream[method] = ((url, options) => got(url, { ...options, method, isStream: true })); - } - if (!defaults.mutableDefaults) { - Object.freeze(defaults.handlers); - defaults.options.freeze(); - } - Object.defineProperty(got, 'defaults', { - value: defaults, - writable: false, - configurable: false, - enumerable: true, - }); - return got; -}; -/* harmony default export */ const dist_source_create = (create_create); - -;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.3.0/node_modules/got/dist/source/index.js - - -const source_defaults = { - options: new options_Options(), - handlers: [], - mutableDefaults: false, -}; -const source_got = dist_source_create(source_defaults); -/* harmony default export */ const node_modules_got_dist_source = (source_got); -// TODO: Remove this in the next major version. - - - - - - - - - - - - ;// CONCATENATED MODULE: ./dist/index.js // src/index.ts @@ -103208,7 +98085,7 @@ var NixInstallerAction = class extends DetSysAction { feat.payload ); try { - const resp = await node_modules_got_dist_source.get(url, { + const resp = await got_dist_source.get(url, { timeout: { request: timeoutMs } diff --git a/package.json b/package.json index 1dd2ec0..bfb12e8 100644 --- a/package.json +++ b/package.json @@ -28,8 +28,8 @@ "@actions/core": "^1.10.1", "@actions/exec": "^1.1.1", "@actions/github": "^5.1.1", - "detsys-ts": "github:DeterminateSystems/detsys-ts", - "got": "^14.3.0", + "detsys-ts": "github:DeterminateSystems/detsys-ts#retry-streams", + "got": "^14.4.2", "string-argv": "^0.3.2" }, "devDependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index aca1660..7796bdd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -15,11 +15,11 @@ dependencies: specifier: ^5.1.1 version: 5.1.1 detsys-ts: - specifier: github:DeterminateSystems/detsys-ts - version: github.com/DeterminateSystems/detsys-ts/817e4d4123b6fb4eae5aa557658f25f8539e7240 + specifier: github:DeterminateSystems/detsys-ts#retry-streams + version: github.com/DeterminateSystems/detsys-ts/b32eaff5853519dc6c92a63bac86f5169bc07112 got: - specifier: ^14.3.0 - version: 14.3.0 + specifier: ^14.4.2 + version: 14.4.2 string-argv: specifier: ^0.3.2 version: 0.3.2 @@ -184,6 +184,7 @@ packages: integrity: sha512-Fok9VVhMdxAFOtqiiAtg74fL0UJkt0z3D+ouUUxcRLzZNBioPRAMJFVxiWoJljYpXsRi4GDQHzQHDc9AiYaIUQ==, } engines: { node: ">=14.0.0" } + deprecated: deprecating as we migrated to core v2 dependencies: "@azure/abort-controller": 1.1.0 "@azure/core-auth": 1.7.2 @@ -1262,14 +1263,6 @@ packages: } dev: false - /@sindresorhus/is@6.3.1: - resolution: - { - integrity: sha512-FX4MfcifwJyFOI2lPoX7PQxCqx8BG1HCho7WdiXwpEQx1Ycij0JxkfYtGK7yqNScrZGSlt6RE6sw8QYoH7eKnQ==, - } - engines: { node: ">=16" } - dev: false - /@sindresorhus/is@7.0.0: resolution: { @@ -3285,14 +3278,6 @@ packages: engines: { node: ">=10" } dev: true - /get-stream@8.0.1: - resolution: - { - integrity: sha512-VaUJspBffn/LMCJVoMvSAdmscJyS1auj5Zulnn5UoYcY531UWmdwhRWkcGKnGU93m5HSXP9LP2usOryrBtQowA==, - } - engines: { node: ">=16" } - dev: false - /get-stream@9.0.1: resolution: { @@ -3428,26 +3413,6 @@ packages: get-intrinsic: 1.2.4 dev: true - /got@14.3.0: - resolution: - { - integrity: sha512-vZkrXdq5BtPWTXqvjXSpl6zky3zpHaOVfSug/RfFHu3YrtSsvYzopVMDqrh2do77WnGoCSSRCHW25zXOSAQ9zw==, - } - engines: { node: ">=20" } - dependencies: - "@sindresorhus/is": 6.3.1 - "@szmarczak/http-timer": 5.0.1 - cacheable-lookup: 7.0.0 - cacheable-request: 12.0.1 - decompress-response: 6.0.0 - form-data-encoder: 4.0.2 - get-stream: 8.0.1 - http2-wrapper: 2.2.1 - lowercase-keys: 3.0.0 - p-cancelable: 4.0.1 - responselike: 3.0.0 - dev: false - /got@14.4.2: resolution: { @@ -5685,10 +5650,10 @@ packages: engines: { node: ">=10" } dev: true - github.com/DeterminateSystems/detsys-ts/817e4d4123b6fb4eae5aa557658f25f8539e7240: + github.com/DeterminateSystems/detsys-ts/b32eaff5853519dc6c92a63bac86f5169bc07112: resolution: { - tarball: https://codeload.github.com/DeterminateSystems/detsys-ts/tar.gz/817e4d4123b6fb4eae5aa557658f25f8539e7240, + tarball: https://codeload.github.com/DeterminateSystems/detsys-ts/tar.gz/b32eaff5853519dc6c92a63bac86f5169bc07112, } name: detsys-ts version: 1.0.0