@li0ard/widevine 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/device.d.ts CHANGED
@@ -22,4 +22,6 @@ export declare class Device {
22
22
  * @param privateKey Device private key blob (ASN.1 encoded)
23
23
  */
24
24
  static decode(type: DeviceType, clientId: Uint8Array, privateKey: Uint8Array): Device;
25
+ /** Get device instance from `.wvd` file */
26
+ static fromWvd(data: Uint8Array): Device;
25
27
  }
package/dist/device.js CHANGED
@@ -35,4 +35,33 @@ export class Device {
35
35
  throw new Error("Missing token in Client ID");
36
36
  return new Device(type, client_id, decodePrivateKey(privateKey));
37
37
  }
38
+ /** Get device instance from `.wvd` file */
39
+ static fromWvd(data) {
40
+ const rdr = new DataView(data.buffer);
41
+ let offset = 0;
42
+ const magic = new TextDecoder().decode(data.subarray(offset, offset += 3));
43
+ if (magic != "WVD")
44
+ throw new Error("Invalid magic constant, not a WVD file");
45
+ const version = rdr.getUint8(offset);
46
+ offset += 1;
47
+ if (version != 1 && version != 2)
48
+ throw new Error("Invalid version, not a WVD file");
49
+ const type = rdr.getUint8(offset);
50
+ offset += 1;
51
+ const level = rdr.getUint8(offset);
52
+ offset += 1;
53
+ if (level < 1 || level > 3)
54
+ throw new Error("Invalid device version, not a WVD file");
55
+ //const flags = rdr.getUint8(offset);
56
+ offset += 1;
57
+ const privateKeyLength = rdr.getUint16(offset);
58
+ offset += 2;
59
+ const privateKey = data.slice(offset, offset += privateKeyLength);
60
+ const clientIdLen = rdr.getUint16(offset);
61
+ offset += 2;
62
+ const clientId = pywidevine_license_protocol.ClientIdentification.deserializeBinary(data.slice(offset, offset += clientIdLen));
63
+ if (!clientId.token)
64
+ throw new Error("Missing token in Client ID, not a WVD file");
65
+ return new Device(type, clientId, decodePrivateKey(privateKey));
66
+ }
38
67
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@li0ard/widevine",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",