Skip to content

Commit

Permalink
jwt
Browse files Browse the repository at this point in the history
  • Loading branch information
pashaie committed Jan 23, 2023
1 parent fbf7d60 commit 3a7ee88
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 2 deletions.
10 changes: 8 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"antd": "^5.1.4",
"generate-password-browser": "^1.1.0",
"hardpass": "^0.1.4",
"jwt-decode": "^3.1.2",
"localforage": "^1.10.0",
"match-sorter": "^6.3.1",
"react": "^18.2.0",
Expand Down
6 changes: 6 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
HomeOutlined,
GithubOutlined,
GlobalOutlined,
StarOutlined,
} from "@ant-design/icons";
import { Button, Layout, Menu, theme } from "antd";
import { Outlet, useNavigate } from "react-router-dom";
Expand Down Expand Up @@ -76,6 +77,11 @@ const App: React.FC = () => {
icon: <GlobalOutlined />,
label: "National Code",
},
{
key: "jwt",
icon: <StarOutlined />,
label: "JWT",
},
]}
/>
</Sider>
Expand Down
39 changes: 39 additions & 0 deletions src/JWT.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { Row, Col, Divider, QRCode } from "antd";
import TextArea from "antd/es/input/TextArea";
import React, { useEffect, useState } from "react";
import jwt_decode from "jwt-decode";

export default function JWT() {
const [token, setToken] = useState("");
const [data, setData] = useState("");
useEffect(() => {
try {
const header = jwt_decode(token, { header: true });
const payload = jwt_decode(token);
setData(
`${JSON.stringify(header, null, 2)} \n ${JSON.stringify(
payload,
null,
2
)}`
);
} catch (e) {
console.log(e);
}
}, [token]);
return (
<div>
<Row justify="center">
<Col xs={{ span: 24 }} md={{ span: 18, offset: 3 }}>
<TextArea
placeholder="text or url"
value={token}
onChange={(e) => setToken(e.target.value)}
/>
<Divider>JWT Data</Divider>
<code>{data}</code>
</Col>
</Row>
</div>
);
}
5 changes: 5 additions & 0 deletions src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import App from "./App";
import Base64 from "./Base64";
import Home from "./Home";
import "./index.css";
import JWT from "./JWT";
import NationalCode from "./NationalCode";
import Pashword from "./Pashword";
import Password from "./Password";
Expand Down Expand Up @@ -39,6 +40,10 @@ const router = createBrowserRouter([
path: "nationalCode",
element: <NationalCode></NationalCode>,
},
{
path: "jwt",
element: <JWT />,
},
],
},
]);
Expand Down

0 comments on commit 3a7ee88

Please sign in to comment.