Skip to content

Commit

Permalink
Implemented captcha authentication mechanism (API v2)
Browse files Browse the repository at this point in the history
Updated version of the package eufy-security-client (1.4.0)
  • Loading branch information
bropat committed Nov 22, 2021
1 parent 1ee0ef6 commit 4ca594e
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 39 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,11 @@ Best is to set the adapter to Debug log mode (Instances -> Expert mode -> Column

## Changelog

### 0.7.4 (2021-11-22)

* (bropat) Implemented captcha authentication mechanism (API v2)
* (bropat) Updated version of the package eufy-security-client (1.4.0)

### 0.7.3 (2021-11-20)

* (bropat) Implemented new encrypted authentication mechanism (API v2)
Expand Down
26 changes: 26 additions & 0 deletions build/main.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/main.js.map

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions io-package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
{
"common": {
"name": "eufy-security",
"version": "0.7.3",
"version": "0.7.4",
"news": {
"0.7.4": {
"en": "Updated version of the package eufy-security-client (1.4.0)",
"de": "Version des Pakets eufy-security-client (1.4.0) aktualisiert",
"ru": "Обновленная версия пакета eufy-security-client (1.4.0)",
"pt": "Versão atualizada do pacote eufy-security-client (1.4.0)",
"nl": "Bijgewerkte versie van het pakket eufy-security-client (1.4.0)",
"fr": "Version mise à jour du paquet eufy-security-client (1.4.0)",
"it": "Aggiornata la versione del pacchetto eufy-security-client (1.4.0)",
"es": "Versión actualizada del paquete eufy-security-client (1.4.0)",
"pl": "Zaktualizowana wersja pakietu eufy-security-client (1.4.0)",
"zh-cn": "包 eufy-security-client (1.4.0) 的更新版本"
},
"0.7.3": {
"en": "Updated version of the package eufy-security-client (1.3.0)",
"de": "Version des Pakets eufy-security-client (1.3.0) aktualisiert",
Expand Down Expand Up @@ -218,18 +230,6 @@
"es": "Se corrigió la regresión en la transmisión en vivo con el códec h265",
"pl": "Naprawiono regresję podczas transmisji na żywo z kodekiem h265",
"zh-cn": "使用H265编解码器修复了实时流的回归"
},
"0.3.0": {
"en": "Implemented feature request #81, #88 and asynchronous download of event videos including some fixes",
"de": "Implementierte Feature-Anforderung Nr. 81, Nr. 88 und asynchrones Herunterladen von Ereignisvideos einschließlich einiger Korrekturen",
"ru": "Реализован запрос функции # 81, # 88 и асинхронная загрузка видео событий, включая некоторые исправления.",
"pt": "Solicitação de recurso implementada nº 81, nº 88 e download assíncrono de vídeos de eventos, incluindo algumas correções",
"nl": "Functieverzoek # 81, # 88 geïmplementeerd en asynchrone download van evenementvideo's inclusief enkele fixes",
"fr": "Implémentation de la demande de fonctionnalité n ° 81, n ° 88 et du téléchargement asynchrone des vidéos d'événements, y compris des correctifs",
"it": "Richiesta di funzionalità implementata n. 81, n. 88 e download asincrono di video di eventi, comprese alcune correzioni",
"es": "Solicitud de función implementada # 81, # 88 y descarga asincrónica de videos de eventos, incluidas algunas correcciones",
"pl": "Zaimplementowano żądanie funkcji # 81, # 88 i asynchroniczne pobieranie filmów z wydarzeń, w tym kilka poprawek",
"zh-cn": "已实现功能请求#81,#88和事件视频的异步下载,包括一些修复程序"
}
},
"title": "Eufy Security",
Expand Down
46 changes: 23 additions & 23 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "iobroker.eufy-security",
"version": "0.7.3",
"version": "0.7.4",
"description": "ioBroker adapter that integrates Eufy-Security cameras with stations",
"author": {
"name": "bropat",
Expand All @@ -27,7 +27,7 @@
"@cospired/i18n-iso-languages": "^3.1.1",
"@iobroker/adapter-core": "^2.5.1",
"axios": "^0.24.0",
"eufy-security-client": "^1.3.0",
"eufy-security-client": "^1.4.0",
"ffmpeg-static": "^4.4.0",
"fs-extra": "^10.0.0",
"i18n-iso-countries": "^7.0.0",
Expand Down
26 changes: 26 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export class EufySecurity extends utils.Adapter {
version: ""
};
private rtmpFFmpegPromise: Map<string, StoppablePromise> = new Map<string, StoppablePromise>();
private captchaId: string | null = null;

public constructor(options: Partial<utils.AdapterOptions> = {}) {
super({
Expand Down Expand Up @@ -83,6 +84,17 @@ export class EufySecurity extends utils.Adapter {
},
native: {},
});
await this.setObjectNotExistsAsync("captcha", {
type: "state",
common: {
name: "Enter captcha",
type: "string",
role: "state",
read: true,
write: true,
},
native: {},
});
await this.setObjectNotExistsAsync("info", {
type: "channel",
common: {
Expand Down Expand Up @@ -155,6 +167,7 @@ export class EufySecurity extends utils.Adapter {
}

this.subscribeStates("verify_code");
this.subscribeStates("captcha");

const systemConfig = await this.getForeignObjectAsync("system.config");
let countryCode = undefined;
Expand Down Expand Up @@ -229,6 +242,7 @@ export class EufySecurity extends utils.Adapter {
this.eufy.on("station connect", (station: Station) => this.onStationConnect(station));
this.eufy.on("station close", (station: Station) => this.onStationClose(station));
this.eufy.on("tfa request", () => this.onTFARequest());
this.eufy.on("captcha request", (captchaId: string, captcha: string) => this.onCaptchaRequest(captchaId, captcha));

//TODO: Implement station alarm event
//this.eufy.on("station alarm event", );
Expand Down Expand Up @@ -301,6 +315,12 @@ export class EufySecurity extends utils.Adapter {
this.eufy.connect(state.val as string);
await this.delStateAsync(id);
}
} else if (station_sn == "captcha") {
if (this.eufy) {
this.logger.info(`Captcha received, send it. (captcha: ${state.val})`);
this.eufy.connect(state.val as string, this.captchaId);
await this.delStateAsync(id);
}
} else if (device_type == "station") {
try {
const station_state_name = values[4];
Expand Down Expand Up @@ -1293,6 +1313,12 @@ export class EufySecurity extends utils.Adapter {
this.logger.warn(`Two factor authentication request received, please enter valid verification code in state ${this.namespace}.verify_code`);
}

private onCaptchaRequest(captchaId: string, captcha: string): void {
this.captchaId = captchaId;
this.logger.warn(`Captcha authentication request received, please enter valid captcha in state ${this.namespace}.captcha`);
this.logger.warn(`Captcha: <img src="${captcha}">`);
}

}

if (module.parent) {
Expand Down

0 comments on commit 4ca594e

Please sign in to comment.