+ Fixed video being allowed to play when the keys were already retrieved

This commit is contained in:
BuildTools
2024-10-23 09:56:02 +02:00
parent ba51922445
commit 91ceed8741
4 changed files with 27 additions and 16 deletions

View File

@@ -3,7 +3,14 @@ import "./license_protocol.js";
import "./forge.min.js";
import { Session } from "./license.js";
import { DeviceManager, base64toUint8Array, uint8ArrayToBase64, uint8ArrayToHex, SettingsManager, AsyncLocalStorage } from "./util.js";
import {
DeviceManager,
base64toUint8Array,
uint8ArrayToBase64,
uint8ArrayToHex,
SettingsManager,
AsyncLocalStorage
} from "./util.js";
import { WidevineDevice } from "./device.js";
const { LicenseType, SignedMessage, LicenseRequest, License } = protobuf.roots.default.license_protocol;
@@ -34,7 +41,7 @@ chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
return;
}
if (logs.filter(log => log.pssh_data === uint8ArrayToBase64(pssh_data)).length > 0) {
if (logs.filter(log => log.pssh_data === Session.psshDataToPsshBoxB64(pssh_data)).length > 0) {
console.log("[WidevineProxy2]", `KEYS_ALREADY_RETRIEVED: ${uint8ArrayToBase64(pssh_data)}`);
sendResponse(message.body);
return;

View File

@@ -5,7 +5,7 @@ import {
uint8ArrayToString,
stringToUint8Array,
stringToHex,
base64toUint8Array, uint8ArrayToBase64
base64toUint8Array, uint8ArrayToBase64, intToUint8Array
} from "./util.js"
const { ClientIdentification, DrmCertificate, EncryptedClientIdentification, License, LicenseRequest, LicenseType,
ProtocolVersion, SignedDrmCertificate, SignedMessage, WidevinePsshData } = protobuf.roots.default.license_protocol;
@@ -365,24 +365,21 @@ export class Session {
return forge.random.getBytesSync(16)
}
_intToUint8Array(num) {
const buffer = new ArrayBuffer(4);
const view = new DataView(buffer);
view.setUint32(0, num, false);
return new Uint8Array(buffer);
}
getPSSH() {
const dataLength = this._pssh.length;
static psshDataToPsshBoxB64(pssh_data) {
const dataLength = pssh_data.length;
const totalLength = dataLength + 32;
const pssh = new Uint8Array([
...this._intToUint8Array(totalLength),
...intToUint8Array(totalLength),
...PSSH_MAGIC,
...new Uint8Array(4),
...WIDEVINE_SYSTEM_ID,
...this._intToUint8Array(dataLength),
...this._pssh
...intToUint8Array(dataLength),
...pssh_data
]);
return uint8ArrayToBase64(pssh);
}
getPSSH() {
return Session.psshDataToPsshBoxB64(this._pssh)
}
}

View File

@@ -1,7 +1,7 @@
{
"manifest_version": 3,
"name": "WidevineProxy2",
"version": "0.3",
"version": "0.4",
"permissions": [
"activeTab",
"tabs",

View File

@@ -182,6 +182,13 @@ export class SettingsManager {
}
}
export function intToUint8Array(num) {
const buffer = new ArrayBuffer(4);
const view = new DataView(buffer);
view.setUint32(0, num, false);
return new Uint8Array(buffer);
}
export function compareUint8Arrays(arr1, arr2) {
if (arr1.length !== arr2.length)
return false;