Skip to content

Headers, credentials and base64 certificate#16

Open
chris-heathwood-piksel wants to merge 5 commits into
chemoish:masterfrom
chris-heathwood-piksel:head_and_cred
Open

Headers, credentials and base64 certificate#16
chris-heathwood-piksel wants to merge 5 commits into
chemoish:masterfrom
chris-heathwood-piksel:head_and_cred

Conversation

@chris-heathwood-piksel

Copy link
Copy Markdown

Hi,

Hope it is ok created the PR with some extra optional settings.

It would be great if this could make it in to npm :)

Thanks

Chris H

'certificate' as a base64string
'licenseRequestHeaders' as a function to call to add any headers that
might be needed
'withCredentials' so we can send cookies with the license request
licenseRequestHeaders as an object makes more sense.
@chris-heathwood-piksel

Copy link
Copy Markdown
Author

Just switched to an object for the request headers, am looking at passing back some information on the response too :)

@adamthesax

Copy link
Copy Markdown

Any update on this pull request? Being able to override headers is an extremely handy feature to have

@chemoish

chemoish commented Jan 7, 2018

Copy link
Copy Markdown
Owner

@chris-heathwood-piksel i seriously hope you forked this; idk why i sporadically get emails from github.

i am no longer working on video stuff, but i can do a cursory review this week and merge a year later :X

@chemoish chemoish left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall comment, it would be easier to merge and review if the changes were separated and there was a brief description to the reasons behind the changes.

Comment thread src/videojs-fairplay.js
logToBrowserConsole = value;
}

ab2str(buf) {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would move this to util

Comment thread src/videojs-fairplay.js
tech.isReady_ = false;

if (this.protection_.certificate) {
this.log('Using base64 encoded certificate set on the source protection.');

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there value to log to indicate a parameter has been set?

Comment thread src/videojs-fairplay.js

if (this.protection_.certificate) {
this.log('Using base64 encoded certificate set on the source protection.');
certificate = base64DecodeUint8Array(this.protection_.certificate);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it worth it to refactor?

// from
let certificate;

// to
if (this.protection._certificate) {
  this.setCertificate(this.protection._certificate);
}

setCertificate(certificate) {
  // can normalize input later and or just leave it simple—would also need to update references
  this.certificate = certificate;
}

Comment thread src/videojs-fairplay.js
}

return all;
},

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}, {}); style preference.

Comment thread src/videojs-fairplay.js
this.onRequestError(event.target, ERROR_TYPE.FETCH_LICENCE);

// Return response content
if (licenseResponseErrorContent && typeof licenseResponseErrorContent === 'function') {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

licenseResponseErrorContent => licenseLoadError is there a better name or something more applicable?

is an inverse needed? licenseLoadSuccess? licenseLoadHeaders?

Comment thread src/videojs-fairplay.js

// Return response headers here
if (licenseResponseHeaders && typeof licenseResponseHeaders === 'function') {
const headers = event.target.getAllResponseHeaders().split('\r\n').reduce((all, part) => {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would chuck this in a method somewhere to facilitate legibility and if its needed in another method.

createHeadersFromResponseHeaders or something.

Comment thread README.md
// Optional settings

// Instead of a certificateUrl send the cert in a string
certificate: 'base64string',

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would stick this next to certificateUrl and indicate either or.

Comment thread README.md
certificate: 'base64string',

// Object to add any extra license request headers that might be needed
licenseRequestHeaders: {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this just be headers? is there multiple headers that need to be set to indicate and prefix a type (licenseRequest)?

Comment thread README.md
},

// Function to call back with license response content if it errors
licenseResponseErrorContent: function (content) {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see some of the comments below, ideally I would like to consolidate naming to one specific style.

shooting from the hip;

  • onLicenseLoad (can be changed if needed)
  • onLicenseError({ error })
  • onLicenseSuccess({ headers })

signatures would be able to be grouped and are conventionally named, they can be enhanced with data as needed.

Comment thread README.md
certificateUrl: '/path/to/certificate',
licenseUrl: '/path/to/license',

// Optional settings

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, options would be separated and described in an options section.

See https://github.com/chemoish/videojs-bif#options or whatever similar.

@chemoish

Copy link
Copy Markdown
Owner

Feel free to email me directly if you still need these changes, I will prioritize whatever you need. Again, apologies for not seeing this sooner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants