@fedify/vocab 2.3.0-dev.1189 → 2.3.0-dev.1190

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/vocab",
3
- "version": "2.3.0-dev.1189+97e55e59",
3
+ "version": "2.3.0-dev.1190+2dfa46e0",
4
4
  "license": "MIT",
5
5
  "exports": {
6
6
  ".": "./src/mod.ts"
package/dist/mod.cjs CHANGED
@@ -33,7 +33,7 @@ let _fedify_vocab_runtime_temporal = require("@fedify/vocab-runtime/temporal");
33
33
  let es_toolkit = require("es-toolkit");
34
34
  //#region deno.json
35
35
  var name = "@fedify/vocab";
36
- var version = "2.3.0-dev.1189+97e55e59";
36
+ var version = "2.3.0-dev.1190+2dfa46e0";
37
37
  //#endregion
38
38
  //#region src/type.ts
39
39
  function getTypeId(object) {
@@ -47372,7 +47372,7 @@ function getActorDiscoveryInstruments(meterProvider) {
47372
47372
  function getActorDiscoveryRemoteHost(actor) {
47373
47373
  const id = actor instanceof URL ? actor : actor.id;
47374
47374
  if (id == null) return void 0;
47375
- return id.hostname === "" ? void 0 : id.hostname;
47375
+ return id.host === "" ? void 0 : id.host;
47376
47376
  }
47377
47377
  var ActorHandleNotFoundError = class extends TypeError {
47378
47378
  constructor() {
@@ -47635,7 +47635,7 @@ function getLookupRemoteHost(identifier) {
47635
47635
  } catch {
47636
47636
  return extractHandleHost(identifier.startsWith("@") ? identifier.slice(1) : identifier);
47637
47637
  }
47638
- if (url.hostname !== "") return url.hostname;
47638
+ if (url.host !== "") return url.host;
47639
47639
  if (url.protocol === "acct:") return extractHandleHost(url.pathname);
47640
47640
  }
47641
47641
  function extractHandleHost(handle) {
@@ -47644,7 +47644,7 @@ function extractHandleHost(handle) {
47644
47644
  const candidate = handle.slice(at + 1);
47645
47645
  if (/[/?#\s]/.test(candidate)) return void 0;
47646
47646
  try {
47647
- return new URL(`https://${candidate}`).hostname || void 0;
47647
+ return new URL(`https://${candidate}`).host || void 0;
47648
47648
  } catch {
47649
47649
  return;
47650
47650
  }
package/dist/mod.js CHANGED
@@ -9,7 +9,7 @@ import { isTemporalDuration, isTemporalInstant } from "@fedify/vocab-runtime/tem
9
9
  import { delay } from "es-toolkit";
10
10
  //#region deno.json
11
11
  var name = "@fedify/vocab";
12
- var version = "2.3.0-dev.1189+97e55e59";
12
+ var version = "2.3.0-dev.1190+2dfa46e0";
13
13
  //#endregion
14
14
  //#region src/type.ts
15
15
  function getTypeId(object) {
@@ -47348,7 +47348,7 @@ function getActorDiscoveryInstruments(meterProvider) {
47348
47348
  function getActorDiscoveryRemoteHost(actor) {
47349
47349
  const id = actor instanceof URL ? actor : actor.id;
47350
47350
  if (id == null) return void 0;
47351
- return id.hostname === "" ? void 0 : id.hostname;
47351
+ return id.host === "" ? void 0 : id.host;
47352
47352
  }
47353
47353
  var ActorHandleNotFoundError = class extends TypeError {
47354
47354
  constructor() {
@@ -47611,7 +47611,7 @@ function getLookupRemoteHost(identifier) {
47611
47611
  } catch {
47612
47612
  return extractHandleHost(identifier.startsWith("@") ? identifier.slice(1) : identifier);
47613
47613
  }
47614
- if (url.hostname !== "") return url.hostname;
47614
+ if (url.host !== "") return url.host;
47615
47615
  if (url.protocol === "acct:") return extractHandleHost(url.pathname);
47616
47616
  }
47617
47617
  function extractHandleHost(handle) {
@@ -47620,7 +47620,7 @@ function extractHandleHost(handle) {
47620
47620
  const candidate = handle.slice(at + 1);
47621
47621
  if (/[/?#\s]/.test(candidate)) return void 0;
47622
47622
  try {
47623
- return new URL(`https://${candidate}`).hostname || void 0;
47623
+ return new URL(`https://${candidate}`).host || void 0;
47624
47624
  } catch {
47625
47625
  return;
47626
47626
  }
@@ -1206,7 +1206,7 @@ var esm_default = new class FetchMock {
1206
1206
  //#endregion
1207
1207
  //#region deno.json
1208
1208
  var name = "@fedify/vocab";
1209
- var version = "2.3.0-dev.1189+97e55e59";
1209
+ var version = "2.3.0-dev.1190+2dfa46e0";
1210
1210
  //#endregion
1211
1211
  //#region src/actor.ts
1212
1212
  const ACTOR_DISCOVERY_HISTOGRAM_BUCKETS = [
@@ -1248,7 +1248,7 @@ function getActorDiscoveryInstruments(meterProvider) {
1248
1248
  function getActorDiscoveryRemoteHost(actor) {
1249
1249
  const id = actor instanceof URL ? actor : actor.id;
1250
1250
  if (id == null) return void 0;
1251
- return id.hostname === "" ? void 0 : id.hostname;
1251
+ return id.host === "" ? void 0 : id.host;
1252
1252
  }
1253
1253
  var ActorHandleNotFoundError = class extends TypeError {
1254
1254
  constructor() {
@@ -1,7 +1,7 @@
1
1
  import "@js-temporal/polyfill";
2
2
  globalThis.addEventListener = () => {};
3
3
  import { j as __exportAll, r as Application, u as Group, v as Organization, w as Service, y as Person } from "./vocab-B0Z-tH4q.mjs";
4
- import { a as normalizeActorHandle, c as esm_default, i as isActor, n as getActorHandle, r as getActorTypeName, t as getActorClassByTypeName } from "./actor-CFYfbiwh.mjs";
4
+ import { a as normalizeActorHandle, c as esm_default, i as isActor, n as getActorHandle, r as getActorTypeName, t as getActorClassByTypeName } from "./actor-CY7bpkap.mjs";
5
5
  import { createTestMeterProvider, test } from "@fedify/fixture";
6
6
  import { deepStrictEqual, ok, rejects, strictEqual, throws } from "node:assert/strict";
7
7
  //#region ../../node_modules/.pnpm/fast-check@3.23.2/node_modules/fast-check/lib/esm/check/precondition/PreconditionFailure.js
@@ -5744,6 +5744,15 @@ test("getActorHandle() records activitypub.actor.discovery counter", { permissio
5744
5744
  ok(duration != null);
5745
5745
  deepStrictEqual(duration.attributes["activitypub.actor.discovery.result"], "not_found");
5746
5746
  });
5747
+ await t.step("records non-default ports for actor IDs", async () => {
5748
+ esm_default.removeRoutes();
5749
+ esm_default.get("begin:https://foo.example.com:8443/.well-known/webfinger?", { status: 404 });
5750
+ const [meterProvider, recorder] = createTestMeterProvider();
5751
+ await rejects(() => getActorHandle(new URL("https://foo.example.com:8443/@john"), { meterProvider }), TypeError);
5752
+ const counter = recorder.getMeasurement("activitypub.actor.discovery");
5753
+ ok(counter != null);
5754
+ deepStrictEqual(counter.attributes["activitypub.remote.host"], "foo.example.com:8443");
5755
+ });
5747
5756
  await t.step("records result=error when a malformed WebFinger alias throws TypeError", async () => {
5748
5757
  esm_default.removeRoutes();
5749
5758
  esm_default.get("begin:https://foo.example.com/.well-known/webfinger?", {
@@ -1,7 +1,7 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  globalThis.addEventListener = () => {};
3
3
  import { g as Object$1, h as Note, i as Collection, y as Person } from "./vocab-B0Z-tH4q.mjs";
4
- import { c as esm_default, i as isActor, o as name, s as version } from "./actor-CFYfbiwh.mjs";
4
+ import { c as esm_default, i as isActor, o as name, s as version } from "./actor-CY7bpkap.mjs";
5
5
  import { t as getTypeId } from "./type-Cf-vxmre.mjs";
6
6
  import { t as assertInstanceOf } from "./utils-CE8Dk5hm.mjs";
7
7
  import { createTestMeterProvider, createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
@@ -87,7 +87,7 @@ function getLookupRemoteHost(identifier) {
87
87
  } catch {
88
88
  return extractHandleHost(identifier.startsWith("@") ? identifier.slice(1) : identifier);
89
89
  }
90
- if (url.hostname !== "") return url.hostname;
90
+ if (url.host !== "") return url.host;
91
91
  if (url.protocol === "acct:") return extractHandleHost(url.pathname);
92
92
  }
93
93
  function extractHandleHost(handle) {
@@ -96,7 +96,7 @@ function extractHandleHost(handle) {
96
96
  const candidate = handle.slice(at + 1);
97
97
  if (/[/?#\s]/.test(candidate)) return void 0;
98
98
  try {
99
- return new URL(`https://${candidate}`).hostname || void 0;
99
+ return new URL(`https://${candidate}`).host || void 0;
100
100
  } catch {
101
101
  return;
102
102
  }
@@ -753,6 +753,23 @@ test("lookupObject() records activitypub.object.lookup counter", {
753
753
  deepStrictEqual(counters[0].attributes["activitypub.lookup.kind"], "object");
754
754
  deepStrictEqual(counters[0].attributes["activitypub.remote.host"], "example.com");
755
755
  });
756
+ await t.step("records non-default ports for URL identifiers", async () => {
757
+ const [meterProvider, recorder] = createTestMeterProvider();
758
+ assertInstanceOf(await lookupObject("https://example.com:8443/object", {
759
+ documentLoader: (url) => Promise.resolve({
760
+ contextUrl: null,
761
+ documentUrl: url,
762
+ document: {
763
+ "@context": "https://www.w3.org/ns/activitystreams",
764
+ id: url,
765
+ type: "Note"
766
+ }
767
+ }),
768
+ contextLoader: mockDocumentLoader,
769
+ meterProvider
770
+ }), Object$1);
771
+ deepStrictEqual(recorder.getMeasurement("activitypub.object.lookup")?.attributes["activitypub.remote.host"], "example.com:8443");
772
+ });
756
773
  await t.step("records kind=other on null result", async () => {
757
774
  esm_default.removeRoutes();
758
775
  esm_default.get("begin:https://example.com/.well-known/webfinger", {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/vocab",
3
- "version": "2.3.0-dev.1189+97e55e59",
3
+ "version": "2.3.0-dev.1190+2dfa46e0",
4
4
  "homepage": "https://fedify.dev/",
5
5
  "repository": {
6
6
  "type": "git",
@@ -46,9 +46,9 @@
46
46
  "es-toolkit": "1.46.1",
47
47
  "jsonld": "^9.0.0",
48
48
  "pkijs": "^3.3.3",
49
- "@fedify/vocab-tools": "2.3.0-dev.1189+97e55e59",
50
- "@fedify/vocab-runtime": "2.3.0-dev.1189+97e55e59",
51
- "@fedify/webfinger": "2.3.0-dev.1189+97e55e59"
49
+ "@fedify/vocab-tools": "2.3.0-dev.1190+2dfa46e0",
50
+ "@fedify/webfinger": "2.3.0-dev.1190+2dfa46e0",
51
+ "@fedify/vocab-runtime": "2.3.0-dev.1190+2dfa46e0"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@types/node": "^22.17.0",
package/src/actor.test.ts CHANGED
@@ -297,6 +297,31 @@ test("getActorHandle() records activitypub.actor.discovery counter", {
297
297
  },
298
298
  );
299
299
 
300
+ await t.step(
301
+ "records non-default ports for actor IDs",
302
+ async () => {
303
+ fetchMock.removeRoutes();
304
+ fetchMock.get(
305
+ "begin:https://foo.example.com:8443/.well-known/webfinger?",
306
+ { status: 404 },
307
+ );
308
+ const [meterProvider, recorder] = createTestMeterProvider();
309
+ await rejects(
310
+ () =>
311
+ getActorHandle(new URL("https://foo.example.com:8443/@john"), {
312
+ meterProvider,
313
+ }),
314
+ TypeError,
315
+ );
316
+ const counter = recorder.getMeasurement("activitypub.actor.discovery");
317
+ ok(counter != null);
318
+ deepStrictEqual(
319
+ counter.attributes["activitypub.remote.host"],
320
+ "foo.example.com:8443",
321
+ );
322
+ },
323
+ );
324
+
300
325
  await t.step(
301
326
  "records result=error when a malformed WebFinger alias throws TypeError",
302
327
  async () => {
package/src/actor.ts CHANGED
@@ -93,7 +93,7 @@ function getActorDiscoveryRemoteHost(
93
93
  ): string | undefined {
94
94
  const id = actor instanceof URL ? actor : actor.id;
95
95
  if (id == null) return undefined;
96
- return id.hostname === "" ? undefined : id.hostname;
96
+ return id.host === "" ? undefined : id.host;
97
97
  }
98
98
 
99
99
  // Subclass of TypeError that preserves the documented `throws {TypeError}`
@@ -765,6 +765,33 @@ test("lookupObject() records activitypub.object.lookup counter", {
765
765
  );
766
766
  });
767
767
 
768
+ await t.step(
769
+ "records non-default ports for URL identifiers",
770
+ async () => {
771
+ const [meterProvider, recorder] = createTestMeterProvider();
772
+ const object = await lookupObject("https://example.com:8443/object", {
773
+ documentLoader: (url) =>
774
+ Promise.resolve({
775
+ contextUrl: null,
776
+ documentUrl: url,
777
+ document: {
778
+ "@context": "https://www.w3.org/ns/activitystreams",
779
+ id: url,
780
+ type: "Note",
781
+ },
782
+ }),
783
+ contextLoader: mockDocumentLoader,
784
+ meterProvider,
785
+ });
786
+ assertInstanceOf(object, Object);
787
+ const counter = recorder.getMeasurement("activitypub.object.lookup");
788
+ deepStrictEqual(
789
+ counter?.attributes["activitypub.remote.host"],
790
+ "example.com:8443",
791
+ );
792
+ },
793
+ );
794
+
768
795
  await t.step("records kind=other on null result", async () => {
769
796
  fetchMock.removeRoutes();
770
797
  fetchMock.get("begin:https://example.com/.well-known/webfinger", {
package/src/lookup.ts CHANGED
@@ -67,13 +67,13 @@ function getLookupRemoteHost(identifier: string | URL): string | undefined {
67
67
  return extractHandleHost(stripped);
68
68
  }
69
69
  }
70
- if (url.hostname !== "") return url.hostname;
71
- // `acct:` URIs are opaque (no `//host` form), so the URL hostname is
72
- // empty. The user and authority live in `url.pathname` as
70
+ if (url.host !== "") return url.host;
71
+ // `acct:` URIs are opaque (no `//host` form), so the URL host is empty.
72
+ // The user and authority live in `url.pathname` as
73
73
  // `user@host`; reuse the same handle-extraction logic, which both
74
74
  // takes only the substring after the last `@` and refuses to record
75
75
  // anything that looks like a path / query / fragment rather than a
76
- // bare hostname.
76
+ // bare host.
77
77
  if (url.protocol === "acct:") return extractHandleHost(url.pathname);
78
78
  return undefined;
79
79
  }
@@ -87,9 +87,9 @@ function extractHandleHost(handle: string): string | undefined {
87
87
  // the metric attribute, so we drop the host entirely in those cases.
88
88
  if (/[/?#\s]/.test(candidate)) return undefined;
89
89
  // Round-trip through `URL` so the parser validates the authority and
90
- // strips any port/userinfo before we record it.
90
+ // strips any userinfo before we record it.
91
91
  try {
92
- return new URL(`https://${candidate}`).hostname || undefined;
92
+ return new URL(`https://${candidate}`).host || undefined;
93
93
  } catch {
94
94
  return undefined;
95
95
  }