Skip to content

Commit

Permalink
Merge pull request #7 from leandro-lorenzini/feat/totp
Browse files Browse the repository at this point in the history
Feat/totp
  • Loading branch information
leandro-lorenzini authored Aug 29, 2023
2 parents 768c375 + eaa07b5 commit 7dbbf80
Show file tree
Hide file tree
Showing 11 changed files with 374 additions and 102 deletions.
236 changes: 202 additions & 34 deletions gui/package-lock.json

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

2 changes: 2 additions & 0 deletions gui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
"electron-is-dev": "^2.0.0",
"electron-squirrel-startup": "^1.0.0",
"jsencrypt": "^3.3.2",
"otp-client": "^1.0.3",
"otplib": "^12.0.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.11.2",
Expand Down
12 changes: 6 additions & 6 deletions gui/src/components/Sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ function Sync(props) {
if (secret[0]?.vault.ciphertext && key?.length) {
// Decrypt password using current user's private Key
let currentUserKey = props.recovery ? props.recovery : props.keys.privateKey;
encryption.decrypt(secret[0].vault.ciphertext, currentUserKey).then(plaintext => {
encryption.decrypt([secret[0].vault.ciphertext, secret[0].vault.totp], currentUserKey).then(plaintext => {
// Encrypt password with other user's public key.
encryption.encrypt(plaintext, key[0].value).then(ciphertext => {
encryption.encrypt([plaintext[0], plaintext[1]], key[0].value).then(ciphertext => {
// Create a vault for the other user's public key
Api.vault.add(secret[0].folder, secret[0].id, missing.user, missing.key, ciphertext, secret[0].version).catch(error => {
Api.vault.add(secret[0].folder, secret[0].id, missing.user, missing.key, ciphertext[0], ciphertext[1], secret[0].version).catch(error => {
console.error(error);
});

Expand All @@ -50,11 +50,11 @@ function Sync(props) {
if (secret[0]?.vault.ciphertext && key?.length) {
// Decrypt password using current user's private Key
let currentUserKey = props.recovery ? props.recovery : props.keys.privateKey;
encryption.decrypt(secret[0].vault.ciphertext, currentUserKey).then(plaintext => {
encryption.decrypt([secret[0].vault.ciphertext, secret[0].vault.totp], currentUserKey).then(plaintext => {
// Encrypt password with other user's public key.
encryption.encrypt(plaintext, key[0].value).then(ciphertext => {
encryption.encrypt([plaintext[0], plaintext[1]], key[0].value).then(ciphertext => {
// Create a vault for the other user's public key
Api.vault.update(secret[0].folder, secret[0].id, outdated.user, outdated.key, ciphertext, secret[0].version).catch(error => {
Api.vault.update(secret[0].folder, secret[0].id, outdated.user, outdated.key, ciphertext[0], ciphertext[1], secret[0].version).catch(error => {
console.error(error);
});

Expand Down
Loading

0 comments on commit 7dbbf80

Please sign in to comment.