@tonyclaw/agent-inspector 4.0.8 → 4.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.output/backend/nitro.json +1 -1
- package/.output/cli.js +915 -25970
- package/.output/server/_chunks/ssr-renderer.mjs +1 -38
- package/.output/server/_libs/@opentelemetry/semantic-conventions+[...].mjs +1 -2658
- package/.output/server/_libs/agent-base.mjs +2 -234
- package/.output/server/_libs/ajv-formats.mjs +1 -330
- package/.output/server/_libs/ajv.mjs +8 -6080
- package/.output/server/_libs/anthropic-ai__sdk.mjs +19 -6021
- package/.output/server/_libs/atomically.mjs +1 -155
- package/.output/server/_libs/base64-js.mjs +1 -102
- package/.output/server/_libs/bignumber.js.mjs +1 -1353
- package/.output/server/_libs/buffer-equal-constant-time.mjs +1 -38
- package/.output/server/_libs/conf.mjs +1 -635
- package/.output/server/_libs/cookie-es.mjs +1 -44
- package/.output/server/_libs/core-util-is.mjs +1 -75
- package/.output/server/_libs/data-uri-to-buffer.mjs +1 -39
- package/.output/server/_libs/debounce-fn.mjs +1 -69
- package/.output/server/_libs/debug.mjs +5 -547
- package/.output/server/_libs/dot-prop.mjs +1 -265
- package/.output/server/_libs/ecdsa-sig-formatter.mjs +1 -162
- package/.output/server/_libs/env-paths.mjs +1 -57
- package/.output/server/_libs/extend.mjs +1 -94
- package/.output/server/_libs/fast-deep-equal.mjs +1 -38
- package/.output/server/_libs/fast-uri.mjs +1 -812
- package/.output/server/_libs/fetch-blob.mjs +1 -287
- package/.output/server/_libs/formdata-polyfill.mjs +9 -86
- package/.output/server/_libs/gaxios.mjs +5 -926
- package/.output/server/_libs/gcp-metadata.mjs +1 -322
- package/.output/server/_libs/google-auth-library.mjs +16 -6339
- package/.output/server/_libs/google-logging-utils.mjs +1 -385
- package/.output/server/_libs/google__genai.mjs +13 -18034
- package/.output/server/_libs/h3-v2.mjs +2 -287
- package/.output/server/_libs/h3.mjs +2 -408
- package/.output/server/_libs/has-flag.mjs +1 -16
- package/.output/server/_libs/https-proxy-agent.mjs +7 -280
- package/.output/server/_libs/immediate.mjs +1 -74
- package/.output/server/_libs/inherits.mjs +1 -50
- package/.output/server/_libs/isarray.mjs +1 -14
- package/.output/server/_libs/isbot.mjs +1 -20
- package/.output/server/_libs/json-bigint.mjs +8 -413
- package/.output/server/_libs/json-schema-traverse.mjs +1 -91
- package/.output/server/_libs/jszip.mjs +2 -3051
- package/.output/server/_libs/jwa.mjs +3 -233
- package/.output/server/_libs/jws.mjs +1 -298
- package/.output/server/_libs/lie.mjs +1 -273
- package/.output/server/_libs/mariozechner__pi-agent-core.mjs +1 -824
- package/.output/server/_libs/mariozechner__pi-ai.mjs +34 -22887
- package/.output/server/_libs/mimic-function.mjs +2 -47
- package/.output/server/_libs/mistralai__mistralai.mjs +7 -32045
- package/.output/server/_libs/modelcontextprotocol__core.mjs +1 -1121
- package/.output/server/_libs/modelcontextprotocol__server.mjs +13 -13205
- package/.output/server/_libs/ms.mjs +1 -120
- package/.output/server/_libs/node-domexception.mjs +1 -17
- package/.output/server/_libs/node-fetch.mjs +4 -1578
- package/.output/server/_libs/ohash.mjs +1 -1
- package/.output/server/_libs/openai.mjs +23 -6766
- package/.output/server/_libs/opentelemetry__api.mjs +1 -1678
- package/.output/server/_libs/p-retry.mjs +1 -87
- package/.output/server/_libs/pako.mjs +1 -4223
- package/.output/server/_libs/partial-json.mjs +2 -244
- package/.output/server/_libs/process-nextick-args.mjs +1 -48
- package/.output/server/_libs/react-dom.mjs +62 -10778
- package/.output/server/_libs/react.mjs +1 -519
- package/.output/server/_libs/readable-stream.mjs +1 -1518
- package/.output/server/_libs/retry.mjs +1 -236
- package/.output/server/_libs/rou3.mjs +1 -14
- package/.output/server/_libs/safe-buffer.mjs +1 -126
- package/.output/server/_libs/semver.mjs +1 -1938
- package/.output/server/_libs/seroval-plugins.mjs +1 -58
- package/.output/server/_libs/seroval.mjs +3 -1775
- package/.output/server/_libs/setimmediate.mjs +1 -152
- package/.output/server/_libs/srvx.mjs +4 -1390
- package/.output/server/_libs/stubborn-fs.mjs +1 -91
- package/.output/server/_libs/stubborn-utils.mjs +1 -66
- package/.output/server/_libs/supports-color.mjs +1 -108
- package/.output/server/_libs/tanstack__history.mjs +1 -230
- package/.output/server/_libs/tanstack__react-router.mjs +1 -848
- package/.output/server/_libs/tanstack__react-store.mjs +1 -1
- package/.output/server/_libs/tanstack__router-core.mjs +1 -4839
- package/.output/server/_libs/typebox.mjs +3 -6596
- package/.output/server/_libs/ufo.mjs +1 -54
- package/.output/server/_libs/uint8array-extras.mjs +1 -69
- package/.output/server/_libs/util-deprecate.mjs +1 -12
- package/.output/server/_libs/web-streams-polyfill.mjs +1 -4282
- package/.output/server/_libs/when-exit.mjs +1 -53
- package/.output/server/_libs/ws.mjs +7 -3715
- package/.output/server/_libs/zod-to-json-schema.mjs +5 -1207
- package/.output/server/_libs/zod.mjs +59 -9958
- package/.output/server/_ssr/empty-plugin-adapters-C3Q1xu4u.mjs +1 -0
- package/.output/server/_ssr/index.mjs +2 -1512
- package/.output/server/_ssr/publicBasePathContext--TAQS2_5.mjs +1 -0
- package/.output/server/_ssr/router-zSWaME0l.mjs +341 -0
- package/.output/server/_ssr/start-PDVGOqUN.mjs +1 -0
- package/.output/server/_tanstack-start-manifest_v-D7cKwKzM.mjs +1 -0
- package/.output/server/index.mjs +1 -320
- package/.output/ui/assets/{CompareDrawer-DafpfgaT.js → CompareDrawer-C6KvvPtJ.js} +1 -1
- package/.output/ui/assets/{InspectorPet-Brsmmfzx.js → InspectorPet-CSH6OAhB.js} +1 -1
- package/.output/ui/assets/{ProxyViewerContainer-D2pq1fUr.js → ProxyViewerContainer-vPd7g0Xn.js} +4 -4
- package/.output/ui/assets/{ReplayDialog-D4mXXgT9.js → ReplayDialog-DbXUcT39.js} +1 -1
- package/.output/ui/assets/{RequestAnatomy-Ccnsq12U.js → RequestAnatomy-BWOCIN7J.js} +1 -1
- package/.output/ui/assets/{ResponseView-CJv3vB5X.js → ResponseView-BqDbTzFs.js} +1 -1
- package/.output/ui/assets/{StreamingChunkSequence-CEkLnOF6.js → StreamingChunkSequence-UHl2g6w6.js} +1 -1
- package/.output/ui/assets/{_sessionId-DlG-yHoI.js → _sessionId-B2S61lDJ.js} +1 -1
- package/.output/ui/assets/{_sessionId-C7s68UH3.js → _sessionId-CS6hqj8-.js} +1 -1
- package/.output/ui/assets/{index-Cqh47jeU.js → index-C6V66rNI.js} +1 -1
- package/.output/ui/assets/{index-CFqnSirZ.js → index-DY5xBYHr.js} +1 -1
- package/.output/ui/assets/{index-B0NCZQ93.js → index-DgyIeqyV.js} +2 -2
- package/.output/ui/assets/{index-ChZZrVHa.js → index-HLs5jTyi.js} +1 -1
- package/.output/ui/assets/{json-viewer-DvpI0vbY.js → json-viewer-i5LcN8e7.js} +1 -1
- package/.output/ui/assets/{jszip.min-5AG8hW2c.js → jszip.min-yNpb9qnf.js} +1 -1
- package/.output/ui/index.html +1 -1
- package/.output/workers/logFinalizer.worker.js +41 -17739
- package/.output/workers/sessionWorkerEntry.js +41 -17735
- package/package.json +7 -7
- package/.output/server/_ssr/empty-plugin-adapters-BFgPZ6_d.mjs +0 -6
- package/.output/server/_ssr/publicBasePathContext-IH2ilOfu.mjs +0 -176
- package/.output/server/_ssr/router-BDyF-OMB.mjs +0 -27187
- package/.output/server/_ssr/start-COQu_AgD.mjs +0 -57
- package/.output/server/_tanstack-start-manifest_v-ClTaMkEj.mjs +0 -4
|
@@ -1,927 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { r as requireExtend } from "./extend.mjs";
|
|
3
|
-
|
|
4
|
-
var src = {};
|
|
5
|
-
var gaxios = {};
|
|
6
|
-
var common = {};
|
|
7
|
-
const name = "gaxios";
|
|
8
|
-
const version = "7.1.6";
|
|
9
|
-
const description = "A simple common HTTP client specifically for Google APIs and services.";
|
|
10
|
-
const main = "build/cjs/src/index.js";
|
|
11
|
-
const types = "build/cjs/src/index.d.ts";
|
|
12
|
-
const files = ["build/"];
|
|
13
|
-
const exports$1 = { ".": { "import": { "types": "./build/esm/src/index.d.ts", "default": "./build/esm/src/index.js" }, "require": { "types": "./build/cjs/src/index.d.ts", "default": "./build/cjs/src/index.js" } } };
|
|
14
|
-
const scripts = { "lint": "gts check --no-inline-config", "test": "c8 mocha build/esm/test", "presystem-test": "npm run compile", "system-test": "mocha build/esm/system-test --timeout 80000", "compile": "tsc -b ./tsconfig.json ./tsconfig.cjs.json && node utils/enable-esm.mjs", "fix": "gts fix", "prepare": "npm run compile", "pretest": "npm run compile", "webpack": "webpack", "prebrowser-test": "npm run compile", "browser-test": "node build/browser-test/browser-test-runner.js", "docs": "jsdoc -c .jsdoc.js", "samples-test": "cd samples/ && npm link ../ && npm test && cd ../", "prelint": "cd samples; npm link ../; npm install", "clean": "gts clean" };
|
|
15
|
-
const repository = { "type": "git", "directory": "core/packages/gaxios", "url": "https://github.com/googleapis/google-cloud-node.git" };
|
|
16
|
-
const keywords = ["google"];
|
|
17
|
-
const engines = { "node": ">=18" };
|
|
18
|
-
const author = "Google, LLC";
|
|
19
|
-
const license = "Apache-2.0";
|
|
20
|
-
const devDependencies = { "@babel/plugin-proposal-private-methods": "^7.18.6", "@types/cors": "^2.8.6", "@types/express": "^5.0.0", "@types/extend": "^3.0.1", "@types/mocha": "^10.0.10", "@types/multiparty": "4.2.1", "@types/mv": "^2.1.0", "@types/ncp": "^2.0.8", "@types/node": "^24.0.0", "@types/sinon": "^21.0.0", "@types/tmp": "^0.2.6", "assert": "^2.0.0", "browserify": "^17.0.0", "c8": "^10.1.3", "cors": "^2.8.5", "express": "^5.0.0", "gts": "^6.0.2", "is-docker": "^3.0.0", "jsdoc": "^4.0.4", "jsdoc-fresh": "^5.0.0", "jsdoc-region-tag": "^4.0.0", "karma": "^6.0.0", "karma-chrome-launcher": "^3.0.0", "karma-coverage": "^2.0.0", "karma-firefox-launcher": "^2.0.0", "karma-mocha": "^2.0.0", "karma-remap-coverage": "^0.1.5", "karma-sourcemap-loader": "^0.4.0", "karma-webpack": "^5.0.1", "mocha": "^11.1.0", "multiparty": "^4.2.1", "mv": "^2.1.1", "ncp": "^2.0.0", "nock": "14.0.5", "null-loader": "^4.0.1", "pack-n-play": "^4.0.0", "puppeteer": "^24.0.0", "sinon": "21.0.3", "stream-browserify": "^3.0.0", "tmp": "0.2.6", "ts-loader": "^9.5.2", "typescript": "5.8.3", "undici-types": "^7.24.1", "webpack": "^5.97.1", "webpack-cli": "^6.0.1" };
|
|
21
|
-
const dependencies = { "extend": "^3.0.2", "https-proxy-agent": "^7.0.1", "node-fetch": "^3.3.2" };
|
|
22
|
-
const homepage = "https://github.com/googleapis/google-cloud-node/tree/main/core/packages/gaxios";
|
|
23
|
-
const require$$0 = {
|
|
24
|
-
name,
|
|
25
|
-
version,
|
|
26
|
-
description,
|
|
27
|
-
main,
|
|
28
|
-
types,
|
|
29
|
-
files,
|
|
30
|
-
exports: exports$1,
|
|
31
|
-
scripts,
|
|
32
|
-
repository,
|
|
33
|
-
keywords,
|
|
34
|
-
engines,
|
|
35
|
-
author,
|
|
36
|
-
license,
|
|
37
|
-
devDependencies,
|
|
38
|
-
dependencies,
|
|
39
|
-
homepage
|
|
40
|
-
};
|
|
41
|
-
var util;
|
|
42
|
-
var hasRequiredUtil;
|
|
43
|
-
function requireUtil() {
|
|
44
|
-
if (hasRequiredUtil) return util;
|
|
45
|
-
hasRequiredUtil = 1;
|
|
46
|
-
const pkg = require$$0;
|
|
47
|
-
util = { pkg };
|
|
48
|
-
return util;
|
|
49
|
-
}
|
|
50
|
-
var hasRequiredCommon;
|
|
51
|
-
function requireCommon() {
|
|
52
|
-
if (hasRequiredCommon) return common;
|
|
53
|
-
hasRequiredCommon = 1;
|
|
54
|
-
(function(exports$12) {
|
|
55
|
-
var __importDefault = common && common.__importDefault || function(mod) {
|
|
56
|
-
return mod && mod.__esModule ? mod : { "default": mod };
|
|
57
|
-
};
|
|
58
|
-
Object.defineProperty(exports$12, "__esModule", { value: true });
|
|
59
|
-
exports$12.GaxiosError = exports$12.GAXIOS_ERROR_SYMBOL = void 0;
|
|
60
|
-
exports$12.defaultErrorRedactor = defaultErrorRedactor;
|
|
61
|
-
const extend_1 = __importDefault(requireExtend());
|
|
62
|
-
const util_cjs_1 = __importDefault(requireUtil());
|
|
63
|
-
const pkg = util_cjs_1.default.pkg;
|
|
64
|
-
exports$12.GAXIOS_ERROR_SYMBOL = /* @__PURE__ */ Symbol.for(`${pkg.name}-gaxios-error`);
|
|
65
|
-
class GaxiosError extends Error {
|
|
66
|
-
config;
|
|
67
|
-
response;
|
|
68
|
-
/**
|
|
69
|
-
* An error code.
|
|
70
|
-
* Can be a system error code, DOMException error name, or any error's 'code' property where it is a `string`.
|
|
71
|
-
*
|
|
72
|
-
* It is only a `number` when the cause is sourced from an API-level error (AIP-193).
|
|
73
|
-
*
|
|
74
|
-
* @see {@link https://nodejs.org/api/errors.html#errorcode error.code}
|
|
75
|
-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/DOMException#error_names DOMException#error_names}
|
|
76
|
-
* @see {@link https://google.aip.dev/193#http11json-representation AIP-193}
|
|
77
|
-
*
|
|
78
|
-
* @example
|
|
79
|
-
* 'ECONNRESET'
|
|
80
|
-
*
|
|
81
|
-
* @example
|
|
82
|
-
* 'TimeoutError'
|
|
83
|
-
*
|
|
84
|
-
* @example
|
|
85
|
-
* 500
|
|
86
|
-
*/
|
|
87
|
-
code;
|
|
88
|
-
/**
|
|
89
|
-
* An HTTP Status code.
|
|
90
|
-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Response/status Response#status}
|
|
91
|
-
*
|
|
92
|
-
* @example
|
|
93
|
-
* 500
|
|
94
|
-
*/
|
|
95
|
-
status;
|
|
96
|
-
/**
|
|
97
|
-
* @deprecated use {@link GaxiosError.cause} instead.
|
|
98
|
-
*
|
|
99
|
-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause Error#cause}
|
|
100
|
-
*
|
|
101
|
-
* @privateRemarks
|
|
102
|
-
*
|
|
103
|
-
* We will want to remove this property later as the modern `cause` property is better suited
|
|
104
|
-
* for displaying and relaying nested errors. Keeping this here makes the resulting
|
|
105
|
-
* error log larger than it needs to be.
|
|
106
|
-
*
|
|
107
|
-
*/
|
|
108
|
-
error;
|
|
109
|
-
/**
|
|
110
|
-
* Support `instanceof` operator for `GaxiosError` across builds/duplicated files.
|
|
111
|
-
*
|
|
112
|
-
* @see {@link GAXIOS_ERROR_SYMBOL}
|
|
113
|
-
* @see {@link GaxiosError[Symbol.hasInstance]}
|
|
114
|
-
* @see {@link https://github.com/microsoft/TypeScript/issues/13965#issuecomment-278570200}
|
|
115
|
-
* @see {@link https://stackoverflow.com/questions/46618852/require-and-instanceof}
|
|
116
|
-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/@@hasInstance#reverting_to_default_instanceof_behavior}
|
|
117
|
-
*/
|
|
118
|
-
[exports$12.GAXIOS_ERROR_SYMBOL] = pkg.version;
|
|
119
|
-
/**
|
|
120
|
-
* Support `instanceof` operator for `GaxiosError` across builds/duplicated files.
|
|
121
|
-
*
|
|
122
|
-
* @see {@link GAXIOS_ERROR_SYMBOL}
|
|
123
|
-
* @see {@link GaxiosError[GAXIOS_ERROR_SYMBOL]}
|
|
124
|
-
*/
|
|
125
|
-
static [Symbol.hasInstance](instance) {
|
|
126
|
-
if (instance && typeof instance === "object" && exports$12.GAXIOS_ERROR_SYMBOL in instance && instance[exports$12.GAXIOS_ERROR_SYMBOL] === pkg.version) {
|
|
127
|
-
return true;
|
|
128
|
-
}
|
|
129
|
-
return Function.prototype[Symbol.hasInstance].call(GaxiosError, instance);
|
|
130
|
-
}
|
|
131
|
-
constructor(message, config, response, cause) {
|
|
132
|
-
super(message, { cause });
|
|
133
|
-
this.config = config;
|
|
134
|
-
this.response = response;
|
|
135
|
-
this.error = cause instanceof Error ? cause : void 0;
|
|
136
|
-
this.config = (0, extend_1.default)(true, {}, config);
|
|
137
|
-
if (this.response) {
|
|
138
|
-
this.response.config = (0, extend_1.default)(true, {}, this.response.config);
|
|
139
|
-
}
|
|
140
|
-
if (this.response) {
|
|
141
|
-
try {
|
|
142
|
-
this.response.data = translateData(
|
|
143
|
-
this.config.responseType,
|
|
144
|
-
// workaround for `node-fetch`'s `.data` deprecation...
|
|
145
|
-
this.response?.bodyUsed ? this.response?.data : void 0
|
|
146
|
-
);
|
|
147
|
-
} catch {
|
|
148
|
-
}
|
|
149
|
-
this.status = this.response.status;
|
|
150
|
-
}
|
|
151
|
-
if (cause instanceof DOMException) {
|
|
152
|
-
this.code = cause.name;
|
|
153
|
-
} else if (cause && typeof cause === "object" && "code" in cause && (typeof cause.code === "string" || typeof cause.code === "number")) {
|
|
154
|
-
this.code = cause.code;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* An AIP-193 conforming error extractor.
|
|
159
|
-
*
|
|
160
|
-
* @see {@link https://google.aip.dev/193#http11json-representation AIP-193}
|
|
161
|
-
*
|
|
162
|
-
* @internal
|
|
163
|
-
* @expiremental
|
|
164
|
-
*
|
|
165
|
-
* @param res the response object
|
|
166
|
-
* @returns the extracted error information
|
|
167
|
-
*/
|
|
168
|
-
static extractAPIErrorFromResponse(res, defaultErrorMessage = "The request failed") {
|
|
169
|
-
let message = defaultErrorMessage;
|
|
170
|
-
if (typeof res.data === "string") {
|
|
171
|
-
message = res.data;
|
|
172
|
-
}
|
|
173
|
-
if (res.data && typeof res.data === "object" && "error" in res.data && res.data.error && !res.ok) {
|
|
174
|
-
if (typeof res.data.error === "string") {
|
|
175
|
-
return {
|
|
176
|
-
message: res.data.error,
|
|
177
|
-
code: res.status,
|
|
178
|
-
status: res.statusText
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
if (typeof res.data.error === "object") {
|
|
182
|
-
message = "message" in res.data.error && typeof res.data.error.message === "string" ? res.data.error.message : message;
|
|
183
|
-
const status = "status" in res.data.error && typeof res.data.error.status === "string" ? res.data.error.status : res.statusText;
|
|
184
|
-
const code = "code" in res.data.error && typeof res.data.error.code === "number" ? res.data.error.code : res.status;
|
|
185
|
-
if ("errors" in res.data.error && Array.isArray(res.data.error.errors)) {
|
|
186
|
-
const errorMessages = [];
|
|
187
|
-
for (const e of res.data.error.errors) {
|
|
188
|
-
if (typeof e === "object" && "message" in e && typeof e.message === "string") {
|
|
189
|
-
errorMessages.push(e.message);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
return Object.assign({
|
|
193
|
-
message: errorMessages.join("\n") || message,
|
|
194
|
-
code,
|
|
195
|
-
status
|
|
196
|
-
}, res.data.error);
|
|
197
|
-
}
|
|
198
|
-
return Object.assign({
|
|
199
|
-
message,
|
|
200
|
-
code,
|
|
201
|
-
status
|
|
202
|
-
}, res.data.error);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
return {
|
|
206
|
-
message,
|
|
207
|
-
code: res.status,
|
|
208
|
-
status: res.statusText
|
|
209
|
-
};
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
exports$12.GaxiosError = GaxiosError;
|
|
213
|
-
function translateData(responseType, data) {
|
|
214
|
-
switch (responseType) {
|
|
215
|
-
case "stream":
|
|
216
|
-
return data;
|
|
217
|
-
case "json":
|
|
218
|
-
return JSON.parse(JSON.stringify(data));
|
|
219
|
-
case "arraybuffer":
|
|
220
|
-
return JSON.parse(Buffer.from(data).toString("utf8"));
|
|
221
|
-
case "blob":
|
|
222
|
-
return JSON.parse(data.text());
|
|
223
|
-
default:
|
|
224
|
-
return data;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
function defaultErrorRedactor(data) {
|
|
228
|
-
const REDACT = "<<REDACTED> - See `errorRedactor` option in `gaxios` for configuration>.";
|
|
229
|
-
function redactHeaders(headers) {
|
|
230
|
-
if (!headers)
|
|
231
|
-
return;
|
|
232
|
-
headers.forEach((_, key) => {
|
|
233
|
-
if (/^authentication$/i.test(key) || /^authorization$/i.test(key) || /secret/i.test(key))
|
|
234
|
-
headers.set(key, REDACT);
|
|
235
|
-
});
|
|
236
|
-
}
|
|
237
|
-
function redactString(obj, key) {
|
|
238
|
-
if (typeof obj === "object" && obj !== null && typeof obj[key] === "string") {
|
|
239
|
-
const text = obj[key];
|
|
240
|
-
if (/grant_type=/i.test(text) || /assertion=/i.test(text) || /secret/i.test(text)) {
|
|
241
|
-
obj[key] = REDACT;
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
function redactObject(obj) {
|
|
246
|
-
if (!obj || typeof obj !== "object") {
|
|
247
|
-
return;
|
|
248
|
-
} else if (obj instanceof FormData || obj instanceof URLSearchParams || // support `node-fetch` FormData/URLSearchParams
|
|
249
|
-
"forEach" in obj && "set" in obj) {
|
|
250
|
-
obj.forEach((_, key) => {
|
|
251
|
-
if (["grant_type", "assertion"].includes(key) || /secret/.test(key)) {
|
|
252
|
-
obj.set(key, REDACT);
|
|
253
|
-
}
|
|
254
|
-
});
|
|
255
|
-
} else {
|
|
256
|
-
if ("grant_type" in obj) {
|
|
257
|
-
obj["grant_type"] = REDACT;
|
|
258
|
-
}
|
|
259
|
-
if ("assertion" in obj) {
|
|
260
|
-
obj["assertion"] = REDACT;
|
|
261
|
-
}
|
|
262
|
-
if ("client_secret" in obj) {
|
|
263
|
-
obj["client_secret"] = REDACT;
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
if (data.config) {
|
|
268
|
-
redactHeaders(data.config.headers);
|
|
269
|
-
redactString(data.config, "data");
|
|
270
|
-
redactObject(data.config.data);
|
|
271
|
-
redactString(data.config, "body");
|
|
272
|
-
redactObject(data.config.body);
|
|
273
|
-
if (data.config.url.searchParams.has("token")) {
|
|
274
|
-
data.config.url.searchParams.set("token", REDACT);
|
|
275
|
-
}
|
|
276
|
-
if (data.config.url.searchParams.has("client_secret")) {
|
|
277
|
-
data.config.url.searchParams.set("client_secret", REDACT);
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
if (data.response) {
|
|
281
|
-
defaultErrorRedactor({ config: data.response.config });
|
|
282
|
-
redactHeaders(data.response.headers);
|
|
283
|
-
if (data.response.bodyUsed) {
|
|
284
|
-
redactString(data.response, "data");
|
|
285
|
-
redactObject(data.response.data);
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
return data;
|
|
289
|
-
}
|
|
290
|
-
})(common);
|
|
291
|
-
return common;
|
|
292
|
-
}
|
|
293
|
-
var retry = {};
|
|
294
|
-
var hasRequiredRetry;
|
|
295
|
-
function requireRetry() {
|
|
296
|
-
if (hasRequiredRetry) return retry;
|
|
297
|
-
hasRequiredRetry = 1;
|
|
298
|
-
Object.defineProperty(retry, "__esModule", { value: true });
|
|
299
|
-
retry.getRetryConfig = getRetryConfig;
|
|
300
|
-
async function getRetryConfig(err) {
|
|
301
|
-
let config = getConfig(err);
|
|
302
|
-
if (!err || !err.config || !config && !err.config.retry) {
|
|
303
|
-
return { shouldRetry: false };
|
|
304
|
-
}
|
|
305
|
-
config = config || {};
|
|
306
|
-
config.currentRetryAttempt = config.currentRetryAttempt || 0;
|
|
307
|
-
config.retry = config.retry === void 0 || config.retry === null ? 3 : config.retry;
|
|
308
|
-
config.httpMethodsToRetry = config.httpMethodsToRetry || [
|
|
309
|
-
"GET",
|
|
310
|
-
"HEAD",
|
|
311
|
-
"PUT",
|
|
312
|
-
"OPTIONS",
|
|
313
|
-
"DELETE"
|
|
314
|
-
];
|
|
315
|
-
config.noResponseRetries = config.noResponseRetries === void 0 || config.noResponseRetries === null ? 2 : config.noResponseRetries;
|
|
316
|
-
config.retryDelayMultiplier = config.retryDelayMultiplier ? config.retryDelayMultiplier : 2;
|
|
317
|
-
config.timeOfFirstRequest = config.timeOfFirstRequest ? config.timeOfFirstRequest : Date.now();
|
|
318
|
-
config.totalTimeout = config.totalTimeout ? config.totalTimeout : Number.MAX_SAFE_INTEGER;
|
|
319
|
-
config.maxRetryDelay = config.maxRetryDelay ? config.maxRetryDelay : Number.MAX_SAFE_INTEGER;
|
|
320
|
-
const retryRanges = [
|
|
321
|
-
// https://en.wikipedia.org/wiki/List_of_HTTP_status_codes
|
|
322
|
-
// 1xx - Retry (Informational, request still processing)
|
|
323
|
-
// 2xx - Do not retry (Success)
|
|
324
|
-
// 3xx - Do not retry (Redirect)
|
|
325
|
-
// 4xx - Do not retry (Client errors)
|
|
326
|
-
// 408 - Retry ("Request Timeout")
|
|
327
|
-
// 429 - Retry ("Too Many Requests")
|
|
328
|
-
// 5xx - Retry (Server errors)
|
|
329
|
-
[100, 199],
|
|
330
|
-
[408, 408],
|
|
331
|
-
[429, 429],
|
|
332
|
-
[500, 599]
|
|
333
|
-
];
|
|
334
|
-
config.statusCodesToRetry = config.statusCodesToRetry || retryRanges;
|
|
335
|
-
err.config.retryConfig = config;
|
|
336
|
-
const shouldRetryFn = config.shouldRetry || shouldRetryRequest;
|
|
337
|
-
if (!await shouldRetryFn(err)) {
|
|
338
|
-
return { shouldRetry: false, config: err.config };
|
|
339
|
-
}
|
|
340
|
-
const delay = getNextRetryDelay(config);
|
|
341
|
-
err.config.retryConfig.currentRetryAttempt += 1;
|
|
342
|
-
const backoff = config.retryBackoff ? config.retryBackoff(err, delay) : new Promise((resolve) => {
|
|
343
|
-
setTimeout(resolve, delay);
|
|
344
|
-
});
|
|
345
|
-
if (config.onRetryAttempt) {
|
|
346
|
-
await config.onRetryAttempt(err);
|
|
347
|
-
}
|
|
348
|
-
await backoff;
|
|
349
|
-
return { shouldRetry: true, config: err.config };
|
|
350
|
-
}
|
|
351
|
-
function shouldRetryRequest(err) {
|
|
352
|
-
const config = getConfig(err);
|
|
353
|
-
if (err.config.signal?.aborted && err.code !== "TimeoutError" || err.code === "AbortError") {
|
|
354
|
-
return false;
|
|
355
|
-
}
|
|
356
|
-
if (!config || config.retry === 0) {
|
|
357
|
-
return false;
|
|
358
|
-
}
|
|
359
|
-
if (!err.response && (config.currentRetryAttempt || 0) >= config.noResponseRetries) {
|
|
360
|
-
return false;
|
|
361
|
-
}
|
|
362
|
-
if (!config.httpMethodsToRetry || !config.httpMethodsToRetry.includes(err.config.method?.toUpperCase() || "GET")) {
|
|
363
|
-
return false;
|
|
364
|
-
}
|
|
365
|
-
if (err.response && err.response.status) {
|
|
366
|
-
let isInRange = false;
|
|
367
|
-
for (const [min, max] of config.statusCodesToRetry) {
|
|
368
|
-
const status = err.response.status;
|
|
369
|
-
if (status >= min && status <= max) {
|
|
370
|
-
isInRange = true;
|
|
371
|
-
break;
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
if (!isInRange) {
|
|
375
|
-
return false;
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
config.currentRetryAttempt = config.currentRetryAttempt || 0;
|
|
379
|
-
if (config.currentRetryAttempt >= config.retry) {
|
|
380
|
-
return false;
|
|
381
|
-
}
|
|
382
|
-
return true;
|
|
383
|
-
}
|
|
384
|
-
function getConfig(err) {
|
|
385
|
-
if (err && err.config && err.config.retryConfig) {
|
|
386
|
-
return err.config.retryConfig;
|
|
387
|
-
}
|
|
388
|
-
return;
|
|
389
|
-
}
|
|
390
|
-
function getNextRetryDelay(config) {
|
|
391
|
-
const retryDelay = config.currentRetryAttempt ? 0 : config.retryDelay ?? 100;
|
|
392
|
-
const calculatedDelay = retryDelay + (Math.pow(config.retryDelayMultiplier, config.currentRetryAttempt) - 1) / 2 * 1e3;
|
|
393
|
-
const maxAllowableDelay = config.totalTimeout - (Date.now() - config.timeOfFirstRequest);
|
|
394
|
-
return Math.min(calculatedDelay, maxAllowableDelay, config.maxRetryDelay);
|
|
395
|
-
}
|
|
396
|
-
return retry;
|
|
397
|
-
}
|
|
398
|
-
var interceptor = {};
|
|
399
|
-
var hasRequiredInterceptor;
|
|
400
|
-
function requireInterceptor() {
|
|
401
|
-
if (hasRequiredInterceptor) return interceptor;
|
|
402
|
-
hasRequiredInterceptor = 1;
|
|
403
|
-
Object.defineProperty(interceptor, "__esModule", { value: true });
|
|
404
|
-
interceptor.GaxiosInterceptorManager = void 0;
|
|
405
|
-
class GaxiosInterceptorManager extends Set {
|
|
406
|
-
}
|
|
407
|
-
interceptor.GaxiosInterceptorManager = GaxiosInterceptorManager;
|
|
408
|
-
return interceptor;
|
|
409
|
-
}
|
|
410
|
-
var hasRequiredGaxios;
|
|
411
|
-
function requireGaxios() {
|
|
412
|
-
if (hasRequiredGaxios) return gaxios;
|
|
413
|
-
hasRequiredGaxios = 1;
|
|
414
|
-
var __importDefault = gaxios && gaxios.__importDefault || function(mod) {
|
|
415
|
-
return mod && mod.__esModule ? mod : { "default": mod };
|
|
416
|
-
};
|
|
417
|
-
var _a;
|
|
418
|
-
Object.defineProperty(gaxios, "__esModule", { value: true });
|
|
419
|
-
gaxios.Gaxios = void 0;
|
|
420
|
-
const extend_1 = __importDefault(requireExtend());
|
|
421
|
-
const https_1 = require$$1;
|
|
422
|
-
const common_js_1 = requireCommon();
|
|
423
|
-
const retry_js_1 = requireRetry();
|
|
424
|
-
const stream_1 = require$$0$1;
|
|
425
|
-
const interceptor_js_1 = requireInterceptor();
|
|
426
|
-
const randomUUID = async () => globalThis.crypto?.randomUUID() || (await import("crypto")).randomUUID();
|
|
427
|
-
const HTTP_STATUS_NO_CONTENT = 204;
|
|
428
|
-
class Gaxios {
|
|
429
|
-
agentCache = /* @__PURE__ */ new Map();
|
|
430
|
-
/**
|
|
431
|
-
* Default HTTP options that will be used for every HTTP request.
|
|
432
|
-
*/
|
|
433
|
-
defaults;
|
|
434
|
-
/**
|
|
435
|
-
* Interceptors
|
|
436
|
-
*/
|
|
437
|
-
interceptors;
|
|
438
|
-
/**
|
|
439
|
-
* The Gaxios class is responsible for making HTTP requests.
|
|
440
|
-
* @param defaults The default set of options to be used for this instance.
|
|
441
|
-
*/
|
|
442
|
-
constructor(defaults) {
|
|
443
|
-
this.defaults = defaults || {};
|
|
444
|
-
this.interceptors = {
|
|
445
|
-
request: new interceptor_js_1.GaxiosInterceptorManager(),
|
|
446
|
-
response: new interceptor_js_1.GaxiosInterceptorManager()
|
|
447
|
-
};
|
|
448
|
-
}
|
|
449
|
-
/**
|
|
450
|
-
* A {@link fetch `fetch`} compliant API for {@link Gaxios}.
|
|
451
|
-
*
|
|
452
|
-
* @remarks
|
|
453
|
-
*
|
|
454
|
-
* This is useful as a drop-in replacement for `fetch` API usage.
|
|
455
|
-
*
|
|
456
|
-
* @example
|
|
457
|
-
*
|
|
458
|
-
* ```ts
|
|
459
|
-
* const gaxios = new Gaxios();
|
|
460
|
-
* const myFetch: typeof fetch = (...args) => gaxios.fetch(...args);
|
|
461
|
-
* await myFetch('https://example.com');
|
|
462
|
-
* ```
|
|
463
|
-
*
|
|
464
|
-
* @param args `fetch` API or `Gaxios#request` parameters
|
|
465
|
-
* @returns the {@link Response} with Gaxios-added properties
|
|
466
|
-
*/
|
|
467
|
-
fetch(...args) {
|
|
468
|
-
const input = args[0];
|
|
469
|
-
const init = args[1];
|
|
470
|
-
let url = void 0;
|
|
471
|
-
const headers = new Headers();
|
|
472
|
-
if (typeof input === "string") {
|
|
473
|
-
url = new URL(input);
|
|
474
|
-
} else if (input instanceof URL) {
|
|
475
|
-
url = input;
|
|
476
|
-
} else if (input && input.url) {
|
|
477
|
-
url = new URL(input.url);
|
|
478
|
-
}
|
|
479
|
-
if (input && typeof input === "object" && "headers" in input) {
|
|
480
|
-
_a.mergeHeaders(headers, input.headers);
|
|
481
|
-
}
|
|
482
|
-
if (init) {
|
|
483
|
-
_a.mergeHeaders(headers, new Headers(init.headers));
|
|
484
|
-
}
|
|
485
|
-
if (typeof input === "object" && !(input instanceof URL)) {
|
|
486
|
-
return this.request({ ...init, ...input, headers, url });
|
|
487
|
-
} else {
|
|
488
|
-
return this.request({ ...init, headers, url });
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
/**
|
|
492
|
-
* Perform an HTTP request with the given options.
|
|
493
|
-
* @param opts Set of HTTP options that will be used for this HTTP request.
|
|
494
|
-
*/
|
|
495
|
-
async request(opts = {}) {
|
|
496
|
-
let prepared = await this.#prepareRequest(opts);
|
|
497
|
-
prepared = await this.#applyRequestInterceptors(prepared);
|
|
498
|
-
return this.#applyResponseInterceptors(this._request(prepared));
|
|
499
|
-
}
|
|
500
|
-
async _defaultAdapter(config) {
|
|
501
|
-
const fetchImpl = config.fetchImplementation || this.defaults.fetchImplementation || await _a.#getFetch();
|
|
502
|
-
const preparedOpts = { ...config };
|
|
503
|
-
delete preparedOpts.data;
|
|
504
|
-
const res = await fetchImpl(config.url, preparedOpts);
|
|
505
|
-
const data = await this.getResponseData(config, res);
|
|
506
|
-
if (!Object.getOwnPropertyDescriptor(res, "data")?.configurable) {
|
|
507
|
-
Object.defineProperties(res, {
|
|
508
|
-
data: {
|
|
509
|
-
configurable: true,
|
|
510
|
-
writable: true,
|
|
511
|
-
enumerable: true,
|
|
512
|
-
value: data
|
|
513
|
-
}
|
|
514
|
-
});
|
|
515
|
-
}
|
|
516
|
-
return Object.assign(res, { config, data });
|
|
517
|
-
}
|
|
518
|
-
/**
|
|
519
|
-
* Internal, retryable version of the `request` method.
|
|
520
|
-
* @param opts Set of HTTP options that will be used for this HTTP request.
|
|
521
|
-
*/
|
|
522
|
-
async _request(opts) {
|
|
523
|
-
try {
|
|
524
|
-
let translatedResponse;
|
|
525
|
-
if (opts.adapter) {
|
|
526
|
-
translatedResponse = await opts.adapter(opts, this._defaultAdapter.bind(this));
|
|
527
|
-
} else {
|
|
528
|
-
translatedResponse = await this._defaultAdapter(opts);
|
|
529
|
-
}
|
|
530
|
-
if (!opts.validateStatus(translatedResponse.status)) {
|
|
531
|
-
if (opts.responseType === "stream") {
|
|
532
|
-
const response = [];
|
|
533
|
-
for await (const chunk of translatedResponse.data) {
|
|
534
|
-
response.push(chunk);
|
|
535
|
-
}
|
|
536
|
-
translatedResponse.data = Buffer.concat(response.map((c) => typeof c === "string" ? Buffer.from(c) : c)).toString("utf8");
|
|
537
|
-
}
|
|
538
|
-
const errorInfo = common_js_1.GaxiosError.extractAPIErrorFromResponse(translatedResponse, `Request failed with status code ${translatedResponse.status}`);
|
|
539
|
-
throw new common_js_1.GaxiosError(errorInfo?.message, opts, translatedResponse, errorInfo);
|
|
540
|
-
}
|
|
541
|
-
return translatedResponse;
|
|
542
|
-
} catch (e) {
|
|
543
|
-
let err;
|
|
544
|
-
if (e instanceof common_js_1.GaxiosError) {
|
|
545
|
-
err = e;
|
|
546
|
-
} else if (e instanceof Error) {
|
|
547
|
-
err = new common_js_1.GaxiosError(e.message, opts, void 0, e);
|
|
548
|
-
} else {
|
|
549
|
-
err = new common_js_1.GaxiosError("Unexpected Gaxios Error", opts, void 0, e);
|
|
550
|
-
}
|
|
551
|
-
const { shouldRetry, config } = await (0, retry_js_1.getRetryConfig)(err);
|
|
552
|
-
if (shouldRetry && config) {
|
|
553
|
-
err.config.retryConfig.currentRetryAttempt = config.retryConfig.currentRetryAttempt;
|
|
554
|
-
opts.retryConfig = err.config?.retryConfig;
|
|
555
|
-
this.#appendTimeoutToSignal(opts);
|
|
556
|
-
return this._request(opts);
|
|
557
|
-
}
|
|
558
|
-
if (opts.errorRedactor) {
|
|
559
|
-
opts.errorRedactor(err);
|
|
560
|
-
}
|
|
561
|
-
throw err;
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
|
-
async getResponseData(opts, res) {
|
|
565
|
-
if (res.status === HTTP_STATUS_NO_CONTENT) {
|
|
566
|
-
return "";
|
|
567
|
-
}
|
|
568
|
-
if (opts.maxContentLength && res.headers.has("content-length") && opts.maxContentLength < Number.parseInt(res.headers?.get("content-length") || "")) {
|
|
569
|
-
throw new common_js_1.GaxiosError("Response's `Content-Length` is over the limit.", opts, Object.assign(res, { config: opts }));
|
|
570
|
-
}
|
|
571
|
-
switch (opts.responseType) {
|
|
572
|
-
case "stream":
|
|
573
|
-
return res.body;
|
|
574
|
-
case "json": {
|
|
575
|
-
const data = await res.text();
|
|
576
|
-
try {
|
|
577
|
-
return JSON.parse(data);
|
|
578
|
-
} catch {
|
|
579
|
-
return data;
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
case "arraybuffer":
|
|
583
|
-
return res.arrayBuffer();
|
|
584
|
-
case "blob":
|
|
585
|
-
return res.blob();
|
|
586
|
-
case "text":
|
|
587
|
-
return res.text();
|
|
588
|
-
default:
|
|
589
|
-
return this.getResponseDataFromContentType(res);
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
#urlMayUseProxy(url, noProxy = []) {
|
|
593
|
-
const candidate = new URL(url);
|
|
594
|
-
const noProxyList = [...noProxy];
|
|
595
|
-
const noProxyEnvList = (process.env.NO_PROXY ?? process.env.no_proxy)?.split(",") || [];
|
|
596
|
-
for (const rule of noProxyEnvList) {
|
|
597
|
-
noProxyList.push(rule.trim());
|
|
598
|
-
}
|
|
599
|
-
for (const rule of noProxyList) {
|
|
600
|
-
if (rule instanceof RegExp) {
|
|
601
|
-
if (rule.test(candidate.toString())) {
|
|
602
|
-
return false;
|
|
603
|
-
}
|
|
604
|
-
} else if (rule instanceof URL) {
|
|
605
|
-
if (rule.origin === candidate.origin) {
|
|
606
|
-
return false;
|
|
607
|
-
}
|
|
608
|
-
} else if (rule.startsWith("*.") || rule.startsWith(".")) {
|
|
609
|
-
const cleanedRule = rule.replace(/^\*\./, ".");
|
|
610
|
-
if (candidate.hostname.endsWith(cleanedRule)) {
|
|
611
|
-
return false;
|
|
612
|
-
}
|
|
613
|
-
} else if (rule === candidate.origin || rule === candidate.hostname || rule === candidate.href) {
|
|
614
|
-
return false;
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
return true;
|
|
618
|
-
}
|
|
619
|
-
/**
|
|
620
|
-
* Applies the request interceptors. The request interceptors are applied after the
|
|
621
|
-
* call to prepareRequest is completed.
|
|
622
|
-
*
|
|
623
|
-
* @param {GaxiosOptionsPrepared} options The current set of options.
|
|
624
|
-
*
|
|
625
|
-
* @returns {Promise<GaxiosOptionsPrepared>} Promise that resolves to the set of options or response after interceptors are applied.
|
|
626
|
-
*/
|
|
627
|
-
async #applyRequestInterceptors(options) {
|
|
628
|
-
let promiseChain = Promise.resolve(options);
|
|
629
|
-
for (const interceptor2 of this.interceptors.request.values()) {
|
|
630
|
-
if (interceptor2) {
|
|
631
|
-
promiseChain = promiseChain.then(interceptor2.resolved, interceptor2.rejected);
|
|
632
|
-
}
|
|
633
|
-
}
|
|
634
|
-
return promiseChain;
|
|
635
|
-
}
|
|
636
|
-
/**
|
|
637
|
-
* Applies the response interceptors. The response interceptors are applied after the
|
|
638
|
-
* call to request is made.
|
|
639
|
-
*
|
|
640
|
-
* @param {GaxiosOptionsPrepared} options The current set of options.
|
|
641
|
-
*
|
|
642
|
-
* @returns {Promise<GaxiosOptionsPrepared>} Promise that resolves to the set of options or response after interceptors are applied.
|
|
643
|
-
*/
|
|
644
|
-
async #applyResponseInterceptors(response) {
|
|
645
|
-
let promiseChain = Promise.resolve(response);
|
|
646
|
-
for (const interceptor2 of this.interceptors.response.values()) {
|
|
647
|
-
if (interceptor2) {
|
|
648
|
-
promiseChain = promiseChain.then(interceptor2.resolved, interceptor2.rejected);
|
|
649
|
-
}
|
|
650
|
-
}
|
|
651
|
-
return promiseChain;
|
|
652
|
-
}
|
|
653
|
-
/**
|
|
654
|
-
* Validates the options, merges them with defaults, and prepare request.
|
|
655
|
-
*
|
|
656
|
-
* @param options The original options passed from the client.
|
|
657
|
-
* @returns Prepared options, ready to make a request
|
|
658
|
-
*/
|
|
659
|
-
async #prepareRequest(options) {
|
|
660
|
-
const preparedHeaders = new Headers(this.defaults.headers);
|
|
661
|
-
_a.mergeHeaders(preparedHeaders, options.headers);
|
|
662
|
-
const opts = (0, extend_1.default)(true, {}, this.defaults, options);
|
|
663
|
-
if (!opts.url) {
|
|
664
|
-
throw new Error("URL is required.");
|
|
665
|
-
}
|
|
666
|
-
if (opts.baseURL) {
|
|
667
|
-
opts.url = new URL(opts.url, opts.baseURL);
|
|
668
|
-
}
|
|
669
|
-
opts.url = new URL(opts.url);
|
|
670
|
-
if (opts.params) {
|
|
671
|
-
if (opts.paramsSerializer) {
|
|
672
|
-
let additionalQueryParams = opts.paramsSerializer(opts.params);
|
|
673
|
-
if (additionalQueryParams.startsWith("?")) {
|
|
674
|
-
additionalQueryParams = additionalQueryParams.slice(1);
|
|
675
|
-
}
|
|
676
|
-
const prefix = opts.url.toString().includes("?") ? "&" : "?";
|
|
677
|
-
opts.url = opts.url + prefix + additionalQueryParams;
|
|
678
|
-
} else {
|
|
679
|
-
const url = opts.url instanceof URL ? opts.url : new URL(opts.url);
|
|
680
|
-
for (const [key, value] of new URLSearchParams(opts.params)) {
|
|
681
|
-
url.searchParams.append(key, value);
|
|
682
|
-
}
|
|
683
|
-
opts.url = url;
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
if (typeof options.maxContentLength === "number") {
|
|
687
|
-
opts.size = options.maxContentLength;
|
|
688
|
-
}
|
|
689
|
-
if (typeof options.maxRedirects === "number") {
|
|
690
|
-
opts.follow = options.maxRedirects;
|
|
691
|
-
}
|
|
692
|
-
const shouldDirectlyPassData = typeof opts.data === "string" || opts.data instanceof ArrayBuffer || opts.data instanceof Blob || // Node 18 does not have a global `File` object
|
|
693
|
-
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`
|
|
694
|
-
/**
|
|
695
|
-
* @deprecated `node-fetch` or another third-party's request types
|
|
696
|
-
*/
|
|
697
|
-
["Blob", "File", "FormData"].includes(opts.data?.constructor?.name || "");
|
|
698
|
-
if (opts.multipart?.length) {
|
|
699
|
-
const boundary = await randomUUID();
|
|
700
|
-
preparedHeaders.set("content-type", `multipart/related; boundary=${boundary}`);
|
|
701
|
-
opts.body = stream_1.Readable.from(this.getMultipartRequest(opts.multipart, boundary));
|
|
702
|
-
} else if (shouldDirectlyPassData) {
|
|
703
|
-
opts.body = opts.data;
|
|
704
|
-
} else if (typeof opts.data === "object") {
|
|
705
|
-
if (preparedHeaders.get("Content-Type") === "application/x-www-form-urlencoded") {
|
|
706
|
-
opts.body = opts.paramsSerializer ? opts.paramsSerializer(opts.data) : new URLSearchParams(opts.data);
|
|
707
|
-
} else {
|
|
708
|
-
if (!preparedHeaders.has("content-type")) {
|
|
709
|
-
preparedHeaders.set("content-type", "application/json");
|
|
710
|
-
}
|
|
711
|
-
opts.body = JSON.stringify(opts.data);
|
|
712
|
-
}
|
|
713
|
-
} else if (opts.data) {
|
|
714
|
-
opts.body = opts.data;
|
|
715
|
-
}
|
|
716
|
-
opts.validateStatus = opts.validateStatus || this.validateStatus;
|
|
717
|
-
opts.responseType = opts.responseType || "unknown";
|
|
718
|
-
if (!preparedHeaders.has("accept") && opts.responseType === "json") {
|
|
719
|
-
preparedHeaders.set("accept", "application/json");
|
|
720
|
-
}
|
|
721
|
-
const proxy = opts.proxy || process?.env?.HTTPS_PROXY || process?.env?.https_proxy || process?.env?.HTTP_PROXY || process?.env?.http_proxy;
|
|
722
|
-
if (opts.agent) ;
|
|
723
|
-
else if (proxy && this.#urlMayUseProxy(opts.url, opts.noProxy)) {
|
|
724
|
-
const HttpsProxyAgent = await _a.#getProxyAgent();
|
|
725
|
-
if (this.agentCache.has(proxy)) {
|
|
726
|
-
opts.agent = this.agentCache.get(proxy);
|
|
727
|
-
} else {
|
|
728
|
-
opts.agent = new HttpsProxyAgent(proxy, {
|
|
729
|
-
cert: opts.cert,
|
|
730
|
-
key: opts.key
|
|
731
|
-
});
|
|
732
|
-
this.agentCache.set(proxy, opts.agent);
|
|
733
|
-
}
|
|
734
|
-
} else if (opts.cert && opts.key) {
|
|
735
|
-
if (this.agentCache.has(opts.key)) {
|
|
736
|
-
opts.agent = this.agentCache.get(opts.key);
|
|
737
|
-
} else {
|
|
738
|
-
opts.agent = new https_1.Agent({
|
|
739
|
-
cert: opts.cert,
|
|
740
|
-
key: opts.key
|
|
741
|
-
});
|
|
742
|
-
this.agentCache.set(opts.key, opts.agent);
|
|
743
|
-
}
|
|
744
|
-
}
|
|
745
|
-
if (typeof opts.errorRedactor !== "function" && opts.errorRedactor !== false) {
|
|
746
|
-
opts.errorRedactor = common_js_1.defaultErrorRedactor;
|
|
747
|
-
}
|
|
748
|
-
if (opts.body && !("duplex" in opts)) {
|
|
749
|
-
opts.duplex = "half";
|
|
750
|
-
}
|
|
751
|
-
this.#appendTimeoutToSignal(opts);
|
|
752
|
-
return Object.assign(opts, {
|
|
753
|
-
headers: preparedHeaders,
|
|
754
|
-
url: opts.url instanceof URL ? opts.url : new URL(opts.url)
|
|
755
|
-
});
|
|
756
|
-
}
|
|
757
|
-
#appendTimeoutToSignal(opts) {
|
|
758
|
-
if (opts.timeout) {
|
|
759
|
-
const timeoutSignal = AbortSignal.timeout(opts.timeout);
|
|
760
|
-
if (opts.signal && !opts.signal.aborted) {
|
|
761
|
-
opts.signal = AbortSignal.any([opts.signal, timeoutSignal]);
|
|
762
|
-
} else {
|
|
763
|
-
opts.signal = timeoutSignal;
|
|
764
|
-
}
|
|
765
|
-
}
|
|
766
|
-
}
|
|
767
|
-
/**
|
|
768
|
-
* By default, throw for any non-2xx status code
|
|
769
|
-
* @param status status code from the HTTP response
|
|
770
|
-
*/
|
|
771
|
-
validateStatus(status) {
|
|
772
|
-
return status >= 200 && status < 300;
|
|
773
|
-
}
|
|
774
|
-
/**
|
|
775
|
-
* Attempts to parse a response by looking at the Content-Type header.
|
|
776
|
-
* @param {Response} response the HTTP response.
|
|
777
|
-
* @returns a promise that resolves to the response data.
|
|
778
|
-
*/
|
|
779
|
-
async getResponseDataFromContentType(response) {
|
|
780
|
-
let contentType = response.headers.get("Content-Type");
|
|
781
|
-
if (contentType === null) {
|
|
782
|
-
return response.text();
|
|
783
|
-
}
|
|
784
|
-
contentType = contentType.toLowerCase();
|
|
785
|
-
if (contentType.includes("application/json")) {
|
|
786
|
-
let data = await response.text();
|
|
787
|
-
try {
|
|
788
|
-
data = JSON.parse(data);
|
|
789
|
-
} catch {
|
|
790
|
-
}
|
|
791
|
-
return data;
|
|
792
|
-
} else if (contentType.match(/^text\//)) {
|
|
793
|
-
return response.text();
|
|
794
|
-
} else {
|
|
795
|
-
return response.blob();
|
|
796
|
-
}
|
|
797
|
-
}
|
|
798
|
-
/**
|
|
799
|
-
* Creates an async generator that yields the pieces of a multipart/related request body.
|
|
800
|
-
* This implementation follows the spec: https://www.ietf.org/rfc/rfc2387.txt. However, recursive
|
|
801
|
-
* multipart/related requests are not currently supported.
|
|
802
|
-
*
|
|
803
|
-
* @param {GaxiosMultipartOptions[]} multipartOptions the pieces to turn into a multipart/related body.
|
|
804
|
-
* @param {string} boundary the boundary string to be placed between each part.
|
|
805
|
-
*/
|
|
806
|
-
async *getMultipartRequest(multipartOptions, boundary) {
|
|
807
|
-
const finale = `--${boundary}--`;
|
|
808
|
-
for (const currentPart of multipartOptions) {
|
|
809
|
-
const partContentType = currentPart.headers.get("Content-Type") || "application/octet-stream";
|
|
810
|
-
const preamble = `--${boundary}\r
|
|
811
|
-
Content-Type: ${partContentType}\r
|
|
1
|
+
import M from"https";import{r as C}from"./extend.mjs";import L from"stream";var R={},b={},w={};const U="gaxios",I="7.1.6",k="A simple common HTTP client specifically for Google APIs and services.",F="build/cjs/src/index.js",H="build/cjs/src/index.d.ts",N=["build/"],B={".":{import:{types:"./build/esm/src/index.d.ts",default:"./build/esm/src/index.js"},require:{types:"./build/cjs/src/index.d.ts",default:"./build/cjs/src/index.js"}}},X={lint:"gts check --no-inline-config",test:"c8 mocha build/esm/test","presystem-test":"npm run compile","system-test":"mocha build/esm/system-test --timeout 80000",compile:"tsc -b ./tsconfig.json ./tsconfig.cjs.json && node utils/enable-esm.mjs",fix:"gts fix",prepare:"npm run compile",pretest:"npm run compile",webpack:"webpack","prebrowser-test":"npm run compile","browser-test":"node build/browser-test/browser-test-runner.js",docs:"jsdoc -c .jsdoc.js","samples-test":"cd samples/ && npm link ../ && npm test && cd ../",prelint:"cd samples; npm link ../; npm install",clean:"gts clean"},Y={type:"git",directory:"core/packages/gaxios",url:"https://github.com/googleapis/google-cloud-node.git"},J=["google"],z={node:">=18"},W="Google, LLC",Q="Apache-2.0",V={"@babel/plugin-proposal-private-methods":"^7.18.6","@types/cors":"^2.8.6","@types/express":"^5.0.0","@types/extend":"^3.0.1","@types/mocha":"^10.0.10","@types/multiparty":"4.2.1","@types/mv":"^2.1.0","@types/ncp":"^2.0.8","@types/node":"^24.0.0","@types/sinon":"^21.0.0","@types/tmp":"^0.2.6",assert:"^2.0.0",browserify:"^17.0.0",c8:"^10.1.3",cors:"^2.8.5",express:"^5.0.0",gts:"^6.0.2","is-docker":"^3.0.0",jsdoc:"^4.0.4","jsdoc-fresh":"^5.0.0","jsdoc-region-tag":"^4.0.0",karma:"^6.0.0","karma-chrome-launcher":"^3.0.0","karma-coverage":"^2.0.0","karma-firefox-launcher":"^2.0.0","karma-mocha":"^2.0.0","karma-remap-coverage":"^0.1.5","karma-sourcemap-loader":"^0.4.0","karma-webpack":"^5.0.1",mocha:"^11.1.0",multiparty:"^4.2.1",mv:"^2.1.1",ncp:"^2.0.0",nock:"14.0.5","null-loader":"^4.0.1","pack-n-play":"^4.0.0",puppeteer:"^24.0.0",sinon:"21.0.3","stream-browserify":"^3.0.0",tmp:"0.2.6","ts-loader":"^9.5.2",typescript:"5.8.3","undici-types":"^7.24.1",webpack:"^5.97.1","webpack-cli":"^6.0.1"},K={extend:"^3.0.2","https-proxy-agent":"^7.0.1","node-fetch":"^3.3.2"},Z="https://github.com/googleapis/google-cloud-node/tree/main/core/packages/gaxios",$={name:U,version:I,description:k,main:F,types:H,files:N,exports:B,scripts:X,repository:Y,keywords:J,engines:z,author:W,license:Q,devDependencies:V,dependencies:K,homepage:Z};var O,S;function ee(){return S||(S=1,O={pkg:$}),O}var T;function D(){return T||(T=1,(function(f){var m=w&&w.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(f,"__esModule",{value:!0}),f.GaxiosError=f.GAXIOS_ERROR_SYMBOL=void 0,f.defaultErrorRedactor=d;const g=m(C()),a=m(ee()).default.pkg;f.GAXIOS_ERROR_SYMBOL=Symbol.for(`${a.name}-gaxios-error`);class s extends Error{config;response;code;status;error;[f.GAXIOS_ERROR_SYMBOL]=a.version;static[Symbol.hasInstance](n){return n&&typeof n=="object"&&f.GAXIOS_ERROR_SYMBOL in n&&n[f.GAXIOS_ERROR_SYMBOL]===a.version?!0:Function.prototype[Symbol.hasInstance].call(s,n)}constructor(n,p,y,r){if(super(n,{cause:r}),this.config=p,this.response=y,this.error=r instanceof Error?r:void 0,this.config=(0,g.default)(!0,{},p),this.response&&(this.response.config=(0,g.default)(!0,{},this.response.config)),this.response){try{this.response.data=l(this.config.responseType,this.response?.bodyUsed?this.response?.data:void 0)}catch{}this.status=this.response.status}r instanceof DOMException?this.code=r.name:r&&typeof r=="object"&&"code"in r&&(typeof r.code=="string"||typeof r.code=="number")&&(this.code=r.code)}static extractAPIErrorFromResponse(n,p="The request failed"){let y=p;if(typeof n.data=="string"&&(y=n.data),n.data&&typeof n.data=="object"&&"error"in n.data&&n.data.error&&!n.ok){if(typeof n.data.error=="string")return{message:n.data.error,code:n.status,status:n.statusText};if(typeof n.data.error=="object"){y="message"in n.data.error&&typeof n.data.error.message=="string"?n.data.error.message:y;const r="status"in n.data.error&&typeof n.data.error.status=="string"?n.data.error.status:n.statusText,t="code"in n.data.error&&typeof n.data.error.code=="number"?n.data.error.code:n.status;if("errors"in n.data.error&&Array.isArray(n.data.error.errors)){const e=[];for(const o of n.data.error.errors)typeof o=="object"&&"message"in o&&typeof o.message=="string"&&e.push(o.message);return Object.assign({message:e.join(`
|
|
2
|
+
`)||y,code:t,status:r},n.data.error)}return Object.assign({message:y,code:t,status:r},n.data.error)}}return{message:y,code:n.status,status:n.statusText}}}f.GaxiosError=s;function l(i,n){switch(i){case"stream":return n;case"json":return JSON.parse(JSON.stringify(n));case"arraybuffer":return JSON.parse(Buffer.from(n).toString("utf8"));case"blob":return JSON.parse(n.text());default:return n}}function d(i){const n="<<REDACTED> - See `errorRedactor` option in `gaxios` for configuration>.";function p(t){t&&t.forEach((e,o)=>{(/^authentication$/i.test(o)||/^authorization$/i.test(o)||/secret/i.test(o))&&t.set(o,n)})}function y(t,e){if(typeof t=="object"&&t!==null&&typeof t[e]=="string"){const o=t[e];(/grant_type=/i.test(o)||/assertion=/i.test(o)||/secret/i.test(o))&&(t[e]=n)}}function r(t){!t||typeof t!="object"||(t instanceof FormData||t instanceof URLSearchParams||"forEach"in t&&"set"in t?t.forEach((e,o)=>{(["grant_type","assertion"].includes(o)||/secret/.test(o))&&t.set(o,n)}):("grant_type"in t&&(t.grant_type=n),"assertion"in t&&(t.assertion=n),"client_secret"in t&&(t.client_secret=n)))}return i.config&&(p(i.config.headers),y(i.config,"data"),r(i.config.data),y(i.config,"body"),r(i.config.body),i.config.url.searchParams.has("token")&&i.config.url.searchParams.set("token",n),i.config.url.searchParams.has("client_secret")&&i.config.url.searchParams.set("client_secret",n)),i.response&&(d({config:i.response.config}),p(i.response.headers),i.response.bodyUsed&&(y(i.response,"data"),r(i.response.data))),i}})(w)),w}var v={},E;function te(){if(E)return v;E=1,Object.defineProperty(v,"__esModule",{value:!0}),v.getRetryConfig=f;async function f(a){let s=g(a);if(!a||!a.config||!s&&!a.config.retry)return{shouldRetry:!1};s=s||{},s.currentRetryAttempt=s.currentRetryAttempt||0,s.retry=s.retry===void 0||s.retry===null?3:s.retry,s.httpMethodsToRetry=s.httpMethodsToRetry||["GET","HEAD","PUT","OPTIONS","DELETE"],s.noResponseRetries=s.noResponseRetries===void 0||s.noResponseRetries===null?2:s.noResponseRetries,s.retryDelayMultiplier=s.retryDelayMultiplier?s.retryDelayMultiplier:2,s.timeOfFirstRequest=s.timeOfFirstRequest?s.timeOfFirstRequest:Date.now(),s.totalTimeout=s.totalTimeout?s.totalTimeout:Number.MAX_SAFE_INTEGER,s.maxRetryDelay=s.maxRetryDelay?s.maxRetryDelay:Number.MAX_SAFE_INTEGER;const l=[[100,199],[408,408],[429,429],[500,599]];if(s.statusCodesToRetry=s.statusCodesToRetry||l,a.config.retryConfig=s,!await(s.shouldRetry||m)(a))return{shouldRetry:!1,config:a.config};const i=h(s);a.config.retryConfig.currentRetryAttempt+=1;const n=s.retryBackoff?s.retryBackoff(a,i):new Promise(p=>{setTimeout(p,i)});return s.onRetryAttempt&&await s.onRetryAttempt(a),await n,{shouldRetry:!0,config:a.config}}function m(a){const s=g(a);if(a.config.signal?.aborted&&a.code!=="TimeoutError"||a.code==="AbortError"||!s||s.retry===0||!a.response&&(s.currentRetryAttempt||0)>=s.noResponseRetries||!s.httpMethodsToRetry||!s.httpMethodsToRetry.includes(a.config.method?.toUpperCase()||"GET"))return!1;if(a.response&&a.response.status){let l=!1;for(const[d,i]of s.statusCodesToRetry){const n=a.response.status;if(n>=d&&n<=i){l=!0;break}}if(!l)return!1}return s.currentRetryAttempt=s.currentRetryAttempt||0,!(s.currentRetryAttempt>=s.retry)}function g(a){if(a&&a.config&&a.config.retryConfig)return a.config.retryConfig}function h(a){const l=(a.currentRetryAttempt?0:a.retryDelay??100)+(Math.pow(a.retryDelayMultiplier,a.currentRetryAttempt)-1)/2*1e3,d=a.totalTimeout-(Date.now()-a.timeOfFirstRequest);return Math.min(l,d,a.maxRetryDelay)}return v}var x={},A;function q(){if(A)return x;A=1,Object.defineProperty(x,"__esModule",{value:!0}),x.GaxiosInterceptorManager=void 0;class f extends Set{}return x.GaxiosInterceptorManager=f,x}var j;function re(){if(j)return b;j=1;var f=b&&b.__importDefault||function(y){return y&&y.__esModule?y:{default:y}},m;Object.defineProperty(b,"__esModule",{value:!0}),b.Gaxios=void 0;const g=f(C()),h=M,a=D(),s=te(),l=L,d=q(),i=async()=>globalThis.crypto?.randomUUID()||(await import("crypto")).randomUUID(),n=204;class p{agentCache=new Map;defaults;interceptors;constructor(r){this.defaults=r||{},this.interceptors={request:new d.GaxiosInterceptorManager,response:new d.GaxiosInterceptorManager}}fetch(...r){const t=r[0],e=r[1];let o;const u=new Headers;return typeof t=="string"?o=new URL(t):t instanceof URL?o=t:t&&t.url&&(o=new URL(t.url)),t&&typeof t=="object"&&"headers"in t&&m.mergeHeaders(u,t.headers),e&&m.mergeHeaders(u,new Headers(e.headers)),typeof t=="object"&&!(t instanceof URL)?this.request({...e,...t,headers:u,url:o}):this.request({...e,headers:u,url:o})}async request(r={}){let t=await this.#o(r);return t=await this.#s(t),this.#a(this._request(t))}async _defaultAdapter(r){const t=r.fetchImplementation||this.defaults.fetchImplementation||await m.#c(),e={...r};delete e.data;const o=await t(r.url,e),u=await this.getResponseData(r,o);return Object.getOwnPropertyDescriptor(o,"data")?.configurable||Object.defineProperties(o,{data:{configurable:!0,writable:!0,enumerable:!0,value:u}}),Object.assign(o,{config:r,data:u})}async _request(r){try{let t;if(r.adapter?t=await r.adapter(r,this._defaultAdapter.bind(this)):t=await this._defaultAdapter(r),!r.validateStatus(t.status)){if(r.responseType==="stream"){const o=[];for await(const u of t.data)o.push(u);t.data=Buffer.concat(o.map(u=>typeof u=="string"?Buffer.from(u):u)).toString("utf8")}const e=a.GaxiosError.extractAPIErrorFromResponse(t,`Request failed with status code ${t.status}`);throw new a.GaxiosError(e?.message,r,t,e)}return t}catch(t){let e;t instanceof a.GaxiosError?e=t:t instanceof Error?e=new a.GaxiosError(t.message,r,void 0,t):e=new a.GaxiosError("Unexpected Gaxios Error",r,void 0,t);const{shouldRetry:o,config:u}=await(0,s.getRetryConfig)(e);if(o&&u)return e.config.retryConfig.currentRetryAttempt=u.retryConfig.currentRetryAttempt,r.retryConfig=e.config?.retryConfig,this.#e(r),this._request(r);throw r.errorRedactor&&r.errorRedactor(e),e}}async getResponseData(r,t){if(t.status===n)return"";if(r.maxContentLength&&t.headers.has("content-length")&&r.maxContentLength<Number.parseInt(t.headers?.get("content-length")||""))throw new a.GaxiosError("Response's `Content-Length` is over the limit.",r,Object.assign(t,{config:r}));switch(r.responseType){case"stream":return t.body;case"json":{const e=await t.text();try{return JSON.parse(e)}catch{return e}}case"arraybuffer":return t.arrayBuffer();case"blob":return t.blob();case"text":return t.text();default:return this.getResponseDataFromContentType(t)}}#n(r,t=[]){const e=new URL(r),o=[...t],u=(process.env.NO_PROXY??process.env.no_proxy)?.split(",")||[];for(const c of u)o.push(c.trim());for(const c of o)if(c instanceof RegExp){if(c.test(e.toString()))return!1}else if(c instanceof URL){if(c.origin===e.origin)return!1}else if(c.startsWith("*.")||c.startsWith(".")){const _=c.replace(/^\*\./,".");if(e.hostname.endsWith(_))return!1}else if(c===e.origin||c===e.hostname||c===e.href)return!1;return!0}async#s(r){let t=Promise.resolve(r);for(const e of this.interceptors.request.values())e&&(t=t.then(e.resolved,e.rejected));return t}async#a(r){let t=Promise.resolve(r);for(const e of this.interceptors.response.values())e&&(t=t.then(e.resolved,e.rejected));return t}async#o(r){const t=new Headers(this.defaults.headers);m.mergeHeaders(t,r.headers);const e=(0,g.default)(!0,{},this.defaults,r);if(!e.url)throw new Error("URL is required.");if(e.baseURL&&(e.url=new URL(e.url,e.baseURL)),e.url=new URL(e.url),e.params)if(e.paramsSerializer){let c=e.paramsSerializer(e.params);c.startsWith("?")&&(c=c.slice(1));const _=e.url.toString().includes("?")?"&":"?";e.url=e.url+_+c}else{const c=e.url instanceof URL?e.url:new URL(e.url);for(const[_,G]of new URLSearchParams(e.params))c.searchParams.append(_,G);e.url=c}typeof r.maxContentLength=="number"&&(e.size=r.maxContentLength),typeof r.maxRedirects=="number"&&(e.follow=r.maxRedirects);const o=typeof e.data=="string"||e.data instanceof ArrayBuffer||e.data instanceof Blob||globalThis.File&&e.data instanceof File||e.data instanceof FormData||e.data instanceof l.Readable||e.data instanceof ReadableStream||e.data instanceof String||e.data instanceof URLSearchParams||ArrayBuffer.isView(e.data)||["Blob","File","FormData"].includes(e.data?.constructor?.name||"");if(e.multipart?.length){const c=await i();t.set("content-type",`multipart/related; boundary=${c}`),e.body=l.Readable.from(this.getMultipartRequest(e.multipart,c))}else o?e.body=e.data:typeof e.data=="object"?t.get("Content-Type")==="application/x-www-form-urlencoded"?e.body=e.paramsSerializer?e.paramsSerializer(e.data):new URLSearchParams(e.data):(t.has("content-type")||t.set("content-type","application/json"),e.body=JSON.stringify(e.data)):e.data&&(e.body=e.data);e.validateStatus=e.validateStatus||this.validateStatus,e.responseType=e.responseType||"unknown",!t.has("accept")&&e.responseType==="json"&&t.set("accept","application/json");const u=e.proxy||process?.env?.HTTPS_PROXY||process?.env?.https_proxy||process?.env?.HTTP_PROXY||process?.env?.http_proxy;if(!e.agent)if(u&&this.#n(e.url,e.noProxy)){const c=await m.#i();this.agentCache.has(u)?e.agent=this.agentCache.get(u):(e.agent=new c(u,{cert:e.cert,key:e.key}),this.agentCache.set(u,e.agent))}else e.cert&&e.key&&(this.agentCache.has(e.key)?e.agent=this.agentCache.get(e.key):(e.agent=new h.Agent({cert:e.cert,key:e.key}),this.agentCache.set(e.key,e.agent)));return typeof e.errorRedactor!="function"&&e.errorRedactor!==!1&&(e.errorRedactor=a.defaultErrorRedactor),e.body&&!("duplex"in e)&&(e.duplex="half"),this.#e(e),Object.assign(e,{headers:t,url:e.url instanceof URL?e.url:new URL(e.url)})}#e(r){if(r.timeout){const t=AbortSignal.timeout(r.timeout);r.signal&&!r.signal.aborted?r.signal=AbortSignal.any([r.signal,t]):r.signal=t}}validateStatus(r){return r>=200&&r<300}async getResponseDataFromContentType(r){let t=r.headers.get("Content-Type");if(t===null)return r.text();if(t=t.toLowerCase(),t.includes("application/json")){let e=await r.text();try{e=JSON.parse(e)}catch{}return e}else return t.match(/^text\//)?r.text():r.blob()}async*getMultipartRequest(r,t){const e=`--${t}--`;for(const o of r){const u=o.headers.get("Content-Type")||"application/octet-stream";yield`--${t}\r
|
|
3
|
+
Content-Type: ${u}\r
|
|
812
4
|
\r
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
if (typeof currentPart.content === "string") {
|
|
816
|
-
yield currentPart.content;
|
|
817
|
-
} else {
|
|
818
|
-
yield* currentPart.content;
|
|
819
|
-
}
|
|
820
|
-
yield "\r\n";
|
|
821
|
-
}
|
|
822
|
-
yield finale;
|
|
823
|
-
}
|
|
824
|
-
/**
|
|
825
|
-
* A cache for the lazily-loaded proxy agent.
|
|
826
|
-
*
|
|
827
|
-
* Should use {@link Gaxios[#getProxyAgent]} to retrieve.
|
|
828
|
-
*/
|
|
829
|
-
// using `import` to dynamically import the types here
|
|
830
|
-
static #proxyAgent;
|
|
831
|
-
/**
|
|
832
|
-
* A cache for the lazily-loaded fetch library.
|
|
833
|
-
*
|
|
834
|
-
* Should use {@link Gaxios[#getFetch]} to retrieve.
|
|
835
|
-
*/
|
|
836
|
-
//
|
|
837
|
-
static #fetch;
|
|
838
|
-
/**
|
|
839
|
-
* Imports, caches, and returns a proxy agent - if not already imported
|
|
840
|
-
*
|
|
841
|
-
* @returns A proxy agent
|
|
842
|
-
*/
|
|
843
|
-
static async #getProxyAgent() {
|
|
844
|
-
this.#proxyAgent ||= (await import("./https-proxy-agent.mjs").then(function(n) {
|
|
845
|
-
return n.i;
|
|
846
|
-
})).HttpsProxyAgent;
|
|
847
|
-
return this.#proxyAgent;
|
|
848
|
-
}
|
|
849
|
-
static async #getFetch() {
|
|
850
|
-
const hasWindow = typeof window !== "undefined" && !!window;
|
|
851
|
-
this.#fetch ||= hasWindow ? window.fetch : (await import("./node-fetch.mjs")).default;
|
|
852
|
-
return this.#fetch;
|
|
853
|
-
}
|
|
854
|
-
/**
|
|
855
|
-
* Merges headers.
|
|
856
|
-
* If the base headers do not exist a new `Headers` object will be returned.
|
|
857
|
-
*
|
|
858
|
-
* @remarks
|
|
859
|
-
*
|
|
860
|
-
* Using this utility can be helpful when the headers are not known to exist:
|
|
861
|
-
* - if they exist as `Headers`, that instance will be used
|
|
862
|
-
* - it improves performance and allows users to use their existing references to their `Headers`
|
|
863
|
-
* - if they exist in another form (`HeadersInit`), they will be used to create a new `Headers` object
|
|
864
|
-
* - if the base headers do not exist a new `Headers` object will be created
|
|
865
|
-
*
|
|
866
|
-
* @param base headers to append/overwrite to
|
|
867
|
-
* @param append headers to append/overwrite with
|
|
868
|
-
* @returns the base headers instance with merged `Headers`
|
|
869
|
-
*/
|
|
870
|
-
static mergeHeaders(base, ...append) {
|
|
871
|
-
base = base instanceof Headers ? base : new Headers(base);
|
|
872
|
-
for (const headers of append) {
|
|
873
|
-
const add = headers instanceof Headers ? headers : new Headers(headers);
|
|
874
|
-
add.forEach((value, key) => {
|
|
875
|
-
key === "set-cookie" ? base.append(key, value) : base.set(key, value);
|
|
876
|
-
});
|
|
877
|
-
}
|
|
878
|
-
return base;
|
|
879
|
-
}
|
|
880
|
-
}
|
|
881
|
-
gaxios.Gaxios = Gaxios;
|
|
882
|
-
_a = Gaxios;
|
|
883
|
-
return gaxios;
|
|
884
|
-
}
|
|
885
|
-
var hasRequiredSrc;
|
|
886
|
-
function requireSrc() {
|
|
887
|
-
if (hasRequiredSrc) return src;
|
|
888
|
-
hasRequiredSrc = 1;
|
|
889
|
-
(function(exports$12) {
|
|
890
|
-
var __createBinding = src && src.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
891
|
-
if (k2 === void 0) k2 = k;
|
|
892
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
893
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
894
|
-
desc = { enumerable: true, get: function() {
|
|
895
|
-
return m[k];
|
|
896
|
-
} };
|
|
897
|
-
}
|
|
898
|
-
Object.defineProperty(o, k2, desc);
|
|
899
|
-
}) : (function(o, m, k, k2) {
|
|
900
|
-
if (k2 === void 0) k2 = k;
|
|
901
|
-
o[k2] = m[k];
|
|
902
|
-
}));
|
|
903
|
-
var __exportStar = src && src.__exportStar || function(m, exports$13) {
|
|
904
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports$13, p)) __createBinding(exports$13, m, p);
|
|
905
|
-
};
|
|
906
|
-
Object.defineProperty(exports$12, "__esModule", { value: true });
|
|
907
|
-
exports$12.instance = exports$12.Gaxios = exports$12.GaxiosError = void 0;
|
|
908
|
-
exports$12.request = request;
|
|
909
|
-
const gaxios_js_1 = requireGaxios();
|
|
910
|
-
Object.defineProperty(exports$12, "Gaxios", { enumerable: true, get: function() {
|
|
911
|
-
return gaxios_js_1.Gaxios;
|
|
912
|
-
} });
|
|
913
|
-
var common_js_1 = requireCommon();
|
|
914
|
-
Object.defineProperty(exports$12, "GaxiosError", { enumerable: true, get: function() {
|
|
915
|
-
return common_js_1.GaxiosError;
|
|
916
|
-
} });
|
|
917
|
-
__exportStar(requireInterceptor(), exports$12);
|
|
918
|
-
exports$12.instance = new gaxios_js_1.Gaxios();
|
|
919
|
-
async function request(opts) {
|
|
920
|
-
return exports$12.instance.request(opts);
|
|
921
|
-
}
|
|
922
|
-
})(src);
|
|
923
|
-
return src;
|
|
924
|
-
}
|
|
925
|
-
export {
|
|
926
|
-
requireSrc as r
|
|
927
|
-
};
|
|
5
|
+
`,typeof o.content=="string"?yield o.content:yield*o.content,yield`\r
|
|
6
|
+
`}yield e}static#t;static#r;static async#i(){return this.#t||=(await import("./https-proxy-agent.mjs").then(function(r){return r.i})).HttpsProxyAgent,this.#t}static async#c(){const r=typeof window<"u"&&!!window;return this.#r||=r?window.fetch:(await import("./node-fetch.mjs")).default,this.#r}static mergeHeaders(r,...t){r=r instanceof Headers?r:new Headers(r);for(const e of t)(e instanceof Headers?e:new Headers(e)).forEach((u,c)=>{c==="set-cookie"?r.append(c,u):r.set(c,u)});return r}}return b.Gaxios=p,m=p,b}var P;function oe(){return P||(P=1,(function(f){var m=R&&R.__createBinding||(Object.create?(function(l,d,i,n){n===void 0&&(n=i);var p=Object.getOwnPropertyDescriptor(d,i);(!p||("get"in p?!d.__esModule:p.writable||p.configurable))&&(p={enumerable:!0,get:function(){return d[i]}}),Object.defineProperty(l,n,p)}):(function(l,d,i,n){n===void 0&&(n=i),l[n]=d[i]})),g=R&&R.__exportStar||function(l,d){for(var i in l)i!=="default"&&!Object.prototype.hasOwnProperty.call(d,i)&&m(d,l,i)};Object.defineProperty(f,"__esModule",{value:!0}),f.instance=f.Gaxios=f.GaxiosError=void 0,f.request=s;const h=re();Object.defineProperty(f,"Gaxios",{enumerable:!0,get:function(){return h.Gaxios}});var a=D();Object.defineProperty(f,"GaxiosError",{enumerable:!0,get:function(){return a.GaxiosError}}),g(q(),f),f.instance=new h.Gaxios;async function s(l){return f.instance.request(l)}})(R)),R}export{oe as r};
|