Proyecto audio control. inicado con panel y control.

This commit is contained in:
2025-11-11 02:26:04 -05:00
parent 7ea49a026e
commit 6895960127
4248 changed files with 493435 additions and 0 deletions

View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1,109 @@
"use strict";
// Copyright 2019 Google, LLC
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const express_1 = __importDefault(require("express"));
const child_process_1 = require("child_process");
const multiparty = __importStar(require("multiparty"));
const cors_1 = __importDefault(require("cors"));
const util_1 = require("util");
const port = 7172;
const exec = (0, util_1.promisify)(child_process_1.execFile);
async function listen(app, port) {
return new Promise((resolve, reject) => {
const server = app.listen(port, (err) => {
if (err) {
reject(err);
}
resolve(server);
});
});
}
// Starts a web server that browser tests will use, then runs actual browser
// tests.
async function main() {
const app = (0, express_1.default)();
app.use((0, cors_1.default)());
app.post('/path', (req, res) => {
if (req.header('origin')) {
res.set('Access-Control-Allow-Origin', req.header('origin'));
}
const form = new multiparty.Form({ autoFields: true });
form.parse(req, (err, fields) => {
if (err) {
res.status(500).send({ message: err.message });
}
else {
res.status(200).send(fields.null);
}
});
});
app.get('/path', (req, res) => {
if (req.header('origin')) {
res.set('Access-Control-Allow-Origin', req.header('origin'));
}
res.send('response');
});
app.get('/querystring', (req, res) => {
if (req.header('origin')) {
res.set('Access-Control-Allow-Origin', req.header('origin'));
}
const query = req.query.query;
res.send(query || '');
});
const server = await listen(app, port);
console.log(`[http server] I'm listening on port ${port}! Starting karma.`);
await exec('karma', ['start']);
server.close();
console.log(`[http server] Karma has finished! I'm no longer listening on port ${port}!`);
}
main().catch(err => {
console.log('Error:', err);
});
//# sourceMappingURL=browser-test-runner.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"browser-test-runner.js","sourceRoot":"","sources":["../../../browser-test/browser-test-runner.ts"],"names":[],"mappings":";AAAA,6BAA6B;AAC7B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,gDAAgD;AAChD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEjC,sDAA8B;AAE9B,iDAAuC;AACvC,uDAAyC;AACzC,gDAAwB;AACxB,+BAA+B;AAE/B,MAAM,IAAI,GAAG,IAAI,CAAC;AAElB,MAAM,IAAI,GAAG,IAAA,gBAAS,EAAC,wBAAQ,C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-0,0 +1 @@
export {};

View File

@@ -0,0 +1,81 @@
"use strict";
// Copyright 2019 Google, LLC
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const assert_1 = __importDefault(require("assert"));
const mocha_1 = require("mocha");
const index_1 = require("../src/index");
const port = 7172; // should match the port defined in `webserver.ts`
(0, mocha_1.describe)('💻 browser tests', () => {
(0, mocha_1.it)('should just work from browser', async () => {
const result = await (0, index_1.request)({ url: `http://localhost:${port}/path` });
assert_1.default.strictEqual(result.status, 200);
assert_1.default.strictEqual(result.data, 'response');
});
(0, mocha_1.it)('should pass querystring parameters from browser', async () => {
const result = await (0, index_1.request)({
url: `http://localhost:${port}/querystring`,
params: { query: 'value' },
});
assert_1.default.strictEqual(result.status, 200);
assert_1.default.strictEqual(result.data, 'value');
});
(0, mocha_1.it)('should allow passing browser fetch explicitly', async () => {
const result = await (0, index_1.request)({
url: `http://localhost:${port}/path`,
fetchImplementation: window.fetch,
});
assert_1.default.strictEqual(result.status, 200);
});
(0, mocha_1.it)('should support multipart post from the browser', async () => {
const headers = new Headers();
const multipart = [
{
'Content-Type': 'application/json',
body: JSON.stringify({ hello: 'world' }),
},
{
'Content-Type': 'text/plain',
body: 'hello world!',
},
];
const boundary = globalThis?.crypto.randomUUID() || (await import('crypto')).randomUUID();
const finale = `--${boundary}--`;
headers.set('Content-Type', `multipart/related; boundary=${boundary}`);
let content = '';
for (const part of multipart) {
const preamble = `--${boundary}\r\nContent-Type: ${part['Content-Type']}\r\n\r\n`;
// rStream.push(preamble);
content += preamble;
if (typeof part.body === 'string') {
content += part.body;
content += '\r\n';
}
}
content += finale;
const result = await (0, index_1.request)({
headers,
data: content,
method: 'POST',
url: `http://localhost:${port}/path`,
});
assert_1.default.strictEqual(result.status, 200);
const parts = result.data;
assert_1.default.strictEqual(parts[0], '{"hello":"world"}');
assert_1.default.strictEqual(parts[1], 'hello world!');
});
});
//# sourceMappingURL=test.browser.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"test.browser.js","sourceRoot":"","sources":["../../../browser-test/test.browser.ts"],"names":[],"mappings":";AAAA,6BAA6B;AAC7B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,gDAAgD;AAChD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;;;;AAEjC,oDAA4B;AAC5B,iCAAmC;AACnC,wCAAqC;AACrC,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,kDAAkD;AAErE,IAAA,gBAAQ,EAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,IAAA,UAAE,EAAC,+BAA+B,EAAE,KAAK,IAAI,EAAE;QAC7C,MAAM,MAAM,GAAG,MAAM,IAAA,eAAO,EAAC,EAAC,GAAG,EAAE,oBAAoB,IAAI,OAAO,EAAC,CAAC,CAAC;QACrE,gBAAM,CAAC,WAAW,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QACvC,gBAAM,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;IAEH,IAAA,UAAE,EAAC,iDAAiD,EAAE,KAAK,IAAI,EAAE;QAC/D,MAAM,MAAM,GAAG,MAAM,IAAA,eAAO,EAAC;YAC3B,GAAG,EAAE,oBAAoB,IAAI,cAAc;YAC3C,MAAM,EAAE,EAAC,KAAK,EAAE,OAAO,EAAC;SACzB,CAAC,CAAC;QACH,gBAAM,CAAC,W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I,QAAQ,CAAC;YACpB,IAAI,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;gBAClC,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC;gBACrB,OAAO,IAAI,MAAM,CAAC;YACpB,CAAC;QACH,CAAC;QACD,OAAO,IAAI,MAAM,CAAC;QAClB,MAAM,MAAM,GAAG,MAAM,IAAA,eAAO,EAAC;YAC3B,OAAO;YACP,IAAI,EAAE,OAAO;YACb,MAAM,EAAE,MAAM;YACd,GAAG,EAAE,oBAAoB,IAAI,OAAO;SACrC,CAAC,CAAC;QACH,gBAAM,CAAC,WAAW,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QACvC,MAAM,KAAK,GAAG,MAAM,CAAC,IAAgB,CAAC;QACtC,gBAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,mBAAmB,CAAC,CAAC;QAClD,gBAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}

329
node_modules/gaxios/build/cjs/src/common.d.ts generated vendored Normal file
View File

@@ -0,0 +1,329 @@
import { Agent } from 'http';
import { Readable } from 'stream';
/**
* TypeScript does not have this type available globally - however `@types/node` includes `undici-types`, which has it:
* - https://www.npmjs.com/package/@types/node/v/18.19.59?activeTab=dependencies
*
* Additionally, this is the TypeScript pattern for type sniffing and `import("undici-types")` is pretty common:
* - https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/node/globals.d.ts
*/
type _BodyInit = typeof globalThis extends {
BodyInit: infer T;
} ? T : import('undici-types').BodyInit;
/**
* An AIP-193 conforming error interface.
*
* @see {@link https://google.aip.dev/193#http11json-representation AIP-193}
*
* @param res the response object
* @returns the extracted error information
*/
export interface AIPErrorInterface {
error: {
code: number;
message: string;
status: string;
details?: {}[];
};
}
/**
* Support `instanceof` operator for `GaxiosError`s in different versions of this library.
*
* @see {@link GaxiosError[Symbol.hasInstance]}
*/
export declare const GAXIOS_ERROR_SYMBOL: unique symbol;
export declare class GaxiosError<T = ReturnType<JSON['parse']>> extends Error {
config: GaxiosOptionsPrepared;
response?: GaxiosResponse<T> | undefined;
/**
* An error code.
* Can be a system error code, DOMException error name, or any error's 'code' property where it is a `string`.
*
* It is only a `number` when the cause is sourced from an API-level error (AIP-193).
*
* @see {@link https://nodejs.org/api/errors.html#errorcode error.code}
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/DOMException#error_names DOMException#error_names}
* @see {@link https://google.aip.dev/193#http11json-representation AIP-193}
*
* @example
* 'ECONNRESET'
*
* @example
* 'TimeoutError'
*
* @example
* 500
*/
code?: string | number;
/**
* An HTTP Status code.
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Response/status Response#status}
*
* @example
* 500
*/
status?: number;
/**
* @deprecated use {@link GaxiosError.cause} instead.
*
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause Error#cause}
*
* @privateRemarks
*
* We will want to remove this property later as the modern `cause` property is better suited
* for displaying and relaying nested errors. Keeping this here makes the resulting
* error log larger than it needs to be.
*
*/
error?: Error | NodeJS.ErrnoException;
/**
* Support `instanceof` operator for `GaxiosError` across builds/duplicated files.
*
* @see {@link GAXIOS_ERROR_SYMBOL}
* @see {@link GaxiosError[Symbol.hasInstance]}
* @see {@link https://github.com/microsoft/TypeScript/issues/13965#issuecomment-278570200}
* @see {@link https://stackoverflow.com/questions/46618852/require-and-instanceof}
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/@@hasInstance#reverting_to_default_instanceof_behavior}
*/
[GAXIOS_ERROR_SYMBOL]: string;
/**
* Support `instanceof` operator for `GaxiosError` across builds/duplicated files.
*
* @see {@link GAXIOS_ERROR_SYMBOL}
* @see {@link GaxiosError[GAXIOS_ERROR_SYMBOL]}
*/
static [Symbol.hasInstance](instance: unknown): boolean;
constructor(message: string, config: GaxiosOptionsPrepared, response?: GaxiosResponse<T> | undefined, cause?: unknown);
}
type GaxiosResponseData = ReturnType<JSON['parse']> | GaxiosOptionsPrepared['data'];
export type GaxiosPromise<T = GaxiosResponseData> = Promise<GaxiosResponse<T>>;
export interface GaxiosResponse<T = GaxiosResponseData> extends Response {
config: GaxiosOptionsPrepared;
data: T;
}
export interface GaxiosMultipartOptions {
headers: Headers;
content: string | Readable;
}
/**
* Request options that are used to form the request.
*/
export interface GaxiosOptions extends RequestInit {
/**
* Optional method to override making the actual HTTP request. Useful
* for writing tests.
*/
adapter?: <T = GaxiosResponseData>(options: GaxiosOptionsPrepared, defaultAdapter: (options: GaxiosOptionsPrepared) => GaxiosPromise<T>) => GaxiosPromise<T>;
url?: string | URL;
baseURL?: string | URL;
/**
* The data to send in the {@link RequestInit.body} of the request. Objects will be
* serialized as JSON, except for:
* - `ArrayBuffer`
* - `Blob`
* - `Buffer` (Node.js)
* - `DataView`
* - `File`
* - `FormData`
* - `ReadableStream`
* - `stream.Readable` (Node.js)
* - strings
* - `TypedArray` (e.g. `Uint8Array`, `BigInt64Array`)
* - `URLSearchParams`
* - all other objects where:
* - headers['Content-Type'] === 'application/x-www-form-urlencoded' (serialized as `URLSearchParams`)
*
* In all other cases, if you would like to prevent `application/json` as the
* default `Content-Type` header you must provide a string or readable stream
* rather than an object, e.g.:
*
* ```ts
* {data: JSON.stringify({some: 'data'})}
* {data: fs.readFile('./some-data.jpeg')}
* ```
*/
data?: _BodyInit | ArrayBuffer | Blob | Buffer | DataView | File | FormData | ReadableStream | Readable | string | ArrayBufferView | URLSearchParams | {};
/**
* The maximum size of the http response `Content-Length` in bytes allowed.
*/
maxContentLength?: number;
/**
* The maximum number of redirects to follow. Defaults to 20.
*
* @deprecated non-spec. Should use `20` if enabled per-spec: https://fetch.spec.whatwg.org/#http-redirect-fetch
*/
maxRedirects?: number;
/**
* @deprecated non-spec. Should use `20` if enabled per-spec: https://fetch.spec.whatwg.org/#http-redirect-fetch
*/
follow?: number;
/**
* A collection of parts to send as a `Content-Type: multipart/related` request.
*
* This is passed to {@link RequestInit.body}.
*/
multipart?: GaxiosMultipartOptions[];
params?: GaxiosResponseData;
/**
* @deprecated Use {@link URLSearchParams} instead and pass this directly to {@link GaxiosOptions.data `data`}.
*/
paramsSerializer?: (params: {
[index: string]: string | number;
}) => string;
/**
* A timeout for the request, in milliseconds. No timeout by default.
*/
timeout?: number;
/**
* @deprecated ignored
*/
onUploadProgress?: (progressEvent: GaxiosResponseData) => void;
/**
* If the `fetchImplementation` is native `fetch`, the
* stream is a `ReadableStream`, otherwise `readable.Stream`
*/
responseType?: 'arraybuffer' | 'blob' | 'json' | 'text' | 'stream' | 'unknown';
agent?: Agent | ((parsedUrl: URL) => Agent);
validateStatus?: (status: number) => boolean;
retryConfig?: RetryConfig;
retry?: boolean;
/**
* @deprecated non-spec. https://github.com/node-fetch/node-fetch/issues/1438
*/
size?: number;
/**
* Implementation of `fetch` to use when making the API call. Will use `fetch` by default.
*
* @example
*
* let customFetchCalled = false;
* const myFetch = (...args: Parameters<typeof fetch>) => {
* customFetchCalled = true;
* return fetch(...args);
* };
*
* {fetchImplementation: myFetch};
*/
fetchImplementation?: typeof fetch;
cert?: string;
key?: string;
/**
* An optional proxy to use for requests.
* Available via `process.env.HTTP_PROXY` and `process.env.HTTPS_PROXY` as well - with a preference for the this config option when multiple are available.
* The {@link GaxiosOptions.agent `agent`} option overrides this.
*
* @see {@link GaxiosOptions.noProxy}
* @see {@link GaxiosOptions.agent}
*/
proxy?: string | URL;
/**
* A list for excluding traffic for proxies.
* Available via `process.env.NO_PROXY` as well as a common-separated list of strings - merged with any local `noProxy` rules.
*
* - When provided a string, it is matched by
* - Wildcard `*.` and `.` matching are available. (e.g. `.example.com` or `*.example.com`)
* - When provided a URL, it is matched by the `.origin` property.
* - For example, requesting `https://example.com` with the following `noProxy`s would result in a no proxy use:
* - new URL('https://example.com')
* - new URL('https://example.com:443')
* - The following would be used with a proxy:
* - new URL('http://example.com:80')
* - new URL('https://example.com:8443')
* - When provided a regular expression it is used to match the stringified URL
*
* @see {@link GaxiosOptions.proxy}
*/
noProxy?: (string | URL | RegExp)[];
/**
* An experimental error redactor.
*
* @remarks
*
* This does not replace the requirement for an active Data Loss Prevention (DLP) provider. For DLP suggestions, see:
* - https://cloud.google.com/sensitive-data-protection/docs/redacting-sensitive-data#dlp_deidentify_replace_infotype-nodejs
* - https://cloud.google.com/sensitive-data-protection/docs/infotypes-reference#credentials_and_secrets
*
* @experimental
*/
errorRedactor?: typeof defaultErrorRedactor | false;
}
export interface GaxiosOptionsPrepared extends GaxiosOptions {
headers: Headers;
url: URL;
}
/**
* Gaxios retry configuration.
*/
export interface RetryConfig {
/**
* The number of times to retry the request. Defaults to 3.
*/
retry?: number;
/**
* The number of retries already attempted.
*/
currentRetryAttempt?: number;
/**
* The amount of time to initially delay the retry, in ms. Defaults to 100ms.
*/
retryDelay?: number;
/**
* The HTTP Methods that will be automatically retried.
* Defaults to ['GET','PUT','HEAD','OPTIONS','DELETE']
*/
httpMethodsToRetry?: string[];
/**
* The HTTP response status codes that will automatically be retried.
* Defaults to: [[100, 199], [408, 408], [429, 429], [500, 599]]
*/
statusCodesToRetry?: number[][];
/**
* Function to invoke when a retry attempt is made.
*/
onRetryAttempt?: (err: GaxiosError) => Promise<void> | void;
/**
* Function to invoke which determines if you should retry
*/
shouldRetry?: (err: GaxiosError) => Promise<boolean> | boolean;
/**
* When there is no response, the number of retries to attempt. Defaults to 2.
*/
noResponseRetries?: number;
/**
* Function to invoke which returns a promise. After the promise resolves,
* the retry will be triggered. If provided, this will be used in-place of
* the `retryDelay`
*/
retryBackoff?: (err: GaxiosError, defaultBackoffMs: number) => Promise<void>;
/**
* Time that the initial request was made. Users should not set this directly.
*/
timeOfFirstRequest?: number;
/**
* The length of time to keep retrying in ms. The last sleep period will
* be shortened as necessary, so that the last retry runs at deadline (and not
* considerably beyond it). The total time starting from when the initial
* request is sent, after which an error will be returned, regardless of the
* retrying attempts made meanwhile. Defaults to Number.MAX_SAFE_INTEGER indicating to effectively
* ignore totalTimeout.
*/
totalTimeout?: number;
maxRetryDelay?: number;
retryDelayMultiplier?: number;
}
/**
* An experimental error redactor.
*
* @param config Config to potentially redact properties of
* @param response Config to potentially redact properties of
*
* @experimental
*/
export declare function defaultErrorRedactor<O extends GaxiosOptionsPrepared, R extends GaxiosResponse<GaxiosResponseData>>(data: {
config?: O;
response?: R;
}): {
config?: O;
response?: R;
};
export {};

311
node_modules/gaxios/build/cjs/src/common.js generated vendored Normal file
View File

@@ -0,0 +1,311 @@
"use strict";
// Copyright 2018 Google LLC
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.GaxiosError = exports.GAXIOS_ERROR_SYMBOL = void 0;
exports.defaultErrorRedactor = defaultErrorRedactor;
const extend_1 = __importDefault(require("extend"));
const util_cjs_1 = __importDefault(require("./util.cjs"));
const pkg = util_cjs_1.default.pkg;
/**
* Support `instanceof` operator for `GaxiosError`s in different versions of this library.
*
* @see {@link GaxiosError[Symbol.hasInstance]}
*/
exports.GAXIOS_ERROR_SYMBOL = Symbol.for(`${pkg.name}-gaxios-error`);
class GaxiosError extends Error {
config;
response;
/**
* An error code.
* Can be a system error code, DOMException error name, or any error's 'code' property where it is a `string`.
*
* It is only a `number` when the cause is sourced from an API-level error (AIP-193).
*
* @see {@link https://nodejs.org/api/errors.html#errorcode error.code}
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/DOMException#error_names DOMException#error_names}
* @see {@link https://google.aip.dev/193#http11json-representation AIP-193}
*
* @example
* 'ECONNRESET'
*
* @example
* 'TimeoutError'
*
* @example
* 500
*/
code;
/**
* An HTTP Status code.
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Response/status Response#status}
*
* @example
* 500
*/
status;
/**
* @deprecated use {@link GaxiosError.cause} instead.
*
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause Error#cause}
*
* @privateRemarks
*
* We will want to remove this property later as the modern `cause` property is better suited
* for displaying and relaying nested errors. Keeping this here makes the resulting
* error log larger than it needs to be.
*
*/
error;
/**
* Support `instanceof` operator for `GaxiosError` across builds/duplicated files.
*
* @see {@link GAXIOS_ERROR_SYMBOL}
* @see {@link GaxiosError[Symbol.hasInstance]}
* @see {@link https://github.com/microsoft/TypeScript/issues/13965#issuecomment-278570200}
* @see {@link https://stackoverflow.com/questions/46618852/require-and-instanceof}
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/@@hasInstance#reverting_to_default_instanceof_behavior}
*/
[exports.GAXIOS_ERROR_SYMBOL] = pkg.version;
/**
* Support `instanceof` operator for `GaxiosError` across builds/duplicated files.
*
* @see {@link GAXIOS_ERROR_SYMBOL}
* @see {@link GaxiosError[GAXIOS_ERROR_SYMBOL]}
*/
static [Symbol.hasInstance](instance) {
if (instance &&
typeof instance === 'object' &&
exports.GAXIOS_ERROR_SYMBOL in instance &&
instance[exports.GAXIOS_ERROR_SYMBOL] === pkg.version) {
return true;
}
// fallback to native
return Function.prototype[Symbol.hasInstance].call(GaxiosError, instance);
}
constructor(message, config, response, cause) {
super(message, { cause });
this.config = config;
this.response = response;
this.error = cause instanceof Error ? cause : undefined;
// deep-copy config as we do not want to mutate
// the existing config for future retries/use
this.config = (0, extend_1.default)(true, {}, config);
if (this.response) {
this.response.config = (0, extend_1.default)(true, {}, this.response.config);
}
if (this.response) {
try {
this.response.data = translateData(this.config.responseType,
// workaround for `node-fetch`'s `.data` deprecation...
this.response?.bodyUsed ? this.response?.data : undefined);
}
catch {
// best effort - don't throw an error within an error
// we could set `this.response.config.responseType = 'unknown'`, but
// that would mutate future calls with this config object.
}
this.status = this.response.status;
}
if (cause instanceof DOMException) {
// The DOMException's equivalent to code is its name
// E.g.: name = `TimeoutError`, code = number
// https://developer.mozilla.org/en-US/docs/Web/API/DOMException/name
this.code = cause.name;
}
else if (cause &&
typeof cause === 'object' &&
'code' in cause &&
(typeof cause.code === 'string' || typeof cause.code === 'number')) {
this.code = cause.code;
}
}
/**
* An AIP-193 conforming error extractor.
*
* @see {@link https://google.aip.dev/193#http11json-representation AIP-193}
*
* @internal
* @expiremental
*
* @param res the response object
* @returns the extracted error information
*/
static extractAPIErrorFromResponse(res, defaultErrorMessage = 'The request failed') {
let message = defaultErrorMessage;
// Use res.data as the error message
if (typeof res.data === 'string') {
message = res.data;
}
if (res.data &&
typeof res.data === 'object' &&
'error' in res.data &&
res.data.error &&
!res.ok) {
if (typeof res.data.error === 'string') {
return {
message: res.data.error,
code: res.status,
status: res.statusText,
};
}
if (typeof res.data.error === 'object') {
// extract status from data.message
message =
'message' in res.data.error &&
typeof res.data.error.message === 'string'
? res.data.error.message
: message;
// extract status from data.error
const status = 'status' in res.data.error &&
typeof res.data.error.status === 'string'
? res.data.error.status
: res.statusText;
// extract code from data.error
const code = 'code' in res.data.error && typeof res.data.error.code === 'number'
? res.data.error.code
: res.status;
if ('errors' in res.data.error &&
Array.isArray(res.data.error.errors)) {
const errorMessages = [];
for (const e of res.data.error.errors) {
if (typeof e === 'object' &&
'message' in e &&
typeof e.message === 'string') {
errorMessages.push(e.message);
}
}
return Object.assign({
message: errorMessages.join('\n') || message,
code,
status,
}, res.data.error);
}
return Object.assign({
message,
code,
status,
}, res.data.error);
}
}
return {
message,
code: res.status,
status: res.statusText,
};
}
}
exports.GaxiosError = GaxiosError;
function translateData(responseType, data) {
switch (responseType) {
case 'stream':
return data;
case 'json':
return JSON.parse(JSON.stringify(data));
case 'arraybuffer':
return JSON.parse(Buffer.from(data).toString('utf8'));
case 'blob':
return JSON.parse(data.text());
default:
return data;
}
}
/**
* An experimental error redactor.
*
* @param config Config to potentially redact properties of
* @param response Config to potentially redact properties of
*
* @experimental
*/
function defaultErrorRedactor(data) {
const REDACT = '<<REDACTED> - See `errorRedactor` option in `gaxios` for configuration>.';
function redactHeaders(headers) {
if (!headers)
return;
headers.forEach((_, key) => {
// any casing of `Authentication`
// any casing of `Authorization`
// anything containing secret, such as 'client secret'
if (/^authentication$/i.test(key) ||
/^authorization$/i.test(key) ||
/secret/i.test(key))
headers.set(key, REDACT);
});
}
function redactString(obj, key) {
if (typeof obj === 'object' &&
obj !== null &&
typeof obj[key] === 'string') {
const text = obj[key];
if (/grant_type=/i.test(text) ||
/assertion=/i.test(text) ||
/secret/i.test(text)) {
obj[key] = REDACT;
}
}
}
function redactObject(obj) {
if (!obj || typeof obj !== 'object') {
return;
}
else if (obj instanceof FormData ||
obj instanceof URLSearchParams ||
// support `node-fetch` FormData/URLSearchParams
('forEach' in obj && 'set' in obj)) {
obj.forEach((_, key) => {
if (['grant_type', 'assertion'].includes(key) || /secret/.test(key)) {
obj.set(key, REDACT);
}
});
}
else {
if ('grant_type' in obj) {
obj['grant_type'] = REDACT;
}
if ('assertion' in obj) {
obj['assertion'] = REDACT;
}
if ('client_secret' in obj) {
obj['client_secret'] = REDACT;
}
}
}
if (data.config) {
redactHeaders(data.config.headers);
redactString(data.config, 'data');
redactObject(data.config.data);
redactString(data.config, 'body');
redactObject(data.config.body);
if (data.config.url.searchParams.has('token')) {
data.config.url.searchParams.set('token', REDACT);
}
if (data.config.url.searchParams.has('client_secret')) {
data.config.url.searchParams.set('client_secret', REDACT);
}
}
if (data.response) {
defaultErrorRedactor({ config: data.response.config });
redactHeaders(data.response.headers);
// workaround for `node-fetch`'s `.data` deprecation...
if (data.response.bodyUsed) {
redactString(data.response, 'data');
redactObject(data.response.data);
}
}
return data;
}
//# sourceMappingURL=common.js.map

1
node_modules/gaxios/build/cjs/src/common.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

104
node_modules/gaxios/build/cjs/src/gaxios.d.ts generated vendored Normal file
View File

@@ -0,0 +1,104 @@
import { Agent } from 'http';
import { GaxiosOptions, GaxiosOptionsPrepared, GaxiosPromise, GaxiosResponse } from './common.js';
import { GaxiosInterceptorManager } from './interceptor.js';
/**
* An interface for enforcing `fetch`-type compliance.
*
* @remarks
*
* This provides type guarantees during build-time, ensuring the `fetch` method is 1:1
* compatible with the `fetch` API.
*/
interface FetchCompliance {
fetch: typeof fetch;
}
export declare class Gaxios implements FetchCompliance {
#private;
protected agentCache: Map<string | URL, Agent | ((parsedUrl: URL) => Agent)>;
/**
* Default HTTP options that will be used for every HTTP request.
*/
defaults: GaxiosOptions;
/**
* Interceptors
*/
interceptors: {
request: GaxiosInterceptorManager<GaxiosOptionsPrepared>;
response: GaxiosInterceptorManager<GaxiosResponse>;
};
/**
* The Gaxios class is responsible for making HTTP requests.
* @param defaults The default set of options to be used for this instance.
*/
constructor(defaults?: GaxiosOptions);
/**
* A {@link fetch `fetch`} compliant API for {@link Gaxios}.
*
* @remarks
*
* This is useful as a drop-in replacement for `fetch` API usage.
*
* @example
*
* ```ts
* const gaxios = new Gaxios();
* const myFetch: typeof fetch = (...args) => gaxios.fetch(...args);
* await myFetch('https://example.com');
* ```
*
* @param args `fetch` API or `Gaxios#request` parameters
* @returns the {@link Response} with Gaxios-added properties
*/
fetch<T = unknown>(...args: Parameters<typeof fetch> | Parameters<Gaxios['request']>): GaxiosPromise<T>;
/**
* Perform an HTTP request with the given options.
* @param opts Set of HTTP options that will be used for this HTTP request.
*/
request<T = ReturnType<JSON['parse']>>(opts?: GaxiosOptions): GaxiosPromise<T>;
private _defaultAdapter;
/**
* Internal, retryable version of the `request` method.
* @param opts Set of HTTP options that will be used for this HTTP request.
*/
protected _request<T = ReturnType<JSON['parse']>>(opts: GaxiosOptionsPrepared): GaxiosPromise<T>;
private getResponseData;
/**
* By default, throw for any non-2xx status code
* @param status status code from the HTTP response
*/
private validateStatus;
/**
* Attempts to parse a response by looking at the Content-Type header.
* @param {Response} response the HTTP response.
* @returns a promise that resolves to the response data.
*/
private getResponseDataFromContentType;
/**
* Creates an async generator that yields the pieces of a multipart/related request body.
* This implementation follows the spec: https://www.ietf.org/rfc/rfc2387.txt. However, recursive
* multipart/related requests are not currently supported.
*
* @param {GaxiosMultipartOptions[]} multipartOptions the pieces to turn into a multipart/related body.
* @param {string} boundary the boundary string to be placed between each part.
*/
private getMultipartRequest;
/**
* Merges headers.
* If the base headers do not exist a new `Headers` object will be returned.
*
* @remarks
*
* Using this utility can be helpful when the headers are not known to exist:
* - if they exist as `Headers`, that instance will be used
* - it improves performance and allows users to use their existing references to their `Headers`
* - if they exist in another form (`HeadersInit`), they will be used to create a new `Headers` object
* - if the base headers do not exist a new `Headers` object will be created
*
* @param base headers to append/overwrite to
* @param append headers to append/overwrite with
* @returns the base headers instance with merged `Headers`
*/
static mergeHeaders(base?: HeadersInit, ...append: HeadersInit[]): Headers;
}
type HeadersInit = ConstructorParameters<typeof Headers>[0];
export {};

564
node_modules/gaxios/build/cjs/src/gaxios.js generated vendored Normal file
View File

@@ -0,0 +1,564 @@
"use strict";
// Copyright 2018 Google LLC
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Gaxios = void 0;
const extend_1 = __importDefault(require("extend"));
const https_1 = require("https");
const common_js_1 = require("./common.js");
const retry_js_1 = require("./retry.js");
const stream_1 = require("stream");
const interceptor_js_1 = require("./interceptor.js");
const randomUUID = async () => globalThis.crypto?.randomUUID() || (await import('crypto')).randomUUID();
const HTTP_STATUS_NO_CONTENT = 204;
class Gaxios {
agentCache = new Map();
/**
* Default HTTP options that will be used for every HTTP request.
*/
defaults;
/**
* Interceptors
*/
interceptors;
/**
* The Gaxios class is responsible for making HTTP requests.
* @param defaults The default set of options to be used for this instance.
*/
constructor(defaults) {
this.defaults = defaults || {};
this.interceptors = {
request: new interceptor_js_1.GaxiosInterceptorManager(),
response: new interceptor_js_1.GaxiosInterceptorManager(),
};
}
/**
* A {@link fetch `fetch`} compliant API for {@link Gaxios}.
*
* @remarks
*
* This is useful as a drop-in replacement for `fetch` API usage.
*
* @example
*
* ```ts
* const gaxios = new Gaxios();
* const myFetch: typeof fetch = (...args) => gaxios.fetch(...args);
* await myFetch('https://example.com');
* ```
*
* @param args `fetch` API or `Gaxios#request` parameters
* @returns the {@link Response} with Gaxios-added properties
*/
fetch(...args) {
// Up to 2 parameters in either overload
const input = args[0];
const init = args[1];
let url = undefined;
const headers = new Headers();
// prepare URL
if (typeof input === 'string') {
url = new URL(input);
}
else if (input instanceof URL) {
url = input;
}
else if (input && input.url) {
url = new URL(input.url);
}
// prepare headers
if (input && typeof input === 'object' && 'headers' in input) {
_a.mergeHeaders(headers, input.headers);
}
if (init) {
_a.mergeHeaders(headers, new Headers(init.headers));
}
// prepare request
if (typeof input === 'object' && !(input instanceof URL)) {
// input must have been a non-URL object
return this.request({ ...init, ...input, headers, url });
}
else {
// input must have been a string or URL
return this.request({ ...init, headers, url });
}
}
/**
* Perform an HTTP request with the given options.
* @param opts Set of HTTP options that will be used for this HTTP request.
*/
async request(opts = {}) {
let prepared = await this.#prepareRequest(opts);
prepared = await this.#applyRequestInterceptors(prepared);
return this.#applyResponseInterceptors(this._request(prepared));
}
async _defaultAdapter(config) {
const fetchImpl = config.fetchImplementation ||
this.defaults.fetchImplementation ||
(await _a.#getFetch());
// node-fetch v3 warns when `data` is present
// https://github.com/node-fetch/node-fetch/issues/1000
const preparedOpts = { ...config };
delete preparedOpts.data;
const res = (await fetchImpl(config.url, preparedOpts));
const data = await this.getResponseData(config, res);
if (!Object.getOwnPropertyDescriptor(res, 'data')?.configurable) {
// Work-around for `node-fetch` v3 as accessing `data` would otherwise throw
Object.defineProperties(res, {
data: {
configurable: true,
writable: true,
enumerable: true,
value: data,
},
});
}
// Keep object as an instance of `Response`
return Object.assign(res, { config, data });
}
/**
* Internal, retryable version of the `request` method.
* @param opts Set of HTTP options that will be used for this HTTP request.
*/
async _request(opts) {
try {
let translatedResponse;
if (opts.adapter) {
translatedResponse = await opts.adapter(opts, this._defaultAdapter.bind(this));
}
else {
translatedResponse = await this._defaultAdapter(opts);
}
if (!opts.validateStatus(translatedResponse.status)) {
if (opts.responseType === 'stream') {
const response = [];
for await (const chunk of translatedResponse.data) {
response.push(chunk);
}
translatedResponse.data = response.toString();
}
const errorInfo = common_js_1.GaxiosError.extractAPIErrorFromResponse(translatedResponse, `Request failed with status code ${translatedResponse.status}`);
throw new common_js_1.GaxiosError(errorInfo?.message, opts, translatedResponse, errorInfo);
}
return translatedResponse;
}
catch (e) {
let err;
if (e instanceof common_js_1.GaxiosError) {
err = e;
}
else if (e instanceof Error) {
err = new common_js_1.GaxiosError(e.message, opts, undefined, e);
}
else {
err = new common_js_1.GaxiosError('Unexpected Gaxios Error', opts, undefined, e);
}
const { shouldRetry, config } = await (0, retry_js_1.getRetryConfig)(err);
if (shouldRetry && config) {
err.config.retryConfig.currentRetryAttempt =
config.retryConfig.currentRetryAttempt;
// The error's config could be redacted - therefore we only want to
// copy the retry state over to the existing config
opts.retryConfig = err.config?.retryConfig;
// re-prepare timeout for the next request
this.#appendTimeoutToSignal(opts);
return this._request(opts);
}
if (opts.errorRedactor) {
opts.errorRedactor(err);
}
throw err;
}
}
async getResponseData(opts, res) {
if (res.status === HTTP_STATUS_NO_CONTENT) {
return '';
}
if (opts.maxContentLength &&
res.headers.has('content-length') &&
opts.maxContentLength <
Number.parseInt(res.headers?.get('content-length') || '')) {
throw new common_js_1.GaxiosError("Response's `Content-Length` is over the limit.", opts, Object.assign(res, { config: opts }));
}
switch (opts.responseType) {
case 'stream':
return res.body;
case 'json': {
const data = await res.text();
try {
return JSON.parse(data);
}
catch {
return data;
}
}
case 'arraybuffer':
return res.arrayBuffer();
case 'blob':
return res.blob();
case 'text':
return res.text();
default:
return this.getResponseDataFromContentType(res);
}
}
#urlMayUseProxy(url, noProxy = []) {
const candidate = new URL(url);
const noProxyList = [...noProxy];
const noProxyEnvList = (process.env.NO_PROXY ?? process.env.no_proxy)?.split(',') || [];
for (const rule of noProxyEnvList) {
noProxyList.push(rule.trim());
}
for (const rule of noProxyList) {
// Match regex
if (rule instanceof RegExp) {
if (rule.test(candidate.toString())) {
return false;
}
}
// Match URL
else if (rule instanceof URL) {
if (rule.origin === candidate.origin) {
return false;
}
}
// Match string regex
else if (rule.startsWith('*.') || rule.startsWith('.')) {
const cleanedRule = rule.replace(/^\*\./, '.');
if (candidate.hostname.endsWith(cleanedRule)) {
return false;
}
}
// Basic string match
else if (rule === candidate.origin ||
rule === candidate.hostname ||
rule === candidate.href) {
return false;
}
}
return true;
}
/**
* Applies the request interceptors. The request interceptors are applied after the
* call to prepareRequest is completed.
*
* @param {GaxiosOptionsPrepared} options The current set of options.
*
* @returns {Promise<GaxiosOptionsPrepared>} Promise that resolves to the set of options or response after interceptors are applied.
*/
async #applyRequestInterceptors(options) {
let promiseChain = Promise.resolve(options);
for (const interceptor of this.interceptors.request.values()) {
if (interceptor) {
promiseChain = promiseChain.then(interceptor.resolved, interceptor.rejected);
}
}
return promiseChain;
}
/**
* Applies the response interceptors. The response interceptors are applied after the
* call to request is made.
*
* @param {GaxiosOptionsPrepared} options The current set of options.
*
* @returns {Promise<GaxiosOptionsPrepared>} Promise that resolves to the set of options or response after interceptors are applied.
*/
async #applyResponseInterceptors(response) {
let promiseChain = Promise.resolve(response);
for (const interceptor of this.interceptors.response.values()) {
if (interceptor) {
promiseChain = promiseChain.then(interceptor.resolved, interceptor.rejected);
}
}
return promiseChain;
}
/**
* Validates the options, merges them with defaults, and prepare request.
*
* @param options The original options passed from the client.
* @returns Prepared options, ready to make a request
*/
async #prepareRequest(options) {
// Prepare Headers - copy in order to not mutate the original objects
const preparedHeaders = new Headers(this.defaults.headers);
_a.mergeHeaders(preparedHeaders, options.headers);
// Merge options
const opts = (0, extend_1.default)(true, {}, this.defaults, options);
if (!opts.url) {
throw new Error('URL is required.');
}
if (opts.baseURL) {
opts.url = new URL(opts.url, opts.baseURL);
}
// don't modify the properties of a default or provided URL
opts.url = new URL(opts.url);
if (opts.params) {
if (opts.paramsSerializer) {
let additionalQueryParams = opts.paramsSerializer(opts.params);
if (additionalQueryParams.startsWith('?')) {
additionalQueryParams = additionalQueryParams.slice(1);
}
const prefix = opts.url.toString().includes('?') ? '&' : '?';
opts.url = opts.url + prefix + additionalQueryParams;
}
else {
const url = opts.url instanceof URL ? opts.url : new URL(opts.url);
for (const [key, value] of new URLSearchParams(opts.params)) {
url.searchParams.append(key, value);
}
opts.url = url;
}
}
if (typeof options.maxContentLength === 'number') {
opts.size = options.maxContentLength;
}
if (typeof options.maxRedirects === 'number') {
opts.follow = options.maxRedirects;
}
const shouldDirectlyPassData = typeof opts.data === 'string' ||
opts.data instanceof ArrayBuffer ||
opts.data instanceof Blob ||
// Node 18 does not have a global `File` object
(globalThis.File && opts.data instanceof File) ||
opts.data instanceof FormData ||
opts.data instanceof stream_1.Readable ||
opts.data instanceof ReadableStream ||
opts.data instanceof String ||
opts.data instanceof URLSearchParams ||
ArrayBuffer.isView(opts.data) || // `Buffer` (Node.js), `DataView`, `TypedArray`
/**
* @deprecated `node-fetch` or another third-party's request types
*/
['Blob', 'File', 'FormData'].includes(opts.data?.constructor?.name || '');
if (opts.multipart?.length) {
const boundary = await randomUUID();
preparedHeaders.set('content-type', `multipart/related; boundary=${boundary}`);
opts.body = stream_1.Readable.from(this.getMultipartRequest(opts.multipart, boundary));
}
else if (shouldDirectlyPassData) {
opts.body = opts.data;
}
else if (typeof opts.data === 'object') {
if (preparedHeaders.get('Content-Type') ===
'application/x-www-form-urlencoded') {
// If www-form-urlencoded content type has been set, but data is
// provided as an object, serialize the content
opts.body = opts.paramsSerializer
? opts.paramsSerializer(opts.data)
: new URLSearchParams(opts.data);
}
else {
if (!preparedHeaders.has('content-type')) {
preparedHeaders.set('content-type', 'application/json');
}
opts.body = JSON.stringify(opts.data);
}
}
else if (opts.data) {
opts.body = opts.data;
}
opts.validateStatus = opts.validateStatus || this.validateStatus;
opts.responseType = opts.responseType || 'unknown';
if (!preparedHeaders.has('accept') && opts.responseType === 'json') {
preparedHeaders.set('accept', 'application/json');
}
const proxy = opts.proxy ||
process?.env?.HTTPS_PROXY ||
process?.env?.https_proxy ||
process?.env?.HTTP_PROXY ||
process?.env?.http_proxy;
if (opts.agent) {
// don't do any of the following options - use the user-provided agent.
}
else if (proxy && this.#urlMayUseProxy(opts.url, opts.noProxy)) {
const HttpsProxyAgent = await _a.#getProxyAgent();
if (this.agentCache.has(proxy)) {
opts.agent = this.agentCache.get(proxy);
}
else {
opts.agent = new HttpsProxyAgent(proxy, {
cert: opts.cert,
key: opts.key,
});
this.agentCache.set(proxy, opts.agent);
}
}
else if (opts.cert && opts.key) {
// Configure client for mTLS
if (this.agentCache.has(opts.key)) {
opts.agent = this.agentCache.get(opts.key);
}
else {
opts.agent = new https_1.Agent({
cert: opts.cert,
key: opts.key,
});
this.agentCache.set(opts.key, opts.agent);
}
}
if (typeof opts.errorRedactor !== 'function' &&
opts.errorRedactor !== false) {
opts.errorRedactor = common_js_1.defaultErrorRedactor;
}
if (opts.body && !('duplex' in opts)) {
/**
* required for Node.js and the type isn't available today
* @link https://github.com/nodejs/node/issues/46221
* @link https://github.com/microsoft/TypeScript-DOM-lib-generator/issues/1483
*/
opts.duplex = 'half';
}
this.#appendTimeoutToSignal(opts);
return Object.assign(opts, {
headers: preparedHeaders,
url: opts.url instanceof URL ? opts.url : new URL(opts.url),
});
}
#appendTimeoutToSignal(opts) {
if (opts.timeout) {
const timeoutSignal = AbortSignal.timeout(opts.timeout);
if (opts.signal && !opts.signal.aborted) {
opts.signal = AbortSignal.any([opts.signal, timeoutSignal]);
}
else {
opts.signal = timeoutSignal;
}
}
}
/**
* By default, throw for any non-2xx status code
* @param status status code from the HTTP response
*/
validateStatus(status) {
return status >= 200 && status < 300;
}
/**
* Attempts to parse a response by looking at the Content-Type header.
* @param {Response} response the HTTP response.
* @returns a promise that resolves to the response data.
*/
async getResponseDataFromContentType(response) {
let contentType = response.headers.get('Content-Type');
if (contentType === null) {
// Maintain existing functionality by calling text()
return response.text();
}
contentType = contentType.toLowerCase();
if (contentType.includes('application/json')) {
let data = await response.text();
try {
data = JSON.parse(data);
}
catch {
// continue
}
return data;
}
else if (contentType.match(/^text\//)) {
return response.text();
}
else {
// If the content type is something not easily handled, just return the raw data (blob)
return response.blob();
}
}
/**
* Creates an async generator that yields the pieces of a multipart/related request body.
* This implementation follows the spec: https://www.ietf.org/rfc/rfc2387.txt. However, recursive
* multipart/related requests are not currently supported.
*
* @param {GaxiosMultipartOptions[]} multipartOptions the pieces to turn into a multipart/related body.
* @param {string} boundary the boundary string to be placed between each part.
*/
async *getMultipartRequest(multipartOptions, boundary) {
const finale = `--${boundary}--`;
for (const currentPart of multipartOptions) {
const partContentType = currentPart.headers.get('Content-Type') || 'application/octet-stream';
const preamble = `--${boundary}\r\nContent-Type: ${partContentType}\r\n\r\n`;
yield preamble;
if (typeof currentPart.content === 'string') {
yield currentPart.content;
}
else {
yield* currentPart.content;
}
yield '\r\n';
}
yield finale;
}
/**
* A cache for the lazily-loaded proxy agent.
*
* Should use {@link Gaxios[#getProxyAgent]} to retrieve.
*/
// using `import` to dynamically import the types here
static #proxyAgent;
/**
* A cache for the lazily-loaded fetch library.
*
* Should use {@link Gaxios[#getFetch]} to retrieve.
*/
//
static #fetch;
/**
* Imports, caches, and returns a proxy agent - if not already imported
*
* @returns A proxy agent
*/
static async #getProxyAgent() {
this.#proxyAgent ||= (await import('https-proxy-agent')).HttpsProxyAgent;
return this.#proxyAgent;
}
static async #getFetch() {
const hasWindow = typeof window !== 'undefined' && !!window;
this.#fetch ||= hasWindow
? window.fetch
: (await import('node-fetch')).default;
return this.#fetch;
}
/**
* Merges headers.
* If the base headers do not exist a new `Headers` object will be returned.
*
* @remarks
*
* Using this utility can be helpful when the headers are not known to exist:
* - if they exist as `Headers`, that instance will be used
* - it improves performance and allows users to use their existing references to their `Headers`
* - if they exist in another form (`HeadersInit`), they will be used to create a new `Headers` object
* - if the base headers do not exist a new `Headers` object will be created
*
* @param base headers to append/overwrite to
* @param append headers to append/overwrite with
* @returns the base headers instance with merged `Headers`
*/
static mergeHeaders(base, ...append) {
base = base instanceof Headers ? base : new Headers(base);
for (const headers of append) {
const add = headers instanceof Headers ? headers : new Headers(headers);
add.forEach((value, key) => {
// set-cookie is the only header that would repeat.
// A bit of background: https://developer.mozilla.org/en-US/docs/Web/API/Headers/getSetCookie
key === 'set-cookie' ? base.append(key, value) : base.set(key, value);
});
}
return base;
}
}
exports.Gaxios = Gaxios;
_a = Gaxios;
//# sourceMappingURL=gaxios.js.map

1
node_modules/gaxios/build/cjs/src/gaxios.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

15
node_modules/gaxios/build/cjs/src/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,15 @@
import { GaxiosOptions } from './common.js';
import { Gaxios } from './gaxios.js';
export { GaxiosError, GaxiosPromise, GaxiosResponse, GaxiosOptionsPrepared, RetryConfig, } from './common.js';
export { Gaxios, GaxiosOptions };
export * from './interceptor.js';
/**
* The default instance used when the `request` method is directly
* invoked.
*/
export declare const instance: Gaxios;
/**
* Make an HTTP request using the given options.
* @param opts Options for the request
*/
export declare function request<T>(opts: GaxiosOptions): Promise<import("./common.js").GaxiosResponse<T>>;

48
node_modules/gaxios/build/cjs/src/index.js generated vendored Normal file
View File

@@ -0,0 +1,48 @@
"use strict";
// Copyright 2018 Google LLC
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.instance = exports.Gaxios = exports.GaxiosError = void 0;
exports.request = request;
const gaxios_js_1 = require("./gaxios.js");
Object.defineProperty(exports, "Gaxios", { enumerable: true, get: function () { return gaxios_js_1.Gaxios; } });
var common_js_1 = require("./common.js");
Object.defineProperty(exports, "GaxiosError", { enumerable: true, get: function () { return common_js_1.GaxiosError; } });
__exportStar(require("./interceptor.js"), exports);
/**
* The default instance used when the `request` method is directly
* invoked.
*/
exports.instance = new gaxios_js_1.Gaxios();
/**
* Make an HTTP request using the given options.
* @param opts Options for the request
*/
async function request(opts) {
return exports.instance.request(opts);
}
//# sourceMappingURL=index.js.map

1
node_modules/gaxios/build/cjs/src/index.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":";AAAA,4BAA4B;AAC5B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,gDAAgD;AAChD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;;;;;;;;;;;;;;;;AAyBjC,0BAEC;AAxBD,2CAAmC;AAS3B,uFATA,kBAAM,OASA;AAPd,yCAMqB;AALnB,wGAAA,WAAW,OAAA;AAOb,mDAAiC;AAEjC;;;GAGG;AACU,QAAA,QAAQ,GAAG,IAAI,kBAAM,EAAE,CAAC;AAErC;;;GAGG;AACI,KAAK,UAAU,OAAO,CAAI,IAAmB;IAClD,OAAO,gBAAQ,CAAC,OAAO,CAAI,IAAI,CAAC,CAAC;AACnC,CAAC"}

25
node_modules/gaxios/build/cjs/src/interceptor.d.ts generated vendored Normal file
View File

@@ -0,0 +1,25 @@
import { GaxiosError, GaxiosOptionsPrepared, GaxiosResponse } from './common.js';
/**
* Interceptors that can be run for requests or responses. These interceptors run asynchronously.
*/
export interface GaxiosInterceptor<T extends GaxiosOptionsPrepared | GaxiosResponse> {
/**
* Function to be run when applying an interceptor.
*
* @param {T} configOrResponse The current configuration or response.
* @returns {Promise<T>} Promise that resolves to the modified set of options or response.
*/
resolved?: (configOrResponse: T) => Promise<T>;
/**
* Function to be run if the previous call to resolved throws / rejects or the request results in an invalid status
* as determined by the call to validateStatus.
*
* @param {GaxiosError} err The error thrown from the previously called resolved function.
*/
rejected?: (err: GaxiosError) => void;
}
/**
* Class to manage collections of GaxiosInterceptors for both requests and responses.
*/
export declare class GaxiosInterceptorManager<T extends GaxiosOptionsPrepared | GaxiosResponse> extends Set<GaxiosInterceptor<T> | null> {
}

22
node_modules/gaxios/build/cjs/src/interceptor.js generated vendored Normal file
View File

@@ -0,0 +1,22 @@
"use strict";
// Copyright 2024 Google LLC
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
Object.defineProperty(exports, "__esModule", { value: true });
exports.GaxiosInterceptorManager = void 0;
/**
* Class to manage collections of GaxiosInterceptors for both requests and responses.
*/
class GaxiosInterceptorManager extends Set {
}
exports.GaxiosInterceptorManager = GaxiosInterceptorManager;
//# sourceMappingURL=interceptor.js.map

1
node_modules/gaxios/build/cjs/src/interceptor.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"interceptor.js","sourceRoot":"","sources":["../../../src/interceptor.ts"],"names":[],"mappings":";AAAA,4BAA4B;AAC5B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,gDAAgD;AAChD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;;AA0BjC;;GAEG;AACH,MAAa,wBAEX,SAAQ,GAAgC;CAAG;AAF7C,4DAE6C"}

8
node_modules/gaxios/build/cjs/src/retry.d.ts generated vendored Normal file
View File

@@ -0,0 +1,8 @@
import { GaxiosError } from './common.js';
export declare function getRetryConfig(err: GaxiosError): Promise<{
shouldRetry: boolean;
config?: undefined;
} | {
shouldRetry: boolean;
config: import("./common.js").GaxiosOptionsPrepared;
}>;

165
node_modules/gaxios/build/cjs/src/retry.js generated vendored Normal file
View File

@@ -0,0 +1,165 @@
"use strict";
// Copyright 2018 Google LLC
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
Object.defineProperty(exports, "__esModule", { value: true });
exports.getRetryConfig = getRetryConfig;
async function getRetryConfig(err) {
let config = getConfig(err);
if (!err || !err.config || (!config && !err.config.retry)) {
return { shouldRetry: false };
}
config = config || {};
config.currentRetryAttempt = config.currentRetryAttempt || 0;
config.retry =
config.retry === undefined || config.retry === null ? 3 : config.retry;
config.httpMethodsToRetry = config.httpMethodsToRetry || [
'GET',
'HEAD',
'PUT',
'OPTIONS',
'DELETE',
];
config.noResponseRetries =
config.noResponseRetries === undefined || config.noResponseRetries === null
? 2
: config.noResponseRetries;
config.retryDelayMultiplier = config.retryDelayMultiplier
? config.retryDelayMultiplier
: 2;
config.timeOfFirstRequest = config.timeOfFirstRequest
? config.timeOfFirstRequest
: Date.now();
config.totalTimeout = config.totalTimeout
? config.totalTimeout
: Number.MAX_SAFE_INTEGER;
config.maxRetryDelay = config.maxRetryDelay
? config.maxRetryDelay
: Number.MAX_SAFE_INTEGER;
// If this wasn't in the list of status codes where we want
// to automatically retry, return.
const retryRanges = [
// https://en.wikipedia.org/wiki/List_of_HTTP_status_codes
// 1xx - Retry (Informational, request still processing)
// 2xx - Do not retry (Success)
// 3xx - Do not retry (Redirect)
// 4xx - Do not retry (Client errors)
// 408 - Retry ("Request Timeout")
// 429 - Retry ("Too Many Requests")
// 5xx - Retry (Server errors)
[100, 199],
[408, 408],
[429, 429],
[500, 599],
];
config.statusCodesToRetry = config.statusCodesToRetry || retryRanges;
// Put the config back into the err
err.config.retryConfig = config;
// Determine if we should retry the request
const shouldRetryFn = config.shouldRetry || shouldRetryRequest;
if (!(await shouldRetryFn(err))) {
return { shouldRetry: false, config: err.config };
}
const delay = getNextRetryDelay(config);
// We're going to retry! Increment the counter.
err.config.retryConfig.currentRetryAttempt += 1;
// Create a promise that invokes the retry after the backOffDelay
const backoff = config.retryBackoff
? config.retryBackoff(err, delay)
: new Promise(resolve => {
setTimeout(resolve, delay);
});
// Notify the user if they added an `onRetryAttempt` handler
if (config.onRetryAttempt) {
await config.onRetryAttempt(err);
}
// Return the promise in which recalls Gaxios to retry the request
await backoff;
return { shouldRetry: true, config: err.config };
}
/**
* Determine based on config if we should retry the request.
* @param err The GaxiosError passed to the interceptor.
*/
function shouldRetryRequest(err) {
const config = getConfig(err);
if ((err.config.signal?.aborted && err.code !== 'TimeoutError') ||
err.code === 'AbortError') {
return false;
}
// If there's no config, or retries are disabled, return.
if (!config || config.retry === 0) {
return false;
}
// Check if this error has no response (ETIMEDOUT, ENOTFOUND, etc)
if (!err.response &&
(config.currentRetryAttempt || 0) >= config.noResponseRetries) {
return false;
}
// Only retry with configured HttpMethods.
if (!config.httpMethodsToRetry ||
!config.httpMethodsToRetry.includes(err.config.method?.toUpperCase() || 'GET')) {
return false;
}
// If this wasn't in the list of status codes where we want
// to automatically retry, return.
if (err.response && err.response.status) {
let isInRange = false;
for (const [min, max] of config.statusCodesToRetry) {
const status = err.response.status;
if (status >= min && status <= max) {
isInRange = true;
break;
}
}
if (!isInRange) {
return false;
}
}
// If we are out of retry attempts, return
config.currentRetryAttempt = config.currentRetryAttempt || 0;
if (config.currentRetryAttempt >= config.retry) {
return false;
}
return true;
}
/**
* Acquire the raxConfig object from an GaxiosError if available.
* @param err The Gaxios error with a config object.
*/
function getConfig(err) {
if (err && err.config && err.config.retryConfig) {
return err.config.retryConfig;
}
return;
}
/**
* Gets the delay to wait before the next retry.
*
* @param {RetryConfig} config The current set of retry options
* @returns {number} the amount of ms to wait before the next retry attempt.
*/
function getNextRetryDelay(config) {
// Calculate time to wait with exponential backoff.
// If this is the first retry, look for a configured retryDelay.
const retryDelay = config.currentRetryAttempt
? 0
: (config.retryDelay ?? 100);
// Formula: retryDelay + ((retryDelayMultiplier^currentRetryAttempt - 1 / 2) * 1000)
const calculatedDelay = retryDelay +
((Math.pow(config.retryDelayMultiplier, config.currentRetryAttempt) - 1) /
2) *
1000;
const maxAllowableDelay = config.totalTimeout - (Date.now() - config.timeOfFirstRequest);
return Math.min(calculatedDelay, maxAllowableDelay, config.maxRetryDelay);
}
//# sourceMappingURL=retry.js.map

