diff --git a/README.md b/README.md index cc857c5..616189a 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,67 @@ -# WidevineProxy2 -An extension-based proxy for Widevine EME challenges and license messages. Modifies the challenge before it reaches the web player and obtains the decryption keys from the response. +# WidevineProxy2 +An extension-based proxy for Widevine EME challenges and license messages. \ +Modifies the challenge before it reaches the web player and obtains the decryption keys from the response. + +## Features ++ User-friendly / GUI-based ++ Bypasses one-time tokens, hashes and license wrapping ++ JavaScript native Widevine implementation ++ Supports Widevine Device files ++ Manifest V3 compliant + +## Widevine Devices +This addon requires a Widevine Device file to work, which is not provided by this project. ++ Follow [this](https://forum.videohelp.com/threads/408031) guide if you want to dump your own device. ++ Ready-to-use Widevine Devices can be found on the [VideoHelp forum](https://forum.videohelp.com/forums/48). + +## Compatibility ++ Compatible (tested) browsers: Firefox/Chrome on Windows/Linux. ++ Works with any service that accepts challenges from Android devices on the same endpoint. + +## Installation ++ Chrome + 1. Download this repository as a ZIP file + 2. Navigate to `chrome://extensions/` + 3. Enable `Developer mode` + 4. Click `Load unpacked` and the select downloaded file ++ Firefox + + Persistent installation + 1. Download the XPI file from the [releases section](https://github.com/DevLARLEY/WidevineProxy2/releases) + 2. Navigate to `about:addons` + 3. Click the settings icon and choose `Install Add-on From File...` + 4. Select the downloaded file + + Temporary installation + 1. Download this repository as a ZIP file + 2. Navigate to `about:debugging#/runtime/this-firefox` + 3. Click `Load Temporary Add-on...` and select the downloaded file + +## Setup ++ Once installed, open the extension, click `Choose File` and select your Widevine Device file. ++ The files are saved in the extension's `chrome.storage.sync` storage and will be synchronized across any browsers into which the user is signed in with their Google account. ++ Due to the sync storage limit of 100KB, the maximum amount of installable of devices at the same time is ~30. ++ Check `Enabled` to activate the message interception and you're done. + +## Usage +All the user has to do is to play a DRM protected video and the decryption keys should appear in the `Keys` group box (if the service is not unsupported, as stated above). \ +Keys are saved: ++ Temporarily until the extension is either refreshed manually (if installed temporarily) or a removal of the keys is manually initiated. ++ Permanently in the extension's `chrome.storage.local` storage until manually wiped or exported via the command line. + +## Issues ++ DRM playback won't work when the extension is disabled and EME Logger is active. This caused by my fix for dealing with EME Logger interference (solutions are welcome). + +## Demo +[Demo](demo.mp4) + +## Disclaimer ++ This program is intended solely for educational purposes. ++ Do not use this program to decrypt or access any content for which you do not have the legal rights or explicit permission. ++ Unauthorized decryption or distribution of copyrighted materials is a violation of applicable laws and intellectual property rights. ++ This tool must not be used for any illegal activities, including but not limited to piracy, circumventing digital rights management (DRM), or unauthorized access to protected content. ++ The developers, contributors, and maintainers of this program are not responsible for any misuse or illegal activities performed using this software. ++ By using this program, you agree to comply with all applicable laws and regulations governing digital rights and copyright protections. + +## Credits ++ [node-widevine](https://github.com/Frooastside/node-widevine) ++ [forge](https://github.com/digitalbazaar/forge) ++ [protobuf.js](https://github.com/protobufjs/protobuf.js) diff --git a/background.js b/background.js new file mode 100644 index 0000000..d489d19 --- /dev/null +++ b/background.js @@ -0,0 +1,158 @@ +import "./protobuf.min.js"; +import "./license_protocol.js"; +import "./forge.min.js"; + +import { Session } from "./license.js"; +import { DeviceManager, base64toUint8Array, uint8ArrayToBase64, uint8ArrayToHex, SettingsManager, AsyncLocalStorage } from "./util.js"; +import { WidevineDevice } from "./device.js"; + +const { LicenseType, SignedMessage, LicenseRequest, License } = protobuf.roots.default.license_protocol; + +let sessions = new Map(); +let logs = []; + +chrome.runtime.onMessage.addListener((message, sender, sendResponse) => { + (async () => { + switch (message.type) { + case "REQUEST": + if (!await SettingsManager.getEnabled()) { + sendResponse(message.body); + return; + } + try { + JSON.parse(atob(message.body)); + sendResponse(message.body); + return; + } catch { + if (message.body) { + const signed_message = SignedMessage.decode(base64toUint8Array(message.body)); + const license_request = LicenseRequest.decode(signed_message.msg); + const pssh_data = license_request.contentId.widevinePsshData.psshData[0]; + + if (!pssh_data) { + sendResponse(message.body); // TODO: send report message back or just log from background script + return; + } + + if (logs.filter(log => log.pssh_data === uint8ArrayToBase64(pssh_data)).length > 0) { + console.log("[WidevineProxy2]", `KEYS_ALREADY_RETRIEVED: ${uint8ArrayToBase64(pssh_data)}`); + sendResponse(message.body); + return; + } + + const selected_device_name = await DeviceManager.getSelectedWidevineDevice(); + if (!selected_device_name) { + sendResponse(message.body); + return; + } + + const device_b64 = await DeviceManager.loadWidevineDevice(selected_device_name); + const widevine_device = new WidevineDevice(base64toUint8Array(device_b64).buffer); + + const private_key = `-----BEGIN RSA PRIVATE KEY-----${uint8ArrayToBase64(widevine_device.private_key)}-----END RSA PRIVATE KEY-----`; + const session = new Session( + { + privateKey: private_key, + identifierBlob: widevine_device.client_id_bytes + }, + pssh_data + ); + + const [challenge, request_id] = session.createLicenseRequest(LicenseType.STREAMING, widevine_device.type === 2); + sessions.set(uint8ArrayToBase64(request_id), session); + + sendResponse(uint8ArrayToBase64(challenge)); + } + } + break; + + case "RESPONSE": + if (!await SettingsManager.getEnabled()) { + sendResponse(message.body); + return; + } + const tab_url = sender.tab ? sender.tab.url : null; + + try { + const clearkey = JSON.parse(atob(message.body)); + + const formatted_keys = clearkey["keys"].map(key => ({ + ...key, + kid: uint8ArrayToHex(base64toUint8Array(key.kid.replace(/-/g, "+").replace(/_/g, "/") + "==")), + k: uint8ArrayToHex(base64toUint8Array(key.k.replace(/-/g, "+").replace(/_/g, "/") + "==")) + })); + const pssh_data = btoa(JSON.stringify({kids: clearkey["keys"].map(key => key.k)})); + + if (logs.filter(log => log.pssh_data === pssh_data).length > 0) { + console.log("[WidevineProxy2]", `KEYS_ALREADY_RETRIEVED: ${pssh_data}`); + sendResponse(); + return; + } + + console.log("keys", formatted_keys); + const log = { + type: "CLEARKEY", + pssh_data: pssh_data, + keys: formatted_keys, + url: tab_url, + timestamp: Math.floor(Date.now() / 1000) + } + logs.push(log); + + await AsyncLocalStorage.setStorage({[pssh_data]: log}); + sendResponse(); + return; + } catch (e) { + const license = base64toUint8Array(message.body); + const signed_license_message = SignedMessage.decode(license); + if (signed_license_message.type !== SignedMessage.MessageType.LICENSE) { + console.log("[WidevineProxy2]", "INVALID_MESSAGE_TYPE", signed_license_message.type.toString()) + sendResponse(); + return; + } + + const license_obj = License.decode(signed_license_message.msg); + const loaded_request_id = uint8ArrayToBase64(license_obj.id.requestId); + + if (!sessions.has(loaded_request_id)) { + sendResponse(); + return; + } + + const loadedSession = sessions.get(loaded_request_id); + const keys = await loadedSession.parseLicense(license); + const pssh = loadedSession.getPSSH(); + + console.log("[WidevineProxy2]", "KEYS", JSON.stringify(keys), tab_url); + const log = { + type: "WIDEVINE", + pssh_data: pssh, + keys: keys, + url: tab_url, + timestamp: Math.floor(Date.now() / 1000) + } + logs.push(log); + await AsyncLocalStorage.setStorage({[pssh]: log}); + + sessions.delete(loaded_request_id); + sendResponse(); + return; + } + case "GET_LOGS": + sendResponse(logs); + break; + case "OPEN_PICKER": + chrome.windows.create({ + url: 'picker/filePicker.html', + type: 'popup', + width: 300, + height: 200, + }); + break; + case "CLEAR": + logs = []; + break; + } + })(); + return true; +}); diff --git a/cmac.js b/cmac.js new file mode 100644 index 0000000..a356278 --- /dev/null +++ b/cmac.js @@ -0,0 +1,118 @@ +export class AES_CMAC { + BLOCK_SIZE = 16; + XOR_RIGHT = new Uint8Array([ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x87 + ]); + EMPTY_BLOCK_SIZE_BUFFER = new Uint8Array(this.BLOCK_SIZE); + + constructor(key) { + if (![16, 24, 32].includes(key.length)) { + throw new Error("Key size must be 128, 192, or 256 bits."); + } + this._key = key; + } + + async calculate(message) { + this._subkeys = await this._generateSubkeys(); + const blockCount = this._getBlockCount(message); + + let x = this.EMPTY_BLOCK_SIZE_BUFFER; + let y; + + for (let i = 0; i < blockCount - 1; i++) { + const from = i * this.BLOCK_SIZE; + const block = message.subarray(from, from + this.BLOCK_SIZE); + y = this._xor(x, block); + x = await this._aes(y); + } + + y = this._xor(x, this._getLastBlock(message)); + x = await this._aes(y); + + return x; + } + + async _generateSubkeys() { + const l = await this._aes(this.EMPTY_BLOCK_SIZE_BUFFER); + + let first = this._bitShiftLeft(l); + if (l[0] & 0x80) { + first = this._xor(first, this.XOR_RIGHT); + } + + let second = this._bitShiftLeft(first); + if (first[0] & 0x80) { + second = this._xor(second, this.XOR_RIGHT); + } + + return { first: first, second: second }; + } + + _getBlockCount(message) { + const blockCount = Math.ceil(message.length / this.BLOCK_SIZE); + return blockCount === 0 ? 1 : blockCount; + } + + async _aes(message) { + const keyBuffer = forge.util.createBuffer(this._key, 'raw'); + const cipher = forge.cipher.createCipher('AES-CBC', keyBuffer); + + const iv = forge.util.createBuffer(new Uint8Array(16), 'raw'); + cipher.start({ + iv: iv.getBytes() + }); + + cipher.update(forge.util.createBuffer(message)); + cipher.finish(); + + const outputBuffer = cipher.output; + return new Uint8Array(outputBuffer.getBytes().slice(0, 16).split('').map(c => c.charCodeAt(0))); + } + + _getLastBlock(message) { + const blockCount = this._getBlockCount(message); + const paddedBlock = this._padding(message, blockCount - 1); + + let complete = false; + if (message.length > 0) { + complete = message.length % this.BLOCK_SIZE === 0; + } + + const key = complete ? this._subkeys.first : this._subkeys.second; + return this._xor(paddedBlock, key); + } + + _padding(message, blockIndex) { + const block = new Uint8Array(this.BLOCK_SIZE); + + const from = blockIndex * this.BLOCK_SIZE; + const slice = message.subarray(from, from + this.BLOCK_SIZE); + block.set(slice); + + if (slice.length !== this.BLOCK_SIZE) { + block[slice.length] = 0x80; + } + + return block; + } + + _bitShiftLeft(input) { + const output = new Uint8Array(input.length); + let overflow = 0; + for (let i = input.length - 1; i >= 0; i--) { + output[i] = (input[i] << 1) | overflow; + overflow = input[i] & 0x80 ? 1 : 0; + } + return output; + } + + _xor(a, b) { + const length = Math.min(a.length, b.length); + const output = new Uint8Array(length); + for (let i = 0; i < length; i++) { + output[i] = a[i] ^ b[i]; + } + return output; + } +} diff --git a/content_script.js b/content_script.js new file mode 100644 index 0000000..4095a5f --- /dev/null +++ b/content_script.js @@ -0,0 +1,149 @@ +function uint8ArrayToBase64(uint8array) { + return btoa(String.fromCharCode.apply(null, uint8array)); +} + +function base64toUint8Array(base64_string){ + return Uint8Array.from(atob(base64_string), c => c.charCodeAt(0)) +} + +function compareUint8Arrays(arr1, arr2) { + if (arr1.length !== arr2.length) + return false; + return Array.from(arr1).every((value, index) => value === arr2[index]); +} + +function emitAndWaitForResponse(type, data) { + return new Promise((resolve) => { + const requestId = Math.random().toString(16).substring(2, 9); + + const responseHandler = (event) => { + const { detail } = event; + if (detail.substring(0, 7) === requestId) { + document.removeEventListener('responseReceived', responseHandler); + resolve(detail.substring(7)); + } + }; + document.addEventListener('responseReceived', responseHandler); + const requestEvent = new CustomEvent('response', { + detail: { + type: type, + body: data, + requestId: requestId, + } + }); + document.dispatchEvent(requestEvent); + }); +} + +const fnproxy = (object, func) => new Proxy(object, { apply: func }); +const proxy = (object, key, func) => Object.hasOwnProperty.call(object, key) && Object.defineProperty(object, key, { + value: fnproxy(object[key], func) +}); + +function getEventListeners(type) { + if (this == null) return []; + const store = this[Symbol.for(getEventListeners)]; + if (store == null || store[type] == null) return []; + return store[type]; +} + +(async () => { + if (typeof EventTarget !== 'undefined') { + proxy(EventTarget.prototype, 'addEventListener', async (_target, _this, _args) => { + if (_this != null) { + const [type, listener] = _args; + + const storeKey = Symbol.for(getEventListeners); + if (!(storeKey in _this)) _this[storeKey] = {}; + + const store = _this[storeKey]; + if (!(type in store)) store[type] = []; + const listeners = store[type]; + + let wrappedListener = listener; + if (!!listener && !listener._isWrapped) { + wrappedListener = async function(event) { + if (event instanceof MediaKeyMessageEvent) { + if (event._isCustomEvent) { + if (listener.handleEvent) { + listener.handleEvent(event); + } else { + listener.call(this, event); + } + return; + } + + let newBody = new Uint8Array(event.message); + if (!compareUint8Arrays(new Uint8Array([0x08, 0x04]), new Uint8Array(event.message))) { + console.log("[WidevineProxy2]", "WIDEVINE_PROXY", "MESSAGE", listener); + if (listener.name !== "messageHandler") { + const oldChallenge = uint8ArrayToBase64(new Uint8Array(event.message)); + const newChallenge = await emitAndWaitForResponse("REQUEST", oldChallenge); + if (oldChallenge !== newChallenge) { + // Playback will fail if the challenges are the same (aka. the background script + // returned the same challenge because the addon is disabled), but I still + // override the challenge anyway, so check beforehand (in base64 form) + newBody = base64toUint8Array(newChallenge); + } + } else { + // trick EME Logger + // better suggestions for avoiding EME Logger interference are welcome + await emitAndWaitForResponse("REQUEST", ""); + } + } + + const newEvent = new MediaKeyMessageEvent('message', { + isTrusted: event.isTrusted, + bubbles: event.bubbles, + cancelBubble: event.cancelBubble, + composed: event.composed, + currentTarget: event.currentTarget, + defaultPrevented: event.defaultPrevented, + eventPhase: event.eventPhase, + message: newBody.buffer, + messageType: event.messageType, + returnValue: event.returnValue, + srcElement: event.srcElement, + target: event.target, + timeStamp: event.timeStamp, + }); + newEvent._isCustomEvent = true; + + _this.dispatchEvent(newEvent); + event.stopImmediatePropagation(); + return + } + + if (listener.handleEvent) { + listener.handleEvent(event); + } else { + listener.call(this, event); + } + }; + + wrappedListener._isWrapped = true; + wrappedListener.originalListener = listener; + } + + const alreadyAdded = listeners.some( + storedListener => storedListener && storedListener.originalListener === listener + ); + + if (!alreadyAdded) { + listeners.push(wrappedListener); + _args[1] = wrappedListener; + } + } + return _target.apply(_this, _args); + }); + } + + if (typeof MediaKeySession !== 'undefined') { + proxy(MediaKeySession.prototype, 'update', async (_target, _this, _args) => { + const [response] = _args; + console.log("[WidevineProxy2]", "WIDEVINE_PROXY", "UPDATE"); + await emitAndWaitForResponse("RESPONSE", uint8ArrayToBase64(new Uint8Array(response))) + return await _target.apply(_this, _args); + }); + } +})(); \ No newline at end of file diff --git a/demo.mp4 b/demo.mp4 new file mode 100644 index 0000000..b692e55 Binary files /dev/null and b/demo.mp4 differ diff --git a/device.js b/device.js new file mode 100644 index 0000000..0f6167c --- /dev/null +++ b/device.js @@ -0,0 +1,65 @@ +const { ClientIdentification } = protobuf.roots.default.license_protocol; + +export class Crc32 { + constructor() { + this.crc_table = this.setupTable(); + } + + setupTable() { + let c; + const crcTable = []; + for (let n = 0; n < 256; n++) { + c = n; + for (let k = 0; k < 8; k++) { + c = (c & 1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1); + } + crcTable[n] = c; + } + return crcTable; + } + + crc32(uint8Array) { + let crc = 0 ^ (-1); + for (let i = 0; i < uint8Array.length; i++) { + crc = (crc >>> 8) ^ this.crc_table[(crc ^ uint8Array[i]) & 0xFF]; + } + return (crc ^ (-1)) >>> 0; + } +} + +export class WidevineDevice { + constructor(bytes) { + this._raw_bytes = new Uint8Array(bytes); + this._data_view = new DataView(bytes); + + this.version = this._data_view.getUint8(3); + this.type = this._data_view.getUint8(4); + this.security_level = this._data_view.getUint8(5); + this.flags = this._data_view.getUint8(6); + + this.private_key_len = this._data_view.getUint16(7); + this.private_key = this._raw_bytes.subarray(9, 9 + this.private_key_len); + + this.client_id_len = this._data_view.getUint16(9 + this.private_key_len); + this.client_id_bytes = this._raw_bytes.subarray(11 + this.private_key_len, 11 + this.private_key_len + this.client_id_len); + this.client_id = ClientIdentification.decode(this.client_id_bytes); + } + + get_name() { + const client_info = Object.fromEntries(this.client_id.clientInfo.map(item => [item.name, item.value])) + const type = this.type === 1 ? "CHROME" : `L${this.security_level}` + + let name = `[${type}]`; + if (client_info["company_name"]) + name += ` ${client_info["company_name"]}`; + if (client_info["model_name"]) + name += `, ${client_info["model_name"]}`; + if (client_info["product_name"]) + name += `, ${client_info["product_name"]}`; + + const crc32 = new Crc32(); + name += `, ${crc32.crc32(this._raw_bytes).toString(16)}`; + + return name; + } +} diff --git a/forge.min.js b/forge.min.js new file mode 100644 index 0000000..5023c9f --- /dev/null +++ b/forge.min.js @@ -0,0 +1,2 @@ +const window=self;!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.forge=t():e.forge=t()}(window,(function(){return function(e){var t={};function r(a){if(t[a])return t[a].exports;var n=t[a]={i:a,l:!1,exports:{}};return e[a].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=e,r.c=t,r.d=function(e,t,a){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:a})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var a=Object.create(null);if(r.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)r.d(a,n,function(t){return e[t]}.bind(null,n));return a},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=34)}([function(e,t){e.exports={options:{usePureJavaScript:!1}}},function(e,t,r){(function(t){var a=r(0),n=r(37),i=e.exports=a.util=a.util||{};function s(e){if(8!==e&&16!==e&&24!==e&&32!==e)throw new Error("Only 8, 16, 24, or 32 bits supported: "+e)}function o(e){if(this.data="",this.read=0,"string"==typeof e)this.data=e;else if(i.isArrayBuffer(e)||i.isArrayBufferView(e))if("undefined"!=typeof Buffer&&e instanceof Buffer)this.data=e.toString("binary");else{var t=new Uint8Array(e);try{this.data=String.fromCharCode.apply(null,t)}catch(e){for(var r=0;r15?(r=Date.now(),s(e)):(t.push(e),1===t.length&&n.setAttribute("a",a=!a))}}i.nextTick=i.setImmediate}(),i.isNodejs="undefined"!=typeof process&&process.versions&&process.versions.node,i.globalScope=i.isNodejs?t:"undefined"==typeof self?window:self,i.isArray=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},i.isArrayBuffer=function(e){return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer},i.isArrayBufferView=function(e){return e&&i.isArrayBuffer(e.buffer)&&void 0!==e.byteLength},i.ByteBuffer=o,i.ByteStringBuffer=o;i.ByteStringBuffer.prototype._optimizeConstructedString=function(e){this._constructedStringLength+=e,this._constructedStringLength>4096&&(this.data.substr(0,1),this._constructedStringLength=0)},i.ByteStringBuffer.prototype.length=function(){return this.data.length-this.read},i.ByteStringBuffer.prototype.isEmpty=function(){return this.length()<=0},i.ByteStringBuffer.prototype.putByte=function(e){return this.putBytes(String.fromCharCode(e))},i.ByteStringBuffer.prototype.fillWithByte=function(e,t){e=String.fromCharCode(e);for(var r=this.data;t>0;)1&t&&(r+=e),(t>>>=1)>0&&(e+=e);return this.data=r,this._optimizeConstructedString(t),this},i.ByteStringBuffer.prototype.putBytes=function(e){return this.data+=e,this._optimizeConstructedString(e.length),this},i.ByteStringBuffer.prototype.putString=function(e){return this.putBytes(i.encodeUtf8(e))},i.ByteStringBuffer.prototype.putInt16=function(e){return this.putBytes(String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},i.ByteStringBuffer.prototype.putInt24=function(e){return this.putBytes(String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},i.ByteStringBuffer.prototype.putInt32=function(e){return this.putBytes(String.fromCharCode(e>>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},i.ByteStringBuffer.prototype.putInt16Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255))},i.ByteStringBuffer.prototype.putInt24Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255))},i.ByteStringBuffer.prototype.putInt32Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>24&255))},i.ByteStringBuffer.prototype.putInt=function(e,t){s(t);var r="";do{t-=8,r+=String.fromCharCode(e>>t&255)}while(t>0);return this.putBytes(r)},i.ByteStringBuffer.prototype.putSignedInt=function(e,t){return e<0&&(e+=2<0);return t},i.ByteStringBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),r=2<=r&&(t-=r<<1),t},i.ByteStringBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):0===e?t="":(t=0===this.read?this.data:this.data.slice(this.read),this.clear()),t},i.ByteStringBuffer.prototype.bytes=function(e){return void 0===e?this.data.slice(this.read):this.data.slice(this.read,this.read+e)},i.ByteStringBuffer.prototype.at=function(e){return this.data.charCodeAt(this.read+e)},i.ByteStringBuffer.prototype.setAt=function(e,t){return this.data=this.data.substr(0,this.read+e)+String.fromCharCode(t)+this.data.substr(this.read+e+1),this},i.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)},i.ByteStringBuffer.prototype.copy=function(){var e=i.createBuffer(this.data);return e.read=this.read,e},i.ByteStringBuffer.prototype.compact=function(){return this.read>0&&(this.data=this.data.slice(this.read),this.read=0),this},i.ByteStringBuffer.prototype.clear=function(){return this.data="",this.read=0,this},i.ByteStringBuffer.prototype.truncate=function(e){var t=Math.max(0,this.length()-e);return this.data=this.data.substr(this.read,t),this.read=0,this},i.ByteStringBuffer.prototype.toHex=function(){for(var e="",t=this.read;t=e)return this;t=Math.max(t||this.growSize,e);var r=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength),a=new Uint8Array(this.length()+t);return a.set(r),this.data=new DataView(a.buffer),this},i.DataBuffer.prototype.putByte=function(e){return this.accommodate(1),this.data.setUint8(this.write++,e),this},i.DataBuffer.prototype.fillWithByte=function(e,t){this.accommodate(t);for(var r=0;r>8&65535),this.data.setInt8(this.write,e>>16&255),this.write+=3,this},i.DataBuffer.prototype.putInt32=function(e){return this.accommodate(4),this.data.setInt32(this.write,e),this.write+=4,this},i.DataBuffer.prototype.putInt16Le=function(e){return this.accommodate(2),this.data.setInt16(this.write,e,!0),this.write+=2,this},i.DataBuffer.prototype.putInt24Le=function(e){return this.accommodate(3),this.data.setInt8(this.write,e>>16&255),this.data.setInt16(this.write,e>>8&65535,!0),this.write+=3,this},i.DataBuffer.prototype.putInt32Le=function(e){return this.accommodate(4),this.data.setInt32(this.write,e,!0),this.write+=4,this},i.DataBuffer.prototype.putInt=function(e,t){s(t),this.accommodate(t/8);do{t-=8,this.data.setInt8(this.write++,e>>t&255)}while(t>0);return this},i.DataBuffer.prototype.putSignedInt=function(e,t){return s(t),this.accommodate(t/8),e<0&&(e+=2<0);return t},i.DataBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),r=2<=r&&(t-=r<<1),t},i.DataBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):0===e?t="":(t=0===this.read?this.data:this.data.slice(this.read),this.clear()),t},i.DataBuffer.prototype.bytes=function(e){return void 0===e?this.data.slice(this.read):this.data.slice(this.read,this.read+e)},i.DataBuffer.prototype.at=function(e){return this.data.getUint8(this.read+e)},i.DataBuffer.prototype.setAt=function(e,t){return this.data.setUint8(e,t),this},i.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)},i.DataBuffer.prototype.copy=function(){return new i.DataBuffer(this)},i.DataBuffer.prototype.compact=function(){if(this.read>0){var e=new Uint8Array(this.data.buffer,this.read),t=new Uint8Array(e.byteLength);t.set(e),this.data=new DataView(t),this.write-=this.read,this.read=0}return this},i.DataBuffer.prototype.clear=function(){return this.data=new DataView(new ArrayBuffer(0)),this.read=this.write=0,this},i.DataBuffer.prototype.truncate=function(e){return this.write=Math.max(0,this.length()-e),this.read=Math.min(this.read,this.write),this},i.DataBuffer.prototype.toHex=function(){for(var e="",t=this.read;t0;)1&t&&(r+=e),(t>>>=1)>0&&(e+=e);return r},i.xorBytes=function(e,t,r){for(var a="",n="",i="",s=0,o=0;r>0;--r,++s)n=e.charCodeAt(s)^t.charCodeAt(s),o>=10&&(a+=i,i="",o=0),i+=String.fromCharCode(n),++o;return a+=i},i.hexToBytes=function(e){var t="",r=0;for(!0&e.length&&(r=1,t+=String.fromCharCode(parseInt(e[0],16)));r>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e)};var c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",u=[62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,64,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],l="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";i.encode64=function(e,t){for(var r,a,n,i="",s="",o=0;o>2),i+=c.charAt((3&r)<<4|a>>4),isNaN(a)?i+="==":(i+=c.charAt((15&a)<<2|n>>6),i+=isNaN(n)?"=":c.charAt(63&n)),t&&i.length>t&&(s+=i.substr(0,t)+"\r\n",i=i.substr(t));return s+=i},i.decode64=function(e){e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var t,r,a,n,i="",s=0;s>4),64!==a&&(i+=String.fromCharCode((15&r)<<4|a>>2),64!==n&&(i+=String.fromCharCode((3&a)<<6|n)));return i},i.encodeUtf8=function(e){return unescape(encodeURIComponent(e))},i.decodeUtf8=function(e){return decodeURIComponent(escape(e))},i.binary={raw:{},hex:{},base64:{},base58:{},baseN:{encode:n.encode,decode:n.decode}},i.binary.raw.encode=function(e){return String.fromCharCode.apply(null,e)},i.binary.raw.decode=function(e,t,r){var a=t;a||(a=new Uint8Array(e.length));for(var n=r=r||0,i=0;i>2),i+=c.charAt((3&r)<<4|a>>4),isNaN(a)?i+="==":(i+=c.charAt((15&a)<<2|n>>6),i+=isNaN(n)?"=":c.charAt(63&n)),t&&i.length>t&&(s+=i.substr(0,t)+"\r\n",i=i.substr(t));return s+=i},i.binary.base64.decode=function(e,t,r){var a,n,i,s,o=t;o||(o=new Uint8Array(3*Math.ceil(e.length/4))),e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var c=0,l=r=r||0;c>4,64!==i&&(o[l++]=(15&n)<<4|i>>2,64!==s&&(o[l++]=(3&i)<<6|s));return t?l-r:o.subarray(0,l)},i.binary.base58.encode=function(e,t){return i.binary.baseN.encode(e,l,t)},i.binary.base58.decode=function(e,t){return i.binary.baseN.decode(e,l,t)},i.text={utf8:{},utf16:{}},i.text.utf8.encode=function(e,t,r){e=i.encodeUtf8(e);var a=t;a||(a=new Uint8Array(e.length));for(var n=r=r||0,s=0;s0?(n=r[a].substring(0,s),i=r[a].substring(s+1)):(n=r[a],i=null),n in t||(t[n]=[]),n in Object.prototype||null===i||t[n].push(unescape(i))}return t};return void 0===e?(null===v&&(v="undefined"!=typeof window&&window.location&&window.location.search?r(window.location.search.substring(1)):{}),t=v):t=r(e),t},i.parseFragment=function(e){var t=e,r="",a=e.indexOf("?");a>0&&(t=e.substring(0,a),r=e.substring(a+1));var n=t.split("/");return n.length>0&&""===n[0]&&n.shift(),{pathString:t,queryString:r,path:n,query:""===r?{}:i.getQueryVariables(r)}},i.makeRequest=function(e){var t=i.parseFragment(e),r={path:t.pathString,query:t.queryString,getPath:function(e){return void 0===e?t.path:t.path[e]},getQuery:function(e,r){var a;return void 0===e?a=t.query:(a=t.query[e])&&void 0!==r&&(a=a[r]),a},getQueryLast:function(e,t){var a=r.getQuery(e);return a?a[a.length-1]:t}};return r},i.makeLink=function(e,t,r){e=jQuery.isArray(e)?e.join("/"):e;var a=jQuery.param(t||{});return r=r||"",e+(a.length>0?"?"+a:"")+(r.length>0?"#"+r:"")},i.isEmpty=function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0},i.format=function(e){for(var t,r,a=/%./g,n=0,i=[],s=0;t=a.exec(e);){(r=e.substring(s,a.lastIndex-2)).length>0&&i.push(r),s=a.lastIndex;var o=t[0][1];switch(o){case"s":case"o":n");break;case"%":i.push("%");break;default:i.push("<%"+o+"?>")}}return i.push(e.substring(s)),i.join("")},i.formatNumber=function(e,t,r,a){var n=e,i=isNaN(t=Math.abs(t))?2:t,s=void 0===r?",":r,o=void 0===a?".":a,c=n<0?"-":"",u=parseInt(n=Math.abs(+n||0).toFixed(i),10)+"",l=u.length>3?u.length%3:0;return c+(l?u.substr(0,l)+o:"")+u.substr(l).replace(/(\d{3})(?=\d)/g,"$1"+o)+(i?s+Math.abs(n-u).toFixed(i).slice(2):"")},i.formatSize=function(e){return e=e>=1073741824?i.formatNumber(e/1073741824,2,".","")+" GiB":e>=1048576?i.formatNumber(e/1048576,2,".","")+" MiB":e>=1024?i.formatNumber(e/1024,0)+" KiB":i.formatNumber(e,0)+" bytes"},i.bytesFromIP=function(e){return-1!==e.indexOf(".")?i.bytesFromIPv4(e):-1!==e.indexOf(":")?i.bytesFromIPv6(e):null},i.bytesFromIPv4=function(e){if(4!==(e=e.split(".")).length)return null;for(var t=i.createBuffer(),r=0;rr[a].end-r[a].start&&(a=r.length-1)):r.push({start:c,end:c})}t.push(s)}if(r.length>0){var u=r[a];u.end-u.start>0&&(t.splice(u.start,u.end-u.start+1,""),0===u.start&&t.unshift(""),7===u.end&&t.push(""))}return t.join(":")},i.estimateCores=function(e,t){if("function"==typeof e&&(t=e,e={}),e=e||{},"cores"in i&&!e.update)return t(null,i.cores);if("undefined"!=typeof navigator&&"hardwareConcurrency"in navigator&&navigator.hardwareConcurrency>0)return i.cores=navigator.hardwareConcurrency,t(null,i.cores);if("undefined"==typeof Worker)return i.cores=1,t(null,i.cores);if("undefined"==typeof Blob)return i.cores=2,t(null,i.cores);var r=URL.createObjectURL(new Blob(["(",function(){self.addEventListener("message",(function(e){for(var t=Date.now(),r=t+4;Date.now()o.st&&n.stn.st&&o.stt){var a=new Error("Too few bytes to parse DER.");throw a.available=e.length(),a.remaining=t,a.requested=r,a}}n.Class={UNIVERSAL:0,APPLICATION:64,CONTEXT_SPECIFIC:128,PRIVATE:192},n.Type={NONE:0,BOOLEAN:1,INTEGER:2,BITSTRING:3,OCTETSTRING:4,NULL:5,OID:6,ODESC:7,EXTERNAL:8,REAL:9,ENUMERATED:10,EMBEDDED:11,UTF8:12,ROID:13,SEQUENCE:16,SET:17,PRINTABLESTRING:19,IA5STRING:22,UTCTIME:23,GENERALIZEDTIME:24,BMPSTRING:30},n.create=function(e,t,r,i,s){if(a.util.isArray(i)){for(var o=[],c=0;cr){if(s.strict){var d=new Error("Too few bytes to read ASN.1 value.");throw d.available=t.length(),d.remaining=r,d.requested=h,d}h=r}var y=32==(32&c);if(y)if(p=[],void 0===h)for(;;){if(i(t,r,2),t.bytes(2)===String.fromCharCode(0,0)){t.getBytes(2),r-=2;break}o=t.length(),p.push(e(t,r,a+1,s)),r-=o-t.length()}else for(;h>0;)o=t.length(),p.push(e(t,h,a+1,s)),r-=o-t.length(),h-=o-t.length();void 0===p&&u===n.Class.UNIVERSAL&&l===n.Type.BITSTRING&&(f=t.bytes(h));if(void 0===p&&s.decodeBitStrings&&u===n.Class.UNIVERSAL&&l===n.Type.BITSTRING&&h>1){var g=t.read,m=r,v=0;if(l===n.Type.BITSTRING&&(i(t,r,1),v=t.getByte(),r--),0===v)try{o=t.length();var C={verbose:s.verbose,strict:!0,decodeBitStrings:!0},E=e(t,r,a+1,C),S=o-t.length();r-=S,l==n.Type.BITSTRING&&S++;var T=E.tagClass;S!==h||T!==n.Class.UNIVERSAL&&T!==n.Class.CONTEXT_SPECIFIC||(p=[E])}catch(e){}void 0===p&&(t.read=g,r=m)}if(void 0===p){if(void 0===h){if(s.strict)throw new Error("Non-constructed ASN.1 object of indefinite length.");h=r}if(l===n.Type.BMPSTRING)for(p="";h>0;h-=2)i(t,r,2),p+=String.fromCharCode(t.getInt16()),r-=2;else p=t.getBytes(h)}var I=void 0===f?null:{bitStringContents:f};return n.create(u,l,y,p,I)}(e,e.length(),0,t)},n.toDer=function(e){var t=a.util.createBuffer(),r=e.tagClass|e.type,i=a.util.createBuffer(),s=!1;if("bitStringContents"in e&&(s=!0,e.original&&(s=n.equals(e,e.original))),s)i.putBytes(e.bitStringContents);else if(e.composed){e.constructed?r|=32:i.putByte(0);for(var o=0;o1&&(0===e.value.charCodeAt(0)&&0==(128&e.value.charCodeAt(1))||255===e.value.charCodeAt(0)&&128==(128&e.value.charCodeAt(1)))?i.putBytes(e.value.substr(1)):i.putBytes(e.value);if(t.putByte(r),i.length()<=127)t.putByte(127&i.length());else{var c=i.length(),u="";do{u+=String.fromCharCode(255&c),c>>>=8}while(c>0);t.putByte(128|u.length);for(o=u.length-1;o>=0;--o)t.putByte(u.charCodeAt(o))}return t.putBuffer(i),t},n.oidToDer=function(e){var t,r,n,i,s=e.split("."),o=a.util.createBuffer();o.putByte(40*parseInt(s[0],10)+parseInt(s[1],10));for(var c=2;c>>=7,t||(i|=128),r.push(i),t=!1}while(n>0);for(var u=r.length-1;u>=0;--u)o.putByte(r[u])}return o},n.derToOid=function(e){var t;"string"==typeof e&&(e=a.util.createBuffer(e));var r=e.getByte();t=Math.floor(r/40)+"."+r%40;for(var n=0;e.length()>0;)n<<=7,128&(r=e.getByte())?n+=127&r:(t+="."+(n+r),n=0);return t},n.utcTimeToDate=function(e){var t=new Date,r=parseInt(e.substr(0,2),10);r=r>=50?1900+r:2e3+r;var a=parseInt(e.substr(2,2),10)-1,n=parseInt(e.substr(4,2),10),i=parseInt(e.substr(6,2),10),s=parseInt(e.substr(8,2),10),o=0;if(e.length>11){var c=e.charAt(10),u=10;"+"!==c&&"-"!==c&&(o=parseInt(e.substr(10,2),10),u+=2)}if(t.setUTCFullYear(r,a,n),t.setUTCHours(i,s,o,0),u&&("+"===(c=e.charAt(u))||"-"===c)){var l=60*parseInt(e.substr(u+1,2),10)+parseInt(e.substr(u+4,2),10);l*=6e4,"+"===c?t.setTime(+t-l):t.setTime(+t+l)}return t},n.generalizedTimeToDate=function(e){var t=new Date,r=parseInt(e.substr(0,4),10),a=parseInt(e.substr(4,2),10)-1,n=parseInt(e.substr(6,2),10),i=parseInt(e.substr(8,2),10),s=parseInt(e.substr(10,2),10),o=parseInt(e.substr(12,2),10),c=0,u=0,l=!1;"Z"===e.charAt(e.length-1)&&(l=!0);var p=e.length-5,f=e.charAt(p);"+"!==f&&"-"!==f||(u=60*parseInt(e.substr(p+1,2),10)+parseInt(e.substr(p+4,2),10),u*=6e4,"+"===f&&(u*=-1),l=!0);return"."===e.charAt(14)&&(c=1e3*parseFloat(e.substr(14),10)),l?(t.setUTCFullYear(r,a,n),t.setUTCHours(i,s,o,c),t.setTime(+t+u)):(t.setFullYear(r,a,n),t.setHours(i,s,o,c)),t},n.dateToUtcTime=function(e){if("string"==typeof e)return e;var t="",r=[];r.push((""+e.getUTCFullYear()).substr(2)),r.push(""+(e.getUTCMonth()+1)),r.push(""+e.getUTCDate()),r.push(""+e.getUTCHours()),r.push(""+e.getUTCMinutes()),r.push(""+e.getUTCSeconds());for(var a=0;a=-128&&e<128)return t.putSignedInt(e,8);if(e>=-32768&&e<32768)return t.putSignedInt(e,16);if(e>=-8388608&&e<8388608)return t.putSignedInt(e,24);if(e>=-2147483648&&e<2147483648)return t.putSignedInt(e,32);var r=new Error("Integer too large; max is 32-bits.");throw r.integer=e,r},n.derToInteger=function(e){"string"==typeof e&&(e=a.util.createBuffer(e));var t=8*e.length();if(t>32)throw new Error("Integer too large; max is 32-bits.");return e.getSignedInt(t)},n.validate=function(e,t,r,i){var s=!1;if(e.tagClass!==t.tagClass&&void 0!==t.tagClass||e.type!==t.type&&void 0!==t.type)i&&(e.tagClass!==t.tagClass&&i.push("["+t.name+'] Expected tag class "'+t.tagClass+'", got "'+e.tagClass+'"'),e.type!==t.type&&i.push("["+t.name+'] Expected type "'+t.type+'", got "'+e.type+'"'));else if(e.constructed===t.constructed||void 0===t.constructed){if(s=!0,t.value&&a.util.isArray(t.value))for(var o=0,c=0;s&&c0&&(i+="\n");for(var o="",c=0;c1?i+="0x"+a.util.bytesToHex(e.value.slice(1)):i+="(none)",e.value.length>0){var f=e.value.charCodeAt(0);1==f?i+=" (1 unused bit shown)":f>1&&(i+=" ("+f+" unused bits shown)")}}else e.type===n.Type.OCTETSTRING?(s.test(e.value)||(i+="("+e.value+") "),i+="0x"+a.util.bytesToHex(e.value)):e.type===n.Type.UTF8?i+=a.util.decodeUtf8(e.value):e.type===n.Type.PRINTABLESTRING||e.type===n.Type.IA5String?i+=e.value:s.test(e.value)?i+="0x"+a.util.bytesToHex(e.value):0===e.value.length?i+="[null]":i+=e.value}return i}},function(e,t,r){var a=r(0);e.exports=a.md=a.md||{},a.md.algorithms=a.md.algorithms||{}},function(e,t,r){var a=r(0);function n(e,t){a.cipher.registerAlgorithm(e,(function(){return new a.aes.Algorithm(e,t)}))}r(13),r(19),r(1),e.exports=a.aes=a.aes||{},a.aes.startEncrypting=function(e,t,r,a){var n=d({key:e,output:r,decrypt:!1,mode:a});return n.start(t),n},a.aes.createEncryptionCipher=function(e,t){return d({key:e,output:null,decrypt:!1,mode:t})},a.aes.startDecrypting=function(e,t,r,a){var n=d({key:e,output:r,decrypt:!0,mode:a});return n.start(t),n},a.aes.createDecryptionCipher=function(e,t){return d({key:e,output:null,decrypt:!0,mode:t})},a.aes.Algorithm=function(e,t){l||p();var r=this;r.name=e,r.mode=new t({blockSize:16,cipher:{encrypt:function(e,t){return h(r._w,e,t,!1)},decrypt:function(e,t){return h(r._w,e,t,!0)}}}),r._init=!1},a.aes.Algorithm.prototype.initialize=function(e){if(!this._init){var t,r=e.key;if("string"!=typeof r||16!==r.length&&24!==r.length&&32!==r.length){if(a.util.isArray(r)&&(16===r.length||24===r.length||32===r.length)){t=r,r=a.util.createBuffer();for(var n=0;n>>=2;for(n=0;n>8^255&p^99,i[y]=p,s[p]=y,h=(f=e[p])<<24^p<<16^p<<8^p^f,d=((r=e[y])^(a=e[r])^(n=e[a]))<<24^(y^n)<<16^(y^a^n)<<8^y^r^n;for(var m=0;m<4;++m)c[m][y]=h,u[m][p]=d,h=h<<24|h>>>8,d=d<<24|d>>>8;0===y?y=g=1:(y=r^e[e[e[r^n]]],g^=e[e[g]])}}function f(e,t){for(var r,a=e.slice(0),n=1,s=a.length,c=4*(s+6+1),l=s;l>>16&255]<<24^i[r>>>8&255]<<16^i[255&r]<<8^i[r>>>24]^o[n]<<24,n++):s>6&&l%s==4&&(r=i[r>>>24]<<24^i[r>>>16&255]<<16^i[r>>>8&255]<<8^i[255&r]),a[l]=a[l-s]^r;if(t){for(var p,f=u[0],h=u[1],d=u[2],y=u[3],g=a.slice(0),m=(l=0,(c=a.length)-4);l>>24]]^h[i[p>>>16&255]]^d[i[p>>>8&255]]^y[i[255&p]];a=g}return a}function h(e,t,r,a){var n,o,l,p,f,h,d,y,g,m,v,C,E=e.length/4-1;a?(n=u[0],o=u[1],l=u[2],p=u[3],f=s):(n=c[0],o=c[1],l=c[2],p=c[3],f=i),h=t[0]^e[0],d=t[a?3:1]^e[1],y=t[2]^e[2],g=t[a?1:3]^e[3];for(var S=3,T=1;T>>24]^o[d>>>16&255]^l[y>>>8&255]^p[255&g]^e[++S],v=n[d>>>24]^o[y>>>16&255]^l[g>>>8&255]^p[255&h]^e[++S],C=n[y>>>24]^o[g>>>16&255]^l[h>>>8&255]^p[255&d]^e[++S],g=n[g>>>24]^o[h>>>16&255]^l[d>>>8&255]^p[255&y]^e[++S],h=m,d=v,y=C;r[0]=f[h>>>24]<<24^f[d>>>16&255]<<16^f[y>>>8&255]<<8^f[255&g]^e[++S],r[a?3:1]=f[d>>>24]<<24^f[y>>>16&255]<<16^f[g>>>8&255]<<8^f[255&h]^e[++S],r[2]=f[y>>>24]<<24^f[g>>>16&255]<<16^f[h>>>8&255]<<8^f[255&d]^e[++S],r[a?1:3]=f[g>>>24]<<24^f[h>>>16&255]<<16^f[d>>>8&255]<<8^f[255&y]^e[++S]}function d(e){var t,r="AES-"+((e=e||{}).mode||"CBC").toUpperCase(),n=(t=e.decrypt?a.cipher.createDecipher(r,e.key):a.cipher.createCipher(r,e.key)).start;return t.start=function(e,r){var i=null;r instanceof a.util.ByteBuffer&&(i=r,r={}),(r=r||{}).output=i,r.iv=e,n.call(t,r)},t}},function(e,t,r){var a=r(0);a.pki=a.pki||{};var n=e.exports=a.pki.oids=a.oids=a.oids||{};function i(e,t){n[e]=t,n[t]=e}function s(e,t){n[e]=t}i("1.2.840.113549.1.1.1","rsaEncryption"),i("1.2.840.113549.1.1.4","md5WithRSAEncryption"),i("1.2.840.113549.1.1.5","sha1WithRSAEncryption"),i("1.2.840.113549.1.1.7","RSAES-OAEP"),i("1.2.840.113549.1.1.8","mgf1"),i("1.2.840.113549.1.1.9","pSpecified"),i("1.2.840.113549.1.1.10","RSASSA-PSS"),i("1.2.840.113549.1.1.11","sha256WithRSAEncryption"),i("1.2.840.113549.1.1.12","sha384WithRSAEncryption"),i("1.2.840.113549.1.1.13","sha512WithRSAEncryption"),i("1.3.101.112","EdDSA25519"),i("1.2.840.10040.4.3","dsa-with-sha1"),i("1.3.14.3.2.7","desCBC"),i("1.3.14.3.2.26","sha1"),i("2.16.840.1.101.3.4.2.1","sha256"),i("2.16.840.1.101.3.4.2.2","sha384"),i("2.16.840.1.101.3.4.2.3","sha512"),i("1.2.840.113549.2.5","md5"),i("1.2.840.113549.1.7.1","data"),i("1.2.840.113549.1.7.2","signedData"),i("1.2.840.113549.1.7.3","envelopedData"),i("1.2.840.113549.1.7.4","signedAndEnvelopedData"),i("1.2.840.113549.1.7.5","digestedData"),i("1.2.840.113549.1.7.6","encryptedData"),i("1.2.840.113549.1.9.1","emailAddress"),i("1.2.840.113549.1.9.2","unstructuredName"),i("1.2.840.113549.1.9.3","contentType"),i("1.2.840.113549.1.9.4","messageDigest"),i("1.2.840.113549.1.9.5","signingTime"),i("1.2.840.113549.1.9.6","counterSignature"),i("1.2.840.113549.1.9.7","challengePassword"),i("1.2.840.113549.1.9.8","unstructuredAddress"),i("1.2.840.113549.1.9.14","extensionRequest"),i("1.2.840.113549.1.9.20","friendlyName"),i("1.2.840.113549.1.9.21","localKeyId"),i("1.2.840.113549.1.9.22.1","x509Certificate"),i("1.2.840.113549.1.12.10.1.1","keyBag"),i("1.2.840.113549.1.12.10.1.2","pkcs8ShroudedKeyBag"),i("1.2.840.113549.1.12.10.1.3","certBag"),i("1.2.840.113549.1.12.10.1.4","crlBag"),i("1.2.840.113549.1.12.10.1.5","secretBag"),i("1.2.840.113549.1.12.10.1.6","safeContentsBag"),i("1.2.840.113549.1.5.13","pkcs5PBES2"),i("1.2.840.113549.1.5.12","pkcs5PBKDF2"),i("1.2.840.113549.1.12.1.1","pbeWithSHAAnd128BitRC4"),i("1.2.840.113549.1.12.1.2","pbeWithSHAAnd40BitRC4"),i("1.2.840.113549.1.12.1.3","pbeWithSHAAnd3-KeyTripleDES-CBC"),i("1.2.840.113549.1.12.1.4","pbeWithSHAAnd2-KeyTripleDES-CBC"),i("1.2.840.113549.1.12.1.5","pbeWithSHAAnd128BitRC2-CBC"),i("1.2.840.113549.1.12.1.6","pbewithSHAAnd40BitRC2-CBC"),i("1.2.840.113549.2.7","hmacWithSHA1"),i("1.2.840.113549.2.8","hmacWithSHA224"),i("1.2.840.113549.2.9","hmacWithSHA256"),i("1.2.840.113549.2.10","hmacWithSHA384"),i("1.2.840.113549.2.11","hmacWithSHA512"),i("1.2.840.113549.3.7","des-EDE3-CBC"),i("2.16.840.1.101.3.4.1.2","aes128-CBC"),i("2.16.840.1.101.3.4.1.22","aes192-CBC"),i("2.16.840.1.101.3.4.1.42","aes256-CBC"),i("2.5.4.3","commonName"),i("2.5.4.5","serialName"),i("2.5.4.6","countryName"),i("2.5.4.7","localityName"),i("2.5.4.8","stateOrProvinceName"),i("2.5.4.9","streetAddress"),i("2.5.4.10","organizationName"),i("2.5.4.11","organizationalUnitName"),i("2.5.4.13","description"),i("2.5.4.15","businessCategory"),i("2.5.4.17","postalCode"),i("1.3.6.1.4.1.311.60.2.1.2","jurisdictionOfIncorporationStateOrProvinceName"),i("1.3.6.1.4.1.311.60.2.1.3","jurisdictionOfIncorporationCountryName"),i("2.16.840.1.113730.1.1","nsCertType"),i("2.16.840.1.113730.1.13","nsComment"),s("2.5.29.1","authorityKeyIdentifier"),s("2.5.29.2","keyAttributes"),s("2.5.29.3","certificatePolicies"),s("2.5.29.4","keyUsageRestriction"),s("2.5.29.5","policyMapping"),s("2.5.29.6","subtreesConstraint"),s("2.5.29.7","subjectAltName"),s("2.5.29.8","issuerAltName"),s("2.5.29.9","subjectDirectoryAttributes"),s("2.5.29.10","basicConstraints"),s("2.5.29.11","nameConstraints"),s("2.5.29.12","policyConstraints"),s("2.5.29.13","basicConstraints"),i("2.5.29.14","subjectKeyIdentifier"),i("2.5.29.15","keyUsage"),s("2.5.29.16","privateKeyUsagePeriod"),i("2.5.29.17","subjectAltName"),i("2.5.29.18","issuerAltName"),i("2.5.29.19","basicConstraints"),s("2.5.29.20","cRLNumber"),s("2.5.29.21","cRLReason"),s("2.5.29.22","expirationDate"),s("2.5.29.23","instructionCode"),s("2.5.29.24","invalidityDate"),s("2.5.29.25","cRLDistributionPoints"),s("2.5.29.26","issuingDistributionPoint"),s("2.5.29.27","deltaCRLIndicator"),s("2.5.29.28","issuingDistributionPoint"),s("2.5.29.29","certificateIssuer"),s("2.5.29.30","nameConstraints"),i("2.5.29.31","cRLDistributionPoints"),i("2.5.29.32","certificatePolicies"),s("2.5.29.33","policyMappings"),s("2.5.29.34","policyConstraints"),i("2.5.29.35","authorityKeyIdentifier"),s("2.5.29.36","policyConstraints"),i("2.5.29.37","extKeyUsage"),s("2.5.29.46","freshestCRL"),s("2.5.29.54","inhibitAnyPolicy"),i("1.3.6.1.4.1.11129.2.4.2","timestampList"),i("1.3.6.1.5.5.7.1.1","authorityInfoAccess"),i("1.3.6.1.5.5.7.3.1","serverAuth"),i("1.3.6.1.5.5.7.3.2","clientAuth"),i("1.3.6.1.5.5.7.3.3","codeSigning"),i("1.3.6.1.5.5.7.3.4","emailProtection"),i("1.3.6.1.5.5.7.3.8","timeStamping")},function(e,t,r){var a=r(0);r(1);var n=e.exports=a.pem=a.pem||{};function i(e){for(var t=e.name+": ",r=[],a=function(e,t){return" "+t},n=0;n65&&-1!==s){var o=t[s];","===o?(++s,t=t.substr(0,s)+"\r\n "+t.substr(s)):t=t.substr(0,s)+"\r\n"+o+t.substr(s+1),i=n-s-1,s=-1,++n}else" "!==t[n]&&"\t"!==t[n]&&","!==t[n]||(s=n);return t}function s(e){return e.replace(/^\s+/,"")}n.encode=function(e,t){t=t||{};var r,n="-----BEGIN "+e.type+"-----\r\n";if(e.procType&&(n+=i(r={name:"Proc-Type",values:[String(e.procType.version),e.procType.type]})),e.contentDomain&&(n+=i(r={name:"Content-Domain",values:[e.contentDomain]})),e.dekInfo&&(r={name:"DEK-Info",values:[e.dekInfo.algorithm]},e.dekInfo.parameters&&r.values.push(e.dekInfo.parameters),n+=i(r)),e.headers)for(var s=0;st.blockLength&&(t.start(),t.update(s.bytes()),s=t.digest()),r=a.util.createBuffer(),n=a.util.createBuffer(),u=s.length();for(c=0;c>>0,c>>>0];for(var u=n.fullMessageLength.length-1;u>=0;--u)n.fullMessageLength[u]+=c[1],c[1]=c[0]+(n.fullMessageLength[u]/4294967296>>>0),n.fullMessageLength[u]=n.fullMessageLength[u]>>>0,c[0]=c[1]/4294967296>>>0;return t.putBytes(i),o(e,r,t),(t.read>2048||0===t.length())&&t.compact(),n},n.digest=function(){var s=a.util.createBuffer();s.putBytes(t.bytes());var c,u=n.fullMessageLength[n.fullMessageLength.length-1]+n.messageLengthSize&n.blockLength-1;s.putBytes(i.substr(0,n.blockLength-u));for(var l=8*n.fullMessageLength[0],p=0;p>>0,s.putInt32(l>>>0),l=c>>>0;s.putInt32(l);var f={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4};o(f,r,s);var h=a.util.createBuffer();return h.putInt32(f.h0),h.putInt32(f.h1),h.putInt32(f.h2),h.putInt32(f.h3),h.putInt32(f.h4),h},n};var i=null,s=!1;function o(e,t,r){for(var a,n,i,s,o,c,u,l=r.length();l>=64;){for(n=e.h0,i=e.h1,s=e.h2,o=e.h3,c=e.h4,u=0;u<16;++u)a=r.getInt32(),t[u]=a,a=(n<<5|n>>>27)+(o^i&(s^o))+c+1518500249+a,c=o,o=s,s=(i<<30|i>>>2)>>>0,i=n,n=a;for(;u<20;++u)a=(a=t[u-3]^t[u-8]^t[u-14]^t[u-16])<<1|a>>>31,t[u]=a,a=(n<<5|n>>>27)+(o^i&(s^o))+c+1518500249+a,c=o,o=s,s=(i<<30|i>>>2)>>>0,i=n,n=a;for(;u<32;++u)a=(a=t[u-3]^t[u-8]^t[u-14]^t[u-16])<<1|a>>>31,t[u]=a,a=(n<<5|n>>>27)+(i^s^o)+c+1859775393+a,c=o,o=s,s=(i<<30|i>>>2)>>>0,i=n,n=a;for(;u<40;++u)a=(a=t[u-6]^t[u-16]^t[u-28]^t[u-32])<<2|a>>>30,t[u]=a,a=(n<<5|n>>>27)+(i^s^o)+c+1859775393+a,c=o,o=s,s=(i<<30|i>>>2)>>>0,i=n,n=a;for(;u<60;++u)a=(a=t[u-6]^t[u-16]^t[u-28]^t[u-32])<<2|a>>>30,t[u]=a,a=(n<<5|n>>>27)+(i&s|o&(i^s))+c+2400959708+a,c=o,o=s,s=(i<<30|i>>>2)>>>0,i=n,n=a;for(;u<80;++u)a=(a=t[u-6]^t[u-16]^t[u-28]^t[u-32])<<2|a>>>30,t[u]=a,a=(n<<5|n>>>27)+(i^s^o)+c+3395469782+a,c=o,o=s,s=(i<<30|i>>>2)>>>0,i=n,n=a;e.h0=e.h0+n|0,e.h1=e.h1+i|0,e.h2=e.h2+s|0,e.h3=e.h3+o|0,e.h4=e.h4+c|0,l-=64}}},function(e,t,r){var a=r(0);function n(e,t){a.cipher.registerAlgorithm(e,(function(){return new a.des.Algorithm(e,t)}))}r(13),r(19),r(1),e.exports=a.des=a.des||{},a.des.startEncrypting=function(e,t,r,a){var n=d({key:e,output:r,decrypt:!1,mode:a||(null===t?"ECB":"CBC")});return n.start(t),n},a.des.createEncryptionCipher=function(e,t){return d({key:e,output:null,decrypt:!1,mode:t})},a.des.startDecrypting=function(e,t,r,a){var n=d({key:e,output:r,decrypt:!0,mode:a||(null===t?"ECB":"CBC")});return n.start(t),n},a.des.createDecryptionCipher=function(e,t){return d({key:e,output:null,decrypt:!0,mode:t})},a.des.Algorithm=function(e,t){var r=this;r.name=e,r.mode=new t({blockSize:8,cipher:{encrypt:function(e,t){return h(r._keys,e,t,!1)},decrypt:function(e,t){return h(r._keys,e,t,!0)}}}),r._init=!1},a.des.Algorithm.prototype.initialize=function(e){if(!this._init){var t=a.util.createBuffer(e.key);if(0===this.name.indexOf("3DES")&&24!==t.length())throw new Error("Invalid Triple-DES key size: "+8*t.length());this._keys=function(e){for(var t,r=[0,4,536870912,536870916,65536,65540,536936448,536936452,512,516,536871424,536871428,66048,66052,536936960,536936964],a=[0,1,1048576,1048577,67108864,67108865,68157440,68157441,256,257,1048832,1048833,67109120,67109121,68157696,68157697],n=[0,8,2048,2056,16777216,16777224,16779264,16779272,0,8,2048,2056,16777216,16777224,16779264,16779272],i=[0,2097152,134217728,136314880,8192,2105344,134225920,136323072,131072,2228224,134348800,136445952,139264,2236416,134356992,136454144],s=[0,262144,16,262160,0,262144,16,262160,4096,266240,4112,266256,4096,266240,4112,266256],o=[0,1024,32,1056,0,1024,32,1056,33554432,33555456,33554464,33555488,33554432,33555456,33554464,33555488],c=[0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746],u=[0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032,537069568],l=[0,262144,0,262144,2,262146,2,262146,33554432,33816576,33554432,33816576,33554434,33816578,33554434,33816578],p=[0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488],f=[0,32,0,32,1048576,1048608,1048576,1048608,8192,8224,8192,8224,1056768,1056800,1056768,1056800],h=[0,16777216,512,16777728,2097152,18874368,2097664,18874880,67108864,83886080,67109376,83886592,69206016,85983232,69206528,85983744],d=[0,4096,134217728,134221824,524288,528384,134742016,134746112,16,4112,134217744,134221840,524304,528400,134742032,134746128],y=[0,4,256,260,0,4,256,260,1,5,257,261,1,5,257,261],g=e.length()>8?3:1,m=[],v=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0],C=0,E=0;E>>4^T))<<4,S^=t=65535&((T^=t)>>>-16^S),S^=(t=858993459&(S>>>2^(T^=t<<-16)))<<2,S^=t=65535&((T^=t)>>>-16^S),S^=(t=1431655765&(S>>>1^(T^=t<<-16)))<<1,S^=t=16711935&((T^=t)>>>8^S),t=(S^=(t=1431655765&(S>>>1^(T^=t<<8)))<<1)<<8|(T^=t)>>>20&240,S=T<<24|T<<8&16711680|T>>>8&65280|T>>>24&240,T=t;for(var I=0;I>>26,T=T<<2|T>>>26):(S=S<<1|S>>>27,T=T<<1|T>>>27);var b=r[(S&=-15)>>>28]|a[S>>>24&15]|n[S>>>20&15]|i[S>>>16&15]|s[S>>>12&15]|o[S>>>8&15]|c[S>>>4&15],A=u[(T&=-15)>>>28]|l[T>>>24&15]|p[T>>>20&15]|f[T>>>16&15]|h[T>>>12&15]|d[T>>>8&15]|y[T>>>4&15];t=65535&(A>>>16^b),m[C++]=b^t,m[C++]=A^t<<16}}return m}(t),this._init=!0}},n("DES-ECB",a.cipher.modes.ecb),n("DES-CBC",a.cipher.modes.cbc),n("DES-CFB",a.cipher.modes.cfb),n("DES-OFB",a.cipher.modes.ofb),n("DES-CTR",a.cipher.modes.ctr),n("3DES-ECB",a.cipher.modes.ecb),n("3DES-CBC",a.cipher.modes.cbc),n("3DES-CFB",a.cipher.modes.cfb),n("3DES-OFB",a.cipher.modes.ofb),n("3DES-CTR",a.cipher.modes.ctr);var i=[16843776,0,65536,16843780,16842756,66564,4,65536,1024,16843776,16843780,1024,16778244,16842756,16777216,4,1028,16778240,16778240,66560,66560,16842752,16842752,16778244,65540,16777220,16777220,65540,0,1028,66564,16777216,65536,16843780,4,16842752,16843776,16777216,16777216,1024,16842756,65536,66560,16777220,1024,4,16778244,66564,16843780,65540,16842752,16778244,16777220,1028,66564,16843776,1028,16778240,16778240,0,65540,66560,0,16842756],s=[-2146402272,-2147450880,32768,1081376,1048576,32,-2146435040,-2147450848,-2147483616,-2146402272,-2146402304,-2147483648,-2147450880,1048576,32,-2146435040,1081344,1048608,-2147450848,0,-2147483648,32768,1081376,-2146435072,1048608,-2147483616,0,1081344,32800,-2146402304,-2146435072,32800,0,1081376,-2146435040,1048576,-2147450848,-2146435072,-2146402304,32768,-2146435072,-2147450880,32,-2146402272,1081376,32,32768,-2147483648,32800,-2146402304,1048576,-2147483616,1048608,-2147450848,-2147483616,1048608,1081344,0,-2147450880,32800,-2147483648,-2146435040,-2146402272,1081344],o=[520,134349312,0,134348808,134218240,0,131592,134218240,131080,134217736,134217736,131072,134349320,131080,134348800,520,134217728,8,134349312,512,131584,134348800,134348808,131592,134218248,131584,131072,134218248,8,134349320,512,134217728,134349312,134217728,131080,520,131072,134349312,134218240,0,512,131080,134349320,134218240,134217736,512,0,134348808,134218248,131072,134217728,134349320,8,131592,131584,134217736,134348800,134218248,520,134348800,131592,8,134348808,131584],c=[8396801,8321,8321,128,8396928,8388737,8388609,8193,0,8396800,8396800,8396929,129,0,8388736,8388609,1,8192,8388608,8396801,128,8388608,8193,8320,8388737,1,8320,8388736,8192,8396928,8396929,129,8388736,8388609,8396800,8396929,129,0,0,8396800,8320,8388736,8388737,1,8396801,8321,8321,128,8396929,129,1,8192,8388609,8193,8396928,8388737,8193,8320,8388608,8396801,128,8388608,8192,8396928],u=[256,34078976,34078720,1107296512,524288,256,1073741824,34078720,1074266368,524288,33554688,1074266368,1107296512,1107820544,524544,1073741824,33554432,1074266112,1074266112,0,1073742080,1107820800,1107820800,33554688,1107820544,1073742080,0,1107296256,34078976,33554432,1107296256,524544,524288,1107296512,256,33554432,1073741824,34078720,1107296512,1074266368,33554688,1073741824,1107820544,34078976,1074266368,256,33554432,1107820544,1107820800,524544,1107296256,1107820800,34078720,0,1074266112,1107296256,524544,33554688,1073742080,524288,0,1074266112,34078976,1073742080],l=[536870928,541065216,16384,541081616,541065216,16,541081616,4194304,536887296,4210704,4194304,536870928,4194320,536887296,536870912,16400,0,4194320,536887312,16384,4210688,536887312,16,541065232,541065232,0,4210704,541081600,16400,4210688,541081600,536870912,536887296,16,541065232,4210688,541081616,4194304,16400,536870928,4194304,536887296,536870912,16400,536870928,541081616,4210688,541065216,4210704,541081600,0,541065232,16,16384,541065216,4210704,16384,4194320,536887312,0,541081600,536870912,4194320,536887312],p=[2097152,69206018,67110914,0,2048,67110914,2099202,69208064,69208066,2097152,0,67108866,2,67108864,69206018,2050,67110912,2099202,2097154,67110912,67108866,69206016,69208064,2097154,69206016,2048,2050,69208066,2099200,2,67108864,2099200,67108864,2099200,2097152,67110914,67110914,69206018,69206018,2,2097154,67108864,67110912,2097152,69208064,2050,2099202,69208064,2050,67108866,69208066,69206016,2099200,0,2,69208066,0,2099202,69206016,2048,67108866,67110912,2048,2097154],f=[268439616,4096,262144,268701760,268435456,268439616,64,268435456,262208,268697600,268701760,266240,268701696,266304,4096,64,268697600,268435520,268439552,4160,266240,262208,268697664,268701696,4160,0,0,268697664,268435520,268439552,266304,262144,266304,262144,268701696,4096,64,268697664,4096,266304,268439552,64,268435520,268697600,268697664,268435456,262144,268439616,0,268701760,262208,268435520,268697600,268439552,268439616,0,268701760,266240,266240,4160,4160,262208,268435456,268701696];function h(e,t,r,a){var n,h,d=32===e.length?3:9;n=3===d?a?[30,-2,-2]:[0,32,2]:a?[94,62,-2,32,64,2,30,-2,-2]:[0,32,2,62,30,-2,64,96,2];var y=t[0],g=t[1];y^=(h=252645135&(y>>>4^g))<<4,y^=(h=65535&(y>>>16^(g^=h)))<<16,y^=h=858993459&((g^=h)>>>2^y),y^=h=16711935&((g^=h<<2)>>>8^y),y=(y^=(h=1431655765&(y>>>1^(g^=h<<8)))<<1)<<1|y>>>31,g=(g^=h)<<1|g>>>31;for(var m=0;m>>4|g<<28)^e[E+1];h=y,y=g,g=h^(s[S>>>24&63]|c[S>>>16&63]|l[S>>>8&63]|f[63&S]|i[T>>>24&63]|o[T>>>16&63]|u[T>>>8&63]|p[63&T])}h=y,y=g,g=h}g=g>>>1|g<<31,g^=h=1431655765&((y=y>>>1|y<<31)>>>1^g),g^=(h=16711935&(g>>>8^(y^=h<<1)))<<8,g^=(h=858993459&(g>>>2^(y^=h)))<<2,g^=h=65535&((y^=h)>>>16^g),g^=h=252645135&((y^=h<<16)>>>4^g),y^=h<<4,r[0]=y,r[1]=g}function d(e){var t,r="DES-"+((e=e||{}).mode||"CBC").toUpperCase(),n=(t=e.decrypt?a.cipher.createDecipher(r,e.key):a.cipher.createCipher(r,e.key)).start;return t.start=function(e,r){var i=null;r instanceof a.util.ByteBuffer&&(i=r,r={}),(r=r||{}).output=i,r.iv=e,n.call(t,r)},t}},function(e,t,r){var a=r(0);if(r(3),r(12),r(6),r(26),r(27),r(2),r(1),void 0===n)var n=a.jsbn.BigInteger;var i=a.util.isNodejs?r(16):null,s=a.asn1,o=a.util;a.pki=a.pki||{},e.exports=a.pki.rsa=a.rsa=a.rsa||{};var c=a.pki,u=[6,4,2,4,2,4,6,2],l={name:"PrivateKeyInfo",tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:s.Class.UNIVERSAL,type:s.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:s.Class.UNIVERSAL,type:s.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},p={name:"RSAPrivateKey",tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPrivateKey.version",tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"RSAPrivateKey.modulus",tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,capture:"privateKeyModulus"},{name:"RSAPrivateKey.publicExponent",tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,capture:"privateKeyPublicExponent"},{name:"RSAPrivateKey.privateExponent",tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,capture:"privateKeyPrivateExponent"},{name:"RSAPrivateKey.prime1",tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,capture:"privateKeyPrime1"},{name:"RSAPrivateKey.prime2",tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,capture:"privateKeyPrime2"},{name:"RSAPrivateKey.exponent1",tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,capture:"privateKeyExponent1"},{name:"RSAPrivateKey.exponent2",tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,capture:"privateKeyExponent2"},{name:"RSAPrivateKey.coefficient",tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,capture:"privateKeyCoefficient"}]},f={name:"RSAPublicKey",tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPublicKey.modulus",tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,capture:"publicKeyModulus"},{name:"RSAPublicKey.exponent",tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,capture:"publicKeyExponent"}]},h=a.pki.rsa.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:s.Class.UNIVERSAL,type:s.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{name:"SubjectPublicKeyInfo.subjectPublicKey",tagClass:s.Class.UNIVERSAL,type:s.Type.BITSTRING,constructed:!1,value:[{name:"SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey",tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"rsaPublicKey"}]}]},d=function(e){var t;if(!(e.algorithm in c.oids)){var r=new Error("Unknown message digest algorithm.");throw r.algorithm=e.algorithm,r}t=c.oids[e.algorithm];var a=s.oidToDer(t).getBytes(),n=s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[]),i=s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[]);i.value.push(s.create(s.Class.UNIVERSAL,s.Type.OID,!1,a)),i.value.push(s.create(s.Class.UNIVERSAL,s.Type.NULL,!1,""));var o=s.create(s.Class.UNIVERSAL,s.Type.OCTETSTRING,!1,e.digest().getBytes());return n.value.push(i),n.value.push(o),s.toDer(n).getBytes()},y=function(e,t,r){if(r)return e.modPow(t.e,t.n);if(!t.p||!t.q)return e.modPow(t.d,t.n);var i;t.dP||(t.dP=t.d.mod(t.p.subtract(n.ONE))),t.dQ||(t.dQ=t.d.mod(t.q.subtract(n.ONE))),t.qInv||(t.qInv=t.q.modInverse(t.p));do{i=new n(a.util.bytesToHex(a.random.getBytes(t.n.bitLength()/8)),16)}while(i.compareTo(t.n)>=0||!i.gcd(t.n).equals(n.ONE));for(var s=(e=e.multiply(i.modPow(t.e,t.n)).mod(t.n)).mod(t.p).modPow(t.dP,t.p),o=e.mod(t.q).modPow(t.dQ,t.q);s.compareTo(o)<0;)s=s.add(t.p);var c=s.subtract(o).multiply(t.qInv).mod(t.p).multiply(t.q).add(o);return c=c.multiply(i.modInverse(t.n)).mod(t.n)};function g(e,t,r){var n=a.util.createBuffer(),i=Math.ceil(t.n.bitLength()/8);if(e.length>i-11){var s=new Error("Message is too long for PKCS#1 v1.5 padding.");throw s.length=e.length,s.max=i-11,s}n.putByte(0),n.putByte(r);var o,c=i-3-e.length;if(0===r||1===r){o=0===r?0:255;for(var u=0;u0;){var l=0,p=a.random.getBytes(c);for(u=0;u1;){if(255!==s.getByte()){--s.read;break}++u}else if(2===c)for(u=0;s.length()>1;){if(0===s.getByte()){--s.read;break}++u}if(0!==s.getByte()||u!==i-3-s.length())throw new Error("Encryption block is invalid.");return s.getBytes()}function v(e,t,r){"function"==typeof t&&(r=t,t={});var i={algorithm:{name:(t=t||{}).algorithm||"PRIMEINC",options:{workers:t.workers||2,workLoad:t.workLoad||100,workerScript:t.workerScript}}};function s(){o(e.pBits,(function(t,a){return t?r(t):(e.p=a,null!==e.q?u(t,e.q):void o(e.qBits,u))}))}function o(e,t){a.prime.generateProbablePrime(e,i,t)}function u(t,a){if(t)return r(t);if(e.q=a,e.p.compareTo(e.q)<0){var i=e.p;e.p=e.q,e.q=i}if(0!==e.p.subtract(n.ONE).gcd(e.e).compareTo(n.ONE))return e.p=null,void s();if(0!==e.q.subtract(n.ONE).gcd(e.e).compareTo(n.ONE))return e.q=null,void o(e.qBits,u);if(e.p1=e.p.subtract(n.ONE),e.q1=e.q.subtract(n.ONE),e.phi=e.p1.multiply(e.q1),0!==e.phi.gcd(e.e).compareTo(n.ONE))return e.p=e.q=null,void s();if(e.n=e.p.multiply(e.q),e.n.bitLength()!==e.bits)return e.q=null,void o(e.qBits,u);var l=e.e.modInverse(e.phi);e.keys={privateKey:c.rsa.setPrivateKey(e.n,e.e,l,e.p,e.q,l.mod(e.p1),l.mod(e.q1),e.q.modInverse(e.p)),publicKey:c.rsa.setPublicKey(e.n,e.e)},r(null,e.keys)}"prng"in t&&(i.prng=t.prng),s()}function C(e){var t=e.toString(16);t[0]>="8"&&(t="00"+t);var r=a.util.hexToBytes(t);return r.length>1&&(0===r.charCodeAt(0)&&0==(128&r.charCodeAt(1))||255===r.charCodeAt(0)&&128==(128&r.charCodeAt(1)))?r.substr(1):r}function E(e){return e<=100?27:e<=150?18:e<=200?15:e<=250?12:e<=300?9:e<=350?8:e<=400?7:e<=500?6:e<=600?5:e<=800?4:e<=1250?3:2}function S(e){return a.util.isNodejs&&"function"==typeof i[e]}function T(e){return void 0!==o.globalScope&&"object"==typeof o.globalScope.crypto&&"object"==typeof o.globalScope.crypto.subtle&&"function"==typeof o.globalScope.crypto.subtle[e]}function I(e){return void 0!==o.globalScope&&"object"==typeof o.globalScope.msCrypto&&"object"==typeof o.globalScope.msCrypto.subtle&&"function"==typeof o.globalScope.msCrypto.subtle[e]}function b(e){for(var t=a.util.hexToBytes(e.toString(16)),r=new Uint8Array(t.length),n=0;n0;)l.putByte(0),--p;return l.putBytes(a.util.hexToBytes(u)),l.getBytes()},c.rsa.decrypt=function(e,t,r,i){var s=Math.ceil(t.n.bitLength()/8);if(e.length!==s){var o=new Error("Encrypted message length is invalid.");throw o.length=e.length,o.expected=s,o}var c=new n(a.util.createBuffer(e).toHex(),16);if(c.compareTo(t.n)>=0)throw new Error("Encrypted message is invalid.");for(var u=y(c,t,r).toString(16),l=a.util.createBuffer(),p=s-Math.ceil(u.length/2);p>0;)l.putByte(0),--p;return l.putBytes(a.util.hexToBytes(u)),!1!==i?m(l.getBytes(),t,r):l.getBytes()},c.rsa.createKeyPairGenerationState=function(e,t,r){"string"==typeof e&&(e=parseInt(e,10)),e=e||2048;var i,s=(r=r||{}).prng||a.random,o={nextBytes:function(e){for(var t=s.getBytesSync(e.length),r=0;r>1,pBits:e-(e>>1),pqState:0,num:null,keys:null}).e.fromInt(i.eInt),i},c.rsa.stepKeyPairGenerationState=function(e,t){"algorithm"in e||(e.algorithm="PRIMEINC");var r=new n(null);r.fromInt(30);for(var a,i=0,s=function(e,t){return e|t},o=+new Date,l=0;null===e.keys&&(t<=0||lp?e.pqState=0:e.num.isProbablePrime(E(e.num.bitLength()))?++e.pqState:e.num.dAddOffset(u[i++%8],0):2===e.pqState?e.pqState=0===e.num.subtract(n.ONE).gcd(e.e).compareTo(n.ONE)?3:0:3===e.pqState&&(e.pqState=0,null===e.p?e.p=e.num:e.q=e.num,null!==e.p&&null!==e.q&&++e.state,e.num=null)}else if(1===e.state)e.p.compareTo(e.q)<0&&(e.num=e.p,e.p=e.q,e.q=e.num),++e.state;else if(2===e.state)e.p1=e.p.subtract(n.ONE),e.q1=e.q.subtract(n.ONE),e.phi=e.p1.multiply(e.q1),++e.state;else if(3===e.state)0===e.phi.gcd(e.e).compareTo(n.ONE)?++e.state:(e.p=null,e.q=null,e.state=0);else if(4===e.state)e.n=e.p.multiply(e.q),e.n.bitLength()===e.bits?++e.state:(e.q=null,e.state=0);else if(5===e.state){var h=e.e.modInverse(e.phi);e.keys={privateKey:c.rsa.setPrivateKey(e.n,e.e,h,e.p,e.q,h.mod(e.p1),h.mod(e.q1),e.q.modInverse(e.p)),publicKey:c.rsa.setPublicKey(e.n,e.e)}}l+=(a=+new Date)-o,o=a}return null!==e.keys},c.rsa.generateKeyPair=function(e,t,r,n){if(1===arguments.length?"object"==typeof e?(r=e,e=void 0):"function"==typeof e&&(n=e,e=void 0):2===arguments.length?"number"==typeof e?"function"==typeof t?(n=t,t=void 0):"number"!=typeof t&&(r=t,t=void 0):(r=e,n=t,e=void 0,t=void 0):3===arguments.length&&("number"==typeof t?"function"==typeof r&&(n=r,r=void 0):(n=r,r=t,t=void 0)),r=r||{},void 0===e&&(e=r.bits||2048),void 0===t&&(t=r.e||65537),!a.options.usePureJavaScript&&!r.prng&&e>=256&&e<=16384&&(65537===t||3===t))if(n){if(S("generateKeyPair"))return i.generateKeyPair("rsa",{modulusLength:e,publicExponent:t,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}},(function(e,t,r){if(e)return n(e);n(null,{privateKey:c.privateKeyFromPem(r),publicKey:c.publicKeyFromPem(t)})}));if(T("generateKey")&&T("exportKey"))return o.globalScope.crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:b(t),hash:{name:"SHA-256"}},!0,["sign","verify"]).then((function(e){return o.globalScope.crypto.subtle.exportKey("pkcs8",e.privateKey)})).then(void 0,(function(e){n(e)})).then((function(e){if(e){var t=c.privateKeyFromAsn1(s.fromDer(a.util.createBuffer(e)));n(null,{privateKey:t,publicKey:c.setRsaPublicKey(t.n,t.e)})}}));if(I("generateKey")&&I("exportKey")){var u=o.globalScope.msCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:b(t),hash:{name:"SHA-256"}},!0,["sign","verify"]);return u.oncomplete=function(e){var t=e.target.result,r=o.globalScope.msCrypto.subtle.exportKey("pkcs8",t.privateKey);r.oncomplete=function(e){var t=e.target.result,r=c.privateKeyFromAsn1(s.fromDer(a.util.createBuffer(t)));n(null,{privateKey:r,publicKey:c.setRsaPublicKey(r.n,r.e)})},r.onerror=function(e){n(e)}},void(u.onerror=function(e){n(e)})}}else if(S("generateKeyPairSync")){var l=i.generateKeyPairSync("rsa",{modulusLength:e,publicExponent:t,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{privateKey:c.privateKeyFromPem(l.privateKey),publicKey:c.publicKeyFromPem(l.publicKey)}}var p=c.rsa.createKeyPairGenerationState(e,t,r);if(!n)return c.rsa.stepKeyPairGenerationState(p,0),p.keys;v(p,r,n)},c.setRsaPublicKey=c.rsa.setPublicKey=function(e,t){var r={n:e,e:t,encrypt:function(e,t,n){if("string"==typeof t?t=t.toUpperCase():void 0===t&&(t="RSAES-PKCS1-V1_5"),"RSAES-PKCS1-V1_5"===t)t={encode:function(e,t,r){return g(e,t,2).getBytes()}};else if("RSA-OAEP"===t||"RSAES-OAEP"===t)t={encode:function(e,t){return a.pkcs1.encode_rsa_oaep(t,e,n)}};else if(-1!==["RAW","NONE","NULL",null].indexOf(t))t={encode:function(e){return e}};else if("string"==typeof t)throw new Error('Unsupported encryption scheme: "'+t+'".');var i=t.encode(e,r,!0);return c.rsa.encrypt(i,r,!0)},verify:function(e,t,a){"string"==typeof a?a=a.toUpperCase():void 0===a&&(a="RSASSA-PKCS1-V1_5"),"RSASSA-PKCS1-V1_5"===a?a={verify:function(e,t){return t=m(t,r,!0),e===s.fromDer(t).value[1].value}}:"NONE"!==a&&"NULL"!==a&&null!==a||(a={verify:function(e,t){return e===(t=m(t,r,!0))}});var n=c.rsa.decrypt(t,r,!0,!1);return a.verify(e,n,r.n.bitLength())}};return r},c.setRsaPrivateKey=c.rsa.setPrivateKey=function(e,t,r,n,i,s,o,u){var l={n:e,e:t,d:r,p:n,q:i,dP:s,dQ:o,qInv:u,decrypt:function(e,t,r){"string"==typeof t?t=t.toUpperCase():void 0===t&&(t="RSAES-PKCS1-V1_5");var n=c.rsa.decrypt(e,l,!1,!1);if("RSAES-PKCS1-V1_5"===t)t={decode:m};else if("RSA-OAEP"===t||"RSAES-OAEP"===t)t={decode:function(e,t){return a.pkcs1.decode_rsa_oaep(t,e,r)}};else{if(-1===["RAW","NONE","NULL",null].indexOf(t))throw new Error('Unsupported encryption scheme: "'+t+'".');t={decode:function(e){return e}}}return t.decode(n,l,!1)},sign:function(e,t){var r=!1;"string"==typeof t&&(t=t.toUpperCase()),void 0===t||"RSASSA-PKCS1-V1_5"===t?(t={encode:d},r=1):"NONE"!==t&&"NULL"!==t&&null!==t||(t={encode:function(){return e}},r=1);var a=t.encode(e,l.n.bitLength());return c.rsa.encrypt(a,l,r)}};return l},c.wrapRsaPrivateKey=function(e){return s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,s.integerToDer(0).getBytes()),s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.OID,!1,s.oidToDer(c.oids.rsaEncryption).getBytes()),s.create(s.Class.UNIVERSAL,s.Type.NULL,!1,"")]),s.create(s.Class.UNIVERSAL,s.Type.OCTETSTRING,!1,s.toDer(e).getBytes())])},c.privateKeyFromAsn1=function(e){var t,r,i,o,u,f,h,d,y={},g=[];if(s.validate(e,l,y,g)&&(e=s.fromDer(a.util.createBuffer(y.privateKey))),y={},g=[],!s.validate(e,p,y,g)){var m=new Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.");throw m.errors=g,m}return t=a.util.createBuffer(y.privateKeyModulus).toHex(),r=a.util.createBuffer(y.privateKeyPublicExponent).toHex(),i=a.util.createBuffer(y.privateKeyPrivateExponent).toHex(),o=a.util.createBuffer(y.privateKeyPrime1).toHex(),u=a.util.createBuffer(y.privateKeyPrime2).toHex(),f=a.util.createBuffer(y.privateKeyExponent1).toHex(),h=a.util.createBuffer(y.privateKeyExponent2).toHex(),d=a.util.createBuffer(y.privateKeyCoefficient).toHex(),c.setRsaPrivateKey(new n(t,16),new n(r,16),new n(i,16),new n(o,16),new n(u,16),new n(f,16),new n(h,16),new n(d,16))},c.privateKeyToAsn1=c.privateKeyToRSAPrivateKey=function(e){return s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,s.integerToDer(0).getBytes()),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,C(e.n)),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,C(e.e)),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,C(e.d)),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,C(e.p)),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,C(e.q)),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,C(e.dP)),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,C(e.dQ)),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,C(e.qInv))])},c.publicKeyFromAsn1=function(e){var t={},r=[];if(s.validate(e,h,t,r)){var i,o=s.derToOid(t.publicKeyOid);if(o!==c.oids.rsaEncryption)throw(i=new Error("Cannot read public key. Unknown OID.")).oid=o,i;e=t.rsaPublicKey}if(r=[],!s.validate(e,f,t,r))throw(i=new Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey.")).errors=r,i;var u=a.util.createBuffer(t.publicKeyModulus).toHex(),l=a.util.createBuffer(t.publicKeyExponent).toHex();return c.setRsaPublicKey(new n(u,16),new n(l,16))},c.publicKeyToAsn1=c.publicKeyToSubjectPublicKeyInfo=function(e){return s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.OID,!1,s.oidToDer(c.oids.rsaEncryption).getBytes()),s.create(s.Class.UNIVERSAL,s.Type.NULL,!1,"")]),s.create(s.Class.UNIVERSAL,s.Type.BITSTRING,!1,[c.publicKeyToRSAPublicKey(e)])])},c.publicKeyToRSAPublicKey=function(e){return s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,C(e.n)),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,C(e.e))])}},function(e,t,r){var a,n=r(0);e.exports=n.jsbn=n.jsbn||{};function i(e,t,r){this.data=[],null!=e&&("number"==typeof e?this.fromNumber(e,t,r):null==t&&"string"!=typeof e?this.fromString(e,256):this.fromString(e,t))}function s(){return new i(null)}function o(e,t,r,a,n,i){for(var s=16383&t,o=t>>14;--i>=0;){var c=16383&this.data[e],u=this.data[e++]>>14,l=o*c+u*s;n=((c=s*c+((16383&l)<<14)+r.data[a]+n)>>28)+(l>>14)+o*u,r.data[a++]=268435455&c}return n}n.jsbn.BigInteger=i,"undefined"==typeof navigator?(i.prototype.am=o,a=28):"Microsoft Internet Explorer"==navigator.appName?(i.prototype.am=function(e,t,r,a,n,i){for(var s=32767&t,o=t>>15;--i>=0;){var c=32767&this.data[e],u=this.data[e++]>>15,l=o*c+u*s;n=((c=s*c+((32767&l)<<15)+r.data[a]+(1073741823&n))>>>30)+(l>>>15)+o*u+(n>>>30),r.data[a++]=1073741823&c}return n},a=30):"Netscape"!=navigator.appName?(i.prototype.am=function(e,t,r,a,n,i){for(;--i>=0;){var s=t*this.data[e++]+r.data[a]+n;n=Math.floor(s/67108864),r.data[a++]=67108863&s}return n},a=26):(i.prototype.am=o,a=28),i.prototype.DB=a,i.prototype.DM=(1<>>16)&&(e=t,r+=16),0!=(t=e>>8)&&(e=t,r+=8),0!=(t=e>>4)&&(e=t,r+=4),0!=(t=e>>2)&&(e=t,r+=2),0!=(t=e>>1)&&(e=t,r+=1),r}function y(e){this.m=e}function g(e){this.m=e,this.mp=e.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=16,t+=16),0==(255&e)&&(e>>=8,t+=8),0==(15&e)&&(e>>=4,t+=4),0==(3&e)&&(e>>=2,t+=2),0==(1&e)&&++t,t}function T(e){for(var t=0;0!=e;)e&=e-1,++t;return t}function I(){}function b(e){return e}function A(e){this.r2=s(),this.q3=s(),i.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e),this.m=e}y.prototype.convert=function(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e},y.prototype.revert=function(e){return e},y.prototype.reduce=function(e){e.divRemTo(this.m,null,e)},y.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},y.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},g.prototype.convert=function(e){var t=s();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(i.ZERO)>0&&this.m.subTo(t,t),t},g.prototype.revert=function(e){var t=s();return e.copyTo(t),this.reduce(t),t},g.prototype.reduce=function(e){for(;e.t<=this.mt2;)e.data[e.t++]=0;for(var t=0;t>15)*this.mpl&this.um)<<15)&e.DM;for(r=t+this.m.t,e.data[r]+=this.m.am(0,a,e,t,0,this.m.t);e.data[r]>=e.DV;)e.data[r]-=e.DV,e.data[++r]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)},g.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},g.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},i.prototype.copyTo=function(e){for(var t=this.t-1;t>=0;--t)e.data[t]=this.data[t];e.t=this.t,e.s=this.s},i.prototype.fromInt=function(e){this.t=1,this.s=e<0?-1:0,e>0?this.data[0]=e:e<-1?this.data[0]=e+this.DV:this.t=0},i.prototype.fromString=function(e,t){var r;if(16==t)r=4;else if(8==t)r=3;else if(256==t)r=8;else if(2==t)r=1;else if(32==t)r=5;else{if(4!=t)return void this.fromRadix(e,t);r=2}this.t=0,this.s=0;for(var a=e.length,n=!1,s=0;--a>=0;){var o=8==r?255&e[a]:f(e,a);o<0?"-"==e.charAt(a)&&(n=!0):(n=!1,0==s?this.data[this.t++]=o:s+r>this.DB?(this.data[this.t-1]|=(o&(1<>this.DB-s):this.data[this.t-1]|=o<=this.DB&&(s-=this.DB))}8==r&&0!=(128&e[0])&&(this.s=-1,s>0&&(this.data[this.t-1]|=(1<0&&this.data[this.t-1]==e;)--this.t},i.prototype.dlShiftTo=function(e,t){var r;for(r=this.t-1;r>=0;--r)t.data[r+e]=this.data[r];for(r=e-1;r>=0;--r)t.data[r]=0;t.t=this.t+e,t.s=this.s},i.prototype.drShiftTo=function(e,t){for(var r=e;r=0;--r)t.data[r+s+1]=this.data[r]>>n|o,o=(this.data[r]&i)<=0;--r)t.data[r]=0;t.data[s]=o,t.t=this.t+s+1,t.s=this.s,t.clamp()},i.prototype.rShiftTo=function(e,t){t.s=this.s;var r=Math.floor(e/this.DB);if(r>=this.t)t.t=0;else{var a=e%this.DB,n=this.DB-a,i=(1<>a;for(var s=r+1;s>a;a>0&&(t.data[this.t-r-1]|=(this.s&i)<>=this.DB;if(e.t>=this.DB;a+=this.s}else{for(a+=this.s;r>=this.DB;a-=e.s}t.s=a<0?-1:0,a<-1?t.data[r++]=this.DV+a:a>0&&(t.data[r++]=a),t.t=r,t.clamp()},i.prototype.multiplyTo=function(e,t){var r=this.abs(),a=e.abs(),n=r.t;for(t.t=n+a.t;--n>=0;)t.data[n]=0;for(n=0;n=0;)e.data[r]=0;for(r=0;r=t.DV&&(e.data[r+t.t]-=t.DV,e.data[r+t.t+1]=1)}e.t>0&&(e.data[e.t-1]+=t.am(r,t.data[r],e,2*r,0,1)),e.s=0,e.clamp()},i.prototype.divRemTo=function(e,t,r){var a=e.abs();if(!(a.t<=0)){var n=this.abs();if(n.t0?(a.lShiftTo(l,o),n.lShiftTo(l,r)):(a.copyTo(o),n.copyTo(r));var p=o.t,f=o.data[p-1];if(0!=f){var h=f*(1<1?o.data[p-2]>>this.F2:0),y=this.FV/h,g=(1<=0&&(r.data[r.t++]=1,r.subTo(E,r)),i.ONE.dlShiftTo(p,E),E.subTo(o,o);o.t=0;){var S=r.data[--v]==f?this.DM:Math.floor(r.data[v]*y+(r.data[v-1]+m)*g);if((r.data[v]+=o.am(0,S,r,C,0,p))0&&r.rShiftTo(l,r),c<0&&i.ZERO.subTo(r,r)}}},i.prototype.invDigit=function(){if(this.t<1)return 0;var e=this.data[0];if(0==(1&e))return 0;var t=3&e;return(t=(t=(t=(t=t*(2-(15&e)*t)&15)*(2-(255&e)*t)&255)*(2-((65535&e)*t&65535))&65535)*(2-e*t%this.DV)%this.DV)>0?this.DV-t:-t},i.prototype.isEven=function(){return 0==(this.t>0?1&this.data[0]:this.s)},i.prototype.exp=function(e,t){if(e>4294967295||e<1)return i.ONE;var r=s(),a=s(),n=t.convert(this),o=d(e)-1;for(n.copyTo(r);--o>=0;)if(t.sqrTo(r,a),(e&1<0)t.mulTo(a,n,r);else{var c=r;r=a,a=c}return t.revert(r)},i.prototype.toString=function(e){if(this.s<0)return"-"+this.negate().toString(e);var t;if(16==e)t=4;else if(8==e)t=3;else if(2==e)t=1;else if(32==e)t=5;else{if(4!=e)return this.toRadix(e);t=2}var r,a=(1<0)for(o>o)>0&&(n=!0,i=p(r));s>=0;)o>(o+=this.DB-t)):(r=this.data[s]>>(o-=t)&a,o<=0&&(o+=this.DB,--s)),r>0&&(n=!0),n&&(i+=p(r));return n?i:"0"},i.prototype.negate=function(){var e=s();return i.ZERO.subTo(this,e),e},i.prototype.abs=function(){return this.s<0?this.negate():this},i.prototype.compareTo=function(e){var t=this.s-e.s;if(0!=t)return t;var r=this.t;if(0!=(t=r-e.t))return this.s<0?-t:t;for(;--r>=0;)if(0!=(t=this.data[r]-e.data[r]))return t;return 0},i.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+d(this.data[this.t-1]^this.s&this.DM)},i.prototype.mod=function(e){var t=s();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(i.ZERO)>0&&e.subTo(t,t),t},i.prototype.modPowInt=function(e,t){var r;return r=e<256||t.isEven()?new y(t):new g(t),this.exp(e,r)},i.ZERO=h(0),i.ONE=h(1),I.prototype.convert=b,I.prototype.revert=b,I.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r)},I.prototype.sqrTo=function(e,t){e.squareTo(t)},A.prototype.convert=function(e){if(e.s<0||e.t>2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var t=s();return e.copyTo(t),this.reduce(t),t},A.prototype.revert=function(e){return e},A.prototype.reduce=function(e){for(e.drShiftTo(this.m.t-1,this.r2),e.t>this.m.t+1&&(e.t=this.m.t+1,e.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);e.compareTo(this.r2)<0;)e.dAddOffset(1,this.m.t+1);for(e.subTo(this.r2,e);e.compareTo(this.m)>=0;)e.subTo(this.m,e)},A.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},A.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)};var B=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509],N=(1<<26)/B[B.length-1];i.prototype.chunkSize=function(e){return Math.floor(Math.LN2*this.DB/Math.log(e))},i.prototype.toRadix=function(e){if(null==e&&(e=10),0==this.signum()||e<2||e>36)return"0";var t=this.chunkSize(e),r=Math.pow(e,t),a=h(r),n=s(),i=s(),o="";for(this.divRemTo(a,n,i);n.signum()>0;)o=(r+i.intValue()).toString(e).substr(1)+o,n.divRemTo(a,n,i);return i.intValue().toString(e)+o},i.prototype.fromRadix=function(e,t){this.fromInt(0),null==t&&(t=10);for(var r=this.chunkSize(t),a=Math.pow(t,r),n=!1,s=0,o=0,c=0;c=r&&(this.dMultiply(a),this.dAddOffset(o,0),s=0,o=0))}s>0&&(this.dMultiply(Math.pow(t,s)),this.dAddOffset(o,0)),n&&i.ZERO.subTo(this,this)},i.prototype.fromNumber=function(e,t,r){if("number"==typeof t)if(e<2)this.fromInt(1);else for(this.fromNumber(e,r),this.testBit(e-1)||this.bitwiseTo(i.ONE.shiftLeft(e-1),v,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(i.ONE.shiftLeft(e-1),this);else{var a=new Array,n=7&e;a.length=1+(e>>3),t.nextBytes(a),n>0?a[0]&=(1<>=this.DB;if(e.t>=this.DB;a+=this.s}else{for(a+=this.s;r>=this.DB;a+=e.s}t.s=a<0?-1:0,a>0?t.data[r++]=a:a<-1&&(t.data[r++]=this.DV+a),t.t=r,t.clamp()},i.prototype.dMultiply=function(e){this.data[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()},i.prototype.dAddOffset=function(e,t){if(0!=e){for(;this.t<=t;)this.data[this.t++]=0;for(this.data[t]+=e;this.data[t]>=this.DV;)this.data[t]-=this.DV,++t>=this.t&&(this.data[this.t++]=0),++this.data[t]}},i.prototype.multiplyLowerTo=function(e,t,r){var a,n=Math.min(this.t+e.t,t);for(r.s=0,r.t=n;n>0;)r.data[--n]=0;for(a=r.t-this.t;n=0;)r.data[a]=0;for(a=Math.max(t-this.t,0);a0)if(0==t)r=this.data[0]%e;else for(var a=this.t-1;a>=0;--a)r=(t*r+this.data[a])%e;return r},i.prototype.millerRabin=function(e){var t=this.subtract(i.ONE),r=t.getLowestSetBit();if(r<=0)return!1;for(var a,n=t.shiftRight(r),s={nextBytes:function(e){for(var t=0;t=0);var c=a.modPow(n,this);if(0!=c.compareTo(i.ONE)&&0!=c.compareTo(t)){for(var u=1;u++>24},i.prototype.shortValue=function(){return 0==this.t?this.s:this.data[0]<<16>>16},i.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this.data[0]<=0?0:1},i.prototype.toByteArray=function(){var e=this.t,t=new Array;t[0]=this.s;var r,a=this.DB-e*this.DB%8,n=0;if(e-- >0)for(a>a)!=(this.s&this.DM)>>a&&(t[n++]=r|this.s<=0;)a<8?(r=(this.data[e]&(1<>(a+=this.DB-8)):(r=this.data[e]>>(a-=8)&255,a<=0&&(a+=this.DB,--e)),0!=(128&r)&&(r|=-256),0==n&&(128&this.s)!=(128&r)&&++n,(n>0||r!=this.s)&&(t[n++]=r);return t},i.prototype.equals=function(e){return 0==this.compareTo(e)},i.prototype.min=function(e){return this.compareTo(e)<0?this:e},i.prototype.max=function(e){return this.compareTo(e)>0?this:e},i.prototype.and=function(e){var t=s();return this.bitwiseTo(e,m,t),t},i.prototype.or=function(e){var t=s();return this.bitwiseTo(e,v,t),t},i.prototype.xor=function(e){var t=s();return this.bitwiseTo(e,C,t),t},i.prototype.andNot=function(e){var t=s();return this.bitwiseTo(e,E,t),t},i.prototype.not=function(){for(var e=s(),t=0;t=this.t?0!=this.s:0!=(this.data[t]&1<1){var p=s();for(a.sqrTo(o[1],p);c<=l;)o[c]=s(),a.mulTo(p,o[c-2],o[c]),c+=2}var f,m,v=e.t-1,C=!0,E=s();for(n=d(e.data[v])-1;v>=0;){for(n>=u?f=e.data[v]>>n-u&l:(f=(e.data[v]&(1<0&&(f|=e.data[v-1]>>this.DB+n-u)),c=r;0==(1&f);)f>>=1,--c;if((n-=c)<0&&(n+=this.DB,--v),C)o[f].copyTo(i),C=!1;else{for(;c>1;)a.sqrTo(i,E),a.sqrTo(E,i),c-=2;c>0?a.sqrTo(i,E):(m=i,i=E,E=m),a.mulTo(E,o[f],i)}for(;v>=0&&0==(e.data[v]&1<=0?(r.subTo(a,r),t&&n.subTo(o,n),s.subTo(c,s)):(a.subTo(r,a),t&&o.subTo(n,o),c.subTo(s,c))}return 0!=a.compareTo(i.ONE)?i.ZERO:c.compareTo(e)>=0?c.subtract(e):c.signum()<0?(c.addTo(e,c),c.signum()<0?c.add(e):c):c},i.prototype.pow=function(e){return this.exp(e,new I)},i.prototype.gcd=function(e){var t=this.s<0?this.negate():this.clone(),r=e.s<0?e.negate():e.clone();if(t.compareTo(r)<0){var a=t;t=r,r=a}var n=t.getLowestSetBit(),i=r.getLowestSetBit();if(i<0)return t;for(n0&&(t.rShiftTo(i,t),r.rShiftTo(i,r));t.signum()>0;)(n=t.getLowestSetBit())>0&&t.rShiftTo(n,t),(n=r.getLowestSetBit())>0&&r.rShiftTo(n,r),t.compareTo(r)>=0?(t.subTo(r,t),t.rShiftTo(1,t)):(r.subTo(t,r),r.rShiftTo(1,r));return i>0&&r.lShiftTo(i,r),r},i.prototype.isProbablePrime=function(e){var t,r=this.abs();if(1==r.t&&r.data[0]<=B[B.length-1]){for(t=0;t>>0,o>>>0];for(var c=n.fullMessageLength.length-1;c>=0;--c)n.fullMessageLength[c]+=o[1],o[1]=o[0]+(n.fullMessageLength[c]/4294967296>>>0),n.fullMessageLength[c]=n.fullMessageLength[c]>>>0,o[0]=o[1]/4294967296>>>0;return t.putBytes(i),l(e,r,t),(t.read>2048||0===t.length())&&t.compact(),n},n.digest=function(){var s=a.util.createBuffer();s.putBytes(t.bytes());var o=n.fullMessageLength[n.fullMessageLength.length-1]+n.messageLengthSize&n.blockLength-1;s.putBytes(i.substr(0,n.blockLength-o));for(var c,u=0,p=n.fullMessageLength.length-1;p>=0;--p)u=(c=8*n.fullMessageLength[p]+u)/4294967296>>>0,s.putInt32Le(c>>>0);var f={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3};l(f,r,s);var h=a.util.createBuffer();return h.putInt32Le(f.h0),h.putInt32Le(f.h1),h.putInt32Le(f.h2),h.putInt32Le(f.h3),h},n};var i=null,s=null,o=null,c=null,u=!1;function l(e,t,r){for(var a,n,i,u,l,p,f,h=r.length();h>=64;){for(n=e.h0,i=e.h1,u=e.h2,l=e.h3,f=0;f<16;++f)t[f]=r.getInt32Le(),a=n+(l^i&(u^l))+c[f]+t[f],n=l,l=u,u=i,i+=a<<(p=o[f])|a>>>32-p;for(;f<32;++f)a=n+(u^l&(i^u))+c[f]+t[s[f]],n=l,l=u,u=i,i+=a<<(p=o[f])|a>>>32-p;for(;f<48;++f)a=n+(i^u^l)+c[f]+t[s[f]],n=l,l=u,u=i,i+=a<<(p=o[f])|a>>>32-p;for(;f<64;++f)a=n+(u^(i|~l))+c[f]+t[s[f]],n=l,l=u,u=i,i+=a<<(p=o[f])|a>>>32-p;e.h0=e.h0+n|0,e.h1=e.h1+i|0,e.h2=e.h2+u|0,e.h3=e.h3+l|0,h-=64}}},function(e,t,r){var a=r(0);r(8),r(4),r(1);var n,i=a.pkcs5=a.pkcs5||{};a.util.isNodejs&&!a.options.usePureJavaScript&&(n=r(16)),e.exports=a.pbkdf2=i.pbkdf2=function(e,t,r,i,s,o){if("function"==typeof s&&(o=s,s=null),a.util.isNodejs&&!a.options.usePureJavaScript&&n.pbkdf2&&(null===s||"object"!=typeof s)&&(n.pbkdf2Sync.length>4||!s||"sha1"===s))return"string"!=typeof s&&(s="sha1"),e=Buffer.from(e,"binary"),t=Buffer.from(t,"binary"),o?4===n.pbkdf2Sync.length?n.pbkdf2(e,t,r,i,(function(e,t){if(e)return o(e);o(null,t.toString("binary"))})):n.pbkdf2(e,t,r,i,s,(function(e,t){if(e)return o(e);o(null,t.toString("binary"))})):4===n.pbkdf2Sync.length?n.pbkdf2Sync(e,t,r,i).toString("binary"):n.pbkdf2Sync(e,t,r,i,s).toString("binary");if(null==s&&(s="sha1"),"string"==typeof s){if(!(s in a.md.algorithms))throw new Error("Unknown hash algorithm: "+s);s=a.md[s].create()}var c=s.digestLength;if(i>4294967295*c){var u=new Error("Derived key is too long.");if(o)return o(u);throw u}var l=Math.ceil(i/c),p=i-(l-1)*c,f=a.hmac.create();f.start(s,e);var h,d,y,g="";if(!o){for(var m=1;m<=l;++m){f.start(null,null),f.update(t),f.update(a.util.int32ToBytes(m)),h=y=f.digest().getBytes();for(var v=2;v<=r;++v)f.start(null,null),f.update(y),d=f.digest().getBytes(),h=a.util.xorBytes(h,d,c),y=d;g+=ml)return o(null,g);f.start(null,null),f.update(t),f.update(a.util.int32ToBytes(m)),h=y=f.digest().getBytes(),v=2,E()}function E(){if(v<=r)return f.start(null,null),f.update(y),d=f.digest().getBytes(),h=a.util.xorBytes(h,d,c),y=d,++v,a.util.setImmediate(E);g+=m128)throw new Error('Invalid "nsComment" content.');e.value=n.create(n.Class.UNIVERSAL,n.Type.IA5STRING,!1,e.comment)}else if("subjectKeyIdentifier"===e.name&&t.cert){var h=t.cert.generateSubjectKeyIdentifier();e.subjectKeyIdentifier=h.toHex(),e.value=n.create(n.Class.UNIVERSAL,n.Type.OCTETSTRING,!1,h.getBytes())}else if("authorityKeyIdentifier"===e.name&&t.cert){e.value=n.create(n.Class.UNIVERSAL,n.Type.SEQUENCE,!0,[]);l=e.value.value;if(e.keyIdentifier){var d=!0===e.keyIdentifier?t.cert.generateSubjectKeyIdentifier().getBytes():e.keyIdentifier;l.push(n.create(n.Class.CONTEXT_SPECIFIC,0,!1,d))}if(e.authorityCertIssuer){var g=[n.create(n.Class.CONTEXT_SPECIFIC,4,!0,[y(!0===e.authorityCertIssuer?t.cert.issuer:e.authorityCertIssuer)])];l.push(n.create(n.Class.CONTEXT_SPECIFIC,1,!0,g))}if(e.serialNumber){var m=a.util.hexToBytes(!0===e.serialNumber?t.cert.serialNumber:e.serialNumber);l.push(n.create(n.Class.CONTEXT_SPECIFIC,2,!1,m))}}else if("cRLDistributionPoints"===e.name){e.value=n.create(n.Class.UNIVERSAL,n.Type.SEQUENCE,!0,[]);l=e.value.value;var v,C=n.create(n.Class.UNIVERSAL,n.Type.SEQUENCE,!0,[]),E=n.create(n.Class.CONTEXT_SPECIFIC,0,!0,[]);for(f=0;f2)throw new Error("Cannot read notBefore/notAfter validity times; more than two times were provided in the certificate.");if(p.length<2)throw new Error("Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime.");if(c.validity.notBefore=p[0],c.validity.notAfter=p[1],c.tbsCertificate=r.tbsCertificate,t){var f;if(c.md=null,c.signatureOid in s)switch(s[c.signatureOid]){case"sha1WithRSAEncryption":c.md=a.md.sha1.create();break;case"md5WithRSAEncryption":c.md=a.md.md5.create();break;case"sha256WithRSAEncryption":c.md=a.md.sha256.create();break;case"sha384WithRSAEncryption":c.md=a.md.sha384.create();break;case"sha512WithRSAEncryption":c.md=a.md.sha512.create();break;case"RSASSA-PSS":c.md=a.md.sha256.create()}if(null===c.md)throw(f=new Error("Could not compute certificate digest. Unknown signature OID.")).signatureOid=c.signatureOid,f;var y=n.toDer(c.tbsCertificate);c.md.update(y.getBytes())}var m=a.md.sha1.create();c.issuer.getField=function(e){return h(c.issuer,e)},c.issuer.addField=function(e){g([e]),c.issuer.attributes.push(e)},c.issuer.attributes=i.RDNAttributesAsArray(r.certIssuer,m),r.certIssuerUniqueId&&(c.issuer.uniqueId=r.certIssuerUniqueId),c.issuer.hash=m.digest().toHex();var v=a.md.sha1.create();return c.subject.getField=function(e){return h(c.subject,e)},c.subject.addField=function(e){g([e]),c.subject.attributes.push(e)},c.subject.attributes=i.RDNAttributesAsArray(r.certSubject,v),r.certSubjectUniqueId&&(c.subject.uniqueId=r.certSubjectUniqueId),c.subject.hash=v.digest().toHex(),r.certExtensions?c.extensions=i.certificateExtensionsFromAsn1(r.certExtensions):c.extensions=[],c.publicKey=i.publicKeyFromAsn1(r.subjectPublicKeyInfo),c},i.certificateExtensionsFromAsn1=function(e){for(var t=[],r=0;r1&&(r=c.value.charCodeAt(1),i=c.value.length>2?c.value.charCodeAt(2):0),t.digitalSignature=128==(128&r),t.nonRepudiation=64==(64&r),t.keyEncipherment=32==(32&r),t.dataEncipherment=16==(16&r),t.keyAgreement=8==(8&r),t.keyCertSign=4==(4&r),t.cRLSign=2==(2&r),t.encipherOnly=1==(1&r),t.decipherOnly=128==(128&i)}else if("basicConstraints"===t.name){(c=n.fromDer(t.value)).value.length>0&&c.value[0].type===n.Type.BOOLEAN?t.cA=0!==c.value[0].value.charCodeAt(0):t.cA=!1;var o=null;c.value.length>0&&c.value[0].type===n.Type.INTEGER?o=c.value[0].value:c.value.length>1&&(o=c.value[1].value),null!==o&&(t.pathLenConstraint=n.derToInteger(o))}else if("extKeyUsage"===t.name)for(var c=n.fromDer(t.value),u=0;u1&&(r=c.value.charCodeAt(1)),t.client=128==(128&r),t.server=64==(64&r),t.email=32==(32&r),t.objsign=16==(16&r),t.reserved=8==(8&r),t.sslCA=4==(4&r),t.emailCA=2==(2&r),t.objCA=1==(1&r)}else if("subjectAltName"===t.name||"issuerAltName"===t.name){var p;t.altNames=[];c=n.fromDer(t.value);for(var f=0;f=E&&e0&&s.value.push(i.certificateExtensionsToAsn1(e.extensions)),s},i.getCertificationRequestInfo=function(e){return n.create(n.Class.UNIVERSAL,n.Type.SEQUENCE,!0,[n.create(n.Class.UNIVERSAL,n.Type.INTEGER,!1,n.integerToDer(e.version).getBytes()),y(e.subject),i.publicKeyToAsn1(e.publicKey),C(e)])},i.distinguishedNameToAsn1=function(e){return y(e)},i.certificateToAsn1=function(e){var t=e.tbsCertificate||i.getTBSCertificate(e);return n.create(n.Class.UNIVERSAL,n.Type.SEQUENCE,!0,[t,n.create(n.Class.UNIVERSAL,n.Type.SEQUENCE,!0,[n.create(n.Class.UNIVERSAL,n.Type.OID,!1,n.oidToDer(e.signatureOid).getBytes()),v(e.signatureOid,e.signatureParameters)]),n.create(n.Class.UNIVERSAL,n.Type.BITSTRING,!1,String.fromCharCode(0)+e.signature)])},i.certificateExtensionsToAsn1=function(e){var t=n.create(n.Class.CONTEXT_SPECIFIC,3,!0,[]),r=n.create(n.Class.UNIVERSAL,n.Type.SEQUENCE,!0,[]);t.value.push(r);for(var a=0;al.validity.notAfter)&&(c={message:"Certificate is not valid yet or has expired.",error:i.certificateError.certificate_expired,notBefore:l.validity.notBefore,notAfter:l.validity.notAfter,now:s}),null===c){if(null===(p=t[0]||e.getIssuer(l))&&l.isIssuer(l)&&(f=!0,p=l),p){var h=p;a.util.isArray(h)||(h=[h]);for(var d=!1;!d&&h.length>0;){p=h.shift();try{d=p.verify(l)}catch(e){}}d||(c={message:"Certificate signature is invalid.",error:i.certificateError.bad_certificate})}null!==c||p&&!f||e.hasCertificate(l)||(c={message:"Certificate is not trusted.",error:i.certificateError.unknown_ca})}if(null===c&&p&&!l.isIssuer(p)&&(c={message:"Certificate issuer is invalid.",error:i.certificateError.bad_certificate}),null===c)for(var y={keyUsage:!0,basicConstraints:!0},g=0;null===c&&gv.pathLenConstraint&&(c={message:"Certificate basicConstraints pathLenConstraint violated.",error:i.certificateError.bad_certificate})}var E=null===c||c.error,S=r.verify?r.verify(E,u,n):E;if(!0!==S)throw!0===E&&(c={message:"The application rejected the certificate.",error:i.certificateError.bad_certificate}),(S||0===S)&&("object"!=typeof S||a.util.isArray(S)?"string"==typeof S&&(c.error=S):(S.message&&(c.message=S.message),S.error&&(c.error=S.error))),c;c=null,o=!1,++u}while(t.length>0);return!0}},function(e,t,r){var a=r(0);r(2),r(1),(e.exports=a.pss=a.pss||{}).create=function(e){3===arguments.length&&(e={md:arguments[0],mgf:arguments[1],saltLength:arguments[2]});var t,r=e.md,n=e.mgf,i=r.digestLength,s=e.salt||null;if("string"==typeof s&&(s=a.util.createBuffer(s)),"saltLength"in e)t=e.saltLength;else{if(null===s)throw new Error("Salt length not specified or specific salt not given.");t=s.length()}if(null!==s&&s.length()!==t)throw new Error("Given salt length does not match length of given salt.");var o=e.prng||a.random,c={encode:function(e,c){var u,l,p=c-1,f=Math.ceil(p/8),h=e.digest().getBytes();if(f>8*f-p&255;return(E=String.fromCharCode(E.charCodeAt(0)&~S)+E.substr(1))+y+String.fromCharCode(188)},verify:function(e,s,o){var c,u=o-1,l=Math.ceil(u/8);if(s=s.substr(-l),l>8*l-u&255;if(0!=(f.charCodeAt(0)&d))throw new Error("Bits beyond keysize not zero as expected.");var y=n.generate(h,p),g="";for(c=0;c4){var r=e;e=a.util.createBuffer();for(var n=0;n0))return!0;for(var a=0;a0))return!0;for(var a=0;a0)return!1;var r=e.length(),a=e.at(r-1);return!(a>this.blockSize<<2)&&(e.truncate(a),!0)},n.cbc=function(e){e=e||{},this.name="CBC",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)},n.cbc.prototype.start=function(e){if(null===e.iv){if(!this._prev)throw new Error("Invalid IV parameter.");this._iv=this._prev.slice(0)}else{if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=i(e.iv,this.blockSize),this._prev=this._iv.slice(0)}},n.cbc.prototype.encrypt=function(e,t,r){if(e.length()0))return!0;for(var a=0;a0))return!0;for(var a=0;a0)return!1;var r=e.length(),a=e.at(r-1);return!(a>this.blockSize<<2)&&(e.truncate(a),!0)},n.cfb=function(e){e=e||{},this.name="CFB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialBlock=new Array(this._ints),this._partialOutput=a.util.createBuffer(),this._partialBytes=0},n.cfb.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=i(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},n.cfb.prototype.encrypt=function(e,t,r){var a=e.length();if(0===a)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&a>=this.blockSize)for(var n=0;n0&&(i=this.blockSize-i),this._partialOutput.clear();for(n=0;n0)e.read-=this.blockSize;else for(n=0;n0&&this._partialOutput.getBytes(this._partialBytes),i>0&&!r)return t.putBytes(this._partialOutput.getBytes(i-this._partialBytes)),this._partialBytes=i,!0;t.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=0}},n.cfb.prototype.decrypt=function(e,t,r){var a=e.length();if(0===a)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&a>=this.blockSize)for(var n=0;n0&&(i=this.blockSize-i),this._partialOutput.clear();for(n=0;n0)e.read-=this.blockSize;else for(n=0;n0&&this._partialOutput.getBytes(this._partialBytes),i>0&&!r)return t.putBytes(this._partialOutput.getBytes(i-this._partialBytes)),this._partialBytes=i,!0;t.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=0}},n.ofb=function(e){e=e||{},this.name="OFB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=a.util.createBuffer(),this._partialBytes=0},n.ofb.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=i(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},n.ofb.prototype.encrypt=function(e,t,r){var a=e.length();if(0===e.length())return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&a>=this.blockSize)for(var n=0;n0&&(i=this.blockSize-i),this._partialOutput.clear();for(n=0;n0)e.read-=this.blockSize;else for(n=0;n0&&this._partialOutput.getBytes(this._partialBytes),i>0&&!r)return t.putBytes(this._partialOutput.getBytes(i-this._partialBytes)),this._partialBytes=i,!0;t.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=0}},n.ofb.prototype.decrypt=n.ofb.prototype.encrypt,n.ctr=function(e){e=e||{},this.name="CTR",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=a.util.createBuffer(),this._partialBytes=0},n.ctr.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=i(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},n.ctr.prototype.encrypt=function(e,t,r){var a=e.length();if(0===a)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&a>=this.blockSize)for(var n=0;n0&&(i=this.blockSize-i),this._partialOutput.clear();for(n=0;n0&&(e.read-=this.blockSize),this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),i>0&&!r)return t.putBytes(this._partialOutput.getBytes(i-this._partialBytes)),this._partialBytes=i,!0;t.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=0}s(this._inBlock)},n.ctr.prototype.decrypt=n.ctr.prototype.encrypt,n.gcm=function(e){e=e||{},this.name="GCM",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints),this._partialOutput=a.util.createBuffer(),this._partialBytes=0,this._R=3774873600},n.gcm.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");var t,r=a.util.createBuffer(e.iv);if(this._cipherLength=0,t="additionalData"in e?a.util.createBuffer(e.additionalData):a.util.createBuffer(),this._tagLength="tagLength"in e?e.tagLength:128,this._tag=null,e.decrypt&&(this._tag=a.util.createBuffer(e.tag).getBytes(),this._tag.length!==this._tagLength/8))throw new Error("Authentication tag does not match tag length.");this._hashBlock=new Array(this._ints),this.tag=null,this._hashSubkey=new Array(this._ints),this.cipher.encrypt([0,0,0,0],this._hashSubkey),this.componentBits=4,this._m=this.generateHashTable(this._hashSubkey,this.componentBits);var n=r.length();if(12===n)this._j0=[r.getInt32(),r.getInt32(),r.getInt32(),1];else{for(this._j0=[0,0,0,0];r.length()>0;)this._j0=this.ghash(this._hashSubkey,this._j0,[r.getInt32(),r.getInt32(),r.getInt32(),r.getInt32()]);this._j0=this.ghash(this._hashSubkey,this._j0,[0,0].concat(o(8*n)))}this._inBlock=this._j0.slice(0),s(this._inBlock),this._partialBytes=0,t=a.util.createBuffer(t),this._aDataLength=o(8*t.length());var i=t.length()%this.blockSize;for(i&&t.fillWithByte(0,this.blockSize-i),this._s=[0,0,0,0];t.length()>0;)this._s=this.ghash(this._hashSubkey,this._s,[t.getInt32(),t.getInt32(),t.getInt32(),t.getInt32()])},n.gcm.prototype.encrypt=function(e,t,r){var a=e.length();if(0===a)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&a>=this.blockSize){for(var n=0;n0&&(i=this.blockSize-i),this._partialOutput.clear();for(n=0;n0&&this._partialOutput.getBytes(this._partialBytes),i>0&&!r)return e.read-=this.blockSize,t.putBytes(this._partialOutput.getBytes(i-this._partialBytes)),this._partialBytes=i,!0;t.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=0}this._s=this.ghash(this._hashSubkey,this._s,this._outBlock),s(this._inBlock)},n.gcm.prototype.decrypt=function(e,t,r){var a=e.length();if(a0))return!0;this.cipher.encrypt(this._inBlock,this._outBlock),s(this._inBlock),this._hashBlock[0]=e.getInt32(),this._hashBlock[1]=e.getInt32(),this._hashBlock[2]=e.getInt32(),this._hashBlock[3]=e.getInt32(),this._s=this.ghash(this._hashSubkey,this._s,this._hashBlock);for(var n=0;n0;--a)t[a]=e[a]>>>1|(1&e[a-1])<<31;t[0]=e[0]>>>1,r&&(t[0]^=this._R)},n.gcm.prototype.tableMultiply=function(e){for(var t=[0,0,0,0],r=0;r<32;++r){var a=e[r/8|0]>>>4*(7-r%8)&15,n=this._m[r][a];t[0]^=n[0],t[1]^=n[1],t[2]^=n[2],t[3]^=n[3]}return t},n.gcm.prototype.ghash=function(e,t,r){return t[0]^=r[0],t[1]^=r[1],t[2]^=r[2],t[3]^=r[3],this.tableMultiply(t)},n.gcm.prototype.generateHashTable=function(e,t){for(var r=8/t,a=4*r,n=16*r,i=new Array(n),s=0;s>>1,n=new Array(r);n[a]=e.slice(0);for(var i=a>>>1;i>0;)this.pow(n[2*i],n[i]=[]),i>>=1;for(i=2;i>1,o=s+(1&e.length),c=e.substr(0,o),u=e.substr(s,o),l=a.util.createBuffer(),p=a.hmac.create();r=t+r;var f=Math.ceil(n/16),h=Math.ceil(n/20);p.start("MD5",c);var d=a.util.createBuffer();l.putBytes(r);for(var y=0;y0&&(u.queue(e,u.createAlert(e,{level:u.Alert.Level.warning,description:u.Alert.Description.no_renegotiation})),u.flush(e)),e.process()},u.parseHelloMessage=function(e,t,r){var n=null,i=e.entity===u.ConnectionEnd.client;if(r<38)e.error(e,{message:i?"Invalid ServerHello message. Message too short.":"Invalid ClientHello message. Message too short.",send:!0,alert:{level:u.Alert.Level.fatal,description:u.Alert.Description.illegal_parameter}});else{var s=t.fragment,c=s.length();if(n={version:{major:s.getByte(),minor:s.getByte()},random:a.util.createBuffer(s.getBytes(32)),session_id:o(s,1),extensions:[]},i?(n.cipher_suite=s.getBytes(2),n.compression_method=s.getByte()):(n.cipher_suites=o(s,2),n.compression_methods=o(s,1)),(c=r-(c-s.length()))>0){for(var l=o(s,2);l.length()>0;)n.extensions.push({type:[l.getByte(),l.getByte()],data:o(l,2)});if(!i)for(var p=0;p0;){if(0!==h.getByte())break;e.session.extensions.server_name.serverNameList.push(o(h,2).getBytes())}}}if(e.session.version&&(n.version.major!==e.session.version.major||n.version.minor!==e.session.version.minor))return e.error(e,{message:"TLS version change is disallowed during renegotiation.",send:!0,alert:{level:u.Alert.Level.fatal,description:u.Alert.Description.protocol_version}});if(i)e.session.cipherSuite=u.getCipherSuite(n.cipher_suite);else for(var d=a.util.createBuffer(n.cipher_suites.bytes());d.length()>0&&(e.session.cipherSuite=u.getCipherSuite(d.getBytes(2)),null===e.session.cipherSuite););if(null===e.session.cipherSuite)return e.error(e,{message:"No cipher suites in common.",send:!0,alert:{level:u.Alert.Level.fatal,description:u.Alert.Description.handshake_failure},cipherSuite:a.util.bytesToHex(n.cipher_suite)});e.session.compressionMethod=i?n.compression_method:u.CompressionMethod.none}return n},u.createSecurityParameters=function(e,t){var r=e.entity===u.ConnectionEnd.client,a=t.random.bytes(),n=r?e.session.sp.client_random:a,i=r?a:u.createRandom().getBytes();e.session.sp={entity:e.entity,prf_algorithm:u.PRFAlgorithm.tls_prf_sha256,bulk_cipher_algorithm:null,cipher_type:null,enc_key_length:null,block_length:null,fixed_iv_length:null,record_iv_length:null,mac_algorithm:null,mac_length:null,mac_key_length:null,compression_algorithm:e.session.compressionMethod,pre_master_secret:null,master_secret:null,client_random:n,server_random:i}},u.handleServerHello=function(e,t,r){var a=u.parseHelloMessage(e,t,r);if(!e.fail){if(!(a.version.minor<=e.version.minor))return e.error(e,{message:"Incompatible TLS version.",send:!0,alert:{level:u.Alert.Level.fatal,description:u.Alert.Description.protocol_version}});e.version.minor=a.version.minor,e.session.version=e.version;var n=a.session_id.bytes();n.length>0&&n===e.session.id?(e.expect=d,e.session.resuming=!0,e.session.sp.server_random=a.random.bytes()):(e.expect=l,e.session.resuming=!1,u.createSecurityParameters(e,a)),e.session.id=n,e.process()}},u.handleClientHello=function(e,t,r){var n=u.parseHelloMessage(e,t,r);if(!e.fail){var i=n.session_id.bytes(),s=null;if(e.sessionCache&&(null===(s=e.sessionCache.getSession(i))?i="":(s.version.major!==n.version.major||s.version.minor>n.version.minor)&&(s=null,i="")),0===i.length&&(i=a.random.getBytes(32)),e.session.id=i,e.session.clientHelloVersion=n.version,e.session.sp={},s)e.version=e.session.version=s.version,e.session.sp=s.sp;else{for(var o,c=1;c0;)n=o(c.certificate_list,3),i=a.asn1.fromDer(n),n=a.pki.certificateFromAsn1(i,!0),l.push(n)}catch(t){return e.error(e,{message:"Could not parse certificate list.",cause:t,send:!0,alert:{level:u.Alert.Level.fatal,description:u.Alert.Description.bad_certificate}})}var f=e.entity===u.ConnectionEnd.client;!f&&!0!==e.verifyClient||0!==l.length?0===l.length?e.expect=f?p:C:(f?e.session.serverCertificate=l[0]:e.session.clientCertificate=l[0],u.verifyCertificateChain(e,l)&&(e.expect=f?p:C)):e.error(e,{message:f?"No server certificate provided.":"No client certificate provided.",send:!0,alert:{level:u.Alert.Level.fatal,description:u.Alert.Description.illegal_parameter}}),e.process()},u.handleServerKeyExchange=function(e,t,r){if(r>0)return e.error(e,{message:"Invalid key parameters. Only RSA is supported.",send:!0,alert:{level:u.Alert.Level.fatal,description:u.Alert.Description.unsupported_certificate}});e.expect=f,e.process()},u.handleClientKeyExchange=function(e,t,r){if(r<48)return e.error(e,{message:"Invalid key parameters. Only RSA is supported.",send:!0,alert:{level:u.Alert.Level.fatal,description:u.Alert.Description.unsupported_certificate}});var n=t.fragment,i={enc_pre_master_secret:o(n,2).getBytes()},s=null;if(e.getPrivateKey)try{s=e.getPrivateKey(e,e.session.serverCertificate),s=a.pki.privateKeyFromPem(s)}catch(t){e.error(e,{message:"Could not get private key.",cause:t,send:!0,alert:{level:u.Alert.Level.fatal,description:u.Alert.Description.internal_error}})}if(null===s)return e.error(e,{message:"No private key set.",send:!0,alert:{level:u.Alert.Level.fatal,description:u.Alert.Description.internal_error}});try{var c=e.session.sp;c.pre_master_secret=s.decrypt(i.enc_pre_master_secret);var l=e.session.clientHelloVersion;if(l.major!==c.pre_master_secret.charCodeAt(0)||l.minor!==c.pre_master_secret.charCodeAt(1))throw new Error("TLS version rollback attack detected.")}catch(e){c.pre_master_secret=a.random.getBytes(48)}e.expect=S,null!==e.session.clientCertificate&&(e.expect=E),e.process()},u.handleCertificateRequest=function(e,t,r){if(r<3)return e.error(e,{message:"Invalid CertificateRequest. Message too short.",send:!0,alert:{level:u.Alert.Level.fatal,description:u.Alert.Description.illegal_parameter}});var a=t.fragment,n={certificate_types:o(a,1),certificate_authorities:o(a,2)};e.session.certificateRequest=n,e.expect=h,e.process()},u.handleCertificateVerify=function(e,t,r){if(r<2)return e.error(e,{message:"Invalid CertificateVerify. Message too short.",send:!0,alert:{level:u.Alert.Level.fatal,description:u.Alert.Description.illegal_parameter}});var n=t.fragment;n.read-=4;var i=n.bytes();n.read+=4;var s={signature:o(n,2).getBytes()},c=a.util.createBuffer();c.putBuffer(e.session.md5.digest()),c.putBuffer(e.session.sha1.digest()),c=c.getBytes();try{if(!e.session.clientCertificate.publicKey.verify(c,s.signature,"NONE"))throw new Error("CertificateVerify signature does not match.");e.session.md5.update(i),e.session.sha1.update(i)}catch(t){return e.error(e,{message:"Bad signature in CertificateVerify.",send:!0,alert:{level:u.Alert.Level.fatal,description:u.Alert.Description.handshake_failure}})}e.expect=S,e.process()},u.handleServerHelloDone=function(e,t,r){if(r>0)return e.error(e,{message:"Invalid ServerHelloDone message. Invalid length.",send:!0,alert:{level:u.Alert.Level.fatal,description:u.Alert.Description.record_overflow}});if(null===e.serverCertificate){var n={message:"No server certificate provided. Not enough security.",send:!0,alert:{level:u.Alert.Level.fatal,description:u.Alert.Description.insufficient_security}},i=e.verify(e,n.alert.description,0,[]);if(!0!==i)return(i||0===i)&&("object"!=typeof i||a.util.isArray(i)?"number"==typeof i&&(n.alert.description=i):(i.message&&(n.message=i.message),i.alert&&(n.alert.description=i.alert))),e.error(e,n)}null!==e.session.certificateRequest&&(t=u.createRecord(e,{type:u.ContentType.handshake,data:u.createCertificate(e)}),u.queue(e,t)),t=u.createRecord(e,{type:u.ContentType.handshake,data:u.createClientKeyExchange(e)}),u.queue(e,t),e.expect=m;var s=function(e,t){null!==e.session.certificateRequest&&null!==e.session.clientCertificate&&u.queue(e,u.createRecord(e,{type:u.ContentType.handshake,data:u.createCertificateVerify(e,t)})),u.queue(e,u.createRecord(e,{type:u.ContentType.change_cipher_spec,data:u.createChangeCipherSpec()})),e.state.pending=u.createConnectionState(e),e.state.current.write=e.state.pending.write,u.queue(e,u.createRecord(e,{type:u.ContentType.handshake,data:u.createFinished(e)})),e.expect=d,u.flush(e),e.process()};if(null===e.session.certificateRequest||null===e.session.clientCertificate)return s(e,null);u.getClientSignature(e,s)},u.handleChangeCipherSpec=function(e,t){if(1!==t.fragment.getByte())return e.error(e,{message:"Invalid ChangeCipherSpec message received.",send:!0,alert:{level:u.Alert.Level.fatal,description:u.Alert.Description.illegal_parameter}});var r=e.entity===u.ConnectionEnd.client;(e.session.resuming&&r||!e.session.resuming&&!r)&&(e.state.pending=u.createConnectionState(e)),e.state.current.read=e.state.pending.read,(!e.session.resuming&&r||e.session.resuming&&!r)&&(e.state.pending=null),e.expect=r?y:T,e.process()},u.handleFinished=function(e,t,r){var i=t.fragment;i.read-=4;var s=i.bytes();i.read+=4;var o=t.fragment.getBytes();(i=a.util.createBuffer()).putBuffer(e.session.md5.digest()),i.putBuffer(e.session.sha1.digest());var c=e.entity===u.ConnectionEnd.client,l=c?"server finished":"client finished",p=e.session.sp;if((i=n(p.master_secret,l,i.getBytes(),12)).getBytes()!==o)return e.error(e,{message:"Invalid verify_data in Finished message.",send:!0,alert:{level:u.Alert.Level.fatal,description:u.Alert.Description.decrypt_error}});e.session.md5.update(s),e.session.sha1.update(s),(e.session.resuming&&c||!e.session.resuming&&!c)&&(u.queue(e,u.createRecord(e,{type:u.ContentType.change_cipher_spec,data:u.createChangeCipherSpec()})),e.state.current.write=e.state.pending.write,e.state.pending=null,u.queue(e,u.createRecord(e,{type:u.ContentType.handshake,data:u.createFinished(e)}))),e.expect=c?g:I,e.handshaking=!1,++e.handshakes,e.peerCertificate=c?e.session.serverCertificate:e.session.clientCertificate,u.flush(e),e.isConnected=!0,e.connected(e),e.process()},u.handleAlert=function(e,t){var r,a=t.fragment,n={level:a.getByte(),description:a.getByte()};switch(n.description){case u.Alert.Description.close_notify:r="Connection closed.";break;case u.Alert.Description.unexpected_message:r="Unexpected message.";break;case u.Alert.Description.bad_record_mac:r="Bad record MAC.";break;case u.Alert.Description.decryption_failed:r="Decryption failed.";break;case u.Alert.Description.record_overflow:r="Record overflow.";break;case u.Alert.Description.decompression_failure:r="Decompression failed.";break;case u.Alert.Description.handshake_failure:r="Handshake failure.";break;case u.Alert.Description.bad_certificate:r="Bad certificate.";break;case u.Alert.Description.unsupported_certificate:r="Unsupported certificate.";break;case u.Alert.Description.certificate_revoked:r="Certificate revoked.";break;case u.Alert.Description.certificate_expired:r="Certificate expired.";break;case u.Alert.Description.certificate_unknown:r="Certificate unknown.";break;case u.Alert.Description.illegal_parameter:r="Illegal parameter.";break;case u.Alert.Description.unknown_ca:r="Unknown certificate authority.";break;case u.Alert.Description.access_denied:r="Access denied.";break;case u.Alert.Description.decode_error:r="Decode error.";break;case u.Alert.Description.decrypt_error:r="Decrypt error.";break;case u.Alert.Description.export_restriction:r="Export restriction.";break;case u.Alert.Description.protocol_version:r="Unsupported protocol version.";break;case u.Alert.Description.insufficient_security:r="Insufficient security.";break;case u.Alert.Description.internal_error:r="Internal error.";break;case u.Alert.Description.user_canceled:r="User canceled.";break;case u.Alert.Description.no_renegotiation:r="Renegotiation not supported.";break;default:r="Unknown error."}if(n.description===u.Alert.Description.close_notify)return e.close();e.error(e,{message:r,send:!1,origin:e.entity===u.ConnectionEnd.client?"server":"client",alert:n}),e.process()},u.handleHandshake=function(e,t){var r=t.fragment,n=r.getByte(),i=r.getInt24();if(i>r.length())return e.fragmented=t,t.fragment=a.util.createBuffer(),r.read-=4,e.process();e.fragmented=null,r.read-=4;var s=r.bytes(i+4);r.read+=4,n in K[e.entity][e.expect]?(e.entity!==u.ConnectionEnd.server||e.open||e.fail||(e.handshaking=!0,e.session={version:null,extensions:{server_name:{serverNameList:[]}},cipherSuite:null,compressionMethod:null,serverCertificate:null,clientCertificate:null,md5:a.md.md5.create(),sha1:a.md.sha1.create()}),n!==u.HandshakeType.hello_request&&n!==u.HandshakeType.certificate_verify&&n!==u.HandshakeType.finished&&(e.session.md5.update(s),e.session.sha1.update(s)),K[e.entity][e.expect][n](e,t,i)):u.handleUnexpected(e,t)},u.handleApplicationData=function(e,t){e.data.putBuffer(t.fragment),e.dataReady(e),e.process()},u.handleHeartbeat=function(e,t){var r=t.fragment,n=r.getByte(),i=r.getInt16(),s=r.getBytes(i);if(n===u.HeartbeatMessageType.heartbeat_request){if(e.handshaking||i>s.length)return e.process();u.queue(e,u.createRecord(e,{type:u.ContentType.heartbeat,data:u.createHeartbeat(u.HeartbeatMessageType.heartbeat_response,s)})),u.flush(e)}else if(n===u.HeartbeatMessageType.heartbeat_response){if(s!==e.expectedHeartbeatPayload)return e.process();e.heartbeatReceived&&e.heartbeatReceived(e,a.util.createBuffer(s))}e.process()};var l=1,p=2,f=3,h=4,d=5,y=6,g=7,m=8,v=1,C=2,E=3,S=4,T=5,I=6,b=u.handleUnexpected,A=u.handleChangeCipherSpec,B=u.handleAlert,N=u.handleHandshake,k=u.handleApplicationData,w=u.handleHeartbeat,R=[];R[u.ConnectionEnd.client]=[[b,B,N,b,w],[b,B,N,b,w],[b,B,N,b,w],[b,B,N,b,w],[b,B,N,b,w],[A,B,b,b,w],[b,B,N,b,w],[b,B,N,k,w],[b,B,N,b,w]],R[u.ConnectionEnd.server]=[[b,B,N,b,w],[b,B,N,b,w],[b,B,N,b,w],[b,B,N,b,w],[A,B,b,b,w],[b,B,N,b,w],[b,B,N,k,w],[b,B,N,b,w]];var _=u.handleHelloRequest,L=u.handleServerHello,U=u.handleCertificate,D=u.handleServerKeyExchange,P=u.handleCertificateRequest,V=u.handleServerHelloDone,O=u.handleFinished,K=[];K[u.ConnectionEnd.client]=[[b,b,L,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b],[_,b,b,b,b,b,b,b,b,b,b,U,D,P,V,b,b,b,b,b,b],[_,b,b,b,b,b,b,b,b,b,b,b,D,P,V,b,b,b,b,b,b],[_,b,b,b,b,b,b,b,b,b,b,b,b,P,V,b,b,b,b,b,b],[_,b,b,b,b,b,b,b,b,b,b,b,b,b,V,b,b,b,b,b,b],[_,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b],[_,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,O],[_,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b],[_,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b]];var x=u.handleClientHello,M=u.handleClientKeyExchange,F=u.handleCertificateVerify;K[u.ConnectionEnd.server]=[[b,x,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b],[b,b,b,b,b,b,b,b,b,b,b,U,b,b,b,b,b,b,b,b,b],[b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,M,b,b,b,b],[b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,F,b,b,b,b,b],[b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b],[b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,O],[b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b],[b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b]],u.generateKeys=function(e,t){var r=n,a=t.client_random+t.server_random;e.session.resuming||(t.master_secret=r(t.pre_master_secret,"master secret",a,48).bytes(),t.pre_master_secret=null),a=t.server_random+t.client_random;var i=2*t.mac_key_length+2*t.enc_key_length,s=e.version.major===u.Versions.TLS_1_0.major&&e.version.minor===u.Versions.TLS_1_0.minor;s&&(i+=2*t.fixed_iv_length);var o=r(t.master_secret,"key expansion",a,i),c={client_write_MAC_key:o.getBytes(t.mac_key_length),server_write_MAC_key:o.getBytes(t.mac_key_length),client_write_key:o.getBytes(t.enc_key_length),server_write_key:o.getBytes(t.enc_key_length)};return s&&(c.client_write_IV=o.getBytes(t.fixed_iv_length),c.server_write_IV=o.getBytes(t.fixed_iv_length)),c},u.createConnectionState=function(e){var t=e.entity===u.ConnectionEnd.client,r=function(){var e={sequenceNumber:[0,0],macKey:null,macLength:0,macFunction:null,cipherState:null,cipherFunction:function(e){return!0},compressionState:null,compressFunction:function(e){return!0},updateSequenceNumber:function(){4294967295===e.sequenceNumber[1]?(e.sequenceNumber[1]=0,++e.sequenceNumber[0]):++e.sequenceNumber[1]}};return e},a={read:r(),write:r()};if(a.read.update=function(e,t){return a.read.cipherFunction(t,a.read)?a.read.compressFunction(e,t,a.read)||e.error(e,{message:"Could not decompress record.",send:!0,alert:{level:u.Alert.Level.fatal,description:u.Alert.Description.decompression_failure}}):e.error(e,{message:"Could not decrypt record or bad MAC.",send:!0,alert:{level:u.Alert.Level.fatal,description:u.Alert.Description.bad_record_mac}}),!e.fail},a.write.update=function(e,t){return a.write.compressFunction(e,t,a.write)?a.write.cipherFunction(t,a.write)||e.error(e,{message:"Could not encrypt record.",send:!1,alert:{level:u.Alert.Level.fatal,description:u.Alert.Description.internal_error}}):e.error(e,{message:"Could not compress record.",send:!1,alert:{level:u.Alert.Level.fatal,description:u.Alert.Description.internal_error}}),!e.fail},e.session){var n=e.session.sp;switch(e.session.cipherSuite.initSecurityParameters(n),n.keys=u.generateKeys(e,n),a.read.macKey=t?n.keys.server_write_MAC_key:n.keys.client_write_MAC_key,a.write.macKey=t?n.keys.client_write_MAC_key:n.keys.server_write_MAC_key,e.session.cipherSuite.initConnectionState(a,e,n),n.compression_algorithm){case u.CompressionMethod.none:break;case u.CompressionMethod.deflate:a.read.compressFunction=s,a.write.compressFunction=i;break;default:throw new Error("Unsupported compression algorithm.")}}return a},u.createRandom=function(){var e=new Date,t=+e+6e4*e.getTimezoneOffset(),r=a.util.createBuffer();return r.putInt32(t),r.putBytes(a.random.getBytes(28)),r},u.createRecord=function(e,t){return t.data?{type:t.type,version:{major:e.version.major,minor:e.version.minor},length:t.data.length(),fragment:t.data}:null},u.createAlert=function(e,t){var r=a.util.createBuffer();return r.putByte(t.level),r.putByte(t.description),u.createRecord(e,{type:u.ContentType.alert,data:r})},u.createClientHello=function(e){e.session.clientHelloVersion={major:e.version.major,minor:e.version.minor};for(var t=a.util.createBuffer(),r=0;r0&&(d+=2);var y=e.session.id,g=y.length+1+2+4+28+2+i+1+o+d,m=a.util.createBuffer();return m.putByte(u.HandshakeType.client_hello),m.putInt24(g),m.putByte(e.version.major),m.putByte(e.version.minor),m.putBytes(e.session.sp.client_random),c(m,1,a.util.createBuffer(y)),c(m,2,t),c(m,1,s),d>0&&c(m,2,l),m},u.createServerHello=function(e){var t=e.session.id,r=t.length+1+2+4+28+2+1,n=a.util.createBuffer();return n.putByte(u.HandshakeType.server_hello),n.putInt24(r),n.putByte(e.version.major),n.putByte(e.version.minor),n.putBytes(e.session.sp.server_random),c(n,1,a.util.createBuffer(t)),n.putByte(e.session.cipherSuite.id[0]),n.putByte(e.session.cipherSuite.id[1]),n.putByte(e.session.compressionMethod),n},u.createCertificate=function(e){var t,r=e.entity===u.ConnectionEnd.client,n=null;e.getCertificate&&(t=r?e.session.certificateRequest:e.session.extensions.server_name.serverNameList,n=e.getCertificate(e,t));var i=a.util.createBuffer();if(null!==n)try{a.util.isArray(n)||(n=[n]);for(var s=null,o=0;ou.MaxFragment;)n.push(u.createRecord(e,{type:t.type,data:a.util.createBuffer(i.slice(0,u.MaxFragment))})),i=i.slice(u.MaxFragment);i.length>0&&n.push(u.createRecord(e,{type:t.type,data:a.util.createBuffer(i)}))}for(var s=0;s0&&(n=r.order[0]),null!==n&&n in r.cache)for(var i in t=r.cache[n],delete r.cache[n],r.order)if(r.order[i]===n){r.order.splice(i,1);break}return t},r.setSession=function(e,t){if(r.order.length===r.capacity){var n=r.order.shift();delete r.cache[n]}n=a.util.bytesToHex(e);r.order.push(n),r.cache[n]=t}}return r},u.createConnection=function(e){var t=null;t=e.caStore?a.util.isArray(e.caStore)?a.pki.createCaStore(e.caStore):e.caStore:a.pki.createCaStore();var r=e.cipherSuites||null;if(null===r)for(var n in r=[],u.CipherSuites)r.push(u.CipherSuites[n]);var i=e.server?u.ConnectionEnd.server:u.ConnectionEnd.client,s=e.sessionCache?u.createSessionCache(e.sessionCache):null,o={version:{major:u.Version.major,minor:u.Version.minor},entity:i,sessionId:e.sessionId,caStore:t,sessionCache:s,cipherSuites:r,connected:e.connected,virtualHost:e.virtualHost||null,verifyClient:e.verifyClient||!1,verify:e.verify||function(e,t,r,a){return t},verifyOptions:e.verifyOptions||{},getCertificate:e.getCertificate||null,getPrivateKey:e.getPrivateKey||null,getSignature:e.getSignature||null,input:a.util.createBuffer(),tlsData:a.util.createBuffer(),data:a.util.createBuffer(),tlsDataReady:e.tlsDataReady,dataReady:e.dataReady,heartbeatReceived:e.heartbeatReceived,closed:e.closed,error:function(t,r){r.origin=r.origin||(t.entity===u.ConnectionEnd.client?"client":"server"),r.send&&(u.queue(t,u.createAlert(t,r.alert)),u.flush(t));var a=!1!==r.fatal;a&&(t.fail=!0),e.error(t,r),a&&t.close(!1)},deflate:e.deflate||null,inflate:e.inflate||null,reset:function(e){o.version={major:u.Version.major,minor:u.Version.minor},o.record=null,o.session=null,o.peerCertificate=null,o.state={pending:null,current:null},o.expect=(o.entity,u.ConnectionEnd.client,0),o.fragmented=null,o.records=[],o.open=!1,o.handshakes=0,o.handshaking=!1,o.isConnected=!1,o.fail=!(e||void 0===e),o.input.clear(),o.tlsData.clear(),o.data.clear(),o.state.current=u.createConnectionState(o)}};o.reset();return o.handshake=function(e){if(o.entity!==u.ConnectionEnd.client)o.error(o,{message:"Cannot initiate handshake as a server.",fatal:!1});else if(o.handshaking)o.error(o,{message:"Handshake already in progress.",fatal:!1});else{o.fail&&!o.open&&0===o.handshakes&&(o.fail=!1),o.handshaking=!0;var t=null;(e=e||"").length>0&&(o.sessionCache&&(t=o.sessionCache.getSession(e)),null===t&&(e="")),0===e.length&&o.sessionCache&&null!==(t=o.sessionCache.getSession())&&(e=t.id),o.session={id:e,version:null,cipherSuite:null,compressionMethod:null,serverCertificate:null,certificateRequest:null,clientCertificate:null,sp:{},md5:a.md.md5.create(),sha1:a.md.sha1.create()},t&&(o.version=t.version,o.session.sp=t.sp),o.session.sp.client_random=u.createRandom().getBytes(),o.open=!0,u.queue(o,u.createRecord(o,{type:u.ContentType.handshake,data:u.createClientHello(o)})),u.flush(o)}},o.process=function(e){var t=0;return e&&o.input.putBytes(e),o.fail||(null!==o.record&&o.record.ready&&o.record.fragment.isEmpty()&&(o.record=null),null===o.record&&(t=function(e){var t=0,r=e.input,n=r.length();if(n<5)t=5-n;else{e.record={type:r.getByte(),version:{major:r.getByte(),minor:r.getByte()},length:r.getInt16(),fragment:a.util.createBuffer(),ready:!1};var i=e.record.version.major===e.version.major;i&&e.session&&e.session.version&&(i=e.record.version.minor===e.version.minor),i||e.error(e,{message:"Incompatible TLS version.",send:!0,alert:{level:u.Alert.Level.fatal,description:u.Alert.Description.protocol_version}})}return t}(o)),o.fail||null===o.record||o.record.ready||(t=function(e){var t=0,r=e.input,a=r.length();a=0;c--)w>>=8,w+=A.at(c)+k.at(c),k.setAt(c,255&w);N.putBuffer(k)}E=N,p.putBuffer(I)}return p.truncate(p.length()-i),p},s.pbe.getCipher=function(e,t,r){switch(e){case s.oids.pkcs5PBES2:return s.pbe.getCipherForPBES2(e,t,r);case s.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case s.oids["pbewithSHAAnd40BitRC2-CBC"]:return s.pbe.getCipherForPKCS12PBE(e,t,r);default:var a=new Error("Cannot read encrypted PBE data block. Unsupported OID.");throw a.oid=e,a.supportedOids=["pkcs5PBES2","pbeWithSHAAnd3-KeyTripleDES-CBC","pbewithSHAAnd40BitRC2-CBC"],a}},s.pbe.getCipherForPBES2=function(e,t,r){var n,o={},c=[];if(!i.validate(t,u,o,c))throw(n=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.")).errors=c,n;if((e=i.derToOid(o.kdfOid))!==s.oids.pkcs5PBKDF2)throw(n=new Error("Cannot read encrypted private key. Unsupported key derivation function OID.")).oid=e,n.supportedOids=["pkcs5PBKDF2"],n;if((e=i.derToOid(o.encOid))!==s.oids["aes128-CBC"]&&e!==s.oids["aes192-CBC"]&&e!==s.oids["aes256-CBC"]&&e!==s.oids["des-EDE3-CBC"]&&e!==s.oids.desCBC)throw(n=new Error("Cannot read encrypted private key. Unsupported encryption scheme OID.")).oid=e,n.supportedOids=["aes128-CBC","aes192-CBC","aes256-CBC","des-EDE3-CBC","desCBC"],n;var l,p,h=o.kdfSalt,d=a.util.createBuffer(o.kdfIterationCount);switch(d=d.getInt(d.length()<<3),s.oids[e]){case"aes128-CBC":l=16,p=a.aes.createDecryptionCipher;break;case"aes192-CBC":l=24,p=a.aes.createDecryptionCipher;break;case"aes256-CBC":l=32,p=a.aes.createDecryptionCipher;break;case"des-EDE3-CBC":l=24,p=a.des.createDecryptionCipher;break;case"desCBC":l=8,p=a.des.createDecryptionCipher}var y=f(o.prfOid),g=a.pkcs5.pbkdf2(r,h,d,l,y),m=o.encIv,v=p(g);return v.start(m),v},s.pbe.getCipherForPKCS12PBE=function(e,t,r){var n={},o=[];if(!i.validate(t,l,n,o))throw(y=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.")).errors=o,y;var c,u,p,h=a.util.createBuffer(n.salt),d=a.util.createBuffer(n.iterations);switch(d=d.getInt(d.length()<<3),e){case s.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:c=24,u=8,p=a.des.startDecrypting;break;case s.oids["pbewithSHAAnd40BitRC2-CBC"]:c=5,u=8,p=function(e,t){var r=a.rc2.createDecryptionCipher(e,40);return r.start(t,null),r};break;default:var y;throw(y=new Error("Cannot read PKCS #12 PBE data block. Unsupported OID.")).oid=e,y}var g=f(n.prfOid),m=s.pbe.generatePkcs12Key(r,h,1,d,c,g);return g.start(),p(m,s.pbe.generatePkcs12Key(r,h,2,d,u,g))},s.pbe.opensslDeriveBytes=function(e,t,r,n){if(null==n){if(!("md5"in a.md))throw new Error('"md5" hash algorithm unavailable.');n=a.md.md5.create()}null===t&&(t="");for(var i=[p(n,e+t)],s=16,o=1;s>>0,o>>>0];for(var u=n.fullMessageLength.length-1;u>=0;--u)n.fullMessageLength[u]+=o[1],o[1]=o[0]+(n.fullMessageLength[u]/4294967296>>>0),n.fullMessageLength[u]=n.fullMessageLength[u]>>>0,o[0]=o[1]/4294967296>>>0;return t.putBytes(i),c(e,r,t),(t.read>2048||0===t.length())&&t.compact(),n},n.digest=function(){var s=a.util.createBuffer();s.putBytes(t.bytes());var o,u=n.fullMessageLength[n.fullMessageLength.length-1]+n.messageLengthSize&n.blockLength-1;s.putBytes(i.substr(0,n.blockLength-u));for(var l=8*n.fullMessageLength[0],p=0;p>>0,s.putInt32(l>>>0),l=o>>>0;s.putInt32(l);var f={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4,h5:e.h5,h6:e.h6,h7:e.h7};c(f,r,s);var h=a.util.createBuffer();return h.putInt32(f.h0),h.putInt32(f.h1),h.putInt32(f.h2),h.putInt32(f.h3),h.putInt32(f.h4),h.putInt32(f.h5),h.putInt32(f.h6),h.putInt32(f.h7),h},n};var i=null,s=!1,o=null;function c(e,t,r){for(var a,n,i,s,c,u,l,p,f,h,d,y,g,m=r.length();m>=64;){for(c=0;c<16;++c)t[c]=r.getInt32();for(;c<64;++c)a=((a=t[c-2])>>>17|a<<15)^(a>>>19|a<<13)^a>>>10,n=((n=t[c-15])>>>7|n<<25)^(n>>>18|n<<14)^n>>>3,t[c]=a+t[c-7]+n+t[c-16]|0;for(u=e.h0,l=e.h1,p=e.h2,f=e.h3,h=e.h4,d=e.h5,y=e.h6,g=e.h7,c=0;c<64;++c)i=(u>>>2|u<<30)^(u>>>13|u<<19)^(u>>>22|u<<10),s=u&l|p&(u^l),a=g+((h>>>6|h<<26)^(h>>>11|h<<21)^(h>>>25|h<<7))+(y^h&(d^y))+o[c]+t[c],g=y,y=d,d=h,h=f+a>>>0,f=p,p=l,l=u,u=a+(n=i+s)>>>0;e.h0=e.h0+u|0,e.h1=e.h1+l|0,e.h2=e.h2+p|0,e.h3=e.h3+f|0,e.h4=e.h4+h|0,e.h5=e.h5+d|0,e.h6=e.h6+y|0,e.h7=e.h7+g|0,m-=64}}},function(e,t,r){var a=r(0);r(1);var n=null;!a.util.isNodejs||a.options.usePureJavaScript||process.versions["node-webkit"]||(n=r(16)),(e.exports=a.prng=a.prng||{}).create=function(e){for(var t={plugin:e,key:null,seed:null,time:null,reseeds:0,generated:0,keyBytes:""},r=e.md,i=new Array(32),s=0;s<32;++s)i[s]=r.create();function o(){if(t.pools[0].messageLength>=32)return c();var e=32-t.pools[0].messageLength<<5;t.collect(t.seedFileSync(e)),c()}function c(){t.reseeds=4294967295===t.reseeds?0:t.reseeds+1;var e=t.plugin.md.create();e.update(t.keyBytes);for(var r=1,a=0;a<32;++a)t.reseeds%r==0&&(e.update(t.pools[a].digest().getBytes()),t.pools[a].start()),r<<=1;t.keyBytes=e.digest().getBytes(),e.start(),e.update(t.keyBytes);var n=e.digest().getBytes();t.key=t.plugin.formatKey(t.keyBytes),t.seed=t.plugin.formatSeed(n),t.generated=0}function u(e){var t=null,r=a.util.globalScope,n=r.crypto||r.msCrypto;n&&n.getRandomValues&&(t=function(e){return n.getRandomValues(e)});var i=a.util.createBuffer();if(t)for(;i.length()>16)))<<16,f=4294967295&(l=(2147483647&(l+=u>>15))+(l>>31));for(c=0;c<3;++c)p=f>>>(c<<3),p^=Math.floor(256*Math.random()),i.putByte(String.fromCharCode(255&p))}return i.getBytes(e)}return t.pools=i,t.pool=0,t.generate=function(e,r){if(!r)return t.generateSync(e);var n=t.plugin.cipher,i=t.plugin.increment,s=t.plugin.formatKey,o=t.plugin.formatSeed,u=a.util.createBuffer();t.key=null,function l(p){if(p)return r(p);if(u.length()>=e)return r(null,u.getBytes(e));t.generated>1048575&&(t.key=null);if(null===t.key)return a.util.nextTick((function(){!function(e){if(t.pools[0].messageLength>=32)return c(),e();var r=32-t.pools[0].messageLength<<5;t.seedFile(r,(function(r,a){if(r)return e(r);t.collect(a),c(),e()}))}(l)}));var f=n(t.key,t.seed);t.generated+=f.length,u.putBytes(f),t.key=s(n(t.key,i(t.seed))),t.seed=o(n(t.key,t.seed)),a.util.setImmediate(l)}()},t.generateSync=function(e){var r=t.plugin.cipher,n=t.plugin.increment,i=t.plugin.formatKey,s=t.plugin.formatSeed;t.key=null;for(var c=a.util.createBuffer();c.length()1048575&&(t.key=null),null===t.key&&o();var u=r(t.key,t.seed);t.generated+=u.length,c.putBytes(u),t.key=i(r(t.key,n(t.seed))),t.seed=s(r(t.key,t.seed))}return c.getBytes(e)},n?(t.seedFile=function(e,t){n.randomBytes(e,(function(e,r){if(e)return t(e);t(null,r.toString())}))},t.seedFileSync=function(e){return n.randomBytes(e).toString()}):(t.seedFile=function(e,t){try{t(null,u(e))}catch(e){t(e)}},t.seedFileSync=u),t.collect=function(e){for(var r=e.length,a=0;a>n&255);t.collect(a)},t.registerWorker=function(e){if(e===self)t.seedFile=function(e,t){self.addEventListener("message",(function e(r){var a=r.data;a.forge&&a.forge.prng&&(self.removeEventListener("message",e),t(a.forge.prng.err,a.forge.prng.bytes))})),self.postMessage({forge:{prng:{needed:e}}})};else{e.addEventListener("message",(function(r){var a=r.data;a.forge&&a.forge.prng&&t.seedFile(a.forge.prng.needed,(function(t,r){e.postMessage({forge:{prng:{err:t,bytes:r}}})}))}))}},t}},function(e,t,r){var a=r(0);r(1);var n=[217,120,249,196,25,221,181,237,40,233,253,121,74,160,216,157,198,126,55,131,43,118,83,142,98,76,100,136,68,139,251,162,23,154,89,245,135,179,79,19,97,69,109,141,9,129,125,50,189,143,64,235,134,183,123,11,240,149,33,34,92,107,78,130,84,214,101,147,206,96,178,28,115,86,192,20,167,140,241,220,18,117,202,31,59,190,228,209,66,61,212,48,163,60,182,38,111,191,14,218,70,105,7,87,39,242,29,155,188,148,67,3,248,17,199,246,144,239,62,231,6,195,213,47,200,102,30,215,8,232,234,222,128,82,238,247,132,170,114,172,53,77,106,42,150,26,210,113,90,21,73,116,75,159,208,94,4,24,164,236,194,224,65,110,15,81,203,204,36,145,175,80,161,244,112,57,153,124,58,133,35,184,180,122,252,2,54,91,37,85,151,49,45,93,250,152,227,138,146,174,5,223,41,16,103,108,186,201,211,0,230,207,225,158,168,44,99,22,1,63,88,226,137,169,13,56,52,27,171,51,255,176,187,72,12,95,185,177,205,46,197,243,219,71,229,165,156,119,10,166,32,104,254,127,193,173],i=[1,2,3,5],s=function(e,t){return e<>16-t},o=function(e,t){return(65535&e)>>t|e<<16-t&65535};e.exports=a.rc2=a.rc2||{},a.rc2.expandKey=function(e,t){"string"==typeof e&&(e=a.util.createBuffer(e)),t=t||128;var r,i=e,s=e.length(),o=t,c=Math.ceil(o/8),u=255>>(7&o);for(r=s;r<128;r++)i.putByte(n[i.at(r-1)+i.at(r-s)&255]);for(i.setAt(128-c,n[i.at(128-c)&u]),r=127-c;r>=0;r--)i.setAt(r,n[i.at(r+1)^i.at(r+c)]);return i};var c=function(e,t,r){var n,c,u,l,p=!1,f=null,h=null,d=null,y=[];for(e=a.rc2.expandKey(e,t),u=0;u<64;u++)y.push(e.getInt16Le());r?(n=function(e){for(u=0;u<4;u++)e[u]+=y[l]+(e[(u+3)%4]&e[(u+2)%4])+(~e[(u+3)%4]&e[(u+1)%4]),e[u]=s(e[u],i[u]),l++},c=function(e){for(u=0;u<4;u++)e[u]+=y[63&e[(u+3)%4]]}):(n=function(e){for(u=3;u>=0;u--)e[u]=o(e[u],i[u]),e[u]-=y[l]+(e[(u+3)%4]&e[(u+2)%4])+(~e[(u+3)%4]&e[(u+1)%4]),l--},c=function(e){for(u=3;u>=0;u--)e[u]-=y[63&e[(u+3)%4]]});var g=function(e){var t=[];for(u=0;u<4;u++){var a=f.getInt16Le();null!==d&&(r?a^=d.getInt16Le():d.putInt16Le(a)),t.push(65535&a)}l=r?0:63;for(var n=0;n=8;)g([[5,n],[1,c],[6,n],[1,c],[5,n]])},finish:function(e){var t=!0;if(r)if(e)t=e(8,f,!r);else{var a=8===f.length()?8:8-f.length();f.fillWithByte(a,a)}if(t&&(p=!0,m.update()),!r&&(t=0===f.length()))if(e)t=e(8,h,!r);else{var n=h.length(),i=h.at(n-1);i>n?t=!1:h.truncate(i)}return t}}};a.rc2.startEncrypting=function(e,t,r){var n=a.rc2.createEncryptionCipher(e,128);return n.start(t,r),n},a.rc2.createEncryptionCipher=function(e,t){return c(e,t,!0)},a.rc2.startDecrypting=function(e,t,r){var n=a.rc2.createDecryptionCipher(e,128);return n.start(t,r),n},a.rc2.createDecryptionCipher=function(e,t){return c(e,t,!1)}},function(e,t,r){var a=r(0);r(1),r(2),r(9);var n=e.exports=a.pkcs1=a.pkcs1||{};function i(e,t,r){r||(r=a.md.sha1.create());for(var n="",i=Math.ceil(t/r.digestLength),s=0;s>24&255,s>>16&255,s>>8&255,255&s);r.start(),r.update(e+o),n+=r.digest().getBytes()}return n.substring(0,t)}n.encode_rsa_oaep=function(e,t,r){var n,s,o,c;"string"==typeof r?(n=r,s=arguments[3]||void 0,o=arguments[4]||void 0):r&&(n=r.label||void 0,s=r.seed||void 0,o=r.md||void 0,r.mgf1&&r.mgf1.md&&(c=r.mgf1.md)),o?o.start():o=a.md.sha1.create(),c||(c=o);var u=Math.ceil(e.n.bitLength()/8),l=u-2*o.digestLength-2;if(t.length>l)throw(g=new Error("RSAES-OAEP input message length is too long.")).length=t.length,g.maxLength=l,g;n||(n=""),o.update(n,"raw");for(var p=o.digest(),f="",h=l-t.length,d=0;de&&(s=c(e,t));var h=s.toString(16);n.target.postMessage({hex:h,workLoad:l}),s.dAddOffset(p,0)}}}h()}(e,t,n,i);return o(e,t,n,i)}(e,u,i.options,n);throw new Error("Invalid prime generation algorithm: "+i.name)}}function o(e,t,r,i){var s=c(e,t),o=function(e){return e<=100?27:e<=150?18:e<=200?15:e<=250?12:e<=300?9:e<=350?8:e<=400?7:e<=500?6:e<=600?5:e<=800?4:e<=1250?3:2}(s.bitLength());"millerRabinTests"in r&&(o=r.millerRabinTests);var u=10;"maxBlockTime"in r&&(u=r.maxBlockTime),function e(t,r,i,s,o,u,l){var p=+new Date;do{if(t.bitLength()>r&&(t=c(r,i)),t.isProbablePrime(o))return l(null,t);t.dAddOffset(n[s++%8],0)}while(u<0||+new Date-p=0&&n.push(o):n.push(o))}return n}function h(e){if(e.composed||e.constructed){for(var t=a.util.createBuffer(),r=0;r0&&(c=n.create(n.Class.UNIVERSAL,n.Type.SET,!0,p));var f=[],h=[];null!==t&&(h=a.util.isArray(t)?t:[t]);for(var d=[],y=0;y0){var C=n.create(n.Class.UNIVERSAL,n.Type.SEQUENCE,!0,d),E=n.create(n.Class.UNIVERSAL,n.Type.SEQUENCE,!0,[n.create(n.Class.UNIVERSAL,n.Type.OID,!1,n.oidToDer(i.oids.data).getBytes()),n.create(n.Class.CONTEXT_SPECIFIC,0,!0,[n.create(n.Class.UNIVERSAL,n.Type.OCTETSTRING,!1,n.toDer(C).getBytes())])]);f.push(E)}var S=null;if(null!==e){var T=i.wrapRsaPrivateKey(i.privateKeyToAsn1(e));S=null===r?n.create(n.Class.UNIVERSAL,n.Type.SEQUENCE,!0,[n.create(n.Class.UNIVERSAL,n.Type.OID,!1,n.oidToDer(i.oids.keyBag).getBytes()),n.create(n.Class.CONTEXT_SPECIFIC,0,!0,[T]),c]):n.create(n.Class.UNIVERSAL,n.Type.SEQUENCE,!0,[n.create(n.Class.UNIVERSAL,n.Type.OID,!1,n.oidToDer(i.oids.pkcs8ShroudedKeyBag).getBytes()),n.create(n.Class.CONTEXT_SPECIFIC,0,!0,[i.encryptPrivateKeyInfo(T,r,o)]),c]);var I=n.create(n.Class.UNIVERSAL,n.Type.SEQUENCE,!0,[S]),b=n.create(n.Class.UNIVERSAL,n.Type.SEQUENCE,!0,[n.create(n.Class.UNIVERSAL,n.Type.OID,!1,n.oidToDer(i.oids.data).getBytes()),n.create(n.Class.CONTEXT_SPECIFIC,0,!0,[n.create(n.Class.UNIVERSAL,n.Type.OCTETSTRING,!1,n.toDer(I).getBytes())])]);f.push(b)}var A,B=n.create(n.Class.UNIVERSAL,n.Type.SEQUENCE,!0,f);if(o.useMac){var N=a.md.sha1.create(),k=new a.util.ByteBuffer(a.random.getBytes(o.saltSize)),w=o.count,R=(e=s.generateKey(r,k,3,w,20),a.hmac.create());R.start(N,e),R.update(n.toDer(B).getBytes());var _=R.getMac();A=n.create(n.Class.UNIVERSAL,n.Type.SEQUENCE,!0,[n.create(n.Class.UNIVERSAL,n.Type.SEQUENCE,!0,[n.create(n.Class.UNIVERSAL,n.Type.SEQUENCE,!0,[n.create(n.Class.UNIVERSAL,n.Type.OID,!1,n.oidToDer(i.oids.sha1).getBytes()),n.create(n.Class.UNIVERSAL,n.Type.NULL,!1,"")]),n.create(n.Class.UNIVERSAL,n.Type.OCTETSTRING,!1,_.getBytes())]),n.create(n.Class.UNIVERSAL,n.Type.OCTETSTRING,!1,k.getBytes()),n.create(n.Class.UNIVERSAL,n.Type.INTEGER,!1,n.integerToDer(w).getBytes())])}return n.create(n.Class.UNIVERSAL,n.Type.SEQUENCE,!0,[n.create(n.Class.UNIVERSAL,n.Type.INTEGER,!1,n.integerToDer(3).getBytes()),n.create(n.Class.UNIVERSAL,n.Type.SEQUENCE,!0,[n.create(n.Class.UNIVERSAL,n.Type.OID,!1,n.oidToDer(i.oids.data).getBytes()),n.create(n.Class.CONTEXT_SPECIFIC,0,!0,[n.create(n.Class.UNIVERSAL,n.Type.OCTETSTRING,!1,n.toDer(B).getBytes())])]),A])},s.generateKey=a.pbe.generatePkcs12Key},function(e,t,r){var a=r(0);r(3),r(1);var n=a.asn1,i=e.exports=a.pkcs7asn1=a.pkcs7asn1||{};a.pkcs7=a.pkcs7||{},a.pkcs7.asn1=i;var s={name:"ContentInfo",tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.ContentType",tagClass:n.Class.UNIVERSAL,type:n.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:n.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,captureAsn1:"content"}]};i.contentInfoValidator=s;var o={name:"EncryptedContentInfo",tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentType",tagClass:n.Class.UNIVERSAL,type:n.Type.OID,constructed:!1,capture:"contentType"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm",tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentEncryptionAlgorithm.algorithm",tagClass:n.Class.UNIVERSAL,type:n.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm.parameter",tagClass:n.Class.UNIVERSAL,captureAsn1:"encParameter"}]},{name:"EncryptedContentInfo.encryptedContent",tagClass:n.Class.CONTEXT_SPECIFIC,type:0,capture:"encryptedContent",captureAsn1:"encryptedContentAsn1"}]};i.envelopedDataValidator={name:"EnvelopedData",tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,value:[{name:"EnvelopedData.Version",tagClass:n.Class.UNIVERSAL,type:n.Type.INTEGER,constructed:!1,capture:"version"},{name:"EnvelopedData.RecipientInfos",tagClass:n.Class.UNIVERSAL,type:n.Type.SET,constructed:!0,captureAsn1:"recipientInfos"}].concat(o)},i.encryptedDataValidator={name:"EncryptedData",tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedData.Version",tagClass:n.Class.UNIVERSAL,type:n.Type.INTEGER,constructed:!1,capture:"version"}].concat(o)};var c={name:"SignerInfo",tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.version",tagClass:n.Class.UNIVERSAL,type:n.Type.INTEGER,constructed:!1},{name:"SignerInfo.issuerAndSerialNumber",tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.issuerAndSerialNumber.issuer",tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"SignerInfo.issuerAndSerialNumber.serialNumber",tagClass:n.Class.UNIVERSAL,type:n.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"SignerInfo.digestAlgorithm",tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.digestAlgorithm.algorithm",tagClass:n.Class.UNIVERSAL,type:n.Type.OID,constructed:!1,capture:"digestAlgorithm"},{name:"SignerInfo.digestAlgorithm.parameter",tagClass:n.Class.UNIVERSAL,constructed:!1,captureAsn1:"digestParameter",optional:!0}]},{name:"SignerInfo.authenticatedAttributes",tagClass:n.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"authenticatedAttributes"},{name:"SignerInfo.digestEncryptionAlgorithm",tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,capture:"signatureAlgorithm"},{name:"SignerInfo.encryptedDigest",tagClass:n.Class.UNIVERSAL,type:n.Type.OCTETSTRING,constructed:!1,capture:"signature"},{name:"SignerInfo.unauthenticatedAttributes",tagClass:n.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,capture:"unauthenticatedAttributes"}]};i.signedDataValidator={name:"SignedData",tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,value:[{name:"SignedData.Version",tagClass:n.Class.UNIVERSAL,type:n.Type.INTEGER,constructed:!1,capture:"version"},{name:"SignedData.DigestAlgorithms",tagClass:n.Class.UNIVERSAL,type:n.Type.SET,constructed:!0,captureAsn1:"digestAlgorithms"},s,{name:"SignedData.Certificates",tagClass:n.Class.CONTEXT_SPECIFIC,type:0,optional:!0,captureAsn1:"certificates"},{name:"SignedData.CertificateRevocationLists",tagClass:n.Class.CONTEXT_SPECIFIC,type:1,optional:!0,captureAsn1:"crls"},{name:"SignedData.SignerInfos",tagClass:n.Class.UNIVERSAL,type:n.Type.SET,capture:"signerInfos",optional:!0,value:[c]}]},i.recipientInfoValidator={name:"RecipientInfo",tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.version",tagClass:n.Class.UNIVERSAL,type:n.Type.INTEGER,constructed:!1,capture:"version"},{name:"RecipientInfo.issuerAndSerial",tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.issuerAndSerial.issuer",tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"RecipientInfo.issuerAndSerial.serialNumber",tagClass:n.Class.UNIVERSAL,type:n.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"RecipientInfo.keyEncryptionAlgorithm",tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.keyEncryptionAlgorithm.algorithm",tagClass:n.Class.UNIVERSAL,type:n.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"RecipientInfo.keyEncryptionAlgorithm.parameter",tagClass:n.Class.UNIVERSAL,constructed:!1,captureAsn1:"encParameter"}]},{name:"RecipientInfo.encryptedKey",tagClass:n.Class.UNIVERSAL,type:n.Type.OCTETSTRING,constructed:!1,capture:"encKey"}]}},function(e,t,r){var a=r(0);r(1),a.mgf=a.mgf||{},(e.exports=a.mgf.mgf1=a.mgf1=a.mgf1||{}).create=function(e){return{generate:function(t,r){for(var n=new a.util.ByteBuffer,i=Math.ceil(r/e.digestLength),s=0;s>>0,s>>>0];for(var o=h.fullMessageLength.length-1;o>=0;--o)h.fullMessageLength[o]+=s[1],s[1]=s[0]+(h.fullMessageLength[o]/4294967296>>>0),h.fullMessageLength[o]=h.fullMessageLength[o]>>>0,s[0]=s[1]/4294967296>>>0;return n.putBytes(e),l(r,i,n),(n.read>2048||0===n.length())&&n.compact(),h},h.digest=function(){var t=a.util.createBuffer();t.putBytes(n.bytes());var o,c=h.fullMessageLength[h.fullMessageLength.length-1]+h.messageLengthSize&h.blockLength-1;t.putBytes(s.substr(0,h.blockLength-c));for(var u=8*h.fullMessageLength[0],p=0;p>>0,t.putInt32(u>>>0),u=o>>>0;t.putInt32(u);var f=new Array(r.length);for(p=0;p=128;){for(R=0;R<16;++R)t[R][0]=r.getInt32()>>>0,t[R][1]=r.getInt32()>>>0;for(;R<80;++R)a=(((_=(U=t[R-2])[0])>>>19|(L=U[1])<<13)^(L>>>29|_<<3)^_>>>6)>>>0,n=((_<<13|L>>>19)^(L<<3|_>>>29)^(_<<26|L>>>6))>>>0,i=(((_=(P=t[R-15])[0])>>>1|(L=P[1])<<31)^(_>>>8|L<<24)^_>>>7)>>>0,s=((_<<31|L>>>1)^(_<<24|L>>>8)^(_<<25|L>>>7))>>>0,D=t[R-7],V=t[R-16],L=n+D[1]+s+V[1],t[R][0]=a+D[0]+i+V[0]+(L/4294967296>>>0)>>>0,t[R][1]=L>>>0;for(d=e[0][0],y=e[0][1],g=e[1][0],m=e[1][1],v=e[2][0],C=e[2][1],E=e[3][0],S=e[3][1],T=e[4][0],I=e[4][1],b=e[5][0],A=e[5][1],B=e[6][0],N=e[6][1],k=e[7][0],w=e[7][1],R=0;R<80;++R)l=((T>>>14|I<<18)^(T>>>18|I<<14)^(I>>>9|T<<23))>>>0,p=(B^T&(b^B))>>>0,o=((d>>>28|y<<4)^(y>>>2|d<<30)^(y>>>7|d<<25))>>>0,u=((d<<4|y>>>28)^(y<<30|d>>>2)^(y<<25|d>>>7))>>>0,f=(d&g|v&(d^g))>>>0,h=(y&m|C&(y^m))>>>0,L=w+(((T<<18|I>>>14)^(T<<14|I>>>18)^(I<<23|T>>>9))>>>0)+((N^I&(A^N))>>>0)+c[R][1]+t[R][1],a=k+l+p+c[R][0]+t[R][0]+(L/4294967296>>>0)>>>0,n=L>>>0,i=o+f+((L=u+h)/4294967296>>>0)>>>0,s=L>>>0,k=B,w=N,B=b,N=A,b=T,A=I,T=E+a+((L=S+n)/4294967296>>>0)>>>0,I=L>>>0,E=v,S=C,v=g,C=m,g=d,m=y,d=a+i+((L=n+s)/4294967296>>>0)>>>0,y=L>>>0;L=e[0][1]+y,e[0][0]=e[0][0]+d+(L/4294967296>>>0)>>>0,e[0][1]=L>>>0,L=e[1][1]+m,e[1][0]=e[1][0]+g+(L/4294967296>>>0)>>>0,e[1][1]=L>>>0,L=e[2][1]+C,e[2][0]=e[2][0]+v+(L/4294967296>>>0)>>>0,e[2][1]=L>>>0,L=e[3][1]+S,e[3][0]=e[3][0]+E+(L/4294967296>>>0)>>>0,e[3][1]=L>>>0,L=e[4][1]+I,e[4][0]=e[4][0]+T+(L/4294967296>>>0)>>>0,e[4][1]=L>>>0,L=e[5][1]+A,e[5][0]=e[5][0]+b+(L/4294967296>>>0)>>>0,e[5][1]=L>>>0,L=e[6][1]+N,e[6][0]=e[6][0]+B+(L/4294967296>>>0)>>>0,e[6][1]=L>>>0,L=e[7][1]+w,e[7][0]=e[7][0]+k+(L/4294967296>>>0)>>>0,e[7][1]=L>>>0,O-=128}}},function(e,t,r){var a=r(0);r(1),e.exports=a.log=a.log||{},a.log.levels=["none","error","warning","info","debug","verbose","max"];var n={},i=[],s=null;a.log.LEVEL_LOCKED=2,a.log.NO_LEVEL_CHECK=4,a.log.INTERPOLATE=8;for(var o=0;o0;)o.push(u%i),u=u/i|0}for(n=0;0===e[n]&&n=0;--n)a+=t[o[n]]}else a=function(e,t){var r=0,a=t.length,n=t.charAt(0),i=[0];for(r=0;r0;)i.push(o%a),o=o/a|0}var c="";for(r=0;0===e.at(r)&&r=0;--r)c+=t[i[r]];return c}(e,t);if(r){var l=new RegExp(".{1,"+r+"}","g");a=a.match(l).join("\r\n")}return a},r.decode=function(e,t){if("string"!=typeof e)throw new TypeError('"input" must be a string.');if("string"!=typeof t)throw new TypeError('"alphabet" must be a string.');var r=a[t];if(!r){r=a[t]=[];for(var n=0;n>=8;for(;l>0;)o.push(255&l),l>>=8}for(var p=0;e[p]===s&&p=n.Versions.TLS_1_1.minor&&c.output.putBytes(r),c.update(e.fragment),c.finish(o)&&(e.fragment=c.output,e.length=e.fragment.length(),i=!0),i}function o(e,t,r){if(!r){var a=e-t.length()%e;t.fillWithByte(a-1,a)}return!0}function c(e,t,r){var a=!0;if(r){for(var n=t.length(),i=t.last(),s=n-1-i;s=o?(e.fragment=s.output.getBytes(l-o),u=s.output.getBytes(o)):e.fragment=s.output.getBytes(),e.fragment=a.util.createBuffer(e.fragment),e.length=e.fragment.length();var p=t.macFunction(t.macKey,t.sequenceNumber,e);return t.updateSequenceNumber(),i=function(e,t,r){var n=a.hmac.create();return n.start("SHA1",e),n.update(t),t=n.digest().getBytes(),n.start(null,null),n.update(r),r=n.digest().getBytes(),t===r}(t.macKey,u,p)&&i}n.CipherSuites.TLS_RSA_WITH_AES_128_CBC_SHA={id:[0,47],name:"TLS_RSA_WITH_AES_128_CBC_SHA",initSecurityParameters:function(e){e.bulk_cipher_algorithm=n.BulkCipherAlgorithm.aes,e.cipher_type=n.CipherType.block,e.enc_key_length=16,e.block_length=16,e.fixed_iv_length=16,e.record_iv_length=16,e.mac_algorithm=n.MACAlgorithm.hmac_sha1,e.mac_length=20,e.mac_key_length=20},initConnectionState:i},n.CipherSuites.TLS_RSA_WITH_AES_256_CBC_SHA={id:[0,53],name:"TLS_RSA_WITH_AES_256_CBC_SHA",initSecurityParameters:function(e){e.bulk_cipher_algorithm=n.BulkCipherAlgorithm.aes,e.cipher_type=n.CipherType.block,e.enc_key_length=32,e.block_length=16,e.fixed_iv_length=16,e.record_iv_length=16,e.mac_algorithm=n.MACAlgorithm.hmac_sha1,e.mac_length=20,e.mac_key_length=20},initConnectionState:i}},function(e,t,r){var a=r(0);r(30),e.exports=a.mgf=a.mgf||{},a.mgf.mgf1=a.mgf1},function(e,t,r){var a=r(0);r(12),r(2),r(32),r(1);var n=r(41),i=n.publicKeyValidator,s=n.privateKeyValidator;if(void 0===o)var o=a.jsbn.BigInteger;var c=a.util.ByteBuffer,u="undefined"==typeof Buffer?Uint8Array:Buffer;a.pki=a.pki||{},e.exports=a.pki.ed25519=a.ed25519=a.ed25519||{};var l=a.ed25519;function p(e){var t=e.message;if(t instanceof Uint8Array||t instanceof u)return t;var r=e.encoding;if(void 0===t){if(!e.md)throw new TypeError('"options.message" or "options.md" not specified.');t=e.md.digest().getBytes(),r="binary"}if("string"==typeof t&&!r)throw new TypeError('"options.encoding" must be "binary" or "utf8".');if("string"==typeof t){if("undefined"!=typeof Buffer)return Buffer.from(t,r);t=new c(t,r)}else if(!(t instanceof c))throw new TypeError('"options.message" must be a node.js Buffer, a Uint8Array, a forge ByteBuffer, or a string with "options.encoding" specifying its encoding.');for(var a=new u(t.length()),n=0;n=0;--r)K(a,a),1!==r&&x(a,a,t);for(r=0;r<16;++r)e[r]=a[r]}(r,r),x(r,r,n),x(r,r,i),x(r,r,i),x(e[0],r,i),K(a,e[0]),x(a,a,i),N(a,n)&&x(e[0],e[0],C);if(K(a,e[0]),x(a,a,i),N(a,n))return-1;w(e[0])===t[31]>>7&&O(e[0],f,e[0]);return x(e[3],e[0],e[1]),0}(o,a))return-1;for(n=0;n=0};var f=P(),h=P([1]),d=P([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),y=P([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),g=P([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),m=P([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),v=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]),C=P([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function E(e,t){var r=a.md.sha512.create(),n=new c(e);r.update(n.getBytes(t),"binary");var i=r.digest().getBytes();if("undefined"!=typeof Buffer)return Buffer.from(i,"binary");for(var s=new u(l.constants.HASH_BYTE_LENGTH),o=0;o<64;++o)s[o]=i.charCodeAt(o);return s}function S(e,t){var r,a,n,i;for(a=63;a>=32;--a){for(r=0,n=a-32,i=a-12;n>8,t[n]-=256*r;t[n]+=r,t[a]=0}for(r=0,n=0;n<32;++n)t[n]+=r-(t[31]>>4)*v[n],r=t[n]>>8,t[n]&=255;for(n=0;n<32;++n)t[n]-=r*v[n];for(a=0;a<32;++a)t[a+1]+=t[a]>>8,e[a]=255&t[a]}function T(e){for(var t=new Float64Array(64),r=0;r<64;++r)t[r]=e[r],e[r]=0;S(e,t)}function I(e,t){var r=P(),a=P(),n=P(),i=P(),s=P(),o=P(),c=P(),u=P(),l=P();O(r,e[1],e[0]),O(l,t[1],t[0]),x(r,r,l),V(a,e[0],e[1]),V(l,t[0],t[1]),x(a,a,l),x(n,e[3],t[3]),x(n,n,y),x(i,e[2],t[2]),V(i,i,i),O(s,a,r),O(o,i,n),V(c,i,n),V(u,a,r),x(e[0],s,o),x(e[1],u,c),x(e[2],c,o),x(e[3],s,u)}function b(e,t,r){for(var a=0;a<4;++a)D(e[a],t[a],r)}function A(e,t){var r=P(),a=P(),n=P();!function(e,t){var r,a=P();for(r=0;r<16;++r)a[r]=t[r];for(r=253;r>=0;--r)K(a,a),2!==r&&4!==r&&x(a,a,t);for(r=0;r<16;++r)e[r]=a[r]}(n,t[2]),x(r,t[0],n),x(a,t[1],n),B(e,a),e[31]^=w(r)<<7}function B(e,t){var r,a,n,i=P(),s=P();for(r=0;r<16;++r)s[r]=t[r];for(U(s),U(s),U(s),a=0;a<2;++a){for(i[0]=s[0]-65517,r=1;r<15;++r)i[r]=s[r]-65535-(i[r-1]>>16&1),i[r-1]&=65535;i[15]=s[15]-32767-(i[14]>>16&1),n=i[15]>>16&1,i[14]&=65535,D(s,i,1-n)}for(r=0;r<16;r++)e[2*r]=255&s[r],e[2*r+1]=s[r]>>8}function N(e,t){var r=new u(32),a=new u(32);return B(r,e),B(a,t),k(r,0,a,0)}function k(e,t,r,a){return function(e,t,r,a,n){var i,s=0;for(i=0;i>>8)-1}(e,t,r,a,32)}function w(e){var t=new u(32);return B(t,e),1&t[0]}function R(e,t,r){var a,n;for(L(e[0],f),L(e[1],h),L(e[2],h),L(e[3],f),n=255;n>=0;--n)b(e,t,a=r[n/8|0]>>(7&n)&1),I(t,e),I(e,e),b(e,t,a)}function _(e,t){var r=[P(),P(),P(),P()];L(r[0],g),L(r[1],m),L(r[2],h),x(r[3],g,m),R(e,r,t)}function L(e,t){var r;for(r=0;r<16;r++)e[r]=0|t[r]}function U(e){var t,r,a=1;for(t=0;t<16;++t)r=e[t]+a+65535,a=Math.floor(r/65536),e[t]=r-65536*a;e[0]+=a-1+37*(a-1)}function D(e,t,r){for(var a,n=~(r-1),i=0;i<16;++i)a=n&(e[i]^t[i]),e[i]^=a,t[i]^=a}function P(e){var t,r=new Float64Array(16);if(e)for(t=0;t0&&(s=a.util.fillString(String.fromCharCode(0),c)+s),{encapsulation:t.encrypt(s,"NONE"),key:e.generate(s,i)}},decrypt:function(t,r,a){var n=t.decrypt(r,"NONE");return e.generate(n,a)}};return i},a.kem.kdf1=function(e,t){i(this,e,0,t||e.digestLength)},a.kem.kdf2=function(e,t){i(this,e,1,t||e.digestLength)}},function(e,t,r){e.exports=r(4),r(14),r(9),r(23),r(32)},function(e,t,r){var a=r(0);r(5),r(3),r(10),r(6),r(7),r(29),r(2),r(1),r(17);var n=a.asn1,i=e.exports=a.pkcs7=a.pkcs7||{};function s(e){var t={},r=[];if(!n.validate(e,i.asn1.recipientInfoValidator,t,r)){var s=new Error("Cannot read PKCS#7 RecipientInfo. ASN.1 object is not an PKCS#7 RecipientInfo.");throw s.errors=r,s}return{version:t.version.charCodeAt(0),issuer:a.pki.RDNAttributesAsArray(t.issuer),serialNumber:a.util.createBuffer(t.serial).toHex(),encryptedContent:{algorithm:n.derToOid(t.encAlgorithm),parameter:t.encParameter.value,content:t.encKey}}}function o(e){for(var t,r=[],i=0;i0){for(var r=n.create(n.Class.CONTEXT_SPECIFIC,1,!0,[]),i=0;i=r&&s0&&s.value[0].value.push(n.create(n.Class.CONTEXT_SPECIFIC,0,!0,t)),i.length>0&&s.value[0].value.push(n.create(n.Class.CONTEXT_SPECIFIC,1,!0,i)),s.value[0].value.push(n.create(n.Class.UNIVERSAL,n.Type.SET,!0,e.signerInfos)),n.create(n.Class.UNIVERSAL,n.Type.SEQUENCE,!0,[n.create(n.Class.UNIVERSAL,n.Type.OID,!1,n.oidToDer(e.type).getBytes()),s])},addSigner:function(t){var r=t.issuer,n=t.serialNumber;if(t.certificate){var i=t.certificate;"string"==typeof i&&(i=a.pki.certificateFromPem(i)),r=i.issuer.attributes,n=i.serialNumber}var s=t.key;if(!s)throw new Error("Could not add PKCS#7 signer; no private key specified.");"string"==typeof s&&(s=a.pki.privateKeyFromPem(s));var o=t.digestAlgorithm||a.pki.oids.sha1;switch(o){case a.pki.oids.sha1:case a.pki.oids.sha256:case a.pki.oids.sha384:case a.pki.oids.sha512:case a.pki.oids.md5:break;default:throw new Error("Could not add PKCS#7 signer; unknown message digest algorithm: "+o)}var c=t.authenticatedAttributes||[];if(c.length>0){for(var u=!1,l=!1,p=0;p="8"&&(r="00"+r);var n=a.util.hexToBytes(r);e.putInt32(n.length),e.putBytes(n)}function s(e,t){e.putInt32(t.length),e.putString(t)}function o(){for(var e=a.md.sha1.create(),t=arguments.length,r=0;r0&&(this.state=g[this.state].block)},m.prototype.unblock=function(e){return e=void 0===e?1:e,this.blocks-=e,0===this.blocks&&this.state!==f&&(this.state=u,v(this,0)),this.blocks},m.prototype.sleep=function(e){e=void 0===e?0:e,this.state=g[this.state].sleep;var t=this;this.timeoutId=setTimeout((function(){t.timeoutId=null,t.state=u,v(t,0)}),e)},m.prototype.wait=function(e){e.wait(this)},m.prototype.wakeup=function(){this.state===p&&(cancelTimeout(this.timeoutId),this.timeoutId=null,this.state=u,v(this,0))},m.prototype.cancel=function(){this.state=g[this.state].cancel,this.permitsNeeded=0,null!==this.timeoutId&&(cancelTimeout(this.timeoutId),this.timeoutId=null),this.subtasks=[]},m.prototype.fail=function(e){if(this.error=!0,C(this,!0),e)e.error=this.error,e.swapTime=this.swapTime,e.userData=this.userData,v(e,0);else{if(null!==this.parent){for(var t=this.parent;null!==t.parent;)t.error=this.error,t.swapTime=this.swapTime,t.userData=this.userData,t=t.parent;C(t,!0)}this.failureCallback&&this.failureCallback(this)}};var v=function(e,t){var r=t>30||+new Date-e.swapTime>20,a=function(t){if(t++,e.state===u)if(r&&(e.swapTime=+new Date),e.subtasks.length>0){var a=e.subtasks.shift();a.error=e.error,a.swapTime=e.swapTime,a.userData=e.userData,a.run(a),a.error||v(a,t)}else C(e),e.error||null!==e.parent&&(e.parent.error=e.error,e.parent.swapTime=e.swapTime,e.parent.userData=e.userData,v(e.parent,t))};r?setTimeout(a,0):a(t)},C=function(e,t){e.state=f,delete i[e.id],null===e.parent&&(e.type in o?0===o[e.type].length?a.log.error(n,"[%s][%s] task queue empty [%s]",e.id,e.name,e.type):o[e.type][0]!==e?a.log.error(n,"[%s][%s] task not first in queue [%s]",e.id,e.name,e.type):(o[e.type].shift(),0===o[e.type].length?delete o[e.type]:o[e.type][0].start()):a.log.error(n,"[%s][%s] task queue missing [%s]",e.id,e.name,e.type),t||(e.error&&e.failureCallback?e.failureCallback(e):!e.error&&e.successCallback&&e.successCallback(e)))};e.exports=a.task=a.task||{},a.task.start=function(e){var t=new m({run:e.run,name:e.name||"?"});t.type=e.type,t.successCallback=e.success||null,t.failureCallback=e.failure||null,t.type in o?o[e.type].push(t):(o[t.type]=[t],function(e){e.error=!1,e.state=g[e.state][y],setTimeout((function(){e.state===u&&(e.swapTime=+new Date,e.run(e),v(e,0))}),0)}(t))},a.task.cancel=function(e){e in o&&(o[e]=[o[e][0]])},a.task.createCondition=function(){var e={tasks:{},wait:function(t){t.id in e.tasks||(t.block(),e.tasks[t.id]=t)},notify:function(){var t=e.tasks;for(var r in e.tasks={},t)t[r].unblock()}};return e}}])})); +//# sourceMappingURL=forge.min.js.map \ No newline at end of file diff --git a/images/icon-128.png b/images/icon-128.png new file mode 100644 index 0000000..4938138 Binary files /dev/null and b/images/icon-128.png differ diff --git a/images/proxy_text.png b/images/proxy_text.png new file mode 100644 index 0000000..403c0a6 Binary files /dev/null and b/images/proxy_text.png differ diff --git a/license.js b/license.js new file mode 100644 index 0000000..ad72cd4 --- /dev/null +++ b/license.js @@ -0,0 +1,371 @@ +import { AES_CMAC } from "./cmac.js" +import { + compareUint8Arrays, + uint8ArrayToHex, + uint8ArrayToString, + stringToUint8Array, + stringToHex, + base64toUint8Array, uint8ArrayToBase64 +} from "./util.js" +const { ClientIdentification, DrmCertificate, EncryptedClientIdentification, License, LicenseRequest, LicenseType, + ProtocolVersion, SignedDrmCertificate, SignedMessage, WidevinePsshData } = protobuf.roots.default.license_protocol; + + +export const SERVICE_CERTIFICATE_CHALLENGE = new Uint8Array([0x08, 0x04]); + +const WIDEVINE_SYSTEM_ID = new Uint8Array([0xed, 0xef, 0x8b, 0xa9, 0x79, 0xd6, 0x4a, 0xce, 0xa3, 0xc8, 0x27, 0xdc, 0xd5, 0x1d, 0x21, 0xed]); +const PSSH_MAGIC = new Uint8Array([0x70, 0x73, 0x73, 0x68]) + +const WIDEVINE_ROOT_PUBLIC_KEY = new Uint8Array([ + 0x30, 0x82, 0x01, 0x8a, 0x02, 0x82, 0x01, 0x81, 0x00, 0xb4, 0xfe, 0x39, 0xc3, 0x65, 0x90, 0x03, 0xdb, 0x3c, 0x11, 0x97, 0x09, 0xe8, 0x68, 0xcd, + 0xf2, 0xc3, 0x5e, 0x9b, 0xf2, 0xe7, 0x4d, 0x23, 0xb1, 0x10, 0xdb, 0x87, 0x65, 0xdf, 0xdc, 0xfb, 0x9f, 0x35, 0xa0, 0x57, 0x03, 0x53, 0x4c, 0xf6, + 0x6d, 0x35, 0x7d, 0xa6, 0x78, 0xdb, 0xb3, 0x36, 0xd2, 0x3f, 0x9c, 0x40, 0xa9, 0x95, 0x26, 0x72, 0x7f, 0xb8, 0xbe, 0x66, 0xdf, 0xc5, 0x21, 0x98, + 0x78, 0x15, 0x16, 0x68, 0x5d, 0x2f, 0x46, 0x0e, 0x43, 0xcb, 0x8a, 0x84, 0x39, 0xab, 0xfb, 0xb0, 0x35, 0x80, 0x22, 0xbe, 0x34, 0x23, 0x8b, 0xab, + 0x53, 0x5b, 0x72, 0xec, 0x4b, 0xb5, 0x48, 0x69, 0x53, 0x3e, 0x47, 0x5f, 0xfd, 0x09, 0xfd, 0xa7, 0x76, 0x13, 0x8f, 0x0f, 0x92, 0xd6, 0x4c, 0xdf, + 0xae, 0x76, 0xa9, 0xba, 0xd9, 0x22, 0x10, 0xa9, 0x9d, 0x71, 0x45, 0xd6, 0xd7, 0xe1, 0x19, 0x25, 0x85, 0x9c, 0x53, 0x9a, 0x97, 0xeb, 0x84, 0xd7, + 0xcc, 0xa8, 0x88, 0x82, 0x20, 0x70, 0x26, 0x20, 0xfd, 0x7e, 0x40, 0x50, 0x27, 0xe2, 0x25, 0x93, 0x6f, 0xbc, 0x3e, 0x72, 0xa0, 0xfa, 0xc1, 0xbd, + 0x29, 0xb4, 0x4d, 0x82, 0x5c, 0xc1, 0xb4, 0xcb, 0x9c, 0x72, 0x7e, 0xb0, 0xe9, 0x8a, 0x17, 0x3e, 0x19, 0x63, 0xfc, 0xfd, 0x82, 0x48, 0x2b, 0xb7, + 0xb2, 0x33, 0xb9, 0x7d, 0xec, 0x4b, 0xba, 0x89, 0x1f, 0x27, 0xb8, 0x9b, 0x88, 0x48, 0x84, 0xaa, 0x18, 0x92, 0x0e, 0x65, 0xf5, 0xc8, 0x6c, 0x11, + 0xff, 0x6b, 0x36, 0xe4, 0x74, 0x34, 0xca, 0x8c, 0x33, 0xb1, 0xf9, 0xb8, 0x8e, 0xb4, 0xe6, 0x12, 0xe0, 0x02, 0x98, 0x79, 0x52, 0x5e, 0x45, 0x33, + 0xff, 0x11, 0xdc, 0xeb, 0xc3, 0x53, 0xba, 0x7c, 0x60, 0x1a, 0x11, 0x3d, 0x00, 0xfb, 0xd2, 0xb7, 0xaa, 0x30, 0xfa, 0x4f, 0x5e, 0x48, 0x77, 0x5b, + 0x17, 0xdc, 0x75, 0xef, 0x6f, 0xd2, 0x19, 0x6d, 0xdc, 0xbe, 0x7f, 0xb0, 0x78, 0x8f, 0xdc, 0x82, 0x60, 0x4c, 0xbf, 0xe4, 0x29, 0x06, 0x5e, 0x69, + 0x8c, 0x39, 0x13, 0xad, 0x14, 0x25, 0xed, 0x19, 0xb2, 0xf2, 0x9f, 0x01, 0x82, 0x0d, 0x56, 0x44, 0x88, 0xc8, 0x35, 0xec, 0x1f, 0x11, 0xb3, 0x24, + 0xe0, 0x59, 0x0d, 0x37, 0xe4, 0x47, 0x3c, 0xea, 0x4b, 0x7f, 0x97, 0x31, 0x1c, 0x81, 0x7c, 0x94, 0x8a, 0x4c, 0x7d, 0x68, 0x15, 0x84, 0xff, 0xa5, + 0x08, 0xfd, 0x18, 0xe7, 0xe7, 0x2b, 0xe4, 0x47, 0x27, 0x12, 0x11, 0xb8, 0x23, 0xec, 0x58, 0x93, 0x3c, 0xac, 0x12, 0xd2, 0x88, 0x6d, 0x41, 0x3d, + 0xc5, 0xfe, 0x1c, 0xdc, 0xb9, 0xf8, 0xd4, 0x51, 0x3e, 0x07, 0xe5, 0x03, 0x6f, 0xa7, 0x12, 0xe8, 0x12, 0xf7, 0xb5, 0xce, 0xa6, 0x96, 0x55, 0x3f, + 0x78, 0xb4, 0x64, 0x82, 0x50, 0xd2, 0x33, 0x5f, 0x91, 0x02, 0x03, 0x01, 0x00, 0x01 +]); + +const STAGING_PRIVACY_CERT = new Uint8Array([ + 0x0a, 0xbf, 0x02, 0x08, 0x03, 0x12, 0x10, 0x28, 0x70, 0x34, 0x54, 0xc0, 0x08, 0xf6, 0x36, 0x18, 0xad, 0xe7, 0x44, 0x3d, 0xb6, 0xc4, 0xc8, 0x18, + 0x8b, 0xe7, 0xf9, 0x90, 0x05, 0x22, 0x8e, 0x02, 0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, 0x00, 0xb5, 0x21, 0x12, 0xb8, 0xd0, 0x5d, 0x02, + 0x3f, 0xcc, 0x5d, 0x95, 0xe2, 0xc2, 0x51, 0xc1, 0xc6, 0x49, 0xb4, 0x17, 0x7c, 0xd8, 0xd2, 0xbe, 0xef, 0x35, 0x5b, 0xb0, 0x67, 0x43, 0xde, 0x66, + 0x1e, 0x3d, 0x2a, 0xbc, 0x31, 0x82, 0xb7, 0x99, 0x46, 0xd5, 0x5f, 0xdc, 0x08, 0xdf, 0xe9, 0x54, 0x07, 0x81, 0x5e, 0x9a, 0x62, 0x74, 0xb3, 0x22, + 0xa2, 0xc7, 0xf5, 0xe0, 0x67, 0xbb, 0x5f, 0x0a, 0xc0, 0x7a, 0x89, 0xd4, 0x5a, 0xea, 0x94, 0xb2, 0x51, 0x6f, 0x07, 0x5b, 0x66, 0xef, 0x81, 0x1d, + 0x0d, 0x26, 0xe1, 0xb9, 0xa6, 0xb8, 0x94, 0xf2, 0xb9, 0x85, 0x79, 0x62, 0xaa, 0x17, 0x1c, 0x4f, 0x66, 0x63, 0x0d, 0x3e, 0x4c, 0x60, 0x27, 0x18, + 0x89, 0x7f, 0x5e, 0x1e, 0xf9, 0xb6, 0xaa, 0xf5, 0xad, 0x4d, 0xba, 0x2a, 0x7e, 0x14, 0x17, 0x6d, 0xf1, 0x34, 0xa1, 0xd3, 0x18, 0x5b, 0x5a, 0x21, + 0x8a, 0xc0, 0x5a, 0x4c, 0x41, 0xf0, 0x81, 0xef, 0xff, 0x80, 0xa3, 0xa0, 0x40, 0xc5, 0x0b, 0x09, 0xbb, 0xc7, 0x40, 0xee, 0xdc, 0xd8, 0xf1, 0x4d, + 0x67, 0x5a, 0x91, 0x98, 0x0f, 0x92, 0xca, 0x7d, 0xdc, 0x64, 0x6a, 0x06, 0xad, 0xad, 0x51, 0x01, 0xf7, 0x4a, 0x0e, 0x49, 0x8c, 0xc0, 0x1f, 0x00, + 0x53, 0x2b, 0xac, 0x21, 0x78, 0x50, 0xbd, 0x90, 0x5e, 0x90, 0x92, 0x36, 0x56, 0xb7, 0xdf, 0xef, 0xef, 0x42, 0x48, 0x67, 0x67, 0xf3, 0x3e, 0xf6, + 0x28, 0x3d, 0x4f, 0x42, 0x54, 0xab, 0x72, 0x58, 0x93, 0x90, 0xbe, 0xe5, 0x58, 0x08, 0xf1, 0xd6, 0x68, 0x08, 0x0d, 0x45, 0xd8, 0x93, 0xc2, 0xbc, + 0xa2, 0xf7, 0x4d, 0x60, 0xa0, 0xc0, 0xd0, 0xa0, 0x99, 0x3c, 0xef, 0x01, 0x60, 0x47, 0x03, 0x33, 0x4c, 0x36, 0x38, 0x13, 0x94, 0x86, 0xbc, 0x9d, + 0xaf, 0x24, 0xfd, 0x67, 0xa0, 0x7f, 0x9a, 0xd9, 0x43, 0x02, 0x03, 0x01, 0x00, 0x01, 0x3a, 0x12, 0x73, 0x74, 0x61, 0x67, 0x69, 0x6e, 0x67, 0x2e, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x12, 0x80, 0x03, 0x98, 0x3e, 0x30, 0x35, 0x26, 0x75, 0xf4, 0x0b, 0xa7, 0x15, 0xfc, + 0x24, 0x9b, 0xda, 0xe5, 0xd4, 0xac, 0x72, 0x49, 0xa2, 0x66, 0x65, 0x21, 0xe4, 0x36, 0x55, 0x73, 0x95, 0x29, 0x72, 0x1f, 0xf8, 0x80, 0xe0, 0xaa, + 0xef, 0xc5, 0xe2, 0x7b, 0xc9, 0x80, 0xda, 0xea, 0xda, 0xbf, 0x3f, 0xc3, 0x86, 0xd0, 0x84, 0xa0, 0x2c, 0x82, 0x53, 0x78, 0x48, 0xcc, 0x75, 0x3f, + 0xf4, 0x97, 0xb0, 0x11, 0xa7, 0xda, 0x97, 0x78, 0x8a, 0x00, 0xe2, 0xaa, 0x6b, 0x84, 0xcd, 0x7d, 0x71, 0xc0, 0x7a, 0x48, 0xeb, 0xf6, 0x16, 0x02, + 0xcc, 0xa5, 0xa3, 0xf3, 0x20, 0x30, 0xa7, 0x29, 0x5c, 0x30, 0xda, 0x91, 0x5b, 0x91, 0xdc, 0x18, 0xb9, 0xbc, 0x95, 0x93, 0xb8, 0xde, 0x8b, 0xb5, + 0x0f, 0x0d, 0xed, 0xc1, 0x29, 0x38, 0xb8, 0xe9, 0xe0, 0x39, 0xcd, 0xde, 0x18, 0xfa, 0x82, 0xe8, 0x1b, 0xb0, 0x32, 0x63, 0x0f, 0xe9, 0x55, 0xd8, + 0x5a, 0x56, 0x6c, 0xe1, 0x54, 0x30, 0x0b, 0xf6, 0xd4, 0xc1, 0xbd, 0x12, 0x69, 0x66, 0x35, 0x6b, 0x28, 0x7d, 0x65, 0x7b, 0x18, 0xce, 0x63, 0xd0, + 0xef, 0xd4, 0x5f, 0xc5, 0x26, 0x9e, 0x97, 0xea, 0xb1, 0x1c, 0xb5, 0x63, 0xe5, 0x56, 0x43, 0xb2, 0x6f, 0xf4, 0x9f, 0x10, 0x9c, 0x21, 0x01, 0xaf, + 0xca, 0xf3, 0x5b, 0x83, 0x2f, 0x28, 0x8f, 0x0d, 0x9d, 0x45, 0x96, 0x0e, 0x25, 0x9e, 0x85, 0xfb, 0x5d, 0x24, 0xdb, 0xd2, 0xcf, 0x82, 0x76, 0x4c, + 0x5d, 0xd9, 0xbf, 0x72, 0x7e, 0xfb, 0xe9, 0xc8, 0x61, 0xf8, 0x69, 0x32, 0x1f, 0x6a, 0xde, 0x18, 0x90, 0x5f, 0x4d, 0x92, 0xf9, 0xa6, 0xda, 0x65, + 0x36, 0xdb, 0x84, 0x75, 0x87, 0x1d, 0x16, 0x8e, 0x87, 0x0b, 0xb2, 0x30, 0x3c, 0xf7, 0x0c, 0x6e, 0x97, 0x84, 0xc9, 0x3d, 0x2d, 0xe8, 0x45, 0xad, + 0x82, 0x62, 0xbe, 0x7e, 0x0d, 0x4e, 0x2e, 0x4a, 0x07, 0x59, 0xce, 0xf8, 0x2d, 0x10, 0x9d, 0x25, 0x92, 0xc7, 0x24, 0x29, 0xf8, 0xc0, 0x17, 0x42, + 0xba, 0xe2, 0xb3, 0xde, 0xca, 0xdb, 0xc3, 0x3c, 0x3e, 0x5f, 0x4b, 0xaf, 0x5e, 0x16, 0xec, 0xb7, 0x4e, 0xad, 0xba, 0xfc, 0xb7, 0xc6, 0x70, 0x5f, + 0x7a, 0x9e, 0x3b, 0x6f, 0x39, 0x40, 0x38, 0x3f, 0x9c, 0x51, 0x16, 0xd2, 0x02, 0xa2, 0x0c, 0x92, 0x29, 0xee, 0x96, 0x9c, 0x25, 0x19, 0x71, 0x83, + 0x03, 0xb5, 0x0d, 0x01, 0x30, 0xc3, 0x35, 0x2e, 0x06, 0xb0, 0x14, 0xd8, 0x38, 0x54, 0x0f, 0x8a, 0x0c, 0x22, 0x7c, 0x00, 0x11, 0xe0, 0xf5, 0xb3, + 0x8e, 0x4e, 0x29, 0x8e, 0xd2, 0xcb, 0x30, 0x1e, 0xb4, 0x56, 0x49, 0x65, 0xf5, 0x5c, 0x5d, 0x79, 0x75, 0x7a, 0x25, 0x0a, 0x4e, 0xb9, 0xc8, 0x4a, + 0xb3, 0xe6, 0x53, 0x9f, 0x6b, 0x6f, 0xdf, 0x56, 0x89, 0x9e, 0xa2, 0x99, 0x14 +]) + + +export class Session { + constructor(contentDecryptionModule, pssh) { + this._devicePrivateKey = forge.pki.privateKeyFromPem( + contentDecryptionModule.privateKey + ) + this._identifierBlob = ClientIdentification.decode( + contentDecryptionModule.identifierBlob + ) + if (typeof pssh === "string") { + pssh = base64toUint8Array(pssh) + } + this._pssh = pssh + } + + async setDefaultServiceCertificate() { + await this.setServiceCertificate(STAGING_PRIVACY_CERT) + } + + async setServiceCertificateFromMessage(rawSignedMessage) { + const signedMessage = SignedMessage.decode(new Uint8Array(rawSignedMessage)) + if (!signedMessage.msg) { + throw new Error( + "the service certificate message does not contain a message" + ) + } + await this.setServiceCertificate(signedMessage.msg) + } + + async setServiceCertificate(serviceCertificate) { + const signedServiceCertificate = SignedDrmCertificate.decode( + serviceCertificate + ) + if (!(await this._verifyServiceCertificate(signedServiceCertificate))) { + throw new Error( + "Service certificate is not signed by the Widevine root certificate" + ) + } + this._serviceCertificate = signedServiceCertificate + } + + createLicenseRequest(licenseType = LicenseType.STREAMING, android = false) { + if (compareUint8Arrays(this._pssh.subarray(4, 8), PSSH_MAGIC)) { + if (compareUint8Arrays(this._pssh.subarray(12, 28), WIDEVINE_SYSTEM_ID)) { + this._pssh = this._pssh.subarray(32) + } else { + throw new Error(`Invalid System ID in PSSH Box: ${uint8ArrayToHex(this._pssh.subarray(12, 28))}`) + } + } + + const pssh = this._parseWidevinePsshData(this._pssh) + if (!pssh) { + throw new Error("Invalid WidevinePsshData found") + } + + const request_id = android ? this._generateAndroidIdentifier() : this._generateGenericIdentifier(); + const licenseRequest = new LicenseRequest({ + type: LicenseRequest.RequestType.NEW, + contentId: new LicenseRequest.ContentIdentification({ + widevinePsshData: new LicenseRequest.ContentIdentification.WidevinePsshData({ + psshData: [this._pssh], + licenseType: licenseType, + requestId: request_id + }) + }), + requestTime: Math.floor(Date.now() / 1000), // BigInt(Date.now()) / BigInt(1000), + protocolVersion: ProtocolVersion.VERSION_2_1, + keyControlNonce: Math.floor(Math.random() * 2 ** 31) + }) + + if (this._serviceCertificate) { + licenseRequest.encryptedClientId = this._encryptClientIdentification( + this._identifierBlob, + this._serviceCertificate + ) + } else { + licenseRequest.clientId = this._identifierBlob + } + + this._rawLicenseRequest = LicenseRequest.encode(licenseRequest).finish() + + const pss = forge.pss.create({ + md: forge.md.sha1.create(), + mgf: forge.mgf.mgf1.create(forge.md.sha1.create()), + saltLength: 20 + }) + + const md = forge.md.sha1.create() + md.update(uint8ArrayToString(this._rawLicenseRequest), "raw") + + const signature = stringToUint8Array(this._devicePrivateKey.sign(md, pss)) + const signedLicenseRequest = new SignedMessage({ + type: SignedMessage.MessageType.LICENSE_REQUEST, + msg: this._rawLicenseRequest, + signature: signature + }) + + return [SignedMessage.encode(signedLicenseRequest).finish(), request_id] + } + + async parseLicense(rawLicense) { + if (!this._rawLicenseRequest) { + throw new Error("please request a license first") + } + + const signedLicense = SignedMessage.decode(new Uint8Array(rawLicense)) + if (!signedLicense.sessionKey) { + throw new Error("the license does not contain a session key") + } + if (!signedLicense.msg) { + throw new Error("the license does not contain a message") + } + if (!signedLicense.signature) { + throw new Error("the license does not contain a signature") + } + + const sessionKey = this._devicePrivateKey.decrypt( + uint8ArrayToString(signedLicense.sessionKey), + "RSA-OAEP", + { + md: forge.md.sha1.create() + } + ) + + const cmac = new AES_CMAC(stringToUint8Array(sessionKey)) + const encKeyBase = new Uint8Array([ + ...stringToUint8Array("ENCRYPTION"), + ...new Uint8Array([0x00]), + ...this._rawLicenseRequest, + ...new Uint8Array([0x00, 0x00, 0x00, 0x80]) + ]) + const authKeyBase = new Uint8Array([ + ...stringToUint8Array("AUTHENTICATION"), + ...new Uint8Array([0x00]), + ...this._rawLicenseRequest, + ...new Uint8Array([0x00, 0x00, 0x02, 0x00]) + ]) + + const encKey = await cmac.calculate( + new Uint8Array([ + ...new Uint8Array([0x01]), + ...encKeyBase + ]) + ) + + const server_key_1 = await cmac.calculate(new Uint8Array([ + ...new Uint8Array([0x01]), + ...authKeyBase + ])) + const server_key_2 = await cmac.calculate(new Uint8Array([ + ...new Uint8Array([0x02]), + ...authKeyBase + ])) + const serverKey = new Uint8Array([ + ...new Uint8Array(server_key_1), + ...new Uint8Array(server_key_2) + ]) + + const hmac = forge.hmac.create() + hmac.start(forge.md.sha256.create(), uint8ArrayToString(serverKey), "raw") + hmac.update(uint8ArrayToString(signedLicense.msg)) + const calculatedSignature = stringToUint8Array(hmac.digest().data) + + if (!compareUint8Arrays(calculatedSignature, signedLicense.signature)) { + throw new Error("signatures do not match") + } + + const license = License.decode(signedLicense.msg) + + const keyContainers = license.key.map(keyContainer => { + if (keyContainer.type && keyContainer.type === 2 && keyContainer.key && keyContainer.iv) { + const keyBuffer = forge.util.createBuffer(encKey, 'raw'); + const decipher = forge.cipher.createDecipher( + "AES-CBC", + keyBuffer + ) + + decipher.start({ + iv: uint8ArrayToString(keyContainer.iv) + }) + decipher.update(forge.util.createBuffer(keyContainer.key)) + decipher.finish() + + return { + kid: keyContainer.id.length !== 0 ? uint8ArrayToHex(keyContainer.id) : "00000000000000000000000000000000", + k: stringToHex(decipher.output.data) + } + } + }) + const valid_containers = keyContainers.filter(container => !!container); + if (valid_containers.length < 1) { + throw new Error("there was not a single valid key in the response") + } + return valid_containers; + } + + _encryptClientIdentification(clientIdentification, signedServiceCertificate) { + if (!signedServiceCertificate.drmCertificate) { + throw new Error( + "the service certificate does not contain an actual certificate" + ) + } + + const serviceCertificate = DrmCertificate.decode( + signedServiceCertificate.drmCertificate + ) + console.log("[WidevineProxy2]", "SERVICE_CERTIFICATE", serviceCertificate); + + if (!serviceCertificate.publicKey) { + throw new Error("the service certificate does not contain a public key") + } + + const key = forge.random.getBytesSync(16) + const iv = forge.random.getBytesSync(16) + + const cipher = forge.cipher.createCipher("AES-CBC", key) + cipher.start({ + iv: iv + }) + cipher.update( + forge.util.createBuffer( + ClientIdentification.encode(clientIdentification).finish() + ) + ) + cipher.finish() + const rawEncryptedClientIdentification = stringToUint8Array(cipher.output.data) + + const publicKey = forge.pki.publicKeyFromAsn1( + forge.asn1.fromDer( + uint8ArrayToString(serviceCertificate.publicKey) + ) + ) + const encryptedKey = publicKey.encrypt(key, "RSA-OAEP", { + md: forge.md.sha1.create() + }) + + return new EncryptedClientIdentification({ + encryptedClientId: rawEncryptedClientIdentification, + encryptedClientIdIv: stringToUint8Array(iv), + encryptedPrivacyKey: stringToUint8Array(encryptedKey), + providerId: serviceCertificate.providerId, + serviceCertificateSerialNumber: serviceCertificate.serialNumber + }) + } + + async _verifyServiceCertificate(signedServiceCertificate) { + if (!signedServiceCertificate.drmCertificate) { + throw new Error( + "the service certificate does not contain an actual certificate" + ) + } + if (!signedServiceCertificate.signature) { + throw new Error("the service certificate does not contain a signature") + } + + const pss = forge.pss.create({ + md: forge.md.sha1.create(), + mgf: forge.mgf.mgf1.create(forge.md.sha1.create()), + saltLength: 20 + }) + + const sha1 = forge.md.sha1.create() + sha1.update( + uint8ArrayToString(signedServiceCertificate.drmCertificate), + "raw" + ) + + const publicKey = forge.pki.publicKeyFromAsn1( + forge.asn1.fromDer( + uint8ArrayToString(WIDEVINE_ROOT_PUBLIC_KEY) + ) + ) + + return publicKey.verify( + sha1.digest().bytes(), + uint8ArrayToString(signedServiceCertificate.signature), + pss + ) + } + + _parseWidevinePsshData(pssh) { + try { + return WidevinePsshData.decode(pssh) + } catch { + return null + } + } + + _generateAndroidIdentifier() { + return stringToUint8Array(`${forge.util.bytesToHex(forge.random.getBytesSync(8))}0100000000000000`) + } + + _generateGenericIdentifier() { + return forge.random.getBytesSync(16) + } + + getPSSH() { + return uint8ArrayToBase64(this._pssh); + } +} diff --git a/license_protocol.js b/license_protocol.js new file mode 100644 index 0000000..edbcc6c --- /dev/null +++ b/license_protocol.js @@ -0,0 +1,11727 @@ +/*eslint-disable block-scoped-var, id-length, no-control-regex, no-magic-numbers, no-prototype-builtins, no-redeclare, no-shadow, no-var, sort-vars*/ +(function($protobuf) { + "use strict"; + + // Common aliases + var $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util; + + // Exported root namespace + var $root = $protobuf.roots["default"] || ($protobuf.roots["default"] = {}); + + $root.license_protocol = (function() { + + /** + * Namespace license_protocol. + * @exports license_protocol + * @namespace + */ + var license_protocol = {}; + + /** + * LicenseType enum. + * @name license_protocol.LicenseType + * @enum {number} + * @property {number} STREAMING=1 STREAMING value + * @property {number} OFFLINE=2 OFFLINE value + * @property {number} AUTOMATIC=3 AUTOMATIC value + */ + license_protocol.LicenseType = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[1] = "STREAMING"] = 1; + values[valuesById[2] = "OFFLINE"] = 2; + values[valuesById[3] = "AUTOMATIC"] = 3; + return values; + })(); + + /** + * PlatformVerificationStatus enum. + * @name license_protocol.PlatformVerificationStatus + * @enum {number} + * @property {number} PLATFORM_UNVERIFIED=0 PLATFORM_UNVERIFIED value + * @property {number} PLATFORM_TAMPERED=1 PLATFORM_TAMPERED value + * @property {number} PLATFORM_SOFTWARE_VERIFIED=2 PLATFORM_SOFTWARE_VERIFIED value + * @property {number} PLATFORM_HARDWARE_VERIFIED=3 PLATFORM_HARDWARE_VERIFIED value + * @property {number} PLATFORM_NO_VERIFICATION=4 PLATFORM_NO_VERIFICATION value + * @property {number} PLATFORM_SECURE_STORAGE_SOFTWARE_VERIFIED=5 PLATFORM_SECURE_STORAGE_SOFTWARE_VERIFIED value + */ + license_protocol.PlatformVerificationStatus = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "PLATFORM_UNVERIFIED"] = 0; + values[valuesById[1] = "PLATFORM_TAMPERED"] = 1; + values[valuesById[2] = "PLATFORM_SOFTWARE_VERIFIED"] = 2; + values[valuesById[3] = "PLATFORM_HARDWARE_VERIFIED"] = 3; + values[valuesById[4] = "PLATFORM_NO_VERIFICATION"] = 4; + values[valuesById[5] = "PLATFORM_SECURE_STORAGE_SOFTWARE_VERIFIED"] = 5; + return values; + })(); + + license_protocol.LicenseIdentification = (function() { + + /** + * Properties of a LicenseIdentification. + * @memberof license_protocol + * @interface ILicenseIdentification + * @property {Uint8Array|null} [requestId] LicenseIdentification requestId + * @property {Uint8Array|null} [sessionId] LicenseIdentification sessionId + * @property {Uint8Array|null} [purchaseId] LicenseIdentification purchaseId + * @property {license_protocol.LicenseType|null} [type] LicenseIdentification type + * @property {number|null} [version] LicenseIdentification version + * @property {Uint8Array|null} [providerSessionToken] LicenseIdentification providerSessionToken + */ + + /** + * Constructs a new LicenseIdentification. + * @memberof license_protocol + * @classdesc Represents a LicenseIdentification. + * @implements ILicenseIdentification + * @constructor + * @param {license_protocol.ILicenseIdentification=} [properties] Properties to set + */ + function LicenseIdentification(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * LicenseIdentification requestId. + * @member {Uint8Array} requestId + * @memberof license_protocol.LicenseIdentification + * @instance + */ + LicenseIdentification.prototype.requestId = $util.newBuffer([]); + + /** + * LicenseIdentification sessionId. + * @member {Uint8Array} sessionId + * @memberof license_protocol.LicenseIdentification + * @instance + */ + LicenseIdentification.prototype.sessionId = $util.newBuffer([]); + + /** + * LicenseIdentification purchaseId. + * @member {Uint8Array} purchaseId + * @memberof license_protocol.LicenseIdentification + * @instance + */ + LicenseIdentification.prototype.purchaseId = $util.newBuffer([]); + + /** + * LicenseIdentification type. + * @member {license_protocol.LicenseType} type + * @memberof license_protocol.LicenseIdentification + * @instance + */ + LicenseIdentification.prototype.type = 1; + + /** + * LicenseIdentification version. + * @member {number} version + * @memberof license_protocol.LicenseIdentification + * @instance + */ + LicenseIdentification.prototype.version = 0; + + /** + * LicenseIdentification providerSessionToken. + * @member {Uint8Array} providerSessionToken + * @memberof license_protocol.LicenseIdentification + * @instance + */ + LicenseIdentification.prototype.providerSessionToken = $util.newBuffer([]); + + /** + * Creates a new LicenseIdentification instance using the specified properties. + * @function create + * @memberof license_protocol.LicenseIdentification + * @static + * @param {license_protocol.ILicenseIdentification=} [properties] Properties to set + * @returns {license_protocol.LicenseIdentification} LicenseIdentification instance + */ + LicenseIdentification.create = function create(properties) { + return new LicenseIdentification(properties); + }; + + /** + * Encodes the specified LicenseIdentification message. Does not implicitly {@link license_protocol.LicenseIdentification.verify|verify} messages. + * @function encode + * @memberof license_protocol.LicenseIdentification + * @static + * @param {license_protocol.ILicenseIdentification} message LicenseIdentification message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + LicenseIdentification.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.requestId != null && Object.hasOwnProperty.call(message, "requestId")) + writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.requestId); + if (message.sessionId != null && Object.hasOwnProperty.call(message, "sessionId")) + writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.sessionId); + if (message.purchaseId != null && Object.hasOwnProperty.call(message, "purchaseId")) + writer.uint32(/* id 3, wireType 2 =*/26).bytes(message.purchaseId); + if (message.type != null && Object.hasOwnProperty.call(message, "type")) + writer.uint32(/* id 4, wireType 0 =*/32).int32(message.type); + if (message.version != null && Object.hasOwnProperty.call(message, "version")) + writer.uint32(/* id 5, wireType 0 =*/40).int32(message.version); + if (message.providerSessionToken != null && Object.hasOwnProperty.call(message, "providerSessionToken")) + writer.uint32(/* id 6, wireType 2 =*/50).bytes(message.providerSessionToken); + return writer; + }; + + /** + * Encodes the specified LicenseIdentification message, length delimited. Does not implicitly {@link license_protocol.LicenseIdentification.verify|verify} messages. + * @function encodeDelimited + * @memberof license_protocol.LicenseIdentification + * @static + * @param {license_protocol.ILicenseIdentification} message LicenseIdentification message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + LicenseIdentification.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a LicenseIdentification message from the specified reader or buffer. + * @function decode + * @memberof license_protocol.LicenseIdentification + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {license_protocol.LicenseIdentification} LicenseIdentification + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + LicenseIdentification.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.license_protocol.LicenseIdentification(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.requestId = reader.bytes(); + break; + } + case 2: { + message.sessionId = reader.bytes(); + break; + } + case 3: { + message.purchaseId = reader.bytes(); + break; + } + case 4: { + message.type = reader.int32(); + break; + } + case 5: { + message.version = reader.int32(); + break; + } + case 6: { + message.providerSessionToken = reader.bytes(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a LicenseIdentification message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof license_protocol.LicenseIdentification + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {license_protocol.LicenseIdentification} LicenseIdentification + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + LicenseIdentification.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a LicenseIdentification message. + * @function verify + * @memberof license_protocol.LicenseIdentification + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + LicenseIdentification.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.requestId != null && message.hasOwnProperty("requestId")) + if (!(message.requestId && typeof message.requestId.length === "number" || $util.isString(message.requestId))) + return "requestId: buffer expected"; + if (message.sessionId != null && message.hasOwnProperty("sessionId")) + if (!(message.sessionId && typeof message.sessionId.length === "number" || $util.isString(message.sessionId))) + return "sessionId: buffer expected"; + if (message.purchaseId != null && message.hasOwnProperty("purchaseId")) + if (!(message.purchaseId && typeof message.purchaseId.length === "number" || $util.isString(message.purchaseId))) + return "purchaseId: buffer expected"; + if (message.type != null && message.hasOwnProperty("type")) + switch (message.type) { + default: + return "type: enum value expected"; + case 1: + case 2: + case 3: + break; + } + if (message.version != null && message.hasOwnProperty("version")) + if (!$util.isInteger(message.version)) + return "version: integer expected"; + if (message.providerSessionToken != null && message.hasOwnProperty("providerSessionToken")) + if (!(message.providerSessionToken && typeof message.providerSessionToken.length === "number" || $util.isString(message.providerSessionToken))) + return "providerSessionToken: buffer expected"; + return null; + }; + + /** + * Creates a LicenseIdentification message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof license_protocol.LicenseIdentification + * @static + * @param {Object.} object Plain object + * @returns {license_protocol.LicenseIdentification} LicenseIdentification + */ + LicenseIdentification.fromObject = function fromObject(object) { + if (object instanceof $root.license_protocol.LicenseIdentification) + return object; + var message = new $root.license_protocol.LicenseIdentification(); + if (object.requestId != null) + if (typeof object.requestId === "string") + $util.base64.decode(object.requestId, message.requestId = $util.newBuffer($util.base64.length(object.requestId)), 0); + else if (object.requestId.length >= 0) + message.requestId = object.requestId; + if (object.sessionId != null) + if (typeof object.sessionId === "string") + $util.base64.decode(object.sessionId, message.sessionId = $util.newBuffer($util.base64.length(object.sessionId)), 0); + else if (object.sessionId.length >= 0) + message.sessionId = object.sessionId; + if (object.purchaseId != null) + if (typeof object.purchaseId === "string") + $util.base64.decode(object.purchaseId, message.purchaseId = $util.newBuffer($util.base64.length(object.purchaseId)), 0); + else if (object.purchaseId.length >= 0) + message.purchaseId = object.purchaseId; + switch (object.type) { + default: + if (typeof object.type === "number") { + message.type = object.type; + break; + } + break; + case "STREAMING": + case 1: + message.type = 1; + break; + case "OFFLINE": + case 2: + message.type = 2; + break; + case "AUTOMATIC": + case 3: + message.type = 3; + break; + } + if (object.version != null) + message.version = object.version | 0; + if (object.providerSessionToken != null) + if (typeof object.providerSessionToken === "string") + $util.base64.decode(object.providerSessionToken, message.providerSessionToken = $util.newBuffer($util.base64.length(object.providerSessionToken)), 0); + else if (object.providerSessionToken.length >= 0) + message.providerSessionToken = object.providerSessionToken; + return message; + }; + + /** + * Creates a plain object from a LicenseIdentification message. Also converts values to other types if specified. + * @function toObject + * @memberof license_protocol.LicenseIdentification + * @static + * @param {license_protocol.LicenseIdentification} message LicenseIdentification + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + LicenseIdentification.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + if (options.bytes === String) + object.requestId = ""; + else { + object.requestId = []; + if (options.bytes !== Array) + object.requestId = $util.newBuffer(object.requestId); + } + if (options.bytes === String) + object.sessionId = ""; + else { + object.sessionId = []; + if (options.bytes !== Array) + object.sessionId = $util.newBuffer(object.sessionId); + } + if (options.bytes === String) + object.purchaseId = ""; + else { + object.purchaseId = []; + if (options.bytes !== Array) + object.purchaseId = $util.newBuffer(object.purchaseId); + } + object.type = options.enums === String ? "STREAMING" : 1; + object.version = 0; + if (options.bytes === String) + object.providerSessionToken = ""; + else { + object.providerSessionToken = []; + if (options.bytes !== Array) + object.providerSessionToken = $util.newBuffer(object.providerSessionToken); + } + } + if (message.requestId != null && message.hasOwnProperty("requestId")) + object.requestId = options.bytes === String ? $util.base64.encode(message.requestId, 0, message.requestId.length) : options.bytes === Array ? Array.prototype.slice.call(message.requestId) : message.requestId; + if (message.sessionId != null && message.hasOwnProperty("sessionId")) + object.sessionId = options.bytes === String ? $util.base64.encode(message.sessionId, 0, message.sessionId.length) : options.bytes === Array ? Array.prototype.slice.call(message.sessionId) : message.sessionId; + if (message.purchaseId != null && message.hasOwnProperty("purchaseId")) + object.purchaseId = options.bytes === String ? $util.base64.encode(message.purchaseId, 0, message.purchaseId.length) : options.bytes === Array ? Array.prototype.slice.call(message.purchaseId) : message.purchaseId; + if (message.type != null && message.hasOwnProperty("type")) + object.type = options.enums === String ? $root.license_protocol.LicenseType[message.type] === undefined ? message.type : $root.license_protocol.LicenseType[message.type] : message.type; + if (message.version != null && message.hasOwnProperty("version")) + object.version = message.version; + if (message.providerSessionToken != null && message.hasOwnProperty("providerSessionToken")) + object.providerSessionToken = options.bytes === String ? $util.base64.encode(message.providerSessionToken, 0, message.providerSessionToken.length) : options.bytes === Array ? Array.prototype.slice.call(message.providerSessionToken) : message.providerSessionToken; + return object; + }; + + /** + * Converts this LicenseIdentification to JSON. + * @function toJSON + * @memberof license_protocol.LicenseIdentification + * @instance + * @returns {Object.} JSON object + */ + LicenseIdentification.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for LicenseIdentification + * @function getTypeUrl + * @memberof license_protocol.LicenseIdentification + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + LicenseIdentification.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/license_protocol.LicenseIdentification"; + }; + + return LicenseIdentification; + })(); + + license_protocol.License = (function() { + + /** + * Properties of a License. + * @memberof license_protocol + * @interface ILicense + * @property {license_protocol.ILicenseIdentification|null} [id] License id + * @property {license_protocol.License.IPolicy|null} [policy] License policy + * @property {Array.|null} [key] License key + * @property {number|Long|null} [licenseStartTime] License licenseStartTime + * @property {boolean|null} [remoteAttestationVerified] License remoteAttestationVerified + * @property {Uint8Array|null} [providerClientToken] License providerClientToken + * @property {number|null} [protectionScheme] License protectionScheme + * @property {Uint8Array|null} [srmRequirement] License srmRequirement + * @property {Uint8Array|null} [srmUpdate] License srmUpdate + * @property {license_protocol.PlatformVerificationStatus|null} [platformVerificationStatus] License platformVerificationStatus + * @property {Array.|null} [groupIds] License groupIds + */ + + /** + * Constructs a new License. + * @memberof license_protocol + * @classdesc Represents a License. + * @implements ILicense + * @constructor + * @param {license_protocol.ILicense=} [properties] Properties to set + */ + function License(properties) { + this.key = []; + this.groupIds = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * License id. + * @member {license_protocol.ILicenseIdentification|null|undefined} id + * @memberof license_protocol.License + * @instance + */ + License.prototype.id = null; + + /** + * License policy. + * @member {license_protocol.License.IPolicy|null|undefined} policy + * @memberof license_protocol.License + * @instance + */ + License.prototype.policy = null; + + /** + * License key. + * @member {Array.} key + * @memberof license_protocol.License + * @instance + */ + License.prototype.key = $util.emptyArray; + + /** + * License licenseStartTime. + * @member {number|Long} licenseStartTime + * @memberof license_protocol.License + * @instance + */ + License.prototype.licenseStartTime = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * License remoteAttestationVerified. + * @member {boolean} remoteAttestationVerified + * @memberof license_protocol.License + * @instance + */ + License.prototype.remoteAttestationVerified = false; + + /** + * License providerClientToken. + * @member {Uint8Array} providerClientToken + * @memberof license_protocol.License + * @instance + */ + License.prototype.providerClientToken = $util.newBuffer([]); + + /** + * License protectionScheme. + * @member {number} protectionScheme + * @memberof license_protocol.License + * @instance + */ + License.prototype.protectionScheme = 0; + + /** + * License srmRequirement. + * @member {Uint8Array} srmRequirement + * @memberof license_protocol.License + * @instance + */ + License.prototype.srmRequirement = $util.newBuffer([]); + + /** + * License srmUpdate. + * @member {Uint8Array} srmUpdate + * @memberof license_protocol.License + * @instance + */ + License.prototype.srmUpdate = $util.newBuffer([]); + + /** + * License platformVerificationStatus. + * @member {license_protocol.PlatformVerificationStatus} platformVerificationStatus + * @memberof license_protocol.License + * @instance + */ + License.prototype.platformVerificationStatus = 4; + + /** + * License groupIds. + * @member {Array.} groupIds + * @memberof license_protocol.License + * @instance + */ + License.prototype.groupIds = $util.emptyArray; + + /** + * Creates a new License instance using the specified properties. + * @function create + * @memberof license_protocol.License + * @static + * @param {license_protocol.ILicense=} [properties] Properties to set + * @returns {license_protocol.License} License instance + */ + License.create = function create(properties) { + return new License(properties); + }; + + /** + * Encodes the specified License message. Does not implicitly {@link license_protocol.License.verify|verify} messages. + * @function encode + * @memberof license_protocol.License + * @static + * @param {license_protocol.ILicense} message License message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + License.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.id != null && Object.hasOwnProperty.call(message, "id")) + $root.license_protocol.LicenseIdentification.encode(message.id, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.policy != null && Object.hasOwnProperty.call(message, "policy")) + $root.license_protocol.License.Policy.encode(message.policy, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.key != null && message.key.length) + for (var i = 0; i < message.key.length; ++i) + $root.license_protocol.License.KeyContainer.encode(message.key[i], writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.licenseStartTime != null && Object.hasOwnProperty.call(message, "licenseStartTime")) + writer.uint32(/* id 4, wireType 0 =*/32).int64(message.licenseStartTime); + if (message.remoteAttestationVerified != null && Object.hasOwnProperty.call(message, "remoteAttestationVerified")) + writer.uint32(/* id 5, wireType 0 =*/40).bool(message.remoteAttestationVerified); + if (message.providerClientToken != null && Object.hasOwnProperty.call(message, "providerClientToken")) + writer.uint32(/* id 6, wireType 2 =*/50).bytes(message.providerClientToken); + if (message.protectionScheme != null && Object.hasOwnProperty.call(message, "protectionScheme")) + writer.uint32(/* id 7, wireType 0 =*/56).uint32(message.protectionScheme); + if (message.srmRequirement != null && Object.hasOwnProperty.call(message, "srmRequirement")) + writer.uint32(/* id 8, wireType 2 =*/66).bytes(message.srmRequirement); + if (message.srmUpdate != null && Object.hasOwnProperty.call(message, "srmUpdate")) + writer.uint32(/* id 9, wireType 2 =*/74).bytes(message.srmUpdate); + if (message.platformVerificationStatus != null && Object.hasOwnProperty.call(message, "platformVerificationStatus")) + writer.uint32(/* id 10, wireType 0 =*/80).int32(message.platformVerificationStatus); + if (message.groupIds != null && message.groupIds.length) + for (var i = 0; i < message.groupIds.length; ++i) + writer.uint32(/* id 11, wireType 2 =*/90).bytes(message.groupIds[i]); + return writer; + }; + + /** + * Encodes the specified License message, length delimited. Does not implicitly {@link license_protocol.License.verify|verify} messages. + * @function encodeDelimited + * @memberof license_protocol.License + * @static + * @param {license_protocol.ILicense} message License message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + License.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a License message from the specified reader or buffer. + * @function decode + * @memberof license_protocol.License + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {license_protocol.License} License + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + License.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.license_protocol.License(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.id = $root.license_protocol.LicenseIdentification.decode(reader, reader.uint32()); + break; + } + case 2: { + message.policy = $root.license_protocol.License.Policy.decode(reader, reader.uint32()); + break; + } + case 3: { + if (!(message.key && message.key.length)) + message.key = []; + message.key.push($root.license_protocol.License.KeyContainer.decode(reader, reader.uint32())); + break; + } + case 4: { + message.licenseStartTime = reader.int64(); + break; + } + case 5: { + message.remoteAttestationVerified = reader.bool(); + break; + } + case 6: { + message.providerClientToken = reader.bytes(); + break; + } + case 7: { + message.protectionScheme = reader.uint32(); + break; + } + case 8: { + message.srmRequirement = reader.bytes(); + break; + } + case 9: { + message.srmUpdate = reader.bytes(); + break; + } + case 10: { + message.platformVerificationStatus = reader.int32(); + break; + } + case 11: { + if (!(message.groupIds && message.groupIds.length)) + message.groupIds = []; + message.groupIds.push(reader.bytes()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a License message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof license_protocol.License + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {license_protocol.License} License + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + License.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a License message. + * @function verify + * @memberof license_protocol.License + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + License.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.id != null && message.hasOwnProperty("id")) { + var error = $root.license_protocol.LicenseIdentification.verify(message.id); + if (error) + return "id." + error; + } + if (message.policy != null && message.hasOwnProperty("policy")) { + var error = $root.license_protocol.License.Policy.verify(message.policy); + if (error) + return "policy." + error; + } + if (message.key != null && message.hasOwnProperty("key")) { + if (!Array.isArray(message.key)) + return "key: array expected"; + for (var i = 0; i < message.key.length; ++i) { + var error = $root.license_protocol.License.KeyContainer.verify(message.key[i]); + if (error) + return "key." + error; + } + } + if (message.licenseStartTime != null && message.hasOwnProperty("licenseStartTime")) + if (!$util.isInteger(message.licenseStartTime) && !(message.licenseStartTime && $util.isInteger(message.licenseStartTime.low) && $util.isInteger(message.licenseStartTime.high))) + return "licenseStartTime: integer|Long expected"; + if (message.remoteAttestationVerified != null && message.hasOwnProperty("remoteAttestationVerified")) + if (typeof message.remoteAttestationVerified !== "boolean") + return "remoteAttestationVerified: boolean expected"; + if (message.providerClientToken != null && message.hasOwnProperty("providerClientToken")) + if (!(message.providerClientToken && typeof message.providerClientToken.length === "number" || $util.isString(message.providerClientToken))) + return "providerClientToken: buffer expected"; + if (message.protectionScheme != null && message.hasOwnProperty("protectionScheme")) + if (!$util.isInteger(message.protectionScheme)) + return "protectionScheme: integer expected"; + if (message.srmRequirement != null && message.hasOwnProperty("srmRequirement")) + if (!(message.srmRequirement && typeof message.srmRequirement.length === "number" || $util.isString(message.srmRequirement))) + return "srmRequirement: buffer expected"; + if (message.srmUpdate != null && message.hasOwnProperty("srmUpdate")) + if (!(message.srmUpdate && typeof message.srmUpdate.length === "number" || $util.isString(message.srmUpdate))) + return "srmUpdate: buffer expected"; + if (message.platformVerificationStatus != null && message.hasOwnProperty("platformVerificationStatus")) + switch (message.platformVerificationStatus) { + default: + return "platformVerificationStatus: enum value expected"; + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + break; + } + if (message.groupIds != null && message.hasOwnProperty("groupIds")) { + if (!Array.isArray(message.groupIds)) + return "groupIds: array expected"; + for (var i = 0; i < message.groupIds.length; ++i) + if (!(message.groupIds[i] && typeof message.groupIds[i].length === "number" || $util.isString(message.groupIds[i]))) + return "groupIds: buffer[] expected"; + } + return null; + }; + + /** + * Creates a License message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof license_protocol.License + * @static + * @param {Object.} object Plain object + * @returns {license_protocol.License} License + */ + License.fromObject = function fromObject(object) { + if (object instanceof $root.license_protocol.License) + return object; + var message = new $root.license_protocol.License(); + if (object.id != null) { + if (typeof object.id !== "object") + throw TypeError(".license_protocol.License.id: object expected"); + message.id = $root.license_protocol.LicenseIdentification.fromObject(object.id); + } + if (object.policy != null) { + if (typeof object.policy !== "object") + throw TypeError(".license_protocol.License.policy: object expected"); + message.policy = $root.license_protocol.License.Policy.fromObject(object.policy); + } + if (object.key) { + if (!Array.isArray(object.key)) + throw TypeError(".license_protocol.License.key: array expected"); + message.key = []; + for (var i = 0; i < object.key.length; ++i) { + if (typeof object.key[i] !== "object") + throw TypeError(".license_protocol.License.key: object expected"); + message.key[i] = $root.license_protocol.License.KeyContainer.fromObject(object.key[i]); + } + } + if (object.licenseStartTime != null) + if ($util.Long) + (message.licenseStartTime = $util.Long.fromValue(object.licenseStartTime)).unsigned = false; + else if (typeof object.licenseStartTime === "string") + message.licenseStartTime = parseInt(object.licenseStartTime, 10); + else if (typeof object.licenseStartTime === "number") + message.licenseStartTime = object.licenseStartTime; + else if (typeof object.licenseStartTime === "object") + message.licenseStartTime = new $util.LongBits(object.licenseStartTime.low >>> 0, object.licenseStartTime.high >>> 0).toNumber(); + if (object.remoteAttestationVerified != null) + message.remoteAttestationVerified = Boolean(object.remoteAttestationVerified); + if (object.providerClientToken != null) + if (typeof object.providerClientToken === "string") + $util.base64.decode(object.providerClientToken, message.providerClientToken = $util.newBuffer($util.base64.length(object.providerClientToken)), 0); + else if (object.providerClientToken.length >= 0) + message.providerClientToken = object.providerClientToken; + if (object.protectionScheme != null) + message.protectionScheme = object.protectionScheme >>> 0; + if (object.srmRequirement != null) + if (typeof object.srmRequirement === "string") + $util.base64.decode(object.srmRequirement, message.srmRequirement = $util.newBuffer($util.base64.length(object.srmRequirement)), 0); + else if (object.srmRequirement.length >= 0) + message.srmRequirement = object.srmRequirement; + if (object.srmUpdate != null) + if (typeof object.srmUpdate === "string") + $util.base64.decode(object.srmUpdate, message.srmUpdate = $util.newBuffer($util.base64.length(object.srmUpdate)), 0); + else if (object.srmUpdate.length >= 0) + message.srmUpdate = object.srmUpdate; + switch (object.platformVerificationStatus) { + case "PLATFORM_UNVERIFIED": + case 0: + message.platformVerificationStatus = 0; + break; + case "PLATFORM_TAMPERED": + case 1: + message.platformVerificationStatus = 1; + break; + case "PLATFORM_SOFTWARE_VERIFIED": + case 2: + message.platformVerificationStatus = 2; + break; + case "PLATFORM_HARDWARE_VERIFIED": + case 3: + message.platformVerificationStatus = 3; + break; + default: + if (typeof object.platformVerificationStatus === "number") { + message.platformVerificationStatus = object.platformVerificationStatus; + break; + } + break; + case "PLATFORM_NO_VERIFICATION": + case 4: + message.platformVerificationStatus = 4; + break; + case "PLATFORM_SECURE_STORAGE_SOFTWARE_VERIFIED": + case 5: + message.platformVerificationStatus = 5; + break; + } + if (object.groupIds) { + if (!Array.isArray(object.groupIds)) + throw TypeError(".license_protocol.License.groupIds: array expected"); + message.groupIds = []; + for (var i = 0; i < object.groupIds.length; ++i) + if (typeof object.groupIds[i] === "string") + $util.base64.decode(object.groupIds[i], message.groupIds[i] = $util.newBuffer($util.base64.length(object.groupIds[i])), 0); + else if (object.groupIds[i].length >= 0) + message.groupIds[i] = object.groupIds[i]; + } + return message; + }; + + /** + * Creates a plain object from a License message. Also converts values to other types if specified. + * @function toObject + * @memberof license_protocol.License + * @static + * @param {license_protocol.License} message License + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + License.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.key = []; + object.groupIds = []; + } + if (options.defaults) { + object.id = null; + object.policy = null; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.licenseStartTime = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.licenseStartTime = options.longs === String ? "0" : 0; + object.remoteAttestationVerified = false; + if (options.bytes === String) + object.providerClientToken = ""; + else { + object.providerClientToken = []; + if (options.bytes !== Array) + object.providerClientToken = $util.newBuffer(object.providerClientToken); + } + object.protectionScheme = 0; + if (options.bytes === String) + object.srmRequirement = ""; + else { + object.srmRequirement = []; + if (options.bytes !== Array) + object.srmRequirement = $util.newBuffer(object.srmRequirement); + } + if (options.bytes === String) + object.srmUpdate = ""; + else { + object.srmUpdate = []; + if (options.bytes !== Array) + object.srmUpdate = $util.newBuffer(object.srmUpdate); + } + object.platformVerificationStatus = options.enums === String ? "PLATFORM_NO_VERIFICATION" : 4; + } + if (message.id != null && message.hasOwnProperty("id")) + object.id = $root.license_protocol.LicenseIdentification.toObject(message.id, options); + if (message.policy != null && message.hasOwnProperty("policy")) + object.policy = $root.license_protocol.License.Policy.toObject(message.policy, options); + if (message.key && message.key.length) { + object.key = []; + for (var j = 0; j < message.key.length; ++j) + object.key[j] = $root.license_protocol.License.KeyContainer.toObject(message.key[j], options); + } + if (message.licenseStartTime != null && message.hasOwnProperty("licenseStartTime")) + if (typeof message.licenseStartTime === "number") + object.licenseStartTime = options.longs === String ? String(message.licenseStartTime) : message.licenseStartTime; + else + object.licenseStartTime = options.longs === String ? $util.Long.prototype.toString.call(message.licenseStartTime) : options.longs === Number ? new $util.LongBits(message.licenseStartTime.low >>> 0, message.licenseStartTime.high >>> 0).toNumber() : message.licenseStartTime; + if (message.remoteAttestationVerified != null && message.hasOwnProperty("remoteAttestationVerified")) + object.remoteAttestationVerified = message.remoteAttestationVerified; + if (message.providerClientToken != null && message.hasOwnProperty("providerClientToken")) + object.providerClientToken = options.bytes === String ? $util.base64.encode(message.providerClientToken, 0, message.providerClientToken.length) : options.bytes === Array ? Array.prototype.slice.call(message.providerClientToken) : message.providerClientToken; + if (message.protectionScheme != null && message.hasOwnProperty("protectionScheme")) + object.protectionScheme = message.protectionScheme; + if (message.srmRequirement != null && message.hasOwnProperty("srmRequirement")) + object.srmRequirement = options.bytes === String ? $util.base64.encode(message.srmRequirement, 0, message.srmRequirement.length) : options.bytes === Array ? Array.prototype.slice.call(message.srmRequirement) : message.srmRequirement; + if (message.srmUpdate != null && message.hasOwnProperty("srmUpdate")) + object.srmUpdate = options.bytes === String ? $util.base64.encode(message.srmUpdate, 0, message.srmUpdate.length) : options.bytes === Array ? Array.prototype.slice.call(message.srmUpdate) : message.srmUpdate; + if (message.platformVerificationStatus != null && message.hasOwnProperty("platformVerificationStatus")) + object.platformVerificationStatus = options.enums === String ? $root.license_protocol.PlatformVerificationStatus[message.platformVerificationStatus] === undefined ? message.platformVerificationStatus : $root.license_protocol.PlatformVerificationStatus[message.platformVerificationStatus] : message.platformVerificationStatus; + if (message.groupIds && message.groupIds.length) { + object.groupIds = []; + for (var j = 0; j < message.groupIds.length; ++j) + object.groupIds[j] = options.bytes === String ? $util.base64.encode(message.groupIds[j], 0, message.groupIds[j].length) : options.bytes === Array ? Array.prototype.slice.call(message.groupIds[j]) : message.groupIds[j]; + } + return object; + }; + + /** + * Converts this License to JSON. + * @function toJSON + * @memberof license_protocol.License + * @instance + * @returns {Object.} JSON object + */ + License.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for License + * @function getTypeUrl + * @memberof license_protocol.License + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + License.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/license_protocol.License"; + }; + + License.Policy = (function() { + + /** + * Properties of a Policy. + * @memberof license_protocol.License + * @interface IPolicy + * @property {boolean|null} [canPlay] Policy canPlay + * @property {boolean|null} [canPersist] Policy canPersist + * @property {boolean|null} [canRenew] Policy canRenew + * @property {number|Long|null} [rentalDurationSeconds] Policy rentalDurationSeconds + * @property {number|Long|null} [playbackDurationSeconds] Policy playbackDurationSeconds + * @property {number|Long|null} [licenseDurationSeconds] Policy licenseDurationSeconds + * @property {number|Long|null} [renewalRecoveryDurationSeconds] Policy renewalRecoveryDurationSeconds + * @property {string|null} [renewalServerUrl] Policy renewalServerUrl + * @property {number|Long|null} [renewalDelaySeconds] Policy renewalDelaySeconds + * @property {number|Long|null} [renewalRetryIntervalSeconds] Policy renewalRetryIntervalSeconds + * @property {boolean|null} [renewWithUsage] Policy renewWithUsage + * @property {boolean|null} [alwaysIncludeClientId] Policy alwaysIncludeClientId + * @property {number|Long|null} [playStartGracePeriodSeconds] Policy playStartGracePeriodSeconds + * @property {boolean|null} [softEnforcePlaybackDuration] Policy softEnforcePlaybackDuration + * @property {boolean|null} [softEnforceRentalDuration] Policy softEnforceRentalDuration + */ + + /** + * Constructs a new Policy. + * @memberof license_protocol.License + * @classdesc Represents a Policy. + * @implements IPolicy + * @constructor + * @param {license_protocol.License.IPolicy=} [properties] Properties to set + */ + function Policy(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Policy canPlay. + * @member {boolean} canPlay + * @memberof license_protocol.License.Policy + * @instance + */ + Policy.prototype.canPlay = false; + + /** + * Policy canPersist. + * @member {boolean} canPersist + * @memberof license_protocol.License.Policy + * @instance + */ + Policy.prototype.canPersist = false; + + /** + * Policy canRenew. + * @member {boolean} canRenew + * @memberof license_protocol.License.Policy + * @instance + */ + Policy.prototype.canRenew = false; + + /** + * Policy rentalDurationSeconds. + * @member {number|Long} rentalDurationSeconds + * @memberof license_protocol.License.Policy + * @instance + */ + Policy.prototype.rentalDurationSeconds = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Policy playbackDurationSeconds. + * @member {number|Long} playbackDurationSeconds + * @memberof license_protocol.License.Policy + * @instance + */ + Policy.prototype.playbackDurationSeconds = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Policy licenseDurationSeconds. + * @member {number|Long} licenseDurationSeconds + * @memberof license_protocol.License.Policy + * @instance + */ + Policy.prototype.licenseDurationSeconds = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Policy renewalRecoveryDurationSeconds. + * @member {number|Long} renewalRecoveryDurationSeconds + * @memberof license_protocol.License.Policy + * @instance + */ + Policy.prototype.renewalRecoveryDurationSeconds = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Policy renewalServerUrl. + * @member {string} renewalServerUrl + * @memberof license_protocol.License.Policy + * @instance + */ + Policy.prototype.renewalServerUrl = ""; + + /** + * Policy renewalDelaySeconds. + * @member {number|Long} renewalDelaySeconds + * @memberof license_protocol.License.Policy + * @instance + */ + Policy.prototype.renewalDelaySeconds = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Policy renewalRetryIntervalSeconds. + * @member {number|Long} renewalRetryIntervalSeconds + * @memberof license_protocol.License.Policy + * @instance + */ + Policy.prototype.renewalRetryIntervalSeconds = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Policy renewWithUsage. + * @member {boolean} renewWithUsage + * @memberof license_protocol.License.Policy + * @instance + */ + Policy.prototype.renewWithUsage = false; + + /** + * Policy alwaysIncludeClientId. + * @member {boolean} alwaysIncludeClientId + * @memberof license_protocol.License.Policy + * @instance + */ + Policy.prototype.alwaysIncludeClientId = false; + + /** + * Policy playStartGracePeriodSeconds. + * @member {number|Long} playStartGracePeriodSeconds + * @memberof license_protocol.License.Policy + * @instance + */ + Policy.prototype.playStartGracePeriodSeconds = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Policy softEnforcePlaybackDuration. + * @member {boolean} softEnforcePlaybackDuration + * @memberof license_protocol.License.Policy + * @instance + */ + Policy.prototype.softEnforcePlaybackDuration = false; + + /** + * Policy softEnforceRentalDuration. + * @member {boolean} softEnforceRentalDuration + * @memberof license_protocol.License.Policy + * @instance + */ + Policy.prototype.softEnforceRentalDuration = true; + + /** + * Creates a new Policy instance using the specified properties. + * @function create + * @memberof license_protocol.License.Policy + * @static + * @param {license_protocol.License.IPolicy=} [properties] Properties to set + * @returns {license_protocol.License.Policy} Policy instance + */ + Policy.create = function create(properties) { + return new Policy(properties); + }; + + /** + * Encodes the specified Policy message. Does not implicitly {@link license_protocol.License.Policy.verify|verify} messages. + * @function encode + * @memberof license_protocol.License.Policy + * @static + * @param {license_protocol.License.IPolicy} message Policy message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Policy.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.canPlay != null && Object.hasOwnProperty.call(message, "canPlay")) + writer.uint32(/* id 1, wireType 0 =*/8).bool(message.canPlay); + if (message.canPersist != null && Object.hasOwnProperty.call(message, "canPersist")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.canPersist); + if (message.canRenew != null && Object.hasOwnProperty.call(message, "canRenew")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.canRenew); + if (message.rentalDurationSeconds != null && Object.hasOwnProperty.call(message, "rentalDurationSeconds")) + writer.uint32(/* id 4, wireType 0 =*/32).int64(message.rentalDurationSeconds); + if (message.playbackDurationSeconds != null && Object.hasOwnProperty.call(message, "playbackDurationSeconds")) + writer.uint32(/* id 5, wireType 0 =*/40).int64(message.playbackDurationSeconds); + if (message.licenseDurationSeconds != null && Object.hasOwnProperty.call(message, "licenseDurationSeconds")) + writer.uint32(/* id 6, wireType 0 =*/48).int64(message.licenseDurationSeconds); + if (message.renewalRecoveryDurationSeconds != null && Object.hasOwnProperty.call(message, "renewalRecoveryDurationSeconds")) + writer.uint32(/* id 7, wireType 0 =*/56).int64(message.renewalRecoveryDurationSeconds); + if (message.renewalServerUrl != null && Object.hasOwnProperty.call(message, "renewalServerUrl")) + writer.uint32(/* id 8, wireType 2 =*/66).string(message.renewalServerUrl); + if (message.renewalDelaySeconds != null && Object.hasOwnProperty.call(message, "renewalDelaySeconds")) + writer.uint32(/* id 9, wireType 0 =*/72).int64(message.renewalDelaySeconds); + if (message.renewalRetryIntervalSeconds != null && Object.hasOwnProperty.call(message, "renewalRetryIntervalSeconds")) + writer.uint32(/* id 10, wireType 0 =*/80).int64(message.renewalRetryIntervalSeconds); + if (message.renewWithUsage != null && Object.hasOwnProperty.call(message, "renewWithUsage")) + writer.uint32(/* id 11, wireType 0 =*/88).bool(message.renewWithUsage); + if (message.alwaysIncludeClientId != null && Object.hasOwnProperty.call(message, "alwaysIncludeClientId")) + writer.uint32(/* id 12, wireType 0 =*/96).bool(message.alwaysIncludeClientId); + if (message.playStartGracePeriodSeconds != null && Object.hasOwnProperty.call(message, "playStartGracePeriodSeconds")) + writer.uint32(/* id 13, wireType 0 =*/104).int64(message.playStartGracePeriodSeconds); + if (message.softEnforcePlaybackDuration != null && Object.hasOwnProperty.call(message, "softEnforcePlaybackDuration")) + writer.uint32(/* id 14, wireType 0 =*/112).bool(message.softEnforcePlaybackDuration); + if (message.softEnforceRentalDuration != null && Object.hasOwnProperty.call(message, "softEnforceRentalDuration")) + writer.uint32(/* id 15, wireType 0 =*/120).bool(message.softEnforceRentalDuration); + return writer; + }; + + /** + * Encodes the specified Policy message, length delimited. Does not implicitly {@link license_protocol.License.Policy.verify|verify} messages. + * @function encodeDelimited + * @memberof license_protocol.License.Policy + * @static + * @param {license_protocol.License.IPolicy} message Policy message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Policy.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Policy message from the specified reader or buffer. + * @function decode + * @memberof license_protocol.License.Policy + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {license_protocol.License.Policy} Policy + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Policy.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.license_protocol.License.Policy(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.canPlay = reader.bool(); + break; + } + case 2: { + message.canPersist = reader.bool(); + break; + } + case 3: { + message.canRenew = reader.bool(); + break; + } + case 4: { + message.rentalDurationSeconds = reader.int64(); + break; + } + case 5: { + message.playbackDurationSeconds = reader.int64(); + break; + } + case 6: { + message.licenseDurationSeconds = reader.int64(); + break; + } + case 7: { + message.renewalRecoveryDurationSeconds = reader.int64(); + break; + } + case 8: { + message.renewalServerUrl = reader.string(); + break; + } + case 9: { + message.renewalDelaySeconds = reader.int64(); + break; + } + case 10: { + message.renewalRetryIntervalSeconds = reader.int64(); + break; + } + case 11: { + message.renewWithUsage = reader.bool(); + break; + } + case 12: { + message.alwaysIncludeClientId = reader.bool(); + break; + } + case 13: { + message.playStartGracePeriodSeconds = reader.int64(); + break; + } + case 14: { + message.softEnforcePlaybackDuration = reader.bool(); + break; + } + case 15: { + message.softEnforceRentalDuration = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Policy message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof license_protocol.License.Policy + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {license_protocol.License.Policy} Policy + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Policy.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Policy message. + * @function verify + * @memberof license_protocol.License.Policy + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Policy.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.canPlay != null && message.hasOwnProperty("canPlay")) + if (typeof message.canPlay !== "boolean") + return "canPlay: boolean expected"; + if (message.canPersist != null && message.hasOwnProperty("canPersist")) + if (typeof message.canPersist !== "boolean") + return "canPersist: boolean expected"; + if (message.canRenew != null && message.hasOwnProperty("canRenew")) + if (typeof message.canRenew !== "boolean") + return "canRenew: boolean expected"; + if (message.rentalDurationSeconds != null && message.hasOwnProperty("rentalDurationSeconds")) + if (!$util.isInteger(message.rentalDurationSeconds) && !(message.rentalDurationSeconds && $util.isInteger(message.rentalDurationSeconds.low) && $util.isInteger(message.rentalDurationSeconds.high))) + return "rentalDurationSeconds: integer|Long expected"; + if (message.playbackDurationSeconds != null && message.hasOwnProperty("playbackDurationSeconds")) + if (!$util.isInteger(message.playbackDurationSeconds) && !(message.playbackDurationSeconds && $util.isInteger(message.playbackDurationSeconds.low) && $util.isInteger(message.playbackDurationSeconds.high))) + return "playbackDurationSeconds: integer|Long expected"; + if (message.licenseDurationSeconds != null && message.hasOwnProperty("licenseDurationSeconds")) + if (!$util.isInteger(message.licenseDurationSeconds) && !(message.licenseDurationSeconds && $util.isInteger(message.licenseDurationSeconds.low) && $util.isInteger(message.licenseDurationSeconds.high))) + return "licenseDurationSeconds: integer|Long expected"; + if (message.renewalRecoveryDurationSeconds != null && message.hasOwnProperty("renewalRecoveryDurationSeconds")) + if (!$util.isInteger(message.renewalRecoveryDurationSeconds) && !(message.renewalRecoveryDurationSeconds && $util.isInteger(message.renewalRecoveryDurationSeconds.low) && $util.isInteger(message.renewalRecoveryDurationSeconds.high))) + return "renewalRecoveryDurationSeconds: integer|Long expected"; + if (message.renewalServerUrl != null && message.hasOwnProperty("renewalServerUrl")) + if (!$util.isString(message.renewalServerUrl)) + return "renewalServerUrl: string expected"; + if (message.renewalDelaySeconds != null && message.hasOwnProperty("renewalDelaySeconds")) + if (!$util.isInteger(message.renewalDelaySeconds) && !(message.renewalDelaySeconds && $util.isInteger(message.renewalDelaySeconds.low) && $util.isInteger(message.renewalDelaySeconds.high))) + return "renewalDelaySeconds: integer|Long expected"; + if (message.renewalRetryIntervalSeconds != null && message.hasOwnProperty("renewalRetryIntervalSeconds")) + if (!$util.isInteger(message.renewalRetryIntervalSeconds) && !(message.renewalRetryIntervalSeconds && $util.isInteger(message.renewalRetryIntervalSeconds.low) && $util.isInteger(message.renewalRetryIntervalSeconds.high))) + return "renewalRetryIntervalSeconds: integer|Long expected"; + if (message.renewWithUsage != null && message.hasOwnProperty("renewWithUsage")) + if (typeof message.renewWithUsage !== "boolean") + return "renewWithUsage: boolean expected"; + if (message.alwaysIncludeClientId != null && message.hasOwnProperty("alwaysIncludeClientId")) + if (typeof message.alwaysIncludeClientId !== "boolean") + return "alwaysIncludeClientId: boolean expected"; + if (message.playStartGracePeriodSeconds != null && message.hasOwnProperty("playStartGracePeriodSeconds")) + if (!$util.isInteger(message.playStartGracePeriodSeconds) && !(message.playStartGracePeriodSeconds && $util.isInteger(message.playStartGracePeriodSeconds.low) && $util.isInteger(message.playStartGracePeriodSeconds.high))) + return "playStartGracePeriodSeconds: integer|Long expected"; + if (message.softEnforcePlaybackDuration != null && message.hasOwnProperty("softEnforcePlaybackDuration")) + if (typeof message.softEnforcePlaybackDuration !== "boolean") + return "softEnforcePlaybackDuration: boolean expected"; + if (message.softEnforceRentalDuration != null && message.hasOwnProperty("softEnforceRentalDuration")) + if (typeof message.softEnforceRentalDuration !== "boolean") + return "softEnforceRentalDuration: boolean expected"; + return null; + }; + + /** + * Creates a Policy message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof license_protocol.License.Policy + * @static + * @param {Object.} object Plain object + * @returns {license_protocol.License.Policy} Policy + */ + Policy.fromObject = function fromObject(object) { + if (object instanceof $root.license_protocol.License.Policy) + return object; + var message = new $root.license_protocol.License.Policy(); + if (object.canPlay != null) + message.canPlay = Boolean(object.canPlay); + if (object.canPersist != null) + message.canPersist = Boolean(object.canPersist); + if (object.canRenew != null) + message.canRenew = Boolean(object.canRenew); + if (object.rentalDurationSeconds != null) + if ($util.Long) + (message.rentalDurationSeconds = $util.Long.fromValue(object.rentalDurationSeconds)).unsigned = false; + else if (typeof object.rentalDurationSeconds === "string") + message.rentalDurationSeconds = parseInt(object.rentalDurationSeconds, 10); + else if (typeof object.rentalDurationSeconds === "number") + message.rentalDurationSeconds = object.rentalDurationSeconds; + else if (typeof object.rentalDurationSeconds === "object") + message.rentalDurationSeconds = new $util.LongBits(object.rentalDurationSeconds.low >>> 0, object.rentalDurationSeconds.high >>> 0).toNumber(); + if (object.playbackDurationSeconds != null) + if ($util.Long) + (message.playbackDurationSeconds = $util.Long.fromValue(object.playbackDurationSeconds)).unsigned = false; + else if (typeof object.playbackDurationSeconds === "string") + message.playbackDurationSeconds = parseInt(object.playbackDurationSeconds, 10); + else if (typeof object.playbackDurationSeconds === "number") + message.playbackDurationSeconds = object.playbackDurationSeconds; + else if (typeof object.playbackDurationSeconds === "object") + message.playbackDurationSeconds = new $util.LongBits(object.playbackDurationSeconds.low >>> 0, object.playbackDurationSeconds.high >>> 0).toNumber(); + if (object.licenseDurationSeconds != null) + if ($util.Long) + (message.licenseDurationSeconds = $util.Long.fromValue(object.licenseDurationSeconds)).unsigned = false; + else if (typeof object.licenseDurationSeconds === "string") + message.licenseDurationSeconds = parseInt(object.licenseDurationSeconds, 10); + else if (typeof object.licenseDurationSeconds === "number") + message.licenseDurationSeconds = object.licenseDurationSeconds; + else if (typeof object.licenseDurationSeconds === "object") + message.licenseDurationSeconds = new $util.LongBits(object.licenseDurationSeconds.low >>> 0, object.licenseDurationSeconds.high >>> 0).toNumber(); + if (object.renewalRecoveryDurationSeconds != null) + if ($util.Long) + (message.renewalRecoveryDurationSeconds = $util.Long.fromValue(object.renewalRecoveryDurationSeconds)).unsigned = false; + else if (typeof object.renewalRecoveryDurationSeconds === "string") + message.renewalRecoveryDurationSeconds = parseInt(object.renewalRecoveryDurationSeconds, 10); + else if (typeof object.renewalRecoveryDurationSeconds === "number") + message.renewalRecoveryDurationSeconds = object.renewalRecoveryDurationSeconds; + else if (typeof object.renewalRecoveryDurationSeconds === "object") + message.renewalRecoveryDurationSeconds = new $util.LongBits(object.renewalRecoveryDurationSeconds.low >>> 0, object.renewalRecoveryDurationSeconds.high >>> 0).toNumber(); + if (object.renewalServerUrl != null) + message.renewalServerUrl = String(object.renewalServerUrl); + if (object.renewalDelaySeconds != null) + if ($util.Long) + (message.renewalDelaySeconds = $util.Long.fromValue(object.renewalDelaySeconds)).unsigned = false; + else if (typeof object.renewalDelaySeconds === "string") + message.renewalDelaySeconds = parseInt(object.renewalDelaySeconds, 10); + else if (typeof object.renewalDelaySeconds === "number") + message.renewalDelaySeconds = object.renewalDelaySeconds; + else if (typeof object.renewalDelaySeconds === "object") + message.renewalDelaySeconds = new $util.LongBits(object.renewalDelaySeconds.low >>> 0, object.renewalDelaySeconds.high >>> 0).toNumber(); + if (object.renewalRetryIntervalSeconds != null) + if ($util.Long) + (message.renewalRetryIntervalSeconds = $util.Long.fromValue(object.renewalRetryIntervalSeconds)).unsigned = false; + else if (typeof object.renewalRetryIntervalSeconds === "string") + message.renewalRetryIntervalSeconds = parseInt(object.renewalRetryIntervalSeconds, 10); + else if (typeof object.renewalRetryIntervalSeconds === "number") + message.renewalRetryIntervalSeconds = object.renewalRetryIntervalSeconds; + else if (typeof object.renewalRetryIntervalSeconds === "object") + message.renewalRetryIntervalSeconds = new $util.LongBits(object.renewalRetryIntervalSeconds.low >>> 0, object.renewalRetryIntervalSeconds.high >>> 0).toNumber(); + if (object.renewWithUsage != null) + message.renewWithUsage = Boolean(object.renewWithUsage); + if (object.alwaysIncludeClientId != null) + message.alwaysIncludeClientId = Boolean(object.alwaysIncludeClientId); + if (object.playStartGracePeriodSeconds != null) + if ($util.Long) + (message.playStartGracePeriodSeconds = $util.Long.fromValue(object.playStartGracePeriodSeconds)).unsigned = false; + else if (typeof object.playStartGracePeriodSeconds === "string") + message.playStartGracePeriodSeconds = parseInt(object.playStartGracePeriodSeconds, 10); + else if (typeof object.playStartGracePeriodSeconds === "number") + message.playStartGracePeriodSeconds = object.playStartGracePeriodSeconds; + else if (typeof object.playStartGracePeriodSeconds === "object") + message.playStartGracePeriodSeconds = new $util.LongBits(object.playStartGracePeriodSeconds.low >>> 0, object.playStartGracePeriodSeconds.high >>> 0).toNumber(); + if (object.softEnforcePlaybackDuration != null) + message.softEnforcePlaybackDuration = Boolean(object.softEnforcePlaybackDuration); + if (object.softEnforceRentalDuration != null) + message.softEnforceRentalDuration = Boolean(object.softEnforceRentalDuration); + return message; + }; + + /** + * Creates a plain object from a Policy message. Also converts values to other types if specified. + * @function toObject + * @memberof license_protocol.License.Policy + * @static + * @param {license_protocol.License.Policy} message Policy + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Policy.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.canPlay = false; + object.canPersist = false; + object.canRenew = false; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.rentalDurationSeconds = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.rentalDurationSeconds = options.longs === String ? "0" : 0; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.playbackDurationSeconds = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.playbackDurationSeconds = options.longs === String ? "0" : 0; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.licenseDurationSeconds = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.licenseDurationSeconds = options.longs === String ? "0" : 0; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.renewalRecoveryDurationSeconds = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.renewalRecoveryDurationSeconds = options.longs === String ? "0" : 0; + object.renewalServerUrl = ""; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.renewalDelaySeconds = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.renewalDelaySeconds = options.longs === String ? "0" : 0; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.renewalRetryIntervalSeconds = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.renewalRetryIntervalSeconds = options.longs === String ? "0" : 0; + object.renewWithUsage = false; + object.alwaysIncludeClientId = false; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.playStartGracePeriodSeconds = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.playStartGracePeriodSeconds = options.longs === String ? "0" : 0; + object.softEnforcePlaybackDuration = false; + object.softEnforceRentalDuration = true; + } + if (message.canPlay != null && message.hasOwnProperty("canPlay")) + object.canPlay = message.canPlay; + if (message.canPersist != null && message.hasOwnProperty("canPersist")) + object.canPersist = message.canPersist; + if (message.canRenew != null && message.hasOwnProperty("canRenew")) + object.canRenew = message.canRenew; + if (message.rentalDurationSeconds != null && message.hasOwnProperty("rentalDurationSeconds")) + if (typeof message.rentalDurationSeconds === "number") + object.rentalDurationSeconds = options.longs === String ? String(message.rentalDurationSeconds) : message.rentalDurationSeconds; + else + object.rentalDurationSeconds = options.longs === String ? $util.Long.prototype.toString.call(message.rentalDurationSeconds) : options.longs === Number ? new $util.LongBits(message.rentalDurationSeconds.low >>> 0, message.rentalDurationSeconds.high >>> 0).toNumber() : message.rentalDurationSeconds; + if (message.playbackDurationSeconds != null && message.hasOwnProperty("playbackDurationSeconds")) + if (typeof message.playbackDurationSeconds === "number") + object.playbackDurationSeconds = options.longs === String ? String(message.playbackDurationSeconds) : message.playbackDurationSeconds; + else + object.playbackDurationSeconds = options.longs === String ? $util.Long.prototype.toString.call(message.playbackDurationSeconds) : options.longs === Number ? new $util.LongBits(message.playbackDurationSeconds.low >>> 0, message.playbackDurationSeconds.high >>> 0).toNumber() : message.playbackDurationSeconds; + if (message.licenseDurationSeconds != null && message.hasOwnProperty("licenseDurationSeconds")) + if (typeof message.licenseDurationSeconds === "number") + object.licenseDurationSeconds = options.longs === String ? String(message.licenseDurationSeconds) : message.licenseDurationSeconds; + else + object.licenseDurationSeconds = options.longs === String ? $util.Long.prototype.toString.call(message.licenseDurationSeconds) : options.longs === Number ? new $util.LongBits(message.licenseDurationSeconds.low >>> 0, message.licenseDurationSeconds.high >>> 0).toNumber() : message.licenseDurationSeconds; + if (message.renewalRecoveryDurationSeconds != null && message.hasOwnProperty("renewalRecoveryDurationSeconds")) + if (typeof message.renewalRecoveryDurationSeconds === "number") + object.renewalRecoveryDurationSeconds = options.longs === String ? String(message.renewalRecoveryDurationSeconds) : message.renewalRecoveryDurationSeconds; + else + object.renewalRecoveryDurationSeconds = options.longs === String ? $util.Long.prototype.toString.call(message.renewalRecoveryDurationSeconds) : options.longs === Number ? new $util.LongBits(message.renewalRecoveryDurationSeconds.low >>> 0, message.renewalRecoveryDurationSeconds.high >>> 0).toNumber() : message.renewalRecoveryDurationSeconds; + if (message.renewalServerUrl != null && message.hasOwnProperty("renewalServerUrl")) + object.renewalServerUrl = message.renewalServerUrl; + if (message.renewalDelaySeconds != null && message.hasOwnProperty("renewalDelaySeconds")) + if (typeof message.renewalDelaySeconds === "number") + object.renewalDelaySeconds = options.longs === String ? String(message.renewalDelaySeconds) : message.renewalDelaySeconds; + else + object.renewalDelaySeconds = options.longs === String ? $util.Long.prototype.toString.call(message.renewalDelaySeconds) : options.longs === Number ? new $util.LongBits(message.renewalDelaySeconds.low >>> 0, message.renewalDelaySeconds.high >>> 0).toNumber() : message.renewalDelaySeconds; + if (message.renewalRetryIntervalSeconds != null && message.hasOwnProperty("renewalRetryIntervalSeconds")) + if (typeof message.renewalRetryIntervalSeconds === "number") + object.renewalRetryIntervalSeconds = options.longs === String ? String(message.renewalRetryIntervalSeconds) : message.renewalRetryIntervalSeconds; + else + object.renewalRetryIntervalSeconds = options.longs === String ? $util.Long.prototype.toString.call(message.renewalRetryIntervalSeconds) : options.longs === Number ? new $util.LongBits(message.renewalRetryIntervalSeconds.low >>> 0, message.renewalRetryIntervalSeconds.high >>> 0).toNumber() : message.renewalRetryIntervalSeconds; + if (message.renewWithUsage != null && message.hasOwnProperty("renewWithUsage")) + object.renewWithUsage = message.renewWithUsage; + if (message.alwaysIncludeClientId != null && message.hasOwnProperty("alwaysIncludeClientId")) + object.alwaysIncludeClientId = message.alwaysIncludeClientId; + if (message.playStartGracePeriodSeconds != null && message.hasOwnProperty("playStartGracePeriodSeconds")) + if (typeof message.playStartGracePeriodSeconds === "number") + object.playStartGracePeriodSeconds = options.longs === String ? String(message.playStartGracePeriodSeconds) : message.playStartGracePeriodSeconds; + else + object.playStartGracePeriodSeconds = options.longs === String ? $util.Long.prototype.toString.call(message.playStartGracePeriodSeconds) : options.longs === Number ? new $util.LongBits(message.playStartGracePeriodSeconds.low >>> 0, message.playStartGracePeriodSeconds.high >>> 0).toNumber() : message.playStartGracePeriodSeconds; + if (message.softEnforcePlaybackDuration != null && message.hasOwnProperty("softEnforcePlaybackDuration")) + object.softEnforcePlaybackDuration = message.softEnforcePlaybackDuration; + if (message.softEnforceRentalDuration != null && message.hasOwnProperty("softEnforceRentalDuration")) + object.softEnforceRentalDuration = message.softEnforceRentalDuration; + return object; + }; + + /** + * Converts this Policy to JSON. + * @function toJSON + * @memberof license_protocol.License.Policy + * @instance + * @returns {Object.} JSON object + */ + Policy.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Policy + * @function getTypeUrl + * @memberof license_protocol.License.Policy + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Policy.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/license_protocol.License.Policy"; + }; + + return Policy; + })(); + + License.KeyContainer = (function() { + + /** + * Properties of a KeyContainer. + * @memberof license_protocol.License + * @interface IKeyContainer + * @property {Uint8Array|null} [id] KeyContainer id + * @property {Uint8Array|null} [iv] KeyContainer iv + * @property {Uint8Array|null} [key] KeyContainer key + * @property {license_protocol.License.KeyContainer.KeyType|null} [type] KeyContainer type + * @property {license_protocol.License.KeyContainer.SecurityLevel|null} [level] KeyContainer level + * @property {license_protocol.License.KeyContainer.IOutputProtection|null} [requiredProtection] KeyContainer requiredProtection + * @property {license_protocol.License.KeyContainer.IOutputProtection|null} [requestedProtection] KeyContainer requestedProtection + * @property {license_protocol.License.KeyContainer.IKeyControl|null} [keyControl] KeyContainer keyControl + * @property {license_protocol.License.KeyContainer.IOperatorSessionKeyPermissions|null} [operatorSessionKeyPermissions] KeyContainer operatorSessionKeyPermissions + * @property {Array.|null} [videoResolutionConstraints] KeyContainer videoResolutionConstraints + * @property {boolean|null} [antiRollbackUsageTable] KeyContainer antiRollbackUsageTable + * @property {string|null} [trackLabel] KeyContainer trackLabel + */ + + /** + * Constructs a new KeyContainer. + * @memberof license_protocol.License + * @classdesc Represents a KeyContainer. + * @implements IKeyContainer + * @constructor + * @param {license_protocol.License.IKeyContainer=} [properties] Properties to set + */ + function KeyContainer(properties) { + this.videoResolutionConstraints = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * KeyContainer id. + * @member {Uint8Array} id + * @memberof license_protocol.License.KeyContainer + * @instance + */ + KeyContainer.prototype.id = $util.newBuffer([]); + + /** + * KeyContainer iv. + * @member {Uint8Array} iv + * @memberof license_protocol.License.KeyContainer + * @instance + */ + KeyContainer.prototype.iv = $util.newBuffer([]); + + /** + * KeyContainer key. + * @member {Uint8Array} key + * @memberof license_protocol.License.KeyContainer + * @instance + */ + KeyContainer.prototype.key = $util.newBuffer([]); + + /** + * KeyContainer type. + * @member {license_protocol.License.KeyContainer.KeyType} type + * @memberof license_protocol.License.KeyContainer + * @instance + */ + KeyContainer.prototype.type = 1; + + /** + * KeyContainer level. + * @member {license_protocol.License.KeyContainer.SecurityLevel} level + * @memberof license_protocol.License.KeyContainer + * @instance + */ + KeyContainer.prototype.level = 1; + + /** + * KeyContainer requiredProtection. + * @member {license_protocol.License.KeyContainer.IOutputProtection|null|undefined} requiredProtection + * @memberof license_protocol.License.KeyContainer + * @instance + */ + KeyContainer.prototype.requiredProtection = null; + + /** + * KeyContainer requestedProtection. + * @member {license_protocol.License.KeyContainer.IOutputProtection|null|undefined} requestedProtection + * @memberof license_protocol.License.KeyContainer + * @instance + */ + KeyContainer.prototype.requestedProtection = null; + + /** + * KeyContainer keyControl. + * @member {license_protocol.License.KeyContainer.IKeyControl|null|undefined} keyControl + * @memberof license_protocol.License.KeyContainer + * @instance + */ + KeyContainer.prototype.keyControl = null; + + /** + * KeyContainer operatorSessionKeyPermissions. + * @member {license_protocol.License.KeyContainer.IOperatorSessionKeyPermissions|null|undefined} operatorSessionKeyPermissions + * @memberof license_protocol.License.KeyContainer + * @instance + */ + KeyContainer.prototype.operatorSessionKeyPermissions = null; + + /** + * KeyContainer videoResolutionConstraints. + * @member {Array.} videoResolutionConstraints + * @memberof license_protocol.License.KeyContainer + * @instance + */ + KeyContainer.prototype.videoResolutionConstraints = $util.emptyArray; + + /** + * KeyContainer antiRollbackUsageTable. + * @member {boolean} antiRollbackUsageTable + * @memberof license_protocol.License.KeyContainer + * @instance + */ + KeyContainer.prototype.antiRollbackUsageTable = false; + + /** + * KeyContainer trackLabel. + * @member {string} trackLabel + * @memberof license_protocol.License.KeyContainer + * @instance + */ + KeyContainer.prototype.trackLabel = ""; + + /** + * Creates a new KeyContainer instance using the specified properties. + * @function create + * @memberof license_protocol.License.KeyContainer + * @static + * @param {license_protocol.License.IKeyContainer=} [properties] Properties to set + * @returns {license_protocol.License.KeyContainer} KeyContainer instance + */ + KeyContainer.create = function create(properties) { + return new KeyContainer(properties); + }; + + /** + * Encodes the specified KeyContainer message. Does not implicitly {@link license_protocol.License.KeyContainer.verify|verify} messages. + * @function encode + * @memberof license_protocol.License.KeyContainer + * @static + * @param {license_protocol.License.IKeyContainer} message KeyContainer message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + KeyContainer.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.id != null && Object.hasOwnProperty.call(message, "id")) + writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.id); + if (message.iv != null && Object.hasOwnProperty.call(message, "iv")) + writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.iv); + if (message.key != null && Object.hasOwnProperty.call(message, "key")) + writer.uint32(/* id 3, wireType 2 =*/26).bytes(message.key); + if (message.type != null && Object.hasOwnProperty.call(message, "type")) + writer.uint32(/* id 4, wireType 0 =*/32).int32(message.type); + if (message.level != null && Object.hasOwnProperty.call(message, "level")) + writer.uint32(/* id 5, wireType 0 =*/40).int32(message.level); + if (message.requiredProtection != null && Object.hasOwnProperty.call(message, "requiredProtection")) + $root.license_protocol.License.KeyContainer.OutputProtection.encode(message.requiredProtection, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + if (message.requestedProtection != null && Object.hasOwnProperty.call(message, "requestedProtection")) + $root.license_protocol.License.KeyContainer.OutputProtection.encode(message.requestedProtection, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); + if (message.keyControl != null && Object.hasOwnProperty.call(message, "keyControl")) + $root.license_protocol.License.KeyContainer.KeyControl.encode(message.keyControl, writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim(); + if (message.operatorSessionKeyPermissions != null && Object.hasOwnProperty.call(message, "operatorSessionKeyPermissions")) + $root.license_protocol.License.KeyContainer.OperatorSessionKeyPermissions.encode(message.operatorSessionKeyPermissions, writer.uint32(/* id 9, wireType 2 =*/74).fork()).ldelim(); + if (message.videoResolutionConstraints != null && message.videoResolutionConstraints.length) + for (var i = 0; i < message.videoResolutionConstraints.length; ++i) + $root.license_protocol.License.KeyContainer.VideoResolutionConstraint.encode(message.videoResolutionConstraints[i], writer.uint32(/* id 10, wireType 2 =*/82).fork()).ldelim(); + if (message.antiRollbackUsageTable != null && Object.hasOwnProperty.call(message, "antiRollbackUsageTable")) + writer.uint32(/* id 11, wireType 0 =*/88).bool(message.antiRollbackUsageTable); + if (message.trackLabel != null && Object.hasOwnProperty.call(message, "trackLabel")) + writer.uint32(/* id 12, wireType 2 =*/98).string(message.trackLabel); + return writer; + }; + + /** + * Encodes the specified KeyContainer message, length delimited. Does not implicitly {@link license_protocol.License.KeyContainer.verify|verify} messages. + * @function encodeDelimited + * @memberof license_protocol.License.KeyContainer + * @static + * @param {license_protocol.License.IKeyContainer} message KeyContainer message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + KeyContainer.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a KeyContainer message from the specified reader or buffer. + * @function decode + * @memberof license_protocol.License.KeyContainer + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {license_protocol.License.KeyContainer} KeyContainer + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + KeyContainer.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.license_protocol.License.KeyContainer(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.id = reader.bytes(); + break; + } + case 2: { + message.iv = reader.bytes(); + break; + } + case 3: { + message.key = reader.bytes(); + break; + } + case 4: { + message.type = reader.int32(); + break; + } + case 5: { + message.level = reader.int32(); + break; + } + case 6: { + message.requiredProtection = $root.license_protocol.License.KeyContainer.OutputProtection.decode(reader, reader.uint32()); + break; + } + case 7: { + message.requestedProtection = $root.license_protocol.License.KeyContainer.OutputProtection.decode(reader, reader.uint32()); + break; + } + case 8: { + message.keyControl = $root.license_protocol.License.KeyContainer.KeyControl.decode(reader, reader.uint32()); + break; + } + case 9: { + message.operatorSessionKeyPermissions = $root.license_protocol.License.KeyContainer.OperatorSessionKeyPermissions.decode(reader, reader.uint32()); + break; + } + case 10: { + if (!(message.videoResolutionConstraints && message.videoResolutionConstraints.length)) + message.videoResolutionConstraints = []; + message.videoResolutionConstraints.push($root.license_protocol.License.KeyContainer.VideoResolutionConstraint.decode(reader, reader.uint32())); + break; + } + case 11: { + message.antiRollbackUsageTable = reader.bool(); + break; + } + case 12: { + message.trackLabel = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a KeyContainer message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof license_protocol.License.KeyContainer + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {license_protocol.License.KeyContainer} KeyContainer + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + KeyContainer.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a KeyContainer message. + * @function verify + * @memberof license_protocol.License.KeyContainer + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + KeyContainer.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.id != null && message.hasOwnProperty("id")) + if (!(message.id && typeof message.id.length === "number" || $util.isString(message.id))) + return "id: buffer expected"; + if (message.iv != null && message.hasOwnProperty("iv")) + if (!(message.iv && typeof message.iv.length === "number" || $util.isString(message.iv))) + return "iv: buffer expected"; + if (message.key != null && message.hasOwnProperty("key")) + if (!(message.key && typeof message.key.length === "number" || $util.isString(message.key))) + return "key: buffer expected"; + if (message.type != null && message.hasOwnProperty("type")) + switch (message.type) { + default: + return "type: enum value expected"; + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + break; + } + if (message.level != null && message.hasOwnProperty("level")) + switch (message.level) { + default: + return "level: enum value expected"; + case 1: + case 2: + case 3: + case 4: + case 5: + break; + } + if (message.requiredProtection != null && message.hasOwnProperty("requiredProtection")) { + var error = $root.license_protocol.License.KeyContainer.OutputProtection.verify(message.requiredProtection); + if (error) + return "requiredProtection." + error; + } + if (message.requestedProtection != null && message.hasOwnProperty("requestedProtection")) { + var error = $root.license_protocol.License.KeyContainer.OutputProtection.verify(message.requestedProtection); + if (error) + return "requestedProtection." + error; + } + if (message.keyControl != null && message.hasOwnProperty("keyControl")) { + var error = $root.license_protocol.License.KeyContainer.KeyControl.verify(message.keyControl); + if (error) + return "keyControl." + error; + } + if (message.operatorSessionKeyPermissions != null && message.hasOwnProperty("operatorSessionKeyPermissions")) { + var error = $root.license_protocol.License.KeyContainer.OperatorSessionKeyPermissions.verify(message.operatorSessionKeyPermissions); + if (error) + return "operatorSessionKeyPermissions." + error; + } + if (message.videoResolutionConstraints != null && message.hasOwnProperty("videoResolutionConstraints")) { + if (!Array.isArray(message.videoResolutionConstraints)) + return "videoResolutionConstraints: array expected"; + for (var i = 0; i < message.videoResolutionConstraints.length; ++i) { + var error = $root.license_protocol.License.KeyContainer.VideoResolutionConstraint.verify(message.videoResolutionConstraints[i]); + if (error) + return "videoResolutionConstraints." + error; + } + } + if (message.antiRollbackUsageTable != null && message.hasOwnProperty("antiRollbackUsageTable")) + if (typeof message.antiRollbackUsageTable !== "boolean") + return "antiRollbackUsageTable: boolean expected"; + if (message.trackLabel != null && message.hasOwnProperty("trackLabel")) + if (!$util.isString(message.trackLabel)) + return "trackLabel: string expected"; + return null; + }; + + /** + * Creates a KeyContainer message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof license_protocol.License.KeyContainer + * @static + * @param {Object.} object Plain object + * @returns {license_protocol.License.KeyContainer} KeyContainer + */ + KeyContainer.fromObject = function fromObject(object) { + if (object instanceof $root.license_protocol.License.KeyContainer) + return object; + var message = new $root.license_protocol.License.KeyContainer(); + if (object.id != null) + if (typeof object.id === "string") + $util.base64.decode(object.id, message.id = $util.newBuffer($util.base64.length(object.id)), 0); + else if (object.id.length >= 0) + message.id = object.id; + if (object.iv != null) + if (typeof object.iv === "string") + $util.base64.decode(object.iv, message.iv = $util.newBuffer($util.base64.length(object.iv)), 0); + else if (object.iv.length >= 0) + message.iv = object.iv; + if (object.key != null) + if (typeof object.key === "string") + $util.base64.decode(object.key, message.key = $util.newBuffer($util.base64.length(object.key)), 0); + else if (object.key.length >= 0) + message.key = object.key; + switch (object.type) { + default: + if (typeof object.type === "number") { + message.type = object.type; + break; + } + break; + case "SIGNING": + case 1: + message.type = 1; + break; + case "CONTENT": + case 2: + message.type = 2; + break; + case "KEY_CONTROL": + case 3: + message.type = 3; + break; + case "OPERATOR_SESSION": + case 4: + message.type = 4; + break; + case "ENTITLEMENT": + case 5: + message.type = 5; + break; + case "OEM_CONTENT": + case 6: + message.type = 6; + break; + } + switch (object.level) { + default: + if (typeof object.level === "number") { + message.level = object.level; + break; + } + break; + case "SW_SECURE_CRYPTO": + case 1: + message.level = 1; + break; + case "SW_SECURE_DECODE": + case 2: + message.level = 2; + break; + case "HW_SECURE_CRYPTO": + case 3: + message.level = 3; + break; + case "HW_SECURE_DECODE": + case 4: + message.level = 4; + break; + case "HW_SECURE_ALL": + case 5: + message.level = 5; + break; + } + if (object.requiredProtection != null) { + if (typeof object.requiredProtection !== "object") + throw TypeError(".license_protocol.License.KeyContainer.requiredProtection: object expected"); + message.requiredProtection = $root.license_protocol.License.KeyContainer.OutputProtection.fromObject(object.requiredProtection); + } + if (object.requestedProtection != null) { + if (typeof object.requestedProtection !== "object") + throw TypeError(".license_protocol.License.KeyContainer.requestedProtection: object expected"); + message.requestedProtection = $root.license_protocol.License.KeyContainer.OutputProtection.fromObject(object.requestedProtection); + } + if (object.keyControl != null) { + if (typeof object.keyControl !== "object") + throw TypeError(".license_protocol.License.KeyContainer.keyControl: object expected"); + message.keyControl = $root.license_protocol.License.KeyContainer.KeyControl.fromObject(object.keyControl); + } + if (object.operatorSessionKeyPermissions != null) { + if (typeof object.operatorSessionKeyPermissions !== "object") + throw TypeError(".license_protocol.License.KeyContainer.operatorSessionKeyPermissions: object expected"); + message.operatorSessionKeyPermissions = $root.license_protocol.License.KeyContainer.OperatorSessionKeyPermissions.fromObject(object.operatorSessionKeyPermissions); + } + if (object.videoResolutionConstraints) { + if (!Array.isArray(object.videoResolutionConstraints)) + throw TypeError(".license_protocol.License.KeyContainer.videoResolutionConstraints: array expected"); + message.videoResolutionConstraints = []; + for (var i = 0; i < object.videoResolutionConstraints.length; ++i) { + if (typeof object.videoResolutionConstraints[i] !== "object") + throw TypeError(".license_protocol.License.KeyContainer.videoResolutionConstraints: object expected"); + message.videoResolutionConstraints[i] = $root.license_protocol.License.KeyContainer.VideoResolutionConstraint.fromObject(object.videoResolutionConstraints[i]); + } + } + if (object.antiRollbackUsageTable != null) + message.antiRollbackUsageTable = Boolean(object.antiRollbackUsageTable); + if (object.trackLabel != null) + message.trackLabel = String(object.trackLabel); + return message; + }; + + /** + * Creates a plain object from a KeyContainer message. Also converts values to other types if specified. + * @function toObject + * @memberof license_protocol.License.KeyContainer + * @static + * @param {license_protocol.License.KeyContainer} message KeyContainer + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + KeyContainer.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.videoResolutionConstraints = []; + if (options.defaults) { + if (options.bytes === String) + object.id = ""; + else { + object.id = []; + if (options.bytes !== Array) + object.id = $util.newBuffer(object.id); + } + if (options.bytes === String) + object.iv = ""; + else { + object.iv = []; + if (options.bytes !== Array) + object.iv = $util.newBuffer(object.iv); + } + if (options.bytes === String) + object.key = ""; + else { + object.key = []; + if (options.bytes !== Array) + object.key = $util.newBuffer(object.key); + } + object.type = options.enums === String ? "SIGNING" : 1; + object.level = options.enums === String ? "SW_SECURE_CRYPTO" : 1; + object.requiredProtection = null; + object.requestedProtection = null; + object.keyControl = null; + object.operatorSessionKeyPermissions = null; + object.antiRollbackUsageTable = false; + object.trackLabel = ""; + } + if (message.id != null && message.hasOwnProperty("id")) + object.id = options.bytes === String ? $util.base64.encode(message.id, 0, message.id.length) : options.bytes === Array ? Array.prototype.slice.call(message.id) : message.id; + if (message.iv != null && message.hasOwnProperty("iv")) + object.iv = options.bytes === String ? $util.base64.encode(message.iv, 0, message.iv.length) : options.bytes === Array ? Array.prototype.slice.call(message.iv) : message.iv; + if (message.key != null && message.hasOwnProperty("key")) + object.key = options.bytes === String ? $util.base64.encode(message.key, 0, message.key.length) : options.bytes === Array ? Array.prototype.slice.call(message.key) : message.key; + if (message.type != null && message.hasOwnProperty("type")) + object.type = options.enums === String ? $root.license_protocol.License.KeyContainer.KeyType[message.type] === undefined ? message.type : $root.license_protocol.License.KeyContainer.KeyType[message.type] : message.type; + if (message.level != null && message.hasOwnProperty("level")) + object.level = options.enums === String ? $root.license_protocol.License.KeyContainer.SecurityLevel[message.level] === undefined ? message.level : $root.license_protocol.License.KeyContainer.SecurityLevel[message.level] : message.level; + if (message.requiredProtection != null && message.hasOwnProperty("requiredProtection")) + object.requiredProtection = $root.license_protocol.License.KeyContainer.OutputProtection.toObject(message.requiredProtection, options); + if (message.requestedProtection != null && message.hasOwnProperty("requestedProtection")) + object.requestedProtection = $root.license_protocol.License.KeyContainer.OutputProtection.toObject(message.requestedProtection, options); + if (message.keyControl != null && message.hasOwnProperty("keyControl")) + object.keyControl = $root.license_protocol.License.KeyContainer.KeyControl.toObject(message.keyControl, options); + if (message.operatorSessionKeyPermissions != null && message.hasOwnProperty("operatorSessionKeyPermissions")) + object.operatorSessionKeyPermissions = $root.license_protocol.License.KeyContainer.OperatorSessionKeyPermissions.toObject(message.operatorSessionKeyPermissions, options); + if (message.videoResolutionConstraints && message.videoResolutionConstraints.length) { + object.videoResolutionConstraints = []; + for (var j = 0; j < message.videoResolutionConstraints.length; ++j) + object.videoResolutionConstraints[j] = $root.license_protocol.License.KeyContainer.VideoResolutionConstraint.toObject(message.videoResolutionConstraints[j], options); + } + if (message.antiRollbackUsageTable != null && message.hasOwnProperty("antiRollbackUsageTable")) + object.antiRollbackUsageTable = message.antiRollbackUsageTable; + if (message.trackLabel != null && message.hasOwnProperty("trackLabel")) + object.trackLabel = message.trackLabel; + return object; + }; + + /** + * Converts this KeyContainer to JSON. + * @function toJSON + * @memberof license_protocol.License.KeyContainer + * @instance + * @returns {Object.} JSON object + */ + KeyContainer.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for KeyContainer + * @function getTypeUrl + * @memberof license_protocol.License.KeyContainer + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + KeyContainer.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/license_protocol.License.KeyContainer"; + }; + + /** + * KeyType enum. + * @name license_protocol.License.KeyContainer.KeyType + * @enum {number} + * @property {number} SIGNING=1 SIGNING value + * @property {number} CONTENT=2 CONTENT value + * @property {number} KEY_CONTROL=3 KEY_CONTROL value + * @property {number} OPERATOR_SESSION=4 OPERATOR_SESSION value + * @property {number} ENTITLEMENT=5 ENTITLEMENT value + * @property {number} OEM_CONTENT=6 OEM_CONTENT value + */ + KeyContainer.KeyType = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[1] = "SIGNING"] = 1; + values[valuesById[2] = "CONTENT"] = 2; + values[valuesById[3] = "KEY_CONTROL"] = 3; + values[valuesById[4] = "OPERATOR_SESSION"] = 4; + values[valuesById[5] = "ENTITLEMENT"] = 5; + values[valuesById[6] = "OEM_CONTENT"] = 6; + return values; + })(); + + /** + * SecurityLevel enum. + * @name license_protocol.License.KeyContainer.SecurityLevel + * @enum {number} + * @property {number} SW_SECURE_CRYPTO=1 SW_SECURE_CRYPTO value + * @property {number} SW_SECURE_DECODE=2 SW_SECURE_DECODE value + * @property {number} HW_SECURE_CRYPTO=3 HW_SECURE_CRYPTO value + * @property {number} HW_SECURE_DECODE=4 HW_SECURE_DECODE value + * @property {number} HW_SECURE_ALL=5 HW_SECURE_ALL value + */ + KeyContainer.SecurityLevel = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[1] = "SW_SECURE_CRYPTO"] = 1; + values[valuesById[2] = "SW_SECURE_DECODE"] = 2; + values[valuesById[3] = "HW_SECURE_CRYPTO"] = 3; + values[valuesById[4] = "HW_SECURE_DECODE"] = 4; + values[valuesById[5] = "HW_SECURE_ALL"] = 5; + return values; + })(); + + KeyContainer.KeyControl = (function() { + + /** + * Properties of a KeyControl. + * @memberof license_protocol.License.KeyContainer + * @interface IKeyControl + * @property {Uint8Array|null} [keyControlBlock] KeyControl keyControlBlock + * @property {Uint8Array|null} [iv] KeyControl iv + */ + + /** + * Constructs a new KeyControl. + * @memberof license_protocol.License.KeyContainer + * @classdesc Represents a KeyControl. + * @implements IKeyControl + * @constructor + * @param {license_protocol.License.KeyContainer.IKeyControl=} [properties] Properties to set + */ + function KeyControl(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * KeyControl keyControlBlock. + * @member {Uint8Array} keyControlBlock + * @memberof license_protocol.License.KeyContainer.KeyControl + * @instance + */ + KeyControl.prototype.keyControlBlock = $util.newBuffer([]); + + /** + * KeyControl iv. + * @member {Uint8Array} iv + * @memberof license_protocol.License.KeyContainer.KeyControl + * @instance + */ + KeyControl.prototype.iv = $util.newBuffer([]); + + /** + * Creates a new KeyControl instance using the specified properties. + * @function create + * @memberof license_protocol.License.KeyContainer.KeyControl + * @static + * @param {license_protocol.License.KeyContainer.IKeyControl=} [properties] Properties to set + * @returns {license_protocol.License.KeyContainer.KeyControl} KeyControl instance + */ + KeyControl.create = function create(properties) { + return new KeyControl(properties); + }; + + /** + * Encodes the specified KeyControl message. Does not implicitly {@link license_protocol.License.KeyContainer.KeyControl.verify|verify} messages. + * @function encode + * @memberof license_protocol.License.KeyContainer.KeyControl + * @static + * @param {license_protocol.License.KeyContainer.IKeyControl} message KeyControl message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + KeyControl.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.keyControlBlock != null && Object.hasOwnProperty.call(message, "keyControlBlock")) + writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.keyControlBlock); + if (message.iv != null && Object.hasOwnProperty.call(message, "iv")) + writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.iv); + return writer; + }; + + /** + * Encodes the specified KeyControl message, length delimited. Does not implicitly {@link license_protocol.License.KeyContainer.KeyControl.verify|verify} messages. + * @function encodeDelimited + * @memberof license_protocol.License.KeyContainer.KeyControl + * @static + * @param {license_protocol.License.KeyContainer.IKeyControl} message KeyControl message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + KeyControl.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a KeyControl message from the specified reader or buffer. + * @function decode + * @memberof license_protocol.License.KeyContainer.KeyControl + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {license_protocol.License.KeyContainer.KeyControl} KeyControl + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + KeyControl.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.license_protocol.License.KeyContainer.KeyControl(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.keyControlBlock = reader.bytes(); + break; + } + case 2: { + message.iv = reader.bytes(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a KeyControl message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof license_protocol.License.KeyContainer.KeyControl + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {license_protocol.License.KeyContainer.KeyControl} KeyControl + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + KeyControl.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a KeyControl message. + * @function verify + * @memberof license_protocol.License.KeyContainer.KeyControl + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + KeyControl.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.keyControlBlock != null && message.hasOwnProperty("keyControlBlock")) + if (!(message.keyControlBlock && typeof message.keyControlBlock.length === "number" || $util.isString(message.keyControlBlock))) + return "keyControlBlock: buffer expected"; + if (message.iv != null && message.hasOwnProperty("iv")) + if (!(message.iv && typeof message.iv.length === "number" || $util.isString(message.iv))) + return "iv: buffer expected"; + return null; + }; + + /** + * Creates a KeyControl message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof license_protocol.License.KeyContainer.KeyControl + * @static + * @param {Object.} object Plain object + * @returns {license_protocol.License.KeyContainer.KeyControl} KeyControl + */ + KeyControl.fromObject = function fromObject(object) { + if (object instanceof $root.license_protocol.License.KeyContainer.KeyControl) + return object; + var message = new $root.license_protocol.License.KeyContainer.KeyControl(); + if (object.keyControlBlock != null) + if (typeof object.keyControlBlock === "string") + $util.base64.decode(object.keyControlBlock, message.keyControlBlock = $util.newBuffer($util.base64.length(object.keyControlBlock)), 0); + else if (object.keyControlBlock.length >= 0) + message.keyControlBlock = object.keyControlBlock; + if (object.iv != null) + if (typeof object.iv === "string") + $util.base64.decode(object.iv, message.iv = $util.newBuffer($util.base64.length(object.iv)), 0); + else if (object.iv.length >= 0) + message.iv = object.iv; + return message; + }; + + /** + * Creates a plain object from a KeyControl message. Also converts values to other types if specified. + * @function toObject + * @memberof license_protocol.License.KeyContainer.KeyControl + * @static + * @param {license_protocol.License.KeyContainer.KeyControl} message KeyControl + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + KeyControl.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + if (options.bytes === String) + object.keyControlBlock = ""; + else { + object.keyControlBlock = []; + if (options.bytes !== Array) + object.keyControlBlock = $util.newBuffer(object.keyControlBlock); + } + if (options.bytes === String) + object.iv = ""; + else { + object.iv = []; + if (options.bytes !== Array) + object.iv = $util.newBuffer(object.iv); + } + } + if (message.keyControlBlock != null && message.hasOwnProperty("keyControlBlock")) + object.keyControlBlock = options.bytes === String ? $util.base64.encode(message.keyControlBlock, 0, message.keyControlBlock.length) : options.bytes === Array ? Array.prototype.slice.call(message.keyControlBlock) : message.keyControlBlock; + if (message.iv != null && message.hasOwnProperty("iv")) + object.iv = options.bytes === String ? $util.base64.encode(message.iv, 0, message.iv.length) : options.bytes === Array ? Array.prototype.slice.call(message.iv) : message.iv; + return object; + }; + + /** + * Converts this KeyControl to JSON. + * @function toJSON + * @memberof license_protocol.License.KeyContainer.KeyControl + * @instance + * @returns {Object.} JSON object + */ + KeyControl.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for KeyControl + * @function getTypeUrl + * @memberof license_protocol.License.KeyContainer.KeyControl + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + KeyControl.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/license_protocol.License.KeyContainer.KeyControl"; + }; + + return KeyControl; + })(); + + KeyContainer.OutputProtection = (function() { + + /** + * Properties of an OutputProtection. + * @memberof license_protocol.License.KeyContainer + * @interface IOutputProtection + * @property {license_protocol.License.KeyContainer.OutputProtection.HDCP|null} [hdcp] OutputProtection hdcp + * @property {license_protocol.License.KeyContainer.OutputProtection.CGMS|null} [cgmsFlags] OutputProtection cgmsFlags + * @property {license_protocol.License.KeyContainer.OutputProtection.HdcpSrmRule|null} [hdcpSrmRule] OutputProtection hdcpSrmRule + * @property {boolean|null} [disableAnalogOutput] OutputProtection disableAnalogOutput + * @property {boolean|null} [disableDigitalOutput] OutputProtection disableDigitalOutput + */ + + /** + * Constructs a new OutputProtection. + * @memberof license_protocol.License.KeyContainer + * @classdesc Represents an OutputProtection. + * @implements IOutputProtection + * @constructor + * @param {license_protocol.License.KeyContainer.IOutputProtection=} [properties] Properties to set + */ + function OutputProtection(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * OutputProtection hdcp. + * @member {license_protocol.License.KeyContainer.OutputProtection.HDCP} hdcp + * @memberof license_protocol.License.KeyContainer.OutputProtection + * @instance + */ + OutputProtection.prototype.hdcp = 0; + + /** + * OutputProtection cgmsFlags. + * @member {license_protocol.License.KeyContainer.OutputProtection.CGMS} cgmsFlags + * @memberof license_protocol.License.KeyContainer.OutputProtection + * @instance + */ + OutputProtection.prototype.cgmsFlags = 42; + + /** + * OutputProtection hdcpSrmRule. + * @member {license_protocol.License.KeyContainer.OutputProtection.HdcpSrmRule} hdcpSrmRule + * @memberof license_protocol.License.KeyContainer.OutputProtection + * @instance + */ + OutputProtection.prototype.hdcpSrmRule = 0; + + /** + * OutputProtection disableAnalogOutput. + * @member {boolean} disableAnalogOutput + * @memberof license_protocol.License.KeyContainer.OutputProtection + * @instance + */ + OutputProtection.prototype.disableAnalogOutput = false; + + /** + * OutputProtection disableDigitalOutput. + * @member {boolean} disableDigitalOutput + * @memberof license_protocol.License.KeyContainer.OutputProtection + * @instance + */ + OutputProtection.prototype.disableDigitalOutput = false; + + /** + * Creates a new OutputProtection instance using the specified properties. + * @function create + * @memberof license_protocol.License.KeyContainer.OutputProtection + * @static + * @param {license_protocol.License.KeyContainer.IOutputProtection=} [properties] Properties to set + * @returns {license_protocol.License.KeyContainer.OutputProtection} OutputProtection instance + */ + OutputProtection.create = function create(properties) { + return new OutputProtection(properties); + }; + + /** + * Encodes the specified OutputProtection message. Does not implicitly {@link license_protocol.License.KeyContainer.OutputProtection.verify|verify} messages. + * @function encode + * @memberof license_protocol.License.KeyContainer.OutputProtection + * @static + * @param {license_protocol.License.KeyContainer.IOutputProtection} message OutputProtection message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + OutputProtection.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.hdcp != null && Object.hasOwnProperty.call(message, "hdcp")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.hdcp); + if (message.cgmsFlags != null && Object.hasOwnProperty.call(message, "cgmsFlags")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.cgmsFlags); + if (message.hdcpSrmRule != null && Object.hasOwnProperty.call(message, "hdcpSrmRule")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.hdcpSrmRule); + if (message.disableAnalogOutput != null && Object.hasOwnProperty.call(message, "disableAnalogOutput")) + writer.uint32(/* id 4, wireType 0 =*/32).bool(message.disableAnalogOutput); + if (message.disableDigitalOutput != null && Object.hasOwnProperty.call(message, "disableDigitalOutput")) + writer.uint32(/* id 5, wireType 0 =*/40).bool(message.disableDigitalOutput); + return writer; + }; + + /** + * Encodes the specified OutputProtection message, length delimited. Does not implicitly {@link license_protocol.License.KeyContainer.OutputProtection.verify|verify} messages. + * @function encodeDelimited + * @memberof license_protocol.License.KeyContainer.OutputProtection + * @static + * @param {license_protocol.License.KeyContainer.IOutputProtection} message OutputProtection message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + OutputProtection.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an OutputProtection message from the specified reader or buffer. + * @function decode + * @memberof license_protocol.License.KeyContainer.OutputProtection + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {license_protocol.License.KeyContainer.OutputProtection} OutputProtection + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + OutputProtection.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.license_protocol.License.KeyContainer.OutputProtection(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.hdcp = reader.int32(); + break; + } + case 2: { + message.cgmsFlags = reader.int32(); + break; + } + case 3: { + message.hdcpSrmRule = reader.int32(); + break; + } + case 4: { + message.disableAnalogOutput = reader.bool(); + break; + } + case 5: { + message.disableDigitalOutput = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an OutputProtection message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof license_protocol.License.KeyContainer.OutputProtection + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {license_protocol.License.KeyContainer.OutputProtection} OutputProtection + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + OutputProtection.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an OutputProtection message. + * @function verify + * @memberof license_protocol.License.KeyContainer.OutputProtection + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + OutputProtection.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.hdcp != null && message.hasOwnProperty("hdcp")) + switch (message.hdcp) { + default: + return "hdcp: enum value expected"; + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + case 255: + break; + } + if (message.cgmsFlags != null && message.hasOwnProperty("cgmsFlags")) + switch (message.cgmsFlags) { + default: + return "cgmsFlags: enum value expected"; + case 42: + case 0: + case 2: + case 3: + break; + } + if (message.hdcpSrmRule != null && message.hasOwnProperty("hdcpSrmRule")) + switch (message.hdcpSrmRule) { + default: + return "hdcpSrmRule: enum value expected"; + case 0: + case 1: + break; + } + if (message.disableAnalogOutput != null && message.hasOwnProperty("disableAnalogOutput")) + if (typeof message.disableAnalogOutput !== "boolean") + return "disableAnalogOutput: boolean expected"; + if (message.disableDigitalOutput != null && message.hasOwnProperty("disableDigitalOutput")) + if (typeof message.disableDigitalOutput !== "boolean") + return "disableDigitalOutput: boolean expected"; + return null; + }; + + /** + * Creates an OutputProtection message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof license_protocol.License.KeyContainer.OutputProtection + * @static + * @param {Object.} object Plain object + * @returns {license_protocol.License.KeyContainer.OutputProtection} OutputProtection + */ + OutputProtection.fromObject = function fromObject(object) { + if (object instanceof $root.license_protocol.License.KeyContainer.OutputProtection) + return object; + var message = new $root.license_protocol.License.KeyContainer.OutputProtection(); + switch (object.hdcp) { + default: + if (typeof object.hdcp === "number") { + message.hdcp = object.hdcp; + break; + } + break; + case "HDCP_NONE": + case 0: + message.hdcp = 0; + break; + case "HDCP_V1": + case 1: + message.hdcp = 1; + break; + case "HDCP_V2": + case 2: + message.hdcp = 2; + break; + case "HDCP_V2_1": + case 3: + message.hdcp = 3; + break; + case "HDCP_V2_2": + case 4: + message.hdcp = 4; + break; + case "HDCP_V2_3": + case 5: + message.hdcp = 5; + break; + case "HDCP_NO_DIGITAL_OUTPUT": + case 255: + message.hdcp = 255; + break; + } + switch (object.cgmsFlags) { + default: + if (typeof object.cgmsFlags === "number") { + message.cgmsFlags = object.cgmsFlags; + break; + } + break; + case "CGMS_NONE": + case 42: + message.cgmsFlags = 42; + break; + case "COPY_FREE": + case 0: + message.cgmsFlags = 0; + break; + case "COPY_ONCE": + case 2: + message.cgmsFlags = 2; + break; + case "COPY_NEVER": + case 3: + message.cgmsFlags = 3; + break; + } + switch (object.hdcpSrmRule) { + default: + if (typeof object.hdcpSrmRule === "number") { + message.hdcpSrmRule = object.hdcpSrmRule; + break; + } + break; + case "HDCP_SRM_RULE_NONE": + case 0: + message.hdcpSrmRule = 0; + break; + case "CURRENT_SRM": + case 1: + message.hdcpSrmRule = 1; + break; + } + if (object.disableAnalogOutput != null) + message.disableAnalogOutput = Boolean(object.disableAnalogOutput); + if (object.disableDigitalOutput != null) + message.disableDigitalOutput = Boolean(object.disableDigitalOutput); + return message; + }; + + /** + * Creates a plain object from an OutputProtection message. Also converts values to other types if specified. + * @function toObject + * @memberof license_protocol.License.KeyContainer.OutputProtection + * @static + * @param {license_protocol.License.KeyContainer.OutputProtection} message OutputProtection + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + OutputProtection.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.hdcp = options.enums === String ? "HDCP_NONE" : 0; + object.cgmsFlags = options.enums === String ? "CGMS_NONE" : 42; + object.hdcpSrmRule = options.enums === String ? "HDCP_SRM_RULE_NONE" : 0; + object.disableAnalogOutput = false; + object.disableDigitalOutput = false; + } + if (message.hdcp != null && message.hasOwnProperty("hdcp")) + object.hdcp = options.enums === String ? $root.license_protocol.License.KeyContainer.OutputProtection.HDCP[message.hdcp] === undefined ? message.hdcp : $root.license_protocol.License.KeyContainer.OutputProtection.HDCP[message.hdcp] : message.hdcp; + if (message.cgmsFlags != null && message.hasOwnProperty("cgmsFlags")) + object.cgmsFlags = options.enums === String ? $root.license_protocol.License.KeyContainer.OutputProtection.CGMS[message.cgmsFlags] === undefined ? message.cgmsFlags : $root.license_protocol.License.KeyContainer.OutputProtection.CGMS[message.cgmsFlags] : message.cgmsFlags; + if (message.hdcpSrmRule != null && message.hasOwnProperty("hdcpSrmRule")) + object.hdcpSrmRule = options.enums === String ? $root.license_protocol.License.KeyContainer.OutputProtection.HdcpSrmRule[message.hdcpSrmRule] === undefined ? message.hdcpSrmRule : $root.license_protocol.License.KeyContainer.OutputProtection.HdcpSrmRule[message.hdcpSrmRule] : message.hdcpSrmRule; + if (message.disableAnalogOutput != null && message.hasOwnProperty("disableAnalogOutput")) + object.disableAnalogOutput = message.disableAnalogOutput; + if (message.disableDigitalOutput != null && message.hasOwnProperty("disableDigitalOutput")) + object.disableDigitalOutput = message.disableDigitalOutput; + return object; + }; + + /** + * Converts this OutputProtection to JSON. + * @function toJSON + * @memberof license_protocol.License.KeyContainer.OutputProtection + * @instance + * @returns {Object.} JSON object + */ + OutputProtection.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for OutputProtection + * @function getTypeUrl + * @memberof license_protocol.License.KeyContainer.OutputProtection + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + OutputProtection.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/license_protocol.License.KeyContainer.OutputProtection"; + }; + + /** + * HDCP enum. + * @name license_protocol.License.KeyContainer.OutputProtection.HDCP + * @enum {number} + * @property {number} HDCP_NONE=0 HDCP_NONE value + * @property {number} HDCP_V1=1 HDCP_V1 value + * @property {number} HDCP_V2=2 HDCP_V2 value + * @property {number} HDCP_V2_1=3 HDCP_V2_1 value + * @property {number} HDCP_V2_2=4 HDCP_V2_2 value + * @property {number} HDCP_V2_3=5 HDCP_V2_3 value + * @property {number} HDCP_NO_DIGITAL_OUTPUT=255 HDCP_NO_DIGITAL_OUTPUT value + */ + OutputProtection.HDCP = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "HDCP_NONE"] = 0; + values[valuesById[1] = "HDCP_V1"] = 1; + values[valuesById[2] = "HDCP_V2"] = 2; + values[valuesById[3] = "HDCP_V2_1"] = 3; + values[valuesById[4] = "HDCP_V2_2"] = 4; + values[valuesById[5] = "HDCP_V2_3"] = 5; + values[valuesById[255] = "HDCP_NO_DIGITAL_OUTPUT"] = 255; + return values; + })(); + + /** + * CGMS enum. + * @name license_protocol.License.KeyContainer.OutputProtection.CGMS + * @enum {number} + * @property {number} CGMS_NONE=42 CGMS_NONE value + * @property {number} COPY_FREE=0 COPY_FREE value + * @property {number} COPY_ONCE=2 COPY_ONCE value + * @property {number} COPY_NEVER=3 COPY_NEVER value + */ + OutputProtection.CGMS = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[42] = "CGMS_NONE"] = 42; + values[valuesById[0] = "COPY_FREE"] = 0; + values[valuesById[2] = "COPY_ONCE"] = 2; + values[valuesById[3] = "COPY_NEVER"] = 3; + return values; + })(); + + /** + * HdcpSrmRule enum. + * @name license_protocol.License.KeyContainer.OutputProtection.HdcpSrmRule + * @enum {number} + * @property {number} HDCP_SRM_RULE_NONE=0 HDCP_SRM_RULE_NONE value + * @property {number} CURRENT_SRM=1 CURRENT_SRM value + */ + OutputProtection.HdcpSrmRule = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "HDCP_SRM_RULE_NONE"] = 0; + values[valuesById[1] = "CURRENT_SRM"] = 1; + return values; + })(); + + return OutputProtection; + })(); + + KeyContainer.VideoResolutionConstraint = (function() { + + /** + * Properties of a VideoResolutionConstraint. + * @memberof license_protocol.License.KeyContainer + * @interface IVideoResolutionConstraint + * @property {number|null} [minResolutionPixels] VideoResolutionConstraint minResolutionPixels + * @property {number|null} [maxResolutionPixels] VideoResolutionConstraint maxResolutionPixels + * @property {license_protocol.License.KeyContainer.IOutputProtection|null} [requiredProtection] VideoResolutionConstraint requiredProtection + */ + + /** + * Constructs a new VideoResolutionConstraint. + * @memberof license_protocol.License.KeyContainer + * @classdesc Represents a VideoResolutionConstraint. + * @implements IVideoResolutionConstraint + * @constructor + * @param {license_protocol.License.KeyContainer.IVideoResolutionConstraint=} [properties] Properties to set + */ + function VideoResolutionConstraint(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * VideoResolutionConstraint minResolutionPixels. + * @member {number} minResolutionPixels + * @memberof license_protocol.License.KeyContainer.VideoResolutionConstraint + * @instance + */ + VideoResolutionConstraint.prototype.minResolutionPixels = 0; + + /** + * VideoResolutionConstraint maxResolutionPixels. + * @member {number} maxResolutionPixels + * @memberof license_protocol.License.KeyContainer.VideoResolutionConstraint + * @instance + */ + VideoResolutionConstraint.prototype.maxResolutionPixels = 0; + + /** + * VideoResolutionConstraint requiredProtection. + * @member {license_protocol.License.KeyContainer.IOutputProtection|null|undefined} requiredProtection + * @memberof license_protocol.License.KeyContainer.VideoResolutionConstraint + * @instance + */ + VideoResolutionConstraint.prototype.requiredProtection = null; + + /** + * Creates a new VideoResolutionConstraint instance using the specified properties. + * @function create + * @memberof license_protocol.License.KeyContainer.VideoResolutionConstraint + * @static + * @param {license_protocol.License.KeyContainer.IVideoResolutionConstraint=} [properties] Properties to set + * @returns {license_protocol.License.KeyContainer.VideoResolutionConstraint} VideoResolutionConstraint instance + */ + VideoResolutionConstraint.create = function create(properties) { + return new VideoResolutionConstraint(properties); + }; + + /** + * Encodes the specified VideoResolutionConstraint message. Does not implicitly {@link license_protocol.License.KeyContainer.VideoResolutionConstraint.verify|verify} messages. + * @function encode + * @memberof license_protocol.License.KeyContainer.VideoResolutionConstraint + * @static + * @param {license_protocol.License.KeyContainer.IVideoResolutionConstraint} message VideoResolutionConstraint message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + VideoResolutionConstraint.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.minResolutionPixels != null && Object.hasOwnProperty.call(message, "minResolutionPixels")) + writer.uint32(/* id 1, wireType 0 =*/8).uint32(message.minResolutionPixels); + if (message.maxResolutionPixels != null && Object.hasOwnProperty.call(message, "maxResolutionPixels")) + writer.uint32(/* id 2, wireType 0 =*/16).uint32(message.maxResolutionPixels); + if (message.requiredProtection != null && Object.hasOwnProperty.call(message, "requiredProtection")) + $root.license_protocol.License.KeyContainer.OutputProtection.encode(message.requiredProtection, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified VideoResolutionConstraint message, length delimited. Does not implicitly {@link license_protocol.License.KeyContainer.VideoResolutionConstraint.verify|verify} messages. + * @function encodeDelimited + * @memberof license_protocol.License.KeyContainer.VideoResolutionConstraint + * @static + * @param {license_protocol.License.KeyContainer.IVideoResolutionConstraint} message VideoResolutionConstraint message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + VideoResolutionConstraint.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a VideoResolutionConstraint message from the specified reader or buffer. + * @function decode + * @memberof license_protocol.License.KeyContainer.VideoResolutionConstraint + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {license_protocol.License.KeyContainer.VideoResolutionConstraint} VideoResolutionConstraint + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + VideoResolutionConstraint.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.license_protocol.License.KeyContainer.VideoResolutionConstraint(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.minResolutionPixels = reader.uint32(); + break; + } + case 2: { + message.maxResolutionPixels = reader.uint32(); + break; + } + case 3: { + message.requiredProtection = $root.license_protocol.License.KeyContainer.OutputProtection.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a VideoResolutionConstraint message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof license_protocol.License.KeyContainer.VideoResolutionConstraint + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {license_protocol.License.KeyContainer.VideoResolutionConstraint} VideoResolutionConstraint + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + VideoResolutionConstraint.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a VideoResolutionConstraint message. + * @function verify + * @memberof license_protocol.License.KeyContainer.VideoResolutionConstraint + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + VideoResolutionConstraint.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.minResolutionPixels != null && message.hasOwnProperty("minResolutionPixels")) + if (!$util.isInteger(message.minResolutionPixels)) + return "minResolutionPixels: integer expected"; + if (message.maxResolutionPixels != null && message.hasOwnProperty("maxResolutionPixels")) + if (!$util.isInteger(message.maxResolutionPixels)) + return "maxResolutionPixels: integer expected"; + if (message.requiredProtection != null && message.hasOwnProperty("requiredProtection")) { + var error = $root.license_protocol.License.KeyContainer.OutputProtection.verify(message.requiredProtection); + if (error) + return "requiredProtection." + error; + } + return null; + }; + + /** + * Creates a VideoResolutionConstraint message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof license_protocol.License.KeyContainer.VideoResolutionConstraint + * @static + * @param {Object.} object Plain object + * @returns {license_protocol.License.KeyContainer.VideoResolutionConstraint} VideoResolutionConstraint + */ + VideoResolutionConstraint.fromObject = function fromObject(object) { + if (object instanceof $root.license_protocol.License.KeyContainer.VideoResolutionConstraint) + return object; + var message = new $root.license_protocol.License.KeyContainer.VideoResolutionConstraint(); + if (object.minResolutionPixels != null) + message.minResolutionPixels = object.minResolutionPixels >>> 0; + if (object.maxResolutionPixels != null) + message.maxResolutionPixels = object.maxResolutionPixels >>> 0; + if (object.requiredProtection != null) { + if (typeof object.requiredProtection !== "object") + throw TypeError(".license_protocol.License.KeyContainer.VideoResolutionConstraint.requiredProtection: object expected"); + message.requiredProtection = $root.license_protocol.License.KeyContainer.OutputProtection.fromObject(object.requiredProtection); + } + return message; + }; + + /** + * Creates a plain object from a VideoResolutionConstraint message. Also converts values to other types if specified. + * @function toObject + * @memberof license_protocol.License.KeyContainer.VideoResolutionConstraint + * @static + * @param {license_protocol.License.KeyContainer.VideoResolutionConstraint} message VideoResolutionConstraint + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + VideoResolutionConstraint.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.minResolutionPixels = 0; + object.maxResolutionPixels = 0; + object.requiredProtection = null; + } + if (message.minResolutionPixels != null && message.hasOwnProperty("minResolutionPixels")) + object.minResolutionPixels = message.minResolutionPixels; + if (message.maxResolutionPixels != null && message.hasOwnProperty("maxResolutionPixels")) + object.maxResolutionPixels = message.maxResolutionPixels; + if (message.requiredProtection != null && message.hasOwnProperty("requiredProtection")) + object.requiredProtection = $root.license_protocol.License.KeyContainer.OutputProtection.toObject(message.requiredProtection, options); + return object; + }; + + /** + * Converts this VideoResolutionConstraint to JSON. + * @function toJSON + * @memberof license_protocol.License.KeyContainer.VideoResolutionConstraint + * @instance + * @returns {Object.} JSON object + */ + VideoResolutionConstraint.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for VideoResolutionConstraint + * @function getTypeUrl + * @memberof license_protocol.License.KeyContainer.VideoResolutionConstraint + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + VideoResolutionConstraint.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/license_protocol.License.KeyContainer.VideoResolutionConstraint"; + }; + + return VideoResolutionConstraint; + })(); + + KeyContainer.OperatorSessionKeyPermissions = (function() { + + /** + * Properties of an OperatorSessionKeyPermissions. + * @memberof license_protocol.License.KeyContainer + * @interface IOperatorSessionKeyPermissions + * @property {boolean|null} [allowEncrypt] OperatorSessionKeyPermissions allowEncrypt + * @property {boolean|null} [allowDecrypt] OperatorSessionKeyPermissions allowDecrypt + * @property {boolean|null} [allowSign] OperatorSessionKeyPermissions allowSign + * @property {boolean|null} [allowSignatureVerify] OperatorSessionKeyPermissions allowSignatureVerify + */ + + /** + * Constructs a new OperatorSessionKeyPermissions. + * @memberof license_protocol.License.KeyContainer + * @classdesc Represents an OperatorSessionKeyPermissions. + * @implements IOperatorSessionKeyPermissions + * @constructor + * @param {license_protocol.License.KeyContainer.IOperatorSessionKeyPermissions=} [properties] Properties to set + */ + function OperatorSessionKeyPermissions(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * OperatorSessionKeyPermissions allowEncrypt. + * @member {boolean} allowEncrypt + * @memberof license_protocol.License.KeyContainer.OperatorSessionKeyPermissions + * @instance + */ + OperatorSessionKeyPermissions.prototype.allowEncrypt = false; + + /** + * OperatorSessionKeyPermissions allowDecrypt. + * @member {boolean} allowDecrypt + * @memberof license_protocol.License.KeyContainer.OperatorSessionKeyPermissions + * @instance + */ + OperatorSessionKeyPermissions.prototype.allowDecrypt = false; + + /** + * OperatorSessionKeyPermissions allowSign. + * @member {boolean} allowSign + * @memberof license_protocol.License.KeyContainer.OperatorSessionKeyPermissions + * @instance + */ + OperatorSessionKeyPermissions.prototype.allowSign = false; + + /** + * OperatorSessionKeyPermissions allowSignatureVerify. + * @member {boolean} allowSignatureVerify + * @memberof license_protocol.License.KeyContainer.OperatorSessionKeyPermissions + * @instance + */ + OperatorSessionKeyPermissions.prototype.allowSignatureVerify = false; + + /** + * Creates a new OperatorSessionKeyPermissions instance using the specified properties. + * @function create + * @memberof license_protocol.License.KeyContainer.OperatorSessionKeyPermissions + * @static + * @param {license_protocol.License.KeyContainer.IOperatorSessionKeyPermissions=} [properties] Properties to set + * @returns {license_protocol.License.KeyContainer.OperatorSessionKeyPermissions} OperatorSessionKeyPermissions instance + */ + OperatorSessionKeyPermissions.create = function create(properties) { + return new OperatorSessionKeyPermissions(properties); + }; + + /** + * Encodes the specified OperatorSessionKeyPermissions message. Does not implicitly {@link license_protocol.License.KeyContainer.OperatorSessionKeyPermissions.verify|verify} messages. + * @function encode + * @memberof license_protocol.License.KeyContainer.OperatorSessionKeyPermissions + * @static + * @param {license_protocol.License.KeyContainer.IOperatorSessionKeyPermissions} message OperatorSessionKeyPermissions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + OperatorSessionKeyPermissions.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.allowEncrypt != null && Object.hasOwnProperty.call(message, "allowEncrypt")) + writer.uint32(/* id 1, wireType 0 =*/8).bool(message.allowEncrypt); + if (message.allowDecrypt != null && Object.hasOwnProperty.call(message, "allowDecrypt")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.allowDecrypt); + if (message.allowSign != null && Object.hasOwnProperty.call(message, "allowSign")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.allowSign); + if (message.allowSignatureVerify != null && Object.hasOwnProperty.call(message, "allowSignatureVerify")) + writer.uint32(/* id 4, wireType 0 =*/32).bool(message.allowSignatureVerify); + return writer; + }; + + /** + * Encodes the specified OperatorSessionKeyPermissions message, length delimited. Does not implicitly {@link license_protocol.License.KeyContainer.OperatorSessionKeyPermissions.verify|verify} messages. + * @function encodeDelimited + * @memberof license_protocol.License.KeyContainer.OperatorSessionKeyPermissions + * @static + * @param {license_protocol.License.KeyContainer.IOperatorSessionKeyPermissions} message OperatorSessionKeyPermissions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + OperatorSessionKeyPermissions.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an OperatorSessionKeyPermissions message from the specified reader or buffer. + * @function decode + * @memberof license_protocol.License.KeyContainer.OperatorSessionKeyPermissions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {license_protocol.License.KeyContainer.OperatorSessionKeyPermissions} OperatorSessionKeyPermissions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + OperatorSessionKeyPermissions.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.license_protocol.License.KeyContainer.OperatorSessionKeyPermissions(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.allowEncrypt = reader.bool(); + break; + } + case 2: { + message.allowDecrypt = reader.bool(); + break; + } + case 3: { + message.allowSign = reader.bool(); + break; + } + case 4: { + message.allowSignatureVerify = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an OperatorSessionKeyPermissions message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof license_protocol.License.KeyContainer.OperatorSessionKeyPermissions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {license_protocol.License.KeyContainer.OperatorSessionKeyPermissions} OperatorSessionKeyPermissions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + OperatorSessionKeyPermissions.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an OperatorSessionKeyPermissions message. + * @function verify + * @memberof license_protocol.License.KeyContainer.OperatorSessionKeyPermissions + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + OperatorSessionKeyPermissions.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.allowEncrypt != null && message.hasOwnProperty("allowEncrypt")) + if (typeof message.allowEncrypt !== "boolean") + return "allowEncrypt: boolean expected"; + if (message.allowDecrypt != null && message.hasOwnProperty("allowDecrypt")) + if (typeof message.allowDecrypt !== "boolean") + return "allowDecrypt: boolean expected"; + if (message.allowSign != null && message.hasOwnProperty("allowSign")) + if (typeof message.allowSign !== "boolean") + return "allowSign: boolean expected"; + if (message.allowSignatureVerify != null && message.hasOwnProperty("allowSignatureVerify")) + if (typeof message.allowSignatureVerify !== "boolean") + return "allowSignatureVerify: boolean expected"; + return null; + }; + + /** + * Creates an OperatorSessionKeyPermissions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof license_protocol.License.KeyContainer.OperatorSessionKeyPermissions + * @static + * @param {Object.} object Plain object + * @returns {license_protocol.License.KeyContainer.OperatorSessionKeyPermissions} OperatorSessionKeyPermissions + */ + OperatorSessionKeyPermissions.fromObject = function fromObject(object) { + if (object instanceof $root.license_protocol.License.KeyContainer.OperatorSessionKeyPermissions) + return object; + var message = new $root.license_protocol.License.KeyContainer.OperatorSessionKeyPermissions(); + if (object.allowEncrypt != null) + message.allowEncrypt = Boolean(object.allowEncrypt); + if (object.allowDecrypt != null) + message.allowDecrypt = Boolean(object.allowDecrypt); + if (object.allowSign != null) + message.allowSign = Boolean(object.allowSign); + if (object.allowSignatureVerify != null) + message.allowSignatureVerify = Boolean(object.allowSignatureVerify); + return message; + }; + + /** + * Creates a plain object from an OperatorSessionKeyPermissions message. Also converts values to other types if specified. + * @function toObject + * @memberof license_protocol.License.KeyContainer.OperatorSessionKeyPermissions + * @static + * @param {license_protocol.License.KeyContainer.OperatorSessionKeyPermissions} message OperatorSessionKeyPermissions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + OperatorSessionKeyPermissions.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.allowEncrypt = false; + object.allowDecrypt = false; + object.allowSign = false; + object.allowSignatureVerify = false; + } + if (message.allowEncrypt != null && message.hasOwnProperty("allowEncrypt")) + object.allowEncrypt = message.allowEncrypt; + if (message.allowDecrypt != null && message.hasOwnProperty("allowDecrypt")) + object.allowDecrypt = message.allowDecrypt; + if (message.allowSign != null && message.hasOwnProperty("allowSign")) + object.allowSign = message.allowSign; + if (message.allowSignatureVerify != null && message.hasOwnProperty("allowSignatureVerify")) + object.allowSignatureVerify = message.allowSignatureVerify; + return object; + }; + + /** + * Converts this OperatorSessionKeyPermissions to JSON. + * @function toJSON + * @memberof license_protocol.License.KeyContainer.OperatorSessionKeyPermissions + * @instance + * @returns {Object.} JSON object + */ + OperatorSessionKeyPermissions.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for OperatorSessionKeyPermissions + * @function getTypeUrl + * @memberof license_protocol.License.KeyContainer.OperatorSessionKeyPermissions + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + OperatorSessionKeyPermissions.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/license_protocol.License.KeyContainer.OperatorSessionKeyPermissions"; + }; + + return OperatorSessionKeyPermissions; + })(); + + return KeyContainer; + })(); + + return License; + })(); + + /** + * ProtocolVersion enum. + * @name license_protocol.ProtocolVersion + * @enum {number} + * @property {number} VERSION_2_0=20 VERSION_2_0 value + * @property {number} VERSION_2_1=21 VERSION_2_1 value + * @property {number} VERSION_2_2=22 VERSION_2_2 value + */ + license_protocol.ProtocolVersion = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[20] = "VERSION_2_0"] = 20; + values[valuesById[21] = "VERSION_2_1"] = 21; + values[valuesById[22] = "VERSION_2_2"] = 22; + return values; + })(); + + license_protocol.LicenseRequest = (function() { + + /** + * Properties of a LicenseRequest. + * @memberof license_protocol + * @interface ILicenseRequest + * @property {license_protocol.IClientIdentification|null} [clientId] LicenseRequest clientId + * @property {license_protocol.LicenseRequest.IContentIdentification|null} [contentId] LicenseRequest contentId + * @property {license_protocol.LicenseRequest.RequestType|null} [type] LicenseRequest type + * @property {number|Long|null} [requestTime] LicenseRequest requestTime + * @property {Uint8Array|null} [keyControlNonceDeprecated] LicenseRequest keyControlNonceDeprecated + * @property {license_protocol.ProtocolVersion|null} [protocolVersion] LicenseRequest protocolVersion + * @property {number|null} [keyControlNonce] LicenseRequest keyControlNonce + * @property {license_protocol.IEncryptedClientIdentification|null} [encryptedClientId] LicenseRequest encryptedClientId + */ + + /** + * Constructs a new LicenseRequest. + * @memberof license_protocol + * @classdesc Represents a LicenseRequest. + * @implements ILicenseRequest + * @constructor + * @param {license_protocol.ILicenseRequest=} [properties] Properties to set + */ + function LicenseRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * LicenseRequest clientId. + * @member {license_protocol.IClientIdentification|null|undefined} clientId + * @memberof license_protocol.LicenseRequest + * @instance + */ + LicenseRequest.prototype.clientId = null; + + /** + * LicenseRequest contentId. + * @member {license_protocol.LicenseRequest.IContentIdentification|null|undefined} contentId + * @memberof license_protocol.LicenseRequest + * @instance + */ + LicenseRequest.prototype.contentId = null; + + /** + * LicenseRequest type. + * @member {license_protocol.LicenseRequest.RequestType} type + * @memberof license_protocol.LicenseRequest + * @instance + */ + LicenseRequest.prototype.type = 1; + + /** + * LicenseRequest requestTime. + * @member {number|Long} requestTime + * @memberof license_protocol.LicenseRequest + * @instance + */ + LicenseRequest.prototype.requestTime = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * LicenseRequest keyControlNonceDeprecated. + * @member {Uint8Array} keyControlNonceDeprecated + * @memberof license_protocol.LicenseRequest + * @instance + */ + LicenseRequest.prototype.keyControlNonceDeprecated = $util.newBuffer([]); + + /** + * LicenseRequest protocolVersion. + * @member {license_protocol.ProtocolVersion} protocolVersion + * @memberof license_protocol.LicenseRequest + * @instance + */ + LicenseRequest.prototype.protocolVersion = 20; + + /** + * LicenseRequest keyControlNonce. + * @member {number} keyControlNonce + * @memberof license_protocol.LicenseRequest + * @instance + */ + LicenseRequest.prototype.keyControlNonce = 0; + + /** + * LicenseRequest encryptedClientId. + * @member {license_protocol.IEncryptedClientIdentification|null|undefined} encryptedClientId + * @memberof license_protocol.LicenseRequest + * @instance + */ + LicenseRequest.prototype.encryptedClientId = null; + + /** + * Creates a new LicenseRequest instance using the specified properties. + * @function create + * @memberof license_protocol.LicenseRequest + * @static + * @param {license_protocol.ILicenseRequest=} [properties] Properties to set + * @returns {license_protocol.LicenseRequest} LicenseRequest instance + */ + LicenseRequest.create = function create(properties) { + return new LicenseRequest(properties); + }; + + /** + * Encodes the specified LicenseRequest message. Does not implicitly {@link license_protocol.LicenseRequest.verify|verify} messages. + * @function encode + * @memberof license_protocol.LicenseRequest + * @static + * @param {license_protocol.ILicenseRequest} message LicenseRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + LicenseRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.clientId != null && Object.hasOwnProperty.call(message, "clientId")) + $root.license_protocol.ClientIdentification.encode(message.clientId, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.contentId != null && Object.hasOwnProperty.call(message, "contentId")) + $root.license_protocol.LicenseRequest.ContentIdentification.encode(message.contentId, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.type != null && Object.hasOwnProperty.call(message, "type")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.type); + if (message.requestTime != null && Object.hasOwnProperty.call(message, "requestTime")) + writer.uint32(/* id 4, wireType 0 =*/32).int64(message.requestTime); + if (message.keyControlNonceDeprecated != null && Object.hasOwnProperty.call(message, "keyControlNonceDeprecated")) + writer.uint32(/* id 5, wireType 2 =*/42).bytes(message.keyControlNonceDeprecated); + if (message.protocolVersion != null && Object.hasOwnProperty.call(message, "protocolVersion")) + writer.uint32(/* id 6, wireType 0 =*/48).int32(message.protocolVersion); + if (message.keyControlNonce != null && Object.hasOwnProperty.call(message, "keyControlNonce")) + writer.uint32(/* id 7, wireType 0 =*/56).uint32(message.keyControlNonce); + if (message.encryptedClientId != null && Object.hasOwnProperty.call(message, "encryptedClientId")) + $root.license_protocol.EncryptedClientIdentification.encode(message.encryptedClientId, writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified LicenseRequest message, length delimited. Does not implicitly {@link license_protocol.LicenseRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof license_protocol.LicenseRequest + * @static + * @param {license_protocol.ILicenseRequest} message LicenseRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + LicenseRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a LicenseRequest message from the specified reader or buffer. + * @function decode + * @memberof license_protocol.LicenseRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {license_protocol.LicenseRequest} LicenseRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + LicenseRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.license_protocol.LicenseRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.clientId = $root.license_protocol.ClientIdentification.decode(reader, reader.uint32()); + break; + } + case 2: { + message.contentId = $root.license_protocol.LicenseRequest.ContentIdentification.decode(reader, reader.uint32()); + break; + } + case 3: { + message.type = reader.int32(); + break; + } + case 4: { + message.requestTime = reader.int64(); + break; + } + case 5: { + message.keyControlNonceDeprecated = reader.bytes(); + break; + } + case 6: { + message.protocolVersion = reader.int32(); + break; + } + case 7: { + message.keyControlNonce = reader.uint32(); + break; + } + case 8: { + message.encryptedClientId = $root.license_protocol.EncryptedClientIdentification.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a LicenseRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof license_protocol.LicenseRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {license_protocol.LicenseRequest} LicenseRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + LicenseRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a LicenseRequest message. + * @function verify + * @memberof license_protocol.LicenseRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + LicenseRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.clientId != null && message.hasOwnProperty("clientId")) { + var error = $root.license_protocol.ClientIdentification.verify(message.clientId); + if (error) + return "clientId." + error; + } + if (message.contentId != null && message.hasOwnProperty("contentId")) { + var error = $root.license_protocol.LicenseRequest.ContentIdentification.verify(message.contentId); + if (error) + return "contentId." + error; + } + if (message.type != null && message.hasOwnProperty("type")) + switch (message.type) { + default: + return "type: enum value expected"; + case 1: + case 2: + case 3: + break; + } + if (message.requestTime != null && message.hasOwnProperty("requestTime")) + if (!$util.isInteger(message.requestTime) && !(message.requestTime && $util.isInteger(message.requestTime.low) && $util.isInteger(message.requestTime.high))) + return "requestTime: integer|Long expected"; + if (message.keyControlNonceDeprecated != null && message.hasOwnProperty("keyControlNonceDeprecated")) + if (!(message.keyControlNonceDeprecated && typeof message.keyControlNonceDeprecated.length === "number" || $util.isString(message.keyControlNonceDeprecated))) + return "keyControlNonceDeprecated: buffer expected"; + if (message.protocolVersion != null && message.hasOwnProperty("protocolVersion")) + switch (message.protocolVersion) { + default: + return "protocolVersion: enum value expected"; + case 20: + case 21: + case 22: + break; + } + if (message.keyControlNonce != null && message.hasOwnProperty("keyControlNonce")) + if (!$util.isInteger(message.keyControlNonce)) + return "keyControlNonce: integer expected"; + if (message.encryptedClientId != null && message.hasOwnProperty("encryptedClientId")) { + var error = $root.license_protocol.EncryptedClientIdentification.verify(message.encryptedClientId); + if (error) + return "encryptedClientId." + error; + } + return null; + }; + + /** + * Creates a LicenseRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof license_protocol.LicenseRequest + * @static + * @param {Object.} object Plain object + * @returns {license_protocol.LicenseRequest} LicenseRequest + */ + LicenseRequest.fromObject = function fromObject(object) { + if (object instanceof $root.license_protocol.LicenseRequest) + return object; + var message = new $root.license_protocol.LicenseRequest(); + if (object.clientId != null) { + if (typeof object.clientId !== "object") + throw TypeError(".license_protocol.LicenseRequest.clientId: object expected"); + message.clientId = $root.license_protocol.ClientIdentification.fromObject(object.clientId); + } + if (object.contentId != null) { + if (typeof object.contentId !== "object") + throw TypeError(".license_protocol.LicenseRequest.contentId: object expected"); + message.contentId = $root.license_protocol.LicenseRequest.ContentIdentification.fromObject(object.contentId); + } + switch (object.type) { + default: + if (typeof object.type === "number") { + message.type = object.type; + break; + } + break; + case "NEW": + case 1: + message.type = 1; + break; + case "RENEWAL": + case 2: + message.type = 2; + break; + case "RELEASE": + case 3: + message.type = 3; + break; + } + if (object.requestTime != null) + if ($util.Long) + (message.requestTime = $util.Long.fromValue(object.requestTime)).unsigned = false; + else if (typeof object.requestTime === "string") + message.requestTime = parseInt(object.requestTime, 10); + else if (typeof object.requestTime === "number") + message.requestTime = object.requestTime; + else if (typeof object.requestTime === "object") + message.requestTime = new $util.LongBits(object.requestTime.low >>> 0, object.requestTime.high >>> 0).toNumber(); + if (object.keyControlNonceDeprecated != null) + if (typeof object.keyControlNonceDeprecated === "string") + $util.base64.decode(object.keyControlNonceDeprecated, message.keyControlNonceDeprecated = $util.newBuffer($util.base64.length(object.keyControlNonceDeprecated)), 0); + else if (object.keyControlNonceDeprecated.length >= 0) + message.keyControlNonceDeprecated = object.keyControlNonceDeprecated; + switch (object.protocolVersion) { + default: + if (typeof object.protocolVersion === "number") { + message.protocolVersion = object.protocolVersion; + break; + } + break; + case "VERSION_2_0": + case 20: + message.protocolVersion = 20; + break; + case "VERSION_2_1": + case 21: + message.protocolVersion = 21; + break; + case "VERSION_2_2": + case 22: + message.protocolVersion = 22; + break; + } + if (object.keyControlNonce != null) + message.keyControlNonce = object.keyControlNonce >>> 0; + if (object.encryptedClientId != null) { + if (typeof object.encryptedClientId !== "object") + throw TypeError(".license_protocol.LicenseRequest.encryptedClientId: object expected"); + message.encryptedClientId = $root.license_protocol.EncryptedClientIdentification.fromObject(object.encryptedClientId); + } + return message; + }; + + /** + * Creates a plain object from a LicenseRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof license_protocol.LicenseRequest + * @static + * @param {license_protocol.LicenseRequest} message LicenseRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + LicenseRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.clientId = null; + object.contentId = null; + object.type = options.enums === String ? "NEW" : 1; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.requestTime = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.requestTime = options.longs === String ? "0" : 0; + if (options.bytes === String) + object.keyControlNonceDeprecated = ""; + else { + object.keyControlNonceDeprecated = []; + if (options.bytes !== Array) + object.keyControlNonceDeprecated = $util.newBuffer(object.keyControlNonceDeprecated); + } + object.protocolVersion = options.enums === String ? "VERSION_2_0" : 20; + object.keyControlNonce = 0; + object.encryptedClientId = null; + } + if (message.clientId != null && message.hasOwnProperty("clientId")) + object.clientId = $root.license_protocol.ClientIdentification.toObject(message.clientId, options); + if (message.contentId != null && message.hasOwnProperty("contentId")) + object.contentId = $root.license_protocol.LicenseRequest.ContentIdentification.toObject(message.contentId, options); + if (message.type != null && message.hasOwnProperty("type")) + object.type = options.enums === String ? $root.license_protocol.LicenseRequest.RequestType[message.type] === undefined ? message.type : $root.license_protocol.LicenseRequest.RequestType[message.type] : message.type; + if (message.requestTime != null && message.hasOwnProperty("requestTime")) + if (typeof message.requestTime === "number") + object.requestTime = options.longs === String ? String(message.requestTime) : message.requestTime; + else + object.requestTime = options.longs === String ? $util.Long.prototype.toString.call(message.requestTime) : options.longs === Number ? new $util.LongBits(message.requestTime.low >>> 0, message.requestTime.high >>> 0).toNumber() : message.requestTime; + if (message.keyControlNonceDeprecated != null && message.hasOwnProperty("keyControlNonceDeprecated")) + object.keyControlNonceDeprecated = options.bytes === String ? $util.base64.encode(message.keyControlNonceDeprecated, 0, message.keyControlNonceDeprecated.length) : options.bytes === Array ? Array.prototype.slice.call(message.keyControlNonceDeprecated) : message.keyControlNonceDeprecated; + if (message.protocolVersion != null && message.hasOwnProperty("protocolVersion")) + object.protocolVersion = options.enums === String ? $root.license_protocol.ProtocolVersion[message.protocolVersion] === undefined ? message.protocolVersion : $root.license_protocol.ProtocolVersion[message.protocolVersion] : message.protocolVersion; + if (message.keyControlNonce != null && message.hasOwnProperty("keyControlNonce")) + object.keyControlNonce = message.keyControlNonce; + if (message.encryptedClientId != null && message.hasOwnProperty("encryptedClientId")) + object.encryptedClientId = $root.license_protocol.EncryptedClientIdentification.toObject(message.encryptedClientId, options); + return object; + }; + + /** + * Converts this LicenseRequest to JSON. + * @function toJSON + * @memberof license_protocol.LicenseRequest + * @instance + * @returns {Object.} JSON object + */ + LicenseRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for LicenseRequest + * @function getTypeUrl + * @memberof license_protocol.LicenseRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + LicenseRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/license_protocol.LicenseRequest"; + }; + + LicenseRequest.ContentIdentification = (function() { + + /** + * Properties of a ContentIdentification. + * @memberof license_protocol.LicenseRequest + * @interface IContentIdentification + * @property {license_protocol.LicenseRequest.ContentIdentification.IWidevinePsshData|null} [widevinePsshData] ContentIdentification widevinePsshData + * @property {license_protocol.LicenseRequest.ContentIdentification.IWebmKeyId|null} [webmKeyId] ContentIdentification webmKeyId + * @property {license_protocol.LicenseRequest.ContentIdentification.IExistingLicense|null} [existingLicense] ContentIdentification existingLicense + * @property {license_protocol.LicenseRequest.ContentIdentification.IInitData|null} [initData] ContentIdentification initData + */ + + /** + * Constructs a new ContentIdentification. + * @memberof license_protocol.LicenseRequest + * @classdesc Represents a ContentIdentification. + * @implements IContentIdentification + * @constructor + * @param {license_protocol.LicenseRequest.IContentIdentification=} [properties] Properties to set + */ + function ContentIdentification(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ContentIdentification widevinePsshData. + * @member {license_protocol.LicenseRequest.ContentIdentification.IWidevinePsshData|null|undefined} widevinePsshData + * @memberof license_protocol.LicenseRequest.ContentIdentification + * @instance + */ + ContentIdentification.prototype.widevinePsshData = null; + + /** + * ContentIdentification webmKeyId. + * @member {license_protocol.LicenseRequest.ContentIdentification.IWebmKeyId|null|undefined} webmKeyId + * @memberof license_protocol.LicenseRequest.ContentIdentification + * @instance + */ + ContentIdentification.prototype.webmKeyId = null; + + /** + * ContentIdentification existingLicense. + * @member {license_protocol.LicenseRequest.ContentIdentification.IExistingLicense|null|undefined} existingLicense + * @memberof license_protocol.LicenseRequest.ContentIdentification + * @instance + */ + ContentIdentification.prototype.existingLicense = null; + + /** + * ContentIdentification initData. + * @member {license_protocol.LicenseRequest.ContentIdentification.IInitData|null|undefined} initData + * @memberof license_protocol.LicenseRequest.ContentIdentification + * @instance + */ + ContentIdentification.prototype.initData = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * ContentIdentification contentIdVariant. + * @member {"widevinePsshData"|"webmKeyId"|"existingLicense"|"initData"|undefined} contentIdVariant + * @memberof license_protocol.LicenseRequest.ContentIdentification + * @instance + */ + Object.defineProperty(ContentIdentification.prototype, "contentIdVariant", { + get: $util.oneOfGetter($oneOfFields = ["widevinePsshData", "webmKeyId", "existingLicense", "initData"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new ContentIdentification instance using the specified properties. + * @function create + * @memberof license_protocol.LicenseRequest.ContentIdentification + * @static + * @param {license_protocol.LicenseRequest.IContentIdentification=} [properties] Properties to set + * @returns {license_protocol.LicenseRequest.ContentIdentification} ContentIdentification instance + */ + ContentIdentification.create = function create(properties) { + return new ContentIdentification(properties); + }; + + /** + * Encodes the specified ContentIdentification message. Does not implicitly {@link license_protocol.LicenseRequest.ContentIdentification.verify|verify} messages. + * @function encode + * @memberof license_protocol.LicenseRequest.ContentIdentification + * @static + * @param {license_protocol.LicenseRequest.IContentIdentification} message ContentIdentification message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ContentIdentification.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.widevinePsshData != null && Object.hasOwnProperty.call(message, "widevinePsshData")) + $root.license_protocol.LicenseRequest.ContentIdentification.WidevinePsshData.encode(message.widevinePsshData, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.webmKeyId != null && Object.hasOwnProperty.call(message, "webmKeyId")) + $root.license_protocol.LicenseRequest.ContentIdentification.WebmKeyId.encode(message.webmKeyId, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.existingLicense != null && Object.hasOwnProperty.call(message, "existingLicense")) + $root.license_protocol.LicenseRequest.ContentIdentification.ExistingLicense.encode(message.existingLicense, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.initData != null && Object.hasOwnProperty.call(message, "initData")) + $root.license_protocol.LicenseRequest.ContentIdentification.InitData.encode(message.initData, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ContentIdentification message, length delimited. Does not implicitly {@link license_protocol.LicenseRequest.ContentIdentification.verify|verify} messages. + * @function encodeDelimited + * @memberof license_protocol.LicenseRequest.ContentIdentification + * @static + * @param {license_protocol.LicenseRequest.IContentIdentification} message ContentIdentification message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ContentIdentification.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ContentIdentification message from the specified reader or buffer. + * @function decode + * @memberof license_protocol.LicenseRequest.ContentIdentification + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {license_protocol.LicenseRequest.ContentIdentification} ContentIdentification + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ContentIdentification.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.license_protocol.LicenseRequest.ContentIdentification(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.widevinePsshData = $root.license_protocol.LicenseRequest.ContentIdentification.WidevinePsshData.decode(reader, reader.uint32()); + break; + } + case 2: { + message.webmKeyId = $root.license_protocol.LicenseRequest.ContentIdentification.WebmKeyId.decode(reader, reader.uint32()); + break; + } + case 3: { + message.existingLicense = $root.license_protocol.LicenseRequest.ContentIdentification.ExistingLicense.decode(reader, reader.uint32()); + break; + } + case 4: { + message.initData = $root.license_protocol.LicenseRequest.ContentIdentification.InitData.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ContentIdentification message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof license_protocol.LicenseRequest.ContentIdentification + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {license_protocol.LicenseRequest.ContentIdentification} ContentIdentification + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ContentIdentification.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ContentIdentification message. + * @function verify + * @memberof license_protocol.LicenseRequest.ContentIdentification + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ContentIdentification.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.widevinePsshData != null && message.hasOwnProperty("widevinePsshData")) { + properties.contentIdVariant = 1; + { + var error = $root.license_protocol.LicenseRequest.ContentIdentification.WidevinePsshData.verify(message.widevinePsshData); + if (error) + return "widevinePsshData." + error; + } + } + if (message.webmKeyId != null && message.hasOwnProperty("webmKeyId")) { + if (properties.contentIdVariant === 1) + return "contentIdVariant: multiple values"; + properties.contentIdVariant = 1; + { + var error = $root.license_protocol.LicenseRequest.ContentIdentification.WebmKeyId.verify(message.webmKeyId); + if (error) + return "webmKeyId." + error; + } + } + if (message.existingLicense != null && message.hasOwnProperty("existingLicense")) { + if (properties.contentIdVariant === 1) + return "contentIdVariant: multiple values"; + properties.contentIdVariant = 1; + { + var error = $root.license_protocol.LicenseRequest.ContentIdentification.ExistingLicense.verify(message.existingLicense); + if (error) + return "existingLicense." + error; + } + } + if (message.initData != null && message.hasOwnProperty("initData")) { + if (properties.contentIdVariant === 1) + return "contentIdVariant: multiple values"; + properties.contentIdVariant = 1; + { + var error = $root.license_protocol.LicenseRequest.ContentIdentification.InitData.verify(message.initData); + if (error) + return "initData." + error; + } + } + return null; + }; + + /** + * Creates a ContentIdentification message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof license_protocol.LicenseRequest.ContentIdentification + * @static + * @param {Object.} object Plain object + * @returns {license_protocol.LicenseRequest.ContentIdentification} ContentIdentification + */ + ContentIdentification.fromObject = function fromObject(object) { + if (object instanceof $root.license_protocol.LicenseRequest.ContentIdentification) + return object; + var message = new $root.license_protocol.LicenseRequest.ContentIdentification(); + if (object.widevinePsshData != null) { + if (typeof object.widevinePsshData !== "object") + throw TypeError(".license_protocol.LicenseRequest.ContentIdentification.widevinePsshData: object expected"); + message.widevinePsshData = $root.license_protocol.LicenseRequest.ContentIdentification.WidevinePsshData.fromObject(object.widevinePsshData); + } + if (object.webmKeyId != null) { + if (typeof object.webmKeyId !== "object") + throw TypeError(".license_protocol.LicenseRequest.ContentIdentification.webmKeyId: object expected"); + message.webmKeyId = $root.license_protocol.LicenseRequest.ContentIdentification.WebmKeyId.fromObject(object.webmKeyId); + } + if (object.existingLicense != null) { + if (typeof object.existingLicense !== "object") + throw TypeError(".license_protocol.LicenseRequest.ContentIdentification.existingLicense: object expected"); + message.existingLicense = $root.license_protocol.LicenseRequest.ContentIdentification.ExistingLicense.fromObject(object.existingLicense); + } + if (object.initData != null) { + if (typeof object.initData !== "object") + throw TypeError(".license_protocol.LicenseRequest.ContentIdentification.initData: object expected"); + message.initData = $root.license_protocol.LicenseRequest.ContentIdentification.InitData.fromObject(object.initData); + } + return message; + }; + + /** + * Creates a plain object from a ContentIdentification message. Also converts values to other types if specified. + * @function toObject + * @memberof license_protocol.LicenseRequest.ContentIdentification + * @static + * @param {license_protocol.LicenseRequest.ContentIdentification} message ContentIdentification + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ContentIdentification.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.widevinePsshData != null && message.hasOwnProperty("widevinePsshData")) { + object.widevinePsshData = $root.license_protocol.LicenseRequest.ContentIdentification.WidevinePsshData.toObject(message.widevinePsshData, options); + if (options.oneofs) + object.contentIdVariant = "widevinePsshData"; + } + if (message.webmKeyId != null && message.hasOwnProperty("webmKeyId")) { + object.webmKeyId = $root.license_protocol.LicenseRequest.ContentIdentification.WebmKeyId.toObject(message.webmKeyId, options); + if (options.oneofs) + object.contentIdVariant = "webmKeyId"; + } + if (message.existingLicense != null && message.hasOwnProperty("existingLicense")) { + object.existingLicense = $root.license_protocol.LicenseRequest.ContentIdentification.ExistingLicense.toObject(message.existingLicense, options); + if (options.oneofs) + object.contentIdVariant = "existingLicense"; + } + if (message.initData != null && message.hasOwnProperty("initData")) { + object.initData = $root.license_protocol.LicenseRequest.ContentIdentification.InitData.toObject(message.initData, options); + if (options.oneofs) + object.contentIdVariant = "initData"; + } + return object; + }; + + /** + * Converts this ContentIdentification to JSON. + * @function toJSON + * @memberof license_protocol.LicenseRequest.ContentIdentification + * @instance + * @returns {Object.} JSON object + */ + ContentIdentification.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ContentIdentification + * @function getTypeUrl + * @memberof license_protocol.LicenseRequest.ContentIdentification + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ContentIdentification.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/license_protocol.LicenseRequest.ContentIdentification"; + }; + + ContentIdentification.WidevinePsshData = (function() { + + /** + * Properties of a WidevinePsshData. + * @memberof license_protocol.LicenseRequest.ContentIdentification + * @interface IWidevinePsshData + * @property {Array.|null} [psshData] WidevinePsshData psshData + * @property {license_protocol.LicenseType|null} [licenseType] WidevinePsshData licenseType + * @property {Uint8Array|null} [requestId] WidevinePsshData requestId + */ + + /** + * Constructs a new WidevinePsshData. + * @memberof license_protocol.LicenseRequest.ContentIdentification + * @classdesc Represents a WidevinePsshData. + * @implements IWidevinePsshData + * @constructor + * @param {license_protocol.LicenseRequest.ContentIdentification.IWidevinePsshData=} [properties] Properties to set + */ + function WidevinePsshData(properties) { + this.psshData = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * WidevinePsshData psshData. + * @member {Array.} psshData + * @memberof license_protocol.LicenseRequest.ContentIdentification.WidevinePsshData + * @instance + */ + WidevinePsshData.prototype.psshData = $util.emptyArray; + + /** + * WidevinePsshData licenseType. + * @member {license_protocol.LicenseType} licenseType + * @memberof license_protocol.LicenseRequest.ContentIdentification.WidevinePsshData + * @instance + */ + WidevinePsshData.prototype.licenseType = 1; + + /** + * WidevinePsshData requestId. + * @member {Uint8Array} requestId + * @memberof license_protocol.LicenseRequest.ContentIdentification.WidevinePsshData + * @instance + */ + WidevinePsshData.prototype.requestId = $util.newBuffer([]); + + /** + * Creates a new WidevinePsshData instance using the specified properties. + * @function create + * @memberof license_protocol.LicenseRequest.ContentIdentification.WidevinePsshData + * @static + * @param {license_protocol.LicenseRequest.ContentIdentification.IWidevinePsshData=} [properties] Properties to set + * @returns {license_protocol.LicenseRequest.ContentIdentification.WidevinePsshData} WidevinePsshData instance + */ + WidevinePsshData.create = function create(properties) { + return new WidevinePsshData(properties); + }; + + /** + * Encodes the specified WidevinePsshData message. Does not implicitly {@link license_protocol.LicenseRequest.ContentIdentification.WidevinePsshData.verify|verify} messages. + * @function encode + * @memberof license_protocol.LicenseRequest.ContentIdentification.WidevinePsshData + * @static + * @param {license_protocol.LicenseRequest.ContentIdentification.IWidevinePsshData} message WidevinePsshData message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + WidevinePsshData.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.psshData != null && message.psshData.length) + for (var i = 0; i < message.psshData.length; ++i) + writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.psshData[i]); + if (message.licenseType != null && Object.hasOwnProperty.call(message, "licenseType")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.licenseType); + if (message.requestId != null && Object.hasOwnProperty.call(message, "requestId")) + writer.uint32(/* id 3, wireType 2 =*/26).bytes(message.requestId); + return writer; + }; + + /** + * Encodes the specified WidevinePsshData message, length delimited. Does not implicitly {@link license_protocol.LicenseRequest.ContentIdentification.WidevinePsshData.verify|verify} messages. + * @function encodeDelimited + * @memberof license_protocol.LicenseRequest.ContentIdentification.WidevinePsshData + * @static + * @param {license_protocol.LicenseRequest.ContentIdentification.IWidevinePsshData} message WidevinePsshData message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + WidevinePsshData.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a WidevinePsshData message from the specified reader or buffer. + * @function decode + * @memberof license_protocol.LicenseRequest.ContentIdentification.WidevinePsshData + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {license_protocol.LicenseRequest.ContentIdentification.WidevinePsshData} WidevinePsshData + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + WidevinePsshData.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.license_protocol.LicenseRequest.ContentIdentification.WidevinePsshData(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.psshData && message.psshData.length)) + message.psshData = []; + message.psshData.push(reader.bytes()); + break; + } + case 2: { + message.licenseType = reader.int32(); + break; + } + case 3: { + message.requestId = reader.bytes(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a WidevinePsshData message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof license_protocol.LicenseRequest.ContentIdentification.WidevinePsshData + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {license_protocol.LicenseRequest.ContentIdentification.WidevinePsshData} WidevinePsshData + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + WidevinePsshData.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a WidevinePsshData message. + * @function verify + * @memberof license_protocol.LicenseRequest.ContentIdentification.WidevinePsshData + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + WidevinePsshData.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.psshData != null && message.hasOwnProperty("psshData")) { + if (!Array.isArray(message.psshData)) + return "psshData: array expected"; + for (var i = 0; i < message.psshData.length; ++i) + if (!(message.psshData[i] && typeof message.psshData[i].length === "number" || $util.isString(message.psshData[i]))) + return "psshData: buffer[] expected"; + } + if (message.licenseType != null && message.hasOwnProperty("licenseType")) + switch (message.licenseType) { + default: + return "licenseType: enum value expected"; + case 1: + case 2: + case 3: + break; + } + if (message.requestId != null && message.hasOwnProperty("requestId")) + if (!(message.requestId && typeof message.requestId.length === "number" || $util.isString(message.requestId))) + return "requestId: buffer expected"; + return null; + }; + + /** + * Creates a WidevinePsshData message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof license_protocol.LicenseRequest.ContentIdentification.WidevinePsshData + * @static + * @param {Object.} object Plain object + * @returns {license_protocol.LicenseRequest.ContentIdentification.WidevinePsshData} WidevinePsshData + */ + WidevinePsshData.fromObject = function fromObject(object) { + if (object instanceof $root.license_protocol.LicenseRequest.ContentIdentification.WidevinePsshData) + return object; + var message = new $root.license_protocol.LicenseRequest.ContentIdentification.WidevinePsshData(); + if (object.psshData) { + if (!Array.isArray(object.psshData)) + throw TypeError(".license_protocol.LicenseRequest.ContentIdentification.WidevinePsshData.psshData: array expected"); + message.psshData = []; + for (var i = 0; i < object.psshData.length; ++i) + if (typeof object.psshData[i] === "string") + $util.base64.decode(object.psshData[i], message.psshData[i] = $util.newBuffer($util.base64.length(object.psshData[i])), 0); + else if (object.psshData[i].length >= 0) + message.psshData[i] = object.psshData[i]; + } + switch (object.licenseType) { + default: + if (typeof object.licenseType === "number") { + message.licenseType = object.licenseType; + break; + } + break; + case "STREAMING": + case 1: + message.licenseType = 1; + break; + case "OFFLINE": + case 2: + message.licenseType = 2; + break; + case "AUTOMATIC": + case 3: + message.licenseType = 3; + break; + } + if (object.requestId != null) + if (typeof object.requestId === "string") + $util.base64.decode(object.requestId, message.requestId = $util.newBuffer($util.base64.length(object.requestId)), 0); + else if (object.requestId.length >= 0) + message.requestId = object.requestId; + return message; + }; + + /** + * Creates a plain object from a WidevinePsshData message. Also converts values to other types if specified. + * @function toObject + * @memberof license_protocol.LicenseRequest.ContentIdentification.WidevinePsshData + * @static + * @param {license_protocol.LicenseRequest.ContentIdentification.WidevinePsshData} message WidevinePsshData + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + WidevinePsshData.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.psshData = []; + if (options.defaults) { + object.licenseType = options.enums === String ? "STREAMING" : 1; + if (options.bytes === String) + object.requestId = ""; + else { + object.requestId = []; + if (options.bytes !== Array) + object.requestId = $util.newBuffer(object.requestId); + } + } + if (message.psshData && message.psshData.length) { + object.psshData = []; + for (var j = 0; j < message.psshData.length; ++j) + object.psshData[j] = options.bytes === String ? $util.base64.encode(message.psshData[j], 0, message.psshData[j].length) : options.bytes === Array ? Array.prototype.slice.call(message.psshData[j]) : message.psshData[j]; + } + if (message.licenseType != null && message.hasOwnProperty("licenseType")) + object.licenseType = options.enums === String ? $root.license_protocol.LicenseType[message.licenseType] === undefined ? message.licenseType : $root.license_protocol.LicenseType[message.licenseType] : message.licenseType; + if (message.requestId != null && message.hasOwnProperty("requestId")) + object.requestId = options.bytes === String ? $util.base64.encode(message.requestId, 0, message.requestId.length) : options.bytes === Array ? Array.prototype.slice.call(message.requestId) : message.requestId; + return object; + }; + + /** + * Converts this WidevinePsshData to JSON. + * @function toJSON + * @memberof license_protocol.LicenseRequest.ContentIdentification.WidevinePsshData + * @instance + * @returns {Object.} JSON object + */ + WidevinePsshData.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for WidevinePsshData + * @function getTypeUrl + * @memberof license_protocol.LicenseRequest.ContentIdentification.WidevinePsshData + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + WidevinePsshData.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/license_protocol.LicenseRequest.ContentIdentification.WidevinePsshData"; + }; + + return WidevinePsshData; + })(); + + ContentIdentification.WebmKeyId = (function() { + + /** + * Properties of a WebmKeyId. + * @memberof license_protocol.LicenseRequest.ContentIdentification + * @interface IWebmKeyId + * @property {Uint8Array|null} [header] WebmKeyId header + * @property {license_protocol.LicenseType|null} [licenseType] WebmKeyId licenseType + * @property {Uint8Array|null} [requestId] WebmKeyId requestId + */ + + /** + * Constructs a new WebmKeyId. + * @memberof license_protocol.LicenseRequest.ContentIdentification + * @classdesc Represents a WebmKeyId. + * @implements IWebmKeyId + * @constructor + * @param {license_protocol.LicenseRequest.ContentIdentification.IWebmKeyId=} [properties] Properties to set + */ + function WebmKeyId(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * WebmKeyId header. + * @member {Uint8Array} header + * @memberof license_protocol.LicenseRequest.ContentIdentification.WebmKeyId + * @instance + */ + WebmKeyId.prototype.header = $util.newBuffer([]); + + /** + * WebmKeyId licenseType. + * @member {license_protocol.LicenseType} licenseType + * @memberof license_protocol.LicenseRequest.ContentIdentification.WebmKeyId + * @instance + */ + WebmKeyId.prototype.licenseType = 1; + + /** + * WebmKeyId requestId. + * @member {Uint8Array} requestId + * @memberof license_protocol.LicenseRequest.ContentIdentification.WebmKeyId + * @instance + */ + WebmKeyId.prototype.requestId = $util.newBuffer([]); + + /** + * Creates a new WebmKeyId instance using the specified properties. + * @function create + * @memberof license_protocol.LicenseRequest.ContentIdentification.WebmKeyId + * @static + * @param {license_protocol.LicenseRequest.ContentIdentification.IWebmKeyId=} [properties] Properties to set + * @returns {license_protocol.LicenseRequest.ContentIdentification.WebmKeyId} WebmKeyId instance + */ + WebmKeyId.create = function create(properties) { + return new WebmKeyId(properties); + }; + + /** + * Encodes the specified WebmKeyId message. Does not implicitly {@link license_protocol.LicenseRequest.ContentIdentification.WebmKeyId.verify|verify} messages. + * @function encode + * @memberof license_protocol.LicenseRequest.ContentIdentification.WebmKeyId + * @static + * @param {license_protocol.LicenseRequest.ContentIdentification.IWebmKeyId} message WebmKeyId message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + WebmKeyId.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.header != null && Object.hasOwnProperty.call(message, "header")) + writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.header); + if (message.licenseType != null && Object.hasOwnProperty.call(message, "licenseType")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.licenseType); + if (message.requestId != null && Object.hasOwnProperty.call(message, "requestId")) + writer.uint32(/* id 3, wireType 2 =*/26).bytes(message.requestId); + return writer; + }; + + /** + * Encodes the specified WebmKeyId message, length delimited. Does not implicitly {@link license_protocol.LicenseRequest.ContentIdentification.WebmKeyId.verify|verify} messages. + * @function encodeDelimited + * @memberof license_protocol.LicenseRequest.ContentIdentification.WebmKeyId + * @static + * @param {license_protocol.LicenseRequest.ContentIdentification.IWebmKeyId} message WebmKeyId message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + WebmKeyId.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a WebmKeyId message from the specified reader or buffer. + * @function decode + * @memberof license_protocol.LicenseRequest.ContentIdentification.WebmKeyId + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {license_protocol.LicenseRequest.ContentIdentification.WebmKeyId} WebmKeyId + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + WebmKeyId.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.license_protocol.LicenseRequest.ContentIdentification.WebmKeyId(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.header = reader.bytes(); + break; + } + case 2: { + message.licenseType = reader.int32(); + break; + } + case 3: { + message.requestId = reader.bytes(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a WebmKeyId message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof license_protocol.LicenseRequest.ContentIdentification.WebmKeyId + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {license_protocol.LicenseRequest.ContentIdentification.WebmKeyId} WebmKeyId + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + WebmKeyId.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a WebmKeyId message. + * @function verify + * @memberof license_protocol.LicenseRequest.ContentIdentification.WebmKeyId + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + WebmKeyId.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.header != null && message.hasOwnProperty("header")) + if (!(message.header && typeof message.header.length === "number" || $util.isString(message.header))) + return "header: buffer expected"; + if (message.licenseType != null && message.hasOwnProperty("licenseType")) + switch (message.licenseType) { + default: + return "licenseType: enum value expected"; + case 1: + case 2: + case 3: + break; + } + if (message.requestId != null && message.hasOwnProperty("requestId")) + if (!(message.requestId && typeof message.requestId.length === "number" || $util.isString(message.requestId))) + return "requestId: buffer expected"; + return null; + }; + + /** + * Creates a WebmKeyId message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof license_protocol.LicenseRequest.ContentIdentification.WebmKeyId + * @static + * @param {Object.} object Plain object + * @returns {license_protocol.LicenseRequest.ContentIdentification.WebmKeyId} WebmKeyId + */ + WebmKeyId.fromObject = function fromObject(object) { + if (object instanceof $root.license_protocol.LicenseRequest.ContentIdentification.WebmKeyId) + return object; + var message = new $root.license_protocol.LicenseRequest.ContentIdentification.WebmKeyId(); + if (object.header != null) + if (typeof object.header === "string") + $util.base64.decode(object.header, message.header = $util.newBuffer($util.base64.length(object.header)), 0); + else if (object.header.length >= 0) + message.header = object.header; + switch (object.licenseType) { + default: + if (typeof object.licenseType === "number") { + message.licenseType = object.licenseType; + break; + } + break; + case "STREAMING": + case 1: + message.licenseType = 1; + break; + case "OFFLINE": + case 2: + message.licenseType = 2; + break; + case "AUTOMATIC": + case 3: + message.licenseType = 3; + break; + } + if (object.requestId != null) + if (typeof object.requestId === "string") + $util.base64.decode(object.requestId, message.requestId = $util.newBuffer($util.base64.length(object.requestId)), 0); + else if (object.requestId.length >= 0) + message.requestId = object.requestId; + return message; + }; + + /** + * Creates a plain object from a WebmKeyId message. Also converts values to other types if specified. + * @function toObject + * @memberof license_protocol.LicenseRequest.ContentIdentification.WebmKeyId + * @static + * @param {license_protocol.LicenseRequest.ContentIdentification.WebmKeyId} message WebmKeyId + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + WebmKeyId.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + if (options.bytes === String) + object.header = ""; + else { + object.header = []; + if (options.bytes !== Array) + object.header = $util.newBuffer(object.header); + } + object.licenseType = options.enums === String ? "STREAMING" : 1; + if (options.bytes === String) + object.requestId = ""; + else { + object.requestId = []; + if (options.bytes !== Array) + object.requestId = $util.newBuffer(object.requestId); + } + } + if (message.header != null && message.hasOwnProperty("header")) + object.header = options.bytes === String ? $util.base64.encode(message.header, 0, message.header.length) : options.bytes === Array ? Array.prototype.slice.call(message.header) : message.header; + if (message.licenseType != null && message.hasOwnProperty("licenseType")) + object.licenseType = options.enums === String ? $root.license_protocol.LicenseType[message.licenseType] === undefined ? message.licenseType : $root.license_protocol.LicenseType[message.licenseType] : message.licenseType; + if (message.requestId != null && message.hasOwnProperty("requestId")) + object.requestId = options.bytes === String ? $util.base64.encode(message.requestId, 0, message.requestId.length) : options.bytes === Array ? Array.prototype.slice.call(message.requestId) : message.requestId; + return object; + }; + + /** + * Converts this WebmKeyId to JSON. + * @function toJSON + * @memberof license_protocol.LicenseRequest.ContentIdentification.WebmKeyId + * @instance + * @returns {Object.} JSON object + */ + WebmKeyId.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for WebmKeyId + * @function getTypeUrl + * @memberof license_protocol.LicenseRequest.ContentIdentification.WebmKeyId + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + WebmKeyId.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/license_protocol.LicenseRequest.ContentIdentification.WebmKeyId"; + }; + + return WebmKeyId; + })(); + + ContentIdentification.ExistingLicense = (function() { + + /** + * Properties of an ExistingLicense. + * @memberof license_protocol.LicenseRequest.ContentIdentification + * @interface IExistingLicense + * @property {license_protocol.ILicenseIdentification|null} [licenseId] ExistingLicense licenseId + * @property {number|Long|null} [secondsSinceStarted] ExistingLicense secondsSinceStarted + * @property {number|Long|null} [secondsSinceLastPlayed] ExistingLicense secondsSinceLastPlayed + * @property {Uint8Array|null} [sessionUsageTableEntry] ExistingLicense sessionUsageTableEntry + */ + + /** + * Constructs a new ExistingLicense. + * @memberof license_protocol.LicenseRequest.ContentIdentification + * @classdesc Represents an ExistingLicense. + * @implements IExistingLicense + * @constructor + * @param {license_protocol.LicenseRequest.ContentIdentification.IExistingLicense=} [properties] Properties to set + */ + function ExistingLicense(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ExistingLicense licenseId. + * @member {license_protocol.ILicenseIdentification|null|undefined} licenseId + * @memberof license_protocol.LicenseRequest.ContentIdentification.ExistingLicense + * @instance + */ + ExistingLicense.prototype.licenseId = null; + + /** + * ExistingLicense secondsSinceStarted. + * @member {number|Long} secondsSinceStarted + * @memberof license_protocol.LicenseRequest.ContentIdentification.ExistingLicense + * @instance + */ + ExistingLicense.prototype.secondsSinceStarted = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * ExistingLicense secondsSinceLastPlayed. + * @member {number|Long} secondsSinceLastPlayed + * @memberof license_protocol.LicenseRequest.ContentIdentification.ExistingLicense + * @instance + */ + ExistingLicense.prototype.secondsSinceLastPlayed = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * ExistingLicense sessionUsageTableEntry. + * @member {Uint8Array} sessionUsageTableEntry + * @memberof license_protocol.LicenseRequest.ContentIdentification.ExistingLicense + * @instance + */ + ExistingLicense.prototype.sessionUsageTableEntry = $util.newBuffer([]); + + /** + * Creates a new ExistingLicense instance using the specified properties. + * @function create + * @memberof license_protocol.LicenseRequest.ContentIdentification.ExistingLicense + * @static + * @param {license_protocol.LicenseRequest.ContentIdentification.IExistingLicense=} [properties] Properties to set + * @returns {license_protocol.LicenseRequest.ContentIdentification.ExistingLicense} ExistingLicense instance + */ + ExistingLicense.create = function create(properties) { + return new ExistingLicense(properties); + }; + + /** + * Encodes the specified ExistingLicense message. Does not implicitly {@link license_protocol.LicenseRequest.ContentIdentification.ExistingLicense.verify|verify} messages. + * @function encode + * @memberof license_protocol.LicenseRequest.ContentIdentification.ExistingLicense + * @static + * @param {license_protocol.LicenseRequest.ContentIdentification.IExistingLicense} message ExistingLicense message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExistingLicense.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.licenseId != null && Object.hasOwnProperty.call(message, "licenseId")) + $root.license_protocol.LicenseIdentification.encode(message.licenseId, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.secondsSinceStarted != null && Object.hasOwnProperty.call(message, "secondsSinceStarted")) + writer.uint32(/* id 2, wireType 0 =*/16).int64(message.secondsSinceStarted); + if (message.secondsSinceLastPlayed != null && Object.hasOwnProperty.call(message, "secondsSinceLastPlayed")) + writer.uint32(/* id 3, wireType 0 =*/24).int64(message.secondsSinceLastPlayed); + if (message.sessionUsageTableEntry != null && Object.hasOwnProperty.call(message, "sessionUsageTableEntry")) + writer.uint32(/* id 4, wireType 2 =*/34).bytes(message.sessionUsageTableEntry); + return writer; + }; + + /** + * Encodes the specified ExistingLicense message, length delimited. Does not implicitly {@link license_protocol.LicenseRequest.ContentIdentification.ExistingLicense.verify|verify} messages. + * @function encodeDelimited + * @memberof license_protocol.LicenseRequest.ContentIdentification.ExistingLicense + * @static + * @param {license_protocol.LicenseRequest.ContentIdentification.IExistingLicense} message ExistingLicense message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExistingLicense.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ExistingLicense message from the specified reader or buffer. + * @function decode + * @memberof license_protocol.LicenseRequest.ContentIdentification.ExistingLicense + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {license_protocol.LicenseRequest.ContentIdentification.ExistingLicense} ExistingLicense + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExistingLicense.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.license_protocol.LicenseRequest.ContentIdentification.ExistingLicense(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.licenseId = $root.license_protocol.LicenseIdentification.decode(reader, reader.uint32()); + break; + } + case 2: { + message.secondsSinceStarted = reader.int64(); + break; + } + case 3: { + message.secondsSinceLastPlayed = reader.int64(); + break; + } + case 4: { + message.sessionUsageTableEntry = reader.bytes(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ExistingLicense message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof license_protocol.LicenseRequest.ContentIdentification.ExistingLicense + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {license_protocol.LicenseRequest.ContentIdentification.ExistingLicense} ExistingLicense + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExistingLicense.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ExistingLicense message. + * @function verify + * @memberof license_protocol.LicenseRequest.ContentIdentification.ExistingLicense + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ExistingLicense.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.licenseId != null && message.hasOwnProperty("licenseId")) { + var error = $root.license_protocol.LicenseIdentification.verify(message.licenseId); + if (error) + return "licenseId." + error; + } + if (message.secondsSinceStarted != null && message.hasOwnProperty("secondsSinceStarted")) + if (!$util.isInteger(message.secondsSinceStarted) && !(message.secondsSinceStarted && $util.isInteger(message.secondsSinceStarted.low) && $util.isInteger(message.secondsSinceStarted.high))) + return "secondsSinceStarted: integer|Long expected"; + if (message.secondsSinceLastPlayed != null && message.hasOwnProperty("secondsSinceLastPlayed")) + if (!$util.isInteger(message.secondsSinceLastPlayed) && !(message.secondsSinceLastPlayed && $util.isInteger(message.secondsSinceLastPlayed.low) && $util.isInteger(message.secondsSinceLastPlayed.high))) + return "secondsSinceLastPlayed: integer|Long expected"; + if (message.sessionUsageTableEntry != null && message.hasOwnProperty("sessionUsageTableEntry")) + if (!(message.sessionUsageTableEntry && typeof message.sessionUsageTableEntry.length === "number" || $util.isString(message.sessionUsageTableEntry))) + return "sessionUsageTableEntry: buffer expected"; + return null; + }; + + /** + * Creates an ExistingLicense message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof license_protocol.LicenseRequest.ContentIdentification.ExistingLicense + * @static + * @param {Object.} object Plain object + * @returns {license_protocol.LicenseRequest.ContentIdentification.ExistingLicense} ExistingLicense + */ + ExistingLicense.fromObject = function fromObject(object) { + if (object instanceof $root.license_protocol.LicenseRequest.ContentIdentification.ExistingLicense) + return object; + var message = new $root.license_protocol.LicenseRequest.ContentIdentification.ExistingLicense(); + if (object.licenseId != null) { + if (typeof object.licenseId !== "object") + throw TypeError(".license_protocol.LicenseRequest.ContentIdentification.ExistingLicense.licenseId: object expected"); + message.licenseId = $root.license_protocol.LicenseIdentification.fromObject(object.licenseId); + } + if (object.secondsSinceStarted != null) + if ($util.Long) + (message.secondsSinceStarted = $util.Long.fromValue(object.secondsSinceStarted)).unsigned = false; + else if (typeof object.secondsSinceStarted === "string") + message.secondsSinceStarted = parseInt(object.secondsSinceStarted, 10); + else if (typeof object.secondsSinceStarted === "number") + message.secondsSinceStarted = object.secondsSinceStarted; + else if (typeof object.secondsSinceStarted === "object") + message.secondsSinceStarted = new $util.LongBits(object.secondsSinceStarted.low >>> 0, object.secondsSinceStarted.high >>> 0).toNumber(); + if (object.secondsSinceLastPlayed != null) + if ($util.Long) + (message.secondsSinceLastPlayed = $util.Long.fromValue(object.secondsSinceLastPlayed)).unsigned = false; + else if (typeof object.secondsSinceLastPlayed === "string") + message.secondsSinceLastPlayed = parseInt(object.secondsSinceLastPlayed, 10); + else if (typeof object.secondsSinceLastPlayed === "number") + message.secondsSinceLastPlayed = object.secondsSinceLastPlayed; + else if (typeof object.secondsSinceLastPlayed === "object") + message.secondsSinceLastPlayed = new $util.LongBits(object.secondsSinceLastPlayed.low >>> 0, object.secondsSinceLastPlayed.high >>> 0).toNumber(); + if (object.sessionUsageTableEntry != null) + if (typeof object.sessionUsageTableEntry === "string") + $util.base64.decode(object.sessionUsageTableEntry, message.sessionUsageTableEntry = $util.newBuffer($util.base64.length(object.sessionUsageTableEntry)), 0); + else if (object.sessionUsageTableEntry.length >= 0) + message.sessionUsageTableEntry = object.sessionUsageTableEntry; + return message; + }; + + /** + * Creates a plain object from an ExistingLicense message. Also converts values to other types if specified. + * @function toObject + * @memberof license_protocol.LicenseRequest.ContentIdentification.ExistingLicense + * @static + * @param {license_protocol.LicenseRequest.ContentIdentification.ExistingLicense} message ExistingLicense + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ExistingLicense.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.licenseId = null; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.secondsSinceStarted = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.secondsSinceStarted = options.longs === String ? "0" : 0; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.secondsSinceLastPlayed = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.secondsSinceLastPlayed = options.longs === String ? "0" : 0; + if (options.bytes === String) + object.sessionUsageTableEntry = ""; + else { + object.sessionUsageTableEntry = []; + if (options.bytes !== Array) + object.sessionUsageTableEntry = $util.newBuffer(object.sessionUsageTableEntry); + } + } + if (message.licenseId != null && message.hasOwnProperty("licenseId")) + object.licenseId = $root.license_protocol.LicenseIdentification.toObject(message.licenseId, options); + if (message.secondsSinceStarted != null && message.hasOwnProperty("secondsSinceStarted")) + if (typeof message.secondsSinceStarted === "number") + object.secondsSinceStarted = options.longs === String ? String(message.secondsSinceStarted) : message.secondsSinceStarted; + else + object.secondsSinceStarted = options.longs === String ? $util.Long.prototype.toString.call(message.secondsSinceStarted) : options.longs === Number ? new $util.LongBits(message.secondsSinceStarted.low >>> 0, message.secondsSinceStarted.high >>> 0).toNumber() : message.secondsSinceStarted; + if (message.secondsSinceLastPlayed != null && message.hasOwnProperty("secondsSinceLastPlayed")) + if (typeof message.secondsSinceLastPlayed === "number") + object.secondsSinceLastPlayed = options.longs === String ? String(message.secondsSinceLastPlayed) : message.secondsSinceLastPlayed; + else + object.secondsSinceLastPlayed = options.longs === String ? $util.Long.prototype.toString.call(message.secondsSinceLastPlayed) : options.longs === Number ? new $util.LongBits(message.secondsSinceLastPlayed.low >>> 0, message.secondsSinceLastPlayed.high >>> 0).toNumber() : message.secondsSinceLastPlayed; + if (message.sessionUsageTableEntry != null && message.hasOwnProperty("sessionUsageTableEntry")) + object.sessionUsageTableEntry = options.bytes === String ? $util.base64.encode(message.sessionUsageTableEntry, 0, message.sessionUsageTableEntry.length) : options.bytes === Array ? Array.prototype.slice.call(message.sessionUsageTableEntry) : message.sessionUsageTableEntry; + return object; + }; + + /** + * Converts this ExistingLicense to JSON. + * @function toJSON + * @memberof license_protocol.LicenseRequest.ContentIdentification.ExistingLicense + * @instance + * @returns {Object.} JSON object + */ + ExistingLicense.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ExistingLicense + * @function getTypeUrl + * @memberof license_protocol.LicenseRequest.ContentIdentification.ExistingLicense + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ExistingLicense.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/license_protocol.LicenseRequest.ContentIdentification.ExistingLicense"; + }; + + return ExistingLicense; + })(); + + ContentIdentification.InitData = (function() { + + /** + * Properties of an InitData. + * @memberof license_protocol.LicenseRequest.ContentIdentification + * @interface IInitData + * @property {license_protocol.LicenseRequest.ContentIdentification.InitData.InitDataType|null} [initDataType] InitData initDataType + * @property {Uint8Array|null} [initData] InitData initData + * @property {license_protocol.LicenseType|null} [licenseType] InitData licenseType + * @property {Uint8Array|null} [requestId] InitData requestId + */ + + /** + * Constructs a new InitData. + * @memberof license_protocol.LicenseRequest.ContentIdentification + * @classdesc Represents an InitData. + * @implements IInitData + * @constructor + * @param {license_protocol.LicenseRequest.ContentIdentification.IInitData=} [properties] Properties to set + */ + function InitData(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * InitData initDataType. + * @member {license_protocol.LicenseRequest.ContentIdentification.InitData.InitDataType} initDataType + * @memberof license_protocol.LicenseRequest.ContentIdentification.InitData + * @instance + */ + InitData.prototype.initDataType = 1; + + /** + * InitData initData. + * @member {Uint8Array} initData + * @memberof license_protocol.LicenseRequest.ContentIdentification.InitData + * @instance + */ + InitData.prototype.initData = $util.newBuffer([]); + + /** + * InitData licenseType. + * @member {license_protocol.LicenseType} licenseType + * @memberof license_protocol.LicenseRequest.ContentIdentification.InitData + * @instance + */ + InitData.prototype.licenseType = 1; + + /** + * InitData requestId. + * @member {Uint8Array} requestId + * @memberof license_protocol.LicenseRequest.ContentIdentification.InitData + * @instance + */ + InitData.prototype.requestId = $util.newBuffer([]); + + /** + * Creates a new InitData instance using the specified properties. + * @function create + * @memberof license_protocol.LicenseRequest.ContentIdentification.InitData + * @static + * @param {license_protocol.LicenseRequest.ContentIdentification.IInitData=} [properties] Properties to set + * @returns {license_protocol.LicenseRequest.ContentIdentification.InitData} InitData instance + */ + InitData.create = function create(properties) { + return new InitData(properties); + }; + + /** + * Encodes the specified InitData message. Does not implicitly {@link license_protocol.LicenseRequest.ContentIdentification.InitData.verify|verify} messages. + * @function encode + * @memberof license_protocol.LicenseRequest.ContentIdentification.InitData + * @static + * @param {license_protocol.LicenseRequest.ContentIdentification.IInitData} message InitData message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + InitData.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.initDataType != null && Object.hasOwnProperty.call(message, "initDataType")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.initDataType); + if (message.initData != null && Object.hasOwnProperty.call(message, "initData")) + writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.initData); + if (message.licenseType != null && Object.hasOwnProperty.call(message, "licenseType")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.licenseType); + if (message.requestId != null && Object.hasOwnProperty.call(message, "requestId")) + writer.uint32(/* id 4, wireType 2 =*/34).bytes(message.requestId); + return writer; + }; + + /** + * Encodes the specified InitData message, length delimited. Does not implicitly {@link license_protocol.LicenseRequest.ContentIdentification.InitData.verify|verify} messages. + * @function encodeDelimited + * @memberof license_protocol.LicenseRequest.ContentIdentification.InitData + * @static + * @param {license_protocol.LicenseRequest.ContentIdentification.IInitData} message InitData message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + InitData.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an InitData message from the specified reader or buffer. + * @function decode + * @memberof license_protocol.LicenseRequest.ContentIdentification.InitData + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {license_protocol.LicenseRequest.ContentIdentification.InitData} InitData + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + InitData.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.license_protocol.LicenseRequest.ContentIdentification.InitData(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.initDataType = reader.int32(); + break; + } + case 2: { + message.initData = reader.bytes(); + break; + } + case 3: { + message.licenseType = reader.int32(); + break; + } + case 4: { + message.requestId = reader.bytes(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an InitData message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof license_protocol.LicenseRequest.ContentIdentification.InitData + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {license_protocol.LicenseRequest.ContentIdentification.InitData} InitData + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + InitData.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an InitData message. + * @function verify + * @memberof license_protocol.LicenseRequest.ContentIdentification.InitData + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + InitData.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.initDataType != null && message.hasOwnProperty("initDataType")) + switch (message.initDataType) { + default: + return "initDataType: enum value expected"; + case 1: + case 2: + break; + } + if (message.initData != null && message.hasOwnProperty("initData")) + if (!(message.initData && typeof message.initData.length === "number" || $util.isString(message.initData))) + return "initData: buffer expected"; + if (message.licenseType != null && message.hasOwnProperty("licenseType")) + switch (message.licenseType) { + default: + return "licenseType: enum value expected"; + case 1: + case 2: + case 3: + break; + } + if (message.requestId != null && message.hasOwnProperty("requestId")) + if (!(message.requestId && typeof message.requestId.length === "number" || $util.isString(message.requestId))) + return "requestId: buffer expected"; + return null; + }; + + /** + * Creates an InitData message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof license_protocol.LicenseRequest.ContentIdentification.InitData + * @static + * @param {Object.} object Plain object + * @returns {license_protocol.LicenseRequest.ContentIdentification.InitData} InitData + */ + InitData.fromObject = function fromObject(object) { + if (object instanceof $root.license_protocol.LicenseRequest.ContentIdentification.InitData) + return object; + var message = new $root.license_protocol.LicenseRequest.ContentIdentification.InitData(); + switch (object.initDataType) { + default: + if (typeof object.initDataType === "number") { + message.initDataType = object.initDataType; + break; + } + break; + case "CENC": + case 1: + message.initDataType = 1; + break; + case "WEBM": + case 2: + message.initDataType = 2; + break; + } + if (object.initData != null) + if (typeof object.initData === "string") + $util.base64.decode(object.initData, message.initData = $util.newBuffer($util.base64.length(object.initData)), 0); + else if (object.initData.length >= 0) + message.initData = object.initData; + switch (object.licenseType) { + default: + if (typeof object.licenseType === "number") { + message.licenseType = object.licenseType; + break; + } + break; + case "STREAMING": + case 1: + message.licenseType = 1; + break; + case "OFFLINE": + case 2: + message.licenseType = 2; + break; + case "AUTOMATIC": + case 3: + message.licenseType = 3; + break; + } + if (object.requestId != null) + if (typeof object.requestId === "string") + $util.base64.decode(object.requestId, message.requestId = $util.newBuffer($util.base64.length(object.requestId)), 0); + else if (object.requestId.length >= 0) + message.requestId = object.requestId; + return message; + }; + + /** + * Creates a plain object from an InitData message. Also converts values to other types if specified. + * @function toObject + * @memberof license_protocol.LicenseRequest.ContentIdentification.InitData + * @static + * @param {license_protocol.LicenseRequest.ContentIdentification.InitData} message InitData + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + InitData.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.initDataType = options.enums === String ? "CENC" : 1; + if (options.bytes === String) + object.initData = ""; + else { + object.initData = []; + if (options.bytes !== Array) + object.initData = $util.newBuffer(object.initData); + } + object.licenseType = options.enums === String ? "STREAMING" : 1; + if (options.bytes === String) + object.requestId = ""; + else { + object.requestId = []; + if (options.bytes !== Array) + object.requestId = $util.newBuffer(object.requestId); + } + } + if (message.initDataType != null && message.hasOwnProperty("initDataType")) + object.initDataType = options.enums === String ? $root.license_protocol.LicenseRequest.ContentIdentification.InitData.InitDataType[message.initDataType] === undefined ? message.initDataType : $root.license_protocol.LicenseRequest.ContentIdentification.InitData.InitDataType[message.initDataType] : message.initDataType; + if (message.initData != null && message.hasOwnProperty("initData")) + object.initData = options.bytes === String ? $util.base64.encode(message.initData, 0, message.initData.length) : options.bytes === Array ? Array.prototype.slice.call(message.initData) : message.initData; + if (message.licenseType != null && message.hasOwnProperty("licenseType")) + object.licenseType = options.enums === String ? $root.license_protocol.LicenseType[message.licenseType] === undefined ? message.licenseType : $root.license_protocol.LicenseType[message.licenseType] : message.licenseType; + if (message.requestId != null && message.hasOwnProperty("requestId")) + object.requestId = options.bytes === String ? $util.base64.encode(message.requestId, 0, message.requestId.length) : options.bytes === Array ? Array.prototype.slice.call(message.requestId) : message.requestId; + return object; + }; + + /** + * Converts this InitData to JSON. + * @function toJSON + * @memberof license_protocol.LicenseRequest.ContentIdentification.InitData + * @instance + * @returns {Object.} JSON object + */ + InitData.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for InitData + * @function getTypeUrl + * @memberof license_protocol.LicenseRequest.ContentIdentification.InitData + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + InitData.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/license_protocol.LicenseRequest.ContentIdentification.InitData"; + }; + + /** + * InitDataType enum. + * @name license_protocol.LicenseRequest.ContentIdentification.InitData.InitDataType + * @enum {number} + * @property {number} CENC=1 CENC value + * @property {number} WEBM=2 WEBM value + */ + InitData.InitDataType = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[1] = "CENC"] = 1; + values[valuesById[2] = "WEBM"] = 2; + return values; + })(); + + return InitData; + })(); + + return ContentIdentification; + })(); + + /** + * RequestType enum. + * @name license_protocol.LicenseRequest.RequestType + * @enum {number} + * @property {number} NEW=1 NEW value + * @property {number} RENEWAL=2 RENEWAL value + * @property {number} RELEASE=3 RELEASE value + */ + LicenseRequest.RequestType = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[1] = "NEW"] = 1; + values[valuesById[2] = "RENEWAL"] = 2; + values[valuesById[3] = "RELEASE"] = 3; + return values; + })(); + + return LicenseRequest; + })(); + + license_protocol.MetricData = (function() { + + /** + * Properties of a MetricData. + * @memberof license_protocol + * @interface IMetricData + * @property {string|null} [stageName] MetricData stageName + * @property {Array.|null} [metricData] MetricData metricData + */ + + /** + * Constructs a new MetricData. + * @memberof license_protocol + * @classdesc Represents a MetricData. + * @implements IMetricData + * @constructor + * @param {license_protocol.IMetricData=} [properties] Properties to set + */ + function MetricData(properties) { + this.metricData = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * MetricData stageName. + * @member {string} stageName + * @memberof license_protocol.MetricData + * @instance + */ + MetricData.prototype.stageName = ""; + + /** + * MetricData metricData. + * @member {Array.} metricData + * @memberof license_protocol.MetricData + * @instance + */ + MetricData.prototype.metricData = $util.emptyArray; + + /** + * Creates a new MetricData instance using the specified properties. + * @function create + * @memberof license_protocol.MetricData + * @static + * @param {license_protocol.IMetricData=} [properties] Properties to set + * @returns {license_protocol.MetricData} MetricData instance + */ + MetricData.create = function create(properties) { + return new MetricData(properties); + }; + + /** + * Encodes the specified MetricData message. Does not implicitly {@link license_protocol.MetricData.verify|verify} messages. + * @function encode + * @memberof license_protocol.MetricData + * @static + * @param {license_protocol.IMetricData} message MetricData message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MetricData.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.stageName != null && Object.hasOwnProperty.call(message, "stageName")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.stageName); + if (message.metricData != null && message.metricData.length) + for (var i = 0; i < message.metricData.length; ++i) + $root.license_protocol.MetricData.TypeValue.encode(message.metricData[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified MetricData message, length delimited. Does not implicitly {@link license_protocol.MetricData.verify|verify} messages. + * @function encodeDelimited + * @memberof license_protocol.MetricData + * @static + * @param {license_protocol.IMetricData} message MetricData message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MetricData.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a MetricData message from the specified reader or buffer. + * @function decode + * @memberof license_protocol.MetricData + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {license_protocol.MetricData} MetricData + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MetricData.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.license_protocol.MetricData(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.stageName = reader.string(); + break; + } + case 2: { + if (!(message.metricData && message.metricData.length)) + message.metricData = []; + message.metricData.push($root.license_protocol.MetricData.TypeValue.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a MetricData message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof license_protocol.MetricData + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {license_protocol.MetricData} MetricData + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MetricData.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a MetricData message. + * @function verify + * @memberof license_protocol.MetricData + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + MetricData.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.stageName != null && message.hasOwnProperty("stageName")) + if (!$util.isString(message.stageName)) + return "stageName: string expected"; + if (message.metricData != null && message.hasOwnProperty("metricData")) { + if (!Array.isArray(message.metricData)) + return "metricData: array expected"; + for (var i = 0; i < message.metricData.length; ++i) { + var error = $root.license_protocol.MetricData.TypeValue.verify(message.metricData[i]); + if (error) + return "metricData." + error; + } + } + return null; + }; + + /** + * Creates a MetricData message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof license_protocol.MetricData + * @static + * @param {Object.} object Plain object + * @returns {license_protocol.MetricData} MetricData + */ + MetricData.fromObject = function fromObject(object) { + if (object instanceof $root.license_protocol.MetricData) + return object; + var message = new $root.license_protocol.MetricData(); + if (object.stageName != null) + message.stageName = String(object.stageName); + if (object.metricData) { + if (!Array.isArray(object.metricData)) + throw TypeError(".license_protocol.MetricData.metricData: array expected"); + message.metricData = []; + for (var i = 0; i < object.metricData.length; ++i) { + if (typeof object.metricData[i] !== "object") + throw TypeError(".license_protocol.MetricData.metricData: object expected"); + message.metricData[i] = $root.license_protocol.MetricData.TypeValue.fromObject(object.metricData[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a MetricData message. Also converts values to other types if specified. + * @function toObject + * @memberof license_protocol.MetricData + * @static + * @param {license_protocol.MetricData} message MetricData + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + MetricData.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.metricData = []; + if (options.defaults) + object.stageName = ""; + if (message.stageName != null && message.hasOwnProperty("stageName")) + object.stageName = message.stageName; + if (message.metricData && message.metricData.length) { + object.metricData = []; + for (var j = 0; j < message.metricData.length; ++j) + object.metricData[j] = $root.license_protocol.MetricData.TypeValue.toObject(message.metricData[j], options); + } + return object; + }; + + /** + * Converts this MetricData to JSON. + * @function toJSON + * @memberof license_protocol.MetricData + * @instance + * @returns {Object.} JSON object + */ + MetricData.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for MetricData + * @function getTypeUrl + * @memberof license_protocol.MetricData + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + MetricData.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/license_protocol.MetricData"; + }; + + /** + * MetricType enum. + * @name license_protocol.MetricData.MetricType + * @enum {number} + * @property {number} LATENCY=1 LATENCY value + * @property {number} TIMESTAMP=2 TIMESTAMP value + */ + MetricData.MetricType = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[1] = "LATENCY"] = 1; + values[valuesById[2] = "TIMESTAMP"] = 2; + return values; + })(); + + MetricData.TypeValue = (function() { + + /** + * Properties of a TypeValue. + * @memberof license_protocol.MetricData + * @interface ITypeValue + * @property {license_protocol.MetricData.MetricType|null} [type] TypeValue type + * @property {number|Long|null} [value] TypeValue value + */ + + /** + * Constructs a new TypeValue. + * @memberof license_protocol.MetricData + * @classdesc Represents a TypeValue. + * @implements ITypeValue + * @constructor + * @param {license_protocol.MetricData.ITypeValue=} [properties] Properties to set + */ + function TypeValue(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * TypeValue type. + * @member {license_protocol.MetricData.MetricType} type + * @memberof license_protocol.MetricData.TypeValue + * @instance + */ + TypeValue.prototype.type = 1; + + /** + * TypeValue value. + * @member {number|Long} value + * @memberof license_protocol.MetricData.TypeValue + * @instance + */ + TypeValue.prototype.value = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Creates a new TypeValue instance using the specified properties. + * @function create + * @memberof license_protocol.MetricData.TypeValue + * @static + * @param {license_protocol.MetricData.ITypeValue=} [properties] Properties to set + * @returns {license_protocol.MetricData.TypeValue} TypeValue instance + */ + TypeValue.create = function create(properties) { + return new TypeValue(properties); + }; + + /** + * Encodes the specified TypeValue message. Does not implicitly {@link license_protocol.MetricData.TypeValue.verify|verify} messages. + * @function encode + * @memberof license_protocol.MetricData.TypeValue + * @static + * @param {license_protocol.MetricData.ITypeValue} message TypeValue message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + TypeValue.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.type != null && Object.hasOwnProperty.call(message, "type")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.type); + if (message.value != null && Object.hasOwnProperty.call(message, "value")) + writer.uint32(/* id 2, wireType 0 =*/16).int64(message.value); + return writer; + }; + + /** + * Encodes the specified TypeValue message, length delimited. Does not implicitly {@link license_protocol.MetricData.TypeValue.verify|verify} messages. + * @function encodeDelimited + * @memberof license_protocol.MetricData.TypeValue + * @static + * @param {license_protocol.MetricData.ITypeValue} message TypeValue message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + TypeValue.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a TypeValue message from the specified reader or buffer. + * @function decode + * @memberof license_protocol.MetricData.TypeValue + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {license_protocol.MetricData.TypeValue} TypeValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TypeValue.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.license_protocol.MetricData.TypeValue(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.type = reader.int32(); + break; + } + case 2: { + message.value = reader.int64(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a TypeValue message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof license_protocol.MetricData.TypeValue + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {license_protocol.MetricData.TypeValue} TypeValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TypeValue.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a TypeValue message. + * @function verify + * @memberof license_protocol.MetricData.TypeValue + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + TypeValue.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.type != null && message.hasOwnProperty("type")) + switch (message.type) { + default: + return "type: enum value expected"; + case 1: + case 2: + break; + } + if (message.value != null && message.hasOwnProperty("value")) + if (!$util.isInteger(message.value) && !(message.value && $util.isInteger(message.value.low) && $util.isInteger(message.value.high))) + return "value: integer|Long expected"; + return null; + }; + + /** + * Creates a TypeValue message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof license_protocol.MetricData.TypeValue + * @static + * @param {Object.} object Plain object + * @returns {license_protocol.MetricData.TypeValue} TypeValue + */ + TypeValue.fromObject = function fromObject(object) { + if (object instanceof $root.license_protocol.MetricData.TypeValue) + return object; + var message = new $root.license_protocol.MetricData.TypeValue(); + switch (object.type) { + default: + if (typeof object.type === "number") { + message.type = object.type; + break; + } + break; + case "LATENCY": + case 1: + message.type = 1; + break; + case "TIMESTAMP": + case 2: + message.type = 2; + break; + } + if (object.value != null) + if ($util.Long) + (message.value = $util.Long.fromValue(object.value)).unsigned = false; + else if (typeof object.value === "string") + message.value = parseInt(object.value, 10); + else if (typeof object.value === "number") + message.value = object.value; + else if (typeof object.value === "object") + message.value = new $util.LongBits(object.value.low >>> 0, object.value.high >>> 0).toNumber(); + return message; + }; + + /** + * Creates a plain object from a TypeValue message. Also converts values to other types if specified. + * @function toObject + * @memberof license_protocol.MetricData.TypeValue + * @static + * @param {license_protocol.MetricData.TypeValue} message TypeValue + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + TypeValue.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.type = options.enums === String ? "LATENCY" : 1; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.value = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.value = options.longs === String ? "0" : 0; + } + if (message.type != null && message.hasOwnProperty("type")) + object.type = options.enums === String ? $root.license_protocol.MetricData.MetricType[message.type] === undefined ? message.type : $root.license_protocol.MetricData.MetricType[message.type] : message.type; + if (message.value != null && message.hasOwnProperty("value")) + if (typeof message.value === "number") + object.value = options.longs === String ? String(message.value) : message.value; + else + object.value = options.longs === String ? $util.Long.prototype.toString.call(message.value) : options.longs === Number ? new $util.LongBits(message.value.low >>> 0, message.value.high >>> 0).toNumber() : message.value; + return object; + }; + + /** + * Converts this TypeValue to JSON. + * @function toJSON + * @memberof license_protocol.MetricData.TypeValue + * @instance + * @returns {Object.} JSON object + */ + TypeValue.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for TypeValue + * @function getTypeUrl + * @memberof license_protocol.MetricData.TypeValue + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + TypeValue.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/license_protocol.MetricData.TypeValue"; + }; + + return TypeValue; + })(); + + return MetricData; + })(); + + license_protocol.VersionInfo = (function() { + + /** + * Properties of a VersionInfo. + * @memberof license_protocol + * @interface IVersionInfo + * @property {string|null} [licenseSdkVersion] VersionInfo licenseSdkVersion + * @property {string|null} [licenseServiceVersion] VersionInfo licenseServiceVersion + */ + + /** + * Constructs a new VersionInfo. + * @memberof license_protocol + * @classdesc Represents a VersionInfo. + * @implements IVersionInfo + * @constructor + * @param {license_protocol.IVersionInfo=} [properties] Properties to set + */ + function VersionInfo(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * VersionInfo licenseSdkVersion. + * @member {string} licenseSdkVersion + * @memberof license_protocol.VersionInfo + * @instance + */ + VersionInfo.prototype.licenseSdkVersion = ""; + + /** + * VersionInfo licenseServiceVersion. + * @member {string} licenseServiceVersion + * @memberof license_protocol.VersionInfo + * @instance + */ + VersionInfo.prototype.licenseServiceVersion = ""; + + /** + * Creates a new VersionInfo instance using the specified properties. + * @function create + * @memberof license_protocol.VersionInfo + * @static + * @param {license_protocol.IVersionInfo=} [properties] Properties to set + * @returns {license_protocol.VersionInfo} VersionInfo instance + */ + VersionInfo.create = function create(properties) { + return new VersionInfo(properties); + }; + + /** + * Encodes the specified VersionInfo message. Does not implicitly {@link license_protocol.VersionInfo.verify|verify} messages. + * @function encode + * @memberof license_protocol.VersionInfo + * @static + * @param {license_protocol.IVersionInfo} message VersionInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + VersionInfo.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.licenseSdkVersion != null && Object.hasOwnProperty.call(message, "licenseSdkVersion")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.licenseSdkVersion); + if (message.licenseServiceVersion != null && Object.hasOwnProperty.call(message, "licenseServiceVersion")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.licenseServiceVersion); + return writer; + }; + + /** + * Encodes the specified VersionInfo message, length delimited. Does not implicitly {@link license_protocol.VersionInfo.verify|verify} messages. + * @function encodeDelimited + * @memberof license_protocol.VersionInfo + * @static + * @param {license_protocol.IVersionInfo} message VersionInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + VersionInfo.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a VersionInfo message from the specified reader or buffer. + * @function decode + * @memberof license_protocol.VersionInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {license_protocol.VersionInfo} VersionInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + VersionInfo.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.license_protocol.VersionInfo(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.licenseSdkVersion = reader.string(); + break; + } + case 2: { + message.licenseServiceVersion = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a VersionInfo message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof license_protocol.VersionInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {license_protocol.VersionInfo} VersionInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + VersionInfo.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a VersionInfo message. + * @function verify + * @memberof license_protocol.VersionInfo + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + VersionInfo.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.licenseSdkVersion != null && message.hasOwnProperty("licenseSdkVersion")) + if (!$util.isString(message.licenseSdkVersion)) + return "licenseSdkVersion: string expected"; + if (message.licenseServiceVersion != null && message.hasOwnProperty("licenseServiceVersion")) + if (!$util.isString(message.licenseServiceVersion)) + return "licenseServiceVersion: string expected"; + return null; + }; + + /** + * Creates a VersionInfo message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof license_protocol.VersionInfo + * @static + * @param {Object.} object Plain object + * @returns {license_protocol.VersionInfo} VersionInfo + */ + VersionInfo.fromObject = function fromObject(object) { + if (object instanceof $root.license_protocol.VersionInfo) + return object; + var message = new $root.license_protocol.VersionInfo(); + if (object.licenseSdkVersion != null) + message.licenseSdkVersion = String(object.licenseSdkVersion); + if (object.licenseServiceVersion != null) + message.licenseServiceVersion = String(object.licenseServiceVersion); + return message; + }; + + /** + * Creates a plain object from a VersionInfo message. Also converts values to other types if specified. + * @function toObject + * @memberof license_protocol.VersionInfo + * @static + * @param {license_protocol.VersionInfo} message VersionInfo + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + VersionInfo.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.licenseSdkVersion = ""; + object.licenseServiceVersion = ""; + } + if (message.licenseSdkVersion != null && message.hasOwnProperty("licenseSdkVersion")) + object.licenseSdkVersion = message.licenseSdkVersion; + if (message.licenseServiceVersion != null && message.hasOwnProperty("licenseServiceVersion")) + object.licenseServiceVersion = message.licenseServiceVersion; + return object; + }; + + /** + * Converts this VersionInfo to JSON. + * @function toJSON + * @memberof license_protocol.VersionInfo + * @instance + * @returns {Object.} JSON object + */ + VersionInfo.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for VersionInfo + * @function getTypeUrl + * @memberof license_protocol.VersionInfo + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + VersionInfo.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/license_protocol.VersionInfo"; + }; + + return VersionInfo; + })(); + + license_protocol.SignedMessage = (function() { + + /** + * Properties of a SignedMessage. + * @memberof license_protocol + * @interface ISignedMessage + * @property {license_protocol.SignedMessage.MessageType|null} [type] SignedMessage type + * @property {Uint8Array|null} [msg] SignedMessage msg + * @property {Uint8Array|null} [signature] SignedMessage signature + * @property {Uint8Array|null} [sessionKey] SignedMessage sessionKey + * @property {Uint8Array|null} [remoteAttestation] SignedMessage remoteAttestation + * @property {Array.|null} [metricData] SignedMessage metricData + * @property {license_protocol.IVersionInfo|null} [serviceVersionInfo] SignedMessage serviceVersionInfo + * @property {license_protocol.SignedMessage.SessionKeyType|null} [sessionKeyType] SignedMessage sessionKeyType + * @property {Uint8Array|null} [oemcryptoCoreMessage] SignedMessage oemcryptoCoreMessage + */ + + /** + * Constructs a new SignedMessage. + * @memberof license_protocol + * @classdesc Represents a SignedMessage. + * @implements ISignedMessage + * @constructor + * @param {license_protocol.ISignedMessage=} [properties] Properties to set + */ + function SignedMessage(properties) { + this.metricData = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * SignedMessage type. + * @member {license_protocol.SignedMessage.MessageType} type + * @memberof license_protocol.SignedMessage + * @instance + */ + SignedMessage.prototype.type = 1; + + /** + * SignedMessage msg. + * @member {Uint8Array} msg + * @memberof license_protocol.SignedMessage + * @instance + */ + SignedMessage.prototype.msg = $util.newBuffer([]); + + /** + * SignedMessage signature. + * @member {Uint8Array} signature + * @memberof license_protocol.SignedMessage + * @instance + */ + SignedMessage.prototype.signature = $util.newBuffer([]); + + /** + * SignedMessage sessionKey. + * @member {Uint8Array} sessionKey + * @memberof license_protocol.SignedMessage + * @instance + */ + SignedMessage.prototype.sessionKey = $util.newBuffer([]); + + /** + * SignedMessage remoteAttestation. + * @member {Uint8Array} remoteAttestation + * @memberof license_protocol.SignedMessage + * @instance + */ + SignedMessage.prototype.remoteAttestation = $util.newBuffer([]); + + /** + * SignedMessage metricData. + * @member {Array.} metricData + * @memberof license_protocol.SignedMessage + * @instance + */ + SignedMessage.prototype.metricData = $util.emptyArray; + + /** + * SignedMessage serviceVersionInfo. + * @member {license_protocol.IVersionInfo|null|undefined} serviceVersionInfo + * @memberof license_protocol.SignedMessage + * @instance + */ + SignedMessage.prototype.serviceVersionInfo = null; + + /** + * SignedMessage sessionKeyType. + * @member {license_protocol.SignedMessage.SessionKeyType} sessionKeyType + * @memberof license_protocol.SignedMessage + * @instance + */ + SignedMessage.prototype.sessionKeyType = 1; + + /** + * SignedMessage oemcryptoCoreMessage. + * @member {Uint8Array} oemcryptoCoreMessage + * @memberof license_protocol.SignedMessage + * @instance + */ + SignedMessage.prototype.oemcryptoCoreMessage = $util.newBuffer([]); + + /** + * Creates a new SignedMessage instance using the specified properties. + * @function create + * @memberof license_protocol.SignedMessage + * @static + * @param {license_protocol.ISignedMessage=} [properties] Properties to set + * @returns {license_protocol.SignedMessage} SignedMessage instance + */ + SignedMessage.create = function create(properties) { + return new SignedMessage(properties); + }; + + /** + * Encodes the specified SignedMessage message. Does not implicitly {@link license_protocol.SignedMessage.verify|verify} messages. + * @function encode + * @memberof license_protocol.SignedMessage + * @static + * @param {license_protocol.ISignedMessage} message SignedMessage message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SignedMessage.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.type != null && Object.hasOwnProperty.call(message, "type")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.type); + if (message.msg != null && Object.hasOwnProperty.call(message, "msg")) + writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.msg); + if (message.signature != null && Object.hasOwnProperty.call(message, "signature")) + writer.uint32(/* id 3, wireType 2 =*/26).bytes(message.signature); + if (message.sessionKey != null && Object.hasOwnProperty.call(message, "sessionKey")) + writer.uint32(/* id 4, wireType 2 =*/34).bytes(message.sessionKey); + if (message.remoteAttestation != null && Object.hasOwnProperty.call(message, "remoteAttestation")) + writer.uint32(/* id 5, wireType 2 =*/42).bytes(message.remoteAttestation); + if (message.metricData != null && message.metricData.length) + for (var i = 0; i < message.metricData.length; ++i) + $root.license_protocol.MetricData.encode(message.metricData[i], writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + if (message.serviceVersionInfo != null && Object.hasOwnProperty.call(message, "serviceVersionInfo")) + $root.license_protocol.VersionInfo.encode(message.serviceVersionInfo, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); + if (message.sessionKeyType != null && Object.hasOwnProperty.call(message, "sessionKeyType")) + writer.uint32(/* id 8, wireType 0 =*/64).int32(message.sessionKeyType); + if (message.oemcryptoCoreMessage != null && Object.hasOwnProperty.call(message, "oemcryptoCoreMessage")) + writer.uint32(/* id 9, wireType 2 =*/74).bytes(message.oemcryptoCoreMessage); + return writer; + }; + + /** + * Encodes the specified SignedMessage message, length delimited. Does not implicitly {@link license_protocol.SignedMessage.verify|verify} messages. + * @function encodeDelimited + * @memberof license_protocol.SignedMessage + * @static + * @param {license_protocol.ISignedMessage} message SignedMessage message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SignedMessage.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SignedMessage message from the specified reader or buffer. + * @function decode + * @memberof license_protocol.SignedMessage + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {license_protocol.SignedMessage} SignedMessage + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SignedMessage.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.license_protocol.SignedMessage(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.type = reader.int32(); + break; + } + case 2: { + message.msg = reader.bytes(); + break; + } + case 3: { + message.signature = reader.bytes(); + break; + } + case 4: { + message.sessionKey = reader.bytes(); + break; + } + case 5: { + message.remoteAttestation = reader.bytes(); + break; + } + case 6: { + if (!(message.metricData && message.metricData.length)) + message.metricData = []; + message.metricData.push($root.license_protocol.MetricData.decode(reader, reader.uint32())); + break; + } + case 7: { + message.serviceVersionInfo = $root.license_protocol.VersionInfo.decode(reader, reader.uint32()); + break; + } + case 8: { + message.sessionKeyType = reader.int32(); + break; + } + case 9: { + message.oemcryptoCoreMessage = reader.bytes(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SignedMessage message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof license_protocol.SignedMessage + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {license_protocol.SignedMessage} SignedMessage + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SignedMessage.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SignedMessage message. + * @function verify + * @memberof license_protocol.SignedMessage + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SignedMessage.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.type != null && message.hasOwnProperty("type")) + switch (message.type) { + default: + return "type: enum value expected"; + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + case 9: + case 10: + break; + } + if (message.msg != null && message.hasOwnProperty("msg")) + if (!(message.msg && typeof message.msg.length === "number" || $util.isString(message.msg))) + return "msg: buffer expected"; + if (message.signature != null && message.hasOwnProperty("signature")) + if (!(message.signature && typeof message.signature.length === "number" || $util.isString(message.signature))) + return "signature: buffer expected"; + if (message.sessionKey != null && message.hasOwnProperty("sessionKey")) + if (!(message.sessionKey && typeof message.sessionKey.length === "number" || $util.isString(message.sessionKey))) + return "sessionKey: buffer expected"; + if (message.remoteAttestation != null && message.hasOwnProperty("remoteAttestation")) + if (!(message.remoteAttestation && typeof message.remoteAttestation.length === "number" || $util.isString(message.remoteAttestation))) + return "remoteAttestation: buffer expected"; + if (message.metricData != null && message.hasOwnProperty("metricData")) { + if (!Array.isArray(message.metricData)) + return "metricData: array expected"; + for (var i = 0; i < message.metricData.length; ++i) { + var error = $root.license_protocol.MetricData.verify(message.metricData[i]); + if (error) + return "metricData." + error; + } + } + if (message.serviceVersionInfo != null && message.hasOwnProperty("serviceVersionInfo")) { + var error = $root.license_protocol.VersionInfo.verify(message.serviceVersionInfo); + if (error) + return "serviceVersionInfo." + error; + } + if (message.sessionKeyType != null && message.hasOwnProperty("sessionKeyType")) + switch (message.sessionKeyType) { + default: + return "sessionKeyType: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.oemcryptoCoreMessage != null && message.hasOwnProperty("oemcryptoCoreMessage")) + if (!(message.oemcryptoCoreMessage && typeof message.oemcryptoCoreMessage.length === "number" || $util.isString(message.oemcryptoCoreMessage))) + return "oemcryptoCoreMessage: buffer expected"; + return null; + }; + + /** + * Creates a SignedMessage message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof license_protocol.SignedMessage + * @static + * @param {Object.} object Plain object + * @returns {license_protocol.SignedMessage} SignedMessage + */ + SignedMessage.fromObject = function fromObject(object) { + if (object instanceof $root.license_protocol.SignedMessage) + return object; + var message = new $root.license_protocol.SignedMessage(); + switch (object.type) { + default: + if (typeof object.type === "number") { + message.type = object.type; + break; + } + break; + case "LICENSE_REQUEST": + case 1: + message.type = 1; + break; + case "LICENSE": + case 2: + message.type = 2; + break; + case "ERROR_RESPONSE": + case 3: + message.type = 3; + break; + case "SERVICE_CERTIFICATE_REQUEST": + case 4: + message.type = 4; + break; + case "SERVICE_CERTIFICATE": + case 5: + message.type = 5; + break; + case "SUB_LICENSE": + case 6: + message.type = 6; + break; + case "CAS_LICENSE_REQUEST": + case 7: + message.type = 7; + break; + case "CAS_LICENSE": + case 8: + message.type = 8; + break; + case "EXTERNAL_LICENSE_REQUEST": + case 9: + message.type = 9; + break; + case "EXTERNAL_LICENSE": + case 10: + message.type = 10; + break; + } + if (object.msg != null) + if (typeof object.msg === "string") + $util.base64.decode(object.msg, message.msg = $util.newBuffer($util.base64.length(object.msg)), 0); + else if (object.msg.length >= 0) + message.msg = object.msg; + if (object.signature != null) + if (typeof object.signature === "string") + $util.base64.decode(object.signature, message.signature = $util.newBuffer($util.base64.length(object.signature)), 0); + else if (object.signature.length >= 0) + message.signature = object.signature; + if (object.sessionKey != null) + if (typeof object.sessionKey === "string") + $util.base64.decode(object.sessionKey, message.sessionKey = $util.newBuffer($util.base64.length(object.sessionKey)), 0); + else if (object.sessionKey.length >= 0) + message.sessionKey = object.sessionKey; + if (object.remoteAttestation != null) + if (typeof object.remoteAttestation === "string") + $util.base64.decode(object.remoteAttestation, message.remoteAttestation = $util.newBuffer($util.base64.length(object.remoteAttestation)), 0); + else if (object.remoteAttestation.length >= 0) + message.remoteAttestation = object.remoteAttestation; + if (object.metricData) { + if (!Array.isArray(object.metricData)) + throw TypeError(".license_protocol.SignedMessage.metricData: array expected"); + message.metricData = []; + for (var i = 0; i < object.metricData.length; ++i) { + if (typeof object.metricData[i] !== "object") + throw TypeError(".license_protocol.SignedMessage.metricData: object expected"); + message.metricData[i] = $root.license_protocol.MetricData.fromObject(object.metricData[i]); + } + } + if (object.serviceVersionInfo != null) { + if (typeof object.serviceVersionInfo !== "object") + throw TypeError(".license_protocol.SignedMessage.serviceVersionInfo: object expected"); + message.serviceVersionInfo = $root.license_protocol.VersionInfo.fromObject(object.serviceVersionInfo); + } + switch (object.sessionKeyType) { + case "UNDEFINED": + case 0: + message.sessionKeyType = 0; + break; + default: + if (typeof object.sessionKeyType === "number") { + message.sessionKeyType = object.sessionKeyType; + break; + } + break; + case "WRAPPED_AES_KEY": + case 1: + message.sessionKeyType = 1; + break; + case "EPHERMERAL_ECC_PUBLIC_KEY": + case 2: + message.sessionKeyType = 2; + break; + } + if (object.oemcryptoCoreMessage != null) + if (typeof object.oemcryptoCoreMessage === "string") + $util.base64.decode(object.oemcryptoCoreMessage, message.oemcryptoCoreMessage = $util.newBuffer($util.base64.length(object.oemcryptoCoreMessage)), 0); + else if (object.oemcryptoCoreMessage.length >= 0) + message.oemcryptoCoreMessage = object.oemcryptoCoreMessage; + return message; + }; + + /** + * Creates a plain object from a SignedMessage message. Also converts values to other types if specified. + * @function toObject + * @memberof license_protocol.SignedMessage + * @static + * @param {license_protocol.SignedMessage} message SignedMessage + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SignedMessage.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.metricData = []; + if (options.defaults) { + object.type = options.enums === String ? "LICENSE_REQUEST" : 1; + if (options.bytes === String) + object.msg = ""; + else { + object.msg = []; + if (options.bytes !== Array) + object.msg = $util.newBuffer(object.msg); + } + if (options.bytes === String) + object.signature = ""; + else { + object.signature = []; + if (options.bytes !== Array) + object.signature = $util.newBuffer(object.signature); + } + if (options.bytes === String) + object.sessionKey = ""; + else { + object.sessionKey = []; + if (options.bytes !== Array) + object.sessionKey = $util.newBuffer(object.sessionKey); + } + if (options.bytes === String) + object.remoteAttestation = ""; + else { + object.remoteAttestation = []; + if (options.bytes !== Array) + object.remoteAttestation = $util.newBuffer(object.remoteAttestation); + } + object.serviceVersionInfo = null; + object.sessionKeyType = options.enums === String ? "WRAPPED_AES_KEY" : 1; + if (options.bytes === String) + object.oemcryptoCoreMessage = ""; + else { + object.oemcryptoCoreMessage = []; + if (options.bytes !== Array) + object.oemcryptoCoreMessage = $util.newBuffer(object.oemcryptoCoreMessage); + } + } + if (message.type != null && message.hasOwnProperty("type")) + object.type = options.enums === String ? $root.license_protocol.SignedMessage.MessageType[message.type] === undefined ? message.type : $root.license_protocol.SignedMessage.MessageType[message.type] : message.type; + if (message.msg != null && message.hasOwnProperty("msg")) + object.msg = options.bytes === String ? $util.base64.encode(message.msg, 0, message.msg.length) : options.bytes === Array ? Array.prototype.slice.call(message.msg) : message.msg; + if (message.signature != null && message.hasOwnProperty("signature")) + object.signature = options.bytes === String ? $util.base64.encode(message.signature, 0, message.signature.length) : options.bytes === Array ? Array.prototype.slice.call(message.signature) : message.signature; + if (message.sessionKey != null && message.hasOwnProperty("sessionKey")) + object.sessionKey = options.bytes === String ? $util.base64.encode(message.sessionKey, 0, message.sessionKey.length) : options.bytes === Array ? Array.prototype.slice.call(message.sessionKey) : message.sessionKey; + if (message.remoteAttestation != null && message.hasOwnProperty("remoteAttestation")) + object.remoteAttestation = options.bytes === String ? $util.base64.encode(message.remoteAttestation, 0, message.remoteAttestation.length) : options.bytes === Array ? Array.prototype.slice.call(message.remoteAttestation) : message.remoteAttestation; + if (message.metricData && message.metricData.length) { + object.metricData = []; + for (var j = 0; j < message.metricData.length; ++j) + object.metricData[j] = $root.license_protocol.MetricData.toObject(message.metricData[j], options); + } + if (message.serviceVersionInfo != null && message.hasOwnProperty("serviceVersionInfo")) + object.serviceVersionInfo = $root.license_protocol.VersionInfo.toObject(message.serviceVersionInfo, options); + if (message.sessionKeyType != null && message.hasOwnProperty("sessionKeyType")) + object.sessionKeyType = options.enums === String ? $root.license_protocol.SignedMessage.SessionKeyType[message.sessionKeyType] === undefined ? message.sessionKeyType : $root.license_protocol.SignedMessage.SessionKeyType[message.sessionKeyType] : message.sessionKeyType; + if (message.oemcryptoCoreMessage != null && message.hasOwnProperty("oemcryptoCoreMessage")) + object.oemcryptoCoreMessage = options.bytes === String ? $util.base64.encode(message.oemcryptoCoreMessage, 0, message.oemcryptoCoreMessage.length) : options.bytes === Array ? Array.prototype.slice.call(message.oemcryptoCoreMessage) : message.oemcryptoCoreMessage; + return object; + }; + + /** + * Converts this SignedMessage to JSON. + * @function toJSON + * @memberof license_protocol.SignedMessage + * @instance + * @returns {Object.} JSON object + */ + SignedMessage.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for SignedMessage + * @function getTypeUrl + * @memberof license_protocol.SignedMessage + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + SignedMessage.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/license_protocol.SignedMessage"; + }; + + /** + * MessageType enum. + * @name license_protocol.SignedMessage.MessageType + * @enum {number} + * @property {number} LICENSE_REQUEST=1 LICENSE_REQUEST value + * @property {number} LICENSE=2 LICENSE value + * @property {number} ERROR_RESPONSE=3 ERROR_RESPONSE value + * @property {number} SERVICE_CERTIFICATE_REQUEST=4 SERVICE_CERTIFICATE_REQUEST value + * @property {number} SERVICE_CERTIFICATE=5 SERVICE_CERTIFICATE value + * @property {number} SUB_LICENSE=6 SUB_LICENSE value + * @property {number} CAS_LICENSE_REQUEST=7 CAS_LICENSE_REQUEST value + * @property {number} CAS_LICENSE=8 CAS_LICENSE value + * @property {number} EXTERNAL_LICENSE_REQUEST=9 EXTERNAL_LICENSE_REQUEST value + * @property {number} EXTERNAL_LICENSE=10 EXTERNAL_LICENSE value + */ + SignedMessage.MessageType = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[1] = "LICENSE_REQUEST"] = 1; + values[valuesById[2] = "LICENSE"] = 2; + values[valuesById[3] = "ERROR_RESPONSE"] = 3; + values[valuesById[4] = "SERVICE_CERTIFICATE_REQUEST"] = 4; + values[valuesById[5] = "SERVICE_CERTIFICATE"] = 5; + values[valuesById[6] = "SUB_LICENSE"] = 6; + values[valuesById[7] = "CAS_LICENSE_REQUEST"] = 7; + values[valuesById[8] = "CAS_LICENSE"] = 8; + values[valuesById[9] = "EXTERNAL_LICENSE_REQUEST"] = 9; + values[valuesById[10] = "EXTERNAL_LICENSE"] = 10; + return values; + })(); + + /** + * SessionKeyType enum. + * @name license_protocol.SignedMessage.SessionKeyType + * @enum {number} + * @property {number} UNDEFINED=0 UNDEFINED value + * @property {number} WRAPPED_AES_KEY=1 WRAPPED_AES_KEY value + * @property {number} EPHERMERAL_ECC_PUBLIC_KEY=2 EPHERMERAL_ECC_PUBLIC_KEY value + */ + SignedMessage.SessionKeyType = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "UNDEFINED"] = 0; + values[valuesById[1] = "WRAPPED_AES_KEY"] = 1; + values[valuesById[2] = "EPHERMERAL_ECC_PUBLIC_KEY"] = 2; + return values; + })(); + + return SignedMessage; + })(); + + /** + * HashAlgorithmProto enum. + * @name license_protocol.HashAlgorithmProto + * @enum {number} + * @property {number} HASH_ALGORITHM_UNSPECIFIED=0 HASH_ALGORITHM_UNSPECIFIED value + * @property {number} HASH_ALGORITHM_SHA_1=1 HASH_ALGORITHM_SHA_1 value + * @property {number} HASH_ALGORITHM_SHA_256=2 HASH_ALGORITHM_SHA_256 value + * @property {number} HASH_ALGORITHM_SHA_384=3 HASH_ALGORITHM_SHA_384 value + */ + license_protocol.HashAlgorithmProto = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "HASH_ALGORITHM_UNSPECIFIED"] = 0; + values[valuesById[1] = "HASH_ALGORITHM_SHA_1"] = 1; + values[valuesById[2] = "HASH_ALGORITHM_SHA_256"] = 2; + values[valuesById[3] = "HASH_ALGORITHM_SHA_384"] = 3; + return values; + })(); + + license_protocol.ClientIdentification = (function() { + + /** + * Properties of a ClientIdentification. + * @memberof license_protocol + * @interface IClientIdentification + * @property {license_protocol.ClientIdentification.TokenType|null} [type] ClientIdentification type + * @property {Uint8Array|null} [token] ClientIdentification token + * @property {Array.|null} [clientInfo] ClientIdentification clientInfo + * @property {Uint8Array|null} [providerClientToken] ClientIdentification providerClientToken + * @property {number|null} [licenseCounter] ClientIdentification licenseCounter + * @property {license_protocol.ClientIdentification.IClientCapabilities|null} [clientCapabilities] ClientIdentification clientCapabilities + * @property {Uint8Array|null} [vmpData] ClientIdentification vmpData + * @property {Array.|null} [deviceCredentials] ClientIdentification deviceCredentials + */ + + /** + * Constructs a new ClientIdentification. + * @memberof license_protocol + * @classdesc Represents a ClientIdentification. + * @implements IClientIdentification + * @constructor + * @param {license_protocol.IClientIdentification=} [properties] Properties to set + */ + function ClientIdentification(properties) { + this.clientInfo = []; + this.deviceCredentials = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ClientIdentification type. + * @member {license_protocol.ClientIdentification.TokenType} type + * @memberof license_protocol.ClientIdentification + * @instance + */ + ClientIdentification.prototype.type = 0; + + /** + * ClientIdentification token. + * @member {Uint8Array} token + * @memberof license_protocol.ClientIdentification + * @instance + */ + ClientIdentification.prototype.token = $util.newBuffer([]); + + /** + * ClientIdentification clientInfo. + * @member {Array.} clientInfo + * @memberof license_protocol.ClientIdentification + * @instance + */ + ClientIdentification.prototype.clientInfo = $util.emptyArray; + + /** + * ClientIdentification providerClientToken. + * @member {Uint8Array} providerClientToken + * @memberof license_protocol.ClientIdentification + * @instance + */ + ClientIdentification.prototype.providerClientToken = $util.newBuffer([]); + + /** + * ClientIdentification licenseCounter. + * @member {number} licenseCounter + * @memberof license_protocol.ClientIdentification + * @instance + */ + ClientIdentification.prototype.licenseCounter = 0; + + /** + * ClientIdentification clientCapabilities. + * @member {license_protocol.ClientIdentification.IClientCapabilities|null|undefined} clientCapabilities + * @memberof license_protocol.ClientIdentification + * @instance + */ + ClientIdentification.prototype.clientCapabilities = null; + + /** + * ClientIdentification vmpData. + * @member {Uint8Array} vmpData + * @memberof license_protocol.ClientIdentification + * @instance + */ + ClientIdentification.prototype.vmpData = $util.newBuffer([]); + + /** + * ClientIdentification deviceCredentials. + * @member {Array.} deviceCredentials + * @memberof license_protocol.ClientIdentification + * @instance + */ + ClientIdentification.prototype.deviceCredentials = $util.emptyArray; + + /** + * Creates a new ClientIdentification instance using the specified properties. + * @function create + * @memberof license_protocol.ClientIdentification + * @static + * @param {license_protocol.IClientIdentification=} [properties] Properties to set + * @returns {license_protocol.ClientIdentification} ClientIdentification instance + */ + ClientIdentification.create = function create(properties) { + return new ClientIdentification(properties); + }; + + /** + * Encodes the specified ClientIdentification message. Does not implicitly {@link license_protocol.ClientIdentification.verify|verify} messages. + * @function encode + * @memberof license_protocol.ClientIdentification + * @static + * @param {license_protocol.IClientIdentification} message ClientIdentification message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ClientIdentification.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.type != null && Object.hasOwnProperty.call(message, "type")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.type); + if (message.token != null && Object.hasOwnProperty.call(message, "token")) + writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.token); + if (message.clientInfo != null && message.clientInfo.length) + for (var i = 0; i < message.clientInfo.length; ++i) + $root.license_protocol.ClientIdentification.NameValue.encode(message.clientInfo[i], writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.providerClientToken != null && Object.hasOwnProperty.call(message, "providerClientToken")) + writer.uint32(/* id 4, wireType 2 =*/34).bytes(message.providerClientToken); + if (message.licenseCounter != null && Object.hasOwnProperty.call(message, "licenseCounter")) + writer.uint32(/* id 5, wireType 0 =*/40).uint32(message.licenseCounter); + if (message.clientCapabilities != null && Object.hasOwnProperty.call(message, "clientCapabilities")) + $root.license_protocol.ClientIdentification.ClientCapabilities.encode(message.clientCapabilities, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + if (message.vmpData != null && Object.hasOwnProperty.call(message, "vmpData")) + writer.uint32(/* id 7, wireType 2 =*/58).bytes(message.vmpData); + if (message.deviceCredentials != null && message.deviceCredentials.length) + for (var i = 0; i < message.deviceCredentials.length; ++i) + $root.license_protocol.ClientIdentification.ClientCredentials.encode(message.deviceCredentials[i], writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ClientIdentification message, length delimited. Does not implicitly {@link license_protocol.ClientIdentification.verify|verify} messages. + * @function encodeDelimited + * @memberof license_protocol.ClientIdentification + * @static + * @param {license_protocol.IClientIdentification} message ClientIdentification message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ClientIdentification.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ClientIdentification message from the specified reader or buffer. + * @function decode + * @memberof license_protocol.ClientIdentification + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {license_protocol.ClientIdentification} ClientIdentification + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ClientIdentification.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.license_protocol.ClientIdentification(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.type = reader.int32(); + break; + } + case 2: { + message.token = reader.bytes(); + break; + } + case 3: { + if (!(message.clientInfo && message.clientInfo.length)) + message.clientInfo = []; + message.clientInfo.push($root.license_protocol.ClientIdentification.NameValue.decode(reader, reader.uint32())); + break; + } + case 4: { + message.providerClientToken = reader.bytes(); + break; + } + case 5: { + message.licenseCounter = reader.uint32(); + break; + } + case 6: { + message.clientCapabilities = $root.license_protocol.ClientIdentification.ClientCapabilities.decode(reader, reader.uint32()); + break; + } + case 7: { + message.vmpData = reader.bytes(); + break; + } + case 8: { + if (!(message.deviceCredentials && message.deviceCredentials.length)) + message.deviceCredentials = []; + message.deviceCredentials.push($root.license_protocol.ClientIdentification.ClientCredentials.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ClientIdentification message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof license_protocol.ClientIdentification + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {license_protocol.ClientIdentification} ClientIdentification + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ClientIdentification.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ClientIdentification message. + * @function verify + * @memberof license_protocol.ClientIdentification + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ClientIdentification.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.type != null && message.hasOwnProperty("type")) + switch (message.type) { + default: + return "type: enum value expected"; + case 0: + case 1: + case 2: + case 3: + break; + } + if (message.token != null && message.hasOwnProperty("token")) + if (!(message.token && typeof message.token.length === "number" || $util.isString(message.token))) + return "token: buffer expected"; + if (message.clientInfo != null && message.hasOwnProperty("clientInfo")) { + if (!Array.isArray(message.clientInfo)) + return "clientInfo: array expected"; + for (var i = 0; i < message.clientInfo.length; ++i) { + var error = $root.license_protocol.ClientIdentification.NameValue.verify(message.clientInfo[i]); + if (error) + return "clientInfo." + error; + } + } + if (message.providerClientToken != null && message.hasOwnProperty("providerClientToken")) + if (!(message.providerClientToken && typeof message.providerClientToken.length === "number" || $util.isString(message.providerClientToken))) + return "providerClientToken: buffer expected"; + if (message.licenseCounter != null && message.hasOwnProperty("licenseCounter")) + if (!$util.isInteger(message.licenseCounter)) + return "licenseCounter: integer expected"; + if (message.clientCapabilities != null && message.hasOwnProperty("clientCapabilities")) { + var error = $root.license_protocol.ClientIdentification.ClientCapabilities.verify(message.clientCapabilities); + if (error) + return "clientCapabilities." + error; + } + if (message.vmpData != null && message.hasOwnProperty("vmpData")) + if (!(message.vmpData && typeof message.vmpData.length === "number" || $util.isString(message.vmpData))) + return "vmpData: buffer expected"; + if (message.deviceCredentials != null && message.hasOwnProperty("deviceCredentials")) { + if (!Array.isArray(message.deviceCredentials)) + return "deviceCredentials: array expected"; + for (var i = 0; i < message.deviceCredentials.length; ++i) { + var error = $root.license_protocol.ClientIdentification.ClientCredentials.verify(message.deviceCredentials[i]); + if (error) + return "deviceCredentials." + error; + } + } + return null; + }; + + /** + * Creates a ClientIdentification message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof license_protocol.ClientIdentification + * @static + * @param {Object.} object Plain object + * @returns {license_protocol.ClientIdentification} ClientIdentification + */ + ClientIdentification.fromObject = function fromObject(object) { + if (object instanceof $root.license_protocol.ClientIdentification) + return object; + var message = new $root.license_protocol.ClientIdentification(); + switch (object.type) { + default: + if (typeof object.type === "number") { + message.type = object.type; + break; + } + break; + case "KEYBOX": + case 0: + message.type = 0; + break; + case "DRM_DEVICE_CERTIFICATE": + case 1: + message.type = 1; + break; + case "REMOTE_ATTESTATION_CERTIFICATE": + case 2: + message.type = 2; + break; + case "OEM_DEVICE_CERTIFICATE": + case 3: + message.type = 3; + break; + } + if (object.token != null) + if (typeof object.token === "string") + $util.base64.decode(object.token, message.token = $util.newBuffer($util.base64.length(object.token)), 0); + else if (object.token.length >= 0) + message.token = object.token; + if (object.clientInfo) { + if (!Array.isArray(object.clientInfo)) + throw TypeError(".license_protocol.ClientIdentification.clientInfo: array expected"); + message.clientInfo = []; + for (var i = 0; i < object.clientInfo.length; ++i) { + if (typeof object.clientInfo[i] !== "object") + throw TypeError(".license_protocol.ClientIdentification.clientInfo: object expected"); + message.clientInfo[i] = $root.license_protocol.ClientIdentification.NameValue.fromObject(object.clientInfo[i]); + } + } + if (object.providerClientToken != null) + if (typeof object.providerClientToken === "string") + $util.base64.decode(object.providerClientToken, message.providerClientToken = $util.newBuffer($util.base64.length(object.providerClientToken)), 0); + else if (object.providerClientToken.length >= 0) + message.providerClientToken = object.providerClientToken; + if (object.licenseCounter != null) + message.licenseCounter = object.licenseCounter >>> 0; + if (object.clientCapabilities != null) { + if (typeof object.clientCapabilities !== "object") + throw TypeError(".license_protocol.ClientIdentification.clientCapabilities: object expected"); + message.clientCapabilities = $root.license_protocol.ClientIdentification.ClientCapabilities.fromObject(object.clientCapabilities); + } + if (object.vmpData != null) + if (typeof object.vmpData === "string") + $util.base64.decode(object.vmpData, message.vmpData = $util.newBuffer($util.base64.length(object.vmpData)), 0); + else if (object.vmpData.length >= 0) + message.vmpData = object.vmpData; + if (object.deviceCredentials) { + if (!Array.isArray(object.deviceCredentials)) + throw TypeError(".license_protocol.ClientIdentification.deviceCredentials: array expected"); + message.deviceCredentials = []; + for (var i = 0; i < object.deviceCredentials.length; ++i) { + if (typeof object.deviceCredentials[i] !== "object") + throw TypeError(".license_protocol.ClientIdentification.deviceCredentials: object expected"); + message.deviceCredentials[i] = $root.license_protocol.ClientIdentification.ClientCredentials.fromObject(object.deviceCredentials[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a ClientIdentification message. Also converts values to other types if specified. + * @function toObject + * @memberof license_protocol.ClientIdentification + * @static + * @param {license_protocol.ClientIdentification} message ClientIdentification + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ClientIdentification.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.clientInfo = []; + object.deviceCredentials = []; + } + if (options.defaults) { + object.type = options.enums === String ? "KEYBOX" : 0; + if (options.bytes === String) + object.token = ""; + else { + object.token = []; + if (options.bytes !== Array) + object.token = $util.newBuffer(object.token); + } + if (options.bytes === String) + object.providerClientToken = ""; + else { + object.providerClientToken = []; + if (options.bytes !== Array) + object.providerClientToken = $util.newBuffer(object.providerClientToken); + } + object.licenseCounter = 0; + object.clientCapabilities = null; + if (options.bytes === String) + object.vmpData = ""; + else { + object.vmpData = []; + if (options.bytes !== Array) + object.vmpData = $util.newBuffer(object.vmpData); + } + } + if (message.type != null && message.hasOwnProperty("type")) + object.type = options.enums === String ? $root.license_protocol.ClientIdentification.TokenType[message.type] === undefined ? message.type : $root.license_protocol.ClientIdentification.TokenType[message.type] : message.type; + if (message.token != null && message.hasOwnProperty("token")) + object.token = options.bytes === String ? $util.base64.encode(message.token, 0, message.token.length) : options.bytes === Array ? Array.prototype.slice.call(message.token) : message.token; + if (message.clientInfo && message.clientInfo.length) { + object.clientInfo = []; + for (var j = 0; j < message.clientInfo.length; ++j) + object.clientInfo[j] = $root.license_protocol.ClientIdentification.NameValue.toObject(message.clientInfo[j], options); + } + if (message.providerClientToken != null && message.hasOwnProperty("providerClientToken")) + object.providerClientToken = options.bytes === String ? $util.base64.encode(message.providerClientToken, 0, message.providerClientToken.length) : options.bytes === Array ? Array.prototype.slice.call(message.providerClientToken) : message.providerClientToken; + if (message.licenseCounter != null && message.hasOwnProperty("licenseCounter")) + object.licenseCounter = message.licenseCounter; + if (message.clientCapabilities != null && message.hasOwnProperty("clientCapabilities")) + object.clientCapabilities = $root.license_protocol.ClientIdentification.ClientCapabilities.toObject(message.clientCapabilities, options); + if (message.vmpData != null && message.hasOwnProperty("vmpData")) + object.vmpData = options.bytes === String ? $util.base64.encode(message.vmpData, 0, message.vmpData.length) : options.bytes === Array ? Array.prototype.slice.call(message.vmpData) : message.vmpData; + if (message.deviceCredentials && message.deviceCredentials.length) { + object.deviceCredentials = []; + for (var j = 0; j < message.deviceCredentials.length; ++j) + object.deviceCredentials[j] = $root.license_protocol.ClientIdentification.ClientCredentials.toObject(message.deviceCredentials[j], options); + } + return object; + }; + + /** + * Converts this ClientIdentification to JSON. + * @function toJSON + * @memberof license_protocol.ClientIdentification + * @instance + * @returns {Object.} JSON object + */ + ClientIdentification.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ClientIdentification + * @function getTypeUrl + * @memberof license_protocol.ClientIdentification + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ClientIdentification.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/license_protocol.ClientIdentification"; + }; + + /** + * TokenType enum. + * @name license_protocol.ClientIdentification.TokenType + * @enum {number} + * @property {number} KEYBOX=0 KEYBOX value + * @property {number} DRM_DEVICE_CERTIFICATE=1 DRM_DEVICE_CERTIFICATE value + * @property {number} REMOTE_ATTESTATION_CERTIFICATE=2 REMOTE_ATTESTATION_CERTIFICATE value + * @property {number} OEM_DEVICE_CERTIFICATE=3 OEM_DEVICE_CERTIFICATE value + */ + ClientIdentification.TokenType = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "KEYBOX"] = 0; + values[valuesById[1] = "DRM_DEVICE_CERTIFICATE"] = 1; + values[valuesById[2] = "REMOTE_ATTESTATION_CERTIFICATE"] = 2; + values[valuesById[3] = "OEM_DEVICE_CERTIFICATE"] = 3; + return values; + })(); + + ClientIdentification.NameValue = (function() { + + /** + * Properties of a NameValue. + * @memberof license_protocol.ClientIdentification + * @interface INameValue + * @property {string|null} [name] NameValue name + * @property {string|null} [value] NameValue value + */ + + /** + * Constructs a new NameValue. + * @memberof license_protocol.ClientIdentification + * @classdesc Represents a NameValue. + * @implements INameValue + * @constructor + * @param {license_protocol.ClientIdentification.INameValue=} [properties] Properties to set + */ + function NameValue(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * NameValue name. + * @member {string} name + * @memberof license_protocol.ClientIdentification.NameValue + * @instance + */ + NameValue.prototype.name = ""; + + /** + * NameValue value. + * @member {string} value + * @memberof license_protocol.ClientIdentification.NameValue + * @instance + */ + NameValue.prototype.value = ""; + + /** + * Creates a new NameValue instance using the specified properties. + * @function create + * @memberof license_protocol.ClientIdentification.NameValue + * @static + * @param {license_protocol.ClientIdentification.INameValue=} [properties] Properties to set + * @returns {license_protocol.ClientIdentification.NameValue} NameValue instance + */ + NameValue.create = function create(properties) { + return new NameValue(properties); + }; + + /** + * Encodes the specified NameValue message. Does not implicitly {@link license_protocol.ClientIdentification.NameValue.verify|verify} messages. + * @function encode + * @memberof license_protocol.ClientIdentification.NameValue + * @static + * @param {license_protocol.ClientIdentification.INameValue} message NameValue message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + NameValue.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && Object.hasOwnProperty.call(message, "name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + if (message.value != null && Object.hasOwnProperty.call(message, "value")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.value); + return writer; + }; + + /** + * Encodes the specified NameValue message, length delimited. Does not implicitly {@link license_protocol.ClientIdentification.NameValue.verify|verify} messages. + * @function encodeDelimited + * @memberof license_protocol.ClientIdentification.NameValue + * @static + * @param {license_protocol.ClientIdentification.INameValue} message NameValue message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + NameValue.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a NameValue message from the specified reader or buffer. + * @function decode + * @memberof license_protocol.ClientIdentification.NameValue + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {license_protocol.ClientIdentification.NameValue} NameValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + NameValue.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.license_protocol.ClientIdentification.NameValue(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + case 2: { + message.value = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a NameValue message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof license_protocol.ClientIdentification.NameValue + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {license_protocol.ClientIdentification.NameValue} NameValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + NameValue.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a NameValue message. + * @function verify + * @memberof license_protocol.ClientIdentification.NameValue + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + NameValue.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + if (message.value != null && message.hasOwnProperty("value")) + if (!$util.isString(message.value)) + return "value: string expected"; + return null; + }; + + /** + * Creates a NameValue message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof license_protocol.ClientIdentification.NameValue + * @static + * @param {Object.} object Plain object + * @returns {license_protocol.ClientIdentification.NameValue} NameValue + */ + NameValue.fromObject = function fromObject(object) { + if (object instanceof $root.license_protocol.ClientIdentification.NameValue) + return object; + var message = new $root.license_protocol.ClientIdentification.NameValue(); + if (object.name != null) + message.name = String(object.name); + if (object.value != null) + message.value = String(object.value); + return message; + }; + + /** + * Creates a plain object from a NameValue message. Also converts values to other types if specified. + * @function toObject + * @memberof license_protocol.ClientIdentification.NameValue + * @static + * @param {license_protocol.ClientIdentification.NameValue} message NameValue + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + NameValue.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.value = ""; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.value != null && message.hasOwnProperty("value")) + object.value = message.value; + return object; + }; + + /** + * Converts this NameValue to JSON. + * @function toJSON + * @memberof license_protocol.ClientIdentification.NameValue + * @instance + * @returns {Object.} JSON object + */ + NameValue.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for NameValue + * @function getTypeUrl + * @memberof license_protocol.ClientIdentification.NameValue + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + NameValue.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/license_protocol.ClientIdentification.NameValue"; + }; + + return NameValue; + })(); + + ClientIdentification.ClientCapabilities = (function() { + + /** + * Properties of a ClientCapabilities. + * @memberof license_protocol.ClientIdentification + * @interface IClientCapabilities + * @property {boolean|null} [clientToken] ClientCapabilities clientToken + * @property {boolean|null} [sessionToken] ClientCapabilities sessionToken + * @property {boolean|null} [videoResolutionConstraints] ClientCapabilities videoResolutionConstraints + * @property {license_protocol.ClientIdentification.ClientCapabilities.HdcpVersion|null} [maxHdcpVersion] ClientCapabilities maxHdcpVersion + * @property {number|null} [oemCryptoApiVersion] ClientCapabilities oemCryptoApiVersion + * @property {boolean|null} [antiRollbackUsageTable] ClientCapabilities antiRollbackUsageTable + * @property {number|null} [srmVersion] ClientCapabilities srmVersion + * @property {boolean|null} [canUpdateSrm] ClientCapabilities canUpdateSrm + * @property {Array.|null} [supportedCertificateKeyType] ClientCapabilities supportedCertificateKeyType + * @property {license_protocol.ClientIdentification.ClientCapabilities.AnalogOutputCapabilities|null} [analogOutputCapabilities] ClientCapabilities analogOutputCapabilities + * @property {boolean|null} [canDisableAnalogOutput] ClientCapabilities canDisableAnalogOutput + * @property {number|null} [resourceRatingTier] ClientCapabilities resourceRatingTier + */ + + /** + * Constructs a new ClientCapabilities. + * @memberof license_protocol.ClientIdentification + * @classdesc Represents a ClientCapabilities. + * @implements IClientCapabilities + * @constructor + * @param {license_protocol.ClientIdentification.IClientCapabilities=} [properties] Properties to set + */ + function ClientCapabilities(properties) { + this.supportedCertificateKeyType = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ClientCapabilities clientToken. + * @member {boolean} clientToken + * @memberof license_protocol.ClientIdentification.ClientCapabilities + * @instance + */ + ClientCapabilities.prototype.clientToken = false; + + /** + * ClientCapabilities sessionToken. + * @member {boolean} sessionToken + * @memberof license_protocol.ClientIdentification.ClientCapabilities + * @instance + */ + ClientCapabilities.prototype.sessionToken = false; + + /** + * ClientCapabilities videoResolutionConstraints. + * @member {boolean} videoResolutionConstraints + * @memberof license_protocol.ClientIdentification.ClientCapabilities + * @instance + */ + ClientCapabilities.prototype.videoResolutionConstraints = false; + + /** + * ClientCapabilities maxHdcpVersion. + * @member {license_protocol.ClientIdentification.ClientCapabilities.HdcpVersion} maxHdcpVersion + * @memberof license_protocol.ClientIdentification.ClientCapabilities + * @instance + */ + ClientCapabilities.prototype.maxHdcpVersion = 0; + + /** + * ClientCapabilities oemCryptoApiVersion. + * @member {number} oemCryptoApiVersion + * @memberof license_protocol.ClientIdentification.ClientCapabilities + * @instance + */ + ClientCapabilities.prototype.oemCryptoApiVersion = 0; + + /** + * ClientCapabilities antiRollbackUsageTable. + * @member {boolean} antiRollbackUsageTable + * @memberof license_protocol.ClientIdentification.ClientCapabilities + * @instance + */ + ClientCapabilities.prototype.antiRollbackUsageTable = false; + + /** + * ClientCapabilities srmVersion. + * @member {number} srmVersion + * @memberof license_protocol.ClientIdentification.ClientCapabilities + * @instance + */ + ClientCapabilities.prototype.srmVersion = 0; + + /** + * ClientCapabilities canUpdateSrm. + * @member {boolean} canUpdateSrm + * @memberof license_protocol.ClientIdentification.ClientCapabilities + * @instance + */ + ClientCapabilities.prototype.canUpdateSrm = false; + + /** + * ClientCapabilities supportedCertificateKeyType. + * @member {Array.} supportedCertificateKeyType + * @memberof license_protocol.ClientIdentification.ClientCapabilities + * @instance + */ + ClientCapabilities.prototype.supportedCertificateKeyType = $util.emptyArray; + + /** + * ClientCapabilities analogOutputCapabilities. + * @member {license_protocol.ClientIdentification.ClientCapabilities.AnalogOutputCapabilities} analogOutputCapabilities + * @memberof license_protocol.ClientIdentification.ClientCapabilities + * @instance + */ + ClientCapabilities.prototype.analogOutputCapabilities = 0; + + /** + * ClientCapabilities canDisableAnalogOutput. + * @member {boolean} canDisableAnalogOutput + * @memberof license_protocol.ClientIdentification.ClientCapabilities + * @instance + */ + ClientCapabilities.prototype.canDisableAnalogOutput = false; + + /** + * ClientCapabilities resourceRatingTier. + * @member {number} resourceRatingTier + * @memberof license_protocol.ClientIdentification.ClientCapabilities + * @instance + */ + ClientCapabilities.prototype.resourceRatingTier = 0; + + /** + * Creates a new ClientCapabilities instance using the specified properties. + * @function create + * @memberof license_protocol.ClientIdentification.ClientCapabilities + * @static + * @param {license_protocol.ClientIdentification.IClientCapabilities=} [properties] Properties to set + * @returns {license_protocol.ClientIdentification.ClientCapabilities} ClientCapabilities instance + */ + ClientCapabilities.create = function create(properties) { + return new ClientCapabilities(properties); + }; + + /** + * Encodes the specified ClientCapabilities message. Does not implicitly {@link license_protocol.ClientIdentification.ClientCapabilities.verify|verify} messages. + * @function encode + * @memberof license_protocol.ClientIdentification.ClientCapabilities + * @static + * @param {license_protocol.ClientIdentification.IClientCapabilities} message ClientCapabilities message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ClientCapabilities.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.clientToken != null && Object.hasOwnProperty.call(message, "clientToken")) + writer.uint32(/* id 1, wireType 0 =*/8).bool(message.clientToken); + if (message.sessionToken != null && Object.hasOwnProperty.call(message, "sessionToken")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.sessionToken); + if (message.videoResolutionConstraints != null && Object.hasOwnProperty.call(message, "videoResolutionConstraints")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.videoResolutionConstraints); + if (message.maxHdcpVersion != null && Object.hasOwnProperty.call(message, "maxHdcpVersion")) + writer.uint32(/* id 4, wireType 0 =*/32).int32(message.maxHdcpVersion); + if (message.oemCryptoApiVersion != null && Object.hasOwnProperty.call(message, "oemCryptoApiVersion")) + writer.uint32(/* id 5, wireType 0 =*/40).uint32(message.oemCryptoApiVersion); + if (message.antiRollbackUsageTable != null && Object.hasOwnProperty.call(message, "antiRollbackUsageTable")) + writer.uint32(/* id 6, wireType 0 =*/48).bool(message.antiRollbackUsageTable); + if (message.srmVersion != null && Object.hasOwnProperty.call(message, "srmVersion")) + writer.uint32(/* id 7, wireType 0 =*/56).uint32(message.srmVersion); + if (message.canUpdateSrm != null && Object.hasOwnProperty.call(message, "canUpdateSrm")) + writer.uint32(/* id 8, wireType 0 =*/64).bool(message.canUpdateSrm); + if (message.supportedCertificateKeyType != null && message.supportedCertificateKeyType.length) + for (var i = 0; i < message.supportedCertificateKeyType.length; ++i) + writer.uint32(/* id 9, wireType 0 =*/72).int32(message.supportedCertificateKeyType[i]); + if (message.analogOutputCapabilities != null && Object.hasOwnProperty.call(message, "analogOutputCapabilities")) + writer.uint32(/* id 10, wireType 0 =*/80).int32(message.analogOutputCapabilities); + if (message.canDisableAnalogOutput != null && Object.hasOwnProperty.call(message, "canDisableAnalogOutput")) + writer.uint32(/* id 11, wireType 0 =*/88).bool(message.canDisableAnalogOutput); + if (message.resourceRatingTier != null && Object.hasOwnProperty.call(message, "resourceRatingTier")) + writer.uint32(/* id 12, wireType 0 =*/96).uint32(message.resourceRatingTier); + return writer; + }; + + /** + * Encodes the specified ClientCapabilities message, length delimited. Does not implicitly {@link license_protocol.ClientIdentification.ClientCapabilities.verify|verify} messages. + * @function encodeDelimited + * @memberof license_protocol.ClientIdentification.ClientCapabilities + * @static + * @param {license_protocol.ClientIdentification.IClientCapabilities} message ClientCapabilities message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ClientCapabilities.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ClientCapabilities message from the specified reader or buffer. + * @function decode + * @memberof license_protocol.ClientIdentification.ClientCapabilities + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {license_protocol.ClientIdentification.ClientCapabilities} ClientCapabilities + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ClientCapabilities.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.license_protocol.ClientIdentification.ClientCapabilities(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.clientToken = reader.bool(); + break; + } + case 2: { + message.sessionToken = reader.bool(); + break; + } + case 3: { + message.videoResolutionConstraints = reader.bool(); + break; + } + case 4: { + message.maxHdcpVersion = reader.int32(); + break; + } + case 5: { + message.oemCryptoApiVersion = reader.uint32(); + break; + } + case 6: { + message.antiRollbackUsageTable = reader.bool(); + break; + } + case 7: { + message.srmVersion = reader.uint32(); + break; + } + case 8: { + message.canUpdateSrm = reader.bool(); + break; + } + case 9: { + if (!(message.supportedCertificateKeyType && message.supportedCertificateKeyType.length)) + message.supportedCertificateKeyType = []; + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) + message.supportedCertificateKeyType.push(reader.int32()); + } else + message.supportedCertificateKeyType.push(reader.int32()); + break; + } + case 10: { + message.analogOutputCapabilities = reader.int32(); + break; + } + case 11: { + message.canDisableAnalogOutput = reader.bool(); + break; + } + case 12: { + message.resourceRatingTier = reader.uint32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ClientCapabilities message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof license_protocol.ClientIdentification.ClientCapabilities + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {license_protocol.ClientIdentification.ClientCapabilities} ClientCapabilities + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ClientCapabilities.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ClientCapabilities message. + * @function verify + * @memberof license_protocol.ClientIdentification.ClientCapabilities + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ClientCapabilities.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.clientToken != null && message.hasOwnProperty("clientToken")) + if (typeof message.clientToken !== "boolean") + return "clientToken: boolean expected"; + if (message.sessionToken != null && message.hasOwnProperty("sessionToken")) + if (typeof message.sessionToken !== "boolean") + return "sessionToken: boolean expected"; + if (message.videoResolutionConstraints != null && message.hasOwnProperty("videoResolutionConstraints")) + if (typeof message.videoResolutionConstraints !== "boolean") + return "videoResolutionConstraints: boolean expected"; + if (message.maxHdcpVersion != null && message.hasOwnProperty("maxHdcpVersion")) + switch (message.maxHdcpVersion) { + default: + return "maxHdcpVersion: enum value expected"; + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + case 255: + break; + } + if (message.oemCryptoApiVersion != null && message.hasOwnProperty("oemCryptoApiVersion")) + if (!$util.isInteger(message.oemCryptoApiVersion)) + return "oemCryptoApiVersion: integer expected"; + if (message.antiRollbackUsageTable != null && message.hasOwnProperty("antiRollbackUsageTable")) + if (typeof message.antiRollbackUsageTable !== "boolean") + return "antiRollbackUsageTable: boolean expected"; + if (message.srmVersion != null && message.hasOwnProperty("srmVersion")) + if (!$util.isInteger(message.srmVersion)) + return "srmVersion: integer expected"; + if (message.canUpdateSrm != null && message.hasOwnProperty("canUpdateSrm")) + if (typeof message.canUpdateSrm !== "boolean") + return "canUpdateSrm: boolean expected"; + if (message.supportedCertificateKeyType != null && message.hasOwnProperty("supportedCertificateKeyType")) { + if (!Array.isArray(message.supportedCertificateKeyType)) + return "supportedCertificateKeyType: array expected"; + for (var i = 0; i < message.supportedCertificateKeyType.length; ++i) + switch (message.supportedCertificateKeyType[i]) { + default: + return "supportedCertificateKeyType: enum value[] expected"; + case 0: + case 1: + case 2: + case 3: + case 4: + break; + } + } + if (message.analogOutputCapabilities != null && message.hasOwnProperty("analogOutputCapabilities")) + switch (message.analogOutputCapabilities) { + default: + return "analogOutputCapabilities: enum value expected"; + case 0: + case 1: + case 2: + case 3: + break; + } + if (message.canDisableAnalogOutput != null && message.hasOwnProperty("canDisableAnalogOutput")) + if (typeof message.canDisableAnalogOutput !== "boolean") + return "canDisableAnalogOutput: boolean expected"; + if (message.resourceRatingTier != null && message.hasOwnProperty("resourceRatingTier")) + if (!$util.isInteger(message.resourceRatingTier)) + return "resourceRatingTier: integer expected"; + return null; + }; + + /** + * Creates a ClientCapabilities message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof license_protocol.ClientIdentification.ClientCapabilities + * @static + * @param {Object.} object Plain object + * @returns {license_protocol.ClientIdentification.ClientCapabilities} ClientCapabilities + */ + ClientCapabilities.fromObject = function fromObject(object) { + if (object instanceof $root.license_protocol.ClientIdentification.ClientCapabilities) + return object; + var message = new $root.license_protocol.ClientIdentification.ClientCapabilities(); + if (object.clientToken != null) + message.clientToken = Boolean(object.clientToken); + if (object.sessionToken != null) + message.sessionToken = Boolean(object.sessionToken); + if (object.videoResolutionConstraints != null) + message.videoResolutionConstraints = Boolean(object.videoResolutionConstraints); + switch (object.maxHdcpVersion) { + default: + if (typeof object.maxHdcpVersion === "number") { + message.maxHdcpVersion = object.maxHdcpVersion; + break; + } + break; + case "HDCP_NONE": + case 0: + message.maxHdcpVersion = 0; + break; + case "HDCP_V1": + case 1: + message.maxHdcpVersion = 1; + break; + case "HDCP_V2": + case 2: + message.maxHdcpVersion = 2; + break; + case "HDCP_V2_1": + case 3: + message.maxHdcpVersion = 3; + break; + case "HDCP_V2_2": + case 4: + message.maxHdcpVersion = 4; + break; + case "HDCP_V2_3": + case 5: + message.maxHdcpVersion = 5; + break; + case "HDCP_NO_DIGITAL_OUTPUT": + case 255: + message.maxHdcpVersion = 255; + break; + } + if (object.oemCryptoApiVersion != null) + message.oemCryptoApiVersion = object.oemCryptoApiVersion >>> 0; + if (object.antiRollbackUsageTable != null) + message.antiRollbackUsageTable = Boolean(object.antiRollbackUsageTable); + if (object.srmVersion != null) + message.srmVersion = object.srmVersion >>> 0; + if (object.canUpdateSrm != null) + message.canUpdateSrm = Boolean(object.canUpdateSrm); + if (object.supportedCertificateKeyType) { + if (!Array.isArray(object.supportedCertificateKeyType)) + throw TypeError(".license_protocol.ClientIdentification.ClientCapabilities.supportedCertificateKeyType: array expected"); + message.supportedCertificateKeyType = []; + for (var i = 0; i < object.supportedCertificateKeyType.length; ++i) + switch (object.supportedCertificateKeyType[i]) { + default: + if (typeof object.supportedCertificateKeyType[i] === "number") { + message.supportedCertificateKeyType[i] = object.supportedCertificateKeyType[i]; + break; + } + case "RSA_2048": + case 0: + message.supportedCertificateKeyType[i] = 0; + break; + case "RSA_3072": + case 1: + message.supportedCertificateKeyType[i] = 1; + break; + case "ECC_SECP256R1": + case 2: + message.supportedCertificateKeyType[i] = 2; + break; + case "ECC_SECP384R1": + case 3: + message.supportedCertificateKeyType[i] = 3; + break; + case "ECC_SECP521R1": + case 4: + message.supportedCertificateKeyType[i] = 4; + break; + } + } + switch (object.analogOutputCapabilities) { + default: + if (typeof object.analogOutputCapabilities === "number") { + message.analogOutputCapabilities = object.analogOutputCapabilities; + break; + } + break; + case "ANALOG_OUTPUT_UNKNOWN": + case 0: + message.analogOutputCapabilities = 0; + break; + case "ANALOG_OUTPUT_NONE": + case 1: + message.analogOutputCapabilities = 1; + break; + case "ANALOG_OUTPUT_SUPPORTED": + case 2: + message.analogOutputCapabilities = 2; + break; + case "ANALOG_OUTPUT_SUPPORTS_CGMS_A": + case 3: + message.analogOutputCapabilities = 3; + break; + } + if (object.canDisableAnalogOutput != null) + message.canDisableAnalogOutput = Boolean(object.canDisableAnalogOutput); + if (object.resourceRatingTier != null) + message.resourceRatingTier = object.resourceRatingTier >>> 0; + return message; + }; + + /** + * Creates a plain object from a ClientCapabilities message. Also converts values to other types if specified. + * @function toObject + * @memberof license_protocol.ClientIdentification.ClientCapabilities + * @static + * @param {license_protocol.ClientIdentification.ClientCapabilities} message ClientCapabilities + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ClientCapabilities.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.supportedCertificateKeyType = []; + if (options.defaults) { + object.clientToken = false; + object.sessionToken = false; + object.videoResolutionConstraints = false; + object.maxHdcpVersion = options.enums === String ? "HDCP_NONE" : 0; + object.oemCryptoApiVersion = 0; + object.antiRollbackUsageTable = false; + object.srmVersion = 0; + object.canUpdateSrm = false; + object.analogOutputCapabilities = options.enums === String ? "ANALOG_OUTPUT_UNKNOWN" : 0; + object.canDisableAnalogOutput = false; + object.resourceRatingTier = 0; + } + if (message.clientToken != null && message.hasOwnProperty("clientToken")) + object.clientToken = message.clientToken; + if (message.sessionToken != null && message.hasOwnProperty("sessionToken")) + object.sessionToken = message.sessionToken; + if (message.videoResolutionConstraints != null && message.hasOwnProperty("videoResolutionConstraints")) + object.videoResolutionConstraints = message.videoResolutionConstraints; + if (message.maxHdcpVersion != null && message.hasOwnProperty("maxHdcpVersion")) + object.maxHdcpVersion = options.enums === String ? $root.license_protocol.ClientIdentification.ClientCapabilities.HdcpVersion[message.maxHdcpVersion] === undefined ? message.maxHdcpVersion : $root.license_protocol.ClientIdentification.ClientCapabilities.HdcpVersion[message.maxHdcpVersion] : message.maxHdcpVersion; + if (message.oemCryptoApiVersion != null && message.hasOwnProperty("oemCryptoApiVersion")) + object.oemCryptoApiVersion = message.oemCryptoApiVersion; + if (message.antiRollbackUsageTable != null && message.hasOwnProperty("antiRollbackUsageTable")) + object.antiRollbackUsageTable = message.antiRollbackUsageTable; + if (message.srmVersion != null && message.hasOwnProperty("srmVersion")) + object.srmVersion = message.srmVersion; + if (message.canUpdateSrm != null && message.hasOwnProperty("canUpdateSrm")) + object.canUpdateSrm = message.canUpdateSrm; + if (message.supportedCertificateKeyType && message.supportedCertificateKeyType.length) { + object.supportedCertificateKeyType = []; + for (var j = 0; j < message.supportedCertificateKeyType.length; ++j) + object.supportedCertificateKeyType[j] = options.enums === String ? $root.license_protocol.ClientIdentification.ClientCapabilities.CertificateKeyType[message.supportedCertificateKeyType[j]] === undefined ? message.supportedCertificateKeyType[j] : $root.license_protocol.ClientIdentification.ClientCapabilities.CertificateKeyType[message.supportedCertificateKeyType[j]] : message.supportedCertificateKeyType[j]; + } + if (message.analogOutputCapabilities != null && message.hasOwnProperty("analogOutputCapabilities")) + object.analogOutputCapabilities = options.enums === String ? $root.license_protocol.ClientIdentification.ClientCapabilities.AnalogOutputCapabilities[message.analogOutputCapabilities] === undefined ? message.analogOutputCapabilities : $root.license_protocol.ClientIdentification.ClientCapabilities.AnalogOutputCapabilities[message.analogOutputCapabilities] : message.analogOutputCapabilities; + if (message.canDisableAnalogOutput != null && message.hasOwnProperty("canDisableAnalogOutput")) + object.canDisableAnalogOutput = message.canDisableAnalogOutput; + if (message.resourceRatingTier != null && message.hasOwnProperty("resourceRatingTier")) + object.resourceRatingTier = message.resourceRatingTier; + return object; + }; + + /** + * Converts this ClientCapabilities to JSON. + * @function toJSON + * @memberof license_protocol.ClientIdentification.ClientCapabilities + * @instance + * @returns {Object.} JSON object + */ + ClientCapabilities.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ClientCapabilities + * @function getTypeUrl + * @memberof license_protocol.ClientIdentification.ClientCapabilities + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ClientCapabilities.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/license_protocol.ClientIdentification.ClientCapabilities"; + }; + + /** + * HdcpVersion enum. + * @name license_protocol.ClientIdentification.ClientCapabilities.HdcpVersion + * @enum {number} + * @property {number} HDCP_NONE=0 HDCP_NONE value + * @property {number} HDCP_V1=1 HDCP_V1 value + * @property {number} HDCP_V2=2 HDCP_V2 value + * @property {number} HDCP_V2_1=3 HDCP_V2_1 value + * @property {number} HDCP_V2_2=4 HDCP_V2_2 value + * @property {number} HDCP_V2_3=5 HDCP_V2_3 value + * @property {number} HDCP_NO_DIGITAL_OUTPUT=255 HDCP_NO_DIGITAL_OUTPUT value + */ + ClientCapabilities.HdcpVersion = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "HDCP_NONE"] = 0; + values[valuesById[1] = "HDCP_V1"] = 1; + values[valuesById[2] = "HDCP_V2"] = 2; + values[valuesById[3] = "HDCP_V2_1"] = 3; + values[valuesById[4] = "HDCP_V2_2"] = 4; + values[valuesById[5] = "HDCP_V2_3"] = 5; + values[valuesById[255] = "HDCP_NO_DIGITAL_OUTPUT"] = 255; + return values; + })(); + + /** + * CertificateKeyType enum. + * @name license_protocol.ClientIdentification.ClientCapabilities.CertificateKeyType + * @enum {number} + * @property {number} RSA_2048=0 RSA_2048 value + * @property {number} RSA_3072=1 RSA_3072 value + * @property {number} ECC_SECP256R1=2 ECC_SECP256R1 value + * @property {number} ECC_SECP384R1=3 ECC_SECP384R1 value + * @property {number} ECC_SECP521R1=4 ECC_SECP521R1 value + */ + ClientCapabilities.CertificateKeyType = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "RSA_2048"] = 0; + values[valuesById[1] = "RSA_3072"] = 1; + values[valuesById[2] = "ECC_SECP256R1"] = 2; + values[valuesById[3] = "ECC_SECP384R1"] = 3; + values[valuesById[4] = "ECC_SECP521R1"] = 4; + return values; + })(); + + /** + * AnalogOutputCapabilities enum. + * @name license_protocol.ClientIdentification.ClientCapabilities.AnalogOutputCapabilities + * @enum {number} + * @property {number} ANALOG_OUTPUT_UNKNOWN=0 ANALOG_OUTPUT_UNKNOWN value + * @property {number} ANALOG_OUTPUT_NONE=1 ANALOG_OUTPUT_NONE value + * @property {number} ANALOG_OUTPUT_SUPPORTED=2 ANALOG_OUTPUT_SUPPORTED value + * @property {number} ANALOG_OUTPUT_SUPPORTS_CGMS_A=3 ANALOG_OUTPUT_SUPPORTS_CGMS_A value + */ + ClientCapabilities.AnalogOutputCapabilities = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "ANALOG_OUTPUT_UNKNOWN"] = 0; + values[valuesById[1] = "ANALOG_OUTPUT_NONE"] = 1; + values[valuesById[2] = "ANALOG_OUTPUT_SUPPORTED"] = 2; + values[valuesById[3] = "ANALOG_OUTPUT_SUPPORTS_CGMS_A"] = 3; + return values; + })(); + + return ClientCapabilities; + })(); + + ClientIdentification.ClientCredentials = (function() { + + /** + * Properties of a ClientCredentials. + * @memberof license_protocol.ClientIdentification + * @interface IClientCredentials + * @property {license_protocol.ClientIdentification.TokenType|null} [type] ClientCredentials type + * @property {Uint8Array|null} [token] ClientCredentials token + */ + + /** + * Constructs a new ClientCredentials. + * @memberof license_protocol.ClientIdentification + * @classdesc Represents a ClientCredentials. + * @implements IClientCredentials + * @constructor + * @param {license_protocol.ClientIdentification.IClientCredentials=} [properties] Properties to set + */ + function ClientCredentials(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ClientCredentials type. + * @member {license_protocol.ClientIdentification.TokenType} type + * @memberof license_protocol.ClientIdentification.ClientCredentials + * @instance + */ + ClientCredentials.prototype.type = 0; + + /** + * ClientCredentials token. + * @member {Uint8Array} token + * @memberof license_protocol.ClientIdentification.ClientCredentials + * @instance + */ + ClientCredentials.prototype.token = $util.newBuffer([]); + + /** + * Creates a new ClientCredentials instance using the specified properties. + * @function create + * @memberof license_protocol.ClientIdentification.ClientCredentials + * @static + * @param {license_protocol.ClientIdentification.IClientCredentials=} [properties] Properties to set + * @returns {license_protocol.ClientIdentification.ClientCredentials} ClientCredentials instance + */ + ClientCredentials.create = function create(properties) { + return new ClientCredentials(properties); + }; + + /** + * Encodes the specified ClientCredentials message. Does not implicitly {@link license_protocol.ClientIdentification.ClientCredentials.verify|verify} messages. + * @function encode + * @memberof license_protocol.ClientIdentification.ClientCredentials + * @static + * @param {license_protocol.ClientIdentification.IClientCredentials} message ClientCredentials message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ClientCredentials.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.type != null && Object.hasOwnProperty.call(message, "type")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.type); + if (message.token != null && Object.hasOwnProperty.call(message, "token")) + writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.token); + return writer; + }; + + /** + * Encodes the specified ClientCredentials message, length delimited. Does not implicitly {@link license_protocol.ClientIdentification.ClientCredentials.verify|verify} messages. + * @function encodeDelimited + * @memberof license_protocol.ClientIdentification.ClientCredentials + * @static + * @param {license_protocol.ClientIdentification.IClientCredentials} message ClientCredentials message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ClientCredentials.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ClientCredentials message from the specified reader or buffer. + * @function decode + * @memberof license_protocol.ClientIdentification.ClientCredentials + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {license_protocol.ClientIdentification.ClientCredentials} ClientCredentials + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ClientCredentials.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.license_protocol.ClientIdentification.ClientCredentials(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.type = reader.int32(); + break; + } + case 2: { + message.token = reader.bytes(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ClientCredentials message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof license_protocol.ClientIdentification.ClientCredentials + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {license_protocol.ClientIdentification.ClientCredentials} ClientCredentials + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ClientCredentials.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ClientCredentials message. + * @function verify + * @memberof license_protocol.ClientIdentification.ClientCredentials + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ClientCredentials.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.type != null && message.hasOwnProperty("type")) + switch (message.type) { + default: + return "type: enum value expected"; + case 0: + case 1: + case 2: + case 3: + break; + } + if (message.token != null && message.hasOwnProperty("token")) + if (!(message.token && typeof message.token.length === "number" || $util.isString(message.token))) + return "token: buffer expected"; + return null; + }; + + /** + * Creates a ClientCredentials message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof license_protocol.ClientIdentification.ClientCredentials + * @static + * @param {Object.} object Plain object + * @returns {license_protocol.ClientIdentification.ClientCredentials} ClientCredentials + */ + ClientCredentials.fromObject = function fromObject(object) { + if (object instanceof $root.license_protocol.ClientIdentification.ClientCredentials) + return object; + var message = new $root.license_protocol.ClientIdentification.ClientCredentials(); + switch (object.type) { + default: + if (typeof object.type === "number") { + message.type = object.type; + break; + } + break; + case "KEYBOX": + case 0: + message.type = 0; + break; + case "DRM_DEVICE_CERTIFICATE": + case 1: + message.type = 1; + break; + case "REMOTE_ATTESTATION_CERTIFICATE": + case 2: + message.type = 2; + break; + case "OEM_DEVICE_CERTIFICATE": + case 3: + message.type = 3; + break; + } + if (object.token != null) + if (typeof object.token === "string") + $util.base64.decode(object.token, message.token = $util.newBuffer($util.base64.length(object.token)), 0); + else if (object.token.length >= 0) + message.token = object.token; + return message; + }; + + /** + * Creates a plain object from a ClientCredentials message. Also converts values to other types if specified. + * @function toObject + * @memberof license_protocol.ClientIdentification.ClientCredentials + * @static + * @param {license_protocol.ClientIdentification.ClientCredentials} message ClientCredentials + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ClientCredentials.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.type = options.enums === String ? "KEYBOX" : 0; + if (options.bytes === String) + object.token = ""; + else { + object.token = []; + if (options.bytes !== Array) + object.token = $util.newBuffer(object.token); + } + } + if (message.type != null && message.hasOwnProperty("type")) + object.type = options.enums === String ? $root.license_protocol.ClientIdentification.TokenType[message.type] === undefined ? message.type : $root.license_protocol.ClientIdentification.TokenType[message.type] : message.type; + if (message.token != null && message.hasOwnProperty("token")) + object.token = options.bytes === String ? $util.base64.encode(message.token, 0, message.token.length) : options.bytes === Array ? Array.prototype.slice.call(message.token) : message.token; + return object; + }; + + /** + * Converts this ClientCredentials to JSON. + * @function toJSON + * @memberof license_protocol.ClientIdentification.ClientCredentials + * @instance + * @returns {Object.} JSON object + */ + ClientCredentials.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ClientCredentials + * @function getTypeUrl + * @memberof license_protocol.ClientIdentification.ClientCredentials + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ClientCredentials.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/license_protocol.ClientIdentification.ClientCredentials"; + }; + + return ClientCredentials; + })(); + + return ClientIdentification; + })(); + + license_protocol.EncryptedClientIdentification = (function() { + + /** + * Properties of an EncryptedClientIdentification. + * @memberof license_protocol + * @interface IEncryptedClientIdentification + * @property {string|null} [providerId] EncryptedClientIdentification providerId + * @property {Uint8Array|null} [serviceCertificateSerialNumber] EncryptedClientIdentification serviceCertificateSerialNumber + * @property {Uint8Array|null} [encryptedClientId] EncryptedClientIdentification encryptedClientId + * @property {Uint8Array|null} [encryptedClientIdIv] EncryptedClientIdentification encryptedClientIdIv + * @property {Uint8Array|null} [encryptedPrivacyKey] EncryptedClientIdentification encryptedPrivacyKey + */ + + /** + * Constructs a new EncryptedClientIdentification. + * @memberof license_protocol + * @classdesc Represents an EncryptedClientIdentification. + * @implements IEncryptedClientIdentification + * @constructor + * @param {license_protocol.IEncryptedClientIdentification=} [properties] Properties to set + */ + function EncryptedClientIdentification(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * EncryptedClientIdentification providerId. + * @member {string} providerId + * @memberof license_protocol.EncryptedClientIdentification + * @instance + */ + EncryptedClientIdentification.prototype.providerId = ""; + + /** + * EncryptedClientIdentification serviceCertificateSerialNumber. + * @member {Uint8Array} serviceCertificateSerialNumber + * @memberof license_protocol.EncryptedClientIdentification + * @instance + */ + EncryptedClientIdentification.prototype.serviceCertificateSerialNumber = $util.newBuffer([]); + + /** + * EncryptedClientIdentification encryptedClientId. + * @member {Uint8Array} encryptedClientId + * @memberof license_protocol.EncryptedClientIdentification + * @instance + */ + EncryptedClientIdentification.prototype.encryptedClientId = $util.newBuffer([]); + + /** + * EncryptedClientIdentification encryptedClientIdIv. + * @member {Uint8Array} encryptedClientIdIv + * @memberof license_protocol.EncryptedClientIdentification + * @instance + */ + EncryptedClientIdentification.prototype.encryptedClientIdIv = $util.newBuffer([]); + + /** + * EncryptedClientIdentification encryptedPrivacyKey. + * @member {Uint8Array} encryptedPrivacyKey + * @memberof license_protocol.EncryptedClientIdentification + * @instance + */ + EncryptedClientIdentification.prototype.encryptedPrivacyKey = $util.newBuffer([]); + + /** + * Creates a new EncryptedClientIdentification instance using the specified properties. + * @function create + * @memberof license_protocol.EncryptedClientIdentification + * @static + * @param {license_protocol.IEncryptedClientIdentification=} [properties] Properties to set + * @returns {license_protocol.EncryptedClientIdentification} EncryptedClientIdentification instance + */ + EncryptedClientIdentification.create = function create(properties) { + return new EncryptedClientIdentification(properties); + }; + + /** + * Encodes the specified EncryptedClientIdentification message. Does not implicitly {@link license_protocol.EncryptedClientIdentification.verify|verify} messages. + * @function encode + * @memberof license_protocol.EncryptedClientIdentification + * @static + * @param {license_protocol.IEncryptedClientIdentification} message EncryptedClientIdentification message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EncryptedClientIdentification.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.providerId != null && Object.hasOwnProperty.call(message, "providerId")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.providerId); + if (message.serviceCertificateSerialNumber != null && Object.hasOwnProperty.call(message, "serviceCertificateSerialNumber")) + writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.serviceCertificateSerialNumber); + if (message.encryptedClientId != null && Object.hasOwnProperty.call(message, "encryptedClientId")) + writer.uint32(/* id 3, wireType 2 =*/26).bytes(message.encryptedClientId); + if (message.encryptedClientIdIv != null && Object.hasOwnProperty.call(message, "encryptedClientIdIv")) + writer.uint32(/* id 4, wireType 2 =*/34).bytes(message.encryptedClientIdIv); + if (message.encryptedPrivacyKey != null && Object.hasOwnProperty.call(message, "encryptedPrivacyKey")) + writer.uint32(/* id 5, wireType 2 =*/42).bytes(message.encryptedPrivacyKey); + return writer; + }; + + /** + * Encodes the specified EncryptedClientIdentification message, length delimited. Does not implicitly {@link license_protocol.EncryptedClientIdentification.verify|verify} messages. + * @function encodeDelimited + * @memberof license_protocol.EncryptedClientIdentification + * @static + * @param {license_protocol.IEncryptedClientIdentification} message EncryptedClientIdentification message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EncryptedClientIdentification.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an EncryptedClientIdentification message from the specified reader or buffer. + * @function decode + * @memberof license_protocol.EncryptedClientIdentification + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {license_protocol.EncryptedClientIdentification} EncryptedClientIdentification + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EncryptedClientIdentification.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.license_protocol.EncryptedClientIdentification(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.providerId = reader.string(); + break; + } + case 2: { + message.serviceCertificateSerialNumber = reader.bytes(); + break; + } + case 3: { + message.encryptedClientId = reader.bytes(); + break; + } + case 4: { + message.encryptedClientIdIv = reader.bytes(); + break; + } + case 5: { + message.encryptedPrivacyKey = reader.bytes(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an EncryptedClientIdentification message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof license_protocol.EncryptedClientIdentification + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {license_protocol.EncryptedClientIdentification} EncryptedClientIdentification + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EncryptedClientIdentification.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an EncryptedClientIdentification message. + * @function verify + * @memberof license_protocol.EncryptedClientIdentification + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + EncryptedClientIdentification.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.providerId != null && message.hasOwnProperty("providerId")) + if (!$util.isString(message.providerId)) + return "providerId: string expected"; + if (message.serviceCertificateSerialNumber != null && message.hasOwnProperty("serviceCertificateSerialNumber")) + if (!(message.serviceCertificateSerialNumber && typeof message.serviceCertificateSerialNumber.length === "number" || $util.isString(message.serviceCertificateSerialNumber))) + return "serviceCertificateSerialNumber: buffer expected"; + if (message.encryptedClientId != null && message.hasOwnProperty("encryptedClientId")) + if (!(message.encryptedClientId && typeof message.encryptedClientId.length === "number" || $util.isString(message.encryptedClientId))) + return "encryptedClientId: buffer expected"; + if (message.encryptedClientIdIv != null && message.hasOwnProperty("encryptedClientIdIv")) + if (!(message.encryptedClientIdIv && typeof message.encryptedClientIdIv.length === "number" || $util.isString(message.encryptedClientIdIv))) + return "encryptedClientIdIv: buffer expected"; + if (message.encryptedPrivacyKey != null && message.hasOwnProperty("encryptedPrivacyKey")) + if (!(message.encryptedPrivacyKey && typeof message.encryptedPrivacyKey.length === "number" || $util.isString(message.encryptedPrivacyKey))) + return "encryptedPrivacyKey: buffer expected"; + return null; + }; + + /** + * Creates an EncryptedClientIdentification message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof license_protocol.EncryptedClientIdentification + * @static + * @param {Object.} object Plain object + * @returns {license_protocol.EncryptedClientIdentification} EncryptedClientIdentification + */ + EncryptedClientIdentification.fromObject = function fromObject(object) { + if (object instanceof $root.license_protocol.EncryptedClientIdentification) + return object; + var message = new $root.license_protocol.EncryptedClientIdentification(); + if (object.providerId != null) + message.providerId = String(object.providerId); + if (object.serviceCertificateSerialNumber != null) + if (typeof object.serviceCertificateSerialNumber === "string") + $util.base64.decode(object.serviceCertificateSerialNumber, message.serviceCertificateSerialNumber = $util.newBuffer($util.base64.length(object.serviceCertificateSerialNumber)), 0); + else if (object.serviceCertificateSerialNumber.length >= 0) + message.serviceCertificateSerialNumber = object.serviceCertificateSerialNumber; + if (object.encryptedClientId != null) + if (typeof object.encryptedClientId === "string") + $util.base64.decode(object.encryptedClientId, message.encryptedClientId = $util.newBuffer($util.base64.length(object.encryptedClientId)), 0); + else if (object.encryptedClientId.length >= 0) + message.encryptedClientId = object.encryptedClientId; + if (object.encryptedClientIdIv != null) + if (typeof object.encryptedClientIdIv === "string") + $util.base64.decode(object.encryptedClientIdIv, message.encryptedClientIdIv = $util.newBuffer($util.base64.length(object.encryptedClientIdIv)), 0); + else if (object.encryptedClientIdIv.length >= 0) + message.encryptedClientIdIv = object.encryptedClientIdIv; + if (object.encryptedPrivacyKey != null) + if (typeof object.encryptedPrivacyKey === "string") + $util.base64.decode(object.encryptedPrivacyKey, message.encryptedPrivacyKey = $util.newBuffer($util.base64.length(object.encryptedPrivacyKey)), 0); + else if (object.encryptedPrivacyKey.length >= 0) + message.encryptedPrivacyKey = object.encryptedPrivacyKey; + return message; + }; + + /** + * Creates a plain object from an EncryptedClientIdentification message. Also converts values to other types if specified. + * @function toObject + * @memberof license_protocol.EncryptedClientIdentification + * @static + * @param {license_protocol.EncryptedClientIdentification} message EncryptedClientIdentification + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + EncryptedClientIdentification.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.providerId = ""; + if (options.bytes === String) + object.serviceCertificateSerialNumber = ""; + else { + object.serviceCertificateSerialNumber = []; + if (options.bytes !== Array) + object.serviceCertificateSerialNumber = $util.newBuffer(object.serviceCertificateSerialNumber); + } + if (options.bytes === String) + object.encryptedClientId = ""; + else { + object.encryptedClientId = []; + if (options.bytes !== Array) + object.encryptedClientId = $util.newBuffer(object.encryptedClientId); + } + if (options.bytes === String) + object.encryptedClientIdIv = ""; + else { + object.encryptedClientIdIv = []; + if (options.bytes !== Array) + object.encryptedClientIdIv = $util.newBuffer(object.encryptedClientIdIv); + } + if (options.bytes === String) + object.encryptedPrivacyKey = ""; + else { + object.encryptedPrivacyKey = []; + if (options.bytes !== Array) + object.encryptedPrivacyKey = $util.newBuffer(object.encryptedPrivacyKey); + } + } + if (message.providerId != null && message.hasOwnProperty("providerId")) + object.providerId = message.providerId; + if (message.serviceCertificateSerialNumber != null && message.hasOwnProperty("serviceCertificateSerialNumber")) + object.serviceCertificateSerialNumber = options.bytes === String ? $util.base64.encode(message.serviceCertificateSerialNumber, 0, message.serviceCertificateSerialNumber.length) : options.bytes === Array ? Array.prototype.slice.call(message.serviceCertificateSerialNumber) : message.serviceCertificateSerialNumber; + if (message.encryptedClientId != null && message.hasOwnProperty("encryptedClientId")) + object.encryptedClientId = options.bytes === String ? $util.base64.encode(message.encryptedClientId, 0, message.encryptedClientId.length) : options.bytes === Array ? Array.prototype.slice.call(message.encryptedClientId) : message.encryptedClientId; + if (message.encryptedClientIdIv != null && message.hasOwnProperty("encryptedClientIdIv")) + object.encryptedClientIdIv = options.bytes === String ? $util.base64.encode(message.encryptedClientIdIv, 0, message.encryptedClientIdIv.length) : options.bytes === Array ? Array.prototype.slice.call(message.encryptedClientIdIv) : message.encryptedClientIdIv; + if (message.encryptedPrivacyKey != null && message.hasOwnProperty("encryptedPrivacyKey")) + object.encryptedPrivacyKey = options.bytes === String ? $util.base64.encode(message.encryptedPrivacyKey, 0, message.encryptedPrivacyKey.length) : options.bytes === Array ? Array.prototype.slice.call(message.encryptedPrivacyKey) : message.encryptedPrivacyKey; + return object; + }; + + /** + * Converts this EncryptedClientIdentification to JSON. + * @function toJSON + * @memberof license_protocol.EncryptedClientIdentification + * @instance + * @returns {Object.} JSON object + */ + EncryptedClientIdentification.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for EncryptedClientIdentification + * @function getTypeUrl + * @memberof license_protocol.EncryptedClientIdentification + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + EncryptedClientIdentification.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/license_protocol.EncryptedClientIdentification"; + }; + + return EncryptedClientIdentification; + })(); + + license_protocol.DrmCertificate = (function() { + + /** + * Properties of a DrmCertificate. + * @memberof license_protocol + * @interface IDrmCertificate + * @property {license_protocol.DrmCertificate.Type|null} [type] DrmCertificate type + * @property {Uint8Array|null} [serialNumber] DrmCertificate serialNumber + * @property {number|null} [creationTimeSeconds] DrmCertificate creationTimeSeconds + * @property {number|null} [expirationTimeSeconds] DrmCertificate expirationTimeSeconds + * @property {Uint8Array|null} [publicKey] DrmCertificate publicKey + * @property {number|null} [systemId] DrmCertificate systemId + * @property {boolean|null} [testDeviceDeprecated] DrmCertificate testDeviceDeprecated + * @property {string|null} [providerId] DrmCertificate providerId + * @property {Array.|null} [serviceTypes] DrmCertificate serviceTypes + * @property {license_protocol.DrmCertificate.Algorithm|null} [algorithm] DrmCertificate algorithm + * @property {Uint8Array|null} [rotId] DrmCertificate rotId + * @property {license_protocol.DrmCertificate.IEncryptionKey|null} [encryptionKey] DrmCertificate encryptionKey + */ + + /** + * Constructs a new DrmCertificate. + * @memberof license_protocol + * @classdesc Represents a DrmCertificate. + * @implements IDrmCertificate + * @constructor + * @param {license_protocol.IDrmCertificate=} [properties] Properties to set + */ + function DrmCertificate(properties) { + this.serviceTypes = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DrmCertificate type. + * @member {license_protocol.DrmCertificate.Type} type + * @memberof license_protocol.DrmCertificate + * @instance + */ + DrmCertificate.prototype.type = 0; + + /** + * DrmCertificate serialNumber. + * @member {Uint8Array} serialNumber + * @memberof license_protocol.DrmCertificate + * @instance + */ + DrmCertificate.prototype.serialNumber = $util.newBuffer([]); + + /** + * DrmCertificate creationTimeSeconds. + * @member {number} creationTimeSeconds + * @memberof license_protocol.DrmCertificate + * @instance + */ + DrmCertificate.prototype.creationTimeSeconds = 0; + + /** + * DrmCertificate expirationTimeSeconds. + * @member {number} expirationTimeSeconds + * @memberof license_protocol.DrmCertificate + * @instance + */ + DrmCertificate.prototype.expirationTimeSeconds = 0; + + /** + * DrmCertificate publicKey. + * @member {Uint8Array} publicKey + * @memberof license_protocol.DrmCertificate + * @instance + */ + DrmCertificate.prototype.publicKey = $util.newBuffer([]); + + /** + * DrmCertificate systemId. + * @member {number} systemId + * @memberof license_protocol.DrmCertificate + * @instance + */ + DrmCertificate.prototype.systemId = 0; + + /** + * DrmCertificate testDeviceDeprecated. + * @member {boolean} testDeviceDeprecated + * @memberof license_protocol.DrmCertificate + * @instance + */ + DrmCertificate.prototype.testDeviceDeprecated = false; + + /** + * DrmCertificate providerId. + * @member {string} providerId + * @memberof license_protocol.DrmCertificate + * @instance + */ + DrmCertificate.prototype.providerId = ""; + + /** + * DrmCertificate serviceTypes. + * @member {Array.} serviceTypes + * @memberof license_protocol.DrmCertificate + * @instance + */ + DrmCertificate.prototype.serviceTypes = $util.emptyArray; + + /** + * DrmCertificate algorithm. + * @member {license_protocol.DrmCertificate.Algorithm} algorithm + * @memberof license_protocol.DrmCertificate + * @instance + */ + DrmCertificate.prototype.algorithm = 1; + + /** + * DrmCertificate rotId. + * @member {Uint8Array} rotId + * @memberof license_protocol.DrmCertificate + * @instance + */ + DrmCertificate.prototype.rotId = $util.newBuffer([]); + + /** + * DrmCertificate encryptionKey. + * @member {license_protocol.DrmCertificate.IEncryptionKey|null|undefined} encryptionKey + * @memberof license_protocol.DrmCertificate + * @instance + */ + DrmCertificate.prototype.encryptionKey = null; + + /** + * Creates a new DrmCertificate instance using the specified properties. + * @function create + * @memberof license_protocol.DrmCertificate + * @static + * @param {license_protocol.IDrmCertificate=} [properties] Properties to set + * @returns {license_protocol.DrmCertificate} DrmCertificate instance + */ + DrmCertificate.create = function create(properties) { + return new DrmCertificate(properties); + }; + + /** + * Encodes the specified DrmCertificate message. Does not implicitly {@link license_protocol.DrmCertificate.verify|verify} messages. + * @function encode + * @memberof license_protocol.DrmCertificate + * @static + * @param {license_protocol.IDrmCertificate} message DrmCertificate message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DrmCertificate.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.type != null && Object.hasOwnProperty.call(message, "type")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.type); + if (message.serialNumber != null && Object.hasOwnProperty.call(message, "serialNumber")) + writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.serialNumber); + if (message.creationTimeSeconds != null && Object.hasOwnProperty.call(message, "creationTimeSeconds")) + writer.uint32(/* id 3, wireType 0 =*/24).uint32(message.creationTimeSeconds); + if (message.publicKey != null && Object.hasOwnProperty.call(message, "publicKey")) + writer.uint32(/* id 4, wireType 2 =*/34).bytes(message.publicKey); + if (message.systemId != null && Object.hasOwnProperty.call(message, "systemId")) + writer.uint32(/* id 5, wireType 0 =*/40).uint32(message.systemId); + if (message.testDeviceDeprecated != null && Object.hasOwnProperty.call(message, "testDeviceDeprecated")) + writer.uint32(/* id 6, wireType 0 =*/48).bool(message.testDeviceDeprecated); + if (message.providerId != null && Object.hasOwnProperty.call(message, "providerId")) + writer.uint32(/* id 7, wireType 2 =*/58).string(message.providerId); + if (message.serviceTypes != null && message.serviceTypes.length) + for (var i = 0; i < message.serviceTypes.length; ++i) + writer.uint32(/* id 8, wireType 0 =*/64).int32(message.serviceTypes[i]); + if (message.algorithm != null && Object.hasOwnProperty.call(message, "algorithm")) + writer.uint32(/* id 9, wireType 0 =*/72).int32(message.algorithm); + if (message.rotId != null && Object.hasOwnProperty.call(message, "rotId")) + writer.uint32(/* id 10, wireType 2 =*/82).bytes(message.rotId); + if (message.encryptionKey != null && Object.hasOwnProperty.call(message, "encryptionKey")) + $root.license_protocol.DrmCertificate.EncryptionKey.encode(message.encryptionKey, writer.uint32(/* id 11, wireType 2 =*/90).fork()).ldelim(); + if (message.expirationTimeSeconds != null && Object.hasOwnProperty.call(message, "expirationTimeSeconds")) + writer.uint32(/* id 12, wireType 0 =*/96).uint32(message.expirationTimeSeconds); + return writer; + }; + + /** + * Encodes the specified DrmCertificate message, length delimited. Does not implicitly {@link license_protocol.DrmCertificate.verify|verify} messages. + * @function encodeDelimited + * @memberof license_protocol.DrmCertificate + * @static + * @param {license_protocol.IDrmCertificate} message DrmCertificate message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DrmCertificate.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DrmCertificate message from the specified reader or buffer. + * @function decode + * @memberof license_protocol.DrmCertificate + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {license_protocol.DrmCertificate} DrmCertificate + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DrmCertificate.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.license_protocol.DrmCertificate(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.type = reader.int32(); + break; + } + case 2: { + message.serialNumber = reader.bytes(); + break; + } + case 3: { + message.creationTimeSeconds = reader.uint32(); + break; + } + case 12: { + message.expirationTimeSeconds = reader.uint32(); + break; + } + case 4: { + message.publicKey = reader.bytes(); + break; + } + case 5: { + message.systemId = reader.uint32(); + break; + } + case 6: { + message.testDeviceDeprecated = reader.bool(); + break; + } + case 7: { + message.providerId = reader.string(); + break; + } + case 8: { + if (!(message.serviceTypes && message.serviceTypes.length)) + message.serviceTypes = []; + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) + message.serviceTypes.push(reader.int32()); + } else + message.serviceTypes.push(reader.int32()); + break; + } + case 9: { + message.algorithm = reader.int32(); + break; + } + case 10: { + message.rotId = reader.bytes(); + break; + } + case 11: { + message.encryptionKey = $root.license_protocol.DrmCertificate.EncryptionKey.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a DrmCertificate message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof license_protocol.DrmCertificate + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {license_protocol.DrmCertificate} DrmCertificate + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DrmCertificate.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DrmCertificate message. + * @function verify + * @memberof license_protocol.DrmCertificate + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DrmCertificate.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.type != null && message.hasOwnProperty("type")) + switch (message.type) { + default: + return "type: enum value expected"; + case 0: + case 1: + case 2: + case 3: + case 4: + break; + } + if (message.serialNumber != null && message.hasOwnProperty("serialNumber")) + if (!(message.serialNumber && typeof message.serialNumber.length === "number" || $util.isString(message.serialNumber))) + return "serialNumber: buffer expected"; + if (message.creationTimeSeconds != null && message.hasOwnProperty("creationTimeSeconds")) + if (!$util.isInteger(message.creationTimeSeconds)) + return "creationTimeSeconds: integer expected"; + if (message.expirationTimeSeconds != null && message.hasOwnProperty("expirationTimeSeconds")) + if (!$util.isInteger(message.expirationTimeSeconds)) + return "expirationTimeSeconds: integer expected"; + if (message.publicKey != null && message.hasOwnProperty("publicKey")) + if (!(message.publicKey && typeof message.publicKey.length === "number" || $util.isString(message.publicKey))) + return "publicKey: buffer expected"; + if (message.systemId != null && message.hasOwnProperty("systemId")) + if (!$util.isInteger(message.systemId)) + return "systemId: integer expected"; + if (message.testDeviceDeprecated != null && message.hasOwnProperty("testDeviceDeprecated")) + if (typeof message.testDeviceDeprecated !== "boolean") + return "testDeviceDeprecated: boolean expected"; + if (message.providerId != null && message.hasOwnProperty("providerId")) + if (!$util.isString(message.providerId)) + return "providerId: string expected"; + if (message.serviceTypes != null && message.hasOwnProperty("serviceTypes")) { + if (!Array.isArray(message.serviceTypes)) + return "serviceTypes: array expected"; + for (var i = 0; i < message.serviceTypes.length; ++i) + switch (message.serviceTypes[i]) { + default: + return "serviceTypes: enum value[] expected"; + case 0: + case 1: + case 2: + case 3: + case 4: + break; + } + } + if (message.algorithm != null && message.hasOwnProperty("algorithm")) + switch (message.algorithm) { + default: + return "algorithm: enum value expected"; + case 0: + case 1: + case 2: + case 3: + case 4: + break; + } + if (message.rotId != null && message.hasOwnProperty("rotId")) + if (!(message.rotId && typeof message.rotId.length === "number" || $util.isString(message.rotId))) + return "rotId: buffer expected"; + if (message.encryptionKey != null && message.hasOwnProperty("encryptionKey")) { + var error = $root.license_protocol.DrmCertificate.EncryptionKey.verify(message.encryptionKey); + if (error) + return "encryptionKey." + error; + } + return null; + }; + + /** + * Creates a DrmCertificate message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof license_protocol.DrmCertificate + * @static + * @param {Object.} object Plain object + * @returns {license_protocol.DrmCertificate} DrmCertificate + */ + DrmCertificate.fromObject = function fromObject(object) { + if (object instanceof $root.license_protocol.DrmCertificate) + return object; + var message = new $root.license_protocol.DrmCertificate(); + switch (object.type) { + default: + if (typeof object.type === "number") { + message.type = object.type; + break; + } + break; + case "ROOT": + case 0: + message.type = 0; + break; + case "DEVICE_MODEL": + case 1: + message.type = 1; + break; + case "DEVICE": + case 2: + message.type = 2; + break; + case "SERVICE": + case 3: + message.type = 3; + break; + case "PROVISIONER": + case 4: + message.type = 4; + break; + } + if (object.serialNumber != null) + if (typeof object.serialNumber === "string") + $util.base64.decode(object.serialNumber, message.serialNumber = $util.newBuffer($util.base64.length(object.serialNumber)), 0); + else if (object.serialNumber.length >= 0) + message.serialNumber = object.serialNumber; + if (object.creationTimeSeconds != null) + message.creationTimeSeconds = object.creationTimeSeconds >>> 0; + if (object.expirationTimeSeconds != null) + message.expirationTimeSeconds = object.expirationTimeSeconds >>> 0; + if (object.publicKey != null) + if (typeof object.publicKey === "string") + $util.base64.decode(object.publicKey, message.publicKey = $util.newBuffer($util.base64.length(object.publicKey)), 0); + else if (object.publicKey.length >= 0) + message.publicKey = object.publicKey; + if (object.systemId != null) + message.systemId = object.systemId >>> 0; + if (object.testDeviceDeprecated != null) + message.testDeviceDeprecated = Boolean(object.testDeviceDeprecated); + if (object.providerId != null) + message.providerId = String(object.providerId); + if (object.serviceTypes) { + if (!Array.isArray(object.serviceTypes)) + throw TypeError(".license_protocol.DrmCertificate.serviceTypes: array expected"); + message.serviceTypes = []; + for (var i = 0; i < object.serviceTypes.length; ++i) + switch (object.serviceTypes[i]) { + default: + if (typeof object.serviceTypes[i] === "number") { + message.serviceTypes[i] = object.serviceTypes[i]; + break; + } + case "UNKNOWN_SERVICE_TYPE": + case 0: + message.serviceTypes[i] = 0; + break; + case "LICENSE_SERVER_SDK": + case 1: + message.serviceTypes[i] = 1; + break; + case "LICENSE_SERVER_PROXY_SDK": + case 2: + message.serviceTypes[i] = 2; + break; + case "PROVISIONING_SDK": + case 3: + message.serviceTypes[i] = 3; + break; + case "CAS_PROXY_SDK": + case 4: + message.serviceTypes[i] = 4; + break; + } + } + switch (object.algorithm) { + case "UNKNOWN_ALGORITHM": + case 0: + message.algorithm = 0; + break; + default: + if (typeof object.algorithm === "number") { + message.algorithm = object.algorithm; + break; + } + break; + case "RSA": + case 1: + message.algorithm = 1; + break; + case "ECC_SECP256R1": + case 2: + message.algorithm = 2; + break; + case "ECC_SECP384R1": + case 3: + message.algorithm = 3; + break; + case "ECC_SECP521R1": + case 4: + message.algorithm = 4; + break; + } + if (object.rotId != null) + if (typeof object.rotId === "string") + $util.base64.decode(object.rotId, message.rotId = $util.newBuffer($util.base64.length(object.rotId)), 0); + else if (object.rotId.length >= 0) + message.rotId = object.rotId; + if (object.encryptionKey != null) { + if (typeof object.encryptionKey !== "object") + throw TypeError(".license_protocol.DrmCertificate.encryptionKey: object expected"); + message.encryptionKey = $root.license_protocol.DrmCertificate.EncryptionKey.fromObject(object.encryptionKey); + } + return message; + }; + + /** + * Creates a plain object from a DrmCertificate message. Also converts values to other types if specified. + * @function toObject + * @memberof license_protocol.DrmCertificate + * @static + * @param {license_protocol.DrmCertificate} message DrmCertificate + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DrmCertificate.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.serviceTypes = []; + if (options.defaults) { + object.type = options.enums === String ? "ROOT" : 0; + if (options.bytes === String) + object.serialNumber = ""; + else { + object.serialNumber = []; + if (options.bytes !== Array) + object.serialNumber = $util.newBuffer(object.serialNumber); + } + object.creationTimeSeconds = 0; + if (options.bytes === String) + object.publicKey = ""; + else { + object.publicKey = []; + if (options.bytes !== Array) + object.publicKey = $util.newBuffer(object.publicKey); + } + object.systemId = 0; + object.testDeviceDeprecated = false; + object.providerId = ""; + object.algorithm = options.enums === String ? "RSA" : 1; + if (options.bytes === String) + object.rotId = ""; + else { + object.rotId = []; + if (options.bytes !== Array) + object.rotId = $util.newBuffer(object.rotId); + } + object.encryptionKey = null; + object.expirationTimeSeconds = 0; + } + if (message.type != null && message.hasOwnProperty("type")) + object.type = options.enums === String ? $root.license_protocol.DrmCertificate.Type[message.type] === undefined ? message.type : $root.license_protocol.DrmCertificate.Type[message.type] : message.type; + if (message.serialNumber != null && message.hasOwnProperty("serialNumber")) + object.serialNumber = options.bytes === String ? $util.base64.encode(message.serialNumber, 0, message.serialNumber.length) : options.bytes === Array ? Array.prototype.slice.call(message.serialNumber) : message.serialNumber; + if (message.creationTimeSeconds != null && message.hasOwnProperty("creationTimeSeconds")) + object.creationTimeSeconds = message.creationTimeSeconds; + if (message.publicKey != null && message.hasOwnProperty("publicKey")) + object.publicKey = options.bytes === String ? $util.base64.encode(message.publicKey, 0, message.publicKey.length) : options.bytes === Array ? Array.prototype.slice.call(message.publicKey) : message.publicKey; + if (message.systemId != null && message.hasOwnProperty("systemId")) + object.systemId = message.systemId; + if (message.testDeviceDeprecated != null && message.hasOwnProperty("testDeviceDeprecated")) + object.testDeviceDeprecated = message.testDeviceDeprecated; + if (message.providerId != null && message.hasOwnProperty("providerId")) + object.providerId = message.providerId; + if (message.serviceTypes && message.serviceTypes.length) { + object.serviceTypes = []; + for (var j = 0; j < message.serviceTypes.length; ++j) + object.serviceTypes[j] = options.enums === String ? $root.license_protocol.DrmCertificate.ServiceType[message.serviceTypes[j]] === undefined ? message.serviceTypes[j] : $root.license_protocol.DrmCertificate.ServiceType[message.serviceTypes[j]] : message.serviceTypes[j]; + } + if (message.algorithm != null && message.hasOwnProperty("algorithm")) + object.algorithm = options.enums === String ? $root.license_protocol.DrmCertificate.Algorithm[message.algorithm] === undefined ? message.algorithm : $root.license_protocol.DrmCertificate.Algorithm[message.algorithm] : message.algorithm; + if (message.rotId != null && message.hasOwnProperty("rotId")) + object.rotId = options.bytes === String ? $util.base64.encode(message.rotId, 0, message.rotId.length) : options.bytes === Array ? Array.prototype.slice.call(message.rotId) : message.rotId; + if (message.encryptionKey != null && message.hasOwnProperty("encryptionKey")) + object.encryptionKey = $root.license_protocol.DrmCertificate.EncryptionKey.toObject(message.encryptionKey, options); + if (message.expirationTimeSeconds != null && message.hasOwnProperty("expirationTimeSeconds")) + object.expirationTimeSeconds = message.expirationTimeSeconds; + return object; + }; + + /** + * Converts this DrmCertificate to JSON. + * @function toJSON + * @memberof license_protocol.DrmCertificate + * @instance + * @returns {Object.} JSON object + */ + DrmCertificate.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for DrmCertificate + * @function getTypeUrl + * @memberof license_protocol.DrmCertificate + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + DrmCertificate.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/license_protocol.DrmCertificate"; + }; + + /** + * Type enum. + * @name license_protocol.DrmCertificate.Type + * @enum {number} + * @property {number} ROOT=0 ROOT value + * @property {number} DEVICE_MODEL=1 DEVICE_MODEL value + * @property {number} DEVICE=2 DEVICE value + * @property {number} SERVICE=3 SERVICE value + * @property {number} PROVISIONER=4 PROVISIONER value + */ + DrmCertificate.Type = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "ROOT"] = 0; + values[valuesById[1] = "DEVICE_MODEL"] = 1; + values[valuesById[2] = "DEVICE"] = 2; + values[valuesById[3] = "SERVICE"] = 3; + values[valuesById[4] = "PROVISIONER"] = 4; + return values; + })(); + + /** + * ServiceType enum. + * @name license_protocol.DrmCertificate.ServiceType + * @enum {number} + * @property {number} UNKNOWN_SERVICE_TYPE=0 UNKNOWN_SERVICE_TYPE value + * @property {number} LICENSE_SERVER_SDK=1 LICENSE_SERVER_SDK value + * @property {number} LICENSE_SERVER_PROXY_SDK=2 LICENSE_SERVER_PROXY_SDK value + * @property {number} PROVISIONING_SDK=3 PROVISIONING_SDK value + * @property {number} CAS_PROXY_SDK=4 CAS_PROXY_SDK value + */ + DrmCertificate.ServiceType = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "UNKNOWN_SERVICE_TYPE"] = 0; + values[valuesById[1] = "LICENSE_SERVER_SDK"] = 1; + values[valuesById[2] = "LICENSE_SERVER_PROXY_SDK"] = 2; + values[valuesById[3] = "PROVISIONING_SDK"] = 3; + values[valuesById[4] = "CAS_PROXY_SDK"] = 4; + return values; + })(); + + /** + * Algorithm enum. + * @name license_protocol.DrmCertificate.Algorithm + * @enum {number} + * @property {number} UNKNOWN_ALGORITHM=0 UNKNOWN_ALGORITHM value + * @property {number} RSA=1 RSA value + * @property {number} ECC_SECP256R1=2 ECC_SECP256R1 value + * @property {number} ECC_SECP384R1=3 ECC_SECP384R1 value + * @property {number} ECC_SECP521R1=4 ECC_SECP521R1 value + */ + DrmCertificate.Algorithm = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "UNKNOWN_ALGORITHM"] = 0; + values[valuesById[1] = "RSA"] = 1; + values[valuesById[2] = "ECC_SECP256R1"] = 2; + values[valuesById[3] = "ECC_SECP384R1"] = 3; + values[valuesById[4] = "ECC_SECP521R1"] = 4; + return values; + })(); + + DrmCertificate.EncryptionKey = (function() { + + /** + * Properties of an EncryptionKey. + * @memberof license_protocol.DrmCertificate + * @interface IEncryptionKey + * @property {Uint8Array|null} [publicKey] EncryptionKey publicKey + * @property {license_protocol.DrmCertificate.Algorithm|null} [algorithm] EncryptionKey algorithm + */ + + /** + * Constructs a new EncryptionKey. + * @memberof license_protocol.DrmCertificate + * @classdesc Represents an EncryptionKey. + * @implements IEncryptionKey + * @constructor + * @param {license_protocol.DrmCertificate.IEncryptionKey=} [properties] Properties to set + */ + function EncryptionKey(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * EncryptionKey publicKey. + * @member {Uint8Array} publicKey + * @memberof license_protocol.DrmCertificate.EncryptionKey + * @instance + */ + EncryptionKey.prototype.publicKey = $util.newBuffer([]); + + /** + * EncryptionKey algorithm. + * @member {license_protocol.DrmCertificate.Algorithm} algorithm + * @memberof license_protocol.DrmCertificate.EncryptionKey + * @instance + */ + EncryptionKey.prototype.algorithm = 1; + + /** + * Creates a new EncryptionKey instance using the specified properties. + * @function create + * @memberof license_protocol.DrmCertificate.EncryptionKey + * @static + * @param {license_protocol.DrmCertificate.IEncryptionKey=} [properties] Properties to set + * @returns {license_protocol.DrmCertificate.EncryptionKey} EncryptionKey instance + */ + EncryptionKey.create = function create(properties) { + return new EncryptionKey(properties); + }; + + /** + * Encodes the specified EncryptionKey message. Does not implicitly {@link license_protocol.DrmCertificate.EncryptionKey.verify|verify} messages. + * @function encode + * @memberof license_protocol.DrmCertificate.EncryptionKey + * @static + * @param {license_protocol.DrmCertificate.IEncryptionKey} message EncryptionKey message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EncryptionKey.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.publicKey != null && Object.hasOwnProperty.call(message, "publicKey")) + writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.publicKey); + if (message.algorithm != null && Object.hasOwnProperty.call(message, "algorithm")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.algorithm); + return writer; + }; + + /** + * Encodes the specified EncryptionKey message, length delimited. Does not implicitly {@link license_protocol.DrmCertificate.EncryptionKey.verify|verify} messages. + * @function encodeDelimited + * @memberof license_protocol.DrmCertificate.EncryptionKey + * @static + * @param {license_protocol.DrmCertificate.IEncryptionKey} message EncryptionKey message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EncryptionKey.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an EncryptionKey message from the specified reader or buffer. + * @function decode + * @memberof license_protocol.DrmCertificate.EncryptionKey + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {license_protocol.DrmCertificate.EncryptionKey} EncryptionKey + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EncryptionKey.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.license_protocol.DrmCertificate.EncryptionKey(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.publicKey = reader.bytes(); + break; + } + case 2: { + message.algorithm = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an EncryptionKey message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof license_protocol.DrmCertificate.EncryptionKey + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {license_protocol.DrmCertificate.EncryptionKey} EncryptionKey + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EncryptionKey.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an EncryptionKey message. + * @function verify + * @memberof license_protocol.DrmCertificate.EncryptionKey + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + EncryptionKey.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.publicKey != null && message.hasOwnProperty("publicKey")) + if (!(message.publicKey && typeof message.publicKey.length === "number" || $util.isString(message.publicKey))) + return "publicKey: buffer expected"; + if (message.algorithm != null && message.hasOwnProperty("algorithm")) + switch (message.algorithm) { + default: + return "algorithm: enum value expected"; + case 0: + case 1: + case 2: + case 3: + case 4: + break; + } + return null; + }; + + /** + * Creates an EncryptionKey message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof license_protocol.DrmCertificate.EncryptionKey + * @static + * @param {Object.} object Plain object + * @returns {license_protocol.DrmCertificate.EncryptionKey} EncryptionKey + */ + EncryptionKey.fromObject = function fromObject(object) { + if (object instanceof $root.license_protocol.DrmCertificate.EncryptionKey) + return object; + var message = new $root.license_protocol.DrmCertificate.EncryptionKey(); + if (object.publicKey != null) + if (typeof object.publicKey === "string") + $util.base64.decode(object.publicKey, message.publicKey = $util.newBuffer($util.base64.length(object.publicKey)), 0); + else if (object.publicKey.length >= 0) + message.publicKey = object.publicKey; + switch (object.algorithm) { + case "UNKNOWN_ALGORITHM": + case 0: + message.algorithm = 0; + break; + default: + if (typeof object.algorithm === "number") { + message.algorithm = object.algorithm; + break; + } + break; + case "RSA": + case 1: + message.algorithm = 1; + break; + case "ECC_SECP256R1": + case 2: + message.algorithm = 2; + break; + case "ECC_SECP384R1": + case 3: + message.algorithm = 3; + break; + case "ECC_SECP521R1": + case 4: + message.algorithm = 4; + break; + } + return message; + }; + + /** + * Creates a plain object from an EncryptionKey message. Also converts values to other types if specified. + * @function toObject + * @memberof license_protocol.DrmCertificate.EncryptionKey + * @static + * @param {license_protocol.DrmCertificate.EncryptionKey} message EncryptionKey + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + EncryptionKey.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + if (options.bytes === String) + object.publicKey = ""; + else { + object.publicKey = []; + if (options.bytes !== Array) + object.publicKey = $util.newBuffer(object.publicKey); + } + object.algorithm = options.enums === String ? "RSA" : 1; + } + if (message.publicKey != null && message.hasOwnProperty("publicKey")) + object.publicKey = options.bytes === String ? $util.base64.encode(message.publicKey, 0, message.publicKey.length) : options.bytes === Array ? Array.prototype.slice.call(message.publicKey) : message.publicKey; + if (message.algorithm != null && message.hasOwnProperty("algorithm")) + object.algorithm = options.enums === String ? $root.license_protocol.DrmCertificate.Algorithm[message.algorithm] === undefined ? message.algorithm : $root.license_protocol.DrmCertificate.Algorithm[message.algorithm] : message.algorithm; + return object; + }; + + /** + * Converts this EncryptionKey to JSON. + * @function toJSON + * @memberof license_protocol.DrmCertificate.EncryptionKey + * @instance + * @returns {Object.} JSON object + */ + EncryptionKey.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for EncryptionKey + * @function getTypeUrl + * @memberof license_protocol.DrmCertificate.EncryptionKey + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + EncryptionKey.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/license_protocol.DrmCertificate.EncryptionKey"; + }; + + return EncryptionKey; + })(); + + return DrmCertificate; + })(); + + license_protocol.SignedDrmCertificate = (function() { + + /** + * Properties of a SignedDrmCertificate. + * @memberof license_protocol + * @interface ISignedDrmCertificate + * @property {Uint8Array|null} [drmCertificate] SignedDrmCertificate drmCertificate + * @property {Uint8Array|null} [signature] SignedDrmCertificate signature + * @property {license_protocol.ISignedDrmCertificate|null} [signer] SignedDrmCertificate signer + * @property {license_protocol.HashAlgorithmProto|null} [hashAlgorithm] SignedDrmCertificate hashAlgorithm + */ + + /** + * Constructs a new SignedDrmCertificate. + * @memberof license_protocol + * @classdesc Represents a SignedDrmCertificate. + * @implements ISignedDrmCertificate + * @constructor + * @param {license_protocol.ISignedDrmCertificate=} [properties] Properties to set + */ + function SignedDrmCertificate(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * SignedDrmCertificate drmCertificate. + * @member {Uint8Array} drmCertificate + * @memberof license_protocol.SignedDrmCertificate + * @instance + */ + SignedDrmCertificate.prototype.drmCertificate = $util.newBuffer([]); + + /** + * SignedDrmCertificate signature. + * @member {Uint8Array} signature + * @memberof license_protocol.SignedDrmCertificate + * @instance + */ + SignedDrmCertificate.prototype.signature = $util.newBuffer([]); + + /** + * SignedDrmCertificate signer. + * @member {license_protocol.ISignedDrmCertificate|null|undefined} signer + * @memberof license_protocol.SignedDrmCertificate + * @instance + */ + SignedDrmCertificate.prototype.signer = null; + + /** + * SignedDrmCertificate hashAlgorithm. + * @member {license_protocol.HashAlgorithmProto} hashAlgorithm + * @memberof license_protocol.SignedDrmCertificate + * @instance + */ + SignedDrmCertificate.prototype.hashAlgorithm = 0; + + /** + * Creates a new SignedDrmCertificate instance using the specified properties. + * @function create + * @memberof license_protocol.SignedDrmCertificate + * @static + * @param {license_protocol.ISignedDrmCertificate=} [properties] Properties to set + * @returns {license_protocol.SignedDrmCertificate} SignedDrmCertificate instance + */ + SignedDrmCertificate.create = function create(properties) { + return new SignedDrmCertificate(properties); + }; + + /** + * Encodes the specified SignedDrmCertificate message. Does not implicitly {@link license_protocol.SignedDrmCertificate.verify|verify} messages. + * @function encode + * @memberof license_protocol.SignedDrmCertificate + * @static + * @param {license_protocol.ISignedDrmCertificate} message SignedDrmCertificate message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SignedDrmCertificate.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.drmCertificate != null && Object.hasOwnProperty.call(message, "drmCertificate")) + writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.drmCertificate); + if (message.signature != null && Object.hasOwnProperty.call(message, "signature")) + writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.signature); + if (message.signer != null && Object.hasOwnProperty.call(message, "signer")) + $root.license_protocol.SignedDrmCertificate.encode(message.signer, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.hashAlgorithm != null && Object.hasOwnProperty.call(message, "hashAlgorithm")) + writer.uint32(/* id 4, wireType 0 =*/32).int32(message.hashAlgorithm); + return writer; + }; + + /** + * Encodes the specified SignedDrmCertificate message, length delimited. Does not implicitly {@link license_protocol.SignedDrmCertificate.verify|verify} messages. + * @function encodeDelimited + * @memberof license_protocol.SignedDrmCertificate + * @static + * @param {license_protocol.ISignedDrmCertificate} message SignedDrmCertificate message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SignedDrmCertificate.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SignedDrmCertificate message from the specified reader or buffer. + * @function decode + * @memberof license_protocol.SignedDrmCertificate + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {license_protocol.SignedDrmCertificate} SignedDrmCertificate + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SignedDrmCertificate.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.license_protocol.SignedDrmCertificate(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.drmCertificate = reader.bytes(); + break; + } + case 2: { + message.signature = reader.bytes(); + break; + } + case 3: { + message.signer = $root.license_protocol.SignedDrmCertificate.decode(reader, reader.uint32()); + break; + } + case 4: { + message.hashAlgorithm = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SignedDrmCertificate message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof license_protocol.SignedDrmCertificate + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {license_protocol.SignedDrmCertificate} SignedDrmCertificate + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SignedDrmCertificate.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SignedDrmCertificate message. + * @function verify + * @memberof license_protocol.SignedDrmCertificate + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SignedDrmCertificate.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.drmCertificate != null && message.hasOwnProperty("drmCertificate")) + if (!(message.drmCertificate && typeof message.drmCertificate.length === "number" || $util.isString(message.drmCertificate))) + return "drmCertificate: buffer expected"; + if (message.signature != null && message.hasOwnProperty("signature")) + if (!(message.signature && typeof message.signature.length === "number" || $util.isString(message.signature))) + return "signature: buffer expected"; + if (message.signer != null && message.hasOwnProperty("signer")) { + var error = $root.license_protocol.SignedDrmCertificate.verify(message.signer); + if (error) + return "signer." + error; + } + if (message.hashAlgorithm != null && message.hasOwnProperty("hashAlgorithm")) + switch (message.hashAlgorithm) { + default: + return "hashAlgorithm: enum value expected"; + case 0: + case 1: + case 2: + case 3: + break; + } + return null; + }; + + /** + * Creates a SignedDrmCertificate message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof license_protocol.SignedDrmCertificate + * @static + * @param {Object.} object Plain object + * @returns {license_protocol.SignedDrmCertificate} SignedDrmCertificate + */ + SignedDrmCertificate.fromObject = function fromObject(object) { + if (object instanceof $root.license_protocol.SignedDrmCertificate) + return object; + var message = new $root.license_protocol.SignedDrmCertificate(); + if (object.drmCertificate != null) + if (typeof object.drmCertificate === "string") + $util.base64.decode(object.drmCertificate, message.drmCertificate = $util.newBuffer($util.base64.length(object.drmCertificate)), 0); + else if (object.drmCertificate.length >= 0) + message.drmCertificate = object.drmCertificate; + if (object.signature != null) + if (typeof object.signature === "string") + $util.base64.decode(object.signature, message.signature = $util.newBuffer($util.base64.length(object.signature)), 0); + else if (object.signature.length >= 0) + message.signature = object.signature; + if (object.signer != null) { + if (typeof object.signer !== "object") + throw TypeError(".license_protocol.SignedDrmCertificate.signer: object expected"); + message.signer = $root.license_protocol.SignedDrmCertificate.fromObject(object.signer); + } + switch (object.hashAlgorithm) { + default: + if (typeof object.hashAlgorithm === "number") { + message.hashAlgorithm = object.hashAlgorithm; + break; + } + break; + case "HASH_ALGORITHM_UNSPECIFIED": + case 0: + message.hashAlgorithm = 0; + break; + case "HASH_ALGORITHM_SHA_1": + case 1: + message.hashAlgorithm = 1; + break; + case "HASH_ALGORITHM_SHA_256": + case 2: + message.hashAlgorithm = 2; + break; + case "HASH_ALGORITHM_SHA_384": + case 3: + message.hashAlgorithm = 3; + break; + } + return message; + }; + + /** + * Creates a plain object from a SignedDrmCertificate message. Also converts values to other types if specified. + * @function toObject + * @memberof license_protocol.SignedDrmCertificate + * @static + * @param {license_protocol.SignedDrmCertificate} message SignedDrmCertificate + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SignedDrmCertificate.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + if (options.bytes === String) + object.drmCertificate = ""; + else { + object.drmCertificate = []; + if (options.bytes !== Array) + object.drmCertificate = $util.newBuffer(object.drmCertificate); + } + if (options.bytes === String) + object.signature = ""; + else { + object.signature = []; + if (options.bytes !== Array) + object.signature = $util.newBuffer(object.signature); + } + object.signer = null; + object.hashAlgorithm = options.enums === String ? "HASH_ALGORITHM_UNSPECIFIED" : 0; + } + if (message.drmCertificate != null && message.hasOwnProperty("drmCertificate")) + object.drmCertificate = options.bytes === String ? $util.base64.encode(message.drmCertificate, 0, message.drmCertificate.length) : options.bytes === Array ? Array.prototype.slice.call(message.drmCertificate) : message.drmCertificate; + if (message.signature != null && message.hasOwnProperty("signature")) + object.signature = options.bytes === String ? $util.base64.encode(message.signature, 0, message.signature.length) : options.bytes === Array ? Array.prototype.slice.call(message.signature) : message.signature; + if (message.signer != null && message.hasOwnProperty("signer")) + object.signer = $root.license_protocol.SignedDrmCertificate.toObject(message.signer, options); + if (message.hashAlgorithm != null && message.hasOwnProperty("hashAlgorithm")) + object.hashAlgorithm = options.enums === String ? $root.license_protocol.HashAlgorithmProto[message.hashAlgorithm] === undefined ? message.hashAlgorithm : $root.license_protocol.HashAlgorithmProto[message.hashAlgorithm] : message.hashAlgorithm; + return object; + }; + + /** + * Converts this SignedDrmCertificate to JSON. + * @function toJSON + * @memberof license_protocol.SignedDrmCertificate + * @instance + * @returns {Object.} JSON object + */ + SignedDrmCertificate.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for SignedDrmCertificate + * @function getTypeUrl + * @memberof license_protocol.SignedDrmCertificate + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + SignedDrmCertificate.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/license_protocol.SignedDrmCertificate"; + }; + + return SignedDrmCertificate; + })(); + + license_protocol.WidevinePsshData = (function() { + + /** + * Properties of a WidevinePsshData. + * @memberof license_protocol + * @interface IWidevinePsshData + * @property {Array.|null} [keyIds] WidevinePsshData keyIds + * @property {Uint8Array|null} [contentId] WidevinePsshData contentId + * @property {number|null} [cryptoPeriodIndex] WidevinePsshData cryptoPeriodIndex + * @property {number|null} [protectionScheme] WidevinePsshData protectionScheme + * @property {number|null} [cryptoPeriodSeconds] WidevinePsshData cryptoPeriodSeconds + * @property {license_protocol.WidevinePsshData.Type|null} [type] WidevinePsshData type + * @property {number|null} [keySequence] WidevinePsshData keySequence + * @property {Array.|null} [groupIds] WidevinePsshData groupIds + * @property {Array.|null} [entitledKeys] WidevinePsshData entitledKeys + * @property {string|null} [videoFeature] WidevinePsshData videoFeature + * @property {license_protocol.WidevinePsshData.Algorithm|null} [algorithm] WidevinePsshData algorithm + * @property {string|null} [provider] WidevinePsshData provider + * @property {string|null} [trackType] WidevinePsshData trackType + * @property {string|null} [policy] WidevinePsshData policy + * @property {Uint8Array|null} [groupedLicense] WidevinePsshData groupedLicense + */ + + /** + * Constructs a new WidevinePsshData. + * @memberof license_protocol + * @classdesc Represents a WidevinePsshData. + * @implements IWidevinePsshData + * @constructor + * @param {license_protocol.IWidevinePsshData=} [properties] Properties to set + */ + function WidevinePsshData(properties) { + this.keyIds = []; + this.groupIds = []; + this.entitledKeys = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * WidevinePsshData keyIds. + * @member {Array.} keyIds + * @memberof license_protocol.WidevinePsshData + * @instance + */ + WidevinePsshData.prototype.keyIds = $util.emptyArray; + + /** + * WidevinePsshData contentId. + * @member {Uint8Array} contentId + * @memberof license_protocol.WidevinePsshData + * @instance + */ + WidevinePsshData.prototype.contentId = $util.newBuffer([]); + + /** + * WidevinePsshData cryptoPeriodIndex. + * @member {number} cryptoPeriodIndex + * @memberof license_protocol.WidevinePsshData + * @instance + */ + WidevinePsshData.prototype.cryptoPeriodIndex = 0; + + /** + * WidevinePsshData protectionScheme. + * @member {number} protectionScheme + * @memberof license_protocol.WidevinePsshData + * @instance + */ + WidevinePsshData.prototype.protectionScheme = 0; + + /** + * WidevinePsshData cryptoPeriodSeconds. + * @member {number} cryptoPeriodSeconds + * @memberof license_protocol.WidevinePsshData + * @instance + */ + WidevinePsshData.prototype.cryptoPeriodSeconds = 0; + + /** + * WidevinePsshData type. + * @member {license_protocol.WidevinePsshData.Type} type + * @memberof license_protocol.WidevinePsshData + * @instance + */ + WidevinePsshData.prototype.type = 0; + + /** + * WidevinePsshData keySequence. + * @member {number} keySequence + * @memberof license_protocol.WidevinePsshData + * @instance + */ + WidevinePsshData.prototype.keySequence = 0; + + /** + * WidevinePsshData groupIds. + * @member {Array.} groupIds + * @memberof license_protocol.WidevinePsshData + * @instance + */ + WidevinePsshData.prototype.groupIds = $util.emptyArray; + + /** + * WidevinePsshData entitledKeys. + * @member {Array.} entitledKeys + * @memberof license_protocol.WidevinePsshData + * @instance + */ + WidevinePsshData.prototype.entitledKeys = $util.emptyArray; + + /** + * WidevinePsshData videoFeature. + * @member {string} videoFeature + * @memberof license_protocol.WidevinePsshData + * @instance + */ + WidevinePsshData.prototype.videoFeature = ""; + + /** + * WidevinePsshData algorithm. + * @member {license_protocol.WidevinePsshData.Algorithm} algorithm + * @memberof license_protocol.WidevinePsshData + * @instance + */ + WidevinePsshData.prototype.algorithm = 0; + + /** + * WidevinePsshData provider. + * @member {string} provider + * @memberof license_protocol.WidevinePsshData + * @instance + */ + WidevinePsshData.prototype.provider = ""; + + /** + * WidevinePsshData trackType. + * @member {string} trackType + * @memberof license_protocol.WidevinePsshData + * @instance + */ + WidevinePsshData.prototype.trackType = ""; + + /** + * WidevinePsshData policy. + * @member {string} policy + * @memberof license_protocol.WidevinePsshData + * @instance + */ + WidevinePsshData.prototype.policy = ""; + + /** + * WidevinePsshData groupedLicense. + * @member {Uint8Array} groupedLicense + * @memberof license_protocol.WidevinePsshData + * @instance + */ + WidevinePsshData.prototype.groupedLicense = $util.newBuffer([]); + + /** + * Creates a new WidevinePsshData instance using the specified properties. + * @function create + * @memberof license_protocol.WidevinePsshData + * @static + * @param {license_protocol.IWidevinePsshData=} [properties] Properties to set + * @returns {license_protocol.WidevinePsshData} WidevinePsshData instance + */ + WidevinePsshData.create = function create(properties) { + return new WidevinePsshData(properties); + }; + + /** + * Encodes the specified WidevinePsshData message. Does not implicitly {@link license_protocol.WidevinePsshData.verify|verify} messages. + * @function encode + * @memberof license_protocol.WidevinePsshData + * @static + * @param {license_protocol.IWidevinePsshData} message WidevinePsshData message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + WidevinePsshData.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.algorithm != null && Object.hasOwnProperty.call(message, "algorithm")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.algorithm); + if (message.keyIds != null && message.keyIds.length) + for (var i = 0; i < message.keyIds.length; ++i) + writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.keyIds[i]); + if (message.provider != null && Object.hasOwnProperty.call(message, "provider")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.provider); + if (message.contentId != null && Object.hasOwnProperty.call(message, "contentId")) + writer.uint32(/* id 4, wireType 2 =*/34).bytes(message.contentId); + if (message.trackType != null && Object.hasOwnProperty.call(message, "trackType")) + writer.uint32(/* id 5, wireType 2 =*/42).string(message.trackType); + if (message.policy != null && Object.hasOwnProperty.call(message, "policy")) + writer.uint32(/* id 6, wireType 2 =*/50).string(message.policy); + if (message.cryptoPeriodIndex != null && Object.hasOwnProperty.call(message, "cryptoPeriodIndex")) + writer.uint32(/* id 7, wireType 0 =*/56).uint32(message.cryptoPeriodIndex); + if (message.groupedLicense != null && Object.hasOwnProperty.call(message, "groupedLicense")) + writer.uint32(/* id 8, wireType 2 =*/66).bytes(message.groupedLicense); + if (message.protectionScheme != null && Object.hasOwnProperty.call(message, "protectionScheme")) + writer.uint32(/* id 9, wireType 0 =*/72).uint32(message.protectionScheme); + if (message.cryptoPeriodSeconds != null && Object.hasOwnProperty.call(message, "cryptoPeriodSeconds")) + writer.uint32(/* id 10, wireType 0 =*/80).uint32(message.cryptoPeriodSeconds); + if (message.type != null && Object.hasOwnProperty.call(message, "type")) + writer.uint32(/* id 11, wireType 0 =*/88).int32(message.type); + if (message.keySequence != null && Object.hasOwnProperty.call(message, "keySequence")) + writer.uint32(/* id 12, wireType 0 =*/96).uint32(message.keySequence); + if (message.groupIds != null && message.groupIds.length) + for (var i = 0; i < message.groupIds.length; ++i) + writer.uint32(/* id 13, wireType 2 =*/106).bytes(message.groupIds[i]); + if (message.entitledKeys != null && message.entitledKeys.length) + for (var i = 0; i < message.entitledKeys.length; ++i) + $root.license_protocol.WidevinePsshData.EntitledKey.encode(message.entitledKeys[i], writer.uint32(/* id 14, wireType 2 =*/114).fork()).ldelim(); + if (message.videoFeature != null && Object.hasOwnProperty.call(message, "videoFeature")) + writer.uint32(/* id 15, wireType 2 =*/122).string(message.videoFeature); + return writer; + }; + + /** + * Encodes the specified WidevinePsshData message, length delimited. Does not implicitly {@link license_protocol.WidevinePsshData.verify|verify} messages. + * @function encodeDelimited + * @memberof license_protocol.WidevinePsshData + * @static + * @param {license_protocol.IWidevinePsshData} message WidevinePsshData message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + WidevinePsshData.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a WidevinePsshData message from the specified reader or buffer. + * @function decode + * @memberof license_protocol.WidevinePsshData + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {license_protocol.WidevinePsshData} WidevinePsshData + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + WidevinePsshData.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.license_protocol.WidevinePsshData(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 2: { + if (!(message.keyIds && message.keyIds.length)) + message.keyIds = []; + message.keyIds.push(reader.bytes()); + break; + } + case 4: { + message.contentId = reader.bytes(); + break; + } + case 7: { + message.cryptoPeriodIndex = reader.uint32(); + break; + } + case 9: { + message.protectionScheme = reader.uint32(); + break; + } + case 10: { + message.cryptoPeriodSeconds = reader.uint32(); + break; + } + case 11: { + message.type = reader.int32(); + break; + } + case 12: { + message.keySequence = reader.uint32(); + break; + } + case 13: { + if (!(message.groupIds && message.groupIds.length)) + message.groupIds = []; + message.groupIds.push(reader.bytes()); + break; + } + case 14: { + if (!(message.entitledKeys && message.entitledKeys.length)) + message.entitledKeys = []; + message.entitledKeys.push($root.license_protocol.WidevinePsshData.EntitledKey.decode(reader, reader.uint32())); + break; + } + case 15: { + message.videoFeature = reader.string(); + break; + } + case 1: { + message.algorithm = reader.int32(); + break; + } + case 3: { + message.provider = reader.string(); + break; + } + case 5: { + message.trackType = reader.string(); + break; + } + case 6: { + message.policy = reader.string(); + break; + } + case 8: { + message.groupedLicense = reader.bytes(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a WidevinePsshData message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof license_protocol.WidevinePsshData + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {license_protocol.WidevinePsshData} WidevinePsshData + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + WidevinePsshData.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a WidevinePsshData message. + * @function verify + * @memberof license_protocol.WidevinePsshData + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + WidevinePsshData.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.keyIds != null && message.hasOwnProperty("keyIds")) { + if (!Array.isArray(message.keyIds)) + return "keyIds: array expected"; + for (var i = 0; i < message.keyIds.length; ++i) + if (!(message.keyIds[i] && typeof message.keyIds[i].length === "number" || $util.isString(message.keyIds[i]))) + return "keyIds: buffer[] expected"; + } + if (message.contentId != null && message.hasOwnProperty("contentId")) + if (!(message.contentId && typeof message.contentId.length === "number" || $util.isString(message.contentId))) + return "contentId: buffer expected"; + if (message.cryptoPeriodIndex != null && message.hasOwnProperty("cryptoPeriodIndex")) + if (!$util.isInteger(message.cryptoPeriodIndex)) + return "cryptoPeriodIndex: integer expected"; + if (message.protectionScheme != null && message.hasOwnProperty("protectionScheme")) + if (!$util.isInteger(message.protectionScheme)) + return "protectionScheme: integer expected"; + if (message.cryptoPeriodSeconds != null && message.hasOwnProperty("cryptoPeriodSeconds")) + if (!$util.isInteger(message.cryptoPeriodSeconds)) + return "cryptoPeriodSeconds: integer expected"; + if (message.type != null && message.hasOwnProperty("type")) + switch (message.type) { + default: + return "type: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.keySequence != null && message.hasOwnProperty("keySequence")) + if (!$util.isInteger(message.keySequence)) + return "keySequence: integer expected"; + if (message.groupIds != null && message.hasOwnProperty("groupIds")) { + if (!Array.isArray(message.groupIds)) + return "groupIds: array expected"; + for (var i = 0; i < message.groupIds.length; ++i) + if (!(message.groupIds[i] && typeof message.groupIds[i].length === "number" || $util.isString(message.groupIds[i]))) + return "groupIds: buffer[] expected"; + } + if (message.entitledKeys != null && message.hasOwnProperty("entitledKeys")) { + if (!Array.isArray(message.entitledKeys)) + return "entitledKeys: array expected"; + for (var i = 0; i < message.entitledKeys.length; ++i) { + var error = $root.license_protocol.WidevinePsshData.EntitledKey.verify(message.entitledKeys[i]); + if (error) + return "entitledKeys." + error; + } + } + if (message.videoFeature != null && message.hasOwnProperty("videoFeature")) + if (!$util.isString(message.videoFeature)) + return "videoFeature: string expected"; + if (message.algorithm != null && message.hasOwnProperty("algorithm")) + switch (message.algorithm) { + default: + return "algorithm: enum value expected"; + case 0: + case 1: + break; + } + if (message.provider != null && message.hasOwnProperty("provider")) + if (!$util.isString(message.provider)) + return "provider: string expected"; + if (message.trackType != null && message.hasOwnProperty("trackType")) + if (!$util.isString(message.trackType)) + return "trackType: string expected"; + if (message.policy != null && message.hasOwnProperty("policy")) + if (!$util.isString(message.policy)) + return "policy: string expected"; + if (message.groupedLicense != null && message.hasOwnProperty("groupedLicense")) + if (!(message.groupedLicense && typeof message.groupedLicense.length === "number" || $util.isString(message.groupedLicense))) + return "groupedLicense: buffer expected"; + return null; + }; + + /** + * Creates a WidevinePsshData message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof license_protocol.WidevinePsshData + * @static + * @param {Object.} object Plain object + * @returns {license_protocol.WidevinePsshData} WidevinePsshData + */ + WidevinePsshData.fromObject = function fromObject(object) { + if (object instanceof $root.license_protocol.WidevinePsshData) + return object; + var message = new $root.license_protocol.WidevinePsshData(); + if (object.keyIds) { + if (!Array.isArray(object.keyIds)) + throw TypeError(".license_protocol.WidevinePsshData.keyIds: array expected"); + message.keyIds = []; + for (var i = 0; i < object.keyIds.length; ++i) + if (typeof object.keyIds[i] === "string") + $util.base64.decode(object.keyIds[i], message.keyIds[i] = $util.newBuffer($util.base64.length(object.keyIds[i])), 0); + else if (object.keyIds[i].length >= 0) + message.keyIds[i] = object.keyIds[i]; + } + if (object.contentId != null) + if (typeof object.contentId === "string") + $util.base64.decode(object.contentId, message.contentId = $util.newBuffer($util.base64.length(object.contentId)), 0); + else if (object.contentId.length >= 0) + message.contentId = object.contentId; + if (object.cryptoPeriodIndex != null) + message.cryptoPeriodIndex = object.cryptoPeriodIndex >>> 0; + if (object.protectionScheme != null) + message.protectionScheme = object.protectionScheme >>> 0; + if (object.cryptoPeriodSeconds != null) + message.cryptoPeriodSeconds = object.cryptoPeriodSeconds >>> 0; + switch (object.type) { + default: + if (typeof object.type === "number") { + message.type = object.type; + break; + } + break; + case "SINGLE": + case 0: + message.type = 0; + break; + case "ENTITLEMENT": + case 1: + message.type = 1; + break; + case "ENTITLED_KEY": + case 2: + message.type = 2; + break; + } + if (object.keySequence != null) + message.keySequence = object.keySequence >>> 0; + if (object.groupIds) { + if (!Array.isArray(object.groupIds)) + throw TypeError(".license_protocol.WidevinePsshData.groupIds: array expected"); + message.groupIds = []; + for (var i = 0; i < object.groupIds.length; ++i) + if (typeof object.groupIds[i] === "string") + $util.base64.decode(object.groupIds[i], message.groupIds[i] = $util.newBuffer($util.base64.length(object.groupIds[i])), 0); + else if (object.groupIds[i].length >= 0) + message.groupIds[i] = object.groupIds[i]; + } + if (object.entitledKeys) { + if (!Array.isArray(object.entitledKeys)) + throw TypeError(".license_protocol.WidevinePsshData.entitledKeys: array expected"); + message.entitledKeys = []; + for (var i = 0; i < object.entitledKeys.length; ++i) { + if (typeof object.entitledKeys[i] !== "object") + throw TypeError(".license_protocol.WidevinePsshData.entitledKeys: object expected"); + message.entitledKeys[i] = $root.license_protocol.WidevinePsshData.EntitledKey.fromObject(object.entitledKeys[i]); + } + } + if (object.videoFeature != null) + message.videoFeature = String(object.videoFeature); + switch (object.algorithm) { + default: + if (typeof object.algorithm === "number") { + message.algorithm = object.algorithm; + break; + } + break; + case "UNENCRYPTED": + case 0: + message.algorithm = 0; + break; + case "AESCTR": + case 1: + message.algorithm = 1; + break; + } + if (object.provider != null) + message.provider = String(object.provider); + if (object.trackType != null) + message.trackType = String(object.trackType); + if (object.policy != null) + message.policy = String(object.policy); + if (object.groupedLicense != null) + if (typeof object.groupedLicense === "string") + $util.base64.decode(object.groupedLicense, message.groupedLicense = $util.newBuffer($util.base64.length(object.groupedLicense)), 0); + else if (object.groupedLicense.length >= 0) + message.groupedLicense = object.groupedLicense; + return message; + }; + + /** + * Creates a plain object from a WidevinePsshData message. Also converts values to other types if specified. + * @function toObject + * @memberof license_protocol.WidevinePsshData + * @static + * @param {license_protocol.WidevinePsshData} message WidevinePsshData + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + WidevinePsshData.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.keyIds = []; + object.groupIds = []; + object.entitledKeys = []; + } + if (options.defaults) { + object.algorithm = options.enums === String ? "UNENCRYPTED" : 0; + object.provider = ""; + if (options.bytes === String) + object.contentId = ""; + else { + object.contentId = []; + if (options.bytes !== Array) + object.contentId = $util.newBuffer(object.contentId); + } + object.trackType = ""; + object.policy = ""; + object.cryptoPeriodIndex = 0; + if (options.bytes === String) + object.groupedLicense = ""; + else { + object.groupedLicense = []; + if (options.bytes !== Array) + object.groupedLicense = $util.newBuffer(object.groupedLicense); + } + object.protectionScheme = 0; + object.cryptoPeriodSeconds = 0; + object.type = options.enums === String ? "SINGLE" : 0; + object.keySequence = 0; + object.videoFeature = ""; + } + if (message.algorithm != null && message.hasOwnProperty("algorithm")) + object.algorithm = options.enums === String ? $root.license_protocol.WidevinePsshData.Algorithm[message.algorithm] === undefined ? message.algorithm : $root.license_protocol.WidevinePsshData.Algorithm[message.algorithm] : message.algorithm; + if (message.keyIds && message.keyIds.length) { + object.keyIds = []; + for (var j = 0; j < message.keyIds.length; ++j) + object.keyIds[j] = options.bytes === String ? $util.base64.encode(message.keyIds[j], 0, message.keyIds[j].length) : options.bytes === Array ? Array.prototype.slice.call(message.keyIds[j]) : message.keyIds[j]; + } + if (message.provider != null && message.hasOwnProperty("provider")) + object.provider = message.provider; + if (message.contentId != null && message.hasOwnProperty("contentId")) + object.contentId = options.bytes === String ? $util.base64.encode(message.contentId, 0, message.contentId.length) : options.bytes === Array ? Array.prototype.slice.call(message.contentId) : message.contentId; + if (message.trackType != null && message.hasOwnProperty("trackType")) + object.trackType = message.trackType; + if (message.policy != null && message.hasOwnProperty("policy")) + object.policy = message.policy; + if (message.cryptoPeriodIndex != null && message.hasOwnProperty("cryptoPeriodIndex")) + object.cryptoPeriodIndex = message.cryptoPeriodIndex; + if (message.groupedLicense != null && message.hasOwnProperty("groupedLicense")) + object.groupedLicense = options.bytes === String ? $util.base64.encode(message.groupedLicense, 0, message.groupedLicense.length) : options.bytes === Array ? Array.prototype.slice.call(message.groupedLicense) : message.groupedLicense; + if (message.protectionScheme != null && message.hasOwnProperty("protectionScheme")) + object.protectionScheme = message.protectionScheme; + if (message.cryptoPeriodSeconds != null && message.hasOwnProperty("cryptoPeriodSeconds")) + object.cryptoPeriodSeconds = message.cryptoPeriodSeconds; + if (message.type != null && message.hasOwnProperty("type")) + object.type = options.enums === String ? $root.license_protocol.WidevinePsshData.Type[message.type] === undefined ? message.type : $root.license_protocol.WidevinePsshData.Type[message.type] : message.type; + if (message.keySequence != null && message.hasOwnProperty("keySequence")) + object.keySequence = message.keySequence; + if (message.groupIds && message.groupIds.length) { + object.groupIds = []; + for (var j = 0; j < message.groupIds.length; ++j) + object.groupIds[j] = options.bytes === String ? $util.base64.encode(message.groupIds[j], 0, message.groupIds[j].length) : options.bytes === Array ? Array.prototype.slice.call(message.groupIds[j]) : message.groupIds[j]; + } + if (message.entitledKeys && message.entitledKeys.length) { + object.entitledKeys = []; + for (var j = 0; j < message.entitledKeys.length; ++j) + object.entitledKeys[j] = $root.license_protocol.WidevinePsshData.EntitledKey.toObject(message.entitledKeys[j], options); + } + if (message.videoFeature != null && message.hasOwnProperty("videoFeature")) + object.videoFeature = message.videoFeature; + return object; + }; + + /** + * Converts this WidevinePsshData to JSON. + * @function toJSON + * @memberof license_protocol.WidevinePsshData + * @instance + * @returns {Object.} JSON object + */ + WidevinePsshData.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for WidevinePsshData + * @function getTypeUrl + * @memberof license_protocol.WidevinePsshData + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + WidevinePsshData.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/license_protocol.WidevinePsshData"; + }; + + /** + * Type enum. + * @name license_protocol.WidevinePsshData.Type + * @enum {number} + * @property {number} SINGLE=0 SINGLE value + * @property {number} ENTITLEMENT=1 ENTITLEMENT value + * @property {number} ENTITLED_KEY=2 ENTITLED_KEY value + */ + WidevinePsshData.Type = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "SINGLE"] = 0; + values[valuesById[1] = "ENTITLEMENT"] = 1; + values[valuesById[2] = "ENTITLED_KEY"] = 2; + return values; + })(); + + WidevinePsshData.EntitledKey = (function() { + + /** + * Properties of an EntitledKey. + * @memberof license_protocol.WidevinePsshData + * @interface IEntitledKey + * @property {Uint8Array|null} [entitlementKeyId] EntitledKey entitlementKeyId + * @property {Uint8Array|null} [keyId] EntitledKey keyId + * @property {Uint8Array|null} [key] EntitledKey key + * @property {Uint8Array|null} [iv] EntitledKey iv + * @property {number|null} [entitlementKeySizeBytes] EntitledKey entitlementKeySizeBytes + */ + + /** + * Constructs a new EntitledKey. + * @memberof license_protocol.WidevinePsshData + * @classdesc Represents an EntitledKey. + * @implements IEntitledKey + * @constructor + * @param {license_protocol.WidevinePsshData.IEntitledKey=} [properties] Properties to set + */ + function EntitledKey(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * EntitledKey entitlementKeyId. + * @member {Uint8Array} entitlementKeyId + * @memberof license_protocol.WidevinePsshData.EntitledKey + * @instance + */ + EntitledKey.prototype.entitlementKeyId = $util.newBuffer([]); + + /** + * EntitledKey keyId. + * @member {Uint8Array} keyId + * @memberof license_protocol.WidevinePsshData.EntitledKey + * @instance + */ + EntitledKey.prototype.keyId = $util.newBuffer([]); + + /** + * EntitledKey key. + * @member {Uint8Array} key + * @memberof license_protocol.WidevinePsshData.EntitledKey + * @instance + */ + EntitledKey.prototype.key = $util.newBuffer([]); + + /** + * EntitledKey iv. + * @member {Uint8Array} iv + * @memberof license_protocol.WidevinePsshData.EntitledKey + * @instance + */ + EntitledKey.prototype.iv = $util.newBuffer([]); + + /** + * EntitledKey entitlementKeySizeBytes. + * @member {number} entitlementKeySizeBytes + * @memberof license_protocol.WidevinePsshData.EntitledKey + * @instance + */ + EntitledKey.prototype.entitlementKeySizeBytes = 32; + + /** + * Creates a new EntitledKey instance using the specified properties. + * @function create + * @memberof license_protocol.WidevinePsshData.EntitledKey + * @static + * @param {license_protocol.WidevinePsshData.IEntitledKey=} [properties] Properties to set + * @returns {license_protocol.WidevinePsshData.EntitledKey} EntitledKey instance + */ + EntitledKey.create = function create(properties) { + return new EntitledKey(properties); + }; + + /** + * Encodes the specified EntitledKey message. Does not implicitly {@link license_protocol.WidevinePsshData.EntitledKey.verify|verify} messages. + * @function encode + * @memberof license_protocol.WidevinePsshData.EntitledKey + * @static + * @param {license_protocol.WidevinePsshData.IEntitledKey} message EntitledKey message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EntitledKey.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.entitlementKeyId != null && Object.hasOwnProperty.call(message, "entitlementKeyId")) + writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.entitlementKeyId); + if (message.keyId != null && Object.hasOwnProperty.call(message, "keyId")) + writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.keyId); + if (message.key != null && Object.hasOwnProperty.call(message, "key")) + writer.uint32(/* id 3, wireType 2 =*/26).bytes(message.key); + if (message.iv != null && Object.hasOwnProperty.call(message, "iv")) + writer.uint32(/* id 4, wireType 2 =*/34).bytes(message.iv); + if (message.entitlementKeySizeBytes != null && Object.hasOwnProperty.call(message, "entitlementKeySizeBytes")) + writer.uint32(/* id 5, wireType 0 =*/40).uint32(message.entitlementKeySizeBytes); + return writer; + }; + + /** + * Encodes the specified EntitledKey message, length delimited. Does not implicitly {@link license_protocol.WidevinePsshData.EntitledKey.verify|verify} messages. + * @function encodeDelimited + * @memberof license_protocol.WidevinePsshData.EntitledKey + * @static + * @param {license_protocol.WidevinePsshData.IEntitledKey} message EntitledKey message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EntitledKey.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an EntitledKey message from the specified reader or buffer. + * @function decode + * @memberof license_protocol.WidevinePsshData.EntitledKey + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {license_protocol.WidevinePsshData.EntitledKey} EntitledKey + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EntitledKey.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.license_protocol.WidevinePsshData.EntitledKey(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.entitlementKeyId = reader.bytes(); + break; + } + case 2: { + message.keyId = reader.bytes(); + break; + } + case 3: { + message.key = reader.bytes(); + break; + } + case 4: { + message.iv = reader.bytes(); + break; + } + case 5: { + message.entitlementKeySizeBytes = reader.uint32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an EntitledKey message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof license_protocol.WidevinePsshData.EntitledKey + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {license_protocol.WidevinePsshData.EntitledKey} EntitledKey + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EntitledKey.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an EntitledKey message. + * @function verify + * @memberof license_protocol.WidevinePsshData.EntitledKey + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + EntitledKey.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.entitlementKeyId != null && message.hasOwnProperty("entitlementKeyId")) + if (!(message.entitlementKeyId && typeof message.entitlementKeyId.length === "number" || $util.isString(message.entitlementKeyId))) + return "entitlementKeyId: buffer expected"; + if (message.keyId != null && message.hasOwnProperty("keyId")) + if (!(message.keyId && typeof message.keyId.length === "number" || $util.isString(message.keyId))) + return "keyId: buffer expected"; + if (message.key != null && message.hasOwnProperty("key")) + if (!(message.key && typeof message.key.length === "number" || $util.isString(message.key))) + return "key: buffer expected"; + if (message.iv != null && message.hasOwnProperty("iv")) + if (!(message.iv && typeof message.iv.length === "number" || $util.isString(message.iv))) + return "iv: buffer expected"; + if (message.entitlementKeySizeBytes != null && message.hasOwnProperty("entitlementKeySizeBytes")) + if (!$util.isInteger(message.entitlementKeySizeBytes)) + return "entitlementKeySizeBytes: integer expected"; + return null; + }; + + /** + * Creates an EntitledKey message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof license_protocol.WidevinePsshData.EntitledKey + * @static + * @param {Object.} object Plain object + * @returns {license_protocol.WidevinePsshData.EntitledKey} EntitledKey + */ + EntitledKey.fromObject = function fromObject(object) { + if (object instanceof $root.license_protocol.WidevinePsshData.EntitledKey) + return object; + var message = new $root.license_protocol.WidevinePsshData.EntitledKey(); + if (object.entitlementKeyId != null) + if (typeof object.entitlementKeyId === "string") + $util.base64.decode(object.entitlementKeyId, message.entitlementKeyId = $util.newBuffer($util.base64.length(object.entitlementKeyId)), 0); + else if (object.entitlementKeyId.length >= 0) + message.entitlementKeyId = object.entitlementKeyId; + if (object.keyId != null) + if (typeof object.keyId === "string") + $util.base64.decode(object.keyId, message.keyId = $util.newBuffer($util.base64.length(object.keyId)), 0); + else if (object.keyId.length >= 0) + message.keyId = object.keyId; + if (object.key != null) + if (typeof object.key === "string") + $util.base64.decode(object.key, message.key = $util.newBuffer($util.base64.length(object.key)), 0); + else if (object.key.length >= 0) + message.key = object.key; + if (object.iv != null) + if (typeof object.iv === "string") + $util.base64.decode(object.iv, message.iv = $util.newBuffer($util.base64.length(object.iv)), 0); + else if (object.iv.length >= 0) + message.iv = object.iv; + if (object.entitlementKeySizeBytes != null) + message.entitlementKeySizeBytes = object.entitlementKeySizeBytes >>> 0; + return message; + }; + + /** + * Creates a plain object from an EntitledKey message. Also converts values to other types if specified. + * @function toObject + * @memberof license_protocol.WidevinePsshData.EntitledKey + * @static + * @param {license_protocol.WidevinePsshData.EntitledKey} message EntitledKey + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + EntitledKey.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + if (options.bytes === String) + object.entitlementKeyId = ""; + else { + object.entitlementKeyId = []; + if (options.bytes !== Array) + object.entitlementKeyId = $util.newBuffer(object.entitlementKeyId); + } + if (options.bytes === String) + object.keyId = ""; + else { + object.keyId = []; + if (options.bytes !== Array) + object.keyId = $util.newBuffer(object.keyId); + } + if (options.bytes === String) + object.key = ""; + else { + object.key = []; + if (options.bytes !== Array) + object.key = $util.newBuffer(object.key); + } + if (options.bytes === String) + object.iv = ""; + else { + object.iv = []; + if (options.bytes !== Array) + object.iv = $util.newBuffer(object.iv); + } + object.entitlementKeySizeBytes = 32; + } + if (message.entitlementKeyId != null && message.hasOwnProperty("entitlementKeyId")) + object.entitlementKeyId = options.bytes === String ? $util.base64.encode(message.entitlementKeyId, 0, message.entitlementKeyId.length) : options.bytes === Array ? Array.prototype.slice.call(message.entitlementKeyId) : message.entitlementKeyId; + if (message.keyId != null && message.hasOwnProperty("keyId")) + object.keyId = options.bytes === String ? $util.base64.encode(message.keyId, 0, message.keyId.length) : options.bytes === Array ? Array.prototype.slice.call(message.keyId) : message.keyId; + if (message.key != null && message.hasOwnProperty("key")) + object.key = options.bytes === String ? $util.base64.encode(message.key, 0, message.key.length) : options.bytes === Array ? Array.prototype.slice.call(message.key) : message.key; + if (message.iv != null && message.hasOwnProperty("iv")) + object.iv = options.bytes === String ? $util.base64.encode(message.iv, 0, message.iv.length) : options.bytes === Array ? Array.prototype.slice.call(message.iv) : message.iv; + if (message.entitlementKeySizeBytes != null && message.hasOwnProperty("entitlementKeySizeBytes")) + object.entitlementKeySizeBytes = message.entitlementKeySizeBytes; + return object; + }; + + /** + * Converts this EntitledKey to JSON. + * @function toJSON + * @memberof license_protocol.WidevinePsshData.EntitledKey + * @instance + * @returns {Object.} JSON object + */ + EntitledKey.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for EntitledKey + * @function getTypeUrl + * @memberof license_protocol.WidevinePsshData.EntitledKey + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + EntitledKey.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/license_protocol.WidevinePsshData.EntitledKey"; + }; + + return EntitledKey; + })(); + + /** + * Deprecated Fields //////////////////////////// + * @name license_protocol.WidevinePsshData.Algorithm + * @enum {number} + * @property {number} UNENCRYPTED=0 UNENCRYPTED value + * @property {number} AESCTR=1 AESCTR value + */ + WidevinePsshData.Algorithm = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "UNENCRYPTED"] = 0; + values[valuesById[1] = "AESCTR"] = 1; + return values; + })(); + + return WidevinePsshData; + })(); + + license_protocol.FileHashes = (function() { + + /** + * Properties of a FileHashes. + * @memberof license_protocol + * @interface IFileHashes + * @property {Uint8Array|null} [signer] FileHashes signer + * @property {Array.|null} [signatures] FileHashes signatures + */ + + /** + * Constructs a new FileHashes. + * @memberof license_protocol + * @classdesc Represents a FileHashes. + * @implements IFileHashes + * @constructor + * @param {license_protocol.IFileHashes=} [properties] Properties to set + */ + function FileHashes(properties) { + this.signatures = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * FileHashes signer. + * @member {Uint8Array} signer + * @memberof license_protocol.FileHashes + * @instance + */ + FileHashes.prototype.signer = $util.newBuffer([]); + + /** + * FileHashes signatures. + * @member {Array.} signatures + * @memberof license_protocol.FileHashes + * @instance + */ + FileHashes.prototype.signatures = $util.emptyArray; + + /** + * Creates a new FileHashes instance using the specified properties. + * @function create + * @memberof license_protocol.FileHashes + * @static + * @param {license_protocol.IFileHashes=} [properties] Properties to set + * @returns {license_protocol.FileHashes} FileHashes instance + */ + FileHashes.create = function create(properties) { + return new FileHashes(properties); + }; + + /** + * Encodes the specified FileHashes message. Does not implicitly {@link license_protocol.FileHashes.verify|verify} messages. + * @function encode + * @memberof license_protocol.FileHashes + * @static + * @param {license_protocol.IFileHashes} message FileHashes message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FileHashes.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.signer != null && Object.hasOwnProperty.call(message, "signer")) + writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.signer); + if (message.signatures != null && message.signatures.length) + for (var i = 0; i < message.signatures.length; ++i) + $root.license_protocol.FileHashes.Signature.encode(message.signatures[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified FileHashes message, length delimited. Does not implicitly {@link license_protocol.FileHashes.verify|verify} messages. + * @function encodeDelimited + * @memberof license_protocol.FileHashes + * @static + * @param {license_protocol.IFileHashes} message FileHashes message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FileHashes.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a FileHashes message from the specified reader or buffer. + * @function decode + * @memberof license_protocol.FileHashes + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {license_protocol.FileHashes} FileHashes + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FileHashes.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.license_protocol.FileHashes(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.signer = reader.bytes(); + break; + } + case 2: { + if (!(message.signatures && message.signatures.length)) + message.signatures = []; + message.signatures.push($root.license_protocol.FileHashes.Signature.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a FileHashes message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof license_protocol.FileHashes + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {license_protocol.FileHashes} FileHashes + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FileHashes.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a FileHashes message. + * @function verify + * @memberof license_protocol.FileHashes + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FileHashes.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.signer != null && message.hasOwnProperty("signer")) + if (!(message.signer && typeof message.signer.length === "number" || $util.isString(message.signer))) + return "signer: buffer expected"; + if (message.signatures != null && message.hasOwnProperty("signatures")) { + if (!Array.isArray(message.signatures)) + return "signatures: array expected"; + for (var i = 0; i < message.signatures.length; ++i) { + var error = $root.license_protocol.FileHashes.Signature.verify(message.signatures[i]); + if (error) + return "signatures." + error; + } + } + return null; + }; + + /** + * Creates a FileHashes message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof license_protocol.FileHashes + * @static + * @param {Object.} object Plain object + * @returns {license_protocol.FileHashes} FileHashes + */ + FileHashes.fromObject = function fromObject(object) { + if (object instanceof $root.license_protocol.FileHashes) + return object; + var message = new $root.license_protocol.FileHashes(); + if (object.signer != null) + if (typeof object.signer === "string") + $util.base64.decode(object.signer, message.signer = $util.newBuffer($util.base64.length(object.signer)), 0); + else if (object.signer.length >= 0) + message.signer = object.signer; + if (object.signatures) { + if (!Array.isArray(object.signatures)) + throw TypeError(".license_protocol.FileHashes.signatures: array expected"); + message.signatures = []; + for (var i = 0; i < object.signatures.length; ++i) { + if (typeof object.signatures[i] !== "object") + throw TypeError(".license_protocol.FileHashes.signatures: object expected"); + message.signatures[i] = $root.license_protocol.FileHashes.Signature.fromObject(object.signatures[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a FileHashes message. Also converts values to other types if specified. + * @function toObject + * @memberof license_protocol.FileHashes + * @static + * @param {license_protocol.FileHashes} message FileHashes + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FileHashes.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.signatures = []; + if (options.defaults) + if (options.bytes === String) + object.signer = ""; + else { + object.signer = []; + if (options.bytes !== Array) + object.signer = $util.newBuffer(object.signer); + } + if (message.signer != null && message.hasOwnProperty("signer")) + object.signer = options.bytes === String ? $util.base64.encode(message.signer, 0, message.signer.length) : options.bytes === Array ? Array.prototype.slice.call(message.signer) : message.signer; + if (message.signatures && message.signatures.length) { + object.signatures = []; + for (var j = 0; j < message.signatures.length; ++j) + object.signatures[j] = $root.license_protocol.FileHashes.Signature.toObject(message.signatures[j], options); + } + return object; + }; + + /** + * Converts this FileHashes to JSON. + * @function toJSON + * @memberof license_protocol.FileHashes + * @instance + * @returns {Object.} JSON object + */ + FileHashes.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for FileHashes + * @function getTypeUrl + * @memberof license_protocol.FileHashes + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + FileHashes.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/license_protocol.FileHashes"; + }; + + FileHashes.Signature = (function() { + + /** + * Properties of a Signature. + * @memberof license_protocol.FileHashes + * @interface ISignature + * @property {string|null} [filename] Signature filename + * @property {boolean|null} [testSigning] Signature testSigning + * @property {Uint8Array|null} [SHA512Hash] Signature SHA512Hash + * @property {boolean|null} [mainExe] Signature mainExe + * @property {Uint8Array|null} [signature] Signature signature + */ + + /** + * Constructs a new Signature. + * @memberof license_protocol.FileHashes + * @classdesc Represents a Signature. + * @implements ISignature + * @constructor + * @param {license_protocol.FileHashes.ISignature=} [properties] Properties to set + */ + function Signature(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Signature filename. + * @member {string} filename + * @memberof license_protocol.FileHashes.Signature + * @instance + */ + Signature.prototype.filename = ""; + + /** + * Signature testSigning. + * @member {boolean} testSigning + * @memberof license_protocol.FileHashes.Signature + * @instance + */ + Signature.prototype.testSigning = false; + + /** + * Signature SHA512Hash. + * @member {Uint8Array} SHA512Hash + * @memberof license_protocol.FileHashes.Signature + * @instance + */ + Signature.prototype.SHA512Hash = $util.newBuffer([]); + + /** + * Signature mainExe. + * @member {boolean} mainExe + * @memberof license_protocol.FileHashes.Signature + * @instance + */ + Signature.prototype.mainExe = false; + + /** + * Signature signature. + * @member {Uint8Array} signature + * @memberof license_protocol.FileHashes.Signature + * @instance + */ + Signature.prototype.signature = $util.newBuffer([]); + + /** + * Creates a new Signature instance using the specified properties. + * @function create + * @memberof license_protocol.FileHashes.Signature + * @static + * @param {license_protocol.FileHashes.ISignature=} [properties] Properties to set + * @returns {license_protocol.FileHashes.Signature} Signature instance + */ + Signature.create = function create(properties) { + return new Signature(properties); + }; + + /** + * Encodes the specified Signature message. Does not implicitly {@link license_protocol.FileHashes.Signature.verify|verify} messages. + * @function encode + * @memberof license_protocol.FileHashes.Signature + * @static + * @param {license_protocol.FileHashes.ISignature} message Signature message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Signature.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.filename != null && Object.hasOwnProperty.call(message, "filename")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.filename); + if (message.testSigning != null && Object.hasOwnProperty.call(message, "testSigning")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.testSigning); + if (message.SHA512Hash != null && Object.hasOwnProperty.call(message, "SHA512Hash")) + writer.uint32(/* id 3, wireType 2 =*/26).bytes(message.SHA512Hash); + if (message.mainExe != null && Object.hasOwnProperty.call(message, "mainExe")) + writer.uint32(/* id 4, wireType 0 =*/32).bool(message.mainExe); + if (message.signature != null && Object.hasOwnProperty.call(message, "signature")) + writer.uint32(/* id 5, wireType 2 =*/42).bytes(message.signature); + return writer; + }; + + /** + * Encodes the specified Signature message, length delimited. Does not implicitly {@link license_protocol.FileHashes.Signature.verify|verify} messages. + * @function encodeDelimited + * @memberof license_protocol.FileHashes.Signature + * @static + * @param {license_protocol.FileHashes.ISignature} message Signature message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Signature.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Signature message from the specified reader or buffer. + * @function decode + * @memberof license_protocol.FileHashes.Signature + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {license_protocol.FileHashes.Signature} Signature + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Signature.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.license_protocol.FileHashes.Signature(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.filename = reader.string(); + break; + } + case 2: { + message.testSigning = reader.bool(); + break; + } + case 3: { + message.SHA512Hash = reader.bytes(); + break; + } + case 4: { + message.mainExe = reader.bool(); + break; + } + case 5: { + message.signature = reader.bytes(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Signature message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof license_protocol.FileHashes.Signature + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {license_protocol.FileHashes.Signature} Signature + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Signature.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Signature message. + * @function verify + * @memberof license_protocol.FileHashes.Signature + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Signature.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.filename != null && message.hasOwnProperty("filename")) + if (!$util.isString(message.filename)) + return "filename: string expected"; + if (message.testSigning != null && message.hasOwnProperty("testSigning")) + if (typeof message.testSigning !== "boolean") + return "testSigning: boolean expected"; + if (message.SHA512Hash != null && message.hasOwnProperty("SHA512Hash")) + if (!(message.SHA512Hash && typeof message.SHA512Hash.length === "number" || $util.isString(message.SHA512Hash))) + return "SHA512Hash: buffer expected"; + if (message.mainExe != null && message.hasOwnProperty("mainExe")) + if (typeof message.mainExe !== "boolean") + return "mainExe: boolean expected"; + if (message.signature != null && message.hasOwnProperty("signature")) + if (!(message.signature && typeof message.signature.length === "number" || $util.isString(message.signature))) + return "signature: buffer expected"; + return null; + }; + + /** + * Creates a Signature message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof license_protocol.FileHashes.Signature + * @static + * @param {Object.} object Plain object + * @returns {license_protocol.FileHashes.Signature} Signature + */ + Signature.fromObject = function fromObject(object) { + if (object instanceof $root.license_protocol.FileHashes.Signature) + return object; + var message = new $root.license_protocol.FileHashes.Signature(); + if (object.filename != null) + message.filename = String(object.filename); + if (object.testSigning != null) + message.testSigning = Boolean(object.testSigning); + if (object.SHA512Hash != null) + if (typeof object.SHA512Hash === "string") + $util.base64.decode(object.SHA512Hash, message.SHA512Hash = $util.newBuffer($util.base64.length(object.SHA512Hash)), 0); + else if (object.SHA512Hash.length >= 0) + message.SHA512Hash = object.SHA512Hash; + if (object.mainExe != null) + message.mainExe = Boolean(object.mainExe); + if (object.signature != null) + if (typeof object.signature === "string") + $util.base64.decode(object.signature, message.signature = $util.newBuffer($util.base64.length(object.signature)), 0); + else if (object.signature.length >= 0) + message.signature = object.signature; + return message; + }; + + /** + * Creates a plain object from a Signature message. Also converts values to other types if specified. + * @function toObject + * @memberof license_protocol.FileHashes.Signature + * @static + * @param {license_protocol.FileHashes.Signature} message Signature + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Signature.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.filename = ""; + object.testSigning = false; + if (options.bytes === String) + object.SHA512Hash = ""; + else { + object.SHA512Hash = []; + if (options.bytes !== Array) + object.SHA512Hash = $util.newBuffer(object.SHA512Hash); + } + object.mainExe = false; + if (options.bytes === String) + object.signature = ""; + else { + object.signature = []; + if (options.bytes !== Array) + object.signature = $util.newBuffer(object.signature); + } + } + if (message.filename != null && message.hasOwnProperty("filename")) + object.filename = message.filename; + if (message.testSigning != null && message.hasOwnProperty("testSigning")) + object.testSigning = message.testSigning; + if (message.SHA512Hash != null && message.hasOwnProperty("SHA512Hash")) + object.SHA512Hash = options.bytes === String ? $util.base64.encode(message.SHA512Hash, 0, message.SHA512Hash.length) : options.bytes === Array ? Array.prototype.slice.call(message.SHA512Hash) : message.SHA512Hash; + if (message.mainExe != null && message.hasOwnProperty("mainExe")) + object.mainExe = message.mainExe; + if (message.signature != null && message.hasOwnProperty("signature")) + object.signature = options.bytes === String ? $util.base64.encode(message.signature, 0, message.signature.length) : options.bytes === Array ? Array.prototype.slice.call(message.signature) : message.signature; + return object; + }; + + /** + * Converts this Signature to JSON. + * @function toJSON + * @memberof license_protocol.FileHashes.Signature + * @instance + * @returns {Object.} JSON object + */ + Signature.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Signature + * @function getTypeUrl + * @memberof license_protocol.FileHashes.Signature + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Signature.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/license_protocol.FileHashes.Signature"; + }; + + return Signature; + })(); + + return FileHashes; + })(); + + return license_protocol; + })(); + + return $root; +})(protobuf); diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..8305d96 --- /dev/null +++ b/manifest.json @@ -0,0 +1,50 @@ +{ + "manifest_version": 3, + "name": "WidevineProxy2", + "version": "0.2", + "permissions": [ + "activeTab", + "tabs", + "storage", + "unlimitedStorage" + ], + "host_permissions": [ + "*://*/*" + ], + "action": { + "default_popup": "panel/panel.html", + "default_icon": { + "128": "images/icon-128.png" + } + }, + "icons": { + "128": "images/icon-128.png" + }, + "background": { + "scripts": ["background.js"], + "service_worker": "background.js", + "type": "module" + }, + "content_scripts": [ + { + "matches": [""], + "js": ["message_proxy.js"], + "run_at": "document_start", + "world": "ISOLATED", + "all_frames": true + }, + { + "matches": [""], + "js": ["content_script.js"], + "run_at": "document_start", + "world": "MAIN", + "all_frames": true + } + ], + "browser_specific_settings": { + "gecko": { + "id": "DevLARLEY@larley.dev", + "strict_min_version": "58.0" + } + } +} diff --git a/message_proxy.js b/message_proxy.js new file mode 100644 index 0000000..699bb5f --- /dev/null +++ b/message_proxy.js @@ -0,0 +1,22 @@ +async function processMessage(detail) { + return new Promise((resolve, reject) => { + chrome.runtime.sendMessage({ + type: detail.type, + body: detail.body, + }, (response) => { + if (chrome.runtime.lastError) { + return reject(chrome.runtime.lastError); + } + resolve(response); + }); + }) +} + +document.addEventListener('response', async (event) => { + const { detail } = event; + const responseData = await processMessage(detail); + const responseEvent = new CustomEvent('responseReceived', { + detail: detail.requestId.concat(responseData) + }); + document.dispatchEvent(responseEvent); +}); diff --git a/panel/panel.css b/panel/panel.css new file mode 100644 index 0000000..3f150ba --- /dev/null +++ b/panel/panel.css @@ -0,0 +1,53 @@ +.header { + display: flex; + justify-content: center; + align-items: center; +} + +.header > * { + margin: 5px; +} + +#wvd > * { + margin: 5px; +} + +.log-container { + display: flex; + justify-content: center; +} + +.right-bound { + text-align: right; +} + +.text-box { + width: 80%; +} + +.expandableDiv { + width: 100%; + overflow: hidden; + background-color: lightblue; + padding: 0; +} + +.expandableDiv.expanded { + padding: 5px; +} + +.expandableDiv.collapsed { + padding: 0; +} + +.always-visible { + display: block; +} + +.expanded-only { + display: none; +} + +.expandableDiv.expanded .expanded-only { + display: block; +} \ No newline at end of file diff --git a/panel/panel.html b/panel/panel.html new file mode 100644 index 0000000..4b2b3ba --- /dev/null +++ b/panel/panel.html @@ -0,0 +1,33 @@ + + + + + + + + +
+ WidevineProxy Icon + ProxyText +
+
+ Settings + +
+
+ Widevine Device +
+
+ + +
+
+
+ Keys + +
+
+ + diff --git a/panel/panel.js b/panel/panel.js new file mode 100644 index 0000000..048cf05 --- /dev/null +++ b/panel/panel.js @@ -0,0 +1,114 @@ +import "../protobuf.min.js"; +import "../license_protocol.js"; +import { base64toUint8Array, DeviceManager, SettingsManager } from "../util.js"; + +const key_container = document.getElementById('key-container'); + +const enabled = document.getElementById('enabled'); +enabled.addEventListener('change', async function (){ + await SettingsManager.setEnabled(enabled.checked); +}); + +const wvd_combobox = document.getElementById('wvd-combobox'); +wvd_combobox.addEventListener('change', async function() { + await DeviceManager.saveSelectedWidevineDevice(wvd_combobox.options[wvd_combobox.selectedIndex].text); +}); + +const remove = document.getElementById('remove'); +remove.addEventListener('click', async function() { + await DeviceManager.removeSelectedWidevineDevice(); + wvd_combobox.innerHTML = ''; + await DeviceManager.loadSetAllWidevineDevices(); + const selected_option = wvd_combobox.options[wvd_combobox.selectedIndex]; + if (selected_option) { + await DeviceManager.saveSelectedWidevineDevice(selected_option.text); + } +}); + +const download = document.getElementById('download'); +download.addEventListener('click', async function() { + const widevine_device = await DeviceManager.getSelectedWidevineDevice(); + SettingsManager.downloadFile( + base64toUint8Array(await DeviceManager.loadWidevineDevice(widevine_device)), + widevine_device + ".wvd" + ) +}); + +const clear = document.getElementById('clear'); +clear.addEventListener('click', async function() { + chrome.runtime.sendMessage({ type: "CLEAR" }); + key_container.innerHTML = ""; +}); + +document.getElementById('fileInput').addEventListener('click', () => { + chrome.runtime.sendMessage({ type: "OPEN_PICKER" }); + window.close(); +}); + +function appendLog(result) { + const key_string = result.keys.map(key => `--key ${key.kid}:${key.k}`).join(' '); + const date = new Date(result.timestamp * 1000); + const date_string = date.toLocaleString(); + + key_container.innerHTML += ` +
+ + +
` +} + +function applyListeners() { + const toggleButtons = document.querySelectorAll('.toggleButton'); + toggleButtons.forEach(button => { + button.addEventListener('click', function () { + const expandableDiv = this.nextElementSibling; + if (expandableDiv.classList.contains('collapsed')) { + expandableDiv.classList.remove('collapsed'); + expandableDiv.classList.add('expanded'); + } else { + expandableDiv.classList.remove('expanded'); + expandableDiv.classList.add('collapsed'); + } + }); + }); +} + +chrome.storage.onChanged.addListener((changes, areaName) => { + if (areaName === 'local') { + for (const [key, values] of Object.entries(changes)) { + appendLog(values.newValue); + applyListeners(); + } + } +}); + +function checkLogs() { + chrome.runtime.sendMessage({ type: "GET_LOGS" }, function(response) { + if (response) { + response.forEach((result) => { + appendLog(result); + }); + applyListeners(); + } + }); +} + +document.addEventListener('DOMContentLoaded', async function () { + enabled.checked = await SettingsManager.getEnabled(); + await DeviceManager.loadSetAllWidevineDevices(); + await DeviceManager.selectWidevineDevice(await DeviceManager.getSelectedWidevineDevice()); + checkLogs(); +}); diff --git a/picker/filePicker.html b/picker/filePicker.html new file mode 100644 index 0000000..e78cbe8 --- /dev/null +++ b/picker/filePicker.html @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/picker/filePicker.js b/picker/filePicker.js new file mode 100644 index 0000000..e5a9a77 --- /dev/null +++ b/picker/filePicker.js @@ -0,0 +1,10 @@ +import "../protobuf.min.js"; +import "../license_protocol.js"; +import { SettingsManager } from "../util.js"; + +document.getElementById('fileInput').addEventListener('change', async (event) => { + const file = event.target.files[0]; + await SettingsManager.importDevice(file).then(() => { + window.close(); + }); +}); \ No newline at end of file diff --git a/protobuf.min.js b/protobuf.min.js new file mode 100644 index 0000000..2708fe2 --- /dev/null +++ b/protobuf.min.js @@ -0,0 +1,8 @@ +/*! + * protobuf.js v7.4.0 (c) 2016, daniel wirtz + * compiled thu, 22 aug 2024 20:30:39 utc + * licensed under the bsd-3-clause license + * see: https://github.com/dcodeio/protobuf.js for details + */ +!function(d){"use strict";!function(r,u,t){var n=function t(n){var i=u[n];return i||r[n][0].call(i=u[n]={exports:{}},t,i,i.exports),i.exports}(t[0]);n.util.global.protobuf=n,"function"==typeof define&&define.amd&&define(["long"],function(t){return t&&t.isLong&&(n.util.Long=t,n.configure()),n}),"object"==typeof module&&module&&module.exports&&(module.exports=n)}({1:[function(t,n,i){n.exports=function(t,n){var i=Array(arguments.length-1),e=0,r=2,s=!0;for(;r>2],r=(3&o)<<4,h=1;break;case 1:e[s++]=f[r|o>>4],r=(15&o)<<2,h=2;break;case 2:e[s++]=f[r|o>>6],e[s++]=f[63&o],h=0}8191>4,r=h,e=2;break;case 2:n[i++]=(15&r)<<4|(60&h)>>2,r=h,e=3;break;case 3:n[i++]=(3&r)<<6|h,e=0}}if(1===e)throw Error(c);return i-u},i.test=function(t){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t)}},{}],3:[function(t,n,i){function r(){this.t={}}(n.exports=r).prototype.on=function(t,n,i){return(this.t[t]||(this.t[t]=[])).push({fn:n,ctx:i||this}),this},r.prototype.off=function(t,n){if(t===d)this.t={};else if(n===d)this.t[t]=[];else for(var i=this.t[t],r=0;r>>0:n<11754943508222875e-54?(u<<31|Math.round(n/1401298464324817e-60))>>>0:(u<<31|127+(t=Math.floor(Math.log(n)/Math.LN2))<<23|8388607&Math.round(n*Math.pow(2,-t)*8388608))>>>0,i,r)}function i(t,n,i){t=t(n,i),n=2*(t>>31)+1,i=t>>>23&255,t&=8388607;return 255==i?t?NaN:1/0*n:0==i?1401298464324817e-60*n*t:n*Math.pow(2,i-150)*(8388608+t)}function r(t,n,i){h[0]=t,n[i]=o[0],n[i+1]=o[1],n[i+2]=o[2],n[i+3]=o[3]}function u(t,n,i){h[0]=t,n[i]=o[3],n[i+1]=o[2],n[i+2]=o[1],n[i+3]=o[0]}function e(t,n){return o[0]=t[n],o[1]=t[n+1],o[2]=t[n+2],o[3]=t[n+3],h[0]}function s(t,n){return o[3]=t[n],o[2]=t[n+1],o[1]=t[n+2],o[0]=t[n+3],h[0]}var h,o,f,c,a;function l(t,n,i,r,u,e){var s,h=r<0?1:0;0===(r=h?-r:r)?(t(0,u,e+n),t(0<1/r?0:2147483648,u,e+i)):isNaN(r)?(t(0,u,e+n),t(2146959360,u,e+i)):17976931348623157e292>>0,u,e+i)):r<22250738585072014e-324?(t((s=r/5e-324)>>>0,u,e+n),t((h<<31|s/4294967296)>>>0,u,e+i)):(t(4503599627370496*(s=r*Math.pow(2,-(r=1024===(r=Math.floor(Math.log(r)/Math.LN2))?1023:r)))>>>0,u,e+n),t((h<<31|r+1023<<20|1048576*s&1048575)>>>0,u,e+i))}function v(t,n,i,r,u){n=t(r,u+n),t=t(r,u+i),r=2*(t>>31)+1,u=t>>>20&2047,i=4294967296*(1048575&t)+n;return 2047==u?i?NaN:1/0*r:0==u?5e-324*r*i:r*Math.pow(2,u-1075)*(i+4503599627370496)}function w(t,n,i){f[0]=t,n[i]=c[0],n[i+1]=c[1],n[i+2]=c[2],n[i+3]=c[3],n[i+4]=c[4],n[i+5]=c[5],n[i+6]=c[6],n[i+7]=c[7]}function b(t,n,i){f[0]=t,n[i]=c[7],n[i+1]=c[6],n[i+2]=c[5],n[i+3]=c[4],n[i+4]=c[3],n[i+5]=c[2],n[i+6]=c[1],n[i+7]=c[0]}function y(t,n){return c[0]=t[n],c[1]=t[n+1],c[2]=t[n+2],c[3]=t[n+3],c[4]=t[n+4],c[5]=t[n+5],c[6]=t[n+6],c[7]=t[n+7],f[0]}function g(t,n){return c[7]=t[n],c[6]=t[n+1],c[5]=t[n+2],c[4]=t[n+3],c[3]=t[n+4],c[2]=t[n+5],c[1]=t[n+6],c[0]=t[n+7],f[0]}return"undefined"!=typeof Float32Array?(h=new Float32Array([-0]),o=new Uint8Array(h.buffer),a=128===o[3],t.writeFloatLE=a?r:u,t.writeFloatBE=a?u:r,t.readFloatLE=a?e:s,t.readFloatBE=a?s:e):(t.writeFloatLE=n.bind(null,d),t.writeFloatBE=n.bind(null,A),t.readFloatLE=i.bind(null,p),t.readFloatBE=i.bind(null,m)),"undefined"!=typeof Float64Array?(f=new Float64Array([-0]),c=new Uint8Array(f.buffer),a=128===c[7],t.writeDoubleLE=a?w:b,t.writeDoubleBE=a?b:w,t.readDoubleLE=a?y:g,t.readDoubleBE=a?g:y):(t.writeDoubleLE=l.bind(null,d,0,4),t.writeDoubleBE=l.bind(null,A,4,0),t.readDoubleLE=v.bind(null,p,0,4),t.readDoubleBE=v.bind(null,m,4,0)),t}function d(t,n,i){n[i]=255&t,n[i+1]=t>>>8&255,n[i+2]=t>>>16&255,n[i+3]=t>>>24}function A(t,n,i){n[i]=t>>>24,n[i+1]=t>>>16&255,n[i+2]=t>>>8&255,n[i+3]=255&t}function p(t,n){return(t[n]|t[n+1]<<8|t[n+2]<<16|t[n+3]<<24)>>>0}function m(t,n){return(t[n]<<24|t[n+1]<<16|t[n+2]<<8|t[n+3])>>>0}n.exports=r(r)},{}],5:[function(t,n,i){function r(t){try{var n=void 0;if(n&&(n.length||Object.keys(n).length))return n}catch(t){}return null}n.exports=r},{}],6:[function(t,n,i){n.exports=function(n,i,t){var r=t||8192,u=r>>>1,e=null,s=r;return function(t){if(t<1||u>10),e[s++]=56320+(1023&r)):e[s++]=(15&r)<<12|(63&t[n++])<<6|63&t[n++],8191>6|192:(55296==(64512&r)&&56320==(64512&(u=t.charCodeAt(s+1)))?(++s,n[i++]=(r=65536+((1023&r)<<10)+(1023&u))>>18|240,n[i++]=r>>12&63|128):n[i++]=r>>12|224,n[i++]=r>>6&63|128),n[i++]=63&r|128);return i-e}},{}],8:[function(t,n,i){var r=i;function u(){r.util.n(),r.Writer.n(r.BufferWriter),r.Reader.n(r.BufferReader)}r.build="minimal",r.Writer=t(16),r.BufferWriter=t(17),r.Reader=t(9),r.BufferReader=t(10),r.util=t(15),r.rpc=t(12),r.roots=t(11),r.configure=u,u()},{10:10,11:11,12:12,15:15,16:16,17:17,9:9}],9:[function(t,n,i){n.exports=o;var r,u=t(15),e=u.LongBits,s=u.utf8;function h(t,n){return RangeError("index out of range: "+t.pos+" + "+(n||1)+" > "+t.len)}function o(t){this.buf=t,this.pos=0,this.len=t.length}function f(){return u.Buffer?function(t){return(o.create=function(t){return u.Buffer.isBuffer(t)?new r(t):a(t)})(t)}:a}var c,a="undefined"!=typeof Uint8Array?function(t){if(t instanceof Uint8Array||Array.isArray(t))return new o(t);throw Error("illegal buffer")}:function(t){if(Array.isArray(t))return new o(t);throw Error("illegal buffer")};function l(){var t=new e(0,0),n=0;if(!(4=this.len)throw h(this);if(t.lo=(t.lo|(127&this.buf[this.pos])<<7*n)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(127&this.buf[this.pos++])<<7*n)>>>0,t}for(;n<4;++n)if(t.lo=(t.lo|(127&this.buf[this.pos])<<7*n)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(127&this.buf[this.pos])<<28)>>>0,t.hi=(t.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return t;if(n=0,4>>0,this.buf[this.pos++]<128)return t}else for(;n<5;++n){if(this.pos>=this.len)throw h(this);if(t.hi=(t.hi|(127&this.buf[this.pos])<<7*n+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}function v(t,n){return(t[n-4]|t[n-3]<<8|t[n-2]<<16|t[n-1]<<24)>>>0}function w(){if(this.pos+8>this.len)throw h(this,8);return new e(v(this.buf,this.pos+=4),v(this.buf,this.pos+=4))}o.create=f(),o.prototype.i=u.Array.prototype.subarray||u.Array.prototype.slice,o.prototype.uint32=(c=4294967295,function(){if(c=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128||(c=(c|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128||(c=(c|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128||(c=(c|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128||(c=(c|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128||!((this.pos+=5)>this.len))))))return c;throw this.pos=this.len,h(this,10)}),o.prototype.int32=function(){return 0|this.uint32()},o.prototype.sint32=function(){var t=this.uint32();return t>>>1^-(1&t)|0},o.prototype.bool=function(){return 0!==this.uint32()},o.prototype.fixed32=function(){if(this.pos+4>this.len)throw h(this,4);return v(this.buf,this.pos+=4)},o.prototype.sfixed32=function(){if(this.pos+4>this.len)throw h(this,4);return 0|v(this.buf,this.pos+=4)},o.prototype.float=function(){if(this.pos+4>this.len)throw h(this,4);var t=u.float.readFloatLE(this.buf,this.pos);return this.pos+=4,t},o.prototype.double=function(){if(this.pos+8>this.len)throw h(this,4);var t=u.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,t},o.prototype.bytes=function(){var t=this.uint32(),n=this.pos,i=this.pos+t;if(i>this.len)throw h(this,t);return this.pos+=t,Array.isArray(this.buf)?this.buf.slice(n,i):n===i?(t=u.Buffer)?t.alloc(0):new this.buf.constructor(0):this.i.call(this.buf,n,i)},o.prototype.string=function(){var t=this.bytes();return s.read(t,0,t.length)},o.prototype.skip=function(t){if("number"==typeof t){if(this.pos+t>this.len)throw h(this,t);this.pos+=t}else do{if(this.pos>=this.len)throw h(this)}while(128&this.buf[this.pos++]);return this},o.prototype.skipType=function(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!=(t=7&this.uint32());)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+t+" at offset "+this.pos)}return this},o.n=function(t){r=t,o.create=f(),r.n();var n=u.Long?"toLong":"toNumber";u.merge(o.prototype,{int64:function(){return l.call(this)[n](!1)},uint64:function(){return l.call(this)[n](!0)},sint64:function(){return l.call(this).zzDecode()[n](!1)},fixed64:function(){return w.call(this)[n](!0)},sfixed64:function(){return w.call(this)[n](!1)}})}},{15:15}],10:[function(t,n,i){n.exports=e;var r=t(9),u=((e.prototype=Object.create(r.prototype)).constructor=e,t(15));function e(t){r.call(this,t)}e.n=function(){u.Buffer&&(e.prototype.i=u.Buffer.prototype.slice)},e.prototype.string=function(){var t=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+t,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+t,this.len))},e.n()},{15:15,9:9}],11:[function(t,n,i){n.exports={}},{}],12:[function(t,n,i){i.Service=t(13)},{13:13}],13:[function(t,n,i){n.exports=r;var h=t(15);function r(t,n,i){if("function"!=typeof t)throw TypeError("rpcImpl must be a function");h.EventEmitter.call(this),this.rpcImpl=t,this.requestDelimited=!!n,this.responseDelimited=!!i}((r.prototype=Object.create(h.EventEmitter.prototype)).constructor=r).prototype.rpcCall=function t(i,n,r,u,e){if(!u)throw TypeError("request must be specified");var s=this;if(!e)return h.asPromise(t,s,i,n,r,u);if(!s.rpcImpl)return setTimeout(function(){e(Error("already ended"))},0),d;try{return s.rpcImpl(i,n[s.requestDelimited?"encodeDelimited":"encode"](u).finish(),function(t,n){if(t)return s.emit("error",t,i),e(t);if(null===n)return s.end(!0),d;if(!(n instanceof r))try{n=r[s.responseDelimited?"decodeDelimited":"decode"](n)}catch(t){return s.emit("error",t,i),e(t)}return s.emit("data",n,i),e(null,n)})}catch(t){return s.emit("error",t,i),setTimeout(function(){e(t)},0),d}},r.prototype.end=function(t){return this.rpcImpl&&(t||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}},{15:15}],14:[function(t,n,i){n.exports=u;var r=t(15);function u(t,n){this.lo=t>>>0,this.hi=n>>>0}var e=u.zero=new u(0,0),s=(e.toNumber=function(){return 0},e.zzEncode=e.zzDecode=function(){return this},e.length=function(){return 1},u.zeroHash="\0\0\0\0\0\0\0\0",u.fromNumber=function(t){var n,i;return 0===t?e:(i=(t=(n=t<0)?-t:t)>>>0,t=(t-i)/4294967296>>>0,n&&(t=~t>>>0,i=~i>>>0,4294967295<++i&&(i=0,4294967295<++t&&(t=0))),new u(i,t))},u.from=function(t){if("number"==typeof t)return u.fromNumber(t);if(r.isString(t)){if(!r.Long)return u.fromNumber(parseInt(t,10));t=r.Long.fromString(t)}return t.low||t.high?new u(t.low>>>0,t.high>>>0):e},u.prototype.toNumber=function(t){var n;return!t&&this.hi>>>31?(t=1+~this.lo>>>0,n=~this.hi>>>0,-(t+4294967296*(n=t?n:n+1>>>0))):this.lo+4294967296*this.hi},u.prototype.toLong=function(t){return r.Long?new r.Long(0|this.lo,0|this.hi,!!t):{low:0|this.lo,high:0|this.hi,unsigned:!!t}},String.prototype.charCodeAt);u.fromHash=function(t){return"\0\0\0\0\0\0\0\0"===t?e:new u((s.call(t,0)|s.call(t,1)<<8|s.call(t,2)<<16|s.call(t,3)<<24)>>>0,(s.call(t,4)|s.call(t,5)<<8|s.call(t,6)<<16|s.call(t,7)<<24)>>>0)},u.prototype.toHash=function(){return String.fromCharCode(255&this.lo,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,255&this.hi,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},u.prototype.zzEncode=function(){var t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this},u.prototype.zzDecode=function(){var t=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this},u.prototype.length=function(){var t=this.lo,n=(this.lo>>>28|this.hi<<4)>>>0,i=this.hi>>>24;return 0==i?0==n?t<16384?t<128?1:2:t<2097152?3:4:n<16384?n<128?5:6:n<2097152?7:8:i<128?9:10}},{15:15}],15:[function(t,n,i){var r=i;function u(t,n,i){for(var r=Object.keys(n),u=0;u>>7|t.hi<<25)>>>0,t.hi>>>=7;for(;127>>7;n[i++]=t.lo}function y(t,n,i){n[i]=255&t,n[i+1]=t>>>8&255,n[i+2]=t>>>16&255,n[i+3]=t>>>24}a.create=l(),a.alloc=function(t){return new u.Array(t)},u.Array!==Array&&(a.alloc=u.pool(a.alloc,u.Array.prototype.subarray)),a.prototype.e=function(t,n,i){return this.tail=this.tail.next=new o(t,n,i),this.len+=n,this},(w.prototype=Object.create(o.prototype)).fn=function(t,n,i){for(;127>>=7;n[i]=t},a.prototype.uint32=function(t){return this.len+=(this.tail=this.tail.next=new w((t>>>=0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this},a.prototype.int32=function(t){return t<0?this.e(b,10,e.fromNumber(t)):this.uint32(t)},a.prototype.sint32=function(t){return this.uint32((t<<1^t>>31)>>>0)},a.prototype.int64=a.prototype.uint64=function(t){t=e.from(t);return this.e(b,t.length(),t)},a.prototype.sint64=function(t){t=e.from(t).zzEncode();return this.e(b,t.length(),t)},a.prototype.bool=function(t){return this.e(v,1,t?1:0)},a.prototype.sfixed32=a.prototype.fixed32=function(t){return this.e(y,4,t>>>0)},a.prototype.sfixed64=a.prototype.fixed64=function(t){t=e.from(t);return this.e(y,4,t.lo).e(y,4,t.hi)},a.prototype.float=function(t){return this.e(u.float.writeFloatLE,4,t)},a.prototype.double=function(t){return this.e(u.float.writeDoubleLE,8,t)};var g=u.Array.prototype.set?function(t,n,i){n.set(t,i)}:function(t,n,i){for(var r=0;r>>0;return i?(u.isString(t)&&(n=a.alloc(i=s.length(t)),s.decode(t,n,0),t=n),this.uint32(i).e(g,i,t)):this.e(v,1,0)},a.prototype.string=function(t){var n=h.length(t);return n?this.uint32(n).e(h.write,n,t):this.e(v,1,0)},a.prototype.fork=function(){return this.states=new c(this),this.head=this.tail=new o(f,0,0),this.len=0,this},a.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new o(f,0,0),this.len=0),this},a.prototype.ldelim=function(){var t=this.head,n=this.tail,i=this.len;return this.reset().uint32(i),i&&(this.tail.next=t.next,this.tail=n,this.len+=i),this},a.prototype.finish=function(){for(var t=this.head.next,n=this.constructor.alloc(this.len),i=0;t;)t.fn(t.val,n,i),i+=t.len,t=t.next;return n},a.n=function(t){r=t,a.create=l(),r.n()}},{15:15}],17:[function(t,n,i){n.exports=e;var r=t(16),u=((e.prototype=Object.create(r.prototype)).constructor=e,t(15));function e(){r.call(this)}function s(t,n,i){t.length<40?u.utf8.write(t,n,i):n.utf8Write?n.utf8Write(t,i):n.write(t,i)}e.n=function(){e.alloc=u.u,e.writeBytesBuffer=u.Buffer&&u.Buffer.prototype instanceof Uint8Array&&"set"===u.Buffer.prototype.set.name?function(t,n,i){n.set(t,i)}:function(t,n,i){if(t.copy)t.copy(n,i,0,t.length);else for(var r=0;r>>0;return this.uint32(n),n&&this.e(e.writeBytesBuffer,n,t),this},e.prototype.string=function(t){var n=u.Buffer.byteLength(t);return this.uint32(n),n&&this.e(s,n,t),this},e.n()},{15:15,16:16}]},{},[8])}(); +//# sourceMappingURL=protobuf.min.js.map diff --git a/util.js b/util.js new file mode 100644 index 0000000..46dd943 --- /dev/null +++ b/util.js @@ -0,0 +1,213 @@ +import { WidevineDevice } from "./device.js"; + +export class AsyncSyncStorage { + static async setStorage(items) { + return new Promise((resolve, reject) => { + chrome.storage.sync.set(items, () => { + if (chrome.runtime.lastError) { + reject(new Error(chrome.runtime.lastError)); + } else { + resolve(); + } + }); + }); + } + + static async getStorage(keys) { + return new Promise((resolve, reject) => { + chrome.storage.sync.get(keys, (result) => { + if (chrome.runtime.lastError) { + reject(new Error(chrome.runtime.lastError)); + } else { + resolve(result); + } + }); + }); + } + + static async removeStorage(keys) { + return new Promise((resolve, reject) => { + chrome.storage.sync.remove(keys, (result) => { + if (chrome.runtime.lastError) { + reject(new Error(chrome.runtime.lastError)); + } else { + resolve(result); + } + }); + }); + } +} + +export class AsyncLocalStorage { + static async setStorage(items) { + return new Promise((resolve, reject) => { + chrome.storage.local.set(items, () => { + if (chrome.runtime.lastError) { + reject(new Error(chrome.runtime.lastError)); + } else { + resolve(); + } + }); + }); + } + + static async getStorage(keys) { + return new Promise((resolve, reject) => { + chrome.storage.local.get(keys, (result) => { + if (chrome.runtime.lastError) { + reject(new Error(chrome.runtime.lastError)); + } else { + resolve(result); + } + }); + }); + } + + static async removeStorage(keys) { + return new Promise((resolve, reject) => { + chrome.storage.local.remove(keys, (result) => { + if (chrome.runtime.lastError) { + reject(new Error(chrome.runtime.lastError)); + } else { + resolve(result); + } + }); + }); + } +} + +export class DeviceManager { + static async saveWidevineDevice(name, value) { + const result = await AsyncSyncStorage.getStorage(['devices']); + const array = result.devices === undefined ? [] : result.devices; + array.push(name); + await AsyncSyncStorage.setStorage({ devices: array }); + + await AsyncSyncStorage.setStorage({ [name]: value }); + } + + static async loadWidevineDevice(name) { + const result = await AsyncSyncStorage.getStorage([name]); + return result[name] || ""; + } + + static setWidevineDevice(name, value){ + const wvd_combobox = document.getElementById('wvd-combobox'); + const wvd_element = document.createElement('option'); + + wvd_element.text = name; + wvd_element.value = value; + + wvd_combobox.appendChild(wvd_element); + } + + static async loadSetAllWidevineDevices() { + const result = await AsyncSyncStorage.getStorage(['devices']); + const array = result.devices || []; + for (const item of array) { + this.setWidevineDevice(item, await this.loadWidevineDevice(item)); + } + } + + static async saveSelectedWidevineDevice(name) { + await AsyncSyncStorage.setStorage({ selected: name }); + } + + static async getSelectedWidevineDevice() { + const result = await AsyncSyncStorage.getStorage(["selected"]); + return result["selected"] || ""; + } + + static async selectWidevineDevice(name) { + document.getElementById('wvd-combobox').value = await this.loadWidevineDevice(name); + } + + static async removeSelectedWidevineDevice() { + const selected_device_name = await DeviceManager.getSelectedWidevineDevice(); + + const result = await AsyncSyncStorage.getStorage(['devices']); + const array = result.devices === undefined ? [] : result.devices; + + const index = array.indexOf(selected_device_name); + if (index > -1) { + array.splice(index, 1); + } + + await AsyncSyncStorage.setStorage({ devices: array }); + await AsyncSyncStorage.removeStorage([selected_device_name]); + } +} + +export class SettingsManager { + static async setEnabled(enabled) { + await AsyncSyncStorage.setStorage({ enabled: enabled }); + } + + static async getEnabled() { + const result = await AsyncSyncStorage.getStorage(["enabled"]); + return result["enabled"] === undefined ? false : result["enabled"]; + } + + static downloadFile(content, filename) { + const blob = new Blob([content], { type: 'application/octet-stream' }); + const url = URL.createObjectURL(blob); + const a = document.createElement('a'); + a.href = url; + a.download = filename; + document.body.appendChild(a); + a.click(); + document.body.removeChild(a); + URL.revokeObjectURL(url); + } + + static async importDevice(file) { + return new Promise((resolve, reject) => { + const reader = new FileReader(); + reader.onload = async function (loaded) { + const result = loaded.target.result; + + const widevine_device = new WidevineDevice(result); + const b64_device = uint8ArrayToBase64(new Uint8Array(result)); + const device_name = widevine_device.get_name(); + + if (!await DeviceManager.loadWidevineDevice(device_name)) { + await DeviceManager.saveWidevineDevice(device_name, b64_device); + } + + await DeviceManager.saveSelectedWidevineDevice(device_name); + resolve(); + }; + reader.readAsArrayBuffer(file); + }) + } +} + +export function compareUint8Arrays(arr1, arr2) { + if (arr1.length !== arr2.length) + return false; + return Array.from(arr1).every((value, index) => value === arr2[index]); +} + +export function uint8ArrayToHex(buffer) { + return Array.prototype.map.call(buffer, x => x.toString(16).padStart(2, '0')).join(''); +} + +export function uint8ArrayToString(uint8array) { + return String.fromCharCode.apply(null, uint8array) +} + +export function uint8ArrayToBase64(uint8array) { + return btoa(String.fromCharCode.apply(null, uint8array)); +} + +export function base64toUint8Array(base64_string){ + return Uint8Array.from(atob(base64_string), c => c.charCodeAt(0)) +} + +export function stringToUint8Array(string) { + return Uint8Array.from(string.split("").map(x => x.charCodeAt())) +} + +export function stringToHex(string){ + return string.split("").map(c => c.charCodeAt(0).toString(16).padStart(2, "0")).join(""); +}