@fedify/testing 2.4.5-dev.2462 → 2.4.5

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 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");
@@ -428,9 +429,13 @@ var MockFederation = class {
428
429
  outboxListenersInitialized = false;
429
430
  contextData;
430
431
  receivedActivities = [];
432
+ documentLoader;
433
+ contextLoader;
431
434
  constructor(options = {}) {
432
435
  this.options = options;
433
436
  this.contextData = options.contextData;
437
+ this.documentLoader = options.documentLoader ?? (options.allowPrivateAddress ? (0, _fedify_vocab_runtime.getDocumentLoader)({ allowPrivateAddress: true }) : void 0);
438
+ this.contextLoader = options.contextLoader ?? this.documentLoader;
434
439
  }
435
440
  setNodeInfoDispatcher(path, dispatcher) {
436
441
  this.nodeInfoDispatcher = dispatcher;
@@ -641,9 +646,9 @@ var MockFederation = class {
641
646
  data: contextData,
642
647
  federation: mockFederation,
643
648
  meterProvider: this.options.meterProvider,
644
- tracerProvider: this.options.tracerProvider,
645
- documentLoader: this.options.documentLoader,
646
- contextLoader: this.options.contextLoader,
649
+ tracerProvider: this.options.tracerProvider ?? (this.documentLoader == null ? void 0 : _opentelemetry_api.trace.getTracerProvider()),
650
+ documentLoader: this.documentLoader,
651
+ contextLoader: this.contextLoader,
647
652
  verifyPortableObject: this.options.verifyPortableObject,
648
653
  portableRequest: options.portableRequest
649
654
  });
@@ -714,10 +719,20 @@ var MockFederation = class {
714
719
  const typeName = activity.constructor.name;
715
720
  const listeners = this.inboxListeners.get(typeName) || [];
716
721
  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.");
722
+ const receivedActivity = listeners.length > 0 && this.documentLoader != null ? activity.clone({}, {
723
+ documentLoader: this.documentLoader,
724
+ contextLoader: this.contextLoader
725
+ }) : activity;
726
+ if (receivedActivity !== activity) Reflect.set(receivedActivity, "_cachedJsonLd", Reflect.get(activity, "_cachedJsonLd"));
717
727
  for (const listener of listeners) await listener(createInboxContext({
718
728
  data: this.contextData,
719
- federation: this
720
- }), activity);
729
+ federation: this,
730
+ documentLoader: this.documentLoader,
731
+ contextLoader: this.contextLoader,
732
+ tracerProvider: this.options.tracerProvider ?? (this.documentLoader == null ? void 0 : _opentelemetry_api.trace.getTracerProvider()),
733
+ meterProvider: this.options.meterProvider,
734
+ verifyPortableObject: this.options.verifyPortableObject
735
+ }), receivedActivity);
721
736
  }
722
737
  /**
723
738
  * 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";
@@ -427,9 +428,13 @@ var MockFederation = class {
427
428
  outboxListenersInitialized = false;
428
429
  contextData;
429
430
  receivedActivities = [];
431
+ documentLoader;
432
+ contextLoader;
430
433
  constructor(options = {}) {
431
434
  this.options = options;
432
435
  this.contextData = options.contextData;
436
+ this.documentLoader = options.documentLoader ?? (options.allowPrivateAddress ? getDocumentLoader({ allowPrivateAddress: true }) : void 0);
437
+ this.contextLoader = options.contextLoader ?? this.documentLoader;
433
438
  }
434
439
  setNodeInfoDispatcher(path, dispatcher) {
435
440
  this.nodeInfoDispatcher = dispatcher;
@@ -640,9 +645,9 @@ var MockFederation = class {
640
645
  data: contextData,
641
646
  federation: mockFederation,
642
647
  meterProvider: this.options.meterProvider,
643
- tracerProvider: this.options.tracerProvider,
644
- documentLoader: this.options.documentLoader,
645
- contextLoader: this.options.contextLoader,
648
+ tracerProvider: this.options.tracerProvider ?? (this.documentLoader == null ? void 0 : trace.getTracerProvider()),
649
+ documentLoader: this.documentLoader,
650
+ contextLoader: this.contextLoader,
646
651
  verifyPortableObject: this.options.verifyPortableObject,
647
652
  portableRequest: options.portableRequest
648
653
  });
@@ -713,10 +718,20 @@ var MockFederation = class {
713
718
  const typeName = activity.constructor.name;
714
719
  const listeners = this.inboxListeners.get(typeName) || [];
715
720
  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.");
721
+ const receivedActivity = listeners.length > 0 && this.documentLoader != null ? activity.clone({}, {
722
+ documentLoader: this.documentLoader,
723
+ contextLoader: this.contextLoader
724
+ }) : activity;
725
+ if (receivedActivity !== activity) Reflect.set(receivedActivity, "_cachedJsonLd", Reflect.get(activity, "_cachedJsonLd"));
716
726
  for (const listener of listeners) await listener(createInboxContext({
717
727
  data: this.contextData,
718
- federation: this
719
- }), activity);
728
+ federation: this,
729
+ documentLoader: this.documentLoader,
730
+ contextLoader: this.contextLoader,
731
+ tracerProvider: this.options.tracerProvider ?? (this.documentLoader == null ? void 0 : trace.getTracerProvider()),
732
+ meterProvider: this.options.meterProvider,
733
+ verifyPortableObject: this.options.verifyPortableObject
734
+ }), receivedActivity);
720
735
  }
721
736
  /**
722
737
  * 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.4.5-dev.2462+46a3f2c5",
3
+ "version": "2.4.5",
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.4.5-dev.2462+46a3f2c5"
50
+ "@fedify/fedify": "^2.4.5"
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.4.5-dev.2462+46a3f2c5",
56
- "@fedify/vocab-runtime": "^2.4.5-dev.2462+46a3f2c5"
56
+ "@fedify/vocab-runtime": "^2.4.5",
57
+ "@fedify/vocab": "2.4.5"
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/vocab": "^2.4.5-dev.2462+46a3f2c5",
65
- "@fedify/fixture": "^2.0.0",
66
- "@fedify/vocab-runtime": "^2.4.5-dev.2462+46a3f2c5"
65
+ "@fedify/fixture": "^2.0.0"
67
66
  },
68
67
  "scripts": {
69
68
  "build:self": "tsdown",