tokentracker-cli 0.14.1 → 0.14.3
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.
- package/README.md +1 -1
- package/bin/tracker.js +11 -1
- package/dashboard/dist/assets/{main-Dc116CZl.js → main-BZ54G0n1.js} +194 -194
- package/dashboard/dist/index.html +1 -1
- package/dashboard/dist/share.html +1 -1
- package/package.json +4 -2
- package/src/lib/cursor-config.js +55 -10
- package/src/lib/pricing/seed-snapshot.json +1 -1
- package/src/lib/proxy-env.js +50 -0
package/src/lib/proxy-env.js
CHANGED
|
@@ -73,9 +73,59 @@ function relaunchWithProxyEnvIfNeeded({
|
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
function pickProxyUrl(env = process.env) {
|
|
77
|
+
return (
|
|
78
|
+
env.HTTPS_PROXY ||
|
|
79
|
+
env.https_proxy ||
|
|
80
|
+
env.HTTP_PROXY ||
|
|
81
|
+
env.http_proxy ||
|
|
82
|
+
env.ALL_PROXY ||
|
|
83
|
+
env.all_proxy ||
|
|
84
|
+
null
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Node's built-in NODE_USE_ENV_PROXY support only landed in v22.21 / v24.5.
|
|
89
|
+
// For older runtimes (including the v22.14 we historically embedded in the
|
|
90
|
+
// macOS app, and the v22.16 a community user hit on Discussion #68) the env
|
|
91
|
+
// var is silently ignored and fetch() bypasses the proxy. Setting an undici
|
|
92
|
+
// ProxyAgent dispatcher at startup gives us proxy support on every Node ≥ 18
|
|
93
|
+
// regardless of the env-proxy flag.
|
|
94
|
+
function applyUndiciProxyIfNeeded({
|
|
95
|
+
env = process.env,
|
|
96
|
+
setGlobalDispatcher,
|
|
97
|
+
ProxyAgent,
|
|
98
|
+
} = {}) {
|
|
99
|
+
const proxyUrl = pickProxyUrl(env);
|
|
100
|
+
if (!proxyUrl) return null;
|
|
101
|
+
|
|
102
|
+
let setter = setGlobalDispatcher;
|
|
103
|
+
let Agent = ProxyAgent;
|
|
104
|
+
if (!setter || !Agent) {
|
|
105
|
+
try {
|
|
106
|
+
// eslint-disable-next-line global-require
|
|
107
|
+
const undici = require("undici");
|
|
108
|
+
setter = setter || undici.setGlobalDispatcher;
|
|
109
|
+
Agent = Agent || undici.ProxyAgent;
|
|
110
|
+
} catch (_e) {
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
if (typeof setter !== "function" || typeof Agent !== "function") return null;
|
|
115
|
+
|
|
116
|
+
try {
|
|
117
|
+
setter(new Agent(proxyUrl));
|
|
118
|
+
return proxyUrl;
|
|
119
|
+
} catch (_e) {
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
76
124
|
module.exports = {
|
|
77
125
|
hasProxyEnv,
|
|
78
126
|
parseMacProxyOutput,
|
|
127
|
+
pickProxyUrl,
|
|
79
128
|
resolveSystemProxyEnv,
|
|
80
129
|
relaunchWithProxyEnvIfNeeded,
|
|
130
|
+
applyUndiciProxyIfNeeded,
|
|
81
131
|
};
|