Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ This will allow you to run NethLink on your Linux machine. You can also move the

## 📦 Requirements

- **macOS**: Version 10.15 (Catalina) or later.
- **macOS**: Version 13 (Ventura) or later.
- **Windows**: Windows 10 or later.
- **Rosetta**: Required on macOS for ARM architectures.

Expand Down
20 changes: 17 additions & 3 deletions electron.vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
import react from '@vitejs/plugin-react'
import { defineConfig, externalizeDepsPlugin } from 'electron-vite'
import { defineConfig } from 'electron-vite'
import { resolve } from 'path'

if (
process.platform === 'linux' &&
(process.env['XDG_SESSION_TYPE'] === 'wayland' ||
!!process.env['WAYLAND_DISPLAY'])
) {
const electronArgs: string[] = process.env['ELECTRON_CLI_ARGS']
? JSON.parse(process.env['ELECTRON_CLI_ARGS'])
: []
if (!electronArgs.some((arg) => arg.startsWith('--ozone-platform'))) {
process.env['ELECTRON_CLI_ARGS'] = JSON.stringify([
'--ozone-platform=x11',
...electronArgs,
])
}
}

export default defineConfig({
main: {
plugins: [externalizeDepsPlugin()],
resolve: {
alias: {
'@/lib': resolve('src/main/lib'),
Expand All @@ -14,7 +29,6 @@ export default defineConfig({
},
},
preload: {
plugins: [externalizeDepsPlugin()],
resolve: {
alias: {
'@shared': resolve('src/shared'),
Expand Down
2,970 changes: 1,281 additions & 1,689 deletions package-lock.json

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "1.6.1",
"description": "NethLink is a tool designed to link NethServer systems and provide remote access tools. This project aims to offer a simple yet powerful user interface for managing NethServer systems more efficiently.",
"main": "./out/main/main.js",
"desktopName": "nethlink.desktop",
"license": "MIT",
"author": {
"name": "NethesisSRL",
Expand All @@ -27,7 +28,7 @@
"postversion": "git push origin main --tags",
"build": "rm -rf out && rm -rf dist && npm run typecheck && electron-vite build",
"build:w": "del /s /q out && del /s /q dist && npm run typecheck && electron-vite build",
"postinstall": "electron-builder install-app-deps",
"postinstall": "install-electron && electron-builder install-app-deps",
"build:unpack": "npm run build && electron-builder --dir",
"build:win": "npm run build:w && electron-builder --win",
"build:mac": "npm run build && electron-builder --mac",
Expand All @@ -50,21 +51,21 @@
"@nethesis/phone-island": "^1.1.8",
"@tailwindcss/forms": "^0.5.7",
"@types/lodash": "^4.14.202",
"@types/node": "^18.19.9",
"@types/node": "^24.19.2",
"@types/react": "^18.2.48",
"@types/react-dom": "^18.2.18",
"@vitejs/plugin-react": "^4.2.1",
"@vitejs/plugin-react": "^6.3.0",
"autoprefixer": "^10.4.17",
"axios": "^1.6.7",
"classnames": "^2.5.1",
"clsx": "^2.1.0",
"crypto-js": "^4.2.0",
"date-fns": "^2.30.0",
"date-fns-tz": "^1.3.8",
"electron": "^28.2.0",
"electron": "^45.4.1",
"electron-builder": "^26.16.1",
"electron-builder-notarize": "github:therockerline/electron-builder-notarize#customizations",
"electron-vite": "^2.0.0",
"electron-vite": "^6.0.0",
"eslint": "^9.39.5",
"eslint-plugin-react": "^7.37.5",
"eslint-plugin-react-hooks": "^5.2.0",
Expand All @@ -87,7 +88,7 @@
"tailwind-merge": "^2.2.1",
"tailwindcss": "^3.4.1",
"typescript": "^5.9.3",
"vite": "^5.0.12",
"vite": "^8.3.8",
"zod": "^3.22.4",
"zustand": "^4.5.0"
},
Expand Down
12 changes: 8 additions & 4 deletions src/main/classes/controllers/AccountController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,17 @@ export class AccountController {
delayMs: number = 500,
): Promise<boolean> {
let retries = 0
while (!safeStorage.isEncryptionAvailable() && retries < maxRetries) {
while (
!(await safeStorage.isAsyncEncryptionAvailable()) &&
retries < maxRetries
) {
Log.info(
`waiting for safeStorage to become available (attempt ${retries + 1}/${maxRetries})`,
)
await new Promise((resolve) => setTimeout(resolve, delayMs))
retries++
}
return safeStorage.isEncryptionAvailable()
return safeStorage.isAsyncEncryptionAvailable()
}

async logout() {
Expand Down Expand Up @@ -107,7 +110,8 @@ export class AccountController {
const psw: Buffer = Buffer.from(
authAppData.lastUserCryptPsw as Uint8Array,
)
const decryptString = safeStorage.decryptString(psw)
const { result: decryptString } =
await safeStorage.decryptStringAsync(psw)
const _accountData = JSON.parse(decryptString)
const password = _accountData.password

Expand Down Expand Up @@ -308,7 +312,7 @@ export class AccountController {
username: account.username,
password: password,
})
const cryptString = safeStorage.encryptString(clearString)
const cryptString = await safeStorage.encryptStringAsync(clearString)
const accountUID = getAccountUID(account)
const authAppData = store.store.auth
if (authAppData) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/classes/windows/BaseWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export class BaseWindow {
window.setTitle(this._id)
const instance = this

const onReady = (_e) => {
const onReady = () => {
this._callbacks.forEach((c) => c())
// once called I remove them
this._callbacks = []
Expand Down
5 changes: 2 additions & 3 deletions src/main/classes/windows/PhoneIslandWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,8 @@ export class PhoneIslandWindow extends BaseWindow {
// Uses 'phone-island-log' channel which always writes to file (not gated by isDev)
window.webContents.on(
'console-message',
(_event, level, message, line, sourceId) => {
const levelMap = ['DEBUG', 'INFO', 'WARNING', 'ERROR']
const levelStr = levelMap[level] || 'INFO'
({ level, message, lineNumber: line, sourceId }) => {
const levelStr = level ? level.toUpperCase() : 'INFO'
const source = sourceId ? sourceId.split('/').pop() : 'unknown'
const timestamp = new Date()
.toISOString()
Expand Down
14 changes: 9 additions & 5 deletions src/main/lib/ipcEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,11 @@ export function registerIpcEvents() {
)

ipcMain.on(IPC_EVENTS.COPY_TO_CLIPBOARD, async (_, text) => {
clipboard.writeText(text)
try {
await clipboard.writeText(text)
} catch (e) {
Log.warning('cannot copy to the clipboard', e)
}
})

// Chat island window: size, and island events between it and NethLink.
Expand Down Expand Up @@ -562,9 +566,9 @@ export function registerIpcEvents() {
await new Promise((resolve) => setTimeout(resolve, 100))

// trim spaces
let selectedText = await clipboard.readText(
isLinux ? 'selection' : 'clipboard',
)
let selectedText = await (isLinux
? clipboard.selection.readText()
: clipboard.readText())
if (typeof selectedText !== 'string') return
selectedText = selectedText.trim()

Expand Down Expand Up @@ -780,7 +784,7 @@ export function registerIpcEvents() {
}
// saveLoggedAccount logs out when it cannot encrypt: the session is
// still valid, keep it and let the user sign in again when needed
if (!safeStorage.isEncryptionAvailable()) {
if (!(await safeStorage.isAsyncEncryptionAvailable())) {
Log.warning(
'password update: encryption not available, password not stored',
)
Expand Down
29 changes: 28 additions & 1 deletion src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,8 @@ async function resetApp() {
await delay(100)
}

let screenPermissionDialogShown = false

async function getPermissions() {
if (process.platform === 'darwin') {
// if permission has already been granted I disabled another request to improve performance
Expand All @@ -955,6 +957,15 @@ async function getPermissions() {
systemPreferences.getMediaAccessStatus('screen')
if (recordScreenPermissionState !== 'granted') {
recordScreenPermission = false
}
// The first call runs before the translations are loaded: the dialog
// waits for the next one, and it is shown once
if (
!recordScreenPermission &&
i18next.isInitialized &&
!screenPermissionDialogShown
) {
screenPermissionDialogShown = true
dialog
.showMessageBox({
type: 'warning',
Expand Down Expand Up @@ -1137,5 +1148,21 @@ async function checkConnection() {
return connected
}

function relaunchOnXWayland(): boolean {
if (
process.platform !== 'linux' ||
app.commandLine.getSwitchValue('ozone-platform') !== 'wayland' ||
process.argv.some((arg) => arg.startsWith('--ozone-platform'))
) {
return false
}
app.relaunch({
execPath: process.env['APPIMAGE'] || process.execPath,
args: ['--ozone-platform=x11', ...process.argv.slice(1)],
})
app.exit(0)
return true
}

// BEGIN APP
startup()
if (!relaunchOnXWayland()) startup()
Loading