Skip to content

Commit

Permalink
Improved window content protection #156
Browse files Browse the repository at this point in the history
  • Loading branch information
Levminer committed Nov 19, 2021
1 parent 6e50970 commit c40430a
Show file tree
Hide file tree
Showing 8 changed files with 100 additions and 65 deletions.
12 changes: 12 additions & 0 deletions app/confirm/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,18 @@ <h4>If you have a backup key you can recover your password. If you don't have on
</svg>
Choose backup file
</button>

<hr />

<h3>Window capture</h3>
<h4>Allows screenshots and screen capture. You can record or screenshot the app until you restart Authme.</h4>
<div class="flex justify-center items-center w-72 h-[68px] bg-white mx-auto rounded-full">
<div class="relative inline-block w-10 mr-2 align-middle select-none bg-gray-900 border-2 border-gray-900 rounded-full">
<input onclick="toggleWindowCapture()" id="tgl0" type="checkbox" class="toggle checked:bg-white outline-none focus:outline-none right-5 duration-200 ease-in absolute block w-4 h-4 rounded-full top-1 bg-black appearance-none cursor-pointer" />
<label for="tgl0" class="toggle-bg block overflow-hidden h-6 rounded-full bg-white cursor-pointer"></label>
</div>
<span id="tgt0" class="text-black text-xl">Off</span>
</div>
</div>
</div>
</div>
Expand Down
16 changes: 16 additions & 0 deletions app/confirm/src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,3 +268,19 @@ const showMoreOptions = () => {
more_options_shown = false
}
}

/**
* Toggles window capture state
*/
const toggleWindowCapture = () => {
const tgl0 = document.querySelector("#tgl0").checked
const tgt0 = document.querySelector("#tgt0")

if (tgl0 === false) {
ipc.send("disableWindowCapture")
tgt0.textContent = "Off"
} else {
tgt0.textContent = "On"
ipc.send("enableWindowCapture")
}
}
8 changes: 4 additions & 4 deletions app/landing/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,17 @@ <h4>In case you forget your password you can use this backup key to get back you
Generate key
</button>

<!-- <hr />
<hr />

<h3>Window capture</h3>
<h4>Allows screenshots and screen capture. You can record or screenshot the app.</h4>
<h4>Allows screenshots and screen capture. You can record or screenshot the app until you restart Authme.</h4>
<div class="flex justify-center items-center w-72 h-[68px] bg-white mx-auto rounded-full">
<div class="relative inline-block w-10 mr-2 align-middle select-none bg-gray-900 border-2 border-gray-900 rounded-full">
<input onclick="toggleWindowCapture()" id="tgl0" type="checkbox" class="toggle checked:bg-white outline-none focus:outline-none right-5 duration-200 ease-in absolute block w-4 h-4 rounded-full top-1 bg-black appearance-none cursor-pointer" />
<label for="tgl0" class="toggle-bg block overflow-hidden h-6 rounded-full bg-white cursor-pointer"></label>
</div>
<span id="tgt0" class="text-black text-xl">off</span>
</div> -->
<span id="tgt0" class="text-black text-xl">Off</span>
</div>
</div>
</div>
</div>
Expand Down
28 changes: 16 additions & 12 deletions app/landing/src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,18 +230,6 @@ const noPassword = () => {
})
}

// ? encryption method toggle
const encryptionMethodToggle = () => {
const tgl0 = document.querySelector("#tgl0").checked
const tgt0 = document.querySelector("#tgt0")

if (tgl0 === false) {
tgt0.textContent = "Off"
} else {
tgt0.textContent = "On"
}
}

/**
* Generate a backup key which encrypts the password
*/
Expand Down Expand Up @@ -372,3 +360,19 @@ const showMoreOptions = () => {
more_options_shown = false
}
}

/**
* Toggles window capture state
*/
const toggleWindowCapture = () => {
const tgl0 = document.querySelector("#tgl0").checked
const tgt0 = document.querySelector("#tgt0")

if (tgl0 === false) {
ipc.send("disableWindowCapture")
tgt0.textContent = "Off"
} else {
tgt0.textContent = "On"
ipc.send("enableWindowCapture")
}
}
6 changes: 3 additions & 3 deletions app/settings/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,13 @@ <h4>On closing the app will not quit. You can open the app from the tray.</h4>
<hr />
<div id="disable_screen_capture_div">
<h3>Window capture</h3>
<h4>Allows screenshots and screen capture. You can record or screenshot the app.</h4>
<h4>Allows screenshots and screen capture. You can record or screenshot the app until you restart Authme.</h4>
<div class="flex justify-center items-center w-72 h-[68px] bg-white mx-auto rounded-full">
<div class="relative inline-block w-10 mr-2 align-middle select-none bg-gray-900 border-2 border-gray-900 rounded-full">
<input id="tgl2" onclick="capture()" type="checkbox" class="toggle" />
<input id="tgl2" onclick="toggleWindowCapture()" type="checkbox" class="toggle" />
<label for="tgl2" class="toggle-bg block overflow-hidden h-6 rounded-full bg-white cursor-pointer"></label>
</div>
<span id="tgt2" class="text-black text-xl">-</span>
<span id="tgt2" class="text-black text-xl">Off</span>
</div>
<hr />
</div>
Expand Down
53 changes: 23 additions & 30 deletions app/settings/src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,20 +112,6 @@ if (tray_state === true) {
ipc.send("disable_tray")
}

