Skip to content

Commit

Permalink
refactor(deps): opn -> open (#1778)
Browse files Browse the repository at this point in the history
* refactor(deps): `opn` -> `open`

The package has been renamed

* chore: Copyright headers

* revert: Unrelated change

* chore: lint fixes
  • Loading branch information
danielbankhead committed Mar 27, 2024
1 parent fc8dfe9 commit 847caa0
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 39 deletions.
6 changes: 3 additions & 3 deletions samples/oauth2-codeVerifier.js
@@ -1,4 +1,4 @@
// Copyright 2017, Google, Inc.
// Copyright 2017 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
Expand All @@ -16,7 +16,7 @@
const {OAuth2Client} = require('google-auth-library');
const http = require('http');
const url = require('url');
const opn = require('opn');
const open = require('open');
const destroyer = require('server-destroy');

// Download your OAuth2 configuration from the Google Developer Console.
Expand Down Expand Up @@ -95,7 +95,7 @@ async function getAuthenticatedClient() {
})
.listen(3000, () => {
// open the browser to the authorize url to start the workflow
opn(authorizeUrl, {wait: false}).then(cp => cp.unref());
open(authorizeUrl, {wait: false}).then(cp => cp.unref());
});
destroyer(server);
});
Expand Down
6 changes: 3 additions & 3 deletions samples/oauth2.js
@@ -1,4 +1,4 @@
// Copyright 2017, Google, Inc.
// Copyright 2017 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
Expand All @@ -16,7 +16,7 @@
const {OAuth2Client} = require('google-auth-library');
const http = require('http');
const url = require('url');
const opn = require('opn');
const open = require('open');
const destroyer = require('server-destroy');

// Download your OAuth2 configuration from the Google
Expand Down Expand Up @@ -88,7 +88,7 @@ function getAuthenticatedClient() {
})
.listen(3000, () => {
// open the browser to the authorize url to start the workflow
opn(authorizeUrl, {wait: false}).then(cp => cp.unref());
open(authorizeUrl, {wait: false}).then(cp => cp.unref());
});
destroyer(server);
});
Expand Down
2 changes: 1 addition & 1 deletion samples/package.json
Expand Up @@ -17,7 +17,7 @@
"@googleapis/iam": "^15.0.0",
"google-auth-library": "^9.7.0",
"node-fetch": "^2.3.0",
"opn": "^6.0.0",
"open": "^6.0.0",
"server-destroy": "^1.0.1"
},
"devDependencies": {
Expand Down
6 changes: 3 additions & 3 deletions samples/verifyIdToken.js
@@ -1,4 +1,4 @@
// Copyright 2017, Google, Inc.
// Copyright 2017 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
Expand All @@ -16,7 +16,7 @@
const {OAuth2Client} = require('google-auth-library');
const http = require('http');
const url = require('url');
const opn = require('opn');
const open = require('open');
const destroyer = require('server-destroy');

// Download your OAuth2 configuration from the Google
Expand Down Expand Up @@ -87,7 +87,7 @@ function getAuthenticatedClient() {
})
.listen(3000, () => {
// open the browser to the authorize url to start the workflow
opn(authorizeUrl, {wait: false}).then(cp => cp.unref());
open(authorizeUrl, {wait: false}).then(cp => cp.unref());
});
destroyer(server);
});
Expand Down
4 changes: 2 additions & 2 deletions src/auth/computeclient.ts
Expand Up @@ -55,8 +55,8 @@ export class Compute extends OAuth2Client {
this.scopes = Array.isArray(options.scopes)
? options.scopes
: options.scopes
? [options.scopes]
: [];
? [options.scopes]
: [];
}

