mirror of
https://github.com/crypto-pro-web/crypto-pro-js.git
synced 2025-04-21 13:03:07 +03:00
31 lines
1022 B
TypeScript
31 lines
1022 B
TypeScript
import { _afterPluginsLoaded } from '../../helpers/_afterPluginsLoaded';
|
|
import { _extractMeaningfulErrorMessage } from '../../helpers/_extractMeaningfulErrorMessage';
|
|
import { __cadesAsyncToken__, _generateCadesFn } from '../../helpers/_generateCadesFn';
|
|
import { Certificate } from './certificate';
|
|
|
|
/**
|
|
* Проверяет действительность сертификата
|
|
*
|
|
* @returns флаг валидности
|
|
*/
|
|
export const isValid = _afterPluginsLoaded(function (): boolean {
|
|
const cadesCertificate = (this as Certificate)._cadesCertificate;
|
|
|
|
return eval(
|
|
_generateCadesFn(function isValid() {
|
|
let isValid;
|
|
|
|
try {
|
|
isValid = __cadesAsyncToken__ + cadesCertificate.IsValid();
|
|
isValid = __cadesAsyncToken__ + isValid.Result;
|
|
} catch (error) {
|
|
console.error(error);
|
|
|
|
throw new Error(_extractMeaningfulErrorMessage(error) || 'Ошибка при проверке сертификата');
|
|
}
|
|
|
|
return Boolean(isValid);
|
|
}),
|
|
);
|
|
});
|