@como/como-client 0.7.0 → 0.7.4
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 +36 -4
- package/lib/services/auth.service.js +21 -14
- package/package.json +1 -1
- package/src/como.js +13 -0
package/lib/como.js
CHANGED
|
@@ -4,6 +4,10 @@ var _keys = require('babel-runtime/core-js/object/keys');
|
|
|
4
4
|
|
|
5
5
|
var _keys2 = _interopRequireDefault(_keys);
|
|
6
6
|
|
|
7
|
+
var _stringify = require('babel-runtime/core-js/json/stringify');
|
|
8
|
+
|
|
9
|
+
var _stringify2 = _interopRequireDefault(_stringify);
|
|
10
|
+
|
|
7
11
|
var _promise = require('babel-runtime/core-js/promise');
|
|
8
12
|
|
|
9
13
|
var _promise2 = _interopRequireDefault(_promise);
|
|
@@ -144,7 +148,7 @@ var Como = function () {
|
|
|
144
148
|
|
|
145
149
|
var enableSignon = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
|
|
146
150
|
|
|
147
|
-
var isExists, environmentId, locationId, installationId, source, updateCredentials, getCredentials, gateway, _APIService$getServic, service, refresher, initService, accessToken, refreshToken, expiresIn, credExist, isExpired, refreshFailed, data, interval, _data;
|
|
151
|
+
var isExists, environmentId, locationId, installationId, source, updateCredentials, getCredentials, gateway, _APIService$getServic, service, refresher, initService, accessToken, refreshToken, expiresIn, credExist, isExpired, refreshFailed, data, interval, _data, _data2;
|
|
148
152
|
|
|
149
153
|
return _regenerator2.default.wrap(function _callee2$(_context2) {
|
|
150
154
|
while (1) {
|
|
@@ -223,7 +227,7 @@ var Como = function () {
|
|
|
223
227
|
interval = 0;
|
|
224
228
|
|
|
225
229
|
if (!(refreshFailed || !credExist)) {
|
|
226
|
-
_context2.next =
|
|
230
|
+
_context2.next = 51;
|
|
227
231
|
break;
|
|
228
232
|
}
|
|
229
233
|
|
|
@@ -262,17 +266,45 @@ var Como = function () {
|
|
|
262
266
|
break;
|
|
263
267
|
|
|
264
268
|
case 49:
|
|
269
|
+
_context2.next = 63;
|
|
270
|
+
break;
|
|
271
|
+
|
|
272
|
+
case 51:
|
|
273
|
+
_context2.prev = 51;
|
|
274
|
+
|
|
275
|
+
console.error('signOn with, installationId:' + installationId + ', locationId:' + locationId + ', source:' + source + ',accessToken:' + accessToken);
|
|
276
|
+
_context2.next = 55;
|
|
277
|
+
return this.comoData.initApi.signOn(installationId, locationId, source, accessToken);
|
|
278
|
+
|
|
279
|
+
case 55:
|
|
280
|
+
_data2 = _context2.sent;
|
|
281
|
+
|
|
282
|
+
console.error('signOn with result " ' + (0, _stringify2.default)(_data2));
|
|
283
|
+
if (_data2 && _data2.accessToken) {
|
|
284
|
+
console.error('signOn entered update credentials');
|
|
285
|
+
updateCredentials(_data2, true);
|
|
286
|
+
}
|
|
287
|
+
_context2.next = 63;
|
|
288
|
+
break;
|
|
289
|
+
|
|
290
|
+
case 60:
|
|
291
|
+
_context2.prev = 60;
|
|
292
|
+
_context2.t2 = _context2['catch'](51);
|
|
293
|
+
|
|
294
|
+
console.log('Failed signOn with accessToken, installationId:' + installationId + ', locationId:' + locationId + ', source:' + source + ',accessToken:' + accessToken + ', error:' + _context2.t2);
|
|
295
|
+
|
|
296
|
+
case 63:
|
|
265
297
|
if (!this.comoData.token) {
|
|
266
298
|
this.comoData.token = this.comoData.accessToken;
|
|
267
299
|
}
|
|
268
300
|
return _context2.abrupt('return', this.getCredentials());
|
|
269
301
|
|
|
270
|
-
case
|
|
302
|
+
case 65:
|
|
271
303
|
case 'end':
|
|
272
304
|
return _context2.stop();
|
|
273
305
|
}
|
|
274
306
|
}
|
|
275
|
-
}, _callee2, this, [[17, 24], [32, 40]]);
|
|
307
|
+
}, _callee2, this, [[17, 24], [32, 40], [51, 60]]);
|
|
276
308
|
}));
|
|
277
309
|
|
|
278
310
|
function init(_x, _x2, _x3) {
|
|
@@ -27,24 +27,31 @@ function getHashHeader(data) {
|
|
|
27
27
|
|
|
28
28
|
exports.signOn = function (service) {
|
|
29
29
|
return function () {
|
|
30
|
-
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(deviceId, locationId, source) {
|
|
30
|
+
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(deviceId, locationId, source, accessToken) {
|
|
31
31
|
var params, headers, _ref2, data;
|
|
32
32
|
|
|
33
33
|
return _regenerator2.default.wrap(function _callee$(_context) {
|
|
34
34
|
while (1) {
|
|
35
35
|
switch (_context.prev = _context.next) {
|
|
36
36
|
case 0:
|
|
37
|
-
params = { deviceId: deviceId, locationId: locationId, source: source };
|
|
37
|
+
params = { deviceId: deviceId, locationId: locationId, source: source, accessToken: accessToken };
|
|
38
38
|
headers = getHashHeader(params);
|
|
39
|
-
|
|
39
|
+
|
|
40
|
+
if (accessToken) {
|
|
41
|
+
headers['Authorization'] = "Bearer " + accessToken;
|
|
42
|
+
}
|
|
43
|
+
console.error("signOn(auth) with deviceId:" + deviceId + ", locationId:" + locationId + ", source:" + source + ",accessToken:" + accessToken + ", headers: " + headers);
|
|
44
|
+
_context.next = 6;
|
|
40
45
|
return service.post('/auth/v2/auth/signOn', params, { headers: headers });
|
|
41
46
|
|
|
42
|
-
case
|
|
47
|
+
case 6:
|
|
43
48
|
_ref2 = _context.sent;
|
|
44
49
|
data = _ref2.data;
|
|
50
|
+
|
|
51
|
+
console.error("signOn(auth) result with data:" + data);
|
|
45
52
|
return _context.abrupt("return", data);
|
|
46
53
|
|
|
47
|
-
case
|
|
54
|
+
case 10:
|
|
48
55
|
case "end":
|
|
49
56
|
return _context.stop();
|
|
50
57
|
}
|
|
@@ -52,7 +59,7 @@ exports.signOn = function (service) {
|
|
|
52
59
|
}, _callee, undefined);
|
|
53
60
|
}));
|
|
54
61
|
|
|
55
|
-
return function (_x, _x2, _x3) {
|
|
62
|
+
return function (_x, _x2, _x3, _x4) {
|
|
56
63
|
return _ref.apply(this, arguments);
|
|
57
64
|
};
|
|
58
65
|
}();
|
|
@@ -85,7 +92,7 @@ exports.register = function (service) {
|
|
|
85
92
|
}, _callee2, undefined);
|
|
86
93
|
}));
|
|
87
94
|
|
|
88
|
-
return function (
|
|
95
|
+
return function (_x5, _x6, _x7) {
|
|
89
96
|
return _ref3.apply(this, arguments);
|
|
90
97
|
};
|
|
91
98
|
}();
|
|
@@ -117,7 +124,7 @@ exports.registerVerify = function (service) {
|
|
|
117
124
|
}, _callee3, undefined);
|
|
118
125
|
}));
|
|
119
126
|
|
|
120
|
-
return function (
|
|
127
|
+
return function (_x9, _x10, _x11, _x12) {
|
|
121
128
|
return _ref5.apply(this, arguments);
|
|
122
129
|
};
|
|
123
130
|
}();
|
|
@@ -150,7 +157,7 @@ exports.updateProfile = function (service) {
|
|
|
150
157
|
}, _callee4, undefined);
|
|
151
158
|
}));
|
|
152
159
|
|
|
153
|
-
return function (
|
|
160
|
+
return function (_x13, _x14) {
|
|
154
161
|
return _ref7.apply(this, arguments);
|
|
155
162
|
};
|
|
156
163
|
}();
|
|
@@ -184,7 +191,7 @@ exports.updateProfileVerify = function (service) {
|
|
|
184
191
|
}, _callee5, undefined);
|
|
185
192
|
}));
|
|
186
193
|
|
|
187
|
-
return function (
|
|
194
|
+
return function (_x16, _x17, _x18, _x19) {
|
|
188
195
|
return _ref9.apply(this, arguments);
|
|
189
196
|
};
|
|
190
197
|
}();
|
|
@@ -216,7 +223,7 @@ exports.unsubscribeSms = function (service) {
|
|
|
216
223
|
}, _callee6, undefined);
|
|
217
224
|
}));
|
|
218
225
|
|
|
219
|
-
return function (
|
|
226
|
+
return function (_x21, _x22) {
|
|
220
227
|
return _ref11.apply(this, arguments);
|
|
221
228
|
};
|
|
222
229
|
}();
|
|
@@ -249,7 +256,7 @@ exports.logIn = function (service) {
|
|
|
249
256
|
}, _callee7, undefined);
|
|
250
257
|
}));
|
|
251
258
|
|
|
252
|
-
return function (
|
|
259
|
+
return function (_x23, _x24) {
|
|
253
260
|
return _ref13.apply(this, arguments);
|
|
254
261
|
};
|
|
255
262
|
}();
|
|
@@ -286,7 +293,7 @@ exports.logInVerify = function (service) {
|
|
|
286
293
|
}, _callee8, undefined);
|
|
287
294
|
}));
|
|
288
295
|
|
|
289
|
-
return function (
|
|
296
|
+
return function (_x25, _x26, _x27) {
|
|
290
297
|
return _ref15.apply(this, arguments);
|
|
291
298
|
};
|
|
292
299
|
}();
|
|
@@ -344,7 +351,7 @@ exports.refreshToken = function (service) {
|
|
|
344
351
|
}, _callee10, undefined);
|
|
345
352
|
}));
|
|
346
353
|
|
|
347
|
-
return function (
|
|
354
|
+
return function (_x28, _x29, _x30, _x31) {
|
|
348
355
|
return _ref19.apply(this, arguments);
|
|
349
356
|
};
|
|
350
357
|
}();
|
package/package.json
CHANGED
package/src/como.js
CHANGED
|
@@ -130,6 +130,19 @@ class Como {
|
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
|
+
else{
|
|
134
|
+
try{
|
|
135
|
+
console.error(`signOn with, installationId:${installationId}, locationId:${locationId}, source:${source},accessToken:${accessToken}`);
|
|
136
|
+
const data = await this.comoData.initApi.signOn(installationId, locationId, source, accessToken);
|
|
137
|
+
console.error(`signOn with result " ${JSON.stringify(data)}`);
|
|
138
|
+
if(data && data.accessToken){
|
|
139
|
+
console.error(`signOn entered update credentials`);
|
|
140
|
+
updateCredentials(data, true);
|
|
141
|
+
}
|
|
142
|
+
}catch(e){
|
|
143
|
+
console.log(`Failed signOn with accessToken, installationId:${installationId}, locationId:${locationId}, source:${source},accessToken:${accessToken}, error:${e}`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
133
146
|
if(!this.comoData.token){
|
|
134
147
|
this.comoData.token = this.comoData.accessToken;
|
|
135
148
|
}
|