techprufer-mcp 0.1.5 → 0.1.6
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/api.d.ts +1 -0
- package/dist/api.js +21 -4
- package/dist/login.js +7 -2
- package/package.json +1 -1
package/dist/api.d.ts
CHANGED
package/dist/api.js
CHANGED
|
@@ -11,15 +11,32 @@ export class ApiError extends Error {
|
|
|
11
11
|
export async function apiFetch(path, init = {}) {
|
|
12
12
|
const creds = loadCredentials();
|
|
13
13
|
const token = init.token === undefined ? creds?.token : init.token;
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
// Explicit baseUrl wins (login). Otherwise prefer env override, then saved
|
|
15
|
+
// apiUrl, then default — so a stale localhost cred can't hijack prod login.
|
|
16
|
+
const base = (init.baseUrl ||
|
|
17
|
+
process.env.TECHPRUFER_API_URL ||
|
|
18
|
+
(token ? creds?.apiUrl : undefined) ||
|
|
19
|
+
getApiUrl()).replace(/\/$/, '');
|
|
20
|
+
const { token: _token, baseUrl: _baseUrl, ...fetchInit } = init;
|
|
21
|
+
const headers = new Headers(fetchInit.headers);
|
|
16
22
|
headers.set('Accept', 'application/json');
|
|
17
|
-
if (
|
|
23
|
+
if (fetchInit.body && !headers.has('Content-Type')) {
|
|
18
24
|
headers.set('Content-Type', 'application/json');
|
|
19
25
|
}
|
|
20
26
|
if (token)
|
|
21
27
|
headers.set('Authorization', `Bearer ${token}`);
|
|
22
|
-
|
|
28
|
+
let res;
|
|
29
|
+
try {
|
|
30
|
+
res = await fetch(`${base}${path}`, { ...fetchInit, headers });
|
|
31
|
+
}
|
|
32
|
+
catch (err) {
|
|
33
|
+
const cause = err instanceof Error && err.cause instanceof Error
|
|
34
|
+
? err.cause.message
|
|
35
|
+
: err instanceof Error
|
|
36
|
+
? err.message
|
|
37
|
+
: String(err);
|
|
38
|
+
throw new Error(`fetch failed (${base}${path}): ${cause}`);
|
|
39
|
+
}
|
|
23
40
|
const text = await res.text();
|
|
24
41
|
let body = null;
|
|
25
42
|
if (text) {
|
package/dist/login.js
CHANGED
|
@@ -20,8 +20,11 @@ function alignVerifyUrl(verifyUrl, apiUrl) {
|
|
|
20
20
|
try {
|
|
21
21
|
const verify = new URL(verifyUrl);
|
|
22
22
|
const api = new URL(apiUrl);
|
|
23
|
+
// Set hostname + port separately — assigning `.host` without a port keeps
|
|
24
|
+
// the previous port in Node (e.g. localhost:3000 → techprufer.com:3000).
|
|
23
25
|
verify.protocol = api.protocol;
|
|
24
|
-
verify.
|
|
26
|
+
verify.hostname = api.hostname;
|
|
27
|
+
verify.port = api.port;
|
|
25
28
|
return verify.toString();
|
|
26
29
|
}
|
|
27
30
|
catch {
|
|
@@ -34,6 +37,7 @@ export async function runLogin(deviceName) {
|
|
|
34
37
|
const start = await apiFetch('/api/agent/device/start', {
|
|
35
38
|
method: 'POST',
|
|
36
39
|
token: null,
|
|
40
|
+
baseUrl: apiUrl,
|
|
37
41
|
body: JSON.stringify({ deviceName: deviceName || undefined }),
|
|
38
42
|
});
|
|
39
43
|
const verifyUrl = alignVerifyUrl(start.verifyUrl, apiUrl);
|
|
@@ -50,6 +54,7 @@ export async function runLogin(deviceName) {
|
|
|
50
54
|
const poll = await apiFetch('/api/agent/device/poll', {
|
|
51
55
|
method: 'POST',
|
|
52
56
|
token: null,
|
|
57
|
+
baseUrl: apiUrl,
|
|
53
58
|
body: JSON.stringify({ deviceCode: start.deviceCode }),
|
|
54
59
|
});
|
|
55
60
|
if (poll.status === 'pending')
|
|
@@ -64,7 +69,7 @@ export async function runLogin(deviceName) {
|
|
|
64
69
|
apiUrl,
|
|
65
70
|
deviceId: poll.deviceId,
|
|
66
71
|
});
|
|
67
|
-
console.error('Logged in. You can close this window and use /tailor
|
|
72
|
+
console.error('Logged in. You can close this window and use /techprufer/tailor or /techprufer/build-profile.');
|
|
68
73
|
return;
|
|
69
74
|
}
|
|
70
75
|
}
|