@como/como-client 0.1.5 → 0.1.9-1.1
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/README.md +14 -0
- package/index.js +3 -0
- package/lib/como.js +2120 -489
- package/lib/config/env.js +19 -5
- package/lib/constants/resourceNames.js +3 -0
- package/lib/interceptors/refresh.js +92 -36
- package/lib/interceptors/response.js +46 -0
- package/lib/services/auth.service.js +212 -46
- package/lib/services/form.service.js +96 -0
- package/lib/services/index.js +25 -12
- package/lib/services/log.service.js +332 -0
- package/lib/services/loyalty.service.js +769 -14
- package/lib/services/ssr.service.js +75 -0
- package/lib/utils/comoExternalUrlTranslator.js +242 -0
- package/lib/utils/urls.js +27 -0
- package/package.json +15 -5
- package/src/como.js +930 -0
- package/.babelrc +0 -15
- package/.eslintignore +0 -1
- package/.eslintrc +0 -46
- package/.npmrc-publish +0 -4
- package/.vscode/launch.json +0 -14
- package/como.js +0 -413
- package/webpack.config.js +0 -13
- package/yarn.lock +0 -5026
package/lib/config/env.js
CHANGED
|
@@ -2,21 +2,35 @@
|
|
|
2
2
|
|
|
3
3
|
module.exports = {
|
|
4
4
|
hotfix: {
|
|
5
|
-
gateway: 'https://janua-
|
|
5
|
+
gateway: 'https://janua-env.como.com',
|
|
6
6
|
zapp_root: 'loyalty-zapp',
|
|
7
7
|
services_root: 'loyalty-services',
|
|
8
|
-
|
|
8
|
+
services_root_cdn: 'https://static.comoqa.como.com',
|
|
9
|
+
app_modules_root: 'https://janua-env.como.com/app-modules',
|
|
10
|
+
app_modules_legacy_root: 'https://appmodules-hotfix.como.com'
|
|
9
11
|
},
|
|
10
12
|
qa: {
|
|
11
13
|
gateway: 'https://janua-dev.como.com',
|
|
12
14
|
zapp_root: 'loyalty-zapp',
|
|
13
15
|
services_root: 'loyalty-services',
|
|
14
|
-
|
|
16
|
+
services_root_cdn: 'https://static.comoqa.como.com',
|
|
17
|
+
app_modules_root: 'https://janua-dev.como.com/app-modules',
|
|
18
|
+
app_modules_legacy_root: 'https://appmodules-qa.como.com'
|
|
15
19
|
},
|
|
16
20
|
prod: {
|
|
17
|
-
gateway: 'https://janua
|
|
21
|
+
gateway: 'https://janua.como.com',
|
|
22
|
+
zapp_root: 'loyalty-zapp',
|
|
23
|
+
services_root: 'loyalty-services',
|
|
24
|
+
services_root_cdn: 'https://static.prod.como.com',
|
|
25
|
+
app_modules_root: 'https://janua.como.com/app-modules',
|
|
26
|
+
app_modules_legacy_root: 'https://appmodules-prod.como.com'
|
|
27
|
+
},
|
|
28
|
+
test: {
|
|
29
|
+
gateway: 'https://janua-env.como.com',
|
|
18
30
|
zapp_root: 'loyalty-zapp',
|
|
19
31
|
services_root: 'loyalty-services',
|
|
20
|
-
|
|
32
|
+
services_root_cdn: 'https://static.comoqa.como.com',
|
|
33
|
+
app_modules_root: 'https://janua-env.como.com/app-modules',
|
|
34
|
+
app_modules_legacy_root: 'https://appmodules-qa.como.com'
|
|
21
35
|
}
|
|
22
36
|
};
|
|
@@ -14,32 +14,81 @@ var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
|
|
|
14
14
|
|
|
15
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
16
|
|
|
17
|
+
var moment = require('moment-timezone');
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Checks if the given date format is before current date.
|
|
21
|
+
*
|
|
22
|
+
* @param {string} expires date format
|
|
23
|
+
*/
|
|
24
|
+
var isExpired = function isExpired(expires) {
|
|
25
|
+
return moment(expires).isBefore(moment());
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Returns a bearer token http request header
|
|
30
|
+
*
|
|
31
|
+
* @param {string} token
|
|
32
|
+
*/
|
|
33
|
+
var authHeader = function authHeader(token) {
|
|
34
|
+
return { Authorization: 'Bearer ' + token };
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Request interceptor which handles token expiry, and token header is present.
|
|
39
|
+
*
|
|
40
|
+
* @param {func} getCredentials a callback returning the current active session credentials
|
|
41
|
+
* @param {func} refresher an api call to use the refresh token and get new credentials
|
|
42
|
+
*/
|
|
17
43
|
/* eslint-disable no-param-reassign */
|
|
18
|
-
exports.tokenInterceptor = function (getCredentials) {
|
|
44
|
+
exports.tokenInterceptor = function (getCredentials, refresher) {
|
|
19
45
|
return function () {
|
|
20
46
|
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(config) {
|
|
21
|
-
var _getCredentials,
|
|
47
|
+
var _getCredentials, expiresIn, _getCredentials2, accessToken;
|
|
22
48
|
|
|
23
49
|
return _regenerator2.default.wrap(function _callee$(_context) {
|
|
24
50
|
while (1) {
|
|
25
51
|
switch (_context.prev = _context.next) {
|
|
26
52
|
case 0:
|
|
27
|
-
_getCredentials = getCredentials(),
|
|
53
|
+
_getCredentials = getCredentials(), expiresIn = _getCredentials.expiresIn;
|
|
54
|
+
|
|
55
|
+
if (!(expiresIn && isExpired(expiresIn))) {
|
|
56
|
+
_context.next = 11;
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
_context.prev = 2;
|
|
61
|
+
_context.next = 5;
|
|
62
|
+
return refresher();
|
|
28
63
|
|
|
29
|
-
|
|
30
|
-
|
|
64
|
+
case 5:
|
|
65
|
+
_context.next = 11;
|
|
66
|
+
break;
|
|
67
|
+
|
|
68
|
+
case 7:
|
|
69
|
+
_context.prev = 7;
|
|
70
|
+
_context.t0 = _context['catch'](2);
|
|
71
|
+
|
|
72
|
+
console.log(_context.t0);
|
|
73
|
+
throw new Error('Could not refresh token');
|
|
74
|
+
|
|
75
|
+
case 11:
|
|
76
|
+
_getCredentials2 = getCredentials(), accessToken = _getCredentials2.accessToken;
|
|
77
|
+
|
|
78
|
+
if (accessToken) {
|
|
79
|
+
config.headers = (0, _extends3.default)({}, config.headers, authHeader(accessToken));
|
|
31
80
|
} else if (config.headers.Authorization) {
|
|
32
81
|
delete config.headers.Authorization;
|
|
33
82
|
}
|
|
34
83
|
|
|
35
84
|
return _context.abrupt('return', config);
|
|
36
85
|
|
|
37
|
-
case
|
|
86
|
+
case 14:
|
|
38
87
|
case 'end':
|
|
39
88
|
return _context.stop();
|
|
40
89
|
}
|
|
41
90
|
}
|
|
42
|
-
}, _callee, undefined);
|
|
91
|
+
}, _callee, undefined, [[2, 7]]);
|
|
43
92
|
}));
|
|
44
93
|
|
|
45
94
|
return function (_x) {
|
|
@@ -48,6 +97,12 @@ exports.tokenInterceptor = function (getCredentials) {
|
|
|
48
97
|
}();
|
|
49
98
|
};
|
|
50
99
|
|
|
100
|
+
/**
|
|
101
|
+
* Response failed interceptor handles token expiry and refreshes it
|
|
102
|
+
*
|
|
103
|
+
* @param {func} refresher an api call to use the refresh token and get new credentials
|
|
104
|
+
* @param {Object} service request handler
|
|
105
|
+
*/
|
|
51
106
|
/* eslint-disable no-param-reassign */
|
|
52
107
|
exports.refreshInterceptor = function (refresher, service) {
|
|
53
108
|
return function () {
|
|
@@ -57,59 +112,60 @@ exports.refreshInterceptor = function (refresher, service) {
|
|
|
57
112
|
while (1) {
|
|
58
113
|
switch (_context2.prev = _context2.next) {
|
|
59
114
|
case 0:
|
|
60
|
-
if (!
|
|
61
|
-
_context2.next =
|
|
115
|
+
if (!error.response) {
|
|
116
|
+
_context2.next = 5;
|
|
62
117
|
break;
|
|
63
118
|
}
|
|
64
119
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
case 2:
|
|
68
|
-
config = error.config;
|
|
69
|
-
|
|
70
|
-
if (!config._retry) {
|
|
71
|
-
_context2.next = 5;
|
|
120
|
+
if (error.response.headers['janua-token-expired']) {
|
|
121
|
+
_context2.next = 3;
|
|
72
122
|
break;
|
|
73
123
|
}
|
|
74
124
|
|
|
75
|
-
throw
|
|
125
|
+
throw error;
|
|
126
|
+
|
|
127
|
+
case 3:
|
|
128
|
+
_context2.next = 6;
|
|
129
|
+
break;
|
|
76
130
|
|
|
77
131
|
case 5:
|
|
78
|
-
|
|
132
|
+
throw error;
|
|
79
133
|
|
|
80
|
-
|
|
81
|
-
|
|
134
|
+
case 6:
|
|
135
|
+
config = error.config;
|
|
136
|
+
_context2.prev = 7;
|
|
137
|
+
_context2.next = 10;
|
|
82
138
|
return refresher();
|
|
83
139
|
|
|
84
|
-
case
|
|
85
|
-
_context2.next =
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
case 11:
|
|
89
|
-
res = _context2.sent;
|
|
90
|
-
return _context2.abrupt('return', res);
|
|
140
|
+
case 10:
|
|
141
|
+
_context2.next = 16;
|
|
142
|
+
break;
|
|
91
143
|
|
|
92
|
-
case
|
|
93
|
-
_context2.prev =
|
|
94
|
-
_context2.t0 = _context2['catch'](
|
|
144
|
+
case 12:
|
|
145
|
+
_context2.prev = 12;
|
|
146
|
+
_context2.t0 = _context2['catch'](7);
|
|
95
147
|
|
|
96
148
|
console.log(_context2.t0);
|
|
97
149
|
throw new Error('Could not refresh token');
|
|
98
150
|
|
|
99
|
-
case
|
|
151
|
+
case 16:
|
|
152
|
+
_context2.next = 18;
|
|
153
|
+
return service.request(config);
|
|
154
|
+
|
|
155
|
+
case 18:
|
|
156
|
+
res = _context2.sent;
|
|
157
|
+
return _context2.abrupt('return', res);
|
|
158
|
+
|
|
159
|
+
case 20:
|
|
100
160
|
case 'end':
|
|
101
161
|
return _context2.stop();
|
|
102
162
|
}
|
|
103
163
|
}
|
|
104
|
-
}, _callee2, undefined, [[
|
|
164
|
+
}, _callee2, undefined, [[7, 12]]);
|
|
105
165
|
}));
|
|
106
166
|
|
|
107
167
|
return function (_x2) {
|
|
108
168
|
return _ref2.apply(this, arguments);
|
|
109
169
|
};
|
|
110
170
|
}();
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
var authHeader = function authHeader(token) {
|
|
114
|
-
return { Authorization: 'Bearer ' + token };
|
|
115
171
|
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _regenerator = require('babel-runtime/regenerator');
|
|
4
|
+
|
|
5
|
+
var _regenerator2 = _interopRequireDefault(_regenerator);
|
|
6
|
+
|
|
7
|
+
var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');
|
|
8
|
+
|
|
9
|
+
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
|
|
10
|
+
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Response success interceptor which handles refresh session credentials
|
|
15
|
+
*
|
|
16
|
+
* @param {func} credentialsRefresh a callback which refreshes the current session credentials
|
|
17
|
+
*/
|
|
18
|
+
exports.responseInterceptor = function (credentialsRefresh) {
|
|
19
|
+
return function () {
|
|
20
|
+
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(response) {
|
|
21
|
+
var _response$data, accessToken, refreshToken, expiresIn;
|
|
22
|
+
|
|
23
|
+
return _regenerator2.default.wrap(function _callee$(_context) {
|
|
24
|
+
while (1) {
|
|
25
|
+
switch (_context.prev = _context.next) {
|
|
26
|
+
case 0:
|
|
27
|
+
if (response.headers['janua-token-modified']) {
|
|
28
|
+
_response$data = response.data, accessToken = _response$data.accessToken, refreshToken = _response$data.refreshToken, expiresIn = _response$data.expiresIn;
|
|
29
|
+
|
|
30
|
+
credentialsRefresh({ accessToken: accessToken, refreshToken: refreshToken, expiresIn: expiresIn }, true);
|
|
31
|
+
}
|
|
32
|
+
return _context.abrupt('return', response);
|
|
33
|
+
|
|
34
|
+
case 2:
|
|
35
|
+
case 'end':
|
|
36
|
+
return _context.stop();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}, _callee, undefined);
|
|
40
|
+
}));
|
|
41
|
+
|
|
42
|
+
return function (_x) {
|
|
43
|
+
return _ref.apply(this, arguments);
|
|
44
|
+
};
|
|
45
|
+
}();
|
|
46
|
+
};
|
|
@@ -12,16 +12,16 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
12
12
|
|
|
13
13
|
exports.signOn = function (service) {
|
|
14
14
|
return function () {
|
|
15
|
-
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(deviceId, locationId) {
|
|
15
|
+
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(deviceId, locationId, refreshToken, source) {
|
|
16
16
|
var params, _ref2, data;
|
|
17
17
|
|
|
18
18
|
return _regenerator2.default.wrap(function _callee$(_context) {
|
|
19
19
|
while (1) {
|
|
20
20
|
switch (_context.prev = _context.next) {
|
|
21
21
|
case 0:
|
|
22
|
-
params = { deviceId: deviceId, locationId: locationId };
|
|
22
|
+
params = { deviceId: deviceId, locationId: locationId, refreshToken: refreshToken, source: source };
|
|
23
23
|
_context.next = 3;
|
|
24
|
-
return service.post('/
|
|
24
|
+
return service.post('/auth/v2/auth/signOn', params);
|
|
25
25
|
|
|
26
26
|
case 3:
|
|
27
27
|
_ref2 = _context.sent;
|
|
@@ -36,31 +36,32 @@ exports.signOn = function (service) {
|
|
|
36
36
|
}, _callee, undefined);
|
|
37
37
|
}));
|
|
38
38
|
|
|
39
|
-
return function (_x, _x2) {
|
|
39
|
+
return function (_x, _x2, _x3, _x4) {
|
|
40
40
|
return _ref.apply(this, arguments);
|
|
41
41
|
};
|
|
42
42
|
}();
|
|
43
43
|
};
|
|
44
44
|
|
|
45
|
-
exports.
|
|
45
|
+
exports.register = function (service) {
|
|
46
46
|
return function () {
|
|
47
|
-
var _ref3 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee2(
|
|
48
|
-
var
|
|
47
|
+
var _ref3 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee2(form, verification, reCaptchaToken) {
|
|
48
|
+
var source = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'App';
|
|
49
|
+
|
|
50
|
+
var _ref4, data;
|
|
49
51
|
|
|
50
52
|
return _regenerator2.default.wrap(function _callee2$(_context2) {
|
|
51
53
|
while (1) {
|
|
52
54
|
switch (_context2.prev = _context2.next) {
|
|
53
55
|
case 0:
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return service.post('/v1/auth/logIn', params);
|
|
56
|
+
_context2.next = 2;
|
|
57
|
+
return service.post('/auth/v1/registration', { form: form, verification: verification, reCaptchaToken: reCaptchaToken, source: source });
|
|
57
58
|
|
|
58
|
-
case
|
|
59
|
+
case 2:
|
|
59
60
|
_ref4 = _context2.sent;
|
|
60
61
|
data = _ref4.data;
|
|
61
62
|
return _context2.abrupt('return', data);
|
|
62
63
|
|
|
63
|
-
case
|
|
64
|
+
case 5:
|
|
64
65
|
case 'end':
|
|
65
66
|
return _context2.stop();
|
|
66
67
|
}
|
|
@@ -68,26 +69,24 @@ exports.logIn = function (service) {
|
|
|
68
69
|
}, _callee2, undefined);
|
|
69
70
|
}));
|
|
70
71
|
|
|
71
|
-
return function (
|
|
72
|
+
return function (_x5, _x6, _x7) {
|
|
72
73
|
return _ref3.apply(this, arguments);
|
|
73
74
|
};
|
|
74
75
|
}();
|
|
75
76
|
};
|
|
76
77
|
|
|
77
|
-
exports.
|
|
78
|
+
exports.registerVerify = function (service) {
|
|
78
79
|
return function () {
|
|
79
|
-
var _ref5 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee3(
|
|
80
|
-
var
|
|
80
|
+
var _ref5 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee3(verification, type, form, reCaptchaToken) {
|
|
81
|
+
var body, _ref6, data;
|
|
81
82
|
|
|
82
83
|
return _regenerator2.default.wrap(function _callee3$(_context3) {
|
|
83
84
|
while (1) {
|
|
84
85
|
switch (_context3.prev = _context3.next) {
|
|
85
86
|
case 0:
|
|
86
|
-
|
|
87
|
-
code: code, type: type, identifier: identifier
|
|
88
|
-
};
|
|
87
|
+
body = { verification: verification, type: type, form: form, reCaptchaToken: reCaptchaToken };
|
|
89
88
|
_context3.next = 3;
|
|
90
|
-
return service.post('/v1/
|
|
89
|
+
return service.post('/auth/v1/registration/verify', body);
|
|
91
90
|
|
|
92
91
|
case 3:
|
|
93
92
|
_ref6 = _context3.sent;
|
|
@@ -102,49 +101,59 @@ exports.logInVerify = function (service) {
|
|
|
102
101
|
}, _callee3, undefined);
|
|
103
102
|
}));
|
|
104
103
|
|
|
105
|
-
return function (
|
|
104
|
+
return function (_x9, _x10, _x11, _x12) {
|
|
106
105
|
return _ref5.apply(this, arguments);
|
|
107
106
|
};
|
|
108
107
|
}();
|
|
109
108
|
};
|
|
110
109
|
|
|
111
|
-
exports.
|
|
112
|
-
return
|
|
113
|
-
var
|
|
110
|
+
exports.updateProfile = function (service) {
|
|
111
|
+
return function () {
|
|
112
|
+
var _ref7 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee4(form, reCaptchaToken) {
|
|
113
|
+
var source = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'App';
|
|
114
114
|
|
|
115
|
-
|
|
116
|
-
while (1) {
|
|
117
|
-
switch (_context4.prev = _context4.next) {
|
|
118
|
-
case 0:
|
|
119
|
-
_context4.next = 2;
|
|
120
|
-
return service.post('/v1/auth/logOut');
|
|
115
|
+
var _ref8, data;
|
|
121
116
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
117
|
+
return _regenerator2.default.wrap(function _callee4$(_context4) {
|
|
118
|
+
while (1) {
|
|
119
|
+
switch (_context4.prev = _context4.next) {
|
|
120
|
+
case 0:
|
|
121
|
+
_context4.next = 2;
|
|
122
|
+
return service.post('/auth/v1/update-profile', { form: form, source: source, reCaptchaToken: reCaptchaToken });
|
|
126
123
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
124
|
+
case 2:
|
|
125
|
+
_ref8 = _context4.sent;
|
|
126
|
+
data = _ref8.data;
|
|
127
|
+
return _context4.abrupt('return', data);
|
|
128
|
+
|
|
129
|
+
case 5:
|
|
130
|
+
case 'end':
|
|
131
|
+
return _context4.stop();
|
|
132
|
+
}
|
|
130
133
|
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
+
}, _callee4, undefined);
|
|
135
|
+
}));
|
|
136
|
+
|
|
137
|
+
return function (_x13, _x14) {
|
|
138
|
+
return _ref7.apply(this, arguments);
|
|
139
|
+
};
|
|
140
|
+
}();
|
|
134
141
|
};
|
|
135
142
|
|
|
136
|
-
exports.
|
|
143
|
+
exports.updateProfileVerify = function (service) {
|
|
137
144
|
return function () {
|
|
138
|
-
var _ref9 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee5(
|
|
139
|
-
var
|
|
145
|
+
var _ref9 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee5(code, type, form, reCaptchaToken) {
|
|
146
|
+
var source = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 'App';
|
|
147
|
+
|
|
148
|
+
var body, _ref10, data;
|
|
140
149
|
|
|
141
150
|
return _regenerator2.default.wrap(function _callee5$(_context5) {
|
|
142
151
|
while (1) {
|
|
143
152
|
switch (_context5.prev = _context5.next) {
|
|
144
153
|
case 0:
|
|
145
|
-
|
|
154
|
+
body = { code: code, type: type, form: form, source: source, reCaptchaToken: reCaptchaToken };
|
|
146
155
|
_context5.next = 3;
|
|
147
|
-
return service.post('/v1/
|
|
156
|
+
return service.post('/auth/v1/update-profile/verify', body);
|
|
148
157
|
|
|
149
158
|
case 3:
|
|
150
159
|
_ref10 = _context5.sent;
|
|
@@ -159,8 +168,165 @@ exports.refreshToken = function (service) {
|
|
|
159
168
|
}, _callee5, undefined);
|
|
160
169
|
}));
|
|
161
170
|
|
|
162
|
-
return function (
|
|
171
|
+
return function (_x16, _x17, _x18, _x19) {
|
|
163
172
|
return _ref9.apply(this, arguments);
|
|
164
173
|
};
|
|
165
174
|
}();
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
exports.unsubscribeSms = function (service) {
|
|
178
|
+
return function () {
|
|
179
|
+
var _ref11 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee6(locationId, identifier) {
|
|
180
|
+
var body, _ref12, data;
|
|
181
|
+
|
|
182
|
+
return _regenerator2.default.wrap(function _callee6$(_context6) {
|
|
183
|
+
while (1) {
|
|
184
|
+
switch (_context6.prev = _context6.next) {
|
|
185
|
+
case 0:
|
|
186
|
+
body = { locationId: locationId, identifier: identifier };
|
|
187
|
+
_context6.next = 3;
|
|
188
|
+
return service.post('/auth/v1/update-profile/unsubscribeSms', body);
|
|
189
|
+
|
|
190
|
+
case 3:
|
|
191
|
+
_ref12 = _context6.sent;
|
|
192
|
+
data = _ref12.data;
|
|
193
|
+
return _context6.abrupt('return', data);
|
|
194
|
+
|
|
195
|
+
case 6:
|
|
196
|
+
case 'end':
|
|
197
|
+
return _context6.stop();
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}, _callee6, undefined);
|
|
201
|
+
}));
|
|
202
|
+
|
|
203
|
+
return function (_x21, _x22) {
|
|
204
|
+
return _ref11.apply(this, arguments);
|
|
205
|
+
};
|
|
206
|
+
}();
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
exports.logIn = function (service) {
|
|
210
|
+
return function () {
|
|
211
|
+
var _ref13 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee7(type, identifier) {
|
|
212
|
+
var params, _ref14, data;
|
|
213
|
+
|
|
214
|
+
return _regenerator2.default.wrap(function _callee7$(_context7) {
|
|
215
|
+
while (1) {
|
|
216
|
+
switch (_context7.prev = _context7.next) {
|
|
217
|
+
case 0:
|
|
218
|
+
params = { type: type, identifier: identifier };
|
|
219
|
+
_context7.next = 3;
|
|
220
|
+
return service.post('/auth/v1/auth/logIn', params);
|
|
221
|
+
|
|
222
|
+
case 3:
|
|
223
|
+
_ref14 = _context7.sent;
|
|
224
|
+
data = _ref14.data;
|
|
225
|
+
return _context7.abrupt('return', data);
|
|
226
|
+
|
|
227
|
+
case 6:
|
|
228
|
+
case 'end':
|
|
229
|
+
return _context7.stop();
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}, _callee7, undefined);
|
|
233
|
+
}));
|
|
234
|
+
|
|
235
|
+
return function (_x23, _x24) {
|
|
236
|
+
return _ref13.apply(this, arguments);
|
|
237
|
+
};
|
|
238
|
+
}();
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
exports.logInVerify = function (service) {
|
|
242
|
+
return function () {
|
|
243
|
+
var _ref15 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee8(code, type, identifier) {
|
|
244
|
+
var params, _ref16, data;
|
|
245
|
+
|
|
246
|
+
return _regenerator2.default.wrap(function _callee8$(_context8) {
|
|
247
|
+
while (1) {
|
|
248
|
+
switch (_context8.prev = _context8.next) {
|
|
249
|
+
case 0:
|
|
250
|
+
params = {
|
|
251
|
+
identifier: identifier,
|
|
252
|
+
code: code,
|
|
253
|
+
type: type
|
|
254
|
+
};
|
|
255
|
+
_context8.next = 3;
|
|
256
|
+
return service.post('/auth/v1/auth/logInVerify', params);
|
|
257
|
+
|
|
258
|
+
case 3:
|
|
259
|
+
_ref16 = _context8.sent;
|
|
260
|
+
data = _ref16.data;
|
|
261
|
+
return _context8.abrupt('return', data);
|
|
262
|
+
|
|
263
|
+
case 6:
|
|
264
|
+
case 'end':
|
|
265
|
+
return _context8.stop();
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}, _callee8, undefined);
|
|
269
|
+
}));
|
|
270
|
+
|
|
271
|
+
return function (_x25, _x26, _x27) {
|
|
272
|
+
return _ref15.apply(this, arguments);
|
|
273
|
+
};
|
|
274
|
+
}();
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
exports.logOut = function (service) {
|
|
278
|
+
return (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee9() {
|
|
279
|
+
var _ref18, data;
|
|
280
|
+
|
|
281
|
+
return _regenerator2.default.wrap(function _callee9$(_context9) {
|
|
282
|
+
while (1) {
|
|
283
|
+
switch (_context9.prev = _context9.next) {
|
|
284
|
+
case 0:
|
|
285
|
+
_context9.next = 2;
|
|
286
|
+
return service.post('/auth/v1/auth/logOut');
|
|
287
|
+
|
|
288
|
+
case 2:
|
|
289
|
+
_ref18 = _context9.sent;
|
|
290
|
+
data = _ref18.data;
|
|
291
|
+
return _context9.abrupt('return', data);
|
|
292
|
+
|
|
293
|
+
case 5:
|
|
294
|
+
case 'end':
|
|
295
|
+
return _context9.stop();
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}, _callee9, undefined);
|
|
299
|
+
}));
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
exports.refreshToken = function (service, source) {
|
|
303
|
+
return function () {
|
|
304
|
+
var _ref19 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee10(uid, token, locationId) {
|
|
305
|
+
var params, _ref20, data;
|
|
306
|
+
|
|
307
|
+
return _regenerator2.default.wrap(function _callee10$(_context10) {
|
|
308
|
+
while (1) {
|
|
309
|
+
switch (_context10.prev = _context10.next) {
|
|
310
|
+
case 0:
|
|
311
|
+
params = { uid: uid, refreshToken: token, source: source, locationId: locationId };
|
|
312
|
+
_context10.next = 3;
|
|
313
|
+
return service.post('/auth/v2/auth/refresh-token', params);
|
|
314
|
+
|
|
315
|
+
case 3:
|
|
316
|
+
_ref20 = _context10.sent;
|
|
317
|
+
data = _ref20.data;
|
|
318
|
+
return _context10.abrupt('return', data);
|
|
319
|
+
|
|
320
|
+
case 6:
|
|
321
|
+
case 'end':
|
|
322
|
+
return _context10.stop();
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}, _callee10, undefined);
|
|
326
|
+
}));
|
|
327
|
+
|
|
328
|
+
return function (_x28, _x29, _x30) {
|
|
329
|
+
return _ref19.apply(this, arguments);
|
|
330
|
+
};
|
|
331
|
+
}();
|
|
166
332
|
};
|