Add proxy support (#218)
This commit is contained in:
parent
246692c248
commit
c4e906d161
2
dist/main/index.js
vendored
2
dist/main/index.js
vendored
File diff suppressed because one or more lines are too long
283
package-lock.json
generated
283
package-lock.json
generated
@ -10,23 +10,24 @@
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.9.1",
|
||||
"@actions/http-client": "^2.0.1",
|
||||
"@google-github-actions/actions-utils": "^0.4.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/chai": "^4.3.3",
|
||||
"@types/mocha": "^9.1.1",
|
||||
"@types/node": "^18.7.13",
|
||||
"@typescript-eslint/eslint-plugin": "^5.34.0",
|
||||
"@typescript-eslint/parser": "^5.34.0",
|
||||
"@types/node": "^18.7.14",
|
||||
"@typescript-eslint/eslint-plugin": "^5.36.1",
|
||||
"@typescript-eslint/parser": "^5.36.1",
|
||||
"@vercel/ncc": "^0.34.0",
|
||||
"chai": "^4.3.6",
|
||||
"eslint": "^8.22.0",
|
||||
"eslint": "^8.23.0",
|
||||
"eslint-config-prettier": "^8.5.0",
|
||||
"eslint-plugin-prettier": "^4.2.1",
|
||||
"mocha": "^10.0.0",
|
||||
"prettier": "^2.7.1",
|
||||
"ts-node": "^10.9.1",
|
||||
"typescript": "^4.7.4"
|
||||
"typescript": "^4.8.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@actions/core": {
|
||||
@ -59,14 +60,14 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@eslint/eslintrc": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.3.0.tgz",
|
||||
"integrity": "sha512-UWW0TMTmk2d7hLcWD1/e2g5HDM/HQ3csaLSqXCfqwh4uNDuNqlaKWXmEsL4Cs41Z0KnILNvwbHAah3C2yt06kw==",
|
||||
"version": "1.3.1",
|
||||
"resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.3.1.tgz",
|
||||
"integrity": "sha512-OhSY22oQQdw3zgPOOwdoj01l/Dzl1Z+xyUP33tkSN+aqyEhymJCcPHyXt+ylW8FSe0TfRC2VG+ROQOapD0aZSQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"ajv": "^6.12.4",
|
||||
"debug": "^4.3.2",
|
||||
"espree": "^9.3.2",
|
||||
"espree": "^9.4.0",
|
||||
"globals": "^13.15.0",
|
||||
"ignore": "^5.2.0",
|
||||
"import-fresh": "^3.2.1",
|
||||
@ -76,6 +77,9 @@
|
||||
},
|
||||
"engines": {
|
||||
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/eslint"
|
||||
}
|
||||
},
|
||||
"node_modules/@google-github-actions/actions-utils": {
|
||||
@ -110,6 +114,19 @@
|
||||
"url": "https://github.com/sponsors/nzakas"
|
||||
}
|
||||
},
|
||||
"node_modules/@humanwhocodes/module-importer": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz",
|
||||
"integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=12.22"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/nzakas"
|
||||
}
|
||||
},
|
||||
"node_modules/@humanwhocodes/object-schema": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz",
|
||||
@ -219,20 +236,20 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "18.7.13",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.7.13.tgz",
|
||||
"integrity": "sha512-46yIhxSe5xEaJZXWdIBP7GU4HDTG8/eo0qd9atdiL+lFpA03y8KS+lkTN834TWJj5767GbWv4n/P6efyTFt1Dw==",
|
||||
"version": "18.7.14",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.7.14.tgz",
|
||||
"integrity": "sha512-6bbDaETVi8oyIARulOE9qF1/Qdi/23z6emrUh0fNJRUmjznqrixD4MpGDdgOFk5Xb0m2H6Xu42JGdvAxaJR/wA==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@typescript-eslint/eslint-plugin": {
|
||||
"version": "5.34.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.34.0.tgz",
|
||||
"integrity": "sha512-eRfPPcasO39iwjlUAMtjeueRGuIrW3TQ9WseIDl7i5UWuFbf83yYaU7YPs4j8+4CxUMIsj1k+4kV+E+G+6ypDQ==",
|
||||
"version": "5.36.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.36.1.tgz",
|
||||
"integrity": "sha512-iC40UK8q1tMepSDwiLbTbMXKDxzNy+4TfPWgIL661Ym0sD42vRcQU93IsZIrmi+x292DBr60UI/gSwfdVYexCA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@typescript-eslint/scope-manager": "5.34.0",
|
||||
"@typescript-eslint/type-utils": "5.34.0",
|
||||
"@typescript-eslint/utils": "5.34.0",
|
||||
"@typescript-eslint/scope-manager": "5.36.1",
|
||||
"@typescript-eslint/type-utils": "5.36.1",
|
||||
"@typescript-eslint/utils": "5.36.1",
|
||||
"debug": "^4.3.4",
|
||||
"functional-red-black-tree": "^1.0.1",
|
||||
"ignore": "^5.2.0",
|
||||
@ -258,14 +275,14 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/parser": {
|
||||
"version": "5.34.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.34.0.tgz",
|
||||
"integrity": "sha512-SZ3NEnK4usd2CXkoV3jPa/vo1mWX1fqRyIVUQZR4As1vyp4fneknBNJj+OFtV8WAVgGf+rOHMSqQbs2Qn3nFZQ==",
|
||||
"version": "5.36.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.36.1.tgz",
|
||||
"integrity": "sha512-/IsgNGOkBi7CuDfUbwt1eOqUXF9WGVBW9dwEe1pi+L32XrTsZIgmDFIi2RxjzsvB/8i+MIf5JIoTEH8LOZ368A==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@typescript-eslint/scope-manager": "5.34.0",
|
||||
"@typescript-eslint/types": "5.34.0",
|
||||
"@typescript-eslint/typescript-estree": "5.34.0",
|
||||
"@typescript-eslint/scope-manager": "5.36.1",
|
||||
"@typescript-eslint/types": "5.36.1",
|
||||
"@typescript-eslint/typescript-estree": "5.36.1",
|
||||
"debug": "^4.3.4"
|
||||
},
|
||||
"engines": {
|
||||
@ -285,13 +302,13 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/scope-manager": {
|
||||
"version": "5.34.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.34.0.tgz",
|
||||
"integrity": "sha512-HNvASMQlah5RsBW6L6c7IJ0vsm+8Sope/wu5sEAf7joJYWNb1LDbJipzmdhdUOnfrDFE6LR1j57x1EYVxrY4ow==",
|
||||
"version": "5.36.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.36.1.tgz",
|
||||
"integrity": "sha512-pGC2SH3/tXdu9IH3ItoqciD3f3RRGCh7hb9zPdN2Drsr341zgd6VbhP5OHQO/reUqihNltfPpMpTNihFMarP2w==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "5.34.0",
|
||||
"@typescript-eslint/visitor-keys": "5.34.0"
|
||||
"@typescript-eslint/types": "5.36.1",
|
||||
"@typescript-eslint/visitor-keys": "5.36.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
|
||||
@ -302,12 +319,13 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/type-utils": {
|
||||
"version": "5.34.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.34.0.tgz",
|
||||
"integrity": "sha512-Pxlno9bjsQ7hs1pdWRUv9aJijGYPYsHpwMeCQ/Inavhym3/XaKt1ZKAA8FIw4odTBfowBdZJDMxf2aavyMDkLg==",
|
||||
"version": "5.36.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.36.1.tgz",
|
||||
"integrity": "sha512-xfZhfmoQT6m3lmlqDvDzv9TiCYdw22cdj06xY0obSznBsT///GK5IEZQdGliXpAOaRL34o8phEvXzEo/VJx13Q==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@typescript-eslint/utils": "5.34.0",
|
||||
"@typescript-eslint/typescript-estree": "5.36.1",
|
||||
"@typescript-eslint/utils": "5.36.1",
|
||||
"debug": "^4.3.4",
|
||||
"tsutils": "^3.21.0"
|
||||
},
|
||||
@ -328,9 +346,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/types": {
|
||||
"version": "5.34.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.34.0.tgz",
|
||||
"integrity": "sha512-49fm3xbbUPuzBIOcy2CDpYWqy/X7VBkxVN+DC21e0zIm3+61Z0NZi6J9mqPmSW1BDVk9FIOvuCFyUPjXz93sjA==",
|
||||
"version": "5.36.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.36.1.tgz",
|
||||
"integrity": "sha512-jd93ShpsIk1KgBTx9E+hCSEuLCUFwi9V/urhjOWnOaksGZFbTOxAT47OH2d4NLJnLhkVD+wDbB48BuaycZPLBg==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
|
||||
@ -341,13 +359,13 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/typescript-estree": {
|
||||
"version": "5.34.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.34.0.tgz",
|
||||
"integrity": "sha512-mXHAqapJJDVzxauEkfJI96j3D10sd567LlqroyCeJaHnu42sDbjxotGb3XFtGPYKPD9IyLjhsoULML1oI3M86A==",
|
||||
"version": "5.36.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.36.1.tgz",
|
||||
"integrity": "sha512-ih7V52zvHdiX6WcPjsOdmADhYMDN15SylWRZrT2OMy80wzKbc79n8wFW0xpWpU0x3VpBz/oDgTm2xwDAnFTl+g==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "5.34.0",
|
||||
"@typescript-eslint/visitor-keys": "5.34.0",
|
||||
"@typescript-eslint/types": "5.36.1",
|
||||
"@typescript-eslint/visitor-keys": "5.36.1",
|
||||
"debug": "^4.3.4",
|
||||
"globby": "^11.1.0",
|
||||
"is-glob": "^4.0.3",
|
||||
@ -368,15 +386,15 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/utils": {
|
||||
"version": "5.34.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.34.0.tgz",
|
||||
"integrity": "sha512-kWRYybU4Rn++7lm9yu8pbuydRyQsHRoBDIo11k7eqBWTldN4xUdVUMCsHBiE7aoEkFzrUEaZy3iH477vr4xHAQ==",
|
||||
"version": "5.36.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.36.1.tgz",
|
||||
"integrity": "sha512-lNj4FtTiXm5c+u0pUehozaUWhh7UYKnwryku0nxJlYUEWetyG92uw2pr+2Iy4M/u0ONMKzfrx7AsGBTCzORmIg==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@types/json-schema": "^7.0.9",
|
||||
"@typescript-eslint/scope-manager": "5.34.0",
|
||||
"@typescript-eslint/types": "5.34.0",
|
||||
"@typescript-eslint/typescript-estree": "5.34.0",
|
||||
"@typescript-eslint/scope-manager": "5.36.1",
|
||||
"@typescript-eslint/types": "5.36.1",
|
||||
"@typescript-eslint/typescript-estree": "5.36.1",
|
||||
"eslint-scope": "^5.1.1",
|
||||
"eslint-utils": "^3.0.0"
|
||||
},
|
||||
@ -392,12 +410,12 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/visitor-keys": {
|
||||
"version": "5.34.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.34.0.tgz",
|
||||
"integrity": "sha512-O1moYjOSrab0a2fUvFpsJe0QHtvTC+cR+ovYpgKrAVXzqQyc74mv76TgY6z+aEtjQE2vgZux3CQVtGryqdcOAw==",
|
||||
"version": "5.36.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.36.1.tgz",
|
||||
"integrity": "sha512-ojB9aRyRFzVMN3b5joSYni6FAS10BBSCAfKJhjJAV08t/a95aM6tAhz+O1jF+EtgxktuSO3wJysp2R+Def/IWQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "5.34.0",
|
||||
"@typescript-eslint/types": "5.36.1",
|
||||
"eslint-visitor-keys": "^3.3.0"
|
||||
},
|
||||
"engines": {
|
||||
@ -854,14 +872,15 @@
|
||||
}
|
||||
},
|
||||
"node_modules/eslint": {
|
||||
"version": "8.22.0",
|
||||
"resolved": "https://registry.npmjs.org/eslint/-/eslint-8.22.0.tgz",
|
||||
"integrity": "sha512-ci4t0sz6vSRKdmkOGmprBo6fmI4PrphDFMy5JEq/fNS0gQkJM3rLmrqcp8ipMcdobH3KtUP40KniAE9W19S4wA==",
|
||||
"version": "8.23.0",
|
||||
"resolved": "https://registry.npmjs.org/eslint/-/eslint-8.23.0.tgz",
|
||||
"integrity": "sha512-pBG/XOn0MsJcKcTRLr27S5HpzQo4kLr+HjLQIyK4EiCsijDl/TB+h5uEuJU6bQ8Edvwz1XWOjpaP2qgnXGpTcA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@eslint/eslintrc": "^1.3.0",
|
||||
"@eslint/eslintrc": "^1.3.1",
|
||||
"@humanwhocodes/config-array": "^0.10.4",
|
||||
"@humanwhocodes/gitignore-to-minimatch": "^1.0.2",
|
||||
"@humanwhocodes/module-importer": "^1.0.1",
|
||||
"ajv": "^6.10.0",
|
||||
"chalk": "^4.0.0",
|
||||
"cross-spawn": "^7.0.2",
|
||||
@ -871,7 +890,7 @@
|
||||
"eslint-scope": "^7.1.1",
|
||||
"eslint-utils": "^3.0.0",
|
||||
"eslint-visitor-keys": "^3.3.0",
|
||||
"espree": "^9.3.3",
|
||||
"espree": "^9.4.0",
|
||||
"esquery": "^1.4.0",
|
||||
"esutils": "^2.0.2",
|
||||
"fast-deep-equal": "^3.1.3",
|
||||
@ -896,8 +915,7 @@
|
||||
"regexpp": "^3.2.0",
|
||||
"strip-ansi": "^6.0.1",
|
||||
"strip-json-comments": "^3.1.0",
|
||||
"text-table": "^0.2.0",
|
||||
"v8-compile-cache": "^2.0.3"
|
||||
"text-table": "^0.2.0"
|
||||
},
|
||||
"bin": {
|
||||
"eslint": "bin/eslint.js"
|
||||
@ -1014,9 +1032,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/espree": {
|
||||
"version": "9.3.3",
|
||||
"resolved": "https://registry.npmjs.org/espree/-/espree-9.3.3.tgz",
|
||||
"integrity": "sha512-ORs1Rt/uQTqUKjDdGCyrtYxbazf5umATSf/K4qxjmZHORR6HJk+2s/2Pqe+Kk49HHINC/xNIrGfgh8sZcll0ng==",
|
||||
"version": "9.4.0",
|
||||
"resolved": "https://registry.npmjs.org/espree/-/espree-9.4.0.tgz",
|
||||
"integrity": "sha512-DQmnRpLj7f6TgN/NYb0MTzJXL+vJF9h3pHy4JhCIs3zwcgez8xmGg3sXHcEO97BrmO2OSvCwMdfdlyl+E9KjOw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"acorn": "^8.8.0",
|
||||
@ -2279,9 +2297,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/typescript": {
|
||||
"version": "4.7.4",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.7.4.tgz",
|
||||
"integrity": "sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ==",
|
||||
"version": "4.8.2",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.2.tgz",
|
||||
"integrity": "sha512-C0I1UsrrDHo2fYI5oaCGbSejwX4ch+9Y5jTQELvovfmFkK3HHSZJB8MSJcWLmCUBzQBchCrZ9rMRV6GuNrvGtw==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
@ -2308,12 +2326,6 @@
|
||||
"uuid": "dist/bin/uuid"
|
||||
}
|
||||
},
|
||||
"node_modules/v8-compile-cache": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz",
|
||||
"integrity": "sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/v8-compile-cache-lib": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz",
|
||||
@ -2488,14 +2500,14 @@
|
||||
}
|
||||
},
|
||||
"@eslint/eslintrc": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.3.0.tgz",
|
||||
"integrity": "sha512-UWW0TMTmk2d7hLcWD1/e2g5HDM/HQ3csaLSqXCfqwh4uNDuNqlaKWXmEsL4Cs41Z0KnILNvwbHAah3C2yt06kw==",
|
||||
"version": "1.3.1",
|
||||
"resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.3.1.tgz",
|
||||
"integrity": "sha512-OhSY22oQQdw3zgPOOwdoj01l/Dzl1Z+xyUP33tkSN+aqyEhymJCcPHyXt+ylW8FSe0TfRC2VG+ROQOapD0aZSQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ajv": "^6.12.4",
|
||||
"debug": "^4.3.2",
|
||||
"espree": "^9.3.2",
|
||||
"espree": "^9.4.0",
|
||||
"globals": "^13.15.0",
|
||||
"ignore": "^5.2.0",
|
||||
"import-fresh": "^3.2.1",
|
||||
@ -2529,6 +2541,12 @@
|
||||
"integrity": "sha512-rSqmMJDdLFUsyxR6FMtD00nfQKKLFb1kv+qBbOVKqErvloEIJLo5bDTJTQNTYgeyp78JsA7u/NPi5jT1GR/MuA==",
|
||||
"dev": true
|
||||
},
|
||||
"@humanwhocodes/module-importer": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz",
|
||||
"integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==",
|
||||
"dev": true
|
||||
},
|
||||
"@humanwhocodes/object-schema": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz",
|
||||
@ -2626,20 +2644,20 @@
|
||||
"dev": true
|
||||
},
|
||||
"@types/node": {
|
||||
"version": "18.7.13",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.7.13.tgz",
|
||||
"integrity": "sha512-46yIhxSe5xEaJZXWdIBP7GU4HDTG8/eo0qd9atdiL+lFpA03y8KS+lkTN834TWJj5767GbWv4n/P6efyTFt1Dw==",
|
||||
"version": "18.7.14",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.7.14.tgz",
|
||||
"integrity": "sha512-6bbDaETVi8oyIARulOE9qF1/Qdi/23z6emrUh0fNJRUmjznqrixD4MpGDdgOFk5Xb0m2H6Xu42JGdvAxaJR/wA==",
|
||||
"dev": true
|
||||
},
|
||||
"@typescript-eslint/eslint-plugin": {
|
||||
"version": "5.34.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.34.0.tgz",
|
||||
"integrity": "sha512-eRfPPcasO39iwjlUAMtjeueRGuIrW3TQ9WseIDl7i5UWuFbf83yYaU7YPs4j8+4CxUMIsj1k+4kV+E+G+6ypDQ==",
|
||||
"version": "5.36.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.36.1.tgz",
|
||||
"integrity": "sha512-iC40UK8q1tMepSDwiLbTbMXKDxzNy+4TfPWgIL661Ym0sD42vRcQU93IsZIrmi+x292DBr60UI/gSwfdVYexCA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@typescript-eslint/scope-manager": "5.34.0",
|
||||
"@typescript-eslint/type-utils": "5.34.0",
|
||||
"@typescript-eslint/utils": "5.34.0",
|
||||
"@typescript-eslint/scope-manager": "5.36.1",
|
||||
"@typescript-eslint/type-utils": "5.36.1",
|
||||
"@typescript-eslint/utils": "5.36.1",
|
||||
"debug": "^4.3.4",
|
||||
"functional-red-black-tree": "^1.0.1",
|
||||
"ignore": "^5.2.0",
|
||||
@ -2649,52 +2667,53 @@
|
||||
}
|
||||
},
|
||||
"@typescript-eslint/parser": {
|
||||
"version": "5.34.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.34.0.tgz",
|
||||
"integrity": "sha512-SZ3NEnK4usd2CXkoV3jPa/vo1mWX1fqRyIVUQZR4As1vyp4fneknBNJj+OFtV8WAVgGf+rOHMSqQbs2Qn3nFZQ==",
|
||||
"version": "5.36.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.36.1.tgz",
|
||||
"integrity": "sha512-/IsgNGOkBi7CuDfUbwt1eOqUXF9WGVBW9dwEe1pi+L32XrTsZIgmDFIi2RxjzsvB/8i+MIf5JIoTEH8LOZ368A==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@typescript-eslint/scope-manager": "5.34.0",
|
||||
"@typescript-eslint/types": "5.34.0",
|
||||
"@typescript-eslint/typescript-estree": "5.34.0",
|
||||
"@typescript-eslint/scope-manager": "5.36.1",
|
||||
"@typescript-eslint/types": "5.36.1",
|
||||
"@typescript-eslint/typescript-estree": "5.36.1",
|
||||
"debug": "^4.3.4"
|
||||
}
|
||||
},
|
||||
"@typescript-eslint/scope-manager": {
|
||||
"version": "5.34.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.34.0.tgz",
|
||||
"integrity": "sha512-HNvASMQlah5RsBW6L6c7IJ0vsm+8Sope/wu5sEAf7joJYWNb1LDbJipzmdhdUOnfrDFE6LR1j57x1EYVxrY4ow==",
|
||||
"version": "5.36.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.36.1.tgz",
|
||||
"integrity": "sha512-pGC2SH3/tXdu9IH3ItoqciD3f3RRGCh7hb9zPdN2Drsr341zgd6VbhP5OHQO/reUqihNltfPpMpTNihFMarP2w==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@typescript-eslint/types": "5.34.0",
|
||||
"@typescript-eslint/visitor-keys": "5.34.0"
|
||||
"@typescript-eslint/types": "5.36.1",
|
||||
"@typescript-eslint/visitor-keys": "5.36.1"
|
||||
}
|
||||
},
|
||||
"@typescript-eslint/type-utils": {
|
||||
"version": "5.34.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.34.0.tgz",
|
||||
"integrity": "sha512-Pxlno9bjsQ7hs1pdWRUv9aJijGYPYsHpwMeCQ/Inavhym3/XaKt1ZKAA8FIw4odTBfowBdZJDMxf2aavyMDkLg==",
|
||||
"version": "5.36.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.36.1.tgz",
|
||||
"integrity": "sha512-xfZhfmoQT6m3lmlqDvDzv9TiCYdw22cdj06xY0obSznBsT///GK5IEZQdGliXpAOaRL34o8phEvXzEo/VJx13Q==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@typescript-eslint/utils": "5.34.0",
|
||||
"@typescript-eslint/typescript-estree": "5.36.1",
|
||||
"@typescript-eslint/utils": "5.36.1",
|
||||
"debug": "^4.3.4",
|
||||
"tsutils": "^3.21.0"
|
||||
}
|
||||
},
|
||||
"@typescript-eslint/types": {
|
||||
"version": "5.34.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.34.0.tgz",
|
||||
"integrity": "sha512-49fm3xbbUPuzBIOcy2CDpYWqy/X7VBkxVN+DC21e0zIm3+61Z0NZi6J9mqPmSW1BDVk9FIOvuCFyUPjXz93sjA==",
|
||||
"version": "5.36.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.36.1.tgz",
|
||||
"integrity": "sha512-jd93ShpsIk1KgBTx9E+hCSEuLCUFwi9V/urhjOWnOaksGZFbTOxAT47OH2d4NLJnLhkVD+wDbB48BuaycZPLBg==",
|
||||
"dev": true
|
||||
},
|
||||
"@typescript-eslint/typescript-estree": {
|
||||
"version": "5.34.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.34.0.tgz",
|
||||
"integrity": "sha512-mXHAqapJJDVzxauEkfJI96j3D10sd567LlqroyCeJaHnu42sDbjxotGb3XFtGPYKPD9IyLjhsoULML1oI3M86A==",
|
||||
"version": "5.36.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.36.1.tgz",
|
||||
"integrity": "sha512-ih7V52zvHdiX6WcPjsOdmADhYMDN15SylWRZrT2OMy80wzKbc79n8wFW0xpWpU0x3VpBz/oDgTm2xwDAnFTl+g==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@typescript-eslint/types": "5.34.0",
|
||||
"@typescript-eslint/visitor-keys": "5.34.0",
|
||||
"@typescript-eslint/types": "5.36.1",
|
||||
"@typescript-eslint/visitor-keys": "5.36.1",
|
||||
"debug": "^4.3.4",
|
||||
"globby": "^11.1.0",
|
||||
"is-glob": "^4.0.3",
|
||||
@ -2703,26 +2722,26 @@
|
||||
}
|
||||
},
|
||||
"@typescript-eslint/utils": {
|
||||
"version": "5.34.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.34.0.tgz",
|
||||
"integrity": "sha512-kWRYybU4Rn++7lm9yu8pbuydRyQsHRoBDIo11k7eqBWTldN4xUdVUMCsHBiE7aoEkFzrUEaZy3iH477vr4xHAQ==",
|
||||
"version": "5.36.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.36.1.tgz",
|
||||
"integrity": "sha512-lNj4FtTiXm5c+u0pUehozaUWhh7UYKnwryku0nxJlYUEWetyG92uw2pr+2Iy4M/u0ONMKzfrx7AsGBTCzORmIg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/json-schema": "^7.0.9",
|
||||
"@typescript-eslint/scope-manager": "5.34.0",
|
||||
"@typescript-eslint/types": "5.34.0",
|
||||
"@typescript-eslint/typescript-estree": "5.34.0",
|
||||
"@typescript-eslint/scope-manager": "5.36.1",
|
||||
"@typescript-eslint/types": "5.36.1",
|
||||
"@typescript-eslint/typescript-estree": "5.36.1",
|
||||
"eslint-scope": "^5.1.1",
|
||||
"eslint-utils": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"@typescript-eslint/visitor-keys": {
|
||||
"version": "5.34.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.34.0.tgz",
|
||||
"integrity": "sha512-O1moYjOSrab0a2fUvFpsJe0QHtvTC+cR+ovYpgKrAVXzqQyc74mv76TgY6z+aEtjQE2vgZux3CQVtGryqdcOAw==",
|
||||
"version": "5.36.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.36.1.tgz",
|
||||
"integrity": "sha512-ojB9aRyRFzVMN3b5joSYni6FAS10BBSCAfKJhjJAV08t/a95aM6tAhz+O1jF+EtgxktuSO3wJysp2R+Def/IWQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@typescript-eslint/types": "5.34.0",
|
||||
"@typescript-eslint/types": "5.36.1",
|
||||
"eslint-visitor-keys": "^3.3.0"
|
||||
}
|
||||
},
|
||||
@ -3053,14 +3072,15 @@
|
||||
"dev": true
|
||||
},
|
||||
"eslint": {
|
||||
"version": "8.22.0",
|
||||
"resolved": "https://registry.npmjs.org/eslint/-/eslint-8.22.0.tgz",
|
||||
"integrity": "sha512-ci4t0sz6vSRKdmkOGmprBo6fmI4PrphDFMy5JEq/fNS0gQkJM3rLmrqcp8ipMcdobH3KtUP40KniAE9W19S4wA==",
|
||||
"version": "8.23.0",
|
||||
"resolved": "https://registry.npmjs.org/eslint/-/eslint-8.23.0.tgz",
|
||||
"integrity": "sha512-pBG/XOn0MsJcKcTRLr27S5HpzQo4kLr+HjLQIyK4EiCsijDl/TB+h5uEuJU6bQ8Edvwz1XWOjpaP2qgnXGpTcA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@eslint/eslintrc": "^1.3.0",
|
||||
"@eslint/eslintrc": "^1.3.1",
|
||||
"@humanwhocodes/config-array": "^0.10.4",
|
||||
"@humanwhocodes/gitignore-to-minimatch": "^1.0.2",
|
||||
"@humanwhocodes/module-importer": "^1.0.1",
|
||||
"ajv": "^6.10.0",
|
||||
"chalk": "^4.0.0",
|
||||
"cross-spawn": "^7.0.2",
|
||||
@ -3070,7 +3090,7 @@
|
||||
"eslint-scope": "^7.1.1",
|
||||
"eslint-utils": "^3.0.0",
|
||||
"eslint-visitor-keys": "^3.3.0",
|
||||
"espree": "^9.3.3",
|
||||
"espree": "^9.4.0",
|
||||
"esquery": "^1.4.0",
|
||||
"esutils": "^2.0.2",
|
||||
"fast-deep-equal": "^3.1.3",
|
||||
@ -3095,8 +3115,7 @@
|
||||
"regexpp": "^3.2.0",
|
||||
"strip-ansi": "^6.0.1",
|
||||
"strip-json-comments": "^3.1.0",
|
||||
"text-table": "^0.2.0",
|
||||
"v8-compile-cache": "^2.0.3"
|
||||
"text-table": "^0.2.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"eslint-scope": {
|
||||
@ -3167,9 +3186,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"espree": {
|
||||
"version": "9.3.3",
|
||||
"resolved": "https://registry.npmjs.org/espree/-/espree-9.3.3.tgz",
|
||||
"integrity": "sha512-ORs1Rt/uQTqUKjDdGCyrtYxbazf5umATSf/K4qxjmZHORR6HJk+2s/2Pqe+Kk49HHINC/xNIrGfgh8sZcll0ng==",
|
||||
"version": "9.4.0",
|
||||
"resolved": "https://registry.npmjs.org/espree/-/espree-9.4.0.tgz",
|
||||
"integrity": "sha512-DQmnRpLj7f6TgN/NYb0MTzJXL+vJF9h3pHy4JhCIs3zwcgez8xmGg3sXHcEO97BrmO2OSvCwMdfdlyl+E9KjOw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"acorn": "^8.8.0",
|
||||
@ -4056,9 +4075,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"typescript": {
|
||||
"version": "4.7.4",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.7.4.tgz",
|
||||
"integrity": "sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ==",
|
||||
"version": "4.8.2",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.2.tgz",
|
||||
"integrity": "sha512-C0I1UsrrDHo2fYI5oaCGbSejwX4ch+9Y5jTQELvovfmFkK3HHSZJB8MSJcWLmCUBzQBchCrZ9rMRV6GuNrvGtw==",
|
||||
"dev": true
|
||||
},
|
||||
"uri-js": {
|
||||
@ -4075,12 +4094,6 @@
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
|
||||
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg=="
|
||||
},
|
||||
"v8-compile-cache": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz",
|
||||
"integrity": "sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==",
|
||||
"dev": true
|
||||
},
|
||||
"v8-compile-cache-lib": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz",
|
||||
|
11
package.json
11
package.json
@ -24,22 +24,23 @@
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.9.1",
|
||||
"@actions/http-client": "^2.0.1",
|
||||
"@google-github-actions/actions-utils": "^0.4.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/chai": "^4.3.3",
|
||||
"@types/mocha": "^9.1.1",
|
||||
"@types/node": "^18.7.13",
|
||||
"@typescript-eslint/eslint-plugin": "^5.34.0",
|
||||
"@typescript-eslint/parser": "^5.34.0",
|
||||
"@types/node": "^18.7.14",
|
||||
"@typescript-eslint/eslint-plugin": "^5.36.1",
|
||||
"@typescript-eslint/parser": "^5.36.1",
|
||||
"@vercel/ncc": "^0.34.0",
|
||||
"chai": "^4.3.6",
|
||||
"eslint": "^8.22.0",
|
||||
"eslint": "^8.23.0",
|
||||
"eslint-config-prettier": "^8.5.0",
|
||||
"eslint-plugin-prettier": "^4.2.1",
|
||||
"mocha": "^10.0.0",
|
||||
"prettier": "^2.7.1",
|
||||
"ts-node": "^10.9.1",
|
||||
"typescript": "^4.7.4"
|
||||
"typescript": "^4.8.2"
|
||||
}
|
||||
}
|
||||
|
123
src/base.ts
123
src/base.ts
@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
import https, { RequestOptions } from 'https';
|
||||
import { URL, URLSearchParams } from 'url';
|
||||
import { HttpClient } from '@actions/http-client';
|
||||
import { URLSearchParams } from 'url';
|
||||
import {
|
||||
GoogleAccessTokenParameters,
|
||||
GoogleAccessTokenResponse,
|
||||
@ -13,63 +13,32 @@ import {
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const { version: appVersion } = require('../package.json');
|
||||
|
||||
// userAgent is the default user agent.
|
||||
const userAgent = `google-github-actions:auth/${appVersion}`;
|
||||
|
||||
/**
|
||||
* BaseClient is the default HTTP client for interacting with the IAM
|
||||
* credentials API.
|
||||
*/
|
||||
export class BaseClient {
|
||||
/**
|
||||
* request is a high-level helper that returns a promise from the executed
|
||||
* request.
|
||||
* client is the HTTP client.
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
|
||||
static request(opts: RequestOptions, data?: any): Promise<string> {
|
||||
if (!opts.headers) {
|
||||
opts.headers = {};
|
||||
}
|
||||
protected readonly client: HttpClient;
|
||||
|
||||
if (!opts.headers['User-Agent']) {
|
||||
opts.headers['User-Agent'] = `google-github-actions:auth/${appVersion}`;
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
const req = https.request(opts, (res) => {
|
||||
res.setEncoding('utf8');
|
||||
|
||||
let body = '';
|
||||
res.on('data', (data) => {
|
||||
body += data;
|
||||
});
|
||||
|
||||
res.on('end', () => {
|
||||
if (res.statusCode && res.statusCode >= 400) {
|
||||
reject(body);
|
||||
} else {
|
||||
resolve(body);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
req.on('error', (err) => {
|
||||
reject(err);
|
||||
});
|
||||
|
||||
if (data != null) {
|
||||
req.write(data);
|
||||
}
|
||||
|
||||
req.end();
|
||||
});
|
||||
constructor() {
|
||||
this.client = new HttpClient(userAgent);
|
||||
}
|
||||
|
||||
/**
|
||||
* googleIDToken generates a Google Cloud ID token for the provided
|
||||
* service account email or unique id.
|
||||
*/
|
||||
static async googleIDToken(
|
||||
async googleIDToken(
|
||||
token: string,
|
||||
{ serviceAccount, audience, delegates, includeEmail }: GoogleIDTokenParameters,
|
||||
): Promise<GoogleIDTokenResponse> {
|
||||
const serviceAccountID = `projects/-/serviceAccounts/${serviceAccount}`;
|
||||
const tokenURL = new URL(
|
||||
`https://iamcredentials.googleapis.com/v1/${serviceAccountID}:generateIdToken`,
|
||||
);
|
||||
const pth = `https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/${serviceAccount}:generateIdToken`;
|
||||
|
||||
const data = {
|
||||
delegates: delegates,
|
||||
@ -77,21 +46,20 @@ export class BaseClient {
|
||||
includeEmail: includeEmail,
|
||||
};
|
||||
|
||||
const opts = {
|
||||
hostname: tokenURL.hostname,
|
||||
port: tokenURL.port,
|
||||
path: tokenURL.pathname + tokenURL.search,
|
||||
method: 'POST',
|
||||
headers: {
|
||||
const headers = {
|
||||
'Authorization': `Bearer ${token}`,
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
};
|
||||
|
||||
try {
|
||||
const resp = await BaseClient.request(opts, JSON.stringify(data));
|
||||
const parsed = JSON.parse(resp);
|
||||
const resp = await this.client.request('POST', pth, JSON.stringify(data), headers);
|
||||
const body = await resp.readBody();
|
||||
const statusCode = resp.message.statusCode || 500;
|
||||
if (statusCode >= 400) {
|
||||
throw new Error(`(${statusCode}) ${body}`);
|
||||
}
|
||||
const parsed = JSON.parse(body);
|
||||
return {
|
||||
token: parsed['token'],
|
||||
};
|
||||
@ -104,14 +72,11 @@ export class BaseClient {
|
||||
* googleAccessToken generates a Google Cloud access token for the provided
|
||||
* service account email or unique id.
|
||||
*/
|
||||
static async googleAccessToken(
|
||||
async googleAccessToken(
|
||||
token: string,
|
||||
{ serviceAccount, delegates, scopes, lifetime }: GoogleAccessTokenParameters,
|
||||
): Promise<GoogleAccessTokenResponse> {
|
||||
const serviceAccountID = `projects/-/serviceAccounts/${serviceAccount}`;
|
||||
const tokenURL = new URL(
|
||||
`https://iamcredentials.googleapis.com/v1/${serviceAccountID}:generateAccessToken`,
|
||||
);
|
||||
const pth = `https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/${serviceAccount}:generateAccessToken`;
|
||||
|
||||
const data: Record<string, string | Array<string>> = {};
|
||||
if (delegates && delegates.length > 0) {
|
||||
@ -125,21 +90,20 @@ export class BaseClient {
|
||||
data.lifetime = `${lifetime}s`;
|
||||
}
|
||||
|
||||
const opts = {
|
||||
hostname: tokenURL.hostname,
|
||||
port: tokenURL.port,
|
||||
path: tokenURL.pathname + tokenURL.search,
|
||||
method: 'POST',
|
||||
headers: {
|
||||
const headers = {
|
||||
'Authorization': `Bearer ${token}`,
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
};
|
||||
|
||||
try {
|
||||
const resp = await BaseClient.request(opts, JSON.stringify(data));
|
||||
const parsed = JSON.parse(resp);
|
||||
const resp = await this.client.request('POST', pth, JSON.stringify(data), headers);
|
||||
const body = await resp.readBody();
|
||||
const statusCode = resp.message.statusCode || 500;
|
||||
if (statusCode >= 400) {
|
||||
throw new Error(`(${statusCode}) ${body}`);
|
||||
}
|
||||
const parsed = JSON.parse(body);
|
||||
return {
|
||||
accessToken: parsed['accessToken'],
|
||||
expiration: parsed['expireTime'],
|
||||
@ -155,18 +119,12 @@ export class BaseClient {
|
||||
*
|
||||
* @param assertion A signed JWT.
|
||||
*/
|
||||
static async googleOAuthToken(assertion: string): Promise<GoogleAccessTokenResponse> {
|
||||
const tokenURL = new URL('https://oauth2.googleapis.com/token');
|
||||
async googleOAuthToken(assertion: string): Promise<GoogleAccessTokenResponse> {
|
||||
const pth = `https://oauth2.googleapis.com/token`;
|
||||
|
||||
const opts = {
|
||||
hostname: tokenURL.hostname,
|
||||
port: tokenURL.port,
|
||||
path: tokenURL.pathname + tokenURL.search,
|
||||
method: 'POST',
|
||||
headers: {
|
||||
const headers = {
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
};
|
||||
|
||||
const data = new URLSearchParams();
|
||||
@ -174,8 +132,13 @@ export class BaseClient {
|
||||
data.append('assertion', assertion);
|
||||
|
||||
try {
|
||||
const resp = await BaseClient.request(opts, data.toString());
|
||||
const parsed = JSON.parse(resp);
|
||||
const resp = await this.client.request('POST', pth, data.toString(), headers);
|
||||
const body = await resp.readBody();
|
||||
const statusCode = resp.message.statusCode || 500;
|
||||
if (statusCode >= 400) {
|
||||
throw new Error(`(${statusCode}) ${body}`);
|
||||
}
|
||||
const parsed = JSON.parse(body);
|
||||
|
||||
// Normalize the expiration to be a timestamp like the iamcredentials API.
|
||||
// This API returns the number of seconds until expiration, so convert
|
||||
|
@ -9,6 +9,16 @@ export interface AuthClient {
|
||||
getProjectID(): Promise<string>;
|
||||
getServiceAccount(): Promise<string>;
|
||||
createCredentialsFile(outputDir: string): Promise<string>;
|
||||
|
||||
/**
|
||||
* Provided by BaseClient.
|
||||
*/
|
||||
googleIDToken(token: string, params: GoogleIDTokenParameters): Promise<GoogleIDTokenResponse>;
|
||||
googleAccessToken(
|
||||
token: string,
|
||||
params: GoogleAccessTokenParameters,
|
||||
): Promise<GoogleAccessTokenResponse>;
|
||||
googleOAuthToken(assertion: string): Promise<GoogleAccessTokenResponse>;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -10,6 +10,7 @@ import {
|
||||
} from '@google-github-actions/actions-utils';
|
||||
|
||||
import { AuthClient } from './auth_client';
|
||||
import { BaseClient } from '../base';
|
||||
|
||||
/**
|
||||
* Available options to create the CredentialsJSONClient.
|
||||
@ -27,11 +28,13 @@ interface CredentialsJSONClientOptions {
|
||||
* CredentialsJSONClient is a client that accepts a service account key JSON
|
||||
* credential.
|
||||
*/
|
||||
export class CredentialsJSONClient implements AuthClient {
|
||||
export class CredentialsJSONClient extends BaseClient implements AuthClient {
|
||||
readonly #projectID: string;
|
||||
readonly #credentials: ServiceAccountKey;
|
||||
|
||||
constructor(opts: CredentialsJSONClientOptions) {
|
||||
super();
|
||||
|
||||
const credentials = parseCredential(opts.credentialsJSON);
|
||||
if (!isServiceAccountKey(credentials)) {
|
||||
throw new Error(`Provided credential is not a valid service account key JSON`);
|
||||
|
@ -35,7 +35,7 @@ interface WorkloadIdentityClientOptions {
|
||||
* WorkloadIdentityClient is a client that uses the GitHub Actions runtime to
|
||||
* authentication via Workload Identity.
|
||||
*/
|
||||
export class WorkloadIdentityClient implements AuthClient {
|
||||
export class WorkloadIdentityClient extends BaseClient implements AuthClient {
|
||||
readonly #projectID: string;
|
||||
readonly #providerID: string;
|
||||
readonly #serviceAccount: string;
|
||||
@ -46,6 +46,8 @@ export class WorkloadIdentityClient implements AuthClient {
|
||||
readonly #oidcTokenRequestToken: string;
|
||||
|
||||
constructor(opts: WorkloadIdentityClientOptions) {
|
||||
super();
|
||||
|
||||
this.#providerID = opts.providerID;
|
||||
this.#serviceAccount = opts.serviceAccount;
|
||||
this.#token = opts.token;
|
||||
@ -85,7 +87,7 @@ export class WorkloadIdentityClient implements AuthClient {
|
||||
* OIDC token and Workload Identity Provider.
|
||||
*/
|
||||
async getAuthToken(): Promise<string> {
|
||||
const stsURL = new URL('https://sts.googleapis.com/v1/token');
|
||||
const pth = `https://sts.googleapis.com/v1/token`;
|
||||
|
||||
const data = {
|
||||
audience: '//iam.googleapis.com/' + this.#providerID,
|
||||
@ -96,20 +98,19 @@ export class WorkloadIdentityClient implements AuthClient {
|
||||
subjectToken: this.#token,
|
||||
};
|
||||
|
||||
const opts = {
|
||||
hostname: stsURL.hostname,
|
||||
port: stsURL.port,
|
||||
path: stsURL.pathname + stsURL.search,
|
||||
method: 'POST',
|
||||
headers: {
|
||||
const headers = {
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
};
|
||||
|
||||
try {
|
||||
const resp = await BaseClient.request(opts, JSON.stringify(data));
|
||||
const parsed = JSON.parse(resp);
|
||||
const resp = await this.client.request('POST', pth, JSON.stringify(data), headers);
|
||||
const body = await resp.readBody();
|
||||
const statusCode = resp.message.statusCode || 500;
|
||||
if (statusCode >= 400) {
|
||||
throw new Error(`(${statusCode}) ${body}`);
|
||||
}
|
||||
const parsed = JSON.parse(body);
|
||||
return parsed['access_token'];
|
||||
} catch (err) {
|
||||
throw new Error(
|
||||
@ -129,9 +130,7 @@ export class WorkloadIdentityClient implements AuthClient {
|
||||
const serviceAccount = await this.getServiceAccount();
|
||||
const federatedToken = await this.getAuthToken();
|
||||
|
||||
const signJWTURL = new URL(
|
||||
`https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/${serviceAccount}:signJwt`,
|
||||
);
|
||||
const pth = `https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/${serviceAccount}:signJwt`;
|
||||
|
||||
const data: Record<string, string | Array<string>> = {
|
||||
payload: unsignedJWT,
|
||||
@ -140,21 +139,20 @@ export class WorkloadIdentityClient implements AuthClient {
|
||||
data.delegates = delegates;
|
||||
}
|
||||
|
||||
const opts = {
|
||||
hostname: signJWTURL.hostname,
|
||||
port: signJWTURL.port,
|
||||
path: signJWTURL.pathname + signJWTURL.search,
|
||||
method: 'POST',
|
||||
headers: {
|
||||
const headers = {
|
||||
'Accept': 'application/json',
|
||||
'Authorization': `Bearer ${federatedToken}`,
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
};
|
||||
|
||||
try {
|
||||
const resp = await BaseClient.request(opts, JSON.stringify(data));
|
||||
const parsed = JSON.parse(resp);
|
||||
const resp = await this.client.request('POST', pth, JSON.stringify(data), headers);
|
||||
const body = await resp.readBody();
|
||||
const statusCode = resp.message.statusCode || 500;
|
||||
if (statusCode >= 400) {
|
||||
throw new Error(`(${statusCode}) ${body}`);
|
||||
}
|
||||
const parsed = JSON.parse(body);
|
||||
return parsed['signedJwt'];
|
||||
} catch (err) {
|
||||
throw new Error(`Failed to sign JWT using ${serviceAccount}: ${err}`);
|
||||
|
@ -28,7 +28,6 @@ import {
|
||||
import { WorkloadIdentityClient } from './client/workload_identity_client';
|
||||
import { CredentialsJSONClient } from './client/credentials_json_client';
|
||||
import { AuthClient } from './client/auth_client';
|
||||
import { BaseClient } from './base';
|
||||
import { buildDomainWideDelegationJWT, generateCredentialsFilename } from './utils';
|
||||
|
||||
const secretsWarning =
|
||||
@ -249,10 +248,10 @@ async function main() {
|
||||
accessTokenLifetime,
|
||||
);
|
||||
const signedJWT = await client.signJWT(unsignedJWT, delegates);
|
||||
({ accessToken, expiration } = await BaseClient.googleOAuthToken(signedJWT));
|
||||
({ accessToken, expiration } = await client.googleOAuthToken(signedJWT));
|
||||
} else {
|
||||
const authToken = await client.getAuthToken();
|
||||
({ accessToken, expiration } = await BaseClient.googleAccessToken(authToken, {
|
||||
({ accessToken, expiration } = await client.googleAccessToken(authToken, {
|
||||
serviceAccount,
|
||||
delegates,
|
||||
scopes: accessTokenScopes,
|
||||
@ -273,7 +272,7 @@ async function main() {
|
||||
const serviceAccount = await client.getServiceAccount();
|
||||
|
||||
const authToken = await client.getAuthToken();
|
||||
const { token } = await BaseClient.googleIDToken(authToken, {
|
||||
const { token } = await client.googleIDToken(authToken, {
|
||||
serviceAccount,
|
||||
audience: idTokenAudience,
|
||||
delegates,
|
||||
|
@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
import { getBooleanInput, setFailed, info as logInfo } from '@actions/core';
|
||||
import { errorMessage, removeFile } from '@google-github-actions/actions-utils';
|
||||
import { errorMessage, forceRemove } from '@google-github-actions/actions-utils';
|
||||
|
||||
/**
|
||||
* Executes the post action, documented inline.
|
||||
@ -31,12 +31,8 @@ export async function run(): Promise<void> {
|
||||
}
|
||||
|
||||
// Remove the file.
|
||||
const removed = await removeFile(credentialsPath);
|
||||
if (removed) {
|
||||
await forceRemove(credentialsPath);
|
||||
logInfo(`Removed exported credentials at "${credentialsPath}".`);
|
||||
} else {
|
||||
logInfo(`No exported credentials were found at "${credentialsPath}".`);
|
||||
}
|
||||
} catch (err) {
|
||||
const msg = errorMessage(err);
|
||||
setFailed(`google-github-actions/auth post failed with: ${msg}`);
|
||||
|
Loading…
Reference in New Issue
Block a user