From 2b3b13c2681b3bb7b81626b96aefcabc2c91c4e0 Mon Sep 17 00:00:00 2001 From: Vitalii Goma Date: Fri, 20 Jan 2017 11:45:41 +0300 Subject: [PATCH] 1.0.4 --- CHANGELOG.md | 5 +++++ dist/crypto-pro.js | 48 ++++++++++++++++++++++++++++++++++++++---- dist/crypto-pro.js.map | 2 +- package.json | 2 +- src/cades.js | 48 ++++++++++++++++++++++++++++++++++++++---- 5 files changed, 95 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 237d3fd..6a3d96e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 ================== diff --git a/dist/crypto-pro.js b/dist/crypto-pro.js index 9ff6cd4..f8a7af8 100644 --- a/dist/crypto-pro.js +++ b/dist/crypto-pro.js @@ -236,6 +236,10 @@ var CryptoPro = } function cpcsp_console_log(level, msg) { + if (typeof console === 'undefined') { + return; + } + if (level <= cadesplugin.current_log_level) { if (level == cadesplugin.LOG_LEVEL_DEBUG) { console.log('DEBUG: %s', msg); @@ -294,6 +298,9 @@ var CryptoPro = 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_STORE_OPEN_MAXIMUM_ALLOWED = 2; cadesplugin.CAPICOM_CERTIFICATE_FIND_SUBJECT_NAME = 1; @@ -481,6 +488,38 @@ var CryptoPro = 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 function CreateObjectAsync(name) { return pluginObject.CreateObjectAsync(name); @@ -662,7 +701,7 @@ var CryptoPro = elem.setAttribute('id', 'cadesplugin_object'); elem.setAttribute('type', 'application/x-cades'); - elem.setAttribute('style', 'visibility=hidden'); + elem.setAttribute('style', 'visibility: hidden'); document.getElementsByTagName('body')[0].appendChild(elem); pluginObject = document.getElementById('cadesplugin_object'); @@ -672,13 +711,13 @@ var CryptoPro = elem1.setAttribute('id', 'certEnrollClassFactory'); 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); var elem2 = document.createElement('object'); elem2.setAttribute('id', 'webClassFactory'); 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); } @@ -785,10 +824,11 @@ var CryptoPro = } // Export - cadesplugin.JSModuleVersion = '2.0.2'; + cadesplugin.JSModuleVersion = '2.0.3'; cadesplugin.async_spawn = async_spawn; cadesplugin.set = set_pluginObject; cadesplugin.set_log_level = set_log_level; + cadesplugin.getLastError = getLastError; if (isChromiumBased()) { cadesplugin.CreateObjectAsync = CreateObjectAsync; diff --git a/dist/crypto-pro.js.map b/dist/crypto-pro.js.map index ba5cc6a..30e57ac 100644 --- a/dist/crypto-pro.js.map +++ b/dist/crypto-pro.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/bootstrap d50a3320355cb0b6ec07","webpack:///./index.js","webpack:///./cades.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;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;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;;;;;;ACpGA,EAAC;AACD;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;;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;;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,wCAAuC,UAAU,gBAAgB,aAAa;AAC9E;AACA;;AAEA;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;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;;AAEA;AACA;AACA;AACA;;AAEA;AACA,UAAS;AACT;;AAEA;AACA;AACA;AACA;;AAEA;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;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,MAAK;AACL;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA;;AAEA;AACA,EAAC,I","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 d50a3320355cb0b6ec07\n **/","require('./cades');\n\nvar global = Function('return this')(),\n canPromise = Boolean(global.Promise),\n cadesplugin = global.cadesplugin,\n canAsync = Boolean(cadesplugin.CreateObjectAsync),\n CryptoProConfig = global.CryptoProConfig,\n cryptoService,\n _errorMsg = '',\n _isLoaded = false,\n _onLoadCbQueue = [];\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 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 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 (isChromiumBased()) {\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.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 isChromiumBased() {\n var retVal_chrome = navigator.userAgent.match(/chrome/i),\n\n // некоторых версиях IE8 с подключенным плагином chromeframe он определяется как\n // Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; chromeframe/29.0.1547.67;\n // и может попадать в ветку Chrome\n retVal_chromeframe = navigator.userAgent.match(/chromeframe/i);\n\n isOpera = navigator.userAgent.match(/opr/i);\n isYaBrowser = navigator.userAgent.match(/YaBrowser/i);\n\n if (retVal_chrome == null) {\n // В Firefox и 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 // Функция активации асинхронных объектов КриптоПро ЭЦП 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 extension_onload() {\n window.postMessage('cadesplugin_echo_request', '*');\n\n window.addEventListener('message', function (event) {\n if (event.data != 'cadesplugin_loaded') {\n return;\n }\n\n cpcsp_chrome_nmcades.check_chrome_plugin(plugin_loaded, plugin_loaded_error);\n }, false);\n }\n\n // Загружаем расширения для Chrome, Opera, YaBrowser\n function load_extension() {\n var fileref = document.createElement('script'),\n hash = isChromiumBased() && 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 = extension_onload;\n document.getElementsByTagName('head')[0].appendChild(fileref);\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 (isChromiumBased()) {\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 (isChromiumBased()) {\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.0.2';\n cadesplugin.async_spawn = async_spawn;\n cadesplugin.set = set_pluginObject;\n cadesplugin.set_log_level = set_log_level;\n\n if (isChromiumBased()) {\n cadesplugin.CreateObjectAsync = CreateObjectAsync;\n }\n\n if (!isChromiumBased()) {\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 **/"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/bootstrap 15e9ffdf7517eed65379","webpack:///./index.js","webpack:///./cades.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;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;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;;;;;;ACpGA,EAAC;AACD;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;;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,wCAAuC,UAAU,gBAAgB,aAAa;AAC9E;AACA;;AAEA;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;;AAEA;AACA;AACA;AACA;;AAEA;AACA,UAAS;AACT;;AAEA;AACA;AACA;AACA;;AAEA;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","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 15e9ffdf7517eed65379\n **/","require('./cades');\n\nvar global = Function('return this')(),\n canPromise = Boolean(global.Promise),\n cadesplugin = global.cadesplugin,\n canAsync = Boolean(cadesplugin.CreateObjectAsync),\n CryptoProConfig = global.CryptoProConfig,\n cryptoService,\n _errorMsg = '',\n _isLoaded = false,\n _onLoadCbQueue = [];\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 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 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 (isChromiumBased()) {\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 isChromiumBased() {\n var retVal_chrome = navigator.userAgent.match(/chrome/i),\n\n // некоторых версиях IE8 с подключенным плагином chromeframe он определяется как\n // Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; chromeframe/29.0.1547.67;\n // и может попадать в ветку Chrome\n retVal_chromeframe = navigator.userAgent.match(/chromeframe/i);\n\n isOpera = navigator.userAgent.match(/opr/i);\n isYaBrowser = navigator.userAgent.match(/YaBrowser/i);\n\n if (retVal_chrome == null) {\n // В Firefox и 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 (isChromiumBased() || 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 extension_onload() {\n window.postMessage('cadesplugin_echo_request', '*');\n\n window.addEventListener('message', function (event) {\n if (event.data != 'cadesplugin_loaded') {\n return;\n }\n\n cpcsp_chrome_nmcades.check_chrome_plugin(plugin_loaded, plugin_loaded_error);\n }, false);\n }\n\n // Загружаем расширения для Chrome, Opera, YaBrowser\n function load_extension() {\n var fileref = document.createElement('script'),\n hash = isChromiumBased() && 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 = extension_onload;\n document.getElementsByTagName('head')[0].appendChild(fileref);\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 (isChromiumBased()) {\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 (isChromiumBased()) {\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.0.3';\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 (isChromiumBased()) {\n cadesplugin.CreateObjectAsync = CreateObjectAsync;\n }\n\n if (!isChromiumBased()) {\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 **/"],"sourceRoot":""} \ No newline at end of file diff --git a/package.json b/package.json index 90a70d1..e6eb83b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "crypto-pro", - "version": "1.0.3", + "version": "1.0.4", "description": "API для взаимодействия с КриптоПро", "main": "index.js", "scripts": { diff --git a/src/cades.js b/src/cades.js index e3f1db5..f4be9a3 100755 --- a/src/cades.js +++ b/src/cades.js @@ -32,6 +32,10 @@ } function cpcsp_console_log(level, msg) { + if (typeof console === 'undefined') { + return; + } + if (level <= cadesplugin.current_log_level) { if (level == cadesplugin.LOG_LEVEL_DEBUG) { console.log('DEBUG: %s', msg); @@ -90,6 +94,9 @@ 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_STORE_OPEN_MAXIMUM_ALLOWED = 2; cadesplugin.CAPICOM_CERTIFICATE_FIND_SUBJECT_NAME = 1; @@ -277,6 +284,38 @@ 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 function CreateObjectAsync(name) { return pluginObject.CreateObjectAsync(name); @@ -458,7 +497,7 @@ elem.setAttribute('id', 'cadesplugin_object'); elem.setAttribute('type', 'application/x-cades'); - elem.setAttribute('style', 'visibility=hidden'); + elem.setAttribute('style', 'visibility: hidden'); document.getElementsByTagName('body')[0].appendChild(elem); pluginObject = document.getElementById('cadesplugin_object'); @@ -468,13 +507,13 @@ elem1.setAttribute('id', 'certEnrollClassFactory'); 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); var elem2 = document.createElement('object'); elem2.setAttribute('id', 'webClassFactory'); 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); } @@ -581,10 +620,11 @@ } // Export - cadesplugin.JSModuleVersion = '2.0.2'; + cadesplugin.JSModuleVersion = '2.0.3'; cadesplugin.async_spawn = async_spawn; cadesplugin.set = set_pluginObject; cadesplugin.set_log_level = set_log_level; + cadesplugin.getLastError = getLastError; if (isChromiumBased()) { cadesplugin.CreateObjectAsync = CreateObjectAsync;