@worker-protocol/conformance 0.1.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 +201 -0
- package/NOTICE +9 -0
- package/dist/attribution.d.ts +13 -0
- package/dist/attribution.js +27 -0
- package/dist/checks/actions.d.ts +24 -0
- package/dist/checks/actions.js +345 -0
- package/dist/checks/activity.d.ts +18 -0
- package/dist/checks/activity.js +64 -0
- package/dist/checks/alerts.d.ts +16 -0
- package/dist/checks/alerts.js +84 -0
- package/dist/checks/arranged.d.ts +27 -0
- package/dist/checks/arranged.js +232 -0
- package/dist/checks/descriptor.d.ts +34 -0
- package/dist/checks/descriptor.js +179 -0
- package/dist/checks/endpoints.d.ts +17 -0
- package/dist/checks/endpoints.js +139 -0
- package/dist/checks/events.d.ts +16 -0
- package/dist/checks/events.js +58 -0
- package/dist/checks/health.d.ts +13 -0
- package/dist/checks/health.js +85 -0
- package/dist/checks/metrics.d.ts +14 -0
- package/dist/checks/metrics.js +422 -0
- package/dist/checks/nudges.d.ts +20 -0
- package/dist/checks/nudges.js +77 -0
- package/dist/checks/surfaces.d.ts +14 -0
- package/dist/checks/surfaces.js +249 -0
- package/dist/checks/tasks.d.ts +23 -0
- package/dist/checks/tasks.js +171 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +120 -0
- package/dist/index.d.ts +95 -0
- package/dist/index.js +128 -0
- package/dist/report.d.ts +87 -0
- package/dist/report.js +71 -0
- package/dist/transcript.d.ts +44 -0
- package/dist/transcript.js +49 -0
- package/package.json +51 -0
- package/rules.json +1242 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Rowing Tech, S.A.
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
worker-protocol
|
|
2
|
+
Copyright 2026 Rowing Tech, S.A.
|
|
3
|
+
|
|
4
|
+
This product includes software developed at Rowing Tech, S.A. (https://rowing.tech).
|
|
5
|
+
|
|
6
|
+
Licensed under the Apache License, Version 2.0. See LICENSE for the full text.
|
|
7
|
+
|
|
8
|
+
"worker-protocol" and any conformance claim made in its name are not licensed under Apache-2.0;
|
|
9
|
+
see section 6 of the License.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which rule a failure at a place in a document belongs to.
|
|
3
|
+
*
|
|
4
|
+
* The map is generated from `schemas/` by `src/generate-rules.ts`, which reads the leading rule id
|
|
5
|
+
* off each node's `description`. Nothing is decided here: this file only walks a path against what
|
|
6
|
+
* the normative artifact already says, so that a report names the obligation that was broken
|
|
7
|
+
* rather than announcing that a document is invalid.
|
|
8
|
+
*
|
|
9
|
+
* A segment the schema has nothing to say about — a key under `additionalProperties`, which is the
|
|
10
|
+
* Worker's own — matches `*`.
|
|
11
|
+
*/
|
|
12
|
+
export type Attribution = Record<string, Record<string, string>>;
|
|
13
|
+
export declare function ruleFor(attribution: Attribution, schema: string, path: PropertyKey[]): string | null;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export function ruleFor(attribution, schema, path) {
|
|
2
|
+
const map = attribution[schema];
|
|
3
|
+
if (map === undefined)
|
|
4
|
+
return null;
|
|
5
|
+
// The deepest node on the path that cites a rule. Walking rather than looking up the whole path
|
|
6
|
+
// is what lets a failure deep inside a member the schema says nothing finer about still land on
|
|
7
|
+
// the rule that governs the member — a report that is coarse where the schema is coarse, and
|
|
8
|
+
// never more precise than the document it derives from.
|
|
9
|
+
let found = map[""] ?? null;
|
|
10
|
+
let prefix = "";
|
|
11
|
+
for (const segment of path) {
|
|
12
|
+
const literal = prefix === "" ? String(segment) : `${prefix}/${String(segment)}`;
|
|
13
|
+
const wildcard = prefix === "" ? "*" : `${prefix}/*`;
|
|
14
|
+
if (map[literal] !== undefined) {
|
|
15
|
+
prefix = literal;
|
|
16
|
+
found = map[literal];
|
|
17
|
+
}
|
|
18
|
+
else if (map[wildcard] !== undefined) {
|
|
19
|
+
prefix = wildcard;
|
|
20
|
+
found = map[wildcard];
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return found;
|
|
27
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type Attribution } from "../attribution.ts";
|
|
2
|
+
import type { Arrangement } from "../index.ts";
|
|
3
|
+
import { type Result, type Rule } from "../report.ts";
|
|
4
|
+
import type { Transcript } from "../transcript.ts";
|
|
5
|
+
/**
|
|
6
|
+
* The `actions` Capability.
|
|
7
|
+
*
|
|
8
|
+
* **This is the first check in the verifier that sends a POST, and it asks permission first.**
|
|
9
|
+
* Every other surface here is read: a GET establishes what it establishes and leaves the Worker as
|
|
10
|
+
* it found it. An Action is an operation somebody's operators chose to expose, and a tool that
|
|
11
|
+
* posted to one uninvited would be performing work on a system it was pointed at to inspect —
|
|
12
|
+
* which is not a thing a conformance report is worth. So every probe that posts is behind
|
|
13
|
+
* `mayPerform`, and without it those rules report `notExercised` with the reason.
|
|
14
|
+
*
|
|
15
|
+
* The refusals below perform nothing even when they are allowed — an Action name no entry
|
|
16
|
+
* declares, a request naming none, an input no schema could accept — but the request is still a
|
|
17
|
+
* POST to somebody's Worker, and whether that is acceptable is theirs to say rather than this
|
|
18
|
+
* tool's to assume.
|
|
19
|
+
*/
|
|
20
|
+
export declare const CLAIMS: readonly ["ACT-16", "ACT-2", "ACT-3", "ACT-4", "ACT-6", "ACT-7", "ACT-8", "ACT-12", "ACT-15", "DESC-11", "ENDP-3", "ENDP-15", "ENDP-18", "REG-31", "ACT-5", "ACT-9", "ACT-10", "ACT-11", "ENDP-12", "ENDP-16", "ENDP-17"];
|
|
21
|
+
export declare function checkActions(entry: Record<string, unknown> | undefined, url: string | null, descriptorUrl: string, rules: Map<string, Rule>, attribution: Attribution, transcript: Transcript, mayPerform: boolean, arrangement: Arrangement): Promise<{
|
|
22
|
+
results: Result[];
|
|
23
|
+
addresses: string[];
|
|
24
|
+
}>;
|
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
import { actionsEntry } from "@worker-protocol/schemas";
|
|
2
|
+
import { ruleFor } from "../attribution.js";
|
|
3
|
+
import { verdicts } from "../report.js";
|
|
4
|
+
/**
|
|
5
|
+
* The `actions` Capability.
|
|
6
|
+
*
|
|
7
|
+
* **This is the first check in the verifier that sends a POST, and it asks permission first.**
|
|
8
|
+
* Every other surface here is read: a GET establishes what it establishes and leaves the Worker as
|
|
9
|
+
* it found it. An Action is an operation somebody's operators chose to expose, and a tool that
|
|
10
|
+
* posted to one uninvited would be performing work on a system it was pointed at to inspect —
|
|
11
|
+
* which is not a thing a conformance report is worth. So every probe that posts is behind
|
|
12
|
+
* `mayPerform`, and without it those rules report `notExercised` with the reason.
|
|
13
|
+
*
|
|
14
|
+
* The refusals below perform nothing even when they are allowed — an Action name no entry
|
|
15
|
+
* declares, a request naming none, an input no schema could accept — but the request is still a
|
|
16
|
+
* POST to somebody's Worker, and whether that is acceptable is theirs to say rather than this
|
|
17
|
+
* tool's to assume.
|
|
18
|
+
*/
|
|
19
|
+
export const CLAIMS = [
|
|
20
|
+
"ACT-16",
|
|
21
|
+
"ACT-2",
|
|
22
|
+
"ACT-3",
|
|
23
|
+
"ACT-4",
|
|
24
|
+
"ACT-6",
|
|
25
|
+
"ACT-7",
|
|
26
|
+
"ACT-8",
|
|
27
|
+
"ACT-12",
|
|
28
|
+
"ACT-15",
|
|
29
|
+
"DESC-11",
|
|
30
|
+
"ENDP-3",
|
|
31
|
+
"ENDP-15",
|
|
32
|
+
"ENDP-18",
|
|
33
|
+
"REG-31",
|
|
34
|
+
// Only observable against a Worker whose operators arranged one, and said so.
|
|
35
|
+
"ACT-5",
|
|
36
|
+
"ACT-9",
|
|
37
|
+
"ACT-10",
|
|
38
|
+
"ACT-11",
|
|
39
|
+
"ENDP-12",
|
|
40
|
+
"ENDP-16",
|
|
41
|
+
"ENDP-17",
|
|
42
|
+
];
|
|
43
|
+
export async function checkActions(entry, url, descriptorUrl, rules, attribution, transcript, mayPerform, arrangement) {
|
|
44
|
+
const { results, say, allExcept } = verdicts(rules, CLAIMS);
|
|
45
|
+
const addresses = [];
|
|
46
|
+
if (entry === undefined) {
|
|
47
|
+
allExcept("notExercised", "the Worker declares no `actions`");
|
|
48
|
+
return { results, addresses };
|
|
49
|
+
}
|
|
50
|
+
// ACT-16 to ACT-4, ACT-12 and ENDP-15 are read off the Descriptor, and a verifier fails the
|
|
51
|
+
// Worker on them without sending anything at all.
|
|
52
|
+
const declared = actionsEntry.safeParse(entry);
|
|
53
|
+
if (!declared.success) {
|
|
54
|
+
const blamed = new Set();
|
|
55
|
+
for (const issue of declared.error.issues) {
|
|
56
|
+
const id = ruleFor(attribution, "actions-entry", issue.path) ?? "ACT-16";
|
|
57
|
+
if (blamed.has(id))
|
|
58
|
+
continue;
|
|
59
|
+
blamed.add(id);
|
|
60
|
+
say(id, "fails", `${issue.path.join(".") || "(root)"}: ${issue.message}`);
|
|
61
|
+
}
|
|
62
|
+
allExcept("notExercised", "the `actions` entry did not validate", [...blamed]);
|
|
63
|
+
return { results, addresses };
|
|
64
|
+
}
|
|
65
|
+
const { accepts: actions } = declared.data;
|
|
66
|
+
for (const id of ["ACT-16", "ACT-2", "ACT-3", "ACT-4"])
|
|
67
|
+
say(id, "passes");
|
|
68
|
+
// ACT-12 and ENDP-15 are the same declaration seen from two files: ENDP-15 requires it and
|
|
69
|
+
// ACT-12 says where it lives and what it carries. Where no Action takes a key there is nothing
|
|
70
|
+
// to judge, and saying so is not the same as passing.
|
|
71
|
+
const withKeys = Object.entries(actions).filter(([, a]) => a.idempotency !== undefined);
|
|
72
|
+
if (withKeys.length === 0) {
|
|
73
|
+
say("ACT-12", "notExercised", "no Action declares an idempotency key");
|
|
74
|
+
say("ENDP-15", "notExercised", "no Action declares an idempotency key");
|
|
75
|
+
say("DESC-11", "notExercised", "no Capability declares a behaviour conditional on a call");
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
// The schema made the half-set state unspellable — `from: "input"` with no member named is a
|
|
79
|
+
// document nobody can write — so validating it IS the check.
|
|
80
|
+
say("ACT-12", "passes");
|
|
81
|
+
say("ENDP-15", "passes");
|
|
82
|
+
// DESC-11: where a Capability's behaviour on a call is conditional, the condition is declared
|
|
83
|
+
// in its entry. An idempotency declaration is that rule's first case.
|
|
84
|
+
say("DESC-11", "passes");
|
|
85
|
+
}
|
|
86
|
+
// ACT-15: a Worker that declares `configure` declares a reading address for it, and a GET of
|
|
87
|
+
// that address answers a document its own `configure` would accept. Without it a console renders
|
|
88
|
+
// an empty form and an operator replaces everything they did not remember.
|
|
89
|
+
const configure = actions.configure;
|
|
90
|
+
if (configure === undefined) {
|
|
91
|
+
say("ACT-15", "notExercised", "the Worker declares no `configure`");
|
|
92
|
+
}
|
|
93
|
+
else if (typeof configure.readAddress !== "string" || configure.readAddress.length === 0) {
|
|
94
|
+
say("ACT-15", "fails", "`configure` is declared with no reading address");
|
|
95
|
+
}
|
|
96
|
+
else if (url === null) {
|
|
97
|
+
say("ACT-15", "notExercised", "the `actions` address did not resolve");
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
// DESC-12 resolves a relative reference against the URL THE DESCRIPTOR WAS READ FROM, not
|
|
101
|
+
// against the Capability's own address. The two coincide for a Worker at the origin root and
|
|
102
|
+
// diverge the moment one is mounted under a path, which is the case that catches it.
|
|
103
|
+
const target = new URL(configure.readAddress, descriptorUrl).toString();
|
|
104
|
+
// ENDP-1: every address a caller uses is one the Descriptor declared, and this one is — inside
|
|
105
|
+
// the Action that declared it rather than beside the Capability. Each Capability knows where
|
|
106
|
+
// its own addresses live, which is why it hands them back rather than being guessed at.
|
|
107
|
+
addresses.push(target);
|
|
108
|
+
const answer = await transcript.send(target, "the `configure` reading address");
|
|
109
|
+
if (answer.status !== 200) {
|
|
110
|
+
say("ACT-15", "fails", `${target} answered ${answer.status}`);
|
|
111
|
+
}
|
|
112
|
+
else if (answer.json === null || typeof answer.json !== "object") {
|
|
113
|
+
say("ACT-15", "fails", "the reading address did not answer a document");
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
say("ACT-15", "passes");
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
if (url === null) {
|
|
120
|
+
allExcept("notExercised", "the `actions` address did not resolve", [
|
|
121
|
+
"ACT-16",
|
|
122
|
+
"ACT-2",
|
|
123
|
+
"ACT-3",
|
|
124
|
+
"ACT-4",
|
|
125
|
+
"ACT-12",
|
|
126
|
+
"ACT-15",
|
|
127
|
+
"DESC-11",
|
|
128
|
+
"ENDP-15",
|
|
129
|
+
]);
|
|
130
|
+
return { results, addresses };
|
|
131
|
+
}
|
|
132
|
+
if (!mayPerform) {
|
|
133
|
+
for (const id of [
|
|
134
|
+
"ACT-6",
|
|
135
|
+
"ACT-7",
|
|
136
|
+
"ACT-8",
|
|
137
|
+
"ENDP-3",
|
|
138
|
+
"ENDP-18",
|
|
139
|
+
"REG-31",
|
|
140
|
+
"ACT-5",
|
|
141
|
+
"ACT-9",
|
|
142
|
+
"ACT-10",
|
|
143
|
+
"ACT-11",
|
|
144
|
+
"ENDP-12",
|
|
145
|
+
"ENDP-16",
|
|
146
|
+
"ENDP-17",
|
|
147
|
+
]) {
|
|
148
|
+
say(id, "notExercised", "the verifier was not permitted to POST to this Worker");
|
|
149
|
+
}
|
|
150
|
+
return { results, addresses };
|
|
151
|
+
}
|
|
152
|
+
const post = (parameters, body, intent, extra = {}) => transcript.send(`${url}${parameters}`, intent, { method: "POST", body, ...extra });
|
|
153
|
+
const code = (answer) => answer.json?.code;
|
|
154
|
+
// ACT-7: a request naming no Action has not said what it wants, which is a parameter fault.
|
|
155
|
+
const unnamed = await post("", "{}", "a POST naming no Action", { permanent: true });
|
|
156
|
+
if (unnamed.status === 400 && code(unnamed) === "invalid_parameter")
|
|
157
|
+
say("ACT-7", "passes");
|
|
158
|
+
else
|
|
159
|
+
say("ACT-7", "fails", `answered ${unnamed.status} with \`${code(unnamed) ?? "no code"}\``);
|
|
160
|
+
// ENDP-3: everything that changes state is POST, on an address declared for the purpose. The
|
|
161
|
+
// witness is the converse — the address answers a POST, and does not serve the same operation
|
|
162
|
+
// to a GET, which ENDP-2 reserves for reads that change nothing.
|
|
163
|
+
const asRead = await transcript.send(`${url}?action=${encodeURIComponent(Object.keys(actions)[0] ?? "x")}`, "the Actions address as a GET");
|
|
164
|
+
if (unnamed.status !== 404 && asRead.status === 404)
|
|
165
|
+
say("ENDP-3", "passes");
|
|
166
|
+
else if (asRead.status !== 404)
|
|
167
|
+
say("ENDP-3", "fails", `a GET of the Actions address answered ${asRead.status}`);
|
|
168
|
+
else
|
|
169
|
+
say("ENDP-3", "fails", "the Actions address does not answer a POST");
|
|
170
|
+
// REG-31 recommends a credential on every address that changes state. A write accepted from the
|
|
171
|
+
// world is an operation performed by anyone who asks — and this protocol has published the
|
|
172
|
+
// address and the schema of every one of them in the Descriptor, which is the hard half of the
|
|
173
|
+
// attacker's work already done. It recommends rather than binds because it is advice about a
|
|
174
|
+
// deployment's exposure: every call to a Worker that ignores it still succeeds.
|
|
175
|
+
const uncredentialed = await transcript.send(`${url}?action=${encodeURIComponent(Object.keys(actions)[0] ?? "x")}`, "a POST with no credential at all", {
|
|
176
|
+
method: "POST",
|
|
177
|
+
body: "[]",
|
|
178
|
+
headers: { authorization: "" },
|
|
179
|
+
permanent: true,
|
|
180
|
+
});
|
|
181
|
+
if (uncredentialed.status === 401 || uncredentialed.status === 403)
|
|
182
|
+
say("REG-31", "passes");
|
|
183
|
+
else
|
|
184
|
+
say("REG-31", "fails", `a POST with no credential answered ${uncredentialed.status}`);
|
|
185
|
+
// ACT-6: an Action the entry does not declare is a resource that does not exist, and nothing is
|
|
186
|
+
// performed on the way to finding that out.
|
|
187
|
+
const absent = await post("?action=no-such-action-b7d2", "{}", "an Action the entry does not declare", { permanent: true });
|
|
188
|
+
if (absent.status === 404 && code(absent) === "not_found")
|
|
189
|
+
say("ACT-6", "passes");
|
|
190
|
+
else
|
|
191
|
+
say("ACT-6", "fails", `answered ${absent.status} with \`${code(absent) ?? "no code"}\``);
|
|
192
|
+
const [name, declaration] = Object.entries(actions)[0] ?? [];
|
|
193
|
+
if (name === undefined || declaration === undefined) {
|
|
194
|
+
say("ACT-8", "notExercised", "the entry declares no Action to post to");
|
|
195
|
+
say("ENDP-18", "notExercised", "the entry declares no Action to post to");
|
|
196
|
+
return { results, addresses };
|
|
197
|
+
}
|
|
198
|
+
// ACT-8: an input that does not match the declared schema. The body is an empty ARRAY on
|
|
199
|
+
// purpose: it is the smallest document that no Action's input schema could describe, so a Worker
|
|
200
|
+
// that acted on it would have acted on no input at all. A conformance tool has to pick something
|
|
201
|
+
// to be refused, and this is the one thing that cannot be mistaken for a request to do work.
|
|
202
|
+
//
|
|
203
|
+
// A key travels with it where the Action declares one. Two faults are present otherwise — a body
|
|
204
|
+
// that does not match AND a required key that is absent — and no rule fixes which a Worker names
|
|
205
|
+
// first, so a probe that provoked both would be asking a question the specification does not
|
|
206
|
+
// answer and failing whichever Worker answered it the other way. ENDP-18 has its own probe below.
|
|
207
|
+
const mismatched = await post(`?action=${encodeURIComponent(name)}`, "[]", "an input no schema could accept", {
|
|
208
|
+
permanent: true,
|
|
209
|
+
...(declaration.idempotency === undefined
|
|
210
|
+
? {}
|
|
211
|
+
: { headers: { "idempotency-key": `conformance-mismatch-${Date.now()}` } }),
|
|
212
|
+
});
|
|
213
|
+
if (mismatched.status === 400 && code(mismatched) === "schema_mismatch")
|
|
214
|
+
say("ACT-8", "passes");
|
|
215
|
+
else
|
|
216
|
+
say("ACT-8", "fails", `answered ${mismatched.status} with \`${code(mismatched) ?? "no code"}\``);
|
|
217
|
+
// ENDP-18: a required key that is absent is `400`. A Worker that performs the Action anyway has
|
|
218
|
+
// performed exactly the operation the key existed to protect.
|
|
219
|
+
const needsKey = Object.entries(actions).find(([, a]) => a.idempotency?.required === true);
|
|
220
|
+
if (needsKey === undefined) {
|
|
221
|
+
say("ENDP-18", "notExercised", "no Action requires an idempotency key");
|
|
222
|
+
}
|
|
223
|
+
else {
|
|
224
|
+
const [keyed] = needsKey;
|
|
225
|
+
const without = await post(`?action=${encodeURIComponent(keyed)}`, "[]", "an Action that requires a key, with none", { permanent: true });
|
|
226
|
+
if (without.status === 400 && code(without) === "idempotency_key_required") {
|
|
227
|
+
say("ENDP-18", "passes");
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
say("ENDP-18", "fails", `answered ${without.status} with \`${code(without) ?? "no code"}\``);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
await checkArranged(actions, arrangement, mismatched.status, post, say);
|
|
234
|
+
return { results, addresses };
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* The rules that need a Worker arranged for them, and told to the verifier.
|
|
238
|
+
*
|
|
239
|
+
* Every probe above is refused by design and performs nothing. These are the opposite: they ask a
|
|
240
|
+
* Worker to actually do something, so they need TWO consents — `mayPerform`, and an operator
|
|
241
|
+
* naming which Action is safe. Without both, each reports what was missing.
|
|
242
|
+
*/
|
|
243
|
+
async function checkArranged(actions, arrangement, mismatchedStatus, post, say) {
|
|
244
|
+
const code = (answer) => answer.json?.code;
|
|
245
|
+
const query = (name) => `?action=${encodeURIComponent(name)}`;
|
|
246
|
+
// ACT-5 and ACT-10: a performance that succeeds, answering `200` with the declared result or
|
|
247
|
+
// `204` where the Action declares none.
|
|
248
|
+
const safe = arrangement.safeAction;
|
|
249
|
+
if (safe === undefined) {
|
|
250
|
+
for (const id of ["ACT-5", "ACT-10", "ENDP-16", "ENDP-17"]) {
|
|
251
|
+
say(id, "notExercised", "no Action was named as safe to perform");
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
else {
|
|
255
|
+
const declaration = actions[safe.name];
|
|
256
|
+
const key = declaration?.idempotency !== undefined ? `conformance-${Date.now()}` : undefined;
|
|
257
|
+
const headers = key === undefined ? undefined : { "idempotency-key": key };
|
|
258
|
+
const body = JSON.stringify(safe.input);
|
|
259
|
+
const done = await post(query(safe.name), body, `the Action \`${safe.name}\``, { headers });
|
|
260
|
+
const wantsResult = declaration?.result !== undefined;
|
|
261
|
+
if (done.status === 200 || done.status === 204) {
|
|
262
|
+
say("ACT-5", "passes");
|
|
263
|
+
if (wantsResult && done.status === 200)
|
|
264
|
+
say("ACT-10", "passes");
|
|
265
|
+
else if (!wantsResult && done.status === 204)
|
|
266
|
+
say("ACT-10", "passes");
|
|
267
|
+
else {
|
|
268
|
+
const expected = wantsResult ? "200 with its result" : "204";
|
|
269
|
+
say("ACT-10", "fails", `it declares ${wantsResult ? "a result" : "none"} and answered ${done.status}, not ${expected}`);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
else {
|
|
273
|
+
say("ACT-5", "fails", `answered ${done.status} with \`${code(done) ?? "no code"}\``);
|
|
274
|
+
say("ACT-10", "notExercised", "the performance did not succeed");
|
|
275
|
+
}
|
|
276
|
+
if (key === undefined) {
|
|
277
|
+
for (const id of ["ENDP-16", "ENDP-17"]) {
|
|
278
|
+
say(id, "notExercised", `\`${safe.name}\` declares no idempotency key`);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
else {
|
|
282
|
+
// ENDP-16: within the window, a repeat under the same key is not a second performance — the
|
|
283
|
+
// Worker answers the outcome it recorded.
|
|
284
|
+
const again = await post(query(safe.name), body, "the same Action under the same key", {
|
|
285
|
+
headers,
|
|
286
|
+
});
|
|
287
|
+
if (again.status === done.status && again.body === done.body)
|
|
288
|
+
say("ENDP-16", "passes");
|
|
289
|
+
else
|
|
290
|
+
say("ENDP-16", "fails", `the repeat answered ${again.status}, not the recorded outcome`);
|
|
291
|
+
// ENDP-17: a key reused with a different body is `409`. Only the caller can tell a retry
|
|
292
|
+
// from a genuine repeat, and this is the Worker refusing to guess.
|
|
293
|
+
const other = JSON.stringify({ ...safe.input, "conformance-probe": true });
|
|
294
|
+
const reused = await post(query(safe.name), other, "the same key with another body", {
|
|
295
|
+
headers,
|
|
296
|
+
permanent: true,
|
|
297
|
+
});
|
|
298
|
+
if (reused.status === 409)
|
|
299
|
+
say("ENDP-17", "passes");
|
|
300
|
+
else
|
|
301
|
+
say("ENDP-17", "fails", `answered ${reused.status}, not 409`);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
// ACT-9 and ENDP-12: an input that matches the schema and that the Worker will not accept on its
|
|
305
|
+
// own rules. ENDP-12 needs BOTH halves — a 400 for a body it could not read and a 422 for one it
|
|
306
|
+
// read and refused — and the 400 came from the schema-mismatch probe above.
|
|
307
|
+
const refused = arrangement.refusedInput;
|
|
308
|
+
if (refused === undefined) {
|
|
309
|
+
say("ACT-9", "notExercised", "no input was named that this Worker refuses on its own rules");
|
|
310
|
+
say("ENDP-12", "notExercised", "nothing provoked a 422 to compare against the 400");
|
|
311
|
+
}
|
|
312
|
+
else {
|
|
313
|
+
const answer = await post(query(refused.name), JSON.stringify(refused.input), `\`${refused.name}\` with an input it refuses`, { permanent: true });
|
|
314
|
+
if (answer.status === 422 && code(answer) === "unprocessable_content") {
|
|
315
|
+
say("ACT-9", "passes");
|
|
316
|
+
if (mismatchedStatus === 400)
|
|
317
|
+
say("ENDP-12", "passes");
|
|
318
|
+
else
|
|
319
|
+
say("ENDP-12", "fails", `an unreadable body answered ${mismatchedStatus}, not 400`);
|
|
320
|
+
}
|
|
321
|
+
else {
|
|
322
|
+
say("ACT-9", "fails", `answered ${answer.status} with \`${code(answer) ?? "no code"}\``);
|
|
323
|
+
say("ENDP-12", "notExercised", "no 422 was provoked");
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
// ACT-11: an Action that declares it does not complete within the call answers `202` and no
|
|
327
|
+
// body. The declaration is read from the Descriptor, so a Worker that named the wrong Action
|
|
328
|
+
// here fails on what it itself declared.
|
|
329
|
+
const async = arrangement.asyncAction;
|
|
330
|
+
if (async === undefined) {
|
|
331
|
+
say("ACT-11", "notExercised", "no Action was named that does not complete within the call");
|
|
332
|
+
}
|
|
333
|
+
else if (actions[async.name]?.completesWithinCall !== false) {
|
|
334
|
+
say("ACT-11", "fails", `\`${async.name}\` declares that it DOES complete within the call`);
|
|
335
|
+
}
|
|
336
|
+
else {
|
|
337
|
+
const answer = await post(query(async.name), JSON.stringify(async.input), `\`${async.name}\`, which does not complete within the call`);
|
|
338
|
+
if (answer.status === 202 && answer.body.length === 0)
|
|
339
|
+
say("ACT-11", "passes");
|
|
340
|
+
else if (answer.status !== 202)
|
|
341
|
+
say("ACT-11", "fails", `answered ${answer.status}, not 202`);
|
|
342
|
+
else
|
|
343
|
+
say("ACT-11", "fails", "answered 202 with a body");
|
|
344
|
+
}
|
|
345
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type Attribution } from "../attribution.ts";
|
|
2
|
+
import { type Result, type Rule } from "../report.ts";
|
|
3
|
+
import type { Transcript } from "../transcript.ts";
|
|
4
|
+
/**
|
|
5
|
+
* The `activity` Capability.
|
|
6
|
+
*
|
|
7
|
+
* Alerts with the words changed, which is what `spec/activity.md` says it is: one address, one
|
|
8
|
+
* page, items that carry a closed-vocabulary state and a summary addressed to a person. What these
|
|
9
|
+
* checks can reach is exactly what a program can act on — that the page has the shape and that
|
|
10
|
+
* every state is one of the three.
|
|
11
|
+
*
|
|
12
|
+
* ACTV-5 is absent because nothing can reach it. An activity that disappears may have finished,
|
|
13
|
+
* failed, or been dropped, and no tool outside the Worker can tell which — the same shape as ALRT-5
|
|
14
|
+
* and TASK-15. ACTV-6 is `H` and lives in `arranged.ts` with ALRT-6, because two credentials have
|
|
15
|
+
* to exist before two lists can be compared.
|
|
16
|
+
*/
|
|
17
|
+
export declare const CLAIMS: readonly ["ACTV-1", "ACTV-2", "ACTV-3", "ACTV-4"];
|
|
18
|
+
export declare function checkActivity(entry: Record<string, unknown> | undefined, url: string | null, rules: Map<string, Rule>, attribution: Attribution, transcript: Transcript): Promise<Result[]>;
|