mirror of
https://github.com/crypto-pro-web/crypto-pro-js.git
synced 2024-11-24 00:55:00 +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 { _afterPluginsLoaded } from '../helpers/_afterPluginsLoaded';
|
||||||
import { _extractMeaningfulErrorMessage } from '../helpers/_extractMeaningfulErrorMessage';
|
import { _extractMeaningfulErrorMessage } from '../helpers/_extractMeaningfulErrorMessage';
|
||||||
import { __cadesAsyncToken__, __createCadesPluginObject__, _generateCadesFn } from '../helpers/_generateCadesFn';
|
import { __cadesAsyncToken__, __createCadesPluginObject__, _generateCadesFn } from '../helpers/_generateCadesFn';
|
||||||
import { _getCadesCert } from '../helpers/_getCadesCert';
|
import { _getCadesCert } from '../helpers/_getCadesCert';
|
||||||
|
import { _getDateObj } from '../helpers/_getDateObj';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Создает отсоединенную подпись хеша по отпечатку сертификата
|
* Создает отсоединенную подпись хеша по отпечатку сертификата
|
||||||
@ -17,11 +19,13 @@ export const createDetachedSignature = _afterPluginsLoaded(
|
|||||||
|
|
||||||
return eval(
|
return eval(
|
||||||
_generateCadesFn(function createDetachedSignature(): string {
|
_generateCadesFn(function createDetachedSignature(): string {
|
||||||
|
let cadesAttrs;
|
||||||
let cadesHashedData;
|
let cadesHashedData;
|
||||||
let cadesSignedData;
|
let cadesSignedData;
|
||||||
let cadesSigner;
|
let cadesSigner;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
cadesAttrs = __cadesAsyncToken__ + __createCadesPluginObject__('CADESCOM.CPAttribute');
|
||||||
cadesHashedData = __cadesAsyncToken__ + __createCadesPluginObject__('CAdESCOM.HashedData');
|
cadesHashedData = __cadesAsyncToken__ + __createCadesPluginObject__('CAdESCOM.HashedData');
|
||||||
cadesSignedData = __cadesAsyncToken__ + __createCadesPluginObject__('CAdESCOM.CadesSignedData');
|
cadesSignedData = __cadesAsyncToken__ + __createCadesPluginObject__('CAdESCOM.CadesSignedData');
|
||||||
cadesSigner = __cadesAsyncToken__ + __createCadesPluginObject__('CAdESCOM.CPSigner');
|
cadesSigner = __cadesAsyncToken__ + __createCadesPluginObject__('CAdESCOM.CPSigner');
|
||||||
@ -31,8 +35,23 @@ export const createDetachedSignature = _afterPluginsLoaded(
|
|||||||
throw new Error(_extractMeaningfulErrorMessage(error) || 'Ошибка при инициализации подписи');
|
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 {
|
try {
|
||||||
void (__cadesAsyncToken__ + cadesSigner.propset_Certificate(cadesCertificate));
|
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));
|
void (__cadesAsyncToken__ + cadesSigner.propset_Options(cadesplugin.CAPICOM_CERTIFICATE_INCLUDE_WHOLE_CHAIN));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
Loading…
Reference in New Issue
Block a user