@ai-sdk/mcp 1.0.90 → 1.0.91

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
@@ -1190,8 +1190,9 @@ async function registerClient(authorizationServerUrl, {
1190
1190
  }
1191
1191
  async function auth(provider, options) {
1192
1192
  var _a3, _b3, _c;
1193
+ const refreshAttempt = {};
1193
1194
  try {
1194
- return await authInternal(provider, options);
1195
+ return await authInternal(provider, options, refreshAttempt);
1195
1196
  } catch (error) {
1196
1197
  if (error instanceof InvalidClientError || error instanceof UnauthorizedClientError) {
1197
1198
  if (options.authorizationCode !== void 0 || !await ((_a3 = provider.isClientInformationDynamicallyRegistered) == null ? void 0 : _a3.call(provider))) {
@@ -1199,8 +1200,10 @@ async function auth(provider, options) {
1199
1200
  }
1200
1201
  await ((_b3 = provider.invalidateCredentials) == null ? void 0 : _b3.call(provider, "all"));
1201
1202
  return await authInternal(provider, options);
1202
- } else if (error instanceof InvalidGrantError) {
1203
- await ((_c = provider.invalidateCredentials) == null ? void 0 : _c.call(provider, "tokens"));
1203
+ } else if (error instanceof InvalidGrantError && refreshAttempt.tokens) {
1204
+ await ((_c = provider.invalidateCredentials) == null ? void 0 : _c.call(provider, "tokens", {
1205
+ tokens: refreshAttempt.tokens
1206
+ }));
1204
1207
  return await authInternal(provider, options);
1205
1208
  }
1206
1209
  throw error;
@@ -1234,7 +1237,7 @@ async function authInternal(provider, {
1234
1237
  scope,
1235
1238
  resourceMetadataUrl,
1236
1239
  fetchFn
1237
- }) {
1240
+ }, refreshAttempt) {
1238
1241
  var _a3, _b3, _c;
1239
1242
  let resourceMetadata;
1240
1243
  let authorizationServerUrl;
@@ -1378,10 +1381,15 @@ async function authInternal(provider, {
1378
1381
  currentAuthorizationServerInformation
1379
1382
  });
1380
1383
  } else {
1381
- await ((_c = provider.invalidateCredentials) == null ? void 0 : _c.call(provider, "tokens"));
1384
+ await ((_c = provider.invalidateCredentials) == null ? void 0 : _c.call(provider, "tokens", {
1385
+ tokens: { ...tokens }
1386
+ }));
1382
1387
  }
1383
1388
  try {
1384
1389
  if (storedAuthorizationServerInformation) {
1390
+ if (refreshAttempt) {
1391
+ refreshAttempt.tokens = { ...tokens };
1392
+ }
1385
1393
  const newTokens = await refreshAuthorization(authorizationServerUrl, {
1386
1394
  metadata,
1387
1395
  clientInformation,