Interface MKFairplayDrmConfig

Apple Fairplay Drm configuration.

EZDRM Example:

fairplay: {
LA_URL: 'http://fps.ezdrm.com/api/licenses/YOUR-CONTENT-ID',
certificateURL: 'YOUR-CERTIFICATE',
prepareContentId: (contentId) => {
const uri = contentId;
const uriParts = uri.split('://', 1);
const protocol = uriParts[0].slice(-3);
uriParts = uri.split(';', 2);
contentId = uriParts.length>1?uriParts[1]:'';
return protocol.toLowerCase()=='skd' ? contentId : '';
},
prepareLicenseAsync: (ckc) => {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.addEventListener('loadend', () => {
const array = new Uint8Array(reader.result);
resolve(array);
});
reader.addEventListener('error', () => {
reject(reader.error);
});
reader.readAsArrayBuffer(ckc);
});
},
prepareMessage: (event, session) => {
return new Blob([event.message], {type: 'application/octet-binary'});
},
headers: {
'content-type': 'application/octet-stream',
},
useUint16InitData: true,
licenseResponseType: 'blob'
}

DRMtoday by castLabs Example:

fairplay: {
LA_URL: 'https://license-server-url-provided-by-drmtoday',
certificateURL: 'https://certificate-url-provided-by-drmtoday',
headers: {
'dt-custom-data': 'INSERT-YOUR-BASE64-ENCODED-CUSTOMDATA',
},
prepareMessage : (event, session) => {
return 'spc=' + encodeURIComponent(event.messageBase64Encoded) + '&' + session.contentId;
},
prepareContentId : (contentId) => {
const pattern='skd://drmtoday?';
let parameters;
let idx = contentId.indexOf(pattern);

if (idx > -1) {
parameters = contentId.substring(idx + pattern.length);
parameters = parameters.replace(/assetid/gi, 'assetId');
parameters = parameters.replace(/variantid/gi, 'variantId');
return parameters;
} else {
return '';
}
}
}

Hierarchy

  • MKFairplayDrmConfig

Properties

LA_URL?: string

The URL to the Fairplay license server for this content.

Can be defined in the configuration or taken out from the video manifest if defined there.

If the config URL is defined it has precedence over the URL defined in the manifest.

certificateHeaders?: MKHeaders

An object specifying custom HTTP request headers for the certificate request.

certificateURL: string

URL to the Fairplay certificate of the license server.

getLicenseServerUrl?: ((skdUrl) => string)

Type declaration

    • (skdUrl): string
    • A callback function which gets the URI (without the skd: part) from the HLS manifest passed as parameter.

      The function needs to return a string which is used as LA_URL “as is”.

      Parameters

      • skdUrl: string

      Returns string

headers?: MKHeaders

An object specifying HTTP request headers for the license request.

licenseResponseType?: MKHttpResponseType

Sets an explicit response type for the license request.

Default response type for this request is TEXT.

maxCertificateRequestRetries?: number

Specifies how often a certificate request should be retried if was not successful (e.g. the certificate URL returns a 404).

Default is 1 and a value of 0 disables retries.

maxLicenseRequestRetries?: number

Specifies how often a license request should be retried if was not successful (e.g. the license server was not reachable).

Default is 1 and a value of 0 disables retries.

prepareCertificate?: ((data) => ArrayBuffer)

Type declaration

    • (data): ArrayBuffer
    • A function to prepare the certificate before passing it into the browser.

      This is needed if the server response with anything else than the certificate, e.g. if the certificate is wrapped into a JSON object.

      The server response is passed as parameter “as is” and the return type is expected to be an ArrayBuffer.

      Note: Please see notes for usingAzuki.

      Parameters

      • data: any

      Returns ArrayBuffer

prepareContentId?: ((url) => string)

Type declaration

    • (url): string
    • A function to prepare the contentId, which is sent to the Fairplay license server as request body (optional).

      As many DRM providers expect different, vendor-specific messages, this can be done using this user-defined function.

      The parameter is the URI extracted from the HLS manifset (m3u8) and the return value should be the contentID as string.

      Note: Please see notes for usingAzuki.

      Parameters

      • url: string

      Returns string

prepareLicense?: ((data) => string)

Type declaration

    • (data): string
    • A function to prepare the license before passing it into the browser.

      This is needed if the server response with anything else than the license, e.g. if the license is wrapped into a JSON object.

      The server response is passed as parameter “as is” and the return type is expected to be a Base64-encoded string.

      Note: Please see notes for usingAzuki.

      Parameters

      • data: any

      Returns string

prepareMessage?: ((event, session) => any)

Type declaration

    • (event, session): any
    • A function to prepare the license acquisition message which will be sent to the license acquisition server (optional).

      As many DRM providers expect different, vendor-specific messages, this can be done using this user-defined function.

      The first parameter is the key message event object as given by the Fairplay Content Decryption Module (CDM), enhanced by the messageBase64Encoded attribute, which contains the key message encoded as base64 encoded string.

      The second parameter is the session object, enhanced by a contentId attribute.

      Note: Please see notes for usingAzuki.

      Parameters

      • event: any
      • session: any

      Returns any

serverCertificate?: ArrayBuffer

Defaults to null, e.g., certificate will be requested from the license server if required.

A key-system-specific server certificate used to encrypt license requests.

Its use is optional and is meant as an optimization to avoid a round-trip to request a certificate.

useUint16InitData?: boolean

A flag to change between Uint8Array (default, value false) and Uint16Array initialization data.

Depends on the fairplay license server, most use Uint8Array

withCredentials?: boolean

Set to true to send credentials such as cookies or authorization headers along with the license requests.

Default value is false.