@burdenoff/mcp-libs 2026.1031.3 → 2026.1101.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/{chunk-FVLIANOQ.js → chunk-LUXDBCVJ.js} +3 -3
- package/dist/{chunk-FVLIANOQ.js.map → chunk-LUXDBCVJ.js.map} +1 -1
- package/dist/{chunk-76RGHRRS.js → chunk-WYCRYHHY.js} +83 -33
- package/dist/chunk-WYCRYHHY.js.map +1 -0
- package/dist/core/auth/store.d.ts +1 -0
- package/dist/core/gql/client.d.ts +6 -0
- package/dist/core/index.cjs +83 -30
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.js +1 -1
- package/dist/index.cjs +80 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/modules/adaptercloud/index.js +1 -1
- package/dist/modules/artistrybase/index.js +1 -1
- package/dist/modules/assethandler/index.js +1 -1
- package/dist/modules/atheletebridge/index.js +1 -1
- package/dist/modules/auth/index.js +3 -3
- package/dist/modules/billing/index.js +1 -1
- package/dist/modules/brainyrich/index.js +1 -1
- package/dist/modules/buildmyiq/index.js +1 -1
- package/dist/modules/channels/index.js +1 -1
- package/dist/modules/collabkin/index.js +1 -1
- package/dist/modules/comradecircle/index.js +1 -1
- package/dist/modules/conversations/index.js +1 -1
- package/dist/modules/coolandlovely/index.js +1 -1
- package/dist/modules/cosmicintersection/index.js +1 -1
- package/dist/modules/crewfoundry/index.js +1 -1
- package/dist/modules/devportal/index.js +1 -1
- package/dist/modules/ecoimpacthub/index.js +1 -1
- package/dist/modules/eventfullymanaged/index.js +1 -1
- package/dist/modules/export/index.js +1 -1
- package/dist/modules/files/index.js +1 -1
- package/dist/modules/fluidgrids/index.js +1 -1
- package/dist/modules/ggnomad/index.js +1 -1
- package/dist/modules/govcitizenhub/index.js +1 -1
- package/dist/modules/groups/index.js +1 -1
- package/dist/modules/headshotmarketing/index.js +1 -1
- package/dist/modules/health/index.js +1 -1
- package/dist/modules/healthybowl/index.js +1 -1
- package/dist/modules/hookmovies/index.js +1 -1
- package/dist/modules/housingvista/index.js +1 -1
- package/dist/modules/integrations/index.js +1 -1
- package/dist/modules/intelwatchtower/index.js +1 -1
- package/dist/modules/kadaikodi/index.js +1 -1
- package/dist/modules/labsofscience/index.js +1 -1
- package/dist/modules/manufacturedops/index.js +1 -1
- package/dist/modules/movethewheels/index.js +1 -1
- package/dist/modules/mybodyshield/index.js +1 -1
- package/dist/modules/notifications/index.js +1 -1
- package/dist/modules/organizations/index.js +1 -1
- package/dist/modules/planmagnet/index.js +1 -1
- package/dist/modules/products/index.js +1 -1
- package/dist/modules/proserviceworld/index.js +1 -1
- package/dist/modules/rbac/index.js +1 -1
- package/dist/modules/sandbox/index.js +1 -1
- package/dist/modules/scheduler/index.js +1 -1
- package/dist/modules/security/index.js +1 -1
- package/dist/modules/semanticfed/index.js +1 -1
- package/dist/modules/store/index.js +1 -1
- package/dist/modules/subscriberbot/index.js +1 -1
- package/dist/modules/support/index.js +1 -1
- package/dist/modules/tags/index.js +1 -1
- package/dist/modules/technospam/index.js +1 -1
- package/dist/modules/theculturepost/index.js +1 -1
- package/dist/modules/theglobalfuel/index.js +1 -1
- package/dist/modules/timecampus/index.js +1 -1
- package/dist/modules/tours/index.js +1 -1
- package/dist/modules/vibecontrols/index.js +2 -2
- package/dist/modules/workspaces/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-76RGHRRS.js.map +0 -1
package/dist/core/index.cjs
CHANGED
|
@@ -16,6 +16,31 @@ var fetch__default = /*#__PURE__*/_interopDefault(fetch);
|
|
|
16
16
|
|
|
17
17
|
// src/core/auth/store.ts
|
|
18
18
|
var TOKEN_BUFFER_MS = 5 * 60 * 1e3;
|
|
19
|
+
function decodeJwtPayload(token) {
|
|
20
|
+
if (!token) return null;
|
|
21
|
+
const parts = token.split(".");
|
|
22
|
+
if (parts.length !== 3) return null;
|
|
23
|
+
try {
|
|
24
|
+
const payload = JSON.parse(
|
|
25
|
+
Buffer.from(parts[1].replace(/-/g, "+").replace(/_/g, "/"), "base64").toString("utf8")
|
|
26
|
+
);
|
|
27
|
+
return payload && typeof payload === "object" ? payload : null;
|
|
28
|
+
} catch {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function jwtExpiryMs(token) {
|
|
33
|
+
const exp = decodeJwtPayload(token)?.exp;
|
|
34
|
+
return typeof exp === "number" && Number.isFinite(exp) ? exp * 1e3 : null;
|
|
35
|
+
}
|
|
36
|
+
function accessTokenExpiry(auth) {
|
|
37
|
+
if (!auth) return null;
|
|
38
|
+
return auth.expiresAt ?? jwtExpiryMs(auth.accessToken);
|
|
39
|
+
}
|
|
40
|
+
function workspaceTokenExpiry(auth) {
|
|
41
|
+
if (!auth?.workspaceToken) return auth?.workspaceTokenExpiresAt ?? null;
|
|
42
|
+
return auth.workspaceTokenExpiresAt ?? jwtExpiryMs(auth.workspaceToken);
|
|
43
|
+
}
|
|
19
44
|
function createAuthStore(configDir, authFileName2 = "auth.json") {
|
|
20
45
|
const authFile = path.join(configDir, authFileName2);
|
|
21
46
|
function ensureConfigDir() {
|
|
@@ -47,24 +72,24 @@ function createAuthStore(configDir, authFileName2 = "auth.json") {
|
|
|
47
72
|
}
|
|
48
73
|
}
|
|
49
74
|
function isTokenExpired() {
|
|
50
|
-
const
|
|
51
|
-
if (!
|
|
52
|
-
return Date.now() >=
|
|
75
|
+
const expiresAt = accessTokenExpiry(read());
|
|
76
|
+
if (!expiresAt) return false;
|
|
77
|
+
return Date.now() >= expiresAt;
|
|
53
78
|
}
|
|
54
79
|
function isTokenExpiringSoon() {
|
|
55
|
-
const
|
|
56
|
-
if (!
|
|
57
|
-
return Date.now() + TOKEN_BUFFER_MS >=
|
|
80
|
+
const expiresAt = accessTokenExpiry(read());
|
|
81
|
+
if (!expiresAt) return false;
|
|
82
|
+
return Date.now() + TOKEN_BUFFER_MS >= expiresAt;
|
|
58
83
|
}
|
|
59
84
|
function isWorkspaceTokenExpired() {
|
|
60
|
-
const
|
|
61
|
-
if (!
|
|
62
|
-
return Date.now() >=
|
|
85
|
+
const expiresAt = workspaceTokenExpiry(read());
|
|
86
|
+
if (!expiresAt) return false;
|
|
87
|
+
return Date.now() >= expiresAt;
|
|
63
88
|
}
|
|
64
89
|
function isWorkspaceTokenExpiringSoon() {
|
|
65
|
-
const
|
|
66
|
-
if (!
|
|
67
|
-
return Date.now() + TOKEN_BUFFER_MS >=
|
|
90
|
+
const expiresAt = workspaceTokenExpiry(read());
|
|
91
|
+
if (!expiresAt) return false;
|
|
92
|
+
return Date.now() + TOKEN_BUFFER_MS >= expiresAt;
|
|
68
93
|
}
|
|
69
94
|
function isAuthenticated() {
|
|
70
95
|
const auth = read();
|
|
@@ -73,19 +98,8 @@ function createAuthStore(configDir, authFileName2 = "auth.json") {
|
|
|
73
98
|
return !isTokenExpired();
|
|
74
99
|
}
|
|
75
100
|
function getActorUserId() {
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
if (!token) return null;
|
|
79
|
-
const parts = token.split(".");
|
|
80
|
-
if (parts.length !== 3) return null;
|
|
81
|
-
try {
|
|
82
|
-
const payload = JSON.parse(
|
|
83
|
-
Buffer.from(parts[1].replace(/-/g, "+").replace(/_/g, "/"), "base64").toString("utf8")
|
|
84
|
-
);
|
|
85
|
-
return typeof payload.sub === "string" ? payload.sub : null;
|
|
86
|
-
} catch {
|
|
87
|
-
return null;
|
|
88
|
-
}
|
|
101
|
+
const sub = decodeJwtPayload(read()?.accessToken)?.sub;
|
|
102
|
+
return typeof sub === "string" ? sub : null;
|
|
89
103
|
}
|
|
90
104
|
return {
|
|
91
105
|
read,
|
|
@@ -342,6 +356,30 @@ function isNetworkOrServerError(error) {
|
|
|
342
356
|
}
|
|
343
357
|
return false;
|
|
344
358
|
}
|
|
359
|
+
var GqlRequestError = class extends Error {
|
|
360
|
+
status;
|
|
361
|
+
authFailure;
|
|
362
|
+
constructor(message, status, authFailure) {
|
|
363
|
+
super(message);
|
|
364
|
+
this.name = "GqlRequestError";
|
|
365
|
+
this.status = status;
|
|
366
|
+
this.authFailure = authFailure;
|
|
367
|
+
}
|
|
368
|
+
};
|
|
369
|
+
function toGqlRequestError(error) {
|
|
370
|
+
let status;
|
|
371
|
+
let authFailure;
|
|
372
|
+
if (error && typeof error === "object" && "response" in error) {
|
|
373
|
+
const resp = error.response;
|
|
374
|
+
if (typeof resp?.status === "number") status = resp.status;
|
|
375
|
+
const failure = resp?.errors?.find((e) => typeof e.extensions?.authFailure === "string")?.extensions?.authFailure;
|
|
376
|
+
if (typeof failure === "string") authFailure = failure;
|
|
377
|
+
}
|
|
378
|
+
return new GqlRequestError(extractGqlErrorMessage(error), status, authFailure);
|
|
379
|
+
}
|
|
380
|
+
function isExpiredCredentialError(error) {
|
|
381
|
+
return error instanceof GqlRequestError && error.authFailure === "CREDENTIAL_EXPIRED";
|
|
382
|
+
}
|
|
345
383
|
function extractGqlErrorMessage(error) {
|
|
346
384
|
if (error && typeof error === "object" && "response" in error) {
|
|
347
385
|
const resp = error;
|
|
@@ -394,7 +432,7 @@ async function executeWithRetry(client, document, variables) {
|
|
|
394
432
|
break;
|
|
395
433
|
}
|
|
396
434
|
}
|
|
397
|
-
throw
|
|
435
|
+
throw toGqlRequestError(lastError);
|
|
398
436
|
}
|
|
399
437
|
function createGqlClients(config, authStore) {
|
|
400
438
|
let workspaceClient = null;
|
|
@@ -456,7 +494,7 @@ function createGqlClients(config, authStore) {
|
|
|
456
494
|
}
|
|
457
495
|
async function refreshWorkspaceToken() {
|
|
458
496
|
const auth = authStore.read();
|
|
459
|
-
if (!auth?.accessToken || !auth.workspaceId || !auth.organizationId) return;
|
|
497
|
+
if (!auth?.accessToken || !auth.workspaceId || !auth.organizationId) return false;
|
|
460
498
|
const cfg = config.read();
|
|
461
499
|
try {
|
|
462
500
|
const result = await issueWorkspaceToken(
|
|
@@ -471,7 +509,9 @@ function createGqlClients(config, authStore) {
|
|
|
471
509
|
workspaceTokenExpiresAt: new Date(result.expiresAt).getTime()
|
|
472
510
|
});
|
|
473
511
|
workspaceClient = null;
|
|
512
|
+
return true;
|
|
474
513
|
} catch {
|
|
514
|
+
return false;
|
|
475
515
|
}
|
|
476
516
|
}
|
|
477
517
|
async function ensureFreshTokens() {
|
|
@@ -484,12 +524,22 @@ function createGqlClients(config, authStore) {
|
|
|
484
524
|
await refreshWorkspaceToken();
|
|
485
525
|
}
|
|
486
526
|
}
|
|
527
|
+
async function requestWorkspace(document, variables) {
|
|
528
|
+
const { workspace: ws } = workspaceClient ? { workspace: workspaceClient } : init();
|
|
529
|
+
ws.setHeaders(getWorkspaceHeaders(authStore.read()));
|
|
530
|
+
return executeWithRetry(ws, document, variables);
|
|
531
|
+
}
|
|
487
532
|
const workspace = {
|
|
488
533
|
async request(document, variables) {
|
|
489
534
|
await ensureFreshTokens();
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
535
|
+
try {
|
|
536
|
+
return await requestWorkspace(document, variables);
|
|
537
|
+
} catch (error) {
|
|
538
|
+
if (!isExpiredCredentialError(error) || authStore.read()?.apiKey) throw error;
|
|
539
|
+
if (authStore.isTokenExpiringSoon()) await refreshPlatformToken();
|
|
540
|
+
if (!await refreshWorkspaceToken()) throw error;
|
|
541
|
+
return requestWorkspace(document, variables);
|
|
542
|
+
}
|
|
493
543
|
}
|
|
494
544
|
};
|
|
495
545
|
const global = {
|
|
@@ -1110,6 +1160,7 @@ function stringifyCause(cause) {
|
|
|
1110
1160
|
|
|
1111
1161
|
exports.CircularDependencyError = CircularDependencyError;
|
|
1112
1162
|
exports.DESTRUCTIVE_NAME_VERBS = DESTRUCTIVE_NAME_VERBS;
|
|
1163
|
+
exports.GqlRequestError = GqlRequestError;
|
|
1113
1164
|
exports.McpAuthError = McpAuthError;
|
|
1114
1165
|
exports.McpInternalError = McpInternalError;
|
|
1115
1166
|
exports.McpUserError = McpUserError;
|
|
@@ -1128,8 +1179,10 @@ exports.extractGqlErrorMessage = extractGqlErrorMessage;
|
|
|
1128
1179
|
exports.fetchWorkspaces = fetchWorkspaces;
|
|
1129
1180
|
exports.inferDestructiveHint = inferDestructiveHint;
|
|
1130
1181
|
exports.inferReadOnlyHint = inferReadOnlyHint;
|
|
1182
|
+
exports.isExpiredCredentialError = isExpiredCredentialError;
|
|
1131
1183
|
exports.issueWorkspaceToken = issueWorkspaceToken;
|
|
1132
1184
|
exports.jsonResult = jsonResult;
|
|
1185
|
+
exports.jwtExpiryMs = jwtExpiryMs;
|
|
1133
1186
|
exports.mcpPromptName = mcpPromptName;
|
|
1134
1187
|
exports.mcpResourceUri = mcpResourceUri;
|
|
1135
1188
|
exports.mcpToolName = mcpToolName;
|