@vercel/connect 2.7.0 → 2.8.0-snapshot-c80a43d75dc7

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
@@ -2,9 +2,10 @@
2
2
 
3
3
  SDK for obtaining scoped tokens for third-party services on behalf of apps or users. Authenticates the calling Vercel project via [`@vercel/oidc`](https://www.npmjs.com/package/@vercel/oidc) and exchanges the OIDC token for a Vercel Connect-issued credential.
4
4
 
5
- Eight entrypoints, all ESM:
5
+ Entrypoints, all ESM:
6
6
 
7
7
  - `@vercel/connect` — core token / authorization SDK
8
+ - `@vercel/connect/aws` — AWS credentials and a lazy AWS SDK credentials provider (no AWS SDK runtime dependency)
8
9
  - `@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
10
  - `@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
11
  - `@vercel/connect/mcp` — canonical MCP-spec `OAuthClientProvider` for any MCP client (no SDK dependency; returns a self-contained `ConnectOAuthClientProvider` assignable to `@ai-sdk/mcp` and `@modelcontextprotocol/sdk`)
@@ -58,6 +59,42 @@ const { url } = await startAuthorization(
58
59
  );
59
60
  ```
60
61
 
62
+ ### AWS SDK
63
+
64
+ Use an AWS OIDC connector with any AWS SDK client that accepts a credentials
65
+ provider:
66
+
67
+ ```ts
68
+ import { S3Client } from '@aws-sdk/client-s3';
69
+ import { connectAwsCredentialsProvider } from '@vercel/connect/aws';
70
+
71
+ const s3 = new S3Client({
72
+ region: 'us-east-1',
73
+ credentials: connectAwsCredentialsProvider('aws/production', {
74
+ roleArn: 'arn:aws:iam::123456789012:role/MyRole',
75
+ }),
76
+ });
77
+ ```
78
+
79
+ Both helpers accept `(connector, params?, options?)` and request app-scoped
80
+ credentials. The optional `params.roleArn` selects the IAM role; omit it to use
81
+ the connector's configured default role.
82
+
83
+ For a single credential lookup:
84
+
85
+ ```ts
86
+ import { getAwsCredentials } from '@vercel/connect/aws';
87
+
88
+ const credentials = await getAwsCredentials('aws/production');
89
+ ```
90
+
91
+ `getAwsCredentials` parses the JSON returned by `getToken`. The provider also
92
+ includes the token response's expiration as a `Date`, so long-lived AWS SDK
93
+ clients can refresh credentials. Both use Connect's token cache and accept the
94
+ standard options, including `vercelToken`, `region`, and `forceRefresh`. The
95
+ Connect `region` option controls API routing; configure the AWS region on the
96
+ AWS client separately.
97
+
61
98
  ### Chat SDK
62
99
 
63
100
  Spread the helper into the matching `create*Adapter` factory. Each helper
@@ -0,0 +1,32 @@
1
+ import { type ConnectOptions } from '../token.js';
2
+ /** AWS SDK-compatible credentials, without a dependency on AWS SDK types. */
3
+ export interface ConnectAwsCredentials {
4
+ accessKeyId: string;
5
+ secretAccessKey: string;
6
+ sessionToken: string;
7
+ /** Provided by {@link connectAwsCredentialsProvider} for SDK refreshes. */
8
+ expiration?: Date;
9
+ }
10
+ export interface ConnectAwsCredentialsParams {
11
+ /** IAM role ARN to assume. Defaults to the connector's configured role. */
12
+ roleArn?: string;
13
+ }
14
+ /**
15
+ * Get AWS credentials from a Vercel Connect AWS OIDC connector.
16
+ *
17
+ * Parses the JSON returned by {@link getToken} into AWS SDK credential fields.
18
+ * Requests an app-scoped token and uses Connect's token cache.
19
+ *
20
+ * For long-lived AWS SDK clients, use {@link connectAwsCredentialsProvider} so
21
+ * the SDK receives credential expiration and can refresh automatically.
22
+ */
23
+ export declare function getAwsCredentials(connector: string, params?: ConnectAwsCredentialsParams, options?: ConnectOptions): Promise<ConnectAwsCredentials>;
24
+ /**
25
+ * Create a lazy AWS SDK credentials provider backed by Vercel Connect.
26
+ *
27
+ * Accepts the same arguments as {@link getAwsCredentials}. The provider includes
28
+ * the token response's expiration as a `Date`, allowing AWS SDK clients to
29
+ * refresh temporary credentials. This is a conservative refresh deadline and
30
+ * may be earlier than the AWS credentials' actual expiration.
31
+ */
32
+ export declare function connectAwsCredentialsProvider(connector: string, params?: ConnectAwsCredentialsParams, options?: ConnectOptions): () => Promise<ConnectAwsCredentials>;
@@ -0,0 +1,37 @@
1
+ import { getToken, getTokenResponse, } from '../token.js';
2
+ /**
3
+ * Get AWS credentials from a Vercel Connect AWS OIDC connector.
4
+ *
5
+ * Parses the JSON returned by {@link getToken} into AWS SDK credential fields.
6
+ * Requests an app-scoped token and uses Connect's token cache.
7
+ *
8
+ * For long-lived AWS SDK clients, use {@link connectAwsCredentialsProvider} so
9
+ * the SDK receives credential expiration and can refresh automatically.
10
+ */
11
+ export async function getAwsCredentials(connector, params, options) {
12
+ const token = await getToken(connector, tokenParams(params), options);
13
+ return JSON.parse(token);
14
+ }
15
+ /**
16
+ * Create a lazy AWS SDK credentials provider backed by Vercel Connect.
17
+ *
18
+ * Accepts the same arguments as {@link getAwsCredentials}. The provider includes
19
+ * the token response's expiration as a `Date`, allowing AWS SDK clients to
20
+ * refresh temporary credentials. This is a conservative refresh deadline and
21
+ * may be earlier than the AWS credentials' actual expiration.
22
+ */
23
+ export function connectAwsCredentialsProvider(connector, params, options) {
24
+ return (async () => {
25
+ const { token, expiresAt } = await getTokenResponse(connector, tokenParams(params), options);
26
+ return {
27
+ ...JSON.parse(token),
28
+ expiration: new Date(expiresAt),
29
+ };
30
+ });
31
+ }
32
+ function tokenParams({ roleArn, } = {}) {
33
+ return {
34
+ subject: { type: 'app' },
35
+ ...(roleArn === undefined ? {} : { scopes: [roleArn] }),
36
+ };
37
+ }
@@ -0,0 +1 @@
1
+ export { connectAwsCredentialsProvider, getAwsCredentials, type ConnectAwsCredentials, type ConnectAwsCredentialsParams, } from './credentials.js';
@@ -0,0 +1 @@
1
+ export { connectAwsCredentialsProvider, getAwsCredentials, } from './credentials.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/connect",
3
- "version": "2.7.0",
3
+ "version": "2.8.0-snapshot-c80a43d75dc7",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "repository": {
@@ -13,6 +13,10 @@
13
13
  "types": "./dist/index.d.ts",
14
14
  "default": "./dist/index.js"
15
15
  },
16
+ "./aws": {
17
+ "types": "./dist/aws/index.d.ts",
18
+ "default": "./dist/aws/index.js"
19
+ },
16
20
  "./chat": {
17
21
  "types": "./dist/chat/index.d.ts",
18
22
  "default": "./dist/chat/index.js"
@@ -50,7 +54,7 @@
50
54
  "dist"
51
55
  ],
52
56
  "dependencies": {
53
- "@vercel/oidc": "4.0.5"
57
+ "@vercel/oidc": "4.0.6-snapshot-c80a43d75dc7"
54
58
  },
55
59
  "peerDependencies": {
56
60
  "@ai-sdk/mcp": "^1 || ^2",
@@ -89,6 +93,7 @@
89
93
  "@auth/core": "0.41.3",
90
94
  "@chat-adapter/slack": "4.31.0",
91
95
  "@modelcontextprotocol/sdk": "1.29.0",
96
+ "@smithy/types": "3.3.0",
92
97
  "@tanstack/ai-mcp": "0.3.10",
93
98
  "ai": "7.0.26",
94
99
  "better-auth": "1.5.5",