@@ -25,9 +25,6 @@ const ELECTRON_KDE_DESKTOP = "KDE";
2525// Chromium recognizes LXQt and still selects basic text for it, so it does need a forced backend.
2626const ELECTRON_UNPROTECTED_DESKTOPS = new Set ( [ "LXQt" ] ) ;
2727
28- const KDE_NAME_PREFIXES = [ "kde" , "plasma" ] ;
29- const NEGATIVE_FLAG_VALUES = new Set ( [ "0" , "false" , "no" , "off" ] ) ;
30-
3128export function normalizeLinuxPasswordStorePreference (
3229 value : unknown ,
3330) : LinuxPasswordStorePreference {
@@ -77,102 +74,6 @@ function electronSelectsProtectedBackend(env: NodeJS.ProcessEnv): boolean {
7774 return false ;
7875}
7976
80- export function resolveLinuxSecretStorageUnavailableMessage ( input : {
81- readonly configuredPreference : LinuxPasswordStorePreference ;
82- readonly selectedBackend : string | null ;
83- readonly env : NodeJS . ProcessEnv ;
84- } ) : string {
85- if ( input . configuredPreference === "gnome-libsecret" ) {
86- return getGnomeKeyringRemediationMessage ( ) ;
87- }
88-
89- if (
90- input . configuredPreference === "kwallet" ||
91- input . configuredPreference === "kwallet5" ||
92- input . configuredPreference === "kwallet6"
93- ) {
94- return getKWalletRemediationMessage ( ) ;
95- }
96-
97- const backend = normalizeSelectedStorageBackend ( input . selectedBackend ) ;
98- if ( backend === "gnome-libsecret" ) {
99- return getGnomeKeyringRemediationMessage ( ) ;
100- }
101-
102- if (
103- backend === "kwallet" ||
104- backend === "kwallet5" ||
105- backend === "kwallet6" ||
106- looksLikeKdeSession ( input . env )
107- ) {
108- return getKWalletRemediationMessage ( ) ;
109- }
110-
111- return getGnomeKeyringRemediationMessage ( ) ;
112- }
113-
114- function getGnomeKeyringRemediationMessage ( ) : string {
115- return "T3 Code could not access GNOME Keyring to save this environment credential. Install and start GNOME Keyring, then restart T3 Code." ;
116- }
117-
118- function getKWalletRemediationMessage ( ) : string {
119- return "T3 Code could not access KWallet to save this environment credential. Enable the KDE wallet subsystem in System Settings, then restart T3 Code." ;
120- }
121-
122- // Advisory only: this picks between the GNOME Keyring and KWallet wording in the failure notice. It
123- // never decides which backend to select, so a loose match costs a user slightly wrong instructions
124- // rather than an unprotected credential store.
125- function looksLikeKdeSession ( env : NodeJS . ProcessEnv ) : boolean {
126- const currentDesktopNames = nonEmptyDesktopNames ( env . XDG_CURRENT_DESKTOP ) ;
127- if ( currentDesktopNames . length > 0 ) {
128- return currentDesktopNames . some ( isKdeDesktopName ) ;
129- }
130-
131- const legacyNames = legacyDesktopNames ( env ) ;
132- if ( legacyNames . length > 0 ) {
133- return legacyNames . some ( isKdeDesktopName ) ;
134- }
135-
136- return isSet ( env . KDE_SESSION_VERSION ) || isAffirmativeFlag ( env . KDE_FULL_SESSION ) ;
137- }
138-
139- function isKdeDesktopName ( name : string ) : boolean {
140- return KDE_NAME_PREFIXES . some ( ( prefix ) => name . startsWith ( prefix ) ) ;
141- }
142-
143- function legacyDesktopNames ( env : NodeJS . ProcessEnv ) : string [ ] {
144- return [ env . XDG_SESSION_DESKTOP , env . DESKTOP_SESSION , env . GDMSESSION ] . flatMap ( ( entry ) => {
145- const normalized = normalizeDesktopName ( entry ) ;
146- return normalized ? [ normalized ] : [ ] ;
147- } ) ;
148- }
149-
150- function nonEmptyDesktopNames ( value : string | undefined ) : string [ ] {
151- return splitDesktopNameList ( value ) . flatMap ( ( entry ) => {
152- const normalized = normalizeDesktopName ( entry ) ;
153- return normalized ? [ normalized ] : [ ] ;
154- } ) ;
155- }
156-
157- function isSet ( value : string | undefined ) : boolean {
158- return Boolean ( value ?. trim ( ) ) ;
159- }
160-
161- function isAffirmativeFlag ( value : string | undefined ) : boolean {
162- const normalized = value ?. trim ( ) . toLowerCase ( ) ;
163- return normalized ? ! NEGATIVE_FLAG_VALUES . has ( normalized ) : false ;
164- }
165-
16677function splitDesktopNameList ( value : string | undefined ) : string [ ] {
16778 return value ?. split ( ":" ) ?? [ ] ;
16879}
169-
170- function normalizeDesktopName ( value : string | undefined ) : string | null {
171- const normalized = value ?. trim ( ) . toLowerCase ( ) ;
172- return normalized && normalized . length > 0 ? normalized : null ;
173- }
174-
175- function normalizeSelectedStorageBackend ( value : string | null ) : string | null {
176- const normalized = value ?. trim ( ) . toLowerCase ( ) . replace ( / _ / gu, "-" ) ;
177- return normalized && normalized . length > 0 ? normalized : null ;
178- }
0 commit comments