crypto-pro-js/src/api/certificate/getDecodedExtendedKeyUsage.ts
2020-03-28 21:11:00 +03:00

25 lines
773 B
TypeScript

import { OIDS_DICTIONARY } from '../../constants';
import { _afterPluginsLoaded } from '../../helpers/_afterPluginsLoaded';
import { Certificate } from './certificate';
export interface ExtendedKeysTranslations {
[key: string]: string | null;
}
/**
* Возвращает расшифрованные ОИД'ы сертификата
*
* @returns словарь расшифрованных ОИД'ов
*/
export const getDecodedExtendedKeyUsage = _afterPluginsLoaded(async function (): Promise<ExtendedKeysTranslations> {
const certificateOids = await (this as Certificate).getExtendedKeyUsage();
return certificateOids.reduce(
(decodedOids, oidCode) => ({
...decodedOids,
[oidCode]: OIDS_DICTIONARY[oidCode] || null,
}),
{},
);
});