From 937da83bb4a7e356a9ec43a7e48682a90816ebb5 Mon Sep 17 00:00:00 2001 From: Artem Vasilev Date: Thu, 23 Jun 2022 11:58:48 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D0=B8=D1=81=D0=BA=20=D1=81=D0=B5?= =?UTF-8?q?=D1=80=D1=82=D0=B8=D1=84=D0=B8=D0=BA=D0=B0=D1=82=D0=B0=20=D0=B2?= =?UTF-8?q?=20=D0=BE=D0=B1=D1=8A=D0=B5=D0=B4=D0=B5=D0=BD=D1=91=D0=BD=D0=BD?= =?UTF-8?q?=D0=BE=D0=BC=20=D1=81=D0=BF=D0=B8=D1=81=D0=BA=D0=B5=20=D1=81?= =?UTF-8?q?=D0=B5=D1=80=D1=82=D0=B8=D1=84=D0=B8=D0=BA=D0=B0=D1=82=D0=BE?= =?UTF-8?q?=D0=B2=20=D0=B8=D0=B7=20=D0=BB=D0=B8=D1=87=D0=BD=D0=BE=D0=B3?= =?UTF-8?q?=D0=BE=20=D1=85=D1=80=D0=B0=D0=BD=D0=B8=D0=BB=D0=B8=D1=89=D0=B0?= =?UTF-8?q?=20=D0=B8=20=D0=B8=D0=B7=20=D0=B7=D0=B0=D0=BA=D1=80=D1=8B=D1=82?= =?UTF-8?q?=D0=BE=D0=B3=D0=BE=20=D0=BA=D0=BB=D1=8E=D1=87=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/getCertificate.ts | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/api/getCertificate.ts b/src/api/getCertificate.ts index 329604a..543a381 100644 --- a/src/api/getCertificate.ts +++ b/src/api/getCertificate.ts @@ -1,20 +1,29 @@ -import { Certificate } from './certificate'; -import { _afterPluginsLoaded } from '../helpers/_afterPluginsLoaded'; -import { getUserCertificates } from './getUserCertificates'; +import {Certificate} from './certificate'; +import {_afterPluginsLoaded} from '../helpers/_afterPluginsLoaded'; +import {getCertificates} from "./getCertificates"; +import {getAllCertificates} from "./getAllCertificates"; /** * Возвращает сертификат по отпечатку * * @param thumbprint - отпечаток сертификата + * @param validOnly - проверять сертификаты по дате и наличию приватного ключа * @returns сертификат */ export const getCertificate = _afterPluginsLoaded( - async (thumbprint: string): Promise => { + async (thumbprint: string, validOnly: boolean = true): Promise => { if (!thumbprint) { throw new Error('Отпечаток не указан'); } - const availableCertificates: Certificate[] = await getUserCertificates(); + let availableCertificates: Certificate[]; + + if (validOnly) { + availableCertificates = await getCertificates(); + } else { + availableCertificates = await getAllCertificates(); + } + const foundCertificate: Certificate = availableCertificates.find((cert) => cert.thumbprint === thumbprint); if (!foundCertificate) {