@svta/cml-drm 1.1.6 → 1.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -14
- package/dist/index.js.map +1 -1
- package/dist/tsdoc-metadata.json +1 -1
- package/package.json +4 -4
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/common/ContentProtection.ts","../src/cenc/findCencContentProtection.ts","../src/cenc/getLicenseServerUrlFromContentProtection.ts","../src/cenc/getPsshData.ts","../src/cenc/getPsshForKeySystem.ts","../src/cenc/parseInitDataFromContentProtection.ts","../src/cenc/parsePsshList.ts","../src/keysystem/createMediaKeySystemConfiguration.ts","../src/common/MediaKeySystemAccessRequest.ts","../src/keysystem/getKeySystemAccess.ts","../src/keysystem/getLegacyKeySystemAccess.ts","../src/keysystem/getSupportedKeySystemConfiguration.ts","../src/fairplay/concatInitDataIdAndCertificate.ts","../src/fairplay/decodeFairPlayLicense.ts","../src/fairplay/extractContentId.ts","../src/fairplay/getId.ts","../src/fairplay/getLicenseServerUrl.ts","../src/playready/getLicenseRequestFromMessage.ts","../src/playready/getRequestHeadersFromMessage.ts","../src/playready/toBigEndianKeyId.ts","../src/common/LicenseRequest.ts","../src/common/CBCS.ts","../src/common/CENC.ts","../src/common/CHALLENGE.ts","../src/common/CLEAR_KEY_SYSTEM.ts","../src/common/CLEAR_KEY_UUID.ts","../src/common/CONTENT_TYPE.ts","../src/common/EncryptionScheme.ts","../src/common/EXPIRED.ts","../src/common/FAIRPLAY_KEY_SYSTEM.ts","../src/common/FAIRPLAY_UUID.ts","../src/common/HTTP_HEADERS.ts","../src/common/HW_SECURE_ALL.ts","../src/common/HW_SECURE_CRYPTO.ts","../src/common/HW_SECURE_DECODE.ts","../src/common/INDIVIDUALIZATION_REQUEST.ts","../src/common/KEYIDS.ts","../src/common/WEBM.ts","../src/common/InitializationDataType.ts","../src/common/INTERNAL_ERROR.ts","../src/common/LICENSE_ACQUISITION.ts","../src/common/LICENSE_RELEASE.ts","../src/common/LICENSE_RENEWAL.ts","../src/common/LICENSE_REQUEST.ts","../src/common/MediaKeyMessageType.ts","../src/common/OUTPUT_DOWNSCALED.ts","../src/common/OUTPUT_RESTRICTED.ts","../src/common/RELEASED.ts","../src/common/STATUS_PENDING.ts","../src/common/USABLE.ts","../src/common/MediaKeyStatus.ts","../src/common/MP4_PROTECTION_SCHEME.ts","../src/common/PLAYREADY_KEY_MESSAGE.ts","../src/common/PLAYREADY_KEY_SYSTEM.ts","../src/common/PLAYREADY_RECOMMENDATION_KEY_SYSTEM.ts","../src/common/PLAYREADY_UUID.ts","../src/common/SW_SECURE_CRYPTO.ts","../src/common/SW_SECURE_DECODE.ts","../src/common/TEXT_XML_UTF8.ts","../src/common/W3C_CLEAR_KEY_UUID.ts","../src/common/WIDEVINE_KEY_SYSTEM.ts","../src/common/WIDEVINE_UUID.ts","../src/common/WidevineRobustness.ts","../src/ensureEncryptedInit.ts"],"sourcesContent":[],"mappings":";;;;;;;AAKA;;KAAY,iBAAA;;ECWZ,KAAgB,CAAA,EAAA,MAAA;;;;;;;;ADXhB;;;;ACWA;;;;ACFA;iBDEgB,yBAAA,UAAmC,sBAAsB;;;;;ADXzE;;;;ACWA;;;;ACFA;;iBAAgB,wCAAA,4BACY;;;;;;AFV5B;;;;ACWA;;;;ACFgB,iBCHA,WAAA,CDGA,IAAA,ECHkB,eDGlB,CACY,ECJwB,eDIxB;;;;;;AFV5B;;;;ACWA;;;;ACFA;;iBECgB,mBAAA,yBAEL,kBACR;;;;;AJbH;;;;ACWA;;;;ACFA;;;iBGCgB,kCAAA,SACP;EFLT,WAAgB,EAAA,CAAA,KAAA,EAAA,MAAA,EAAkB,GEMS,UFNT;IEO/B;;;;;;ALbH;;;;ACWA;;;;ACFA;;;iBIEgB,aAAA,OAAoB,kBAAkB,eAAe;AHLrD,iBGMA,aAAA,CHNkB,IAAA,EGME,UHNgB,CAAA,EGMH,MHNG,CAAA,MAAA,EGMY,UHNZ,CAAA;;;;;;AHNpD;;;;ACWA;;;;ACFA;iBKFgB,iCAAA,iBACC,wDACA,yCACd;;;;;;APVH;;;KQCY,2BAAA;EPUZ,SAAgB,EAAA,MAAA;kBORC;;;;;;ARHjB;;;;ACWA;;iBQNsB,kBAAA,WACX,gCACR,QAAQ;;;;;ATPX;;;;ACWA;;iBSJgB,wBAAA,WACL,gCACR;;;;;;AVTH;;;;ACWA;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/common/ContentProtection.ts","../src/cenc/findCencContentProtection.ts","../src/cenc/getLicenseServerUrlFromContentProtection.ts","../src/cenc/getPsshData.ts","../src/cenc/getPsshForKeySystem.ts","../src/cenc/parseInitDataFromContentProtection.ts","../src/cenc/parsePsshList.ts","../src/keysystem/createMediaKeySystemConfiguration.ts","../src/common/MediaKeySystemAccessRequest.ts","../src/keysystem/getKeySystemAccess.ts","../src/keysystem/getLegacyKeySystemAccess.ts","../src/keysystem/getSupportedKeySystemConfiguration.ts","../src/fairplay/concatInitDataIdAndCertificate.ts","../src/fairplay/decodeFairPlayLicense.ts","../src/fairplay/extractContentId.ts","../src/fairplay/getId.ts","../src/fairplay/getLicenseServerUrl.ts","../src/playready/getLicenseRequestFromMessage.ts","../src/playready/getRequestHeadersFromMessage.ts","../src/playready/toBigEndianKeyId.ts","../src/common/LicenseRequest.ts","../src/common/CBCS.ts","../src/common/CENC.ts","../src/common/CHALLENGE.ts","../src/common/CLEAR_KEY_SYSTEM.ts","../src/common/CLEAR_KEY_UUID.ts","../src/common/CONTENT_TYPE.ts","../src/common/EncryptionScheme.ts","../src/common/EXPIRED.ts","../src/common/FAIRPLAY_KEY_SYSTEM.ts","../src/common/FAIRPLAY_UUID.ts","../src/common/HTTP_HEADERS.ts","../src/common/HW_SECURE_ALL.ts","../src/common/HW_SECURE_CRYPTO.ts","../src/common/HW_SECURE_DECODE.ts","../src/common/INDIVIDUALIZATION_REQUEST.ts","../src/common/KEYIDS.ts","../src/common/WEBM.ts","../src/common/InitializationDataType.ts","../src/common/INTERNAL_ERROR.ts","../src/common/LICENSE_ACQUISITION.ts","../src/common/LICENSE_RELEASE.ts","../src/common/LICENSE_RENEWAL.ts","../src/common/LICENSE_REQUEST.ts","../src/common/MediaKeyMessageType.ts","../src/common/OUTPUT_DOWNSCALED.ts","../src/common/OUTPUT_RESTRICTED.ts","../src/common/RELEASED.ts","../src/common/STATUS_PENDING.ts","../src/common/USABLE.ts","../src/common/MediaKeyStatus.ts","../src/common/MP4_PROTECTION_SCHEME.ts","../src/common/PLAYREADY_KEY_MESSAGE.ts","../src/common/PLAYREADY_KEY_SYSTEM.ts","../src/common/PLAYREADY_RECOMMENDATION_KEY_SYSTEM.ts","../src/common/PLAYREADY_UUID.ts","../src/common/SW_SECURE_CRYPTO.ts","../src/common/SW_SECURE_DECODE.ts","../src/common/TEXT_XML_UTF8.ts","../src/common/W3C_CLEAR_KEY_UUID.ts","../src/common/WIDEVINE_KEY_SYSTEM.ts","../src/common/WIDEVINE_UUID.ts","../src/common/WidevineRobustness.ts","../src/ensureEncryptedInit.ts"],"sourcesContent":[],"mappings":";;;;;;;AAKA;;KAAY,iBAAA;;ECWZ,KAAgB,CAAA,EAAA,MAAA;;;;;;;;ADXhB;;;;ACWA;;;;ACFA;iBDEgB,yBAAA,UAAmC,sBAAsB;;;;;ADXzE;;;;ACWA;;;;ACFA;;iBAAgB,wCAAA,4BACY;;;;;;AFV5B;;;;ACWA;;;;ACFgB,iBCHA,WAAA,CDGA,IAAA,ECHkB,eDGlB,CACY,ECJwB,eDIxB;;;;;;AFV5B;;;;ACWA;;;;ACFA;;iBECgB,mBAAA,yBAEL,kBACR;;;;;AJbH;;;;ACWA;;;;ACFA;;;iBGCgB,kCAAA,SACP;EFLT,WAAgB,EAAA,CAAA,KAAA,EAAA,MAAA,EAAkB,GEMS,UFNT;IEO/B;;;;;;AL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;;;;AhDAb;;ciDAa,MAAA;;;;;;A/CSb;;cgDAa;0BACa;E/CJ1B,SAAgB,OAAA,EAAA,O+CKY,O/CLM;4B+CMJ;qCACkB;qCACA;E9CJhD,SAAgB,cAAA,EAAA,O8CK0B,c9CH/B;kC8CI+B;;;A7CN1C;;;;AAGG,K6CWS,cAAA,GAAiB,O7CX1B,CAAA,O6CWyC,c7CXzC,CAAA;;;;;;ALbH;;cmDAa,qBAAA;;;;;;AnDAb;;coDAa,qBAAA;;;;;;ApDAb;;cqDAa,oBAAA;;;;;;ArDAb;;csDAa,mCAAA;;;;;;AtDAb;;cuDAa,cAAA;;;;;;AvDAb;;cwDAa,gBAAA;;;;;;AxDAb;;cyDAa,gBAAA;;;;;;AzDAb;;c0DAa,aAAA;;;;;;A1DAb;;c2DAa,kBAAA;;;;;;A3DAb;;c4DAa,mBAAA;;;;;;A5DAb;;c6DAa,aAAA;;;;A5DWb;;;;ACFgB,c4DFH,kB5DEG,EAAA;oC4DD8B;oCACA;oCACA;E3DJ9C,SAAgB,gBAAA,EAAA,O2DK8B,gB3DLM;iC2DMZ;;;A1DFxC;;;;ACAgB,KyDUJ,kBAAA,GAAqB,OzDVjB,CAAA,OyDUgC,kBzDVhC,CAAA;;;;;;ALVhB;;K+D+CY,0BAAA;;A9DpCZ;;;;ECFA,OAAgB,EAAA,OAAA;;;;ACHhB;;;;ACIA;;;;ECAA,UAAgB,EAAA,MAAA;EACP;;;;;;;ACAT;;;;;AACA;;;;;;;;ACLA;AACiB,iBwDmFD,mBAAA,CxDnFC,IAAA,EwDmFyB,UxDnFzB,EAAA,OAAA,CAAA,EwDmF+C,OxDnF/C,CwDmFuD,0BxDnFvD,CAAA,CAAA,EwDmFqF,UxDnFrF"}
|
package/dist/index.js
CHANGED
|
@@ -241,7 +241,7 @@ async function getKeySystemAccess(requests) {
|
|
|
241
241
|
|
|
242
242
|
//#endregion
|
|
243
243
|
//#region src/keysystem/getSupportedKeySystemConfiguration.ts
|
|
244
|
-
const isTypeSupported = typeof MediaKeys !== "undefined" && typeof MediaKeys.isTypeSupported === "function" ? MediaKeys.isTypeSupported : void 0;
|
|
244
|
+
const isTypeSupported = /* @__PURE__ */ (() => typeof MediaKeys !== "undefined" && typeof MediaKeys.isTypeSupported === "function" ? MediaKeys.isTypeSupported : void 0)();
|
|
245
245
|
/**
|
|
246
246
|
* Filters and returns the supported key system configuration for a given system string.
|
|
247
247
|
*
|
|
@@ -886,19 +886,25 @@ const videoTypes = [
|
|
|
886
886
|
"dvc1",
|
|
887
887
|
"dvi1"
|
|
888
888
|
];
|
|
889
|
-
const readers =
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
889
|
+
const readers = /* @__PURE__ */ (() => {
|
|
890
|
+
const map = { stsd: readStsd };
|
|
891
|
+
audioTypes.forEach((type) => map[type] = createAudioSampleEntryReader(type));
|
|
892
|
+
videoTypes.forEach((type) => map[type] = createVisualSampleEntryReader(type));
|
|
893
|
+
return map;
|
|
894
|
+
})();
|
|
895
|
+
const writers = /* @__PURE__ */ (() => {
|
|
896
|
+
const map = {
|
|
897
|
+
stsd: writeStsd,
|
|
898
|
+
frma: writeFrma,
|
|
899
|
+
schm: writeSchm,
|
|
900
|
+
tenc: writeTenc,
|
|
901
|
+
encv: writeVisualSampleEntryBox,
|
|
902
|
+
enca: writeAudioSampleEntryBox
|
|
903
|
+
};
|
|
904
|
+
audioTypes.forEach((type) => map[type] = writeAudioSampleEntryBox);
|
|
905
|
+
videoTypes.forEach((type) => map[type] = writeVisualSampleEntryBox);
|
|
906
|
+
return map;
|
|
907
|
+
})();
|
|
902
908
|
/**
|
|
903
909
|
* Ensures that the init segment is encrypted. Used on platforms that have issues playing unencrypted
|
|
904
910
|
* content before playing encrypted content. Both prepend and includeOriginal are optional.
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["pssh: Record<string, ArrayBufferLike | Uint8Array>","val: string","config: MediaKeySystemConfiguration","isTypeSupported: (keySystem: string, type: string) => boolean | undefined","headers: Record<string, string>"],"sources":["../src/common/CBCS.ts","../src/common/CENC.ts","../src/common/MP4_PROTECTION_SCHEME.ts","../src/cenc/findCencContentProtection.ts","../src/cenc/getLicenseServerUrlFromContentProtection.ts","../src/cenc/getPsshData.ts","../src/cenc/parsePsshList.ts","../src/cenc/getPsshForKeySystem.ts","../src/cenc/parseInitDataFromContentProtection.ts","../src/keysystem/createMediaKeySystemConfiguration.ts","../src/keysystem/getKeySystemAccess.ts","../src/keysystem/getSupportedKeySystemConfiguration.ts","../src/keysystem/getLegacyKeySystemAccess.ts","../src/fairplay/concatInitDataIdAndCertificate.ts","../src/fairplay/decodeFairPlayLicense.ts","../src/fairplay/extractContentId.ts","../src/fairplay/getId.ts","../src/fairplay/getLicenseServerUrl.ts","../src/common/CHALLENGE.ts","../src/common/PLAYREADY_KEY_MESSAGE.ts","../src/playready/getLicenseRequestFromMessage.ts","../src/common/CONTENT_TYPE.ts","../src/common/HTTP_HEADERS.ts","../src/common/TEXT_XML_UTF8.ts","../src/playready/getRequestHeadersFromMessage.ts","../src/playready/toBigEndianKeyId.ts","../src/common/CLEAR_KEY_SYSTEM.ts","../src/common/CLEAR_KEY_UUID.ts","../src/common/EncryptionScheme.ts","../src/common/EXPIRED.ts","../src/common/FAIRPLAY_KEY_SYSTEM.ts","../src/common/FAIRPLAY_UUID.ts","../src/common/HW_SECURE_ALL.ts","../src/common/HW_SECURE_CRYPTO.ts","../src/common/HW_SECURE_DECODE.ts","../src/common/INDIVIDUALIZATION_REQUEST.ts","../src/common/KEYIDS.ts","../src/common/WEBM.ts","../src/common/InitializationDataType.ts","../src/common/INTERNAL_ERROR.ts","../src/common/LICENSE_ACQUISITION.ts","../src/common/LICENSE_RELEASE.ts","../src/common/LICENSE_RENEWAL.ts","../src/common/LICENSE_REQUEST.ts","../src/common/MediaKeyMessageType.ts","../src/common/OUTPUT_DOWNSCALED.ts","../src/common/OUTPUT_RESTRICTED.ts","../src/common/RELEASED.ts","../src/common/STATUS_PENDING.ts","../src/common/USABLE.ts","../src/common/MediaKeyStatus.ts","../src/common/PLAYREADY_KEY_SYSTEM.ts","../src/common/PLAYREADY_RECOMMENDATION_KEY_SYSTEM.ts","../src/common/PLAYREADY_UUID.ts","../src/common/SW_SECURE_CRYPTO.ts","../src/common/SW_SECURE_DECODE.ts","../src/common/W3C_CLEAR_KEY_UUID.ts","../src/common/WIDEVINE_KEY_SYSTEM.ts","../src/common/WIDEVINE_UUID.ts","../src/common/WidevineRobustness.ts","../src/ensureEncryptedInit.ts"],"sourcesContent":["/**\n * Cipher Block Chaining Sample encryption scheme.\n *\n * @public\n */\nexport const CBCS = 'cbcs'\n","/**\n * Common Encryption scheme.\n *\n * @public\n */\nexport const CENC = 'cenc'\n","/**\n * The DASH MP4 Protection Scheme schemeIdUri.\n *\n * @public\n */\nexport const MP4_PROTECTION_SCHEME = 'urn:mpeg:dash:mp4protection:2011'\n","import { CBCS } from '../common/CBCS.ts'\nimport { CENC } from '../common/CENC.ts'\nimport type { ContentProtection } from '../common/ContentProtection.ts'\nimport { MP4_PROTECTION_SCHEME } from '../common/MP4_PROTECTION_SCHEME.ts'\n\n/**\n * Finds and returns the ContentProtection element for MP4 Common Encryption.\n *\n * @param cpArray - Array of ContentProtection elements.\n * @returns The Common Encryption content protection element, or null if not found.\n *\n * @public\n *\n * @example\n * {@includeCode ../../test/cenc/findCencContentProtection.test.ts#example}\n */\nexport function findCencContentProtection(cpArray: ContentProtection[]): ContentProtection | null {\n\tif (!cpArray) {\n\t\treturn null\n\t}\n\n\tfor (const cp of cpArray) {\n\t\tif (\n\t\t\tcp.schemeIdUri?.toLowerCase() === MP4_PROTECTION_SCHEME &&\n\t\t\tcp.value &&\n\t\t\t(cp.value.toLowerCase() === CENC ||\n\t\t\t\tcp.value.toLowerCase() === CBCS)\n\t\t) {\n\t\t\treturn cp\n\t\t}\n\t}\n\n\treturn null\n}\n","import type { ContentProtection } from '../common/ContentProtection.ts'\n\n/**\n * Extracts a license server URL from an array of ContentProtection elements.\n *\n * @param contentProtectionElements - Array of ContentProtection nodes from the manifest.\n * @param schemeIdUri - schemeIdUri we are searching for.\n * @returns The license server URL, and if not found then null.\n *\n * @public\n *\n * @example\n * {@includeCode ../../test/cenc/getLicenseServerUrlFromContentProtection.test.ts#example}\n */\nexport function getLicenseServerUrlFromContentProtection(\n\tcontentProtectionElements: ContentProtection[],\n\tschemeIdUri: string,\n): string | null {\n\treturn contentProtectionElements.find(cp => cp.schemeIdUri === schemeIdUri)?.laUrl || null\n}\n","/**\n * Returns the data portion of a single PSSH box.\n *\n * @param pssh - The PSSH ArrayBuffer.\n * @returns The data portion of the PSSH.\n *\n * @public\n *\n * @example\n * {@includeCode ../../test/cenc/getPsshData.test.ts#example}\n */\nexport function getPsshData(pssh: ArrayBufferLike): ArrayBufferLike {\n\tconst offset = 8 // Box size and type fields\n\tconst view = new DataView(pssh)\n\n\tconst version = view.getUint8(offset) // Read version\n\tlet dataOffset = offset + 20\n\n\tif (version > 0) {\n\t\tconst kidCount = view.getUint32(dataOffset)\n\t\tdataOffset += 4 + (16 * kidCount)\n\t}\n\n\tdataOffset += 4 // Data size\n\treturn pssh.slice(dataOffset)\n}\n\n","import { isArrayBufferLike } from '@svta/cml-utils'\n\n/**\n * Parses a list of PSSH boxes into keysystem-specific PSSH data.\n *\n * @param data - The concatenated list of PSSH boxes as provided by\n * the CDM as initialization data when CommonEncryption content is detected\n * @returns An object that has a property named according to each of\n * the detected key system UUIDs (e.g. 00000000-0000-0000-0000-0000000000)\n * and a ArrayBuffer (the entire PSSH box) as the property value\n *\n * @public\n *\n * @example\n * {@includeCode ../../test/cenc/parsePsshList.test.ts#example}\n */\nexport function parsePsshList(data: ArrayBufferLike): Record<string, ArrayBufferLike>\nexport function parsePsshList(data: Uint8Array): Record<string, Uint8Array>\nexport function parsePsshList(data: ArrayBufferLike | Uint8Array): Record<string, ArrayBufferLike | Uint8Array> {\n\tif (!data) {\n\t\treturn {}\n\t}\n\n\t// data.buffer first for Uint8Array support\n\tconst dv = isArrayBufferLike(data)\n\t\t? new DataView(data)\n\t\t: new DataView((data as Uint8Array).buffer, data.byteOffset, data.byteLength)\n\tconst pssh: Record<string, ArrayBufferLike | Uint8Array> = {}\n\tlet byteCursor = 0\n\n\twhile (true) {\n\t\tif (byteCursor >= dv.byteLength) {\n\t\t\tbreak\n\t\t}\n\n\t\tconst boxStart = byteCursor\n\n\t\t// Box size\n\t\tconst size = dv.getUint32(byteCursor)\n\t\tconst nextBox = byteCursor + size\n\t\tbyteCursor += 4\n\n\t\t// Verify PSSH\n\t\tif (dv.getUint32(byteCursor) !== 0x70737368) {\n\t\t\tbyteCursor = nextBox\n\t\t\tcontinue\n\t\t}\n\t\tbyteCursor += 4\n\n\t\t// Version must be 0 or 1\n\t\tconst version = dv.getUint8(byteCursor)\n\t\tif (version !== 0 && version !== 1) {\n\t\t\tbyteCursor = nextBox\n\t\t\tcontinue\n\t\t}\n\n\t\tbyteCursor += 1 // Move past version\n\t\tbyteCursor += 3 // Skip flags\n\n\t\t// 16-byte UUID/SystemID\n\t\tlet systemID = ''\n\t\tlet val: string\n\n\t\tfor (let i = 0; i < 4; i++) {\n\t\t\tval = dv.getUint8(byteCursor + i).toString(16)\n\t\t\tsystemID += val.length === 1 ? '0' + val : val\n\t\t}\n\t\tbyteCursor += 4\n\t\tsystemID += '-'\n\n\t\tfor (let i = 0; i < 2; i++) {\n\t\t\tval = dv.getUint8(byteCursor + i).toString(16)\n\t\t\tsystemID += val.length === 1 ? '0' + val : val\n\t\t}\n\t\tbyteCursor += 2\n\t\tsystemID += '-'\n\n\t\tfor (let i = 0; i < 2; i++) {\n\t\t\tval = dv.getUint8(byteCursor + i).toString(16)\n\t\t\tsystemID += val.length === 1 ? '0' + val : val\n\t\t}\n\t\tbyteCursor += 2\n\t\tsystemID += '-'\n\n\t\tfor (let i = 0; i < 2; i++) {\n\t\t\tval = dv.getUint8(byteCursor + i).toString(16)\n\t\t\tsystemID += val.length === 1 ? '0' + val : val\n\t\t}\n\t\tbyteCursor += 2\n\t\tsystemID += '-'\n\n\t\tfor (let i = 0; i < 6; i++) {\n\t\t\tval = dv.getUint8(byteCursor + i).toString(16)\n\t\t\tsystemID += val.length === 1 ? '0' + val : val\n\t\t}\n\t\tbyteCursor += 6\n\n\t\tsystemID = systemID.toLowerCase()\n\n\t\t// PSSH Data Size\n\t\tbyteCursor += 4\n\n\t\t// PSSH boxdata\n\t\tpssh[systemID] = data.slice(boxStart, nextBox)\n\n\t\tbyteCursor = nextBox\n\t}\n\n\treturn pssh\n}\n\n","import { parsePsshList } from './parsePsshList.ts'\n\n/**\n * Returns the PSSH box associated with the given key system from the concatenated\n * list of PSSH boxes in the provided initData.\n *\n * @param uuid - The desired key system UUID\n * @param initData - 'cenc' initialization data. Concatenated list of PSSH boxes.\n * @returns The PSSH box ArrayBuffer corresponding to the given key system, or null if not found.\n *\n * @public\n *\n * @example\n * {@includeCode ../../test/cenc/getPsshForKeySystem.test.ts#example}\n */\nexport function getPsshForKeySystem(\n\tuuid: string,\n\tinitData: ArrayBufferLike,\n): ArrayBufferLike | null {\n\tif (!initData || !uuid) {\n\t\treturn null\n\t}\n\n\tconst psshList = parsePsshList(initData)\n\treturn psshList[uuid.toLowerCase()] || null\n}\n","import type { ContentProtection } from '../common/ContentProtection.ts'\n\n/**\n * Parse a standard common encryption PSSH which contains a simple\n * base64-encoding of the init data\n *\n * @param cpData - The ContentProtection element that may contain PSSH data.\n * @param BASE64 - The BASE64 reference.\n * @returns init data as an ArrayBuffer, or null if not found.\n *\n * @public\n *\n * @example\n * {@includeCode ../../test/cenc/parseInitDataFromContentProtection.test.ts#example}\n */\nexport function parseInitDataFromContentProtection(\n\tcpData: ContentProtection,\n\tBASE64: { decodeArray: (input: string) => Uint8Array },\n): ArrayBuffer | null {\n\tif (cpData?.pssh && cpData.pssh) {\n\t\tconst cleanedText = cpData.pssh.replace(/\\r?\\n|\\r/g, '').replace(/\\s+/g, '')\n\t\treturn BASE64.decodeArray(cleanedText).buffer as ArrayBuffer\n\t}\n\n\treturn null\n}\n","/**\n * Creates a valid KeySystemConfiguration from supported audio and video capabilities.\n *\n * @param supportedAudio - supported audio capabilities.\n * @param supportedVideo - supported video capabilities.\n * @returns KeySystemConfiguration object.\n *\n * @public\n *\n * @example\n * {@includeCode ../../test/keysystem/createMediaKeySystemConfiguration.test.ts#example}\n */\nexport function createMediaKeySystemConfiguration(\n\tsupportedAudio: MediaKeySystemMediaCapability[] | null,\n\tsupportedVideo: MediaKeySystemMediaCapability[] | null,\n): MediaKeySystemConfiguration {\n\tconst config: MediaKeySystemConfiguration = {}\n\n\tif (supportedAudio && supportedAudio.length > 0) {\n\t\tconfig.audioCapabilities = supportedAudio\n\t}\n\n\tif (supportedVideo && supportedVideo.length > 0) {\n\t\tconfig.videoCapabilities = supportedVideo\n\t}\n\n\t// default values\n\tconfig.distinctiveIdentifier = 'optional'\n\tconfig.persistentState = 'optional'\n\tconfig.sessionTypes = ['temporary']\n\n\treturn config\n}\n","import type { MediaKeySystemAccessRequest } from '../common/MediaKeySystemAccessRequest.ts'\n\n/**\n * Attempts to get key system access using requestMediaKeySystemAccess from EME.\n *\n * @param requests - An array of key system access requests.\n * @returns MediaKeySystemAccess object if successful, or null if no system is supported.\n *\n * @public\n */\nexport async function getKeySystemAccess(\n\trequests: MediaKeySystemAccessRequest[],\n): Promise<MediaKeySystemAccess | null> {\n\tfor (const { keySystem, configurations } of requests) {\n\t\ttry {\n\t\t\treturn await navigator.requestMediaKeySystemAccess(keySystem, configurations)\n\t\t}\n\t\tcatch {\n\t\t\t// legacy approach could be used here\n\t\t}\n\t}\n\treturn null\n}\n","const isTypeSupported: (keySystem: string, type: string) => boolean | undefined = (typeof MediaKeys !== 'undefined' && typeof (MediaKeys as any).isTypeSupported === 'function') ? (MediaKeys as any).isTypeSupported : undefined\n\n/**\n * Filters and returns the supported key system configuration for a given system string.\n *\n * @param keySystem - Key system string such as 'com.widevine.alpha'\n * @param configs - An array of key system configurations.\n * @returns The first supported configuration or null if none are supported.\n *\n * @public\n */\nexport function getSupportedKeySystemConfiguration(\n\tkeySystem: string,\n\tconfigs: Iterable<MediaKeySystemConfiguration>,\n): { supportedAudio: MediaKeySystemMediaCapability[]; supportedVideo: MediaKeySystemMediaCapability[] } {\n\tif (!configs || typeof isTypeSupported === 'undefined') {\n\t\treturn { supportedAudio: [], supportedVideo: [] }\n\t}\n\n\tfor (const config of configs) {\n\t\tconst audios = config.audioCapabilities || []\n\t\tconst videos = config.videoCapabilities || []\n\n\t\tconst supportedAudio = audios.filter(audio => isTypeSupported(keySystem, audio.contentType ?? ''))\n\t\tconst supportedVideo = videos.filter(video => isTypeSupported(keySystem, video.contentType ?? ''))\n\n\t\tconst hasAudio = supportedAudio.length > 0\n\t\tconst hasVideo = supportedVideo.length > 0\n\n\t\tif (hasAudio || hasVideo) {\n\t\t\treturn { supportedAudio, supportedVideo }\n\t\t}\n\t}\n\n\treturn { supportedAudio: [], supportedVideo: [] }\n}\n","import type { MediaKeySystemAccessRequest } from '../common/MediaKeySystemAccessRequest.ts'\nimport { createMediaKeySystemConfiguration } from './createMediaKeySystemConfiguration.ts'\nimport { getSupportedKeySystemConfiguration } from './getSupportedKeySystemConfiguration.ts'\n\n/**\n * Fallback method to get key system access using legacy MediaKeys.isTypeSupported().\n *\n * @param requests - An array of key system access requests.\n * @returns A KeySystemAccess object if successful, or null if no system is supported.\n *\n * @public\n */\nexport function getLegacyKeySystemAccess(\n\trequests: MediaKeySystemAccessRequest[],\n): MediaKeySystemAccessRequest | null {\n\tfor (const { keySystem, configurations } of requests) {\n\t\tconst supportedConfig = getSupportedKeySystemConfiguration(keySystem, configurations)\n\t\tif (supportedConfig) {\n\t\t\tconst configuration = createMediaKeySystemConfiguration(\n\t\t\t\tsupportedConfig.supportedAudio,\n\t\t\t\tsupportedConfig.supportedVideo,\n\t\t\t)\n\n\t\t\treturn {\n\t\t\t\tkeySystem,\n\t\t\t\tconfigurations: [configuration],\n\t\t\t}\n\t\t}\n\t}\n\treturn null\n}\n","import { stringToUint16 } from '@svta/cml-utils'\n\n/**\n * Concatenates InitData, ID, and Certificate for FairPlay DRM.\n *\n * @param initData - The initialization data (PSSH box)\n * @param id - The content ID (string or Uint16Array)\n * @param cert - The application certificate (Uint8Array)\n * @returns A Uint8Array containing the concatenated data\n *\n * @public\n *\n * @example\n * {@includeCode ../../test/fairplay/concatInitDataIdAndCertificate.test.ts#example}\n */\n\nexport function concatInitDataIdAndCertificate(initData: Uint16Array, id: Uint16Array | string, cert: Uint8Array): Uint8Array {\n\tif (typeof id === 'string') {\n\t\tid = stringToUint16(id)\n\t}\n\tconst buffer = new ArrayBuffer(initData.byteLength + 4 + id.byteLength + 4 + cert.byteLength)\n\tconst dataView = new DataView(buffer)\n\tlet offset = 0\n\n\tnew Uint8Array(buffer, offset, initData.byteLength).set(initData)\n\toffset += initData.byteLength\n\n\tdataView.setUint32(offset, id.byteLength, true)\n\toffset += 4\n\tnew Uint16Array(buffer, offset, id.length).set(id)\n\toffset += id.byteLength\n\n\tdataView.setUint32(offset, cert.byteLength, true)\n\toffset += 4\n\tnew Uint8Array(buffer, offset, cert.byteLength).set(cert)\n\n\treturn new Uint8Array(buffer)\n}\n","import { decodeBase64 } from '@svta/cml-utils'\n\n/**\n * Decodes a FairPlay DRM license response.\n *\n * @param response - The license response, either a base64 string or ArrayBuffer\n * @returns A Uint8Array containing the decoded license\n *\n * @public\n *\n * @example\n * {@includeCode ../../test/fairplay/decodeFairPlayLicense.test.ts#example}\n */\n\nexport function decodeFairPlayLicense(response: string | ArrayBuffer): Uint8Array {\n\treturn typeof response === 'string'\n\t\t? decodeBase64(response)\n\t\t: new Uint8Array(response)\n}\n","import type { Encoding } from '@svta/cml-utils'\nimport { decodeText, UTF_16 } from '@svta/cml-utils'\n\n/**\n * Extracts the content ID from InitData using skd:// URI or query parameters.\n *\n * @param initData - The initialization data (PSSH box)\n * @returns The extracted content ID\n *\n * @public\n *\n * @example\n * {@includeCode ../../test/fairplay/extractContentId.test.ts#example}\n */\nexport function extractContentId(initData: ArrayBufferLike, encoding: Encoding = UTF_16): string {\n\tconst initDataString = decodeText(initData, { encoding })\n\n\t// Try extracting skd:// content ID\n\treturn initDataString.split('skd://')[1] || ''\n}\n","import { extractContentId } from './extractContentId.ts'\n\n/**\n * Extracts the content ID from the license server URL or InitData.\n *\n * @param licenseServerUrl - The license server URL\n * @param initData - The initialization data (PSSH box)\n * @param queryParam - The query parameter key to extract (default: 'ContentId')\n * @returns The extracted content ID as a string or null if not found\n *\n * @public\n *\n * @example\n * {@includeCode ../../test/fairplay/getId.test.ts#example}\n */\n\nexport function getId(licenseServerUrl: string, initData: ArrayBufferLike, queryParam: string = 'ContentId'): string {\n\ttry {\n\t\tconst url = new URL(licenseServerUrl)\n\t\tconst params = new URLSearchParams(url.search)\n\t\treturn params.get(queryParam) || extractContentId(initData)\n\t}\n\tcatch {\n\t\t// in case if URL parsing fails,\n\t\t// fallback to extracting from initData\n\t\treturn extractContentId(initData)\n\t}\n}\n","/**\n * Retrieves the FairPlay license server URL from InitData.\n *\n * @param initData - The initialization data (PSSH box)\n * @returns The license server URL as a string\n *\n * @public\n *\n * @example\n * {@includeCode ../../test/fairplay/getLicenseServerUrl.test.ts#example}\n */\n\nexport function getLicenseServerUrl(initData: Uint16Array): string {\n\tlet initDataString = ''\n\tfor (const code of initData) {\n\t\tif (code !== 0) { // Ignore null characters\n\t\t\tinitDataString += String.fromCharCode(code)\n\t\t}\n\t}\n\n\tconst match = initDataString.match(/skd:\\/\\/([^\"\\s]+)/)\n\treturn match ? `https://${match[1]}` : ''\n}\n","/**\n * License Challenge.\n *\n * @public\n */\nexport const CHALLENGE = 'Challenge'\n","/**\n * Playready Key Message.\n *\n * @public\n */\nexport const PLAYREADY_KEY_MESSAGE = 'PlayReadyKeyMessage'\n","import type { Encoding } from '@svta/cml-utils'\nimport { decodeBase64, decodeText, UTF_16 } from '@svta/cml-utils'\nimport { getElementsByName, parseXml } from '@svta/cml-xml'\nimport { CHALLENGE } from '../common/CHALLENGE.ts'\nimport { PLAYREADY_KEY_MESSAGE } from '../common/PLAYREADY_KEY_MESSAGE.ts'\n\n/**\n * Gets the PlayReady license request from the MediaKeyMessageEvent.\n *\n * @param message - An ArrayBuffer from the content decryption module.\n * @param encoding - The message encoding type. Default is UTF-16.\n * @returns The license request as an ArrayBuffer.\n *\n * @public\n *\n * @example\n * {@includeCode ../../test/playready/getLicenseRequestFromMessage.test.ts#example}\n */\nexport function getLicenseRequestFromMessage(\n\tmessage: ArrayBuffer,\n\tencoding: Encoding = UTF_16,\n): ArrayBuffer {\n\n\t// If encoding is configured for UTF-16 and the number of bytes is odd,\n\t// assume an 'unwrapped' raw CDM message.\n\tif (encoding === UTF_16 && message?.byteLength % 2 === 1) {\n\t\treturn message\n\t}\n\n\tconst msg = decodeText(message, { encoding })\n\tconst xml = parseXml(msg)\n\tconst playReadyKeyMessage = getElementsByName(xml, PLAYREADY_KEY_MESSAGE)[0]\n\n\tif (!playReadyKeyMessage) {\n\t\t// The message from the CDM is not wrapped and contains the direct challenge.\n\t\treturn message\n\t}\n\n\tconst challengeNode = getElementsByName(playReadyKeyMessage, CHALLENGE)[0]\n\tconst challengeValue = challengeNode?.childNodes[0]?.nodeValue\n\n\tif (challengeValue) {\n\t\treturn decodeBase64(challengeValue).buffer as ArrayBuffer\n\t}\n\n\treturn message\n}\n","/**\n * Content-Type header.\n *\n * @public\n */\nexport const CONTENT_TYPE = 'Content-Type'\n","/**\n * Playready HTTP Headers.\n *\n * @public\n */\nexport const HTTP_HEADERS = 'HttpHeaders'\n","/**\n * XML formatted, UTF-8 encoded, text header.\n *\n * @public\n */\nexport const TEXT_XML_UTF8 = 'text/xml; charset=utf-8'\n","import type { UTF_8 } from '@svta/cml-utils'\nimport { decodeText, UTF_16 } from '@svta/cml-utils'\nimport { getElementsByName, parseXml } from '@svta/cml-xml'\nimport { CONTENT_TYPE } from '../common/CONTENT_TYPE.ts'\nimport { HTTP_HEADERS } from '../common/HTTP_HEADERS.ts'\nimport { TEXT_XML_UTF8 } from '../common/TEXT_XML_UTF8.ts'\n\n/**\n * Gets the PlayReady license request headers from the MediaKeyMessageEvent.\n *\n * @param message - An ArrayBuffer from the content decryption module.\n * @param encoding - The message encoding type. Default is UTF-16.\n * @returns Request headers.\n *\n * @public\n *\n * @example\n * {@includeCode ../../test/playready/getRequestHeadersFromMessage.test.ts#example}\n */\nexport function getRequestHeadersFromMessage(\n\tmessage: ArrayBuffer,\n\tencoding: typeof UTF_8 | typeof UTF_16 = UTF_16,\n): Record<string, string> {\n\tconst headers: Record<string, string> = {}\n\n\t// If message format configured/defaulted to utf-16 AND number of bytes is odd,\n\t// assume 'unwrapped' raw CDM message.\n\tif (encoding === UTF_16 && message && message.byteLength % 2 === 1) {\n\t\theaders[CONTENT_TYPE] = TEXT_XML_UTF8\n\t\treturn headers\n\t}\n\n\tconst msg = decodeText(message, { encoding })\n\tconst xml = parseXml(msg)\n\tconst httpHeaders = getElementsByName(xml, HTTP_HEADERS)[0]?.childNodes\n\n\tif (!httpHeaders) {\n\t\treturn headers\n\t}\n\n\tfor (const header of httpHeaders) {\n\t\tconst name = getElementsByName(header, 'name')[0]?.childNodes[0]?.nodeValue\n\t\tconst value = getElementsByName(header, 'value')[0]?.childNodes[0]?.nodeValue\n\n\t\tif (name && value) {\n\t\t\theaders[name] = value\n\t\t}\n\t}\n\t// Some versions of the PlayReady CDM return 'Content' instead of 'Content-Type'.\n\t// This does not adhere to the W3C spec and license servers may reject the request.\n\tif (headers['Content']) {\n\t\theaders[CONTENT_TYPE] = headers['Content']\n\t\tdelete headers['Content']\n\t}\n\t// Set 'Content-Type' header by default if not provided in the the CDM message\n\t// or if the message is unwrapped.\n\tif (!headers[CONTENT_TYPE]) {\n\t\theaders[CONTENT_TYPE] = TEXT_XML_UTF8\n\t}\n\n\treturn headers\n}\n","/**\n * Converts a 16-byte key ID from little-endian to big-endian format.\n *\n * @param keyId - The little-endian key ID to convert.\n * @returns The big-endian representation of the key ID.\n *\n * @public\n *\n * @example\n * {@includeCode ../../test/playready/toBigEndianKeyId.test.ts#example}\n */\nexport function toBigEndianKeyId(keyId: ArrayBuffer): ArrayBuffer {\n\tif (keyId.byteLength !== 16) {\n\t\treturn keyId\n\t}\n\n\tconst buffer = keyId.slice(0)\n\tconst dataView = new DataView(buffer)\n\tdataView.setUint32(0, dataView.getUint32(0, true), false)\n\tdataView.setUint16(4, dataView.getUint16(4, true), false)\n\tdataView.setUint16(6, dataView.getUint16(6, true), false)\n\n\treturn buffer\n}\n","/**\n * Clear Key System.\n *\n * @public\n */\nexport const CLEAR_KEY_SYSTEM = 'org.w3.clearkey'\n","/**\n * Clear Key UUID.\n *\n * @public\n */\nexport const CLEAR_KEY_UUID = 'e2719d58-a985-b3c9-781a-b030af78d30e'\n","import type { ValueOf } from '@svta/cml-utils'\nimport { CBCS } from './CBCS.ts'\nimport { CENC } from './CENC.ts'\n\n/**\n * Encryption schemes.\n *\n * @public\n */\nexport const EncryptionScheme = {\n\tCENC: CENC as typeof CENC,\n\tCBCS: CBCS as typeof CBCS,\n} as const\n\n/**\n * Encryption schemes.\n *\n * @public\n */\nexport type EncryptionScheme = ValueOf<typeof EncryptionScheme>;\n","/**\n * Expired Media Key Status.\n *\n * @public\n */\nexport const EXPIRED = 'expired'\n","/**\n * FairPlay Key System.\n *\n * @public\n */\nexport const FAIRPLAY_KEY_SYSTEM = 'com.apple.fps.1_0'\n","/**\n * FairPlay UUID.\n *\n * @public\n */\nexport const FAIRPLAY_UUID = '29701fe4-3cc7-4a34-8c5b-ae90c7439a47'\n","/**\n * Hardware Secure All Robustness.\n *\n * @public\n */\nexport const HW_SECURE_ALL = 'HW_SECURE_ALL'\n","/**\n * Hardware Secure Crypto Robustness.\n *\n * @public\n */\nexport const HW_SECURE_CRYPTO = 'HW_SECURE_CRYPTO'\n","/**\n * Hardware Secure Decode Robustness.\n *\n * @public\n */\nexport const HW_SECURE_DECODE = 'HW_SECURE_DECODE'\n","/**\n * Individualization Request.\n *\n * @public\n */\nexport const INDIVIDUALIZATION_REQUEST = 'individualization-request'\n","/**\n * Key IDs.\n *\n * @public\n */\nexport const KEYIDS = 'keyids'\n","/**\n * WEBM.\n *\n * @public\n */\nexport const WEBM = 'webm'\n","import type { ValueOf } from '@svta/cml-utils'\nimport { CBCS } from './CBCS.ts'\nimport { CENC } from './CENC.ts'\nimport { KEYIDS } from './KEYIDS.ts'\nimport { WEBM } from './WEBM.ts'\n\n/**\n * Initialization Data Type.\n *\n * @public\n */\nexport const InitializationDataType = {\n\tCENC: CENC as typeof CENC,\n\tCBCS: CBCS as typeof CBCS,\n\tKEYIDS: KEYIDS as typeof KEYIDS,\n\tWEBM: WEBM as typeof WEBM,\n} as const\n\n/**\n * Initialization Data Type.\n *\n * @public\n */\nexport type InitializationDataType = ValueOf<typeof InitializationDataType>;\n","/**\n * Internal Error Media Key Status.\n *\n * @public\n */\nexport const INTERNAL_ERROR = 'internal-error'\n","/**\n * License Acquisition.\n *\n * @public\n */\nexport const LICENSE_ACQUISITION = 'LicenseAcquisition'\n","/**\n * License Release.\n *\n * @public\n */\nexport const LICENSE_RELEASE = 'license-release'\n","/**\n * License Renewal.\n *\n * @public\n */\nexport const LICENSE_RENEWAL = 'license-renewal'\n","/**\n * License Request.\n *\n * @public\n */\nexport const LICENSE_REQUEST = 'license-request'\n","import type { ValueOf } from '@svta/cml-utils'\nimport { INDIVIDUALIZATION_REQUEST } from './INDIVIDUALIZATION_REQUEST.ts'\nimport { LICENSE_RELEASE } from './LICENSE_RELEASE.ts'\nimport { LICENSE_RENEWAL } from './LICENSE_RENEWAL.ts'\nimport { LICENSE_REQUEST } from './LICENSE_REQUEST.ts'\n\n/**\n * Media Key Message Types.\n *\n * @public\n */\nexport const MediaKeyMessageType = {\n\tLICENSE_REQUEST: LICENSE_REQUEST as typeof LICENSE_REQUEST,\n\tLICENSE_RENEWAL: LICENSE_RENEWAL as typeof LICENSE_RENEWAL,\n\tLICENSE_RELEASE: LICENSE_RELEASE as typeof LICENSE_RELEASE,\n\tINDIVIDUALIZATION_REQUEST: INDIVIDUALIZATION_REQUEST as typeof INDIVIDUALIZATION_REQUEST,\n} as const\n\n/**\n * Media Key Message Types.\n *\n * @public\n */\nexport type MediaKeyMessageType = ValueOf<typeof MediaKeyMessageType>;\n","/**\n * Output Downscaled Media Key Status.\n *\n * @public\n */\nexport const OUTPUT_DOWNSCALED = 'output-downscaled'\n","/**\n * Output Restricted Media Key Status.\n *\n * @public\n */\nexport const OUTPUT_RESTRICTED = 'output-restricted'\n","/**\n * Released Media Key Status.\n *\n * @public\n */\nexport const RELEASED = 'released'\n","/**\n * Status Pending Media Key Status.\n *\n * @public\n */\nexport const STATUS_PENDING = 'status-pending'\n","/**\n * Usable Media Key Status.\n *\n * @public\n */\nexport const USABLE = 'usable'\n","import type { ValueOf } from '@svta/cml-utils'\nimport { EXPIRED } from './EXPIRED.ts'\nimport { INTERNAL_ERROR } from './INTERNAL_ERROR.ts'\nimport { OUTPUT_DOWNSCALED } from './OUTPUT_DOWNSCALED.ts'\nimport { OUTPUT_RESTRICTED } from './OUTPUT_RESTRICTED.ts'\nimport { RELEASED } from './RELEASED.ts'\nimport { STATUS_PENDING } from './STATUS_PENDING.ts'\nimport { USABLE } from './USABLE.ts'\n\n/**\n * Media Key Statuses.\n *\n * @public\n */\nexport const MediaKeyStatus = {\n\tUSABLE: USABLE as typeof USABLE,\n\tEXPIRED: EXPIRED as typeof EXPIRED,\n\tRELEASED: RELEASED as typeof RELEASED,\n\tOUTPUT_RESTRICTED: OUTPUT_RESTRICTED as typeof OUTPUT_RESTRICTED,\n\tOUTPUT_DOWNSCALED: OUTPUT_DOWNSCALED as typeof OUTPUT_DOWNSCALED,\n\tSTATUS_PENDING: STATUS_PENDING as typeof STATUS_PENDING,\n\tINTERNAL_ERROR: INTERNAL_ERROR as typeof INTERNAL_ERROR,\n} as const\n\n/**\n * Media Key Statuses.\n *\n * @public\n */\nexport type MediaKeyStatus = ValueOf<typeof MediaKeyStatus>;\n","/**\n * Playready Key System.\n *\n * @public\n */\nexport const PLAYREADY_KEY_SYSTEM = 'com.microsoft.playready'\n","/**\n * Playready Recommendation Key System.\n *\n * @public\n */\nexport const PLAYREADY_RECOMMENDATION_KEY_SYSTEM = 'com.microsoft.playready.recommendation'\n","/**\n * Playready UUID.\n *\n * @public\n */\nexport const PLAYREADY_UUID = '9a04f079-9840-4286-ab92-e65be0885f95'\n","/**\n * Software Secure Crypto Robustness.\n *\n * @public\n */\nexport const SW_SECURE_CRYPTO = 'SW_SECURE_CRYPTO'\n","/**\n * Software Secure Decode Robustness.\n *\n * @public\n */\nexport const SW_SECURE_DECODE = 'SW_SECURE_DECODE'\n","/**\n * W3C Clear Key UUID.\n *\n * @public\n */\nexport const W3C_CLEAR_KEY_UUID = '1077efec-c0b2-4d02-ace3-3c1e52e2fb4b'\n","/**\n * Widevine Key System.\n *\n * @public\n */\nexport const WIDEVINE_KEY_SYSTEM = 'com.widevine.alpha'\n","/**\n * Widevine UUID.\n *\n * @public\n */\nexport const WIDEVINE_UUID = 'edef8ba9-79d6-4ace-a3c8-27dcd51d21ed'\n","import type { ValueOf } from '@svta/cml-utils'\nimport { HW_SECURE_ALL } from './HW_SECURE_ALL.ts'\nimport { HW_SECURE_CRYPTO } from './HW_SECURE_CRYPTO.ts'\nimport { HW_SECURE_DECODE } from './HW_SECURE_DECODE.ts'\nimport { SW_SECURE_CRYPTO } from './SW_SECURE_CRYPTO.ts'\nimport { SW_SECURE_DECODE } from './SW_SECURE_DECODE.ts'\n\n/**\n * Widevine Robustness.\n *\n * @public\n */\nexport const WidevineRobustness = {\n\tSW_SECURE_CRYPTO: SW_SECURE_CRYPTO as typeof SW_SECURE_CRYPTO,\n\tSW_SECURE_DECODE: SW_SECURE_DECODE as typeof SW_SECURE_DECODE,\n\tHW_SECURE_CRYPTO: HW_SECURE_CRYPTO as typeof HW_SECURE_CRYPTO,\n\tHW_SECURE_DECODE: HW_SECURE_DECODE as typeof HW_SECURE_DECODE,\n\tHW_SECURE_ALL: HW_SECURE_ALL as typeof HW_SECURE_ALL,\n} as const\n\n/**\n * Widevine Robustness.\n *\n * @public\n */\nexport type WidevineRobustness = ValueOf<typeof WidevineRobustness>;\n","import { createAudioSampleEntryReader, createVisualSampleEntryReader, findIsoBox, fourCcToUint32, readIsoBoxes, readStsd, writeAudioSampleEntryBox, writeFrma, writeIsoBoxes, writeSchm, writeStsd, writeTenc, writeVisualSampleEntryBox, type AudioSampleEntryBox, type VisualSampleEntryBox } from '@svta/cml-iso-bmff'\n\nconst audioTypes = [\n\t'mp4a',\n\t'ac-3',\n\t'ec-3',\n\t'ac-4',\n\t'fLaC',\n\t'Opus',\n]\n\nconst videoTypes = [\n\t'dvh1',\n\t'dvhe',\n\t'hev1',\n\t'hvc1',\n\t'avc1',\n\t'avc3',\n\t'dvav',\n\t'dva1',\n\t'dvc1',\n\t'dvi1',\n]\n\nconst readers = {\n\tstsd: readStsd,\n}\naudioTypes.forEach(type => (readers as any)[type] = createAudioSampleEntryReader(type))\nvideoTypes.forEach(type => (readers as any)[type] = createVisualSampleEntryReader(type))\n\nconst writers = {\n\tstsd: writeStsd,\n\tfrma: writeFrma,\n\tschm: writeSchm,\n\ttenc: writeTenc,\n\tencv: writeVisualSampleEntryBox,\n\tenca: writeAudioSampleEntryBox,\n}\naudioTypes.forEach(type => (writers as any)[type] = writeAudioSampleEntryBox)\nvideoTypes.forEach(type => (writers as any)[type] = writeVisualSampleEntryBox)\n\n/**\n * Options for the `ensureEncryptedInit` function.\n *\n * @public\n */\nexport type EnsureEncryptedInitOptions = {\n\t/**\n\t * Whether to prepend the encrypted entries to the sample table.\n\t *\n\t * @defaultValue `true`\n\t */\n\tprepend: boolean;\n\n\t/**\n\t * Whether to include the original init segment in the result.\n\t *\n\t * @defaultValue `true`\n\t */\n\tincludeOriginal: boolean;\n\n\t/**\n\t * The scheme type to use for the encryption. Defaults to `cenc`.\n\t *\n\t * @defaultValue `1667591779`\n\t */\n\tschemeType: number;\n\n\t/**\n\t * The default KID to use for the encryption.\n\t *\n\t * @defaultValue `[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]`\n\t */\n\tdefaultKid: number[];\n}\n\n/**\n * Ensures that the init segment is encrypted. Used on platforms that have issues playing unencrypted\n * content before playing encrypted content. Both prepend and includeOriginal are optional.\n *\n * @param init - The init segment to ensure is encrypted.\n * @param options - The options for the encryption.\n *\n * @returns The encrypted init segment.\n *\n * @public\n *\n * @example\n * {@includeCode ../test/ensureEncryptedInit.test.ts#example}\n */\nexport function ensureEncryptedInit(init: Uint8Array, options?: Partial<EnsureEncryptedInitOptions>): Uint8Array {\n\tconst { prepend = true, includeOriginal = true, schemeType = 1667591779, defaultKid = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } = options ?? {}\n\tconst boxes = readIsoBoxes(init, { readers })\n\tconst stsd = findIsoBox(boxes, box => box.type === 'stsd')\n\n\t// No stsd box found, return original init\n\tif (stsd?.type !== 'stsd') {\n\t\treturn init\n\t}\n\n\t// If the stsd box already contains enca or encv entries, return original init\n\tif (stsd.entries.find(({ type }) => type === 'enca' || type === 'encv')) {\n\t\treturn init\n\t}\n\n\tconst entries = stsd.entries.filter(({ type }) => videoTypes.includes(type) || audioTypes.includes(type))\n\n\t// Add sinf to each sample entry box\n\tfor (const entry of entries) {\n\t\tconst type = videoTypes.includes(entry.type) ? 'encv' : 'enca'\n\t\tconst box = { ...entry, boxes: entry.boxes.slice(), type } as AudioSampleEntryBox | VisualSampleEntryBox\n\n\t\tif (prepend) {\n\t\t\tstsd.entries.unshift(box)\n\t\t}\n\t\telse {\n\t\t\tstsd.entries.push(box)\n\t\t}\n\n\t\tbox.boxes.push({\n\t\t\ttype: 'sinf',\n\t\t\tboxes: [{\n\t\t\t\ttype: 'frma',\n\t\t\t\tdataFormat: fourCcToUint32(entry.type),\n\t\t\t}, {\n\t\t\t\ttype: 'schm',\n\t\t\t\tversion: 0,\n\t\t\t\tflags: 0,\n\t\t\t\tschemeType,\n\t\t\t\tschemeVersion: 65536,\n\t\t\t}, {\n\t\t\t\ttype: 'schi',\n\t\t\t\tboxes: [{\n\t\t\t\t\ttype: 'tenc',\n\t\t\t\t\tversion: 0,\n\t\t\t\t\tflags: 0,\n\t\t\t\t\tdefaultIsEncrypted: 1,\n\t\t\t\t\tdefaultIvSize: 8,\n\t\t\t\t\tdefaultKid,\n\t\t\t\t}],\n\t\t\t}],\n\t\t})\n\t}\n\n\t// Write the boxes to a new Uint8Array\n\tconst chunks = writeIsoBoxes(boxes, { writers })\n\tconst size = chunks.reduce((acc, chunk) => acc + chunk.byteLength, 0)\n\tconst length = includeOriginal ? init.length + size : size\n\tconst result = new Uint8Array(length)\n\tlet offset = 0\n\n\tfor (const box of chunks) {\n\t\tresult.set(box, offset)\n\t\toffset += box.byteLength\n\t}\n\n\tif (includeOriginal) {\n\t\tresult.set(init, offset)\n\t}\n\n\treturn result\n}\n"],"mappings":";;;;;;;;;;AAKA,MAAa,OAAO;;;;;;;;;ACApB,MAAa,OAAO;;;;;;;;;ACApB,MAAa,wBAAwB;;;;;;;;;;;;;;;ACWrC,SAAgB,0BAA0B,SAAwD;AACjG,KAAI,CAAC,QACJ,QAAO;AAGR,MAAK,MAAM,MAAM,QAChB,KACC,GAAG,aAAa,aAAa,KAAK,yBAClC,GAAG,UACF,GAAG,MAAM,aAAa,KAAK,QAC3B,GAAG,MAAM,aAAa,KAAK,MAE5B,QAAO;AAIT,QAAO;;;;;;;;;;;;;;;;;AClBR,SAAgB,yCACf,2BACA,aACgB;AAChB,QAAO,0BAA0B,MAAK,OAAM,GAAG,gBAAgB,YAAY,EAAE,SAAS;;;;;;;;;;;;;;;;ACPvF,SAAgB,YAAY,MAAwC;CACnE,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AK,GAAG,SAAS;EACxD,MAAM,MAAM;GAAE,GAAG;GAAO,OAAO,MAAM,MAAM,OAAO;GAAE;GAAM;AAE1D,MAAI,QACH,MAAK,QAAQ,QAAQ,IAAI;MAGzB,MAAK,QAAQ,KAAK,IAAI;AAGvB,MAAI,MAAM,KAAK;GACd,MAAM;GACN,OAAO;IAAC;KACP,MAAM;KACN,YAAY,eAAe,MAAM,KAAK;KACtC;IAAE;KACF,MAAM;KACN,SAAS;KACT,OAAO;KACP;KACA,eAAe;KACf;IAAE;KACF,MAAM;KACN,OAAO,CAAC;MACP,MAAM;MACN,SAAS;MACT,OAAO;MACP,oBAAoB;MACpB,eAAe;MACf;MACA,CAAC;KACF;IAAC;GACF,CAAC;;CAIH,MAAM,SAAS,cAAc,OAAO,EAAE,SAAS,CAAC;CAChD,MAAM,OAAO,OAAO,QAAQ,KAAK,UAAU,MAAM,MAAM,YAAY,EAAE;CACrE,MAAM,SAAS,kBAAkB,KAAK,SAAS,OAAO;CACtD,MAAM,SAAS,IAAI,WAAW,OAAO;CACrC,IAAI,SAAS;AAEb,MAAK,MAAM,OAAO,QAAQ;AACzB,SAAO,IAAI,KAAK,OAAO;AACvB,YAAU,IAAI;;AAGf,KAAI,gBACH,QAAO,IAAI,MAAM,OAAO;AAGzB,QAAO"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["pssh: Record<string, ArrayBufferLike | Uint8Array>","val: string","config: MediaKeySystemConfiguration","isTypeSupported: (keySystem: string, type: string) => boolean | undefined","headers: Record<string, string>"],"sources":["../src/common/CBCS.ts","../src/common/CENC.ts","../src/common/MP4_PROTECTION_SCHEME.ts","../src/cenc/findCencContentProtection.ts","../src/cenc/getLicenseServerUrlFromContentProtection.ts","../src/cenc/getPsshData.ts","../src/cenc/parsePsshList.ts","../src/cenc/getPsshForKeySystem.ts","../src/cenc/parseInitDataFromContentProtection.ts","../src/keysystem/createMediaKeySystemConfiguration.ts","../src/keysystem/getKeySystemAccess.ts","../src/keysystem/getSupportedKeySystemConfiguration.ts","../src/keysystem/getLegacyKeySystemAccess.ts","../src/fairplay/concatInitDataIdAndCertificate.ts","../src/fairplay/decodeFairPlayLicense.ts","../src/fairplay/extractContentId.ts","../src/fairplay/getId.ts","../src/fairplay/getLicenseServerUrl.ts","../src/common/CHALLENGE.ts","../src/common/PLAYREADY_KEY_MESSAGE.ts","../src/playready/getLicenseRequestFromMessage.ts","../src/common/CONTENT_TYPE.ts","../src/common/HTTP_HEADERS.ts","../src/common/TEXT_XML_UTF8.ts","../src/playready/getRequestHeadersFromMessage.ts","../src/playready/toBigEndianKeyId.ts","../src/common/CLEAR_KEY_SYSTEM.ts","../src/common/CLEAR_KEY_UUID.ts","../src/common/EncryptionScheme.ts","../src/common/EXPIRED.ts","../src/common/FAIRPLAY_KEY_SYSTEM.ts","../src/common/FAIRPLAY_UUID.ts","../src/common/HW_SECURE_ALL.ts","../src/common/HW_SECURE_CRYPTO.ts","../src/common/HW_SECURE_DECODE.ts","../src/common/INDIVIDUALIZATION_REQUEST.ts","../src/common/KEYIDS.ts","../src/common/WEBM.ts","../src/common/InitializationDataType.ts","../src/common/INTERNAL_ERROR.ts","../src/common/LICENSE_ACQUISITION.ts","../src/common/LICENSE_RELEASE.ts","../src/common/LICENSE_RENEWAL.ts","../src/common/LICENSE_REQUEST.ts","../src/common/MediaKeyMessageType.ts","../src/common/OUTPUT_DOWNSCALED.ts","../src/common/OUTPUT_RESTRICTED.ts","../src/common/RELEASED.ts","../src/common/STATUS_PENDING.ts","../src/common/USABLE.ts","../src/common/MediaKeyStatus.ts","../src/common/PLAYREADY_KEY_SYSTEM.ts","../src/common/PLAYREADY_RECOMMENDATION_KEY_SYSTEM.ts","../src/common/PLAYREADY_UUID.ts","../src/common/SW_SECURE_CRYPTO.ts","../src/common/SW_SECURE_DECODE.ts","../src/common/W3C_CLEAR_KEY_UUID.ts","../src/common/WIDEVINE_KEY_SYSTEM.ts","../src/common/WIDEVINE_UUID.ts","../src/common/WidevineRobustness.ts","../src/ensureEncryptedInit.ts"],"sourcesContent":["/**\n * Cipher Block Chaining Sample encryption scheme.\n *\n * @public\n */\nexport const CBCS = 'cbcs'\n","/**\n * Common Encryption scheme.\n *\n * @public\n */\nexport const CENC = 'cenc'\n","/**\n * The DASH MP4 Protection Scheme schemeIdUri.\n *\n * @public\n */\nexport const MP4_PROTECTION_SCHEME = 'urn:mpeg:dash:mp4protection:2011'\n","import { CBCS } from '../common/CBCS.ts'\nimport { CENC } from '../common/CENC.ts'\nimport type { ContentProtection } from '../common/ContentProtection.ts'\nimport { MP4_PROTECTION_SCHEME } from '../common/MP4_PROTECTION_SCHEME.ts'\n\n/**\n * Finds and returns the ContentProtection element for MP4 Common Encryption.\n *\n * @param cpArray - Array of ContentProtection elements.\n * @returns The Common Encryption content protection element, or null if not found.\n *\n * @public\n *\n * @example\n * {@includeCode ../../test/cenc/findCencContentProtection.test.ts#example}\n */\nexport function findCencContentProtection(cpArray: ContentProtection[]): ContentProtection | null {\n\tif (!cpArray) {\n\t\treturn null\n\t}\n\n\tfor (const cp of cpArray) {\n\t\tif (\n\t\t\tcp.schemeIdUri?.toLowerCase() === MP4_PROTECTION_SCHEME &&\n\t\t\tcp.value &&\n\t\t\t(cp.value.toLowerCase() === CENC ||\n\t\t\t\tcp.value.toLowerCase() === CBCS)\n\t\t) {\n\t\t\treturn cp\n\t\t}\n\t}\n\n\treturn null\n}\n","import type { ContentProtection } from '../common/ContentProtection.ts'\n\n/**\n * Extracts a license server URL from an array of ContentProtection elements.\n *\n * @param contentProtectionElements - Array of ContentProtection nodes from the manifest.\n * @param schemeIdUri - schemeIdUri we are searching for.\n * @returns The license server URL, and if not found then null.\n *\n * @public\n *\n * @example\n * {@includeCode ../../test/cenc/getLicenseServerUrlFromContentProtection.test.ts#example}\n */\nexport function getLicenseServerUrlFromContentProtection(\n\tcontentProtectionElements: ContentProtection[],\n\tschemeIdUri: string,\n): string | null {\n\treturn contentProtectionElements.find(cp => cp.schemeIdUri === schemeIdUri)?.laUrl || null\n}\n","/**\n * Returns the data portion of a single PSSH box.\n *\n * @param pssh - The PSSH ArrayBuffer.\n * @returns The data portion of the PSSH.\n *\n * @public\n *\n * @example\n * {@includeCode ../../test/cenc/getPsshData.test.ts#example}\n */\nexport function getPsshData(pssh: ArrayBufferLike): ArrayBufferLike {\n\tconst offset = 8 // Box size and type fields\n\tconst view = new DataView(pssh)\n\n\tconst version = view.getUint8(offset) // Read version\n\tlet dataOffset = offset + 20\n\n\tif (version > 0) {\n\t\tconst kidCount = view.getUint32(dataOffset)\n\t\tdataOffset += 4 + (16 * kidCount)\n\t}\n\n\tdataOffset += 4 // Data size\n\treturn pssh.slice(dataOffset)\n}\n\n","import { isArrayBufferLike } from '@svta/cml-utils'\n\n/**\n * Parses a list of PSSH boxes into keysystem-specific PSSH data.\n *\n * @param data - The concatenated list of PSSH boxes as provided by\n * the CDM as initialization data when CommonEncryption content is detected\n * @returns An object that has a property named according to each of\n * the detected key system UUIDs (e.g. 00000000-0000-0000-0000-0000000000)\n * and a ArrayBuffer (the entire PSSH box) as the property value\n *\n * @public\n *\n * @example\n * {@includeCode ../../test/cenc/parsePsshList.test.ts#example}\n */\nexport function parsePsshList(data: ArrayBufferLike): Record<string, ArrayBufferLike>\nexport function parsePsshList(data: Uint8Array): Record<string, Uint8Array>\nexport function parsePsshList(data: ArrayBufferLike | Uint8Array): Record<string, ArrayBufferLike | Uint8Array> {\n\tif (!data) {\n\t\treturn {}\n\t}\n\n\t// data.buffer first for Uint8Array support\n\tconst dv = isArrayBufferLike(data)\n\t\t? new DataView(data)\n\t\t: new DataView((data as Uint8Array).buffer, data.byteOffset, data.byteLength)\n\tconst pssh: Record<string, ArrayBufferLike | Uint8Array> = {}\n\tlet byteCursor = 0\n\n\twhile (true) {\n\t\tif (byteCursor >= dv.byteLength) {\n\t\t\tbreak\n\t\t}\n\n\t\tconst boxStart = byteCursor\n\n\t\t// Box size\n\t\tconst size = dv.getUint32(byteCursor)\n\t\tconst nextBox = byteCursor + size\n\t\tbyteCursor += 4\n\n\t\t// Verify PSSH\n\t\tif (dv.getUint32(byteCursor) !== 0x70737368) {\n\t\t\tbyteCursor = nextBox\n\t\t\tcontinue\n\t\t}\n\t\tbyteCursor += 4\n\n\t\t// Version must be 0 or 1\n\t\tconst version = dv.getUint8(byteCursor)\n\t\tif (version !== 0 && version !== 1) {\n\t\t\tbyteCursor = nextBox\n\t\t\tcontinue\n\t\t}\n\n\t\tbyteCursor += 1 // Move past version\n\t\tbyteCursor += 3 // Skip flags\n\n\t\t// 16-byte UUID/SystemID\n\t\tlet systemID = ''\n\t\tlet val: string\n\n\t\tfor (let i = 0; i < 4; i++) {\n\t\t\tval = dv.getUint8(byteCursor + i).toString(16)\n\t\t\tsystemID += val.length === 1 ? '0' + val : val\n\t\t}\n\t\tbyteCursor += 4\n\t\tsystemID += '-'\n\n\t\tfor (let i = 0; i < 2; i++) {\n\t\t\tval = dv.getUint8(byteCursor + i).toString(16)\n\t\t\tsystemID += val.length === 1 ? '0' + val : val\n\t\t}\n\t\tbyteCursor += 2\n\t\tsystemID += '-'\n\n\t\tfor (let i = 0; i < 2; i++) {\n\t\t\tval = dv.getUint8(byteCursor + i).toString(16)\n\t\t\tsystemID += val.length === 1 ? '0' + val : val\n\t\t}\n\t\tbyteCursor += 2\n\t\tsystemID += '-'\n\n\t\tfor (let i = 0; i < 2; i++) {\n\t\t\tval = dv.getUint8(byteCursor + i).toString(16)\n\t\t\tsystemID += val.length === 1 ? '0' + val : val\n\t\t}\n\t\tbyteCursor += 2\n\t\tsystemID += '-'\n\n\t\tfor (let i = 0; i < 6; i++) {\n\t\t\tval = dv.getUint8(byteCursor + i).toString(16)\n\t\t\tsystemID += val.length === 1 ? '0' + val : val\n\t\t}\n\t\tbyteCursor += 6\n\n\t\tsystemID = systemID.toLowerCase()\n\n\t\t// PSSH Data Size\n\t\tbyteCursor += 4\n\n\t\t// PSSH boxdata\n\t\tpssh[systemID] = data.slice(boxStart, nextBox)\n\n\t\tbyteCursor = nextBox\n\t}\n\n\treturn pssh\n}\n\n","import { parsePsshList } from './parsePsshList.ts'\n\n/**\n * Returns the PSSH box associated with the given key system from the concatenated\n * list of PSSH boxes in the provided initData.\n *\n * @param uuid - The desired key system UUID\n * @param initData - 'cenc' initialization data. Concatenated list of PSSH boxes.\n * @returns The PSSH box ArrayBuffer corresponding to the given key system, or null if not found.\n *\n * @public\n *\n * @example\n * {@includeCode ../../test/cenc/getPsshForKeySystem.test.ts#example}\n */\nexport function getPsshForKeySystem(\n\tuuid: string,\n\tinitData: ArrayBufferLike,\n): ArrayBufferLike | null {\n\tif (!initData || !uuid) {\n\t\treturn null\n\t}\n\n\tconst psshList = parsePsshList(initData)\n\treturn psshList[uuid.toLowerCase()] || null\n}\n","import type { ContentProtection } from '../common/ContentProtection.ts'\n\n/**\n * Parse a standard common encryption PSSH which contains a simple\n * base64-encoding of the init data\n *\n * @param cpData - The ContentProtection element that may contain PSSH data.\n * @param BASE64 - The BASE64 reference.\n * @returns init data as an ArrayBuffer, or null if not found.\n *\n * @public\n *\n * @example\n * {@includeCode ../../test/cenc/parseInitDataFromContentProtection.test.ts#example}\n */\nexport function parseInitDataFromContentProtection(\n\tcpData: ContentProtection,\n\tBASE64: { decodeArray: (input: string) => Uint8Array },\n): ArrayBuffer | null {\n\tif (cpData?.pssh && cpData.pssh) {\n\t\tconst cleanedText = cpData.pssh.replace(/\\r?\\n|\\r/g, '').replace(/\\s+/g, '')\n\t\treturn BASE64.decodeArray(cleanedText).buffer as ArrayBuffer\n\t}\n\n\treturn null\n}\n","/**\n * Creates a valid KeySystemConfiguration from supported audio and video capabilities.\n *\n * @param supportedAudio - supported audio capabilities.\n * @param supportedVideo - supported video capabilities.\n * @returns KeySystemConfiguration object.\n *\n * @public\n *\n * @example\n * {@includeCode ../../test/keysystem/createMediaKeySystemConfiguration.test.ts#example}\n */\nexport function createMediaKeySystemConfiguration(\n\tsupportedAudio: MediaKeySystemMediaCapability[] | null,\n\tsupportedVideo: MediaKeySystemMediaCapability[] | null,\n): MediaKeySystemConfiguration {\n\tconst config: MediaKeySystemConfiguration = {}\n\n\tif (supportedAudio && supportedAudio.length > 0) {\n\t\tconfig.audioCapabilities = supportedAudio\n\t}\n\n\tif (supportedVideo && supportedVideo.length > 0) {\n\t\tconfig.videoCapabilities = supportedVideo\n\t}\n\n\t// default values\n\tconfig.distinctiveIdentifier = 'optional'\n\tconfig.persistentState = 'optional'\n\tconfig.sessionTypes = ['temporary']\n\n\treturn config\n}\n","import type { MediaKeySystemAccessRequest } from '../common/MediaKeySystemAccessRequest.ts'\n\n/**\n * Attempts to get key system access using requestMediaKeySystemAccess from EME.\n *\n * @param requests - An array of key system access requests.\n * @returns MediaKeySystemAccess object if successful, or null if no system is supported.\n *\n * @public\n */\nexport async function getKeySystemAccess(\n\trequests: MediaKeySystemAccessRequest[],\n): Promise<MediaKeySystemAccess | null> {\n\tfor (const { keySystem, configurations } of requests) {\n\t\ttry {\n\t\t\treturn await navigator.requestMediaKeySystemAccess(keySystem, configurations)\n\t\t}\n\t\tcatch {\n\t\t\t// legacy approach could be used here\n\t\t}\n\t}\n\treturn null\n}\n","// The pure IIFE keeps this module-scope MediaKeys read from being retained by\n// consumer bundlers when this function is unused (unknown global reads are\n// treated as side effects).\nconst isTypeSupported: (keySystem: string, type: string) => boolean | undefined = /* @__PURE__ */ (() =>\n\t(typeof MediaKeys !== 'undefined' && typeof (MediaKeys as any).isTypeSupported === 'function') ? (MediaKeys as any).isTypeSupported : undefined\n)()\n\n/**\n * Filters and returns the supported key system configuration for a given system string.\n *\n * @param keySystem - Key system string such as 'com.widevine.alpha'\n * @param configs - An array of key system configurations.\n * @returns The first supported configuration or null if none are supported.\n *\n * @public\n */\nexport function getSupportedKeySystemConfiguration(\n\tkeySystem: string,\n\tconfigs: Iterable<MediaKeySystemConfiguration>,\n): { supportedAudio: MediaKeySystemMediaCapability[]; supportedVideo: MediaKeySystemMediaCapability[] } {\n\tif (!configs || typeof isTypeSupported === 'undefined') {\n\t\treturn { supportedAudio: [], supportedVideo: [] }\n\t}\n\n\tfor (const config of configs) {\n\t\tconst audios = config.audioCapabilities || []\n\t\tconst videos = config.videoCapabilities || []\n\n\t\tconst supportedAudio = audios.filter(audio => isTypeSupported(keySystem, audio.contentType ?? ''))\n\t\tconst supportedVideo = videos.filter(video => isTypeSupported(keySystem, video.contentType ?? ''))\n\n\t\tconst hasAudio = supportedAudio.length > 0\n\t\tconst hasVideo = supportedVideo.length > 0\n\n\t\tif (hasAudio || hasVideo) {\n\t\t\treturn { supportedAudio, supportedVideo }\n\t\t}\n\t}\n\n\treturn { supportedAudio: [], supportedVideo: [] }\n}\n","import type { MediaKeySystemAccessRequest } from '../common/MediaKeySystemAccessRequest.ts'\nimport { createMediaKeySystemConfiguration } from './createMediaKeySystemConfiguration.ts'\nimport { getSupportedKeySystemConfiguration } from './getSupportedKeySystemConfiguration.ts'\n\n/**\n * Fallback method to get key system access using legacy MediaKeys.isTypeSupported().\n *\n * @param requests - An array of key system access requests.\n * @returns A KeySystemAccess object if successful, or null if no system is supported.\n *\n * @public\n */\nexport function getLegacyKeySystemAccess(\n\trequests: MediaKeySystemAccessRequest[],\n): MediaKeySystemAccessRequest | null {\n\tfor (const { keySystem, configurations } of requests) {\n\t\tconst supportedConfig = getSupportedKeySystemConfiguration(keySystem, configurations)\n\t\tif (supportedConfig) {\n\t\t\tconst configuration = createMediaKeySystemConfiguration(\n\t\t\t\tsupportedConfig.supportedAudio,\n\t\t\t\tsupportedConfig.supportedVideo,\n\t\t\t)\n\n\t\t\treturn {\n\t\t\t\tkeySystem,\n\t\t\t\tconfigurations: [configuration],\n\t\t\t}\n\t\t}\n\t}\n\treturn null\n}\n","import { stringToUint16 } from '@svta/cml-utils'\n\n/**\n * Concatenates InitData, ID, and Certificate for FairPlay DRM.\n *\n * @param initData - The initialization data (PSSH box)\n * @param id - The content ID (string or Uint16Array)\n * @param cert - The application certificate (Uint8Array)\n * @returns A Uint8Array containing the concatenated data\n *\n * @public\n *\n * @example\n * {@includeCode ../../test/fairplay/concatInitDataIdAndCertificate.test.ts#example}\n */\n\nexport function concatInitDataIdAndCertificate(initData: Uint16Array, id: Uint16Array | string, cert: Uint8Array): Uint8Array {\n\tif (typeof id === 'string') {\n\t\tid = stringToUint16(id)\n\t}\n\tconst buffer = new ArrayBuffer(initData.byteLength + 4 + id.byteLength + 4 + cert.byteLength)\n\tconst dataView = new DataView(buffer)\n\tlet offset = 0\n\n\tnew Uint8Array(buffer, offset, initData.byteLength).set(initData)\n\toffset += initData.byteLength\n\n\tdataView.setUint32(offset, id.byteLength, true)\n\toffset += 4\n\tnew Uint16Array(buffer, offset, id.length).set(id)\n\toffset += id.byteLength\n\n\tdataView.setUint32(offset, cert.byteLength, true)\n\toffset += 4\n\tnew Uint8Array(buffer, offset, cert.byteLength).set(cert)\n\n\treturn new Uint8Array(buffer)\n}\n","import { decodeBase64 } from '@svta/cml-utils'\n\n/**\n * Decodes a FairPlay DRM license response.\n *\n * @param response - The license response, either a base64 string or ArrayBuffer\n * @returns A Uint8Array containing the decoded license\n *\n * @public\n *\n * @example\n * {@includeCode ../../test/fairplay/decodeFairPlayLicense.test.ts#example}\n */\n\nexport function decodeFairPlayLicense(response: string | ArrayBuffer): Uint8Array {\n\treturn typeof response === 'string'\n\t\t? decodeBase64(response)\n\t\t: new Uint8Array(response)\n}\n","import type { Encoding } from '@svta/cml-utils'\nimport { decodeText, UTF_16 } from '@svta/cml-utils'\n\n/**\n * Extracts the content ID from InitData using skd:// URI or query parameters.\n *\n * @param initData - The initialization data (PSSH box)\n * @returns The extracted content ID\n *\n * @public\n *\n * @example\n * {@includeCode ../../test/fairplay/extractContentId.test.ts#example}\n */\nexport function extractContentId(initData: ArrayBufferLike, encoding: Encoding = UTF_16): string {\n\tconst initDataString = decodeText(initData, { encoding })\n\n\t// Try extracting skd:// content ID\n\treturn initDataString.split('skd://')[1] || ''\n}\n","import { extractContentId } from './extractContentId.ts'\n\n/**\n * Extracts the content ID from the license server URL or InitData.\n *\n * @param licenseServerUrl - The license server URL\n * @param initData - The initialization data (PSSH box)\n * @param queryParam - The query parameter key to extract (default: 'ContentId')\n * @returns The extracted content ID as a string or null if not found\n *\n * @public\n *\n * @example\n * {@includeCode ../../test/fairplay/getId.test.ts#example}\n */\n\nexport function getId(licenseServerUrl: string, initData: ArrayBufferLike, queryParam: string = 'ContentId'): string {\n\ttry {\n\t\tconst url = new URL(licenseServerUrl)\n\t\tconst params = new URLSearchParams(url.search)\n\t\treturn params.get(queryParam) || extractContentId(initData)\n\t}\n\tcatch {\n\t\t// in case if URL parsing fails,\n\t\t// fallback to extracting from initData\n\t\treturn extractContentId(initData)\n\t}\n}\n","/**\n * Retrieves the FairPlay license server URL from InitData.\n *\n * @param initData - The initialization data (PSSH box)\n * @returns The license server URL as a string\n *\n * @public\n *\n * @example\n * {@includeCode ../../test/fairplay/getLicenseServerUrl.test.ts#example}\n */\n\nexport function getLicenseServerUrl(initData: Uint16Array): string {\n\tlet initDataString = ''\n\tfor (const code of initData) {\n\t\tif (code !== 0) { // Ignore null characters\n\t\t\tinitDataString += String.fromCharCode(code)\n\t\t}\n\t}\n\n\tconst match = initDataString.match(/skd:\\/\\/([^\"\\s]+)/)\n\treturn match ? `https://${match[1]}` : ''\n}\n","/**\n * License Challenge.\n *\n * @public\n */\nexport const CHALLENGE = 'Challenge'\n","/**\n * Playready Key Message.\n *\n * @public\n */\nexport const PLAYREADY_KEY_MESSAGE = 'PlayReadyKeyMessage'\n","import type { Encoding } from '@svta/cml-utils'\nimport { decodeBase64, decodeText, UTF_16 } from '@svta/cml-utils'\nimport { getElementsByName, parseXml } from '@svta/cml-xml'\nimport { CHALLENGE } from '../common/CHALLENGE.ts'\nimport { PLAYREADY_KEY_MESSAGE } from '../common/PLAYREADY_KEY_MESSAGE.ts'\n\n/**\n * Gets the PlayReady license request from the MediaKeyMessageEvent.\n *\n * @param message - An ArrayBuffer from the content decryption module.\n * @param encoding - The message encoding type. Default is UTF-16.\n * @returns The license request as an ArrayBuffer.\n *\n * @public\n *\n * @example\n * {@includeCode ../../test/playready/getLicenseRequestFromMessage.test.ts#example}\n */\nexport function getLicenseRequestFromMessage(\n\tmessage: ArrayBuffer,\n\tencoding: Encoding = UTF_16,\n): ArrayBuffer {\n\n\t// If encoding is configured for UTF-16 and the number of bytes is odd,\n\t// assume an 'unwrapped' raw CDM message.\n\tif (encoding === UTF_16 && message?.byteLength % 2 === 1) {\n\t\treturn message\n\t}\n\n\tconst msg = decodeText(message, { encoding })\n\tconst xml = parseXml(msg)\n\tconst playReadyKeyMessage = getElementsByName(xml, PLAYREADY_KEY_MESSAGE)[0]\n\n\tif (!playReadyKeyMessage) {\n\t\t// The message from the CDM is not wrapped and contains the direct challenge.\n\t\treturn message\n\t}\n\n\tconst challengeNode = getElementsByName(playReadyKeyMessage, CHALLENGE)[0]\n\tconst challengeValue = challengeNode?.childNodes[0]?.nodeValue\n\n\tif (challengeValue) {\n\t\treturn decodeBase64(challengeValue).buffer as ArrayBuffer\n\t}\n\n\treturn message\n}\n","/**\n * Content-Type header.\n *\n * @public\n */\nexport const CONTENT_TYPE = 'Content-Type'\n","/**\n * Playready HTTP Headers.\n *\n * @public\n */\nexport const HTTP_HEADERS = 'HttpHeaders'\n","/**\n * XML formatted, UTF-8 encoded, text header.\n *\n * @public\n */\nexport const TEXT_XML_UTF8 = 'text/xml; charset=utf-8'\n","import type { UTF_8 } from '@svta/cml-utils'\nimport { decodeText, UTF_16 } from '@svta/cml-utils'\nimport { getElementsByName, parseXml } from '@svta/cml-xml'\nimport { CONTENT_TYPE } from '../common/CONTENT_TYPE.ts'\nimport { HTTP_HEADERS } from '../common/HTTP_HEADERS.ts'\nimport { TEXT_XML_UTF8 } from '../common/TEXT_XML_UTF8.ts'\n\n/**\n * Gets the PlayReady license request headers from the MediaKeyMessageEvent.\n *\n * @param message - An ArrayBuffer from the content decryption module.\n * @param encoding - The message encoding type. Default is UTF-16.\n * @returns Request headers.\n *\n * @public\n *\n * @example\n * {@includeCode ../../test/playready/getRequestHeadersFromMessage.test.ts#example}\n */\nexport function getRequestHeadersFromMessage(\n\tmessage: ArrayBuffer,\n\tencoding: typeof UTF_8 | typeof UTF_16 = UTF_16,\n): Record<string, string> {\n\tconst headers: Record<string, string> = {}\n\n\t// If message format configured/defaulted to utf-16 AND number of bytes is odd,\n\t// assume 'unwrapped' raw CDM message.\n\tif (encoding === UTF_16 && message && message.byteLength % 2 === 1) {\n\t\theaders[CONTENT_TYPE] = TEXT_XML_UTF8\n\t\treturn headers\n\t}\n\n\tconst msg = decodeText(message, { encoding })\n\tconst xml = parseXml(msg)\n\tconst httpHeaders = getElementsByName(xml, HTTP_HEADERS)[0]?.childNodes\n\n\tif (!httpHeaders) {\n\t\treturn headers\n\t}\n\n\tfor (const header of httpHeaders) {\n\t\tconst name = getElementsByName(header, 'name')[0]?.childNodes[0]?.nodeValue\n\t\tconst value = getElementsByName(header, 'value')[0]?.childNodes[0]?.nodeValue\n\n\t\tif (name && value) {\n\t\t\theaders[name] = value\n\t\t}\n\t}\n\t// Some versions of the PlayReady CDM return 'Content' instead of 'Content-Type'.\n\t// This does not adhere to the W3C spec and license servers may reject the request.\n\tif (headers['Content']) {\n\t\theaders[CONTENT_TYPE] = headers['Content']\n\t\tdelete headers['Content']\n\t}\n\t// Set 'Content-Type' header by default if not provided in the the CDM message\n\t// or if the message is unwrapped.\n\tif (!headers[CONTENT_TYPE]) {\n\t\theaders[CONTENT_TYPE] = TEXT_XML_UTF8\n\t}\n\n\treturn headers\n}\n","/**\n * Converts a 16-byte key ID from little-endian to big-endian format.\n *\n * @param keyId - The little-endian key ID to convert.\n * @returns The big-endian representation of the key ID.\n *\n * @public\n *\n * @example\n * {@includeCode ../../test/playready/toBigEndianKeyId.test.ts#example}\n */\nexport function toBigEndianKeyId(keyId: ArrayBuffer): ArrayBuffer {\n\tif (keyId.byteLength !== 16) {\n\t\treturn keyId\n\t}\n\n\tconst buffer = keyId.slice(0)\n\tconst dataView = new DataView(buffer)\n\tdataView.setUint32(0, dataView.getUint32(0, true), false)\n\tdataView.setUint16(4, dataView.getUint16(4, true), false)\n\tdataView.setUint16(6, dataView.getUint16(6, true), false)\n\n\treturn buffer\n}\n","/**\n * Clear Key System.\n *\n * @public\n */\nexport const CLEAR_KEY_SYSTEM = 'org.w3.clearkey'\n","/**\n * Clear Key UUID.\n *\n * @public\n */\nexport const CLEAR_KEY_UUID = 'e2719d58-a985-b3c9-781a-b030af78d30e'\n","import type { ValueOf } from '@svta/cml-utils'\nimport { CBCS } from './CBCS.ts'\nimport { CENC } from './CENC.ts'\n\n/**\n * Encryption schemes.\n *\n * @public\n */\nexport const EncryptionScheme = {\n\tCENC: CENC as typeof CENC,\n\tCBCS: CBCS as typeof CBCS,\n} as const\n\n/**\n * Encryption schemes.\n *\n * @public\n */\nexport type EncryptionScheme = ValueOf<typeof EncryptionScheme>;\n","/**\n * Expired Media Key Status.\n *\n * @public\n */\nexport const EXPIRED = 'expired'\n","/**\n * FairPlay Key System.\n *\n * @public\n */\nexport const FAIRPLAY_KEY_SYSTEM = 'com.apple.fps.1_0'\n","/**\n * FairPlay UUID.\n *\n * @public\n */\nexport const FAIRPLAY_UUID = '29701fe4-3cc7-4a34-8c5b-ae90c7439a47'\n","/**\n * Hardware Secure All Robustness.\n *\n * @public\n */\nexport const HW_SECURE_ALL = 'HW_SECURE_ALL'\n","/**\n * Hardware Secure Crypto Robustness.\n *\n * @public\n */\nexport const HW_SECURE_CRYPTO = 'HW_SECURE_CRYPTO'\n","/**\n * Hardware Secure Decode Robustness.\n *\n * @public\n */\nexport const HW_SECURE_DECODE = 'HW_SECURE_DECODE'\n","/**\n * Individualization Request.\n *\n * @public\n */\nexport const INDIVIDUALIZATION_REQUEST = 'individualization-request'\n","/**\n * Key IDs.\n *\n * @public\n */\nexport const KEYIDS = 'keyids'\n","/**\n * WEBM.\n *\n * @public\n */\nexport const WEBM = 'webm'\n","import type { ValueOf } from '@svta/cml-utils'\nimport { CBCS } from './CBCS.ts'\nimport { CENC } from './CENC.ts'\nimport { KEYIDS } from './KEYIDS.ts'\nimport { WEBM } from './WEBM.ts'\n\n/**\n * Initialization Data Type.\n *\n * @public\n */\nexport const InitializationDataType = {\n\tCENC: CENC as typeof CENC,\n\tCBCS: CBCS as typeof CBCS,\n\tKEYIDS: KEYIDS as typeof KEYIDS,\n\tWEBM: WEBM as typeof WEBM,\n} as const\n\n/**\n * Initialization Data Type.\n *\n * @public\n */\nexport type InitializationDataType = ValueOf<typeof InitializationDataType>;\n","/**\n * Internal Error Media Key Status.\n *\n * @public\n */\nexport const INTERNAL_ERROR = 'internal-error'\n","/**\n * License Acquisition.\n *\n * @public\n */\nexport const LICENSE_ACQUISITION = 'LicenseAcquisition'\n","/**\n * License Release.\n *\n * @public\n */\nexport const LICENSE_RELEASE = 'license-release'\n","/**\n * License Renewal.\n *\n * @public\n */\nexport const LICENSE_RENEWAL = 'license-renewal'\n","/**\n * License Request.\n *\n * @public\n */\nexport const LICENSE_REQUEST = 'license-request'\n","import type { ValueOf } from '@svta/cml-utils'\nimport { INDIVIDUALIZATION_REQUEST } from './INDIVIDUALIZATION_REQUEST.ts'\nimport { LICENSE_RELEASE } from './LICENSE_RELEASE.ts'\nimport { LICENSE_RENEWAL } from './LICENSE_RENEWAL.ts'\nimport { LICENSE_REQUEST } from './LICENSE_REQUEST.ts'\n\n/**\n * Media Key Message Types.\n *\n * @public\n */\nexport const MediaKeyMessageType = {\n\tLICENSE_REQUEST: LICENSE_REQUEST as typeof LICENSE_REQUEST,\n\tLICENSE_RENEWAL: LICENSE_RENEWAL as typeof LICENSE_RENEWAL,\n\tLICENSE_RELEASE: LICENSE_RELEASE as typeof LICENSE_RELEASE,\n\tINDIVIDUALIZATION_REQUEST: INDIVIDUALIZATION_REQUEST as typeof INDIVIDUALIZATION_REQUEST,\n} as const\n\n/**\n * Media Key Message Types.\n *\n * @public\n */\nexport type MediaKeyMessageType = ValueOf<typeof MediaKeyMessageType>;\n","/**\n * Output Downscaled Media Key Status.\n *\n * @public\n */\nexport const OUTPUT_DOWNSCALED = 'output-downscaled'\n","/**\n * Output Restricted Media Key Status.\n *\n * @public\n */\nexport const OUTPUT_RESTRICTED = 'output-restricted'\n","/**\n * Released Media Key Status.\n *\n * @public\n */\nexport const RELEASED = 'released'\n","/**\n * Status Pending Media Key Status.\n *\n * @public\n */\nexport const STATUS_PENDING = 'status-pending'\n","/**\n * Usable Media Key Status.\n *\n * @public\n */\nexport const USABLE = 'usable'\n","import type { ValueOf } from '@svta/cml-utils'\nimport { EXPIRED } from './EXPIRED.ts'\nimport { INTERNAL_ERROR } from './INTERNAL_ERROR.ts'\nimport { OUTPUT_DOWNSCALED } from './OUTPUT_DOWNSCALED.ts'\nimport { OUTPUT_RESTRICTED } from './OUTPUT_RESTRICTED.ts'\nimport { RELEASED } from './RELEASED.ts'\nimport { STATUS_PENDING } from './STATUS_PENDING.ts'\nimport { USABLE } from './USABLE.ts'\n\n/**\n * Media Key Statuses.\n *\n * @public\n */\nexport const MediaKeyStatus = {\n\tUSABLE: USABLE as typeof USABLE,\n\tEXPIRED: EXPIRED as typeof EXPIRED,\n\tRELEASED: RELEASED as typeof RELEASED,\n\tOUTPUT_RESTRICTED: OUTPUT_RESTRICTED as typeof OUTPUT_RESTRICTED,\n\tOUTPUT_DOWNSCALED: OUTPUT_DOWNSCALED as typeof OUTPUT_DOWNSCALED,\n\tSTATUS_PENDING: STATUS_PENDING as typeof STATUS_PENDING,\n\tINTERNAL_ERROR: INTERNAL_ERROR as typeof INTERNAL_ERROR,\n} as const\n\n/**\n * Media Key Statuses.\n *\n * @public\n */\nexport type MediaKeyStatus = ValueOf<typeof MediaKeyStatus>;\n","/**\n * Playready Key System.\n *\n * @public\n */\nexport const PLAYREADY_KEY_SYSTEM = 'com.microsoft.playready'\n","/**\n * Playready Recommendation Key System.\n *\n * @public\n */\nexport const PLAYREADY_RECOMMENDATION_KEY_SYSTEM = 'com.microsoft.playready.recommendation'\n","/**\n * Playready UUID.\n *\n * @public\n */\nexport const PLAYREADY_UUID = '9a04f079-9840-4286-ab92-e65be0885f95'\n","/**\n * Software Secure Crypto Robustness.\n *\n * @public\n */\nexport const SW_SECURE_CRYPTO = 'SW_SECURE_CRYPTO'\n","/**\n * Software Secure Decode Robustness.\n *\n * @public\n */\nexport const SW_SECURE_DECODE = 'SW_SECURE_DECODE'\n","/**\n * W3C Clear Key UUID.\n *\n * @public\n */\nexport const W3C_CLEAR_KEY_UUID = '1077efec-c0b2-4d02-ace3-3c1e52e2fb4b'\n","/**\n * Widevine Key System.\n *\n * @public\n */\nexport const WIDEVINE_KEY_SYSTEM = 'com.widevine.alpha'\n","/**\n * Widevine UUID.\n *\n * @public\n */\nexport const WIDEVINE_UUID = 'edef8ba9-79d6-4ace-a3c8-27dcd51d21ed'\n","import type { ValueOf } from '@svta/cml-utils'\nimport { HW_SECURE_ALL } from './HW_SECURE_ALL.ts'\nimport { HW_SECURE_CRYPTO } from './HW_SECURE_CRYPTO.ts'\nimport { HW_SECURE_DECODE } from './HW_SECURE_DECODE.ts'\nimport { SW_SECURE_CRYPTO } from './SW_SECURE_CRYPTO.ts'\nimport { SW_SECURE_DECODE } from './SW_SECURE_DECODE.ts'\n\n/**\n * Widevine Robustness.\n *\n * @public\n */\nexport const WidevineRobustness = {\n\tSW_SECURE_CRYPTO: SW_SECURE_CRYPTO as typeof SW_SECURE_CRYPTO,\n\tSW_SECURE_DECODE: SW_SECURE_DECODE as typeof SW_SECURE_DECODE,\n\tHW_SECURE_CRYPTO: HW_SECURE_CRYPTO as typeof HW_SECURE_CRYPTO,\n\tHW_SECURE_DECODE: HW_SECURE_DECODE as typeof HW_SECURE_DECODE,\n\tHW_SECURE_ALL: HW_SECURE_ALL as typeof HW_SECURE_ALL,\n} as const\n\n/**\n * Widevine Robustness.\n *\n * @public\n */\nexport type WidevineRobustness = ValueOf<typeof WidevineRobustness>;\n","import { createAudioSampleEntryReader, createVisualSampleEntryReader, findIsoBox, fourCcToUint32, readIsoBoxes, readStsd, writeAudioSampleEntryBox, writeFrma, writeIsoBoxes, writeSchm, writeStsd, writeTenc, writeVisualSampleEntryBox, type AudioSampleEntryBox, type VisualSampleEntryBox } from '@svta/cml-iso-bmff'\n\nconst audioTypes = [\n\t'mp4a',\n\t'ac-3',\n\t'ec-3',\n\t'ac-4',\n\t'fLaC',\n\t'Opus',\n]\n\nconst videoTypes = [\n\t'dvh1',\n\t'dvhe',\n\t'hev1',\n\t'hvc1',\n\t'avc1',\n\t'avc3',\n\t'dvav',\n\t'dva1',\n\t'dvc1',\n\t'dvi1',\n]\n\nconst readers = /* @__PURE__ */ (() => {\n\tconst map = {\n\t\tstsd: readStsd,\n\t}\n\taudioTypes.forEach(type => (map as any)[type] = createAudioSampleEntryReader(type))\n\tvideoTypes.forEach(type => (map as any)[type] = createVisualSampleEntryReader(type))\n\treturn map\n})()\n\nconst writers = /* @__PURE__ */ (() => {\n\tconst map = {\n\t\tstsd: writeStsd,\n\t\tfrma: writeFrma,\n\t\tschm: writeSchm,\n\t\ttenc: writeTenc,\n\t\tencv: writeVisualSampleEntryBox,\n\t\tenca: writeAudioSampleEntryBox,\n\t}\n\taudioTypes.forEach(type => (map as any)[type] = writeAudioSampleEntryBox)\n\tvideoTypes.forEach(type => (map as any)[type] = writeVisualSampleEntryBox)\n\treturn map\n})()\n\n/**\n * Options for the `ensureEncryptedInit` function.\n *\n * @public\n */\nexport type EnsureEncryptedInitOptions = {\n\t/**\n\t * Whether to prepend the encrypted entries to the sample table.\n\t *\n\t * @defaultValue `true`\n\t */\n\tprepend: boolean;\n\n\t/**\n\t * Whether to include the original init segment in the result.\n\t *\n\t * @defaultValue `true`\n\t */\n\tincludeOriginal: boolean;\n\n\t/**\n\t * The scheme type to use for the encryption. Defaults to `cenc`.\n\t *\n\t * @defaultValue `1667591779`\n\t */\n\tschemeType: number;\n\n\t/**\n\t * The default KID to use for the encryption.\n\t *\n\t * @defaultValue `[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]`\n\t */\n\tdefaultKid: number[];\n}\n\n/**\n * Ensures that the init segment is encrypted. Used on platforms that have issues playing unencrypted\n * content before playing encrypted content. Both prepend and includeOriginal are optional.\n *\n * @param init - The init segment to ensure is encrypted.\n * @param options - The options for the encryption.\n *\n * @returns The encrypted init segment.\n *\n * @public\n *\n * @example\n * {@includeCode ../test/ensureEncryptedInit.test.ts#example}\n */\nexport function ensureEncryptedInit(init: Uint8Array, options?: Partial<EnsureEncryptedInitOptions>): Uint8Array {\n\tconst { prepend = true, includeOriginal = true, schemeType = 1667591779, defaultKid = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] } = options ?? {}\n\tconst boxes = readIsoBoxes(init, { readers })\n\tconst stsd = findIsoBox(boxes, box => box.type === 'stsd')\n\n\t// No stsd box found, return original init\n\tif (stsd?.type !== 'stsd') {\n\t\treturn init\n\t}\n\n\t// If the stsd box already contains enca or encv entries, return original init\n\tif (stsd.entries.find(({ type }) => type === 'enca' || type === 'encv')) {\n\t\treturn init\n\t}\n\n\tconst entries = stsd.entries.filter(({ type }) => videoTypes.includes(type) || audioTypes.includes(type))\n\n\t// Add sinf to each sample entry box\n\tfor (const entry of entries) {\n\t\tconst type = videoTypes.includes(entry.type) ? 'encv' : 'enca'\n\t\tconst box = { ...entry, boxes: entry.boxes.slice(), type } as AudioSampleEntryBox | VisualSampleEntryBox\n\n\t\tif (prepend) {\n\t\t\tstsd.entries.unshift(box)\n\t\t}\n\t\telse {\n\t\t\tstsd.entries.push(box)\n\t\t}\n\n\t\tbox.boxes.push({\n\t\t\ttype: 'sinf',\n\t\t\tboxes: [{\n\t\t\t\ttype: 'frma',\n\t\t\t\tdataFormat: fourCcToUint32(entry.type),\n\t\t\t}, {\n\t\t\t\ttype: 'schm',\n\t\t\t\tversion: 0,\n\t\t\t\tflags: 0,\n\t\t\t\tschemeType,\n\t\t\t\tschemeVersion: 65536,\n\t\t\t}, {\n\t\t\t\ttype: 'schi',\n\t\t\t\tboxes: [{\n\t\t\t\t\ttype: 'tenc',\n\t\t\t\t\tversion: 0,\n\t\t\t\t\tflags: 0,\n\t\t\t\t\tdefaultIsEncrypted: 1,\n\t\t\t\t\tdefaultIvSize: 8,\n\t\t\t\t\tdefaultKid,\n\t\t\t\t}],\n\t\t\t}],\n\t\t})\n\t}\n\n\t// Write the boxes to a new Uint8Array\n\tconst chunks = writeIsoBoxes(boxes, { writers })\n\tconst size = chunks.reduce((acc, chunk) => acc + chunk.byteLength, 0)\n\tconst length = includeOriginal ? init.length + size : size\n\tconst result = new Uint8Array(length)\n\tlet offset = 0\n\n\tfor (const box of chunks) {\n\t\tresult.set(box, offset)\n\t\toffset += box.byteLength\n\t}\n\n\tif (includeOriginal) {\n\t\tresult.set(init, offset)\n\t}\n\n\treturn result\n}\n"],"mappings":";;;;;;;;;;AAKA,MAAa,OAAO;;;;;;;;;ACApB,MAAa,OAAO;;;;;;;;;ACApB,MAAa,wBAAwB;;;;;;;;;;;;;;;ACWrC,SAAgB,0BAA0B,SAAwD;AACjG,KAAI,CAAC,QACJ,QAAO;AAGR,MAAK,MAAM,MAAM,QAChB,KACC,GAAG,aAAa,aAAa,KAAK,yBAClC,GAAG,UACF,GAAG,MAAM,aAAa,KAAK,QAC3B,GAAG,MAAM,aAAa,KAAK,MAE5B,QAAO;AAIT,QAAO;;;;;;;;;;;;;;;;;AClBR,SAAgB,yCACf,2BACA,aACgB;AAChB,QAAO,0BAA0B,MAAK,OAAM,GAAG,gBAAgB,YAAY,EAAE,SAAS;;;;;;;;;;;;;;;;ACPvF,SAAgB,YAAY,MAAwC;CACnE,MAAM,SAAS;CACf,MAAM,OAAO,IAAI,SAAS,KAAK;CAE/B,MAAM,UAAU,KAAK,SAAS,OAAO;CACrC,IAAI,aAAa,SAAS;AAE1B,KAAI,UAAU,GAAG;EAChB,MAAM,WAAW,KAAK,UAAU,WAAW;AAC3C,gBAAc,IAAK,KAAK;;AAGzB,eAAc;AACd,QAAO,KAAK,MA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AGzB,MAAK,QAAQ,KAAK,IAAI;AAGvB,MAAI,MAAM,KAAK;GACd,MAAM;GACN,OAAO;IAAC;KACP,MAAM;KACN,YAAY,eAAe,MAAM,KAAK;KACtC;IAAE;KACF,MAAM;KACN,SAAS;KACT,OAAO;KACP;KACA,eAAe;KACf;IAAE;KACF,MAAM;KACN,OAAO,CAAC;MACP,MAAM;MACN,SAAS;MACT,OAAO;MACP,oBAAoB;MACpB,eAAe;MACf;MACA,CAAC;KACF;IAAC;GACF,CAAC;;CAIH,MAAM,SAAS,cAAc,OAAO,EAAE,SAAS,CAAC;CAChD,MAAM,OAAO,OAAO,QAAQ,KAAK,UAAU,MAAM,MAAM,YAAY,EAAE;CACrE,MAAM,SAAS,kBAAkB,KAAK,SAAS,OAAO;CACtD,MAAM,SAAS,IAAI,WAAW,OAAO;CACrC,IAAI,SAAS;AAEb,MAAK,MAAM,OAAO,QAAQ;AACzB,SAAO,IAAI,KAAK,OAAO;AACvB,YAAU,IAAI;;AAGf,KAAI,gBACH,QAAO,IAAI,MAAM,OAAO;AAGzB,QAAO"}
|
package/dist/tsdoc-metadata.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@svta/cml-drm",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.7",
|
|
4
4
|
"description": "Digital Rights Management (DRM) functionality",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -54,8 +54,8 @@
|
|
|
54
54
|
}
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
|
-
"@svta/cml-iso-bmff": "1.0.
|
|
58
|
-
"@svta/cml-utils": "1.5.
|
|
59
|
-
"@svta/cml-xml": "1.1.
|
|
57
|
+
"@svta/cml-iso-bmff": "1.0.3",
|
|
58
|
+
"@svta/cml-utils": "1.5.1",
|
|
59
|
+
"@svta/cml-xml": "1.1.5"
|
|
60
60
|
}
|
|
61
61
|
}
|