-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
export default async function() { | ||
let keySystemAccess; | ||
try{ | ||
keySystemAccess = await navigator.requestMediaKeySystemAccess('com.widevine.alpha', config) | ||
} catch { | ||
config[0]['sessionTypes'] = ['temporary'] | ||
keySystemAccess = await navigator.requestMediaKeySystemAccess('com.widevine.alpha', config) | ||
} | ||
let challenge = await getChallenge(keySystemAccess); | ||
return challenge | ||
}; | ||
|
||
// Tears of Steel Init data Widevine | ||
let initData = Uint8Array.from(atob('AAAARHBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAACQIARIBMRoNd2lkZXZpbmVfdGVzdCIKMjAxNV90ZWFycyoCU0Q='), c => c.charCodeAt(0)) | ||
|
||
// Widevine CDM config MediaKeyAccess default | ||
let config = [{ | ||
initDataTypes: ['cenc'], | ||
sessionTypes: ['persistent-license'], | ||
videoCapabilities: [{ | ||
contentType: 'video/mp4; codecs="avc1.640029"' | ||
}], | ||
audioCapabilities: [{ | ||
contentType: 'audio/mp4; codecs="mp4a.40.2"' | ||
}] | ||
}]; | ||
|
||
async function getChallenge(keySystemAccess) { | ||
return new Promise((resolve, reject) => { | ||
try{ | ||
keySystemAccess.createMediaKeys().then(mediaKeys => { | ||
let keySession = mediaKeys.createSession(config[0]['sessionTypes']) | ||
keySession.addEventListener("message", () => resolve(event.message)); | ||
keySession.generateRequest("cenc", initData) | ||
}) | ||
} catch(err) { | ||
reject("Unable to create MediaKeys : " + err) | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script type="module"> | ||
import getChallenge from './getChallenge.js' | ||
window.onload = async () => { | ||
let b64encode = b => btoa(String.fromCharCode(...new Uint8Array(b))) | ||
let challenge = await getChallenge() | ||
console.log(b64encode(challenge)) | ||
} | ||
</script> | ||
</head> | ||
<body> | ||
</body> | ||
</html> |