@coffre/client 0.14.5 → 0.15.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-B2UlVqL3.d.ts} +129 -11
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/routes.d.ts +1 -1
- package/dist/routes.js +7 -0
- package/dist/{src-BCKSeCER.js → src-Dwhw_Cc4.js} +51 -3
- package/dist/{workload-BuKb9O4W.js → workload-BsyIQcko.js} +11 -5
- package/dist/workload-postgres.d.ts +10 -1
- package/dist/workload-postgres.js +22 -6
- package/dist/workload.d.ts +1 -1
- package/dist/workload.js +2 -2
- package/package.json +1 -1
- package/src/api.ts +68 -0
- package/src/audit.ts +16 -0
- package/src/index.ts +35 -1
- package/src/routes.ts +4 -0
- package/src/workload-postgres.ts +22 -5
- package/src/workload.ts +11 -4
|
@@ -51,6 +51,7 @@ type Api = {
|
|
|
51
51
|
};
|
|
52
52
|
};
|
|
53
53
|
credentialExpiresAt: string | null;
|
|
54
|
+
credentialId: string | null;
|
|
54
55
|
environments: {
|
|
55
56
|
project: string;
|
|
56
57
|
environment: string;
|
|
@@ -490,6 +491,11 @@ type Api = {
|
|
|
490
491
|
principalId: string;
|
|
491
492
|
toRotate: number;
|
|
492
493
|
}[];
|
|
494
|
+
reads?: {
|
|
495
|
+
through: string | null;
|
|
496
|
+
behind: boolean;
|
|
497
|
+
forged?: true;
|
|
498
|
+
};
|
|
493
499
|
};
|
|
494
500
|
};
|
|
495
501
|
"GET /members/:member": {
|
|
@@ -530,6 +536,11 @@ type Api = {
|
|
|
530
536
|
at: string;
|
|
531
537
|
}[];
|
|
532
538
|
rotated: number;
|
|
539
|
+
reads?: {
|
|
540
|
+
through: string | null;
|
|
541
|
+
behind: boolean;
|
|
542
|
+
forged?: true;
|
|
543
|
+
};
|
|
533
544
|
issuedTokens: {
|
|
534
545
|
id: string;
|
|
535
546
|
service: string;
|
|
@@ -675,6 +686,11 @@ type Api = {
|
|
|
675
686
|
at: string;
|
|
676
687
|
}[];
|
|
677
688
|
rotated: number;
|
|
689
|
+
reads?: {
|
|
690
|
+
through: string | null;
|
|
691
|
+
behind: boolean;
|
|
692
|
+
forged?: true;
|
|
693
|
+
};
|
|
678
694
|
issuedTokens: {
|
|
679
695
|
id: string;
|
|
680
696
|
service: string;
|
|
@@ -1120,12 +1136,16 @@ type Api = {
|
|
|
1120
1136
|
actor?: string;
|
|
1121
1137
|
decision?: "allow" | "deny";
|
|
1122
1138
|
detail?: "1" | "true";
|
|
1139
|
+
sealed?: "1" | "true";
|
|
1140
|
+
hidden?: "1" | "true";
|
|
1123
1141
|
before?: unknown;
|
|
1124
1142
|
limit?: unknown;
|
|
1125
1143
|
};
|
|
1126
1144
|
output: {
|
|
1127
1145
|
entries: {
|
|
1128
1146
|
seq: number;
|
|
1147
|
+
log: "0.14" | "0.15";
|
|
1148
|
+
forged?: true;
|
|
1129
1149
|
author: "app" | "vault";
|
|
1130
1150
|
occurredAt: string;
|
|
1131
1151
|
actorType: "service" | "system" | "user";
|
|
@@ -1148,6 +1168,7 @@ type Api = {
|
|
|
1148
1168
|
requestId: string | null;
|
|
1149
1169
|
run: null | {
|
|
1150
1170
|
exchangeSeq: number;
|
|
1171
|
+
log: "0.14" | "0.15";
|
|
1151
1172
|
claims: {
|
|
1152
1173
|
[key: string]: string | number;
|
|
1153
1174
|
};
|
|
@@ -1161,10 +1182,17 @@ type Api = {
|
|
|
1161
1182
|
};
|
|
1162
1183
|
}[];
|
|
1163
1184
|
more: boolean;
|
|
1185
|
+
next: string | null;
|
|
1164
1186
|
hidden?: {
|
|
1165
1187
|
action: string;
|
|
1166
1188
|
count: number;
|
|
1167
1189
|
}[];
|
|
1190
|
+
reads?: {
|
|
1191
|
+
through: string | null;
|
|
1192
|
+
behind: boolean;
|
|
1193
|
+
forged?: true;
|
|
1194
|
+
};
|
|
1195
|
+
readsOmitted?: "path" | "scope";
|
|
1168
1196
|
};
|
|
1169
1197
|
};
|
|
1170
1198
|
"GET /audit/verification": {
|
|
@@ -1720,6 +1748,37 @@ type Api = {
|
|
|
1720
1748
|
resumes: number | null;
|
|
1721
1749
|
};
|
|
1722
1750
|
};
|
|
1751
|
+
"GET /audit/trees": {
|
|
1752
|
+
input: undefined;
|
|
1753
|
+
output: {
|
|
1754
|
+
kept: false;
|
|
1755
|
+
} | {
|
|
1756
|
+
kept: true;
|
|
1757
|
+
ok: boolean;
|
|
1758
|
+
problems: string[];
|
|
1759
|
+
checkpoint: null | {
|
|
1760
|
+
upto: string;
|
|
1761
|
+
at: number;
|
|
1762
|
+
};
|
|
1763
|
+
unsealed: number;
|
|
1764
|
+
capped: boolean;
|
|
1765
|
+
};
|
|
1766
|
+
};
|
|
1767
|
+
"GET /audit/reads": {
|
|
1768
|
+
input: {
|
|
1769
|
+
from: string;
|
|
1770
|
+
};
|
|
1771
|
+
output: {
|
|
1772
|
+
kept: false;
|
|
1773
|
+
} | {
|
|
1774
|
+
kept: true;
|
|
1775
|
+
ok: boolean;
|
|
1776
|
+
problems: string[];
|
|
1777
|
+
through: string;
|
|
1778
|
+
listed: string;
|
|
1779
|
+
next: string | null;
|
|
1780
|
+
};
|
|
1781
|
+
};
|
|
1723
1782
|
};
|
|
1724
1783
|
type AccessValue = string | null | {
|
|
1725
1784
|
role: string;
|
|
@@ -1765,6 +1824,8 @@ type ApprovalView = {
|
|
|
1765
1824
|
};
|
|
1766
1825
|
type AuditEntryView = {
|
|
1767
1826
|
seq: number;
|
|
1827
|
+
log: "0.14" | "0.15";
|
|
1828
|
+
forged?: true;
|
|
1768
1829
|
author: "app" | "vault";
|
|
1769
1830
|
occurredAt: string;
|
|
1770
1831
|
actorType: "service" | "system" | "user";
|
|
@@ -1787,6 +1848,7 @@ type AuditEntryView = {
|
|
|
1787
1848
|
requestId: string | null;
|
|
1788
1849
|
run: null | {
|
|
1789
1850
|
exchangeSeq: number;
|
|
1851
|
+
log: "0.14" | "0.15";
|
|
1790
1852
|
claims: {
|
|
1791
1853
|
[key: string]: string | number;
|
|
1792
1854
|
};
|
|
@@ -2071,6 +2133,7 @@ type Me = {
|
|
|
2071
2133
|
};
|
|
2072
2134
|
};
|
|
2073
2135
|
credentialExpiresAt: string | null;
|
|
2136
|
+
credentialId: string | null;
|
|
2074
2137
|
environments: {
|
|
2075
2138
|
project: string;
|
|
2076
2139
|
environment: string;
|
|
@@ -2178,6 +2241,11 @@ type OffboardingReport = {
|
|
|
2178
2241
|
at: string;
|
|
2179
2242
|
}[];
|
|
2180
2243
|
rotated: number;
|
|
2244
|
+
reads?: {
|
|
2245
|
+
through: string | null;
|
|
2246
|
+
behind: boolean;
|
|
2247
|
+
forged?: true;
|
|
2248
|
+
};
|
|
2181
2249
|
issuedTokens: {
|
|
2182
2250
|
id: string;
|
|
2183
2251
|
service: string;
|
|
@@ -2488,6 +2556,17 @@ declare function ageInDays(entry: Pick<SecretKey, 'updatedAt'>, now?: number): n
|
|
|
2488
2556
|
*/
|
|
2489
2557
|
declare function olderThan(entry: Pick<SecretKey, 'archived' | 'updatedAt'>, days: number, now?: number): boolean;
|
|
2490
2558
|
//#endregion
|
|
2559
|
+
//#region src/audit.d.ts
|
|
2560
|
+
/** How the audit log's entries are said, to people: by the pages and the CLI alike. */
|
|
2561
|
+
/**
|
|
2562
|
+
* The CI run an entry was written for, as its issuer stated it at the
|
|
2563
|
+
* exchange: `acme/api run 7001 at 3f2a9c1`, a GitLab pipeline, or the
|
|
2564
|
+
* token's subject. Null for an entry no trust binding's credential wrote.
|
|
2565
|
+
*/
|
|
2566
|
+
declare function runLabel(run: {
|
|
2567
|
+
claims: Record<string, string | number>;
|
|
2568
|
+
} | null): string | null;
|
|
2569
|
+
//#endregion
|
|
2491
2570
|
//#region src/folders.d.ts
|
|
2492
2571
|
/**
|
|
2493
2572
|
* Rows grouped by folder, as every list shows them: those in no folder
|
|
@@ -2560,7 +2639,9 @@ declare class CoffreError extends Error {
|
|
|
2560
2639
|
readonly code: string;
|
|
2561
2640
|
/** The vault's own code when it refused: `no_grant`, `removed`, `bulk_limit`, ... */
|
|
2562
2641
|
readonly reason: string | undefined;
|
|
2563
|
-
|
|
2642
|
+
/** When to ask again, in seconds, when the answer says (`Retry-After`): a 503's, a 429's. */
|
|
2643
|
+
readonly retryAfter: string | undefined;
|
|
2644
|
+
constructor(status: number, code: string, message: string, reason?: string, retryAfter?: string);
|
|
2564
2645
|
}
|
|
2565
2646
|
type Args<K extends RouteKey> = RouteInput<K> extends undefined ? [params: Params<K>, input?: undefined] : Partial<RouteInput<K>> extends RouteInput<K> ? [params: Params<K>, input?: RouteInput<K>] : [params: Params<K>, input: RouteInput<K>];
|
|
2566
2647
|
/** A role's change confirmed: an instance role's, and the `revision` of the policy its preview answered with. */
|
|
@@ -2621,6 +2702,7 @@ declare function createClient(options: ClientOptions): {
|
|
|
2621
2702
|
};
|
|
2622
2703
|
};
|
|
2623
2704
|
credentialExpiresAt: string | null;
|
|
2705
|
+
credentialId: string | null;
|
|
2624
2706
|
environments: {
|
|
2625
2707
|
project: string;
|
|
2626
2708
|
environment: string;
|
|
@@ -2823,9 +2905,7 @@ declare function createClient(options: ClientOptions): {
|
|
|
2823
2905
|
versionId: string | null;
|
|
2824
2906
|
generated: null | {
|
|
2825
2907
|
recipe: string;
|
|
2826
|
-
pair
|
|
2827
|
-
/** Who I am, and every place I can reach. */
|
|
2828
|
-
/** Who I am, and every place I can reach. */ : {
|
|
2908
|
+
pair?: {
|
|
2829
2909
|
private: string;
|
|
2830
2910
|
public: string;
|
|
2831
2911
|
};
|
|
@@ -2980,6 +3060,11 @@ declare function createClient(options: ClientOptions): {
|
|
|
2980
3060
|
principalId: string;
|
|
2981
3061
|
toRotate: number;
|
|
2982
3062
|
}[];
|
|
3063
|
+
reads?: {
|
|
3064
|
+
through: string | null;
|
|
3065
|
+
behind: boolean;
|
|
3066
|
+
forged?: true;
|
|
3067
|
+
};
|
|
2983
3068
|
}>;
|
|
2984
3069
|
/** What they hold, and what to rotate if they leave. */
|
|
2985
3070
|
get: (member: string) => Promise<{
|
|
@@ -3018,6 +3103,11 @@ declare function createClient(options: ClientOptions): {
|
|
|
3018
3103
|
at: string;
|
|
3019
3104
|
}[];
|
|
3020
3105
|
rotated: number;
|
|
3106
|
+
reads?: {
|
|
3107
|
+
through: string | null;
|
|
3108
|
+
behind: boolean;
|
|
3109
|
+
forged?: true;
|
|
3110
|
+
};
|
|
3021
3111
|
issuedTokens: {
|
|
3022
3112
|
id: string;
|
|
3023
3113
|
service: string;
|
|
@@ -3168,6 +3258,11 @@ declare function createClient(options: ClientOptions): {
|
|
|
3168
3258
|
at: string;
|
|
3169
3259
|
}[];
|
|
3170
3260
|
rotated: number;
|
|
3261
|
+
reads?: {
|
|
3262
|
+
through: string | null;
|
|
3263
|
+
behind: boolean;
|
|
3264
|
+
forged?: true;
|
|
3265
|
+
};
|
|
3171
3266
|
issuedTokens: {
|
|
3172
3267
|
id: string;
|
|
3173
3268
|
service: string;
|
|
@@ -3303,16 +3398,14 @@ declare function createClient(options: ClientOptions): {
|
|
|
3303
3398
|
keyAudience?: true;
|
|
3304
3399
|
sessionHours?: number;
|
|
3305
3400
|
replicas?: number;
|
|
3306
|
-
sessionDays
|
|
3307
|
-
overlapMinutes?: number;
|
|
3308
|
-
mintedBy?
|
|
3309
|
-
/**
|
|
3401
|
+
sessionDays? /**
|
|
3310
3402
|
* The instance's roles, in two columns, an environment's that is not
|
|
3311
3403
|
* protected and one's that is (docs/design/roles.md). Any member lists
|
|
3312
3404
|
* them; an Owner of the whole instance edits them. `instance` is about
|
|
3313
3405
|
* instance roles, a person's across every project in their scope.
|
|
3314
|
-
*/
|
|
3315
|
-
|
|
3406
|
+
*/ : number;
|
|
3407
|
+
overlapMinutes?: number;
|
|
3408
|
+
mintedBy?: string;
|
|
3316
3409
|
approve?: true;
|
|
3317
3410
|
onContention?: "alert";
|
|
3318
3411
|
unsignedUploads?: true;
|
|
@@ -3689,6 +3782,8 @@ declare function createClient(options: ClientOptions): {
|
|
|
3689
3782
|
list: (query?: RouteInput<"GET /audit">) => Promise<{
|
|
3690
3783
|
entries: {
|
|
3691
3784
|
seq: number;
|
|
3785
|
+
log: "0.14" | "0.15";
|
|
3786
|
+
forged?: true;
|
|
3692
3787
|
author: "app" | "vault";
|
|
3693
3788
|
occurredAt: string;
|
|
3694
3789
|
actorType: "service" | "system" | "user";
|
|
@@ -3711,6 +3806,7 @@ declare function createClient(options: ClientOptions): {
|
|
|
3711
3806
|
requestId: string | null;
|
|
3712
3807
|
run: null | {
|
|
3713
3808
|
exchangeSeq: number;
|
|
3809
|
+
log: "0.14" | "0.15";
|
|
3714
3810
|
claims: {
|
|
3715
3811
|
[key: string]: string | number;
|
|
3716
3812
|
};
|
|
@@ -3724,10 +3820,17 @@ declare function createClient(options: ClientOptions): {
|
|
|
3724
3820
|
};
|
|
3725
3821
|
}[];
|
|
3726
3822
|
more: boolean;
|
|
3823
|
+
next: string | null;
|
|
3727
3824
|
hidden?: {
|
|
3728
3825
|
action: string;
|
|
3729
3826
|
count: number;
|
|
3730
3827
|
}[];
|
|
3828
|
+
reads?: {
|
|
3829
|
+
through: string | null;
|
|
3830
|
+
behind: boolean;
|
|
3831
|
+
forged?: true;
|
|
3832
|
+
};
|
|
3833
|
+
readsOmitted?: "path" | "scope";
|
|
3731
3834
|
}>;
|
|
3732
3835
|
/**
|
|
3733
3836
|
* Whether the log holds, from the newest checkpoint; or, with `from`, a
|
|
@@ -3777,6 +3880,21 @@ declare function createClient(options: ClientOptions): {
|
|
|
3777
3880
|
author: "app" | "vault";
|
|
3778
3881
|
reason: string;
|
|
3779
3882
|
}>;
|
|
3883
|
+
/**
|
|
3884
|
+
* Whether 0.15's log holds (the vault's `verifyTrees`): its newest signed
|
|
3885
|
+
* checkpoint and every entry since. `kept` false where the instance
|
|
3886
|
+
* keeps 0.14's log alone, a server older than 0.15 (no such route)
|
|
3887
|
+
* included.
|
|
3888
|
+
*/
|
|
3889
|
+
verifyTrees: () => Promise<RouteOutput<"GET /audit/trees">>;
|
|
3890
|
+
/**
|
|
3891
|
+
* The reads the audit pages list held to the uses 0.15's log sealed, a
|
|
3892
|
+
* stretch a request, from the first to as far as the projector has
|
|
3893
|
+
* listed: the first stretch that fails, or the last. `kept` false where
|
|
3894
|
+
* the instance keeps 0.14's log alone, a server older than 0.15 (no
|
|
3895
|
+
* such route) included.
|
|
3896
|
+
*/
|
|
3897
|
+
verifyReads: (onStretch?: (verdict: RouteOutput<"GET /audit/reads">) => void) => Promise<RouteOutput<"GET /audit/reads">>;
|
|
3780
3898
|
/** What an escrowed key is checked against: public material, for admins and owners of the whole instance. */
|
|
3781
3899
|
keys: () => Promise<{
|
|
3782
3900
|
app: {
|
|
@@ -3828,4 +3946,4 @@ declare function planImport(coffre: CoffreClient, path: string, entries: readonl
|
|
|
3828
3946
|
changes: Record<string, string>;
|
|
3829
3947
|
}>;
|
|
3830
3948
|
//#endregion
|
|
3831
|
-
export {
|
|
3949
|
+
export { RoleView as $, ConnectedApp as A, InheritResult as B, Api as C, AuthorizationView as D, AuthInfo as E, DryRunOutcome as F, MemberAccess as G, ListedReference as H, DryRunResult as I, PersonalConfig as J, MissingKey as K, EnvironmentView as L, Deletion as M, DeletionResult as N, BindingPlan as O, DismissedKey as P, RoleImpact as Q, IdentityRow as R, AccessValue as S, AuditEntryView as T, Me as U, KeysPlan as V, Member as W, ReferenceView as X, ProjectSummary as Y, RemovedMember as Z, byFolder as _, Params as a, TokenPlan as at, ageInDays as b, RouteOutput as c, planImport as d, RolesView as et, Unreachable as f, shownMember as g, serviceName as h, ImportAction as i, SetResult as it, Decision as j, BindingView as k, Transport as l, apiMember as m, CoffreClient as n, SecretVersion as nt, RouteInput as o, TokenRow as ot, unreachable as p, OffboardingReport as q, CoffreError as r, SessionRow as rt, RouteKey as s, WorkloadIds as st, ClientOptions as t, SecretKey as tt, createClient as u, foldersOf as v, ApprovalView as w, olderThan as x, runLabel as y, ImpactLine as z };
|
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 RoleView, A as ConnectedApp, B as InheritResult, C as Api, D as AuthorizationView, E as AuthInfo, F as DryRunOutcome, G as MemberAccess, H as ListedReference, I as DryRunResult, J as PersonalConfig, K as MissingKey, L as EnvironmentView, M as Deletion, N as DeletionResult, O as BindingPlan, P as DismissedKey, Q as RoleImpact, R as IdentityRow, S as AccessValue, T as AuditEntryView, U as Me, V as KeysPlan, W as Member, X as ReferenceView, Y as ProjectSummary, Z as RemovedMember, _ as byFolder, a as Params, at as TokenPlan, b as ageInDays, c as RouteOutput, d as planImport, et as RolesView, f as Unreachable, g as shownMember, h as serviceName, i as ImportAction, it as SetResult, j as Decision, k as BindingView, l as Transport, m as apiMember, n as CoffreClient, nt as SecretVersion, o as RouteInput, ot as TokenRow, p as unreachable, q as OffboardingReport, r as CoffreError, rt as SessionRow, s as RouteKey, st as WorkloadIds, t as ClientOptions, tt as SecretKey, u as createClient, v as foldersOf, w as ApprovalView, x as olderThan, y as runLabel, z as ImpactLine } from "./index-B2UlVqL3.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 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, runLabel, serviceName, shownMember, unreachable };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as serviceName, c as foldersOf, d as
|
|
2
|
-
export { CoffreError, Unreachable, ageInDays, apiMember, byFolder, createClient, foldersOf, olderThan, planImport, serviceName, shownMember, unreachable };
|
|
1
|
+
import { a as serviceName, c as foldersOf, d as olderThan, f as Unreachable, i as apiMember, l as runLabel, n as createClient, o as shownMember, p as unreachable, r as planImport, s as byFolder, t as CoffreError, u as ageInDays } from "./src-Dwhw_Cc4.js";
|
|
2
|
+
export { CoffreError, Unreachable, ageInDays, apiMember, byFolder, createClient, foldersOf, olderThan, planImport, runLabel, 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-B2UlVqL3.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
|
@@ -59,6 +59,11 @@ function getCalls({ places, secrets, members, services }) {
|
|
|
59
59
|
}
|
|
60
60
|
}],
|
|
61
61
|
"GET /audit/verification": [{ params: {} }],
|
|
62
|
+
"GET /audit/trees": [{ params: {} }],
|
|
63
|
+
"GET /audit/reads": [{
|
|
64
|
+
params: {},
|
|
65
|
+
input: { from: "start" }
|
|
66
|
+
}],
|
|
62
67
|
"GET /audit/keys": [{ params: {} }]
|
|
63
68
|
};
|
|
64
69
|
}
|
|
@@ -142,6 +147,8 @@ const EVERY_ROUTE = {
|
|
|
142
147
|
"DELETE /apps/:id": true,
|
|
143
148
|
"GET /audit": true,
|
|
144
149
|
"GET /audit/verification": true,
|
|
150
|
+
"GET /audit/trees": true,
|
|
151
|
+
"GET /audit/reads": true,
|
|
145
152
|
"GET /audit/keys": true,
|
|
146
153
|
"POST /audit/loss": true
|
|
147
154
|
};
|
|
@@ -65,6 +65,23 @@ function olderThan(entry, days, now = Date.now()) {
|
|
|
65
65
|
return !entry.archived && age !== null && age > days;
|
|
66
66
|
}
|
|
67
67
|
//#endregion
|
|
68
|
+
//#region src/audit.ts
|
|
69
|
+
/** How the audit log's entries are said, to people: by the pages and the CLI alike. */
|
|
70
|
+
/**
|
|
71
|
+
* The CI run an entry was written for, as its issuer stated it at the
|
|
72
|
+
* exchange: `acme/api run 7001 at 3f2a9c1`, a GitLab pipeline, or the
|
|
73
|
+
* token's subject. Null for an entry no trust binding's credential wrote.
|
|
74
|
+
*/
|
|
75
|
+
function runLabel(run) {
|
|
76
|
+
if (run === null) return null;
|
|
77
|
+
const { claims } = run;
|
|
78
|
+
const text = (name) => typeof claims[name] === "string" || typeof claims[name] === "number" ? String(claims[name]) : null;
|
|
79
|
+
const at = text("sha") === null ? "" : ` at ${text("sha").slice(0, 7)}`;
|
|
80
|
+
if (text("repository") !== null && text("run_id") !== null) return `${text("repository")} run ${text("run_id")}${at}`;
|
|
81
|
+
if (text("project_path") !== null && text("pipeline_id") !== null) return `${text("project_path")} pipeline ${text("pipeline_id")}${at}`;
|
|
82
|
+
return text("sub") === null ? "a CI run" : `CI run ${text("sub")}`;
|
|
83
|
+
}
|
|
84
|
+
//#endregion
|
|
68
85
|
//#region src/folders.ts
|
|
69
86
|
/**
|
|
70
87
|
* Rows grouped by folder, as every list shows them: those in no folder
|
|
@@ -111,12 +128,15 @@ var CoffreError = class extends Error {
|
|
|
111
128
|
code;
|
|
112
129
|
/** The vault's own code when it refused: `no_grant`, `removed`, `bulk_limit`, ... */
|
|
113
130
|
reason;
|
|
114
|
-
|
|
131
|
+
/** When to ask again, in seconds, when the answer says (`Retry-After`): a 503's, a 429's. */
|
|
132
|
+
retryAfter;
|
|
133
|
+
constructor(status, code, message, reason, retryAfter) {
|
|
115
134
|
super(message);
|
|
116
135
|
this.name = "CoffreError";
|
|
117
136
|
this.status = status;
|
|
118
137
|
this.code = code;
|
|
119
138
|
this.reason = reason;
|
|
139
|
+
this.retryAfter = retryAfter;
|
|
120
140
|
}
|
|
121
141
|
};
|
|
122
142
|
/** `market/prod/KEY` as route parameters. */
|
|
@@ -159,7 +179,7 @@ function createClient(options) {
|
|
|
159
179
|
const payload = await response.json().catch(() => null);
|
|
160
180
|
if (!response.ok) {
|
|
161
181
|
const error = payload;
|
|
162
|
-
throw new CoffreError(response.status, typeof error?.error === "string" ? error.error : "http_error", typeof error?.message === "string" ? error.message : `request failed with status ${response.status}`, typeof error?.reason === "string" ? error.reason : void 0);
|
|
182
|
+
throw new CoffreError(response.status, typeof error?.error === "string" ? error.error : "http_error", typeof error?.message === "string" ? error.message : `request failed with status ${response.status}`, typeof error?.reason === "string" ? error.reason : void 0, response.headers.get("retry-after") ?? void 0);
|
|
163
183
|
}
|
|
164
184
|
return payload;
|
|
165
185
|
}
|
|
@@ -453,6 +473,34 @@ set: (member, access) => call("PATCH /access/:member", { member }, access) },
|
|
|
453
473
|
from = verdict.next;
|
|
454
474
|
}
|
|
455
475
|
},
|
|
476
|
+
/**
|
|
477
|
+
* Whether 0.15's log holds (the vault's `verifyTrees`): its newest signed
|
|
478
|
+
* checkpoint and every entry since. `kept` false where the instance
|
|
479
|
+
* keeps 0.14's log alone, a server older than 0.15 (no such route)
|
|
480
|
+
* included.
|
|
481
|
+
*/
|
|
482
|
+
verifyTrees: () => call("GET /audit/trees", {}).catch((error) => {
|
|
483
|
+
if (error instanceof CoffreError && error.status === 404) return { kept: false };
|
|
484
|
+
throw error;
|
|
485
|
+
}),
|
|
486
|
+
/**
|
|
487
|
+
* The reads the audit pages list held to the uses 0.15's log sealed, a
|
|
488
|
+
* stretch a request, from the first to as far as the projector has
|
|
489
|
+
* listed: the first stretch that fails, or the last. `kept` false where
|
|
490
|
+
* the instance keeps 0.14's log alone, a server older than 0.15 (no
|
|
491
|
+
* such route) included.
|
|
492
|
+
*/
|
|
493
|
+
verifyReads: async (onStretch = () => {}) => {
|
|
494
|
+
for (let from = "start";;) {
|
|
495
|
+
const verdict = await call("GET /audit/reads", {}, { from }).catch((error) => {
|
|
496
|
+
if (error instanceof CoffreError && error.status === 404) return { kept: false };
|
|
497
|
+
throw error;
|
|
498
|
+
});
|
|
499
|
+
onStretch(verdict);
|
|
500
|
+
if (!verdict.kept || !verdict.ok || verdict.next === null) return verdict;
|
|
501
|
+
from = verdict.next;
|
|
502
|
+
}
|
|
503
|
+
},
|
|
456
504
|
/** What an escrowed key is checked against: public material, for admins and owners of the whole instance. */
|
|
457
505
|
keys: () => call("GET /audit/keys", {}),
|
|
458
506
|
/**
|
|
@@ -496,4 +544,4 @@ async function planImport(coffre, path, entries) {
|
|
|
496
544
|
};
|
|
497
545
|
}
|
|
498
546
|
//#endregion
|
|
499
|
-
export { serviceName as a, foldersOf as c,
|
|
547
|
+
export { serviceName as a, foldersOf as c, olderThan as d, Unreachable as f, apiMember as i, runLabel as l, createClient as n, shownMember as o, unreachable as p, planImport as r, byFolder 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-Dwhw_Cc4.js";
|
|
2
2
|
import { base64url, bodyDigest, bodyLine, contentDigest, createProof, declaredDigest, 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). */
|
|
@@ -371,7 +371,8 @@ const sleep$1 = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
|
371
371
|
* or its session awaits approval (10), and after a spent projected token,
|
|
372
372
|
* once the kubelet writes the next;
|
|
373
373
|
* - renewal at half-life, every 30 seconds for an enrollment session, whose
|
|
374
|
-
* expiry is its liveness
|
|
374
|
+
* expiry is its liveness, and none for a session already at its hard end
|
|
375
|
+
* (a projected token's), which only a new proof outlives; a fresh proof, with the same key, before the
|
|
375
376
|
* session's hard end, `notAfter`; and a new session whenever the old one
|
|
376
377
|
* is lost (revoked, frozen, expired while the process slept);
|
|
377
378
|
* - each request under `<url>/use/` signed whole (method, URL, query, the
|
|
@@ -535,10 +536,15 @@ async function workload(options) {
|
|
|
535
536
|
timers[which] = setTimeout(() => void run(), Math.max(0, when - Date.now()));
|
|
536
537
|
timers[which].unref?.();
|
|
537
538
|
};
|
|
538
|
-
/** Renew at half-life, or every 30 seconds for an enrollment
|
|
539
|
-
const
|
|
539
|
+
/** Renew at half-life, or every 30 seconds for an enrollment, while the session's end can still move: one already at its hard end, as a projected token's is, only the next proof replaces. */
|
|
540
|
+
const planRenewal = (held) => {
|
|
541
|
+
if (held.expiresAt >= held.notAfter) return clearTimeout(timers.renew);
|
|
540
542
|
const now = Date.now();
|
|
541
543
|
at("renew", enrolled ? now + ENROLLMENT_RENEW_MS : now + Math.max(1e3, (held.expiresAt - now) / 2), renew);
|
|
544
|
+
};
|
|
545
|
+
/** Renew as `planRenewal` says; prove again at 90% of the way to `notAfter`. */
|
|
546
|
+
const plan = (held) => {
|
|
547
|
+
planRenewal(held);
|
|
542
548
|
if (!enrolled) at("prove", held.notAfter - (held.notAfter - held.issuedAt) / 10, () => prove().catch(() => void 0));
|
|
543
549
|
};
|
|
544
550
|
/** A new session, with a fresh proof and the same key: requests in flight finish on the old one. Retried with backoff while it fails, unless it cannot change. */
|
|
@@ -577,7 +583,7 @@ async function workload(options) {
|
|
|
577
583
|
const { response, body } = await api("/api/auth/workload/renew", held.token);
|
|
578
584
|
if (response.ok && typeof body?.expiresAt === "string") {
|
|
579
585
|
held.expiresAt = Date.parse(body.expiresAt);
|
|
580
|
-
if (session === held)
|
|
586
|
+
if (session === held) planRenewal(held);
|
|
581
587
|
return;
|
|
582
588
|
}
|
|
583
589
|
if (response.status !== 401 && response.status !== 403 || askedNonce(response)) throw new Error(`renewal answered ${response.status}`);
|
|
@@ -25,7 +25,7 @@ export type WebSocketClass = new (url: string, options: {
|
|
|
25
25
|
headers: Record<string, string>;
|
|
26
26
|
}) => TunnelSocket;
|
|
27
27
|
/**
|
|
28
|
-
* A stream to the database behind the tunnel `name`, which
|
|
28
|
+
* A stream to the database behind the tunnel `name`, which the app's driver
|
|
29
29
|
* connects, writes and ends as it would a socket.
|
|
30
30
|
*/
|
|
31
31
|
export declare function connect(coffre: Workload, name: string, options?: {
|
|
@@ -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,17 +1,19 @@
|
|
|
1
|
-
import { i as upgradeRefused, r as upgradeHeaders } from "./workload-
|
|
1
|
+
import { i as upgradeRefused, r as upgradeHeaders } from "./workload-BsyIQcko.js";
|
|
2
2
|
import { Buffer } from "node:buffer";
|
|
3
3
|
import { Duplex } from "node:stream";
|
|
4
4
|
//#region src/workload-postgres.ts
|
|
5
5
|
/**
|
|
6
6
|
* Postgres from a workload, through coffre's tunnel (docs/design/workload-access.md,
|
|
7
|
-
* section 9.1): a stream
|
|
8
|
-
* tunnel's WebSocket and signed by the session. No listener, no password,
|
|
7
|
+
* section 9.1): a stream the app's driver takes as its socket, carried over
|
|
8
|
+
* the tunnel's WebSocket and signed by the session. No listener, no password,
|
|
9
9
|
* and no database URL in the app: coffre logs in to the database.
|
|
10
10
|
*
|
|
11
|
-
* import
|
|
11
|
+
* import postgres from 'postgres';
|
|
12
12
|
* import { connect } from '@coffre/client/workload/postgres';
|
|
13
13
|
*
|
|
14
|
-
* const
|
|
14
|
+
* const sql = postgres({ socket: () => connect(coffre, 'db') });
|
|
15
|
+
*
|
|
16
|
+
* node-postgres takes it as its stream: `new pg.Pool({ stream: () => connect(coffre, 'db') })`.
|
|
15
17
|
*
|
|
16
18
|
* The WebSocket is the runtime's own (`globalThis.WebSocket`: Node 22 and
|
|
17
19
|
* later, Deno, Bun), which takes the upgrade's headers; on Node 20, pass the
|
|
@@ -35,7 +37,7 @@ const FRAME = 65536;
|
|
|
35
37
|
/** How often an open connection says it is there, so that an idle one outlives Cloudflare's 100-second timeout. */
|
|
36
38
|
const KEEPALIVE_MS = 3e4;
|
|
37
39
|
/**
|
|
38
|
-
* A stream to the database behind the tunnel `name`, which
|
|
40
|
+
* A stream to the database behind the tunnel `name`, which the app's driver
|
|
39
41
|
* connects, writes and ends as it would a socket.
|
|
40
42
|
*/
|
|
41
43
|
function connect(coffre, name, options = {}) {
|
|
@@ -98,6 +100,20 @@ var TunnelStream = class extends Duplex {
|
|
|
98
100
|
});
|
|
99
101
|
}, (error) => this.destroy(error));
|
|
100
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* As a socket's: `opening` until the WebSocket opens; then `open` while
|
|
105
|
+
* both ways are, `readOnly` once the app ended its side, `writeOnly`
|
|
106
|
+
* once coffre ended its own, and `closed` once neither is, or the stream
|
|
107
|
+
* was destroyed. A driver reads it to know whether to say goodbye and wait
|
|
108
|
+
* for the close: postgres.js ends only an open socket, and its `end()`
|
|
109
|
+
* waits for the `close` of any socket that is not closed.
|
|
110
|
+
*/
|
|
111
|
+
get readyState() {
|
|
112
|
+
if (this.destroyed) return "closed";
|
|
113
|
+
if (!this.#opened) return "opening";
|
|
114
|
+
if (this.readable && this.writable) return "open";
|
|
115
|
+
return this.readable ? "readOnly" : this.writable ? "writeOnly" : "closed";
|
|
116
|
+
}
|
|
101
117
|
/** node-postgres connects its stream itself; this one is connecting already, and says so with `connect`. */
|
|
102
118
|
connect() {
|
|
103
119
|
return this;
|
package/dist/workload.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { r as CoffreError } from "./index-
|
|
1
|
+
import { r as CoffreError } from "./index-B2UlVqL3.js";
|
|
2
2
|
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-DwWrQQg1.js";
|
|
3
3
|
export { type AwsCredentials, CoffreError, KUBERNETES_TOKEN, NarrowOptions, type PlatformProof, type Proof, type ProofContext, 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-Dwhw_Cc4.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-BsyIQcko.js";
|
|
3
3
|
export { CoffreError, KUBERNETES_TOKEN, askedNonce, aws, azure, enrollment, fly, fromCoffre, gcp, github, keyAudience, kubernetes, oidc, upgradeHeaders, upgradeRefused, vercel, workload };
|
package/package.json
CHANGED
package/src/api.ts
CHANGED
|
@@ -54,6 +54,7 @@ export type Api = {
|
|
|
54
54
|
};
|
|
55
55
|
};
|
|
56
56
|
credentialExpiresAt: string | null;
|
|
57
|
+
credentialId: string | null;
|
|
57
58
|
environments: {
|
|
58
59
|
project: string;
|
|
59
60
|
environment: string;
|
|
@@ -493,6 +494,11 @@ export type Api = {
|
|
|
493
494
|
principalId: string;
|
|
494
495
|
toRotate: number;
|
|
495
496
|
}[];
|
|
497
|
+
reads?: {
|
|
498
|
+
through: string | null;
|
|
499
|
+
behind: boolean;
|
|
500
|
+
forged?: true;
|
|
501
|
+
};
|
|
496
502
|
};
|
|
497
503
|
};
|
|
498
504
|
"GET /members/:member": {
|
|
@@ -533,6 +539,11 @@ export type Api = {
|
|
|
533
539
|
at: string;
|
|
534
540
|
}[];
|
|
535
541
|
rotated: number;
|
|
542
|
+
reads?: {
|
|
543
|
+
through: string | null;
|
|
544
|
+
behind: boolean;
|
|
545
|
+
forged?: true;
|
|
546
|
+
};
|
|
536
547
|
issuedTokens: {
|
|
537
548
|
id: string;
|
|
538
549
|
service: string;
|
|
@@ -678,6 +689,11 @@ export type Api = {
|
|
|
678
689
|
at: string;
|
|
679
690
|
}[];
|
|
680
691
|
rotated: number;
|
|
692
|
+
reads?: {
|
|
693
|
+
through: string | null;
|
|
694
|
+
behind: boolean;
|
|
695
|
+
forged?: true;
|
|
696
|
+
};
|
|
681
697
|
issuedTokens: {
|
|
682
698
|
id: string;
|
|
683
699
|
service: string;
|
|
@@ -1123,12 +1139,16 @@ export type Api = {
|
|
|
1123
1139
|
actor?: string;
|
|
1124
1140
|
decision?: "allow" | "deny";
|
|
1125
1141
|
detail?: "1" | "true";
|
|
1142
|
+
sealed?: "1" | "true";
|
|
1143
|
+
hidden?: "1" | "true";
|
|
1126
1144
|
before?: unknown;
|
|
1127
1145
|
limit?: unknown;
|
|
1128
1146
|
};
|
|
1129
1147
|
output: {
|
|
1130
1148
|
entries: {
|
|
1131
1149
|
seq: number;
|
|
1150
|
+
log: "0.14" | "0.15";
|
|
1151
|
+
forged?: true;
|
|
1132
1152
|
author: "app" | "vault";
|
|
1133
1153
|
occurredAt: string;
|
|
1134
1154
|
actorType: "service" | "system" | "user";
|
|
@@ -1151,6 +1171,7 @@ export type Api = {
|
|
|
1151
1171
|
requestId: string | null;
|
|
1152
1172
|
run: null | {
|
|
1153
1173
|
exchangeSeq: number;
|
|
1174
|
+
log: "0.14" | "0.15";
|
|
1154
1175
|
claims: {
|
|
1155
1176
|
[key: string]: string | number;
|
|
1156
1177
|
};
|
|
@@ -1164,10 +1185,17 @@ export type Api = {
|
|
|
1164
1185
|
};
|
|
1165
1186
|
}[];
|
|
1166
1187
|
more: boolean;
|
|
1188
|
+
next: string | null;
|
|
1167
1189
|
hidden?: {
|
|
1168
1190
|
action: string;
|
|
1169
1191
|
count: number;
|
|
1170
1192
|
}[];
|
|
1193
|
+
reads?: {
|
|
1194
|
+
through: string | null;
|
|
1195
|
+
behind: boolean;
|
|
1196
|
+
forged?: true;
|
|
1197
|
+
};
|
|
1198
|
+
readsOmitted?: "path" | "scope";
|
|
1171
1199
|
};
|
|
1172
1200
|
};
|
|
1173
1201
|
"GET /audit/verification": {
|
|
@@ -1723,6 +1751,37 @@ export type Api = {
|
|
|
1723
1751
|
resumes: number | null;
|
|
1724
1752
|
};
|
|
1725
1753
|
};
|
|
1754
|
+
"GET /audit/trees": {
|
|
1755
|
+
input: undefined;
|
|
1756
|
+
output: {
|
|
1757
|
+
kept: false;
|
|
1758
|
+
} | {
|
|
1759
|
+
kept: true;
|
|
1760
|
+
ok: boolean;
|
|
1761
|
+
problems: string[];
|
|
1762
|
+
checkpoint: null | {
|
|
1763
|
+
upto: string;
|
|
1764
|
+
at: number;
|
|
1765
|
+
};
|
|
1766
|
+
unsealed: number;
|
|
1767
|
+
capped: boolean;
|
|
1768
|
+
};
|
|
1769
|
+
};
|
|
1770
|
+
"GET /audit/reads": {
|
|
1771
|
+
input: {
|
|
1772
|
+
from: string;
|
|
1773
|
+
};
|
|
1774
|
+
output: {
|
|
1775
|
+
kept: false;
|
|
1776
|
+
} | {
|
|
1777
|
+
kept: true;
|
|
1778
|
+
ok: boolean;
|
|
1779
|
+
problems: string[];
|
|
1780
|
+
through: string;
|
|
1781
|
+
listed: string;
|
|
1782
|
+
next: string | null;
|
|
1783
|
+
};
|
|
1784
|
+
};
|
|
1726
1785
|
};
|
|
1727
1786
|
|
|
1728
1787
|
export type AccessValue = string | null | {
|
|
@@ -1771,6 +1830,8 @@ export type ApprovalView = {
|
|
|
1771
1830
|
|
|
1772
1831
|
export type AuditEntryView = {
|
|
1773
1832
|
seq: number;
|
|
1833
|
+
log: "0.14" | "0.15";
|
|
1834
|
+
forged?: true;
|
|
1774
1835
|
author: "app" | "vault";
|
|
1775
1836
|
occurredAt: string;
|
|
1776
1837
|
actorType: "service" | "system" | "user";
|
|
@@ -1793,6 +1854,7 @@ export type AuditEntryView = {
|
|
|
1793
1854
|
requestId: string | null;
|
|
1794
1855
|
run: null | {
|
|
1795
1856
|
exchangeSeq: number;
|
|
1857
|
+
log: "0.14" | "0.15";
|
|
1796
1858
|
claims: {
|
|
1797
1859
|
[key: string]: string | number;
|
|
1798
1860
|
};
|
|
@@ -2093,6 +2155,7 @@ export type Me = {
|
|
|
2093
2155
|
};
|
|
2094
2156
|
};
|
|
2095
2157
|
credentialExpiresAt: string | null;
|
|
2158
|
+
credentialId: string | null;
|
|
2096
2159
|
environments: {
|
|
2097
2160
|
project: string;
|
|
2098
2161
|
environment: string;
|
|
@@ -2219,6 +2282,11 @@ export type OffboardingReport = {
|
|
|
2219
2282
|
at: string;
|
|
2220
2283
|
}[];
|
|
2221
2284
|
rotated: number;
|
|
2285
|
+
reads?: {
|
|
2286
|
+
through: string | null;
|
|
2287
|
+
behind: boolean;
|
|
2288
|
+
forged?: true;
|
|
2289
|
+
};
|
|
2222
2290
|
issuedTokens: {
|
|
2223
2291
|
id: string;
|
|
2224
2292
|
service: string;
|
package/src/audit.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** How the audit log's entries are said, to people: by the pages and the CLI alike. */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The CI run an entry was written for, as its issuer stated it at the
|
|
5
|
+
* exchange: `acme/api run 7001 at 3f2a9c1`, a GitLab pipeline, or the
|
|
6
|
+
* token's subject. Null for an entry no trust binding's credential wrote.
|
|
7
|
+
*/
|
|
8
|
+
export function runLabel(run: { claims: Record<string, string | number> } | null): string | null {
|
|
9
|
+
if (run === null) return null;
|
|
10
|
+
const { claims } = run;
|
|
11
|
+
const text = (name: string) => (typeof claims[name] === 'string' || typeof claims[name] === 'number' ? String(claims[name]) : null);
|
|
12
|
+
const at = text('sha') === null ? '' : ` at ${text('sha')!.slice(0, 7)}`;
|
|
13
|
+
if (text('repository') !== null && text('run_id') !== null) return `${text('repository')} run ${text('run_id')}${at}`;
|
|
14
|
+
if (text('project_path') !== null && text('pipeline_id') !== null) return `${text('project_path')} pipeline ${text('pipeline_id')}${at}`;
|
|
15
|
+
return text('sub') === null ? 'a CI run' : `CI run ${text('sub')}`;
|
|
16
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -57,6 +57,7 @@ export type {
|
|
|
57
57
|
} from './api.ts';
|
|
58
58
|
|
|
59
59
|
export { ageInDays, olderThan } from './age.ts';
|
|
60
|
+
export { runLabel } from './audit.ts';
|
|
60
61
|
export { byFolder, foldersOf } from './folders.ts';
|
|
61
62
|
export { apiMember, serviceName, shownMember } from './members.ts';
|
|
62
63
|
export { unreachable, Unreachable } from './reach.ts';
|
|
@@ -92,13 +93,16 @@ export class CoffreError extends Error {
|
|
|
92
93
|
readonly code: string;
|
|
93
94
|
/** The vault's own code when it refused: `no_grant`, `removed`, `bulk_limit`, ... */
|
|
94
95
|
readonly reason: string | undefined;
|
|
96
|
+
/** When to ask again, in seconds, when the answer says (`Retry-After`): a 503's, a 429's. */
|
|
97
|
+
readonly retryAfter: string | undefined;
|
|
95
98
|
|
|
96
|
-
constructor(status: number, code: string, message: string, reason?: string) {
|
|
99
|
+
constructor(status: number, code: string, message: string, reason?: string, retryAfter?: string) {
|
|
97
100
|
super(message);
|
|
98
101
|
this.name = 'CoffreError';
|
|
99
102
|
this.status = status;
|
|
100
103
|
this.code = code;
|
|
101
104
|
this.reason = reason;
|
|
105
|
+
this.retryAfter = retryAfter;
|
|
102
106
|
}
|
|
103
107
|
}
|
|
104
108
|
|
|
@@ -157,6 +161,7 @@ export function createClient(options: ClientOptions) {
|
|
|
157
161
|
typeof error?.error === 'string' ? error.error : 'http_error',
|
|
158
162
|
typeof error?.message === 'string' ? error.message : `request failed with status ${response.status}`,
|
|
159
163
|
typeof error?.reason === 'string' ? error.reason : undefined,
|
|
164
|
+
response.headers.get('retry-after') ?? undefined,
|
|
160
165
|
);
|
|
161
166
|
}
|
|
162
167
|
return payload;
|
|
@@ -477,6 +482,35 @@ export function createClient(options: ClientOptions) {
|
|
|
477
482
|
from = verdict.next;
|
|
478
483
|
}
|
|
479
484
|
},
|
|
485
|
+
/**
|
|
486
|
+
* Whether 0.15's log holds (the vault's `verifyTrees`): its newest signed
|
|
487
|
+
* checkpoint and every entry since. `kept` false where the instance
|
|
488
|
+
* keeps 0.14's log alone, a server older than 0.15 (no such route)
|
|
489
|
+
* included.
|
|
490
|
+
*/
|
|
491
|
+
verifyTrees: (): Promise<RouteOutput<'GET /audit/trees'>> =>
|
|
492
|
+
call('GET /audit/trees', {}).catch((error: unknown) => {
|
|
493
|
+
if (error instanceof CoffreError && error.status === 404) return { kept: false as const };
|
|
494
|
+
throw error;
|
|
495
|
+
}),
|
|
496
|
+
/**
|
|
497
|
+
* The reads the audit pages list held to the uses 0.15's log sealed, a
|
|
498
|
+
* stretch a request, from the first to as far as the projector has
|
|
499
|
+
* listed: the first stretch that fails, or the last. `kept` false where
|
|
500
|
+
* the instance keeps 0.14's log alone, a server older than 0.15 (no
|
|
501
|
+
* such route) included.
|
|
502
|
+
*/
|
|
503
|
+
verifyReads: async (onStretch: (verdict: RouteOutput<'GET /audit/reads'>) => void = () => {}): Promise<RouteOutput<'GET /audit/reads'>> => {
|
|
504
|
+
for (let from = 'start'; ;) {
|
|
505
|
+
const verdict: RouteOutput<'GET /audit/reads'> = await call('GET /audit/reads', {}, { from }).catch((error: unknown) => {
|
|
506
|
+
if (error instanceof CoffreError && error.status === 404) return { kept: false as const };
|
|
507
|
+
throw error;
|
|
508
|
+
});
|
|
509
|
+
onStretch(verdict);
|
|
510
|
+
if (!verdict.kept || !verdict.ok || verdict.next === null) return verdict;
|
|
511
|
+
from = verdict.next;
|
|
512
|
+
}
|
|
513
|
+
},
|
|
480
514
|
/** What an escrowed key is checked against: public material, for admins and owners of the whole instance. */
|
|
481
515
|
keys: () => call('GET /audit/keys', {}),
|
|
482
516
|
/**
|
package/src/routes.ts
CHANGED
|
@@ -56,6 +56,8 @@ export function getCalls({ places, secrets, members, services }: Subjects): GetC
|
|
|
56
56
|
'GET /apps': [{ params: {} }],
|
|
57
57
|
'GET /audit': [{ params: {}, input: { limit: 500 } }, { params: {}, input: { limit: 500, detail: '1' } }],
|
|
58
58
|
'GET /audit/verification': [{ params: {} }],
|
|
59
|
+
'GET /audit/trees': [{ params: {} }],
|
|
60
|
+
'GET /audit/reads': [{ params: {}, input: { from: 'start' } }],
|
|
59
61
|
'GET /audit/keys': [{ params: {} }],
|
|
60
62
|
};
|
|
61
63
|
}
|
|
@@ -140,6 +142,8 @@ const EVERY_ROUTE: { [K in RouteKey]: true } = {
|
|
|
140
142
|
'DELETE /apps/:id': true,
|
|
141
143
|
'GET /audit': true,
|
|
142
144
|
'GET /audit/verification': true,
|
|
145
|
+
'GET /audit/trees': true,
|
|
146
|
+
'GET /audit/reads': true,
|
|
143
147
|
'GET /audit/keys': true,
|
|
144
148
|
'POST /audit/loss': true,
|
|
145
149
|
};
|
package/src/workload-postgres.ts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Postgres from a workload, through coffre's tunnel (docs/design/workload-access.md,
|
|
3
|
-
* section 9.1): a stream
|
|
4
|
-
* tunnel's WebSocket and signed by the session. No listener, no password,
|
|
3
|
+
* section 9.1): a stream the app's driver takes as its socket, carried over
|
|
4
|
+
* the tunnel's WebSocket and signed by the session. No listener, no password,
|
|
5
5
|
* and no database URL in the app: coffre logs in to the database.
|
|
6
6
|
*
|
|
7
|
-
* import
|
|
7
|
+
* import postgres from 'postgres';
|
|
8
8
|
* import { connect } from '@coffre/client/workload/postgres';
|
|
9
9
|
*
|
|
10
|
-
* const
|
|
10
|
+
* const sql = postgres({ socket: () => connect(coffre, 'db') });
|
|
11
|
+
*
|
|
12
|
+
* node-postgres takes it as its stream: `new pg.Pool({ stream: () => connect(coffre, 'db') })`.
|
|
11
13
|
*
|
|
12
14
|
* The WebSocket is the runtime's own (`globalThis.WebSocket`: Node 22 and
|
|
13
15
|
* later, Deno, Bun), which takes the upgrade's headers; on Node 20, pass the
|
|
@@ -59,7 +61,7 @@ const FRAME = 64 * 1024;
|
|
|
59
61
|
const KEEPALIVE_MS = 30_000;
|
|
60
62
|
|
|
61
63
|
/**
|
|
62
|
-
* A stream to the database behind the tunnel `name`, which
|
|
64
|
+
* A stream to the database behind the tunnel `name`, which the app's driver
|
|
63
65
|
* connects, writes and ends as it would a socket.
|
|
64
66
|
*/
|
|
65
67
|
export function connect(coffre: Workload, name: string, options: { WebSocket?: WebSocketClass } = {}): TunnelStream {
|
|
@@ -128,6 +130,21 @@ export class TunnelStream extends Duplex {
|
|
|
128
130
|
);
|
|
129
131
|
}
|
|
130
132
|
|
|
133
|
+
/**
|
|
134
|
+
* As a socket's: `opening` until the WebSocket opens; then `open` while
|
|
135
|
+
* both ways are, `readOnly` once the app ended its side, `writeOnly`
|
|
136
|
+
* once coffre ended its own, and `closed` once neither is, or the stream
|
|
137
|
+
* was destroyed. A driver reads it to know whether to say goodbye and wait
|
|
138
|
+
* for the close: postgres.js ends only an open socket, and its `end()`
|
|
139
|
+
* waits for the `close` of any socket that is not closed.
|
|
140
|
+
*/
|
|
141
|
+
get readyState(): 'opening' | 'open' | 'readOnly' | 'writeOnly' | 'closed' {
|
|
142
|
+
if (this.destroyed) return 'closed';
|
|
143
|
+
if (!this.#opened) return 'opening';
|
|
144
|
+
if (this.readable && this.writable) return 'open';
|
|
145
|
+
return this.readable ? 'readOnly' : this.writable ? 'writeOnly' : 'closed';
|
|
146
|
+
}
|
|
147
|
+
|
|
131
148
|
/** node-postgres connects its stream itself; this one is connecting already, and says so with `connect`. */
|
|
132
149
|
connect(): this {
|
|
133
150
|
return this;
|
package/src/workload.ts
CHANGED
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
* or its session awaits approval (10), and after a spent projected token,
|
|
20
20
|
* once the kubelet writes the next;
|
|
21
21
|
* - renewal at half-life, every 30 seconds for an enrollment session, whose
|
|
22
|
-
* expiry is its liveness
|
|
22
|
+
* expiry is its liveness, and none for a session already at its hard end
|
|
23
|
+
* (a projected token's), which only a new proof outlives; a fresh proof, with the same key, before the
|
|
23
24
|
* session's hard end, `notAfter`; and a new session whenever the old one
|
|
24
25
|
* is lost (revoked, frozen, expired while the process slept);
|
|
25
26
|
* - each request under `<url>/use/` signed whole (method, URL, query, the
|
|
@@ -241,10 +242,16 @@ export async function workload(options: WorkloadOptions): Promise<Workload> {
|
|
|
241
242
|
(timers[which] as { unref?: () => void }).unref?.();
|
|
242
243
|
};
|
|
243
244
|
|
|
244
|
-
/** Renew at half-life, or every 30 seconds for an enrollment
|
|
245
|
-
const
|
|
245
|
+
/** Renew at half-life, or every 30 seconds for an enrollment, while the session's end can still move: one already at its hard end, as a projected token's is, only the next proof replaces. */
|
|
246
|
+
const planRenewal = (held: Session) => {
|
|
247
|
+
if (held.expiresAt >= held.notAfter) return clearTimeout(timers.renew);
|
|
246
248
|
const now = Date.now();
|
|
247
249
|
at('renew', enrolled ? now + ENROLLMENT_RENEW_MS : now + Math.max(1000, (held.expiresAt - now) / 2), renew);
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
/** Renew as `planRenewal` says; prove again at 90% of the way to `notAfter`. */
|
|
253
|
+
const plan = (held: Session) => {
|
|
254
|
+
planRenewal(held);
|
|
248
255
|
// An enrollment's `notAfter` is its code's end, which no new proof passes. A projected token's next is written at 80% of its life.
|
|
249
256
|
if (!enrolled) at('prove', held.notAfter - (held.notAfter - held.issuedAt) / 10, () => prove().catch(() => undefined));
|
|
250
257
|
};
|
|
@@ -293,7 +300,7 @@ export async function workload(options: WorkloadOptions): Promise<Workload> {
|
|
|
293
300
|
const { response, body } = await api('/api/auth/workload/renew', held.token);
|
|
294
301
|
if (response.ok && typeof body?.expiresAt === 'string') {
|
|
295
302
|
held.expiresAt = Date.parse(body.expiresAt);
|
|
296
|
-
if (session === held)
|
|
303
|
+
if (session === held) planRenewal(held);
|
|
297
304
|
return;
|
|
298
305
|
}
|
|
299
306
|
// Asked for a nonce once more, it says nothing of the session: tried again soon, as when coffre is out of reach.
|