From 41dfe7a8ed8c073d84f6a4718edd9da173315b79 Mon Sep 17 00:00:00 2001 From: xweiba Date: Mon, 10 Aug 2026 13:35:47 +0800 Subject: [PATCH] feat: unify app and third-party wloc features --- .gitignore | 3 + App/FirstSetupView.swift | 5 + App/ProxyManager.swift | 35 +- App/SettingsView.swift | 53 ++ Core/bridge.go | 16 +- Core/proxy.go | 29 +- Core/wloc_patch.go | 37 +- Core/wloc_patch_test.go | 69 +++ Resources/ThirdPartyProxyModules/wloc.conf | 8 +- Resources/ThirdPartyProxyModules/wloc.lpx | 9 +- Resources/ThirdPartyProxyModules/wloc.module | 9 +- .../ThirdPartyProxyModules/wloc.sgmodule | 8 +- .../ThirdPartyProxyModules/wloc.stoverride | 12 +- Shared/AppGroup.swift | 44 ++ Shared/ThirdPartyProxyManager.swift | 102 +++- .../MotionSimulationStoreTests.swift | 17 + .../ThirdPartyModuleSourceStoreTests.swift | 17 + .../ThirdPartyProxyManagerTests.swift | 29 +- ThirdParty/WlocScripts/THIRD_PARTY_NOTICES.md | 6 + ThirdParty/WlocScripts/build.mjs | 19 + .../WlocScripts/dist/v1/wloc-settings.js | 1 + ThirdParty/WlocScripts/dist/v1/wloc.js | 6 + .../WlocScripts/modules/direct/wloc.conf | 11 + .../WlocScripts/modules/direct/wloc.lpx | 11 + .../WlocScripts/modules/direct/wloc.module | 12 + .../WlocScripts/modules/direct/wloc.sgmodule | 12 + .../modules/direct/wloc.stoverride | 31 ++ ThirdParty/WlocScripts/package-lock.json | 508 ++++++++++++++++++ ThirdParty/WlocScripts/package.json | 16 + ThirdParty/WlocScripts/src/core.js | 263 +++++++++ ThirdParty/WlocScripts/src/response-entry.js | 26 + ThirdParty/WlocScripts/src/runtime.js | 109 ++++ ThirdParty/WlocScripts/src/settings-entry.js | 48 ++ .../test/bundle-compatibility.test.js | 52 ++ ThirdParty/WlocScripts/test/core.test.js | 85 +++ docs/THIRD_PARTY_MODULES.md | 57 +- 36 files changed, 1702 insertions(+), 73 deletions(-) create mode 100644 Tests/PaopaoLocationSpooferTests/MotionSimulationStoreTests.swift create mode 100644 Tests/PaopaoLocationSpooferTests/ThirdPartyModuleSourceStoreTests.swift create mode 100644 ThirdParty/WlocScripts/THIRD_PARTY_NOTICES.md create mode 100644 ThirdParty/WlocScripts/build.mjs create mode 100644 ThirdParty/WlocScripts/dist/v1/wloc-settings.js create mode 100644 ThirdParty/WlocScripts/dist/v1/wloc.js create mode 100644 ThirdParty/WlocScripts/modules/direct/wloc.conf create mode 100644 ThirdParty/WlocScripts/modules/direct/wloc.lpx create mode 100644 ThirdParty/WlocScripts/modules/direct/wloc.module create mode 100644 ThirdParty/WlocScripts/modules/direct/wloc.sgmodule create mode 100644 ThirdParty/WlocScripts/modules/direct/wloc.stoverride create mode 100644 ThirdParty/WlocScripts/package-lock.json create mode 100644 ThirdParty/WlocScripts/package.json create mode 100644 ThirdParty/WlocScripts/src/core.js create mode 100644 ThirdParty/WlocScripts/src/response-entry.js create mode 100644 ThirdParty/WlocScripts/src/runtime.js create mode 100644 ThirdParty/WlocScripts/src/settings-entry.js create mode 100644 ThirdParty/WlocScripts/test/bundle-compatibility.test.js create mode 100644 ThirdParty/WlocScripts/test/core.test.js diff --git a/.gitignore b/.gitignore index 40d24b6..a852710 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,9 @@ .superpowers/ build/ dist/ +!ThirdParty/WlocScripts/dist/ +!ThirdParty/WlocScripts/dist/** +node_modules/ DerivedData/ xcuserdata/ *.xcuserstate diff --git a/App/FirstSetupView.swift b/App/FirstSetupView.swift index b521983..76a50a3 100644 --- a/App/FirstSetupView.swift +++ b/App/FirstSetupView.swift @@ -818,10 +818,14 @@ struct FirstSetupView: View { Task { @MainActor in defer { isVerifying = false } do { + let version = try await thirdPartyProxy.validateVersion() let response = try await thirdPartyProxy.query() let elapsedMilliseconds = Int(Date().timeIntervalSince(startedAt) * 1_000) RuntimeLogger.info("APP", "ThirdPartyProxy", "第三方代理连接检测通过", details: [ "当前客户端": client.name, + "模块版本": version.moduleVersion, + "协议版本": String(version.protocolVersion), + "能力": version.capabilities.sorted().joined(separator: ","), "请求动作": "WLOC query", "连接状态": response.latitude == nil || response.longitude == nil ? "已连接,无保存坐标" : "已连接,有保存坐标", "耗时毫秒": String(elapsedMilliseconds) @@ -849,6 +853,7 @@ struct FirstSetupView: View { message: """ ======== 第三方代理连接检测 ======== 当前客户端:\(client.name) + 版本接口:/wloc-settings/version 请求动作:WLOC query 检查范围:模块拦截、MITM、证书、代理/VPN 连接 连接状态:\(connectionState) diff --git a/App/ProxyManager.swift b/App/ProxyManager.swift index e304eef..e2e0cfe 100644 --- a/App/ProxyManager.swift +++ b/App/ProxyManager.swift @@ -25,12 +25,21 @@ final class ProxyManager: ObservableObject { let lon = settings.flatMap { $0.enabled ? $0.longitude : nil } ?? 0 let enabled = (settings?.enabled ?? false) ? CInt(1) : CInt(0) let accuracy = CInt(settings?.accuracy ?? 25) + let motionEnabled = MotionSimulationStore.shared.isEnabled ? CInt(1) : CInt(0) if enabled != 0 { RuntimeLogger.info("APP", "坐标转换", "启动代理: 恢复上次 WGS-84 定位") } let result: UInt = authority.certPEM.withCString { cp in authority.keyPEM.withCString { kp in - UInt(wloccore_startproxy(UnsafeMutablePointer(mutating: cp), UnsafeMutablePointer(mutating: kp), CDouble(lat), CDouble(lon), enabled, accuracy)) + UInt(wloccore_startproxyv2( + UnsafeMutablePointer(mutating: cp), + UnsafeMutablePointer(mutating: kp), + CDouble(lat), + CDouble(lon), + enabled, + accuracy, + motionEnabled + )) } } guard result != 0 else { CoreBridge.flushLogs(category: "Proxy"); throw ProxyError.startFailed } @@ -58,7 +67,13 @@ final class ProxyManager: ObservableObject { @discardableResult func setCoords(lat: Double, lon: Double, enabled: Bool, accuracy: Int = 25) -> UInt64 { coordinateRevision &+= 1 - wloccore_setcoords(CDouble(lat), CDouble(lon), enabled ? 1 : 0, CInt(accuracy)) + wloccore_setpatchconfig( + CDouble(lat), + CDouble(lon), + enabled ? 1 : 0, + CInt(accuracy), + MotionSimulationStore.shared.isEnabled ? 1 : 0 + ) RuntimeLogger.info("APP", "Proxy.coords", "写入坐标", details: [ "revision": String(coordinateRevision), "enabled": String(enabled), @@ -119,6 +134,22 @@ final class ProxyManager: ObservableObject { return (Double(r.r0), Double(r.r1), r.r2 != 0) } + func applyMotionSimulation(_ enabled: Bool) { + MotionSimulationStore.shared.setEnabled(enabled) + let settings = WlocSettingsStore.load() + wloccore_setpatchconfig( + CDouble(settings?.latitude ?? 0), + CDouble(settings?.longitude ?? 0), + settings?.enabled == true ? 1 : 0, + CInt(settings?.accuracy ?? 25), + enabled ? 1 : 0 + ) + RuntimeLogger.info("APP", "Proxy.motion", "运动状态模拟设置已更新", details: [ + "enabled": String(enabled) + ]) + CoreBridge.flushLogs(category: "Proxy") + } + func prepareCertificateDownloadURL() async -> URL? { do { if !isRunning { try await start() } diff --git a/App/SettingsView.swift b/App/SettingsView.swift index b43b986..be6d930 100644 --- a/App/SettingsView.swift +++ b/App/SettingsView.swift @@ -7,6 +7,8 @@ struct SettingsView: View { @ObservedObject private var runtimeMode = ProxyRuntimeModeStore.shared @ObservedObject private var thirdPartyProxy = ThirdPartyProxyManager.shared @ObservedObject private var thirdPartyClient = ThirdPartyProxyClientStore.shared + @ObservedObject private var motionSimulation = MotionSimulationStore.shared + @ObservedObject private var moduleSource = ThirdPartyModuleSourceStore.shared @Environment(\.dismiss) private var dismiss @State private var activeTip: TipKind? @State private var proxyOperationError = "" @@ -62,6 +64,14 @@ struct SettingsView: View { } } + Section("定位模拟") { + Toggle("运动状态模拟", isOn: motionSimulationBinding) + .disabled(modeOperationRunning || actions.state.isBusy || thirdPartyProxy.isRequesting) + Text("实验性功能,默认关闭。开启后会同时模拟定位响应中的运动状态。") + .font(.footnote) + .foregroundStyle(.secondary) + } + if runtimeMode.mode == .thirdParty { thirdPartyConfigurationSection } else { @@ -248,6 +258,39 @@ struct SettingsView: View { ) } + private var motionSimulationBinding: Binding { + Binding( + get: { motionSimulation.isEnabled }, + set: { enabled in + if runtimeMode.mode == .localWiFi { + proxy.applyMotionSimulation(enabled) + return + } + guard thirdPartyProxy.activeSettings?.success == true else { + motionSimulation.setEnabled(enabled) + return + } + modeOperationRunning = true + Task { @MainActor in + do { + _ = try await thirdPartyProxy.updateMotionSimulation(enabled) + motionSimulation.setEnabled(enabled) + } catch { + RuntimeLogger.error( + "APP", + "ThirdPartyProxy", + "同步运动状态设置失败", + error: error, + details: ["当前客户端": thirdPartyClient.selectedClient.name] + ) + setup.requestThirdPartySetup(message: error.localizedDescription) + } + modeOperationRunning = false + } + } + ) + } + @ViewBuilder private var thirdPartyConfigurationSection: some View { Section("第三方代理配置") { @@ -260,6 +303,14 @@ struct SettingsView: View { } } + Toggle("使用国内镜像下载模块", isOn: Binding( + get: { moduleSource.useMirror }, + set: { moduleSource.setUseMirror($0) } + )) + Text("仅影响之后复制和重新导入的模块地址;已安装模块需要重新导入后切换来源。") + .font(.footnote) + .foregroundStyle(.secondary) + if let verificationText = thirdPartyClient.selectedClient.verificationText { HStack { Text("验证状态") @@ -353,6 +404,7 @@ struct SettingsView: View { runtimeMode.setMode(.thirdParty) if runtimeMode.isInitialized(.thirdParty) { do { + _ = try await thirdPartyProxy.validateVersion() _ = try await thirdPartyProxy.query() proxyOperationAlertTitle = "模式已切换" proxyOperationError = "第三方代理模式检测通过。请关闭 Wi-Fi 中的 127.0.0.1:8888 手动代理,避免双重拦截。" @@ -395,6 +447,7 @@ struct SettingsView: View { let startedAt = Date() Task { @MainActor in do { + _ = try await thirdPartyProxy.validateVersion() _ = try await thirdPartyProxy.query() RuntimeLogger.info("APP", "ThirdPartyProxy", "设置页第三方连接检测通过", details: [ "当前客户端": client.name, diff --git a/Core/bridge.go b/Core/bridge.go index 5d7c9e4..f121d0d 100644 --- a/Core/bridge.go +++ b/Core/bridge.go @@ -55,6 +55,11 @@ func wloccore_validateca(certData, keyData *C.char) C.int { //export wloccore_startproxy func wloccore_startproxy(certData, keyData *C.char, lat, lon C.double, enabled C.int, accuracy C.int) C.uintptr_t { + return wloccore_startproxyv2(certData, keyData, lat, lon, enabled, accuracy, 0) +} + +//export wloccore_startproxyv2 +func wloccore_startproxyv2(certData, keyData *C.char, lat, lon C.double, enabled C.int, accuracy C.int, motionEnabled C.int) C.uintptr_t { if certData == nil || keyData == nil { return 0 } @@ -65,6 +70,7 @@ func wloccore_startproxy(certData, keyData *C.char, lat, lon C.double, enabled C float64(lon), enabled != 0, int(accuracy), + motionEnabled != 0, ) if err != nil { logEvent("startproxy failed: " + err.Error()) @@ -106,13 +112,21 @@ func proxyForHandle(h C.uintptr_t) (server *http.Server, handle cgo.Handle, ok b //export wloccore_setcoords func wloccore_setcoords(lat, lon C.double, enabled C.int, accuracy C.int) { + wloccore_setpatchconfig(lat, lon, enabled, accuracy, 0) +} + +//export wloccore_setpatchconfig +func wloccore_setpatchconfig(lat, lon C.double, enabled C.int, accuracy C.int, motionEnabled C.int) { stateMu.Lock() currentLat = float64(lat) currentLon = float64(lon) currentEnabled = enabled != 0 currentAccuracy = int(accuracy) + currentMotionSimulationEnabled = motionEnabled != 0 stateMu.Unlock() - logEvent("setcoords enabled=" + strconv.FormatBool(enabled != 0) + " accuracy=" + strconv.Itoa(int(accuracy))) + logEvent("setpatchconfig enabled=" + strconv.FormatBool(enabled != 0) + + " accuracy=" + strconv.Itoa(int(accuracy)) + + " motion=" + strconv.FormatBool(motionEnabled != 0)) } //export wloccore_getcoords diff --git a/Core/proxy.go b/Core/proxy.go index fa6a87b..9c20d29 100644 --- a/Core/proxy.go +++ b/Core/proxy.go @@ -22,13 +22,14 @@ import ( const proxyPort = 8888 var ( - stateMu sync.Mutex - currentLat float64 - currentLon float64 - currentEnabled bool - currentAccuracy int - globalCACert *tls.Certificate - verifyToken string + stateMu sync.Mutex + currentLat float64 + currentLon float64 + currentEnabled bool + currentAccuracy int + currentMotionSimulationEnabled bool + globalCACert *tls.Certificate + verifyToken string logMu sync.Mutex logEntries []string @@ -94,10 +95,10 @@ func newProxy(cert *tls.Certificate) *goproxy.ProxyHttpServer { } if r.URL.Path == "/coords" { stateMu.Lock() - enabled, lat, lon, accuracy := currentEnabled, currentLat, currentLon, currentAccuracy + enabled, lat, lon, accuracy, motionEnabled := currentEnabled, currentLat, currentLon, currentAccuracy, currentMotionSimulationEnabled stateMu.Unlock() w.Header().Set("Content-Type", "application/json") - w.Write([]byte(fmt.Sprintf(`{"enabled":%t,"lat":%.6f,"lon":%.6f,"accuracy":%d}`, enabled, lat, lon, accuracy))) + w.Write([]byte(fmt.Sprintf(`{"enabled":%t,"lat":%.6f,"lon":%.6f,"accuracy":%d,"motionSimulationEnabled":%t}`, enabled, lat, lon, accuracy, motionEnabled))) return } if r.URL.Path == "/proxy.mobileconfig" || r.URL.Path == "/proxy.mobileconfig/" { @@ -221,7 +222,7 @@ func patchWlocResponse(resp *http.Response, ctx *goproxy.ProxyCtx) *http.Respons } stateMu.Lock() - enabled, lat, lon, accuracy := currentEnabled, currentLat, currentLon, currentAccuracy + enabled, lat, lon, accuracy, motionEnabled := currentEnabled, currentLat, currentLon, currentAccuracy, currentMotionSimulationEnabled stateMu.Unlock() const maxPatchBodyBytes int64 = 1 << 20 @@ -249,7 +250,10 @@ func patchWlocResponse(resp *http.Response, ctx *goproxy.ProxyCtx) *http.Respons return resp } - patched, stats, err := patchResponseBody(body, wlocCoords{Latitude: lat, Longitude: lon, Accuracy: accuracy}) + patched, stats, err := patchResponseBody(body, wlocCoords{ + Latitude: lat, Longitude: lon, Accuracy: accuracy, + MotionSimulationEnabled: motionEnabled, + }) if err != nil || bytes.Equal(patched, body) { if err != nil { logEvent("wloc patch skipped: " + err.Error()) @@ -326,7 +330,7 @@ func randomUint32() uint32 { return uint32(b[0])<<24 | uint32(b[1])<<16 | uint32(b[2])<<8 | uint32(b[3]) } -func startProxy(certPEM, keyPEM []byte, lat, lon float64, enabled bool, accuracy int) (*http.Server, error) { +func startProxy(certPEM, keyPEM []byte, lat, lon float64, enabled bool, accuracy int, motionEnabled bool) (*http.Server, error) { cert, err := parseCA(certPEM, keyPEM) if err != nil { return nil, err @@ -335,6 +339,7 @@ func startProxy(certPEM, keyPEM []byte, lat, lon float64, enabled bool, accuracy stateMu.Lock() globalCACert = cert currentLat, currentLon, currentEnabled, currentAccuracy = lat, lon, enabled, accuracy + currentMotionSimulationEnabled = motionEnabled stateMu.Unlock() listener, err := net.Listen("tcp", fmt.Sprintf("127.0.0.1:%d", proxyPort)) diff --git a/Core/wloc_patch.go b/Core/wloc_patch.go index 0867abe..5bc50ca 100644 --- a/Core/wloc_patch.go +++ b/Core/wloc_patch.go @@ -20,11 +20,17 @@ const ( ) type wlocCoords struct { - Latitude float64 - Longitude float64 - Accuracy int + Latitude float64 + Longitude float64 + Accuracy int + MotionSimulationEnabled bool } +const ( + motionActivityType = 63 + motionActivityConfidence = 467 +) + type patchStats struct { WiFi int Cell int @@ -179,6 +185,7 @@ func patchLocation(loc []byte, c wlocCoords) ([]byte, bool, error) { lon := int64(math.Round(c.Longitude * 1e8)) var out []byte changed := false + hasMotionType, hasMotionConfidence := false, false for _, f := range fields { switch { case f.num == 1 && f.wireType == wireVarint: @@ -199,10 +206,34 @@ func patchLocation(loc []byte, c wlocCoords) ([]byte, bool, error) { changed = true } out = append(out, raw...) + case c.MotionSimulationEnabled && f.num == 11 && f.wireType == wireVarint: + hasMotionType = true + raw := append(writeTag(11, wireVarint), writeVarint(motionActivityType)...) + if !bytes.Equal(raw, f.raw) { + changed = true + } + out = append(out, raw...) + case c.MotionSimulationEnabled && f.num == 12 && f.wireType == wireVarint: + hasMotionConfidence = true + raw := append(writeTag(12, wireVarint), writeVarint(motionActivityConfidence)...) + if !bytes.Equal(raw, f.raw) { + changed = true + } + out = append(out, raw...) default: out = append(out, f.raw...) } } + if c.MotionSimulationEnabled && !hasMotionType { + out = append(out, writeTag(11, wireVarint)...) + out = append(out, writeVarint(motionActivityType)...) + changed = true + } + if c.MotionSimulationEnabled && !hasMotionConfidence { + out = append(out, writeTag(12, wireVarint)...) + out = append(out, writeVarint(motionActivityConfidence)...) + changed = true + } return out, changed, nil } diff --git a/Core/wloc_patch_test.go b/Core/wloc_patch_test.go index bcc66a2..dbe3883 100644 --- a/Core/wloc_patch_test.go +++ b/Core/wloc_patch_test.go @@ -25,6 +25,15 @@ func testLocation(lat, lon int64, accuracy uint64) []byte { return out } +func testLocationWithMotion(lat, lon int64, accuracy, motionType, motionConfidence uint64) []byte { + out := testLocation(lat, lon, accuracy) + out = append(out, writeTag(11, wireVarint)...) + out = append(out, writeVarint(motionType)...) + out = append(out, writeTag(12, wireVarint)...) + out = append(out, writeVarint(motionConfidence)...) + return out +} + func testWifiDevice(loc []byte) []byte { mac := []byte("aa:bb:cc:dd:ee:ff") var out []byte @@ -113,6 +122,66 @@ func TestPatchCellLocation(t *testing.T) { } } +func TestMotionSimulationDisabledPreservesFields(t *testing.T) { + original := testLocationWithMotion(100, 200, 25, 7, 88) + patched, changed, err := patchLocation(original, wlocCoords{ + Latitude: 31.230416, Longitude: 121.473701, Accuracy: 50, + }) + if err != nil { + t.Fatal(err) + } + if !changed { + t.Fatal("coordinates were not patched") + } + fields, err := parseFields(patched) + if err != nil { + t.Fatal(err) + } + for _, field := range fields { + if (field.num == 11 || field.num == 12) && !bytes.Contains(original, field.raw) { + t.Fatalf("motion field %d changed while disabled", field.num) + } + } +} + +func TestMotionSimulationEnabledReplacesFields(t *testing.T) { + original := testLocationWithMotion(100, 200, 25, 7, 88) + patched, _, err := patchLocation(original, wlocCoords{ + Latitude: 31.230416, Longitude: 121.473701, Accuracy: 50, + MotionSimulationEnabled: true, + }) + if err != nil { + t.Fatal(err) + } + if !bytes.Contains(patched, append(writeTag(11, wireVarint), writeVarint(motionActivityType)...)) { + t.Fatal("motion activity type was not replaced") + } + if !bytes.Contains(patched, append(writeTag(12, wireVarint), writeVarint(motionActivityConfidence)...)) { + t.Fatal("motion activity confidence was not replaced") + } +} + +func TestMotionSimulationEnabledAddsMissingFields(t *testing.T) { + patched, _, err := patchLocation(testLocation(100, 200, 25), wlocCoords{ + Latitude: 31.230416, Longitude: 121.473701, Accuracy: 50, + MotionSimulationEnabled: true, + }) + if err != nil { + t.Fatal(err) + } + fields, err := parseFields(patched) + if err != nil { + t.Fatal(err) + } + counts := map[int]int{} + for _, field := range fields { + counts[field.num]++ + } + if counts[11] != 1 || counts[12] != 1 { + t.Fatalf("expected one inserted motion field each, got %+v", counts) + } +} + func TestPatchARPCFramePreservesEnvelopeAndSuffix(t *testing.T) { payload := writeLengthDelimited(2, testWifiDevice(testLocation(100, 200, 25))) suffix := []byte{0xde, 0xad, 0xbe, 0xef} diff --git a/Resources/ThirdPartyProxyModules/wloc.conf b/Resources/ThirdPartyProxyModules/wloc.conf index 6be0b02..c7dff58 100644 --- a/Resources/ThirdPartyProxyModules/wloc.conf +++ b/Resources/ThirdPartyProxyModules/wloc.conf @@ -1,11 +1,11 @@ #!name=Apple WLOC 定位修改 #!desc=修改 Apple 网络定位返回坐标 | 快捷指令(推荐): 设置地理位置 https://www.icloud.com/shortcuts/a82717d8fdad4e6280866fcf911173f7 清理恢复位置 https://www.icloud.com/shortcuts/f42632d406504f24a2cd163af4fe012f | 选点页面: https://wloc-pages.pages.dev/ -#!author=Yu9191 Rewrite -#!homepage=https://github.com/Yu9191/wloc +#!author=xweiba +#!homepage=https://github.com/xweiba/location-spoofer [rewrite_local] -^https?:\/\/gs-loc(-cn)?\.apple\.com\/clls\/wloc url script-response-body https://raw.githubusercontent.com/Yu9191/wloc/refs/heads/main/dist/wloc.js -^https?:\/\/gs-loc(-cn)?\.apple\.com\/wloc-settings\/save url script-echo-response https://raw.githubusercontent.com/Yu9191/wloc/refs/heads/main/dist/wloc-settings.js +^https?:\/\/gs-loc(-cn)?\.apple\.com\/clls\/wloc url script-response-body https://gh-proxy.org/https://raw.githubusercontent.com/xweiba/location-spoofer/main/ThirdParty/WlocScripts/dist/v1/wloc.js +^https?:\/\/gs-loc(-cn)?\.apple\.com\/wloc-settings\/(save|version) url script-echo-response https://gh-proxy.org/https://raw.githubusercontent.com/xweiba/location-spoofer/main/ThirdParty/WlocScripts/dist/v1/wloc-settings.js [mitm] hostname = gs-loc.apple.com, gs-loc-cn.apple.com diff --git a/Resources/ThirdPartyProxyModules/wloc.lpx b/Resources/ThirdPartyProxyModules/wloc.lpx index 4680394..66beb6c 100644 --- a/Resources/ThirdPartyProxyModules/wloc.lpx +++ b/Resources/ThirdPartyProxyModules/wloc.lpx @@ -1,8 +1,7 @@ #!name=Apple WLOC 定位修改 #!desc=修改 Apple 网络定位返回坐标 | 快捷指令(推荐): 设置地理位置 https://www.icloud.com/shortcuts/a82717d8fdad4e6280866fcf911173f7 清理恢复位置 https://www.icloud.com/shortcuts/f42632d406504f24a2cd163af4fe012f -#!icon=https://raw.githubusercontent.com/Yu9191/wloc/refs/heads/main/wloc.jpg -#!author=Yu9191 Rewrite -#!homepage=https://github.com/Yu9191/wloc +#!author=xweiba +#!homepage=https://github.com/xweiba/location-spoofer #!openUrl=https://wloc-pages.pages.dev/ [Argument] @@ -12,8 +11,8 @@ accuracy = input, "25", tag=精度(米) logLevel = select, "info", "off", "error", "warn", "debug", "all", tag=日志级别 [Script] -http-response ^https?:\/\/gs-loc(-cn)?\.apple\.com\/clls\/wloc script-path=https://raw.githubusercontent.com/Yu9191/wloc/refs/heads/main/dist/wloc.js, requires-body=true, binary-body-mode=true, timeout=30, tag=Apple WLOC, argument=[{longitude},{latitude},{accuracy},{logLevel}] -http-request ^https?:\/\/gs-loc(-cn)?\.apple\.com\/wloc-settings\/save script-path=https://raw.githubusercontent.com/Yu9191/wloc/refs/heads/main/dist/wloc-settings.js, timeout=10, tag=WLOC Settings +http-response ^https?:\/\/gs-loc(-cn)?\.apple\.com\/clls\/wloc script-path=https://gh-proxy.org/https://raw.githubusercontent.com/xweiba/location-spoofer/main/ThirdParty/WlocScripts/dist/v1/wloc.js, requires-body=true, binary-body-mode=true, timeout=30, tag=Apple WLOC +http-request ^https?:\/\/gs-loc(-cn)?\.apple\.com\/wloc-settings\/(save|version) script-path=https://gh-proxy.org/https://raw.githubusercontent.com/xweiba/location-spoofer/main/ThirdParty/WlocScripts/dist/v1/wloc-settings.js, timeout=10, tag=WLOC Settings [MITM] hostname = gs-loc.apple.com, gs-loc-cn.apple.com diff --git a/Resources/ThirdPartyProxyModules/wloc.module b/Resources/ThirdPartyProxyModules/wloc.module index b603eb2..2d2163a 100644 --- a/Resources/ThirdPartyProxyModules/wloc.module +++ b/Resources/ThirdPartyProxyModules/wloc.module @@ -1,13 +1,12 @@ #!name=Apple WLOC 定位修改 #!desc=修改 Apple 网络定位返回坐标 (Shadowrocket 小火箭) | 快捷指令(推荐): 设置地理位置 https://www.icloud.com/shortcuts/a82717d8fdad4e6280866fcf911173f7 清理恢复位置 https://www.icloud.com/shortcuts/f42632d406504f24a2cd163af4fe012f | 选点页面: https://wloc-pages.pages.dev/ -#!author=Yu9191 Rewrite -#!homepage=https://github.com/Yu9191/wloc -#!icon=https://raw.githubusercontent.com/Yu9191/wloc/refs/heads/main/wloc.jpg +#!author=xweiba +#!homepage=https://github.com/xweiba/location-spoofer #!category=Tools [Script] -Apple WLOC = type=http-response,pattern=^https?:\/\/gs-loc(-cn)?\.apple\.com\/clls\/wloc,requires-body=1,binary-body-mode=1,max-size=0,timeout=30,script-path=https://raw.githubusercontent.com/Yu9191/wloc/refs/heads/main/dist/wloc.js,argument=longitude=113.94114&latitude=22.544577&accuracy=25&logLevel=info -WLOC Settings = type=http-request,pattern=^https?:\/\/gs-loc(-cn)?\.apple\.com\/wloc-settings\/save,requires-body=0,max-size=0,timeout=10,script-path=https://raw.githubusercontent.com/Yu9191/wloc/refs/heads/main/dist/wloc-settings.js +Apple WLOC = type=http-response,pattern=^https?:\/\/gs-loc(-cn)?\.apple\.com\/clls\/wloc,requires-body=1,binary-body-mode=1,max-size=0,timeout=30,script-path=https://gh-proxy.org/https://raw.githubusercontent.com/xweiba/location-spoofer/main/ThirdParty/WlocScripts/dist/v1/wloc.js +WLOC Settings = type=http-request,pattern=^https?:\/\/gs-loc(-cn)?\.apple\.com\/wloc-settings\/(save|version),requires-body=0,max-size=0,timeout=10,script-path=https://gh-proxy.org/https://raw.githubusercontent.com/xweiba/location-spoofer/main/ThirdParty/WlocScripts/dist/v1/wloc-settings.js [MITM] hostname = %APPEND% gs-loc.apple.com, gs-loc-cn.apple.com diff --git a/Resources/ThirdPartyProxyModules/wloc.sgmodule b/Resources/ThirdPartyProxyModules/wloc.sgmodule index b8f8553..c531258 100644 --- a/Resources/ThirdPartyProxyModules/wloc.sgmodule +++ b/Resources/ThirdPartyProxyModules/wloc.sgmodule @@ -1,14 +1,14 @@ #!name=Apple WLOC 定位修改 #!desc=修改 Apple 网络定位返回坐标 | 快捷指令(推荐): 设置地理位置 https://www.icloud.com/shortcuts/a82717d8fdad4e6280866fcf911173f7 清理恢复位置 https://www.icloud.com/shortcuts/f42632d406504f24a2cd163af4fe012f | 选点页面: https://wloc-pages.pages.dev/ -#!author=Yu9191 Rewrite -#!homepage=https://github.com/Yu9191/wloc +#!author=xweiba +#!homepage=https://github.com/xweiba/location-spoofer #!category=Tools #!arguments=经度:113.94114, 纬度:22.544577, 精度:25, 日志级别:info #!arguments-desc=经度/纬度: 默认坐标(在线选点储存后优先)\n精度: GPS精度(米)\n日志级别: off/error/warn/info/debug/all\n\n使用方法: 打开选点页面 -> 选位置 -> 储存到设备 [Script] -Apple WLOC = type=http-response, pattern="^https?:\/\/gs-loc(-cn)?\.apple\.com\/clls\/wloc", requires-body=1, binary-body-mode=1, max-size=0, timeout=30, script-path=https://raw.githubusercontent.com/Yu9191/wloc/refs/heads/main/dist/wloc.js, argument=longitude={{{经度}}}&latitude={{{纬度}}}&accuracy={{{精度}}}&logLevel={{{日志级别}}} -WLOC Settings = type=http-request, pattern="^https?:\/\/gs-loc(-cn)?\.apple\.com\/wloc-settings\/save", requires-body=0, max-size=0, timeout=10, script-path=https://raw.githubusercontent.com/Yu9191/wloc/refs/heads/main/dist/wloc-settings.js +Apple WLOC = type=http-response, pattern="^https?:\/\/gs-loc(-cn)?\.apple\.com\/clls\/wloc", requires-body=1, binary-body-mode=1, max-size=0, timeout=30, script-path=https://gh-proxy.org/https://raw.githubusercontent.com/xweiba/location-spoofer/main/ThirdParty/WlocScripts/dist/v1/wloc.js +WLOC Settings = type=http-request, pattern="^https?:\/\/gs-loc(-cn)?\.apple\.com\/wloc-settings\/(save|version)", requires-body=0, max-size=0, timeout=10, script-path=https://gh-proxy.org/https://raw.githubusercontent.com/xweiba/location-spoofer/main/ThirdParty/WlocScripts/dist/v1/wloc-settings.js [MITM] hostname = %APPEND% gs-loc.apple.com, gs-loc-cn.apple.com diff --git a/Resources/ThirdPartyProxyModules/wloc.stoverride b/Resources/ThirdPartyProxyModules/wloc.stoverride index 10d85b4..ea52815 100644 --- a/Resources/ThirdPartyProxyModules/wloc.stoverride +++ b/Resources/ThirdPartyProxyModules/wloc.stoverride @@ -1,8 +1,7 @@ name: Apple WLOC 定位修改 desc: "修改 Apple 网络定位返回坐标 | 快捷指令(推荐): 设置地理位置 https://www.icloud.com/shortcuts/a82717d8fdad4e6280866fcf911173f7 清理恢复位置 https://www.icloud.com/shortcuts/f42632d406504f24a2cd163af4fe012f | 选点页面: https://wloc-pages.pages.dev/" -author: Yu9191 Rewrite -homepage: https://github.com/Yu9191/wloc -icon: https://raw.githubusercontent.com/Yu9191/wloc/refs/heads/main/wloc.jpg +author: xweiba +homepage: https://github.com/xweiba/location-spoofer category: Tools http: @@ -17,8 +16,7 @@ http: binary-mode: true max-size: 0 timeout: 30 - argument: longitude=113.94114&latitude=22.544577&accuracy=25&logLevel=info - - match: ^https?:\/\/gs-loc(-cn)?\.apple\.com\/wloc-settings\/save + - match: ^https?:\/\/gs-loc(-cn)?\.apple\.com\/wloc-settings\/(save|version) name: WLOC.Settings type: request require-body: false @@ -26,8 +24,8 @@ http: script-providers: WLOC.Location: - url: https://raw.githubusercontent.com/Yu9191/wloc/refs/heads/main/dist/wloc.js + url: https://gh-proxy.org/https://raw.githubusercontent.com/xweiba/location-spoofer/main/ThirdParty/WlocScripts/dist/v1/wloc.js interval: 86400 WLOC.Settings: - url: https://raw.githubusercontent.com/Yu9191/wloc/refs/heads/main/dist/wloc-settings.js + url: https://gh-proxy.org/https://raw.githubusercontent.com/xweiba/location-spoofer/main/ThirdParty/WlocScripts/dist/v1/wloc-settings.js interval: 86400 diff --git a/Shared/AppGroup.swift b/Shared/AppGroup.swift index bfe574b..fc9c05a 100644 --- a/Shared/AppGroup.swift +++ b/Shared/AppGroup.swift @@ -44,6 +44,50 @@ enum WlocSettingsStore { } } +@MainActor +final class MotionSimulationStore: ObservableObject { + static let shared = MotionSimulationStore() + + private enum Key { + static let enabled = "motionSimulation.enabled" + } + + @Published private(set) var isEnabled: Bool + private let defaults: UserDefaults + + init(defaults: UserDefaults = AppGroup.defaults) { + self.defaults = defaults + isEnabled = defaults.bool(forKey: Key.enabled) + } + + func setEnabled(_ enabled: Bool) { + isEnabled = enabled + defaults.set(enabled, forKey: Key.enabled) + } +} + +@MainActor +final class ThirdPartyModuleSourceStore: ObservableObject { + static let shared = ThirdPartyModuleSourceStore() + + private enum Key { + static let useMirror = "thirdPartyModule.useMirror" + } + + @Published private(set) var useMirror: Bool + private let defaults: UserDefaults + + init(defaults: UserDefaults = AppGroup.defaults) { + self.defaults = defaults + useMirror = defaults.object(forKey: Key.useMirror) as? Bool ?? true + } + + func setUseMirror(_ enabled: Bool) { + useMirror = enabled + defaults.set(enabled, forKey: Key.useMirror) + } +} + enum VirtualLocationTipKind: Equatable { case activation case deactivation diff --git a/Shared/ThirdPartyProxyManager.swift b/Shared/ThirdPartyProxyManager.swift index 8a4d95b..14f3844 100644 --- a/Shared/ThirdPartyProxyManager.swift +++ b/Shared/ThirdPartyProxyManager.swift @@ -6,6 +6,22 @@ struct ThirdPartyProxySettingsResponse: Decodable, Equatable { let latitude: Double? let accuracy: Int? let error: String? + let motionSimulationEnabled: Bool? +} + +struct ThirdPartyProxyVersionResponse: Decodable, Equatable { + let success: Bool + let moduleVersion: String + let protocolVersion: Int + let capabilities: Set + + static let requiredCapabilities: Set = [ + "wifi", "cellTower", "arpc", "marker", "synthetic", "bare", "motionSimulation" + ] + + var isCompatible: Bool { + success && protocolVersion >= 1 && capabilities.isSuperset(of: Self.requiredCapabilities) + } } enum ThirdPartyProxyConnectionState: Equatable { @@ -20,6 +36,7 @@ enum ThirdPartyProxyError: LocalizedError, Equatable { case rejected(String) case coordinateMismatch case network(String) + case moduleOutdated var errorDescription: String? { switch self { @@ -33,6 +50,8 @@ enum ThirdPartyProxyError: LocalizedError, Equatable { return "第三方代理保存的坐标与当前选点不一致" case .network(let message): return "第三方代理请求失败:\(message)" + case .moduleOutdated: + return "模块版本过低,请重新导入模块" } } } @@ -48,6 +67,7 @@ final class ThirdPartyProxyManager: ObservableObject { static let shared = ThirdPartyProxyManager() static let interceptionHostname = "gs-loc.apple.com" static let configurationEndpoint = URL(string: "https://gs-loc.apple.com/wloc-settings/save")! + static let versionEndpoint = URL(string: "https://gs-loc.apple.com/wloc-settings/version")! @Published private(set) var connectionState: ThirdPartyProxyConnectionState = .unknown @Published private(set) var activeSettings: ThirdPartyProxySettingsResponse? @@ -86,11 +106,13 @@ final class ThirdPartyProxyManager: ObservableObject { } func save(_ favorite: FavoriteLocation) async throws -> ThirdPartyProxySettingsResponse { + _ = try await validateVersion() let wgs84 = favorite.coordinatePair.wgs84 let response = try await perform(action: .save( latitude: wgs84.latitude, longitude: wgs84.longitude, - accuracy: favorite.accuracy + accuracy: favorite.accuracy, + motionEnabled: MotionSimulationStore.shared.isEnabled )) guard response.success else { throw ThirdPartyProxyError.rejected(response.error ?? "第三方代理拒绝保存坐标") @@ -111,6 +133,57 @@ final class ThirdPartyProxyManager: ObservableObject { return response } + func updateMotionSimulation(_ enabled: Bool) async throws -> ThirdPartyProxySettingsResponse { + guard let current = activeSettings, + let latitude = current.latitude, + let longitude = current.longitude else { + throw ThirdPartyProxyError.rejected("第三方虚拟定位尚未开启") + } + _ = try await validateVersion() + let response = try await perform(action: .save( + latitude: latitude, + longitude: longitude, + accuracy: current.accuracy ?? 25, + motionEnabled: enabled + )) + guard response.success else { + throw ThirdPartyProxyError.rejected(response.error ?? "第三方代理拒绝更新运动状态") + } + activeSettings = response + return response + } + + func validateVersion() async throws -> ThirdPartyProxyVersionResponse { + guard !isRequesting else { + throw ThirdPartyProxyError.rejected("已有第三方代理请求正在执行") + } + isRequesting = true + defer { isRequesting = false } + + var request = URLRequest(url: Self.versionEndpoint) + request.httpMethod = "GET" + request.cachePolicy = .reloadIgnoringLocalAndRemoteCacheData + request.timeoutInterval = 8 + do { + let (data, response) = try await requester.data(for: request) + guard let http = response as? HTTPURLResponse, http.statusCode == 200, + let version = try? JSONDecoder().decode(ThirdPartyProxyVersionResponse.self, from: data), + version.isCompatible else { + throw ThirdPartyProxyError.moduleOutdated + } + RuntimeLogger.info("APP", "ThirdPartyProxy", "第三方模块版本检测通过", details: [ + "模块版本": version.moduleVersion, + "协议版本": String(version.protocolVersion), + "能力": version.capabilities.sorted().joined(separator: ",") + ]) + return version + } catch let error as ThirdPartyProxyError { + throw error + } catch { + throw ThirdPartyProxyError.network(error.localizedDescription) + } + } + func clear() async throws { let response = try await perform(action: .clear) guard response.success else { @@ -123,7 +196,7 @@ final class ThirdPartyProxyManager: ObservableObject { private enum Action { case query - case save(latitude: Double, longitude: Double, accuracy: Int) + case save(latitude: Double, longitude: Double, accuracy: Int, motionEnabled: Bool) case clear } @@ -140,11 +213,15 @@ final class ThirdPartyProxyManager: ObservableObject { components.queryItems = [URLQueryItem(name: "action", value: "query")] case .clear: components.queryItems = [URLQueryItem(name: "action", value: "clear")] - case .save(let latitude, let longitude, let accuracy): + case .save(let latitude, let longitude, let accuracy, let motionEnabled): components.queryItems = [ URLQueryItem(name: "lon", value: String(format: "%.8f", locale: Locale(identifier: "en_US_POSIX"), longitude)), URLQueryItem(name: "lat", value: String(format: "%.8f", locale: Locale(identifier: "en_US_POSIX"), latitude)), - URLQueryItem(name: "acc", value: String(accuracy)) + URLQueryItem(name: "acc", value: String(accuracy)), + URLQueryItem( + name: "motion", + value: motionEnabled ? "1" : "0" + ) ] } guard let url = components.url else { throw ThirdPartyProxyError.invalidResponse } @@ -211,19 +288,26 @@ enum ThirdPartyProxyClient: String, CaseIterable, Identifiable { } } + @MainActor var subscriptionURL: URL { let url: String + let directory = ThirdPartyModuleSourceStore.shared.useMirror + ? "Resources/ThirdPartyProxyModules" + : "ThirdParty/WlocScripts/modules/direct" + let prefix = ThirdPartyModuleSourceStore.shared.useMirror + ? "https://gh-proxy.org/https://raw.githubusercontent.com/xweiba/location-spoofer/main/" + : "https://raw.githubusercontent.com/xweiba/location-spoofer/main/" switch self { case .surge, .egern: - url = "https://raw.githubusercontent.com/Yu9191/wloc/refs/heads/main/modules/wloc.sgmodule" + url = "\(prefix)\(directory)/wloc.sgmodule" case .quantumultX: - url = "https://raw.githubusercontent.com/Yu9191/wloc/refs/heads/main/modules/wloc.conf" + url = "\(prefix)\(directory)/wloc.conf" case .loon: - url = "https://raw.githubusercontent.com/Yu9191/wloc/refs/heads/main/modules/wloc.lpx" + url = "\(prefix)\(directory)/wloc.lpx" case .stash: - url = "https://raw.githubusercontent.com/Yu9191/wloc/refs/heads/main/modules/wloc.stoverride" + url = "\(prefix)\(directory)/wloc.stoverride" case .shadowrocket: - url = "https://raw.githubusercontent.com/Yu9191/wloc/refs/heads/main/modules/wloc.module" + url = "\(prefix)\(directory)/wloc.module" } return URL(string: url)! } diff --git a/Tests/PaopaoLocationSpooferTests/MotionSimulationStoreTests.swift b/Tests/PaopaoLocationSpooferTests/MotionSimulationStoreTests.swift new file mode 100644 index 0000000..1598673 --- /dev/null +++ b/Tests/PaopaoLocationSpooferTests/MotionSimulationStoreTests.swift @@ -0,0 +1,17 @@ +import XCTest +@testable import PaopaoLocationSpoofer + +@MainActor +final class MotionSimulationStoreTests: XCTestCase { + func testDefaultsToDisabledAndPersistsChanges() { + let suite = "MotionSimulationStoreTests.\(UUID().uuidString)" + let defaults = UserDefaults(suiteName: suite)! + defer { defaults.removePersistentDomain(forName: suite) } + + let store = MotionSimulationStore(defaults: defaults) + XCTAssertFalse(store.isEnabled) + + store.setEnabled(true) + XCTAssertTrue(MotionSimulationStore(defaults: defaults).isEnabled) + } +} diff --git a/Tests/PaopaoLocationSpooferTests/ThirdPartyModuleSourceStoreTests.swift b/Tests/PaopaoLocationSpooferTests/ThirdPartyModuleSourceStoreTests.swift new file mode 100644 index 0000000..4491cca --- /dev/null +++ b/Tests/PaopaoLocationSpooferTests/ThirdPartyModuleSourceStoreTests.swift @@ -0,0 +1,17 @@ +import XCTest +@testable import PaopaoLocationSpoofer + +@MainActor +final class ThirdPartyModuleSourceStoreTests: XCTestCase { + func testMirrorDefaultsToEnabledAndPersists() { + let suite = "ThirdPartyModuleSourceStoreTests.\(UUID().uuidString)" + let defaults = UserDefaults(suiteName: suite)! + defer { defaults.removePersistentDomain(forName: suite) } + + let store = ThirdPartyModuleSourceStore(defaults: defaults) + XCTAssertTrue(store.useMirror) + + store.setUseMirror(false) + XCTAssertFalse(ThirdPartyModuleSourceStore(defaults: defaults).useMirror) + } +} diff --git a/Tests/PaopaoLocationSpooferTests/ThirdPartyProxyManagerTests.swift b/Tests/PaopaoLocationSpooferTests/ThirdPartyProxyManagerTests.swift index c1bfe13..93a2d40 100644 --- a/Tests/PaopaoLocationSpooferTests/ThirdPartyProxyManagerTests.swift +++ b/Tests/PaopaoLocationSpooferTests/ThirdPartyProxyManagerTests.swift @@ -37,9 +37,21 @@ final class ThirdPartyProxyManagerTests: XCTestCase { XCTAssertEqual(latitude, wgs84.latitude, accuracy: 0.000_000_01) XCTAssertEqual(longitude, wgs84.longitude, accuracy: 0.000_000_01) XCTAssertEqual(values["acc"], "20") + XCTAssertEqual(values["motion"], "0") XCTAssertEqual(manager.connectionState, .connected(active: true)) } + func testVersionEndpointRequiresProtocolAndCapabilities() async throws { + let requester = FakeThirdPartyRequester(body: #"{"success":false,"error":"无已保存的坐标"}"#) + let manager = ThirdPartyProxyManager(requester: requester) + + let version = try await manager.validateVersion() + + XCTAssertEqual(requester.lastURL?.path, "/wloc-settings/version") + XCTAssertEqual(version.moduleVersion, "1.0.0") + XCTAssertTrue(version.isCompatible) + } + func testSaveRejectsCoordinateMismatchWithoutMarkingActive() async { let requester = FakeThirdPartyRequester(body: #"{"success":true,"longitude":1,"latitude":2,"accuracy":25}"#) let manager = ThirdPartyProxyManager(requester: requester) @@ -65,12 +77,19 @@ final class ThirdPartyProxyManagerTests: XCTestCase { } } - func testClientLinksUseOfficialUpstreamModulesAndVerificationLabels() { + func testClientLinksUseProjectOwnedMirrorModulesAndVerificationLabels() { XCTAssertNil(ThirdPartyProxyClient.shadowrocket.verificationText) XCTAssertTrue(ThirdPartyProxyClient.surge.verificationText?.contains("尚未验证") == true) XCTAssertEqual(ThirdPartyProxyClient.egern.subscriptionURL, ThirdPartyProxyClient.surge.subscriptionURL) - XCTAssertTrue(ThirdPartyProxyClient.stash.subscriptionURL.absoluteString.hasSuffix("/modules/wloc.stoverride")) - XCTAssertTrue(ThirdPartyProxyClient.shadowrocket.subscriptionURL.absoluteString.hasSuffix("/modules/wloc.module")) + XCTAssertTrue(ThirdPartyProxyClient.stash.subscriptionURL.absoluteString.hasPrefix( + "https://gh-proxy.org/https://raw.githubusercontent.com/xweiba/location-spoofer/main/" + )) + XCTAssertTrue(ThirdPartyProxyClient.stash.subscriptionURL.absoluteString.hasSuffix( + "/Resources/ThirdPartyProxyModules/wloc.stoverride" + )) + XCTAssertTrue(ThirdPartyProxyClient.shadowrocket.subscriptionURL.absoluteString.hasSuffix( + "/Resources/ThirdPartyProxyModules/wloc.module" + )) XCTAssertEqual(ThirdPartyProxyClient.shadowrocket.launchURL?.scheme, "shadowrocket") XCTAssertEqual(ThirdPartyProxyClient.surge.launchURL?.scheme, "surge") XCTAssertEqual(ThirdPartyProxyClient.quantumultX.launchURL?.scheme, "quantumult-x") @@ -94,10 +113,12 @@ final class ThirdPartyProxyManagerTests: XCTestCase { private final class FakeThirdPartyRequester: ThirdPartyProxyRequesting { private let data: Data + private let versionData: Data private(set) var lastURL: URL? init(body: String) { data = Data(body.utf8) + versionData = Data(#"{"success":true,"moduleVersion":"1.0.0","protocolVersion":1,"capabilities":["wifi","cellTower","arpc","marker","synthetic","bare","motionSimulation"]}"#.utf8) } func data(for request: URLRequest) async throws -> (Data, URLResponse) { @@ -108,6 +129,6 @@ private final class FakeThirdPartyRequester: ThirdPartyProxyRequesting { httpVersion: "HTTP/1.1", headerFields: ["Content-Type": "application/json"] )! - return (data, response) + return (request.url?.path == "/wloc-settings/version" ? versionData : data, response) } } diff --git a/ThirdParty/WlocScripts/THIRD_PARTY_NOTICES.md b/ThirdParty/WlocScripts/THIRD_PARTY_NOTICES.md new file mode 100644 index 0000000..5779f54 --- /dev/null +++ b/ThirdParty/WlocScripts/THIRD_PARTY_NOTICES.md @@ -0,0 +1,6 @@ +# Third-Party Notices + +The generated proxy scripts bundle: + +- `pako` 2.1.0, Copyright (C) 2014-2017 Vitaly Puzrin and contributors, MIT License. +- `esbuild` is used only as a development/build dependency and is distributed under the MIT License. diff --git a/ThirdParty/WlocScripts/build.mjs b/ThirdParty/WlocScripts/build.mjs new file mode 100644 index 0000000..0c6cdaa --- /dev/null +++ b/ThirdParty/WlocScripts/build.mjs @@ -0,0 +1,19 @@ +import { build } from "esbuild"; +import { mkdir } from "node:fs/promises"; + +await mkdir(new URL("./dist/v1/", import.meta.url), { recursive: true }); + +for (const [entry, outfile] of [ + ["src/response-entry.js", "dist/v1/wloc.js"], + ["src/settings-entry.js", "dist/v1/wloc-settings.js"] +]) { + await build({ + entryPoints: [entry], + outfile, + bundle: true, + format: "iife", + target: ["es2017"], + minify: true, + legalComments: "eof" + }); +} diff --git a/ThirdParty/WlocScripts/dist/v1/wloc-settings.js b/ThirdParty/WlocScripts/dist/v1/wloc-settings.js new file mode 100644 index 0000000..6e7377d --- /dev/null +++ b/ThirdParty/WlocScripts/dist/v1/wloc-settings.js @@ -0,0 +1 @@ +(()=>{var y="1.0.0";var m=["wifi","cellTower","arpc","marker","synthetic","bare","motionSimulation"],c="locationSpoofer.settings.v1";function u(){return typeof $task!="undefined"?"quantumultX":typeof $loon!="undefined"?"loon":typeof $rocket!="undefined"?"shadowrocket":typeof Egern!="undefined"?"egern":typeof $environment!="undefined"&&$environment["stash-version"]?"stash":typeof $environment!="undefined"&&$environment["surge-version"]?"surge":"unknown"}function h(e){let t=u()==="quantumultX"?$prefs.valueForKey(e):$persistentStore.read(e);if(!t)return null;try{return JSON.parse(t)}catch(n){return null}}function l(e,t){let n=t==null?"":JSON.stringify(t);return u()==="quantumultX"?$prefs.setValueForKey(n,e):$persistentStore.write(n,e)}function i(e){let t={status:200,headers:{"Content-Type":"application/json; charset=utf-8"},body:JSON.stringify(e)};u()==="quantumultX"?$done(Object.assign({},t,{status:"HTTP/1.1 200 OK"})):u()==="stash"?$done(t):$done({response:t})}function g(e){let t=e.split("?")[1]||"",n={};return t.split("&").forEach(s=>{if(!s)return;let o=s.indexOf("="),f=o<0?s:s.slice(0,o),d=o<0?"":s.slice(o+1),a=f,p=d;try{a=decodeURIComponent(f.replace(/\+/g," "))}catch($){}try{p=decodeURIComponent(d.replace(/\+/g," "))}catch($){}Object.prototype.hasOwnProperty.call(n,a)||(n[a]=p)}),n}function O(e){let t=e.split("?")[0],n=t.indexOf("://");if(n<0)return t;let s=t.indexOf("/",n+3);return s<0?"/":t.slice(s)}var b=typeof $request=="undefined"?"":$request.url||"",E=O(b),r=g(b);if(E==="/wloc-settings/version")i({success:!0,moduleVersion:y,protocolVersion:1,capabilities:m});else if(r.action==="query"){let e=h(c);i(e&&e.enabled?{success:!0,longitude:e.longitude,latitude:e.latitude,accuracy:e.accuracy,motionSimulationEnabled:e.motionSimulationEnabled===!0}:{success:!1,error:"\u65E0\u5DF2\u4FDD\u5B58\u7684\u5750\u6807"})}else if(r.action==="clear")l(c,null),i({success:!0});else{let e=Number(r.lon!=null?r.lon:r.longitude),t=Number(r.lat!=null?r.lat:r.latitude),n=Number(r.acc!=null?r.acc:r.accuracy!=null?r.accuracy:25);if(!Number.isFinite(e)||!Number.isFinite(t))i({success:!1,error:"\u7F3A\u5C11 lon/lat \u53C2\u6570"});else{let s={enabled:!0,longitude:e,latitude:t,accuracy:n,motionSimulationEnabled:r.motion==="1"},o=l(c,s);i(o?{success:!0,longitude:e,latitude:t,accuracy:n,motionSimulationEnabled:s.motionSimulationEnabled}:{success:!1,error:"\u4FDD\u5B58\u914D\u7F6E\u5931\u8D25"})}}})(); diff --git a/ThirdParty/WlocScripts/dist/v1/wloc.js b/ThirdParty/WlocScripts/dist/v1/wloc.js new file mode 100644 index 0000000..06ea42d --- /dev/null +++ b/ThirdParty/WlocScripts/dist/v1/wloc.js @@ -0,0 +1,6 @@ +(()=>{function ue(e){let n=e.length;for(;--n>=0;)e[n]=0}var si=0,bn=1,_i=2,hi=3,ci=258,mt=29,De=256,ye=De+1+mt,he=30,Et=19,xn=2*ye+1,te=15,Qe=16,di=7,yt=256,vn=16,kn=17,mn=18,dt=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),Pe=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),ui=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),En=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),wi=512,Y=new Array((ye+2)*2);ue(Y);var ke=new Array(he*2);ue(ke);var Ae=new Array(wi);ue(Ae);var Se=new Array(ci-hi+1);ue(Se);var At=new Array(mt);ue(At);var Ke=new Array(he);ue(Ke);function et(e,n,t,i,a){this.static_tree=e,this.extra_bits=n,this.extra_base=t,this.elems=i,this.max_length=a,this.has_stree=e&&e.length}var yn,An,Sn;function tt(e,n){this.dyn_tree=e,this.max_code=0,this.stat_desc=n}var Tn=e=>e<256?Ae[e]:Ae[256+(e>>>7)],Te=(e,n)=>{e.pending_buf[e.pending++]=n&255,e.pending_buf[e.pending++]=n>>>8&255},C=(e,n,t)=>{e.bi_valid>Qe-t?(e.bi_buf|=n<>Qe-e.bi_valid,e.bi_valid+=t-Qe):(e.bi_buf|=n<{C(e,t[n*2],t[n*2+1])},zn=(e,n)=>{let t=0;do t|=e&1,e>>>=1,t<<=1;while(--n>0);return t>>>1},pi=e=>{e.bi_valid===16?(Te(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=e.bi_buf&255,e.bi_buf>>=8,e.bi_valid-=8)},gi=(e,n)=>{let t=n.dyn_tree,i=n.max_code,a=n.stat_desc.static_tree,r=n.stat_desc.has_stree,f=n.stat_desc.extra_bits,o=n.stat_desc.extra_base,h=n.stat_desc.max_length,l,s,E,d,_,u,R=0;for(d=0;d<=te;d++)e.bl_count[d]=0;for(t[e.heap[e.heap_max]*2+1]=0,l=e.heap_max+1;lh&&(d=h,R++),t[s*2+1]=d,!(s>i)&&(e.bl_count[d]++,_=0,s>=o&&(_=f[s-o]),u=t[s*2],e.opt_len+=u*(d+_),r&&(e.static_len+=u*(a[s*2+1]+_)));if(R!==0){do{for(d=h-1;e.bl_count[d]===0;)d--;e.bl_count[d]--,e.bl_count[d+1]+=2,e.bl_count[h]--,R-=2}while(R>0);for(d=h;d!==0;d--)for(s=e.bl_count[d];s!==0;)E=e.heap[--l],!(E>i)&&(t[E*2+1]!==d&&(e.opt_len+=(d-t[E*2+1])*t[E*2],t[E*2+1]=d),s--)}},Rn=(e,n,t)=>{let i=new Array(te+1),a=0,r,f;for(r=1;r<=te;r++)a=a+t[r-1]<<1,i[r]=a;for(f=0;f<=n;f++){let o=e[f*2+1];o!==0&&(e[f*2]=zn(i[o]++,o))}},bi=()=>{let e,n,t,i,a,r=new Array(te+1);for(t=0,i=0;i>=7;i{let n;for(n=0;n{e.bi_valid>8?Te(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},Nt=(e,n,t,i)=>{let a=n*2,r=t*2;return e[a]{let i=e.heap[t],a=t<<1;for(;a<=e.heap_len&&(a{let i,a,r=0,f,o;if(e.sym_next!==0)do i=e.pending_buf[e.sym_buf+r++]&255,i+=(e.pending_buf[e.sym_buf+r++]&255)<<8,a=e.pending_buf[e.sym_buf+r++],i===0?H(e,a,n):(f=Se[a],H(e,f+De+1,n),o=dt[f],o!==0&&(a-=At[f],C(e,a,o)),i--,f=Tn(i),H(e,f,t),o=Pe[f],o!==0&&(i-=Ke[f],C(e,i,o)));while(r{let t=n.dyn_tree,i=n.stat_desc.static_tree,a=n.stat_desc.has_stree,r=n.stat_desc.elems,f,o,h=-1,l;for(e.heap_len=0,e.heap_max=xn,f=0;f>1;f>=1;f--)nt(e,t,f);l=r;do f=e.heap[1],e.heap[1]=e.heap[e.heap_len--],nt(e,t,1),o=e.heap[1],e.heap[--e.heap_max]=f,e.heap[--e.heap_max]=o,t[l*2]=t[f*2]+t[o*2],e.depth[l]=(e.depth[f]>=e.depth[o]?e.depth[f]:e.depth[o])+1,t[f*2+1]=t[o*2+1]=l,e.heap[1]=l++,nt(e,t,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],gi(e,n),Rn(t,h,e.bl_count)},Ct=(e,n,t)=>{let i,a=-1,r,f=n[1],o=0,h=7,l=4;for(f===0&&(h=138,l=3),n[(t+1)*2+1]=65535,i=0;i<=t;i++)r=f,f=n[(i+1)*2+1],!(++o{let i,a=-1,r,f=n[1],o=0,h=7,l=4;for(f===0&&(h=138,l=3),i=0;i<=t;i++)if(r=f,f=n[(i+1)*2+1],!(++o{let n;for(Ct(e,e.dyn_ltree,e.l_desc.max_code),Ct(e,e.dyn_dtree,e.d_desc.max_code),ut(e,e.bl_desc),n=Et-1;n>=3&&e.bl_tree[En[n]*2+1]===0;n--);return e.opt_len+=3*(n+1)+5+5+4,n},vi=(e,n,t,i)=>{let a;for(C(e,n-257,5),C(e,t-1,5),C(e,i-4,4),a=0;a{let n=4093624447,t;for(t=0;t<=31;t++,n>>>=1)if(n&1&&e.dyn_ltree[t*2]!==0)return 0;if(e.dyn_ltree[18]!==0||e.dyn_ltree[20]!==0||e.dyn_ltree[26]!==0)return 1;for(t=32;t{Lt||(bi(),Lt=!0),e.l_desc=new tt(e.dyn_ltree,yn),e.d_desc=new tt(e.dyn_dtree,An),e.bl_desc=new tt(e.bl_tree,Sn),e.bi_buf=0,e.bi_valid=0,On(e)},Dn=(e,n,t,i)=>{C(e,(si<<1)+(i?1:0),3),In(e),Te(e,t),Te(e,~t),t&&e.pending_buf.set(e.window.subarray(n,n+t),e.pending),e.pending+=t},Ei=e=>{C(e,bn<<1,3),H(e,yt,Y),pi(e)},yi=(e,n,t,i)=>{let a,r,f=0;e.level>0?(e.strm.data_type===2&&(e.strm.data_type=ki(e)),ut(e,e.l_desc),ut(e,e.d_desc),f=xi(e),a=e.opt_len+3+7>>>3,r=e.static_len+3+7>>>3,r<=a&&(a=r)):a=r=t+5,t+4<=a&&n!==-1?Dn(e,n,t,i):e.strategy===4||r===a?(C(e,(bn<<1)+(i?1:0),3),Zt(e,Y,ke)):(C(e,(_i<<1)+(i?1:0),3),vi(e,e.l_desc.max_code+1,e.d_desc.max_code+1,f+1),Zt(e,e.dyn_ltree,e.dyn_dtree)),On(e),i&&In(e)},Ai=(e,n,t)=>(e.pending_buf[e.sym_buf+e.sym_next++]=n,e.pending_buf[e.sym_buf+e.sym_next++]=n>>8,e.pending_buf[e.sym_buf+e.sym_next++]=t,n===0?e.dyn_ltree[t*2]++:(e.matches++,n--,e.dyn_ltree[(Se[t]+De+1)*2]++,e.dyn_dtree[Tn(n)*2]++),e.sym_next===e.sym_end),Si=mi,Ti=Dn,zi=yi,Ri=Ai,Oi=Ei,Ii={_tr_init:Si,_tr_stored_block:Ti,_tr_flush_block:zi,_tr_tally:Ri,_tr_align:Oi},Di=(e,n,t,i)=>{let a=e&65535|0,r=e>>>16&65535|0,f=0;for(;t!==0;){f=t>2e3?2e3:t,t-=f;do a=a+n[i++]|0,r=r+a|0;while(--f);a%=65521,r%=65521}return a|r<<16|0},ze=Di,Ni=()=>{let e,n=[];for(var t=0;t<256;t++){e=t;for(var i=0;i<8;i++)e=e&1?3988292384^e>>>1:e>>>1;n[t]=e}return n},Zi=new Uint32Array(Ni()),Ci=(e,n,t,i)=>{let a=Zi,r=i+t;e^=-1;for(let f=i;f>>8^a[(e^n[f])&255];return e^-1},I=Ci,ae={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},we={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8},{_tr_init:$i,_tr_stored_block:wt,_tr_flush_block:Li,_tr_tally:W,_tr_align:Ui}=Ii,{Z_NO_FLUSH:q,Z_PARTIAL_FLUSH:Mi,Z_FULL_FLUSH:Fi,Z_FINISH:U,Z_BLOCK:Ut,Z_OK:D,Z_STREAM_END:Mt,Z_STREAM_ERROR:B,Z_DATA_ERROR:Hi,Z_BUF_ERROR:it,Z_DEFAULT_COMPRESSION:Bi,Z_FILTERED:Pi,Z_HUFFMAN_ONLY:Ue,Z_RLE:Ki,Z_FIXED:Yi,Z_DEFAULT_STRATEGY:Xi,Z_UNKNOWN:Gi,Z_DEFLATED:Ge}=we,ji=9,Vi=15,Wi=8,qi=29,Ji=256,pt=Ji+1+qi,Qi=30,ea=19,ta=2*pt+1,na=15,v=3,V=258,P=V+v+1,ia=32,ce=42,St=57,gt=69,bt=73,xt=91,vt=103,ne=113,xe=666,Z=1,pe=2,re=3,ge=4,aa=3,ie=(e,n)=>(e.msg=ae[n],n),Ft=e=>e*2-(e>4?9:0),j=e=>{let n=e.length;for(;--n>=0;)e[n]=0},ra=e=>{let n,t,i,a=e.w_size;n=e.hash_size,i=n;do t=e.head[--i],e.head[i]=t>=a?t-a:0;while(--n);n=a,i=n;do t=e.prev[--i],e.prev[i]=t>=a?t-a:0;while(--n)},la=(e,n,t)=>(n<{let n=e.state,t=n.pending;t>e.avail_out&&(t=e.avail_out),t!==0&&(e.output.set(n.pending_buf.subarray(n.pending_out,n.pending_out+t),e.next_out),e.next_out+=t,n.pending_out+=t,e.total_out+=t,e.avail_out-=t,n.pending-=t,n.pending===0&&(n.pending_out=0))},L=(e,n)=>{Li(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,n),e.block_start=e.strstart,$(e.strm)},A=(e,n)=>{e.pending_buf[e.pending++]=n},be=(e,n)=>{e.pending_buf[e.pending++]=n>>>8&255,e.pending_buf[e.pending++]=n&255},kt=(e,n,t,i)=>{let a=e.avail_in;return a>i&&(a=i),a===0?0:(e.avail_in-=a,n.set(e.input.subarray(e.next_in,e.next_in+a),t),e.state.wrap===1?e.adler=ze(e.adler,n,a,t):e.state.wrap===2&&(e.adler=I(e.adler,n,a,t)),e.next_in+=a,e.total_in+=a,a)},Nn=(e,n)=>{let t=e.max_chain_length,i=e.strstart,a,r,f=e.prev_length,o=e.nice_match,h=e.strstart>e.w_size-P?e.strstart-(e.w_size-P):0,l=e.window,s=e.w_mask,E=e.prev,d=e.strstart+V,_=l[i+f-1],u=l[i+f];e.prev_length>=e.good_match&&(t>>=2),o>e.lookahead&&(o=e.lookahead);do if(a=n,!(l[a+f]!==u||l[a+f-1]!==_||l[a]!==l[i]||l[++a]!==l[i+1])){i+=2,a++;do;while(l[++i]===l[++a]&&l[++i]===l[++a]&&l[++i]===l[++a]&&l[++i]===l[++a]&&l[++i]===l[++a]&&l[++i]===l[++a]&&l[++i]===l[++a]&&l[++i]===l[++a]&&if){if(e.match_start=n,f=r,r>=o)break;_=l[i+f-1],u=l[i+f]}}while((n=E[n&s])>h&&--t!==0);return f<=e.lookahead?f:e.lookahead},de=e=>{let n=e.w_size,t,i,a;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=n+(n-P)&&(e.window.set(e.window.subarray(n,n+n-i),0),e.match_start-=n,e.strstart-=n,e.block_start-=n,e.insert>e.strstart&&(e.insert=e.strstart),ra(e),i+=n),e.strm.avail_in===0)break;if(t=kt(e.strm,e.window,e.strstart+e.lookahead,i),e.lookahead+=t,e.lookahead+e.insert>=v)for(a=e.strstart-e.insert,e.ins_h=e.window[a],e.ins_h=J(e,e.ins_h,e.window[a+1]);e.insert&&(e.ins_h=J(e,e.ins_h,e.window[a+v-1]),e.prev[a&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=a,a++,e.insert--,!(e.lookahead+e.insert{let t=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,i,a,r,f=0,o=e.strm.avail_in;do{if(i=65535,r=e.bi_valid+42>>3,e.strm.avail_outa+e.strm.avail_in&&(i=a+e.strm.avail_in),i>r&&(i=r),i>8,e.pending_buf[e.pending-2]=~i,e.pending_buf[e.pending-1]=~i>>8,$(e.strm),a&&(a>i&&(a=i),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+a),e.strm.next_out),e.strm.next_out+=a,e.strm.avail_out-=a,e.strm.total_out+=a,e.block_start+=a,i-=a),i&&(kt(e.strm,e.strm.output,e.strm.next_out,i),e.strm.next_out+=i,e.strm.avail_out-=i,e.strm.total_out+=i)}while(f===0);return o-=e.strm.avail_in,o&&(o>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=o&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-o,e.strm.next_in),e.strstart),e.strstart+=o,e.insert+=o>e.w_size-e.insert?e.w_size-e.insert:o),e.block_start=e.strstart),e.high_waterr&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,r+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),r>e.strm.avail_in&&(r=e.strm.avail_in),r&&(kt(e.strm,e.window,e.strstart,r),e.strstart+=r,e.insert+=r>e.w_size-e.insert?e.w_size-e.insert:r),e.high_water>3,r=e.pending_buf_size-r>65535?65535:e.pending_buf_size-r,t=r>e.w_size?e.w_size:r,a=e.strstart-e.block_start,(a>=t||(a||n===U)&&n!==q&&e.strm.avail_in===0&&a<=r)&&(i=a>r?r:a,f=n===U&&e.strm.avail_in===0&&i===a?1:0,wt(e,e.block_start,i,f),e.block_start+=i,$(e.strm)),f?re:Z)},at=(e,n)=>{let t,i;for(;;){if(e.lookahead=v&&(e.ins_h=J(e,e.ins_h,e.window[e.strstart+v-1]),t=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),t!==0&&e.strstart-t<=e.w_size-P&&(e.match_length=Nn(e,t)),e.match_length>=v)if(i=W(e,e.strstart-e.match_start,e.match_length-v),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=v){e.match_length--;do e.strstart++,e.ins_h=J(e,e.ins_h,e.window[e.strstart+v-1]),t=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart;while(--e.match_length!==0);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=J(e,e.ins_h,e.window[e.strstart+1]);else i=W(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(i&&(L(e,!1),e.strm.avail_out===0))return Z}return e.insert=e.strstart{let t,i,a;for(;;){if(e.lookahead=v&&(e.ins_h=J(e,e.ins_h,e.window[e.strstart+v-1]),t=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=v-1,t!==0&&e.prev_length4096)&&(e.match_length=v-1)),e.prev_length>=v&&e.match_length<=e.prev_length){a=e.strstart+e.lookahead-v,i=W(e,e.strstart-1-e.prev_match,e.prev_length-v),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=a&&(e.ins_h=J(e,e.ins_h,e.window[e.strstart+v-1]),t=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart);while(--e.prev_length!==0);if(e.match_available=0,e.match_length=v-1,e.strstart++,i&&(L(e,!1),e.strm.avail_out===0))return Z}else if(e.match_available){if(i=W(e,0,e.window[e.strstart-1]),i&&L(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return Z}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(i=W(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart{let t,i,a,r,f=e.window;for(;;){if(e.lookahead<=V){if(de(e),e.lookahead<=V&&n===q)return Z;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=v&&e.strstart>0&&(a=e.strstart-1,i=f[a],i===f[++a]&&i===f[++a]&&i===f[++a])){r=e.strstart+V;do;while(i===f[++a]&&i===f[++a]&&i===f[++a]&&i===f[++a]&&i===f[++a]&&i===f[++a]&&i===f[++a]&&i===f[++a]&&ae.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=v?(t=W(e,1,e.match_length-v),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(t=W(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),t&&(L(e,!1),e.strm.avail_out===0))return Z}return e.insert=0,n===U?(L(e,!0),e.strm.avail_out===0?re:ge):e.sym_next&&(L(e,!1),e.strm.avail_out===0)?Z:pe},fa=(e,n)=>{let t;for(;;){if(e.lookahead===0&&(de(e),e.lookahead===0)){if(n===q)return Z;break}if(e.match_length=0,t=W(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,t&&(L(e,!1),e.strm.avail_out===0))return Z}return e.insert=0,n===U?(L(e,!0),e.strm.avail_out===0?re:ge):e.sym_next&&(L(e,!1),e.strm.avail_out===0)?Z:pe};function F(e,n,t,i,a){this.good_length=e,this.max_lazy=n,this.nice_length=t,this.max_chain=i,this.func=a}var ve=[new F(0,0,0,0,Zn),new F(4,4,8,4,at),new F(4,5,16,8,at),new F(4,6,32,32,at),new F(4,4,16,16,se),new F(8,16,32,32,se),new F(8,16,128,128,se),new F(8,32,128,256,se),new F(32,128,258,1024,se),new F(32,258,258,4096,se)],sa=e=>{e.window_size=2*e.w_size,j(e.head),e.max_lazy_match=ve[e.level].max_lazy,e.good_match=ve[e.level].good_length,e.nice_match=ve[e.level].nice_length,e.max_chain_length=ve[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=v-1,e.match_available=0,e.ins_h=0};function _a(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Ge,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(ta*2),this.dyn_dtree=new Uint16Array((2*Qi+1)*2),this.bl_tree=new Uint16Array((2*ea+1)*2),j(this.dyn_ltree),j(this.dyn_dtree),j(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(na+1),this.heap=new Uint16Array(2*pt+1),j(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*pt+1),j(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}var Ne=e=>{if(!e)return 1;let n=e.state;return!n||n.strm!==e||n.status!==ce&&n.status!==St&&n.status!==gt&&n.status!==bt&&n.status!==xt&&n.status!==vt&&n.status!==ne&&n.status!==xe?1:0},Cn=e=>{if(Ne(e))return ie(e,B);e.total_in=e.total_out=0,e.data_type=Gi;let n=e.state;return n.pending=0,n.pending_out=0,n.wrap<0&&(n.wrap=-n.wrap),n.status=n.wrap===2?St:n.wrap?ce:ne,e.adler=n.wrap===2?0:1,n.last_flush=-2,$i(n),D},$n=e=>{let n=Cn(e);return n===D&&sa(e.state),n},ha=(e,n)=>Ne(e)||e.state.wrap!==2?B:(e.state.gzhead=n,D),Ln=(e,n,t,i,a,r)=>{if(!e)return B;let f=1;if(n===Bi&&(n=6),i<0?(f=0,i=-i):i>15&&(f=2,i-=16),a<1||a>ji||t!==Ge||i<8||i>15||n<0||n>9||r<0||r>Yi||i===8&&f!==1)return ie(e,B);i===8&&(i=9);let o=new _a;return e.state=o,o.strm=e,o.status=ce,o.wrap=f,o.gzhead=null,o.w_bits=i,o.w_size=1<Ln(e,n,Ge,Vi,Wi,Xi),da=(e,n)=>{if(Ne(e)||n>Ut||n<0)return e?ie(e,B):B;let t=e.state;if(!e.output||e.avail_in!==0&&!e.input||t.status===xe&&n!==U)return ie(e,e.avail_out===0?it:B);let i=t.last_flush;if(t.last_flush=n,t.pending!==0){if($(e),e.avail_out===0)return t.last_flush=-1,D}else if(e.avail_in===0&&Ft(n)<=Ft(i)&&n!==U)return ie(e,it);if(t.status===xe&&e.avail_in!==0)return ie(e,it);if(t.status===ce&&t.wrap===0&&(t.status=ne),t.status===ce){let a=Ge+(t.w_bits-8<<4)<<8,r=-1;if(t.strategy>=Ue||t.level<2?r=0:t.level<6?r=1:t.level===6?r=2:r=3,a|=r<<6,t.strstart!==0&&(a|=ia),a+=31-a%31,be(t,a),t.strstart!==0&&(be(t,e.adler>>>16),be(t,e.adler&65535)),e.adler=1,t.status=ne,$(e),t.pending!==0)return t.last_flush=-1,D}if(t.status===St){if(e.adler=0,A(t,31),A(t,139),A(t,8),t.gzhead)A(t,(t.gzhead.text?1:0)+(t.gzhead.hcrc?2:0)+(t.gzhead.extra?4:0)+(t.gzhead.name?8:0)+(t.gzhead.comment?16:0)),A(t,t.gzhead.time&255),A(t,t.gzhead.time>>8&255),A(t,t.gzhead.time>>16&255),A(t,t.gzhead.time>>24&255),A(t,t.level===9?2:t.strategy>=Ue||t.level<2?4:0),A(t,t.gzhead.os&255),t.gzhead.extra&&t.gzhead.extra.length&&(A(t,t.gzhead.extra.length&255),A(t,t.gzhead.extra.length>>8&255)),t.gzhead.hcrc&&(e.adler=I(e.adler,t.pending_buf,t.pending,0)),t.gzindex=0,t.status=gt;else if(A(t,0),A(t,0),A(t,0),A(t,0),A(t,0),A(t,t.level===9?2:t.strategy>=Ue||t.level<2?4:0),A(t,aa),t.status=ne,$(e),t.pending!==0)return t.last_flush=-1,D}if(t.status===gt){if(t.gzhead.extra){let a=t.pending,r=(t.gzhead.extra.length&65535)-t.gzindex;for(;t.pending+r>t.pending_buf_size;){let o=t.pending_buf_size-t.pending;if(t.pending_buf.set(t.gzhead.extra.subarray(t.gzindex,t.gzindex+o),t.pending),t.pending=t.pending_buf_size,t.gzhead.hcrc&&t.pending>a&&(e.adler=I(e.adler,t.pending_buf,t.pending-a,a)),t.gzindex+=o,$(e),t.pending!==0)return t.last_flush=-1,D;a=0,r-=o}let f=new Uint8Array(t.gzhead.extra);t.pending_buf.set(f.subarray(t.gzindex,t.gzindex+r),t.pending),t.pending+=r,t.gzhead.hcrc&&t.pending>a&&(e.adler=I(e.adler,t.pending_buf,t.pending-a,a)),t.gzindex=0}t.status=bt}if(t.status===bt){if(t.gzhead.name){let a=t.pending,r;do{if(t.pending===t.pending_buf_size){if(t.gzhead.hcrc&&t.pending>a&&(e.adler=I(e.adler,t.pending_buf,t.pending-a,a)),$(e),t.pending!==0)return t.last_flush=-1,D;a=0}t.gzindexa&&(e.adler=I(e.adler,t.pending_buf,t.pending-a,a)),t.gzindex=0}t.status=xt}if(t.status===xt){if(t.gzhead.comment){let a=t.pending,r;do{if(t.pending===t.pending_buf_size){if(t.gzhead.hcrc&&t.pending>a&&(e.adler=I(e.adler,t.pending_buf,t.pending-a,a)),$(e),t.pending!==0)return t.last_flush=-1,D;a=0}t.gzindexa&&(e.adler=I(e.adler,t.pending_buf,t.pending-a,a))}t.status=vt}if(t.status===vt){if(t.gzhead.hcrc){if(t.pending+2>t.pending_buf_size&&($(e),t.pending!==0))return t.last_flush=-1,D;A(t,e.adler&255),A(t,e.adler>>8&255),e.adler=0}if(t.status=ne,$(e),t.pending!==0)return t.last_flush=-1,D}if(e.avail_in!==0||t.lookahead!==0||n!==q&&t.status!==xe){let a=t.level===0?Zn(t,n):t.strategy===Ue?fa(t,n):t.strategy===Ki?oa(t,n):ve[t.level].func(t,n);if((a===re||a===ge)&&(t.status=xe),a===Z||a===re)return e.avail_out===0&&(t.last_flush=-1),D;if(a===pe&&(n===Mi?Ui(t):n!==Ut&&(wt(t,0,0,!1),n===Fi&&(j(t.head),t.lookahead===0&&(t.strstart=0,t.block_start=0,t.insert=0))),$(e),e.avail_out===0))return t.last_flush=-1,D}return n!==U?D:t.wrap<=0?Mt:(t.wrap===2?(A(t,e.adler&255),A(t,e.adler>>8&255),A(t,e.adler>>16&255),A(t,e.adler>>24&255),A(t,e.total_in&255),A(t,e.total_in>>8&255),A(t,e.total_in>>16&255),A(t,e.total_in>>24&255)):(be(t,e.adler>>>16),be(t,e.adler&65535)),$(e),t.wrap>0&&(t.wrap=-t.wrap),t.pending!==0?D:Mt)},ua=e=>{if(Ne(e))return B;let n=e.state.status;return e.state=null,n===ne?ie(e,Hi):D},wa=(e,n)=>{let t=n.length;if(Ne(e))return B;let i=e.state,a=i.wrap;if(a===2||a===1&&i.status!==ce||i.lookahead)return B;if(a===1&&(e.adler=ze(e.adler,n,t,0)),i.wrap=0,t>=i.w_size){a===0&&(j(i.head),i.strstart=0,i.block_start=0,i.insert=0);let h=new Uint8Array(i.w_size);h.set(n.subarray(t-i.w_size,t),0),n=h,t=i.w_size}let r=e.avail_in,f=e.next_in,o=e.input;for(e.avail_in=t,e.next_in=0,e.input=n,de(i);i.lookahead>=v;){let h=i.strstart,l=i.lookahead-(v-1);do i.ins_h=J(i,i.ins_h,i.window[h+v-1]),i.prev[h&i.w_mask]=i.head[i.ins_h],i.head[i.ins_h]=h,h++;while(--l);i.strstart=h,i.lookahead=v-1,de(i)}return i.strstart+=i.lookahead,i.block_start=i.strstart,i.insert=i.lookahead,i.lookahead=0,i.match_length=i.prev_length=v-1,i.match_available=0,e.next_in=f,e.input=o,e.avail_in=r,i.wrap=a,D},pa=ca,ga=Ln,ba=$n,xa=Cn,va=ha,ka=da,ma=ua,Ea=wa,ya="pako deflate (from Nodeca project)",me={deflateInit:pa,deflateInit2:ga,deflateReset:ba,deflateResetKeep:xa,deflateSetHeader:va,deflate:ka,deflateEnd:ma,deflateSetDictionary:Ea,deflateInfo:ya},Aa=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),Sa=function(e){let n=Array.prototype.slice.call(arguments,1);for(;n.length;){let t=n.shift();if(t){if(typeof t!="object")throw new TypeError(t+"must be non-object");for(let i in t)Aa(t,i)&&(e[i]=t[i])}}return e},Ta=e=>{let n=0;for(let i=0,a=e.length;i=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;Re[254]=Re[254]=1;var za=e=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(e);let n,t,i,a,r,f=e.length,o=0;for(a=0;a>>6,n[r++]=128|t&63):t<65536?(n[r++]=224|t>>>12,n[r++]=128|t>>>6&63,n[r++]=128|t&63):(n[r++]=240|t>>>18,n[r++]=128|t>>>12&63,n[r++]=128|t>>>6&63,n[r++]=128|t&63);return n},Ra=(e,n)=>{if(n<65534&&e.subarray&&Un)return String.fromCharCode.apply(null,e.length===n?e:e.subarray(0,n));let t="";for(let i=0;i{let t=n||e.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(e.subarray(0,n));let i,a,r=new Array(t*2);for(a=0,i=0;i4){r[a++]=65533,i+=o-1;continue}for(f&=o===2?31:o===3?15:7;o>1&&i1){r[a++]=65533;continue}f<65536?r[a++]=f:(f-=65536,r[a++]=55296|f>>10&1023,r[a++]=56320|f&1023)}return Ra(r,a)},Ia=(e,n)=>{n=n||e.length,n>e.length&&(n=e.length);let t=n-1;for(;t>=0&&(e[t]&192)===128;)t--;return t<0||t===0?n:t+Re[e[t]]>n?t:n},Oe={string2buf:za,buf2string:Oa,utf8border:Ia};function Da(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}var Mn=Da,Fn=Object.prototype.toString,{Z_NO_FLUSH:Na,Z_SYNC_FLUSH:Za,Z_FULL_FLUSH:Ca,Z_FINISH:$a,Z_OK:Ye,Z_STREAM_END:La,Z_DEFAULT_COMPRESSION:Ua,Z_DEFAULT_STRATEGY:Ma,Z_DEFLATED:Fa}=we;function Ze(e){this.options=je.assign({level:Ua,method:Fa,chunkSize:16384,windowBits:15,memLevel:8,strategy:Ma},e||{});let n=this.options;n.raw&&n.windowBits>0?n.windowBits=-n.windowBits:n.gzip&&n.windowBits>0&&n.windowBits<16&&(n.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Mn,this.strm.avail_out=0;let t=me.deflateInit2(this.strm,n.level,n.method,n.windowBits,n.memLevel,n.strategy);if(t!==Ye)throw new Error(ae[t]);if(n.header&&me.deflateSetHeader(this.strm,n.header),n.dictionary){let i;if(typeof n.dictionary=="string"?i=Oe.string2buf(n.dictionary):Fn.call(n.dictionary)==="[object ArrayBuffer]"?i=new Uint8Array(n.dictionary):i=n.dictionary,t=me.deflateSetDictionary(this.strm,i),t!==Ye)throw new Error(ae[t]);this._dict_set=!0}}Ze.prototype.push=function(e,n){let t=this.strm,i=this.options.chunkSize,a,r;if(this.ended)return!1;for(n===~~n?r=n:r=n===!0?$a:Na,typeof e=="string"?t.input=Oe.string2buf(e):Fn.call(e)==="[object ArrayBuffer]"?t.input=new Uint8Array(e):t.input=e,t.next_in=0,t.avail_in=t.input.length;;){if(t.avail_out===0&&(t.output=new Uint8Array(i),t.next_out=0,t.avail_out=i),(r===Za||r===Ca)&&t.avail_out<=6){this.onData(t.output.subarray(0,t.next_out)),t.avail_out=0;continue}if(a=me.deflate(t,r),a===La)return t.next_out>0&&this.onData(t.output.subarray(0,t.next_out)),a=me.deflateEnd(this.strm),this.onEnd(a),this.ended=!0,a===Ye;if(t.avail_out===0){this.onData(t.output);continue}if(r>0&&t.next_out>0){this.onData(t.output.subarray(0,t.next_out)),t.avail_out=0;continue}if(t.avail_in===0)break}return!0};Ze.prototype.onData=function(e){this.chunks.push(e)};Ze.prototype.onEnd=function(e){e===Ye&&(this.result=je.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function Tt(e,n){let t=new Ze(n);if(t.push(e,!0),t.err)throw t.msg||ae[t.err];return t.result}function Ha(e,n){return n=n||{},n.raw=!0,Tt(e,n)}function Ba(e,n){return n=n||{},n.gzip=!0,Tt(e,n)}var Pa=Ze,Ka=Tt,Ya=Ha,Xa=Ba,Ga=we,ja={Deflate:Pa,deflate:Ka,deflateRaw:Ya,gzip:Xa,constants:Ga},Me=16209,Va=16191,Wa=function(n,t){let i,a,r,f,o,h,l,s,E,d,_,u,R,k,g,S,b,c,y,O,w,T,m,p,x=n.state;i=n.next_in,m=n.input,a=i+(n.avail_in-5),r=n.next_out,p=n.output,f=r-(t-n.avail_out),o=r+(n.avail_out-257),h=x.dmax,l=x.wsize,s=x.whave,E=x.wnext,d=x.window,_=x.hold,u=x.bits,R=x.lencode,k=x.distcode,g=(1<>>24,_>>>=c,u-=c,c=b>>>16&255,c===0)p[r++]=b&65535;else if(c&16){y=b&65535,c&=15,c&&(u>>=c,u-=c),u<15&&(_+=m[i++]<>>24,_>>>=c,u-=c,c=b>>>16&255,c&16){if(O=b&65535,c&=15,uh){n.msg="invalid distance too far back",x.mode=Me;break e}if(_>>>=c,u-=c,c=r-f,O>c){if(c=O-c,c>s&&x.sane){n.msg="invalid distance too far back",x.mode=Me;break e}if(w=0,T=d,E===0){if(w+=l-c,c2;)p[r++]=T[w++],p[r++]=T[w++],p[r++]=T[w++],y-=3;y&&(p[r++]=T[w++],y>1&&(p[r++]=T[w++]))}else{w=r-O;do p[r++]=p[w++],p[r++]=p[w++],p[r++]=p[w++],y-=3;while(y>2);y&&(p[r++]=p[w++],y>1&&(p[r++]=p[w++]))}}else if((c&64)===0){b=k[(b&65535)+(_&(1<>3,i-=y,u-=y<<3,_&=(1<{let h=o.bits,l=0,s=0,E=0,d=0,_=0,u=0,R=0,k=0,g=0,S=0,b,c,y,O,w,T=null,m,p=new Uint16Array(_e+1),x=new Uint16Array(_e+1),ee=null,Dt,$e,Le;for(l=0;l<=_e;l++)p[l]=0;for(s=0;s=1&&p[d]===0;d--);if(_>d&&(_=d),d===0)return a[r++]=1<<24|64<<16|0,a[r++]=1<<24|64<<16|0,o.bits=1,0;for(E=1;E0&&(e===Pt||d!==1))return-1;for(x[1]=0,l=1;l<_e;l++)x[l+1]=x[l]+p[l];for(s=0;sHt||e===Kt&&g>Bt)return 1;for(;;){Dt=l-R,f[s]+1=m?($e=ee[f[s]-m],Le=T[f[s]-m]):($e=96,Le=0),b=1<>R)+c]=Dt<<24|$e<<16|Le|0;while(c!==0);for(b=1<>=1;if(b!==0?(S&=b-1,S+=b):S=0,s++,--p[l]===0){if(l===d)break;l=n[t+f[s]]}if(l>_&&(S&O)!==y){for(R===0&&(R=_),w+=E,u=l-R,k=1<Ht||e===Kt&&g>Bt)return 1;y=S&O,a[y]=_<<24|u<<16|w-r|0}}return S!==0&&(a[w+S]=l-R<<24|64<<16|0),o.bits=_,0},Ee=tr,nr=0,Hn=1,Bn=2,{Z_FINISH:Yt,Z_BLOCK:ir,Z_TREES:Fe,Z_OK:le,Z_STREAM_END:ar,Z_NEED_DICT:rr,Z_STREAM_ERROR:M,Z_DATA_ERROR:Pn,Z_MEM_ERROR:Kn,Z_BUF_ERROR:lr,Z_DEFLATED:Xt}=we,Ve=16180,Gt=16181,jt=16182,Vt=16183,Wt=16184,qt=16185,Jt=16186,Qt=16187,en=16188,tn=16189,Xe=16190,K=16191,lt=16192,nn=16193,ot=16194,an=16195,rn=16196,ln=16197,on=16198,He=16199,Be=16200,fn=16201,sn=16202,_n=16203,hn=16204,cn=16205,ft=16206,dn=16207,un=16208,z=16209,Yn=16210,Xn=16211,or=852,fr=592,sr=15,_r=sr,wn=e=>(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24);function hr(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}var oe=e=>{if(!e)return 1;let n=e.state;return!n||n.strm!==e||n.modeXn?1:0},Gn=e=>{if(oe(e))return M;let n=e.state;return e.total_in=e.total_out=n.total=0,e.msg="",n.wrap&&(e.adler=n.wrap&1),n.mode=Ve,n.last=0,n.havedict=0,n.flags=-1,n.dmax=32768,n.head=null,n.hold=0,n.bits=0,n.lencode=n.lendyn=new Int32Array(or),n.distcode=n.distdyn=new Int32Array(fr),n.sane=1,n.back=-1,le},jn=e=>{if(oe(e))return M;let n=e.state;return n.wsize=0,n.whave=0,n.wnext=0,Gn(e)},Vn=(e,n)=>{let t;if(oe(e))return M;let i=e.state;return n<0?(t=0,n=-n):(t=(n>>4)+5,n<48&&(n&=15)),n&&(n<8||n>15)?M:(i.window!==null&&i.wbits!==n&&(i.window=null),i.wrap=t,i.wbits=n,jn(e))},Wn=(e,n)=>{if(!e)return M;let t=new hr;e.state=t,t.strm=e,t.window=null,t.mode=Ve;let i=Vn(e,n);return i!==le&&(e.state=null),i},cr=e=>Wn(e,_r),pn=!0,st,_t,dr=e=>{if(pn){st=new Int32Array(512),_t=new Int32Array(32);let n=0;for(;n<144;)e.lens[n++]=8;for(;n<256;)e.lens[n++]=9;for(;n<280;)e.lens[n++]=7;for(;n<288;)e.lens[n++]=8;for(Ee(Hn,e.lens,0,288,st,0,e.work,{bits:9}),n=0;n<32;)e.lens[n++]=5;Ee(Bn,e.lens,0,32,_t,0,e.work,{bits:5}),pn=!1}e.lencode=st,e.lenbits=9,e.distcode=_t,e.distbits=5},qn=(e,n,t,i)=>{let a,r=e.state;return r.window===null&&(r.wsize=1<=r.wsize?(r.window.set(n.subarray(t-r.wsize,t),0),r.wnext=0,r.whave=r.wsize):(a=r.wsize-r.wnext,a>i&&(a=i),r.window.set(n.subarray(t-i,t-i+a),r.wnext),i-=a,i?(r.window.set(n.subarray(t-i,t),0),r.wnext=i,r.whave=r.wsize):(r.wnext+=a,r.wnext===r.wsize&&(r.wnext=0),r.whave{let t,i,a,r,f,o,h,l,s,E,d,_,u,R,k=0,g,S,b,c,y,O,w,T,m=new Uint8Array(4),p,x,ee=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(oe(e)||!e.output||!e.input&&e.avail_in!==0)return M;t=e.state,t.mode===K&&(t.mode=lt),f=e.next_out,a=e.output,h=e.avail_out,r=e.next_in,i=e.input,o=e.avail_in,l=t.hold,s=t.bits,E=o,d=h,T=le;e:for(;;)switch(t.mode){case Ve:if(t.wrap===0){t.mode=lt;break}for(;s<16;){if(o===0)break e;o--,l+=i[r++]<>>8&255,t.check=I(t.check,m,2,0),l=0,s=0,t.mode=Gt;break}if(t.head&&(t.head.done=!1),!(t.wrap&1)||(((l&255)<<8)+(l>>8))%31){e.msg="incorrect header check",t.mode=z;break}if((l&15)!==Xt){e.msg="unknown compression method",t.mode=z;break}if(l>>>=4,s-=4,w=(l&15)+8,t.wbits===0&&(t.wbits=w),w>15||w>t.wbits){e.msg="invalid window size",t.mode=z;break}t.dmax=1<>8&1),t.flags&512&&t.wrap&4&&(m[0]=l&255,m[1]=l>>>8&255,t.check=I(t.check,m,2,0)),l=0,s=0,t.mode=jt;case jt:for(;s<32;){if(o===0)break e;o--,l+=i[r++]<>>8&255,m[2]=l>>>16&255,m[3]=l>>>24&255,t.check=I(t.check,m,4,0)),l=0,s=0,t.mode=Vt;case Vt:for(;s<16;){if(o===0)break e;o--,l+=i[r++]<>8),t.flags&512&&t.wrap&4&&(m[0]=l&255,m[1]=l>>>8&255,t.check=I(t.check,m,2,0)),l=0,s=0,t.mode=Wt;case Wt:if(t.flags&1024){for(;s<16;){if(o===0)break e;o--,l+=i[r++]<>>8&255,t.check=I(t.check,m,2,0)),l=0,s=0}else t.head&&(t.head.extra=null);t.mode=qt;case qt:if(t.flags&1024&&(_=t.length,_>o&&(_=o),_&&(t.head&&(w=t.head.extra_len-t.length,t.head.extra||(t.head.extra=new Uint8Array(t.head.extra_len)),t.head.extra.set(i.subarray(r,r+_),w)),t.flags&512&&t.wrap&4&&(t.check=I(t.check,i,_,r)),o-=_,r+=_,t.length-=_),t.length))break e;t.length=0,t.mode=Jt;case Jt:if(t.flags&2048){if(o===0)break e;_=0;do w=i[r+_++],t.head&&w&&t.length<65536&&(t.head.name+=String.fromCharCode(w));while(w&&_>9&1,t.head.done=!0),e.adler=t.check=0,t.mode=K;break;case tn:for(;s<32;){if(o===0)break e;o--,l+=i[r++]<>>=s&7,s-=s&7,t.mode=ft;break}for(;s<3;){if(o===0)break e;o--,l+=i[r++]<>>=1,s-=1,l&3){case 0:t.mode=nn;break;case 1:if(dr(t),t.mode=He,n===Fe){l>>>=2,s-=2;break e}break;case 2:t.mode=rn;break;case 3:e.msg="invalid block type",t.mode=z}l>>>=2,s-=2;break;case nn:for(l>>>=s&7,s-=s&7;s<32;){if(o===0)break e;o--,l+=i[r++]<>>16^65535)){e.msg="invalid stored block lengths",t.mode=z;break}if(t.length=l&65535,l=0,s=0,t.mode=ot,n===Fe)break e;case ot:t.mode=an;case an:if(_=t.length,_){if(_>o&&(_=o),_>h&&(_=h),_===0)break e;a.set(i.subarray(r,r+_),f),o-=_,r+=_,h-=_,f+=_,t.length-=_;break}t.mode=K;break;case rn:for(;s<14;){if(o===0)break e;o--,l+=i[r++]<>>=5,s-=5,t.ndist=(l&31)+1,l>>>=5,s-=5,t.ncode=(l&15)+4,l>>>=4,s-=4,t.nlen>286||t.ndist>30){e.msg="too many length or distance symbols",t.mode=z;break}t.have=0,t.mode=ln;case ln:for(;t.have>>=3,s-=3}for(;t.have<19;)t.lens[ee[t.have++]]=0;if(t.lencode=t.lendyn,t.lenbits=7,p={bits:t.lenbits},T=Ee(nr,t.lens,0,19,t.lencode,0,t.work,p),t.lenbits=p.bits,T){e.msg="invalid code lengths set",t.mode=z;break}t.have=0,t.mode=on;case on:for(;t.have>>24,S=k>>>16&255,b=k&65535,!(g<=s);){if(o===0)break e;o--,l+=i[r++]<>>=g,s-=g,t.lens[t.have++]=b;else{if(b===16){for(x=g+2;s>>=g,s-=g,t.have===0){e.msg="invalid bit length repeat",t.mode=z;break}w=t.lens[t.have-1],_=3+(l&3),l>>>=2,s-=2}else if(b===17){for(x=g+3;s>>=g,s-=g,w=0,_=3+(l&7),l>>>=3,s-=3}else{for(x=g+7;s>>=g,s-=g,w=0,_=11+(l&127),l>>>=7,s-=7}if(t.have+_>t.nlen+t.ndist){e.msg="invalid bit length repeat",t.mode=z;break}for(;_--;)t.lens[t.have++]=w}}if(t.mode===z)break;if(t.lens[256]===0){e.msg="invalid code -- missing end-of-block",t.mode=z;break}if(t.lenbits=9,p={bits:t.lenbits},T=Ee(Hn,t.lens,0,t.nlen,t.lencode,0,t.work,p),t.lenbits=p.bits,T){e.msg="invalid literal/lengths set",t.mode=z;break}if(t.distbits=6,t.distcode=t.distdyn,p={bits:t.distbits},T=Ee(Bn,t.lens,t.nlen,t.ndist,t.distcode,0,t.work,p),t.distbits=p.bits,T){e.msg="invalid distances set",t.mode=z;break}if(t.mode=He,n===Fe)break e;case He:t.mode=Be;case Be:if(o>=6&&h>=258){e.next_out=f,e.avail_out=h,e.next_in=r,e.avail_in=o,t.hold=l,t.bits=s,Wa(e,d),f=e.next_out,a=e.output,h=e.avail_out,r=e.next_in,i=e.input,o=e.avail_in,l=t.hold,s=t.bits,t.mode===K&&(t.back=-1);break}for(t.back=0;k=t.lencode[l&(1<>>24,S=k>>>16&255,b=k&65535,!(g<=s);){if(o===0)break e;o--,l+=i[r++]<>c)],g=k>>>24,S=k>>>16&255,b=k&65535,!(c+g<=s);){if(o===0)break e;o--,l+=i[r++]<>>=c,s-=c,t.back+=c}if(l>>>=g,s-=g,t.back+=g,t.length=b,S===0){t.mode=cn;break}if(S&32){t.back=-1,t.mode=K;break}if(S&64){e.msg="invalid literal/length code",t.mode=z;break}t.extra=S&15,t.mode=fn;case fn:if(t.extra){for(x=t.extra;s>>=t.extra,s-=t.extra,t.back+=t.extra}t.was=t.length,t.mode=sn;case sn:for(;k=t.distcode[l&(1<>>24,S=k>>>16&255,b=k&65535,!(g<=s);){if(o===0)break e;o--,l+=i[r++]<>c)],g=k>>>24,S=k>>>16&255,b=k&65535,!(c+g<=s);){if(o===0)break e;o--,l+=i[r++]<>>=c,s-=c,t.back+=c}if(l>>>=g,s-=g,t.back+=g,S&64){e.msg="invalid distance code",t.mode=z;break}t.offset=b,t.extra=S&15,t.mode=_n;case _n:if(t.extra){for(x=t.extra;s>>=t.extra,s-=t.extra,t.back+=t.extra}if(t.offset>t.dmax){e.msg="invalid distance too far back",t.mode=z;break}t.mode=hn;case hn:if(h===0)break e;if(_=d-h,t.offset>_){if(_=t.offset-_,_>t.whave&&t.sane){e.msg="invalid distance too far back",t.mode=z;break}_>t.wnext?(_-=t.wnext,u=t.wsize-_):u=t.wnext-_,_>t.length&&(_=t.length),R=t.window}else R=a,u=f-t.offset,_=t.length;_>h&&(_=h),h-=_,t.length-=_;do a[f++]=R[u++];while(--_);t.length===0&&(t.mode=Be);break;case cn:if(h===0)break e;a[f++]=t.length,h--,t.mode=Be;break;case ft:if(t.wrap){for(;s<32;){if(o===0)break e;o--,l|=i[r++]<{if(oe(e))return M;let n=e.state;return n.window&&(n.window=null),e.state=null,le},pr=(e,n)=>{if(oe(e))return M;let t=e.state;return(t.wrap&2)===0?M:(t.head=n,n.done=!1,le)},gr=(e,n)=>{let t=n.length,i,a,r;return oe(e)||(i=e.state,i.wrap!==0&&i.mode!==Xe)?M:i.mode===Xe&&(a=1,a=ze(a,n,t,0),a!==i.check)?Pn:(r=qn(e,n,t,t),r?(i.mode=Yn,Kn):(i.havedict=1,le))},br=jn,xr=Vn,vr=Gn,kr=cr,mr=Wn,Er=ur,yr=wr,Ar=pr,Sr=gr,Tr="pako inflate (from Nodeca project)",X={inflateReset:br,inflateReset2:xr,inflateResetKeep:vr,inflateInit:kr,inflateInit2:mr,inflate:Er,inflateEnd:yr,inflateGetHeader:Ar,inflateSetDictionary:Sr,inflateInfo:Tr};function zr(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var Rr=zr,Jn=Object.prototype.toString,{Z_NO_FLUSH:Or,Z_FINISH:Ir,Z_OK:Ie,Z_STREAM_END:ht,Z_NEED_DICT:ct,Z_STREAM_ERROR:Dr,Z_DATA_ERROR:gn,Z_MEM_ERROR:Nr}=we;function Ce(e){this.options=je.assign({chunkSize:1024*64,windowBits:15,to:""},e||{});let n=this.options;n.raw&&n.windowBits>=0&&n.windowBits<16&&(n.windowBits=-n.windowBits,n.windowBits===0&&(n.windowBits=-15)),n.windowBits>=0&&n.windowBits<16&&!(e&&e.windowBits)&&(n.windowBits+=32),n.windowBits>15&&n.windowBits<48&&(n.windowBits&15)===0&&(n.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Mn,this.strm.avail_out=0;let t=X.inflateInit2(this.strm,n.windowBits);if(t!==Ie)throw new Error(ae[t]);if(this.header=new Rr,X.inflateGetHeader(this.strm,this.header),n.dictionary&&(typeof n.dictionary=="string"?n.dictionary=Oe.string2buf(n.dictionary):Jn.call(n.dictionary)==="[object ArrayBuffer]"&&(n.dictionary=new Uint8Array(n.dictionary)),n.raw&&(t=X.inflateSetDictionary(this.strm,n.dictionary),t!==Ie)))throw new Error(ae[t])}Ce.prototype.push=function(e,n){let t=this.strm,i=this.options.chunkSize,a=this.options.dictionary,r,f,o;if(this.ended)return!1;for(n===~~n?f=n:f=n===!0?Ir:Or,Jn.call(e)==="[object ArrayBuffer]"?t.input=new Uint8Array(e):t.input=e,t.next_in=0,t.avail_in=t.input.length;;){for(t.avail_out===0&&(t.output=new Uint8Array(i),t.next_out=0,t.avail_out=i),r=X.inflate(t,f),r===ct&&a&&(r=X.inflateSetDictionary(t,a),r===Ie?r=X.inflate(t,f):r===gn&&(r=ct));t.avail_in>0&&r===ht&&t.state.wrap>0&&e[t.next_in]!==0;)X.inflateReset(t),r=X.inflate(t,f);switch(r){case Dr:case gn:case ct:case Nr:return this.onEnd(r),this.ended=!0,!1}if(o=t.avail_out,t.next_out&&(t.avail_out===0||r===ht))if(this.options.to==="string"){let h=Oe.utf8border(t.output,t.next_out),l=t.next_out-h,s=Oe.buf2string(t.output,h);t.next_out=l,t.avail_out=i-l,l&&t.output.set(t.output.subarray(h,h+l),0),this.onData(s)}else this.onData(t.output.length===t.next_out?t.output:t.output.subarray(0,t.next_out));if(!(r===Ie&&o===0)){if(r===ht)return r=X.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,!0;if(t.avail_in===0)break}}return!0};Ce.prototype.onData=function(e){this.chunks.push(e)};Ce.prototype.onEnd=function(e){e===Ie&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=je.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function zt(e,n){let t=new Ce(n);if(t.push(e),t.err)throw t.msg||ae[t.err];return t.result}function Zr(e,n){return n=n||{},n.raw=!0,zt(e,n)}var Cr=Ce,$r=zt,Lr=Zr,Ur=zt,Mr=we,Fr={Inflate:Cr,inflate:$r,inflateRaw:Lr,ungzip:Ur,constants:Mr},{Deflate:Jr,deflate:Qr,deflateRaw:el,gzip:tl}=ja,{Inflate:nl,inflate:il,inflateRaw:al,ungzip:Hr}=Fr;var Qn=Hr;var ei=Uint8Array.from([0,0,0,1,0,0]),Br=4294967296,N=(...e)=>{let n=e.reduce((a,r)=>a+r.length,0),t=new Uint8Array(n),i=0;for(let a of e)t.set(a,i),i+=a.length;return t},fe=(e,n)=>e.length===n.length&&e.every((t,i)=>t===n[i]);function Rt(e,n){let t=0,i=1;for(let a=0;a<10&&n+a>>0,i=Math.floor(n/Br)>>>0,a=[];do{let r=t&127;t=(t>>>7|(i&127)<<25)>>>0,i>>>=7;let f=i!==0||t!==0;a.push(r|(f?128:0))}while(i!==0||t!==0);return Uint8Array.from(a)}var Q=(e,n)=>G(e<<3|n);function We(e,n){return N(Q(e,2),G(n.length),n)}function qe(e){let n=[],t=0;for(;te.length)throw new Error("truncated fixed64");o=e.slice(t,t+8),t+=8}else if(f===2){let h=Rt(e,t);t=h.next;let l=h.value;if(!Number.isSafeInteger(l)||t+l>e.length)throw new Error("truncated length-delimited field");o=e.slice(t,t+l),t+=l}else if(f===5){if(t+4>e.length)throw new Error("truncated fixed32");o=e.slice(t,t+4),t+=4}else throw new Error(`unsupported wire type ${f}`);n.push({number:r,wireType:f,value:o,raw:e.slice(i,t)})}return n}function ti(e,n,t){let i=qe(e);if(!i.some(h=>h.number===1&&h.wireType===0)||!i.some(h=>h.number===2&&h.wireType===0))return e;let a=!1,r=!1,f=i.map(h=>h.wireType!==0?h.raw:h.number===1?N(Q(1,0),G(Math.round(n.latitude*1e8))):h.number===2?N(Q(2,0),G(Math.round(n.longitude*1e8))):h.number===3?N(Q(3,0),G(n.accuracy)):n.motionSimulationEnabled&&h.number===11?(a=!0,N(Q(11,0),G(63))):n.motionSimulationEnabled&&h.number===12?(r=!0,N(Q(12,0),G(467))):h.raw);n.motionSimulationEnabled&&!a&&f.push(N(Q(11,0),G(63))),n.motionSimulationEnabled&&!r&&f.push(N(Q(12,0),G(467)));let o=N(...f);return fe(o,e)||(t.locations+=1),o}function Pr(e,n,t){let i=qe(e);if(!i.some(o=>o.number===1&&o.wireType===2&&/^[0-9a-fA-F]{1,2}(:[0-9a-fA-F]{1,2}){5}$/.test(Array.from(o.value,h=>String.fromCharCode(h)).join(""))))return e;let r=!1,f=i.map(o=>{if(o.number!==2||o.wireType!==2)return o.raw;let h=ti(o.value,n,t);return r||(r=!fe(h,o.value)),We(2,h)});return r&&(t.wifi+=1),N(...f)}function Kr(e,n,t){let i=!1,a=qe(e).map(r=>{if(r.number!==5||r.wireType!==2)return r.raw;let f=ti(r.value,n,t);return i||(i=!fe(f,r.value)),We(5,f)});return i&&(t.cell+=1),N(...a)}function Je(e,n,t={wifi:0,cell:0,locations:0}){let i=qe(e).map(a=>a.number===2&&a.wireType===2?We(2,Pr(a.value,n,t)):(a.number===22||a.number===24)&&a.wireType===2?We(a.number,Kr(a.value,n,t)):a.raw);return{data:N(...i),stats:t}}var Ot=(e,n)=>e[n]<<8|e[n+1],Yr=(e,n)=>e[n]*16777216+(e[n+1]<<16)+(e[n+2]<<8)+e[n+3]>>>0,ni=e=>Uint8Array.from([e>>>8&255,e&255]),Xr=e=>Uint8Array.from([e>>>24&255,e>>>16&255,e>>>8&255,e&255]);function Gr(e,n){e:for(let t=0;t<=e.length-n.length;t+=1){for(let i=0;ie.length)throw new Error("truncated ARPC string");t+=2+Ot(e,t)}let i=t+4,a=i+4;if(a>e.length)throw new Error("truncated ARPC header");let r=Yr(e,i);if(!r||a+r>e.length)throw new Error("invalid ARPC length");let f=Je(e.slice(a,a+r),n);if(fe(f.data,e.slice(a,a+r)))throw new Error("unchanged ARPC");return{data:N(e.slice(0,i),Xr(f.data.length),f.data,e.slice(a+r)),stats:f.stats}}function Vr(e,n){let t=Gr(e,ei);if(t<0)throw new Error("marker not found");let i=t+ei.length,a=i+2,r=Ot(e,i);if(!r||a+r>e.length)throw new Error("invalid marker length");let f=Je(e.slice(a,a+r),n);if(f.data.length>65535||fe(f.data,e.slice(a,a+r)))throw new Error("unchanged marker");return{data:N(e.slice(0,i),ni(f.data.length),f.data,e.slice(a+r)),stats:f.stats}}function Wr(e,n,t){if(n+10>e.length)throw new Error("short frame");let i=Ot(e,n+8);if(!i||n+10+i>e.length)throw new Error("invalid frame");let a=Je(e.slice(n+10,n+10+i),t);if(a.data.length>65535||fe(a.data,e.slice(n+10,n+10+i)))throw new Error("unchanged frame");return{data:N(e.slice(0,n+8),ni(a.data.length),a.data,e.slice(n+10+i)),stats:a.stats}}function ii(e,n){for(let i of[jr,Vr])try{return i(e,n)}catch(a){}let t=[...new Set([0,2,4,6,8,10,12,14,16,...Array.from({length:Math.min(96,Math.max(0,e.length-10))+1},(i,a)=>a)])];for(let i of t)try{return Wr(e,i,n)}catch(a){}for(let i=0;i<=Math.min(256,e.length);i+=1)try{let a=Je(e.slice(i),n);if(!fe(a.data,e.slice(i)))return{data:N(e.slice(0,i),a.data),stats:a.stats}}catch(a){}throw new Error("no patchable wloc payload found")}var ai="locationSpoofer.settings.v1";function ri(){return typeof $task!="undefined"?"quantumultX":typeof $loon!="undefined"?"loon":typeof $rocket!="undefined"?"shadowrocket":typeof Egern!="undefined"?"egern":typeof $environment!="undefined"&&$environment["stash-version"]?"stash":typeof $environment!="undefined"&&$environment["surge-version"]?"surge":"unknown"}function li(e){let n=ri()==="quantumultX"?$prefs.valueForKey(e):$persistentStore.read(e);if(!n)return null;try{return JSON.parse(n)}catch(t){return null}}function oi(){let e=typeof $response=="undefined"?null:$response,n=e&&e.bodyBytes!=null?e.bodyBytes:e&&e.body;return n instanceof ArrayBuffer?new Uint8Array(n):ArrayBuffer.isView(n)?new Uint8Array(n.buffer,n.byteOffset,n.byteLength):typeof n=="string"?Uint8Array.from(n,t=>t.charCodeAt(0)&255):new Uint8Array}function qr(e,n){let t=Object.assign({},e||{});for(let i of["Content-Encoding","content-encoding","Transfer-Encoding","transfer-encoding"])delete t[i];return t["Content-Length"]=String(n),t}function fi(e){let n=typeof $response=="undefined"?{}:$response,t=qr(n.headers,e.length),i=ri();i==="quantumultX"?(delete t["Content-Length"],$done({status:"HTTP/1.1 200 OK",headers:t,bodyBytes:e.buffer})):i==="stash"?$done(Object.assign({},n,{status:200,headers:t,body:e})):$done({response:Object.assign({},n,{status:200,headers:t,body:e})})}function It(){$done({})}try{let e=li(ai),n=oi();if(!e||!e.enabled||!n.length)It();else{let i=n.length>=2&&n[0]===31&&n[1]===139?Qn(n):n,a=ii(i,{latitude:Number(e.latitude),longitude:Number(e.longitude),accuracy:Number(e.accuracy!=null?e.accuracy:25),motionSimulationEnabled:e.motionSimulationEnabled===!0});fi(a.data)}}catch(e){console.log(`[Location Spoofer] ${e&&e.message?e.message:e}`),It()}})(); +/*! Bundled license information: + +pako/dist/pako.esm.mjs: + (*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) *) +*/ diff --git a/ThirdParty/WlocScripts/modules/direct/wloc.conf b/ThirdParty/WlocScripts/modules/direct/wloc.conf new file mode 100644 index 0000000..db8fdfd --- /dev/null +++ b/ThirdParty/WlocScripts/modules/direct/wloc.conf @@ -0,0 +1,11 @@ +#!name=Apple WLOC 定位修改 +#!desc=Location Spoofer 第三方代理模块 +#!author=xweiba +#!homepage=https://github.com/xweiba/location-spoofer + +[rewrite_local] +^https?:\/\/gs-loc(-cn)?\.apple\.com\/clls\/wloc url script-response-body https://raw.githubusercontent.com/xweiba/location-spoofer/main/ThirdParty/WlocScripts/dist/v1/wloc.js +^https?:\/\/gs-loc(-cn)?\.apple\.com\/wloc-settings\/(save|version) url script-echo-response https://raw.githubusercontent.com/xweiba/location-spoofer/main/ThirdParty/WlocScripts/dist/v1/wloc-settings.js + +[mitm] +hostname = gs-loc.apple.com, gs-loc-cn.apple.com diff --git a/ThirdParty/WlocScripts/modules/direct/wloc.lpx b/ThirdParty/WlocScripts/modules/direct/wloc.lpx new file mode 100644 index 0000000..d5c9cd7 --- /dev/null +++ b/ThirdParty/WlocScripts/modules/direct/wloc.lpx @@ -0,0 +1,11 @@ +#!name=Apple WLOC 定位修改 +#!desc=Location Spoofer 第三方代理模块 +#!author=xweiba +#!homepage=https://github.com/xweiba/location-spoofer + +[Script] +http-response ^https?:\/\/gs-loc(-cn)?\.apple\.com\/clls\/wloc script-path=https://raw.githubusercontent.com/xweiba/location-spoofer/main/ThirdParty/WlocScripts/dist/v1/wloc.js, requires-body=true, binary-body-mode=true, timeout=30, tag=Apple WLOC +http-request ^https?:\/\/gs-loc(-cn)?\.apple\.com\/wloc-settings\/(save|version) script-path=https://raw.githubusercontent.com/xweiba/location-spoofer/main/ThirdParty/WlocScripts/dist/v1/wloc-settings.js, timeout=10, tag=WLOC Settings + +[MITM] +hostname = gs-loc.apple.com, gs-loc-cn.apple.com diff --git a/ThirdParty/WlocScripts/modules/direct/wloc.module b/ThirdParty/WlocScripts/modules/direct/wloc.module new file mode 100644 index 0000000..69f82bf --- /dev/null +++ b/ThirdParty/WlocScripts/modules/direct/wloc.module @@ -0,0 +1,12 @@ +#!name=Apple WLOC 定位修改 +#!desc=Location Spoofer 第三方代理模块 +#!author=xweiba +#!homepage=https://github.com/xweiba/location-spoofer +#!category=Tools + +[Script] +Apple WLOC = type=http-response,pattern=^https?:\/\/gs-loc(-cn)?\.apple\.com\/clls\/wloc,requires-body=1,binary-body-mode=1,max-size=0,timeout=30,script-path=https://raw.githubusercontent.com/xweiba/location-spoofer/main/ThirdParty/WlocScripts/dist/v1/wloc.js +WLOC Settings = type=http-request,pattern=^https?:\/\/gs-loc(-cn)?\.apple\.com\/wloc-settings\/(save|version),requires-body=0,max-size=0,timeout=10,script-path=https://raw.githubusercontent.com/xweiba/location-spoofer/main/ThirdParty/WlocScripts/dist/v1/wloc-settings.js + +[MITM] +hostname = %APPEND% gs-loc.apple.com, gs-loc-cn.apple.com diff --git a/ThirdParty/WlocScripts/modules/direct/wloc.sgmodule b/ThirdParty/WlocScripts/modules/direct/wloc.sgmodule new file mode 100644 index 0000000..4c041fe --- /dev/null +++ b/ThirdParty/WlocScripts/modules/direct/wloc.sgmodule @@ -0,0 +1,12 @@ +#!name=Apple WLOC 定位修改 +#!desc=Location Spoofer 第三方代理模块 +#!author=xweiba +#!homepage=https://github.com/xweiba/location-spoofer +#!category=Tools + +[Script] +Apple WLOC = type=http-response, pattern="^https?:\/\/gs-loc(-cn)?\.apple\.com\/clls\/wloc", requires-body=1, binary-body-mode=1, max-size=0, timeout=30, script-path=https://raw.githubusercontent.com/xweiba/location-spoofer/main/ThirdParty/WlocScripts/dist/v1/wloc.js +WLOC Settings = type=http-request, pattern="^https?:\/\/gs-loc(-cn)?\.apple\.com\/wloc-settings\/(save|version)", requires-body=0, max-size=0, timeout=10, script-path=https://raw.githubusercontent.com/xweiba/location-spoofer/main/ThirdParty/WlocScripts/dist/v1/wloc-settings.js + +[MITM] +hostname = %APPEND% gs-loc.apple.com, gs-loc-cn.apple.com diff --git a/ThirdParty/WlocScripts/modules/direct/wloc.stoverride b/ThirdParty/WlocScripts/modules/direct/wloc.stoverride new file mode 100644 index 0000000..01b536e --- /dev/null +++ b/ThirdParty/WlocScripts/modules/direct/wloc.stoverride @@ -0,0 +1,31 @@ +name: Apple WLOC 定位修改 +desc: Location Spoofer 第三方代理模块 +author: xweiba +homepage: https://github.com/xweiba/location-spoofer +category: Tools + +http: + mitm: + - "gs-loc.apple.com" + - "gs-loc-cn.apple.com" + script: + - match: ^https?:\/\/gs-loc(-cn)?\.apple\.com\/clls\/wloc + name: WLOC.Location + type: response + require-body: true + binary-mode: true + max-size: 0 + timeout: 30 + - match: ^https?:\/\/gs-loc(-cn)?\.apple\.com\/wloc-settings\/(save|version) + name: WLOC.Settings + type: request + require-body: false + timeout: 10 + +script-providers: + WLOC.Location: + url: https://raw.githubusercontent.com/xweiba/location-spoofer/main/ThirdParty/WlocScripts/dist/v1/wloc.js + interval: 86400 + WLOC.Settings: + url: https://raw.githubusercontent.com/xweiba/location-spoofer/main/ThirdParty/WlocScripts/dist/v1/wloc-settings.js + interval: 86400 diff --git a/ThirdParty/WlocScripts/package-lock.json b/ThirdParty/WlocScripts/package-lock.json new file mode 100644 index 0000000..344233c --- /dev/null +++ b/ThirdParty/WlocScripts/package-lock.json @@ -0,0 +1,508 @@ +{ + "name": "@location-spoofer/wloc-scripts", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "@location-spoofer/wloc-scripts", + "version": "1.0.0", + "dependencies": { + "pako": "2.1.0" + }, + "devDependencies": { + "esbuild": "0.25.8" + } + }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.25.8", + "resolved": "https://registry.npmmirror.com/@esbuild/aix-ppc64/-/aix-ppc64-0.25.8.tgz", + "integrity": "sha512-urAvrUedIqEiFR3FYSLTWQgLu5tb+m0qZw0NBEasUeo6wuqatkMDaRT+1uABiGXEu5vqgPd7FGE1BhsAIy9QVA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.25.8", + "resolved": "https://registry.npmmirror.com/@esbuild/android-arm/-/android-arm-0.25.8.tgz", + "integrity": "sha512-RONsAvGCz5oWyePVnLdZY/HHwA++nxYWIX1atInlaW6SEkwq6XkP3+cb825EUcRs5Vss/lGh/2YxAb5xqc07Uw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.25.8", + "resolved": "https://registry.npmmirror.com/@esbuild/android-arm64/-/android-arm64-0.25.8.tgz", + "integrity": "sha512-OD3p7LYzWpLhZEyATcTSJ67qB5D+20vbtr6vHlHWSQYhKtzUYrETuWThmzFpZtFsBIxRvhO07+UgVA9m0i/O1w==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.25.8", + "resolved": "https://registry.npmmirror.com/@esbuild/android-x64/-/android-x64-0.25.8.tgz", + "integrity": "sha512-yJAVPklM5+4+9dTeKwHOaA+LQkmrKFX96BM0A/2zQrbS6ENCmxc4OVoBs5dPkCCak2roAD+jKCdnmOqKszPkjA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.25.8", + "resolved": "https://registry.npmmirror.com/@esbuild/darwin-arm64/-/darwin-arm64-0.25.8.tgz", + "integrity": "sha512-Jw0mxgIaYX6R8ODrdkLLPwBqHTtYHJSmzzd+QeytSugzQ0Vg4c5rDky5VgkoowbZQahCbsv1rT1KW72MPIkevw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.25.8", + "resolved": "https://registry.npmmirror.com/@esbuild/darwin-x64/-/darwin-x64-0.25.8.tgz", + "integrity": "sha512-Vh2gLxxHnuoQ+GjPNvDSDRpoBCUzY4Pu0kBqMBDlK4fuWbKgGtmDIeEC081xi26PPjn+1tct+Bh8FjyLlw1Zlg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.25.8", + "resolved": "https://registry.npmmirror.com/@esbuild/freebsd-arm64/-/freebsd-arm64-0.25.8.tgz", + "integrity": "sha512-YPJ7hDQ9DnNe5vxOm6jaie9QsTwcKedPvizTVlqWG9GBSq+BuyWEDazlGaDTC5NGU4QJd666V0yqCBL2oWKPfA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.25.8", + "resolved": "https://registry.npmmirror.com/@esbuild/freebsd-x64/-/freebsd-x64-0.25.8.tgz", + "integrity": "sha512-MmaEXxQRdXNFsRN/KcIimLnSJrk2r5H8v+WVafRWz5xdSVmWLoITZQXcgehI2ZE6gioE6HirAEToM/RvFBeuhw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.25.8", + "resolved": "https://registry.npmmirror.com/@esbuild/linux-arm/-/linux-arm-0.25.8.tgz", + "integrity": "sha512-FuzEP9BixzZohl1kLf76KEVOsxtIBFwCaLupVuk4eFVnOZfU+Wsn+x5Ryam7nILV2pkq2TqQM9EZPsOBuMC+kg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.25.8", + "resolved": "https://registry.npmmirror.com/@esbuild/linux-arm64/-/linux-arm64-0.25.8.tgz", + "integrity": "sha512-WIgg00ARWv/uYLU7lsuDK00d/hHSfES5BzdWAdAig1ioV5kaFNrtK8EqGcUBJhYqotlUByUKz5Qo6u8tt7iD/w==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.25.8", + "resolved": "https://registry.npmmirror.com/@esbuild/linux-ia32/-/linux-ia32-0.25.8.tgz", + "integrity": "sha512-A1D9YzRX1i+1AJZuFFUMP1E9fMaYY+GnSQil9Tlw05utlE86EKTUA7RjwHDkEitmLYiFsRd9HwKBPEftNdBfjg==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.25.8", + "resolved": "https://registry.npmmirror.com/@esbuild/linux-loong64/-/linux-loong64-0.25.8.tgz", + "integrity": "sha512-O7k1J/dwHkY1RMVvglFHl1HzutGEFFZ3kNiDMSOyUrB7WcoHGf96Sh+64nTRT26l3GMbCW01Ekh/ThKM5iI7hQ==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.25.8", + "resolved": "https://registry.npmmirror.com/@esbuild/linux-mips64el/-/linux-mips64el-0.25.8.tgz", + "integrity": "sha512-uv+dqfRazte3BzfMp8PAQXmdGHQt2oC/y2ovwpTteqrMx2lwaksiFZ/bdkXJC19ttTvNXBuWH53zy/aTj1FgGw==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.25.8", + "resolved": "https://registry.npmmirror.com/@esbuild/linux-ppc64/-/linux-ppc64-0.25.8.tgz", + "integrity": "sha512-GyG0KcMi1GBavP5JgAkkstMGyMholMDybAf8wF5A70CALlDM2p/f7YFE7H92eDeH/VBtFJA5MT4nRPDGg4JuzQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.25.8", + "resolved": "https://registry.npmmirror.com/@esbuild/linux-riscv64/-/linux-riscv64-0.25.8.tgz", + "integrity": "sha512-rAqDYFv3yzMrq7GIcen3XP7TUEG/4LK86LUPMIz6RT8A6pRIDn0sDcvjudVZBiiTcZCY9y2SgYX2lgK3AF+1eg==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.25.8", + "resolved": "https://registry.npmmirror.com/@esbuild/linux-s390x/-/linux-s390x-0.25.8.tgz", + "integrity": "sha512-Xutvh6VjlbcHpsIIbwY8GVRbwoviWT19tFhgdA7DlenLGC/mbc3lBoVb7jxj9Z+eyGqvcnSyIltYUrkKzWqSvg==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.25.8", + "resolved": "https://registry.npmmirror.com/@esbuild/linux-x64/-/linux-x64-0.25.8.tgz", + "integrity": "sha512-ASFQhgY4ElXh3nDcOMTkQero4b1lgubskNlhIfJrsH5OKZXDpUAKBlNS0Kx81jwOBp+HCeZqmoJuihTv57/jvQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-arm64": { + "version": "0.25.8", + "resolved": "https://registry.npmmirror.com/@esbuild/netbsd-arm64/-/netbsd-arm64-0.25.8.tgz", + "integrity": "sha512-d1KfruIeohqAi6SA+gENMuObDbEjn22olAR7egqnkCD9DGBG0wsEARotkLgXDu6c4ncgWTZJtN5vcgxzWRMzcw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.25.8", + "resolved": "https://registry.npmmirror.com/@esbuild/netbsd-x64/-/netbsd-x64-0.25.8.tgz", + "integrity": "sha512-nVDCkrvx2ua+XQNyfrujIG38+YGyuy2Ru9kKVNyh5jAys6n+l44tTtToqHjino2My8VAY6Lw9H7RI73XFi66Cg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.25.8", + "resolved": "https://registry.npmmirror.com/@esbuild/openbsd-arm64/-/openbsd-arm64-0.25.8.tgz", + "integrity": "sha512-j8HgrDuSJFAujkivSMSfPQSAa5Fxbvk4rgNAS5i3K+r8s1X0p1uOO2Hl2xNsGFppOeHOLAVgYwDVlmxhq5h+SQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.25.8", + "resolved": "https://registry.npmmirror.com/@esbuild/openbsd-x64/-/openbsd-x64-0.25.8.tgz", + "integrity": "sha512-1h8MUAwa0VhNCDp6Af0HToI2TJFAn1uqT9Al6DJVzdIBAd21m/G0Yfc77KDM3uF3T/YaOgQq3qTJHPbTOInaIQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openharmony-arm64": { + "version": "0.25.8", + "resolved": "https://registry.npmmirror.com/@esbuild/openharmony-arm64/-/openharmony-arm64-0.25.8.tgz", + "integrity": "sha512-r2nVa5SIK9tSWd0kJd9HCffnDHKchTGikb//9c7HX+r+wHYCpQrSgxhlY6KWV1nFo1l4KFbsMlHk+L6fekLsUg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.25.8", + "resolved": "https://registry.npmmirror.com/@esbuild/sunos-x64/-/sunos-x64-0.25.8.tgz", + "integrity": "sha512-zUlaP2S12YhQ2UzUfcCuMDHQFJyKABkAjvO5YSndMiIkMimPmxA+BYSBikWgsRpvyxuRnow4nS5NPnf9fpv41w==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.25.8", + "resolved": "https://registry.npmmirror.com/@esbuild/win32-arm64/-/win32-arm64-0.25.8.tgz", + "integrity": "sha512-YEGFFWESlPva8hGL+zvj2z/SaK+pH0SwOM0Nc/d+rVnW7GSTFlLBGzZkuSU9kFIGIo8q9X3ucpZhu8PDN5A2sQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.25.8", + "resolved": "https://registry.npmmirror.com/@esbuild/win32-ia32/-/win32-ia32-0.25.8.tgz", + "integrity": "sha512-hiGgGC6KZ5LZz58OL/+qVVoZiuZlUYlYHNAmczOm7bs2oE1XriPFi5ZHHrS8ACpV5EjySrnoCKmcbQMN+ojnHg==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.25.8", + "resolved": "https://registry.npmmirror.com/@esbuild/win32-x64/-/win32-x64-0.25.8.tgz", + "integrity": "sha512-cn3Yr7+OaaZq1c+2pe+8yxC8E144SReCQjN6/2ynubzYjvyqZjTXfQJpAcQpsdJq3My7XADANiYGHoFC69pLQw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/esbuild": { + "version": "0.25.8", + "resolved": "https://registry.npmmirror.com/esbuild/-/esbuild-0.25.8.tgz", + "integrity": "sha512-vVC0USHGtMi8+R4Kz8rt6JhEWLxsv9Rnu/lGYbPR8u47B+DCBksq9JarW0zOO7bs37hyOK1l2/oqtbciutL5+Q==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.25.8", + "@esbuild/android-arm": "0.25.8", + "@esbuild/android-arm64": "0.25.8", + "@esbuild/android-x64": "0.25.8", + "@esbuild/darwin-arm64": "0.25.8", + "@esbuild/darwin-x64": "0.25.8", + "@esbuild/freebsd-arm64": "0.25.8", + "@esbuild/freebsd-x64": "0.25.8", + "@esbuild/linux-arm": "0.25.8", + "@esbuild/linux-arm64": "0.25.8", + "@esbuild/linux-ia32": "0.25.8", + "@esbuild/linux-loong64": "0.25.8", + "@esbuild/linux-mips64el": "0.25.8", + "@esbuild/linux-ppc64": "0.25.8", + "@esbuild/linux-riscv64": "0.25.8", + "@esbuild/linux-s390x": "0.25.8", + "@esbuild/linux-x64": "0.25.8", + "@esbuild/netbsd-arm64": "0.25.8", + "@esbuild/netbsd-x64": "0.25.8", + "@esbuild/openbsd-arm64": "0.25.8", + "@esbuild/openbsd-x64": "0.25.8", + "@esbuild/openharmony-arm64": "0.25.8", + "@esbuild/sunos-x64": "0.25.8", + "@esbuild/win32-arm64": "0.25.8", + "@esbuild/win32-ia32": "0.25.8", + "@esbuild/win32-x64": "0.25.8" + } + }, + "node_modules/pako": { + "version": "2.1.0", + "resolved": "https://registry.npmmirror.com/pako/-/pako-2.1.0.tgz", + "integrity": "sha512-w+eufiZ1WuJYgPXbV/PO3NCMEc3xqylkKHzp8bxp1uW4qaSNQUkwmLLEc3kKsfz8lpV1F8Ht3U1Cm+9Srog2ug==", + "license": "(MIT AND Zlib)" + } + } +} diff --git a/ThirdParty/WlocScripts/package.json b/ThirdParty/WlocScripts/package.json new file mode 100644 index 0000000..11f7080 --- /dev/null +++ b/ThirdParty/WlocScripts/package.json @@ -0,0 +1,16 @@ +{ + "name": "@location-spoofer/wloc-scripts", + "version": "1.0.0", + "private": true, + "type": "module", + "scripts": { + "build": "node build.mjs", + "test": "node --test" + }, + "dependencies": { + "pako": "2.1.0" + }, + "devDependencies": { + "esbuild": "0.25.8" + } +} diff --git a/ThirdParty/WlocScripts/src/core.js b/ThirdParty/WlocScripts/src/core.js new file mode 100644 index 0000000..15f66f0 --- /dev/null +++ b/ThirdParty/WlocScripts/src/core.js @@ -0,0 +1,263 @@ +export const MOTION_ACTIVITY_TYPE = 63; +export const MOTION_ACTIVITY_CONFIDENCE = 467; +export const WLOC_MARKER = Uint8Array.from([0, 0, 0, 1, 0, 0]); +const UINT32_RANGE = 0x100000000; + +const concat = (...parts) => { + const length = parts.reduce((sum, part) => sum + part.length, 0); + const out = new Uint8Array(length); + let offset = 0; + for (const part of parts) { + out.set(part, offset); + offset += part.length; + } + return out; +}; + +const equal = (left, right) => + left.length === right.length && left.every((value, index) => value === right[index]); + +function readVarint(data, offset) { + let value = 0; + let multiplier = 1; + for (let index = 0; index < 10 && offset + index < data.length; index += 1) { + const byte = data[offset + index]; + const chunk = byte & 0x7f; + if (value !== null && chunk <= Math.floor((Number.MAX_SAFE_INTEGER - value) / multiplier)) { + value += chunk * multiplier; + } else { + value = null; + } + if ((byte & 0x80) === 0) return { value, next: offset + index + 1 }; + multiplier *= 0x80; + } + throw new Error("invalid varint"); +} + +function writeVarint(input) { + const value = Math.trunc(Number(input)); + if (!Number.isSafeInteger(value)) throw new Error("varint value is not a safe integer"); + let low = value >>> 0; + let high = Math.floor(value / UINT32_RANGE) >>> 0; + const bytes = []; + do { + const byte = low & 0x7f; + low = ((low >>> 7) | ((high & 0x7f) << 25)) >>> 0; + high >>>= 7; + const hasMore = high !== 0 || low !== 0; + bytes.push(byte | (hasMore ? 0x80 : 0)); + } while (high !== 0 || low !== 0); + return Uint8Array.from(bytes); +} + +const writeTag = (number, wireType) => writeVarint((number << 3) | wireType); + +function writeLengthDelimited(number, value) { + return concat(writeTag(number, 2), writeVarint(value.length), value); +} + +export function parseFields(data) { + const fields = []; + let offset = 0; + while (offset < data.length) { + const start = offset; + const tag = readVarint(data, offset); + offset = tag.next; + if (!Number.isSafeInteger(tag.value)) throw new Error("protobuf tag is too large"); + const number = Math.floor(tag.value / 8); + const wireType = tag.value & 7; + if (number === 0) throw new Error("invalid protobuf field 0"); + let value; + if (wireType === 0) { + const item = readVarint(data, offset); + value = data.slice(offset, item.next); + offset = item.next; + } else if (wireType === 1) { + if (offset + 8 > data.length) throw new Error("truncated fixed64"); + value = data.slice(offset, offset + 8); + offset += 8; + } else if (wireType === 2) { + const length = readVarint(data, offset); + offset = length.next; + const size = length.value; + if (!Number.isSafeInteger(size) || offset + size > data.length) { + throw new Error("truncated length-delimited field"); + } + value = data.slice(offset, offset + size); + offset += size; + } else if (wireType === 5) { + if (offset + 4 > data.length) throw new Error("truncated fixed32"); + value = data.slice(offset, offset + 4); + offset += 4; + } else { + throw new Error(`unsupported wire type ${wireType}`); + } + fields.push({ number, wireType, value, raw: data.slice(start, offset) }); + } + return fields; +} + +function patchLocation(data, config, stats) { + const fields = parseFields(data); + if (!fields.some((field) => field.number === 1 && field.wireType === 0) || + !fields.some((field) => field.number === 2 && field.wireType === 0)) { + return data; + } + let hasMotionType = false; + let hasMotionConfidence = false; + const parts = fields.map((field) => { + if (field.wireType !== 0) return field.raw; + if (field.number === 1) return concat(writeTag(1, 0), writeVarint(Math.round(config.latitude * 1e8))); + if (field.number === 2) return concat(writeTag(2, 0), writeVarint(Math.round(config.longitude * 1e8))); + if (field.number === 3) return concat(writeTag(3, 0), writeVarint(config.accuracy)); + if (config.motionSimulationEnabled && field.number === 11) { + hasMotionType = true; + return concat(writeTag(11, 0), writeVarint(MOTION_ACTIVITY_TYPE)); + } + if (config.motionSimulationEnabled && field.number === 12) { + hasMotionConfidence = true; + return concat(writeTag(12, 0), writeVarint(MOTION_ACTIVITY_CONFIDENCE)); + } + return field.raw; + }); + if (config.motionSimulationEnabled && !hasMotionType) { + parts.push(concat(writeTag(11, 0), writeVarint(MOTION_ACTIVITY_TYPE))); + } + if (config.motionSimulationEnabled && !hasMotionConfidence) { + parts.push(concat(writeTag(12, 0), writeVarint(MOTION_ACTIVITY_CONFIDENCE))); + } + const out = concat(...parts); + if (!equal(out, data)) stats.locations += 1; + return out; +} + +function patchWifi(data, config, stats) { + const fields = parseFields(data); + const hasMac = fields.some((field) => + field.number === 1 && field.wireType === 2 && + /^[0-9a-fA-F]{1,2}(:[0-9a-fA-F]{1,2}){5}$/.test( + Array.from(field.value, (byte) => String.fromCharCode(byte)).join("") + ) + ); + if (!hasMac) return data; + let changed = false; + const parts = fields.map((field) => { + if (field.number !== 2 || field.wireType !== 2) return field.raw; + const value = patchLocation(field.value, config, stats); + changed ||= !equal(value, field.value); + return writeLengthDelimited(2, value); + }); + if (changed) stats.wifi += 1; + return concat(...parts); +} + +function patchCell(data, config, stats) { + let changed = false; + const parts = parseFields(data).map((field) => { + if (field.number !== 5 || field.wireType !== 2) return field.raw; + const value = patchLocation(field.value, config, stats); + changed ||= !equal(value, field.value); + return writeLengthDelimited(5, value); + }); + if (changed) stats.cell += 1; + return concat(...parts); +} + +export function patchPayload(data, config, stats = { wifi: 0, cell: 0, locations: 0 }) { + const parts = parseFields(data).map((field) => { + if (field.number === 2 && field.wireType === 2) { + return writeLengthDelimited(2, patchWifi(field.value, config, stats)); + } + if ((field.number === 22 || field.number === 24) && field.wireType === 2) { + return writeLengthDelimited(field.number, patchCell(field.value, config, stats)); + } + return field.raw; + }); + return { data: concat(...parts), stats }; +} + +const uint16 = (data, offset) => (data[offset] << 8) | data[offset + 1]; +const uint32 = (data, offset) => + ((data[offset] * 0x1000000) + (data[offset + 1] << 16) + + (data[offset + 2] << 8) + data[offset + 3]) >>> 0; +const writeUint16 = (value) => Uint8Array.from([(value >>> 8) & 0xff, value & 0xff]); +const writeUint32 = (value) => Uint8Array.from([ + (value >>> 24) & 0xff, (value >>> 16) & 0xff, (value >>> 8) & 0xff, value & 0xff +]); + +function findBytes(data, marker) { + outer: for (let offset = 0; offset <= data.length - marker.length; offset += 1) { + for (let index = 0; index < marker.length; index += 1) { + if (data[offset + index] !== marker[index]) continue outer; + } + return offset; + } + return -1; +} + +function patchARPC(body, config) { + if (body.length < 2) throw new Error("short ARPC"); + let offset = 2; + for (let index = 0; index < 3; index += 1) { + if (offset + 2 > body.length) throw new Error("truncated ARPC string"); + offset += 2 + uint16(body, offset); + } + const lengthOffset = offset + 4; + const payloadOffset = lengthOffset + 4; + if (payloadOffset > body.length) throw new Error("truncated ARPC header"); + const length = uint32(body, lengthOffset); + if (!length || payloadOffset + length > body.length) throw new Error("invalid ARPC length"); + const patched = patchPayload(body.slice(payloadOffset, payloadOffset + length), config); + if (equal(patched.data, body.slice(payloadOffset, payloadOffset + length))) throw new Error("unchanged ARPC"); + return { data: concat(body.slice(0, lengthOffset), writeUint32(patched.data.length), + patched.data, body.slice(payloadOffset + length)), stats: patched.stats }; +} + +function patchMarker(body, config) { + const markerOffset = findBytes(body, WLOC_MARKER); + if (markerOffset < 0) throw new Error("marker not found"); + const lengthOffset = markerOffset + WLOC_MARKER.length; + const payloadOffset = lengthOffset + 2; + const length = uint16(body, lengthOffset); + if (!length || payloadOffset + length > body.length) throw new Error("invalid marker length"); + const patched = patchPayload(body.slice(payloadOffset, payloadOffset + length), config); + if (patched.data.length > 65535 || equal(patched.data, body.slice(payloadOffset, payloadOffset + length))) { + throw new Error("unchanged marker"); + } + return { data: concat(body.slice(0, lengthOffset), writeUint16(patched.data.length), + patched.data, body.slice(payloadOffset + length)), stats: patched.stats }; +} + +function patchSynthetic(body, offset, config) { + if (offset + 10 > body.length) throw new Error("short frame"); + const length = uint16(body, offset + 8); + if (!length || offset + 10 + length > body.length) throw new Error("invalid frame"); + const patched = patchPayload(body.slice(offset + 10, offset + 10 + length), config); + if (patched.data.length > 65535 || equal(patched.data, body.slice(offset + 10, offset + 10 + length))) { + throw new Error("unchanged frame"); + } + return { data: concat(body.slice(0, offset + 8), writeUint16(patched.data.length), + patched.data, body.slice(offset + 10 + length)), stats: patched.stats }; +} + +export function patchWlocBody(body, config) { + for (const patcher of [patchARPC, patchMarker]) { + try { return patcher(body, config); } catch {} + } + const offsets = [...new Set([0, 2, 4, 6, 8, 10, 12, 14, 16, + ...Array.from({ length: Math.min(96, Math.max(0, body.length - 10)) + 1 }, (_, index) => index)])]; + for (const offset of offsets) { + try { return patchSynthetic(body, offset, config); } catch {} + } + for (let offset = 0; offset <= Math.min(256, body.length); offset += 1) { + try { + const patched = patchPayload(body.slice(offset), config); + if (!equal(patched.data, body.slice(offset))) { + return { data: concat(body.slice(0, offset), patched.data), stats: patched.stats }; + } + } catch {} + } + throw new Error("no patchable wloc payload found"); +} + +export const internals = { concat, writeVarint, writeTag, writeLengthDelimited, equal }; diff --git a/ThirdParty/WlocScripts/src/response-entry.js b/ThirdParty/WlocScripts/src/response-entry.js new file mode 100644 index 0000000..49f46ab --- /dev/null +++ b/ThirdParty/WlocScripts/src/response-entry.js @@ -0,0 +1,26 @@ +import { ungzip } from "pako"; +import { patchWlocBody } from "./core.js"; +import { + STORAGE_KEY, finishBinary, finishPassthrough, readPersistent, responseBytes +} from "./runtime.js"; + +try { + const settings = readPersistent(STORAGE_KEY); + const input = responseBytes(); + if (!settings || !settings.enabled || !input.length) { + finishPassthrough(); + } else { + const isGzip = input.length >= 2 && input[0] === 0x1f && input[1] === 0x8b; + const body = isGzip ? ungzip(input) : input; + const patched = patchWlocBody(body, { + latitude: Number(settings.latitude), + longitude: Number(settings.longitude), + accuracy: Number(settings.accuracy != null ? settings.accuracy : 25), + motionSimulationEnabled: settings.motionSimulationEnabled === true + }); + finishBinary(patched.data); + } +} catch (error) { + console.log(`[Location Spoofer] ${error && error.message ? error.message : error}`); + finishPassthrough(); +} diff --git a/ThirdParty/WlocScripts/src/runtime.js b/ThirdParty/WlocScripts/src/runtime.js new file mode 100644 index 0000000..0423b9e --- /dev/null +++ b/ThirdParty/WlocScripts/src/runtime.js @@ -0,0 +1,109 @@ +export const MODULE_VERSION = "1.0.0"; +export const PROTOCOL_VERSION = 1; +export const CAPABILITIES = [ + "wifi", "cellTower", "arpc", "marker", "synthetic", "bare", "motionSimulation" +]; +export const STORAGE_KEY = "locationSpoofer.settings.v1"; + +export function environment() { + if (typeof $task !== "undefined") return "quantumultX"; + if (typeof $loon !== "undefined") return "loon"; + if (typeof $rocket !== "undefined") return "shadowrocket"; + if (typeof Egern !== "undefined") return "egern"; + if (typeof $environment !== "undefined" && $environment["stash-version"]) return "stash"; + if (typeof $environment !== "undefined" && $environment["surge-version"]) return "surge"; + return "unknown"; +} + +export function readPersistent(key) { + const raw = environment() === "quantumultX" + ? $prefs.valueForKey(key) + : $persistentStore.read(key); + if (!raw) return null; + try { return JSON.parse(raw); } catch { return null; } +} + +export function writePersistent(key, value) { + const raw = value == null ? "" : JSON.stringify(value); + return environment() === "quantumultX" + ? $prefs.setValueForKey(raw, key) + : $persistentStore.write(raw, key); +} + +export function responseBytes() { + const response = typeof $response === "undefined" ? null : $response; + const value = response && response.bodyBytes != null ? response.bodyBytes : response && response.body; + if (value instanceof ArrayBuffer) return new Uint8Array(value); + if (ArrayBuffer.isView(value)) return new Uint8Array(value.buffer, value.byteOffset, value.byteLength); + if (typeof value === "string") { + return Uint8Array.from(value, (character) => character.charCodeAt(0) & 0xff); + } + return new Uint8Array(); +} + +function cleanHeaders(headers, length) { + const out = Object.assign({}, headers || {}); + for (const name of ["Content-Encoding", "content-encoding", "Transfer-Encoding", "transfer-encoding"]) { + delete out[name]; + } + out["Content-Length"] = String(length); + return out; +} + +export function finishBinary(bytes) { + const response = typeof $response === "undefined" ? {} : $response; + const headers = cleanHeaders(response.headers, bytes.length); + const env = environment(); + if (env === "quantumultX") { + delete headers["Content-Length"]; + $done({ status: "HTTP/1.1 200 OK", headers, bodyBytes: bytes.buffer }); + } else if (env === "stash") { + $done(Object.assign({}, response, { status: 200, headers, body: bytes })); + } else { + $done({ response: Object.assign({}, response, { status: 200, headers, body: bytes }) }); + } +} + +export function finishPassthrough() { + $done({}); +} + +export function finishJSON(value) { + const response = { + status: 200, + headers: { "Content-Type": "application/json; charset=utf-8" }, + body: JSON.stringify(value) + }; + if (environment() === "quantumultX") { + $done(Object.assign({}, response, { status: "HTTP/1.1 200 OK" })); + } else if (environment() === "stash") { + $done(response); + } else { + $done({ response }); + } +} + +export function queryParameters(url) { + const query = url.split("?")[1] || ""; + const values = {}; + query.split("&").forEach((item) => { + if (!item) return; + const separator = item.indexOf("="); + const rawKey = separator < 0 ? item : item.slice(0, separator); + const rawValue = separator < 0 ? "" : item.slice(separator + 1); + let key = rawKey; + let value = rawValue; + try { key = decodeURIComponent(rawKey.replace(/\+/g, " ")); } catch {} + try { value = decodeURIComponent(rawValue.replace(/\+/g, " ")); } catch {} + if (!Object.prototype.hasOwnProperty.call(values, key)) values[key] = value; + }); + return values; +} + +export function requestPath(url) { + const withoutQuery = url.split("?")[0]; + const scheme = withoutQuery.indexOf("://"); + if (scheme < 0) return withoutQuery; + const path = withoutQuery.indexOf("/", scheme + 3); + return path < 0 ? "/" : withoutQuery.slice(path); +} diff --git a/ThirdParty/WlocScripts/src/settings-entry.js b/ThirdParty/WlocScripts/src/settings-entry.js new file mode 100644 index 0000000..626d0d8 --- /dev/null +++ b/ThirdParty/WlocScripts/src/settings-entry.js @@ -0,0 +1,48 @@ +import { + CAPABILITIES, MODULE_VERSION, PROTOCOL_VERSION, STORAGE_KEY, + finishJSON, queryParameters, readPersistent, requestPath, writePersistent +} from "./runtime.js"; + +const url = typeof $request === "undefined" ? "" : ($request.url || ""); +const path = requestPath(url); +const parameters = queryParameters(url); + +if (path === "/wloc-settings/version") { + finishJSON({ + success: true, + moduleVersion: MODULE_VERSION, + protocolVersion: PROTOCOL_VERSION, + capabilities: CAPABILITIES + }); +} else if (parameters.action === "query") { + const settings = readPersistent(STORAGE_KEY); + finishJSON(settings && settings.enabled + ? { success: true, longitude: settings.longitude, latitude: settings.latitude, + accuracy: settings.accuracy, motionSimulationEnabled: settings.motionSimulationEnabled === true } + : { success: false, error: "无已保存的坐标" }); +} else if (parameters.action === "clear") { + writePersistent(STORAGE_KEY, null); + finishJSON({ success: true }); +} else { + const longitude = Number(parameters.lon != null ? parameters.lon : parameters.longitude); + const latitude = Number(parameters.lat != null ? parameters.lat : parameters.latitude); + const accuracy = Number(parameters.acc != null + ? parameters.acc + : (parameters.accuracy != null ? parameters.accuracy : 25)); + if (!Number.isFinite(longitude) || !Number.isFinite(latitude)) { + finishJSON({ success: false, error: "缺少 lon/lat 参数" }); + } else { + const settings = { + enabled: true, + longitude, + latitude, + accuracy, + motionSimulationEnabled: parameters.motion === "1" + }; + const success = writePersistent(STORAGE_KEY, settings); + finishJSON(success + ? { success: true, longitude, latitude, accuracy, + motionSimulationEnabled: settings.motionSimulationEnabled } + : { success: false, error: "保存配置失败" }); + } +} diff --git a/ThirdParty/WlocScripts/test/bundle-compatibility.test.js b/ThirdParty/WlocScripts/test/bundle-compatibility.test.js new file mode 100644 index 0000000..10b5b71 --- /dev/null +++ b/ThirdParty/WlocScripts/test/bundle-compatibility.test.js @@ -0,0 +1,52 @@ +import test from "node:test"; +import assert from "node:assert/strict"; +import { readFile } from "node:fs/promises"; +import vm from "node:vm"; + +const bundles = [ + new URL("../dist/v1/wloc.js", import.meta.url), + new URL("../dist/v1/wloc-settings.js", import.meta.url) +]; + +test("generated bundles avoid newer JavaScriptCore runtime requirements", async () => { + for (const bundle of bundles) { + const source = await readFile(bundle, "utf8"); + for (const unsupported of [ + /\bBigInt\b/, + /\bglobalThis\b/, + /\bURLSearchParams\b/, + /\bObject\.fromEntries\b/, + /\?\./, + /\?\?/ + ]) { + assert.equal(unsupported.test(source), false, `${bundle.pathname} contains ${unsupported}`); + } + } +}); + +test("settings bundle runs without modern URL and text globals", async () => { + const source = await readFile(bundles[1], "utf8"); + let result; + const storage = new Map(); + vm.runInNewContext(source, { + $rocket: {}, + $request: { + url: "https://gs-loc.apple.com/wloc-settings/save?lon=121.1&lat=31.2&acc=25" + }, + $persistentStore: { + read: (key) => storage.get(key) || null, + write: (value, key) => { + storage.set(key, value); + return true; + } + }, + $done: (value) => { result = value; }, + JSON, + Number, + Object, + String, + decodeURIComponent + }); + + assert.equal(JSON.parse(result.response.body).success, true); +}); diff --git a/ThirdParty/WlocScripts/test/core.test.js b/ThirdParty/WlocScripts/test/core.test.js new file mode 100644 index 0000000..ad1733b --- /dev/null +++ b/ThirdParty/WlocScripts/test/core.test.js @@ -0,0 +1,85 @@ +import test from "node:test"; +import assert from "node:assert/strict"; +import { + MOTION_ACTIVITY_CONFIDENCE, MOTION_ACTIVITY_TYPE, internals, parseFields, patchWlocBody +} from "../src/core.js"; + +const { concat, writeVarint, writeTag, writeLengthDelimited } = internals; + +function location(withMotion = false) { + const fields = [ + concat(writeTag(1, 0), writeVarint(100)), + concat(writeTag(2, 0), writeVarint(200)), + concat(writeTag(3, 0), writeVarint(25)) + ]; + if (withMotion) { + fields.push(concat(writeTag(11, 0), writeVarint(7))); + fields.push(concat(writeTag(12, 0), writeVarint(88))); + } + return concat(...fields); +} + +function wifiPayload(value = location()) { + const device = concat( + writeLengthDelimited(1, new TextEncoder().encode("aa:bb:cc:dd:ee:ff")), + writeLengthDelimited(2, value) + ); + return writeLengthDelimited(2, device); +} + +function frame(payload) { + return concat(Uint8Array.from([0, 1, 0, 0, 0, 1, 0, 0]), + Uint8Array.from([payload.length >> 8, payload.length & 0xff]), payload); +} + +const config = { + latitude: 31.230416, + longitude: 121.473701, + accuracy: 50, + motionSimulationEnabled: false +}; + +test("patches synthetic Wi-Fi response", () => { + const result = patchWlocBody(frame(wifiPayload()), config); + assert.equal(result.stats.wifi, 1); + assert.equal(result.stats.locations, 1); +}); + +test("preserves motion fields while disabled", () => { + const result = patchWlocBody(frame(wifiPayload(location(true))), config); + const payload = result.data.slice(10); + assert.ok(payload.includes(7)); + assert.ok(payload.includes(88)); +}); + +test("replaces motion fields while enabled", () => { + const result = patchWlocBody(frame(wifiPayload(location(true))), { + ...config, motionSimulationEnabled: true + }); + const root = parseFields(result.data.slice(10)); + const device = parseFields(root[0].value); + const fields = parseFields(device.find((field) => field.number === 2).value); + const motionType = fields.find((field) => field.number === 11); + const motionConfidence = fields.find((field) => field.number === 12); + assert.deepEqual(motionType.value, writeVarint(MOTION_ACTIVITY_TYPE)); + assert.deepEqual(motionConfidence.value, writeVarint(MOTION_ACTIVITY_CONFIDENCE)); +}); + +test("patches CellTower fields 22 and 24", () => { + for (const number of [22, 24]) { + const cell = writeLengthDelimited(5, location()); + const result = patchWlocBody(frame(writeLengthDelimited(number, cell)), config); + assert.equal(result.stats.cell, 1); + } +}); + +test("encodes signed int64 coordinates without BigInt", () => { + assert.deepEqual( + Array.from(writeVarint(-18_000_000_000)), + [128, 152, 247, 248, 188, 255, 255, 255, 255, 1] + ); + assert.deepEqual( + Array.from(writeVarint(18_000_000_000)), + [128, 232, 136, 135, 67] + ); +}); diff --git a/docs/THIRD_PARTY_MODULES.md b/docs/THIRD_PARTY_MODULES.md index b2df17a..036e42a 100644 --- a/docs/THIRD_PARTY_MODULES.md +++ b/docs/THIRD_PARTY_MODULES.md @@ -1,15 +1,18 @@ -# Third-party proxy module snapshots +# Third-party proxy modules -The files under `Resources/ThirdPartyProxyModules/` are bundled configuration -snapshots from [Yu9191/wloc](https://github.com/Yu9191/wloc). They are retained -in the App bundle for release provenance and offline inspection. The setup UI -copies the official subscription URL instead of exporting these files. +The files under `Resources/ThirdPartyProxyModules/` are project-owned module +definitions used by the App's default domestic-mirror subscription path. Their +executable scripts are built from `ThirdParty/WlocScripts/src/` and checked in +under the versioned `ThirdParty/WlocScripts/dist/v1/` directory. -- Upstream commit: `eec07a8dc8de6dbaee8eac1fb376e4d03020154a` -- Snapshot date: 2026-08-06 -- Source directory: `modules/` +The direct GitHub Raw variants are stored under +`ThirdParty/WlocScripts/modules/direct/`. The Settings switch selects which +module URL the App copies: -| Bundled file | Client | +- enabled by default: `gh-proxy.org` in front of GitHub Raw; +- disabled: GitHub Raw directly. + +| Module file | Client | |---|---| | `wloc.module` | Shadowrocket | | `wloc.sgmodule` | Surge and Egern | @@ -17,15 +20,35 @@ copies the official subscription URL instead of exporting these files. | `wloc.lpx` | Loon | | `wloc.stoverride` | Stash | -SHA-256: +Egern reuses the Surge module. Stash imports `.stoverride` directly. + +Both script entry points are owned by this repository: + +- `wloc.js` patches Apple WLOC response bodies; +- `wloc-settings.js` implements `/wloc-settings/save` and + `/wloc-settings/version`. + +The generated scripts target ES2017 and avoid hard dependencies on `BigInt`, +optional chaining, nullish coalescing, `globalThis`, `URLSearchParams`, and +`Object.fromEntries`. This keeps them usable by older proxy-client releases +that still implement the established module syntax, binary response body, +`$done`, and persistent-storage APIs. + +Already-installed legacy modules that point to another repository are not +silently migrated because their remote script URL is outside this project's +control. Those users must re-import the project-owned module before using the +versioned protocol and motion setting. + +Current bundled module SHA-256 values: ```text -bb5e17b60027704971660b0ea2df3560ceff973c27d43e7f2c2c18b48d368ac6 wloc.conf -1fb451616fb17242849f72490f016afcdb8aa81a0b086f6dd5f94e1af3d58ee1 wloc.lpx -97cab104056428aa0e90521c3bf2646e9739b0b4c83272b31790f99584bca89e wloc.module -5d6b82c31316f4a7be65e3b8d2335f4338e01af98e262948118eefe63abf7034 wloc.sgmodule -cb06593752db8b223dfa5cd1cbd089115fe3a541f5c8532491615923e83df2cb wloc.stoverride +263f3eae0ec4ef19d03eefa58f28e6545cccbc6a2d32c5e1d3493ba207ca7605 wloc.conf +c0755a9edb2a1686190d12d156e9aa53693e15721efc4a29f9a06c2bf3115a5f wloc.lpx +06a426e4f37828d18b80abea04a8ade4fa7f93817cb1e37928c52da3e46f693a wloc.module +f6b9fc51c4d3c4fca837ff896dbe544f99604d9646f05841bad82bfdfdf5c4fa wloc.sgmodule +100e569e6ca3183f7da15fbb38ddb5cd91178488c0d9774acabc2721fa85a58c wloc.stoverride ``` -The official subscription URLs are the setup UI's import path. Egern reuses the -Surge module. Stash imports `.stoverride` directly. +The project acknowledges [Yu9191/wloc](https://github.com/Yu9191/wloc) as a +reference for earlier WLOC implementation ideas. That acknowledgement is not +an executable dependency or subscription source.