@coffre/client 0.5.1 → 0.6.1

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.
@@ -10,7 +10,7 @@ type Api = {
10
10
  };
11
11
  registered: boolean;
12
12
  tampered: boolean;
13
- instanceRole: "admin" | "auditor" | "developer" | "member" | "owner" | "root-admin";
13
+ instanceRole: "admin" | "auditor" | "developer" | "member" | "owner";
14
14
  scope: {
15
15
  projects: "all" | {
16
16
  only: string[];
@@ -23,7 +23,6 @@ type Api = {
23
23
  except: string[];
24
24
  };
25
25
  };
26
- isRootAdmin: boolean;
27
26
  runsInstance: boolean;
28
27
  canReadAudit: boolean;
29
28
  setsUpServices: boolean;
@@ -234,6 +233,7 @@ type Api = {
234
233
  updatedAt: string | null;
235
234
  updatedBy: string | null;
236
235
  }[];
236
+ rotateAfterDays: number | null;
237
237
  };
238
238
  };
239
239
  "PATCH /secrets/:project/:environment": {
@@ -384,7 +384,7 @@ type Api = {
384
384
  member: string;
385
385
  principalType: "service" | "user";
386
386
  principalId: string;
387
- instanceRole: "admin" | "auditor" | "developer" | "member" | "owner" | "root-admin";
387
+ instanceRole: "admin" | "auditor" | "developer" | "member" | "owner";
388
388
  scope: null | {
389
389
  projects: "all" | {
390
390
  only: string[];
@@ -399,8 +399,8 @@ type Api = {
399
399
  };
400
400
  reachesByRole: boolean;
401
401
  managed: boolean;
402
- isRootAdmin: boolean;
403
402
  tampered: boolean;
403
+ declared: boolean;
404
404
  grants: {
405
405
  id: string;
406
406
  project: string;
@@ -424,7 +424,7 @@ type Api = {
424
424
  principalType: "service" | "user";
425
425
  principalId: string;
426
426
  status: "active" | "removed" | "tampered";
427
- instanceRole: "admin" | "auditor" | "developer" | "member" | "owner" | "root-admin";
427
+ instanceRole: "admin" | "auditor" | "developer" | "member" | "owner";
428
428
  scope: {
429
429
  projects: "all" | {
430
430
  only: string[];
@@ -437,7 +437,7 @@ type Api = {
437
437
  except: string[];
438
438
  };
439
439
  };
440
- isRootAdmin: boolean;
440
+ declared: boolean;
441
441
  removedAt: string | null;
442
442
  removedBy: string | null;
443
443
  live: {
@@ -506,6 +506,12 @@ type Api = {
506
506
  except: string[];
507
507
  };
508
508
  };
509
+ access?: {
510
+ [key: string]: "access-manager" | "auditor" | "developer" | "maintainer" | "owner" | "viewer" | null | {
511
+ role: "access-manager" | "auditor" | "developer" | "maintainer" | "owner" | "viewer";
512
+ until: string | null;
513
+ };
514
+ };
509
515
  };
510
516
  output: {
511
517
  member: string;
@@ -523,6 +529,9 @@ type Api = {
523
529
  };
524
530
  };
525
531
  created: boolean;
532
+ changes?: {
533
+ [key: string]: "created" | "revoked" | "unchanged" | "updated";
534
+ };
526
535
  };
527
536
  };
528
537
  "DELETE /members/:member": {
@@ -539,7 +548,7 @@ type Api = {
539
548
  principalType: "service" | "user";
540
549
  principalId: string;
541
550
  status: "active" | "removed" | "tampered";
542
- instanceRole: "admin" | "auditor" | "developer" | "member" | "owner" | "root-admin";
551
+ instanceRole: "admin" | "auditor" | "developer" | "member" | "owner";
543
552
  scope: {
544
553
  projects: "all" | {
545
554
  only: string[];
@@ -552,7 +561,7 @@ type Api = {
552
561
  except: string[];
553
562
  };
554
563
  };
555
- isRootAdmin: boolean;
564
+ declared: boolean;
556
565
  removedAt: string | null;
557
566
  removedBy: string | null;
558
567
  live: {
@@ -730,6 +739,9 @@ type Api = {
730
739
  github: string;
731
740
  repositoryId: string;
732
741
  ownerId: string;
742
+ } | {
743
+ github: string;
744
+ ownerId: string;
733
745
  } | {
734
746
  gitlab: string;
735
747
  projectId: string;
@@ -753,6 +765,23 @@ type Api = {
753
765
  changes: {
754
766
  [key: string]: "created" | "revoked" | "unchanged" | "updated";
755
767
  };
768
+ admitted?: {
769
+ created: boolean;
770
+ role: "admin" | "auditor" | "developer" | "member" | "owner";
771
+ scope: {
772
+ projects: "all" | {
773
+ only: string[];
774
+ } | {
775
+ except: string[];
776
+ };
777
+ environments: "all" | {
778
+ only: string[];
779
+ } | {
780
+ except: string[];
781
+ };
782
+ };
783
+ generation: number;
784
+ };
756
785
  };
757
786
  };
758
787
  "GET /sessions": {
@@ -1050,7 +1079,7 @@ type Api = {
1050
1079
  principalType: "service" | "user";
1051
1080
  principalId: string;
1052
1081
  status: "active" | "removed" | "tampered";
1053
- instanceRole: "admin" | "auditor" | "developer" | "member" | "owner" | "root-admin";
1082
+ instanceRole: "admin" | "auditor" | "developer" | "member" | "owner";
1054
1083
  scope: null | {
1055
1084
  projects: "all" | {
1056
1085
  only: string[];
@@ -1063,7 +1092,6 @@ type Api = {
1063
1092
  except: string[];
1064
1093
  };
1065
1094
  };
1066
- isRootAdmin: boolean;
1067
1095
  managed: boolean;
1068
1096
  grants: {
1069
1097
  id: string;
@@ -1123,6 +1151,25 @@ type Api = {
1123
1151
  };
1124
1152
  };
1125
1153
  };
1154
+ "GET /workloads/repositories": {
1155
+ input: undefined;
1156
+ output: {
1157
+ app: {
1158
+ name: string;
1159
+ installUrl: string;
1160
+ };
1161
+ installations: string[];
1162
+ repositories: {
1163
+ github: string;
1164
+ repositoryId: string;
1165
+ ownerId: string;
1166
+ private: boolean;
1167
+ }[];
1168
+ truncated: boolean;
1169
+ } | {
1170
+ app: null;
1171
+ };
1172
+ };
1126
1173
  };
1127
1174
  type AccessValue = "access-manager" | "auditor" | "developer" | "maintainer" | "owner" | "viewer" | null | {
1128
1175
  role: "access-manager" | "auditor" | "developer" | "maintainer" | "owner" | "viewer";
@@ -1329,6 +1376,9 @@ type WorkloadIds = {
1329
1376
  github: string;
1330
1377
  repositoryId: string;
1331
1378
  ownerId: string;
1379
+ } | {
1380
+ github: string;
1381
+ ownerId: string;
1332
1382
  } | {
1333
1383
  gitlab: string;
1334
1384
  projectId: string;
@@ -1362,7 +1412,7 @@ type Me = {
1362
1412
  };
1363
1413
  registered: boolean;
1364
1414
  tampered: boolean;
1365
- instanceRole: "admin" | "auditor" | "developer" | "member" | "owner" | "root-admin";
1415
+ instanceRole: "admin" | "auditor" | "developer" | "member" | "owner";
1366
1416
  scope: {
1367
1417
  projects: "all" | {
1368
1418
  only: string[];
@@ -1375,7 +1425,6 @@ type Me = {
1375
1425
  except: string[];
1376
1426
  };
1377
1427
  };
1378
- isRootAdmin: boolean;
1379
1428
  runsInstance: boolean;
1380
1429
  canReadAudit: boolean;
1381
1430
  setsUpServices: boolean;
@@ -1405,7 +1454,7 @@ type Member = {
1405
1454
  member: string;
1406
1455
  principalType: "service" | "user";
1407
1456
  principalId: string;
1408
- instanceRole: "admin" | "auditor" | "developer" | "member" | "owner" | "root-admin";
1457
+ instanceRole: "admin" | "auditor" | "developer" | "member" | "owner";
1409
1458
  scope: null | {
1410
1459
  projects: "all" | {
1411
1460
  only: string[];
@@ -1420,8 +1469,8 @@ type Member = {
1420
1469
  };
1421
1470
  reachesByRole: boolean;
1422
1471
  managed: boolean;
1423
- isRootAdmin: boolean;
1424
1472
  tampered: boolean;
1473
+ declared: boolean;
1425
1474
  grants: {
1426
1475
  id: string;
1427
1476
  project: string;
@@ -1437,7 +1486,7 @@ type MemberAccess = {
1437
1486
  principalType: "service" | "user";
1438
1487
  principalId: string;
1439
1488
  status: "active" | "removed" | "tampered";
1440
- instanceRole: "admin" | "auditor" | "developer" | "member" | "owner" | "root-admin";
1489
+ instanceRole: "admin" | "auditor" | "developer" | "member" | "owner";
1441
1490
  scope: null | {
1442
1491
  projects: "all" | {
1443
1492
  only: string[];
@@ -1450,7 +1499,6 @@ type MemberAccess = {
1450
1499
  except: string[];
1451
1500
  };
1452
1501
  };
1453
- isRootAdmin: boolean;
1454
1502
  managed: boolean;
1455
1503
  grants: {
1456
1504
  id: string;
@@ -1471,7 +1519,7 @@ type OffboardingReport = {
1471
1519
  principalType: "service" | "user";
1472
1520
  principalId: string;
1473
1521
  status: "active" | "removed" | "tampered";
1474
- instanceRole: "admin" | "auditor" | "developer" | "member" | "owner" | "root-admin";
1522
+ instanceRole: "admin" | "auditor" | "developer" | "member" | "owner";
1475
1523
  scope: {
1476
1524
  projects: "all" | {
1477
1525
  only: string[];
@@ -1484,7 +1532,7 @@ type OffboardingReport = {
1484
1532
  except: string[];
1485
1533
  };
1486
1534
  };
1487
- isRootAdmin: boolean;
1535
+ declared: boolean;
1488
1536
  removedAt: string | null;
1489
1537
  removedBy: string | null;
1490
1538
  live: {
@@ -1654,6 +1702,19 @@ type TokenPlan = {
1654
1702
  };
1655
1703
  };
1656
1704
  //#endregion
1705
+ //#region src/age.d.ts
1706
+ /**
1707
+ * Whole days since a key's value was written (`updatedAt`, a reference's
1708
+ * source's): 0 on the day it was. Null while it reads no value.
1709
+ */
1710
+ declare function ageInDays(entry: Pick<SecretKey, 'updatedAt'>, now?: number): number | null;
1711
+ /**
1712
+ * Whether a key's value has gone unchanged for more than `days` whole days:
1713
+ * against the deployment's `rotateAfterDays`, due for rotation. An archived
1714
+ * key, which nothing reads, and a key with no value never are.
1715
+ */
1716
+ declare function olderThan(entry: Pick<SecretKey, 'archived' | 'updatedAt'>, days: number, now?: number): boolean;
1717
+ //#endregion
1657
1718
  //#region src/folders.d.ts
1658
1719
  /**
1659
1720
  * Rows grouped by folder, as every list shows them: those in no folder
@@ -1741,7 +1802,7 @@ declare function createClient(options: ClientOptions): {
1741
1802
  };
1742
1803
  registered: boolean;
1743
1804
  tampered: boolean;
1744
- instanceRole: "admin" | "auditor" | "developer" | "member" | "owner" | "root-admin";
1805
+ instanceRole: "admin" | "auditor" | "developer" | "member" | "owner";
1745
1806
  scope: {
1746
1807
  projects: "all" | {
1747
1808
  only: string[];
@@ -1754,7 +1815,6 @@ declare function createClient(options: ClientOptions): {
1754
1815
  except: string[];
1755
1816
  };
1756
1817
  };
1757
- isRootAdmin: boolean;
1758
1818
  runsInstance: boolean;
1759
1819
  canReadAudit: boolean;
1760
1820
  setsUpServices: boolean;
@@ -1886,7 +1946,7 @@ declare function createClient(options: ClientOptions): {
1886
1946
  stranded: string[];
1887
1947
  };
1888
1948
  }>;
1889
- /** The keys its sibling environments have and it lacks, those you can see, and those its team dismissed. */
1949
+ /** The keys its sibling environments have and it lacks, read or not, and those its team dismissed. */
1890
1950
  missing: (path: string) => Promise<{
1891
1951
  missing: {
1892
1952
  key: string;
@@ -1933,6 +1993,7 @@ declare function createClient(options: ClientOptions): {
1933
1993
  updatedAt: string | null;
1934
1994
  updatedBy: string | null;
1935
1995
  }[];
1996
+ rotateAfterDays: number | null;
1936
1997
  }>;
1937
1998
  /** Decrypts one secret, or every secret in an environment. Logged in your name. */
1938
1999
  reveal: (path: string) => Promise<{
@@ -2020,7 +2081,7 @@ declare function createClient(options: ClientOptions): {
2020
2081
  member: string;
2021
2082
  principalType: "service" | "user";
2022
2083
  principalId: string;
2023
- instanceRole: "admin" | "auditor" | "developer" | "member" | "owner" | "root-admin";
2084
+ instanceRole: "admin" | "auditor" | "developer" | "member" | "owner";
2024
2085
  scope: null | {
2025
2086
  projects: "all" | {
2026
2087
  only: string[];
@@ -2035,8 +2096,8 @@ declare function createClient(options: ClientOptions): {
2035
2096
  };
2036
2097
  reachesByRole: boolean;
2037
2098
  managed: boolean;
2038
- isRootAdmin: boolean;
2039
2099
  tampered: boolean;
2100
+ declared: boolean;
2040
2101
  grants: {
2041
2102
  id: string;
2042
2103
  project: string;
@@ -2058,7 +2119,7 @@ declare function createClient(options: ClientOptions): {
2058
2119
  principalType: "service" | "user";
2059
2120
  principalId: string;
2060
2121
  status: "active" | "removed" | "tampered";
2061
- instanceRole: "admin" | "auditor" | "developer" | "member" | "owner" | "root-admin";
2122
+ instanceRole: "admin" | "auditor" | "developer" | "member" | "owner";
2062
2123
  scope: {
2063
2124
  projects: "all" | {
2064
2125
  only: string[];
@@ -2071,7 +2132,7 @@ declare function createClient(options: ClientOptions): {
2071
2132
  except: string[];
2072
2133
  };
2073
2134
  };
2074
- isRootAdmin: boolean;
2135
+ declared: boolean;
2075
2136
  removedAt: string | null;
2076
2137
  removedBy: string | null;
2077
2138
  live: {
@@ -2130,7 +2191,7 @@ declare function createClient(options: ClientOptions): {
2130
2191
  principalType: "service" | "user";
2131
2192
  principalId: string;
2132
2193
  status: "active" | "removed" | "tampered";
2133
- instanceRole: "admin" | "auditor" | "developer" | "member" | "owner" | "root-admin";
2194
+ instanceRole: "admin" | "auditor" | "developer" | "member" | "owner";
2134
2195
  scope: null | {
2135
2196
  projects: "all" | {
2136
2197
  only: string[];
@@ -2143,7 +2204,6 @@ declare function createClient(options: ClientOptions): {
2143
2204
  except: string[];
2144
2205
  };
2145
2206
  };
2146
- isRootAdmin: boolean;
2147
2207
  managed: boolean;
2148
2208
  grants: {
2149
2209
  id: string;
@@ -2171,6 +2231,9 @@ declare function createClient(options: ClientOptions): {
2171
2231
  };
2172
2232
  };
2173
2233
  created: boolean;
2234
+ changes?: {
2235
+ [key: string]: "created" | "revoked" | "unchanged" | "updated";
2236
+ };
2174
2237
  }>;
2175
2238
  /** Offboards; returns what to rotate. */
2176
2239
  remove: (member: string) => Promise<{
@@ -2185,7 +2248,7 @@ declare function createClient(options: ClientOptions): {
2185
2248
  principalType: "service" | "user";
2186
2249
  principalId: string;
2187
2250
  status: "active" | "removed" | "tampered";
2188
- instanceRole: "admin" | "auditor" | "developer" | "member" | "owner" | "root-admin";
2251
+ instanceRole: "admin" | "auditor" | "developer" | "member" | "owner";
2189
2252
  scope: {
2190
2253
  projects: "all" | {
2191
2254
  only: string[];
@@ -2198,7 +2261,7 @@ declare function createClient(options: ClientOptions): {
2198
2261
  except: string[];
2199
2262
  };
2200
2263
  };
2201
- isRootAdmin: boolean;
2264
+ declared: boolean;
2202
2265
  removedAt: string | null;
2203
2266
  removedBy: string | null;
2204
2267
  live: {
@@ -2308,16 +2371,36 @@ declare function createClient(options: ClientOptions): {
2308
2371
  remove: (member: string, id: string) => Promise<{
2309
2372
  unbound: true;
2310
2373
  }>;
2311
- /** A public GitHub repository's or GitLab project's IDs, which bindings name. */
2374
+ /** 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. */
2312
2375
  lookup: (input: RouteInput<"GET /workloads/lookup">) => Promise<{
2313
2376
  github: string;
2314
2377
  repositoryId: string;
2315
2378
  ownerId: string;
2379
+ } | {
2380
+ github: string;
2381
+ ownerId: string;
2316
2382
  } | {
2317
2383
  gitlab: string;
2318
2384
  projectId: string;
2319
2385
  namespaceId: string;
2320
2386
  }>;
2387
+ /** The repositories the deployment's GitHub App is installed on, private ones too; `{ app: null }` without one. */
2388
+ repositories: () => Promise<{
2389
+ app: {
2390
+ name: string;
2391
+ installUrl: string;
2392
+ };
2393
+ installations: string[];
2394
+ repositories: {
2395
+ github: string;
2396
+ repositoryId: string;
2397
+ ownerId: string;
2398
+ private: boolean;
2399
+ }[];
2400
+ truncated: boolean;
2401
+ } | {
2402
+ app: null;
2403
+ }>;
2321
2404
  };
2322
2405
  access: {
2323
2406
  /** What they should hold at each place; the server applies the difference. `null` revokes. */
@@ -2325,6 +2408,23 @@ declare function createClient(options: ClientOptions): {
2325
2408
  changes: {
2326
2409
  [key: string]: "created" | "revoked" | "unchanged" | "updated";
2327
2410
  };
2411
+ admitted?: {
2412
+ created: boolean;
2413
+ role: "admin" | "auditor" | "developer" | "member" | "owner";
2414
+ scope: {
2415
+ projects: "all" | {
2416
+ only: string[];
2417
+ } | {
2418
+ except: string[];
2419
+ };
2420
+ environments: "all" | {
2421
+ only: string[];
2422
+ } | {
2423
+ except: string[];
2424
+ };
2425
+ };
2426
+ generation: number;
2427
+ };
2328
2428
  }>;
2329
2429
  };
2330
2430
  /** Where I am signed in. Only where coffre runs its own sign-in. */
@@ -2598,7 +2698,7 @@ declare function createClient(options: ClientOptions): {
2598
2698
  author: "app" | "vault";
2599
2699
  reason: string;
2600
2700
  }>;
2601
- /** What an escrowed key is checked against: public material, owners and root admins only. */
2701
+ /** What an escrowed key is checked against: public material, for admins and owners of the whole instance. */
2602
2702
  keys: () => Promise<{
2603
2703
  app: {
2604
2704
  keyId: string;
@@ -2640,4 +2740,4 @@ declare function planImport(coffre: CoffreClient, path: string, entries: readonl
2640
2740
  changes: Record<string, string>;
2641
2741
  }>;
2642
2742
  //#endregion
2643
- export { DeletionResult as A, OffboardingReport as B, AuthInfo as C, ConnectedApp as D, BindingView as E, ListedReference as F, SecretVersion as G, ReferenceView as H, Me as I, SetResult as J, ServiceTokenRow as K, Member as L, DryRunOutcome as M, DryRunResult as N, Decision as O, IdentityRow as P, MemberAccess as R, AuditEntryView as S, BindingPlan as T, RemovedMember as U, ProjectSummary as V, SecretKey as W, WorkloadIds as X, TokenPlan as Y, byFolder as _, Params as a, Api as b, RouteOutput as c, planImport as d, Unreachable as f, shownMember as g, serviceName as h, ImportAction as i, DismissedKey as j, Deletion as k, Transport as l, apiMember as m, CoffreClient as n, RouteInput as o, unreachable as p, SessionRow as q, CoffreError as r, RouteKey as s, ClientOptions as t, createClient as u, foldersOf as v, AuthorizationView as w, ApprovalView as x, AccessValue as y, MissingKey as z };
2743
+ export { Decision as A, MemberAccess as B, ApprovalView as C, BindingPlan as D, AuthorizationView as E, DryRunResult as F, RemovedMember as G, OffboardingReport as H, IdentityRow as I, ServiceTokenRow as J, SecretKey as K, ListedReference as L, DeletionResult as M, DismissedKey as N, BindingView as O, DryRunOutcome as P, WorkloadIds as Q, Me as R, Api as S, AuthInfo as T, ProjectSummary as U, MissingKey as V, ReferenceView as W, SetResult as X, SessionRow as Y, TokenPlan as Z, byFolder as _, Params as a, olderThan as b, RouteOutput as c, planImport as d, Unreachable as f, shownMember as g, serviceName as h, ImportAction as i, Deletion as j, ConnectedApp as k, Transport as l, apiMember as m, CoffreClient as n, RouteInput as o, unreachable as p, SecretVersion as q, CoffreError as r, RouteKey as s, ClientOptions as t, createClient as u, foldersOf as v, AuditEntryView as w, AccessValue as x, ageInDays as y, Member as z };
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { A as DeletionResult, B as OffboardingReport, C as AuthInfo, D as ConnectedApp, E as BindingView, F as ListedReference, G as SecretVersion, H as ReferenceView, I as Me, J as SetResult, K as ServiceTokenRow, L as Member, M as DryRunOutcome, N as DryRunResult, O as Decision, P as IdentityRow, R as MemberAccess, S as AuditEntryView, T as BindingPlan, U as RemovedMember, V as ProjectSummary, W as SecretKey, X as WorkloadIds, Y as TokenPlan, _ as byFolder, a as Params, b as Api, c as RouteOutput, d as planImport, f as Unreachable, g as shownMember, h as serviceName, i as ImportAction, j as DismissedKey, k as Deletion, l as Transport, m as apiMember, n as CoffreClient, o as RouteInput, p as unreachable, q as SessionRow, r as CoffreError, s as RouteKey, t as ClientOptions, u as createClient, v as foldersOf, w as AuthorizationView, x as ApprovalView, y as AccessValue, z as MissingKey } from "./index-D0kM4Gfi.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 IdentityRow, ImportAction, type ListedReference, type Me, type Member, type MemberAccess, type MissingKey, type OffboardingReport, Params, type ProjectSummary, type ReferenceView, type RemovedMember, RouteInput, RouteKey, RouteOutput, type SecretKey, type SecretVersion, type ServiceTokenRow, type SessionRow, type SetResult, type TokenPlan, Transport, Unreachable, type WorkloadIds, apiMember, byFolder, createClient, foldersOf, planImport, serviceName, shownMember, unreachable };
1
+ import { A as Decision, B as MemberAccess, C as ApprovalView, D as BindingPlan, E as AuthorizationView, F as DryRunResult, G as RemovedMember, H as OffboardingReport, I as IdentityRow, J as ServiceTokenRow, K as SecretKey, L as ListedReference, M as DeletionResult, N as DismissedKey, O as BindingView, P as DryRunOutcome, Q as WorkloadIds, R as Me, S as Api, T as AuthInfo, U as ProjectSummary, V as MissingKey, W as ReferenceView, X as SetResult, Y as SessionRow, Z as TokenPlan, _ as byFolder, a as Params, b as olderThan, c as RouteOutput, d as planImport, f as Unreachable, g as shownMember, h as serviceName, i as ImportAction, j as Deletion, k as ConnectedApp, l as Transport, m as apiMember, n as CoffreClient, o as RouteInput, p as unreachable, q as SecretVersion, r as CoffreError, s as RouteKey, t as ClientOptions, u as createClient, v as foldersOf, w as AuditEntryView, x as AccessValue, y as ageInDays, z as Member } from "./index-BHK1QCh7.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 IdentityRow, ImportAction, type ListedReference, type Me, type Member, type MemberAccess, type MissingKey, type OffboardingReport, Params, type ProjectSummary, type ReferenceView, type RemovedMember, RouteInput, RouteKey, RouteOutput, type SecretKey, type SecretVersion, type ServiceTokenRow, type SessionRow, type SetResult, type TokenPlan, Transport, Unreachable, type WorkloadIds, ageInDays, apiMember, byFolder, createClient, foldersOf, olderThan, planImport, serviceName, shownMember, unreachable };
package/dist/index.js CHANGED
@@ -46,6 +46,25 @@ var Unreachable = class extends Error {
46
46
  }
47
47
  };
48
48
  //#endregion
49
+ //#region src/age.ts
50
+ const DAY = 864e5;
51
+ /**
52
+ * Whole days since a key's value was written (`updatedAt`, a reference's
53
+ * source's): 0 on the day it was. Null while it reads no value.
54
+ */
55
+ function ageInDays(entry, now = Date.now()) {
56
+ return entry.updatedAt === null ? null : Math.max(0, Math.floor((now - Date.parse(entry.updatedAt)) / DAY));
57
+ }
58
+ /**
59
+ * Whether a key's value has gone unchanged for more than `days` whole days:
60
+ * against the deployment's `rotateAfterDays`, due for rotation. An archived
61
+ * key, which nothing reads, and a key with no value never are.
62
+ */
63
+ function olderThan(entry, days, now = Date.now()) {
64
+ const age = ageInDays(entry, now);
65
+ return !entry.archived && age !== null && age > days;
66
+ }
67
+ //#endregion
49
68
  //#region src/folders.ts
50
69
  /**
51
70
  * Rows grouped by folder, as every list shows them: those in no folder
@@ -179,7 +198,7 @@ function createClient(options) {
179
198
  },
180
199
  /** Delete an archived environment for good, as a project is. Owners only. */
181
200
  delete: (path) => call("DELETE /projects/:project/:environment", place(path)),
182
- /** The keys its sibling environments have and it lacks, those you can see, and those its team dismissed. */
201
+ /** The keys its sibling environments have and it lacks, read or not, and those its team dismissed. */
183
202
  missing: (path) => call("GET /projects/:project/:environment/missing", place(path)),
184
203
  /** Dismiss missing keys (`true`) or restore them (`null`). */
185
204
  dismiss: (path, patch) => call("PATCH /projects/:project/:environment/dismissals", place(path), patch)
@@ -254,8 +273,10 @@ function createClient(options) {
254
273
  member,
255
274
  id
256
275
  }),
257
- /** A public GitHub repository's or GitLab project's IDs, which bindings name. */
258
- lookup: (input) => call("GET /workloads/lookup", {}, input)
276
+ /** 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. */
277
+ lookup: (input) => call("GET /workloads/lookup", {}, input),
278
+ /** The repositories the deployment's GitHub App is installed on, private ones too; `{ app: null }` without one. */
279
+ repositories: () => call("GET /workloads/repositories", {})
259
280
  },
260
281
  access: {
261
282
  /** What they should hold at each place; the server applies the difference. `null` revokes. */
@@ -332,7 +353,7 @@ set: (member, access) => call("PATCH /access/:member", { member }, access) },
332
353
  audit: {
333
354
  list: (query = {}) => call("GET /audit", {}, query),
334
355
  verify: () => call("GET /audit/verification", {}),
335
- /** What an escrowed key is checked against: public material, owners and root admins only. */
356
+ /** What an escrowed key is checked against: public material, for admins and owners of the whole instance. */
336
357
  keys: () => call("GET /audit/keys", {})
337
358
  }
338
359
  };
@@ -369,4 +390,4 @@ async function planImport(coffre, path, entries) {
369
390
  };
370
391
  }
371
392
  //#endregion
372
- export { CoffreError, Unreachable, apiMember, byFolder, createClient, foldersOf, planImport, serviceName, shownMember, unreachable };
393
+ export { CoffreError, Unreachable, ageInDays, apiMember, byFolder, createClient, foldersOf, 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-D0kM4Gfi.js";
1
+ import { a as Params, o as RouteInput, s as RouteKey } from "./index-BHK1QCh7.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
@@ -26,6 +26,7 @@ function getCalls({ places, secrets, members, services }) {
26
26
  params: {},
27
27
  input: { github: "acme/api" }
28
28
  }],
29
+ "GET /workloads/repositories": [{ params: {} }],
29
30
  "GET /settings": [{ params: {} }],
30
31
  "GET /sessions": [{ params: {} }],
31
32
  "GET /identities": [{ params: {} }],
@@ -98,6 +99,7 @@ const EVERY_ROUTE = {
98
99
  "POST /members/:member/bindings": true,
99
100
  "DELETE /members/:member/bindings/:id": true,
100
101
  "GET /workloads/lookup": true,
102
+ "GET /workloads/repositories": true,
101
103
  "GET /settings": true,
102
104
  "PUT /settings": true,
103
105
  "PATCH /access/:member": true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coffre/client",
3
- "version": "0.5.1",
3
+ "version": "0.6.1",
4
4
  "description": "The coffre API as typed function calls.",
5
5
  "license": "MIT",
6
6
  "repository": {
package/src/age.ts ADDED
@@ -0,0 +1,21 @@
1
+ import type { SecretKey } from './api.ts';
2
+
3
+ const DAY = 86_400_000;
4
+
5
+ /**
6
+ * Whole days since a key's value was written (`updatedAt`, a reference's
7
+ * source's): 0 on the day it was. Null while it reads no value.
8
+ */
9
+ export function ageInDays(entry: Pick<SecretKey, 'updatedAt'>, now: number = Date.now()): number | null {
10
+ return entry.updatedAt === null ? null : Math.max(0, Math.floor((now - Date.parse(entry.updatedAt)) / DAY));
11
+ }
12
+
13
+ /**
14
+ * Whether a key's value has gone unchanged for more than `days` whole days:
15
+ * against the deployment's `rotateAfterDays`, due for rotation. An archived
16
+ * key, which nothing reads, and a key with no value never are.
17
+ */
18
+ export function olderThan(entry: Pick<SecretKey, 'archived' | 'updatedAt'>, days: number, now: number = Date.now()): boolean {
19
+ const age = ageInDays(entry, now);
20
+ return !entry.archived && age !== null && age > days;
21
+ }
package/src/api.ts CHANGED
@@ -13,7 +13,7 @@ export type Api = {
13
13
  };
14
14
  registered: boolean;
15
15
  tampered: boolean;
16
- instanceRole: "admin" | "auditor" | "developer" | "member" | "owner" | "root-admin";
16
+ instanceRole: "admin" | "auditor" | "developer" | "member" | "owner";
17
17
  scope: {
18
18
  projects: "all" | {
19
19
  only: string[];
@@ -26,7 +26,6 @@ export type Api = {
26
26
  except: string[];
27
27
  };
28
28
  };
29
- isRootAdmin: boolean;
30
29
  runsInstance: boolean;
31
30
  canReadAudit: boolean;
32
31
  setsUpServices: boolean;
@@ -237,6 +236,7 @@ export type Api = {
237
236
  updatedAt: string | null;
238
237
  updatedBy: string | null;
239
238
  }[];
239
+ rotateAfterDays: number | null;
240
240
  };
241
241
  };
242
242
  "PATCH /secrets/:project/:environment": {
@@ -387,7 +387,7 @@ export type Api = {
387
387
  member: string;
388
388
  principalType: "service" | "user";
389
389
  principalId: string;
390
- instanceRole: "admin" | "auditor" | "developer" | "member" | "owner" | "root-admin";
390
+ instanceRole: "admin" | "auditor" | "developer" | "member" | "owner";
391
391
  scope: null | {
392
392
  projects: "all" | {
393
393
  only: string[];
@@ -402,8 +402,8 @@ export type Api = {
402
402
  };
403
403
  reachesByRole: boolean;
404
404
  managed: boolean;
405
- isRootAdmin: boolean;
406
405
  tampered: boolean;
406
+ declared: boolean;
407
407
  grants: {
408
408
  id: string;
409
409
  project: string;
@@ -427,7 +427,7 @@ export type Api = {
427
427
  principalType: "service" | "user";
428
428
  principalId: string;
429
429
  status: "active" | "removed" | "tampered";
430
- instanceRole: "admin" | "auditor" | "developer" | "member" | "owner" | "root-admin";
430
+ instanceRole: "admin" | "auditor" | "developer" | "member" | "owner";
431
431
  scope: {
432
432
  projects: "all" | {
433
433
  only: string[];
@@ -440,7 +440,7 @@ export type Api = {
440
440
  except: string[];
441
441
  };
442
442
  };
443
- isRootAdmin: boolean;
443
+ declared: boolean;
444
444
  removedAt: string | null;
445
445
  removedBy: string | null;
446
446
  live: {
@@ -509,6 +509,12 @@ export type Api = {
509
509
  except: string[];
510
510
  };
511
511
  };
512
+ access?: {
513
+ [key: string]: "access-manager" | "auditor" | "developer" | "maintainer" | "owner" | "viewer" | null | {
514
+ role: "access-manager" | "auditor" | "developer" | "maintainer" | "owner" | "viewer";
515
+ until: string | null;
516
+ };
517
+ };
512
518
  };
513
519
  output: {
514
520
  member: string;
@@ -526,6 +532,9 @@ export type Api = {
526
532
  };
527
533
  };
528
534
  created: boolean;
535
+ changes?: {
536
+ [key: string]: "created" | "revoked" | "unchanged" | "updated";
537
+ };
529
538
  };
530
539
  };
531
540
  "DELETE /members/:member": {
@@ -542,7 +551,7 @@ export type Api = {
542
551
  principalType: "service" | "user";
543
552
  principalId: string;
544
553
  status: "active" | "removed" | "tampered";
545
- instanceRole: "admin" | "auditor" | "developer" | "member" | "owner" | "root-admin";
554
+ instanceRole: "admin" | "auditor" | "developer" | "member" | "owner";
546
555
  scope: {
547
556
  projects: "all" | {
548
557
  only: string[];
@@ -555,7 +564,7 @@ export type Api = {
555
564
  except: string[];
556
565
  };
557
566
  };
558
- isRootAdmin: boolean;
567
+ declared: boolean;
559
568
  removedAt: string | null;
560
569
  removedBy: string | null;
561
570
  live: {
@@ -733,6 +742,9 @@ export type Api = {
733
742
  github: string;
734
743
  repositoryId: string;
735
744
  ownerId: string;
745
+ } | {
746
+ github: string;
747
+ ownerId: string;
736
748
  } | {
737
749
  gitlab: string;
738
750
  projectId: string;
@@ -756,6 +768,23 @@ export type Api = {
756
768
  changes: {
757
769
  [key: string]: "created" | "revoked" | "unchanged" | "updated";
758
770
  };
771
+ admitted?: {
772
+ created: boolean;
773
+ role: "admin" | "auditor" | "developer" | "member" | "owner";
774
+ scope: {
775
+ projects: "all" | {
776
+ only: string[];
777
+ } | {
778
+ except: string[];
779
+ };
780
+ environments: "all" | {
781
+ only: string[];
782
+ } | {
783
+ except: string[];
784
+ };
785
+ };
786
+ generation: number;
787
+ };
759
788
  };
760
789
  };
761
790
  "GET /sessions": {
@@ -1053,7 +1082,7 @@ export type Api = {
1053
1082
  principalType: "service" | "user";
1054
1083
  principalId: string;
1055
1084
  status: "active" | "removed" | "tampered";
1056
- instanceRole: "admin" | "auditor" | "developer" | "member" | "owner" | "root-admin";
1085
+ instanceRole: "admin" | "auditor" | "developer" | "member" | "owner";
1057
1086
  scope: null | {
1058
1087
  projects: "all" | {
1059
1088
  only: string[];
@@ -1066,7 +1095,6 @@ export type Api = {
1066
1095
  except: string[];
1067
1096
  };
1068
1097
  };
1069
- isRootAdmin: boolean;
1070
1098
  managed: boolean;
1071
1099
  grants: {
1072
1100
  id: string;
@@ -1126,6 +1154,25 @@ export type Api = {
1126
1154
  };
1127
1155
  };
1128
1156
  };
1157
+ "GET /workloads/repositories": {
1158
+ input: undefined;
1159
+ output: {
1160
+ app: {
1161
+ name: string;
1162
+ installUrl: string;
1163
+ };
1164
+ installations: string[];
1165
+ repositories: {
1166
+ github: string;
1167
+ repositoryId: string;
1168
+ ownerId: string;
1169
+ private: boolean;
1170
+ }[];
1171
+ truncated: boolean;
1172
+ } | {
1173
+ app: null;
1174
+ };
1175
+ };
1129
1176
  };
1130
1177
 
1131
1178
  export type AccessValue = "access-manager" | "auditor" | "developer" | "maintainer" | "owner" | "viewer" | null | {
@@ -1344,6 +1391,9 @@ export type WorkloadIds = {
1344
1391
  github: string;
1345
1392
  repositoryId: string;
1346
1393
  ownerId: string;
1394
+ } | {
1395
+ github: string;
1396
+ ownerId: string;
1347
1397
  } | {
1348
1398
  gitlab: string;
1349
1399
  projectId: string;
@@ -1382,7 +1432,7 @@ export type Me = {
1382
1432
  };
1383
1433
  registered: boolean;
1384
1434
  tampered: boolean;
1385
- instanceRole: "admin" | "auditor" | "developer" | "member" | "owner" | "root-admin";
1435
+ instanceRole: "admin" | "auditor" | "developer" | "member" | "owner";
1386
1436
  scope: {
1387
1437
  projects: "all" | {
1388
1438
  only: string[];
@@ -1395,7 +1445,6 @@ export type Me = {
1395
1445
  except: string[];
1396
1446
  };
1397
1447
  };
1398
- isRootAdmin: boolean;
1399
1448
  runsInstance: boolean;
1400
1449
  canReadAudit: boolean;
1401
1450
  setsUpServices: boolean;
@@ -1426,7 +1475,7 @@ export type Member = {
1426
1475
  member: string;
1427
1476
  principalType: "service" | "user";
1428
1477
  principalId: string;
1429
- instanceRole: "admin" | "auditor" | "developer" | "member" | "owner" | "root-admin";
1478
+ instanceRole: "admin" | "auditor" | "developer" | "member" | "owner";
1430
1479
  scope: null | {
1431
1480
  projects: "all" | {
1432
1481
  only: string[];
@@ -1441,8 +1490,8 @@ export type Member = {
1441
1490
  };
1442
1491
  reachesByRole: boolean;
1443
1492
  managed: boolean;
1444
- isRootAdmin: boolean;
1445
1493
  tampered: boolean;
1494
+ declared: boolean;
1446
1495
  grants: {
1447
1496
  id: string;
1448
1497
  project: string;
@@ -1459,7 +1508,7 @@ export type MemberAccess = {
1459
1508
  principalType: "service" | "user";
1460
1509
  principalId: string;
1461
1510
  status: "active" | "removed" | "tampered";
1462
- instanceRole: "admin" | "auditor" | "developer" | "member" | "owner" | "root-admin";
1511
+ instanceRole: "admin" | "auditor" | "developer" | "member" | "owner";
1463
1512
  scope: null | {
1464
1513
  projects: "all" | {
1465
1514
  only: string[];
@@ -1472,7 +1521,6 @@ export type MemberAccess = {
1472
1521
  except: string[];
1473
1522
  };
1474
1523
  };
1475
- isRootAdmin: boolean;
1476
1524
  managed: boolean;
1477
1525
  grants: {
1478
1526
  id: string;
@@ -1510,7 +1558,7 @@ export type OffboardingReport = {
1510
1558
  principalType: "service" | "user";
1511
1559
  principalId: string;
1512
1560
  status: "active" | "removed" | "tampered";
1513
- instanceRole: "admin" | "auditor" | "developer" | "member" | "owner" | "root-admin";
1561
+ instanceRole: "admin" | "auditor" | "developer" | "member" | "owner";
1514
1562
  scope: {
1515
1563
  projects: "all" | {
1516
1564
  only: string[];
@@ -1523,7 +1571,7 @@ export type OffboardingReport = {
1523
1571
  except: string[];
1524
1572
  };
1525
1573
  };
1526
- isRootAdmin: boolean;
1574
+ declared: boolean;
1527
1575
  removedAt: string | null;
1528
1576
  removedBy: string | null;
1529
1577
  live: {
package/src/index.ts CHANGED
@@ -48,6 +48,7 @@ export type {
48
48
  WorkloadIds,
49
49
  } from './api.ts';
50
50
 
51
+ export { ageInDays, olderThan } from './age.ts';
51
52
  export { byFolder, foldersOf } from './folders.ts';
52
53
  export { apiMember, serviceName, shownMember } from './members.ts';
53
54
  export { unreachable, Unreachable } from './reach.ts';
@@ -197,7 +198,7 @@ export function createClient(options: ClientOptions) {
197
198
  },
198
199
  /** Delete an archived environment for good, as a project is. Owners only. */
199
200
  delete: (path: string) => call('DELETE /projects/:project/:environment', place(path)),
200
- /** The keys its sibling environments have and it lacks, those you can see, and those its team dismissed. */
201
+ /** The keys its sibling environments have and it lacks, read or not, and those its team dismissed. */
201
202
  missing: (path: string) => call('GET /projects/:project/:environment/missing', place(path)),
202
203
  /** Dismiss missing keys (`true`) or restore them (`null`). */
203
204
  dismiss: (path: string, patch: RouteInput<'PATCH /projects/:project/:environment/dismissals'>) =>
@@ -279,8 +280,10 @@ export function createClient(options: ClientOptions) {
279
280
  create: (member: string, input: RouteInput<'POST /members/:member/bindings'>) =>
280
281
  call('POST /members/:member/bindings', { member }, input) as Promise<{ binding: BindingView; replaced: string[] }>,
281
282
  remove: (member: string, id: string) => call('DELETE /members/:member/bindings/:id', { member, id }),
282
- /** A public GitHub repository's or GitLab project's IDs, which bindings name. */
283
+ /** 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. */
283
284
  lookup: (input: RouteInput<'GET /workloads/lookup'>) => call('GET /workloads/lookup', {}, input),
285
+ /** The repositories the deployment's GitHub App is installed on, private ones too; `{ app: null }` without one. */
286
+ repositories: () => call('GET /workloads/repositories', {}),
284
287
  },
285
288
 
286
289
  access: {
@@ -361,7 +364,7 @@ export function createClient(options: ClientOptions) {
361
364
  audit: {
362
365
  list: (query: RouteInput<'GET /audit'> = {}) => call('GET /audit', {}, query),
363
366
  verify: () => call('GET /audit/verification', {}),
364
- /** What an escrowed key is checked against: public material, owners and root admins only. */
367
+ /** What an escrowed key is checked against: public material, for admins and owners of the whole instance. */
365
368
  keys: () => call('GET /audit/keys', {}),
366
369
  },
367
370
  };
package/src/routes.ts CHANGED
@@ -41,6 +41,7 @@ export function getCalls({ places, secrets, members, services }: Subjects): GetC
41
41
  'GET /members/:member/tokens': services.map((member) => ({ params: { member } })),
42
42
  'GET /members/:member/bindings': services.map((member) => ({ params: { member } })),
43
43
  'GET /workloads/lookup': [{ params: {}, input: { github: 'acme/api' } }],
44
+ 'GET /workloads/repositories': [{ params: {} }],
44
45
  'GET /settings': [{ params: {} }],
45
46
  'GET /sessions': [{ params: {} }],
46
47
  'GET /identities': [{ params: {} }],
@@ -99,6 +100,7 @@ const EVERY_ROUTE: { [K in RouteKey]: true } = {
99
100
  'POST /members/:member/bindings': true,
100
101
  'DELETE /members/:member/bindings/:id': true,
101
102
  'GET /workloads/lookup': true,
103
+ 'GET /workloads/repositories': true,
102
104
  'GET /settings': true,
103
105
  'PUT /settings': true,
104
106
  'PATCH /access/:member': true,