feat: Complete zCode CLI X with Telegram bot integration

- Add full Telegram bot functionality with Z.AI API integration
- Implement 4 tools: Bash, FileEdit, WebSearch, Git
- Add 3 agents: Code Reviewer, Architect, DevOps Engineer
- Add 6 skills for common coding tasks
- Add systemd service file for 24/7 operation
- Add nginx configuration for HTTPS webhook
- Add comprehensive documentation
- Implement WebSocket server for real-time updates
- Add logging system with Winston
- Add environment validation

🤖 zCode CLI X - Agentic coder with Z.AI + Telegram integration
This commit is contained in:
admin
2026-05-05 09:01:26 +00:00
Unverified
parent 4a7035dd92
commit 875c7f9b91
24688 changed files with 3224957 additions and 221 deletions

View File

@@ -0,0 +1,397 @@
# Changelog
## [6.7.1](https://github.com/googleapis/gaxios/compare/v6.7.0...v6.7.1) (2024-08-13)
### Bug Fixes
* Release uuid rollback ([#641](https://github.com/googleapis/gaxios/issues/641)) ([2e21115](https://github.com/googleapis/gaxios/commit/2e211158d5351d81de4e84f999ec3b41475ec0cd))
## [6.7.0](https://github.com/googleapis/gaxios/compare/v6.6.0...v6.7.0) (2024-06-27)
### Features
* Add additional retry configuration options ([#634](https://github.com/googleapis/gaxios/issues/634)) ([cb5c833](https://github.com/googleapis/gaxios/commit/cb5c833a9750bf6d0c0f8e27992bb44bd953566c))
### Bug Fixes
* **deps:** Update dependency uuid to v10 ([#629](https://github.com/googleapis/gaxios/issues/629)) ([6ff684e](https://github.com/googleapis/gaxios/commit/6ff684e6e6e5f4e5e6d270685b2ac0e4d28bc964))
## [6.6.0](https://github.com/googleapis/gaxios/compare/v6.5.0...v6.6.0) (2024-05-15)
### Features
* Add request and response interceptors ([#619](https://github.com/googleapis/gaxios/issues/619)) ([059fe77](https://github.com/googleapis/gaxios/commit/059fe7708e6d98cc44814ec1fad7d412668a05b9))
## [6.5.0](https://github.com/googleapis/gaxios/compare/v6.4.0...v6.5.0) (2024-04-09)
### Features
* Retry `408` by Default ([#616](https://github.com/googleapis/gaxios/issues/616)) ([9331f79](https://github.com/googleapis/gaxios/commit/9331f79f9c9d0c1f4f1f995e1928323f4feb5427))
* Support `proxy` option ([#614](https://github.com/googleapis/gaxios/issues/614)) ([2d14b3f](https://github.com/googleapis/gaxios/commit/2d14b3f54bc97111cb184cecf2379b55ceaca3c2))
## [6.4.0](https://github.com/googleapis/gaxios/compare/v6.3.0...v6.4.0) (2024-04-03)
### Features
* Enhance Error Redaction ([#609](https://github.com/googleapis/gaxios/issues/609)) ([b1d2875](https://github.com/googleapis/gaxios/commit/b1d28759110f91b37746f9b88aba92bf52df2fcc))
* Support multipart/related requests ([#610](https://github.com/googleapis/gaxios/issues/610)) ([086c824](https://github.com/googleapis/gaxios/commit/086c8240652bd893dff0dd4c097ef00f5777564e))
### Bug Fixes
* Error Redactor Case-Insensitive Matching ([#613](https://github.com/googleapis/gaxios/issues/613)) ([05e65ef](https://github.com/googleapis/gaxios/commit/05e65efda6d13e760d4f7f87be7d6cebeba3cc64))
## [6.3.0](https://github.com/googleapis/gaxios/compare/v6.2.0...v6.3.0) (2024-02-01)
### Features
* Support URL objects ([#598](https://github.com/googleapis/gaxios/issues/598)) ([ef40c61](https://github.com/googleapis/gaxios/commit/ef40c61fabf0a48b2f08be085ee0c56dc32cf78c))
## [6.2.0](https://github.com/googleapis/gaxios/compare/v6.1.1...v6.2.0) (2024-01-31)
### Features
* Extend `instanceof` Support for GaxiosError ([#593](https://github.com/googleapis/gaxios/issues/593)) ([4fd1fe2](https://github.com/googleapis/gaxios/commit/4fd1fe2c91b9888c4f976cf91e752d407b99ec75))
### Bug Fixes
* Do Not Mutate Config for Redacted Retries ([#597](https://github.com/googleapis/gaxios/issues/597)) ([4d1a551](https://github.com/googleapis/gaxios/commit/4d1a55134940031a1e0ff2392ab0b08c186166f0))
* Return text when content type is text/* ([#579](https://github.com/googleapis/gaxios/issues/579)) ([3cc1c76](https://github.com/googleapis/gaxios/commit/3cc1c76a08d98daac01c83bed6f9480320ec0a37))
## [6.1.1](https://github.com/googleapis/gaxios/compare/v6.1.0...v6.1.1) (2023-09-07)
### Bug Fixes
* Don't throw an error within a `GaxiosError` ([#569](https://github.com/googleapis/gaxios/issues/569)) ([035d9dd](https://github.com/googleapis/gaxios/commit/035d9dd833c3ad63148bc50facaee421f4792192))
## [6.1.0](https://github.com/googleapis/gaxios/compare/v6.0.4...v6.1.0) (2023-08-11)
### Features
* Prevent Auth Logging by Default ([#565](https://github.com/googleapis/gaxios/issues/565)) ([b28e562](https://github.com/googleapis/gaxios/commit/b28e5628f5964e2ecc04cc1df8a54948567a4b48))
## [6.0.4](https://github.com/googleapis/gaxios/compare/v6.0.3...v6.0.4) (2023-08-03)
### Bug Fixes
* **deps:** Update https-proxy-agent to 7.0.1 and fix imports and tests ([#560](https://github.com/googleapis/gaxios/issues/560)) ([5c877e2](https://github.com/googleapis/gaxios/commit/5c877e28c3c9336a87b50536c074cb215b779d8e))
## [6.0.3](https://github.com/googleapis/gaxios/compare/v6.0.2...v6.0.3) (2023-07-24)
### Bug Fixes
* Handle invalid json when Content-Type=application/json ([#558](https://github.com/googleapis/gaxios/issues/558)) ([71602eb](https://github.com/googleapis/gaxios/commit/71602ebc2ab18d5af904b152723756f57fb13bce))
## [6.0.2](https://github.com/googleapis/gaxios/compare/v6.0.1...v6.0.2) (2023-07-20)
### Bug Fixes
* Revert attempting to convert 'text/plain', leave as data in GaxiosError ([#556](https://github.com/googleapis/gaxios/issues/556)) ([d603bde](https://github.com/googleapis/gaxios/commit/d603bde35f698564c028108d24c6891cec3b8ea1))
## [6.0.1](https://github.com/googleapis/gaxios/compare/v6.0.0...v6.0.1) (2023-07-20)
### Bug Fixes
* Add text to responseType switch statement ([#554](https://github.com/googleapis/gaxios/issues/554)) ([899cf1f](https://github.com/googleapis/gaxios/commit/899cf1fb088f49927624d526f6de212837a31b9d))
## [6.0.0](https://github.com/googleapis/gaxios/compare/v5.1.3...v6.0.0) (2023-07-12)
### ⚠ BREAKING CHANGES
* add status as a number to GaxiosError, change code to error code as a string ([#552](https://github.com/googleapis/gaxios/issues/552))
* migrate to Node 14 ([#548](https://github.com/googleapis/gaxios/issues/548))
* examine response content-type if no contentType is set ([#535](https://github.com/googleapis/gaxios/issues/535))
### Bug Fixes
* Add status as a number to GaxiosError, change code to error code as a string ([#552](https://github.com/googleapis/gaxios/issues/552)) ([88ba2e9](https://github.com/googleapis/gaxios/commit/88ba2e99e32b66d84725c9ea9ad95152bd1dc653))
* Examine response content-type if no contentType is set ([#535](https://github.com/googleapis/gaxios/issues/535)) ([cd8ca7b](https://github.com/googleapis/gaxios/commit/cd8ca7b209f0ba932082a80ace8fec608a71facf))
### Miscellaneous Chores
* Migrate to Node 14 ([#548](https://github.com/googleapis/gaxios/issues/548)) ([b9b26eb](https://github.com/googleapis/gaxios/commit/b9b26eb2c4af35633efd91770aa24c4b5d9019b4))
## [5.1.3](https://github.com/googleapis/gaxios/compare/v5.1.2...v5.1.3) (2023-07-05)
### Bug Fixes
* Translate GaxiosError message to object regardless of return type (return data as default) ([#546](https://github.com/googleapis/gaxios/issues/546)) ([adfd570](https://github.com/googleapis/gaxios/commit/adfd57068a98d03921d5383fed11a652a21d59dd))
## [5.1.2](https://github.com/googleapis/gaxios/compare/v5.1.1...v5.1.2) (2023-06-25)
### Bug Fixes
* Revert changes to error handling due to downstream breakage ([#544](https://github.com/googleapis/gaxios/issues/544)) ([64fbf07](https://github.com/googleapis/gaxios/commit/64fbf07f3697f40b75a9e7dbe8bff7f6243a9e12))
## [5.1.1](https://github.com/googleapis/gaxios/compare/v5.1.0...v5.1.1) (2023-06-23)
### Bug Fixes
* Translate GaxiosError message to object regardless of return type ([#537](https://github.com/googleapis/gaxios/issues/537)) ([563c653](https://github.com/googleapis/gaxios/commit/563c6537a06bc64d5c6e918090c00ec7a586cecb))
## [5.1.0](https://github.com/googleapis/gaxios/compare/v5.0.2...v5.1.0) (2023-03-06)
### Features
* Add support for custom backoff ([#498](https://github.com/googleapis/gaxios/issues/498)) ([4a34467](https://github.com/googleapis/gaxios/commit/4a344678110864d97818a8272ebcc5e1c4921b52))
## [5.0.2](https://github.com/googleapis/gaxios/compare/v5.0.1...v5.0.2) (2022-09-09)
### Bug Fixes
* Do not import the whole google-gax from proto JS ([#1553](https://github.com/googleapis/gaxios/issues/1553)) ([#501](https://github.com/googleapis/gaxios/issues/501)) ([6f58d1e](https://github.com/googleapis/gaxios/commit/6f58d1e80ce6b196d17fbc75dc47d8d20804920a))
* use google-gax v3.3.0 ([6f58d1e](https://github.com/googleapis/gaxios/commit/6f58d1e80ce6b196d17fbc75dc47d8d20804920a))
## [5.0.1](https://github.com/googleapis/gaxios/compare/v5.0.0...v5.0.1) (2022-07-04)
### Bug Fixes
* **types:** loosen AbortSignal type ([5a379ca](https://github.com/googleapis/gaxios/commit/5a379ca123f08f286c4774711a7a3293bffc1ea6))
## [5.0.0](https://github.com/googleapis/gaxios/compare/v4.3.3...v5.0.0) (2022-04-20)
### ⚠ BREAKING CHANGES
* drop node 10 from engines list, update typescript to 4.6.3 (#477)
### Features
* handling missing process global ([c30395b](https://github.com/googleapis/gaxios/commit/c30395bbf34d889e75c7c72a7dff701dc7a98244))
### Build System
* drop node 10 from engines list, update typescript to 4.6.3 ([#477](https://github.com/googleapis/gaxios/issues/477)) ([a926962](https://github.com/googleapis/gaxios/commit/a9269624a70aa6305599cc0af079d0225ed6af50))
### [4.3.3](https://github.com/googleapis/gaxios/compare/v4.3.2...v4.3.3) (2022-04-08)
### Bug Fixes
* do not stringify form data ([#475](https://github.com/googleapis/gaxios/issues/475)) ([17370dc](https://github.com/googleapis/gaxios/commit/17370dcdfd4568d7f3f0855961030d238166836a))
### [4.3.2](https://www.github.com/googleapis/gaxios/compare/v4.3.1...v4.3.2) (2021-09-14)
### Bug Fixes
* address codeql warning with hostname matches ([#415](https://www.github.com/googleapis/gaxios/issues/415)) ([5a4d060](https://www.github.com/googleapis/gaxios/commit/5a4d06019343aa08e1bcf8e05108e22ac3b12636))
### [4.3.1](https://www.github.com/googleapis/gaxios/compare/v4.3.0...v4.3.1) (2021-09-02)
### Bug Fixes
* **build:** switch primary branch to main ([#427](https://www.github.com/googleapis/gaxios/issues/427)) ([819219e](https://www.github.com/googleapis/gaxios/commit/819219ed742814259c525bdf5721b28234019c08))
## [4.3.0](https://www.github.com/googleapis/gaxios/compare/v4.2.1...v4.3.0) (2021-05-26)
### Features
* allow cert and key to be provided for mTLS ([#399](https://www.github.com/googleapis/gaxios/issues/399)) ([d74ab91](https://www.github.com/googleapis/gaxios/commit/d74ab9125d581e46d655614729872e79317c740d))
### [4.2.1](https://www.github.com/googleapis/gaxios/compare/v4.2.0...v4.2.1) (2021-04-20)
### Bug Fixes
* **deps:** upgrade webpack and karma-webpack ([#379](https://www.github.com/googleapis/gaxios/issues/379)) ([75c9013](https://www.github.com/googleapis/gaxios/commit/75c90132e99c2f960c01e0faf0f8e947c920aa73))
## [4.2.0](https://www.github.com/googleapis/gaxios/compare/v4.1.0...v4.2.0) (2021-03-01)
### Features
* handle application/x-www-form-urlencoded/Buffer ([#374](https://www.github.com/googleapis/gaxios/issues/374)) ([ce21e9c](https://www.github.com/googleapis/gaxios/commit/ce21e9ccd228578a9f90bb2fddff797cec4a9402))
## [4.1.0](https://www.github.com/googleapis/gaxios/compare/v4.0.1...v4.1.0) (2020-12-08)
### Features
* add an option to configure the fetch impl ([#342](https://www.github.com/googleapis/gaxios/issues/342)) ([2e081ef](https://www.github.com/googleapis/gaxios/commit/2e081ef161d84aa435788e8d525d393dc7964117))
* add no_proxy env variable ([#361](https://www.github.com/googleapis/gaxios/issues/361)) ([efe72a7](https://www.github.com/googleapis/gaxios/commit/efe72a71de81d466160dde5da551f7a41acc3ac4))
### [4.0.1](https://www.github.com/googleapis/gaxios/compare/v4.0.0...v4.0.1) (2020-10-27)
### Bug Fixes
* prevent bonus ? with empty qs params ([#357](https://www.github.com/googleapis/gaxios/issues/357)) ([b155f76](https://www.github.com/googleapis/gaxios/commit/b155f76cbc4c234da1d99c26691296702342c205))
## [4.0.0](https://www.github.com/googleapis/gaxios/compare/v3.2.0...v4.0.0) (2020-10-21)
### ⚠ BREAKING CHANGES
* parameters in `url` and parameters provided via params will now be combined.
### Bug Fixes
* drop requirement on URL/combine url and params ([#338](https://www.github.com/googleapis/gaxios/issues/338)) ([e166bc6](https://www.github.com/googleapis/gaxios/commit/e166bc6721fd979070ab3d9c69b71ffe9ee061c7))
## [3.2.0](https://www.github.com/googleapis/gaxios/compare/v3.1.0...v3.2.0) (2020-09-14)
### Features
* add initial retry delay, and set default to 100ms ([#336](https://www.github.com/googleapis/gaxios/issues/336)) ([870326b](https://www.github.com/googleapis/gaxios/commit/870326b8245f16fafde0b0c32cfd2f277946e3a1))
## [3.1.0](https://www.github.com/googleapis/gaxios/compare/v3.0.4...v3.1.0) (2020-07-30)
### Features
* pass default adapter to adapter option ([#319](https://www.github.com/googleapis/gaxios/issues/319)) ([cf06bd9](https://www.github.com/googleapis/gaxios/commit/cf06bd9f51cbe707ed5973e390d31a091d4537c1))
### [3.0.4](https://www.github.com/googleapis/gaxios/compare/v3.0.3...v3.0.4) (2020-07-09)
### Bug Fixes
* typeo in nodejs .gitattribute ([#306](https://www.github.com/googleapis/gaxios/issues/306)) ([8514672](https://www.github.com/googleapis/gaxios/commit/8514672f9d56bc6f077dcbab050b3342d4e343c6))
### [3.0.3](https://www.github.com/googleapis/gaxios/compare/v3.0.2...v3.0.3) (2020-04-20)
### Bug Fixes
* apache license URL ([#468](https://www.github.com/googleapis/gaxios/issues/468)) ([#272](https://www.github.com/googleapis/gaxios/issues/272)) ([cf1b7cb](https://www.github.com/googleapis/gaxios/commit/cf1b7cb66e4c98405236834e63349931b4f35b90))
### [3.0.2](https://www.github.com/googleapis/gaxios/compare/v3.0.1...v3.0.2) (2020-03-24)
### Bug Fixes
* continue replacing application/x-www-form-urlencoded with application/json ([#263](https://www.github.com/googleapis/gaxios/issues/263)) ([dca176d](https://www.github.com/googleapis/gaxios/commit/dca176df0990f2c22255f9764405c496ea07ada2))
### [3.0.1](https://www.github.com/googleapis/gaxios/compare/v3.0.0...v3.0.1) (2020-03-23)
### Bug Fixes
* allow an alternate JSON content-type to be set ([#257](https://www.github.com/googleapis/gaxios/issues/257)) ([698a29f](https://www.github.com/googleapis/gaxios/commit/698a29ff3b22f30ea99ad190c4592940bef88f1f))
## [3.0.0](https://www.github.com/googleapis/gaxios/compare/v2.3.2...v3.0.0) (2020-03-19)
### ⚠ BREAKING CHANGES
* **deps:** TypeScript introduced breaking changes in generated code in 3.7.x
* drop Node 8 from engines field (#254)
### Features
* drop Node 8 from engines field ([#254](https://www.github.com/googleapis/gaxios/issues/254)) ([8c9fff7](https://www.github.com/googleapis/gaxios/commit/8c9fff7f92f70f029292c906c62d194c1d58827d))
* **deps:** updates to latest TypeScript ([#253](https://www.github.com/googleapis/gaxios/issues/253)) ([054267b](https://www.github.com/googleapis/gaxios/commit/054267bf12e1801c134e3b5cae92dcc5ea041fab))
### [2.3.2](https://www.github.com/googleapis/gaxios/compare/v2.3.1...v2.3.2) (2020-02-28)
### Bug Fixes
* update github repo in package ([#239](https://www.github.com/googleapis/gaxios/issues/239)) ([7e750cb](https://www.github.com/googleapis/gaxios/commit/7e750cbaaa59812817d725c74fb9d364c4b71096))
### [2.3.1](https://www.github.com/googleapis/gaxios/compare/v2.3.0...v2.3.1) (2020-02-13)
### Bug Fixes
* **deps:** update dependency https-proxy-agent to v5 ([#233](https://www.github.com/googleapis/gaxios/issues/233)) ([56de0a8](https://www.github.com/googleapis/gaxios/commit/56de0a824a2f9622e3e4d4bdd41adccd812a30b4))
## [2.3.0](https://www.github.com/googleapis/gaxios/compare/v2.2.2...v2.3.0) (2020-01-31)
### Features
* add promise support for onRetryAttempt and shouldRetry ([#223](https://www.github.com/googleapis/gaxios/issues/223)) ([061afa3](https://www.github.com/googleapis/gaxios/commit/061afa381a51d39823e63accf3dacd16e191f3b9))
### [2.2.2](https://www.github.com/googleapis/gaxios/compare/v2.2.1...v2.2.2) (2020-01-08)
### Bug Fixes
* **build:** add publication configuration ([#218](https://www.github.com/googleapis/gaxios/issues/218)) ([43e581f](https://www.github.com/googleapis/gaxios/commit/43e581ff4ed5e79d72f6f29748a5eebb6bff1229))
### [2.2.1](https://www.github.com/googleapis/gaxios/compare/v2.2.0...v2.2.1) (2020-01-04)
### Bug Fixes
* **deps:** update dependency https-proxy-agent to v4 ([#201](https://www.github.com/googleapis/gaxios/issues/201)) ([5cdeef2](https://www.github.com/googleapis/gaxios/commit/5cdeef288a0c5c544c0dc2659aafbb2215d06c4b))
* remove retryDelay option ([#203](https://www.github.com/googleapis/gaxios/issues/203)) ([d21e08d](https://www.github.com/googleapis/gaxios/commit/d21e08d2aada980d39bc5ca7093d54452be2d646))
## [2.2.0](https://www.github.com/googleapis/gaxios/compare/v2.1.1...v2.2.0) (2019-12-05)
### Features
* populate GaxiosResponse with raw response information (res.url) ([#189](https://www.github.com/googleapis/gaxios/issues/189)) ([53a7f54](https://www.github.com/googleapis/gaxios/commit/53a7f54cc0f20320d7a6a21a9a9f36050cec2eec))
### Bug Fixes
* don't retry a request that is aborted intentionally ([#190](https://www.github.com/googleapis/gaxios/issues/190)) ([ba9777b](https://www.github.com/googleapis/gaxios/commit/ba9777b15b5262f8288a8bb3cca49a1de8427d8e))
* **deps:** pin TypeScript below 3.7.0 ([5373f07](https://www.github.com/googleapis/gaxios/commit/5373f0793a765965a8221ecad2f99257ed1b7444))
### [2.1.1](https://www.github.com/googleapis/gaxios/compare/v2.1.0...v2.1.1) (2019-11-15)
### Bug Fixes
* **docs:** snippets are now replaced in jsdoc comments ([#183](https://www.github.com/googleapis/gaxios/issues/183)) ([8dd1324](https://www.github.com/googleapis/gaxios/commit/8dd1324256590bd2f2e9015c813950e1cd8cb330))
## [2.1.0](https://www.github.com/googleapis/gaxios/compare/v2.0.3...v2.1.0) (2019-10-09)
### Bug Fixes
* **deps:** update dependency https-proxy-agent to v3 ([#172](https://www.github.com/googleapis/gaxios/issues/172)) ([4a38f35](https://www.github.com/googleapis/gaxios/commit/4a38f35))
### Features
* **TypeScript:** agent can now be passed as builder method, rather than agent instance ([c84ddd6](https://www.github.com/googleapis/gaxios/commit/c84ddd6))
### [2.0.3](https://www.github.com/googleapis/gaxios/compare/v2.0.2...v2.0.3) (2019-09-11)
### Bug Fixes
* do not override content-type if its given ([#158](https://www.github.com/googleapis/gaxios/issues/158)) ([f49e0e6](https://www.github.com/googleapis/gaxios/commit/f49e0e6))
* improve stream detection logic ([6c41537](https://www.github.com/googleapis/gaxios/commit/6c41537))
* revert header change ([#161](https://www.github.com/googleapis/gaxios/issues/161)) ([b0f6a8b](https://www.github.com/googleapis/gaxios/commit/b0f6a8b))
### [2.0.2](https://www.github.com/googleapis/gaxios/compare/v2.0.1...v2.0.2) (2019-07-23)
### Bug Fixes
* check for existence of fetch before using it ([#138](https://www.github.com/googleapis/gaxios/issues/138)) ([79eb58d](https://www.github.com/googleapis/gaxios/commit/79eb58d))
* **docs:** make anchors work in jsdoc ([#139](https://www.github.com/googleapis/gaxios/issues/139)) ([85103bb](https://www.github.com/googleapis/gaxios/commit/85103bb))
* prevent double option processing ([#142](https://www.github.com/googleapis/gaxios/issues/142)) ([19b4b3c](https://www.github.com/googleapis/gaxios/commit/19b4b3c))

View File

@@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
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.

View File

@@ -0,0 +1,210 @@
# gaxios
[![npm version](https://img.shields.io/npm/v/gaxios.svg)](https://www.npmjs.org/package/gaxios)
[![codecov](https://codecov.io/gh/googleapis/gaxios/branch/master/graph/badge.svg)](https://codecov.io/gh/googleapis/gaxios)
[![Code Style: Google](https://img.shields.io/badge/code%20style-google-blueviolet.svg)](https://github.com/google/gts)
> An HTTP request client that provides an `axios` like interface over top of `node-fetch`.
## Install
```sh
$ npm install gaxios
```
## Example
```js
const {request} = require('gaxios');
const res = await request({
url: 'https://www.googleapis.com/discovery/v1/apis/',
});
```
## Setting Defaults
Gaxios supports setting default properties both on the default instance, and on additional instances. This is often useful when making many requests to the same domain with the same base settings. For example:
```js
const gaxios = require('gaxios');
gaxios.instance.defaults = {
baseURL: 'https://example.com'
headers: {
Authorization: 'SOME_TOKEN'
}
}
gaxios.request({url: '/data'}).then(...);
```
Note that setting default values will take precedence
over other authentication methods, i.e., application default credentials.
## Request Options
```ts
interface GaxiosOptions = {
// The url to which the request should be sent. Required.
url: string,
// The HTTP method to use for the request. Defaults to `GET`.
method: 'GET',
// The base Url to use for the request. Prepended to the `url` property above.
baseURL: 'https://example.com';
// The HTTP methods to be sent with the request.
headers: { 'some': 'header' },
// The data to send in the body of the request. Data objects will be
// serialized as JSON.
//
// Note: if you would like to provide a Content-Type header other than
// application/json you you must provide a string or readable stream, rather
// than an object:
// data: JSON.stringify({some: 'data'})
// data: fs.readFile('./some-data.jpeg')
data: {
some: 'data'
},
// The max size of the http response content in bytes allowed.
// Defaults to `0`, which is the same as unset.
maxContentLength: 2000,
// The max number of HTTP redirects to follow.
// Defaults to 100.
maxRedirects: 100,
// The querystring parameters that will be encoded using `qs` and
// appended to the url
params: {
querystring: 'parameters'
},
// By default, we use the `querystring` package in node core to serialize
// querystring parameters. You can override that and provide your
// own implementation.
paramsSerializer: (params) => {
return qs.stringify(params);
},
// The timeout for the HTTP request in milliseconds. Defaults to 0.
timeout: 1000,
// Optional method to override making the actual HTTP request. Useful
// for writing tests and instrumentation
adapter?: async (options, defaultAdapter) => {
const res = await defaultAdapter(options);
res.data = {
...res.data,
extraProperty: 'your extra property',
};
return res;
};
// The expected return type of the request. Options are:
// json | stream | blob | arraybuffer | text | unknown
// Defaults to `unknown`.
responseType: 'unknown',
// The node.js http agent to use for the request.
agent: someHttpsAgent,
// Custom function to determine if the response is valid based on the
// status code. Defaults to (>= 200 && < 300)
validateStatus: (status: number) => true,
// Implementation of `fetch` to use when making the API call. By default,
// will use the browser context if available, and fall back to `node-fetch`
// in node.js otherwise.
fetchImplementation?: typeof fetch;
// Configuration for retrying of requests.
retryConfig: {
// The number of times to retry the request. Defaults to 3.
retry?: number;
// The number of retries already attempted.
currentRetryAttempt?: 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;
// The amount of time to initially delay the retry, in ms. Defaults to 100ms.
retryDelay?: number;
},
// Enables default configuration for retries.
retry: boolean,
// Cancelling a request requires the `abort-controller` library.
// See https://github.com/bitinn/node-fetch#request-cancellation-with-abortsignal
signal?: AbortSignal
/**
* A collection of parts to send as a `Content-Type: multipart/related` request.
*/
multipart?: GaxiosMultipartOptions;
/**
* 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 `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, customizable error redactor.
*
* Set `false` to disable.
*
* @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;
}
```
## License
[Apache-2.0](https://github.com/googleapis/gaxios/blob/master/LICENSE)

View File

@@ -0,0 +1,274 @@
import { Agent } from 'http';
import { URL } from 'url';
import { Readable } from 'stream';
/**
* 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 = any> extends Error {
config: GaxiosOptions;
response?: GaxiosResponse<T> | undefined;
error?: (Error | NodeJS.ErrnoException) | undefined;
/**
* An Error code.
* See {@link https://nodejs.org/api/errors.html#errorcode error.code}
*
* @example
* 'ECONNRESET'
*/
code?: string;
/**
* An HTTP Status code.
* See {@link https://developer.mozilla.org/en-US/docs/Web/API/Response/status Response: status property}
*
* @example
* 500
*/
status?: number;
/**
* 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: GaxiosOptions, response?: GaxiosResponse<T> | undefined, error?: (Error | NodeJS.ErrnoException) | undefined);
}
export interface Headers {
[index: string]: any;
}
export type GaxiosPromise<T = any> = Promise<GaxiosResponse<T>>;
export interface GaxiosXMLHttpRequest {
responseURL: string;
}
export interface GaxiosResponse<T = any> {
config: GaxiosOptions;
data: T;
status: number;
statusText: string;
headers: Headers;
request: GaxiosXMLHttpRequest;
}
export interface GaxiosMultipartOptions {
headers: Headers;
content: string | Readable;
}
/**
* Request options that are used to form the request.
*/
export interface GaxiosOptions {
/**
* Optional method to override making the actual HTTP request. Useful
* for writing tests.
*/
adapter?: <T = any>(options: GaxiosOptions, defaultAdapter: (options: GaxiosOptions) => GaxiosPromise<T>) => GaxiosPromise<T>;
url?: string | URL;
/**
* @deprecated
*/
baseUrl?: string;
baseURL?: string | URL;
method?: 'GET' | 'HEAD' | 'POST' | 'DELETE' | 'PUT' | 'CONNECT' | 'OPTIONS' | 'TRACE' | 'PATCH';
headers?: Headers;
data?: any;
body?: any;
/**
* The maximum size of the http response content in bytes allowed.
*/
maxContentLength?: number;
/**
* The maximum number of redirects to follow. Defaults to 20.
*/
maxRedirects?: number;
follow?: number;
/**
* A collection of parts to send as a `Content-Type: multipart/related` request.
*/
multipart?: GaxiosMultipartOptions[];
params?: any;
paramsSerializer?: (params: {
[index: string]: string | number;
}) => string;
timeout?: number;
/**
* @deprecated ignored
*/
onUploadProgress?: (progressEvent: any) => void;
responseType?: 'arraybuffer' | 'blob' | 'json' | 'text' | 'stream' | 'unknown';
agent?: Agent | ((parsedUrl: URL) => Agent);
validateStatus?: (status: number) => boolean;
retryConfig?: RetryConfig;
retry?: boolean;
signal?: any;
size?: number;
/**
* Implementation of `fetch` to use when making the API call. By default,
* will use the browser context if available, and fall back to `node-fetch`
* in node.js otherwise.
*/
fetchImplementation?: FetchImplementation;
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;
}
/**
* A partial object of `GaxiosResponse` with only redactable keys
*
* @experimental
*/
export type RedactableGaxiosOptions = Pick<GaxiosOptions, 'body' | 'data' | 'headers' | 'url'>;
/**
* A partial object of `GaxiosResponse` with only redactable keys
*
* @experimental
*/
export type RedactableGaxiosResponse<T = any> = Pick<GaxiosResponse<T>, 'config' | 'data' | 'headers'>;
/**
* Configuration for the Gaxios `request` method.
*/
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;
}
export type FetchImplementation = (input: FetchRequestInfo, init?: FetchRequestInit) => Promise<FetchResponse>;
export type FetchRequestInfo = any;
export interface FetchResponse {
readonly status: number;
readonly statusText: string;
readonly url: string;
readonly body: unknown | null;
arrayBuffer(): Promise<unknown>;
blob(): Promise<unknown>;
readonly headers: FetchHeaders;
json(): Promise<any>;
text(): Promise<string>;
}
export interface FetchRequestInit {
method?: string;
}
export interface FetchHeaders {
append(name: string, value: string): void;
delete(name: string): void;
get(name: string): string | null;
has(name: string): boolean;
set(name: string, value: string): void;
forEach(callbackfn: (value: string, key: string) => void, thisArg?: any): void;
}
/**
* 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<T = any>(data: {
config?: RedactableGaxiosOptions;
response?: RedactableGaxiosResponse<T>;
}): {
config?: RedactableGaxiosOptions;
response?: RedactableGaxiosResponse<T>;
};

View File

@@ -0,0 +1,188 @@
"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.GaxiosError = exports.GAXIOS_ERROR_SYMBOL = void 0;
exports.defaultErrorRedactor = defaultErrorRedactor;
const url_1 = require("url");
const util_1 = require("./util");
const extend_1 = __importDefault(require("extend"));
/**
* Support `instanceof` operator for `GaxiosError`s in different versions of this library.
*
* @see {@link GaxiosError[Symbol.hasInstance]}
*/
exports.GAXIOS_ERROR_SYMBOL = Symbol.for(`${util_1.pkg.name}-gaxios-error`);
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
class GaxiosError extends Error {
/**
* Support `instanceof` operator for `GaxiosError` across builds/duplicated files.
*
* @see {@link GAXIOS_ERROR_SYMBOL}
* @see {@link GaxiosError[GAXIOS_ERROR_SYMBOL]}
*/
static [(_a = exports.GAXIOS_ERROR_SYMBOL, Symbol.hasInstance)](instance) {
if (instance &&
typeof instance === 'object' &&
exports.GAXIOS_ERROR_SYMBOL in instance &&
instance[exports.GAXIOS_ERROR_SYMBOL] === util_1.pkg.version) {
return true;
}
// fallback to native
return Function.prototype[Symbol.hasInstance].call(GaxiosError, instance);
}
constructor(message, config, response, error) {
var _b;
super(message);
this.config = config;
this.response = response;
this.error = 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}
*/
this[_a] = util_1.pkg.version;
// 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, (_b = this.response) === null || _b === void 0 ? void 0 : _b.data);
}
catch (_c) {
// 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 (error && 'code' in error && error.code) {
this.code = error.code;
}
if (config.errorRedactor) {
config.errorRedactor({
config: this.config,
response: this.response,
});
}
}
}
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;
for (const key of Object.keys(headers)) {
// any casing of `Authentication`
if (/^authentication$/i.test(key)) {
headers[key] = REDACT;
}
// any casing of `Authorization`
if (/^authorization$/i.test(key)) {
headers[key] = REDACT;
}
// anything containing secret, such as 'client secret'
if (/secret/i.test(key)) {
headers[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 (typeof obj === 'object' && obj !== null) {
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);
try {
const url = new url_1.URL('', data.config.url);
if (url.searchParams.has('token')) {
url.searchParams.set('token', REDACT);
}
if (url.searchParams.has('client_secret')) {
url.searchParams.set('client_secret', REDACT);
}
data.config.url = url.toString();
}
catch (_b) {
// ignore error - no need to parse an invalid URL
}
}
if (data.response) {
defaultErrorRedactor({ config: data.response.config });
redactHeaders(data.response.headers);
redactString(data.response, 'data');
redactObject(data.response.data);
}
return data;
}
//# sourceMappingURL=common.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/common.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;;;;;;;AAwZjC,oDAiGC;AAtfD,6BAAwB;AAExB,iCAA2B;AAC3B,oDAA4B;AAG5B;;;;GAIG;AACU,QAAA,mBAAmB,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,UAAG,CAAC,IAAI,eAAe,CAAC,CAAC;AAE1E,iEAAiE;AACjE,MAAa,WAAqB,SAAQ,KAAK;IA6B7C;;;;;OAKG;IACH,MAAM,CAAC,OARN,2BAAmB,EAQZ,MAAM,CAAC,WAAW,EAAC,CAAC,QAAiB;QAC3C,IACE,QAAQ;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,62 @@
import { Agent } from 'http';
import { URL } from 'url';
import { GaxiosOptions, GaxiosPromise, GaxiosResponse } from './common';
import { GaxiosInterceptorManager } from './interceptor';
export declare class Gaxios {
#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<GaxiosOptions>;
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);
/**
* Perform an HTTP request with the given options.
* @param opts Set of HTTP options that will be used for this HTTP request.
*/
request<T = any>(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 = any>(opts?: GaxiosOptions): GaxiosPromise<T>;
private getResponseData;
/**
* By default, throw for any non-2xx status code
* @param status status code from the HTTP response
*/
private validateStatus;
/**
* Encode a set of key/value pars into a querystring format (?foo=bar&baz=boo)
* @param params key value pars to encode
*/
private paramsSerializer;
private translateResponse;
/**
* Attempts to parse a response by looking at the Content-Type header.
* @param {FetchResponse} response the HTTP response.
* @returns {Promise<any>} 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 {GaxioMultipartOptions[]} multipartOptions the pieces to turn into a multipart/related body.
* @param {string} boundary the boundary string to be placed between each part.
*/
private getMultipartRequest;
}

View File

@@ -0,0 +1,480 @@
"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 (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _Gaxios_instances, _a, _Gaxios_urlMayUseProxy, _Gaxios_applyRequestInterceptors, _Gaxios_applyResponseInterceptors, _Gaxios_prepareRequest, _Gaxios_proxyAgent, _Gaxios_getProxyAgent;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Gaxios = void 0;
const extend_1 = __importDefault(require("extend"));
const https_1 = require("https");
const node_fetch_1 = __importDefault(require("node-fetch"));
const querystring_1 = __importDefault(require("querystring"));
const is_stream_1 = __importDefault(require("is-stream"));
const url_1 = require("url");
const common_1 = require("./common");
const retry_1 = require("./retry");
const stream_1 = require("stream");
const uuid_1 = require("uuid");
const interceptor_1 = require("./interceptor");
/* eslint-disable @typescript-eslint/no-explicit-any */
const fetch = hasFetch() ? window.fetch : node_fetch_1.default;
function hasWindow() {
return typeof window !== 'undefined' && !!window;
}
function hasFetch() {
return hasWindow() && !!window.fetch;
}
function hasBuffer() {
return typeof Buffer !== 'undefined';
}
function hasHeader(options, header) {
return !!getHeader(options, header);
}
function getHeader(options, header) {
header = header.toLowerCase();
for (const key of Object.keys((options === null || options === void 0 ? void 0 : options.headers) || {})) {
if (header === key.toLowerCase()) {
return options.headers[key];
}
}
return undefined;
}
class Gaxios {
/**
* The Gaxios class is responsible for making HTTP requests.
* @param defaults The default set of options to be used for this instance.
*/
constructor(defaults) {
_Gaxios_instances.add(this);
this.agentCache = new Map();
this.defaults = defaults || {};
this.interceptors = {
request: new interceptor_1.GaxiosInterceptorManager(),
response: new interceptor_1.GaxiosInterceptorManager(),
};
}
/**
* 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 = {}) {
opts = await __classPrivateFieldGet(this, _Gaxios_instances, "m", _Gaxios_prepareRequest).call(this, opts);
opts = await __classPrivateFieldGet(this, _Gaxios_instances, "m", _Gaxios_applyRequestInterceptors).call(this, opts);
return __classPrivateFieldGet(this, _Gaxios_instances, "m", _Gaxios_applyResponseInterceptors).call(this, this._request(opts));
}
async _defaultAdapter(opts) {
const fetchImpl = opts.fetchImplementation || fetch;
const res = (await fetchImpl(opts.url, opts));
const data = await this.getResponseData(opts, res);
return this.translateResponse(opts, res, 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 = {}) {
var _b;
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') {
let response = '';
await new Promise(resolve => {
(translatedResponse === null || translatedResponse === void 0 ? void 0 : translatedResponse.data).on('data', chunk => {
response += chunk;
});
(translatedResponse === null || translatedResponse === void 0 ? void 0 : translatedResponse.data).on('end', resolve);
});
translatedResponse.data = response;
}
throw new common_1.GaxiosError(`Request failed with status code ${translatedResponse.status}`, opts, translatedResponse);
}
return translatedResponse;
}
catch (e) {
const err = e instanceof common_1.GaxiosError
? e
: new common_1.GaxiosError(e.message, opts, undefined, e);
const { shouldRetry, config } = await (0, retry_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 = (_b = err.config) === null || _b === void 0 ? void 0 : _b.retryConfig;
return this._request(opts);
}
throw err;
}
}
async getResponseData(opts, res) {
switch (opts.responseType) {
case 'stream':
return res.body;
case 'json': {
let data = await res.text();
try {
data = JSON.parse(data);
}
catch (_b) {
// continue
}
return data;
}
case 'arraybuffer':
return res.arrayBuffer();
case 'blob':
return res.blob();
case 'text':
return res.text();
default:
return this.getResponseDataFromContentType(res);
}
}
/**
* By default, throw for any non-2xx status code
* @param status status code from the HTTP response
*/
validateStatus(status) {
return status >= 200 && status < 300;
}
/**
* Encode a set of key/value pars into a querystring format (?foo=bar&baz=boo)
* @param params key value pars to encode
*/
paramsSerializer(params) {
return querystring_1.default.stringify(params);
}
translateResponse(opts, res, data) {
// headers need to be converted from a map to an obj
const headers = {};
res.headers.forEach((value, key) => {
headers[key] = value;
});
return {
config: opts,
data: data,
headers,
status: res.status,
statusText: res.statusText,
// XMLHttpRequestLike
request: {
responseURL: res.url,
},
};
}
/**
* Attempts to parse a response by looking at the Content-Type header.
* @param {FetchResponse} response the HTTP response.
* @returns {Promise<any>} 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 (_b) {
// 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 {GaxioMultipartOptions[]} 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['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;
}
}
exports.Gaxios = Gaxios;
_a = Gaxios, _Gaxios_instances = new WeakSet(), _Gaxios_urlMayUseProxy = function _Gaxios_urlMayUseProxy(url, noProxy = []) {
var _b, _c;
const candidate = new url_1.URL(url);
const noProxyList = [...noProxy];
const noProxyEnvList = ((_c = ((_b = process.env.NO_PROXY) !== null && _b !== void 0 ? _b : process.env.no_proxy)) === null || _c === void 0 ? void 0 : _c.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_1.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;
}, _Gaxios_applyRequestInterceptors =
/**
* Applies the request interceptors. The request interceptors are applied after the
* call to prepareRequest is completed.
*
* @param {GaxiosOptions} options The current set of options.
*
* @returns {Promise<GaxiosOptions>} Promise that resolves to the set of options or response after interceptors are applied.
*/
async function _Gaxios_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;
}, _Gaxios_applyResponseInterceptors =
/**
* Applies the response interceptors. The response interceptors are applied after the
* call to request is made.
*
* @param {GaxiosOptions} options The current set of options.
*
* @returns {Promise<GaxiosOptions>} Promise that resolves to the set of options or response after interceptors are applied.
*/
async function _Gaxios_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;
}, _Gaxios_prepareRequest =
/**
* 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 function _Gaxios_prepareRequest(options) {
var _b, _c, _d, _e;
const opts = (0, extend_1.default)(true, {}, this.defaults, options);
if (!opts.url) {
throw new Error('URL is required.');
}
// baseUrl has been deprecated, remove in 2.0
const baseUrl = opts.baseUrl || opts.baseURL;
if (baseUrl) {
opts.url = baseUrl.toString() + opts.url;
}
opts.paramsSerializer = opts.paramsSerializer || this.paramsSerializer;
if (opts.params && Object.keys(opts.params).length > 0) {
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;
}
if (typeof options.maxContentLength === 'number') {
opts.size = options.maxContentLength;
}
if (typeof options.maxRedirects === 'number') {
opts.follow = options.maxRedirects;
}
opts.headers = opts.headers || {};
if (opts.multipart === undefined && opts.data) {
const isFormData = typeof FormData === 'undefined'
? false
: (opts === null || opts === void 0 ? void 0 : opts.data) instanceof FormData;
if (is_stream_1.default.readable(opts.data)) {
opts.body = opts.data;
}
else if (hasBuffer() && Buffer.isBuffer(opts.data)) {
// Do not attempt to JSON.stringify() a Buffer:
opts.body = opts.data;
if (!hasHeader(opts, 'Content-Type')) {
opts.headers['Content-Type'] = 'application/json';
}
}
else if (typeof opts.data === 'object') {
// If www-form-urlencoded content type has been set, but data is
// provided as an object, serialize the content using querystring:
if (!isFormData) {
if (getHeader(opts, 'content-type') ===
'application/x-www-form-urlencoded') {
opts.body = opts.paramsSerializer(opts.data);
}
else {
// } else if (!(opts.data instanceof FormData)) {
if (!hasHeader(opts, 'Content-Type')) {
opts.headers['Content-Type'] = 'application/json';
}
opts.body = JSON.stringify(opts.data);
}
}
}
else {
opts.body = opts.data;
}
}
else if (opts.multipart && opts.multipart.length > 0) {
// note: once the minimum version reaches Node 16,
// this can be replaced with randomUUID() function from crypto
// and the dependency on UUID removed
const boundary = (0, uuid_1.v4)();
opts.headers['Content-Type'] = `multipart/related; boundary=${boundary}`;
const bodyStream = new stream_1.PassThrough();
opts.body = bodyStream;
(0, stream_1.pipeline)(this.getMultipartRequest(opts.multipart, boundary), bodyStream, () => { });
}
opts.validateStatus = opts.validateStatus || this.validateStatus;
opts.responseType = opts.responseType || 'unknown';
if (!opts.headers['Accept'] && opts.responseType === 'json') {
opts.headers['Accept'] = 'application/json';
}
opts.method = opts.method || 'GET';
const proxy = opts.proxy ||
((_b = process === null || process === void 0 ? void 0 : process.env) === null || _b === void 0 ? void 0 : _b.HTTPS_PROXY) ||
((_c = process === null || process === void 0 ? void 0 : process.env) === null || _c === void 0 ? void 0 : _c.https_proxy) ||
((_d = process === null || process === void 0 ? void 0 : process.env) === null || _d === void 0 ? void 0 : _d.HTTP_PROXY) ||
((_e = process === null || process === void 0 ? void 0 : process.env) === null || _e === void 0 ? void 0 : _e.http_proxy);
const urlMayUseProxy = __classPrivateFieldGet(this, _Gaxios_instances, "m", _Gaxios_urlMayUseProxy).call(this, opts.url, opts.noProxy);
if (opts.agent) {
// don't do any of the following options - use the user-provided agent.
}
else if (proxy && urlMayUseProxy) {
const HttpsProxyAgent = await __classPrivateFieldGet(_a, _a, "m", _Gaxios_getProxyAgent).call(_a);
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_1.defaultErrorRedactor;
}
return opts;
}, _Gaxios_getProxyAgent = async function _Gaxios_getProxyAgent() {
__classPrivateFieldSet(this, _a, __classPrivateFieldGet(this, _a, "f", _Gaxios_proxyAgent) || (await Promise.resolve().then(() => __importStar(require('https-proxy-agent')))).HttpsProxyAgent, "f", _Gaxios_proxyAgent);
return __classPrivateFieldGet(this, _a, "f", _Gaxios_proxyAgent);
};
/**
* A cache for the lazily-loaded proxy agent.
*
* Should use {@link Gaxios[#getProxyAgent]} to retrieve.
*/
// using `import` to dynamically import the types here
_Gaxios_proxyAgent = { value: void 0 };
//# sourceMappingURL=gaxios.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,15 @@
import { GaxiosOptions } from './common';
import { Gaxios } from './gaxios';
export { GaxiosError, GaxiosPromise, GaxiosResponse, Headers, RetryConfig, } from './common';
export { Gaxios, GaxiosOptions };
export * from './interceptor';
/**
* 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").GaxiosResponse<T>>;

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_1 = require("./gaxios");
Object.defineProperty(exports, "Gaxios", { enumerable: true, get: function () { return gaxios_1.Gaxios; } });
var common_1 = require("./common");
Object.defineProperty(exports, "GaxiosError", { enumerable: true, get: function () { return common_1.GaxiosError; } });
__exportStar(require("./interceptor"), exports);
/**
* The default instance used when the `request` method is directly
* invoked.
*/
exports.instance = new gaxios_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

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,qCAAgC;AASxB,uFATA,eAAM,OASA;AAPd,mCAMkB;AALhB,qGAAA,WAAW,OAAA;AAOb,gDAA8B;AAE9B;;;GAGG;AACU,QAAA,QAAQ,GAAG,IAAI,eAAM,EAAE,CAAC;AAErC;;;GAGG;AACI,KAAK,UAAU,OAAO,CAAI,IAAmB;IAClD,OAAO,gBAAQ,CAAC,OAAO,CAAI,IAAI,CAAC,CAAC;AACnC,CAAC"}

View File

@@ -0,0 +1,25 @@
import { GaxiosError, GaxiosOptions, GaxiosResponse } from './common';
/**
* Interceptors that can be run for requests or responses. These interceptors run asynchronously.
*/
export interface GaxiosInterceptor<T extends GaxiosOptions | 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 GaxiosOptions | GaxiosResponse> extends Set<GaxiosInterceptor<T> | null> {
}

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

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;;;AAwBjC;;GAEG;AACH,MAAa,wBAEX,SAAQ,GAAgC;CAAG;AAF7C,4DAE6C"}

View File

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

View File

@@ -0,0 +1,166 @@
"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! Incremenent 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) {
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) {
var _a;
const config = getConfig(err);
// node-fetch raises an AbortError if signaled:
// https://github.com/bitinn/node-fetch#request-cancellation-with-abortsignal
if (err.name === 'AbortError' || ((_a = err.error) === null || _a === void 0 ? void 0 : _a.name) === '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 (!err.config.method ||
config.httpMethodsToRetry.indexOf(err.config.method.toUpperCase()) < 0) {
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) {
var _a;
// Calculate time to wait with exponential backoff.
// If this is the first retry, look for a configured retryDelay.
const retryDelay = config.currentRetryAttempt ? 0 : (_a = config.retryDelay) !== null && _a !== void 0 ? _a : 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

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,wCAgFC;AAhFM,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,kBAAkB,IAAI;QACvD,KAAK;QACL,MAAM;QACN,KAAK;QACL,SAAS;QACT,QAAQ;KACT,CAAC;IACF,MAAM,CAAC,iBAAiB;QACtB,MAAM,CAAC,iBAAiB,KAAK,SAAS,IAAI,MAAM,CAAC,iBAAiB,KAAK,IAAI;YACzE,CAAC,CAAC,CAAC;YACH,CAAC,CAAC,MAAM,CAAC,iBAAiB,CAAC;IAC/B,MAAM,CAAC,oBAAoB,GAAG,MAAM,CAAC,oBAAoB;QACvD,CAAC,CAA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AC,CAAC,CAAC,MAAA,MAAM,CAAC,UAAU,mCAAI,GAAG,CAAC;IAC7E,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"}

View File

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

View File

@@ -0,0 +1,17 @@
"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.
Object.defineProperty(exports, "__esModule", { value: true });
exports.pkg = void 0;
exports.pkg = require('../../package.json');
//# sourceMappingURL=util.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/util.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;;;AAEpB,QAAA,GAAG,GAGZ,OAAO,CAAC,oBAAoB,CAAC,CAAC"}

View File

@@ -0,0 +1,96 @@
{
"name": "gaxios",
"version": "6.7.1",
"description": "A simple common HTTP client specifically for Google APIs and services.",
"main": "build/src/index.js",
"types": "build/src/index.d.ts",
"files": [
"build/src"
],
"scripts": {
"lint": "gts check",
"test": "c8 mocha build/test",
"presystem-test": "npm run compile",
"system-test": "mocha build/system-test --timeout 80000",
"compile": "tsc -p .",
"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": "compodoc src/",
"docs-test": "linkinator docs",
"predocs-test": "npm run docs",
"samples-test": "cd samples/ && npm link ../ && npm test && cd ../",
"prelint": "cd samples; npm link ../; npm install",
"clean": "gts clean",
"precompile": "gts clean"
},
"repository": "googleapis/gaxios",
"keywords": [
"google"
],
"engines": {
"node": ">=14"
},
"author": "Google, LLC",
"license": "Apache-2.0",
"devDependencies": {
"@babel/plugin-proposal-private-methods": "^7.18.6",
"@compodoc/compodoc": "1.1.19",
"@types/cors": "^2.8.6",
"@types/express": "^4.16.1",
"@types/extend": "^3.0.1",
"@types/mocha": "^9.0.0",
"@types/multiparty": "0.0.36",
"@types/mv": "^2.1.0",
"@types/ncp": "^2.0.1",
"@types/node": "^20.0.0",
"@types/node-fetch": "^2.5.7",
"@types/sinon": "^17.0.0",
"@types/tmp": "0.2.6",
"@types/uuid": "^10.0.0",
"abort-controller": "^3.0.0",
"assert": "^2.0.0",
"browserify": "^17.0.0",
"c8": "^8.0.0",
"cheerio": "1.0.0-rc.10",
"cors": "^2.8.5",
"execa": "^5.0.0",
"express": "^4.16.4",
"form-data": "^4.0.0",
"gts": "^5.0.0",
"is-docker": "^2.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.0",
"linkinator": "^3.0.0",
"mocha": "^8.0.0",
"multiparty": "^4.2.1",
"mv": "^2.1.1",
"ncp": "^2.0.0",
"nock": "^13.0.0",
"null-loader": "^4.0.0",
"puppeteer": "^19.0.0",
"sinon": "^18.0.0",
"stream-browserify": "^3.0.0",
"tmp": "0.2.3",
"ts-loader": "^8.0.0",
"typescript": "^5.1.6",
"webpack": "^5.35.0",
"webpack-cli": "^4.0.0"
},
"dependencies": {
"extend": "^3.0.2",
"https-proxy-agent": "^7.0.1",
"is-stream": "^2.0.0",
"node-fetch": "^2.6.9",
"uuid": "^9.0.1"
}
}