Skip to content

Commit

Permalink
Integrations #217
Browse files Browse the repository at this point in the history
  • Loading branch information
Levminer committed Jul 2, 2022
1 parent 6277135 commit fc27195
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 6 deletions.
4 changes: 2 additions & 2 deletions app/codes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ const generateCodeElements = (data) => {
}
}, 500)

if (settings.settings.search_filter) {
if (settings.settings.integrations === true) {
const http = require("http")

/**
Expand Down Expand Up @@ -356,7 +356,7 @@ const generateCodeElements = (data) => {
const server = http.createServer(requestListener)

server.listen(1010, () => {
console.log("Server started")
logger.log("Server started")
})
}

Expand Down
13 changes: 13 additions & 0 deletions app/settings/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,19 @@ <h4>There are no experiments currently! Please check back later!</h4>
GitHub Issues
</button>
</div>

<br />
<hr />
<h3>Integrations</h3>
<h4>You can use the provided URL and key with 3rd party integrations. This URL only works on your machine by default.</h4>
<div class="mx-auto flex h-[68px] w-72 items-center justify-center rounded-full bg-white">
<a href="#" onclick="integrations()">
<div class="pointer-events-none relative mr-2 inline-block w-10 select-none rounded-full border-2 border-gray-900 bg-gray-900 align-middle">
<input tabindex="-1" id="integrationsToggle" type="checkbox" class="toggle" />
<label for="integrationsToggle" class="toggle-bg block h-6 cursor-pointer overflow-hidden rounded-full bg-white"></label></div
></a>
<span id="integrationsLabel" class="text-xl text-black">-</span>
</div>
</div>
</div>
</div>
Expand Down
48 changes: 46 additions & 2 deletions app/settings/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { shell, app, dialog, BrowserWindow } = require("@electron/remote")
const { convert, localization } = require("@levminer/lib")
const { convert, localization, aes } = require("@levminer/lib")
const logger = require("@levminer/lib/logger/renderer")
const { ipcRenderer: ipc } = require("electron")
const path = require("path")
Expand Down Expand Up @@ -89,6 +89,9 @@ const tgt7 = document.querySelector("#tgt7")
const tgl8 = document.querySelector("#tgl8")
const tgt8 = document.querySelector("#tgt8")

const integrationsToggle = document.querySelector("#integrationsToggle")
const integrationsLabel = document.querySelector("#integrationsLabel")

// launch on startup
let launch_startup_state = settings.settings.launch_on_startup
if (launch_startup_state === true) {
Expand Down Expand Up @@ -211,6 +214,17 @@ if (analytics_state === false) {
tgl8.checked = true
}

// integrations
let integrations_state = settings.settings.integrations

if (integrations_state === false) {
integrationsLabel.textContent = "Off"
integrationsToggle.checked = false
} else {
integrationsLabel.textContent = "On"
integrationsToggle.checked = true
}

/**
* Launch Authme on system startup
*/
Expand Down Expand Up @@ -843,7 +857,7 @@ try {
const restart = () => {
setTimeout(() => {
app.relaunch()
app.quit()
app.exit()
}, 300)
}

Expand Down Expand Up @@ -1183,3 +1197,33 @@ const resetShortcut = (value) => {

ipc.invoke("refreshShortcuts")
}

/* Integrations */
const integrations = () => {
const key = aes.generateRandomKey(aes.generateSalt())
const hash = aes.hash(key)

console.log(hash)

if (integrations_state === true) {
settings.settings.integrations = false

save()

integrationsLabel.textContent = "Off"
integrationsToggle.checked = false

integrations_state = false
} else {
settings.settings.integrations = true

save()

integrationsLabel.textContent = "On"
integrationsToggle.checked = true

integrations_state = true
}

reloadApplicationWindow()
}
9 changes: 9 additions & 0 deletions lib/aes.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,13 @@ module.exports = {
const messagetext = decipher.update(encryptedMessage)
return Buffer.concat([messagetext, decipher.final()])
},

/**
*
* @param {string|Buffer} text
* @returns {string} sha512 text
*/
hash: (text) => {
return crypto.createHash("sha512").update(text).digest("base64")
},
}
1 change: 1 addition & 0 deletions lib/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ interface LibSettings {
search_history: boolean
hardware_acceleration: boolean
analytics: boolean
integrations: boolean
language: null | string
sort: null | number
search_filter: {
Expand Down
9 changes: 8 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ const settings_file = {
language: null,
sort: null,
analytics: true,
integrations: true,
},
security: {
require_password: null,
Expand Down Expand Up @@ -311,6 +312,12 @@ if (settings.settings.analytics === undefined) {
saveSettings()
}

if (settings.settings.integrations === undefined) {
settings.settings.integrations = false

saveSettings()
}

/**
* Force dark mode
*/
Expand Down Expand Up @@ -643,7 +650,7 @@ const createWindows = () => {
saveWindowPosition()

if (dev === true) {
app.quit()
app.exit()
} else {
if (settings.settings.close_to_tray === false) {
try {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"license": "LICENSE.md",
"oneClick": false,
"allowToChangeInstallationDirectory": true,
"createDesktopShortcut": "always",
"createDesktopShortcut": true,
"artifactName": "authme-${version}-windows-x64-installer.exe"
},
"linux": {
Expand Down

0 comments on commit fc27195

Please sign in to comment.