pssh-tools
Advanced tools
Comparing version 0.0.12 to 0.1.0-alpha1
const crypto = require('crypto') | ||
const utils = require('./tools') | ||
const tools = require('./tools') | ||
@@ -136,4 +136,4 @@ const DRM_AES_KEYSIZE_128 = 16 | ||
const data = getPsshData({ keyIds, licenseUrl, keySeed, compatibilityMode }) | ||
let psshHeader = utils.getPsshHeader({ | ||
systemId: utils.system.PLAYREADY.id, | ||
let psshHeader = tools.getPsshHeader({ | ||
systemId: tools.system.PLAYREADY.id, | ||
keyIds: keyIds, | ||
@@ -162,4 +162,15 @@ data: data | ||
const decodeData = (data) => { | ||
return tools.decodePsshData(tools.system.PLAYREADY.name, data) | ||
} | ||
const decodeKey = (keyData) => { | ||
const keyBuffer = Buffer.from(keyData, 'base64') | ||
return swapEndian(keyBuffer.toString('hex')).toString('hex') | ||
} | ||
module.exports = { | ||
encodePssh | ||
decodeData, | ||
encodePssh, | ||
decodeKey | ||
} |
const path = require('path') | ||
const protobuf = require('protobufjs') | ||
const utils = require('./tools') | ||
const tools = require('./tools') | ||
@@ -52,4 +52,4 @@ const getPsshData = ({ contentId = null, trackType = '', keyIds = [], provider = '', protectionScheme = 'cenc' }) => { | ||
}) | ||
const psshHeader = utils.getPsshHeader({ | ||
systemId: utils.system.WIDEVINE.id, | ||
const psshHeader = tools.getPsshHeader({ | ||
systemId: tools.system.WIDEVINE.id, | ||
keyIds: keyIds, | ||
@@ -78,4 +78,9 @@ data: data | ||
const decodeData = (data) => { | ||
return tools.decodePsshData(tools.system.WIDEVINE.name, data) | ||
} | ||
module.exports = { | ||
decodeData, | ||
encodePssh | ||
} |
{ | ||
"name": "pssh-tools", | ||
"version": "0.0.12", | ||
"version": "0.1.0-alpha1", | ||
"description": "Tools to generate PSSH Data and PSSH Box", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -7,3 +7,4 @@ const test = require('ava') | ||
const PSSH_TEST = 'AAAAQXBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAACESEJjp6TNjifjK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ZgB0AC4AYwBvAG0ALwBEAFIATQAvADIAMAAwADcALwAwADMALwBQAGwAYQB5AFIAZQBhAGQAeQBIAGUAYQBkAGUAcgAiACAAdgBlAHIAcwBpAG8AbgA9ACIANAAuADAALgAwAC4AMAAiAD4APABEAEEAVABBAD4APABQAFIATwBUAEUAQwBUAEkATgBGAE8APgA8AEsARQBZAEwARQBOAD4AMQA2ADwALwBLAEUAWQBMAEUATgA+ADwAQQBMAEcASQBEAD4AQQBFAFMAQwBUAFIAPAAvAEEATABHAEkARAA+ADwALwBQAFIATwBUAEUAQwBUAEkATgBGAE8APgA8AEsASQBEAD4AWgAwAFUAagBBAGEAdQBKADcAOAAwAEIASQAwAFYAbgBpAGEAdgBOADcAdwA9AD0APAAvAEsASQBEAD4APABDAEgARQBDAEsAUwBVAE0APgAwAHgAOQAxAFcARgB0AEcAWABCAEkAPQA8AC8AQwBIAEUAQwBLAFMAVQBNAD4APABMAEEAXwBVAFIATAA+AGgAdAB0AHAAOgAvAC8AdABlAHMAdAAuAHAAbABhAHkAcgBlAGEAZAB5AC4AbQBpAGMAcgBvAHMAbwBmAHQALgBjAG8AbQAvAHMAZQByAHYAaQBjAGUALwByAGkAZwBoAHQAcwBtAGEAbgBhAGcAZQByAC4AYQBzAG0AeAA8AC8ATABBAF8AVQBSAEwAPgA8AC8ARABBAFQAQQA+ADwALwBXAFIATQBIAEUAQQBEAEUAUgA+AA==' | ||
const PR_CONTENT_KEY = 'Z0UjAauJ780BI0VniavN7w==' | ||
@@ -65,3 +66,3 @@ test('Should return Widevine PSSH version 0 without KID', t => { | ||
test('Should be able to decode PlayReady PSSH data', t => { | ||
const result = pssh.tools.decodePsshData(pssh.tools.system.PLAYREADY.name, PSSH_DATA) | ||
const result = pssh.tools.decodePsshData(pssh.tools.system.PLAYREADY.name, PSSH_DATA_PR) | ||
console.log(result.recordXml) | ||
@@ -71,1 +72,8 @@ | ||
}) | ||
test('Should be able to decode PlayReady content key', t => { | ||
const result = pssh.playready.decodeKey(PR_CONTENT_KEY) | ||
console.log(`\nKey ID: ${result}\n`) | ||
t.is(result, '0123456789abcdef0123456789abcdef') | ||
}) |
24348
549