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

cimpress-customizr

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cimpress-customizr - npm Package Compare versions

Comparing version 1.1.13 to 1.2.0

4

CHANGELOG.md

@@ -7,2 +7,6 @@ # Changelog

## [1.2.0] - 2021.05.19
### Changed
- Making it session aware.
## [1.1.11] - 2019.09.11

@@ -9,0 +13,0 @@ ### Changed

101

lib/CustomizrClient.js

@@ -29,2 +29,3 @@ "use strict";

var DEFAULT_BASE_URL = 'https://customizr.at.cimpress.io';
var SESSION_PROXY_URL = 'https://sessions.cimpress.io';

@@ -59,11 +60,21 @@ var CustomizrClient =

}, {
key: "__getProxyUrl",
value: function __getProxyUrl(url, method) {
return "".concat((0, _pope.pope)('/v1/sessions/proxy?proxyUrl={{url}}&proxyUrlMethod={{method}}', {
url: url,
method: method
}));
}
}, {
key: "__getAxiosInstance",
value: function __getAxiosInstance(accessToken) {
value: function __getAxiosInstance(accessToken, sessionId) {
var _this = this;
var instance = _axios["default"].create({
baseURL: this.baseUrl,
baseURL: accessToken ? this.baseUrl : SESSION_PROXY_URL,
timeout: this.timeout,
headers: {
headers: accessToken ? {
Authorization: "Bearer ".concat(accessToken)
} : {
'x-session-id': sessionId
}

@@ -91,2 +102,3 @@ });

var resource,
sessionId,
axiosInstance,

@@ -100,26 +112,45 @@ response,

resource = _args.length > 1 && _args[1] !== undefined ? _args[1] : undefined;
axiosInstance = this.__getAxiosInstance(accessToken);
_context.prev = 2;
_context.next = 5;
sessionId = _args.length > 2 && _args[2] !== undefined ? _args[2] : undefined;
axiosInstance = this.__getAxiosInstance(accessToken, sessionId);
_context.prev = 3;
if (!accessToken) {
_context.next = 10;
break;
}
_context.next = 7;
return axiosInstance.get(this.__getUrl(resource));
case 5:
response = _context.sent;
case 7:
_context.t0 = _context.sent;
_context.next = 13;
break;
case 10:
_context.next = 12;
return axiosInstance.post(this.__getProxyUrl("".concat(this.baseUrl).concat(this.__getUrl(resource)), 'get'), {});
case 12:
_context.t0 = _context.sent;
case 13:
response = _context.t0;
return _context.abrupt("return", response.data);
case 9:
_context.prev = 9;
_context.t0 = _context["catch"](2);
case 17:
_context.prev = 17;
_context.t1 = _context["catch"](3);
if (!(_context.t0.response && _context.t0.response.status !== 404)) {
_context.next = 13;
if (!(_context.t1.response && _context.t1.response.status !== 404)) {
_context.next = 21;
break;
}
throw _context.t0;
throw _context.t1;
case 13:
case 21:
return _context.abrupt("return", {});
case 14:
case 22:
case "end":

@@ -129,3 +160,3 @@ return _context.stop();

}
}, _callee, this, [[2, 9]]);
}, _callee, this, [[3, 17]]);
}));

@@ -146,2 +177,3 @@

var resource,
sessionId,
settings,

@@ -157,17 +189,36 @@ newSettings,

resource = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : undefined;
_context2.next = 3;
return this.getSettings(accessToken, resource);
sessionId = _args2.length > 3 && _args2[3] !== undefined ? _args2[3] : undefined;
_context2.next = 4;
return this.getSettings(accessToken, resource, sessionId);
case 3:
case 4:
settings = _context2.sent;
newSettings = Object.assign({}, settings, update);
axiosInstance = this.__getAxiosInstance(accessToken);
_context2.next = 8;
axiosInstance = this.__getAxiosInstance(accessToken, sessionId);
if (!accessToken) {
_context2.next = 13;
break;
}
_context2.next = 10;
return axiosInstance.put(this.__getUrl(resource), newSettings);
case 8:
response = _context2.sent;
case 10:
_context2.t0 = _context2.sent;
_context2.next = 16;
break;
case 13:
_context2.next = 15;
return axiosInstance.post(this.__getProxyUrl("".concat(this.baseUrl).concat(this.__getUrl(resource)), 'put'), newSettings);
case 15:
_context2.t0 = _context2.sent;
case 16:
response = _context2.t0;
return _context2.abrupt("return", response.data);
case 10:
case 18:
case "end":

@@ -174,0 +225,0 @@ return _context2.stop();

@@ -36,2 +36,3 @@ "use strict";

* @param {string} accessToken - Access token to use to call Customizr
* @param {string} sessionId - Session Id to use to call Customizr
* @return {Promise<*|void>}

@@ -47,2 +48,3 @@ */

* @param {object} settings - Settings object. Only language, regionalSettings and timezone will be read
* @param {string} sessionId - Session Id to use to call Customizr
* @return {Promise<void>}

