@vercel/connect 2.0.4 → 2.2.0

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/README.md CHANGED
@@ -5,7 +5,7 @@ SDK for obtaining scoped tokens for third-party services on behalf of apps or us
5
5
  Seven entrypoints, all ESM:
6
6
 
7
7
  - `@vercel/connect` — core token / authorization SDK
8
- - `@vercel/connect/chat` — adapter helpers for the [Chat SDK](https://chat-sdk.dev) (`chat`): `connectSlackAdapter`, `connectDiscordAdapter`, `connectGitHubAdapter`, `connectLinearAdapter`, `connectNotionAdapter`, `connectTelegramAdapter`, `connectSendblueAdapter` (no Chat SDK dependency — returns structural config)
8
+ - `@vercel/connect/chat` — adapter helpers for the [Chat SDK](https://chat-sdk.dev) (`chat`): `connectSlackAdapter`, `connectDiscordAdapter`, `connectGitHubAdapter`, `connectLinearAdapter`, `connectNotionAdapter`, `connectTelegramAdapter`, `connectSendblueAdapter`, `connectTeamsAdapter` (no Chat SDK dependency — returns structural config)
9
9
  - `@vercel/connect/ai-sdk` — [Vercel AI SDK](https://ai-sdk.dev) glue: re-exports `connectAuthProvider` for MCP transports (optional peers: `ai`, `@ai-sdk/mcp`)
10
10
  - `@vercel/connect/mcp` — canonical MCP-spec `OAuthClientProvider` for any MCP client (optional peer: `@ai-sdk/mcp`)
11
11
  - `@vercel/connect/eve` — adapter helpers for [Eve](https://github.com/vercel/eve) connections (optional peer: `eve`)
@@ -62,6 +62,20 @@ createSlackAdapter({
62
62
  `connectGitHubAdapter` (`installationToken`), and `connectLinearAdapter`
63
63
  (`accessToken`) follow the same shape. `connectSendblueAdapter` supplies a
64
64
  lazy Sendblue `accessToken` and Connect OIDC webhook verifier.
65
+ `connectTeamsAdapter` supplies a lazy Microsoft Teams `appId`, a scope-aware
66
+ `token` callback for Bot Framework and Microsoft Graph, and Connect OIDC webhook
67
+ verification. Use it with a Teams adapter release that supports lazy `appId`
68
+ and `webhookVerifier`:
69
+
70
+ ```ts
71
+ import { createTeamsAdapter } from '@chat-adapter/teams';
72
+ import { connectTeamsAdapter } from '@vercel/connect/chat';
73
+
74
+ createTeamsAdapter({
75
+ ...connectTeamsAdapter('microsoft-teams/my-bot'),
76
+ });
77
+ ```
78
+
65
79
  `connectNotionAdapter` supplies only the outbound `token`; native Notion
66
80
  webhooks still require `NOTION_VERIFICATION_TOKEN`. `connectTelegramAdapter`
67
81
  supplies only `botToken`; Telegram retains native webhook verification or
@@ -110,10 +124,10 @@ can import the same `connectAuthProvider` from `@vercel/connect/mcp`.
110
124
 
111
125
  ### Eve
112
126
 
113
- Use `connectSendblueCredentials` with Eve's native Sendblue channel. It
114
- resolves the app-scoped bearer token and managed sending line together, and
115
- includes Vercel OIDC webhook verification. When the connector has multiple
116
- lines, pass `fromNumber` to choose one.
127
+ Use channel-specific credential helpers with Eve's native channels.
128
+ `connectSendblueCredentials` resolves the app-scoped bearer token and managed
129
+ sending line together, and includes Vercel OIDC webhook verification. When the
130
+ connector has multiple lines, pass `fromNumber` to choose one.
117
131
 
118
132
  ```ts
119
133
  import { connectSendblueCredentials } from '@vercel/connect/eve';
@@ -124,6 +138,20 @@ export default sendblueChannel({
124
138
  });
125
139
  ```
126
140
 
141
+ For managed Microsoft Teams bots, `connectTeamsCredentials` resolves the
142
+ public bot application id and short-lived Bot Framework token without exposing
143
+ the managed app's federated credential. It also verifies Connect-forwarded
144
+ activities with Vercel OIDC.
145
+
146
+ ```ts
147
+ import { connectTeamsCredentials } from '@vercel/connect/eve';
148
+ import { teamsChannel } from 'eve/channels/teams';
149
+
150
+ export default teamsChannel({
151
+ credentials: connectTeamsCredentials('microsoft-teams/my-agent'),
152
+ });
153
+ ```
154
+
127
155
  ```ts
128
156
  import { defineMcpClientConnection } from 'eve/connections';
129
157
  import { connect } from '@vercel/connect/eve';
@@ -21,7 +21,7 @@
21
21
  * ```
22
22
  */
23
23
  export { createConnectWebhookVerifier, type ConnectWebhookVerifier, type ConnectWebhookVerifierOptions, } from './webhook-verifier.js';
24
- export type { ConnectDiscordAdapterConfig, ConnectGitHubAdapterConfig, ConnectLinearAdapterConfig, ConnectLinqAdapterConfig, ConnectLinqCredentials, ConnectNotionAdapterConfig, ConnectSendblueAdapterConfig, ConnectTelegramAdapterConfig, ConnectTokenResolver, } from './types.js';
24
+ export type { ConnectDiscordAdapterConfig, ConnectGitHubAdapterConfig, ConnectLinearAdapterConfig, ConnectLinqAdapterConfig, ConnectLinqCredentials, ConnectNotionAdapterConfig, ConnectSendblueAdapterConfig, ConnectTeamsAdapterConfig, ConnectTelegramAdapterConfig, ConnectTokenResolver, } from './types.js';
25
25
  export { connectDiscordAdapter, type ConnectDiscordAdapterParams, } from './discord-adapter.js';
26
26
  export { connectSlackAdapter, type ConnectSlackAdapterConfig, type ConnectSlackAdapterParams, } from './slack-adapter.js';
27
27
  export { connectGitHubAdapter, type ConnectGitHubAdapterParams, } from './github-adapter.js';
@@ -30,3 +30,4 @@ export { connectLinqAdapter, type ConnectLinqAdapterParams, } from './linq-adapt
30
30
  export { connectNotionAdapter, type ConnectNotionAdapterParams, } from './notion-adapter.js';
31
31
  export { connectTelegramAdapter, type ConnectTelegramAdapterParams, } from './telegram-adapter.js';
32
32
  export { connectSendblueAdapter, type ConnectSendblueAdapterParams, } from './sendblue-adapter.js';
33
+ export { connectTeamsAdapter, type ConnectTeamsAdapterParams, } from './teams-adapter.js';
@@ -29,3 +29,4 @@ export { connectLinqAdapter, } from './linq-adapter.js';
29
29
  export { connectNotionAdapter, } from './notion-adapter.js';
30
30
  export { connectTelegramAdapter, } from './telegram-adapter.js';
31
31
  export { connectSendblueAdapter, } from './sendblue-adapter.js';
32
+ export { connectTeamsAdapter, } from './teams-adapter.js';
@@ -0,0 +1,31 @@
1
+ import { type ConnectOptions, type ConnectTokenParams } from '../index.js';
2
+ import type { ConnectTeamsAdapterConfig } from './types.js';
3
+ /**
4
+ * Teams bot tokens are app-scoped. The adapter selects the resource scopes
5
+ * for each call, so neither `subject` nor `scopes` can be overridden here.
6
+ */
7
+ export type ConnectTeamsAdapterParams = Omit<ConnectTokenParams, 'subject' | 'scopes'>;
8
+ /**
9
+ * Build a Microsoft Teams adapter config backed by a managed Connect bot.
10
+ *
11
+ * ```ts
12
+ * import { createTeamsAdapter } from '@chat-adapter/teams';
13
+ * import { connectTeamsAdapter } from '@vercel/connect/chat';
14
+ *
15
+ * createTeamsAdapter({
16
+ * ...connectTeamsAdapter('microsoft-teams/my-bot'),
17
+ * });
18
+ * ```
19
+ *
20
+ * The app id is resolved lazily from public connector metadata. The token
21
+ * callback requests separate Bot Framework and Microsoft Graph tokens using
22
+ * the adapter's scopes, with caching and refresh handled by Connect. Graph
23
+ * access requires the bot's resource-specific permissions to be granted when
24
+ * it is installed in a team.
25
+ *
26
+ * Connect selects the managed bot's home tenant, so the token callback's
27
+ * tenant argument does not change token selection. The webhook verifier
28
+ * validates Connect-forwarded activities with Vercel OIDC after Connect has
29
+ * verified Microsoft's native JWT.
30
+ */
31
+ export declare function connectTeamsAdapter(connector: string, params?: ConnectTeamsAdapterParams, options?: ConnectOptions): ConnectTeamsAdapterConfig;
@@ -0,0 +1,43 @@
1
+ import { getConnectorMetadata, getToken, } from '../index.js';
2
+ import { createConnectWebhookVerifier } from './webhook-verifier.js';
3
+ /**
4
+ * Build a Microsoft Teams adapter config backed by a managed Connect bot.
5
+ *
6
+ * ```ts
7
+ * import { createTeamsAdapter } from '@chat-adapter/teams';
8
+ * import { connectTeamsAdapter } from '@vercel/connect/chat';
9
+ *
10
+ * createTeamsAdapter({
11
+ * ...connectTeamsAdapter('microsoft-teams/my-bot'),
12
+ * });
13
+ * ```
14
+ *
15
+ * The app id is resolved lazily from public connector metadata. The token
16
+ * callback requests separate Bot Framework and Microsoft Graph tokens using
17
+ * the adapter's scopes, with caching and refresh handled by Connect. Graph
18
+ * access requires the bot's resource-specific permissions to be granted when
19
+ * it is installed in a team.
20
+ *
21
+ * Connect selects the managed bot's home tenant, so the token callback's
22
+ * tenant argument does not change token selection. The webhook verifier
23
+ * validates Connect-forwarded activities with Vercel OIDC after Connect has
24
+ * verified Microsoft's native JWT.
25
+ */
26
+ export function connectTeamsAdapter(connector, params = {}, options) {
27
+ return {
28
+ appId: async () => {
29
+ const metadata = await getConnectorMetadata(connector, options);
30
+ const appId = metadata.vendor.appId;
31
+ if (typeof appId !== 'string' || appId.length === 0) {
32
+ throw new Error(`Vercel Connect connector ${connector} did not return a Microsoft Teams app id.`);
33
+ }
34
+ return appId;
35
+ },
36
+ token: scope => getToken(connector, {
37
+ ...params,
38
+ subject: { type: 'app' },
39
+ scopes: Array.isArray(scope) ? scope : [scope],
40
+ }, options),
41
+ webhookVerifier: createConnectWebhookVerifier(),
42
+ };
43
+ }
@@ -76,6 +76,17 @@ export interface ConnectNotionAdapterConfig {
76
76
  export interface ConnectTelegramAdapterConfig {
77
77
  botToken: ConnectTokenResolver;
78
78
  }
79
+ /**
80
+ * Partial Microsoft Teams adapter config backed by Vercel Connect.
81
+ *
82
+ * Structurally matches the lazy `appId`, scope-aware `token`, and
83
+ * `webhookVerifier` options of `createTeamsAdapter` from `@chat-adapter/teams`.
84
+ */
85
+ export interface ConnectTeamsAdapterConfig {
86
+ appId: ConnectTokenResolver;
87
+ token: (scope: string | string[], tenantId?: string) => Promise<string>;
88
+ webhookVerifier: ConnectWebhookVerifier;
89
+ }
79
90
  /**
80
91
  * Partial Sendblue adapter config backed by Vercel Connect.
81
92
  *
@@ -12,6 +12,7 @@ export { connectDiscordCredentials, type ConnectDiscordCredentialsParams, } from
12
12
  export { connectGitHubCredentials, type ConnectGitHubCredentialsParams, } from './github-credentials.js';
13
13
  export { connectLinearCredentials, type ConnectLinearCredentialsParams, } from './linear-credentials.js';
14
14
  export { connectLinqCredentials, type ConnectLinqCredentials, type ConnectLinqCredentialsParams, } from './linq-credentials.js';
15
+ export { connectTeamsCredentials, type ConnectTeamsCredentialsParams, } from './microsoft-teams-credentials.js';
15
16
  export { connectPhotonCredentials, type ConnectPhotonCredentialProvider, type PhotonCredentials, type ConnectPhotonCredentialsParams, } from './photon-credentials.js';
16
17
  export { connectSlackCredentials, type ConnectSlackCredentialsParams, } from './slack-credentials.js';
17
18
  export { connectSendblueCredentials, type ConnectSendblueCredentials, type ConnectSendblueCredentialsParams, } from './sendblue-credentials.js';
package/dist/eve/index.js CHANGED
@@ -12,6 +12,7 @@ export { connectDiscordCredentials, } from './discord-credentials.js';
12
12
  export { connectGitHubCredentials, } from './github-credentials.js';
13
13
  export { connectLinearCredentials, } from './linear-credentials.js';
14
14
  export { connectLinqCredentials, } from './linq-credentials.js';
15
+ export { connectTeamsCredentials, } from './microsoft-teams-credentials.js';
15
16
  export { connectPhotonCredentials, } from './photon-credentials.js';
16
17
  export { connectSlackCredentials, } from './slack-credentials.js';
17
18
  export { connectSendblueCredentials, } from './sendblue-credentials.js';
@@ -0,0 +1,30 @@
1
+ import type { TeamsChannelCredentials } from 'eve/channels/teams';
2
+ import { type ConnectOptions, type ConnectTokenParams } from '../index.js';
3
+ /**
4
+ * Token parameters accepted by {@link connectTeamsCredentials}.
5
+ *
6
+ * Mirrors {@link ConnectTokenParams}, except that Teams bot credentials are
7
+ * always app-scoped and must request the Bot Framework resource. `subject`
8
+ * and `scopes` are therefore pinned by the helper.
9
+ */
10
+ export type ConnectTeamsCredentialsParams = Omit<ConnectTokenParams, 'subject' | 'scopes'>;
11
+ /**
12
+ * Build {@link TeamsChannelCredentials} backed by a managed Vercel Connect
13
+ * Microsoft Teams connector.
14
+ *
15
+ * The helper resolves the managed bot's public application id from connector
16
+ * metadata and obtains short-lived Bot Framework access tokens through
17
+ * Vercel Connect. It never exposes the managed app's federated credential.
18
+ * Vercel OIDC verifies trigger-forwarded Bot Framework activities, after
19
+ * Connect has verified their native bearer JWT.
20
+ *
21
+ * ```ts
22
+ * import { connectTeamsCredentials } from '@vercel/connect/eve';
23
+ * import { teamsChannel } from 'eve/channels/teams';
24
+ *
25
+ * export default teamsChannel({
26
+ * credentials: connectTeamsCredentials('microsoft-teams/my-agent'),
27
+ * });
28
+ * ```
29
+ */
30
+ export declare function connectTeamsCredentials(connector: string, params?: ConnectTeamsCredentialsParams, options?: ConnectOptions): TeamsChannelCredentials;
@@ -0,0 +1,44 @@
1
+ import { vercelOidc } from 'eve/channels/auth';
2
+ import { getConnectorMetadata, getTokenResponse, } from '../index.js';
3
+ const BOT_FRAMEWORK_SCOPE = 'https://api.botframework.com/.default';
4
+ /**
5
+ * Build {@link TeamsChannelCredentials} backed by a managed Vercel Connect
6
+ * Microsoft Teams connector.
7
+ *
8
+ * The helper resolves the managed bot's public application id from connector
9
+ * metadata and obtains short-lived Bot Framework access tokens through
10
+ * Vercel Connect. It never exposes the managed app's federated credential.
11
+ * Vercel OIDC verifies trigger-forwarded Bot Framework activities, after
12
+ * Connect has verified their native bearer JWT.
13
+ *
14
+ * ```ts
15
+ * import { connectTeamsCredentials } from '@vercel/connect/eve';
16
+ * import { teamsChannel } from 'eve/channels/teams';
17
+ *
18
+ * export default teamsChannel({
19
+ * credentials: connectTeamsCredentials('microsoft-teams/my-agent'),
20
+ * });
21
+ * ```
22
+ */
23
+ export function connectTeamsCredentials(connector, params = {}, options) {
24
+ return {
25
+ appId: () => getTeamsAppId(connector, options),
26
+ tokenProvider: async () => {
27
+ const response = await getTokenResponse(connector, {
28
+ ...params,
29
+ subject: { type: 'app' },
30
+ scopes: [BOT_FRAMEWORK_SCOPE],
31
+ }, options);
32
+ return { accessToken: response.token, expiresAt: response.expiresAt };
33
+ },
34
+ webhookVerifier: vercelOidc(),
35
+ };
36
+ }
37
+ async function getTeamsAppId(connector, options) {
38
+ const metadata = await getConnectorMetadata(connector, options);
39
+ const appId = metadata.vendor.appId;
40
+ if (typeof appId !== 'string' || appId.length === 0) {
41
+ throw new Error(`Vercel Connect connector ${connector} did not return a Microsoft Teams app id.`);
42
+ }
43
+ return appId;
44
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/connect",
3
- "version": "2.0.4",
3
+ "version": "2.2.0",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "repository": {
@@ -42,7 +42,7 @@
42
42
  "dist"
43
43
  ],
44
44
  "dependencies": {
45
- "@vercel/oidc": "3.8.7"
45
+ "@vercel/oidc": "3.8.8"
46
46
  },
47
47
  "peerDependencies": {
48
48
  "@ai-sdk/mcp": "^1 || ^2",