Skip to content

Commit

Permalink
move challenge gen to login method
Browse files Browse the repository at this point in the history
  • Loading branch information
foomoon committed Dec 15, 2023
1 parent dc53f5d commit 6fe59fe
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion dist/lib/light.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion src/lib/light.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit 6fe59fe

Please sign in to comment.