@intellectual-frontiers/ergonex 0.3.3 → 0.3.5
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/mod.js +6 -6
- package/dist/state-record.d.ts +1 -1
- package/dist/vendor/ts/githost/github.d.ts +1 -1
- package/dist/vendor/ts/githost/gitlab.d.ts +1 -1
- package/dist/vendor/ts/githost/mod.d.ts +1 -1
- package/ergonex.mjs +173 -248
- package/package.json +2 -1
- package/dist/vendor/ts/runtime/http-client.d.ts +0 -149
package/dist/mod.js
CHANGED
|
@@ -911,7 +911,7 @@ function toSarif(findings, tool = "ergonex") {
|
|
|
911
911
|
}
|
|
912
912
|
|
|
913
913
|
// src/state-record.ts
|
|
914
|
-
var ERGONEX_VERSION = "0.3.
|
|
914
|
+
var ERGONEX_VERSION = "0.3.5";
|
|
915
915
|
var STATE_RECORD_PATH = ".ergonex/state.auto.json";
|
|
916
916
|
var EMPTY_RECORD = {
|
|
917
917
|
ergonex: ERGONEX_VERSION,
|
|
@@ -2078,7 +2078,7 @@ function rcFileFor(shell, f) {
|
|
|
2078
2078
|
return absurd(shell);
|
|
2079
2079
|
}
|
|
2080
2080
|
}
|
|
2081
|
-
// ../
|
|
2081
|
+
// ../telemetry/src/otel.ts
|
|
2082
2082
|
var TRACE_ID = /^[0-9a-f]{32}$/;
|
|
2083
2083
|
var SPAN_ID = /^[0-9a-f]{16}$/;
|
|
2084
2084
|
var ZEROS = /^0+$/;
|
|
@@ -2152,7 +2152,7 @@ function commandShape(argv) {
|
|
|
2152
2152
|
return out;
|
|
2153
2153
|
}
|
|
2154
2154
|
|
|
2155
|
-
// ../
|
|
2155
|
+
// ../telemetry/src/otlp.ts
|
|
2156
2156
|
var SPAN_KINDS = ["internal", "server", "client", "producer", "consumer"];
|
|
2157
2157
|
class Failure extends Error {
|
|
2158
2158
|
error;
|
|
@@ -2479,7 +2479,7 @@ var decodeMetric = message((f, path) => {
|
|
|
2479
2479
|
throw new Failure(failure(`${path}.sum`, "a sum, a gauge or a histogram", undefined));
|
|
2480
2480
|
});
|
|
2481
2481
|
|
|
2482
|
-
// ../
|
|
2482
|
+
// ../telemetry/src/signals.ts
|
|
2483
2483
|
var ATTRIBUTE_TYPES = new Set([
|
|
2484
2484
|
"string",
|
|
2485
2485
|
"boolean",
|
|
@@ -2579,7 +2579,7 @@ var build = Object.freeze({
|
|
|
2579
2579
|
target: tripleOf(osOf(process.platform), archOf(process.arch))
|
|
2580
2580
|
});
|
|
2581
2581
|
|
|
2582
|
-
// ../
|
|
2582
|
+
// ../telemetry/src/host/otel.ts
|
|
2583
2583
|
var RETRYABLE_STATUSES = new Set([429, 502, 503, 504]);
|
|
2584
2584
|
var DAY_MS = 24 * 60 * 60 * 1000;
|
|
2585
2585
|
var RUNTIME_SIGNALS = defineSignals({
|
|
@@ -2647,7 +2647,7 @@ function traceProcess(argv, run) {
|
|
|
2647
2647
|
setProcessTracer(traceProcess);
|
|
2648
2648
|
var UNTRACED = new WeakSet;
|
|
2649
2649
|
|
|
2650
|
-
// ../
|
|
2650
|
+
// ../net/src/http-client.ts
|
|
2651
2651
|
var exchangeDecoder = object({
|
|
2652
2652
|
method: literal("GET", "HEAD", "POST", "PUT", "PATCH", "DELETE"),
|
|
2653
2653
|
url: string,
|
package/dist/state-record.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ import { type Sha256 } from "@intellectual-frontiers/crypto";
|
|
|
14
14
|
import { type Finding } from "./findings.js";
|
|
15
15
|
import { type GeneratedFile } from "./render.js";
|
|
16
16
|
/** The version of Ergonex the record names. */
|
|
17
|
-
export declare const ERGONEX_VERSION = "0.3.
|
|
17
|
+
export declare const ERGONEX_VERSION = "0.3.5";
|
|
18
18
|
/** Where the state record is, below the root. */
|
|
19
19
|
export declare const STATE_RECORD_PATH = ".ergonex/state.auto.json";
|
|
20
20
|
/** One generated file as it was written. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Transport } from "
|
|
1
|
+
import { type Transport } from "@intellectual-frontiers/net/http-client";
|
|
2
2
|
import { type PlainGitOptions } from "./git.js";
|
|
3
3
|
import type { GitHostClient, RepoRef } from "./types.js";
|
|
4
4
|
export { CAPABILITIES, COMMON_CAPABILITIES, maxDepth, supports, unsupported } from "./capabilities.js";
|
package/ergonex.mjs
CHANGED
|
@@ -2208,7 +2208,7 @@ function parseJson5(text) {
|
|
|
2208
2208
|
}
|
|
2209
2209
|
}
|
|
2210
2210
|
|
|
2211
|
-
// ../
|
|
2211
|
+
// ../telemetry/src/otel.ts
|
|
2212
2212
|
var TRACE_ID = /^[0-9a-f]{32}$/;
|
|
2213
2213
|
var SPAN_ID = /^[0-9a-f]{16}$/;
|
|
2214
2214
|
var ZEROS = /^0+$/;
|
|
@@ -2423,7 +2423,7 @@ function commandShape(argv) {
|
|
|
2423
2423
|
return out;
|
|
2424
2424
|
}
|
|
2425
2425
|
|
|
2426
|
-
// ../
|
|
2426
|
+
// ../telemetry/src/otlp.ts
|
|
2427
2427
|
var SPAN_KINDS = ["internal", "server", "client", "producer", "consumer"];
|
|
2428
2428
|
function encodeDouble(n) {
|
|
2429
2429
|
if (Number.isNaN(n))
|
|
@@ -2919,7 +2919,7 @@ function decodeLogs(input) {
|
|
|
2919
2919
|
return r.kind === "err" ? r : ok(r.value.map((b) => ({ resource: b.resource, scope: b.scope, records: b.items })));
|
|
2920
2920
|
}
|
|
2921
2921
|
|
|
2922
|
-
// ../
|
|
2922
|
+
// ../telemetry/src/signals.ts
|
|
2923
2923
|
var ATTRIBUTE_TYPES = new Set([
|
|
2924
2924
|
"string",
|
|
2925
2925
|
"boolean",
|
|
@@ -2951,7 +2951,7 @@ function defineSignals(kinds) {
|
|
|
2951
2951
|
return { kinds };
|
|
2952
2952
|
}
|
|
2953
2953
|
|
|
2954
|
-
// ../
|
|
2954
|
+
// ../telemetry/src/host/otel.ts
|
|
2955
2955
|
var RETRYABLE_STATUSES = new Set([429, 502, 503, 504]);
|
|
2956
2956
|
var DAY_MS = 24 * 60 * 60 * 1000;
|
|
2957
2957
|
var RUNTIME_SIGNALS = defineSignals({
|
|
@@ -3054,7 +3054,7 @@ function traceHttpClient(method, url, send, status) {
|
|
|
3054
3054
|
}
|
|
3055
3055
|
var UNTRACED = new WeakSet;
|
|
3056
3056
|
|
|
3057
|
-
// ../
|
|
3057
|
+
// ../net/src/http-client.ts
|
|
3058
3058
|
var CREDENTIAL_HEADERS = [
|
|
3059
3059
|
"authorization",
|
|
3060
3060
|
"proxy-authorization",
|
|
@@ -3859,7 +3859,7 @@ function checkFiles(files, repositories) {
|
|
|
3859
3859
|
}
|
|
3860
3860
|
|
|
3861
3861
|
// src/state-record.ts
|
|
3862
|
-
var ERGONEX_VERSION = "0.3.
|
|
3862
|
+
var ERGONEX_VERSION = "0.3.5";
|
|
3863
3863
|
var STATE_RECORD_PATH = ".ergonex/state.auto.json";
|
|
3864
3864
|
var EMPTY_RECORD = {
|
|
3865
3865
|
ergonex: ERGONEX_VERSION,
|
|
@@ -8223,7 +8223,7 @@ var pathsModule = {
|
|
|
8223
8223
|
commands: [paths]
|
|
8224
8224
|
};
|
|
8225
8225
|
|
|
8226
|
-
// ../
|
|
8226
|
+
// ../net/src/acme.ts
|
|
8227
8227
|
var directoryDecoder = object({ newNonce: string, newAccount: string, newOrder: string });
|
|
8228
8228
|
var accountDecoder = object({ status: string });
|
|
8229
8229
|
var orderDecoder = object({ status: string, authorizations: array(string), finalize: string }, { certificate: string });
|
|
@@ -8235,195 +8235,7 @@ var cfError = object({ errors: array(object({ message: string })) });
|
|
|
8235
8235
|
var cfZones = object({ result: array(object({ id: string, name: string })) });
|
|
8236
8236
|
var cfRecord = object({ result: object({ id: string }) });
|
|
8237
8237
|
var cfRecords = object({ result: array(object({ id: string, content: string })) });
|
|
8238
|
-
// ../
|
|
8239
|
-
var INSTANT = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:[.,](\d{1,9}))?(Z|[+-]\d{2}:\d{2})$/i;
|
|
8240
|
-
var CANONICAL_INSTANT = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/;
|
|
8241
|
-
function instantOf(text) {
|
|
8242
|
-
const m = INSTANT.exec(text.trim());
|
|
8243
|
-
if (m === null)
|
|
8244
|
-
return;
|
|
8245
|
-
const [y, mo, d, h, mi, s] = [m[1], m[2], m[3], m[4], m[5], m[6]].map((x) => Number(x ?? ""));
|
|
8246
|
-
if (y === undefined || mo === undefined || d === undefined || h === undefined || mi === undefined || s === undefined)
|
|
8247
|
-
return;
|
|
8248
|
-
const ms = Number((m[7] ?? "").padEnd(3, "0").slice(0, 3));
|
|
8249
|
-
if (mo < 1 || mo > 12 || d < 1 || d > daysInMonth(y, mo) || h > 23 || mi > 59 || s > 59)
|
|
8250
|
-
return;
|
|
8251
|
-
const zone = (m[8] ?? "Z").toUpperCase();
|
|
8252
|
-
let offset = 0;
|
|
8253
|
-
if (zone !== "Z") {
|
|
8254
|
-
const oh = Number(zone.slice(1, 3));
|
|
8255
|
-
const om = Number(zone.slice(4, 6));
|
|
8256
|
-
if (oh > 23 || om > 59)
|
|
8257
|
-
return;
|
|
8258
|
-
offset = (zone.startsWith("-") ? -1 : 1) * (oh * 60 + om) * 60000;
|
|
8259
|
-
}
|
|
8260
|
-
const date = new Date(0);
|
|
8261
|
-
date.setUTCFullYear(y, mo - 1, d);
|
|
8262
|
-
date.setUTCHours(h, mi, s, ms);
|
|
8263
|
-
return instantFromEpochMs(date.getTime() - offset);
|
|
8264
|
-
}
|
|
8265
|
-
function instantFromEpochMs(ms) {
|
|
8266
|
-
if (!Number.isFinite(ms))
|
|
8267
|
-
return;
|
|
8268
|
-
const date = new Date(Math.trunc(ms));
|
|
8269
|
-
if (Number.isNaN(date.getTime()))
|
|
8270
|
-
return;
|
|
8271
|
-
const text = date.toISOString();
|
|
8272
|
-
return CANONICAL_INSTANT.test(text) ? text : undefined;
|
|
8273
|
-
}
|
|
8274
|
-
function daysInMonth(year, month) {
|
|
8275
|
-
const leap = year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
|
|
8276
|
-
return month === 2 ? leap ? 29 : 28 : [4, 6, 9, 11].includes(month) ? 30 : 31;
|
|
8277
|
-
}
|
|
8278
|
-
var DURATION = /^P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+(?:[.,]\d+)?)S)?)?$/;
|
|
8279
|
-
function parseDuration(text) {
|
|
8280
|
-
const m = DURATION.exec(text);
|
|
8281
|
-
if (m === null || text === "P" || text.endsWith("T"))
|
|
8282
|
-
return err({ kind: "duration", text });
|
|
8283
|
-
const n = (i) => Number((m[i] ?? "0").replace(",", "."));
|
|
8284
|
-
return ok({ text, years: n(1), months: n(2), weeks: n(3), days: n(4), hours: n(5), minutes: n(6), seconds: n(7) });
|
|
8285
|
-
}
|
|
8286
|
-
function duration(text) {
|
|
8287
|
-
const r = parseDuration(text);
|
|
8288
|
-
if (r.kind === "err")
|
|
8289
|
-
throw new Error(`not an ISO 8601 duration: ${JSON.stringify(text)}`);
|
|
8290
|
-
return r.value;
|
|
8291
|
-
}
|
|
8292
|
-
var ROLE = /^[a-z][a-z0-9]*(?:[-_./][a-z0-9]+)*$/;
|
|
8293
|
-
function roleOf(text) {
|
|
8294
|
-
return ROLE.test(text) ? text : undefined;
|
|
8295
|
-
}
|
|
8296
|
-
var SEVERITIES2 = ["info", "low", "medium", "high", "critical"];
|
|
8297
|
-
var refined = (name, f) => {
|
|
8298
|
-
return (input, path = "$") => {
|
|
8299
|
-
if (typeof input === "string") {
|
|
8300
|
-
const v = f(input);
|
|
8301
|
-
if (v !== undefined)
|
|
8302
|
-
return ok(v);
|
|
8303
|
-
}
|
|
8304
|
-
return err({
|
|
8305
|
-
kind: "decode",
|
|
8306
|
-
path,
|
|
8307
|
-
expected: name,
|
|
8308
|
-
found: typeof input === "string" ? `the string ${JSON.stringify(input).slice(0, 60)}` : typeof input
|
|
8309
|
-
});
|
|
8310
|
-
};
|
|
8311
|
-
};
|
|
8312
|
-
var instantDecoder = refined("an ISO 8601 date-time with a zone", instantOf);
|
|
8313
|
-
var roleDecoder = refined("a role (lower-case words joined by - _ . or /)", roleOf);
|
|
8314
|
-
var durationDecoder = refined("an ISO 8601 duration", (t) => {
|
|
8315
|
-
const r = parseDuration(t);
|
|
8316
|
-
return r.kind === "ok" ? r.value : undefined;
|
|
8317
|
-
});
|
|
8318
|
-
var severityDecoder = literal(...SEVERITIES2);
|
|
8319
|
-
var waiverInput = mapDecoder(object({ id: string, control: string, subjects: array(string), reason: string, approvedBy: roleDecoder, grantedAt: instantDecoder }, { expiresAt: instantDecoder }), (w) => w);
|
|
8320
|
-
|
|
8321
|
-
// ../ts/kernel/assess.ts
|
|
8322
|
-
var impactDeclarationDecoder = object({ paths: array(string), controls: array(string) });
|
|
8323
|
-
var RISK_LEVELS = ["very-low", "low", "moderate", "high", "very-high"];
|
|
8324
|
-
var levelDecoder = literal(...RISK_LEVELS);
|
|
8325
|
-
var riskDecoder = object({
|
|
8326
|
-
id: string,
|
|
8327
|
-
title: string,
|
|
8328
|
-
likelihood: levelDecoder,
|
|
8329
|
-
impact: levelDecoder,
|
|
8330
|
-
treatment: literal("accept", "mitigate", "transfer", "avoid"),
|
|
8331
|
-
owner: roleDecoder,
|
|
8332
|
-
reviewBy: instantDecoder
|
|
8333
|
-
}, { description: string, controls: array(string) });
|
|
8334
|
-
// ../ts/runtime/grc.ts
|
|
8335
|
-
var EXTENSIONS = new Map([
|
|
8336
|
-
["toml", "toml"],
|
|
8337
|
-
["yaml", "yaml"],
|
|
8338
|
-
["yml", "yaml"],
|
|
8339
|
-
["json", "json"],
|
|
8340
|
-
["json5", "json5"]
|
|
8341
|
-
]);
|
|
8342
|
-
var GRC_SIGNALS = defineSignals({
|
|
8343
|
-
"grc.pack": {
|
|
8344
|
-
signal: "span",
|
|
8345
|
-
role: "step",
|
|
8346
|
-
description: "A pack run: its id, how many controls and subjects, and how many findings of each outcome.",
|
|
8347
|
-
attributes: {
|
|
8348
|
-
"grc.pack.id": "string",
|
|
8349
|
-
"grc.pack.controls": "int",
|
|
8350
|
-
"grc.pack.subjects": "int",
|
|
8351
|
-
"grc.pack.findings?": "int",
|
|
8352
|
-
"grc.outcome?": "string",
|
|
8353
|
-
"grc.findings.not-applicable?": "int",
|
|
8354
|
-
"grc.findings.pass?": "int",
|
|
8355
|
-
"grc.findings.accepted?": "int",
|
|
8356
|
-
"grc.findings.warn?": "int",
|
|
8357
|
-
"grc.findings.gap?": "int",
|
|
8358
|
-
"grc.findings.fail?": "int",
|
|
8359
|
-
"grc.findings.error?": "int"
|
|
8360
|
-
}
|
|
8361
|
-
},
|
|
8362
|
-
"grc.control": {
|
|
8363
|
-
signal: "span",
|
|
8364
|
-
role: "detail",
|
|
8365
|
-
description: "One control's check of one subject: the join of its findings' statuses and of their outcomes, waivers applied.",
|
|
8366
|
-
attributes: {
|
|
8367
|
-
"grc.pack.id": "string",
|
|
8368
|
-
"grc.control.id": "string",
|
|
8369
|
-
"grc.subject.kind": "string",
|
|
8370
|
-
"grc.subject.id": "string",
|
|
8371
|
-
"grc.status?": "string",
|
|
8372
|
-
"grc.outcome?": "string",
|
|
8373
|
-
"grc.findings?": "int"
|
|
8374
|
-
}
|
|
8375
|
-
},
|
|
8376
|
-
"grc.finding": {
|
|
8377
|
-
signal: "log",
|
|
8378
|
-
severity: SEVERITY.INFO,
|
|
8379
|
-
role: "none",
|
|
8380
|
-
description: "A finding; its body is the finding's OCSF Compliance Finding (class 2003), its severity the finding's.",
|
|
8381
|
-
attributes: {
|
|
8382
|
-
"grc.pack.id": "string",
|
|
8383
|
-
"grc.control.id": "string",
|
|
8384
|
-
"grc.subject.kind": "string",
|
|
8385
|
-
"grc.subject.id": "string",
|
|
8386
|
-
"grc.status": "string",
|
|
8387
|
-
"grc.outcome": "string",
|
|
8388
|
-
"grc.severity": "string",
|
|
8389
|
-
"grc.waiver.id?": "string"
|
|
8390
|
-
}
|
|
8391
|
-
}
|
|
8392
|
-
});
|
|
8393
|
-
var FINDING_SEVERITY = {
|
|
8394
|
-
info: SEVERITY.INFO,
|
|
8395
|
-
low: SEVERITY.INFO,
|
|
8396
|
-
medium: SEVERITY.WARN,
|
|
8397
|
-
high: SEVERITY.ERROR,
|
|
8398
|
-
critical: SEVERITY.FATAL
|
|
8399
|
-
};
|
|
8400
|
-
var telemetries = new WeakMap;
|
|
8401
|
-
// ../terminal/src/palette.ts
|
|
8402
|
-
var ESC = String.fromCharCode(27);
|
|
8403
|
-
|
|
8404
|
-
// ../terminal/src/width.ts
|
|
8405
|
-
var ESC2 = String.fromCharCode(27);
|
|
8406
|
-
var BEL = String.fromCharCode(7);
|
|
8407
|
-
var ESCAPE = new RegExp(`${ESC2}(?:\\[[0-?]*[ -/]*[@-~]?|[\\]PX^_][^${BEL}${ESC2}]*(?:${BEL}|${ESC2}\\\\)?|[ -/]*[0-~]|)`, "g");
|
|
8408
|
-
var segmenter = new Intl.Segmenter(undefined, { granularity: "grapheme" });
|
|
8409
|
-
var SGR = new RegExp(`^${ESC2}\\[([0-9;:]*)m$`);
|
|
8410
|
-
var RESET = `${ESC2}[0m`;
|
|
8411
|
-
|
|
8412
|
-
// ../ts/kernel/render.ts
|
|
8413
|
-
var ESC3 = String.fromCharCode(27);
|
|
8414
|
-
var CONTROL2 = new RegExp(`[${String.fromCharCode(0)}-${String.fromCharCode(31)}${String.fromCharCode(127)}-${String.fromCharCode(159)}]`, "g");
|
|
8415
|
-
|
|
8416
|
-
// ../ts/runtime/console.ts
|
|
8417
|
-
var uncaughtSignals = {
|
|
8418
|
-
exception: {
|
|
8419
|
-
signal: "log",
|
|
8420
|
-
role: "error",
|
|
8421
|
-
severity: SEVERITY.FATAL,
|
|
8422
|
-
description: "An uncaught exception or an unhandled rejection, after which the process exits with status 1.",
|
|
8423
|
-
attributes: { "exception.type": "string", "exception.message": "string", "exception.stacktrace?": "string" }
|
|
8424
|
-
}
|
|
8425
|
-
};
|
|
8426
|
-
// ../ts/runtime/serve.ts
|
|
8238
|
+
// ../net/src/serve.ts
|
|
8427
8239
|
var NO_BODY = new Set(["GET", "HEAD"]);
|
|
8428
8240
|
// src/platform/r-http-client.ts
|
|
8429
8241
|
var liveTransport2 = liveTransport;
|
|
@@ -10405,7 +10217,7 @@ var RENDER_OPTIONS = {
|
|
|
10405
10217
|
help: "Wait for another run of ergonex on this workspace instead of refusing."
|
|
10406
10218
|
})
|
|
10407
10219
|
};
|
|
10408
|
-
var
|
|
10220
|
+
var render = defineCommand({
|
|
10409
10221
|
name: "render",
|
|
10410
10222
|
summary: "Write the generated files from the manifest; --check names what would change and writes nothing, --diff shows it.",
|
|
10411
10223
|
options: RENDER_OPTIONS,
|
|
@@ -10482,8 +10294,8 @@ var verifyModule = {
|
|
|
10482
10294
|
};
|
|
10483
10295
|
var renderModule = {
|
|
10484
10296
|
name: "render",
|
|
10485
|
-
summary:
|
|
10486
|
-
commands: [
|
|
10297
|
+
summary: render.summary,
|
|
10298
|
+
commands: [render]
|
|
10487
10299
|
};
|
|
10488
10300
|
|
|
10489
10301
|
// src/commands/worktree.ts
|
|
@@ -10751,29 +10563,107 @@ function guidanceFor(f) {
|
|
|
10751
10563
|
].join(`
|
|
10752
10564
|
`);
|
|
10753
10565
|
}
|
|
10754
|
-
// ../
|
|
10755
|
-
var
|
|
10756
|
-
|
|
10757
|
-
|
|
10758
|
-
|
|
10566
|
+
// ../terminal/src/palette.ts
|
|
10567
|
+
var ESC = String.fromCharCode(27);
|
|
10568
|
+
|
|
10569
|
+
// ../terminal/src/width.ts
|
|
10570
|
+
var ESC2 = String.fromCharCode(27);
|
|
10571
|
+
var BEL = String.fromCharCode(7);
|
|
10572
|
+
var ESCAPE = new RegExp(`${ESC2}(?:\\[[0-?]*[ -/]*[@-~]?|[\\]PX^_][^${BEL}${ESC2}]*(?:${BEL}|${ESC2}\\\\)?|[ -/]*[0-~]|)`, "g");
|
|
10573
|
+
var segmenter = new Intl.Segmenter(undefined, { granularity: "grapheme" });
|
|
10574
|
+
var SGR = new RegExp(`^${ESC2}\\[([0-9;:]*)m$`);
|
|
10575
|
+
var RESET = `${ESC2}[0m`;
|
|
10576
|
+
|
|
10577
|
+
// ../telemetry/src/render.ts
|
|
10578
|
+
var ESC3 = String.fromCharCode(27);
|
|
10579
|
+
var CONTROL2 = new RegExp(`[${String.fromCharCode(0)}-${String.fromCharCode(31)}${String.fromCharCode(127)}-${String.fromCharCode(159)}]`, "g");
|
|
10580
|
+
// src/platform/k-otel.ts
|
|
10581
|
+
var parseSpanId2 = parseSpanId;
|
|
10582
|
+
var parseTraceId2 = parseTraceId;
|
|
10583
|
+
|
|
10584
|
+
// ../ts/kernel/grc.ts
|
|
10585
|
+
var INSTANT = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:[.,](\d{1,9}))?(Z|[+-]\d{2}:\d{2})$/i;
|
|
10586
|
+
var CANONICAL_INSTANT = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/;
|
|
10587
|
+
function instantOf(text) {
|
|
10588
|
+
const m = INSTANT.exec(text.trim());
|
|
10589
|
+
if (m === null)
|
|
10590
|
+
return;
|
|
10591
|
+
const [y, mo, d, h, mi, s] = [m[1], m[2], m[3], m[4], m[5], m[6]].map((x) => Number(x ?? ""));
|
|
10592
|
+
if (y === undefined || mo === undefined || d === undefined || h === undefined || mi === undefined || s === undefined)
|
|
10593
|
+
return;
|
|
10594
|
+
const ms = Number((m[7] ?? "").padEnd(3, "0").slice(0, 3));
|
|
10595
|
+
if (mo < 1 || mo > 12 || d < 1 || d > daysInMonth(y, mo) || h > 23 || mi > 59 || s > 59)
|
|
10596
|
+
return;
|
|
10597
|
+
const zone = (m[8] ?? "Z").toUpperCase();
|
|
10598
|
+
let offset = 0;
|
|
10599
|
+
if (zone !== "Z") {
|
|
10600
|
+
const oh = Number(zone.slice(1, 3));
|
|
10601
|
+
const om = Number(zone.slice(4, 6));
|
|
10602
|
+
if (oh > 23 || om > 59)
|
|
10603
|
+
return;
|
|
10604
|
+
offset = (zone.startsWith("-") ? -1 : 1) * (oh * 60 + om) * 60000;
|
|
10605
|
+
}
|
|
10606
|
+
const date = new Date(0);
|
|
10607
|
+
date.setUTCFullYear(y, mo - 1, d);
|
|
10608
|
+
date.setUTCHours(h, mi, s, ms);
|
|
10609
|
+
return instantFromEpochMs(date.getTime() - offset);
|
|
10610
|
+
}
|
|
10611
|
+
function instantFromEpochMs(ms) {
|
|
10612
|
+
if (!Number.isFinite(ms))
|
|
10613
|
+
return;
|
|
10614
|
+
const date = new Date(Math.trunc(ms));
|
|
10615
|
+
if (Number.isNaN(date.getTime()))
|
|
10616
|
+
return;
|
|
10617
|
+
const text = date.toISOString();
|
|
10618
|
+
return CANONICAL_INSTANT.test(text) ? text : undefined;
|
|
10619
|
+
}
|
|
10620
|
+
function daysInMonth(year, month) {
|
|
10621
|
+
const leap = year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
|
|
10622
|
+
return month === 2 ? leap ? 29 : 28 : [4, 6, 9, 11].includes(month) ? 30 : 31;
|
|
10623
|
+
}
|
|
10624
|
+
var DURATION = /^P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+(?:[.,]\d+)?)S)?)?$/;
|
|
10625
|
+
function parseDuration(text) {
|
|
10626
|
+
const m = DURATION.exec(text);
|
|
10627
|
+
if (m === null || text === "P" || text.endsWith("T"))
|
|
10628
|
+
return err({ kind: "duration", text });
|
|
10629
|
+
const n = (i) => Number((m[i] ?? "0").replace(",", "."));
|
|
10630
|
+
return ok({ text, years: n(1), months: n(2), weeks: n(3), days: n(4), hours: n(5), minutes: n(6), seconds: n(7) });
|
|
10631
|
+
}
|
|
10632
|
+
function duration(text) {
|
|
10633
|
+
const r = parseDuration(text);
|
|
10634
|
+
if (r.kind === "err")
|
|
10635
|
+
throw new Error(`not an ISO 8601 duration: ${JSON.stringify(text)}`);
|
|
10636
|
+
return r.value;
|
|
10637
|
+
}
|
|
10638
|
+
var ROLE = /^[a-z][a-z0-9]*(?:[-_./][a-z0-9]+)*$/;
|
|
10639
|
+
function roleOf2(text) {
|
|
10640
|
+
return ROLE.test(text) ? text : undefined;
|
|
10641
|
+
}
|
|
10642
|
+
var SEVERITIES2 = ["info", "low", "medium", "high", "critical"];
|
|
10643
|
+
var refined = (name, f) => {
|
|
10644
|
+
return (input, path = "$") => {
|
|
10645
|
+
if (typeof input === "string") {
|
|
10646
|
+
const v = f(input);
|
|
10647
|
+
if (v !== undefined)
|
|
10648
|
+
return ok(v);
|
|
10649
|
+
}
|
|
10650
|
+
return err({
|
|
10651
|
+
kind: "decode",
|
|
10652
|
+
path,
|
|
10653
|
+
expected: name,
|
|
10654
|
+
found: typeof input === "string" ? `the string ${JSON.stringify(input).slice(0, 60)}` : typeof input
|
|
10655
|
+
});
|
|
10656
|
+
};
|
|
10759
10657
|
};
|
|
10760
|
-
var
|
|
10761
|
-
|
|
10762
|
-
|
|
10763
|
-
|
|
10764
|
-
kind:
|
|
10765
|
-
subject: object({ kind: string, id: string }),
|
|
10766
|
-
evidence: sha256Decoder,
|
|
10767
|
-
digest: sha256Decoder
|
|
10768
|
-
});
|
|
10769
|
-
var manifestDecoder2 = object({
|
|
10770
|
-
files: array(object({ path: string, size: refine(integer, "size", (n) => n >= 0), sha256: sha256Decoder }))
|
|
10658
|
+
var instantDecoder = refined("an ISO 8601 date-time with a zone", instantOf);
|
|
10659
|
+
var roleDecoder = refined("a role (lower-case words joined by - _ . or /)", roleOf2);
|
|
10660
|
+
var durationDecoder = refined("an ISO 8601 duration", (t) => {
|
|
10661
|
+
const r = parseDuration(t);
|
|
10662
|
+
return r.kind === "ok" ? r.value : undefined;
|
|
10771
10663
|
});
|
|
10664
|
+
var severityDecoder = literal(...SEVERITIES2);
|
|
10665
|
+
var waiverInput = mapDecoder(object({ id: string, control: string, subjects: array(string), reason: string, approvedBy: roleDecoder, grantedAt: instantDecoder }, { expiresAt: instantDecoder }), (w) => w);
|
|
10772
10666
|
|
|
10773
|
-
// ../ts/kernel/attest.ts
|
|
10774
|
-
var PASSING = new Set(["pass"]);
|
|
10775
|
-
// ../ts/kernel/oscal.ts
|
|
10776
|
-
var OPEN_OUTCOMES = new Set(["fail", "warn", "gap", "error", "accepted"]);
|
|
10777
10667
|
// ../ts/kernel/test-record.ts
|
|
10778
10668
|
var OUTCOMES = ["pass", "fail", "skip", "todo", "cancelled"];
|
|
10779
10669
|
function isOutcome(text) {
|
|
@@ -10817,7 +10707,7 @@ function installationFromEnv(self, env) {
|
|
|
10817
10707
|
const given = get("IFC_TEST_ROLE");
|
|
10818
10708
|
let role = fallback;
|
|
10819
10709
|
if (given !== undefined) {
|
|
10820
|
-
if (
|
|
10710
|
+
if (roleOf2(given) === undefined)
|
|
10821
10711
|
warnings.push(`IFC_TEST_ROLE is not a role (lower-case words, never a person); ${fallback} is used`);
|
|
10822
10712
|
else
|
|
10823
10713
|
role = given;
|
|
@@ -11061,6 +10951,65 @@ function closeOrphans(signals, at) {
|
|
|
11061
10951
|
}
|
|
11062
10952
|
return extra.length === 0 ? signals : mergeBatches({ traces: [...signals.traces, ...extra], logs: signals.logs });
|
|
11063
10953
|
}
|
|
10954
|
+
|
|
10955
|
+
// ../ts/quality/pure/names.ts
|
|
10956
|
+
var QUALITY_OUTCOMES = [...OUTCOMES, "not_run"];
|
|
10957
|
+
function isQualityOutcome(text) {
|
|
10958
|
+
return QUALITY_OUTCOMES.includes(text);
|
|
10959
|
+
}
|
|
10960
|
+
var GRADES = ["E0", "E1", "E2", "E3", "E4", "E5"];
|
|
10961
|
+
function isGrade(text) {
|
|
10962
|
+
return GRADES.includes(text);
|
|
10963
|
+
}
|
|
10964
|
+
var ATTR = {
|
|
10965
|
+
grade: "ifc.quality.grade",
|
|
10966
|
+
previous: "ifc.quality.previous.sha256",
|
|
10967
|
+
characteristic: "ifc.test.characteristic",
|
|
10968
|
+
notRun: "ifc.quality.not_run",
|
|
10969
|
+
rule: "ifc.check.rule",
|
|
10970
|
+
line: "code.line.number"
|
|
10971
|
+
};
|
|
10972
|
+
var QUALITY_BRANCH = "quality";
|
|
10973
|
+
var EVIDENCE_ROOT = "quality/evidence";
|
|
10974
|
+
var CASE_EVENT = "ifc.test.case";
|
|
10975
|
+
var RUN_GRADE = "E3";
|
|
10976
|
+
var NO_GRADE = "E0";
|
|
10977
|
+
// ../ts/kernel/evidence.ts
|
|
10978
|
+
var GENESIS = "0".repeat(64);
|
|
10979
|
+
var sha256Decoder = (input, path = "$") => {
|
|
10980
|
+
const s = typeof input === "string" && /^[0-9a-f]{64}$/.test(input) ? sha256Of(input) : undefined;
|
|
10981
|
+
return s === undefined ? err({ kind: "decode", path, expected: "a SHA-256 (64 lower-case hexadecimal digits)", found: typeof input }) : ok(s);
|
|
10982
|
+
};
|
|
10983
|
+
var ledgerEntryDecoder = object({
|
|
10984
|
+
seq: refine(integer, "positive", (n) => n >= 1),
|
|
10985
|
+
prev: sha256Decoder,
|
|
10986
|
+
at: instantDecoder,
|
|
10987
|
+
kind: string,
|
|
10988
|
+
subject: object({ kind: string, id: string }),
|
|
10989
|
+
evidence: sha256Decoder,
|
|
10990
|
+
digest: sha256Decoder
|
|
10991
|
+
});
|
|
10992
|
+
var manifestDecoder2 = object({
|
|
10993
|
+
files: array(object({ path: string, size: refine(integer, "size", (n) => n >= 0), sha256: sha256Decoder }))
|
|
10994
|
+
});
|
|
10995
|
+
|
|
10996
|
+
// ../ts/kernel/assess.ts
|
|
10997
|
+
var impactDeclarationDecoder = object({ paths: array(string), controls: array(string) });
|
|
10998
|
+
var RISK_LEVELS = ["very-low", "low", "moderate", "high", "very-high"];
|
|
10999
|
+
var levelDecoder = literal(...RISK_LEVELS);
|
|
11000
|
+
var riskDecoder = object({
|
|
11001
|
+
id: string,
|
|
11002
|
+
title: string,
|
|
11003
|
+
likelihood: levelDecoder,
|
|
11004
|
+
impact: levelDecoder,
|
|
11005
|
+
treatment: literal("accept", "mitigate", "transfer", "avoid"),
|
|
11006
|
+
owner: roleDecoder,
|
|
11007
|
+
reviewBy: instantDecoder
|
|
11008
|
+
}, { description: string, controls: array(string) });
|
|
11009
|
+
|
|
11010
|
+
// ../ts/kernel/oscal.ts
|
|
11011
|
+
var OPEN_OUTCOMES = new Set(["fail", "warn", "gap", "error", "accepted"]);
|
|
11012
|
+
|
|
11064
11013
|
// ../ts/kernel/test-report.ts
|
|
11065
11014
|
var byText = (a, b) => a < b ? -1 : a > b ? 1 : 0;
|
|
11066
11015
|
function testOf(s, runtime) {
|
|
@@ -11191,7 +11140,7 @@ function requirementsOf2(tests, reviews, required) {
|
|
|
11191
11140
|
};
|
|
11192
11141
|
});
|
|
11193
11142
|
}
|
|
11194
|
-
function
|
|
11143
|
+
function judge(input) {
|
|
11195
11144
|
const failures = [];
|
|
11196
11145
|
const counts = countsOf(input.tests);
|
|
11197
11146
|
const plural = (n, one, many) => `${n} ${n === 1 ? one : many}`;
|
|
@@ -11223,7 +11172,7 @@ function assembleRecord(input) {
|
|
|
11223
11172
|
if (tests.kind === "err")
|
|
11224
11173
|
return tests;
|
|
11225
11174
|
const reviews = [...reviewsOf(closed), ...input.reviews ?? []];
|
|
11226
|
-
const judgement =
|
|
11175
|
+
const judgement = judge({ tests: tests.value, runners: input.runners, required: input.required, reviews });
|
|
11227
11176
|
const resource = installationResource(input.runner);
|
|
11228
11177
|
const runSpan = {
|
|
11229
11178
|
name: RUN_SPAN,
|
|
@@ -11333,32 +11282,7 @@ function readRecord(input) {
|
|
|
11333
11282
|
});
|
|
11334
11283
|
}
|
|
11335
11284
|
var STYLE = "body{font:15px/1.5 system-ui,sans-serif;margin:2rem auto;max-width:72rem;padding:0 1rem;color:#1b1b1b;background:#fff}" + "table{border-collapse:collapse;margin:.5rem 0;width:100%}th,td{border:1px solid #c8c8c8;padding:.25rem .5rem;text-align:left;vertical-align:top;overflow-wrap:anywhere}" + "th{background:#f0f0f0}h1{font-size:1.6rem}h2{font-size:1.2rem;margin-top:2rem}" + "@media (prefers-color-scheme:dark){body{color:#e8e8e8;background:#161616}th{background:#2a2a2a}th,td{border-color:#444}}";
|
|
11336
|
-
// src/platform/k-otel.ts
|
|
11337
|
-
var parseSpanId2 = parseSpanId;
|
|
11338
|
-
var parseTraceId2 = parseTraceId;
|
|
11339
11285
|
|
|
11340
|
-
// ../ts/quality/pure/names.ts
|
|
11341
|
-
var QUALITY_OUTCOMES = [...OUTCOMES, "not_run"];
|
|
11342
|
-
function isQualityOutcome(text) {
|
|
11343
|
-
return QUALITY_OUTCOMES.includes(text);
|
|
11344
|
-
}
|
|
11345
|
-
var GRADES = ["E0", "E1", "E2", "E3", "E4", "E5"];
|
|
11346
|
-
function isGrade(text) {
|
|
11347
|
-
return GRADES.includes(text);
|
|
11348
|
-
}
|
|
11349
|
-
var ATTR = {
|
|
11350
|
-
grade: "ifc.quality.grade",
|
|
11351
|
-
previous: "ifc.quality.previous.sha256",
|
|
11352
|
-
characteristic: "ifc.test.characteristic",
|
|
11353
|
-
notRun: "ifc.quality.not_run",
|
|
11354
|
-
rule: "ifc.check.rule",
|
|
11355
|
-
line: "code.line.number"
|
|
11356
|
-
};
|
|
11357
|
-
var QUALITY_BRANCH = "quality";
|
|
11358
|
-
var EVIDENCE_ROOT = "quality/evidence";
|
|
11359
|
-
var CASE_EVENT = "ifc.test.case";
|
|
11360
|
-
var RUN_GRADE = "E3";
|
|
11361
|
-
var NO_GRADE = "E0";
|
|
11362
11286
|
// ../ts/quality/pure/record.ts
|
|
11363
11287
|
function formatQualityError(e) {
|
|
11364
11288
|
switch (e.kind) {
|
|
@@ -12147,7 +12071,8 @@ function placesOf(env, os) {
|
|
|
12147
12071
|
const shims = d.bin ?? rules.join(tools, "bin");
|
|
12148
12072
|
return ok({ os, data: d.data, state: d.state, cache: d.cache, tools, shims });
|
|
12149
12073
|
}
|
|
12150
|
-
|
|
12074
|
+
// ../ts/kernel/attest.ts
|
|
12075
|
+
var PASSING = new Set(["pass"]);
|
|
12151
12076
|
// src/platform/k-test-record.ts
|
|
12152
12077
|
var TEST_SCOPE2 = TEST_SCOPE;
|
|
12153
12078
|
var installationFromEnv2 = installationFromEnv;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intellectual-frontiers/ergonex",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.5",
|
|
4
4
|
"description": "Ergonex, the workspaces management of Intellectual Frontiers: one command that sets up, configures and operates a team's software repositories, package registries and builds, on Windows, macOS and Linux, with Bun by default and Node 26 as the backup.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"@intellectual-frontiers/core": "0.1.1",
|
|
23
23
|
"@intellectual-frontiers/crypto": "0.1.1",
|
|
24
24
|
"@intellectual-frontiers/formats": "0.1.1",
|
|
25
|
+
"@intellectual-frontiers/net": "0.1.0",
|
|
25
26
|
"@intellectual-frontiers/terminal": "0.1.1"
|
|
26
27
|
},
|
|
27
28
|
"files": [
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* How a typed client reaches a system over HTTP (commons 0005-typescript-runtime FR-040): a transport, live (`fetch`) or recorded (the
|
|
3
|
-
* exchanges a test keeps, so it reaches no host), and over it the guards and helpers every client otherwise rewrites: a read-only guard
|
|
4
|
-
* (safe methods only, POST to the token endpoints named, and the POSTs a predicate says only read, FR-066), AWS Signature Version 4 on each
|
|
5
|
-
* request (FR-069), backoff on 429 and 503 that honours `Retry-After`, a JSON read decoded at the boundary with typed failures (a denied
|
|
6
|
-
* call is told apart, so a caller can record a gap instead of failing), and every item of a list that pages by `Link: rel="next"` or by a
|
|
7
|
-
* cursor in the body. A request that carries a credential is refused before it is sent unless the transport is made to allow it, so a
|
|
8
|
-
* harness whose proxy injects credentials never sends one by mistake. Taken from erga's `lib/ts/http-client` and Stolos's connector SDK
|
|
9
|
-
* (`src/archon/connect/sdk.ts`, `connector.ts`).
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```ts
|
|
13
|
-
* import { array, object, string } from "@intellectual-frontiers/core";
|
|
14
|
-
* import { getJson, liveTransport, withBackoff } from "./http-client.js";
|
|
15
|
-
* const http = withBackoff(liveTransport());
|
|
16
|
-
* const repo = await getJson(http, "https://api.github.com/repos/oven-sh/bun", object({ full_name: string }));
|
|
17
|
-
* ```
|
|
18
|
-
*
|
|
19
|
-
* @module
|
|
20
|
-
*/
|
|
21
|
-
import { type Decoder, type Result } from "@intellectual-frontiers/core";
|
|
22
|
-
import { type AwsCredentials } from "@intellectual-frontiers/crypto/sigv4";
|
|
23
|
-
/** A request a client makes. */
|
|
24
|
-
export type OutRequest = {
|
|
25
|
-
readonly method: "GET" | "HEAD" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
26
|
-
readonly url: string;
|
|
27
|
-
readonly headers: Readonly<Record<string, string>>;
|
|
28
|
-
readonly body?: string;
|
|
29
|
-
/** Read the answer as bytes (`Exchange.bytes`), for an artifact that is not text (a tarball, a zip); the text `body` of the answer is then empty. */
|
|
30
|
-
readonly binary?: boolean;
|
|
31
|
-
};
|
|
32
|
-
/** One exchange: a request and what answered it. */
|
|
33
|
-
export type Exchange = {
|
|
34
|
-
readonly method: OutRequest["method"];
|
|
35
|
-
readonly url: string;
|
|
36
|
-
readonly status: number;
|
|
37
|
-
/** The headers kept: the content type, paging, rate limits and `Retry-After`. */
|
|
38
|
-
readonly headers: Readonly<Record<string, string>>;
|
|
39
|
-
readonly body: string;
|
|
40
|
-
/** The answer's bytes: present where the request asked for `binary` (a recorded exchange of an artifact holds them). */
|
|
41
|
-
readonly bytes?: Uint8Array;
|
|
42
|
-
};
|
|
43
|
-
/** Why a request got no answer at all (a refusal before it was sent, or the network). */
|
|
44
|
-
export type TransportError = {
|
|
45
|
-
readonly kind: "refused";
|
|
46
|
-
readonly message: string;
|
|
47
|
-
} | {
|
|
48
|
-
readonly kind: "network";
|
|
49
|
-
readonly message: string;
|
|
50
|
-
};
|
|
51
|
-
/** A way to reach a system. */
|
|
52
|
-
export type Transport = {
|
|
53
|
-
readonly kind: "live" | "recorded";
|
|
54
|
-
readonly send: (r: OutRequest) => Promise<Result<Exchange, TransportError>>;
|
|
55
|
-
};
|
|
56
|
-
/** The headers a credential travels in. */
|
|
57
|
-
export declare const CREDENTIAL_HEADERS: readonly string[];
|
|
58
|
-
/** Why a request may not be sent where credentials are refused: it carries one in a header or in its query. Undefined where it carries none. */
|
|
59
|
-
export declare function carriesCredential(r: OutRequest): string | undefined;
|
|
60
|
-
/** How the live transport sends. */
|
|
61
|
-
export type LiveOptions = {
|
|
62
|
-
/** The `fetch` to use (the platform's by default). */
|
|
63
|
-
readonly fetch?: typeof fetch;
|
|
64
|
-
/** Refuse a request that carries a credential (the default), or send it. */
|
|
65
|
-
readonly credentials?: "refuse" | "allow";
|
|
66
|
-
/** The `User-Agent` said to every system: a generic name, never a person's. */
|
|
67
|
-
readonly userAgent?: string;
|
|
68
|
-
/** No answer within this many seconds fails the request (30 by default). */
|
|
69
|
-
readonly timeoutSeconds?: number;
|
|
70
|
-
};
|
|
71
|
-
/** The live transport, over `fetch`. */
|
|
72
|
-
export declare function liveTransport(options?: LiveOptions): Transport;
|
|
73
|
-
/** A transport that answers from recorded exchanges, by method and URL, and refuses a request it has none for, naming it. */
|
|
74
|
-
export declare function recordedTransport(exchanges: readonly Exchange[]): Transport;
|
|
75
|
-
/**
|
|
76
|
-
* Whether a `POST` only reads (FR-066): a GraphQL query, a search, a JSON API's `Describe` and `Get` actions. It is given the whole
|
|
77
|
-
* request (method, URL, headers and body), as an action may be named in a header (`x-amz-target`) or the body.
|
|
78
|
-
*/
|
|
79
|
-
export type ReadPost = (r: OutRequest) => boolean;
|
|
80
|
-
/**
|
|
81
|
-
* A transport that sends only safe methods (GET, HEAD, ...), POST to URLs that start with one of `tokenEndpoints`, and the POSTs that
|
|
82
|
-
* `readPost` says only read (FR-066). Every other request (PUT, PATCH, DELETE, any other POST) is refused without being sent.
|
|
83
|
-
*/
|
|
84
|
-
export declare function readOnly(t: Transport, tokenEndpoints?: readonly string[], readPost?: ReadPost): Transport;
|
|
85
|
-
/** How {@link withSigV4} signs. */
|
|
86
|
-
export type SigV4TransportOptions = {
|
|
87
|
-
readonly credentials: AwsCredentials;
|
|
88
|
-
readonly region: string;
|
|
89
|
-
readonly service: string;
|
|
90
|
-
/** The clock read as each request is sent (`new Date()` by default; a test gives its own). */
|
|
91
|
-
readonly now?: () => Date;
|
|
92
|
-
/** Sign `UNSIGNED-PAYLOAD` instead of the body's hash (S3 allows it). */
|
|
93
|
-
readonly unsignedPayload?: boolean;
|
|
94
|
-
};
|
|
95
|
-
/**
|
|
96
|
-
* A transport that signs each request by AWS Signature Version 4 (FR-069, by the kernel's `sigv4`, FR-068) when it is sent. A signed
|
|
97
|
-
* request carries a credential, so the live transport under it must be made with `credentials: "allow"`, or it refuses the request.
|
|
98
|
-
*/
|
|
99
|
-
export declare function withSigV4(t: Transport, options: SigV4TransportOptions): Transport;
|
|
100
|
-
/** How long to back off. */
|
|
101
|
-
export type BackoffOptions = {
|
|
102
|
-
/** Tries after the first (3 by default). */
|
|
103
|
-
readonly retries?: number;
|
|
104
|
-
/** How a wait is spent (a timer by default; a test passes one that returns at once). */
|
|
105
|
-
readonly pause?: (ms: number) => Promise<void>;
|
|
106
|
-
/** The longest wait, whatever `Retry-After` asks (60 s by default). */
|
|
107
|
-
readonly capMs?: number;
|
|
108
|
-
};
|
|
109
|
-
/** A transport that waits and tries again on 429 and 503: as long as `Retry-After` asks (up to the cap), else 1, 2, 4 seconds. */
|
|
110
|
-
export declare function withBackoff(t: Transport, options?: BackoffOptions): Transport;
|
|
111
|
-
/** Why a JSON read failed. */
|
|
112
|
-
export type ReadError = TransportError | {
|
|
113
|
-
readonly kind: "denied";
|
|
114
|
-
readonly status: 401 | 403;
|
|
115
|
-
readonly url: string;
|
|
116
|
-
} | {
|
|
117
|
-
readonly kind: "status";
|
|
118
|
-
readonly status: number;
|
|
119
|
-
readonly url: string;
|
|
120
|
-
} | {
|
|
121
|
-
readonly kind: "decode";
|
|
122
|
-
readonly url: string;
|
|
123
|
-
readonly message: string;
|
|
124
|
-
};
|
|
125
|
-
/** A read error as one sentence; never a header or a body, so no credential or personal datum is said. */
|
|
126
|
-
export declare function formatReadError(e: ReadError): string;
|
|
127
|
-
/** A GET whose JSON body is decoded, with the exchange; 401 and 403 are `denied`, any other status from 400 up is `status`. */
|
|
128
|
-
export declare function getExchange<T>(t: Transport, url: string, decoder: Decoder<T>, headers?: Readonly<Record<string, string>>): Promise<Result<{
|
|
129
|
-
readonly value: T;
|
|
130
|
-
readonly exchange: Exchange;
|
|
131
|
-
}, ReadError>>;
|
|
132
|
-
/** A GET whose JSON body is decoded. */
|
|
133
|
-
export declare function getJson<T>(t: Transport, url: string, decoder: Decoder<T>, headers?: Readonly<Record<string, string>>): Promise<Result<T, ReadError>>;
|
|
134
|
-
/** Every page of a list that pages by `Link: <...>; rel="next"`, at most `maxPages` (200 by default); the first failure ends it, as an error. */
|
|
135
|
-
export declare function linkPages<T>(t: Transport, url: string, item: Decoder<T>, options?: {
|
|
136
|
-
readonly headers?: Readonly<Record<string, string>>;
|
|
137
|
-
readonly maxPages?: number;
|
|
138
|
-
}): AsyncGenerator<T, Result<number, ReadError>>;
|
|
139
|
-
/** Every item of a list that pages by a cursor in its body: `items` takes a page's items, `next` the next page's URL or undefined. */
|
|
140
|
-
export declare function cursorPages<B, T>(t: Transport, first: string, page: Decoder<B>, items: (body: B) => readonly T[], next: (body: B, url: string) => string | undefined, options?: {
|
|
141
|
-
readonly headers?: Readonly<Record<string, string>>;
|
|
142
|
-
readonly maxPages?: number;
|
|
143
|
-
}): AsyncGenerator<T, Result<number, ReadError>>;
|
|
144
|
-
/** A recorded exchange read from the JSON5 text `recordedText` writes, or why it is not one. */
|
|
145
|
-
export declare function decodeRecorded(text: string): Result<Exchange, string>;
|
|
146
|
-
/** The text a recorded exchange is kept in: a comment that says where and when it was recorded, then the exchange as JSON5. */
|
|
147
|
-
export declare function recordedText(x: Exchange, note: string): string;
|
|
148
|
-
/** Headers that give a bearer token (for a transport made to allow credentials). */
|
|
149
|
-
export declare function bearer(token: string, scheme?: string): Readonly<Record<string, string>>;
|