New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

checklist-ninja

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

checklist-ninja - npm Package Compare versions

Comparing version 0.0.0 to 0.1.0

test/account.spec.js

155

index.js

@@ -9,5 +9,13 @@ /*jshint node: true */

merge = require('lodash.merge'),
config = {};
url = require('url'),
config = { host: baseURI };
// prepare payloads
function parsePayload(input) {
if (typeof input === "object") { return input; }
var obj = { title: input };
return obj;
}
this.config = function (config) {

@@ -19,56 +27,143 @@ if (config) { this.config = merge(this.config,config); }

this.sign = function (method, resource, date) {
var str = this.config.secret + '\n' + date + '\n' + method + '\n' + resource + '\n',
shasum = crypto.createHash('sha1'); // this may be okay at higher scope
shasum.update(str);
return shasum.digest('hex');
};
var parsedUrl = url.parse(resource);
var str = this.config.secret + '\n' + date + '\n' + method + '\n' + parsedUrl.pathname + '\n',
shasum = crypto.createHash('sha1'); // this may be okay at higher scope
shasum.update(str);
return shasum.digest('hex');
};
this.date = function () { return new Date().toUTCString(); };
this.date = function () {
return new Date().toUTCString();
};
this.raw = function (method, endpoint, payload, callback) {
if (arguments.length === 3) { callback = payload; } // allow for optional payload
var date = this.date(),
sig = this.sign(method, endpoint, date),
headers = {
'authorization': 'ChecklistNinja ' + this.config.pubkey + ':' + sig,
'date' : date
},
options = { url: baseURI + endpoint, method: method, headers: headers };
request(options)
.pipe(json.parse('*')) // parse everything for now
.pipe(es.mapSync(function (data){
callback(undefined,data);
}));
};
if (arguments.length === 3) {
callback = payload;
}
var date = this.date(),
sig = this.sign(method, endpoint, date),
headers = {
'authorization': 'ChecklistNinja ' + this.config.pubkey + ':' + sig,
'date' : date
},
options = { url: this.config.host + endpoint, method: method, headers: headers };
if (arguments.length === 4) {
options.body = JSON.stringify(payload);
}
request(options, function (error, response, body) {
if (!error) {
if (response.statusCode == 204) {
return callback(undefined, response.statusCode, null);
}
return callback(undefined, response.statusCode, JSON.parse(body));
}
return callback(error, null, null);
});
};
// Sugar
this.get = function (endpoint, callback) {
this.raw('GET',endpoint,callback);
this.raw('GET', endpoint, callback);
};
this.post = function (endpoint, payload, callback) {
this.raw('POST',endpoint, payload, callback);
this.raw('POST', endpoint, payload, callback);
};
this.put = function (endpoint, payload, callback) {
this.raw('PUT',endpoint, payload, callback);
this.raw('PUT', endpoint, payload, callback);
};
this.patch = function (endpoint, payload, callback) {
this.raw('PATCH',endpoint, payload, callback);
this.raw('PATCH', endpoint, payload, callback);
};
this.delete = function (endpoint, callback) {
this.raw('DELETE',endpoint,callback);
this.raw('DELETE', endpoint, callback);
};
this.getAccount = function(accountId, callback) {
this.getOrFail('/accounts/' + accountId, 'Could not load account.', callback);
};
this.findAccount = function(email, callback) {
var endpoint = '/accounts?email=' + encodeURIComponent(email);
this.getOrFail(endpoint, 'Could not load account.', callback);
};
this.getChecklists = function(callback) {
this.getOrFail('/checklists', 'Could not load checklists.', callback);
};
this.getChecklist = function(checklistId, callback) {
this.getOrFail('/checklists/' + checklistId, 'Could not load checklist.', callback);
};
this.getChecklistEvents = function(checklistId, callback) {
this.getOrFail('/checklists/' + checklistId + '/events', 'Could not load checklist events.', callback);
};
this.getChecklistWebhooks = function(checklistId, callback) {
this.getOrFail('/checklists/' + checklistId + '/webhooks', 'Could not load checklist webhooks.', callback);
};
this.createChecklist = function(title, callback) {
var payload = parsePayload(title);
this.put('/checklists', payload, function(err, code, data) {
if (!err && code == 201) {
return callback(null, data);
}
callback('Could not create checklist.');
});
};
this.createItem = function(checklistId, displayText, parent, position, callback) {
// TODO: Ensure position is serialized as a number.
var payload = {
'display_text': displayText,
'parent': parent,
'position': position
};
this.put('/checklists/' + checklistId + '/items', payload, function(err, code, data) {
if (!err && code == 201) {
return callback(null, data);
}
callback('Could not create checklist item.');
});
};
this.createGroup = function(checklistId, label, parent, position, callback) {
// TODO: Ensure position is serialized as a number.
var payload = {
'label': label,
'parent': parent,
'position': position
};
this.put('/checklists/' + checklistId + '/groups', payload, function(err, code, data) {
if (!err && code == 201) {
return callback(null, data);
}
callback('Could not create checklist group.');
});
};
this.getOrFail = function(endpoint, errmessage, callback) {
this.get(endpoint, function(err, code, data) {
if (!err && code == 200) {
return callback(null, data);
}
callback(errmessage);
});
};
{
"name": "checklist-ninja",
"version": "0.0.0",
"version": "0.1.0",
"description": "A Node.js client for the http://checklist.ninja API",
"main": "index.js",
"scripts": {
"test": "npm run unit",
"unit": "mocha -R spec"
"test": "npm run unit && npm run ci-cov",
"unit": "mocha -R spec",
"cov-report": " mocha -r blanket -R html-cov > test.html ",
"ci-cov": " mocha -r blanket -R travis-cov"
},
"config": {
"blanket": {
"pattern": "index.js",
"data-cover-never": "node_modules"
},
"travis-cov": {
"threshold": 95
}
},
"keywords": [
"checklist",
"checklist",
"ninja",

@@ -17,3 +27,15 @@ "devops"

"author": "Mark Wilkerson <mark@segfawlt.net>",
"contributors": [{
"name": "Nick Gerakines",
"email": "nick@gerakines.net",
"url": "http://ngerakines.me/"
}],
"license": "MIT",
"bugs": {
"url" : "http://github.com/markhuge/node-checklist-ninja/issues"
},
"repository": {
"type" : "git",
"url" : "http://github.com/markhuge/node-checklist-ninja.git"
},
"dependencies": {

@@ -20,0 +42,0 @@ "JSONStream": "^0.8.4",

18

README.md

@@ -1,16 +0,10 @@

# Hi there. Don't use this yet
# node-checklist-ninja
The checklist.ninja API is still in a bit of flux. I'm publishing this early to facilitate some testing and collaboration.
node-checklist-ninja
====================
> A Node.js module for interacting with the https://checklist.ninja API
A word of caution: This library is being actively developed. It was originally made to facilitate testing and collaboration, but this library's interfaces as well as the Checklist Ninja API may change.
## Install
`npm install checklist-ninja`
$ npm install checklist-ninja

@@ -27,6 +21,6 @@ ## Usage

ninja.createList("My new list", function(err, listID) {
console.log("My new list: ", listID)
ninja.createChecklist("My new list", function(err, checklist) {
console.log("My new list: ", checklist)
});
```
```

Sorry, the diff of this file is not supported yet

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