@lumiastream/tapo-cove 3.0.19 → 3.0.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -96,7 +96,7 @@ declare class TapoApi {
96
96
  };
97
97
  state: LightState;
98
98
  fetchConfig?: {
99
- useFetch: boolean;
99
+ useAxios: boolean;
100
100
  shouldWait: boolean;
101
101
  };
102
102
  }) => Promise<any>;
@@ -105,6 +105,10 @@ declare class TapoApi {
105
105
  id: string;
106
106
  };
107
107
  power: boolean;
108
+ fetchConfig?: {
109
+ useAxios: boolean;
110
+ shouldWait: boolean;
111
+ };
108
112
  }) => void;
109
113
  }
110
114
 
package/dist/index.js CHANGED
@@ -163,7 +163,6 @@ var throwErrorIfFound = (responseData) => {
163
163
  }
164
164
  };
165
165
  var handshake = (deviceIp) => __async(void 0, null, function* () {
166
- var _a, _b;
167
166
  const keyPair = yield generateKeyPair();
168
167
  const handshakeRequest = {
169
168
  method: "handshake",
@@ -171,7 +170,7 @@ var handshake = (deviceIp) => __async(void 0, null, function* () {
171
170
  key: keyPair.publicKey
172
171
  }
173
172
  };
174
- const response = yield (globalThis.nodeAxios ? globalThis.nodeAxios : import_axios.default)({
173
+ const response = yield (0, import_axios.default)({
175
174
  method: "post",
176
175
  url: `http://${deviceIp}/app`,
177
176
  data: handshakeRequest
@@ -179,7 +178,9 @@ var handshake = (deviceIp) => __async(void 0, null, function* () {
179
178
  throwErrorIfFound(response.data);
180
179
  let setCookieHeader;
181
180
  if (response.headers["set-cookie"]) {
182
- setCookieHeader = (_b = (_a = response.headers["set-cookie"]) == null ? void 0 : _a[0]) != null ? _b : response.headers["set-cookie"];
181
+ setCookieHeader = Array.isArray(response.headers["set-cookie"]) ? response.headers["set-cookie"][0] : response.headers["set-cookie"];
182
+ } else if (response.headers["bypass-cookie"]) {
183
+ setCookieHeader = Array.isArray(response.headers["bypass-cookie"]) ? response.headers["bypass-cookie"][0] : response.headers["bypass-cookie"];
183
184
  } else {
184
185
  setCookieHeader = response.headers.get("set-cookie");
185
186
  }
@@ -408,14 +409,15 @@ var TapoApi = class {
408
409
  request: encryptedRequest
409
410
  }
410
411
  };
411
- if (!((_a = config.fetchConfig) == null ? void 0 : _a.useFetch)) {
412
+ if ((_a = config.fetchConfig) == null ? void 0 : _a.useAxios) {
412
413
  return this.axiosInstance({
413
414
  url: `http://${deviceKey.deviceIp}/app?token=${deviceKey.token}`,
414
415
  data: {
415
416
  method: "POST",
416
417
  body: securePassthroughRequest,
417
418
  headers: {
418
- Cookie: deviceKey.sessionCookie
419
+ Cookie: deviceKey.sessionCookie,
420
+ BypassCookie: deviceKey.sessionCookie
419
421
  }
420
422
  }
421
423
  });
@@ -426,7 +428,8 @@ var TapoApi = class {
426
428
  method: "POST",
427
429
  body: securePassthroughRequest,
428
430
  headers: {
429
- Cookie: deviceKey.sessionCookie
431
+ Cookie: deviceKey.sessionCookie,
432
+ BypassCookie: deviceKey.sessionCookie
430
433
  }
431
434
  },
432
435
  shouldWait
@@ -434,11 +437,10 @@ var TapoApi = class {
434
437
  }
435
438
  };
436
439
  this.sendPower = (config) => {
437
- this.sendState({ device: config.device, state: new LightState({ on: config.power }) });
440
+ this.sendState({ device: config.device, state: new LightState({ on: config.power }), fetchConfig: config.fetchConfig });
438
441
  };
439
442
  this.axiosInstance = import_axios2.default.create();
440
443
  this.axiosInstance.defaults.timeout = (config == null ? void 0 : config.httpTimeout) || 4e3;
441
- this.axiosInstance.defaults.webSecurity = false;
442
444
  this._config = __spreadValues(__spreadValues({}, this._config), config);
443
445
  }
444
446
  };
package/dist/index.mjs CHANGED
@@ -131,7 +131,6 @@ var throwErrorIfFound = (responseData) => {
131
131
  }
132
132
  };
133
133
  var handshake = (deviceIp) => __async(void 0, null, function* () {
134
- var _a, _b;
135
134
  const keyPair = yield generateKeyPair();
136
135
  const handshakeRequest = {
137
136
  method: "handshake",
@@ -139,7 +138,7 @@ var handshake = (deviceIp) => __async(void 0, null, function* () {
139
138
  key: keyPair.publicKey
140
139
  }
141
140
  };
142
- const response = yield (globalThis.nodeAxios ? globalThis.nodeAxios : axios)({
141
+ const response = yield axios({
143
142
  method: "post",
144
143
  url: `http://${deviceIp}/app`,
145
144
  data: handshakeRequest
@@ -147,7 +146,9 @@ var handshake = (deviceIp) => __async(void 0, null, function* () {
147
146
  throwErrorIfFound(response.data);
148
147
  let setCookieHeader;
149
148
  if (response.headers["set-cookie"]) {
150
- setCookieHeader = (_b = (_a = response.headers["set-cookie"]) == null ? void 0 : _a[0]) != null ? _b : response.headers["set-cookie"];
149
+ setCookieHeader = Array.isArray(response.headers["set-cookie"]) ? response.headers["set-cookie"][0] : response.headers["set-cookie"];
150
+ } else if (response.headers["bypass-cookie"]) {
151
+ setCookieHeader = Array.isArray(response.headers["bypass-cookie"]) ? response.headers["bypass-cookie"][0] : response.headers["bypass-cookie"];
151
152
  } else {
152
153
  setCookieHeader = response.headers.get("set-cookie");
153
154
  }
@@ -376,14 +377,15 @@ var TapoApi = class {
376
377
  request: encryptedRequest
377
378
  }
378
379
  };
379
- if (!((_a = config.fetchConfig) == null ? void 0 : _a.useFetch)) {
380
+ if ((_a = config.fetchConfig) == null ? void 0 : _a.useAxios) {
380
381
  return this.axiosInstance({
381
382
  url: `http://${deviceKey.deviceIp}/app?token=${deviceKey.token}`,
382
383
  data: {
383
384
  method: "POST",
384
385
  body: securePassthroughRequest,
385
386
  headers: {
386
- Cookie: deviceKey.sessionCookie
387
+ Cookie: deviceKey.sessionCookie,
388
+ BypassCookie: deviceKey.sessionCookie
387
389
  }
388
390
  }
389
391
  });
@@ -394,7 +396,8 @@ var TapoApi = class {
394
396
  method: "POST",
395
397
  body: securePassthroughRequest,
396
398
  headers: {
397
- Cookie: deviceKey.sessionCookie
399
+ Cookie: deviceKey.sessionCookie,
400
+ BypassCookie: deviceKey.sessionCookie
398
401
  }
399
402
  },
400
403
  shouldWait
@@ -402,11 +405,10 @@ var TapoApi = class {
402
405
  }
403
406
  };
404
407
  this.sendPower = (config) => {
405
- this.sendState({ device: config.device, state: new LightState({ on: config.power }) });
408
+ this.sendState({ device: config.device, state: new LightState({ on: config.power }), fetchConfig: config.fetchConfig });
406
409
  };
407
410
  this.axiosInstance = axios2.create();
408
411
  this.axiosInstance.defaults.timeout = (config == null ? void 0 : config.httpTimeout) || 4e3;
409
- this.axiosInstance.defaults.webSecurity = false;
410
412
  this._config = __spreadValues(__spreadValues({}, this._config), config);
411
413
  }
412
414
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lumiastream/tapo-cove",
3
- "version": "3.0.19",
3
+ "version": "3.0.21",
4
4
  "private": false,
5
5
  "license": "GPL",
6
6
  "main": "dist/index.js",
@@ -23,5 +23,5 @@
23
23
  "tsup": "*",
24
24
  "typescript": "*"
25
25
  },
26
- "gitHead": "279191669821d9d04ca87576a2cb91d0af37655c"
26
+ "gitHead": "7423f02644d2f558402b56d5379fd3bc96ba91c9"
27
27
  }