mirror of
https://github.com/crypto-pro-web/crypto-pro-js.git
synced 2025-04-18 19:43:12 +03:00
31 lines
1.1 KiB
TypeScript
31 lines
1.1 KiB
TypeScript
import { _afterPluginsLoaded } from '../../helpers/_afterPluginsLoaded';
|
||
import { _extractMeaningfulErrorMessage } from '../../helpers/_extractMeaningfulErrorMessage';
|
||
import { __cadesAsyncToken__, _generateCadesFn } from '../../helpers/_generateCadesFn';
|
||
import { Certificate } from './certificate';
|
||
|
||
/**
|
||
* Возвращает указанное внутренее свойство у сертификата в формате Cades
|
||
*
|
||
* @param propName = наименование свойства
|
||
* @returns значение запрошенного свойства
|
||
*/
|
||
export const getCadesProp = _afterPluginsLoaded(function (propName: string): any {
|
||
const cadesCertificate = (this as Certificate)._cadesCertificate;
|
||
|
||
return eval(
|
||
_generateCadesFn(function getCadesProp() {
|
||
let propertyValue;
|
||
|
||
try {
|
||
propertyValue = __cadesAsyncToken__ + cadesCertificate[propName];
|
||
} catch (error) {
|
||
console.error(error);
|
||
|
||
throw new Error(_extractMeaningfulErrorMessage(error) || 'Ошибка при обращении к свойству сертификата');
|
||
}
|
||
|
||
return propertyValue;
|
||
}),
|
||
);
|
||
});
|