@camera.ui/camera-ui-tuya 0.0.20 → 0.0.21
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/bundle.zip +0 -0
- package/package.json +16 -37
- package/CHANGELOG.md +0 -8
- package/CONTRIBUTING.md +0 -1
- package/LICENSE.md +0 -22
- package/README.md +0 -1
- package/config.schema.json +0 -296
- package/dist/camera.d.ts +0 -34
- package/dist/camera.js +0 -247
- package/dist/camera.js.map +0 -1
- package/dist/index.d.ts +0 -24
- package/dist/index.js +0 -225
- package/dist/index.js.map +0 -1
- package/dist/peer.d.ts +0 -34
- package/dist/peer.js +0 -268
- package/dist/peer.js.map +0 -1
- package/dist/tuya/cloud.d.ts +0 -35
- package/dist/tuya/cloud.js +0 -227
- package/dist/tuya/cloud.js.map +0 -1
- package/dist/tuya/const.d.ts +0 -121
- package/dist/tuya/const.js +0 -2
- package/dist/tuya/const.js.map +0 -1
- package/dist/tuya/device.d.ts +0 -14
- package/dist/tuya/device.js +0 -68
- package/dist/tuya/device.js.map +0 -1
- package/dist/tuya/mq.d.ts +0 -25
- package/dist/tuya/mq.js +0 -85
- package/dist/tuya/mq.js.map +0 -1
- package/dist/tuya/pulsar.d.ts +0 -74
- package/dist/tuya/pulsar.js +0 -198
- package/dist/tuya/pulsar.js.map +0 -1
- package/dist/tuya/utils.d.ts +0 -16
- package/dist/tuya/utils.js +0 -276
- package/dist/tuya/utils.js.map +0 -1
- package/dist/types.d.ts +0 -11
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
package/dist/tuya/const.js
DELETED
package/dist/tuya/const.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"const.js","sourceRoot":"","sources":["../../src/tuya/const.ts"],"names":[],"mappings":""}
|
package/dist/tuya/device.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { TuyaCloud } from './cloud.js';
|
|
2
|
-
import type { TuyaDeviceConfig, TuyaDeviceStatus } from './const.js';
|
|
3
|
-
export declare namespace TuyaDevice {
|
|
4
|
-
function hasLightSwitch(camera: TuyaDeviceConfig): boolean;
|
|
5
|
-
function getLightSwitchStatus(camera: TuyaDeviceConfig): TuyaDeviceStatus | undefined;
|
|
6
|
-
function hasStatusIndicator(camera: TuyaDeviceConfig): boolean;
|
|
7
|
-
function getStatusIndicator(camera: TuyaDeviceConfig): TuyaDeviceStatus | undefined;
|
|
8
|
-
function isDoorbell(camera: TuyaDeviceConfig): boolean;
|
|
9
|
-
function getDoorbellRing(camera: TuyaDeviceConfig): TuyaDeviceStatus | undefined;
|
|
10
|
-
function hasMotionDetection(camera: TuyaDeviceConfig): boolean;
|
|
11
|
-
function getMotionDetectionStatus(camera: TuyaDeviceConfig): TuyaDeviceStatus | undefined;
|
|
12
|
-
function supportsWebRTC(camera: TuyaDeviceConfig, cloud: TuyaCloud): Promise<boolean>;
|
|
13
|
-
function getStatus(camera: TuyaDeviceConfig, statusCode: string[]): TuyaDeviceStatus | undefined;
|
|
14
|
-
}
|
package/dist/tuya/device.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
export var TuyaDevice;
|
|
2
|
-
(function (TuyaDevice) {
|
|
3
|
-
// MARK: Switch Light
|
|
4
|
-
function hasLightSwitch(camera) {
|
|
5
|
-
return getLightSwitchStatus(camera) !== undefined;
|
|
6
|
-
}
|
|
7
|
-
TuyaDevice.hasLightSwitch = hasLightSwitch;
|
|
8
|
-
function getLightSwitchStatus(camera) {
|
|
9
|
-
const lightStatusCode = [
|
|
10
|
-
'floodlight_switch', // Devices with floodlight switch
|
|
11
|
-
];
|
|
12
|
-
return getStatus(camera, lightStatusCode);
|
|
13
|
-
}
|
|
14
|
-
TuyaDevice.getLightSwitchStatus = getLightSwitchStatus;
|
|
15
|
-
// MARK: Status Indicator
|
|
16
|
-
function hasStatusIndicator(camera) {
|
|
17
|
-
return getStatusIndicator(camera) !== undefined;
|
|
18
|
-
}
|
|
19
|
-
TuyaDevice.hasStatusIndicator = hasStatusIndicator;
|
|
20
|
-
function getStatusIndicator(camera) {
|
|
21
|
-
return getStatus(camera, ['basic_indicator']);
|
|
22
|
-
}
|
|
23
|
-
TuyaDevice.getStatusIndicator = getStatusIndicator;
|
|
24
|
-
// MARK: Doorbell
|
|
25
|
-
function isDoorbell(camera) {
|
|
26
|
-
const search = [
|
|
27
|
-
'wireless_powermode', // According to tuya, most low-powered devices are doorbells
|
|
28
|
-
'doorbell_ring_exist', // Typically, doorbells are able to add chimes. If this option is available, then most likely it is a doorbell.
|
|
29
|
-
// 'doorbell_active', // Seems to be very common even in non-doorbell config
|
|
30
|
-
];
|
|
31
|
-
for (const code of search) {
|
|
32
|
-
const status = camera.status.find((status) => status.code == code);
|
|
33
|
-
if (status?.value !== undefined) {
|
|
34
|
-
return true;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return false;
|
|
38
|
-
}
|
|
39
|
-
TuyaDevice.isDoorbell = isDoorbell;
|
|
40
|
-
function getDoorbellRing(camera) {
|
|
41
|
-
const ring = ['alarm_message', 'doorbell_pic'];
|
|
42
|
-
return getStatus(camera, ring);
|
|
43
|
-
}
|
|
44
|
-
TuyaDevice.getDoorbellRing = getDoorbellRing;
|
|
45
|
-
// MARK: Motion Detection
|
|
46
|
-
function hasMotionDetection(camera) {
|
|
47
|
-
const motionSwitchCodes = ['motion_switch', 'pir_sensitivity'];
|
|
48
|
-
return getStatus(camera, motionSwitchCodes) !== undefined;
|
|
49
|
-
}
|
|
50
|
-
TuyaDevice.hasMotionDetection = hasMotionDetection;
|
|
51
|
-
function getMotionDetectionStatus(camera) {
|
|
52
|
-
const motionDetectionCodes = ['movement_detect_pic'];
|
|
53
|
-
return getStatus(camera, motionDetectionCodes);
|
|
54
|
-
}
|
|
55
|
-
TuyaDevice.getMotionDetectionStatus = getMotionDetectionStatus;
|
|
56
|
-
// Supports WebRTC
|
|
57
|
-
async function supportsWebRTC(camera, cloud) {
|
|
58
|
-
const webRTConfig = await cloud.getDeviceWebRTConfig(camera);
|
|
59
|
-
return webRTConfig.success && webRTConfig.result.supports_webrtc;
|
|
60
|
-
}
|
|
61
|
-
TuyaDevice.supportsWebRTC = supportsWebRTC;
|
|
62
|
-
// Device Status
|
|
63
|
-
function getStatus(camera, statusCode) {
|
|
64
|
-
return camera.status.find((value) => statusCode.includes(value.code));
|
|
65
|
-
}
|
|
66
|
-
TuyaDevice.getStatus = getStatus;
|
|
67
|
-
})(TuyaDevice || (TuyaDevice = {}));
|
|
68
|
-
//# sourceMappingURL=device.js.map
|
package/dist/tuya/device.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"device.js","sourceRoot":"","sources":["../../src/tuya/device.ts"],"names":[],"mappings":"AAGA,MAAM,KAAW,UAAU,CA0E1B;AA1ED,WAAiB,UAAU;IACzB,qBAAqB;IAErB,SAAgB,cAAc,CAAC,MAAwB;QACrD,OAAO,oBAAoB,CAAC,MAAM,CAAC,KAAK,SAAS,CAAC;IACpD,CAAC;IAFe,yBAAc,iBAE7B,CAAA;IAED,SAAgB,oBAAoB,CAAC,MAAwB;QAC3D,MAAM,eAAe,GAAG;YACtB,mBAAmB,EAAE,iCAAiC;SACvD,CAAC;QAEF,OAAO,SAAS,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAC5C,CAAC;IANe,+BAAoB,uBAMnC,CAAA;IAED,yBAAyB;IAEzB,SAAgB,kBAAkB,CAAC,MAAwB;QACzD,OAAO,kBAAkB,CAAC,MAAM,CAAC,KAAK,SAAS,CAAC;IAClD,CAAC;IAFe,6BAAkB,qBAEjC,CAAA;IAED,SAAgB,kBAAkB,CAAC,MAAwB;QACzD,OAAO,SAAS,CAAC,MAAM,EAAE,CAAC,iBAAiB,CAAC,CAAC,CAAC;IAChD,CAAC;IAFe,6BAAkB,qBAEjC,CAAA;IAED,iBAAiB;IAEjB,SAAgB,UAAU,CAAC,MAAwB;QACjD,MAAM,MAAM,GAAG;YACb,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ACnE,CAAC;IAHqB,yBAAc,iBAGnC,CAAA;IAED,gBAAgB;IAEhB,SAAgB,SAAS,CAAC,MAAwB,EAAE,UAAoB;QACtE,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;IACxE,CAAC;IAFe,oBAAS,YAExB,CAAA;AACH,CAAC,EA1EgB,UAAU,KAAV,UAAU,QA0E1B"}
|
package/dist/tuya/mq.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import * as mqtt from 'mqtt';
|
|
2
|
-
import type { MqttClient } from 'mqtt';
|
|
3
|
-
import type { MQTTConfig } from './const.js';
|
|
4
|
-
export declare class TuyaMQ {
|
|
5
|
-
static connected: string;
|
|
6
|
-
static message: string;
|
|
7
|
-
static error: string;
|
|
8
|
-
static close: string;
|
|
9
|
-
private client?;
|
|
10
|
-
private config;
|
|
11
|
-
private event;
|
|
12
|
-
constructor(config: MQTTConfig);
|
|
13
|
-
stop(): void;
|
|
14
|
-
connect(): Promise<MqttClient>;
|
|
15
|
-
message(cb: (client: mqtt.MqttClient, message: any) => void): void;
|
|
16
|
-
error(cb: (client: mqtt.MqttClient, error: Error) => void): void;
|
|
17
|
-
close(cb: (client: mqtt.MqttClient) => void): void;
|
|
18
|
-
publish(message: string): void;
|
|
19
|
-
removeMessageListener(cb: (client: mqtt.MqttClient, message: any) => void): void;
|
|
20
|
-
private _connect;
|
|
21
|
-
private subConnect;
|
|
22
|
-
private subMessage;
|
|
23
|
-
private subError;
|
|
24
|
-
private subClose;
|
|
25
|
-
}
|
package/dist/tuya/mq.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import Event from 'events';
|
|
2
|
-
import * as mqtt from 'mqtt';
|
|
3
|
-
export class TuyaMQ {
|
|
4
|
-
static connected = 'TUYA_CONNECTED';
|
|
5
|
-
static message = 'TUYA_MESSAGE';
|
|
6
|
-
static error = 'TUYA_ERROR';
|
|
7
|
-
static close = 'TUYA_CLOSE';
|
|
8
|
-
client;
|
|
9
|
-
config;
|
|
10
|
-
event;
|
|
11
|
-
constructor(config) {
|
|
12
|
-
this.config = Object.assign({}, config);
|
|
13
|
-
this.event = new Event();
|
|
14
|
-
}
|
|
15
|
-
stop() {
|
|
16
|
-
this.client?.end();
|
|
17
|
-
}
|
|
18
|
-
async connect() {
|
|
19
|
-
return new Promise((resolve, reject) => {
|
|
20
|
-
this.event.on(TuyaMQ.connected, (client) => {
|
|
21
|
-
if (client.connected) {
|
|
22
|
-
resolve(client);
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
reject(new Error('Client did not connect successfully.'));
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
this.client = this._connect();
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
message(cb) {
|
|
32
|
-
this.event.on(TuyaMQ.message, cb);
|
|
33
|
-
}
|
|
34
|
-
error(cb) {
|
|
35
|
-
this.event.on(TuyaMQ.error, cb);
|
|
36
|
-
}
|
|
37
|
-
close(cb) {
|
|
38
|
-
this.event.on(TuyaMQ.close, cb);
|
|
39
|
-
}
|
|
40
|
-
publish(message) {
|
|
41
|
-
const properties = {
|
|
42
|
-
qos: 1,
|
|
43
|
-
retain: false,
|
|
44
|
-
};
|
|
45
|
-
this.client?.publish(this.config.sink_topic, message, properties);
|
|
46
|
-
}
|
|
47
|
-
removeMessageListener(cb) {
|
|
48
|
-
this.event.removeListener(TuyaMQ.message, cb);
|
|
49
|
-
}
|
|
50
|
-
_connect() {
|
|
51
|
-
this.client = mqtt.connect(this.config.url, {
|
|
52
|
-
clientId: this.config.client_id,
|
|
53
|
-
username: this.config.username,
|
|
54
|
-
password: this.config.password,
|
|
55
|
-
});
|
|
56
|
-
this.subConnect(this.client);
|
|
57
|
-
this.subMessage(this.client);
|
|
58
|
-
this.subError(this.client);
|
|
59
|
-
this.subClose(this.client);
|
|
60
|
-
return this.client;
|
|
61
|
-
}
|
|
62
|
-
subConnect(client) {
|
|
63
|
-
client.on('connect', () => {
|
|
64
|
-
client.subscribe(this.config.source_topic);
|
|
65
|
-
this.event.emit(TuyaMQ.connected, client);
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
subMessage(client) {
|
|
69
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
70
|
-
client.on('message', (topic, payload, packet) => {
|
|
71
|
-
this.event.emit(TuyaMQ.message, client, payload);
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
subError(client) {
|
|
75
|
-
client.on('error', (error) => {
|
|
76
|
-
this.event.emit(TuyaMQ.error, error);
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
subClose(client) {
|
|
80
|
-
client.on('close', () => {
|
|
81
|
-
this.event.emit(TuyaMQ.close, this.client);
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
//# sourceMappingURL=mq.js.map
|
package/dist/tuya/mq.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mq.js","sourceRoot":"","sources":["../../src/tuya/mq.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,QAAQ,CAAC;AAC3B,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAM7B,MAAM,OAAO,MAAM;IACjB,MAAM,CAAC,SAAS,GAAG,gBAAgB,CAAC;IACpC,MAAM,CAAC,OAAO,GAAG,cAAc,CAAC;IAChC,MAAM,CAAC,KAAK,GAAG,YAAY,CAAC;IAC5B,MAAM,CAAC,KAAK,GAAG,YAAY,CAAC;IAEpB,MAAM,CAAmB;IACzB,MAAM,CAAa;IACnB,KAAK,CAAQ;IAErB,YAAY,MAAkB;QAC5B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;QACxC,IAAI,CAAC,KAAK,GAAG,IAAI,KA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CAAC,OAAO,EAAE,CAAC,KAAY,EAAE,EAAE;YAClC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QACvC,CAAC,CAAC,CAAC;IACL,CAAC;IAEO,QAAQ,CAAC,MAAuB;QACtC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;YACtB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAC7C,CAAC,CAAC,CAAC;IACL,CAAC"}
|
package/dist/tuya/pulsar.d.ts
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import type { LoggerService } from '@camera.ui/types';
|
|
2
|
-
import WebSocket from 'ws';
|
|
3
|
-
export interface TuyaPulsarMessage {
|
|
4
|
-
payload: {
|
|
5
|
-
data: {
|
|
6
|
-
devId: string;
|
|
7
|
-
productKey: string;
|
|
8
|
-
bizCode?: string;
|
|
9
|
-
bizData?: any;
|
|
10
|
-
status?: StatusItem[];
|
|
11
|
-
};
|
|
12
|
-
protocol: number;
|
|
13
|
-
pv: string;
|
|
14
|
-
sign: string;
|
|
15
|
-
t: number;
|
|
16
|
-
};
|
|
17
|
-
messageId: string;
|
|
18
|
-
properties: any;
|
|
19
|
-
publishTime: string;
|
|
20
|
-
redeliveryCount: number;
|
|
21
|
-
key: string;
|
|
22
|
-
}
|
|
23
|
-
interface StatusItem {
|
|
24
|
-
code: string;
|
|
25
|
-
value: any;
|
|
26
|
-
t: number;
|
|
27
|
-
}
|
|
28
|
-
export interface IConfig {
|
|
29
|
-
accessId: string;
|
|
30
|
-
accessKey: string;
|
|
31
|
-
url: string;
|
|
32
|
-
timeout?: number;
|
|
33
|
-
maxRetryTimes?: number;
|
|
34
|
-
retryTimeout?: number;
|
|
35
|
-
}
|
|
36
|
-
export declare class TuyaPulsar {
|
|
37
|
-
static data: string;
|
|
38
|
-
static error: string;
|
|
39
|
-
static open: string;
|
|
40
|
-
static close: string;
|
|
41
|
-
static reconnect: string;
|
|
42
|
-
static ping: string;
|
|
43
|
-
static pong: string;
|
|
44
|
-
static maxRetries: string;
|
|
45
|
-
private config;
|
|
46
|
-
private server?;
|
|
47
|
-
private timer;
|
|
48
|
-
private retryTimes;
|
|
49
|
-
private event;
|
|
50
|
-
constructor(config: IConfig, logger: LoggerService);
|
|
51
|
-
start(): void;
|
|
52
|
-
stop(): void;
|
|
53
|
-
open(cb: (ws: WebSocket) => void): void;
|
|
54
|
-
message(cb: (ws: WebSocket, message: any) => void): void;
|
|
55
|
-
ping(cb: (ws: WebSocket) => void): void;
|
|
56
|
-
pong(cb: (ws: WebSocket) => void): void;
|
|
57
|
-
reconnect(cb: (ws: WebSocket) => void): void;
|
|
58
|
-
ackMessage(messageId: string): void;
|
|
59
|
-
error(cb: (ws: WebSocket, error: any) => void): void;
|
|
60
|
-
close(cb: (ws: WebSocket) => void): void;
|
|
61
|
-
maxRetries(cb: () => void): void;
|
|
62
|
-
private _reconnect;
|
|
63
|
-
private _connect;
|
|
64
|
-
private subOpen;
|
|
65
|
-
private subPing;
|
|
66
|
-
private subPong;
|
|
67
|
-
private subMessage;
|
|
68
|
-
private subClose;
|
|
69
|
-
private subError;
|
|
70
|
-
private clearKeepAlive;
|
|
71
|
-
private keepAlive;
|
|
72
|
-
private handleMessage;
|
|
73
|
-
}
|
|
74
|
-
export {};
|
package/dist/tuya/pulsar.js
DELETED
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
// From Tuya Pulsar (Node.js)
|
|
2
|
-
// https://developer.tuya.com/en/docs/iot/Pulsar-SDK-get-message-nodejs?id=Kawfmtxp8yscg
|
|
3
|
-
import CryptoJS from 'crypto-js';
|
|
4
|
-
import Event from 'events';
|
|
5
|
-
import WebSocket from 'ws';
|
|
6
|
-
export class TuyaPulsar {
|
|
7
|
-
static data = 'TUTA_DATA';
|
|
8
|
-
static error = 'TUYA_ERROR';
|
|
9
|
-
static open = 'TUYA_OPEN';
|
|
10
|
-
static close = 'TUYA_CLOSE';
|
|
11
|
-
static reconnect = 'TUYA_RECONNECT';
|
|
12
|
-
static ping = 'TUYA_PING';
|
|
13
|
-
static pong = 'TUYA_PONG';
|
|
14
|
-
static maxRetries = 'TUYA_MAXRETRIES';
|
|
15
|
-
config;
|
|
16
|
-
server;
|
|
17
|
-
timer;
|
|
18
|
-
retryTimes;
|
|
19
|
-
event;
|
|
20
|
-
constructor(config, logger) {
|
|
21
|
-
this.config = Object.assign({
|
|
22
|
-
ackTimeoutMillis: 3000,
|
|
23
|
-
subscriptionType: 'Failover',
|
|
24
|
-
retryTimeout: 1000,
|
|
25
|
-
maxRetryTimes: 10,
|
|
26
|
-
timeout: 30000,
|
|
27
|
-
logger: (...args) => logger.trace(...args),
|
|
28
|
-
}, config);
|
|
29
|
-
this.event = new Event();
|
|
30
|
-
this.retryTimes = 0;
|
|
31
|
-
}
|
|
32
|
-
start() {
|
|
33
|
-
this.server = this._connect();
|
|
34
|
-
}
|
|
35
|
-
stop() {
|
|
36
|
-
this.server?.terminate();
|
|
37
|
-
}
|
|
38
|
-
open(cb) {
|
|
39
|
-
this.event.on(TuyaPulsar.open, cb);
|
|
40
|
-
}
|
|
41
|
-
message(cb) {
|
|
42
|
-
this.event.on(TuyaPulsar.data, cb);
|
|
43
|
-
}
|
|
44
|
-
ping(cb) {
|
|
45
|
-
this.event.on(TuyaPulsar.ping, cb);
|
|
46
|
-
}
|
|
47
|
-
pong(cb) {
|
|
48
|
-
this.event.on(TuyaPulsar.pong, cb);
|
|
49
|
-
}
|
|
50
|
-
reconnect(cb) {
|
|
51
|
-
this.event.on(TuyaPulsar.reconnect, cb);
|
|
52
|
-
}
|
|
53
|
-
ackMessage(messageId) {
|
|
54
|
-
this.server && this.server.send(JSON.stringify({ messageId }));
|
|
55
|
-
}
|
|
56
|
-
error(cb) {
|
|
57
|
-
this.event.on(TuyaPulsar.error, cb);
|
|
58
|
-
}
|
|
59
|
-
close(cb) {
|
|
60
|
-
this.event.on(TuyaPulsar.close, cb);
|
|
61
|
-
}
|
|
62
|
-
maxRetries(cb) {
|
|
63
|
-
this.event.on(TuyaPulsar.maxRetries, cb);
|
|
64
|
-
}
|
|
65
|
-
_reconnect() {
|
|
66
|
-
if (this.config.maxRetryTimes && this.retryTimes < this.config.maxRetryTimes) {
|
|
67
|
-
const timer = setTimeout(() => {
|
|
68
|
-
clearTimeout(timer);
|
|
69
|
-
this.retryTimes++;
|
|
70
|
-
this._connect(false);
|
|
71
|
-
}, this.config.retryTimeout);
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
this.clearKeepAlive();
|
|
75
|
-
this.event.emit(TuyaPulsar.maxRetries);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
_connect(isInit = true) {
|
|
79
|
-
const { accessId, accessKey, url } = this.config;
|
|
80
|
-
const topicUrl = getTopicUrl(url, accessId, 'event', `?${buildQuery({ subscriptionType: 'Failover', ackTimeoutMillis: 30000 })}`);
|
|
81
|
-
const password = buildPassword(accessId, accessKey);
|
|
82
|
-
this.server = new WebSocket(topicUrl, {
|
|
83
|
-
rejectUnauthorized: false,
|
|
84
|
-
headers: { username: accessId, password },
|
|
85
|
-
});
|
|
86
|
-
this.subOpen(this.server, isInit);
|
|
87
|
-
this.subMessage(this.server);
|
|
88
|
-
this.subPing(this.server);
|
|
89
|
-
this.subPong(this.server);
|
|
90
|
-
this.subError(this.server);
|
|
91
|
-
this.subClose(this.server);
|
|
92
|
-
return this.server;
|
|
93
|
-
}
|
|
94
|
-
subOpen(server, isInit = true) {
|
|
95
|
-
server.on('open', () => {
|
|
96
|
-
if (server.readyState === server.OPEN) {
|
|
97
|
-
this.retryTimes = 0;
|
|
98
|
-
}
|
|
99
|
-
this.keepAlive(server);
|
|
100
|
-
this.event.emit(isInit ? TuyaPulsar.open : TuyaPulsar.reconnect, this.server);
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
subPing(server) {
|
|
104
|
-
server.on('ping', () => {
|
|
105
|
-
this.event.emit(TuyaPulsar.ping, this.server);
|
|
106
|
-
this.keepAlive(server);
|
|
107
|
-
server.pong(this.config.accessId);
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
subPong(server) {
|
|
111
|
-
server.on('pong', () => {
|
|
112
|
-
this.keepAlive(server);
|
|
113
|
-
this.event.emit(TuyaPulsar.pong, this.server);
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
subMessage(server) {
|
|
117
|
-
server.on('message', (data) => {
|
|
118
|
-
try {
|
|
119
|
-
this.keepAlive(server);
|
|
120
|
-
const obj = this.handleMessage(data);
|
|
121
|
-
this.event.emit(TuyaPulsar.data, this.server, obj);
|
|
122
|
-
}
|
|
123
|
-
catch (e) {
|
|
124
|
-
this.event.emit(TuyaPulsar.error, e);
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
subClose(server) {
|
|
129
|
-
server.on('close', (...data) => {
|
|
130
|
-
this._reconnect();
|
|
131
|
-
this.clearKeepAlive();
|
|
132
|
-
this.event.emit(TuyaPulsar.close, ...data);
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
subError(server) {
|
|
136
|
-
server.on('error', (e) => {
|
|
137
|
-
this.event.emit(TuyaPulsar.error, this.server, e);
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
clearKeepAlive() {
|
|
141
|
-
clearTimeout(this.timer);
|
|
142
|
-
}
|
|
143
|
-
keepAlive(server) {
|
|
144
|
-
this.clearKeepAlive();
|
|
145
|
-
this.timer = setTimeout(() => {
|
|
146
|
-
server.ping(this.config.accessId);
|
|
147
|
-
}, this.config.timeout);
|
|
148
|
-
}
|
|
149
|
-
handleMessage(data) {
|
|
150
|
-
const { payload, ...others } = JSON.parse(data);
|
|
151
|
-
const pStr = Buffer.from(payload, 'base64').toString('utf-8');
|
|
152
|
-
const pJson = JSON.parse(pStr);
|
|
153
|
-
pJson.data = decrypt(pJson.data, this.config.accessKey);
|
|
154
|
-
return { payload: pJson, ...others };
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
function getTopicUrl(websocketUrl, accessId, env, query) {
|
|
158
|
-
return `${websocketUrl}ws/v2/consumer/persistent/${accessId}/out/${env}/${accessId}-sub${query}`;
|
|
159
|
-
}
|
|
160
|
-
function buildQuery(query) {
|
|
161
|
-
return Object.keys(query)
|
|
162
|
-
.map((key) => `${key}=${encodeURIComponent(query[key])}`)
|
|
163
|
-
.join('&');
|
|
164
|
-
}
|
|
165
|
-
function buildPassword(accessId, accessKey) {
|
|
166
|
-
const key = CryptoJS.MD5(accessKey).toString();
|
|
167
|
-
return CryptoJS.MD5(`${accessId}${key}`).toString().substr(8, 16);
|
|
168
|
-
}
|
|
169
|
-
function decrypt(data, accessKey) {
|
|
170
|
-
try {
|
|
171
|
-
const realKey = CryptoJS.enc.Utf8.parse(accessKey.substring(8, 24));
|
|
172
|
-
const json = CryptoJS.AES.decrypt(data, realKey, {
|
|
173
|
-
mode: CryptoJS.mode.ECB,
|
|
174
|
-
padding: CryptoJS.pad.Pkcs7,
|
|
175
|
-
});
|
|
176
|
-
const dataStr = CryptoJS.enc.Utf8.stringify(json).toString();
|
|
177
|
-
return JSON.parse(dataStr);
|
|
178
|
-
}
|
|
179
|
-
catch {
|
|
180
|
-
return undefined;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
184
|
-
function encrypt(data, accessKey) {
|
|
185
|
-
try {
|
|
186
|
-
const realKey = CryptoJS.enc.Utf8.parse(accessKey.substring(8, 24));
|
|
187
|
-
const realData = JSON.stringify(data);
|
|
188
|
-
const retData = CryptoJS.AES.encrypt(realData, realKey, {
|
|
189
|
-
mode: CryptoJS.mode.ECB,
|
|
190
|
-
padding: CryptoJS.pad.Pkcs7,
|
|
191
|
-
}).toString();
|
|
192
|
-
return retData;
|
|
193
|
-
}
|
|
194
|
-
catch {
|
|
195
|
-
return '';
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
//# sourceMappingURL=pulsar.js.map
|
package/dist/tuya/pulsar.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pulsar.js","sourceRoot":"","sources":["../../src/tuya/pulsar.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAC7B,wFAAwF;AAGxF,OAAO,QAAQ,MAAM,WAAW,CAAC;AACjC,OAAO,KAAK,MAAM,QAAQ,CAAC;AAC3B,OAAO,SAAS,MAAM,IAAI,CAAC;AAwC3B,MAAM,OAAO,UAAU;IACrB,MAAM,CAAC,IAAI,GAAG,WAAW,CAAC;IAC1B,MAAM,CAAC,KAAK,GAAG,YAAY,CAAC;IAC5B,MAAM,CAAC,IAAI,GAAG,WAAW,CAAC;IAC1B,MAAM,CAAC,KAAK,GAAG,YAAY,CAAC;IAC5B,MAAM,CAAC,SAAS,GAAG,gBAAgB,CAAC;IACpC,MAAM,CAAC,IAAI,GAAG,WAAW,CAAC;IAC1B,MAAM,CAAC,IAAI,GAAG,WAAW,CAAC;IAC1B,MAAM,CAAC,UAAU,GAAG,iBAAiB,CAAC;IAE9B,MAAM,CAAU;IAChB,MAAM,CAAa;IACnB,KAAK,CAAM;IACX,UAAU,CAAS;IACnB,KAAK,CAAQ;IAErB,YAAY,MAAe,EAAE,MAAqB;QAChD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CACzB;YACE,gBAAgB,EAAE,IAAI;YACtB,gBAAgB,EAAE,UAAU;YAC5B,YAAY,EAAE,IAAI;YAClB,aAAa,EAAE,EAAE;YACjB,OAAO,EAAE,KAAK;YACd,MAAM,EAAE,CAAC,GAAG,IAAW,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;SAClD,EACD,MAAM,CACP,CAAC;QACF,IAAI,CAAC,KAAK,GAAG,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,CAAC,UAAU,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,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,EAAE;YACtD,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,GAAG;YACvB,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,KAAK;SAC5B,CAAC,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,OAAO,CAAC;IACjB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC"}
|
package/dist/tuya/utils.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
declare enum EndpointGroup {
|
|
2
|
-
Europe = 0,
|
|
3
|
-
America = 1,
|
|
4
|
-
India = 2,
|
|
5
|
-
China = 3
|
|
6
|
-
}
|
|
7
|
-
export interface TuyaSupportedCountry {
|
|
8
|
-
country: string;
|
|
9
|
-
countryCode: number;
|
|
10
|
-
endpointGroup: EndpointGroup;
|
|
11
|
-
}
|
|
12
|
-
export declare const TUYA_COUNTRIES: TuyaSupportedCountry[];
|
|
13
|
-
export declare function getEndPointWithCountryCode(code: number): EndpointGroup;
|
|
14
|
-
export declare function getTuyaCloudEndpoint(country: TuyaSupportedCountry): string;
|
|
15
|
-
export declare function getTuyaPulsarEndpoint(country: TuyaSupportedCountry): string;
|
|
16
|
-
export {};
|