@fedify/vocab-runtime 2.4.0-pr.936.41 → 2.4.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.
Files changed (138) hide show
  1. package/deno.json +4 -2
  2. package/dist/{tests/docloader-Ck8bcBir.mjs → contexts-BK1CqBR5.cjs} +164 -275
  3. package/dist/{tests/docloader-S_gQZ2tt.cjs → contexts-DPuJ4UYL.js} +160 -294
  4. package/dist/{docloader-C_dir7Xb.d.ts → docloader-CYwqh5Df.d.cts} +66 -2
  5. package/dist/{docloader-D2DTRiyA.d.cts → docloader-CYwqh5Df.d.ts} +66 -2
  6. package/dist/internal/jsonld-cache.cjs +70 -1
  7. package/dist/internal/jsonld-cache.d.cts +35 -2
  8. package/dist/internal/jsonld-cache.d.ts +35 -2
  9. package/dist/internal/jsonld-cache.js +67 -2
  10. package/dist/internal/portable-dereference.cjs +721 -0
  11. package/dist/internal/portable-dereference.d.cts +349 -0
  12. package/dist/internal/portable-dereference.d.ts +349 -0
  13. package/dist/internal/portable-dereference.js +702 -0
  14. package/dist/internal/signed-representation.cjs +378 -0
  15. package/dist/internal/signed-representation.d.cts +144 -0
  16. package/dist/internal/signed-representation.d.ts +144 -0
  17. package/dist/internal/signed-representation.js +371 -0
  18. package/dist/jsonld.cjs +2 -2
  19. package/dist/mod.cjs +711 -4527
  20. package/dist/mod.d.cts +400 -8
  21. package/dist/mod.d.ts +400 -9
  22. package/dist/mod.js +692 -4522
  23. package/dist/portable-DqtfLy_1.d.cts +160 -0
  24. package/dist/portable-DtWsu2yU.d.ts +160 -0
  25. package/dist/tests/body-CYiu9CO-.mjs +130 -0
  26. package/dist/tests/body-CkEwROsn.cjs +153 -0
  27. package/dist/tests/body.test.cjs +89 -0
  28. package/dist/tests/body.test.d.cts +1 -0
  29. package/dist/tests/body.test.d.mts +1 -0
  30. package/dist/tests/body.test.mjs +90 -0
  31. package/dist/tests/contexts-CIKsin4e.mjs +4512 -0
  32. package/dist/tests/contexts-DizzBjz4.cjs +4523 -0
  33. package/dist/tests/decimal.test.cjs +8 -7
  34. package/dist/tests/decimal.test.mjs +8 -6
  35. package/dist/tests/digest-3FeH2Y-Q.cjs +176 -0
  36. package/dist/tests/digest-COC7xDiQ.mjs +141 -0
  37. package/dist/tests/digest.test.cjs +102 -0
  38. package/dist/tests/digest.test.d.cts +1 -0
  39. package/dist/tests/digest.test.d.mts +1 -0
  40. package/dist/tests/digest.test.mjs +103 -0
  41. package/dist/tests/docloader-C3YFl6y4.cjs +396 -0
  42. package/dist/tests/docloader-CvmS4sVq.mjs +373 -0
  43. package/dist/tests/docloader.test.cjs +692 -39
  44. package/dist/tests/docloader.test.mjs +686 -34
  45. package/dist/tests/internal/multicodec.test.cjs +2 -3
  46. package/dist/tests/internal/multicodec.test.mjs +2 -2
  47. package/dist/tests/internal/portable-dereference.test.cjs +172 -0
  48. package/dist/tests/internal/portable-dereference.test.d.cts +1 -0
  49. package/dist/tests/internal/portable-dereference.test.d.mts +1 -0
  50. package/dist/tests/internal/portable-dereference.test.mjs +173 -0
  51. package/dist/tests/jsonld-cache-BPQmOZWD.mjs +342 -0
  52. package/dist/tests/jsonld-cache-C07AyNOY.cjs +397 -0
  53. package/dist/tests/jsonld-cache.test.cjs +101 -298
  54. package/dist/tests/jsonld-cache.test.mjs +94 -289
  55. package/dist/tests/{key-_wXwomh_.cjs → key-C-AYkdJJ.cjs} +11 -4
  56. package/dist/tests/{key-CDGDH_vC.mjs → key-C2Db_TAJ.mjs} +11 -3
  57. package/dist/tests/key.test.cjs +6 -5
  58. package/dist/tests/key.test.mjs +6 -4
  59. package/dist/tests/langstr.test.cjs +4 -4
  60. package/dist/tests/langstr.test.mjs +2 -2
  61. package/dist/tests/link.test.cjs +2 -3
  62. package/dist/tests/link.test.mjs +2 -2
  63. package/dist/tests/multibase/multibase.test.cjs +8 -9
  64. package/dist/tests/multibase/multibase.test.mjs +6 -6
  65. package/dist/tests/{multibase-Bz_UUDtL.cjs → multibase-B5Mea7Ip.cjs} +19 -2
  66. package/dist/tests/{multibase-B4bvakyA.mjs → multibase-BPnF_L4e.mjs} +12 -1
  67. package/dist/tests/portable-dereference-BNXtgg5U.cjs +278 -0
  68. package/dist/tests/portable-dereference-DRE5bz-l.mjs +249 -0
  69. package/dist/tests/portable-media-BLKllU56.cjs +153 -0
  70. package/dist/tests/portable-media-DRSGBORB.mjs +148 -0
  71. package/dist/tests/portable-media.test.cjs +222 -0
  72. package/dist/tests/portable-media.test.d.cts +1 -0
  73. package/dist/tests/portable-media.test.d.mts +1 -0
  74. package/dist/tests/portable-media.test.mjs +223 -0
  75. package/dist/tests/portable-workers.test.cjs +36 -0
  76. package/dist/tests/portable-workers.test.d.cts +2 -0
  77. package/dist/tests/portable-workers.test.d.mts +2 -0
  78. package/dist/tests/portable-workers.test.mjs +35 -0
  79. package/dist/tests/{request-uk51rkhO.cjs → request-8vPWtV1-.cjs} +10 -4
  80. package/dist/tests/{request-C8CaGwtt.mjs → request-DRaOaTqD.mjs} +8 -2
  81. package/dist/tests/request.test.cjs +7 -4
  82. package/dist/tests/request.test.mjs +5 -2
  83. package/dist/tests/signed-representation.test.cjs +588 -0
  84. package/dist/tests/signed-representation.test.d.cts +1 -0
  85. package/dist/tests/signed-representation.test.d.mts +1 -0
  86. package/dist/tests/signed-representation.test.mjs +589 -0
  87. package/dist/tests/temporal.test.cjs +1 -2
  88. package/dist/tests/temporal.test.mjs +1 -1
  89. package/dist/tests/url-BNakuZ8k.cjs +998 -0
  90. package/dist/tests/url-DMxmp7ZG.mjs +859 -0
  91. package/dist/tests/url.test.cjs +489 -6
  92. package/dist/tests/url.test.mjs +489 -5
  93. package/dist/url-DrGTR8yv.cjs +993 -0
  94. package/dist/url-Dzyp-NsC.js +860 -0
  95. package/package.json +27 -4
  96. package/scripts/test-bun.mjs +17 -0
  97. package/src/body.test.ts +125 -0
  98. package/src/body.ts +152 -0
  99. package/src/contexts/cid-v1.json +114 -0
  100. package/src/contexts/fep-22cd.json +21 -0
  101. package/src/contexts/miscellany.json +17 -0
  102. package/src/contexts.ts +39 -1
  103. package/src/digest.test.ts +220 -0
  104. package/src/digest.ts +229 -0
  105. package/src/docloader.test.ts +918 -27
  106. package/src/docloader.ts +320 -105
  107. package/src/internal/jsonld-cache.ts +97 -1
  108. package/src/internal/portable-dereference.test.ts +254 -0
  109. package/src/internal/portable-dereference.ts +1000 -0
  110. package/src/internal/signed-representation.ts +565 -0
  111. package/src/jsonld-cache.test.ts +89 -0
  112. package/src/key.test.ts +9 -0
  113. package/src/key.ts +11 -1
  114. package/src/mod.ts +28 -0
  115. package/src/multibase/multibase.test.ts +5 -5
  116. package/src/portable-media.test.ts +293 -0
  117. package/src/portable-media.ts +264 -0
  118. package/src/portable-workers.test.ts +81 -0
  119. package/src/portable.ts +180 -0
  120. package/src/preprocessor.ts +7 -0
  121. package/src/request.test.ts +10 -1
  122. package/src/request.ts +9 -1
  123. package/src/signed-representation.test.ts +338 -0
  124. package/src/url.test.ts +823 -3
  125. package/src/url.ts +700 -23
  126. package/tsdown.config.ts +2 -0
  127. package/dist/tests/url-CsOV_B_P.cjs +0 -482
  128. package/dist/tests/url-Du7RQQgP.mjs +0 -392
  129. package/dist/url-DD4F0ULf.cjs +0 -483
  130. package/dist/url-DGVbSVVi.js +0 -393
  131. /package/dist/{chunk-M78iaK0I.cjs → rolldown-runtime-B7lfambq.cjs} +0 -0
  132. /package/dist/tests/{langstr-CbAxaeEZ.cjs → langstr-C4Fl80ae.cjs} +0 -0
  133. /package/dist/tests/{langstr-Di5AvKpB.mjs → langstr-CQ26J_L7.mjs} +0 -0
  134. /package/dist/tests/{link-NUUWCdnK.mjs → link-Cevmc87v.mjs} +0 -0
  135. /package/dist/tests/{link-FguCydMA.cjs → link-DlKm8bEr.cjs} +0 -0
  136. /package/dist/tests/{multicodec-CxGVGa91.cjs → multicodec-CLRPeW4N.cjs} +0 -0
  137. /package/dist/tests/{multicodec-CyFp54fI.mjs → multicodec-CRIj_05H.mjs} +0 -0
  138. /package/dist/tests/{chunk-C2EiDwsr.cjs → rolldown-runtime-emK7D4bc.cjs} +0 -0
