mirror of
				https://github.com/crypto-pro-web/crypto-pro-js.git
				synced 2025-10-31 06:13:22 +03:00 
			
		
		
		
	рефакторинг
This commit is contained in:
		
							parent
							
								
									ce55951de8
								
							
						
					
					
						commit
						c3525905d2
					
				
							
								
								
									
										140
									
								
								dist/1.crypto-pro.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										140
									
								
								dist/1.crypto-pro.js
									
									
									
									
										vendored
									
									
								
							| @ -26,19 +26,19 @@ webpackJsonpCryptoPro([1],[ | ||||
| 	    var cert = this._cert; | ||||
| 	 | ||||
| 	    return new Promise(function (resolve, reject) { | ||||
| 	        cadesplugin.async_spawn(function* () { | ||||
| 	        eval(cryptoCommon.execute(function () { | ||||
| 	            var result; | ||||
| 	 | ||||
| 	            try { | ||||
| 	                result = yield cert.IsValid(); | ||||
| 	                result = yield result.Result; | ||||
| 	                result = 'yield' + cert.IsValid(); | ||||
| 	                result = 'yield' + result.Result; | ||||
| 	            } catch (err) { | ||||
| 	                reject('Ошибка при проверке сертификата: ', err.message); | ||||
| 	                return; | ||||
| 	            } | ||||
| 	 | ||||
| 	            resolve(result); | ||||
| 	        }); | ||||
| 	        })); | ||||
| 	    }); | ||||
| 	}; | ||||
| 	 | ||||
| @ -49,18 +49,18 @@ webpackJsonpCryptoPro([1],[ | ||||
| 	    var cert = this._cert; | ||||
| 	 | ||||
| 	    return new Promise(function (resolve, reject) { | ||||
| 	        cadesplugin.async_spawn(function* () { | ||||
| 	        eval(cryptoCommon.execute(function () { | ||||
| 	            var result; | ||||
| 	 | ||||
| 	            try { | ||||
| 	                result = yield cert[propName]; | ||||
| 	                result = 'yield' + cert[propName]; | ||||
| 	            } catch (err) { | ||||
| 	                reject('Ошибка при обращении к свойству сертификата: ', err.message); | ||||
| 	                return; | ||||
| 	            } | ||||
| 	 | ||||
| 	            resolve(result); | ||||
| 	        }); | ||||
| 	        })); | ||||
| 	    }); | ||||
| 	}; | ||||
| 	 | ||||
| @ -71,18 +71,18 @@ webpackJsonpCryptoPro([1],[ | ||||
| 	    var cert = this._cert; | ||||
| 	 | ||||
| 	    return new Promise(function (resolve, reject) { | ||||
| 	        cadesplugin.async_spawn(function* () { | ||||
| 	        eval(cryptoCommon.execute(function () { | ||||
| 	            var base64; | ||||
| 	 | ||||
| 	            try { | ||||
| 	                base64 = yield cert.Export(0); | ||||
| 	                base64 = 'yield' + cert.Export(0); | ||||
| 	            } catch (err) { | ||||
| 	                reject('Ошибка при экспорте сертификата: ', err.message); | ||||
| 	                return; | ||||
| 	            } | ||||
| 	 | ||||
| 	            resolve(base64); | ||||
| 	        }); | ||||
| 	        })); | ||||
| 	    }); | ||||
| 	}; | ||||
| 	 | ||||
| @ -93,23 +93,23 @@ webpackJsonpCryptoPro([1],[ | ||||
| 	    var cert = this._cert; | ||||
| 	 | ||||
| 	    return new Promise(function (resolve, reject) { | ||||
| 	        cadesplugin.async_spawn(function* () { | ||||
| 	        eval(cryptoCommon.execute(function () { | ||||
| 	            var result = {}, | ||||
| 	                algorithm; | ||||
| 	 | ||||
| 	            try { | ||||
| 	                algorithm = yield cert.PublicKey(); | ||||
| 	                algorithm = yield algorithm.Algorithm; | ||||
| 	                algorithm = 'yield' + cert.PublicKey(); | ||||
| 	                algorithm = 'yield' + algorithm.Algorithm; | ||||
| 	 | ||||
| 	                result.algorithm = yield algorithm.FriendlyName; | ||||
| 	                result.oid = yield algorithm.Value; | ||||
| 	                result.algorithm = 'yield' + algorithm.FriendlyName; | ||||
| 	                result.oid = 'yield' + algorithm.Value; | ||||
| 	            } catch (err) { | ||||
| 	                reject('Ошибка при получении алгоритма: ', err.message); | ||||
| 	                return; | ||||
| 	            } | ||||
| 	 | ||||
| 	            resolve(result); | ||||
| 	        }); | ||||
| 	        })); | ||||
| 	    }); | ||||
| 	}; | ||||
| 	 | ||||
| @ -136,22 +136,22 @@ webpackJsonpCryptoPro([1],[ | ||||
| 	    var cert = this._cert; | ||||
| 	 | ||||
| 	    return new Promise(function (resolve, reject) { | ||||
| 	        cadesplugin.async_spawn(function* () { | ||||
| 	        eval(cryptoCommon.execute(function () { | ||||
| 	            var OIDS = [], | ||||
| 	                count, | ||||
| 	                item; | ||||
| 	 | ||||
| 	            try { | ||||
| 	                count = yield cert.ExtendedKeyUsage(); | ||||
| 	                count = yield count.EKUs; | ||||
| 	                count = yield count.Count; | ||||
| 	                count = 'yield' + cert.ExtendedKeyUsage(); | ||||
| 	                count = 'yield' + count.EKUs; | ||||
| 	                count = 'yield' + count.Count; | ||||
| 	 | ||||
| 	                if (count > 0) { | ||||
| 	                    while (count > 0) { | ||||
| 	                        item = yield cert.ExtendedKeyUsage(); | ||||
| 	                        item = yield item.EKUs; | ||||
| 	                        item = yield item.Item(count); | ||||
| 	                        item = yield item.OID; | ||||
| 	                        item = 'yield' + cert.ExtendedKeyUsage(); | ||||
| 	                        item = 'yield' + item.EKUs; | ||||
| 	                        item = 'yield' + item.Item(count); | ||||
| 	                        item = 'yield' + item.OID; | ||||
| 	 | ||||
| 	                        OIDS.push(item); | ||||
| 	 | ||||
| @ -164,7 +164,7 @@ webpackJsonpCryptoPro([1],[ | ||||
| 	            } | ||||
| 	 | ||||
| 	            resolve(OIDS); | ||||
| 	        }); | ||||
| 	        })); | ||||
| 	    }); | ||||
| 	}; | ||||
| 	 | ||||
| @ -181,7 +181,7 @@ webpackJsonpCryptoPro([1],[ | ||||
| 	            var result; | ||||
| 	 | ||||
| 	            try { | ||||
| 	                result = cryptoCommon.createObj('CAdESCOM.About'); | ||||
| 	                result = 'yield' + cryptoCommon.createObj('CAdESCOM.About'); | ||||
| 	            } catch (error) { | ||||
| 	                reject('Настройки ЭП на данной машине не верны'); | ||||
| 	            } | ||||
| @ -196,8 +196,8 @@ webpackJsonpCryptoPro([1],[ | ||||
| 	 * */ | ||||
| 	function getCadesCert(hash) { | ||||
| 	    return new Promise(function (resolve, reject) { | ||||
| 	        cadesplugin.async_spawn(function* () { | ||||
| 	            var oStore = yield cadesplugin.CreateObjectAsync('CAdESCOM.Store'), | ||||
| 	        eval(cryptoCommon.execute(function () { | ||||
| 	            var oStore = 'yield' + cryptoCommon.createObj('CAdESCOM.Store'), | ||||
| 	                certs, | ||||
| 	                certCnt, | ||||
| 	                cert; | ||||
| @ -209,7 +209,7 @@ webpackJsonpCryptoPro([1],[ | ||||
| 	 | ||||
| 	            // Открываем хранилище
 | ||||
| 	            try { | ||||
| 	                yield oStore.Open( | ||||
| 	                'yield' + oStore.Open( | ||||
| 	                    cadesplugin.CAPICOM_CURRENT_USER_STORE, | ||||
| 	                    cadesplugin.CAPICOM_MY_STORE, | ||||
| 	                    cadesplugin.CAPICOM_STORE_OPEN_MAXIMUM_ALLOWED | ||||
| @ -221,8 +221,8 @@ webpackJsonpCryptoPro([1],[ | ||||
| 	 | ||||
| 	            // Получаем доступ к сертификатам
 | ||||
| 	            try { | ||||
| 	                certs = yield oStore.Certificates; | ||||
| 	                certCnt = yield certs.Count; | ||||
| 	                certs = 'yield' + oStore.Certificates; | ||||
| 	                certCnt = 'yield' + certs.Count; | ||||
| 	            } catch (err) { | ||||
| 	                reject('Ошибка получения списка сертификатов: ' + err.message); | ||||
| 	                return; | ||||
| @ -235,10 +235,10 @@ webpackJsonpCryptoPro([1],[ | ||||
| 	 | ||||
| 	            // Получаем сертификат по хэшу
 | ||||
| 	            try { | ||||
| 	                certs = yield certs.Find(cadesplugin.CAPICOM_CERTIFICATE_FIND_SHA1_HASH, hash); | ||||
| 	                certs = 'yield' + certs.Find(cadesplugin.CAPICOM_CERTIFICATE_FIND_SHA1_HASH, hash); | ||||
| 	 | ||||
| 	                if (certs.Count) { | ||||
| 	                    cert = yield certs.Item(1); | ||||
| 	                    cert = 'yield' + certs.Item(1); | ||||
| 	                } else { | ||||
| 	                    throw new Error(hash); | ||||
| 	                } | ||||
| @ -250,7 +250,7 @@ webpackJsonpCryptoPro([1],[ | ||||
| 	            oStore.Close(); | ||||
| 	 | ||||
| 	            resolve(cert); | ||||
| 	        }); | ||||
| 	        })); | ||||
| 	    }); | ||||
| 	} | ||||
| 	 | ||||
| @ -261,18 +261,18 @@ webpackJsonpCryptoPro([1],[ | ||||
| 	    var cert = this._cert; | ||||
| 	 | ||||
| 	    return new Promise(function (resolve, reject) { | ||||
| 	        cadesplugin.async_spawn(function* () { | ||||
| 	        eval(cryptoCommon.execute(function () { | ||||
| 	            var propInfo; | ||||
| 	 | ||||
| 	            try { | ||||
| 	                propInfo = yield cert[propName]; | ||||
| 	                propInfo = 'yield' + cert[propName]; | ||||
| 	            } catch (err) { | ||||
| 	                reject('Ошибка при извлечении данных из сертификата: ', err.message); | ||||
| 	                return; | ||||
| 	            } | ||||
| 	 | ||||
| 	            resolve(cryptoCommon.parseCertInfo(tags, propInfo)); | ||||
| 	        }); | ||||
| 	        })); | ||||
| 	    }); | ||||
| 	} | ||||
| 	 | ||||
| @ -406,19 +406,19 @@ webpackJsonpCryptoPro([1],[ | ||||
| 	 | ||||
| 	    return new Promise(function (resolve, reject) { | ||||
| 	        getCadesCert(hash).then(function (cert) { | ||||
| 	            cadesplugin.async_spawn(function* () { | ||||
| 	            eval(cryptoCommon.execute(function () { | ||||
| 	                var clientTime = new Date(), | ||||
| 	                    oAttrs = yield cadesplugin.CreateObjectAsync('CADESCOM.CPAttribute'), | ||||
| 	                    oSignedData = yield cadesplugin.CreateObjectAsync('CAdESCOM.CadesSignedData'), | ||||
| 	                    oSigner = yield cadesplugin.CreateObjectAsync('CAdESCOM.CPSigner'), | ||||
| 	                    oAttrs = 'yield' + cryptoCommon.createObj('CADESCOM.CPAttribute'), | ||||
| 	                    oSignedData = 'yield' + cryptoCommon.createObj('CAdESCOM.CadesSignedData'), | ||||
| 	                    oSigner = 'yield' + cryptoCommon.createObj('CAdESCOM.CPSigner'), | ||||
| 	                    attrs, | ||||
| 	                    signature; | ||||
| 	 | ||||
| 	                clientTime = cryptoCommon.getDateObj(clientTime); | ||||
| 	 | ||||
| 	                try { | ||||
| 	                    yield oAttrs.propset_Name(cryptoConstants.Time.AUTHENTICATED_ATTRIBUTE_SIGNING_TIME); | ||||
| 	                    yield oAttrs.propset_Value(clientTime); | ||||
| 	                    'yield' + oAttrs.propset_Name(cryptoConstants.Time.AUTHENTICATED_ATTRIBUTE_SIGNING_TIME); | ||||
| 	                    'yield' + oAttrs.propset_Value(clientTime); | ||||
| 	                } catch (err) { | ||||
| 	                    reject('Ошибка при установке данных подписи: ' + err.message); | ||||
| 	                    return; | ||||
| @ -426,19 +426,19 @@ webpackJsonpCryptoPro([1],[ | ||||
| 	 | ||||
| 	                // Задаем настройки для подписи
 | ||||
| 	                try { | ||||
| 	                    yield oSigner.propset_Certificate(cert); | ||||
| 	                    attrs = yield oSigner.AuthenticatedAttributes2; | ||||
| 	                    yield attrs.Add(oAttrs); | ||||
| 	                    yield oSignedData.propset_ContentEncoding(cadesplugin.CADESCOM_BASE64_TO_BINARY); | ||||
| 	                    yield oSignedData.propset_Content(dataBase64); | ||||
| 	                    yield oSigner.propset_Options(cadesplugin.CAPICOM_CERTIFICATE_INCLUDE_END_ENTITY_ONLY); | ||||
| 	                    'yield' + oSigner.propset_Certificate(cert); | ||||
| 	                    attrs = 'yield' + oSigner.AuthenticatedAttributes2; | ||||
| 	                    'yield' + attrs.Add(oAttrs); | ||||
| 	                    'yield' + oSignedData.propset_ContentEncoding(cadesplugin.CADESCOM_BASE64_TO_BINARY); | ||||
| 	                    'yield' + oSignedData.propset_Content(dataBase64); | ||||
| 	                    'yield' + oSigner.propset_Options(cadesplugin.CAPICOM_CERTIFICATE_INCLUDE_END_ENTITY_ONLY); | ||||
| 	                } catch (err) { | ||||
| 	                    reject('Не удалось установить настройки для подписи: ' + err.message); | ||||
| 	                    return; | ||||
| 	                } | ||||
| 	 | ||||
| 	                try { | ||||
| 	                    signature = yield oSignedData.SignCades( | ||||
| 	                    signature = 'yield' + oSignedData.SignCades( | ||||
| 	                        oSigner, | ||||
| 	                        cadesplugin.CADESCOM_CADES_BES, | ||||
| 	                        signType | ||||
| @ -449,7 +449,7 @@ webpackJsonpCryptoPro([1],[ | ||||
| 	                } | ||||
| 	 | ||||
| 	                resolve(signature); | ||||
| 	            }); | ||||
| 	            })); | ||||
| 	        }, reject); | ||||
| 	    }); | ||||
| 	} | ||||
| @ -464,37 +464,37 @@ webpackJsonpCryptoPro([1],[ | ||||
| 	function signDataXML(hash, dataXML) { | ||||
| 	    return new Promise(function (resolve, reject) { | ||||
| 	        getCadesCert(hash).then(function (cert) { | ||||
| 	            cadesplugin.async_spawn(function* () { | ||||
| 	                var oSigner = yield cadesplugin.CreateObjectAsync('CAdESCOM.CPSigner'), | ||||
| 	                    signerXML = yield cadesplugin.CreateObjectAsync('CAdESCOM.SignedXML'), | ||||
| 	            eval(cryptoCommon.execute(function () { | ||||
| 	                var oSigner = 'yield' + cryptoCommon.createObj('CAdESCOM.CPSigner'), | ||||
| 	                    signerXML = 'yield' + cryptoCommon.createObj('CAdESCOM.SignedXML'), | ||||
| 	                    cnts = cryptoConstants, | ||||
| 	                    signature; | ||||
| 	 | ||||
| 	                // Задаем настройки для подписи
 | ||||
| 	                try { | ||||
| 	                    yield oSigner.propset_Certificate(cert); | ||||
| 	                    'yield' + oSigner.propset_Certificate(cert); | ||||
| 	                    // Добавляем данные для подписи
 | ||||
| 	                    yield signerXML.propset_Content(dataXML); | ||||
| 	                    'yield' + signerXML.propset_Content(dataXML); | ||||
| 	                    // Устанавливаем тип подписи
 | ||||
| 	                    yield signerXML.propset_SignatureType(cnts.SignatureType.CADESCOM_XML_SIGNATURE_TYPE_ENVELOPED); | ||||
| 	                    'yield' + signerXML.propset_SignatureType(cnts.SignatureType.CADESCOM_XML_SIGNATURE_TYPE_ENVELOPED); | ||||
| 	                    // Устанавливаем алгоритм подписи
 | ||||
| 	                    yield signerXML.propset_SignatureMethod(cnts.GostXmlDSigUrls.XmlDsigGost3410Url); | ||||
| 	                    'yield' + signerXML.propset_SignatureMethod(cnts.GostXmlDSigUrls.XmlDsigGost3410Url); | ||||
| 	                    // Устанавливаем алгоритм хэширования
 | ||||
| 	                    yield signerXML.propset_DigestMethod(cnts.GostXmlDSigUrls.XmlDsigGost3411Url); | ||||
| 	                    'yield' + signerXML.propset_DigestMethod(cnts.GostXmlDSigUrls.XmlDsigGost3411Url); | ||||
| 	                } catch (err) { | ||||
| 	                    reject('Не удалось установить настройки для подписи: ' + err.message); | ||||
| 	                    return; | ||||
| 	                } | ||||
| 	 | ||||
| 	                try { | ||||
| 	                    signature = yield signerXML.Sign(oSigner); | ||||
| 	                    signature = 'yield' + signerXML.Sign(oSigner); | ||||
| 	                } catch (err) { | ||||
| 	                    reject('Не удалось создать подпись: ' + err.message); | ||||
| 	                    return; | ||||
| 	                } | ||||
| 	 | ||||
| 	                resolve(signature); | ||||
| 	            }); | ||||
| 	            })); | ||||
| 	        }, reject); | ||||
| 	    }); | ||||
| 	} | ||||
| @ -506,28 +506,28 @@ webpackJsonpCryptoPro([1],[ | ||||
| 	    var sysInfo = cryptoCommon.getEnvInfo(); | ||||
| 	 | ||||
| 	    return new Promise(function (resolve, reject) { | ||||
| 	        cadesplugin.async_spawn(function* () { | ||||
| 	        eval(cryptoCommon.execute(function () { | ||||
| 	            var e; | ||||
| 	 | ||||
| 	            try { | ||||
| 	                e = yield cadesplugin.CreateObjectAsync('CAdESCOM.About'); | ||||
| 	                e = 'yield' + cryptoCommon.createObj('CAdESCOM.About'); | ||||
| 	 | ||||
| 	                sysInfo.cadesVersion = yield e.PluginVersion; | ||||
| 	                // Возможен вызов в ранних версиях в виде sysInfo.cspVersion = yield e.CSPVersion('', 75);
 | ||||
| 	                sysInfo.cspVersion = yield e.CSPVersion(); | ||||
| 	                sysInfo.cadesVersion = 'yield' + e.PluginVersion; | ||||
| 	                // Возможен вызов в ранних версиях в виде sysInfo.cspVersion = 'yield' + e.CSPVersion('', 75);
 | ||||
| 	                sysInfo.cspVersion = 'yield' + e.CSPVersion(); | ||||
| 	 | ||||
| 	                if (!sysInfo.cadesVersion) { | ||||
| 	                    sysInfo.cadesVersion = yield e.Version; | ||||
| 	                    sysInfo.cadesVersion = 'yield' + e.Version; | ||||
| 	                } | ||||
| 	 | ||||
| 	                sysInfo.cadesVersion = yield sysInfo.cadesVersion.toString(); | ||||
| 	                sysInfo.cspVersion = yield sysInfo.cspVersion.toString(); | ||||
| 	                sysInfo.cadesVersion = 'yield' + sysInfo.cadesVersion.toString(); | ||||
| 	                sysInfo.cspVersion = 'yield' + sysInfo.cspVersion.toString(); | ||||
| 	 | ||||
| 	                resolve(sysInfo); | ||||
| 	            } catch (err) { | ||||
| 	                reject('Ошибка при получении информации о системе: ', err.message); | ||||
| 	            } | ||||
| 	        }); | ||||
| 	        })); | ||||
| 	    }); | ||||
| 	} | ||||
| 	 | ||||
|  | ||||
							
								
								
									
										2
									
								
								dist/1.crypto-pro.js.map
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								dist/1.crypto-pro.js.map
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										2
									
								
								dist/crypto-pro.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								dist/crypto-pro.js
									
									
									
									
										vendored
									
									
								
							| @ -178,7 +178,7 @@ var CryptoPro = | ||||
| 	        cadesplugin.then( | ||||
| 	            function () { | ||||
| 	                if (canAsync) { | ||||
| 	                    __webpack_require__.e/* nsure */(1, function () { | ||||
| 	                    __webpack_require__.e/* nsure */(1/* empty */, function () { | ||||
| 	                        cryptoService = __webpack_require__(4); | ||||
| 	                        finishLoading(); | ||||
| 	                    }); | ||||
|  | ||||
							
								
								
									
										2
									
								
								dist/crypto-pro.js.map
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								dist/crypto-pro.js.map
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										140
									
								
								src/apiAsync.js
									
									
									
									
									
								
							
							
						
						
									
										140
									
								
								src/apiAsync.js
									
									
									
									
									
								
							| @ -18,19 +18,19 @@ Certificate.prototype.isValid = function isValid() { | ||||
|     var cert = this._cert; | ||||
| 
 | ||||
|     return new Promise(function (resolve, reject) { | ||||
|         cadesplugin.async_spawn(function* () { | ||||
|         eval(cryptoCommon.execute(function () { | ||||
|             var result; | ||||
| 
 | ||||
|             try { | ||||
|                 result = yield cert.IsValid(); | ||||
|                 result = yield result.Result; | ||||
|                 result = 'yield' + cert.IsValid(); | ||||
|                 result = 'yield' + result.Result; | ||||
|             } catch (err) { | ||||
|                 reject('Ошибка при проверке сертификата: ', err.message); | ||||
|                 return; | ||||
|             } | ||||
| 
 | ||||
|             resolve(result); | ||||
|         }); | ||||
|         })); | ||||
|     }); | ||||
| }; | ||||
| 
 | ||||
| @ -41,18 +41,18 @@ Certificate.prototype.getProp = function (propName) { | ||||
|     var cert = this._cert; | ||||
| 
 | ||||
|     return new Promise(function (resolve, reject) { | ||||
|         cadesplugin.async_spawn(function* () { | ||||
|         eval(cryptoCommon.execute(function () { | ||||
|             var result; | ||||
| 
 | ||||
|             try { | ||||
|                 result = yield cert[propName]; | ||||
|                 result = 'yield' + cert[propName]; | ||||
|             } catch (err) { | ||||
|                 reject('Ошибка при обращении к свойству сертификата: ', err.message); | ||||
|                 return; | ||||
|             } | ||||
| 
 | ||||
|             resolve(result); | ||||
|         }); | ||||
|         })); | ||||
|     }); | ||||
| }; | ||||
| 
 | ||||
| @ -63,18 +63,18 @@ Certificate.prototype.exportBase64 = function exportBase64() { | ||||
|     var cert = this._cert; | ||||
| 
 | ||||
|     return new Promise(function (resolve, reject) { | ||||
|         cadesplugin.async_spawn(function* () { | ||||
|         eval(cryptoCommon.execute(function () { | ||||
|             var base64; | ||||
| 
 | ||||
|             try { | ||||
|                 base64 = yield cert.Export(0); | ||||
|                 base64 = 'yield' + cert.Export(0); | ||||
|             } catch (err) { | ||||
|                 reject('Ошибка при экспорте сертификата: ', err.message); | ||||
|                 return; | ||||
|             } | ||||
| 
 | ||||
|             resolve(base64); | ||||
|         }); | ||||
|         })); | ||||
|     }); | ||||
| }; | ||||
| 
 | ||||
| @ -85,23 +85,23 @@ Certificate.prototype.getAlgorithm = function getAlgorithm() { | ||||
|     var cert = this._cert; | ||||
| 
 | ||||
|     return new Promise(function (resolve, reject) { | ||||
|         cadesplugin.async_spawn(function* () { | ||||
|         eval(cryptoCommon.execute(function () { | ||||
|             var result = {}, | ||||
|                 algorithm; | ||||
| 
 | ||||
|             try { | ||||
|                 algorithm = yield cert.PublicKey(); | ||||
|                 algorithm = yield algorithm.Algorithm; | ||||
|                 algorithm = 'yield' + cert.PublicKey(); | ||||
|                 algorithm = 'yield' + algorithm.Algorithm; | ||||
| 
 | ||||
|                 result.algorithm = yield algorithm.FriendlyName; | ||||
|                 result.oid = yield algorithm.Value; | ||||
|                 result.algorithm = 'yield' + algorithm.FriendlyName; | ||||
|                 result.oid = 'yield' + algorithm.Value; | ||||
|             } catch (err) { | ||||
|                 reject('Ошибка при получении алгоритма: ', err.message); | ||||
|                 return; | ||||
|             } | ||||
| 
 | ||||
|             resolve(result); | ||||
|         }); | ||||
|         })); | ||||
|     }); | ||||
| }; | ||||
| 
 | ||||
| @ -128,22 +128,22 @@ Certificate.prototype.getExtendedKeyUsage = function getExtendedKeyUsage() { | ||||
|     var cert = this._cert; | ||||
| 
 | ||||
|     return new Promise(function (resolve, reject) { | ||||
|         cadesplugin.async_spawn(function* () { | ||||
|         eval(cryptoCommon.execute(function () { | ||||
|             var OIDS = [], | ||||
|                 count, | ||||
|                 item; | ||||
| 
 | ||||
|             try { | ||||
|                 count = yield cert.ExtendedKeyUsage(); | ||||
|                 count = yield count.EKUs; | ||||
|                 count = yield count.Count; | ||||
|                 count = 'yield' + cert.ExtendedKeyUsage(); | ||||
|                 count = 'yield' + count.EKUs; | ||||
|                 count = 'yield' + count.Count; | ||||
| 
 | ||||
|                 if (count > 0) { | ||||
|                     while (count > 0) { | ||||
|                         item = yield cert.ExtendedKeyUsage(); | ||||
|                         item = yield item.EKUs; | ||||
|                         item = yield item.Item(count); | ||||
|                         item = yield item.OID; | ||||
|                         item = 'yield' + cert.ExtendedKeyUsage(); | ||||
|                         item = 'yield' + item.EKUs; | ||||
|                         item = 'yield' + item.Item(count); | ||||
|                         item = 'yield' + item.OID; | ||||
| 
 | ||||
|                         OIDS.push(item); | ||||
| 
 | ||||
| @ -156,7 +156,7 @@ Certificate.prototype.getExtendedKeyUsage = function getExtendedKeyUsage() { | ||||
|             } | ||||
| 
 | ||||
|             resolve(OIDS); | ||||
|         }); | ||||
|         })); | ||||
|     }); | ||||
| }; | ||||
| 
 | ||||
| @ -173,7 +173,7 @@ function isValidEDSSettings() { | ||||
|             var result; | ||||
| 
 | ||||
|             try { | ||||
|                 result = cryptoCommon.createObj('CAdESCOM.About'); | ||||
|                 result = 'yield' + cryptoCommon.createObj('CAdESCOM.About'); | ||||
|             } catch (error) { | ||||
|                 reject('Настройки ЭП на данной машине не верны'); | ||||
|             } | ||||
| @ -188,8 +188,8 @@ function isValidEDSSettings() { | ||||
|  * */ | ||||
| function getCadesCert(hash) { | ||||
|     return new Promise(function (resolve, reject) { | ||||
|         cadesplugin.async_spawn(function* () { | ||||
|             var oStore = yield cadesplugin.CreateObjectAsync('CAdESCOM.Store'), | ||||
|         eval(cryptoCommon.execute(function () { | ||||
|             var oStore = 'yield' + cryptoCommon.createObj('CAdESCOM.Store'), | ||||
|                 certs, | ||||
|                 certCnt, | ||||
|                 cert; | ||||
| @ -201,7 +201,7 @@ function getCadesCert(hash) { | ||||
| 
 | ||||
|             // Открываем хранилище
 | ||||
|             try { | ||||
|                 yield oStore.Open( | ||||
|                 'yield' + oStore.Open( | ||||
|                     cadesplugin.CAPICOM_CURRENT_USER_STORE, | ||||
|                     cadesplugin.CAPICOM_MY_STORE, | ||||
|                     cadesplugin.CAPICOM_STORE_OPEN_MAXIMUM_ALLOWED | ||||
| @ -213,8 +213,8 @@ function getCadesCert(hash) { | ||||
| 
 | ||||
|             // Получаем доступ к сертификатам
 | ||||
|             try { | ||||
|                 certs = yield oStore.Certificates; | ||||
|                 certCnt = yield certs.Count; | ||||
|                 certs = 'yield' + oStore.Certificates; | ||||
|                 certCnt = 'yield' + certs.Count; | ||||
|             } catch (err) { | ||||
|                 reject('Ошибка получения списка сертификатов: ' + err.message); | ||||
|                 return; | ||||
| @ -227,10 +227,10 @@ function getCadesCert(hash) { | ||||
| 
 | ||||
|             // Получаем сертификат по хэшу
 | ||||
|             try { | ||||
|                 certs = yield certs.Find(cadesplugin.CAPICOM_CERTIFICATE_FIND_SHA1_HASH, hash); | ||||
|                 certs = 'yield' + certs.Find(cadesplugin.CAPICOM_CERTIFICATE_FIND_SHA1_HASH, hash); | ||||
| 
 | ||||
|                 if (certs.Count) { | ||||
|                     cert = yield certs.Item(1); | ||||
|                     cert = 'yield' + certs.Item(1); | ||||
|                 } else { | ||||
|                     throw new Error(hash); | ||||
|                 } | ||||
| @ -242,7 +242,7 @@ function getCadesCert(hash) { | ||||
|             oStore.Close(); | ||||
| 
 | ||||
|             resolve(cert); | ||||
|         }); | ||||
|         })); | ||||
|     }); | ||||
| } | ||||
| 
 | ||||
| @ -253,18 +253,18 @@ function getCertInfo(tags, propName) { | ||||
|     var cert = this._cert; | ||||
| 
 | ||||
|     return new Promise(function (resolve, reject) { | ||||
|         cadesplugin.async_spawn(function* () { | ||||
|         eval(cryptoCommon.execute(function () { | ||||
|             var propInfo; | ||||
| 
 | ||||
|             try { | ||||
|                 propInfo = yield cert[propName]; | ||||
|                 propInfo = 'yield' + cert[propName]; | ||||
|             } catch (err) { | ||||
|                 reject('Ошибка при извлечении данных из сертификата: ', err.message); | ||||
|                 return; | ||||
|             } | ||||
| 
 | ||||
|             resolve(cryptoCommon.parseCertInfo(tags, propInfo)); | ||||
|         }); | ||||
|         })); | ||||
|     }); | ||||
| } | ||||
| 
 | ||||
| @ -398,19 +398,19 @@ function signData(hash, dataBase64, signType) { | ||||
| 
 | ||||
|     return new Promise(function (resolve, reject) { | ||||
|         getCadesCert(hash).then(function (cert) { | ||||
|             cadesplugin.async_spawn(function* () { | ||||
|             eval(cryptoCommon.execute(function () { | ||||
|                 var clientTime = new Date(), | ||||
|                     oAttrs = yield cadesplugin.CreateObjectAsync('CADESCOM.CPAttribute'), | ||||
|                     oSignedData = yield cadesplugin.CreateObjectAsync('CAdESCOM.CadesSignedData'), | ||||
|                     oSigner = yield cadesplugin.CreateObjectAsync('CAdESCOM.CPSigner'), | ||||
|                     oAttrs = 'yield' + cryptoCommon.createObj('CADESCOM.CPAttribute'), | ||||
|                     oSignedData = 'yield' + cryptoCommon.createObj('CAdESCOM.CadesSignedData'), | ||||
|                     oSigner = 'yield' + cryptoCommon.createObj('CAdESCOM.CPSigner'), | ||||
|                     attrs, | ||||
|                     signature; | ||||
| 
 | ||||
|                 clientTime = cryptoCommon.getDateObj(clientTime); | ||||
| 
 | ||||
|                 try { | ||||
|                     yield oAttrs.propset_Name(cryptoConstants.Time.AUTHENTICATED_ATTRIBUTE_SIGNING_TIME); | ||||
|                     yield oAttrs.propset_Value(clientTime); | ||||
|                     'yield' + oAttrs.propset_Name(cryptoConstants.Time.AUTHENTICATED_ATTRIBUTE_SIGNING_TIME); | ||||
|                     'yield' + oAttrs.propset_Value(clientTime); | ||||
|                 } catch (err) { | ||||
|                     reject('Ошибка при установке данных подписи: ' + err.message); | ||||
|                     return; | ||||
| @ -418,19 +418,19 @@ function signData(hash, dataBase64, signType) { | ||||
| 
 | ||||
|                 // Задаем настройки для подписи
 | ||||
|                 try { | ||||
|                     yield oSigner.propset_Certificate(cert); | ||||
|                     attrs = yield oSigner.AuthenticatedAttributes2; | ||||
|                     yield attrs.Add(oAttrs); | ||||
|                     yield oSignedData.propset_ContentEncoding(cadesplugin.CADESCOM_BASE64_TO_BINARY); | ||||
|                     yield oSignedData.propset_Content(dataBase64); | ||||
|                     yield oSigner.propset_Options(cadesplugin.CAPICOM_CERTIFICATE_INCLUDE_END_ENTITY_ONLY); | ||||
|                     'yield' + oSigner.propset_Certificate(cert); | ||||
|                     attrs = 'yield' + oSigner.AuthenticatedAttributes2; | ||||
|                     'yield' + attrs.Add(oAttrs); | ||||
|                     'yield' + oSignedData.propset_ContentEncoding(cadesplugin.CADESCOM_BASE64_TO_BINARY); | ||||
|                     'yield' + oSignedData.propset_Content(dataBase64); | ||||
|                     'yield' + oSigner.propset_Options(cadesplugin.CAPICOM_CERTIFICATE_INCLUDE_END_ENTITY_ONLY); | ||||
|                 } catch (err) { | ||||
|                     reject('Не удалось установить настройки для подписи: ' + err.message); | ||||
|                     return; | ||||
|                 } | ||||
| 
 | ||||
|                 try { | ||||
|                     signature = yield oSignedData.SignCades( | ||||
|                     signature = 'yield' + oSignedData.SignCades( | ||||
|                         oSigner, | ||||
|                         cadesplugin.CADESCOM_CADES_BES, | ||||
|                         signType | ||||
| @ -441,7 +441,7 @@ function signData(hash, dataBase64, signType) { | ||||
|                 } | ||||
| 
 | ||||
|                 resolve(signature); | ||||
|             }); | ||||
|             })); | ||||
|         }, reject); | ||||
|     }); | ||||
| } | ||||
| @ -456,37 +456,37 @@ function signData(hash, dataBase64, signType) { | ||||
| function signDataXML(hash, dataXML) { | ||||
|     return new Promise(function (resolve, reject) { | ||||
|         getCadesCert(hash).then(function (cert) { | ||||
|             cadesplugin.async_spawn(function* () { | ||||
|                 var oSigner = yield cadesplugin.CreateObjectAsync('CAdESCOM.CPSigner'), | ||||
|                     signerXML = yield cadesplugin.CreateObjectAsync('CAdESCOM.SignedXML'), | ||||
|             eval(cryptoCommon.execute(function () { | ||||
|                 var oSigner = 'yield' + cryptoCommon.createObj('CAdESCOM.CPSigner'), | ||||
|                     signerXML = 'yield' + cryptoCommon.createObj('CAdESCOM.SignedXML'), | ||||
|                     cnts = cryptoConstants, | ||||
|                     signature; | ||||
| 
 | ||||
|                 // Задаем настройки для подписи
 | ||||
|                 try { | ||||
|                     yield oSigner.propset_Certificate(cert); | ||||
|                     'yield' + oSigner.propset_Certificate(cert); | ||||
|                     // Добавляем данные для подписи
 | ||||
|                     yield signerXML.propset_Content(dataXML); | ||||
|                     'yield' + signerXML.propset_Content(dataXML); | ||||
|                     // Устанавливаем тип подписи
 | ||||
|                     yield signerXML.propset_SignatureType(cnts.SignatureType.CADESCOM_XML_SIGNATURE_TYPE_ENVELOPED); | ||||
|                     'yield' + signerXML.propset_SignatureType(cnts.SignatureType.CADESCOM_XML_SIGNATURE_TYPE_ENVELOPED); | ||||
|                     // Устанавливаем алгоритм подписи
 | ||||
|                     yield signerXML.propset_SignatureMethod(cnts.GostXmlDSigUrls.XmlDsigGost3410Url); | ||||
|                     'yield' + signerXML.propset_SignatureMethod(cnts.GostXmlDSigUrls.XmlDsigGost3410Url); | ||||
|                     // Устанавливаем алгоритм хэширования
 | ||||
|                     yield signerXML.propset_DigestMethod(cnts.GostXmlDSigUrls.XmlDsigGost3411Url); | ||||
|                     'yield' + signerXML.propset_DigestMethod(cnts.GostXmlDSigUrls.XmlDsigGost3411Url); | ||||
|                 } catch (err) { | ||||
|                     reject('Не удалось установить настройки для подписи: ' + err.message); | ||||
|                     return; | ||||
|                 } | ||||
| 
 | ||||
|                 try { | ||||
|                     signature = yield signerXML.Sign(oSigner); | ||||
|                     signature = 'yield' + signerXML.Sign(oSigner); | ||||
|                 } catch (err) { | ||||
|                     reject('Не удалось создать подпись: ' + err.message); | ||||
|                     return; | ||||
|                 } | ||||
| 
 | ||||
|                 resolve(signature); | ||||
|             }); | ||||
|             })); | ||||
|         }, reject); | ||||
|     }); | ||||
| } | ||||
| @ -498,28 +498,28 @@ function getSystemInfo() { | ||||
|     var sysInfo = cryptoCommon.getEnvInfo(); | ||||
| 
 | ||||
|     return new Promise(function (resolve, reject) { | ||||
|         cadesplugin.async_spawn(function* () { | ||||
|         eval(cryptoCommon.execute(function () { | ||||
|             var e; | ||||
| 
 | ||||
|             try { | ||||
|                 e = yield cadesplugin.CreateObjectAsync('CAdESCOM.About'); | ||||
|                 e = 'yield' + cryptoCommon.createObj('CAdESCOM.About'); | ||||
| 
 | ||||
|                 sysInfo.cadesVersion = yield e.PluginVersion; | ||||
|                 // Возможен вызов в ранних версиях в виде sysInfo.cspVersion = yield e.CSPVersion('', 75);
 | ||||
|                 sysInfo.cspVersion = yield e.CSPVersion(); | ||||
|                 sysInfo.cadesVersion = 'yield' + e.PluginVersion; | ||||
|                 // Возможен вызов в ранних версиях в виде sysInfo.cspVersion = 'yield' + e.CSPVersion('', 75);
 | ||||
|                 sysInfo.cspVersion = 'yield' + e.CSPVersion(); | ||||
| 
 | ||||
|                 if (!sysInfo.cadesVersion) { | ||||
|                     sysInfo.cadesVersion = yield e.Version; | ||||
|                     sysInfo.cadesVersion = 'yield' + e.Version; | ||||
|                 } | ||||
| 
 | ||||
|                 sysInfo.cadesVersion = yield sysInfo.cadesVersion.toString(); | ||||
|                 sysInfo.cspVersion = yield sysInfo.cspVersion.toString(); | ||||
|                 sysInfo.cadesVersion = 'yield' + sysInfo.cadesVersion.toString(); | ||||
|                 sysInfo.cspVersion = 'yield' + sysInfo.cspVersion.toString(); | ||||
| 
 | ||||
|                 resolve(sysInfo); | ||||
|             } catch (err) { | ||||
|                 reject('Ошибка при получении информации о системе: ', err.message); | ||||
|             } | ||||
|         }); | ||||
|         })); | ||||
|     }); | ||||
| } | ||||
| 
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 vgoma
						vgoma