@fedify/vocab-runtime 2.4.0-pr.936.41 → 2.4.1
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/deno.json +4 -2
- package/dist/{tests/docloader-Ck8bcBir.mjs → contexts-B09jb9Pi.cjs} +173 -274
- package/dist/{tests/docloader-S_gQZ2tt.cjs → contexts-DWrj4AGR.js} +169 -293
- package/dist/{docloader-C_dir7Xb.d.ts → docloader-BMHljyYb.d.cts} +68 -2
- package/dist/{docloader-D2DTRiyA.d.cts → docloader-BMHljyYb.d.ts} +68 -2
- package/dist/internal/jsonld-cache.cjs +70 -1
- package/dist/internal/jsonld-cache.d.cts +35 -2
- package/dist/internal/jsonld-cache.d.ts +35 -2
- package/dist/internal/jsonld-cache.js +67 -2
- package/dist/internal/portable-dereference.cjs +721 -0
- package/dist/internal/portable-dereference.d.cts +349 -0
- package/dist/internal/portable-dereference.d.ts +349 -0
- package/dist/internal/portable-dereference.js +702 -0
- package/dist/internal/signed-representation.cjs +378 -0
- package/dist/internal/signed-representation.d.cts +144 -0
- package/dist/internal/signed-representation.d.ts +144 -0
- package/dist/internal/signed-representation.js +371 -0
- package/dist/jsonld.cjs +2 -2
- package/dist/mod.cjs +762 -4529
- package/dist/mod.d.cts +427 -9
- package/dist/mod.d.ts +427 -10
- package/dist/mod.js +742 -4524
- package/dist/portable-6Aj-7dZJ.d.cts +160 -0
- package/dist/portable-nkTiqH0w.d.ts +160 -0
- package/dist/tests/body-DpC9p-iG.mjs +130 -0
- package/dist/tests/body-cKLBprYm.cjs +153 -0
- package/dist/tests/body.test.cjs +89 -0
- package/dist/tests/body.test.d.cts +1 -0
- package/dist/tests/body.test.d.mts +1 -0
- package/dist/tests/body.test.mjs +90 -0
- package/dist/tests/contexts-C9Lj11SC.cjs +4533 -0
- package/dist/tests/contexts-duRA_dDC.mjs +4522 -0
- package/dist/tests/decimal.test.cjs +9 -7
- package/dist/tests/decimal.test.mjs +9 -6
- package/dist/tests/digest-3FeH2Y-Q.cjs +176 -0
- package/dist/tests/digest-COC7xDiQ.mjs +141 -0
- package/dist/tests/digest.test.cjs +102 -0
- package/dist/tests/digest.test.d.cts +1 -0
- package/dist/tests/digest.test.d.mts +1 -0
- package/dist/tests/digest.test.mjs +103 -0
- package/dist/tests/docloader-DyZ1JGIl.cjs +398 -0
- package/dist/tests/docloader-tUmMeXjU.mjs +375 -0
- package/dist/tests/docloader.test.cjs +816 -39
- package/dist/tests/docloader.test.mjs +810 -34
- package/dist/tests/internal/multicodec.test.cjs +2 -3
- package/dist/tests/internal/multicodec.test.mjs +2 -2
- package/dist/tests/internal/portable-dereference.test.cjs +172 -0
- package/dist/tests/internal/portable-dereference.test.d.cts +1 -0
- package/dist/tests/internal/portable-dereference.test.d.mts +1 -0
- package/dist/tests/internal/portable-dereference.test.mjs +173 -0
- package/dist/tests/jsonld-CmDhHNTx.cjs +12 -0
- package/dist/tests/jsonld-DweIJ07b.mjs +5 -0
- package/dist/tests/jsonld-cache-BEXiiM-V.cjs +386 -0
- package/dist/tests/jsonld-cache-DFnWsLuZ.mjs +339 -0
- package/dist/tests/jsonld-cache.test.cjs +102 -298
- package/dist/tests/jsonld-cache.test.mjs +95 -289
- package/dist/tests/{key-_wXwomh_.cjs → key-C-AYkdJJ.cjs} +11 -4
- package/dist/tests/{key-CDGDH_vC.mjs → key-C2Db_TAJ.mjs} +11 -3
- package/dist/tests/key.test.cjs +6 -5
- package/dist/tests/key.test.mjs +6 -4
- package/dist/tests/{langstr-Di5AvKpB.mjs → langstr-DYRmJqFn.mjs} +5 -2
- package/dist/tests/{langstr-CbAxaeEZ.cjs → langstr-_PqsL1ae.cjs} +5 -2
- package/dist/tests/langstr.test.cjs +11 -4
- package/dist/tests/langstr.test.mjs +9 -2
- package/dist/tests/langtag-CUppHs_s.mjs +45 -0
- package/dist/tests/langtag-Czjvxfzx.cjs +50 -0
- package/dist/tests/langtag.test.cjs +45 -0
- package/dist/tests/langtag.test.d.cts +1 -0
- package/dist/tests/langtag.test.d.mts +1 -0
- package/dist/tests/langtag.test.mjs +46 -0
- package/dist/tests/link.test.cjs +2 -3
- package/dist/tests/link.test.mjs +2 -2
- package/dist/tests/multibase/multibase.test.cjs +8 -9
- package/dist/tests/multibase/multibase.test.mjs +6 -6
- package/dist/tests/{multibase-Bz_UUDtL.cjs → multibase-B5Mea7Ip.cjs} +19 -2
- package/dist/tests/{multibase-B4bvakyA.mjs → multibase-BPnF_L4e.mjs} +12 -1
- package/dist/tests/portable-dereference-DmTYDy2p.mjs +250 -0
- package/dist/tests/portable-dereference-qTLMqe2_.cjs +279 -0
- package/dist/tests/portable-media-5p8azal0.cjs +153 -0
- package/dist/tests/portable-media-B_lt9MMA.mjs +148 -0
- package/dist/tests/portable-media.test.cjs +222 -0
- package/dist/tests/portable-media.test.d.cts +1 -0
- package/dist/tests/portable-media.test.d.mts +1 -0
- package/dist/tests/portable-media.test.mjs +223 -0
- package/dist/tests/portable-workers.test.cjs +36 -0
- package/dist/tests/portable-workers.test.d.cts +2 -0
- package/dist/tests/portable-workers.test.d.mts +2 -0
- package/dist/tests/portable-workers.test.mjs +35 -0
- package/dist/tests/{request-uk51rkhO.cjs → request-BgjA9wyl.cjs} +10 -4
- package/dist/tests/{request-C8CaGwtt.mjs → request-DodZNukP.mjs} +8 -2
- package/dist/tests/request.test.cjs +7 -4
- package/dist/tests/request.test.mjs +5 -2
- package/dist/tests/signed-representation.test.cjs +588 -0
- package/dist/tests/signed-representation.test.d.cts +1 -0
- package/dist/tests/signed-representation.test.d.mts +1 -0
- package/dist/tests/signed-representation.test.mjs +589 -0
- package/dist/tests/temporal.test.cjs +1 -2
- package/dist/tests/temporal.test.mjs +1 -1
- package/dist/tests/url-BNakuZ8k.cjs +998 -0
- package/dist/tests/url-DMxmp7ZG.mjs +859 -0
- package/dist/tests/url.test.cjs +489 -6
- package/dist/tests/url.test.mjs +489 -5
- package/dist/url-DrGTR8yv.cjs +993 -0
- package/dist/url-Dzyp-NsC.js +860 -0
- package/package.json +27 -4
- package/scripts/test-bun.mjs +17 -0
- package/src/body.test.ts +125 -0
- package/src/body.ts +152 -0
- package/src/contexts/cid-v1.json +114 -0
- package/src/contexts/fep-22cd.json +21 -0
- package/src/contexts/fep-6757.json +12 -0
- package/src/contexts/joinmastodon.json +1 -1
- package/src/contexts/miscellany.json +17 -0
- package/src/contexts.ts +47 -1
- package/src/digest.test.ts +220 -0
- package/src/digest.ts +229 -0
- package/src/docloader.test.ts +1066 -27
- package/src/docloader.ts +322 -105
- package/src/internal/jsonld-cache.ts +97 -1
- package/src/internal/portable-dereference.test.ts +254 -0
- package/src/internal/portable-dereference.ts +1000 -0
- package/src/internal/signed-representation.ts +565 -0
- package/src/jsonld-cache.test.ts +89 -0
- package/src/key.test.ts +9 -0
- package/src/key.ts +11 -1
- package/src/langstr.test.ts +18 -1
- package/src/langstr.ts +6 -2
- package/src/langtag.test.ts +53 -0
- package/src/langtag.ts +76 -0
- package/src/mod.ts +29 -0
- package/src/multibase/multibase.test.ts +5 -5
- package/src/portable-media.test.ts +293 -0
- package/src/portable-media.ts +264 -0
- package/src/portable-workers.test.ts +81 -0
- package/src/portable.ts +180 -0
- package/src/preprocessor.ts +7 -0
- package/src/request.test.ts +10 -1
- package/src/request.ts +9 -1
- package/src/signed-representation.test.ts +338 -0
- package/src/url.test.ts +823 -3
- package/src/url.ts +700 -23
- package/tsdown.config.ts +2 -0
- package/dist/tests/url-CsOV_B_P.cjs +0 -482
- package/dist/tests/url-Du7RQQgP.mjs +0 -392
- package/dist/url-DD4F0ULf.cjs +0 -483
- package/dist/url-DGVbSVVi.js +0 -393
- /package/dist/{chunk-M78iaK0I.cjs → rolldown-runtime-B7lfambq.cjs} +0 -0
- /package/dist/tests/{link-NUUWCdnK.mjs → link-Cevmc87v.mjs} +0 -0
- /package/dist/tests/{link-FguCydMA.cjs → link-DlKm8bEr.cjs} +0 -0
- /package/dist/tests/{multicodec-CxGVGa91.cjs → multicodec-CLRPeW4N.cjs} +0 -0
- /package/dist/tests/{multicodec-CyFp54fI.mjs → multicodec-CRIj_05H.mjs} +0 -0
- /package/dist/tests/{chunk-C2EiDwsr.cjs → rolldown-runtime-emK7D4bc.cjs} +0 -0
|
@@ -0,0 +1,993 @@
|
|
|
1
|
+
|
|
2
|
+
const require_rolldown_runtime = require("./rolldown-runtime-B7lfambq.cjs");
|
|
3
|
+
let node_dns_promises = require("node:dns/promises");
|
|
4
|
+
node_dns_promises = require_rolldown_runtime.__toESM(node_dns_promises, 1);
|
|
5
|
+
let node_net = require("node:net");
|
|
6
|
+
//#region src/url.ts
|
|
7
|
+
var UrlError = class extends Error {
|
|
8
|
+
/**
|
|
9
|
+
* The failure category. Defaults to `"disallowed"`.
|
|
10
|
+
* `"dns"` includes lookup errors and results with no usable IP addresses.
|
|
11
|
+
* @since 2.0.29
|
|
12
|
+
*/
|
|
13
|
+
reason;
|
|
14
|
+
constructor(message, options) {
|
|
15
|
+
super(message, options);
|
|
16
|
+
this.name = "UrlError";
|
|
17
|
+
this.reason = options?.reason ?? "disallowed";
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
const PORTABLE_IRI_PATTERN = /^(ap|ap\+ef61):\/\/([^/?#]*)([^?#]*)(\?[^#]*)?(#.*)?$/i;
|
|
21
|
+
const INVALID_PERCENT_ENCODING_PATTERN = /%(?![0-9A-Fa-f]{2})/;
|
|
22
|
+
const PERCENT_ENCODING_PATTERN = /%[0-9A-Fa-f]{2}/g;
|
|
23
|
+
const DID_SCHEME_PATTERN = /^did:/i;
|
|
24
|
+
const DID_PATTERN = /^did:[a-z0-9]+:[-A-Za-z0-9._%]+(?::[-A-Za-z0-9._%]+)*$/i;
|
|
25
|
+
const DOT_SEGMENT_PATTERN = /(?:^|\/)(?:\.|%2e){1,2}(?=\/|$)/i;
|
|
26
|
+
function prepareUrlInput(iri) {
|
|
27
|
+
let prepared = iri.replace(/[\t\n\r]/g, "");
|
|
28
|
+
while (prepared.length > 0 && prepared.charCodeAt(0) <= 32) prepared = prepared.slice(1);
|
|
29
|
+
while (prepared.length > 0 && prepared.charCodeAt(prepared.length - 1) <= 32) prepared = prepared.slice(0, -1);
|
|
30
|
+
return prepared;
|
|
31
|
+
}
|
|
32
|
+
function assertPortablePathCanBeParsed(iri) {
|
|
33
|
+
const match = prepareUrlInput(iri).match(PORTABLE_IRI_PATTERN);
|
|
34
|
+
if (match != null && DOT_SEGMENT_PATTERN.test(match[3])) throw new TypeError("Portable ActivityPub IRI paths with dot segments cannot be represented as URLs.");
|
|
35
|
+
}
|
|
36
|
+
function assertCompatiblePathCanBeParsed(raw, parsed) {
|
|
37
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") return;
|
|
38
|
+
const match = prepareUrlInput(raw).match(/^https?:[\/\\]*[^/?#\\]*([^?#]*)/i);
|
|
39
|
+
if (match == null) return;
|
|
40
|
+
const rawPath = match[1].replace(/\\/g, "/");
|
|
41
|
+
const compatiblePath = parsed.pathname.startsWith(COMPATIBLE_ID_PATH_PREFIX) && COMPATIBLE_ID_DID_PATTERN.test(parsed.pathname.slice(COMPATIBLE_ID_PATH_PREFIX.length));
|
|
42
|
+
const rawCompatiblePath = rawPath.startsWith(COMPATIBLE_ID_PATH_PREFIX) && COMPATIBLE_ID_DID_PATTERN.test(rawPath.slice(COMPATIBLE_ID_PATH_PREFIX.length));
|
|
43
|
+
if ((compatiblePath || rawCompatiblePath) && DOT_SEGMENT_PATTERN.test(rawPath)) throw new TypeError("FEP-ef61 compatible identifier paths with dot segments cannot be represented as URLs.");
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Parses a JSON-LD `@id` value as an IRI, including FEP-ef61 portable
|
|
47
|
+
* ActivityPub IRIs. See {@link parseIri} for how IRIs are parsed.
|
|
48
|
+
* @param id The `@id` value.
|
|
49
|
+
* @param base The base IRI to resolve a relative `@id` against.
|
|
50
|
+
* @returns The parsed IRI, or `undefined` if `id` is missing or a blank node
|
|
51
|
+
* identifier.
|
|
52
|
+
* @throws {TypeError} If `id` is not a valid IRI.
|
|
53
|
+
* @since 2.4.0
|
|
54
|
+
*/
|
|
55
|
+
function parseJsonLdId(id, base) {
|
|
56
|
+
if (id == null || id.startsWith("_:")) return void 0;
|
|
57
|
+
try {
|
|
58
|
+
return parseIri(id, base);
|
|
59
|
+
} catch {
|
|
60
|
+
throw new TypeError("Invalid @id: " + id);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Parses an IRI as a URL, including FEP-ef61 portable ActivityPub IRIs.
|
|
65
|
+
* Portable URI and FEP-ef61 compatible identifier strings whose path contains
|
|
66
|
+
* a `.` or `..` segment, including percent-encoded spellings, throw a
|
|
67
|
+
* `TypeError`: JavaScript `URL` would otherwise identify a different object.
|
|
68
|
+
* This also applies to compatible identifier strings used as relative bases.
|
|
69
|
+
* A `URL` argument may already have lost such segments before this function
|
|
70
|
+
* receives it.
|
|
71
|
+
*
|
|
72
|
+
* Portable IRIs, e.g., `ap://did:key:z6Mk.../actor`, cannot be represented by
|
|
73
|
+
* JavaScript `URL` as they are, so the returned `URL` keeps the DID authority
|
|
74
|
+
* percent-encoded, e.g., `ap+ef61://did%3Akey%3Az6Mk.../actor`. Use
|
|
75
|
+
* {@link formatIri} to get the canonical string back.
|
|
76
|
+
* @param iri The IRI to parse.
|
|
77
|
+
* @param base The base IRI to resolve a relative IRI against.
|
|
78
|
+
* @returns The parsed IRI.
|
|
79
|
+
* @throws {TypeError} If the IRI is malformed.
|
|
80
|
+
* @since 2.4.0
|
|
81
|
+
*/
|
|
82
|
+
function parseIri(iri, base) {
|
|
83
|
+
if (iri instanceof URL) return normalizePortableUrl(iri) ?? new URL(iri.href);
|
|
84
|
+
assertPortablePathCanBeParsed(iri);
|
|
85
|
+
const portable = parsePortableIri(iri);
|
|
86
|
+
if (portable != null) return portable;
|
|
87
|
+
base = normalizeBaseIri(base);
|
|
88
|
+
if (!URL.canParse(iri, base) && iri.startsWith("at://")) return parseAtUri(iri);
|
|
89
|
+
const parsed = new URL(iri, base);
|
|
90
|
+
assertCompatiblePathCanBeParsed(iri, parsed);
|
|
91
|
+
return normalizePortableUrl(parsed) ?? parsed;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Formats a URL as an IRI, including FEP-ef61 portable ActivityPub IRIs.
|
|
95
|
+
* Portable URI and FEP-ef61 compatible identifier strings with dot segments
|
|
96
|
+
* throw a `TypeError` because their paths cannot be represented by JavaScript
|
|
97
|
+
* `URL` without normalization.
|
|
98
|
+
*
|
|
99
|
+
* Portable IRIs are formatted with the `ap+ef61:` scheme and a decoded DID
|
|
100
|
+
* authority, even if they were parsed from `ap:` IRIs. FEP-ef61 currently
|
|
101
|
+
* recommends the `ap:` scheme, so a future major version of Fedify may change
|
|
102
|
+
* the scheme this function produces. Do not compare its results as strings to
|
|
103
|
+
* tell whether two portable IRIs identify the same object; use
|
|
104
|
+
* `arePortableUrisEqual()` instead.
|
|
105
|
+
* @param iri The IRI to format.
|
|
106
|
+
* @returns The formatted IRI. A string that cannot be parsed as a URL at all
|
|
107
|
+
* is returned unchanged.
|
|
108
|
+
* @throws {TypeError} If the IRI is a malformed portable IRI or FEP-ef61
|
|
109
|
+
* compatible identifier, e.g., one with dot segments.
|
|
110
|
+
* @since 2.4.0
|
|
111
|
+
*/
|
|
112
|
+
function formatIri(iri) {
|
|
113
|
+
if (typeof iri === "string") assertPortablePathCanBeParsed(iri);
|
|
114
|
+
const parsed = parsePortableIri(iri instanceof URL ? iri.href : iri);
|
|
115
|
+
if (parsed == null) {
|
|
116
|
+
if (iri instanceof URL) return iri.href;
|
|
117
|
+
if (!URL.canParse(iri)) return iri;
|
|
118
|
+
const url = new URL(iri);
|
|
119
|
+
assertCompatiblePathCanBeParsed(iri, url);
|
|
120
|
+
return url.href;
|
|
121
|
+
}
|
|
122
|
+
return `ap+ef61://${decodePortableAuthority(parsed.host)}${parsed.pathname}${parsed.search}${parsed.hash}`;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Canonicalizes a FEP-ef61 portable ActivityPub URI for comparison.
|
|
126
|
+
*
|
|
127
|
+
* This accepts both `ap:` and `ap+ef61:` URI strings with decoded or
|
|
128
|
+
* percent-encoded DID authorities. The returned value uses the `ap+ef61:`
|
|
129
|
+
* scheme, a decoded DID authority, and no query component. Pass the raw URI
|
|
130
|
+
* string, not a `URL` object, because JavaScript `URL` normalizes opaque path
|
|
131
|
+
* segments before Fedify can compare them.
|
|
132
|
+
*
|
|
133
|
+
* The `ap+ef61:` scheme of the result is a choice of Fedify's, whereas
|
|
134
|
+
* FEP-ef61 currently canonicalizes portable URIs with the `ap:` scheme.
|
|
135
|
+
* A future major version of Fedify may change the scheme of the result, so
|
|
136
|
+
* do not persist the result as the only copy of an identifier; keep the
|
|
137
|
+
* original URI, and canonicalize it again when comparing.
|
|
138
|
+
*
|
|
139
|
+
* @param input The raw portable ActivityPub URI string to canonicalize.
|
|
140
|
+
* @returns The canonical portable ActivityPub URI string.
|
|
141
|
+
* @throws {TypeError} If the input is not a valid portable ActivityPub IRI.
|
|
142
|
+
* @since 2.4.0
|
|
143
|
+
*/
|
|
144
|
+
function canonicalizePortableUri(input) {
|
|
145
|
+
if (typeof input !== "string") throw new TypeError("Invalid portable ActivityPub IRI.");
|
|
146
|
+
const parsed = parsePortableIri(input);
|
|
147
|
+
if (parsed == null) throw new TypeError("Invalid portable ActivityPub IRI.");
|
|
148
|
+
const match = input.match(PORTABLE_IRI_PATTERN);
|
|
149
|
+
return `ap+ef61://${normalizePortableAuthority(getDidUrlOrigin(decodePortableAuthority(parsed.host)))}${normalizePortableComponent(match[3])}${match[5] == null ? "" : normalizePortableComponent(match[5])}`;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Checks whether two FEP-ef61 portable ActivityPub URIs identify the same
|
|
153
|
+
* portable object.
|
|
154
|
+
*
|
|
155
|
+
* Non-string inputs return `false`. Non-portable URI strings use strict string
|
|
156
|
+
* equality. Portable URI strings are compared through
|
|
157
|
+
* {@link canonicalizePortableUri}; malformed portable URI strings return
|
|
158
|
+
* `false` unless they are exactly equal.
|
|
159
|
+
*
|
|
160
|
+
* @since 2.4.0
|
|
161
|
+
*/
|
|
162
|
+
function arePortableUrisEqual(left, right) {
|
|
163
|
+
if (typeof left !== "string" || typeof right !== "string") return false;
|
|
164
|
+
if (left === right) return true;
|
|
165
|
+
if (!PORTABLE_IRI_PATTERN.test(left) || !PORTABLE_IRI_PATTERN.test(right)) return false;
|
|
166
|
+
try {
|
|
167
|
+
return canonicalizePortableUri(left) === canonicalizePortableUri(right);
|
|
168
|
+
} catch (error) {
|
|
169
|
+
if (error instanceof TypeError) return false;
|
|
170
|
+
throw error;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Computes an IRI's FEP-fe34 origin.
|
|
175
|
+
*
|
|
176
|
+
* HTTP(S) IRIs use their web origin. FEP-ef61 portable ActivityPub IRIs and
|
|
177
|
+
* DID URLs use their DID as a cryptographic origin.
|
|
178
|
+
*
|
|
179
|
+
* @throws {TypeError} If the IRI does not have a supported FEP-fe34 origin.
|
|
180
|
+
* @since 2.4.0
|
|
181
|
+
*/
|
|
182
|
+
function getFe34Origin(input) {
|
|
183
|
+
if (input instanceof URL) {
|
|
184
|
+
const portable = normalizePortableUrl(input);
|
|
185
|
+
if (portable != null) return getPortableCryptographicOrigin(portable);
|
|
186
|
+
if (input.protocol === "did:") return getDidUrlOrigin(input.href);
|
|
187
|
+
if (input.protocol === "http:" || input.protocol === "https:") return input.origin;
|
|
188
|
+
throw new TypeError("Unsupported FEP-fe34 origin IRI.");
|
|
189
|
+
}
|
|
190
|
+
const portable = parsePortableIri(input);
|
|
191
|
+
if (portable != null) return getPortableCryptographicOrigin(portable);
|
|
192
|
+
if (DID_SCHEME_PATTERN.test(input)) return getDidUrlOrigin(input);
|
|
193
|
+
const parsed = new URL(input);
|
|
194
|
+
if (parsed.protocol === "http:" || parsed.protocol === "https:") return parsed.origin;
|
|
195
|
+
throw new TypeError("Unsupported FEP-fe34 origin IRI.");
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Checks whether two IRIs have the same FEP-fe34 origin.
|
|
199
|
+
*
|
|
200
|
+
* Malformed or unsupported IRIs are treated as non-matching.
|
|
201
|
+
*
|
|
202
|
+
* @since 2.4.0
|
|
203
|
+
*/
|
|
204
|
+
function haveSameFe34Origin(left, right) {
|
|
205
|
+
try {
|
|
206
|
+
return getFe34Origin(left) === getFe34Origin(right);
|
|
207
|
+
} catch (error) {
|
|
208
|
+
if (error instanceof TypeError) return false;
|
|
209
|
+
throw error;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Checks whether two IRIs have the same origin. Unlike comparing
|
|
214
|
+
* `URL.origin`, which is `"null"` for URLs with non-special schemes, this
|
|
215
|
+
* compares FEP-ef61 portable ActivityPub IRIs by their schemes and DIDs, so
|
|
216
|
+
* that `ap:` and `ap+ef61:` IRIs of the same DID with decoded or
|
|
217
|
+
* percent-encoded authorities have the same origin. Other IRIs with
|
|
218
|
+
* a non-special scheme and a host are compared by their schemes and hosts.
|
|
219
|
+
*
|
|
220
|
+
* This is not an FEP-fe34 origin check: an `ap+ef61:` IRI and the `did:key`
|
|
221
|
+
* verification method of the same DID have different origins here. Use
|
|
222
|
+
* {@link haveSameFe34Origin} for that.
|
|
223
|
+
* @param left The first IRI.
|
|
224
|
+
* @param right The second IRI.
|
|
225
|
+
* @returns `true` if the IRIs have the same origin.
|
|
226
|
+
* @since 2.4.0
|
|
227
|
+
*/
|
|
228
|
+
function haveSameIriOrigin(left, right) {
|
|
229
|
+
return getComparableIriOrigin(left) === getComparableIriOrigin(right);
|
|
230
|
+
}
|
|
231
|
+
function getComparableIriOrigin(iri) {
|
|
232
|
+
iri = normalizePortableUrl(iri) ?? iri;
|
|
233
|
+
if (iri.origin !== "null") return iri.origin;
|
|
234
|
+
if (iri.host !== "") {
|
|
235
|
+
const host = iri.protocol === "ap+ef61:" ? encodeURIComponent(getDidUrlOrigin(decodePortableAuthority(iri.host))) : iri.host;
|
|
236
|
+
return `${iri.protocol}//${host}`;
|
|
237
|
+
}
|
|
238
|
+
return iri.href;
|
|
239
|
+
}
|
|
240
|
+
function getPortableCryptographicOrigin(iri) {
|
|
241
|
+
return getDidUrlOrigin(decodePortableAuthority(iri.host));
|
|
242
|
+
}
|
|
243
|
+
function getDidUrlOrigin(iri) {
|
|
244
|
+
const did = iri.split(/[/?#]/, 1)[0].replace(DID_SCHEME_PATTERN, "did:");
|
|
245
|
+
if (!DID_PATTERN.test(did)) throw new TypeError("Invalid DID URL.");
|
|
246
|
+
const parts = did.split(":");
|
|
247
|
+
parts[1] = parts[1].toLowerCase();
|
|
248
|
+
return normalizePortableAuthority(parts.join(":"));
|
|
249
|
+
}
|
|
250
|
+
function parsePortableIri(iri) {
|
|
251
|
+
const match = iri.match(PORTABLE_IRI_PATTERN);
|
|
252
|
+
if (match == null) return null;
|
|
253
|
+
const authority = getDidUrlOrigin(decodePortableAuthority(match[2]));
|
|
254
|
+
if (!DID_PATTERN.test(authority)) throw new TypeError("Invalid portable ActivityPub IRI authority.");
|
|
255
|
+
if (match[3] === "") throw new TypeError("Invalid portable ActivityPub IRI path.");
|
|
256
|
+
return new URL(`ap+ef61://${encodeURIComponent(authority)}${match[3]}${match[4] ?? ""}${match[5] ?? ""}`);
|
|
257
|
+
}
|
|
258
|
+
function normalizePortableUrl(iri) {
|
|
259
|
+
if (iri.protocol !== "ap:" && iri.protocol !== "ap+ef61:") return null;
|
|
260
|
+
const raw = `ap+ef61://${iri.host}${iri.pathname}${iri.search}${iri.hash}`;
|
|
261
|
+
assertPortablePathCanBeParsed(raw);
|
|
262
|
+
return parsePortableIri(raw);
|
|
263
|
+
}
|
|
264
|
+
function normalizeBaseIri(base) {
|
|
265
|
+
if (base == null) return void 0;
|
|
266
|
+
if (base instanceof URL) return normalizePortableUrl(base) ?? base;
|
|
267
|
+
assertPortablePathCanBeParsed(base);
|
|
268
|
+
if (URL.canParse(base)) assertCompatiblePathCanBeParsed(base, new URL(base));
|
|
269
|
+
return parsePortableIri(base) ?? (base.startsWith("at://") && !URL.canParse(".", base) ? parseAtUri(base) : base);
|
|
270
|
+
}
|
|
271
|
+
function decodePortableAuthority(authority) {
|
|
272
|
+
if (INVALID_PERCENT_ENCODING_PATTERN.test(authority)) throw new TypeError("Invalid portable ActivityPub IRI authority.");
|
|
273
|
+
if (DID_SCHEME_PATTERN.test(authority)) {
|
|
274
|
+
const decoded = authority.replace(/%25/gi, "%");
|
|
275
|
+
if (INVALID_PERCENT_ENCODING_PATTERN.test(decoded)) throw new TypeError("Invalid portable ActivityPub IRI authority.");
|
|
276
|
+
return decoded;
|
|
277
|
+
}
|
|
278
|
+
const decoded = authority.replace(/%(25|3A)/gi, (match) => match.toLowerCase() === "%3a" ? ":" : "%");
|
|
279
|
+
if (INVALID_PERCENT_ENCODING_PATTERN.test(decoded)) throw new TypeError("Invalid portable ActivityPub IRI authority.");
|
|
280
|
+
return decoded;
|
|
281
|
+
}
|
|
282
|
+
function normalizePercentEncoding(value) {
|
|
283
|
+
return value.replace(PERCENT_ENCODING_PATTERN, (match) => match.toUpperCase());
|
|
284
|
+
}
|
|
285
|
+
function normalizePortableAuthority(authority) {
|
|
286
|
+
return normalizePercentEncoding(authority).replace(PERCENT_ENCODING_PATTERN, (match) => {
|
|
287
|
+
const decoded = String.fromCharCode(Number.parseInt(match.slice(1), 16));
|
|
288
|
+
return /[A-Za-z0-9._~-]/.test(decoded) ? decoded : match;
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
function normalizePortableComponent(value) {
|
|
292
|
+
if (INVALID_PERCENT_ENCODING_PATTERN.test(value)) throw new TypeError("Invalid portable ActivityPub IRI component.");
|
|
293
|
+
return value.replace(/%[0-9A-Fa-f]{2}|[^%]+/g, (match) => {
|
|
294
|
+
if (match.startsWith("%")) {
|
|
295
|
+
const upper = match.toUpperCase();
|
|
296
|
+
const decoded = String.fromCharCode(Number.parseInt(upper.slice(1), 16));
|
|
297
|
+
return /[A-Za-z0-9._~-]/.test(decoded) ? decoded : upper;
|
|
298
|
+
}
|
|
299
|
+
try {
|
|
300
|
+
return encodeURI(match);
|
|
301
|
+
} catch (error) {
|
|
302
|
+
if (error instanceof URIError) throw new TypeError("Invalid portable ActivityPub IRI component.");
|
|
303
|
+
throw error;
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
function parseAtUri(uri) {
|
|
308
|
+
const index = uri.indexOf("/", 5);
|
|
309
|
+
const authority = index >= 0 ? uri.slice(5, index) : uri.slice(5);
|
|
310
|
+
const path = index >= 0 ? uri.slice(index) : "";
|
|
311
|
+
return new URL("at://" + encodeURIComponent(authority) + path);
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Checks whether the URL is an FEP-ef61 gateway base URI, i.e., an HTTP(S)
|
|
315
|
+
* URI with no credentials, path, query, or fragment, such as
|
|
316
|
+
* `https://example.com/`. FEP-ef61 requires every item of a portable actor's
|
|
317
|
+
* `gateways` to be such a URI. A URI with an empty query or fragment
|
|
318
|
+
* delimiter, such as `https://example.com/?`, is not a gateway base URI.
|
|
319
|
+
*
|
|
320
|
+
* Note that the `URL` class normalizes `https://example.com` to
|
|
321
|
+
* `https://example.com/`, so both are gateway base URIs.
|
|
322
|
+
* @param url The URL to check.
|
|
323
|
+
* @returns `true` if the URL is an FEP-ef61 gateway base URI.
|
|
324
|
+
* @since 2.4.0
|
|
325
|
+
*/
|
|
326
|
+
function isGatewayUrl(url) {
|
|
327
|
+
return (url.protocol === "http:" || url.protocol === "https:") && url.href === `${url.origin}/`;
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Parses and validates an FEP-ef61 gateway base URI, i.e., an HTTP(S) URI with
|
|
331
|
+
* no credentials, path, query, or fragment, such as `https://example.com`.
|
|
332
|
+
* See {@link isGatewayUrl} for the rules.
|
|
333
|
+
* @param url The gateway base URI to parse.
|
|
334
|
+
* @returns The parsed gateway base URI, whose path is `/`.
|
|
335
|
+
* @throws {TypeError} If the URI is malformed, or is not an HTTP(S) base URI
|
|
336
|
+
* with no credentials, path, query, or fragment. In the
|
|
337
|
+
* latter case, the message starts with
|
|
338
|
+
* `Invalid FEP-ef61 gateway:`.
|
|
339
|
+
* @since 2.4.0
|
|
340
|
+
*/
|
|
341
|
+
function parseGatewayUrl(url) {
|
|
342
|
+
const parsed = parseIri(url);
|
|
343
|
+
if (!isGatewayUrl(parsed)) throw new TypeError(`Invalid FEP-ef61 gateway: ${url}. FEP-ef61 gateways must be HTTP(S) base URIs with no credentials, path, query, or fragment.`);
|
|
344
|
+
return parsed;
|
|
345
|
+
}
|
|
346
|
+
const COMPATIBLE_ID_PATH_PREFIX = "/.well-known/apgateway/";
|
|
347
|
+
const COMPATIBLE_ID_DID_PATTERN = /^did(?::|%3A)/i;
|
|
348
|
+
const RAW_COMPATIBLE_ID_PREFIX_PATTERN = /^(?:[hH][tT][tT][pP][sS]?):\/\/[^/?#]*\/\.well-known\/apgateway\/(?=[dD][iI][dD](?::|%3[aA]))/;
|
|
349
|
+
const LOCATION_HINT_PARAMETERS = /* @__PURE__ */ new Set(["@gateway", "gateways"]);
|
|
350
|
+
/**
|
|
351
|
+
* Converts an [FEP-ef61] compatible identifier into a portable ActivityPub
|
|
352
|
+
* URI.
|
|
353
|
+
*
|
|
354
|
+
* A compatible identifier is an HTTP(S) URL under a gateway's fixed
|
|
355
|
+
* `/.well-known/apgateway/` path, such as
|
|
356
|
+
* `https://server.example/.well-known/apgateway/did:key:z6Mk.../objects/1`.
|
|
357
|
+
* This function removes the gateway part and returns the corresponding
|
|
358
|
+
* portable URI, e.g., `ap+ef61://did:key:z6Mk.../objects/1`, in the same
|
|
359
|
+
* internal `URL` form that {@link parseIri} produces. The path, query, and
|
|
360
|
+
* fragment are preserved, so the result is a portable URI, not a comparison
|
|
361
|
+
* form; pass its `href` to {@link canonicalizePortableUri} or
|
|
362
|
+
* {@link arePortableUrisEqual} to compare it with other portable URIs.
|
|
363
|
+
*
|
|
364
|
+
* The conversion only reveals the *claimed* portable identifier. Anyone can
|
|
365
|
+
* publish a compatible identifier for any DID on their own server, so the
|
|
366
|
+
* gateway that served it is neither the object's origin nor authorized to act
|
|
367
|
+
* for the DID. Callers must still verify the retrieved document's Object
|
|
368
|
+
* Integrity Proof against the DID, as FEP-ef61 requires, and should keep the
|
|
369
|
+
* original URL if they need the gateway as a retrieval hint.
|
|
370
|
+
*
|
|
371
|
+
* Arbitrary gateway paths are not supported.
|
|
372
|
+
*
|
|
373
|
+
* [FEP-ef61]: https://w3id.org/fep/ef61
|
|
374
|
+
*
|
|
375
|
+
* @param input The URL to convert.
|
|
376
|
+
* @returns The portable ActivityPub URI, or `null` if the input is not an
|
|
377
|
+
* HTTP(S) URL whose path starts with `/.well-known/apgateway/did:`.
|
|
378
|
+
* Other gateway routes, such as the gateway discovery endpoint and
|
|
379
|
+
* hashlink media URLs, also yield `null`.
|
|
380
|
+
* @throws {TypeError} If the input looks like a compatible identifier but is
|
|
381
|
+
* malformed, e.g., it has an invalid DID, no object path,
|
|
382
|
+
* invalid percent-encoding, credentials, or location
|
|
383
|
+
* hints (`@gateway` query parameters, or the legacy
|
|
384
|
+
* `gateways` parameter), or its raw string path would
|
|
385
|
+
* change during URL parsing. Already-parsed `URL`
|
|
386
|
+
* arguments cannot reveal segments lost by their parser.
|
|
387
|
+
* @since 2.4.0
|
|
388
|
+
*/
|
|
389
|
+
function fromCompatibleEf61Id(input) {
|
|
390
|
+
return convertCompatibleEf61Id(input)?.url ?? null;
|
|
391
|
+
}
|
|
392
|
+
function convertCompatibleEf61Id(input) {
|
|
393
|
+
let url;
|
|
394
|
+
const rawPrefix = typeof input === "string" ? input.match(RAW_COMPATIBLE_ID_PREFIX_PATTERN) : null;
|
|
395
|
+
if (input instanceof URL) url = input;
|
|
396
|
+
else if (typeof input === "string" && URL.canParse(input)) url = new URL(input);
|
|
397
|
+
else return null;
|
|
398
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") return null;
|
|
399
|
+
if (typeof input === "string" && rawPrefix == null) {
|
|
400
|
+
if (url.pathname.startsWith(COMPATIBLE_ID_PATH_PREFIX) && COMPATIBLE_ID_DID_PATTERN.test(url.pathname.slice(23))) throw new TypeError("Invalid FEP-ef61 compatible identifier.");
|
|
401
|
+
}
|
|
402
|
+
if (!url.pathname.startsWith(COMPATIBLE_ID_PATH_PREFIX)) {
|
|
403
|
+
if (rawPrefix != null) throw new TypeError("Invalid FEP-ef61 compatible identifier.");
|
|
404
|
+
return null;
|
|
405
|
+
}
|
|
406
|
+
const tail = url.pathname.slice(23);
|
|
407
|
+
if (!COMPATIBLE_ID_DID_PATTERN.test(tail)) {
|
|
408
|
+
if (rawPrefix != null) throw new TypeError("Invalid FEP-ef61 compatible identifier.");
|
|
409
|
+
return null;
|
|
410
|
+
}
|
|
411
|
+
if (url.username !== "" || url.password !== "") throw new TypeError("Invalid FEP-ef61 compatible identifier: credentials are not allowed.");
|
|
412
|
+
const iri = "ap+ef61://" + url.href.slice(url.origin.length + 23);
|
|
413
|
+
try {
|
|
414
|
+
const parsed = parsePortableIri(iri);
|
|
415
|
+
if (parsed == null) throw new TypeError("Not a portable IRI.");
|
|
416
|
+
if (typeof input === "string" && rawPrefix != null && canonicalizePortableUri("ap://" + input.slice(rawPrefix[0].length)) !== canonicalizePortableUri(iri)) throw new TypeError("URL parsing changed the portable identifier.");
|
|
417
|
+
canonicalizePortableUri(iri);
|
|
418
|
+
if ((url.search === "" ? [] : normalizePortableComponent(url.search.slice(1)).split("&")).some(isLocationHint)) throw new TypeError("Location hints are not allowed.");
|
|
419
|
+
return {
|
|
420
|
+
url: parsed,
|
|
421
|
+
iri
|
|
422
|
+
};
|
|
423
|
+
} catch (error) {
|
|
424
|
+
if (error instanceof TypeError) throw new TypeError("Invalid FEP-ef61 compatible identifier.", { cause: error });
|
|
425
|
+
throw error;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* Converts a portable ActivityPub URI into an [FEP-ef61] compatible
|
|
430
|
+
* identifier, which is an HTTP(S) URL under the gateway's fixed
|
|
431
|
+
* `/.well-known/apgateway/` path.
|
|
432
|
+
*
|
|
433
|
+
* For example, `ap+ef61://did:key:z6Mk.../objects/1` and
|
|
434
|
+
* `https://server.example` yield
|
|
435
|
+
* `https://server.example/.well-known/apgateway/did:key:z6Mk.../objects/1`.
|
|
436
|
+
* Both `ap:` and `ap+ef61:` URIs with decoded or percent-encoded DID
|
|
437
|
+
* authorities are accepted. Publishers should use the first gateway in the
|
|
438
|
+
* actor's `gateways` list, as FEP-ef61 requires.
|
|
439
|
+
*
|
|
440
|
+
* The path and fragment are preserved, with characters that are not allowed
|
|
441
|
+
* in HTTP(S) URLs percent-encoded the same way as
|
|
442
|
+
* {@link canonicalizePortableUri} does. FEP-ef61 location hints (`@gateway`
|
|
443
|
+
* query parameters, and the legacy `gateways` parameter) are removed, since
|
|
444
|
+
* compatible identifiers must not have them; other query parameters are kept
|
|
445
|
+
* in order.
|
|
446
|
+
*
|
|
447
|
+
* Arbitrary gateway paths are not supported.
|
|
448
|
+
*
|
|
449
|
+
* [FEP-ef61]: https://w3id.org/fep/ef61
|
|
450
|
+
*
|
|
451
|
+
* @param portableId The `ap:` or `ap+ef61:` URI to convert.
|
|
452
|
+
* @param gateway The gateway's HTTP(S) origin, e.g., `https://server.example`.
|
|
453
|
+
* @returns The compatible identifier.
|
|
454
|
+
* @throws {TypeError} If the portable ID is not a valid `ap:` or `ap+ef61:`
|
|
455
|
+
* URI, if its path has `.` or `..` segments (which
|
|
456
|
+
* HTTP(S) URLs cannot represent without changing the
|
|
457
|
+
* identified object), or if the gateway is
|
|
458
|
+
* not an HTTP(S) origin with no credentials, path, query,
|
|
459
|
+
* or fragment.
|
|
460
|
+
* @since 2.4.0
|
|
461
|
+
*/
|
|
462
|
+
function toCompatibleEf61Id(portableId, gateway) {
|
|
463
|
+
const gatewayUrl = parseCompatibleEf61Gateway(gateway);
|
|
464
|
+
const raw = getRawPortableIri(portableId);
|
|
465
|
+
const match = raw.match(PORTABLE_IRI_PATTERN);
|
|
466
|
+
const parsed = parsePortableIri(raw);
|
|
467
|
+
if (match == null || parsed == null) throw new TypeError("Invalid portable ActivityPub IRI.");
|
|
468
|
+
let did = decodePortableAuthority(parsed.host);
|
|
469
|
+
if (/%25/i.test(did)) did = did.replace(/%/g, "%25");
|
|
470
|
+
const path = normalizePortableComponent(match[3]);
|
|
471
|
+
if (path.split("/").some((segment) => segment === "." || segment === "..")) throw new TypeError("FEP-ef61 compatible identifiers cannot represent portable IRI paths with dot segments.");
|
|
472
|
+
const query = match[4] == null ? "" : stripLocationHints(normalizePortableComponent(match[4].slice(1)));
|
|
473
|
+
const fragment = match[5] == null ? "" : normalizePortableComponent(match[5]);
|
|
474
|
+
const result = new URL(gatewayUrl.origin + COMPATIBLE_ID_PATH_PREFIX + did + path + query + fragment);
|
|
475
|
+
const converted = convertCompatibleEf61Id(result);
|
|
476
|
+
if (converted == null || canonicalizePortableUri(converted.iri) !== canonicalizePortableUri(raw)) throw new TypeError("The portable ActivityPub IRI cannot be represented as an FEP-ef61 compatible identifier.");
|
|
477
|
+
return result;
|
|
478
|
+
}
|
|
479
|
+
function parseCompatibleEf61Gateway(gateway) {
|
|
480
|
+
const url = gateway instanceof URL ? gateway : typeof gateway === "string" && URL.canParse(gateway) ? new URL(gateway) : null;
|
|
481
|
+
if (url == null || !isGatewayUrl(url)) throw new TypeError("FEP-ef61 gateways for compatible identifiers must be HTTP(S) origins with no credentials, path, query, or fragment.");
|
|
482
|
+
return url;
|
|
483
|
+
}
|
|
484
|
+
function getRawPortableIri(portableId) {
|
|
485
|
+
if (portableId instanceof URL) {
|
|
486
|
+
if (portableId.protocol !== "ap:" && portableId.protocol !== "ap+ef61:") throw new TypeError("Invalid portable ActivityPub IRI.");
|
|
487
|
+
if (portableId.username !== "" || portableId.password !== "" || portableId.port !== "") throw new TypeError("Invalid portable ActivityPub IRI authority.");
|
|
488
|
+
return portableId.href;
|
|
489
|
+
}
|
|
490
|
+
if (typeof portableId !== "string") throw new TypeError("Invalid portable ActivityPub IRI.");
|
|
491
|
+
return portableId;
|
|
492
|
+
}
|
|
493
|
+
function stripLocationHints(query) {
|
|
494
|
+
const pairs = query.split("&").filter((pair) => !isLocationHint(pair));
|
|
495
|
+
return pairs.length < 1 ? "" : `?${pairs.join("&")}`;
|
|
496
|
+
}
|
|
497
|
+
function isLocationHint(pair) {
|
|
498
|
+
const name = pair.split("=", 1)[0].replace(/\+/g, " ");
|
|
499
|
+
try {
|
|
500
|
+
return LOCATION_HINT_PARAMETERS.has(decodeURIComponent(name));
|
|
501
|
+
} catch (error) {
|
|
502
|
+
if (error instanceof URIError) return false;
|
|
503
|
+
throw error;
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* The name of the FEP-ef61 location hint query parameter.
|
|
508
|
+
* @internal
|
|
509
|
+
*/
|
|
510
|
+
const GATEWAY_HINT_PARAMETER = "@gateway";
|
|
511
|
+
/**
|
|
512
|
+
* Parses an FEP-ef61 gateway, which has to be an HTTP(S) origin with no
|
|
513
|
+
* credentials, path, query, or fragment.
|
|
514
|
+
* @returns The gateway, or `null` if it is not a valid gateway.
|
|
515
|
+
* @internal
|
|
516
|
+
*/
|
|
517
|
+
function parseGatewayOrigin(gateway) {
|
|
518
|
+
let url;
|
|
519
|
+
if (gateway instanceof URL) url = new URL(gateway.href);
|
|
520
|
+
else if (typeof gateway === "string" && URL.canParse(gateway)) url = new URL(gateway);
|
|
521
|
+
else return null;
|
|
522
|
+
return isGatewayUrl(url) ? url : null;
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
* Returns a copy of an [FEP-ef61] portable ActivityPub URI with `@gateway`
|
|
526
|
+
* location hints for the given gateways, which tell consumers where they can
|
|
527
|
+
* retrieve the object. Put hints on *references* to portable actors, e.g.,
|
|
528
|
+
* in `actor`, `attributedTo`, `to`, or `cc`, when constructing an object, as
|
|
529
|
+
* FEP-ef61 recommends:
|
|
530
|
+
*
|
|
531
|
+
* ~~~~ typescript
|
|
532
|
+
* withGatewayHints("ap://did:key:z6Mk.../actor", [
|
|
533
|
+
* "https://server1.example",
|
|
534
|
+
* "https://server2.example",
|
|
535
|
+
* ]);
|
|
536
|
+
* // ap+ef61://did:key:z6Mk.../actor?@gateway=https%3A%2F%2Fserver1.example&@gateway=https%3A%2F%2Fserver2.example
|
|
537
|
+
* ~~~~
|
|
538
|
+
*
|
|
539
|
+
* Do not put hints on an object's own `id`. Hints do not change the
|
|
540
|
+
* identity of a portable URI, since FEP-ef61 drops the query when comparing
|
|
541
|
+
* portable URIs, but implementations that do not canonicalize portable URIs
|
|
542
|
+
* would take a hinted ID for another object. Add hints before signing the
|
|
543
|
+
* object, since its Object Integrity Proof covers its references too.
|
|
544
|
+
*
|
|
545
|
+
* The hints that the URI already has, including the legacy `gateways`
|
|
546
|
+
* parameter, are replaced. Each gateway becomes a `@gateway` query
|
|
547
|
+
* parameter whose value is its URI-encoded origin, e.g.,
|
|
548
|
+
* `@gateway=https%3A%2F%2Fserver1.example`, in the given order after the
|
|
549
|
+
* other query parameters. Duplicate gateways are dropped, and an empty list
|
|
550
|
+
* removes the hints as {@link withoutGatewayHints} does. The other query
|
|
551
|
+
* parameters, their order, and the fragment are kept, but percent-encoding
|
|
552
|
+
* is normalized the same way as {@link canonicalizePortableUri} does it.
|
|
553
|
+
*
|
|
554
|
+
* Fedify follows at most five hints when dereferencing a portable URI
|
|
555
|
+
* (three for the key ID of an HTTP Signature), so list the preferred
|
|
556
|
+
* gateways first; there is no limit on the number of hints added here.
|
|
557
|
+
*
|
|
558
|
+
* [FEP-ef61]: https://w3id.org/fep/ef61
|
|
559
|
+
*
|
|
560
|
+
* @param portableId The `ap:` or `ap+ef61:` URI. Pass the raw string rather
|
|
561
|
+
* than a `URL` if its path may have `.` or `..` segments,
|
|
562
|
+
* because the `URL` class resolves them.
|
|
563
|
+
* @param gateways The gateways, e.g., the `gateways` of the actor that the
|
|
564
|
+
* URI refers to. Each has to be an HTTP(S) origin with no
|
|
565
|
+
* credentials, path, query, or fragment.
|
|
566
|
+
* @returns The portable URI with the hints, in the same internal `URL` form
|
|
567
|
+
* as {@link parseIri} returns. Use {@link formatIri} to get its
|
|
568
|
+
* canonical string.
|
|
569
|
+
* @throws {TypeError} If the portable ID is not a valid `ap:` or `ap+ef61:`
|
|
570
|
+
* URI, e.g., it is a compatible identifier, which must
|
|
571
|
+
* not have location hints; if its path has `.` or `..`
|
|
572
|
+
* segments, which the `URL` class cannot represent; or
|
|
573
|
+
* if a gateway is invalid.
|
|
574
|
+
* @since 2.4.0
|
|
575
|
+
*/
|
|
576
|
+
function withGatewayHints(portableId, gateways) {
|
|
577
|
+
const parts = splitPortableIri(portableId);
|
|
578
|
+
if (typeof gateways === "string") throw new TypeError("The gateways must be an iterable of gateways, not a string.");
|
|
579
|
+
const hints = [];
|
|
580
|
+
const seen = /* @__PURE__ */ new Set();
|
|
581
|
+
for (const gateway of gateways) {
|
|
582
|
+
const url = parseGatewayOrigin(gateway);
|
|
583
|
+
if (url == null) throw new TypeError("FEP-ef61 gateways must be HTTP(S) origins with no credentials, path, query, or fragment: " + String(gateway));
|
|
584
|
+
if (seen.has(url.href)) continue;
|
|
585
|
+
seen.add(url.href);
|
|
586
|
+
hints.push(url);
|
|
587
|
+
}
|
|
588
|
+
return replaceGatewayHints(parts, hints);
|
|
589
|
+
}
|
|
590
|
+
/**
|
|
591
|
+
* Returns a copy of an [FEP-ef61] portable ActivityPub URI without its
|
|
592
|
+
* location hints, i.e., `@gateway` query parameters and the legacy
|
|
593
|
+
* `gateways` parameter. The other query parameters, their order, and the
|
|
594
|
+
* fragment are kept, but percent-encoding is normalized the same way as
|
|
595
|
+
* {@link canonicalizePortableUri} does it.
|
|
596
|
+
*
|
|
597
|
+
* [FEP-ef61]: https://w3id.org/fep/ef61
|
|
598
|
+
*
|
|
599
|
+
* @param portableId The `ap:` or `ap+ef61:` URI. Pass the raw string rather
|
|
600
|
+
* than a `URL` if its path may have `.` or `..` segments,
|
|
601
|
+
* because the `URL` class resolves them.
|
|
602
|
+
* @returns The portable URI without the hints, in the same internal `URL`
|
|
603
|
+
* form as {@link parseIri} returns.
|
|
604
|
+
* @throws {TypeError} If the portable ID is not a valid `ap:` or `ap+ef61:`
|
|
605
|
+
* URI, or if its path has `.` or `..` segments, which
|
|
606
|
+
* the `URL` class cannot represent.
|
|
607
|
+
* @since 2.4.0
|
|
608
|
+
*/
|
|
609
|
+
function withoutGatewayHints(portableId) {
|
|
610
|
+
return replaceGatewayHints(splitPortableIri(portableId), []);
|
|
611
|
+
}
|
|
612
|
+
/**
|
|
613
|
+
* Gets the gateways in the `@gateway` location hints of an [FEP-ef61]
|
|
614
|
+
* portable ActivityPub URI, in order. Hints that are not valid gateways,
|
|
615
|
+
* i.e., HTTP(S) origins with no credentials, path, query, or fragment, are
|
|
616
|
+
* skipped, and so are duplicates. The legacy `gateways` parameter is not
|
|
617
|
+
* read.
|
|
618
|
+
*
|
|
619
|
+
* Unlike Fedify's dereferencing, which follows at most five hints, this
|
|
620
|
+
* returns all of them.
|
|
621
|
+
*
|
|
622
|
+
* [FEP-ef61]: https://w3id.org/fep/ef61
|
|
623
|
+
*
|
|
624
|
+
* @param portableId The `ap:` or `ap+ef61:` URI.
|
|
625
|
+
* @returns The gateways, e.g., `https://server1.example/`.
|
|
626
|
+
* @throws {TypeError} If the portable ID is not a valid `ap:` or `ap+ef61:`
|
|
627
|
+
* URI.
|
|
628
|
+
* @since 2.4.0
|
|
629
|
+
*/
|
|
630
|
+
function getGatewayHints(portableId) {
|
|
631
|
+
const { query } = splitPortableIri(portableId);
|
|
632
|
+
return query == null ? [] : parseGatewayHints(query);
|
|
633
|
+
}
|
|
634
|
+
function splitPortableIri(portableId) {
|
|
635
|
+
const raw = getRawPortableIri(portableId);
|
|
636
|
+
const match = raw.match(PORTABLE_IRI_PATTERN);
|
|
637
|
+
const parsed = parsePortableIri(raw);
|
|
638
|
+
if (match == null || parsed == null) throw new TypeError("Invalid portable ActivityPub IRI.");
|
|
639
|
+
return {
|
|
640
|
+
raw,
|
|
641
|
+
parsed,
|
|
642
|
+
path: normalizePortableComponent(match[3]),
|
|
643
|
+
query: match[4] == null ? null : normalizePortableComponent(match[4].slice(1)),
|
|
644
|
+
fragment: match[5] == null ? "" : normalizePortableComponent(match[5])
|
|
645
|
+
};
|
|
646
|
+
}
|
|
647
|
+
function parseGatewayHints(query) {
|
|
648
|
+
const hints = [];
|
|
649
|
+
const seen = /* @__PURE__ */ new Set();
|
|
650
|
+
for (const hint of new URLSearchParams(`?${query}`).getAll(GATEWAY_HINT_PARAMETER)) {
|
|
651
|
+
const url = parseGatewayOrigin(hint);
|
|
652
|
+
if (url == null || seen.has(url.href)) continue;
|
|
653
|
+
seen.add(url.href);
|
|
654
|
+
hints.push(url);
|
|
655
|
+
}
|
|
656
|
+
return hints;
|
|
657
|
+
}
|
|
658
|
+
function replaceGatewayHints(parts, hints) {
|
|
659
|
+
const pairs = parts.query == null ? [] : parts.query.split("&").filter((pair) => pair !== "" && !isLocationHint(pair));
|
|
660
|
+
for (const hint of hints) pairs.push(`${GATEWAY_HINT_PARAMETER}=${encodeURIComponent(hint.origin)}`);
|
|
661
|
+
const query = pairs.length < 1 ? "" : `?${pairs.join("&")}`;
|
|
662
|
+
const result = parsePortableIri(`ap+ef61://${parts.parsed.host}${parts.path}${query}${parts.fragment}`);
|
|
663
|
+
if (result == null || canonicalizePortableUri(result.href) !== canonicalizePortableUri(parts.raw) || parseGatewayHints(result.search.slice(1)).map((url) => url.href).join(" ") !== hints.map((url) => url.href).join(" ")) throw new TypeError("The portable ActivityPub IRI cannot be represented as a URL without changing the object it refers to.");
|
|
664
|
+
return result;
|
|
665
|
+
}
|
|
666
|
+
/**
|
|
667
|
+
* Validates a URL to prevent SSRF attacks.
|
|
668
|
+
*/
|
|
669
|
+
async function validatePublicUrl(url) {
|
|
670
|
+
const parsed = new URL(url);
|
|
671
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") throw new UrlError(`Unsupported protocol: ${parsed.protocol}`);
|
|
672
|
+
let hostname = parsed.hostname;
|
|
673
|
+
if (hostname.startsWith("[") && hostname.endsWith("]")) hostname = hostname.slice(1, -1);
|
|
674
|
+
if (hostname === "localhost") throw new UrlError("Localhost is not allowed");
|
|
675
|
+
const hostnameFamily = (0, node_net.isIP)(hostname);
|
|
676
|
+
if (hostnameFamily !== 0) {
|
|
677
|
+
validatePublicIpAddress(hostname, hostnameFamily);
|
|
678
|
+
return;
|
|
679
|
+
}
|
|
680
|
+
if ("Deno" in globalThis && !(0, node_net.isIP)(hostname)) {
|
|
681
|
+
if ((await Deno.permissions.query({ name: "net" })).state !== "granted") return;
|
|
682
|
+
}
|
|
683
|
+
if ("Bun" in globalThis) {
|
|
684
|
+
if (hostname === "example.com" || hostname.endsWith(".example.com")) return;
|
|
685
|
+
else if (hostname === "fedify-test.internal") throw new UrlError("Invalid or private address: fedify-test.internal");
|
|
686
|
+
}
|
|
687
|
+
let addresses;
|
|
688
|
+
try {
|
|
689
|
+
addresses = await node_dns_promises.default.lookup(hostname, { all: true });
|
|
690
|
+
} catch (error) {
|
|
691
|
+
throw new UrlError("DNS lookup failed", {
|
|
692
|
+
cause: error,
|
|
693
|
+
reason: "dns"
|
|
694
|
+
});
|
|
695
|
+
}
|
|
696
|
+
validateLookupAddresses(addresses);
|
|
697
|
+
}
|
|
698
|
+
/**
|
|
699
|
+
* Validates the IP addresses returned by `node:dns.lookup()`.
|
|
700
|
+
*
|
|
701
|
+
* Cloudflare Workers' `node:dns` implementation currently maps every record
|
|
702
|
+
* in a DNS-over-HTTPS `Answer` array—including CNAME records—to a
|
|
703
|
+
* `LookupAddress`, even though Node.js specifies that the `address` field must
|
|
704
|
+
* contain an IPv4 or IPv6 literal. See:
|
|
705
|
+
* https://github.com/cloudflare/workerd/issues/6886
|
|
706
|
+
*
|
|
707
|
+
* Work around that bug by ignoring non-IP entries only when the lookup also
|
|
708
|
+
* returns at least one actual IP address. This remains fail-closed: a result
|
|
709
|
+
* containing no IP addresses is rejected, and every returned IP address is
|
|
710
|
+
* still validated and must be public. This workaround can be revisited once
|
|
711
|
+
* the Workerd issue is fixed in supported Cloudflare Workers runtimes.
|
|
712
|
+
*
|
|
713
|
+
* @internal
|
|
714
|
+
*/
|
|
715
|
+
function validateLookupAddresses(addresses) {
|
|
716
|
+
let ipAddressCount = 0;
|
|
717
|
+
for (const { address } of addresses) {
|
|
718
|
+
const family = (0, node_net.isIP)(address);
|
|
719
|
+
if (family === 0) continue;
|
|
720
|
+
ipAddressCount++;
|
|
721
|
+
validatePublicIpAddress(address, family);
|
|
722
|
+
}
|
|
723
|
+
if (ipAddressCount === 0) throw new UrlError("DNS lookup did not return any IP address", { reason: "dns" });
|
|
724
|
+
}
|
|
725
|
+
function validatePublicIpAddress(address, family) {
|
|
726
|
+
if (family === 4 && isValidPublicIPv4Address(address) || family === 6 && isValidPublicIPv6Address(address)) return;
|
|
727
|
+
throw new UrlError(`Invalid or private address: ${address}`);
|
|
728
|
+
}
|
|
729
|
+
function isValidPublicIPv4Address(address) {
|
|
730
|
+
const parts = parseIPv4Address(address);
|
|
731
|
+
if (parts == null) return false;
|
|
732
|
+
const value = ipv4PartsToNumber(parts);
|
|
733
|
+
return !nonPublicIPv4Prefixes.some(({ base, prefix }) => matchesIPv4Prefix(value, base, prefix));
|
|
734
|
+
}
|
|
735
|
+
function isValidPublicIPv6Address(address) {
|
|
736
|
+
const words = parseIPv6Address(address);
|
|
737
|
+
if (words == null) return false;
|
|
738
|
+
if (nonPublicIPv6Prefixes.some(({ words: prefixWords, prefix }) => matchesIPv6Prefix(words, prefixWords, prefix))) return false;
|
|
739
|
+
for (const { extractIPv4, prefix, words: prefixWords } of ipv6WithIPv4Prefixes) {
|
|
740
|
+
if (!matchesIPv6Prefix(words, prefixWords, prefix)) continue;
|
|
741
|
+
const ipv4Address = extractIPv4(words);
|
|
742
|
+
if (ipv4Address != null && !isValidPublicIPv4Address(ipv4Address)) return false;
|
|
743
|
+
}
|
|
744
|
+
return true;
|
|
745
|
+
}
|
|
746
|
+
function expandIPv6Address(address) {
|
|
747
|
+
address = address.toLowerCase();
|
|
748
|
+
const ipv4Delimiter = address.lastIndexOf(":");
|
|
749
|
+
if (address.includes(".") && ipv4Delimiter >= 0) {
|
|
750
|
+
const ipv4Parts = parseIPv4Address(address.substring(ipv4Delimiter + 1));
|
|
751
|
+
if (ipv4Parts == null) return address;
|
|
752
|
+
const high = (ipv4Parts[0] << 8) + ipv4Parts[1];
|
|
753
|
+
const low = (ipv4Parts[2] << 8) + ipv4Parts[3];
|
|
754
|
+
address = address.substring(0, ipv4Delimiter + 1) + high.toString(16) + ":" + low.toString(16);
|
|
755
|
+
}
|
|
756
|
+
if (address === "::") return "0000:0000:0000:0000:0000:0000:0000:0000";
|
|
757
|
+
if (address.startsWith("::")) address = "0000" + address;
|
|
758
|
+
if (address.endsWith("::")) address = address + "0000";
|
|
759
|
+
address = address.replace("::", ":0000".repeat(8 - (address.match(/:/g) || []).length) + ":");
|
|
760
|
+
return address.split(":").map((part) => part.padStart(4, "0")).join(":");
|
|
761
|
+
}
|
|
762
|
+
const nonPublicIPv4Prefixes = [
|
|
763
|
+
ipv4Prefix("0.0.0.0/8", "RFC 6890"),
|
|
764
|
+
ipv4Prefix("10.0.0.0/8", "RFC 1918"),
|
|
765
|
+
ipv4Prefix("100.64.0.0/10", "RFC 6598"),
|
|
766
|
+
ipv4Prefix("127.0.0.0/8", "RFC 1122"),
|
|
767
|
+
ipv4Prefix("169.254.0.0/16", "RFC 3927"),
|
|
768
|
+
ipv4Prefix("172.16.0.0/12", "RFC 1918"),
|
|
769
|
+
ipv4Prefix("192.0.0.0/24", "RFC 6890"),
|
|
770
|
+
ipv4Prefix("192.0.2.0/24", "RFC 5737"),
|
|
771
|
+
ipv4Prefix("192.88.99.0/24", "RFC 7526"),
|
|
772
|
+
ipv4Prefix("192.168.0.0/16", "RFC 1918"),
|
|
773
|
+
ipv4Prefix("198.18.0.0/15", "RFC 2544"),
|
|
774
|
+
ipv4Prefix("198.51.100.0/24", "RFC 5737"),
|
|
775
|
+
ipv4Prefix("203.0.113.0/24", "RFC 5737"),
|
|
776
|
+
ipv4Prefix("224.0.0.0/4", "RFC 5771"),
|
|
777
|
+
ipv4Prefix("240.0.0.0/4", "RFC 1112")
|
|
778
|
+
];
|
|
779
|
+
const nonPublicIPv6Prefixes = [
|
|
780
|
+
ipv6Prefix("::/16", "RFC 4291"),
|
|
781
|
+
ipv6Prefix("2001::/32", "RFC 4380"),
|
|
782
|
+
ipv6Prefix("2002::/16", "RFC 3056"),
|
|
783
|
+
ipv6Prefix("64:ff9b:1::/48", "RFC 8215"),
|
|
784
|
+
ipv6Prefix("fc00::/7", "RFC 4193"),
|
|
785
|
+
ipv6Prefix("fe80::/10", "RFC 4291"),
|
|
786
|
+
ipv6Prefix("ff00::/8", "RFC 4291")
|
|
787
|
+
];
|
|
788
|
+
const ipv6WithIPv4Prefixes = [{
|
|
789
|
+
...ipv6Prefix("64:ff9b::/96", "RFC 6052"),
|
|
790
|
+
extractIPv4: (words) => ipv4FromWords(words[6], words[7])
|
|
791
|
+
}];
|
|
792
|
+
function ipv4Prefix(cidr, rfc) {
|
|
793
|
+
const [address, prefixText] = cidr.split("/");
|
|
794
|
+
const prefix = parseInt(prefixText, 10);
|
|
795
|
+
const parts = parseIPv4Address(address);
|
|
796
|
+
if (parts == null || !Number.isInteger(prefix) || prefix < 0 || prefix > 32) throw new Error(`Invalid IPv4 prefix: ${cidr}`);
|
|
797
|
+
return {
|
|
798
|
+
cidr,
|
|
799
|
+
base: ipv4PartsToNumber(parts),
|
|
800
|
+
prefix,
|
|
801
|
+
rfc
|
|
802
|
+
};
|
|
803
|
+
}
|
|
804
|
+
function ipv6Prefix(cidr, rfc) {
|
|
805
|
+
const [address, prefixText] = cidr.split("/");
|
|
806
|
+
const prefix = parseInt(prefixText, 10);
|
|
807
|
+
const words = parseIPv6Address(address);
|
|
808
|
+
if (words == null || !Number.isInteger(prefix) || prefix < 0 || prefix > 128) throw new Error(`Invalid IPv6 prefix: ${cidr}`);
|
|
809
|
+
return {
|
|
810
|
+
cidr,
|
|
811
|
+
words,
|
|
812
|
+
prefix,
|
|
813
|
+
rfc
|
|
814
|
+
};
|
|
815
|
+
}
|
|
816
|
+
function parseIPv4Address(address) {
|
|
817
|
+
const parts = address.split(".").map((part) => {
|
|
818
|
+
if (!/^\d+$/.test(part)) return NaN;
|
|
819
|
+
return parseInt(part, 10);
|
|
820
|
+
});
|
|
821
|
+
if (parts.length !== 4 || parts.some((part) => !Number.isInteger(part) || part < 0 || part > 255)) return null;
|
|
822
|
+
return parts;
|
|
823
|
+
}
|
|
824
|
+
function parseIPv6Address(address) {
|
|
825
|
+
const parts = expandIPv6Address(address).split(":");
|
|
826
|
+
if (parts.length !== 8) return null;
|
|
827
|
+
const words = parts.map((part) => {
|
|
828
|
+
if (!/^[0-9a-f]{1,4}$/i.test(part)) return NaN;
|
|
829
|
+
return parseInt(part, 16);
|
|
830
|
+
});
|
|
831
|
+
if (words.some((word) => !Number.isInteger(word) || word < 0 || word > 65535)) return null;
|
|
832
|
+
return words;
|
|
833
|
+
}
|
|
834
|
+
function ipv4PartsToNumber(parts) {
|
|
835
|
+
return parts[0] * 2 ** 24 + parts[1] * 2 ** 16 + parts[2] * 2 ** 8 + parts[3];
|
|
836
|
+
}
|
|
837
|
+
function ipv4FromWords(highWord, lowWord) {
|
|
838
|
+
return [
|
|
839
|
+
highWord >> 8,
|
|
840
|
+
highWord & 255,
|
|
841
|
+
lowWord >> 8,
|
|
842
|
+
lowWord & 255
|
|
843
|
+
].join(".");
|
|
844
|
+
}
|
|
845
|
+
function matchesIPv4Prefix(address, prefixBase, prefixLength) {
|
|
846
|
+
const blockSize = 2 ** (32 - prefixLength);
|
|
847
|
+
return Math.floor(address / blockSize) === Math.floor(prefixBase / blockSize);
|
|
848
|
+
}
|
|
849
|
+
function matchesIPv6Prefix(address, prefixWords, prefixLength) {
|
|
850
|
+
let remaining = prefixLength;
|
|
851
|
+
for (let i = 0; i < 8 && remaining > 0; i++) if (remaining >= 16) {
|
|
852
|
+
if (address[i] !== prefixWords[i]) return false;
|
|
853
|
+
remaining -= 16;
|
|
854
|
+
} else {
|
|
855
|
+
const mask = 65535 << 16 - remaining & 65535;
|
|
856
|
+
if ((address[i] & mask) !== (prefixWords[i] & mask)) return false;
|
|
857
|
+
remaining = 0;
|
|
858
|
+
}
|
|
859
|
+
return true;
|
|
860
|
+
}
|
|
861
|
+
//#endregion
|
|
862
|
+
Object.defineProperty(exports, "GATEWAY_HINT_PARAMETER", {
|
|
863
|
+
enumerable: true,
|
|
864
|
+
get: function() {
|
|
865
|
+
return GATEWAY_HINT_PARAMETER;
|
|
866
|
+
}
|
|
867
|
+
});
|
|
868
|
+
Object.defineProperty(exports, "UrlError", {
|
|
869
|
+
enumerable: true,
|
|
870
|
+
get: function() {
|
|
871
|
+
return UrlError;
|
|
872
|
+
}
|
|
873
|
+
});
|
|
874
|
+
Object.defineProperty(exports, "arePortableUrisEqual", {
|
|
875
|
+
enumerable: true,
|
|
876
|
+
get: function() {
|
|
877
|
+
return arePortableUrisEqual;
|
|
878
|
+
}
|
|
879
|
+
});
|
|
880
|
+
Object.defineProperty(exports, "canonicalizePortableUri", {
|
|
881
|
+
enumerable: true,
|
|
882
|
+
get: function() {
|
|
883
|
+
return canonicalizePortableUri;
|
|
884
|
+
}
|
|
885
|
+
});
|
|
886
|
+
Object.defineProperty(exports, "expandIPv6Address", {
|
|
887
|
+
enumerable: true,
|
|
888
|
+
get: function() {
|
|
889
|
+
return expandIPv6Address;
|
|
890
|
+
}
|
|
891
|
+
});
|
|
892
|
+
Object.defineProperty(exports, "formatIri", {
|
|
893
|
+
enumerable: true,
|
|
894
|
+
get: function() {
|
|
895
|
+
return formatIri;
|
|
896
|
+
}
|
|
897
|
+
});
|
|
898
|
+
Object.defineProperty(exports, "fromCompatibleEf61Id", {
|
|
899
|
+
enumerable: true,
|
|
900
|
+
get: function() {
|
|
901
|
+
return fromCompatibleEf61Id;
|
|
902
|
+
}
|
|
903
|
+
});
|
|
904
|
+
Object.defineProperty(exports, "getFe34Origin", {
|
|
905
|
+
enumerable: true,
|
|
906
|
+
get: function() {
|
|
907
|
+
return getFe34Origin;
|
|
908
|
+
}
|
|
909
|
+
});
|
|
910
|
+
Object.defineProperty(exports, "getGatewayHints", {
|
|
911
|
+
enumerable: true,
|
|
912
|
+
get: function() {
|
|
913
|
+
return getGatewayHints;
|
|
914
|
+
}
|
|
915
|
+
});
|
|
916
|
+
Object.defineProperty(exports, "haveSameFe34Origin", {
|
|
917
|
+
enumerable: true,
|
|
918
|
+
get: function() {
|
|
919
|
+
return haveSameFe34Origin;
|
|
920
|
+
}
|
|
921
|
+
});
|
|
922
|
+
Object.defineProperty(exports, "haveSameIriOrigin", {
|
|
923
|
+
enumerable: true,
|
|
924
|
+
get: function() {
|
|
925
|
+
return haveSameIriOrigin;
|
|
926
|
+
}
|
|
927
|
+
});
|
|
928
|
+
Object.defineProperty(exports, "isGatewayUrl", {
|
|
929
|
+
enumerable: true,
|
|
930
|
+
get: function() {
|
|
931
|
+
return isGatewayUrl;
|
|
932
|
+
}
|
|
933
|
+
});
|
|
934
|
+
Object.defineProperty(exports, "isValidPublicIPv4Address", {
|
|
935
|
+
enumerable: true,
|
|
936
|
+
get: function() {
|
|
937
|
+
return isValidPublicIPv4Address;
|
|
938
|
+
}
|
|
939
|
+
});
|
|
940
|
+
Object.defineProperty(exports, "isValidPublicIPv6Address", {
|
|
941
|
+
enumerable: true,
|
|
942
|
+
get: function() {
|
|
943
|
+
return isValidPublicIPv6Address;
|
|
944
|
+
}
|
|
945
|
+
});
|
|
946
|
+
Object.defineProperty(exports, "parseGatewayOrigin", {
|
|
947
|
+
enumerable: true,
|
|
948
|
+
get: function() {
|
|
949
|
+
return parseGatewayOrigin;
|
|
950
|
+
}
|
|
951
|
+
});
|
|
952
|
+
Object.defineProperty(exports, "parseGatewayUrl", {
|
|
953
|
+
enumerable: true,
|
|
954
|
+
get: function() {
|
|
955
|
+
return parseGatewayUrl;
|
|
956
|
+
}
|
|
957
|
+
});
|
|
958
|
+
Object.defineProperty(exports, "parseIri", {
|
|
959
|
+
enumerable: true,
|
|
960
|
+
get: function() {
|
|
961
|
+
return parseIri;
|
|
962
|
+
}
|
|
963
|
+
});
|
|
964
|
+
Object.defineProperty(exports, "parseJsonLdId", {
|
|
965
|
+
enumerable: true,
|
|
966
|
+
get: function() {
|
|
967
|
+
return parseJsonLdId;
|
|
968
|
+
}
|
|
969
|
+
});
|
|
970
|
+
Object.defineProperty(exports, "toCompatibleEf61Id", {
|
|
971
|
+
enumerable: true,
|
|
972
|
+
get: function() {
|
|
973
|
+
return toCompatibleEf61Id;
|
|
974
|
+
}
|
|
975
|
+
});
|
|
976
|
+
Object.defineProperty(exports, "validatePublicUrl", {
|
|
977
|
+
enumerable: true,
|
|
978
|
+
get: function() {
|
|
979
|
+
return validatePublicUrl;
|
|
980
|
+
}
|
|
981
|
+
});
|
|
982
|
+
Object.defineProperty(exports, "withGatewayHints", {
|
|
983
|
+
enumerable: true,
|
|
984
|
+
get: function() {
|
|
985
|
+
return withGatewayHints;
|
|
986
|
+
}
|
|
987
|
+
});
|
|
988
|
+
Object.defineProperty(exports, "withoutGatewayHints", {
|
|
989
|
+
enumerable: true,
|
|
990
|
+
get: function() {
|
|
991
|
+
return withoutGatewayHints;
|
|
992
|
+
}
|
|
993
|
+
});
|