@como/como-client 0.6.6 → 0.7.0
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 +42 -18
- package/lib/services/auth.service.js +6 -1
- package/lib/services/form.service.js +32 -0
- package/package.json +1 -1
- package/src/como.js +20 -8
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 = 49;
|
|
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,29 +242,32 @@ 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
|
+
if (!this.comoData.token) {
|
|
266
|
+
this.comoData.token = this.comoData.accessToken;
|
|
267
|
+
}
|
|
265
268
|
return _context2.abrupt('return', this.getCredentials());
|
|
266
269
|
|
|
267
|
-
case
|
|
270
|
+
case 51:
|
|
268
271
|
case 'end':
|
|
269
272
|
return _context2.stop();
|
|
270
273
|
}
|
|
@@ -885,14 +888,21 @@ var Como = function () {
|
|
|
885
888
|
switch (_context14.prev = _context14.next) {
|
|
886
889
|
case 0:
|
|
887
890
|
_comoData7 = this.comoData, api = _comoData7.api, locationId = _comoData7.locationId, token = _comoData7.token, env = _comoData7.env_params;
|
|
891
|
+
_context14.prev = 1;
|
|
888
892
|
return _context14.abrupt('return', api.clientUpdateMembership(env.services_root, token, locationId, pushEnable, locationEnable));
|
|
889
893
|
|
|
890
|
-
case
|
|
894
|
+
case 5:
|
|
895
|
+
_context14.prev = 5;
|
|
896
|
+
_context14.t0 = _context14['catch'](1);
|
|
897
|
+
|
|
898
|
+
console.log('clientUpdateMembership failed, token:' + token + ', locationId:' + locationId + ', error: ' + _context14.t0);
|
|
899
|
+
|
|
900
|
+
case 8:
|
|
891
901
|
case 'end':
|
|
892
902
|
return _context14.stop();
|
|
893
903
|
}
|
|
894
904
|
}
|
|
895
|
-
}, _callee14, this);
|
|
905
|
+
}, _callee14, this, [[1, 5]]);
|
|
896
906
|
}));
|
|
897
907
|
|
|
898
908
|
function clientUpdateMembership(_x35, _x36) {
|
|
@@ -2238,6 +2248,20 @@ var Como = function () {
|
|
|
2238
2248
|
|
|
2239
2249
|
return getPurchaseHistory;
|
|
2240
2250
|
}()
|
|
2251
|
+
|
|
2252
|
+
/**
|
|
2253
|
+
* Get app texts for multi languages - only for apps that has project set in translation service
|
|
2254
|
+
*/
|
|
2255
|
+
|
|
2256
|
+
}, {
|
|
2257
|
+
key: 'getAppTextsV2',
|
|
2258
|
+
value: function getAppTextsV2() {
|
|
2259
|
+
var _comoData44 = this.comoData,
|
|
2260
|
+
api = _comoData44.api,
|
|
2261
|
+
locationId = _comoData44.locationId;
|
|
2262
|
+
|
|
2263
|
+
return api.getAllTranslations(locationId);
|
|
2264
|
+
}
|
|
2241
2265
|
}]);
|
|
2242
2266
|
return Como;
|
|
2243
2267
|
}();
|
|
@@ -14,7 +14,12 @@ var jsSHA = require("jssha");
|
|
|
14
14
|
var stringify = require('json-stable-stringify');
|
|
15
15
|
|
|
16
16
|
function getHashHeader(data) {
|
|
17
|
-
var shaObj =
|
|
17
|
+
var shaObj = void 0;
|
|
18
|
+
try {
|
|
19
|
+
shaObj = new jsSHA("SHA-256", "TEXT", { encoding: "UTF8" });
|
|
20
|
+
} catch (e) {
|
|
21
|
+
shaObj = new jsSHA.default("SHA-256", "TEXT", { encoding: "UTF8" });
|
|
22
|
+
}
|
|
18
23
|
shaObj.update(stringify(data));
|
|
19
24
|
var hash = shaObj.getHash("HEX");
|
|
20
25
|
return { awskt_1: hash };
|
|
@@ -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,16 @@ 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
|
}
|
|
136
|
-
|
|
133
|
+
if(!this.comoData.token){
|
|
134
|
+
this.comoData.token = this.comoData.accessToken;
|
|
135
|
+
}
|
|
137
136
|
return this.getCredentials();
|
|
138
137
|
}
|
|
139
138
|
|
|
@@ -369,8 +368,13 @@ class Como {
|
|
|
369
368
|
const {
|
|
370
369
|
api, locationId, token, env_params: env,
|
|
371
370
|
} = this.comoData;
|
|
371
|
+
try{
|
|
372
|
+
return api.clientUpdateMembership(env.services_root, token, locationId, pushEnable, locationEnable);
|
|
373
|
+
}
|
|
374
|
+
catch(e){
|
|
375
|
+
console.log(`clientUpdateMembership failed, token:${token}, locationId:${locationId}, error: ${e}`);
|
|
372
376
|
|
|
373
|
-
|
|
377
|
+
}
|
|
374
378
|
}
|
|
375
379
|
|
|
376
380
|
/**
|
|
@@ -934,6 +938,14 @@ class Como {
|
|
|
934
938
|
} = this.comoData;
|
|
935
939
|
return api.getPurchaseHistory(locationId, membership.Key, limit, offset);
|
|
936
940
|
}
|
|
941
|
+
|
|
942
|
+
/**
|
|
943
|
+
* Get app texts for multi languages - only for apps that has project set in translation service
|
|
944
|
+
*/
|
|
945
|
+
getAppTextsV2() {
|
|
946
|
+
const { api, locationId } = this.comoData;
|
|
947
|
+
return api.getAllTranslations(locationId);
|
|
948
|
+
}
|
|
937
949
|
}
|
|
938
950
|
|
|
939
951
|
module.exports = Como;
|