Socket
Socket
Sign inDemoInstall

google-auto-auth

Package Overview
Dependencies
84
Maintainers
12
Versions
32
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.9.6 to 0.9.7

62

index.js

@@ -6,4 +6,4 @@ 'use strict';

var fs = require('fs');
var GoogleAuth = require('google-auth-library').GoogleAuth;
var gcpMetadata = require('gcp-metadata');
var googleAuthLibrary = require('google-auth-library');
var path = require('path');

@@ -20,2 +20,3 @@ var request = require('request');

this.environment = {};
this.jwtClient = null;
this.projectId = this.config.projectId;

@@ -65,4 +66,5 @@ }

var keyFile = config.keyFilename || config.keyFile;
var googleAuthClient;
this.googleAuthClient = new GoogleAuth();
var addScope = (err, authClient, projectId) => {

@@ -87,2 +89,15 @@ if (err) {

if (!this.projectId) {
this.googleAuthClient.getDefaultProjectId((err, projectId) => {
// Ignore error, since the user might not require a project ID.
if (projectId) {
this.projectId = projectId;
}
resolve(authClient);
});
return;
}
resolve(authClient);

@@ -92,6 +107,4 @@ };

if (config.credentials) {
googleAuthClient = new googleAuthLibrary.GoogleAuth();
try {
var client = googleAuthClient.fromJSON(config.credentials);
var client = this.googleAuthClient.fromJSON(config.credentials);
addScope(null, client);

@@ -111,19 +124,22 @@ } catch (e) {

try {
googleAuthClient = new googleAuthLibrary.GoogleAuth();
var client = googleAuthClient.fromJSON(JSON.parse(contents));
var client = this.googleAuthClient.fromJSON(JSON.parse(contents));
addScope(null, client);
} catch(e) {
googleAuthClient = new googleAuthLibrary.JWT({
email: config.email,
keyFile: keyFile
// @TODO Find a better way to do this.
// Ref: https://github.com/googleapis/nodejs-storage/issues/147
// Ref: https://github.com/google/google-auth-library-nodejs/issues/313
var client = this.googleAuthClient.fromJSON({
type: 'jwt-pem-p12',
client_email: config.email,
private_key: keyFile
});
addScope(null, googleAuthClient);
delete client.key;
client.keyFile = keyFile;
this.jwtClient = client;
addScope(null, client);
}
});
} else {
googleAuthClient = new googleAuthLibrary.GoogleAuth();
googleAuthClient.getApplicationDefault(addScope);
this.googleAuthClient.getApplicationDefault(addScope);
}
this.googleAuthClient = googleAuthClient;
};

@@ -166,3 +182,17 @@

callback(null, credentials);
if (this.jwtClient) {
this.jwtClient.authorize(err => {
if (err) {
callback(err);
return;
}
this.credentials.private_key = this.jwtClient.key;
callback(null, this.credentials);
});
return;
}
callback(null, this.credentials);
});

@@ -169,0 +199,0 @@ });

{
"name": "google-auto-auth",
"version": "0.9.6",
"version": "0.9.7",
"description": "Making it as easy as possible to authenticate a Google API request",

@@ -38,3 +38,3 @@ "main": "index.js",

"gcp-metadata": "^0.6.1",
"google-auth-library": "^1.2.0",
"google-auth-library": "^1.3.1",
"request": "^2.79.0"

@@ -41,0 +41,0 @@ },

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc