Skip to content

Commit

Permalink
Merge pull request #103 from Mudlet/dependabot/npm_and_yarn/google-au…
Browse files Browse the repository at this point in the history
…th-library-9.14.1

Bump google-auth-library from 9.13.0 to 9.14.1
  • Loading branch information
keneanung authored Oct 1, 2024
2 parents 45ba4d7 + df80f42 commit 9d29367
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 57 deletions.
134 changes: 86 additions & 48 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8496,6 +8496,7 @@ class AuthClient extends events_1.EventEmitter {
this.universeDomain = exports.DEFAULT_UNIVERSE;
const options = (0, util_1.originalOrCamelOptions)(opts);
// Shared auth options
this.apiKey = opts.apiKey;
this.projectId = (_a = options.get('project_id')) !== null && _a !== void 0 ? _a : null;
this.quotaProjectId = options.get('quota_project_id');
this.credentials = (_b = options.get('credentials')) !== null && _b !== void 0 ? _b : {};
Expand Down Expand Up @@ -10688,7 +10689,7 @@ exports.FileSubjectTokenSupplier = FileSubjectTokenSupplier;
/***/ }),

/***/ 95934:
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {


// Copyright 2019 Google LLC
Expand All @@ -10704,8 +10705,20 @@ exports.FileSubjectTokenSupplier = FileSubjectTokenSupplier;
// 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 __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 _GoogleAuth_instances, _GoogleAuth_pendingAuthClient, _GoogleAuth_prepareAndCacheClient, _GoogleAuth_determineClient;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.GoogleAuth = exports.CLOUD_SDK_CLIENT_ID = void 0;
exports.GoogleAuth = exports.GoogleAuthExceptionMessages = exports.CLOUD_SDK_CLIENT_ID = void 0;
const child_process_1 = __nccwpck_require__(35317);
const fs = __nccwpck_require__(79896);
const gcpMetadata = __nccwpck_require__(23046);
Expand All @@ -10725,19 +10738,21 @@ const authclient_1 = __nccwpck_require__(34810);
const externalAccountAuthorizedUserClient_1 = __nccwpck_require__(34240);
const util_1 = __nccwpck_require__(37870);
exports.CLOUD_SDK_CLIENT_ID = '764086051850-6qr4p6gpi6hn506pt8ejuq83di341hur.apps.googleusercontent.com';
const GoogleAuthExceptionMessages = {
exports.GoogleAuthExceptionMessages = {
API_KEY_WITH_CREDENTIALS: 'API Keys and Credentials are mutually exclusive authentication methods and cannot be used together.',
NO_PROJECT_ID_FOUND: 'Unable to detect a Project Id in the current environment. \n' +
'To learn more about authentication and Google APIs, visit: \n' +
'https://cloud.google.com/docs/authentication/getting-started',
NO_CREDENTIALS_FOUND: 'Unable to find credentials in current environment. \n' +
'To learn more about authentication and Google APIs, visit: \n' +
'https://cloud.google.com/docs/authentication/getting-started',
NO_ADC_FOUND: 'Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started for more information.',
NO_UNIVERSE_DOMAIN_FOUND: 'Unable to detect a Universe Domain in the current environment.\n' +
'To learn more about Universe Domain retrieval, visit: \n' +
'https://cloud.google.com/compute/docs/metadata/predefined-metadata-keys',
};
class GoogleAuth {
// Note: this properly is only public to satisify unit tests.
// Note: this properly is only public to satisfy unit tests.
// https://github.com/Microsoft/TypeScript/issues/5228
get isGCE() {
return this.checkIsGCE;
Expand All @@ -10753,7 +10768,8 @@ class GoogleAuth {
*
* @param opts
*/
constructor(opts) {
constructor(opts = {}) {
_GoogleAuth_instances.add(this);
/**
* Caches a value indicating whether the auth layer is running on Google
* Compute Engine.
Expand All @@ -10763,14 +10779,22 @@ class GoogleAuth {
// To save the contents of the JSON credential file
this.jsonContent = null;
this.cachedCredential = null;
/**
* A pending {@link AuthClient}. Used for concurrent {@link GoogleAuth.getClient} calls.
*/
_GoogleAuth_pendingAuthClient.set(this, null);
this.clientOptions = {};
opts = opts || {};
this._cachedProjectId = opts.projectId || null;
this.cachedCredential = opts.authClient || null;
this.keyFilename = opts.keyFilename || opts.keyFile;
this.scopes = opts.scopes;
this.jsonContent = opts.credentials || null;
this.clientOptions = opts.clientOptions || {};
this.jsonContent = opts.credentials || null;
this.apiKey = opts.apiKey || this.clientOptions.apiKey || null;
// Cannot use both API Key + Credentials
if (this.apiKey && (this.jsonContent || this.clientOptions.credentials)) {
throw new RangeError(exports.GoogleAuthExceptionMessages.API_KEY_WITH_CREDENTIALS);
}
if (opts.universeDomain) {
this.clientOptions.universeDomain = opts.universeDomain;
}
Expand Down Expand Up @@ -10805,7 +10829,7 @@ class GoogleAuth {
}
catch (e) {
if (e instanceof Error &&
e.message === GoogleAuthExceptionMessages.NO_PROJECT_ID_FOUND) {
e.message === exports.GoogleAuthExceptionMessages.NO_PROJECT_ID_FOUND) {
return null;
}
else {
Expand Down Expand Up @@ -10836,7 +10860,7 @@ class GoogleAuth {
return projectId;
}
else {
throw new Error(GoogleAuthExceptionMessages.NO_PROJECT_ID_FOUND);
throw new Error(exports.GoogleAuthExceptionMessages.NO_PROJECT_ID_FOUND);
}
}
async getProjectIdAsync() {
Expand Down Expand Up @@ -10918,11 +10942,9 @@ class GoogleAuth {
// This will also preserve one's configured quota project, in case they
// set one directly on the credential previously.
if (this.cachedCredential) {
return await this.prepareAndCacheADC(this.cachedCredential);
// cache, while preserving existing quota project preferences
return await __classPrivateFieldGet(this, _GoogleAuth_instances, "m", _GoogleAuth_prepareAndCacheClient).call(this, this.cachedCredential, null);
}
// Since this is a 'new' ADC to cache we will use the environment variable
// if it's available. We prefer this value over the value from ADC.
const quotaProjectIdOverride = process.env['GOOGLE_CLOUD_QUOTA_PROJECT'];
let credential;
// Check for the existence of a local environment variable pointing to the
// location of the credential file. This is typically used in local
Expand All @@ -10936,7 +10958,7 @@ class GoogleAuth {
else if (credential instanceof baseexternalclient_1.BaseExternalAccountClient) {
credential.scopes = this.getAnyScopes();
}
return await this.prepareAndCacheADC(credential, quotaProjectIdOverride);
return await __classPrivateFieldGet(this, _GoogleAuth_instances, "m", _GoogleAuth_prepareAndCacheClient).call(this, credential);
}
// Look in the well-known credential file location.
credential =
Expand All @@ -10948,7 +10970,7 @@ class GoogleAuth {
else if (credential instanceof baseexternalclient_1.BaseExternalAccountClient) {
credential.scopes = this.getAnyScopes();
}
return await this.prepareAndCacheADC(credential, quotaProjectIdOverride);
return await __classPrivateFieldGet(this, _GoogleAuth_instances, "m", _GoogleAuth_prepareAndCacheClient).call(this, credential);
}
// Determine if we're running on GCE.
if (await this._checkIsGCE()) {
Expand All @@ -10958,17 +10980,9 @@ class GoogleAuth {
await this.getUniverseDomainFromMetadataServer();
}
options.scopes = this.getAnyScopes();
return await this.prepareAndCacheADC(new computeclient_1.Compute(options), quotaProjectIdOverride);
}
throw new Error('Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started for more information.');
}
async prepareAndCacheADC(credential, quotaProjectIdOverride) {
const projectId = await this.getProjectIdOptional();
if (quotaProjectIdOverride) {
credential.quotaProjectId = quotaProjectIdOverride;
return await __classPrivateFieldGet(this, _GoogleAuth_instances, "m", _GoogleAuth_prepareAndCacheClient).call(this, new computeclient_1.Compute(options));
}
this.cachedCredential = credential;
return { credential, projectId };
throw new Error(exports.GoogleAuthExceptionMessages.NO_ADC_FOUND);
}
/**
* Determines whether the auth layer is running on Google Compute Engine.
Expand Down Expand Up @@ -11184,15 +11198,15 @@ class GoogleAuth {
if (!inputStream) {
throw new Error('Must pass in a stream containing the Google auth settings.');
}
let s = '';
const chunks = [];
inputStream
.setEncoding('utf8')
.on('error', reject)
.on('data', chunk => (s += chunk))
.on('data', chunk => chunks.push(chunk))
.on('end', () => {
try {
try {
const data = JSON.parse(s);
const data = JSON.parse(chunks.join(''));
const r = this._cacheClientFromJSON(data, options);
return resolve(r);
}
Expand All @@ -11218,15 +11232,14 @@ class GoogleAuth {
}
/**
* Create a credentials instance using the given API key string.
* The created client is not cached. In order to create and cache it use the {@link GoogleAuth.getClient `getClient`} method after first providing an {@link GoogleAuth.apiKey `apiKey`}.
*
* @param apiKey The API key string
* @param options An optional options object.
* @returns A JWT loaded from the key
*/
fromAPIKey(apiKey, options) {
options = options || {};
const client = new jwtclient_1.JWT(options);
client.fromAPIKey(apiKey);
return client;
fromAPIKey(apiKey, options = {}) {
return new jwtclient_1.JWT({ ...options, apiKey });
}
/**
* Determines whether the current operating system is Windows.
Expand Down Expand Up @@ -11366,28 +11379,26 @@ class GoogleAuth {
]);
return { client_email, universe_domain };
}
throw new Error(GoogleAuthExceptionMessages.NO_CREDENTIALS_FOUND);
throw new Error(exports.GoogleAuthExceptionMessages.NO_CREDENTIALS_FOUND);
}
/**
* Automatically obtain an {@link AuthClient `AuthClient`} based on the
* provided configuration. If no options were passed, use Application
* Default Credentials.
*/
async getClient() {
if (!this.cachedCredential) {
if (this.jsonContent) {
this._cacheClientFromJSON(this.jsonContent, this.clientOptions);
}
else if (this.keyFilename) {
const filePath = path.resolve(this.keyFilename);
const stream = fs.createReadStream(filePath);
await this.fromStreamAsync(stream, this.clientOptions);
}
else {
await this.getApplicationDefaultAsync(this.clientOptions);
}
if (this.cachedCredential) {
return this.cachedCredential;
}
// Use an existing auth client request, or cache a new one
__classPrivateFieldSet(this, _GoogleAuth_pendingAuthClient, __classPrivateFieldGet(this, _GoogleAuth_pendingAuthClient, "f") || __classPrivateFieldGet(this, _GoogleAuth_instances, "m", _GoogleAuth_determineClient).call(this), "f");
try {
return await __classPrivateFieldGet(this, _GoogleAuth_pendingAuthClient, "f");
}
finally {
// reset the pending auth client in case it is changed later
__classPrivateFieldSet(this, _GoogleAuth_pendingAuthClient, null, "f");
}
return this.cachedCredential;
}
/**
* Creates a client which will fetch an ID token for authorization.
Expand Down Expand Up @@ -11495,6 +11506,33 @@ class GoogleAuth {
}
}
exports.GoogleAuth = GoogleAuth;
_GoogleAuth_pendingAuthClient = new WeakMap(), _GoogleAuth_instances = new WeakSet(), _GoogleAuth_prepareAndCacheClient = async function _GoogleAuth_prepareAndCacheClient(credential, quotaProjectIdOverride = process.env['GOOGLE_CLOUD_QUOTA_PROJECT'] || null) {
const projectId = await this.getProjectIdOptional();
if (quotaProjectIdOverride) {
credential.quotaProjectId = quotaProjectIdOverride;
}
this.cachedCredential = credential;
return { credential, projectId };
}, _GoogleAuth_determineClient = async function _GoogleAuth_determineClient() {
if (this.jsonContent) {
return this._cacheClientFromJSON(this.jsonContent, this.clientOptions);
}
else if (this.keyFilename) {
const filePath = path.resolve(this.keyFilename);
const stream = fs.createReadStream(filePath);
return await this.fromStreamAsync(stream, this.clientOptions);
}
else if (this.apiKey) {
const client = await this.fromAPIKey(this.apiKey, this.clientOptions);
client.scopes = this.scopes;
const { credential } = await __classPrivateFieldGet(this, _GoogleAuth_instances, "m", _GoogleAuth_prepareAndCacheClient).call(this, client);
return credential;
}
else {
const { credential } = await this.getApplicationDefaultAsync(this.clientOptions);
return credential;
}
};
/**
* Export DefaultTransporter as a static property of the class.
*/
Expand Down Expand Up @@ -728178,7 +728216,7 @@ module.exports = /*#__PURE__*/JSON.parse('{"name":"dotenv","version":"16.4.5","d
/***/ 96066:
/***/ ((module) => {

module.exports = /*#__PURE__*/JSON.parse('{"name":"google-auth-library","version":"9.13.0","author":"Google Inc.","description":"Google APIs Authentication Client Library for Node.js","engines":{"node":">=14"},"main":"./build/src/index.js","types":"./build/src/index.d.ts","repository":"googleapis/google-auth-library-nodejs.git","keywords":["google","api","google apis","client","client library"],"dependencies":{"base64-js":"^1.3.0","ecdsa-sig-formatter":"^1.0.11","gaxios":"^6.1.1","gcp-metadata":"^6.1.0","gtoken":"^7.0.0","jws":"^4.0.0"},"devDependencies":{"@compodoc/compodoc":"1.1.23","@types/base64-js":"^1.2.5","@types/chai":"^4.1.7","@types/jws":"^3.1.0","@types/mocha":"^9.0.0","@types/mv":"^2.1.0","@types/ncp":"^2.0.1","@types/node":"^20.4.2","@types/sinon":"^17.0.0","assert-rejects":"^1.0.0","c8":"^8.0.0","chai":"^4.2.0","codecov":"^3.0.2","execa":"^5.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-sourcemap-loader":"^0.4.0","karma-webpack":"5.0.0","keypair":"^1.0.4","linkinator":"^4.0.0","mocha":"^9.2.2","mv":"^2.1.1","ncp":"^2.0.0","nock":"^13.0.0","null-loader":"^4.0.0","puppeteer":"^21.0.0","sinon":"^18.0.0","ts-loader":"^8.0.0","typescript":"^5.1.6","webpack":"^5.21.2","webpack-cli":"^4.0.0"},"files":["build/src","!build/src/**/*.map"],"scripts":{"test":"c8 mocha build/test","clean":"gts clean","prepare":"npm run compile","lint":"gts check","compile":"tsc -p .","fix":"gts fix","pretest":"npm run compile -- --sourceMap","docs":"compodoc src/","samples-setup":"cd samples/ && npm link ../ && npm run setup && cd ../","samples-test":"cd samples/ && npm link ../ && npm test && cd ../","system-test":"mocha build/system-test --timeout 60000","presystem-test":"npm run compile -- --sourceMap","webpack":"webpack","browser-test":"karma start","docs-test":"linkinator docs","predocs-test":"npm run docs","prelint":"cd samples; npm link ../; npm install","precompile":"gts clean"},"license":"Apache-2.0"}');
module.exports = /*#__PURE__*/JSON.parse('{"name":"google-auth-library","version":"9.14.1","author":"Google Inc.","description":"Google APIs Authentication Client Library for Node.js","engines":{"node":">=14"},"main":"./build/src/index.js","types":"./build/src/index.d.ts","repository":"googleapis/google-auth-library-nodejs.git","keywords":["google","api","google apis","client","client library"],"dependencies":{"base64-js":"^1.3.0","ecdsa-sig-formatter":"^1.0.11","gaxios":"^6.1.1","gcp-metadata":"^6.1.0","gtoken":"^7.0.0","jws":"^4.0.0"},"devDependencies":{"@compodoc/compodoc":"1.1.23","@types/base64-js":"^1.2.5","@types/chai":"^4.1.7","@types/jws":"^3.1.0","@types/mocha":"^9.0.0","@types/mv":"^2.1.0","@types/ncp":"^2.0.1","@types/node":"^20.4.2","@types/sinon":"^17.0.0","assert-rejects":"^1.0.0","c8":"^8.0.0","chai":"^4.2.0","cheerio":"1.0.0-rc.12","codecov":"^3.0.2","execa":"^5.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-sourcemap-loader":"^0.4.0","karma-webpack":"5.0.0","keypair":"^1.0.4","linkinator":"^4.0.0","mocha":"^9.2.2","mv":"^2.1.1","ncp":"^2.0.0","nock":"^13.0.0","null-loader":"^4.0.0","puppeteer":"^21.0.0","sinon":"^18.0.0","ts-loader":"^8.0.0","typescript":"^5.1.6","webpack":"^5.21.2","webpack-cli":"^4.0.0"},"files":["build/src","!build/src/**/*.map"],"scripts":{"test":"c8 mocha build/test","clean":"gts clean","prepare":"npm run compile","lint":"gts check","compile":"tsc -p .","fix":"gts fix","pretest":"npm run compile -- --sourceMap","docs":"compodoc src/","samples-setup":"cd samples/ && npm link ../ && npm run setup && cd ../","samples-test":"cd samples/ && npm link ../ && npm test && cd ../","system-test":"mocha build/system-test --timeout 60000","presystem-test":"npm run compile -- --sourceMap","webpack":"webpack","browser-test":"karma start","docs-test":"linkinator docs","predocs-test":"npm run docs","prelint":"cd samples; npm link ../; npm install","precompile":"gts clean"},"license":"Apache-2.0"}');

/***/ }),

Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

Loading

0 comments on commit 9d29367

Please sign in to comment.