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
							
								
									484c1148ea
								
							
						
					
					
						commit
						f1353cdcaf
					
				| @ -96,6 +96,9 @@ import { getUserCertificates, Certificate } from 'crypto-pro-js'; | ||||
| <a name="api-cryptopro"></a> | ||||
| ### Методы объекта cryptoPro | ||||
| - [getUserCertificates](src/api/getUserCertificates.ts) - возвращает список [сертификатов](#api-certificate), доступных пользователю в системе | ||||
| - [getAllUserCertificates](src/api/getAllUserCertificates.ts) - возвращает список [сертификатов](#api-certificate), доступных пользователю в системе, в том числе просроченные и без закрытого ключа | ||||
| - [getContainerCertificates](src/api/getContainerCertificates.ts) - возвращает список [сертификатов](#api-certificate), из закрытых ключей и/или сертификаты не установленные всистеме* | ||||
| - [getAllContainerCertificates](src/api/getAllContainerCertificates.ts) - возвращает список [сертификатов](#api-certificate), из закрытых ключей и/или сертификаты не установленные всистеме*, в том числе просроченные и без закрытого ключа | ||||
| - [getCertificate](src/api/getCertificate.ts) - возвращает [сертификат](#api-certificate) по отпечатку | ||||
| - [createAttachedSignature](src/api/createAttachedSignature.ts) - создает совмещенную (присоединенную) подпись сообщения | ||||
| - [createDetachedSignature](src/api/createDetachedSignature.ts) - создает отсоединенную (открепленную) подпись сообщения | ||||
| @ -106,6 +109,8 @@ import { getUserCertificates, Certificate } from 'crypto-pro-js'; | ||||
| - [getSystemInfo](src/api/getSystemInfo.ts) - возвращает информацию о CSP и плагине | ||||
| - [isValidSystemSetup](src/api/isValidSystemSetup.ts) - возвращает флаг корректности настроек ЭП на машине | ||||
| 
 | ||||
| > *Методы `getContainerCertificates` и `getAllContainerCertificates` позволяют получить сертификаты из закрытых ключей, записанных на обыкновенную флэшку  | ||||
| 
 | ||||
| <a name="api-certificate"></a> | ||||
| ### Методы объекта сертификата | ||||
| [Сертификат](src/api/certificate/certificate.ts) предоставляет следущее API: | ||||
|  | ||||
							
								
								
									
										9
									
								
								dist/api/getAllContainerCertificates.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								dist/api/getAllContainerCertificates.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,9 @@ | ||||
| import { Certificate } from './certificate'; | ||||
| /** | ||||
|  * Начиная с версии плагина 2.0.13292 есть возможность получить сертификаты из закрытых ключей | ||||
|  * Возвращает все сертификаты без фильтрации по дате и наличию приватного ключа | ||||
|  * | ||||
|  * @param resetCache = false - позволяет сбросить кэш ранее полученных сертификатов | ||||
|  * @returns список сертификатов | ||||
|  */ | ||||
| export declare const getAllContainerCertificates: (resetCache?: boolean) => Promise<Certificate[]>; | ||||
							
								
								
									
										9
									
								
								dist/api/getContainerCertificates.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								dist/api/getContainerCertificates.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,9 @@ | ||||
| import { Certificate } from './certificate'; | ||||
| /** | ||||
|  * Начиная с версии плагина 2.0.13292 есть возможность получить сертификаты из закрытых ключей | ||||
|  * Возвращает список сертификатов, доступных пользователю в системе | ||||
|  * | ||||
|  * @param resetCache = false - позволяет сбросить кэш ранее полученных сертификатов | ||||
|  * @returns список сертификатов | ||||
|  */ | ||||
| export declare const getContainerCertificates: (resetCache?: boolean) => Promise<Certificate[]>; | ||||
							
								
								
									
										2
									
								
								dist/api/index.d.ts
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								dist/api/index.d.ts
									
									
									
									
										vendored
									
									
								
							| @ -1,6 +1,8 @@ | ||||
| export * from './getCertificate'; | ||||
| export * from './getUserCertificates'; | ||||
| export * from './getAllUserCertificates'; | ||||
| export * from './getContainerCertificates'; | ||||
| export * from './getAllContainerCertificates'; | ||||
| export * from './getSystemInfo'; | ||||
| export * from './isValidSystemSetup'; | ||||
| export * from './createXMLSignature'; | ||||
|  | ||||
							
								
								
									
										174
									
								
								dist/crypto-pro-js.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										174
									
								
								dist/crypto-pro-js.js
									
									
									
									
										vendored
									
									
								
							| @ -3457,6 +3457,86 @@ exports.createXMLSignature = _afterPluginsLoaded_1._afterPluginsLoaded(function | ||||
| }); }); | ||||
| 
 | ||||
| 
 | ||||
| /***/ }), | ||||
| 
 | ||||
| /***/ "./api/getAllContainerCertificates.ts": | ||||
| /*!********************************************!*\ | ||||
|   !*** ./api/getAllContainerCertificates.ts ***! | ||||
|   \********************************************/ | ||||
| /*! no static exports found */ | ||||
| /***/ (function(module, exports, __webpack_require__) { | ||||
| 
 | ||||
| "use strict"; | ||||
| 
 | ||||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||||
| var certificate_1 = __webpack_require__(/*! ./certificate */ "./api/certificate/index.ts"); | ||||
| var _afterPluginsLoaded_1 = __webpack_require__(/*! ../helpers/_afterPluginsLoaded */ "./helpers/_afterPluginsLoaded.ts"); | ||||
| var _extractCommonName_1 = __webpack_require__(/*! ../helpers/_extractCommonName */ "./helpers/_extractCommonName.ts"); | ||||
| var _extractMeaningfulErrorMessage_1 = __webpack_require__(/*! ../helpers/_extractMeaningfulErrorMessage */ "./helpers/_extractMeaningfulErrorMessage.ts"); | ||||
| var _generateCadesFn_1 = __webpack_require__(/*! ../helpers/_generateCadesFn */ "./helpers/_generateCadesFn.ts"); | ||||
| var certificatesCache; | ||||
| /** | ||||
|  * Начиная с версии плагина 2.0.13292 есть возможность получить сертификаты из закрытых ключей | ||||
|  * Возвращает все сертификаты без фильтрации по дате и наличию приватного ключа | ||||
|  * | ||||
|  * @param resetCache = false - позволяет сбросить кэш ранее полученных сертификатов | ||||
|  * @returns список сертификатов | ||||
|  */ | ||||
| exports.getAllContainerCertificates = _afterPluginsLoaded_1._afterPluginsLoaded(function (resetCache) { | ||||
|     if (resetCache === void 0) { resetCache = false; } | ||||
|     var cadesplugin = window.cadesplugin; | ||||
|     if (!resetCache && certificatesCache) { | ||||
|         return certificatesCache; | ||||
|     } | ||||
|     return eval(_generateCadesFn_1._generateCadesFn(function getAllContainerCertificates() { | ||||
|         var cadesStore; | ||||
|         try { | ||||
|             cadesStore = _generateCadesFn_1.__cadesAsyncToken__ + _generateCadesFn_1.__createCadesPluginObject__('CAdESCOM.Store'); | ||||
|         } | ||||
|         catch (error) { | ||||
|             console.error(error); | ||||
|             throw new Error(_extractMeaningfulErrorMessage_1._extractMeaningfulErrorMessage(error) || 'Ошибка при попытке доступа к хранилищу'); | ||||
|         } | ||||
|         try { | ||||
|             void (_generateCadesFn_1.__cadesAsyncToken__ + | ||||
|                 cadesStore.Open(cadesplugin.CADESCOM_CONTAINER_STORE, cadesplugin.CAPICOM_MY_STORE, cadesplugin.CAPICOM_STORE_OPEN_MAXIMUM_ALLOWED)); | ||||
|         } | ||||
|         catch (error) { | ||||
|             console.error(error); | ||||
|             throw new Error(_extractMeaningfulErrorMessage_1._extractMeaningfulErrorMessage(error) || 'Ошибка при открытии хранилища'); | ||||
|         } | ||||
|         var cadesCertificates; | ||||
|         var cadesCertificatesCount; | ||||
|         try { | ||||
|             cadesCertificates = _generateCadesFn_1.__cadesAsyncToken__ + cadesStore.Certificates; | ||||
|             cadesCertificatesCount = _generateCadesFn_1.__cadesAsyncToken__ + cadesCertificates.Count; | ||||
|         } | ||||
|         catch (error) { | ||||
|             console.error(error); | ||||
|             throw new Error(_extractMeaningfulErrorMessage_1._extractMeaningfulErrorMessage(error) || 'Ошибка получения списка сертификатов'); | ||||
|         } | ||||
|         if (!cadesCertificatesCount) { | ||||
|             throw new Error('Нет доступных сертификатов'); | ||||
|         } | ||||
|         var certificateList = []; | ||||
|         try { | ||||
|             while (cadesCertificatesCount) { | ||||
|                 var cadesCertificate = _generateCadesFn_1.__cadesAsyncToken__ + cadesCertificates.Item(cadesCertificatesCount); | ||||
|                 certificateList.push(new certificate_1.Certificate(cadesCertificate, _extractCommonName_1._extractCommonName(_generateCadesFn_1.__cadesAsyncToken__ + cadesCertificate.SubjectName), _generateCadesFn_1.__cadesAsyncToken__ + cadesCertificate.IssuerName, _generateCadesFn_1.__cadesAsyncToken__ + cadesCertificate.SubjectName, _generateCadesFn_1.__cadesAsyncToken__ + cadesCertificate.Thumbprint, _generateCadesFn_1.__cadesAsyncToken__ + cadesCertificate.ValidFromDate, _generateCadesFn_1.__cadesAsyncToken__ + cadesCertificate.ValidToDate)); | ||||
|                 cadesCertificatesCount--; | ||||
|             } | ||||
|         } | ||||
|         catch (error) { | ||||
|             console.error(error); | ||||
|             throw new Error(_extractMeaningfulErrorMessage_1._extractMeaningfulErrorMessage(error) || 'Ошибка обработки сертификатов'); | ||||
|         } | ||||
|         cadesStore.Close(); | ||||
|         certificatesCache = certificateList; | ||||
|         return certificatesCache; | ||||
|     })); | ||||
| }); | ||||
| 
 | ||||
| 
 | ||||
| /***/ }), | ||||
| 
 | ||||
| /***/ "./api/getAllUserCertificates.ts": | ||||
| @ -3613,6 +3693,98 @@ exports.getCertificate = _afterPluginsLoaded_1._afterPluginsLoaded(function (thu | ||||
| }); }); | ||||
| 
 | ||||
| 
 | ||||
| /***/ }), | ||||
| 
 | ||||
| /***/ "./api/getContainerCertificates.ts": | ||||
| /*!*****************************************!*\ | ||||
|   !*** ./api/getContainerCertificates.ts ***! | ||||
|   \*****************************************/ | ||||
| /*! no static exports found */ | ||||
| /***/ (function(module, exports, __webpack_require__) { | ||||
| 
 | ||||
| "use strict"; | ||||
| 
 | ||||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||||
| var certificate_1 = __webpack_require__(/*! ./certificate */ "./api/certificate/index.ts"); | ||||
| var constants_1 = __webpack_require__(/*! ../constants */ "./constants/index.ts"); | ||||
| var _afterPluginsLoaded_1 = __webpack_require__(/*! ../helpers/_afterPluginsLoaded */ "./helpers/_afterPluginsLoaded.ts"); | ||||
| var _extractCommonName_1 = __webpack_require__(/*! ../helpers/_extractCommonName */ "./helpers/_extractCommonName.ts"); | ||||
| var _extractMeaningfulErrorMessage_1 = __webpack_require__(/*! ../helpers/_extractMeaningfulErrorMessage */ "./helpers/_extractMeaningfulErrorMessage.ts"); | ||||
| var _generateCadesFn_1 = __webpack_require__(/*! ../helpers/_generateCadesFn */ "./helpers/_generateCadesFn.ts"); | ||||
| var certificatesCache; | ||||
| /** | ||||
|  * Начиная с версии плагина 2.0.13292 есть возможность получить сертификаты из закрытых ключей | ||||
|  * Возвращает список сертификатов, доступных пользователю в системе | ||||
|  * | ||||
|  * @param resetCache = false - позволяет сбросить кэш ранее полученных сертификатов | ||||
|  * @returns список сертификатов | ||||
|  */ | ||||
| exports.getContainerCertificates = _afterPluginsLoaded_1._afterPluginsLoaded(function (resetCache) { | ||||
|     if (resetCache === void 0) { resetCache = false; } | ||||
|     var cadesplugin = window.cadesplugin; | ||||
|     if (!resetCache && certificatesCache) { | ||||
|         return certificatesCache; | ||||
|     } | ||||
|     return eval(_generateCadesFn_1._generateCadesFn(function getContainerCertificates() { | ||||
|         var cadesStore; | ||||
|         try { | ||||
|             cadesStore = _generateCadesFn_1.__cadesAsyncToken__ + _generateCadesFn_1.__createCadesPluginObject__('CAdESCOM.Store'); | ||||
|         } | ||||
|         catch (error) { | ||||
|             console.error(error); | ||||
|             throw new Error(_extractMeaningfulErrorMessage_1._extractMeaningfulErrorMessage(error) || 'Ошибка при попытке доступа к хранилищу'); | ||||
|         } | ||||
|         try { | ||||
|             void (_generateCadesFn_1.__cadesAsyncToken__ + | ||||
|                 cadesStore.Open(cadesplugin.CADESCOM_CONTAINER_STORE, cadesplugin.CAPICOM_MY_STORE, cadesplugin.CAPICOM_STORE_OPEN_MAXIMUM_ALLOWED)); | ||||
|         } | ||||
|         catch (error) { | ||||
|             console.error(error); | ||||
|             throw new Error(_extractMeaningfulErrorMessage_1._extractMeaningfulErrorMessage(error) || 'Ошибка при открытии хранилища'); | ||||
|         } | ||||
|         var cadesCertificates; | ||||
|         var cadesCertificatesCount; | ||||
|         try { | ||||
|             cadesCertificates = _generateCadesFn_1.__cadesAsyncToken__ + cadesStore.Certificates; | ||||
|             if (cadesCertificates) { | ||||
|                 cadesCertificates = | ||||
|                     _generateCadesFn_1.__cadesAsyncToken__ + cadesCertificates.Find(cadesplugin.CAPICOM_CERTIFICATE_FIND_TIME_VALID); | ||||
|                 /** | ||||
|                  * Не рассматриваются сертификаты, в которых отсутствует закрытый ключ | ||||
|                  * или не действительны на данный момент | ||||
|                  */ | ||||
|                 cadesCertificates = | ||||
|                     _generateCadesFn_1.__cadesAsyncToken__ + | ||||
|                         cadesCertificates.Find(cadesplugin.CAPICOM_CERTIFICATE_FIND_EXTENDED_PROPERTY, constants_1.CAPICOM_PROPID_KEY_PROV_INFO); | ||||
|                 cadesCertificatesCount = _generateCadesFn_1.__cadesAsyncToken__ + cadesCertificates.Count; | ||||
|             } | ||||
|         } | ||||
|         catch (error) { | ||||
|             console.error(error); | ||||
|             throw new Error(_extractMeaningfulErrorMessage_1._extractMeaningfulErrorMessage(error) || 'Ошибка получения списка сертификатов'); | ||||
|         } | ||||
|         if (!cadesCertificatesCount) { | ||||
|             throw new Error('Нет доступных сертификатов'); | ||||
|         } | ||||
|         var certificateList = []; | ||||
|         try { | ||||
|             while (cadesCertificatesCount) { | ||||
|                 var cadesCertificate = _generateCadesFn_1.__cadesAsyncToken__ + cadesCertificates.Item(cadesCertificatesCount); | ||||
|                 certificateList.push(new certificate_1.Certificate(cadesCertificate, _extractCommonName_1._extractCommonName(_generateCadesFn_1.__cadesAsyncToken__ + cadesCertificate.SubjectName), _generateCadesFn_1.__cadesAsyncToken__ + cadesCertificate.IssuerName, _generateCadesFn_1.__cadesAsyncToken__ + cadesCertificate.SubjectName, _generateCadesFn_1.__cadesAsyncToken__ + cadesCertificate.Thumbprint, _generateCadesFn_1.__cadesAsyncToken__ + cadesCertificate.ValidFromDate, _generateCadesFn_1.__cadesAsyncToken__ + cadesCertificate.ValidToDate)); | ||||
|                 cadesCertificatesCount--; | ||||
|             } | ||||
|         } | ||||
|         catch (error) { | ||||
|             console.error(error); | ||||
|             throw new Error(_extractMeaningfulErrorMessage_1._extractMeaningfulErrorMessage(error) || 'Ошибка обработки сертификатов'); | ||||
|         } | ||||
|         cadesStore.Close(); | ||||
|         certificatesCache = certificateList; | ||||
|         return certificatesCache; | ||||
|     })); | ||||
| }); | ||||
| 
 | ||||
| 
 | ||||
| /***/ }), | ||||
| 
 | ||||
| /***/ "./api/getCspVersion.ts": | ||||
| @ -3847,6 +4019,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||||
| __export(__webpack_require__(/*! ./getCertificate */ "./api/getCertificate.ts")); | ||||
| __export(__webpack_require__(/*! ./getUserCertificates */ "./api/getUserCertificates.ts")); | ||||
| __export(__webpack_require__(/*! ./getAllUserCertificates */ "./api/getAllUserCertificates.ts")); | ||||
| __export(__webpack_require__(/*! ./getContainerCertificates */ "./api/getContainerCertificates.ts")); | ||||
| __export(__webpack_require__(/*! ./getAllContainerCertificates */ "./api/getAllContainerCertificates.ts")); | ||||
| __export(__webpack_require__(/*! ./getSystemInfo */ "./api/getSystemInfo.ts")); | ||||
| __export(__webpack_require__(/*! ./isValidSystemSetup */ "./api/isValidSystemSetup.ts")); | ||||
| __export(__webpack_require__(/*! ./createXMLSignature */ "./api/createXMLSignature.ts")); | ||||
|  | ||||
							
								
								
									
										2
									
								
								dist/crypto-pro-js.js.map
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								dist/crypto-pro-js.js.map
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										6
									
								
								dist/crypto-pro-js.min.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								dist/crypto-pro-js.min.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										2
									
								
								dist/crypto-pro-js.min.js.map
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								dist/crypto-pro-js.min.js.map
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										0
									
								
								examples/script-tag/package-lock.json
									
									
									
										generated
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
						
						
									
										0
									
								
								examples/script-tag/package-lock.json
									
									
									
										generated
									
									
									
										
										
										Normal file → Executable file
									
								
							
							
								
								
									
										8
									
								
								lib/api/addAttachedSignature.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								lib/api/addAttachedSignature.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,8 @@ | ||||
| /** | ||||
|  * Добавляет присоединенную подпись к подписанному сообщению по отпечатку сертификата | ||||
|  * | ||||
|  * @param thumbprint - отпечаток сертификата | ||||
|  * @param signedMessage - подписанное сообщение | ||||
|  * @returns подпись в формате PKCS#7 | ||||
|  */ | ||||
| export declare const addAttachedSignature: (thumbprint: string, signedMessage: string | ArrayBuffer) => Promise<string>; | ||||
							
								
								
									
										9
									
								
								lib/api/addDetachedSignature.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								lib/api/addDetachedSignature.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,9 @@ | ||||
| /** | ||||
|  * Добавляет отсоединенную подпись хеша к подписанному сообщению по отпечатку сертификата | ||||
|  * | ||||
|  * @param thumbprint - отпечаток сертификата | ||||
|  * @param signedMessage - подписанное сообщение | ||||
|  * @param messageHash - хеш подписываемого сообщения, сгенерированный по ГОСТ Р 34.11-2012 256 бит | ||||
|  * @returns подпись в формате PKCS#7 | ||||
|  */ | ||||
| export declare const addDetachedSignature: (thumbprint: string, signedMessage: string | ArrayBuffer, messageHash: string) => Promise<string>; | ||||
							
								
								
									
										22
									
								
								lib/api/certificate/certificate.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								lib/api/certificate/certificate.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,22 @@ | ||||
| import { TagTranslation } from '../../helpers/_parseCertInfo'; | ||||
| import { ExtendedKeysTranslations } from './getDecodedExtendedKeyUsage'; | ||||
| export declare type CadesCertificate = any; | ||||
| export declare class Certificate { | ||||
|     _cadesCertificate: CadesCertificate; | ||||
|     name: string; | ||||
|     issuerName: string; | ||||
|     subjectName: string; | ||||
|     thumbprint: string; | ||||
|     validFrom: string; | ||||
|     validTo: string; | ||||
|     constructor(_cadesCertificate: CadesCertificate, name: string, issuerName: string, subjectName: string, thumbprint: string, validFrom: string, validTo: string); | ||||
|     getOwnerInfo(): Promise<TagTranslation[]>; | ||||
|     getIssuerInfo(): Promise<TagTranslation[]>; | ||||
|     getExtendedKeyUsage(): Promise<string[]>; | ||||
|     getDecodedExtendedKeyUsage(): Promise<ExtendedKeysTranslations>; | ||||
|     getAlgorithm(): Promise<string>; | ||||
|     getCadesProp(propName: any): Promise<any>; | ||||
|     isValid(): Promise<boolean>; | ||||
|     exportBase64(): Promise<string>; | ||||
|     hasExtendedKeyUsage(oids: any): Promise<boolean>; | ||||
| } | ||||
							
								
								
									
										6
									
								
								lib/api/certificate/exportBase64.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								lib/api/certificate/exportBase64.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,6 @@ | ||||
| /** | ||||
|  * Экспортирует сертификат в формате base64 | ||||
|  * | ||||
|  * @returns сертификат в формате base64 | ||||
|  */ | ||||
| export declare const exportBase64: () => Promise<string>; | ||||
							
								
								
									
										11
									
								
								lib/api/certificate/getAlgorithm.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								lib/api/certificate/getAlgorithm.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,11 @@ | ||||
| interface AlgorithmInfo { | ||||
|     algorithm: string; | ||||
|     oid: string; | ||||
| } | ||||
| /** | ||||
|  * Возвращает информацию об алгоритме сертификата | ||||
|  * | ||||
|  * @returns информацию об алгоритме и его OID'е | ||||
|  */ | ||||
| export declare const getAlgorithm: () => Promise<AlgorithmInfo>; | ||||
| export {}; | ||||
							
								
								
									
										7
									
								
								lib/api/certificate/getCadesProp.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								lib/api/certificate/getCadesProp.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,7 @@ | ||||
| /** | ||||
|  * Возвращает указанное внутренее свойство у сертификата в формате Cades | ||||
|  * | ||||
|  * @param propName = наименование свойства | ||||
|  * @returns значение запрошенного свойства | ||||
|  */ | ||||
| export declare const getCadesProp: (propName: string) => Promise<any>; | ||||
							
								
								
									
										9
									
								
								lib/api/certificate/getDecodedExtendedKeyUsage.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								lib/api/certificate/getDecodedExtendedKeyUsage.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,9 @@ | ||||
| export interface ExtendedKeysTranslations { | ||||
|     [key: string]: string | null; | ||||
| } | ||||
| /** | ||||
|  * Возвращает расшифрованные ОИД'ы сертификата | ||||
|  * | ||||
|  * @returns словарь расшифрованных ОИД'ов | ||||
|  */ | ||||
| export declare const getDecodedExtendedKeyUsage: () => Promise<ExtendedKeysTranslations>; | ||||
							
								
								
									
										6
									
								
								lib/api/certificate/getExtendedKeyUsage.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								lib/api/certificate/getExtendedKeyUsage.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,6 @@ | ||||
| /** | ||||
|  * Возвращает ОИД'ы сертификата | ||||
|  * | ||||
|  * @returns список ОИД'ов | ||||
|  */ | ||||
| export declare const getExtendedKeyUsage: () => Promise<string[]>; | ||||
							
								
								
									
										10
									
								
								lib/api/certificate/getInfo.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								lib/api/certificate/getInfo.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,10 @@ | ||||
| import { TagsTranslations } from '../../constants/tags-translations'; | ||||
| import { TagTranslation } from '../../helpers/_parseCertInfo'; | ||||
| /** | ||||
|  * Возвращает расшифрованную информацию о сертификате из указанного свойства по тэгам | ||||
|  * | ||||
|  * @param tags = словарь | ||||
|  * @param entitiesPath = путь к разбираемой сущности | ||||
|  * @returns расшифрованная информация по отдельным тэгам | ||||
|  */ | ||||
| export declare const getInfo: (tags: TagsTranslations[], entitiesPath: string) => Promise<TagTranslation[]>; | ||||
							
								
								
									
										7
									
								
								lib/api/certificate/hasExtendedKeyUsage.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								lib/api/certificate/hasExtendedKeyUsage.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,7 @@ | ||||
| /** | ||||
|  * Проверяет наличие ОИД'а (ОИД'ов) у сертификата | ||||
|  * | ||||
|  * @param oids - ОИД'ы для проверки | ||||
|  * @returns флаг наличия ОИД'ов у сертификата | ||||
|  */ | ||||
| export declare const hasExtendedKeyUsage: (oids: string | string[]) => Promise<boolean>; | ||||
							
								
								
									
										1
									
								
								lib/api/certificate/index.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								lib/api/certificate/index.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1 @@ | ||||
| export * from './certificate'; | ||||
							
								
								
									
										6
									
								
								lib/api/certificate/isValid.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								lib/api/certificate/isValid.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,6 @@ | ||||
| /** | ||||
|  * Проверяет действительность сертификата | ||||
|  * | ||||
|  * @returns флаг валидности | ||||
|  */ | ||||
| export declare const isValid: () => Promise<boolean>; | ||||
							
								
								
									
										8
									
								
								lib/api/createAttachedSignature.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								lib/api/createAttachedSignature.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,8 @@ | ||||
| /** | ||||
|  * Создает присоединенную подпись сообщения по отпечатку сертификата | ||||
|  * | ||||
|  * @param thumbprint - отпечаток сертификата | ||||
|  * @param message - подписываемое сообщение | ||||
|  * @returns подпись в формате PKCS#7 | ||||
|  */ | ||||
| export declare const createAttachedSignature: (thumbprint: string, unencryptedMessage: string | ArrayBuffer) => Promise<string>; | ||||
							
								
								
									
										8
									
								
								lib/api/createDetachedSignature.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								lib/api/createDetachedSignature.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,8 @@ | ||||
| /** | ||||
|  * Создает отсоединенную подпись хеша по отпечатку сертификата | ||||
|  * | ||||
|  * @param thumbprint - отпечаток сертификата | ||||
|  * @param messageHash - хеш подписываемого сообщения, сгенерированный по ГОСТ Р 34.11-2012 256 бит | ||||
|  * @returns подпись в формате PKCS#7 | ||||
|  */ | ||||
| export declare const createDetachedSignature: (thumbprint: string, messageHash: string) => Promise<string>; | ||||
							
								
								
									
										9
									
								
								lib/api/createHash.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								lib/api/createHash.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,9 @@ | ||||
| /** | ||||
|  * Создает хеш сообщения по ГОСТ Р 34.11-2012 256 бит | ||||
|  * https://ru.wikipedia.org/wiki/%D0%A1%D1%82%D1%80%D0%B8%D0%B1%D0%BE%D0%B3_(%D1%85%D0%B5%D1%88-%D1%84%D1%83%D0%BD%D0%BA%D1%86%D0%B8%D1%8F)
 | ||||
|  * | ||||
|  * @param unencryptedMessage - сообщение для хеширования | ||||
|  * | ||||
|  * @returns хеш | ||||
|  */ | ||||
| export declare const createHash: (unencryptedMessage: string | ArrayBuffer) => Promise<string>; | ||||
							
								
								
									
										8
									
								
								lib/api/createXMLSignature.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								lib/api/createXMLSignature.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,8 @@ | ||||
| /** | ||||
|  * Создает XML подпись для документа в формате XML | ||||
|  * | ||||
|  * @param thumbprint - отпечаток сертификата | ||||
|  * @param unencryptedMessage - подписываемое сообщение в формате XML | ||||
|  * @returns подпись | ||||
|  */ | ||||
| export declare const createXMLSignature: (thumbprint: string, unencryptedMessage: string) => Promise<string>; | ||||
							
								
								
									
										9
									
								
								lib/api/getAllContainerCertificates.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								lib/api/getAllContainerCertificates.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,9 @@ | ||||
| import { Certificate } from './certificate'; | ||||
| /** | ||||
|  * Начиная с версии плагина 2.0.13292 есть возможность получить сертификаты из закрытых ключей | ||||
|  * Возвращает все сертификаты без фильтрации по дате и наличию приватного ключа | ||||
|  * | ||||
|  * @param resetCache = false - позволяет сбросить кэш ранее полученных сертификатов | ||||
|  * @returns список сертификатов | ||||
|  */ | ||||
| export declare const getAllContainerCertificates: (resetCache?: boolean) => Promise<Certificate[]>; | ||||
							
								
								
									
										8
									
								
								lib/api/getAllUserCertificates.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								lib/api/getAllUserCertificates.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,8 @@ | ||||
| import { Certificate } from './certificate'; | ||||
| /** | ||||
|  * Возвращает все сертификаты без фильтрации по дате и наличию приватного ключа | ||||
|  * | ||||
|  * @param resetCache = false - позволяет сбросить кэш ранее полученных сертификатов | ||||
|  * @returns список сертификатов | ||||
|  */ | ||||
| export declare const getAllUserCertificates: (resetCache?: boolean) => Promise<Certificate[]>; | ||||
							
								
								
									
										8
									
								
								lib/api/getCertificate.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								lib/api/getCertificate.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,8 @@ | ||||
| import { Certificate } from './certificate'; | ||||
| /** | ||||
|  * Возвращает сертификат по отпечатку | ||||
|  * | ||||
|  * @param thumbprint - отпечаток сертификата | ||||
|  * @returns сертификат | ||||
|  */ | ||||
| export declare const getCertificate: (thumbprint: string) => Promise<Certificate>; | ||||
							
								
								
									
										9
									
								
								lib/api/getContainerCertificates.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								lib/api/getContainerCertificates.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,9 @@ | ||||
| import { Certificate } from './certificate'; | ||||
| /** | ||||
|  * Начиная с версии плагина 2.0.13292 есть возможность получить сертификаты из закрытых ключей | ||||
|  * Возвращает список сертификатов, доступных пользователю в системе | ||||
|  * | ||||
|  * @param resetCache = false - позволяет сбросить кэш ранее полученных сертификатов | ||||
|  * @returns список сертификатов | ||||
|  */ | ||||
| export declare const getContainerCertificates: (resetCache?: boolean) => Promise<Certificate[]>; | ||||
							
								
								
									
										6
									
								
								lib/api/getCspVersion.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								lib/api/getCspVersion.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,6 @@ | ||||
| /** | ||||
|  * Предоставляет информацию о системе | ||||
|  * | ||||
|  * @returns информацию о CSP | ||||
|  */ | ||||
| export declare const getCspVersion: () => Promise<string>; | ||||
							
								
								
									
										6
									
								
								lib/api/getPluginVersion.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								lib/api/getPluginVersion.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,6 @@ | ||||
| /** | ||||
|  * Предоставляет информацию о системе | ||||
|  * | ||||
|  * @returns информацию о плагине | ||||
|  */ | ||||
| export declare const getPluginVersion: () => Promise<string>; | ||||
							
								
								
									
										10
									
								
								lib/api/getSystemInfo.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								lib/api/getSystemInfo.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,10 @@ | ||||
| export interface SystemInfo { | ||||
|     cadesVersion: string; | ||||
|     cspVersion: string; | ||||
| } | ||||
| /** | ||||
|  * Предоставляет информацию о системе | ||||
|  * | ||||
|  * @returns информацию о CSP и плагине | ||||
|  */ | ||||
| export declare const getSystemInfo: () => Promise<SystemInfo>; | ||||
							
								
								
									
										8
									
								
								lib/api/getUserCertificates.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								lib/api/getUserCertificates.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,8 @@ | ||||
| import { Certificate } from './certificate'; | ||||
| /** | ||||
|  * Возвращает список сертификатов, доступных пользователю в системе | ||||
|  * | ||||
|  * @param resetCache = false - позволяет сбросить кэш ранее полученных сертификатов | ||||
|  * @returns список сертификатов | ||||
|  */ | ||||
| export declare const getUserCertificates: (resetCache?: boolean) => Promise<Certificate[]>; | ||||
							
								
								
									
										16
									
								
								lib/api/index.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								lib/api/index.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,16 @@ | ||||
| export * from './getCertificate'; | ||||
| export * from './getUserCertificates'; | ||||
| export * from './getAllUserCertificates'; | ||||
| export * from './getContainerCertificates'; | ||||
| export * from './getAllContainerCertificates'; | ||||
| export * from './getSystemInfo'; | ||||
| export * from './isValidSystemSetup'; | ||||
| export * from './createXMLSignature'; | ||||
| export * from './createDetachedSignature'; | ||||
| export * from './addDetachedSignature'; | ||||
| export * from './createAttachedSignature'; | ||||
| export * from './addAttachedSignature'; | ||||
| export * from './createHash'; | ||||
| export * from './certificate'; | ||||
| export * from './getCspVersion'; | ||||
| export * from './getPluginVersion'; | ||||
							
								
								
									
										6
									
								
								lib/api/isValidSystemSetup.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								lib/api/isValidSystemSetup.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,6 @@ | ||||
| /** | ||||
|  * Проверяет корректность настроек ЭП на машине | ||||
|  * | ||||
|  * @returns флаг корректности настроек | ||||
|  */ | ||||
| export declare const isValidSystemSetup: () => Promise<boolean>; | ||||
							
								
								
									
										149
									
								
								lib/constants/cades-constants.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										149
									
								
								lib/constants/cades-constants.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,149 @@ | ||||
| export declare const CADESCOM_ATTRIBUTE_OTHER = -1; | ||||
| export declare const CADESCOM_AUTHENTICATED_ATTRIBUTE_DOCUMENT_DESCRIPTION = 2; | ||||
| export declare const CADESCOM_AUTHENTICATED_ATTRIBUTE_DOCUMENT_NAME = 1; | ||||
| export declare const CADESCOM_AUTHENTICATED_ATTRIBUTE_SIGNING_TIME = 0; | ||||
| export declare const CADESCOM_AllowNoOutstandingRequest = 1; | ||||
| export declare const CADESCOM_AllowNone = 0; | ||||
| export declare const CADESCOM_AllowUntrustedCertificate = 2; | ||||
| export declare const CADESCOM_AllowUntrustedRoot = 4; | ||||
| export declare const CADESCOM_BASE64_TO_BINARY = 1; | ||||
| export declare const CADESCOM_CADES_BES = 1; | ||||
| export declare const CADESCOM_CADES_DEFAULT = 0; | ||||
| export declare const CADESCOM_CADES_T = 5; | ||||
| export declare const CADESCOM_CADES_X_LONG_TYPE_1 = 93; | ||||
| export declare const CADESCOM_CONTAINER_STORE = 100; | ||||
| export declare const CADESCOM_CURRENT_USER_STORE = 2; | ||||
| export declare const CADESCOM_DISPLAY_DATA_ATTRIBUTE = 2; | ||||
| export declare const CADESCOM_DISPLAY_DATA_CONTENT = 1; | ||||
| export declare const CADESCOM_DISPLAY_DATA_NONE = 0; | ||||
| export declare const CADESCOM_ENCODE_ANY = -1; | ||||
| export declare const CADESCOM_ENCODE_BASE64 = 0; | ||||
| export declare const CADESCOM_ENCODE_BINARY = 1; | ||||
| export declare const CADESCOM_ENCRYPTION_ALGORITHM_3DES = 3; | ||||
| export declare const CADESCOM_ENCRYPTION_ALGORITHM_AES = 4; | ||||
| export declare const CADESCOM_ENCRYPTION_ALGORITHM_DES = 2; | ||||
| export declare const CADESCOM_ENCRYPTION_ALGORITHM_GOST_28147_89 = 25; | ||||
| export declare const CADESCOM_ENCRYPTION_ALGORITHM_RC2 = 0; | ||||
| export declare const CADESCOM_ENCRYPTION_ALGORITHM_RC4 = 1; | ||||
| export declare const CADESCOM_HASH_ALGORITHM_CP_GOST_3411 = 100; | ||||
| export declare const CADESCOM_HASH_ALGORITHM_CP_GOST_3411_2012_256 = 101; | ||||
| export declare const CADESCOM_HASH_ALGORITHM_CP_GOST_3411_2012_256_HMAC = 111; | ||||
| export declare const CADESCOM_HASH_ALGORITHM_CP_GOST_3411_2012_512 = 102; | ||||
| export declare const CADESCOM_HASH_ALGORITHM_CP_GOST_3411_2012_512_HMAC = 112; | ||||
| export declare const CADESCOM_HASH_ALGORITHM_CP_GOST_3411_HMAC = 110; | ||||
| export declare const CADESCOM_HASH_ALGORITHM_MD2 = 1; | ||||
| export declare const CADESCOM_HASH_ALGORITHM_MD4 = 2; | ||||
| export declare const CADESCOM_HASH_ALGORITHM_MD5 = 3; | ||||
| export declare const CADESCOM_HASH_ALGORITHM_SHA1 = 0; | ||||
| export declare const CADESCOM_HASH_ALGORITHM_SHA_256 = 4; | ||||
| export declare const CADESCOM_HASH_ALGORITHM_SHA_384 = 5; | ||||
| export declare const CADESCOM_HASH_ALGORITHM_SHA_512 = 6; | ||||
| export declare const CADESCOM_LOCAL_MACHINE_STORE = 1; | ||||
| export declare const CADESCOM_PKCS7_TYPE = 65535; | ||||
| export declare const CADESCOM_STRING_TO_UCS2LE = 0; | ||||
| export declare const CADESCOM_SkipInstallToStore = 268435456; | ||||
| export declare const CADESCOM_XML_SIGNATURE_TYPE_ENVELOPED = 0; | ||||
| export declare const CADESCOM_XML_SIGNATURE_TYPE_ENVELOPING = 1; | ||||
| export declare const CADESCOM_XML_SIGNATURE_TYPE_TEMPLATE = 2; | ||||
| export declare const CAPICOM_ACTIVE_DIRECTORY_USER_STORE = 3; | ||||
| export declare const CAPICOM_AUTHENTICATED_ATTRIBUTE_DOCUMENT_DESCRIPTION = 2; | ||||
| export declare const CAPICOM_AUTHENTICATED_ATTRIBUTE_DOCUMENT_NAME = 1; | ||||
| export declare const CAPICOM_AUTHENTICATED_ATTRIBUTE_SIGNING_TIME = 0; | ||||
| export declare const CAPICOM_CERTIFICATE_FIND_APPLICATION_POLICY = 7; | ||||
| export declare const CAPICOM_CERTIFICATE_FIND_CERTIFICATE_POLICY = 8; | ||||
| export declare const CAPICOM_CERTIFICATE_FIND_EXTENDED_PROPERTY = 6; | ||||
| export declare const CAPICOM_CERTIFICATE_FIND_EXTENSION = 5; | ||||
| export declare const CAPICOM_CERTIFICATE_FIND_ISSUER_NAME = 2; | ||||
| export declare const CAPICOM_CERTIFICATE_FIND_KEY_USAGE = 12; | ||||
| export declare const CAPICOM_CERTIFICATE_FIND_ROOT_NAME = 3; | ||||
| export declare const CAPICOM_CERTIFICATE_FIND_SHA1_HASH = 0; | ||||
| export declare const CAPICOM_CERTIFICATE_FIND_SUBJECT_NAME = 1; | ||||
| export declare const CAPICOM_CERTIFICATE_FIND_TEMPLATE_NAME = 4; | ||||
| export declare const CAPICOM_CERTIFICATE_FIND_TIME_EXPIRED = 11; | ||||
| export declare const CAPICOM_CERTIFICATE_FIND_TIME_NOT_YET_VALID = 10; | ||||
| export declare const CAPICOM_CERTIFICATE_FIND_TIME_VALID = 9; | ||||
| export declare const CAPICOM_CERTIFICATE_INCLUDE_CHAIN_EXCEPT_ROOT = 0; | ||||
| export declare const CAPICOM_CERTIFICATE_INCLUDE_END_ENTITY_ONLY = 2; | ||||
| export declare const CAPICOM_CERTIFICATE_INCLUDE_WHOLE_CHAIN = 1; | ||||
| export declare const CAPICOM_CERT_INFO_ISSUER_SIMPLE_NAME = 1; | ||||
| export declare const CAPICOM_CERT_INFO_SUBJECT_SIMPLE_NAME = 0; | ||||
| export declare const CAPICOM_CURRENT_USER_STORE = 2; | ||||
| export declare const CAPICOM_DIGITAL_SIGNATURE_KEY_USAGE = 128; | ||||
| export declare const CAPICOM_EKU_CLIENT_AUTH = 2; | ||||
| export declare const CAPICOM_EKU_OTHER = 0; | ||||
| export declare const CAPICOM_EKU_SMARTCARD_LOGON = 5; | ||||
| export declare const CAPICOM_LOCAL_MACHINE_STORE = 1; | ||||
| export declare const CAPICOM_MEMORY_STORE = 0; | ||||
| export declare const CAPICOM_MY_STORE = "My"; | ||||
| export declare const CAPICOM_OID_KEY_USAGE_EXTENSION = 10; | ||||
| export declare const CAPICOM_OID_OTHER = 0; | ||||
| export declare const CAPICOM_PROPID_ACCESS_STATE = 14; | ||||
| export declare const CAPICOM_PROPID_ARCHIVED = 19; | ||||
| export declare const CAPICOM_PROPID_ARCHIVED_KEY_HASH = 65; | ||||
| export declare const CAPICOM_PROPID_AUTO_ENROLL = 21; | ||||
| export declare const CAPICOM_PROPID_CROSS_CERT_DIST_POINTS = 23; | ||||
| export declare const CAPICOM_PROPID_CTL_USAGE = 9; | ||||
| export declare const CAPICOM_PROPID_DATE_STAMP = 27; | ||||
| export declare const CAPICOM_PROPID_DESCRIPTION = 13; | ||||
| export declare const CAPICOM_PROPID_EFS = 17; | ||||
| export declare const CAPICOM_PROPID_ENHKEY_USAGE = 9; | ||||
| export declare const CAPICOM_PROPID_ENROLLMENT = 26; | ||||
| export declare const CAPICOM_PROPID_EXTENDED_ERROR_INFO = 30; | ||||
| export declare const CAPICOM_PROPID_FIRST_RESERVED = 66; | ||||
| export declare const CAPICOM_PROPID_FIRST_USER = 32768; | ||||
| export declare const CAPICOM_PROPID_FORTEZZA_DATA = 18; | ||||
| export declare const CAPICOM_PROPID_FRIENDLY_NAME = 11; | ||||
| export declare const CAPICOM_PROPID_HASH_PROP = 3; | ||||
| export declare const CAPICOM_PROPID_IE30_RESERVED = 7; | ||||
| export declare const CAPICOM_PROPID_ISSUER_PUBLIC_KEY_MD5_HASH = 24; | ||||
| export declare const CAPICOM_PROPID_ISSUER_SERIAL_NUMBER_MD5_HASH = 28; | ||||
| export declare const CAPICOM_PROPID_KEY_CONTEXT = 5; | ||||
| export declare const CAPICOM_PROPID_KEY_IDENTIFIER = 20; | ||||
| export declare const CAPICOM_PROPID_KEY_PROV_HANDLE = 1; | ||||
| export declare const CAPICOM_PROPID_KEY_PROV_INFO = 2; | ||||
| export declare const CAPICOM_PROPID_KEY_SPEC = 6; | ||||
| export declare const CAPICOM_PROPID_LAST_RESERVED = 32767; | ||||
| export declare const CAPICOM_PROPID_LAST_USER = 65535; | ||||
| export declare const CAPICOM_PROPID_MD5_HASH = 4; | ||||
| export declare const CAPICOM_PROPID_NEXT_UPDATE_LOCATION = 10; | ||||
| export declare const CAPICOM_PROPID_PUBKEY_ALG_PARA = 22; | ||||
| export declare const CAPICOM_PROPID_PUBKEY_HASH_RESERVED = 8; | ||||
| export declare const CAPICOM_PROPID_PVK_FILE = 12; | ||||
| export declare const CAPICOM_PROPID_RENEWAL = 64; | ||||
| export declare const CAPICOM_PROPID_SHA1_HASH = 3; | ||||
| export declare const CAPICOM_PROPID_SIGNATURE_HASH = 15; | ||||
| export declare const CAPICOM_PROPID_SMART_CARD_DATA = 16; | ||||
| export declare const CAPICOM_PROPID_SUBJECT_NAME_MD5_HASH = 29; | ||||
| export declare const CAPICOM_PROPID_SUBJECT_PUBLIC_KEY_MD5_HASH = 25; | ||||
| export declare const CAPICOM_PROPID_UNKNOWN = 0; | ||||
| export declare const CAPICOM_SMART_CARD_USER_STORE = 4; | ||||
| export declare const CAPICOM_STORE_OPEN_EXISTING_ONLY = 128; | ||||
| export declare const CAPICOM_STORE_OPEN_INCLUDE_ARCHIVED = 256; | ||||
| export declare const CAPICOM_STORE_OPEN_MAXIMUM_ALLOWED = 2; | ||||
| export declare const CAPICOM_STORE_OPEN_READ_ONLY = 0; | ||||
| export declare const CAPICOM_STORE_OPEN_READ_WRITE = 1; | ||||
| export declare const CHECK_NONE = 0; | ||||
| export declare const CHECK_OFFLINE_REVOCATION_STATUS = 16; | ||||
| export declare const CHECK_ONLINE_REVOCATION_STATUS = 8; | ||||
| export declare const CHECK_SIGNATURE_VALIDITY = 4; | ||||
| export declare const CHECK_TIME_VALIDITY = 2; | ||||
| export declare const CHECK_TRUSTED_ROOT = 1; | ||||
| export declare const LOG_LEVEL_DEBUG = 4; | ||||
| export declare const LOG_LEVEL_ERROR = 1; | ||||
| export declare const LOG_LEVEL_INFO = 2; | ||||
| export declare const TRUST_CTL_IS_NOT_SIGNATURE_VALID = 262144; | ||||
| export declare const TRUST_CTL_IS_NOT_TIME_VALID = 131072; | ||||
| export declare const TRUST_CTL_IS_NOT_VALID_FOR_USAGE = 524288; | ||||
| export declare const TRUST_IS_CYCLIC = 128; | ||||
| export declare const TRUST_IS_NOT_SIGNATURE_VALID = 8; | ||||
| export declare const TRUST_IS_NOT_TIME_NESTED = 2; | ||||
| export declare const TRUST_IS_NOT_TIME_VALID = 1; | ||||
| export declare const TRUST_IS_NOT_VALID_FOR_USAGE = 16; | ||||
| export declare const TRUST_IS_PARTIAL_CHAIN = 65536; | ||||
| export declare const TRUST_IS_REVOKED = 4; | ||||
| export declare const TRUST_IS_UNTRUSTED_ROOT = 32; | ||||
| export declare const TRUST_REVOCATION_STATUS_UNKNOWN = 64; | ||||
| export declare const XmlDsigGost3410Url = "urn:ietf:params:xml:ns:cpxmlsec:algorithms:gostr34102001-gostr3411"; | ||||
| export declare const XmlDsigGost3410UrlObsolete = "http://www.w3.org/2001/04/xmldsig-more#gostr34102001-gostr3411"; | ||||
| export declare const XmlDsigGost3411Url = "urn:ietf:params:xml:ns:cpxmlsec:algorithms:gostr3411"; | ||||
| export declare const XmlDsigGost3411UrlObsolete = "http://www.w3.org/2001/04/xmldsig-more#gostr3411"; | ||||
							
								
								
									
										4
									
								
								lib/constants/index.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								lib/constants/index.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,4 @@ | ||||
| export * from './cades-constants'; | ||||
| export * from './issuer-tags-translations'; | ||||
| export * from './oids-dictionary'; | ||||
| export * from './subject-tags-translations'; | ||||
							
								
								
									
										2
									
								
								lib/constants/issuer-tags-translations.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								lib/constants/issuer-tags-translations.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,2 @@ | ||||
| import { TagsTranslations } from './tags-translations'; | ||||
| export declare const ISSUER_TAGS_TRANSLATIONS: TagsTranslations[]; | ||||
							
								
								
									
										44
									
								
								lib/constants/oids-dictionary.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								lib/constants/oids-dictionary.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,44 @@ | ||||
| export declare const OIDS_DICTIONARY: { | ||||
|     '1.2.643.2.2.34.6': string; | ||||
|     '1.2.643.2.39.1.1': string; | ||||
|     '1.2.643.3.131.1.1': string; | ||||
|     '1.2.643.3.141.1.1': string; | ||||
|     '1.2.643.3.141.1.2': string; | ||||
|     '1.2.643.3.2.100.65.13.11': string; | ||||
|     '1.2.643.3.8.100.1': string; | ||||
|     '1.2.643.3.8.100.1.1': string; | ||||
|     '1.2.643.3.8.100.1.10': string; | ||||
|     '1.2.643.3.8.100.1.11': string; | ||||
|     '1.2.643.3.8.100.1.12': string; | ||||
|     '1.2.643.3.8.100.1.13': string; | ||||
|     '1.2.643.3.8.100.1.14': string; | ||||
|     '1.2.643.3.8.100.1.2': string; | ||||
|     '1.2.643.3.8.100.1.3': string; | ||||
|     '1.2.643.3.8.100.1.4': string; | ||||
|     '1.2.643.3.8.100.1.5': string; | ||||
|     '1.2.643.3.8.100.1.6': string; | ||||
|     '1.2.643.3.8.100.1.7': string; | ||||
|     '1.2.643.3.8.100.1.8': string; | ||||
|     '1.2.643.3.8.100.1.9': string; | ||||
|     '1.2.643.5.1.24.2.1.3': string; | ||||
|     '1.2.643.5.1.24.2.1.3.1': string; | ||||
|     '1.2.643.5.1.24.2.2.2': string; | ||||
|     '1.2.643.5.1.24.2.2.3': string; | ||||
|     '1.2.643.6.2.1.7.1': string; | ||||
|     '1.2.643.6.2.1.7.2': string; | ||||
|     '1.2.643.6.3': string; | ||||
|     '1.2.643.6.3.1.1': string; | ||||
|     '1.2.643.6.3.1.2.1': string; | ||||
|     '1.2.643.6.3.1.2.2': string; | ||||
|     '1.2.643.6.3.1.2.3': string; | ||||
|     '1.2.643.6.3.1.3.1': string; | ||||
|     '1.2.643.6.3.1.4.1': string; | ||||
|     '1.2.643.6.3.1.4.2': string; | ||||
|     '1.2.643.6.3.1.4.3': string; | ||||
|     '1.2.840.113549.1.9.2': string; | ||||
|     '1.3.6.1.4.1.24138.1.1.8.1': string; | ||||
|     '1.3.6.1.4.1.29919.21': string; | ||||
|     '1.3.6.1.5.5.7.3.2': string; | ||||
|     '1.3.6.1.5.5.7.3.4': string; | ||||
|     '1.3.643.3.8.100.15': string; | ||||
| }; | ||||
							
								
								
									
										2
									
								
								lib/constants/subject-tags-translations.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								lib/constants/subject-tags-translations.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,2 @@ | ||||
| import { TagsTranslations } from './tags-translations'; | ||||
| export declare const SUBJECT_TAGS_TRANSLATIONS: TagsTranslations[]; | ||||
							
								
								
									
										4
									
								
								lib/constants/tags-translations.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								lib/constants/tags-translations.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,4 @@ | ||||
| export interface TagsTranslations { | ||||
|     possibleNames: string[]; | ||||
|     translation: string; | ||||
| } | ||||
							
								
								
									
										5
									
								
								lib/crypto-pro-js.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								lib/crypto-pro-js.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,5 @@ | ||||
| // Type definitions for crypto-pro-js 2.3.1
 | ||||
| // Project: crypto-pro-js
 | ||||
| // Definitions by: Artem Vasilev https://github.com/kernusr
 | ||||
| 
 | ||||
| export * from './api'; | ||||
							
								
								
									
										5133
									
								
								lib/crypto-pro-js.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5133
									
								
								lib/crypto-pro-js.js
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										1
									
								
								lib/crypto-pro-js.js.map
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								lib/crypto-pro-js.js.map
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										3
									
								
								lib/helpers/_afterPluginsLoaded.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								lib/helpers/_afterPluginsLoaded.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,3 @@ | ||||
| declare type Unpromisify<T> = T extends Promise<infer R> ? R : T; | ||||
| export declare const _afterPluginsLoaded: <T extends (...args: any[]) => any>(fn: T) => (...args: Parameters<T>) => Promise<Unpromisify<ReturnType<T>>>; | ||||
| export {}; | ||||
							
								
								
									
										1
									
								
								lib/helpers/_extractCommonName.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								lib/helpers/_extractCommonName.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1 @@ | ||||
| export declare const _extractCommonName: (subjectName: string) => string; | ||||
							
								
								
									
										1
									
								
								lib/helpers/_extractMeaningfulErrorMessage.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								lib/helpers/_extractMeaningfulErrorMessage.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1 @@ | ||||
| export declare const _extractMeaningfulErrorMessage: (error: Error) => string; | ||||
							
								
								
									
										3
									
								
								lib/helpers/_generateCadesFn.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								lib/helpers/_generateCadesFn.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,3 @@ | ||||
| export declare const __cadesAsyncToken__: {}; | ||||
| export declare const __createCadesPluginObject__: (...args: any[]) => any; | ||||
| export declare const _generateCadesFn: (callback: Function) => string; | ||||
							
								
								
									
										7
									
								
								lib/helpers/_getCadesCert.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								lib/helpers/_getCadesCert.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,7 @@ | ||||
| /** | ||||
|  * Возвращает сертификат в формате Cades по отпечатку | ||||
|  * | ||||
|  * @param thumbprint - отпечаток сертификата | ||||
|  * @returns сертификат в формате Cades | ||||
|  */ | ||||
| export declare const _getCadesCert: (thumbprint: string) => Promise<any>; | ||||
							
								
								
									
										7
									
								
								lib/helpers/_getDateObj.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								lib/helpers/_getDateObj.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,7 @@ | ||||
| /** | ||||
|  * Возвращает объект даты, совместимый с Cades plugin'ом, зависящий от браузера. | ||||
|  * | ||||
|  * В IE необходимо использовать специфичный формат "VT_DATE" | ||||
|  * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Microsoft_Extensions/Date.getVarDate
 | ||||
|  */ | ||||
| export declare const _getDateObj: (dateObj: any) => Date; | ||||
							
								
								
									
										1
									
								
								lib/helpers/_isSupportedCSPVersion.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								lib/helpers/_isSupportedCSPVersion.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1 @@ | ||||
| export declare const _isSupportedCSPVersion: (version: string) => boolean; | ||||
							
								
								
									
										1
									
								
								lib/helpers/_isSupportedCadesVersion.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								lib/helpers/_isSupportedCadesVersion.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1 @@ | ||||
| export declare const _isSupportedCadesVersion: (version: string) => boolean; | ||||
							
								
								
									
										14
									
								
								lib/helpers/_parseCertInfo.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								lib/helpers/_parseCertInfo.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,14 @@ | ||||
| import { TagsTranslations } from '../constants/tags-translations'; | ||||
| export interface TagTranslation { | ||||
|     description: string; | ||||
|     title: string; | ||||
|     isTranslated: boolean; | ||||
| } | ||||
| /** | ||||
|  * Парсит информацию из строки с информацией о сертификате | ||||
|  * | ||||
|  * @param tagsTranslations - словарь с расшифровками тэгов | ||||
|  * @param rawInfo - данные для парсинга | ||||
|  * @returns расшифрованная информация по отдельным тэгам | ||||
|  */ | ||||
| export declare const _parseCertInfo: (tagsTranslations: TagsTranslations[], rawInfo: string) => TagTranslation[]; | ||||
							
								
								
									
										60
									
								
								src/api/getAllContainerCertificates.test.ts
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										60
									
								
								src/api/getAllContainerCertificates.test.ts
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,60 @@ | ||||
| import 'cadesplugin'; | ||||
| import { rawCertificates, parsedCertificates } from '../__mocks__/certificates'; | ||||
| import { getAllContainerCertificates } from './getAllContainerCertificates'; | ||||
| 
 | ||||
| const [rawCertificateMock] = rawCertificates; | ||||
| const [parsedCertificateMock] = parsedCertificates; | ||||
| 
 | ||||
| const executionSteps = [ | ||||
|   Symbol('step 0'), | ||||
|   Symbol('step 1'), | ||||
|   Symbol('step 2'), | ||||
|   Symbol('step 3'), | ||||
|   Symbol('step 4'), | ||||
|   Symbol('step 5'), | ||||
|   Symbol('step 6'), | ||||
|   Symbol('step 7'), | ||||
|   Symbol('step 8'), | ||||
| ]; | ||||
| 
 | ||||
| const executionFlow = { | ||||
|   [executionSteps[0]]: { | ||||
|     Certificates: executionSteps[1], | ||||
|     Close: jest.fn(), | ||||
|     Open: jest.fn(), | ||||
|   }, | ||||
|   [executionSteps[1]]: { | ||||
|     Count: executionSteps[2], | ||||
|     Item: jest.fn(() => executionSteps[3]), | ||||
|   }, | ||||
|   [executionSteps[2]]: 1, | ||||
|   [executionSteps[3]]: { | ||||
|     IssuerName: executionSteps[6], | ||||
|     SubjectName: executionSteps[5], | ||||
|     Thumbprint: executionSteps[4], | ||||
|     ValidFromDate: executionSteps[7], | ||||
|     ValidToDate: executionSteps[8], | ||||
|   }, | ||||
|   [executionSteps[6]]: rawCertificateMock.IssuerName, | ||||
|   [executionSteps[5]]: rawCertificateMock.SubjectName, | ||||
|   [executionSteps[4]]: rawCertificateMock.Thumbprint, | ||||
|   [executionSteps[7]]: rawCertificateMock.ValidFromDate, | ||||
|   [executionSteps[8]]: rawCertificateMock.ValidToDate, | ||||
| }; | ||||
| 
 | ||||
| window.cadesplugin.__defineExecutionFlow(executionFlow); | ||||
| window.cadesplugin.CreateObjectAsync.mockImplementation(() => executionSteps[0]); | ||||
| 
 | ||||
| describe('getUserCertificates', () => { | ||||
|   test('returns certificates list', async () => { | ||||
|     const certificates = await getAllContainerCertificates(); | ||||
| 
 | ||||
|     expect(certificates.length).toBeGreaterThan(0); | ||||
|   }); | ||||
| 
 | ||||
|   test('returns certificates with correct fields', async () => { | ||||
|     const [certificate] = await getAllContainerCertificates(); | ||||
| 
 | ||||
|     expect(certificate).toMatchObject(parsedCertificateMock); | ||||
|   }); | ||||
| }); | ||||
							
								
								
									
										100
									
								
								src/api/getAllContainerCertificates.ts
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										100
									
								
								src/api/getAllContainerCertificates.ts
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,100 @@ | ||||
| import { CadesCertificate, Certificate } from './certificate'; | ||||
| import { _afterPluginsLoaded } from '../helpers/_afterPluginsLoaded'; | ||||
| import { _extractCommonName } from '../helpers/_extractCommonName'; | ||||
| import { _extractMeaningfulErrorMessage } from '../helpers/_extractMeaningfulErrorMessage'; | ||||
| import { __cadesAsyncToken__, __createCadesPluginObject__, _generateCadesFn } from '../helpers/_generateCadesFn'; | ||||
| 
 | ||||
| let certificatesCache: Certificate[]; | ||||
| 
 | ||||
| /** | ||||
|  * Начиная с версии плагина 2.0.13292 есть возможность получить сертификаты из закрытых ключей | ||||
|  * Возвращает все сертификаты без фильтрации по дате и наличию приватного ключа | ||||
|  * | ||||
|  * @param resetCache = false - позволяет сбросить кэш ранее полученных сертификатов | ||||
|  * @returns список сертификатов | ||||
|  */ | ||||
| export const getAllContainerCertificates = _afterPluginsLoaded((resetCache: boolean = false): Certificate[] => { | ||||
|   const { cadesplugin } = window; | ||||
| 
 | ||||
|   if (!resetCache && certificatesCache) { | ||||
|     return certificatesCache; | ||||
|   } | ||||
| 
 | ||||
|   return eval( | ||||
|     _generateCadesFn(function getAllContainerCertificates(): Certificate[] { | ||||
|       let cadesStore; | ||||
| 
 | ||||
|       try { | ||||
|         cadesStore = __cadesAsyncToken__ + __createCadesPluginObject__('CAdESCOM.Store'); | ||||
|       } catch (error) { | ||||
|         console.error(error); | ||||
| 
 | ||||
|         throw new Error(_extractMeaningfulErrorMessage(error) || 'Ошибка при попытке доступа к хранилищу'); | ||||
|       } | ||||
| 
 | ||||
|       try { | ||||
|         void ( | ||||
|           __cadesAsyncToken__ + | ||||
|           cadesStore.Open( | ||||
|             cadesplugin.CADESCOM_CONTAINER_STORE, | ||||
|             cadesplugin.CAPICOM_MY_STORE, | ||||
|             cadesplugin.CAPICOM_STORE_OPEN_MAXIMUM_ALLOWED, | ||||
|           ) | ||||
|         ); | ||||
|       } catch (error) { | ||||
|         console.error(error); | ||||
| 
 | ||||
|         throw new Error(_extractMeaningfulErrorMessage(error) || 'Ошибка при открытии хранилища'); | ||||
|       } | ||||
| 
 | ||||
|       let cadesCertificates; | ||||
|       let cadesCertificatesCount; | ||||
| 
 | ||||
|       try { | ||||
|         cadesCertificates = __cadesAsyncToken__ + cadesStore.Certificates; | ||||
|         cadesCertificatesCount = __cadesAsyncToken__ + cadesCertificates.Count; | ||||
|       } catch (error) { | ||||
|         console.error(error); | ||||
| 
 | ||||
|         throw new Error(_extractMeaningfulErrorMessage(error) || 'Ошибка получения списка сертификатов'); | ||||
|       } | ||||
| 
 | ||||
|       if (!cadesCertificatesCount) { | ||||
|         throw new Error('Нет доступных сертификатов'); | ||||
|       } | ||||
| 
 | ||||
|       const certificateList: Certificate[] = []; | ||||
| 
 | ||||
|       try { | ||||
|         while (cadesCertificatesCount) { | ||||
|           const cadesCertificate: CadesCertificate = | ||||
|             __cadesAsyncToken__ + cadesCertificates.Item(cadesCertificatesCount); | ||||
| 
 | ||||
|           certificateList.push( | ||||
|             new Certificate( | ||||
|               cadesCertificate, | ||||
|               _extractCommonName(__cadesAsyncToken__ + cadesCertificate.SubjectName), | ||||
|               __cadesAsyncToken__ + cadesCertificate.IssuerName, | ||||
|               __cadesAsyncToken__ + cadesCertificate.SubjectName, | ||||
|               __cadesAsyncToken__ + cadesCertificate.Thumbprint, | ||||
|               __cadesAsyncToken__ + cadesCertificate.ValidFromDate, | ||||
|               __cadesAsyncToken__ + cadesCertificate.ValidToDate, | ||||
|             ), | ||||
|           ); | ||||
| 
 | ||||
|           cadesCertificatesCount--; | ||||
|         } | ||||
|       } catch (error) { | ||||
|         console.error(error); | ||||
| 
 | ||||
|         throw new Error(_extractMeaningfulErrorMessage(error) || 'Ошибка обработки сертификатов'); | ||||
|       } | ||||
| 
 | ||||
|       cadesStore.Close(); | ||||
| 
 | ||||
|       certificatesCache = certificateList; | ||||
| 
 | ||||
|       return certificatesCache; | ||||
|     }), | ||||
|   ); | ||||
| }); | ||||
							
								
								
									
										68
									
								
								src/api/getContainerCertificates.test.ts
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										68
									
								
								src/api/getContainerCertificates.test.ts
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,68 @@ | ||||
| import 'cadesplugin'; | ||||
| import { rawCertificates, parsedCertificates } from '../__mocks__/certificates'; | ||||
| import { getContainerCertificates } from './getContainerCertificates'; | ||||
| 
 | ||||
| const [rawCertificateMock] = rawCertificates; | ||||
| const [parsedCertificateMock] = parsedCertificates; | ||||
| 
 | ||||
| const executionSteps = [ | ||||
|   Symbol('step 0'), | ||||
|   Symbol('step 1'), | ||||
|   Symbol('step 2'), | ||||
|   Symbol('step 3'), | ||||
|   Symbol('step 4'), | ||||
|   Symbol('step 5'), | ||||
|   Symbol('step 6'), | ||||
|   Symbol('step 7'), | ||||
|   Symbol('step 8'), | ||||
|   Symbol('step 9'), | ||||
|   Symbol('step 10'), | ||||
| ]; | ||||
| 
 | ||||
| const executionFlow = { | ||||
|   [executionSteps[0]]: { | ||||
|     Certificates: executionSteps[1], | ||||
|     Close: jest.fn(), | ||||
|     Open: jest.fn(), | ||||
|   }, | ||||
|   [executionSteps[1]]: { | ||||
|     Find: jest.fn(() => executionSteps[2]), | ||||
|   }, | ||||
|   [executionSteps[2]]: { | ||||
|     Find: jest.fn(() => executionSteps[3]), | ||||
|   }, | ||||
|   [executionSteps[3]]: { | ||||
|     Count: executionSteps[4], | ||||
|     Item: jest.fn(() => executionSteps[5]), | ||||
|   }, | ||||
|   [executionSteps[4]]: 1, | ||||
|   [executionSteps[5]]: { | ||||
|     IssuerName: executionSteps[8], | ||||
|     SubjectName: executionSteps[7], | ||||
|     Thumbprint: executionSteps[6], | ||||
|     ValidFromDate: executionSteps[9], | ||||
|     ValidToDate: executionSteps[10], | ||||
|   }, | ||||
|   [executionSteps[8]]: rawCertificateMock.IssuerName, | ||||
|   [executionSteps[7]]: rawCertificateMock.SubjectName, | ||||
|   [executionSteps[6]]: rawCertificateMock.Thumbprint, | ||||
|   [executionSteps[9]]: rawCertificateMock.ValidFromDate, | ||||
|   [executionSteps[10]]: rawCertificateMock.ValidToDate, | ||||
| }; | ||||
| 
 | ||||
| window.cadesplugin.__defineExecutionFlow(executionFlow); | ||||
| window.cadesplugin.CreateObjectAsync.mockImplementation(() => executionSteps[0]); | ||||
| 
 | ||||
| describe('getContainerCertificates', () => { | ||||
|   test('returns certificates list', async () => { | ||||
|     const certificates = await getContainerCertificates(); | ||||
| 
 | ||||
|     expect(certificates.length).toBeGreaterThan(0); | ||||
|   }); | ||||
| 
 | ||||
|   test('returns certificates with correct fields', async () => { | ||||
|     const [certificate] = await getContainerCertificates(); | ||||
| 
 | ||||
|     expect(certificate).toMatchObject(parsedCertificateMock); | ||||
|   }); | ||||
| }); | ||||
							
								
								
									
										118
									
								
								src/api/getContainerCertificates.ts
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										118
									
								
								src/api/getContainerCertificates.ts
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,118 @@ | ||||
| import { CadesCertificate, Certificate } from './certificate'; | ||||
| import { CAPICOM_PROPID_KEY_PROV_INFO } from '../constants'; | ||||
| import { _afterPluginsLoaded } from '../helpers/_afterPluginsLoaded'; | ||||
| import { _extractCommonName } from '../helpers/_extractCommonName'; | ||||
| import { _extractMeaningfulErrorMessage } from '../helpers/_extractMeaningfulErrorMessage'; | ||||
| import { __cadesAsyncToken__, __createCadesPluginObject__, _generateCadesFn } from '../helpers/_generateCadesFn'; | ||||
| 
 | ||||
| let certificatesCache: Certificate[]; | ||||
| 
 | ||||
| /** | ||||
|  * Начиная с версии плагина 2.0.13292 есть возможность получить сертификаты из закрытых ключей | ||||
|  * Возвращает список сертификатов, доступных пользователю в системе | ||||
|  * | ||||
|  * @param resetCache = false - позволяет сбросить кэш ранее полученных сертификатов | ||||
|  * @returns список сертификатов | ||||
|  */ | ||||
| export const getContainerCertificates = _afterPluginsLoaded((resetCache: boolean = false): Certificate[] => { | ||||
|   const { cadesplugin } = window; | ||||
| 
 | ||||
|   if (!resetCache && certificatesCache) { | ||||
|     return certificatesCache; | ||||
|   } | ||||
| 
 | ||||
|   return eval( | ||||
|     _generateCadesFn(function getContainerCertificates(): Certificate[] { | ||||
|       let cadesStore; | ||||
| 
 | ||||
|       try { | ||||
|         cadesStore = __cadesAsyncToken__ + __createCadesPluginObject__('CAdESCOM.Store'); | ||||
|       } catch (error) { | ||||
|         console.error(error); | ||||
| 
 | ||||
|         throw new Error(_extractMeaningfulErrorMessage(error) || 'Ошибка при попытке доступа к хранилищу'); | ||||
|       } | ||||
| 
 | ||||
|       try { | ||||
|         void ( | ||||
|           __cadesAsyncToken__ + | ||||
|           cadesStore.Open( | ||||
|             cadesplugin.CADESCOM_CONTAINER_STORE, | ||||
|             cadesplugin.CAPICOM_MY_STORE, | ||||
|             cadesplugin.CAPICOM_STORE_OPEN_MAXIMUM_ALLOWED, | ||||
|           ) | ||||
|         ); | ||||
|       } catch (error) { | ||||
|         console.error(error); | ||||
| 
 | ||||
|         throw new Error(_extractMeaningfulErrorMessage(error) || 'Ошибка при открытии хранилища'); | ||||
|       } | ||||
| 
 | ||||
|       let cadesCertificates; | ||||
|       let cadesCertificatesCount; | ||||
| 
 | ||||
|       try { | ||||
|         cadesCertificates = __cadesAsyncToken__ + cadesStore.Certificates; | ||||
| 
 | ||||
|         if (cadesCertificates) { | ||||
|           cadesCertificates = | ||||
|             __cadesAsyncToken__ + cadesCertificates.Find(cadesplugin.CAPICOM_CERTIFICATE_FIND_TIME_VALID); | ||||
| 
 | ||||
|           /** | ||||
|            * Не рассматриваются сертификаты, в которых отсутствует закрытый ключ | ||||
|            * или не действительны на данный момент | ||||
|            */ | ||||
|           cadesCertificates = | ||||
|             __cadesAsyncToken__ + | ||||
|             cadesCertificates.Find( | ||||
|               cadesplugin.CAPICOM_CERTIFICATE_FIND_EXTENDED_PROPERTY, | ||||
|               CAPICOM_PROPID_KEY_PROV_INFO, | ||||
|             ); | ||||
| 
 | ||||
|           cadesCertificatesCount = __cadesAsyncToken__ + cadesCertificates.Count; | ||||
|         } | ||||
|       } catch (error) { | ||||
|         console.error(error); | ||||
| 
 | ||||
|         throw new Error(_extractMeaningfulErrorMessage(error) || 'Ошибка получения списка сертификатов'); | ||||
|       } | ||||
| 
 | ||||
|       if (!cadesCertificatesCount) { | ||||
|         throw new Error('Нет доступных сертификатов'); | ||||
|       } | ||||
| 
 | ||||
|       const certificateList: Certificate[] = []; | ||||
| 
 | ||||
|       try { | ||||
|         while (cadesCertificatesCount) { | ||||
|           const cadesCertificate: CadesCertificate = | ||||
|             __cadesAsyncToken__ + cadesCertificates.Item(cadesCertificatesCount); | ||||
| 
 | ||||
|           certificateList.push( | ||||
|             new Certificate( | ||||
|               cadesCertificate, | ||||
|               _extractCommonName(__cadesAsyncToken__ + cadesCertificate.SubjectName), | ||||
|               __cadesAsyncToken__ + cadesCertificate.IssuerName, | ||||
|               __cadesAsyncToken__ + cadesCertificate.SubjectName, | ||||
|               __cadesAsyncToken__ + cadesCertificate.Thumbprint, | ||||
|               __cadesAsyncToken__ + cadesCertificate.ValidFromDate, | ||||
|               __cadesAsyncToken__ + cadesCertificate.ValidToDate, | ||||
|             ), | ||||
|           ); | ||||
| 
 | ||||
|           cadesCertificatesCount--; | ||||
|         } | ||||
|       } catch (error) { | ||||
|         console.error(error); | ||||
| 
 | ||||
|         throw new Error(_extractMeaningfulErrorMessage(error) || 'Ошибка обработки сертификатов'); | ||||
|       } | ||||
| 
 | ||||
|       cadesStore.Close(); | ||||
| 
 | ||||
|       certificatesCache = certificateList; | ||||
| 
 | ||||
|       return certificatesCache; | ||||
|     }), | ||||
|   ); | ||||
| }); | ||||
| @ -1,6 +1,8 @@ | ||||
| export * from './getCertificate'; | ||||
| export * from './getUserCertificates'; | ||||
| export * from './getAllUserCertificates'; | ||||
| export * from './getContainerCertificates'; | ||||
| export * from './getAllContainerCertificates'; | ||||
| export * from './getSystemInfo'; | ||||
| export * from './isValidSystemSetup'; | ||||
| export * from './createXMLSignature'; | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user