Skip to content

Commit

Permalink
doorbird: remove axios digest auth
Browse files Browse the repository at this point in the history
  • Loading branch information
koush committed Jan 12, 2024
1 parent 566c182 commit 245c6e3
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 51 deletions.
48 changes: 13 additions & 35 deletions plugins/doorbird/package-lock.json

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

1 change: 0 additions & 1 deletion plugins/doorbird/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
]
},
"dependencies": {
"@koush/axios-digest-auth": "^0.8.5",
"doorbird": "^2.1.2"
},
"devDependencies": {
Expand Down
31 changes: 16 additions & 15 deletions plugins/doorbird/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { ffmpegLogInitialOutput, safePrintFFmpegArguments } from "@scrypted/comm
import net from 'net';
import { randomBytes } from 'crypto';
import { PassThrough, Readable } from "stream";
import AxiosDigestAuth from '@koush/axios-digest-auth';
import { readLength } from "@scrypted/common/src/read-stream";
import { authHttpFetch } from "@scrypted/common/src/http-auth-fetch";
import { ApiRingEvent, ApiMotionEvent, DoorbirdAPI } from "./doorbird-api";

const { deviceManager, mediaManager } = sdk;
Expand All @@ -27,7 +27,7 @@ class DoorbirdCamera extends ScryptedDeviceBase implements Intercom, Camera, Vid
this.binaryState = false;
this.doorbellAudioActive = false;

this.updateDeviceInfo();
this.updateDeviceInfo();
}

getDoorbirdApi() {
Expand All @@ -49,8 +49,8 @@ class DoorbirdCamera extends ScryptedDeviceBase implements Intercom, Camera, Vid
this.console?.log("Time:", event.timestamp);
this.triggerMotionSensor();
});
this.getDoorbirdApi()?.startEventSocket();
}
this.getDoorbirdApi()?.startEventSocket();
}
return this.doorbirdApi;
}

Expand Down Expand Up @@ -157,7 +157,7 @@ class DoorbirdCamera extends ScryptedDeviceBase implements Intercom, Camera, Vid
this.stopAudioTransmitter();
this.stopAudioReceiver();
}

async startAudioTransmitter(media: MediaObject): Promise<void> {
const ffmpegInput: FFmpegInput = JSON.parse((await mediaManager.convertMediaObjectToBuffer(media, ScryptedMimeTypes.FFmpegInput)).toString());

Expand Down Expand Up @@ -194,13 +194,13 @@ class DoorbirdCamera extends ScryptedDeviceBase implements Intercom, Camera, Vid
this.console.log('Doorbird: audio transmitter started.');

const passthrough = new PassThrough();
const digestAuth = new AxiosDigestAuth({
username,
password
});
digestAuth.request({
authHttpFetch({
method: 'POST',
url: audioTxUrl,
credential: {
username,
password,
},
headers: {
'Content-Type': 'audio/basic',
'Content-Length': '9999999'
Expand Down Expand Up @@ -293,7 +293,8 @@ class DoorbirdCamera extends ScryptedDeviceBase implements Intercom, Camera, Vid
// this is a hint to let homekit, et al, know that it's OPUS audio and does not need transcoding.
codec: 'pcm_mulaw',
}
}]; }
}];
}

async getVideoStream(options?: ResponseMediaStreamOptions): Promise<MediaObject> {

Expand Down Expand Up @@ -327,7 +328,7 @@ class DoorbirdCamera extends ScryptedDeviceBase implements Intercom, Camera, Vid
if (this.audioSilenceProcess)
return;

this.console.log('Doorbird: starting audio silence generator...')
this.console.log('Doorbird: starting audio silence generator...')

const ffmpegPath = await mediaManager.getFFmpegPath();
const ffmpegArgs = [
Expand Down Expand Up @@ -552,10 +553,10 @@ export class DoorbirdCamProvider extends ScryptedDeviceBase implements DevicePro
}

async releaseDevice(id: string, nativeId: string): Promise<void> {
if( this.devices.delete( nativeId ) ) {
this.console.log("Doorbird: Removed device from list: " + id + " / " + nativeId )
if (this.devices.delete(nativeId)) {
this.console.log("Doorbird: Removed device from list: " + id + " / " + nativeId)
}
}
}

createCamera(nativeId: string): DoorbirdCamera {
return new DoorbirdCamera(nativeId, this);
Expand Down

0 comments on commit 245c6e3

Please sign in to comment.