Socket
Socket
Sign inDemoInstall

github

Package Overview
Dependencies
Maintainers
2
Versions
101
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github - npm Package Compare versions

Comparing version 6.0.2 to 6.0.3

examples/updateReference.js

5

CHANGELOG.md
# CHANGELOG
## 6.0.3
Bug fixes:
* Fix ref params being uri encoded.
## 6.0.2

@@ -4,0 +9,0 @@

29

lib/generate.js

@@ -42,9 +42,11 @@ #!/usr/bin/env node

function prepareApi(struct, baseType) {
if (!baseType)
if (!baseType) {
baseType = "";
}
Object.keys(struct).sort().forEach(function(routePart) {
var block = struct[routePart];
if (!block)
if (!block) {
return;
}
var messageType = baseType + "/" + routePart;

@@ -70,4 +72,5 @@ if (block.url && block.params) {

// add test to the testSections
if (!testSections[section])
if (!testSections[section]) {
testSections[section] = [];
}
testSections[section].push(TestHandlerTpl

@@ -143,3 +146,8 @@ .replace("<%name%>", block.method + " " + block.url + " (" + funcName + ")")

commentLines.push(" * @apiParam {" + paramType + "} " + paramLabel + " " + paramDescription);
var allowedValues = '';
if (paramInfo['enum']) {
allowedValues = '=' + paramInfo['enum'].join(',');
}
commentLines.push(" * @apiParam {" + paramType + allowedValues + "} " + paramLabel + " " + paramDescription);
});

@@ -154,4 +162,5 @@

var params = Object.keys(paramsStruct);
if (!params.length)
if (!params.length) {
return "{}";
}
var values = [];

@@ -167,8 +176,8 @@ var paramName, def;

process.exit(1);
} else {
def = defines.params[paramName];
}
else
def = defines.params[paramName];
} else {
def = paramsStruct[paramName];
}
else
def = paramsStruct[paramName];

@@ -199,4 +208,6 @@ values.push(indent + " " + paramName + ": \"" + def.type + "\"");

});
require('./generateFlowTypes.js');
};
main();

@@ -97,4 +97,5 @@ "use strict";

for (var accept in mediaHash) {
for (var route in mediaHash[accept])
for (var route in mediaHash[accept]) {
mediaTypes[mediaHash[accept][route]] = accept;
}
}

@@ -149,4 +150,5 @@

function trim(s) {
if (typeof s != "string")
if (typeof s != "string") {
return s;
}
return s.replace(/^[\s\t\r\n]+/, "").replace(/[\s\t\r\n]+$/, "");

@@ -165,10 +167,9 @@ }

paramName + "' not found in defines block", "fatal");
}
else {
} else {
def = paramsStruct[paramName] = defines.params[paramName];
delete paramsStruct["$" + paramName];
}
} else {
def = paramsStruct[paramName];
}
else
def = paramsStruct[paramName];

@@ -181,4 +182,5 @@ value = trim(msg[paramName]);

