@fedify/fedify 2.0.0-pr.433.1601 → 2.0.0-pr.434.1659
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-BODH8--e.cjs +37786 -0
- package/dist/{actor-BYk33gpL.js → actor-DJS2ne1f.js} +200 -200
- package/dist/actor-DMgu-ZjT.d.cts +128 -0
- package/dist/{actor-DhgsJz-4.js → actor-WgMDAZc5.js} +1 -1
- package/dist/{assert_rejects-7UF4R_Qs.js → assert_rejects-DiIiJbZn.js} +1 -1
- package/dist/{assert_throws-53_pKeP3.js → assert_throws-BOO88avQ.js} +1 -1
- package/dist/authdocloader-C8Eqv2Kg.cjs +58 -0
- package/dist/{authdocloader-Bnyhgo9N.js → authdocloader-FA-VNPvw.js} +3 -3
- package/dist/{authdocloader-Dcu0wNV2.js → authdocloader-SW1oQJ7q.js} +6 -6
- package/dist/{builder-QxLyGSq9.js → builder-Cp2PpvmH.js} +4 -4
- package/dist/chunk-DqRYRqnO.cjs +34 -0
- package/dist/client-CegPX0Rn.d.cts +222 -0
- package/dist/{client-apb-XuqD.js → client-D_BQdihX.js} +2 -7
- package/dist/compat/mod.cjs +10 -0
- package/dist/compat/mod.d.cts +13 -0
- package/dist/compat/mod.d.ts +2 -2
- package/dist/compat/mod.js +5 -5
- package/dist/compat/transformers.test.js +18 -17
- package/dist/compat-DmDDELst.cjs +4 -0
- package/dist/compat-nxUqe4Z-.js +4 -0
- package/dist/{context-CDSZdQHD.d.ts → context-CQsAT7xk.d.ts} +0 -1
- package/dist/context-tVOQ76fi.d.cts +2254 -0
- package/dist/docloader-D-MrRyHl.d.cts +219 -0
- package/dist/{docloader-C5a95do5.js → docloader-DrPHprgh.js} +188 -8
- package/dist/docloader-dZO9fPIT.cjs +4861 -0
- package/dist/{esm-Bgz4xida.js → esm-CjcCcZ6s.js} +1 -1
- package/dist/federation/builder.test.js +10 -10
- package/dist/federation/collection.test.js +8 -8
- package/dist/federation/handler.test.js +26 -145
- package/dist/federation/inbox.test.js +6 -6
- package/dist/federation/keycache.test.js +4 -4
- package/dist/federation/kv.test.js +9 -8
- package/dist/federation/middleware.test.js +255 -38
- package/dist/federation/mod.cjs +29 -0
- package/dist/federation/mod.d.cts +13 -0
- package/dist/federation/mod.d.ts +1 -1
- package/dist/federation/mod.js +15 -15
- package/dist/federation/mq.test.js +10 -10
- package/dist/federation/negotiation.test.d.ts +3 -0
- package/dist/federation/negotiation.test.js +28 -0
- package/dist/federation/retry.test.js +5 -5
- package/dist/federation/router.test.js +8 -8
- package/dist/federation/send.test.js +15 -15
- package/dist/{federation-CMX7WzeL.js → federation-D1U8YY9t.js} +3 -3
- package/dist/federation-H2_En3j5.cjs +244 -0
- package/dist/{http-DNI66-5x.js → http-BPkuNd26.js} +2 -2
- package/dist/http-BS6766zs.d.cts +253 -0
- package/dist/{http-JY6wHpzI.js → http-BgQ07Ja_.js} +6 -6
- package/dist/http-CZJRJ0Pv.cjs +826 -0
- package/dist/{inbox-DQ8L0DJL.js → inbox-CCB1CbWJ.js} +1 -1
- package/dist/{key-5IrrMBg5.js → key-B_P3wH2F.js} +5 -5
- package/dist/{key-Be6l1ofa.js → key-BstbqwrH.js} +3 -3
- package/dist/{key-BPlyixfT.js → key-C0k2A_bI.js} +2 -2
- package/dist/key-C8TOf6mh.cjs +290 -0
- package/dist/key-CtA7xiw_.js +10 -0
- package/dist/key-hknDPZ-z.cjs +10 -0
- package/dist/{keycache-C4ahXsL4.js → keycache-DvDW8JPA.js} +1 -1
- package/dist/{keys-DJSYNKDA.js → keys-DzXrG_sX.js} +1 -1
- package/dist/kv-63Cil1MD.d.cts +81 -0
- package/dist/{ld-CWJxBIBV.js → ld-BcKcM_o9.js} +2 -2
- package/dist/{lookup-BnXYO054.js → lookup-C3BC8XO-.js} +4 -4
- package/dist/lookup-C3BGNQTz.cjs +137 -0
- package/dist/{lookup-C7LsgCJN.js → lookup-DbTBDJcT.js} +1 -1
- package/dist/{middleware-exe_8YIh.js → middleware-B3crRaK-.js} +50 -81
- package/dist/middleware-BWXHJSkY.cjs +17 -0
- package/dist/middleware-C4A4GTtX.cjs +4204 -0
- package/dist/middleware-CGlIdSyy.js +17 -0
- package/dist/middleware-CUWXMbGt.js +26 -0
- package/dist/{middleware-DfHez8_s.js → middleware-CXRqw8n4.js} +49 -144
- package/dist/{mod-RI3-KvUI.d.ts → mod-B26zRlH1.d.ts} +1 -1
- package/dist/mod-BClfg3ej.d.cts +266 -0
- package/dist/mod-C2tOeRkN.d.cts +1 -0
- package/dist/mod-DBQAI4v9.d.cts +80 -0
- package/dist/mod-Dc_-mf8s.d.cts +102 -0
- package/dist/mod-FZd39qVq.d.cts +1 -0
- package/dist/mod-evzlRVZq.d.cts +289 -0
- package/dist/mod-jQ4OODsl.d.cts +113 -0
- package/dist/mod.cjs +150 -0
- package/dist/mod.d.cts +17 -0
- package/dist/mod.d.ts +2 -2
- package/dist/mod.js +20 -20
- package/dist/mq-B7R1Q-M5.d.cts +140 -0
- package/dist/negotiation-5NPJL6zp.js +71 -0
- package/dist/nodeinfo/client.test.js +10 -10
- package/dist/nodeinfo/handler.test.js +23 -22
- package/dist/nodeinfo/mod.cjs +11 -0
- package/dist/nodeinfo/mod.d.cts +5 -0
- package/dist/nodeinfo/mod.js +6 -6
- package/dist/nodeinfo/types.test.js +8 -8
- package/dist/nodeinfo-Co9lJrWl.cjs +4 -0
- package/dist/nodeinfo-DfycQ8Wf.js +4 -0
- package/dist/owner-B-7Ptt_m.d.cts +67 -0
- package/dist/{owner-CM_3htrf.js → owner-BcEciLTD.js} +2 -2
- package/dist/{proof-WqatqDcH.js → proof-DAEfR6xA.js} +6 -6
- package/dist/proof-ZBmKo2zb.cjs +673 -0
- package/dist/{proof-B13S28BP.js → proof-vGquXXR6.js} +2 -2
- package/dist/runtime/authdocloader.test.js +14 -14
- package/dist/runtime/docloader.test.js +9 -9
- package/dist/runtime/key.test.js +10 -10
- package/dist/runtime/langstr.test.js +8 -8
- package/dist/runtime/link.test.d.ts +3 -0
- package/dist/runtime/link.test.js +61 -0
- package/dist/runtime/mod.cjs +25 -0
- package/dist/runtime/mod.d.cts +6 -0
- package/dist/runtime/mod.js +10 -10
- package/dist/runtime/multibase/multibase.test.js +8 -8
- package/dist/runtime/url.test.js +5 -5
- package/dist/runtime-C58AJWSv.cjs +4 -0
- package/dist/runtime-DPYEDf-o.js +4 -0
- package/dist/{send-BcaNFUhd.js → send-svmMjAUr.js} +2 -2
- package/dist/sig/http.test.js +13 -13
- package/dist/sig/key.test.js +11 -11
- package/dist/sig/ld.test.js +10 -10
- package/dist/sig/mod.cjs +30 -0
- package/dist/sig/mod.d.cts +8 -0
- package/dist/sig/mod.js +10 -10
- package/dist/sig/owner.test.js +12 -12
- package/dist/sig/proof.test.js +12 -12
- package/dist/sig-ByHXzqUi.cjs +4 -0
- package/dist/sig-Cj3tk-ig.js +4 -0
- package/dist/testing/docloader.test.js +8 -8
- package/dist/testing/mod.js +3 -3
- package/dist/{testing-CakwOL23.js → testing-y9ueu9Aj.js} +2 -2
- package/dist/{transformers-Dna8Fg7k.js → transformers-BFT6d7J5.js} +3 -3
- package/dist/transformers-CoBS-oFG.cjs +116 -0
- package/dist/{type-BKY_LVaq.js → type-9o78PXlX.js} +381 -201
- package/dist/{types-zVT9nODh.js → types-DTCqX5HE.js} +5 -10
- package/dist/types-K5btoOl6.cjs +315 -0
- package/dist/vocab/actor.test.js +10 -10
- package/dist/vocab/lookup.test.js +9 -9
- package/dist/vocab/mod.cjs +87 -0
- package/dist/vocab/mod.d.cts +6 -0
- package/dist/vocab/mod.js +7 -7
- package/dist/vocab/type.test.js +3 -3
- package/dist/vocab/vocab.test.js +45 -10
- package/dist/vocab-CJ0jQMQV.cjs +282 -0
- package/dist/{vocab-ClXayeh5.js → vocab-C_Pm3NG3.js} +6 -6
- package/dist/vocab-DJTYMqyU.d.cts +14632 -0
- package/dist/webfinger/handler.test.js +23 -22
- package/dist/webfinger/lookup.test.js +9 -9
- package/dist/webfinger/mod.cjs +9 -0
- package/dist/webfinger/mod.d.cts +4 -0
- package/dist/webfinger/mod.js +6 -6
- package/dist/webfinger-BjOEdFPs.cjs +4 -0
- package/dist/webfinger-De_bU0iE.js +4 -0
- package/dist/x/cfworkers.cjs +100 -0
- package/dist/x/cfworkers.d.cts +59 -0
- package/dist/x/cfworkers.js +3 -3
- package/dist/x/cfworkers.test.js +8 -8
- package/dist/x/hono.cjs +61 -0
- package/dist/x/hono.d.cts +54 -0
- package/dist/x/hono.d.ts +1 -1
- package/dist/x/hono.js +3 -3
- package/dist/x/sveltekit.cjs +69 -0
- package/dist/x/sveltekit.d.cts +46 -0
- package/dist/x/sveltekit.d.ts +1 -1
- package/dist/x/sveltekit.js +3 -3
- package/package.json +68 -13
- package/dist/compat-Bb5myD13.js +0 -4
- package/dist/key-BLStGL0R.js +0 -10
- package/dist/middleware-D2diREI8.js +0 -17
- package/dist/middleware-D5PCuUVh.js +0 -25
- package/dist/nodeinfo-CyEbLjHs.js +0 -4
- package/dist/runtime-BSkOVUWM.js +0 -4
- package/dist/sig-BXJO--F9.js +0 -4
- package/dist/webfinger-C3GIyXIg.js +0 -4
- /package/dist/{assert_is_error-B035L3om.js → assert_is_error-BPGph1Jx.js} +0 -0
- /package/dist/{assert_not_equals-C80BG-_5.js → assert_not_equals-f3m3epl3.js} +0 -0
- /package/dist/{denokv-jZ0Z2h0M.js → denokv-Bv33Xxea.js} +0 -0
- /package/dist/{retry-CfF8Gn4d.js → retry-D4GJ670a.js} +0 -0
- /package/dist/{std__assert-DWivtrGR.js → std__assert-X-_kMxKM.js} +0 -0
@@ -1,8 +1,8 @@
|
|
1
1
|
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
import { getUserAgent } from "./docloader-
|
2
|
+
import { Temporal } from "@js-temporal/polyfill";
|
3
|
+
import { URLPattern } from "urlpattern-polyfill";
|
4
|
+
|
5
|
+
import { getUserAgent } from "./docloader-DrPHprgh.js";
|
6
6
|
import { getLogger } from "@logtape/logtape";
|
7
7
|
|
8
8
|
//#region src/nodeinfo/client.ts
|
@@ -131,12 +131,7 @@ function parseSoftware(data, options = {}) {
|
|
131
131
|
name = data.name.trim().toLowerCase();
|
132
132
|
} else return null;
|
133
133
|
let version;
|
134
|
-
if ("version" in data)
|
135
|
-
version = String(data.version);
|
136
|
-
} catch {
|
137
|
-
if (!options.tryBestEffort) return null;
|
138
|
-
version = "0.0.0";
|
139
|
-
}
|
134
|
+
if ("version" in data) version = String(data.version);
|
140
135
|
else {
|
141
136
|
if (!options.tryBestEffort) return null;
|
142
137
|
version = "0.0.0";
|
@@ -0,0 +1,315 @@
|
|
1
|
+
|
2
|
+
const { Temporal } = require("@js-temporal/polyfill");
|
3
|
+
const { URLPattern } = require("urlpattern-polyfill");
|
4
|
+
|
5
|
+
const require_chunk = require('./chunk-DqRYRqnO.cjs');
|
6
|
+
const require_docloader = require('./docloader-dZO9fPIT.cjs');
|
7
|
+
const __logtape_logtape = require_chunk.__toESM(require("@logtape/logtape"));
|
8
|
+
|
9
|
+
//#region src/nodeinfo/client.ts
|
10
|
+
const logger = (0, __logtape_logtape.getLogger)([
|
11
|
+
"fedify",
|
12
|
+
"nodeinfo",
|
13
|
+
"client"
|
14
|
+
]);
|
15
|
+
async function getNodeInfo(url, options = {}) {
|
16
|
+
try {
|
17
|
+
let nodeInfoUrl = url;
|
18
|
+
if (!options.direct) {
|
19
|
+
const wellKnownUrl = new URL("/.well-known/nodeinfo", url);
|
20
|
+
const wellKnownResponse = await fetch(wellKnownUrl, { headers: {
|
21
|
+
Accept: "application/json",
|
22
|
+
"User-Agent": typeof options.userAgent === "string" ? options.userAgent : require_docloader.getUserAgent(options.userAgent)
|
23
|
+
} });
|
24
|
+
if (!wellKnownResponse.ok) {
|
25
|
+
logger.error("Failed to fetch {url}: {status} {statusText}", {
|
26
|
+
url: wellKnownUrl.href,
|
27
|
+
status: wellKnownResponse.status,
|
28
|
+
statusText: wellKnownResponse.statusText
|
29
|
+
});
|
30
|
+
return void 0;
|
31
|
+
}
|
32
|
+
const wellKnownRd = await wellKnownResponse.json();
|
33
|
+
const link = wellKnownRd?.links?.find((link$1) => link$1 != null && "rel" in link$1 && (link$1.rel === "http://nodeinfo.diaspora.software/ns/schema/2.0" || link$1.rel === "http://nodeinfo.diaspora.software/ns/schema/2.1") && "href" in link$1 && link$1.href != null);
|
34
|
+
if (link == null || link.href == null) {
|
35
|
+
logger.error("Failed to find a NodeInfo document link from {url}: {resourceDescriptor}", {
|
36
|
+
url: wellKnownUrl.href,
|
37
|
+
resourceDescriptor: wellKnownRd
|
38
|
+
});
|
39
|
+
return void 0;
|
40
|
+
}
|
41
|
+
nodeInfoUrl = link.href;
|
42
|
+
}
|
43
|
+
const response = await fetch(nodeInfoUrl, { headers: {
|
44
|
+
Accept: "application/json",
|
45
|
+
"User-Agent": typeof options.userAgent === "string" ? options.userAgent : require_docloader.getUserAgent(options.userAgent)
|
46
|
+
} });
|
47
|
+
if (!response.ok) {
|
48
|
+
logger.error("Failed to fetch NodeInfo document from {url}: {status} {statusText}", {
|
49
|
+
url: nodeInfoUrl.toString(),
|
50
|
+
status: response.status,
|
51
|
+
statusText: response.statusText
|
52
|
+
});
|
53
|
+
return void 0;
|
54
|
+
}
|
55
|
+
const data = await response.json();
|
56
|
+
if (options.parse === "none") return data;
|
57
|
+
return parseNodeInfo(data, { tryBestEffort: options.parse === "best-effort" }) ?? void 0;
|
58
|
+
} catch (error) {
|
59
|
+
logger.error("Failed to fetch NodeInfo document from {url}: {error}", {
|
60
|
+
url: url.toString(),
|
61
|
+
error
|
62
|
+
});
|
63
|
+
return void 0;
|
64
|
+
}
|
65
|
+
}
|
66
|
+
/**
|
67
|
+
* Parses a NodeInfo document.
|
68
|
+
* @param data A JSON value that complies with the NodeInfo schema.
|
69
|
+
* @param options Options for parsing the NodeInfo document.
|
70
|
+
* @returns The parsed NodeInfo document if it is valid. Otherwise, `null`
|
71
|
+
* is returned.
|
72
|
+
* @since 1.2.0
|
73
|
+
*/
|
74
|
+
function parseNodeInfo(data, options = {}) {
|
75
|
+
if (typeof data !== "object" || data == null || !("software" in data)) return null;
|
76
|
+
const software = parseSoftware(data.software, options);
|
77
|
+
if (software == null) return null;
|
78
|
+
let protocols = [];
|
79
|
+
if ("protocols" in data && Array.isArray(data.protocols)) {
|
80
|
+
const ps = data.protocols.map(parseProtocol);
|
81
|
+
protocols = ps.filter((p) => p != null);
|
82
|
+
if (ps.length != protocols.length && !options.tryBestEffort) return null;
|
83
|
+
} else if (!options.tryBestEffort) return null;
|
84
|
+
let services;
|
85
|
+
if ("services" in data) {
|
86
|
+
if (typeof data.services === "object" && data.services != null) {
|
87
|
+
const ss = parseServices(data.services, options);
|
88
|
+
if (ss == null) {
|
89
|
+
if (!options.tryBestEffort) return null;
|
90
|
+
} else services = ss;
|
91
|
+
} else if (!options.tryBestEffort) return null;
|
92
|
+
}
|
93
|
+
let openRegistrations;
|
94
|
+
if ("openRegistrations" in data) {
|
95
|
+
if (typeof data.openRegistrations === "boolean") openRegistrations = data.openRegistrations;
|
96
|
+
else if (!options.tryBestEffort) return null;
|
97
|
+
}
|
98
|
+
let usage = {
|
99
|
+
users: {},
|
100
|
+
localPosts: 0,
|
101
|
+
localComments: 0
|
102
|
+
};
|
103
|
+
if ("usage" in data) {
|
104
|
+
const u = parseUsage(data.usage, options);
|
105
|
+
if (u == null) {
|
106
|
+
if (!options.tryBestEffort) return null;
|
107
|
+
} else usage = u;
|
108
|
+
}
|
109
|
+
let metadata;
|
110
|
+
if ("metadata" in data) {
|
111
|
+
if (typeof data.metadata === "object" && data.metadata != null) metadata = Object.fromEntries(Object.entries(data.metadata));
|
112
|
+
else if (!options.tryBestEffort) return null;
|
113
|
+
}
|
114
|
+
const result = {
|
115
|
+
software,
|
116
|
+
protocols,
|
117
|
+
usage
|
118
|
+
};
|
119
|
+
if (services != null) result.services = services;
|
120
|
+
if (openRegistrations != null) result.openRegistrations = openRegistrations;
|
121
|
+
if (metadata != null) result.metadata = metadata;
|
122
|
+
return result;
|
123
|
+
}
|
124
|
+
function parseSoftware(data, options = {}) {
|
125
|
+
if (typeof data !== "object" || data == null) {
|
126
|
+
if (!options.tryBestEffort) data = {};
|
127
|
+
return null;
|
128
|
+
}
|
129
|
+
let name;
|
130
|
+
if ("name" in data && typeof data.name === "string" && data.name.match(/^\s*[A-Za-z0-9-]+\s*$/)) {
|
131
|
+
if (!data.name.match(/^[a-z0-9-]+$/) && !options.tryBestEffort) return null;
|
132
|
+
name = data.name.trim().toLowerCase();
|
133
|
+
} else return null;
|
134
|
+
let version;
|
135
|
+
if ("version" in data) version = String(data.version);
|
136
|
+
else {
|
137
|
+
if (!options.tryBestEffort) return null;
|
138
|
+
version = "0.0.0";
|
139
|
+
}
|
140
|
+
let repository;
|
141
|
+
if ("repository" in data) {
|
142
|
+
if (typeof data.repository === "string") try {
|
143
|
+
repository = new URL(data.repository);
|
144
|
+
} catch {
|
145
|
+
if (!options.tryBestEffort) return null;
|
146
|
+
}
|
147
|
+
else if (!options.tryBestEffort) return null;
|
148
|
+
}
|
149
|
+
let homepage;
|
150
|
+
if ("homepage" in data) {
|
151
|
+
if (typeof data.homepage === "string") try {
|
152
|
+
homepage = new URL(data.homepage);
|
153
|
+
} catch {
|
154
|
+
if (!options.tryBestEffort) return null;
|
155
|
+
}
|
156
|
+
else if (!options.tryBestEffort) return null;
|
157
|
+
}
|
158
|
+
const result = {
|
159
|
+
name,
|
160
|
+
version
|
161
|
+
};
|
162
|
+
if (repository != null) result.repository = repository;
|
163
|
+
if (homepage != null) result.homepage = homepage;
|
164
|
+
return result;
|
165
|
+
}
|
166
|
+
function parseProtocol(data) {
|
167
|
+
if (data === "activitypub" || data === "buddycloud" || data === "dfrn" || data === "diaspora" || data === "libertree" || data === "ostatus" || data === "pumpio" || data === "tent" || data === "xmpp" || data === "zot") return data;
|
168
|
+
return null;
|
169
|
+
}
|
170
|
+
function parseServices(data, options = {}) {
|
171
|
+
if (!(typeof data === "object") || data == null) {
|
172
|
+
if (options.tryBestEffort) return {};
|
173
|
+
return null;
|
174
|
+
}
|
175
|
+
let inbound;
|
176
|
+
if ("inbound" in data && Array.isArray(data.inbound)) {
|
177
|
+
const is = data.inbound.map(parseInboundService);
|
178
|
+
inbound = is.filter((i) => i != null);
|
179
|
+
if (is.length > inbound.length && !options.tryBestEffort) return null;
|
180
|
+
}
|
181
|
+
let outbound;
|
182
|
+
if ("outbound" in data && Array.isArray(data.outbound)) {
|
183
|
+
const os = data.outbound.map(parseOutboundService);
|
184
|
+
outbound = os.filter((o) => o != null);
|
185
|
+
if (os.length > outbound.length && !options.tryBestEffort) return null;
|
186
|
+
}
|
187
|
+
const result = {};
|
188
|
+
if (inbound != null) result.inbound = inbound;
|
189
|
+
if (outbound != null) result.outbound = outbound;
|
190
|
+
return result;
|
191
|
+
}
|
192
|
+
function parseInboundService(data) {
|
193
|
+
if (data === "atom1.0" || data === "gnusocial" || data === "imap" || data === "pnut" || data === "pop3" || data === "pumpio" || data === "rss2.0" || data === "twitter") return data;
|
194
|
+
return null;
|
195
|
+
}
|
196
|
+
function parseOutboundService(data) {
|
197
|
+
if (data === "atom1.0" || data === "blogger" || data === "buddycloud" || data === "diaspora" || data === "dreamwidth" || data === "drupal" || data === "facebook" || data === "friendica" || data === "gnusocial" || data === "google" || data === "insanejournal" || data === "libertree" || data === "linkedin" || data === "livejournal" || data === "mediagoblin" || data === "myspace" || data === "pinterest" || data === "pnut" || data === "posterous" || data === "pumpio" || data === "redmatrix" || data === "rss2.0" || data === "smtp" || data === "tent" || data === "tumblr" || data === "twitter" || data === "wordpress" || data === "xmpp") return data;
|
198
|
+
return null;
|
199
|
+
}
|
200
|
+
function parseUsage(data, options = {}) {
|
201
|
+
if (typeof data !== "object" || data == null) return null;
|
202
|
+
const users = {};
|
203
|
+
if ("users" in data && typeof data.users === "object" && data.users != null) {
|
204
|
+
if ("total" in data.users) if (typeof data.users.total === "number") users.total = data.users.total;
|
205
|
+
else {
|
206
|
+
if (!options.tryBestEffort) return null;
|
207
|
+
if (typeof data.users.total === "string") {
|
208
|
+
const n = parseInt(data.users.total);
|
209
|
+
if (!isNaN(n)) users.total = n;
|
210
|
+
}
|
211
|
+
}
|
212
|
+
if ("activeHalfyear" in data.users) if (typeof data.users.activeHalfyear === "number") users.activeHalfyear = data.users.activeHalfyear;
|
213
|
+
else {
|
214
|
+
if (!options.tryBestEffort) return null;
|
215
|
+
if (typeof data.users.activeHalfyear === "string") {
|
216
|
+
const n = parseInt(data.users.activeHalfyear);
|
217
|
+
if (!isNaN(n)) users.activeHalfyear = n;
|
218
|
+
}
|
219
|
+
}
|
220
|
+
if ("activeMonth" in data.users) if (typeof data.users.activeMonth === "number") users.activeMonth = data.users.activeMonth;
|
221
|
+
else {
|
222
|
+
if (!options.tryBestEffort) return null;
|
223
|
+
if (typeof data.users.activeMonth === "string") {
|
224
|
+
const n = parseInt(data.users.activeMonth);
|
225
|
+
if (!isNaN(n)) users.activeMonth = n;
|
226
|
+
}
|
227
|
+
}
|
228
|
+
} else if (!options.tryBestEffort) return null;
|
229
|
+
let localPosts = 0;
|
230
|
+
if ("localPosts" in data) if (typeof data.localPosts === "number") localPosts = data.localPosts;
|
231
|
+
else {
|
232
|
+
if (!options.tryBestEffort) return null;
|
233
|
+
if (typeof data.localPosts === "string") {
|
234
|
+
const n = parseInt(data.localPosts);
|
235
|
+
if (!isNaN(n)) localPosts = n;
|
236
|
+
}
|
237
|
+
}
|
238
|
+
let localComments = 0;
|
239
|
+
if ("localComments" in data) if (typeof data.localComments === "number") localComments = data.localComments;
|
240
|
+
else {
|
241
|
+
if (!options.tryBestEffort) return null;
|
242
|
+
if (typeof data.localComments === "string") {
|
243
|
+
const n = parseInt(data.localComments);
|
244
|
+
if (!isNaN(n)) localComments = n;
|
245
|
+
}
|
246
|
+
}
|
247
|
+
return {
|
248
|
+
users,
|
249
|
+
localPosts,
|
250
|
+
localComments
|
251
|
+
};
|
252
|
+
}
|
253
|
+
|
254
|
+
//#endregion
|
255
|
+
//#region src/nodeinfo/types.ts
|
256
|
+
/**
|
257
|
+
* Converts a {@link NodeInfo} object to a JSON value.
|
258
|
+
* @param nodeInfo The {@link NodeInfo} object to convert.
|
259
|
+
* @returns The JSON value that complies with the NodeInfo schema.
|
260
|
+
* @throws {TypeError} If the {@link NodeInfo} object is invalid.
|
261
|
+
*/
|
262
|
+
function nodeInfoToJson(nodeInfo) {
|
263
|
+
if (!nodeInfo.software.name.match(/^[a-z0-9-]+$/)) throw new TypeError("Invalid software name.");
|
264
|
+
if (nodeInfo.protocols.length < 1) throw new TypeError("At least one protocol must be supported.");
|
265
|
+
if (nodeInfo.usage.users.total != null && (nodeInfo.usage.users.total < 0 || !Number.isInteger(nodeInfo.usage.users.total))) throw new TypeError("Invalid total users.");
|
266
|
+
if (nodeInfo.usage.users.activeHalfyear != null && (nodeInfo.usage.users.activeHalfyear < 0 || !Number.isInteger(nodeInfo.usage.users.activeHalfyear))) throw new TypeError("Invalid active halfyear users.");
|
267
|
+
if (nodeInfo.usage.users.activeMonth != null && (nodeInfo.usage.users.activeMonth < 0 || !Number.isInteger(nodeInfo.usage.users.activeMonth))) throw new TypeError("Invalid active month users.");
|
268
|
+
if (nodeInfo.usage.localPosts < 0 || !Number.isInteger(nodeInfo.usage.localPosts)) throw new TypeError("Invalid local posts.");
|
269
|
+
if (nodeInfo.usage.localComments < 0 || !Number.isInteger(nodeInfo.usage.localComments)) throw new TypeError("Invalid local comments.");
|
270
|
+
return {
|
271
|
+
"$schema": "http://nodeinfo.diaspora.software/ns/schema/2.1#",
|
272
|
+
version: "2.1",
|
273
|
+
software: {
|
274
|
+
name: nodeInfo.software.name,
|
275
|
+
version: nodeInfo.software.version,
|
276
|
+
repository: nodeInfo.software.repository?.href,
|
277
|
+
homepage: nodeInfo.software.homepage?.href
|
278
|
+
},
|
279
|
+
protocols: nodeInfo.protocols,
|
280
|
+
services: nodeInfo.services == null ? {
|
281
|
+
inbound: [],
|
282
|
+
outbound: []
|
283
|
+
} : {
|
284
|
+
inbound: nodeInfo.services.inbound ?? [],
|
285
|
+
outbound: nodeInfo.services.outbound ?? []
|
286
|
+
},
|
287
|
+
openRegistrations: nodeInfo.openRegistrations ?? false,
|
288
|
+
usage: {
|
289
|
+
users: nodeInfo.usage.users,
|
290
|
+
localPosts: nodeInfo.usage.localPosts,
|
291
|
+
localComments: nodeInfo.usage.localComments
|
292
|
+
},
|
293
|
+
metadata: nodeInfo.metadata ?? {}
|
294
|
+
};
|
295
|
+
}
|
296
|
+
|
297
|
+
//#endregion
|
298
|
+
Object.defineProperty(exports, 'getNodeInfo', {
|
299
|
+
enumerable: true,
|
300
|
+
get: function () {
|
301
|
+
return getNodeInfo;
|
302
|
+
}
|
303
|
+
});
|
304
|
+
Object.defineProperty(exports, 'nodeInfoToJson', {
|
305
|
+
enumerable: true,
|
306
|
+
get: function () {
|
307
|
+
return nodeInfoToJson;
|
308
|
+
}
|
309
|
+
});
|
310
|
+
Object.defineProperty(exports, 'parseNodeInfo', {
|
311
|
+
enumerable: true,
|
312
|
+
get: function () {
|
313
|
+
return parseNodeInfo;
|
314
|
+
}
|
315
|
+
});
|
package/dist/vocab/actor.test.js
CHANGED
@@ -3,19 +3,19 @@
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
4
4
|
globalThis.addEventListener = () => {};
|
5
5
|
|
6
|
-
import { Application, Group, Organization, Person, Service, __export } from "../type-
|
6
|
+
import { Application, Group, Organization, Person, Service, __export } from "../type-9o78PXlX.js";
|
7
7
|
import { assertEquals } from "../assert_equals-DSbWqCm3.js";
|
8
8
|
import { assert } from "../assert-MZs1qjMx.js";
|
9
9
|
import "../assert_instance_of-DHz7EHNU.js";
|
10
|
-
import "../lookup-
|
11
|
-
import { getActorClassByTypeName, getActorHandle, getActorTypeName, isActor, normalizeActorHandle } from "../actor-
|
12
|
-
import { test } from "../testing-
|
13
|
-
import { assertStrictEquals } from "../std__assert-
|
14
|
-
import { assertFalse, assertRejects } from "../assert_rejects-
|
15
|
-
import "../assert_is_error-
|
16
|
-
import "../assert_not_equals-
|
17
|
-
import { assertThrows } from "../assert_throws-
|
18
|
-
import { esm_default } from "../esm-
|
10
|
+
import "../lookup-DbTBDJcT.js";
|
11
|
+
import { getActorClassByTypeName, getActorHandle, getActorTypeName, isActor, normalizeActorHandle } from "../actor-WgMDAZc5.js";
|
12
|
+
import { test } from "../testing-y9ueu9Aj.js";
|
13
|
+
import { assertStrictEquals } from "../std__assert-X-_kMxKM.js";
|
14
|
+
import { assertFalse, assertRejects } from "../assert_rejects-DiIiJbZn.js";
|
15
|
+
import "../assert_is_error-BPGph1Jx.js";
|
16
|
+
import "../assert_not_equals-f3m3epl3.js";
|
17
|
+
import { assertThrows } from "../assert_throws-BOO88avQ.js";
|
18
|
+
import { esm_default } from "../esm-CjcCcZ6s.js";
|
19
19
|
|
20
20
|
//#region ../../node_modules/.pnpm/fast-check@3.23.2/node_modules/fast-check/lib/esm/check/precondition/PreconditionFailure.js
|
21
21
|
var PreconditionFailure = class PreconditionFailure extends Error {
|
@@ -3,18 +3,18 @@
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
4
4
|
globalThis.addEventListener = () => {};
|
5
5
|
|
6
|
-
import { Collection, Note, Object as Object$1, Person } from "../type-
|
6
|
+
import { Collection, Note, Object as Object$1, Person } from "../type-9o78PXlX.js";
|
7
7
|
import { assertEquals } from "../assert_equals-DSbWqCm3.js";
|
8
8
|
import "../assert-MZs1qjMx.js";
|
9
9
|
import { assertInstanceOf } from "../assert_instance_of-DHz7EHNU.js";
|
10
|
-
import { lookupObject, traverseCollection } from "../lookup-
|
11
|
-
import { mockDocumentLoader, test } from "../testing-
|
12
|
-
import "../std__assert-
|
13
|
-
import "../assert_rejects-
|
14
|
-
import "../assert_is_error-
|
15
|
-
import "../assert_not_equals-
|
16
|
-
import "../assert_throws-
|
17
|
-
import { esm_default } from "../esm-
|
10
|
+
import { lookupObject, traverseCollection } from "../lookup-DbTBDJcT.js";
|
11
|
+
import { mockDocumentLoader, test } from "../testing-y9ueu9Aj.js";
|
12
|
+
import "../std__assert-X-_kMxKM.js";
|
13
|
+
import "../assert_rejects-DiIiJbZn.js";
|
14
|
+
import "../assert_is_error-BPGph1Jx.js";
|
15
|
+
import "../assert_not_equals-f3m3epl3.js";
|
16
|
+
import "../assert_throws-BOO88avQ.js";
|
17
|
+
import { esm_default } from "../esm-CjcCcZ6s.js";
|
18
18
|
|
19
19
|
//#region src/vocab/lookup.test.ts
|
20
20
|
test("lookupObject()", {
|
@@ -0,0 +1,87 @@
|
|
1
|
+
|
2
|
+
const { Temporal } = require("@js-temporal/polyfill");
|
3
|
+
const { URLPattern } = require("urlpattern-polyfill");
|
4
|
+
|
5
|
+
require('../docloader-dZO9fPIT.cjs');
|
6
|
+
const require_actor = require('../actor-BODH8--e.cjs');
|
7
|
+
require('../lookup-C3BGNQTz.cjs');
|
8
|
+
const require_vocab = require('../vocab-CJ0jQMQV.cjs');
|
9
|
+
|
10
|
+
exports.Accept = require_actor.Accept;
|
11
|
+
exports.Activity = require_actor.Activity;
|
12
|
+
exports.Add = require_actor.Add;
|
13
|
+
exports.Announce = require_actor.Announce;
|
14
|
+
exports.Application = require_actor.Application;
|
15
|
+
exports.Arrive = require_actor.Arrive;
|
16
|
+
exports.Article = require_actor.Article;
|
17
|
+
exports.Audio = require_actor.Audio;
|
18
|
+
exports.Block = require_actor.Block;
|
19
|
+
exports.ChatMessage = require_actor.ChatMessage;
|
20
|
+
exports.Collection = require_actor.Collection;
|
21
|
+
exports.CollectionPage = require_actor.CollectionPage;
|
22
|
+
exports.Create = require_actor.Create;
|
23
|
+
exports.CryptographicKey = require_actor.CryptographicKey;
|
24
|
+
exports.DataIntegrityProof = require_actor.DataIntegrityProof;
|
25
|
+
exports.Delete = require_actor.Delete;
|
26
|
+
exports.DidService = require_actor.DidService;
|
27
|
+
exports.Dislike = require_actor.Dislike;
|
28
|
+
exports.Document = require_actor.Document;
|
29
|
+
exports.Emoji = require_actor.Emoji;
|
30
|
+
exports.EmojiReact = require_actor.EmojiReact;
|
31
|
+
exports.Endpoints = require_actor.Endpoints;
|
32
|
+
exports.Event = require_actor.Event;
|
33
|
+
exports.Export = require_actor.Export;
|
34
|
+
exports.Flag = require_actor.Flag;
|
35
|
+
exports.Follow = require_actor.Follow;
|
36
|
+
exports.Group = require_actor.Group;
|
37
|
+
exports.Hashtag = require_actor.Hashtag;
|
38
|
+
exports.Ignore = require_actor.Ignore;
|
39
|
+
exports.Image = require_actor.Image;
|
40
|
+
exports.IntransitiveActivity = require_actor.IntransitiveActivity;
|
41
|
+
exports.Invite = require_actor.Invite;
|
42
|
+
exports.Join = require_actor.Join;
|
43
|
+
exports.Leave = require_actor.Leave;
|
44
|
+
exports.Like = require_actor.Like;
|
45
|
+
exports.Link = require_actor.Link;
|
46
|
+
exports.Listen = require_actor.Listen;
|
47
|
+
exports.Mention = require_actor.Mention;
|
48
|
+
exports.Move = require_actor.Move;
|
49
|
+
exports.Multikey = require_actor.Multikey;
|
50
|
+
exports.Note = require_actor.Note;
|
51
|
+
exports.Object = require_actor.Object$1;
|
52
|
+
exports.Offer = require_actor.Offer;
|
53
|
+
exports.OrderedCollection = require_actor.OrderedCollection;
|
54
|
+
exports.OrderedCollectionPage = require_actor.OrderedCollectionPage;
|
55
|
+
exports.Organization = require_actor.Organization;
|
56
|
+
exports.PUBLIC_COLLECTION = require_vocab.PUBLIC_COLLECTION;
|
57
|
+
exports.Page = require_actor.Page;
|
58
|
+
exports.Person = require_actor.Person;
|
59
|
+
exports.Place = require_actor.Place;
|
60
|
+
exports.Profile = require_actor.Profile;
|
61
|
+
exports.PropertyValue = require_actor.PropertyValue;
|
62
|
+
exports.Question = require_actor.Question;
|
63
|
+
exports.Read = require_actor.Read;
|
64
|
+
exports.Reject = require_actor.Reject;
|
65
|
+
exports.Relationship = require_actor.Relationship;
|
66
|
+
exports.Remove = require_actor.Remove;
|
67
|
+
exports.Service = require_actor.Service;
|
68
|
+
exports.Source = require_actor.Source;
|
69
|
+
exports.TentativeAccept = require_actor.TentativeAccept;
|
70
|
+
exports.TentativeReject = require_actor.TentativeReject;
|
71
|
+
exports.Tombstone = require_actor.Tombstone;
|
72
|
+
exports.Travel = require_actor.Travel;
|
73
|
+
exports.Undo = require_actor.Undo;
|
74
|
+
exports.Update = require_actor.Update;
|
75
|
+
exports.Video = require_actor.Video;
|
76
|
+
exports.View = require_actor.View;
|
77
|
+
exports.getActorClassByTypeName = require_actor.getActorClassByTypeName;
|
78
|
+
exports.getActorHandle = require_actor.getActorHandle;
|
79
|
+
exports.getActorTypeName = require_actor.getActorTypeName;
|
80
|
+
exports.getTypeId = require_actor.getTypeId;
|
81
|
+
exports.isActor = require_actor.isActor;
|
82
|
+
exports.isFediverseHandle = require_vocab.isFediverseHandle;
|
83
|
+
exports.lookupObject = require_vocab.lookupObject;
|
84
|
+
exports.normalizeActorHandle = require_actor.normalizeActorHandle;
|
85
|
+
exports.parseFediverseHandle = require_vocab.parseFediverseHandle;
|
86
|
+
exports.toAcctUrl = require_vocab.toAcctUrl;
|
87
|
+
exports.traverseCollection = require_vocab.traverseCollection;
|
@@ -0,0 +1,6 @@
|
|
1
|
+
import "../kv-63Cil1MD.cjs";
|
2
|
+
import "../docloader-D-MrRyHl.cjs";
|
3
|
+
import { Accept, Activity, Add, Announce, Application, Arrive, Article, Audio, Block, ChatMessage, Collection, CollectionPage, Create, CryptographicKey, DataIntegrityProof, Delete, DidService, Dislike, Document, Emoji, EmojiReact, Endpoints, Event, Export, Flag, Follow, Group, Hashtag, Ignore, Image, IntransitiveActivity, Invite, Join, Leave, Like, Link, Listen, Mention, Move, Multikey, Note, Object as Object$1, Offer, OrderedCollection, OrderedCollectionPage, Organization, Page, Person, Place, Profile, PropertyValue, Question, Read, Reject, Relationship, Remove, Service, Source, TentativeAccept, TentativeReject, Tombstone, Travel, Undo, Update, Video, View } from "../vocab-DJTYMqyU.cjs";
|
4
|
+
import { Actor, ActorTypeName, GetActorHandleOptions, NormalizeActorHandleOptions, Recipient, getActorClassByTypeName, getActorHandle, getActorTypeName, isActor, normalizeActorHandle } from "../actor-DMgu-ZjT.cjs";
|
5
|
+
import { FediverseHandle, LookupObjectOptions, PUBLIC_COLLECTION, TraverseCollectionOptions, getTypeId, isFediverseHandle, lookupObject, parseFediverseHandle, toAcctUrl, traverseCollection } from "../mod-evzlRVZq.cjs";
|
6
|
+
export { Accept, Activity, Actor, ActorTypeName, Add, Announce, Application, Arrive, Article, Audio, Block, ChatMessage, Collection, CollectionPage, Create, CryptographicKey, DataIntegrityProof, Delete, DidService, Dislike, Document, Emoji, EmojiReact, Endpoints, Event, Export, FediverseHandle, Flag, Follow, GetActorHandleOptions, Group, Hashtag, Ignore, Image, IntransitiveActivity, Invite, Join, Leave, Like, Link, Listen, LookupObjectOptions, Mention, Move, Multikey, NormalizeActorHandleOptions, Note, Object$1 as Object, Offer, OrderedCollection, OrderedCollectionPage, Organization, PUBLIC_COLLECTION, Page, Person, Place, Profile, PropertyValue, Question, Read, Recipient, Reject, Relationship, Remove, Service, Source, TentativeAccept, TentativeReject, Tombstone, Travel, TraverseCollectionOptions, Undo, Update, Video, View, getActorClassByTypeName, getActorHandle, getActorTypeName, getTypeId, isActor, isFediverseHandle, lookupObject, normalizeActorHandle, parseFediverseHandle, toAcctUrl, traverseCollection };
|
package/dist/vocab/mod.js
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
import "../docloader-
|
6
|
-
import { Accept, Activity, Add, Announce, Application, Arrive, Article, Audio, Block, ChatMessage, Collection, CollectionPage, Create, CryptographicKey, DataIntegrityProof, Delete, DidService, Dislike, Document, Emoji, EmojiReact, Endpoints, Event, Export, Flag, Follow, Group, Hashtag, Ignore, Image, IntransitiveActivity, Invite, Join, Leave, Like, Link, Listen, Mention, Move, Multikey, Note, Object as Object$1, Offer, OrderedCollection, OrderedCollectionPage, Organization, Page, Person, Place, Profile, PropertyValue, Question, Read, Reject, Relationship, Remove, Service, Source, TentativeAccept, TentativeReject, Tombstone, Travel, Undo, Update, Video, View, getActorClassByTypeName, getActorHandle, getActorTypeName, getTypeId, isActor, normalizeActorHandle } from "../actor-
|
7
|
-
import "../lookup-
|
8
|
-
import { PUBLIC_COLLECTION, isFediverseHandle, lookupObject, parseFediverseHandle, toAcctUrl, traverseCollection } from "../vocab-
|
2
|
+
import { Temporal } from "@js-temporal/polyfill";
|
3
|
+
import { URLPattern } from "urlpattern-polyfill";
|
4
|
+
|
5
|
+
import "../docloader-DrPHprgh.js";
|
6
|
+
import { Accept, Activity, Add, Announce, Application, Arrive, Article, Audio, Block, ChatMessage, Collection, CollectionPage, Create, CryptographicKey, DataIntegrityProof, Delete, DidService, Dislike, Document, Emoji, EmojiReact, Endpoints, Event, Export, Flag, Follow, Group, Hashtag, Ignore, Image, IntransitiveActivity, Invite, Join, Leave, Like, Link, Listen, Mention, Move, Multikey, Note, Object as Object$1, Offer, OrderedCollection, OrderedCollectionPage, Organization, Page, Person, Place, Profile, PropertyValue, Question, Read, Reject, Relationship, Remove, Service, Source, TentativeAccept, TentativeReject, Tombstone, Travel, Undo, Update, Video, View, getActorClassByTypeName, getActorHandle, getActorTypeName, getTypeId, isActor, normalizeActorHandle } from "../actor-DJS2ne1f.js";
|
7
|
+
import "../lookup-C3BC8XO-.js";
|
8
|
+
import { PUBLIC_COLLECTION, isFediverseHandle, lookupObject, parseFediverseHandle, toAcctUrl, traverseCollection } from "../vocab-C_Pm3NG3.js";
|
9
9
|
|
10
10
|
export { Accept, Activity, Add, Announce, Application, Arrive, Article, Audio, Block, ChatMessage, Collection, CollectionPage, Create, CryptographicKey, DataIntegrityProof, Delete, DidService, Dislike, Document, Emoji, EmojiReact, Endpoints, Event, Export, Flag, Follow, Group, Hashtag, Ignore, Image, IntransitiveActivity, Invite, Join, Leave, Like, Link, Listen, Mention, Move, Multikey, Note, Object$1 as Object, Offer, OrderedCollection, OrderedCollectionPage, Organization, PUBLIC_COLLECTION, Page, Person, Place, Profile, PropertyValue, Question, Read, Reject, Relationship, Remove, Service, Source, TentativeAccept, TentativeReject, Tombstone, Travel, Undo, Update, Video, View, getActorClassByTypeName, getActorHandle, getActorTypeName, getTypeId, isActor, isFediverseHandle, lookupObject, normalizeActorHandle, parseFediverseHandle, toAcctUrl, traverseCollection };
|
package/dist/vocab/type.test.js
CHANGED
@@ -3,10 +3,10 @@
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
4
4
|
globalThis.addEventListener = () => {};
|
5
5
|
|
6
|
-
import { Person, getTypeId } from "../type-
|
6
|
+
import { Person, getTypeId } from "../type-9o78PXlX.js";
|
7
7
|
import { assertEquals } from "../assert_equals-DSbWqCm3.js";
|
8
|
-
import "../lookup-
|
9
|
-
import { test } from "../testing-
|
8
|
+
import "../lookup-DbTBDJcT.js";
|
9
|
+
import { test } from "../testing-y9ueu9Aj.js";
|
10
10
|
|
11
11
|
//#region src/vocab/type.test.ts
|
12
12
|
test("getTypeId()", () => {
|
package/dist/vocab/vocab.test.js
CHANGED
@@ -3,18 +3,18 @@
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
4
4
|
globalThis.addEventListener = () => {};
|
5
5
|
|
6
|
-
import { Activity, Announce, Collection, Create, CryptographicKey, Follow, Hashtag, LanguageString, Note, Object as Object$1, OrderedCollectionPage, Person, Place, Question, Source, decode, vocab_exports } from "../type-
|
6
|
+
import { Activity, Announce, Collection, Create, CryptographicKey, Follow, Hashtag, LanguageString, Link, Note, Object as Object$1, OrderedCollectionPage, Person, Place, Question, Source, decode, vocab_exports } from "../type-9o78PXlX.js";
|
7
7
|
import { assertEquals } from "../assert_equals-DSbWqCm3.js";
|
8
8
|
import { assert } from "../assert-MZs1qjMx.js";
|
9
9
|
import { assertInstanceOf } from "../assert_instance_of-DHz7EHNU.js";
|
10
|
-
import "../lookup-
|
11
|
-
import { mockDocumentLoader, test } from "../testing-
|
12
|
-
import "../std__assert-
|
13
|
-
import { assertFalse, assertRejects } from "../assert_rejects-
|
14
|
-
import "../assert_is_error-
|
15
|
-
import { assertNotEquals } from "../assert_not_equals-
|
16
|
-
import { assertThrows } from "../assert_throws-
|
17
|
-
import { ed25519PublicKey, rsaPublicKey1 } from "../keys-
|
10
|
+
import "../lookup-DbTBDJcT.js";
|
11
|
+
import { mockDocumentLoader, test } from "../testing-y9ueu9Aj.js";
|
12
|
+
import "../std__assert-X-_kMxKM.js";
|
13
|
+
import { assertFalse, assertRejects } from "../assert_rejects-DiIiJbZn.js";
|
14
|
+
import "../assert_is_error-BPGph1Jx.js";
|
15
|
+
import { assertNotEquals } from "../assert_not_equals-f3m3epl3.js";
|
16
|
+
import { assertThrows } from "../assert_throws-BOO88avQ.js";
|
17
|
+
import { ed25519PublicKey, rsaPublicKey1 } from "../keys-DzXrG_sX.js";
|
18
18
|
import { pascalCase } from "es-toolkit";
|
19
19
|
import { Validator } from "@cfworker/json-schema";
|
20
20
|
import { readFile, readdir } from "node:fs/promises";
|
@@ -2241,7 +2241,20 @@ const scalarTypes = {
|
|
2241
2241
|
&& ${v}["@id"] !== "" && ${v}["@id"] !== "/"`;
|
2242
2242
|
},
|
2243
2243
|
decoder(v) {
|
2244
|
-
return
|
2244
|
+
return `${v}["@id"].startsWith("at://")
|
2245
|
+
? new URL("at://" +
|
2246
|
+
encodeURIComponent(
|
2247
|
+
${v}["@id"].includes("/", 5)
|
2248
|
+
? ${v}["@id"].slice(5, ${v}["@id"].indexOf("/", 5))
|
2249
|
+
: ${v}["@id"].slice(5)
|
2250
|
+
) +
|
2251
|
+
(
|
2252
|
+
${v}["@id"].includes("/", 5)
|
2253
|
+
? ${v}["@id"].slice(${v}["@id"].indexOf("/", 5))
|
2254
|
+
: ""
|
2255
|
+
)
|
2256
|
+
)
|
2257
|
+
: new URL(${v}["@id"])`;
|
2245
2258
|
}
|
2246
2259
|
},
|
2247
2260
|
"http://www.w3.org/1999/02/22-rdf-syntax-ns#langString": {
|
@@ -3059,6 +3072,28 @@ test("Actor.getOutbox()", async () => {
|
|
3059
3072
|
assertInstanceOf(outbox, OrderedCollectionPage);
|
3060
3073
|
assertEquals(outbox.totalItems, 1);
|
3061
3074
|
});
|
3075
|
+
test("Link.fromJsonLd()", async () => {
|
3076
|
+
const link = await Link.fromJsonLd({
|
3077
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
3078
|
+
"type": "Link",
|
3079
|
+
"rel": "canonical",
|
3080
|
+
"href": "at://did:plc:ia76kvnndjutgedggx2ibrem/app.bsky.feed.post/3lyxjjs27jkqg"
|
3081
|
+
});
|
3082
|
+
assertEquals(link.rel, "canonical");
|
3083
|
+
assertEquals(link.href, new URL("at://did%3Aplc%3Aia76kvnndjutgedggx2ibrem/app.bsky.feed.post/3lyxjjs27jkqg"));
|
3084
|
+
const link2 = await Link.fromJsonLd({
|
3085
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
3086
|
+
"type": "Link",
|
3087
|
+
"href": "at://bnewbold.bsky.team/app.bsky.feed.post/3jwdwj2ctlk26"
|
3088
|
+
});
|
3089
|
+
assertEquals(link2.href, new URL("at://bnewbold.bsky.team/app.bsky.feed.post/3jwdwj2ctlk26"));
|
3090
|
+
const link3 = await Link.fromJsonLd({
|
3091
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
3092
|
+
"type": "Link",
|
3093
|
+
"href": "at://did:plc:ia76kvnndjutgedggx2ibrem"
|
3094
|
+
});
|
3095
|
+
assertEquals(link3.href, new URL("at://did%3Aplc%3Aia76kvnndjutgedggx2ibrem"));
|
3096
|
+
});
|
3062
3097
|
function getAllProperties(type, types$1) {
|
3063
3098
|
const props = type.properties;
|
3064
3099
|
if (type.extends != null) props.push(...getAllProperties(types$1[type.extends], types$1));
|