Fix licenseXhrSetup return types and selectKeySystem nested Promise anti-pattern

This commit is contained in:
Rob Walch
2026-06-01 19:17:08 -07:00
committed by Rob Walch
parent 18307e5fe2
commit b667f1e79f
3 changed files with 13 additions and 16 deletions
+1 -1
View File
@@ -1301,7 +1301,7 @@ export class EMEController extends Logger implements ComponentAPI {
export type EMEControllerConfig = {
licenseXhrSetup?: (this: Hls, xhr: XMLHttpRequest, url: string, keyContext: MediaKeySessionContext & {
decryptdata: LevelKey;
}, licenseChallenge: Uint8Array) => void | Uint8Array | Promise<Uint8Array | void>;
}, licenseChallenge: Uint8Array) => void | Uint8Array | string | Promise<Uint8Array | string | void>;
licenseResponseCallback?: (this: Hls, xhr: XMLHttpRequest, url: string, keyContext: MediaKeySessionContext & {
decryptdata: LevelKey;
}) => ArrayBuffer;
+1 -1
View File
@@ -139,7 +139,7 @@ export type EMEControllerConfig = {
url: string,
keyContext: MediaKeySessionContext & { decryptdata: LevelKey },
licenseChallenge: Uint8Array,
) => void | Uint8Array | Promise<Uint8Array | void>;
) => void | Uint8Array | string | Promise<Uint8Array | string | void>;
licenseResponseCallback?: (
this: Hls,
xhr: XMLHttpRequest,
+11 -14
View File
@@ -428,20 +428,17 @@ class EMEController extends Logger implements ComponentAPI {
private selectKeySystem(
keySystemsToAttempt: KeySystems[],
): Promise<KeySystemFormats> {
return new Promise((resolve, reject) => {
this.getKeySystemSelectionPromise(keySystemsToAttempt)
.then(({ keySystem }) => {
const keySystemFormat = keySystemDomainToKeySystemFormat(keySystem);
if (keySystemFormat) {
resolve(keySystemFormat);
} else {
reject(
new Error(`Unable to find format for key-system "${keySystem}"`),
);
}
})
.catch(reject);
});
return this.getKeySystemSelectionPromise(keySystemsToAttempt).then(
({ keySystem }) => {
const keySystemFormat = keySystemDomainToKeySystemFormat(keySystem);
if (!keySystemFormat) {
throw new Error(
`Unable to find format for key-system "${keySystem}"`,
);
}
return keySystemFormat;
},
);
}
public selectKeySystemFormat(frag: Fragment): Promise<KeySystemFormats> {