(def["allow-empty"] && value === "") ||
(def["allow-null"] && value === null))
(def["allow-null"] && value === null)) {
continue;
}
throw new error.BadRequest("Empty value for parameter '" +

@@ -204,4 +206,3 @@ paramName + "': " + value);

}
}
else if (type == "float") {
} else if (type == "float") {
value = parseFloat(value);

@@ -212,9 +213,7 @@ if (isNaN(value)) {

}
}
else if (type == "json") {
} else if (type == "json") {
if (typeof value == "string") {
try {
value = JSON.parse(value);
}
catch(ex) {
} catch(ex) {
throw new error.BadRequest("JSON parse error of value for parameter '" +

@@ -224,4 +223,3 @@ paramName + "': " + value);

}
}
else if (type == "date") {
} else if (type == "date") {
value = new Date(value);

@@ -235,8 +233,10 @@ }

function prepareApi(struct, baseType) {
if (!baseType)
if (!baseType) {
baseType = "";
}
Object.keys(struct).forEach(function(routePart) {
var block = struct[routePart];
if (!block)
if (!block) {
return;
}
var messageType = baseType + "/" + routePart;

@@ -263,11 +263,13 @@ if (block.url && block.params) {

parseParams(msg, block.params);
}
catch (ex) {
} catch (ex) {
// when the message was sent to the client, we can
// reply with the error directly.
self.sendError(ex, block, msg, callback);
if (self.debug)
if (self.debug) {
Util.log(ex.message, "fatal");
}
if (self.Promise && typeof callback !== 'function') return self.Promise.reject(ex)
if (self.Promise && typeof callback !== 'function') {
return self.Promise.reject(ex)
}

@@ -297,4 +299,3 @@ // on error, there's no need to continue.

};
}
else {
} else {
// recurse into this block next:

@@ -358,12 +359,16 @@ prepareApi(block, messageType);

}
if (!options.type || "basic|oauth|client|token|integration".indexOf(options.type) === -1)
if (!options.type || "basic|oauth|client|token|integration".indexOf(options.type) === -1) {
throw new Error("Invalid authentication type, must be 'basic', 'integration', 'oauth' or 'client'");
if (options.type == "basic" && (!options.username || !options.password))
}
if (options.type == "basic" && (!options.username || !options.password)) {
throw new Error("Basic authentication requires both a username and password to be set");
}
if (options.type == "oauth") {
if (!options.token && !(options.key && options.secret))
if (!options.token && !(options.key && options.secret)) {
throw new Error("OAuth2 authentication requires a token or key & secret to be set");
}
}
if ((options.type == "token" || options.type == "integration") && !options.token)
if ((options.type == "token" || options.type == "integration") && !options.token) {
throw new Error("Token authentication requires a token to be set");
}

@@ -374,8 +379,10 @@ this.auth = options;

function getPageLinks(link) {
if (typeof link == "object" && (link.link || link.meta.link))
if (typeof link == "object" && (link.link || link.meta.link)) {
link = link.link || link.meta.link;
}
var links = {};
if (typeof link != "string")
if (typeof link != "string") {
return links;
}

@@ -441,4 +448,5 @@ // link format:

var msg = Object.create(parsedUrl.query);
if (headers != null)
if (headers != null) {
msg.headers = headers;
}

@@ -536,5 +544,5 @@ var block = {

function getRequestFormat(hasBody, block) {
if (hasBody)
if (hasBody) {
return block.requestFormat || this.constants.requestFormat;
}
return "query";

@@ -558,4 +566,5 @@ }

paramName = paramName.replace(/^[$]+/, "");
if (!(paramName in msg))
if (!(paramName in msg)) {
return;
}

@@ -570,9 +579,7 @@ var isUrlParam = url.indexOf(":" + paramName) !== -1;

val = encodeURIComponent(msg[paramName]);
}
catch (ex) {
} catch (ex) {
return Util.log("httpSend: Error while converting object to JSON: "
+ (ex.message || ex), "error");
}
}
else if (def.params[paramName] && def.params[paramName].combined) {
} else if (def.params[paramName] && def.params[paramName].combined) {
// Check if this is a combined (search) string.

@@ -584,19 +591,24 @@ val = msg[paramName].split(/[\s\t\r\n]*\+[\s\t\r\n]*/)

.join("+");
} else {
// we don't want to encode ref param values since they're paths
if (paramName !== 'ref') {
val = encodeURIComponent(msg[paramName]);
} else {
val = msg[paramName];
}
}
else
val = encodeURIComponent(msg[paramName]);
} else {
val = msg[paramName];
}
else
val = msg[paramName];
if (isUrlParam) {
url = url.replace(":" + paramName, val);
}
else {
if (format == "json" && def.params[paramName].sendValueAsBody)
} else {
if (format == "json" && def.params[paramName].sendValueAsBody) {
ret.query = val;
else if (format == "json")
} else if (format == "json") {
ret.query[paramName] = val;
else if (format != "raw")
} else if (format != "raw") {
ret.query.push(paramName + "=" + val);
}
}

@@ -645,4 +657,5 @@ });

}
if (!hasBody && query.length)
if (!hasBody && query.length) {
path += "?" + query.join("&");
}

