Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
goshander committed May 5, 2024
0 parents commit fab2c30
Show file tree
Hide file tree
Showing 30 changed files with 346 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
dist
out
.gitignore
12 changes: 12 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* eslint-env node */
require('@rushstack/eslint-patch/modern-module-resolution')

module.exports = {
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
'@electron-toolkit',
'@electron-toolkit/eslint-config-ts/eslint-recommended'
]
}
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
dist
out
.DS_Store
*.log*
6 changes: 6 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
out
dist
pnpm-lock.yaml
LICENSE.md
tsconfig.json
tsconfig.*.json
4 changes: 4 additions & 0 deletions .prettierrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
singleQuote: true
semi: false
printWidth: 100
trailingComma: none
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["dbaeumer.vscode-eslint"]
}
21 changes: 21 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug Main Process",
"type": "node",
"request": "launch",
"cwd": "${workspaceRoot}",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron-vite",
"windows": {
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron-vite.cmd"
},
"runtimeArgs": [
"--sourcemap"
],
"env": {
"REMOTE_DEBUGGING_PORT": "9222"
}
},
],
}
11 changes: 11 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"[typescript]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"[javascript]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"[json]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
}
}
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# 🔐 Kaspersky Password Manager for Linux

Unofficial Electron application based on web version

## Project Setup

### Install

```bash
$ bun install
```

### Development

```bash
$ bun run dev
```

### Build

