@cutos/core 0.0.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.
@@ -0,0 +1,1200 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var require$$1 = require('mqtt');
6
+
7
+ function getAugmentedNamespace(n) {
8
+ if (n.__esModule) return n;
9
+ var f = n.default;
10
+ if (typeof f == "function") {
11
+ var a = function a () {
12
+ if (this instanceof a) {
13
+ return Reflect.construct(f, arguments, this.constructor);
14
+ }
15
+ return f.apply(this, arguments);
16
+ };
17
+ a.prototype = f.prototype;
18
+ } else a = {};
19
+ Object.defineProperty(a, '__esModule', {value: true});
20
+ Object.keys(n).forEach(function (k) {
21
+ var d = Object.getOwnPropertyDescriptor(n, k);
22
+ Object.defineProperty(a, k, d.get ? d : {
23
+ enumerable: true,
24
+ get: function () {
25
+ return n[k];
26
+ }
27
+ });
28
+ });
29
+ return a;
30
+ }
31
+
32
+ var cutos = {};
33
+
34
+ // Unique ID creation requires a high quality random # generator. In the browser we therefore
35
+ // require the crypto API and do not support built-in fallback to lower quality random number
36
+ // generators (like Math.random()).
37
+ let getRandomValues;
38
+ const rnds8 = new Uint8Array(16);
39
+ function rng() {
40
+ // lazy load so that environments that need to polyfill have a chance to do so
41
+ if (!getRandomValues) {
42
+ // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
43
+ getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
44
+
45
+ if (!getRandomValues) {
46
+ throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
47
+ }
48
+ }
49
+
50
+ return getRandomValues(rnds8);
51
+ }
52
+
53
+ var REGEX = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
54
+
55
+ function validate(uuid) {
56
+ return typeof uuid === 'string' && REGEX.test(uuid);
57
+ }
58
+
59
+ /**
60
+ * Convert array of 16 byte values to UUID string format of the form:
61
+ * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
62
+ */
63
+
64
+ const byteToHex = [];
65
+
66
+ for (let i = 0; i < 256; ++i) {
67
+ byteToHex.push((i + 0x100).toString(16).slice(1));
68
+ }
69
+
70
+ function unsafeStringify(arr, offset = 0) {
71
+ // Note: Be careful editing this code! It's been tuned for performance
72
+ // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
73
+ return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];
74
+ }
75
+
76
+ function stringify(arr, offset = 0) {
77
+ const uuid = unsafeStringify(arr, offset); // Consistency check for valid UUID. If this throws, it's likely due to one
78
+ // of the following:
79
+ // - One or more input array values don't map to a hex octet (leading to
80
+ // "undefined" in the uuid)
81
+ // - Invalid input values for the RFC `version` or `variant` fields
82
+
83
+ if (!validate(uuid)) {
84
+ throw TypeError('Stringified UUID is invalid');
85
+ }
86
+
87
+ return uuid;
88
+ }
89
+
90
+ //
91
+ // Inspired by https://github.com/LiosK/UUID.js
92
+ // and http://docs.python.org/library/uuid.html
93
+
94
+ let _nodeId;
95
+
96
+ let _clockseq; // Previous uuid creation time
97
+
98
+
99
+ let _lastMSecs = 0;
100
+ let _lastNSecs = 0; // See https://github.com/uuidjs/uuid for API details
101
+
102
+ function v1(options, buf, offset) {
103
+ let i = buf && offset || 0;
104
+ const b = buf || new Array(16);
105
+ options = options || {};
106
+ let node = options.node || _nodeId;
107
+ let clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq; // node and clockseq need to be initialized to random values if they're not
108
+ // specified. We do this lazily to minimize issues related to insufficient
109
+ // system entropy. See #189
110
+
111
+ if (node == null || clockseq == null) {
112
+ const seedBytes = options.random || (options.rng || rng)();
113
+
114
+ if (node == null) {
115
+ // Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1)
116
+ node = _nodeId = [seedBytes[0] | 0x01, seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]];
117
+ }
118
+
119
+ if (clockseq == null) {
120
+ // Per 4.2.2, randomize (14 bit) clockseq
121
+ clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 0x3fff;
122
+ }
123
+ } // UUID timestamps are 100 nano-second units since the Gregorian epoch,
124
+ // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so
125
+ // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs'
126
+ // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00.
127
+
128
+
129
+ let msecs = options.msecs !== undefined ? options.msecs : Date.now(); // Per 4.2.1.2, use count of uuid's generated during the current clock
130
+ // cycle to simulate higher resolution clock
131
+
132
+ let nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1; // Time since last uuid creation (in msecs)
133
+
134
+ const dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 10000; // Per 4.2.1.2, Bump clockseq on clock regression
135
+
136
+ if (dt < 0 && options.clockseq === undefined) {
137
+ clockseq = clockseq + 1 & 0x3fff;
138
+ } // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new
139
+ // time interval
140
+
141
+
142
+ if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) {
143
+ nsecs = 0;
144
+ } // Per 4.2.1.2 Throw error if too many uuids are requested
145
+
146
+
147
+ if (nsecs >= 10000) {
148
+ throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");
149
+ }
150
+
151
+ _lastMSecs = msecs;
152
+ _lastNSecs = nsecs;
153
+ _clockseq = clockseq; // Per 4.1.4 - Convert from unix epoch to Gregorian epoch
154
+
155
+ msecs += 12219292800000; // `time_low`
156
+
157
+ const tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000;
158
+ b[i++] = tl >>> 24 & 0xff;
159
+ b[i++] = tl >>> 16 & 0xff;
160
+ b[i++] = tl >>> 8 & 0xff;
161
+ b[i++] = tl & 0xff; // `time_mid`
162
+
163
+ const tmh = msecs / 0x100000000 * 10000 & 0xfffffff;
164
+ b[i++] = tmh >>> 8 & 0xff;
165
+ b[i++] = tmh & 0xff; // `time_high_and_version`
166
+
167
+ b[i++] = tmh >>> 24 & 0xf | 0x10; // include version
168
+
169
+ b[i++] = tmh >>> 16 & 0xff; // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant)
170
+
171
+ b[i++] = clockseq >>> 8 | 0x80; // `clock_seq_low`
172
+
173
+ b[i++] = clockseq & 0xff; // `node`
174
+
175
+ for (let n = 0; n < 6; ++n) {
176
+ b[i + n] = node[n];
177
+ }
178
+
179
+ return buf || unsafeStringify(b);
180
+ }
181
+
182
+ function parse(uuid) {
183
+ if (!validate(uuid)) {
184
+ throw TypeError('Invalid UUID');
185
+ }
186
+
187
+ let v;
188
+ const arr = new Uint8Array(16); // Parse ########-....-....-....-............
189
+
190
+ arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24;
191
+ arr[1] = v >>> 16 & 0xff;
192
+ arr[2] = v >>> 8 & 0xff;
193
+ arr[3] = v & 0xff; // Parse ........-####-....-....-............
194
+
195
+ arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8;
196
+ arr[5] = v & 0xff; // Parse ........-....-####-....-............
197
+
198
+ arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8;
199
+ arr[7] = v & 0xff; // Parse ........-....-....-####-............
200
+
201
+ arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8;
202
+ arr[9] = v & 0xff; // Parse ........-....-....-....-############
203
+ // (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes)
204
+
205
+ arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff;
206
+ arr[11] = v / 0x100000000 & 0xff;
207
+ arr[12] = v >>> 24 & 0xff;
208
+ arr[13] = v >>> 16 & 0xff;
209
+ arr[14] = v >>> 8 & 0xff;
210
+ arr[15] = v & 0xff;
211
+ return arr;
212
+ }
213
+
214
+ function stringToBytes(str) {
215
+ str = unescape(encodeURIComponent(str)); // UTF8 escape
216
+
217
+ const bytes = [];
218
+
219
+ for (let i = 0; i < str.length; ++i) {
220
+ bytes.push(str.charCodeAt(i));
221
+ }
222
+
223
+ return bytes;
224
+ }
225
+
226
+ const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
227
+ const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
228
+ function v35(name, version, hashfunc) {
229
+ function generateUUID(value, namespace, buf, offset) {
230
+ var _namespace;
231
+
232
+ if (typeof value === 'string') {
233
+ value = stringToBytes(value);
234
+ }
235
+
236
+ if (typeof namespace === 'string') {
237
+ namespace = parse(namespace);
238
+ }
239
+
240
+ if (((_namespace = namespace) === null || _namespace === void 0 ? void 0 : _namespace.length) !== 16) {
241
+ throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)');
242
+ } // Compute hash of namespace and value, Per 4.3
243
+ // Future: Use spread syntax when supported on all platforms, e.g. `bytes =
244
+ // hashfunc([...namespace, ... value])`
245
+
246
+
247
+ let bytes = new Uint8Array(16 + value.length);
248
+ bytes.set(namespace);
249
+ bytes.set(value, namespace.length);
250
+ bytes = hashfunc(bytes);
251
+ bytes[6] = bytes[6] & 0x0f | version;
252
+ bytes[8] = bytes[8] & 0x3f | 0x80;
253
+
254
+ if (buf) {
255
+ offset = offset || 0;
256
+
257
+ for (let i = 0; i < 16; ++i) {
258
+ buf[offset + i] = bytes[i];
259
+ }
260
+
261
+ return buf;
262
+ }
263
+
264
+ return unsafeStringify(bytes);
265
+ } // Function#name is not settable on some platforms (#270)
266
+
267
+
268
+ try {
269
+ generateUUID.name = name; // eslint-disable-next-line no-empty
270
+ } catch (err) {} // For CommonJS default export support
271
+
272
+
273
+ generateUUID.DNS = DNS;
274
+ generateUUID.URL = URL;
275
+ return generateUUID;
276
+ }
277
+
278
+ /*
279
+ * Browser-compatible JavaScript MD5
280
+ *
281
+ * Modification of JavaScript MD5
282
+ * https://github.com/blueimp/JavaScript-MD5
283
+ *
284
+ * Copyright 2011, Sebastian Tschan
285
+ * https://blueimp.net
286
+ *
287
+ * Licensed under the MIT license:
288
+ * https://opensource.org/licenses/MIT
289
+ *
290
+ * Based on
291
+ * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
292
+ * Digest Algorithm, as defined in RFC 1321.
293
+ * Version 2.2 Copyright (C) Paul Johnston 1999 - 2009
294
+ * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
295
+ * Distributed under the BSD License
296
+ * See http://pajhome.org.uk/crypt/md5 for more info.
297
+ */
298
+ function md5(bytes) {
299
+ if (typeof bytes === 'string') {
300
+ const msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
301
+
302
+ bytes = new Uint8Array(msg.length);
303
+
304
+ for (let i = 0; i < msg.length; ++i) {
305
+ bytes[i] = msg.charCodeAt(i);
306
+ }
307
+ }
308
+
309
+ return md5ToHexEncodedArray(wordsToMd5(bytesToWords(bytes), bytes.length * 8));
310
+ }
311
+ /*
312
+ * Convert an array of little-endian words to an array of bytes
313
+ */
314
+
315
+
316
+ function md5ToHexEncodedArray(input) {
317
+ const output = [];
318
+ const length32 = input.length * 32;
319
+ const hexTab = '0123456789abcdef';
320
+
321
+ for (let i = 0; i < length32; i += 8) {
322
+ const x = input[i >> 5] >>> i % 32 & 0xff;
323
+ const hex = parseInt(hexTab.charAt(x >>> 4 & 0x0f) + hexTab.charAt(x & 0x0f), 16);
324
+ output.push(hex);
325
+ }
326
+
327
+ return output;
328
+ }
329
+ /**
330
+ * Calculate output length with padding and bit length
331
+ */
332
+
333
+
334
+ function getOutputLength(inputLength8) {
335
+ return (inputLength8 + 64 >>> 9 << 4) + 14 + 1;
336
+ }
337
+ /*
338
+ * Calculate the MD5 of an array of little-endian words, and a bit length.
339
+ */
340
+
341
+
342
+ function wordsToMd5(x, len) {
343
+ /* append padding */
344
+ x[len >> 5] |= 0x80 << len % 32;
345
+ x[getOutputLength(len) - 1] = len;
346
+ let a = 1732584193;
347
+ let b = -271733879;
348
+ let c = -1732584194;
349
+ let d = 271733878;
350
+
351
+ for (let i = 0; i < x.length; i += 16) {
352
+ const olda = a;
353
+ const oldb = b;
354
+ const oldc = c;
355
+ const oldd = d;
356
+ a = md5ff(a, b, c, d, x[i], 7, -680876936);
357
+ d = md5ff(d, a, b, c, x[i + 1], 12, -389564586);
358
+ c = md5ff(c, d, a, b, x[i + 2], 17, 606105819);
359
+ b = md5ff(b, c, d, a, x[i + 3], 22, -1044525330);
360
+ a = md5ff(a, b, c, d, x[i + 4], 7, -176418897);
361
+ d = md5ff(d, a, b, c, x[i + 5], 12, 1200080426);
362
+ c = md5ff(c, d, a, b, x[i + 6], 17, -1473231341);
363
+ b = md5ff(b, c, d, a, x[i + 7], 22, -45705983);
364
+ a = md5ff(a, b, c, d, x[i + 8], 7, 1770035416);
365
+ d = md5ff(d, a, b, c, x[i + 9], 12, -1958414417);
366
+ c = md5ff(c, d, a, b, x[i + 10], 17, -42063);
367
+ b = md5ff(b, c, d, a, x[i + 11], 22, -1990404162);
368
+ a = md5ff(a, b, c, d, x[i + 12], 7, 1804603682);
369
+ d = md5ff(d, a, b, c, x[i + 13], 12, -40341101);
370
+ c = md5ff(c, d, a, b, x[i + 14], 17, -1502002290);
371
+ b = md5ff(b, c, d, a, x[i + 15], 22, 1236535329);
372
+ a = md5gg(a, b, c, d, x[i + 1], 5, -165796510);
373
+ d = md5gg(d, a, b, c, x[i + 6], 9, -1069501632);
374
+ c = md5gg(c, d, a, b, x[i + 11], 14, 643717713);
375
+ b = md5gg(b, c, d, a, x[i], 20, -373897302);
376
+ a = md5gg(a, b, c, d, x[i + 5], 5, -701558691);
377
+ d = md5gg(d, a, b, c, x[i + 10], 9, 38016083);
378
+ c = md5gg(c, d, a, b, x[i + 15], 14, -660478335);
379
+ b = md5gg(b, c, d, a, x[i + 4], 20, -405537848);
380
+ a = md5gg(a, b, c, d, x[i + 9], 5, 568446438);
381
+ d = md5gg(d, a, b, c, x[i + 14], 9, -1019803690);
382
+ c = md5gg(c, d, a, b, x[i + 3], 14, -187363961);
383
+ b = md5gg(b, c, d, a, x[i + 8], 20, 1163531501);
384
+ a = md5gg(a, b, c, d, x[i + 13], 5, -1444681467);
385
+ d = md5gg(d, a, b, c, x[i + 2], 9, -51403784);
386
+ c = md5gg(c, d, a, b, x[i + 7], 14, 1735328473);
387
+ b = md5gg(b, c, d, a, x[i + 12], 20, -1926607734);
388
+ a = md5hh(a, b, c, d, x[i + 5], 4, -378558);
389
+ d = md5hh(d, a, b, c, x[i + 8], 11, -2022574463);
390
+ c = md5hh(c, d, a, b, x[i + 11], 16, 1839030562);
391
+ b = md5hh(b, c, d, a, x[i + 14], 23, -35309556);
392
+ a = md5hh(a, b, c, d, x[i + 1], 4, -1530992060);
393
+ d = md5hh(d, a, b, c, x[i + 4], 11, 1272893353);
394
+ c = md5hh(c, d, a, b, x[i + 7], 16, -155497632);
395
+ b = md5hh(b, c, d, a, x[i + 10], 23, -1094730640);
396
+ a = md5hh(a, b, c, d, x[i + 13], 4, 681279174);
397
+ d = md5hh(d, a, b, c, x[i], 11, -358537222);
398
+ c = md5hh(c, d, a, b, x[i + 3], 16, -722521979);
399
+ b = md5hh(b, c, d, a, x[i + 6], 23, 76029189);
400
+ a = md5hh(a, b, c, d, x[i + 9], 4, -640364487);
401
+ d = md5hh(d, a, b, c, x[i + 12], 11, -421815835);
402
+ c = md5hh(c, d, a, b, x[i + 15], 16, 530742520);
403
+ b = md5hh(b, c, d, a, x[i + 2], 23, -995338651);
404
+ a = md5ii(a, b, c, d, x[i], 6, -198630844);
405
+ d = md5ii(d, a, b, c, x[i + 7], 10, 1126891415);
406
+ c = md5ii(c, d, a, b, x[i + 14], 15, -1416354905);
407
+ b = md5ii(b, c, d, a, x[i + 5], 21, -57434055);
408
+ a = md5ii(a, b, c, d, x[i + 12], 6, 1700485571);
409
+ d = md5ii(d, a, b, c, x[i + 3], 10, -1894986606);
410
+ c = md5ii(c, d, a, b, x[i + 10], 15, -1051523);
411
+ b = md5ii(b, c, d, a, x[i + 1], 21, -2054922799);
412
+ a = md5ii(a, b, c, d, x[i + 8], 6, 1873313359);
413
+ d = md5ii(d, a, b, c, x[i + 15], 10, -30611744);
414
+ c = md5ii(c, d, a, b, x[i + 6], 15, -1560198380);
415
+ b = md5ii(b, c, d, a, x[i + 13], 21, 1309151649);
416
+ a = md5ii(a, b, c, d, x[i + 4], 6, -145523070);
417
+ d = md5ii(d, a, b, c, x[i + 11], 10, -1120210379);
418
+ c = md5ii(c, d, a, b, x[i + 2], 15, 718787259);
419
+ b = md5ii(b, c, d, a, x[i + 9], 21, -343485551);
420
+ a = safeAdd(a, olda);
421
+ b = safeAdd(b, oldb);
422
+ c = safeAdd(c, oldc);
423
+ d = safeAdd(d, oldd);
424
+ }
425
+
426
+ return [a, b, c, d];
427
+ }
428
+ /*
429
+ * Convert an array bytes to an array of little-endian words
430
+ * Characters >255 have their high-byte silently ignored.
431
+ */
432
+
433
+
434
+ function bytesToWords(input) {
435
+ if (input.length === 0) {
436
+ return [];
437
+ }
438
+
439
+ const length8 = input.length * 8;
440
+ const output = new Uint32Array(getOutputLength(length8));
441
+
442
+ for (let i = 0; i < length8; i += 8) {
443
+ output[i >> 5] |= (input[i / 8] & 0xff) << i % 32;
444
+ }
445
+
446
+ return output;
447
+ }
448
+ /*
449
+ * Add integers, wrapping at 2^32. This uses 16-bit operations internally
450
+ * to work around bugs in some JS interpreters.
451
+ */
452
+
453
+
454
+ function safeAdd(x, y) {
455
+ const lsw = (x & 0xffff) + (y & 0xffff);
456
+ const msw = (x >> 16) + (y >> 16) + (lsw >> 16);
457
+ return msw << 16 | lsw & 0xffff;
458
+ }
459
+ /*
460
+ * Bitwise rotate a 32-bit number to the left.
461
+ */
462
+
463
+
464
+ function bitRotateLeft(num, cnt) {
465
+ return num << cnt | num >>> 32 - cnt;
466
+ }
467
+ /*
468
+ * These functions implement the four basic operations the algorithm uses.
469
+ */
470
+
471
+
472
+ function md5cmn(q, a, b, x, s, t) {
473
+ return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b);
474
+ }
475
+
476
+ function md5ff(a, b, c, d, x, s, t) {
477
+ return md5cmn(b & c | ~b & d, a, b, x, s, t);
478
+ }
479
+
480
+ function md5gg(a, b, c, d, x, s, t) {
481
+ return md5cmn(b & d | c & ~d, a, b, x, s, t);
482
+ }
483
+
484
+ function md5hh(a, b, c, d, x, s, t) {
485
+ return md5cmn(b ^ c ^ d, a, b, x, s, t);
486
+ }
487
+
488
+ function md5ii(a, b, c, d, x, s, t) {
489
+ return md5cmn(c ^ (b | ~d), a, b, x, s, t);
490
+ }
491
+
492
+ const v3 = v35('v3', 0x30, md5);
493
+ var v3$1 = v3;
494
+
495
+ const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
496
+ var native = {
497
+ randomUUID
498
+ };
499
+
500
+ function v4(options, buf, offset) {
501
+ if (native.randomUUID && !buf && !options) {
502
+ return native.randomUUID();
503
+ }
504
+
505
+ options = options || {};
506
+ const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
507
+
508
+ rnds[6] = rnds[6] & 0x0f | 0x40;
509
+ rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
510
+
511
+ if (buf) {
512
+ offset = offset || 0;
513
+
514
+ for (let i = 0; i < 16; ++i) {
515
+ buf[offset + i] = rnds[i];
516
+ }
517
+
518
+ return buf;
519
+ }
520
+
521
+ return unsafeStringify(rnds);
522
+ }
523
+
524
+ // Adapted from Chris Veness' SHA1 code at
525
+ // http://www.movable-type.co.uk/scripts/sha1.html
526
+ function f(s, x, y, z) {
527
+ switch (s) {
528
+ case 0:
529
+ return x & y ^ ~x & z;
530
+
531
+ case 1:
532
+ return x ^ y ^ z;
533
+
534
+ case 2:
535
+ return x & y ^ x & z ^ y & z;
536
+
537
+ case 3:
538
+ return x ^ y ^ z;
539
+ }
540
+ }
541
+
542
+ function ROTL(x, n) {
543
+ return x << n | x >>> 32 - n;
544
+ }
545
+
546
+ function sha1(bytes) {
547
+ const K = [0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6];
548
+ const H = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0];
549
+
550
+ if (typeof bytes === 'string') {
551
+ const msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
552
+
553
+ bytes = [];
554
+
555
+ for (let i = 0; i < msg.length; ++i) {
556
+ bytes.push(msg.charCodeAt(i));
557
+ }
558
+ } else if (!Array.isArray(bytes)) {
559
+ // Convert Array-like to Array
560
+ bytes = Array.prototype.slice.call(bytes);
561
+ }
562
+
563
+ bytes.push(0x80);
564
+ const l = bytes.length / 4 + 2;
565
+ const N = Math.ceil(l / 16);
566
+ const M = new Array(N);
567
+
568
+ for (let i = 0; i < N; ++i) {
569
+ const arr = new Uint32Array(16);
570
+
571
+ for (let j = 0; j < 16; ++j) {
572
+ arr[j] = bytes[i * 64 + j * 4] << 24 | bytes[i * 64 + j * 4 + 1] << 16 | bytes[i * 64 + j * 4 + 2] << 8 | bytes[i * 64 + j * 4 + 3];
573
+ }
574
+
575
+ M[i] = arr;
576
+ }
577
+
578
+ M[N - 1][14] = (bytes.length - 1) * 8 / Math.pow(2, 32);
579
+ M[N - 1][14] = Math.floor(M[N - 1][14]);
580
+ M[N - 1][15] = (bytes.length - 1) * 8 & 0xffffffff;
581
+
582
+ for (let i = 0; i < N; ++i) {
583
+ const W = new Uint32Array(80);
584
+
585
+ for (let t = 0; t < 16; ++t) {
586
+ W[t] = M[i][t];
587
+ }
588
+
589
+ for (let t = 16; t < 80; ++t) {
590
+ W[t] = ROTL(W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16], 1);
591
+ }
592
+
593
+ let a = H[0];
594
+ let b = H[1];
595
+ let c = H[2];
596
+ let d = H[3];
597
+ let e = H[4];
598
+
599
+ for (let t = 0; t < 80; ++t) {
600
+ const s = Math.floor(t / 20);
601
+ const T = ROTL(a, 5) + f(s, b, c, d) + e + K[s] + W[t] >>> 0;
602
+ e = d;
603
+ d = c;
604
+ c = ROTL(b, 30) >>> 0;
605
+ b = a;
606
+ a = T;
607
+ }
608
+
609
+ H[0] = H[0] + a >>> 0;
610
+ H[1] = H[1] + b >>> 0;
611
+ H[2] = H[2] + c >>> 0;
612
+ H[3] = H[3] + d >>> 0;
613
+ H[4] = H[4] + e >>> 0;
614
+ }
615
+
616
+ return [H[0] >> 24 & 0xff, H[0] >> 16 & 0xff, H[0] >> 8 & 0xff, H[0] & 0xff, H[1] >> 24 & 0xff, H[1] >> 16 & 0xff, H[1] >> 8 & 0xff, H[1] & 0xff, H[2] >> 24 & 0xff, H[2] >> 16 & 0xff, H[2] >> 8 & 0xff, H[2] & 0xff, H[3] >> 24 & 0xff, H[3] >> 16 & 0xff, H[3] >> 8 & 0xff, H[3] & 0xff, H[4] >> 24 & 0xff, H[4] >> 16 & 0xff, H[4] >> 8 & 0xff, H[4] & 0xff];
617
+ }
618
+
619
+ const v5 = v35('v5', 0x50, sha1);
620
+ var v5$1 = v5;
621
+
622
+ var nil = '00000000-0000-0000-0000-000000000000';
623
+
624
+ function version(uuid) {
625
+ if (!validate(uuid)) {
626
+ throw TypeError('Invalid UUID');
627
+ }
628
+
629
+ return parseInt(uuid.slice(14, 15), 16);
630
+ }
631
+
632
+ var esmBrowser = /*#__PURE__*/Object.freeze({
633
+ __proto__: null,
634
+ NIL: nil,
635
+ parse: parse,
636
+ stringify: stringify,
637
+ v1: v1,
638
+ v3: v3$1,
639
+ v4: v4,
640
+ v5: v5$1,
641
+ validate: validate,
642
+ version: version
643
+ });
644
+
645
+ var require$$0 = /*@__PURE__*/getAugmentedNamespace(esmBrowser);
646
+
647
+ /**
648
+ * Copyright (C) 2010-2023 - SipTimes Technologies Corporation - All rights reserved.
649
+ */
650
+
651
+ const CORE = Object.freeze({ // core level api
652
+ PLATFORM: 'core-platform',
653
+ CONFIG: 'core-config',
654
+ BOX_INFO: 'core-box-info',
655
+ SIGN_INFO: 'core-sign-info',
656
+ SIGN_GROUP_INFO: 'core-sign-group-info',
657
+ SHELL: 'core-shell',
658
+ DATABASE: 'core-database',
659
+ GET_VOLUME: 'core-get-volume',
660
+ SET_VOLUME: 'core-set-volume'
661
+ });
662
+ const CORE_NORESP = Object.freeze({ // core level api with no response
663
+ IPC: 'core-ipc',
664
+ HEARTBEAT_PING: 'core-heartbeat-ping',
665
+ HEARTBEAT_REGISTER: 'core-heartbeat-register',
666
+ HEARTBEAT_UNREGISTER: 'core-heartbeat-unregister',
667
+ LOGGER: 'core-logger'
668
+ });
669
+ const CORE_APP = Object.freeze({ // application level api, notification from core
670
+ NOTIFICATION: 'core-notification', HEARTBEAT_LISTENER: 'core-heartbeat-listener'
671
+ });
672
+
673
+ const DEVICE = Object.freeze({ // core level api
674
+ CHANNEL: 'device-channel',
675
+ DEFAULT: 'device-default',
676
+ ID_CARD_READER: 'device-id-card-reader',
677
+ NFC: 'device-nfc',
678
+ FINGERPRINT_READER: 'device-fingerprint-reader',
679
+ QR_CODE_SCANNER: 'device-qr-code-scanner',
680
+ PRINTER: 'device-printer'
681
+ });
682
+
683
+ const HEARTBEAT_STATUS = Object.freeze({
684
+ REGISTER: "register", ALIVE: "alive", ERROR: 'error', NOT_FOUND: 'not-found', SUCCESS: 'success'
685
+ });
686
+
687
+ const cutosAPI$1 = {
688
+ version: '2.0.1', CORE, CORE_NORESP, CORE_APP, DEVICE, HEARTBEAT_STATUS
689
+ };
690
+ var cutosApi = cutosAPI$1;
691
+
692
+ /**
693
+ * Copyright (C) 2010-2023 - SipTimes Technologies Corporation - All rights reserved.
694
+ */
695
+
696
+ const {v4: uuidv4} = require$$0;
697
+ const mqtt = require$$1;
698
+ const cutosAPI = cutosApi;
699
+ const callbackMap = new Map();
700
+ const listenerMap = new Map();
701
+
702
+ const ipformat = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
703
+
704
+ let client = null;
705
+
706
+ function publishRequest(api, callback, body, destAddress) {
707
+ let request = {};
708
+ request.context = {};
709
+ request.context.id = uuidv4();
710
+ request.context.destAddress = destAddress;
711
+ request.body = body;
712
+ if (typeof callback === "function") {
713
+ callbackMap.set(request.context.id, callback);
714
+ }
715
+ client.publish(api, JSON.stringify(request));
716
+ return true;
717
+ }
718
+
719
+ /*
720
+ retentionTime: retention time, default 48 hours
721
+ */
722
+ class Database {
723
+ KEY_TYPE_TEXT = "TEXT";
724
+ KEY_TYPE_INTEGER = "INTEGER";
725
+
726
+ constructor(db, callback, retentionTime = 48) {
727
+ // sub class
728
+ this.Table = class {
729
+ constructor(db, name, callback, retentionTime, keyType, keyName) {
730
+ this.db = db;
731
+ this.name = name;
732
+ let body = {
733
+ db: this.db, cmd: "db.table.create", name: name
734
+ };
735
+ if (retentionTime) {
736
+ body.retentionTime = retentionTime;
737
+ }
738
+ if (keyType === 'INTEGER' || keyType === 'TEXT') {
739
+ body.keyName = keyName;
740
+ body.keyType = keyType;
741
+ } else {
742
+ throw new Error("keyType MUST be INTEGER or TEXT");
743
+
744
+ }
745
+ return publishRequest(cutosAPI.CORE.DATABASE, callback, body);
746
+ }
747
+
748
+ insert(value, callback, tid) {
749
+ let body = {
750
+ db: this.db, cmd: "db.table.insert", name: this.name, value: value, tid: tid
751
+ };
752
+ return publishRequest(cutosAPI.CORE.DATABASE, callback, body);
753
+ }
754
+
755
+ insertById(id, value, callback, tid) {
756
+ let body = {
757
+ db: this.db, cmd: "db.table.insertById", name: this.name, id: id, value: value, tid: tid
758
+ };
759
+ return publishRequest(cutosAPI.CORE.DATABASE, callback, body);
760
+ }
761
+
762
+ insertByKey(key, value, callback, tid) {
763
+ let body = {
764
+ db: this.db, cmd: "db.table.insertByKey", name: this.name, key: key, value: value, tid: tid
765
+ };
766
+ return publishRequest(cutosAPI.CORE.DATABASE, callback, body);
767
+ }
768
+
769
+ update(id, value, callback) {
770
+ let body = {
771
+ db: this.db, cmd: "db.table.update", name: this.name, id: id, value: value
772
+ };
773
+ return publishRequest(cutosAPI.CORE.DATABASE, callback, body);
774
+ }
775
+
776
+ updateByKey(key, value, callback) {
777
+ let body = {
778
+ db: this.db, cmd: "db.table.updateByKey", name: this.name, key: key, value: value
779
+ };
780
+ return publishRequest(cutosAPI.CORE.DATABASE, callback, body);
781
+ }
782
+
783
+ delete(id, callback) {
784
+ let body = {
785
+ db: this.db, cmd: "db.table.delete", name: this.name, id: id
786
+ };
787
+ return publishRequest(cutosAPI.CORE.DATABASE, callback, body);
788
+ }
789
+
790
+ query(id, callback, count = 100) {
791
+ let body = {
792
+ db: this.db, cmd: "db.table.query", name: this.name, id: id
793
+ };
794
+ return publishRequest(cutosAPI.CORE.DATABASE, callback, body);
795
+ }
796
+
797
+ queryByKey(key, callback, count = 100) {
798
+ let body = {
799
+ db: this.db, cmd: "db.table.queryByKey", name: this.name, key: key
800
+ };
801
+ return publishRequest(cutosAPI.CORE.DATABASE, callback, body);
802
+ }
803
+
804
+ queryByTid(tid, callback, limit = 100) {
805
+ let body = {
806
+ db: this.db, cmd: "db.table.queryByTid", name: this.name, limit: limit, tid: tid
807
+ };
808
+ return publishRequest(cutosAPI.CORE.DATABASE, callback, body);
809
+ }
810
+
811
+ queryUnsynced(callback, limit = 100) {
812
+ let body = {
813
+ db: this.db, cmd: "db.table.queryUnsynced", name: this.name, limit: limit
814
+ };
815
+ return publishRequest(cutosAPI.CORE.DATABASE, callback, body);
816
+ }
817
+
818
+ queryAll(callback) {
819
+ let body = {
820
+ db: this.db, cmd: "db.table.queryAll", name: this.name
821
+ };
822
+ return publishRequest(cutosAPI.CORE.DATABASE, callback, body);
823
+ }
824
+
825
+ sync(id, callback) {
826
+ let body = {
827
+ db: this.db, cmd: "db.table.sync", name: this.name, id: id
828
+ };
829
+ return publishRequest(cutosAPI.CORE.DATABASE, callback, body);
830
+ }
831
+ };
832
+ this.db = db;
833
+ this.retentionTime = retentionTime;
834
+ let body = {
835
+ cmd: "db.connect", db: this.db
836
+ };
837
+ return publishRequest(cutosAPI.CORE.DATABASE, callback, body);
838
+ }
839
+
840
+ run(sql, callback) {
841
+ let body = {
842
+ db: this.db, cmd: "db.run", sql: sql
843
+ };
844
+ return publishRequest(cutosAPI.CORE.DATABASE, callback, body);
845
+ }
846
+
847
+ createTable(name, callback, retentionTime, keyType = 'INTEGER', keyName = 'id') {
848
+ return new this.Table(null, name, callback, retentionTime, keyType, keyName);
849
+ }
850
+ }
851
+
852
+ class Logger {
853
+ constructor() {
854
+ }
855
+
856
+ info(remark, content, type = "LWA") {
857
+ let body = {
858
+ type: type, level: "info", remark: remark, content: content
859
+ };
860
+ return publishRequest(cutosAPI.CORE_NORESP.LOGGER, null, body);
861
+ }
862
+
863
+ warning(remark, content, type = "LWA") {
864
+ let body = {
865
+ type: type, level: "warning", remark: remark, content: content
866
+ };
867
+ return publishRequest(cutosAPI.CORE_NORESP.LOGGER, null, body);
868
+ }
869
+
870
+ error(remark, content, type = "LWA") {
871
+ let body = {
872
+ type: type, level: "error", remark: remark, content: content
873
+ };
874
+ return publishRequest(cutosAPI.CORE_NORESP.LOGGER, null, body);
875
+ }
876
+
877
+ debug(remark, content, type = "LWA") {
878
+ let body = {
879
+ type: type, level: "debug", remark: remark, content: content
880
+ };
881
+ return publishRequest(cutosAPI.CORE_NORESP.LOGGER, null, body);
882
+ }
883
+ }
884
+
885
+ class IPC {
886
+ constructor(destAddress) {
887
+ if (destAddress === undefined || destAddress === null || destAddress.length === 0 || destAddress === 'localhost' || destAddress === '127.0.0.1') {
888
+ this.destAddress = undefined;
889
+ } else if (destAddress.match(ipformat)) {
890
+ this.destAddress = destAddress;
891
+ } else {
892
+ throw new TypeError(destAddress + " is NOT an ip address.");
893
+ }
894
+ }
895
+
896
+ sendTo(channel, args) {
897
+ let body = {};
898
+ body.channel = channel;
899
+ body.args = args;
900
+ return publishRequest(cutosAPI.CORE_NORESP.IPC, null, body, this.destAddress);
901
+ }
902
+
903
+ on(channel, listener) {
904
+ listenerMap.set(channel, listener);
905
+ }
906
+
907
+ removeListener(channel) {
908
+ listenerMap.delete(channel);
909
+ }
910
+ }
911
+
912
+ class Notification {
913
+ constructor() {
914
+ }
915
+
916
+ register(listener) {
917
+ listenerMap.set(cutosAPI.CORE_APP.NOTIFICATION, listener);
918
+ }
919
+
920
+ unregister() {
921
+ listenerMap.delete(cutosAPI.CORE_APP.NOTIFICATION);
922
+ }
923
+
924
+ emit(event, msg) {
925
+ client.publish(cutosAPI.CORE_APP.NOTIFICATION, JSON.stringify({event: event, msg: msg}));
926
+ return true;
927
+ }
928
+ }
929
+
930
+ class Heartbeat {
931
+ STATUS = cutosAPI.HEARTBEAT_STATUS;
932
+
933
+ constructor(pinger, counter) {
934
+ this.registered = false;
935
+ this.request = {};
936
+ this.request.counter = counter;
937
+ this.request.pinger = pinger;
938
+ this.request.subscriber = cutosAPI.CORE_NORESP.HEARTBEAT_PING + '-' + pinger;
939
+
940
+ }
941
+
942
+ register() {
943
+ this.request.msg = {};
944
+ this.request.msg.status = this.STATUS.REGISTER;
945
+ this.request.msg.info = `Start to monitor ${this.request.pinger}.`;
946
+
947
+ client.publish(cutosAPI.CORE_NORESP.HEARTBEAT_REGISTER, JSON.stringify(this.request));
948
+ this.registered = true;
949
+ }
950
+
951
+ ping(status, info = {}) {
952
+ if (!this.registered) {
953
+ throw ("The heartbeat is NOT registered!")
954
+ }
955
+ this.request.msg = {};
956
+ this.request.msg.status = status;
957
+ this.request.msg.info = info;
958
+ client.publish(cutosAPI.CORE_NORESP.HEARTBEAT_PING, JSON.stringify(this.request));
959
+ }
960
+ }
961
+
962
+ class Device {
963
+ constructor(name = 'default-device-name', type = cutosAPI.DEVICE.DEFAULT, callback) {
964
+ this.name = name;
965
+ this.type = type;
966
+ this.topicData = cutosAPI.DEVICE.CHANNEL + '-' + type + '-data';
967
+ this.topicResponse = cutosAPI.DEVICE.CHANNEL + '-' + type + '-response';
968
+ this.topicCommand = cutosAPI.DEVICE.CHANNEL + '-' + type + '-command';
969
+ this.data = {};
970
+
971
+ if (Device.objectMap === undefined) {
972
+ Device.objectMap = new Map();
973
+ }
974
+ Device.objectMap.set(this.type, this);
975
+
976
+ if (Device.heartbeatListener === undefined) {
977
+ Device.heartbeatListener = function (msg) {
978
+ for (const [key, obj] of Device.objectMap) {
979
+ if (obj.statusListener !== undefined) {
980
+ if (obj.type === "default-device" || obj.type === msg.pinger) {
981
+ obj.statusListener(msg);
982
+ obj.msg = msg;
983
+ }
984
+ }
985
+ }
986
+ //console.debug(JSON.stringify(msg));
987
+ };
988
+ listenerMap.set(cutosAPI.CORE_APP.HEARTBEAT_LISTENER, Device.heartbeatListener);
989
+ }
990
+ this.init(name, type, callback);
991
+ }
992
+
993
+ init(name, type, callback) {
994
+ let command = {};
995
+ command.cmd = "init";
996
+ command.args = {name: name, type: type};
997
+ command.topicResponse = this.topicResponse;
998
+ let defaultTopic = cutosAPI.DEVICE.CHANNEL + '-' + cutosAPI.DEVICE.DEFAULT + '-command';
999
+ client.publish(defaultTopic, JSON.stringify(command));
1000
+
1001
+ // response callback
1002
+ client.subscribe(this.topicResponse); // receive response from device
1003
+ listenerMap.set(this.topicResponse, callback);
1004
+ }
1005
+
1006
+ onStatus(listener) {
1007
+ this.statusListener = listener;
1008
+ }
1009
+
1010
+ getCurrentStatus() {
1011
+ return this.msg;
1012
+ }
1013
+
1014
+ sendCommand(command) {
1015
+ client.publish(this.topicCommand, JSON.stringify(command));
1016
+ }
1017
+
1018
+ onData(listener) {
1019
+ client.subscribe(this.topicData); // receive data from device
1020
+ let _this = this;
1021
+ listenerMap.set(this.topicData, function (data) {
1022
+ _this.data = data;
1023
+ listener(data);
1024
+ });
1025
+ }
1026
+
1027
+ getCurrentData() {
1028
+ return this.data;
1029
+ }
1030
+
1031
+ readDeviceInfo(context) {
1032
+ let msg = {};
1033
+ msg.cmd = "read-device-info";
1034
+ msg.context = context;
1035
+ this.sendCommand(msg);
1036
+ }
1037
+ }
1038
+
1039
+ class Driver {
1040
+ constructor(name = 'default-driver-name', type = cutosAPI.DEVICE.DEFAULT, counter = 10) {
1041
+ this.name = name;
1042
+ this.type = type;
1043
+ this.heartbeat = new Heartbeat(type, counter);
1044
+ this.statusInfo = {};
1045
+ this.beatInterval = 3000;
1046
+ this.topicData = cutosAPI.DEVICE.CHANNEL + '-' + type + '-data';
1047
+ this.topicResponse = cutosAPI.DEVICE.CHANNEL + '-' + type + '-response';
1048
+ this.topicCommand = cutosAPI.DEVICE.CHANNEL + '-' + type + '-command';
1049
+
1050
+ }
1051
+
1052
+ startBeat() {
1053
+ this.heartbeat.register();
1054
+ let _this = this;
1055
+ setInterval(function () {
1056
+ if (_this.statusInfo.status !== undefined && _this.statusInfo.status !== _this.heartbeat.STATUS.REGISTER) {
1057
+ _this.heartbeat.ping(_this.statusInfo.status, _this.statusInfo.info);
1058
+ }
1059
+ }, _this.beatInterval);
1060
+ }
1061
+
1062
+ updateStatusInfo(status = 'default-status', info = 'default-info') {
1063
+ this.statusInfo.status = status;
1064
+ this.statusInfo.info = info;
1065
+ }
1066
+
1067
+ sendData(data) {
1068
+ client.publish(this.topicData, JSON.stringify(data));
1069
+ }
1070
+
1071
+ sendResponse(data, topic = this.topicResponse) {
1072
+ client.publish(topic, JSON.stringify(data));
1073
+ }
1074
+
1075
+ onCommand(listener) {
1076
+ client.subscribe(this.topicCommand); // receive command from app
1077
+ listenerMap.set(this.topicCommand, listener);
1078
+ }
1079
+ }
1080
+
1081
+ class CoreAPI {
1082
+ constructor(mqttHost = 'ws://localhost:1883') {
1083
+ client = mqtt.connect(mqttHost);
1084
+
1085
+ client.on('connect', function () {
1086
+ console.log("CUTOS CORE connected.");
1087
+ for (let api in cutosAPI.CORE) {
1088
+ client.subscribe(cutosAPI.CORE[api] + '-callback');
1089
+ }
1090
+ for (let api in cutosAPI.CORE_NORESP) {
1091
+ client.subscribe(cutosAPI.CORE_NORESP[api] + '-endpoint');
1092
+ }
1093
+ for (let api in cutosAPI.CORE_APP) {
1094
+ client.subscribe(cutosAPI.CORE_APP[api]);
1095
+ }
1096
+ });
1097
+
1098
+ client.on('message', function (topic, message, context) {
1099
+ // message is Buffer
1100
+ // console.debug(topic.toString() + message.toString());
1101
+ let _message = JSON.parse(message);
1102
+ if (topic === cutosAPI.CORE_NORESP.IPC + '-endpoint') { // ipc
1103
+ let listener = listenerMap.get(_message.body.channel);
1104
+ if (listener !== undefined) {
1105
+ listener(_message.body.args, _message.context);
1106
+ }
1107
+ } else if (topic === cutosAPI.CORE_APP.NOTIFICATION || topic === cutosAPI.CORE_APP.HEARTBEAT_LISTENER || topic.startsWith(cutosAPI.DEVICE.CHANNEL)) {
1108
+ let listener = listenerMap.get(topic);
1109
+ if (listener !== undefined) {
1110
+ listener(_message);
1111
+ }
1112
+ } else { // cutos core api callback
1113
+ let callback = callbackMap.get(_message.id);
1114
+ if (typeof callback === "function") {
1115
+ callbackMap.delete(_message.id);
1116
+ callback(_message.result);
1117
+ }
1118
+ }
1119
+ });
1120
+
1121
+ client.on("close", () => {
1122
+ console.log("CUTOS CORE closed.");
1123
+ });
1124
+
1125
+ client.on("error", (e) => {
1126
+ console.error("CUTOS CORE error: ", e.message);
1127
+ });
1128
+ }
1129
+
1130
+ connected() {
1131
+ return client.connected;
1132
+ }
1133
+
1134
+ getVersion() {
1135
+ return cutosAPI.version;
1136
+ }
1137
+
1138
+ getPlatform(callback) {
1139
+ return publishRequest(cutosAPI.CORE.PLATFORM, callback);
1140
+ }
1141
+
1142
+ getConfig(callback) {
1143
+ return publishRequest(cutosAPI.CORE.CONFIG, callback);
1144
+ }
1145
+
1146
+ getBoxInfo(callback) {
1147
+ return publishRequest(cutosAPI.CORE.BOX_INFO, callback);
1148
+ }
1149
+
1150
+ getSignInfo(callback) {
1151
+ return publishRequest(cutosAPI.CORE.SIGN_INFO, callback);
1152
+ }
1153
+
1154
+ getSignGroupInfo(callback) {
1155
+ return publishRequest(cutosAPI.CORE.SIGN_GROUP_INFO, callback);
1156
+ }
1157
+
1158
+ getIPC(destAddress) {
1159
+ return new IPC(destAddress);
1160
+ }
1161
+
1162
+ getNotification() {
1163
+ return new Notification();
1164
+ }
1165
+
1166
+ getLogger() {
1167
+ return new Logger();
1168
+ }
1169
+
1170
+ shell(command, callback) {
1171
+ return publishRequest(cutosAPI.CORE.SHELL, callback, command);
1172
+ }
1173
+
1174
+ getDatabase(db, callback) {
1175
+ return new Database(db, callback);
1176
+ }
1177
+
1178
+ getVolume(callback) {
1179
+ return publishRequest(cutosAPI.CORE.GET_VOLUME, callback);
1180
+ }
1181
+
1182
+ setVolume(vol, callback) {
1183
+ return publishRequest(cutosAPI.CORE.SET_VOLUME, callback, vol);
1184
+ }
1185
+ }
1186
+
1187
+ var CoreAPI_1 = cutos.CoreAPI = CoreAPI;
1188
+ var CoreDefine = cutos.CoreDefine = {
1189
+ DEVICE: cutosAPI.DEVICE, HEARTBEAT_STATUS: cutosAPI.HEARTBEAT_STATUS
1190
+ };
1191
+ var CoreClass = cutos.CoreClass = {
1192
+ Device, Driver
1193
+ };
1194
+ var cutosAPI_1 = cutos.cutosAPI = cutosAPI;
1195
+
1196
+ exports.CoreAPI = CoreAPI_1;
1197
+ exports.CoreClass = CoreClass;
1198
+ exports.CoreDefine = CoreDefine;
1199
+ exports.cutosAPI = cutosAPI_1;
1200
+ exports.default = cutos;