@@ -654,6 +667,7 @@ var headers = {

if (hasBody) {
if (format == "json")
if (format == "json") {
query = JSON.stringify(query);
else if (format != "raw")
} else if (format != "raw") {
query = query.join("&");
}
headers["content-length"] = Buffer.byteLength(query, "utf8");

@@ -706,4 +720,5 @@ headers["content-type"] = format == "json"

var headerLC = header.toLowerCase();
if (self.requestHeaders.indexOf(headerLC) == -1)
if (self.requestHeaders.indexOf(headerLC) == -1) {
return;
}
headers[headerLC] = customHeaders[header];

@@ -714,7 +729,9 @@ });

if (!headers["user-agent"])
if (!headers["user-agent"]) {
headers["user-agent"] = "NodeJS HTTP Client";
}
if (!("accept" in headers))
headers["accept"] = this.acceptUrls[block.url] || this.config.requestMedia || this.constants.requestMedia;
if (!("accept" in headers)) {
headers["accept"] = this.acceptUrls[block.url] || this.config.requestMedia || this.constants.requestMedia;
}

@@ -734,7 +751,9 @@ var options = {

if (this.config.rejectUnauthorized !== undefined)
if (this.config.rejectUnauthorized !== undefined) {
options.rejectUnauthorized = this.config.rejectUnauthorized;
}
if (this.debug)
if (this.debug) {
console.log("REQUEST: ", options);
}

@@ -772,4 +791,5 @@ function httpSendRequest() {

req.on("error", function(e) {
if (self.debug)
if (self.debug) {
console.log("problem with request: " + e.message);
}
callCallback(e.message);

@@ -779,4 +799,5 @@ });

req.on("timeout", function() {
if (self.debug)
if (self.debug) {
console.log("problem with request: timed out");
}
req.abort();

@@ -788,4 +809,5 @@ callCallback(new error.GatewayTimeout());

if (hasBody && query.length) {
if (self.debug)
if (self.debug) {
console.log("REQUEST BODY: " + query + "\n");
}
req.write(query + "\n");

@@ -818,8 +840,11 @@ }

this.sendError = function(err, block, msg, callback) {
if (this.debug)
if (this.debug) {
Util.log(err, block, msg, "error");
if (typeof err == "string")
}
if (typeof err == "string") {
err = new error.InternalServerError(err);
if (callback && typeof(callback) === "function")
}
if (callback && typeof(callback) === "function") {
callback(err);
}
};

@@ -830,4 +855,5 @@

this.httpSend(msg, block, function(err, res) {
if (err)
if (err) {
return self.sendError(err, msg, null, callback);
}

@@ -837,10 +863,11 @@ var ret;

var contentType = res.headers["content-type"];
if (contentType && contentType.indexOf("application/json") !== -1)
if (contentType && contentType.indexOf("application/json") !== -1) {
ret = res.data && JSON.parse(res.data);
else
} else {
ret = {data: res.data};
}
catch (ex) {
if (callback)
}
} catch (ex) {
if (callback) {
callback(new error.InternalServerError(ex.message), res);
}
return;

@@ -859,6 +886,7 @@ }

if (callback)
if (callback) {
callback(null, ret);
}
});
}
}).call(Client.prototype);

@@ -26,4 +26,5 @@ /** section: github

for (var prop in src) {
if (!noOverwrite || typeof dest[prop] == "undefined")
if (!noOverwrite || typeof dest[prop] == "undefined") {
dest[prop] = src[prop];
}
}

@@ -61,4 +62,5 @@ return dest;

});
if (upper)
if (upper) {
return str;
}
return str.charAt(0).toLowerCase() + str.substr(1);

@@ -131,4 +133,5 @@ };

var level = levels[lastArg] ? args.pop() : "info";
if (!args.length)
if (!args.length) {
return;
}

@@ -135,0 +138,0 @@ var msg = args.map(function(arg) {

{
"name": "github",
"version": "6.0.2",
"version": "6.0.3",
"description": "NodeJS wrapper for the GitHub API",

@@ -34,3 +34,4 @@ "author": "Mike de Boer <info@mikedeboer.nl>",

"devDependencies": {
"mocha": "~1.13.0"
"mocha": "~1.13.0",
"mustache": "^2.2.1"
},

@@ -51,3 +52,3 @@ "main": "lib",

"name": "node-github",
"version": "6.0.2",
"version": "6.0.3",
"template": {

@@ -54,0 +55,0 @@ "withCompare": true

Sorry, the diff of this file is too big to display

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