diff --git a/dist/crypto-pro.js b/dist/crypto-pro.js index 01fa8af..d6b4082 100644 --- a/dist/crypto-pro.js +++ b/dist/crypto-pro.js @@ -211,128 +211,113 @@ var CryptoPro = /***/ function(module, exports) { ;(function () { - /** - * Это переделанная версия cadesplugin_api.js с сайта Крипто ПРО, - * в которую добавлена поддержка IE-8. - * - * Обсуждение: - * https://www.cryptopro.ru/forum2/default.aspx?g=posts&t=9271 - * - * Оригинальный файл: - * https://www.cryptopro.ru/sites/default/files/products/cades/cadesplugin_api.js - * */ - var pluginObject, - plugin_resolved = 0, - plugin_reject, - plugin_resolve, - isOpera = 0, - isYaBrowser = 0, - isFireFox = 0, - canPromise = Boolean(window.Promise), - cadesplugin; - - if (window.cadesplugin) { + //already loaded + if(window.cadesplugin) return; - } - if (canPromise) { - cadesplugin = new Promise(function (resolve, reject) { + var pluginObject; + var plugin_resolved = 0; + var plugin_reject; + var plugin_resolve; + var isOpera = 0; + var isYaBrowser = 0; + var isFireFox = 0; + var failed_extensions = 0; + + var canPromise = !!window.Promise; + var cadesplugin; + + if(canPromise) + { + cadesplugin = new Promise(function(resolve, reject) + { plugin_resolve = resolve; plugin_reject = reject; }); - } else { + } else + { cadesplugin = {}; } - function cpcsp_console_log(level, msg) { + function cpcsp_console_log(level, msg){ //IE9 не может писать в консоль если не открыта вкладка developer tools - if (typeof console === 'undefined') { + if(typeof(console) == 'undefined') + return; + if (level <= cadesplugin.current_log_level ){ + if (level == cadesplugin.LOG_LEVEL_DEBUG) + console.log("DEBUG: %s", msg); + if (level == cadesplugin.LOG_LEVEL_INFO) + console.info("INFO: %s", msg); + if (level == cadesplugin.LOG_LEVEL_ERROR) + console.error("ERROR: %s", msg); return; - } - - if (level <= cadesplugin.current_log_level) { - if (level == cadesplugin.LOG_LEVEL_DEBUG) { - console.log('DEBUG: %s', msg); - } - - if (level == cadesplugin.LOG_LEVEL_INFO) { - console.info('INFO: %s', msg); - } - - if (level == cadesplugin.LOG_LEVEL_ERROR) { - console.error('ERROR: %s', msg); - } } } - function set_log_level(level) { - var isSetLoglevel = (level == cadesplugin.LOG_LEVEL_DEBUG) - || (level == cadesplugin.LOG_LEVEL_INFO) - || (level == cadesplugin.LOG_LEVEL_ERROR); - - if (!isSetLoglevel) { - cpcsp_console_log(cadesplugin.LOG_LEVEL_ERROR, 'cadesplugin_api.js: Incorrect log_level: ' + level); - + function set_log_level(level){ + if (!((level == cadesplugin.LOG_LEVEL_DEBUG) || + (level == cadesplugin.LOG_LEVEL_INFO) || + (level == cadesplugin.LOG_LEVEL_ERROR))){ + cpcsp_console_log(cadesplugin.LOG_LEVEL_ERROR, "cadesplugin_api.js: Incorrect log_level: " + level); return; } - cadesplugin.current_log_level = level; - - if (cadesplugin.current_log_level == cadesplugin.LOG_LEVEL_DEBUG) { - cpcsp_console_log(cadesplugin.LOG_LEVEL_INFO, 'cadesplugin_api.js: log_level = DEBUG'); - } - - if (cadesplugin.current_log_level == cadesplugin.LOG_LEVEL_INFO) { - cpcsp_console_log(cadesplugin.LOG_LEVEL_INFO, 'cadesplugin_api.js: log_level = INFO'); - } - - if (cadesplugin.current_log_level == cadesplugin.LOG_LEVEL_ERROR) { - cpcsp_console_log(cadesplugin.LOG_LEVEL_INFO, 'cadesplugin_api.js: log_level = ERROR'); - } - - if (isNativeMessageSupported()) { - if (cadesplugin.current_log_level == cadesplugin.LOG_LEVEL_DEBUG) { - window.postMessage('set_log_level=debug', '*'); - } - - if (cadesplugin.current_log_level == cadesplugin.LOG_LEVEL_INFO) { - window.postMessage('set_log_level=info', '*'); - } - - if (cadesplugin.current_log_level == cadesplugin.LOG_LEVEL_ERROR) { - window.postMessage('set_log_level=error', '*'); - } + if (cadesplugin.current_log_level == cadesplugin.LOG_LEVEL_DEBUG) + cpcsp_console_log(cadesplugin.LOG_LEVEL_INFO, "cadesplugin_api.js: log_level = DEBUG"); + if (cadesplugin.current_log_level == cadesplugin.LOG_LEVEL_INFO) + cpcsp_console_log(cadesplugin.LOG_LEVEL_INFO, "cadesplugin_api.js: log_level = INFO"); + if (cadesplugin.current_log_level == cadesplugin.LOG_LEVEL_ERROR) + cpcsp_console_log(cadesplugin.LOG_LEVEL_INFO, "cadesplugin_api.js: log_level = ERROR"); + if(isNativeMessageSupported()) + { + if (cadesplugin.current_log_level == cadesplugin.LOG_LEVEL_DEBUG) + window.postMessage("set_log_level=debug", "*"); + if (cadesplugin.current_log_level == cadesplugin.LOG_LEVEL_INFO) + window.postMessage("set_log_level=info", "*"); + if (cadesplugin.current_log_level == cadesplugin.LOG_LEVEL_ERROR) + window.postMessage("set_log_level=error", "*"); } } - function set_constantValues() { + function set_constantValues() + { cadesplugin.CAPICOM_LOCAL_MACHINE_STORE = 1; cadesplugin.CAPICOM_CURRENT_USER_STORE = 2; cadesplugin.CADESCOM_LOCAL_MACHINE_STORE = 1; cadesplugin.CADESCOM_CURRENT_USER_STORE = 2; cadesplugin.CADESCOM_CONTAINER_STORE = 100; - cadesplugin.CAPICOM_MY_STORE = 'My'; + + cadesplugin.CAPICOM_MY_STORE = "My"; + cadesplugin.CAPICOM_STORE_OPEN_MAXIMUM_ALLOWED = 2; + cadesplugin.CAPICOM_CERTIFICATE_FIND_SUBJECT_NAME = 1; + cadesplugin.CADESCOM_XML_SIGNATURE_TYPE_ENVELOPED = 0; cadesplugin.CADESCOM_XML_SIGNATURE_TYPE_ENVELOPING = 1; cadesplugin.CADESCOM_XML_SIGNATURE_TYPE_TEMPLATE = 2; - cadesplugin.XmlDsigGost3410UrlObsolete = 'http://www.w3.org/2001/04/xmldsig-more#gostr34102001-gostr3411'; - cadesplugin.XmlDsigGost3411UrlObsolete = 'http://www.w3.org/2001/04/xmldsig-more#gostr3411'; - cadesplugin.XmlDsigGost3410Url = 'urn:ietf:params:xml:ns:cpxmlsec:algorithms:gostr34102001-gostr3411'; - cadesplugin.XmlDsigGost3411Url = 'urn:ietf:params:xml:ns:cpxmlsec:algorithms:gostr3411'; + + cadesplugin.XmlDsigGost3410UrlObsolete = "http://www.w3.org/2001/04/xmldsig-more#gostr34102001-gostr3411"; + cadesplugin.XmlDsigGost3411UrlObsolete = "http://www.w3.org/2001/04/xmldsig-more#gostr3411"; + cadesplugin.XmlDsigGost3410Url = "urn:ietf:params:xml:ns:cpxmlsec:algorithms:gostr34102001-gostr3411"; + cadesplugin.XmlDsigGost3411Url = "urn:ietf:params:xml:ns:cpxmlsec:algorithms:gostr3411"; + cadesplugin.CADESCOM_CADES_DEFAULT = 0; cadesplugin.CADESCOM_CADES_BES = 1; cadesplugin.CADESCOM_CADES_T = 0x5; cadesplugin.CADESCOM_CADES_X_LONG_TYPE_1 = 0x5d; + cadesplugin.CADESCOM_ENCODE_BASE64 = 0; cadesplugin.CADESCOM_ENCODE_BINARY = 1; cadesplugin.CADESCOM_ENCODE_ANY = -1; + cadesplugin.CAPICOM_CERTIFICATE_INCLUDE_CHAIN_EXCEPT_ROOT = 0; cadesplugin.CAPICOM_CERTIFICATE_INCLUDE_WHOLE_CHAIN = 1; cadesplugin.CAPICOM_CERTIFICATE_INCLUDE_END_ENTITY_ONLY = 2; + cadesplugin.CAPICOM_CERT_INFO_SUBJECT_SIMPLE_NAME = 0; cadesplugin.CAPICOM_CERT_INFO_ISSUER_SIMPLE_NAME = 1; + cadesplugin.CAPICOM_CERTIFICATE_FIND_SHA1_HASH = 0; cadesplugin.CAPICOM_CERTIFICATE_FIND_SUBJECT_NAME = 1; cadesplugin.CAPICOM_CERTIFICATE_FIND_ISSUER_NAME = 2; @@ -346,28 +331,37 @@ var CryptoPro = cadesplugin.CAPICOM_CERTIFICATE_FIND_TIME_NOT_YET_VALID = 10; cadesplugin.CAPICOM_CERTIFICATE_FIND_TIME_EXPIRED = 11; cadesplugin.CAPICOM_CERTIFICATE_FIND_KEY_USAGE = 12; + cadesplugin.CAPICOM_DIGITAL_SIGNATURE_KEY_USAGE = 128; + cadesplugin.CAPICOM_PROPID_ENHKEY_USAGE = 9; + cadesplugin.CAPICOM_OID_OTHER = 0; cadesplugin.CAPICOM_OID_KEY_USAGE_EXTENSION = 10; + cadesplugin.CAPICOM_EKU_CLIENT_AUTH = 2; cadesplugin.CAPICOM_EKU_SMARTCARD_LOGON = 5; cadesplugin.CAPICOM_EKU_OTHER = 0; + cadesplugin.CAPICOM_AUTHENTICATED_ATTRIBUTE_SIGNING_TIME = 0; cadesplugin.CADESCOM_AUTHENTICATED_ATTRIBUTE_DOCUMENT_NAME = 1; cadesplugin.CADESCOM_AUTHENTICATED_ATTRIBUTE_DOCUMENT_DESCRIPTION = 2; cadesplugin.CADESCOM_ATTRIBUTE_OTHER = -1; + cadesplugin.CADESCOM_STRING_TO_UCS2LE = 0; cadesplugin.CADESCOM_BASE64_TO_BINARY = 1; + cadesplugin.CADESCOM_DISPLAY_DATA_NONE = 0; cadesplugin.CADESCOM_DISPLAY_DATA_CONTENT = 1; cadesplugin.CADESCOM_DISPLAY_DATA_ATTRIBUTE = 2; + cadesplugin.CADESCOM_ENCRYPTION_ALGORITHM_RC2 = 0; cadesplugin.CADESCOM_ENCRYPTION_ALGORITHM_RC4 = 1; cadesplugin.CADESCOM_ENCRYPTION_ALGORITHM_DES = 2; cadesplugin.CADESCOM_ENCRYPTION_ALGORITHM_3DES = 3; cadesplugin.CADESCOM_ENCRYPTION_ALGORITHM_AES = 4; cadesplugin.CADESCOM_ENCRYPTION_ALGORITHM_GOST_28147_89 = 25; + cadesplugin.CADESCOM_HASH_ALGORITHM_SHA1 = 0; cadesplugin.CADESCOM_HASH_ALGORITHM_MD2 = 1; cadesplugin.CADESCOM_HASH_ALGORITHM_MD4 = 2; @@ -378,67 +372,65 @@ var CryptoPro = cadesplugin.CADESCOM_HASH_ALGORITHM_CP_GOST_3411 = 100; cadesplugin.CADESCOM_HASH_ALGORITHM_CP_GOST_3411_2012_256 = 101; cadesplugin.CADESCOM_HASH_ALGORITHM_CP_GOST_3411_2012_512 = 102; + cadesplugin.LOG_LEVEL_DEBUG = 4; cadesplugin.LOG_LEVEL_INFO = 2; cadesplugin.LOG_LEVEL_ERROR = 1; } function async_spawn(generatorFunc) { - var generator = generatorFunc(Array.prototype.slice.call(arguments, 1)), - onFulfilled = continuer.bind(continuer, 'next'), - onRejected = continuer.bind(continuer, 'throw'); - - function continuer(verb, arg) { - var result; - - try { - result = generator[verb](arg); - } catch (err) { - return Promise.reject(err); - } - - if (result.done) { - return result.value; - } else { - return Promise.resolve(result.value).then(onFulfilled, onRejected); - } + function continuer(verb, arg) { + var result; + try { + result = generator[verb](arg); + } catch (err) { + return Promise.reject(err); } - - return onFulfilled(); + if (result.done) { + return result.value; + } else { + return Promise.resolve(result.value).then(onFulfilled, onRejected); + } + } + var generator = generatorFunc(Array.prototype.slice.call(arguments, 1)); + var onFulfilled = continuer.bind(continuer, "next"); + var onRejected = continuer.bind(continuer, "throw"); + return onFulfilled(); } function isIE() { - return navigator.appName === 'Microsoft Internet Explorer' // IE < 11 - || navigator.userAgent.match(/Trident\/./i); // IE 11 + var retVal = (("Microsoft Internet Explorer" == navigator.appName) || // IE < 11 + navigator.userAgent.match(/Trident\/./i)); // IE 11 + return retVal; } function isIOS() { - return navigator.userAgent.match(/ipod/i) - || navigator.userAgent.match(/ipad/i) - || navigator.userAgent.match(/iphone/i); + var retVal = (navigator.userAgent.match(/ipod/i) || + navigator.userAgent.match(/ipad/i) || + navigator.userAgent.match(/iphone/i)); + return retVal; } - function isNativeMessageSupported() { + function isNativeMessageSupported() + { var retVal_chrome = navigator.userAgent.match(/chrome/i); - isOpera = navigator.userAgent.match(/opr/i); isYaBrowser = navigator.userAgent.match(/YaBrowser/i); isFireFox = navigator.userAgent.match(/Firefox/i); - if (isFireFox && window.allow_firefox_cadesplugin_async) { + if(isFireFox && window.allow_firefox_cadesplugin_async) return true; - } - if (retVal_chrome == null) { - // В IE работаем через NPAPI + if(retVal_chrome == null) // В IE работаем через NPAPI return false; - } else { + else + { // В Chrome и Opera работаем через асинхронную версию - if (retVal_chrome.length > 0 || isOpera != null) { + if(retVal_chrome.length > 0 || isOpera != null ) + { return true; } } - return false; } @@ -447,30 +439,26 @@ var CryptoPro = if (isIOS()) { // На iOS для создания объектов используется функция // call_ru_cryptopro_npcades_10_native_bridge, определенная в IOS_npcades_supp.js - return call_ru_cryptopro_npcades_10_native_bridge('CreateObject', [name]); + return call_ru_cryptopro_npcades_10_native_bridge("CreateObject", [name]); } - if (isIE()) { - // В Internet Explorer создаются COM-объекты - if (name.match(/X509Enrollment/i)) { + // В Internet Explorer создаются COM-объекты + if (name.match(/X509Enrollment/i)) { try { // Объекты CertEnroll создаются через CX509EnrollmentWebClassFactory - var objCertEnrollClassFactory = document.getElementById('certEnrollClassFactory'); + var objCertEnrollClassFactory = document.getElementById("certEnrollClassFactory"); return objCertEnrollClassFactory.CreateObject(name); - } catch (e) { - throw( - 'Для создания обьектов X509Enrollment следует настроить ' + - 'веб-узел на использование проверки подлинности по протоколу HTTPS' - ); + } + catch (e) { + throw("Для создания обьектов X509Enrollment следует настроить веб-узел на использование проверки подлинности по протоколу HTTPS"); } } - // Объекты CAPICOM и CAdESCOM создаются через CAdESCOM.WebClassFactory try { - var objWebClassFactory = document.getElementById('webClassFactory'); - + var objWebClassFactory = document.getElementById("webClassFactory"); return objWebClassFactory.CreateObject(name); - } catch (e) { + } + catch (e) { try { // Для версий плагина ниже 2.0.12538 return new ActiveXObject(name); @@ -493,7 +481,6 @@ var CryptoPro = } } } - // В Firefox, Safari создаются объекты NPAPI return pluginObject.CreateObject(name); } @@ -508,24 +495,22 @@ var CryptoPro = function GetMessageFromException(e) { var err = e.message; - if (!err) { err = e; } else if (e.number) { - err += ' (0x' + decimalToHexString(e.number) + ')'; + err += " (0x" + decimalToHexString(e.number) + ")"; } - return err; } function getLastError(exception) { - if (isNativeMessageSupported() || isIE() || isIOS()) { + if(isNativeMessageSupported() || isIE() || isIOS() ) { return GetMessageFromException(exception); } try { return pluginObject.getLastError(); - } catch (e) { + } catch(e) { return GetMessageFromException(exception); } } @@ -535,312 +520,284 @@ var CryptoPro = return pluginObject.CreateObjectAsync(name); } - // Функции для IOS + //Функции для IOS var ru_cryptopro_npcades_10_native_bridge = { - callbacksCount: 1, - callbacks: {}, + callbacksCount : 1, + callbacks : {}, - // Automatically called by native layer when a result is available - resultForCallback: function resultForCallback(callbackId, resultArray) { + // Automatically called by native layer when a result is available + resultForCallback : function resultForCallback(callbackId, resultArray) { var callback = ru_cryptopro_npcades_10_native_bridge.callbacks[callbackId]; + if (!callback) return; + callback.apply(null,resultArray); + }, - if (!callback) { - return; + // Use this in javascript to request native objective-c code + // functionName : string (I think the name is explicit :p) + // args : array of arguments + // callback : function with n-arguments that is going to be called when the native code returned + call : function call(functionName, args, callback) { + var hasCallback = callback && typeof callback == "function"; + var callbackId = hasCallback ? ru_cryptopro_npcades_10_native_bridge.callbacksCount++ : 0; + + if (hasCallback) + ru_cryptopro_npcades_10_native_bridge.callbacks[callbackId] = callback; + + var iframe = document.createElement("IFRAME"); + var arrObjs = new Array("_CPNP_handle"); + try{ + iframe.setAttribute("src", "cpnp-js-call:" + functionName + ":" + callbackId+ ":" + encodeURIComponent(JSON.stringify(args, arrObjs))); + } catch(e){ + alert(e); } - - callback.apply(null, resultArray); - }, - - // Use this in javascript to request native objective-c code - // functionName : string (I think the name is explicit :p) - // args : array of arguments - // callback : function with n-arguments that is going to be called when the native code returned - call: function call(functionName, args, callback) { - var hasCallback = callback && typeof callback == 'function', - callbackId = hasCallback ? ru_cryptopro_npcades_10_native_bridge.callbacksCount++ : 0, - iframe, - arrObjs; - - if (hasCallback) { - ru_cryptopro_npcades_10_native_bridge.callbacks[callbackId] = callback; - } - - iframe = document.createElement('IFRAME'); - - arrObjs = new Array('_CPNP_handle'); - - try { - iframe.setAttribute( - 'src', - 'cpnp-js-call:' + - functionName + ':' + callbackId + ':' + encodeURIComponent(JSON.stringify(args, arrObjs)) - ); - } catch (e) { - alert(e); - } - - document.documentElement.appendChild(iframe); - - iframe.parentNode.removeChild(iframe); - iframe = null; - } + document.documentElement.appendChild(iframe); + iframe.parentNode.removeChild(iframe); + iframe = null; + } }; - function call_ru_cryptopro_npcades_10_native_bridge(functionName, array) { - var tmpobj, - ex; - - ru_cryptopro_npcades_10_native_bridge.call(functionName, array, function (e, response) { - ex = e; - var str = 'tmpobj=' + response; - - eval(str); - - if (typeof (tmpobj) == 'string') { - tmpobj = tmpobj.replace(/\\\n/gm, '\n'); - tmpobj = tmpobj.replace(/\\\r/gm, '\r'); - } - }); - - if (ex) { + function call_ru_cryptopro_npcades_10_native_bridge(functionName, array){ + var tmpobj; + var ex; + ru_cryptopro_npcades_10_native_bridge.call(functionName, array, function(e, response){ + ex = e; + var str='tmpobj='+response; + eval(str); + if (typeof (tmpobj) == "string"){ + tmpobj = tmpobj.replace(/\\\n/gm, "\n"); + tmpobj = tmpobj.replace(/\\\r/gm, "\r"); + } + }); + if(ex) throw ex; - } - return tmpobj; } - // Выводим окно поверх других с предложением установить расширение для Opera. - // Если установленна переменная cadesplugin_skip_extension_install - не предлагаем установить расширение - function install_opera_extension() { - if (!window.cadesplugin_skip_extension_install) { - var ovr = document.createElement('div'); + //Выводим окно поверх других с предложением установить расширение для Opera. + //Если установленна переменная cadesplugin_skip_extension_install - не предлагаем установить расширение + function install_opera_extension() + { + if (!window.cadesplugin_skip_extension_install) + { + document.addEventListener('DOMContentLoaded', function() { + var ovr = document.createElement('div'); + ovr.id = "cadesplugin_ovr"; + ovr.style = "visibility: hidden; position: fixed; left: 0px; top: 0px; width:100%; height:100%; background-color: rgba(0,0,0,0.7)"; + ovr.innerHTML = "
" + + "" + + "

Для работы КриптоПро ЭЦП Browser plugin на данном сайте необходимо установить расширение из каталога дополнений Opera." + + "

" + + "
"; + document.getElementsByTagName("Body")[0].appendChild(ovr); + var btn_install = document.getElementById("cadesplugin_install"); + btn_install.addEventListener('click', function(event) { + opr.addons.installExtension("epebfcehmdedogndhlcacafjaacknbcm", + function() + { + document.getElementById("cadesplugin_ovr").style.visibility = 'hidden'; + location.reload(); + }, + function(){}) + }); + document.getElementById("cadesplugin_close_install").addEventListener('click',function() + { + plugin_loaded_error("Плагин недоступен"); + document.getElementById("cadesplugin_ovr").style.visibility = 'hidden'; + }); - ovr.id = 'cadesplugin_ovr'; - ovr.style = [ - 'visibility: hidden; position: fixed; left: 0px; top: 0px;', - 'width:100%; height:100%; background-color: rgba(0,0,0,0.7)' - ].join(' '); - - ovr.innerHTML = '\ -
\ - \ -

\ - Для работы КриптоПро ЭЦП Browser plugin на данном сайте необходимо установить\ - расширение из каталога дополнений Opera.\ -

\ -

\ -
\ - '; - - document.getElementsByTagName('Body')[0].appendChild(ovr); - - var btn_install = document.getElementById('cadesplugin_install'); - - btn_install.addEventListener('click', function (event) { - opr.addons.installExtension('epebfcehmdedogndhlcacafjaacknbcm', - function () { - document.getElementById('cadesplugin_ovr').style.visibility = 'hidden'; - location.reload(); - }, - function () {} - ); + ovr.addEventListener('click',function() + { + plugin_loaded_error("Плагин недоступен"); + document.getElementById("cadesplugin_ovr").style.visibility = 'hidden'; + }); + ovr.style.visibility="visible"; + document.getElementById("cadesplugin_ovr_item").addEventListener('click',function(e){ + e.stopPropagation(); + }); }); - - document.getElementById('cadesplugin_close_install').addEventListener('click', function () { - plugin_loaded_error('Плагин недоступен'); - document.getElementById('cadesplugin_ovr').style.visibility = 'hidden'; - }); - - ovr.addEventListener('click', function () { - plugin_loaded_error('Плагин недоступен'); - document.getElementById('cadesplugin_ovr').style.visibility = 'hidden'; - }); - - ovr.style.visibility = 'visible'; - - document.getElementById('cadesplugin_ovr_item').addEventListener('click', function (e) { - e.stopPropagation(); - }); - } else { - plugin_loaded_error('Плагин недоступен'); + }else + { + plugin_loaded_error("Плагин недоступен"); } } function firefox_nmcades_onload() { - window.cpcsp_chrome_nmcades.check_chrome_plugin(plugin_loaded, plugin_loaded_error); + cpcsp_chrome_nmcades.check_chrome_plugin(plugin_loaded, plugin_loaded_error); } - function nmcades_api_onload() { - window.postMessage('cadesplugin_echo_request', '*'); - - window.addEventListener('message', function (event) { - if (typeof event.data !== 'string' || !event.data.match('cadesplugin_loaded')) { - return; - } - - if (isFireFox) { + function nmcades_api_onload () { + window.postMessage("cadesplugin_echo_request", "*"); + window.addEventListener("message", function (event){ + if (typeof(event.data) != "string" || !event.data.match("cadesplugin_loaded")) + return; + if(isFireFox) + { // Для Firefox вместе с сообщением cadesplugin_loaded прилетает url для загрузки nmcades_plugin_api.js - var url = event.data.substring(event.data.indexOf('url:') + 4); + var url = event.data.substring(event.data.indexOf("url:") + 4); var fileref = document.createElement('script'); - - fileref.setAttribute('type', 'text/javascript'); - fileref.setAttribute('src', url); + fileref.setAttribute("type", "text/javascript"); + fileref.setAttribute("src", url); fileref.onerror = plugin_loaded_error; fileref.onload = firefox_nmcades_onload; - document.getElementsByTagName('head')[0].appendChild(fileref); - } else { + document.getElementsByTagName("head")[0].appendChild(fileref); + + }else { cpcsp_chrome_nmcades.check_chrome_plugin(plugin_loaded, plugin_loaded_error); } }, false); } //Загружаем расширения для Chrome, Opera, YaBrowser, FireFox, Edge - function load_extension() { - if (isFireFox) { + function load_extension() + { + + if(isFireFox){ // вызываем callback руками т.к. нам нужно узнать ID расширения. Он уникальный для браузера. nmcades_api_onload(); return; } else { - var fileref = document.createElement('script'), - hash = isNativeMessageSupported() && isOpera ? 'epebfcehmdedogndhlcacafjaacknbcm' : 'iifchhfnnmpdbibifmljnfjhpififfog'; - - if (hash) { - fileref.setAttribute('type', 'text/javascript'); - fileref.setAttribute('src', 'chrome-extension://' + hash + '/nmcades_plugin_api.js'); - fileref.onerror = plugin_loaded_error; - fileref.onload = nmcades_api_onload; - document.getElementsByTagName('head')[0].appendChild(fileref); - } + // в асинхронном варианте для chrome и opera подключаем оба расширения + var fileref = document.createElement('script'); + fileref.setAttribute("type", "text/javascript"); + fileref.setAttribute("src", "chrome-extension://iifchhfnnmpdbibifmljnfjhpififfog/nmcades_plugin_api.js"); + fileref.onerror = plugin_loaded_error; + fileref.onload = nmcades_api_onload; + document.getElementsByTagName("head")[0].appendChild(fileref); + fileref = document.createElement('script'); + fileref.setAttribute("type", "text/javascript"); + fileref.setAttribute("src", "chrome-extension://epebfcehmdedogndhlcacafjaacknbcm/nmcades_plugin_api.js"); + fileref.onerror = plugin_loaded_error; + fileref.onload = nmcades_api_onload; + document.getElementsByTagName("head")[0].appendChild(fileref); } } - // Загружаем плагин для NPAPI - function load_npapi_plugin() { + //Загружаем плагин для NPAPI + function load_npapi_plugin() + { var elem = document.createElement('object'); - - elem.setAttribute('id', 'cadesplugin_object'); - elem.setAttribute('type', 'application/x-cades'); - elem.setAttribute('style', 'visibility: hidden'); - document.getElementsByTagName('body')[0].appendChild(elem); - - pluginObject = document.getElementById('cadesplugin_object'); - - if (isIE()) { + elem.setAttribute("id", "cadesplugin_object"); + elem.setAttribute("type", "application/x-cades"); + elem.setAttribute("style", "visibility: hidden"); + document.getElementsByTagName("body")[0].appendChild(elem); + pluginObject = document.getElementById("cadesplugin_object"); + if(isIE()) + { var elem1 = document.createElement('object'); - - elem1.setAttribute('id', 'certEnrollClassFactory'); - elem1.setAttribute('classid', 'clsid:884e2049-217d-11da-b2a4-000e7bbb2b09'); - elem1.setAttribute('style', 'visibility: hidden'); - document.getElementsByTagName('body')[0].appendChild(elem1); - + elem1.setAttribute("id", "certEnrollClassFactory"); + elem1.setAttribute("classid", "clsid:884e2049-217d-11da-b2a4-000e7bbb2b09"); + elem1.setAttribute("style", "visibility: hidden"); + document.getElementsByTagName("body")[0].appendChild(elem1); var elem2 = document.createElement('object'); - elem2.setAttribute('id', 'webClassFactory'); - elem2.setAttribute('classid', 'clsid:B04C8637-10BD-484E-B0DA-B8A039F60024'); - elem2.setAttribute('style', 'visibility: hidden'); - - document.getElementsByTagName('body')[0].appendChild(elem2); + elem2.setAttribute("id", "webClassFactory"); + elem2.setAttribute("classid", "clsid:B04C8637-10BD-484E-B0DA-B8A039F60024"); + elem2.setAttribute("style", "visibility: hidden"); + document.getElementsByTagName("body")[0].appendChild(elem2); } } - // Отправляем событие что все ок. - function plugin_loaded() { + //Отправляем событие что все ок. + function plugin_loaded() + { plugin_resolved = 1; - if (canPromise) { + if(canPromise) + { plugin_resolve(); - } else { - window.postMessage('cadesplugin_loaded', '*'); + }else { + window.postMessage("cadesplugin_loaded", "*"); } } - // Отправляем событие что сломались. - function plugin_loaded_error(msg) { - if (isNativeMessageSupported()) { - if (isOpera && (typeof(msg) == 'undefined' || typeof(msg) == 'object')) { + //Отправляем событие что сломались. + function plugin_loaded_error(msg) + { + if(isNativeMessageSupported()) + { + //в асинхронном варианте подключаем оба расширения, если сломались оба пробуем установить для Opera + failed_extensions++; + if(failed_extensions<2) + return; + if(isOpera && (typeof(msg) == 'undefined'|| typeof(msg) == 'object')) + { install_opera_extension(); return; } } - - if (typeof(msg) == 'undefined' || typeof(msg) == 'object') { - msg = 'Плагин недоступен'; - } - + if(typeof(msg) == 'undefined' || typeof(msg) == 'object') + msg = "Плагин недоступен"; plugin_resolved = 1; - - if (canPromise) { + if(canPromise) + { plugin_reject(msg); } else { - window.postMessage('cadesplugin_load_error', '*'); + window.postMessage("cadesplugin_load_error", "*"); } } - // проверяем что у нас хоть какое то событие ушло, и если не уходило кидаем еще раз ошибку - function check_load_timeout() { - if (plugin_resolved == 1) { + //проверяем что у нас хоть какое то событие ушло, и если не уходило кидаем еще раз ошибку + function check_load_timeout() + { + if(plugin_resolved == 1) return; - } - plugin_resolved = 1; - - if (canPromise) { - plugin_reject('Истекло время ожидания загрузки плагина'); + if(canPromise) + { + plugin_reject("Истекло время ожидания загрузки плагина"); } else { - window.postMessage('cadesplugin_load_error', '*'); + window.postMessage("cadesplugin_load_error", "*"); } + } - function check_npapi_plugin() { - try { - var oAbout = CreateObject('CAdESCOM.About'); + //Вспомогательная функция для NPAPI + function createPromise(arg) + { + return new Promise(arg); + } + function check_npapi_plugin (){ + try { + var oAbout = CreateObject("CAdESCOM.About"); plugin_loaded(); - } catch (err) { - document.getElementById('cadesplugin_object').style.display = 'none'; + } + catch (err) { + document.getElementById("cadesplugin_object").style.display = 'none'; // Объект создать не удалось, проверим, установлен ли // вообще плагин. Такая возможность есть не во всех браузерах - var mimetype = navigator.mimeTypes['application/x-cades']; + var mimetype = navigator.mimeTypes["application/x-cades"]; if (mimetype) { var plugin = mimetype.enabledPlugin; if (plugin) { - plugin_loaded_error('Плагин загружен, но не создаются обьекты'); - } else { - plugin_loaded_error('Ошибка при загрузке плагина'); + plugin_loaded_error("Плагин загружен, но не создаются обьекты"); + }else + { + plugin_loaded_error("Ошибка при загрузке плагина"); } - } else { - plugin_loaded_error('Плагин недоступен'); + }else + { + plugin_loaded_error("Плагин недоступен"); } } } - // Проверяем работает ли плагин - function check_plugin_working() { - if (isNativeMessageSupported()) { + //Проверяем работает ли плагин + function check_plugin_working() + { + if(isNativeMessageSupported()) + { load_extension(); - } else if (!canPromise) { - window.addEventListener('message', function (event) { - if (event.data != 'cadesplugin_echo_request') { - return; - } - - load_npapi_plugin(); - check_npapi_plugin(); - }, false); - } else { + }else if(!canPromise) { + window.addEventListener("message", function (event){ + if (event.data != "cadesplugin_echo_request") + return; + load_npapi_plugin(); + check_npapi_plugin(); + }, + false); + }else + { if (window.addEventListener) { - window.addEventListener('load', function (event) { + window.addEventListener("load", function (event) { load_npapi_plugin(); check_npapi_plugin(); }, false); @@ -851,44 +808,45 @@ var CryptoPro = } } - function set_pluginObject(obj) { + function set_pluginObject(obj) + { pluginObject = obj; } - // Export - cadesplugin.JSModuleVersion = '2.1.0'; + //Export + cadesplugin.JSModuleVersion = "2.1.0"; cadesplugin.async_spawn = async_spawn; cadesplugin.set = set_pluginObject; cadesplugin.set_log_level = set_log_level; cadesplugin.getLastError = getLastError; - if (isNativeMessageSupported()) { + if(isNativeMessageSupported()) + { cadesplugin.CreateObjectAsync = CreateObjectAsync; } - if (!isNativeMessageSupported()) { + if(!isNativeMessageSupported()) + { cadesplugin.CreateObject = CreateObject; } - if (window.cadesplugin_load_timeout) { + if(window.cadesplugin_load_timeout) + { setTimeout(check_load_timeout, window.cadesplugin_load_timeout); - } else { - /** - * Даже при слабом интернете плагин успевает загрузиться - * менее чем за секунду, тк отдается из кэша - * */ + } + else + { setTimeout(check_load_timeout, 20000); } set_constantValues(); cadesplugin.current_log_level = cadesplugin.LOG_LEVEL_ERROR; - window.cadesplugin = cadesplugin; - check_plugin_working(); }()); + /***/ }, /* 2 */, /* 3 */, diff --git a/dist/crypto-pro.js.map b/dist/crypto-pro.js.map index 91b71df..1d6995b 100644 --- a/dist/crypto-pro.js.map +++ b/dist/crypto-pro.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/bootstrap decb9d280a6d555831fe","webpack:///./index.js","webpack:///./cades.js","webpack:///../~/bowser/bowser.js","webpack:///../~/webpack/buildin/amd-define.js"],"names":[],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAQ,oBAAoB;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,uBAAe;AACf;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;;;;;;ACzFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA;;AAEA;;AAEA;AACA;AACA;AACA,MAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,UAAS;AACT,MAAK;AACL;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAqB;AACrB,kBAAiB;AACjB;AACA;AACA;AACA,sBAAqB;AACrB;AACA,cAAa;;AAEb;AACA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA,EAAC;AACD;AACA;;AAEA;AACA;AACA,G;;;;;;AC5GA,EAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,UAAS;AACT,MAAK;AACL;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,cAAa;AACb;AACA;;AAEA;AACA;AACA,cAAa;AACb;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,yDAAwD;AACxD;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAiB;AACjB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,cAAa;AACb;AACA;AACA;AACA,kBAAiB;AACjB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAAyB;AACzB;AACA;AACA,sBAAqB;AACrB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,UAAS;AACT;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA,UAAS;AACT;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,sBAAqB;;AAErB;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,UAAS;;AAET;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,cAAa;AACb;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,UAAS;;AAET;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,qCAAoC,iBAAiB,WAAW,UAAU;AAC1E,6BAA4B,aAAa;AACzC;;AAEA;AACA;AACA,2CAA0C;AAC1C,qCAAoC;AACpC,2CAA0C;AAC1C,+CAA8C;AAC9C,+CAA8C;AAC9C,sCAAqC;AACrC,2CAA0C;AAC1C,oCAAmC;AACnC;AACA;AACA;AACA,6CAA4C,iBAAiB,yBAAyB,WAAW;AACjG;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA,sBAAqB;AACrB;AACA;AACA,cAAa;;AAEb;AACA;AACA;AACA,cAAa;;AAEb;AACA;AACA;AACA,cAAa;;AAEb;;AAEA;AACA;AACA,cAAa;AACb,UAAS;AACT;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,cAAa;AACb;AACA;AACA,UAAS;AACT;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA,UAAS;AACT;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA,UAAS;AACT;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,UAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAiB;AACjB;AACA;AACA,cAAa;AACb;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;AACA;;AAEA;AACA;AACA,cAAa;AACb,UAAS;AACT;AACA;AACA;AACA;AACA,kBAAiB;AACjB,cAAa;AACb;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,MAAK;AACL;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA;;AAEA;AACA,EAAC,I;;;;;;;;ACrqBD;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,EAAC;AACD;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8BAA6B;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA,MAAK;AACL;AACA,MAAK;AACL;AACA,MAAK;AACL;AACA,MAAK;AACL;AACA;;AAEA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA,MAAK;AACL;AACA,MAAK;AACL;AACA,MAAK;AACL;AACA,MAAK;AACL;AACA,MAAK;AACL;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAK;;AAEL;AACA;;AAEA;;AAEA;AACA,oBAAmB,wBAAwB;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAc,OAAO;AACrB,eAAc;AACd;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,eAAc,MAAM;AACpB,eAAc,SAAS;AACvB,eAAc;AACd;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,gBAAgB;AAC/B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,sDAAqD;AACrD,mDAAkD;AAClD,mDAAkD;AAClD;AACA,eAAc,cAAc;AAC5B,eAAc,OAAO;AACrB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,QAAO;AACP,MAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAQ;AACR;AACA,eAAc,OAAO;AACrB,eAAc,QAAQ;AACtB,eAAc,OAAO;AACrB,eAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA,uBAAsB;AACtB;;AAEA;AACA;AACA;AACA,eAAc,OAAO;AACrB,eAAc,QAAQ;AACtB,eAAc,OAAO;AACrB,eAAc;AACd;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,EAAC;;;;;;;ACnkBD,8BAA6B,mDAAmD","file":"crypto-pro.js","sourcesContent":[" \t// install a JSONP callback for chunk loading\n \tvar parentJsonpFunction = window[\"webpackJsonpCryptoPro\"];\n \twindow[\"webpackJsonpCryptoPro\"] = function webpackJsonpCallback(chunkIds, moreModules) {\n \t\t// add \"moreModules\" to the modules object,\n \t\t// then flag all \"chunkIds\" as loaded and fire callback\n \t\tvar moduleId, chunkId, i = 0, callbacks = [];\n \t\tfor(;i < chunkIds.length; i++) {\n \t\t\tchunkId = chunkIds[i];\n \t\t\tif(installedChunks[chunkId])\n \t\t\t\tcallbacks.push.apply(callbacks, installedChunks[chunkId]);\n \t\t\tinstalledChunks[chunkId] = 0;\n \t\t}\n \t\tfor(moduleId in moreModules) {\n \t\t\tmodules[moduleId] = moreModules[moduleId];\n \t\t}\n \t\tif(parentJsonpFunction) parentJsonpFunction(chunkIds, moreModules);\n \t\twhile(callbacks.length)\n \t\t\tcallbacks.shift().call(null, __webpack_require__);\n\n \t};\n\n \t// The module cache\n \tvar installedModules = {};\n\n \t// object to store loaded and loading chunks\n \t// \"0\" means \"already loaded\"\n \t// Array means \"loading\", array contains callbacks\n \tvar installedChunks = {\n \t\t0:0\n \t};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n \t// This file contains only the entry chunk.\n \t// The chunk loading function for additional chunks\n \t__webpack_require__.e = function requireEnsure(chunkId, callback) {\n \t\t// \"0\" is the signal for \"already loaded\"\n \t\tif(installedChunks[chunkId] === 0)\n \t\t\treturn callback.call(null, __webpack_require__);\n\n \t\t// an array means \"currently loading\".\n \t\tif(installedChunks[chunkId] !== undefined) {\n \t\t\tinstalledChunks[chunkId].push(callback);\n \t\t} else {\n \t\t\t// start chunk loading\n \t\t\tinstalledChunks[chunkId] = [callback];\n \t\t\tvar head = document.getElementsByTagName('head')[0];\n \t\t\tvar script = document.createElement('script');\n \t\t\tscript.type = 'text/javascript';\n \t\t\tscript.charset = 'utf-8';\n \t\t\tscript.async = true;\n\n \t\t\tscript.src = __webpack_require__.p + \"\" + chunkId + \".crypto-pro.js\";\n \t\t\thead.appendChild(script);\n \t\t}\n \t};\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n/** WEBPACK FOOTER **\n ** webpack/bootstrap decb9d280a6d555831fe\n **/","var bowser = require('bowser/bowser'),\n browserInfo = bowser._detect(navigator.userAgent),\n global = Function('return this')(),\n canPromise = Boolean(global.Promise),\n CryptoProConfig = global.CryptoProConfig,\n canAsync,\n cadesplugin,\n cryptoService,\n _errorMsg = '',\n _isLoaded = false,\n _onLoadCbQueue = [];\n\nglobal.allow_firefox_cadesplugin_async = browserInfo.firefox && browserInfo.version >= 52;\n\nrequire('./cades');\n\ncadesplugin = global.cadesplugin;\n\ncanAsync = Boolean(cadesplugin.CreateObjectAsync);\n\nfunction execOnloadQueue() {\n _onLoadCbQueue.forEach(function (callback) {\n callback();\n });\n}\n\nfunction passToWaitOnLoad(callback) {\n if (Object.prototype.toString.call(callback) === '[object Function]') {\n _onLoadCbQueue.push(callback);\n }\n}\n\nfunction callOnLoad(method) {\n _isLoaded ? method() : passToWaitOnLoad(method);\n}\n\nfunction finishLoading() {\n _isLoaded = true;\n\n execOnloadQueue();\n}\n\nfunction call() {\n var args = Array.prototype.slice.call(arguments),\n methodName = args.shift();\n\n return new Promise(function (resolve, reject) {\n callOnLoad(function () {\n var method;\n\n if (_errorMsg) {\n reject(_errorMsg);\n return;\n }\n\n method = cryptoService[methodName];\n\n if (!method) {\n reject('Метод \"' + methodName + '\" не доступен');\n return;\n }\n\n method.apply(null, args).then(resolve, reject);\n });\n });\n}\n\nif (cadesplugin) {\n canAsync = Boolean(cadesplugin.CreateObjectAsync);\n\n // Уровень отладки (LOG_LEVEL_DEBUG, LOG_LEVEL_INFO, LOG_LEVEL_ERROR)\n cadesplugin.set_log_level(cadesplugin.LOG_LEVEL_ERROR);\n\n // Получаем указанные конфиги\n if (CryptoProConfig && CryptoProConfig.publicPath) {\n __webpack_public_path__ = CryptoProConfig.publicPath;\n }\n\n if (canPromise) {\n cadesplugin.then(\n function () {\n if (canAsync) {\n require.ensure([], function () {\n cryptoService = require('./apiAsync');\n finishLoading();\n });\n } else {\n require.ensure([], function () {\n cryptoService = require('./apiSync');\n finishLoading();\n });\n }\n },\n\n function () {\n _errorMsg = 'КриптоПРО ЭЦП Browser Plug-In не доступен';\n finishLoading();\n }\n );\n } else {\n throw new Error('Не поддерживаются промисы. Необходим полифилл.');\n }\n} else {\n throw new Error('Не подключен модуль для работы с cades plugin');\n}\n\nmodule.exports = {\n call: call\n};\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./index.js\n ** module id = 0\n ** module chunks = 0\n **/",";(function () {\n /**\n * Это переделанная версия cadesplugin_api.js с сайта Крипто ПРО,\n * в которую добавлена поддержка IE-8.\n *\n * Обсуждение:\n * https://www.cryptopro.ru/forum2/default.aspx?g=posts&t=9271\n *\n * Оригинальный файл:\n * https://www.cryptopro.ru/sites/default/files/products/cades/cadesplugin_api.js\n * */\n var pluginObject,\n plugin_resolved = 0,\n plugin_reject,\n plugin_resolve,\n isOpera = 0,\n isYaBrowser = 0,\n isFireFox = 0,\n canPromise = Boolean(window.Promise),\n cadesplugin;\n\n if (window.cadesplugin) {\n return;\n }\n\n if (canPromise) {\n cadesplugin = new Promise(function (resolve, reject) {\n plugin_resolve = resolve;\n plugin_reject = reject;\n });\n } else {\n cadesplugin = {};\n }\n\n function cpcsp_console_log(level, msg) {\n //IE9 не может писать в консоль если не открыта вкладка developer tools\n if (typeof console === 'undefined') {\n return;\n }\n\n if (level <= cadesplugin.current_log_level) {\n if (level == cadesplugin.LOG_LEVEL_DEBUG) {\n console.log('DEBUG: %s', msg);\n }\n\n if (level == cadesplugin.LOG_LEVEL_INFO) {\n console.info('INFO: %s', msg);\n }\n\n if (level == cadesplugin.LOG_LEVEL_ERROR) {\n console.error('ERROR: %s', msg);\n }\n }\n }\n\n function set_log_level(level) {\n var isSetLoglevel = (level == cadesplugin.LOG_LEVEL_DEBUG)\n || (level == cadesplugin.LOG_LEVEL_INFO)\n || (level == cadesplugin.LOG_LEVEL_ERROR);\n\n if (!isSetLoglevel) {\n cpcsp_console_log(cadesplugin.LOG_LEVEL_ERROR, 'cadesplugin_api.js: Incorrect log_level: ' + level);\n\n return;\n }\n\n cadesplugin.current_log_level = level;\n\n if (cadesplugin.current_log_level == cadesplugin.LOG_LEVEL_DEBUG) {\n cpcsp_console_log(cadesplugin.LOG_LEVEL_INFO, 'cadesplugin_api.js: log_level = DEBUG');\n }\n\n if (cadesplugin.current_log_level == cadesplugin.LOG_LEVEL_INFO) {\n cpcsp_console_log(cadesplugin.LOG_LEVEL_INFO, 'cadesplugin_api.js: log_level = INFO');\n }\n\n if (cadesplugin.current_log_level == cadesplugin.LOG_LEVEL_ERROR) {\n cpcsp_console_log(cadesplugin.LOG_LEVEL_INFO, 'cadesplugin_api.js: log_level = ERROR');\n }\n\n if (isNativeMessageSupported()) {\n if (cadesplugin.current_log_level == cadesplugin.LOG_LEVEL_DEBUG) {\n window.postMessage('set_log_level=debug', '*');\n }\n\n if (cadesplugin.current_log_level == cadesplugin.LOG_LEVEL_INFO) {\n window.postMessage('set_log_level=info', '*');\n }\n\n if (cadesplugin.current_log_level == cadesplugin.LOG_LEVEL_ERROR) {\n window.postMessage('set_log_level=error', '*');\n }\n }\n }\n\n function set_constantValues() {\n cadesplugin.CAPICOM_LOCAL_MACHINE_STORE = 1;\n cadesplugin.CAPICOM_CURRENT_USER_STORE = 2;\n cadesplugin.CADESCOM_LOCAL_MACHINE_STORE = 1;\n cadesplugin.CADESCOM_CURRENT_USER_STORE = 2;\n cadesplugin.CADESCOM_CONTAINER_STORE = 100;\n cadesplugin.CAPICOM_MY_STORE = 'My';\n cadesplugin.CAPICOM_STORE_OPEN_MAXIMUM_ALLOWED = 2;\n cadesplugin.CAPICOM_CERTIFICATE_FIND_SUBJECT_NAME = 1;\n cadesplugin.CADESCOM_XML_SIGNATURE_TYPE_ENVELOPED = 0;\n cadesplugin.CADESCOM_XML_SIGNATURE_TYPE_ENVELOPING = 1;\n cadesplugin.CADESCOM_XML_SIGNATURE_TYPE_TEMPLATE = 2;\n cadesplugin.XmlDsigGost3410UrlObsolete = 'http://www.w3.org/2001/04/xmldsig-more#gostr34102001-gostr3411';\n cadesplugin.XmlDsigGost3411UrlObsolete = 'http://www.w3.org/2001/04/xmldsig-more#gostr3411';\n cadesplugin.XmlDsigGost3410Url = 'urn:ietf:params:xml:ns:cpxmlsec:algorithms:gostr34102001-gostr3411';\n cadesplugin.XmlDsigGost3411Url = 'urn:ietf:params:xml:ns:cpxmlsec:algorithms:gostr3411';\n cadesplugin.CADESCOM_CADES_DEFAULT = 0;\n cadesplugin.CADESCOM_CADES_BES = 1;\n cadesplugin.CADESCOM_CADES_T = 0x5;\n cadesplugin.CADESCOM_CADES_X_LONG_TYPE_1 = 0x5d;\n cadesplugin.CADESCOM_ENCODE_BASE64 = 0;\n cadesplugin.CADESCOM_ENCODE_BINARY = 1;\n cadesplugin.CADESCOM_ENCODE_ANY = -1;\n cadesplugin.CAPICOM_CERTIFICATE_INCLUDE_CHAIN_EXCEPT_ROOT = 0;\n cadesplugin.CAPICOM_CERTIFICATE_INCLUDE_WHOLE_CHAIN = 1;\n cadesplugin.CAPICOM_CERTIFICATE_INCLUDE_END_ENTITY_ONLY = 2;\n cadesplugin.CAPICOM_CERT_INFO_SUBJECT_SIMPLE_NAME = 0;\n cadesplugin.CAPICOM_CERT_INFO_ISSUER_SIMPLE_NAME = 1;\n cadesplugin.CAPICOM_CERTIFICATE_FIND_SHA1_HASH = 0;\n cadesplugin.CAPICOM_CERTIFICATE_FIND_SUBJECT_NAME = 1;\n cadesplugin.CAPICOM_CERTIFICATE_FIND_ISSUER_NAME = 2;\n cadesplugin.CAPICOM_CERTIFICATE_FIND_ROOT_NAME = 3;\n cadesplugin.CAPICOM_CERTIFICATE_FIND_TEMPLATE_NAME = 4;\n cadesplugin.CAPICOM_CERTIFICATE_FIND_EXTENSION = 5;\n cadesplugin.CAPICOM_CERTIFICATE_FIND_EXTENDED_PROPERTY = 6;\n cadesplugin.CAPICOM_CERTIFICATE_FIND_APPLICATION_POLICY = 7;\n cadesplugin.CAPICOM_CERTIFICATE_FIND_CERTIFICATE_POLICY = 8;\n cadesplugin.CAPICOM_CERTIFICATE_FIND_TIME_VALID = 9;\n cadesplugin.CAPICOM_CERTIFICATE_FIND_TIME_NOT_YET_VALID = 10;\n cadesplugin.CAPICOM_CERTIFICATE_FIND_TIME_EXPIRED = 11;\n cadesplugin.CAPICOM_CERTIFICATE_FIND_KEY_USAGE = 12;\n cadesplugin.CAPICOM_DIGITAL_SIGNATURE_KEY_USAGE = 128;\n cadesplugin.CAPICOM_PROPID_ENHKEY_USAGE = 9;\n cadesplugin.CAPICOM_OID_OTHER = 0;\n cadesplugin.CAPICOM_OID_KEY_USAGE_EXTENSION = 10;\n cadesplugin.CAPICOM_EKU_CLIENT_AUTH = 2;\n cadesplugin.CAPICOM_EKU_SMARTCARD_LOGON = 5;\n cadesplugin.CAPICOM_EKU_OTHER = 0;\n cadesplugin.CAPICOM_AUTHENTICATED_ATTRIBUTE_SIGNING_TIME = 0;\n cadesplugin.CADESCOM_AUTHENTICATED_ATTRIBUTE_DOCUMENT_NAME = 1;\n cadesplugin.CADESCOM_AUTHENTICATED_ATTRIBUTE_DOCUMENT_DESCRIPTION = 2;\n cadesplugin.CADESCOM_ATTRIBUTE_OTHER = -1;\n cadesplugin.CADESCOM_STRING_TO_UCS2LE = 0;\n cadesplugin.CADESCOM_BASE64_TO_BINARY = 1;\n cadesplugin.CADESCOM_DISPLAY_DATA_NONE = 0;\n cadesplugin.CADESCOM_DISPLAY_DATA_CONTENT = 1;\n cadesplugin.CADESCOM_DISPLAY_DATA_ATTRIBUTE = 2;\n cadesplugin.CADESCOM_ENCRYPTION_ALGORITHM_RC2 = 0;\n cadesplugin.CADESCOM_ENCRYPTION_ALGORITHM_RC4 = 1;\n cadesplugin.CADESCOM_ENCRYPTION_ALGORITHM_DES = 2;\n cadesplugin.CADESCOM_ENCRYPTION_ALGORITHM_3DES = 3;\n cadesplugin.CADESCOM_ENCRYPTION_ALGORITHM_AES = 4;\n cadesplugin.CADESCOM_ENCRYPTION_ALGORITHM_GOST_28147_89 = 25;\n cadesplugin.CADESCOM_HASH_ALGORITHM_SHA1 = 0;\n cadesplugin.CADESCOM_HASH_ALGORITHM_MD2 = 1;\n cadesplugin.CADESCOM_HASH_ALGORITHM_MD4 = 2;\n cadesplugin.CADESCOM_HASH_ALGORITHM_MD5 = 3;\n cadesplugin.CADESCOM_HASH_ALGORITHM_SHA_256 = 4;\n cadesplugin.CADESCOM_HASH_ALGORITHM_SHA_384 = 5;\n cadesplugin.CADESCOM_HASH_ALGORITHM_SHA_512 = 6;\n cadesplugin.CADESCOM_HASH_ALGORITHM_CP_GOST_3411 = 100;\n cadesplugin.CADESCOM_HASH_ALGORITHM_CP_GOST_3411_2012_256 = 101;\n cadesplugin.CADESCOM_HASH_ALGORITHM_CP_GOST_3411_2012_512 = 102;\n cadesplugin.LOG_LEVEL_DEBUG = 4;\n cadesplugin.LOG_LEVEL_INFO = 2;\n cadesplugin.LOG_LEVEL_ERROR = 1;\n }\n\n function async_spawn(generatorFunc) {\n var generator = generatorFunc(Array.prototype.slice.call(arguments, 1)),\n onFulfilled = continuer.bind(continuer, 'next'),\n onRejected = continuer.bind(continuer, 'throw');\n\n function continuer(verb, arg) {\n var result;\n\n try {\n result = generator[verb](arg);\n } catch (err) {\n return Promise.reject(err);\n }\n\n if (result.done) {\n return result.value;\n } else {\n return Promise.resolve(result.value).then(onFulfilled, onRejected);\n }\n }\n\n return onFulfilled();\n }\n\n function isIE() {\n return navigator.appName === 'Microsoft Internet Explorer' // IE < 11\n || navigator.userAgent.match(/Trident\\/./i); // IE 11\n }\n\n function isIOS() {\n return navigator.userAgent.match(/ipod/i)\n || navigator.userAgent.match(/ipad/i)\n || navigator.userAgent.match(/iphone/i);\n }\n\n function isNativeMessageSupported() {\n var retVal_chrome = navigator.userAgent.match(/chrome/i);\n\n isOpera = navigator.userAgent.match(/opr/i);\n isYaBrowser = navigator.userAgent.match(/YaBrowser/i);\n isFireFox = navigator.userAgent.match(/Firefox/i);\n\n if (isFireFox && window.allow_firefox_cadesplugin_async) {\n return true;\n }\n\n if (retVal_chrome == null) {\n // В IE работаем через NPAPI\n return false;\n } else {\n // В Chrome и Opera работаем через асинхронную версию\n if (retVal_chrome.length > 0 || isOpera != null) {\n return true;\n }\n }\n\n return false;\n }\n\n // Функция активации объектов КриптоПро ЭЦП Browser plug-in\n function CreateObject(name) {\n if (isIOS()) {\n // На iOS для создания объектов используется функция\n // call_ru_cryptopro_npcades_10_native_bridge, определенная в IOS_npcades_supp.js\n return call_ru_cryptopro_npcades_10_native_bridge('CreateObject', [name]);\n }\n\n if (isIE()) {\n // В Internet Explorer создаются COM-объекты\n if (name.match(/X509Enrollment/i)) {\n try {\n // Объекты CertEnroll создаются через CX509EnrollmentWebClassFactory\n var objCertEnrollClassFactory = document.getElementById('certEnrollClassFactory');\n return objCertEnrollClassFactory.CreateObject(name);\n } catch (e) {\n throw(\n 'Для создания обьектов X509Enrollment следует настроить ' +\n 'веб-узел на использование проверки подлинности по протоколу HTTPS'\n );\n }\n }\n\n // Объекты CAPICOM и CAdESCOM создаются через CAdESCOM.WebClassFactory\n try {\n var objWebClassFactory = document.getElementById('webClassFactory');\n\n return objWebClassFactory.CreateObject(name);\n } catch (e) {\n try {\n // Для версий плагина ниже 2.0.12538\n return new ActiveXObject(name);\n } catch (e) {\n var mimetype = navigator.mimeTypes['application/x-cades'];\n\n if (mimetype) {\n if (mimetype.enabledPlugin) {\n console.log(\n 'EDS:',\n 'Плагин КриптоПРО ЭЦП browser plug-in загружен,',\n 'но не создаются обьекты'\n );\n } else {\n console.log('EDS:', 'Ошибка при загрузке плагина КриптоПРО ЭЦП browser plug-in');\n }\n } else {\n console.log('EDS:', 'Плагин КриптоПРО ЭЦП browser plug-in недоступен');\n }\n }\n }\n }\n\n // В Firefox, Safari создаются объекты NPAPI\n return pluginObject.CreateObject(name);\n }\n\n function decimalToHexString(number) {\n if (number < 0) {\n number = 0xFFFFFFFF + number + 1;\n }\n\n return number.toString(16).toUpperCase();\n }\n\n function GetMessageFromException(e) {\n var err = e.message;\n\n if (!err) {\n err = e;\n } else if (e.number) {\n err += ' (0x' + decimalToHexString(e.number) + ')';\n }\n\n return err;\n }\n\n function getLastError(exception) {\n if (isNativeMessageSupported() || isIE() || isIOS()) {\n return GetMessageFromException(exception);\n }\n\n try {\n return pluginObject.getLastError();\n } catch (e) {\n return GetMessageFromException(exception);\n }\n }\n\n // Функция активации асинхронных объектов КриптоПро ЭЦП Browser plug-in\n function CreateObjectAsync(name) {\n return pluginObject.CreateObjectAsync(name);\n }\n\n // Функции для IOS\n var ru_cryptopro_npcades_10_native_bridge = {\n callbacksCount: 1,\n callbacks: {},\n\n // Automatically called by native layer when a result is available\n resultForCallback: function resultForCallback(callbackId, resultArray) {\n var callback = ru_cryptopro_npcades_10_native_bridge.callbacks[callbackId];\n\n if (!callback) {\n return;\n }\n\n callback.apply(null, resultArray);\n },\n\n // Use this in javascript to request native objective-c code\n // functionName : string (I think the name is explicit :p)\n // args : array of arguments\n // callback : function with n-arguments that is going to be called when the native code returned\n call: function call(functionName, args, callback) {\n var hasCallback = callback && typeof callback == 'function',\n callbackId = hasCallback ? ru_cryptopro_npcades_10_native_bridge.callbacksCount++ : 0,\n iframe,\n arrObjs;\n\n if (hasCallback) {\n ru_cryptopro_npcades_10_native_bridge.callbacks[callbackId] = callback;\n }\n\n iframe = document.createElement('IFRAME');\n\n arrObjs = new Array('_CPNP_handle');\n\n try {\n iframe.setAttribute(\n 'src',\n 'cpnp-js-call:' +\n functionName + ':' + callbackId + ':' + encodeURIComponent(JSON.stringify(args, arrObjs))\n );\n } catch (e) {\n alert(e);\n }\n\n document.documentElement.appendChild(iframe);\n\n iframe.parentNode.removeChild(iframe);\n iframe = null;\n }\n };\n\n function call_ru_cryptopro_npcades_10_native_bridge(functionName, array) {\n var tmpobj,\n ex;\n\n ru_cryptopro_npcades_10_native_bridge.call(functionName, array, function (e, response) {\n ex = e;\n var str = 'tmpobj=' + response;\n\n eval(str);\n\n if (typeof (tmpobj) == 'string') {\n tmpobj = tmpobj.replace(/\\\\\\n/gm, '\\n');\n tmpobj = tmpobj.replace(/\\\\\\r/gm, '\\r');\n }\n });\n\n if (ex) {\n throw ex;\n }\n\n return tmpobj;\n }\n\n // Выводим окно поверх других с предложением установить расширение для Opera.\n // Если установленна переменная cadesplugin_skip_extension_install - не предлагаем установить расширение\n function install_opera_extension() {\n if (!window.cadesplugin_skip_extension_install) {\n var ovr = document.createElement('div');\n\n ovr.id = 'cadesplugin_ovr';\n ovr.style = [\n 'visibility: hidden; position: fixed; left: 0px; top: 0px;',\n 'width:100%; height:100%; background-color: rgba(0,0,0,0.7)'\n ].join(' ');\n\n ovr.innerHTML = '\\\n
\\\n \\\n

\\\n Для работы КриптоПро ЭЦП Browser plugin на данном сайте необходимо установить\\\n расширение из каталога дополнений Opera.\\\n

\\\n

\\\n
\\\n ';\n\n document.getElementsByTagName('Body')[0].appendChild(ovr);\n\n var btn_install = document.getElementById('cadesplugin_install');\n\n btn_install.addEventListener('click', function (event) {\n opr.addons.installExtension('epebfcehmdedogndhlcacafjaacknbcm',\n function () {\n document.getElementById('cadesplugin_ovr').style.visibility = 'hidden';\n location.reload();\n },\n function () {}\n );\n });\n\n document.getElementById('cadesplugin_close_install').addEventListener('click', function () {\n plugin_loaded_error('Плагин недоступен');\n document.getElementById('cadesplugin_ovr').style.visibility = 'hidden';\n });\n\n ovr.addEventListener('click', function () {\n plugin_loaded_error('Плагин недоступен');\n document.getElementById('cadesplugin_ovr').style.visibility = 'hidden';\n });\n\n ovr.style.visibility = 'visible';\n\n document.getElementById('cadesplugin_ovr_item').addEventListener('click', function (e) {\n e.stopPropagation();\n });\n } else {\n plugin_loaded_error('Плагин недоступен');\n }\n }\n\n function firefox_nmcades_onload() {\n window.cpcsp_chrome_nmcades.check_chrome_plugin(plugin_loaded, plugin_loaded_error);\n }\n\n function nmcades_api_onload() {\n window.postMessage('cadesplugin_echo_request', '*');\n\n window.addEventListener('message', function (event) {\n if (typeof event.data !== 'string' || !event.data.match('cadesplugin_loaded')) {\n return;\n }\n\n if (isFireFox) {\n // Для Firefox вместе с сообщением cadesplugin_loaded прилетает url для загрузки nmcades_plugin_api.js\n var url = event.data.substring(event.data.indexOf('url:') + 4);\n var fileref = document.createElement('script');\n\n fileref.setAttribute('type', 'text/javascript');\n fileref.setAttribute('src', url);\n fileref.onerror = plugin_loaded_error;\n fileref.onload = firefox_nmcades_onload;\n document.getElementsByTagName('head')[0].appendChild(fileref);\n } else {\n cpcsp_chrome_nmcades.check_chrome_plugin(plugin_loaded, plugin_loaded_error);\n }\n }, false);\n }\n\n //Загружаем расширения для Chrome, Opera, YaBrowser, FireFox, Edge\n function load_extension() {\n if (isFireFox) {\n // вызываем callback руками т.к. нам нужно узнать ID расширения. Он уникальный для браузера.\n nmcades_api_onload();\n return;\n } else {\n var fileref = document.createElement('script'),\n hash = isNativeMessageSupported() && isOpera ? 'epebfcehmdedogndhlcacafjaacknbcm' : 'iifchhfnnmpdbibifmljnfjhpififfog';\n\n if (hash) {\n fileref.setAttribute('type', 'text/javascript');\n fileref.setAttribute('src', 'chrome-extension://' + hash + '/nmcades_plugin_api.js');\n fileref.onerror = plugin_loaded_error;\n fileref.onload = nmcades_api_onload;\n document.getElementsByTagName('head')[0].appendChild(fileref);\n }\n }\n }\n\n // Загружаем плагин для NPAPI\n function load_npapi_plugin() {\n var elem = document.createElement('object');\n\n elem.setAttribute('id', 'cadesplugin_object');\n elem.setAttribute('type', 'application/x-cades');\n elem.setAttribute('style', 'visibility: hidden');\n document.getElementsByTagName('body')[0].appendChild(elem);\n\n pluginObject = document.getElementById('cadesplugin_object');\n\n if (isIE()) {\n var elem1 = document.createElement('object');\n\n elem1.setAttribute('id', 'certEnrollClassFactory');\n elem1.setAttribute('classid', 'clsid:884e2049-217d-11da-b2a4-000e7bbb2b09');\n elem1.setAttribute('style', 'visibility: hidden');\n document.getElementsByTagName('body')[0].appendChild(elem1);\n\n var elem2 = document.createElement('object');\n elem2.setAttribute('id', 'webClassFactory');\n elem2.setAttribute('classid', 'clsid:B04C8637-10BD-484E-B0DA-B8A039F60024');\n elem2.setAttribute('style', 'visibility: hidden');\n\n document.getElementsByTagName('body')[0].appendChild(elem2);\n }\n }\n\n // Отправляем событие что все ок.\n function plugin_loaded() {\n plugin_resolved = 1;\n if (canPromise) {\n plugin_resolve();\n } else {\n window.postMessage('cadesplugin_loaded', '*');\n }\n }\n\n // Отправляем событие что сломались.\n function plugin_loaded_error(msg) {\n if (isNativeMessageSupported()) {\n if (isOpera && (typeof(msg) == 'undefined' || typeof(msg) == 'object')) {\n install_opera_extension();\n return;\n }\n }\n\n if (typeof(msg) == 'undefined' || typeof(msg) == 'object') {\n msg = 'Плагин недоступен';\n }\n\n plugin_resolved = 1;\n\n if (canPromise) {\n plugin_reject(msg);\n } else {\n window.postMessage('cadesplugin_load_error', '*');\n }\n }\n\n // проверяем что у нас хоть какое то событие ушло, и если не уходило кидаем еще раз ошибку\n function check_load_timeout() {\n if (plugin_resolved == 1) {\n return;\n }\n\n plugin_resolved = 1;\n\n if (canPromise) {\n plugin_reject('Истекло время ожидания загрузки плагина');\n } else {\n window.postMessage('cadesplugin_load_error', '*');\n }\n }\n\n function check_npapi_plugin() {\n try {\n var oAbout = CreateObject('CAdESCOM.About');\n\n plugin_loaded();\n } catch (err) {\n document.getElementById('cadesplugin_object').style.display = 'none';\n // Объект создать не удалось, проверим, установлен ли\n // вообще плагин. Такая возможность есть не во всех браузерах\n var mimetype = navigator.mimeTypes['application/x-cades'];\n if (mimetype) {\n var plugin = mimetype.enabledPlugin;\n if (plugin) {\n plugin_loaded_error('Плагин загружен, но не создаются обьекты');\n } else {\n plugin_loaded_error('Ошибка при загрузке плагина');\n }\n } else {\n plugin_loaded_error('Плагин недоступен');\n }\n }\n }\n\n // Проверяем работает ли плагин\n function check_plugin_working() {\n if (isNativeMessageSupported()) {\n load_extension();\n } else if (!canPromise) {\n window.addEventListener('message', function (event) {\n if (event.data != 'cadesplugin_echo_request') {\n return;\n }\n\n load_npapi_plugin();\n check_npapi_plugin();\n }, false);\n } else {\n if (window.addEventListener) {\n window.addEventListener('load', function (event) {\n load_npapi_plugin();\n check_npapi_plugin();\n }, false);\n } else {\n load_npapi_plugin();\n check_npapi_plugin();\n }\n }\n }\n\n function set_pluginObject(obj) {\n pluginObject = obj;\n }\n\n // Export\n cadesplugin.JSModuleVersion = '2.1.0';\n cadesplugin.async_spawn = async_spawn;\n cadesplugin.set = set_pluginObject;\n cadesplugin.set_log_level = set_log_level;\n cadesplugin.getLastError = getLastError;\n\n if (isNativeMessageSupported()) {\n cadesplugin.CreateObjectAsync = CreateObjectAsync;\n }\n\n if (!isNativeMessageSupported()) {\n cadesplugin.CreateObject = CreateObject;\n }\n\n if (window.cadesplugin_load_timeout) {\n setTimeout(check_load_timeout, window.cadesplugin_load_timeout);\n } else {\n /**\n * Даже при слабом интернете плагин успевает загрузиться\n * менее чем за секунду, тк отдается из кэша\n * */\n setTimeout(check_load_timeout, 20000);\n }\n\n set_constantValues();\n\n cadesplugin.current_log_level = cadesplugin.LOG_LEVEL_ERROR;\n\n window.cadesplugin = cadesplugin;\n\n check_plugin_working();\n}());\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./cades.js\n ** module id = 1\n ** module chunks = 0\n **/","/*!\n * Bowser - a browser detector\n * https://github.com/ded/bowser\n * MIT License | (c) Dustin Diaz 2015\n */\n\n!function (name, definition) {\n if (typeof module != 'undefined' && module.exports) module.exports = definition()\n else if (typeof define == 'function' && define.amd) define(name, definition)\n else this[name] = definition()\n}('bowser', function () {\n /**\n * See useragents.js for examples of navigator.userAgent\n */\n\n var t = true\n\n function detect(ua) {\n\n function getFirstMatch(regex) {\n var match = ua.match(regex);\n return (match && match.length > 1 && match[1]) || '';\n }\n\n function getSecondMatch(regex) {\n var match = ua.match(regex);\n return (match && match.length > 1 && match[2]) || '';\n }\n\n var iosdevice = getFirstMatch(/(ipod|iphone|ipad)/i).toLowerCase()\n , likeAndroid = /like android/i.test(ua)\n , android = !likeAndroid && /android/i.test(ua)\n , nexusMobile = /nexus\\s*[0-6]\\s*/i.test(ua)\n , nexusTablet = !nexusMobile && /nexus\\s*[0-9]+/i.test(ua)\n , chromeos = /CrOS/.test(ua)\n , silk = /silk/i.test(ua)\n , sailfish = /sailfish/i.test(ua)\n , tizen = /tizen/i.test(ua)\n , webos = /(web|hpw)os/i.test(ua)\n , windowsphone = /windows phone/i.test(ua)\n , samsungBrowser = /SamsungBrowser/i.test(ua)\n , windows = !windowsphone && /windows/i.test(ua)\n , mac = !iosdevice && !silk && /macintosh/i.test(ua)\n , linux = !android && !sailfish && !tizen && !webos && /linux/i.test(ua)\n , edgeVersion = getFirstMatch(/edge\\/(\\d+(\\.\\d+)?)/i)\n , versionIdentifier = getFirstMatch(/version\\/(\\d+(\\.\\d+)?)/i)\n , tablet = /tablet/i.test(ua)\n , mobile = !tablet && /[^-]mobi/i.test(ua)\n , xbox = /xbox/i.test(ua)\n , result\n\n if (/opera/i.test(ua)) {\n // an old Opera\n result = {\n name: 'Opera'\n , opera: t\n , version: versionIdentifier || getFirstMatch(/(?:opera|opr|opios)[\\s\\/](\\d+(\\.\\d+)?)/i)\n }\n } else if (/opr|opios/i.test(ua)) {\n // a new Opera\n result = {\n name: 'Opera'\n , opera: t\n , version: getFirstMatch(/(?:opr|opios)[\\s\\/](\\d+(\\.\\d+)?)/i) || versionIdentifier\n }\n }\n else if (/SamsungBrowser/i.test(ua)) {\n result = {\n name: 'Samsung Internet for Android'\n , samsungBrowser: t\n , version: versionIdentifier || getFirstMatch(/(?:SamsungBrowser)[\\s\\/](\\d+(\\.\\d+)?)/i)\n }\n }\n else if (/coast/i.test(ua)) {\n result = {\n name: 'Opera Coast'\n , coast: t\n , version: versionIdentifier || getFirstMatch(/(?:coast)[\\s\\/](\\d+(\\.\\d+)?)/i)\n }\n }\n else if (/yabrowser/i.test(ua)) {\n result = {\n name: 'Yandex Browser'\n , yandexbrowser: t\n , version: versionIdentifier || getFirstMatch(/(?:yabrowser)[\\s\\/](\\d+(\\.\\d+)?)/i)\n }\n }\n else if (/ucbrowser/i.test(ua)) {\n result = {\n name: 'UC Browser'\n , ucbrowser: t\n , version: getFirstMatch(/(?:ucbrowser)[\\s\\/](\\d+(?:\\.\\d+)+)/i)\n }\n }\n else if (/mxios/i.test(ua)) {\n result = {\n name: 'Maxthon'\n , maxthon: t\n , version: getFirstMatch(/(?:mxios)[\\s\\/](\\d+(?:\\.\\d+)+)/i)\n }\n }\n else if (/epiphany/i.test(ua)) {\n result = {\n name: 'Epiphany'\n , epiphany: t\n , version: getFirstMatch(/(?:epiphany)[\\s\\/](\\d+(?:\\.\\d+)+)/i)\n }\n }\n else if (/puffin/i.test(ua)) {\n result = {\n name: 'Puffin'\n , puffin: t\n , version: getFirstMatch(/(?:puffin)[\\s\\/](\\d+(?:\\.\\d+)?)/i)\n }\n }\n else if (/sleipnir/i.test(ua)) {\n result = {\n name: 'Sleipnir'\n , sleipnir: t\n , version: getFirstMatch(/(?:sleipnir)[\\s\\/](\\d+(?:\\.\\d+)+)/i)\n }\n }\n else if (/k-meleon/i.test(ua)) {\n result = {\n name: 'K-Meleon'\n , kMeleon: t\n , version: getFirstMatch(/(?:k-meleon)[\\s\\/](\\d+(?:\\.\\d+)+)/i)\n }\n }\n else if (windowsphone) {\n result = {\n name: 'Windows Phone'\n , windowsphone: t\n }\n if (edgeVersion) {\n result.msedge = t\n result.version = edgeVersion\n }\n else {\n result.msie = t\n result.version = getFirstMatch(/iemobile\\/(\\d+(\\.\\d+)?)/i)\n }\n }\n else if (/msie|trident/i.test(ua)) {\n result = {\n name: 'Internet Explorer'\n , msie: t\n , version: getFirstMatch(/(?:msie |rv:)(\\d+(\\.\\d+)?)/i)\n }\n } else if (chromeos) {\n result = {\n name: 'Chrome'\n , chromeos: t\n , chromeBook: t\n , chrome: t\n , version: getFirstMatch(/(?:chrome|crios|crmo)\\/(\\d+(\\.\\d+)?)/i)\n }\n } else if (/chrome.+? edge/i.test(ua)) {\n result = {\n name: 'Microsoft Edge'\n , msedge: t\n , version: edgeVersion\n }\n }\n else if (/vivaldi/i.test(ua)) {\n result = {\n name: 'Vivaldi'\n , vivaldi: t\n , version: getFirstMatch(/vivaldi\\/(\\d+(\\.\\d+)?)/i) || versionIdentifier\n }\n }\n else if (sailfish) {\n result = {\n name: 'Sailfish'\n , sailfish: t\n , version: getFirstMatch(/sailfish\\s?browser\\/(\\d+(\\.\\d+)?)/i)\n }\n }\n else if (/seamonkey\\//i.test(ua)) {\n result = {\n name: 'SeaMonkey'\n , seamonkey: t\n , version: getFirstMatch(/seamonkey\\/(\\d+(\\.\\d+)?)/i)\n }\n }\n else if (/firefox|iceweasel|fxios/i.test(ua)) {\n result = {\n name: 'Firefox'\n , firefox: t\n , version: getFirstMatch(/(?:firefox|iceweasel|fxios)[ \\/](\\d+(\\.\\d+)?)/i)\n }\n if (/\\((mobile|tablet);[^\\)]*rv:[\\d\\.]+\\)/i.test(ua)) {\n result.firefoxos = t\n }\n }\n else if (silk) {\n result = {\n name: 'Amazon Silk'\n , silk: t\n , version : getFirstMatch(/silk\\/(\\d+(\\.\\d+)?)/i)\n }\n }\n else if (/phantom/i.test(ua)) {\n result = {\n name: 'PhantomJS'\n , phantom: t\n , version: getFirstMatch(/phantomjs\\/(\\d+(\\.\\d+)?)/i)\n }\n }\n else if (/slimerjs/i.test(ua)) {\n result = {\n name: 'SlimerJS'\n , slimer: t\n , version: getFirstMatch(/slimerjs\\/(\\d+(\\.\\d+)?)/i)\n }\n }\n else if (/blackberry|\\bbb\\d+/i.test(ua) || /rim\\stablet/i.test(ua)) {\n result = {\n name: 'BlackBerry'\n , blackberry: t\n , version: versionIdentifier || getFirstMatch(/blackberry[\\d]+\\/(\\d+(\\.\\d+)?)/i)\n }\n }\n else if (webos) {\n result = {\n name: 'WebOS'\n , webos: t\n , version: versionIdentifier || getFirstMatch(/w(?:eb)?osbrowser\\/(\\d+(\\.\\d+)?)/i)\n };\n /touchpad\\//i.test(ua) && (result.touchpad = t)\n }\n else if (/bada/i.test(ua)) {\n result = {\n name: 'Bada'\n , bada: t\n , version: getFirstMatch(/dolfin\\/(\\d+(\\.\\d+)?)/i)\n };\n }\n else if (tizen) {\n result = {\n name: 'Tizen'\n , tizen: t\n , version: getFirstMatch(/(?:tizen\\s?)?browser\\/(\\d+(\\.\\d+)?)/i) || versionIdentifier\n };\n }\n else if (/qupzilla/i.test(ua)) {\n result = {\n name: 'QupZilla'\n , qupzilla: t\n , version: getFirstMatch(/(?:qupzilla)[\\s\\/](\\d+(?:\\.\\d+)+)/i) || versionIdentifier\n }\n }\n else if (/chromium/i.test(ua)) {\n result = {\n name: 'Chromium'\n , chromium: t\n , version: getFirstMatch(/(?:chromium)[\\s\\/](\\d+(?:\\.\\d+)?)/i) || versionIdentifier\n }\n }\n else if (/chrome|crios|crmo/i.test(ua)) {\n result = {\n name: 'Chrome'\n , chrome: t\n , version: getFirstMatch(/(?:chrome|crios|crmo)\\/(\\d+(\\.\\d+)?)/i)\n }\n }\n else if (android) {\n result = {\n name: 'Android'\n , version: versionIdentifier\n }\n }\n else if (/safari|applewebkit/i.test(ua)) {\n result = {\n name: 'Safari'\n , safari: t\n }\n if (versionIdentifier) {\n result.version = versionIdentifier\n }\n }\n else if (iosdevice) {\n result = {\n name : iosdevice == 'iphone' ? 'iPhone' : iosdevice == 'ipad' ? 'iPad' : 'iPod'\n }\n // WTF: version is not part of user agent in web apps\n if (versionIdentifier) {\n result.version = versionIdentifier\n }\n }\n else if(/googlebot/i.test(ua)) {\n result = {\n name: 'Googlebot'\n , googlebot: t\n , version: getFirstMatch(/googlebot\\/(\\d+(\\.\\d+))/i) || versionIdentifier\n }\n }\n else {\n result = {\n name: getFirstMatch(/^(.*)\\/(.*) /),\n version: getSecondMatch(/^(.*)\\/(.*) /)\n };\n }\n\n // set webkit or gecko flag for browsers based on these engines\n if (!result.msedge && /(apple)?webkit/i.test(ua)) {\n if (/(apple)?webkit\\/537\\.36/i.test(ua)) {\n result.name = result.name || \"Blink\"\n result.blink = t\n } else {\n result.name = result.name || \"Webkit\"\n result.webkit = t\n }\n if (!result.version && versionIdentifier) {\n result.version = versionIdentifier\n }\n } else if (!result.opera && /gecko\\//i.test(ua)) {\n result.name = result.name || \"Gecko\"\n result.gecko = t\n result.version = result.version || getFirstMatch(/gecko\\/(\\d+(\\.\\d+)?)/i)\n }\n\n // set OS flags for platforms that have multiple browsers\n if (!result.windowsphone && !result.msedge && (android || result.silk)) {\n result.android = t\n } else if (!result.windowsphone && !result.msedge && iosdevice) {\n result[iosdevice] = t\n result.ios = t\n } else if (mac) {\n result.mac = t\n } else if (xbox) {\n result.xbox = t\n } else if (windows) {\n result.windows = t\n } else if (linux) {\n result.linux = t\n }\n\n // OS version extraction\n var osVersion = '';\n if (result.windowsphone) {\n osVersion = getFirstMatch(/windows phone (?:os)?\\s?(\\d+(\\.\\d+)*)/i);\n } else if (iosdevice) {\n osVersion = getFirstMatch(/os (\\d+([_\\s]\\d+)*) like mac os x/i);\n osVersion = osVersion.replace(/[_\\s]/g, '.');\n } else if (android) {\n osVersion = getFirstMatch(/android[ \\/-](\\d+(\\.\\d+)*)/i);\n } else if (result.webos) {\n osVersion = getFirstMatch(/(?:web|hpw)os\\/(\\d+(\\.\\d+)*)/i);\n } else if (result.blackberry) {\n osVersion = getFirstMatch(/rim\\stablet\\sos\\s(\\d+(\\.\\d+)*)/i);\n } else if (result.bada) {\n osVersion = getFirstMatch(/bada\\/(\\d+(\\.\\d+)*)/i);\n } else if (result.tizen) {\n osVersion = getFirstMatch(/tizen[\\/\\s](\\d+(\\.\\d+)*)/i);\n }\n if (osVersion) {\n result.osversion = osVersion;\n }\n\n // device type extraction\n var osMajorVersion = osVersion.split('.')[0];\n if (\n tablet\n || nexusTablet\n || iosdevice == 'ipad'\n || (android && (osMajorVersion == 3 || (osMajorVersion >= 4 && !mobile)))\n || result.silk\n ) {\n result.tablet = t\n } else if (\n mobile\n || iosdevice == 'iphone'\n || iosdevice == 'ipod'\n || android\n || nexusMobile\n || result.blackberry\n || result.webos\n || result.bada\n ) {\n result.mobile = t\n }\n\n // Graded Browser Support\n // http://developer.yahoo.com/yui/articles/gbs\n if (result.msedge ||\n (result.msie && result.version >= 10) ||\n (result.yandexbrowser && result.version >= 15) ||\n\t\t (result.vivaldi && result.version >= 1.0) ||\n (result.chrome && result.version >= 20) ||\n (result.samsungBrowser && result.version >= 4) ||\n (result.firefox && result.version >= 20.0) ||\n (result.safari && result.version >= 6) ||\n (result.opera && result.version >= 10.0) ||\n (result.ios && result.osversion && result.osversion.split(\".\")[0] >= 6) ||\n (result.blackberry && result.version >= 10.1)\n || (result.chromium && result.version >= 20)\n ) {\n result.a = t;\n }\n else if ((result.msie && result.version < 10) ||\n (result.chrome && result.version < 20) ||\n (result.firefox && result.version < 20.0) ||\n (result.safari && result.version < 6) ||\n (result.opera && result.version < 10.0) ||\n (result.ios && result.osversion && result.osversion.split(\".\")[0] < 6)\n || (result.chromium && result.version < 20)\n ) {\n result.c = t\n } else result.x = t\n\n return result\n }\n\n var bowser = detect(typeof navigator !== 'undefined' ? navigator.userAgent || '' : '')\n\n bowser.test = function (browserList) {\n for (var i = 0; i < browserList.length; ++i) {\n var browserItem = browserList[i];\n if (typeof browserItem=== 'string') {\n if (browserItem in bowser) {\n return true;\n }\n }\n }\n return false;\n }\n\n /**\n * Get version precisions count\n *\n * @example\n * getVersionPrecision(\"1.10.3\") // 3\n *\n * @param {string} version\n * @return {number}\n */\n function getVersionPrecision(version) {\n return version.split(\".\").length;\n }\n\n /**\n * Array::map polyfill\n *\n * @param {Array} arr\n * @param {Function} iterator\n * @return {Array}\n */\n function map(arr, iterator) {\n var result = [], i;\n if (Array.prototype.map) {\n return Array.prototype.map.call(arr, iterator);\n }\n for (i = 0; i < arr.length; i++) {\n result.push(iterator(arr[i]));\n }\n return result;\n }\n\n /**\n * Calculate browser version weight\n *\n * @example\n * compareVersions(['1.10.2.1', '1.8.2.1.90']) // 1\n * compareVersions(['1.010.2.1', '1.09.2.1.90']); // 1\n * compareVersions(['1.10.2.1', '1.10.2.1']); // 0\n * compareVersions(['1.10.2.1', '1.0800.2']); // -1\n *\n * @param {Array} versions versions to compare\n * @return {Number} comparison result\n */\n function compareVersions(versions) {\n // 1) get common precision for both versions, for example for \"10.0\" and \"9\" it should be 2\n var precision = Math.max(getVersionPrecision(versions[0]), getVersionPrecision(versions[1]));\n var chunks = map(versions, function (version) {\n var delta = precision - getVersionPrecision(version);\n\n // 2) \"9\" -> \"9.0\" (for precision = 2)\n version = version + new Array(delta + 1).join(\".0\");\n\n // 3) \"9.0\" -> [\"000000000\"\", \"000000009\"]\n return map(version.split(\".\"), function (chunk) {\n return new Array(20 - chunk.length).join(\"0\") + chunk;\n }).reverse();\n });\n\n // iterate in reverse order by reversed chunks array\n while (--precision >= 0) {\n // 4) compare: \"000000009\" > \"000000010\" = false (but \"9\" > \"10\" = true)\n if (chunks[0][precision] > chunks[1][precision]) {\n return 1;\n }\n else if (chunks[0][precision] === chunks[1][precision]) {\n if (precision === 0) {\n // all version chunks are same\n return 0;\n }\n }\n else {\n return -1;\n }\n }\n }\n\n /**\n * Check if browser is unsupported\n *\n * @example\n * bowser.isUnsupportedBrowser({\n * msie: \"10\",\n * firefox: \"23\",\n * chrome: \"29\",\n * safari: \"5.1\",\n * opera: \"16\",\n * phantom: \"534\"\n * });\n *\n * @param {Object} minVersions map of minimal version to browser\n * @param {Boolean} [strictMode = false] flag to return false if browser wasn't found in map\n * @param {String} [ua] user agent string\n * @return {Boolean}\n */\n function isUnsupportedBrowser(minVersions, strictMode, ua) {\n var _bowser = bowser;\n\n // make strictMode param optional with ua param usage\n if (typeof strictMode === 'string') {\n ua = strictMode;\n strictMode = void(0);\n }\n\n if (strictMode === void(0)) {\n strictMode = false;\n }\n if (ua) {\n _bowser = detect(ua);\n }\n\n var version = \"\" + _bowser.version;\n for (var browser in minVersions) {\n if (minVersions.hasOwnProperty(browser)) {\n if (_bowser[browser]) {\n if (typeof minVersions[browser] !== 'string') {\n throw new Error('Browser version in the minVersion map should be a string: ' + browser + ': ' + String(minVersions));\n }\n\n // browser version and min supported version.\n return compareVersions([version, minVersions[browser]]) < 0;\n }\n }\n }\n\n return strictMode; // not found\n }\n\n /**\n * Check if browser is supported\n *\n * @param {Object} minVersions map of minimal version to browser\n * @param {Boolean} [strictMode = false] flag to return false if browser wasn't found in map\n * @param {String} [ua] user agent string\n * @return {Boolean}\n */\n function check(minVersions, strictMode, ua) {\n return !isUnsupportedBrowser(minVersions, strictMode, ua);\n }\n\n bowser.isUnsupportedBrowser = isUnsupportedBrowser;\n bowser.compareVersions = compareVersions;\n bowser.check = check;\n\n /*\n * Set our detect method to the main bowser object so we can\n * reuse it to test other user agents.\n * This is needed to implement future tests.\n */\n bowser._detect = detect;\n\n return bowser\n});\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ../~/bowser/bowser.js\n ** module id = 4\n ** module chunks = 0\n **/","module.exports = function() { throw new Error(\"define cannot be used indirect\"); };\r\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ../~/webpack/buildin/amd-define.js\n ** module id = 5\n ** module chunks = 0\n **/"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/bootstrap 145835aa60e0a1ec522f","webpack:///./index.js","webpack:///./cades.js","webpack:///../~/bowser/bowser.js","webpack:///../~/webpack/buildin/amd-define.js"],"names":[],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAQ,oBAAoB;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,uBAAe;AACf;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;;;;;;ACzFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA;;AAEA;;AAEA;AACA;AACA;AACA,MAAK;AACL;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,UAAS;AACT,MAAK;AACL;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAqB;AACrB,kBAAiB;AACjB;AACA;AACA;AACA,sBAAqB;AACrB;AACA,cAAa;;AAEb;AACA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA,EAAC;AACD;AACA;;AAEA;AACA;AACA,G;;;;;;AC5GA,EAAC;AACD;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT,MAAK;AACL;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,uDAAsD;AACtD;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAiB;AACjB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAAyB;AACzB;AACA;AACA,sBAAqB;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA,UAAS;AACT;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,qBAAoB;;AAEpB;AACA;AACA;AACA;AACA;AACA,QAAO;;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA,cAAa;AACb;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4CAA2C;AAC3C;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iDAAgD,iBAAiB,WAAW,UAAU,YAAY,aAAa;AAC/G,0FAAyF,aAAa,mBAAmB,uBAAuB,uBAAuB,cAAc,mBAAmB,YAAY;AACpN,6FAA4F,iBAAiB,yBAAyB,WAAW;AACjJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAAyB;AACzB,qCAAoC;AACpC,kBAAiB;AACjB;AACA;AACA;AACA;AACA,0BAAyB;;AAEzB;AACA;AACA;AACA;AACA,0BAAyB;AACzB;AACA;AACA;AACA,kBAAiB;AACjB,cAAa;AACb,UAAS;AACT;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,cAAa;AACb;AACA;AACA,UAAS;AACT;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAiB;AACjB;AACA;AACA;AACA,cAAa;AACb;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,UAAS;AACT;AACA;AACA;AACA;AACA;AACA,sBAAqB;AACrB;AACA,UAAS;AACT;AACA;AACA;AACA;AACA;AACA,kBAAiB;AACjB,cAAa;AACb;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA,EAAC;;;;;;;;;AC1nBD;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,EAAC;AACD;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8BAA6B;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,QAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA,MAAK;AACL;AACA,MAAK;AACL;AACA,MAAK;AACL;AACA,MAAK;AACL;AACA;;AAEA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA,MAAK;AACL;AACA,MAAK;AACL;AACA,MAAK;AACL;AACA,MAAK;AACL;AACA,MAAK;AACL;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAK;;AAEL;AACA;;AAEA;;AAEA;AACA,oBAAmB,wBAAwB;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAc,OAAO;AACrB,eAAc;AACd;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,eAAc,MAAM;AACpB,eAAc,SAAS;AACvB,eAAc;AACd;AACA;AACA;AACA;AACA;AACA;AACA,gBAAe,gBAAgB;AAC/B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,sDAAqD;AACrD,mDAAkD;AAClD,mDAAkD;AAClD;AACA,eAAc,cAAc;AAC5B,eAAc,OAAO;AACrB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,QAAO;AACP,MAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAQ;AACR;AACA,eAAc,OAAO;AACrB,eAAc,QAAQ;AACtB,eAAc,OAAO;AACrB,eAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA,uBAAsB;AACtB;;AAEA;AACA;AACA;AACA,eAAc,OAAO;AACrB,eAAc,QAAQ;AACtB,eAAc,OAAO;AACrB,eAAc;AACd;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,EAAC;;;;;;;ACnkBD,8BAA6B,mDAAmD","file":"crypto-pro.js","sourcesContent":[" \t// install a JSONP callback for chunk loading\n \tvar parentJsonpFunction = window[\"webpackJsonpCryptoPro\"];\n \twindow[\"webpackJsonpCryptoPro\"] = function webpackJsonpCallback(chunkIds, moreModules) {\n \t\t// add \"moreModules\" to the modules object,\n \t\t// then flag all \"chunkIds\" as loaded and fire callback\n \t\tvar moduleId, chunkId, i = 0, callbacks = [];\n \t\tfor(;i < chunkIds.length; i++) {\n \t\t\tchunkId = chunkIds[i];\n \t\t\tif(installedChunks[chunkId])\n \t\t\t\tcallbacks.push.apply(callbacks, installedChunks[chunkId]);\n \t\t\tinstalledChunks[chunkId] = 0;\n \t\t}\n \t\tfor(moduleId in moreModules) {\n \t\t\tmodules[moduleId] = moreModules[moduleId];\n \t\t}\n \t\tif(parentJsonpFunction) parentJsonpFunction(chunkIds, moreModules);\n \t\twhile(callbacks.length)\n \t\t\tcallbacks.shift().call(null, __webpack_require__);\n\n \t};\n\n \t// The module cache\n \tvar installedModules = {};\n\n \t// object to store loaded and loading chunks\n \t// \"0\" means \"already loaded\"\n \t// Array means \"loading\", array contains callbacks\n \tvar installedChunks = {\n \t\t0:0\n \t};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n \t// This file contains only the entry chunk.\n \t// The chunk loading function for additional chunks\n \t__webpack_require__.e = function requireEnsure(chunkId, callback) {\n \t\t// \"0\" is the signal for \"already loaded\"\n \t\tif(installedChunks[chunkId] === 0)\n \t\t\treturn callback.call(null, __webpack_require__);\n\n \t\t// an array means \"currently loading\".\n \t\tif(installedChunks[chunkId] !== undefined) {\n \t\t\tinstalledChunks[chunkId].push(callback);\n \t\t} else {\n \t\t\t// start chunk loading\n \t\t\tinstalledChunks[chunkId] = [callback];\n \t\t\tvar head = document.getElementsByTagName('head')[0];\n \t\t\tvar script = document.createElement('script');\n \t\t\tscript.type = 'text/javascript';\n \t\t\tscript.charset = 'utf-8';\n \t\t\tscript.async = true;\n\n \t\t\tscript.src = __webpack_require__.p + \"\" + chunkId + \".crypto-pro.js\";\n \t\t\thead.appendChild(script);\n \t\t}\n \t};\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n/** WEBPACK FOOTER **\n ** webpack/bootstrap 145835aa60e0a1ec522f\n **/","var bowser = require('bowser/bowser'),\n browserInfo = bowser._detect(navigator.userAgent),\n global = Function('return this')(),\n canPromise = Boolean(global.Promise),\n CryptoProConfig = global.CryptoProConfig,\n canAsync,\n cadesplugin,\n cryptoService,\n _errorMsg = '',\n _isLoaded = false,\n _onLoadCbQueue = [];\n\nglobal.allow_firefox_cadesplugin_async = browserInfo.firefox && browserInfo.version >= 52;\n\nrequire('./cades');\n\ncadesplugin = global.cadesplugin;\n\ncanAsync = Boolean(cadesplugin.CreateObjectAsync);\n\nfunction execOnloadQueue() {\n _onLoadCbQueue.forEach(function (callback) {\n callback();\n });\n}\n\nfunction passToWaitOnLoad(callback) {\n if (Object.prototype.toString.call(callback) === '[object Function]') {\n _onLoadCbQueue.push(callback);\n }\n}\n\nfunction callOnLoad(method) {\n _isLoaded ? method() : passToWaitOnLoad(method);\n}\n\nfunction finishLoading() {\n _isLoaded = true;\n\n execOnloadQueue();\n}\n\nfunction call() {\n var args = Array.prototype.slice.call(arguments),\n methodName = args.shift();\n\n return new Promise(function (resolve, reject) {\n callOnLoad(function () {\n var method;\n\n if (_errorMsg) {\n reject(_errorMsg);\n return;\n }\n\n method = cryptoService[methodName];\n\n if (!method) {\n reject('Метод \"' + methodName + '\" не доступен');\n return;\n }\n\n method.apply(null, args).then(resolve, reject);\n });\n });\n}\n\nif (cadesplugin) {\n canAsync = Boolean(cadesplugin.CreateObjectAsync);\n\n // Уровень отладки (LOG_LEVEL_DEBUG, LOG_LEVEL_INFO, LOG_LEVEL_ERROR)\n cadesplugin.set_log_level(cadesplugin.LOG_LEVEL_ERROR);\n\n // Получаем указанные конфиги\n if (CryptoProConfig && CryptoProConfig.publicPath) {\n __webpack_public_path__ = CryptoProConfig.publicPath;\n }\n\n if (canPromise) {\n cadesplugin.then(\n function () {\n if (canAsync) {\n require.ensure([], function () {\n cryptoService = require('./apiAsync');\n finishLoading();\n });\n } else {\n require.ensure([], function () {\n cryptoService = require('./apiSync');\n finishLoading();\n });\n }\n },\n\n function () {\n _errorMsg = 'КриптоПРО ЭЦП Browser Plug-In не доступен';\n finishLoading();\n }\n );\n } else {\n throw new Error('Не поддерживаются промисы. Необходим полифилл.');\n }\n} else {\n throw new Error('Не подключен модуль для работы с cades plugin');\n}\n\nmodule.exports = {\n call: call\n};\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./index.js\n ** module id = 0\n ** module chunks = 0\n **/",";(function () {\n //already loaded\n if(window.cadesplugin)\n return;\n\n var pluginObject;\n var plugin_resolved = 0;\n var plugin_reject;\n var plugin_resolve;\n var isOpera = 0;\n var isYaBrowser = 0;\n var isFireFox = 0;\n var failed_extensions = 0;\n\n var canPromise = !!window.Promise;\n var cadesplugin;\n\n if(canPromise)\n {\n cadesplugin = new Promise(function(resolve, reject)\n {\n plugin_resolve = resolve;\n plugin_reject = reject;\n });\n } else\n {\n cadesplugin = {};\n }\n\n function cpcsp_console_log(level, msg){\n //IE9 не может писать в консоль если не открыта вкладка developer tools\n if(typeof(console) == 'undefined')\n return;\n if (level <= cadesplugin.current_log_level ){\n if (level == cadesplugin.LOG_LEVEL_DEBUG)\n console.log(\"DEBUG: %s\", msg);\n if (level == cadesplugin.LOG_LEVEL_INFO)\n console.info(\"INFO: %s\", msg);\n if (level == cadesplugin.LOG_LEVEL_ERROR)\n console.error(\"ERROR: %s\", msg);\n return;\n }\n }\n\n function set_log_level(level){\n if (!((level == cadesplugin.LOG_LEVEL_DEBUG) ||\n (level == cadesplugin.LOG_LEVEL_INFO) ||\n (level == cadesplugin.LOG_LEVEL_ERROR))){\n cpcsp_console_log(cadesplugin.LOG_LEVEL_ERROR, \"cadesplugin_api.js: Incorrect log_level: \" + level);\n return;\n }\n cadesplugin.current_log_level = level;\n if (cadesplugin.current_log_level == cadesplugin.LOG_LEVEL_DEBUG)\n cpcsp_console_log(cadesplugin.LOG_LEVEL_INFO, \"cadesplugin_api.js: log_level = DEBUG\");\n if (cadesplugin.current_log_level == cadesplugin.LOG_LEVEL_INFO)\n cpcsp_console_log(cadesplugin.LOG_LEVEL_INFO, \"cadesplugin_api.js: log_level = INFO\");\n if (cadesplugin.current_log_level == cadesplugin.LOG_LEVEL_ERROR)\n cpcsp_console_log(cadesplugin.LOG_LEVEL_INFO, \"cadesplugin_api.js: log_level = ERROR\");\n if(isNativeMessageSupported())\n {\n if (cadesplugin.current_log_level == cadesplugin.LOG_LEVEL_DEBUG)\n window.postMessage(\"set_log_level=debug\", \"*\");\n if (cadesplugin.current_log_level == cadesplugin.LOG_LEVEL_INFO)\n window.postMessage(\"set_log_level=info\", \"*\");\n if (cadesplugin.current_log_level == cadesplugin.LOG_LEVEL_ERROR)\n window.postMessage(\"set_log_level=error\", \"*\");\n }\n }\n\n function set_constantValues()\n {\n cadesplugin.CAPICOM_LOCAL_MACHINE_STORE = 1;\n cadesplugin.CAPICOM_CURRENT_USER_STORE = 2;\n cadesplugin.CADESCOM_LOCAL_MACHINE_STORE = 1;\n cadesplugin.CADESCOM_CURRENT_USER_STORE = 2;\n cadesplugin.CADESCOM_CONTAINER_STORE = 100;\n\n cadesplugin.CAPICOM_MY_STORE = \"My\";\n\n cadesplugin.CAPICOM_STORE_OPEN_MAXIMUM_ALLOWED = 2;\n\n cadesplugin.CAPICOM_CERTIFICATE_FIND_SUBJECT_NAME = 1;\n\n cadesplugin.CADESCOM_XML_SIGNATURE_TYPE_ENVELOPED = 0;\n cadesplugin.CADESCOM_XML_SIGNATURE_TYPE_ENVELOPING = 1;\n cadesplugin.CADESCOM_XML_SIGNATURE_TYPE_TEMPLATE = 2;\n\n cadesplugin.XmlDsigGost3410UrlObsolete = \"http://www.w3.org/2001/04/xmldsig-more#gostr34102001-gostr3411\";\n cadesplugin.XmlDsigGost3411UrlObsolete = \"http://www.w3.org/2001/04/xmldsig-more#gostr3411\";\n cadesplugin.XmlDsigGost3410Url = \"urn:ietf:params:xml:ns:cpxmlsec:algorithms:gostr34102001-gostr3411\";\n cadesplugin.XmlDsigGost3411Url = \"urn:ietf:params:xml:ns:cpxmlsec:algorithms:gostr3411\";\n\n cadesplugin.CADESCOM_CADES_DEFAULT = 0;\n cadesplugin.CADESCOM_CADES_BES = 1;\n cadesplugin.CADESCOM_CADES_T = 0x5;\n cadesplugin.CADESCOM_CADES_X_LONG_TYPE_1 = 0x5d;\n\n cadesplugin.CADESCOM_ENCODE_BASE64 = 0;\n cadesplugin.CADESCOM_ENCODE_BINARY = 1;\n cadesplugin.CADESCOM_ENCODE_ANY = -1;\n\n cadesplugin.CAPICOM_CERTIFICATE_INCLUDE_CHAIN_EXCEPT_ROOT = 0;\n cadesplugin.CAPICOM_CERTIFICATE_INCLUDE_WHOLE_CHAIN = 1;\n cadesplugin.CAPICOM_CERTIFICATE_INCLUDE_END_ENTITY_ONLY = 2;\n\n cadesplugin.CAPICOM_CERT_INFO_SUBJECT_SIMPLE_NAME = 0;\n cadesplugin.CAPICOM_CERT_INFO_ISSUER_SIMPLE_NAME = 1;\n\n cadesplugin.CAPICOM_CERTIFICATE_FIND_SHA1_HASH = 0;\n cadesplugin.CAPICOM_CERTIFICATE_FIND_SUBJECT_NAME = 1;\n cadesplugin.CAPICOM_CERTIFICATE_FIND_ISSUER_NAME = 2;\n cadesplugin.CAPICOM_CERTIFICATE_FIND_ROOT_NAME = 3;\n cadesplugin.CAPICOM_CERTIFICATE_FIND_TEMPLATE_NAME = 4;\n cadesplugin.CAPICOM_CERTIFICATE_FIND_EXTENSION = 5;\n cadesplugin.CAPICOM_CERTIFICATE_FIND_EXTENDED_PROPERTY = 6;\n cadesplugin.CAPICOM_CERTIFICATE_FIND_APPLICATION_POLICY = 7;\n cadesplugin.CAPICOM_CERTIFICATE_FIND_CERTIFICATE_POLICY = 8;\n cadesplugin.CAPICOM_CERTIFICATE_FIND_TIME_VALID = 9;\n cadesplugin.CAPICOM_CERTIFICATE_FIND_TIME_NOT_YET_VALID = 10;\n cadesplugin.CAPICOM_CERTIFICATE_FIND_TIME_EXPIRED = 11;\n cadesplugin.CAPICOM_CERTIFICATE_FIND_KEY_USAGE = 12;\n\n cadesplugin.CAPICOM_DIGITAL_SIGNATURE_KEY_USAGE = 128;\n\n cadesplugin.CAPICOM_PROPID_ENHKEY_USAGE = 9;\n\n cadesplugin.CAPICOM_OID_OTHER = 0;\n cadesplugin.CAPICOM_OID_KEY_USAGE_EXTENSION = 10;\n\n cadesplugin.CAPICOM_EKU_CLIENT_AUTH = 2;\n cadesplugin.CAPICOM_EKU_SMARTCARD_LOGON = 5;\n cadesplugin.CAPICOM_EKU_OTHER = 0;\n\n cadesplugin.CAPICOM_AUTHENTICATED_ATTRIBUTE_SIGNING_TIME = 0;\n cadesplugin.CADESCOM_AUTHENTICATED_ATTRIBUTE_DOCUMENT_NAME = 1;\n cadesplugin.CADESCOM_AUTHENTICATED_ATTRIBUTE_DOCUMENT_DESCRIPTION = 2;\n cadesplugin.CADESCOM_ATTRIBUTE_OTHER = -1;\n\n cadesplugin.CADESCOM_STRING_TO_UCS2LE = 0;\n cadesplugin.CADESCOM_BASE64_TO_BINARY = 1;\n\n cadesplugin.CADESCOM_DISPLAY_DATA_NONE = 0;\n cadesplugin.CADESCOM_DISPLAY_DATA_CONTENT = 1;\n cadesplugin.CADESCOM_DISPLAY_DATA_ATTRIBUTE = 2;\n\n cadesplugin.CADESCOM_ENCRYPTION_ALGORITHM_RC2 = 0;\n cadesplugin.CADESCOM_ENCRYPTION_ALGORITHM_RC4 = 1;\n cadesplugin.CADESCOM_ENCRYPTION_ALGORITHM_DES = 2;\n cadesplugin.CADESCOM_ENCRYPTION_ALGORITHM_3DES = 3;\n cadesplugin.CADESCOM_ENCRYPTION_ALGORITHM_AES = 4;\n cadesplugin.CADESCOM_ENCRYPTION_ALGORITHM_GOST_28147_89 = 25;\n\n cadesplugin.CADESCOM_HASH_ALGORITHM_SHA1 = 0;\n cadesplugin.CADESCOM_HASH_ALGORITHM_MD2 = 1;\n cadesplugin.CADESCOM_HASH_ALGORITHM_MD4 = 2;\n cadesplugin.CADESCOM_HASH_ALGORITHM_MD5 = 3;\n cadesplugin.CADESCOM_HASH_ALGORITHM_SHA_256 = 4;\n cadesplugin.CADESCOM_HASH_ALGORITHM_SHA_384 = 5;\n cadesplugin.CADESCOM_HASH_ALGORITHM_SHA_512 = 6;\n cadesplugin.CADESCOM_HASH_ALGORITHM_CP_GOST_3411 = 100;\n cadesplugin.CADESCOM_HASH_ALGORITHM_CP_GOST_3411_2012_256 = 101;\n cadesplugin.CADESCOM_HASH_ALGORITHM_CP_GOST_3411_2012_512 = 102;\n\n cadesplugin.LOG_LEVEL_DEBUG = 4;\n cadesplugin.LOG_LEVEL_INFO = 2;\n cadesplugin.LOG_LEVEL_ERROR = 1;\n }\n\n function async_spawn(generatorFunc) {\n function continuer(verb, arg) {\n var result;\n try {\n result = generator[verb](arg);\n } catch (err) {\n return Promise.reject(err);\n }\n if (result.done) {\n return result.value;\n } else {\n return Promise.resolve(result.value).then(onFulfilled, onRejected);\n }\n }\n var generator = generatorFunc(Array.prototype.slice.call(arguments, 1));\n var onFulfilled = continuer.bind(continuer, \"next\");\n var onRejected = continuer.bind(continuer, \"throw\");\n return onFulfilled();\n }\n\n function isIE() {\n var retVal = ((\"Microsoft Internet Explorer\" == navigator.appName) || // IE < 11\n navigator.userAgent.match(/Trident\\/./i)); // IE 11\n return retVal;\n }\n\n function isIOS() {\n var retVal = (navigator.userAgent.match(/ipod/i) ||\n navigator.userAgent.match(/ipad/i) ||\n navigator.userAgent.match(/iphone/i));\n return retVal;\n }\n\n function isNativeMessageSupported()\n {\n var retVal_chrome = navigator.userAgent.match(/chrome/i);\n isOpera = navigator.userAgent.match(/opr/i);\n isYaBrowser = navigator.userAgent.match(/YaBrowser/i);\n isFireFox = navigator.userAgent.match(/Firefox/i);\n\n if(isFireFox && window.allow_firefox_cadesplugin_async)\n return true;\n\n if(retVal_chrome == null) // В IE работаем через NPAPI\n return false;\n else\n {\n // В Chrome и Opera работаем через асинхронную версию\n if(retVal_chrome.length > 0 || isOpera != null )\n {\n return true;\n }\n }\n return false;\n }\n\n // Функция активации объектов КриптоПро ЭЦП Browser plug-in\n function CreateObject(name) {\n if (isIOS()) {\n // На iOS для создания объектов используется функция\n // call_ru_cryptopro_npcades_10_native_bridge, определенная в IOS_npcades_supp.js\n return call_ru_cryptopro_npcades_10_native_bridge(\"CreateObject\", [name]);\n }\n if (isIE()) {\n // В Internet Explorer создаются COM-объекты\n if (name.match(/X509Enrollment/i)) {\n try {\n // Объекты CertEnroll создаются через CX509EnrollmentWebClassFactory\n var objCertEnrollClassFactory = document.getElementById(\"certEnrollClassFactory\");\n return objCertEnrollClassFactory.CreateObject(name);\n }\n catch (e) {\n throw(\"Для создания обьектов X509Enrollment следует настроить веб-узел на использование проверки подлинности по протоколу HTTPS\");\n }\n }\n // Объекты CAPICOM и CAdESCOM создаются через CAdESCOM.WebClassFactory\n try {\n var objWebClassFactory = document.getElementById(\"webClassFactory\");\n return objWebClassFactory.CreateObject(name);\n }\n catch (e) {\n try {\n // Для версий плагина ниже 2.0.12538\n return new ActiveXObject(name);\n } catch (e) {\n var mimetype = navigator.mimeTypes['application/x-cades'];\n\n if (mimetype) {\n if (mimetype.enabledPlugin) {\n console.log(\n 'EDS:',\n 'Плагин КриптоПРО ЭЦП browser plug-in загружен,',\n 'но не создаются обьекты'\n );\n } else {\n console.log('EDS:', 'Ошибка при загрузке плагина КриптоПРО ЭЦП browser plug-in');\n }\n } else {\n console.log('EDS:', 'Плагин КриптоПРО ЭЦП browser plug-in недоступен');\n }\n }\n }\n }\n // В Firefox, Safari создаются объекты NPAPI\n return pluginObject.CreateObject(name);\n }\n\n function decimalToHexString(number) {\n if (number < 0) {\n number = 0xFFFFFFFF + number + 1;\n }\n\n return number.toString(16).toUpperCase();\n }\n\n function GetMessageFromException(e) {\n var err = e.message;\n if (!err) {\n err = e;\n } else if (e.number) {\n err += \" (0x\" + decimalToHexString(e.number) + \")\";\n }\n return err;\n }\n\n function getLastError(exception) {\n if(isNativeMessageSupported() || isIE() || isIOS() ) {\n return GetMessageFromException(exception);\n }\n\n try {\n return pluginObject.getLastError();\n } catch(e) {\n return GetMessageFromException(exception);\n }\n }\n\n // Функция активации асинхронных объектов КриптоПро ЭЦП Browser plug-in\n function CreateObjectAsync(name) {\n return pluginObject.CreateObjectAsync(name);\n }\n\n //Функции для IOS\n var ru_cryptopro_npcades_10_native_bridge = {\n callbacksCount : 1,\n callbacks : {},\n\n // Automatically called by native layer when a result is available\n resultForCallback : function resultForCallback(callbackId, resultArray) {\n var callback = ru_cryptopro_npcades_10_native_bridge.callbacks[callbackId];\n if (!callback) return;\n callback.apply(null,resultArray);\n },\n\n // Use this in javascript to request native objective-c code\n // functionName : string (I think the name is explicit :p)\n // args : array of arguments\n // callback : function with n-arguments that is going to be called when the native code returned\n call : function call(functionName, args, callback) {\n var hasCallback = callback && typeof callback == \"function\";\n var callbackId = hasCallback ? ru_cryptopro_npcades_10_native_bridge.callbacksCount++ : 0;\n\n if (hasCallback)\n ru_cryptopro_npcades_10_native_bridge.callbacks[callbackId] = callback;\n\n var iframe = document.createElement(\"IFRAME\");\n var arrObjs = new Array(\"_CPNP_handle\");\n try{\n iframe.setAttribute(\"src\", \"cpnp-js-call:\" + functionName + \":\" + callbackId+ \":\" + encodeURIComponent(JSON.stringify(args, arrObjs)));\n } catch(e){\n alert(e);\n }\n document.documentElement.appendChild(iframe);\n iframe.parentNode.removeChild(iframe);\n iframe = null;\n }\n };\n\n function call_ru_cryptopro_npcades_10_native_bridge(functionName, array){\n var tmpobj;\n var ex;\n ru_cryptopro_npcades_10_native_bridge.call(functionName, array, function(e, response){\n ex = e;\n var str='tmpobj='+response;\n eval(str);\n if (typeof (tmpobj) == \"string\"){\n tmpobj = tmpobj.replace(/\\\\\\n/gm, \"\\n\");\n tmpobj = tmpobj.replace(/\\\\\\r/gm, \"\\r\");\n }\n });\n if(ex)\n throw ex;\n return tmpobj;\n }\n\n //Выводим окно поверх других с предложением установить расширение для Opera.\n //Если установленна переменная cadesplugin_skip_extension_install - не предлагаем установить расширение\n function install_opera_extension()\n {\n if (!window.cadesplugin_skip_extension_install)\n {\n document.addEventListener('DOMContentLoaded', function() {\n var ovr = document.createElement('div');\n ovr.id = \"cadesplugin_ovr\";\n ovr.style = \"visibility: hidden; position: fixed; left: 0px; top: 0px; width:100%; height:100%; background-color: rgba(0,0,0,0.7)\";\n ovr.innerHTML = \"
\" +\n \"\" +\n \"

Для работы КриптоПро ЭЦП Browser plugin на данном сайте необходимо установить расширение из каталога дополнений Opera.\" +\n \"

\" +\n \"
\";\n document.getElementsByTagName(\"Body\")[0].appendChild(ovr);\n var btn_install = document.getElementById(\"cadesplugin_install\");\n btn_install.addEventListener('click', function(event) {\n opr.addons.installExtension(\"epebfcehmdedogndhlcacafjaacknbcm\",\n function()\n {\n document.getElementById(\"cadesplugin_ovr\").style.visibility = 'hidden';\n location.reload();\n },\n function(){})\n });\n document.getElementById(\"cadesplugin_close_install\").addEventListener('click',function()\n {\n plugin_loaded_error(\"Плагин недоступен\");\n document.getElementById(\"cadesplugin_ovr\").style.visibility = 'hidden';\n });\n\n ovr.addEventListener('click',function()\n {\n plugin_loaded_error(\"Плагин недоступен\");\n document.getElementById(\"cadesplugin_ovr\").style.visibility = 'hidden';\n });\n ovr.style.visibility=\"visible\";\n document.getElementById(\"cadesplugin_ovr_item\").addEventListener('click',function(e){\n e.stopPropagation();\n });\n });\n }else\n {\n plugin_loaded_error(\"Плагин недоступен\");\n }\n }\n\n function firefox_nmcades_onload() {\n cpcsp_chrome_nmcades.check_chrome_plugin(plugin_loaded, plugin_loaded_error);\n }\n\n function nmcades_api_onload () {\n window.postMessage(\"cadesplugin_echo_request\", \"*\");\n window.addEventListener(\"message\", function (event){\n if (typeof(event.data) != \"string\" || !event.data.match(\"cadesplugin_loaded\"))\n return;\n if(isFireFox)\n {\n // Для Firefox вместе с сообщением cadesplugin_loaded прилетает url для загрузки nmcades_plugin_api.js\n var url = event.data.substring(event.data.indexOf(\"url:\") + 4);\n var fileref = document.createElement('script');\n fileref.setAttribute(\"type\", \"text/javascript\");\n fileref.setAttribute(\"src\", url);\n fileref.onerror = plugin_loaded_error;\n fileref.onload = firefox_nmcades_onload;\n document.getElementsByTagName(\"head\")[0].appendChild(fileref);\n\n }else {\n cpcsp_chrome_nmcades.check_chrome_plugin(plugin_loaded, plugin_loaded_error);\n }\n }, false);\n }\n\n //Загружаем расширения для Chrome, Opera, YaBrowser, FireFox, Edge\n function load_extension()\n {\n\n if(isFireFox){\n // вызываем callback руками т.к. нам нужно узнать ID расширения. Он уникальный для браузера.\n nmcades_api_onload();\n return;\n } else {\n // в асинхронном варианте для chrome и opera подключаем оба расширения\n var fileref = document.createElement('script');\n fileref.setAttribute(\"type\", \"text/javascript\");\n fileref.setAttribute(\"src\", \"chrome-extension://iifchhfnnmpdbibifmljnfjhpififfog/nmcades_plugin_api.js\");\n fileref.onerror = plugin_loaded_error;\n fileref.onload = nmcades_api_onload;\n document.getElementsByTagName(\"head\")[0].appendChild(fileref);\n fileref = document.createElement('script');\n fileref.setAttribute(\"type\", \"text/javascript\");\n fileref.setAttribute(\"src\", \"chrome-extension://epebfcehmdedogndhlcacafjaacknbcm/nmcades_plugin_api.js\");\n fileref.onerror = plugin_loaded_error;\n fileref.onload = nmcades_api_onload;\n document.getElementsByTagName(\"head\")[0].appendChild(fileref);\n }\n }\n\n //Загружаем плагин для NPAPI\n function load_npapi_plugin()\n {\n var elem = document.createElement('object');\n elem.setAttribute(\"id\", \"cadesplugin_object\");\n elem.setAttribute(\"type\", \"application/x-cades\");\n elem.setAttribute(\"style\", \"visibility: hidden\");\n document.getElementsByTagName(\"body\")[0].appendChild(elem);\n pluginObject = document.getElementById(\"cadesplugin_object\");\n if(isIE())\n {\n var elem1 = document.createElement('object');\n elem1.setAttribute(\"id\", \"certEnrollClassFactory\");\n elem1.setAttribute(\"classid\", \"clsid:884e2049-217d-11da-b2a4-000e7bbb2b09\");\n elem1.setAttribute(\"style\", \"visibility: hidden\");\n document.getElementsByTagName(\"body\")[0].appendChild(elem1);\n var elem2 = document.createElement('object');\n elem2.setAttribute(\"id\", \"webClassFactory\");\n elem2.setAttribute(\"classid\", \"clsid:B04C8637-10BD-484E-B0DA-B8A039F60024\");\n elem2.setAttribute(\"style\", \"visibility: hidden\");\n document.getElementsByTagName(\"body\")[0].appendChild(elem2);\n }\n }\n\n //Отправляем событие что все ок.\n function plugin_loaded()\n {\n plugin_resolved = 1;\n if(canPromise)\n {\n plugin_resolve();\n }else {\n window.postMessage(\"cadesplugin_loaded\", \"*\");\n }\n }\n\n //Отправляем событие что сломались.\n function plugin_loaded_error(msg)\n {\n if(isNativeMessageSupported())\n {\n //в асинхронном варианте подключаем оба расширения, если сломались оба пробуем установить для Opera\n failed_extensions++;\n if(failed_extensions<2)\n return;\n if(isOpera && (typeof(msg) == 'undefined'|| typeof(msg) == 'object'))\n {\n install_opera_extension();\n return;\n }\n }\n if(typeof(msg) == 'undefined' || typeof(msg) == 'object')\n msg = \"Плагин недоступен\";\n plugin_resolved = 1;\n if(canPromise)\n {\n plugin_reject(msg);\n } else {\n window.postMessage(\"cadesplugin_load_error\", \"*\");\n }\n }\n\n //проверяем что у нас хоть какое то событие ушло, и если не уходило кидаем еще раз ошибку\n function check_load_timeout()\n {\n if(plugin_resolved == 1)\n return;\n plugin_resolved = 1;\n if(canPromise)\n {\n plugin_reject(\"Истекло время ожидания загрузки плагина\");\n } else {\n window.postMessage(\"cadesplugin_load_error\", \"*\");\n }\n\n }\n\n //Вспомогательная функция для NPAPI\n function createPromise(arg)\n {\n return new Promise(arg);\n }\n\n function check_npapi_plugin (){\n try {\n var oAbout = CreateObject(\"CAdESCOM.About\");\n plugin_loaded();\n }\n catch (err) {\n document.getElementById(\"cadesplugin_object\").style.display = 'none';\n // Объект создать не удалось, проверим, установлен ли\n // вообще плагин. Такая возможность есть не во всех браузерах\n var mimetype = navigator.mimeTypes[\"application/x-cades\"];\n if (mimetype) {\n var plugin = mimetype.enabledPlugin;\n if (plugin) {\n plugin_loaded_error(\"Плагин загружен, но не создаются обьекты\");\n }else\n {\n plugin_loaded_error(\"Ошибка при загрузке плагина\");\n }\n }else\n {\n plugin_loaded_error(\"Плагин недоступен\");\n }\n }\n }\n\n //Проверяем работает ли плагин\n function check_plugin_working()\n {\n if(isNativeMessageSupported())\n {\n load_extension();\n }else if(!canPromise) {\n window.addEventListener(\"message\", function (event){\n if (event.data != \"cadesplugin_echo_request\")\n return;\n load_npapi_plugin();\n check_npapi_plugin();\n },\n false);\n }else\n {\n if (window.addEventListener) {\n window.addEventListener(\"load\", function (event) {\n load_npapi_plugin();\n check_npapi_plugin();\n }, false);\n } else {\n load_npapi_plugin();\n check_npapi_plugin();\n }\n }\n }\n\n function set_pluginObject(obj)\n {\n pluginObject = obj;\n }\n\n //Export\n cadesplugin.JSModuleVersion = \"2.1.0\";\n cadesplugin.async_spawn = async_spawn;\n cadesplugin.set = set_pluginObject;\n cadesplugin.set_log_level = set_log_level;\n cadesplugin.getLastError = getLastError;\n\n if(isNativeMessageSupported())\n {\n cadesplugin.CreateObjectAsync = CreateObjectAsync;\n }\n\n if(!isNativeMessageSupported())\n {\n cadesplugin.CreateObject = CreateObject;\n }\n\n if(window.cadesplugin_load_timeout)\n {\n setTimeout(check_load_timeout, window.cadesplugin_load_timeout);\n }\n else\n {\n setTimeout(check_load_timeout, 20000);\n }\n\n set_constantValues();\n\n cadesplugin.current_log_level = cadesplugin.LOG_LEVEL_ERROR;\n window.cadesplugin = cadesplugin;\n check_plugin_working();\n}());\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./cades.js\n ** module id = 1\n ** module chunks = 0\n **/","/*!\n * Bowser - a browser detector\n * https://github.com/ded/bowser\n * MIT License | (c) Dustin Diaz 2015\n */\n\n!function (name, definition) {\n if (typeof module != 'undefined' && module.exports) module.exports = definition()\n else if (typeof define == 'function' && define.amd) define(name, definition)\n else this[name] = definition()\n}('bowser', function () {\n /**\n * See useragents.js for examples of navigator.userAgent\n */\n\n var t = true\n\n function detect(ua) {\n\n function getFirstMatch(regex) {\n var match = ua.match(regex);\n return (match && match.length > 1 && match[1]) || '';\n }\n\n function getSecondMatch(regex) {\n var match = ua.match(regex);\n return (match && match.length > 1 && match[2]) || '';\n }\n\n var iosdevice = getFirstMatch(/(ipod|iphone|ipad)/i).toLowerCase()\n , likeAndroid = /like android/i.test(ua)\n , android = !likeAndroid && /android/i.test(ua)\n , nexusMobile = /nexus\\s*[0-6]\\s*/i.test(ua)\n , nexusTablet = !nexusMobile && /nexus\\s*[0-9]+/i.test(ua)\n , chromeos = /CrOS/.test(ua)\n , silk = /silk/i.test(ua)\n , sailfish = /sailfish/i.test(ua)\n , tizen = /tizen/i.test(ua)\n , webos = /(web|hpw)os/i.test(ua)\n , windowsphone = /windows phone/i.test(ua)\n , samsungBrowser = /SamsungBrowser/i.test(ua)\n , windows = !windowsphone && /windows/i.test(ua)\n , mac = !iosdevice && !silk && /macintosh/i.test(ua)\n , linux = !android && !sailfish && !tizen && !webos && /linux/i.test(ua)\n , edgeVersion = getFirstMatch(/edge\\/(\\d+(\\.\\d+)?)/i)\n , versionIdentifier = getFirstMatch(/version\\/(\\d+(\\.\\d+)?)/i)\n , tablet = /tablet/i.test(ua)\n , mobile = !tablet && /[^-]mobi/i.test(ua)\n , xbox = /xbox/i.test(ua)\n , result\n\n if (/opera/i.test(ua)) {\n // an old Opera\n result = {\n name: 'Opera'\n , opera: t\n , version: versionIdentifier || getFirstMatch(/(?:opera|opr|opios)[\\s\\/](\\d+(\\.\\d+)?)/i)\n }\n } else if (/opr|opios/i.test(ua)) {\n // a new Opera\n result = {\n name: 'Opera'\n , opera: t\n , version: getFirstMatch(/(?:opr|opios)[\\s\\/](\\d+(\\.\\d+)?)/i) || versionIdentifier\n }\n }\n else if (/SamsungBrowser/i.test(ua)) {\n result = {\n name: 'Samsung Internet for Android'\n , samsungBrowser: t\n , version: versionIdentifier || getFirstMatch(/(?:SamsungBrowser)[\\s\\/](\\d+(\\.\\d+)?)/i)\n }\n }\n else if (/coast/i.test(ua)) {\n result = {\n name: 'Opera Coast'\n , coast: t\n , version: versionIdentifier || getFirstMatch(/(?:coast)[\\s\\/](\\d+(\\.\\d+)?)/i)\n }\n }\n else if (/yabrowser/i.test(ua)) {\n result = {\n name: 'Yandex Browser'\n , yandexbrowser: t\n , version: versionIdentifier || getFirstMatch(/(?:yabrowser)[\\s\\/](\\d+(\\.\\d+)?)/i)\n }\n }\n else if (/ucbrowser/i.test(ua)) {\n result = {\n name: 'UC Browser'\n , ucbrowser: t\n , version: getFirstMatch(/(?:ucbrowser)[\\s\\/](\\d+(?:\\.\\d+)+)/i)\n }\n }\n else if (/mxios/i.test(ua)) {\n result = {\n name: 'Maxthon'\n , maxthon: t\n , version: getFirstMatch(/(?:mxios)[\\s\\/](\\d+(?:\\.\\d+)+)/i)\n }\n }\n else if (/epiphany/i.test(ua)) {\n result = {\n name: 'Epiphany'\n , epiphany: t\n , version: getFirstMatch(/(?:epiphany)[\\s\\/](\\d+(?:\\.\\d+)+)/i)\n }\n }\n else if (/puffin/i.test(ua)) {\n result = {\n name: 'Puffin'\n , puffin: t\n , version: getFirstMatch(/(?:puffin)[\\s\\/](\\d+(?:\\.\\d+)?)/i)\n }\n }\n else if (/sleipnir/i.test(ua)) {\n result = {\n name: 'Sleipnir'\n , sleipnir: t\n , version: getFirstMatch(/(?:sleipnir)[\\s\\/](\\d+(?:\\.\\d+)+)/i)\n }\n }\n else if (/k-meleon/i.test(ua)) {\n result = {\n name: 'K-Meleon'\n , kMeleon: t\n , version: getFirstMatch(/(?:k-meleon)[\\s\\/](\\d+(?:\\.\\d+)+)/i)\n }\n }\n else if (windowsphone) {\n result = {\n name: 'Windows Phone'\n , windowsphone: t\n }\n if (edgeVersion) {\n result.msedge = t\n result.version = edgeVersion\n }\n else {\n result.msie = t\n result.version = getFirstMatch(/iemobile\\/(\\d+(\\.\\d+)?)/i)\n }\n }\n else if (/msie|trident/i.test(ua)) {\n result = {\n name: 'Internet Explorer'\n , msie: t\n , version: getFirstMatch(/(?:msie |rv:)(\\d+(\\.\\d+)?)/i)\n }\n } else if (chromeos) {\n result = {\n name: 'Chrome'\n , chromeos: t\n , chromeBook: t\n , chrome: t\n , version: getFirstMatch(/(?:chrome|crios|crmo)\\/(\\d+(\\.\\d+)?)/i)\n }\n } else if (/chrome.+? edge/i.test(ua)) {\n result = {\n name: 'Microsoft Edge'\n , msedge: t\n , version: edgeVersion\n }\n }\n else if (/vivaldi/i.test(ua)) {\n result = {\n name: 'Vivaldi'\n , vivaldi: t\n , version: getFirstMatch(/vivaldi\\/(\\d+(\\.\\d+)?)/i) || versionIdentifier\n }\n }\n else if (sailfish) {\n result = {\n name: 'Sailfish'\n , sailfish: t\n , version: getFirstMatch(/sailfish\\s?browser\\/(\\d+(\\.\\d+)?)/i)\n }\n }\n else if (/seamonkey\\//i.test(ua)) {\n result = {\n name: 'SeaMonkey'\n , seamonkey: t\n , version: getFirstMatch(/seamonkey\\/(\\d+(\\.\\d+)?)/i)\n }\n }\n else if (/firefox|iceweasel|fxios/i.test(ua)) {\n result = {\n name: 'Firefox'\n , firefox: t\n , version: getFirstMatch(/(?:firefox|iceweasel|fxios)[ \\/](\\d+(\\.\\d+)?)/i)\n }\n if (/\\((mobile|tablet);[^\\)]*rv:[\\d\\.]+\\)/i.test(ua)) {\n result.firefoxos = t\n }\n }\n else if (silk) {\n result = {\n name: 'Amazon Silk'\n , silk: t\n , version : getFirstMatch(/silk\\/(\\d+(\\.\\d+)?)/i)\n }\n }\n else if (/phantom/i.test(ua)) {\n result = {\n name: 'PhantomJS'\n , phantom: t\n , version: getFirstMatch(/phantomjs\\/(\\d+(\\.\\d+)?)/i)\n }\n }\n else if (/slimerjs/i.test(ua)) {\n result = {\n name: 'SlimerJS'\n , slimer: t\n , version: getFirstMatch(/slimerjs\\/(\\d+(\\.\\d+)?)/i)\n }\n }\n else if (/blackberry|\\bbb\\d+/i.test(ua) || /rim\\stablet/i.test(ua)) {\n result = {\n name: 'BlackBerry'\n , blackberry: t\n , version: versionIdentifier || getFirstMatch(/blackberry[\\d]+\\/(\\d+(\\.\\d+)?)/i)\n }\n }\n else if (webos) {\n result = {\n name: 'WebOS'\n , webos: t\n , version: versionIdentifier || getFirstMatch(/w(?:eb)?osbrowser\\/(\\d+(\\.\\d+)?)/i)\n };\n /touchpad\\//i.test(ua) && (result.touchpad = t)\n }\n else if (/bada/i.test(ua)) {\n result = {\n name: 'Bada'\n , bada: t\n , version: getFirstMatch(/dolfin\\/(\\d+(\\.\\d+)?)/i)\n };\n }\n else if (tizen) {\n result = {\n name: 'Tizen'\n , tizen: t\n , version: getFirstMatch(/(?:tizen\\s?)?browser\\/(\\d+(\\.\\d+)?)/i) || versionIdentifier\n };\n }\n else if (/qupzilla/i.test(ua)) {\n result = {\n name: 'QupZilla'\n , qupzilla: t\n , version: getFirstMatch(/(?:qupzilla)[\\s\\/](\\d+(?:\\.\\d+)+)/i) || versionIdentifier\n }\n }\n else if (/chromium/i.test(ua)) {\n result = {\n name: 'Chromium'\n , chromium: t\n , version: getFirstMatch(/(?:chromium)[\\s\\/](\\d+(?:\\.\\d+)?)/i) || versionIdentifier\n }\n }\n else if (/chrome|crios|crmo/i.test(ua)) {\n result = {\n name: 'Chrome'\n , chrome: t\n , version: getFirstMatch(/(?:chrome|crios|crmo)\\/(\\d+(\\.\\d+)?)/i)\n }\n }\n else if (android) {\n result = {\n name: 'Android'\n , version: versionIdentifier\n }\n }\n else if (/safari|applewebkit/i.test(ua)) {\n result = {\n name: 'Safari'\n , safari: t\n }\n if (versionIdentifier) {\n result.version = versionIdentifier\n }\n }\n else if (iosdevice) {\n result = {\n name : iosdevice == 'iphone' ? 'iPhone' : iosdevice == 'ipad' ? 'iPad' : 'iPod'\n }\n // WTF: version is not part of user agent in web apps\n if (versionIdentifier) {\n result.version = versionIdentifier\n }\n }\n else if(/googlebot/i.test(ua)) {\n result = {\n name: 'Googlebot'\n , googlebot: t\n , version: getFirstMatch(/googlebot\\/(\\d+(\\.\\d+))/i) || versionIdentifier\n }\n }\n else {\n result = {\n name: getFirstMatch(/^(.*)\\/(.*) /),\n version: getSecondMatch(/^(.*)\\/(.*) /)\n };\n }\n\n // set webkit or gecko flag for browsers based on these engines\n if (!result.msedge && /(apple)?webkit/i.test(ua)) {\n if (/(apple)?webkit\\/537\\.36/i.test(ua)) {\n result.name = result.name || \"Blink\"\n result.blink = t\n } else {\n result.name = result.name || \"Webkit\"\n result.webkit = t\n }\n if (!result.version && versionIdentifier) {\n result.version = versionIdentifier\n }\n } else if (!result.opera && /gecko\\//i.test(ua)) {\n result.name = result.name || \"Gecko\"\n result.gecko = t\n result.version = result.version || getFirstMatch(/gecko\\/(\\d+(\\.\\d+)?)/i)\n }\n\n // set OS flags for platforms that have multiple browsers\n if (!result.windowsphone && !result.msedge && (android || result.silk)) {\n result.android = t\n } else if (!result.windowsphone && !result.msedge && iosdevice) {\n result[iosdevice] = t\n result.ios = t\n } else if (mac) {\n result.mac = t\n } else if (xbox) {\n result.xbox = t\n } else if (windows) {\n result.windows = t\n } else if (linux) {\n result.linux = t\n }\n\n // OS version extraction\n var osVersion = '';\n if (result.windowsphone) {\n osVersion = getFirstMatch(/windows phone (?:os)?\\s?(\\d+(\\.\\d+)*)/i);\n } else if (iosdevice) {\n osVersion = getFirstMatch(/os (\\d+([_\\s]\\d+)*) like mac os x/i);\n osVersion = osVersion.replace(/[_\\s]/g, '.');\n } else if (android) {\n osVersion = getFirstMatch(/android[ \\/-](\\d+(\\.\\d+)*)/i);\n } else if (result.webos) {\n osVersion = getFirstMatch(/(?:web|hpw)os\\/(\\d+(\\.\\d+)*)/i);\n } else if (result.blackberry) {\n osVersion = getFirstMatch(/rim\\stablet\\sos\\s(\\d+(\\.\\d+)*)/i);\n } else if (result.bada) {\n osVersion = getFirstMatch(/bada\\/(\\d+(\\.\\d+)*)/i);\n } else if (result.tizen) {\n osVersion = getFirstMatch(/tizen[\\/\\s](\\d+(\\.\\d+)*)/i);\n }\n if (osVersion) {\n result.osversion = osVersion;\n }\n\n // device type extraction\n var osMajorVersion = osVersion.split('.')[0];\n if (\n tablet\n || nexusTablet\n || iosdevice == 'ipad'\n || (android && (osMajorVersion == 3 || (osMajorVersion >= 4 && !mobile)))\n || result.silk\n ) {\n result.tablet = t\n } else if (\n mobile\n || iosdevice == 'iphone'\n || iosdevice == 'ipod'\n || android\n || nexusMobile\n || result.blackberry\n || result.webos\n || result.bada\n ) {\n result.mobile = t\n }\n\n // Graded Browser Support\n // http://developer.yahoo.com/yui/articles/gbs\n if (result.msedge ||\n (result.msie && result.version >= 10) ||\n (result.yandexbrowser && result.version >= 15) ||\n\t\t (result.vivaldi && result.version >= 1.0) ||\n (result.chrome && result.version >= 20) ||\n (result.samsungBrowser && result.version >= 4) ||\n (result.firefox && result.version >= 20.0) ||\n (result.safari && result.version >= 6) ||\n (result.opera && result.version >= 10.0) ||\n (result.ios && result.osversion && result.osversion.split(\".\")[0] >= 6) ||\n (result.blackberry && result.version >= 10.1)\n || (result.chromium && result.version >= 20)\n ) {\n result.a = t;\n }\n else if ((result.msie && result.version < 10) ||\n (result.chrome && result.version < 20) ||\n (result.firefox && result.version < 20.0) ||\n (result.safari && result.version < 6) ||\n (result.opera && result.version < 10.0) ||\n (result.ios && result.osversion && result.osversion.split(\".\")[0] < 6)\n || (result.chromium && result.version < 20)\n ) {\n result.c = t\n } else result.x = t\n\n return result\n }\n\n var bowser = detect(typeof navigator !== 'undefined' ? navigator.userAgent || '' : '')\n\n bowser.test = function (browserList) {\n for (var i = 0; i < browserList.length; ++i) {\n var browserItem = browserList[i];\n if (typeof browserItem=== 'string') {\n if (browserItem in bowser) {\n return true;\n }\n }\n }\n return false;\n }\n\n /**\n * Get version precisions count\n *\n * @example\n * getVersionPrecision(\"1.10.3\") // 3\n *\n * @param {string} version\n * @return {number}\n */\n function getVersionPrecision(version) {\n return version.split(\".\").length;\n }\n\n /**\n * Array::map polyfill\n *\n * @param {Array} arr\n * @param {Function} iterator\n * @return {Array}\n */\n function map(arr, iterator) {\n var result = [], i;\n if (Array.prototype.map) {\n return Array.prototype.map.call(arr, iterator);\n }\n for (i = 0; i < arr.length; i++) {\n result.push(iterator(arr[i]));\n }\n return result;\n }\n\n /**\n * Calculate browser version weight\n *\n * @example\n * compareVersions(['1.10.2.1', '1.8.2.1.90']) // 1\n * compareVersions(['1.010.2.1', '1.09.2.1.90']); // 1\n * compareVersions(['1.10.2.1', '1.10.2.1']); // 0\n * compareVersions(['1.10.2.1', '1.0800.2']); // -1\n *\n * @param {Array} versions versions to compare\n * @return {Number} comparison result\n */\n function compareVersions(versions) {\n // 1) get common precision for both versions, for example for \"10.0\" and \"9\" it should be 2\n var precision = Math.max(getVersionPrecision(versions[0]), getVersionPrecision(versions[1]));\n var chunks = map(versions, function (version) {\n var delta = precision - getVersionPrecision(version);\n\n // 2) \"9\" -> \"9.0\" (for precision = 2)\n version = version + new Array(delta + 1).join(\".0\");\n\n // 3) \"9.0\" -> [\"000000000\"\", \"000000009\"]\n return map(version.split(\".\"), function (chunk) {\n return new Array(20 - chunk.length).join(\"0\") + chunk;\n }).reverse();\n });\n\n // iterate in reverse order by reversed chunks array\n while (--precision >= 0) {\n // 4) compare: \"000000009\" > \"000000010\" = false (but \"9\" > \"10\" = true)\n if (chunks[0][precision] > chunks[1][precision]) {\n return 1;\n }\n else if (chunks[0][precision] === chunks[1][precision]) {\n if (precision === 0) {\n // all version chunks are same\n return 0;\n }\n }\n else {\n return -1;\n }\n }\n }\n\n /**\n * Check if browser is unsupported\n *\n * @example\n * bowser.isUnsupportedBrowser({\n * msie: \"10\",\n * firefox: \"23\",\n * chrome: \"29\",\n * safari: \"5.1\",\n * opera: \"16\",\n * phantom: \"534\"\n * });\n *\n * @param {Object} minVersions map of minimal version to browser\n * @param {Boolean} [strictMode = false] flag to return false if browser wasn't found in map\n * @param {String} [ua] user agent string\n * @return {Boolean}\n */\n function isUnsupportedBrowser(minVersions, strictMode, ua) {\n var _bowser = bowser;\n\n // make strictMode param optional with ua param usage\n if (typeof strictMode === 'string') {\n ua = strictMode;\n strictMode = void(0);\n }\n\n if (strictMode === void(0)) {\n strictMode = false;\n }\n if (ua) {\n _bowser = detect(ua);\n }\n\n var version = \"\" + _bowser.version;\n for (var browser in minVersions) {\n if (minVersions.hasOwnProperty(browser)) {\n if (_bowser[browser]) {\n if (typeof minVersions[browser] !== 'string') {\n throw new Error('Browser version in the minVersion map should be a string: ' + browser + ': ' + String(minVersions));\n }\n\n // browser version and min supported version.\n return compareVersions([version, minVersions[browser]]) < 0;\n }\n }\n }\n\n return strictMode; // not found\n }\n\n /**\n * Check if browser is supported\n *\n * @param {Object} minVersions map of minimal version to browser\n * @param {Boolean} [strictMode = false] flag to return false if browser wasn't found in map\n * @param {String} [ua] user agent string\n * @return {Boolean}\n */\n function check(minVersions, strictMode, ua) {\n return !isUnsupportedBrowser(minVersions, strictMode, ua);\n }\n\n bowser.isUnsupportedBrowser = isUnsupportedBrowser;\n bowser.compareVersions = compareVersions;\n bowser.check = check;\n\n /*\n * Set our detect method to the main bowser object so we can\n * reuse it to test other user agents.\n * This is needed to implement future tests.\n */\n bowser._detect = detect;\n\n return bowser\n});\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ../~/bowser/bowser.js\n ** module id = 4\n ** module chunks = 0\n **/","module.exports = function() { throw new Error(\"define cannot be used indirect\"); };\r\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ../~/webpack/buildin/amd-define.js\n ** module id = 5\n ** module chunks = 0\n **/"],"sourceRoot":""} \ No newline at end of file diff --git a/src/cades.js b/src/cades.js index 4fc01e8..de98cb3 100755 --- a/src/cades.js +++ b/src/cades.js @@ -1,126 +1,111 @@ ;(function () { - /** - * Это переделанная версия cadesplugin_api.js с сайта Крипто ПРО, - * в которую добавлена поддержка IE-8. - * - * Обсуждение: - * https://www.cryptopro.ru/forum2/default.aspx?g=posts&t=9271 - * - * Оригинальный файл: - * https://www.cryptopro.ru/sites/default/files/products/cades/cadesplugin_api.js - * */ - var pluginObject, - plugin_resolved = 0, - plugin_reject, - plugin_resolve, - isOpera = 0, - isYaBrowser = 0, - isFireFox = 0, - canPromise = Boolean(window.Promise), - cadesplugin; - - if (window.cadesplugin) { + //already loaded + if(window.cadesplugin) return; - } - if (canPromise) { - cadesplugin = new Promise(function (resolve, reject) { + var pluginObject; + var plugin_resolved = 0; + var plugin_reject; + var plugin_resolve; + var isOpera = 0; + var isYaBrowser = 0; + var isFireFox = 0; + var failed_extensions = 0; + + var canPromise = !!window.Promise; + var cadesplugin; + + if(canPromise) + { + cadesplugin = new Promise(function(resolve, reject) + { plugin_resolve = resolve; plugin_reject = reject; }); - } else { + } else + { cadesplugin = {}; } - function cpcsp_console_log(level, msg) { + function cpcsp_console_log(level, msg){ //IE9 не может писать в консоль если не открыта вкладка developer tools - if (typeof console === 'undefined') { + if(typeof(console) == 'undefined') + return; + if (level <= cadesplugin.current_log_level ){ + if (level == cadesplugin.LOG_LEVEL_DEBUG) + console.log("DEBUG: %s", msg); + if (level == cadesplugin.LOG_LEVEL_INFO) + console.info("INFO: %s", msg); + if (level == cadesplugin.LOG_LEVEL_ERROR) + console.error("ERROR: %s", msg); return; - } - - if (level <= cadesplugin.current_log_level) { - if (level == cadesplugin.LOG_LEVEL_DEBUG) { - console.log('DEBUG: %s', msg); - } - - if (level == cadesplugin.LOG_LEVEL_INFO) { - console.info('INFO: %s', msg); - } - - if (level == cadesplugin.LOG_LEVEL_ERROR) { - console.error('ERROR: %s', msg); - } } } - function set_log_level(level) { - var isSetLoglevel = (level == cadesplugin.LOG_LEVEL_DEBUG) - || (level == cadesplugin.LOG_LEVEL_INFO) - || (level == cadesplugin.LOG_LEVEL_ERROR); - - if (!isSetLoglevel) { - cpcsp_console_log(cadesplugin.LOG_LEVEL_ERROR, 'cadesplugin_api.js: Incorrect log_level: ' + level); - + function set_log_level(level){ + if (!((level == cadesplugin.LOG_LEVEL_DEBUG) || + (level == cadesplugin.LOG_LEVEL_INFO) || + (level == cadesplugin.LOG_LEVEL_ERROR))){ + cpcsp_console_log(cadesplugin.LOG_LEVEL_ERROR, "cadesplugin_api.js: Incorrect log_level: " + level); return; } - cadesplugin.current_log_level = level; - - if (cadesplugin.current_log_level == cadesplugin.LOG_LEVEL_DEBUG) { - cpcsp_console_log(cadesplugin.LOG_LEVEL_INFO, 'cadesplugin_api.js: log_level = DEBUG'); - } - - if (cadesplugin.current_log_level == cadesplugin.LOG_LEVEL_INFO) { - cpcsp_console_log(cadesplugin.LOG_LEVEL_INFO, 'cadesplugin_api.js: log_level = INFO'); - } - - if (cadesplugin.current_log_level == cadesplugin.LOG_LEVEL_ERROR) { - cpcsp_console_log(cadesplugin.LOG_LEVEL_INFO, 'cadesplugin_api.js: log_level = ERROR'); - } - - if (isNativeMessageSupported()) { - if (cadesplugin.current_log_level == cadesplugin.LOG_LEVEL_DEBUG) { - window.postMessage('set_log_level=debug', '*'); - } - - if (cadesplugin.current_log_level == cadesplugin.LOG_LEVEL_INFO) { - window.postMessage('set_log_level=info', '*'); - } - - if (cadesplugin.current_log_level == cadesplugin.LOG_LEVEL_ERROR) { - window.postMessage('set_log_level=error', '*'); - } + if (cadesplugin.current_log_level == cadesplugin.LOG_LEVEL_DEBUG) + cpcsp_console_log(cadesplugin.LOG_LEVEL_INFO, "cadesplugin_api.js: log_level = DEBUG"); + if (cadesplugin.current_log_level == cadesplugin.LOG_LEVEL_INFO) + cpcsp_console_log(cadesplugin.LOG_LEVEL_INFO, "cadesplugin_api.js: log_level = INFO"); + if (cadesplugin.current_log_level == cadesplugin.LOG_LEVEL_ERROR) + cpcsp_console_log(cadesplugin.LOG_LEVEL_INFO, "cadesplugin_api.js: log_level = ERROR"); + if(isNativeMessageSupported()) + { + if (cadesplugin.current_log_level == cadesplugin.LOG_LEVEL_DEBUG) + window.postMessage("set_log_level=debug", "*"); + if (cadesplugin.current_log_level == cadesplugin.LOG_LEVEL_INFO) + window.postMessage("set_log_level=info", "*"); + if (cadesplugin.current_log_level == cadesplugin.LOG_LEVEL_ERROR) + window.postMessage("set_log_level=error", "*"); } } - function set_constantValues() { + function set_constantValues() + { cadesplugin.CAPICOM_LOCAL_MACHINE_STORE = 1; cadesplugin.CAPICOM_CURRENT_USER_STORE = 2; cadesplugin.CADESCOM_LOCAL_MACHINE_STORE = 1; cadesplugin.CADESCOM_CURRENT_USER_STORE = 2; cadesplugin.CADESCOM_CONTAINER_STORE = 100; - cadesplugin.CAPICOM_MY_STORE = 'My'; + + cadesplugin.CAPICOM_MY_STORE = "My"; + cadesplugin.CAPICOM_STORE_OPEN_MAXIMUM_ALLOWED = 2; + cadesplugin.CAPICOM_CERTIFICATE_FIND_SUBJECT_NAME = 1; + cadesplugin.CADESCOM_XML_SIGNATURE_TYPE_ENVELOPED = 0; cadesplugin.CADESCOM_XML_SIGNATURE_TYPE_ENVELOPING = 1; cadesplugin.CADESCOM_XML_SIGNATURE_TYPE_TEMPLATE = 2; - cadesplugin.XmlDsigGost3410UrlObsolete = 'http://www.w3.org/2001/04/xmldsig-more#gostr34102001-gostr3411'; - cadesplugin.XmlDsigGost3411UrlObsolete = 'http://www.w3.org/2001/04/xmldsig-more#gostr3411'; - cadesplugin.XmlDsigGost3410Url = 'urn:ietf:params:xml:ns:cpxmlsec:algorithms:gostr34102001-gostr3411'; - cadesplugin.XmlDsigGost3411Url = 'urn:ietf:params:xml:ns:cpxmlsec:algorithms:gostr3411'; + + cadesplugin.XmlDsigGost3410UrlObsolete = "http://www.w3.org/2001/04/xmldsig-more#gostr34102001-gostr3411"; + cadesplugin.XmlDsigGost3411UrlObsolete = "http://www.w3.org/2001/04/xmldsig-more#gostr3411"; + cadesplugin.XmlDsigGost3410Url = "urn:ietf:params:xml:ns:cpxmlsec:algorithms:gostr34102001-gostr3411"; + cadesplugin.XmlDsigGost3411Url = "urn:ietf:params:xml:ns:cpxmlsec:algorithms:gostr3411"; + cadesplugin.CADESCOM_CADES_DEFAULT = 0; cadesplugin.CADESCOM_CADES_BES = 1; cadesplugin.CADESCOM_CADES_T = 0x5; cadesplugin.CADESCOM_CADES_X_LONG_TYPE_1 = 0x5d; + cadesplugin.CADESCOM_ENCODE_BASE64 = 0; cadesplugin.CADESCOM_ENCODE_BINARY = 1; cadesplugin.CADESCOM_ENCODE_ANY = -1; + cadesplugin.CAPICOM_CERTIFICATE_INCLUDE_CHAIN_EXCEPT_ROOT = 0; cadesplugin.CAPICOM_CERTIFICATE_INCLUDE_WHOLE_CHAIN = 1; cadesplugin.CAPICOM_CERTIFICATE_INCLUDE_END_ENTITY_ONLY = 2; + cadesplugin.CAPICOM_CERT_INFO_SUBJECT_SIMPLE_NAME = 0; cadesplugin.CAPICOM_CERT_INFO_ISSUER_SIMPLE_NAME = 1; + cadesplugin.CAPICOM_CERTIFICATE_FIND_SHA1_HASH = 0; cadesplugin.CAPICOM_CERTIFICATE_FIND_SUBJECT_NAME = 1; cadesplugin.CAPICOM_CERTIFICATE_FIND_ISSUER_NAME = 2; @@ -134,28 +119,37 @@ cadesplugin.CAPICOM_CERTIFICATE_FIND_TIME_NOT_YET_VALID = 10; cadesplugin.CAPICOM_CERTIFICATE_FIND_TIME_EXPIRED = 11; cadesplugin.CAPICOM_CERTIFICATE_FIND_KEY_USAGE = 12; + cadesplugin.CAPICOM_DIGITAL_SIGNATURE_KEY_USAGE = 128; + cadesplugin.CAPICOM_PROPID_ENHKEY_USAGE = 9; + cadesplugin.CAPICOM_OID_OTHER = 0; cadesplugin.CAPICOM_OID_KEY_USAGE_EXTENSION = 10; + cadesplugin.CAPICOM_EKU_CLIENT_AUTH = 2; cadesplugin.CAPICOM_EKU_SMARTCARD_LOGON = 5; cadesplugin.CAPICOM_EKU_OTHER = 0; + cadesplugin.CAPICOM_AUTHENTICATED_ATTRIBUTE_SIGNING_TIME = 0; cadesplugin.CADESCOM_AUTHENTICATED_ATTRIBUTE_DOCUMENT_NAME = 1; cadesplugin.CADESCOM_AUTHENTICATED_ATTRIBUTE_DOCUMENT_DESCRIPTION = 2; cadesplugin.CADESCOM_ATTRIBUTE_OTHER = -1; + cadesplugin.CADESCOM_STRING_TO_UCS2LE = 0; cadesplugin.CADESCOM_BASE64_TO_BINARY = 1; + cadesplugin.CADESCOM_DISPLAY_DATA_NONE = 0; cadesplugin.CADESCOM_DISPLAY_DATA_CONTENT = 1; cadesplugin.CADESCOM_DISPLAY_DATA_ATTRIBUTE = 2; + cadesplugin.CADESCOM_ENCRYPTION_ALGORITHM_RC2 = 0; cadesplugin.CADESCOM_ENCRYPTION_ALGORITHM_RC4 = 1; cadesplugin.CADESCOM_ENCRYPTION_ALGORITHM_DES = 2; cadesplugin.CADESCOM_ENCRYPTION_ALGORITHM_3DES = 3; cadesplugin.CADESCOM_ENCRYPTION_ALGORITHM_AES = 4; cadesplugin.CADESCOM_ENCRYPTION_ALGORITHM_GOST_28147_89 = 25; + cadesplugin.CADESCOM_HASH_ALGORITHM_SHA1 = 0; cadesplugin.CADESCOM_HASH_ALGORITHM_MD2 = 1; cadesplugin.CADESCOM_HASH_ALGORITHM_MD4 = 2; @@ -166,67 +160,65 @@ cadesplugin.CADESCOM_HASH_ALGORITHM_CP_GOST_3411 = 100; cadesplugin.CADESCOM_HASH_ALGORITHM_CP_GOST_3411_2012_256 = 101; cadesplugin.CADESCOM_HASH_ALGORITHM_CP_GOST_3411_2012_512 = 102; + cadesplugin.LOG_LEVEL_DEBUG = 4; cadesplugin.LOG_LEVEL_INFO = 2; cadesplugin.LOG_LEVEL_ERROR = 1; } function async_spawn(generatorFunc) { - var generator = generatorFunc(Array.prototype.slice.call(arguments, 1)), - onFulfilled = continuer.bind(continuer, 'next'), - onRejected = continuer.bind(continuer, 'throw'); - - function continuer(verb, arg) { - var result; - - try { - result = generator[verb](arg); - } catch (err) { - return Promise.reject(err); - } - - if (result.done) { - return result.value; - } else { - return Promise.resolve(result.value).then(onFulfilled, onRejected); - } + function continuer(verb, arg) { + var result; + try { + result = generator[verb](arg); + } catch (err) { + return Promise.reject(err); } - - return onFulfilled(); + if (result.done) { + return result.value; + } else { + return Promise.resolve(result.value).then(onFulfilled, onRejected); + } + } + var generator = generatorFunc(Array.prototype.slice.call(arguments, 1)); + var onFulfilled = continuer.bind(continuer, "next"); + var onRejected = continuer.bind(continuer, "throw"); + return onFulfilled(); } function isIE() { - return navigator.appName === 'Microsoft Internet Explorer' // IE < 11 - || navigator.userAgent.match(/Trident\/./i); // IE 11 + var retVal = (("Microsoft Internet Explorer" == navigator.appName) || // IE < 11 + navigator.userAgent.match(/Trident\/./i)); // IE 11 + return retVal; } function isIOS() { - return navigator.userAgent.match(/ipod/i) - || navigator.userAgent.match(/ipad/i) - || navigator.userAgent.match(/iphone/i); + var retVal = (navigator.userAgent.match(/ipod/i) || + navigator.userAgent.match(/ipad/i) || + navigator.userAgent.match(/iphone/i)); + return retVal; } - function isNativeMessageSupported() { + function isNativeMessageSupported() + { var retVal_chrome = navigator.userAgent.match(/chrome/i); - isOpera = navigator.userAgent.match(/opr/i); isYaBrowser = navigator.userAgent.match(/YaBrowser/i); isFireFox = navigator.userAgent.match(/Firefox/i); - if (isFireFox && window.allow_firefox_cadesplugin_async) { + if(isFireFox && window.allow_firefox_cadesplugin_async) return true; - } - if (retVal_chrome == null) { - // В IE работаем через NPAPI + if(retVal_chrome == null) // В IE работаем через NPAPI return false; - } else { + else + { // В Chrome и Opera работаем через асинхронную версию - if (retVal_chrome.length > 0 || isOpera != null) { + if(retVal_chrome.length > 0 || isOpera != null ) + { return true; } } - return false; } @@ -235,30 +227,26 @@ if (isIOS()) { // На iOS для создания объектов используется функция // call_ru_cryptopro_npcades_10_native_bridge, определенная в IOS_npcades_supp.js - return call_ru_cryptopro_npcades_10_native_bridge('CreateObject', [name]); + return call_ru_cryptopro_npcades_10_native_bridge("CreateObject", [name]); } - if (isIE()) { - // В Internet Explorer создаются COM-объекты - if (name.match(/X509Enrollment/i)) { + // В Internet Explorer создаются COM-объекты + if (name.match(/X509Enrollment/i)) { try { // Объекты CertEnroll создаются через CX509EnrollmentWebClassFactory - var objCertEnrollClassFactory = document.getElementById('certEnrollClassFactory'); + var objCertEnrollClassFactory = document.getElementById("certEnrollClassFactory"); return objCertEnrollClassFactory.CreateObject(name); - } catch (e) { - throw( - 'Для создания обьектов X509Enrollment следует настроить ' + - 'веб-узел на использование проверки подлинности по протоколу HTTPS' - ); + } + catch (e) { + throw("Для создания обьектов X509Enrollment следует настроить веб-узел на использование проверки подлинности по протоколу HTTPS"); } } - // Объекты CAPICOM и CAdESCOM создаются через CAdESCOM.WebClassFactory try { - var objWebClassFactory = document.getElementById('webClassFactory'); - + var objWebClassFactory = document.getElementById("webClassFactory"); return objWebClassFactory.CreateObject(name); - } catch (e) { + } + catch (e) { try { // Для версий плагина ниже 2.0.12538 return new ActiveXObject(name); @@ -281,7 +269,6 @@ } } } - // В Firefox, Safari создаются объекты NPAPI return pluginObject.CreateObject(name); } @@ -296,24 +283,22 @@ function GetMessageFromException(e) { var err = e.message; - if (!err) { err = e; } else if (e.number) { - err += ' (0x' + decimalToHexString(e.number) + ')'; + err += " (0x" + decimalToHexString(e.number) + ")"; } - return err; } function getLastError(exception) { - if (isNativeMessageSupported() || isIE() || isIOS()) { + if(isNativeMessageSupported() || isIE() || isIOS() ) { return GetMessageFromException(exception); } try { return pluginObject.getLastError(); - } catch (e) { + } catch(e) { return GetMessageFromException(exception); } } @@ -323,312 +308,284 @@ return pluginObject.CreateObjectAsync(name); } - // Функции для IOS + //Функции для IOS var ru_cryptopro_npcades_10_native_bridge = { - callbacksCount: 1, - callbacks: {}, + callbacksCount : 1, + callbacks : {}, - // Automatically called by native layer when a result is available - resultForCallback: function resultForCallback(callbackId, resultArray) { + // Automatically called by native layer when a result is available + resultForCallback : function resultForCallback(callbackId, resultArray) { var callback = ru_cryptopro_npcades_10_native_bridge.callbacks[callbackId]; + if (!callback) return; + callback.apply(null,resultArray); + }, - if (!callback) { - return; + // Use this in javascript to request native objective-c code + // functionName : string (I think the name is explicit :p) + // args : array of arguments + // callback : function with n-arguments that is going to be called when the native code returned + call : function call(functionName, args, callback) { + var hasCallback = callback && typeof callback == "function"; + var callbackId = hasCallback ? ru_cryptopro_npcades_10_native_bridge.callbacksCount++ : 0; + + if (hasCallback) + ru_cryptopro_npcades_10_native_bridge.callbacks[callbackId] = callback; + + var iframe = document.createElement("IFRAME"); + var arrObjs = new Array("_CPNP_handle"); + try{ + iframe.setAttribute("src", "cpnp-js-call:" + functionName + ":" + callbackId+ ":" + encodeURIComponent(JSON.stringify(args, arrObjs))); + } catch(e){ + alert(e); } - - callback.apply(null, resultArray); - }, - - // Use this in javascript to request native objective-c code - // functionName : string (I think the name is explicit :p) - // args : array of arguments - // callback : function with n-arguments that is going to be called when the native code returned - call: function call(functionName, args, callback) { - var hasCallback = callback && typeof callback == 'function', - callbackId = hasCallback ? ru_cryptopro_npcades_10_native_bridge.callbacksCount++ : 0, - iframe, - arrObjs; - - if (hasCallback) { - ru_cryptopro_npcades_10_native_bridge.callbacks[callbackId] = callback; - } - - iframe = document.createElement('IFRAME'); - - arrObjs = new Array('_CPNP_handle'); - - try { - iframe.setAttribute( - 'src', - 'cpnp-js-call:' + - functionName + ':' + callbackId + ':' + encodeURIComponent(JSON.stringify(args, arrObjs)) - ); - } catch (e) { - alert(e); - } - - document.documentElement.appendChild(iframe); - - iframe.parentNode.removeChild(iframe); - iframe = null; - } + document.documentElement.appendChild(iframe); + iframe.parentNode.removeChild(iframe); + iframe = null; + } }; - function call_ru_cryptopro_npcades_10_native_bridge(functionName, array) { - var tmpobj, - ex; - - ru_cryptopro_npcades_10_native_bridge.call(functionName, array, function (e, response) { - ex = e; - var str = 'tmpobj=' + response; - - eval(str); - - if (typeof (tmpobj) == 'string') { - tmpobj = tmpobj.replace(/\\\n/gm, '\n'); - tmpobj = tmpobj.replace(/\\\r/gm, '\r'); - } - }); - - if (ex) { + function call_ru_cryptopro_npcades_10_native_bridge(functionName, array){ + var tmpobj; + var ex; + ru_cryptopro_npcades_10_native_bridge.call(functionName, array, function(e, response){ + ex = e; + var str='tmpobj='+response; + eval(str); + if (typeof (tmpobj) == "string"){ + tmpobj = tmpobj.replace(/\\\n/gm, "\n"); + tmpobj = tmpobj.replace(/\\\r/gm, "\r"); + } + }); + if(ex) throw ex; - } - return tmpobj; } - // Выводим окно поверх других с предложением установить расширение для Opera. - // Если установленна переменная cadesplugin_skip_extension_install - не предлагаем установить расширение - function install_opera_extension() { - if (!window.cadesplugin_skip_extension_install) { - var ovr = document.createElement('div'); + //Выводим окно поверх других с предложением установить расширение для Opera. + //Если установленна переменная cadesplugin_skip_extension_install - не предлагаем установить расширение + function install_opera_extension() + { + if (!window.cadesplugin_skip_extension_install) + { + document.addEventListener('DOMContentLoaded', function() { + var ovr = document.createElement('div'); + ovr.id = "cadesplugin_ovr"; + ovr.style = "visibility: hidden; position: fixed; left: 0px; top: 0px; width:100%; height:100%; background-color: rgba(0,0,0,0.7)"; + ovr.innerHTML = "
" + + "" + + "

Для работы КриптоПро ЭЦП Browser plugin на данном сайте необходимо установить расширение из каталога дополнений Opera." + + "

" + + "
"; + document.getElementsByTagName("Body")[0].appendChild(ovr); + var btn_install = document.getElementById("cadesplugin_install"); + btn_install.addEventListener('click', function(event) { + opr.addons.installExtension("epebfcehmdedogndhlcacafjaacknbcm", + function() + { + document.getElementById("cadesplugin_ovr").style.visibility = 'hidden'; + location.reload(); + }, + function(){}) + }); + document.getElementById("cadesplugin_close_install").addEventListener('click',function() + { + plugin_loaded_error("Плагин недоступен"); + document.getElementById("cadesplugin_ovr").style.visibility = 'hidden'; + }); - ovr.id = 'cadesplugin_ovr'; - ovr.style = [ - 'visibility: hidden; position: fixed; left: 0px; top: 0px;', - 'width:100%; height:100%; background-color: rgba(0,0,0,0.7)' - ].join(' '); - - ovr.innerHTML = '\ -
\ - \ -

\ - Для работы КриптоПро ЭЦП Browser plugin на данном сайте необходимо установить\ - расширение из каталога дополнений Opera.\ -

\ -

\ -
\ - '; - - document.getElementsByTagName('Body')[0].appendChild(ovr); - - var btn_install = document.getElementById('cadesplugin_install'); - - btn_install.addEventListener('click', function (event) { - opr.addons.installExtension('epebfcehmdedogndhlcacafjaacknbcm', - function () { - document.getElementById('cadesplugin_ovr').style.visibility = 'hidden'; - location.reload(); - }, - function () {} - ); + ovr.addEventListener('click',function() + { + plugin_loaded_error("Плагин недоступен"); + document.getElementById("cadesplugin_ovr").style.visibility = 'hidden'; + }); + ovr.style.visibility="visible"; + document.getElementById("cadesplugin_ovr_item").addEventListener('click',function(e){ + e.stopPropagation(); + }); }); - - document.getElementById('cadesplugin_close_install').addEventListener('click', function () { - plugin_loaded_error('Плагин недоступен'); - document.getElementById('cadesplugin_ovr').style.visibility = 'hidden'; - }); - - ovr.addEventListener('click', function () { - plugin_loaded_error('Плагин недоступен'); - document.getElementById('cadesplugin_ovr').style.visibility = 'hidden'; - }); - - ovr.style.visibility = 'visible'; - - document.getElementById('cadesplugin_ovr_item').addEventListener('click', function (e) { - e.stopPropagation(); - }); - } else { - plugin_loaded_error('Плагин недоступен'); + }else + { + plugin_loaded_error("Плагин недоступен"); } } function firefox_nmcades_onload() { - window.cpcsp_chrome_nmcades.check_chrome_plugin(plugin_loaded, plugin_loaded_error); + cpcsp_chrome_nmcades.check_chrome_plugin(plugin_loaded, plugin_loaded_error); } - function nmcades_api_onload() { - window.postMessage('cadesplugin_echo_request', '*'); - - window.addEventListener('message', function (event) { - if (typeof event.data !== 'string' || !event.data.match('cadesplugin_loaded')) { - return; - } - - if (isFireFox) { + function nmcades_api_onload () { + window.postMessage("cadesplugin_echo_request", "*"); + window.addEventListener("message", function (event){ + if (typeof(event.data) != "string" || !event.data.match("cadesplugin_loaded")) + return; + if(isFireFox) + { // Для Firefox вместе с сообщением cadesplugin_loaded прилетает url для загрузки nmcades_plugin_api.js - var url = event.data.substring(event.data.indexOf('url:') + 4); + var url = event.data.substring(event.data.indexOf("url:") + 4); var fileref = document.createElement('script'); - - fileref.setAttribute('type', 'text/javascript'); - fileref.setAttribute('src', url); + fileref.setAttribute("type", "text/javascript"); + fileref.setAttribute("src", url); fileref.onerror = plugin_loaded_error; fileref.onload = firefox_nmcades_onload; - document.getElementsByTagName('head')[0].appendChild(fileref); - } else { + document.getElementsByTagName("head")[0].appendChild(fileref); + + }else { cpcsp_chrome_nmcades.check_chrome_plugin(plugin_loaded, plugin_loaded_error); } }, false); } //Загружаем расширения для Chrome, Opera, YaBrowser, FireFox, Edge - function load_extension() { - if (isFireFox) { + function load_extension() + { + + if(isFireFox){ // вызываем callback руками т.к. нам нужно узнать ID расширения. Он уникальный для браузера. nmcades_api_onload(); return; } else { - var fileref = document.createElement('script'), - hash = isNativeMessageSupported() && isOpera ? 'epebfcehmdedogndhlcacafjaacknbcm' : 'iifchhfnnmpdbibifmljnfjhpififfog'; - - if (hash) { - fileref.setAttribute('type', 'text/javascript'); - fileref.setAttribute('src', 'chrome-extension://' + hash + '/nmcades_plugin_api.js'); - fileref.onerror = plugin_loaded_error; - fileref.onload = nmcades_api_onload; - document.getElementsByTagName('head')[0].appendChild(fileref); - } + // в асинхронном варианте для chrome и opera подключаем оба расширения + var fileref = document.createElement('script'); + fileref.setAttribute("type", "text/javascript"); + fileref.setAttribute("src", "chrome-extension://iifchhfnnmpdbibifmljnfjhpififfog/nmcades_plugin_api.js"); + fileref.onerror = plugin_loaded_error; + fileref.onload = nmcades_api_onload; + document.getElementsByTagName("head")[0].appendChild(fileref); + fileref = document.createElement('script'); + fileref.setAttribute("type", "text/javascript"); + fileref.setAttribute("src", "chrome-extension://epebfcehmdedogndhlcacafjaacknbcm/nmcades_plugin_api.js"); + fileref.onerror = plugin_loaded_error; + fileref.onload = nmcades_api_onload; + document.getElementsByTagName("head")[0].appendChild(fileref); } } - // Загружаем плагин для NPAPI - function load_npapi_plugin() { + //Загружаем плагин для NPAPI + function load_npapi_plugin() + { var elem = document.createElement('object'); - - elem.setAttribute('id', 'cadesplugin_object'); - elem.setAttribute('type', 'application/x-cades'); - elem.setAttribute('style', 'visibility: hidden'); - document.getElementsByTagName('body')[0].appendChild(elem); - - pluginObject = document.getElementById('cadesplugin_object'); - - if (isIE()) { + elem.setAttribute("id", "cadesplugin_object"); + elem.setAttribute("type", "application/x-cades"); + elem.setAttribute("style", "visibility: hidden"); + document.getElementsByTagName("body")[0].appendChild(elem); + pluginObject = document.getElementById("cadesplugin_object"); + if(isIE()) + { var elem1 = document.createElement('object'); - - elem1.setAttribute('id', 'certEnrollClassFactory'); - elem1.setAttribute('classid', 'clsid:884e2049-217d-11da-b2a4-000e7bbb2b09'); - elem1.setAttribute('style', 'visibility: hidden'); - document.getElementsByTagName('body')[0].appendChild(elem1); - + elem1.setAttribute("id", "certEnrollClassFactory"); + elem1.setAttribute("classid", "clsid:884e2049-217d-11da-b2a4-000e7bbb2b09"); + elem1.setAttribute("style", "visibility: hidden"); + document.getElementsByTagName("body")[0].appendChild(elem1); var elem2 = document.createElement('object'); - elem2.setAttribute('id', 'webClassFactory'); - elem2.setAttribute('classid', 'clsid:B04C8637-10BD-484E-B0DA-B8A039F60024'); - elem2.setAttribute('style', 'visibility: hidden'); - - document.getElementsByTagName('body')[0].appendChild(elem2); + elem2.setAttribute("id", "webClassFactory"); + elem2.setAttribute("classid", "clsid:B04C8637-10BD-484E-B0DA-B8A039F60024"); + elem2.setAttribute("style", "visibility: hidden"); + document.getElementsByTagName("body")[0].appendChild(elem2); } } - // Отправляем событие что все ок. - function plugin_loaded() { + //Отправляем событие что все ок. + function plugin_loaded() + { plugin_resolved = 1; - if (canPromise) { + if(canPromise) + { plugin_resolve(); - } else { - window.postMessage('cadesplugin_loaded', '*'); + }else { + window.postMessage("cadesplugin_loaded", "*"); } } - // Отправляем событие что сломались. - function plugin_loaded_error(msg) { - if (isNativeMessageSupported()) { - if (isOpera && (typeof(msg) == 'undefined' || typeof(msg) == 'object')) { + //Отправляем событие что сломались. + function plugin_loaded_error(msg) + { + if(isNativeMessageSupported()) + { + //в асинхронном варианте подключаем оба расширения, если сломались оба пробуем установить для Opera + failed_extensions++; + if(failed_extensions<2) + return; + if(isOpera && (typeof(msg) == 'undefined'|| typeof(msg) == 'object')) + { install_opera_extension(); return; } } - - if (typeof(msg) == 'undefined' || typeof(msg) == 'object') { - msg = 'Плагин недоступен'; - } - + if(typeof(msg) == 'undefined' || typeof(msg) == 'object') + msg = "Плагин недоступен"; plugin_resolved = 1; - - if (canPromise) { + if(canPromise) + { plugin_reject(msg); } else { - window.postMessage('cadesplugin_load_error', '*'); + window.postMessage("cadesplugin_load_error", "*"); } } - // проверяем что у нас хоть какое то событие ушло, и если не уходило кидаем еще раз ошибку - function check_load_timeout() { - if (plugin_resolved == 1) { + //проверяем что у нас хоть какое то событие ушло, и если не уходило кидаем еще раз ошибку + function check_load_timeout() + { + if(plugin_resolved == 1) return; - } - plugin_resolved = 1; - - if (canPromise) { - plugin_reject('Истекло время ожидания загрузки плагина'); + if(canPromise) + { + plugin_reject("Истекло время ожидания загрузки плагина"); } else { - window.postMessage('cadesplugin_load_error', '*'); + window.postMessage("cadesplugin_load_error", "*"); } + } - function check_npapi_plugin() { - try { - var oAbout = CreateObject('CAdESCOM.About'); + //Вспомогательная функция для NPAPI + function createPromise(arg) + { + return new Promise(arg); + } + function check_npapi_plugin (){ + try { + var oAbout = CreateObject("CAdESCOM.About"); plugin_loaded(); - } catch (err) { - document.getElementById('cadesplugin_object').style.display = 'none'; + } + catch (err) { + document.getElementById("cadesplugin_object").style.display = 'none'; // Объект создать не удалось, проверим, установлен ли // вообще плагин. Такая возможность есть не во всех браузерах - var mimetype = navigator.mimeTypes['application/x-cades']; + var mimetype = navigator.mimeTypes["application/x-cades"]; if (mimetype) { var plugin = mimetype.enabledPlugin; if (plugin) { - plugin_loaded_error('Плагин загружен, но не создаются обьекты'); - } else { - plugin_loaded_error('Ошибка при загрузке плагина'); + plugin_loaded_error("Плагин загружен, но не создаются обьекты"); + }else + { + plugin_loaded_error("Ошибка при загрузке плагина"); } - } else { - plugin_loaded_error('Плагин недоступен'); + }else + { + plugin_loaded_error("Плагин недоступен"); } } } - // Проверяем работает ли плагин - function check_plugin_working() { - if (isNativeMessageSupported()) { + //Проверяем работает ли плагин + function check_plugin_working() + { + if(isNativeMessageSupported()) + { load_extension(); - } else if (!canPromise) { - window.addEventListener('message', function (event) { - if (event.data != 'cadesplugin_echo_request') { - return; - } - - load_npapi_plugin(); - check_npapi_plugin(); - }, false); - } else { + }else if(!canPromise) { + window.addEventListener("message", function (event){ + if (event.data != "cadesplugin_echo_request") + return; + load_npapi_plugin(); + check_npapi_plugin(); + }, + false); + }else + { if (window.addEventListener) { - window.addEventListener('load', function (event) { + window.addEventListener("load", function (event) { load_npapi_plugin(); check_npapi_plugin(); }, false); @@ -639,40 +596,40 @@ } } - function set_pluginObject(obj) { + function set_pluginObject(obj) + { pluginObject = obj; } - // Export - cadesplugin.JSModuleVersion = '2.1.0'; + //Export + cadesplugin.JSModuleVersion = "2.1.0"; cadesplugin.async_spawn = async_spawn; cadesplugin.set = set_pluginObject; cadesplugin.set_log_level = set_log_level; cadesplugin.getLastError = getLastError; - if (isNativeMessageSupported()) { + if(isNativeMessageSupported()) + { cadesplugin.CreateObjectAsync = CreateObjectAsync; } - if (!isNativeMessageSupported()) { + if(!isNativeMessageSupported()) + { cadesplugin.CreateObject = CreateObject; } - if (window.cadesplugin_load_timeout) { + if(window.cadesplugin_load_timeout) + { setTimeout(check_load_timeout, window.cadesplugin_load_timeout); - } else { - /** - * Даже при слабом интернете плагин успевает загрузиться - * менее чем за секунду, тк отдается из кэша - * */ + } + else + { setTimeout(check_load_timeout, 20000); } set_constantValues(); cadesplugin.current_log_level = cadesplugin.LOG_LEVEL_ERROR; - window.cadesplugin = cadesplugin; - check_plugin_working(); -}()); \ No newline at end of file +}());