@ai-sdk/mcp 2.0.54 → 2.0.56

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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @ai-sdk/mcp
2
2
 
3
+ ## 2.0.56
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [ffb0e76]
8
+ - @ai-sdk/provider@4.0.18
9
+ - @ai-sdk/provider-utils@5.0.46
10
+
11
+ ## 2.0.55
12
+
13
+ ### Patch Changes
14
+
15
+ - 7fc2bc1: fix(mcp): preserve pre-registered OAuth clients after client authentication errors and require explicit provider provenance before replacing dynamically registered credentials
16
+
3
17
  ## 2.0.54
4
18
 
5
19
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -199,6 +199,16 @@ interface OAuthClientProvider {
199
199
  get redirectUrl(): string | URL;
200
200
  get clientMetadata(): OAuthClientMetadata;
201
201
  clientInformation(): OAuthClientInformation | undefined | Promise<OAuthClientInformation | undefined>;
202
+ /**
203
+ * Returns whether the current client information was obtained through
204
+ * dynamic client registration.
205
+ *
206
+ * Return `true` only when the current client information was saved after a
207
+ * dynamic registration response. When this method is omitted or returns
208
+ * `false`, the client information is treated as pre-registered and is not
209
+ * automatically invalidated after client authentication errors.
210
+ */
211
+ isClientInformationDynamicallyRegistered?(): boolean | Promise<boolean>;
202
212
  saveClientInformation?(clientInformation: OAuthClientInformation): void | Promise<void>;
203
213
  authorizationServerInformation?(): OAuthAuthorizationServerInformation | undefined | Promise<OAuthAuthorizationServerInformation | undefined>;
204
214
  saveAuthorizationServerInformation?(authorizationServerInformation: OAuthAuthorizationServerInformation): void | Promise<void>;
package/dist/index.js CHANGED
@@ -1258,15 +1258,18 @@ function inferOAuthApplicationType(redirectUris) {
1258
1258
  return redirectUris.every(isNativeRedirectUri) ? "native" : "web";
1259
1259
  }
1260
1260
  async function auth(provider, options) {
1261
- var _a3, _b3;
1261
+ var _a3, _b3, _c;
1262
1262
  try {
1263
1263
  return await authInternal(provider, options);
1264
1264
  } catch (error) {
1265
1265
  if (error instanceof InvalidClientError || error instanceof UnauthorizedClientError) {
1266
- await ((_a3 = provider.invalidateCredentials) == null ? void 0 : _a3.call(provider, "all"));
1266
+ if (options.authorizationCode !== void 0 || !await ((_a3 = provider.isClientInformationDynamicallyRegistered) == null ? void 0 : _a3.call(provider))) {
1267
+ throw error;
1268
+ }
1269
+ await ((_b3 = provider.invalidateCredentials) == null ? void 0 : _b3.call(provider, "all"));
1267
1270
  return await authInternal(provider, options);
1268
1271
  } else if (error instanceof InvalidGrantError) {
1269
- await ((_b3 = provider.invalidateCredentials) == null ? void 0 : _b3.call(provider, "tokens"));
1272
+ await ((_c = provider.invalidateCredentials) == null ? void 0 : _c.call(provider, "tokens"));
1270
1273
  return await authInternal(provider, options);
1271
1274
  }
1272
1275
  throw error;