@como/como-client 0.7.0 → 0.7.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/lib/como.js +22 -3
- package/lib/services/auth.service.js +18 -14
- package/package.json +1 -1
- package/src/como.js +9 -0
package/lib/como.js
CHANGED
|
@@ -223,7 +223,7 @@ var Como = function () {
|
|
|
223
223
|
interval = 0;
|
|
224
224
|
|
|
225
225
|
if (!(refreshFailed || !credExist)) {
|
|
226
|
-
_context2.next =
|
|
226
|
+
_context2.next = 51;
|
|
227
227
|
break;
|
|
228
228
|
}
|
|
229
229
|
|
|
@@ -262,17 +262,36 @@ var Como = function () {
|
|
|
262
262
|
break;
|
|
263
263
|
|
|
264
264
|
case 49:
|
|
265
|
+
_context2.next = 59;
|
|
266
|
+
break;
|
|
267
|
+
|
|
268
|
+
case 51:
|
|
269
|
+
_context2.prev = 51;
|
|
270
|
+
_context2.next = 54;
|
|
271
|
+
return this.comoData.initApi.signOn(installationId, locationId, source, accessToken);
|
|
272
|
+
|
|
273
|
+
case 54:
|
|
274
|
+
_context2.next = 59;
|
|
275
|
+
break;
|
|
276
|
+
|
|
277
|
+
case 56:
|
|
278
|
+
_context2.prev = 56;
|
|
279
|
+
_context2.t2 = _context2['catch'](51);
|
|
280
|
+
|
|
281
|
+
console.log('Failed signOn with accessToken, installationId:' + installationId + ', locationId:' + locationId + ', source:' + source + ',accessToken:' + accessToken + ', error:' + _context2.t2);
|
|
282
|
+
|
|
283
|
+
case 59:
|
|
265
284
|
if (!this.comoData.token) {
|
|
266
285
|
this.comoData.token = this.comoData.accessToken;
|
|
267
286
|
}
|
|
268
287
|
return _context2.abrupt('return', this.getCredentials());
|
|
269
288
|
|
|
270
|
-
case
|
|
289
|
+
case 61:
|
|
271
290
|
case 'end':
|
|
272
291
|
return _context2.stop();
|
|
273
292
|
}
|
|
274
293
|
}
|
|
275
|
-
}, _callee2, this, [[17, 24], [32, 40]]);
|
|
294
|
+
}, _callee2, this, [[17, 24], [32, 40], [51, 56]]);
|
|
276
295
|
}));
|
|
277
296
|
|
|
278
297
|
function init(_x, _x2, _x3) {
|
|
@@ -27,24 +27,28 @@ 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 " + token;
|
|
42
|
+
}
|
|
43
|
+
_context.next = 5;
|
|
40
44
|
return service.post('/auth/v2/auth/signOn', params, { headers: headers });
|
|
41
45
|
|
|
42
|
-
case
|
|
46
|
+
case 5:
|
|
43
47
|
_ref2 = _context.sent;
|
|
44
48
|
data = _ref2.data;
|
|
45
49
|
return _context.abrupt("return", data);
|
|
46
50
|
|
|
47
|
-
case
|
|
51
|
+
case 8:
|
|
48
52
|
case "end":
|
|
49
53
|
return _context.stop();
|
|
50
54
|
}
|
|
@@ -52,7 +56,7 @@ exports.signOn = function (service) {
|
|
|
52
56
|
}, _callee, undefined);
|
|
53
57
|
}));
|
|
54
58
|
|
|
55
|
-
return function (_x, _x2, _x3) {
|
|
59
|
+
return function (_x, _x2, _x3, _x4) {
|
|
56
60
|
return _ref.apply(this, arguments);
|
|
57
61
|
};
|
|
58
62
|
}();
|
|
@@ -85,7 +89,7 @@ exports.register = function (service) {
|
|
|
85
89
|
}, _callee2, undefined);
|
|
86
90
|
}));
|
|
87
91
|
|
|
88
|
-
return function (
|
|
92
|
+
return function (_x5, _x6, _x7) {
|
|
89
93
|
return _ref3.apply(this, arguments);
|
|
90
94
|
};
|
|
91
95
|
}();
|
|
@@ -117,7 +121,7 @@ exports.registerVerify = function (service) {
|
|
|
117
121
|
}, _callee3, undefined);
|
|
118
122
|
}));
|
|
119
123
|
|
|
120
|
-
return function (
|
|
124
|
+
return function (_x9, _x10, _x11, _x12) {
|
|
121
125
|
return _ref5.apply(this, arguments);
|
|
122
126
|
};
|
|
123
127
|
}();
|
|
@@ -150,7 +154,7 @@ exports.updateProfile = function (service) {
|
|
|
150
154
|
}, _callee4, undefined);
|
|
151
155
|
}));
|
|
152
156
|
|
|
153
|
-
return function (
|
|
157
|
+
return function (_x13, _x14) {
|
|
154
158
|
return _ref7.apply(this, arguments);
|
|
155
159
|
};
|
|
156
160
|
}();
|
|
@@ -184,7 +188,7 @@ exports.updateProfileVerify = function (service) {
|
|
|
184
188
|
}, _callee5, undefined);
|
|
185
189
|
}));
|
|
186
190
|
|
|
187
|
-
return function (
|
|
191
|
+
return function (_x16, _x17, _x18, _x19) {
|
|
188
192
|
return _ref9.apply(this, arguments);
|
|
189
193
|
};
|
|
190
194
|
}();
|
|
@@ -216,7 +220,7 @@ exports.unsubscribeSms = function (service) {
|
|
|
216
220
|
}, _callee6, undefined);
|
|
217
221
|
}));
|
|
218
222
|
|
|
219
|
-
return function (
|
|
223
|
+
return function (_x21, _x22) {
|
|
220
224
|
return _ref11.apply(this, arguments);
|
|
221
225
|
};
|
|
222
226
|
}();
|
|
@@ -249,7 +253,7 @@ exports.logIn = function (service) {
|
|
|
249
253
|
}, _callee7, undefined);
|
|
250
254
|
}));
|
|
251
255
|
|
|
252
|
-
return function (
|
|
256
|
+
return function (_x23, _x24) {
|
|
253
257
|
return _ref13.apply(this, arguments);
|
|
254
258
|
};
|
|
255
259
|
}();
|
|
@@ -286,7 +290,7 @@ exports.logInVerify = function (service) {
|
|
|
286
290
|
}, _callee8, undefined);
|
|
287
291
|
}));
|
|
288
292
|
|
|
289
|
-
return function (
|
|
293
|
+
return function (_x25, _x26, _x27) {
|
|
290
294
|
return _ref15.apply(this, arguments);
|
|
291
295
|
};
|
|
292
296
|
}();
|
|
@@ -344,7 +348,7 @@ exports.refreshToken = function (service) {
|
|
|
344
348
|
}, _callee10, undefined);
|
|
345
349
|
}));
|
|
346
350
|
|
|
347
|
-
return function (
|
|
351
|
+
return function (_x28, _x29, _x30, _x31) {
|
|
348
352
|
return _ref19.apply(this, arguments);
|
|
349
353
|
};
|
|
350
354
|
}();
|
package/package.json
CHANGED
package/src/como.js
CHANGED
|
@@ -130,6 +130,15 @@ class Como {
|
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
|
+
else{
|
|
134
|
+
try{
|
|
135
|
+
await this.comoData.initApi.signOn(installationId, locationId, source, accessToken);
|
|
136
|
+
}catch(e){
|
|
137
|
+
console.log(`Failed signOn with accessToken, installationId:${installationId}, locationId:${locationId}, source:${source},accessToken:${accessToken}, error:${e}`);
|
|
138
|
+
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
}
|
|
133
142
|
if(!this.comoData.token){
|
|
134
143
|
this.comoData.token = this.comoData.accessToken;
|
|
135
144
|
}
|