/**
Expand Down
5 changes: 2 additions & 3 deletions src/transporters.ts
Expand Up @@ -64,9 +64,8 @@ export class DefaultTransporter implements Transporter {
if (!uaValue) {
opts.headers['User-Agent'] = DefaultTransporter.USER_AGENT;
} else if (!uaValue.includes(`${PRODUCT_NAME}/`)) {
opts.headers[
'User-Agent'
] = `${uaValue} ${DefaultTransporter.USER_AGENT}`;
opts.headers['User-Agent'] =
`${uaValue} ${DefaultTransporter.USER_AGENT}`;
}
// track google-auth-library-nodejs version:
if (!opts.headers['x-goog-api-client']) {
Expand Down
4 changes: 2 additions & 2 deletions test/test.downscopedclient.ts
Expand Up @@ -54,11 +54,11 @@ class TestAuthClient extends AuthClient {
this.credentials.expiry_date = expirationTime;
}

async getRequestHeaders(url?: string): Promise<Headers> {
async getRequestHeaders(): Promise<Headers> {
throw new Error('Not implemented.');
}

request<T>(opts: GaxiosOptions): GaxiosPromise<T> {
request<T>(): GaxiosPromise<T> {
throw new Error('Not implemented.');
}
}
Expand Down
1 change: 0 additions & 1 deletion test/test.jwt.ts
Expand Up @@ -28,7 +28,6 @@ describe('jwt', () => {
const keypair = require('keypair');
const PEM_PATH = './test/fixtures/private.pem';
const PEM_CONTENTS = fs.readFileSync(PEM_PATH, 'utf8');
const P12_PATH = './test/fixtures/key.p12';

nock.disableNetConnect();

Expand Down
30 changes: 12 additions & 18 deletions test/test.oauth2common.ts
Expand Up @@ -104,9 +104,8 @@ describe('OAuthClientAuthHandler', () => {
};
const actualOptions = Object.assign({}, originalOptions);
const expectedOptions = Object.assign({}, originalOptions);
(
expectedOptions.headers as Headers
).Authorization = `Basic ${expectedBase64EncodedCred}`;
(expectedOptions.headers as Headers).Authorization =
`Basic ${expectedBase64EncodedCred}`;

handler.testApplyClientAuthenticationOptions(actualOptions);
assert.deepStrictEqual(expectedOptions, actualOptions);
Expand All @@ -127,9 +126,8 @@ describe('OAuthClientAuthHandler', () => {
};
const actualOptions = Object.assign({}, originalOptions);
const expectedOptions = Object.assign({}, originalOptions);
(
expectedOptions.headers as Headers
).Authorization = `Basic ${expectedBase64EncodedCredNoSecret}`;
(expectedOptions.headers as Headers).Authorization =
`Basic ${expectedBase64EncodedCredNoSecret}`;

handler.testApplyClientAuthenticationOptions(actualOptions);
assert.deepStrictEqual(expectedOptions, actualOptions);
Expand All @@ -146,9 +144,8 @@ describe('OAuthClientAuthHandler', () => {
};
const actualOptions = Object.assign({}, originalOptions);
const expectedOptions = Object.assign({}, originalOptions);
(
expectedOptions.headers as Headers
).Authorization = `Basic ${expectedBase64EncodedCred}`;
(expectedOptions.headers as Headers).Authorization =
`Basic ${expectedBase64EncodedCred}`;

handler.testApplyClientAuthenticationOptions(actualOptions);
assert.deepStrictEqual(expectedOptions, actualOptions);
Expand Down Expand Up @@ -349,9 +346,8 @@ describe('OAuthClientAuthHandler', () => {
};
const actualOptions = Object.assign({}, originalOptions);
const expectedOptions = Object.assign({}, originalOptions);
(
expectedOptions.headers as Headers
).Authorization = `Bearer ${bearerToken}`;
(expectedOptions.headers as Headers).Authorization =
`Bearer ${bearerToken}`;

handler.testApplyClientAuthenticationOptions(actualOptions, bearerToken);
assert.deepStrictEqual(expectedOptions, actualOptions);
Expand All @@ -374,9 +370,8 @@ describe('OAuthClientAuthHandler', () => {
const actualOptions = Object.assign({}, originalOptions);
// Expected options should have bearer token in header.
const expectedOptions = Object.assign({}, originalOptions);
(
expectedOptions.headers as Headers
).Authorization = `Bearer ${bearerToken}`;
(expectedOptions.headers as Headers).Authorization =
`Bearer ${bearerToken}`;

handler.testApplyClientAuthenticationOptions(actualOptions, bearerToken);
assert.deepStrictEqual(expectedOptions, actualOptions);
Expand All @@ -399,9 +394,8 @@ describe('OAuthClientAuthHandler', () => {
const actualOptions = Object.assign({}, originalOptions);
// Expected options should have bearer token in header.
const expectedOptions = Object.assign({}, originalOptions);
(
expectedOptions.headers as Headers
).Authorization = `Bearer ${bearerToken}`;
(expectedOptions.headers as Headers).Authorization =
`Bearer ${bearerToken}`;

handler.testApplyClientAuthenticationOptions(actualOptions, bearerToken);
assert.deepStrictEqual(expectedOptions, actualOptions);
Expand Down
2 changes: 1 addition & 1 deletion test/test.pluggableauthclient.ts
Expand Up @@ -17,7 +17,7 @@ import {
ExecutableError,
PluggableAuthClient,
} from '../src/auth/pluggable-auth-client';
import {BaseExternalAccountClient, IdentityPoolClient} from '../src';
import {BaseExternalAccountClient} from '../src';
import {
assertGaxiosResponsePresent,
getAudience,
Expand Down
4 changes: 2 additions & 2 deletions test/test.transporters.ts
Expand Up @@ -155,9 +155,9 @@ describe('transporters', () => {
assert.strictEqual(res!.status, 200);
done();
},
_error => {
error => {
scope.done();
done('Unexpected promise failure');
done(error);
}
);
});
Expand Down

0 comments on commit 847caa0

Please sign in to comment.