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 CHANGED
@@ -5,4 +5,5 @@ export declare class ApiError extends Error {
5
5
  }
6
6
  export declare function apiFetch<T>(path: string, init?: RequestInit & {
7
7
  token?: string | null;
8
+ baseUrl?: string;
8
9
  }): Promise<T>;
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
- const base = creds?.apiUrl || getApiUrl();
15
- const headers = new Headers(init.headers);
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 (init.body && !headers.has('Content-Type')) {
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
- const res = await fetch(`${base}${path}`, { ...init, headers });
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.host = api.host;
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 in your AI tool.');
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "techprufer-mcp",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "TechPrufer MCP — tailor resumes and build profiles from your AI tool",
5
5
  "homepage": "https://techprufer.com",
6
6
  "type": "module",