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

@como/como-client

Package Overview
Dependencies
Maintainers
11
Versions
207
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@como/como-client - npm Package Compare versions

Comparing version 0.1.13 to 0.1.14

.whitesource

567

lib/como.js

@@ -278,7 +278,6 @@ 'use strict';

*
* @param {Object} identifier an object which identifies the user by its credentials
* @param {string} type login type i.e PhoneNumber/Email/etc
* @param {Object} form registration form values
*/
como.login = function () {
var _ref6 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee6(identifier, type) {
como.register = function () {
var _ref6 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee6(form) {
var _comoData5, api, data, _error$response$data2, code, message;

@@ -293,3 +292,3 @@

_context6.next = 4;
return api.logIn(type, identifier);
return api.register(form);

@@ -323,3 +322,3 @@ case 4:

return function (_x10, _x11) {
return function (_x10) {
return _ref6.apply(this, arguments);

@@ -331,9 +330,9 @@ };

*
* @param {Object} identifier key-value identifiers
* @param {*} type login type i.e PhoneNumber/Email/etc
* @param {*} code a 2-factor verification code sent to the client
* @param {string} verificationCode code verification sent by 3rd party
* @param {string} type verification type
* @param {Object} form registration form values
*/
como.loginVerify = function () {
var _ref7 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee7(identifier, type, code) {
var _comoData6, api, _ref8, consent, _error$response$data3, errCode, message;
como.registerVerify = function () {
var _ref7 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee7(verificationCode, type, form) {
var _comoData6, api, data, _error$response$data3, code, message;

@@ -347,25 +346,126 @@ return _regenerator2.default.wrap(function _callee7$(_context7) {

_context7.next = 4;
return api.registerVerify(verificationCode, type, form);
case 4:
data = _context7.sent;
return _context7.abrupt('return', data);
case 8:
_context7.prev = 8;
_context7.t0 = _context7['catch'](1);
if (!(_context7.t0.response && _context7.t0.response.data)) {
_context7.next = 13;
break;
}
_error$response$data3 = _context7.t0.response.data, code = _error$response$data3.code, message = _error$response$data3.message;
throw new Error(code || message);
case 13:
throw _context7.t0;
case 14:
case 'end':
return _context7.stop();
}
}
}, _callee7, undefined, [[1, 8]]);
}));
return function (_x11, _x12, _x13) {
return _ref7.apply(this, arguments);
};
}();
/**
*
* @param {Object} identifier an object which identifies the user by its credentials
* @param {string} type login type i.e PhoneNumber/Email/etc
*/
como.login = function () {
var _ref8 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee8(identifier, type) {
var _comoData7, api, data, _error$response$data4, code, message;
return _regenerator2.default.wrap(function _callee8$(_context8) {
while (1) {
switch (_context8.prev = _context8.next) {
case 0:
_comoData7 = comoData, api = _comoData7.api;
_context8.prev = 1;
_context8.next = 4;
return api.logIn(type, identifier);
case 4:
data = _context8.sent;
return _context8.abrupt('return', data);
case 8:
_context8.prev = 8;
_context8.t0 = _context8['catch'](1);
if (!(_context8.t0.response && _context8.t0.response.data)) {
_context8.next = 13;
break;
}
_error$response$data4 = _context8.t0.response.data, code = _error$response$data4.code, message = _error$response$data4.message;
throw new Error(code || message);
case 13:
throw _context8.t0;
case 14:
case 'end':
return _context8.stop();
}
}
}, _callee8, undefined, [[1, 8]]);
}));
return function (_x14, _x15) {
return _ref8.apply(this, arguments);
};
}();
/**
*
* @param {Object} identifier key-value identifiers
* @param {*} type login type i.e PhoneNumber/Email/etc
* @param {*} code a 2-factor verification code sent to the client
*/
como.loginVerify = function () {
var _ref9 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee9(identifier, type, code) {
var _comoData8, api, _ref10, consent, _error$response$data5, errCode, message;
return _regenerator2.default.wrap(function _callee9$(_context9) {
while (1) {
switch (_context9.prev = _context9.next) {
case 0:
_comoData8 = comoData, api = _comoData8.api;
_context9.prev = 1;
_context9.next = 4;
return api.logInVerify(code, type, identifier);
case 4:
_ref8 = _context7.sent;
consent = _ref8.consent;
_ref10 = _context9.sent;
consent = _ref10.consent;
comoData.consent = consent;
_context7.next = 17;
_context9.next = 17;
break;
case 9:
_context7.prev = 9;
_context7.t0 = _context7['catch'](1);
_context9.prev = 9;
_context9.t0 = _context9['catch'](1);
if (!(_context7.t0.response && _context7.t0.response.data)) {
_context7.next = 16;
if (!(_context9.t0.response && _context9.t0.response.data)) {
_context9.next = 16;
break;
}
_error$response$data3 = _context7.t0.response.data, errCode = _error$response$data3.code, message = _error$response$data3.message;
_error$response$data5 = _context9.t0.response.data, errCode = _error$response$data5.code, message = _error$response$data5.message;
if (!(message && message === 'Invalid verification Code')) {
_context7.next = 15;
_context9.next = 15;
break;

@@ -380,17 +480,17 @@ }

case 16:
throw _context7.t0;
throw _context9.t0;
case 17:
return _context7.abrupt('return', como.getCredentials());
return _context9.abrupt('return', como.getCredentials());
case 18:
case 'end':
return _context7.stop();
return _context9.stop();
}
}
}, _callee7, undefined, [[1, 9]]);
}, _callee9, undefined, [[1, 9]]);
}));
return function (_x12, _x13, _x14) {
return _ref7.apply(this, arguments);
return function (_x16, _x17, _x18) {
return _ref9.apply(this, arguments);
};

@@ -403,15 +503,15 @@ }();

