@coffre/client 0.14.7 → 0.16.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-CURF99SB.d.ts → index-DZZ3DRTO.d.ts} +1014 -1086
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/routes.d.ts +1 -1
- package/dist/routes.js +1 -4
- package/dist/{src-BCKSeCER.js → src-JtgcfCXD.js} +36 -29
- package/dist/{workload-ClMNMVqA.js → workload-CkZoajvs.js} +2 -2
- package/dist/workload-postgres.d.ts +9 -0
- package/dist/workload-postgres.js +15 -1
- package/dist/workload.d.ts +1 -1
- package/dist/workload.js +2 -2
- package/package.json +1 -1
- package/src/api.ts +855 -924
- package/src/index.ts +20 -31
- package/src/proofs.ts +42 -0
- package/src/routes.ts +0 -3
- package/src/workload-postgres.ts +15 -0
- package/src/workload-proofs.ts +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
export { type AccessValue, type Api, type ApprovalView, type AuditEntryView, type AuthInfo, type AuthorizationView, type BindingPlan, type BindingView, ClientOptions, CoffreClient, CoffreError, type ConnectedApp, type Decision, type Deletion, type DeletionResult, type DismissedKey, type DryRunOutcome, type DryRunResult, type EnvironmentView, type IdentityRow, type ImpactLine, ImportAction, type InheritResult, type KeysPlan, type ListedReference, type Me, type Member, type MemberAccess, type MissingKey, type OffboardingReport, Params, type PersonalConfig, type ProjectSummary, type ReferenceView, type RemovedMember, type RoleImpact, type RoleView, type RolesView, RouteInput, RouteKey, RouteOutput, type SecretKey, type SecretVersion, type SessionRow, type SetResult, type TokenPlan, type TokenRow, Transport, Unreachable, type WorkloadIds, ageInDays, apiMember, byFolder, createClient, foldersOf, olderThan, planImport, serviceName, shownMember, unreachable };
|
|
1
|
+
import { $ as RoleImpact, A as BindingView, B as ImpactLine, C as AccessValue, D as AuthInfo, E as AuditEntryView, F as DismissedKey, G as Member, H as KeysPlan, I as DryRunOutcome, J as OffboardingReport, K as MemberAccess, L as DryRunResult, M as Decision, N as Deletion, O as AuthorizationView, P as DeletionResult, Q as RemovedMember, R as EnvironmentView, S as olderThan, T as ApprovalView, U as ListedReference, V as InheritResult, W as Me, X as ProjectSummary, Y as PersonalConfig, Z as ReferenceView, _ as serviceName, a as Params, at as SetResult, b as foldersOf, c as RouteOutput, ct as WorkloadIds, d as planImport, et as RoleView, f as Unreachable, g as apiMember, h as judgeProofs, i as ImportAction, it as SessionRow, j as ConnectedApp, k as BindingPlan, l as Transport, m as ProofJudgment, n as CoffreClient, nt as SecretKey, o as RouteInput, ot as TokenPlan, p as unreachable, q as MissingKey, r as CoffreError, rt as SecretVersion, s as RouteKey, st as TokenRow, t as ClientOptions, tt as RolesView, u as createClient, v as shownMember, w as Api, x as ageInDays, y as byFolder, z as IdentityRow } from "./index-DZZ3DRTO.js";
|
|
2
|
+
export { type AccessValue, type Api, type ApprovalView, type AuditEntryView, type AuthInfo, type AuthorizationView, type BindingPlan, type BindingView, ClientOptions, CoffreClient, CoffreError, type ConnectedApp, type Decision, type Deletion, type DeletionResult, type DismissedKey, type DryRunOutcome, type DryRunResult, type EnvironmentView, type IdentityRow, type ImpactLine, ImportAction, type InheritResult, type KeysPlan, type ListedReference, type Me, type Member, type MemberAccess, type MissingKey, type OffboardingReport, Params, type PersonalConfig, type ProjectSummary, type ProofJudgment, type ReferenceView, type RemovedMember, type RoleImpact, type RoleView, type RolesView, RouteInput, RouteKey, RouteOutput, type SecretKey, type SecretVersion, type SessionRow, type SetResult, type TokenPlan, type TokenRow, Transport, Unreachable, type WorkloadIds, ageInDays, apiMember, byFolder, createClient, foldersOf, judgeProofs, olderThan, planImport, serviceName, shownMember, unreachable };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { CoffreError, Unreachable, ageInDays, apiMember, byFolder, createClient, foldersOf, olderThan, planImport, serviceName, shownMember, unreachable };
|
|
1
|
+
import { a as apiMember, c as byFolder, d as olderThan, f as Unreachable, i as judgeProofs, l as foldersOf, n as createClient, o as serviceName, p as unreachable, r as planImport, s as shownMember, t as CoffreError, u as ageInDays } from "./src-JtgcfCXD.js";
|
|
2
|
+
export { CoffreError, Unreachable, ageInDays, apiMember, byFolder, createClient, foldersOf, judgeProofs, olderThan, planImport, serviceName, shownMember, unreachable };
|
package/dist/routes.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as Params, o as RouteInput, s as RouteKey } from "./index-
|
|
1
|
+
import { a as Params, o as RouteInput, s as RouteKey } from "./index-DZZ3DRTO.js";
|
|
2
2
|
//#region src/routes.d.ts
|
|
3
3
|
export type GetKey = Extract<RouteKey, `GET ${string}`>;
|
|
4
4
|
/** Each GET route, with what to ask it. */
|
package/dist/routes.js
CHANGED
|
@@ -58,7 +58,6 @@ function getCalls({ places, secrets, members, services }) {
|
|
|
58
58
|
detail: "1"
|
|
59
59
|
}
|
|
60
60
|
}],
|
|
61
|
-
"GET /audit/verification": [{ params: {} }],
|
|
62
61
|
"GET /audit/keys": [{ params: {} }]
|
|
63
62
|
};
|
|
64
63
|
}
|
|
@@ -141,9 +140,7 @@ const EVERY_ROUTE = {
|
|
|
141
140
|
"GET /apps": true,
|
|
142
141
|
"DELETE /apps/:id": true,
|
|
143
142
|
"GET /audit": true,
|
|
144
|
-
"GET /audit/
|
|
145
|
-
"GET /audit/keys": true,
|
|
146
|
-
"POST /audit/loss": true
|
|
143
|
+
"GET /audit/keys": true
|
|
147
144
|
};
|
|
148
145
|
/**
|
|
149
146
|
* Every route as a method and a URL, each parameter a made-up value: what
|
|
@@ -104,6 +104,23 @@ function serviceName(member) {
|
|
|
104
104
|
return member.replace(/^(?:service|token):/, "");
|
|
105
105
|
}
|
|
106
106
|
//#endregion
|
|
107
|
+
//#region src/proofs.ts
|
|
108
|
+
function judgeProofs(page) {
|
|
109
|
+
const { head, entries } = page;
|
|
110
|
+
const within = (entry) => head !== null && entry.seq < head.size;
|
|
111
|
+
const numbered = entries.filter(within).length;
|
|
112
|
+
const pruned = page.holes !== null && page.holes.length > 0 && page.holes.every((hole) => hole.kept === 0);
|
|
113
|
+
return {
|
|
114
|
+
head,
|
|
115
|
+
numbered,
|
|
116
|
+
proven: entries.filter((entry) => entry.proof === "proven").length,
|
|
117
|
+
failed: entries.filter((entry) => entry.proof === "failed"),
|
|
118
|
+
misplaced: entries.filter((entry) => entry.proof !== "failed" && within(entry) !== (entry.proof === "proven")),
|
|
119
|
+
missing: page.holes,
|
|
120
|
+
racing: numbered === 0 || pruned
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
//#endregion
|
|
107
124
|
//#region src/index.ts
|
|
108
125
|
/** The API's error shape, `{ error, message }`, with the HTTP status. */
|
|
109
126
|
var CoffreError = class extends Error {
|
|
@@ -249,7 +266,7 @@ function createClient(options) {
|
|
|
249
266
|
update: (path, patch) => call("PATCH /secrets/:project/:environment/:key", place(path), patch),
|
|
250
267
|
/**
|
|
251
268
|
* In a fork, a key back to its parent's value (`true`), its own kept,
|
|
252
|
-
* or its own served again (`false`);
|
|
269
|
+
* or its own served again (`false`); the answer says which, `inherit`.
|
|
253
270
|
*/
|
|
254
271
|
inherit: (path, inherit) => call("PATCH /secrets/:project/:environment/:key", place(path), { inherit })
|
|
255
272
|
},
|
|
@@ -311,7 +328,7 @@ function createClient(options) {
|
|
|
311
328
|
return send(method, `${route}?dryRun=1`, input);
|
|
312
329
|
},
|
|
313
330
|
create: (member, input) => call("POST /members/:member/bindings", { member }, input),
|
|
314
|
-
/** The service's bindings on an issuer that new keys would replace,
|
|
331
|
+
/** The service's bindings on an issuer that new keys would replace, the keys as checked, and the places they would withhold; writes nothing. */
|
|
315
332
|
previewKeys: (member, input) => {
|
|
316
333
|
const [method, route] = address("POST /members/:member/bindings/keys", { member });
|
|
317
334
|
return send(method, `${route}?dryRun=1`, input);
|
|
@@ -327,6 +344,21 @@ function createClient(options) {
|
|
|
327
344
|
/** The repositories the deployment's GitHub App is installed on, private ones too; `{ app: null }` without one. */
|
|
328
345
|
repositories: () => call("GET /workloads/repositories", {})
|
|
329
346
|
},
|
|
347
|
+
/**
|
|
348
|
+
* Freezes: every use under a target refused from its next request, its
|
|
349
|
+
* sessions kept, until lifted. A target is `instance`, `service:<name>`,
|
|
350
|
+
* `binding:<id>` or `session:<id>`.
|
|
351
|
+
*/
|
|
352
|
+
freezes: {
|
|
353
|
+
/** The freezes standing that you may know of: the instance's, and those of the service accounts you manage. */
|
|
354
|
+
list: () => call("GET /freezes", {}),
|
|
355
|
+
freeze: (target, reason) => call("POST /freezes", {}, {
|
|
356
|
+
target,
|
|
357
|
+
reason
|
|
358
|
+
}),
|
|
359
|
+
/** Lifts it; a target that is not frozen stays so. */
|
|
360
|
+
unfreeze: (target) => call("DELETE /freezes/:target", { target })
|
|
361
|
+
},
|
|
330
362
|
access: {
|
|
331
363
|
/** What they should hold at each place; the server applies the difference. `null` revokes. */
|
|
332
364
|
set: (member, access) => call("PATCH /access/:member", { member }, access) },
|
|
@@ -434,33 +466,8 @@ set: (member, access) => call("PATCH /access/:member", { member }, access) },
|
|
|
434
466
|
},
|
|
435
467
|
audit: {
|
|
436
468
|
list: (query = {}) => call("GET /audit", {}, query),
|
|
437
|
-
/**
|
|
438
|
-
* Whether the log holds, from the newest checkpoint; or, with `from`, a
|
|
439
|
-
* stretch of the walk from the first entry: `start`, then each `next`
|
|
440
|
-
* until it is null (`verifyWhole`).
|
|
441
|
-
*/
|
|
442
|
-
verify: (query = {}) => call("GET /audit/verification", {}, query),
|
|
443
|
-
/**
|
|
444
|
-
* The walk from the first entry to the head, a stretch a request, each
|
|
445
|
-
* as long as the server walks in one: the first stretch that fails, or
|
|
446
|
-
* the last. `onStretch` sees each verdict as it comes.
|
|
447
|
-
*/
|
|
448
|
-
verifyWhole: async (onStretch = () => {}) => {
|
|
449
|
-
for (let from = "start";;) {
|
|
450
|
-
const verdict = await call("GET /audit/verification", {}, { from });
|
|
451
|
-
onStretch(verdict);
|
|
452
|
-
if (!verdict.ok || verdict.next === void 0 || verdict.next === null) return verdict;
|
|
453
|
-
from = verdict.next;
|
|
454
|
-
}
|
|
455
|
-
},
|
|
456
469
|
/** What an escrowed key is checked against: public material, for admins and owners of the whole instance. */
|
|
457
|
-
keys: () => call("GET /audit/keys", {})
|
|
458
|
-
/**
|
|
459
|
-
* Accept that entries `from` to `to` are lost for good, as an Owner of
|
|
460
|
-
* the whole instance: the audit watch's finding, inside the range, stays
|
|
461
|
-
* in the log, and its anchor goes on past them.
|
|
462
|
-
*/
|
|
463
|
-
acceptLoss: (range) => call("POST /audit/loss", {}, range)
|
|
470
|
+
keys: () => call("GET /audit/keys", {})
|
|
464
471
|
}
|
|
465
472
|
};
|
|
466
473
|
}
|
|
@@ -496,4 +503,4 @@ async function planImport(coffre, path, entries) {
|
|
|
496
503
|
};
|
|
497
504
|
}
|
|
498
505
|
//#endregion
|
|
499
|
-
export {
|
|
506
|
+
export { apiMember as a, byFolder as c, olderThan as d, Unreachable as f, judgeProofs as i, foldersOf as l, createClient as n, serviceName as o, unreachable as p, planImport as r, shownMember as s, CoffreError as t, ageInDays as u };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as CoffreError } from "./src-
|
|
1
|
+
import { t as CoffreError } from "./src-JtgcfCXD.js";
|
|
2
2
|
import { base64url, bodyDigest, bodyLine, contentDigest, createProof, declaredDigest, fromBase64url, generateProofKey, thumbprint } from "./dpop.js";
|
|
3
3
|
//#region src/workload-proofs.ts
|
|
4
4
|
/** `<audience>#jkt=<thumbprint>`: an audience only this key can use (section 4.2). */
|
|
@@ -338,7 +338,7 @@ function oidc(token, name = "oidc") {
|
|
|
338
338
|
* longer show it; the platform's store still holds it.
|
|
339
339
|
*/
|
|
340
340
|
function enrollment(code) {
|
|
341
|
-
if (code === void 0 || !code.startsWith("coffre_enr_")) throw new Error("enrollment(): no enrollment code:
|
|
341
|
+
if (code === void 0 || !code.startsWith("coffre_enr_")) throw new Error("enrollment(): no enrollment code: no release issues one yet (docs/workloads.md)");
|
|
342
342
|
const vars = globalThis.process?.env;
|
|
343
343
|
for (const [name, value] of Object.entries(vars ?? {})) if (value === code) delete vars[name];
|
|
344
344
|
return {
|
|
@@ -40,6 +40,15 @@ export declare function tunnelUrl(coffre: Workload, name: string): string;
|
|
|
40
40
|
export declare class TunnelStream extends Duplex {
|
|
41
41
|
#private;
|
|
42
42
|
constructor(coffre: Workload, url: string, WebSocketImpl: WebSocketClass);
|
|
43
|
+
/**
|
|
44
|
+
* As a socket's: `opening` until the WebSocket opens; then `open` while
|
|
45
|
+
* both ways are, `readOnly` once the app ended its side, `writeOnly`
|
|
46
|
+
* once coffre ended its own, and `closed` once neither is, or the stream
|
|
47
|
+
* was destroyed. A driver reads it to know whether to say goodbye and wait
|
|
48
|
+
* for the close: postgres.js ends only an open socket, and its `end()`
|
|
49
|
+
* waits for the `close` of any socket that is not closed.
|
|
50
|
+
*/
|
|
51
|
+
get readyState(): 'opening' | 'open' | 'readOnly' | 'writeOnly' | 'closed';
|
|
43
52
|
/** node-postgres connects its stream itself; this one is connecting already, and says so with `connect`. */
|
|
44
53
|
connect(): this;
|
|
45
54
|
setNoDelay(): this;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as upgradeRefused, r as upgradeHeaders } from "./workload-
|
|
1
|
+
import { i as upgradeRefused, r as upgradeHeaders } from "./workload-CkZoajvs.js";
|
|
2
2
|
import { Buffer } from "node:buffer";
|
|
3
3
|
import { Duplex } from "node:stream";
|
|
4
4
|
//#region src/workload-postgres.ts
|
|
@@ -98,6 +98,20 @@ var TunnelStream = class extends Duplex {
|
|
|
98
98
|
});
|
|
99
99
|
}, (error) => this.destroy(error));
|
|
100
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* As a socket's: `opening` until the WebSocket opens; then `open` while
|
|
103
|
+
* both ways are, `readOnly` once the app ended its side, `writeOnly`
|
|
104
|
+
* once coffre ended its own, and `closed` once neither is, or the stream
|
|
105
|
+
* was destroyed. A driver reads it to know whether to say goodbye and wait
|
|
106
|
+
* for the close: postgres.js ends only an open socket, and its `end()`
|
|
107
|
+
* waits for the `close` of any socket that is not closed.
|
|
108
|
+
*/
|
|
109
|
+
get readyState() {
|
|
110
|
+
if (this.destroyed) return "closed";
|
|
111
|
+
if (!this.#opened) return "opening";
|
|
112
|
+
if (this.readable && this.writable) return "open";
|
|
113
|
+
return this.readable ? "readOnly" : this.writable ? "writeOnly" : "closed";
|
|
114
|
+
}
|
|
101
115
|
/** node-postgres connects its stream itself; this one is connecting already, and says so with `connect`. */
|
|
102
116
|
connect() {
|
|
103
117
|
return this;
|
package/dist/workload.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { n as Sealed } from "./credential-DyAuH0om.js";
|
|
2
|
-
import { r as CoffreError } from "./index-
|
|
2
|
+
import { r as CoffreError } from "./index-DZZ3DRTO.js";
|
|
3
3
|
import { C as oidc, S as kubernetes, _ as enrollment, a as askedNonce, b as github, c as upgradeRefused, d as KUBERNETES_TOKEN, f as PlatformProof, g as azure, h as aws, i as WorkloadOptions, l as workload, m as ProofContext, n as UsedCredential, o as fromCoffre, p as Proof, r as Workload, s as upgradeHeaders, t as NarrowOptions, u as AwsCredentials, v as fly, w as vercel, x as keyAudience, y as gcp } from "./workload-w5EbGZgy.js";
|
|
4
4
|
export { type AwsCredentials, CoffreError, KUBERNETES_TOKEN, NarrowOptions, type PlatformProof, type Proof, type ProofContext, type Sealed, UsedCredential, Workload, WorkloadOptions, askedNonce, aws, azure, enrollment, fly, fromCoffre, gcp, github, keyAudience, kubernetes, oidc, upgradeHeaders, upgradeRefused, vercel, workload };
|
package/dist/workload.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { t as CoffreError } from "./src-
|
|
2
|
-
import { a as workload, c as azure, d as gcp, f as github, g as vercel, h as oidc, i as upgradeRefused, l as enrollment, m as kubernetes, n as fromCoffre, o as KUBERNETES_TOKEN, p as keyAudience, r as upgradeHeaders, s as aws, t as askedNonce, u as fly } from "./workload-
|
|
1
|
+
import { t as CoffreError } from "./src-JtgcfCXD.js";
|
|
2
|
+
import { a as workload, c as azure, d as gcp, f as github, g as vercel, h as oidc, i as upgradeRefused, l as enrollment, m as kubernetes, n as fromCoffre, o as KUBERNETES_TOKEN, p as keyAudience, r as upgradeHeaders, s as aws, t as askedNonce, u as fly } from "./workload-CkZoajvs.js";
|
|
3
3
|
export { CoffreError, KUBERNETES_TOKEN, askedNonce, aws, azure, enrollment, fly, fromCoffre, gcp, github, keyAudience, kubernetes, oidc, upgradeHeaders, upgradeRefused, vercel, workload };
|