diff --git a/src/vendor/cadesplugin_api.js b/src/vendor/cadesplugin_api.js index 772ccf5..ac32da5 100644 --- a/src/vendor/cadesplugin_api.js +++ b/src/vendor/cadesplugin_api.js @@ -9,11 +9,11 @@ var plugin_resolve; var isOpera = 0; var isFireFox = 0; - var isEdge = 0; var isSafari = 0; - var failed_extensions = 0; - + var isYandex = 0; var canPromise = !!window.Promise; + var cadesplugin_loaded_event_recieved = false; + var isFireFoxExtensionLoaded = false; var cadesplugin; if(canPromise) @@ -29,17 +29,19 @@ } function check_browser() { - var ua= navigator.userAgent, tem, M= ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || []; + var ua= navigator.userAgent, tem, M= ua.match(/(opera|yabrowser|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || []; if(/trident/i.test(M[1])){ - tem= /\brv[ :]+(\d+)/g.exec(ua) || []; - return {name:'IE',version:(tem[1] || '')}; + tem = /\brv[ :]+(\d+)/g.exec(ua) || []; + return { name:'IE', version:(tem[1] || '')}; } - if(M[1]=== 'Chrome'){ - tem= ua.match(/\b(OPR|Edge)\/(\d+)/); - if(tem!= null) return {name:tem[1].replace('OPR', 'Opera'),version:tem[2]}; + if(M[1] === 'Chrome'){ + tem = ua.match(/\b(OPR|Edg|YaBrowser)\/(\d+)/); + if (tem != null) + return { name: tem[1].replace('OPR', 'Opera'), version: tem[2] }; } M= M[2]? [M[1], M[2]]: [navigator.appName, navigator.appVersion, '-?']; - if((tem= ua.match(/version\/(\d+)/i))!= null) M.splice(1, 1, tem[1]); + if ((tem = ua.match(/version\/(\d+)/i)) != null) + M.splice(1, 1, tem[1]); return {name:M[0],version:M[1]}; } var browserSpecs = check_browser(); @@ -59,6 +61,17 @@ } } + function get_extension_version(callback) { + window.postMessage("cadesplugin_extension_version_request", "*"); + window.addEventListener("message", function (event) { + var resp_prefix = "cadesplugin_extension_version_response:"; + if (typeof (event.data) !== "string" || event.data.indexOf(resp_prefix) !== 0) + return; + ext_version = event.data.substring(resp_prefix.length); + callback(ext_version); + }, false); + } + function set_log_level(level){ if (!((level === cadesplugin.LOG_LEVEL_DEBUG) || (level === cadesplugin.LOG_LEVEL_INFO) || @@ -86,14 +99,19 @@ function set_constantValues() { + cadesplugin.CAPICOM_MEMORY_STORE = 0; cadesplugin.CAPICOM_LOCAL_MACHINE_STORE = 1; cadesplugin.CAPICOM_CURRENT_USER_STORE = 2; + cadesplugin.CAPICOM_SMART_CARD_USER_STORE = 4; + cadesplugin.CADESCOM_MEMORY_STORE = 0; cadesplugin.CADESCOM_LOCAL_MACHINE_STORE = 1; cadesplugin.CADESCOM_CURRENT_USER_STORE = 2; + cadesplugin.CADESCOM_SMART_CARD_USER_STORE = 4; cadesplugin.CADESCOM_CONTAINER_STORE = 100; cadesplugin.CAPICOM_MY_STORE = "My"; + cadesplugin.CAPICOM_STORE_OPEN_READ_WRITE = 1; cadesplugin.CAPICOM_STORE_OPEN_MAXIMUM_ALLOWED = 2; cadesplugin.CAPICOM_CERTIFICATE_FIND_SUBJECT_NAME = 1; @@ -102,10 +120,21 @@ cadesplugin.CADESCOM_XML_SIGNATURE_TYPE_ENVELOPING = 1; cadesplugin.CADESCOM_XML_SIGNATURE_TYPE_TEMPLATE = 2; + cadesplugin.CADESCOM_XADES_DEFAULT = 0x00000010; + cadesplugin.CADESCOM_XADES_BES = 0x00000020; + cadesplugin.CADESCOM_XADES_T = 0x00000050; + cadesplugin.CADESCOM_XADES_X_LONG_TYPE_1 = 0x000005d0; + cadesplugin.CADESCOM_XMLDSIG_TYPE = 0x00000000; + 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.XmlDsigGost3411Url2012256 = "urn:ietf:params:xml:ns:cpxmlsec:algorithms:gostr34112012-256"; + cadesplugin.XmlDsigGost3410Url2012256 = "urn:ietf:params:xml:ns:cpxmlsec:algorithms:gostr34102012-gostr34112012-256"; + cadesplugin.XmlDsigGost3411Url2012512 = "urn:ietf:params:xml:ns:cpxmlsec:algorithms:gostr34112012-512"; + cadesplugin.XmlDsigGost3410Url2012512 = "urn:ietf:params:xml:ns:cpxmlsec:algorithms:gostr34102012-gostr34112012-512"; cadesplugin.CADESCOM_CADES_DEFAULT = 0; cadesplugin.CADESCOM_CADES_BES = 1; @@ -155,6 +184,7 @@ cadesplugin.CADESCOM_AUTHENTICATED_ATTRIBUTE_SIGNING_TIME = 0; cadesplugin.CADESCOM_AUTHENTICATED_ATTRIBUTE_DOCUMENT_NAME = 1; cadesplugin.CADESCOM_AUTHENTICATED_ATTRIBUTE_DOCUMENT_DESCRIPTION = 2; + cadesplugin.CADESCOM_AUTHENTICATED_ATTRIBUTE_MACHINE_INFO = 0x100; cadesplugin.CADESCOM_ATTRIBUTE_OTHER = -1; cadesplugin.CADESCOM_STRING_TO_UCS2LE = 0; @@ -194,6 +224,39 @@ cadesplugin.CADESCOM_AllowUntrustedCertificate = 0x2; cadesplugin.CADESCOM_AllowUntrustedRoot = 0x4; cadesplugin.CADESCOM_SkipInstallToStore = 0x10000000; + cadesplugin.CADESCOM_InstallCertChainToContainer = 0x20000000; + cadesplugin.CADESCOM_UseContainerStore = 0x40000000; + + cadesplugin.ENABLE_CARRIER_TYPE_CSP = 0x01; + cadesplugin.ENABLE_CARRIER_TYPE_FKC_NO_SM = 0x02; + cadesplugin.ENABLE_CARRIER_TYPE_FKC_SM = 0x04; + cadesplugin.ENABLE_ANY_CARRIER_TYPE = 0x07; + + cadesplugin.DISABLE_EVERY_CARRIER_OPERATION = 0x00; + cadesplugin.ENABLE_CARRIER_OPEN_ENUM = 0x01; + cadesplugin.ENABLE_CARRIER_CREATE = 0x02; + cadesplugin.ENABLE_ANY_OPERATION = 0x03; + + cadesplugin.CADESCOM_PRODUCT_CSP = 0; + cadesplugin.CADESCOM_PRODUCT_OCSP = 1; + cadesplugin.CADESCOM_PRODUCT_TSP = 2; + + cadesplugin.MEDIA_TYPE_REGISTRY = 0x00000001; + cadesplugin.MEDIA_TYPE_HDIMAGE = 0x00000002; + cadesplugin.MEDIA_TYPE_CLOUD = 0x00000004; + cadesplugin.MEDIA_TYPE_SCARD = 0x00000008; + + cadesplugin.XCN_CRYPT_STRING_BASE64HEADER = 0; + cadesplugin.AT_KEYEXCHANGE = 1; + cadesplugin.AT_SIGNATURE = 2; + + cadesplugin.CARRIER_FLAG_REMOVABLE = 1; + cadesplugin.CARRIER_FLAG_UNIQUE = 2; + cadesplugin.CARRIER_FLAG_PROTECTED = 4; + cadesplugin.CARRIER_FLAG_FUNCTIONAL_CARRIER = 8; + cadesplugin.CARRIER_FLAG_SECURE_MESSAGING = 16; + cadesplugin.CARRIER_FLAG_ABLE_VISUALISE_SIGNATURE = 64; + cadesplugin.CARRIER_FLAG_VIRTUAL = 128; } function async_spawn(generatorFunc) { @@ -234,8 +297,11 @@ if(isIE()) return false; // В Edge работаем через NativeMessage - if(browserSpecs.name === 'Edge') { - isEdge = true; + if (browserSpecs.name === 'Edg') { + return true; + } + if (browserSpecs.name === 'YaBrowser') { + isYandex = true; return true; } // В Chrome, Firefox, Safari и Opera работаем через асинхронную версию в зависимости от версии @@ -416,7 +482,7 @@ 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 на данном сайте необходимо расширение для браузера. Убедитесь, что оно у Вас включено или установите его." + "
" + @@ -436,104 +502,71 @@ ovr.style.visibility="visible"; } } - - - //Выводим окно поверх других с предложением установить расширение для 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." + - "
" + - "