@@ -1,282 +1,87 @@
1
- import { a as formatIri, c as haveSameIriOrigin, p as parseIri, s as haveSameFe34Origin } from "./url-Du7RQQgP.mjs";
2
- import { deepStrictEqual, ok, strictEqual } from "node:assert";
1
+ import { _ as parseIri } from "./url-DMxmp7ZG.mjs";
2
+ import { a as isTrustedIriOrigin, i as getPortableActorGateways, l as jsonld_default, o as normalizeJsonLdIris, r as getJsonLdContext, t as compactJsonLdCache } from "./jsonld-cache-BPQmOZWD.mjs";
3
3
  import { test } from "node:test";
4
- import jsonld from "jsonld/dist/jsonld.esm.js";
5
- //#region src/jsonld.ts
6
- var jsonld_default = jsonld;
7
- //#endregion
8
- //#region src/internal/jsonld-cache.ts
9
- const noJsonLdContext = Symbol("noJsonLdContext");
10
- /**
11
- * Checks whether an IRI is trusted relative to another IRI.
12
- *
13
- * @internal Technically exported for generated vocabulary classes, but not
14
- * part of the public API contract. This is not considered public API for
15
- * Semantic Versioning decisions.
16
- */
17
- function isTrustedIriOrigin(options, left, right) {
18
- return options.crossOrigin === "trust" || left == null || right != null && (haveSameIriOrigin(left, right) || haveSameFe34Origin(left, right));
19
- }
20
- /**
21
- * Normalizes portable IRIs in JSON-LD cache data.
22
- *
23
- * @internal Technically exported for generated vocabulary classes, but not
24
- * part of the public API contract. This is not considered public API for
25
- * Semantic Versioning decisions.
26
- */
27
- function normalizeJsonLdIris(value, iriKeys, iriPattern = /^ap(?:\+ef61)?:\/\//i) {
28
- return normalize(value, void 0, 0, void 0);
29
- function isIriPosition(key, parentKey) {
30
- return iriKeys.has(key) || (key === "@value" || key === "@list" || key === "@set") && parentKey != null && iriKeys.has(parentKey);
31
- }
32
- function arrayItemParentKey(key, parentKey) {
33
- return key === "@list" || key === "@set" ? parentKey : key;
34
- }
35
- function entryParentKey(entryKey, key, parentKey) {
36
- if (entryKey === "@list" || entryKey === "@set") return parentKey ?? key;
37
- return key === "@list" || key === "@set" ? parentKey : key;
38
- }
39
- function normalize(value, key, depth = 0, parentKey) {
40
- if (depth > 32 || key === "@context") return value;
41
- if (typeof value === "string") {
42
- if (key != null && isIriPosition(key, parentKey) && iriPattern.test(value)) try {
43
- return formatIri(value);
44
- } catch {
45
- return value;
46
- }
47
- return value;
48
- }
49
- if (Array.isArray(value)) {
50
- let clone;
51
- const itemParentKey = arrayItemParentKey(key, parentKey);
52
- for (let i = 0; i < value.length; i++) {
53
- const result = normalize(value[i], key, depth + 1, itemParentKey);
54
- if (result !== value[i]) {
55
- clone ??= value.slice(0, i);
56
- clone.push(result);
57
- } else if (clone != null) clone.push(value[i]);
58
- }
59
- return clone ?? value;
60
- }
61
- if (value == null || typeof value !== "object") return value;
62
- const object = value;
63
- let clone;
64
- for (const entryKey of globalThis.Object.keys(object)) {
65
- const result = normalize(object[entryKey], entryKey, depth + 1, entryParentKey(entryKey, key, parentKey));
66
- if (result !== object[entryKey]) {
67
- clone ??= { ...object };
68
- defineJsonLdProperty(clone, entryKey, result);
69
- }
70
- }
71
- return clone ?? object;
72
- }
73
- }
74
- /**
75
- * Finds the first JSON-LD context in a value.
76
- *
77
- * @internal Technically exported for generated vocabulary classes, but not
78
- * part of the public API contract. This is not considered public API for
79
- * Semantic Versioning decisions.
80
- */
81
- function getJsonLdContext(value, depth = 0) {
82
- if (depth > 32) return void 0;
83
- if (Array.isArray(value)) {
84
- for (const item of value) {
85
- const context = getJsonLdContext(item, depth + 1);
86
- if (context !== void 0) return context;
87
- }
88
- return;
89
- }
90
- if (value == null || typeof value !== "object" || !("@context" in value)) return;
91
- return value["@context"];
92
- }
93
- function getOwnJsonLdContext(value) {
94
- if (value == null || typeof value !== "object" || Array.isArray(value) || !("@context" in value)) return noJsonLdContext;
95
- return value["@context"];
96
- }
97
- /**
98
- * Recompacts normalized JSON-LD cache data against the original context.
99
- *
100
- * @internal Technically exported for generated vocabulary classes, but not
101
- * part of the public API contract. This is not considered public API for
102
- * Semantic Versioning decisions.
103
- */
104
- async function compactJsonLdCache(normalized, original, documentLoader, depth = 0, inheritedContext) {
105
- if (depth > 32) return normalized;
106
- if (Array.isArray(original)) {
107
- const normalizedArray = Array.isArray(normalized) ? normalized : normalized != null && typeof normalized === "object" && "@graph" in normalized && Array.isArray(normalized["@graph"]) ? normalized["@graph"] : void 0;
108
- if (normalizedArray == null) return normalized;
109
- let clone;
110
- for (let i = 0; i < normalizedArray.length; i++) {
111
- const item = await compactJsonLdCache(normalizedArray[i], original[i], documentLoader, depth + 1, inheritedContext);
112
- if (item !== normalizedArray[i]) {
113
- clone ??= normalizedArray.slice(0, i);
114
- clone.push(item);
115
- } else if (clone != null) clone.push(normalizedArray[i]);
116
- }
117
- return clone ?? (Array.isArray(normalized) ? normalized : normalizedArray);
118
- }
119
- const ownContext = getOwnJsonLdContext(original);
120
- const context = ownContext === noJsonLdContext ? inheritedContext : ownContext;
121
- if (context == null) return preserveNoContextJsonLdShape(normalized, original, depth);
122
- return await preserveJsonLdShape(await mergeUnmappedTerms(await jsonld_default.compact(Array.isArray(normalized) && normalized.length === 1 ? normalized[0] : normalized, context, { documentLoader }), original, context, documentLoader), original, context, documentLoader, depth);
123
- }
124
- function preserveNoContextJsonLdShape(normalized, original, depth = 0) {
125
- if (depth > 32) return normalized;
126
- if (original == null || typeof original !== "object" || Array.isArray(original)) return normalized;
127
- const normalizedObject = Array.isArray(normalized) && normalized.length === 1 ? normalized[0] : normalized;
128
- if (normalizedObject == null || typeof normalizedObject !== "object" || Array.isArray(normalizedObject)) return normalized;
129
- const source = normalizedObject;
130
- const originalObject = original;
131
- let clone;
132
- for (const key of globalThis.Object.keys(originalObject)) {
133
- if (!globalThis.Object.prototype.hasOwnProperty.call(source, key)) continue;
134
- const value = preserveNoContextValue(source[key], originalObject[key], depth + 1);
135
- if (value !== originalObject[key]) {
136
- clone ??= { ...originalObject };
137
- defineJsonLdProperty(clone, key, value);
138
- }
139
- }
140
- return clone ?? original;
141
- }
142
- function preserveNoContextValue(normalized, original, depth) {
143
- if (depth > 32) return normalized;
144
- if (Array.isArray(original)) {
145
- const normalizedArray = Array.isArray(normalized) ? normalized : [normalized];
146
- let clone;
147
- for (let i = 0; i < original.length; i++) {
148
- const value = preserveNoContextValue(normalizedArray[i], original[i], depth + 1);
149
- if (value !== original[i]) {
150
- clone ??= original.slice(0, i);
151
- clone.push(value);
152
- } else if (clone != null) clone.push(original[i]);
153
- }
154
- return clone ?? original;
155
- }
156
- const normalizedValue = Array.isArray(normalized) ? normalized[0] : normalized;
157
- if (normalizedValue == null || typeof normalizedValue !== "object" || Array.isArray(normalizedValue)) return normalizedValue;
158
- const normalizedObject = normalizedValue;
159
- if (original != null && typeof original === "object" && !Array.isArray(original)) return preserveNoContextJsonLdShape(normalizedObject, original, depth + 1);
160
- if (typeof normalizedObject["@id"] === "string") return normalizedObject["@id"];
161
- if ("@value" in normalizedObject) return normalizedObject["@value"];
162
- return normalizedValue;
163
- }
164
- function getTopLevelTerms(value) {
165
- const terms = /* @__PURE__ */ new Set();
166
- const nodes = Array.isArray(value) ? value : [value];
167
- for (const node of nodes) {
168
- if (node == null || typeof node !== "object" || Array.isArray(node)) continue;
169
- for (const key of globalThis.Object.keys(node)) {
170
- if (key.startsWith("@")) continue;
171
- terms.add(key);
172
- }
173
- }
174
- return terms;
175
- }
176
- async function mergeUnmappedTerms(compacted, original, context, documentLoader) {
177
- if (original == null || typeof original !== "object" || Array.isArray(original) || compacted == null || typeof compacted !== "object" || Array.isArray(compacted)) return compacted;
178
- const unmappedKeys = globalThis.Object.keys(original).filter((key) => key !== "@context" && !globalThis.Object.prototype.hasOwnProperty.call(compacted, key));
179
- if (unmappedKeys.length < 1) return compacted;
180
- const result = { ...compacted };
181
- const compactedWithContext = compacted != null && typeof compacted === "object" && !Array.isArray(compacted) && !("@context" in compacted) ? {
182
- "@context": context,
183
- ...compacted
184
- } : compacted;
185
- const compactedTerms = getTopLevelTerms(await jsonld_default.expand(compactedWithContext, { documentLoader }));
186
- const dummyPrefix = "urn:fedify:dummy:";
187
- const dummy = { "@context": context };
188
- for (let i = 0; i < unmappedKeys.length; i++) defineJsonLdProperty(dummy, unmappedKeys[i], `${dummyPrefix}${i}`);
189
- const expanded = await jsonld_default.expand(dummy, { documentLoader });
190
- const representedKeys = /* @__PURE__ */ new Set();
191
- const nodes = Array.isArray(expanded) ? expanded : [expanded];
192
- for (const node of nodes) {
193
- if (node == null || typeof node !== "object" || Array.isArray(node)) continue;
194
- for (const [term, termValue] of globalThis.Object.entries(node)) {
195
- if (!compactedTerms.has(term)) continue;
196
- for (let i = 0; i < unmappedKeys.length; i++) if (containsValue(termValue, `${dummyPrefix}${i}`)) representedKeys.add(unmappedKeys[i]);
197
- }
198
- }
199
- for (const key of unmappedKeys) if (!representedKeys.has(key)) defineJsonLdProperty(result, key, original[key]);
200
- return result;
201
- }
202
- function defineJsonLdProperty(object, key, value) {
203
- globalThis.Object.defineProperty(object, key, {
204
- value,
205
- enumerable: true,
206
- configurable: true,
207
- writable: true
208
- });
209
- }
210
- function containsValue(value, expected, depth = 0) {
211
- if (depth > 32) return false;
212
- if (value === expected) return true;
213
- if (Array.isArray(value)) return value.some((item) => containsValue(item, expected, depth + 1));
214
- if (value == null || typeof value !== "object") return false;
215
- return globalThis.Object.entries(value).some(([key, item]) => key !== "@context" && containsValue(item, expected, depth + 1));
216
- }
217
- async function preserveJsonLdShape(compacted, original, context, documentLoader, depth = 0) {
218
- if (depth > 32) return compacted;
219
- if (compacted === original) return compacted;
220
- if (original == null || typeof original !== "object" || compacted == null || typeof compacted !== "object") return compacted;
221
- if (Array.isArray(original)) {
222
- const compactedArray = Array.isArray(compacted) ? compacted : "@graph" in compacted && Array.isArray(compacted["@graph"]) ? compacted["@graph"] : void 0;
223
- if (compactedArray == null) return compacted;
224
- let clone;
225
- for (let i = 0; i < compactedArray.length; i++) {
226
- const value = await preserveJsonLdShape(compactedArray[i], original[i], context, documentLoader, depth + 1);
227
- const originalContext = original[i] != null && typeof original[i] === "object" && !Array.isArray(original[i]) && "@context" in original[i] ? original[i]["@context"] : void 0;
228
- const shaped = originalContext !== void 0 && value != null && typeof value === "object" && !Array.isArray(value) && !("@context" in value) ? {
229
- "@context": originalContext,
230
- ...value
231
- } : value;
232
- if (shaped !== compactedArray[i]) {
233
- clone ??= compactedArray.slice(0, i);
234
- clone.push(shaped);
235
- } else if (clone != null) clone.push(compactedArray[i]);
236
- }
237
- return clone ?? (Array.isArray(compacted) ? compacted : compactedArray);
4
+ import { deepStrictEqual, ok, strictEqual } from "node:assert";
5
+ //#region src/jsonld-cache.test.ts
6
+ test("getPortableActorGateways() preserves unmapped portable actor gateways", () => {
7
+ const gateways = [
8
+ { "@value": "https://second.example" },
9
+ { "@value": "https://first.example" },
10
+ { "@value": "not a valid gateway" }
11
+ ];
12
+ for (const id of [
13
+ "ap://did:key:z6Mkabc/actor",
14
+ "ap+ef61://did:key:z6Mkabc/actor",
15
+ "https://gateway.example/.well-known/apgateway/did:key:z6Mkabc/actor"
16
+ ]) {
17
+ const node = {
18
+ "@id": id,
19
+ "http://www.w3.org/ns/ldp#inbox": [{ "@id": `${id}/inbox` }],
20
+ "https://www.w3.org/ns/activitystreams#outbox": [{ "@id": `${id}/outbox` }],
21
+ "_:gateways": gateways
22
+ };
23
+ const original = structuredClone(node);
24
+ strictEqual(getPortableActorGateways(node), gateways, id);
25
+ strictEqual(getPortableActorGateways(node, false), void 0, id);
26
+ deepStrictEqual(node, original);
238
27
  }
239
- if (Array.isArray(compacted)) return compacted;
240
- let clone;
241
- const ownContext = getOwnJsonLdContext(original);
242
- const objectContext = combineContexts(context, ownContext);
243
- const objectCompacted = depth > 0 && ownContext === null ? await compactWithEmptyContext(compacted, context, documentLoader) : compacted;
244
- const compactedObject = depth > 0 ? await mergeUnmappedTerms(objectCompacted, original, objectContext, documentLoader) : objectCompacted;
245
- const originalObject = original;
246
- for (const key of globalThis.Object.keys(compactedObject)) {
247
- if (key === "@context") continue;
248
- const value = await preserveJsonLdShape(compactedObject[key], originalObject[key], objectContext, documentLoader, depth + 1);
249
- const shaped = Array.isArray(originalObject[key]) && !Array.isArray(value) ? [value] : value;
250
- if (shaped !== compactedObject[key]) {
251
- clone ??= { ...compactedObject };
252
- defineJsonLdProperty(clone, key, shaped);
253
- }
28
+ });
29
+ test("getPortableActorGateways() gives mapped gateways precedence", () => {
30
+ const canonical = "https://w3id.org/fep/ef61/gateways";
31
+ const gateways = [{ "@list": [{ "@id": "https://gateway.example" }] }];
32
+ const node = {
33
+ "@id": "ap://did:key:z6Mkabc/actor",
34
+ "http://www.w3.org/ns/ldp#inbox": [],
35
+ "https://www.w3.org/ns/activitystreams#outbox": [],
36
+ "_:gateways": [{ "@value": "https://other.example" }],
37
+ [canonical]: gateways
38
+ };
39
+ strictEqual(getPortableActorGateways(node), gateways);
40
+ strictEqual(getPortableActorGateways(node, false), gateways);
41
+ for (const value of [
42
+ void 0,
43
+ null,
44
+ {},
45
+ "https://gateway.example",
46
+ []
47
+ ]) {
48
+ node[canonical] = value;
49
+ strictEqual(getPortableActorGateways(node), Array.isArray(value) ? value : void 0);
254
50
  }
255
- if (depth > 0) {
256
- if ("@context" in originalObject && !("@context" in compactedObject)) {
257
- clone ??= { ...compactedObject };
258
- clone["@context"] = originalObject["@context"];
259
- }
51
+ });
52
+ test("getPortableActorGateways() limits unmapped terms to portable actors", () => {
53
+ const node = {
54
+ "@id": "ap://did:key:z6Mkabc/actor",
55
+ "http://www.w3.org/ns/ldp#inbox": [],
56
+ "https://www.w3.org/ns/activitystreams#outbox": [],
57
+ "_:gateways": [{ "@value": "https://gateway.example" }]
58
+ };
59
+ for (const id of [
60
+ void 0,
61
+ 1,
62
+ "not an IRI",
63
+ "https://ordinary.example/actor",
64
+ "https://gateway.example/.well-known/apgateway/not-a-did/actor",
65
+ "https://user@gateway.example/.well-known/apgateway/did:key:z6Mkabc/actor"
66
+ ]) strictEqual(getPortableActorGateways({
67
+ ...node,
68
+ "@id": id
69
+ }), void 0);
70
+ for (const property of ["http://www.w3.org/ns/ldp#inbox", "https://www.w3.org/ns/activitystreams#outbox"]) {
71
+ const nonActor = { ...node };
72
+ delete nonActor[property];
73
+ strictEqual(getPortableActorGateways(nonActor), void 0);
260
74
  }
261
- return clone ?? compactedObject;
262
- }
263
- async function compactWithEmptyContext(compacted, context, documentLoader) {
264
- const compactedWithContext = compacted != null && typeof compacted === "object" && !Array.isArray(compacted) && !("@context" in compacted) ? {
265
- "@context": context,
266
- ...compacted
267
- } : compacted;
268
- const expanded = await jsonld_default.expand(compactedWithContext, { documentLoader });
269
- return await jsonld_default.compact(expanded, {}, { documentLoader });
270
- }
271
- function combineContexts(inheritedContext, ownContext) {
272
- if (ownContext === noJsonLdContext || ownContext === inheritedContext) return inheritedContext;
273
- if (ownContext == null) return ownContext;
274
- const inherited = Array.isArray(inheritedContext) ? inheritedContext : [inheritedContext];
275
- const own = Array.isArray(ownContext) ? ownContext : [ownContext];
276
- return [...inherited, ...own];
277
- }
278
- //#endregion
279
- //#region src/jsonld-cache.test.ts
75
+ strictEqual(getPortableActorGateways({
76
+ ...node,
77
+ "_:gateways": null
78
+ }), void 0);
79
+ const empty = [];
80
+ strictEqual(getPortableActorGateways({
81
+ ...node,
82
+ "_:gateways": empty
83
+ }), empty);
84
+ });
280
85
  test("isTrustedIriOrigin() trusts same portable IRI origins", () => {
281
86
  ok(isTrustedIriOrigin({}, parseIri("ap://did:key:z6Mkabc/actor"), parseIri("ap+ef61://did:key:z6Mkabc/outbox")));
282
87
  ok(!isTrustedIriOrigin({}, parseIri("ap://did:key:z6Mkabc/actor"), parseIri("ap://did:key:z6Mkdef/outbox")));
@@ -287,17 +92,17 @@ test("normalizeJsonLdIris() normalizes selected JSON-LD IRI positions", () => {
287
92
  "@id": "ap://did:key:z6Mkabc/object",
288
93
  "https://example.com/ns#ref": [{ "@value": "ap://did:key:z6Mkabc/ref" }],
289
94
  "https://example.com/ns#text": [{ "@value": "ap://did:key:z6Mkabc/not-an-iri-position" }]
290
- }, new Set(["@id", "https://example.com/ns#ref"])), {
95
+ }, /* @__PURE__ */ new Set(["@id", "https://example.com/ns#ref"])), {
291
96
  "@id": "ap+ef61://did:key:z6Mkabc/object",
292
97
  "https://example.com/ns#ref": [{ "@value": "ap+ef61://did:key:z6Mkabc/ref" }],
293
98
  "https://example.com/ns#text": [{ "@value": "ap://did:key:z6Mkabc/not-an-iri-position" }]
294
99
  });
295
100
  });
296
101
  test("normalizeJsonLdIris() preserves IRI context in list/set wrappers", () => {
297
- deepStrictEqual(normalizeJsonLdIris({ "https://example.com/ns#ref": [{ "@list": [{ "@value": "ap://did:key:z6Mkabc/listed" }] }, { "@set": [{ "@value": "ap://did:key:z6Mkabc/set" }] }] }, new Set(["https://example.com/ns#ref"])), { "https://example.com/ns#ref": [{ "@list": [{ "@value": "ap+ef61://did:key:z6Mkabc/listed" }] }, { "@set": [{ "@value": "ap+ef61://did:key:z6Mkabc/set" }] }] });
102
+ deepStrictEqual(normalizeJsonLdIris({ "https://example.com/ns#ref": [{ "@list": [{ "@value": "ap://did:key:z6Mkabc/listed" }] }, { "@set": [{ "@value": "ap://did:key:z6Mkabc/set" }] }] }, /* @__PURE__ */ new Set(["https://example.com/ns#ref"])), { "https://example.com/ns#ref": [{ "@list": [{ "@value": "ap+ef61://did:key:z6Mkabc/listed" }] }, { "@set": [{ "@value": "ap+ef61://did:key:z6Mkabc/set" }] }] });
298
103
  });
299
104
  test("normalizeJsonLdIris() defines prototype-like keys safely", () => {
300
- const iriKeys = new Set(["__proto__"]);
105
+ const iriKeys = /* @__PURE__ */ new Set(["__proto__"]);
301
106
  const value = {};
302
107
  globalThis.Object.defineProperty(value, "__proto__", {
303
108
  value: "ap://did:key:z6Mkabc/object",
@@ -320,7 +125,7 @@ test("compactJsonLdCache() preserves no-context object shape", async () => {
320
125
  "https://www.w3.org/ns/activitystreams#attributedTo": [{ "@id": "ap://did:key:z6Mkabc/actor" }],
321
126
  "https://www.w3.org/ns/activitystreams#content": [{ "@value": "No-context object shape should stay cached." }]
322
127
  };
323
- deepStrictEqual(await compactJsonLdCache(normalizeJsonLdIris(await jsonld_default.expand(original), new Set(["@id", "https://www.w3.org/ns/activitystreams#attributedTo"])), original), {
128
+ deepStrictEqual(await compactJsonLdCache(normalizeJsonLdIris(await jsonld_default.expand(original), /* @__PURE__ */ new Set(["@id", "https://www.w3.org/ns/activitystreams#attributedTo"])), original), {
324
129
  "@id": "ap+ef61://did:key:z6Mkabc/objects/1",
325
130
  "@type": ["https://www.w3.org/ns/activitystreams#Note"],
326
131
  "https://www.w3.org/ns/activitystreams#attributedTo": [{ "@id": "ap+ef61://did:key:z6Mkabc/actor" }],
@@ -341,7 +146,7 @@ test("compactJsonLdCache() ignores nested contexts for no-context parents", asyn
341
146
  name: "Nested object"
342
147
  }]
343
148
  };
344
- deepStrictEqual(await compactJsonLdCache(normalizeJsonLdIris(await jsonld_default.expand(original), new Set(["@id"])), original), {
149
+ deepStrictEqual(await compactJsonLdCache(normalizeJsonLdIris(await jsonld_default.expand(original), /* @__PURE__ */ new Set(["@id"])), original), {
345
150
  "@id": "ap+ef61://did:key:z6Mkabc/objects/1",
346
151
  "@type": ["https://www.w3.org/ns/activitystreams#Note"],
347
152
  "https://www.w3.org/ns/activitystreams#attachment": [{
@@ -388,7 +193,7 @@ test("compactJsonLdCache() preserves nested unmapped terms", async () => {
388
193
  extra: "This nested unmapped property should stay cached."
389
194
  }
390
195
  };
391
- deepStrictEqual(await compactJsonLdCache(normalizeJsonLdIris(await jsonld_default.expand(original), new Set(["@id"])), original), {
196
+ deepStrictEqual(await compactJsonLdCache(normalizeJsonLdIris(await jsonld_default.expand(original), /* @__PURE__ */ new Set(["@id"])), original), {
392
197
  "@context": context,
393
198
  type: "as:Note",
394
199
  id: "ap+ef61://did:key:z6Mkabc/objects/1",
@@ -420,7 +225,7 @@ test("compactJsonLdCache() reuses unchanged unmapped values", async () => {
420
225
  extra
421
226
  }
422
227
  };
423
- const compacted = await compactJsonLdCache(normalizeJsonLdIris(await jsonld_default.expand(original), new Set(["@id"])), original);
228
+ const compacted = await compactJsonLdCache(normalizeJsonLdIris(await jsonld_default.expand(original), /* @__PURE__ */ new Set(["@id"])), original);
424
229
  strictEqual(compacted.rootExtra, rootExtra);
425
230
  strictEqual(compacted.attachment.extra, extra);
426
231
  });
@@ -441,7 +246,7 @@ test("compactJsonLdCache() defines prototype-like unmapped keys safely", async (
441
246
  configurable: true,
442
247
  writable: true
443
248
  });
444
- const compacted = await compactJsonLdCache(normalizeJsonLdIris(await jsonld_default.expand(original), new Set(["@id"])), original);
249
+ const compacted = await compactJsonLdCache(normalizeJsonLdIris(await jsonld_default.expand(original), /* @__PURE__ */ new Set(["@id"])), original);
445
250
  strictEqual(globalThis.Object.getOwnPropertyDescriptor(compacted, "__proto__")?.value, protoValue);
446
251
  strictEqual(globalThis.Object.getPrototypeOf(compacted), Object.prototype);
447
252
  });
@@ -468,7 +273,7 @@ test("compactJsonLdCache() checks prototype-like aliases safely", async () => {
468
273
  configurable: true,
469
274
  writable: true
470
275
  });
471
- const compacted = await compactJsonLdCache(normalizeJsonLdIris(await jsonld_default.expand(original), new Set(["@id"])), original);
276
+ const compacted = await compactJsonLdCache(normalizeJsonLdIris(await jsonld_default.expand(original), /* @__PURE__ */ new Set(["@id"])), original);
472
277
  const protoDescriptor = globalThis.Object.getOwnPropertyDescriptor(compacted, "__proto__");
473
278
  ok(protoDescriptor?.value === "Alias represented by the compacted term." || Array.isArray(protoDescriptor?.value) && protoDescriptor.value.includes("Alias represented by the compacted term."));
474
279
  strictEqual(protoDescriptor?.enumerable, true);
@@ -498,7 +303,7 @@ test("compactJsonLdCache() preserves nested contexts", async () => {
498
303
  title: "Nested title."
499
304
  }
500
305
  };
501
- deepStrictEqual(await compactJsonLdCache(normalizeJsonLdIris(await jsonld_default.expand(original), new Set(["@id"])), original), {
306
+ deepStrictEqual(await compactJsonLdCache(normalizeJsonLdIris(await jsonld_default.expand(original), /* @__PURE__ */ new Set(["@id"])), original), {
502
307
  "@context": context,
503
308
  type: "as:Note",
504
309
  id: "ap+ef61://did:key:z6Mkabc/objects/1",
@@ -530,7 +335,7 @@ test("compactJsonLdCache() preserves nested array contexts", async () => {
530
335
  title: "Nested title."
531
336
  }
532
337
  };
533
- deepStrictEqual(await compactJsonLdCache(normalizeJsonLdIris(await jsonld_default.expand(original), new Set(["@id"])), original), {
338
+ deepStrictEqual(await compactJsonLdCache(normalizeJsonLdIris(await jsonld_default.expand(original), /* @__PURE__ */ new Set(["@id"])), original), {
534
339
  "@context": context,
535
340
  type: "as:Note",
536
341
  id: "ap+ef61://did:key:z6Mkabc/objects/1",
@@ -558,7 +363,7 @@ test("compactJsonLdCache() preserves nested null contexts", async () => {
558
363
  "https://example.com/ns#title": "Absolute title."
559
364
  }
560
365
  };
561
- deepStrictEqual(await compactJsonLdCache(normalizeJsonLdIris(await jsonld_default.expand(original), new Set(["@id"])), original), {
366
+ deepStrictEqual(await compactJsonLdCache(normalizeJsonLdIris(await jsonld_default.expand(original), /* @__PURE__ */ new Set(["@id"])), original), {
562
367
  "@context": context,
563
368
  type: "as:Note",
564
369
  id: "ap+ef61://did:key:z6Mkabc/objects/1",
@@ -597,7 +402,7 @@ test("compactJsonLdCache() does not re-add represented nested aliases", async ()
597
402
  actorRef: "ap://did:key:z6Mkabc/actor"
598
403
  }
599
404
  };
600
- deepStrictEqual(await compactJsonLdCache(normalizeJsonLdIris(await jsonld_default.expand(original), new Set(["@id", "https://www.w3.org/ns/activitystreams#actor"])), original), {
405
+ deepStrictEqual(await compactJsonLdCache(normalizeJsonLdIris(await jsonld_default.expand(original), /* @__PURE__ */ new Set(["@id", "https://www.w3.org/ns/activitystreams#actor"])), original), {
601
406
  "@context": context,
602
407
  type: "as:Note",
603
408
  id: "ap+ef61://did:key:z6Mkabc/objects/1",
@@ -631,7 +436,7 @@ test("compactJsonLdCache() does not confuse dummy marker prefixes", async () =>
631
436
  key9: "Extension 9",
632
437
  key10: "Alias represented by the compacted term."
633
438
  };
634
- deepStrictEqual(await compactJsonLdCache(normalizeJsonLdIris(await jsonld_default.expand(original), new Set(["@id"])), original), {
439
+ deepStrictEqual(await compactJsonLdCache(normalizeJsonLdIris(await jsonld_default.expand(original), /* @__PURE__ */ new Set(["@id"])), original), {
635
440
  "@context": context,
636
441
  id: "ap+ef61://did:key:z6Mkabc/objects/1",
637
442
  key0: "Extension 0",
@@ -1,6 +1,5 @@
1
- require("./chunk-C2EiDwsr.cjs");
2
- const require_multicodec = require("./multicodec-CxGVGa91.cjs");
3
- const require_multibase = require("./multibase-Bz_UUDtL.cjs");
1
+ const require_multicodec = require("./multicodec-CLRPeW4N.cjs");
2
+ const require_multibase = require("./multibase-B5Mea7Ip.cjs");
4
3
  let asn1js = require("asn1js");
5
4
  let byte_encodings_base64 = require("byte-encodings/base64");
6
5
  let byte_encodings_base64url = require("byte-encodings/base64url");
@@ -143,12 +142,20 @@ async function importDidKey(did) {
143
142
  /**
144
143
  * Exports an Ed25519 public key as a `did:key` DID.
145
144
  *
145
+ * The DID is encoded in base58-btc with the Ed25519 multicodec prefix, e.g.,
146
+ * `did:key:z6Mk...`, as [FEP-ef61] requires for the DIDs of portable
147
+ * objects.
148
+ *
149
+ * [FEP-ef61]: https://w3id.org/fep/ef61
150
+ *
146
151
  * @param key The Ed25519 public key.
147
152
  * @returns The `did:key` DID.
148
- * @throws {TypeError} If the key is invalid or unsupported.
153
+ * @throws {TypeError} If the key is invalid or unsupported, or it is not
154
+ * a public key.
149
155
  * @since 2.4.0
150
156
  */
151
157
  async function exportDidKey(key) {
158
+ if (key.type !== "public") throw new TypeError("The key must be a public key.");
152
159
  if (key.algorithm.name !== "Ed25519") throw new TypeError("Unsupported key type: " + JSON.stringify(key.algorithm));
153
160
  return DID_KEY_PREFIX + await exportMultibaseKey(key);
154
161
  }
@@ -1,5 +1,5 @@
1
- import { n as getMulticodecPrefix, r as removeMulticodecPrefix, t as addMulticodecPrefix } from "./multicodec-CyFp54fI.mjs";
2
- import { n as encodeMultibase, t as decodeMultibase } from "./multibase-B4bvakyA.mjs";
1
+ import { n as getMulticodecPrefix, r as removeMulticodecPrefix, t as addMulticodecPrefix } from "./multicodec-CRIj_05H.mjs";
2
+ import { n as encodeMultibase, t as decodeMultibase } from "./multibase-BPnF_L4e.mjs";
3
3
  import { Integer, Sequence } from "asn1js";
4
4
  import { decodeBase64, encodeBase64 } from "byte-encodings/base64";
5
5
  import { decodeBase64Url } from "byte-encodings/base64url";
@@ -142,12 +142,20 @@ async function importDidKey(did) {
142
142
  /**
143
143
  * Exports an Ed25519 public key as a `did:key` DID.
144
144
  *
145
+ * The DID is encoded in base58-btc with the Ed25519 multicodec prefix, e.g.,
146
+ * `did:key:z6Mk...`, as [FEP-ef61] requires for the DIDs of portable
147
+ * objects.
148
+ *
149
+ * [FEP-ef61]: https://w3id.org/fep/ef61
150
+ *
145
151
  * @param key The Ed25519 public key.
146
152
  * @returns The `did:key` DID.
147
- * @throws {TypeError} If the key is invalid or unsupported.
153
+ * @throws {TypeError} If the key is invalid or unsupported, or it is not
154
+ * a public key.
148
155
  * @since 2.4.0
149
156
  */
150
157
  async function exportDidKey(key) {
158
+ if (key.type !== "public") throw new TypeError("The key must be a public key.");
151
159
  if (key.algorithm.name !== "Ed25519") throw new TypeError("Unsupported key type: " + JSON.stringify(key.algorithm));
152
160
  return DID_KEY_PREFIX + await exportMultibaseKey(key);
153
161
  }
@@ -1,9 +1,8 @@
1
- require("./chunk-C2EiDwsr.cjs");
2
- const require_multicodec = require("./multicodec-CxGVGa91.cjs");
3
- const require_key = require("./key-_wXwomh_.cjs");
4
- const require_multibase = require("./multibase-Bz_UUDtL.cjs");
5
- let node_assert = require("node:assert");
1
+ const require_multicodec = require("./multicodec-CLRPeW4N.cjs");
2
+ const require_key = require("./key-C-AYkdJJ.cjs");
3
+ const require_multibase = require("./multibase-B5Mea7Ip.cjs");
6
4
  let node_test = require("node:test");
5
+ let node_assert = require("node:assert");
7
6
  //#region src/key.test.ts
8
7
  const rsaSpki = "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxsRuvCkgJtflBTl4OVsm\nnt/J1mQfZasfJtN33dcZ3d1lJroxmgmMu69zjGEAwkNbMQaWNLqC4eogkJaeJ4RR\n5MHYXkL9nNilVoTkjX5BVit3puzs7XJ7WQnKQgQMI+ezn24GHsZ/v1JIo77lerX5\nk4HNwTNVt+yaZVQWaOMR3+6FwziQR6kd0VuG9/a9dgAnz2cEoORRC1i4W7IZaB1s\nZnh1WbHbevlGd72HSXll5rocPIHn8gq6xpBgpHwRphlRsgn4KHaJ6brXDIJjrnQh\nIe/YUBOGj/ImSEXhRwlFerKsoAVnZ0Hwbfa46qk44TAt8CyoPMWmpK6pt0ng4pQ2\nuwIDAQAB\n-----END PUBLIC KEY-----\n";
9
8
  const rsaPkcs1 = "-----BEGIN RSA PUBLIC KEY-----\nMIIBCgKCAQEAxsRuvCkgJtflBTl4OVsmnt/J1mQfZasfJtN33dcZ3d1lJroxmgmM\nu69zjGEAwkNbMQaWNLqC4eogkJaeJ4RR5MHYXkL9nNilVoTkjX5BVit3puzs7XJ7\nWQnKQgQMI+ezn24GHsZ/v1JIo77lerX5k4HNwTNVt+yaZVQWaOMR3+6FwziQR6kd\n0VuG9/a9dgAnz2cEoORRC1i4W7IZaB1sZnh1WbHbevlGd72HSXll5rocPIHn8gq6\nxpBgpHwRphlRsgn4KHaJ6brXDIJjrnQhIe/YUBOGj/ImSEXhRwlFerKsoAVnZ0Hw\nbfa46qk44TAt8CyoPMWmpK6pt0ng4pQ2uwIDAQAB\n-----END RSA PUBLIC KEY-----\n";
@@ -79,6 +78,8 @@ const ed25519Multibase = "z6MksHj1MJnidCtDiyYW9ugNFftoX9fLK4bornTxmMZ6X7vq";
79
78
  (0, node_assert.deepStrictEqual)(await require_key.exportJwk(await require_key.importDidKey(new URL(did))), ed25519Jwk);
80
79
  const rsaKey = await require_key.importJwk(rsaJwk, "public");
81
80
  await (0, node_assert.rejects)(() => require_key.exportDidKey(rsaKey), TypeError);
81
+ const { privateKey } = await crypto.subtle.generateKey("Ed25519", true, ["sign", "verify"]);
82
+ await (0, node_assert.rejects)(() => require_key.exportDidKey(privateKey), /* @__PURE__ */ new TypeError("The key must be a public key."));
82
83
  await (0, node_assert.rejects)(() => require_key.importDidKey(`did:key:${rsaMultibase}`), /* @__PURE__ */ new TypeError("Unsupported did:key type: 0x1205"));
83
84
  });
84
85
  (0, node_test.test)("parseDidKeyVerificationMethod()", async () => {
@@ -1,8 +1,8 @@
1
- import { t as addMulticodecPrefix } from "./multicodec-CyFp54fI.mjs";
2
- import { a as importMultibaseKey, c as importSpki, d as importJwk, i as importDidKey, l as parseDidKeyVerificationMethod, n as exportMultibaseKey, o as importPem, r as exportSpki, s as importPkcs1, t as exportDidKey, u as exportJwk } from "./key-CDGDH_vC.mjs";
3
- import { n as encodeMultibase } from "./multibase-B4bvakyA.mjs";
4
- import { deepStrictEqual, rejects } from "node:assert";
1
+ import { t as addMulticodecPrefix } from "./multicodec-CRIj_05H.mjs";
2
+ import { a as importMultibaseKey, c as importSpki, d as importJwk, i as importDidKey, l as parseDidKeyVerificationMethod, n as exportMultibaseKey, o as importPem, r as exportSpki, s as importPkcs1, t as exportDidKey, u as exportJwk } from "./key-C2Db_TAJ.mjs";
3
+ import { n as encodeMultibase } from "./multibase-BPnF_L4e.mjs";
5
4
  import { test } from "node:test";
5
+ import { deepStrictEqual, rejects } from "node:assert";
6
6
  //#region src/key.test.ts
7
7
  const rsaSpki = "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxsRuvCkgJtflBTl4OVsm\nnt/J1mQfZasfJtN33dcZ3d1lJroxmgmMu69zjGEAwkNbMQaWNLqC4eogkJaeJ4RR\n5MHYXkL9nNilVoTkjX5BVit3puzs7XJ7WQnKQgQMI+ezn24GHsZ/v1JIo77lerX5\nk4HNwTNVt+yaZVQWaOMR3+6FwziQR6kd0VuG9/a9dgAnz2cEoORRC1i4W7IZaB1s\nZnh1WbHbevlGd72HSXll5rocPIHn8gq6xpBgpHwRphlRsgn4KHaJ6brXDIJjrnQh\nIe/YUBOGj/ImSEXhRwlFerKsoAVnZ0Hwbfa46qk44TAt8CyoPMWmpK6pt0ng4pQ2\nuwIDAQAB\n-----END PUBLIC KEY-----\n";
8
8
  const rsaPkcs1 = "-----BEGIN RSA PUBLIC KEY-----\nMIIBCgKCAQEAxsRuvCkgJtflBTl4OVsmnt/J1mQfZasfJtN33dcZ3d1lJroxmgmM\nu69zjGEAwkNbMQaWNLqC4eogkJaeJ4RR5MHYXkL9nNilVoTkjX5BVit3puzs7XJ7\nWQnKQgQMI+ezn24GHsZ/v1JIo77lerX5k4HNwTNVt+yaZVQWaOMR3+6FwziQR6kd\n0VuG9/a9dgAnz2cEoORRC1i4W7IZaB1sZnh1WbHbevlGd72HSXll5rocPIHn8gq6\nxpBgpHwRphlRsgn4KHaJ6brXDIJjrnQhIe/YUBOGj/ImSEXhRwlFerKsoAVnZ0Hw\nbfa46qk44TAt8CyoPMWmpK6pt0ng4pQ2uwIDAQAB\n-----END RSA PUBLIC KEY-----\n";
@@ -78,6 +78,8 @@ test("exportDidKey() and importDidKey()", async () => {
78
78
  deepStrictEqual(await exportJwk(await importDidKey(new URL(did))), ed25519Jwk);
79
79
  const rsaKey = await importJwk(rsaJwk, "public");
80
80
  await rejects(() => exportDidKey(rsaKey), TypeError);
81
+ const { privateKey } = await crypto.subtle.generateKey("Ed25519", true, ["sign", "verify"]);
82
+ await rejects(() => exportDidKey(privateKey), /* @__PURE__ */ new TypeError("The key must be a public key."));
81
83
  await rejects(() => importDidKey(`did:key:${rsaMultibase}`), /* @__PURE__ */ new TypeError("Unsupported did:key type: 0x1205"));
82
84
  });
83
85
  test("parseDidKeyVerificationMethod()", async () => {
@@ -1,9 +1,9 @@
1
- const require_chunk = require("./chunk-C2EiDwsr.cjs");
2
- const require_langstr = require("./langstr-CbAxaeEZ.cjs");
3
- let node_assert = require("node:assert");
1
+ const require_rolldown_runtime = require("./rolldown-runtime-emK7D4bc.cjs");
2
+ const require_langstr = require("./langstr-C4Fl80ae.cjs");
4
3
  let node_test = require("node:test");
4
+ let node_assert = require("node:assert");
5
5
  let node_util = require("node:util");
6
- node_util = require_chunk.__toESM(node_util, 1);
6
+ node_util = require_rolldown_runtime.__toESM(node_util, 1);
7
7
  //#region src/langstr.test.ts
8
8
  (0, node_test.test)("new LanguageString()", () => {
9
9
  const langStr = new require_langstr.LanguageString("Hello", "en");
@@ -1,6 +1,6 @@
1
- import { t as LanguageString } from "./langstr-Di5AvKpB.mjs";
2
- import { deepStrictEqual } from "node:assert";
1
+ import { t as LanguageString } from "./langstr-CQ26J_L7.mjs";
3
2
  import { test } from "node:test";
3
+ import { deepStrictEqual } from "node:assert";
4
4
  import util from "node:util";
5
5
  //#region src/langstr.test.ts
6
6
  test("new LanguageString()", () => {
@@ -1,7 +1,6 @@
1
- require("./chunk-C2EiDwsr.cjs");
2
- const require_link = require("./link-FguCydMA.cjs");
3
- let node_assert = require("node:assert");
1
+ const require_link = require("./link-DlKm8bEr.cjs");
4
2
  let node_test = require("node:test");
3
+ let node_assert = require("node:assert");
5
4
  //#region src/link.test.ts
6
5
  (0, node_test.test)("String Good 1", () => {
7
6
  const instance = new require_link.HttpHeaderLink(`<https://example.com>; rel="preconnect"`);
@@ -1,6 +1,6 @@
1
- import { t as HttpHeaderLink } from "./link-NUUWCdnK.mjs";
2
- import { deepStrictEqual, throws } from "node:assert";
1
+ import { t as HttpHeaderLink } from "./link-Cevmc87v.mjs";
3
2
  import { test } from "node:test";
3
+ import { deepStrictEqual, throws } from "node:assert";
4
4
  //#region src/link.test.ts
5
5
  test("String Good 1", () => {
6
6
  const instance = new HttpHeaderLink(`<https://example.com>; rel="preconnect"`);