1
node_modules/gaxios/build/cjs/src/retry.js.map generated vendored Norm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MAAM,CAAC,UAAU,IAAI,GAAG,CAAC,CAAC;IAC/B,oFAAoF;IACpF,MAAM,eAAe,GACnB,UAAU;QACV,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,oBAAqB,EAAE,MAAM,CAAC,mBAAoB,CAAC,GAAG,CAAC,CAAC;YACxE,CAAC,CAAC;YACF,IAAI,CAAC;IACT,MAAM,iBAAiB,GACrB,MAAM,CAAC,YAAa,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,kBAAmB,CAAC,CAAC;IAEnE,OAAO,IAAI,CAAC,GAAG,CAAC,eAAe,EAAE,iBAAiB,EAAE,MAAM,CAAC,aAAc,CAAC,CAAC;AAC7E,CAAC"}

16
node_modules/gaxios/build/cjs/src/util.cjs generated vendored Normal file
View File

@@ -0,0 +1,16 @@
"use strict";
// Copyright 2023 Google LLC
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
const pkg = require('../../../package.json');
module.exports = { pkg };
//# sourceMappingURL=util.cjs.map

1
node_modules/gaxios/build/cjs/src/util.cjs.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"util.cjs","sourceRoot":"","sources":["../../../src/util.cts"],"names":[],"mappings":";AAAA,4BAA4B;AAC5B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,gDAAgD;AAChD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,MAAM,GAAG,GAGL,OAAO,CAAC,uBAAuB,CAAC,CAAC;AAErC,iBAAS,EAAC,GAAG,EAAC,CAAC"}

7
node_modules/gaxios/build/cjs/src/util.d.cts generated vendored Normal file
View File

@@ -0,0 +1,7 @@
declare const _default: {
pkg: {
name: string;
version: string;
};
};
export = _default;

View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1,128 @@
"use strict";
// Copyright 2019 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const assert_1 = __importDefault(require("assert"));
const child_process_1 = require("child_process");
const fs_1 = __importDefault(require("fs"));
const mv_1 = __importDefault(require("mv"));
const ncp_1 = __importDefault(require("ncp"));
const path_1 = __importDefault(require("path"));
const tmp_1 = __importDefault(require("tmp"));
const util_1 = require("util");
const mocha_1 = require("mocha");
const pack_n_play_1 = require("pack-n-play");
const node_http_1 = require("node:http");
const util_cjs_1 = __importDefault(require("../src/util.cjs"));
/**
* Optionally keep the staging directory between tests.
*/
const KEEP_STAGING_DIRECTORY = false;
const mvp = (0, util_1.promisify)(mv_1.default);
const ncpp = (0, util_1.promisify)(ncp_1.default);
const pkg = util_cjs_1.default.pkg;
const exec = (0, util_1.promisify)(child_process_1.execFile);
(0, mocha_1.describe)('📦 pack and install', () => {
let stagingDir;
let stagingPath;
(0, mocha_1.before)(() => {
stagingDir = tmp_1.default.dirSync({
keep: KEEP_STAGING_DIRECTORY,
unsafeCleanup: true,
});
stagingPath = stagingDir.name;
});
(0, mocha_1.after)('cleanup staging', () => {
if (!KEEP_STAGING_DIRECTORY) {
stagingDir.removeCallback();
}
});
(0, mocha_1.describe)('pack-n-play', () => {
let server;
let url;
(0, mocha_1.before)(async () => {
server = (0, node_http_1.createServer)((req, res) => {
res.writeHead(200, { 'content-type': 'text/plain' });
res.end(`Hello, ${req.headers['user-agent'] || 'World'}`);
});
await new Promise((resolve, reject) => {
server.on('error', reject);
server.listen(0, resolve);
});
const address = server.address();
if (typeof address === 'string') {
url = address;
}
else {
const base = new URL('http://localhost');
base.host = address.address;
base.port = address.port.toString();
url = base.toString();
}
});
(0, mocha_1.after)(() => {
server.close();
});
(0, mocha_1.it)('supports ESM', async () => {
await (0, pack_n_play_1.packNTest)({
sample: {
description: 'import as ESM',
esm: `
import {Gaxios} from 'gaxios';
const gaxios = new Gaxios();
await gaxios.request({url: '${url}'});
`,
},
});
});
(0, mocha_1.it)('supports CJS', async () => {
await (0, pack_n_play_1.packNTest)({
sample: {
description: 'require as CJS',
cjs: `
const {Gaxios} = require('gaxios');
const gaxios = new Gaxios();
gaxios.request({url: '${url}'}).then(console.log);
`,
},
});
});
});
(0, mocha_1.describe)('webpack', () => {
/**
* Create a staging directory with temp fixtures used to test on a fresh
* application.
*/
(0, mocha_1.before)('pack and install', async () => {
await exec('npm', ['pack']);
const tarball = `${pkg.name}-${pkg.version}.tgz`;
await mvp(tarball, `${stagingPath}/gaxios.tgz`);
await ncpp('system-test/fixtures/sample', `${stagingPath}/`);
await exec('npm', ['install'], { cwd: `${stagingPath}/` });
});
(0, mocha_1.it)('should be able to webpack the library', async () => {
// we expect npm install is executed in the before hook
await exec('npx', ['webpack'], { cwd: `${stagingPath}/` });
const bundle = path_1.default.join(stagingPath, 'dist', 'bundle.min.js');
const stat = fs_1.default.statSync(bundle);
(0, assert_1.default)(stat.size < 256 * 1024);
}).timeout(20000);
});
});
//# sourceMappingURL=test.install.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"test.install.js","sourceRoot":"","sources":["../../../system-test/test.install.ts"],"names":[],"mappings":";AAAA,4BAA4B;AAC5B,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE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AAO,CAAC,KAAK,CAAC,CAAC;IACpB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}

1
node_modules/gaxios/build/cjs/test/test.getch.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export {};

1444
node_modules/gaxios/build/cjs/test/test.getch.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

1
node_modules/gaxios/build/cjs/test/test.getch.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

1
node_modules/gaxios/build/cjs/test/test.index.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export {};

61
node_modules/gaxios/build/cjs/test/test.index.js generated vendored Normal file
View File

@@ -0,0 +1,61 @@
"use strict";
// Copyright 2018 Google LLC
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const assert_1 = __importDefault(require("assert"));
const mocha_1 = require("mocha");
const main = __importStar(require("../src/index.js"));
(0, mocha_1.describe)('📝 main exports', () => {
(0, mocha_1.it)('should export all the types', () => {
(0, assert_1.default)(main.Gaxios);
(0, assert_1.default)(main.GaxiosError);
(0, assert_1.default)(main.GaxiosInterceptorManager);
});
});
//# sourceMappingURL=test.index.js.map

1
node_modules/gaxios/build/cjs/test/test.index.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"test.index.js","sourceRoot":"","sources":["../../../test/test.index.ts"],"names":[],"mappings":";AAAA,4BAA4B;AAC5B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,gDAAgD;AAChD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEjC,oDAA4B;AAC5B,iCAAmC;AACnC,sDAAwC;AAExC,IAAA,gBAAQ,EAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,IAAA,UAAE,EAAC,6BAA6B,EAAE,GAAG,EAAE;QACrC,IAAA,gBAAM,EAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACpB,IAAA,gBAAM,EAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACzB,IAAA,gBAAM,EAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}

1
node_modules/gaxios/build/cjs/test/test.retry.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export {};

367
node_modules/gaxios/build/cjs/test/test.retry.js generated vendored Normal file
View File

@@ -0,0 +1,367 @@
"use strict";
// Copyright 2018 Google LLC
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const assert_1 = __importDefault(require("assert"));
const nock_1 = __importDefault(require("nock"));
const mocha_1 = require("mocha");
const index_js_1 = require("../src/index.js");
nock_1.default.disableNetConnect();
const url = 'https://example.com';
function getConfig(err) {
const e = err;
if (e && e.config && e.config.retryConfig) {
return e.config.retryConfig;
}
return;
}
(0, mocha_1.afterEach)(() => {
nock_1.default.cleanAll();
});
(0, mocha_1.describe)('🛸 retry & exponential backoff', () => {
(0, mocha_1.it)('should provide an expected set of defaults', async () => {
const scope = (0, nock_1.default)(url).get('/').times(4).reply(500);
await assert_1.default.rejects((0, index_js_1.request)({ url, retry: true }), (e) => {
scope.done();
const config = getConfig(e);
if (!config) {
assert_1.default.fail('no config available');
}
assert_1.default.strictEqual(config.currentRetryAttempt, 3);
assert_1.default.strictEqual(config.retry, 3);
assert_1.default.strictEqual(config.noResponseRetries, 2);
const expectedMethods = ['GET', 'HEAD', 'PUT', 'OPTIONS', 'DELETE'];
for (const method of config.httpMethodsToRetry) {
(0, assert_1.default)(expectedMethods.indexOf(method) > -1);
}
const expectedStatusCodes = [
[100, 199],
[408, 408],
[429, 429],
[500, 599],
];
const statusCodesToRetry = config.statusCodesToRetry;
for (let i = 0; i < statusCodesToRetry.length; i++) {
const [min, max] = statusCodesToRetry[i];
const [expMin, expMax] = expectedStatusCodes[i];
assert_1.default.strictEqual(min, expMin);
assert_1.default.strictEqual(max, expMax);
}
return true;
});
});
(0, mocha_1.it)('should retry on 500 on the main export', async () => {
const body = { buttered: '🥖' };
const scopes = [
(0, nock_1.default)(url).get('/').reply(500),
(0, nock_1.default)(url).get('/').reply(200, body),
];
const res = await (0, index_js_1.request)({
url,
retry: true,
});
assert_1.default.deepStrictEqual(res.data, body);
scopes.forEach(s => s.done());
});
(0, mocha_1.it)('should not retry on a post', async () => {
const scope = (0, nock_1.default)(url).post('/').reply(500);
await assert_1.default.rejects((0, index_js_1.request)({ url, method: 'POST', retry: true }), (e) => {
const config = getConfig(e);
return config.currentRetryAttempt === 0;
});
scope.done();
});
(0, mocha_1.it)('should not retry if user aborted request', async () => {
const ac = new AbortController();
const config = {
method: 'GET',
url: 'https://google.com',
signal: ac.signal,
retryConfig: { retry: 10, noResponseRetries: 10 },
};
const req = (0, index_js_1.request)(config);
ac.abort();
try {
await req;
throw Error('unreachable');
}
catch (err) {
(0, assert_1.default)(err instanceof index_js_1.GaxiosError);
(0, assert_1.default)(err.config);
assert_1.default.strictEqual(err.config.retryConfig?.currentRetryAttempt, 0);
}
});
(0, mocha_1.it)('should retry at least the configured number of times', async () => {
const body = { dippy: '🥚' };
const scopes = [
(0, nock_1.default)(url).get('/').times(3).reply(500),
(0, nock_1.default)(url).get('/').reply(200, body),
];
const cfg = { url, retryConfig: { retry: 4 } };
const res = await (0, index_js_1.request)(cfg);
assert_1.default.deepStrictEqual(res.data, body);
scopes.forEach(s => s.done());
});
(0, mocha_1.it)('should not retry more than configured', async () => {
const scope = (0, nock_1.default)(url).get('/').twice().reply(500);
const cfg = { url, retryConfig: { retry: 1 } };
await assert_1.default.rejects((0, index_js_1.request)(cfg), (e) => {
return getConfig(e).currentRetryAttempt === 1;
});
scope.done();
});
(0, mocha_1.it)('should not retry on 4xx errors', async () => {
const scope = (0, nock_1.default)(url).get('/').reply(404);
await assert_1.default.rejects((0, index_js_1.request)({ url, retry: true }), (e) => {
const cfg = getConfig(e);
return cfg.currentRetryAttempt === 0;
});
scope.done();
});
(0, mocha_1.it)('should retain the baseURL on retry', async () => {
const body = { pumpkin: '🥧' };
const url = '/path';
const baseURL = 'http://example.com';
const scope = (0, nock_1.default)(baseURL).get(url).reply(500).get(url).reply(200, body);
const gaxios = new index_js_1.Gaxios({ baseURL });
const res = await gaxios.request({
url,
retry: true,
});
assert_1.default.deepStrictEqual(res.data, body);
scope.done();
});
(0, mocha_1.it)('should not retry if retries set to 0', async () => {
const scope = (0, nock_1.default)(url).get('/').reply(500);
const cfg = { url, retryConfig: { retry: 0 } };
await assert_1.default.rejects((0, index_js_1.request)(cfg), (e) => {
const cfg = getConfig(e);
return cfg.currentRetryAttempt === 0;
});
scope.done();
});
(0, mocha_1.it)('should notify on retry attempts', async () => {
const body = { buttered: '🥖' };
const scopes = [
(0, nock_1.default)(url).get('/').reply(500),
(0, nock_1.default)(url).get('/').reply(200, body),
];
let flipped = false;
const config = {
url,
retryConfig: {
onRetryAttempt: err => {
const cfg = getConfig(err);
assert_1.default.strictEqual(cfg.currentRetryAttempt, 1);
flipped = true;
},
},
};
await (0, index_js_1.request)(config);
assert_1.default.strictEqual(flipped, true);
scopes.forEach(s => s.done());
});
(0, mocha_1.it)('accepts async onRetryAttempt handler', async () => {
const body = { buttered: '🥖' };
const scopes = [
(0, nock_1.default)(url).get('/').reply(500),
(0, nock_1.default)(url).get('/').reply(200, body),
];
let flipped = false;
const config = {
url,
retryConfig: {
onRetryAttempt: async (err) => {
const cfg = getConfig(err);
assert_1.default.strictEqual(cfg.currentRetryAttempt, 1);
flipped = true;
},
},
};
await (0, index_js_1.request)(config);
assert_1.default.strictEqual(flipped, true);
scopes.forEach(s => s.done());
});
(0, mocha_1.it)('should support overriding the shouldRetry method', async () => {
const scope = (0, nock_1.default)(url).get('/').reply(500);
const config = {
url,
retryConfig: {
shouldRetry: () => {
return false;
},
},
};
await assert_1.default.rejects((0, index_js_1.request)(config), (e) => {
const cfg = getConfig(e);
return cfg.currentRetryAttempt === 0;
});
scope.done();
});
(0, mocha_1.it)('should support overriding the shouldRetry method with a promise', async () => {
const scope = (0, nock_1.default)(url).get('/').reply(500);
const config = {
url,
retryConfig: {
shouldRetry: async () => {
return false;
},
},
};
await assert_1.default.rejects((0, index_js_1.request)(config), (e) => {
const cfg = getConfig(e);
return cfg.currentRetryAttempt === 0;
});
scope.done();
});
(0, mocha_1.it)('should retry on ENOTFOUND', async () => {
const body = { spicy: '🌮' };
const scopes = [
(0, nock_1.default)(url).get('/').reply(500, { code: 'ENOTFOUND' }),
(0, nock_1.default)(url).get('/').reply(200, body),
];
const res = await (0, index_js_1.request)({ url, retry: true });
assert_1.default.deepStrictEqual(res.data, body);
scopes.forEach(s => s.done());
});
(0, mocha_1.it)('should retry on ETIMEDOUT', async () => {
const body = { sizzling: '🥓' };
const scopes = [
(0, nock_1.default)(url).get('/').reply(500, { code: 'ETIMEDOUT' }),
(0, nock_1.default)(url).get('/').reply(200, body),
];
const res = await (0, index_js_1.request)({ url, retry: true });
assert_1.default.deepStrictEqual(res.data, body);
scopes.forEach(s => s.done());
});
(0, mocha_1.it)('should allow configuring noResponseRetries', async () => {
// `nock` is not listening, therefore it should fail
const config = { url, retryConfig: { noResponseRetries: 0 } };
await assert_1.default.rejects((0, index_js_1.request)(config), (e) => {
return (e.code === 'ENETUNREACH' &&
e.config.retryConfig?.currentRetryAttempt === 0);
});
});
(0, mocha_1.it)('should delay the initial retry by 100ms by default', async () => {
const scope = (0, nock_1.default)(url).get('/').reply(500).get('/').reply(200, {});
const start = Date.now();
await (0, index_js_1.request)({
url,
retry: true,
});
const delay = Date.now() - start;
assert_1.default.ok(delay > 100 && delay < 199);
scope.done();
});
(0, mocha_1.it)('should respect the retryDelay if configured', async () => {
const scope = (0, nock_1.default)(url).get('/').reply(500).get('/').reply(200, {});
const start = Date.now();
await (0, index_js_1.request)({
url,
retryConfig: {
retryDelay: 500,
},
});
const delay = Date.now() - start;
assert_1.default.ok(delay > 500 && delay < 599);
scope.done();
});
(0, mocha_1.it)('should respect retryDelayMultiplier if configured', async () => {
const scope = (0, nock_1.default)(url)
.get('/')
.reply(500)
.get('/')
.reply(500)
.get('/')
.reply(200, {});
const start = Date.now();
await (0, index_js_1.request)({
url,
retryConfig: {
retryDelayMultiplier: 3,
},
});
const delay = Date.now() - start;
assert_1.default.ok(delay > 1000 && delay < 1999);
scope.done();
});
(0, mocha_1.it)('should respect totalTimeout if configured', async () => {
const scope = (0, nock_1.default)(url)
.get('/')
.reply(500)
.get('/')
.reply(500)
.get('/')
.reply(200, {});
const start = Date.now();
await (0, index_js_1.request)({
url,
retryConfig: {
retryDelayMultiplier: 100,
totalTimeout: 3000,
},
});
const delay = Date.now() - start;
assert_1.default.ok(delay > 3000 && delay < 3999);
scope.done();
});
(0, mocha_1.it)('should respect maxRetryDelay if configured', async () => {
const scope = (0, nock_1.default)(url)
.get('/')
.reply(500)
.get('/')
.reply(500)
.get('/')
.reply(200, {});
const start = Date.now();
await (0, index_js_1.request)({
url,
retryConfig: {
retryDelayMultiplier: 100,
maxRetryDelay: 4000,
},
});
const delay = Date.now() - start;
assert_1.default.ok(delay > 4000 && delay < 4999);
scope.done();
});
(0, mocha_1.it)('should retry on `timeout`', async () => {
const scope = (0, nock_1.default)(url).get('/').delay(500).reply(400).get('/').reply(204);
const gaxios = new index_js_1.Gaxios();
const timeout = 100;
async function onRetryAttempt({ config, message }) {
(0, assert_1.default)(config.signal?.reason instanceof DOMException);
assert_1.default.equal(config.signal.reason.name, 'TimeoutError');
assert_1.default.match(message, /timeout/i);
// increase timeout to something higher to avoid time-sensitive flaky tests
// note: the second `nock` GET is not delayed like the first one
config.timeout = 10000;
}
const res = await gaxios.request({
url,
timeout,
// NOTE: `node-fetch` does not yet support `TimeoutError` - testing with native `fetch` for now.
fetchImplementation: fetch,
retryConfig: {
onRetryAttempt,
},
});
assert_1.default.equal(res.status, 204);
assert_1.default.equal(res.config?.retryConfig?.currentRetryAttempt, 1);
scope.done();
});
});
//# sourceMappingURL=test.retry.js.map

