Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: convert initData to a string #147

Merged
merged 2 commits into from
Oct 20, 2021
Merged

fix: convert initData to a string #147

merged 2 commits into from
Oct 20, 2021

Conversation

gkatsev
Copy link
Member

@gkatsev gkatsev commented Oct 19, 2021

This is to help get around the change in data type of initData between
the legacy API and the standards API.

In the legacy API, the initData was a Uint8Array but needed to be
converted to a Uint16Array to be able to toString it.

In the standards API, initData is an ArrayBuffer but can be converted to
a Uint8Array to be able to toString it.

We now do this string conversion for you so that you can just use the
contentId and not need to figure out whether legacy or standard API is
used.

BREAKING CHANGE: getContentId will now receive a string representation
of the initData

This is to help get around the change in data type of initData between
the legacy API and the standards API.

In the legacy API, the initData was a Uint8Array but needed to be
converted to a Uint16Array to be able to toString it.

In the standards API, initData is an ArrayBuffer but can be converted to
a Uint8Array to be able to toString it.

We now do this string conversion for you so that you can just use the
contentId and not need to figure out whether legacy or standard API is
used.

BREAKING CHANGE: getContentId will now receive a string representation
of the initData
src/fairplay.js Outdated
@@ -128,8 +128,8 @@ export const defaultGetCertificate = (fairplayOptions) => {
};
};

export const defaultGetContentId = (emeOptions, initData) => {
return getHostnameFromUri(uint8ArrayToString(initData));
export const defaultGetContentId = (emeOptions, contentId) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

perhaps this should be named initDataString now?

Copy link
Contributor

@brandonocasey brandonocasey left a comment

Choose a reason for hiding this comment

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

One small comment, nice branch name 😆

@gkatsev gkatsev merged commit 922e5eb into main Oct 20, 2021
@gkatsev gkatsev deleted the safaaaaaaaari branch October 20, 2021 16:10
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.

None yet

2 participants