@intellectual-frontiers/ergonex 0.2.6 → 0.3.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.
- package/README.md +2 -0
- package/dist/desired.d.ts +27 -0
- package/dist/diff.d.ts +12 -0
- package/dist/doctor.d.ts +79 -0
- package/dist/findings.d.ts +85 -0
- package/dist/layout.d.ts +83 -0
- package/dist/manifest.d.ts +84 -0
- package/dist/mod.d.ts +29 -0
- package/dist/mod.js +3927 -0
- package/dist/modules/external.d.ts +31 -0
- package/dist/modules/mod.d.ts +10 -0
- package/dist/modules/name.d.ts +32 -0
- package/dist/modules/registry.d.ts +51 -0
- package/dist/modules/types.d.ts +178 -0
- package/dist/places.d.ts +35 -0
- package/dist/plan.d.ts +176 -0
- package/dist/platform/k-args.d.ts +7 -0
- package/dist/policy.d.ts +39 -0
- package/dist/portable.d.ts +111 -0
- package/dist/render.d.ts +95 -0
- package/dist/setup/evidence.d.ts +58 -0
- package/dist/shell/block.d.ts +45 -0
- package/dist/shell/mod.d.ts +8 -0
- package/dist/shell/snippet.d.ts +43 -0
- package/dist/state-record.d.ts +59 -0
- package/dist/state.d.ts +64 -0
- package/dist/templates/data.d.ts +25 -0
- package/dist/templates/hooks.d.ts +13 -0
- package/dist/templates/mod.d.ts +16 -0
- package/dist/tools/catalog.d.ts +70 -0
- package/dist/types.d.ts +51 -0
- package/dist/vendor/ts/githost/capabilities.d.ts +18 -0
- package/dist/vendor/ts/githost/git.d.ts +16 -0
- package/dist/vendor/ts/githost/github.d.ts +15 -0
- package/dist/vendor/ts/githost/gitlab.d.ts +15 -0
- package/dist/vendor/ts/githost/mod.d.ts +29 -0
- package/dist/vendor/ts/githost/remote.d.ts +59 -0
- package/dist/vendor/ts/githost/types.d.ts +101 -0
- package/dist/vendor/ts/kernel/archive.d.ts +147 -0
- package/dist/vendor/ts/kernel/assess.d.ts +247 -0
- package/dist/vendor/ts/kernel/attest.d.ts +164 -0
- package/dist/vendor/ts/kernel/base64.d.ts +24 -0
- package/dist/vendor/ts/kernel/cbor.d.ts +39 -0
- package/dist/vendor/ts/kernel/cms.d.ts +106 -0
- package/dist/vendor/ts/kernel/cose.d.ts +34 -0
- package/dist/vendor/ts/kernel/crypt.d.ts +30 -0
- package/dist/vendor/ts/kernel/csv.d.ts +38 -0
- package/dist/vendor/ts/kernel/der.d.ts +67 -0
- package/dist/vendor/ts/kernel/documentation.d.ts +118 -0
- package/dist/vendor/ts/kernel/dsse.d.ts +137 -0
- package/dist/vendor/ts/kernel/evidence.d.ts +212 -0
- package/dist/vendor/ts/kernel/glob.d.ts +64 -0
- package/dist/vendor/ts/kernel/grc.d.ts +356 -0
- package/dist/vendor/ts/kernel/http.d.ts +46 -0
- package/dist/vendor/ts/kernel/json5.d.ts +46 -0
- package/dist/vendor/ts/kernel/layers.d.ts +35 -0
- package/dist/vendor/ts/kernel/md5.d.ts +19 -0
- package/dist/vendor/ts/kernel/media-types.d.ts +28 -0
- package/dist/vendor/ts/kernel/mod.d.ts +89 -0
- package/dist/vendor/ts/kernel/ocsf-types.auto.d.ts +4374 -0
- package/dist/vendor/ts/kernel/ocsf.d.ts +160 -0
- package/dist/vendor/ts/kernel/oscal.d.ts +356 -0
- package/dist/vendor/ts/kernel/otel.d.ts +365 -0
- package/dist/vendor/ts/kernel/otlp.d.ts +83 -0
- package/dist/vendor/ts/kernel/png.d.ts +124 -0
- package/dist/vendor/ts/kernel/render.d.ts +111 -0
- package/dist/vendor/ts/kernel/schedule.d.ts +207 -0
- package/dist/vendor/ts/kernel/semver.d.ts +94 -0
- package/dist/vendor/ts/kernel/sha256.d.ts +29 -0
- package/dist/vendor/ts/kernel/signals.d.ts +371 -0
- package/dist/vendor/ts/kernel/sigv4.d.ts +67 -0
- package/dist/vendor/ts/kernel/test-record.d.ts +222 -0
- package/dist/vendor/ts/kernel/test-report.d.ts +294 -0
- package/dist/vendor/ts/kernel/toml.d.ts +51 -0
- package/dist/vendor/ts/kernel/trace.d.ts +169 -0
- package/dist/vendor/ts/kernel/ts-literal.d.ts +62 -0
- package/dist/vendor/ts/kernel/uuid.d.ts +53 -0
- package/dist/vendor/ts/kernel/webauthn.d.ts +212 -0
- package/dist/vendor/ts/kernel/xml.d.ts +73 -0
- package/dist/vendor/ts/kernel/yaml.d.ts +44 -0
- package/dist/vendor/ts/runtime/http-client.d.ts +149 -0
- package/ergonex.mjs +3480 -3765
- package/package.json +19 -5
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Assessment: what findings, evidence and declarations add up to (commons 0007-grc FR-010 to FR-015). Every function is pure and takes the
|
|
3
|
+
* instant it judges at as a value.
|
|
4
|
+
*
|
|
5
|
+
* - **Coverage** rolls each catalog control (a requirement) or control up as `gap`, `untested`, `partial`, `addressed` or `covered` (FR-010).
|
|
6
|
+
* - **Freshness** holds the newest evidence to a cadence (an ISO 8601 duration): `fresh`, `due` within the last tenth of the cadence, or
|
|
7
|
+
* `stale`, with the instant it falls due (FR-011).
|
|
8
|
+
* - **Drift** compares a declared and an observed view of keyed records: added, removed and changed, each change with its field's path
|
|
9
|
+
* and both values, in key order (FR-012).
|
|
10
|
+
* - The **change-impact gate** reads declarations of paths (globs) to controls and judges a change `allowed` or `blocked`, with every
|
|
11
|
+
* reason (FR-013).
|
|
12
|
+
* - The **risk register** levels each risk by NIST SP 800-30 Rev. 1's Table I-2 and reports those past their review (FR-014).
|
|
13
|
+
* - The **trace** relates each requirement to the mechanisms that enforce it and the evidence they gave, and names those with none (FR-015).
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* import { riskLevel } from "./assess.js";
|
|
18
|
+
* riskLevel("moderate", "very-high"); // "high"
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @module
|
|
22
|
+
*/
|
|
23
|
+
import { type Decoder } from "@intellectual-frontiers/core";
|
|
24
|
+
import { type Catalog, type CatalogControl, type ControlRef, type Duration, type Finding, type Instant, type Outcome, type Role } from "./grc.js";
|
|
25
|
+
import type { Json } from "./json5.js";
|
|
26
|
+
import type { Sha256 } from "./sha256.js";
|
|
27
|
+
/** The findings of the newest assessment of each control and subject: for each, those with the latest `at`. */
|
|
28
|
+
export declare function newestFindings(findings: readonly Finding[]): readonly Finding[];
|
|
29
|
+
/** How well a requirement or control is met, from the worst to the best. */
|
|
30
|
+
export type CoverageStatus = "gap" | "untested" | "partial" | "addressed" | "covered";
|
|
31
|
+
/**
|
|
32
|
+
* The coverage that subjects' outcomes give, `not-applicable` ones left out: `untested` where none is left, `partial` where one is
|
|
33
|
+
* neither passing nor accepted, `addressed` where every one passes or is accepted and at least one is accepted, `covered` where every one
|
|
34
|
+
* passes.
|
|
35
|
+
*/
|
|
36
|
+
export declare function coverageOf(outcomes: readonly Outcome[]): Exclude<CoverageStatus, "gap">;
|
|
37
|
+
/** A control's coverage from the newest findings of it. */
|
|
38
|
+
export type ControlCoverage = {
|
|
39
|
+
readonly control: string;
|
|
40
|
+
readonly status: Exclude<CoverageStatus, "gap">;
|
|
41
|
+
readonly outcome: Outcome;
|
|
42
|
+
};
|
|
43
|
+
/** Each control's coverage, in the order given, from the newest findings of each control and subject. */
|
|
44
|
+
export declare function controlCoverage(controls: readonly {
|
|
45
|
+
readonly id: string;
|
|
46
|
+
}[], findings: readonly Finding[]): readonly ControlCoverage[];
|
|
47
|
+
/** A requirement's coverage: the catalog control, the controls that implement it, and how well they meet it. */
|
|
48
|
+
export type RequirementCoverage<C extends string = string, I extends string = string> = {
|
|
49
|
+
readonly requirement: ControlRef<C, I>;
|
|
50
|
+
readonly status: CoverageStatus;
|
|
51
|
+
readonly outcome: Outcome;
|
|
52
|
+
readonly controls: readonly string[];
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Every control of a catalog as a requirement, in the catalog's order: `gap` where no control implements it, else the coverage of the
|
|
56
|
+
* newest findings of every control that does (`untested` where there are none).
|
|
57
|
+
*/
|
|
58
|
+
export declare function requirementCoverage<C extends string, E extends CatalogControl>(catalog: Catalog<C, E>, controls: readonly {
|
|
59
|
+
readonly id: string;
|
|
60
|
+
readonly implements: readonly ControlRef[];
|
|
61
|
+
}[], findings: readonly Finding[]): readonly RequirementCoverage<C, E["id"]>[];
|
|
62
|
+
/** Whether evidence is recent enough for its cadence. */
|
|
63
|
+
export type FreshnessStatus = "fresh" | "due" | "stale";
|
|
64
|
+
/** How fresh evidence is: its status, the newest evidence, when it falls due (`null` past the year 9999) and when the `due` window opens. */
|
|
65
|
+
export type Freshness = {
|
|
66
|
+
readonly status: FreshnessStatus;
|
|
67
|
+
readonly cadence: string;
|
|
68
|
+
readonly newest: Instant | null;
|
|
69
|
+
readonly dueAt: Instant | null;
|
|
70
|
+
readonly dueFrom: Instant | null;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* The freshness at `at` of evidence observed at the given instants, held to a cadence: it falls due one cadence after the newest; it is
|
|
74
|
+
* `stale` after that instant, `due` in the last tenth of the cadence up to and at it, `fresh` before. No evidence at all is `stale`, due at `at`.
|
|
75
|
+
*/
|
|
76
|
+
export declare function freshness(cadence: Duration, evidence: readonly Instant[], at: Instant): Freshness;
|
|
77
|
+
/** The freshness of each control's newest finding, held to the control's cadence, in the order given. */
|
|
78
|
+
export declare function controlFreshness(controls: readonly {
|
|
79
|
+
readonly id: string;
|
|
80
|
+
readonly cadence: Duration;
|
|
81
|
+
}[], findings: readonly Finding[], at: Instant): readonly {
|
|
82
|
+
readonly control: string;
|
|
83
|
+
readonly freshness: Freshness;
|
|
84
|
+
}[];
|
|
85
|
+
/** One step of a field's path: a member name or an array index. */
|
|
86
|
+
export type PathStep = string | number;
|
|
87
|
+
/** A field that differs: its path inside the record, and its value on each side (absent where that side does not have it). */
|
|
88
|
+
export type FieldChange = {
|
|
89
|
+
readonly path: readonly PathStep[];
|
|
90
|
+
readonly field: string;
|
|
91
|
+
readonly declared?: Json;
|
|
92
|
+
readonly observed?: Json;
|
|
93
|
+
};
|
|
94
|
+
/** What differs between a declared and an observed view of keyed records, each list in key order. */
|
|
95
|
+
export type Drift = {
|
|
96
|
+
readonly added: readonly {
|
|
97
|
+
readonly key: string;
|
|
98
|
+
readonly value: Json;
|
|
99
|
+
}[];
|
|
100
|
+
readonly removed: readonly {
|
|
101
|
+
readonly key: string;
|
|
102
|
+
readonly value: Json;
|
|
103
|
+
}[];
|
|
104
|
+
readonly changed: readonly {
|
|
105
|
+
readonly key: string;
|
|
106
|
+
readonly changes: readonly FieldChange[];
|
|
107
|
+
}[];
|
|
108
|
+
};
|
|
109
|
+
/** Keyed records: a map, or an object whose members are the records. */
|
|
110
|
+
export type KeyedView = ReadonlyMap<string, Json> | {
|
|
111
|
+
readonly [key: string]: Json;
|
|
112
|
+
};
|
|
113
|
+
/** A field's path as text, `$` for the record itself: `$.ports[0]`, `$["a b"]`. */
|
|
114
|
+
export declare function formatFieldPath(path: readonly PathStep[]): string;
|
|
115
|
+
/** The field changes between two values: objects compared member by member in key order, arrays index by index, anything else whole. */
|
|
116
|
+
export declare function fieldChanges(declared: Json, observed: Json): readonly FieldChange[];
|
|
117
|
+
/** The drift from what is declared to what is observed: records only observed are added, only declared removed, in both but different changed. */
|
|
118
|
+
export declare function drift(declared: KeyedView, observed: KeyedView): Drift;
|
|
119
|
+
/** Paths (globs) and the controls a change to them bears on. */
|
|
120
|
+
export type ImpactDeclaration = {
|
|
121
|
+
readonly paths: readonly string[];
|
|
122
|
+
readonly controls: readonly string[];
|
|
123
|
+
};
|
|
124
|
+
/** A change: the paths it touches, the reviews it says it needs (by role) and the reviews given. */
|
|
125
|
+
export type Change = {
|
|
126
|
+
readonly paths: readonly string[];
|
|
127
|
+
readonly needsReview?: readonly Role[];
|
|
128
|
+
readonly reviewedBy?: readonly Role[];
|
|
129
|
+
};
|
|
130
|
+
/** The outcomes that block a change to the paths of a control. */
|
|
131
|
+
export type BlockingOutcome = "fail" | "error" | "gap";
|
|
132
|
+
/** Why a change is blocked. */
|
|
133
|
+
export type GateReason = {
|
|
134
|
+
readonly kind: "control";
|
|
135
|
+
readonly control: string;
|
|
136
|
+
readonly outcome: BlockingOutcome;
|
|
137
|
+
readonly paths: readonly string[];
|
|
138
|
+
} | {
|
|
139
|
+
readonly kind: "review";
|
|
140
|
+
readonly role: Role;
|
|
141
|
+
};
|
|
142
|
+
/** A control a change bears on, and the touched paths declared for it. */
|
|
143
|
+
export type Touched = {
|
|
144
|
+
readonly control: string;
|
|
145
|
+
readonly paths: readonly string[];
|
|
146
|
+
};
|
|
147
|
+
/** The gate's judgement of a change, with every control it touches; where blocked, every reason. */
|
|
148
|
+
export type GateDecision = {
|
|
149
|
+
readonly kind: "allowed";
|
|
150
|
+
readonly touched: readonly Touched[];
|
|
151
|
+
} | {
|
|
152
|
+
readonly kind: "blocked";
|
|
153
|
+
readonly touched: readonly Touched[];
|
|
154
|
+
readonly reasons: readonly [GateReason, ...GateReason[]];
|
|
155
|
+
};
|
|
156
|
+
/** A gate reason as one sentence. */
|
|
157
|
+
export declare function formatGateReason(r: GateReason): string;
|
|
158
|
+
/** Each control's newest outcome: the join of its newest findings' outcomes. */
|
|
159
|
+
export declare function newestOutcomes(findings: readonly Finding[]): ReadonlyMap<string, Outcome>;
|
|
160
|
+
/**
|
|
161
|
+
* A change judged against the declarations and each control's newest outcome: `blocked` where a touched path is declared for a control
|
|
162
|
+
* whose outcome is `fail`, `error` or `gap` (a control with no outcome does not block), or where a review the change needs was not given;
|
|
163
|
+
* else `allowed`. Reasons: controls in id order, then reviews in role order.
|
|
164
|
+
*/
|
|
165
|
+
export declare function gate(declarations: readonly ImpactDeclaration[], change: Change, outcomes: ReadonlyMap<string, Outcome>): GateDecision;
|
|
166
|
+
/** An impact declaration as a file holds it. */
|
|
167
|
+
export declare const impactDeclarationDecoder: Decoder<ImpactDeclaration>;
|
|
168
|
+
/** NIST SP 800-30's five qualitative levels, from the least to the greatest. */
|
|
169
|
+
export declare const RISK_LEVELS: readonly ["very-low", "low", "moderate", "high", "very-high"];
|
|
170
|
+
/** A qualitative level of likelihood, impact or risk (NIST SP 800-30 Rev. 1, Appendices G to I). */
|
|
171
|
+
export type RiskLevel = (typeof RISK_LEVELS)[number];
|
|
172
|
+
/**
|
|
173
|
+
* NIST SP 800-30 Rev. 1, Table I-2, "Assessment scale – level of risk (combination of likelihood and impact)": the level of risk for a
|
|
174
|
+
* likelihood (the row) and an impact (the column).
|
|
175
|
+
*/
|
|
176
|
+
export declare const RISK_MATRIX: Readonly<Record<RiskLevel, Readonly<Record<RiskLevel, RiskLevel>>>>;
|
|
177
|
+
/** The level of risk of a likelihood and an impact, by Table I-2. */
|
|
178
|
+
export declare function riskLevel(likelihood: RiskLevel, impact: RiskLevel): RiskLevel;
|
|
179
|
+
/** What is done about a risk. */
|
|
180
|
+
export type Treatment = "accept" | "mitigate" | "transfer" | "avoid";
|
|
181
|
+
/** A risk as it is written: the level is computed. */
|
|
182
|
+
export type RiskInput = {
|
|
183
|
+
readonly id: string;
|
|
184
|
+
readonly title: string;
|
|
185
|
+
readonly description?: string;
|
|
186
|
+
readonly likelihood: RiskLevel;
|
|
187
|
+
readonly impact: RiskLevel;
|
|
188
|
+
readonly treatment: Treatment;
|
|
189
|
+
readonly owner: Role;
|
|
190
|
+
readonly reviewBy: Instant;
|
|
191
|
+
readonly controls?: readonly string[];
|
|
192
|
+
};
|
|
193
|
+
/** A risk with its level. */
|
|
194
|
+
export type Risk = RiskInput & {
|
|
195
|
+
readonly level: RiskLevel;
|
|
196
|
+
};
|
|
197
|
+
/** A risk past its review date at the instant the register was taken. */
|
|
198
|
+
export type OverdueReview = {
|
|
199
|
+
readonly risk: string;
|
|
200
|
+
readonly owner: Role;
|
|
201
|
+
readonly reviewBy: Instant;
|
|
202
|
+
};
|
|
203
|
+
/** A register: its risks from the greatest level to the least (then by id), and those past their review. */
|
|
204
|
+
export type RiskRegister = {
|
|
205
|
+
readonly at: Instant;
|
|
206
|
+
readonly risks: readonly Risk[];
|
|
207
|
+
readonly overdue: readonly OverdueReview[];
|
|
208
|
+
};
|
|
209
|
+
/** A risk with its level computed. */
|
|
210
|
+
export declare function defineRisk(r: RiskInput): Risk;
|
|
211
|
+
/** The register of some risks at an instant: each levelled, and each whose review date is before the instant reported overdue. */
|
|
212
|
+
export declare function riskRegister(risks: readonly RiskInput[], at: Instant): RiskRegister;
|
|
213
|
+
/** A risk as a file holds it. */
|
|
214
|
+
export declare const riskDecoder: Decoder<RiskInput>;
|
|
215
|
+
/** What enforces requirements: a control, a policy, a process, named by its id. */
|
|
216
|
+
export type Mechanism<R extends string = string> = {
|
|
217
|
+
readonly id: string;
|
|
218
|
+
readonly enforces: readonly R[];
|
|
219
|
+
};
|
|
220
|
+
/** A piece of evidence a mechanism gave. */
|
|
221
|
+
export type EvidenceLink = {
|
|
222
|
+
readonly mechanism: string;
|
|
223
|
+
readonly digest: Sha256;
|
|
224
|
+
};
|
|
225
|
+
/** Why a requirement is unproven: no mechanism enforces it, or none that does gave evidence. */
|
|
226
|
+
export type Unproven = "unenforced" | "unevidenced";
|
|
227
|
+
/** One requirement's trace: each mechanism that enforces it with the evidence it gave (digests in order, once each). */
|
|
228
|
+
export type RequirementTrace<R extends string = string> = {
|
|
229
|
+
readonly requirement: R;
|
|
230
|
+
readonly status: "proven" | Unproven;
|
|
231
|
+
readonly mechanisms: readonly {
|
|
232
|
+
readonly id: string;
|
|
233
|
+
readonly evidence: readonly Sha256[];
|
|
234
|
+
}[];
|
|
235
|
+
};
|
|
236
|
+
/** Every requirement's trace in the order given, and those unproven. */
|
|
237
|
+
export type Trace<R extends string = string> = {
|
|
238
|
+
readonly requirements: readonly RequirementTrace<R>[];
|
|
239
|
+
readonly unproven: readonly {
|
|
240
|
+
readonly requirement: R;
|
|
241
|
+
readonly reason: Unproven;
|
|
242
|
+
}[];
|
|
243
|
+
};
|
|
244
|
+
/** The trace of requirements to mechanisms to evidence; a requirement is proven where a mechanism that enforces it gave evidence. */
|
|
245
|
+
export declare function trace<const R extends string>(requirements: readonly R[], mechanisms: readonly Mechanism<NoInfer<R>>[], evidence: readonly EvidenceLink[]): Trace<R>;
|
|
246
|
+
/** The evidence that findings carry, as links from their controls (the mechanisms) to the digests. */
|
|
247
|
+
export declare function evidenceOfFindings(findings: readonly Finding[]): readonly EvidenceLink[];
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { type ResourceDescriptor, type Statement } from "./dsse.js";
|
|
2
|
+
import { type Assessment, type Instant } from "./grc.js";
|
|
3
|
+
import { type Sha256 } from "./sha256.js";
|
|
4
|
+
import { type Uuid } from "./uuid.js";
|
|
5
|
+
/** A CycloneDX 1.6 component type. */
|
|
6
|
+
export type CdxComponentType = "application" | "framework" | "library" | "container" | "platform" | "operating-system" | "device" | "device-driver" | "firmware" | "file" | "machine-learning-model" | "data" | "cryptographic-asset";
|
|
7
|
+
/** A requirement of a standard. */
|
|
8
|
+
export type CdxRequirement = {
|
|
9
|
+
readonly "bom-ref": string;
|
|
10
|
+
readonly identifier: string;
|
|
11
|
+
readonly title?: string;
|
|
12
|
+
readonly text?: string;
|
|
13
|
+
};
|
|
14
|
+
/** A standard (`definitions.standards`): its requirements, and what is known of it. */
|
|
15
|
+
export type CdxStandard = {
|
|
16
|
+
readonly "bom-ref": string;
|
|
17
|
+
readonly name: string;
|
|
18
|
+
readonly version?: string;
|
|
19
|
+
readonly description?: string;
|
|
20
|
+
readonly owner?: string;
|
|
21
|
+
readonly requirements: readonly CdxRequirement[];
|
|
22
|
+
};
|
|
23
|
+
/** An assessor. */
|
|
24
|
+
export type CdxAssessor = {
|
|
25
|
+
readonly "bom-ref": string;
|
|
26
|
+
readonly thirdParty: boolean;
|
|
27
|
+
readonly organization: {
|
|
28
|
+
readonly name: string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
/** How far a requirement is met: a score from 0 to 1 and why. */
|
|
32
|
+
export type CdxConformance = {
|
|
33
|
+
readonly score: number;
|
|
34
|
+
readonly rationale: string;
|
|
35
|
+
};
|
|
36
|
+
/** One requirement of an attestation, with the claims and counter-claims that bear on it. */
|
|
37
|
+
export type CdxAttestationMapItem = {
|
|
38
|
+
readonly requirement: string;
|
|
39
|
+
readonly claims: readonly string[];
|
|
40
|
+
readonly counterClaims?: readonly string[];
|
|
41
|
+
readonly conformance: CdxConformance;
|
|
42
|
+
};
|
|
43
|
+
/** An attestation: an assessor's map of requirements to claims. */
|
|
44
|
+
export type CdxAttestation = {
|
|
45
|
+
readonly summary: string;
|
|
46
|
+
readonly assessor: string;
|
|
47
|
+
readonly map: readonly CdxAttestationMapItem[];
|
|
48
|
+
};
|
|
49
|
+
/** A claim about a target, with the evidence for it and against it. */
|
|
50
|
+
export type CdxClaim = {
|
|
51
|
+
readonly "bom-ref": string;
|
|
52
|
+
readonly target: string;
|
|
53
|
+
readonly predicate: string;
|
|
54
|
+
readonly reasoning: string;
|
|
55
|
+
readonly evidence?: readonly string[];
|
|
56
|
+
readonly counterEvidence?: readonly string[];
|
|
57
|
+
};
|
|
58
|
+
/** A piece of evidence: what it is, when it was made, and where its data is. */
|
|
59
|
+
export type CdxEvidence = {
|
|
60
|
+
readonly "bom-ref": string;
|
|
61
|
+
readonly description: string;
|
|
62
|
+
readonly data?: readonly {
|
|
63
|
+
readonly name: string;
|
|
64
|
+
readonly contents: {
|
|
65
|
+
readonly url: string;
|
|
66
|
+
};
|
|
67
|
+
}[];
|
|
68
|
+
readonly created: Instant;
|
|
69
|
+
};
|
|
70
|
+
/** A component claims are about. */
|
|
71
|
+
export type CdxTargetComponent = {
|
|
72
|
+
readonly "bom-ref": string;
|
|
73
|
+
readonly type: CdxComponentType;
|
|
74
|
+
readonly name: string;
|
|
75
|
+
readonly version?: string;
|
|
76
|
+
};
|
|
77
|
+
/** CycloneDX 1.6 declarations. */
|
|
78
|
+
export type CdxDeclarations = {
|
|
79
|
+
readonly assessors: readonly CdxAssessor[];
|
|
80
|
+
readonly attestations: readonly CdxAttestation[];
|
|
81
|
+
readonly claims: readonly CdxClaim[];
|
|
82
|
+
readonly evidence: readonly CdxEvidence[];
|
|
83
|
+
readonly targets: {
|
|
84
|
+
readonly components: readonly CdxTargetComponent[];
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
/** A tool that made a BOM. */
|
|
88
|
+
export type CdxTool = {
|
|
89
|
+
readonly type: "application";
|
|
90
|
+
readonly name: string;
|
|
91
|
+
readonly version: string;
|
|
92
|
+
};
|
|
93
|
+
/** A minimal CycloneDX 1.6 BOM that carries declarations. */
|
|
94
|
+
export type CdxBom = {
|
|
95
|
+
readonly bomFormat: "CycloneDX";
|
|
96
|
+
readonly specVersion: "1.6";
|
|
97
|
+
readonly serialNumber: `urn:uuid:${string}`;
|
|
98
|
+
readonly version: 1;
|
|
99
|
+
readonly metadata: {
|
|
100
|
+
readonly timestamp: Instant;
|
|
101
|
+
readonly tools?: {
|
|
102
|
+
readonly components: readonly CdxTool[];
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
readonly definitions: {
|
|
106
|
+
readonly standards: readonly CdxStandard[];
|
|
107
|
+
};
|
|
108
|
+
readonly declarations: CdxDeclarations;
|
|
109
|
+
};
|
|
110
|
+
/** What an attestation needs beyond the assessment. */
|
|
111
|
+
export type AttestOptions = {
|
|
112
|
+
/** The namespace of the BOM's serial number and of its evidence's UUIDs. */
|
|
113
|
+
readonly namespace: Uuid;
|
|
114
|
+
readonly assessor: {
|
|
115
|
+
readonly name: string;
|
|
116
|
+
readonly thirdParty: boolean;
|
|
117
|
+
};
|
|
118
|
+
/** What the claims are about. */
|
|
119
|
+
readonly target: {
|
|
120
|
+
readonly name: string;
|
|
121
|
+
readonly type?: CdxComponentType;
|
|
122
|
+
readonly version?: string;
|
|
123
|
+
};
|
|
124
|
+
readonly tool?: {
|
|
125
|
+
readonly name: string;
|
|
126
|
+
readonly version: string;
|
|
127
|
+
};
|
|
128
|
+
/** What is known of each catalog, by its id. */
|
|
129
|
+
readonly standards?: Readonly<Record<string, {
|
|
130
|
+
readonly name?: string;
|
|
131
|
+
readonly version?: string;
|
|
132
|
+
readonly owner?: string;
|
|
133
|
+
readonly description?: string;
|
|
134
|
+
}>>;
|
|
135
|
+
readonly summary?: string;
|
|
136
|
+
};
|
|
137
|
+
/** An RFC 6920 Named Information URI of a SHA-256: `ni:///sha-256;` and the digest in base64url without padding. */
|
|
138
|
+
export declare function niUri(digest: Sha256): string;
|
|
139
|
+
/** An assessment's declarations, and the standards their requirements are of. */
|
|
140
|
+
export declare function declarations(a: Assessment, o: AttestOptions): Promise<{
|
|
141
|
+
readonly standards: readonly CdxStandard[];
|
|
142
|
+
readonly declarations: CdxDeclarations;
|
|
143
|
+
}>;
|
|
144
|
+
/** An assessment as a CycloneDX 1.6 BOM of its declarations: the serial number a version 5 UUID of the pack and time in the namespace. */
|
|
145
|
+
export declare function cyclonedxBom(a: Assessment, o: AttestOptions): Promise<CdxBom>;
|
|
146
|
+
/** The in-toto predicate type of a CycloneDX BOM. */
|
|
147
|
+
export declare const CYCLONEDX_PREDICATE_TYPE = "https://cyclonedx.org/bom";
|
|
148
|
+
/** A statement's subject named by its SHA-256. */
|
|
149
|
+
export type DigestSubject = ResourceDescriptor & {
|
|
150
|
+
readonly digest: {
|
|
151
|
+
readonly sha256: Sha256;
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
/** An in-toto Statement v1 whose predicate type is `T` and predicate `P`, its subjects named by their SHA-256: a `Statement<P>` for DSSE. */
|
|
155
|
+
export type TypedStatement<T extends string, P> = Statement<P> & {
|
|
156
|
+
readonly predicateType: T;
|
|
157
|
+
readonly subject: readonly DigestSubject[];
|
|
158
|
+
};
|
|
159
|
+
/** A subject: the name and the SHA-256 of the bytes. */
|
|
160
|
+
export declare function digestSubject(name: string, bytes: Uint8Array): Promise<DigestSubject>;
|
|
161
|
+
/** An in-toto Statement v1 of a predicate of the type named about the subjects. */
|
|
162
|
+
export declare function intotoStatement<const T extends string, P>(subjects: readonly DigestSubject[], predicateType: T, predicate: P): TypedStatement<T, P>;
|
|
163
|
+
/** A CycloneDX BOM as the predicate of an in-toto statement about the subjects. */
|
|
164
|
+
export declare function bomStatement(bom: CdxBom, subjects: readonly DigestSubject[]): TypedStatement<typeof CYCLONEDX_PREDICATE_TYPE, CdxBom>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base64 and base64url (RFC 4648 §4 and §5), both ways, on bytes (commons 0005-typescript-runtime FR-042): what DSSE envelopes, JWTs, data
|
|
3
|
+
* URLs, PEM and signed URLs carry. Decoding refuses what is not base64 of the alphabet asked for, rather than skipping it; base64url is
|
|
4
|
+
* written without padding and read with or without it. Taken from the helpers Stolos wrote in `src/archon/export/intoto.ts` and S/MIME.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { fromBase64, toBase64, toBase64Url } from "./base64.js";
|
|
9
|
+
* toBase64(new TextEncoder().encode("foobar")); // "Zm9vYmFy"
|
|
10
|
+
* toBase64Url(Uint8Array.of(0xfb, 0xff)); // "-_8"
|
|
11
|
+
* fromBase64("Zm9v"); // { kind: "ok", value: Uint8Array [102, 111, 111] }
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* @module
|
|
15
|
+
*/
|
|
16
|
+
import { type Result } from "@intellectual-frontiers/core";
|
|
17
|
+
/** Bytes as standard base64, padded. */
|
|
18
|
+
export declare function toBase64(bytes: Uint8Array): string;
|
|
19
|
+
/** Standard base64 as bytes; white space between the characters is ignored, and anything else that is not base64 refused. */
|
|
20
|
+
export declare function fromBase64(text: string): Result<Uint8Array, string>;
|
|
21
|
+
/** Bytes as base64url, without padding. */
|
|
22
|
+
export declare function toBase64Url(bytes: Uint8Array): string;
|
|
23
|
+
/** Base64url (padded or not) as bytes; anything else refused. */
|
|
24
|
+
export declare function fromBase64Url(text: string): Result<Uint8Array, string>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type Result } from "@intellectual-frontiers/core";
|
|
2
|
+
/** A map key this module reads and writes: an integer or a text string. */
|
|
3
|
+
export type CborKey = number | bigint | string;
|
|
4
|
+
/** A tagged value (major type 6): its tag number and the value it tags. */
|
|
5
|
+
export type CborTagged = {
|
|
6
|
+
readonly tag: number | bigint;
|
|
7
|
+
readonly value: CborValue;
|
|
8
|
+
};
|
|
9
|
+
/** A CBOR data item as a value: integers (a `bigint` beyond the safe range), floats, strings, bytes, arrays, maps, tags and simple values. */
|
|
10
|
+
export type CborValue = number | bigint | string | Uint8Array | boolean | null | undefined | readonly CborValue[] | ReadonlyMap<CborKey, CborValue> | CborTagged;
|
|
11
|
+
/** Why bytes are not CBOR this reader takes: what, and at which byte. */
|
|
12
|
+
export type CborError = {
|
|
13
|
+
readonly kind: "cbor";
|
|
14
|
+
readonly at: number;
|
|
15
|
+
readonly message: string;
|
|
16
|
+
};
|
|
17
|
+
/** One data item read from a longer input: its value and the offset just after it. */
|
|
18
|
+
export type CborItem = {
|
|
19
|
+
readonly value: CborValue;
|
|
20
|
+
readonly end: number;
|
|
21
|
+
};
|
|
22
|
+
/** The deepest nesting of arrays, maps and tags read. */
|
|
23
|
+
export declare const MAX_DEPTH = 64;
|
|
24
|
+
/** A CBOR error as one line. */
|
|
25
|
+
export declare function formatCborError(e: CborError): string;
|
|
26
|
+
/** Whether a value is a tagged value (rather than a map, an array or bytes). */
|
|
27
|
+
export declare function isTagged(value: CborValue): value is CborTagged;
|
|
28
|
+
/** Whether a value is a map. */
|
|
29
|
+
export declare function isMap(value: CborValue): value is ReadonlyMap<CborKey, CborValue>;
|
|
30
|
+
/** The data item that starts at `offset`, and the offset just after it: for CBOR followed by more bytes (WebAuthn's authenticator data). */
|
|
31
|
+
export declare function decodeCborItem(bytes: Uint8Array, offset?: number): Result<CborItem, CborError>;
|
|
32
|
+
/** The one data item the bytes hold; bytes left after it are an error. */
|
|
33
|
+
export declare function decodeCbor(bytes: Uint8Array): Result<CborValue, CborError>;
|
|
34
|
+
/**
|
|
35
|
+
* A value as CBOR, in the core deterministic encoding: integers (safe `number`s or `bigint`s) in their shortest head, other numbers as
|
|
36
|
+
* doubles, strings as UTF-8, `Uint8Array` as a byte string, arrays, maps with their keys sorted by their encoding, tags and the four
|
|
37
|
+
* simple values. A value no CBOR item can hold (an integer beyond 64 bits) is a programming error and throws a `RangeError`.
|
|
38
|
+
*/
|
|
39
|
+
export declare function encodeCbor(value: CborValue): Uint8Array;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { type Tlv } from "./der.js";
|
|
2
|
+
import { type Result } from "@intellectual-frontiers/core";
|
|
3
|
+
/** The object identifiers used. */
|
|
4
|
+
export declare const OID: {
|
|
5
|
+
readonly data: "1.2.840.113549.1.7.1";
|
|
6
|
+
readonly authEnvelopedData: "1.2.840.113549.1.9.16.1.23";
|
|
7
|
+
readonly aes256gcm: "2.16.840.1.101.3.4.1.46";
|
|
8
|
+
readonly rsaEncryption: "1.2.840.113549.1.1.1";
|
|
9
|
+
readonly rsaesOaep: "1.2.840.113549.1.1.7";
|
|
10
|
+
readonly mgf1: "1.2.840.113549.1.1.8";
|
|
11
|
+
readonly sha256: "2.16.840.1.101.3.4.2.1";
|
|
12
|
+
readonly commonName: "2.5.4.3";
|
|
13
|
+
readonly emailAddress: "1.2.840.113549.1.9.1";
|
|
14
|
+
readonly subjectAltName: "2.5.29.17";
|
|
15
|
+
readonly keyUsage: "2.5.29.15";
|
|
16
|
+
};
|
|
17
|
+
/** Why CMS or a certificate could not be read, written or opened. */
|
|
18
|
+
export type CmsError = {
|
|
19
|
+
readonly kind: "pem";
|
|
20
|
+
readonly message: string;
|
|
21
|
+
} | {
|
|
22
|
+
readonly kind: "certificate";
|
|
23
|
+
readonly message: string;
|
|
24
|
+
} | {
|
|
25
|
+
readonly kind: "unsupported";
|
|
26
|
+
readonly message: string;
|
|
27
|
+
} | {
|
|
28
|
+
readonly kind: "structure";
|
|
29
|
+
readonly message: string;
|
|
30
|
+
} | {
|
|
31
|
+
readonly kind: "no-recipient";
|
|
32
|
+
readonly message: string;
|
|
33
|
+
} | {
|
|
34
|
+
readonly kind: "decrypt";
|
|
35
|
+
readonly message: string;
|
|
36
|
+
};
|
|
37
|
+
/** A CMS error as one sentence. */
|
|
38
|
+
export declare function formatCmsError(e: CmsError): string;
|
|
39
|
+
/** Every PEM block of a label (`CERTIFICATE`, `PRIVATE KEY`) in a text, as DER; none found, or a block that is not base64, is an error. */
|
|
40
|
+
export declare function readPem(text: string, label: string): Result<readonly Uint8Array[], CmsError>;
|
|
41
|
+
/** DER as a PEM block of a label, base64 in 64-column lines. */
|
|
42
|
+
export declare function toPem(der: Uint8Array, label: string): string;
|
|
43
|
+
/** What encryption and a person need from a recipient's X.509 certificate. */
|
|
44
|
+
export type Certificate = {
|
|
45
|
+
/** The issuer's Name, its DER exactly as in the certificate. */
|
|
46
|
+
readonly issuer: Uint8Array;
|
|
47
|
+
/** The serial number's INTEGER element, exactly as in the certificate. */
|
|
48
|
+
readonly serial: Uint8Array;
|
|
49
|
+
/** The serial number in hexadecimal. */
|
|
50
|
+
readonly serialHex: string;
|
|
51
|
+
/** The SubjectPublicKeyInfo, DER. */
|
|
52
|
+
readonly spki: Uint8Array;
|
|
53
|
+
/** The public key's algorithm, as an OID. */
|
|
54
|
+
readonly keyAlgorithm: string;
|
|
55
|
+
/** The subject's common name, where it has one. */
|
|
56
|
+
readonly commonName: string | undefined;
|
|
57
|
+
/** The addresses it names (subjectAltName rfc822Name and the subject's emailAddress), in lower case. */
|
|
58
|
+
readonly emails: readonly string[];
|
|
59
|
+
/** When it starts being valid, where its time can be read. */
|
|
60
|
+
readonly notBefore: Date | undefined;
|
|
61
|
+
/** When it stops being valid, where its time can be read. */
|
|
62
|
+
readonly notAfter: Date | undefined;
|
|
63
|
+
/** Whether it may encrypt keys: true where it has no keyUsage extension, else its keyEncipherment bit. */
|
|
64
|
+
readonly keyEncipherment: boolean;
|
|
65
|
+
};
|
|
66
|
+
/** An X.509 certificate read for what encryption needs, or why it is not one this reader takes. */
|
|
67
|
+
export declare function readCertificate(der: Uint8Array): Result<Certificate, CmsError>;
|
|
68
|
+
/** Why a certificate cannot encrypt to an address now. */
|
|
69
|
+
export type CertificateProblem = {
|
|
70
|
+
readonly kind: "not-rsa";
|
|
71
|
+
readonly algorithm: string;
|
|
72
|
+
} | {
|
|
73
|
+
readonly kind: "not-yet-valid";
|
|
74
|
+
readonly from: Date;
|
|
75
|
+
} | {
|
|
76
|
+
readonly kind: "expired";
|
|
77
|
+
readonly on: Date;
|
|
78
|
+
} | {
|
|
79
|
+
readonly kind: "signing-only";
|
|
80
|
+
} | {
|
|
81
|
+
readonly kind: "other-address";
|
|
82
|
+
readonly names: readonly string[];
|
|
83
|
+
};
|
|
84
|
+
/** Why a certificate cannot be used to encrypt to `address` at `now`, or undefined where it can. */
|
|
85
|
+
export declare function certificateProblem(c: Certificate, address: string, now: Date): CertificateProblem | undefined;
|
|
86
|
+
/** RSAES-OAEP with SHA-256 and MGF1 with SHA-256, as an AlgorithmIdentifier (RFC 4055 §4.1). */
|
|
87
|
+
export declare function oaepSha256(): Uint8Array;
|
|
88
|
+
/** The fresh secrets of one message: a 32-byte AES-256 content key and a 12-byte GCM nonce. */
|
|
89
|
+
export type CmsKeys = {
|
|
90
|
+
readonly contentKey: Uint8Array;
|
|
91
|
+
readonly nonce: Uint8Array;
|
|
92
|
+
};
|
|
93
|
+
/** Fresh secrets from a source of random bytes, such as `(n) => crypto.getRandomValues(new Uint8Array(n))`. */
|
|
94
|
+
export declare function cmsKeys(random: (length: number) => Uint8Array): CmsKeys;
|
|
95
|
+
/**
|
|
96
|
+
* A CMS ContentInfo holding AuthEnvelopedData, as DER: `content` encrypted with AES-256-GCM, its key encrypted to every recipient with
|
|
97
|
+
* RSA-OAEP SHA-256. No recipient, a recipient whose key is not RSA, or keys of the wrong size are errors.
|
|
98
|
+
*/
|
|
99
|
+
export declare function authEnveloped(content: Uint8Array, recipients: readonly Certificate[], keys: CmsKeys): Promise<Result<Uint8Array, CmsError>>;
|
|
100
|
+
/** Whether an AlgorithmIdentifier is RSAES-OAEP with SHA-256, MGF1 with SHA-256 and the default label, however its NULLs are written. */
|
|
101
|
+
export declare function isOaepSha256(t: Tlv): boolean;
|
|
102
|
+
/**
|
|
103
|
+
* The content of an AuthEnvelopedData, opened by the recipient whose certificate is `cert` with its RSA-OAEP SHA-256 private key; or why
|
|
104
|
+
* it cannot be: not this structure, no RecipientInfo for this certificate, or a key or tag that does not decrypt (the content was changed).
|
|
105
|
+
*/
|
|
106
|
+
export declare function openAuthEnveloped(der: Uint8Array, cert: Certificate, privateKey: CryptoKey): Promise<Result<Uint8Array, CmsError>>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type Result } from "@intellectual-frontiers/core";
|
|
2
|
+
/** COSE's identifier of ES256: ECDSA on P-256 with SHA-256. */
|
|
3
|
+
export declare const ES256 = -7;
|
|
4
|
+
/** COSE's identifier of EdDSA (here always Ed25519). */
|
|
5
|
+
export declare const EDDSA = -8;
|
|
6
|
+
/** The algorithms commons accepts, in order of preference. */
|
|
7
|
+
export declare const ALGORITHMS: readonly number[];
|
|
8
|
+
/** A public key read from a `COSE_Key`: an EC2 key on P-256 for ES256, or an OKP key on Ed25519 for EdDSA. */
|
|
9
|
+
export type CoseKey = {
|
|
10
|
+
readonly kty: "EC2";
|
|
11
|
+
readonly alg: typeof ES256;
|
|
12
|
+
readonly crv: "P-256";
|
|
13
|
+
readonly x: Uint8Array;
|
|
14
|
+
readonly y: Uint8Array;
|
|
15
|
+
} | {
|
|
16
|
+
readonly kty: "OKP";
|
|
17
|
+
readonly alg: typeof EDDSA;
|
|
18
|
+
readonly crv: "Ed25519";
|
|
19
|
+
readonly x: Uint8Array;
|
|
20
|
+
};
|
|
21
|
+
/** A `COSE_Key` read from its CBOR: a map with `kty` (1), `alg` (3), `crv` (-1), `x` (-2) and, for EC2, `y` (-3); anything else refused. */
|
|
22
|
+
export declare function parseCoseKey(bytes: Uint8Array): Result<CoseKey, string>;
|
|
23
|
+
/** The CBOR `COSE_Key` of a key (deterministic: its labels sorted). */
|
|
24
|
+
export declare function encodeCoseKey(key: CoseKey): Uint8Array;
|
|
25
|
+
/** The `COSE_Key` of a public JSON Web Key: EC on P-256 (as ES256) or OKP on Ed25519 (as EdDSA); any other key refused. */
|
|
26
|
+
export declare function coseKeyFromJwk(jwk: JsonWebKey): Result<Uint8Array, string>;
|
|
27
|
+
/** The public JSON Web Key of a COSE key. */
|
|
28
|
+
export declare function jwkOfCoseKey(key: CoseKey): JsonWebKey;
|
|
29
|
+
/** The key imported into Web Crypto for verifying; a point not on its curve is refused. */
|
|
30
|
+
export declare function importCoseKey(key: CoseKey): Promise<Result<CryptoKey, string>>;
|
|
31
|
+
/** An ECDSA signature as DER (`Ecdsa-Sig-Value ::= SEQUENCE { r INTEGER, s INTEGER }`) turned into raw `r || s` of `size` bytes each. */
|
|
32
|
+
export declare function ecdsaDerToRaw(der: Uint8Array, size?: number): Result<Uint8Array, string>;
|
|
33
|
+
/** Whether `signature` is the key's signature of `data` (ES256: DER as WebAuthn gives it; EdDSA: 64 raw bytes); an unusable key or a malformed signature is an error. */
|
|
34
|
+
export declare function verifyCose(key: CoseKey, signature: Uint8Array, data: Uint8Array): Promise<Result<boolean, string>>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SHA-512 crypt (`$6$`), the password hash of glibc's `crypt(3)` that Linux accounts and Ubuntu's installer accept, on Web Crypto alone
|
|
3
|
+
* (commons 0005-typescript-runtime FR-034). The algorithm is Ulrich Drepper's "Unix crypt using SHA-256 and SHA-512". The salt is given,
|
|
4
|
+
* so the kernel stays free of effects: a caller makes one from random bytes with `cryptSalt(crypto.getRandomValues(new Uint8Array(16)))`.
|
|
5
|
+
* Taken from Stolos's `src/archon/core/crypt.ts`.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { sha512Crypt } from "./crypt.js";
|
|
10
|
+
* await sha512Crypt("Hello world!", "saltstring");
|
|
11
|
+
* // "$6$saltstring$svn8UoSVapNtMuq1ukKS4tPQd8iKwSMHWjl/O817G3uBnIFNjnQJuesI68u4OTLiBFdcbYEdFCoEOfaS35inz1"
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* @module
|
|
15
|
+
*/
|
|
16
|
+
/** The rounds glibc uses when none are named, and the least and most it accepts. */
|
|
17
|
+
export declare const CRYPT_ROUNDS: {
|
|
18
|
+
readonly default: 5000;
|
|
19
|
+
readonly min: 1000;
|
|
20
|
+
readonly max: 999999999;
|
|
21
|
+
};
|
|
22
|
+
/** A salt of crypt's alphabet (`./0-9A-Za-z`) made from bytes, one character each, at most 16. */
|
|
23
|
+
export declare function cryptSalt(bytes: Uint8Array): string;
|
|
24
|
+
/**
|
|
25
|
+
* A password hashed as SHA-512 crypt: `$6$<salt>$<hash>`, with `rounds=<n>$` after `$6$` where rounds are given (5000 where they are
|
|
26
|
+
* not). Only the first 16 characters of the salt count, and given rounds are clamped to what glibc accepts, as glibc does.
|
|
27
|
+
*/
|
|
28
|
+
export declare function sha512Crypt(password: string, salt: string, rounds?: number): Promise<string>;
|
|
29
|
+
/** Whether a password matches a `$6$` hash, by hashing it again with the hash's own salt and rounds. */
|
|
30
|
+
export declare function verifySha512Crypt(password: string, hash: string): Promise<boolean>;
|