// capture
let capture_state = file.settings.disable_window_capture
if (capture_state === true) {
tgt2.textContent = "Off"
tgl2.checked = false

ipc.send("disable_capture")
} else {
tgt2.textContent = "On"
tgl2.checked = true

ipc.send("enable_capture")
}

// names
let names_state = file.settings.show_2fa_names
if (names_state === true) {
Expand Down Expand Up @@ -250,30 +236,37 @@ const tray = () => {
}
}

// ? capture
const capture = () => {
if (capture_state == true) {
file.settings.disable_window_capture = false

save()
/**
* Toggles window capture
*/
const toggleWindowCapture = () => {
const tgl2 = document.querySelector("#tgl2").checked
const tgt2 = document.querySelector("#tgt2")

if (tgl2 == true) {
tgt2.textContent = "On"
tgl2.checked = true

capture_state = false

ipc.send("enable_capture")
ipc.send("enableWindowCapture")
} else {
file.settings.disable_window_capture = true
tgt2.textContent = "Off"

save()
ipc.send("disableWindowCapture")
}
}

/**
* Toggles window capture switch if this option is switched somewhere else
*/
const toggleWindowCaptureSwitch = () => {
const tgl2 = document.querySelector("#tgl2")
const tgt2 = document.querySelector("#tgt2")

if (tgl2.checked === false) {
tgt2.textContent = "On"
tgl2.checked = true
} else {
tgt2.textContent = "Off"
tgl2.checked = false

capture_state = true

ipc.send("disable_capture")
}
}

Expand Down
40 changes: 25 additions & 15 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ const settings = `{
"click_to_reveal": false,
"reset_after_copy": false,
"save_search_results": true,
"disable_window_capture": true,
"disable_hardware_acceleration": true,
"search_bar_filter": {
"name": true,
Expand Down Expand Up @@ -553,14 +552,16 @@ const createWindow = () => {
logger.log("Edit closed")
})

// ? disable screen capture by default
if (file.settings.disable_window_capture === true) {
window_settings.setContentProtection(true)
window_edit.setContentProtection(true)
window_application.setContentProtection(true)
window_import.setContentProtection(true)
window_export.setContentProtection(true)
}
/**
* Disables window capture by default
*/
window_landing.setContentProtection(true)
window_confirm.setContentProtection(true)
window_application.setContentProtection(true)
window_settings.setContentProtection(true)
window_import.setContentProtection(true)
window_export.setContentProtection(true)
window_edit.setContentProtection(true)

// ? check for auto update
window_application.on("show", () => {
Expand Down Expand Up @@ -833,9 +834,15 @@ ipc.on("enable_startup", () => {
logger.log("Startup enabled")
})

ipc.on("disable_capture", () => {
window_settings.setContentProtection(true)
window_edit.setContentProtection(true)
/**
* Disables screen capture until restart
*/
ipc.on("disableWindowCapture", () => {
try {
window_landing.setContentProtection(true)
window_confirm.setContentProtection(true)
} catch (error) {}

window_application.setContentProtection(true)
window_import.setContentProtection(true)
window_export.setContentProtection(true)
Expand All @@ -844,9 +851,12 @@ ipc.on("disable_capture", () => {
logger.log("Screen capture disabled")
})

ipc.on("enable_capture", () => {
window_settings.setContentProtection(false)
window_edit.setContentProtection(false)
/**
* Enables screen capture until restart
*/
ipc.on("enableWindowCapture", () => {
try {
window_confirm.setContentProtection(false)
window_application.setContentProtection(false)
window_import.setContentProtection(false)
window_export.setContentProtection(false)
Expand Down
2 changes: 1 addition & 1 deletion src/tailwind.css

Large diffs are not rendered by default.

0 comments on commit c40430a

Please sign in to comment.