@appport/integration 0.0.0-stage → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +126 -0
- package/README.md +35 -2
- package/dist/base64url.d.ts +4 -0
- package/dist/base64url.d.ts.map +1 -0
- package/dist/base64url.js +36 -0
- package/dist/base64url.js.map +1 -0
- package/dist/behavior.d.ts +164 -0
- package/dist/behavior.d.ts.map +1 -0
- package/dist/behavior.js +493 -0
- package/dist/behavior.js.map +1 -0
- package/dist/coverage.d.ts +44 -0
- package/dist/coverage.d.ts.map +1 -0
- package/dist/coverage.js +43 -0
- package/dist/coverage.js.map +1 -0
- package/dist/declarations.d.ts +53 -0
- package/dist/declarations.d.ts.map +1 -0
- package/dist/declarations.js +45 -0
- package/dist/declarations.js.map +1 -0
- package/dist/ed25519.d.ts +8 -0
- package/dist/ed25519.d.ts.map +1 -0
- package/dist/ed25519.js +128 -0
- package/dist/ed25519.js.map +1 -0
- package/dist/encodings.d.ts +9 -0
- package/dist/encodings.d.ts.map +1 -0
- package/dist/encodings.js +75 -0
- package/dist/encodings.js.map +1 -0
- package/dist/fields.d.ts +29 -0
- package/dist/fields.d.ts.map +1 -0
- package/dist/fields.js +76 -0
- package/dist/fields.js.map +1 -0
- package/dist/findings.d.ts +189 -0
- package/dist/findings.d.ts.map +1 -0
- package/dist/findings.js +195 -0
- package/dist/findings.js.map +1 -0
- package/dist/footprint.d.ts +67 -0
- package/dist/footprint.d.ts.map +1 -0
- package/dist/footprint.js +78 -0
- package/dist/footprint.js.map +1 -0
- package/dist/graph.d.ts +111 -0
- package/dist/graph.d.ts.map +1 -0
- package/dist/graph.js +396 -0
- package/dist/graph.js.map +1 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +38 -0
- package/dist/index.js.map +1 -0
- package/dist/lint.d.ts +57 -0
- package/dist/lint.d.ts.map +1 -0
- package/dist/lint.js +281 -0
- package/dist/lint.js.map +1 -0
- package/dist/mapping.d.ts +28 -0
- package/dist/mapping.d.ts.map +1 -0
- package/dist/mapping.js +282 -0
- package/dist/mapping.js.map +1 -0
- package/dist/normalize.d.ts +27 -0
- package/dist/normalize.d.ts.map +1 -0
- package/dist/normalize.js +56 -0
- package/dist/normalize.js.map +1 -0
- package/dist/plan.d.ts +240 -0
- package/dist/plan.d.ts.map +1 -0
- package/dist/plan.js +746 -0
- package/dist/plan.js.map +1 -0
- package/dist/readiness.d.ts +146 -0
- package/dist/readiness.d.ts.map +1 -0
- package/dist/readiness.js +346 -0
- package/dist/readiness.js.map +1 -0
- package/dist/reference.d.ts +39 -0
- package/dist/reference.d.ts.map +1 -0
- package/dist/reference.js +74 -0
- package/dist/reference.js.map +1 -0
- package/dist/scenario.d.ts +114 -0
- package/dist/scenario.d.ts.map +1 -0
- package/dist/scenario.js +117 -0
- package/dist/scenario.js.map +1 -0
- package/dist/select.d.ts +41 -0
- package/dist/select.d.ts.map +1 -0
- package/dist/select.js +71 -0
- package/dist/select.js.map +1 -0
- package/dist/trust.d.ts +237 -0
- package/dist/trust.d.ts.map +1 -0
- package/dist/trust.js +511 -0
- package/dist/trust.js.map +1 -0
- package/dist/types.d.ts +130 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +19 -0
- package/dist/types.js.map +1 -0
- package/dist/units.d.ts +20 -0
- package/dist/units.d.ts.map +1 -0
- package/dist/units.js +47 -0
- package/dist/units.js.map +1 -0
- package/dist/verification.d.ts +54 -0
- package/dist/verification.d.ts.map +1 -0
- package/dist/verification.js +115 -0
- package/dist/verification.js.map +1 -0
- package/package.json +28 -4
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Behavioral replacement scenarios: a declarative, language-independent statement of observable behaviour a replacement
|
|
3
|
+
* must preserve (`appport.replacement-scenario/1`, `appport.replacement-suite/1`).
|
|
4
|
+
*
|
|
5
|
+
* A scenario is data. It contains no code and no provider-specific names: values are asserted in terms of the *concepts*
|
|
6
|
+
* published in the two contracts (`x-appport-concept`), with units, encodings and enum concepts stated explicitly, so two
|
|
7
|
+
* implementations with different internal representations are compared on meaning. A scenario is evidence a consumer chose to
|
|
8
|
+
* collect, not a published contract, and passing one is evidence for that scenario only.
|
|
9
|
+
*/
|
|
10
|
+
import type { JsonValue, SemanticEncoding, ValueRef } from "@appport/protocol";
|
|
11
|
+
export declare const SCENARIO_FORMAT: "appport.replacement-scenario/1";
|
|
12
|
+
export declare const SUITE_FORMAT: "appport.replacement-suite/1";
|
|
13
|
+
/** A value stated in concept space. `unit` / `encoding` say how `equals` is expressed; each implementation's own representation is normalized to it. */
|
|
14
|
+
export interface ConceptAssertion {
|
|
15
|
+
concept: string;
|
|
16
|
+
/** For a field with an enum value-concept mapping, an enum value concept IRI. */
|
|
17
|
+
equals?: JsonValue;
|
|
18
|
+
exists?: true;
|
|
19
|
+
unit?: string;
|
|
20
|
+
encoding?: SemanticEncoding;
|
|
21
|
+
}
|
|
22
|
+
export type CallOutcome = "success" | {
|
|
23
|
+
error: string;
|
|
24
|
+
};
|
|
25
|
+
export interface ScenarioCall {
|
|
26
|
+
id: string;
|
|
27
|
+
/** `name@version`; defaults to the scenario's capability. */
|
|
28
|
+
capability?: string;
|
|
29
|
+
input: JsonValue;
|
|
30
|
+
/** The input to send the candidate when its published input differs from the original's. Both must satisfy their own published schema. */
|
|
31
|
+
candidateInput?: JsonValue;
|
|
32
|
+
idempotencyKey?: string;
|
|
33
|
+
/** `unauthorized`: a caller that lacks the capability's scopes (the target must supply one). */
|
|
34
|
+
caller?: "authorized" | "unauthorized";
|
|
35
|
+
expect: {
|
|
36
|
+
outcome: CallOutcome;
|
|
37
|
+
/** Output assertions in concept space. Evaluated only for a successful outcome. */
|
|
38
|
+
output?: ConceptAssertion[];
|
|
39
|
+
/** The normalized output equals that of an earlier call (idempotent replay). */
|
|
40
|
+
sameAs?: string;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/** Read state back through a declared observation capability, after the calls. */
|
|
44
|
+
export interface ScenarioReadBack {
|
|
45
|
+
id: string;
|
|
46
|
+
/** The logical resource this read-back is evidence about (feeds coverage and `state-effect` required tests). */
|
|
47
|
+
resource?: string;
|
|
48
|
+
/** Which call's `$input` / `$output` the probe input refers to. Default: the first call. */
|
|
49
|
+
from?: string;
|
|
50
|
+
via: {
|
|
51
|
+
capability: string;
|
|
52
|
+
version: number;
|
|
53
|
+
input: Record<string, ValueRef>;
|
|
54
|
+
};
|
|
55
|
+
expect: {
|
|
56
|
+
found: false;
|
|
57
|
+
} | {
|
|
58
|
+
found: true;
|
|
59
|
+
assertions?: ConceptAssertion[];
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
export interface ScenarioEventExpectation {
|
|
63
|
+
name: string;
|
|
64
|
+
/** Exactly this many. Default 1. */
|
|
65
|
+
count?: number;
|
|
66
|
+
}
|
|
67
|
+
export interface ReplacementScenario {
|
|
68
|
+
format: typeof SCENARIO_FORMAT;
|
|
69
|
+
id: string;
|
|
70
|
+
description?: string;
|
|
71
|
+
/** `name@version` under test. */
|
|
72
|
+
capability: string;
|
|
73
|
+
/** Calls made before the measured ones, through the same boundary, to establish preconditions. All must succeed. */
|
|
74
|
+
setup?: Array<{
|
|
75
|
+
capability?: string;
|
|
76
|
+
input: JsonValue;
|
|
77
|
+
candidateInput?: JsonValue;
|
|
78
|
+
}>;
|
|
79
|
+
calls: ScenarioCall[];
|
|
80
|
+
readBack?: ScenarioReadBack[];
|
|
81
|
+
events?: {
|
|
82
|
+
expect: ScenarioEventExpectation[]; /** Also require no other events. Default true. */
|
|
83
|
+
exclusive?: boolean;
|
|
84
|
+
};
|
|
85
|
+
/** Run each implementation's *own declared* state verification for this call and require `verified`. */
|
|
86
|
+
verify?: Array<{
|
|
87
|
+
call: string;
|
|
88
|
+
methods?: string[];
|
|
89
|
+
}>;
|
|
90
|
+
}
|
|
91
|
+
export interface ReplacementSuite {
|
|
92
|
+
format: typeof SUITE_FORMAT;
|
|
93
|
+
/** `name@version` being replaced. */
|
|
94
|
+
capability: string;
|
|
95
|
+
scenarios: ReplacementScenario[];
|
|
96
|
+
/** Coverage tags that must additionally be demonstrated (`success`, `error:CODE`, `state:RESOURCE`, `event:NAME`, `verify:METHOD`, `idempotent-replay`, `authorization-refused`). */
|
|
97
|
+
requires?: string[];
|
|
98
|
+
/**
|
|
99
|
+
* Explicitly set aside a coverage requirement the original's contract implies but that cannot be provoked through the contract
|
|
100
|
+
* (for example a failure code reachable only by a fault). Waivers are never silent: the report lists each with its reason.
|
|
101
|
+
*/
|
|
102
|
+
waive?: Array<{
|
|
103
|
+
tag: string;
|
|
104
|
+
reason: string;
|
|
105
|
+
}>;
|
|
106
|
+
}
|
|
107
|
+
export interface ScenarioIssue {
|
|
108
|
+
path: string;
|
|
109
|
+
message: string;
|
|
110
|
+
}
|
|
111
|
+
/** Structural validation of a scenario, independent of any contract. */
|
|
112
|
+
export declare function validateScenario(value: unknown): ScenarioIssue[];
|
|
113
|
+
export declare function validateSuite(value: unknown): ScenarioIssue[];
|
|
114
|
+
//# sourceMappingURL=scenario.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scenario.d.ts","sourceRoot":"","sources":["../src/scenario.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE/E,eAAO,MAAM,eAAe,EAAG,gCAAyC,CAAC;AACzE,eAAO,MAAM,YAAY,EAAG,6BAAsC,CAAC;AAEnE,wJAAwJ;AACxJ,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,iFAAiF;IACjF,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,MAAM,CAAC,EAAE,IAAI,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,gBAAgB,CAAC;CAC7B;AAED,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
1
|
+
export const SCENARIO_FORMAT = "appport.replacement-scenario/1";
|
|
2
|
+
export const SUITE_FORMAT = "appport.replacement-suite/1";
|
|
3
|
+
const CAP = /^[a-z][a-z0-9]*(\.[a-z][a-z0-9]*)+@[1-9][0-9]*$/;
|
|
4
|
+
const IRI = /^[A-Za-z][A-Za-z0-9+.-]*:\S+$/;
|
|
5
|
+
/** Structural validation of a scenario, independent of any contract. */
|
|
6
|
+
export function validateScenario(value) {
|
|
7
|
+
const issues = [];
|
|
8
|
+
const bad = (path, message) => issues.push({ path, message });
|
|
9
|
+
const s = value;
|
|
10
|
+
if (!s || typeof s !== "object" || Array.isArray(s))
|
|
11
|
+
return [{ path: "", message: "not an object" }];
|
|
12
|
+
if (s.format !== SCENARIO_FORMAT)
|
|
13
|
+
bad("format", `must be ${SCENARIO_FORMAT}`);
|
|
14
|
+
for (const key of Object.keys(s))
|
|
15
|
+
if (!["format", "id", "description", "capability", "setup", "calls", "readBack", "events", "verify"].includes(key))
|
|
16
|
+
bad(key, "unknown member");
|
|
17
|
+
if (typeof s.id !== "string" || !s.id)
|
|
18
|
+
bad("id", "required");
|
|
19
|
+
if (typeof s.capability !== "string" || !CAP.test(s.capability))
|
|
20
|
+
bad("capability", "must be name@version");
|
|
21
|
+
if (!Array.isArray(s.calls) || s.calls.length === 0)
|
|
22
|
+
return [...issues, { path: "calls", message: "at least one call is required" }];
|
|
23
|
+
const ids = new Set();
|
|
24
|
+
s.calls.forEach((call, i) => {
|
|
25
|
+
const here = `calls[${i}]`;
|
|
26
|
+
if (typeof call.id !== "string" || !call.id)
|
|
27
|
+
bad(`${here}.id`, "required");
|
|
28
|
+
else if (ids.has(call.id))
|
|
29
|
+
bad(`${here}.id`, `duplicate call id ${call.id}`);
|
|
30
|
+
else
|
|
31
|
+
ids.add(call.id);
|
|
32
|
+
if (call.capability !== undefined && !CAP.test(call.capability))
|
|
33
|
+
bad(`${here}.capability`, "must be name@version");
|
|
34
|
+
if (call.input === undefined)
|
|
35
|
+
bad(`${here}.input`, "required");
|
|
36
|
+
const o = call.expect?.outcome;
|
|
37
|
+
if (o !== "success" && !(o && typeof o === "object" && typeof o.error === "string"))
|
|
38
|
+
bad(`${here}.expect.outcome`, 'must be "success" or { error: code }');
|
|
39
|
+
if (call.expect?.sameAs !== undefined && !s.calls.slice(0, i).some((c) => c.id === call.expect.sameAs))
|
|
40
|
+
bad(`${here}.expect.sameAs`, "must name an earlier call");
|
|
41
|
+
if (call.expect?.output && o !== "success")
|
|
42
|
+
bad(`${here}.expect.output`, "output assertions need a successful outcome");
|
|
43
|
+
for (const [j, a] of (call.expect?.output ?? []).entries())
|
|
44
|
+
assertionIssues(a, `${here}.expect.output[${j}]`, bad);
|
|
45
|
+
if (call.caller !== undefined && call.caller !== "authorized" && call.caller !== "unauthorized")
|
|
46
|
+
bad(`${here}.caller`, "authorized or unauthorized");
|
|
47
|
+
});
|
|
48
|
+
const rb = new Set();
|
|
49
|
+
(s.readBack ?? []).forEach((r, i) => {
|
|
50
|
+
const here = `readBack[${i}]`;
|
|
51
|
+
if (typeof r.id !== "string" || !r.id)
|
|
52
|
+
bad(`${here}.id`, "required");
|
|
53
|
+
else if (rb.has(r.id))
|
|
54
|
+
bad(`${here}.id`, "duplicate");
|
|
55
|
+
else
|
|
56
|
+
rb.add(r.id);
|
|
57
|
+
if (r.resource !== undefined && !IRI.test(r.resource))
|
|
58
|
+
bad(`${here}.resource`, "must be an absolute IRI");
|
|
59
|
+
if (r.from !== undefined && !ids.has(r.from))
|
|
60
|
+
bad(`${here}.from`, "must name a call");
|
|
61
|
+
if (!r.via || typeof r.via.capability !== "string" || !Number.isInteger(r.via.version))
|
|
62
|
+
bad(`${here}.via`, "needs capability and version");
|
|
63
|
+
const e = r.expect;
|
|
64
|
+
if (!e || typeof e.found !== "boolean")
|
|
65
|
+
bad(`${here}.expect.found`, "must be true or false");
|
|
66
|
+
else if (e.found === false && e.assertions)
|
|
67
|
+
bad(`${here}.expect`, "assertions apply only when found");
|
|
68
|
+
for (const [j, a] of (e?.assertions ?? []).entries())
|
|
69
|
+
assertionIssues(a, `${here}.expect.assertions[${j}]`, bad);
|
|
70
|
+
});
|
|
71
|
+
for (const [i, v] of (s.verify ?? []).entries())
|
|
72
|
+
if (!ids.has(v.call))
|
|
73
|
+
bad(`verify[${i}].call`, "must name a call");
|
|
74
|
+
for (const [i, e] of (s.events?.expect ?? []).entries()) {
|
|
75
|
+
if (typeof e.name !== "string" || !e.name)
|
|
76
|
+
bad(`events.expect[${i}].name`, "required");
|
|
77
|
+
if (e.count !== undefined && (!Number.isInteger(e.count) || e.count < 0))
|
|
78
|
+
bad(`events.expect[${i}].count`, "non-negative integer");
|
|
79
|
+
}
|
|
80
|
+
return issues;
|
|
81
|
+
}
|
|
82
|
+
function assertionIssues(a, path, bad) {
|
|
83
|
+
if (typeof a.concept !== "string" || !IRI.test(a.concept))
|
|
84
|
+
bad(`${path}.concept`, "must be an absolute IRI");
|
|
85
|
+
if ((a.equals === undefined) === (a.exists === undefined))
|
|
86
|
+
bad(path, "give exactly one of equals / exists");
|
|
87
|
+
if (a.exists !== undefined && a.exists !== true)
|
|
88
|
+
bad(`${path}.exists`, "must be true");
|
|
89
|
+
}
|
|
90
|
+
export function validateSuite(value) {
|
|
91
|
+
const s = value;
|
|
92
|
+
if (!s || typeof s !== "object")
|
|
93
|
+
return [{ path: "", message: "not an object" }];
|
|
94
|
+
const issues = [];
|
|
95
|
+
if (s.format !== SUITE_FORMAT)
|
|
96
|
+
issues.push({ path: "format", message: `must be ${SUITE_FORMAT}` });
|
|
97
|
+
if (typeof s.capability !== "string" || !CAP.test(s.capability))
|
|
98
|
+
issues.push({ path: "capability", message: "must be name@version" });
|
|
99
|
+
if (!Array.isArray(s.scenarios) || s.scenarios.length === 0)
|
|
100
|
+
return [...issues, { path: "scenarios", message: "at least one scenario" }];
|
|
101
|
+
for (const [i, w] of (s.waive ?? []).entries())
|
|
102
|
+
if (typeof w?.tag !== "string" || typeof w?.reason !== "string" || w.reason.length < 10)
|
|
103
|
+
issues.push({ path: `waive[${i}]`, message: "a waiver needs a tag and a reason of substance" });
|
|
104
|
+
const ids = new Set();
|
|
105
|
+
s.scenarios.forEach((sc, i) => {
|
|
106
|
+
for (const issue of validateScenario(sc))
|
|
107
|
+
issues.push({ path: `scenarios[${i}].${issue.path}`, message: issue.message });
|
|
108
|
+
if (sc?.capability !== s.capability)
|
|
109
|
+
issues.push({ path: `scenarios[${i}].capability`, message: "every scenario in a suite tests the suite's capability" });
|
|
110
|
+
if (ids.has(sc?.id))
|
|
111
|
+
issues.push({ path: `scenarios[${i}].id`, message: "duplicate scenario id" });
|
|
112
|
+
else
|
|
113
|
+
ids.add(sc?.id);
|
|
114
|
+
});
|
|
115
|
+
return issues;
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=scenario.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scenario.js","sourceRoot":"","sources":["../src/scenario.ts"],"names":[],"mappings":"AAWA,MAAM,CAAC,MAAM,eAAe,GAAG,gCAAyC,CAAC;AACzE,MAAM,CAAC,MAAM,YAAY,GAAG,6BAAsC,CAAC;AAoFnE,MAAM,GAAG,GAAG,iDAAiD,CAAC;AAC9D,MAAM,GAAG,GAAG,+BAA+B,CAAC;AAE5C,wEAAwE;AACxE,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC7C,MAAM,MAAM,GAAoB,EAAE,CAAC;IACnC,MAAM,GAAG,GAAG,CAAC,IAAY,EAAE,OAAe,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;IAC9E,MAAM,CAAC,GAAG,KAAmC,CAAC;IAC9C,IAAI,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;QAAE,OAAO,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC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AAE,OAAO,EAAE,wDAAwD,EAAE,CAAC,CAAC;QAC5J,IAAI,GAAG,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC;YAAE,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,aAAa,CAAC,MAAM,EAAE,OAAO,EAAE,uBAAuB,EAAE,CAAC,CAAC;;YAAM,GAAG,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IAC3H,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/select.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { RESOURCE_OPERATIONS, type AppPortManifest } from "@appport/protocol";
|
|
2
|
+
/**
|
|
3
|
+
* A machine-matchable statement of what a task needs from a capability, expressed only in
|
|
4
|
+
* fields a contract publishes: a capability name, the logical resource it reads or changes,
|
|
5
|
+
* a declared effect type, or a field concept. Prose descriptions are never matched.
|
|
6
|
+
* All stated criteria must hold.
|
|
7
|
+
*/
|
|
8
|
+
export interface Selector {
|
|
9
|
+
application?: string;
|
|
10
|
+
/** `name` or `name@version`. */
|
|
11
|
+
capability?: string;
|
|
12
|
+
/** Logical resource id the capability declares it reads. */
|
|
13
|
+
reads?: string;
|
|
14
|
+
/** Logical resource id the capability declares it changes. */
|
|
15
|
+
changes?: string;
|
|
16
|
+
operation?: (typeof RESOURCE_OPERATIONS)[number];
|
|
17
|
+
/** A declared effect `type`. */
|
|
18
|
+
effectType?: string;
|
|
19
|
+
/** A concept IRI carried by any input or output field. */
|
|
20
|
+
concept?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface CapabilityMatch {
|
|
23
|
+
application: string;
|
|
24
|
+
/** `name@version` */
|
|
25
|
+
capability: string;
|
|
26
|
+
/** The published fields that satisfied the selector, e.g. `access:changes:urn:...`. */
|
|
27
|
+
matchedOn: string[];
|
|
28
|
+
}
|
|
29
|
+
export interface FindResult {
|
|
30
|
+
matches: CapabilityMatch[];
|
|
31
|
+
/**
|
|
32
|
+
* Capabilities that could not be evaluated against a descriptor-based criterion because they
|
|
33
|
+
* publish no integration entry. They may or may not satisfy the selector: unknown, not "no".
|
|
34
|
+
*/
|
|
35
|
+
undeclared: Array<{
|
|
36
|
+
application: string;
|
|
37
|
+
capability: string;
|
|
38
|
+
}>;
|
|
39
|
+
}
|
|
40
|
+
export declare function findCapabilities(manifests: readonly AppPortManifest[], selector: Selector): FindResult;
|
|
41
|
+
//# sourceMappingURL=select.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../src/select.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,mBAAmB,EAAE,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAG9G;;;;;GAKG;AACH,MAAM,WAAW,QAAQ;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gCAAgC;IAChC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,4DAA4D;IAC5D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8DAA8D;IAC9D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,CAAC,CAAC;IACjD,gCAAgC;IAChC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,0DAA0D;IAC1D,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,eAAe;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,qBAAqB;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,uFAAuF;IACvF,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B;;;OAGG;IACH,UAAU,EAAE,KAAK,CAAC;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAChE;AAID,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,SAAS,eAAe,EAAE,EAAE,QAAQ,EAAE,QAAQ,GAAG,UAAU,CAuDtG"}
|
package/dist/select.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { getIntegration, integrationKey, RESOURCE_OPERATIONS } from "@appport/protocol";
|
|
2
|
+
import { describeFootprint } from "./footprint.js";
|
|
3
|
+
const DESCRIPTOR_CRITERIA = ["reads", "changes", "operation", "effectType"];
|
|
4
|
+
export function findCapabilities(manifests, selector) {
|
|
5
|
+
const matches = [];
|
|
6
|
+
const undeclared = [];
|
|
7
|
+
const wantsDescriptor = DESCRIPTOR_CRITERIA.some((key) => selector[key] !== undefined);
|
|
8
|
+
const pinned = selector.capability?.includes("@") ?? false;
|
|
9
|
+
for (const manifest of manifests) {
|
|
10
|
+
if (selector.application !== undefined && manifest.application.id !== selector.application)
|
|
11
|
+
continue;
|
|
12
|
+
const descriptor = getIntegration(manifest);
|
|
13
|
+
for (const entry of manifest.capabilities) {
|
|
14
|
+
for (const definition of entry.definitions) {
|
|
15
|
+
if (definition.kind !== "request")
|
|
16
|
+
continue;
|
|
17
|
+
const key = integrationKey(entry.name, definition.version);
|
|
18
|
+
if (selector.capability !== undefined && selector.capability !== key && selector.capability !== entry.name)
|
|
19
|
+
continue;
|
|
20
|
+
if (definition.deprecated && !pinned)
|
|
21
|
+
continue;
|
|
22
|
+
const integration = descriptor?.capabilities[key];
|
|
23
|
+
const matchedOn = [];
|
|
24
|
+
if (selector.capability !== undefined)
|
|
25
|
+
matchedOn.push(`capability:${key}`);
|
|
26
|
+
if (wantsDescriptor && !integration) {
|
|
27
|
+
if (entry.name.startsWith("appport."))
|
|
28
|
+
continue; // protocol-defined; they have no integration to declare
|
|
29
|
+
undeclared.push({ application: manifest.application.id, capability: key });
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
let ok = true;
|
|
33
|
+
if (selector.reads !== undefined) {
|
|
34
|
+
const hit = (integration?.access ?? []).some((a) => a.mode === "reads" && a.resource === selector.reads);
|
|
35
|
+
ok &&= hit;
|
|
36
|
+
if (hit)
|
|
37
|
+
matchedOn.push(`access:reads:${selector.reads}`);
|
|
38
|
+
}
|
|
39
|
+
if (selector.changes !== undefined) {
|
|
40
|
+
// An operation is only matched when the contract states operations; unstated operations are not "any".
|
|
41
|
+
const hit = (integration?.access ?? []).some((a) => a.mode === "changes" && a.resource === selector.changes && (selector.operation === undefined || (a.operations ?? []).includes(selector.operation)));
|
|
42
|
+
ok &&= hit;
|
|
43
|
+
if (hit)
|
|
44
|
+
matchedOn.push(`access:changes:${selector.changes}`);
|
|
45
|
+
}
|
|
46
|
+
else if (selector.operation !== undefined)
|
|
47
|
+
ok = false; // an operation means nothing without the resource it applies to
|
|
48
|
+
if (selector.effectType !== undefined) {
|
|
49
|
+
const hit = (integration?.effects ?? []).some((e) => e.type === selector.effectType);
|
|
50
|
+
ok &&= hit;
|
|
51
|
+
if (hit)
|
|
52
|
+
matchedOn.push(`effect:${selector.effectType}`);
|
|
53
|
+
}
|
|
54
|
+
if (selector.concept !== undefined) {
|
|
55
|
+
const footprint = describeFootprint(manifest, entry.name, definition.version);
|
|
56
|
+
const hit = [...footprint.consumes, ...footprint.produces].some((f) => f.concept === selector.concept);
|
|
57
|
+
ok &&= hit;
|
|
58
|
+
if (hit)
|
|
59
|
+
matchedOn.push(`concept:${selector.concept}`);
|
|
60
|
+
}
|
|
61
|
+
if (matchedOn.length === 0)
|
|
62
|
+
continue; // an empty selector selects nothing
|
|
63
|
+
if (ok)
|
|
64
|
+
matches.push({ application: manifest.application.id, capability: key, matchedOn });
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const order = (a, b) => a.application.localeCompare(b.application) || a.capability.localeCompare(b.capability);
|
|
69
|
+
return { matches: matches.sort(order), undeclared: undeclared.sort(order) };
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=select.js.map
|
|
@@ -0,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AAK,GAAG,CAAC;oBACX,IAAI,GAAG;wBAAE,SAAS,CAAC,IAAI,CAAC,WAAW,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;gBACzD,CAAC;gBACD,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC;oBAAE,SAAS,CAAC,oCAAoC;gBAC1E,IAAI,EAAE;oBAAE,OAAO,CAAC,IAAI,CAAC,EAAE,WAAW,EAAE,QAAQ,CAAC,WAAW,CAAC,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,CAAC;YAC7F,CAAC;QACH,CAAC;IACH,CAAC;IACD,MAAM,KAAK,GAAG,CAAC,CAA8C,EAAE,CAA8C,EAAE,EAAE,CAC/G,CAAC,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;IACzF,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,UAAU,EAAE,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;AAC9E,CAAC"}
|
package/dist/trust.d.ts
ADDED
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Publisher trust for mapping artifacts: a verification boundary, not a registry.
|
|
3
|
+
*
|
|
4
|
+
* Five questions are answered separately and never merged:
|
|
5
|
+
*
|
|
6
|
+
* 1. **Authenticity**: does the signature verify against a public key? (cryptography)
|
|
7
|
+
* 2. **Integrity**: do the artifact's identity and digest equal what was signed? (canonical JSON + SHA-256)
|
|
8
|
+
* 3. **Trust**: does the *consumer's* policy trust this publisher and key, for this mapping id? (consumer decision)
|
|
9
|
+
* 4. **Semantic validity**: does the mapping pass the mapping linter and its own vectors? (meaning)
|
|
10
|
+
* 5. **Pin consistency**: is this the digest already pinned for this `(id, version)`? (immutability)
|
|
11
|
+
*
|
|
12
|
+
* A mapping is `eligible` only when every one succeeds. None of them stands in for another: a valid signature from a
|
|
13
|
+
* trusted key proves who signed those bytes, not that the mapping is right; a pin proves the bytes did not change, not who
|
|
14
|
+
* wrote them; trust never bypasses the linter. Eligibility is a verdict about the artifact. It authorizes no execution.
|
|
15
|
+
*
|
|
16
|
+
* Trust comes only from the policy the consumer supplies. Nothing in an artifact or envelope can grant it, and nothing is
|
|
17
|
+
* inferred from a URL, a download, a digest, or an earlier acceptance.
|
|
18
|
+
*/
|
|
19
|
+
import { type MappingReference } from "@appport/protocol";
|
|
20
|
+
import { type MappingPins } from "./reference.js";
|
|
21
|
+
import type { AppPortManifest } from "@appport/protocol";
|
|
22
|
+
export declare const MAPPING_SIGNATURE_FORMAT: "appport.mapping-signature/1";
|
|
23
|
+
export declare const TRUST_POLICY_FORMAT: "appport.mapping-trust-policy/1";
|
|
24
|
+
export declare const TRUST_RESULT_FORMAT: "appport.mapping-trust-result/1";
|
|
25
|
+
export declare const SIGNATURE_SCHEMES: readonly ["ed25519"];
|
|
26
|
+
export type SignatureScheme = (typeof SIGNATURE_SCHEMES)[number];
|
|
27
|
+
/**
|
|
28
|
+
* `appport.mapping-signature/1`. The signature covers every member except `signature` and `publicKey`.
|
|
29
|
+
* `publicKey` is an unsigned *claim* that lets a verifier check authenticity for a key it has no policy entry for; it is
|
|
30
|
+
* never a source of trust, and when the policy knows the key the two must agree.
|
|
31
|
+
*/
|
|
32
|
+
export interface MappingSignatureEnvelope {
|
|
33
|
+
format: typeof MAPPING_SIGNATURE_FORMAT;
|
|
34
|
+
/** The exact artifact signed: its immutable identity and the digest of its canonical JSON. No locations. */
|
|
35
|
+
mapping: {
|
|
36
|
+
id: string;
|
|
37
|
+
version: number;
|
|
38
|
+
digest: string;
|
|
39
|
+
};
|
|
40
|
+
/** Absolute IRI naming the publisher, e.g. `publisher://acme.example`. */
|
|
41
|
+
publisher: string;
|
|
42
|
+
/** Identifies one of the publisher's keys. Unique within the publisher. */
|
|
43
|
+
keyId: string;
|
|
44
|
+
scheme: SignatureScheme;
|
|
45
|
+
/** base64url (no padding) of the 64-byte Ed25519 signature. */
|
|
46
|
+
signature: string;
|
|
47
|
+
/** base64url (no padding) of the 32-byte raw public key. Optional, unsigned, a claim. */
|
|
48
|
+
publicKey?: string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* The signed bytes: UTF-8 of `"appport.mapping-signature/1\n"` followed by the RFC 8785 canonical JSON of the envelope
|
|
52
|
+
* without `signature` and `publicKey`. The prefix is domain separation: a signature over mapping bytes can never be
|
|
53
|
+
* mistaken for a signature over anything else this key signs.
|
|
54
|
+
*/
|
|
55
|
+
export declare function mappingSignatureBytes(envelope: Pick<MappingSignatureEnvelope, "format" | "mapping" | "publisher" | "keyId" | "scheme">): Uint8Array;
|
|
56
|
+
/** Stable, machine-readable reasons. Their meaning never changes within `/1`. */
|
|
57
|
+
export declare const TRUST_REASONS: readonly ["envelope.malformed", "envelope.unsupported-format", "scheme.unsupported", "runtime.ed25519-unavailable", "key.unknown", "key.mismatch", "key.invalid", "signature.invalid", "identity.mismatch", "digest.mismatch", "reference.mismatch", "artifact.malformed", "artifact.unsupported", "trust.policy-unavailable", "trust.unknown-publisher", "trust.unknown-key", "trust.key-untrusted", "trust.key-rejected", "trust.key-revoked", "trust.out-of-scope", "semantic.unchecked", "semantic.invalid", "semantic.vectors-failed", "semantic.generated-origin", "pin.unchecked", "pin.conflict"];
|
|
58
|
+
export type TrustReason = (typeof TRUST_REASONS)[number];
|
|
59
|
+
interface EnvelopeProblem {
|
|
60
|
+
reason: TrustReason;
|
|
61
|
+
detail: string;
|
|
62
|
+
}
|
|
63
|
+
/** Strict, closed validation. Returns the envelope or why it is not one. */
|
|
64
|
+
export declare function parseSignatureEnvelope(value: unknown): {
|
|
65
|
+
envelope: MappingSignatureEnvelope;
|
|
66
|
+
} | {
|
|
67
|
+
problem: EnvelopeProblem;
|
|
68
|
+
};
|
|
69
|
+
/** A publisher's helper. The private key never leaves the caller: pass a 32-byte seed. */
|
|
70
|
+
export declare function signMapping(options: {
|
|
71
|
+
artifact: unknown;
|
|
72
|
+
publisher: string;
|
|
73
|
+
keyId: string;
|
|
74
|
+
seed: Uint8Array;
|
|
75
|
+
includePublicKey?: boolean;
|
|
76
|
+
}): Promise<MappingSignatureEnvelope>;
|
|
77
|
+
/** The raw public key (base64url) for a seed. For publishers and tests. */
|
|
78
|
+
export declare function publicKeyOf(seed: Uint8Array): Promise<string>;
|
|
79
|
+
export declare const KEY_STATUSES: readonly ["trusted", "untrusted", "rejected", "revoked"];
|
|
80
|
+
export type KeyStatus = (typeof KEY_STATUSES)[number];
|
|
81
|
+
/**
|
|
82
|
+
* `appport.mapping-trust-policy/1`, supplied by the consumer or its host. Decisions are per publisher *and key*.
|
|
83
|
+
* A publisher or key that is not listed is untrusted. `rejected` is the consumer's decision; `revoked` records that the
|
|
84
|
+
* key is known to be compromised or withdrawn. Both stop a key from authorizing anything, whenever the signature was made.
|
|
85
|
+
*
|
|
86
|
+
* AppPort does not distribute this file or key status updates. If the consumer's copy is stale, so are its decisions.
|
|
87
|
+
*/
|
|
88
|
+
export interface MappingTrustPolicy {
|
|
89
|
+
format: typeof TRUST_POLICY_FORMAT;
|
|
90
|
+
publishers: Array<{
|
|
91
|
+
publisher: string;
|
|
92
|
+
/** If present, this publisher is trusted only for mapping ids that start with one of these. */
|
|
93
|
+
idPrefixes?: string[];
|
|
94
|
+
/** Several keys per publisher: rotation adds a key and revokes or removes the old one; the publisher identity stays. */
|
|
95
|
+
keys: Array<{
|
|
96
|
+
keyId: string;
|
|
97
|
+
publicKey: string;
|
|
98
|
+
status: KeyStatus;
|
|
99
|
+
revokedAt?: string;
|
|
100
|
+
note?: string;
|
|
101
|
+
}>;
|
|
102
|
+
}>;
|
|
103
|
+
}
|
|
104
|
+
export declare class TrustPolicyError extends Error {
|
|
105
|
+
constructor(message: string);
|
|
106
|
+
}
|
|
107
|
+
export interface CompiledTrustPolicy {
|
|
108
|
+
readonly publishers: ReadonlyMap<string, {
|
|
109
|
+
idPrefixes?: readonly string[];
|
|
110
|
+
keys: ReadonlyMap<string, {
|
|
111
|
+
publicKey: Uint8Array;
|
|
112
|
+
publicKeyText: string;
|
|
113
|
+
status: KeyStatus;
|
|
114
|
+
}>;
|
|
115
|
+
}>;
|
|
116
|
+
}
|
|
117
|
+
/** Validates a policy. Throws {@link TrustPolicyError}; a policy is configuration, and a bad one must not be half-applied. */
|
|
118
|
+
export declare function compileTrustPolicy(value: unknown): CompiledTrustPolicy;
|
|
119
|
+
export type TrustStatus = "trusted" | "untrusted" | "rejected" | "revoked" | "out-of-scope" | "unavailable";
|
|
120
|
+
export interface TrustDecision {
|
|
121
|
+
status: TrustStatus;
|
|
122
|
+
/** The policy rule that determined the outcome, e.g. `key:publisher://acme/k1:revoked` or `default:unknown-publisher`. */
|
|
123
|
+
rule: string;
|
|
124
|
+
reasons: TrustReason[];
|
|
125
|
+
}
|
|
126
|
+
/** The consumer's decision about a publisher, key and mapping id. Depends only on the policy and its three arguments. */
|
|
127
|
+
export declare function evaluateTrust(policy: CompiledTrustPolicy | undefined, claim: {
|
|
128
|
+
publisher: string;
|
|
129
|
+
keyId: string;
|
|
130
|
+
mappingId: string;
|
|
131
|
+
}): TrustDecision;
|
|
132
|
+
export type SemanticVerdict = {
|
|
133
|
+
status: "valid" | "invalid";
|
|
134
|
+
reasons?: TrustReason[];
|
|
135
|
+
issues?: string[];
|
|
136
|
+
};
|
|
137
|
+
export interface VerifyMappingTrustInput {
|
|
138
|
+
/** The artifact bytes as parsed JSON, exactly as received. */
|
|
139
|
+
artifact: unknown;
|
|
140
|
+
envelope: unknown;
|
|
141
|
+
/** The consumer's compiled policy. Absent means trust status is unavailable, which is untrusted. */
|
|
142
|
+
policy?: CompiledTrustPolicy;
|
|
143
|
+
/** If the artifact came with a reference (descriptor or catalog), the reference must agree with what was signed. */
|
|
144
|
+
reference?: MappingReference;
|
|
145
|
+
/** The consumer's pins. Required for eligibility: pinning is what stops identity reuse. */
|
|
146
|
+
pins?: MappingPins;
|
|
147
|
+
/** Record the pin once the mapping is eligible. Never done for an ineligible mapping. */
|
|
148
|
+
recordPin?: boolean;
|
|
149
|
+
/**
|
|
150
|
+
* How semantic validity is established: `manifests` runs the mapping linter and the artifact's own vectors against the two
|
|
151
|
+
* applications' published manifests (the normal path); `verdict` supplies a result computed elsewhere. Trust never replaces it.
|
|
152
|
+
*/
|
|
153
|
+
semantic?: {
|
|
154
|
+
manifests: {
|
|
155
|
+
from: AppPortManifest;
|
|
156
|
+
to: AppPortManifest;
|
|
157
|
+
};
|
|
158
|
+
} | {
|
|
159
|
+
verdict: SemanticVerdict;
|
|
160
|
+
};
|
|
161
|
+
/** Local policy's explicit acceptance of `origin: "generated"` artifacts, which are otherwise not eligible. */
|
|
162
|
+
acceptGenerated?: boolean;
|
|
163
|
+
}
|
|
164
|
+
export interface MappingTrustResult {
|
|
165
|
+
type: typeof TRUST_RESULT_FORMAT;
|
|
166
|
+
mapping: {
|
|
167
|
+
id?: string;
|
|
168
|
+
version?: number;
|
|
169
|
+
digest?: string;
|
|
170
|
+
};
|
|
171
|
+
authenticity: {
|
|
172
|
+
status: "valid" | "invalid" | "unverifiable";
|
|
173
|
+
publisher?: string;
|
|
174
|
+
keyId?: string;
|
|
175
|
+
keySource?: "policy" | "envelope";
|
|
176
|
+
reasons: TrustReason[];
|
|
177
|
+
};
|
|
178
|
+
integrity: {
|
|
179
|
+
status: "valid" | "invalid";
|
|
180
|
+
reasons: TrustReason[];
|
|
181
|
+
};
|
|
182
|
+
trust: TrustDecision;
|
|
183
|
+
semantic: {
|
|
184
|
+
status: "valid" | "invalid" | "unchecked";
|
|
185
|
+
reasons: TrustReason[];
|
|
186
|
+
issues: string[];
|
|
187
|
+
};
|
|
188
|
+
pins: {
|
|
189
|
+
status: "new" | "consistent" | "conflict" | "unchecked";
|
|
190
|
+
reasons: TrustReason[];
|
|
191
|
+
pinned?: string;
|
|
192
|
+
};
|
|
193
|
+
/** True only when authenticity, integrity, trust, semantic validity and pin consistency all succeeded. Authorizes nothing. */
|
|
194
|
+
eligible: boolean;
|
|
195
|
+
/** Every reason that applies, sorted and unique. Empty exactly when `eligible`. */
|
|
196
|
+
reasons: TrustReason[];
|
|
197
|
+
limits: string[];
|
|
198
|
+
}
|
|
199
|
+
export declare const TRUST_LIMITS: readonly string[];
|
|
200
|
+
/** Limits on what an untrusted artifact may contain before it is canonicalized: depth, size, unsafe integers and strings with no UTF-8 encoding. */
|
|
201
|
+
export declare const ARTIFACT_LIMITS: {
|
|
202
|
+
readonly maxDepth: 64;
|
|
203
|
+
readonly maxNodes: 100000;
|
|
204
|
+
};
|
|
205
|
+
/** Why an artifact is outside what this verifier will canonicalize, or `undefined`. Iterative: a hostile depth cannot exhaust the stack. */
|
|
206
|
+
export declare function artifactContentProblem(value: unknown): string | undefined;
|
|
207
|
+
export declare function verifyMappingTrust(input: VerifyMappingTrustInput): Promise<MappingTrustResult>;
|
|
208
|
+
/** What `planIntegration` consumes. Produced by {@link assessMappingTrust}; the planner itself stays synchronous and pure. */
|
|
209
|
+
export interface MappingTrustAssessment {
|
|
210
|
+
type: "appport.mapping-trust-assessment/1";
|
|
211
|
+
/** One result per (artifact, envelope) pair whose mapping identity agrees. */
|
|
212
|
+
results: MappingTrustResult[];
|
|
213
|
+
/** Supplied artifacts for which no envelope was supplied at all. */
|
|
214
|
+
unsigned: Array<{
|
|
215
|
+
id: string;
|
|
216
|
+
version: number;
|
|
217
|
+
digest: string;
|
|
218
|
+
}>;
|
|
219
|
+
/** Whether the host supplied a trust policy / pins. Their absence is reported, never defaulted. */
|
|
220
|
+
policySupplied: boolean;
|
|
221
|
+
pinsSupplied: boolean;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Runs {@link verifyMappingTrust} for every supplied artifact against the envelopes that name its identity, resolving the two
|
|
225
|
+
* manifests each artifact's endpoints refer to for semantic validation. Pure with respect to the world: no I/O, no key
|
|
226
|
+
* discovery, and pins are checked but never recorded. Pass the result to `planIntegration({ trust })`.
|
|
227
|
+
*/
|
|
228
|
+
export declare function assessMappingTrust(input: {
|
|
229
|
+
manifests: readonly AppPortManifest[];
|
|
230
|
+
artifacts: readonly unknown[];
|
|
231
|
+
envelopes?: readonly unknown[];
|
|
232
|
+
policy?: CompiledTrustPolicy | unknown;
|
|
233
|
+
pins?: MappingPins;
|
|
234
|
+
acceptGenerated?: boolean;
|
|
235
|
+
}): Promise<MappingTrustAssessment>;
|
|
236
|
+
export {};
|
|
237
|
+
//# sourceMappingURL=trust.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trust.d.ts","sourceRoot":"","sources":["../src/trust.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAoD,KAAK,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAK5G,OAAO,EAAyB,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAEzE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD,eAAO,MAAM,wBAAwB,EAAG,6BAAsC,CAAC;AAC/E,eAAO,MAAM,mBAAmB,EAAG,gCAAyC,CAAC;AAC7E,eAAO,MAAM,mBAAmB,EAAG,gCAAyC,CAAC;AAC7E,eAAO,MAAM,iBAAiB,sBAAuB,CAAC;AACtD,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AAiBjE;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,OAAO,wBAAwB,CAAC;IACxC,4GAA4G;IAC5G,OAAO,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IACzD,0EAA0E;IAC1E,SAAS,EAAE,MAAM,CAAC;IAClB,2EAA2E;IAC3E,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,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