Skip to content

Commit

Permalink
feat(streamyx): support templates for json license payload
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalygashkov committed Jul 19, 2024
1 parent bc87a31 commit 5f374ef
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# streamyx-extension

## Features

- Copy **Streamyx** command to clipboard (just run command with Streamyx and get content decryption keys)

<sup><sub>Requires Streamyx >= v4.0.0-beta.45 and doesn't work with Windows Command Prompt / cmd.exe (use PowerShell instead).</sub></sup>

- Copy **PSSH** to clipboard
- Copy **license URL** to clipboard
- Block disposable tokens
16 changes: 12 additions & 4 deletions background.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const CMD_EXE_PATH = ''; // For example: streamyx.exe

const SERVERS_WITH_DISPOSABLE_TOKENS = [
's95951.cdn.ngenix.net',
's95951.cdn.ngenix.net', // Wink
'api2.hbogoasia.com/onwards-widevine',
'prepladder.com',
'scvm1sc0.anycast.nagra.com',
Expand Down Expand Up @@ -34,10 +34,15 @@ function requestToClipboard(tabId) {
var i = 0;
let command = `${CMD_EXE_PATH} `;
command += `"${lic_url}"`;
for (; i < lic_headers.length; ++i)
command += ` -H "${lic_headers[i].name.toLowerCase()}: ${lic_headers[i].value.replaceAll(`"`, `'`)}"`;
for (; i < lic_headers.length; ++i) {
const { name, value } = lic_headers[i];
if (name.toLowerCase() === 'origin') continue;
command += ` -H "${name.toLowerCase()}: ${value.replaceAll(`"`, `\\"`)}"`;
}
if (!ip_resposnse.includes('403 Forbidden')) command += ` -H "x-forwarded-for: ${ip_resposnse}"`;
command += ` --pssh ${widevine_pssh}`;
if (lic_data_json && lic_data_json.startsWith('{'))
command += ` --drm-template "${lic_data_json.replaceAll(`"`, `\\"`)}"`;

const notificationId = `${widevine_pssh}`;
chrome.notifications.create(notificationId, {
Expand Down Expand Up @@ -97,7 +102,10 @@ function getLicenseRequestData(details) {
(details.url.includes('license') && decodedString.includes('token') && decodedString.length > 4000) ||
decodedString.includes('8,1,18')
) {
tabIDs[details.tabId].license_data = decodedString;
const challengePart = decodedString.split('"CAES')[1]?.split('"')[0];
const challenge = 'CAES' + challengePart;
const licenseTemplate = decodedString.replace(challenge, '{{challenge}}');
tabIDs[details.tabId].license_data = challengePart ? licenseTemplate : decodedString;
tabIDs[details.tabId].license_url = details.url;
tabIDs[details.tabId].req_id = details.requestId;
} else {
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Streamyx",
"version": "0.0.4",
"version": "0.0.5",
"manifest_version": 2,
"background": {
"scripts": ["background.js"]
Expand Down

0 comments on commit 5f374ef

Please sign in to comment.