@@ -56,3 +58,5 @@ */

_regenerator["default"].mark(function _callee(accessToken) {
var data;
var sessionId,
data,
_args = arguments;
return _regenerator["default"].wrap(function _callee$(_context) {

@@ -62,10 +66,11 @@ while (1) {

case 0:
_context.next = 2;
return mcpCustomizr.getSettings(accessToken);
sessionId = _args.length > 1 && _args[1] !== undefined ? _args[1] : undefined;
_context.next = 3;
return mcpCustomizr.getSettings(accessToken, undefined, sessionId);
case 2:
case 3:
data = _context.sent;
if (!(Object.keys(data).length === 0)) {
_context.next = 5;
_context.next = 6;
break;

@@ -80,6 +85,6 @@ }

case 5:
case 6:
return _context.abrupt("return", data);
case 6:
case 7:
case "end":

@@ -103,2 +108,3 @@ return _context.stop();

* @param {string} timezone - IANA timezone (eg. Europe/Amsterdam)
* @param {string} sessionId - Session Id to use to call Customizr
* @return {Promise<void>}

@@ -112,2 +118,4 @@ */

_regenerator["default"].mark(function _callee2(accessToken, settings) {
var sessionId,
_args2 = arguments;
return _regenerator["default"].wrap(function _callee2$(_context2) {

@@ -117,3 +125,4 @@ while (1) {

case 0:
_context2.next = 2;
sessionId = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : undefined;
_context2.next = 3;
return mcpCustomizr.putSettings(accessToken, {

@@ -123,8 +132,8 @@ language: settings.language,

timezone: settings.timezone
});
}, undefined, sessionId);
case 2:
case 3:
return _context2.abrupt("return", _context2.sent);
case 3:
case 4:
case "end":

@@ -145,2 +154,3 @@ return _context2.stop();

* @param {string} accessToken
* @param {string} sessionId - Session Id to use to call Customizr
* @return {Promise<*|Uint8Array|BigInt64Array|{lang: *, iso639_1: (string), iso639_2: *, iso639_3: *}[]|Float64Array|Int8Array|Float32Array|Int32Array|Uint32Array|Uint8ClampedArray|BigUint64Array|Int16Array|Uint16Array>}

@@ -154,3 +164,8 @@ */

_regenerator["default"].mark(function _callee3(accessToken, languageCode, languageTag, timezone) {
var preferredLanguage, preferredRegionalSettings, preferredTimezone, mcpSettings;
var sessionId,
preferredLanguage,
preferredRegionalSettings,
preferredTimezone,
mcpSettings,
_args3 = arguments;
return _regenerator["default"].wrap(function _callee3$(_context3) {

@@ -160,11 +175,12 @@ while (1) {

case 0:
sessionId = _args3.length > 4 && _args3[4] !== undefined ? _args3[4] : undefined;
preferredLanguage = (0, _utils.getValidLanguageOrThrow)(languageCode);
preferredRegionalSettings = (0, _utils.getValidLanguageTagOrThrow)(languageTag);
preferredTimezone = (0, _utils.getValidTimezoneOrThrow)(timezone);
_context3.next = 5;
return getMcpSettings(accessToken);
_context3.next = 6;
return getMcpSettings(accessToken, sessionId);
case 5:
case 6:
mcpSettings = _context3.sent;
_context3.next = 8;
_context3.next = 9;
return mcpCustomizr.putSettings(accessToken, {

@@ -174,8 +190,8 @@ language: (0, _utils.updatePreferredLanguage)(preferredLanguage, mcpSettings.language),

timezone: preferredTimezone
});
}, undefined, sessionId);
case 8:
case 9:
return _context3.abrupt("return", _context3.sent);
case 9:
case 10:
case "end":

@@ -197,2 +213,3 @@ return _context3.stop();

* @param {string} languageCode - ISO-639 language code (eg. bul, en, eng, de)
* @param {string} sessionId - Session Id to use to call Customizr
* @return {Promise<void>}

@@ -206,3 +223,6 @@ */

_regenerator["default"].mark(function _callee4(accessToken) {
var mcpSettings, twoLetterArray;
var sessionId,
mcpSettings,
twoLetterArray,
_args4 = arguments;
return _regenerator["default"].wrap(function _callee4$(_context4) {

@@ -212,6 +232,7 @@ while (1) {

case 0:
_context4.next = 2;
return getMcpSettings(accessToken);
sessionId = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : undefined;
_context4.next = 3;
return getMcpSettings(accessToken, sessionId);
case 2:
case 3:
mcpSettings = _context4.sent;

@@ -232,3 +253,3 @@ twoLetterArray = mcpSettings.language || [];

case 5:
case 6:
case "end":

@@ -249,2 +270,3 @@ return _context4.stop();

* @param {string} accessToken - Access token to use to call Customizr
* @param {string} sessionId - Session Id to use to call Customizr
* @return {Promise<string>}

@@ -258,3 +280,6 @@ */

_regenerator["default"].mark(function _callee5(accessToken, languageCode) {
var language, currentLanguages;
var sessionId,
language,
currentLanguages,
_args5 = arguments;
return _regenerator["default"].wrap(function _callee5$(_context5) {

@@ -264,7 +289,8 @@ while (1) {

case 0:
sessionId = _args5.length > 2 && _args5[2] !== undefined ? _args5[2] : undefined;
language = (0, _utils.getValidLanguageOrThrow)(languageCode);
_context5.next = 3;
return getPreferredMcpLanguages(accessToken);
_context5.next = 4;
return getPreferredMcpLanguages(accessToken, sessionId);
case 3:
case 4:
currentLanguages = _context5.sent;

@@ -275,5 +301,5 @@ return _context5.abrupt("return", mcpCustomizr.putSettings(accessToken, {

}))
}));
}, undefined, sessionId));
case 5:
case 6:
case "end":

@@ -295,2 +321,3 @@ return _context5.stop();

* @param {string} languageTag - RFC 4656 compliant language code (eg. en, en-US)
* @param {string} sessionId - Session Id to use to call Customizr
* @return {Promise<void>}

@@ -304,3 +331,5 @@ */

_regenerator["default"].mark(function _callee6(accessToken) {
var mcpSettings;
var sessionId,
mcpSettings,
_args6 = arguments;
return _regenerator["default"].wrap(function _callee6$(_context6) {

@@ -310,10 +339,11 @@ while (1) {

case 0:
_context6.next = 2;
return mcpCustomizr.getSettings(accessToken);
sessionId = _args6.length > 1 && _args6[1] !== undefined ? _args6[1] : undefined;
_context6.next = 3;
return mcpCustomizr.getSettings(accessToken, undefined, sessionId);
case 2:
case 3:
mcpSettings = _context6.sent;
return _context6.abrupt("return", mcpSettings.regionalSettings);
case 4:
case 5:
case "end":

@@ -334,2 +364,3 @@ return _context6.stop();

* @param {string} accessToken - Access token to use to call Customizr
* @param {string} sessionId - Session Id to use to call Customizr
* @return {Promise<string>}

@@ -343,3 +374,5 @@ */

_regenerator["default"].mark(function _callee7(accessToken, languageTag) {
var regionalSettings;
var sessionId,
regionalSettings,
_args7 = arguments;
return _regenerator["default"].wrap(function _callee7$(_context7) {

@@ -349,8 +382,9 @@ while (1) {

case 0:
sessionId = _args7.length > 2 && _args7[2] !== undefined ? _args7[2] : undefined;
regionalSettings = (0, _utils.getValidLanguageTagOrThrow)(languageTag);
return _context7.abrupt("return", mcpCustomizr.putSettings(accessToken, {
regionalSettings: regionalSettings
}));
}.undefined, sessionId));
case 2:
case 3:
case "end":

@@ -372,2 +406,3 @@ return _context7.stop();

* @param {string} timezone - IANA timezone (eg. Europe/Amsterdam)
* @param {string} sessionId - Session Id to use to call Customizr
* @return {Promise<void>}

@@ -381,3 +416,5 @@ */

_regenerator["default"].mark(function _callee8(accessToken) {
var mcpSettings;
var sessionId,
mcpSettings,
_args8 = arguments;
return _regenerator["default"].wrap(function _callee8$(_context8) {

@@ -387,10 +424,11 @@ while (1) {

case 0:
_context8.next = 2;
return getMcpSettings(accessToken);
sessionId = _args8.length > 1 && _args8[1] !== undefined ? _args8[1] : undefined;
_context8.next = 3;
return getMcpSettings(accessToken, sessionId);
case 2:
case 3:
mcpSettings = _context8.sent;
return _context8.abrupt("return", mcpSettings.timezone);
case 4:
case 5:
case "end":

@@ -413,3 +451,5 @@ return _context8.stop();

_regenerator["default"].mark(function _callee9(accessToken, timezone) {
var tz;
var sessionId,
tz,
_args9 = arguments;
return _regenerator["default"].wrap(function _callee9$(_context9) {

@@ -419,8 +459,9 @@ while (1) {

case 0:
sessionId = _args9.length > 2 && _args9[2] !== undefined ? _args9[2] : undefined;
tz = (0, _utils.getValidTimezoneOrThrow)(timezone);
return _context9.abrupt("return", mcpCustomizr.putSettings(accessToken, {
timezone: tz
}));
}, undefined, sessionId));
case 2:
case 3:
case "end":

@@ -427,0 +468,0 @@ return _context9.stop();

{
"name": "cimpress-customizr",
"version": "1.1.13",
"version": "1.2.0",
"description": "A thin client for Cimpress Customizr service",

@@ -42,3 +42,3 @@ "main": "./lib/index.js",

"nock": "^9.6.1",
"nyc": "^14.1.1"
"nyc": "^15.1.0"
},

@@ -45,0 +45,0 @@ "dependencies": {

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