@como/como-client 0.9.0 → 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/como.js +470 -376
- package/lib/config/env.js +4 -0
- package/lib/services/auth.service.js +38 -5
- package/package.json +2 -2
- package/src/como.js +31 -1
package/lib/config/env.js
CHANGED
|
@@ -8,6 +8,7 @@ module.exports = {
|
|
|
8
8
|
services_root_cdn: 'https://services.qa.bcomo.com',
|
|
9
9
|
app_modules_root: 'https://app.qa.comosense.com/app-modules',
|
|
10
10
|
app_modules_legacy_root: 'https://appmodules.qa.comosense.com',
|
|
11
|
+
cp_base_url: 'https://{location_id}.qa.comosense.net',
|
|
11
12
|
purchase_connect_base_url: 'https://qr.qa.comosense.com'
|
|
12
13
|
},
|
|
13
14
|
qa: {
|
|
@@ -17,6 +18,7 @@ module.exports = {
|
|
|
17
18
|
services_root_cdn: 'https://services.qa.bcomo.com',
|
|
18
19
|
app_modules_root: 'https://app.qa.comosense.com/app-modules',
|
|
19
20
|
app_modules_legacy_root: 'https://appmodules.qa.comosense.com',
|
|
21
|
+
cp_base_url: 'https://{location_id}.qa.comosense.net',
|
|
20
22
|
purchase_connect_base_url: 'https://qr.qa.comosense.com'
|
|
21
23
|
},
|
|
22
24
|
prod: {
|
|
@@ -26,6 +28,7 @@ module.exports = {
|
|
|
26
28
|
services_root_cdn: 'https://services.prod.bcomo.com',
|
|
27
29
|
app_modules_root: 'https://app.comosense.com/app-modules',
|
|
28
30
|
app_modules_legacy_root: 'https://appmodules.comosense.com',
|
|
31
|
+
cp_base_url: 'https://{location_id}.comosense.net',
|
|
29
32
|
purchase_connect_base_url: 'https://qr.comosense.com'
|
|
30
33
|
},
|
|
31
34
|
test: {
|
|
@@ -35,6 +38,7 @@ module.exports = {
|
|
|
35
38
|
services_root_cdn: 'https://services.qa.bcomo.com',
|
|
36
39
|
app_modules_root: 'https://app.qa.comosense.com/app-modules',
|
|
37
40
|
app_modules_legacy_root: 'https://appmodules.qa.comosense.com',
|
|
41
|
+
cp_base_url: 'https://{location_id}.qa.comosense.net',
|
|
38
42
|
app_payment_purchase: 'https://qr.qa.comosense.com/Purchase/Report',
|
|
39
43
|
purchase_connect_base_url: 'https://qr.qa.comosense.com'
|
|
40
44
|
}
|
|
@@ -401,19 +401,19 @@ exports.logOut = function (service) {
|
|
|
401
401
|
}));
|
|
402
402
|
};
|
|
403
403
|
|
|
404
|
-
exports.
|
|
404
|
+
exports.socialLogin = function (service) {
|
|
405
405
|
return function () {
|
|
406
|
-
var _ref23 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee12(
|
|
406
|
+
var _ref23 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee12(socialId, provider, idToken) {
|
|
407
407
|
var params, headers, _ref24, data;
|
|
408
408
|
|
|
409
409
|
return _regenerator2.default.wrap(function _callee12$(_context12) {
|
|
410
410
|
while (1) {
|
|
411
411
|
switch (_context12.prev = _context12.next) {
|
|
412
412
|
case 0:
|
|
413
|
-
params = {
|
|
413
|
+
params = { socialId: socialId, provider: provider, idToken: idToken };
|
|
414
414
|
headers = getHashHeader(params);
|
|
415
415
|
_context12.next = 4;
|
|
416
|
-
return service.post('/auth/
|
|
416
|
+
return service.post('/auth/v1/auth/socialLogin', params, { headers: headers });
|
|
417
417
|
|
|
418
418
|
case 4:
|
|
419
419
|
_ref24 = _context12.sent;
|
|
@@ -428,8 +428,41 @@ exports.refreshToken = function (service) {
|
|
|
428
428
|
}, _callee12, undefined);
|
|
429
429
|
}));
|
|
430
430
|
|
|
431
|
-
return function (_x39, _x40, _x41
|
|
431
|
+
return function (_x39, _x40, _x41) {
|
|
432
432
|
return _ref23.apply(this, arguments);
|
|
433
433
|
};
|
|
434
434
|
}();
|
|
435
|
+
};
|
|
436
|
+
|
|
437
|
+
exports.refreshToken = function (service) {
|
|
438
|
+
return function () {
|
|
439
|
+
var _ref25 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee13(uid, token, locationId, source) {
|
|
440
|
+
var params, headers, _ref26, data;
|
|
441
|
+
|
|
442
|
+
return _regenerator2.default.wrap(function _callee13$(_context13) {
|
|
443
|
+
while (1) {
|
|
444
|
+
switch (_context13.prev = _context13.next) {
|
|
445
|
+
case 0:
|
|
446
|
+
params = { uid: uid, refreshToken: token, locationId: locationId, source: source };
|
|
447
|
+
headers = getHashHeader(params);
|
|
448
|
+
_context13.next = 4;
|
|
449
|
+
return service.post('/auth/v2/auth/refresh-token', params, { headers: headers });
|
|
450
|
+
|
|
451
|
+
case 4:
|
|
452
|
+
_ref26 = _context13.sent;
|
|
453
|
+
data = _ref26.data;
|
|
454
|
+
return _context13.abrupt("return", data);
|
|
455
|
+
|
|
456
|
+
case 7:
|
|
457
|
+
case "end":
|
|
458
|
+
return _context13.stop();
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
}, _callee13, undefined);
|
|
462
|
+
}));
|
|
463
|
+
|
|
464
|
+
return function (_x42, _x43, _x44, _x45) {
|
|
465
|
+
return _ref25.apply(this, arguments);
|
|
466
|
+
};
|
|
467
|
+
}();
|
|
435
468
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@como/como-client",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.2",
|
|
4
4
|
"description": "Client module for Como's loaylty API",
|
|
5
5
|
"main": "src/como.js",
|
|
6
6
|
"scripts": {
|
|
@@ -50,4 +50,4 @@
|
|
|
50
50
|
"webpack": "^4.8.3",
|
|
51
51
|
"webpack-cli": "^2.1.4"
|
|
52
52
|
}
|
|
53
|
-
}
|
|
53
|
+
}
|
package/src/como.js
CHANGED
|
@@ -392,6 +392,32 @@ class Como {
|
|
|
392
392
|
}
|
|
393
393
|
}
|
|
394
394
|
|
|
395
|
+
/**
|
|
396
|
+
* Social login via Firebase SSO (Google/Facebook/Apple).
|
|
397
|
+
* @param {Object} params
|
|
398
|
+
* @param {string} params.socialId - Firebase user UID
|
|
399
|
+
* @param {string} params.provider - Social provider (google/facebook/apple)
|
|
400
|
+
* @param {string} params.idToken - Firebase ID token
|
|
401
|
+
* @returns {Promise<Object>} { success, accessToken, refreshToken, consent } or { success: false, userExists: false }
|
|
402
|
+
*/
|
|
403
|
+
async socialLogin({ socialId, provider, idToken }) {
|
|
404
|
+
const { api } = this.comoData;
|
|
405
|
+
try {
|
|
406
|
+
const data = await api.socialLogin(socialId, provider, idToken);
|
|
407
|
+
return data;
|
|
408
|
+
} catch (error) {
|
|
409
|
+
if (error.response && error.response.data) {
|
|
410
|
+
const { code, message } = error.response.data;
|
|
411
|
+
throw new Error(code || message);
|
|
412
|
+
}
|
|
413
|
+
throw error;
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
async socialLoginCheck({ socialId, provider, idToken }) {
|
|
418
|
+
return this.socialLogin({ socialId, provider, idToken });
|
|
419
|
+
}
|
|
420
|
+
|
|
395
421
|
/**
|
|
396
422
|
*
|
|
397
423
|
* @param {Object} identifier key-value identifiers
|
|
@@ -834,7 +860,11 @@ class Como {
|
|
|
834
860
|
/**
|
|
835
861
|
* Returns the location specific friend referral web url
|
|
836
862
|
*/
|
|
837
|
-
getFriendReferralInviteLink(referral) {
|
|
863
|
+
getFriendReferralInviteLink(referral) {
|
|
864
|
+
const { env_params: env, locationId } = this.comoData;
|
|
865
|
+
const cpBaseUrl = env.cp_base_url.replace('{location_id}', locationId);
|
|
866
|
+
return `${cpBaseUrl}/auth/register?onboardingflow=register&ReferralCode=${referral}`;
|
|
867
|
+
}
|
|
838
868
|
|
|
839
869
|
/**
|
|
840
870
|
* Return the location state
|