Release 2.3.1

This commit is contained in:
Artem Vasilev 2021-09-15 14:00:09 +03:00
parent f21a69bee5
commit 73dd1c82e1
5 changed files with 702 additions and 708 deletions

View File

@ -1,4 +1,4 @@
// Type definitions for crypto-pro-js 2.3.0
// Type definitions for crypto-pro-js 2.3.1
// Project: crypto-pro-js
// Definitions by: Artem Vasilev https://github.com/kernusr

174
dist/crypto-pro-js.js vendored
View File

@ -4677,11 +4677,10 @@ exports._parseCertInfo = function (tagsTranslations, rawInfo) {
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 cadesplugin;
if(canPromise)
@ -4697,17 +4696,19 @@ exports._parseCertInfo = function (tagsTranslations, rawInfo) {
}
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();
@ -4754,10 +4755,14 @@ exports._parseCertInfo = function (tagsTranslations, rawInfo) {
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";
@ -4770,11 +4775,22 @@ exports._parseCertInfo = function (tagsTranslations, rawInfo) {
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;
cadesplugin.CADESCOM_CADES_T = 0x5;
@ -4823,6 +4839,7 @@ exports._parseCertInfo = function (tagsTranslations, rawInfo) {
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;
@ -4862,6 +4879,31 @@ exports._parseCertInfo = function (tagsTranslations, rawInfo) {
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;
}
function async_spawn(generatorFunc) {
@ -4902,8 +4944,11 @@ exports._parseCertInfo = function (tagsTranslations, rawInfo) {
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 работаем через асинхронную версию в зависимости от версии
@ -5104,57 +5149,7 @@ exports._parseCertInfo = function (tagsTranslations, rawInfo) {
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 = "<div id='cadesplugin_ovr_item' style='position:relative; width:400px; margin:100px auto; background-color:#fff; border:2px solid #000; padding:10px; text-align:center; opacity: 1; z-index: 1500'>" +
"<button id='cadesplugin_close_install' style='float: right; font-size: 10px; background: transparent; border: 1; margin: -5px'>X</button>" +
"<p>Для работы КриптоПро ЭЦП Browser plugin на данном сайте необходимо установить расширение из каталога дополнений Opera." +
"<p><button id='cadesplugin_install' style='font:12px Arial'>Установить расширение</button></p>" +
"</div>";
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.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("Плагин недоступен");
}
}
function firefox_or_edge_nmcades_onload() {
function firefox_or_safari_nmcades_onload() {
cpcsp_chrome_nmcades.check_chrome_plugin(plugin_loaded, plugin_loaded_error);
}
@ -5163,45 +5158,56 @@ exports._parseCertInfo = function (tagsTranslations, rawInfo) {
window.addEventListener("message", function (event){
if (typeof(event.data) !== "string" || !event.data.match("cadesplugin_loaded"))
return;
if(isFireFox || isEdge || isSafari)
if (cadesplugin_loaded_event_recieved)
return;
if(isFireFox || isSafari)
{
// Для Firefox, Сафари, Edge вместе с сообщением cadesplugin_loaded прилетает url для загрузки nmcades_plugin_api.js
// Для Firefox, Сафари вместе с сообщением cadesplugin_loaded прилетает url для загрузки nmcades_plugin_api.js
var url = event.data.substring(event.data.indexOf("url:") + 4);
if (!url.match("^moz-extension://[a-zA-Z0-9-]+/nmcades_plugin_api.js$")
&& !url.match("^safari-extension://[a-zA-Z0-9-]+/[a-zA-Z0-9]+/nmcades_plugin_api.js$"))
{
cpcsp_console_log(cadesplugin.LOG_LEVEL_ERROR, "Bad url \"" + url + "\" for load CryptoPro Extension for CAdES Browser plug-in");
plugin_loaded_error();
return;
}
var fileref = document.createElement('script');
fileref.setAttribute("type", "text/javascript");
fileref.setAttribute("src", url);
fileref.onerror = plugin_loaded_error;
fileref.onload = firefox_or_edge_nmcades_onload;
fileref.onload = firefox_or_safari_nmcades_onload;
document.getElementsByTagName("head")[0].appendChild(fileref);
// Для Firefox, Safari и Edge у нас только по одному расширению.
failed_extensions++;
}else {
cpcsp_chrome_nmcades.check_chrome_plugin(plugin_loaded, plugin_loaded_error);
}
cadesplugin_loaded_event_recieved = true;
}, false);
}
//Загружаем расширения для Chrome, Opera, YaBrowser, FireFox, Edge, Safari
function load_extension()
{
if(isFireFox || isEdge || isSafari){
if(isFireFox || isSafari){
// вызываем callback руками т.к. нам нужно узнать ID расширения. Он уникальный для браузера.
nmcades_api_onload();
} else {
// в асинхронном варианте для chrome и opera подключаем оба расширения
// в асинхронном варианте для Yandex и Opera подключаем расширение из Opera store.
if (isOpera || isYandex) {
var 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);
} else {
// для Chrome, Chromium, Chromium Edge расширение из Chrome store
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);
}
}
}
@ -5244,18 +5250,6 @@ exports._parseCertInfo = function (tagsTranslations, rawInfo) {
//Отправляем событие что сломались.
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 = "Плагин недоступен";
plugin_resolved = 1;
@ -5366,7 +5360,7 @@ exports._parseCertInfo = function (tagsTranslations, rawInfo) {
};
//Export
cadesplugin.JSModuleVersion = "2.1.2";
cadesplugin.JSModuleVersion = "2.3.1";
cadesplugin.async_spawn = async_spawn;
cadesplugin.set = set_pluginObject;
cadesplugin.set_log_level = set_log_level;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long