Skip to content

Commit b111b77

Browse files
SYM01dependabot[bot]transifex-integration[bot]jimchan3301
authored
v1.3.1: Minor fixes for Firefox & Edge (#56)
* update github action * minor change to System profile * Build(deps): Bump nanoid from 3.3.7 to 3.3.8 (#21) Bumps [nanoid](https://github.com/ai/nanoid) from 3.3.7 to 3.3.8. - [Release notes](https://github.com/ai/nanoid/releases) - [Changelog](https://github.com/ai/nanoid/blob/main/CHANGELOG.md) - [Commits](ai/nanoid@3.3.7...3.3.8) --- updated-dependencies: - dependency-name: nanoid dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Avoid blocking 401 authentication request (#22) (#23) * fix 401 issue (#22) * enablle github action on develop branch * Support Firefox (#18) * Adapt firefox * support firefore auto publish * support firefox, and optimized UX * [i18n] Updates for file public/_locales/en/messages.json (#25) * [i18n] Translate messages.json in pt_BR 100% reviewed source file: 'messages.json' on 'pt_BR'. * [i18n] Translate messages.json in zh_CN 100% reviewed source file: 'messages.json' on 'zh_CN'. * [i18n] Translate messages.json in zh_TW 100% reviewed source file: 'messages.json' on 'zh_TW'. * [i18n] Translate messages.json in pt_BR 100% reviewed source file: 'messages.json' on 'pt_BR'. * update English i18n msg --------- Co-authored-by: transifex-integration[bot] <43880903+transifex-integration[bot]@users.noreply.github.com> Co-authored-by: SYM01 <33443792+SYM01@users.noreply.github.com> * sentry integration (#29) * [WIP] support exporting * [WIP] support import/export settings (#7) * Support import/export profiles and close #7 (#30) * implemented an utility to export/import settings * optimized description * [i18n] Updates for file public/_locales/en/messages.json (#32) * [i18n] Translate messages.json in pt_BR 100% reviewed source file: 'messages.json' on 'pt_BR'. * [i18n] Translate messages.json in zh_TW 100% reviewed source file: 'messages.json' on 'zh_TW'. * [i18n] Translate messages.json in zh_CN 100% reviewed source file: 'messages.json' on 'zh_CN'. --------- Co-authored-by: transifex-integration[bot] <43880903+transifex-integration[bot]@users.noreply.github.com> * fix an import issue (#33) (#35) * optimized sentry release * Optimize Development Flow (#37) * [WIP] support chrome auto deploy * finalize Chrome auto deploy * npm audit fix * npm audit fix * UX improvement and close #28 (#38) * minor bug fixed * improve UX and close #28 * use the same CIDR validator as PAC script * [i18n] Updates for file public/_locales/en/messages.json (#40) * [i18n] Translate messages.json in pt_BR 100% reviewed source file: 'messages.json' on 'pt_BR'. * [i18n] Translate messages.json in zh_TW 100% reviewed source file: 'messages.json' on 'zh_TW'. * [i18n] Translate messages.json in zh_CN 100% reviewed source file: 'messages.json' on 'zh_CN'. --------- Co-authored-by: transifex-integration[bot] <43880903+transifex-integration[bot]@users.noreply.github.com> * Support Authentication in Auto Switch Profiles, fixing #34 (#45) * update deps * fix the auth issue in auto switch profiles * fix typo * Support Profile Detection for the Auto Profiles (#42) (#50) * [WIP] Reflect current profile when using auto profile (#42) * Show detected profile in the popup * simplify test cases * [i18n] Updates for file public/_locales/en/messages.json (#52) * [i18n] Translate messages.json in zh_TW 100% reviewed source file: 'messages.json' on 'zh_TW'. * [i18n] Translate messages.json in zh_CN 100% reviewed source file: 'messages.json' on 'zh_CN'. * [i18n] Translate messages.json in pt_BR 100% reviewed source file: 'messages.json' on 'pt_BR'. --------- Co-authored-by: transifex-integration[bot] <43880903+transifex-integration[bot]@users.noreply.github.com> * Improve browser detection Replace generic proxy API detection with Firefox-specific runtime.getBrowserInfo method for more reliable browser identification. * fix the object clone issue, close #49 --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: transifex-integration[bot] <43880903+transifex-integration[bot]@users.noreply.github.com> Co-authored-by: Jim Chan <me@schiznitz.com>
1 parent 37f28af commit b111b77

4 files changed

Lines changed: 23 additions & 7 deletions

File tree

src/adapters/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ import { Firefox } from "./firefox";
44
import { WebBrowser } from "./web";
55

66
function chooseAdapter(): BaseAdapter {
7-
// Firefox supports browser.* and chrome.* APIs
8-
// https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Chrome_incompatibilities
9-
if (globalThis.browser?.proxy) {
7+
// Detect Firefox specifically using browser.runtime.getBrowserInfo
8+
// This is a Firefox-specific API that doesn't exist in Chrome/Edge
9+
// https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/getBrowserInfo
10+
if (typeof globalThis.browser?.runtime?.getBrowserInfo === "function") {
1011
return new Firefox();
1112
}
1213

src/services/profile.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Host, PacScript, SimpleProxyServer } from "@/adapters";
2+
import { deepClone } from "./utils";
23

34
export type ProxyAuthInfo = {
45
username: string;
@@ -103,7 +104,9 @@ export function onProfileUpdate(callback: (p: ProfilesStorage) => void) {
103104
}
104105

105106
async function overwriteProfiles(profiles: ProfilesStorage) {
106-
await Host.set(keyProfileStorage, profiles);
107+
// Deep clone to remove any Proxy objects before saving
108+
const clonedProfiles = deepClone(profiles);
109+
await Host.set(keyProfileStorage, clonedProfiles);
107110
onProfileUpdateListeners.map((cb) => cb(profiles));
108111
}
109112

@@ -115,14 +118,16 @@ async function overwriteProfiles(profiles: ProfilesStorage) {
115118
*/
116119
export async function saveProfile(profile: ProxyProfile) {
117120
const data = await listProfiles();
118-
data[profile.profileID] = profile;
121+
// Deep clone the profile to remove any Proxy objects before saving
122+
data[profile.profileID] = deepClone(profile);
119123
await overwriteProfiles(data);
120124
}
121125

122126
export async function saveManyProfiles(profiles: ProxyProfile[]) {
123127
let data = await listProfiles();
124128
profiles.forEach((p) => {
125-
data[p.profileID] = p;
129+
// Deep clone each profile to remove any Proxy objects before saving
130+
data[p.profileID] = deepClone(p);
126131
});
127132
await overwriteProfiles(data);
128133
}

src/services/proxy/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
import { ProxySettingResultDetails } from "@/adapters";
1010
import { ProfileConverter } from "./profile2config";
1111
import { ProfileAuthProvider } from "./auth";
12+
import { deepClone } from "../utils";
1213

1314
export type ProxySetting = {
1415
activeProfile?: ProxyProfile;
@@ -56,7 +57,8 @@ export async function setProxy(val: ProxyProfile) {
5657
break;
5758
}
5859

59-
await Host.set<ProxyProfile>(keyActiveProfile, val);
60+
// Deep clone to remove any Proxy objects before saving
61+
await Host.set<ProxyProfile>(keyActiveProfile, deepClone(val));
6062
}
6163

6264
/**

src/services/utils.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* Deep clone an object to remove all Proxy objects (e.g., from Vue reactivity).
3+
* This is necessary because chrome.storage and browser.storage use structured clone
4+
* which cannot clone Proxy objects.
5+
*/
6+
export function deepClone<T>(obj: T): T {
7+
return JSON.parse(JSON.stringify(obj));
8+
}

0 commit comments

Comments
 (0)