@fedify/testing 2.5.0-dev.2448 → 2.5.0-dev.2492
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 +20 -5
- package/dist/mod.d.cts +8 -0
- package/dist/mod.d.ts +8 -0
- package/dist/mod.js +21 -6
- package/package.json +6 -7
package/dist/mod.cjs
CHANGED
|
@@ -3,6 +3,7 @@ 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
5
|
let _fedify_vocab_runtime = require("@fedify/vocab-runtime");
|
|
6
|
+
let _opentelemetry_api = require("@opentelemetry/api");
|
|
6
7
|
let _fedify_fedify_federation = require("@fedify/fedify/federation");
|
|
7
8
|
let es_toolkit = require("es-toolkit");
|
|
8
9
|
let node_assert_strict = require("node:assert/strict");
|
|
@@ -441,9 +442,13 @@ var MockFederation = class {
|
|
|
441
442
|
outboxListenersInitialized = false;
|
|
442
443
|
contextData;
|
|
443
444
|
receivedActivities = [];
|
|
445
|
+
documentLoader;
|
|
446
|
+
contextLoader;
|
|
444
447
|
constructor(options = {}) {
|
|
445
448
|
this.options = options;
|
|
446
449
|
this.contextData = options.contextData;
|
|
450
|
+
this.documentLoader = options.documentLoader ?? (options.allowPrivateAddress ? (0, _fedify_vocab_runtime.getDocumentLoader)({ allowPrivateAddress: true }) : void 0);
|
|
451
|
+
this.contextLoader = options.contextLoader ?? this.documentLoader;
|
|
447
452
|
}
|
|
448
453
|
setNodeInfoDispatcher(path, dispatcher) {
|
|
449
454
|
this.nodeInfoDispatcher = dispatcher;
|
|
@@ -654,9 +659,9 @@ var MockFederation = class {
|
|
|
654
659
|
data: contextData,
|
|
655
660
|
federation: mockFederation,
|
|
656
661
|
meterProvider: this.options.meterProvider,
|
|
657
|
-
tracerProvider: this.options.tracerProvider,
|
|
658
|
-
documentLoader: this.
|
|
659
|
-
contextLoader: this.
|
|
662
|
+
tracerProvider: this.options.tracerProvider ?? (this.documentLoader == null ? void 0 : _opentelemetry_api.trace.getTracerProvider()),
|
|
663
|
+
documentLoader: this.documentLoader,
|
|
664
|
+
contextLoader: this.contextLoader,
|
|
660
665
|
verifyPortableObject: this.options.verifyPortableObject,
|
|
661
666
|
portableRequest: options.portableRequest
|
|
662
667
|
});
|
|
@@ -727,10 +732,20 @@ var MockFederation = class {
|
|
|
727
732
|
const typeName = activity.constructor.name;
|
|
728
733
|
const listeners = this.inboxListeners.get(typeName) || [];
|
|
729
734
|
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.");
|
|
735
|
+
const receivedActivity = listeners.length > 0 && this.documentLoader != null ? activity.clone({}, {
|
|
736
|
+
documentLoader: this.documentLoader,
|
|
737
|
+
contextLoader: this.contextLoader
|
|
738
|
+
}) : activity;
|
|
739
|
+
if (receivedActivity !== activity) Reflect.set(receivedActivity, "_cachedJsonLd", Reflect.get(activity, "_cachedJsonLd"));
|
|
730
740
|
for (const listener of listeners) await listener(createInboxContext({
|
|
731
741
|
data: this.contextData,
|
|
732
|
-
federation: this
|
|
733
|
-
|
|
742
|
+
federation: this,
|
|
743
|
+
documentLoader: this.documentLoader,
|
|
744
|
+
contextLoader: this.contextLoader,
|
|
745
|
+
tracerProvider: this.options.tracerProvider ?? (this.documentLoader == null ? void 0 : _opentelemetry_api.trace.getTracerProvider()),
|
|
746
|
+
meterProvider: this.options.meterProvider,
|
|
747
|
+
verifyPortableObject: this.options.verifyPortableObject
|
|
748
|
+
}), receivedActivity);
|
|
734
749
|
}
|
|
735
750
|
/**
|
|
736
751
|
* Simulates posting an activity to a local actor outbox.
|
package/dist/mod.d.cts
CHANGED
|
@@ -161,6 +161,14 @@ declare function createFederation<TContextData>(options?: {
|
|
|
161
161
|
* @since 2.3.0
|
|
162
162
|
*/
|
|
163
163
|
meterProvider?: any;
|
|
164
|
+
/**
|
|
165
|
+
* Use HTTP document loading for received activities and contexts created by
|
|
166
|
+
* this federation, allowing private addresses such as localhost.
|
|
167
|
+
* If false or omitted, contexts retain their no-op mock loaders and
|
|
168
|
+
* received activities retain their own loaders.
|
|
169
|
+
* @since 2.0.35
|
|
170
|
+
*/
|
|
171
|
+
allowPrivateAddress?: boolean;
|
|
164
172
|
tracerProvider?: any; /** The document loader used by mock context lookups. @since 2.4.0 */
|
|
165
173
|
documentLoader?: DocumentLoader; /** The JSON-LD context loader used by mock context lookups. @since 2.4.0 */
|
|
166
174
|
contextLoader?: DocumentLoader;
|
package/dist/mod.d.ts
CHANGED
|
@@ -161,6 +161,14 @@ declare function createFederation<TContextData>(options?: {
|
|
|
161
161
|
* @since 2.3.0
|
|
162
162
|
*/
|
|
163
163
|
meterProvider?: any;
|
|
164
|
+
/**
|
|
165
|
+
* Use HTTP document loading for received activities and contexts created by
|
|
166
|
+
* this federation, allowing private addresses such as localhost.
|
|
167
|
+
* If false or omitted, contexts retain their no-op mock loaders and
|
|
168
|
+
* received activities retain their own loaders.
|
|
169
|
+
* @since 2.0.35
|
|
170
|
+
*/
|
|
171
|
+
allowPrivateAddress?: boolean;
|
|
164
172
|
tracerProvider?: any; /** The document loader used by mock context lookups. @since 2.4.0 */
|
|
165
173
|
documentLoader?: DocumentLoader; /** The JSON-LD context loader used by mock context lookups. @since 2.4.0 */
|
|
166
174
|
contextLoader?: DocumentLoader;
|
package/dist/mod.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Temporal } from "temporal-polyfill";
|
|
2
2
|
import { hasProofLike, hasSignatureLike } from "@fedify/fedify/sig";
|
|
3
3
|
import { Activity, CryptographicKey, Multikey, PUBLIC_COLLECTION, Tombstone, lookupObject, traverseCollection } from "@fedify/vocab";
|
|
4
|
-
import { arePortableUrisEqual, canonicalizePortableUri, decodeMultibase, formatIri, fromCompatibleEf61Id, getFe34Origin, parseDigestMultibase, parseHashlink, parseIri } from "@fedify/vocab-runtime";
|
|
4
|
+
import { arePortableUrisEqual, canonicalizePortableUri, decodeMultibase, formatIri, fromCompatibleEf61Id, getDocumentLoader, getFe34Origin, parseDigestMultibase, parseHashlink, parseIri } from "@fedify/vocab-runtime";
|
|
5
|
+
import { trace } from "@opentelemetry/api";
|
|
5
6
|
import { RouterError } from "@fedify/fedify/federation";
|
|
6
7
|
import { delay } from "es-toolkit";
|
|
7
8
|
import { deepStrictEqual, ok, strictEqual } from "node:assert/strict";
|
|
@@ -440,9 +441,13 @@ var MockFederation = class {
|
|
|
440
441
|
outboxListenersInitialized = false;
|
|
441
442
|
contextData;
|
|
442
443
|
receivedActivities = [];
|
|
444
|
+
documentLoader;
|
|
445
|
+
contextLoader;
|
|
443
446
|
constructor(options = {}) {
|
|
444
447
|
this.options = options;
|
|
445
448
|
this.contextData = options.contextData;
|
|
449
|
+
this.documentLoader = options.documentLoader ?? (options.allowPrivateAddress ? getDocumentLoader({ allowPrivateAddress: true }) : void 0);
|
|
450
|
+
this.contextLoader = options.contextLoader ?? this.documentLoader;
|
|
446
451
|
}
|
|
447
452
|
setNodeInfoDispatcher(path, dispatcher) {
|
|
448
453
|
this.nodeInfoDispatcher = dispatcher;
|
|
@@ -653,9 +658,9 @@ var MockFederation = class {
|
|
|
653
658
|
data: contextData,
|
|
654
659
|
federation: mockFederation,
|
|
655
660
|
meterProvider: this.options.meterProvider,
|
|
656
|
-
tracerProvider: this.options.tracerProvider,
|
|
657
|
-
documentLoader: this.
|
|
658
|
-
contextLoader: this.
|
|
661
|
+
tracerProvider: this.options.tracerProvider ?? (this.documentLoader == null ? void 0 : trace.getTracerProvider()),
|
|
662
|
+
documentLoader: this.documentLoader,
|
|
663
|
+
contextLoader: this.contextLoader,
|
|
659
664
|
verifyPortableObject: this.options.verifyPortableObject,
|
|
660
665
|
portableRequest: options.portableRequest
|
|
661
666
|
});
|
|
@@ -726,10 +731,20 @@ var MockFederation = class {
|
|
|
726
731
|
const typeName = activity.constructor.name;
|
|
727
732
|
const listeners = this.inboxListeners.get(typeName) || [];
|
|
728
733
|
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.");
|
|
734
|
+
const receivedActivity = listeners.length > 0 && this.documentLoader != null ? activity.clone({}, {
|
|
735
|
+
documentLoader: this.documentLoader,
|
|
736
|
+
contextLoader: this.contextLoader
|
|
737
|
+
}) : activity;
|
|
738
|
+
if (receivedActivity !== activity) Reflect.set(receivedActivity, "_cachedJsonLd", Reflect.get(activity, "_cachedJsonLd"));
|
|
729
739
|
for (const listener of listeners) await listener(createInboxContext({
|
|
730
740
|
data: this.contextData,
|
|
731
|
-
federation: this
|
|
732
|
-
|
|
741
|
+
federation: this,
|
|
742
|
+
documentLoader: this.documentLoader,
|
|
743
|
+
contextLoader: this.contextLoader,
|
|
744
|
+
tracerProvider: this.options.tracerProvider ?? (this.documentLoader == null ? void 0 : trace.getTracerProvider()),
|
|
745
|
+
meterProvider: this.options.meterProvider,
|
|
746
|
+
verifyPortableObject: this.options.verifyPortableObject
|
|
747
|
+
}), receivedActivity);
|
|
733
748
|
}
|
|
734
749
|
/**
|
|
735
750
|
* 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.5.0-dev.
|
|
3
|
+
"version": "2.5.0-dev.2492+4648c04e",
|
|
4
4
|
"description": "Testing utilities for Fedify applications",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fedify",
|
|
@@ -47,13 +47,14 @@
|
|
|
47
47
|
"package.json"
|
|
48
48
|
],
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@fedify/fedify": "^2.5.0-dev.
|
|
50
|
+
"@fedify/fedify": "^2.5.0-dev.2492+4648c04e"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
+
"@opentelemetry/api": "~1.9.1",
|
|
53
54
|
"es-toolkit": "1.46.1",
|
|
54
55
|
"temporal-polyfill": "^1.0.1",
|
|
55
|
-
"@fedify/vocab": "2.5.0-dev.
|
|
56
|
-
"@fedify/vocab
|
|
56
|
+
"@fedify/vocab-runtime": "^2.5.0-dev.2492+4648c04e",
|
|
57
|
+
"@fedify/vocab": "2.5.0-dev.2492+4648c04e"
|
|
57
58
|
},
|
|
58
59
|
"devDependencies": {
|
|
59
60
|
"@standard-schema/spec": "^1.1.0",
|
|
@@ -61,9 +62,7 @@
|
|
|
61
62
|
"@std/async": "npm:@jsr/std__async@^1.0.13",
|
|
62
63
|
"tsdown": "^0.22.0",
|
|
63
64
|
"typescript": "^6.0.0",
|
|
64
|
-
"@fedify/fixture": "^2.0.0"
|
|
65
|
-
"@fedify/vocab": "^2.5.0-dev.2448+756933d0",
|
|
66
|
-
"@fedify/vocab-runtime": "^2.5.0-dev.2448+756933d0"
|
|
65
|
+
"@fedify/fixture": "^2.0.0"
|
|
67
66
|
},
|
|
68
67
|
"scripts": {
|
|
69
68
|
"build:self": "tsdown",
|