Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

authbase

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

authbase - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

lib/client.js

84

lib/index.js

@@ -1,80 +0,6 @@

var request = require('superagent'),
q = require('q');
exports.url = 'https://api.authbase.io/v1';
function AuthBase(appId, appSecret) {
function toError(status, message) {
var json;
try { json = JSON.parse(message); message = undefined; } catch(ex) { }
return {
status: status,
message: message,
json: json
}
}
function exceptionToError(ex) {
return toError(null, ex.message);
}
function promisify(callback) {
var deferred = q.defer();
callback(function(err, value) {
if (err) deferred.reject(err);
else deferred.resolve(value);
});
return deferred.promise;
}
function completable(callback, promised) {
return function(error, user) {
// call the callback if it was provided
if (typeof callback === 'function') {
if (error) callback(error);
else callback(undefined, user);
}
// fulfill the promise
if (error) promised(error);
else promised(undefined, user);
}
}
function responseHandler(complete) {
return function(err, res) {
try {
if (err) complete(exceptionToError(err));
else if (res.error) complete(toError(res.error.status, res.error.text));
else complete(undefined, res.body);
} catch(ex) {
complete(exceptionToError(ex));
}
}
}
function api(method, endpoint) {
return function(user, callback) {
return promisify(function(promised) {
method(AuthBase.url + endpoint)
.set('X-App-Id', appId)
.set('X-App-Secret', appSecret)
.send(user)
.buffer()
.end(responseHandler(completable(callback, promised)));
});
}
}
// public API
return {
register: api(request.post, '/register'),
update: api(request.post, '/update'),
unregister: api(request.post, '/unregister'),
verify: api(request.get, '/verify')
}
}
// static override of the AuthBase url
AuthBase.url = 'https://api.authbase.io/v1';
module.exports = AuthBase;
module.exports = {
Client: require('./client'),
Router: require('./router')
};
{
"name": "authbase",
"version": "0.0.3",
"description": "AuthBase API Client",
"version": "0.0.4",
"description": "AuthBase API Client and Router",
"main": "./lib",

@@ -6,0 +6,0 @@ "scripts": {

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