This commit is contained in:
Vitalii Goma 2017-01-20 11:45:41 +03:00
parent ce37ea6d7c
commit 2b3b13c268
5 changed files with 95 additions and 10 deletions

View File

@ -1,3 +1,8 @@
1.0.4 / 2017-01-20
==================
* Улучшение: Добавлены изменения из оригинального js модуля Крипто ПРО "2.0.3" [ссылка на оригинальный файл](https://www.cryptopro.ru/sites/default/files/products/cades/cadesplugin_api.js)
1.0.3 / 2017-01-20 1.0.3 / 2017-01-20
================== ==================

48
dist/crypto-pro.js vendored
View File

@ -236,6 +236,10 @@ var CryptoPro =
} }
function cpcsp_console_log(level, msg) { function cpcsp_console_log(level, msg) {
if (typeof console === 'undefined') {
return;
}
if (level <= cadesplugin.current_log_level) { if (level <= cadesplugin.current_log_level) {
if (level == cadesplugin.LOG_LEVEL_DEBUG) { if (level == cadesplugin.LOG_LEVEL_DEBUG) {
console.log('DEBUG: %s', msg); console.log('DEBUG: %s', msg);
@ -294,6 +298,9 @@ var CryptoPro =
function set_constantValues() { function set_constantValues() {
cadesplugin.CAPICOM_LOCAL_MACHINE_STORE = 1; cadesplugin.CAPICOM_LOCAL_MACHINE_STORE = 1;
cadesplugin.CAPICOM_CURRENT_USER_STORE = 2; 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_STORE_OPEN_MAXIMUM_ALLOWED = 2;
cadesplugin.CAPICOM_CERTIFICATE_FIND_SUBJECT_NAME = 1; cadesplugin.CAPICOM_CERTIFICATE_FIND_SUBJECT_NAME = 1;
@ -481,6 +488,38 @@ var CryptoPro =
return pluginObject.CreateObject(name); return pluginObject.CreateObject(name);
} }
function decimalToHexString(number) {
if (number < 0) {
number = 0xFFFFFFFF + number + 1;
}
return number.toString(16).toUpperCase();
}
function GetMessageFromException(e) {
var err = e.message;
if (!err) {
err = e;
} else if (e.number) {
err += ' (0x' + decimalToHexString(e.number) + ')';
}
return err;
}
function getLastError(exception) {
if (isChromiumBased() || isIE() || isIOS()) {
return GetMessageFromException(exception);
}
try {
return pluginObject.getLastError();
} catch (e) {
return GetMessageFromException(exception);
}
}
// Функция активации асинхронных объектов КриптоПро ЭЦП Browser plug-in // Функция активации асинхронных объектов КриптоПро ЭЦП Browser plug-in
function CreateObjectAsync(name) { function CreateObjectAsync(name) {
return pluginObject.CreateObjectAsync(name); return pluginObject.CreateObjectAsync(name);
@ -662,7 +701,7 @@ var CryptoPro =
elem.setAttribute('id', 'cadesplugin_object'); elem.setAttribute('id', 'cadesplugin_object');
elem.setAttribute('type', 'application/x-cades'); elem.setAttribute('type', 'application/x-cades');
elem.setAttribute('style', 'visibility=hidden'); elem.setAttribute('style', 'visibility: hidden');
document.getElementsByTagName('body')[0].appendChild(elem); document.getElementsByTagName('body')[0].appendChild(elem);
pluginObject = document.getElementById('cadesplugin_object'); pluginObject = document.getElementById('cadesplugin_object');
@ -672,13 +711,13 @@ var CryptoPro =
elem1.setAttribute('id', 'certEnrollClassFactory'); elem1.setAttribute('id', 'certEnrollClassFactory');
elem1.setAttribute('classid', 'clsid:884e2049-217d-11da-b2a4-000e7bbb2b09'); elem1.setAttribute('classid', 'clsid:884e2049-217d-11da-b2a4-000e7bbb2b09');
elem1.setAttribute('style', 'visibility=hidden'); elem1.setAttribute('style', 'visibility: hidden');
document.getElementsByTagName('body')[0].appendChild(elem1); document.getElementsByTagName('body')[0].appendChild(elem1);
var elem2 = document.createElement('object'); var elem2 = document.createElement('object');
elem2.setAttribute('id', 'webClassFactory'); elem2.setAttribute('id', 'webClassFactory');
elem2.setAttribute('classid', 'clsid:B04C8637-10BD-484E-B0DA-B8A039F60024'); elem2.setAttribute('classid', 'clsid:B04C8637-10BD-484E-B0DA-B8A039F60024');
elem2.setAttribute('style', 'visibility=hidden'); elem2.setAttribute('style', 'visibility: hidden');
document.getElementsByTagName('body')[0].appendChild(elem2); document.getElementsByTagName('body')[0].appendChild(elem2);
} }
@ -785,10 +824,11 @@ var CryptoPro =
} }
// Export // Export
cadesplugin.JSModuleVersion = '2.0.2'; cadesplugin.JSModuleVersion = '2.0.3';
cadesplugin.async_spawn = async_spawn; cadesplugin.async_spawn = async_spawn;
cadesplugin.set = set_pluginObject; cadesplugin.set = set_pluginObject;
cadesplugin.set_log_level = set_log_level; cadesplugin.set_log_level = set_log_level;
cadesplugin.getLastError = getLastError;
if (isChromiumBased()) { if (isChromiumBased()) {
cadesplugin.CreateObjectAsync = CreateObjectAsync; cadesplugin.CreateObjectAsync = CreateObjectAsync;

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{ {
"name": "crypto-pro", "name": "crypto-pro",
"version": "1.0.3", "version": "1.0.4",
"description": "API для взаимодействия с КриптоПро", "description": "API для взаимодействия с КриптоПро",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {

View File

@ -32,6 +32,10 @@
} }
function cpcsp_console_log(level, msg) { function cpcsp_console_log(level, msg) {
if (typeof console === 'undefined') {
return;
}
if (level <= cadesplugin.current_log_level) { if (level <= cadesplugin.current_log_level) {
if (level == cadesplugin.LOG_LEVEL_DEBUG) { if (level == cadesplugin.LOG_LEVEL_DEBUG) {
console.log('DEBUG: %s', msg); console.log('DEBUG: %s', msg);
@ -90,6 +94,9 @@
function set_constantValues() { function set_constantValues() {
cadesplugin.CAPICOM_LOCAL_MACHINE_STORE = 1; cadesplugin.CAPICOM_LOCAL_MACHINE_STORE = 1;
cadesplugin.CAPICOM_CURRENT_USER_STORE = 2; 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_STORE_OPEN_MAXIMUM_ALLOWED = 2;
cadesplugin.CAPICOM_CERTIFICATE_FIND_SUBJECT_NAME = 1; cadesplugin.CAPICOM_CERTIFICATE_FIND_SUBJECT_NAME = 1;
@ -277,6 +284,38 @@
return pluginObject.CreateObject(name); return pluginObject.CreateObject(name);
} }
function decimalToHexString(number) {
if (number < 0) {
number = 0xFFFFFFFF + number + 1;
}
return number.toString(16).toUpperCase();
}
function GetMessageFromException(e) {
var err = e.message;
if (!err) {
err = e;
} else if (e.number) {
err += ' (0x' + decimalToHexString(e.number) + ')';
}
return err;
}
function getLastError(exception) {
if (isChromiumBased() || isIE() || isIOS()) {
return GetMessageFromException(exception);
}
try {
return pluginObject.getLastError();
} catch (e) {
return GetMessageFromException(exception);
}
}
// Функция активации асинхронных объектов КриптоПро ЭЦП Browser plug-in // Функция активации асинхронных объектов КриптоПро ЭЦП Browser plug-in
function CreateObjectAsync(name) { function CreateObjectAsync(name) {
return pluginObject.CreateObjectAsync(name); return pluginObject.CreateObjectAsync(name);
@ -458,7 +497,7 @@
elem.setAttribute('id', 'cadesplugin_object'); elem.setAttribute('id', 'cadesplugin_object');
elem.setAttribute('type', 'application/x-cades'); elem.setAttribute('type', 'application/x-cades');
elem.setAttribute('style', 'visibility=hidden'); elem.setAttribute('style', 'visibility: hidden');
document.getElementsByTagName('body')[0].appendChild(elem); document.getElementsByTagName('body')[0].appendChild(elem);
pluginObject = document.getElementById('cadesplugin_object'); pluginObject = document.getElementById('cadesplugin_object');
@ -468,13 +507,13 @@
elem1.setAttribute('id', 'certEnrollClassFactory'); elem1.setAttribute('id', 'certEnrollClassFactory');
elem1.setAttribute('classid', 'clsid:884e2049-217d-11da-b2a4-000e7bbb2b09'); elem1.setAttribute('classid', 'clsid:884e2049-217d-11da-b2a4-000e7bbb2b09');
elem1.setAttribute('style', 'visibility=hidden'); elem1.setAttribute('style', 'visibility: hidden');
document.getElementsByTagName('body')[0].appendChild(elem1); document.getElementsByTagName('body')[0].appendChild(elem1);
var elem2 = document.createElement('object'); var elem2 = document.createElement('object');
elem2.setAttribute('id', 'webClassFactory'); elem2.setAttribute('id', 'webClassFactory');
elem2.setAttribute('classid', 'clsid:B04C8637-10BD-484E-B0DA-B8A039F60024'); elem2.setAttribute('classid', 'clsid:B04C8637-10BD-484E-B0DA-B8A039F60024');
elem2.setAttribute('style', 'visibility=hidden'); elem2.setAttribute('style', 'visibility: hidden');
document.getElementsByTagName('body')[0].appendChild(elem2); document.getElementsByTagName('body')[0].appendChild(elem2);
} }
@ -581,10 +620,11 @@
} }
// Export // Export
cadesplugin.JSModuleVersion = '2.0.2'; cadesplugin.JSModuleVersion = '2.0.3';
cadesplugin.async_spawn = async_spawn; cadesplugin.async_spawn = async_spawn;
cadesplugin.set = set_pluginObject; cadesplugin.set = set_pluginObject;
cadesplugin.set_log_level = set_log_level; cadesplugin.set_log_level = set_log_level;
cadesplugin.getLastError = getLastError;
if (isChromiumBased()) { if (isChromiumBased()) {
cadesplugin.CreateObjectAsync = CreateObjectAsync; cadesplugin.CreateObjectAsync = CreateObjectAsync;