@fedify/testing 2.3.15-dev.2482 → 2.3.15

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
@@ -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");
@@ -301,9 +303,11 @@ var MockFederation = class {
301
303
  outboxListenersInitialized = false;
302
304
  contextData;
303
305
  receivedActivities = [];
306
+ documentLoader;
304
307
  constructor(options = {}) {
305
308
  this.options = options;
306
309
  this.contextData = options.contextData;
310
+ if (options.allowPrivateAddress === true) this.documentLoader = (0, _fedify_vocab_runtime.getDocumentLoader)({ allowPrivateAddress: true });
307
311
  }
308
312
  setNodeInfoDispatcher(path, dispatcher) {
309
313
  this.nodeInfoDispatcher = dispatcher;
@@ -482,7 +486,9 @@ var MockFederation = class {
482
486
  data: contextData,
483
487
  federation: mockFederation,
484
488
  meterProvider: this.options.meterProvider,
485
- tracerProvider: this.options.tracerProvider
489
+ documentLoader: this.documentLoader,
490
+ contextLoader: this.documentLoader,
491
+ tracerProvider: this.options.tracerProvider ?? (this.documentLoader == null ? void 0 : _opentelemetry_api.trace.getTracerProvider())
486
492
  });
487
493
  }
488
494
  async fetch(request, options) {
@@ -502,10 +508,18 @@ var MockFederation = class {
502
508
  const typeName = activity.constructor.name;
503
509
  const listeners = this.inboxListeners.get(typeName) || [];
504
510
  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.");
511
+ const receivedActivity = listeners.length > 0 && this.documentLoader != null ? activity.clone({}, {
512
+ documentLoader: this.documentLoader,
513
+ contextLoader: this.documentLoader
514
+ }) : activity;
515
+ if (receivedActivity !== activity) Reflect.set(receivedActivity, "_cachedJsonLd", Reflect.get(activity, "_cachedJsonLd"));
505
516
  for (const listener of listeners) await listener(createInboxContext({
506
517
  data: this.contextData,
507
- federation: this
508
- }), activity);
518
+ federation: this,
519
+ documentLoader: this.documentLoader,
520
+ contextLoader: this.documentLoader,
521
+ tracerProvider: this.documentLoader == null ? void 0 : this.options.tracerProvider ?? _opentelemetry_api.trace.getTracerProvider()
522
+ }), receivedActivity);
509
523
  }
510
524
  /**
511
525
  * Simulates posting an activity to a local actor outbox.
package/dist/mod.d.cts CHANGED
@@ -150,6 +150,14 @@ declare function createFederation<TContextData>(options?: {
150
150
  * @since 2.3.0
151
151
  */
152
152
  meterProvider?: any;
153
+ /**
154
+ * Use HTTP document loading for received activities and contexts created by
155
+ * this federation, allowing private addresses such as localhost.
156
+ * If false or omitted, contexts retain their no-op mock loaders and
157
+ * received activities retain their own loaders.
158
+ * @since 2.0.35
159
+ */
160
+ allowPrivateAddress?: boolean;
153
161
  tracerProvider?: any;
154
162
  }): TestFederation<TContextData>;
155
163
  //#endregion
package/dist/mod.d.ts CHANGED
@@ -150,6 +150,14 @@ declare function createFederation<TContextData>(options?: {
150
150
  * @since 2.3.0
151
151
  */
152
152
  meterProvider?: any;
153
+ /**
154
+ * Use HTTP document loading for received activities and contexts created by
155
+ * this federation, allowing private addresses such as localhost.
156
+ * If false or omitted, contexts retain their no-op mock loaders and
157
+ * received activities retain their own loaders.
158
+ * @since 2.0.35
159
+ */
160
+ allowPrivateAddress?: boolean;
153
161
  tracerProvider?: any;
154
162
  }): TestFederation<TContextData>;
155
163
  //#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";
@@ -300,9 +302,11 @@ var MockFederation = class {
300
302
  outboxListenersInitialized = false;
301
303
  contextData;
302
304
  receivedActivities = [];
305
+ documentLoader;
303
306
  constructor(options = {}) {
304
307
  this.options = options;
305
308
  this.contextData = options.contextData;
309
+ if (options.allowPrivateAddress === true) this.documentLoader = getDocumentLoader({ allowPrivateAddress: true });
306
310
  }
307
311
  setNodeInfoDispatcher(path, dispatcher) {
308
312
  this.nodeInfoDispatcher = dispatcher;
@@ -481,7 +485,9 @@ var MockFederation = class {
481
485
  data: contextData,
482
486
  federation: mockFederation,
483
487
  meterProvider: this.options.meterProvider,
484
- tracerProvider: this.options.tracerProvider
488
+ documentLoader: this.documentLoader,
489
+ contextLoader: this.documentLoader,
490
+ tracerProvider: this.options.tracerProvider ?? (this.documentLoader == null ? void 0 : trace.getTracerProvider())
485
491
  });
486
492
  }
487
493
  async fetch(request, options) {
@@ -501,10 +507,18 @@ var MockFederation = class {
501
507
  const typeName = activity.constructor.name;
502
508
  const listeners = this.inboxListeners.get(typeName) || [];
503
509
  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.");
510
+ const receivedActivity = listeners.length > 0 && this.documentLoader != null ? activity.clone({}, {
511
+ documentLoader: this.documentLoader,
512
+ contextLoader: this.documentLoader
513
+ }) : activity;
514
+ if (receivedActivity !== activity) Reflect.set(receivedActivity, "_cachedJsonLd", Reflect.get(activity, "_cachedJsonLd"));
504
515
  for (const listener of listeners) await listener(createInboxContext({
505
516
  data: this.contextData,
506
- federation: this
507
- }), activity);
517
+ federation: this,
518
+ documentLoader: this.documentLoader,
519
+ contextLoader: this.documentLoader,
520
+ tracerProvider: this.documentLoader == null ? void 0 : this.options.tracerProvider ?? trace.getTracerProvider()
521
+ }), receivedActivity);
508
522
  }
509
523
  /**
510
524
  * 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.3.15-dev.2482+41d364a2",
3
+ "version": "2.3.15",
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.3.15-dev.2482+41d364a2"
53
+ "@fedify/fedify": "^2.3.15"
54
54
  },
55
55
  "dependencies": {
56
- "es-toolkit": "1.46.1"
56
+ "@js-temporal/polyfill": "^0.5.1",
57
+ "@opentelemetry/api": "~1.9.1",
58
+ "es-toolkit": "1.46.1",
59
+ "@fedify/vocab": "^2.3.15",
60
+ "@fedify/vocab-runtime": "^2.3.15"
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.22.0",
63
66
  "typescript": "^6.0.0",
64
- "@fedify/fixture": "^2.0.0",
65
- "@fedify/vocab-runtime": "^2.3.15-dev.2482+41d364a2",
66
- "@fedify/vocab": "^2.3.15-dev.2482+41d364a2"
67
+ "@fedify/fixture": "^2.0.0"
67
68
  },
68
69
  "scripts": {
69
70
  "build:self": "tsdown",