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

bitballoon

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bitballoon - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

lib/access-token.js

40

lib/client.js

@@ -26,3 +26,4 @@ var base64 = require('base64-js'),

Deploy: require("./deploy").Deploy,
DnsZone: require("./dns-zone").DnsZone
DnsZone: require("./dns-zone").DnsZone,
AccessToken: require("./access-token").AccessToken
};

@@ -34,2 +35,6 @@

var prepareBody = function(body, headers) {
return typeof(body) == "string" ? body : (headers['Content-Type'] == "application/json" ? JSON.stringify(body) : body);
};
Client.prototype = {

@@ -139,2 +144,8 @@ isAuthorized: function() { return !(this.access_token == null); },

accessToken: function(id, cb) { this.element({model: Client.models.AccessToken, id: id}, cb); },
createAccessToken: function(attributes, cb) {
this.create({model: Client.models.AccessToken, attributes: attributes}, cb);
},
collection: function(options, pagination, cb) {

@@ -210,6 +221,12 @@ if (cb === undefined) { cb = pagination; pagination = {}}

headers = options.headers || {},
retries = options.retries || 3;
retries = options.retries ? options.retries : options.retries === 0 ? 0 : 3,
body = null;
headers['Content-Type'] = options.contentType || "application/json";
headers['Content-Length'] = options.body ? options.body.length : 0;
if (options.body) {
body = prepareBody(options.body, headers);
}
headers['Content-Length'] = body ? body.length : 0;

@@ -219,3 +236,3 @@ if (this.access_token && !options.auth) {

}
var requestOptions = {

@@ -249,3 +266,3 @@ method: (options.type || "get").toLowerCase(),

requestOptions.method === "delete") &&
(retries > 0 && res.statusCode !== 422)) {
(retries > 0 && res.statusCode !== 422 && res.statusCode !== 404)) {
options.retries = retries - 1;

@@ -261,3 +278,6 @@ setTimeout(function() { client.request(options, cb); }, 500);

request.on("error", function(err) {
if (requestOptions.method == "get" || requestOptions.method == "put" || requestOptions.method == "delete" && retries > 0) {
if ((requestOptions.method == "get" ||
requestOptions.method == "put" ||
requestOptions.method == "delete") &&
retries > 0) {
options.retries = retries - 1;

@@ -270,8 +290,4 @@ setTimeout(function() { client.request(options, cb); }, 500);

if (options.body) {
request.write(
typeof(options.body) == "string" ?
options.body :
headers['Content-Type'] == "application/json" ? JSON.stringify(options.body) : options.body
);
if (body) {
request.write(body);
}

@@ -278,0 +294,0 @@ request.end();

@@ -5,3 +5,3 @@ {

"description": "BitBalloon API client",
"version": "0.1.1",
"version": "0.1.2",
"repository": {

@@ -8,0 +8,0 @@ "url": ""

@@ -530,2 +530,27 @@ BitBalloon Node Client

});
```
Access Tokens
=============
Resellers can use the node client to create and revoke access tokens on behalf of their users. To use any of these methods your OAuth access token must belong to a reseller admin user.
Creating an access token:
```js
client.createAccessToken({user: {email: "test@example.com", uid: "1234"}}, function(err, accessToken) {
// accessToken.access_token
});
```
The user must have either an email or a uid (or both) as a unique identifier. If the user doesn't exist, a new user will be created on the fly.
Deleting an access token:
```js
client.accessToken("token-string", function(err, accessToken) {
accessToken.destroy(function(err) {
console.log("Access token revoked");
});
});
```
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