1
node_modules/gaxios/build/cjs/test/test.retry.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1,71 @@
// Copyright 2019 Google, LLC
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import express from 'express';
import { execFile } from 'child_process';
import * as multiparty from 'multiparty';
import cors from 'cors';
import { promisify } from 'util';
const port = 7172;
const exec = promisify(execFile);
async function listen(app, port) {
return new Promise((resolve, reject) => {
const server = app.listen(port, (err) => {
if (err) {
reject(err);
}
resolve(server);
});
});
}
// Starts a web server that browser tests will use, then runs actual browser
// tests.
async function main() {
const app = express();
app.use(cors());
app.post('/path', (req, res) => {
if (req.header('origin')) {
res.set('Access-Control-Allow-Origin', req.header('origin'));
}
const form = new multiparty.Form({ autoFields: true });
form.parse(req, (err, fields) => {
if (err) {
res.status(500).send({ message: err.message });
}
else {
res.status(200).send(fields.null);
}
});
});
app.get('/path', (req, res) => {
if (req.header('origin')) {
res.set('Access-Control-Allow-Origin', req.header('origin'));
}
res.send('response');
});
app.get('/querystring', (req, res) => {
if (req.header('origin')) {
res.set('Access-Control-Allow-Origin', req.header('origin'));
}
const query = req.query.query;
res.send(query || '');
});
const server = await listen(app, port);
console.log(`[http server] I'm listening on port ${port}! Starting karma.`);
await exec('karma', ['start']);
server.close();
console.log(`[http server] Karma has finished! I'm no longer listening on port ${port}!`);
}
main().catch(err => {
console.log('Error:', err);
});
//# sourceMappingURL=browser-test-runner.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"browser-test-runner.js","sourceRoot":"","sources":["../../../browser-test/browser-test-runner.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AAC;IAEH,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACvC,OAAO,CAAC,GAAG,CAAC,uCAAuC,IAAI,mBAAmB,CAAC,CAAC;IAC5E,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAC/B,MAAM,CAAC,KAAK,EAAE,CAAC;IACf,OAAO,CAAC,GAAG,CACT,qEAAqE,IAAI,GAAG,CAC7E,CAAC;AACJ,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;IACjB,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;AAC7B,CAAC,CAAC,CAAC"}

View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1,76 @@
// Copyright 2019 Google, LLC
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import assert from 'assert';
import { describe, it } from 'mocha';
import { request } from '../src/index';
const port = 7172; // should match the port defined in `webserver.ts`
describe('💻 browser tests', () => {
it('should just work from browser', async () => {
const result = await request({ url: `http://localhost:${port}/path` });
assert.strictEqual(result.status, 200);
assert.strictEqual(result.data, 'response');
});
it('should pass querystring parameters from browser', async () => {
const result = await request({
url: `http://localhost:${port}/querystring`,
params: { query: 'value' },
});
assert.strictEqual(result.status, 200);
assert.strictEqual(result.data, 'value');
});
it('should allow passing browser fetch explicitly', async () => {
const result = await request({
url: `http://localhost:${port}/path`,
fetchImplementation: window.fetch,
});
assert.strictEqual(result.status, 200);
});
it('should support multipart post from the browser', async () => {
const headers = new Headers();
const multipart = [
{
'Content-Type': 'application/json',
body: JSON.stringify({ hello: 'world' }),
},
{
'Content-Type': 'text/plain',
body: 'hello world!',
},
];
const boundary = globalThis?.crypto.randomUUID() || (await import('crypto')).randomUUID();
const finale = `--${boundary}--`;
headers.set('Content-Type', `multipart/related; boundary=${boundary}`);
let content = '';
for (const part of multipart) {
const preamble = `--${boundary}\r\nContent-Type: ${part['Content-Type']}\r\n\r\n`;
// rStream.push(preamble);
content += preamble;
if (typeof part.body === 'string') {
content += part.body;
content += '\r\n';
}
}
content += finale;
const result = await request({
headers,
data: content,
method: 'POST',
url: `http://localhost:${port}/path`,
});
assert.strictEqual(result.status, 200);
const parts = result.data;
assert.strictEqual(parts[0], '{"hello":"world"}');
assert.strictEqual(parts[1], 'hello world!');
});
});
//# sourceMappingURL=test.browser.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"test.browser.js","sourceRoot":"","sources":["../../../browser-test/test.browser.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAC7B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,gDAAgD;AAChD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAC,QAAQ,EAAE,EAAE,EAAC,MAAM,OAAO,CAAC;AACnC,OAAO,EAAC,OAAO,EAAC,MAAM,cAAc,CAAC;AACrC,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,kDAAkD;AAErE,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,EAAE,CAAC,+BAA+B,EAAE,KAAK,IAAI,EAAE;QAC7C,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,EAAC,GAAG,EAAE,oBAAoB,IAAI,OAAO,EAAC,CAAC,CAAC;QACrE,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QACvC,MAAM,CAAC,WAAW,CAAC,MAAM,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,GAAG,CAAC,cAAc,EAAE,+BAA+B,QAAQ,EAAE,CAAC,CAAC;QAEvE,IAAI,OAAO,GAAG,EAAE,CAAC;QACjB,KAAK,MAAM,IAAI,IAAI,SAAS,EAAE,CAAC;YAC7B,MAAM,QAAQ,GAAG,KAAK,QAAQ,qBAAqB,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC;YAClF,0BAA0B;YAC1B,OAAO,IAAI,QAAQ,CAAC;YACpB,IAAI,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;gBAClC,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC;gBACrB,OAAO,IAAI,MAAM,CAAC;YACpB,CAAC;QACH,CAAC;QACD,OAAO,IAAI,MAAM,CAAC;QAClB,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC;YAC3B,OAAO;YACP,IAAI,EAAE,OAAO;YACb,MAAM,EAAE,MAAM;YACd,GAAG,EAAE,oBAAoB,IAAI,OAAO;SACrC,CAAC,CAAC;QACH,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QACvC,MAAM,KAAK,GAAG,MAAM,CAAC,IAAgB,CAAC;QACtC,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,mBAAmB,CAAC,CAAC;QAClD,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}

1
node_modules/gaxios/build/esm/package.json generated vendored Normal file
View File

@@ -0,0 +1 @@
{"type": "module"}

329
node_modules/gaxios/build/esm/src/common.d.ts generated vendored Normal file
View File

@@ -0,0 +1,329 @@
import { Agent } from 'http';
import { Readable } from 'stream';
/**
* TypeScript does not have this type available globally - however `@types/node` includes `undici-types`, which has it:
* - https://www.npmjs.com/package/@types/node/v/18.19.59?activeTab=dependencies
*
* Additionally, this is the TypeScript pattern for type sniffing and `import("undici-types")` is pretty common:
* - https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/node/globals.d.ts
*/
type _BodyInit = typeof globalThis extends {
BodyInit: infer T;
} ? T : import('undici-types').BodyInit;
/**
* An AIP-193 conforming error interface.
*
* @see {@link https://google.aip.dev/193#http11json-representation AIP-193}
*
* @param res the response object
* @returns the extracted error information
*/
export interface AIPErrorInterface {
error: {
code: number;
message: string;
status: string;
details?: {}[];
};
}
/**
* Support `instanceof` operator for `GaxiosError`s in different versions of this library.
*
* @see {@link GaxiosError[Symbol.hasInstance]}
*/
export declare const GAXIOS_ERROR_SYMBOL: unique symbol;
export declare class GaxiosError<T = ReturnType<JSON['parse']>> extends Error {
config: GaxiosOptionsPrepared;
response?: GaxiosResponse<T> | undefined;
/**
* An error code.
* Can be a system error code, DOMException error name, or any error's 'code' property where it is a `string`.
*
* It is only a `number` when the cause is sourced from an API-level error (AIP-193).
*
* @see {@link https://nodejs.org/api/errors.html#errorcode error.code}
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/DOMException#error_names DOMException#error_names}
* @see {@link https://google.aip.dev/193#http11json-representation AIP-193}
*
* @example
* 'ECONNRESET'
*
* @example
* 'TimeoutError'
*
* @example
* 500
*/
code?: string | number;
/**
* An HTTP Status code.
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Response/status Response#status}
*
* @example
* 500
*/
status?: number;
/**
* @deprecated use {@link GaxiosError.cause} instead.
*
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause Error#cause}
*
* @privateRemarks
*
* We will want to remove this property later as the modern `cause` property is better suited
* for displaying and relaying nested errors. Keeping this here makes the resulting
* error log larger than it needs to be.
*
*/
error?: Error | NodeJS.ErrnoException;
/**
* Support `instanceof` operator for `GaxiosError` across builds/duplicated files.
*
* @see {@link GAXIOS_ERROR_SYMBOL}
* @see {@link GaxiosError[Symbol.hasInstance]}
* @see {@link https://github.com/microsoft/TypeScript/issues/13965#issuecomment-278570200}
* @see {@link https://stackoverflow.com/questions/46618852/require-and-instanceof}
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/@@hasInstance#reverting_to_default_instanceof_behavior}
*/
[GAXIOS_ERROR_SYMBOL]: string;
/**
* Support `instanceof` operator for `GaxiosError` across builds/duplicated files.
*
* @see {@link GAXIOS_ERROR_SYMBOL}
* @see {@link GaxiosError[GAXIOS_ERROR_SYMBOL]}
*/
static [Symbol.hasInstance](instance: unknown): boolean;
constructor(message: string, config: GaxiosOptionsPrepared, response?: GaxiosResponse<T> | undefined, cause?: unknown);
}
type GaxiosResponseData = ReturnType<JSON['parse']> | GaxiosOptionsPrepared['data'];
export type GaxiosPromise<T = GaxiosResponseData> = Promise<GaxiosResponse<T>>;
export interface GaxiosResponse<T = GaxiosResponseData> extends Response {
config: GaxiosOptionsPrepared;
data: T;
}
export interface GaxiosMultipartOptions {
headers: Headers;
content: string | Readable;
}
/**
* Request options that are used to form the request.
*/
export interface GaxiosOptions extends RequestInit {
/**
* Optional method to override making the actual HTTP request. Useful
* for writing tests.
*/
adapter?: <T = GaxiosResponseData>(options: GaxiosOptionsPrepared, defaultAdapter: (options: GaxiosOptionsPrepared) => GaxiosPromise<T>) => GaxiosPromise<T>;
url?: string | URL;
baseURL?: string | URL;
/**
* The data to send in the {@link RequestInit.body} of the request. Objects will be
* serialized as JSON, except for:
* - `ArrayBuffer`
* - `Blob`
* - `Buffer` (Node.js)
* - `DataView`
* - `File`
* - `FormData`
* - `ReadableStream`
* - `stream.Readable` (Node.js)
* - strings
* - `TypedArray` (e.g. `Uint8Array`, `BigInt64Array`)
* - `URLSearchParams`
* - all other objects where:
* - headers['Content-Type'] === 'application/x-www-form-urlencoded' (serialized as `URLSearchParams`)
*
* In all other cases, if you would like to prevent `application/json` as the
* default `Content-Type` header you must provide a string or readable stream
* rather than an object, e.g.:
*
* ```ts
* {data: JSON.stringify({some: 'data'})}
* {data: fs.readFile('./some-data.jpeg')}
* ```
*/
data?: _BodyInit | ArrayBuffer | Blob | Buffer | DataView | File | FormData | ReadableStream | Readable | string | ArrayBufferView | URLSearchParams | {};
/**
* The maximum size of the http response `Content-Length` in bytes allowed.
*/
maxContentLength?: number;
/**
* The maximum number of redirects to follow. Defaults to 20.
*
* @deprecated non-spec. Should use `20` if enabled per-spec: https://fetch.spec.whatwg.org/#http-redirect-fetch
*/
maxRedirects?: number;
/**
* @deprecated non-spec. Should use `20` if enabled per-spec: https://fetch.spec.whatwg.org/#http-redirect-fetch
*/
follow?: number;
/**
* A collection of parts to send as a `Content-Type: multipart/related` request.
*
* This is passed to {@link RequestInit.body}.
*/
multipart?: GaxiosMultipartOptions[];
params?: GaxiosResponseData;
/**
* @deprecated Use {@link URLSearchParams} instead and pass this directly to {@link GaxiosOptions.data `data`}.
*/
paramsSerializer?: (params: {
[index: string]: string | number;
}) => string;
/**
* A timeout for the request, in milliseconds. No timeout by default.
*/
timeout?: number;
/**
* @deprecated ignored
*/
onUploadProgress?: (progressEvent: GaxiosResponseData) => void;
/**
* If the `fetchImplementation` is native `fetch`, the
* stream is a `ReadableStream`, otherwise `readable.Stream`
*/
responseType?: 'arraybuffer' | 'blob' | 'json' | 'text' | 'stream' | 'unknown';
agent?: Agent | ((parsedUrl: URL) => Agent);
validateStatus?: (status: number) => boolean;
retryConfig?: RetryConfig;
retry?: boolean;
/**
* @deprecated non-spec. https://github.com/node-fetch/node-fetch/issues/1438
*/
size?: number;
/**
* Implementation of `fetch` to use when making the API call. Will use `fetch` by default.
*
* @example
*
* let customFetchCalled = false;
* const myFetch = (...args: Parameters<typeof fetch>) => {
* customFetchCalled = true;
* return fetch(...args);
* };
*
* {fetchImplementation: myFetch};
*/
fetchImplementation?: typeof fetch;
cert?: string;
key?: string;
/**
* An optional proxy to use for requests.
* Available via `process.env.HTTP_PROXY` and `process.env.HTTPS_PROXY` as well - with a preference for the this config option when multiple are available.
* The {@link GaxiosOptions.agent `agent`} option overrides this.
*
* @see {@link GaxiosOptions.noProxy}
* @see {@link GaxiosOptions.agent}
*/
proxy?: string | URL;
/**
* A list for excluding traffic for proxies.
* Available via `process.env.NO_PROXY` as well as a common-separated list of strings - merged with any local `noProxy` rules.
*
* - When provided a string, it is matched by
* - Wildcard `*.` and `.` matching are available. (e.g. `.example.com` or `*.example.com`)
* - When provided a URL, it is matched by the `.origin` property.
* - For example, requesting `https://example.com` with the following `noProxy`s would result in a no proxy use:
* - new URL('https://example.com')
* - new URL('https://example.com:443')
* - The following would be used with a proxy:
* - new URL('http://example.com:80')
* - new URL('https://example.com:8443')
* - When provided a regular expression it is used to match the stringified URL
*
* @see {@link GaxiosOptions.proxy}
*/
noProxy?: (string | URL | RegExp)[];
/**
* An experimental error redactor.
*
* @remarks
*
* This does not replace the requirement for an active Data Loss Prevention (DLP) provider. For DLP suggestions, see:
* - https://cloud.google.com/sensitive-data-protection/docs/redacting-sensitive-data#dlp_deidentify_replace_infotype-nodejs
* - https://cloud.google.com/sensitive-data-protection/docs/infotypes-reference#credentials_and_secrets
*
* @experimental
*/
errorRedactor?: typeof defaultErrorRedactor | false;
}
export interface GaxiosOptionsPrepared extends GaxiosOptions {
headers: Headers;
url: URL;
}
/**
* Gaxios retry configuration.
*/
export interface RetryConfig {
/**
* The number of times to retry the request. Defaults to 3.
*/
retry?: number;
/**
* The number of retries already attempted.
*/
currentRetryAttempt?: number;
/**
* The amount of time to initially delay the retry, in ms. Defaults to 100ms.
*/
retryDelay?: number;
/**
* The HTTP Methods that will be automatically retried.
* Defaults to ['GET','PUT','HEAD','OPTIONS','DELETE']
*/
httpMethodsToRetry?: string[];
/**
* The HTTP response status codes that will automatically be retried.
* Defaults to: [[100, 199], [408, 408], [429, 429], [500, 599]]
*/
statusCodesToRetry?: number[][];
/**
* Function to invoke when a retry attempt is made.
*/
onRetryAttempt?: (err: GaxiosError) => Promise<void> | void;
/**
* Function to invoke which determines if you should retry
*/
shouldRetry?: (err: GaxiosError) => Promise<boolean> | boolean;
/**
* When there is no response, the number of retries to attempt. Defaults to 2.
*/
noResponseRetries?: number;
/**
* Function to invoke which returns a promise. After the promise resolves,
* the retry will be triggered. If provided, this will be used in-place of
* the `retryDelay`
*/
retryBackoff?: (err: GaxiosError, defaultBackoffMs: number) => Promise<void>;
/**
* Time that the initial request was made. Users should not set this directly.
*/
timeOfFirstRequest?: number;
/**
* The length of time to keep retrying in ms. The last sleep period will
* be shortened as necessary, so that the last retry runs at deadline (and not
* considerably beyond it). The total time starting from when the initial
* request is sent, after which an error will be returned, regardless of the
* retrying attempts made meanwhile. Defaults to Number.MAX_SAFE_INTEGER indicating to effectively
* ignore totalTimeout.
*/
totalTimeout?: number;
maxRetryDelay?: number;
retryDelayMultiplier?: number;
}
/**
* An experimental error redactor.
*
* @param config Config to potentially redact properties of
* @param response Config to potentially redact properties of
*
* @experimental
*/
export declare function defaultErrorRedactor<O extends GaxiosOptionsPrepared, R extends GaxiosResponse<GaxiosResponseData>>(data: {
config?: O;
response?: R;
}): {
config?: O;
response?: R;
};
export {};

