Merge branch 'v0.10.0' into bp/reset

This commit is contained in:
dr-frmr 2024-12-19 13:49:06 -05:00
commit 46631dedfb
No known key found for this signature in database
5 changed files with 88 additions and 4 deletions

View File

@ -156,6 +156,9 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/argon2-browser/1.18.0/argon2-bundled.min.js"
integrity="sha512-Alrh8vbmKDc5xiq7I/y8LTDwy9nw1nT9S/yR73HMMoWrpX4S1kizNPdWM896c/CDIGILNwAiaih627A94kRhYQ=="
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<!-- REMOVE IN 1.0.0 -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.2.0/crypto-js.min.js"></script>
<!--------------------->
<script>
let isInitialized = false;
@ -207,6 +210,24 @@
if (result.status == 200) {
window.location.reload();
} else {
// REMOVE IN 1.0.0
const hashHex = '0x' + CryptoJS.SHA256(password).toString(CryptoJS.enc.Hex);
const result = await fetch("/login", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
password_hash: hashHex,
subdomain: isSecureSubdomain ? firstPathItem : '',
}),
});
if (result.status == 200) {
window.location.reload();
} else {
throw new Error("Login failed");
}
// END REMOVE IN 1.0.0
throw new Error("Login failed");
}
}).catch(err => {

View File

@ -874,8 +874,20 @@ async fn login_with_password(
let password_hash_hex = format!("0x{}", password_hash);
let k = keygen::decode_keyfile(&disk_keyfile, &password_hash_hex)
.expect("could not decode keyfile, password incorrect");
// SWITCH BACK TO THIS IN 1.0.0
// let k = keygen::decode_keyfile(&disk_keyfile, &password_hash_hex)
// .expect("could not decode keyfile, password incorrect");
// REMOVE IN 1.0.0
let k = match keygen::decode_keyfile(&disk_keyfile, &password_hash_hex) {
Ok(k) => k,
Err(_) => {
use sha2::{Digest, Sha256};
let password_hash = format!("0x{}", hex::encode(Sha256::digest(password)));
keygen::decode_keyfile(&disk_keyfile, &password_hash)
.expect("could not decode keyfile, password incorrect")
}
};
let mut our = Identity {
name: k.username.clone(),

View File

@ -7,6 +7,8 @@ import {
import { PageProps } from "../lib/types";
import Loader from "../components/Loader";
import { redirectToHomepage } from "../utils/redirect-to-homepage";
// REMOVE IN 1.0.0
import { sha256, toBytes } from "viem";
interface ImportKeyfileProps extends PageProps { }
@ -69,7 +71,28 @@ function ImportKeyfile({
});
if (result.status > 399) {
throw new Error(await result.text());
// REMOVE IN 1.0.0
let hashed_password = sha256(toBytes(pw));
const result = await fetch("/import-keyfile", {
method: "POST",
credentials: 'include',
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
keyfile: Buffer.from(localKey).toString('utf8'),
password_hash: hashed_password,
}),
});
if (result.status > 399) {
throw new Error("Incorrect password");
} else {
redirectToHomepage();
}
// END REMOVE IN 1.0.0
// BRING BACK IN 1.0.0
// throw new Error(await result.text());
}
redirectToHomepage();
}).catch(err => {

View File

@ -4,6 +4,8 @@ import Loader from "../components/Loader";
import { useNavigate } from "react-router-dom";
import { Tooltip } from "../components/Tooltip";
import { redirectToHomepage } from "../utils/redirect-to-homepage";
// REMOVE IN 1.0.0
import { sha256, toBytes } from "viem";
interface LoginProps extends PageProps { }
@ -54,7 +56,27 @@ function Login({
);
if (result.status > 399) {
throw new Error(await result.text());
// REMOVE IN 1.0.0
let hashed_password = sha256(toBytes(pw));
const result = await fetch(
"/login",
{
method: "POST",
credentials: 'include',
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ password_hash: hashed_password }),
}
);
if (result.status > 399) {
throw new Error(await result.text());
} else {
redirectToHomepage();
}
// END REMOVE IN 1.0.0
// BRING BACK IN 1.0.0
// throw new Error(await result.text());
}
redirectToHomepage();
}).catch(err => {

6
package-lock.json generated Normal file
View File

@ -0,0 +1,6 @@
{
"name": "kinode",
"lockfileVersion": 2,
"requires": true,
"packages": {}
}