*/
como.reloadMembership = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee8() {
var _comoData7, env, locationId, api, membership;
como.reloadMembership = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee10() {
var _comoData9, env, locationId, api, membership;
return _regenerator2.default.wrap(function _callee8$(_context8) {
return _regenerator2.default.wrap(function _callee10$(_context10) {
while (1) {
switch (_context8.prev = _context8.next) {
switch (_context10.prev = _context10.next) {
case 0:
_comoData7 = comoData, env = _comoData7.env_params, locationId = _comoData7.locationId, api = _comoData7.api;
_context8.next = 3;
_comoData9 = comoData, env = _comoData9.env_params, locationId = _comoData9.locationId, api = _comoData9.api;
_context10.next = 3;
return api.getUserAtLocation(env.zapp_root, locationId);
case 3:
membership = _context8.sent;
membership = _context10.sent;

@@ -422,6 +522,6 @@ comoData.membership = membership;

case 'end':
return _context8.stop();
return _context10.stop();
}
}
}, _callee8, undefined);
}, _callee10, undefined);
}));

@@ -432,18 +532,18 @@

*/
como.openApp = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee9() {
var _comoData8, api, locationId, token, env;
como.openApp = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee11() {
var _comoData10, api, locationId, token, env;
return _regenerator2.default.wrap(function _callee9$(_context9) {
return _regenerator2.default.wrap(function _callee11$(_context11) {
while (1) {
switch (_context9.prev = _context9.next) {
switch (_context11.prev = _context11.next) {
case 0:
_comoData8 = comoData, api = _comoData8.api, locationId = _comoData8.locationId, token = _comoData8.token, env = _comoData8.env_params;
return _context9.abrupt('return', api.openApp(env.zapp_root, token, locationId));
_comoData10 = comoData, api = _comoData10.api, locationId = _comoData10.locationId, token = _comoData10.token, env = _comoData10.env_params;
return _context11.abrupt('return', api.openApp(env.zapp_root, token, locationId));
case 2:
case 'end':
return _context9.stop();
return _context11.stop();
}
}
}, _callee9, undefined);
}, _callee11, undefined);
}));

@@ -457,22 +557,22 @@

