Socket
Socket
Sign inDemoInstall

prostore.rest-client

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prostore.rest-client - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

.eslintignore

25

index.js

@@ -12,3 +12,3 @@ 'use strict';

* @class ApiClient
* @param {object} options - options
* @param {object} options - options
* @param {string} options.url - store URL including schema

@@ -19,3 +19,3 @@ * @param {string} options.userId - ProStore user id (12-byte BSON ObjectId, hex-encoded)

*/
var ApiClient = module.exports = exports = function(options) {
var ApiClient = module.exports = exports = function (options) {
if (!(this instanceof ApiClient))

@@ -35,3 +35,3 @@ return new ApiClient(options);

Object.defineProperty(ApiClient.prototype, 'baseUrl', {
get: function() {
get: function () {
return this.url + '/api';

@@ -58,7 +58,7 @@ }

Object.defineProperty(ApiClient.prototype, 'headers', {
get: function() {
get: function () {
var nonce = randomstring()
, token = createHash('sha256')
.update(nonce + ':' + this.privateToken, 'utf-8')
.digest('hex');
.update(nonce + ':' + this.privateToken, 'utf-8')
.digest('hex');
return {

@@ -79,3 +79,3 @@ 'ProStore-Auth-UserId': this.userId,

*/
ApiClient.prototype.mkurl = function(endpoint) {
ApiClient.prototype.mkurl = function (endpoint) {
return this.baseUrl + '/' + endpoint.replace(/^\//, '');

@@ -112,3 +112,3 @@ };

*/
ApiClient.prototype.request = function(method, endpoint) {
ApiClient.prototype.request = function (method, endpoint) {
return request.defaults({

@@ -131,4 +131,4 @@ method: method ? method.toLowerCase() : undefined,

*/
['get', 'post', 'put', 'delete'].forEach(function(method) {
ApiClient.prototype[method] = function(endpoint, options, cb) {
['get', 'post', 'put', 'delete'].forEach(function (method) {
ApiClient.prototype[method] = function (endpoint, options, cb) {
if (typeof options == 'function') {

@@ -139,4 +139,3 @@ cb = options;

var r = this.request(method, endpoint);
r(options, function(err, res, data) {
/* istanbul ignore if */
r(options, function (err, res, data) {
if (err) return cb(err);

@@ -152,4 +151,4 @@ if (res.statusCode == 401)

cb(null, data);
})
});
};
});
{
"name": "prostore.rest-client",
"version": "0.0.2",
"version": "0.0.3",
"description": "ProStore REST API Client",
"main": "index.js",
"dependencies": {

@@ -10,3 +11,12 @@ "request": "*",

},
"main": "index.js",
"devDependencies": {
"eslint": "*",
"pre-commit": "*"
},
"scripts": {
"pretest": "eslint ."
},
"pre-commit": [
"test"
],
"keywords": [

@@ -13,0 +23,0 @@ "prostore",

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