Socket
Socket
Sign inDemoInstall

@google-cloud/common

Package Overview
Dependencies
Maintainers
1
Versions
118
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@google-cloud/common - npm Package Compare versions

Comparing version 0.3.0 to 0.4.0

4

package.json
{
"name": "@google-cloud/common",
"version": "0.3.0",
"version": "0.4.0",
"author": "Google Inc.",

@@ -51,3 +51,3 @@ "description": "Common components for Google Cloud APIs Node.js Client Libraries",

"google-proto-files": "^0.7.0",
"grpc": "^0.14.1",
"grpc": "^1.0.0",
"is": "^3.0.1",

@@ -54,0 +54,0 @@ "methmeth": "^1.0.0",

@@ -76,6 +76,17 @@ /*!

GrpcServiceObject.prototype.getMetadata = function(callback) {
var self = this;
var protoOpts = this.methods.getMetadata.protoOpts;
var reqOpts = this.methods.getMetadata.reqOpts;
this.request(protoOpts, reqOpts, callback);
this.request(protoOpts, reqOpts, function(err, resp) {
if (err) {
callback(err, null, resp);
return;
}
self.metadata = resp;
callback(null, self.metadata, resp);
});
};

@@ -82,0 +93,0 @@

@@ -141,2 +141,3 @@ /*!

* @param {string} config.baseUrl - The base URL to make API requests to.
* @param {object} config.grpcMetadata - Metadata to send with every request.
* @param {string[]} config.scopes - The scopes required for the request.

@@ -162,2 +163,12 @@ * @param {string} config.service - The name of the service.

this.grpcMetadata = new grpc.Metadata();
if (config.grpcMetadata) {
for (var prop in config.grpcMetadata) {
if (config.grpcMetadata.hasOwnProperty(prop)) {
this.grpcMetadata.add(prop, config.grpcMetadata[prop]);
}
}
}
this.maxRetries = options.maxRetries;

@@ -232,4 +243,6 @@

var service = this.getService_(protoOpts);
var metadata = this.grpcMetadata;
var grpcOpts = {};
if (is.number(protoOpts.timeout)) {

@@ -254,5 +267,5 @@ grpcOpts.deadline = GrpcService.createDeadline_(protoOpts.timeout);

service[protoOpts.method](reqOpts, grpcOpts, function(err, resp) {
if (err) {
respError = GrpcService.decorateError_(err);
service[protoOpts.method](reqOpts, metadata, grpcOpts, function(e, resp) {
if (e) {
respError = GrpcService.decorateError_(e);

@@ -264,3 +277,3 @@ if (respError) {

onResponse(err, resp);
onResponse(e, resp);
return;

@@ -338,3 +351,3 @@ }

request: function() {
return service[protoOpts.method](reqOpts, grpcOpts)
return service[protoOpts.method](reqOpts, self.grpcMetadata, grpcOpts)
.on('metadata', function() {

@@ -468,2 +481,17 @@ // retry-request requires a server response before it starts emitting

/**
* Checks for a grpc status code and extends the error object with additional
* information.
*
* @private
*
* @param {error|object} err - The grpc error.
* @return {error|null}
*/
GrpcService.decorateError_ = function(err) {
var errorObj = is.error(err) ? err : {};
return GrpcService.decorateGrpcResponse_(errorObj, err);
};
/**
* Checks for a grpc status code and extends the supplied object with additional

@@ -481,6 +509,16 @@ * information.

var defaultResponseDetails = GRPC_ERROR_CODE_TO_HTTP[response.code];
var message = defaultResponseDetails.message;
if (response.message) {
// gRPC error messages can be either stringified JSON or strings.
try {
message = JSON.parse(response.message).description;
} catch(e) {
message = response.message;
}
}
return extend(true, obj, response, {
code: defaultResponseDetails.code,
message: response.message || defaultResponseDetails.message
message: message
});

@@ -493,16 +531,2 @@ }

/**
* Checks for a grpc status code and extends the error object with additional
* information.
*
* @private
*
* @param {error|object} err - The grpc error.
* @return {error|null}
*/
GrpcService.decorateError_ = function(err) {
var errorObj = is.error(err) ? new Error() : {};
return GrpcService.decorateGrpcResponse_(errorObj, err);
};
/**
* Checks for grpc status code and extends the status object with additional

@@ -509,0 +533,0 @@ * information

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc