Skip to content

Commit be7d1f9

Browse files
committed
fix: trust ring in electron app was not getting shut down properly
1 parent 77fd2d9 commit be7d1f9

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

docs/appNotifications/readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,5 @@ A sample json is as follows:
5050
5. `PLATFORM`: A comma seperated list(no spaces) of all platforms in which the message will be shown.
5151
allowed values are: `mac,win,linux,allDesktop,firefox,chrome,safari,allBrowser,all`
5252
6. `USER_TYPE`: An array of all user types in which the message will be shown.
53-
allowed values are: [`all`, `notLoggedIn`, `loggedIn`, `trial`, `paidSubscriber`]. This filter is only available
54-
in versions > 5, else it is ignored in older versions. combine with `FOR_VERSIONS` to filter based on user type.
53+
allowed values are: [`all`, `notLoggedIn`, `loggedIn`, `trial`, `paidSubscriber`, `notPaidsubscriber`]. This filter
54+
is only available in versions > 5, else it is ignored in older versions. combine with `FOR_VERSIONS` to filter based on user type.

src-electron/main-cred-ipc.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ try {
1717
const PHOENIX_CRED_PREFIX = 'phcode_electron_';
1818

1919
function registerCredIpcHandlers() {
20-
// Trust window AES key - can only be called once per window
20+
// Trust window AES key - can only be called once per page load
2121
ipcMain.handle('trust-window-aes-key', (event, key, iv) => {
2222
assertTrusted(event);
2323
const webContentsId = event.sender.id;
@@ -140,4 +140,12 @@ function cleanupWindowTrust(webContentsId, windowLabel) {
140140
}
141141
}
142142

143-
module.exports = { registerCredIpcHandlers, cleanupWindowTrust };
143+
// Clear trust on navigation (page reload) - allows fresh trust to be established after reload
144+
function clearTrustOnNavigation(webContentsId, windowLabel) {
145+
if (windowTrustMap.has(webContentsId)) {
146+
windowTrustMap.delete(webContentsId);
147+
console.log(`AES trust cleared for navigation in window: ${windowLabel} (webContentsId: ${webContentsId})`);
148+
}
149+
}
150+
151+
module.exports = { registerCredIpcHandlers, cleanupWindowTrust, clearTrustOnNavigation };

src-electron/main-window-ipc.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const { ipcMain, BrowserWindow, shell, clipboard } = require('electron');
22
const path = require('path');
33
const { spawn } = require('child_process');
4-
const { cleanupWindowTrust } = require('./main-cred-ipc');
4+
const { cleanupWindowTrust, clearTrustOnNavigation } = require('./main-cred-ipc');
55
const { isTrustedOrigin, updateTrustStatus, cleanupTrust, assertTrusted } = require('./ipc-security');
66
const { DEFAULTS, trackWindowState } = require('./window-state');
77

@@ -39,6 +39,14 @@ function registerWindow(win, label) {
3939
// Initial trust evaluation
4040
updateTrustStatus(webContents);
4141

42+
// Clear AES trust before navigation starts (page reload/navigate)
43+
// This allows the new page to establish fresh trust with its own keys
44+
webContents.on('did-start-navigation', (event, url, isInPlace, isMainFrame) => {
45+
if (isMainFrame) {
46+
clearTrustOnNavigation(webContentsId, label);
47+
}
48+
});
49+
4250
// Re-evaluate trust on navigation
4351
webContents.on('did-navigate', () => {
4452
updateTrustStatus(webContents);

0 commit comments

Comments
 (0)