@coffre/client 0.6.2 → 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-M5Gp4kSA.d.ts → index-D802ZJF6.d.ts} +395 -15
- package/dist/index.d.ts +2 -2
- package/dist/index.js +25 -1
- package/dist/routes.d.ts +1 -1
- package/dist/routes.js +5 -0
- package/package.json +1 -1
- package/src/api.ts +279 -15
- package/src/index.ts +31 -2
- 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
|
|
|
@@ -202,6 +205,14 @@ export function createClient(options: ClientOptions) {
|
|
|
202
205
|
delete: (path: string) => call('DELETE /projects/:project/:environment', place(path)),
|
|
203
206
|
/** The keys its sibling environments have and it lacks, read or not, and those its team dismissed. */
|
|
204
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)),
|
|
205
216
|
/** Dismiss missing keys (`true`) or restore them (`null`). */
|
|
206
217
|
dismiss: (path: string, patch: RouteInput<'PATCH /projects/:project/:environment/dismissals'>) =>
|
|
207
218
|
call('PATCH /projects/:project/:environment/dismissals', place(path), patch),
|
|
@@ -232,6 +243,12 @@ export function createClient(options: ClientOptions) {
|
|
|
232
243
|
call('PATCH /secrets/:project/:environment/:key', place(path), { key }),
|
|
233
244
|
update: (path: string, patch: RouteInput<'PATCH /secrets/:project/:environment/:key'>) =>
|
|
234
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>,
|
|
235
252
|
},
|
|
236
253
|
|
|
237
254
|
/**
|
|
@@ -258,6 +275,10 @@ export function createClient(options: ClientOptions) {
|
|
|
258
275
|
remove: (member: string) => call('DELETE /members/:member', { member }),
|
|
259
276
|
},
|
|
260
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
|
+
*/
|
|
261
282
|
tokens: {
|
|
262
283
|
list: (member: string) => call('GET /members/:member/tokens', { member }),
|
|
263
284
|
/** What the token would reach, as the server would issue it now; issues nothing. */
|
|
@@ -281,6 +302,14 @@ export function createClient(options: ClientOptions) {
|
|
|
281
302
|
},
|
|
282
303
|
create: (member: string, input: RouteInput<'POST /members/:member/bindings'>) =>
|
|
283
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[] }>,
|
|
284
313
|
remove: (member: string, id: string) => call('DELETE /members/:member/bindings/:id', { member, id }),
|
|
285
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. */
|
|
286
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,
|