Skip to content

Commit

Permalink
Fix/BITP-10 - Special characters translate in certificate subject, ad…
Browse files Browse the repository at this point in the history
…d state in verification result (#86)

* package json fix pdf issue

* add special character translation in certificate subject, fix secret label translation, add state in certificate subject
  • Loading branch information
mireiaGomariz authored Aug 30, 2024
1 parent bb71e17 commit 5f739a0
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 18 deletions.
13 changes: 11 additions & 2 deletions src/components/DirectoryPreview.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { Card, List } from "antd";
import { Button, Card, List } from "antd";
import Wrapper from "./Wrapper";
import { useVerification } from "../providers/VerificationProvider";
import { useTranslation } from "react-i18next";
import { IPFSCid } from "../models/ReadDirectory";
import { ArrowRightCircle } from "iconoir-react";
import { Icon } from "react-extension-icons";
import { CloseOutlined } from "@ant-design/icons";

function DirectoryPreview() {
const { t } = useTranslation();

const { directoryResponse, onInputChange, isLoading, error } =
const { directoryResponse, onInputChange, isLoading, error, reset } =
useVerification();

return (
Expand All @@ -23,6 +24,14 @@ function DirectoryPreview() {
backgroundColor: "rgba(255, 255, 255, 0.9)",
}}
bordered={false}
extra={
<Button
type="text"
shape="circle"
icon={<CloseOutlined />}
onClick={() => reset()}
/>
}
>
<h2 className="text-center mb-4">{t("directory.title")}</h2>
<List loading={isLoading}>
Expand Down
31 changes: 16 additions & 15 deletions src/components/Results.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { PropsWithChildren } from "react";
import { useTranslation } from "react-i18next";
import { useVerification } from "../providers/VerificationProvider";
import {
decodeString,
formatBytes,
getNetworkTranslation,
getTxHashURL,
Expand Down Expand Up @@ -257,7 +258,7 @@ function Results() {
<>
<Divider />
<Field label={t("results.authenticity.common-name")}>
{signature.subject?.CN}
{decodeString(signature.subject?.CN)}
</Field>
</>
)}
Expand All @@ -267,39 +268,39 @@ function Results() {
<Field
label={t("results.authenticity.organization-unit")}
>
{signature.subject?.OU}
{decodeString(signature.subject?.OU)}
</Field>
</>
)}
{signature.subject?.O && (
<>
<Divider />
<Field label={t("results.authenticity.organization")}>
{signature.subject?.O}
{decodeString(signature.subject?.O)}
</Field>
</>
)}
{signature.subject?.L && (
<>
<Divider />
<Field label={t("results.authenticity.location")}>
{signature.subject?.L}
{decodeString(signature.subject?.L)}
</Field>
</>
)}
{signature.subject?.S && (
{signature.subject?.ST && (
<>
<Divider />
<Field label={t("results.authenticity.state")}>
{signature.subject?.S}
{decodeString(signature.subject?.ST)}
</Field>
</>
)}
{signature.subject?.C && (
<>
<Divider />
<Field label={t("results.authenticity.country")}>
{signature.subject?.C}
{decodeString(signature.subject?.C)}
</Field>
</>
)}
Expand Down Expand Up @@ -339,47 +340,47 @@ function Results() {
<>
<Divider />
<Field label={t("results.encryption.common-name")}>
{encryptionDetails.subject?.CN}
{decodeString(encryptionDetails.subject?.CN)}
</Field>
</>
)}
{encryptionDetails?.subject?.OU && (
<>
<Divider />
<Field label={t("results.encryption.organization-unit")}>
{encryptionDetails.subject?.OU}
{decodeString(encryptionDetails.subject?.OU)}
</Field>
</>
)}
{encryptionDetails?.subject?.O && (
<>
<Divider />
<Field label={t("results.encryption.organization")}>
{encryptionDetails.subject?.O}
{decodeString(encryptionDetails.subject?.O)}
</Field>
</>
)}
{encryptionDetails?.subject?.L && (
<>
<Divider />
<Field label={t("results.encryption.location")}>
{encryptionDetails.subject?.L}
{decodeString(encryptionDetails.subject?.L)}
</Field>
</>
)}
{encryptionDetails?.subject?.S && (
{encryptionDetails?.subject?.ST && (
<>
<Divider />
<Field label={t("results.encryption.state")}>
{encryptionDetails.subject?.S}
{decodeString(encryptionDetails.subject?.ST)}
</Field>
</>
)}
{encryptionDetails?.subject?.C && (
<>
<Divider />
<Field label={t("results.encryption.country")}>
{encryptionDetails.subject?.C}
{decodeString(encryptionDetails.subject?.C)}
</Field>
</>
)}
Expand Down Expand Up @@ -552,7 +553,7 @@ function Results() {
<br />
<p className="font-bold">{t("results.general.issuer")}</p>
<p className="text-gray-500 text-sm">
{authenticityDetails?.subject?.CN ||
{decodeString(authenticityDetails?.subject?.CN) ||
t("results.not-available")}
</p>
<br />
Expand Down
3 changes: 2 additions & 1 deletion src/i18n/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"label": "Código"
},
"secret": {
"description": "This key has Secret access control enabled. In order to use it, add the secret below.",
"description": "Esta clave tiene control de acceso habilitado para Secreto. Para usarla, añade el secreto a continuación.",
"label": "Secreto"
}
},
Expand Down Expand Up @@ -124,6 +124,7 @@
"bloock_chain": "Bloock Chain",
"ethereum_goerli": "",
"ethereum_mainnet": "Ethereum",
"ethereum_sepolia": "Ethereum Sepolia",
"gnosis_chain": "Gnosis",
"label": "Redes",
"polygon_chain": "Polygon",
Expand Down
6 changes: 6 additions & 0 deletions src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,9 @@ export function readBlob(file: Blob): Promise<Uint8Array> {
reader.readAsArrayBuffer(file);
});
}

export const decodeString = (encodedStr?: string) => {
if (encodedStr) {
return decodeURIComponent(escape(encodedStr));
}
};

0 comments on commit 5f739a0

Please sign in to comment.