Skip to content

Commit

Permalink
Initial Aegis support #264
Browse files Browse the repository at this point in the history
  • Loading branch information
Levminer committed Mar 5, 2024
1 parent ba7dd33 commit ea0e9ce
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 4 deletions.
8 changes: 7 additions & 1 deletion interface/utils/language/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,16 @@ export const localeEN = {
authmeFileButton: "Choose file",
// 2FAS
twoFasAuth: "2FAS Authenticator",
twoFasAuthText: "Import all codes from from a 2FAS Authenticator backup.",
twoFasAuthText: "Import all codes from a 2FAS Authenticator backup.",
twoFasFile: "2FAS backup file (without password)",
twoFasFileText: "Import all codes from an existing 2FAS backup file without a password.",
twoFasFileButton: "Choose file",
// aegis
aegisAuth: "Aegis Authenticator",
aegisAuthText: "Import all codes from from an Aegis vault.",
aegisFile: "Aegis vault file (without password)",
aegisFileText: "Import all codes from an existing Aegis vault file without a password.",
aegisFileButton: "Choose file",
// html dialogs
captureScreenTitle: "Capture screen import",
captureScreenWaiting: "Waiting for a QR code...",
Expand Down
8 changes: 7 additions & 1 deletion interface/utils/language/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,16 @@ export const localeES: typeof localeEN = {
authmeFileButton: "Choose file",
// 2FAS
twoFasAuth: "2FAS Authenticator",
twoFasAuthText: "Import all codes from from a 2FAS Authenticator backup.",
twoFasAuthText: "Import all codes from a 2FAS Authenticator backup.",
twoFasFile: "2FAS backup file (without password)",
twoFasFileText: "Import all codes from an existing 2FAS backup file without a password.",
twoFasFileButton: "Choose file",
// aegis
aegisAuth: "Aegis Authenticator",
aegisAuthText: "Import all codes from from an Aegis vault.",
aegisFile: "Aegis vault file (without password)",
aegisFileText: "Import all codes from an existing Aegis vault file without a password.",
aegisFileButton: "Choose file",
// html dialogs
captureScreenTitle: "Importación de pantalla de captura",
captureScreenWaiting: "Esperando un código QR...",
Expand Down
8 changes: 7 additions & 1 deletion interface/utils/language/hu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,16 @@ export const localeHU: typeof localeEN = {
authmeFileButton: "Choose file",
// 2FAS
twoFasAuth: "2FAS Authenticator",
twoFasAuthText: "Import all codes from from a 2FAS Authenticator backup.",
twoFasAuthText: "Import all codes from a 2FAS Authenticator backup.",
twoFasFile: "2FAS backup file (without password)",
twoFasFileText: "Import all codes from an existing 2FAS backup file without a password.",
twoFasFileButton: "Choose file",
// aegis
aegisAuth: "Aegis Authenticator",
aegisAuthText: "Import all codes from from an Aegis vault.",
aegisFile: "Aegis vault file (without password)",
aegisFileText: "Import all codes from an existing Aegis vault file without a password.",
aegisFileButton: "Choose file",
// translate dialogs
captureScreenTitle: "Képernyőről importálás",
captureScreenWaiting: "Várakozás a QR kódra...",
Expand Down
31 changes: 30 additions & 1 deletion interface/windows/import/import.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,35 @@
</div>
</div>

<div class="transparent-800 flex w-full flex-col items-start rounded-xl p-5 text-left">
<div>
<h2>{language.import.aegisAuth}</h2>
<h3>{language.import.aegisAuthText}</h3>
</div>
<div class="mt-5 flex w-full">
<button class="button" on:click={showAuthmeFileDialog}>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10" /><line x1="12" y1="16" x2="12" y2="12" /><line x1="12" y1="8" x2="12.01" y2="8" /></svg>
{language.import.instructions}
</button>
</div>
<div class="mt-5 flex w-full">
<Details title={language.import.chooseImportMethod}>
<div class="flex flex-row justify-between">
<div>
<h4 class="text-white">{language.import.aegisFile}</h4>
<h5>{language.import.aegisFileText}</h5>
</div>
<div>
<button class="smallButton" on:click={aegisFile}>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 22h14a2 2 0 0 0 2-2V7.5L14.5 2H6a2 2 0 0 0-2 2v3" /><polyline points="14 2 14 8 20 8" /><path d="M5 17a3 3 0 1 0 0-6 3 3 0 0 0 0 6z" /><path d="m9 18-1.5-1.5" /></svg>
{language.import.aegisFileButton}
</button>
</div>
</div>
</Details>
</div>
</div>

<div class="transparent-800 flex w-full flex-col items-start rounded-xl p-5 text-left">
<div>
<h2>{language.import.twoFasAuth}</h2>
Expand Down Expand Up @@ -296,7 +325,7 @@
</dialog>

<script>
import { captureScreen, chooseFile, chooseImages, manualEntry, showAuthmeFileDialog, showGADialog, showManualEntry, showTOTPDialog, twoFasAuthFile, useWebcam } from "./index"
import { aegisFile, captureScreen, chooseFile, chooseImages, manualEntry, showAuthmeFileDialog, showGADialog, showManualEntry, showTOTPDialog, twoFasAuthFile, useWebcam } from "./index"
import Details from "../../components/details.svelte"
import { getLanguage } from "@utils/language"
Expand Down
48 changes: 48 additions & 0 deletions interface/windows/import/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@ export const chooseFile = async () => {
}
}

/**
* Import from a 2FAS backup file
*/
export const twoFasAuthFile = async () => {
const filePath = await dialog.open({ filters: [{ name: "2FAS file", extensions: ["2fas"] }] })

Expand Down Expand Up @@ -224,6 +227,51 @@ export const twoFasAuthFile = async () => {
navigate("codes")
}
}

/**
* Import from an Aegis vault file
*/
export const aegisFile = async () => {
const filePath = await dialog.open({ filters: [{ name: "Aegis vault file", extensions: ["json"] }] })

interface AegisFile {
db:{
entries: {
type: string
name: string
issuer: string
info:{
secret: string
}
}[]
}
}

if (filePath !== null) {
const loadedFile = await fs.readTextFile(filePath.toString())
const file: AegisFile = JSON.parse(loadedFile)
let importString = ""

for (let i = 0; i < file.db.entries.length; i++) {
const entry = file.db.entries[i]

console.log(entry)

if (entry.type === "totp") {
importString += totpImageConverter(`otpauth://totp/${entry.name}?secret=${entry.info.secret}&issuer=${entry.issuer}`)
}
}

dialog.message(language.codes.dialog.codesImported)

const state = getState()
state.importData = importString
setState(state)

navigate("codes")
}
}

/**
* Start a video capture, when a QR code detected try to read it
*/
Expand Down

0 comments on commit ea0e9ce

Please sign in to comment.