Skip to content
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
114 changes: 11 additions & 103 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "kinode_lib"
authors = ["KinodeDAO"]
version = "0.8.4"
version = "0.8.5"
edition = "2021"
description = "A general-purpose sovereign cloud computing platform"
homepage = "https://kinode.org"
Expand Down
4 changes: 2 additions & 2 deletions kinode/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "kinode"
authors = ["KinodeDAO"]
version = "0.8.4"
version = "0.8.5"
edition = "2021"
description = "A general-purpose sovereign cloud computing platform"
homepage = "https://kinode.org"
Expand All @@ -14,7 +14,7 @@ path = "src/main.rs"

[build-dependencies]
anyhow = "1.0.71"
kit = { git = "https://github.com/kinode-dao/kit", rev = "4a8999f" }
kit = { git = "https://github.com/kinode-dao/kit", tag = "v0.6.8" }
tokio = "1.28"
walkdir = "2.4"
zip = "0.6"
Expand Down

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion kinode/src/register-ui/build/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<meta httpEquiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport"
content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1.00001, viewport-fit=cover" />
<script type="module" crossorigin src="/assets/index-BVotGXf3.js"></script>
<script type="module" crossorigin src="/assets/index-DS7Uobkv.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-B00cPdAQ.css">
</head>

Expand Down
85 changes: 12 additions & 73 deletions kinode/src/register-ui/src/pages/ImportKeyfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function ImportKeyfile({
nodeChainId,
}: ImportKeyfileProps) {

const [localKey, setLocalKey] = useState<string>("");
const [localKey, setLocalKey] = useState<Uint8Array | null>(null);
const [localKeyFileName, setLocalKeyFileName] = useState<string>("");
const [keyErrs, _setKeyErrs] = useState<string[]>([]);

Expand All @@ -35,84 +35,23 @@ function ImportKeyfile({
document.title = "Import Keyfile";
}, []);

// const handlePassword = useCallback(async () => {
// try {
// const response = await fetch(getFetchUrl("/vet-keyfile"), {
// method: "POST",
// credentials: 'include',
// headers: { "Content-Type": "application/json" },
// body: JSON.stringify({
// keyfile: localKey,
// password: pw,
// }),
// });

// const data = await response.json();

// setOsName(data.username);

// setPwVet(true);

// const errs = [...keyErrs];

// const ws = await kns.ws(namehash(data.username));

// let index = errs.indexOf(KEY_WRONG_NET_KEY);
// if (ws.publicKey !== data.networking_key) {
// if (index === -1) errs.push(KEY_WRONG_NET_KEY);
// } else if (index !== -1) errs.splice(index, 1);

// index = errs.indexOf(KEY_WRONG_IP);
// if(ws.ip === 0)
// setDirect(false)
// else {
// setDirect(true)
// if (ws.ip !== ipAddress && index === -1)
// errs.push(KEY_WRONG_IP);
// }

// setKeyErrs(errs);
// } catch {
// setPwVet(false);
// }
// setPwDebounced(true);
// }, [localKey, pw, keyErrs, ipAddress, kns, setOsName, setDirect]);

// const pwDebouncer = useRef<NodeJS.Timeout | null>(null);
// useEffect(() => {
// if (pwDebouncer.current) clearTimeout(pwDebouncer.current);

// pwDebouncer.current = setTimeout(async () => {
// if (pw !== "") {
// if (pw.length < 6)
// setPwErr("Password must be at least 6 characters")
// else {
// setPwErr("")
// handlePassword()
// }
// }
// }, 500)

// }, [pw])

// for if we check router validity in future
// const KEY_BAD_ROUTERS = "Routers from records are offline"

const handleKeyfile = useCallback((e: any) => {
const handleKeyfile = useCallback((e: React.ChangeEvent<HTMLInputElement>) => {
e.preventDefault();
const file = e.target.files[0];
const file = e.target.files?.[0];
if (!file) return;
const reader = new FileReader();
reader.onloadend = () => {
setLocalKey(reader.result as string);
setLocalKeyFileName(file.name);
if (reader.result instanceof ArrayBuffer) {
setLocalKey(new Uint8Array(reader.result));
setLocalKeyFileName(file.name);
}
};
reader.readAsText(file);
reader.readAsArrayBuffer(file);
}, []);

const keyfileInputRef = useRef<HTMLInputElement>(null);

const handleKeyUploadClick = useCallback(async (e: any) => {
const handleKeyUploadClick = useCallback(async (e: React.MouseEvent) => {
e.preventDefault();
e.stopPropagation();
keyfileInputRef.current?.click();
Expand All @@ -126,15 +65,15 @@ function ImportKeyfile({
setLoading(true);

try {
if (keyErrs.length === 0 && localKey !== "") {
if (keyErrs.length === 0 && localKey !== null) {
let hashed_password = utils.sha256(utils.toUtf8Bytes(pw));

const response = await fetch(getFetchUrl("/vet-keyfile"), {
method: "POST",
credentials: 'include',
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
keyfile: localKey,
keyfile: Buffer.from(localKey).toString('base64'),
password_hash: hashed_password,
}),
});
Expand All @@ -148,7 +87,7 @@ function ImportKeyfile({
credentials: 'include',
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
keyfile: localKey,
keyfile: Buffer.from(localKey).toString('base64'),
password_hash: hashed_password,
}),
});
Expand Down
Loading