@lumiastream/tapo-cove 3.0.13 → 3.0.15
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.js +9 -4
- package/dist/index.mjs +9 -4
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -163,7 +163,7 @@ var throwErrorIfFound = (responseData) => {
|
|
|
163
163
|
}
|
|
164
164
|
};
|
|
165
165
|
var handshake = (deviceIp) => __async(void 0, null, function* () {
|
|
166
|
-
var _a, _b
|
|
166
|
+
var _a, _b;
|
|
167
167
|
const keyPair = yield generateKeyPair();
|
|
168
168
|
const handshakeRequest = {
|
|
169
169
|
method: "handshake",
|
|
@@ -171,13 +171,18 @@ var handshake = (deviceIp) => __async(void 0, null, function* () {
|
|
|
171
171
|
key: keyPair.publicKey
|
|
172
172
|
}
|
|
173
173
|
};
|
|
174
|
-
const response = yield (
|
|
174
|
+
const response = yield (globalThis.nodeAxios ? globalThis.nodeAxios : import_axios.default)({
|
|
175
175
|
method: "post",
|
|
176
176
|
url: `http://${deviceIp}/app`,
|
|
177
177
|
data: handshakeRequest
|
|
178
178
|
});
|
|
179
179
|
throwErrorIfFound(response.data);
|
|
180
|
-
|
|
180
|
+
let setCookieHeader;
|
|
181
|
+
if (response.headers["set-cookie"]) {
|
|
182
|
+
setCookieHeader = (_b = (_a = response.headers["set-cookie"]) == null ? void 0 : _a[0]) != null ? _b : response.headers["set-cookie"];
|
|
183
|
+
} else {
|
|
184
|
+
setCookieHeader = response.headers.get("set-cookie");
|
|
185
|
+
}
|
|
181
186
|
const sessionCookie = setCookieHeader.substring(0, setCookieHeader.indexOf(";"));
|
|
182
187
|
const deviceKey = readDeviceKey(response.data.result.key, keyPair.privateKey);
|
|
183
188
|
return {
|
|
@@ -195,7 +200,7 @@ var securePassthrough = (deviceRequest, deviceKey) => __async(void 0, null, func
|
|
|
195
200
|
request: encryptedRequest
|
|
196
201
|
}
|
|
197
202
|
};
|
|
198
|
-
const response = yield (
|
|
203
|
+
const response = yield (globalThis.nodeAxios ? globalThis.nodeAxios : import_axios.default)({
|
|
199
204
|
method: "post",
|
|
200
205
|
url: `http://${deviceKey.deviceIp}/app?token=${deviceKey.token}`,
|
|
201
206
|
data: securePassthroughRequest,
|
package/dist/index.mjs
CHANGED
|
@@ -131,7 +131,7 @@ var throwErrorIfFound = (responseData) => {
|
|
|
131
131
|
}
|
|
132
132
|
};
|
|
133
133
|
var handshake = (deviceIp) => __async(void 0, null, function* () {
|
|
134
|
-
var _a, _b
|
|
134
|
+
var _a, _b;
|
|
135
135
|
const keyPair = yield generateKeyPair();
|
|
136
136
|
const handshakeRequest = {
|
|
137
137
|
method: "handshake",
|
|
@@ -139,13 +139,18 @@ var handshake = (deviceIp) => __async(void 0, null, function* () {
|
|
|
139
139
|
key: keyPair.publicKey
|
|
140
140
|
}
|
|
141
141
|
};
|
|
142
|
-
const response = yield axios({
|
|
142
|
+
const response = yield (globalThis.nodeAxios ? globalThis.nodeAxios : axios)({
|
|
143
143
|
method: "post",
|
|
144
144
|
url: `http://${deviceIp}/app`,
|
|
145
145
|
data: handshakeRequest
|
|
146
146
|
});
|
|
147
147
|
throwErrorIfFound(response.data);
|
|
148
|
-
|
|
148
|
+
let setCookieHeader;
|
|
149
|
+
if (response.headers["set-cookie"]) {
|
|
150
|
+
setCookieHeader = (_b = (_a = response.headers["set-cookie"]) == null ? void 0 : _a[0]) != null ? _b : response.headers["set-cookie"];
|
|
151
|
+
} else {
|
|
152
|
+
setCookieHeader = response.headers.get("set-cookie");
|
|
153
|
+
}
|
|
149
154
|
const sessionCookie = setCookieHeader.substring(0, setCookieHeader.indexOf(";"));
|
|
150
155
|
const deviceKey = readDeviceKey(response.data.result.key, keyPair.privateKey);
|
|
151
156
|
return {
|
|
@@ -163,7 +168,7 @@ var securePassthrough = (deviceRequest, deviceKey) => __async(void 0, null, func
|
|
|
163
168
|
request: encryptedRequest
|
|
164
169
|
}
|
|
165
170
|
};
|
|
166
|
-
const response = yield axios({
|
|
171
|
+
const response = yield (globalThis.nodeAxios ? globalThis.nodeAxios : axios)({
|
|
167
172
|
method: "post",
|
|
168
173
|
url: `http://${deviceKey.deviceIp}/app?token=${deviceKey.token}`,
|
|
169
174
|
data: securePassthroughRequest,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lumiastream/tapo-cove",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.15",
|
|
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": "
|
|
26
|
+
"gitHead": "cb9dc8d025597cc9a92ae7b3b0cba1eb73b4d71b"
|
|
27
27
|
}
|