@fedify/testing 2.2.18 → 2.2.20
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/mod.cjs +18 -3
- package/dist/mod.d.cts +8 -0
- package/dist/mod.d.ts +8 -0
- package/dist/mod.js +18 -3
- package/package.json +8 -7
package/dist/mod.cjs
CHANGED
|
@@ -2,6 +2,8 @@ const { Temporal } = require("@js-temporal/polyfill");
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
let _fedify_fedify_sig = require("@fedify/fedify/sig");
|
|
4
4
|
let _fedify_vocab = require("@fedify/vocab");
|
|
5
|
+
let _fedify_vocab_runtime = require("@fedify/vocab-runtime");
|
|
6
|
+
let _opentelemetry_api = require("@opentelemetry/api");
|
|
5
7
|
let _fedify_fedify_federation = require("@fedify/fedify/federation");
|
|
6
8
|
let es_toolkit = require("es-toolkit");
|
|
7
9
|
let node_assert_strict = require("node:assert/strict");
|
|
@@ -259,9 +261,11 @@ var MockFederation = class {
|
|
|
259
261
|
outboxListenersInitialized = false;
|
|
260
262
|
contextData;
|
|
261
263
|
receivedActivities = [];
|
|
264
|
+
documentLoader;
|
|
262
265
|
constructor(options = {}) {
|
|
263
266
|
this.options = options;
|
|
264
267
|
this.contextData = options.contextData;
|
|
268
|
+
if (options.allowPrivateAddress === true) this.documentLoader = (0, _fedify_vocab_runtime.getDocumentLoader)({ allowPrivateAddress: true });
|
|
265
269
|
}
|
|
266
270
|
setNodeInfoDispatcher(path, dispatcher) {
|
|
267
271
|
this.nodeInfoDispatcher = dispatcher;
|
|
@@ -438,7 +442,10 @@ var MockFederation = class {
|
|
|
438
442
|
url: request == null ? baseUrlOrRequest : new URL(request.url),
|
|
439
443
|
request,
|
|
440
444
|
data: contextData,
|
|
441
|
-
federation: mockFederation
|
|
445
|
+
federation: mockFederation,
|
|
446
|
+
documentLoader: this.documentLoader,
|
|
447
|
+
contextLoader: this.documentLoader,
|
|
448
|
+
tracerProvider: this.documentLoader == null ? void 0 : this.options.tracerProvider ?? _opentelemetry_api.trace.getTracerProvider()
|
|
442
449
|
});
|
|
443
450
|
}
|
|
444
451
|
async fetch(request, options) {
|
|
@@ -458,10 +465,18 @@ var MockFederation = class {
|
|
|
458
465
|
const typeName = activity.constructor.name;
|
|
459
466
|
const listeners = this.inboxListeners.get(typeName) || [];
|
|
460
467
|
if (listeners.length > 0 && this.contextData === void 0) throw new Error("MockFederation.receiveActivity(): contextData is not initialized. Please provide contextData through the constructor or call startQueue() before receiving activities.");
|
|
468
|
+
const receivedActivity = listeners.length > 0 && this.documentLoader != null ? activity.clone({}, {
|
|
469
|
+
documentLoader: this.documentLoader,
|
|
470
|
+
contextLoader: this.documentLoader
|
|
471
|
+
}) : activity;
|
|
472
|
+
if (receivedActivity !== activity) Reflect.set(receivedActivity, "_cachedJsonLd", Reflect.get(activity, "_cachedJsonLd"));
|
|
461
473
|
for (const listener of listeners) await listener(createInboxContext({
|
|
462
474
|
data: this.contextData,
|
|
463
|
-
federation: this
|
|
464
|
-
|
|
475
|
+
federation: this,
|
|
476
|
+
documentLoader: this.documentLoader,
|
|
477
|
+
contextLoader: this.documentLoader,
|
|
478
|
+
tracerProvider: this.documentLoader == null ? void 0 : this.options.tracerProvider ?? _opentelemetry_api.trace.getTracerProvider()
|
|
479
|
+
}), receivedActivity);
|
|
465
480
|
}
|
|
466
481
|
/**
|
|
467
482
|
* Simulates posting an activity to a local actor outbox.
|
package/dist/mod.d.cts
CHANGED
|
@@ -145,6 +145,14 @@ interface TestFederation<TContextData> extends Omit<Federation<TContextData>, "c
|
|
|
145
145
|
declare function createFederation<TContextData>(options?: {
|
|
146
146
|
contextData?: TContextData;
|
|
147
147
|
origin?: string;
|
|
148
|
+
/**
|
|
149
|
+
* Use HTTP document loading for received activities and contexts created by
|
|
150
|
+
* this federation, allowing private addresses such as localhost.
|
|
151
|
+
* If false or omitted, contexts retain their no-op mock loaders and
|
|
152
|
+
* received activities retain their own loaders.
|
|
153
|
+
* @since 2.0.35
|
|
154
|
+
*/
|
|
155
|
+
allowPrivateAddress?: boolean;
|
|
148
156
|
tracerProvider?: any;
|
|
149
157
|
}): TestFederation<TContextData>;
|
|
150
158
|
//#endregion
|
package/dist/mod.d.ts
CHANGED
|
@@ -145,6 +145,14 @@ interface TestFederation<TContextData> extends Omit<Federation<TContextData>, "c
|
|
|
145
145
|
declare function createFederation<TContextData>(options?: {
|
|
146
146
|
contextData?: TContextData;
|
|
147
147
|
origin?: string;
|
|
148
|
+
/**
|
|
149
|
+
* Use HTTP document loading for received activities and contexts created by
|
|
150
|
+
* this federation, allowing private addresses such as localhost.
|
|
151
|
+
* If false or omitted, contexts retain their no-op mock loaders and
|
|
152
|
+
* received activities retain their own loaders.
|
|
153
|
+
* @since 2.0.35
|
|
154
|
+
*/
|
|
155
|
+
allowPrivateAddress?: boolean;
|
|
148
156
|
tracerProvider?: any;
|
|
149
157
|
}): TestFederation<TContextData>;
|
|
150
158
|
//#endregion
|
package/dist/mod.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import { hasProofLike, hasSignatureLike } from "@fedify/fedify/sig";
|
|
3
3
|
import { Activity, CryptographicKey, Multikey, lookupObject, traverseCollection } from "@fedify/vocab";
|
|
4
|
+
import { getDocumentLoader } from "@fedify/vocab-runtime";
|
|
5
|
+
import { trace } from "@opentelemetry/api";
|
|
4
6
|
import { RouterError } from "@fedify/fedify/federation";
|
|
5
7
|
import { delay } from "es-toolkit";
|
|
6
8
|
import { deepStrictEqual, ok, strictEqual } from "node:assert/strict";
|
|
@@ -258,9 +260,11 @@ var MockFederation = class {
|
|
|
258
260
|
outboxListenersInitialized = false;
|
|
259
261
|
contextData;
|
|
260
262
|
receivedActivities = [];
|
|
263
|
+
documentLoader;
|
|
261
264
|
constructor(options = {}) {
|
|
262
265
|
this.options = options;
|
|
263
266
|
this.contextData = options.contextData;
|
|
267
|
+
if (options.allowPrivateAddress === true) this.documentLoader = getDocumentLoader({ allowPrivateAddress: true });
|
|
264
268
|
}
|
|
265
269
|
setNodeInfoDispatcher(path, dispatcher) {
|
|
266
270
|
this.nodeInfoDispatcher = dispatcher;
|
|
@@ -437,7 +441,10 @@ var MockFederation = class {
|
|
|
437
441
|
url: request == null ? baseUrlOrRequest : new URL(request.url),
|
|
438
442
|
request,
|
|
439
443
|
data: contextData,
|
|
440
|
-
federation: mockFederation
|
|
444
|
+
federation: mockFederation,
|
|
445
|
+
documentLoader: this.documentLoader,
|
|
446
|
+
contextLoader: this.documentLoader,
|
|
447
|
+
tracerProvider: this.documentLoader == null ? void 0 : this.options.tracerProvider ?? trace.getTracerProvider()
|
|
441
448
|
});
|
|
442
449
|
}
|
|
443
450
|
async fetch(request, options) {
|
|
@@ -457,10 +464,18 @@ var MockFederation = class {
|
|
|
457
464
|
const typeName = activity.constructor.name;
|
|
458
465
|
const listeners = this.inboxListeners.get(typeName) || [];
|
|
459
466
|
if (listeners.length > 0 && this.contextData === void 0) throw new Error("MockFederation.receiveActivity(): contextData is not initialized. Please provide contextData through the constructor or call startQueue() before receiving activities.");
|
|
467
|
+
const receivedActivity = listeners.length > 0 && this.documentLoader != null ? activity.clone({}, {
|
|
468
|
+
documentLoader: this.documentLoader,
|
|
469
|
+
contextLoader: this.documentLoader
|
|
470
|
+
}) : activity;
|
|
471
|
+
if (receivedActivity !== activity) Reflect.set(receivedActivity, "_cachedJsonLd", Reflect.get(activity, "_cachedJsonLd"));
|
|
460
472
|
for (const listener of listeners) await listener(createInboxContext({
|
|
461
473
|
data: this.contextData,
|
|
462
|
-
federation: this
|
|
463
|
-
|
|
474
|
+
federation: this,
|
|
475
|
+
documentLoader: this.documentLoader,
|
|
476
|
+
contextLoader: this.documentLoader,
|
|
477
|
+
tracerProvider: this.documentLoader == null ? void 0 : this.options.tracerProvider ?? trace.getTracerProvider()
|
|
478
|
+
}), receivedActivity);
|
|
464
479
|
}
|
|
465
480
|
/**
|
|
466
481
|
* Simulates posting an activity to a local actor outbox.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fedify/testing",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.20",
|
|
4
4
|
"description": "Testing utilities for Fedify applications",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fedify",
|
|
@@ -50,20 +50,21 @@
|
|
|
50
50
|
"package.json"
|
|
51
51
|
],
|
|
52
52
|
"peerDependencies": {
|
|
53
|
-
"@fedify/fedify": "^2.2.
|
|
53
|
+
"@fedify/fedify": "^2.2.20"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"
|
|
56
|
+
"@js-temporal/polyfill": "^0.5.1",
|
|
57
|
+
"@opentelemetry/api": "~1.9.0",
|
|
58
|
+
"es-toolkit": "1.43.0",
|
|
59
|
+
"@fedify/vocab": "^2.2.20",
|
|
60
|
+
"@fedify/vocab-runtime": "^2.2.20"
|
|
57
61
|
},
|
|
58
62
|
"devDependencies": {
|
|
59
|
-
"@js-temporal/polyfill": "^0.5.1",
|
|
60
63
|
"@std/assert": "npm:@jsr/std__assert@^1.0.13",
|
|
61
64
|
"@std/async": "npm:@jsr/std__async@^1.0.13",
|
|
62
65
|
"tsdown": "^0.21.6",
|
|
63
66
|
"typescript": "^6.0.0",
|
|
64
|
-
"@fedify/fixture": "^2.0.0"
|
|
65
|
-
"@fedify/vocab": "^2.2.18",
|
|
66
|
-
"@fedify/vocab-runtime": "^2.2.18"
|
|
67
|
+
"@fedify/fixture": "^2.0.0"
|
|
67
68
|
},
|
|
68
69
|
"scripts": {
|
|
69
70
|
"build:self": "tsdown",
|