forked from vgoma/crypto-pro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathisValid.ts
30 lines (25 loc) · 1 KB
/
isValid.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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 (0, 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);
}),
);
});