feat: Delphi backend + JS↔Delphi bridge (clipboard, tray, auto-lock)
Introduces the Delphi 12 FMX backend (PMServer) that hosts the embedded
WebView2 vault on 127.0.0.1, and a native bridge between JS and Delphi
that wires three privacy-focused features:
1. Secure clipboard
Copying a password registers the Win32 "ExcludeClipboardContentFromMonitorProcessing"
format alongside CF_UNICODETEXT, so Win+V clipboard history never sees
the value. Auto-clears after 30s via TTimer. Bridge.copySecure() in
app.js routes all password/username/secret copy paths through the
native layer when running inside the Delphi WebView2 (falls back to
navigator.clipboard for the PHP standalone).
2. Tray icon (X-to-tray when server running)
Closing the dev panel hides both the form HWND and the TFMAppClass
per-process proxy window that owns the FMX taskbar entry — the form's
HWND alone is not the taskbar-visible one in FMX (took some iteration
to discover). Tray menu: Open, Lock vault, Quit. Clipboard is force-
cleared on minimize as extra safety. First-time minimize fires a
balloon notification so the user knows the app is still running.
3. Auto-lock on Windows session lock (Win+L)
wtsapi32.dll!WTSRegisterSessionNotification on a dedicated message-only
window. On WM_WTSSESSION_CHANGE / WTS_SESSION_LOCK, the bridge calls
ExecuteJavaScript('lockVault()'). Same path used by the tray "Lock vault"
menu item.
Bridge architecture:
- JS → Delphi via cmd:// URLs intercepted in OnBeforeNavigate
(pattern lifted from DeskInsight Monaco). Currently exposes
cmd://clipboard/copy?text=...&clear=... and cmd://clipboard/clear.
- Delphi → JS via TTMSFNCWebBrowser.ExecuteJavaScript with guarded
calls (typeof check) so the bridge degrades cleanly if app.js isn't
loaded yet.
Files:
- Source/PM.Bridge.pas (new) — TSecureClipboard + TPMBridge
- UMainForm.pas/.fmx — bridge wiring, FormCloseQuery intercept, tray
callbacks (BridgeTrayRestore / BridgeLockRequest / BridgeQuit)
- js/app.js — Bridge object, 5 navigator.clipboard sites migrated to
Bridge.copySecure with PHP-compatible fallback, Bridge.onTrayRestore
handler that resets the auto-lock timer
.gitignore extended with Delphi build artifacts (*.dcu, Win32/, Win64/,
__history/, __recovery/, *.identcache, *.dsk, *.local, etc.) so source
checkouts stay clean.
This commit is contained in:
@@ -0,0 +1,133 @@
|
||||
object MainForm: TMainForm
|
||||
Left = 0
|
||||
Top = 0
|
||||
Caption = 'Password Manager - Delphi Backend'
|
||||
ClientHeight = 720
|
||||
ClientWidth = 1100
|
||||
FormFactor.Width = 320
|
||||
FormFactor.Height = 480
|
||||
FormFactor.Devices = [Desktop]
|
||||
OnCreate = FormCreate
|
||||
OnDestroy = FormDestroy
|
||||
OnCloseQuery = FormCloseQuery
|
||||
DesignerMasterStyle = 0
|
||||
object PanelTop: TPanel
|
||||
Align = Top
|
||||
Size.Width = 1100.000000000000000000
|
||||
Size.Height = 56.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
TabOrder = 0
|
||||
object lblPort: TLabel
|
||||
Position.X = 16.000000000000000000
|
||||
Position.Y = 18.000000000000000000
|
||||
Size.Width = 40.000000000000000000
|
||||
Size.Height = 20.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
TextSettings.Trimming = None
|
||||
Text = 'Port:'
|
||||
TabOrder = 0
|
||||
end
|
||||
object edtPort: TEdit
|
||||
Touch.InteractiveGestures = [LongTap, DoubleTap]
|
||||
TabOrder = 1
|
||||
Text = '8765'
|
||||
Position.X = 56.000000000000000000
|
||||
Position.Y = 14.000000000000000000
|
||||
Size.Width = 80.000000000000000000
|
||||
Size.Height = 24.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
end
|
||||
object btnStart: TButton
|
||||
Position.X = 152.000000000000000000
|
||||
Position.Y = 14.000000000000000000
|
||||
Size.Width = 80.000000000000000000
|
||||
Size.Height = 24.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
TabOrder = 2
|
||||
Text = 'Start'
|
||||
TextSettings.Trimming = None
|
||||
OnClick = btnStartClick
|
||||
end
|
||||
object btnStop: TButton
|
||||
Position.X = 240.000000000000000000
|
||||
Position.Y = 14.000000000000000000
|
||||
Size.Width = 80.000000000000000000
|
||||
Size.Height = 24.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
TabOrder = 3
|
||||
Text = 'Stop'
|
||||
TextSettings.Trimming = None
|
||||
OnClick = btnStopClick
|
||||
end
|
||||
object btnReload: TButton
|
||||
Position.X = 328.000000000000000000
|
||||
Position.Y = 14.000000000000000000
|
||||
Size.Width = 80.000000000000000000
|
||||
Size.Height = 24.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
TabOrder = 4
|
||||
Text = 'Reload'
|
||||
TextSettings.Trimming = None
|
||||
OnClick = btnReloadClick
|
||||
end
|
||||
object btnToggleLog: TButton
|
||||
Position.X = 416.000000000000000000
|
||||
Position.Y = 14.000000000000000000
|
||||
Size.Width = 90.000000000000000000
|
||||
Size.Height = 24.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
TabOrder = 5
|
||||
Text = 'Hide log'
|
||||
TextSettings.Trimming = None
|
||||
OnClick = btnToggleLogClick
|
||||
end
|
||||
object lblStatus: TLabel
|
||||
Position.X = 520.000000000000000000
|
||||
Position.Y = 18.000000000000000000
|
||||
Size.Width = 560.000000000000000000
|
||||
Size.Height = 20.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
TextSettings.Trimming = None
|
||||
Text = 'Stopped'
|
||||
TabOrder = 6
|
||||
end
|
||||
end
|
||||
object PanelLog: TPanel
|
||||
Align = Bottom
|
||||
Position.Y = 564.000000000000000000
|
||||
Size.Width = 1100.000000000000000000
|
||||
Size.Height = 156.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
TabOrder = 1
|
||||
object Memo: TMemo
|
||||
Touch.InteractiveGestures = [Pan, LongTap, DoubleTap]
|
||||
DataDetectorTypes = []
|
||||
ReadOnly = True
|
||||
TextSettings.Font.Family = 'Consolas'
|
||||
Align = Client
|
||||
Size.Width = 1100.000000000000000000
|
||||
Size.Height = 156.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
TabOrder = 0
|
||||
Viewport.Width = 1096.000000000000000000
|
||||
Viewport.Height = 152.000000000000000000
|
||||
end
|
||||
end
|
||||
object Splitter: TSplitter
|
||||
Align = Bottom
|
||||
Cursor = crVSplit
|
||||
MinSize = 20.000000000000000000
|
||||
Position.Y = 558.000000000000000000
|
||||
Size.Width = 1100.000000000000000000
|
||||
Size.Height = 6.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
end
|
||||
object WebBrowser: TTMSFNCWebBrowser
|
||||
Align = Client
|
||||
Size.Width = 1100.000000000000000000
|
||||
Size.Height = 502.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
TabOrder = 3
|
||||
DesigntimeEnabled = False
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user