error handling and sanitizing of string input for mnemonic and TextCode

pull/32/head
Niko PLP 4 months ago
parent a36af315fe
commit 3fb85ea8c7
  1. 2
      nextgraph/src/local_broker.rs
  2. 6
      ng-app/src/api.ts
  3. 2
      ng-app/src/lib/Login.svelte
  4. 2
      ng-app/src/locales/en.json
  5. 4
      ng-app/src/routes/WalletLoginTextCode.svelte

@ -1728,7 +1728,7 @@ lazy_static! {
/// with the help of the function [wallet_open_with_pazzle_words]
/// followed by [wallet_import]
pub async fn wallet_import_from_code(code: String) -> Result<Wallet, NgError> {
let qr = NgQRCode::from_code(code)?;
let qr = NgQRCode::from_code(code.trim().to_string())?;
match qr {
NgQRCode::WalletTransferV0(NgQRCodeWalletTransferV0 {
broker,

@ -215,11 +215,13 @@ const handler = {
return await tauri.invoke(path[0],arg)
}
}catch (e) {
let error;
try {
throw JSON.parse(e);
error = JSON.parse(e);
} catch (f) {
throw e;
error = e;
}
throw error;
}
}
},

@ -169,7 +169,7 @@
pazzle.push((emoji.cat << 4) + emoji.index);
}
const mnemonic_words = mnemonic.split(" ");
const mnemonic_words = mnemonic.split(" ").filter((t) => t !== "");
// open the wallet
try {

@ -297,7 +297,7 @@
"AlreadyExists": "The user is already registered with the selected broker.<br />Try logging in instead.",
"InvalidSignature": "The signature is invalid.",
"IncompleteSignature": "The signature is incomplete.",
"SerializationError": "The object could not be serialized.",
"SerializationError": "The data could not be serialized.",
"EncryptionError": "Your wallet could not be opened. You probably did a mistake.",
"DecryptionError": "Error with decryption.",
"InvalidValue": "The value is invalid.",

@ -99,7 +99,7 @@
<!-- Submit Button-->
<div class="my-4 mx-1">
<button
class="mt-4 w-full text-white bg-primary-700 disabled:bg-primary-700/50 hover:bg-primary-700/90 focus:ring-4 focus:ring-primary-100/50 rounded-lg text-lg px-5 py-2.5 text-center inline-flex items-center dark:focus:ring-primary-700/55"
class="mt-4 mb-8 w-full text-white bg-primary-700 disabled:bg-primary-700/50 hover:bg-primary-700/90 focus:ring-4 focus:ring-primary-100/50 rounded-lg text-lg px-5 py-2.5 text-center inline-flex items-center dark:focus:ring-primary-700/55"
on:click={textcode_submit}
disabled={!connected || !textcode}
class:hidden={state === "importing" || error}
@ -114,7 +114,7 @@
<!-- Back Button -->
<button
on:click={() => window.history.go(-1)}
class="mt-8 w-full text-gray-500 dark:text-gray-400 focus:ring-4 focus:ring-primary-100/50 rounded-lg text-lg px-5 py-2.5 text-center inline-flex items-center dark:focus:ring-primary-700/55"
class="w-full text-gray-500 dark:text-gray-400 focus:ring-4 focus:ring-primary-100/50 rounded-lg text-lg px-5 py-2.5 text-center inline-flex items-center dark:focus:ring-primary-700/55"
><ArrowLeft
tabindex="-1"
class="w-8 h-8 mr-2 -ml-1 transition duration-75 focus:outline-none group-hover:text-gray-900 dark:group-hover:text-white"

Loading…
Cancel
Save