@@ -10,7 +10,7 @@ import {
1010
1111export class CastLabsFairplayContentProtectionIntegration implements ContentProtectionIntegration {
1212 static readonly DEFAULT_CERTIFICATE_URL = 'https://lic.drmtoday.com/license-server-fairplay/cert/' ;
13- static readonly DEFAULT_LICENSE_URL = 'https://lic.staging.drmtoday.com/license-server-fairplay/cert/ ' ;
13+ static readonly DEFAULT_LICENSE_URL = 'https://lic.staging.drmtoday.com/license-server-fairplay/' ;
1414
1515 private readonly contentProtectionConfiguration : CastLabsDrmConfiguration ;
1616 private contentId : string | undefined = undefined ;
@@ -31,20 +31,35 @@ export class CastLabsFairplayContentProtectionIntegration implements ContentProt
3131 this . contentProtectionConfiguration . fairplay ?. certificateURL ?? CastLabsFairplayContentProtectionIntegration . DEFAULT_CERTIFICATE_URL ;
3232 request . headers = {
3333 ...request . headers ,
34+ 'x-dt-custom-data' : this . customData !
3435 } ;
3536 return request ;
3637 }
3738
3839 onLicenseRequest ( request : LicenseRequest ) : MaybeAsync < Partial < LicenseRequest > | BufferSource > {
39- request . url =
40+ const isOffline = this . contentProtectionConfiguration . fairplay ?. licenseType === 'persistent' ;
41+
42+ let licenseUrl =
4043 this . contentProtectionConfiguration . fairplay ?. licenseAcquisitionURL ?? CastLabsFairplayContentProtectionIntegration . DEFAULT_LICENSE_URL ;
44+
45+ // Add offline parameter for persistent license / caching support
46+ if ( isOffline ) {
47+ const urlSeparator = licenseUrl . includes ( '?' ) ? '&' : '?' ;
48+ licenseUrl = `${ licenseUrl } ${ urlSeparator } offline=true` ;
49+ }
50+
51+ request . url = licenseUrl ;
4152 request . headers = {
4253 ...request . headers ,
4354 'x-dt-custom-data' : this . customData ! ,
4455 'x-dt-auth-token' : this . contentProtectionConfiguration . integrationParameters . token ?? '' ,
4556 'content-type' : 'application/x-www-form-urlencoded' ,
4657 } ;
47- const body = `spc=${ encodeURIComponent ( fromUint8ArrayToBase64String ( request . body ! ) ) } &${ encodeURIComponent ( this . contentId ! ) } ` ;
58+ const spcEncoded = encodeURIComponent ( fromUint8ArrayToBase64String ( request . body ! ) ) ;
59+ let body = `spc=${ spcEncoded } &${ encodeURIComponent ( this . contentId ! ) } ` ;
60+ if ( isOffline ) {
61+ body += '&offline=true' ;
62+ }
4863 request . body = fromStringToUint8Array ( body ) ;
4964
5065 return request ;
0 commit comments