@ai-sdk/mcp 1.0.79 → 1.0.81

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.mjs CHANGED
@@ -1172,9 +1172,11 @@ async function authInternal(provider, {
1172
1172
  resourceMetadataUrl,
1173
1173
  fetchFn
1174
1174
  }) {
1175
- var _a3, _b3;
1175
+ var _a3, _b3, _c;
1176
1176
  let resourceMetadata;
1177
1177
  let authorizationServerUrl;
1178
+ let clientInformation;
1179
+ let callbackAuthorizationServerInformation;
1178
1180
  assertResourceMetadataUrlSameOrigin(serverUrl, resourceMetadataUrl);
1179
1181
  try {
1180
1182
  resourceMetadata = await discoverOAuthProtectedResourceMetadata(
@@ -1187,15 +1189,24 @@ async function authInternal(provider, {
1187
1189
  }
1188
1190
  } catch (e) {
1189
1191
  }
1192
+ if (authorizationCode !== void 0) {
1193
+ clientInformation = await Promise.resolve(provider.clientInformation());
1194
+ if (clientInformation) {
1195
+ callbackAuthorizationServerInformation = await getStoredAuthorizationServerInformation({
1196
+ provider,
1197
+ clientInformation
1198
+ });
1199
+ }
1200
+ }
1190
1201
  if (!authorizationServerUrl) {
1191
- authorizationServerUrl = serverUrl;
1202
+ authorizationServerUrl = (_a3 = callbackAuthorizationServerInformation == null ? void 0 : callbackAuthorizationServerInformation.authorizationServerUrl) != null ? _a3 : serverUrl;
1192
1203
  }
1193
1204
  const resource = await selectResourceURL(
1194
1205
  serverUrl,
1195
1206
  provider,
1196
1207
  resourceMetadata
1197
1208
  );
1198
- await ((_a3 = provider.validateAuthorizationServerURL) == null ? void 0 : _a3.call(
1209
+ await ((_b3 = provider.validateAuthorizationServerURL) == null ? void 0 : _b3.call(
1199
1210
  provider,
1200
1211
  serverUrl,
1201
1212
  authorizationServerUrl
@@ -1213,7 +1224,9 @@ async function authInternal(provider, {
1213
1224
  resourceMetadata,
1214
1225
  clientMetadata
1215
1226
  });
1216
- let clientInformation = await Promise.resolve(provider.clientInformation());
1227
+ if (authorizationCode === void 0) {
1228
+ clientInformation = await Promise.resolve(provider.clientInformation());
1229
+ }
1217
1230
  if (!clientInformation) {
1218
1231
  if (authorizationCode !== void 0) {
1219
1232
  throw new Error(
@@ -1248,7 +1261,7 @@ async function authInternal(provider, {
1248
1261
  );
1249
1262
  }
1250
1263
  }
1251
- const storedAuthorizationServerInformation = await getStoredAuthorizationServerInformation({
1264
+ const storedAuthorizationServerInformation = callbackAuthorizationServerInformation != null ? callbackAuthorizationServerInformation : await getStoredAuthorizationServerInformation({
1252
1265
  provider,
1253
1266
  clientInformation
1254
1267
  });
@@ -1293,7 +1306,7 @@ async function authInternal(provider, {
1293
1306
  currentAuthorizationServerInformation
1294
1307
  });
1295
1308
  } else {
1296
- await ((_b3 = provider.invalidateCredentials) == null ? void 0 : _b3.call(provider, "tokens"));
1309
+ await ((_c = provider.invalidateCredentials) == null ? void 0 : _c.call(provider, "tokens"));
1297
1310
  }
1298
1311
  try {
1299
1312
  if (storedAuthorizationServerInformation) {