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

23 lines
771 B
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 { Certificate } from './certificate';
/**
* Проверяет наличие ОИД'а (ОИД'ов) у сертификата
*
* @param oids - ОИД'ы для проверки
* @returns флаг наличия ОИД'ов у сертификата
*/
export const hasExtendedKeyUsage = _afterPluginsLoaded(async function (oids: string | string[]): Promise<boolean> {
const certOids = await (this as Certificate).getExtendedKeyUsage();
let result: boolean;
if (Array.isArray(oids)) {
result = oids.every((oidToCheck) => certOids.some((certOid) => certOid === oidToCheck));
} else {
result = certOids.some((certOid) => certOid === oids);
}
return result;
});