@lumiastream/tapo-cove 3.0.22 → 3.1.0

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/CHANGELOG.md ADDED
@@ -0,0 +1,10 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
+
6
+ # [3.1.0](https://github.com/lumiastream/rgb/compare/v3.0.15...v3.1.0) (2023-03-21)
7
+
8
+ ### Bug Fixes
9
+
10
+ - tapo using promise.all instead of allsettled ([a6dc480](https://github.com/lumiastream/rgb/commit/a6dc480f86cc129535b6eac7bf1acdc5cdff06b6))
package/dist/index.d.ts CHANGED
@@ -96,7 +96,6 @@ declare class TapoApi {
96
96
  };
97
97
  state: LightState;
98
98
  fetchConfig?: {
99
- useAxios: boolean;
100
99
  shouldWait: boolean;
101
100
  };
102
101
  }) => Promise<any>;
@@ -105,10 +104,6 @@ declare class TapoApi {
105
104
  id: string;
106
105
  };
107
106
  power: boolean;
108
- fetchConfig?: {
109
- useAxios: boolean;
110
- shouldWait: boolean;
111
- };
112
107
  }) => void;
113
108
  }
114
109
 
package/dist/index.js CHANGED
@@ -163,6 +163,7 @@ var throwErrorIfFound = (responseData) => {
163
163
  }
164
164
  };
165
165
  var handshake = (deviceIp) => __async(void 0, null, function* () {
166
+ var _a, _b;
166
167
  const keyPair = yield generateKeyPair();
167
168
  const handshakeRequest = {
168
169
  method: "handshake",
@@ -170,7 +171,7 @@ var handshake = (deviceIp) => __async(void 0, null, function* () {
170
171
  key: keyPair.publicKey
171
172
  }
172
173
  };
173
- const response = yield (0, import_axios.default)({
174
+ const response = yield (globalThis.nodeAxios ? globalThis.nodeAxios : import_axios.default)({
174
175
  method: "post",
175
176
  url: `http://${deviceIp}/app`,
176
177
  data: handshakeRequest
@@ -178,9 +179,7 @@ var handshake = (deviceIp) => __async(void 0, null, function* () {
178
179
  throwErrorIfFound(response.data);
179
180
  let setCookieHeader;
180
181
  if (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"];
182
+ setCookieHeader = (_b = (_a = response.headers["set-cookie"]) == null ? void 0 : _a[0]) != null ? _b : response.headers["set-cookie"];
184
183
  } else {
185
184
  setCookieHeader = response.headers.get("set-cookie");
186
185
  }
@@ -206,7 +205,6 @@ var securePassthrough = (deviceRequest, deviceKey) => __async(void 0, null, func
206
205
  url: `http://${deviceKey.deviceIp}/app?token=${deviceKey.token}`,
207
206
  data: securePassthroughRequest,
208
207
  headers: {
209
- BypassCookie: deviceKey.sessionCookie,
210
208
  Cookie: deviceKey.sessionCookie
211
209
  }
212
210
  });
@@ -383,12 +381,11 @@ var TapoApi = class {
383
381
  this._devices.set(device.id, deviceKey);
384
382
  return;
385
383
  }));
386
- yield Promise.all(promises);
384
+ yield Promise.allSettled(promises);
387
385
  return this._devices;
388
386
  });
389
387
  // Change state using lightstate
390
388
  this.sendState = (config) => {
391
- var _a;
392
389
  const deviceKey = this._devices.get(config.device.id);
393
390
  let shouldWait = false;
394
391
  if (config.fetchConfig && config.fetchConfig.shouldWait) {
@@ -410,35 +407,20 @@ var TapoApi = class {
410
407
  request: encryptedRequest
411
408
  }
412
409
  };
413
- if ((_a = config.fetchConfig) == null ? void 0 : _a.useAxios) {
414
- return this.axiosInstance({
415
- url: `http://${deviceKey.deviceIp}/app?token=${deviceKey.token}`,
416
- data: {
417
- method: "POST",
418
- body: securePassthroughRequest,
419
- headers: {
420
- BypassCookie: deviceKey.sessionCookie,
421
- Cookie: deviceKey.sessionCookie
422
- }
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
423
417
  }
424
- });
425
- } else {
426
- return (0, import_fetch_cove.fetchWork)({
427
- url: `http://${deviceKey.deviceIp}/app?token=${deviceKey.token}`,
428
- data: {
429
- method: "POST",
430
- body: securePassthroughRequest,
431
- headers: {
432
- BypassCookie: deviceKey.sessionCookie,
433
- Cookie: deviceKey.sessionCookie
434
- }
435
- },
436
- shouldWait
437
- });
438
- }
418
+ },
419
+ shouldWait
420
+ });
439
421
  };
440
422
  this.sendPower = (config) => {
441
- this.sendState({ device: config.device, state: new LightState({ on: config.power }), fetchConfig: config.fetchConfig });
423
+ this.sendState({ device: config.device, state: new LightState({ on: config.power }) });
442
424
  };
443
425
  this.axiosInstance = import_axios2.default.create();
444
426
  this.axiosInstance.defaults.timeout = (config == null ? void 0 : config.httpTimeout) || 4e3;
package/dist/index.mjs CHANGED
@@ -131,6 +131,7 @@ var throwErrorIfFound = (responseData) => {
131
131
  }
132
132
  };
