Skip to content

Commit 69ebbd8

Browse files
authored
Merge pull request #24 from CodeDead/release/v2.1.0
Release/v2.1.0
2 parents 561eb62 + 6d7120c commit 69ebbd8

File tree

30 files changed

+1438
-607
lines changed

30 files changed

+1438
-607
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ jobs:
1818
uses: actions/checkout@v3
1919

2020
- name: Node.js setup
21-
uses: actions/setup-node@v1
21+
uses: actions/setup-node@v3
2222
with:
23-
node-version: 16
23+
node-version: 18
2424

2525
- name: Rust setup
2626
uses: actions-rs/toolchain@v1

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ jobs:
2626
steps:
2727
- uses: actions/checkout@v3
2828
- name: Setup node
29-
uses: actions/setup-node@v1
29+
uses: actions/setup-node@v3
3030
with:
31-
node-version: 16
31+
node-version: 18
3232
- name: Install Rust stable
3333
uses: actions-rs/toolchain@v1
3434
with:

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Advanced PassGen
22

3-
![Advanced PassGen](https://i.imgur.com/bVTaGO7.png)
3+
![Advanced PassGen](https://i.imgur.com/ci8x6rX.png)
44

55
![GitHub](https://img.shields.io/badge/language-JavaScript+Rust-green)
66
![GitHub](https://img.shields.io/github/license/CodeDead/Advanced-PassGen)
@@ -53,7 +53,7 @@ yarn tauri build
5353

5454
### macOS
5555

56-
#### DMG
56+
#### dmg
5757

5858
You can create a macOS build by running the `yarn tauri build` command on a macOS host:
5959
```shell
@@ -85,6 +85,10 @@ The theme used in this application is [MUI](https://mui.com/).
8585

8686
The application icon was provided by [RemixIcon](https://remixicon.com/).
8787

88+
### Translations
89+
90+
* German: [uDEV2019](https://github.com/uDEV2019)
91+
8892
## About
8993

9094
This library is maintained by CodeDead. You can find more about us using the following links:

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"name": "advanced-passgen",
3-
"version": "2.0.0",
3+
"version": "2.1.0",
44
"private": true,
55
"dependencies": {
6-
"@emotion/react": "^11.10.4",
7-
"@emotion/styled": "^11.10.4",
6+
"@emotion/react": "^11.10.5",
7+
"@emotion/styled": "^11.10.5",
88
"@fontsource/roboto": "^4.5.8",
99
"@mui/icons-material": "^5.10.9",
10-
"@mui/material": "^5.10.9",
10+
"@mui/material": "^5.10.12",
1111
"@shopify/react-web-worker": "^5.0.6",
1212
"@tauri-apps/api": "^1.1.0",
1313
"@testing-library/jest-dom": "^5.16.5",
@@ -16,10 +16,10 @@
1616
"clsx": "^1.2.1",
1717
"react": "^18.2.0",
1818
"react-dom": "^18.2.0",
19-
"react-router-dom": "^6.4.2",
19+
"react-router-dom": "^6.4.3",
2020
"react-scripts": "^5.0.1",
2121
"react-virtualized": "^9.22.3",
22-
"web-vitals": "^3.0.3"
22+
"web-vitals": "^3.0.4"
2323
},
2424
"scripts": {
2525
"start": "react-scripts start",
@@ -50,7 +50,7 @@
5050
"devDependencies": {
5151
"@tauri-apps/cli": "^1.1.1",
5252
"cross-env": "^7.0.3",
53-
"eslint": "^8.25.0",
53+
"eslint": "^8.26.0",
5454
"eslint-config-airbnb": "^19.0.4",
5555
"eslint-plugin-import": "^2.26.0",
5656
"eslint-plugin-jsx-a11y": "^6.6.1",

src-tauri/Cargo.lock

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

src-tauri/Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
[package]
22
name = "advanced-passgen"
3-
version = "2.0.0"
3+
version = "2.1.0"
44
description = "Advanced PassGen can be used to quickly generate thousands of passwords"
55
authors = ["CodeDead <admin@codedead.com>"]
66
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.64.0"
10+
rust-version = "1.65.0"
1111

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

@@ -19,6 +19,8 @@ serde_json = "1.0"
1919
serde = { version = "1.0", features = ["derive"] }
2020
tauri = { version = "1.1.1", features = ["api-all"] }
2121
open = "3.0.3"
22+
rand = "0.8.5"
23+
unicode-segmentation = "1.10.0"
2224

2325
[features]
2426
# by default Tauri runs in production mode

src-tauri/src/main.rs

Lines changed: 65 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,81 @@
11
#![cfg_attr(
2-
all(not(debug_assertions), target_os = "windows"),
3-
windows_subsystem = "windows"
2+
all(not(debug_assertions), target_os = "windows"),
3+
windows_subsystem = "windows"
44
)]
55

6+
use rand::Rng;
67
use std::fs;
8+
use unicode_segmentation::UnicodeSegmentation;
79

810
fn main() {
9-
tauri::Builder::default()
10-
.invoke_handler(tauri::generate_handler![open_website, save_string_to_disk])
11-
.run(tauri::generate_context!())
12-
.expect("error while running tauri application");
11+
tauri::Builder::default()
12+
.invoke_handler(tauri::generate_handler![
13+
open_website,
14+
save_string_to_disk,
15+
generate_passwords
16+
])
17+
.run(tauri::generate_context!())
18+
.expect("error while running tauri application");
1319
}
1420

1521
#[tauri::command]
1622
fn open_website(website: &str) -> Result<String, String> {
17-
match open::that(website) {
18-
Ok(_) => {
19-
Ok(String::from("Success"))
23+
match open::that(website) {
24+
Ok(_) => Ok(String::from("Success")),
25+
Err(e) => Err(e.to_string()),
2026
}
21-
Err(e) => {
22-
Err(e.to_string())
23-
}
24-
}
2527
}
2628

2729
#[tauri::command]
2830
fn save_string_to_disk(content: &str, path: &str) -> Result<String, String> {
29-
match fs::write(path, content) {
30-
Ok(_) => Ok(String::from("Success")),
31-
Err(e) => Err(e.to_string()),
32-
}
31+
match fs::write(path, content) {
32+
Ok(_) => Ok(String::from("Success")),
33+
Err(e) => Err(e.to_string()),
34+
}
35+
}
36+
37+
#[tauri::command]
38+
async fn generate_passwords(
39+
min_length: u64,
40+
max_length: u64,
41+
character_set: &str,
42+
amount: u64,
43+
allow_duplicates: bool,
44+
) -> Result<Vec<String>, String> {
45+
let mut password_list: Vec<String> = Vec::new();
46+
let mut max_count: f64 = 0.0;
47+
let char_count = character_set.graphemes(true).count();
48+
49+
if !allow_duplicates {
50+
let mut current = min_length;
51+
while current <= max_length {
52+
max_count += (char_count as f64).powf(current as f64);
53+
current += 1;
54+
}
55+
}
56+
57+
let mut rng = rand::thread_rng();
58+
let chars = character_set.chars();
59+
for _n in 0..amount {
60+
let mut can_continue = false;
61+
while !can_continue {
62+
let mut password = String::from("");
63+
let length = rng.gen_range(min_length..(max_length + 1));
64+
for _j in 0..length {
65+
let index = rng.gen_range(0..char_count);
66+
password.push(chars.clone().nth(index).unwrap());
67+
}
68+
69+
if allow_duplicates || (!allow_duplicates && !password_list.contains(&password)) {
70+
password_list.push(password);
71+
can_continue = true;
72+
}
73+
74+
if !can_continue && !allow_duplicates && password_list.len() as f64 == max_count {
75+
return Ok(password_list);
76+
}
77+
}
78+
}
79+
80+
Ok(password_list)
3381
}

src-tauri/tauri.conf.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
},
99
"package": {
1010
"productName": "advanced-passgen",
11-
"version": "2.0.0"
11+
"version": "2.1.0"
1212
},
1313
"tauri": {
1414
"allowlist": {
@@ -19,7 +19,7 @@
1919
},
2020
"bundle": {
2121
"active": true,
22-
"category": "DeveloperTool",
22+
"category": "Utility",
2323
"copyright": "Copyright © 2022 CodeDead",
2424
"deb": {
2525
"depends": []
@@ -33,7 +33,7 @@
3333
"icons/icon.ico"
3434
],
3535
"identifier": "com.codedead.advancedpassgen",
36-
"longDescription": "",
36+
"longDescription": "Advanced PassGen is a free and open-source application that can help you generate passwords and export them",
3737
"macOS": {
3838
"entitlements": null,
3939
"exceptionDomain": "",
@@ -42,7 +42,7 @@
4242
"signingIdentity": null
4343
},
4444
"resources": [],
45-
"shortDescription": "",
45+
"shortDescription": "Generate passwords with ease",
4646
"targets": "all",
4747
"windows": {
4848
"certificateThumbprint": null,
@@ -62,7 +62,7 @@
6262
"height": 600,
6363
"resizable": true,
6464
"title": "Advanced PassGen",
65-
"width": 950
65+
"width": 1000
6666
}
6767
]
6868
}

src/components/App/index.jsx

Lines changed: 38 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,18 @@ import Toolbar from '@mui/material/Toolbar';
77
import Box from '@mui/material/Box';
88
import { BrowserRouter, Routes, Route } from 'react-router-dom';
99
import { type } from '@tauri-apps/api/os';
10+
import Alert from '@mui/material/Alert';
11+
import Snackbar from '@mui/material/Snackbar';
12+
import Button from '@mui/material/Button';
13+
import Typography from '@mui/material/Typography';
1014
import { MainContext } from '../../contexts/MainContextProvider';
1115
import ThemeSelector from '../../utils/ThemeSelector';
1216
import TopBar from '../TopBar';
1317
import ClippedDrawer from '../ClippedDrawer';
1418
import UpdateDialog from '../UpdateDialog';
15-
import { openWebSite, setError, setUpdate } from '../../reducers/MainReducer/Actions';
19+
import {
20+
openWebSite, setError, setLoading, setUpdate,
21+
} from '../../reducers/MainReducer/Actions';
1622
import Updater from '../../utils/Updater';
1723
import AlertDialog from '../AlertDialog';
1824
import packageJson from '../../../package.json';
@@ -29,10 +35,10 @@ const NotFound = lazy(() => import('../../routes/NotFound'));
2935
const App = () => {
3036
const [state, d1] = useContext(MainContext);
3137
const {
32-
themeIndex, themeType, update, languageIndex, autoUpdate, error,
38+
themeIndex, themeType, update, languageIndex, autoUpdate, error, loading,
3339
} = state;
3440

35-
const [loading, setLoading] = useState(false);
41+
const [snackOpen, setSnackOpen] = useState(false);
3642
const language = state.languages[languageIndex];
3743

3844
const color = ThemeSelector(themeIndex);
@@ -44,14 +50,6 @@ const App = () => {
4450
},
4551
});
4652

47-
/**
48-
* Open a website
49-
* @param website The website that needs to be opened
50-
*/
51-
const openWebsite = (website) => {
52-
d1(openWebSite(website));
53-
};
54-
5553
/**
5654
* Check for updates
5755
*/
@@ -77,7 +75,7 @@ const App = () => {
7775
d1(setError(e));
7876
})
7977
.finally(() => {
80-
setLoading(false);
78+
d1(setLoading(false));
8179
});
8280
};
8381

@@ -88,10 +86,21 @@ const App = () => {
8886
d1(setError(null));
8987
};
9088

89+
/**
90+
* Close the snack bar
91+
*/
92+
const closeSnack = () => {
93+
setSnackOpen(false);
94+
};
95+
9196
useEffect(() => {
9297
// eslint-disable-next-line no-underscore-dangle
93-
if (autoUpdate && window.__TAURI__) {
94-
checkForUpdates();
98+
if (window.__TAURI__) {
99+
if (autoUpdate) {
100+
checkForUpdates();
101+
}
102+
} else {
103+
setSnackOpen(true);
95104
}
96105
}, []);
97106

@@ -131,7 +140,7 @@ const App = () => {
131140
<UpdateDialog
132141
downloadUrl={update.updateUrl}
133142
infoUrl={update.infoUrl}
134-
openWebsite={openWebsite}
143+
openWebsite={openWebSite}
135144
newVersion={update.version}
136145
onClose={() => d1(setUpdate(null))}
137146
updateAvailable={language.updateAvailable}
@@ -141,6 +150,20 @@ const App = () => {
141150
cancel={language.cancel}
142151
/>
143152
) : null}
153+
<Snackbar open={snackOpen} onClose={closeSnack}>
154+
<Alert onClose={closeSnack} severity="info" sx={{ width: '100%' }}>
155+
<Typography>
156+
{language.downloadApp}
157+
</Typography>
158+
<Button
159+
onClick={() => window.open('https://codedead.com/software/advanced-passgen')}
160+
size="small"
161+
color="secondary"
162+
>
163+
{language.download}
164+
</Button>
165+
</Alert>
166+
</Snackbar>
144167
</BrowserRouter>
145168
</ThemeProvider>
146169
);

0 commit comments

Comments
 (0)