@coffre/client 0.6.1 → 0.7.0
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/dist/{index-BHK1QCh7.d.ts → index-D802ZJF6.d.ts} +401 -19
- package/dist/index.d.ts +2 -2
- package/dist/index.js +29 -3
- package/dist/routes.d.ts +1 -1
- package/dist/routes.js +5 -0
- package/package.json +1 -1
- package/src/api.ts +281 -17
- package/src/index.ts +35 -4
- package/src/routes.ts +5 -0
package/src/index.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* its own handling of Cloudflare Access redirects. A request that never
|
|
11
11
|
* reaches the instance throws `Unreachable`, which says why.
|
|
12
12
|
*/
|
|
13
|
-
import type { Api, AuthInfo, BindingPlan, BindingView, DeletionResult, DryRunOutcome, DryRunResult, SetResult, TokenPlan } from './api.ts';
|
|
13
|
+
import type { Api, AuthInfo, BindingPlan, BindingView, DeletionResult, DryRunOutcome, DryRunResult, InheritResult, KeysPlan, SetResult, TokenPlan } from './api.ts';
|
|
14
14
|
import { Unreachable } from './reach.ts';
|
|
15
15
|
|
|
16
16
|
export type {
|
|
@@ -30,21 +30,24 @@ export type {
|
|
|
30
30
|
DryRunOutcome,
|
|
31
31
|
DryRunResult,
|
|
32
32
|
IdentityRow,
|
|
33
|
+
InheritResult,
|
|
34
|
+
KeysPlan,
|
|
33
35
|
ListedReference,
|
|
34
36
|
Me,
|
|
35
37
|
Member,
|
|
36
38
|
MemberAccess,
|
|
37
39
|
MissingKey,
|
|
38
40
|
OffboardingReport,
|
|
41
|
+
PersonalConfig,
|
|
39
42
|
ProjectSummary,
|
|
40
43
|
ReferenceView,
|
|
41
44
|
RemovedMember,
|
|
42
45
|
SecretKey,
|
|
43
46
|
SecretVersion,
|
|
44
|
-
ServiceTokenRow,
|
|
45
47
|
SessionRow,
|
|
46
48
|
SetResult,
|
|
47
49
|
TokenPlan,
|
|
50
|
+
TokenRow,
|
|
48
51
|
WorkloadIds,
|
|
49
52
|
} from './api.ts';
|
|
50
53
|
|
|
@@ -173,7 +176,8 @@ export function createClient(options: ClientOptions) {
|
|
|
173
176
|
projects: {
|
|
174
177
|
/** With their environments. */
|
|
175
178
|
list: () => call('GET /projects', {}),
|
|
176
|
-
|
|
179
|
+
/** Its `name`, which releases before 0.6.2 show, defaults to the slug. */
|
|
180
|
+
create: (project: string, input: RouteInput<'PUT /projects/:project'> = {}) =>
|
|
177
181
|
call('PUT /projects/:project', { project }, input),
|
|
178
182
|
update: (project: string, patch: RouteInput<'PATCH /projects/:project'>) =>
|
|
179
183
|
call('PATCH /projects/:project', { project }, patch),
|
|
@@ -187,7 +191,8 @@ export function createClient(options: ClientOptions) {
|
|
|
187
191
|
},
|
|
188
192
|
|
|
189
193
|
environments: {
|
|
190
|
-
|
|
194
|
+
/** As a project's: its `name` defaults to the slug. `from` forks a sibling. */
|
|
195
|
+
create: (path: string, input: RouteInput<'PUT /projects/:project/:environment'> = {}) =>
|
|
191
196
|
call('PUT /projects/:project/:environment', place(path), input),
|
|
192
197
|
update: (path: string, patch: RouteInput<'PATCH /projects/:project/:environment'>) =>
|
|
193
198
|
call('PATCH /projects/:project/:environment', place(path), patch),
|
|
@@ -200,6 +205,14 @@ export function createClient(options: ClientOptions) {
|
|
|
200
205
|
delete: (path: string) => call('DELETE /projects/:project/:environment', place(path)),
|
|
201
206
|
/** The keys its sibling environments have and it lacks, read or not, and those its team dismissed. */
|
|
202
207
|
missing: (path: string) => call('GET /projects/:project/:environment/missing', place(path)),
|
|
208
|
+
/** A project's personal configs, for whoever manages its environments: whose, of what, and their key names. */
|
|
209
|
+
personal: (project: string) => call('GET /personal/:project', place(project)),
|
|
210
|
+
/**
|
|
211
|
+
* A version of what reading it would open: it changes whenever a read
|
|
212
|
+
* would, and reads no value, so it is not logged. Poll it, and read
|
|
213
|
+
* only when it changed.
|
|
214
|
+
*/
|
|
215
|
+
version: (path: string) => call('GET /projects/:project/:environment/version', place(path)),
|
|
203
216
|
/** Dismiss missing keys (`true`) or restore them (`null`). */
|
|
204
217
|
dismiss: (path: string, patch: RouteInput<'PATCH /projects/:project/:environment/dismissals'>) =>
|
|
205
218
|
call('PATCH /projects/:project/:environment/dismissals', place(path), patch),
|
|
@@ -230,6 +243,12 @@ export function createClient(options: ClientOptions) {
|
|
|
230
243
|
call('PATCH /secrets/:project/:environment/:key', place(path), { key }),
|
|
231
244
|
update: (path: string, patch: RouteInput<'PATCH /secrets/:project/:environment/:key'>) =>
|
|
232
245
|
call('PATCH /secrets/:project/:environment/:key', place(path), patch),
|
|
246
|
+
/**
|
|
247
|
+
* In a fork, a key back to its parent's value (`true`), its own kept,
|
|
248
|
+
* or its own served again (`false`); `from` holds the parent's.
|
|
249
|
+
*/
|
|
250
|
+
inherit: (path: string, inherit: boolean) =>
|
|
251
|
+
call('PATCH /secrets/:project/:environment/:key', place(path), { inherit }) as Promise<InheritResult>,
|
|
233
252
|
},
|
|
234
253
|
|
|
235
254
|
/**
|
|
@@ -256,6 +275,10 @@ export function createClient(options: ClientOptions) {
|
|
|
256
275
|
remove: (member: string) => call('DELETE /members/:member', { member }),
|
|
257
276
|
},
|
|
258
277
|
|
|
278
|
+
/**
|
|
279
|
+
* A member's tokens: a service account's bearer tokens, or a person's
|
|
280
|
+
* personal tokens (`user:<email>`), which act as them within their scope.
|
|
281
|
+
*/
|
|
259
282
|
tokens: {
|
|
260
283
|
list: (member: string) => call('GET /members/:member/tokens', { member }),
|
|
261
284
|
/** What the token would reach, as the server would issue it now; issues nothing. */
|
|
@@ -279,6 +302,14 @@ export function createClient(options: ClientOptions) {
|
|
|
279
302
|
},
|
|
280
303
|
create: (member: string, input: RouteInput<'POST /members/:member/bindings'>) =>
|
|
281
304
|
call('POST /members/:member/bindings', { member }, input) as Promise<{ binding: BindingView; replaced: string[] }>,
|
|
305
|
+
/** The service's bindings on an issuer that new keys would replace, and the keys as checked; writes nothing. */
|
|
306
|
+
previewKeys: (member: string, input: RouteInput<'POST /members/:member/bindings/keys'>) => {
|
|
307
|
+
const [method, route] = address('POST /members/:member/bindings/keys', { member });
|
|
308
|
+
return send(method, `${route}?dryRun=1`, input) as Promise<KeysPlan>;
|
|
309
|
+
},
|
|
310
|
+
/** New keys, uploaded, for every binding of the service on the issuer: each replaced by one the same but for them. */
|
|
311
|
+
replaceKeys: (member: string, input: RouteInput<'POST /members/:member/bindings/keys'>) =>
|
|
312
|
+
call('POST /members/:member/bindings/keys', { member }, input) as Promise<{ bindings: BindingView[]; replaced: string[] }>,
|
|
282
313
|
remove: (member: string, id: string) => call('DELETE /members/:member/bindings/:id', { member, id }),
|
|
283
314
|
/** A GitHub repository's or GitLab project's IDs, which bindings name: a public one's, or one the deployment's GitHub App is installed on. */
|
|
284
315
|
lookup: (input: RouteInput<'GET /workloads/lookup'>) => call('GET /workloads/lookup', {}, input),
|
package/src/routes.ts
CHANGED
|
@@ -28,6 +28,8 @@ export function getCalls({ places, secrets, members, services }: Subjects): GetC
|
|
|
28
28
|
'GET /projects': [{ params: {} }],
|
|
29
29
|
'GET /secrets/:project/:environment': places.map((params) => ({ params })),
|
|
30
30
|
'GET /projects/:project/:environment/missing': places.map((params) => ({ params })),
|
|
31
|
+
'GET /personal/:project': [...new Set(places.map((params) => params.project))].map((project) => ({ params: { project } })),
|
|
32
|
+
'GET /projects/:project/:environment/version': places.map((params) => ({ params })),
|
|
31
33
|
'GET /secrets/:project/:environment/:key/versions': secrets.map((params) => ({ params })),
|
|
32
34
|
'GET /members': [
|
|
33
35
|
{ params: {} },
|
|
@@ -75,6 +77,8 @@ const EVERY_ROUTE: { [K in RouteKey]: true } = {
|
|
|
75
77
|
'PATCH /projects/:project/:environment': true,
|
|
76
78
|
'DELETE /projects/:project/:environment': true,
|
|
77
79
|
'GET /projects/:project/:environment/missing': true,
|
|
80
|
+
'GET /personal/:project': true,
|
|
81
|
+
'GET /projects/:project/:environment/version': true,
|
|
78
82
|
'PATCH /projects/:project/:environment/dismissals': true,
|
|
79
83
|
'GET /secrets/:project/:environment': true,
|
|
80
84
|
'PATCH /secrets/:project/:environment': true,
|
|
@@ -98,6 +102,7 @@ const EVERY_ROUTE: { [K in RouteKey]: true } = {
|
|
|
98
102
|
'DELETE /members/:member/tokens/:id': true,
|
|
99
103
|
'GET /members/:member/bindings': true,
|
|
100
104
|
'POST /members/:member/bindings': true,
|
|
105
|
+
'POST /members/:member/bindings/keys': true,
|
|
101
106
|
'DELETE /members/:member/bindings/:id': true,
|
|
102
107
|
'GET /workloads/lookup': true,
|
|
103
108
|
'GET /workloads/repositories': true,
|