techprufer-mcp 0.1.0 → 0.1.1
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/dist/login.js +16 -2
- package/package.json +1 -1
package/dist/login.js
CHANGED
|
@@ -15,6 +15,19 @@ function openBrowser(url) {
|
|
|
15
15
|
function sleep(ms) {
|
|
16
16
|
return new Promise((r) => setTimeout(r, ms));
|
|
17
17
|
}
|
|
18
|
+
/** Keep verify URL on the same host as TECHPRUFER_API_URL (local vs prod). */
|
|
19
|
+
function alignVerifyUrl(verifyUrl, apiUrl) {
|
|
20
|
+
try {
|
|
21
|
+
const verify = new URL(verifyUrl);
|
|
22
|
+
const api = new URL(apiUrl);
|
|
23
|
+
verify.protocol = api.protocol;
|
|
24
|
+
verify.host = api.host;
|
|
25
|
+
return verify.toString();
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return verifyUrl;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
18
31
|
export async function runLogin(deviceName) {
|
|
19
32
|
const apiUrl = getApiUrl();
|
|
20
33
|
console.error(`TechPrufer Local Agent — logging in against ${apiUrl}`);
|
|
@@ -23,12 +36,13 @@ export async function runLogin(deviceName) {
|
|
|
23
36
|
token: null,
|
|
24
37
|
body: JSON.stringify({ deviceName: deviceName || undefined }),
|
|
25
38
|
});
|
|
39
|
+
const verifyUrl = alignVerifyUrl(start.verifyUrl, apiUrl);
|
|
26
40
|
console.error('');
|
|
27
41
|
console.error(` Code: ${start.userCode}`);
|
|
28
|
-
console.error(` Open: ${
|
|
42
|
+
console.error(` Open: ${verifyUrl}`);
|
|
29
43
|
console.error('');
|
|
30
44
|
console.error('Waiting for approval in the browser…');
|
|
31
|
-
openBrowser(
|
|
45
|
+
openBrowser(verifyUrl);
|
|
32
46
|
const intervalMs = Math.max(3, start.interval || 5) * 1000;
|
|
33
47
|
const deadline = Date.now() + start.expiresIn * 1000;
|
|
34
48
|
while (Date.now() < deadline) {
|