incyclist-services 1.7.17 → 1.7.19
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/cjs/api/bindings/index.js +1 -0
- package/lib/cjs/api/crypto/types.js +2 -0
- package/lib/cjs/api/index.js +1 -2
- package/lib/cjs/api/repository/index.js +4 -1
- package/lib/cjs/api/repository/types.js +0 -4
- package/lib/cjs/api/types.js +2 -0
- package/lib/cjs/apps/komoot/KomootAppConnection.js +12 -14
- package/lib/cjs/apps/velohero/VeloHeroAppConnection.js +12 -14
- package/lib/cjs/devices/access/service.js +10 -0
- package/lib/cjs/devices/page/service.js +7 -7
- package/lib/cjs/routes/base/utils/route.js +7 -2
- package/lib/cjs/routes/index.js +1 -0
- package/lib/cjs/routes/list/service.js +3 -3
- package/lib/cjs/routes/page/index.js +17 -0
- package/lib/cjs/routes/page/service.js +149 -0
- package/lib/cjs/routes/page/types.js +2 -0
- package/lib/cjs/routes/types.js +2 -0
- package/lib/cjs/ui/service.js +2 -4
- package/lib/cjs/workouts/base/model/Workout.js +5 -6
- package/lib/esm/api/bindings/index.js +1 -0
- package/lib/esm/api/crypto/types.js +1 -0
- package/lib/esm/api/index.js +1 -2
- package/lib/esm/api/repository/index.js +2 -1
- package/lib/esm/api/repository/types.js +1 -2
- package/lib/esm/api/types.js +1 -0
- package/lib/esm/apps/komoot/KomootAppConnection.js +8 -7
- package/lib/esm/apps/velohero/VeloHeroAppConnection.js +8 -7
- package/lib/esm/devices/access/service.js +10 -0
- package/lib/esm/devices/page/service.js +7 -7
- package/lib/esm/routes/base/utils/route.js +7 -2
- package/lib/esm/routes/index.js +1 -0
- package/lib/esm/routes/list/service.js +3 -3
- package/lib/esm/routes/page/index.js +1 -0
- package/lib/esm/routes/page/service.js +146 -0
- package/lib/esm/routes/page/types.js +1 -0
- package/lib/esm/routes/types.js +1 -0
- package/lib/esm/ui/service.js +2 -4
- package/lib/esm/workouts/base/model/Workout.js +3 -1
- package/lib/types/activities/ride/service.d.ts +1 -1
- package/lib/types/api/bindings/index.d.ts +14 -12
- package/lib/types/api/crypto/types.d.ts +46 -0
- package/lib/types/api/fs/index.d.ts +1 -0
- package/lib/types/api/index.d.ts +2 -3
- package/lib/types/api/repository/index.d.ts +7 -1
- package/lib/types/api/repository/types.d.ts +0 -6
- package/lib/types/api/types.d.ts +6 -0
- package/lib/types/api/video/index.d.ts +1 -1
- package/lib/types/devices/access/service.d.ts +1 -0
- package/lib/types/devices/page/service.d.ts +3 -3
- package/lib/types/routes/index.d.ts +1 -0
- package/lib/types/routes/list/service.d.ts +5 -59
- package/lib/types/routes/list/types.d.ts +10 -2
- package/lib/types/routes/page/index.d.ts +1 -0
- package/lib/types/routes/page/service.d.ts +25 -0
- package/lib/types/routes/page/types.d.ts +21 -0
- package/lib/types/routes/types.d.ts +2 -0
- package/lib/types/types.d.ts +2 -0
- package/lib/types/video/VideoConversion.d.ts +1 -1
- package/package.json +7 -7
package/lib/cjs/api/index.js
CHANGED
|
@@ -16,6 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./rest/index"), exports);
|
|
18
18
|
__exportStar(require("./rest/types"), exports);
|
|
19
|
-
__exportStar(require("./repository"), exports);
|
|
20
|
-
__exportStar(require("./path"), exports);
|
|
21
19
|
__exportStar(require("./bindings"), exports);
|
|
20
|
+
__exportStar(require("./repository"), exports);
|
|
@@ -14,5 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
|
|
17
|
+
exports.AbstractJsonRepositoryBinding = void 0;
|
|
18
18
|
__exportStar(require("./json"), exports);
|
|
19
|
+
class AbstractJsonRepositoryBinding {
|
|
20
|
+
}
|
|
21
|
+
exports.AbstractJsonRepositoryBinding = AbstractJsonRepositoryBinding;
|
|
@@ -33,15 +33,11 @@ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn,
|
|
|
33
33
|
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
34
34
|
done = true;
|
|
35
35
|
};
|
|
36
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
-
};
|
|
39
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
37
|
exports.KomootAppConnection = void 0;
|
|
41
38
|
const api_1 = require("../../api");
|
|
42
39
|
const decorators_1 = require("../../base/decorators");
|
|
43
40
|
const valid_1 = require("../../utils/valid");
|
|
44
|
-
const crypto_1 = __importDefault(require("crypto"));
|
|
45
41
|
const api_2 = require("../base/api");
|
|
46
42
|
const app_1 = require("../base/app");
|
|
47
43
|
const CRYPT_ALGO = 'aes256';
|
|
@@ -186,20 +182,21 @@ let KomootAppConnection = (() => {
|
|
|
186
182
|
this.on('login-failure', () => { this._isConnecting = false; });
|
|
187
183
|
}
|
|
188
184
|
getCrypto() {
|
|
189
|
-
return
|
|
185
|
+
return (0, api_1.getBindings)().crypto ?? require('crypto');
|
|
190
186
|
}
|
|
191
187
|
encrypt(algo) {
|
|
192
188
|
if (!this.credentials)
|
|
193
189
|
return null;
|
|
194
|
-
const
|
|
190
|
+
const crypto = this.getCrypto();
|
|
191
|
+
const iv = crypto.randomBytes(16);
|
|
195
192
|
const uuid = this.getUuid();
|
|
196
|
-
const key =
|
|
197
|
-
const cipher =
|
|
193
|
+
const key = Buffer.from(uuid.substring(0, 32), 'utf8');
|
|
194
|
+
const cipher = crypto.createCipheriv(algo, key, iv);
|
|
198
195
|
const { username, password, userid } = this.credentials;
|
|
199
196
|
const text = JSON.stringify({ username, password, userid });
|
|
200
197
|
let ciphered;
|
|
201
198
|
ciphered = cipher.update(text, 'utf8', 'hex');
|
|
202
|
-
ciphered += cipher.final('hex');
|
|
199
|
+
ciphered += cipher.final().toString('hex');
|
|
203
200
|
const auth = {
|
|
204
201
|
id: iv.toString('hex'),
|
|
205
202
|
authKey: ciphered,
|
|
@@ -212,22 +209,23 @@ let KomootAppConnection = (() => {
|
|
|
212
209
|
const { id, authKey } = auth;
|
|
213
210
|
const iv = Buffer.from(id, 'hex');
|
|
214
211
|
const uuid = this.getUuid();
|
|
215
|
-
const key =
|
|
212
|
+
const key = Buffer.from(uuid.substring(0, 32), 'utf8');
|
|
213
|
+
const crypto = this.getCrypto();
|
|
216
214
|
try {
|
|
217
215
|
let text;
|
|
218
216
|
if (algo === 'aes-256-gcm') {
|
|
219
|
-
const cipher =
|
|
217
|
+
const cipher = crypto.createDecipheriv(algo, key, iv);
|
|
220
218
|
const raw = Buffer.from(authKey, "hex");
|
|
221
219
|
const authTagBuff = raw.subarray(raw.length - 16);
|
|
222
220
|
const encTextBuff = raw.subarray(0, raw.length - 16);
|
|
223
221
|
cipher.setAuthTag(authTagBuff);
|
|
224
222
|
text = cipher.update(encTextBuff);
|
|
225
|
-
text += cipher.final('utf8');
|
|
223
|
+
text += cipher.final().toString('utf8');
|
|
226
224
|
}
|
|
227
225
|
else {
|
|
228
|
-
const cipher =
|
|
226
|
+
const cipher = crypto.createDecipheriv(algo, key, iv);
|
|
229
227
|
text = cipher.update(authKey, 'hex', 'utf8');
|
|
230
|
-
text += cipher.final('utf8');
|
|
228
|
+
text += cipher.final().toString('utf8');
|
|
231
229
|
}
|
|
232
230
|
const credentials = JSON.parse(text);
|
|
233
231
|
return credentials;
|
|
@@ -33,15 +33,11 @@ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn,
|
|
|
33
33
|
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
34
34
|
done = true;
|
|
35
35
|
};
|
|
36
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
-
};
|
|
39
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
37
|
exports.VeloHeroAppConnection = void 0;
|
|
41
38
|
const api_1 = require("../../api");
|
|
42
39
|
const decorators_1 = require("../../base/decorators");
|
|
43
40
|
const valid_1 = require("../../utils/valid");
|
|
44
|
-
const crypto_1 = __importDefault(require("crypto"));
|
|
45
41
|
const api_2 = require("../base/api");
|
|
46
42
|
const app_1 = require("../base/app");
|
|
47
43
|
const CRYPT_ALGO = 'aes256';
|
|
@@ -175,20 +171,21 @@ let VeloHeroAppConnection = (() => {
|
|
|
175
171
|
this.on('login-failure', () => { this._isConnecting = false; });
|
|
176
172
|
}
|
|
177
173
|
getCrypto() {
|
|
178
|
-
return
|
|
174
|
+
return (0, api_1.getBindings)().crypto ?? require('crypto');
|
|
179
175
|
}
|
|
180
176
|
encrypt(algo) {
|
|
181
177
|
if (!this.credentials)
|
|
182
178
|
return null;
|
|
183
|
-
const
|
|
179
|
+
const crypto = this.getCrypto();
|
|
180
|
+
const iv = crypto.randomBytes(16);
|
|
184
181
|
const uuid = this.getUuid();
|
|
185
|
-
const key =
|
|
186
|
-
const cipher =
|
|
182
|
+
const key = Buffer.from(uuid.substring(0, 32), 'utf8');
|
|
183
|
+
const cipher = crypto.createCipheriv(algo, key, iv);
|
|
187
184
|
const { username, password } = this.credentials;
|
|
188
185
|
const text = JSON.stringify({ username, password });
|
|
189
186
|
let ciphered;
|
|
190
187
|
ciphered = cipher.update(text, 'utf8', 'hex');
|
|
191
|
-
ciphered += cipher.final('hex');
|
|
188
|
+
ciphered += cipher.final().toString('hex');
|
|
192
189
|
const auth = {
|
|
193
190
|
id: iv.toString('hex'),
|
|
194
191
|
authKey: ciphered,
|
|
@@ -201,22 +198,23 @@ let VeloHeroAppConnection = (() => {
|
|
|
201
198
|
const { id, authKey } = auth;
|
|
202
199
|
const iv = Buffer.from(id, 'hex');
|
|
203
200
|
const uuid = this.getUuid();
|
|
204
|
-
const key =
|
|
201
|
+
const key = Buffer.from(uuid.substring(0, 32), 'utf8');
|
|
202
|
+
const crypto = this.getCrypto();
|
|
205
203
|
try {
|
|
206
204
|
let text;
|
|
207
205
|
if (algo === 'aes-256-gcm') {
|
|
208
|
-
const cipher =
|
|
206
|
+
const cipher = crypto.createDecipheriv(algo, key, iv);
|
|
209
207
|
const raw = Buffer.from(authKey, "hex");
|
|
210
208
|
const authTagBuff = raw.subarray(raw.length - 16);
|
|
211
209
|
const encTextBuff = raw.subarray(0, raw.length - 16);
|
|
212
210
|
cipher.setAuthTag(authTagBuff);
|
|
213
211
|
text = cipher.update(encTextBuff);
|
|
214
|
-
text += cipher.final('utf8');
|
|
212
|
+
text += cipher.final().toString('utf8');
|
|
215
213
|
}
|
|
216
214
|
else {
|
|
217
|
-
const cipher =
|
|
215
|
+
const cipher = crypto.createDecipheriv(algo, key, iv);
|
|
218
216
|
text = cipher.update(authKey, 'hex', 'utf8');
|
|
219
|
-
text += cipher.final('utf8');
|
|
217
|
+
text += cipher.final().toString('utf8');
|
|
220
218
|
}
|
|
221
219
|
const credentials = JSON.parse(text);
|
|
222
220
|
return credentials;
|
|
@@ -271,6 +271,16 @@ let DeviceAccessService = (() => {
|
|
|
271
271
|
this.emit('interface-changed', ifaceName, { ...this.interfaces[ifaceName] });
|
|
272
272
|
return disconnected;
|
|
273
273
|
}
|
|
274
|
+
async terminate(ifaceName) {
|
|
275
|
+
await this.disconnect(ifaceName);
|
|
276
|
+
if (!ifaceName) {
|
|
277
|
+
const promises = Object.keys(this.interfaces).map(i => this.terminate(i));
|
|
278
|
+
await Promise.allSettled(promises);
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
const impl = this.getInterface(ifaceName);
|
|
282
|
+
await impl.terminate();
|
|
283
|
+
}
|
|
274
284
|
async scan(filter = {}, props = {}) {
|
|
275
285
|
this.logEvent({ message: 'device scan start', filter, props });
|
|
276
286
|
const detected = [];
|
|
@@ -166,7 +166,7 @@ let DevicesPageService = (() => {
|
|
|
166
166
|
const caps = this.state.capabilities ?? [];
|
|
167
167
|
const ifs = this.state.interfaces ?? [];
|
|
168
168
|
(0, access_1.useDeviceAccess)().enrichWithAccessState(ifs);
|
|
169
|
-
const interfaces = ifs.map(i => this.getInterfaceDisplayProps(i));
|
|
169
|
+
const interfaces = ifs.map(i => { return this.getInterfaceDisplayProps(i); });
|
|
170
170
|
const capProps = caps.map(c => this.getCapabilityDisplayProps(c));
|
|
171
171
|
const loading = this.promiseOpen != undefined;
|
|
172
172
|
const CP = (cap) => capProps.find(c => c.capability === cap);
|
|
@@ -204,6 +204,7 @@ let DevicesPageService = (() => {
|
|
|
204
204
|
}
|
|
205
205
|
getInterfaceSettingsObserver() {
|
|
206
206
|
this.interfaceSettingsObserver = this.interfaceSettingsObserver ?? new types_1.Observer();
|
|
207
|
+
return this.interfaceSettingsObserver;
|
|
207
208
|
}
|
|
208
209
|
getInterfaceSettingsDisplayProps() {
|
|
209
210
|
if (!this.openedInterfaceSettings)
|
|
@@ -219,6 +220,11 @@ let DevicesPageService = (() => {
|
|
|
219
220
|
disableInterface(i) { }
|
|
220
221
|
reconnectInterface(i) { }
|
|
221
222
|
refreshInterface(i) { }
|
|
223
|
+
closeInterfaceSettings() {
|
|
224
|
+
this.openedInterfaceSettings = undefined;
|
|
225
|
+
this.interfaceSettingsObserver?.stop();
|
|
226
|
+
this.updatePage();
|
|
227
|
+
}
|
|
222
228
|
getCapabilityDisplayProps(data) {
|
|
223
229
|
const { capability: cap, deviceName, connectState, value, unit, disabled } = data;
|
|
224
230
|
const capability = this.getTCapability(cap);
|
|
@@ -281,15 +287,9 @@ let DevicesPageService = (() => {
|
|
|
281
287
|
}
|
|
282
288
|
openInterfaceSettings(i) {
|
|
283
289
|
const info = this.state.interfaces.find(id => id.name === i);
|
|
284
|
-
console.log('# open interface settings', i, info);
|
|
285
290
|
this.openedInterfaceSettings = i;
|
|
286
291
|
this.updatePage();
|
|
287
292
|
}
|
|
288
|
-
closeInterfaceSettings() {
|
|
289
|
-
this.openedInterfaceSettings = undefined;
|
|
290
|
-
this.interfaceSettingsObserver?.stop();
|
|
291
|
-
this.updatePage();
|
|
292
|
-
}
|
|
293
293
|
onEnableCapability(enabled) {
|
|
294
294
|
const all = this.state.capabilities ?? [];
|
|
295
295
|
const requested = all.find(c => c.capability === this.openedCapability);
|
|
@@ -4,12 +4,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getNextVideoId = exports.hasNextVideo = exports.createFromJson = exports.getPointAtDistance = exports.getHeading = exports.getPosition = exports.getNextPosition = exports.getRouteHash = exports.getTotalDistance = exports.updateCnt = exports.updateElevationGain = exports.getElevationGainAt = exports.getTotalElevation = exports.validateDistance = exports.validateRoute = exports.correctDistanceValues = exports.addDetails = exports.getSegments = exports.updateSlopes = exports.validateSlopes = exports.checkIsLoop = void 0;
|
|
7
|
+
const api_1 = require("../../../api");
|
|
7
8
|
const utils_1 = require("../../../utils");
|
|
8
9
|
const clone_1 = __importDefault(require("../../../utils/clone"));
|
|
9
10
|
const geo_1 = require("../../../utils/geo");
|
|
10
11
|
const valid_1 = require("../../../utils/valid");
|
|
11
12
|
const route_1 = require("../model/route");
|
|
12
|
-
const crypto_1 = __importDefault(require("crypto"));
|
|
13
13
|
const MAX_LAPMODE_DISTANCE = 50;
|
|
14
14
|
const checkIsLoop = (_route) => {
|
|
15
15
|
let points;
|
|
@@ -310,6 +310,8 @@ const getTotalDistance = (route) => {
|
|
|
310
310
|
};
|
|
311
311
|
exports.getTotalDistance = getTotalDistance;
|
|
312
312
|
const getRouteHash = (route) => {
|
|
313
|
+
console.log('# getRouteHash', 'crypto binding:', getCryptoBinding());
|
|
314
|
+
const cryptoImpl = getCryptoBinding() ?? require('crypto');
|
|
313
315
|
let json;
|
|
314
316
|
if (!route?.points) {
|
|
315
317
|
if (route.epp?.programData) {
|
|
@@ -326,7 +328,7 @@ const getRouteHash = (route) => {
|
|
|
326
328
|
else {
|
|
327
329
|
json = { decoded: route.points.map(p => ({ lat: p.lat, lng: p.lng })) };
|
|
328
330
|
}
|
|
329
|
-
const routeHash =
|
|
331
|
+
const routeHash = cryptoImpl.createHash('md5').update(JSON.stringify(json)).digest('hex').toString();
|
|
330
332
|
return routeHash;
|
|
331
333
|
};
|
|
332
334
|
exports.getRouteHash = getRouteHash;
|
|
@@ -579,3 +581,6 @@ const getNextVideoId = (route) => {
|
|
|
579
581
|
return next;
|
|
580
582
|
};
|
|
581
583
|
exports.getNextVideoId = getNextVideoId;
|
|
584
|
+
const getCryptoBinding = () => {
|
|
585
|
+
return (0, api_1.getBindings)().crypto;
|
|
586
|
+
};
|
package/lib/cjs/routes/index.js
CHANGED
|
@@ -318,8 +318,9 @@ let RouteListService = (() => {
|
|
|
318
318
|
const filters = requestedFilters ?? this.filters;
|
|
319
319
|
let routes = Array.from(this.getAllSearchCards().map(c => c.getDisplayProperties()));
|
|
320
320
|
routes.sort((a, b) => a.title > b.title ? 1 : -1);
|
|
321
|
+
const units = this.getUnitConverter().getDefaultUnits();
|
|
321
322
|
if (!filters) {
|
|
322
|
-
return { routes, filters, observer: this.observer };
|
|
323
|
+
return { routes, filters, observer: this.observer, units };
|
|
323
324
|
}
|
|
324
325
|
if (!filters.includeDeleted)
|
|
325
326
|
routes = routes.filter(r => !r?.isDeleted);
|
|
@@ -333,12 +334,11 @@ let RouteListService = (() => {
|
|
|
333
334
|
const cards = routes.map(r => this.getCard(r.id));
|
|
334
335
|
this.setListTop('list', 0);
|
|
335
336
|
this.setListTop('tiles', 0);
|
|
336
|
-
const units = this.getUnitConverter().getDefaultUnits();
|
|
337
337
|
return { routes, cards, filters, observer: this.observer, units };
|
|
338
338
|
}
|
|
339
339
|
catch (err) {
|
|
340
340
|
this.logError(err, 'search');
|
|
341
|
-
return { routes: [], filters: {} };
|
|
341
|
+
return { routes: [], filters: {}, observer: this.observer };
|
|
342
342
|
}
|
|
343
343
|
}
|
|
344
344
|
setListTop(display, top) {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./service"), exports);
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
3
|
+
var useValue = arguments.length > 2;
|
|
4
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
5
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
6
|
+
}
|
|
7
|
+
return useValue ? value : void 0;
|
|
8
|
+
};
|
|
9
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
10
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
11
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
12
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
13
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
14
|
+
var _, done = false;
|
|
15
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
16
|
+
var context = {};
|
|
17
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
18
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
19
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
20
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
21
|
+
if (kind === "accessor") {
|
|
22
|
+
if (result === void 0) continue;
|
|
23
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
24
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
25
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
26
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
27
|
+
}
|
|
28
|
+
else if (_ = accept(result)) {
|
|
29
|
+
if (kind === "field") initializers.unshift(_);
|
|
30
|
+
else descriptor[key] = _;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
34
|
+
done = true;
|
|
35
|
+
};
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
exports.RoutePageService = void 0;
|
|
38
|
+
const decorators_1 = require("../../base/decorators");
|
|
39
|
+
const pages_1 = require("../../base/pages");
|
|
40
|
+
const list_1 = require("../list");
|
|
41
|
+
let RoutePageService = (() => {
|
|
42
|
+
let _classDecorators = [decorators_1.Singleton];
|
|
43
|
+
let _classDescriptor;
|
|
44
|
+
let _classExtraInitializers = [];
|
|
45
|
+
let _classThis;
|
|
46
|
+
let _classSuper = pages_1.IncyclistPageService;
|
|
47
|
+
let _instanceExtraInitializers = [];
|
|
48
|
+
let _getRouteList_decorators;
|
|
49
|
+
var RoutePageService = class extends _classSuper {
|
|
50
|
+
static { _classThis = this; }
|
|
51
|
+
static {
|
|
52
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
53
|
+
_getRouteList_decorators = [decorators_1.Injectable];
|
|
54
|
+
__esDecorate(this, null, _getRouteList_decorators, { kind: "method", name: "getRouteList", static: false, private: false, access: { has: obj => "getRouteList" in obj, get: obj => obj.getRouteList }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
55
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
56
|
+
RoutePageService = _classThis = _classDescriptor.value;
|
|
57
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
58
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
59
|
+
}
|
|
60
|
+
serviceState = __runInitializers(this, _instanceExtraInitializers);
|
|
61
|
+
openedRoute;
|
|
62
|
+
updateStateHandler;
|
|
63
|
+
syncStartHandler;
|
|
64
|
+
syncStopHandler;
|
|
65
|
+
openPage() {
|
|
66
|
+
super.openPage();
|
|
67
|
+
try {
|
|
68
|
+
const service = (0, list_1.useRouteList)();
|
|
69
|
+
const filters = this.getSearchFilters();
|
|
70
|
+
this.serviceState = service.search(filters);
|
|
71
|
+
if (this.serviceState.observer) {
|
|
72
|
+
this.startEventListener();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
catch (err) {
|
|
76
|
+
}
|
|
77
|
+
return this.getPageObserver();
|
|
78
|
+
}
|
|
79
|
+
closePage() {
|
|
80
|
+
super.closePage();
|
|
81
|
+
}
|
|
82
|
+
pausePage() {
|
|
83
|
+
this.stopEventListener();
|
|
84
|
+
return super.pausePage();
|
|
85
|
+
}
|
|
86
|
+
resumePage() {
|
|
87
|
+
this.startEventListener();
|
|
88
|
+
return super.resumePage();
|
|
89
|
+
}
|
|
90
|
+
getPageDisplayProps() {
|
|
91
|
+
const service = this.getRouteList();
|
|
92
|
+
const { filters } = this.serviceState;
|
|
93
|
+
const displayType = service.getDisplayType();
|
|
94
|
+
const showImport = false;
|
|
95
|
+
const synchronizing = false;
|
|
96
|
+
const loading = this.serviceState === undefined;
|
|
97
|
+
const routes = this.getRoutesDisplayProps();
|
|
98
|
+
const onImportClicked = this.onImportClicked.bind(this);
|
|
99
|
+
const onFilterChanged = this.onFilterChanged.bind(this);
|
|
100
|
+
return { loading, synchronizing, routes, displayType,
|
|
101
|
+
onFilterChanged, onImportClicked };
|
|
102
|
+
}
|
|
103
|
+
onFilterChanged(filters) {
|
|
104
|
+
this.serviceState = this.getRouteList().search(filters);
|
|
105
|
+
this.getPageObserver().emit('page-update');
|
|
106
|
+
}
|
|
107
|
+
onImportClicked() {
|
|
108
|
+
}
|
|
109
|
+
onSelect(id) {
|
|
110
|
+
this.openedRoute = id;
|
|
111
|
+
}
|
|
112
|
+
onDelete(id) {
|
|
113
|
+
const service = this.getRouteList();
|
|
114
|
+
const card = service.getCard(id);
|
|
115
|
+
if (card)
|
|
116
|
+
card.delete();
|
|
117
|
+
}
|
|
118
|
+
getRoutesDisplayProps() {
|
|
119
|
+
const { routes } = this.serviceState;
|
|
120
|
+
return routes;
|
|
121
|
+
}
|
|
122
|
+
getSearchFilters() {
|
|
123
|
+
return this.getRouteList().getFilters();
|
|
124
|
+
}
|
|
125
|
+
startEventListener() {
|
|
126
|
+
const { observer } = this.serviceState;
|
|
127
|
+
if (!observer)
|
|
128
|
+
return;
|
|
129
|
+
observer.on('updated', this.updateStateHandler);
|
|
130
|
+
observer.on('sync-start', this.syncStartHandler);
|
|
131
|
+
observer.on('sync-done', this.syncStopHandler);
|
|
132
|
+
}
|
|
133
|
+
stopEventListener(final) {
|
|
134
|
+
const { observer } = this.serviceState;
|
|
135
|
+
if (!observer)
|
|
136
|
+
return;
|
|
137
|
+
if (final)
|
|
138
|
+
observer.stop();
|
|
139
|
+
observer.off('updated', this.updateStateHandler);
|
|
140
|
+
observer.off('sync-start', this.syncStartHandler);
|
|
141
|
+
observer.off('sync-done', this.syncStopHandler);
|
|
142
|
+
}
|
|
143
|
+
getRouteList() {
|
|
144
|
+
return (0, list_1.useRouteList)();
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
return RoutePageService = _classThis;
|
|
148
|
+
})();
|
|
149
|
+
exports.RoutePageService = RoutePageService;
|
package/lib/cjs/ui/service.js
CHANGED
|
@@ -122,9 +122,7 @@ let UserInterfaceServcie = (() => {
|
|
|
122
122
|
this.logEvent({ message: 'App mounted', channel: platform });
|
|
123
123
|
this.createUserStats();
|
|
124
124
|
await this.initDeviceServices();
|
|
125
|
-
|
|
126
|
-
this.preloadData();
|
|
127
|
-
}
|
|
125
|
+
this.preloadData();
|
|
128
126
|
this.onSessionStart();
|
|
129
127
|
this.appState = 'Active';
|
|
130
128
|
}
|
|
@@ -144,7 +142,7 @@ let UserInterfaceServcie = (() => {
|
|
|
144
142
|
pages_1.IncyclistPageService.closePage();
|
|
145
143
|
await (0, utils_1.waitNextTick)();
|
|
146
144
|
await (0, devices_1.useDevicePairing)().exit();
|
|
147
|
-
await (0, devices_1.useDeviceAccess)().
|
|
145
|
+
await (0, devices_1.useDeviceAccess)().terminate();
|
|
148
146
|
this.appState = 'Stopped';
|
|
149
147
|
this.logEvent({ message: 'onAppExit finished' });
|
|
150
148
|
this.isTerminated = true;
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.Plan = exports.Workout = void 0;
|
|
7
4
|
const Step_1 = require("./Step");
|
|
8
5
|
const Segment_1 = require("./Segment");
|
|
9
6
|
const valid_1 = require("../../../utils/valid");
|
|
10
|
-
const
|
|
7
|
+
const api_1 = require("../../../api");
|
|
11
8
|
class Workout extends Segment_1.Segment {
|
|
12
9
|
id;
|
|
13
10
|
_hash;
|
|
@@ -40,7 +37,8 @@ class Workout extends Segment_1.Segment {
|
|
|
40
37
|
if (this._hash)
|
|
41
38
|
return this._hash;
|
|
42
39
|
const { name, description, steps, repeat } = this;
|
|
43
|
-
|
|
40
|
+
const crypto = (0, api_1.getBindings)().crypto ?? require('crypto');
|
|
41
|
+
this._hash = crypto.createHash('md5').update(JSON.stringify({ name, description, steps, repeat })).digest('hex');
|
|
44
42
|
return this._hash;
|
|
45
43
|
}
|
|
46
44
|
getSegment(time) {
|
|
@@ -96,7 +94,8 @@ class Plan {
|
|
|
96
94
|
return this._hash;
|
|
97
95
|
const { name, description, workouts } = this;
|
|
98
96
|
const data = JSON.stringify({ name, description, workouts });
|
|
99
|
-
|
|
97
|
+
const crypto = (0, api_1.getBindings)().crypto ?? require('crypto');
|
|
98
|
+
this._hash = crypto.createHash('md5').update(data).digest('hex');
|
|
100
99
|
return this._hash;
|
|
101
100
|
}
|
|
102
101
|
addWorkoutSchedule(week, day, workoutId) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/lib/esm/api/index.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
}
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -35,7 +35,6 @@ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn,
|
|
|
35
35
|
import { getBindings } from "../../api";
|
|
36
36
|
import { Injectable, Singleton } from "../../base/decorators";
|
|
37
37
|
import { valid } from "../../utils/valid";
|
|
38
|
-
import crypto from 'crypto';
|
|
39
38
|
import { KomootApi } from "../base/api";
|
|
40
39
|
import { ConnectedAppService } from "../base/app";
|
|
41
40
|
const CRYPT_ALGO = 'aes256';
|
|
@@ -180,20 +179,21 @@ let KomootAppConnection = (() => {
|
|
|
180
179
|
this.on('login-failure', () => { this._isConnecting = false; });
|
|
181
180
|
}
|
|
182
181
|
getCrypto() {
|
|
183
|
-
return
|
|
182
|
+
return getBindings().crypto ?? require('crypto');
|
|
184
183
|
}
|
|
185
184
|
encrypt(algo) {
|
|
186
185
|
if (!this.credentials)
|
|
187
186
|
return null;
|
|
187
|
+
const crypto = this.getCrypto();
|
|
188
188
|
const iv = crypto.randomBytes(16);
|
|
189
189
|
const uuid = this.getUuid();
|
|
190
|
-
const key =
|
|
190
|
+
const key = Buffer.from(uuid.substring(0, 32), 'utf8');
|
|
191
191
|
const cipher = crypto.createCipheriv(algo, key, iv);
|
|
192
192
|
const { username, password, userid } = this.credentials;
|
|
193
193
|
const text = JSON.stringify({ username, password, userid });
|
|
194
194
|
let ciphered;
|
|
195
195
|
ciphered = cipher.update(text, 'utf8', 'hex');
|
|
196
|
-
ciphered += cipher.final('hex');
|
|
196
|
+
ciphered += cipher.final().toString('hex');
|
|
197
197
|
const auth = {
|
|
198
198
|
id: iv.toString('hex'),
|
|
199
199
|
authKey: ciphered,
|
|
@@ -206,7 +206,8 @@ let KomootAppConnection = (() => {
|
|
|
206
206
|
const { id, authKey } = auth;
|
|
207
207
|
const iv = Buffer.from(id, 'hex');
|
|
208
208
|
const uuid = this.getUuid();
|
|
209
|
-
const key =
|
|
209
|
+
const key = Buffer.from(uuid.substring(0, 32), 'utf8');
|
|
210
|
+
const crypto = this.getCrypto();
|
|
210
211
|
try {
|
|
211
212
|
let text;
|
|
212
213
|
if (algo === 'aes-256-gcm') {
|
|
@@ -216,12 +217,12 @@ let KomootAppConnection = (() => {
|
|
|
216
217
|
const encTextBuff = raw.subarray(0, raw.length - 16);
|
|
217
218
|
cipher.setAuthTag(authTagBuff);
|
|
218
219
|
text = cipher.update(encTextBuff);
|
|
219
|
-
text += cipher.final('utf8');
|
|
220
|
+
text += cipher.final().toString('utf8');
|
|
220
221
|
}
|
|
221
222
|
else {
|
|
222
223
|
const cipher = crypto.createDecipheriv(algo, key, iv);
|
|
223
224
|
text = cipher.update(authKey, 'hex', 'utf8');
|
|
224
|
-
text += cipher.final('utf8');
|
|
225
|
+
text += cipher.final().toString('utf8');
|
|
225
226
|
}
|
|
226
227
|
const credentials = JSON.parse(text);
|
|
227
228
|
return credentials;
|