303
node_modules/gaxios/build/esm/src/common.js generated vendored Normal file
View File

@@ -0,0 +1,303 @@
// Copyright 2018 Google LLC
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import extend from 'extend';
import util from './util.cjs';
const pkg = util.pkg;
/**
* Support `instanceof` operator for `GaxiosError`s in different versions of this library.
*
* @see {@link GaxiosError[Symbol.hasInstance]}
*/
export const GAXIOS_ERROR_SYMBOL = Symbol.for(`${pkg.name}-gaxios-error`);
export class GaxiosError extends Error {
config;
response;
/**
* An error code.
* Can be a system error code, DOMException error name, or any error's 'code' property where it is a `string`.
*
* It is only a `number` when the cause is sourced from an API-level error (AIP-193).
*
* @see {@link https://nodejs.org/api/errors.html#errorcode error.code}
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/DOMException#error_names DOMException#error_names}
* @see {@link https://google.aip.dev/193#http11json-representation AIP-193}
*
* @example
* 'ECONNRESET'
*
* @example
* 'TimeoutError'
*
* @example
* 500
*/
code;
/**
* An HTTP Status code.
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Response/status Response#status}
*
* @example
* 500
*/
status;
/**
* @deprecated use {@link GaxiosError.cause} instead.
*
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause Error#cause}
*
* @privateRemarks
*
* We will want to remove this property later as the modern `cause` property is better suited
* for displaying and relaying nested errors. Keeping this here makes the resulting
* error log larger than it needs to be.
*
*/
error;
/**
* Support `instanceof` operator for `GaxiosError` across builds/duplicated files.
*
* @see {@link GAXIOS_ERROR_SYMBOL}
* @see {@link GaxiosError[Symbol.hasInstance]}
* @see {@link https://github.com/microsoft/TypeScript/issues/13965#issuecomment-278570200}
* @see {@link https://stackoverflow.com/questions/46618852/require-and-instanceof}
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/@@hasInstance#reverting_to_default_instanceof_behavior}
*/
[GAXIOS_ERROR_SYMBOL] = pkg.version;
/**
* Support `instanceof` operator for `GaxiosError` across builds/duplicated files.
*
* @see {@link GAXIOS_ERROR_SYMBOL}
* @see {@link GaxiosError[GAXIOS_ERROR_SYMBOL]}
*/
static [Symbol.hasInstance](instance) {
if (instance &&
typeof instance === 'object' &&
GAXIOS_ERROR_SYMBOL in instance &&
instance[GAXIOS_ERROR_SYMBOL] === pkg.version) {
return true;
}
// fallback to native
return Function.prototype[Symbol.hasInstance].call(GaxiosError, instance);
}
constructor(message, config, response, cause) {
super(message, { cause });
this.config = config;
this.response = response;
this.error = cause instanceof Error ? cause : undefined;
// deep-copy config as we do not want to mutate
// the existing config for future retries/use
this.config = extend(true, {}, config);
if (this.response) {
this.response.config = extend(true, {}, this.response.config);
}
if (this.response) {
try {
this.response.data = translateData(this.config.responseType,
// workaround for `node-fetch`'s `.data` deprecation...
this.response?.bodyUsed ? this.response?.data : undefined);
}
catch {
// best effort - don't throw an error within an error
// we could set `this.response.config.responseType = 'unknown'`, but
// that would mutate future calls with this config object.
}
this.status = this.response.status;
}
if (cause instanceof DOMException) {
// The DOMException's equivalent to code is its name
// E.g.: name = `TimeoutError`, code = number
// https://developer.mozilla.org/en-US/docs/Web/API/DOMException/name
this.code = cause.name;
}
else if (cause &&
typeof cause === 'object' &&
'code' in cause &&
(typeof cause.code === 'string' || typeof cause.code === 'number')) {
this.code = cause.code;
}
}
/**
* An AIP-193 conforming error extractor.
*
* @see {@link https://google.aip.dev/193#http11json-representation AIP-193}
*
* @internal
* @expiremental
*
* @param res the response object
* @returns the extracted error information
*/
static extractAPIErrorFromResponse(res, defaultErrorMessage = 'The request failed') {
let message = defaultErrorMessage;
// Use res.data as the error message
if (typeof res.data === 'string') {
message = res.data;
}
if (res.data &&
typeof res.data === 'object' &&
'error' in res.data &&
res.data.error &&
!res.ok) {
if (typeof res.data.error === 'string') {
return {
message: res.data.error,
code: res.status,
status: res.statusText,
};
}
if (typeof res.data.error === 'object') {
// extract status from data.message
message =
'message' in res.data.error &&
typeof res.data.error.message === 'string'
? res.data.error.message
: message;
// extract status from data.error
const status = 'status' in res.data.error &&
typeof res.data.error.status === 'string'
? res.data.error.status
: res.statusText;
// extract code from data.error
const code = 'code' in res.data.error && typeof res.data.error.code === 'number'
? res.data.error.code
: res.status;
if ('errors' in res.data.error &&
Array.isArray(res.data.error.errors)) {
const errorMessages = [];
for (const e of res.data.error.errors) {
if (typeof e === 'object' &&
'message' in e &&
typeof e.message === 'string') {
errorMessages.push(e.message);
}
}
return Object.assign({
message: errorMessages.join('\n') || message,
code,
status,
}, res.data.error);
}
return Object.assign({
message,
code,
status,
}, res.data.error);
}
}
return {
message,
code: res.status,
status: res.statusText,
};
}
}
function translateData(responseType, data) {
switch (responseType) {
case 'stream':
return data;
case 'json':
return JSON.parse(JSON.stringify(data));
case 'arraybuffer':
return JSON.parse(Buffer.from(data).toString('utf8'));
case 'blob':
return JSON.parse(data.text());
default:
return data;
}
}
/**
* An experimental error redactor.
*
* @param config Config to potentially redact properties of
* @param response Config to potentially redact properties of
*
* @experimental
*/
export function defaultErrorRedactor(data) {
const REDACT = '<<REDACTED> - See `errorRedactor` option in `gaxios` for configuration>.';
function redactHeaders(headers) {
if (!headers)
return;
headers.forEach((_, key) => {
// any casing of `Authentication`
// any casing of `Authorization`
// anything containing secret, such as 'client secret'
if (/^authentication$/i.test(key) ||
/^authorization$/i.test(key) ||
/secret/i.test(key))
headers.set(key, REDACT);
});
}
function redactString(obj, key) {
if (typeof obj === 'object' &&
obj !== null &&
typeof obj[key] === 'string') {
const text = obj[key];
if (/grant_type=/i.test(text) ||
/assertion=/i.test(text) ||
/secret/i.test(text)) {
obj[key] = REDACT;
}
}
}
function redactObject(obj) {
if (!obj || typeof obj !== 'object') {
return;
}
else if (obj instanceof FormData ||
obj instanceof URLSearchParams ||
// support `node-fetch` FormData/URLSearchParams
('forEach' in obj && 'set' in obj)) {
obj.forEach((_, key) => {
if (['grant_type', 'assertion'].includes(key) || /secret/.test(key)) {
obj.set(key, REDACT);
}
});
}
else {
if ('grant_type' in obj) {
obj['grant_type'] = REDACT;
}
if ('assertion' in obj) {
obj['assertion'] = REDACT;
}
if ('client_secret' in obj) {
obj['client_secret'] = REDACT;
}
}
}
if (data.config) {
redactHeaders(data.config.headers);
redactString(data.config, 'data');
redactObject(data.config.data);
redactString(data.config, 'body');
redactObject(data.config.body);
if (data.config.url.searchParams.has('token')) {
data.config.url.searchParams.set('token', REDACT);
}
if (data.config.url.searchParams.has('client_secret')) {
data.config.url.searchParams.set('client_secret', REDACT);
}
}
if (data.response) {
defaultErrorRedactor({ config: data.response.config });
redactHeaders(data.response.headers);
// workaround for `node-fetch`'s `.data` deprecation...
if (data.response.bodyUsed) {
redactString(data.response, 'data');
redactObject(data.response.data);
}
}
return data;
}
//# sourceMappingURL=common.js.map

1
node_modules/gaxios/build/esm/src/common.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

104
node_modules/gaxios/build/esm/src/gaxios.d.ts generated vendored Normal file
View File

@@ -0,0 +1,104 @@
import { Agent } from 'http';
import { GaxiosOptions, GaxiosOptionsPrepared, GaxiosPromise, GaxiosResponse } from './common.js';
import { GaxiosInterceptorManager } from './interceptor.js';
/**
* An interface for enforcing `fetch`-type compliance.
*
* @remarks
*
* This provides type guarantees during build-time, ensuring the `fetch` method is 1:1
* compatible with the `fetch` API.
*/
interface FetchCompliance {
fetch: typeof fetch;
}
export declare class Gaxios implements FetchCompliance {
#private;
protected agentCache: Map<string | URL, Agent | ((parsedUrl: URL) => Agent)>;
/**
* Default HTTP options that will be used for every HTTP request.
*/
defaults: GaxiosOptions;
/**
* Interceptors
*/
interceptors: {
request: GaxiosInterceptorManager<GaxiosOptionsPrepared>;
response: GaxiosInterceptorManager<GaxiosResponse>;
};
/**
* The Gaxios class is responsible for making HTTP requests.
* @param defaults The default set of options to be used for this instance.
*/
constructor(defaults?: GaxiosOptions);
/**
* A {@link fetch `fetch`} compliant API for {@link Gaxios}.
*
* @remarks
*
* This is useful as a drop-in replacement for `fetch` API usage.
*
* @example
*
* ```ts
* const gaxios = new Gaxios();
* const myFetch: typeof fetch = (...args) => gaxios.fetch(...args);
* await myFetch('https://example.com');
* ```
*
* @param args `fetch` API or `Gaxios#request` parameters
* @returns the {@link Response} with Gaxios-added properties
*/
fetch<T = unknown>(...args: Parameters<typeof fetch> | Parameters<Gaxios['request']>): GaxiosPromise<T>;
/**
* Perform an HTTP request with the given options.
* @param opts Set of HTTP options that will be used for this HTTP request.
*/
request<T = ReturnType<JSON['parse']>>(opts?: GaxiosOptions): GaxiosPromise<T>;
private _defaultAdapter;
/**
* Internal, retryable version of the `request` method.
* @param opts Set of HTTP options that will be used for this HTTP request.
*/
protected _request<T = ReturnType<JSON['parse']>>(opts: GaxiosOptionsPrepared): GaxiosPromise<T>;
private getResponseData;
/**
* By default, throw for any non-2xx status code
* @param status status code from the HTTP response
*/
private validateStatus;
/**
* Attempts to parse a response by looking at the Content-Type header.
* @param {Response} response the HTTP response.
* @returns a promise that resolves to the response data.
*/
private getResponseDataFromContentType;
/**
* Creates an async generator that yields the pieces of a multipart/related request body.
* This implementation follows the spec: https://www.ietf.org/rfc/rfc2387.txt. However, recursive
* multipart/related requests are not currently supported.
*
* @param {GaxiosMultipartOptions[]} multipartOptions the pieces to turn into a multipart/related body.
* @param {string} boundary the boundary string to be placed between each part.
*/
private getMultipartRequest;
/**
* Merges headers.
* If the base headers do not exist a new `Headers` object will be returned.
*
* @remarks
*
* Using this utility can be helpful when the headers are not known to exist:
* - if they exist as `Headers`, that instance will be used
* - it improves performance and allows users to use their existing references to their `Headers`
* - if they exist in another form (`HeadersInit`), they will be used to create a new `Headers` object
* - if the base headers do not exist a new `Headers` object will be created
*
* @param base headers to append/overwrite to
* @param append headers to append/overwrite with
* @returns the base headers instance with merged `Headers`
*/
static mergeHeaders(base?: HeadersInit, ...append: HeadersInit[]): Headers;
}
type HeadersInit = ConstructorParameters<typeof Headers>[0];
export {};

557
node_modules/gaxios/build/esm/src/gaxios.js generated vendored Normal file
View File

