@vercel/connect 0.6.2 → 0.8.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`, `connectGitHubAdapter`, `connectLinearAdapter` (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` (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`)
@@ -49,8 +49,8 @@ const { url } = await experimental_startInstallation(
49
49
  ### Chat SDK
50
50
 
51
51
  Spread the helper into the matching `create*Adapter` factory. Each helper
52
- wires both outbound app-scoped tokens and inbound Connect trigger-forwarded
53
- webhook verification (Vercel OIDC), so no provider secret lives in your env.
52
+ wires outbound app-scoped tokens; trigger-capable providers also receive
53
+ inbound Connect webhook verification via Vercel OIDC.
54
54
 
55
55
  ```ts
56
56
  import { createSlackAdapter } from '@chat-adapter/slack';
@@ -62,8 +62,12 @@ createSlackAdapter({
62
62
  });
63
63
  ```
64
64
 
65
- `connectGitHubAdapter` (`installationToken`) and `connectLinearAdapter`
66
- (`accessToken`) follow the same shape. See the
65
+ `connectDiscordAdapter` (`botToken` and `applicationId`),
66
+ `connectGitHubAdapter` (`installationToken`), and `connectLinearAdapter`
67
+ (`accessToken`) follow the same shape. `connectNotionAdapter` supplies only the
68
+ outbound `token`; native Notion webhooks still require
69
+ `NOTION_VERIFICATION_TOKEN`. `connectTelegramAdapter` supplies only
70
+ `botToken`; Telegram retains native webhook verification or polling. See the
67
71
  [Chat SDK integration guide](https://github.com/vercel/vercel/blob/main/packages/connect/docs/chat-integration.md)
68
72
  for connector setup, trigger forwarding, and per-platform examples.
69
73
 
@@ -5,6 +5,8 @@ export interface ConnectAuthorizationOptions {
5
5
  webhook?: string;
6
6
  deviceCode?: boolean;
7
7
  expiresInMs?: number;
8
+ /** OAuth prompt value to pass to the connector's authorization server. */
9
+ prompt?: string;
8
10
  }
9
11
  export interface ConnectAuthorizationResponse {
10
12
  request: string;
@@ -27,6 +27,7 @@ export async function startAuthorization(connector, params, options) {
27
27
  ...(options?.expiresInMs !== undefined && {
28
28
  expiresInMs: options.expiresInMs,
29
29
  }),
30
+ ...(options?.prompt !== undefined && { prompt: options.prompt }),
30
31
  };
31
32
  const response = await fetch(endpoint, {
32
33
  method: 'POST',
@@ -0,0 +1,28 @@
1
+ import { type ConnectOptions, type ConnectTokenParams } from '../index.js';
2
+ import type { ConnectDiscordAdapterConfig } from './types.js';
3
+ /**
4
+ * Token parameters accepted by {@link connectDiscordAdapter}.
5
+ *
6
+ * Mirrors {@link ConnectTokenParams} from `@vercel/connect`, minus
7
+ * `subject` — Discord bot tokens are app-scoped, so this helper pins the
8
+ * subject to `{ type: "app" }`.
9
+ */
10
+ export type ConnectDiscordAdapterParams = Omit<ConnectTokenParams, 'subject'>;
11
+ /**
12
+ * Build a Discord adapter config fragment backed by a Vercel Connect Discord
13
+ * Bot connector.
14
+ *
15
+ * The bot token and application id are resolved from the same Connect token
16
+ * response. The webhook verifier accepts interactions forwarded by Connect
17
+ * using Vercel OIDC, so the deployment does not need Discord's public key.
18
+ *
19
+ * ```ts
20
+ * import { createDiscordAdapter } from "@chat-adapter/discord";
21
+ * import { connectDiscordAdapter } from "@vercel/connect/chat";
22
+ *
23
+ * createDiscordAdapter({
24
+ * ...connectDiscordAdapter("discord/my-bot"),
25
+ * });
26
+ * ```
27
+ */
28
+ export declare function connectDiscordAdapter(connector: string, params?: ConnectDiscordAdapterParams, options?: ConnectOptions): ConnectDiscordAdapterConfig;
@@ -0,0 +1,43 @@
1
+ import { getTokenResponse, } from '../index.js';
2
+ import { createConnectWebhookVerifier } from './webhook-verifier.js';
3
+ /**
4
+ * Build a Discord adapter config fragment backed by a Vercel Connect Discord
5
+ * Bot connector.
6
+ *
7
+ * The bot token and application id are resolved from the same Connect token
8
+ * response. The webhook verifier accepts interactions forwarded by Connect
9
+ * using Vercel OIDC, so the deployment does not need Discord's public key.
10
+ *
11
+ * ```ts
12
+ * import { createDiscordAdapter } from "@chat-adapter/discord";
13
+ * import { connectDiscordAdapter } from "@vercel/connect/chat";
14
+ *
15
+ * createDiscordAdapter({
16
+ * ...connectDiscordAdapter("discord/my-bot"),
17
+ * });
18
+ * ```
19
+ */
20
+ export function connectDiscordAdapter(connector, params = {}, options) {
21
+ let pending;
22
+ function resolveCredentials() {
23
+ if (!pending) {
24
+ pending = getTokenResponse(connector, { ...params, subject: { type: 'app' } }, options)
25
+ .then(response => {
26
+ const applicationId = response.metadata?.applicationId;
27
+ if (typeof applicationId !== 'string' || applicationId.length === 0) {
28
+ throw new Error(`Vercel Connect connector ${connector} did not return a Discord application id.`);
29
+ }
30
+ return { applicationId, botToken: response.token };
31
+ })
32
+ .finally(() => {
33
+ pending = undefined;
34
+ });
35
+ }
36
+ return pending;
37
+ }
38
+ return {
39
+ applicationId: async () => (await resolveCredentials()).applicationId,
40
+ botToken: async () => (await resolveCredentials()).botToken,
41
+ webhookVerifier: createConnectWebhookVerifier(),
42
+ };
43
+ }
@@ -4,7 +4,7 @@
4
4
  * Holds helpers that adapt the Vercel Connect SDK to the Chat SDK
5
5
  * (`chat`) platform adapters. Each helper returns a config fragment you
6
6
  * spread into the matching `create*Adapter` factory, wiring a Connect
7
- * connector for both outbound tokens (`getToken`) and inbound
7
+ * connector for both outbound credentials and inbound
8
8
  * trigger-forwarded webhooks (Vercel OIDC verification).
9
9
  *
10
10
  * The helpers stay decoupled from `@chat-adapter/*`: they return
@@ -21,7 +21,10 @@
21
21
  * ```
22
22
  */
23
23
  export { createConnectWebhookVerifier, type ConnectWebhookVerifier, type ConnectWebhookVerifierOptions, } from './webhook-verifier.js';
24
- export type { ConnectGitHubAdapterConfig, ConnectLinearAdapterConfig, ConnectTokenResolver, } from './types.js';
24
+ export type { ConnectDiscordAdapterConfig, ConnectGitHubAdapterConfig, ConnectLinearAdapterConfig, ConnectNotionAdapterConfig, ConnectTelegramAdapterConfig, ConnectTokenResolver, } from './types.js';
25
+ export { connectDiscordAdapter, type ConnectDiscordAdapterParams, } from './discord-adapter.js';
25
26
  export { connectSlackAdapter, type ConnectSlackAdapterConfig, type ConnectSlackAdapterParams, } from './slack-adapter.js';
26
27
  export { connectGitHubAdapter, type ConnectGitHubAdapterParams, } from './github-adapter.js';
27
28
  export { connectLinearAdapter, type ConnectLinearAdapterParams, } from './linear-adapter.js';
29
+ export { connectNotionAdapter, type ConnectNotionAdapterParams, } from './notion-adapter.js';
30
+ export { connectTelegramAdapter, type ConnectTelegramAdapterParams, } from './telegram-adapter.js';
@@ -4,7 +4,7 @@
4
4
  * Holds helpers that adapt the Vercel Connect SDK to the Chat SDK
5
5
  * (`chat`) platform adapters. Each helper returns a config fragment you
6
6
  * spread into the matching `create*Adapter` factory, wiring a Connect
7
- * connector for both outbound tokens (`getToken`) and inbound
7
+ * connector for both outbound credentials and inbound
8
8
  * trigger-forwarded webhooks (Vercel OIDC verification).
9
9
  *
10
10
  * The helpers stay decoupled from `@chat-adapter/*`: they return
@@ -21,6 +21,9 @@
21
21
  * ```
22
22
  */
23
23
  export { createConnectWebhookVerifier, } from './webhook-verifier.js';
24
+ export { connectDiscordAdapter, } from './discord-adapter.js';
24
25
  export { connectSlackAdapter, } from './slack-adapter.js';
25
26
  export { connectGitHubAdapter, } from './github-adapter.js';
26
27
  export { connectLinearAdapter, } from './linear-adapter.js';
28
+ export { connectNotionAdapter, } from './notion-adapter.js';
29
+ export { connectTelegramAdapter, } from './telegram-adapter.js';
@@ -0,0 +1,28 @@
1
+ import { type ConnectOptions, type ConnectTokenParams } from '../index.js';
2
+ import type { ConnectNotionAdapterConfig } from './types.js';
3
+ /**
4
+ * Token parameters accepted by {@link connectNotionAdapter}.
5
+ *
6
+ * Mirrors {@link ConnectTokenParams} from `@vercel/connect`, minus
7
+ * `subject` — Notion connection tokens are app-scoped, so this helper pins
8
+ * the subject to `{ type: "app" }`.
9
+ */
10
+ export type ConnectNotionAdapterParams = Omit<ConnectTokenParams, 'subject'>;
11
+ /**
12
+ * Build a Notion adapter config fragment backed by a Vercel Connect connector.
13
+ *
14
+ * The helper resolves outbound Notion API tokens only. Notion webhooks are
15
+ * delivered directly and must continue to use the adapter's native
16
+ * `verificationToken` / `NOTION_VERIFICATION_TOKEN` HMAC verification.
17
+ *
18
+ * ```ts
19
+ * import { createNotionAdapter } from "@chat-adapter/notion";
20
+ * import { connectNotionAdapter } from "@vercel/connect/chat";
21
+ *
22
+ * createNotionAdapter({
23
+ * ...connectNotionAdapter("notion/acme-notion"),
24
+ * verificationToken: process.env.NOTION_VERIFICATION_TOKEN,
25
+ * });
26
+ * ```
27
+ */
28
+ export declare function connectNotionAdapter(connector: string, params?: ConnectNotionAdapterParams, options?: ConnectOptions): ConnectNotionAdapterConfig;
@@ -0,0 +1,23 @@
1
+ import { getToken, } from '../index.js';
2
+ /**
3
+ * Build a Notion adapter config fragment backed by a Vercel Connect connector.
4
+ *
5
+ * The helper resolves outbound Notion API tokens only. Notion webhooks are
6
+ * delivered directly and must continue to use the adapter's native
7
+ * `verificationToken` / `NOTION_VERIFICATION_TOKEN` HMAC verification.
8
+ *
9
+ * ```ts
10
+ * import { createNotionAdapter } from "@chat-adapter/notion";
11
+ * import { connectNotionAdapter } from "@vercel/connect/chat";
12
+ *
13
+ * createNotionAdapter({
14
+ * ...connectNotionAdapter("notion/acme-notion"),
15
+ * verificationToken: process.env.NOTION_VERIFICATION_TOKEN,
16
+ * });
17
+ * ```
18
+ */
19
+ export function connectNotionAdapter(connector, params = {}, options) {
20
+ return {
21
+ token: () => getToken(connector, { ...params, subject: { type: 'app' } }, options),
22
+ };
23
+ }
@@ -0,0 +1,29 @@
1
+ import { type ConnectOptions, type ConnectTokenParams } from '../index.js';
2
+ import type { ConnectTelegramAdapterConfig } from './types.js';
3
+ /**
4
+ * Token parameters accepted by {@link connectTelegramAdapter}.
5
+ *
6
+ * Mirrors {@link ConnectTokenParams} from `@vercel/connect`, minus
7
+ * `subject` — Telegram bot tokens are app-scoped, so this helper pins the
8
+ * subject to `{ type: "app" }`.
9
+ */
10
+ export type ConnectTelegramAdapterParams = Omit<ConnectTokenParams, 'subject'>;
11
+ /**
12
+ * Build a Telegram adapter config fragment backed by a Vercel Connect
13
+ * connector.
14
+ *
15
+ * The helper resolves outbound Telegram Bot API tokens only. Telegram webhooks
16
+ * are delivered directly and must continue to use the adapter's native
17
+ * `secretToken` / `TELEGRAM_WEBHOOK_SECRET_TOKEN` verification, or polling.
18
+ *
19
+ * ```ts
20
+ * import { createTelegramAdapter } from "@chat-adapter/telegram";
21
+ * import { connectTelegramAdapter } from "@vercel/connect/chat";
22
+ *
23
+ * createTelegramAdapter({
24
+ * ...connectTelegramAdapter("telegram/acme-telegram"),
25
+ * secretToken: process.env.TELEGRAM_WEBHOOK_SECRET_TOKEN,
26
+ * });
27
+ * ```
28
+ */
29
+ export declare function connectTelegramAdapter(connector: string, params?: ConnectTelegramAdapterParams, options?: ConnectOptions): ConnectTelegramAdapterConfig;
@@ -0,0 +1,24 @@
1
+ import { getToken, } from '../index.js';
2
+ /**
3
+ * Build a Telegram adapter config fragment backed by a Vercel Connect
4
+ * connector.
5
+ *
6
+ * The helper resolves outbound Telegram Bot API tokens only. Telegram webhooks
7
+ * are delivered directly and must continue to use the adapter's native
8
+ * `secretToken` / `TELEGRAM_WEBHOOK_SECRET_TOKEN` verification, or polling.
9
+ *
10
+ * ```ts
11
+ * import { createTelegramAdapter } from "@chat-adapter/telegram";
12
+ * import { connectTelegramAdapter } from "@vercel/connect/chat";
13
+ *
14
+ * createTelegramAdapter({
15
+ * ...connectTelegramAdapter("telegram/acme-telegram"),
16
+ * secretToken: process.env.TELEGRAM_WEBHOOK_SECRET_TOKEN,
17
+ * });
18
+ * ```
19
+ */
20
+ export function connectTelegramAdapter(connector, params = {}, options) {
21
+ return {
22
+ botToken: () => getToken(connector, { ...params, subject: { type: 'app' } }, options),
23
+ };
24
+ }
@@ -6,6 +6,18 @@ import type { ConnectWebhookVerifier } from './webhook-verifier.js';
6
6
  * `@vercel/connect` SDK caches and refreshes server-side).
7
7
  */
8
8
  export type ConnectTokenResolver = () => Promise<string>;
9
+ /**
10
+ * Partial Discord adapter config backed by Vercel Connect.
11
+ *
12
+ * Structurally matches the `applicationId`, `botToken`, and
13
+ * `webhookVerifier` options of `createDiscordAdapter` from
14
+ * `@chat-adapter/discord`.
15
+ */
16
+ export interface ConnectDiscordAdapterConfig {
17
+ applicationId: ConnectTokenResolver;
18
+ botToken: ConnectTokenResolver;
19
+ webhookVerifier: ConnectWebhookVerifier;
20
+ }
9
21
  /**
10
22
  * Partial GitHub adapter config backed by Vercel Connect.
11
23
  *
@@ -26,3 +38,23 @@ export interface ConnectLinearAdapterConfig {
26
38
  accessToken: ConnectTokenResolver;
27
39
  webhookVerifier: ConnectWebhookVerifier;
28
40
  }
41
+ /**
42
+ * Partial Notion adapter config backed by Vercel Connect.
43
+ *
44
+ * Structurally matches the `token` option of `createNotionAdapter` from
45
+ * `@chat-adapter/notion`. Notion webhooks continue to use native HMAC
46
+ * verification and are not part of this config fragment.
47
+ */
48
+ export interface ConnectNotionAdapterConfig {
49
+ token: ConnectTokenResolver;
50
+ }
51
+ /**
52
+ * Partial Telegram adapter config backed by Vercel Connect.
53
+ *
54
+ * Structurally matches the `botToken` option of `createTelegramAdapter` from
55
+ * `@chat-adapter/telegram`. Telegram webhooks continue to use native secret
56
+ * token verification and are not part of this config fragment.
57
+ */
58
+ export interface ConnectTelegramAdapterConfig {
59
+ botToken: ConnectTokenResolver;
60
+ }
@@ -4,8 +4,8 @@ import { verifyVercelOidcToken } from '@vercel/oidc';
4
4
  * truthy value marks the request as verified; throwing (or returning a
5
5
  * falsy value) makes the adapter respond `401`.
6
6
  *
7
- * Mirrors the `webhookVerifier` option accepted by the Slack, GitHub,
8
- * and Linear adapters from the `chat` package, so the helpers in this
7
+ * Mirrors the `webhookVerifier` option accepted by the Slack, Discord,
8
+ * GitHub, and Linear adapters from the `chat` package, so the helpers in this
9
9
  * subpath stay decoupled from `@chat-adapter/*` while remaining
10
10
  * structurally compatible.
11
11
  */
@@ -25,8 +25,8 @@ export type ConnectWebhookVerifierOptions = Parameters<typeof verifyVercelOidcTo
25
25
  * the `Authorization` header. This verifier extracts that token and
26
26
  * validates it against Vercel's JWKS via
27
27
  * {@link verifyVercelOidcToken}, replacing the provider's native
28
- * signature check (Slack signing secret, GitHub webhook secret, Linear
29
- * webhook secret).
28
+ * signature check (Slack signing secret, Discord public key, GitHub webhook
29
+ * secret, Linear webhook secret).
30
30
  *
31
31
  * Trust boundary: by default the token must be issued by
32
32
  * `https://oidc.vercel.com` (issuer is hard-pinned) and match the
@@ -9,8 +9,8 @@ const BEARER_TOKEN_PATTERN = /^Bearer\s+(.+)$/i;
9
9
  * the `Authorization` header. This verifier extracts that token and
10
10
  * validates it against Vercel's JWKS via
11
11
  * {@link verifyVercelOidcToken}, replacing the provider's native
12
- * signature check (Slack signing secret, GitHub webhook secret, Linear
13
- * webhook secret).
12
+ * signature check (Slack signing secret, Discord public key, GitHub webhook
13
+ * secret, Linear webhook secret).
14
14
  *
15
15
  * Trust boundary: by default the token must be issued by
16
16
  * `https://oidc.vercel.com` (issuer is hard-pinned) and match the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/connect",
3
- "version": "0.6.2",
3
+ "version": "0.8.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.3"
45
+ "@vercel/oidc": "3.8.4"
46
46
  },
47
47
  "peerDependencies": {
48
48
  "@ai-sdk/mcp": "^1 || ^2",