@li0ard/playready
Simple PlayReady CDM implementation
docs
.prd deserializationnpm i @li0ard/playready
import { Device, CDM, KeyType, CipherType, PSSH } from "@li0ard/playready";
const device = Device.decode(
Buffer.from("....", "base64"),
Buffer.from("....", "base64"),
Buffer.from("....", "base64")
); // Device.fromPrd(....);
const cdm = new CDM(device);
const pssh = PSSH.decode(Buffer.from("....", "base64"));
const challenge = cdm.getLicenseChallenge(pssh.decodedPayload as string);
const license = await (await fetch(`https://test.playready.microsoft.com/service/rightsmanager.asmx?cfg=(persist:false,sl:2000)`, {
headers: {
'Content-Type': 'text/xml; charset=UTF-8'
},
method: "POST",
body: challenge
})).text();
for(const key of cdm.parseLicense(license))
console.log(`- [${KeyType[key.type]}/${CipherType[key.cipher]}] ${key.kid.toHex()}:${key.key.toHex()}`);