Add manifest URL field, reset keys when manifest changes, organize repo, update to Manifest v3 #3

Open
voldemort wants to merge 26 commits from voldemort/CDRM-Extension:main into main
Showing only changes of commit a40a6abaf7 - Show all commits

View File

@ -556,23 +556,32 @@ function ensureRemoteCDM(type, deviceInfo, pssh) {
} }
} }
function detectAndStorePssh(initData) {
const detections = [
{
type: "PlayReady",
getter: getPlayReadyPssh,
store: (pssh) => (foundPlayreadyPssh = pssh),
},
{ type: "Widevine", getter: getWidevinePssh, store: (pssh) => (foundWidevinePssh = pssh) },
];
detections.forEach(({ type, getter, store }) => {
const pssh = getter(initData);
if (pssh) {
logWithPrefix(`[DRM Detected] ${type}`);
store(pssh);
logWithPrefix(`[${type} PSSH found] ${pssh}`);
}
});
}
// Challenge generator interceptor // Challenge generator interceptor
const originalGenerateRequest = MediaKeySession.prototype.generateRequest; const originalGenerateRequest = MediaKeySession.prototype.generateRequest;
MediaKeySession.prototype.generateRequest = function (initDataType, initData) { MediaKeySession.prototype.generateRequest = function (initDataType, initData) {
const session = this; const session = this;
let playReadyPssh = getPlayReadyPssh(initData); detectAndStorePssh(initData);
if (playReadyPssh) {
logWithPrefix("[DRM Detected] PlayReady");
foundPlayreadyPssh = playReadyPssh;
logWithPrefix("[PlayReady PSSH found] " + playReadyPssh);
}
let wideVinePssh = getWidevinePssh(initData);
if (wideVinePssh) {
// Widevine code
logWithPrefix("[DRM Detected] Widevine");
foundWidevinePssh = wideVinePssh;
logWithPrefix("[Widevine PSSH found] " + wideVinePssh);
}
// Challenge message interceptor // Challenge message interceptor
if (!remoteListenerMounted) { if (!remoteListenerMounted) {
remoteListenerMounted = true; remoteListenerMounted = true;