Clone
5
Custom Handlers
Ingan121 edited this page 2025-09-07 00:14:45 +09:00

Vineless Custom Handlers

  • Vineless supports writing your own handler for processing the license generation and key parsing

Writing a custom handler

  • Write a JS file to lib/customhandlers/<handler_name>.js with the following content:
export default class YourCustomHandlerName {
    constructor(host, keySystem, sessionId, tab) {
        this.host = host;
        this.keySystem = keySystem;
        this.sessionId = sessionId;
        this.tab = tab;
    }

    async generateChallenge(pssh, extra) {
        const { serverCert } = extra;
        
        // your challenge generation handler here
        // this.session = new SomeInternalHandler();
        // const challenge = await this.session.generateChallenge(pssh);
        
        return challenge; // base64-encoded challenge data to return
    }

    async parseLicense(license) {
        // license: base64-encoded license data

        // your license parsing logic here
        // const keys = await this.session.parseLicense(body);

        return {
            type: "WIDEVINE", // or "PLAYREADY" or "CLEARKEY"
            pssh: "AAAAXHBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAADwSEDAvgN1BHkiGvKW7H4AYoCQSEDAvgN1BHkiGvKW7H4AYoCQSEDAvgN1BHkiGvKW7H4AYoCRI88aJmwY=",
            keys: [{
                kid: "9eb4050de44b4802932e27d75083e266",
                k: "166634c675823c235a4a9446fad52e4d"
            }]
        }
    }
}
  • In lib/customhandlers/main.js, import your handler and put it into the CustomHandlers object.
import YourCustomHandlerName from "./yourhandler.js"

export const CustomHandlers = {
    "hardcoded": { /* ... */ },
    "yourhandler": {
        "name": "Your Custom Handler's Name",
        "description": "Your Custom Handler's Description",
        "handler": YourCustomHandlerName, // the imported handler class
        "for": "widevine", // or "playready", omit for both
        "disabled": false // true hides it from the list
    }
};