Skip to content

Instantly share code, notes, and snippets.

@philcluff
Last active June 12, 2024 11:45
Show Gist options
  • Save philcluff/27737782cf474b6361570cbcce4e8d69 to your computer and use it in GitHub Desktop.
Save philcluff/27737782cf474b6361570cbcce4e8d69 to your computer and use it in GitHub Desktop.
Signs URLs for a DRM'd asset
const Mux = require('@mux/mux-node');
const mux = new Mux();
async function main() {
var args = process.argv.slice(2);
if (args.length != 1) {
console.log("Usage: node sign-url-drm.js PLAYBACK_ID");
process.exit(1);
}
let playbackId = args[0];
const playbackToken = await mux.jwt.signPlaybackId(playbackId, {expiration: '365d'});
const drmLicenseToken = await mux.jwt.signDrmLicense(playbackId, {expiration: '365d'});
const storyboardToken = await mux.jwt.signPlaybackId(playbackId, {type: "storyboard", expiration: '365d'});
const thumbnailToken = await mux.jwt.signPlaybackId(playbackId, {type: "thumbnail", expiration: '365d'});
console.log(`Playback Token: ${playbackToken}\n`);
console.log(`License Token: ${drmLicenseToken}\n`);
console.log(`Storyboard Token: ${storyboardToken}\n`);
console.log(`Thumbnail Token: ${thumbnailToken}\n`);
}
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment