mirror of
https://github.com/crypto-pro-web/crypto-pro-js.git
synced 2024-11-23 16:44:59 +03:00
Добавил атрибут времени подписания для отсоединенной подписи
This commit is contained in:
parent
864c05f81c
commit
b090fa4e6c
@ -1,7 +1,9 @@
|
||||
import { CADESCOM_AUTHENTICATED_ATTRIBUTE_SIGNING_TIME } from '../constants';
|
||||
import { _afterPluginsLoaded } from '../helpers/_afterPluginsLoaded';
|
||||
import { _extractMeaningfulErrorMessage } from '../helpers/_extractMeaningfulErrorMessage';
|
||||
import { __cadesAsyncToken__, __createCadesPluginObject__, _generateCadesFn } from '../helpers/_generateCadesFn';
|
||||
import { _getCadesCert } from '../helpers/_getCadesCert';
|
||||
import { _getDateObj } from '../helpers/_getDateObj';
|
||||
|
||||
/**
|
||||
* Создает отсоединенную подпись хеша по отпечатку сертификата
|
||||
@ -17,11 +19,13 @@ export const createDetachedSignature = _afterPluginsLoaded(
|
||||
|
||||
return eval(
|
||||
_generateCadesFn(function createDetachedSignature(): string {
|
||||
let cadesAttrs;
|
||||
let cadesHashedData;
|
||||
let cadesSignedData;
|
||||
let cadesSigner;
|
||||
|
||||
try {
|
||||
cadesAttrs = __cadesAsyncToken__ + __createCadesPluginObject__('CADESCOM.CPAttribute');
|
||||
cadesHashedData = __cadesAsyncToken__ + __createCadesPluginObject__('CAdESCOM.HashedData');
|
||||
cadesSignedData = __cadesAsyncToken__ + __createCadesPluginObject__('CAdESCOM.CadesSignedData');
|
||||
cadesSigner = __cadesAsyncToken__ + __createCadesPluginObject__('CAdESCOM.CPSigner');
|
||||
@ -31,8 +35,23 @@ export const createDetachedSignature = _afterPluginsLoaded(
|
||||
throw new Error(_extractMeaningfulErrorMessage(error) || 'Ошибка при инициализации подписи');
|
||||
}
|
||||
|
||||
const currentTime = _getDateObj(new Date());
|
||||
|
||||
try {
|
||||
void (__cadesAsyncToken__ + cadesAttrs.propset_Name(CADESCOM_AUTHENTICATED_ATTRIBUTE_SIGNING_TIME));
|
||||
void (__cadesAsyncToken__ + cadesAttrs.propset_Value(currentTime));
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
|
||||
throw new Error(_extractMeaningfulErrorMessage(error) || 'Ошибка при установке времени подписи');
|
||||
}
|
||||
|
||||
let cadesAuthAttrs;
|
||||
|
||||
try {
|
||||
void (__cadesAsyncToken__ + cadesSigner.propset_Certificate(cadesCertificate));
|
||||
cadesAuthAttrs = __cadesAsyncToken__ + cadesSigner.AuthenticatedAttributes2;
|
||||
void (__cadesAsyncToken__ + cadesAuthAttrs.Add(cadesAttrs));
|
||||
void (__cadesAsyncToken__ + cadesSigner.propset_Options(cadesplugin.CAPICOM_CERTIFICATE_INCLUDE_WHOLE_CHAIN));
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
|
Loading…
Reference in New Issue
Block a user