File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -36,15 +36,29 @@ export class CastLabsFairplayContentProtectionIntegration implements ContentProt
3636 }
3737
3838 onLicenseRequest ( request : LicenseRequest ) : MaybeAsync < Partial < LicenseRequest > | BufferSource > {
39- request . url =
39+ const isOffline = this . contentProtectionConfiguration . fairplay ?. licenseType === 'persistent' ;
40+
41+ let licenseUrl =
4042 this . contentProtectionConfiguration . fairplay ?. licenseAcquisitionURL ?? CastLabsFairplayContentProtectionIntegration . DEFAULT_LICENSE_URL ;
43+
44+ // Add offline parameter for persistent license / caching support
45+ if ( isOffline ) {
46+ const urlSeparator = licenseUrl . includes ( '?' ) ? '&' : '?' ;
47+ licenseUrl = `${ licenseUrl } ${ urlSeparator } offline=true` ;
48+ }
49+
50+ request . url = licenseUrl ;
4151 request . headers = {
4252 ...request . headers ,
4353 'x-dt-custom-data' : this . customData ! ,
4454 'x-dt-auth-token' : this . contentProtectionConfiguration . integrationParameters . token ?? '' ,
4555 'content-type' : 'application/x-www-form-urlencoded' ,
4656 } ;
47- const body = `spc=${ encodeURIComponent ( fromUint8ArrayToBase64String ( request . body ! ) ) } &${ encodeURIComponent ( this . contentId ! ) } ` ;
57+ const spcEncoded = encodeURIComponent ( fromUint8ArrayToBase64String ( request . body ! ) ) ;
58+ let body = `spc=${ spcEncoded } &${ encodeURIComponent ( this . contentId ! ) } ` ;
59+ if ( isOffline ) {
60+ body += '&offline=true' ;
61+ }
4862 request . body = fromStringToUint8Array ( body ) ;
4963
5064 return request ;
You can’t perform that action at this time.
0 commit comments