I am thinking about developing a paid JS script, and I wanted to prevent its piracy by using HTML5's EME to safely decrypt and use my JavaScript file client-side.
Can EME be used for more than just audio/video content?
You cannot currently use Encrypted Media Extensions (EME) to prevent JavaScript piracy.
Because JavaScript is interpreted client-side by the user's browser, the source code can be retrieved.
According to Google:
Encrypted Media Extensions provides an API that enables web applications to interact with content protection systems, to allow playback of encrypted audio and video.
The W3C Recommendation for Encrypted Media Extensions explains:
This proposal extends
HTMLMediaElement
providing APIs to control playback of encrypted content.
Mozilla describes the HTMLMediaElement
as:
The
HTMLMediaElement
interface adds toHTMLElement
the properties and methods needed to support basic media-related capabilities that are common to audio and video. TheHTMLVideoElement
andHTMLAudioElement
elements both inherit this interface.
In other words, HTMLMediaElement
simply refers to <video>
and <audio>
content.
From this information, we can conclude that Encrypted Media Extensions act as a gateway between a client's web browser and DRM software: specifically audio and video. [Source]