@fedify/vocab 2.4.0-pr.936.41 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/deno.json +1 -1
- package/dist/mod.cjs +31328 -8723
- package/dist/mod.d.cts +4599 -6
- package/dist/mod.d.ts +4599 -6
- package/dist/mod.js +31221 -8623
- package/dist-tests/actor-D7_iX4I4.mjs +276 -0
- package/dist-tests/actor.test.mjs +55 -49
- package/dist-tests/{actor-MBpzF3-D.mjs → esm-DP2Spt0u.mjs} +15 -211
- package/dist-tests/gateway.test.mjs +1906 -0
- package/dist-tests/lookup-IiNFWuXL.mjs +480 -0
- package/dist-tests/lookup.test.mjs +10 -268
- package/dist-tests/object.yaml +15 -0
- package/dist-tests/portable-lookup.test.mjs +653 -0
- package/dist-tests/signed-representation.test.mjs +189 -0
- package/dist-tests/translation.test.mjs +404 -0
- package/dist-tests/translation.yaml +91 -0
- package/dist-tests/type.test.mjs +2 -2
- package/dist-tests/{vocab-Bjwctrxn.mjs → vocab-COZcxf00.mjs} +30831 -8515
- package/dist-tests/vocab.test.mjs +677 -10
- package/package.json +5 -5
- package/src/__snapshots__/vocab.test.ts.snap +291 -15
- package/src/actor.test.ts +41 -40
- package/src/actor.ts +120 -1
- package/src/gateway.test.ts +2637 -0
- package/src/lookup.test.ts +6 -5
- package/src/lookup.ts +460 -33
- package/src/mod.ts +9 -0
- package/src/object.yaml +15 -0
- package/src/portable-lookup.test.ts +889 -0
- package/src/preprocessors.ts +1 -1
- package/src/signed-representation.test.ts +277 -0
- package/src/translation.test.ts +518 -0
- package/src/translation.yaml +91 -0
- package/src/vocab.test.ts +914 -5
- /package/dist-tests/{type-_BlsfT3S.mjs → type-BMdjm4Eg.mjs} +0 -0
- /package/dist-tests/{utils-CQjrpUkt.mjs → utils-Df2odC27.mjs} +0 -0
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import "temporal-polyfill";
|
|
2
|
+
globalThis.addEventListener = () => {};
|
|
3
|
+
import { F as Person, P as Organization, U as Service, a as Application, b as Group } from "./vocab-COZcxf00.mjs";
|
|
4
|
+
import { t as getTypeId } from "./type-BMdjm4Eg.mjs";
|
|
5
|
+
import { canonicalizePortableUri, formatIri, fromCompatibleEf61Id, isGatewayUrl } from "@fedify/vocab-runtime";
|
|
6
|
+
import { lookupWebFinger } from "@fedify/webfinger";
|
|
7
|
+
import { SpanStatusCode, trace } from "@opentelemetry/api";
|
|
8
|
+
import { domainToASCII, domainToUnicode } from "node:url";
|
|
9
|
+
//#region deno.json
|
|
10
|
+
var name = "@fedify/vocab";
|
|
11
|
+
var version = "2.4.0";
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region src/actor.ts
|
|
14
|
+
const ACTOR_DISCOVERY_HISTOGRAM_BUCKETS = [
|
|
15
|
+
5,
|
|
16
|
+
10,
|
|
17
|
+
25,
|
|
18
|
+
50,
|
|
19
|
+
75,
|
|
20
|
+
100,
|
|
21
|
+
250,
|
|
22
|
+
500,
|
|
23
|
+
750,
|
|
24
|
+
1e3,
|
|
25
|
+
2500,
|
|
26
|
+
5e3,
|
|
27
|
+
7500,
|
|
28
|
+
1e4
|
|
29
|
+
];
|
|
30
|
+
const actorDiscoveryInstruments = /* @__PURE__ */ new WeakMap();
|
|
31
|
+
function getActorDiscoveryInstruments(meterProvider) {
|
|
32
|
+
let instruments = actorDiscoveryInstruments.get(meterProvider);
|
|
33
|
+
if (instruments == null) {
|
|
34
|
+
const meter = meterProvider.getMeter(name, version);
|
|
35
|
+
instruments = {
|
|
36
|
+
discovery: meter.createCounter("activitypub.actor.discovery", {
|
|
37
|
+
description: "Actor handle discovery attempts via getActorHandle(), classified by terminal outcome.",
|
|
38
|
+
unit: "{discovery}"
|
|
39
|
+
}),
|
|
40
|
+
discoveryDuration: meter.createHistogram("activitypub.actor.discovery.duration", {
|
|
41
|
+
description: "Duration of getActorHandle() actor discovery calls.",
|
|
42
|
+
unit: "ms",
|
|
43
|
+
advice: { explicitBucketBoundaries: [...ACTOR_DISCOVERY_HISTOGRAM_BUCKETS] }
|
|
44
|
+
})
|
|
45
|
+
};
|
|
46
|
+
actorDiscoveryInstruments.set(meterProvider, instruments);
|
|
47
|
+
}
|
|
48
|
+
return instruments;
|
|
49
|
+
}
|
|
50
|
+
function getActorDiscoveryRemoteHost(actor) {
|
|
51
|
+
const id = actor instanceof URL ? actor : actor.id;
|
|
52
|
+
if (id == null) return void 0;
|
|
53
|
+
if (isPortableActorId(id)) return actor instanceof URL ? void 0 : actor.gateway?.host;
|
|
54
|
+
return id.host === "" ? void 0 : id.host;
|
|
55
|
+
}
|
|
56
|
+
var ActorHandleNotFoundError = class extends TypeError {
|
|
57
|
+
constructor() {
|
|
58
|
+
super("Actor does not have enough information to get the handle.");
|
|
59
|
+
this.name = "ActorHandleNotFoundError";
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Checks if the given object is an {@link Actor}.
|
|
64
|
+
* @param object The object to check.
|
|
65
|
+
* @returns `true` if the given object is an {@link Actor}.
|
|
66
|
+
*/
|
|
67
|
+
function isActor(object) {
|
|
68
|
+
return object instanceof Application || object instanceof Group || object instanceof Organization || object instanceof Person || object instanceof Service;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Gets the type name of the given actor.
|
|
72
|
+
* @param actor The actor to get the type name of.
|
|
73
|
+
* @returns The type name of the given actor.
|
|
74
|
+
*/
|
|
75
|
+
function getActorTypeName(actor) {
|
|
76
|
+
if (actor instanceof Application) return "Application";
|
|
77
|
+
else if (actor instanceof Group) return "Group";
|
|
78
|
+
else if (actor instanceof Organization) return "Organization";
|
|
79
|
+
else if (actor instanceof Person) return "Person";
|
|
80
|
+
else if (actor instanceof Service) return "Service";
|
|
81
|
+
throw new Error("Unknown actor type.");
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Gets the actor class by the given type name.
|
|
85
|
+
* @param typeName The type name to get the actor class by.
|
|
86
|
+
* @returns The actor class by the given type name.
|
|
87
|
+
*/
|
|
88
|
+
function getActorClassByTypeName(typeName) {
|
|
89
|
+
switch (typeName) {
|
|
90
|
+
case "Application": return Application;
|
|
91
|
+
case "Group": return Group;
|
|
92
|
+
case "Organization": return Organization;
|
|
93
|
+
case "Person": return Person;
|
|
94
|
+
case "Service": return Service;
|
|
95
|
+
}
|
|
96
|
+
throw new Error("Unknown actor type name.");
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Gets the actor handle, of the form `@username@domain`, from the given actor
|
|
100
|
+
* or an actor URI.
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ``` typescript
|
|
104
|
+
* // Get the handle of an actor object:
|
|
105
|
+
* await getActorHandle(
|
|
106
|
+
* new Person({ id: new URL("https://fosstodon.org/users/hongminhee") })
|
|
107
|
+
* );
|
|
108
|
+
*
|
|
109
|
+
* // Get the handle of an actor URI:
|
|
110
|
+
* await getActorHandle(new URL("https://fosstodon.org/users/hongminhee"));
|
|
111
|
+
* ```
|
|
112
|
+
*
|
|
113
|
+
* For an [FEP-ef61] portable actor, whose ID is an `ap:` or `ap+ef61:` URI,
|
|
114
|
+
* the domain is taken from the first gateway in the actor's `gateways` rather
|
|
115
|
+
* than from its ID. The handle is returned only if its WebFinger response
|
|
116
|
+
* links back to the actor, since the actor's `gateways` are claimed by the
|
|
117
|
+
* actor itself; a failed WebFinger lookup is not enough information to get
|
|
118
|
+
* the handle. A portable actor without `gateways` or
|
|
119
|
+
* `preferredUsername`, or a portable actor URI (which does not tell its
|
|
120
|
+
* gateways), is not supported.
|
|
121
|
+
*
|
|
122
|
+
* [FEP-ef61]: https://w3id.org/fep/ef61
|
|
123
|
+
*
|
|
124
|
+
* @param actor The actor or actor URI to get the handle from.
|
|
125
|
+
* @param options The extra options for getting the actor handle.
|
|
126
|
+
* @returns The actor handle. It starts with `@` and is followed by the
|
|
127
|
+
* username and domain, separated by `@` by default (it can be
|
|
128
|
+
* customized with the options).
|
|
129
|
+
* @throws {TypeError} If the actor does not have enough information to get the
|
|
130
|
+
* handle.
|
|
131
|
+
* @since 0.4.0
|
|
132
|
+
*/
|
|
133
|
+
async function getActorHandle(actor, options = {}) {
|
|
134
|
+
return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(name, version).startActiveSpan("activitypub.get_actor_handle", async (span) => {
|
|
135
|
+
if (isActor(actor)) {
|
|
136
|
+
if (actor.id != null) span.setAttribute("activitypub.actor.id", actor.id.href);
|
|
137
|
+
span.setAttribute("activitypub.actor.type", getTypeId(actor).href);
|
|
138
|
+
}
|
|
139
|
+
const meterProvider = options.meterProvider;
|
|
140
|
+
const start = meterProvider == null ? 0 : performance.now();
|
|
141
|
+
let result = "error";
|
|
142
|
+
try {
|
|
143
|
+
const handle = await getActorHandleInternal(actor, options);
|
|
144
|
+
result = "resolved";
|
|
145
|
+
return handle;
|
|
146
|
+
} catch (error) {
|
|
147
|
+
result = error instanceof ActorHandleNotFoundError ? "not_found" : "error";
|
|
148
|
+
span.setStatus({
|
|
149
|
+
code: SpanStatusCode.ERROR,
|
|
150
|
+
message: String(error)
|
|
151
|
+
});
|
|
152
|
+
throw error;
|
|
153
|
+
} finally {
|
|
154
|
+
if (meterProvider != null) {
|
|
155
|
+
const attributes = { "activitypub.actor.discovery.result": result };
|
|
156
|
+
const host = getActorDiscoveryRemoteHost(actor);
|
|
157
|
+
if (host != null) attributes["activitypub.remote.host"] = host;
|
|
158
|
+
const instruments = getActorDiscoveryInstruments(meterProvider);
|
|
159
|
+
instruments.discovery.add(1, attributes);
|
|
160
|
+
instruments.discoveryDuration.record(Math.max(0, performance.now() - start), attributes);
|
|
161
|
+
}
|
|
162
|
+
span.end();
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
async function getActorHandleInternal(actor, options = {}) {
|
|
167
|
+
const actorId = actor instanceof URL ? actor : actor.id;
|
|
168
|
+
if (actorId != null && isPortableActorId(actorId)) {
|
|
169
|
+
if (actor instanceof URL) throw new ActorHandleNotFoundError();
|
|
170
|
+
return await getPortableActorHandle(actor, actorId, options);
|
|
171
|
+
}
|
|
172
|
+
if (actorId != null) {
|
|
173
|
+
const result = await lookupWebFinger(actorId, {
|
|
174
|
+
userAgent: options.userAgent,
|
|
175
|
+
tracerProvider: options.tracerProvider,
|
|
176
|
+
meterProvider: options.meterProvider
|
|
177
|
+
});
|
|
178
|
+
if (result != null) {
|
|
179
|
+
const aliases = [...result.aliases ?? []];
|
|
180
|
+
if (result.subject != null) aliases.unshift(result.subject);
|
|
181
|
+
for (const alias of aliases) {
|
|
182
|
+
const match = alias.match(/^acct:([^@]+)@([^@]+)$/);
|
|
183
|
+
if (match != null) {
|
|
184
|
+
if (new URL(`https://${match[2]}/`).hostname !== actorId.hostname && !await verifyCrossOriginActorHandle(actorId.href, alias, options.userAgent, options.tracerProvider, options.meterProvider)) continue;
|
|
185
|
+
return normalizeActorHandle(`@${match[1]}@${match[2]}`, options);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
if (!(actor instanceof URL) && actor.preferredUsername != null && actor.id != null) return normalizeActorHandle(`@${actor.preferredUsername}@${actor.id.host}`, options);
|
|
191
|
+
throw new ActorHandleNotFoundError();
|
|
192
|
+
}
|
|
193
|
+
function isPortableActorId(id) {
|
|
194
|
+
return id.protocol === "ap:" || id.protocol === "ap+ef61:";
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* The reverse discovery of an FEP-ef61 portable actor's WebFinger address,
|
|
198
|
+
* which takes the domain from the first gateway in its `gateways`.
|
|
199
|
+
*/
|
|
200
|
+
async function getPortableActorHandle(actor, actorId, options) {
|
|
201
|
+
const gateway = actor.gateway;
|
|
202
|
+
const username = actor.preferredUsername?.toString();
|
|
203
|
+
if (gateway == null || !isGatewayUrl(gateway) || username == null) throw new ActorHandleNotFoundError();
|
|
204
|
+
const canonicalId = canonicalizePortableUri(formatIri(actorId));
|
|
205
|
+
const handle = `acct:${username}@${gateway.host}`;
|
|
206
|
+
const result = await lookupWebFinger(handle, {
|
|
207
|
+
userAgent: options.userAgent,
|
|
208
|
+
tracerProvider: options.tracerProvider,
|
|
209
|
+
meterProvider: options.meterProvider
|
|
210
|
+
});
|
|
211
|
+
if (result == null || !linksToPortableActor(result, canonicalId)) throw new ActorHandleNotFoundError();
|
|
212
|
+
const subject = result.subject?.match(/^acct:([^@]+)@([^@]+)$/);
|
|
213
|
+
if (subject != null && result.subject !== handle) {
|
|
214
|
+
const subjectResult = await lookupWebFinger(result.subject, {
|
|
215
|
+
userAgent: options.userAgent,
|
|
216
|
+
tracerProvider: options.tracerProvider,
|
|
217
|
+
meterProvider: options.meterProvider
|
|
218
|
+
});
|
|
219
|
+
if (subjectResult != null && linksToPortableActor(subjectResult, canonicalId)) return normalizeActorHandle(`@${subject[1]}@${subject[2]}`, options);
|
|
220
|
+
}
|
|
221
|
+
return normalizeActorHandle(`@${username}@${gateway.host}`, options);
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Checks if the first ActivityStreams `self` link of a WebFinger response
|
|
225
|
+
* identifies the portable actor, either by its portable ID or by
|
|
226
|
+
* a compatible identifier.
|
|
227
|
+
*/
|
|
228
|
+
function linksToPortableActor(jrd, canonicalId) {
|
|
229
|
+
const link = jrd.links?.find((l) => l.rel === "self" && l.href != null && (l.type === "application/activity+json" || l.type?.match(/application\/ld\+json;\s*profile="https:\/\/www.w3.org\/ns\/activitystreams"/) != null));
|
|
230
|
+
if (link?.href == null) return false;
|
|
231
|
+
try {
|
|
232
|
+
let id;
|
|
233
|
+
if (/^ap(?:\+ef61)?:/i.test(link.href)) id = link.href;
|
|
234
|
+
else {
|
|
235
|
+
const portable = URL.canParse(link.href) ? fromCompatibleEf61Id(link.href) : null;
|
|
236
|
+
if (portable == null) return false;
|
|
237
|
+
id = formatIri(portable);
|
|
238
|
+
}
|
|
239
|
+
return canonicalizePortableUri(id) === canonicalId;
|
|
240
|
+
} catch (error) {
|
|
241
|
+
if (error instanceof TypeError) return false;
|
|
242
|
+
throw error;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
async function verifyCrossOriginActorHandle(actorId, alias, userAgent, tracerProvider, meterProvider) {
|
|
246
|
+
const response = await lookupWebFinger(alias, {
|
|
247
|
+
userAgent,
|
|
248
|
+
tracerProvider,
|
|
249
|
+
meterProvider
|
|
250
|
+
});
|
|
251
|
+
if (response == null) return false;
|
|
252
|
+
for (const alias of response.aliases ?? []) if (new URL(alias).href === actorId) return true;
|
|
253
|
+
return false;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Normalizes the given actor handle.
|
|
257
|
+
* @param handle The full handle of the actor to normalize.
|
|
258
|
+
* @param options The options for normalizing the actor handle.
|
|
259
|
+
* @returns The normalized actor handle.
|
|
260
|
+
* @throws {TypeError} If the actor handle is invalid.
|
|
261
|
+
* @since 0.9.0
|
|
262
|
+
*/
|
|
263
|
+
function normalizeActorHandle(handle, options = {}) {
|
|
264
|
+
handle = handle.replace(/^@/, "");
|
|
265
|
+
const atPos = handle.indexOf("@");
|
|
266
|
+
if (atPos < 1) throw new TypeError("Invalid actor handle.");
|
|
267
|
+
let domain = handle.substring(atPos + 1);
|
|
268
|
+
if (domain.length < 1 || domain.includes("@")) throw new TypeError("Invalid actor handle.");
|
|
269
|
+
domain = domain.toLowerCase();
|
|
270
|
+
domain = options.punycode ? domainToASCII(domain) : domainToUnicode(domain);
|
|
271
|
+
domain = domain.toLowerCase();
|
|
272
|
+
const user = handle.substring(0, atPos);
|
|
273
|
+
return options.trimLeadingAt ? `${user}@${domain}` : `@${user}@${domain}`;
|
|
274
|
+
}
|
|
275
|
+
//#endregion
|
|
276
|
+
export { normalizeActorHandle as a, isActor as i, getActorHandle as n, name as o, getActorTypeName as r, version as s, getActorClassByTypeName as t };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import "temporal-polyfill";
|
|
2
2
|
globalThis.addEventListener = () => {};
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { F as Person, P as Organization, Q as __exportAll, U as Service, a as Application, b as Group } from "./vocab-COZcxf00.mjs";
|
|
4
|
+
import { t as esm_default } from "./esm-DP2Spt0u.mjs";
|
|
5
|
+
import { a as normalizeActorHandle, i as isActor, n as getActorHandle, r as getActorTypeName, t as getActorClassByTypeName } from "./actor-D7_iX4I4.mjs";
|
|
5
6
|
import { createTestMeterProvider, test } from "@fedify/fixture";
|
|
6
7
|
import { deepStrictEqual, ok, rejects, strictEqual, throws } from "node:assert/strict";
|
|
7
8
|
//#region ../../node_modules/.pnpm/fast-check@3.23.2/node_modules/fast-check/lib/esm/check/precondition/PreconditionFailure.js
|
|
@@ -1816,7 +1817,10 @@ function stringifyInternal(value, previousValues, getAsyncContent) {
|
|
|
1816
1817
|
if (typeof safeBufferIsBuffer === "function" && safeBufferIsBuffer(value)) return `Buffer.from(${stringifyInternal(safeArrayFrom(value.values()), currentValues, getAsyncContent)})`;
|
|
1817
1818
|
const valuePrototype = safeObjectGetPrototypeOf$1(value);
|
|
1818
1819
|
const className = valuePrototype && valuePrototype.constructor && valuePrototype.constructor.name;
|
|
1819
|
-
if (typeof className === "string")
|
|
1820
|
+
if (typeof className === "string") {
|
|
1821
|
+
const valuesFromTypedArr = value.values();
|
|
1822
|
+
return `${className}.from(${stringifyInternal(safeArrayFrom(valuesFromTypedArr), currentValues, getAsyncContent)})`;
|
|
1823
|
+
}
|
|
1820
1824
|
break;
|
|
1821
1825
|
}
|
|
1822
1826
|
}
|
|
@@ -2812,7 +2816,8 @@ function maxGeneratedLengthFromSizeForArbitrary(size, minLength, maxLength, spec
|
|
|
2812
2816
|
const { baseSize: defaultSize = DefaultSize, defaultSizeToMaxWhenMaxSpecified } = readConfigureGlobal() || {};
|
|
2813
2817
|
const definedSize = size !== void 0 ? size : specifiedMaxLength && defaultSizeToMaxWhenMaxSpecified ? "max" : defaultSize;
|
|
2814
2818
|
if (definedSize === "max") return maxLength;
|
|
2815
|
-
|
|
2819
|
+
const finalSize = relativeSizeToSize(definedSize, defaultSize);
|
|
2820
|
+
return safeMathMin$3(maxLengthFromMinLength(minLength, finalSize), maxLength);
|
|
2816
2821
|
}
|
|
2817
2822
|
function depthBiasFromSizeForArbitrary(depthSizeOrSize, specifiedMaxDepth) {
|
|
2818
2823
|
if (typeof depthSizeOrSize === "number") return 1 / depthSizeOrSize;
|
|
@@ -3312,11 +3317,12 @@ var FrequencyArbitrary = class FrequencyArbitrary extends Arbitrary {
|
|
|
3312
3317
|
if (currentWeight < 0) throw new Error(`${label} expects weights to be superior or equal to 0`);
|
|
3313
3318
|
}
|
|
3314
3319
|
if (totalWeight <= 0) throw new Error(`${label} expects the sum of weights to be strictly superior to 0`);
|
|
3315
|
-
|
|
3320
|
+
const sanitizedConstraints = {
|
|
3316
3321
|
depthBias: depthBiasFromSizeForArbitrary(constraints.depthSize, constraints.maxDepth !== void 0),
|
|
3317
3322
|
maxDepth: constraints.maxDepth != void 0 ? constraints.maxDepth : safePositiveInfinity$7,
|
|
3318
3323
|
withCrossShrink: !!constraints.withCrossShrink
|
|
3319
|
-
}
|
|
3324
|
+
};
|
|
3325
|
+
return new FrequencyArbitrary(warbs, sanitizedConstraints, getDepthContextFor(constraints.depthIdentifier));
|
|
3320
3326
|
}
|
|
3321
3327
|
constructor(warbs, constraints, context) {
|
|
3322
3328
|
super();
|
|
@@ -4942,7 +4948,7 @@ const INDEX_NEGATIVE_INFINITY$1 = {
|
|
|
4942
4948
|
sign: -1,
|
|
4943
4949
|
data: [2146435072, 1]
|
|
4944
4950
|
};
|
|
4945
|
-
const f64 = new Float64Array(1);
|
|
4951
|
+
const f64 = /* @__PURE__ */ new Float64Array(1);
|
|
4946
4952
|
const u32$1 = new Uint32Array(f64.buffer, f64.byteOffset);
|
|
4947
4953
|
function bitCastDoubleToUInt64(f) {
|
|
4948
4954
|
f64[0] = f;
|
|
@@ -5047,7 +5053,7 @@ function doubleOnlyMapper(value) {
|
|
|
5047
5053
|
}
|
|
5048
5054
|
function doubleOnlyUnmapper(value) {
|
|
5049
5055
|
if (typeof value !== "number") throw new Error("Unsupported type");
|
|
5050
|
-
return value === safePositiveInfinity$4 ? onlyIntegersAfterThisValue$1 : value === safeNegativeInfinity$4 ? -
|
|
5056
|
+
return value === safePositiveInfinity$4 ? onlyIntegersAfterThisValue$1 : value === safeNegativeInfinity$4 ? -4503599627370496 : value;
|
|
5051
5057
|
}
|
|
5052
5058
|
//#endregion
|
|
5053
5059
|
//#region ../../node_modules/.pnpm/fast-check@3.23.2/node_modules/fast-check/lib/esm/arbitrary/double.js
|
|
@@ -5099,7 +5105,7 @@ const safePositiveInfinity$2 = Number.POSITIVE_INFINITY;
|
|
|
5099
5105
|
const MAX_VALUE_32 = 2 ** 127 * (1 + (2 ** 23 - 1) / 2 ** 23);
|
|
5100
5106
|
const INDEX_POSITIVE_INFINITY = 2139095040;
|
|
5101
5107
|
const INDEX_NEGATIVE_INFINITY = -2139095041;
|
|
5102
|
-
const f32 = new Float32Array(1);
|
|
5108
|
+
const f32 = /* @__PURE__ */ new Float32Array(1);
|
|
5103
5109
|
const u32 = new Uint32Array(f32.buffer, f32.byteOffset);
|
|
5104
5110
|
function bitCastFloatToUInt32(f) {
|
|
5105
5111
|
f32[0] = f;
|
|
@@ -5155,7 +5161,7 @@ function floatOnlyMapper(value) {
|
|
|
5155
5161
|
}
|
|
5156
5162
|
function floatOnlyUnmapper(value) {
|
|
5157
5163
|
if (typeof value !== "number") throw new Error("Unsupported type");
|
|
5158
|
-
return value === safePositiveInfinity$1 ? onlyIntegersAfterThisValue : value === safeNegativeInfinity$1 ? -
|
|
5164
|
+
return value === safePositiveInfinity$1 ? onlyIntegersAfterThisValue : value === safeNegativeInfinity$1 ? -8388608 : value;
|
|
5159
5165
|
}
|
|
5160
5166
|
//#endregion
|
|
5161
5167
|
//#region ../../node_modules/.pnpm/fast-check@3.23.2/node_modules/fast-check/lib/esm/arbitrary/float.js
|
|
@@ -5643,50 +5649,50 @@ test({
|
|
|
5643
5649
|
},
|
|
5644
5650
|
async fn(t) {
|
|
5645
5651
|
esm_default.spyGlobal();
|
|
5646
|
-
esm_default.get("begin:https://
|
|
5647
|
-
body: { subject: "acct:johndoe@
|
|
5652
|
+
esm_default.get("begin:https://1.1.1.1/.well-known/webfinger?", {
|
|
5653
|
+
body: { subject: "acct:johndoe@1.1.1.1" },
|
|
5648
5654
|
headers: { "Content-Type": "application/jrd+json" }
|
|
5649
5655
|
});
|
|
5650
|
-
const actorId = new URL("https://
|
|
5656
|
+
const actorId = new URL("https://1.1.1.1/@john");
|
|
5651
5657
|
const actor = new Person({
|
|
5652
5658
|
id: actorId,
|
|
5653
5659
|
preferredUsername: "john"
|
|
5654
5660
|
});
|
|
5655
5661
|
await t.step("WebFinger subject", async () => {
|
|
5656
|
-
deepStrictEqual(await getActorHandle(actor), "@johndoe@
|
|
5657
|
-
deepStrictEqual(await getActorHandle(actor, { trimLeadingAt: true }), "johndoe@
|
|
5658
|
-
deepStrictEqual(await getActorHandle(actorId), "@johndoe@
|
|
5659
|
-
deepStrictEqual(await getActorHandle(actorId, { trimLeadingAt: true }), "johndoe@
|
|
5662
|
+
deepStrictEqual(await getActorHandle(actor), "@johndoe@1.1.1.1");
|
|
5663
|
+
deepStrictEqual(await getActorHandle(actor, { trimLeadingAt: true }), "johndoe@1.1.1.1");
|
|
5664
|
+
deepStrictEqual(await getActorHandle(actorId), "@johndoe@1.1.1.1");
|
|
5665
|
+
deepStrictEqual(await getActorHandle(actorId, { trimLeadingAt: true }), "johndoe@1.1.1.1");
|
|
5660
5666
|
});
|
|
5661
5667
|
esm_default.removeRoutes();
|
|
5662
|
-
esm_default.get("begin:https://
|
|
5668
|
+
esm_default.get("begin:https://1.1.1.1/.well-known/webfinger?", {
|
|
5663
5669
|
body: {
|
|
5664
|
-
subject: "https://
|
|
5665
|
-
aliases: ["acct:john@
|
|
5670
|
+
subject: "https://1.1.1.1/@john",
|
|
5671
|
+
aliases: ["acct:john@8.8.8.8", "acct:johndoe@1.1.1.1"]
|
|
5666
5672
|
},
|
|
5667
5673
|
headers: { "Content-Type": "application/jrd+json" }
|
|
5668
5674
|
});
|
|
5669
5675
|
await t.step("WebFinger aliases", async () => {
|
|
5670
|
-
deepStrictEqual(await getActorHandle(actor), "@johndoe@
|
|
5671
|
-
deepStrictEqual(await getActorHandle(actor, { trimLeadingAt: true }), "johndoe@
|
|
5672
|
-
deepStrictEqual(await getActorHandle(actorId), "@johndoe@
|
|
5673
|
-
deepStrictEqual(await getActorHandle(actorId, { trimLeadingAt: true }), "johndoe@
|
|
5676
|
+
deepStrictEqual(await getActorHandle(actor), "@johndoe@1.1.1.1");
|
|
5677
|
+
deepStrictEqual(await getActorHandle(actor, { trimLeadingAt: true }), "johndoe@1.1.1.1");
|
|
5678
|
+
deepStrictEqual(await getActorHandle(actorId), "@johndoe@1.1.1.1");
|
|
5679
|
+
deepStrictEqual(await getActorHandle(actorId, { trimLeadingAt: true }), "johndoe@1.1.1.1");
|
|
5674
5680
|
});
|
|
5675
|
-
esm_default.get("begin:https://
|
|
5681
|
+
esm_default.get("begin:https://8.8.8.8/.well-known/webfinger?", {
|
|
5676
5682
|
body: {
|
|
5677
|
-
subject: "acct:john@
|
|
5678
|
-
aliases: ["https://
|
|
5683
|
+
subject: "acct:john@8.8.8.8",
|
|
5684
|
+
aliases: ["https://1.1.1.1/@john"]
|
|
5679
5685
|
},
|
|
5680
5686
|
headers: { "Content-Type": "application/jrd+json" }
|
|
5681
5687
|
});
|
|
5682
5688
|
await t.step("cross-origin WebFinger resources", async () => {
|
|
5683
|
-
deepStrictEqual(await getActorHandle(actor), "@john@
|
|
5689
|
+
deepStrictEqual(await getActorHandle(actor), "@john@8.8.8.8");
|
|
5684
5690
|
});
|
|
5685
5691
|
esm_default.removeRoutes();
|
|
5686
|
-
esm_default.get("begin:https://
|
|
5692
|
+
esm_default.get("begin:https://1.1.1.1/.well-known/webfinger?", { status: 404 });
|
|
5687
5693
|
await t.step("no WebFinger", async () => {
|
|
5688
|
-
deepStrictEqual(await getActorHandle(actor), "@john@
|
|
5689
|
-
rejects(() => getActorHandle(actorId), TypeError);
|
|
5694
|
+
deepStrictEqual(await getActorHandle(actor), "@john@1.1.1.1");
|
|
5695
|
+
await rejects(() => getActorHandle(actorId), TypeError);
|
|
5690
5696
|
});
|
|
5691
5697
|
esm_default.hardReset();
|
|
5692
5698
|
}
|
|
@@ -5697,25 +5703,25 @@ test("getActorHandle() records activitypub.actor.discovery counter", { permissio
|
|
|
5697
5703
|
} }, async (t) => {
|
|
5698
5704
|
esm_default.spyGlobal();
|
|
5699
5705
|
try {
|
|
5700
|
-
const actorId = new URL("https://
|
|
5706
|
+
const actorId = new URL("https://1.1.1.1/@john");
|
|
5701
5707
|
const actor = new Person({
|
|
5702
5708
|
id: actorId,
|
|
5703
5709
|
preferredUsername: "john"
|
|
5704
5710
|
});
|
|
5705
5711
|
await t.step("records result=resolved on a successful lookup", async () => {
|
|
5706
5712
|
esm_default.removeRoutes();
|
|
5707
|
-
esm_default.get("begin:https://
|
|
5708
|
-
body: { subject: "acct:johndoe@
|
|
5713
|
+
esm_default.get("begin:https://1.1.1.1/.well-known/webfinger?", {
|
|
5714
|
+
body: { subject: "acct:johndoe@1.1.1.1" },
|
|
5709
5715
|
headers: { "Content-Type": "application/jrd+json" }
|
|
5710
5716
|
});
|
|
5711
5717
|
const [meterProvider, recorder] = createTestMeterProvider();
|
|
5712
|
-
deepStrictEqual(await getActorHandle(actor, { meterProvider }), "@johndoe@
|
|
5718
|
+
deepStrictEqual(await getActorHandle(actor, { meterProvider }), "@johndoe@1.1.1.1");
|
|
5713
5719
|
const counters = recorder.getMeasurements("activitypub.actor.discovery");
|
|
5714
5720
|
deepStrictEqual(counters.length, 1);
|
|
5715
5721
|
deepStrictEqual(counters[0].type, "counter");
|
|
5716
5722
|
deepStrictEqual(counters[0].value, 1);
|
|
5717
5723
|
deepStrictEqual(counters[0].attributes["activitypub.actor.discovery.result"], "resolved");
|
|
5718
|
-
deepStrictEqual(counters[0].attributes["activitypub.remote.host"], "
|
|
5724
|
+
deepStrictEqual(counters[0].attributes["activitypub.remote.host"], "1.1.1.1");
|
|
5719
5725
|
const durations = recorder.getMeasurements("activitypub.actor.discovery.duration");
|
|
5720
5726
|
deepStrictEqual(durations.length, 1);
|
|
5721
5727
|
deepStrictEqual(durations[0].type, "histogram");
|
|
@@ -5724,40 +5730,40 @@ test("getActorHandle() records activitypub.actor.discovery counter", { permissio
|
|
|
5724
5730
|
});
|
|
5725
5731
|
await t.step("records result=resolved when WebFinger is missing but preferredUsername fallback succeeds", async () => {
|
|
5726
5732
|
esm_default.removeRoutes();
|
|
5727
|
-
esm_default.get("begin:https://
|
|
5733
|
+
esm_default.get("begin:https://1.1.1.1/.well-known/webfinger?", { status: 404 });
|
|
5728
5734
|
const [meterProvider, recorder] = createTestMeterProvider();
|
|
5729
|
-
deepStrictEqual(await getActorHandle(actor, { meterProvider }), "@john@
|
|
5735
|
+
deepStrictEqual(await getActorHandle(actor, { meterProvider }), "@john@1.1.1.1");
|
|
5730
5736
|
const counter = recorder.getMeasurement("activitypub.actor.discovery");
|
|
5731
5737
|
ok(counter != null);
|
|
5732
5738
|
deepStrictEqual(counter.attributes["activitypub.actor.discovery.result"], "resolved");
|
|
5733
5739
|
});
|
|
5734
5740
|
await t.step("records result=not_found when neither WebFinger nor preferredUsername yields a handle", async () => {
|
|
5735
5741
|
esm_default.removeRoutes();
|
|
5736
|
-
esm_default.get("begin:https://
|
|
5742
|
+
esm_default.get("begin:https://1.1.1.1/.well-known/webfinger?", { status: 404 });
|
|
5737
5743
|
const [meterProvider, recorder] = createTestMeterProvider();
|
|
5738
5744
|
await rejects(() => getActorHandle(actorId, { meterProvider }), TypeError);
|
|
5739
5745
|
const counter = recorder.getMeasurement("activitypub.actor.discovery");
|
|
5740
5746
|
ok(counter != null);
|
|
5741
5747
|
deepStrictEqual(counter.attributes["activitypub.actor.discovery.result"], "not_found");
|
|
5742
|
-
deepStrictEqual(counter.attributes["activitypub.remote.host"], "
|
|
5748
|
+
deepStrictEqual(counter.attributes["activitypub.remote.host"], "1.1.1.1");
|
|
5743
5749
|
const duration = recorder.getMeasurement("activitypub.actor.discovery.duration");
|
|
5744
5750
|
ok(duration != null);
|
|
5745
5751
|
deepStrictEqual(duration.attributes["activitypub.actor.discovery.result"], "not_found");
|
|
5746
5752
|
});
|
|
5747
5753
|
await t.step("records non-default ports for actor IDs", async () => {
|
|
5748
5754
|
esm_default.removeRoutes();
|
|
5749
|
-
esm_default.get("begin:https://
|
|
5755
|
+
esm_default.get("begin:https://1.1.1.1:8443/.well-known/webfinger?", { status: 404 });
|
|
5750
5756
|
const [meterProvider, recorder] = createTestMeterProvider();
|
|
5751
|
-
await rejects(() => getActorHandle(new URL("https://
|
|
5757
|
+
await rejects(() => getActorHandle(new URL("https://1.1.1.1:8443/@john"), { meterProvider }), TypeError);
|
|
5752
5758
|
const counter = recorder.getMeasurement("activitypub.actor.discovery");
|
|
5753
5759
|
ok(counter != null);
|
|
5754
|
-
deepStrictEqual(counter.attributes["activitypub.remote.host"], "
|
|
5760
|
+
deepStrictEqual(counter.attributes["activitypub.remote.host"], "1.1.1.1:8443");
|
|
5755
5761
|
});
|
|
5756
5762
|
await t.step("records result=error when a malformed WebFinger alias throws TypeError", async () => {
|
|
5757
5763
|
esm_default.removeRoutes();
|
|
5758
|
-
esm_default.get("begin:https://
|
|
5764
|
+
esm_default.get("begin:https://1.1.1.1/.well-known/webfinger?", {
|
|
5759
5765
|
body: {
|
|
5760
|
-
subject: "https://
|
|
5766
|
+
subject: "https://1.1.1.1/@john",
|
|
5761
5767
|
aliases: ["acct:john@["]
|
|
5762
5768
|
},
|
|
5763
5769
|
headers: { "Content-Type": "application/jrd+json" }
|
|
@@ -5770,8 +5776,8 @@ test("getActorHandle() records activitypub.actor.discovery counter", { permissio
|
|
|
5770
5776
|
});
|
|
5771
5777
|
await t.step("propagates meterProvider into the nested webfinger.lookup", async () => {
|
|
5772
5778
|
esm_default.removeRoutes();
|
|
5773
|
-
esm_default.get("begin:https://
|
|
5774
|
-
body: { subject: "acct:johndoe@
|
|
5779
|
+
esm_default.get("begin:https://1.1.1.1/.well-known/webfinger?", {
|
|
5780
|
+
body: { subject: "acct:johndoe@1.1.1.1" },
|
|
5775
5781
|
headers: { "Content-Type": "application/jrd+json" }
|
|
5776
5782
|
});
|
|
5777
5783
|
const [meterProvider, recorder] = createTestMeterProvider();
|
|
@@ -5782,8 +5788,8 @@ test("getActorHandle() records activitypub.actor.discovery counter", { permissio
|
|
|
5782
5788
|
});
|
|
5783
5789
|
await t.step("omits measurements when no meterProvider is provided", async () => {
|
|
5784
5790
|
esm_default.removeRoutes();
|
|
5785
|
-
esm_default.get("begin:https://
|
|
5786
|
-
body: { subject: "acct:johndoe@
|
|
5791
|
+
esm_default.get("begin:https://1.1.1.1/.well-known/webfinger?", {
|
|
5792
|
+
body: { subject: "acct:johndoe@1.1.1.1" },
|
|
5787
5793
|
headers: { "Content-Type": "application/jrd+json" }
|
|
5788
5794
|
});
|
|
5789
5795
|
const [_unused, recorder] = createTestMeterProvider();
|