Skip to content

Commit

Permalink
Fixed issue #64
Browse files Browse the repository at this point in the history
Fixed issue #65
Updated versions of the package dependencies
  • Loading branch information
bropat committed Nov 16, 2021
1 parent 7d540d4 commit 06aee3b
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 55 deletions.
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ One client instance will show all devices from one Eufy Cloud account and allows
* eufyCam 2 Pro (T8140)
* eufyCam 2C Pro (T8141)
* SoloCam E40 (T8131)
* Floodlight (T8420)
* Floodlight (T8422)
* Floodlight Camera (T8420)
* Floodlight Cam (T8422)
* Floodlight Cam 2 (T8424)
* Wired Doorbell 2k (T8200)
* Wired Doorbell 1080p (T8201)
* Battery Doorbell 2K (T8210)
Expand All @@ -100,6 +101,12 @@ Please use GitHub issues for this.

## Changelog

### 1.2.3 (2021-11-16)

* (bropat) Fixed issue #64
* (bropat) Fixed issue #65
* (bropat) Updated versions of the package dependencies

### 1.2.2 (2021-11-06)

* (bropat) Fixed issue of wrong channel value on event rtsp livestream stopped
Expand Down
34 changes: 17 additions & 17 deletions package-lock.json

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

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eufy-security-client",
"version": "1.2.2",
"version": "1.2.3",
"description": "Client to comunicate with Eufy-Security devices",
"author": {
"name": "bropat",
Expand Down Expand Up @@ -43,13 +43,13 @@
"crypto-js": "^4.1.1",
"ts-log": "^2.2.4",
"tiny-typed-emitter": "^2.1.0",
"i18n-iso-countries": "^6.8.0",
"i18n-iso-countries": "^7.0.0",
"@cospired/i18n-iso-languages": "^3.1.1",
"fs-extra": "^10.0.0",
"sweet-collections": "^1.1.0"
},
"devDependencies": {
"@types/node": "^16.11.6",
"@types/node": "^16.11.7",
"@types/qs": "^6.9.7",
"@types/node-rsa": "^1.1.1",
"@types/crypto-js": "^4.0.2",
Expand Down
3 changes: 2 additions & 1 deletion src/http/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2108,7 +2108,6 @@ export const DeviceProperties: Properties = {
[PropertyName.DeviceRecordingEndClipMotionStops]: DeviceRecordingEndClipMotionStopsProperty,
[PropertyName.DeviceVideoStreamingQuality]: DeviceVideoStreamingQualityProperty,
[PropertyName.DeviceNotificationType]: DeviceNotificationTypeIndoorFloodlightProperty,
[PropertyName.DeviceVideoStreamingQuality]: DeviceVideoStreamingQualityProperty,
[PropertyName.DeviceVideoRecordingQuality]: DeviceVideoRecordingQualityIndoorProperty,
},
[DeviceType.FLOODLIGHT_CAMERA_8423]: {
Expand Down Expand Up @@ -2138,6 +2137,7 @@ export const DeviceProperties: Properties = {
[PropertyName.DeviceRecordingEndClipMotionStops]: DeviceRecordingEndClipMotionStopsProperty,
[PropertyName.DeviceVideoStreamingQuality]: DeviceVideoStreamingQualityProperty,
[PropertyName.DeviceNotificationType]: DeviceNotificationTypeIndoorFloodlightProperty,
[PropertyName.DeviceVideoRecordingQuality]: DeviceVideoRecordingQualityIndoorProperty,
},
[DeviceType.FLOODLIGHT_CAMERA_8424]: {
...GenericDeviceProperties,
Expand Down Expand Up @@ -2166,6 +2166,7 @@ export const DeviceProperties: Properties = {
[PropertyName.DeviceRecordingEndClipMotionStops]: DeviceRecordingEndClipMotionStopsProperty,
[PropertyName.DeviceVideoStreamingQuality]: DeviceVideoStreamingQualityProperty,
[PropertyName.DeviceNotificationType]: DeviceNotificationTypeIndoorFloodlightProperty,
[PropertyName.DeviceVideoRecordingQuality]: DeviceVideoRecordingQualityIndoorProperty,
},
[DeviceType.INDOOR_CAMERA]: {
...GenericDeviceProperties,
Expand Down
2 changes: 1 addition & 1 deletion src/p2p/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1543,7 +1543,7 @@ export class P2PClientProtocol extends TypedEmitter<P2PClientProtocolEvents> {

public updateRawStation(value: HubResponse): void {
this.rawStation = value;
if (this.rawStation.devices.length === 1) {
if (this.rawStation.devices?.length === 1) {
if (!this.energySavingDevice) {
this.energySavingDevice = this.rawStation.station_sn === this.rawStation.devices[0].device_sn && Device.hasBattery(this.rawStation.devices[0].device_type);
if (this.energySavingDevice)
Expand Down
79 changes: 48 additions & 31 deletions src/push/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,42 +138,57 @@ export class PushNotificationService extends TypedEmitter<PushNotificationServic

private async createPushCredentials(): Promise<Credentials> {
const generatedFid = generateFid();

const registerFidResponse = await this.registerFid(generatedFid);
const checkinResponse = await this.executeCheckin();
//TODO: On exception handle it and maybe retry later
const registerGcmResponse = await this.registerGcm(registerFidResponse, checkinResponse);

return {
fidResponse: registerFidResponse,
checkinResponse: checkinResponse,
gcmResponse: registerGcmResponse,
};
return await this.registerFid(generatedFid)
.then(async (registerFidResponse) => {
const checkinResponse = await this.executeCheckin();
return {
fidResponse: registerFidResponse,
checkinResponse: checkinResponse
};
})
.then(async (result) => {
const registerGcmResponse = await this.registerGcm(result.fidResponse, result.checkinResponse);
return {
...result,
gcmResponse: registerGcmResponse,
};
}).catch((error) => {
throw error;
});
}

private async renewPushCredentials(credentials: Credentials): Promise<Credentials> {
credentials.fidResponse.authToken = await this.renewFidToken(credentials.fidResponse.fid, credentials.fidResponse.refreshToken);
const checkinResponse = await this.executeCheckin();
//TODO: On exception handle it and maybe retry later
const registerGcmResponse = await this.registerGcm(credentials.fidResponse, checkinResponse);

return {
fidResponse: credentials.fidResponse,
checkinResponse: checkinResponse,
gcmResponse: registerGcmResponse,
};
return await this.renewFidToken(credentials.fidResponse.fid, credentials.fidResponse.refreshToken)
.then(async (response) => {
credentials.fidResponse.authToken = response;
return await this.executeCheckin();
})
.then(async (response) => {
const registerGcmResponse = await this.registerGcm(credentials.fidResponse, response);
return {
fidResponse: credentials.fidResponse,
checkinResponse: response,
gcmResponse: registerGcmResponse,
} as Credentials;
})
.catch(() => {
return this.createPushCredentials();
});
}

private async loginPushCredentials(credentials: Credentials): Promise<Credentials> {
const checkinResponse = await this.executeCheckin();
//TODO: On exception handle it and maybe retry later
const registerGcmResponse = await this.registerGcm(credentials.fidResponse, checkinResponse);

return {
fidResponse: credentials.fidResponse,
checkinResponse: checkinResponse,
gcmResponse: registerGcmResponse,
};
return await this.executeCheckin()
.then(async (response) => {
const registerGcmResponse = await this.registerGcm(credentials.fidResponse, response);
return {
fidResponse: credentials.fidResponse,
checkinResponse: response,
gcmResponse: registerGcmResponse,
} as Credentials;
})
.catch(() => {
return this.createPushCredentials();
});
}

private async executeCheckin(): Promise<CheckinResponse> {
Expand Down Expand Up @@ -542,7 +557,9 @@ export class PushNotificationService extends TypedEmitter<PushNotificationServic
}

public async open(): Promise<Credentials | undefined> {
await this._open();
await this._open().catch((error) => {
this.log.error(`Got exception trying to initialize push notifications`, error);
});

if (!this.credentials) {
this.clearRetryTimeout();
Expand Down

0 comments on commit 06aee3b

Please sign in to comment.