align-mcp-remote 0.1.40 → 0.1.42
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.
|
@@ -15632,7 +15632,7 @@ var Client = class extends Protocol {
|
|
|
15632
15632
|
};
|
|
15633
15633
|
|
|
15634
15634
|
// package.json
|
|
15635
|
-
var version2 = "0.1.
|
|
15635
|
+
var version2 = "0.1.41";
|
|
15636
15636
|
|
|
15637
15637
|
// node_modules/pkce-challenge/dist/index.node.js
|
|
15638
15638
|
var crypto;
|
|
@@ -18113,9 +18113,24 @@ async function performDownstreamAuth(authProvider, downstreamResource, callbackP
|
|
|
18113
18113
|
const host = authProvider.options.host || "localhost";
|
|
18114
18114
|
const redirectUrl = `http://${host}:${downstreamCallbackPort}/oauth/callback`;
|
|
18115
18115
|
const scope = downstreamResource.scopes_required?.join(" ") ?? "";
|
|
18116
|
+
const downstreamClientMetadata = {
|
|
18117
|
+
redirect_uris: [redirectUrl],
|
|
18118
|
+
token_endpoint_auth_method: "none",
|
|
18119
|
+
grant_types: ["authorization_code", "refresh_token"],
|
|
18120
|
+
response_types: ["code"],
|
|
18121
|
+
client_name: authProvider.options.clientName || "MCP CLI Client",
|
|
18122
|
+
scope
|
|
18123
|
+
};
|
|
18124
|
+
const downstreamClientInfo = await registerClient(downstreamAs, {
|
|
18125
|
+
metadata: downstreamServerMetadata,
|
|
18126
|
+
clientMetadata: downstreamClientMetadata
|
|
18127
|
+
});
|
|
18128
|
+
debugLog("Registered downstream client", { client_id: downstreamClientInfo.client_id });
|
|
18129
|
+
const downstreamHash = crypto2.createHash("md5").update(downstreamAs).digest("hex");
|
|
18130
|
+
await writeJsonFile(downstreamHash, "downstream_client_info.json", downstreamClientInfo);
|
|
18116
18131
|
const { authorizationUrl, codeVerifier } = await startAuthorization(downstreamAs, {
|
|
18117
18132
|
metadata: downstreamServerMetadata,
|
|
18118
|
-
clientInformation:
|
|
18133
|
+
clientInformation: downstreamClientInfo,
|
|
18119
18134
|
redirectUrl,
|
|
18120
18135
|
scope,
|
|
18121
18136
|
resource: new URL(downstreamResource.resource)
|
|
@@ -18135,7 +18150,7 @@ ${authorizationUrl.toString()}
|
|
|
18135
18150
|
const code = await waitForDownstreamCode();
|
|
18136
18151
|
const tokens = await exchangeAuthorization(downstreamAs, {
|
|
18137
18152
|
metadata: downstreamServerMetadata,
|
|
18138
|
-
clientInformation:
|
|
18153
|
+
clientInformation: downstreamClientInfo,
|
|
18139
18154
|
authorizationCode: code,
|
|
18140
18155
|
codeVerifier,
|
|
18141
18156
|
redirectUri: redirectUrl
|
|
@@ -18161,14 +18176,14 @@ async function connectToRemoteServer(client, serverUrl, authProvider, headers, a
|
|
|
18161
18176
|
};
|
|
18162
18177
|
const eventSourceInit = {
|
|
18163
18178
|
fetch: async (url3, init) => {
|
|
18164
|
-
const [tokens,
|
|
18179
|
+
const [tokens, downstreamHeader] = await Promise.all([authProvider?.tokens?.(), resolveDownstreamHeader()]);
|
|
18165
18180
|
return fetch2(url3, {
|
|
18166
18181
|
...init,
|
|
18167
18182
|
headers: {
|
|
18168
18183
|
...init?.headers instanceof Headers2 ? Object.fromEntries(init?.headers.entries()) : init?.headers || {},
|
|
18169
18184
|
...headers,
|
|
18170
18185
|
...tokens?.access_token ? { Authorization: `Bearer ${tokens.access_token}` } : {},
|
|
18171
|
-
...
|
|
18186
|
+
...downstreamHeader,
|
|
18172
18187
|
Accept: "text/event-stream"
|
|
18173
18188
|
}
|
|
18174
18189
|
});
|
|
@@ -18177,15 +18192,22 @@ async function connectToRemoteServer(client, serverUrl, authProvider, headers, a
|
|
|
18177
18192
|
log(`Using transport strategy: ${transportStrategy}`);
|
|
18178
18193
|
const shouldAttemptFallback2 = transportStrategy === "http-first" || transportStrategy === "sse-first";
|
|
18179
18194
|
const sseTransport = transportStrategy === "sse-only" || transportStrategy === "sse-first";
|
|
18180
|
-
const
|
|
18181
|
-
|
|
18195
|
+
const fetchWithDownstreamHeader = async (input, init) => {
|
|
18196
|
+
const downstreamHeader = await resolveDownstreamHeader();
|
|
18197
|
+
const existingHeaders = init?.headers instanceof Headers2 ? Object.fromEntries(init.headers.entries()) : init?.headers || {};
|
|
18198
|
+
return fetch2(input, {
|
|
18199
|
+
...init,
|
|
18200
|
+
headers: { ...existingHeaders, ...headers, ...downstreamHeader }
|
|
18201
|
+
});
|
|
18202
|
+
};
|
|
18182
18203
|
const transport = sseTransport ? new SSEClientTransport(url2, {
|
|
18183
18204
|
authProvider,
|
|
18184
|
-
requestInit: { headers
|
|
18205
|
+
requestInit: { headers },
|
|
18185
18206
|
eventSourceInit
|
|
18186
18207
|
}) : new StreamableHTTPClientTransport(url2, {
|
|
18187
18208
|
authProvider,
|
|
18188
|
-
requestInit: { headers
|
|
18209
|
+
requestInit: { headers },
|
|
18210
|
+
fetch: fetchWithDownstreamHeader
|
|
18189
18211
|
});
|
|
18190
18212
|
try {
|
|
18191
18213
|
debugLog("Attempting to connect to remote server", { sseTransport });
|
package/dist/client.js
CHANGED
package/dist/proxy.js
CHANGED