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

cimpress-fulfiller-identity

Package Overview
Dependencies
Maintainers
3
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cimpress-fulfiller-identity - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

17

lib/aws_xray_mock.js

@@ -1,15 +0,12 @@

"use strict";
module.exports = {
captureAsyncFunc: function captureAsyncFunc(arg, cb) {
captureAsyncFunc: function (arg, cb) {
cb({
addAnnotation: function addAnnotation() {},
addMetadata: function addMetadata() {},
addError: function addError() {},
close: function close() {}
addAnnotation: function () {},
addMetadata: function () {},
addError: function () {},
close: function () {}
});
}, captureAWS: function captureAWS(arg) {
}, captureAWS: function (arg) {
return arg;
}
};
//# sourceMappingURL=aws_xray_mock.js.map
};

@@ -1,22 +0,3 @@

"use strict";
class FulfillerNotFoundError extends Error {}
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var FulfillerNotFoundError = function (_Error) {
_inherits(FulfillerNotFoundError, _Error);
function FulfillerNotFoundError() {
_classCallCheck(this, FulfillerNotFoundError);
return _possibleConstructorReturn(this, (FulfillerNotFoundError.__proto__ || Object.getPrototypeOf(FulfillerNotFoundError)).apply(this, arguments));
}
return FulfillerNotFoundError;
}(Error);
module.exports = FulfillerNotFoundError;
//# sourceMappingURL=fulfiller_not_found_error.js.map
module.exports = FulfillerNotFoundError;

@@ -1,117 +0,71 @@

