nexrall-code 0.5.189 → 0.5.190
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/index.js +44 -21
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -68020,6 +68020,15 @@ function parseResourceMetadataUrl(wwwAuthenticate) {
|
|
|
68020
68020
|
const m2 = /resource_metadata\s*=\s*"([^"]+)"/i.exec(wwwAuthenticate || "");
|
|
68021
68021
|
return m2 ? m2[1] : null;
|
|
68022
68022
|
}
|
|
68023
|
+
function protectedResourceCandidates(serverUrl) {
|
|
68024
|
+
const u = new URL(serverUrl);
|
|
68025
|
+
const base = u.origin;
|
|
68026
|
+
const p = u.pathname.replace(/\/$/, "");
|
|
68027
|
+
return [
|
|
68028
|
+
...p ? [`${base}/.well-known/oauth-protected-resource${p}`] : [],
|
|
68029
|
+
`${base}/.well-known/oauth-protected-resource`
|
|
68030
|
+
];
|
|
68031
|
+
}
|
|
68023
68032
|
function authServerCandidates(authServer) {
|
|
68024
68033
|
const u = new URL(authServer);
|
|
68025
68034
|
const base = u.origin;
|
|
@@ -68076,8 +68085,15 @@ async function discover(serverUrl, wwwAuthenticate, f3 = defaultFetch()) {
|
|
|
68076
68085
|
let authServer = null;
|
|
68077
68086
|
let resource = serverUrl;
|
|
68078
68087
|
let scope;
|
|
68079
|
-
const
|
|
68080
|
-
|
|
68088
|
+
const prmCandidates = [parseResourceMetadataUrl(wwwAuthenticate), ...protectedResourceCandidates(serverUrl)].filter(
|
|
68089
|
+
(u) => Boolean(u)
|
|
68090
|
+
);
|
|
68091
|
+
let prm = null;
|
|
68092
|
+
for (const url2 of new Set(prmCandidates)) {
|
|
68093
|
+
prm = await fetchJsonSafe(f3, url2);
|
|
68094
|
+
if (prm)
|
|
68095
|
+
break;
|
|
68096
|
+
}
|
|
68081
68097
|
if (prm) {
|
|
68082
68098
|
const servers = prm.authorization_servers;
|
|
68083
68099
|
if (Array.isArray(servers) && servers.length)
|
|
@@ -68110,7 +68126,7 @@ async function discover(serverUrl, wwwAuthenticate, f3 = defaultFetch()) {
|
|
|
68110
68126
|
async function registerClient(meta, redirectUri, f3) {
|
|
68111
68127
|
if (!meta.registration_endpoint) {
|
|
68112
68128
|
throw new Error(
|
|
68113
|
-
|
|
68129
|
+
'Authorization server does not support dynamic client registration; a client_id must be configured manually \u2014 create an OAuth client for this server, then re-run `nex mcp login <server> --client-id <id> [--client-secret <secret>]` (or set "clientId" / "clientSecret" in its mcp.json entry).'
|
|
68114
68130
|
);
|
|
68115
68131
|
}
|
|
68116
68132
|
const resp = await f3(meta.registration_endpoint, {
|
|
@@ -68268,25 +68284,32 @@ function openInBrowser(url2) {
|
|
|
68268
68284
|
}
|
|
68269
68285
|
}
|
|
68270
68286
|
async function probeAuthChallenge(serverUrl, f3 = defaultFetch()) {
|
|
68271
|
-
|
|
68272
|
-
|
|
68273
|
-
method: "
|
|
68274
|
-
|
|
68275
|
-
|
|
68276
|
-
|
|
68277
|
-
|
|
68278
|
-
|
|
68279
|
-
|
|
68280
|
-
|
|
68281
|
-
|
|
68282
|
-
|
|
68283
|
-
|
|
68284
|
-
|
|
68285
|
-
|
|
68286
|
-
|
|
68287
|
-
|
|
68288
|
-
|
|
68287
|
+
const steps = [
|
|
68288
|
+
{
|
|
68289
|
+
method: "initialize",
|
|
68290
|
+
params: {
|
|
68291
|
+
protocolVersion: import_code_core5.MCP_PROTOCOL_VERSION,
|
|
68292
|
+
capabilities: {},
|
|
68293
|
+
clientInfo: { name: "nexrall-code", version: "1.0" }
|
|
68294
|
+
}
|
|
68295
|
+
},
|
|
68296
|
+
{ method: "tools/list", params: {} }
|
|
68297
|
+
];
|
|
68298
|
+
for (const { method, params } of steps) {
|
|
68299
|
+
try {
|
|
68300
|
+
const resp = await f3(serverUrl, {
|
|
68301
|
+
method: "POST",
|
|
68302
|
+
headers: { "Content-Type": "application/json", Accept: "application/json, text/event-stream" },
|
|
68303
|
+
body: JSON.stringify({ jsonrpc: "2.0", id: 1, method, params })
|
|
68304
|
+
});
|
|
68305
|
+
const challenge = resp.headers?.get("www-authenticate") ?? "";
|
|
68306
|
+
if (challenge)
|
|
68307
|
+
return challenge;
|
|
68308
|
+
} catch {
|
|
68309
|
+
return "";
|
|
68310
|
+
}
|
|
68289
68311
|
}
|
|
68312
|
+
return "";
|
|
68290
68313
|
}
|
|
68291
68314
|
async function authorizeServer(o) {
|
|
68292
68315
|
const f3 = o.fetchImpl ?? defaultFetch();
|