```bash
$ bun run build-linux
```
Binary file added bun.lockb
Binary file not shown.
Binary file added desktop/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions desktop/kpm.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Desktop Entry]
Name=Kaspersky Password Manager
Name[en_US]=Kaspersky Password Manager
Name[en_GB]=Kaspersky Password Manager
Icon=${HOME}/.appimage/kpm/icon.png
Exec=${HOME}/.appimage/kpm/kpm-linux.AppImage
Path=${HOME}/.appimage/kpm
Type=Application
Categories=X-GNOME-Utilities;
22 changes: 22 additions & 0 deletions electron-builder.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
appId: ru.app64mb.kpm
productName: kpm-linux
directories:
buildResources: build
files:
- '!**/.vscode/*'
- '!src/*'
- '!electron.vite.config.{js,ts,mjs,cjs}'
- '!{.eslintignore,.eslintrc.cjs,.prettierignore,.prettierrc.yaml,dev-app-update.yml,CHANGELOG.md,README.md}'
- '!{.env,.env.*,.npmrc,pnpm-lock.yaml}'
- '!{tsconfig.json,tsconfig.node.json,tsconfig.web.json}'
asarUnpack:
- resources/**
linux:
target:
- AppImage
maintainer: 64mb
category: Utility
icon: resources/icons
appImage:
artifactName: ${name}.${ext}
npmRebuild: false
10 changes: 10 additions & 0 deletions electron.vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { defineConfig, externalizeDepsPlugin } from 'electron-vite'

export default defineConfig({
main: {
plugins: [externalizeDepsPlugin()]
},
preload: {
plugins: [externalizeDepsPlugin()]
}
})
47 changes: 47 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"name": "kpm-linux",
"productName": "Kaspersky Password Manager",
"description": "Kaspersky Password Manager for Linux",
"version": "1.0.0",
"main": "./out/main/index.js",
"author": {
"name": "64mb",
"url": "https://github.com/64mb",
"email": "[email protected]"
},
"homepage": "https://github.com/64mb/kpm-linux",
"repository": {
"url": "https://github.com/64mb/kpm-linux"
},
"scripts": {
"format": "prettier --write .",
"lint": "eslint . --ext .js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix",
"typecheck": "tsc --noEmit -p tsconfig.node.json --composite false",
"start": "electron-vite preview",
"dev": "electron-vite dev",
"postinstall": "electron-builder install-app-deps",
"build": "npm run typecheck && electron-vite build",
"build-linux": "npm run build && electron-builder --linux"
},
"dependencies": {
"@electron-toolkit/preload": "^3.0.0",
"@electron-toolkit/utils": "^3.0.0"
},
"devDependencies": {
"@electron-toolkit/eslint-config": "^1.0.2",
"@electron-toolkit/eslint-config-ts": "^1.0.1",
"@electron-toolkit/tsconfig": "^1.0.1",
"@typescript-eslint/eslint-plugin": "7.4.0",
"@rushstack/eslint-patch": "^1.7.1",
"@types/node": "^18.19.9",
"electron": "^28.2.0",
"electron-builder": "^24.9.1",
"electron-vite": "^2.0.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-prettier": "5.1.3",
"prettier": "^3.2.4",
"typescript": "^5.3.3",
"vite": "^5.0.12"
}
}
Binary file added resources/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/icons/icon-128x128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/icons/icon-16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/icons/icon-256x256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/icons/icon-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/icons/icon-48x48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/icons/icon-64x64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/icons/icon-96x96.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
71 changes: 71 additions & 0 deletions src/main/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { app, shell, BrowserWindow } from 'electron'
import { join } from 'path'
import { electronApp, optimizer } from '@electron-toolkit/utils'
import icon from '../../resources/icon.png?asset'
import { style } from './style'

function createWindow(): void {
const mainWindow = new BrowserWindow({
width: 900,
height: 680,
show: false,
title: 'Kaspersky Password Manager',
fullscreen: false,
fullscreenable: false,
autoHideMenuBar: true,
...(process.platform === 'linux' ? { icon } : {}),
minHeight: 560,
minWidth: 780,
webPreferences: {
preload: join(__dirname, '../preload/index.js'),
sandbox: false
}
})

mainWindow.loadURL('https://my.kaspersky.com/MyPasswords#/portal/pages/kpm/all')

mainWindow.on('ready-to-show', () => {
mainWindow.show()
})

mainWindow.webContents.setWindowOpenHandler((details) => {
shell.openExternal(details.url)
return { action: 'deny' }
})

const styleMin = style.replace(/\n/g, '')

const contents = mainWindow.webContents
contents.addListener('did-finish-load', () => {
contents.insertCSS(styleMin)
})
}

app.whenReady().then(() => {
// set app user model id for windows
electronApp.setAppUserModelId('ru.app64mb.kpm')

// default open or close DevTools by F12 in development
// and ignore CommandOrControl + R in production
// see https://github.com/alex8088/electron-toolkit/tree/master/packages/utils
app.on('browser-window-created', (_, window) => {
optimizer.watchWindowShortcuts(window)
})

createWindow()

app.on('activate', function () {
// on macOS it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open
if (BrowserWindow.getAllWindows().length === 0) createWindow()
})
})

// quit when all windows are closed, except on macOS. There, it's common
// for applications and their menu bar to stay active until the user quits
// explicitly with Cmd + Q
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})
38 changes: 38 additions & 0 deletions src/main/style.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
export const style = `
kl-header-menu, kpm-download-link, .header, .footer, .w-kpmSearch__voice-img, .microphone.microphone_off {
display: none !important;
}
.w-kpmPageLayout__header {
height: 52px !important;
}
.w-kpmPageLayout__header-title {
font-size: 14px !important;
}
kl-desktop-menu ul kl-desktop-menu-item:nth-child(1),
kl-desktop-menu ul kl-desktop-menu-item:nth-child(2),
kl-desktop-menu ul kl-desktop-menu-item:nth-child(6),
kl-desktop-menu ul kl-desktop-menu-item:nth-child(7),
kl-desktop-menu ul kl-desktop-menu-item:nth-child(8) {
display: none !important;
}
kl-desktop-menu ul .w-menu__item-scroller {
display: none !important;
}
kl-desktop-menu ul {
text-align: center !important;
}
.w-kpmListMenu {
height: 680px !important;
}
.w-kpmPageLayout__nav-side {
height: auto !important;
}
`
8 changes: 8 additions & 0 deletions src/preload/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { ElectronAPI } from '@electron-toolkit/preload'

declare global {
interface Window {
electron: ElectronAPI
api: unknown
}
}
22 changes: 22 additions & 0 deletions src/preload/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { contextBridge } from 'electron'
import { electronAPI } from '@electron-toolkit/preload'

// Custom APIs for renderer
const api = {}

// use `contextBridge` APIs to expose Electron APIs to
// renderer only if context isolation is enabled, otherwise
// just add to the DOM global.
if (process.contextIsolated) {
try {
contextBridge.exposeInMainWorld('electron', electronAPI)
contextBridge.exposeInMainWorld('api', api)
} catch (error) {
console.error(error)
}
} else {
// @ts-ignore (define in dts)
window.electron = electronAPI
// @ts-ignore (define in dts)
window.api = api
}
8 changes: 8 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"files": [],
"references": [
{
"path": "./tsconfig.node.json"
}
]
}
13 changes: 13 additions & 0 deletions tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": "@electron-toolkit/tsconfig/tsconfig.node.json",
"include": [
"src/main/**/*",
"src/preload/**/*"
],
"compilerOptions": {
"composite": true,
"types": [
"electron-vite/node"
]
}
}

0 comments on commit fab2c30

Please sign in to comment.