Skip to content

Commit

Permalink
chore: update linter, run --fix on files, and manually lint when need…
Browse files Browse the repository at this point in the history
…ed (#141)
  • Loading branch information
brandonocasey committed Sep 30, 2021
1 parent c4b3dc1 commit a794ea9
Show file tree
Hide file tree
Showing 12 changed files with 1,174 additions and 441 deletions.
1,078 changes: 825 additions & 253 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"videojs-generate-karma-config": "^5.1.0",
"videojs-generate-rollup-config": "^3.1.0",
"videojs-generator-verify": "^1.2.0",
"videojs-standard": "~7.1.0"
"videojs-standard": "~9.0.1"
},
"generator-videojs-plugin": {
"version": "7.3.2"
Expand Down
30 changes: 18 additions & 12 deletions src/eme.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ export const getSupportedConfigurations = (keySystemOptions) => {

if (audioContentType || audioRobustness) {
supportedConfiguration.audioCapabilities = [
Object.assign({},
Object.assign(
{},
(audioContentType ? { contentType: audioContentType } : {}),
(audioRobustness ? { robustness: audioRobustness } : {})
)
Expand All @@ -39,7 +40,8 @@ export const getSupportedConfigurations = (keySystemOptions) => {

if (videoContentType || videoRobustness) {
supportedConfiguration.videoCapabilities = [
Object.assign({},
Object.assign(
{},
(videoContentType ? { contentType: videoContentType } : {}),
(videoRobustness ? { robustness: videoRobustness } : {})
)
Expand Down Expand Up @@ -126,11 +128,13 @@ export const makeNewRequest = (requestOptions) => {
expired = true;
break;
case 'internal-error':
const message =
'Key status reported as "internal-error." Leaving the session open since we ' +
'don\'t have enough details to know if this error is fatal.';

// "This value is not actionable by the application."
// https://www.w3.org/TR/encrypted-media/#dom-mediakeystatus-internal-error
videojs.log.warn(
'Key status reported as "internal-error." Leaving the session open since we ' +
'don\'t have enough details to know if this error is fatal.', event);
videojs.log.warn(message, event);
break;
}
});
Expand Down Expand Up @@ -285,8 +289,7 @@ export const defaultGetLicense = (keySystemOptions) => (emeOptions, keyMessage,
responseType: 'arraybuffer',
body: keyMessage,
headers
}, httpResponseHandler(callback, true)
);
}, httpResponseHandler(callback, true));
};

const promisifyGetLicense = (getLicenseFn, eventBus) => {
Expand Down Expand Up @@ -352,7 +355,8 @@ export const standard5July2016 = ({

keySystemOptions = standardizeKeySystemOptions(
keySystemAccess.keySystem,
options.keySystems[keySystemAccess.keySystem]);
options.keySystems[keySystemAccess.keySystem]
);

if (!keySystemOptions.getCertificate) {
resolve(keySystemAccess);
Expand Down Expand Up @@ -388,16 +392,18 @@ export const standard5July2016 = ({
}

return keySystemPromise.then(() => {
const {getLicense} = standardizeKeySystemOptions(
video.keySystem,
options.keySystems[video.keySystem]
);

return addSession({
video,
initDataType,
initData,
options,
// if key system has not been determined then addSession doesn't need getLicense
getLicense: video.keySystem ?
promisifyGetLicense(standardizeKeySystemOptions(
video.keySystem,
options.keySystems[video.keySystem]).getLicense, eventBus) : null,
getLicense: video.keySystem ? promisifyGetLicense(getLicense, eventBus) : null,
removeSession,
eventBus
});
Expand Down
7 changes: 4 additions & 3 deletions src/fairplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* The W3C Working Draft of 22 October 2013 seems to be the best match for
* the ms-prefixed API. However, it should only be used as a guide; it is
* doubtful the spec is 100% implemented as described.
*
* @see https://www.w3.org/TR/2013/WD-encrypted-media-20131022
*/
import videojs from 'video.js';
Expand All @@ -23,8 +24,7 @@ const concatInitDataIdAndCertificate = ({initData, id, cert}) => {
// [4 byte:certLength]
// [certLength byte: cert]
let offset = 0;
const buffer = new ArrayBuffer(
initData.byteLength + 4 + id.byteLength + 4 + cert.byteLength);
const buffer = new ArrayBuffer(initData.byteLength + 4 + id.byteLength + 4 + cert.byteLength);
const dataView = new DataView(buffer);
const initDataArray = new Uint8Array(buffer, offset, initData.byteLength);

Expand Down Expand Up @@ -65,7 +65,8 @@ const addKey = ({video, contentId, initData, cert, options, getLicense, eventBus
try {
keySession = video.webkitKeys.createSession(
'video/mp4',
concatInitDataIdAndCertificate({id: contentId, initData, cert}));
concatInitDataIdAndCertificate({id: contentId, initData, cert})
);
} catch (error) {
reject('Could not create key session');
return;
Expand Down
26 changes: 13 additions & 13 deletions src/ms-prefixed.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* The W3C Working Draft of 22 October 2013 seems to be the best match for
* the ms-prefixed API. However, it should only be used as a guide; it is
* doubtful the spec is 100% implemented as described.
*
* @see https://www.w3.org/TR/2013/WD-encrypted-media-20131022
* @see https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/compatibility/mt598601(v=vs.85)
*/
Expand All @@ -14,19 +15,18 @@ export const addKeyToSession = (options, session, event, eventBus) => {
let playreadyOptions = options.keySystems[PLAYREADY_KEY_SYSTEM];

if (typeof playreadyOptions.getKey === 'function') {
playreadyOptions.getKey(
options, event.destinationURL, event.message.buffer, (err, key) => {
if (err) {
eventBus.trigger({
message: 'Unable to get key: ' + err,
target: session,
type: 'mskeyerror'
});
return;
}

session.update(key);
});
playreadyOptions.getKey(options, event.destinationURL, event.message.buffer, (err, key) => {
if (err) {
eventBus.trigger({
message: 'Unable to get key: ' + err,
target: session,
type: 'mskeyerror'
});
return;
}

session.update(key);
});
return;
}

Expand Down
8 changes: 4 additions & 4 deletions src/playready.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import {httpResponseHandler} from './http-handler.js';
* license request
*/
export const getMessageContents = (message) => {
const xml = (new window.DOMParser()).parseFromString(
// TODO do we want to support UTF-8?
String.fromCharCode.apply(null, new Uint16Array(message)),
'application/xml');
// TODO do we want to support UTF-8?
const xmlString = String.fromCharCode.apply(null, new Uint16Array(message));
const xml = (new window.DOMParser())
.parseFromString(xmlString, 'application/xml');
const headersElement = xml.getElementsByTagName('HttpHeaders')[0];
const headers = {};

Expand Down

0 comments on commit a794ea9

Please sign in to comment.