From 695dc158f390302c31ca15760b96aecf593a5126 Mon Sep 17 00:00:00 2001 From: CosmoX Date: Sun, 5 Jul 2026 01:03:57 -0700 Subject: [PATCH 1/2] Fix packaged Windows OAuth locale resources (#651) --- app/utilities/auth/githubOAuth.js | 20 +------------------- configs/electronLanguages.js | 16 +++++++--------- main.js | 29 ++--------------------------- package-lock.json | 4 ++-- package.json | 2 +- tests/utilities/githubOAuth.test.js | 24 +----------------------- tests/utilities/i18n.test.js | 21 ++++++++++++++++++--- 7 files changed, 32 insertions(+), 84 deletions(-) diff --git a/app/utilities/auth/githubOAuth.js b/app/utilities/auth/githubOAuth.js index 14b23853..4f40542a 100644 --- a/app/utilities/auth/githubOAuth.js +++ b/app/utilities/auth/githubOAuth.js @@ -1,6 +1,5 @@ const GITHUB_OAUTH_URL = 'https://github.com/login/oauth/authorize' const ELECTRON_ABORTED_LOAD_ERROR_CODE = -3 -const WINDOWS_GITHUB_OAUTH_DISABLED_CHROMIUM_FEATURES = ['RendererCodeIntegrity'] function normalizeScopes (scopes = []) { if (Array.isArray(scopes)) { @@ -100,20 +99,6 @@ function shouldIgnoreGitHubOAuthLoadFailure ({ return isAbortedLoadError(errorCode, errorDescription) || isMainFrame === false } -function shouldSandboxGitHubOAuthWindow (platform = process.platform) { - return platform !== 'win32' -} - -function shouldDisableGitHubOAuthHardwareAccelerationWorkaround (platform = process.platform) { - return platform === 'win32' -} - -function getGitHubOAuthDisabledChromiumFeaturesWorkaround (platform = process.platform) { - if (platform !== 'win32') return [] - - return WINDOWS_GITHUB_OAUTH_DISABLED_CHROMIUM_FEATURES.slice() -} - function isAbortedLoadError (errorCode, errorDescription) { return Number(errorCode) === ELECTRON_ABORTED_LOAD_ERROR_CODE || /\bERR_ABORTED\b|\(-3\)/.test(String(errorDescription || '')) @@ -132,8 +117,5 @@ module.exports = { buildGitHubOAuthUrl, describeGitHubOAuthUrl, parseGitHubOAuthCallback, - shouldIgnoreGitHubOAuthLoadFailure, - shouldDisableGitHubOAuthHardwareAccelerationWorkaround, - getGitHubOAuthDisabledChromiumFeaturesWorkaround, - shouldSandboxGitHubOAuthWindow + shouldIgnoreGitHubOAuthLoadFailure } diff --git a/configs/electronLanguages.js b/configs/electronLanguages.js index 92ba397c..4cd09527 100644 --- a/configs/electronLanguages.js +++ b/configs/electronLanguages.js @@ -1,15 +1,13 @@ -const scriptSpecificChineseResourceSuffixes = { - Hans: [67, 78], - Hant: [84, 87] +// Electron packages Chromium locale resources by .pak filename, which does not +// always match Lepton's app-facing locale id. +const electronLanguageOverrides = { + en: 'en-US', + 'zh-Hans': 'zh-CN', + 'zh-Hant': 'zh-TW' } function toElectronLanguage (locale) { - const [language, script] = locale.split('-') - const resourceSuffix = scriptSpecificChineseResourceSuffixes[script] - - return resourceSuffix - ? [language, String.fromCharCode(...resourceSuffix)].join('_') - : locale + return electronLanguageOverrides[locale] || locale } function getElectronLanguages (supportedLocales) { diff --git a/main.js b/main.js index 5cf4b6e4..e90b0b77 100755 --- a/main.js +++ b/main.js @@ -34,10 +34,7 @@ const { buildGitHubOAuthUrl, describeGitHubOAuthUrl, parseGitHubOAuthCallback, - shouldIgnoreGitHubOAuthLoadFailure, - shouldDisableGitHubOAuthHardwareAccelerationWorkaround, - getGitHubOAuthDisabledChromiumFeaturesWorkaround, - shouldSandboxGitHubOAuthWindow + shouldIgnoreGitHubOAuthLoadFailure } = require('./app/utilities/auth/githubOAuth') const { clearGitHubAuthWindowStorageAndDestroy @@ -45,7 +42,6 @@ const { const { applyDefaultZoomPercent } = require('./app/utilities/zoom') const logger = createMainLogger() -applyGitHubOAuthRenderWorkarounds() const electronLocalStorage = createElectronLocalStorage({ getUserDataPath: () => app.getPath('userData') }) @@ -86,25 +82,6 @@ const MACOS_TRAY_ICON_SIZE = 18 const shortcuts = nconf.get('shortcuts') -function applyGitHubOAuthRenderWorkarounds () { - const disableHardwareAcceleration = shouldDisableGitHubOAuthHardwareAccelerationWorkaround(process.platform) - const disabledChromiumFeatures = getGitHubOAuthDisabledChromiumFeaturesWorkaround(process.platform) - if (!disableHardwareAcceleration && disabledChromiumFeatures.length === 0) return - - if (disabledChromiumFeatures.length > 0) { - app.commandLine.appendSwitch('disable-features', disabledChromiumFeatures.join(',')) - } - - if (disableHardwareAcceleration) { - app.disableHardwareAcceleration() - } - - logger.info('[auth] Applied Electron render workarounds for Windows GitHub OAuth: ' + JSON.stringify({ - disabledChromiumFeatures, - hardwareAccelerationDisabled: disableHardwareAcceleration - })) -} - function getConfigPath() { if (process && process.env && process.env.XDG_CONFIG_HOME) { return path.join(process.env.XDG_CONFIG_HOME, '.leptonrc') @@ -727,7 +704,6 @@ function startGitHubAuthFlow ({ clientId, scopes } = {}) { }) } - const sandboxAuthWindow = shouldSandboxGitHubOAuthWindow(process.platform) const authWindow = new BrowserWindow({ parent: mainWindow, width: 400, @@ -737,7 +713,7 @@ function startGitHubAuthFlow ({ clientId, scopes } = {}) { nodeIntegration: false, enableRemoteModule: false, contextIsolation: true, - sandbox: sandboxAuthWindow, + sandbox: true, spellcheck: false } }) @@ -763,7 +739,6 @@ function startGitHubAuthFlow ({ clientId, scopes } = {}) { hasClientId: Boolean(clientId), clientIdLength: clientId.length, scopeCount: Array.isArray(scopes) ? scopes.length : 0, - sandbox: sandboxAuthWindow, authorizeUrl: describeGitHubOAuthUrl(authUrl) })) diff --git a/package-lock.json b/package-lock.json index 1964869b..cf5a9c62 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "Lepton", - "version": "2.0.0-beta.8", + "version": "2.0.0-beta.13", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "Lepton", - "version": "2.0.0-beta.8", + "version": "2.0.0-beta.13", "license": "MIT", "dependencies": { "@asciidoctor/core": "^2.2.9", diff --git a/package.json b/package.json index 606fd2b4..77140e7f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "Lepton", - "version": "2.0.0-beta.8", + "version": "2.0.0-beta.13", "description": "Democratizing Code Snippets Management (macOS/Win/Linux)", "productName": "Lepton", "main": "main.js", diff --git a/tests/utilities/githubOAuth.test.js b/tests/utilities/githubOAuth.test.js index 52cff4f6..e37be294 100644 --- a/tests/utilities/githubOAuth.test.js +++ b/tests/utilities/githubOAuth.test.js @@ -5,10 +5,7 @@ const { buildGitHubOAuthUrl, describeGitHubOAuthUrl, parseGitHubOAuthCallback, - shouldIgnoreGitHubOAuthLoadFailure, - shouldDisableGitHubOAuthHardwareAccelerationWorkaround, - getGitHubOAuthDisabledChromiumFeaturesWorkaround, - shouldSandboxGitHubOAuthWindow + shouldIgnoreGitHubOAuthLoadFailure } = githubOAuth describe('GitHub OAuth utility', () => { @@ -101,23 +98,4 @@ describe('GitHub OAuth utility', () => { isMainFrame: true })).toBe(false) }) - - it('uses a non-sandboxed OAuth auth window on Windows', () => { - expect(shouldSandboxGitHubOAuthWindow('win32')).toBe(false) - expect(shouldSandboxGitHubOAuthWindow('darwin')).toBe(true) - expect(shouldSandboxGitHubOAuthWindow('linux')).toBe(true) - }) - - it('disables hardware acceleration only for the Windows OAuth rendering workaround', () => { - expect(shouldDisableGitHubOAuthHardwareAccelerationWorkaround('win32')).toBe(true) - expect(shouldDisableGitHubOAuthHardwareAccelerationWorkaround('darwin')).toBe(false) - expect(shouldDisableGitHubOAuthHardwareAccelerationWorkaround('linux')).toBe(false) - }) - - it('disables Chromium renderer code integrity only for the Windows OAuth rendering workaround', () => { - expect(getGitHubOAuthDisabledChromiumFeaturesWorkaround('win32')) - .toEqual(['RendererCodeIntegrity']) - expect(getGitHubOAuthDisabledChromiumFeaturesWorkaround('darwin')).toEqual([]) - expect(getGitHubOAuthDisabledChromiumFeaturesWorkaround('linux')).toEqual([]) - }) }) diff --git a/tests/utilities/i18n.test.js b/tests/utilities/i18n.test.js index 7f06aad6..d3e662de 100644 --- a/tests/utilities/i18n.test.js +++ b/tests/utilities/i18n.test.js @@ -163,13 +163,28 @@ describe('i18n utilities', () => { expect(builderConfig.electronLanguages).toEqual(getElectronLanguages(getSupportedLocales())) }) - it('maps script-specific Chinese locales to Electron resource names', () => { + it('maps app locales to Electron resource names', () => { expect(getElectronLanguages([ + { code: 'en' }, { code: 'zh-Hans' }, { code: 'zh-Hant' } ])).toEqual([ - ['zh', String.fromCharCode(67, 78)].join('_'), - ['zh', String.fromCharCode(84, 87)].join('_') + 'en-US', + 'zh-CN', + 'zh-TW' + ]) + }) + + it('maps every supported locale to the expected Electron resource names', () => { + expect(getElectronLanguages(getSupportedLocales())).toEqual([ + 'en-US', + 'es', + 'fr', + 'ja', + 'ko', + 'tr', + 'zh-CN', + 'zh-TW' ]) }) From b45ea704dbd4d1e67ca0f46af7ba5f2dc9f0ea67 Mon Sep 17 00:00:00 2001 From: hackjutsu Date: Sun, 5 Jul 2026 01:06:04 -0700 Subject: [PATCH 2/2] Bump prerelease version to 2.0.0-beta.14 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index cf5a9c62..1e214bd5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "Lepton", - "version": "2.0.0-beta.13", + "version": "2.0.0-beta.14", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "Lepton", - "version": "2.0.0-beta.13", + "version": "2.0.0-beta.14", "license": "MIT", "dependencies": { "@asciidoctor/core": "^2.2.9", diff --git a/package.json b/package.json index 77140e7f..ffe05315 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "Lepton", - "version": "2.0.0-beta.13", + "version": "2.0.0-beta.14", "description": "Democratizing Code Snippets Management (macOS/Win/Linux)", "productName": "Lepton", "main": "main.js",