From 6fe59fedc2fa599c3d4cd18b2309bb293ed2357d Mon Sep 17 00:00:00 2001 From: foomoon Date: Fri, 15 Dec 2023 08:17:32 -0600 Subject: [PATCH] move challenge gen to login method --- dist/lib/light.js | 3 ++- src/lib/light.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dist/lib/light.js b/dist/lib/light.js index 9a0b773..1087123 100644 --- a/dist/lib/light.js +++ b/dist/lib/light.js @@ -57,7 +57,7 @@ export class Light { constructor(ipaddr, timeout = 20000) { this.ipaddr = ipaddr; // this.challenge = randomBytes(256).toString("hex"); - this.challenge = generateRandomHex(256); + // this.challenge = generateRandomHex(256); this.net = axios.create({ baseURL: `http://${this.ipaddr}/xled/v1/`, timeout: timeout, @@ -86,6 +86,7 @@ export class Light { this.activeLoginCall = true; this.autoEndLoginCall(); let res; + this.challenge = yield generateRandomHex(256); try { res = yield this.net.post("/login", { challenge: this.challenge, diff --git a/src/lib/light.ts b/src/lib/light.ts index ba49817..d655db4 100644 --- a/src/lib/light.ts +++ b/src/lib/light.ts @@ -71,7 +71,7 @@ export class Light { constructor(ipaddr: string, timeout: number = 20000) { this.ipaddr = ipaddr; // this.challenge = randomBytes(256).toString("hex"); - this.challenge = generateRandomHex(256); + // this.challenge = generateRandomHex(256); this.net = axios.create({ baseURL: `http://${this.ipaddr}/xled/v1/`, timeout: timeout, @@ -96,6 +96,7 @@ export class Light { this.activeLoginCall = true; this.autoEndLoginCall(); let res: AxiosResponse; + this.challenge = await generateRandomHex(256); try { res = await this.net.post("/login", { challenge: this.challenge,