Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/BITP-10 - Special characters translate in certificate subject, add state in verification result #86

Merged
merged 5 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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));
}
};
Loading