Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed pairing for TV models that only expose system endpoint on secured port #41

Open
wants to merge 1 commit into
base: feature/upgrade
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 23 additions & 15 deletions lib/Jointspace/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -426,24 +426,32 @@ class Client {
// some newer models which use port 1926 still only listen
// on port 1925 for the system endpoint
return this.request("system", "GET", {}, {}, 1925, false, false).then(response => {
const encryptedAttributes = [
'serialnumber',
'softwareversion',
'model',
'deviceid',
];

encryptedAttributes.forEach((attribute) => {
if (typeof response[attribute + '_encrypted'] !== "undefined") {
try {
response[attribute] = AES.decrypt(decryptionKeyBase64, ivBase64, response[attribute + '_encrypted'].trim());
} catch (e) {
}
if (response === "") {
// system endpoint for some TV models only works on https://<IP>:1926/system (on http://<IP>:1925/system receives HTTP 200 with empty response)
return this.request("system", "GET", {}, {}, 1926, true, false).then(r => this.decryptEncryptedAttributesInResponse(r));
}
});
return this.decryptEncryptedAttributesInResponse(response);
})
}

return response;
decryptEncryptedAttributesInResponse(response) {
const encryptedAttributes = [
'serialnumber',
'softwareversion',
'model',
'deviceid',
];

encryptedAttributes.forEach((attribute) => {
if (typeof response[attribute + '_encrypted'] !== "undefined") {
try {
response[attribute] = AES.decrypt(decryptionKeyBase64, ivBase64, response[attribute + '_encrypted'].trim());
} catch (e) {
}
}
});

return response;
}

getApplications() {
Expand Down