Skip to content

Commit da2a8c4

Browse files
committed
Add raw FEP-f799 shape and origin tools
Inspect original JSON-LD rather than generated getters so invalid values and multiplicity remain visible at the peer boundary. Keep detached evidence and diagnostics, use offline contexts by default, and expose unverified notice, activity, and control metadata claims. Normalize strictly parsed HTTPS origins with pinned Unicode 12 IDNA2008 data, and compare XML Schema timestamps without truncating precision. Keep the tools in a separate subpath for later protocol integration. Closes #1369 Assisted-by: Codex:gpt-6.1-sol Assisted-by: Claude Code:claude-fable-5-2 Assisted-by: OpenCode:kimi-k3.1-pro Assisted-by: Claude Code:claude-sonnet-5-5 Assisted-by: Codex:gpt-6-astra
1 parent 3e03db7 commit da2a8c4

21 files changed

Lines changed: 3940 additions & 3 deletions

File tree

‎CHANGES.md‎

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,17 @@ To be released.
6262
breaking source compatibility for custom implementations. Update custom
6363
mocks, decorators, and wrappers to implement this method.
6464
[[#1316], [#1359] by Jiwon Kwon\]
65+
- Added raw [FEP-f799] shape tools in
66+
`@fedify/fedify/delivery-suspension`. The asynchronous notice, activity,
67+
actor metadata, and inbox metadata parsers preserve expanded IRI spelling,
68+
literal values, and multiplicity, and return detached evidence and
69+
diagnostics. The default loader resolves preloaded contexts locally;
70+
applications can explicitly supply a context loader.
71+
Strict HTTPS origin helpers validate origin spelling before URL
72+
normalization, including IDNA2008 validation against a pinned Unicode 12.0
73+
repertoire. These tools expose unverified claims; they do not authenticate
74+
notices, establish controller authority, or suspend delivery.
75+
[[#1369], [#1435]]
6576
- Added sender payload projection support for the published FEP-171b context,
6677
preserving blind-recipient redaction.
6778
[[#1250], [#1396] by Jiwon Kwon\]
@@ -99,6 +110,7 @@ To be released.
99110
[[#1030], [#1205] by Yujin Jung\]
100111

101112
[FEP-7aa9]: https://w3id.org/fep/7aa9
113+
[FEP-f799]: https://w3id.org/fep/f799
102114
[GHSA-4qhx-hhwf-8685]: https://github.com/fedify-dev/fedify/security/advisories/GHSA-4qhx-hhwf-8685
103115
[#1030]: https://github.com/fedify-dev/fedify/issues/1030
104116
[#1177]: https://github.com/fedify-dev/fedify/issues/1177
@@ -114,9 +126,11 @@ To be released.
114126
[#1328]: https://github.com/fedify-dev/fedify/pull/1328
115127
[#1353]: https://github.com/fedify-dev/fedify/pull/1353
116128
[#1359]: https://github.com/fedify-dev/fedify/pull/1359
129+
[#1369]: https://github.com/fedify-dev/fedify/issues/1369
117130
[#1382]: https://github.com/fedify-dev/fedify/issues/1382
118131
[#1396]: https://github.com/fedify-dev/fedify/pull/1396
119132
[#1415]: https://github.com/fedify-dev/fedify/pull/1415
133+
[#1435]: https://github.com/fedify-dev/fedify/pull/1435
120134

121135
### @fedify/backfill
122136

@@ -506,14 +520,11 @@ To be released.
506520
anew, such as a clone, encodes such an object from its values rather
507521
than embedding its received JSON-LD. [[#1272], [#1356]]
508522

509-
[FEP-f799]: https://w3id.org/fep/f799
510523
[FEP-6757]: https://w3id.org/fep/6757
511524
[#1212]: https://github.com/fedify-dev/fedify/issues/1212
512525
[#1241]: https://github.com/fedify-dev/fedify/pull/1241
513526
[#1243]: https://github.com/fedify-dev/fedify/issues/1243
514527
[#1337]: https://github.com/fedify-dev/fedify/pull/1337
515-
[#1369]: https://github.com/fedify-dev/fedify/issues/1369
516-
[#1435]: https://github.com/fedify-dev/fedify/pull/1435
517528

518529
### @fedify/vocab-runtime
519530

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
links:
3+
'#1369': https://github.com/fedify-dev/fedify/issues/1369
4+
'#1435': https://github.com/fedify-dev/fedify/pull/1435
5+
---
6+
- Added raw [FEP-f799] shape tools in
7+
`@fedify/fedify/delivery-suspension`. The asynchronous notice, activity,
8+
actor metadata, and inbox metadata parsers preserve expanded IRI spelling,
9+
literal values, and multiplicity, and return detached evidence and
10+
diagnostics. The default loader resolves preloaded contexts locally;
11+
applications can explicitly supply a context loader.
12+
Strict HTTPS origin helpers validate origin spelling before URL
13+
normalization, including IDNA2008 validation against a pinned Unicode 12.0
14+
repertoire. These tools expose unverified claims; they do not authenticate
15+
notices, establish controller authority, or suspend delivery.
16+
[[#1369], [#1435]]
17+
18+
[FEP-f799]: https://w3id.org/fep/f799

‎claude-plugin/skills/actor/SKILL.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,11 @@ origin control: verify the reciprocal origin WebFinger relation separately.
3434
it does not fetch the actor or grant authority. These vocabulary properties
3535
do not enable receiving or suspend outbound delivery.
3636

37+
Inspect actor and inbox control claims with `parseActorControlMetadata()`
38+
and `parseInboxControlMetadata()` from
39+
`@fedify/fedify/delivery-suspension`. Use `expectedId` to require an exact
40+
expanded representation ID. The results retain absent, single, multiple,
41+
and invalid link states, including unresolved endpoint links; they do not
42+
establish controller authority or fetch linked resources.
43+
3744
[FEP-f799]: https://w3id.org/fep/f799

‎claude-plugin/skills/fep/SKILL.md‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,19 @@ notice, verify controller authority, advertise a capability, or suspend
6060
delivery. Validate the original JSON-LD before applying protocol decisions;
6161
generated accessors can skip malformed values and hide multiplicity.
6262

63+
For raw FEP-f799 documents, use the tools in
64+
`@fedify/fedify/delivery-suspension`:
65+
`parseDeliverySuspensionDocument()`,
66+
`parseDeliverySuspensionActivityDocument()`,
67+
`parseActorControlMetadata()`, and `parseInboxControlMetadata()`.
68+
These asynchronous parsers retain multiplicity and return detached raw and
69+
expanded evidence. Their default context loader resolves only preloaded
70+
contexts; an explicit `contextLoader` must bound its own I/O.
71+
Use `parseDeliverySuspensionOrigin()` for root-origin identifiers and
72+
`getDeliverySuspensionUrlOrigin()` for endpoint origins. The origin helpers
73+
apply IDNA2008 with a pinned Unicode 12.0 repertoire.
74+
Successful parsing establishes shape consistency only. Authentication,
75+
controller authority, replay checks, and signed-state equality still require
76+
separate validation. An `Undo` result contains an unverified activity claim.
77+
6378
[FEP-f799]: https://w3id.org/fep/f799

‎packages/fedify/deno.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"exports": {
66
".": "./src/mod.ts",
77
"./compat": "./src/compat/mod.ts",
8+
"./delivery-suspension": "./src/delivery-suspension/mod.ts",
89
"./federation": "./src/federation/mod.ts",
910
"./nodeinfo": "./src/nodeinfo/mod.ts",
1011
"./otel": "./src/otel/mod.ts",

‎packages/fedify/package.json‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,16 @@
7777
"require": "./dist/compat/mod.cjs",
7878
"default": "./dist/compat/mod.js"
7979
},
80+
"./delivery-suspension": {
81+
"types": {
82+
"import": "./dist/delivery-suspension/mod.d.ts",
83+
"require": "./dist/delivery-suspension/mod.d.cts",
84+
"default": "./dist/delivery-suspension/mod.d.ts"
85+
},
86+
"import": "./dist/delivery-suspension/mod.js",
87+
"require": "./dist/delivery-suspension/mod.cjs",
88+
"default": "./dist/delivery-suspension/mod.js"
89+
},
8090
"./federation": {
8191
"types": {
8292
"import": "./dist/federation/mod.d.ts",
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
/**
2+
* Offline Unicode 12.0.0 IDNA2008 table generator.
3+
* Run: node --experimental-strip-types scripts/generate-idna.ts INPUT_DIR OUTPUT_DIR [--check]
4+
* Supply the named pinned source files below; this script never fetches data.
5+
* OUTPUT_DIR is packages/fedify/src/delivery-suspension in the checkout.
6+
*/
7+
import { createHash } from "node:crypto";
8+
import { readFileSync, writeFileSync } from "node:fs";
9+
10+
const sources = {
11+
"iana12.csv": [
12+
"https://www.iana.org/assignments/idna-tables-12.0.0/idna-tables-properties.csv",
13+
"160b72e33a377a84253393c572dc338879f39b93beccbb9cb9baebbf4d6dd743",
14+
],
15+
"UnicodeData12.txt": [
16+
"https://www.unicode.org/Public/12.0.0/ucd/UnicodeData.txt",
17+
"57913fdb1c1271fa9fd51dea08d49370f33d5bfda6bbaba348f44d90029ea11d",
18+
],
19+
"DerivedJoiningType12.txt": [
20+
"https://www.unicode.org/Public/12.0.0/ucd/extracted/DerivedJoiningType.txt",
21+
"2a92a39d6713b8cc9a6d4eb808efaf93c52a4fcc01c149fec9892113838dae8b",
22+
],
23+
"Scripts12.txt": [
24+
"https://www.unicode.org/Public/12.0.0/ucd/Scripts.txt",
25+
"bd327cbb8bffd2e4b40b1e9842c9a7d641d1c4e91c34a41020cf174f3a1c86a1",
26+
],
27+
"UnicodeLicense.txt": [
28+
"https://www.unicode.org/license.txt",
29+
"e7a93b009565cfce55919a381437ac4db883e9da2126fa28b91d12732bc53d96",
30+
],
31+
} as const;
32+
const [input, output, mode] = process.argv.slice(2);
33+
if (!input || !output || (mode != null && mode !== "--check")) {
34+
throw new Error("Usage: generate-idna.ts INPUT_DIR OUTPUT_DIR [--check]");
35+
}
36+
function hash(text: string): string {
37+
return createHash("sha256").update(text).digest("hex");
38+
}
39+
const files: Record<string, string> = {};
40+
for (const [name, [, digest]] of Object.entries(sources)) {
41+
const bytes = readFileSync(`${input}/${name}`);
42+
if (createHash("sha256").update(bytes).digest("hex") !== digest) {
43+
throw new Error(`Source hash mismatch: ${name}`);
44+
}
45+
files[name] = bytes.toString("utf8");
46+
}
47+
const bidiNames = [
48+
"",
49+
"L",
50+
"R",
51+
"AL",
52+
"AN",
53+
"EN",
54+
"ES",
55+
"CS",
56+
"ET",
57+
"ON",
58+
"BN",
59+
"NSM",
60+
];
61+
const joiningNames = ["", "L", "R", "D", "T"];
62+
const scriptNames = ["", "Greek", "Hebrew", "Han", "Hiragana", "Katakana"];
63+
const arrays = Object.fromEntries(
64+
["validity", "assigned", "mark", "virama", "bidi", "joining", "script"].map(
65+
(key) => [key, new Uint8Array(0x110000)],
66+
),
67+
);
68+
function fill(key: string, start: number, end: number, value: number): void {
69+
if (value > 0) arrays[key].fill(value, start, end + 1);
70+
}
71+
function range(value: string): [number, number] {
72+
const [start, end = start] = value
73+
.split(/\.\.|-/)
74+
.map((part) => parseInt(part, 16));
75+
if (!(start >= 0 && end >= start && end <= 0x10ffff))
76+
throw new Error("Invalid source range");
77+
return [start, end];
78+
}
79+
for (const line of files["iana12.csv"].split(/\r?\n/).slice(1)) {
80+
const [points, property] = line.split(",");
81+
const value = ["", "PVALID", "CONTEXTJ", "CONTEXTO"].indexOf(property);
82+
if (value > 0) fill("validity", ...range(points), value);
83+
}
84+
let first: string[] | undefined;
85+
for (const line of files["UnicodeData12.txt"].trim().split(/\r?\n/)) {
86+
const fields = line.split(";");
87+
if (fields[1].endsWith(", First>")) {
88+
if (first) throw new Error("Nested First range");
89+
first = fields;
90+
continue;
91+
}
92+
const start = parseInt((first ?? fields)[0], 16);
93+
const end = parseInt(fields[0], 16);
94+
if (first && !fields[1].endsWith(", Last>"))
95+
throw new Error("Unclosed First range");
96+
if (!first && fields[1].endsWith(", Last>"))
97+
throw new Error("Unexpected Last range");
98+
if (first && first.slice(2).join(";") !== fields.slice(2).join(";"))
99+
throw new Error("Inconsistent First/Last properties");
100+
fill("assigned", start, end, 1);
101+
fill("mark", start, end, Number(fields[2].startsWith("M")));
102+
fill("virama", start, end, Number(fields[3] === "9"));
103+
fill("bidi", start, end, bidiNames.indexOf(fields[4]));
104+
first = undefined;
105+
}
106+
if (first) throw new Error("Unclosed First range");
107+
for (const [file, key, names] of [
108+
["DerivedJoiningType12.txt", "joining", joiningNames],
109+
["Scripts12.txt", "script", scriptNames],
110+
] as const) {
111+
for (const line of files[file].split(/\r?\n/)) {
112+
const match = /^\s*([0-9A-F.]+)\s*;\s*(\w+)/.exec(line);
113+
if (match) fill(key, ...range(match[1]), names.indexOf(match[2]));
114+
}
115+
}
116+
// Every array is an ordered sequence of inclusive [first, last, property] triples.
117+
const tables: Record<string, number[]> = {};
118+
for (const [key, values] of Object.entries(arrays)) {
119+
const ranges: number[] = [];
120+
for (let i = 0; i < values.length;) {
121+
const start = i,
122+
value = values[i++];
123+
while (i < values.length && values[i] === value) i++;
124+
if (value > 0) ranges.push(start, i - 1, value);
125+
}
126+
tables[key] = ranges;
127+
}
128+
const digest = hash(JSON.stringify(tables));
129+
const sourceComments = Object.entries(sources)
130+
.map(([name, [url, digest]]) => `// ${name}: ${url}\n// SHA-256: ${digest}`)
131+
.join("\n");
132+
const source = `/*! @license\n${files["UnicodeLicense.txt"].trimEnd()}\n*/\n// Generated by scripts/generate-idna.ts; do not edit.\n// Unicode 12.0.0. See UNICODE-LICENSE.txt in this directory.\n${sourceComments}\nexport const IDNA_UNICODE_VERSION = "12.0.0";\nexport const IDNA_DATA_SHA256 =\n "${digest}";\n// prettier-ignore\nexport const IDNA_TABLES: Readonly<Record<"validity" | "assigned" | "mark" | "virama" | "bidi" | "joining" | "script", readonly number[]>> = ${JSON.stringify(tables, null, 0)};\n`;
133+
for (const [name, content] of [
134+
["idna-data.ts", source],
135+
["UNICODE-LICENSE.txt", files["UnicodeLicense.txt"]],
136+
]) {
137+
const path = `${output}/${name}`;
138+
if (mode === "--check") {
139+
if (readFileSync(path, "utf8") !== content)
140+
throw new Error(`Generated file differs: ${path}`);
141+
} else writeFileSync(path, content);
142+
}
143+
process.stdout.write(
144+
`Unicode 12.0.0 IDNA tables ${mode === "--check" ? "verified" : "generated"}: ${digest}\n`,
145+
);

‎packages/fedify/src/cfworkers/expected-tests.ts‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,34 @@
11
// The Workers suite is deliberately bounded to tests validated on workerd.
22
export const expectedTestNames = [
3+
"delivery suspension context URL limit retains resource diagnostics",
4+
"delivery suspension IDNA validates canonical Unicode 12 A-labels",
5+
"delivery suspension IDNA rejects invalid context and normalization",
6+
"delivery suspension IDNA applies bidi rules to the whole decoded domain",
7+
"delivery suspension Punycode handles scalar boundaries and checked arithmetic",
8+
"delivery suspension IDNA enforces DNS label and domain boundaries",
9+
"delivery suspension Unicode 12 tables preserve source ranges and digest",
10+
"delivery suspension origins preserve DNS spelling and normalize ports",
11+
"delivery suspension origins validate IP literals before URL normalization",
12+
"delivery suspension origins reject lossy and non-origin wire spellings",
13+
"delivery suspension endpoint origins share strict authorities and allow URI suffixes",
14+
"delivery suspension HTTPS syntax retains claims beyond strict IDNA origins",
15+
"delivery suspension notice preserves detached immutable original claims",
16+
"delivery suspension aliases scoped contexts and expanded IRIs retain exact spelling",
17+
"delivery suspension cardinality rejects null empty and aliased extra targets",
18+
"delivery suspension conservative expansion rejects global structural loss",
19+
"delivery suspension strict literal shapes times revisions and target URI syntax",
20+
"delivery suspension Create Update and unverified Undo activity claims",
21+
"delivery suspension metadata preserves absent single invalid and multiple links",
22+
"delivery suspension actor metadata retains unresolved endpoints and parent ambiguity",
23+
"delivery suspension rejects unsafe JSON without invoking accessors",
24+
"delivery suspension default loader is offline cloned and unknown contexts never fetch",
25+
"delivery suspension custom contexts are memoized validated and detached before awaits",
26+
"delivery suspension rejects base in inline scoped imported and loaded context closure",
27+
"delivery suspension loader cannot be bypassed by ambient JSON-LD context cache",
28+
"delivery suspension diagnostic markers avoid input and loaded-context collisions",
29+
"delivery suspension exact dateTime grammar and Gregorian dates",
30+
"delivery suspension exact dateTime offsets and fractional comparison",
31+
"delivery suspension exact dateTime resource bound preserves arbitrary precision",
332
"FEP-f799 DeliverySuspension compacts and round-trips directly and nested",
433
"FEP-f799 controlledOrigins on all actor classes preserves spelling and context",
534
"FEP-f799 deliveryController is an inherited URL scalar without dereference",
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
UNICODE LICENSE V3
2+
3+
COPYRIGHT AND PERMISSION NOTICE
4+
5+
Copyright © 1991-2026 Unicode, Inc.
6+
7+
NOTICE TO USER: Carefully read the following legal agreement. BY
8+
DOWNLOADING, INSTALLING, COPYING OR OTHERWISE USING DATA FILES, AND/OR
9+
SOFTWARE, YOU UNEQUIVOCALLY ACCEPT, AND AGREE TO BE BOUND BY, ALL OF THE
10+
TERMS AND CONDITIONS OF THIS AGREEMENT. IF YOU DO NOT AGREE, DO NOT
11+
DOWNLOAD, INSTALL, COPY, DISTRIBUTE OR USE THE DATA FILES OR SOFTWARE.
12+
13+
Permission is hereby granted, free of charge, to any person obtaining a
14+
copy of data files and any associated documentation (the "Data Files") or
15+
software and any associated documentation (the "Software") to deal in the
16+
Data Files or Software without restriction, including without limitation
17+
the rights to use, copy, modify, merge, publish, distribute, and/or sell
18+
copies of the Data Files or Software, and to permit persons to whom the
19+
Data Files or Software are furnished to do so, provided that either (a)
20+
this copyright and permission notice appear with all copies of the Data
21+
Files or Software, or (b) this copyright and permission notice appear in
22+
associated Documentation.
23+
24+
THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
25+
KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
27+
THIRD PARTY RIGHTS.
28+
29+
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE
30+
BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES,
31+
OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
32+
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
33+
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA
34+
FILES OR SOFTWARE.
35+
36+
Except as contained in this notice, the name of a copyright holder shall
37+
not be used in advertising or otherwise to promote the sale, use or other
38+
dealings in these Data Files or Software without prior written
39+
authorization of the copyright holder.

0 commit comments

Comments
 (0)