"use strict";
const FulfillerIdentityProxy = require("./fulfiller_identity_proxy");
const Fulfiller = require("./fulfiller");
const FulfillerNotFoundError = require("./errors/fulfiller_not_found_error");
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
const AWSXRayMock = require('./aws_xray_mock');
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var FulfillerIdentityProxy = require("./fulfiller_identity_proxy");
var Fulfiller = require("./fulfiller");
var FulfillerNotFoundError = require("./errors/fulfiller_not_found_error");
var AWSXRayMock = require('./aws_xray_mock');
/**
* The main class exposing client methods.
*/
class FulfillerIdentityClient {
var FulfillerIdentityClient = function () {
function FulfillerIdentityClient(authorization, options) {
_classCallCheck(this, FulfillerIdentityClient);
constructor(authorization, options) {
if (typeof authorization === "undefined") {
this.authorizer = { getAuthorization: function getAuthorization() {
return Promise.resolve("");
} };
this.authorizer = { getAuthorization: () => Promise.resolve("") };
} else if (typeof authorization === "string") {
this.authorizer = { getAuthorization: function getAuthorization() {
return Promise.resolve(authorization.startsWith('Bearer ') ? authorization : 'Bearer ' + authorization);
} };
this.authorizer = { getAuthorization: () => Promise.resolve(authorization.startsWith('Bearer ') ? authorization : 'Bearer ' + authorization) };
} else if (typeof authorization === "function") {
this.authorizer = { getAuthorization: function getAuthorization() {
return Promise.resolve(authorization());
} };
this.authorizer = { getAuthorization: () => Promise.resolve(authorization()) };
} else {
throw new Error("The authorization should be either a string, a function that returns a string, or a function that returns a Promise");
}
var url = options && options.url ? options.url : "fulfilleridentity.trdlnk.cimpress.io";
var awsXRay = options && options.AWSXRay ? options.AWSXRay : AWSXRayMock;
let url = options && options.url ? options.url : "fulfilleridentity.trdlnk.cimpress.io";
let awsXRay = options && options.AWSXRay ? options.AWSXRay : AWSXRayMock;
this.fulfillerIdentityProxy = new FulfillerIdentityProxy(url, this.authorizer, awsXRay);
}
_createClass(FulfillerIdentityClient, [{
key: "getUrl",
value: function getUrl() {
return this.fulfillerIdentityProxy.url;
}
getUrl() {
return this.fulfillerIdentityProxy.url;
}
/**
* Returns an array of fulfiller objects that meet the criteria expesses in options
* @param options Criteria for the query
*/
/**
* Returns an array of fulfiller objects that meet the criteria expesses in options
* @param options Criteria for the query
*/
getFulfillers(options) {
let showArchived = options && options.showArchived || false;
let filterByName = options ? options.fulfillerName : null;
let noCache = options && options.noCache || false;
}, {
key: "getFulfillers",
value: function getFulfillers(options) {
var showArchived = options && options.showArchived || false;
var filterByName = options ? options.fulfillerName : null;
var noCache = options && options.noCache || false;
return this.fulfillerIdentityProxy.callFulfillerIdentity("GET").then(parsedBody => parsedBody.map(f => new Fulfiller(f.fulfillerId, f.internalFulfillerId, f.name, f.email, f.phone, f.language, f.links)), err => Promise.reject(new Error("Unable to get fulfillers: " + err.message)));
}
return this.fulfillerIdentityProxy.callFulfillerIdentity("GET").then(function (parsedBody) {
return parsedBody.map(function (f) {
return new Fulfiller(f.fulfillerId, f.internalFulfillerId, f.name, f.email, f.phone, f.language, f.links);
});
}, function (err) {
return Promise.reject(new Error("Unable to get fulfillers: " + err.message));
});
}
/**
* Fetches the fulfiller based on the fulfiller id.
* @param fulfillerId One of the fulfiller identifiers
* @param options
*/
getFulfiller(fulfillerId, options) {
let noCache = options && options.noCache || false;
/**
* Fetches the fulfiller based on the fulfiller id.
* @param fulfillerId One of the fulfiller identifiers
* @param options
*/
return this.fulfillerIdentityProxy.callFulfillerIdentity("GET", { fulfillerId: fulfillerId }).then(f => new Fulfiller(f.fulfillerId, f.internalFulfillerId, f.name, f.email, f.phone, f.language, f.links), err => err.response && err.response.status === 404 ? Promise.reject(new FulfillerNotFoundError(`Fulfiller ${fulfillerId} does not exits`)) : Promise.reject(new Error("Unable to get fulfiller: " + err.message)));
}
}, {
key: "getFulfiller",
value: function getFulfiller(fulfillerId, options) {
var noCache = options && options.noCache || false;
return this.fulfillerIdentityProxy.callFulfillerIdentity("GET", { fulfillerId: fulfillerId }).then(function (f) {
return new Fulfiller(f.fulfillerId, f.internalFulfillerId, f.name, f.email, f.phone, f.language, f.links);
}, function (err) {
return err.response && err.response.status === 404 ? Promise.reject(new FulfillerNotFoundError("Fulfiller " + fulfillerId + " does not exits")) : Promise.reject(new Error("Unable to get fulfiller: " + err.message));
});
/**
* Saves changes made to a fulfiller object.
* @param fulfiller Fufiller object, either retrieved via getFulfiller or getFulfillers or using new Fulfiller statement
*/
saveFulfiller(fulfiller) {
if (fulfiller.fulfillerId || fulfiller.internalFulfillerId) {
return this.fulfillerIdentityProxy.callFulfillerIdentity("PUT", {
fulfillerId: fulfiller.fulfillerId || fulfiller.internalFulfillerId,
data: fulfiller
}).then(f => Promise.resolve(), err => Promise.reject(new Error("Unable to update fulfiller: " + err.message)));
} else {
return this.fulfillerIdentityProxy.callFulfillerIdentity("POST", { data: fulfiller }).then(f => Promise.resolve(), err => Promise.reject(new Error("Unable to update fulfiller: " + err.message)));
}
}
/**
* Saves changes made to a fulfiller object.
* @param fulfiller Fufiller object, either retrieved via getFulfiller or getFulfillers or using new Fulfiller statement
*/
}
}, {
key: "saveFulfiller",
value: function saveFulfiller(fulfiller) {
if (fulfiller.fulfillerId || fulfiller.internalFulfillerId) {
return this.fulfillerIdentityProxy.callFulfillerIdentity("PUT", {
fulfillerId: fulfiller.fulfillerId || fulfiller.internalFulfillerId,
data: fulfiller
}).then(function (f) {
return Promise.resolve();
}, function (err) {
return Promise.reject(new Error("Unable to update fulfiller: " + err.message));
});
} else {
return this.fulfillerIdentityProxy.callFulfillerIdentity("POST", { data: fulfiller }).then(function (f) {
return Promise.resolve();
}, function (err) {
return Promise.reject(new Error("Unable to update fulfiller: " + err.message));
});
}
}
}]);
return FulfillerIdentityClient;
}();
module.exports = FulfillerIdentityClient;
//# sourceMappingURL=fulfiller_identity_client.js.map
module.exports = FulfillerIdentityClient;
'use strict';
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
const axios = require('axios');
const AWSXRayMock = require("./aws_xray_mock");
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
const schemeRegex = /\w+:\/\//;
var axios = require('axios');
var AWSXRayMock = require("./aws_xray_mock");
class FulfillerIdentityProxy {
var schemeRegex = /\w+:\/\//;
var FulfillerIdentityProxy = function () {
function FulfillerIdentityProxy(url, authenticator, xray) {
_classCallCheck(this, FulfillerIdentityProxy);
constructor(url, authenticator, xray) {
if (schemeRegex.test(url)) {

@@ -20,53 +15,44 @@ throw new Error("The URL cannot contain a scheme.");

this.apiUrl = url;
this.authenticator = authenticator ? authenticator : { getAuthorization: function getAuthorization() {
return Promise.resolve();
} };
this.authenticator = authenticator ? authenticator : { getAuthorization: () => Promise.resolve() };
this.xray = xray ? xray : AWSXRayMock;
}
_createClass(FulfillerIdentityProxy, [{
key: 'callFulfillerIdentity',
value: function callFulfillerIdentity(method, callOptions) {
var self = this;
return new Promise(function (resolve, reject) {
self.xray.captureAsyncFunc('FulfillerIdentity.getFulfillerById', function (subsegment) {
self.authenticator.getAuthorization().then(function (authorization) {
var options = {
timeout: 3000,
method: method,
headers: {
'Authorization': authorization,
'Content-Type': 'application/json'
}
};
if (callOptions && callOptions.data) {
options.data = callOptions.data;
get url() {
return `https://${this.apiUrl}`;
}
callFulfillerIdentity(method, callOptions) {
let self = this;
return new Promise((resolve, reject) => {
self.xray.captureAsyncFunc('FulfillerIdentity.getFulfillerById', function (subsegment) {
self.authenticator.getAuthorization().then(authorization => {
let options = {
timeout: 3000,
method: method,
headers: {
'Authorization': authorization,
'Content-Type': 'application/json'
}
if (callOptions && callOptions.fulfillerId) {
subsegment.addAnnotation("FulfillerId", callOptions.fulfillerId);
}
options.url = callOptions && callOptions.fulfillerId ? self.url + '/v1/fulfillers/' + callOptions.fulfillerId : self.url + '/v1/fulfillers';
axios(options).then(function (res) {
subsegment.addMetadata("response", res.data);
subsegment.close();
resolve(res.data);
}).catch(function (err) {
subsegment.close(err);
reject(err);
});
};
if (callOptions && callOptions.data) {
options.data = callOptions.data;
}
if (callOptions && callOptions.fulfillerId) {
subsegment.addAnnotation("FulfillerId", callOptions.fulfillerId);
}
options.url = callOptions && callOptions.fulfillerId ? `${self.url}/v1/fulfillers/${callOptions.fulfillerId}` : `${self.url}/v1/fulfillers`;
axios(options).then(function (res) {
subsegment.addMetadata("response", res.data);
subsegment.close();
resolve(res.data);
}).catch(function (err) {
subsegment.close(err);
reject(err);
});
});
});
}
}, {
key: 'url',
get: function get() {
return 'https://' + this.apiUrl;
}
}]);
});
}
}
return FulfillerIdentityProxy;
}();
module.exports = FulfillerIdentityProxy;
//# sourceMappingURL=fulfiller_identity_proxy.js.map
module.exports = FulfillerIdentityProxy;

@@ -1,14 +0,7 @@

"use strict";
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**
* Objects of fulfiller class are either required or returned by the methods of the FulfillerIdentityClient.
*/
var Fulfiller = function () {
function Fulfiller(fulfillerId, internalFulfillerId, name, email, phone, language, links) {
_classCallCheck(this, Fulfiller);
class Fulfiller {
constructor(fulfillerId, internalFulfillerId, name, email, phone, language, links) {
this._fulfillerId = fulfillerId;

@@ -28,149 +21,116 @@ this._internalFulfillerId = internalFulfillerId;

*/
get fulfillerId() {
return this._fulfillerId;
}
/**
* Returns the internal fulfiller id.
* @returns {*}
*/
get internalFulfillerId() {
return this._internalFulfillerId;
}
_createClass(Fulfiller, [{
key: "getSecurityGroupUrl",
value: function getSecurityGroupUrl() {
return this._links && this._links.fulfillerCoamAdminGroup ? this._links.fulfillerCoamAdminGroup.href : null;
}
}, {
key: "getLogoUrl",
value: function getLogoUrl() {
return this._links && this._links.fulfillerLogo ? this._links.fulfillerLogo.href : null;
}
}, {
key: "toJSON",
value: function toJSON() {
return {
fulfillerId: this.fulfillerId,
internalFulfillerId: this.internalFulfillerId,
name: this.name,
email: this.email,
phone: this.phone,
language: this.language,
archived: this.archived
};
}
}, {
key: "fulfillerId",
get: function get() {
return this._fulfillerId;
}
/**
* Returns the name of the fulfiller.
* @returns {*}
*/
get name() {
return this._name;
}
/**
* Returns the internal fulfiller id.
* @returns {*}
*/
/**
* Changes the name of the fulfiller in the object.
* @param value
*/
set name(value) {
this._name = value;
}
}, {
key: "internalFulfillerId",
get: function get() {
return this._internalFulfillerId;
}
/**
* Returns the fufliller contact point email address.
* @returns {*}
*/
get email() {
return this._email;
}
/**
* Returns the name of the fulfiller.
* @returns {*}
*/
/**
* Sets the fuliller contact point email address in the object.
* @param value
*/
set email(value) {
this._email = value;
}
}, {
key: "name",
get: function get() {
return this._name;
}
/**
* Gets the fulfiller contact point phone number.
* @returns {*}
*/
get phone() {
return this._phone;
}
/**
* Changes the name of the fulfiller in the object.
* @param value
*/
,
set: function set(value) {
this._name = value;
}
/**
* Sets the fulfiller contact point phone number in the object.
* @param value
*/
set phone(value) {
this._phone = value;
}
/**
* Returns the fufliller contact point email address.
* @returns {*}
*/
/***
* Gets the fulfiller perferred language
* @returns {*}
*/
get language() {
return this._language;
}
}, {
key: "email",
get: function get() {
return this._email;
}
/**
* Sets the fulfiller preferred language in the object.
* @param value
*/
set language(value) {
this._language = value;
}
/**
* Sets the fuliller contact point email address in the object.
* @param value
*/
,
set: function set(value) {
this._email = value;
}
/**
* Gets the flag indicating whether the fulfiller is archived.
* @returns {boolean|*}
*/
get archived() {
return this._archived;
}
/**
* Gets the fulfiller contact point phone number.
* @returns {*}
*/
/**
* Sets the fulfiller as archived in the object.
* @param {boolean|*} value
*/
set archived(value) {
this._archived = value;
}
}, {
key: "phone",
get: function get() {
return this._phone;
}
getSecurityGroupUrl() {
return this._links && this._links.fulfillerCoamAdminGroup ? this._links.fulfillerCoamAdminGroup.href : null;
}
/**
* Sets the fulfiller contact point phone number in the object.
* @param value
*/
,
set: function set(value) {
this._phone = value;
}
getLogoUrl() {
return this._links && this._links.fulfillerLogo ? this._links.fulfillerLogo.href : null;
}
/***
* Gets the fulfiller perferred language
* @returns {*}
*/
toJSON() {
return {
fulfillerId: this.fulfillerId,
internalFulfillerId: this.internalFulfillerId,
name: this.name,
email: this.email,
phone: this.phone,
language: this.language,
archived: this.archived
};
}
}, {
key: "language",
get: function get() {
return this._language;
}
}
/**
* Sets the fulfiller preferred language in the object.
* @param value
*/
,
set: function set(value) {
this._language = value;
}
/**
* Gets the flag indicating whether the fulfiller is archived.
* @returns {boolean|*}
*/
}, {
key: "archived",
get: function get() {
return this._archived;
}
/**
* Sets the fulfiller as archived in the object.
* @param {boolean|*} value
*/
,
set: function set(value) {
this._archived = value;
}
}]);
return Fulfiller;
}();
module.exports = Fulfiller;
//# sourceMappingURL=fulfiller.js.map
module.exports = Fulfiller;

@@ -1,6 +0,3 @@

"use strict";
const FulfillerIdentityClient = require("./fulfiller_identity_client");
var FulfillerIdentityClient = require("./fulfiller_identity_client");
module.exports = FulfillerIdentityClient;
//# sourceMappingURL=index.js.map
module.exports = FulfillerIdentityClient;
{
"name": "cimpress-fulfiller-identity",
"version": "0.1.2",
"version": "0.1.3",
"description": "Thin client library for Cimpress' Fulfiller Identity service",
"main": "./lib/index.js",
"scripts": {
"test": "grunt test"
"test": "grunt test",
"build": "babel src -d lib",
"prepublish": "npm run build"
},

@@ -31,3 +33,3 @@ "repository": {

"devDependencies": {
"babel-core": "^6.26.0",
"babel-cli": "^6.26.0",
"babel-plugin-istanbul": "^4.1.4",

@@ -34,0 +36,0 @@ "babel-preset-env": "^1.6.1",

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