appbase-js
Advanced tools
Comparing version 2.0.0 to 2.1.0
@@ -55,9 +55,14 @@ "use strict"; | ||
var headers = { | ||
"Accept": "application/json", | ||
"Content-Type": "application/json" | ||
}; | ||
if (this.client.credentials) { | ||
headers.Authorization = "Basic " + (0, _helpers.btoa)(this.client.credentials); | ||
} | ||
fetch(this.client.protocol + "//" + this.client.url + "/" + this.client.appname + "/" + this.path + "?" + _querystring2.default.stringify(this.params), { | ||
method: this.method, | ||
headers: { | ||
"Authorization": "Basic " + (0, _helpers.btoa)(this.client.credentials), | ||
"Accept": "application/json", | ||
"Content-Type": "application/json" | ||
}, | ||
headers: headers, | ||
body: this.body | ||
@@ -64,0 +69,0 @@ }).then(function (res) { |
@@ -11,2 +11,3 @@ "use strict"; | ||
exports.btoa = btoa; | ||
exports.isAppbase = isAppbase; | ||
function validate(object, fields) { | ||
@@ -79,2 +80,10 @@ var invalid = []; | ||
return output; | ||
} | ||
function isAppbase(client) { | ||
return contains(client.url, "scalr.api.appbase.io"); | ||
} | ||
function contains(string, substring) { | ||
return string.indexOf(substring) !== -1; | ||
} |
@@ -71,2 +71,4 @@ "use strict"; | ||
var _helpers = require("./helpers"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -88,3 +90,3 @@ | ||
this.protocol = parsedUrl.protocol; | ||
this.credentials = parsedUrl.auth; | ||
this.credentials = parsedUrl.auth || null; | ||
this.appname = args.appname || args.app; | ||
@@ -100,6 +102,2 @@ | ||
if (typeof args.username === "string" && args.username !== "" && typeof args.password === "string" && args.password !== "") { | ||
this.credentials = args.username + ":" + args.password; | ||
} | ||
// credentials can be provided as a part of the URL, as username, password args or | ||
@@ -109,5 +107,7 @@ // as a credentials argument directly | ||
this.credentials = args.credentials; | ||
} else if (typeof args.username === "string" && args.username !== "" && typeof args.password === "string" && args.password !== "") { | ||
this.credentials = args.username + ":" + args.password; | ||
} | ||
if (typeof this.credentials !== "string" || this.credentials === "") { | ||
if ((0, _helpers.isAppbase)(this) && this.credentials === null) { | ||
throw new Error("Authentication information is not present. Did you add credentials?"); | ||
@@ -114,0 +114,0 @@ } |
@@ -62,6 +62,9 @@ "use strict"; | ||
method: this.method, | ||
body: this.body, | ||
authorization: "Basic " + new Buffer(this.client.credentials).toString("base64") | ||
body: this.body | ||
}; | ||
if (this.client.credentials) { | ||
this.request.authorization = "Basic " + new Buffer(this.client.credentials).toString("base64"); | ||
} | ||
this.resultStream = new _stream2.default(); | ||
@@ -68,0 +71,0 @@ this.resultStream.readable = true; |
{ | ||
"name": "appbase-js", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "Appbase.io streaming client lib for Javascript", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 2 instances in 1 package
349670
938
2