@vercel/connect 2.0.0 → 2.0.2

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
@@ -30,19 +30,15 @@ const token = await getToken(process.env.CONNECTOR_LINEAR!, {
30
30
  });
31
31
  ```
32
32
 
33
- To create an operator installation request for an app-scoped connector, use the
34
- experimental install helper:
35
-
36
- This feature is gated while experimental. Contact Vercel to enable access
37
- before using it.
33
+ To start an authorization request for a user, use `startAuthorization`:
38
34
 
39
35
  ```ts
40
- import { experimental_startInstallation } from '@vercel/connect';
36
+ import { startAuthorization } from '@vercel/connect';
41
37
 
42
- const { url } = await experimental_startInstallation(
43
- process.env.CONNECTOR_SLACK!,
44
- {},
45
- { returnUrl: 'https://example.com/settings/integrations' }
38
+ const { url } = await startAuthorization(
39
+ process.env.CONNECTOR_LINEAR!,
40
+ { subject: { type: 'user', id: 'user_123' } },
41
+ { callbackUrl: 'https://example.com/settings/integrations' }
46
42
  );
47
43
  ```
48
44
 
@@ -20,5 +20,9 @@ export type ConnectGitHubCredentialsParams = Omit<ConnectTokenParams, 'subject'>
20
20
  *
21
21
  * The webhook verifier accepts Connect-forwarded webhooks authenticated
22
22
  * with Vercel OIDC instead of GitHub's webhook secret.
23
+ *
24
+ * `appSlug` resolves the GitHub App slug from the connector's metadata,
25
+ * so `githubChannel` can derive its invocation token (`botName`) without
26
+ * extra configuration when `botName` is not set.
23
27
  */
24
28
  export declare function connectGitHubCredentials(connector: string, params?: ConnectGitHubCredentialsParams, options?: ConnectOptions): GitHubChannelCredentials;
@@ -1,5 +1,5 @@
1
1
  import { vercelOidc } from 'eve/channels/auth';
2
- import { getToken, } from '../index.js';
2
+ import { getConnectorMetadata, getToken, } from '../index.js';
3
3
  /**
4
4
  * Build {@link GitHubChannelCredentials} backed by a Vercel Connect
5
5
  * connector that stores a GitHub installation access token.
@@ -11,10 +11,23 @@ import { getToken, } from '../index.js';
11
11
  *
12
12
  * The webhook verifier accepts Connect-forwarded webhooks authenticated
13
13
  * with Vercel OIDC instead of GitHub's webhook secret.
14
+ *
15
+ * `appSlug` resolves the GitHub App slug from the connector's metadata,
16
+ * so `githubChannel` can derive its invocation token (`botName`) without
17
+ * extra configuration when `botName` is not set.
14
18
  */
15
19
  export function connectGitHubCredentials(connector, params = {}, options) {
16
20
  return {
21
+ appSlug: () => getGitHubAppSlug(connector, options),
17
22
  installationToken: () => getToken(connector, { ...params, subject: { type: 'app' } }, options),
18
23
  webhookVerifier: vercelOidc(),
19
24
  };
20
25
  }
26
+ async function getGitHubAppSlug(connector, options) {
27
+ const metadata = await getConnectorMetadata(connector, options);
28
+ const appSlug = metadata.vendor.appSlug;
29
+ if (typeof appSlug !== 'string' || appSlug.length === 0) {
30
+ throw new Error(`Vercel Connect connector ${connector} did not return a GitHub App slug.`);
31
+ }
32
+ return appSlug;
33
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/connect",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "repository": {
@@ -78,7 +78,7 @@
78
78
  "@chat-adapter/slack": "4.31.0",
79
79
  "ai": "7.0.26",
80
80
  "better-auth": "1.5.5",
81
- "eve": "0.24.3",
81
+ "eve": "0.39.1",
82
82
  "typescript": "^5"
83
83
  },
84
84
  "private": false,