@fedify/fedify 1.9.10 → 1.9.12-dev.2265
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/dist/{actor-BCmFER1x.js → actor-BJj7NAV7.js} +187 -187
- package/dist/{actor-CGzgm5oD.cjs → actor-BxUB2vBw.cjs} +187 -187
- package/dist/{actor-Dk8QQxfb.mjs → actor-DKEb3nb2.mjs} +1 -1
- package/dist/{authdocloader-C0oFDv-u.cjs → authdocloader-BkG-kREl.cjs} +3 -3
- package/dist/{authdocloader-BlqYxYyU.mjs → authdocloader-DVWlfdZ9.mjs} +3 -3
- package/dist/{authdocloader-C4Km7IX-.js → authdocloader-_m5yqwLt.js} +3 -3
- package/dist/{builder-Dy69enN4.mjs → builder-Dhm6irl1.mjs} +4 -4
- package/dist/{client-BVxHrCKU.mjs → client-CIvLnEyN.mjs} +1 -1
- package/dist/compat/mod.cjs +1 -1
- package/dist/compat/mod.d.cts +1 -1
- package/dist/compat/mod.d.ts +1 -1
- package/dist/compat/transformers.test.mjs +3 -3
- package/dist/{context-Cf8s07xm.d.ts → context-CNkTuNIm.d.ts} +48 -6
- package/dist/{context-Crmwowsw.d.cts → context-jX79cwCB.d.cts} +48 -6
- package/dist/{docloader-CJRlqHTE.js → docloader-CFM5B9fd.js} +121 -13
- package/dist/{docloader-L_Yv0SO1.cjs → docloader-ojCZeNsS.cjs} +121 -13
- package/dist/{esm-Bl5QZ7fr.mjs → esm-DpYRgHio.mjs} +1 -1
- package/dist/federation/builder.test.mjs +3 -3
- package/dist/federation/collection.test.mjs +1 -1
- package/dist/federation/handler.test.mjs +1361 -45
- package/dist/federation/idempotency.test.mjs +5 -5
- package/dist/federation/inbox.test.mjs +3 -3
- package/dist/federation/keycache.test.mjs +3 -3
- package/dist/federation/kv.test.mjs +1 -1
- package/dist/federation/middleware.test.mjs +1586 -82
- package/dist/federation/mod.cjs +2 -2
- package/dist/federation/mod.d.cts +1 -1
- package/dist/federation/mod.d.ts +1 -1
- package/dist/federation/mod.js +1 -1
- package/dist/federation/mq.test.mjs +3 -3
- package/dist/federation/retry.test.mjs +2 -2
- package/dist/federation/router.test.mjs +2 -2
- package/dist/federation/send.test.mjs +7 -7
- package/dist/federation/temporal.test.d.mts +2 -0
- package/dist/federation/temporal.test.mjs +71 -0
- package/dist/{http-ChxLPxfJ.cjs → http-B7su-Fmy.cjs} +3 -3
- package/dist/{http-lEtFJ9QZ.mjs → http-ChKbuD-B.mjs} +2 -2
- package/dist/{http-CEocuLno.js → http-DdMd8CPw.js} +3 -3
- package/dist/{inbox-f2JhwcoC.mjs → inbox-Du7n_Tcq.mjs} +7 -4
- package/dist/{key-DL1K1oFv.cjs → key-AD7NWK_B.cjs} +2 -2
- package/dist/{key-CcFvjYSE.mjs → key-Bd3kgBIA.mjs} +2 -2
- package/dist/{key-GSxkNZYW.cjs → key-COEspOg4.cjs} +1 -1
- package/dist/{key-DXRa1vj8.mjs → key-DINKM8mV.mjs} +1 -1
- package/dist/{key-CfQiiCFY.js → key-DvsZ4r4J.js} +2 -2
- package/dist/{keycache-Car3vCR8.mjs → keycache-DYpvtScH.mjs} +1 -1
- package/dist/{keys-BPA70FRA.mjs → keys-CJPe6iTW.mjs} +1 -1
- package/dist/ld-C51F-FdC.mjs +548 -0
- package/dist/{lookup-BZCRNz7r.cjs → lookup-DrAw0WK4.cjs} +1 -1
- package/dist/{lookup-MjsiCtwV.js → lookup-avek91qK.js} +1 -1
- package/dist/{lookup-ByZEGrUD.mjs → lookup-jTLErl5g.mjs} +1 -1
- package/dist/{middleware-D23J06Wi.js → middleware-B_5QXY9T.js} +401 -76
- package/dist/{middleware-DwelHV2a.cjs → middleware-BxPRXIp2.cjs} +404 -78
- package/dist/{middleware-DzVgR5WN.cjs → middleware-CoZn3Vmd.cjs} +1 -1
- package/dist/{middleware-DT1q8p2_.mjs → middleware-ScXtn6SX.mjs} +313 -80
- package/dist/{middleware-DQF9aAWg.mjs → middleware-ySLVbIpY.mjs} +1 -1
- package/dist/mod.cjs +10 -10
- package/dist/mod.d.cts +1 -1
- package/dist/mod.d.ts +1 -1
- package/dist/mod.js +9 -9
- package/dist/nodeinfo/client.test.mjs +3 -3
- package/dist/nodeinfo/handler.test.mjs +2 -2
- package/dist/nodeinfo/mod.cjs +1 -1
- package/dist/nodeinfo/mod.js +1 -1
- package/dist/nodeinfo/semver.test.mjs +1 -1
- package/dist/nodeinfo/types.test.mjs +1 -1
- package/dist/{owner-2Hw80SWJ.mjs → owner-Ul_H1ZhA.mjs} +3 -3
- package/dist/{proof-B6709oyL.mjs → proof-CGXr6kyw.mjs} +2 -2
- package/dist/{proof-DoJnUD_A.js → proof-CO1rdWN1.js} +300 -6
- package/dist/{proof-DOwB_RsW.cjs → proof-CpHpOx4z.cjs} +347 -5
- package/dist/runtime/authdocloader.test.mjs +6 -6
- package/dist/runtime/docloader.test.mjs +3 -3
- package/dist/runtime/key.test.mjs +3 -3
- package/dist/runtime/langstr.test.mjs +2 -2
- package/dist/runtime/link.test.mjs +2 -2
- package/dist/runtime/mod.cjs +3 -3
- package/dist/runtime/mod.js +3 -3
- package/dist/runtime/multibase/multibase.test.mjs +2 -2
- package/dist/runtime/url.test.mjs +53 -2
- package/dist/{send-CaI0XRhr.mjs → send-BktZN-8x.mjs} +2 -2
- package/dist/sig/http.test.mjs +6 -6
- package/dist/sig/key.test.mjs +4 -4
- package/dist/sig/ld.test.mjs +561 -5
- package/dist/sig/mod.cjs +3 -3
- package/dist/sig/mod.js +3 -3
- package/dist/sig/owner.test.mjs +5 -5
- package/dist/sig/proof.test.mjs +4 -4
- package/dist/temporal-DG3PUHrG.mjs +95 -0
- package/dist/testing/docloader.test.mjs +1 -1
- package/dist/testing/mod.d.mts +48 -6
- package/dist/testing/mod.mjs +1 -1
- package/dist/{testing-2hgRVgOJ.mjs → testing-Dbq3x7rR.mjs} +2 -2
- package/dist/{transformers-BZ3mYJ1P.cjs → transformers-ZXV8xoFH.cjs} +1 -1
- package/dist/{types-36cPcbK8.js → types-CysnskTc.js} +1 -1
- package/dist/{types-DXy2Djgl.cjs → types-kNVIK9BX.cjs} +1 -1
- package/dist/vocab/actor.test.mjs +4 -4
- package/dist/vocab/cjs.test.mjs +1 -1
- package/dist/vocab/lookup.test.mjs +4 -4
- package/dist/vocab/mod.cjs +3 -3
- package/dist/vocab/mod.js +3 -3
- package/dist/vocab/type.test.mjs +2 -2
- package/dist/vocab/vocab.test.mjs +3 -3
- package/dist/{vocab-BPE_99_6.mjs → vocab-BmWZ5Z8b.mjs} +306 -198
- package/dist/webfinger/handler.test.mjs +3 -3
- package/dist/webfinger/lookup.test.mjs +3 -3
- package/dist/webfinger/mod.cjs +1 -1
- package/dist/webfinger/mod.js +1 -1
- package/dist/x/cfworkers.cjs +1 -1
- package/dist/x/cfworkers.test.mjs +1 -1
- package/dist/x/hono.cjs +1 -1
- package/dist/x/hono.d.cts +1 -1
- package/dist/x/hono.d.ts +1 -1
- package/dist/x/sveltekit.cjs +1 -1
- package/dist/x/sveltekit.d.cts +1 -1
- package/dist/x/sveltekit.d.ts +1 -1
- package/package.json +1 -1
- package/dist/ld-C5izJRbw.mjs +0 -254
- /package/dist/{denokv-CoSB_Eps.mjs → denokv-NJPMXyK0.mjs} +0 -0
- /package/dist/{retry-Ddbq3AcK.mjs → retry-B_E3V_Dx.mjs} +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const { Temporal } = require("@js-temporal/polyfill");
|
|
2
2
|
const { URLPattern } = require("urlpattern-polyfill");
|
|
3
|
-
const require_docloader = require("./docloader-
|
|
4
|
-
const require_actor = require("./actor-
|
|
5
|
-
const require_key = require("./key-
|
|
3
|
+
const require_docloader = require("./docloader-ojCZeNsS.cjs");
|
|
4
|
+
const require_actor = require("./actor-BxUB2vBw.cjs");
|
|
5
|
+
const require_key = require("./key-AD7NWK_B.cjs");
|
|
6
6
|
let _logtape_logtape = require("@logtape/logtape");
|
|
7
7
|
let _opentelemetry_api = require("@opentelemetry/api");
|
|
8
8
|
let jsonld = require("jsonld");
|
|
@@ -17,6 +17,288 @@ const logger$1 = (0, _logtape_logtape.getLogger)([
|
|
|
17
17
|
"sig",
|
|
18
18
|
"ld"
|
|
19
19
|
]);
|
|
20
|
+
const localContext = [
|
|
21
|
+
"https://w3id.org/identity/v1",
|
|
22
|
+
"https://www.w3.org/ns/activitystreams",
|
|
23
|
+
"https://w3id.org/security/v1",
|
|
24
|
+
"https://w3id.org/security/data-integrity/v1"
|
|
25
|
+
];
|
|
26
|
+
const localContextUrls = new Set(localContext);
|
|
27
|
+
const builtInContextLoader = require_docloader.getDocumentLoader();
|
|
28
|
+
const disallowedJsonLdKeywords = new Set([
|
|
29
|
+
"@graph",
|
|
30
|
+
"@included",
|
|
31
|
+
"@reverse"
|
|
32
|
+
]);
|
|
33
|
+
/** @internal */
|
|
34
|
+
var UnsafeJsonLdError = class extends TypeError {
|
|
35
|
+
constructor(keyword) {
|
|
36
|
+
super(`Unsupported JSON-LD keyword: ${keyword}.`);
|
|
37
|
+
this.keyword = keyword;
|
|
38
|
+
this.name = "UnsafeJsonLdError";
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
/** @internal */
|
|
42
|
+
var InvalidContextReferenceError = class extends TypeError {
|
|
43
|
+
constructor(reference) {
|
|
44
|
+
super(`Invalid JSON-LD context reference: ${reference}.`);
|
|
45
|
+
this.reference = reference;
|
|
46
|
+
this.name = "InvalidContextReferenceError";
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
function createLoadingRemoteContextFailedError(reference, cause) {
|
|
50
|
+
const message = cause instanceof Error ? cause.message : String(cause);
|
|
51
|
+
const error = /* @__PURE__ */ new Error(`Dereferencing a URL did not result in a valid JSON-LD context: ${reference}. ${message}`);
|
|
52
|
+
error.name = "jsonld.InvalidUrl";
|
|
53
|
+
error.details = {
|
|
54
|
+
code: "loading remote context failed",
|
|
55
|
+
url: reference
|
|
56
|
+
};
|
|
57
|
+
error.cause = cause;
|
|
58
|
+
return error;
|
|
59
|
+
}
|
|
60
|
+
/** @internal */
|
|
61
|
+
function isClearlyMalformedContextReference(reference) {
|
|
62
|
+
for (const char of reference) {
|
|
63
|
+
const code = char.charCodeAt(0);
|
|
64
|
+
if (code <= 32 || code === 127) return true;
|
|
65
|
+
}
|
|
66
|
+
if (/^[A-Za-z][A-Za-z0-9+.-]*:/.test(reference) && !URL.canParse(reference)) return true;
|
|
67
|
+
for (let i = 0; i < reference.length; i++) {
|
|
68
|
+
if (reference[i] !== "%") continue;
|
|
69
|
+
if (i + 2 >= reference.length || !/[0-9A-Fa-f]/.test(reference[i + 1]) || !/[0-9A-Fa-f]/.test(reference[i + 2])) return true;
|
|
70
|
+
i += 2;
|
|
71
|
+
}
|
|
72
|
+
if (reference.startsWith("./") || reference.startsWith("../") || reference.startsWith("/") || reference.startsWith("//")) {
|
|
73
|
+
for (const char of reference) if ("[]<>\"\\^`{|}".includes(char)) return true;
|
|
74
|
+
}
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
function cloneRemoteDocument(remoteDocument) {
|
|
78
|
+
return structuredClone(remoteDocument);
|
|
79
|
+
}
|
|
80
|
+
function createMemoizedDocumentLoader(documentLoader) {
|
|
81
|
+
const cache = /* @__PURE__ */ new Map();
|
|
82
|
+
return async (url, options) => {
|
|
83
|
+
const cacheKey = URL.canParse(url) ? new URL(url).href : url;
|
|
84
|
+
let remoteDocument = cache.get(cacheKey);
|
|
85
|
+
if (remoteDocument == null) {
|
|
86
|
+
remoteDocument = Promise.resolve(documentLoader(url, options)).then(cloneRemoteDocument);
|
|
87
|
+
remoteDocument.catch(() => {
|
|
88
|
+
if (cache.get(cacheKey) === remoteDocument) cache.delete(cacheKey);
|
|
89
|
+
});
|
|
90
|
+
cache.set(cacheKey, remoteDocument);
|
|
91
|
+
}
|
|
92
|
+
return cloneRemoteDocument(await remoteDocument);
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
/** @internal */
|
|
96
|
+
function wrapContextLoaderForJsonLd(contextLoader) {
|
|
97
|
+
const loader = contextLoader ?? builtInContextLoader;
|
|
98
|
+
return async (url, options) => {
|
|
99
|
+
try {
|
|
100
|
+
return await loader(url, options);
|
|
101
|
+
} catch (error) {
|
|
102
|
+
if (!isInvalidUrlTypeError(error)) throw error;
|
|
103
|
+
if (isClearlyMalformedContextReference(url)) throw new InvalidContextReferenceError(url);
|
|
104
|
+
throw createLoadingRemoteContextFailedError(url, error);
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/** @internal */
|
|
109
|
+
function getNormalizationContextLoader(contextLoader) {
|
|
110
|
+
const loader = wrapContextLoaderForJsonLd(contextLoader);
|
|
111
|
+
return createMemoizedDocumentLoader(async (url, options) => {
|
|
112
|
+
if (URL.canParse(url)) {
|
|
113
|
+
const normalizedUrl = new URL(url).href;
|
|
114
|
+
if (localContextUrls.has(normalizedUrl)) return await builtInContextLoader(normalizedUrl, options);
|
|
115
|
+
}
|
|
116
|
+
return await loader(url, options);
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
/** @internal */
|
|
120
|
+
async function compactJsonLd(jsonLd, contextLoader) {
|
|
121
|
+
const hasLds = typeof jsonLd === "object" && jsonLd != null && "signature" in jsonLd;
|
|
122
|
+
const signature = hasLds ? jsonLd.signature : void 0;
|
|
123
|
+
const normalizationContextLoader = getNormalizationContextLoader(contextLoader);
|
|
124
|
+
const document = hasLds ? detachSignature(jsonLd) : jsonLd;
|
|
125
|
+
await assertNoGraphBeforeCompaction(document, normalizationContextLoader);
|
|
126
|
+
const compacted = await jsonld.default.compact(document, localContext, { documentLoader: normalizationContextLoader });
|
|
127
|
+
if (hasLds && typeof compacted === "object" && compacted != null) compacted.signature = signature;
|
|
128
|
+
assertSafeJsonLd(compacted);
|
|
129
|
+
return compacted;
|
|
130
|
+
}
|
|
131
|
+
function createInvalidRemoteContextError(reference) {
|
|
132
|
+
const error = /* @__PURE__ */ new Error(`Dereferencing a URL did not result in a JSON object. The response was valid JSON, but it was not a JSON object. URL: "${reference}".`);
|
|
133
|
+
error.name = "jsonld.InvalidUrl";
|
|
134
|
+
error.details = {
|
|
135
|
+
code: "invalid remote context",
|
|
136
|
+
url: reference
|
|
137
|
+
};
|
|
138
|
+
return error;
|
|
139
|
+
}
|
|
140
|
+
function getRemoteContext(remoteDocument, reference) {
|
|
141
|
+
const { contextUrl, documentUrl } = remoteDocument;
|
|
142
|
+
let { document } = remoteDocument;
|
|
143
|
+
if (typeof document === "string") document = JSON.parse(document);
|
|
144
|
+
if (typeof document !== "object" || document == null || Array.isArray(document)) throw createInvalidRemoteContextError(reference);
|
|
145
|
+
let context = "@context" in document ? document["@context"] : {};
|
|
146
|
+
if (contextUrl != null) context = Array.isArray(context) ? [...context, contextUrl] : [context, contextUrl];
|
|
147
|
+
return {
|
|
148
|
+
context,
|
|
149
|
+
baseUrl: documentUrl ?? reference
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
function createGraphAliasContextState() {
|
|
153
|
+
return {
|
|
154
|
+
graphTerms: /* @__PURE__ */ new Set(),
|
|
155
|
+
jsonTerms: /* @__PURE__ */ new Set(),
|
|
156
|
+
propertyContexts: /* @__PURE__ */ new Map(),
|
|
157
|
+
termTargets: /* @__PURE__ */ new Map()
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
function cloneGraphAliasContextState(state) {
|
|
161
|
+
return {
|
|
162
|
+
graphTerms: new Set(state.graphTerms),
|
|
163
|
+
jsonTerms: new Set(state.jsonTerms),
|
|
164
|
+
propertyContexts: new Map(state.propertyContexts),
|
|
165
|
+
termTargets: new Map(state.termTargets)
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
function resolveContextTarget(target, state) {
|
|
169
|
+
if (target === "@graph") return target;
|
|
170
|
+
const mapped = state.termTargets.get(target);
|
|
171
|
+
if (mapped == null) return target;
|
|
172
|
+
return mapped;
|
|
173
|
+
}
|
|
174
|
+
function getDirectContextTarget(definition) {
|
|
175
|
+
if (definition === null) return null;
|
|
176
|
+
if (typeof definition === "string") return definition;
|
|
177
|
+
if (typeof definition === "object" && definition != null && "@id" in definition) {
|
|
178
|
+
const id = definition["@id"];
|
|
179
|
+
if (id === null) return null;
|
|
180
|
+
if (typeof id === "string") return id;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
function isJsonTypedDefinition(definition) {
|
|
184
|
+
return typeof definition === "object" && definition != null && "@type" in definition && definition["@type"] === "@json";
|
|
185
|
+
}
|
|
186
|
+
function resolveLocalContextTarget(target, state, localTargets, seen = /* @__PURE__ */ new Set()) {
|
|
187
|
+
if (target === "@graph") return target;
|
|
188
|
+
if (seen.has(target)) return target;
|
|
189
|
+
seen.add(target);
|
|
190
|
+
if (localTargets.has(target)) {
|
|
191
|
+
const localTarget = localTargets.get(target);
|
|
192
|
+
return localTarget == null ? target : resolveLocalContextTarget(localTarget, state, localTargets, seen);
|
|
193
|
+
}
|
|
194
|
+
return resolveContextTarget(target, state);
|
|
195
|
+
}
|
|
196
|
+
function refreshGraphAliases(state) {
|
|
197
|
+
state.graphTerms.clear();
|
|
198
|
+
for (const [term, target] of state.termTargets) if (target === "@graph") state.graphTerms.add(term);
|
|
199
|
+
}
|
|
200
|
+
function normalizeContextReference(reference, baseUrl) {
|
|
201
|
+
if (baseUrl != null) return new URL(reference, baseUrl).href;
|
|
202
|
+
return URL.canParse(reference) ? new URL(reference).href : reference;
|
|
203
|
+
}
|
|
204
|
+
/** @internal */
|
|
205
|
+
function isInvalidUrlTypeError(error) {
|
|
206
|
+
const code = error.code;
|
|
207
|
+
return error instanceof TypeError && (code === "ERR_INVALID_URL" || /^Invalid URL(?::|$)/.test(error.message) || / cannot be parsed as a URL\.?$/.test(error.message));
|
|
208
|
+
}
|
|
209
|
+
async function applyGraphAliasContext(state, context, documentLoader, remoteContextCache, baseUrl = null, processingContexts = /* @__PURE__ */ new Set()) {
|
|
210
|
+
if (context === null) return createGraphAliasContextState();
|
|
211
|
+
let nextState = cloneGraphAliasContextState(state);
|
|
212
|
+
if (Array.isArray(context)) {
|
|
213
|
+
for (const item of context) nextState = await applyGraphAliasContext(nextState, item, documentLoader, remoteContextCache, baseUrl, processingContexts);
|
|
214
|
+
return nextState;
|
|
215
|
+
}
|
|
216
|
+
if (typeof context === "string") {
|
|
217
|
+
const reference = normalizeContextReference(context, baseUrl);
|
|
218
|
+
const cacheKey = `${baseUrl ?? ""}\n${reference}`;
|
|
219
|
+
if (processingContexts.has(cacheKey)) return nextState;
|
|
220
|
+
processingContexts.add(cacheKey);
|
|
221
|
+
try {
|
|
222
|
+
let remoteContext = remoteContextCache.get(cacheKey);
|
|
223
|
+
if (remoteContext == null) {
|
|
224
|
+
remoteContext = (async () => {
|
|
225
|
+
try {
|
|
226
|
+
return getRemoteContext(await documentLoader(reference), reference);
|
|
227
|
+
} catch (error) {
|
|
228
|
+
if (reference === context && isInvalidUrlTypeError(error) && isClearlyMalformedContextReference(context)) throw new InvalidContextReferenceError(context);
|
|
229
|
+
throw error;
|
|
230
|
+
}
|
|
231
|
+
})();
|
|
232
|
+
remoteContextCache.set(cacheKey, remoteContext);
|
|
233
|
+
}
|
|
234
|
+
const loadedRemoteContext = await remoteContext;
|
|
235
|
+
return await applyGraphAliasContext(nextState, loadedRemoteContext.context, documentLoader, remoteContextCache, loadedRemoteContext.baseUrl, processingContexts);
|
|
236
|
+
} finally {
|
|
237
|
+
processingContexts.delete(cacheKey);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
if (typeof context === "object" && context != null) {
|
|
241
|
+
if ("@import" in context && typeof context["@import"] === "string") nextState = await applyGraphAliasContext(nextState, context["@import"], documentLoader, remoteContextCache, baseUrl, processingContexts);
|
|
242
|
+
const localTargets = /* @__PURE__ */ new Map();
|
|
243
|
+
for (const [term, definition] of globalThis.Object.entries(context)) {
|
|
244
|
+
if (term.startsWith("@")) continue;
|
|
245
|
+
const target = getDirectContextTarget(definition);
|
|
246
|
+
if (target == null) localTargets.set(term, null);
|
|
247
|
+
else if (typeof target === "string") localTargets.set(term, target);
|
|
248
|
+
else localTargets.delete(term);
|
|
249
|
+
}
|
|
250
|
+
for (const [term, definition] of globalThis.Object.entries(context)) {
|
|
251
|
+
if (term.startsWith("@")) continue;
|
|
252
|
+
if (localTargets.has(term)) {
|
|
253
|
+
const directTarget = localTargets.get(term);
|
|
254
|
+
if (directTarget == null) nextState.termTargets.set(term, null);
|
|
255
|
+
else nextState.termTargets.set(term, resolveLocalContextTarget(directTarget, nextState, localTargets));
|
|
256
|
+
} else nextState.termTargets.delete(term);
|
|
257
|
+
if (typeof definition === "object" && definition != null && "@context" in definition) nextState.propertyContexts.set(term, {
|
|
258
|
+
context: definition["@context"],
|
|
259
|
+
baseUrl
|
|
260
|
+
});
|
|
261
|
+
else nextState.propertyContexts.delete(term);
|
|
262
|
+
if (isJsonTypedDefinition(definition)) nextState.jsonTerms.add(term);
|
|
263
|
+
else nextState.jsonTerms.delete(term);
|
|
264
|
+
}
|
|
265
|
+
refreshGraphAliases(nextState);
|
|
266
|
+
}
|
|
267
|
+
return nextState;
|
|
268
|
+
}
|
|
269
|
+
async function assertNoGraphBeforeCompaction(jsonLd, documentLoader, inheritedState = createGraphAliasContextState(), propertyContext, remoteContextCache = /* @__PURE__ */ new Map()) {
|
|
270
|
+
if (Array.isArray(jsonLd)) {
|
|
271
|
+
for (const item of jsonLd) await assertNoGraphBeforeCompaction(item, documentLoader, inheritedState, propertyContext, remoteContextCache);
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
if (typeof jsonLd !== "object" || jsonLd == null) return;
|
|
275
|
+
const jsonLiteralWrapper = isJsonLiteralWrapper(jsonLd);
|
|
276
|
+
let state = inheritedState;
|
|
277
|
+
if (propertyContext !== void 0) state = await applyGraphAliasContext(state, propertyContext.context, documentLoader, remoteContextCache, propertyContext.baseUrl);
|
|
278
|
+
if ("@context" in jsonLd) state = await applyGraphAliasContext(state, jsonLd["@context"], documentLoader, remoteContextCache);
|
|
279
|
+
for (const [key, value] of globalThis.Object.entries(jsonLd)) {
|
|
280
|
+
if (key === "@context") continue;
|
|
281
|
+
if (jsonLiteralWrapper && key === "@value") continue;
|
|
282
|
+
if (key === "@graph" || state.graphTerms.has(key)) throw new UnsafeJsonLdError("@graph");
|
|
283
|
+
if (state.jsonTerms.has(key)) continue;
|
|
284
|
+
await assertNoGraphBeforeCompaction(value, documentLoader, state, state.propertyContexts.get(key), remoteContextCache);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
function isJsonLiteralWrapper(value) {
|
|
288
|
+
return "@value" in value && (value["@type"] === "@json" || value.type === "@json");
|
|
289
|
+
}
|
|
290
|
+
/** @internal */
|
|
291
|
+
function assertSafeJsonLd(jsonLd) {
|
|
292
|
+
if (Array.isArray(jsonLd)) for (const item of jsonLd) assertSafeJsonLd(item);
|
|
293
|
+
else if (typeof jsonLd === "object" && jsonLd != null) {
|
|
294
|
+
const jsonLiteralWrapper = isJsonLiteralWrapper(jsonLd);
|
|
295
|
+
for (const [key, value] of globalThis.Object.entries(jsonLd)) {
|
|
296
|
+
if (disallowedJsonLdKeywords.has(key)) throw new UnsafeJsonLdError(key);
|
|
297
|
+
if (jsonLiteralWrapper && key === "@value") continue;
|
|
298
|
+
assertSafeJsonLd(value);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
|
20
302
|
/**
|
|
21
303
|
* Attaches a LD signature to the given JSON-LD document.
|
|
22
304
|
* @param jsonLd The JSON-LD document to attach the signature to. It is not
|
|
@@ -210,9 +492,21 @@ async function verifySignature(jsonLd, options = {}) {
|
|
|
210
492
|
* @returns `true` if the document is authentic; `false` otherwise.
|
|
211
493
|
*/
|
|
212
494
|
async function verifyJsonLd(jsonLd, options = {}) {
|
|
495
|
+
return await verifyJsonLdInternal(jsonLd, options, true);
|
|
496
|
+
}
|
|
497
|
+
/** @internal */
|
|
498
|
+
async function verifyCompactJsonLd(jsonLd, options = {}) {
|
|
499
|
+
return await verifyJsonLdInternal(jsonLd, options, false);
|
|
500
|
+
}
|
|
501
|
+
async function verifyJsonLdInternal(jsonLd, options, compact) {
|
|
213
502
|
return await (options.tracerProvider ?? _opentelemetry_api.trace.getTracerProvider()).getTracer(require_docloader.name, require_docloader.version).startActiveSpan("ld_signatures.verify", async (span) => {
|
|
214
503
|
try {
|
|
215
|
-
const
|
|
504
|
+
const verificationOptions = hasSignature(jsonLd) ? {
|
|
505
|
+
...options,
|
|
506
|
+
contextLoader: getNormalizationContextLoader(options.contextLoader)
|
|
507
|
+
} : options;
|
|
508
|
+
const compacted = compact ? hasSignature(jsonLd) ? await compactJsonLd(jsonLd, options.contextLoader) : jsonLd : jsonLd;
|
|
509
|
+
const object = await require_actor.Object.fromJsonLd(compacted, verificationOptions);
|
|
216
510
|
if (object.id != null) span.setAttribute("activitypub.object.id", object.id.href);
|
|
217
511
|
span.setAttribute("activitypub.object.type", require_actor.getTypeId(object).href);
|
|
218
512
|
if (typeof jsonLd === "object" && jsonLd != null && "signature" in jsonLd && typeof jsonLd.signature === "object" && jsonLd.signature != null) {
|
|
@@ -222,7 +516,7 @@ async function verifyJsonLd(jsonLd, options = {}) {
|
|
|
222
516
|
}
|
|
223
517
|
const attributions = new Set(object.attributionIds.map((uri) => uri.href));
|
|
224
518
|
if (object instanceof require_actor.Activity) for (const uri of object.actorIds) attributions.add(uri.href);
|
|
225
|
-
const key = await verifySignature(
|
|
519
|
+
const key = await verifySignature(compacted, verificationOptions);
|
|
226
520
|
if (key == null) return false;
|
|
227
521
|
if (key.ownerId == null) {
|
|
228
522
|
logger$1.debug("Key {keyId} has no owner.", { keyId: key.id?.href });
|
|
@@ -570,12 +864,30 @@ async function verifyObject(cls, jsonLd, options = {}) {
|
|
|
570
864
|
return object;
|
|
571
865
|
}
|
|
572
866
|
//#endregion
|
|
867
|
+
Object.defineProperty(exports, "InvalidContextReferenceError", {
|
|
868
|
+
enumerable: true,
|
|
869
|
+
get: function() {
|
|
870
|
+
return InvalidContextReferenceError;
|
|
871
|
+
}
|
|
872
|
+
});
|
|
873
|
+
Object.defineProperty(exports, "assertSafeJsonLd", {
|
|
874
|
+
enumerable: true,
|
|
875
|
+
get: function() {
|
|
876
|
+
return assertSafeJsonLd;
|
|
877
|
+
}
|
|
878
|
+
});
|
|
573
879
|
Object.defineProperty(exports, "attachSignature", {
|
|
574
880
|
enumerable: true,
|
|
575
881
|
get: function() {
|
|
576
882
|
return attachSignature;
|
|
577
883
|
}
|
|
578
884
|
});
|
|
885
|
+
Object.defineProperty(exports, "compactJsonLd", {
|
|
886
|
+
enumerable: true,
|
|
887
|
+
get: function() {
|
|
888
|
+
return compactJsonLd;
|
|
889
|
+
}
|
|
890
|
+
});
|
|
579
891
|
Object.defineProperty(exports, "createProof", {
|
|
580
892
|
enumerable: true,
|
|
581
893
|
get: function() {
|
|
@@ -606,12 +918,30 @@ Object.defineProperty(exports, "getKeyOwner", {
|
|
|
606
918
|
return getKeyOwner;
|
|
607
919
|
}
|
|
608
920
|
});
|
|
921
|
+
Object.defineProperty(exports, "getNormalizationContextLoader", {
|
|
922
|
+
enumerable: true,
|
|
923
|
+
get: function() {
|
|
924
|
+
return getNormalizationContextLoader;
|
|
925
|
+
}
|
|
926
|
+
});
|
|
609
927
|
Object.defineProperty(exports, "hasSignature", {
|
|
610
928
|
enumerable: true,
|
|
611
929
|
get: function() {
|
|
612
930
|
return hasSignature;
|
|
613
931
|
}
|
|
614
932
|
});
|
|
933
|
+
Object.defineProperty(exports, "isClearlyMalformedContextReference", {
|
|
934
|
+
enumerable: true,
|
|
935
|
+
get: function() {
|
|
936
|
+
return isClearlyMalformedContextReference;
|
|
937
|
+
}
|
|
938
|
+
});
|
|
939
|
+
Object.defineProperty(exports, "isInvalidUrlTypeError", {
|
|
940
|
+
enumerable: true,
|
|
941
|
+
get: function() {
|
|
942
|
+
return isInvalidUrlTypeError;
|
|
943
|
+
}
|
|
944
|
+
});
|
|
615
945
|
Object.defineProperty(exports, "signJsonLd", {
|
|
616
946
|
enumerable: true,
|
|
617
947
|
get: function() {
|
|
@@ -624,6 +954,12 @@ Object.defineProperty(exports, "signObject", {
|
|
|
624
954
|
return signObject;
|
|
625
955
|
}
|
|
626
956
|
});
|
|
957
|
+
Object.defineProperty(exports, "verifyCompactJsonLd", {
|
|
958
|
+
enumerable: true,
|
|
959
|
+
get: function() {
|
|
960
|
+
return verifyCompactJsonLd;
|
|
961
|
+
}
|
|
962
|
+
});
|
|
627
963
|
Object.defineProperty(exports, "verifyJsonLd", {
|
|
628
964
|
enumerable: true,
|
|
629
965
|
get: function() {
|
|
@@ -648,3 +984,9 @@ Object.defineProperty(exports, "verifySignature", {
|
|
|
648
984
|
return verifySignature;
|
|
649
985
|
}
|
|
650
986
|
});
|
|
987
|
+
Object.defineProperty(exports, "wrapContextLoaderForJsonLd", {
|
|
988
|
+
enumerable: true,
|
|
989
|
+
get: function() {
|
|
990
|
+
return wrapContextLoaderForJsonLd;
|
|
991
|
+
}
|
|
992
|
+
});
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { $ as UrlError } from "../vocab-
|
|
5
|
-
import { a as mockDocumentLoader, t as test } from "../testing-
|
|
4
|
+
import { $ as UrlError } from "../vocab-BmWZ5Z8b.mjs";
|
|
5
|
+
import { a as mockDocumentLoader, t as test } from "../testing-Dbq3x7rR.mjs";
|
|
6
6
|
import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
7
7
|
import "../std__assert-2v7gYiZp.mjs";
|
|
8
8
|
import { t as assertRejects } from "../assert_rejects-CJC9ThS-.mjs";
|
|
9
|
-
import { l as verifyRequest } from "../http-
|
|
10
|
-
import { t as getAuthenticatedDocumentLoader } from "../authdocloader-
|
|
11
|
-
import { t as esm_default } from "../esm-
|
|
12
|
-
import { i as rsaPrivateKey2 } from "../keys-
|
|
9
|
+
import { l as verifyRequest } from "../http-ChKbuD-B.mjs";
|
|
10
|
+
import { t as getAuthenticatedDocumentLoader } from "../authdocloader-DVWlfdZ9.mjs";
|
|
11
|
+
import { t as esm_default } from "../esm-DpYRgHio.mjs";
|
|
12
|
+
import { i as rsaPrivateKey2 } from "../keys-CJPe6iTW.mjs";
|
|
13
13
|
//#region src/runtime/authdocloader.test.ts
|
|
14
14
|
test("getAuthenticatedDocumentLoader()", async (t) => {
|
|
15
15
|
esm_default.spyGlobal();
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import { URLPattern } from "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { $ as UrlError, G as FetchError, J as getDocumentLoader, X as getUserAgent, Z as kvCache, at as preloadedContexts, st as version } from "../vocab-
|
|
5
|
-
import { a as mockDocumentLoader, t as test } from "../testing-
|
|
4
|
+
import { $ as UrlError, G as FetchError, J as getDocumentLoader, X as getUserAgent, Z as kvCache, at as preloadedContexts, st as version } from "../vocab-BmWZ5Z8b.mjs";
|
|
5
|
+
import { a as mockDocumentLoader, t as test } from "../testing-Dbq3x7rR.mjs";
|
|
6
6
|
import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
7
7
|
import "../std__assert-2v7gYiZp.mjs";
|
|
8
8
|
import { t as assertRejects } from "../assert_rejects-CJC9ThS-.mjs";
|
|
9
9
|
import { t as assertThrows } from "../assert_throws-BIL7gChy.mjs";
|
|
10
10
|
import { t as assert } from "../assert-DikXweDx.mjs";
|
|
11
11
|
import { t as MemoryKvStore } from "../kv-DM1zFCtL.mjs";
|
|
12
|
-
import { t as esm_default } from "../esm-
|
|
12
|
+
import { t as esm_default } from "../esm-DpYRgHio.mjs";
|
|
13
13
|
import process from "node:process";
|
|
14
14
|
//#region src/runtime/docloader.test.ts
|
|
15
15
|
test("new FetchError()", () => {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { F as importPkcs1, I as importSpki, M as exportSpki, N as importMultibaseKey, P as importPem, j as exportMultibaseKey } from "../vocab-
|
|
5
|
-
import { t as test } from "../testing-
|
|
4
|
+
import { F as importPkcs1, I as importSpki, M as exportSpki, N as importMultibaseKey, P as importPem, j as exportMultibaseKey } from "../vocab-BmWZ5Z8b.mjs";
|
|
5
|
+
import { t as test } from "../testing-Dbq3x7rR.mjs";
|
|
6
6
|
import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
7
7
|
import "../std__assert-2v7gYiZp.mjs";
|
|
8
|
-
import { i as importJwk, t as exportJwk } from "../key-
|
|
8
|
+
import { i as importJwk, t as exportJwk } from "../key-Bd3kgBIA.mjs";
|
|
9
9
|
//#region src/runtime/key.test.ts
|
|
10
10
|
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";
|
|
11
11
|
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";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { A as LanguageString } from "../vocab-
|
|
5
|
-
import { t as test } from "../testing-
|
|
4
|
+
import { A as LanguageString } from "../vocab-BmWZ5Z8b.mjs";
|
|
5
|
+
import { t as test } from "../testing-Dbq3x7rR.mjs";
|
|
6
6
|
import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
7
7
|
import "../std__assert-2v7gYiZp.mjs";
|
|
8
8
|
import { parseLanguageTag } from "@phensley/language-tag";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { it as HttpHeaderLink } from "../vocab-
|
|
5
|
-
import { t as test } from "../testing-
|
|
4
|
+
import { it as HttpHeaderLink } from "../vocab-BmWZ5Z8b.mjs";
|
|
5
|
+
import { t as test } from "../testing-Dbq3x7rR.mjs";
|
|
6
6
|
import { deepStrictEqual, throws } from "node:assert";
|
|
7
7
|
//#region src/runtime/link.test.ts
|
|
8
8
|
test("String Good 1", () => {
|
package/dist/runtime/mod.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
const { Temporal } = require("@js-temporal/polyfill");
|
|
2
2
|
const { URLPattern } = require("urlpattern-polyfill");
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
-
const require_docloader = require("../docloader-
|
|
5
|
-
const require_actor = require("../actor-
|
|
6
|
-
const require_authdocloader = require("../authdocloader-
|
|
4
|
+
const require_docloader = require("../docloader-ojCZeNsS.cjs");
|
|
5
|
+
const require_actor = require("../actor-BxUB2vBw.cjs");
|
|
6
|
+
const require_authdocloader = require("../authdocloader-BkG-kREl.cjs");
|
|
7
7
|
exports.FetchError = require_docloader.FetchError;
|
|
8
8
|
exports.LanguageString = require_actor.LanguageString;
|
|
9
9
|
exports.exportMultibaseKey = require_actor.exportMultibaseKey;
|
package/dist/runtime/mod.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
|
-
import { i as getDocumentLoader, o as getUserAgent, r as fetchDocumentLoader, s as kvCache, t as FetchError } from "../docloader-
|
|
4
|
-
import { Ct as importPkcs1, St as importPem, bt as exportSpki, vt as LanguageString, wt as importSpki, xt as importMultibaseKey, yt as exportMultibaseKey } from "../actor-
|
|
5
|
-
import { t as getAuthenticatedDocumentLoader } from "../authdocloader-
|
|
3
|
+
import { i as getDocumentLoader, o as getUserAgent, r as fetchDocumentLoader, s as kvCache, t as FetchError } from "../docloader-CFM5B9fd.js";
|
|
4
|
+
import { Ct as importPkcs1, St as importPem, bt as exportSpki, vt as LanguageString, wt as importSpki, xt as importMultibaseKey, yt as exportMultibaseKey } from "../actor-BJj7NAV7.js";
|
|
5
|
+
import { t as getAuthenticatedDocumentLoader } from "../authdocloader-_m5yqwLt.js";
|
|
6
6
|
export { FetchError, LanguageString, exportMultibaseKey, exportSpki, fetchDocumentLoader, getAuthenticatedDocumentLoader, getDocumentLoader, getUserAgent, importMultibaseKey, importPem, importPkcs1, importSpki, kvCache };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { B as names, H as encodeText, L as decode, R as encode, V as decodeText, z as codes } from "../../vocab-
|
|
5
|
-
import { t as test } from "../../testing-
|
|
4
|
+
import { B as names, H as encodeText, L as decode, R as encode, V as decodeText, z as codes } from "../../vocab-BmWZ5Z8b.mjs";
|
|
5
|
+
import { t as test } from "../../testing-Dbq3x7rR.mjs";
|
|
6
6
|
import { t as assertEquals } from "../../assert_equals-Ew3jOFa3.mjs";
|
|
7
7
|
import "../../std__assert-2v7gYiZp.mjs";
|
|
8
8
|
//#region src/runtime/multibase/multibase.test.ts
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { $ as UrlError, et as expandIPv6Address, nt as isValidPublicIPv6Address, rt as validatePublicUrl, tt as isValidPublicIPv4Address } from "../vocab-
|
|
5
|
-
import { t as test } from "../testing-
|
|
4
|
+
import { $ as UrlError, et as expandIPv6Address, nt as isValidPublicIPv6Address, rt as validatePublicUrl, tt as isValidPublicIPv4Address } from "../vocab-BmWZ5Z8b.mjs";
|
|
5
|
+
import { t as test } from "../testing-Dbq3x7rR.mjs";
|
|
6
6
|
import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
7
7
|
import { n as assertFalse, t as assertRejects } from "../assert_rejects-CJC9ThS-.mjs";
|
|
8
8
|
import { t as assert } from "../assert-DikXweDx.mjs";
|
|
@@ -14,7 +14,24 @@ test("validatePublicUrl()", async () => {
|
|
|
14
14
|
await assertRejects(() => validatePublicUrl("https://127.0.0.1"), UrlError);
|
|
15
15
|
await assertRejects(() => validatePublicUrl("https://[::1]"), UrlError);
|
|
16
16
|
await assertRejects(() => validatePublicUrl("http://[::ffff:7f00:1]/"), UrlError);
|
|
17
|
+
await assertRejects(() => validatePublicUrl("https://[64:ff9b::7f00:1]/"), UrlError);
|
|
18
|
+
await assertRejects(() => validatePublicUrl("https://[64:ff9b::a00:1]/"), UrlError);
|
|
19
|
+
await assertRejects(() => validatePublicUrl("https://[64:ff9b:1::a00:1]/"), UrlError);
|
|
20
|
+
await assertRejects(() => validatePublicUrl("https://[64:ff9b:1::808:808]/"), UrlError);
|
|
21
|
+
await assertRejects(() => validatePublicUrl("https://[2001::]/"), UrlError);
|
|
22
|
+
await assertRejects(() => validatePublicUrl("https://[2002:a00:1::]/"), UrlError);
|
|
23
|
+
for (const url of [
|
|
24
|
+
"https://100.64.0.1",
|
|
25
|
+
"https://198.18.0.1",
|
|
26
|
+
"https://224.0.0.1",
|
|
27
|
+
"https://240.0.0.1",
|
|
28
|
+
"https://192.0.2.1",
|
|
29
|
+
"https://192.88.99.1",
|
|
30
|
+
"https://198.51.100.1",
|
|
31
|
+
"https://203.0.113.1"
|
|
32
|
+
]) await assertRejects(() => validatePublicUrl(url), UrlError);
|
|
17
33
|
await validatePublicUrl("https://[2001:db8::1]");
|
|
34
|
+
await validatePublicUrl("https://[64:ff9b::8.8.8.8]");
|
|
18
35
|
});
|
|
19
36
|
test("isValidPublicIPv4Address()", () => {
|
|
20
37
|
assert(isValidPublicIPv4Address("8.8.8.8"));
|
|
@@ -23,6 +40,24 @@ test("isValidPublicIPv4Address()", () => {
|
|
|
23
40
|
assertFalse(isValidPublicIPv4Address("10.0.0.1"));
|
|
24
41
|
assertFalse(isValidPublicIPv4Address("127.16.0.1"));
|
|
25
42
|
assertFalse(isValidPublicIPv4Address("169.254.0.1"));
|
|
43
|
+
assertFalse(isValidPublicIPv4Address("100.64.0.1"));
|
|
44
|
+
assertFalse(isValidPublicIPv4Address("100.127.255.255"));
|
|
45
|
+
assertFalse(isValidPublicIPv4Address("192.0.0.1"));
|
|
46
|
+
assertFalse(isValidPublicIPv4Address("192.0.2.1"));
|
|
47
|
+
assertFalse(isValidPublicIPv4Address("192.88.99.0"));
|
|
48
|
+
assertFalse(isValidPublicIPv4Address("192.88.99.1"));
|
|
49
|
+
assertFalse(isValidPublicIPv4Address("192.88.99.2"));
|
|
50
|
+
assertFalse(isValidPublicIPv4Address("192.88.99.255"));
|
|
51
|
+
assertFalse(isValidPublicIPv4Address("198.18.0.1"));
|
|
52
|
+
assertFalse(isValidPublicIPv4Address("198.19.255.255"));
|
|
53
|
+
assertFalse(isValidPublicIPv4Address("198.51.100.1"));
|
|
54
|
+
assertFalse(isValidPublicIPv4Address("203.0.113.1"));
|
|
55
|
+
assertFalse(isValidPublicIPv4Address("224.0.0.1"));
|
|
56
|
+
assertFalse(isValidPublicIPv4Address("239.255.255.255"));
|
|
57
|
+
assertFalse(isValidPublicIPv4Address("240.0.0.1"));
|
|
58
|
+
assertFalse(isValidPublicIPv4Address("255.255.255.255"));
|
|
59
|
+
assertFalse(isValidPublicIPv4Address("1.2.3"));
|
|
60
|
+
assertFalse(isValidPublicIPv4Address("999.1.1.1"));
|
|
26
61
|
});
|
|
27
62
|
test("isValidPublicIPv6Address()", () => {
|
|
28
63
|
assert(isValidPublicIPv6Address("2001:db8::1"));
|
|
@@ -32,12 +67,28 @@ test("isValidPublicIPv6Address()", () => {
|
|
|
32
67
|
assertFalse(isValidPublicIPv6Address("ff00::1"));
|
|
33
68
|
assertFalse(isValidPublicIPv6Address("::"));
|
|
34
69
|
assertFalse(isValidPublicIPv6Address("::ffff:7f00:1"));
|
|
70
|
+
assertFalse(isValidPublicIPv6Address("64:ff9b::7f00:1"));
|
|
71
|
+
assertFalse(isValidPublicIPv6Address("64:ff9b::127.0.0.1"));
|
|
72
|
+
assertFalse(isValidPublicIPv6Address("64:ff9b::a00:1"));
|
|
73
|
+
assertFalse(isValidPublicIPv6Address("64:ff9b::10.0.0.1"));
|
|
74
|
+
assertFalse(isValidPublicIPv6Address("64:ff9b:1::"));
|
|
75
|
+
assertFalse(isValidPublicIPv6Address("64:ff9b:1::a00:1"));
|
|
76
|
+
assertFalse(isValidPublicIPv6Address("64:ff9b:1::10.0.0.1"));
|
|
77
|
+
assertFalse(isValidPublicIPv6Address("2001::"));
|
|
78
|
+
assertFalse(isValidPublicIPv6Address("2001:0:4136:e378:8000:63bf:3fff:fdd2"));
|
|
79
|
+
assertFalse(isValidPublicIPv6Address("2002:a00:1::"));
|
|
80
|
+
assertFalse(isValidPublicIPv6Address("2002:7f00:1::"));
|
|
81
|
+
assertFalse(isValidPublicIPv6Address("2002:c0a8:1::"));
|
|
82
|
+
assertFalse(isValidPublicIPv6Address("2002:a9fe:1::"));
|
|
83
|
+
assert(isValidPublicIPv6Address("64:ff9b::808:808"));
|
|
84
|
+
assert(isValidPublicIPv6Address("64:ff9b::8.8.8.8"));
|
|
35
85
|
});
|
|
36
86
|
test("expandIPv6Address()", () => {
|
|
37
87
|
assertEquals(expandIPv6Address("::"), "0000:0000:0000:0000:0000:0000:0000:0000");
|
|
38
88
|
assertEquals(expandIPv6Address("::1"), "0000:0000:0000:0000:0000:0000:0000:0001");
|
|
39
89
|
assertEquals(expandIPv6Address("2001:db8::"), "2001:0db8:0000:0000:0000:0000:0000:0000");
|
|
40
90
|
assertEquals(expandIPv6Address("2001:db8::1"), "2001:0db8:0000:0000:0000:0000:0000:0001");
|
|
91
|
+
assertEquals(expandIPv6Address("64:ff9b::8.8.8.8"), "0064:ff9b:0000:0000:0000:0000:0808:0808");
|
|
41
92
|
});
|
|
42
93
|
//#endregion
|
|
43
94
|
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { ot as name, st as version } from "./vocab-
|
|
5
|
-
import { n as doubleKnock } from "./http-
|
|
4
|
+
import { ot as name, st as version } from "./vocab-BmWZ5Z8b.mjs";
|
|
5
|
+
import { n as doubleKnock } from "./http-ChKbuD-B.mjs";
|
|
6
6
|
import { getLogger } from "@logtape/logtape";
|
|
7
7
|
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
8
8
|
//#region src/federation/send.ts
|