From 7bcd5bb118fb682eff81f4cc75f472f30f5dfa4c Mon Sep 17 00:00:00 2001 From: Oleksandr Slobodian <129727832+OleksandrSPV@users.noreply.github.com> Date: Thu, 10 Oct 2024 12:25:20 +0300 Subject: [PATCH 1/2] Update fortify webcomponents (#218) Co-authored-by: alex-slobodian --- package.json | 2 +- .../CertificatesList.stories.tsx | 5 ++-- yarn.lock | 28 +++++++++---------- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/package.json b/package.json index b3a851ee..46d4d21f 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ }, "dependencies": { "@peculiar/certificates-viewer-react": "^4.3.1", - "@peculiar/fortify-webcomponents-react": "^4.0.8", + "@peculiar/fortify-webcomponents-react": "^4.0.9", "@peculiar/react-components": "^0.6.7", "@peculiar/x509": "^1.12.3", "clsx": "^2.1.1", diff --git a/src/components/certificates-list/CertificatesList.stories.tsx b/src/components/certificates-list/CertificatesList.stories.tsx index 2ca02887..2d039cb1 100644 --- a/src/components/certificates-list/CertificatesList.stories.tsx +++ b/src/components/certificates-list/CertificatesList.stories.tsx @@ -1,6 +1,7 @@ import type { Meta, StoryObj } from "@storybook/react"; import { CertificatesList } from "./CertificatesList"; import { faker } from "@faker-js/faker"; +import { CertificateProps } from "../../types"; const meta: Meta = { title: "Components/CertificatesList", @@ -27,9 +28,9 @@ export const Default: Story = { label: faker.internet.domainName(), privateKeyId: "", subject: { - commonName: "", + CN: faker.internet.domainName(), }, - })), + })) as unknown as CertificateProps[], }, }; diff --git a/yarn.lock b/yarn.lock index 411e226e..4f501575 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1003,10 +1003,10 @@ resolved "https://registry.npmjs.org/@peculiar/color/-/color-0.1.3.tgz" integrity sha512-ndvAb80Ej1kz4chPngOoSJcbaqZTJRacAs/M7k57raqVkUx/dlMwYflHGgQGVtkfAMAVkjE9TWVMqbjjtxbnhg== -"@peculiar/fortify-client-core@^4.0.8": - version "4.0.8" - resolved "https://registry.npmjs.org/@peculiar/fortify-client-core/-/fortify-client-core-4.0.8.tgz" - integrity sha512-KjswgC50KUbvXraKYO9qnMGjTwM+C44Y2GelquWilZMvrsXiWG8vv7OqWYGtgLPgYuhbxwPM5f4x92HKt3eCUQ== +"@peculiar/fortify-client-core@^4.0.9": + version "4.0.9" + resolved "https://registry.yarnpkg.com/@peculiar/fortify-client-core/-/fortify-client-core-4.0.9.tgz#6aeecb75132962235af0dc09768d666deb17dd8f" + integrity sha512-yZCMKEQHT6xScYeHaoRFaRZCZAeThuxxX6aZfGd2TIaTV/8vH0tQp1smnCisSqE34bFkN5DvUPMvm4hLg2TvjA== dependencies: "@peculiar/asn1-schema" "^2.3.8" "@peculiar/asn1-x509" "^2.3.8" @@ -1018,21 +1018,21 @@ pvtsutils "^1.3.5" tslib "^2.4.0" -"@peculiar/fortify-webcomponents-react@^4.0.8": - version "4.0.8" - resolved "https://registry.npmjs.org/@peculiar/fortify-webcomponents-react/-/fortify-webcomponents-react-4.0.8.tgz" - integrity sha512-kJ14fdQWNqF1Ps30H3b4SuHlZXf/rWSMm0F4uVFxPKQG7lfJt/RDPJdAd06sEX+TpSqunrQZGlGudj//fFNmqA== +"@peculiar/fortify-webcomponents-react@^4.0.9": + version "4.0.9" + resolved "https://registry.yarnpkg.com/@peculiar/fortify-webcomponents-react/-/fortify-webcomponents-react-4.0.9.tgz#ae96522d541effff4f542122615d16de65d6a38d" + integrity sha512-RNfVbxOa0nfYJuTZpdVwTNn6zBjHXwK7lbiNmrfkrfft1hS2T3v0WWfE7Xvbv3W9SUcAbGYG6Yy1yTztZmOwtg== dependencies: - "@peculiar/fortify-webcomponents" "^4.0.8" + "@peculiar/fortify-webcomponents" "^4.0.9" tslib "^2.4.0" -"@peculiar/fortify-webcomponents@^4.0.8": - version "4.0.8" - resolved "https://registry.npmjs.org/@peculiar/fortify-webcomponents/-/fortify-webcomponents-4.0.8.tgz" - integrity sha512-Q/j8oDqgyVatFTUV4/V49NGh7RJ7N2DYXuPLtIYACi6rLU3r7i9JGyLHXIwCvNdemACNmbY7RgCSj0wT0ZF4Yw== +"@peculiar/fortify-webcomponents@^4.0.9": + version "4.0.9" + resolved "https://registry.yarnpkg.com/@peculiar/fortify-webcomponents/-/fortify-webcomponents-4.0.9.tgz#68c5a70c6f6d6daa780b0740f6973af6b5b3685b" + integrity sha512-jxmBFY9hoU5XlBfxy5jrx+hcHSxxuuUI8N03TuRBvnB+oSV6w02QHKb30i/eK3YCprwh1RnwjY1oQwf2I1Lr1w== dependencies: "@peculiar/certificates-viewer" "^4.2.0" - "@peculiar/fortify-client-core" "^4.0.8" + "@peculiar/fortify-client-core" "^4.0.9" "@stencil/core" "^4.3.0" pvtsutils "^1.3.5" From 4a7c3fde381890acfa5531382b2e7b1eddc389c2 Mon Sep 17 00:00:00 2001 From: Oleksandr Slobodian <129727832+OleksandrSPV@users.noreply.github.com> Date: Fri, 11 Oct 2024 11:48:36 +0300 Subject: [PATCH 2/2] Fix certificate name (#219) * Fix certificate name * Fix type * Fix certificate name --------- Co-authored-by: alex-slobodian --- src/utils/certificate.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/utils/certificate.ts b/src/utils/certificate.ts index dcb3f4d9..b88e0093 100644 --- a/src/utils/certificate.ts +++ b/src/utils/certificate.ts @@ -39,22 +39,25 @@ export function certificateSubjectToString( } export function getCertificateName(certificate: CertificateProps) { - const { G, CN, SN, E } = - certificate.subject as unknown as CertificateSubjectProps; + if (!certificate.subject) { + return certificate.subjectName; + } + + const { G, CN, SN, E } = certificate.subject; // Return Common Name if present. if (CN) { - return CN; + return CN[0]; } // Return Given Name + Surname if both present. if (G && SN) { - return `${G} ${SN}`; + return `${G[0]} ${SN[0]}`; } // Return Email if none of the above present if (E) { - return E; + return E[0]; } return certificate.subjectName;