@vercel/connect 0.2.0 → 0.2.1

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
@@ -97,4 +97,4 @@ import { connect } from '@vercel/connect/authjs';
97
97
  const providers = [connect({ connector: 'linear' })];
98
98
  ```
99
99
 
100
- See the source under `src/` for the full API (additional helpers like `getTokenResponse`, `startAuthorization`, typed error classes, and per-adapter options).
100
+ See the source under `src/` for the full API (additional helpers like `revokeToken`, `getTokenResponse`, `startAuthorization`, typed error classes, and per-adapter options).
@@ -0,0 +1,24 @@
1
+ import type { GitHubChannelCredentials } from 'eve/channels/github';
2
+ import { type ConnectOptions, type ConnectTokenParams } from '../index.js';
3
+ /**
4
+ * Token parameters accepted by {@link connectGitHubCredentials}.
5
+ *
6
+ * Mirrors {@link ConnectTokenParams} from `@vercel/connect`, minus
7
+ * `subject` — GitHub installation tokens are app-scoped, so `subject`
8
+ * is pinned to `{ type: "app" }` by this helper and cannot be
9
+ * overridden.
10
+ */
11
+ export type ConnectGitHubCredentialsParams = Omit<ConnectTokenParams, 'subject'>;
12
+ /**
13
+ * Build {@link GitHubChannelCredentials} backed by a Vercel Connect
14
+ * connector that stores a GitHub installation access token.
15
+ *
16
+ * Eve uses `installationToken` directly for authenticated GitHub API
17
+ * calls and skips its native GitHub App JWT exchange. The token is a
18
+ * function form so rotation, refresh, and multi-installation tenancy
19
+ * stay delegated to Vercel Connect.
20
+ *
21
+ * The webhook verifier accepts Connect-forwarded webhooks authenticated
22
+ * with Vercel OIDC instead of GitHub's webhook secret.
23
+ */
24
+ export declare function connectGitHubCredentials(connector: string, params?: ConnectGitHubCredentialsParams, options?: ConnectOptions): GitHubChannelCredentials;
@@ -0,0 +1,20 @@
1
+ import { vercelOidc } from 'eve/channels/auth';
2
+ import { getToken, } from '../index.js';
3
+ /**
4
+ * Build {@link GitHubChannelCredentials} backed by a Vercel Connect
5
+ * connector that stores a GitHub installation access token.
6
+ *
7
+ * Eve uses `installationToken` directly for authenticated GitHub API
8
+ * calls and skips its native GitHub App JWT exchange. The token is a
9
+ * function form so rotation, refresh, and multi-installation tenancy
10
+ * stay delegated to Vercel Connect.
11
+ *
12
+ * The webhook verifier accepts Connect-forwarded webhooks authenticated
13
+ * with Vercel OIDC instead of GitHub's webhook secret.
14
+ */
15
+ export function connectGitHubCredentials(connector, params = {}, options) {
16
+ return {
17
+ installationToken: () => getToken(connector, { ...params, subject: { type: 'app' } }, options),
18
+ webhookVerifier: vercelOidc(),
19
+ };
20
+ }
@@ -8,4 +8,6 @@
8
8
  */
9
9
  export { connect, type EveAuthorizationInput, type EveAuthorizationOptions, type EveConnectAuthorizationDefinition, type ConnectAuthorizationPhase, type VercelConnectMetadata, } from './connection-authorization.js';
10
10
  export { CONNECT_OAUTH_ISSUER, connectOAuth, type ConnectOAuthAudienceEnvironment, type ConnectOAuthEnvironment, type ConnectOAuthOptions, } from './connect-oauth.js';
11
- export { connectSlackCredentials } from './slack-credentials.js';
11
+ export { connectGitHubCredentials, type ConnectGitHubCredentialsParams, } from './github-credentials.js';
12
+ export { connectLinearCredentials, type ConnectLinearCredentialsParams, } from './linear-credentials.js';
13
+ export { connectSlackCredentials, type ConnectSlackCredentialsParams, } from './slack-credentials.js';
package/dist/eve/index.js CHANGED
@@ -8,4 +8,6 @@
8
8
  */
9
9
  export { connect, } from './connection-authorization.js';
10
10
  export { CONNECT_OAUTH_ISSUER, connectOAuth, } from './connect-oauth.js';
11
- export { connectSlackCredentials } from './slack-credentials.js';
11
+ export { connectGitHubCredentials, } from './github-credentials.js';
12
+ export { connectLinearCredentials, } from './linear-credentials.js';
13
+ export { connectSlackCredentials, } from './slack-credentials.js';
@@ -0,0 +1,22 @@
1
+ import type { LinearChannelCredentials } from 'eve/channels/linear';
2
+ import { type ConnectOptions, type ConnectTokenParams } from '../index.js';
3
+ /**
4
+ * Token parameters accepted by {@link connectLinearCredentials}.
5
+ *
6
+ * Mirrors {@link ConnectTokenParams} from `@vercel/connect`, minus
7
+ * `subject` — Linear Agent tokens are app-scoped, so `subject` is
8
+ * pinned to `{ type: "app" }` by this helper and cannot be overridden.
9
+ */
10
+ export type ConnectLinearCredentialsParams = Omit<ConnectTokenParams, 'subject'>;
11
+ /**
12
+ * Build {@link LinearChannelCredentials} backed by a Vercel Connect
13
+ * connector that stores a Linear app access token.
14
+ *
15
+ * Eve uses `accessToken` for Linear GraphQL calls. The token is a
16
+ * function form so rotation, refresh, and multi-workspace tenancy stay
17
+ * delegated to Vercel Connect.
18
+ *
19
+ * The webhook verifier accepts Connect-forwarded webhooks authenticated
20
+ * with Vercel OIDC instead of Linear's webhook secret.
21
+ */
22
+ export declare function connectLinearCredentials(connector: string, params?: ConnectLinearCredentialsParams, options?: ConnectOptions): LinearChannelCredentials;
@@ -0,0 +1,19 @@
1
+ import { vercelOidc } from 'eve/channels/auth';
2
+ import { getToken, } from '../index.js';
3
+ /**
4
+ * Build {@link LinearChannelCredentials} backed by a Vercel Connect
5
+ * connector that stores a Linear app access token.
6
+ *
7
+ * Eve uses `accessToken` for Linear GraphQL calls. The token is a
8
+ * function form so rotation, refresh, and multi-workspace tenancy stay
9
+ * delegated to Vercel Connect.
10
+ *
11
+ * The webhook verifier accepts Connect-forwarded webhooks authenticated
12
+ * with Vercel OIDC instead of Linear's webhook secret.
13
+ */
14
+ export function connectLinearCredentials(connector, params = {}, options) {
15
+ return {
16
+ accessToken: () => getToken(connector, { ...params, subject: { type: 'app' } }, options),
17
+ webhookVerifier: vercelOidc(),
18
+ };
19
+ }
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { getToken, getTokenResponse, ConnectError, NoValidTokenError, UserAuthorizationRequiredError, ConnectorInstallationRequiredError, type ConnectErrorOptions, type ConnectOptions, type ConnectTokenParams, type ConnectTokenResponse, type ConnectTokenSubject, type ConnectVendorErrorPayload, } from './token.js';
1
+ export { getToken, getTokenResponse, revokeToken, ConnectError, NoValidTokenError, UserAuthorizationRequiredError, ConnectorInstallationRequiredError, type ConnectErrorOptions, type ConnectOptions, type ConnectTokenParams, type ConnectTokenResponse, type ConnectTokenSubject, type ConnectVendorErrorPayload, } from './token.js';
2
2
  export { startAuthorization, type ConnectAuthorizationOptions, type ConnectAuthorizationResponse, } from './authorization.js';
3
3
  export type { ConnectAuthorizationDetail } from './authorization-details.js';
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export { getToken, getTokenResponse, ConnectError, NoValidTokenError, UserAuthorizationRequiredError, ConnectorInstallationRequiredError, } from './token.js';
1
+ export { getToken, getTokenResponse, revokeToken, ConnectError, NoValidTokenError, UserAuthorizationRequiredError, ConnectorInstallationRequiredError, } from './token.js';
2
2
  export { startAuthorization, } from './authorization.js';
package/dist/token.d.ts CHANGED
@@ -22,6 +22,10 @@ export interface ConnectTokenParams {
22
22
  subject: ConnectTokenSubject;
23
23
  installationId?: string;
24
24
  audience?: string[];
25
+ /**
26
+ * Access scopes to request. Use `['*']` to request the default scopes for
27
+ * the specified subject type.
28
+ */
25
29
  scopes?: string[];
26
30
  resources?: string[];
27
31
  authorizationDetails?: ConnectAuthorizationDetail[];
@@ -79,4 +83,8 @@ export interface ConnectOptions {
79
83
  }
80
84
  export declare function getToken(connector: string, params: ConnectTokenParams, options?: ConnectOptions): Promise<string>;
81
85
  export declare function getTokenResponse(connector: string, params: ConnectTokenParams, options?: ConnectOptions): Promise<ConnectTokenResponse>;
86
+ export declare function revokeToken(connector: string, params: {
87
+ subject: ConnectTokenSubject;
88
+ installationId?: string;
89
+ }, options?: ConnectOptions): Promise<void>;
82
90
  export declare function createConnectErrorFromResponse(response: Response, fallbackMessage: string): Promise<ConnectError>;
package/dist/token.js CHANGED
@@ -68,6 +68,23 @@ export async function getTokenResponse(connector, params, options) {
68
68
  cache.set(cacheKey, { response: data, lastUsed: Date.now() });
69
69
  return data;
70
70
  }
71
+ export async function revokeToken(connector, params, options) {
72
+ const vercelToken = options?.vercelToken ?? (await getVercelOidcToken());
73
+ const endpoint = `https://api.vercel.com/v1/connect/connectors/${encodeURIComponent(connector)}/tokens`;
74
+ const response = await fetch(endpoint, {
75
+ method: 'DELETE',
76
+ headers: {
77
+ Accept: 'application/json',
78
+ 'Content-Type': 'application/json',
79
+ Authorization: `Bearer ${vercelToken}`,
80
+ },
81
+ body: JSON.stringify(params),
82
+ });
83
+ if (!response.ok) {
84
+ throw await createConnectErrorFromResponse(response, 'Failed to revoke token');
85
+ }
86
+ cache.clear();
87
+ }
71
88
  const DEFAULT_VALIDITY_BUFFER_MS = 30_000;
72
89
  const MAX_CACHE_SIZE = 100;
73
90
  const cache = new Map();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/connect",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "repository": {
@@ -45,7 +45,7 @@
45
45
  "@auth/core": ">=0.37.0",
46
46
  "ai": "^6 || ^7",
47
47
  "better-auth": ">=1.5.0",
48
- "eve": ">=0.8.2"
48
+ "eve": ">=0.6.0-beta.1"
49
49
  },
50
50
  "peerDependenciesMeta": {
51
51
  "@ai-sdk/mcp": {
@@ -69,7 +69,7 @@
69
69
  "@auth/core": "0.37.4",
70
70
  "ai": "7.0.0-beta.116",
71
71
  "better-auth": "1.5.5",
72
- "eve": "file:./fixtures/eve",
72
+ "eve": "0.6.0-beta.1",
73
73
  "typescript": "^5"
74
74
  },
75
75
  "private": false,