From 04b50903ad35397d53f34821089f82dfc6246ae6 Mon Sep 17 00:00:00 2001 From: markh Date: Fri, 24 Jun 2022 14:51:18 +1000 Subject: [PATCH 1/3] Correct random device ID Corrected replace function to scan entire string when generating device ID rather than just the first character --- src/nest/streamer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nest/streamer.ts b/src/nest/streamer.ts index ee6cd04..db14c24 100644 --- a/src/nest/streamer.ts +++ b/src/nest/streamer.ts @@ -26,7 +26,7 @@ enum StreamQuality { * @returns {string} The random device id */ const generateDeviceId = (): string => { - return 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'.replace('x', () => { + return 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'.replace(/x/g, () => { return Math.floor(Math.random() * 16).toString(16); }); }; From 6794e68b955d2252081e198a285fddfd0443e5e0 Mon Sep 17 00:00:00 2001 From: markh Date: Fri, 24 Jun 2022 18:24:19 +1000 Subject: [PATCH 2/3] updateAuthentication support for "Nest" Original code only supported re-authorisation using a "Google" token. Updated function to support both "Nest" and "Google" tokens when a re-authorisation is requested --- src/nest/streamer.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/nest/streamer.ts b/src/nest/streamer.ts index ee6cd04..bd42ff9 100644 --- a/src/nest/streamer.ts +++ b/src/nest/streamer.ts @@ -276,9 +276,14 @@ export class NexusStreamer { * Update the socket authentication with the new access token */ private updateAuthentication(): void { - const token = { - olive_token: this.accessToken, - }; + var token = {}; + if (nestAuth) { + // Re-authorisation using "Nest" token + token = {session_token: accessToken}; + } else { + // Re-authorisation using "Google" token + token = {olive_token: accessToken}; + } const tokenContainer = new Pbf(); AuthorizeRequest.write(token, tokenContainer); const tokenBuffer = tokenContainer.finish(); From da67ebb9c13e3f9c4087e1738a9576ef50eb25ed Mon Sep 17 00:00:00 2001 From: markh Date: Fri, 24 Jun 2022 18:27:50 +1000 Subject: [PATCH 3/3] updateAuthentication support "Nest" token Original code only supported re-authorisation using a "Google" token. Updated function to support both "Nest" and "Google" tokens when a re-authorisation is requested --- src/nest/streamer.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/nest/streamer.ts b/src/nest/streamer.ts index bd42ff9..5879d2c 100644 --- a/src/nest/streamer.ts +++ b/src/nest/streamer.ts @@ -277,12 +277,12 @@ export class NexusStreamer { */ private updateAuthentication(): void { var token = {}; - if (nestAuth) { + if (this.nestAuth) { // Re-authorisation using "Nest" token - token = {session_token: accessToken}; + token = {session_token: this.accessToken}; } else { // Re-authorisation using "Google" token - token = {olive_token: accessToken}; + token = {olive_token: this.accessToken}; } const tokenContainer = new Pbf(); AuthorizeRequest.write(token, tokenContainer);