@vercel/connect 2.0.0 → 2.0.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.
|
@@ -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.
|
|
3
|
+
"version": "2.0.1",
|
|
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.
|
|
81
|
+
"eve": "0.39.1",
|
|
82
82
|
"typescript": "^5"
|
|
83
83
|
},
|
|
84
84
|
"private": false,
|