New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

pssh-tools

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pssh-tools - npm Package Compare versions

Comparing version 0.0.10 to 0.0.11

81

lib/pssh/tools.js

@@ -151,39 +151,8 @@ const path = require('path')

systemName = system.WIDEVINE.name
// cenc header
let header = decodeWidevineHeader(psshData)
let wvData = {}
if (header.keyId && header.keyId.length > 0) {
widevineKeyCount = header.keyId.length
let decodedKeys = header.keyId.map((key) => {
return Buffer.from(key, 'base64').toString('hex')
})
wvData.keyId = decodedKeys
}
if (header.provider) {
wvData.provider = header.provider
}
if (header.contentId) {
wvData.contentId = Buffer.from(header.contentId, 'base64').toString('hex').toUpperCase()
}
result.dataObject = wvData
result.dataObject = decodeWVData(psshData)
widevineKeyCount = result.dataObject.widevineKeyCount || 0
break
case system.PLAYREADY.id:
systemName = system.PLAYREADY.name
// pro header
let proHeader = Buffer.alloc(10)
psshData.copy(proHeader, 0, 0, 10)
let proHeaderLength = proHeader.readInt32LE(0)
// let proRecordCount = proHeader.readInt16LE(4)
let proRecordType = proHeader.readInt16LE(6)
let proDataLength = proHeader.readInt16LE(8)
let proData = Buffer.alloc(proDataLength)
psshData.copy(proData, 0, 10, proHeaderLength)
result.dataObject = {
recordSize: proDataLength,
recordType: proRecordType,
recordXml: proData.toString('utf8')
}
result.dataObject = decodePRData(psshData)
break

@@ -270,2 +239,42 @@ case system.MARLIN.id:

const decodeWVData = (psshData) => {
// cenc header
let header = decodeWidevineHeader(psshData)
let wvData = {}
if (header.keyId && header.keyId.length > 0) {
wvData.widevineKeyCount = header.keyId.length
let decodedKeys = header.keyId.map((key) => {
return Buffer.from(key, 'base64').toString('hex')
})
wvData.keyId = decodedKeys
}
if (header.provider) {
wvData.provider = header.provider
}
if (header.contentId) {
wvData.contentId = Buffer.from(header.contentId, 'base64').toString('hex').toUpperCase()
}
return wvData
}
const decodePRData = (psshData) => {
// pro header
let proHeader = Buffer.alloc(10)
psshData.copy(proHeader, 0, 0, 10)
let proHeaderLength = proHeader.readInt32LE(0)
// let proRecordCount = proHeader.readInt16LE(4)
let proRecordType = proHeader.readInt16LE(6)
let proDataLength = proHeader.readInt16LE(8)
let proData = Buffer.alloc(proDataLength)
psshData.copy(proData, 0, 10, proHeaderLength)
return {
recordSize: proDataLength,
recordType: proRecordType,
recordXml: proData.toString('utf8')
}
}
const stringHexToGuid = (value) => {

@@ -284,3 +293,5 @@ var guidArray = []

getPsshHeader,
decodePssh
decodePssh,
decodePRData,
decodeWVData
}
{
"name": "pssh-tools",
"version": "0.0.10",
"version": "0.0.11",
"description": "Tools to generate PSSH Data and PSSH Box",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -7,2 +7,3 @@ const test = require('ava')

const PSSH_TEST = 'AAAAQXBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAACESEJjp6TNjifjKjuoDBeg+VrUaCmludGVydHJ1c3QiASo='
const PSSH_DATA = 'pAIAAAEAAQCaAjwAVwBSAE0ASABFAEEARABFAFIAIAB4AG0AbABuAHMAPQAiAGgAdAB0AHAAOgAvAC8AcwBjAGgAZQBtAGEAcwAuAG0AaQBjAHIAbwBzAG8AZgB0AC4AYwBvAG0ALwBEAFIATQAvADIAMAAwADcALwAwADMALwBQAGwAYQB5AFIAZQBhAGQAeQBIAGUAYQBkAGUAcgAiACAAdgBlAHIAcwBpAG8AbgA9ACIANAAuADAALgAwAC4AMAAiAD4APABEAEEAVABBAD4APABQAFIATwBUAEUAQwBUAEkATgBGAE8APgA8AEsARQBZAEwARQBOAD4AMQA2ADwALwBLAEUAWQBMAEUATgA+ADwAQQBMAEcASQBEAD4AQQBFAFMAQwBUAFIAPAAvAEEATABHAEkARAA+ADwALwBQAFIATwBUAEUAQwBUAEkATgBGAE8APgA8AEsASQBEAD4AWgAwAFUAagBBAGEAdQBKADcAOAAwAEIASQAwAFYAbgBpAGEAdgBOADcAdwA9AD0APAAvAEsASQBEAD4APABDAEgARQBDAEsAUwBVAE0APgAwAHgAOQAxAFcARgB0AEcAWABCAEkAPQA8AC8AQwBIAEUAQwBLAFMAVQBNAD4APABMAEEAXwBVAFIATAA+AGgAdAB0AHAAOgAvAC8AdABlAHMAdAAuAHAAbABhAHkAcgBlAGEAZAB5AC4AbQBpAGMAcgBvAHMAbwBmAHQALgBjAG8AbQAvAHMAZQByAHYAaQBjAGUALwByAGkAZwBoAHQAcwBtAGEAbgBhAGcAZQByAC4AYQBzAG0AeAA8AC8ATABBAF8AVQBSAEwAPgA8AC8ARABBAFQAQQA+ADwALwBXAFIATQBIAEUAQQBEAEUAUgA+AA=='

@@ -62,1 +63,8 @@ test('Should return Widevine PSSH version 0 without KID', t => {

})
test('Should be able to decode PlayReady PSSH data', t => {
const result = pssh.tools.decodePRData(Buffer.from(PSSH_DATA, 'base64'))
console.log(result.recordXml)
t.not(result.length, 0)
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc