@coffre/client 0.10.0 → 0.10.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.
@@ -1100,11 +1100,16 @@ type Api = {
1100
1100
  };
1101
1101
  };
1102
1102
  "GET /audit/verification": {
1103
- input: undefined;
1103
+ input: {
1104
+ from?: string;
1105
+ };
1104
1106
  output: {
1105
1107
  ok: true;
1106
1108
  through: number | null;
1107
1109
  entries: number;
1110
+ from: number;
1111
+ remaining: number;
1112
+ next?: string | null;
1108
1113
  checkpoint: null | {
1109
1114
  seq: number;
1110
1115
  signedAt: string;
@@ -3502,10 +3507,42 @@ declare function createClient(options: ClientOptions): {
3502
3507
  count: number;
3503
3508
  }[];
3504
3509
  }>;
3505
- verify: () => Promise<{
3510
+ /**
3511
+ * Whether the log holds, from the newest checkpoint; or, with `from`, a
3512
+ * stretch of the walk from the first entry: `start`, then each `next`
3513
+ * until it is null (`verifyWhole`).
3514
+ */
3515
+ verify: (query?: RouteInput<"GET /audit/verification">) => Promise<{
3516
+ ok: true;
3517
+ through: number | null;
3518
+ entries: number;
3519
+ from: number;
3520
+ remaining: number;
3521
+ next?: string | null;
3522
+ checkpoint: null | {
3523
+ seq: number;
3524
+ signedAt: string;
3525
+ };
3526
+ pending?: number;
3527
+ } | {
3528
+ ok: false;
3529
+ through: number | null;
3530
+ failedAtSeq: number | null;
3531
+ author: "app" | "vault";
3532
+ reason: string;
3533
+ }>;
3534
+ /**
3535
+ * The walk from the first entry to the head, a stretch a request, each
3536
+ * as long as the server walks in one: the first stretch that fails, or
3537
+ * the last. `onStretch` sees each verdict as it comes.
3538
+ */
3539
+ verifyWhole: (onStretch?: (verdict: RouteOutput<"GET /audit/verification">) => void) => Promise<{
3506
3540
  ok: true;
3507
3541
  through: number | null;
3508
3542
  entries: number;
3543
+ from: number;
3544
+ remaining: number;
3545
+ next?: string | null;
3509
3546
  checkpoint: null | {
3510
3547
  seq: number;
3511
3548
  signedAt: string;
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { $ as RolesView, A as Decision, B as KeysPlan, C as ApprovalView, D as BindingPlan, E as AuthorizationView, F as DryRunResult, G as MissingKey, H as Me, I as EnvironmentView, J as ProjectSummary, K as OffboardingReport, L as IdentityRow, M as DeletionResult, N as DismissedKey, O as BindingView, P as DryRunOutcome, Q as RoleView, R as ImpactLine, S as Api, T as AuthInfo, U as Member, V as ListedReference, W as MemberAccess, X as RemovedMember, Y as ReferenceView, Z as RoleImpact, _ as byFolder, a as Params, at as TokenRow, b as olderThan, c as RouteOutput, d as planImport, et as SecretKey, f as Unreachable, g as shownMember, h as serviceName, i as ImportAction, it as TokenPlan, j as Deletion, k as ConnectedApp, l as Transport, m as apiMember, n as CoffreClient, nt as SessionRow, o as RouteInput, ot as WorkloadIds, p as unreachable, q as PersonalConfig, r as CoffreError, rt as SetResult, s as RouteKey, t as ClientOptions, tt as SecretVersion, u as createClient, v as foldersOf, w as AuditEntryView, x as AccessValue, y as ageInDays, z as InheritResult } from "./index-PXC2jUur.js";
1
+ import { $ as RolesView, A as Decision, B as KeysPlan, C as ApprovalView, D as BindingPlan, E as AuthorizationView, F as DryRunResult, G as MissingKey, H as Me, I as EnvironmentView, J as ProjectSummary, K as OffboardingReport, L as IdentityRow, M as DeletionResult, N as DismissedKey, O as BindingView, P as DryRunOutcome, Q as RoleView, R as ImpactLine, S as Api, T as AuthInfo, U as Member, V as ListedReference, W as MemberAccess, X as RemovedMember, Y as ReferenceView, Z as RoleImpact, _ as byFolder, a as Params, at as TokenRow, b as olderThan, c as RouteOutput, d as planImport, et as SecretKey, f as Unreachable, g as shownMember, h as serviceName, i as ImportAction, it as TokenPlan, j as Deletion, k as ConnectedApp, l as Transport, m as apiMember, n as CoffreClient, nt as SessionRow, o as RouteInput, ot as WorkloadIds, p as unreachable, q as PersonalConfig, r as CoffreError, rt as SetResult, s as RouteKey, t as ClientOptions, tt as SecretVersion, u as createClient, v as foldersOf, w as AuditEntryView, x as AccessValue, y as ageInDays, z as InheritResult } from "./index-D86fJBDd.js";
2
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 };
package/dist/index.js CHANGED
@@ -427,7 +427,25 @@ set: (member, access) => call("PATCH /access/:member", { member }, access) },
427
427
  },
428
428
  audit: {
429
429
  list: (query = {}) => call("GET /audit", {}, query),
430
- verify: () => call("GET /audit/verification", {}),
430
+ /**
431
+ * Whether the log holds, from the newest checkpoint; or, with `from`, a
432
+ * stretch of the walk from the first entry: `start`, then each `next`
433
+ * until it is null (`verifyWhole`).
434
+ */
435
+ verify: (query = {}) => call("GET /audit/verification", {}, query),
436
+ /**
437
+ * The walk from the first entry to the head, a stretch a request, each
438
+ * as long as the server walks in one: the first stretch that fails, or
439
+ * the last. `onStretch` sees each verdict as it comes.
440
+ */
441
+ verifyWhole: async (onStretch = () => {}) => {
442
+ for (let from = "start";;) {
443
+ const verdict = await call("GET /audit/verification", {}, { from });
444
+ onStretch(verdict);
445
+ if (!verdict.ok || verdict.next === void 0 || verdict.next === null) return verdict;
446
+ from = verdict.next;
447
+ }
448
+ },
431
449
  /** What an escrowed key is checked against: public material, for admins and owners of the whole instance. */
432
450
  keys: () => call("GET /audit/keys", {})
433
451
  }
package/dist/routes.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as Params, o as RouteInput, s as RouteKey } from "./index-PXC2jUur.js";
1
+ import { a as Params, o as RouteInput, s as RouteKey } from "./index-D86fJBDd.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coffre/client",
3
- "version": "0.10.0",
3
+ "version": "0.10.1",
4
4
  "description": "The coffre API as typed function calls.",
5
5
  "license": "MIT",
6
6
  "repository": {
package/src/api.ts CHANGED
@@ -1103,11 +1103,16 @@ export type Api = {
1103
1103
  };
1104
1104
  };
1105
1105
  "GET /audit/verification": {
1106
- input: undefined;
1106
+ input: {
1107
+ from?: string;
1108
+ };
1107
1109
  output: {
1108
1110
  ok: true;
1109
1111
  through: number | null;
1110
1112
  entries: number;
1113
+ from: number;
1114
+ remaining: number;
1115
+ next?: string | null;
1111
1116
  checkpoint: null | {
1112
1117
  seq: number;
1113
1118
  signedAt: string;
package/src/index.ts CHANGED
@@ -456,7 +456,25 @@ export function createClient(options: ClientOptions) {
456
456
 
457
457
  audit: {
458
458
  list: (query: RouteInput<'GET /audit'> = {}) => call('GET /audit', {}, query),
459
- verify: () => call('GET /audit/verification', {}),
459
+ /**
460
+ * Whether the log holds, from the newest checkpoint; or, with `from`, a
461
+ * stretch of the walk from the first entry: `start`, then each `next`
462
+ * until it is null (`verifyWhole`).
463
+ */
464
+ verify: (query: RouteInput<'GET /audit/verification'> = {}) => call('GET /audit/verification', {}, query),
465
+ /**
466
+ * The walk from the first entry to the head, a stretch a request, each
467
+ * as long as the server walks in one: the first stretch that fails, or
468
+ * the last. `onStretch` sees each verdict as it comes.
469
+ */
470
+ verifyWhole: async (onStretch: (verdict: RouteOutput<'GET /audit/verification'>) => void = () => {}) => {
471
+ for (let from = 'start'; ;) {
472
+ const verdict: RouteOutput<'GET /audit/verification'> = await call('GET /audit/verification', {}, { from });
473
+ onStretch(verdict);
474
+ if (!verdict.ok || verdict.next === undefined || verdict.next === null) return verdict;
475
+ from = verdict.next;
476
+ }
477
+ },
460
478
  /** What an escrowed key is checked against: public material, for admins and owners of the whole instance. */
461
479
  keys: () => call('GET /audit/keys', {}),
462
480
  },