google-auth-library
Advanced tools
Comparing version 7.14.1 to 8.0.0
@@ -43,3 +43,3 @@ "use strict"; | ||
this.region = region; | ||
this.crypto = crypto_1.createCrypto(); | ||
this.crypto = (0, crypto_1.createCrypto)(); | ||
} | ||
@@ -203,3 +203,3 @@ /** | ||
`${credentialScope}, SignedHeaders=${signedHeaders}, ` + | ||
`Signature=${crypto_1.fromArrayBufferToHex(signature)}`; | ||
`Signature=${(0, crypto_1.fromArrayBufferToHex)(signature)}`; | ||
return { | ||
@@ -206,0 +206,0 @@ // Do not return x-amz-date if date is available. |
@@ -18,2 +18,3 @@ "use strict"; | ||
const arrify = require("arrify"); | ||
const gaxios_1 = require("gaxios"); | ||
const gcpMetadata = require("gcp-metadata"); | ||
@@ -57,4 +58,6 @@ const oauth2client_1 = require("./oauth2client"); | ||
catch (e) { | ||
e.message = `Could not refresh access token: ${e.message}`; | ||
this.wrapError(e); | ||
if (e instanceof gaxios_1.GaxiosError) { | ||
e.message = `Could not refresh access token: ${e.message}`; | ||
this.wrapError(e); | ||
} | ||
throw e; | ||
@@ -85,3 +88,5 @@ } | ||
catch (e) { | ||
e.message = `Could not fetch ID token: ${e.message}`; | ||
if (e instanceof Error) { | ||
e.message = `Could not fetch ID token: ${e.message}`; | ||
} | ||
throw e; | ||
@@ -88,0 +93,0 @@ } |
@@ -27,4 +27,2 @@ /// <reference types="node" /> | ||
} | ||
interface DeprecatedGetClientOptions { | ||
} | ||
export interface ADCCallback { | ||
@@ -223,3 +221,3 @@ (err: Error | null, credential?: AuthClient, projectId?: string | null): void; | ||
*/ | ||
getClient(options?: DeprecatedGetClientOptions): Promise<Compute | JWT | UserRefreshClient | Impersonated | BaseExternalAccountClient | NonNullable<T>>; | ||
getClient(): Promise<Compute | JSONClient | NonNullable<T>>; | ||
/** | ||
@@ -277,2 +275,1 @@ * Creates a client which will fetch an ID token for authorization. | ||
} | ||
export {}; |
@@ -429,3 +429,3 @@ "use strict"; | ||
return new Promise(resolve => { | ||
child_process_1.exec('gcloud config config-helper --format json', (err, stdout) => { | ||
(0, child_process_1.exec)('gcloud config config-helper --format json', (err, stdout) => { | ||
if (!err && stdout) { | ||
@@ -552,6 +552,3 @@ try { | ||
*/ | ||
async getClient(options) { | ||
if (options) { | ||
throw new Error('Passing options to getClient is forbidden in v5.0.0. Use new GoogleAuth(opts) instead.'); | ||
} | ||
async getClient() { | ||
if (!this.cachedCredential) { | ||
@@ -627,3 +624,3 @@ if (this.jsonContent) { | ||
getEnv() { | ||
return envDetect_1.getEnv(); | ||
return (0, envDetect_1.getEnv)(); | ||
} | ||
@@ -637,3 +634,3 @@ /** | ||
const client = await this.getClient(); | ||
const crypto = crypto_1.createCrypto(); | ||
const crypto = (0, crypto_1.createCrypto)(); | ||
if (client instanceof jwtclient_1.JWT && client.key) { | ||
@@ -640,0 +637,0 @@ const sign = await crypto.sign(client.key, data); |
@@ -25,5 +25,5 @@ "use strict"; | ||
// Fallback to void function to avoid promisify throwing a TypeError. | ||
const readFile = util_1.promisify((_a = fs.readFile) !== null && _a !== void 0 ? _a : (() => { })); | ||
const realpath = util_1.promisify((_b = fs.realpath) !== null && _b !== void 0 ? _b : (() => { })); | ||
const lstat = util_1.promisify((_c = fs.lstat) !== null && _c !== void 0 ? _c : (() => { })); | ||
const readFile = (0, util_1.promisify)((_a = fs.readFile) !== null && _a !== void 0 ? _a : (() => { })); | ||
const realpath = (0, util_1.promisify)((_b = fs.realpath) !== null && _b !== void 0 ? _b : (() => { })); | ||
const lstat = (0, util_1.promisify)((_c = fs.lstat) !== null && _c !== void 0 ? _c : (() => { })); | ||
/** | ||
@@ -57,3 +57,4 @@ * Defines the Url-sourced and file-sourced external account clients mainly | ||
this.formatType = ((_a = options.credential_source.format) === null || _a === void 0 ? void 0 : _a.type) || 'text'; | ||
this.formatSubjectTokenFieldName = (_b = options.credential_source.format) === null || _b === void 0 ? void 0 : _b.subject_token_field_name; | ||
this.formatSubjectTokenFieldName = | ||
(_b = options.credential_source.format) === null || _b === void 0 ? void 0 : _b.subject_token_field_name; | ||
if (this.formatType !== 'json' && this.formatType !== 'text') { | ||
@@ -104,3 +105,5 @@ throw new Error(`Invalid credential_source format "${this.formatType}"`); | ||
catch (err) { | ||
err.message = `The file at ${filePath} does not exist, or it is not a file. ${err.message}`; | ||
if (err instanceof Error) { | ||
err.message = `The file at ${filePath} does not exist, or it is not a file. ${err.message}`; | ||
} | ||
throw err; | ||
@@ -107,0 +110,0 @@ } |
@@ -20,2 +20,3 @@ "use strict"; | ||
const oauth2client_1 = require("./oauth2client"); | ||
const gaxios_1 = require("gaxios"); | ||
class Impersonated extends oauth2client_1.OAuth2Client { | ||
@@ -97,4 +98,10 @@ /** | ||
catch (error) { | ||
const status = (_c = (_b = (_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error) === null || _c === void 0 ? void 0 : _c.status; | ||
const message = (_f = (_e = (_d = error === null || error === void 0 ? void 0 : error.response) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.error) === null || _f === void 0 ? void 0 : _f.message; | ||
if (!(error instanceof Error)) | ||
throw error; | ||
let status = 0; | ||
let message = ''; | ||
if (error instanceof gaxios_1.GaxiosError) { | ||
status = (_c = (_b = (_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error) === null || _c === void 0 ? void 0 : _c.status; | ||
message = (_f = (_e = (_d = error === null || error === void 0 ? void 0 : error.response) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.error) === null || _f === void 0 ? void 0 : _f.message; | ||
} | ||
if (status && message) { | ||
@@ -101,0 +108,0 @@ error.message = `${status}: unable to impersonate: ${message}`; |
@@ -42,3 +42,4 @@ "use strict"; | ||
this.keyId = keyId; | ||
this.eagerRefreshThresholdMillis = eagerRefreshThresholdMillis !== null && eagerRefreshThresholdMillis !== void 0 ? eagerRefreshThresholdMillis : 5 * 60 * 1000; | ||
this.eagerRefreshThresholdMillis = | ||
eagerRefreshThresholdMillis !== null && eagerRefreshThresholdMillis !== void 0 ? eagerRefreshThresholdMillis : 5 * 60 * 1000; | ||
} | ||
@@ -45,0 +46,0 @@ /** |
@@ -403,3 +403,2 @@ import { GaxiosError, GaxiosOptions, GaxiosPromise, GaxiosResponse } from 'gaxios'; | ||
* | ||
* @deprecated use getRequestHeaders instead. | ||
* @param callback callback | ||
@@ -406,0 +405,0 @@ */ |
@@ -87,3 +87,3 @@ "use strict"; | ||
// characters. 6*128/8 = 96. | ||
const crypto = crypto_1.createCrypto(); | ||
const crypto = (0, crypto_1.createCrypto)(); | ||
const randomString = crypto.randomBytesBase64(96); | ||
@@ -482,3 +482,3 @@ // The valid characters in the code_verifier are [A-Z]/[a-z]/[0-9]/ | ||
const nowTime = new Date().getTime(); | ||
const format = crypto_1.hasBrowserCrypto() | ||
const format = (0, crypto_1.hasBrowserCrypto)() | ||
? CertificateFormat.JWK | ||
@@ -507,3 +507,5 @@ : CertificateFormat.PEM; | ||
catch (e) { | ||
e.message = `Failed to retrieve verification certificates: ${e.message}`; | ||
if (e instanceof Error) { | ||
e.message = `Failed to retrieve verification certificates: ${e.message}`; | ||
} | ||
throw e; | ||
@@ -556,3 +558,5 @@ } | ||
catch (e) { | ||
e.message = `Failed to retrieve verification certificates: ${e.message}`; | ||
if (e instanceof Error) { | ||
e.message = `Failed to retrieve verification certificates: ${e.message}`; | ||
} | ||
throw e; | ||
@@ -578,3 +582,3 @@ } | ||
async verifySignedJwtWithCertsAsync(jwt, certs, requiredAudience, issuers, maxExpiry) { | ||
const crypto = crypto_1.createCrypto(); | ||
const crypto = (0, crypto_1.createCrypto)(); | ||
if (!maxExpiry) { | ||
@@ -595,3 +599,5 @@ maxExpiry = OAuth2Client.MAX_TOKEN_LIFETIME_SECS_; | ||
catch (err) { | ||
err.message = `Can't parse token envelope: ${segments[0]}': ${err.message}`; | ||
if (err instanceof Error) { | ||
err.message = `Can't parse token envelope: ${segments[0]}': ${err.message}`; | ||
} | ||
throw err; | ||
@@ -606,3 +612,5 @@ } | ||
catch (err) { | ||
err.message = `Can't parse token payload '${segments[0]}`; | ||
if (err instanceof Error) { | ||
err.message = `Can't parse token payload '${segments[0]}`; | ||
} | ||
throw err; | ||
@@ -609,0 +617,0 @@ } |
@@ -35,3 +35,3 @@ "use strict"; | ||
this.clientAuthentication = clientAuthentication; | ||
this.crypto = crypto_1.createCrypto(); | ||
this.crypto = (0, crypto_1.createCrypto)(); | ||
} | ||
@@ -38,0 +38,0 @@ /** |
@@ -17,2 +17,3 @@ "use strict"; | ||
exports.StsCredentials = void 0; | ||
const gaxios_1 = require("gaxios"); | ||
const querystring = require("querystring"); | ||
@@ -98,4 +99,4 @@ const transporters_1 = require("../transporters"); | ||
// Translate error to OAuthError. | ||
if (error.response) { | ||
throw oauth2common_1.getErrorFromOAuthErrorResponse(error.response.data, | ||
if (error instanceof gaxios_1.GaxiosError && error.response) { | ||
throw (0, oauth2common_1.getErrorFromOAuthErrorResponse)(error.response.data, | ||
// Preserve other fields from the original error. | ||
@@ -102,0 +103,0 @@ error); |
@@ -114,3 +114,3 @@ "use strict"; | ||
const outputBuffer = await window.crypto.subtle.digest('SHA-256', inputBuffer); | ||
return crypto_1.fromArrayBufferToHex(outputBuffer); | ||
return (0, crypto_1.fromArrayBufferToHex)(outputBuffer); | ||
} | ||
@@ -117,0 +117,0 @@ /** |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.GoogleAuth = exports.auth = void 0; | ||
exports.GoogleAuth = exports.auth = exports.DefaultTransporter = exports.DownscopedClient = exports.BaseExternalAccountClient = exports.ExternalAccountClient = exports.IdentityPoolClient = exports.AwsClient = exports.UserRefreshClient = exports.LoginTicket = exports.OAuth2Client = exports.CodeChallengeMethod = exports.Impersonated = exports.JWT = exports.JWTAccess = exports.IdTokenClient = exports.IAMAuth = exports.GCPEnv = exports.Compute = exports.AuthClient = void 0; | ||
// Copyright 2017 Google LLC | ||
@@ -5,0 +5,0 @@ // |
@@ -56,3 +56,3 @@ "use strict"; | ||
try { | ||
options_1.validate(opts); | ||
(0, options_1.validate)(opts); | ||
} | ||
@@ -68,3 +68,3 @@ catch (e) { | ||
if (callback) { | ||
gaxios_1.request(opts).then(r => { | ||
(0, gaxios_1.request)(opts).then(r => { | ||
callback(null, r); | ||
@@ -76,3 +76,3 @@ }, e => { | ||
else { | ||
return gaxios_1.request(opts).catch(e => { | ||
return (0, gaxios_1.request)(opts).catch(e => { | ||
throw this.processError(e); | ||
@@ -79,0 +79,0 @@ }); |
@@ -7,2 +7,19 @@ # Changelog | ||
## [8.0.0](https://github.com/googleapis/google-auth-library-nodejs/compare/v7.14.1...v8.0.0) (2022-04-20) | ||
### ⚠ BREAKING CHANGES | ||
* Set Node v12 to minimum supported version & Upgrade TypeScript (#1392) | ||
* remove deprecated DeprecatedGetClientOptions (#1393) | ||
### Code Refactoring | ||
* remove deprecated DeprecatedGetClientOptions ([#1393](https://github.com/googleapis/google-auth-library-nodejs/issues/1393)) ([9c02941](https://github.com/googleapis/google-auth-library-nodejs/commit/9c02941e52514f8e3b07fedb01439fc313046063)) | ||
### Build System | ||
* Set Node v12 to minimum supported version & Upgrade TypeScript ([#1392](https://github.com/googleapis/google-auth-library-nodejs/issues/1392)) ([b7bcedb](https://github.com/googleapis/google-auth-library-nodejs/commit/b7bcedb9e4ec24217a861016f3378460af7598c7)) | ||
### [7.14.1](https://github.com/googleapis/google-auth-library-nodejs/compare/v7.14.0...v7.14.1) (2022-03-09) | ||
@@ -9,0 +26,0 @@ |
{ | ||
"name": "google-auth-library", | ||
"version": "7.14.1", | ||
"version": "8.0.0", | ||
"author": "Google Inc.", | ||
"description": "Google APIs Authentication Client Library for Node.js", | ||
"engines": { | ||
"node": ">=10" | ||
"node": ">=12" | ||
}, | ||
@@ -26,3 +26,3 @@ "main": "./build/src/index.js", | ||
"gcp-metadata": "^4.2.0", | ||
"gtoken": "^5.0.4", | ||
"gtoken": "^5.3.2", | ||
"jws": "^4.0.0", | ||
@@ -48,3 +48,3 @@ "lru-cache": "^6.0.0" | ||
"execa": "^5.0.0", | ||
"gts": "^2.0.0", | ||
"gts": "^3.1.0", | ||
"is-docker": "^2.0.0", | ||
@@ -70,3 +70,3 @@ "karma": "^6.0.0", | ||
"ts-loader": "^8.0.0", | ||
"typescript": "^3.8.3", | ||
"typescript": "^4.6.3", | ||
"webpack": "^5.21.2", | ||
@@ -73,0 +73,0 @@ "webpack-cli": "^4.0.0" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
423688
7181
Updatedgtoken@^5.3.2