@vercel/integrations 0.0.0 → 0.1.0-snapshot-c4002eb2617b
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/CHANGELOG.md +7 -0
- package/LICENSE +202 -0
- package/README.md +95 -0
- package/dist/errors.d.ts +20 -0
- package/dist/errors.js +41 -0
- package/dist/get-integration-token.d.ts +43 -0
- package/dist/get-integration-token.js +103 -0
- package/dist/get-integration-token.test.d.ts +1 -0
- package/dist/get-integration-token.test.js +266 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +31 -0
- package/dist/request.d.ts +13 -0
- package/dist/request.js +89 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +28 -0
- package/docs/README.md +17 -0
- package/docs/classes/IntegrationTokenError.md +168 -0
- package/docs/functions/getIntegrationToken.md +45 -0
- package/docs/interfaces/GetIntegrationTokenOptions.md +34 -0
- package/package.json +53 -1
package/CHANGELOG.md
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2017 Vercel, Inc.
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# `@vercel/integrations`
|
|
2
|
+
|
|
3
|
+
Runtime helpers for [Vercel Marketplace](https://vercel.com/marketplace)
|
|
4
|
+
integrations, intended to be used with your Vercel Functions.
|
|
5
|
+
|
|
6
|
+
`getIntegrationToken` mints a short-lived token for an integration resource
|
|
7
|
+
connected to your project, so your code can authenticate to the provider
|
|
8
|
+
without a long-lived secret in an environment variable. It authenticates using
|
|
9
|
+
the deployment's [Vercel OIDC token](https://vercel.com/docs/oidc) (fetched
|
|
10
|
+
automatically via [`@vercel/oidc`](https://www.npmjs.com/package/@vercel/oidc)).
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
### Minting a token
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
import { getIntegrationToken } from '@vercel/integrations';
|
|
18
|
+
|
|
19
|
+
const token = await getIntegrationToken('neon');
|
|
20
|
+
|
|
21
|
+
// Request one of the roles the resource defines.
|
|
22
|
+
const readonly = await getIntegrationToken('neon', { role: 'readonly' });
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
The first argument identifies the resource, e.g. an integration slug (`neon`),
|
|
26
|
+
a slug and environment variable prefix (`neon/sales`), or a Vercel resource ID.
|
|
27
|
+
|
|
28
|
+
### As a database password
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
import { Pool } from 'pg';
|
|
32
|
+
import { getIntegrationToken } from '@vercel/integrations';
|
|
33
|
+
|
|
34
|
+
const pool = new Pool({
|
|
35
|
+
host: process.env.PGHOST,
|
|
36
|
+
user: process.env.PGUSER,
|
|
37
|
+
database: process.env.PGDATABASE,
|
|
38
|
+
password: () => getIntegrationToken('neon/sales'),
|
|
39
|
+
ssl: { rejectUnauthorized: true },
|
|
40
|
+
});
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Caching
|
|
44
|
+
|
|
45
|
+
Tokens are cached in memory. Within two minutes of expiry, a call returns the
|
|
46
|
+
cached token and refreshes it in the background; within one minute, it waits
|
|
47
|
+
for a new token. Concurrent calls for the same resource and role share a single
|
|
48
|
+
request.
|
|
49
|
+
|
|
50
|
+
### Providing a Vercel token explicitly
|
|
51
|
+
|
|
52
|
+
By default the deployment's OIDC token is fetched via `getVercelOidcToken()`.
|
|
53
|
+
To authenticate with another Vercel token, pass `vercelToken`, and `teamId` for
|
|
54
|
+
the team that owns the resource.
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
const token = await getIntegrationToken('store_abc123', {
|
|
58
|
+
vercelToken: myVercelToken,
|
|
59
|
+
teamId: 'team_abc123',
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Errors
|
|
64
|
+
|
|
65
|
+
Failures throw an `IntegrationTokenError` with the API's `status`, `code` and
|
|
66
|
+
`message`. Codes include:
|
|
67
|
+
|
|
68
|
+
- `not_found`: no matching resource is connected to the project for this
|
|
69
|
+
deployment's environment
|
|
70
|
+
- `invalid_resource`: `resource` is empty or isn't a valid slug, `slug/prefix`
|
|
71
|
+
or resource id (thrown before any request when `resource` is empty, so
|
|
72
|
+
`status` is absent)
|
|
73
|
+
- `ambiguous_resource`: more than one resource matches the slug and prefix
|
|
74
|
+
- `invalid_role`: the resource doesn't define the requested role
|
|
75
|
+
- `forbidden`: the token isn't a Vercel deployment OIDC token, or isn't allowed
|
|
76
|
+
to read the project's integration resources
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
import {
|
|
80
|
+
getIntegrationToken,
|
|
81
|
+
IntegrationTokenError,
|
|
82
|
+
} from '@vercel/integrations';
|
|
83
|
+
|
|
84
|
+
try {
|
|
85
|
+
await getIntegrationToken('store_abc123', { role: 'admin' });
|
|
86
|
+
} catch (error) {
|
|
87
|
+
if (error instanceof IntegrationTokenError && error.code === 'invalid_role') {
|
|
88
|
+
// ...
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## API
|
|
94
|
+
|
|
95
|
+
See the [generated API docs](./docs/README.md).
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error thrown when an integration token can't be obtained. For API failures it
|
|
3
|
+
* mirrors the error envelope `{ error: { code, message, ...meta } }`: `code` and
|
|
4
|
+
* `message` come from the response body when present, and any remaining fields
|
|
5
|
+
* are exposed on {@link IntegrationTokenError.metadata}.
|
|
6
|
+
*/
|
|
7
|
+
export declare class IntegrationTokenError extends Error {
|
|
8
|
+
/** HTTP status code of the failed response. Absent when no request was made. */
|
|
9
|
+
readonly status?: number;
|
|
10
|
+
/** Machine-readable error code (e.g. `not_found`, `invalid_role`). */
|
|
11
|
+
readonly code: string;
|
|
12
|
+
/** Any additional fields the API attached to the error envelope. */
|
|
13
|
+
readonly metadata: Record<string, unknown>;
|
|
14
|
+
constructor({ status, code, message, metadata, }: {
|
|
15
|
+
status?: number;
|
|
16
|
+
code: string;
|
|
17
|
+
message: string;
|
|
18
|
+
metadata?: Record<string, unknown>;
|
|
19
|
+
});
|
|
20
|
+
}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var errors_exports = {};
|
|
20
|
+
__export(errors_exports, {
|
|
21
|
+
IntegrationTokenError: () => IntegrationTokenError
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(errors_exports);
|
|
24
|
+
class IntegrationTokenError extends Error {
|
|
25
|
+
constructor({
|
|
26
|
+
status,
|
|
27
|
+
code,
|
|
28
|
+
message,
|
|
29
|
+
metadata = {}
|
|
30
|
+
}) {
|
|
31
|
+
super(message);
|
|
32
|
+
this.name = "IntegrationTokenError";
|
|
33
|
+
this.status = status;
|
|
34
|
+
this.code = code;
|
|
35
|
+
this.metadata = metadata;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
+
0 && (module.exports = {
|
|
40
|
+
IntegrationTokenError
|
|
41
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options for {@link getIntegrationToken}.
|
|
3
|
+
*/
|
|
4
|
+
export interface GetIntegrationTokenOptions {
|
|
5
|
+
/**
|
|
6
|
+
* One of the roles the resource defines. Defaults to the resource's default
|
|
7
|
+
* role. Requesting a role the resource doesn't define fails with
|
|
8
|
+
* `invalid_role`.
|
|
9
|
+
*/
|
|
10
|
+
role?: string;
|
|
11
|
+
/**
|
|
12
|
+
* The Vercel team that owns the resource.
|
|
13
|
+
*/
|
|
14
|
+
teamId?: string;
|
|
15
|
+
/**
|
|
16
|
+
* A Vercel token to authenticate with. When omitted, the deployment's OIDC
|
|
17
|
+
* token is fetched automatically via `@vercel/oidc`.
|
|
18
|
+
*/
|
|
19
|
+
vercelToken?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Returns a short-lived token for a Vercel Marketplace integration resource
|
|
23
|
+
* connected to the calling deployment's project and environment. Pass it to the
|
|
24
|
+
* provider wherever it would otherwise expect a long-lived secret, e.g. as a
|
|
25
|
+
* database password.
|
|
26
|
+
*
|
|
27
|
+
* `resource` identifies the resource, e.g. an integration slug (`neon`), a slug
|
|
28
|
+
* and environment variable prefix (`neon/sales`), or a Vercel resource ID. The
|
|
29
|
+
* API resolves it.
|
|
30
|
+
*
|
|
31
|
+
* Tokens are cached in memory and reused until shortly before they expire.
|
|
32
|
+
* Concurrent calls for the same resource and role share one request.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* const token = await getIntegrationToken('neon');
|
|
37
|
+
* const token = await getIntegrationToken('neon/sales', { role: 'readonly' });
|
|
38
|
+
* const token = await getIntegrationToken('store_abc123');
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* @throws {import('./errors').IntegrationTokenError} If the token can't be minted.
|
|
42
|
+
*/
|
|
43
|
+
export declare function getIntegrationToken(resource: string, options?: GetIntegrationTokenOptions): Promise<string>;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var get_integration_token_exports = {};
|
|
20
|
+
__export(get_integration_token_exports, {
|
|
21
|
+
getIntegrationToken: () => getIntegrationToken
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(get_integration_token_exports);
|
|
24
|
+
var import_oidc = require("@vercel/oidc");
|
|
25
|
+
var import_errors = require("./errors");
|
|
26
|
+
var import_request = require("./request");
|
|
27
|
+
const REFRESH_BEFORE_EXPIRY_MS = 6e4;
|
|
28
|
+
const BACKGROUND_REFRESH_BEFORE_EXPIRY_MS = 2 * REFRESH_BEFORE_EXPIRY_MS;
|
|
29
|
+
const cache = /* @__PURE__ */ new Map();
|
|
30
|
+
async function getIntegrationToken(resource, options = {}) {
|
|
31
|
+
const { role, teamId, vercelToken } = options;
|
|
32
|
+
if (!resource) {
|
|
33
|
+
throw new import_errors.IntegrationTokenError({
|
|
34
|
+
code: "invalid_resource",
|
|
35
|
+
message: "`resource` is required."
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
const url = new URL(
|
|
39
|
+
`${import_request.API_BASE_URL}/integrations/marketplace/resources/${encodeURIComponent(resource)}/token`
|
|
40
|
+
);
|
|
41
|
+
if (role) {
|
|
42
|
+
url.searchParams.set("role", role);
|
|
43
|
+
}
|
|
44
|
+
if (teamId) {
|
|
45
|
+
url.searchParams.set("teamId", teamId);
|
|
46
|
+
}
|
|
47
|
+
const key = vercelToken ? `${url} ${vercelToken}` : url.toString();
|
|
48
|
+
const minted = await mintCached(
|
|
49
|
+
key,
|
|
50
|
+
async () => (0, import_request.postJson)({
|
|
51
|
+
url,
|
|
52
|
+
token: vercelToken ?? await (0, import_oidc.getVercelOidcToken)()
|
|
53
|
+
})
|
|
54
|
+
);
|
|
55
|
+
return minted.token;
|
|
56
|
+
}
|
|
57
|
+
function mintCached(key, mint) {
|
|
58
|
+
const cached = cache.get(key);
|
|
59
|
+
if (cached) {
|
|
60
|
+
if (cached.expiresAt === void 0) {
|
|
61
|
+
return cached.promise;
|
|
62
|
+
}
|
|
63
|
+
const remaining = cached.expiresAt - Date.now();
|
|
64
|
+
if (remaining > BACKGROUND_REFRESH_BEFORE_EXPIRY_MS) {
|
|
65
|
+
return cached.promise;
|
|
66
|
+
}
|
|
67
|
+
if (remaining > REFRESH_BEFORE_EXPIRY_MS) {
|
|
68
|
+
if (!cached.refreshing) {
|
|
69
|
+
cached.refreshing = true;
|
|
70
|
+
startMint(key, mint, cached);
|
|
71
|
+
}
|
|
72
|
+
return cached.promise;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return startMint(key, mint);
|
|
76
|
+
}
|
|
77
|
+
function startMint(key, mint, previous) {
|
|
78
|
+
const requestedAt = Date.now();
|
|
79
|
+
const entry = { promise: mint() };
|
|
80
|
+
if (!previous) {
|
|
81
|
+
cache.set(key, entry);
|
|
82
|
+
}
|
|
83
|
+
entry.promise.then(
|
|
84
|
+
(minted) => {
|
|
85
|
+
entry.expiresAt = requestedAt + minted.expiresIn * 1e3;
|
|
86
|
+
if (previous && cache.get(key) === previous) {
|
|
87
|
+
cache.set(key, entry);
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
() => {
|
|
91
|
+
if (previous) {
|
|
92
|
+
previous.refreshing = false;
|
|
93
|
+
} else if (cache.get(key) === entry) {
|
|
94
|
+
cache.delete(key);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
);
|
|
98
|
+
return entry.promise;
|
|
99
|
+
}
|
|
100
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
101
|
+
0 && (module.exports = {
|
|
102
|
+
getIntegrationToken
|
|
103
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var import_vitest = require("vitest");
|
|
3
|
+
var import_oidc = require("@vercel/oidc");
|
|
4
|
+
var import_get_integration_token = require("./get-integration-token");
|
|
5
|
+
var import_errors = require("./errors");
|
|
6
|
+
import_vitest.vi.mock("@vercel/oidc", () => ({
|
|
7
|
+
getVercelOidcToken: import_vitest.vi.fn()
|
|
8
|
+
}));
|
|
9
|
+
const getVercelOidcTokenMock = import_vitest.vi.mocked(import_oidc.getVercelOidcToken);
|
|
10
|
+
const OIDC_TOKEN = "oidc-token";
|
|
11
|
+
function minted(token, expiresIn = 900) {
|
|
12
|
+
return {
|
|
13
|
+
token,
|
|
14
|
+
tokenType: "bearer",
|
|
15
|
+
expiresIn,
|
|
16
|
+
expiresAt: Date.now() + expiresIn * 1e3
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function fetchReturning(body, init) {
|
|
20
|
+
return async () => new Response(typeof body === "string" ? body : JSON.stringify(body), {
|
|
21
|
+
status: 200,
|
|
22
|
+
...init
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
let resourceCounter = 0;
|
|
26
|
+
function nextResourceId() {
|
|
27
|
+
resourceCounter += 1;
|
|
28
|
+
return `store_${resourceCounter}`;
|
|
29
|
+
}
|
|
30
|
+
function settle() {
|
|
31
|
+
return new Promise((resolve) => setTimeout(resolve, 0));
|
|
32
|
+
}
|
|
33
|
+
(0, import_vitest.describe)("getIntegrationToken", () => {
|
|
34
|
+
(0, import_vitest.beforeEach)(() => {
|
|
35
|
+
import_vitest.vi.restoreAllMocks();
|
|
36
|
+
getVercelOidcTokenMock.mockReset();
|
|
37
|
+
getVercelOidcTokenMock.mockResolvedValue(OIDC_TOKEN);
|
|
38
|
+
});
|
|
39
|
+
(0, import_vitest.afterEach)(() => {
|
|
40
|
+
import_vitest.vi.useRealTimers();
|
|
41
|
+
});
|
|
42
|
+
(0, import_vitest.test)("mints a token for a resource with the deployment OIDC token", async () => {
|
|
43
|
+
const resourceId = nextResourceId();
|
|
44
|
+
const fetchMock = import_vitest.vi.spyOn(globalThis, "fetch").mockImplementation(fetchReturning(minted("resource-token")));
|
|
45
|
+
await (0, import_vitest.expect)((0, import_get_integration_token.getIntegrationToken)(resourceId)).resolves.toBe(
|
|
46
|
+
"resource-token"
|
|
47
|
+
);
|
|
48
|
+
(0, import_vitest.expect)(getVercelOidcTokenMock).toHaveBeenCalledWith();
|
|
49
|
+
(0, import_vitest.expect)(fetchMock).toHaveBeenCalledTimes(1);
|
|
50
|
+
const [url, init] = fetchMock.mock.calls[0];
|
|
51
|
+
(0, import_vitest.expect)(url.toString()).toBe(
|
|
52
|
+
`https://api.vercel.com/v1/integrations/marketplace/resources/${resourceId}/token`
|
|
53
|
+
);
|
|
54
|
+
(0, import_vitest.expect)(init?.method).toBe("POST");
|
|
55
|
+
(0, import_vitest.expect)((init?.headers).authorization).toBe(
|
|
56
|
+
`Bearer ${OIDC_TOKEN}`
|
|
57
|
+
);
|
|
58
|
+
});
|
|
59
|
+
(0, import_vitest.test)("passes the role as a query parameter", async () => {
|
|
60
|
+
const resourceId = nextResourceId();
|
|
61
|
+
const fetchMock = import_vitest.vi.spyOn(globalThis, "fetch").mockImplementation(fetchReturning(minted("readonly-token")));
|
|
62
|
+
await (0, import_get_integration_token.getIntegrationToken)(resourceId, { role: "readonly" });
|
|
63
|
+
const [url] = fetchMock.mock.calls[0];
|
|
64
|
+
(0, import_vitest.expect)(url.toString()).toBe(
|
|
65
|
+
`https://api.vercel.com/v1/integrations/marketplace/resources/${resourceId}/token?role=readonly`
|
|
66
|
+
);
|
|
67
|
+
});
|
|
68
|
+
(0, import_vitest.test)("uses and caches an explicit Vercel token without fetching an OIDC token", async () => {
|
|
69
|
+
const resourceId = nextResourceId();
|
|
70
|
+
const fetchMock = import_vitest.vi.spyOn(globalThis, "fetch").mockImplementation(fetchReturning(minted("resource-token")));
|
|
71
|
+
await (0, import_get_integration_token.getIntegrationToken)(resourceId, { vercelToken: "my-token" });
|
|
72
|
+
await (0, import_get_integration_token.getIntegrationToken)(resourceId, { vercelToken: "my-token" });
|
|
73
|
+
(0, import_vitest.expect)(getVercelOidcTokenMock).not.toHaveBeenCalled();
|
|
74
|
+
(0, import_vitest.expect)(fetchMock).toHaveBeenCalledTimes(1);
|
|
75
|
+
const [, init] = fetchMock.mock.calls[0];
|
|
76
|
+
(0, import_vitest.expect)((init?.headers).authorization).toBe(
|
|
77
|
+
"Bearer my-token"
|
|
78
|
+
);
|
|
79
|
+
});
|
|
80
|
+
(0, import_vitest.test)("caches tokens per Vercel token", async () => {
|
|
81
|
+
const resourceId = nextResourceId();
|
|
82
|
+
const fetchMock = import_vitest.vi.spyOn(globalThis, "fetch").mockImplementationOnce(fetchReturning(minted("token-a"))).mockImplementationOnce(fetchReturning(minted("token-b")));
|
|
83
|
+
await (0, import_vitest.expect)(
|
|
84
|
+
(0, import_get_integration_token.getIntegrationToken)(resourceId, { vercelToken: "a" })
|
|
85
|
+
).resolves.toBe("token-a");
|
|
86
|
+
await (0, import_vitest.expect)(
|
|
87
|
+
(0, import_get_integration_token.getIntegrationToken)(resourceId, { vercelToken: "b" })
|
|
88
|
+
).resolves.toBe("token-b");
|
|
89
|
+
(0, import_vitest.expect)(fetchMock).toHaveBeenCalledTimes(2);
|
|
90
|
+
});
|
|
91
|
+
(0, import_vitest.test)("passes the team id as a query parameter", async () => {
|
|
92
|
+
const resourceId = nextResourceId();
|
|
93
|
+
const fetchMock = import_vitest.vi.spyOn(globalThis, "fetch").mockImplementation(fetchReturning(minted("resource-token")));
|
|
94
|
+
await (0, import_get_integration_token.getIntegrationToken)(resourceId, { teamId: "team_123" });
|
|
95
|
+
const [url] = fetchMock.mock.calls[0];
|
|
96
|
+
(0, import_vitest.expect)(url.toString()).toBe(
|
|
97
|
+
`https://api.vercel.com/v1/integrations/marketplace/resources/${resourceId}/token?teamId=team_123`
|
|
98
|
+
);
|
|
99
|
+
});
|
|
100
|
+
(0, import_vitest.test)("reuses a cached token without refreshing it while it is fresh", async () => {
|
|
101
|
+
import_vitest.vi.useFakeTimers({ toFake: ["Date"] });
|
|
102
|
+
const resourceId = nextResourceId();
|
|
103
|
+
const fetchMock = import_vitest.vi.spyOn(globalThis, "fetch").mockImplementation(fetchReturning(minted("first", 300)));
|
|
104
|
+
await (0, import_vitest.expect)((0, import_get_integration_token.getIntegrationToken)(resourceId)).resolves.toBe("first");
|
|
105
|
+
import_vitest.vi.advanceTimersByTime(179e3);
|
|
106
|
+
await (0, import_vitest.expect)((0, import_get_integration_token.getIntegrationToken)(resourceId)).resolves.toBe("first");
|
|
107
|
+
(0, import_vitest.expect)(fetchMock).toHaveBeenCalledTimes(1);
|
|
108
|
+
});
|
|
109
|
+
(0, import_vitest.test)("refreshes in the background shortly before expiry", async () => {
|
|
110
|
+
import_vitest.vi.useFakeTimers({ toFake: ["Date"] });
|
|
111
|
+
const resourceId = nextResourceId();
|
|
112
|
+
const fetchMock = import_vitest.vi.spyOn(globalThis, "fetch").mockImplementationOnce(fetchReturning(minted("first", 300))).mockImplementationOnce(fetchReturning(minted("second", 300)));
|
|
113
|
+
await (0, import_vitest.expect)((0, import_get_integration_token.getIntegrationToken)(resourceId)).resolves.toBe("first");
|
|
114
|
+
import_vitest.vi.advanceTimersByTime(181e3);
|
|
115
|
+
await (0, import_vitest.expect)((0, import_get_integration_token.getIntegrationToken)(resourceId)).resolves.toBe("first");
|
|
116
|
+
await (0, import_vitest.expect)((0, import_get_integration_token.getIntegrationToken)(resourceId)).resolves.toBe("first");
|
|
117
|
+
(0, import_vitest.expect)(fetchMock).toHaveBeenCalledTimes(2);
|
|
118
|
+
await settle();
|
|
119
|
+
await (0, import_vitest.expect)((0, import_get_integration_token.getIntegrationToken)(resourceId)).resolves.toBe("second");
|
|
120
|
+
(0, import_vitest.expect)(fetchMock).toHaveBeenCalledTimes(2);
|
|
121
|
+
});
|
|
122
|
+
(0, import_vitest.test)("keeps serving the cached token when a background refresh fails", async () => {
|
|
123
|
+
import_vitest.vi.useFakeTimers({ toFake: ["Date"] });
|
|
124
|
+
const resourceId = nextResourceId();
|
|
125
|
+
const fetchMock = import_vitest.vi.spyOn(globalThis, "fetch").mockImplementationOnce(fetchReturning(minted("first", 300))).mockImplementationOnce(
|
|
126
|
+
fetchReturning("upstream timeout", { status: 502 })
|
|
127
|
+
).mockImplementationOnce(fetchReturning(minted("second", 300)));
|
|
128
|
+
await (0, import_get_integration_token.getIntegrationToken)(resourceId);
|
|
129
|
+
import_vitest.vi.advanceTimersByTime(181e3);
|
|
130
|
+
await (0, import_vitest.expect)((0, import_get_integration_token.getIntegrationToken)(resourceId)).resolves.toBe("first");
|
|
131
|
+
await settle();
|
|
132
|
+
await (0, import_vitest.expect)((0, import_get_integration_token.getIntegrationToken)(resourceId)).resolves.toBe("first");
|
|
133
|
+
await settle();
|
|
134
|
+
await (0, import_vitest.expect)((0, import_get_integration_token.getIntegrationToken)(resourceId)).resolves.toBe("second");
|
|
135
|
+
(0, import_vitest.expect)(fetchMock).toHaveBeenCalledTimes(3);
|
|
136
|
+
});
|
|
137
|
+
(0, import_vitest.test)("waits for a new token once the cached one is about to expire", async () => {
|
|
138
|
+
import_vitest.vi.useFakeTimers({ toFake: ["Date"] });
|
|
139
|
+
const resourceId = nextResourceId();
|
|
140
|
+
const fetchMock = import_vitest.vi.spyOn(globalThis, "fetch").mockImplementationOnce(fetchReturning(minted("first", 300))).mockImplementationOnce(fetchReturning(minted("second", 300)));
|
|
141
|
+
await (0, import_get_integration_token.getIntegrationToken)(resourceId);
|
|
142
|
+
import_vitest.vi.advanceTimersByTime(24e4);
|
|
143
|
+
await (0, import_vitest.expect)((0, import_get_integration_token.getIntegrationToken)(resourceId)).resolves.toBe("second");
|
|
144
|
+
(0, import_vitest.expect)(fetchMock).toHaveBeenCalledTimes(2);
|
|
145
|
+
});
|
|
146
|
+
(0, import_vitest.test)("caches tokens per role", async () => {
|
|
147
|
+
const resourceId = nextResourceId();
|
|
148
|
+
const fetchMock = import_vitest.vi.spyOn(globalThis, "fetch").mockImplementationOnce(fetchReturning(minted("default-token"))).mockImplementationOnce(fetchReturning(minted("readonly-token")));
|
|
149
|
+
await (0, import_vitest.expect)((0, import_get_integration_token.getIntegrationToken)(resourceId)).resolves.toBe(
|
|
150
|
+
"default-token"
|
|
151
|
+
);
|
|
152
|
+
await (0, import_vitest.expect)(
|
|
153
|
+
(0, import_get_integration_token.getIntegrationToken)(resourceId, { role: "readonly" })
|
|
154
|
+
).resolves.toBe("readonly-token");
|
|
155
|
+
(0, import_vitest.expect)(fetchMock).toHaveBeenCalledTimes(2);
|
|
156
|
+
});
|
|
157
|
+
(0, import_vitest.test)("shares one request between concurrent callers", async () => {
|
|
158
|
+
const resourceId = nextResourceId();
|
|
159
|
+
const fetchMock = import_vitest.vi.spyOn(globalThis, "fetch").mockImplementation(fetchReturning(minted("resource-token")));
|
|
160
|
+
const tokens = await Promise.all([
|
|
161
|
+
(0, import_get_integration_token.getIntegrationToken)(resourceId),
|
|
162
|
+
(0, import_get_integration_token.getIntegrationToken)(resourceId),
|
|
163
|
+
(0, import_get_integration_token.getIntegrationToken)(resourceId)
|
|
164
|
+
]);
|
|
165
|
+
(0, import_vitest.expect)(tokens).toEqual([
|
|
166
|
+
"resource-token",
|
|
167
|
+
"resource-token",
|
|
168
|
+
"resource-token"
|
|
169
|
+
]);
|
|
170
|
+
(0, import_vitest.expect)(fetchMock).toHaveBeenCalledTimes(1);
|
|
171
|
+
});
|
|
172
|
+
(0, import_vitest.test)("does not cache failures", async () => {
|
|
173
|
+
const resourceId = nextResourceId();
|
|
174
|
+
const fetchMock = import_vitest.vi.spyOn(globalThis, "fetch").mockImplementationOnce(
|
|
175
|
+
fetchReturning(
|
|
176
|
+
{ error: { code: "not_found", message: "Not found" } },
|
|
177
|
+
{ status: 404 }
|
|
178
|
+
)
|
|
179
|
+
).mockImplementationOnce(fetchReturning(minted("resource-token")));
|
|
180
|
+
await (0, import_vitest.expect)((0, import_get_integration_token.getIntegrationToken)(resourceId)).rejects.toBeInstanceOf(
|
|
181
|
+
import_errors.IntegrationTokenError
|
|
182
|
+
);
|
|
183
|
+
await (0, import_vitest.expect)((0, import_get_integration_token.getIntegrationToken)(resourceId)).resolves.toBe(
|
|
184
|
+
"resource-token"
|
|
185
|
+
);
|
|
186
|
+
(0, import_vitest.expect)(fetchMock).toHaveBeenCalledTimes(2);
|
|
187
|
+
});
|
|
188
|
+
(0, import_vitest.test)("throws an IntegrationTokenError mapping the API error envelope", async () => {
|
|
189
|
+
import_vitest.vi.spyOn(globalThis, "fetch").mockImplementation(
|
|
190
|
+
fetchReturning(
|
|
191
|
+
{
|
|
192
|
+
error: {
|
|
193
|
+
code: "invalid_role",
|
|
194
|
+
message: "Unknown role",
|
|
195
|
+
role: "admin"
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
{ status: 400, statusText: "Bad Request" }
|
|
199
|
+
)
|
|
200
|
+
);
|
|
201
|
+
await (0, import_vitest.expect)(
|
|
202
|
+
(0, import_get_integration_token.getIntegrationToken)(nextResourceId(), { role: "admin" })
|
|
203
|
+
).rejects.toMatchObject({
|
|
204
|
+
name: "IntegrationTokenError",
|
|
205
|
+
status: 400,
|
|
206
|
+
code: "invalid_role",
|
|
207
|
+
message: "Unknown role",
|
|
208
|
+
metadata: { role: "admin" }
|
|
209
|
+
});
|
|
210
|
+
});
|
|
211
|
+
(0, import_vitest.test)("rejects an empty resource without calling the API", async () => {
|
|
212
|
+
const fetchMock = import_vitest.vi.spyOn(globalThis, "fetch");
|
|
213
|
+
await (0, import_vitest.expect)((0, import_get_integration_token.getIntegrationToken)("")).rejects.toMatchObject({
|
|
214
|
+
name: "IntegrationTokenError",
|
|
215
|
+
status: void 0,
|
|
216
|
+
code: "invalid_resource"
|
|
217
|
+
});
|
|
218
|
+
(0, import_vitest.expect)(fetchMock).not.toHaveBeenCalled();
|
|
219
|
+
(0, import_vitest.expect)(getVercelOidcTokenMock).not.toHaveBeenCalled();
|
|
220
|
+
});
|
|
221
|
+
(0, import_vitest.test)("falls back to a generic error for a non-JSON error body", async () => {
|
|
222
|
+
import_vitest.vi.spyOn(globalThis, "fetch").mockImplementation(
|
|
223
|
+
fetchReturning("upstream timeout", {
|
|
224
|
+
status: 502,
|
|
225
|
+
statusText: "Bad Gateway"
|
|
226
|
+
})
|
|
227
|
+
);
|
|
228
|
+
await (0, import_vitest.expect)((0, import_get_integration_token.getIntegrationToken)(nextResourceId())).rejects.toMatchObject({
|
|
229
|
+
name: "IntegrationTokenError",
|
|
230
|
+
status: 502,
|
|
231
|
+
code: "request_failed",
|
|
232
|
+
message: "Integration token request failed with 502 Bad Gateway",
|
|
233
|
+
metadata: { body: "upstream timeout" }
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
(0, import_vitest.test)("sends an integration slug to the API as-is", async () => {
|
|
237
|
+
const fetchMock = import_vitest.vi.spyOn(globalThis, "fetch").mockImplementation(fetchReturning(minted("slug-token")));
|
|
238
|
+
await (0, import_vitest.expect)(
|
|
239
|
+
(0, import_get_integration_token.getIntegrationToken)("neon", { role: "readonly" })
|
|
240
|
+
).resolves.toBe("slug-token");
|
|
241
|
+
const [url] = fetchMock.mock.calls[0];
|
|
242
|
+
(0, import_vitest.expect)(url.toString()).toBe(
|
|
243
|
+
"https://api.vercel.com/v1/integrations/marketplace/resources/neon/token?role=readonly"
|
|
244
|
+
);
|
|
245
|
+
});
|
|
246
|
+
(0, import_vitest.test)("sends a slug and prefix as a single path segment", async () => {
|
|
247
|
+
const fetchMock = import_vitest.vi.spyOn(globalThis, "fetch").mockImplementation(fetchReturning(minted("prefixed-token")));
|
|
248
|
+
await (0, import_vitest.expect)((0, import_get_integration_token.getIntegrationToken)("neon/sales")).resolves.toBe(
|
|
249
|
+
"prefixed-token"
|
|
250
|
+
);
|
|
251
|
+
const [url] = fetchMock.mock.calls[0];
|
|
252
|
+
(0, import_vitest.expect)(url.toString()).toBe(
|
|
253
|
+
"https://api.vercel.com/v1/integrations/marketplace/resources/neon%2Fsales/token"
|
|
254
|
+
);
|
|
255
|
+
});
|
|
256
|
+
(0, import_vitest.test)("caches tokens per prefix", async () => {
|
|
257
|
+
const fetchMock = import_vitest.vi.spyOn(globalThis, "fetch").mockImplementationOnce(fetchReturning(minted("sales-token"))).mockImplementationOnce(fetchReturning(minted("billing-token")));
|
|
258
|
+
await (0, import_vitest.expect)((0, import_get_integration_token.getIntegrationToken)("prefix-corp/sales")).resolves.toBe(
|
|
259
|
+
"sales-token"
|
|
260
|
+
);
|
|
261
|
+
await (0, import_vitest.expect)((0, import_get_integration_token.getIntegrationToken)("prefix-corp/billing")).resolves.toBe(
|
|
262
|
+
"billing-token"
|
|
263
|
+
);
|
|
264
|
+
(0, import_vitest.expect)(fetchMock).toHaveBeenCalledTimes(2);
|
|
265
|
+
});
|
|
266
|
+
});
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var src_exports = {};
|
|
20
|
+
__export(src_exports, {
|
|
21
|
+
IntegrationTokenError: () => import_errors.IntegrationTokenError,
|
|
22
|
+
getIntegrationToken: () => import_get_integration_token.getIntegrationToken
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(src_exports);
|
|
25
|
+
var import_get_integration_token = require("./get-integration-token");
|
|
26
|
+
var import_errors = require("./errors");
|
|
27
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
+
0 && (module.exports = {
|
|
29
|
+
IntegrationTokenError,
|
|
30
|
+
getIntegrationToken
|
|
31
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base URL for the Vercel API. The resource token endpoint is exposed under
|
|
3
|
+
* `/integrations/marketplace/resources/:resourceId/token` relative to this base.
|
|
4
|
+
*/
|
|
5
|
+
export declare const API_BASE_URL = "https://api.vercel.com/v1";
|
|
6
|
+
/**
|
|
7
|
+
* Performs an authenticated POST without a body and returns the parsed JSON
|
|
8
|
+
* response. Throws {@link IntegrationTokenError} on a non-2xx response.
|
|
9
|
+
*/
|
|
10
|
+
export declare function postJson<T>({ url, token, }: {
|
|
11
|
+
url: URL;
|
|
12
|
+
token: string;
|
|
13
|
+
}): Promise<T>;
|
package/dist/request.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var request_exports = {};
|
|
20
|
+
__export(request_exports, {
|
|
21
|
+
API_BASE_URL: () => API_BASE_URL,
|
|
22
|
+
postJson: () => postJson
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(request_exports);
|
|
25
|
+
var import_errors = require("./errors");
|
|
26
|
+
var import_version = require("./version");
|
|
27
|
+
const API_BASE_URL = "https://api.vercel.com/v1";
|
|
28
|
+
async function postJson({
|
|
29
|
+
url,
|
|
30
|
+
token
|
|
31
|
+
}) {
|
|
32
|
+
const response = await fetch(url, {
|
|
33
|
+
method: "POST",
|
|
34
|
+
headers: {
|
|
35
|
+
accept: "application/json",
|
|
36
|
+
authorization: `Bearer ${token}`,
|
|
37
|
+
"user-agent": `@vercel/integrations@${import_version.version}`
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
if (!response.ok) {
|
|
41
|
+
throw await createIntegrationTokenError(response);
|
|
42
|
+
}
|
|
43
|
+
return await response.json();
|
|
44
|
+
}
|
|
45
|
+
async function createIntegrationTokenError(response) {
|
|
46
|
+
const text = await response.text();
|
|
47
|
+
const parsed = parseJsonObject(text);
|
|
48
|
+
const apiError = isRecord(parsed?.error) ? parsed.error : null;
|
|
49
|
+
if (apiError) {
|
|
50
|
+
const { code, message, ...metadata } = apiError;
|
|
51
|
+
return new import_errors.IntegrationTokenError({
|
|
52
|
+
status: response.status,
|
|
53
|
+
code: typeof code === "string" ? code : "request_failed",
|
|
54
|
+
message: typeof message === "string" ? message : getFallbackErrorMessage(response),
|
|
55
|
+
metadata
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
return new import_errors.IntegrationTokenError({
|
|
59
|
+
status: response.status,
|
|
60
|
+
code: "request_failed",
|
|
61
|
+
message: getFallbackErrorMessage(response),
|
|
62
|
+
metadata: {
|
|
63
|
+
...isRecord(parsed) ? { body: parsed } : {},
|
|
64
|
+
...!parsed && text ? { body: text } : {}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
function getFallbackErrorMessage(response) {
|
|
69
|
+
return `Integration token request failed with ${response.status} ${response.statusText}`;
|
|
70
|
+
}
|
|
71
|
+
function parseJsonObject(text) {
|
|
72
|
+
if (!text) {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
try {
|
|
76
|
+
const parsed = JSON.parse(text);
|
|
77
|
+
return isRecord(parsed) ? parsed : null;
|
|
78
|
+
} catch {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function isRecord(value) {
|
|
83
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
84
|
+
}
|
|
85
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
86
|
+
0 && (module.exports = {
|
|
87
|
+
API_BASE_URL,
|
|
88
|
+
postJson
|
|
89
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const version = "0.1.0-snapshot-c4002eb2617b";
|
package/dist/version.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var version_exports = {};
|
|
20
|
+
__export(version_exports, {
|
|
21
|
+
version: () => version
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(version_exports);
|
|
24
|
+
const version = "0.1.0-snapshot-c4002eb2617b";
|
|
25
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
26
|
+
0 && (module.exports = {
|
|
27
|
+
version
|
|
28
|
+
});
|
package/docs/README.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
**@vercel/integrations**
|
|
2
|
+
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# @vercel/integrations
|
|
6
|
+
|
|
7
|
+
## Classes
|
|
8
|
+
|
|
9
|
+
- [IntegrationTokenError](classes/IntegrationTokenError.md)
|
|
10
|
+
|
|
11
|
+
## Interfaces
|
|
12
|
+
|
|
13
|
+
- [GetIntegrationTokenOptions](interfaces/GetIntegrationTokenOptions.md)
|
|
14
|
+
|
|
15
|
+
## Functions
|
|
16
|
+
|
|
17
|
+
- [getIntegrationToken](functions/getIntegrationToken.md)
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
[**@vercel/integrations**](../README.md)
|
|
2
|
+
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Class: IntegrationTokenError
|
|
6
|
+
|
|
7
|
+
Error thrown when an integration token can't be obtained. For API failures it
|
|
8
|
+
mirrors the error envelope `{ error: { code, message, ...meta } }`: `code` and
|
|
9
|
+
`message` come from the response body when present, and any remaining fields
|
|
10
|
+
are exposed on [IntegrationTokenError.metadata](#metadata).
|
|
11
|
+
|
|
12
|
+
## Extends
|
|
13
|
+
|
|
14
|
+
- [`Error`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error)
|
|
15
|
+
|
|
16
|
+
## Constructors
|
|
17
|
+
|
|
18
|
+
### Constructor
|
|
19
|
+
|
|
20
|
+
> **new IntegrationTokenError**(`__namedParameters`): `IntegrationTokenError`
|
|
21
|
+
|
|
22
|
+
#### Parameters
|
|
23
|
+
|
|
24
|
+
##### \_\_namedParameters
|
|
25
|
+
|
|
26
|
+
###### code
|
|
27
|
+
|
|
28
|
+
`string`
|
|
29
|
+
|
|
30
|
+
###### message
|
|
31
|
+
|
|
32
|
+
`string`
|
|
33
|
+
|
|
34
|
+
###### metadata?
|
|
35
|
+
|
|
36
|
+
[`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)\<`string`, `unknown`\> = `{}`
|
|
37
|
+
|
|
38
|
+
###### status?
|
|
39
|
+
|
|
40
|
+
`number`
|
|
41
|
+
|
|
42
|
+
#### Returns
|
|
43
|
+
|
|
44
|
+
`IntegrationTokenError`
|
|
45
|
+
|
|
46
|
+
#### Overrides
|
|
47
|
+
|
|
48
|
+
`Error.constructor`
|
|
49
|
+
|
|
50
|
+
## Properties
|
|
51
|
+
|
|
52
|
+
### code
|
|
53
|
+
|
|
54
|
+
> `readonly` **code**: `string`
|
|
55
|
+
|
|
56
|
+
Machine-readable error code (e.g. `not_found`, `invalid_role`).
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
### message
|
|
61
|
+
|
|
62
|
+
> **message**: `string`
|
|
63
|
+
|
|
64
|
+
#### Inherited from
|
|
65
|
+
|
|
66
|
+
`Error.message`
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
### metadata
|
|
71
|
+
|
|
72
|
+
> `readonly` **metadata**: [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)\<`string`, `unknown`\>
|
|
73
|
+
|
|
74
|
+
Any additional fields the API attached to the error envelope.
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
### name
|
|
79
|
+
|
|
80
|
+
> **name**: `string`
|
|
81
|
+
|
|
82
|
+
#### Inherited from
|
|
83
|
+
|
|
84
|
+
`Error.name`
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
### stack?
|
|
89
|
+
|
|
90
|
+
> `optional` **stack?**: `string`
|
|
91
|
+
|
|
92
|
+
#### Inherited from
|
|
93
|
+
|
|
94
|
+
`Error.stack`
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
### status?
|
|
99
|
+
|
|
100
|
+
> `readonly` `optional` **status?**: `number`
|
|
101
|
+
|
|
102
|
+
HTTP status code of the failed response. Absent when no request was made.
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
### prepareStackTrace?
|
|
107
|
+
|
|
108
|
+
> `static` `optional` **prepareStackTrace?**: (`err`, `stackTraces`) => `any`
|
|
109
|
+
|
|
110
|
+
Optional override for formatting stack traces
|
|
111
|
+
|
|
112
|
+
#### Parameters
|
|
113
|
+
|
|
114
|
+
##### err
|
|
115
|
+
|
|
116
|
+
[`Error`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error)
|
|
117
|
+
|
|
118
|
+
##### stackTraces
|
|
119
|
+
|
|
120
|
+
`CallSite`[]
|
|
121
|
+
|
|
122
|
+
#### Returns
|
|
123
|
+
|
|
124
|
+
`any`
|
|
125
|
+
|
|
126
|
+
#### See
|
|
127
|
+
|
|
128
|
+
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
|
|
129
|
+
|
|
130
|
+
#### Inherited from
|
|
131
|
+
|
|
132
|
+
`Error.prepareStackTrace`
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
### stackTraceLimit
|
|
137
|
+
|
|
138
|
+
> `static` **stackTraceLimit**: `number`
|
|
139
|
+
|
|
140
|
+
#### Inherited from
|
|
141
|
+
|
|
142
|
+
`Error.stackTraceLimit`
|
|
143
|
+
|
|
144
|
+
## Methods
|
|
145
|
+
|
|
146
|
+
### captureStackTrace()
|
|
147
|
+
|
|
148
|
+
> `static` **captureStackTrace**(`targetObject`, `constructorOpt?`): `void`
|
|
149
|
+
|
|
150
|
+
Create .stack property on a target object
|
|
151
|
+
|
|
152
|
+
#### Parameters
|
|
153
|
+
|
|
154
|
+
##### targetObject
|
|
155
|
+
|
|
156
|
+
`object`
|
|
157
|
+
|
|
158
|
+
##### constructorOpt?
|
|
159
|
+
|
|
160
|
+
[`Function`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function)
|
|
161
|
+
|
|
162
|
+
#### Returns
|
|
163
|
+
|
|
164
|
+
`void`
|
|
165
|
+
|
|
166
|
+
#### Inherited from
|
|
167
|
+
|
|
168
|
+
`Error.captureStackTrace`
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
[**@vercel/integrations**](../README.md)
|
|
2
|
+
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Function: getIntegrationToken()
|
|
6
|
+
|
|
7
|
+
> **getIntegrationToken**(`resource`, `options?`): [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`string`\>
|
|
8
|
+
|
|
9
|
+
Returns a short-lived token for a Vercel Marketplace integration resource
|
|
10
|
+
connected to the calling deployment's project and environment. Pass it to the
|
|
11
|
+
provider wherever it would otherwise expect a long-lived secret, e.g. as a
|
|
12
|
+
database password.
|
|
13
|
+
|
|
14
|
+
`resource` identifies the resource, e.g. an integration slug (`neon`), a slug
|
|
15
|
+
and environment variable prefix (`neon/sales`), or a Vercel resource ID. The
|
|
16
|
+
API resolves it.
|
|
17
|
+
|
|
18
|
+
Tokens are cached in memory and reused until shortly before they expire.
|
|
19
|
+
Concurrent calls for the same resource and role share one request.
|
|
20
|
+
|
|
21
|
+
## Parameters
|
|
22
|
+
|
|
23
|
+
### resource
|
|
24
|
+
|
|
25
|
+
`string`
|
|
26
|
+
|
|
27
|
+
### options?
|
|
28
|
+
|
|
29
|
+
[`GetIntegrationTokenOptions`](../interfaces/GetIntegrationTokenOptions.md) = `{}`
|
|
30
|
+
|
|
31
|
+
## Returns
|
|
32
|
+
|
|
33
|
+
[`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`string`\>
|
|
34
|
+
|
|
35
|
+
## Example
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
const token = await getIntegrationToken('neon');
|
|
39
|
+
const token = await getIntegrationToken('neon/sales', { role: 'readonly' });
|
|
40
|
+
const token = await getIntegrationToken('store_abc123');
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Throws
|
|
44
|
+
|
|
45
|
+
If the token can't be minted.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
[**@vercel/integrations**](../README.md)
|
|
2
|
+
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Interface: GetIntegrationTokenOptions
|
|
6
|
+
|
|
7
|
+
Options for [getIntegrationToken](../functions/getIntegrationToken.md).
|
|
8
|
+
|
|
9
|
+
## Properties
|
|
10
|
+
|
|
11
|
+
### role?
|
|
12
|
+
|
|
13
|
+
> `optional` **role?**: `string`
|
|
14
|
+
|
|
15
|
+
One of the roles the resource defines. Defaults to the resource's default
|
|
16
|
+
role. Requesting a role the resource doesn't define fails with
|
|
17
|
+
`invalid_role`.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
### teamId?
|
|
22
|
+
|
|
23
|
+
> `optional` **teamId?**: `string`
|
|
24
|
+
|
|
25
|
+
The Vercel team that owns the resource.
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
### vercelToken?
|
|
30
|
+
|
|
31
|
+
> `optional` **vercelToken?**: `string`
|
|
32
|
+
|
|
33
|
+
A Vercel token to authenticate with. When omitted, the deployment's OIDC
|
|
34
|
+
token is fetched automatically via `@vercel/oidc`.
|
package/package.json
CHANGED
|
@@ -1 +1,53 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"name": "@vercel/integrations",
|
|
3
|
+
"description": "Runtime helpers for Vercel Marketplace integrations, such as minting short-lived resource tokens",
|
|
4
|
+
"homepage": "https://vercel.com",
|
|
5
|
+
"files": [
|
|
6
|
+
"**/*.js",
|
|
7
|
+
"**/*.d.ts",
|
|
8
|
+
"**/*.md"
|
|
9
|
+
],
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"import": "./dist/index.js",
|
|
14
|
+
"require": "./dist/index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"version": "0.1.0-snapshot-c4002eb2617b",
|
|
18
|
+
"repository": {
|
|
19
|
+
"directory": "packages/integrations",
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/vercel/vercel.git"
|
|
22
|
+
},
|
|
23
|
+
"bugs": {
|
|
24
|
+
"url": "https://github.com/vercel/vercel/issues"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@vercel/oidc": "4.0.5"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"prettier": "3.8.3",
|
|
31
|
+
"tinyspawn": "1.3.1",
|
|
32
|
+
"typedoc": "0.28.19",
|
|
33
|
+
"typedoc-plugin-markdown": "4.11.0",
|
|
34
|
+
"typedoc-plugin-mdn-links": "5.1.1",
|
|
35
|
+
"vitest": "4.1.10"
|
|
36
|
+
},
|
|
37
|
+
"peerDependenciesMeta": {},
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">= 20"
|
|
40
|
+
},
|
|
41
|
+
"license": "Apache-2.0",
|
|
42
|
+
"publishConfig": {
|
|
43
|
+
"access": "public"
|
|
44
|
+
},
|
|
45
|
+
"scripts": {
|
|
46
|
+
"pretest": "pnpm run build:code",
|
|
47
|
+
"test": "vitest",
|
|
48
|
+
"vitest-unit": "glob --absolute 'src/**/*.test.ts'",
|
|
49
|
+
"build": "pnpm run build:code && pnpm run build:docs",
|
|
50
|
+
"build:code": "node build.mjs",
|
|
51
|
+
"build:docs": "typedoc && prettier --write docs/**/*.md docs/*.md"
|
|
52
|
+
}
|
|
53
|
+
}
|