@@ -0,0 +1,557 @@
// Copyright 2018 Google LLC
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
var _a;
import extend from 'extend';
import { Agent as HTTPSAgent } from 'https';
import { GaxiosError, defaultErrorRedactor, } from './common.js';
import { getRetryConfig } from './retry.js';
import { Readable } from 'stream';
import { GaxiosInterceptorManager } from './interceptor.js';
const randomUUID = async () => globalThis.crypto?.randomUUID() || (await import('crypto')).randomUUID();
const HTTP_STATUS_NO_CONTENT = 204;
export class Gaxios {
agentCache = new Map();
/**
* Default HTTP options that will be used for every HTTP request.
*/
defaults;
/**
* Interceptors
*/
interceptors;
/**
* The Gaxios class is responsible for making HTTP requests.
* @param defaults The default set of options to be used for this instance.
*/
constructor(defaults) {
this.defaults = defaults || {};
this.interceptors = {
request: new GaxiosInterceptorManager(),
response: new GaxiosInterceptorManager(),
};
}
/**
* A {@link fetch `fetch`} compliant API for {@link Gaxios}.
*
* @remarks
*
* This is useful as a drop-in replacement for `fetch` API usage.
*
* @example
*
* ```ts
* const gaxios = new Gaxios();
* const myFetch: typeof fetch = (...args) => gaxios.fetch(...args);
* await myFetch('https://example.com');
* ```
*
* @param args `fetch` API or `Gaxios#request` parameters
* @returns the {@link Response} with Gaxios-added properties
*/
fetch(...args) {
// Up to 2 parameters in either overload
const input = args[0];
const init = args[1];
let url = undefined;
const headers = new Headers();
// prepare URL
if (typeof input === 'string') {
url = new URL(input);
}
else if (input instanceof URL) {
url = input;
}
else if (input && input.url) {
url = new URL(input.url);
}
// prepare headers
if (input && typeof input === 'object' && 'headers' in input) {
_a.mergeHeaders(headers, input.headers);
}
if (init) {
_a.mergeHeaders(headers, new Headers(init.headers));
}
// prepare request
if (typeof input === 'object' && !(input instanceof URL)) {
// input must have been a non-URL object
return this.request({ ...init, ...input, headers, url });
}
else {
// input must have been a string or URL
return this.request({ ...init, headers, url });
}
}
/**
* Perform an HTTP request with the given options.
* @param opts Set of HTTP options that will be used for this HTTP request.
*/
async request(opts = {}) {
let prepared = await this.#prepareRequest(opts);
prepared = await this.#applyRequestInterceptors(prepared);
return this.#applyResponseInterceptors(this._request(prepared));
}
async _defaultAdapter(config) {
const fetchImpl = config.fetchImplementation ||
this.defaults.fetchImplementation ||
(await _a.#getFetch());
// node-fetch v3 warns when `data` is present
// https://github.com/node-fetch/node-fetch/issues/1000
const preparedOpts = { ...config };
delete preparedOpts.data;
const res = (await fetchImpl(config.url, preparedOpts));
const data = await this.getResponseData(config, res);
if (!Object.getOwnPropertyDescriptor(res, 'data')?.configurable) {
// Work-around for `node-fetch` v3 as accessing `data` would otherwise throw
Object.defineProperties(res, {
data: {
configurable: true,
writable: true,
enumerable: true,
value: data,
},
});
}
// Keep object as an instance of `Response`
return Object.assign(res, { config, data });
}
/**
* Internal, retryable version of the `request` method.
* @param opts Set of HTTP options that will be used for this HTTP request.
*/
async _request(opts) {
try {
let translatedResponse;
if (opts.adapter) {
translatedResponse = await opts.adapter(opts, this._defaultAdapter.bind(this));
}
else {
translatedResponse = await this._defaultAdapter(opts);
}
if (!opts.validateStatus(translatedResponse.status)) {
if (opts.responseType === 'stream') {
const response = [];
for await (const chunk of translatedResponse.data) {
response.push(chunk);
}
translatedResponse.data = response.toString();
}
const errorInfo = GaxiosError.extractAPIErrorFromResponse(translatedResponse, `Request failed with status code ${translatedResponse.status}`);
throw new GaxiosError(errorInfo?.message, opts, translatedResponse, errorInfo);
}
return translatedResponse;
}
catch (e) {
let err;
if (e instanceof GaxiosError) {
err = e;
}
else if (e instanceof Error) {
err = new GaxiosError(e.message, opts, undefined, e);
}
else {
err = new GaxiosError('Unexpected Gaxios Error', opts, undefined, e);
}
const { shouldRetry, config } = await getRetryConfig(err);
if (shouldRetry && config) {
err.config.retryConfig.currentRetryAttempt =
config.retryConfig.currentRetryAttempt;
// The error's config could be redacted - therefore we only want to
// copy the retry state over to the existing config
opts.retryConfig = err.config?.retryConfig;
// re-prepare timeout for the next request
this.#appendTimeoutToSignal(opts);
return this._request(opts);
}
if (opts.errorRedactor) {
opts.errorRedactor(err);
}
throw err;
}
}
async getResponseData(opts, res) {
if (res.status === HTTP_STATUS_NO_CONTENT) {
return '';
}
if (opts.maxContentLength &&
res.headers.has('content-length') &&
opts.maxContentLength <
Number.parseInt(res.headers?.get('content-length') || '')) {
throw new GaxiosError("Response's `Content-Length` is over the limit.", opts, Object.assign(res, { config: opts }));
}
switch (opts.responseType) {
case 'stream':
return res.body;
case 'json': {
const data = await res.text();
try {
return JSON.parse(data);
}
catch {
return data;
}
}
case 'arraybuffer':
return res.arrayBuffer();
case 'blob':
return res.blob();
case 'text':
return res.text();
default:
return this.getResponseDataFromContentType(res);
}
}
#urlMayUseProxy(url, noProxy = []) {
const candidate = new URL(url);
const noProxyList = [...noProxy];
const noProxyEnvList = (process.env.NO_PROXY ?? process.env.no_proxy)?.split(',') || [];
for (const rule of noProxyEnvList) {
noProxyList.push(rule.trim());
}
for (const rule of noProxyList) {
// Match regex
if (rule instanceof RegExp) {
if (rule.test(candidate.toString())) {
return false;
}
}
// Match URL
else if (rule instanceof URL) {
if (rule.origin === candidate.origin) {
return false;
}
}
// Match string regex
else if (rule.startsWith('*.') || rule.startsWith('.')) {
const cleanedRule = rule.replace(/^\*\./, '.');
if (candidate.hostname.endsWith(cleanedRule)) {
return false;
}
}
// Basic string match
else if (rule === candidate.origin ||
rule === candidate.hostname ||
rule === candidate.href) {
return false;
}
}
return true;
}
/**
* Applies the request interceptors. The request interceptors are applied after the
* call to prepareRequest is completed.
*
* @param {GaxiosOptionsPrepared} options The current set of options.
*
* @returns {Promise<GaxiosOptionsPrepared>} Promise that resolves to the set of options or response after interceptors are applied.
*/
async #applyRequestInterceptors(options) {
let promiseChain = Promise.resolve(options);
for (const interceptor of this.interceptors.request.values()) {
if (interceptor) {
promiseChain = promiseChain.then(interceptor.resolved, interceptor.rejected);
}
}
return promiseChain;
}
/**
* Applies the response interceptors. The response interceptors are applied after the
* call to request is made.
*
* @param {GaxiosOptionsPrepared} options The current set of options.
*
* @returns {Promise<GaxiosOptionsPrepared>} Promise that resolves to the set of options or response after interceptors are applied.
*/
async #applyResponseInterceptors(response) {
let promiseChain = Promise.resolve(response);
for (const interceptor of this.interceptors.response.values()) {
if (interceptor) {
promiseChain = promiseChain.then(interceptor.resolved, interceptor.rejected);
}
}
return promiseChain;
}
/**
* Validates the options, merges them with defaults, and prepare request.
*
* @param options The original options passed from the client.
* @returns Prepared options, ready to make a request
*/
async #prepareRequest(options) {
// Prepare Headers - copy in order to not mutate the original objects
const preparedHeaders = new Headers(this.defaults.headers);
_a.mergeHeaders(preparedHeaders, options.headers);
// Merge options
const opts = extend(true, {}, this.defaults, options);
if (!opts.url) {
throw new Error('URL is required.');
}
if (opts.baseURL) {
opts.url = new URL(opts.url, opts.baseURL);
}
// don't modify the properties of a default or provided URL
opts.url = new URL(opts.url);
if (opts.params) {
if (opts.paramsSerializer) {
let additionalQueryParams = opts.paramsSerializer(opts.params);
if (additionalQueryParams.startsWith('?')) {
additionalQueryParams = additionalQueryParams.slice(1);
}
const prefix = opts.url.toString().includes('?') ? '&' : '?';
opts.url = opts.url + prefix + additionalQueryParams;
}
else {
const url = opts.url instanceof URL ? opts.url : new URL(opts.url);
for (const [key, value] of new URLSearchParams(opts.params)) {
url.searchParams.append(key, value);
}
opts.url = url;
}
}
if (typeof options.maxContentLength === 'number') {
opts.size = options.maxContentLength;
}
if (typeof options.maxRedirects === 'number') {
opts.follow = options.maxRedirects;
}
const shouldDirectlyPassData = typeof opts.data === 'string' ||
opts.data instanceof ArrayBuffer ||
opts.data instanceof Blob ||
// Node 18 does not have a global `File` object
(globalThis.File && opts.data instanceof File) ||
opts.data instanceof FormData ||
opts.data instanceof Readable ||
opts.data instanceof ReadableStream ||
opts.data instanceof String ||
opts.data instanceof URLSearchParams ||
ArrayBuffer.isView(opts.data) || // `Buffer` (Node.js), `DataView`, `TypedArray`
/**
* @deprecated `node-fetch` or another third-party's request types
*/
['Blob', 'File', 'FormData'].includes(opts.data?.constructor?.name || '');
if (opts.multipart?.length) {
const boundary = await randomUUID();
preparedHeaders.set('content-type', `multipart/related; boundary=${boundary}`);
opts.body = Readable.from(this.getMultipartRequest(opts.multipart, boundary));
}
else if (shouldDirectlyPassData) {
opts.body = opts.data;
}
else if (typeof opts.data === 'object') {
if (preparedHeaders.get('Content-Type') ===
'application/x-www-form-urlencoded') {
// If www-form-urlencoded content type has been set, but data is
// provided as an object, serialize the content
opts.body = opts.paramsSerializer
? opts.paramsSerializer(opts.data)
: new URLSearchParams(opts.data);
}
else {
if (!preparedHeaders.has('content-type')) {
preparedHeaders.set('content-type', 'application/json');
}
opts.body = JSON.stringify(opts.data);
}
}
else if (opts.data) {
opts.body = opts.data;
}
opts.validateStatus = opts.validateStatus || this.validateStatus;
opts.responseType = opts.responseType || 'unknown';
if (!preparedHeaders.has('accept') && opts.responseType === 'json') {
preparedHeaders.set('accept', 'application/json');
}
const proxy = opts.proxy ||
process?.env?.HTTPS_PROXY ||
process?.env?.https_proxy ||
process?.env?.HTTP_PROXY ||
process?.env?.http_proxy;
if (opts.agent) {
// don't do any of the following options - use the user-provided agent.
}
else if (proxy && this.#urlMayUseProxy(opts.url, opts.noProxy)) {
const HttpsProxyAgent = await _a.#getProxyAgent();
if (this.agentCache.has(proxy)) {
opts.agent = this.agentCache.get(proxy);
}
else {
opts.agent = new HttpsProxyAgent(proxy, {
cert: opts.cert,
key: opts.key,
});
this.agentCache.set(proxy, opts.agent);
}
}
else if (opts.cert && opts.key) {
// Configure client for mTLS
if (this.agentCache.has(opts.key)) {
opts.agent = this.agentCache.get(opts.key);
}
else {
opts.agent = new HTTPSAgent({
cert: opts.cert,
key: opts.key,
});
this.agentCache.set(opts.key, opts.agent);
}
}
if (typeof opts.errorRedactor !== 'function' &&
opts.errorRedactor !== false) {
opts.errorRedactor = defaultErrorRedactor;
}
if (opts.body && !('duplex' in opts)) {
/**
* required for Node.js and the type isn't available today
* @link https://github.com/nodejs/node/issues/46221
* @link https://github.com/microsoft/TypeScript-DOM-lib-generator/issues/1483
*/
opts.duplex = 'half';
}
this.#appendTimeoutToSignal(opts);
return Object.assign(opts, {
headers: preparedHeaders,
url: opts.url instanceof URL ? opts.url : new URL(opts.url),
});
}
#appendTimeoutToSignal(opts) {
if (opts.timeout) {
const timeoutSignal = AbortSignal.timeout(opts.timeout);
if (opts.signal && !opts.signal.aborted) {
opts.signal = AbortSignal.any([opts.signal, timeoutSignal]);
}
else {
opts.signal = timeoutSignal;
}
}
}
/**
* By default, throw for any non-2xx status code
* @param status status code from the HTTP response
*/
validateStatus(status) {
return status >= 200 && status < 300;
}
/**
* Attempts to parse a response by looking at the Content-Type header.
* @param {Response} response the HTTP response.
* @returns a promise that resolves to the response data.
*/
async getResponseDataFromContentType(response) {
let contentType = response.headers.get('Content-Type');
if (contentType === null) {
// Maintain existing functionality by calling text()
return response.text();
}
contentType = contentType.toLowerCase();
if (contentType.includes('application/json')) {
let data = await response.text();
try {
data = JSON.parse(data);
}
catch {
// continue
}
return data;
}
else if (contentType.match(/^text\//)) {
return response.text();
}
else {
// If the content type is something not easily handled, just return the raw data (blob)
return response.blob();
}
}
/**
* Creates an async generator that yields the pieces of a multipart/related request body.
* This implementation follows the spec: https://www.ietf.org/rfc/rfc2387.txt. However, recursive
* multipart/related requests are not currently supported.
*
* @param {GaxiosMultipartOptions[]} multipartOptions the pieces to turn into a multipart/related body.
* @param {string} boundary the boundary string to be placed between each part.
*/
async *getMultipartRequest(multipartOptions, boundary) {
const finale = `--${boundary}--`;
for (const currentPart of multipartOptions) {
const partContentType = currentPart.headers.get('Content-Type') || 'application/octet-stream';
const preamble = `--${boundary}\r\nContent-Type: ${partContentType}\r\n\r\n`;
yield preamble;
if (typeof currentPart.content === 'string') {
yield currentPart.content;
}
else {
yield* currentPart.content;
}
yield '\r\n';
}
yield finale;
}
/**
* A cache for the lazily-loaded proxy agent.
*
* Should use {@link Gaxios[#getProxyAgent]} to retrieve.
*/
// using `import` to dynamically import the types here
static #proxyAgent;
/**
* A cache for the lazily-loaded fetch library.
*
* Should use {@link Gaxios[#getFetch]} to retrieve.
*/
//
static #fetch;
/**
* Imports, caches, and returns a proxy agent - if not already imported
*
* @returns A proxy agent
*/
static async #getProxyAgent() {
this.#proxyAgent ||= (await import('https-proxy-agent')).HttpsProxyAgent;
return this.#proxyAgent;
}
static async #getFetch() {
const hasWindow = typeof window !== 'undefined' && !!window;
this.#fetch ||= hasWindow
? window.fetch
: (await import('node-fetch')).default;
return this.#fetch;
}
/**
* Merges headers.
* If the base headers do not exist a new `Headers` object will be returned.
*
* @remarks
*
* Using this utility can be helpful when the headers are not known to exist:
* - if they exist as `Headers`, that instance will be used
* - it improves performance and allows users to use their existing references to their `Headers`
* - if they exist in another form (`HeadersInit`), they will be used to create a new `Headers` object
* - if the base headers do not exist a new `Headers` object will be created
*
* @param base headers to append/overwrite to
* @param append headers to append/overwrite with
* @returns the base headers instance with merged `Headers`
*/
static mergeHeaders(base, ...append) {
base = base instanceof Headers ? base : new Headers(base);
for (const headers of append) {
const add = headers instanceof Headers ? headers : new Headers(headers);
add.forEach((value, key) => {
// set-cookie is the only header that would repeat.
// A bit of background: https://developer.mozilla.org/en-US/docs/Web/API/Headers/getSetCookie
key === 'set-cookie' ? base.append(key, value) : base.set(key, value);
});
}
return base;
}
}
_a = Gaxios;
//# sourceMappingURL=gaxios.js.map

1
node_modules/gaxios/build/esm/src/gaxios.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

15
node_modules/gaxios/build/esm/src/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,15 @@
import { GaxiosOptions } from './common.js';
import { Gaxios } from './gaxios.js';
export { GaxiosError, GaxiosPromise, GaxiosResponse, GaxiosOptionsPrepared, RetryConfig, } from './common.js';
export { Gaxios, GaxiosOptions };
export * from './interceptor.js';
/**
* The default instance used when the `request` method is directly
* invoked.
*/
export declare const instance: Gaxios;
/**
* Make an HTTP request using the given options.
* @param opts Options for the request
*/
export declare function request<T>(opts: GaxiosOptions): Promise<import("./common.js").GaxiosResponse<T>>;

29
node_modules/gaxios/build/esm/src/index.js generated vendored Normal file
View File

@@ -0,0 +1,29 @@
// Copyright 2018 Google LLC
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import { Gaxios } from './gaxios.js';
export { GaxiosError, } from './common.js';
export { Gaxios };
export * from './interceptor.js';
/**
* The default instance used when the `request` method is directly
* invoked.
*/
export const instance = new Gaxios();
/**
* Make an HTTP request using the given options.
* @param opts Options for the request
*/
export async function request(opts) {
return instance.request(opts);
}
//# sourceMappingURL=index.js.map

1
node_modules/gaxios/build/esm/src/index.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,gDAAgD;AAChD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAEnC,OAAO,EACL,WAAW,GAKZ,MAAM,aAAa,CAAC;AACrB,OAAO,EAAC,MAAM,EAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AAEjC;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,MAAM,EAAE,CAAC;AAErC;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAAI,IAAmB;IAClD,OAAO,QAAQ,CAAC,OAAO,CAAI,IAAI,CAAC,CAAC;AACnC,CAAC"}

25
node_modules/gaxios/build/esm/src/interceptor.d.ts generated vendored Normal file
View File

@@ -0,0 +1,25 @@
import { GaxiosError, GaxiosOptionsPrepared, GaxiosResponse } from './common.js';
/**
* Interceptors that can be run for requests or responses. These interceptors run asynchronously.
*/
export interface GaxiosInterceptor<T extends GaxiosOptionsPrepared | GaxiosResponse> {
/**
* Function to be run when applying an interceptor.
*
* @param {T} configOrResponse The current configuration or response.
* @returns {Promise<T>} Promise that resolves to the modified set of options or response.
*/
resolved?: (configOrResponse: T) => Promise<T>;
/**
* Function to be run if the previous call to resolved throws / rejects or the request results in an invalid status
* as determined by the call to validateStatus.
*
* @param {GaxiosError} err The error thrown from the previously called resolved function.
*/
rejected?: (err: GaxiosError) => void;
}
/**
* Class to manage collections of GaxiosInterceptors for both requests and responses.
*/
export declare class GaxiosInterceptorManager<T extends GaxiosOptionsPrepared | GaxiosResponse> extends Set<GaxiosInterceptor<T> | null> {
}

18
node_modules/gaxios/build/esm/src/interceptor.js generated vendored Normal file
View File

@@ -0,0 +1,18 @@
// Copyright 2024 Google LLC
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
* Class to manage collections of GaxiosInterceptors for both requests and responses.
*/
export class GaxiosInterceptorManager extends Set {
}
//# sourceMappingURL=interceptor.js.map

