|
1 | 1 | import React, { createContext, useCallback, useContext, useMemo, useState } from 'react'; |
2 | 2 | import { |
3 | 3 | buildConnectionCandidates, |
| 4 | + canAutoRestoreConnectionProfile, |
4 | 5 | createDefaultConnectionProfileDraft, |
5 | 6 | finalizeConnectionProfile, |
6 | 7 | isExplicitHttpUrl, |
7 | 8 | normalizeConnectionProfileDraft, |
8 | 9 | parsePangolinAccessToken, |
9 | 10 | parseStoredConnectionProfile, |
10 | 11 | serializeConnectionProfile, |
| 12 | + stripSensitiveConnectionFields, |
11 | 13 | type ConnectionMode, |
12 | 14 | type ConnectionProfile, |
13 | 15 | type ConnectionProfileDraft, |
@@ -35,7 +37,7 @@ function readInitialConnectionProfile(): ConnectionProfile | null { |
35 | 37 | const stored = parseStoredConnectionProfile( |
36 | 38 | localStorage.getItem(CONNECTION_PROFILE_KEY), |
37 | 39 | ); |
38 | | - if (stored) return stored; |
| 40 | + if (stored && canAutoRestoreConnectionProfile(stored)) return stored; |
39 | 41 |
|
40 | 42 | const legacyBaseUrl = localStorage.getItem(LEGACY_BASE_URL_KEY); |
41 | 43 | if (!legacyBaseUrl) return null; |
@@ -162,7 +164,9 @@ export const ApiProvider: React.FC<{ children: React.ReactNode }> = ({ |
162 | 164 | setConnectionProfile(candidateProfile); |
163 | 165 | localStorage.setItem( |
164 | 166 | CONNECTION_PROFILE_KEY, |
165 | | - serializeConnectionProfile(candidateProfile), |
| 167 | + serializeConnectionProfile( |
| 168 | + stripSensitiveConnectionFields(candidateProfile), |
| 169 | + ), |
166 | 170 | ); |
167 | 171 | localStorage.removeItem(LEGACY_BASE_URL_KEY); |
168 | 172 | localStorage.removeItem(LEGACY_INSECURE_KEY); |
|
0 commit comments