Skip to content

Commit 2f18f56

Browse files
committed
Added ability to save, close and open vaults
1 parent bedc127 commit 2f18f56

File tree

18 files changed

+356
-235
lines changed

18 files changed

+356
-235
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,4 @@ This library is maintained by CodeDead. You can find more about us using the fol
9797
* [Twitter](https://twitter.com/C0DEDEAD/)
9898
* [Facebook](https://facebook.com/deadlinecodedead/)
9999

100-
Copyright © 2022 CodeDead
100+
Copyright © 2023 CodeDead

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77
"@emotion/styled": "^11.10.5",
88
"@fontsource/roboto": "^4.5.8",
99
"@mui/icons-material": "^5.11.0",
10-
"@mui/material": "^5.11.1",
10+
"@mui/material": "^5.11.2",
1111
"@shopify/react-web-worker": "^5.0.6",
1212
"@tauri-apps/api": "^1.2.0",
1313
"@testing-library/jest-dom": "^5.16.5",
1414
"@testing-library/react": "^13.4.0",
1515
"@testing-library/user-event": "^14.4.3",
16+
"crypto-js": "^4.1.1",
1617
"react": "^18.2.0",
1718
"react-dom": "^18.2.0",
1819
"react-router-dom": "^6.6.1",
@@ -50,7 +51,7 @@
5051
"devDependencies": {
5152
"@tauri-apps/cli": "^1.2.2",
5253
"cross-env": "^7.0.3",
53-
"eslint": "^8.30.0",
54+
"eslint": "^8.31.0",
5455
"eslint-config-airbnb": "^19.0.4",
5556
"eslint-plugin-import": "^2.26.0",
5657
"eslint-plugin-jsx-a11y": "^6.6.1",

src-tauri/Cargo.lock

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ license = "GPL-3.0-only"
77
repository = "https://github.com/CodeDead/Advanced-PassGen"
88
default-run = "advanced-passgen"
99
edition = "2021"
10-
rust-version = "1.65.0"
10+
rust-version = "1.66.0"
1111

1212
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1313

1414
[build-dependencies]
15-
tauri-build = { version = "1.1.1", features = [] }
15+
tauri-build = { version = "1.2.1", features = [] }
1616

1717
[dependencies]
1818
serde_json = "1.0"

src-tauri/src/main.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ fn main() {
1212
.invoke_handler(tauri::generate_handler![
1313
open_website,
1414
save_string_to_disk,
15+
read_string_from_file,
1516
generate_passwords
1617
])
1718
.run(tauri::generate_context!())
@@ -34,6 +35,14 @@ fn save_string_to_disk(content: &str, path: &str) -> Result<String, String> {
3435
}
3536
}
3637

38+
#[tauri::command]
39+
async fn read_string_from_file(path: &str) -> Result<String, String> {
40+
match fs::read_to_string(path) {
41+
Ok(s) => Ok(s),
42+
Err(e) => Err(e.to_string()),
43+
}
44+
}
45+
3746
#[tauri::command]
3847
async fn generate_passwords(
3948
min_length: u64,

src-tauri/tauri.conf.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@
1313
"tauri": {
1414
"allowlist": {
1515
"dialog": {
16-
"save": true
16+
"save": true,
17+
"open": true
18+
},
19+
"clipboard": {
20+
"writeText": true
1721
},
1822
"all": true
1923
},

src/components/CreateVaultDialog/index.jsx renamed to src/components/EncryptionKeyDialog/index.jsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import DialogActions from '@mui/material/DialogActions';
77
import Button from '@mui/material/Button';
88
import { MainContext } from '../../contexts/MainContextProvider';
99

10-
const CreateVaultDialog = ({ open, onCreate, onClose }) => {
10+
const EncryptionKeyDialog = ({ open, onAccept, onClose }) => {
1111
const [state] = useContext(MainContext);
1212
const language = state.languages[state.languageIndex];
1313

@@ -24,14 +24,14 @@ const CreateVaultDialog = ({ open, onCreate, onClose }) => {
2424
};
2525

2626
/**
27-
* Create a new vault
27+
* Accept the encryption/decryption key
2828
*/
29-
const create = () => {
29+
const accept = () => {
3030
if (key.length === 0) {
3131
return;
3232
}
33-
if (onCreate) {
34-
onCreate(key);
33+
if (onAccept) {
34+
onAccept(key);
3535
}
3636
handleClose();
3737
};
@@ -43,7 +43,7 @@ const CreateVaultDialog = ({ open, onCreate, onClose }) => {
4343
aria-labelledby="create-vault-dialog-title"
4444
>
4545
<DialogTitle id="create-vault-dialog-title">
46-
{language.createVault}
46+
{language.decryptionKey}
4747
</DialogTitle>
4848
<DialogContent>
4949
<TextField
@@ -63,7 +63,7 @@ const CreateVaultDialog = ({ open, onCreate, onClose }) => {
6363
{language.cancel}
6464
</Button>
6565
<Button
66-
onClick={create}
66+
onClick={accept}
6767
autoFocus
6868
disabled={key.length === 0}
6969
>
@@ -74,4 +74,4 @@ const CreateVaultDialog = ({ open, onCreate, onClose }) => {
7474
);
7575
};
7676

77-
export default CreateVaultDialog;
77+
export default EncryptionKeyDialog;

src/components/VaultCard/index.jsx

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ import CardContent from '@mui/material/CardContent';
44
import CardActions from '@mui/material/CardActions';
55
import Button from '@mui/material/Button';
66
import Typography from '@mui/material/Typography';
7+
import CardActionArea from '@mui/material/CardActionArea';
78

89
const VaultCard = ({
9-
id, title, description, url, openLabel, editLabel,
10-
deleteLabel, onClick, onEdit, onDelete,
10+
id, title, description, url, openLabel, editLabel, copyLabel,
11+
deleteLabel, onClick, onEdit, onDelete, onCopy,
1112
}) => {
1213
/**
1314
* Open the URL
@@ -30,18 +31,29 @@ const VaultCard = ({
3031
onDelete(id);
3132
};
3233

34+
/**
35+
* Copy the password to the clipboard
36+
*/
37+
const copy = () => {
38+
onCopy(id);
39+
};
40+
3341
return (
3442
<Card>
35-
<CardContent>
36-
<Typography variant="h5" component="div">
37-
{title}
38-
</Typography>
39-
{description && description.length > 0 ? (
40-
<Typography variant="body2">
41-
{description}
43+
<CardActionArea
44+
onClick={copy}
45+
>
46+
<CardContent>
47+
<Typography variant="h5" component="div">
48+
{title}
4249
</Typography>
43-
) : null}
44-
</CardContent>
50+
{description && description.length > 0 ? (
51+
<Typography variant="body2">
52+
{description}
53+
</Typography>
54+
) : null}
55+
</CardContent>
56+
</CardActionArea>
4557
<CardActions>
4658
{url && onClick ? (
4759
<Button
@@ -51,6 +63,12 @@ const VaultCard = ({
5163
{openLabel}
5264
</Button>
5365
) : null}
66+
<Button
67+
size="small"
68+
onClick={copy}
69+
>
70+
{copyLabel}
71+
</Button>
5472
{onEdit ? (
5573
<Button
5674
size="small"

src/languages/de_de.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"characterSet": "Zeichensatz",
2020
"generate": "Generieren",
2121
"useCustomCharacterSet": "Benutzerdefinierten Zeichensatz verwenden",
22-
"aboutText": "Advanced PassGen wurde von DeadLine erstellt.\n\nThema: MUI\nLizenz: GPLv3\nÜbersetzung: uDEV2019\nVersion: {x}\n\nCopyright © 2022 CodeDead",
22+
"aboutText": "Advanced PassGen wurde von DeadLine erstellt.\n\nThema: MUI\nLizenz: GPLv3\nÜbersetzung: uDEV2019\nVersion: {x}\n\nCopyright © 2023 CodeDead",
2323
"website": "Webseite",
2424
"license": "Lizenz",
2525
"autoUpdate": "Automatisch auf Aktualisierungen prüfen",
@@ -86,7 +86,6 @@
8686
"open": "Öffnen",
8787
"new": "Neu",
8888
"save": "Speichern",
89-
"createVault": "Tresor erstellen",
9089
"decryptionKey": "Entschlüsselungsschlüssel",
9190
"edit": "Bearbeiten",
9291
"delete": "Löschen",
@@ -96,6 +95,7 @@
9695
"url": "URL",
9796
"add": "Hinzufügen",
9897
"search": "Suche",
99-
"noResults": "Keine Ergebnisse",
100-
"editPassword": "Passwort bearbeiten"
98+
"editPassword": "Passwort bearbeiten",
99+
"close": "Schließen",
100+
"copy": "Kopieren"
101101
}

src/languages/en_us.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"characterSet": "Character set",
2020
"generate": "Generate",
2121
"useCustomCharacterSet": "Use custom character set",
22-
"aboutText": "Advanced PassGen was created by DeadLine.\n\nTheme: MUI\nLicense: GPLv3\nVersion: {x}\n\nCopyright © 2022 CodeDead",
22+
"aboutText": "Advanced PassGen was created by DeadLine.\n\nTheme: MUI\nLicense: GPLv3\nVersion: {x}\n\nCopyright © 2023 CodeDead",
2323
"website": "Website",
2424
"license": "License",
2525
"autoUpdate": "Automatically check for updates",
@@ -86,7 +86,6 @@
8686
"open": "Open",
8787
"new": "New",
8888
"save": "Save",
89-
"createVault": "Create vault",
9089
"decryptionKey": "Decryption key",
9190
"edit": "Edit",
9291
"delete": "Delete",
@@ -96,6 +95,7 @@
9695
"url": "URL",
9796
"add": "Add",
9897
"search": "Search",
99-
"noResults": "No results",
100-
"editPassword": "Edit password"
98+
"editPassword": "Edit password",
99+
"close": "Close",
100+
"copy": "Copy"
101101
}

0 commit comments

Comments
 (0)