-
Notifications
You must be signed in to change notification settings - Fork 89
/
getAlgorithm.ts
41 lines (35 loc) · 1.42 KB
/
getAlgorithm.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
31
32
33
34
35
36
37
38
39
40
41
import { _afterPluginsLoaded } from '../../helpers/_afterPluginsLoaded';
import { _extractMeaningfulErrorMessage } from '../../helpers/_extractMeaningfulErrorMessage';
import { __cadesAsyncToken__, _generateCadesFn } from '../../helpers/_generateCadesFn';
import { Certificate } from './certificate';
export interface AlgorithmInfo {
algorithm: string;
oid: string;
}
/**
* Возвращает информацию об алгоритме сертификата
*
* @returns информацию об алгоритме и его OID'е
*/
export const getAlgorithm = _afterPluginsLoaded(function (): AlgorithmInfo {
const cadesCertificate = (this as Certificate)._cadesCertificate;
return eval(
_generateCadesFn(function getAlgorithm(): AlgorithmInfo {
const algorithmInfo: AlgorithmInfo = {
algorithm: null,
oid: null,
};
let cadesPublicKey;
try {
cadesPublicKey = __cadesAsyncToken__ + cadesCertificate.PublicKey();
cadesPublicKey = __cadesAsyncToken__ + cadesPublicKey.Algorithm;
algorithmInfo.algorithm = __cadesAsyncToken__ + cadesPublicKey.FriendlyName;
algorithmInfo.oid = __cadesAsyncToken__ + cadesPublicKey.Value;
} catch (error) {
console.error(error);
throw new Error(_extractMeaningfulErrorMessage(error) || 'Ошибка при получении алгоритма');
}
return algorithmInfo;
}),
);
});