@swimmingliu/autovpn 2.0.1 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,5 @@
1
1
  import { createHash } from 'node:crypto';
2
+ import { fetch as upstreamFetch, ProxyAgent } from 'undici';
2
3
  import { androidChunkUrls, apkDiscoveryFromBytes, inlineDownloadSpec, candidateApkUrls, cdnConfigUrls, parseCdnConfig, apkSlot } from './apk-discovery.js';
3
4
  import { buildUrl, commonParams, flattenRouteGroups, isPlaceholderNode, LOGIN_SALT, pathAndQuery, selectApiDomain, selectForeignRoutes } from './brand-protocol.js';
4
5
  import { decryptPayload, extractLinksFromPlaintext, linkDigest, linkFingerprint } from './extract.js';
@@ -646,6 +647,35 @@ function credentialRejectionMessage(payload) {
646
647
  * the pipeline already consumes.
647
648
  */
648
649
  export async function fetchCredentialSourceLinks(input, options = {}) {
650
+ const proxyUrl = upstreamProxyUrl(options.env);
651
+ if (!proxyUrl) {
652
+ return fetchCredentialSourceLinksWithTransport(input, options);
653
+ }
654
+ let proxy;
655
+ try {
656
+ proxy = new URL(proxyUrl);
657
+ }
658
+ catch {
659
+ throw new Error('The configured upstream proxy URL is invalid');
660
+ }
661
+ if (proxy.protocol !== 'http:' && proxy.protocol !== 'https:') {
662
+ throw new Error('Credential sources require an HTTP or HTTPS upstream proxy');
663
+ }
664
+ // The proxy previously reached only a text fallback: native site and APK
665
+ // requests still went direct. Keep one source-scoped dispatcher for both
666
+ // response types, without changing the per-node measurement transports.
667
+ const dispatcher = new ProxyAgent({ uri: proxy.href, proxyTunnel: false });
668
+ const fetchImpl = (url, init) => options.fetchImpl
669
+ ? options.fetchImpl(url, { ...init, dispatcher })
670
+ : upstreamFetch(url, { ...init, dispatcher });
671
+ try {
672
+ return await fetchCredentialSourceLinksWithTransport(input, { ...options, fetchImpl });
673
+ }
674
+ finally {
675
+ await dispatcher.destroy();
676
+ }
677
+ }
678
+ async function fetchCredentialSourceLinksWithTransport(input, options) {
649
679
  const source = input.source;
650
680
  const platforms = resolveCredentialPlatforms(source);
651
681
  const policy = resolveRoundPolicy(source);
@@ -5,7 +5,7 @@ const ZH_MESSAGES = {
5
5
  locale: 'zh-CN',
6
6
  appTitle: 'AutoVPN',
7
7
  sidebarTitle: 'AutoVPN',
8
- sidebarVersion: 'v.2.0.1',
8
+ sidebarVersion: 'v.2.0.2',
9
9
  brandSubtitle: '概览、运行、结果、订阅、日志、设置统一管理',
10
10
  languageLabel: '',
11
11
  saveButton: '保存配置',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swimmingliu/autovpn",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "description": "npm wrapper for the AutoVPN headless CLI",
5
5
  "type": "module",
6
6
  "repository": {
@@ -35,6 +35,7 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "@iarna/toml": "^2.2.5",
38
- "qrcode": "^1.5.4"
38
+ "qrcode": "^1.5.4",
39
+ "undici": "7.30.2"
39
40
  }
40
41
  }