попытка объединить асинхронную и синхронную кодовую базу

This commit is contained in:
vgoma 2017-11-29 00:14:10 +03:00
parent af437dcd23
commit bdb36572f1
10 changed files with 1466 additions and 194 deletions

28
dist/1.crypto-pro.js vendored
View File

@ -177,11 +177,11 @@ webpackJsonpCryptoPro([1],[
* */ * */
function isValidEDSSettings() { function isValidEDSSettings() {
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
cadesplugin.async_spawn(function* () { cryptoCommon.execute(function () {
var result; var result;
try { try {
result = yield cadesplugin.CreateObjectAsync('CAdESCOM.About'); result = cryptoCommon.createObj('CAdESCOM.About');
} catch (error) { } catch (error) {
reject('Настройки ЭП на данной машине не верны'); reject('Настройки ЭП на данной машине не верны');
} }
@ -603,6 +603,28 @@ webpackJsonpCryptoPro([1],[
{possibleNames: ['L'], translation: 'Город'} {possibleNames: ['L'], translation: 'Город'}
]; ];
function execute(cb) {
if (cadesplugin.CreateObjectAsync) {
var GeneratorFunction = (new Function('', 'return Object.getPrototypeOf(function*(){}).constructor'))();
cb = String(cb);
var args = cb.match(/^function\s*?\((.*?)\)/);
args = (args && args[1]) || '';
cb = cb.replace(/^.*?{([\s\S]*?)}$/, '$1');
cadesplugin.async_spawn(new GeneratorFunction(args, cb));
}
}
function createObj(type) {
if (cadesplugin.CreateObjectAsync) {
return (new Function('', 'return yield cadesplugin.CreateObjectAsync(' + type + ')'))();
}
}
/** /**
* Парсит информацию из строки с информацией о сертификате * Парсит информацию из строки с информацией о сертификате
* */ * */
@ -830,6 +852,8 @@ webpackJsonpCryptoPro([1],[
} }
module.exports = { module.exports = {
execute: execute,
createObj: createObj,
subjectNameTagsTranslations: subjectNameTagsTranslations, subjectNameTagsTranslations: subjectNameTagsTranslations,
issuerNameTagsTranslations: issuerNameTagsTranslations, issuerNameTagsTranslations: issuerNameTagsTranslations,
parseCertInfo: parseCertInfo, parseCertInfo: parseCertInfo,

File diff suppressed because one or more lines are too long

24
dist/2.crypto-pro.js vendored
View File

@ -46,6 +46,28 @@ webpackJsonpCryptoPro([2],[
{possibleNames: ['L'], translation: 'Город'} {possibleNames: ['L'], translation: 'Город'}
]; ];
function execute(cb) {
if (cadesplugin.CreateObjectAsync) {
var GeneratorFunction = (new Function('', 'return Object.getPrototypeOf(function*(){}).constructor'))();
cb = String(cb);
var args = cb.match(/^function\s*?\((.*?)\)/);
args = (args && args[1]) || '';
cb = cb.replace(/^.*?{([\s\S]*?)}$/, '$1');
cadesplugin.async_spawn(new GeneratorFunction(args, cb));
}
}
function createObj(type) {
if (cadesplugin.CreateObjectAsync) {
return (new Function('', 'return yield cadesplugin.CreateObjectAsync(' + type + ')'))();
}
}
/** /**
* Парсит информацию из строки с информацией о сертификате * Парсит информацию из строки с информацией о сертификате
* */ * */
@ -273,6 +295,8 @@ webpackJsonpCryptoPro([2],[
} }
module.exports = { module.exports = {
execute: execute,
createObj: createObj,
subjectNameTagsTranslations: subjectNameTagsTranslations, subjectNameTagsTranslations: subjectNameTagsTranslations,
issuerNameTagsTranslations: issuerNameTagsTranslations, issuerNameTagsTranslations: issuerNameTagsTranslations,
parseCertInfo: parseCertInfo, parseCertInfo: parseCertInfo,

File diff suppressed because one or more lines are too long

2
dist/crypto-pro.js vendored
View File

@ -178,7 +178,7 @@ var CryptoPro =
cadesplugin.then( cadesplugin.then(
function () { function () {
if (canAsync) { if (canAsync) {
__webpack_require__.e/* nsure */(1, function () { __webpack_require__.e/* nsure */(1/* empty */, function () {
cryptoService = __webpack_require__(4); cryptoService = __webpack_require__(4);
finishLoading(); finishLoading();
}); });

File diff suppressed because one or more lines are too long

View File

@ -3,6 +3,8 @@
var $certs = document.querySelector('#certList'); var $certs = document.querySelector('#certList');
window.CryptoPro.call('isValidEDSSettings');
/** /**
* Пример получения списка сертификатов * Пример получения списка сертификатов
* */ * */

1570
npm-shrinkwrap.json generated

File diff suppressed because it is too large Load Diff

View File

@ -169,11 +169,11 @@ Certificate.prototype.hasExtendedKeyUsage = cryptoCommon.hasExtendedKeyUsage;
* */ * */
function isValidEDSSettings() { function isValidEDSSettings() {
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
cadesplugin.async_spawn(function* () { cryptoCommon.execute(function () {
var result; var result;
try { try {
result = yield cadesplugin.CreateObjectAsync('CAdESCOM.About'); result = cryptoCommon.createObj('CAdESCOM.About');
} catch (error) { } catch (error) {
reject('Настройки ЭП на данной машине не верны'); reject('Настройки ЭП на данной машине не верны');
} }

View File

@ -37,6 +37,28 @@ var subjectNameTagsTranslations = [
{possibleNames: ['L'], translation: 'Город'} {possibleNames: ['L'], translation: 'Город'}
]; ];
function execute(cb) {
if (cadesplugin.CreateObjectAsync) {
var GeneratorFunction = (new Function('', 'return Object.getPrototypeOf(function*(){}).constructor'))();
cb = String(cb);
var args = cb.match(/^function\s*?\((.*?)\)/);
args = (args && args[1]) || '';
cb = cb.replace(/^.*?{([\s\S]*?)}$/, '$1');
cadesplugin.async_spawn(new GeneratorFunction(args, cb));
}
}
function createObj(type) {
if (cadesplugin.CreateObjectAsync) {
return (new Function('', 'return yield cadesplugin.CreateObjectAsync(' + type + ')'))();
}
}
/** /**
* Парсит информацию из строки с информацией о сертификате * Парсит информацию из строки с информацией о сертификате
* */ * */
@ -264,6 +286,8 @@ function isValidCadesVersion(version) {
} }
module.exports = { module.exports = {
execute: execute,
createObj: createObj,
subjectNameTagsTranslations: subjectNameTagsTranslations, subjectNameTagsTranslations: subjectNameTagsTranslations,
issuerNameTagsTranslations: issuerNameTagsTranslations, issuerNameTagsTranslations: issuerNameTagsTranslations,
parseCertInfo: parseCertInfo, parseCertInfo: parseCertInfo,