@opentiny/next-sdk 0.1.8 → 0.1.10

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.
@@ -1061,25 +1061,14 @@
1061
1061
  await this.client.connect(this.transport);
1062
1062
  return { transport: this.transport, sessionId: this.transport.sessionId };
1063
1063
  }
1064
- const { url, token, sessionId, authProvider, type, agent, onError, onUnauthorized, onReconnect } = options;
1064
+ const { url, token, sessionId, type, agent, onError } = options;
1065
1065
  if (agent === true) {
1066
- const proxyOptions = { client: this.client, url, token, sessionId, authProvider };
1067
- let reconnect = false;
1066
+ const proxyOptions = { client: this.client, url, token, sessionId };
1068
1067
  let response;
1069
1068
  const connectProxy = async () => {
1070
1069
  const { transport: transport2, sessionId: sessionId2 } = type === "sse" ? await createSseProxy(proxyOptions) : type === "socket" ? await createSocketProxy(proxyOptions) : await createStreamProxy(proxyOptions);
1071
1070
  transport2.onerror = async (error) => {
1072
1071
  onError == null ? void 0 : onError(error);
1073
- if (error.message === "Unauthorized" && !reconnect) {
1074
- if (typeof onUnauthorized === "function") {
1075
- await onUnauthorized(connectProxy);
1076
- } else {
1077
- reconnect = true;
1078
- await connectProxy();
1079
- reconnect = false;
1080
- await (onReconnect == null ? void 0 : onReconnect());
1081
- }
1082
- }
1083
1072
  };
1084
1073
  response = { transport: transport2, sessionId: sessionId2 };
1085
1074
  };
@@ -1093,14 +1082,9 @@
1093
1082
  await this.client.connect(transport);
1094
1083
  }
1095
1084
  if (type === "sse") {
1096
- if (authProvider) {
1097
- const createTransport = () => new sse_js.SSEClientTransport(endpoint, { authProvider });
1098
- transport = await attemptConnection(this.client, authProvider.waitForOAuthCode, createTransport);
1099
- } else {
1100
- const opts = sseOptions(token, sessionId);
1101
- transport = new sse_js.SSEClientTransport(endpoint, opts);
1102
- await this.client.connect(transport);
1103
- }
1085
+ const opts = sseOptions(token, sessionId);
1086
+ transport = new sse_js.SSEClientTransport(endpoint, opts);
1087
+ await this.client.connect(transport);
1104
1088
  }
1105
1089
  if (type === "socket") {
1106
1090
  transport = new websocket_js.WebSocketClientTransport(new URL(`${url}?sessionId=${sessionId}&token=${token}`));
@@ -1108,14 +1092,9 @@
1108
1092
  await this.client.connect(transport);
1109
1093
  }
1110
1094
  if (typeof transport === "undefined") {
1111
- if (authProvider) {
1112
- const createTransport = () => new streamableHttp_js.StreamableHTTPClientTransport(endpoint, { authProvider });
1113
- transport = await attemptConnection(this.client, authProvider.waitForOAuthCode, createTransport);
1114
- } else {
1115
- const opts = streamOptions(token, sessionId);
1116
- transport = new streamableHttp_js.StreamableHTTPClientTransport(endpoint, opts);
1117
- await this.client.connect(transport);
1118
- }
1095
+ const opts = streamOptions(token, sessionId);
1096
+ transport = new streamableHttp_js.StreamableHTTPClientTransport(endpoint, opts);
1097
+ await this.client.connect(transport);
1119
1098
  }
1120
1099
  this.transport = transport;
1121
1100
  return { transport: this.transport, sessionId: this.transport.sessionId };
@@ -1070,25 +1070,14 @@ class WebMcpClient {
1070
1070
  await this.client.connect(this.transport);
1071
1071
  return { transport: this.transport, sessionId: this.transport.sessionId };
1072
1072
  }
1073
- const { url, token, sessionId, authProvider, type, agent, onError, onUnauthorized, onReconnect } = options;
1073
+ const { url, token, sessionId, type, agent, onError } = options;
1074
1074
  if (agent === true) {
1075
- const proxyOptions = { client: this.client, url, token, sessionId, authProvider };
1076
- let reconnect = false;
1075
+ const proxyOptions = { client: this.client, url, token, sessionId };
1077
1076
  let response;
1078
1077
  const connectProxy = async () => {
1079
1078
  const { transport: transport2, sessionId: sessionId2 } = type === "sse" ? await createSseProxy(proxyOptions) : type === "socket" ? await createSocketProxy(proxyOptions) : await createStreamProxy(proxyOptions);
1080
1079
  transport2.onerror = async (error) => {
1081
1080
  onError == null ? void 0 : onError(error);
1082
- if (error.message === "Unauthorized" && !reconnect) {
1083
- if (typeof onUnauthorized === "function") {
1084
- await onUnauthorized(connectProxy);
1085
- } else {
1086
- reconnect = true;
1087
- await connectProxy();
1088
- reconnect = false;
1089
- await (onReconnect == null ? void 0 : onReconnect());
1090
- }
1091
- }
1092
1081
  };
1093
1082
  response = { transport: transport2, sessionId: sessionId2 };
1094
1083
  };
@@ -1102,14 +1091,9 @@ class WebMcpClient {
1102
1091
  await this.client.connect(transport);
1103
1092
  }
1104
1093
  if (type === "sse") {
1105
- if (authProvider) {
1106
- const createTransport = () => new SSEClientTransport(endpoint, { authProvider });
1107
- transport = await attemptConnection(this.client, authProvider.waitForOAuthCode, createTransport);
1108
- } else {
1109
- const opts = sseOptions(token, sessionId);
1110
- transport = new SSEClientTransport(endpoint, opts);
1111
- await this.client.connect(transport);
1112
- }
1094
+ const opts = sseOptions(token, sessionId);
1095
+ transport = new SSEClientTransport(endpoint, opts);
1096
+ await this.client.connect(transport);
1113
1097
  }
1114
1098
  if (type === "socket") {
1115
1099
  transport = new WebSocketClientTransport(new URL(`${url}?sessionId=${sessionId}&token=${token}`));
@@ -1117,14 +1101,9 @@ class WebMcpClient {
1117
1101
  await this.client.connect(transport);
1118
1102
  }
1119
1103
  if (typeof transport === "undefined") {
1120
- if (authProvider) {
1121
- const createTransport = () => new StreamableHTTPClientTransport(endpoint, { authProvider });
1122
- transport = await attemptConnection(this.client, authProvider.waitForOAuthCode, createTransport);
1123
- } else {
1124
- const opts = streamOptions(token, sessionId);
1125
- transport = new StreamableHTTPClientTransport(endpoint, opts);
1126
- await this.client.connect(transport);
1127
- }
1104
+ const opts = streamOptions(token, sessionId);
1105
+ transport = new StreamableHTTPClientTransport(endpoint, opts);
1106
+ await this.client.connect(transport);
1128
1107
  }
1129
1108
  this.transport = transport;
1130
1109
  return { transport: this.transport, sessionId: this.transport.sessionId };