133
133
  var handshake = (deviceIp) => __async(void 0, null, function* () {
134
+ var _a, _b;
134
135
  const keyPair = yield generateKeyPair();
135
136
  const handshakeRequest = {
136
137
  method: "handshake",
@@ -138,7 +139,7 @@ var handshake = (deviceIp) => __async(void 0, null, function* () {
138
139
  key: keyPair.publicKey
139
140
  }
140
141
  };
141
- const response = yield axios({
142
+ const response = yield (globalThis.nodeAxios ? globalThis.nodeAxios : axios)({
142
143
  method: "post",
143
144
  url: `http://${deviceIp}/app`,
144
145
  data: handshakeRequest
@@ -146,9 +147,7 @@ var handshake = (deviceIp) => __async(void 0, null, function* () {
146
147
  throwErrorIfFound(response.data);
147
148
  let setCookieHeader;
148
149
  if (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"];
150
+ setCookieHeader = (_b = (_a = response.headers["set-cookie"]) == null ? void 0 : _a[0]) != null ? _b : response.headers["set-cookie"];
152
151
  } else {
153
152
  setCookieHeader = response.headers.get("set-cookie");
154
153
  }
@@ -174,7 +173,6 @@ var securePassthrough = (deviceRequest, deviceKey) => __async(void 0, null, func
174
173
  url: `http://${deviceKey.deviceIp}/app?token=${deviceKey.token}`,
175
174
  data: securePassthroughRequest,
176
175
  headers: {
177
- BypassCookie: deviceKey.sessionCookie,
178
176
  Cookie: deviceKey.sessionCookie
179
177
  }
180
178
  });
@@ -351,12 +349,11 @@ var TapoApi = class {
351
349
  this._devices.set(device.id, deviceKey);
352
350
  return;
353
351
  }));
354
- yield Promise.all(promises);
352
+ yield Promise.allSettled(promises);
355
353
  return this._devices;
356
354
  });
357
355
  // Change state using lightstate
358
356
  this.sendState = (config) => {
359
- var _a;
360
357
  const deviceKey = this._devices.get(config.device.id);
361
358
  let shouldWait = false;
362
359
  if (config.fetchConfig && config.fetchConfig.shouldWait) {
@@ -378,35 +375,20 @@ var TapoApi = class {
378
375
  request: encryptedRequest
379
376
  }
380
377
  };
381
- if ((_a = config.fetchConfig) == null ? void 0 : _a.useAxios) {
382
- return this.axiosInstance({
383
- url: `http://${deviceKey.deviceIp}/app?token=${deviceKey.token}`,
384
- data: {
385
- method: "POST",
386
- body: securePassthroughRequest,
387
- headers: {
388
- BypassCookie: deviceKey.sessionCookie,
389
- Cookie: deviceKey.sessionCookie
390
- }
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
391
385
  }
392
- });
393
- } else {
394
- return fetchWork({
395
- url: `http://${deviceKey.deviceIp}/app?token=${deviceKey.token}`,
396
- data: {
397
- method: "POST",
398
- body: securePassthroughRequest,
399
- headers: {
400
- BypassCookie: deviceKey.sessionCookie,
401
- Cookie: deviceKey.sessionCookie
402
- }
403
- },
404
- shouldWait
405
- });
406
- }
386
+ },
387
+ shouldWait
388
+ });
407
389
  };
408
390
  this.sendPower = (config) => {
409
- this.sendState({ device: config.device, state: new LightState({ on: config.power }), fetchConfig: config.fetchConfig });
391
+ this.sendState({ device: config.device, state: new LightState({ on: config.power }) });
410
392
  };
411
393
  this.axiosInstance = axios2.create();
412
394
  this.axiosInstance.defaults.timeout = (config == null ? void 0 : config.httpTimeout) || 4e3;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lumiastream/tapo-cove",
3
- "version": "3.0.22",
3
+ "version": "3.1.0",
4
4
  "private": false,
5
5
  "license": "GPL",
6
6
  "main": "dist/index.js",
@@ -13,7 +13,7 @@
13
13
  "dependencies": {
14
14
  "@lumiastream/fetch-cove": "^3.0.9",
15
15
  "@lumiastream/lumia-rgb-types": "^3.0.9",
16
- "@lumiastream/lumia-rgb-utils": "^3.0.9",
16
+ "@lumiastream/lumia-rgb-utils": "^3.1.0",
17
17
  "axios": "*",
18
18
  "local-devices": "^4.0.0"
19
19
  },
@@ -23,5 +23,5 @@
23
23
  "tsup": "*",
24
24
  "typescript": "*"
25
25
  },
26
- "gitHead": "2d3e359dd1202a90f0f91210b0a30ace3c24a5ad"
26
+ "gitHead": "a92d37d1e70b976c06f10ad8f18d0c7aaa325e02"
27
27
  }