Comparing version 0.0.4 to 0.0.5
{ | ||
"name": "tl-api", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"type": "module", | ||
@@ -8,3 +8,3 @@ "description": "TPLink Router API", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "node --test" | ||
}, | ||
@@ -24,4 +24,10 @@ "files": [ | ||
"cgi_gdpr", | ||
"archer", | ||
"tl-archer", | ||
"vr900v", | ||
"mr6400", | ||
"tl-mr6400", | ||
"archer-vr900v", | ||
"tl-archer-vr900v", | ||
"tl-vr900v", | ||
"tplink sms", | ||
@@ -33,7 +39,7 @@ "sms" | ||
"dependencies": { | ||
"undici": "5.10.0" | ||
"undici": "5.22.1" | ||
}, | ||
"devDependencies": { | ||
"prettier": "^2.7.1" | ||
"prettier": "2.8.8" | ||
} | ||
} |
@@ -62,2 +62,23 @@ # TP-Link Router API (EU GDPR versions) | ||
You can login into your router and hook into data encrypt and decrypt methods with the following snippet. | ||
```javascript | ||
$.Iencryptor.AESDecrypt_backup = $.Iencryptor.AESDecrypt; | ||
$.Iencryptor.AESEncrypt_backup = $.Iencryptor.AESEncrypt; | ||
$.Iencryptor.AESDecrypt = function(data) { | ||
let decrypted = $.Iencryptor.AESDecrypt_backup(data); | ||
console.log("RECV:\n" + decrypted); | ||
return decrypted; | ||
} | ||
$.Iencryptor.AESEncrypt = function(data) { | ||
console.log("SEND:\n" + data); | ||
return $.Iencryptor.AESEncrypt_backup(data); | ||
} | ||
``` | ||
This will log `RECV:` & `SEND:` message before encrypting and decrypting payload, and you can take a note of `<actionType>`, `<actionOperationId>`, `<actionAttributesOrFields>`, `<stack>`, `<pStack>` values after you perform specific actions in the UI. | ||
You can see some values described in this document in the Example section and also in `example.js`. | ||
#### Format: | ||
@@ -64,0 +85,0 @@ |
import { fetch } from "./fetch.js"; | ||
export const _extractVariables = (js) => { | ||
return js | ||
.split("\n") | ||
.map((line) => line.trim()) | ||
.filter((line) => line.length) | ||
.reduce( | ||
(acc, line) => { | ||
switch (true) { | ||
case line.startsWith("var ee="): | ||
acc.exponent = line.slice(8, -2); | ||
break; | ||
case line.startsWith("var nn="): | ||
acc.modulus = line.slice(8, -2); | ||
break; | ||
case line.startsWith("var seq="): | ||
acc.sequence = line.slice(9, -2); | ||
break; | ||
} | ||
return acc; | ||
}, | ||
{ exponent: "", modulus: "", sequence: "" } | ||
); | ||
}; | ||
export const fetchPublicKey = async (baseUrl) => { | ||
@@ -10,9 +34,10 @@ const res = await fetch(new URL("cgi/getParm", baseUrl).href, { | ||
const js = await res.text(); | ||
const [eeLine, nnLine, , seqLine] = js.split("\n").map((s) => s.trim()); | ||
const { exponent, modulus, sequence } = _extractVariables(js); | ||
return { | ||
exponent: Buffer.from(eeLine.slice(8, -2), "hex"), | ||
modulus: Buffer.from(nnLine.slice(8, -2), "hex"), | ||
sequence: Number(seqLine.slice(9, -2)), | ||
exponent: Buffer.from(exponent, "hex"), | ||
modulus: Buffer.from(modulus, "hex"), | ||
sequence: Number(sequence), | ||
}; | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
20183
450
2
145
+ Addedbusboy@1.6.0(transitive)
+ Addedstreamsearch@1.1.0(transitive)
+ Addedundici@5.22.1(transitive)
- Removedundici@5.10.0(transitive)
Updatedundici@5.22.1