@zegazone_mcp/mcp 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.
- package/package.json +1 -1
- package/scripts/oauth-pair.mjs +30 -7
package/package.json
CHANGED
package/scripts/oauth-pair.mjs
CHANGED
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
import crypto from "node:crypto";
|
|
16
|
-
import fs from "node:fs
|
|
16
|
+
import fs from "node:fs";
|
|
17
|
+
import fsPromises from "node:fs/promises";
|
|
17
18
|
import http from "node:http";
|
|
18
19
|
import path from "node:path";
|
|
19
20
|
import os from "node:os";
|
|
@@ -52,6 +53,14 @@ function randomState() {
|
|
|
52
53
|
return base64url(crypto.randomBytes(16));
|
|
53
54
|
}
|
|
54
55
|
|
|
56
|
+
function isWsl() {
|
|
57
|
+
try {
|
|
58
|
+
return fs.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft");
|
|
59
|
+
} catch {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
55
64
|
function openBrowser(url) {
|
|
56
65
|
const plat = process.platform;
|
|
57
66
|
const detached = { detached: true, stdio: "ignore" };
|
|
@@ -103,10 +112,10 @@ async function writeCredentials(filePath, tokens) {
|
|
|
103
112
|
access_token: tokens.access_token,
|
|
104
113
|
access_expires_at_ms,
|
|
105
114
|
};
|
|
106
|
-
await
|
|
115
|
+
await fsPromises.mkdir(path.dirname(filePath), { recursive: true });
|
|
107
116
|
const tmp = `${filePath}.${process.pid}.tmp`;
|
|
108
|
-
await
|
|
109
|
-
await
|
|
117
|
+
await fsPromises.writeFile(tmp, `${JSON.stringify(doc, null, 2)}\n`, { encoding: "utf8", mode: 0o600 });
|
|
118
|
+
await fsPromises.rename(tmp, filePath);
|
|
110
119
|
}
|
|
111
120
|
|
|
112
121
|
function buildAuthorizeUrl(redirectUri, codeChallenge, state) {
|
|
@@ -210,9 +219,20 @@ async function main() {
|
|
|
210
219
|
});
|
|
211
220
|
});
|
|
212
221
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
222
|
+
if (isWsl()) {
|
|
223
|
+
console.error("Running in WSL2 — cannot open a browser automatically.");
|
|
224
|
+
console.error("Open this URL in your Windows browser to authorise:\n");
|
|
225
|
+
console.error(` ${authorizeUrl}\n`);
|
|
226
|
+
console.error("Waiting for the browser callback (up to 10 minutes)…");
|
|
227
|
+
} else {
|
|
228
|
+
console.error("Opening browser for Zegazone login…");
|
|
229
|
+
console.error(`If the browser does not open, visit:\n ${authorizeUrl}\n`);
|
|
230
|
+
openBrowser(authorizeUrl);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
const heartbeat = setInterval(() => {
|
|
234
|
+
process.stderr.write(".");
|
|
235
|
+
}, 10_000);
|
|
216
236
|
|
|
217
237
|
try {
|
|
218
238
|
await done;
|
|
@@ -222,6 +242,9 @@ async function main() {
|
|
|
222
242
|
const msg = e instanceof Error ? e.message : String(e);
|
|
223
243
|
console.error(msg);
|
|
224
244
|
process.exit(1);
|
|
245
|
+
} finally {
|
|
246
|
+
clearInterval(heartbeat);
|
|
247
|
+
process.stderr.write("\n");
|
|
225
248
|
}
|
|
226
249
|
}
|
|
227
250
|
|