@como/como-client 0.6.7 → 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 +62 -19
- package/lib/services/auth.service.js +18 -14
- package/lib/services/form.service.js +32 -0
- package/package.json +1 -1
- package/src/como.js +28 -7
package/lib/como.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var _promise = require('babel-runtime/core-js/promise');
|
|
4
|
-
|
|
5
|
-
var _promise2 = _interopRequireDefault(_promise);
|
|
6
|
-
|
|
7
3
|
var _keys = require('babel-runtime/core-js/object/keys');
|
|
8
4
|
|
|
9
5
|
var _keys2 = _interopRequireDefault(_keys);
|
|
10
6
|
|
|
7
|
+
var _promise = require('babel-runtime/core-js/promise');
|
|
8
|
+
|
|
9
|
+
var _promise2 = _interopRequireDefault(_promise);
|
|
10
|
+
|
|
11
11
|
var _extends2 = require('babel-runtime/helpers/extends');
|
|
12
12
|
|
|
13
13
|
var _extends3 = _interopRequireDefault(_extends2);
|
|
@@ -223,13 +223,13 @@ 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
|
|
|
230
230
|
case 31:
|
|
231
231
|
if (!(!credExist && interval < 3000)) {
|
|
232
|
-
_context2.next =
|
|
232
|
+
_context2.next = 49;
|
|
233
233
|
break;
|
|
234
234
|
}
|
|
235
235
|
|
|
@@ -242,34 +242,56 @@ var Como = function () {
|
|
|
242
242
|
|
|
243
243
|
updateCredentials(_data, true);
|
|
244
244
|
credExist = true;
|
|
245
|
-
_context2.next =
|
|
245
|
+
_context2.next = 47;
|
|
246
246
|
break;
|
|
247
247
|
|
|
248
248
|
case 40:
|
|
249
249
|
_context2.prev = 40;
|
|
250
250
|
_context2.t1 = _context2['catch'](32);
|
|
251
251
|
|
|
252
|
-
console.log('Failed to signOn, installationId:' + installationId + ', locationId:' + locationId + ', source:' + source + ', error:' + _context2.t1);
|
|
253
|
-
initService.logError({ method: 'signOn', installationId: installationId, locationId: locationId, source: source, refreshToken: refreshToken, interval: interval });
|
|
254
|
-
|
|
252
|
+
console.log('Failed to signOn, installationId:' + installationId + ', locationId:' + locationId + ', source:' + source + ',interval:' + interval + ', error:' + _context2.t1);
|
|
255
253
|
interval += 1000;
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
254
|
+
initService.logError({ method: 'signOn', installationId: installationId, locationId: locationId, source: source, refreshToken: refreshToken, interval: interval });
|
|
255
|
+
_context2.next = 47;
|
|
256
|
+
return new _promise2.default(function (r) {
|
|
257
|
+
return setTimeout(r, interval);
|
|
258
|
+
});
|
|
259
259
|
|
|
260
|
-
case
|
|
260
|
+
case 47:
|
|
261
261
|
_context2.next = 31;
|
|
262
262
|
break;
|
|
263
263
|
|
|
264
|
-
case
|
|
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:
|
|
284
|
+
if (!this.comoData.token) {
|
|
285
|
+
this.comoData.token = this.comoData.accessToken;
|
|
286
|
+
}
|
|
265
287
|
return _context2.abrupt('return', this.getCredentials());
|
|
266
288
|
|
|
267
|
-
case
|
|
289
|
+
case 61:
|
|
268
290
|
case 'end':
|
|
269
291
|
return _context2.stop();
|
|
270
292
|
}
|
|
271
293
|
}
|
|
272
|
-
}, _callee2, this, [[17, 24], [32, 40]]);
|
|
294
|
+
}, _callee2, this, [[17, 24], [32, 40], [51, 56]]);
|
|
273
295
|
}));
|
|
274
296
|
|
|
275
297
|
function init(_x, _x2, _x3) {
|
|
@@ -885,14 +907,21 @@ var Como = function () {
|
|
|
885
907
|
switch (_context14.prev = _context14.next) {
|
|
886
908
|
case 0:
|
|
887
909
|
_comoData7 = this.comoData, api = _comoData7.api, locationId = _comoData7.locationId, token = _comoData7.token, env = _comoData7.env_params;
|
|
910
|
+
_context14.prev = 1;
|
|
888
911
|
return _context14.abrupt('return', api.clientUpdateMembership(env.services_root, token, locationId, pushEnable, locationEnable));
|
|
889
912
|
|
|
890
|
-
case
|
|
913
|
+
case 5:
|
|
914
|
+
_context14.prev = 5;
|
|
915
|
+
_context14.t0 = _context14['catch'](1);
|
|
916
|
+
|
|
917
|
+
console.log('clientUpdateMembership failed, token:' + token + ', locationId:' + locationId + ', error: ' + _context14.t0);
|
|
918
|
+
|
|
919
|
+
case 8:
|
|
891
920
|
case 'end':
|
|
892
921
|
return _context14.stop();
|
|
893
922
|
}
|
|
894
923
|
}
|
|
895
|
-
}, _callee14, this);
|
|
924
|
+
}, _callee14, this, [[1, 5]]);
|
|
896
925
|
}));
|
|
897
926
|
|
|
898
927
|
function clientUpdateMembership(_x35, _x36) {
|
|
@@ -2238,6 +2267,20 @@ var Como = function () {
|
|
|
2238
2267
|
|
|
2239
2268
|
return getPurchaseHistory;
|
|
2240
2269
|
}()
|
|
2270
|
+
|
|
2271
|
+
/**
|
|
2272
|
+
* Get app texts for multi languages - only for apps that has project set in translation service
|
|
2273
|
+
*/
|
|
2274
|
+
|
|
2275
|
+
}, {
|
|
2276
|
+
key: 'getAppTextsV2',
|
|
2277
|
+
value: function getAppTextsV2() {
|
|
2278
|
+
var _comoData44 = this.comoData,
|
|
2279
|
+
api = _comoData44.api,
|
|
2280
|
+
locationId = _comoData44.locationId;
|
|
2281
|
+
|
|
2282
|
+
return api.getAllTranslations(locationId);
|
|
2283
|
+
}
|
|
2241
2284
|
}]);
|
|
2242
2285
|
return Como;
|
|
2243
2286
|
}();
|
|
@@ -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
|
}();
|
|
@@ -136,4 +136,36 @@ exports.getZappResource = function (service) {
|
|
|
136
136
|
return _ref7.apply(this, arguments);
|
|
137
137
|
};
|
|
138
138
|
}();
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
exports.getAllTranslations = function (service) {
|
|
142
|
+
return function () {
|
|
143
|
+
var _ref9 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee5(locationId) {
|
|
144
|
+
var url, _ref10, data;
|
|
145
|
+
|
|
146
|
+
return _regenerator2.default.wrap(function _callee5$(_context5) {
|
|
147
|
+
while (1) {
|
|
148
|
+
switch (_context5.prev = _context5.next) {
|
|
149
|
+
case 0:
|
|
150
|
+
url = "/v1/translation/" + locationId;
|
|
151
|
+
_context5.next = 3;
|
|
152
|
+
return service.get(url);
|
|
153
|
+
|
|
154
|
+
case 3:
|
|
155
|
+
_ref10 = _context5.sent;
|
|
156
|
+
data = _ref10.data;
|
|
157
|
+
return _context5.abrupt("return", data);
|
|
158
|
+
|
|
159
|
+
case 6:
|
|
160
|
+
case "end":
|
|
161
|
+
return _context5.stop();
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}, _callee5, undefined);
|
|
165
|
+
}));
|
|
166
|
+
|
|
167
|
+
return function (_x9) {
|
|
168
|
+
return _ref9.apply(this, arguments);
|
|
169
|
+
};
|
|
170
|
+
}();
|
|
139
171
|
};
|
package/package.json
CHANGED
package/src/como.js
CHANGED
|
@@ -123,17 +123,25 @@ class Como {
|
|
|
123
123
|
updateCredentials(data, true);
|
|
124
124
|
credExist = true;
|
|
125
125
|
}catch(e){
|
|
126
|
-
console.log(`Failed to signOn, installationId:${installationId}, locationId:${locationId}, source:${source}, error:${e}`);
|
|
127
|
-
initService.logError({method: 'signOn', installationId, locationId, source, refreshToken, interval});
|
|
128
|
-
|
|
126
|
+
console.log(`Failed to signOn, installationId:${installationId}, locationId:${locationId}, source:${source},interval:${interval}, error:${e}`);
|
|
129
127
|
interval += 1000;
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}, interval);
|
|
128
|
+
initService.logError({method: 'signOn', installationId, locationId, source, refreshToken, interval});
|
|
129
|
+
await new Promise(r => setTimeout(r, interval));
|
|
133
130
|
}
|
|
134
131
|
}
|
|
135
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
|
+
}
|
|
136
140
|
|
|
141
|
+
}
|
|
142
|
+
if(!this.comoData.token){
|
|
143
|
+
this.comoData.token = this.comoData.accessToken;
|
|
144
|
+
}
|
|
137
145
|
return this.getCredentials();
|
|
138
146
|
}
|
|
139
147
|
|
|
@@ -369,8 +377,13 @@ class Como {
|
|
|
369
377
|
const {
|
|
370
378
|
api, locationId, token, env_params: env,
|
|
371
379
|
} = this.comoData;
|
|
380
|
+
try{
|
|
381
|
+
return api.clientUpdateMembership(env.services_root, token, locationId, pushEnable, locationEnable);
|
|
382
|
+
}
|
|
383
|
+
catch(e){
|
|
384
|
+
console.log(`clientUpdateMembership failed, token:${token}, locationId:${locationId}, error: ${e}`);
|
|
372
385
|
|
|
373
|
-
|
|
386
|
+
}
|
|
374
387
|
}
|
|
375
388
|
|
|
376
389
|
/**
|
|
@@ -934,6 +947,14 @@ class Como {
|
|
|
934
947
|
} = this.comoData;
|
|
935
948
|
return api.getPurchaseHistory(locationId, membership.Key, limit, offset);
|
|
936
949
|
}
|
|
950
|
+
|
|
951
|
+
/**
|
|
952
|
+
* Get app texts for multi languages - only for apps that has project set in translation service
|
|
953
|
+
*/
|
|
954
|
+
getAppTextsV2() {
|
|
955
|
+
const { api, locationId } = this.comoData;
|
|
956
|
+
return api.getAllTranslations(locationId);
|
|
957
|
+
}
|
|
937
958
|
}
|
|
938
959
|
|
|
939
960
|
module.exports = Como;
|