Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-bes committed Nov 30, 2023
1 parent 5c05a9f commit 361fbbb
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"date-fns": "^2.22.1",
"file-saver": "^2.0.5",
"html-react-parser": "^1.2.8",
"jose": "^5.1.2",
"jsoneditor": "^9.10.4",
"prettier": "^2.3.1",
"prop-types": "^15.7.2",
Expand Down
19 changes: 17 additions & 2 deletions src/components/Main.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
import React, { useEffect, useState } from "react";

import * as jose from "jose";
import { IPSResult } from "./IPSResult";
import { IPSForm } from "./IPSForm";
import { useIPS } from "../api/useIPS";
import { LoadingIndicator } from "./LoadingIndicator";

async function decryptData(key, encryptedData) {
const decrypter = await jose.JWE.createDecrypt(key);
const decrypted = await decrypter.decrypt(encryptedData);

console.log("decrypted", decrypted);
return decrypted;
}

export const Main = () => {
const [hasPayloadError, setHasPayloadError] = useState(false);
const [validated, setValidated] = useState(false);
const [payload, setPayload] = useState(null);

const hash = window.location.hash;
const payloadBase64 = hash.replace('#shlink:/', '');
const payloadBase64 = hash.replace("#shlink:/", "");

const {
data: ipsPayload,
Expand All @@ -32,6 +40,13 @@ export const Main = () => {
}
}, [payloadBase64]);

useEffect(() => {
if (ipsPayload) {
console.log('payload', payload);
decryptData(payload.key, ipsPayload);
}
}, [ipsPayload]);

if (isLoading) {
return <LoadingIndicator />;
}
Expand Down
12 changes: 5 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2335,13 +2335,6 @@
react-is "^16.8.0 || ^17.0.0"
react-transition-group "^4.4.0"

"@material-ui/icons@^4.11.2":
version "4.11.3"
resolved "https://registry.yarnpkg.com/@material-ui/icons/-/icons-4.11.3.tgz#b0693709f9b161ce9ccde276a770d968484ecff1"
integrity sha512-IKHlyx6LDh8n19vzwH5RtHIOHl9Tu90aAAxcbWME6kp4dmvODM3UvOHJeMIDzUbd4muuJKHmlNoBN+mDY4XkBA==
dependencies:
"@babel/runtime" "^7.4.4"

"@material-ui/lab@^4.0.0-alpha.56":
version "4.0.0-alpha.61"
resolved "https://registry.yarnpkg.com/@material-ui/lab/-/lab-4.0.0-alpha.61.tgz#9bf8eb389c0c26c15e40933cc114d4ad85e3d978"
Expand Down Expand Up @@ -7466,6 +7459,11 @@ jmespath@^0.16.0:
resolved "https://registry.yarnpkg.com/jmespath/-/jmespath-0.16.0.tgz#b15b0a85dfd4d930d43e69ed605943c802785076"
integrity sha512-9FzQjJ7MATs1tSpnco1K6ayiYE3figslrXA72G2HQ/n76RzvYlofyi5QM+iX4YRs/pu3yzxlVQSST23+dMDknw==

jose@^5.1.2:
version "5.1.2"
resolved "https://registry.yarnpkg.com/jose/-/jose-5.1.2.tgz#f71a18e3ee779c2d81778e1b6f0d85062ccd9ee1"
integrity sha512-X7TOC/d8KPvx4wPUuLHVgTSdoWw0UW5TQOUwhvCvj+ZPfsf9vUPhhksYPjNBWVGPQ/6yd/JrL1gQxBnIDwYdFg==

[email protected]:
version "0.8.0"
resolved "https://registry.yarnpkg.com/js-sha3/-/js-sha3-0.8.0.tgz#b9b7a5da73afad7dedd0f8c463954cbde6818840"
Expand Down

0 comments on commit 361fbbb

Please sign in to comment.