como.clientUpdateMembership = function () {
var _ref11 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee10(pushEnable, locationEnable) {
var _comoData9, api, locationId, token, env;
var _ref13 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee12(pushEnable, locationEnable) {
var _comoData11, api, locationId, token, env;
return _regenerator2.default.wrap(function _callee10$(_context10) {
return _regenerator2.default.wrap(function _callee12$(_context12) {
while (1) {
switch (_context10.prev = _context10.next) {
switch (_context12.prev = _context12.next) {
case 0:
_comoData9 = comoData, api = _comoData9.api, locationId = _comoData9.locationId, token = _comoData9.token, env = _comoData9.env_params;
return _context10.abrupt('return', api.clientUpdateMembership(env.services_root, token, locationId, pushEnable, locationEnable));
_comoData11 = comoData, api = _comoData11.api, locationId = _comoData11.locationId, token = _comoData11.token, env = _comoData11.env_params;
return _context12.abrupt('return', api.clientUpdateMembership(env.services_root, token, locationId, pushEnable, locationEnable));
case 2:
case 'end':
return _context10.stop();
return _context12.stop();
}
}
}, _callee10, undefined);
}, _callee12, undefined);
}));
return function (_x15, _x16) {
return _ref11.apply(this, arguments);
return function (_x19, _x20) {
return _ref13.apply(this, arguments);
};

@@ -487,8 +587,8 @@ }();

como.downloadMainResource = function () {
var _ref12 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee11(resourceId) {
var resource, err, _comoData10, env, api, responseJson;
var _ref14 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee13(resourceId) {
var resource, err, _comoData12, env, api, responseJson;
return _regenerator2.default.wrap(function _callee11$(_context11) {
return _regenerator2.default.wrap(function _callee13$(_context13) {
while (1) {
switch (_context11.prev = _context11.next) {
switch (_context13.prev = _context13.next) {
case 0:

@@ -498,3 +598,3 @@ resource = comoData.mainResourcesMap[resourceId];

if (resource) {
_context11.next = 4;
_context13.next = 4;
break;

@@ -507,8 +607,8 @@ }

case 4:
_comoData10 = comoData, env = _comoData10.env_params, api = _comoData10.api;
_context11.next = 7;
_comoData12 = comoData, env = _comoData12.env_params, api = _comoData12.api;
_context13.next = 7;
return api.getLoyaltyResource(env.services_root_temp, resource.id, 'Namespace' in resource ? resource.Namespace : 'location_' + comoData.locationId, resource.Version);
case 7:
responseJson = _context11.sent;
responseJson = _context13.sent;

@@ -520,10 +620,10 @@

case 'end':
return _context11.stop();
return _context13.stop();
}
}
}, _callee11, undefined);
}, _callee13, undefined);
}));
return function (_x17) {
return _ref12.apply(this, arguments);
return function (_x21) {
return _ref14.apply(this, arguments);
};

@@ -536,15 +636,15 @@ }();

*/
como.reloadLocationState = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee12() {
var _comoData11, api, state, mainResources;
como.reloadLocationState = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee14() {
var _comoData13, api, state, mainResources;
return _regenerator2.default.wrap(function _callee12$(_context12) {
return _regenerator2.default.wrap(function _callee14$(_context14) {
while (1) {
switch (_context12.prev = _context12.next) {
switch (_context14.prev = _context14.next) {
case 0:
_comoData11 = comoData, api = _comoData11.api;
_context12.next = 3;
_comoData13 = comoData, api = _comoData13.api;
_context14.next = 3;
return api.getLocationState(comoData.env_params.zapp_root, comoData.locationId);
case 3:
state = _context12.sent;
state = _context14.sent;

@@ -562,6 +662,6 @@ comoData.locationState = state;

case 'end':
return _context12.stop();
return _context14.stop();
}
}
}, _callee12, undefined);
}, _callee14, undefined);
}));

@@ -572,23 +672,23 @@

*/
como.getAppClientID = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee13() {
var _comoData12, env, locationId, api, responseJson;
como.getAppClientID = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee15() {
var _comoData14, env, locationId, api, responseJson;
return _regenerator2.default.wrap(function _callee13$(_context13) {
return _regenerator2.default.wrap(function _callee15$(_context15) {
while (1) {
switch (_context13.prev = _context13.next) {
switch (_context15.prev = _context15.next) {
case 0:
_comoData12 = comoData, env = _comoData12.env_params, locationId = _comoData12.locationId, api = _comoData12.api;
_context13.next = 3;
_comoData14 = comoData, env = _comoData14.env_params, locationId = _comoData14.locationId, api = _comoData14.api;
_context15.next = 3;
return api.getShortUserId(env.zapp_root, locationId);
case 3:
responseJson = _context13.sent;
return _context13.abrupt('return', responseJson.ID);
responseJson = _context15.sent;
return _context15.abrupt('return', responseJson.ID);
case 5:
case 'end':
return _context13.stop();
return _context15.stop();
}
}
}, _callee13, undefined);
}, _callee15, undefined);
}));

@@ -599,23 +699,23 @@

*/
como.getPaymentCode = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee14() {
var _comoData13, env, locationId, api, responseJson;
como.getPaymentCode = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee16() {
var _comoData15, env, locationId, api, responseJson;
return _regenerator2.default.wrap(function _callee14$(_context14) {
return _regenerator2.default.wrap(function _callee16$(_context16) {
while (1) {
switch (_context14.prev = _context14.next) {
switch (_context16.prev = _context16.next) {
case 0:
_comoData13 = comoData, env = _comoData13.env_params, locationId = _comoData13.locationId, api = _comoData13.api;
_context14.next = 3;
_comoData15 = comoData, env = _comoData15.env_params, locationId = _comoData15.locationId, api = _comoData15.api;
_context16.next = 3;
return api.getPaymentCode(env.zapp_root, locationId);
case 3:
responseJson = _context14.sent;
return _context14.abrupt('return', responseJson.VerificationCode);
responseJson = _context16.sent;
return _context16.abrupt('return', responseJson.VerificationCode);
case 5:
case 'end':
return _context14.stop();
return _context16.stop();
}
}
}, _callee14, undefined);
}, _callee16, undefined);
}));

@@ -626,39 +726,39 @@

*/
como.logout = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee15() {
var _comoData14, api, response, _error$response$data4, errCode, message;
como.logout = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee17() {
var _comoData16, api, response, _error$response$data6, errCode, message;
return _regenerator2.default.wrap(function _callee15$(_context15) {
return _regenerator2.default.wrap(function _callee17$(_context17) {
while (1) {
switch (_context15.prev = _context15.next) {
switch (_context17.prev = _context17.next) {
case 0:
_comoData14 = comoData, api = _comoData14.api;
_context15.prev = 1;
_context15.next = 4;
_comoData16 = comoData, api = _comoData16.api;
_context17.prev = 1;
_context17.next = 4;
return api.logOut();
case 4:
response = _context15.sent;
return _context15.abrupt('return', response);
response = _context17.sent;
return _context17.abrupt('return', response);
case 8:
_context15.prev = 8;
_context15.t0 = _context15['catch'](1);
_context17.prev = 8;
_context17.t0 = _context17['catch'](1);
if (!(_context15.t0.response && _context15.t0.response.data)) {
_context15.next = 13;
if (!(_context17.t0.response && _context17.t0.response.data)) {
_context17.next = 13;
break;
}
_error$response$data4 = _context15.t0.response.data, errCode = _error$response$data4.code, message = _error$response$data4.message;
_error$response$data6 = _context17.t0.response.data, errCode = _error$response$data6.code, message = _error$response$data6.message;
throw new Error(errCode || message);
case 13:
throw _context15.t0;
throw _context17.t0;
case 14:
case 'end':
return _context15.stop();
return _context17.stop();
}
}
}, _callee15, undefined, [[1, 8]]);
}, _callee17, undefined, [[1, 8]]);
}));

@@ -671,27 +771,27 @@

como.redeemAsset = function () {
var _ref17 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee16(assetKey) {
var _comoData15, env, locationId, api, responseJson;
var _ref19 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee18(assetKey) {
var _comoData17, env, locationId, api, responseJson;
return _regenerator2.default.wrap(function _callee16$(_context16) {
return _regenerator2.default.wrap(function _callee18$(_context18) {
while (1) {
switch (_context16.prev = _context16.next) {
switch (_context18.prev = _context18.next) {
case 0:
_comoData15 = comoData, env = _comoData15.env_params, locationId = _comoData15.locationId, api = _comoData15.api;
_context16.next = 3;
_comoData17 = comoData, env = _comoData17.env_params, locationId = _comoData17.locationId, api = _comoData17.api;
_context18.next = 3;
return api.redeemAsset(env.zapp_root, locationId, assetKey);
case 3:
responseJson = _context16.sent;
return _context16.abrupt('return', responseJson);
responseJson = _context18.sent;
return _context18.abrupt('return', responseJson);
case 5:
case 'end':
return _context16.stop();
return _context18.stop();
}
}
}, _callee16, undefined);
}, _callee18, undefined);
}));
return function (_x18) {
return _ref17.apply(this, arguments);
return function (_x22) {
return _ref19.apply(this, arguments);
};

@@ -705,27 +805,27 @@ }();

como.purchaseAsset = function () {
var _ref18 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee17(itemId) {
var _comoData16, env, token, locationId, api, responseJson;
var _ref20 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee19(itemId) {
var _comoData18, env, token, locationId, api, responseJson;
return _regenerator2.default.wrap(function _callee17$(_context17) {
return _regenerator2.default.wrap(function _callee19$(_context19) {
while (1) {
switch (_context17.prev = _context17.next) {
switch (_context19.prev = _context19.next) {
case 0:
_comoData16 = comoData, env = _comoData16.env_params, token = _comoData16.token, locationId = _comoData16.locationId, api = _comoData16.api;
_context17.next = 3;
_comoData18 = comoData, env = _comoData18.env_params, token = _comoData18.token, locationId = _comoData18.locationId, api = _comoData18.api;
_context19.next = 3;
return api.purchaseAsset(env.zapp_root, locationId, token, itemId);
case 3:
responseJson = _context17.sent;
return _context17.abrupt('return', responseJson);
responseJson = _context19.sent;
return _context19.abrupt('return', responseJson);
case 5:
case 'end':
return _context17.stop();
return _context19.stop();
}
}
}, _callee17, undefined);
}, _callee19, undefined);
}));
return function (_x19) {
return _ref18.apply(this, arguments);
return function (_x23) {
return _ref20.apply(this, arguments);
};

@@ -738,15 +838,15 @@ }();

*/
como.reloadAssets = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee18() {
var _comoData17, env, locationId, api, responseJson, assets, archivedAssets, dateNow;
como.reloadAssets = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee20() {
var _comoData19, env, locationId, api, responseJson, assets, archivedAssets, dateNow;
return _regenerator2.default.wrap(function _callee18$(_context18) {
return _regenerator2.default.wrap(function _callee20$(_context20) {
while (1) {
switch (_context18.prev = _context18.next) {
switch (_context20.prev = _context20.next) {
case 0:
_comoData17 = comoData, env = _comoData17.env_params, locationId = _comoData17.locationId, api = _comoData17.api;
_context18.next = 3;
_comoData19 = comoData, env = _comoData19.env_params, locationId = _comoData19.locationId, api = _comoData19.api;
_context20.next = 3;
return api.memberAssets(env.services_root, locationId);
case 3:
responseJson = _context18.sent;
responseJson = _context20.sent;
assets = [];

@@ -786,6 +886,6 @@ archivedAssets = [];

case 'end':
return _context18.stop();
return _context20.stop();
}
}
}, _callee18, undefined);
}, _callee20, undefined);
}));

@@ -797,15 +897,15 @@

*/
como.reloadArchivedAssets = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee19() {
var _comoData18, env, locationId, api, responseJson;
como.reloadArchivedAssets = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee21() {
var _comoData20, env, locationId, api, responseJson;
return _regenerator2.default.wrap(function _callee19$(_context19) {
return _regenerator2.default.wrap(function _callee21$(_context21) {
while (1) {
switch (_context19.prev = _context19.next) {
switch (_context21.prev = _context21.next) {
case 0:
_comoData18 = comoData, env = _comoData18.env_params, locationId = _comoData18.locationId, api = _comoData18.api;
_context19.next = 3;
_comoData20 = comoData, env = _comoData20.env_params, locationId = _comoData20.locationId, api = _comoData20.api;
_context21.next = 3;
return api.memberAssets(env.services_root, locationId, true);
case 3:
responseJson = _context19.sent;
responseJson = _context21.sent;

@@ -816,6 +916,6 @@ comoData.redeemedAssets = responseJson;

case 'end':
return _context19.stop();
return _context21.stop();
}
}
}, _callee19, undefined);
}, _callee21, undefined);
}));

@@ -853,11 +953,11 @@

*/
como.downloadMainResources = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee20() {
como.downloadMainResources = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee22() {
var resources, downloads;
return _regenerator2.default.wrap(function _callee20$(_context20) {
return _regenerator2.default.wrap(function _callee22$(_context22) {
while (1) {
switch (_context20.prev = _context20.next) {
switch (_context22.prev = _context22.next) {
case 0:
resources = ['LocationData', 'Menu', 'Updates', 'TCAlts', 'AppTexts', 'DefaultAppTexts'];
downloads = resources.map(como.downloadMainResource);
_context20.next = 4;
_context22.next = 4;
return Promise.all(downloads);

@@ -870,6 +970,6 @@

case 'end':
return _context20.stop();
return _context22.stop();
}
}
}, _callee20, undefined);
}, _callee22, undefined);
}));

@@ -882,5 +982,5 @@

como.loadForm = function (type) {
var _comoData19 = comoData,
api = _comoData19.api,
locationId = _comoData19.locationId;
var _comoData21 = comoData,
api = _comoData21.api,
locationId = _comoData21.locationId;

@@ -896,5 +996,5 @@

como.getConfigration = function (type) {
var _comoData20 = comoData,
api = _comoData20.api,
locationId = _comoData20.locationId;
var _comoData22 = comoData,
api = _comoData22.api,
locationId = _comoData22.locationId;

@@ -912,5 +1012,5 @@ var _como$getLocationStat = como.getLocationState(),

como.getResource = function (type) {
var _comoData21 = comoData,
api = _comoData21.api,
locationId = _comoData21.locationId;
var _comoData23 = comoData,
api = _comoData23.api,
locationId = _comoData23.locationId;

@@ -924,7 +1024,7 @@ return api.getResource(type, locationId);

como.generateReferralCode = function () {
var _comoData22 = comoData,
api = _comoData22.api,
locationId = _comoData22.locationId,
token = _comoData22.token,
env = _comoData22.env_params;
var _comoData24 = comoData,
api = _comoData24.api,
locationId = _comoData24.locationId,
token = _comoData24.token,
env = _comoData24.env_params;

@@ -990,22 +1090,22 @@

*/
como.getRegistrationUrl = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee21() {
var _comoData23, token, locationId, env;
como.getRegistrationUrl = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee23() {
var _comoData25, token, locationId, env;
return _regenerator2.default.wrap(function _callee21$(_context21) {
return _regenerator2.default.wrap(function _callee23$(_context23) {
while (1) {
switch (_context21.prev = _context21.next) {
switch (_context23.prev = _context23.next) {
case 0:
_context21.next = 2;
_context23.next = 2;
return refreshTokenIfNeeded();
case 2:
_comoData23 = comoData, token = _comoData23.token, locationId = _comoData23.locationId, env = _comoData23.env_params;
return _context21.abrupt('return', env.app_modules_root + '/register?token=' + token + '&locationid=' + locationId);
_comoData25 = comoData, token = _comoData25.token, locationId = _comoData25.locationId, env = _comoData25.env_params;
return _context23.abrupt('return', env.app_modules_root + '/register?token=' + token + '&locationid=' + locationId);
case 4:
case 'end':
return _context21.stop();
return _context23.stop();
}
}
}, _callee21, undefined);
}, _callee23, undefined);
}));

@@ -1016,22 +1116,22 @@

*/
como.getProfileUrl = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee22() {
var _comoData24, token, locationId, env;
como.getProfileUrl = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee24() {
var _comoData26, token, locationId, env;
return _regenerator2.default.wrap(function _callee22$(_context22) {
return _regenerator2.default.wrap(function _callee24$(_context24) {
while (1) {
switch (_context22.prev = _context22.next) {
switch (_context24.prev = _context24.next) {
case 0:
_context22.next = 2;
_context24.next = 2;
return refreshTokenIfNeeded();
case 2:
_comoData24 = comoData, token = _comoData24.token, locationId = _comoData24.locationId, env = _comoData24.env_params;
return _context22.abrupt('return', env.app_modules_root + '/profile?token=' + token + '&locationid=' + locationId);
_comoData26 = comoData, token = _comoData26.token, locationId = _comoData26.locationId, env = _comoData26.env_params;
return _context24.abrupt('return', env.app_modules_root + '/profile?token=' + token + '&locationid=' + locationId);
case 4:
case 'end':
return _context22.stop();
return _context24.stop();
}
}
}, _callee22, undefined);
}, _callee24, undefined);
}));

@@ -1042,22 +1142,22 @@

*/
como.getLoginUrl = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee23() {
var _comoData25, token, locationId, env;
como.getLoginUrl = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee25() {
var _comoData27, token, locationId, env;
return _regenerator2.default.wrap(function _callee23$(_context23) {
return _regenerator2.default.wrap(function _callee25$(_context25) {
while (1) {
switch (_context23.prev = _context23.next) {
switch (_context25.prev = _context25.next) {
case 0:
_context23.next = 2;
_context25.next = 2;
return refreshTokenIfNeeded();
case 2:
_comoData25 = comoData, token = _comoData25.token, locationId = _comoData25.locationId, env = _comoData25.env_params;
return _context23.abrupt('return', env.app_modules_root + '/login?token=' + token + '&locationid=' + locationId);
_comoData27 = comoData, token = _comoData27.token, locationId = _comoData27.locationId, env = _comoData27.env_params;
return _context25.abrupt('return', env.app_modules_root + '/login?token=' + token + '&locationid=' + locationId);
case 4:
case 'end':
return _context23.stop();
return _context25.stop();
}
}
}, _callee23, undefined);
}, _callee25, undefined);
}));

@@ -1068,22 +1168,22 @@

*/
como.getAppModulesLegacyBaseUrl = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee24() {
var _comoData26, env;
como.getAppModulesLegacyBaseUrl = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee26() {
var _comoData28, env;
return _regenerator2.default.wrap(function _callee24$(_context24) {
return _regenerator2.default.wrap(function _callee26$(_context26) {
while (1) {
switch (_context24.prev = _context24.next) {
switch (_context26.prev = _context26.next) {
case 0:
_context24.next = 2;
_context26.next = 2;
return refreshTokenIfNeeded();
case 2:
_comoData26 = comoData, env = _comoData26.env_params;
return _context24.abrupt('return', '' + env.app_modules_legacy_root);
_comoData28 = comoData, env = _comoData28.env_params;
return _context26.abrupt('return', '' + env.app_modules_legacy_root);
case 4:
case 'end':
return _context24.stop();
return _context26.stop();
}
}
}, _callee24, undefined);
}, _callee26, undefined);
}));

@@ -1128,5 +1228,5 @@

como.getResourceUrl = function (resourceId, namespace, version) {
var _comoData27 = comoData,
api = _comoData27.api,
env = _comoData27.env_params;
var _comoData29 = comoData,
api = _comoData29.api,
env = _comoData29.env_params;

@@ -1137,10 +1237,10 @@ return api.getResourceUrl(env.services_root_temp, resourceId, namespace, version);

/**
* @param {string} identifier - fcm token created by firebase
* @param {string} identifier fcm token created by firebase
*/
como.sendPushChannel = function (identifier) {
var _comoData28 = comoData,
api = _comoData28.api,
locationId = _comoData28.locationId,
token = _comoData28.token,
env = _comoData28.env_params;
var _comoData30 = comoData,
api = _comoData30.api,
locationId = _comoData30.locationId,
token = _comoData30.token,
env = _comoData30.env_params;

@@ -1150,20 +1250,33 @@ return api.sendPushChannel(env.services_root, locationId, token, identifier);

como.getRegionConfig = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee25() {
var _comoData29, api, locationId, token, env;
como.getRegionConfig = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee27() {
var _comoData31, api, locationId, token, env;
return _regenerator2.default.wrap(function _callee25$(_context25) {
return _regenerator2.default.wrap(function _callee27$(_context27) {
while (1) {
switch (_context25.prev = _context25.next) {
switch (_context27.prev = _context27.next) {
case 0:
_comoData29 = comoData, api = _comoData29.api, locationId = _comoData29.locationId, token = _comoData29.token, env = _comoData29.env_params;
return _context25.abrupt('return', api.getClientBusinessBackend(env.zapp_root, token, locationId));
_comoData31 = comoData, api = _comoData31.api, locationId = _comoData31.locationId, token = _comoData31.token, env = _comoData31.env_params;
return _context27.abrupt('return', api.getClientBusinessBackend(env.zapp_root, token, locationId));
case 2:
case 'end':
return _context25.stop();
return _context27.stop();
}
}
}, _callee25, undefined);
}, _callee27, undefined);
}));
/**
* @param {string} code coupon code entered by user on App
*/
como.sendCouponCode = function (code) {
var _comoData32 = comoData,
api = _comoData32.api,
locationId = _comoData32.locationId,
token = _comoData32.token,
env = _comoData32.env_params;
return api.sendCouponCode(env.zapp_root, locationId, token, code);
};
module.exports = como;

@@ -45,6 +45,6 @@ 'use strict';

exports.logIn = function (service) {
exports.register = function (service) {
return function () {
var _ref3 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee2(type, identifier) {
var params, _ref4, data;
var _ref3 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee2(form) {
var _ref4, data;

@@ -55,7 +55,6 @@ return _regenerator2.default.wrap(function _callee2$(_context2) {

case 0:
params = { type: type, identifier: identifier };
_context2.next = 3;
return service.post('/v1/auth/logIn', params);
_context2.next = 2;
return service.post('/v1/auth/register', { form: form });
case 3:
case 2:
_ref4 = _context2.sent;

@@ -65,3 +64,3 @@ data = _ref4.data;

case 6:
case 5:
case 'end':

@@ -74,3 +73,3 @@ return _context2.stop();

return function (_x3, _x4) {
return function (_x3) {
return _ref3.apply(this, arguments);

@@ -81,6 +80,6 @@ };

exports.logInVerify = function (service) {
exports.registerVerify = function (service) {
return function () {
var _ref5 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee3(code, type, identifier) {
var params, _ref6, data;
var _ref5 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee3(code, type, form) {
var body, _ref6, data;

@@ -91,9 +90,5 @@ return _regenerator2.default.wrap(function _callee3$(_context3) {

case 0:
params = {
identifier: identifier,
code: code,
type: type
};
body = { code: code, type: type, form: form };
_context3.next = 3;
return service.post('/v1/auth/logInVerify', params);
return service.post('/v1/auth/registerVerify', body);

@@ -113,3 +108,3 @@ case 3:

return function (_x5, _x6, _x7) {
return function (_x4, _x5, _x6) {
return _ref5.apply(this, arguments);

@@ -120,24 +115,92 @@ };

exports.logIn = function (service) {
return function () {
var _ref7 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee4(type, identifier) {
var params, _ref8, data;
return _regenerator2.default.wrap(function _callee4$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
params = { type: type, identifier: identifier };
_context4.next = 3;
return service.post('/v1/auth/logIn', params);
case 3:
_ref8 = _context4.sent;
data = _ref8.data;
return _context4.abrupt('return', data);
case 6:
case 'end':
return _context4.stop();
}
}
}, _callee4, undefined);
}));
return function (_x7, _x8) {
return _ref7.apply(this, arguments);
};
}();
};
exports.logInVerify = function (service) {
return function () {
var _ref9 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee5(code, type, identifier) {
var params, _ref10, data;
return _regenerator2.default.wrap(function _callee5$(_context5) {
while (1) {
switch (_context5.prev = _context5.next) {
case 0:
params = {
identifier: identifier,
code: code,
type: type
};
_context5.next = 3;
return service.post('/v1/auth/logInVerify', params);
case 3:
_ref10 = _context5.sent;
data = _ref10.data;
return _context5.abrupt('return', data);
case 6:
case 'end':
return _context5.stop();
}
}
}, _callee5, undefined);
}));
return function (_x9, _x10, _x11) {
return _ref9.apply(this, arguments);
};
}();
};
exports.logOut = function (service) {
return (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee4() {
var _ref8, data;
return (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee6() {
var _ref12, data;
return _regenerator2.default.wrap(function _callee4$(_context4) {
return _regenerator2.default.wrap(function _callee6$(_context6) {
while (1) {
switch (_context4.prev = _context4.next) {
switch (_context6.prev = _context6.next) {
case 0:
_context4.next = 2;
_context6.next = 2;
return service.post('/v1/auth/logOut');
case 2:
_ref8 = _context4.sent;
data = _ref8.data;
return _context4.abrupt('return', data);
_ref12 = _context6.sent;
data = _ref12.data;
return _context6.abrupt('return', data);
case 5:
case 'end':
return _context4.stop();
return _context6.stop();
}
}
}, _callee4, undefined);
}, _callee6, undefined);
}));

@@ -148,30 +211,30 @@ };

return function () {
var _ref9 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee5(uid, token) {
var params, _ref10, data;
var _ref13 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee7(uid, token) {
var params, _ref14, data;
return _regenerator2.default.wrap(function _callee5$(_context5) {
return _regenerator2.default.wrap(function _callee7$(_context7) {
while (1) {
switch (_context5.prev = _context5.next) {
switch (_context7.prev = _context7.next) {
case 0:
params = { uid: uid, refreshToken: token };
_context5.next = 3;
_context7.next = 3;
return service.post('/v1/auth/refresh-token', params);
case 3:
_ref10 = _context5.sent;
data = _ref10.data;
return _context5.abrupt('return', data);
_ref14 = _context7.sent;
data = _ref14.data;
return _context7.abrupt('return', data);
case 6:
case 'end':
return _context5.stop();
return _context7.stop();
}
}
}, _callee5, undefined);
}, _callee7, undefined);
}));
return function (_x8, _x9) {
return _ref9.apply(this, arguments);
return function (_x12, _x13) {
return _ref13.apply(this, arguments);
};
}();
};

@@ -561,2 +561,32 @@ 'use strict';

}();
};
exports.sendCouponCode = function (service) {
return function () {
var _ref28 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee17(baseUrl, locationId, token, code) {
var url, response;
return _regenerator2.default.wrap(function _callee17$(_context17) {
while (1) {
switch (_context17.prev = _context17.next) {
case 0:
url = baseUrl + '/alpha/api/DoCodeBasedAction?LocationID=' + locationId + '&Token=' + token + '&Code=' + code + '&InputType=json&MimeType=application/json';
_context17.next = 3;
return service.post(url);
case 3:
response = _context17.sent;
return _context17.abrupt('return', response);
case 5:
case 'end':
return _context17.stop();
}
}
}, _callee17, undefined);
}));
return function (_x50, _x51, _x52, _x53) {
return _ref28.apply(this, arguments);
};
}();
};
{
"name": "@como/como-client",
"version": "0.1.13",
"version": "0.1.14",
"description": "Client module for Como's loaylty API",

@@ -5,0 +5,0 @@ "main": "src/como.js",

@@ -145,2 +145,41 @@ const moment = require('moment-timezone');

*
* @param {Object} form registration form values
*/
como.register = async form => {
const { api } = comoData;
try {
const data = await api.register(form);
return data;
} catch (error) {
if (error.response && error.response.data) {
const { code, message } = error.response.data;
throw new Error(code || message);
}
throw error;
}
};
/**
*
* @param {string} verificationCode code verification sent by 3rd party
* @param {string} type verification type
* @param {Object} form registration form values
*/
como.registerVerify = async (verificationCode, type, form) => {
const { api } = comoData;
try {
const data = await api.registerVerify(verificationCode, type, form);
return data;
} catch (error) {
if (error.response && error.response.data) {
const { code, message } = error.response.data;
throw new Error(code || message);
}
throw error;
}
};
/**
*
* @param {Object} identifier an object which identifies the user by its credentials

@@ -575,3 +614,3 @@ * @param {string} type login type i.e PhoneNumber/Email/etc

/**
* @param {string} identifier - fcm token created by firebase
* @param {string} identifier fcm token created by firebase
*/

@@ -592,2 +631,13 @@ como.sendPushChannel = identifier => {

/**
* @param {string} code coupon code entered by user on App
*/
como.sendCouponCode = code => {
const {
api, locationId, token, env_params: env,
} = comoData;
return api.sendCouponCode(env.zapp_root, locationId, token, code);
};
module.exports = como;

@@ -7,2 +7,13 @@ exports.signOn = service => async (deviceId, locationId) => {

exports.register = service => async form => {
const { data } = await service.post('/v1/auth/register', { form });
return data;
};
exports.registerVerify = service => async (code, type, form) => {
const body = { code, type, form };
const { data } = await service.post('/v1/auth/registerVerify', body);
return data;
};
exports.logIn = service => async (type, identifier) => {

@@ -9,0 +20,0 @@ const params = { type, identifier };

@@ -79,5 +79,5 @@ const moment = require('moment-timezone');

exports.getLoyaltyResource = service => async (baseUrl, resourceId, namespace, version) => {
const url = buildResourceUrl(baseUrl, resourceId, namespace, version);
const { data } = await axios.get(url);
return data;
const url = buildResourceUrl(baseUrl, resourceId, namespace, version);
const { data } = await axios.get(url);
return data;
};

@@ -137,1 +137,7 @@

exports.sendCouponCode = service => async (baseUrl, locationId, token, code) => {
const url = `${baseUrl}/alpha/api/DoCodeBasedAction?LocationID=${locationId}&Token=${token}&Code=${code}&InputType=json&MimeType=application/json`;
const response = await service.post(url);
return response;
};
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