crypto-pro-js/src/api/getCspVersion.ts
2021-05-12 20:53:44 +03:00

41 lines
1.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { _afterPluginsLoaded } from '../helpers/_afterPluginsLoaded';
import { _extractMeaningfulErrorMessage } from '../helpers/_extractMeaningfulErrorMessage';
import {
__cadesAsyncToken__,
__createCadesPluginObject__,
_generateCadesFn,
} from '../helpers/_generateCadesFn';
/**
* Предоставляет информацию о системе
*
* @returns информацию о CSP
*/
export const getCspVersion = _afterPluginsLoaded((): string => {
let cspVersion = null;
return eval(
_generateCadesFn(function getCspVersion(): string {
let cadesAbout;
try {
cadesAbout =
__cadesAsyncToken__ + __createCadesPluginObject__('CAdESCOM.About');
cspVersion = __cadesAsyncToken__ + cadesAbout.CSPVersion();
cspVersion = __cadesAsyncToken__ + cspVersion.toString();
} catch (error) {
console.error(error);
throw new Error(
_extractMeaningfulErrorMessage(error) ||
'Ошибка при получении версии системы',
);
}
return cspVersion;
}),
);
});