1
node_modules/gaxios/build/esm/src/interceptor.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"interceptor.js","sourceRoot":"","sources":["../../../src/interceptor.ts"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,gDAAgD;AAChD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AA0BjC;;GAEG;AACH,MAAM,OAAO,wBAEX,SAAQ,GAAgC;CAAG"}

8
node_modules/gaxios/build/esm/src/retry.d.ts generated vendored Normal file
View File

@@ -0,0 +1,8 @@
import { GaxiosError } from './common.js';
export declare function getRetryConfig(err: GaxiosError): Promise<{
shouldRetry: boolean;
config?: undefined;
} | {
shouldRetry: boolean;
config: import("./common.js").GaxiosOptionsPrepared;
}>;

162
node_modules/gaxios/build/esm/src/retry.js generated vendored Normal file
View File

@@ -0,0 +1,162 @@
// Copyright 2018 Google LLC
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
export async function getRetryConfig(err) {
let config = getConfig(err);
if (!err || !err.config || (!config && !err.config.retry)) {
return { shouldRetry: false };
}
config = config || {};
config.currentRetryAttempt = config.currentRetryAttempt || 0;
config.retry =
config.retry === undefined || config.retry === null ? 3 : config.retry;
config.httpMethodsToRetry = config.httpMethodsToRetry || [
'GET',
'HEAD',
'PUT',
'OPTIONS',
'DELETE',
];
config.noResponseRetries =
config.noResponseRetries === undefined || config.noResponseRetries === null
? 2
: config.noResponseRetries;
config.retryDelayMultiplier = config.retryDelayMultiplier
? config.retryDelayMultiplier
: 2;
config.timeOfFirstRequest = config.timeOfFirstRequest
? config.timeOfFirstRequest
: Date.now();
config.totalTimeout = config.totalTimeout
? config.totalTimeout
: Number.MAX_SAFE_INTEGER;
config.maxRetryDelay = config.maxRetryDelay
? config.maxRetryDelay
: Number.MAX_SAFE_INTEGER;
// If this wasn't in the list of status codes where we want
// to automatically retry, return.
const retryRanges = [
// https://en.wikipedia.org/wiki/List_of_HTTP_status_codes
// 1xx - Retry (Informational, request still processing)
// 2xx - Do not retry (Success)
// 3xx - Do not retry (Redirect)
// 4xx - Do not retry (Client errors)
// 408 - Retry ("Request Timeout")
// 429 - Retry ("Too Many Requests")
// 5xx - Retry (Server errors)
[100, 199],
[408, 408],
[429, 429],
[500, 599],
];
config.statusCodesToRetry = config.statusCodesToRetry || retryRanges;
// Put the config back into the err
err.config.retryConfig = config;
// Determine if we should retry the request
const shouldRetryFn = config.shouldRetry || shouldRetryRequest;
if (!(await shouldRetryFn(err))) {
return { shouldRetry: false, config: err.config };
}
const delay = getNextRetryDelay(config);
// We're going to retry! Increment the counter.
err.config.retryConfig.currentRetryAttempt += 1;
// Create a promise that invokes the retry after the backOffDelay
const backoff = config.retryBackoff
? config.retryBackoff(err, delay)
: new Promise(resolve => {
setTimeout(resolve, delay);
});
// Notify the user if they added an `onRetryAttempt` handler
if (config.onRetryAttempt) {
await config.onRetryAttempt(err);
}
// Return the promise in which recalls Gaxios to retry the request
await backoff;
return { shouldRetry: true, config: err.config };
}
/**
* Determine based on config if we should retry the request.
* @param err The GaxiosError passed to the interceptor.
*/
function shouldRetryRequest(err) {
const config = getConfig(err);
if ((err.config.signal?.aborted && err.code !== 'TimeoutError') ||
err.code === 'AbortError') {
return false;
}
// If there's no config, or retries are disabled, return.
if (!config || config.retry === 0) {
return false;
}
// Check if this error has no response (ETIMEDOUT, ENOTFOUND, etc)
if (!err.response &&
(config.currentRetryAttempt || 0) >= config.noResponseRetries) {
return false;
}
// Only retry with configured HttpMethods.
if (!config.httpMethodsToRetry ||
!config.httpMethodsToRetry.includes(err.config.method?.toUpperCase() || 'GET')) {
return false;
}
// If this wasn't in the list of status codes where we want
// to automatically retry, return.
if (err.response && err.response.status) {
let isInRange = false;
for (const [min, max] of config.statusCodesToRetry) {
const status = err.response.status;
if (status >= min && status <= max) {
isInRange = true;
break;
}
}
if (!isInRange) {
return false;
}
}
// If we are out of retry attempts, return
config.currentRetryAttempt = config.currentRetryAttempt || 0;
if (config.currentRetryAttempt >= config.retry) {
return false;
}
return true;
}
/**
* Acquire the raxConfig object from an GaxiosError if available.
* @param err The Gaxios error with a config object.
*/
function getConfig(err) {
if (err && err.config && err.config.retryConfig) {
return err.config.retryConfig;
}
return;
}
/**
* Gets the delay to wait before the next retry.
*
* @param {RetryConfig} config The current set of retry options
* @returns {number} the amount of ms to wait before the next retry attempt.
*/
function getNextRetryDelay(config) {
// Calculate time to wait with exponential backoff.
// If this is the first retry, look for a configured retryDelay.
const retryDelay = config.currentRetryAttempt
? 0
: (config.retryDelay ?? 100);
// Formula: retryDelay + ((retryDelayMultiplier^currentRetryAttempt - 1 / 2) * 1000)
const calculatedDelay = retryDelay +
((Math.pow(config.retryDelayMultiplier, config.currentRetryAttempt) - 1) /
2) *
1000;
const maxAllowableDelay = config.totalTimeout - (Date.now() - config.timeOfFirstRequest);
return Math.min(calculatedDelay, maxAllowableDelay, config.maxRetryDelay);
}
//# sourceMappingURL=retry.js.map

1
node_modules/gaxios/build/esm/src/retry.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"retry.js","sourceRoot":"","sources":["../../../src/retry.ts"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,gDAAgD;AAChD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAIjC,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,GAAgB;IACnD,IAAI,MAAM,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;IAC5B,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1D,OAAO,EAAC,WAAW,EAAE,KAAK,EAAC,CAAC;IAC9B,CAAC;IACD,MAAM,GAAG,MAAM,IAAI,EAAE,CAAC;IACtB,MAAM,CAAC,mBAAmB,GAAG,MAAM,CAAC,mBAAmB,IAAI,CAAC,CAAC;IAC7D,MAAM,CAAC,KAAK;QACV,MAAM,CAAC,KAAK,KAAK,SAAS,IAAI,MAAM,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;IACzE,MAAM,CAAC,kBAAkB,GAAG,MAAM,CAAC,kBAAk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jC,IAAI,GAAG,IAAI,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;QAChD,OAAO,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC;IAChC,CAAC;IACD,OAAO;AACT,CAAC;AAED;;;;;GAKG;AACH,SAAS,iBAAiB,CAAC,MAAmB;IAC5C,mDAAmD;IACnD,gEAAgE;IAChE,MAAM,UAAU,GAAG,MAAM,CAAC,mBAAmB;QAC3C,CAAC,CAAC,CAAC;QACH,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,IAAI,GAAG,CAAC,CAAC;IAC/B,oFAAoF;IACpF,MAAM,eAAe,GACnB,UAAU;QACV,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,oBAAqB,EAAE,MAAM,CAAC,mBAAoB,CAAC,GAAG,CAAC,CAAC;YACxE,CAAC,CAAC;YACF,IAAI,CAAC;IACT,MAAM,iBAAiB,GACrB,MAAM,CAAC,YAAa,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,kBAAmB,CAAC,CAAC;IAEnE,OAAO,IAAI,CAAC,GAAG,CAAC,eAAe,EAAE,iBAAiB,EAAE,MAAM,CAAC,aAAc,CAAC,CAAC;AAC7E,CAAC"}

15
node_modules/gaxios/build/esm/src/util.cjs generated vendored Normal file
View File

@@ -0,0 +1,15 @@
// Copyright 2023 Google LLC
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
const pkg = require('../../../package.json');
module.exports = { pkg };
//# sourceMappingURL=util.cjs.map

1
node_modules/gaxios/build/esm/src/util.cjs.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"util.cjs","sourceRoot":"","sources":["../../../src/util.cts"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,gDAAgD;AAChD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,MAAM,GAAG,GAGL,OAAO,CAAC,uBAAuB,CAAC,CAAC;iBAE5B,EAAC,GAAG,EAAC"}

7
node_modules/gaxios/build/esm/src/util.d.cts generated vendored Normal file
View File

@@ -0,0 +1,7 @@
declare const _default: {
pkg: {
name: string;
version: string;
};
};
export = _default;

View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1,123 @@
// Copyright 2019 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import assert from 'assert';
import { execFile } from 'child_process';
import fs from 'fs';
import mv from 'mv';
import ncp from 'ncp';
import path from 'path';
import tmp from 'tmp';
import { promisify } from 'util';
import { describe, it, before, after } from 'mocha';
import { packNTest } from 'pack-n-play';
import { createServer } from 'node:http';
import util from '../src/util.cjs';
/**
* Optionally keep the staging directory between tests.
*/
const KEEP_STAGING_DIRECTORY = false;
const mvp = promisify(mv);
const ncpp = promisify(ncp);
const pkg = util.pkg;
const exec = promisify(execFile);
describe('📦 pack and install', () => {
let stagingDir;
let stagingPath;
before(() => {
stagingDir = tmp.dirSync({
keep: KEEP_STAGING_DIRECTORY,
unsafeCleanup: true,
});
stagingPath = stagingDir.name;
});
after('cleanup staging', () => {
if (!KEEP_STAGING_DIRECTORY) {
stagingDir.removeCallback();
}
});
describe('pack-n-play', () => {
let server;
let url;
before(async () => {
server = createServer((req, res) => {
res.writeHead(200, { 'content-type': 'text/plain' });
res.end(`Hello, ${req.headers['user-agent'] || 'World'}`);
});
await new Promise((resolve, reject) => {
server.on('error', reject);
server.listen(0, resolve);
});
const address = server.address();
if (typeof address === 'string') {
url = address;
}
else {
const base = new URL('http://localhost');
base.host = address.address;
base.port = address.port.toString();
url = base.toString();
}
});
after(() => {
server.close();
});
it('supports ESM', async () => {
await packNTest({
sample: {
description: 'import as ESM',
esm: `
import {Gaxios} from 'gaxios';
const gaxios = new Gaxios();
await gaxios.request({url: '${url}'});
`,
},
});
});
it('supports CJS', async () => {
await packNTest({
sample: {
description: 'require as CJS',
cjs: `
const {Gaxios} = require('gaxios');
const gaxios = new Gaxios();
gaxios.request({url: '${url}'}).then(console.log);
`,
},
});
});
});
describe('webpack', () => {
/**
* Create a staging directory with temp fixtures used to test on a fresh
* application.
*/
before('pack and install', async () => {
await exec('npm', ['pack']);
const tarball = `${pkg.name}-${pkg.version}.tgz`;
await mvp(tarball, `${stagingPath}/gaxios.tgz`);
await ncpp('system-test/fixtures/sample', `${stagingPath}/`);
await exec('npm', ['install'], { cwd: `${stagingPath}/` });
});
it('should be able to webpack the library', async () => {
// we expect npm install is executed in the before hook
await exec('npx', ['webpack'], { cwd: `${stagingPath}/` });
const bundle = path.join(stagingPath, 'dist', 'bundle.min.js');
const stat = fs.statSync(bundle);
assert(stat.size < 256 * 1024);
}).timeout(20000);
});
});
//# sourceMappingURL=test.install.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"test.install.js","sourceRoot":"","sources":["../../../system-test/test.install.ts"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,kDAAkD;AAClD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAO,MAAM,MAAM,QAA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AC,CAAC;YACjC,MAAM,CAAC,IAAI,CAAC,IAAI,GAAG,GAAG,GAAG,IAAI,CAAC,CAAC;QACjC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACpB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}

1
node_modules/gaxios/build/esm/test/test.getch.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export {};

1406
node_modules/gaxios/build/esm/test/test.getch.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

1
node_modules/gaxios/build/esm/test/test.getch.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

1
node_modules/gaxios/build/esm/test/test.index.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export {};

23
node_modules/gaxios/build/esm/test/test.index.js generated vendored Normal file
View File

@@ -0,0 +1,23 @@
// Copyright 2018 Google LLC
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import assert from 'assert';
import { describe, it } from 'mocha';
import * as main from '../src/index.js';
describe('📝 main exports', () => {
it('should export all the types', () => {
assert(main.Gaxios);
assert(main.GaxiosError);
assert(main.GaxiosInterceptorManager);
});
});
//# sourceMappingURL=test.index.js.map

1
node_modules/gaxios/build/esm/test/test.index.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"test.index.js","sourceRoot":"","sources":["../../../test/test.index.ts"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,gDAAgD;AAChD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAC,QAAQ,EAAE,EAAE,EAAC,MAAM,OAAO,CAAC;AACnC,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AAExC,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,EAAE,CAAC,6BAA6B,EAAE,GAAG,EAAE;QACrC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACpB,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACzB,MAAM,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}

1
node_modules/gaxios/build/esm/test/test.retry.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export {};

362
node_modules/gaxios/build/esm/test/test.retry.js generated vendored Normal file
View File

@@ -0,0 +1,362 @@
// Copyright 2018 Google LLC
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import assert from 'assert';
import nock from 'nock';
import { describe, it, afterEach } from 'mocha';
import { Gaxios, GaxiosError, request } from '../src/index.js';
nock.disableNetConnect();
const url = 'https://example.com';
function getConfig(err) {
const e = err;
if (e && e.config && e.config.retryConfig) {
return e.config.retryConfig;
}
return;
}
afterEach(() => {
nock.cleanAll();
});
describe('🛸 retry & exponential backoff', () => {
it('should provide an expected set of defaults', async () => {
const scope = nock(url).get('/').times(4).reply(500);
await assert.rejects(request({ url, retry: true }), (e) => {
scope.done();
const config = getConfig(e);
if (!config) {
assert.fail('no config available');
}
assert.strictEqual(config.currentRetryAttempt, 3);
assert.strictEqual(config.retry, 3);
assert.strictEqual(config.noResponseRetries, 2);
const expectedMethods = ['GET', 'HEAD', 'PUT', 'OPTIONS', 'DELETE'];
for (const method of config.httpMethodsToRetry) {
assert(expectedMethods.indexOf(method) > -1);
}
const expectedStatusCodes = [
[100, 199],
[408, 408],
[429, 429],
[500, 599],
];
const statusCodesToRetry = config.statusCodesToRetry;
for (let i = 0; i < statusCodesToRetry.length; i++) {
const [min, max] = statusCodesToRetry[i];
const [expMin, expMax] = expectedStatusCodes[i];
assert.strictEqual(min, expMin);
assert.strictEqual(max, expMax);
}
return true;
});
});
it('should retry on 500 on the main export', async () => {
const body = { buttered: '🥖' };
const scopes = [
nock(url).get('/').reply(500),
nock(url).get('/').reply(200, body),
];
const res = await request({
url,
retry: true,
});
assert.deepStrictEqual(res.data, body);
scopes.forEach(s => s.done());
});
it('should not retry on a post', async () => {
const scope = nock(url).post('/').reply(500);
await assert.rejects(request({ url, method: 'POST', retry: true }), (e) => {
const config = getConfig(e);
return config.currentRetryAttempt === 0;
});
scope.done();
});
it('should not retry if user aborted request', async () => {
const ac = new AbortController();
const config = {
method: 'GET',
url: 'https://google.com',
signal: ac.signal,
retryConfig: { retry: 10, noResponseRetries: 10 },
};
const req = request(config);
ac.abort();
try {
await req;
throw Error('unreachable');
}
catch (err) {
assert(err instanceof GaxiosError);
assert(err.config);
assert.strictEqual(err.config.retryConfig?.currentRetryAttempt, 0);
}
});
it('should retry at least the configured number of times', async () => {
const body = { dippy: '🥚' };
const scopes = [
nock(url).get('/').times(3).reply(500),
nock(url).get('/').reply(200, body),
];
const cfg = { url, retryConfig: { retry: 4 } };
const res = await request(cfg);
assert.deepStrictEqual(res.data, body);
scopes.forEach(s => s.done());
});
it('should not retry more than configured', async () => {
const scope = nock(url).get('/').twice().reply(500);
const cfg = { url, retryConfig: { retry: 1 } };
await assert.rejects(request(cfg), (e) => {
return getConfig(e).currentRetryAttempt === 1;
});
scope.done();
});
it('should not retry on 4xx errors', async () => {
const scope = nock(url).get('/').reply(404);
await assert.rejects(request({ url, retry: true }), (e) => {
const cfg = getConfig(e);
return cfg.currentRetryAttempt === 0;
});
scope.done();
});
it('should retain the baseURL on retry', async () => {
const body = { pumpkin: '🥧' };
const url = '/path';
const baseURL = 'http://example.com';
const scope = nock(baseURL).get(url).reply(500).get(url).reply(200, body);
const gaxios = new Gaxios({ baseURL });
const res = await gaxios.request({
url,
retry: true,
});
assert.deepStrictEqual(res.data, body);
scope.done();
});
it('should not retry if retries set to 0', async () => {
const scope = nock(url).get('/').reply(500);
const cfg = { url, retryConfig: { retry: 0 } };
await assert.rejects(request(cfg), (e) => {
const cfg = getConfig(e);
return cfg.currentRetryAttempt === 0;
});
scope.done();
});
it('should notify on retry attempts', async () => {
const body = { buttered: '🥖' };
const scopes = [
nock(url).get('/').reply(500),
nock(url).get('/').reply(200, body),
];
let flipped = false;
const config = {
url,
retryConfig: {
onRetryAttempt: err => {
const cfg = getConfig(err);
assert.strictEqual(cfg.currentRetryAttempt, 1);
flipped = true;
},
},
};
await request(config);
assert.strictEqual(flipped, true);
scopes.forEach(s => s.done());
});
it('accepts async onRetryAttempt handler', async () => {
const body = { buttered: '🥖' };
const scopes = [
nock(url).get('/').reply(500),
nock(url).get('/').reply(200, body),
];
let flipped = false;
const config = {
url,
retryConfig: {
onRetryAttempt: async (err) => {
const cfg = getConfig(err);
assert.strictEqual(cfg.currentRetryAttempt, 1);
flipped = true;
},
},
};
await request(config);
assert.strictEqual(flipped, true);
scopes.forEach(s => s.done());
});
it('should support overriding the shouldRetry method', async () => {
const scope = nock(url).get('/').reply(500);
const config = {
url,
retryConfig: {
shouldRetry: () => {
return false;
},
},
};
await assert.rejects(request(config), (e) => {
const cfg = getConfig(e);
return cfg.currentRetryAttempt === 0;
});
scope.done();
});
it('should support overriding the shouldRetry method with a promise', async () => {
const scope = nock(url).get('/').reply(500);
const config = {
url,
retryConfig: {
shouldRetry: async () => {
return false;
},
},
};
await assert.rejects(request(config), (e) => {
const cfg = getConfig(e);
return cfg.currentRetryAttempt === 0;
});
scope.done();
});
it('should retry on ENOTFOUND', async () => {
const body = { spicy: '🌮' };
const scopes = [
nock(url).get('/').reply(500, { code: 'ENOTFOUND' }),
nock(url).get('/').reply(200, body),
];
const res = await request({ url, retry: true });
assert.deepStrictEqual(res.data, body);
scopes.forEach(s => s.done());
});
it('should retry on ETIMEDOUT', async () => {
const body = { sizzling: '🥓' };
const scopes = [
nock(url).get('/').reply(500, { code: 'ETIMEDOUT' }),
nock(url).get('/').reply(200, body),
];
const res = await request({ url, retry: true });
assert.deepStrictEqual(res.data, body);
scopes.forEach(s => s.done());
});
it('should allow configuring noResponseRetries', async () => {
// `nock` is not listening, therefore it should fail
const config = { url, retryConfig: { noResponseRetries: 0 } };
await assert.rejects(request(config), (e) => {
return (e.code === 'ENETUNREACH' &&
e.config.retryConfig?.currentRetryAttempt === 0);
});
});
it('should delay the initial retry by 100ms by default', async () => {
const scope = nock(url).get('/').reply(500).get('/').reply(200, {});
const start = Date.now();
await request({
url,
retry: true,
});
const delay = Date.now() - start;
assert.ok(delay > 100 && delay < 199);
scope.done();
});
it('should respect the retryDelay if configured', async () => {
const scope = nock(url).get('/').reply(500).get('/').reply(200, {});
const start = Date.now();
await request({
url,
retryConfig: {
retryDelay: 500,
},
});
const delay = Date.now() - start;
assert.ok(delay > 500 && delay < 599);
scope.done();
});
it('should respect retryDelayMultiplier if configured', async () => {
const scope = nock(url)
.get('/')
.reply(500)
.get('/')
.reply(500)
.get('/')
.reply(200, {});
const start = Date.now();
await request({
url,
retryConfig: {
retryDelayMultiplier: 3,
},
});
const delay = Date.now() - start;
assert.ok(delay > 1000 && delay < 1999);
scope.done();
});
it('should respect totalTimeout if configured', async () => {
const scope = nock(url)
.get('/')
.reply(500)
.get('/')
.reply(500)
.get('/')
.reply(200, {});
const start = Date.now();
await request({
url,
retryConfig: {
retryDelayMultiplier: 100,
totalTimeout: 3000,
},
});
const delay = Date.now() - start;
assert.ok(delay > 3000 && delay < 3999);
scope.done();
});
it('should respect maxRetryDelay if configured', async () => {
const scope = nock(url)
.get('/')
.reply(500)
.get('/')
.reply(500)
.get('/')
.reply(200, {});
const start = Date.now();
await request({
url,
retryConfig: {
retryDelayMultiplier: 100,
maxRetryDelay: 4000,
},
});
const delay = Date.now() - start;
assert.ok(delay > 4000 && delay < 4999);
scope.done();
});
it('should retry on `timeout`', async () => {
const scope = nock(url).get('/').delay(500).reply(400).get('/').reply(204);
const gaxios = new Gaxios();
const timeout = 100;
async function onRetryAttempt({ config, message }) {
assert(config.signal?.reason instanceof DOMException);
assert.equal(config.signal.reason.name, 'TimeoutError');
assert.match(message, /timeout/i);
// increase timeout to something higher to avoid time-sensitive flaky tests
// note: the second `nock` GET is not delayed like the first one
config.timeout = 10000;
}
const res = await gaxios.request({
url,
timeout,
// NOTE: `node-fetch` does not yet support `TimeoutError` - testing with native `fetch` for now.
fetchImplementation: fetch,
retryConfig: {
onRetryAttempt,
},
});
assert.equal(res.status, 204);
assert.equal(res.config?.retryConfig?.currentRetryAttempt, 1);
scope.done();
});
});
//# sourceMappingURL=test.retry.js.map

1
node_modules/gaxios/build/esm/test/test.retry.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

1
node_modules/gaxios/build/esm/tsconfig.tsbuildinfo generated vendored Normal file

File diff suppressed because one or more lines are too long