Skip to content

Commit

Permalink
chore(deps): update dependency gts to v6 (#1886)
Browse files Browse the repository at this point in the history
* chore(deps): update dependency gts to v6

* style: lint fix

* chore: update config

* chore: lint

* chore: clean-up

* style: lint

* chore: clean-up internal

---------

Co-authored-by: Daniel Bankhead <[email protected]>
  • Loading branch information
renovate-bot and d-goog authored Feb 21, 2025
1 parent f23e807 commit a511e56
Show file tree
Hide file tree
Showing 70 changed files with 970 additions and 1,017 deletions.
10 changes: 5 additions & 5 deletions browser-test/test.crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.

import * as base64js from 'base64-js';
import {assert} from 'chai';
import {strict as assert} from 'assert';
import {createCrypto, fromArrayBufferToHex} from '../src/crypto/crypto';
import {BrowserCrypto} from '../src/crypto/browser/crypto';
import {privateKey, publicKey} from './fixtures/keys';
Expand Down Expand Up @@ -112,8 +112,8 @@ describe('Browser crypto tests', () => {
'f7bc83f430538424b13298e6aa6fb143ef4d59a14946175997479dbc2d1a3cd8';
const expectedHash = new Uint8Array(
(expectedHexHash.match(/.{1,2}/g) as string[]).map(byte =>
parseInt(byte, 16)
)
parseInt(byte, 16),
),
);

const calculatedHash = await crypto.signWithHmacSha256(key, message);
Expand All @@ -129,8 +129,8 @@ describe('Browser crypto tests', () => {
'f7bc83f430538424b13298e6aa6fb143ef4d59a14946175997479dbc2d1a3cd8';
const expectedHash = new Uint8Array(
(expectedHexHash.match(/.{1,2}/g) as string[]).map(byte =>
parseInt(byte, 16)
)
parseInt(byte, 16),
),
);

const calculatedHash = await crypto.signWithHmacSha256(key, message);
Expand Down
16 changes: 7 additions & 9 deletions browser-test/test.oauth2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.

import * as base64js from 'base64-js';
import {assert} from 'chai';
import {strict as assert} from 'assert';
import * as sinon from 'sinon';
import {privateKey, publicKey} from './fixtures/keys';
import {it, describe, beforeEach} from 'mocha';
Expand Down Expand Up @@ -89,8 +89,8 @@ describe('Browser OAuth2 tests', () => {
client.transporter.request = stub;
const response = await client.getToken('code here');
const tokens = response.tokens;
assert.isAbove(tokens!.expiry_date!, now + 10 * 1000);
assert.isBelow(tokens!.expiry_date!, now + 15 * 1000);
assert(tokens!.expiry_date! > now + 10 * 1000);
assert(tokens!.expiry_date! < now + 15 * 1000);
});

it('getFederatedSignonCerts talks to correct endpoint', async () => {
Expand Down Expand Up @@ -135,7 +135,7 @@ describe('Browser OAuth2 tests', () => {
assert.strictEqual(params.get('code_challenge'), codes.codeChallenge);
assert.strictEqual(
params.get('code_challenge_method'),
CodeChallengeMethod.S256
CodeChallengeMethod.S256,
);
});

Expand Down Expand Up @@ -167,25 +167,23 @@ describe('Browser OAuth2 tests', () => {
name: 'RSASSA-PKCS1-v1_5',
hash: {name: 'SHA-256'},
};
// eslint-disable-next-line no-undef
const cryptoKey = await window.crypto.subtle.importKey(
'jwk',
privateKey,
algo,
true,
['sign']
['sign'],
);
// eslint-disable-next-line no-undef
const signature = await window.crypto.subtle.sign(
algo,
cryptoKey,
new TextEncoder().encode(data)
new TextEncoder().encode(data),
);
data += '.' + base64js.fromByteArray(new Uint8Array(signature));
const login = await client.verifySignedJwtWithCertsAsync(
data,
{keyid: publicKey},
'testaudience'
'testaudience',
);
assert.strictEqual(login.getUserId(), '123456789');
});
Expand Down
14 changes: 6 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,17 @@
},
"devDependencies": {
"@types/base64-js": "^1.2.5",
"@types/chai": "^4.1.7",
"@types/jws": "^3.1.0",
"@types/mocha": "^9.0.0",
"@types/mocha": "^10.0.10",
"@types/mv": "^2.1.0",
"@types/ncp": "^2.0.1",
"@types/node": "^22.0.0",
"@types/sinon": "^17.0.0",
"assert-rejects": "^1.0.0",
"c8": "^10.0.0",
"chai": "^4.2.0",
"codecov": "^3.0.2",
"gts": "^5.0.0",
"is-docker": "^2.0.0",
"gts": "^6.0.0",
"is-docker": "^3.0.0",
"jsdoc": "^4.0.0",
"jsdoc-fresh": "^3.0.0",
"jsdoc-region-tag": "^3.0.0",
Expand All @@ -48,16 +46,16 @@
"karma-firefox-launcher": "^2.0.0",
"karma-mocha": "^2.0.0",
"karma-sourcemap-loader": "^0.4.0",
"karma-webpack": "5.0.0",
"karma-webpack": "^5.0.1",
"keypair": "^1.0.4",
"linkinator": "^6.1.2",
"mocha": "^9.2.2",
"mocha": "^11.1.0",
"mv": "^2.1.1",
"ncp": "^2.0.0",
"nock": "^14.0.1",
"null-loader": "^4.0.0",
"puppeteer": "^24.0.0",
"sinon": "^18.0.0",
"sinon": "^18.0.1",
"ts-loader": "^8.0.0",
"typescript": "^5.1.6",
"webpack": "^5.21.2",
Expand Down
2 changes: 1 addition & 1 deletion samples/authenticateAPIKey.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function main() {

console.log(`Text: ${text}`);
console.log(
`Sentiment: ${response.documentSentiment.score}, ${response.documentSentiment.magnitude}`
`Sentiment: ${response.documentSentiment.score}, ${response.documentSentiment.magnitude}`,
);
console.log('Successfully authenticated using the API key');
}
Expand Down
2 changes: 1 addition & 1 deletion samples/idtokens-iap.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

function main(
url = 'https://some.iap.url',
targetAudience = 'IAP_CLIENT_ID.apps.googleusercontent.com'
targetAudience = 'IAP_CLIENT_ID.apps.googleusercontent.com',
) {
// [START iap_make_request]
/**
Expand Down
2 changes: 1 addition & 1 deletion samples/idtokens-serverless.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

function main(
url = 'https://service-1234-uc.a.run.app',
targetAudience = null
targetAudience = null,
) {
if (!targetAudience) {
// Use the target service's hostname as the target audience for requests.
Expand Down
2 changes: 1 addition & 1 deletion samples/jwt.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const fs = require('fs');

async function main(
// Full path to the service account credential
keyFile = process.env.GOOGLE_APPLICATION_CREDENTIALS
keyFile = process.env.GOOGLE_APPLICATION_CREDENTIALS,
) {
const keys = JSON.parse(fs.readFileSync(keyFile, 'utf8'));
const client = new JWT({
Expand Down
2 changes: 1 addition & 1 deletion samples/keyfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const {GoogleAuth} = require('google-auth-library');
*/
async function main(
// Full path to the service account credential
keyFile = process.env.GOOGLE_APPLICATION_CREDENTIALS
keyFile = process.env.GOOGLE_APPLICATION_CREDENTIALS,
) {
const auth = new GoogleAuth({
keyFile: keyFile,
Expand Down
2 changes: 1 addition & 1 deletion samples/oauth2.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ async function main() {
// After acquiring an access_token, you may want to check on the audience, expiration,
// or original scopes requested. You can do that with the `getTokenInfo` method.
const tokenInfo = await oAuth2Client.getTokenInfo(
oAuth2Client.credentials.access_token
oAuth2Client.credentials.access_token,
);
console.log(tokenInfo);
}
Expand Down
2 changes: 1 addition & 1 deletion samples/scripts/downscoping-with-cab-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function generateRandomString(length) {
const allowedChars = 'abcdefghijklmnopqrstuvwxyz0123456789';
for (let i = 0; i < length; i++) {
chars.push(
allowedChars.charAt(Math.floor(Math.random() * allowedChars.length))
allowedChars.charAt(Math.floor(Math.random() * allowedChars.length)),
);
}
return chars.join('');
Expand Down
6 changes: 3 additions & 3 deletions samples/scripts/externalclient-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ function generateRandomString(length) {
const allowedChars = 'abcdefghijklmnopqrstuvwxyz0123456789';
for (let i = 0; i < length; i++) {
chars.push(
allowedChars.charAt(Math.floor(Math.random() * allowedChars.length))
allowedChars.charAt(Math.floor(Math.random() * allowedChars.length)),
);
}
return chars.join('');
Expand Down Expand Up @@ -276,12 +276,12 @@ const config = {
main(config)
.then(audiences => {
console.log(
'The following constants need to be set in test/externalclient.test.js'
'The following constants need to be set in test/externalclient.test.js',
);
console.log(`AUDIENCE_OIDC='${audiences.oidcAudience}'`);
console.log(`AUDIENCE_AWS='${audiences.awsAudience}'`);
console.log(
`AWS_ROLE_ARN='arn:aws:iam::${config.awsAccountId}:role/${config.awsRoleName}'`
`AWS_ROLE_ARN='arn:aws:iam::${config.awsAccountId}:role/${config.awsRoleName}'`,
);
})
.catch(console.error);
8 changes: 4 additions & 4 deletions samples/test/auth.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,23 @@ describe('auth samples', () => {
const projectId = await auth.getProjectId();

const output = execSync(
`node authenticateImplicitWithAdc ${projectId} ${ZONE}`
`node authenticateImplicitWithAdc ${projectId} ${ZONE}`,
);

assert.match(output, /Listed all storage buckets./);
});

it('should get id token from metadata server', async () => {
const output = execSync(
'node idTokenFromMetadataServer https://www.google.com'
'node idTokenFromMetadataServer https://www.google.com',
);

assert.match(output, /Generated ID token./);
});

it('should get id token from service account', async () => {
const output = execSync(
`node idTokenFromServiceAccount ${TARGET_AUDIENCE} ${keyFile}`
`node idTokenFromServiceAccount ${TARGET_AUDIENCE} ${keyFile}`,
);

assert.match(output, /Generated ID token./);
Expand All @@ -69,7 +69,7 @@ describe('auth samples', () => {
const idToken = await client.fetchIdToken(TARGET_AUDIENCE);

const output = execSync(
`node verifyGoogleIdToken ${idToken} ${TARGET_AUDIENCE} https://www.googleapis.com/oauth2/v3/certs`
`node verifyGoogleIdToken ${idToken} ${TARGET_AUDIENCE} https://www.googleapis.com/oauth2/v3/certs`,
);

assert.match(output, /ID token verified./);
Expand Down
12 changes: 6 additions & 6 deletions samples/test/externalclient.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ const assumeRoleWithWebIdentity = async (
auth,
aud,
clientEmail,
awsRoleArn
awsRoleArn,
) => {
// API documented at:
// https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRoleWithWebIdentity.html
Expand Down Expand Up @@ -186,7 +186,7 @@ const generateRandomString = length => {
const allowedChars = 'abcdefghijklmnopqrstuvwxyz0123456789';
while (length > 0) {
chars.push(
allowedChars.charAt(Math.floor(Math.random() * allowedChars.length))
allowedChars.charAt(Math.floor(Math.random() * allowedChars.length)),
);
length--;
}
Expand Down Expand Up @@ -242,7 +242,7 @@ describe('samples for external-account', () => {
auth,
clientId,
clientEmail,
AWS_ROLE_ARN
AWS_ROLE_ARN,
);
});

Expand Down Expand Up @@ -361,15 +361,15 @@ describe('samples for external-account', () => {
res.end(
JSON.stringify({
access_token: oidcToken,
})
}),
);
} else {
res.setHeader('content-type', 'application/json');
res.writeHead(400);
res.end(
JSON.stringify({
error: 'missing-header',
})
}),
);
}
} else {
Expand Down Expand Up @@ -506,7 +506,7 @@ describe('samples for external-account', () => {
const actualExpireTime = new Date(token.res.data.expireTime).getTime();

assert.isTrue(
minExpireTime <= actualExpireTime && actualExpireTime <= maxExpireTime
minExpireTime <= actualExpireTime && actualExpireTime <= maxExpireTime,
);
});
});
6 changes: 3 additions & 3 deletions samples/verifyIdToken-iap.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function main(
iapJwt,
projectNumber = '',
projectId = '',
backendServiceId = ''
backendServiceId = '',
) {
// [START iap_validate_jwt]
/**
Expand All @@ -54,7 +54,7 @@ function main(
iapJwt,
response.pubkeys,
expectedAudience,
['https://cloud.google.com/iap']
['https://cloud.google.com/iap'],
);
// Print out the info contained in the IAP ID token
console.log(ticket);
Expand All @@ -65,7 +65,7 @@ function main(
// [END iap_validate_jwt]
if (!expectedAudience) {
console.log(
'Audience not verified! Supply a projectNumber and projectID to verify'
'Audience not verified! Supply a projectNumber and projectID to verify',
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/auth/authclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ export abstract class AuthClient

if (options.get('useAuthRequestParameters') !== false) {
this.transporter.interceptors.request.add(
AuthClient.DEFAULT_REQUEST_INTERCEPTOR
AuthClient.DEFAULT_REQUEST_INTERCEPTOR,
);
}

Expand Down Expand Up @@ -306,7 +306,7 @@ export abstract class AuthClient
*/
protected addUserProjectAndAuthHeaders<T extends Headers>(
target: T,
source: Headers
source: Headers,
): T {
const xGoogUserProject = source.get('x-goog-user-project');
const authorizationHeader = source.get('authorization');
Expand Down
Loading

0 comments on commit a511e56

Please sign in to comment.