@lumiastream/tapo-cove 3.0.15 → 3.0.17

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,6 +96,7 @@ declare class TapoApi {
96
96
  };
97
97
  state: LightState;
98
98
  fetchConfig?: {
99
+ useFetch: boolean;
99
100
  shouldWait: boolean;
100
101
  };
101
102
  }) => Promise<any>;
package/dist/index.js CHANGED
@@ -386,6 +386,7 @@ var TapoApi = class {
386
386
  });
387
387
  // Change state using lightstate
388
388
  this.sendState = (config) => {
389
+ var _a;
389
390
  const deviceKey = this._devices.get(config.device.id);
390
391
  let shouldWait = false;
391
392
  if (config.fetchConfig && config.fetchConfig.shouldWait) {
@@ -407,23 +408,37 @@ var TapoApi = class {
407
408
  request: encryptedRequest
408
409
  }
409
410
  };
410
- return (0, import_fetch_cove.fetchWork)({
411
- url: `http://${deviceKey.deviceIp}/app?token=${deviceKey.token}`,
412
- data: {
413
- method: "POST",
414
- body: securePassthroughRequest,
415
- headers: {
416
- Cookie: deviceKey.sessionCookie
411
+ if (!((_a = config.fetchConfig) == null ? void 0 : _a.useFetch)) {
412
+ return this.axiosInstance({
413
+ url: `http://${deviceKey.deviceIp}/app?token=${deviceKey.token}`,
414
+ data: {
415
+ method: "POST",
416
+ body: securePassthroughRequest,
417
+ headers: {
418
+ Cookie: deviceKey.sessionCookie
419
+ }
417
420
  }
418
- },
419
- shouldWait
420
- });
421
+ });
422
+ } else {
423
+ return (0, import_fetch_cove.fetchWork)({
424
+ url: `http://${deviceKey.deviceIp}/app?token=${deviceKey.token}`,
425
+ data: {
426
+ method: "POST",
427
+ body: securePassthroughRequest,
428
+ headers: {
429
+ Cookie: deviceKey.sessionCookie
430
+ }
431
+ },
432
+ shouldWait
433
+ });
434
+ }
421
435
  };
422
436
  this.sendPower = (config) => {
423
437
  this.sendState({ device: config.device, state: new LightState({ on: config.power }) });
424
438
  };
425
439
  this.axiosInstance = import_axios2.default.create();
426
440
  this.axiosInstance.defaults.timeout = (config == null ? void 0 : config.httpTimeout) || 4e3;
441
+ this.axiosInstance.defaults.withCredentials = true;
427
442
  this._config = __spreadValues(__spreadValues({}, this._config), config);
428
443
  }
429
444
  };
package/dist/index.mjs CHANGED
@@ -354,6 +354,7 @@ var TapoApi = class {
354
354
  });
355
355
  // Change state using lightstate
356
356
  this.sendState = (config) => {
357
+ var _a;
357
358
  const deviceKey = this._devices.get(config.device.id);
358
359
  let shouldWait = false;
359
360
  if (config.fetchConfig && config.fetchConfig.shouldWait) {
@@ -375,23 +376,37 @@ var TapoApi = class {
375
376
  request: encryptedRequest
376
377
  }
377
378
  };
378
- return fetchWork({
379
- url: `http://${deviceKey.deviceIp}/app?token=${deviceKey.token}`,
380
- data: {
381
- method: "POST",
382
- body: securePassthroughRequest,
383
- headers: {
384
- Cookie: deviceKey.sessionCookie
379
+ if (!((_a = config.fetchConfig) == null ? void 0 : _a.useFetch)) {
380
+ return this.axiosInstance({
381
+ url: `http://${deviceKey.deviceIp}/app?token=${deviceKey.token}`,
382
+ data: {
383
+ method: "POST",
384
+ body: securePassthroughRequest,
385
+ headers: {
386
+ Cookie: deviceKey.sessionCookie
387
+ }
385
388
  }
386
- },
387
- shouldWait
388
- });
389
+ });
390
+ } else {
391
+ return fetchWork({
392
+ url: `http://${deviceKey.deviceIp}/app?token=${deviceKey.token}`,
393
+ data: {
394
+ method: "POST",
395
+ body: securePassthroughRequest,
396
+ headers: {
397
+ Cookie: deviceKey.sessionCookie
398
+ }
399
+ },
400
+ shouldWait
401
+ });
402
+ }
389
403
  };
390
404
  this.sendPower = (config) => {
391
405
  this.sendState({ device: config.device, state: new LightState({ on: config.power }) });
392
406
  };
393
407
  this.axiosInstance = axios2.create();
394
408
  this.axiosInstance.defaults.timeout = (config == null ? void 0 : config.httpTimeout) || 4e3;
409
+ this.axiosInstance.defaults.withCredentials = true;
395
410
  this._config = __spreadValues(__spreadValues({}, this._config), config);
396
411
  }
397
412
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lumiastream/tapo-cove",
3
- "version": "3.0.15",
3
+ "version": "3.0.17",
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": "cb9dc8d025597cc9a92ae7b3b0cba1eb73b4d71b"
26
+ "gitHead": "b9f6b4a73b15a6b7ca2eaf631915156e9af4c04b"
27
27
  }