Init
This commit is contained in:
90
build/http/api.d.ts
vendored
Normal file
90
build/http/api.d.ts
vendored
Normal file
@ -0,0 +1,90 @@
|
||||
import { TypedEmitter } from "tiny-typed-emitter";
|
||||
import { TrustDevice, Cipher, EventRecordResponse, ConfirmInvite, SensorHistoryEntry, ApiResponse, HouseDetail, DeviceListResponse, StationListResponse, HouseInviteListResponse, HouseListResponse, PassportProfileResponse, User, AddUserResponse } from "./models";
|
||||
import { HTTPApiEvents, Ciphers, FullDevices, Hubs, Voices, Invites, HTTPApiRequest, HTTPApiPersistentData, LoginOptions, Schedule } from "./interfaces";
|
||||
import { EventFilterType, PublicKeyType, VerfyCodeTypes } from "./types";
|
||||
export declare class HTTPApi extends TypedEmitter<HTTPApiEvents> {
|
||||
private static apiDomainBase;
|
||||
private readonly SERVER_PUBLIC_KEY;
|
||||
private apiBase;
|
||||
private username;
|
||||
private password;
|
||||
private ecdh;
|
||||
private token;
|
||||
private tokenExpiration;
|
||||
private renewAuthTokenJob?;
|
||||
private connected;
|
||||
private requestEufyCloud;
|
||||
private throttle;
|
||||
private devices;
|
||||
private hubs;
|
||||
private houses;
|
||||
private persistentData;
|
||||
private headers;
|
||||
private constructor();
|
||||
static getApiBaseFromCloud(country: string): Promise<string>;
|
||||
private loadLibraries;
|
||||
static initialize(country: string, username: string, password: string, persistentData?: HTTPApiPersistentData): Promise<HTTPApi>;
|
||||
private clearScheduleRenewAuthToken;
|
||||
private scheduleRenewAuthToken;
|
||||
private invalidateToken;
|
||||
setPhoneModel(model: string): void;
|
||||
getPhoneModel(): string;
|
||||
getCountry(): string;
|
||||
setLanguage(language: string): void;
|
||||
getLanguage(): string;
|
||||
login(options?: LoginOptions): Promise<void>;
|
||||
sendVerifyCode(type?: VerfyCodeTypes): Promise<boolean>;
|
||||
listTrustDevice(): Promise<Array<TrustDevice>>;
|
||||
addTrustDevice(verifyCode: string): Promise<boolean>;
|
||||
getStationList(): Promise<Array<StationListResponse>>;
|
||||
getDeviceList(): Promise<Array<DeviceListResponse>>;
|
||||
refreshHouseData(): Promise<void>;
|
||||
refreshStationData(): Promise<void>;
|
||||
refreshDeviceData(): Promise<void>;
|
||||
refreshAllData(): Promise<void>;
|
||||
request(request: HTTPApiRequest, withoutUrlPrefix?: boolean): Promise<ApiResponse>;
|
||||
checkPushToken(): Promise<boolean>;
|
||||
registerPushToken(token: string): Promise<boolean>;
|
||||
setParameters(stationSN: string, deviceSN: string, params: {
|
||||
paramType: number;
|
||||
paramValue: any;
|
||||
}[]): Promise<boolean>;
|
||||
getCiphers(/*stationSN: string, */ cipherIDs: Array<number>, userID: string): Promise<Ciphers>;
|
||||
getVoices(deviceSN: string): Promise<Voices>;
|
||||
getCipher(/*stationSN: string, */ cipherID: number, userID: string): Promise<Cipher>;
|
||||
getDevices(): FullDevices;
|
||||
getHubs(): Hubs;
|
||||
getToken(): string | null;
|
||||
getTokenExpiration(): Date | null;
|
||||
setToken(token: string): void;
|
||||
setTokenExpiration(tokenExpiration: Date): void;
|
||||
getAPIBase(): string;
|
||||
setOpenUDID(openudid: string): void;
|
||||
setSerialNumber(serialnumber: string): void;
|
||||
private _getEvents;
|
||||
getVideoEvents(startTime: Date, endTime: Date, filter?: EventFilterType, maxResults?: number): Promise<Array<EventRecordResponse>>;
|
||||
getAlarmEvents(startTime: Date, endTime: Date, filter?: EventFilterType, maxResults?: number): Promise<Array<EventRecordResponse>>;
|
||||
getHistoryEvents(startTime: Date, endTime: Date, filter?: EventFilterType, maxResults?: number): Promise<Array<EventRecordResponse>>;
|
||||
getAllVideoEvents(filter?: EventFilterType, maxResults?: number): Promise<Array<EventRecordResponse>>;
|
||||
getAllAlarmEvents(filter?: EventFilterType, maxResults?: number): Promise<Array<EventRecordResponse>>;
|
||||
getAllHistoryEvents(filter?: EventFilterType, maxResults?: number): Promise<Array<EventRecordResponse>>;
|
||||
isConnected(): boolean;
|
||||
getInvites(): Promise<Invites>;
|
||||
confirmInvites(confirmInvites: Array<ConfirmInvite>): Promise<boolean>;
|
||||
getPublicKey(deviceSN: string, type: PublicKeyType): Promise<string>;
|
||||
decryptAPIData(data?: string, json?: boolean): any;
|
||||
getSensorHistory(stationSN: string, deviceSN: string): Promise<Array<SensorHistoryEntry>>;
|
||||
getHouseDetail(houseID: string): Promise<HouseDetail | null>;
|
||||
getHouseList(): Promise<Array<HouseListResponse>>;
|
||||
getHouseInviteList(isInviter?: number): Promise<Array<HouseInviteListResponse>>;
|
||||
confirmHouseInvite(houseID: string, inviteID: number): Promise<boolean>;
|
||||
getPersistentData(): HTTPApiPersistentData | undefined;
|
||||
getPassportProfile(): Promise<PassportProfileResponse | null>;
|
||||
addUser(deviceSN: string, nickname: string, stationSN?: string): Promise<AddUserResponse | null>;
|
||||
deleteUser(deviceSN: string, shortUserId: string, stationSN?: string): Promise<boolean>;
|
||||
getUsers(deviceSN: string, stationSN: string): Promise<Array<User> | null>;
|
||||
getUser(deviceSN: string, stationSN: string, shortUserId: string): Promise<User | null>;
|
||||
updateUser(deviceSN: string, stationSN: string, shortUserId: string, nickname: string): Promise<boolean>;
|
||||
getImage(deviceSN: string, url: string): Promise<Buffer>;
|
||||
updateUserPassword(deviceSN: string, shortUserId: string, passwordId: string, schedule: Schedule, stationSN?: string): Promise<boolean>;
|
||||
}
|
||||
1578
build/http/api.js
Normal file
1578
build/http/api.js
Normal file
File diff suppressed because it is too large
Load Diff
1
build/http/api.js.map
Normal file
1
build/http/api.js.map
Normal file
File diff suppressed because one or more lines are too long
8
build/http/cache.d.ts
vendored
Normal file
8
build/http/cache.d.ts
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
export declare class Cache extends Map {
|
||||
private ttl;
|
||||
private schedules;
|
||||
constructor(ttl?: number);
|
||||
delete(key: any): boolean;
|
||||
set(key: any, value: any, ttl?: number): this;
|
||||
get(key: any): any;
|
||||
}
|
||||
34
build/http/cache.js
Normal file
34
build/http/cache.js
Normal file
@ -0,0 +1,34 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Cache = void 0;
|
||||
class Cache extends Map {
|
||||
ttl = 60000;
|
||||
schedules = new Map();
|
||||
constructor(ttl) {
|
||||
super();
|
||||
if (ttl !== undefined)
|
||||
this.ttl = ttl;
|
||||
}
|
||||
delete(key) {
|
||||
const result = super.delete(key);
|
||||
clearTimeout(this.schedules.get(key));
|
||||
this.schedules.delete(key);
|
||||
return result;
|
||||
}
|
||||
set(key, value, ttl = this.ttl) {
|
||||
super.set(key, value);
|
||||
if (this.schedules.has(key)) {
|
||||
clearTimeout(this.schedules.get(key));
|
||||
}
|
||||
const schedule = setTimeout(() => {
|
||||
this.delete(key);
|
||||
}, ttl);
|
||||
this.schedules.set(key, schedule);
|
||||
return this;
|
||||
}
|
||||
get(key) {
|
||||
return super.get(key);
|
||||
}
|
||||
}
|
||||
exports.Cache = Cache;
|
||||
//# sourceMappingURL=cache.js.map
|
||||
1
build/http/cache.js.map
Normal file
1
build/http/cache.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"cache.js","sourceRoot":"","sources":["../../src/http/cache.ts"],"names":[],"mappings":";;;AAAA,MAAa,KAAM,SAAQ,GAAG;IAElB,GAAG,GAAG,KAAK,CAAC;IACZ,SAAS,GAAI,IAAI,GAAG,EAAE,CAAC;IAE/B,YAAY,GAAY;QACpB,KAAK,EAAE,CAAC;QACR,IAAI,GAAG,KAAK,SAAS;YACjB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACvB,CAAC;IAEM,MAAM,CAAC,GAAQ;QAClB,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACjC,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;QACtC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC3B,OAAO,MAAM,CAAC;IAClB,CAAC;IAEM,GAAG,CAAC,GAAQ,EAAE,KAAU,EAAE,GAAG,GAAG,IAAI,CAAC,GAAG;QAC3C,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACtB,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YAC1B,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;QAC1C,CAAC;QAED,MAAM,QAAQ,GAAG,UAAU,CAAC,GAAG,EAAE;YAC7B,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACrB,CAAC,EAAE,GAAG,CAAC,CAAC;QACR,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QAClC,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,GAAG,CAAC,GAAQ;QACf,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;CACJ;AAlCD,sBAkCC"}
|
||||
3
build/http/const.d.ts
vendored
Normal file
3
build/http/const.d.ts
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
import { EufyTimezone } from "./utils";
|
||||
export declare const PhoneModels: Array<string>;
|
||||
export declare const timeZoneData: Array<EufyTimezone>;
|
||||
8546
build/http/const.js
Normal file
8546
build/http/const.js
Normal file
File diff suppressed because it is too large
Load Diff
1
build/http/const.js.map
Normal file
1
build/http/const.js.map
Normal file
File diff suppressed because one or more lines are too long
474
build/http/device.d.ts
vendored
Normal file
474
build/http/device.d.ts
vendored
Normal file
@ -0,0 +1,474 @@
|
||||
import { TypedEmitter } from "tiny-typed-emitter";
|
||||
import { HTTPApi } from "./api";
|
||||
import { CommandName, DeviceEvent, SourceType, TrackerType } from "./types";
|
||||
import { DeviceListResponse } from "./models";
|
||||
import { DeviceEvents, PropertyValue, PropertyValues, PropertyMetadataAny, IndexedProperty, RawValues, Schedule, Voices, DeviceConfig } from "./interfaces";
|
||||
import { PushMessage } from "../push/models";
|
||||
import { DeviceSmartLockNotifyData } from "../mqtt/model";
|
||||
import { Station } from "./station";
|
||||
export declare class Device extends TypedEmitter<DeviceEvents> {
|
||||
protected api: HTTPApi;
|
||||
protected rawDevice: DeviceListResponse;
|
||||
protected eventTimeouts: Map<DeviceEvent, NodeJS.Timeout>;
|
||||
protected pictureEventTimeouts: Map<string, NodeJS.Timeout>;
|
||||
protected properties: PropertyValues;
|
||||
protected config: DeviceConfig;
|
||||
private rawProperties;
|
||||
private ready;
|
||||
protected constructor(api: HTTPApi, device: DeviceListResponse, deviceConfig: DeviceConfig);
|
||||
protected initializeState(): void;
|
||||
initialize(): void;
|
||||
getRawDevice(): DeviceListResponse;
|
||||
update(device: DeviceListResponse): void;
|
||||
updateProperty(name: string, value: PropertyValue, force?: boolean): boolean;
|
||||
updateRawProperties(values: RawValues): void;
|
||||
protected handlePropertyChange(metadata: PropertyMetadataAny, oldValue: PropertyValue, newValue: PropertyValue): void;
|
||||
updateRawProperty(type: number, value: string, source: SourceType): boolean;
|
||||
protected convertRawPropertyValue(property: PropertyMetadataAny, value: string): PropertyValue;
|
||||
getPropertyMetadata(name: string, hidden?: boolean): PropertyMetadataAny;
|
||||
getPropertyValue(name: string): PropertyValue;
|
||||
hasPropertyValue(name: string): boolean;
|
||||
getRawProperty(type: number): string | undefined;
|
||||
getRawProperties(): RawValues;
|
||||
getProperties(): PropertyValues;
|
||||
getPropertiesMetadata(hidden?: boolean): IndexedProperty;
|
||||
hasProperty(name: string, hidden?: boolean): boolean;
|
||||
getCommands(): Array<CommandName>;
|
||||
hasCommand(name: CommandName): boolean;
|
||||
processPushNotification(_station: Station, _message: PushMessage, _eventDurationSeconds: number): void;
|
||||
setCustomPropertyValue(name: string, value: PropertyValue): void;
|
||||
destroy(): void;
|
||||
protected clearEventTimeout(eventType: DeviceEvent): void;
|
||||
static isSupported(type: number): boolean;
|
||||
static isCamera(type: number): boolean;
|
||||
static hasBattery(type: number): boolean;
|
||||
static isStation(type: number): boolean;
|
||||
static isCamera1(type: number): boolean;
|
||||
static isCameraE(type: number): boolean;
|
||||
static isSensor(type: number): boolean;
|
||||
static isKeyPad(type: number): boolean;
|
||||
static isDoorbell(type: number): boolean;
|
||||
static isWiredDoorbell(type: number): boolean;
|
||||
static isWiredDoorbellT8200X(type: number, serialnumber: string): boolean;
|
||||
static isWiredDoorbellDual(type: number): boolean;
|
||||
static isIndoorCamera(type: number): boolean;
|
||||
static isPanAndTiltCamera(type: number): boolean;
|
||||
static isOutdoorPanAndTiltCamera(type: number): boolean;
|
||||
static isIndoorPanAndTiltCameraS350(type: number): boolean;
|
||||
static isFloodLight(type: number): boolean;
|
||||
static isFloodLightT8420X(type: number, serialnumber: string): boolean;
|
||||
static isFloodLightT8423(type: number): boolean;
|
||||
static isFloodLightT8425(type: number): boolean;
|
||||
static isWallLightCam(type: number): boolean;
|
||||
static isLock(type: number): boolean;
|
||||
static isLockKeypad(type: number): boolean;
|
||||
static isLockBle(type: number): boolean;
|
||||
static isLockBleNoFinger(type: number): boolean;
|
||||
static isLockWifi(type: number, serialnumber: string): boolean;
|
||||
static isLockWifiNoFinger(type: number): boolean;
|
||||
static isLockWifiR10(type: number): boolean;
|
||||
static isLockWifiR20(type: number): boolean;
|
||||
static isLockWifiVideo(type: number): boolean;
|
||||
static isLockWifiR10Keypad(type: number): boolean;
|
||||
static isLockWifiR20Keypad(type: number): boolean;
|
||||
static isLockWifiT8506(type: number): boolean;
|
||||
static isLockWifiT8502(type: number): boolean;
|
||||
static isLockWifiT8510P(type: number, serialnumber: string): boolean;
|
||||
static isLockWifiT8520P(type: number, serialnumber: string): boolean;
|
||||
static isBatteryDoorbell1(type: number): boolean;
|
||||
static isBatteryDoorbell2(type: number): boolean;
|
||||
static isBatteryDoorbellDual(type: number): boolean;
|
||||
static isBatteryDoorbellDualE340(type: number): boolean;
|
||||
static isBatteryDoorbellC30(type: number): boolean;
|
||||
static isBatteryDoorbellC31(type: number): boolean;
|
||||
static isDoorbellDual(type: number): boolean;
|
||||
static isBatteryDoorbell(type: number): boolean;
|
||||
static isSoloCamera(type: number): boolean;
|
||||
static isSoloCameraPro(type: number): boolean;
|
||||
static isSoloCameraSpotlight1080(type: number): boolean;
|
||||
static isSoloCameraSpotlight2k(type: number): boolean;
|
||||
static isSoloCameraSpotlightSolar(type: number): boolean;
|
||||
static isSoloCameraSolar(type: number): boolean;
|
||||
static isSoloCameraC210(type: number): boolean;
|
||||
static isSoloCameraE30(type: number): boolean;
|
||||
static isSoloCameras(type: number): boolean;
|
||||
static isStarlight4GLTE(type: number): boolean;
|
||||
static isIndoorOutdoorCamera1080p(type: number): boolean;
|
||||
static isIndoorOutdoorCamera1080pNoLight(type: number): boolean;
|
||||
static isIndoorOutdoorCamera2k(type: number): boolean;
|
||||
static isIndoorCamMini(type: number): boolean;
|
||||
static isCamera1Product(type: number): boolean;
|
||||
static isCamera2(type: number): boolean;
|
||||
static isCamera2C(type: number): boolean;
|
||||
static isCamera2Pro(type: number): boolean;
|
||||
static isCamera2CPro(type: number): boolean;
|
||||
static isCamera2Product(type: number): boolean;
|
||||
static isCamera3(type: number): boolean;
|
||||
static isCamera3C(type: number): boolean;
|
||||
static isCamera3Pro(type: number): boolean;
|
||||
static isCameraProfessional247(type: number): boolean;
|
||||
static isCamera3Product(type: number): boolean;
|
||||
static isEntrySensor(type: number): boolean;
|
||||
static isMotionSensor(type: number): boolean;
|
||||
static isSmartDrop(type: number): boolean;
|
||||
static isSmartSafe(type: number): boolean;
|
||||
static isGarageCamera(type: number): boolean;
|
||||
static isIntegratedDeviceBySn(sn: string): boolean;
|
||||
static isSoloCameraBySn(sn: string): boolean;
|
||||
static isSmartDropBySn(sn: string): boolean;
|
||||
static isLockBySn(sn: string): boolean;
|
||||
static isGarageCameraBySn(sn: string): boolean;
|
||||
static isFloodlightBySn(sn: string): boolean;
|
||||
static isIndoorCameraBySn(sn: string): boolean;
|
||||
static is4GCameraBySn(sn: string): boolean;
|
||||
static isSmartSafeBySn(sn: string): boolean;
|
||||
static isSmartTrackCard(type: number): boolean;
|
||||
static isSmartTrackLink(type: number): boolean;
|
||||
static isSmartTrack(type: number): boolean;
|
||||
isCamera(): boolean;
|
||||
isFloodLight(): boolean;
|
||||
isFloodLightT8420X(): boolean;
|
||||
isFloodLightT8423(): boolean;
|
||||
isFloodLightT8425(): boolean;
|
||||
isWallLightCam(): boolean;
|
||||
isDoorbell(): boolean;
|
||||
isWiredDoorbell(): boolean;
|
||||
isWiredDoorbellT8200X(): boolean;
|
||||
isWiredDoorbellDual(): boolean;
|
||||
isLock(): boolean;
|
||||
isLockKeypad(): boolean;
|
||||
isLockBle(): boolean;
|
||||
isLockBleNoFinger(): boolean;
|
||||
isLockWifi(): boolean;
|
||||
isLockWifiNoFinger(): boolean;
|
||||
isLockWifiR10(): boolean;
|
||||
isLockWifiR20(): boolean;
|
||||
isLockWifiVideo(): boolean;
|
||||
isLockWifiR10Keypad(): boolean;
|
||||
isLockWifiR20Keypad(): boolean;
|
||||
isLockWifiT8506(): boolean;
|
||||
isLockWifiT8502(): boolean;
|
||||
isLockWifiT8510P(): boolean;
|
||||
isLockWifiT8520P(): boolean;
|
||||
isBatteryDoorbell1(): boolean;
|
||||
isBatteryDoorbell2(): boolean;
|
||||
isBatteryDoorbellDual(): boolean;
|
||||
isBatteryDoorbellDualE340(): boolean;
|
||||
isBatteryDoorbellC30(): boolean;
|
||||
isBatteryDoorbellC31(): boolean;
|
||||
isDoorbellDual(): boolean;
|
||||
isBatteryDoorbell(): boolean;
|
||||
isSoloCamera(): boolean;
|
||||
isSoloCameraPro(): boolean;
|
||||
isSoloCameraSpotlight1080(): boolean;
|
||||
isSoloCameraSpotlight2k(): boolean;
|
||||
isSoloCameraSpotlightSolar(): boolean;
|
||||
isSoloCameraSolar(): boolean;
|
||||
isSoloCameraC210(): boolean;
|
||||
isSoloCameraE30(): boolean;
|
||||
isStarlight4GLTE(): boolean;
|
||||
isIndoorOutdoorCamera1080p(): boolean;
|
||||
isIndoorOutdoorCamera1080pNoLight(): boolean;
|
||||
isIndoorOutdoorCamera2k(): boolean;
|
||||
isIndoorCamMini(): boolean;
|
||||
isSoloCameras(): boolean;
|
||||
isCamera2(): boolean;
|
||||
isCamera2C(): boolean;
|
||||
isCamera2Pro(): boolean;
|
||||
isCamera2CPro(): boolean;
|
||||
isCamera2Product(): boolean;
|
||||
isCamera3(): boolean;
|
||||
isCamera3C(): boolean;
|
||||
isCameraProfessional247(): boolean;
|
||||
isCamera3Pro(): boolean;
|
||||
isCamera3Product(): boolean;
|
||||
isEntrySensor(): boolean;
|
||||
isKeyPad(): boolean;
|
||||
isMotionSensor(): boolean;
|
||||
isIndoorCamera(): boolean;
|
||||
isPanAndTiltCamera(): boolean;
|
||||
isOutdoorPanAndTiltCamera(): boolean;
|
||||
isIndoorPanAndTiltCameraS350(): boolean;
|
||||
isSmartDrop(): boolean;
|
||||
isSmartSafe(): boolean;
|
||||
isGarageCamera(): boolean;
|
||||
isIntegratedDevice(): boolean;
|
||||
isSmartTrack(): boolean;
|
||||
isSmartTrackCard(): boolean;
|
||||
isSmartTrackLink(): boolean;
|
||||
hasBattery(): boolean;
|
||||
getDeviceKey(): string;
|
||||
getDeviceType(): number;
|
||||
getHardwareVersion(): string;
|
||||
getSoftwareVersion(): string;
|
||||
getModel(): string;
|
||||
getName(): string;
|
||||
getSerial(): string;
|
||||
getStationSerial(): string;
|
||||
setParameters(params: {
|
||||
paramType: number;
|
||||
paramValue: any;
|
||||
}[]): Promise<boolean>;
|
||||
getChannel(): number;
|
||||
getStateID(state: string, level?: number): string;
|
||||
getStateChannel(): string;
|
||||
getWifiRssi(): PropertyValue;
|
||||
getStoragePath(filename: string): string;
|
||||
isEnabled(): PropertyValue;
|
||||
}
|
||||
export declare class Camera extends Device {
|
||||
protected constructor(api: HTTPApi, device: DeviceListResponse, deviceConfig: DeviceConfig);
|
||||
static getInstance(api: HTTPApi, device: DeviceListResponse, deviceConfig: DeviceConfig): Promise<Camera>;
|
||||
getStateChannel(): string;
|
||||
protected convertRawPropertyValue(property: PropertyMetadataAny, value: string): PropertyValue;
|
||||
getLastCameraImageURL(): PropertyValue;
|
||||
getMACAddress(): string;
|
||||
startDetection(): Promise<void>;
|
||||
stopDetection(): Promise<void>;
|
||||
getState(): PropertyValue;
|
||||
close(): Promise<void>;
|
||||
getLastChargingDays(): number;
|
||||
getLastChargingFalseEvents(): number;
|
||||
getLastChargingRecordedEvents(): number;
|
||||
getLastChargingTotalEvents(): number;
|
||||
getBatteryValue(): PropertyValue;
|
||||
getBatteryTemperature(): PropertyValue;
|
||||
isMotionDetectionEnabled(): PropertyValue;
|
||||
isLedEnabled(): PropertyValue;
|
||||
isAutoNightVisionEnabled(): PropertyValue;
|
||||
isRTSPStreamEnabled(): PropertyValue;
|
||||
isAntiTheftDetectionEnabled(): PropertyValue;
|
||||
getWatermark(): PropertyValue;
|
||||
isMotionDetected(): boolean;
|
||||
isPersonDetected(): boolean;
|
||||
getDetectedPerson(): string;
|
||||
protected handlePropertyChange(metadata: PropertyMetadataAny, oldValue: PropertyValue, newValue: PropertyValue): void;
|
||||
processPushNotification(station: Station, message: PushMessage, eventDurationSeconds: number): void;
|
||||
}
|
||||
export declare class SoloCamera extends Camera {
|
||||
static getInstance(api: HTTPApi, device: DeviceListResponse, deviceConfig: DeviceConfig): Promise<SoloCamera>;
|
||||
isLedEnabled(): PropertyValue;
|
||||
isMotionDetectionEnabled(): PropertyValue;
|
||||
protected convertRawPropertyValue(property: PropertyMetadataAny, value: string): PropertyValue;
|
||||
processPushNotification(station: Station, message: PushMessage, eventDurationSeconds: number): void;
|
||||
}
|
||||
export declare class IndoorCamera extends Camera {
|
||||
protected constructor(api: HTTPApi, device: DeviceListResponse, deviceConfig: DeviceConfig);
|
||||
static getInstance(api: HTTPApi, device: DeviceListResponse, deviceConfig: DeviceConfig): Promise<IndoorCamera>;
|
||||
isLedEnabled(): PropertyValue;
|
||||
isMotionDetectionEnabled(): PropertyValue;
|
||||
isPetDetectionEnabled(): PropertyValue;
|
||||
isSoundDetectionEnabled(): PropertyValue;
|
||||
isPetDetected(): boolean;
|
||||
isSoundDetected(): boolean;
|
||||
isCryingDetected(): boolean;
|
||||
processPushNotification(station: Station, message: PushMessage, eventDurationSeconds: number): void;
|
||||
destroy(): void;
|
||||
}
|
||||
export declare class DoorbellCamera extends Camera {
|
||||
protected voices: Voices;
|
||||
protected constructor(api: HTTPApi, device: DeviceListResponse, voices: Voices, deviceConfig: DeviceConfig);
|
||||
static getInstance(api: HTTPApi, device: DeviceListResponse, deviceConfig: DeviceConfig): Promise<DoorbellCamera>;
|
||||
private loadMetadataVoiceStates;
|
||||
getVoiceName(id: number): string;
|
||||
getVoices(): Voices;
|
||||
getPropertiesMetadata(hidden?: boolean): IndexedProperty;
|
||||
isRinging(): boolean;
|
||||
protected handlePropertyChange(metadata: PropertyMetadataAny, oldValue: PropertyValue, newValue: PropertyValue): void;
|
||||
processPushNotification(station: Station, message: PushMessage, eventDurationSeconds: number): void;
|
||||
}
|
||||
export declare class WiredDoorbellCamera extends DoorbellCamera {
|
||||
static getInstance(api: HTTPApi, device: DeviceListResponse, deviceConfig: DeviceConfig): Promise<WiredDoorbellCamera>;
|
||||
isLedEnabled(): PropertyValue;
|
||||
isAutoNightVisionEnabled(): PropertyValue;
|
||||
isMotionDetectionEnabled(): PropertyValue;
|
||||
}
|
||||
export declare class BatteryDoorbellCamera extends DoorbellCamera {
|
||||
static getInstance(api: HTTPApi, device: DeviceListResponse, deviceConfig: DeviceConfig): Promise<BatteryDoorbellCamera>;
|
||||
isLedEnabled(): PropertyValue;
|
||||
}
|
||||
export declare class FloodlightCamera extends Camera {
|
||||
static getInstance(api: HTTPApi, device: DeviceListResponse, deviceConfig: DeviceConfig): Promise<FloodlightCamera>;
|
||||
isLedEnabled(): PropertyValue;
|
||||
isMotionDetectionEnabled(): PropertyValue;
|
||||
protected convertRawPropertyValue(property: PropertyMetadataAny, value: string): PropertyValue;
|
||||
processPushNotification(station: Station, message: PushMessage, eventDurationSeconds: number): void;
|
||||
}
|
||||
export declare class WallLightCam extends Camera {
|
||||
static getInstance(api: HTTPApi, device: DeviceListResponse, deviceConfig: DeviceConfig): Promise<WallLightCam>;
|
||||
isLedEnabled(): PropertyValue;
|
||||
isMotionDetectionEnabled(): PropertyValue;
|
||||
protected convertRawPropertyValue(property: PropertyMetadataAny, value: string): PropertyValue;
|
||||
getPropertiesMetadata(hidden?: boolean): IndexedProperty;
|
||||
processPushNotification(station: Station, message: PushMessage, eventDurationSeconds: number): void;
|
||||
}
|
||||
export declare class GarageCamera extends Camera {
|
||||
static getInstance(api: HTTPApi, device: DeviceListResponse, deviceConfig: DeviceConfig): Promise<GarageCamera>;
|
||||
isLedEnabled(): PropertyValue;
|
||||
isMotionDetectionEnabled(): PropertyValue;
|
||||
protected convertRawPropertyValue(property: PropertyMetadataAny, value: string): PropertyValue;
|
||||
processPushNotification(station: Station, message: PushMessage, eventDurationSeconds: number): void;
|
||||
}
|
||||
export declare class Sensor extends Device {
|
||||
static getInstance(api: HTTPApi, device: DeviceListResponse, deviceConfig: DeviceConfig): Promise<Sensor>;
|
||||
getStateChannel(): string;
|
||||
getState(): PropertyValue;
|
||||
}
|
||||
export declare class EntrySensor extends Sensor {
|
||||
static getInstance(api: HTTPApi, device: DeviceListResponse, deviceConfig: DeviceConfig): Promise<EntrySensor>;
|
||||
isSensorOpen(): PropertyValue;
|
||||
getSensorChangeTime(): PropertyValue;
|
||||
isBatteryLow(): PropertyValue;
|
||||
processPushNotification(station: Station, message: PushMessage, eventDurationSeconds: number): void;
|
||||
protected handlePropertyChange(metadata: PropertyMetadataAny, oldValue: PropertyValue, newValue: PropertyValue): void;
|
||||
}
|
||||
export declare class MotionSensor extends Sensor {
|
||||
static readonly MOTION_COOLDOWN_MS = 120000;
|
||||
protected constructor(api: HTTPApi, device: DeviceListResponse, deviceConfig: DeviceConfig);
|
||||
static getInstance(api: HTTPApi, device: DeviceListResponse, deviceConfig: DeviceConfig): Promise<MotionSensor>;
|
||||
isMotionDetected(): boolean;
|
||||
getMotionSensorPIREvent(): PropertyValue;
|
||||
isBatteryLow(): PropertyValue;
|
||||
protected handlePropertyChange(metadata: PropertyMetadataAny, oldValue: PropertyValue, newValue: PropertyValue): void;
|
||||
processPushNotification(station: Station, message: PushMessage, eventDurationSeconds: number): void;
|
||||
}
|
||||
export declare class Lock extends Device {
|
||||
static readonly VERSION_CODE_SMART_LOCK = 3;
|
||||
static readonly VERSION_CODE_LOCKV12 = 18;
|
||||
static getInstance(api: HTTPApi, device: DeviceListResponse, deviceConfig: DeviceConfig): Promise<Lock>;
|
||||
getStateChannel(): string;
|
||||
protected handlePropertyChange(metadata: PropertyMetadataAny, oldValue: PropertyValue, newValue: PropertyValue): void;
|
||||
getState(): PropertyValue;
|
||||
getBatteryValue(): PropertyValue;
|
||||
getWifiRssi(): PropertyValue;
|
||||
isLocked(): PropertyValue;
|
||||
getLockStatus(): PropertyValue;
|
||||
static encodeESLCmdOnOff(short_user_id: number, nickname: string, lock: boolean): Buffer;
|
||||
static encodeESLCmdQueryStatus(admin_user_id: string): Buffer;
|
||||
processPushNotification(station: Station, message: PushMessage, eventDurationSeconds: number): void;
|
||||
processMQTTNotification(message: DeviceSmartLockNotifyData, eventDurationSeconds: number): void;
|
||||
private processNotification;
|
||||
private static getCurrentTimeInSeconds;
|
||||
private static getUInt8Buffer;
|
||||
private static getUint16LEBuffer;
|
||||
private static getUint16BEBuffer;
|
||||
static encodeCmdStatus(user_id: string): Buffer;
|
||||
static encodeCmdUnlock(short_user_id: string, value: number, username: string): Buffer;
|
||||
static encodeCmdCalibrate(user_id: string): Buffer;
|
||||
static encodeCmdAddUser(short_user_id: string, passcode: string, username: string, schedule?: Schedule, user_permission?: number): Buffer;
|
||||
static encodeCmdAddTemporaryUser(schedule?: Schedule, unlimited?: boolean): Buffer;
|
||||
static encodeCmdDeleteTemporaryUser(password_id: string): Buffer;
|
||||
static encodeCmdDeleteUser(short_user_id: string): Buffer;
|
||||
static encodeCmdVerifyPw(password: string): Buffer;
|
||||
static encodeCmdQueryLockRecord(index: number): Buffer;
|
||||
static encodeCmdQueryUser(short_user_id: string): Buffer;
|
||||
static encodeCmdQueryPassword(password_id: string): Buffer;
|
||||
static encodeCmdModifyPassword(password_id: string, passcode: string): Buffer;
|
||||
static encodeCmdUpdateSchedule(short_user_id: string, schedule: Schedule): Buffer;
|
||||
static encodeCmdModifyUsername(username: string, password_id: string): Buffer;
|
||||
static encodeCmdGetLockParam(user_id: string): Buffer;
|
||||
static encodeCmdSetLockParamAutoLock(enabled: boolean, lockTimeSeconds: number): Buffer;
|
||||
private static hexTime;
|
||||
static encodeCmdSetLockParamAutoLockSchedule(enabled: boolean, schedule_start: string, schedule_end: string): Buffer;
|
||||
static encodeCmdSetLockParamOneTouchLock(enabled: boolean): Buffer;
|
||||
static encodeCmdSetLockParamWrongTryProtect(enabled: boolean, lockdownTime: number, attempts: number): Buffer;
|
||||
static encodeCmdSetLockParamScramblePasscode(enabled: boolean): Buffer;
|
||||
static encodeCmdSetLockParamSound(value: number): Buffer;
|
||||
protected convertRawPropertyValue(property: PropertyMetadataAny, value: string): PropertyValue;
|
||||
static encodeCmdSmartLockUnlock(adminUserId: string, lock: boolean, username: string, shortUserId: string): Buffer;
|
||||
static encodeCmdSmartLockCalibrate(adminUserId: string): Buffer;
|
||||
static encodeCmdSetSmartLockParamWrongTryProtect(adminUserId: string, enabled: boolean, attempts: number, lockdownTime: number): Buffer;
|
||||
private static hexTimeSmartLock;
|
||||
static encodeCmdSetSmartLockParamAutoLock(adminUserId: string, enabled: boolean, lockTimeSeconds: number, schedule: boolean, scheduleStart: string, scheduleEnd: string): Buffer;
|
||||
static encodeCmdSetSmartLockParamOneTouchLock(adminUserId: string, enabled: boolean): Buffer;
|
||||
static encodeCmdSetSmartLockParamScramblePasscode(adminUserId: string, enabled: boolean): Buffer;
|
||||
static encodeCmdSetSmartLockParamSound(adminUserId: string, value: number): Buffer;
|
||||
static encodeCmdSmartLockAddUser(adminUserId: string, shortUserId: string, passcode: string, username: string, schedule?: Schedule, userPermission?: number): Buffer;
|
||||
static encodeCmdSmartLockDeleteUser(adminUserId: string, shortUserId: string): Buffer;
|
||||
static encodeCmdSmartLockUpdateSchedule(adminUserId: string, shortUserId: string, username: string, schedule: Schedule, userPermission?: number): Buffer;
|
||||
static encodeCmdSmartLockModifyPassword(adminUserId: string, passwordId: string, passcode: string): Buffer;
|
||||
static encodeCmdSmartLockGetUserList(adminUserId: string): Buffer;
|
||||
static encodeCmdSmartLockStatus(adminUserId: string): Buffer;
|
||||
static encodeCmdSmartLockGetParams(adminUserId: string): Buffer;
|
||||
}
|
||||
export declare class LockKeypad extends Device {
|
||||
static getInstance(api: HTTPApi, device: DeviceListResponse, deviceConfig: DeviceConfig): Promise<LockKeypad>;
|
||||
getStateChannel(): string;
|
||||
}
|
||||
export declare class Keypad extends Device {
|
||||
static getInstance(api: HTTPApi, device: DeviceListResponse, deviceConfig: DeviceConfig): Promise<Keypad>;
|
||||
getStateChannel(): string;
|
||||
getState(): PropertyValue;
|
||||
isBatteryLow(): PropertyValue;
|
||||
isBatteryCharging(): PropertyValue;
|
||||
protected convertRawPropertyValue(property: PropertyMetadataAny, value: string): PropertyValue;
|
||||
}
|
||||
export declare class SmartSafe extends Device {
|
||||
static readonly IV = "052E19EB3F880512E99EBB684D4DC1FE";
|
||||
static readonly DATA_HEADER: number[];
|
||||
static readonly VERSION_CODE = 1;
|
||||
static readonly PUSH_NOTIFICATION_POSITION: {
|
||||
[index: string]: number;
|
||||
};
|
||||
static getInstance(api: HTTPApi, device: DeviceListResponse, deviceConfig: DeviceConfig): Promise<SmartSafe>;
|
||||
getStateChannel(): string;
|
||||
private static getCurrentTimeInSeconds;
|
||||
private static getUInt8Buffer;
|
||||
private static getUint16LEBuffer;
|
||||
private static encodeCmdSingleUInt8;
|
||||
static encodeCmdWrongTryProtect(user_id: string, enabled: boolean, attempts: number, lockdownTime: number): Buffer;
|
||||
static encodeCmdLeftOpenAlarm(user_id: string, enabled: boolean, duration: number): Buffer;
|
||||
static encodeCmdDualUnlock(user_id: string, enabled: boolean): Buffer;
|
||||
static encodeCmdScramblePIN(user_id: string, enabled: boolean): Buffer;
|
||||
static encodeCmdPowerSave(user_id: string, enabled: boolean): Buffer;
|
||||
static encodeCmdInteriorBrightness(user_id: string, interiorBrightness: number, duration: number): Buffer;
|
||||
static encodeCmdTamperAlarm(user_id: string, option: number): Buffer;
|
||||
static encodeCmdRemoteUnlock(user_id: string, option: number): Buffer;
|
||||
static encodeCmdAlertVolume(user_id: string, volume: number): Buffer;
|
||||
static encodeCmdPromptVolume(user_id: string, volume: number): Buffer;
|
||||
static encodeCmdPushNotification(user_id: string, modes: number): Buffer;
|
||||
static encodeCmdUnlock(user_id: string): Buffer;
|
||||
static encodeCmdVerifyPIN(user_id: string, pin: string): Buffer;
|
||||
protected convertRawPropertyValue(property: PropertyMetadataAny, value: string): PropertyValue;
|
||||
shakeEvent(event: number, eventDurationSeconds: number): void;
|
||||
alarm911Event(event: number, eventDurationSeconds: number): void;
|
||||
jammedEvent(eventDurationSeconds: number): void;
|
||||
lowBatteryEvent(eventDurationSeconds: number): void;
|
||||
wrongTryProtectAlarmEvent(eventDurationSeconds: number): void;
|
||||
processPushNotification(station: Station, message: PushMessage, eventDurationSeconds: number): void;
|
||||
protected handlePropertyChange(metadata: PropertyMetadataAny, oldValue: PropertyValue, newValue: PropertyValue): void;
|
||||
getState(): PropertyValue;
|
||||
getBatteryValue(): PropertyValue;
|
||||
getWifiRssi(): PropertyValue;
|
||||
isLocked(): boolean;
|
||||
}
|
||||
export declare class Tracker extends Device {
|
||||
static getInstance(api: HTTPApi, device: DeviceListResponse, deviceConfig: DeviceConfig): Promise<Tracker>;
|
||||
getStateChannel(): string;
|
||||
protected convertRawPropertyValue(property: PropertyMetadataAny, value: string): PropertyValue;
|
||||
setFindPhone(value: boolean): Promise<boolean>;
|
||||
setLeftBehindAlarm(value: boolean): Promise<boolean>;
|
||||
setTrackerType(value: TrackerType): Promise<boolean>;
|
||||
}
|
||||
export declare class DoorbellLock extends DoorbellCamera {
|
||||
static getInstance(api: HTTPApi, device: DeviceListResponse, deviceConfig: DeviceConfig): Promise<DoorbellLock>;
|
||||
getStateChannel(): string;
|
||||
protected handlePropertyChange(metadata: PropertyMetadataAny, oldValue: PropertyValue, newValue: PropertyValue): void;
|
||||
protected convertRawPropertyValue(property: PropertyMetadataAny, value: string): PropertyValue;
|
||||
getState(): PropertyValue;
|
||||
getBatteryValue(): PropertyValue;
|
||||
getWifiRssi(): PropertyValue;
|
||||
isLocked(): PropertyValue;
|
||||
getLockStatus(): PropertyValue;
|
||||
processPushNotification(station: Station, message: PushMessage, eventDurationSeconds: number): void;
|
||||
}
|
||||
export declare class SmartDrop extends Camera {
|
||||
static getInstance(api: HTTPApi, device: DeviceListResponse, deviceConfig: DeviceConfig): Promise<SmartDrop>;
|
||||
getStateChannel(): string;
|
||||
processPushNotification(station: Station, message: PushMessage, eventDurationSeconds: number): void;
|
||||
protected handlePropertyChange(metadata: PropertyMetadataAny, oldValue: PropertyValue, newValue: PropertyValue): void;
|
||||
}
|
||||
export declare class UnknownDevice extends Device {
|
||||
static getInstance(api: HTTPApi, device: DeviceListResponse, deviceConfig: DeviceConfig): Promise<UnknownDevice>;
|
||||
getStateChannel(): string;
|
||||
}
|
||||
4306
build/http/device.js
Normal file
4306
build/http/device.js
Normal file
File diff suppressed because it is too large
Load Diff
1
build/http/device.js.map
Normal file
1
build/http/device.js.map
Normal file
File diff suppressed because one or more lines are too long
73
build/http/error.d.ts
vendored
Normal file
73
build/http/error.d.ts
vendored
Normal file
@ -0,0 +1,73 @@
|
||||
import { BaseError, Jsonable } from "../error";
|
||||
export declare class InvalidPropertyError extends BaseError {
|
||||
constructor(message: string, options?: {
|
||||
cause?: Error;
|
||||
context?: Jsonable;
|
||||
});
|
||||
}
|
||||
export declare class LivestreamAlreadyRunningError extends BaseError {
|
||||
constructor(message: string, options?: {
|
||||
cause?: Error;
|
||||
context?: Jsonable;
|
||||
});
|
||||
}
|
||||
export declare class LivestreamNotRunningError extends BaseError {
|
||||
constructor(message: string, options?: {
|
||||
cause?: Error;
|
||||
context?: Jsonable;
|
||||
});
|
||||
}
|
||||
export declare class PropertyNotSupportedError extends BaseError {
|
||||
constructor(message: string, options?: {
|
||||
cause?: Error;
|
||||
context?: Jsonable;
|
||||
});
|
||||
}
|
||||
export declare class ApiResponseCodeError extends BaseError {
|
||||
constructor(message: string, options?: {
|
||||
cause?: Error;
|
||||
context?: Jsonable;
|
||||
});
|
||||
}
|
||||
export declare class ApiInvalidResponseError extends BaseError {
|
||||
constructor(message: string, options?: {
|
||||
cause?: Error;
|
||||
context?: Jsonable;
|
||||
});
|
||||
}
|
||||
export declare class ApiHTTPResponseCodeError extends BaseError {
|
||||
constructor(message: string, options?: {
|
||||
cause?: Error;
|
||||
context?: Jsonable;
|
||||
});
|
||||
}
|
||||
export declare class ApiGenericError extends BaseError {
|
||||
constructor(message: string, options?: {
|
||||
cause?: Error;
|
||||
context?: Jsonable;
|
||||
});
|
||||
}
|
||||
export declare class ApiBaseLoadError extends BaseError {
|
||||
constructor(message: string, options?: {
|
||||
cause?: Error;
|
||||
context?: Jsonable;
|
||||
});
|
||||
}
|
||||
export declare class ApiRequestError extends BaseError {
|
||||
constructor(message: string, options?: {
|
||||
cause?: Error;
|
||||
context?: Jsonable;
|
||||
});
|
||||
}
|
||||
export declare class ImageBaseCodeError extends BaseError {
|
||||
constructor(message: string, options?: {
|
||||
cause?: Error;
|
||||
context?: Jsonable;
|
||||
});
|
||||
}
|
||||
export declare class ImageSeedError extends BaseError {
|
||||
constructor(message: string, options?: {
|
||||
cause?: Error;
|
||||
context?: Jsonable;
|
||||
});
|
||||
}
|
||||
101
build/http/error.js
Normal file
101
build/http/error.js
Normal file
@ -0,0 +1,101 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ImageSeedError = exports.ImageBaseCodeError = exports.ApiRequestError = exports.ApiBaseLoadError = exports.ApiGenericError = exports.ApiHTTPResponseCodeError = exports.ApiInvalidResponseError = exports.ApiResponseCodeError = exports.PropertyNotSupportedError = exports.LivestreamNotRunningError = exports.LivestreamAlreadyRunningError = exports.InvalidPropertyError = void 0;
|
||||
const error_1 = require("../error");
|
||||
class InvalidPropertyError extends error_1.BaseError {
|
||||
constructor(message, options = {}) {
|
||||
super(message, options);
|
||||
Object.setPrototypeOf(this, new.target.prototype);
|
||||
this.name = InvalidPropertyError.name;
|
||||
}
|
||||
}
|
||||
exports.InvalidPropertyError = InvalidPropertyError;
|
||||
class LivestreamAlreadyRunningError extends error_1.BaseError {
|
||||
constructor(message, options = {}) {
|
||||
super(message, options);
|
||||
Object.setPrototypeOf(this, new.target.prototype);
|
||||
this.name = LivestreamAlreadyRunningError.name;
|
||||
}
|
||||
}
|
||||
exports.LivestreamAlreadyRunningError = LivestreamAlreadyRunningError;
|
||||
class LivestreamNotRunningError extends error_1.BaseError {
|
||||
constructor(message, options = {}) {
|
||||
super(message, options);
|
||||
Object.setPrototypeOf(this, new.target.prototype);
|
||||
this.name = LivestreamNotRunningError.name;
|
||||
}
|
||||
}
|
||||
exports.LivestreamNotRunningError = LivestreamNotRunningError;
|
||||
class PropertyNotSupportedError extends error_1.BaseError {
|
||||
constructor(message, options = {}) {
|
||||
super(message, options);
|
||||
Object.setPrototypeOf(this, new.target.prototype);
|
||||
this.name = PropertyNotSupportedError.name;
|
||||
}
|
||||
}
|
||||
exports.PropertyNotSupportedError = PropertyNotSupportedError;
|
||||
class ApiResponseCodeError extends error_1.BaseError {
|
||||
constructor(message, options = {}) {
|
||||
super(message, options);
|
||||
Object.setPrototypeOf(this, new.target.prototype);
|
||||
this.name = ApiResponseCodeError.name;
|
||||
}
|
||||
}
|
||||
exports.ApiResponseCodeError = ApiResponseCodeError;
|
||||
class ApiInvalidResponseError extends error_1.BaseError {
|
||||
constructor(message, options = {}) {
|
||||
super(message, options);
|
||||
Object.setPrototypeOf(this, new.target.prototype);
|
||||
this.name = ApiInvalidResponseError.name;
|
||||
}
|
||||
}
|
||||
exports.ApiInvalidResponseError = ApiInvalidResponseError;
|
||||
class ApiHTTPResponseCodeError extends error_1.BaseError {
|
||||
constructor(message, options = {}) {
|
||||
super(message, options);
|
||||
Object.setPrototypeOf(this, new.target.prototype);
|
||||
this.name = ApiHTTPResponseCodeError.name;
|
||||
}
|
||||
}
|
||||
exports.ApiHTTPResponseCodeError = ApiHTTPResponseCodeError;
|
||||
class ApiGenericError extends error_1.BaseError {
|
||||
constructor(message, options = {}) {
|
||||
super(message, options);
|
||||
Object.setPrototypeOf(this, new.target.prototype);
|
||||
this.name = ApiGenericError.name;
|
||||
}
|
||||
}
|
||||
exports.ApiGenericError = ApiGenericError;
|
||||
class ApiBaseLoadError extends error_1.BaseError {
|
||||
constructor(message, options = {}) {
|
||||
super(message, options);
|
||||
Object.setPrototypeOf(this, new.target.prototype);
|
||||
this.name = ApiBaseLoadError.name;
|
||||
}
|
||||
}
|
||||
exports.ApiBaseLoadError = ApiBaseLoadError;
|
||||
class ApiRequestError extends error_1.BaseError {
|
||||
constructor(message, options = {}) {
|
||||
super(message, options);
|
||||
Object.setPrototypeOf(this, new.target.prototype);
|
||||
this.name = ApiRequestError.name;
|
||||
}
|
||||
}
|
||||
exports.ApiRequestError = ApiRequestError;
|
||||
class ImageBaseCodeError extends error_1.BaseError {
|
||||
constructor(message, options = {}) {
|
||||
super(message, options);
|
||||
Object.setPrototypeOf(this, new.target.prototype);
|
||||
this.name = ImageBaseCodeError.name;
|
||||
}
|
||||
}
|
||||
exports.ImageBaseCodeError = ImageBaseCodeError;
|
||||
class ImageSeedError extends error_1.BaseError {
|
||||
constructor(message, options = {}) {
|
||||
super(message, options);
|
||||
Object.setPrototypeOf(this, new.target.prototype);
|
||||
this.name = ImageSeedError.name;
|
||||
}
|
||||
}
|
||||
exports.ImageSeedError = ImageSeedError;
|
||||
//# sourceMappingURL=error.js.map
|
||||
1
build/http/error.js.map
Normal file
1
build/http/error.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/http/error.ts"],"names":[],"mappings":";;;AAAA,oCAA+C;AAE/C,MAAa,oBAAqB,SAAQ,iBAAS;IAC/C,YAAY,OAAe,EAAE,UAAiD,EAAE;QAC5E,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAClD,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC,IAAI,CAAC;IAC1C,CAAC;CACJ;AAND,oDAMC;AAED,MAAa,6BAA8B,SAAQ,iBAAS;IACxD,YAAY,OAAe,EAAE,UAAiD,EAAE;QAC5E,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAClD,IAAI,CAAC,IAAI,GAAG,6BAA6B,CAAC,IAAI,CAAC;IACnD,CAAC;CACJ;AAND,sEAMC;AAED,MAAa,yBAA0B,SAAQ,iBAAS;IACpD,YAAY,OAAe,EAAE,UAAiD,EAAE;QAC5E,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAClD,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC,IAAI,CAAC;IAC/C,CAAC;CACJ;AAND,8DAMC;AAED,MAAa,yBAA0B,SAAQ,iBAAS;IACpD,YAAY,OAAe,EAAE,UAAiD,EAAE;QAC5E,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAClD,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC,IAAI,CAAC;IAC/C,CAAC;CACJ;AAND,8DAMC;AAED,MAAa,oBAAqB,SAAQ,iBAAS;IAC/C,YAAY,OAAe,EAAE,UAAiD,EAAE;QAC5E,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAClD,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC,IAAI,CAAC;IAC1C,CAAC;CACJ;AAND,oDAMC;AAED,MAAa,uBAAwB,SAAQ,iBAAS;IAClD,YAAY,OAAe,EAAE,UAAiD,EAAE;QAC5E,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAClD,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC,IAAI,CAAC;IAC7C,CAAC;CACJ;AAND,0DAMC;AAED,MAAa,wBAAyB,SAAQ,iBAAS;IACnD,YAAY,OAAe,EAAE,UAAiD,EAAE;QAC5E,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAClD,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC,IAAI,CAAC;IAC9C,CAAC;CACJ;AAND,4DAMC;AAED,MAAa,eAAgB,SAAQ,iBAAS;IAC1C,YAAY,OAAe,EAAE,UAAiD,EAAE;QAC5E,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAClD,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC,IAAI,CAAC;IACrC,CAAC;CACJ;AAND,0CAMC;AAED,MAAa,gBAAiB,SAAQ,iBAAS;IAE3C,YAAY,OAAe,EAAE,UAAiD,EAAE;QAC5E,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAClD,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC,IAAI,CAAC;IACtC,CAAC;CACJ;AAPD,4CAOC;AAED,MAAa,eAAgB,SAAQ,iBAAS;IAE1C,YAAY,OAAe,EAAE,UAAiD,EAAE;QAC5E,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAClD,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC,IAAI,CAAC;IACrC,CAAC;CACJ;AAPD,0CAOC;AAED,MAAa,kBAAmB,SAAQ,iBAAS;IAE7C,YAAY,OAAe,EAAE,UAAiD,EAAE;QAC5E,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAClD,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC,IAAI,CAAC;IACxC,CAAC;CACJ;AAPD,gDAOC;AAED,MAAa,cAAe,SAAQ,iBAAS;IAEzC,YAAY,OAAe,EAAE,UAAiD,EAAE;QAC5E,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAClD,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC,IAAI,CAAC;IACpC,CAAC;CACJ;AAPD,wCAOC"}
|
||||
10
build/http/index.d.ts
vendored
Normal file
10
build/http/index.d.ts
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
export * from "./api";
|
||||
export * from "./cache";
|
||||
export * from "./device";
|
||||
export * from "./interfaces";
|
||||
export * from "./models";
|
||||
export * from "./parameter";
|
||||
export * from "./station";
|
||||
export * from "./types";
|
||||
export * from "./error";
|
||||
export { isGreaterEqualMinVersion, getAbsoluteFilePath } from "./utils";
|
||||
30
build/http/index.js
Normal file
30
build/http/index.js
Normal file
@ -0,0 +1,30 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getAbsoluteFilePath = exports.isGreaterEqualMinVersion = void 0;
|
||||
__exportStar(require("./api"), exports);
|
||||
__exportStar(require("./cache"), exports);
|
||||
__exportStar(require("./device"), exports);
|
||||
__exportStar(require("./interfaces"), exports);
|
||||
__exportStar(require("./models"), exports);
|
||||
__exportStar(require("./parameter"), exports);
|
||||
__exportStar(require("./station"), exports);
|
||||
__exportStar(require("./types"), exports);
|
||||
__exportStar(require("./error"), exports);
|
||||
var utils_1 = require("./utils");
|
||||
Object.defineProperty(exports, "isGreaterEqualMinVersion", { enumerable: true, get: function () { return utils_1.isGreaterEqualMinVersion; } });
|
||||
Object.defineProperty(exports, "getAbsoluteFilePath", { enumerable: true, get: function () { return utils_1.getAbsoluteFilePath; } });
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
build/http/index.js.map
Normal file
1
build/http/index.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/http/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,wCAAsB;AACtB,0CAAwB;AACxB,2CAAyB;AACzB,+CAA6B;AAC7B,2CAAyB;AACzB,8CAA4B;AAC5B,4CAA0B;AAC1B,0CAAwB;AACxB,0CAAwB;AACxB,iCAAuE;AAA9D,iHAAA,wBAAwB,OAAA;AAAE,4GAAA,mBAAmB,OAAA"}
|
||||
241
build/http/interfaces.d.ts
vendored
Normal file
241
build/http/interfaces.d.ts
vendored
Normal file
@ -0,0 +1,241 @@
|
||||
import { Readable } from "stream";
|
||||
import type { Method } from "got" with {
|
||||
"resolution-mode": "import"
|
||||
};
|
||||
import type { ImageFileExtension } from "image-type" with {
|
||||
"resolution-mode": "import"
|
||||
};
|
||||
import { DatabaseCountByDate, DatabaseQueryLatestInfo, DatabaseQueryLocal, StreamMetadata } from "../p2p/interfaces";
|
||||
import { CommandResult, StorageInfoBodyHB3 } from "../p2p/models";
|
||||
import { AlarmEvent, DatabaseReturnCode, SmartSafeAlarm911Event, SmartSafeShakeAlarmEvent, TFCardStatus } from "../p2p/types";
|
||||
import { Camera, Device } from "./device";
|
||||
import { Cipher, Voice, Invite, DeviceListResponse, StationListResponse, HouseListResponse } from "./models";
|
||||
import { Station } from "./station";
|
||||
import { CommandName, PropertyName, SourceType } from "./types";
|
||||
import { TalkbackStream } from "../p2p/talkback";
|
||||
export type PropertyValue = number | boolean | string | object;
|
||||
export interface PropertyValues {
|
||||
[index: string]: PropertyValue;
|
||||
}
|
||||
export interface DeviceConfig {
|
||||
simultaneousDetections?: boolean;
|
||||
}
|
||||
export interface RawValue {
|
||||
value: string;
|
||||
source: SourceType;
|
||||
}
|
||||
export interface RawValues {
|
||||
[index: number]: RawValue;
|
||||
}
|
||||
export interface Devices {
|
||||
[index: string]: Device;
|
||||
}
|
||||
export interface Cameras {
|
||||
[index: string]: Camera;
|
||||
}
|
||||
export interface Stations {
|
||||
[index: string]: Station;
|
||||
}
|
||||
export interface Houses {
|
||||
[index: string]: HouseListResponse;
|
||||
}
|
||||
export interface Hubs {
|
||||
[index: string]: StationListResponse;
|
||||
}
|
||||
export interface FullDevices {
|
||||
[index: string]: DeviceListResponse;
|
||||
}
|
||||
export interface Ciphers {
|
||||
[index: number]: Cipher;
|
||||
}
|
||||
export interface Voices {
|
||||
[index: number]: Voice;
|
||||
}
|
||||
export interface Invites {
|
||||
[index: number]: Invite;
|
||||
}
|
||||
export interface HTTPApiRequest {
|
||||
method: Method;
|
||||
endpoint: string | URL;
|
||||
responseType?: "text" | "json" | "buffer";
|
||||
data?: any;
|
||||
}
|
||||
export type PropertyMetadataType = "number" | "boolean" | "string" | "object";
|
||||
export interface PropertyMetadataAny {
|
||||
key: number | string;
|
||||
name: PropertyName;
|
||||
type: PropertyMetadataType;
|
||||
default?: any;
|
||||
readable: boolean;
|
||||
writeable: boolean;
|
||||
description?: string;
|
||||
label?: string;
|
||||
commandId?: number;
|
||||
}
|
||||
export interface PropertyMetadataNumeric extends PropertyMetadataAny {
|
||||
type: "number";
|
||||
min?: number;
|
||||
max?: number;
|
||||
steps?: number;
|
||||
default?: number;
|
||||
states?: Record<number, string>;
|
||||
unit?: string;
|
||||
}
|
||||
export interface PropertyMetadataBoolean extends PropertyMetadataAny {
|
||||
type: "boolean";
|
||||
default?: boolean;
|
||||
}
|
||||
export interface PropertyMetadataString extends PropertyMetadataAny {
|
||||
type: "string";
|
||||
minLength?: number;
|
||||
maxLength?: number;
|
||||
default?: string;
|
||||
format?: RegExp;
|
||||
}
|
||||
export interface PropertyMetadataObject extends PropertyMetadataAny {
|
||||
type: "object";
|
||||
isValidObject?: (obj: any) => boolean;
|
||||
default?: any;
|
||||
}
|
||||
export interface IndexedProperty {
|
||||
[index: string]: PropertyMetadataAny;
|
||||
}
|
||||
export interface Properties {
|
||||
[index: number]: IndexedProperty;
|
||||
}
|
||||
export interface Commands {
|
||||
[index: number]: Array<CommandName>;
|
||||
}
|
||||
export interface HTTPApiPersistentData {
|
||||
user_id: string;
|
||||
email: string;
|
||||
nick_name: string;
|
||||
device_public_keys: {
|
||||
[index: string]: string;
|
||||
};
|
||||
clientPrivateKey: string;
|
||||
serverPublicKey: string;
|
||||
}
|
||||
export interface CaptchaOptions {
|
||||
captchaCode: string;
|
||||
captchaId: string;
|
||||
}
|
||||
export interface LoginOptions {
|
||||
verifyCode?: string;
|
||||
captcha?: CaptchaOptions;
|
||||
force: boolean;
|
||||
}
|
||||
export interface Schedule {
|
||||
startDateTime?: Date;
|
||||
endDateTime?: Date;
|
||||
week?: {
|
||||
monday: boolean;
|
||||
tuesday: boolean;
|
||||
wednesday: boolean;
|
||||
thursday: boolean;
|
||||
friday: boolean;
|
||||
saturday: boolean;
|
||||
sunday: boolean;
|
||||
};
|
||||
}
|
||||
export interface ImageType {
|
||||
ext: ImageFileExtension | "unknown";
|
||||
mime: string;
|
||||
}
|
||||
export interface Picture {
|
||||
data: Buffer;
|
||||
type: ImageType;
|
||||
}
|
||||
export interface HTTPApiEvents {
|
||||
"devices": (devices: FullDevices) => void;
|
||||
"hubs": (hubs: Hubs) => void;
|
||||
"houses": (houses: Houses) => void;
|
||||
"connect": () => void;
|
||||
"close": () => void;
|
||||
"connection error": (error: Error) => void;
|
||||
"tfa request": () => void;
|
||||
"captcha request": (id: string, captcha: string) => void;
|
||||
"auth token invalidated": () => void;
|
||||
}
|
||||
export interface StationEvents {
|
||||
"connect": (station: Station) => void;
|
||||
"close": (station: Station) => void;
|
||||
"connection error": (station: Station, error: Error) => void;
|
||||
"raw device property changed": (deviceSN: string, params: RawValues) => void;
|
||||
"property changed": (station: Station, name: string, value: PropertyValue, ready: boolean) => void;
|
||||
"raw property changed": (station: Station, type: number, value: string) => void;
|
||||
"command result": (station: Station, result: CommandResult) => void;
|
||||
"download start": (station: Station, channel: number, metadata: StreamMetadata, videostream: Readable, audiostream: Readable) => void;
|
||||
"download finish": (station: Station, channel: number) => void;
|
||||
"livestream start": (station: Station, channel: number, metadata: StreamMetadata, videostream: Readable, audiostream: Readable) => void;
|
||||
"livestream stop": (station: Station, channel: number) => void;
|
||||
"livestream error": (station: Station, channel: number, error: Error) => void;
|
||||
"rtsp livestream start": (station: Station, channel: number) => void;
|
||||
"rtsp livestream stop": (station: Station, channel: number) => void;
|
||||
"rtsp url": (station: Station, channel: number, value: string) => void;
|
||||
"guard mode": (station: Station, guardMode: number) => void;
|
||||
"current mode": (station: Station, currentMode: number) => void;
|
||||
"alarm event": (station: Station, alarmEvent: AlarmEvent) => void;
|
||||
"ready": (station: Station) => void;
|
||||
"runtime state": (station: Station, channel: number, batteryLevel: number, temperature: number) => void;
|
||||
"charging state": (station: Station, channel: number, chargeType: number, batteryLevel: number) => void;
|
||||
"wifi rssi": (station: Station, channel: number, rssi: number) => void;
|
||||
"floodlight manual switch": (station: Station, channel: number, enabled: boolean) => void;
|
||||
"alarm delay event": (station: Station, alarmDelayEvent: AlarmEvent, alarmDelay: number) => void;
|
||||
"alarm arm delay event": (station: Station, armDelay: number) => void;
|
||||
"alarm armed event": (station: Station) => void;
|
||||
"talkback started": (station: Station, channel: number, talkbackStream: TalkbackStream) => void;
|
||||
"talkback stopped": (station: Station, channel: number) => void;
|
||||
"talkback error": (station: Station, channel: number, error: Error) => void;
|
||||
"secondary command result": (station: Station, result: CommandResult) => void;
|
||||
"device shake alarm": (deviceSN: string, event: SmartSafeShakeAlarmEvent) => void;
|
||||
"device 911 alarm": (deviceSN: string, event: SmartSafeAlarm911Event) => void;
|
||||
"device jammed": (deviceSN: string) => void;
|
||||
"device low battery": (deviceSN: string) => void;
|
||||
"device wrong try-protect alarm": (deviceSN: string) => void;
|
||||
"device pin verified": (deviceSN: string, successfull: boolean) => void;
|
||||
"sd info ex": (station: Station, sdStatus: TFCardStatus, sdCapacity: number, sdCapacityAvailable: number) => void;
|
||||
"image download": (station: Station, file: string, image: Buffer) => void;
|
||||
"database query latest": (station: Station, returnCode: DatabaseReturnCode, data: Array<DatabaseQueryLatestInfo>) => void;
|
||||
"database query local": (station: Station, returnCode: DatabaseReturnCode, data: Array<DatabaseQueryLocal>) => void;
|
||||
"database count by date": (station: Station, returnCode: DatabaseReturnCode, data: Array<DatabaseCountByDate>) => void;
|
||||
"database delete": (station: Station, returnCode: DatabaseReturnCode, failedIds: Array<unknown>) => void;
|
||||
"sensor status": (station: Station, channel: number, status: number) => void;
|
||||
"garage door status": (station: Station, channel: number, doorId: number, status: number) => void;
|
||||
"storage info hb3": (station: Station, channel: number, storageInfo: StorageInfoBodyHB3) => void;
|
||||
}
|
||||
export interface DeviceEvents {
|
||||
"property changed": (device: Device, name: string, value: PropertyValue, ready: boolean) => void;
|
||||
"raw property changed": (device: Device, type: number, value: string) => void;
|
||||
"motion detected": (device: Device, state: boolean) => void;
|
||||
"person detected": (device: Device, state: boolean, person: string) => void;
|
||||
"pet detected": (device: Device, state: boolean) => void;
|
||||
"sound detected": (device: Device, state: boolean) => void;
|
||||
"crying detected": (device: Device, state: boolean) => void;
|
||||
"vehicle detected": (device: Device, state: boolean) => void;
|
||||
"dog detected": (device: Device, state: boolean) => void;
|
||||
"dog lick detected": (device: Device, state: boolean) => void;
|
||||
"dog poop detected": (device: Device, state: boolean) => void;
|
||||
"stranger person detected": (device: Device, state: boolean) => void;
|
||||
"rings": (device: Device, state: boolean) => void;
|
||||
"locked": (device: Device, state: boolean) => void;
|
||||
"open": (device: Device, state: boolean) => void;
|
||||
"ready": (device: Device) => void;
|
||||
"package delivered": (device: Device, state: boolean) => void;
|
||||
"package stranded": (device: Device, state: boolean) => void;
|
||||
"package taken": (device: Device, state: boolean) => void;
|
||||
"someone loitering": (device: Device, state: boolean) => void;
|
||||
"radar motion detected": (device: Device, state: boolean) => void;
|
||||
"911 alarm": (device: Device, state: boolean, detail: SmartSafeAlarm911Event) => void;
|
||||
"shake alarm": (device: Device, state: boolean, detail: SmartSafeShakeAlarmEvent) => void;
|
||||
"wrong try-protect alarm": (device: Device, state: boolean) => void;
|
||||
"long time not close": (device: Device, state: boolean) => void;
|
||||
"low battery": (device: Device, state: boolean) => void;
|
||||
"jammed": (device: Device, state: boolean) => void;
|
||||
"tampering": (device: Device, state: boolean) => void;
|
||||
"low temperature": (device: Device, state: boolean) => void;
|
||||
"high temperature": (device: Device, state: boolean) => void;
|
||||
"pin incorrect": (device: Device, state: boolean) => void;
|
||||
"lid stuck": (device: Device, state: boolean) => void;
|
||||
"battery fully charged": (device: Device, state: boolean) => void;
|
||||
}
|
||||
3
build/http/interfaces.js
Normal file
3
build/http/interfaces.js
Normal file
@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=interfaces.js.map
|
||||
1
build/http/interfaces.js.map
Normal file
1
build/http/interfaces.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/http/interfaces.ts"],"names":[],"mappings":""}
|
||||
608
build/http/models.d.ts
vendored
Normal file
608
build/http/models.d.ts
vendored
Normal file
@ -0,0 +1,608 @@
|
||||
import { UserPasswordType, UserType } from "./types";
|
||||
export interface ApiResponse {
|
||||
status: number;
|
||||
statusText: string;
|
||||
data: any;
|
||||
headers: any;
|
||||
}
|
||||
export interface ResultResponse {
|
||||
code: number;
|
||||
msg: string;
|
||||
data?: any;
|
||||
outline?: any;
|
||||
}
|
||||
export interface LoginResultResponse {
|
||||
user_id: string;
|
||||
email: string;
|
||||
nick_name: string;
|
||||
auth_token: string;
|
||||
token_expires_at: number;
|
||||
avatar: string;
|
||||
invitation_code: string;
|
||||
inviter_code: string;
|
||||
verify_code_url: string;
|
||||
mac_addr: string;
|
||||
domain: string;
|
||||
ab_code: string;
|
||||
geo_key: string;
|
||||
privilege: number;
|
||||
phone: string;
|
||||
phone_code: string;
|
||||
server_secret_info: {
|
||||
public_key: string;
|
||||
} | null;
|
||||
params: Array<{
|
||||
param_type: number;
|
||||
param_value: string;
|
||||
}> | null;
|
||||
trust_list: Array<TrustDevice>;
|
||||
}
|
||||
export interface CaptchaResponse {
|
||||
captcha_id: string;
|
||||
item: string;
|
||||
}
|
||||
export interface LoginRequest {
|
||||
ab: string;
|
||||
client_secret_info: {
|
||||
public_key: string;
|
||||
};
|
||||
enc: number;
|
||||
email: string;
|
||||
password: string;
|
||||
time_zone: number;
|
||||
verify_code?: string;
|
||||
captcha_id?: string;
|
||||
answer?: string;
|
||||
transaction: string;
|
||||
}
|
||||
export interface Member {
|
||||
family_id: number;
|
||||
station_sn: string;
|
||||
admin_user_id: string;
|
||||
member_user_id: string;
|
||||
short_user_id: string;
|
||||
member_type: number;
|
||||
permissions: number;
|
||||
member_nick: string;
|
||||
action_user_id: string;
|
||||
fence_state: number;
|
||||
extra: string;
|
||||
member_avatar: string;
|
||||
house_id: string;
|
||||
create_time: number;
|
||||
update_time: number;
|
||||
status: number;
|
||||
email: string;
|
||||
nick_name: string;
|
||||
avatar: string;
|
||||
action_user_email: string;
|
||||
action_user_name: string;
|
||||
}
|
||||
export interface StationListDevice {
|
||||
device_id: number;
|
||||
is_init_complete: boolean;
|
||||
device_sn: string;
|
||||
device_name: string;
|
||||
device_model: string;
|
||||
time_zone: string;
|
||||
device_type: number;
|
||||
device_channel: number;
|
||||
station_sn: string;
|
||||
schedule: string;
|
||||
schedulex: string;
|
||||
wifi_mac: string;
|
||||
sub1g_mac: string;
|
||||
main_sw_version: string;
|
||||
main_hw_version: string;
|
||||
sec_sw_version: string;
|
||||
sec_hw_version: string;
|
||||
sector_id: number;
|
||||
event_num: number;
|
||||
wifi_ssid: string;
|
||||
ip_addr: string;
|
||||
main_sw_time: number;
|
||||
sec_sw_time: number;
|
||||
bind_time: number;
|
||||
local_ip: string;
|
||||
language: string;
|
||||
sku_number: string;
|
||||
lot_number: string;
|
||||
cpu_id: string;
|
||||
create_time: number;
|
||||
update_time: number;
|
||||
status: number;
|
||||
}
|
||||
export interface StationListResponse {
|
||||
readonly [index: string]: unknown;
|
||||
station_id: number;
|
||||
station_sn: string;
|
||||
station_name: string;
|
||||
station_model: string;
|
||||
time_zone: string;
|
||||
wifi_ssid: string;
|
||||
ip_addr: string;
|
||||
wifi_mac: string;
|
||||
sub1g_mac: string;
|
||||
main_sw_version: string;
|
||||
main_hw_version: string;
|
||||
sec_sw_version: string;
|
||||
sec_hw_version: string;
|
||||
volume: string;
|
||||
main_sw_time: number;
|
||||
sec_sw_time: number;
|
||||
bt_mac: string;
|
||||
setup_code: string;
|
||||
setup_id: string;
|
||||
device_type: number;
|
||||
event_num: number;
|
||||
sku_number: string;
|
||||
lot_number: string;
|
||||
create_time: number;
|
||||
update_time: number;
|
||||
status: number;
|
||||
station_status: number;
|
||||
status_change_time: number;
|
||||
p2p_did: string;
|
||||
push_did: string;
|
||||
p2p_license: string;
|
||||
push_license: string;
|
||||
ndt_did: string;
|
||||
ndt_license: string;
|
||||
wakeup_flag: number;
|
||||
p2p_conn: string;
|
||||
app_conn: string;
|
||||
wipn_enc_dec_key: string;
|
||||
wipn_ndt_aes128key: string;
|
||||
query_server_did: string;
|
||||
prefix: string;
|
||||
wakeup_key: string;
|
||||
member: Member;
|
||||
params: Array<ParameterResponse>;
|
||||
devices: Array<StationListDevice>;
|
||||
sensor_info: null;
|
||||
is_init_complete: boolean;
|
||||
virtual_version: string;
|
||||
house_id?: string;
|
||||
}
|
||||
export interface ParameterResponse {
|
||||
param_id: number;
|
||||
station_sn: string;
|
||||
param_type: number;
|
||||
param_value: string;
|
||||
create_time: number;
|
||||
update_time: number;
|
||||
status: number;
|
||||
}
|
||||
export interface DeviceResponse {
|
||||
device_id: number;
|
||||
is_init_complete: boolean;
|
||||
device_sn: string;
|
||||
device_name: string;
|
||||
device_model: string;
|
||||
time_zone: string;
|
||||
device_type: number;
|
||||
device_channel: number;
|
||||
station_sn: string;
|
||||
schedule: string;
|
||||
schedulex: string;
|
||||
wifi_mac: string;
|
||||
sub1g_mac: string;
|
||||
main_sw_version: string;
|
||||
main_hw_version: string;
|
||||
sec_sw_version: string;
|
||||
sec_hw_version: string;
|
||||
sector_id: number;
|
||||
event_num: number;
|
||||
wifi_ssid: string;
|
||||
ip_addr: string;
|
||||
main_sw_time: number;
|
||||
sec_sw_time: number;
|
||||
bind_time: number;
|
||||
cover_path: string;
|
||||
cover_time: number;
|
||||
local_ip: string;
|
||||
language: string;
|
||||
sku_number: string;
|
||||
lot_number: string;
|
||||
create_time: number;
|
||||
update_time: number;
|
||||
status: number;
|
||||
}
|
||||
export interface DeviceRequest {
|
||||
device_sn: string;
|
||||
num: number;
|
||||
orderby: string;
|
||||
page: number;
|
||||
station_sn: string;
|
||||
}
|
||||
export interface DeviceListResponse {
|
||||
readonly [index: string]: unknown;
|
||||
device_id: number;
|
||||
is_init_complete: boolean;
|
||||
device_sn: string;
|
||||
device_name: string;
|
||||
device_model: string;
|
||||
time_zone: string;
|
||||
device_type: number;
|
||||
device_channel: number;
|
||||
station_sn: string;
|
||||
schedule: string;
|
||||
schedulex: string;
|
||||
wifi_mac: string;
|
||||
sub1g_mac: string;
|
||||
main_sw_version: string;
|
||||
main_hw_version: string;
|
||||
sec_sw_version: string;
|
||||
sec_hw_version: string;
|
||||
sector_id: number;
|
||||
event_num: number;
|
||||
wifi_ssid: string;
|
||||
ip_addr: string;
|
||||
volume: string;
|
||||
main_sw_time: number;
|
||||
sec_sw_time: number;
|
||||
bind_time: number;
|
||||
bt_mac: string;
|
||||
cover_path: string;
|
||||
cover_time: number;
|
||||
local_ip: string;
|
||||
language: string;
|
||||
sku_number: string;
|
||||
lot_number: string;
|
||||
cpu_id: string;
|
||||
create_time: number;
|
||||
update_time: number;
|
||||
status: number;
|
||||
svr_domain: string;
|
||||
svr_port: number;
|
||||
station_conn: {
|
||||
station_sn: string;
|
||||
station_name: string;
|
||||
station_model: string;
|
||||
main_sw_version: string;
|
||||
main_hw_version: string;
|
||||
p2p_did: string;
|
||||
push_did: string;
|
||||
ndt_did: string;
|
||||
p2p_conn: string;
|
||||
app_conn: string;
|
||||
binded: false;
|
||||
setup_code: string;
|
||||
setup_id: string;
|
||||
bt_mac: string;
|
||||
wifi_mac: string;
|
||||
dsk_key: string;
|
||||
expiration: number;
|
||||
};
|
||||
family_num: number;
|
||||
member: Member;
|
||||
permission: any;
|
||||
params: Array<ParameterResponse>;
|
||||
pir_total: number;
|
||||
pir_none: number;
|
||||
pir_missing: number;
|
||||
week_pir_total: number;
|
||||
week_pir_none: number;
|
||||
month_pir_total: number;
|
||||
month_pir_none: number;
|
||||
charging_days: number;
|
||||
charing_total: number;
|
||||
charging_reserve: number;
|
||||
charging_missing: number;
|
||||
battery_usage_last_week: number;
|
||||
virtual_version: string;
|
||||
relate_devices: any;
|
||||
house_id?: string;
|
||||
}
|
||||
export interface DskKeyResponse {
|
||||
enabled: boolean;
|
||||
dsk_keys: Array<{
|
||||
station_sn: string;
|
||||
dsk_key: string;
|
||||
expiration: number;
|
||||
about_to_be_replaced: boolean;
|
||||
}>;
|
||||
}
|
||||
export interface EventRecordResponse {
|
||||
monitor_id: number;
|
||||
transfer_monitor_id: number;
|
||||
station_sn: string;
|
||||
device_sn: string;
|
||||
storage_type: number;
|
||||
storage_path: string;
|
||||
hevc_storage_path: string;
|
||||
cloud_path: string;
|
||||
frame_num: number;
|
||||
thumb_path: string;
|
||||
thumb_data: string;
|
||||
start_time: number;
|
||||
end_time: number;
|
||||
cipher_id: number;
|
||||
cipher_user_id: string;
|
||||
has_human: number;
|
||||
volume: string;
|
||||
vision: number;
|
||||
device_name: string;
|
||||
device_type: number;
|
||||
video_type: number;
|
||||
extra: string;
|
||||
user_range_id: number;
|
||||
viewed: boolean;
|
||||
create_time: number;
|
||||
update_time: number;
|
||||
status: number;
|
||||
station_name: string;
|
||||
p2p_did: string;
|
||||
push_did: string;
|
||||
p2p_license: string;
|
||||
push_license: string;
|
||||
ndt_did: string;
|
||||
ndt_license: string;
|
||||
wakeup_flag: number;
|
||||
p2p_conn: string;
|
||||
app_conn: string;
|
||||
wipn_enc_dec_key: string;
|
||||
wipn_ndt_aes128key: string;
|
||||
query_server_did: string;
|
||||
prefix: string;
|
||||
wakeup_key: string;
|
||||
ai_faces: Array<{
|
||||
is_stranger: number;
|
||||
face_url: string;
|
||||
owner_id: string;
|
||||
user_range_id: number;
|
||||
}>;
|
||||
is_favorite: boolean;
|
||||
storage_alias: number;
|
||||
}
|
||||
export interface EventRecordRequest {
|
||||
device_sn: string;
|
||||
end_time: number;
|
||||
id: number;
|
||||
id_type: number;
|
||||
is_favorite: boolean;
|
||||
num: number;
|
||||
pullup: boolean;
|
||||
shared: boolean;
|
||||
start_time: number;
|
||||
station_sn: string;
|
||||
storage: number;
|
||||
}
|
||||
export interface StreamRequest {
|
||||
device_sn: string;
|
||||
station_sn: string;
|
||||
proto?: number;
|
||||
}
|
||||
export interface TrustDevice {
|
||||
open_udid: string;
|
||||
phone_model: string;
|
||||
is_current_device: number;
|
||||
}
|
||||
export interface Cipher {
|
||||
cipher_id: number;
|
||||
user_id: string;
|
||||
private_key: string;
|
||||
}
|
||||
export interface Voice {
|
||||
voice_id: number;
|
||||
user_id: string;
|
||||
desc: string;
|
||||
device_sn: string;
|
||||
voice_link: string;
|
||||
voice_type: number;
|
||||
key_prefix: string;
|
||||
}
|
||||
export interface DeviceInvite {
|
||||
device_sn: string;
|
||||
checked: boolean;
|
||||
}
|
||||
export interface Invite {
|
||||
invite_id: number;
|
||||
station_sn: string;
|
||||
email: string;
|
||||
devices: Array<DeviceInvite>;
|
||||
action_user_id: string;
|
||||
member_nick: string;
|
||||
member_type: number;
|
||||
permissions: number;
|
||||
create_time: number;
|
||||
update_time: number;
|
||||
status: number;
|
||||
action_user_email: string;
|
||||
action_user_nick: string;
|
||||
}
|
||||
export interface ConfirmInvite {
|
||||
device_sns: Array<string>;
|
||||
invite_id: number;
|
||||
station_sn: string;
|
||||
}
|
||||
export interface SensorHistoryEntry {
|
||||
trigger_time: number;
|
||||
create_time: number;
|
||||
status: string;
|
||||
}
|
||||
export interface HouseUser {
|
||||
id: number;
|
||||
house_id: string;
|
||||
email: string;
|
||||
avatar: string;
|
||||
user_id: string;
|
||||
admin_user_id: string;
|
||||
state: string;
|
||||
role_type: number;
|
||||
}
|
||||
export interface HouseDetail {
|
||||
house_id: string;
|
||||
house_name: string;
|
||||
is_default: number;
|
||||
id: number;
|
||||
geofence_id: number;
|
||||
address: string;
|
||||
latitude: number;
|
||||
longitude: number;
|
||||
radius_range: number;
|
||||
away_mode: number;
|
||||
home_mode: number;
|
||||
location_msg: number;
|
||||
create_time: number;
|
||||
house_users: Array<HouseUser>;
|
||||
house_stations: any;
|
||||
}
|
||||
export interface HouseListResponse {
|
||||
readonly [index: string]: unknown;
|
||||
house_id: string;
|
||||
user_id: string;
|
||||
admin_user_id: string;
|
||||
role_type: number;
|
||||
house_name: string;
|
||||
is_default: number;
|
||||
geofence_id: number;
|
||||
address: string;
|
||||
latitude: number;
|
||||
longitude: number;
|
||||
radius_range: number;
|
||||
location_msg: number;
|
||||
create_time: number;
|
||||
away_mode: number;
|
||||
home_mode: number;
|
||||
}
|
||||
export interface HouseInviteListResponse {
|
||||
readonly [index: string]: unknown;
|
||||
id: number;
|
||||
house_name: string;
|
||||
action_user_nick: string;
|
||||
action_user_email: string;
|
||||
house_id: string;
|
||||
email: string;
|
||||
user_id: string;
|
||||
role_type: number;
|
||||
}
|
||||
export interface ConfirmHouseInvite {
|
||||
house_id: string;
|
||||
invite_id: number;
|
||||
is_inviter: number;
|
||||
user_id: string;
|
||||
}
|
||||
export interface PassportProfileResponse {
|
||||
user_id: string;
|
||||
email: string;
|
||||
nick_name: string;
|
||||
avatar: string;
|
||||
invitation_code: string;
|
||||
inviter_code: string;
|
||||
verify_code_url: string;
|
||||
mac_addr: string;
|
||||
country: {
|
||||
id: number;
|
||||
name: string;
|
||||
code: string;
|
||||
};
|
||||
}
|
||||
export interface StationSecuritySettings {
|
||||
account_id: string;
|
||||
count_down_alarm: StationSecuritySettingsDelayDetails;
|
||||
count_down_arm: StationSecuritySettingsDelayDetails;
|
||||
devices: StationSecuritySettingsDeviceDetails;
|
||||
}
|
||||
export interface StationSecuritySettingsDelayDetails {
|
||||
account_id: string;
|
||||
channel_list: number[];
|
||||
delay_time: number;
|
||||
}
|
||||
export interface StationSecuritySettingsDeviceDetails {
|
||||
action: number;
|
||||
device_channel: number;
|
||||
}
|
||||
export interface SnoozeDetail {
|
||||
snooze_time: number;
|
||||
snooze_chime?: boolean;
|
||||
snooze_motion?: boolean;
|
||||
snooze_homebase?: boolean;
|
||||
}
|
||||
export interface RawSchedule {
|
||||
endDay: string;
|
||||
week: string;
|
||||
startDay: string;
|
||||
startTime: string;
|
||||
endTime: string;
|
||||
}
|
||||
export interface UserPassword {
|
||||
expiration_time: number;
|
||||
is_permanent: number;
|
||||
password: string;
|
||||
password_id: string;
|
||||
password_type: UserPasswordType;
|
||||
name: string;
|
||||
schedule: RawSchedule;
|
||||
}
|
||||
export interface User {
|
||||
avatar: string;
|
||||
password_list: Array<UserPassword>;
|
||||
user_id: string;
|
||||
short_user_id: string;
|
||||
user_name: string;
|
||||
user_type: UserType;
|
||||
is_show: boolean;
|
||||
}
|
||||
export interface UsersResponse {
|
||||
device_sn: string;
|
||||
user_list: Array<User>;
|
||||
}
|
||||
export interface AddUserResponse {
|
||||
user_id: string;
|
||||
short_user_id: string;
|
||||
}
|
||||
export interface GarageDoorSensorsProperty {
|
||||
cmd: number;
|
||||
data: {
|
||||
door_1: {
|
||||
power: number;
|
||||
mac_address: string;
|
||||
version: string;
|
||||
name: string;
|
||||
sn: string;
|
||||
playalarm: number;
|
||||
ota: number;
|
||||
needota: number;
|
||||
};
|
||||
door_2: {
|
||||
power: number;
|
||||
mac_address: string;
|
||||
version: string;
|
||||
name: string;
|
||||
sn: string;
|
||||
playalarm: number;
|
||||
ota: number;
|
||||
needota: number;
|
||||
};
|
||||
};
|
||||
}
|
||||
export interface FloodlightDetectionRangeT8425Property {
|
||||
cur_mode: number;
|
||||
test_mode: number;
|
||||
mode0: Array<{
|
||||
id: number;
|
||||
sst: number;
|
||||
}>;
|
||||
mode1: Array<{
|
||||
id: number;
|
||||
sst: number;
|
||||
}>;
|
||||
mode2: Array<{
|
||||
id: number;
|
||||
sst: number;
|
||||
}>;
|
||||
}
|
||||
export interface FloodlightLightSettingsBrightnessScheduleT8425Property {
|
||||
sunset2rise: number;
|
||||
longtitude: string;
|
||||
latitude: string;
|
||||
brightness: number;
|
||||
schedule: Array<unknown>;
|
||||
}
|
||||
export interface FloodlightLightSettingsMotionT8425Property {
|
||||
brightness: number;
|
||||
enable: number;
|
||||
mode: number;
|
||||
time: number;
|
||||
}
|
||||
3
build/http/models.js
Normal file
3
build/http/models.js
Normal file
@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=models.js.map
|
||||
1
build/http/models.js.map
Normal file
1
build/http/models.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../src/http/models.ts"],"names":[],"mappings":""}
|
||||
5
build/http/parameter.d.ts
vendored
Normal file
5
build/http/parameter.d.ts
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
import { Category } from "typescript-logging-category-style";
|
||||
export declare class ParameterHelper {
|
||||
static readValue(serialNumber: string, type: number, value: string, log: Category): string | undefined;
|
||||
static writeValue(type: number, value: string): string;
|
||||
}
|
||||
103
build/http/parameter.js
Normal file
103
build/http/parameter.js
Normal file
@ -0,0 +1,103 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ParameterHelper = void 0;
|
||||
const types_1 = require("../p2p/types");
|
||||
const utils_1 = require("../p2p/utils");
|
||||
const utils_2 = require("../utils");
|
||||
const types_2 = require("./types");
|
||||
const utils_3 = require("./utils");
|
||||
const error_1 = require("../error");
|
||||
class ParameterHelper {
|
||||
static readValue(serialNumber, type, value, log) {
|
||||
if (value) {
|
||||
if (type === types_2.ParamType.SNOOZE_MODE ||
|
||||
type === types_2.ParamType.CAMERA_MOTION_ZONES ||
|
||||
type === types_1.CommandType.CMD_SET_DOORSENSOR_ALWAYS_OPEN_DELAY ||
|
||||
type === types_1.CommandType.CMD_SET_DOORSENSOR_ALWAYS_OPEN ||
|
||||
type === types_1.CommandType.ARM_DELAY_HOME ||
|
||||
type === types_1.CommandType.ARM_DELAY_AWAY ||
|
||||
type === types_1.CommandType.ARM_DELAY_CUS1 ||
|
||||
type === types_1.CommandType.ARM_DELAY_CUS2 ||
|
||||
type === types_1.CommandType.ARM_DELAY_CUS3 ||
|
||||
type === types_1.CommandType.ARM_DELAY_OFF ||
|
||||
type === types_1.CommandType.CELLULAR_INFO ||
|
||||
type === types_1.CommandType.CMD_WALL_LIGHT_SETTINGS_MANUAL_COLORED_LIGHTING ||
|
||||
type === types_1.CommandType.CMD_WALL_LIGHT_SETTINGS_SCHEDULE_COLORED_LIGHTING ||
|
||||
type === types_1.CommandType.CMD_WALL_LIGHT_SETTINGS_MANUAL_COLORED_LIGHTING ||
|
||||
type === types_1.CommandType.CMD_WALL_LIGHT_SETTINGS_COLORED_LIGHTING_COLORS ||
|
||||
type === types_1.CommandType.CMD_WALL_LIGHT_SETTINGS_DYNAMIC_LIGHTING_THEMES ||
|
||||
type === types_1.CommandType.CMD_INDOOR_DET_SET_ACTIVE_ZONE ||
|
||||
type === types_1.CommandType.CMD_SET_PRIVACYPARAM ||
|
||||
type === types_1.CommandType.CMD_BAT_DOORBELL_VIDEO_QUALITY2 ||
|
||||
type === types_1.CommandType.CMD_BAT_DOORBELL_RECORD_QUALITY2 ||
|
||||
type === types_1.CommandType.CMD_SET_CROSS_TRACKING_CAMERA_LIST ||
|
||||
type === types_1.CommandType.CMD_SET_CROSS_TRACKING_GROUP_LIST ||
|
||||
type === types_1.CommandType.CMD_FLOODLIGHT_SET_DETECTION_RANGE_T8425 ||
|
||||
type === types_1.CommandType.CMD_SET_LIGHT_CTRL_BRIGHT_PIR_T8425 ||
|
||||
type === types_1.CommandType.CMD_SET_LIGHT_CTRL_BRIGHT_SCH_T8425) {
|
||||
if (typeof value === "string") {
|
||||
const parsedValue = (0, utils_2.parseJSON)((0, utils_1.getNullTerminatedString)((0, utils_1.decodeBase64)(value), "utf-8"), log);
|
||||
if (parsedValue === undefined) {
|
||||
log.debug("Non-parsable parameter value received from eufy cloud. Will be ignored.", { serialNumber: serialNumber, type: type, value: value });
|
||||
}
|
||||
return parsedValue;
|
||||
}
|
||||
else {
|
||||
return value; //return object
|
||||
}
|
||||
}
|
||||
else if (type === types_1.CommandType.CMD_BAT_DOORBELL_SET_NOTIFICATION_MODE ||
|
||||
type === types_1.CommandType.CMD_DOORBELL_DUAL_RADAR_WD_DETECTION_SENSITIVITY ||
|
||||
type === types_1.CommandType.CMD_DOORBELL_DUAL_RADAR_WD_AUTO_RESPONSE ||
|
||||
type === types_1.CommandType.CMD_DOORBELL_DUAL_PACKAGE_STRAND_TIME ||
|
||||
type === types_1.CommandType.CMD_DOORBELL_DUAL_RING_AUTO_RESPONSE ||
|
||||
type === types_1.CommandType.CMD_DOORBELL_DUAL_PACKAGE_GUARD_TIME ||
|
||||
type === types_1.CommandType.CMD_DOORBELL_DUAL_RADAR_WD_DISTANCE ||
|
||||
type === types_1.CommandType.CMD_DOORBELL_DUAL_RADAR_WD_TIME ||
|
||||
type === types_1.CommandType.CMD_DOORBELL_DUAL_DELIVERY_GUARD_SWITCH ||
|
||||
type === types_1.CommandType.CMD_DOORBELL_DUAL_PACKAGE_GUARD_VOICE ||
|
||||
type === types_1.CommandType.CMD_CAMERA_GARAGE_DOOR_SENSORS ||
|
||||
type === types_1.CommandType.CMD_MOTION_SET_LEAVING_REACTIONS) {
|
||||
if (typeof value === "string") {
|
||||
const parsedValue = (0, utils_2.parseJSON)(value, log);
|
||||
if (parsedValue === undefined) {
|
||||
log.debug("Non-parsable parameter value received from eufy cloud. Will be ignored.", { serialNumber: serialNumber, type: type, value: value });
|
||||
}
|
||||
return parsedValue;
|
||||
}
|
||||
else {
|
||||
return value; //return object
|
||||
}
|
||||
}
|
||||
else if (type === types_1.TrackerCommandType.COMMAND_NEW_LOCATION ||
|
||||
type === types_1.TrackerCommandType.LOCATION_NEW_ADDRESS) {
|
||||
try {
|
||||
const decrypted = (0, utils_3.decryptTrackerData)(Buffer.from(value, "hex"), Buffer.from(serialNumber));
|
||||
if (decrypted !== undefined) {
|
||||
return decrypted.toString("utf8").trim();
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
const error = (0, error_1.ensureError)(err);
|
||||
log.debug("Non-parsable parameter value received from eufy cloud. Will be ignored.", { serialNumber: serialNumber, type: type, value: value, error: (0, utils_2.getError)(error) });
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
static writeValue(type, value) {
|
||||
if (value) {
|
||||
if (type === types_2.ParamType.SNOOZE_MODE ||
|
||||
type === types_2.ParamType.CAMERA_MOTION_ZONES ||
|
||||
type === types_1.CommandType.CMD_SET_DOORSENSOR_ALWAYS_OPEN_DELAY ||
|
||||
type === types_1.CommandType.CMD_SET_DOORSENSOR_ALWAYS_OPEN) {
|
||||
return Buffer.from(JSON.stringify(value)).toString("base64");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
exports.ParameterHelper = ParameterHelper;
|
||||
//# sourceMappingURL=parameter.js.map
|
||||
1
build/http/parameter.js.map
Normal file
1
build/http/parameter.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"parameter.js","sourceRoot":"","sources":["../../src/http/parameter.ts"],"names":[],"mappings":"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"}
|
||||
364
build/http/station.d.ts
vendored
Normal file
364
build/http/station.d.ts
vendored
Normal file
@ -0,0 +1,364 @@
|
||||
import { TypedEmitter } from "tiny-typed-emitter";
|
||||
import { HTTPApi } from "./api";
|
||||
import { AlarmTone, NotificationSwitchMode, DeviceType, FloodlightMotionTriggeredDistance, GuardMode, NotificationType, PowerSource, PropertyName, TimeFormat, CommandName, VideoTypeStoreToNAS, HB3DetectionTypes, WalllightNotificationType, DailyLightingType, MotionActivationMode, LightingActiveMode, SourceType, T8170DetectionTypes, IndoorS350NotificationTypes, SoloCameraDetectionTypes, MotionDetectionRangeType, ViewModeType, FloodlightT8425NotificationTypes, PresetPositionType, IndoorS350DetectionTypes } from "./types";
|
||||
import { SnoozeDetail, StationListResponse } from "./models";
|
||||
import { IndexedProperty, PropertyMetadataAny, PropertyValue, PropertyValues, RawValues, StationEvents, Schedule } from "./interfaces";
|
||||
import { CrossTrackingGroupEntry, DynamicLighting, MotionZone, RGBColor } from "../p2p/interfaces";
|
||||
import { CalibrateGarageType, FilterDetectType, FilterEventType, FilterStorageType, P2PConnectionType, PanTiltDirection, VideoCodec, WatermarkSetting1, WatermarkSetting2, WatermarkSetting3, WatermarkSetting4, WatermarkSetting5 } from "../p2p/types";
|
||||
import { Device } from "./device";
|
||||
import { PushMessage } from "../push/models";
|
||||
export declare class Station extends TypedEmitter<StationEvents> {
|
||||
private api;
|
||||
private rawStation;
|
||||
private p2pSession;
|
||||
private properties;
|
||||
private rawProperties;
|
||||
private ready;
|
||||
private lockPublicKey;
|
||||
private currentDelay;
|
||||
private reconnectTimeout?;
|
||||
private terminating;
|
||||
private p2pConnectionType;
|
||||
static readonly CHANNEL: number;
|
||||
static readonly CHANNEL_INDOOR: number;
|
||||
private pinVerified;
|
||||
protected constructor(api: HTTPApi, station: StationListResponse, ipAddress?: string, listeningPort?: number, publicKey?: string, enableEmbeddedPKCS1Support?: boolean);
|
||||
protected initializeState(): void;
|
||||
initialize(): void;
|
||||
static getInstance(api: HTTPApi, stationData: StationListResponse, ipAddress?: string, listeningPort?: number, enableEmbeddedPKCS1Support?: boolean): Promise<Station>;
|
||||
getStateID(state: string, level?: number): string;
|
||||
getStateChannel(): string;
|
||||
getRawStation(): StationListResponse;
|
||||
update(station: StationListResponse): void;
|
||||
updateProperty(name: string, value: PropertyValue, force?: boolean): boolean;
|
||||
updateRawProperties(values: RawValues): void;
|
||||
protected handlePropertyChange(metadata: PropertyMetadataAny, oldValue: PropertyValue, newValue: PropertyValue): void;
|
||||
updateRawProperty(type: number, value: string, source: SourceType): boolean;
|
||||
protected convertRawPropertyValue(property: PropertyMetadataAny, value: string): PropertyValue;
|
||||
getPropertyMetadata(name: string, hidden?: boolean): PropertyMetadataAny;
|
||||
getPropertyValue(name: string): PropertyValue;
|
||||
hasPropertyValue(name: string): boolean;
|
||||
getRawProperty(type: number): string | undefined;
|
||||
getRawProperties(): RawValues;
|
||||
getProperties(): PropertyValues;
|
||||
getPropertiesMetadata(hidden?: boolean): IndexedProperty;
|
||||
hasProperty(name: string, hidden?: boolean): boolean;
|
||||
getCommands(): Array<CommandName>;
|
||||
hasCommand(name: CommandName): boolean;
|
||||
static getChannel(type: number): number;
|
||||
static isStation(type: number): boolean;
|
||||
isStation(): boolean;
|
||||
static isStationHomeBase3(type: number): boolean;
|
||||
static isStationHomeBase3BySn(sn: string): boolean;
|
||||
isStationHomeBase3(): boolean;
|
||||
isIntegratedDevice(): boolean;
|
||||
isP2PConnectableDevice(): boolean;
|
||||
getDeviceType(): number;
|
||||
getHardwareVersion(): string;
|
||||
getMACAddress(): string;
|
||||
getModel(): string;
|
||||
getName(): string;
|
||||
getSerial(): string;
|
||||
getSoftwareVersion(): string;
|
||||
getIPAddress(): string;
|
||||
getLANIPAddress(): PropertyValue;
|
||||
getGuardMode(): PropertyValue;
|
||||
getCurrentMode(): PropertyValue;
|
||||
processPushNotification(message: PushMessage): void;
|
||||
isConnected(): boolean;
|
||||
close(): void;
|
||||
isEnergySavingDevice(): boolean;
|
||||
connect(): Promise<void>;
|
||||
private onFinishDownload;
|
||||
private onStartDownload;
|
||||
private onStopLivestream;
|
||||
private onErrorLivestream;
|
||||
private onStartLivestream;
|
||||
private onStopRTSPLivestream;
|
||||
private onStartRTSPLivestream;
|
||||
private onWifiRssiChanged;
|
||||
private onRTSPUrl;
|
||||
private onParameter;
|
||||
private onAlarmDelay;
|
||||
private onAlarmArmed;
|
||||
private onAlarmEvent;
|
||||
setGuardMode(mode: GuardMode): void;
|
||||
getCameraInfo(): void;
|
||||
getStorageInfoEx(): void;
|
||||
private onAlarmMode;
|
||||
private getArmDelay;
|
||||
private _getDeviceSerial;
|
||||
private _handleCameraInfoParameters;
|
||||
private onCameraInfo;
|
||||
private onCommandResponse;
|
||||
private onSecondaryCommandResponse;
|
||||
private onConnect;
|
||||
private onDisconnect;
|
||||
private onTimeout;
|
||||
private getCurrentDelay;
|
||||
private resetCurrentDelay;
|
||||
private scheduleReconnect;
|
||||
rebootHUB(): void;
|
||||
setStatusLed(device: Device, value: boolean): void;
|
||||
setAutoNightVision(device: Device, value: boolean): void;
|
||||
setNightVision(device: Device, value: number): void;
|
||||
setMotionDetection(device: Device, value: boolean): void;
|
||||
setSoundDetection(device: Device, value: boolean): void;
|
||||
setSoundDetectionType(device: Device, value: number): void;
|
||||
setSoundDetectionSensitivity(device: Device, value: number): void;
|
||||
setPetDetection(device: Device, value: boolean): void;
|
||||
panAndTilt(device: Device, direction: PanTiltDirection, command?: number): void;
|
||||
switchLight(device: Device, value: boolean): void;
|
||||
setMotionDetectionSensitivity(device: Device, value: number): void;
|
||||
setMotionDetectionType(device: Device, value: number): void;
|
||||
setMotionDetectionTypeHB3(device: Device, type: HB3DetectionTypes | T8170DetectionTypes | SoloCameraDetectionTypes | IndoorS350DetectionTypes, value: boolean): void;
|
||||
setMotionZone(device: Device, value: MotionZone): void;
|
||||
setMotionTracking(device: Device, value: boolean): void;
|
||||
setPanAndTiltRotationSpeed(device: Device, value: number): void;
|
||||
setMicMute(device: Device, value: boolean): void;
|
||||
setAudioRecording(device: Device, value: boolean): void;
|
||||
enableSpeaker(device: Device, value: boolean): void;
|
||||
setSpeakerVolume(device: Device, value: number): void;
|
||||
setRingtoneVolume(device: Device, value: number): void;
|
||||
enableIndoorChime(device: Device, value: boolean): void;
|
||||
enableHomebaseChime(device: Device, value: boolean): void;
|
||||
setHomebaseChimeRingtoneVolume(device: Device, value: number): void;
|
||||
setHomebaseChimeRingtoneType(device: Device, value: number): void;
|
||||
setNotificationType(device: Device, value: NotificationType | WalllightNotificationType): void;
|
||||
setNotificationPerson(device: Device, value: boolean): void;
|
||||
setNotificationPet(device: Device, value: boolean): void;
|
||||
setNotificationAllOtherMotion(device: Device, value: boolean): void;
|
||||
setNotificationAllSound(device: Device, value: boolean): void;
|
||||
setNotificationCrying(device: Device, value: boolean): void;
|
||||
setNotificationRing(device: Device, value: boolean): void;
|
||||
setNotificationMotion(device: Device, value: boolean): void;
|
||||
setPowerSource(device: Device, value: PowerSource): void;
|
||||
setPowerWorkingMode(device: Device, value: number): void;
|
||||
setRecordingClipLength(device: Device, value: number): void;
|
||||
setRecordingRetriggerInterval(device: Device, value: number): void;
|
||||
setRecordingEndClipMotionStops(device: Device, value: boolean): void;
|
||||
setVideoStreamingQuality(device: Device, value: number): void;
|
||||
setVideoRecordingQuality(device: Device, value: number): void;
|
||||
setWDR(device: Device, value: boolean): void;
|
||||
setFloodlightLightSettingsEnable(device: Device, value: boolean): void;
|
||||
setFloodlightLightSettingsBrightnessManual(device: Device, value: number): void;
|
||||
setFloodlightLightSettingsBrightnessMotion(device: Device, value: number): void;
|
||||
setFloodlightLightSettingsBrightnessSchedule(device: Device, value: number): void;
|
||||
setFloodlightLightSettingsMotionTriggered(device: Device, value: boolean): void;
|
||||
setFloodlightLightSettingsMotionTriggeredDistance(device: Device, value: FloodlightMotionTriggeredDistance): void;
|
||||
setFloodlightLightSettingsMotionTriggeredTimer(device: Device, seconds: number): void;
|
||||
triggerStationAlarmSound(seconds: number): void;
|
||||
resetStationAlarmSound(): void;
|
||||
triggerDeviceAlarmSound(device: Device, seconds: number): void;
|
||||
resetDeviceAlarmSound(device: Device): void;
|
||||
setStationAlarmRingtoneVolume(value: number): void;
|
||||
setStationAlarmTone(value: AlarmTone): void;
|
||||
setStationPromptVolume(value: number): void;
|
||||
setStationNotificationSwitchMode(mode: NotificationSwitchMode, value: boolean): void;
|
||||
setStationNotificationStartAlarmDelay(value: boolean): void;
|
||||
setStationTimeFormat(value: TimeFormat): void;
|
||||
setRTSPStream(device: Device, value: boolean): void;
|
||||
setAntiTheftDetection(device: Device, value: boolean): void;
|
||||
setWatermark(device: Device, value: WatermarkSetting1 | WatermarkSetting2 | WatermarkSetting3 | WatermarkSetting4 | WatermarkSetting5): void;
|
||||
enableDevice(device: Device, value: boolean): void;
|
||||
startDownload(device: Device, path: string, cipher_id?: number): Promise<void>;
|
||||
cancelDownload(device: Device): void;
|
||||
startLivestream(device: Device, videoCodec?: VideoCodec): void;
|
||||
stopLivestream(device: Device): void;
|
||||
isLiveStreaming(device: Device): boolean;
|
||||
isDownloading(device: Device): boolean;
|
||||
quickResponse(device: Device, voice_id: number): void;
|
||||
setChirpVolume(device: Device, value: number): void;
|
||||
setChirpTone(device: Device, value: number): void;
|
||||
setHDR(device: Device, value: boolean): void;
|
||||
setDistortionCorrection(device: Device, value: boolean): void;
|
||||
setRingRecord(device: Device, value: number): void;
|
||||
lockDevice(device: Device, value: boolean): void;
|
||||
setStationSwitchModeWithAccessCode(value: boolean): void;
|
||||
setStationAutoEndAlarm(value: boolean): void;
|
||||
setStationTurnOffAlarmWithButton(value: boolean): void;
|
||||
startRTSPStream(device: Device): void;
|
||||
stopRTSPStream(device: Device): void;
|
||||
setMotionDetectionRange(device: Device, type: MotionDetectionRangeType): void;
|
||||
setMotionDetectionRangeStandardSensitivity(device: Device, sensitivity: number): void;
|
||||
setMotionDetectionRangeAdvancedLeftSensitivity(device: Device, sensitivity: number): void;
|
||||
setMotionDetectionRangeAdvancedMiddleSensitivity(device: Device, sensitivity: number): void;
|
||||
setMotionDetectionRangeAdvancedRightSensitivity(device: Device, sensitivity: number): void;
|
||||
setMotionDetectionTestMode(device: Device, enabled: boolean): void;
|
||||
setMotionTrackingSensitivity(device: Device, sensitivity: number): void;
|
||||
setMotionAutoCruise(device: Device, enabled: boolean): void;
|
||||
setMotionOutOfViewDetection(device: Device, enabled: boolean): void;
|
||||
setLightSettingsColorTemperatureManual(device: Device, value: number): void;
|
||||
setLightSettingsColorTemperatureMotion(device: Device, value: number): void;
|
||||
setLightSettingsColorTemperatureSchedule(device: Device, value: number): void;
|
||||
setLightSettingsMotionActivationMode(device: Device, value: MotionActivationMode): void;
|
||||
setVideoNightvisionImageAdjustment(device: Device, enabled: boolean): void;
|
||||
setVideoColorNightvision(device: Device, enabled: boolean): void;
|
||||
setAutoCalibration(device: Device, enabled: boolean): void;
|
||||
isRTSPLiveStreaming(device: Device): boolean;
|
||||
setConnectionType(type: P2PConnectionType): void;
|
||||
getConnectionType(): P2PConnectionType;
|
||||
private onRuntimeState;
|
||||
private onChargingState;
|
||||
hasDevice(deviceSN: string): boolean;
|
||||
hasDeviceWithType(deviceType: DeviceType): boolean;
|
||||
private onFloodlightManualSwitch;
|
||||
calibrateLock(device: Device): void;
|
||||
private convertAdvancedLockSettingValue;
|
||||
private convertAdvancedLockSettingValueT8530;
|
||||
private getAdvancedLockSettingsPayload;
|
||||
private getAdvancedLockSettingsPayloadT8530;
|
||||
private getAdvancedLockSettingName;
|
||||
private getAdvancedLockSettingNameT8530;
|
||||
setAdvancedLockParams(device: Device, property: PropertyName, value: PropertyValue): void;
|
||||
setLoiteringDetection(device: Device, value: boolean): void;
|
||||
setLoiteringDetectionRange(device: Device, value: number): void;
|
||||
setLoiteringDetectionLength(device: Device, value: number): void;
|
||||
private _setMotionDetectionSensitivity;
|
||||
private _getMotionDetectionSensitivityAdvanced;
|
||||
setMotionDetectionSensitivityMode(device: Device, value: number): void;
|
||||
setMotionDetectionSensitivityStandard(device: Device, value: number): void;
|
||||
setMotionDetectionSensitivityAdvancedA(device: Device, value: number): void;
|
||||
setMotionDetectionSensitivityAdvancedB(device: Device, value: number): void;
|
||||
setMotionDetectionSensitivityAdvancedC(device: Device, value: number): void;
|
||||
setMotionDetectionSensitivityAdvancedD(device: Device, value: number): void;
|
||||
setMotionDetectionSensitivityAdvancedE(device: Device, value: number): void;
|
||||
setMotionDetectionSensitivityAdvancedF(device: Device, value: number): void;
|
||||
setMotionDetectionSensitivityAdvancedG(device: Device, value: number): void;
|
||||
setMotionDetectionSensitivityAdvancedH(device: Device, value: number): void;
|
||||
private _setLoiteringCustomResponse;
|
||||
setLoiteringCustomResponseAutoVoiceResponse(device: Device, value: boolean): void;
|
||||
setLoiteringCustomResponseAutoVoiceResponseVoice(device: Device, value: number): void;
|
||||
setLoiteringCustomResponseHomeBaseNotification(device: Device, value: boolean): void;
|
||||
setLoiteringCustomResponsePhoneNotification(device: Device, value: boolean): void;
|
||||
setLoiteringCustomResponseTimeFrom(device: Device, value: string): void;
|
||||
setLoiteringCustomResponseTimeTo(device: Device, value: string): void;
|
||||
setDeliveryGuard(device: Device, value: boolean): void;
|
||||
setDeliveryGuardPackageGuarding(device: Device, value: boolean): void;
|
||||
setDeliveryGuardPackageGuardingVoiceResponseVoice(device: Device, value: number): void;
|
||||
private setDeliveryGuardPackageGuardingActivatedTime;
|
||||
setDeliveryGuardPackageGuardingActivatedTimeFrom(device: Device, value: string): void;
|
||||
setDeliveryGuardPackageGuardingActivatedTimeTo(device: Device, value: string): void;
|
||||
setDeliveryGuardUncollectedPackageAlert(device: Device, value: boolean): void;
|
||||
setDeliveryGuardUncollectedPackageAlertTimeToCheck(device: Device, value: string): void;
|
||||
setDeliveryGuardPackageLiveCheckAssistance(device: Device, value: boolean): void;
|
||||
setDualCamWatchViewMode(device: Device, value: ViewModeType): void;
|
||||
private _setRingAutoResponse;
|
||||
setRingAutoResponse(device: Device, value: boolean): void;
|
||||
setRingAutoResponseVoiceResponse(device: Device, value: boolean): void;
|
||||
setRingAutoResponseVoiceResponseVoice(device: Device, value: number): void;
|
||||
setRingAutoResponseTimeFrom(device: Device, value: string): void;
|
||||
setRingAutoResponseTimeTo(device: Device, value: string): void;
|
||||
setNotificationRadarDetector(device: Device, value: boolean): void;
|
||||
calibrate(device: Device): void;
|
||||
setContinuousRecording(device: Device, value: boolean): void;
|
||||
setContinuousRecordingType(device: Device, value: number): void;
|
||||
enableDefaultAngle(device: Device, value: boolean): void;
|
||||
setDefaultAngleIdleTime(device: Device, value: number): void;
|
||||
setDefaultAngle(device: Device): void;
|
||||
setPrivacyAngle(device: Device): void;
|
||||
setNotificationIntervalTime(device: Device, value: number): void;
|
||||
setSoundDetectionRoundLook(device: Device, value: boolean): void;
|
||||
startTalkback(device: Device): void;
|
||||
stopTalkback(device: Device): void;
|
||||
private onTalkbackStarted;
|
||||
private onTalkbackStopped;
|
||||
private onTalkbackError;
|
||||
isTalkbackOngoing(device: Device): boolean;
|
||||
setScramblePasscode(device: Device, value: boolean): void;
|
||||
setWrongTryProtection(device: Device, value: boolean): void;
|
||||
setWrongTryAttempts(device: Device, value: number): void;
|
||||
setWrongTryLockdownTime(device: Device, value: number): void;
|
||||
private _sendSmartSafeCommand;
|
||||
setSmartSafeParams(device: Device, property: PropertyName, value: PropertyValue): void;
|
||||
unlock(device: Device): void;
|
||||
verifyPIN(device: Device, pin: string): void;
|
||||
private onDeviceShakeAlarm;
|
||||
private onDevice911Alarm;
|
||||
private onDeviceJammed;
|
||||
private onDeviceLowBattery;
|
||||
private onDeviceWrongTryProtectAlarm;
|
||||
private onSdInfoEx;
|
||||
setVideoTypeStoreToNAS(device: Device, value: VideoTypeStoreToNAS): void;
|
||||
snooze(device: Device, value: SnoozeDetail): void;
|
||||
addUser(device: Device, username: string, shortUserId: string, passcode: string, schedule?: Schedule): void;
|
||||
deleteUser(device: Device, username: string, shortUserId: string): void;
|
||||
updateUserSchedule(device: Device, username: string, shortUserId: string, schedule: Schedule): void;
|
||||
updateUserPasscode(device: Device, username: string, passwordId: string, passcode: string): void;
|
||||
setLockV12Params(device: Device, property: PropertyName, value: PropertyValue): void;
|
||||
setSmartLockParams(device: Device, property: PropertyName, value: PropertyValue): void;
|
||||
setAutoLock(device: Device, value: boolean): void;
|
||||
setAutoLockSchedule(device: Device, value: boolean): void;
|
||||
setAutoLockScheduleStartTime(device: Device, value: string): void;
|
||||
setAutoLockScheduleEndTime(device: Device, value: string): void;
|
||||
setAutoLockTimer(device: Device, value: number): void;
|
||||
setOneTouchLocking(device: Device, value: boolean): void;
|
||||
setSound(device: Device, value: number): void;
|
||||
setNotification(device: Device, value: boolean): void;
|
||||
setNotificationLocked(device: Device, value: boolean): void;
|
||||
setNotificationUnlocked(device: Device, value: boolean): void;
|
||||
private _sendLockV12P2PCommand;
|
||||
queryAllUserId(device: Device): void;
|
||||
chimeHomebase(value: number): void;
|
||||
private onImageDownload;
|
||||
downloadImage(cover_path: string): void;
|
||||
private onTFCardStatus;
|
||||
databaseQueryLatestInfo(failureCallback?: () => void): void;
|
||||
databaseQueryLocal(serialNumbers: Array<string>, startDate: Date, endDate: Date, eventType?: FilterEventType, detectionType?: FilterDetectType, storageType?: FilterStorageType): void;
|
||||
databaseDelete(ids: Array<number>): void;
|
||||
databaseCountByDate(startDate: Date, endDate: Date): void;
|
||||
private onDatabaseQueryLatest;
|
||||
private onDatabaseQueryLocal;
|
||||
private onDatabaseCountByDate;
|
||||
private onDatabaseDelete;
|
||||
private onSensorStatus;
|
||||
setMotionDetectionTypeHuman(device: Device, value: boolean): void;
|
||||
setMotionDetectionTypeAllOtherMotions(device: Device, value: boolean): void;
|
||||
private _setLightSettingsLightingActiveMode;
|
||||
setLightSettingsManualLightingActiveMode(device: Device, value: LightingActiveMode): void;
|
||||
setLightSettingsManualDailyLighting(device: Device, value: DailyLightingType): void;
|
||||
setLightSettingsManualColoredLighting(device: Device, value: RGBColor): void;
|
||||
setLightSettingsManualDynamicLighting(device: Device, value: number): void;
|
||||
setLightSettingsMotionLightingActiveMode(device: Device, value: LightingActiveMode): void;
|
||||
setLightSettingsMotionDailyLighting(device: Device, value: DailyLightingType): void;
|
||||
setLightSettingsMotionColoredLighting(device: Device, value: RGBColor): void;
|
||||
setLightSettingsMotionDynamicLighting(device: Device, value: number): void;
|
||||
setLightSettingsScheduleLightingActiveMode(device: Device, value: LightingActiveMode): void;
|
||||
setLightSettingsScheduleDailyLighting(device: Device, value: DailyLightingType): void;
|
||||
setLightSettingsScheduleColoredLighting(device: Device, value: RGBColor): void;
|
||||
setLightSettingsScheduleDynamicLighting(device: Device, value: number): void;
|
||||
setLightSettingsColoredLightingColors(device: Device, value: Array<RGBColor>): void;
|
||||
setLightSettingsDynamicLightingThemes(device: Device, value: Array<DynamicLighting>): void;
|
||||
setDoorControlWarning(device: Device, value: boolean): void;
|
||||
openDoor(device: Device, value: boolean, doorId?: number): void;
|
||||
private onGarageDoorStatus;
|
||||
calibrateGarageDoor(device: Device, doorId: number, type: CalibrateGarageType): void;
|
||||
private onStorageInfoHB3;
|
||||
setMirrorMode(device: Device, value: boolean): void;
|
||||
setFlickerAdjustment(device: Device, value: number): void;
|
||||
setCrossCameraTracking(value: boolean): void;
|
||||
setContinuousTrackingTime(value: number): void;
|
||||
setTrackingAssistance(value: boolean): void;
|
||||
setCrossTrackingCameraList(value: Array<string>): void;
|
||||
setCrossTrackingGroupList(value: Array<CrossTrackingGroupEntry>): void;
|
||||
setNotificationIndoor(device: Device, type: IndoorS350NotificationTypes, value: boolean): void;
|
||||
setNotificationFloodlightT8425(device: Device, type: FloodlightT8425NotificationTypes, value: boolean): void;
|
||||
presetPosition(device: Device, position: PresetPositionType): void;
|
||||
savePresetPosition(device: Device, position: PresetPositionType): void;
|
||||
deletePresetPosition(device: Device, position: PresetPositionType): void;
|
||||
setLeavingDetection(device: Device, value: boolean): void;
|
||||
private _setLeavingReactions;
|
||||
setLeavingReactionNotification(device: Device, value: boolean): void;
|
||||
setLeavingReactionStartTime(device: Device, value: string): void;
|
||||
setLeavingReactionEndTime(device: Device, value: string): void;
|
||||
setBeepVolume(device: Device, value: number): void;
|
||||
setNightvisionOptimization(device: Device, value: boolean): void;
|
||||
setNightvisionOptimizationSide(device: Device, value: number): void;
|
||||
getLockParameters(): void;
|
||||
getLockStatus(): void;
|
||||
private onSequenceError;
|
||||
updateUsername(device: Device, username: string, passwordId: string): void;
|
||||
setOpenMethod(device: Device, value: number): void;
|
||||
setMotionActivatedPrompt(device: Device, value: boolean): void;
|
||||
open(device: Device): void;
|
||||
}
|
||||
10561
build/http/station.js
Normal file
10561
build/http/station.js
Normal file
File diff suppressed because it is too large
Load Diff
1
build/http/station.js.map
Normal file
1
build/http/station.js.map
Normal file
File diff suppressed because one or more lines are too long
1333
build/http/types.d.ts
vendored
Normal file
1333
build/http/types.d.ts
vendored
Normal file
File diff suppressed because it is too large
Load Diff
9684
build/http/types.js
Normal file
9684
build/http/types.js
Normal file
File diff suppressed because it is too large
Load Diff
1
build/http/types.js.map
Normal file
1
build/http/types.js.map
Normal file
File diff suppressed because one or more lines are too long
79
build/http/utils.d.ts
vendored
Normal file
79
build/http/utils.d.ts
vendored
Normal file
@ -0,0 +1,79 @@
|
||||
import { Device } from "./device";
|
||||
import { Picture, Schedule } from "./interfaces";
|
||||
import { NotificationSwitchMode, SignalLevel, HB3DetectionTypes, SourceType, T8170DetectionTypes, IndoorS350NotificationTypes, FloodlightT8425NotificationTypes, SmartLockNotification, IndoorS350DetectionTypes } from "./types";
|
||||
import { HTTPApi } from "./api";
|
||||
import { LockPushEvent } from "./../push/types";
|
||||
import { Station } from "./station";
|
||||
import { PushMessage } from "../push/models";
|
||||
export declare const isGreaterEqualMinVersion: (minimal_version: string, current_version: string) => boolean;
|
||||
export declare const pad: (num: number) => string;
|
||||
export declare const getTimezoneGMTString: () => string;
|
||||
export declare const getAbsoluteFilePath: (device_type: number, channel: number, filename: string) => string;
|
||||
export declare const getImageFilePath: (device_type: number, channel: number, filename: string) => string;
|
||||
export declare const isNotificationSwitchMode: (value: number, mode: NotificationSwitchMode) => boolean;
|
||||
export declare const switchNotificationMode: (currentValue: number, mode: NotificationSwitchMode, enable: boolean) => number;
|
||||
export declare const calculateWifiSignalLevel: (device: Device, rssi: number) => SignalLevel;
|
||||
export declare const calculateCellularSignalLevel: (rssi: number) => SignalLevel;
|
||||
export declare const encryptAPIData: (data: string, key: Buffer) => string;
|
||||
export declare const decryptAPIData: (data: string, key: Buffer) => Buffer;
|
||||
export declare const getBlocklist: (directions: Array<number>) => Array<number>;
|
||||
export declare const getDistances: (blocklist: Array<number>) => Array<number>;
|
||||
export declare const isHB3DetectionModeEnabled: (value: number, type: HB3DetectionTypes) => boolean;
|
||||
export declare const getHB3DetectionMode: (value: number, type: HB3DetectionTypes, enable: boolean) => number;
|
||||
export interface EufyTimezone {
|
||||
timeZoneName: string;
|
||||
timeId: string;
|
||||
timeSn: string;
|
||||
timeZoneGMT: string;
|
||||
}
|
||||
export declare const getEufyTimezone: () => EufyTimezone | undefined;
|
||||
export declare const getAdvancedLockTimezone: (stationSN: string) => string;
|
||||
export declare class WritePayload {
|
||||
private split_byte;
|
||||
private data;
|
||||
write(bytes: Buffer): void;
|
||||
getData(): Buffer;
|
||||
}
|
||||
export declare class ParsePayload {
|
||||
private data;
|
||||
constructor(data: Buffer);
|
||||
readUint32BE(indexValue: number): number;
|
||||
readUint32LE(indexValue: number): number;
|
||||
readUint16BE(indexValue: number): number;
|
||||
readUint16LE(indexValue: number): number;
|
||||
readString(indexValue: number): string;
|
||||
readStringHex(indexValue: number): string;
|
||||
readInt8(indexValue: number): number;
|
||||
readData(indexValue: number): Buffer;
|
||||
private getDataPosition;
|
||||
private getNextStep;
|
||||
}
|
||||
export declare const encodePasscode: (pass: string) => string;
|
||||
export declare const hexDate: (date: Date) => string;
|
||||
export declare const hexTime: (date: Date) => string;
|
||||
export declare const hexWeek: (schedule: Schedule) => string;
|
||||
export declare const hexStringScheduleToSchedule: (startDay: string, startTime: string, endDay: string, endTime: string, week: string) => Schedule;
|
||||
export declare const randomNumber: (min: number, max: number) => number;
|
||||
export declare const getIdSuffix: (p2pDid: string) => number;
|
||||
export declare const getImageBaseCode: (serialnumber: string, p2pDid: string) => string;
|
||||
export declare const getImageSeed: (p2pDid: string, code: string) => string;
|
||||
export declare const getImageKey: (serialnumber: string, p2pDid: string, code: string) => string;
|
||||
export declare const decodeImage: (p2pDid: string, data: Buffer) => Buffer;
|
||||
export declare const getImagePath: (path: string) => string;
|
||||
export declare const getImage: (api: HTTPApi, serial: string, url: string) => Promise<Picture>;
|
||||
export declare const isPrioritySourceType: (current: SourceType | undefined, update: SourceType) => boolean;
|
||||
export declare const decryptTrackerData: (data: Buffer, key: Buffer) => Buffer;
|
||||
export declare const isT8170DetectionModeEnabled: (value: number, type: T8170DetectionTypes) => boolean;
|
||||
export declare const getT8170DetectionMode: (value: number, type: T8170DetectionTypes, enable: boolean) => number;
|
||||
export declare const isIndoorS350DetectionModeEnabled: (value: number, type: IndoorS350DetectionTypes) => boolean;
|
||||
export declare const getIndoorS350DetectionMode: (value: number, type: IndoorS350DetectionTypes, enable: boolean) => number;
|
||||
export declare const isIndoorNotitficationEnabled: (value: number, type: IndoorS350NotificationTypes) => boolean;
|
||||
export declare const getIndoorNotification: (value: number, type: IndoorS350NotificationTypes, enable: boolean) => number;
|
||||
export declare const isFloodlightT8425NotitficationEnabled: (value: number, type: FloodlightT8425NotificationTypes) => boolean;
|
||||
export declare const getFloodLightT8425Notification: (value: number, type: FloodlightT8425NotificationTypes, enable: boolean) => number;
|
||||
export declare const getLockEventType: (event: LockPushEvent) => number;
|
||||
export declare const switchSmartLockNotification: (currentValue: number, mode: SmartLockNotification, enable: boolean) => number;
|
||||
export declare const isSmartLockNotification: (value: number, mode: SmartLockNotification) => boolean;
|
||||
export declare const getWaitSeconds: (device: Device) => number;
|
||||
export declare const loadImageOverP2P: (station: Station, device: Device, id: string, p2pTimeouts: Map<string, NodeJS.Timeout>) => void;
|
||||
export declare const loadEventImage: (station: Station, api: HTTPApi, device: Device, message: PushMessage, p2pTimeouts: Map<string, NodeJS.Timeout>) => void;
|
||||
789
build/http/utils.js
Normal file
789
build/http/utils.js
Normal file
@ -0,0 +1,789 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.loadEventImage = exports.loadImageOverP2P = exports.getWaitSeconds = exports.isSmartLockNotification = exports.switchSmartLockNotification = exports.getLockEventType = exports.getFloodLightT8425Notification = exports.isFloodlightT8425NotitficationEnabled = exports.getIndoorNotification = exports.isIndoorNotitficationEnabled = exports.getIndoorS350DetectionMode = exports.isIndoorS350DetectionModeEnabled = exports.getT8170DetectionMode = exports.isT8170DetectionModeEnabled = exports.decryptTrackerData = exports.isPrioritySourceType = exports.getImage = exports.getImagePath = exports.decodeImage = exports.getImageKey = exports.getImageSeed = exports.getImageBaseCode = exports.getIdSuffix = exports.randomNumber = exports.hexStringScheduleToSchedule = exports.hexWeek = exports.hexTime = exports.hexDate = exports.encodePasscode = exports.ParsePayload = exports.WritePayload = exports.getAdvancedLockTimezone = exports.getEufyTimezone = exports.getHB3DetectionMode = exports.isHB3DetectionModeEnabled = exports.getDistances = exports.getBlocklist = exports.decryptAPIData = exports.encryptAPIData = exports.calculateCellularSignalLevel = exports.calculateWifiSignalLevel = exports.switchNotificationMode = exports.isNotificationSwitchMode = exports.getImageFilePath = exports.getAbsoluteFilePath = exports.getTimezoneGMTString = exports.pad = exports.isGreaterEqualMinVersion = void 0;
|
||||
const crypto_1 = require("crypto");
|
||||
const const_1 = require("./const");
|
||||
const md5_1 = __importDefault(require("crypto-js/md5"));
|
||||
const enc_hex_1 = __importDefault(require("crypto-js/enc-hex"));
|
||||
const sha256_1 = __importDefault(require("crypto-js/sha256"));
|
||||
const types_1 = require("./types");
|
||||
const error_1 = require("../error");
|
||||
const error_2 = require("./error");
|
||||
const types_2 = require("./../push/types");
|
||||
const logging_1 = require("../logging");
|
||||
const utils_1 = require("../utils");
|
||||
const normalizeVersionString = function (version) {
|
||||
const trimmed = version ? version.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1") : "";
|
||||
const pieces = trimmed.split(RegExp("\\."));
|
||||
const parts = [];
|
||||
let value, piece, num, i;
|
||||
for (i = 0; i < pieces.length; i += 1) {
|
||||
piece = pieces[i].replace(RegExp("\\D"), "");
|
||||
num = parseInt(piece, 10);
|
||||
if (isNaN(num)) {
|
||||
num = 0;
|
||||
}
|
||||
parts.push(num);
|
||||
}
|
||||
const partsLength = parts.length;
|
||||
for (i = partsLength - 1; i >= 0; i -= 1) {
|
||||
value = parts[i];
|
||||
if (value === 0) {
|
||||
parts.length -= 1;
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return parts;
|
||||
};
|
||||
const isGreaterEqualMinVersion = function (minimal_version, current_version) {
|
||||
const x = normalizeVersionString(minimal_version);
|
||||
const y = normalizeVersionString(current_version);
|
||||
const size = Math.min(x.length, y.length);
|
||||
let i;
|
||||
for (i = 0; i < size; i += 1) {
|
||||
if (x[i] !== y[i]) {
|
||||
return x[i] < y[i] ? true : false;
|
||||
}
|
||||
}
|
||||
if (x.length === y.length) {
|
||||
return true;
|
||||
}
|
||||
return (x.length < y.length) ? true : false;
|
||||
};
|
||||
exports.isGreaterEqualMinVersion = isGreaterEqualMinVersion;
|
||||
const pad = function (num) {
|
||||
const norm = Math.floor(Math.abs(num));
|
||||
return (norm < 10 ? "0" : "") + norm;
|
||||
};
|
||||
exports.pad = pad;
|
||||
const getTimezoneGMTString = function () {
|
||||
const tzo = -new Date().getTimezoneOffset();
|
||||
const dif = tzo >= 0 ? "+" : "-";
|
||||
return `GMT${dif}${(0, exports.pad)(tzo / 60)}:${(0, exports.pad)(tzo % 60)}`;
|
||||
};
|
||||
exports.getTimezoneGMTString = getTimezoneGMTString;
|
||||
const getAbsoluteFilePath = function (device_type, channel, filename) {
|
||||
if (device_type === types_1.DeviceType.FLOODLIGHT) {
|
||||
return `/mnt/data/Camera${String(channel).padStart(2, "0")}/${filename}.dat`;
|
||||
}
|
||||
return `/media/mmcblk0p1/Camera${String(channel).padStart(2, "0")}/${filename}.dat`;
|
||||
};
|
||||
exports.getAbsoluteFilePath = getAbsoluteFilePath;
|
||||
const getImageFilePath = function (device_type, channel, filename) {
|
||||
if (device_type === types_1.DeviceType.FLOODLIGHT) {
|
||||
return `/mnt/data/video/${filename}_c${String(channel).padStart(2, "0")}.jpg`;
|
||||
}
|
||||
return `/media/mmcblk0p1/video/${filename}_c${String(channel).padStart(2, "0")}.jpg`;
|
||||
};
|
||||
exports.getImageFilePath = getImageFilePath;
|
||||
const isNotificationSwitchMode = function (value, mode) {
|
||||
if (value === 1)
|
||||
value = 240;
|
||||
return (value & mode) !== 0;
|
||||
};
|
||||
exports.isNotificationSwitchMode = isNotificationSwitchMode;
|
||||
const switchNotificationMode = function (currentValue, mode, enable) {
|
||||
let result = 0;
|
||||
if (!enable && currentValue === 1 /* ALL */) {
|
||||
currentValue = 240;
|
||||
}
|
||||
if (enable) {
|
||||
result = mode | currentValue;
|
||||
}
|
||||
else {
|
||||
result = ~mode & currentValue;
|
||||
}
|
||||
if ((0, exports.isNotificationSwitchMode)(result, types_1.NotificationSwitchMode.SCHEDULE) && (0, exports.isNotificationSwitchMode)(result, types_1.NotificationSwitchMode.APP) && (0, exports.isNotificationSwitchMode)(result, types_1.NotificationSwitchMode.GEOFENCE) && (0, exports.isNotificationSwitchMode)(result, types_1.NotificationSwitchMode.KEYPAD)) {
|
||||
result = 1; /* ALL */
|
||||
}
|
||||
return result;
|
||||
};
|
||||
exports.switchNotificationMode = switchNotificationMode;
|
||||
const calculateWifiSignalLevel = function (device, rssi) {
|
||||
if (device.isWiredDoorbell()) {
|
||||
if (rssi >= -65) {
|
||||
return types_1.SignalLevel.FULL;
|
||||
}
|
||||
if (rssi >= -75) {
|
||||
return types_1.SignalLevel.STRONG;
|
||||
}
|
||||
return rssi >= -80 ? types_1.SignalLevel.NORMAL : types_1.SignalLevel.WEAK;
|
||||
}
|
||||
else if (device.isCamera2Product()) {
|
||||
if (rssi >= 0) {
|
||||
return types_1.SignalLevel.NO_SIGNAL;
|
||||
}
|
||||
if (rssi >= -65) {
|
||||
return types_1.SignalLevel.FULL;
|
||||
}
|
||||
if (rssi >= -75) {
|
||||
return types_1.SignalLevel.STRONG;
|
||||
}
|
||||
return rssi >= -85 ? types_1.SignalLevel.NORMAL : types_1.SignalLevel.WEAK;
|
||||
}
|
||||
else if (device.isFloodLight()) {
|
||||
if (rssi >= 0) {
|
||||
return types_1.SignalLevel.NO_SIGNAL;
|
||||
}
|
||||
if (rssi >= -60) {
|
||||
return types_1.SignalLevel.FULL;
|
||||
}
|
||||
if (rssi >= -70) {
|
||||
return types_1.SignalLevel.STRONG;
|
||||
}
|
||||
return rssi >= -80 ? types_1.SignalLevel.NORMAL : types_1.SignalLevel.WEAK;
|
||||
}
|
||||
else if (device.isBatteryDoorbell()) {
|
||||
if (rssi >= -65) {
|
||||
return types_1.SignalLevel.FULL;
|
||||
}
|
||||
if (rssi >= -75) {
|
||||
return types_1.SignalLevel.STRONG;
|
||||
}
|
||||
return rssi >= -85 ? types_1.SignalLevel.NORMAL : types_1.SignalLevel.WEAK;
|
||||
}
|
||||
else {
|
||||
if (rssi >= 0) {
|
||||
return types_1.SignalLevel.NO_SIGNAL;
|
||||
}
|
||||
if (rssi >= -65) {
|
||||
return types_1.SignalLevel.FULL;
|
||||
}
|
||||
if (rssi >= -75) {
|
||||
return types_1.SignalLevel.STRONG;
|
||||
}
|
||||
return rssi >= -85 ? types_1.SignalLevel.NORMAL : types_1.SignalLevel.WEAK;
|
||||
}
|
||||
};
|
||||
exports.calculateWifiSignalLevel = calculateWifiSignalLevel;
|
||||
const calculateCellularSignalLevel = function (rssi) {
|
||||
if (rssi >= 0) {
|
||||
return types_1.SignalLevel.NO_SIGNAL;
|
||||
}
|
||||
if (rssi >= -90) {
|
||||
return types_1.SignalLevel.FULL;
|
||||
}
|
||||
if (rssi >= -95) {
|
||||
return types_1.SignalLevel.STRONG;
|
||||
}
|
||||
return rssi >= -105 ? types_1.SignalLevel.NORMAL : types_1.SignalLevel.WEAK;
|
||||
};
|
||||
exports.calculateCellularSignalLevel = calculateCellularSignalLevel;
|
||||
const encryptAPIData = (data, key) => {
|
||||
const cipher = (0, crypto_1.createCipheriv)("aes-256-cbc", key, key.subarray(0, 16));
|
||||
return (cipher.update(data, "utf8", "base64") +
|
||||
cipher.final("base64"));
|
||||
};
|
||||
exports.encryptAPIData = encryptAPIData;
|
||||
const decryptAPIData = (data, key) => {
|
||||
const cipher = (0, crypto_1.createDecipheriv)("aes-256-cbc", key, key.subarray(0, 16));
|
||||
return Buffer.concat([
|
||||
cipher.update(data, "base64"),
|
||||
cipher.final()
|
||||
]);
|
||||
};
|
||||
exports.decryptAPIData = decryptAPIData;
|
||||
const getBlocklist = function (directions) {
|
||||
const result = [];
|
||||
for (let distance = 1; distance <= 5; distance++) {
|
||||
let i = 0;
|
||||
let j = 0;
|
||||
let k = 1;
|
||||
for (const directionDistance of directions) {
|
||||
if (directionDistance >= distance) {
|
||||
j += k;
|
||||
}
|
||||
k <<= 1;
|
||||
}
|
||||
if (j == 0) {
|
||||
i = 65535;
|
||||
}
|
||||
else if (!(j == 255 || j == 65535)) {
|
||||
i = (j ^ 255) + 65280;
|
||||
}
|
||||
result.push(65535 & i);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
exports.getBlocklist = getBlocklist;
|
||||
const getDistances = function (blocklist) {
|
||||
const result = [3, 3, 3, 3, 3, 3, 3, 3];
|
||||
let calcDistance = 0;
|
||||
for (const blockElement of blocklist) {
|
||||
let valueOf = blockElement ^ 65535;
|
||||
calcDistance++;
|
||||
if (valueOf !== 0) {
|
||||
for (let i = 0; i < result.length; i++) {
|
||||
const intValue = valueOf & 1;
|
||||
if (intValue > 0) {
|
||||
result[i] = calcDistance;
|
||||
}
|
||||
valueOf = valueOf >> 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
||||
exports.getDistances = getDistances;
|
||||
const isHB3DetectionModeEnabled = function (value, type) {
|
||||
if (type === types_1.HB3DetectionTypes.HUMAN_RECOGNITION) {
|
||||
return (type & value) == type && (value & 65536) == 65536;
|
||||
}
|
||||
else if (type === types_1.HB3DetectionTypes.HUMAN_DETECTION) {
|
||||
return (type & value) == type && (value & 1) == 1;
|
||||
}
|
||||
return (type & value) == type;
|
||||
};
|
||||
exports.isHB3DetectionModeEnabled = isHB3DetectionModeEnabled;
|
||||
const getHB3DetectionMode = function (value, type, enable) {
|
||||
let result = 0;
|
||||
if (!enable) {
|
||||
if (type === types_1.HB3DetectionTypes.HUMAN_RECOGNITION) {
|
||||
const tmp = (type & value) == type ? type ^ value : value;
|
||||
result = (value & 65536) == 65536 ? tmp ^ 65536 : tmp;
|
||||
}
|
||||
else if (type === types_1.HB3DetectionTypes.HUMAN_DETECTION) {
|
||||
const tmp = (type & value) == type ? type ^ value : value;
|
||||
result = (value & 1) == 1 ? tmp ^ 1 : tmp;
|
||||
}
|
||||
else {
|
||||
result = type ^ value;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (type === types_1.HB3DetectionTypes.HUMAN_RECOGNITION) {
|
||||
result = type | value | 65536;
|
||||
}
|
||||
else if (type === types_1.HB3DetectionTypes.HUMAN_DETECTION) {
|
||||
result = type | value | 1;
|
||||
}
|
||||
else {
|
||||
result = type | value;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
||||
exports.getHB3DetectionMode = getHB3DetectionMode;
|
||||
const getEufyTimezone = function () {
|
||||
for (const timezone of const_1.timeZoneData) {
|
||||
if (timezone.timeId === Intl.DateTimeFormat().resolvedOptions().timeZone) {
|
||||
return timezone;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
exports.getEufyTimezone = getEufyTimezone;
|
||||
const getAdvancedLockTimezone = function (stationSN) {
|
||||
const timezone = (0, exports.getEufyTimezone)();
|
||||
if (timezone !== undefined) {
|
||||
if (stationSN.startsWith("T8520") && (0, exports.isGreaterEqualMinVersion)("1.2.8.6", stationSN))
|
||||
return `${timezone.timeZoneGMT}|1.${timezone.timeSn}`;
|
||||
else
|
||||
return timezone.timeZoneGMT;
|
||||
}
|
||||
return "";
|
||||
};
|
||||
exports.getAdvancedLockTimezone = getAdvancedLockTimezone;
|
||||
class WritePayload {
|
||||
split_byte = -95;
|
||||
data = Buffer.from([]);
|
||||
write(bytes) {
|
||||
const tmp_data = Buffer.from(bytes);
|
||||
this.data = Buffer.concat([this.data, Buffer.from([this.split_byte]), Buffer.from([tmp_data.length & 255]), tmp_data]);
|
||||
this.split_byte += 1;
|
||||
}
|
||||
getData() {
|
||||
return this.data;
|
||||
}
|
||||
}
|
||||
exports.WritePayload = WritePayload;
|
||||
class ParsePayload {
|
||||
data;
|
||||
constructor(data) {
|
||||
this.data = data;
|
||||
}
|
||||
readUint32BE(indexValue) {
|
||||
return this.readData(indexValue).readUint32BE();
|
||||
}
|
||||
readUint32LE(indexValue) {
|
||||
return this.readData(indexValue).readUint32LE();
|
||||
}
|
||||
readUint16BE(indexValue) {
|
||||
return this.readData(indexValue).readUint16BE();
|
||||
}
|
||||
readUint16LE(indexValue) {
|
||||
return this.readData(indexValue).readUint16LE();
|
||||
}
|
||||
readString(indexValue) {
|
||||
return this.readData(indexValue).toString();
|
||||
}
|
||||
readStringHex(indexValue) {
|
||||
return this.readData(indexValue).toString("hex");
|
||||
}
|
||||
readInt8(indexValue) {
|
||||
let dataPosition = this.getDataPosition(indexValue);
|
||||
if (dataPosition == -1) {
|
||||
return 0;
|
||||
}
|
||||
dataPosition = dataPosition + 2;
|
||||
if (dataPosition >= this.data.length) {
|
||||
return 0;
|
||||
}
|
||||
return this.data.readInt8(dataPosition);
|
||||
}
|
||||
readData(indexValue) {
|
||||
let dataPosition = this.getDataPosition(indexValue);
|
||||
if (dataPosition == -1) {
|
||||
return Buffer.from("");
|
||||
}
|
||||
dataPosition++;
|
||||
if (dataPosition >= this.data.length) {
|
||||
return Buffer.from("");
|
||||
}
|
||||
const nextStep = this.getNextStep(indexValue, dataPosition, this.data);
|
||||
let tmp;
|
||||
if (nextStep == 1) {
|
||||
tmp = this.data.readInt8(dataPosition);
|
||||
}
|
||||
else {
|
||||
tmp = this.data.readUint16LE(dataPosition);
|
||||
}
|
||||
if (dataPosition + nextStep + tmp > this.data.length) {
|
||||
return Buffer.from("");
|
||||
}
|
||||
return this.data.subarray(dataPosition + nextStep, dataPosition + nextStep + tmp);
|
||||
}
|
||||
getDataPosition(indexValue) {
|
||||
if (this.data && this.data.length >= 1) {
|
||||
for (let currentPosition = 0; currentPosition < this.data.length;) {
|
||||
if (this.data.readInt8(currentPosition) == indexValue) {
|
||||
return currentPosition;
|
||||
}
|
||||
else {
|
||||
const value = this.data.readInt8(currentPosition);
|
||||
currentPosition++;
|
||||
if (currentPosition >= this.data.length) {
|
||||
break;
|
||||
}
|
||||
const nextStep = this.getNextStep(value, currentPosition, this.data);
|
||||
if ((currentPosition + nextStep) >= this.data.length) {
|
||||
break;
|
||||
}
|
||||
if (nextStep == 1) {
|
||||
currentPosition = this.data.readInt8(currentPosition) + currentPosition + nextStep;
|
||||
}
|
||||
else {
|
||||
currentPosition = this.data.readUint16LE(currentPosition) + currentPosition + nextStep;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
getNextStep(indexValue, position, data) {
|
||||
const newPosition = position + 1 + data.readUInt8(position);
|
||||
return (newPosition == data.length || newPosition > data.length || data.readInt8(newPosition) == indexValue + 1) ? 1 : 2;
|
||||
}
|
||||
}
|
||||
exports.ParsePayload = ParsePayload;
|
||||
/*export const generateHash = function(data: Buffer): number {
|
||||
let result = 0;
|
||||
for (const value of data) {
|
||||
result = result ^ value;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export const encodeSmartSafeData = function(command: number, payload: Buffer): Buffer {
|
||||
const header = Buffer.from(SmartSafe.DATA_HEADER);
|
||||
const size = Buffer.allocUnsafe(2);
|
||||
size.writeInt16LE(payload.length + 9);
|
||||
const versionCode = Buffer.from([SmartSafe.VERSION_CODE]);
|
||||
const dataType = Buffer.from([-1]);
|
||||
const commandCode = Buffer.from([command]);
|
||||
const packageFlag = Buffer.from([-64]);
|
||||
const data = Buffer.concat([header, size, versionCode, dataType, commandCode, packageFlag, payload]);
|
||||
const hash = generateHash(data);
|
||||
return Buffer.concat([data, Buffer.from([hash])]);
|
||||
}*/
|
||||
const encodePasscode = function (pass) {
|
||||
let result = "";
|
||||
for (let i = 0; i < pass.length; i++)
|
||||
result += pass.charCodeAt(i).toString(16);
|
||||
return result;
|
||||
};
|
||||
exports.encodePasscode = encodePasscode;
|
||||
const hexDate = function (date) {
|
||||
const buf = Buffer.allocUnsafe(4);
|
||||
buf.writeUint8(date.getDate());
|
||||
buf.writeUint8(date.getMonth() + 1, 1);
|
||||
buf.writeUint16BE(date.getFullYear(), 2);
|
||||
return buf.readUInt32LE().toString(16).padStart(8, "0");
|
||||
};
|
||||
exports.hexDate = hexDate;
|
||||
const hexTime = function (date) {
|
||||
const buf = Buffer.allocUnsafe(2);
|
||||
buf.writeUint8(date.getHours());
|
||||
buf.writeUint8(date.getMinutes(), 1);
|
||||
return buf.readUInt16BE().toString(16).padStart(4, "0");
|
||||
};
|
||||
exports.hexTime = hexTime;
|
||||
const hexWeek = function (schedule) {
|
||||
const SUNDAY = 1;
|
||||
const MONDAY = 2;
|
||||
const TUESDAY = 4;
|
||||
const WEDNESDAY = 8;
|
||||
const THUERSDAY = 16;
|
||||
const FRIDAY = 32;
|
||||
const SATURDAY = 64;
|
||||
let result = 0;
|
||||
if (schedule.week !== undefined) {
|
||||
if (schedule.week.sunday) {
|
||||
result |= SUNDAY;
|
||||
}
|
||||
if (schedule.week.monday) {
|
||||
result |= MONDAY;
|
||||
}
|
||||
if (schedule.week.tuesday) {
|
||||
result |= TUESDAY;
|
||||
}
|
||||
if (schedule.week.wednesday) {
|
||||
result |= WEDNESDAY;
|
||||
}
|
||||
if (schedule.week.thursday) {
|
||||
result |= THUERSDAY;
|
||||
}
|
||||
if (schedule.week.friday) {
|
||||
result |= FRIDAY;
|
||||
}
|
||||
if (schedule.week.saturday) {
|
||||
result |= SATURDAY;
|
||||
}
|
||||
return result.toString(16);
|
||||
}
|
||||
return "ff";
|
||||
};
|
||||
exports.hexWeek = hexWeek;
|
||||
const hexStringScheduleToSchedule = function (startDay, startTime, endDay, endTime, week) {
|
||||
const SUNDAY = 1;
|
||||
const MONDAY = 2;
|
||||
const TUESDAY = 4;
|
||||
const WEDNESDAY = 8;
|
||||
const THUERSDAY = 16;
|
||||
const FRIDAY = 32;
|
||||
const SATURDAY = 64;
|
||||
const weekNumber = Number.parseInt(week, 16);
|
||||
return {
|
||||
startDateTime: startDay === "00000000" ? undefined : new Date(Number.parseInt(`${startDay.substring(2, 4)}${startDay.substring(0, 2)}`, 16), Number.parseInt(startDay.substring(4, 6), 16) - 1, Number.parseInt(startDay.substring(6, 8), 16), Number.parseInt(startTime.substring(0, 2), 16), Number.parseInt(startTime.substring(2, 4), 16)),
|
||||
endDateTime: endDay === "ffffffff" ? undefined : new Date(Number.parseInt(`${endDay.substring(2, 4)}${endDay.substring(0, 2)}`, 16), Number.parseInt(endDay.substring(4, 6), 16) - 1, Number.parseInt(endDay.substring(6, 8), 16), Number.parseInt(endTime.substring(0, 2), 16), Number.parseInt(endTime.substring(2, 4), 16)),
|
||||
week: {
|
||||
monday: (weekNumber & MONDAY) == MONDAY,
|
||||
tuesday: (weekNumber & TUESDAY) == TUESDAY,
|
||||
wednesday: (weekNumber & WEDNESDAY) == WEDNESDAY,
|
||||
thursday: (weekNumber & THUERSDAY) == THUERSDAY,
|
||||
friday: (weekNumber & FRIDAY) == FRIDAY,
|
||||
saturday: (weekNumber & SATURDAY) == SATURDAY,
|
||||
sunday: (weekNumber & SUNDAY) == SUNDAY,
|
||||
},
|
||||
};
|
||||
};
|
||||
exports.hexStringScheduleToSchedule = hexStringScheduleToSchedule;
|
||||
const randomNumber = function (min, max) {
|
||||
return Math.floor(Math.random() * (max - min + 1)) + min;
|
||||
};
|
||||
exports.randomNumber = randomNumber;
|
||||
const getIdSuffix = function (p2pDid) {
|
||||
let result = 0;
|
||||
const match = p2pDid.match(/^[A-Z]+-(\d+)-[A-Z]+$/);
|
||||
if (match?.length == 2) {
|
||||
const num1 = Number.parseInt(match[1][0]);
|
||||
const num2 = Number.parseInt(match[1][1]);
|
||||
const num3 = Number.parseInt(match[1][3]);
|
||||
const num4 = Number.parseInt(match[1][5]);
|
||||
result = num1 + num2 + num3;
|
||||
if (num3 < 5) {
|
||||
result = result + num3;
|
||||
}
|
||||
result = result + num4;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
exports.getIdSuffix = getIdSuffix;
|
||||
const getImageBaseCode = function (serialnumber, p2pDid) {
|
||||
let nr = 0;
|
||||
try {
|
||||
nr = Number.parseInt(`0x${serialnumber[serialnumber.length - 1]}`);
|
||||
}
|
||||
catch (err) {
|
||||
const error = (0, error_1.ensureError)(err);
|
||||
throw new error_2.ImageBaseCodeError("Error generating image base code", { cause: error, context: { serialnumber: serialnumber, p2pDid: p2pDid } });
|
||||
}
|
||||
nr = (nr + 10) % 10;
|
||||
const base = serialnumber.substring(nr);
|
||||
return `${base}${(0, exports.getIdSuffix)(p2pDid)}`;
|
||||
};
|
||||
exports.getImageBaseCode = getImageBaseCode;
|
||||
const getImageSeed = function (p2pDid, code) {
|
||||
try {
|
||||
const ncode = Number.parseInt(code.substring(2));
|
||||
const prefix = 1000 - (0, exports.getIdSuffix)(p2pDid);
|
||||
return (0, md5_1.default)(`${prefix}${ncode}`).toString(enc_hex_1.default).toUpperCase();
|
||||
}
|
||||
catch (err) {
|
||||
const error = (0, error_1.ensureError)(err);
|
||||
throw new error_2.ImageBaseCodeError("Error generating image seed", { cause: error, context: { p2pDid: p2pDid, code: code } });
|
||||
}
|
||||
};
|
||||
exports.getImageSeed = getImageSeed;
|
||||
const getImageKey = function (serialnumber, p2pDid, code) {
|
||||
const basecode = (0, exports.getImageBaseCode)(serialnumber, p2pDid);
|
||||
const seed = (0, exports.getImageSeed)(p2pDid, code);
|
||||
const data = `01${basecode}${seed}`;
|
||||
const hash = (0, sha256_1.default)(data);
|
||||
const hashBytes = [...Buffer.from(hash.toString(enc_hex_1.default), "hex")];
|
||||
const startByte = hashBytes[10];
|
||||
for (let i = 0; i < 32; i++) {
|
||||
const byte = hashBytes[i];
|
||||
let fixed_byte = startByte;
|
||||
if (i < 31) {
|
||||
fixed_byte = hashBytes[i + 1];
|
||||
}
|
||||
if ((i == 31) || ((i & 1) != 0)) {
|
||||
hashBytes[10] = fixed_byte;
|
||||
if ((126 < byte) || (126 < hashBytes[10])) {
|
||||
if (byte < hashBytes[10] || (byte - hashBytes[10]) == 0) {
|
||||
hashBytes[i] = hashBytes[10] - byte;
|
||||
}
|
||||
else {
|
||||
hashBytes[i] = byte - hashBytes[10];
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((byte < 125) || (fixed_byte < 125)) {
|
||||
hashBytes[i] = fixed_byte + byte;
|
||||
}
|
||||
}
|
||||
return `${Buffer.from(hashBytes.slice(16)).toString("hex").toUpperCase()}`;
|
||||
};
|
||||
exports.getImageKey = getImageKey;
|
||||
const decodeImage = function (p2pDid, data) {
|
||||
if (data.length >= 12) {
|
||||
const header = data.subarray(0, 12).toString();
|
||||
if (header === "eufysecurity") {
|
||||
const serialnumber = data.subarray(13, 29).toString();
|
||||
const code = data.subarray(30, 40).toString();
|
||||
const imageKey = (0, exports.getImageKey)(serialnumber, p2pDid, code);
|
||||
const otherData = data.subarray(41);
|
||||
const encryptedData = otherData.subarray(0, 256);
|
||||
const cipher = (0, crypto_1.createDecipheriv)("aes-128-ecb", Buffer.from(imageKey, "utf-8").subarray(0, 16), null);
|
||||
cipher.setAutoPadding(false);
|
||||
const decryptedData = Buffer.concat([
|
||||
cipher.update(encryptedData),
|
||||
cipher.final()
|
||||
]);
|
||||
decryptedData.copy(otherData);
|
||||
return otherData;
|
||||
}
|
||||
}
|
||||
return data;
|
||||
};
|
||||
exports.decodeImage = decodeImage;
|
||||
const getImagePath = function (path) {
|
||||
const splittedPath = path.split("~");
|
||||
if (splittedPath.length === 2) {
|
||||
return splittedPath[1];
|
||||
}
|
||||
return path;
|
||||
};
|
||||
exports.getImagePath = getImagePath;
|
||||
const getImage = async function (api, serial, url) {
|
||||
const { default: imageType } = await import("image-type");
|
||||
const image = await api.getImage(serial, url);
|
||||
const type = await imageType(image);
|
||||
return {
|
||||
data: image,
|
||||
type: type !== null && type !== undefined ? type : { ext: "unknown", mime: "application/octet-stream" }
|
||||
};
|
||||
};
|
||||
exports.getImage = getImage;
|
||||
const isPrioritySourceType = function (current, update) {
|
||||
if (((current === "http" || current === "p2p" || current === "push" || current === "mqtt" || current === undefined) && (update === "p2p" || update === "push" || update === "mqtt")) ||
|
||||
((current === "http" || current === undefined) && update === "http")) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
exports.isPrioritySourceType = isPrioritySourceType;
|
||||
const decryptTrackerData = (data, key) => {
|
||||
const decipher = (0, crypto_1.createDecipheriv)("aes-128-ecb", key, null);
|
||||
decipher.setAutoPadding(false);
|
||||
return Buffer.concat([
|
||||
decipher.update(data),
|
||||
decipher.final()
|
||||
]);
|
||||
};
|
||||
exports.decryptTrackerData = decryptTrackerData;
|
||||
const isT8170DetectionModeEnabled = function (value, type) {
|
||||
return (type & value) == type;
|
||||
};
|
||||
exports.isT8170DetectionModeEnabled = isT8170DetectionModeEnabled;
|
||||
const getT8170DetectionMode = function (value, type, enable) {
|
||||
let result = 0;
|
||||
if ((Object.values(types_1.T8170DetectionTypes).includes(type) && Object.values(types_1.T8170DetectionTypes).includes(value)) && !enable)
|
||||
return value;
|
||||
if (!enable) {
|
||||
result = type ^ value;
|
||||
}
|
||||
else {
|
||||
result = type | value;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
exports.getT8170DetectionMode = getT8170DetectionMode;
|
||||
const isIndoorS350DetectionModeEnabled = function (value, type) {
|
||||
return (type & value) == type;
|
||||
};
|
||||
exports.isIndoorS350DetectionModeEnabled = isIndoorS350DetectionModeEnabled;
|
||||
const getIndoorS350DetectionMode = function (value, type, enable) {
|
||||
let result = 0;
|
||||
if ((Object.values(types_1.IndoorS350DetectionTypes).includes(type) && Object.values(types_1.IndoorS350DetectionTypes).includes(value)) && !enable)
|
||||
return value;
|
||||
if (!enable) {
|
||||
result = type ^ value;
|
||||
}
|
||||
else {
|
||||
result = type | value;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
exports.getIndoorS350DetectionMode = getIndoorS350DetectionMode;
|
||||
const isIndoorNotitficationEnabled = function (value, type) {
|
||||
return (type & value) == type;
|
||||
};
|
||||
exports.isIndoorNotitficationEnabled = isIndoorNotitficationEnabled;
|
||||
const getIndoorNotification = function (value, type, enable) {
|
||||
let result = 0;
|
||||
if (!enable) {
|
||||
result = (type ^ value) + 800;
|
||||
}
|
||||
else {
|
||||
result = type | value;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
exports.getIndoorNotification = getIndoorNotification;
|
||||
const isFloodlightT8425NotitficationEnabled = function (value, type) {
|
||||
return (type & value) == type;
|
||||
};
|
||||
exports.isFloodlightT8425NotitficationEnabled = isFloodlightT8425NotitficationEnabled;
|
||||
const getFloodLightT8425Notification = function (value, type, enable) {
|
||||
let result = 0;
|
||||
if (!enable) {
|
||||
result = (type ^ value);
|
||||
}
|
||||
else {
|
||||
result = type | value;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
exports.getFloodLightT8425Notification = getFloodLightT8425Notification;
|
||||
const getLockEventType = function (event) {
|
||||
switch (event) {
|
||||
case types_2.LockPushEvent.AUTO_LOCK:
|
||||
case types_2.LockPushEvent.AUTO_UNLOCK:
|
||||
return 1;
|
||||
case types_2.LockPushEvent.MANUAL_LOCK:
|
||||
case types_2.LockPushEvent.MANUAL_UNLOCK:
|
||||
return 2;
|
||||
case types_2.LockPushEvent.APP_LOCK:
|
||||
case types_2.LockPushEvent.APP_UNLOCK:
|
||||
return 3;
|
||||
case types_2.LockPushEvent.PW_LOCK:
|
||||
case types_2.LockPushEvent.PW_UNLOCK:
|
||||
return 4;
|
||||
case types_2.LockPushEvent.FINGER_LOCK:
|
||||
case types_2.LockPushEvent.FINGERPRINT_UNLOCK:
|
||||
return 5;
|
||||
case types_2.LockPushEvent.TEMPORARY_PW_LOCK:
|
||||
case types_2.LockPushEvent.TEMPORARY_PW_UNLOCK:
|
||||
return 6;
|
||||
case types_2.LockPushEvent.KEYPAD_LOCK:
|
||||
return 7;
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
exports.getLockEventType = getLockEventType;
|
||||
const switchSmartLockNotification = function (currentValue, mode, enable) {
|
||||
let result = 0;
|
||||
if (enable) {
|
||||
result = mode | currentValue;
|
||||
}
|
||||
else {
|
||||
result = ~mode & currentValue;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
exports.switchSmartLockNotification = switchSmartLockNotification;
|
||||
const isSmartLockNotification = function (value, mode) {
|
||||
return (value & mode) !== 0;
|
||||
};
|
||||
exports.isSmartLockNotification = isSmartLockNotification;
|
||||
const getWaitSeconds = (device) => {
|
||||
let seconds = 60;
|
||||
const workingMode = device.getPropertyValue(types_1.PropertyName.DevicePowerWorkingMode);
|
||||
if (workingMode !== undefined && workingMode === 2) {
|
||||
const customValue = device.getPropertyValue(types_1.PropertyName.DeviceRecordingClipLength);
|
||||
if (customValue !== undefined) {
|
||||
seconds = customValue;
|
||||
}
|
||||
}
|
||||
return seconds;
|
||||
};
|
||||
exports.getWaitSeconds = getWaitSeconds;
|
||||
const loadImageOverP2P = function (station, device, id, p2pTimeouts) {
|
||||
if (station.hasCommand(types_1.CommandName.StationDatabaseQueryLatestInfo) && p2pTimeouts.get(id) === undefined) {
|
||||
const seconds = (0, exports.getWaitSeconds)(device);
|
||||
p2pTimeouts.set(id, setTimeout(async () => {
|
||||
station.databaseQueryLatestInfo();
|
||||
p2pTimeouts.delete(id);
|
||||
}, seconds * 1000));
|
||||
}
|
||||
};
|
||||
exports.loadImageOverP2P = loadImageOverP2P;
|
||||
const loadEventImage = function (station, api, device, message, p2pTimeouts) {
|
||||
if (message.notification_style === types_1.NotificationType.MOST_EFFICIENT) {
|
||||
(0, exports.loadImageOverP2P)(station, device, device.getSerial(), p2pTimeouts);
|
||||
}
|
||||
else {
|
||||
if (!(0, utils_1.isEmpty)(message.pic_url)) {
|
||||
(0, exports.getImage)(api, device.getSerial(), message.pic_url).then((image) => {
|
||||
if (image.data.length > 0) {
|
||||
if (p2pTimeouts.get(device.getSerial()) !== undefined) {
|
||||
clearTimeout(p2pTimeouts.get(device.getSerial()));
|
||||
p2pTimeouts.delete(device.getSerial());
|
||||
}
|
||||
device.updateProperty(types_1.PropertyName.DevicePicture, image, true);
|
||||
}
|
||||
else {
|
||||
//fallback
|
||||
(0, exports.loadImageOverP2P)(station, device, device.getSerial(), p2pTimeouts);
|
||||
}
|
||||
}).catch((err) => {
|
||||
const error = (0, error_1.ensureError)(err);
|
||||
logging_1.rootHTTPLogger.debug(`Device load event image - Fallback Error`, { error: (0, utils_1.getError)(error), stationSN: station.getSerial(), deviceSN: device.getSerial(), message: JSON.stringify(message) });
|
||||
(0, exports.loadImageOverP2P)(station, device, device.getSerial(), p2pTimeouts);
|
||||
});
|
||||
}
|
||||
else {
|
||||
//fallback
|
||||
(0, exports.loadImageOverP2P)(station, device, device.getSerial(), p2pTimeouts);
|
||||
}
|
||||
}
|
||||
};
|
||||
exports.loadEventImage = loadEventImage;
|
||||
//# sourceMappingURL=utils.js.map
|
||||
1
build/http/utils.js.map
Normal file
1
build/http/utils.js.map
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user