diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 24943e1..f7e083b 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,5 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-nodejs:latest - digest: sha256:609822e3c09b7a1bd90b99655904609f162cc15acb4704f1edf778284c36f429 -# created: 2024-10-01T19:34:30.797530443Z + digest: sha256:0d39e59663287ae929c1d4ccf8ebf7cef9946826c9b86eda7e85d8d752dbb584 +# created: 2024-10-30T16:51:59.982020867Z diff --git a/.github/release-trigger.yml b/.github/release-trigger.yml index d4ca941..b86ce86 100644 --- a/.github/release-trigger.yml +++ b/.github/release-trigger.yml @@ -1 +1,2 @@ enabled: true +multiScmName: node-gtoken \ No newline at end of file diff --git a/.github/sync-repo-settings.yaml b/.github/sync-repo-settings.yaml index b46e4c4..a013376 100644 --- a/.github/sync-repo-settings.yaml +++ b/.github/sync-repo-settings.yaml @@ -8,9 +8,9 @@ branchProtectionRules: - "ci/kokoro: Samples test" - "ci/kokoro: System test" - lint - - test (14) - - test (16) - test (18) + - test (20) + - test (22) - cla/google - windows - OwlBot Post Processor diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 4892eb2..791891a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -9,10 +9,10 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node: [14, 16, 18, 20] + node: [18, 20, 22] steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: node-version: ${{ matrix.node }} - run: node --version @@ -29,10 +29,10 @@ jobs: windows: runs-on: windows-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: - node-version: 14 + node-version: 18 - run: npm install --engine-strict - run: npm test env: @@ -40,19 +40,19 @@ jobs: lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: - node-version: 14 + node-version: 18 - run: npm install - run: npm run lint docs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: - node-version: 14 + node-version: 18 - run: npm install - run: npm run docs - uses: JustinBeckwith/linkinator-action@v1 diff --git a/.gitignore b/.gitignore index 7f1be46..3b26b45 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ package-lock.json __pycache__ .coverage docs/ +.DS_Store \ No newline at end of file diff --git a/.kokoro/common.cfg b/.kokoro/common.cfg index a35dac5..790520e 100644 --- a/.kokoro/common.cfg +++ b/.kokoro/common.cfg @@ -16,7 +16,7 @@ build_file: "node-gtoken/.kokoro/trampoline_v2.sh" # Configure the docker image for kokoro-trampoline. env_vars: { key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/node:14-user" + value: "gcr.io/cloud-devrel-kokoro-resources/node:18-user" } env_vars: { key: "TRAMPOLINE_BUILD_FILE" diff --git a/.kokoro/continuous/node14/common.cfg b/.kokoro/continuous/node18/common.cfg similarity index 89% rename from .kokoro/continuous/node14/common.cfg rename to .kokoro/continuous/node18/common.cfg index a35dac5..790520e 100644 --- a/.kokoro/continuous/node14/common.cfg +++ b/.kokoro/continuous/node18/common.cfg @@ -16,7 +16,7 @@ build_file: "node-gtoken/.kokoro/trampoline_v2.sh" # Configure the docker image for kokoro-trampoline. env_vars: { key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/node:14-user" + value: "gcr.io/cloud-devrel-kokoro-resources/node:18-user" } env_vars: { key: "TRAMPOLINE_BUILD_FILE" diff --git a/.kokoro/continuous/node14/lint.cfg b/.kokoro/continuous/node18/lint.cfg similarity index 100% rename from .kokoro/continuous/node14/lint.cfg rename to .kokoro/continuous/node18/lint.cfg diff --git a/.kokoro/continuous/node14/samples-test.cfg b/.kokoro/continuous/node18/samples-test.cfg similarity index 100% rename from .kokoro/continuous/node14/samples-test.cfg rename to .kokoro/continuous/node18/samples-test.cfg diff --git a/.kokoro/continuous/node14/system-test.cfg b/.kokoro/continuous/node18/system-test.cfg similarity index 100% rename from .kokoro/continuous/node14/system-test.cfg rename to .kokoro/continuous/node18/system-test.cfg diff --git a/.kokoro/continuous/node14/test.cfg b/.kokoro/continuous/node18/test.cfg similarity index 100% rename from .kokoro/continuous/node14/test.cfg rename to .kokoro/continuous/node18/test.cfg diff --git a/.kokoro/presubmit/node14/common.cfg b/.kokoro/presubmit/node18/common.cfg similarity index 89% rename from .kokoro/presubmit/node14/common.cfg rename to .kokoro/presubmit/node18/common.cfg index a35dac5..790520e 100644 --- a/.kokoro/presubmit/node14/common.cfg +++ b/.kokoro/presubmit/node18/common.cfg @@ -16,7 +16,7 @@ build_file: "node-gtoken/.kokoro/trampoline_v2.sh" # Configure the docker image for kokoro-trampoline. env_vars: { key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/node:14-user" + value: "gcr.io/cloud-devrel-kokoro-resources/node:18-user" } env_vars: { key: "TRAMPOLINE_BUILD_FILE" diff --git a/.kokoro/presubmit/node14/samples-test.cfg b/.kokoro/presubmit/node18/samples-test.cfg similarity index 100% rename from .kokoro/presubmit/node14/samples-test.cfg rename to .kokoro/presubmit/node18/samples-test.cfg diff --git a/.kokoro/presubmit/node14/system-test.cfg b/.kokoro/presubmit/node18/system-test.cfg similarity index 100% rename from .kokoro/presubmit/node14/system-test.cfg rename to .kokoro/presubmit/node18/system-test.cfg diff --git a/.kokoro/presubmit/node14/test.cfg b/.kokoro/presubmit/node18/test.cfg similarity index 100% rename from .kokoro/presubmit/node14/test.cfg rename to .kokoro/presubmit/node18/test.cfg diff --git a/.kokoro/release/docs-devsite.cfg b/.kokoro/release/docs-devsite.cfg index 0ff4459..de24edc 100644 --- a/.kokoro/release/docs-devsite.cfg +++ b/.kokoro/release/docs-devsite.cfg @@ -11,7 +11,7 @@ before_action { # doc publications use a Python image. env_vars: { key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/node:14-user" + value: "gcr.io/cloud-devrel-kokoro-resources/node:18-user" } # Download trampoline resources. diff --git a/.kokoro/release/docs.cfg b/.kokoro/release/docs.cfg index 2efa230..838b353 100644 --- a/.kokoro/release/docs.cfg +++ b/.kokoro/release/docs.cfg @@ -11,7 +11,7 @@ before_action { # doc publications use a Python image. env_vars: { key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/node:14-user" + value: "gcr.io/cloud-devrel-kokoro-resources/node:18-user" } # Download trampoline resources. diff --git a/.kokoro/release/docs.sh b/.kokoro/release/docs.sh index 1d8f3f4..e9079a6 100755 --- a/.kokoro/release/docs.sh +++ b/.kokoro/release/docs.sh @@ -16,7 +16,7 @@ set -eo pipefail -# build jsdocs (Python is installed on the Node 10 docker image). +# build jsdocs (Python is installed on the Node 18 docker image). if [[ -z "$CREDENTIALS" ]]; then # if CREDENTIALS are explicitly set, assume we're testing locally # and don't set NPM_CONFIG_PREFIX. diff --git a/.kokoro/release/publish.cfg b/.kokoro/release/publish.cfg index ea50d48..9d8aad5 100644 --- a/.kokoro/release/publish.cfg +++ b/.kokoro/release/publish.cfg @@ -30,7 +30,7 @@ build_file: "node-gtoken/.kokoro/trampoline_v2.sh" # Configure the docker image for kokoro-trampoline. env_vars: { key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/node:14-user" + value: "gcr.io/cloud-devrel-kokoro-resources/node:18-user" } env_vars: { diff --git a/.kokoro/samples-test.sh b/.kokoro/samples-test.sh index 8c5d108..5287753 100755 --- a/.kokoro/samples-test.sh +++ b/.kokoro/samples-test.sh @@ -16,7 +16,9 @@ set -eo pipefail -export NPM_CONFIG_PREFIX=${HOME}/.npm-global +# Ensure the npm global directory is writable, otherwise rebuild `npm` +mkdir -p $NPM_CONFIG_PREFIX +npm config -g ls || npm i -g npm@`npm --version` # Setup service account credentials. export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/secret_manager/long-door-651-kokoro-system-test-service-account @@ -56,7 +58,7 @@ fi # codecov combines coverage across integration and unit tests. Include # the logic below for any environment you wish to collect coverage for: -COVERAGE_NODE=14 +COVERAGE_NODE=18 if npx check-node-version@3.3.0 --silent --node $COVERAGE_NODE; then NYC_BIN=./node_modules/nyc/bin/nyc.js if [ -f "$NYC_BIN" ]; then diff --git a/.kokoro/system-test.sh b/.kokoro/system-test.sh index 0b3043d..a90d5cf 100755 --- a/.kokoro/system-test.sh +++ b/.kokoro/system-test.sh @@ -49,7 +49,7 @@ npm run system-test # codecov combines coverage across integration and unit tests. Include # the logic below for any environment you wish to collect coverage for: -COVERAGE_NODE=14 +COVERAGE_NODE=18 if npx check-node-version@3.3.0 --silent --node $COVERAGE_NODE; then NYC_BIN=./node_modules/nyc/bin/nyc.js if [ -f "$NYC_BIN" ]; then diff --git a/.kokoro/test.bat b/.kokoro/test.bat index 0bb1240..caf8256 100644 --- a/.kokoro/test.bat +++ b/.kokoro/test.bat @@ -21,7 +21,7 @@ cd .. @rem we upgrade Node.js in the image: SET PATH=%PATH%;/cygdrive/c/Program Files/nodejs/npm -call nvm use v14.17.3 +call nvm use 18 call which node call npm install || goto :error diff --git a/.kokoro/test.sh b/.kokoro/test.sh index 862d478..0d9f639 100755 --- a/.kokoro/test.sh +++ b/.kokoro/test.sh @@ -39,7 +39,7 @@ npm test # codecov combines coverage across integration and unit tests. Include # the logic below for any environment you wish to collect coverage for: -COVERAGE_NODE=14 +COVERAGE_NODE=18 if npx check-node-version@3.3.0 --silent --node $COVERAGE_NODE; then NYC_BIN=./node_modules/nyc/bin/nyc.js if [ -f "$NYC_BIN" ]; then diff --git a/.kokoro/trampoline_v2.sh b/.kokoro/trampoline_v2.sh index 4d03112..5d6cfcc 100755 --- a/.kokoro/trampoline_v2.sh +++ b/.kokoro/trampoline_v2.sh @@ -44,7 +44,7 @@ # the project root. # # Here is an example for running this script. -# TRAMPOLINE_IMAGE=gcr.io/cloud-devrel-kokoro-resources/node:10-user \ +# TRAMPOLINE_IMAGE=gcr.io/cloud-devrel-kokoro-resources/node:18-user \ # TRAMPOLINE_BUILD_FILE=.kokoro/system-test.sh \ # .kokoro/trampoline_v2.sh diff --git a/package.json b/package.json index 4eb474d..f2541c0 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "main": "./build/src/index.js", "types": "./build/src/index.d.ts", "engines": { - "node": ">=14.0.0" + "node": ">=18" }, "repository": "google/node-gtoken", "scripts": { @@ -21,7 +21,6 @@ "samples-test": "cd samples/ && npm link ../ && npm test && cd ../", "docs": "jsdoc -c .jsdoc.js", "predocs-test": "npm run docs", - "predocs-test": "npm run docs", "prelint": "cd samples; npm link ../; npm install", "precompile": "gts clean" }, @@ -39,25 +38,25 @@ }, "license": "MIT", "dependencies": { - "gaxios": "^6.0.0", + "gaxios": "^6.7.1", "jws": "^4.0.0" }, "devDependencies": { "@babel/plugin-proposal-private-methods": "^7.18.6", - "cheerio": "1.0.0-rc.12", - "@types/jws": "^3.1.0", - "@types/mocha": "^9.0.0", - "@types/node": "^20.0.0", - "c8": "^9.0.0", - "gts": "^5.0.0", - "jsdoc": "^4.0.0", + "@types/jws": "^3.2.10", + "@types/mocha": "^10.0.9", + "@types/node": "^22.9.0", + "c8": "^10.1.2", + "cheerio": "^1.0.0", + "gts": "^6.0.2", + "jsdoc": "^4.0.4", "jsdoc-fresh": "^3.0.0", "jsdoc-region-tag": "^3.0.0", - "linkinator": "^3.0.0", - "mocha": "^9.2.2", - "nock": "^13.0.0", - "pdfmake": "0.2.12", - "typescript": "^5.1.6" + "linkinator": "^6.1.2", + "mocha": "^10.8.2", + "nock": "^13.5.6", + "pdfmake": "^0.2.15", + "typescript": "^5.6.3" }, "files": [ "build/src", diff --git a/samples/package.json b/samples/package.json index 62cbfaf..3c87e7e 100644 --- a/samples/package.json +++ b/samples/package.json @@ -3,7 +3,7 @@ "license": "MIT", "author": "Google LLC", "engines": { - "node": ">=12.0.0" + "node": ">=18" }, "files": [ "*.js", @@ -20,4 +20,4 @@ "devDependencies": { "mocha": "^8.0.0" } -} +} \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 6e12ac7..71b8e6f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -17,7 +17,7 @@ const readFile = fs.readFile // if running in the web-browser, fs.readFile may not have been shimmed. throw new ErrorWithCode( 'use key rather than keyFile.', - 'MISSING_CREDENTIALS' + 'MISSING_CREDENTIALS', ); }; @@ -66,7 +66,7 @@ export interface GetTokenOptions { class ErrorWithCode extends Error { constructor( message: string, - public code: string + public code: string, ) { super(message); } @@ -149,7 +149,7 @@ export class GoogleToken { getToken(callback: GetTokenCallback, opts?: GetTokenOptions): void; getToken( callback?: GetTokenCallback | GetTokenOptions, - opts = {} as GetTokenOptions + opts = {} as GetTokenOptions, ): void | Promise { if (typeof callback === 'object') { opts = callback as GetTokenOptions; @@ -159,7 +159,7 @@ export class GoogleToken { { forceRefresh: false, }, - opts + opts, ); if (callback) { @@ -187,7 +187,7 @@ export class GoogleToken { if (!privateKey || !clientEmail) { throw new ErrorWithCode( 'private_key and client_email are required.', - 'MISSING_CREDENTIALS' + 'MISSING_CREDENTIALS', ); } return {privateKey, clientEmail}; @@ -203,14 +203,14 @@ export class GoogleToken { throw new ErrorWithCode( '*.p12 certificates are not supported after v6.1.2. ' + 'Consider utilizing *.json format or converting *.p12 to *.pem using the OpenSSL CLI.', - 'UNKNOWN_CERTIFICATE_TYPE' + 'UNKNOWN_CERTIFICATE_TYPE', ); } default: throw new ErrorWithCode( 'Unknown certificate type. Type is determined based on file extension. ' + 'Current supported extensions are *.json, and *.pem.', - 'UNKNOWN_CERTIFICATE_TYPE' + 'UNKNOWN_CERTIFICATE_TYPE', ); } } @@ -325,7 +325,7 @@ export class GoogleToken { iat, sub: this.sub, }, - additionalClaims + additionalClaims, ); const signedJWT = jws.sign({ header: {alg: 'RS256'}, diff --git a/test/index.ts b/test/index.ts index 3b1f4f7..e37d7b5 100644 --- a/test/index.ts +++ b/test/index.ts @@ -270,7 +270,7 @@ describe('.getToken()', () => { if (err) { assert.strictEqual( (err as NodeJS.ErrnoException).code, - 'MISSING_CREDENTIALS' + 'MISSING_CREDENTIALS', ); done(); } @@ -317,7 +317,7 @@ describe('.getToken()', () => { if (err) { assert.strictEqual( (err as NodeJS.ErrnoException).code, - 'MISSING_CREDENTIALS' + 'MISSING_CREDENTIALS', ); done(); } @@ -379,7 +379,7 @@ describe('.getToken()', () => { scope.done(); done(); }, - {forceRefresh: true} + {forceRefresh: true}, ); }); @@ -410,7 +410,7 @@ describe('.getToken()', () => { const tokens = await Promise.all([gtoken.getToken(), gtoken.getToken()]); assert.deepStrictEqual( tokens.map(t => t.access_token), - [fakeToken, fakeToken] + [fakeToken, fakeToken], ); }); it('should make parallel requests if forceRefresh=true (promise)', async () => { @@ -429,7 +429,7 @@ describe('.getToken()', () => { ]); assert.deepStrictEqual( tokens.map(t => t.access_token).sort(), - [fakeTokenA, fakeTokenB].sort() + [fakeTokenA, fakeTokenB].sort(), ); }); @@ -440,7 +440,7 @@ describe('.getToken()', () => { if (err) { assert.strictEqual( (err as NodeJS.ErrnoException).code, - 'UNKNOWN_CERTIFICATE_TYPE' + 'UNKNOWN_CERTIFICATE_TYPE', ); done(); } @@ -624,7 +624,7 @@ function createGetTokenMock(code = 200, body?: {}) { grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer', assertion: /.?/, }, - {reqheaders: {'Content-Type': 'application/x-www-form-urlencoded'}} + {reqheaders: {'Content-Type': 'application/x-www-form-urlencoded'}}, ) .reply(code, body); }