@fedify/fedify 1.6.1-dev.851 → 1.6.1-dev.856

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.
Files changed (74) hide show
  1. package/dist/_virtual/rolldown_runtime.js +26 -1
  2. package/dist/codegen/schema.js +5 -4
  3. package/dist/deno.js +15 -2
  4. package/dist/federation/middleware.test.js +62 -53
  5. package/dist/federation/send.test.js +8 -10
  6. package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/_common/constants.js +1 -7
  7. package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/_common/dirname.js +1 -1
  8. package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/_common/normalize.js +1 -1
  9. package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/dirname.js +1 -32
  10. package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/join.js +1 -32
  11. package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/mod.js +0 -2
  12. package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/posix/_util.js +1 -1
  13. package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/posix/dirname.js +2 -2
  14. package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/posix/normalize.js +2 -2
  15. package/dist/node_modules/.pnpm/@jsr_std__url@1.0.0-rc.3/node_modules/@jsr/std__url/dirname.js +1 -1
  16. package/dist/node_modules/.pnpm/@jsr_std__url@1.0.0-rc.3/node_modules/@jsr/std__url/join.js +1 -1
  17. package/dist/node_modules/.pnpm/dequal@2.0.3/node_modules/dequal/dist/index.js +68 -0
  18. package/dist/node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/CallHistory.js +94 -0
  19. package/dist/node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/FetchMock.js +143 -0
  20. package/dist/node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/IsSubsetOf.js +103 -0
  21. package/dist/node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/Matchers.js +195 -0
  22. package/dist/node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/RequestUtils.js +83 -0
  23. package/dist/node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/Route.js +137 -0
  24. package/dist/node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/Router.js +181 -0
  25. package/dist/node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/StatusTextMap.js +73 -0
  26. package/dist/node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/TypeDescriptor.js +97 -0
  27. package/dist/node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/index.js +11 -0
  28. package/dist/node_modules/.pnpm/glob-to-regexp@0.4.1/node_modules/glob-to-regexp/index.js +87 -0
  29. package/dist/node_modules/.pnpm/regexparam@3.0.0/node_modules/regexparam/dist/index.js +37 -0
  30. package/dist/runtime/authdocloader.test.js +5 -5
  31. package/dist/runtime/docloader.js +1 -1
  32. package/dist/runtime/docloader.test.js +8 -0
  33. package/dist/sig/key.js +7 -2
  34. package/dist/testing/docloader.js +34 -15
  35. package/dist/testing/fixtures/example.com/{hong-gildong → hong-gildong.json} +1 -1
  36. package/dist/testing/fixtures/example.com/{object → object.json} +1 -1
  37. package/dist/testing/fixtures/example.com/person.js +29 -0
  38. package/dist/testing/fixtures/example.com/person2.js +48 -0
  39. package/dist/testing/fixtures/example.com/{test → test.json} +1 -1
  40. package/dist/testing/fixtures/w3id.org/security/data-integrity/{v1 → v1.json} +1 -1
  41. package/dist/testing/fixtures/w3id.org/security/{v1 → v1.json} +9 -9
  42. package/dist/testing/mod.d.ts +11 -0
  43. package/dist/testing/mod.js +44 -38
  44. package/dist/vocab/lookup.test.js +30 -35
  45. package/dist/vocab/vocab.js +176 -176
  46. package/dist/vocab/vocab.test.js +2 -2
  47. package/package.json +8 -3
  48. package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/windows/_util.js +0 -19
  49. package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/windows/dirname.js +0 -75
  50. package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/windows/join.js +0 -54
  51. package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/windows/normalize.js +0 -87
  52. /package/dist/testing/fixtures/activitypub.academy/users/{brauca_darradiul → brauca_darradiul.json} +0 -0
  53. /package/dist/testing/fixtures/example.com/{announce → announce.json} +0 -0
  54. /package/dist/testing/fixtures/example.com/{collection → collection.json} +0 -0
  55. /package/dist/testing/fixtures/example.com/{create → create.json} +0 -0
  56. /package/dist/testing/fixtures/example.com/{cross-origin-actor → cross-origin-actor.json} +0 -0
  57. /package/dist/testing/fixtures/example.com/{invite → invite.json} +0 -0
  58. /package/dist/testing/fixtures/example.com/{key → key.json} +0 -0
  59. /package/dist/testing/fixtures/example.com/{key2 → key2.json} +0 -0
  60. /package/dist/testing/fixtures/example.com/{orderedcollectionpage → orderedcollectionpage.json} +0 -0
  61. /package/dist/testing/fixtures/example.com/paged/{a → a.json} +0 -0
  62. /package/dist/testing/fixtures/example.com/paged/{b → b.json} +0 -0
  63. /package/dist/testing/fixtures/example.com/{paged-collection → paged-collection.json} +0 -0
  64. /package/dist/testing/fixtures/example.com/{person → person.json} +0 -0
  65. /package/dist/testing/fixtures/example.com/{person2 → person2.json} +0 -0
  66. /package/dist/testing/fixtures/example.com/users/{handle → handle.json} +0 -0
  67. /package/dist/testing/fixtures/example.com/{wrong-type → wrong-type.json} +0 -0
  68. /package/dist/testing/fixtures/remote.domain/users/{bob → bob.json} +0 -0
  69. /package/dist/testing/fixtures/server.example/users/{alice → alice.json} +0 -0
  70. /package/dist/testing/fixtures/w3id.org/identity/{v1 → v1.json} +0 -0
  71. /package/dist/testing/fixtures/w3id.org/security/multikey/{v1 → v1.json} +0 -0
  72. /package/dist/testing/fixtures/wizard.casa/users/{hongminhee → hongminhee.json} +0 -0
  73. /package/dist/testing/fixtures/www.w3.org/ns/{activitystreams → activitystreams.json} +0 -0
  74. /package/dist/testing/fixtures/www.w3.org/ns/did/{v1 → v1.json} +0 -0
package/dist/sig/key.js CHANGED
@@ -79,8 +79,13 @@ async function importJwk(jwk, type) {
79
79
  name: "RSASSA-PKCS1-v1_5",
80
80
  hash: "SHA-256"
81
81
  }, true, type === "public" ? ["verify"] : ["sign"]);
82
- else if (jwk.kty === "OKP" && jwk.crv === "Ed25519") key = await crypto.subtle.importKey("jwk", jwk, "Ed25519", true, type === "public" ? ["verify"] : ["sign"]);
83
- else throw new TypeError("Unsupported JWK format.");
82
+ else if (jwk.kty === "OKP" && jwk.crv === "Ed25519") {
83
+ if (navigator?.userAgent === "Cloudflare-Workers") {
84
+ jwk = { ...jwk };
85
+ delete jwk.alg;
86
+ }
87
+ key = await crypto.subtle.importKey("jwk", jwk, "Ed25519", true, type === "public" ? ["verify"] : ["sign"]);
88
+ } else throw new TypeError("Unsupported JWK format.");
84
89
  validateCryptoKey(key, type);
85
90
  return key;
86
91
  }
@@ -2,11 +2,7 @@
2
2
  import { Temporal } from "@js-temporal/polyfill";
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
 
5
- import { dirname } from "../node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/dirname.js";
6
- import { fromFileUrl } from "../node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/from_file_url.js";
7
- import { join } from "../node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/join.js";
8
5
  import { getLogger } from "@logtape/logtape";
9
- import { readFileSync } from "node:fs";
10
6
 
11
7
  //#region testing/docloader.ts
12
8
  const logger = getLogger([
@@ -22,26 +18,49 @@ const logger = getLogger([
22
18
  * the file `testing/fixtures/http/example.com/foo/bar` (no suffix) and return
23
19
  * its content as the response.
24
20
  */
25
- function mockDocumentLoader(resource) {
21
+ async function mockDocumentLoader(resource) {
26
22
  const url = new URL(resource);
27
- const path = (url.host + url.pathname).split("/");
28
- if (url.search) path.push(url.search);
29
- const filePath = join(dirname(fromFileUrl(import.meta.url)), "fixtures", ...path);
30
- let content;
23
+ if ("navigator" in globalThis && navigator.userAgent === "Cloudflare-Workers") {
24
+ const testUrl = new URL(url);
25
+ testUrl.hostname += ".test";
26
+ const resp = await fetch(testUrl);
27
+ if (resp.ok) {
28
+ const document$1 = await resp.json();
29
+ logger.debug("Successfully fetched fixture {resource}: {status} {statusText}\n{body}", {
30
+ resource,
31
+ status: resp.status,
32
+ statusText: resp.statusText,
33
+ body: document$1
34
+ });
35
+ return {
36
+ contextUrl: null,
37
+ document: document$1,
38
+ documentUrl: resource
39
+ };
40
+ }
41
+ const error = await resp.text();
42
+ logger.error("Failed to fetch fixture {resource}: {error}", {
43
+ resource,
44
+ error
45
+ });
46
+ throw new Error(error);
47
+ }
48
+ const path = `./fixtures/${url.host}${url.pathname}.json`;
49
+ let document;
31
50
  try {
32
- content = readFileSync(filePath, { encoding: "utf-8" });
51
+ document = (await import(path, { with: { type: "json" } })).default;
33
52
  } catch (error) {
34
- logger.error("Failed to read fixture file {filePath}: {error}", {
35
- filePath,
53
+ logger.error("Failed to read fixture file {path}: {error}", {
54
+ path,
36
55
  error
37
56
  });
38
57
  throw error;
39
58
  }
40
- return Promise.resolve({
59
+ return {
41
60
  contextUrl: null,
42
- document: JSON.parse(content),
61
+ document,
43
62
  documentUrl: resource
44
- });
63
+ };
45
64
  }
46
65
 
47
66
  //#endregion
@@ -8,4 +8,4 @@
8
8
  "@value": "Hong Gildong"
9
9
  }
10
10
  ]
11
- }
11
+ }
@@ -3,4 +3,4 @@
3
3
  "type": "Object",
4
4
  "id": "https://example.com/object",
5
5
  "name": "Fetched object"
6
- }
6
+ }
@@ -0,0 +1,29 @@
1
+
2
+ import { Temporal } from "@js-temporal/polyfill";
3
+ import { URLPattern } from "urlpattern-polyfill";
4
+
5
+ //#region testing/fixtures/example.com/person.json
6
+ var __context = ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"];
7
+ var id = "https://example.com/person";
8
+ var type = "Person";
9
+ var name = "John Doe";
10
+ var publicKey = [{
11
+ "id": "https://example.com/key",
12
+ "owner": "https://example.com/person",
13
+ "type": "CryptographicKey",
14
+ "publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyIB9rotX8G6r6/6toT+x\n24BUiQ/HaPH1Em9dOt4c94s+OPFoEdH7DY7Iym9A8LlH4JaGF8KD38bLHWe1S4x0\njV3gHJKhK7veJfGZCKUENcQecBZ+YWUs5HWvUIX1vVB//0luHrg6BQKGOrSOE+WI\nAxyr0qsWCFfZzQrvSnUD2yvg1arJX2xhms14uxoRd5Kg9efKSCmmQaNEapicARUm\nFWrIEpGFa/nUUnqimssAGw1eZFqf3wA4TjhsuARBhGaJtv/3KEa016eMZxy3kDlO\njZnXZTaTgWkXdodwUvy8563fes3Al6BlcS2iJ9qbtha8rSm0FHqoUKH73JsLPKQI\nwQIDAQAB\n-----END PUBLIC KEY-----"
15
+ }, {
16
+ "id": "https://example.com/key2",
17
+ "type": "CryptographicKey",
18
+ "publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAoRmBtnxbdFutoRd1GLGw\nwGTrsqlRRWUe11hHQaoRLGf5LwQ0tIc6I9q+dynliw+2kxYsLn9SH2je6HcTYOol\ngW7F/cOWXZQN04b+OiYcU1ConAhLjmn4k1uKawJ614y0ScPNd8PQ+CljsnlPxbq9\nofaCMe2BV3B6y09aCuGFJ0nxn1/ubjmIBIWWFTAznoz1J9BhJDGyt3IO3ABy3f9z\nDVlR32L/n5VIkXnxkjUKdzMAOzYb62kuKOp1iznRTPrV71SNtivJMwSh/LVgBrmZ\njtIn/oim+KyX/fdLU3tQ7VClyqmJzyAjccOH6Qj6nFTPh+vX07gqN8IlLT2uye4w\nawIDAQAB\n-----END PUBLIC KEY-----"
19
+ }];
20
+ var person_default = {
21
+ "@context": __context,
22
+ id,
23
+ type,
24
+ name,
25
+ publicKey
26
+ };
27
+
28
+ //#endregion
29
+ export { person_default };
@@ -0,0 +1,48 @@
1
+
2
+ import { Temporal } from "@js-temporal/polyfill";
3
+ import { URLPattern } from "urlpattern-polyfill";
4
+
5
+ //#region testing/fixtures/example.com/person2.json
6
+ var __context = [
7
+ "https://www.w3.org/ns/activitystreams",
8
+ "https://w3id.org/security/v1",
9
+ "https://w3id.org/security/multikey/v1",
10
+ "https://w3id.org/security/data-integrity/v1",
11
+ "https://www.w3.org/ns/did/v1"
12
+ ];
13
+ var id = "https://example.com/person2";
14
+ var type = "Person";
15
+ var name = "Jane Doe";
16
+ var publicKey = [{
17
+ "id": "https://example.com/person2#key3",
18
+ "type": "CryptographicKey",
19
+ "owner": "https://example.com/person2",
20
+ "publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA4GUqWgdiYlN3Su5Gr4l6\ni+xRS8gDDVKZ718vpGk6eIpvqs33q430nRbHIzbHRXRaAhc/1++rUBcK0V4/kjZl\nCSzVtRgGU6HMkmjcD+uE56a8XbTczfltbEDj7afoEuB2F3UhQEWrSz+QJ29DPXaL\nMIa1Yv61NR2vxGqNbdtoMjDORMBYtg77CYbcFkiJHw65PDa7+f/yjLxuCRPye5L7\nhncN0UZuuFoRJmHNRLSg5omBad9WTvQXmSyXEhEdk9fHwlI022AqAzlWbT79hldc\nDSKGGLLbQIs1c3JZIG8G5i6Uh5Vy0Z7tSNBcxbhqoI9i9je4f/x/OPIVc19f04BE\n1LgWuHsftZzRgW9Sdqz53W83XxVdxlyHeywXOnstSWT11f8dkLyQUcHKTH+E6urb\nH+aiPLiRpYK8W7D9KTQA9kZ5JXaEuveBd5vJX7wakhbzAn8pWJU7GYIHNY38Ycok\nmivkU5pY8S2cKFMwY0b7ade3MComlir5P3ZYSjF+n6gRVsT96P+9mNfCu9gXt/f8\nXCyjKlH89kGwuJ7HhR8CuVdm0l+jYozVt6GsDy0hHYyn79NCCAEzP7ZbhBMR0T5V\nrkl+TIGXoJH9WFiz4VxO+NnglF6dNQjDS5IzYLoFRXIK1f3cmQiEB4FZmL70l9HL\nrgwR+Xys83xia79OqFDRezMCAwEAAQ==\n-----END PUBLIC KEY-----\n"
21
+ }, {
22
+ "id": "https://example.com/person2#key4",
23
+ "type": "CryptographicKey",
24
+ "owner": "https://example.com/person2",
25
+ "publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEALR8epAGDe+cVq5p2Tx49CCfphpk1rNhkNoY9i+XEUfg=\n-----END PUBLIC KEY-----\n"
26
+ }];
27
+ var assertionMethod = [{
28
+ "id": "https://example.com/peson2#key3",
29
+ "type": "Multikey",
30
+ "controller": "https://example.com/person2",
31
+ "publicKeyMultibase": "zgghBUVkqmWS8e1j4aN2yowLAEkJC6wowB9wWmLRACYCok7UzstWcTBp3waKiDUM7wqL9bbBD9W9FvNaXEK2KPCZ9ffhvd5dxChJL9bdPQSrMwa28FEYMGDtcF1uocrYNmZm2dBBMaWrCu8U3s4PpVVhn4hsWDL8GLuE466pkJs9Hy8xmECoaaVgAZLiYDw2gwrjHDiX2i7aDHKfE7aSZWUWmC8nAGNZ7DX5pXoyXK3pxuaCWxNxXwPmaFwgKDyy9uhtBJ8znp9NZXkXHBTQe5uAi8GFwHY5asvqCmYPrAGWxcT6pdbZaJHdWkM7nw6apBHfakKs42oMqdBoJ2WkkresoT1qHrX2GW7gNP9PLtveF4vfEd6cwgHKQCdYgayG3muGfZiPvML75cyfkNrjkctvuQUfMxY9umbd2TG3V3mPnLrvQnqHpuRMZYtCn3nX1qfZaqFhTwT4NFPqVNLqvgR6k9vcuGXn6Ndaumhd5xtTK64jk3e2gPBit9iq6MrFUSoxNsbTty4kqcHAodtkK8CMSxUxbFP1kK3nyy8ZfeMgDCts1KboBcT2m5FMpQpYxKtNBfvhTuyeDDC34uhbY8itmTAnDwSr5mKrniwwDUGPZFejda51TYs1N9D9Ejzaw5Mvr8qN6wahHmsDBWTbWwV6YKVMD1MjAhJBUopWJWB5x6mEBAX25MssKfAEhJyDtqYWjq63uQHUJCsPJp"
32
+ }, {
33
+ "id": "https://example.com/person2#key4",
34
+ "type": "Multikey",
35
+ "controller": "https://example.com/person2",
36
+ "publicKeyMultibase": "z6MkhVPuyvgG1RkMv67azDqDCDERPXVrUg1i3qchXY5EACE3"
37
+ }];
38
+ var person2_default = {
39
+ "@context": __context,
40
+ id,
41
+ type,
42
+ name,
43
+ publicKey,
44
+ assertionMethod
45
+ };
46
+
47
+ //#endregion
48
+ export { person2_default };
@@ -2,4 +2,4 @@
2
2
  "https://example.com/prop/test": {
3
3
  "@value": "foo"
4
4
  }
5
- }
5
+ }
@@ -20,28 +20,28 @@
20
20
  "cipherAlgorithm": "sec:cipherAlgorithm",
21
21
  "cipherData": "sec:cipherData",
22
22
  "cipherKey": "sec:cipherKey",
23
- "created": {"@id": "dc:created", "@type": "xsd:dateTime"},
24
- "creator": {"@id": "dc:creator", "@type": "@id"},
23
+ "created": { "@id": "dc:created", "@type": "xsd:dateTime" },
24
+ "creator": { "@id": "dc:creator", "@type": "@id" },
25
25
  "digestAlgorithm": "sec:digestAlgorithm",
26
26
  "digestValue": "sec:digestValue",
27
27
  "domain": "sec:domain",
28
28
  "encryptionKey": "sec:encryptionKey",
29
- "expiration": {"@id": "sec:expiration", "@type": "xsd:dateTime"},
30
- "expires": {"@id": "sec:expiration", "@type": "xsd:dateTime"},
29
+ "expiration": { "@id": "sec:expiration", "@type": "xsd:dateTime" },
30
+ "expires": { "@id": "sec:expiration", "@type": "xsd:dateTime" },
31
31
  "initializationVector": "sec:initializationVector",
32
32
  "iterationCount": "sec:iterationCount",
33
33
  "nonce": "sec:nonce",
34
34
  "normalizationAlgorithm": "sec:normalizationAlgorithm",
35
- "owner": {"@id": "sec:owner", "@type": "@id"},
35
+ "owner": { "@id": "sec:owner", "@type": "@id" },
36
36
  "password": "sec:password",
37
- "privateKey": {"@id": "sec:privateKey", "@type": "@id"},
37
+ "privateKey": { "@id": "sec:privateKey", "@type": "@id" },
38
38
  "privateKeyPem": "sec:privateKeyPem",
39
- "publicKey": {"@id": "sec:publicKey", "@type": "@id"},
39
+ "publicKey": { "@id": "sec:publicKey", "@type": "@id" },
40
40
  "publicKeyBase58": "sec:publicKeyBase58",
41
41
  "publicKeyPem": "sec:publicKeyPem",
42
42
  "publicKeyWif": "sec:publicKeyWif",
43
- "publicKeyService": {"@id": "sec:publicKeyService", "@type": "@id"},
44
- "revoked": {"@id": "sec:revoked", "@type": "xsd:dateTime"},
43
+ "publicKeyService": { "@id": "sec:publicKeyService", "@type": "@id" },
44
+ "revoked": { "@id": "sec:revoked", "@type": "xsd:dateTime" },
45
45
  "salt": "sec:salt",
46
46
  "signature": "sec:signature",
47
47
  "signatureAlgorithm": "sec:signingAlgorithm",
@@ -0,0 +1,11 @@
1
+ import { Temporal } from "@js-temporal/polyfill";
2
+ import { URLPattern } from "urlpattern-polyfill";
3
+
4
+ //#region testing/mod.d.ts
5
+ declare const testDefinitions: Deno.TestDefinition[];
6
+ declare function test(options: Deno.TestDefinition): void;
7
+ declare function test(name: string, fn: (t: Deno.TestContext) => void | Promise<void>): void;
8
+ declare function test(name: string, options: Omit<Deno.TestDefinition, "fn" | "name">, fn: (t: Deno.TestContext) => void | Promise<void>): void;
9
+
10
+ //#endregion
11
+ export { test, testDefinitions };
@@ -2,11 +2,12 @@
2
2
  import { Temporal } from "@js-temporal/polyfill";
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
 
5
+ import { __require } from "../_virtual/rolldown_runtime.js";
5
6
  import { configure, getConsoleSink, reset } from "@logtape/logtape";
6
- import { test } from "node:test";
7
7
 
8
8
  //#region testing/mod.ts
9
- function test$1(name, options, fn) {
9
+ const testDefinitions = [];
10
+ function test(name, options, fn) {
10
11
  const def = typeof name === "string" ? typeof options === "function" ? {
11
12
  name,
12
13
  fn: options
@@ -15,37 +16,39 @@ function test$1(name, options, fn) {
15
16
  ...options,
16
17
  fn
17
18
  } : name;
18
- const func = def.fn;
19
- if ("Deno" in globalThis) Deno.test({
20
- ...def,
21
- async fn(t) {
22
- const records = [];
23
- await configure({
24
- sinks: {
25
- buffer(record) {
26
- if (record.category.length > 1 && record.category[0] === "logtape" && record.category[1] === "meta") return;
27
- records.push(record);
19
+ testDefinitions.push(def);
20
+ if ("Deno" in globalThis) {
21
+ const func = def.fn;
22
+ Deno.test({
23
+ ...def,
24
+ async fn(t) {
25
+ const records = [];
26
+ await configure({
27
+ sinks: {
28
+ buffer(record) {
29
+ if (record.category.length > 1 && record.category[0] === "logtape" && record.category[1] === "meta") return;
30
+ records.push(record);
31
+ },
32
+ console: getConsoleSink()
28
33
  },
29
- console: getConsoleSink()
30
- },
31
- filters: {},
32
- loggers: [{
33
- category: [],
34
- sinks: [Deno.env.get("LOG") === "always" ? "console" : "buffer"]
35
- }]
36
- });
37
- try {
38
- await func(t);
39
- } catch (e) {
40
- const consoleSink = getConsoleSink();
41
- for (const record of records) consoleSink(record);
42
- throw e;
43
- } finally {
44
- await reset();
34
+ filters: {},
35
+ loggers: [{
36
+ category: [],
37
+ sinks: [Deno.env.get("LOG") === "always" ? "console" : "buffer"]
38
+ }]
39
+ });
40
+ try {
41
+ await func(t);
42
+ } catch (e) {
43
+ const consoleSink = getConsoleSink();
44
+ for (const record of records) consoleSink(record);
45
+ throw e;
46
+ } finally {
47
+ await reset();
48
+ }
45
49
  }
46
- }
47
- });
48
- else if ("Bun" in globalThis) {
50
+ });
51
+ } else if ("Bun" in globalThis) {
49
52
  let failed = void 0;
50
53
  async function step(defOrNameOrFn, fn$2) {
51
54
  let def$1;
@@ -84,12 +87,15 @@ function test$1(name, options, fn) {
84
87
  if (def.ignore) bunTest.skip(def.name, fn$1);
85
88
  else if (def.only) bunTest.only(def.name, fn$1);
86
89
  else bunTest(def.name, fn$1);
87
- } else test(def.name, {
88
- only: def.only,
89
- skip: def.ignore
90
- }, async (t) => {
91
- await def.fn(intoDenoTestContext(def.name, t));
92
- });
90
+ } else try {
91
+ const { test: nodeTest } = __require("node:test");
92
+ nodeTest(def.name, {
93
+ only: def.only,
94
+ skip: def.ignore
95
+ }, async (t) => {
96
+ await def.fn(intoDenoTestContext(def.name, t));
97
+ });
98
+ } catch {}
93
99
  }
94
100
  function intoDenoTestContext(name, ctx) {
95
101
  async function step(defOrNameOrFn, fn) {
@@ -133,4 +139,4 @@ function caller() {
133
139
  }
134
140
 
135
141
  //#endregion
136
- export { test$1 as test };
142
+ export { test, testDefinitions };
@@ -8,33 +8,30 @@ import { assertEquals } from "../node_modules/.pnpm/@jsr_std__assert@0.226.0/nod
8
8
  import { assertInstanceOf } from "../node_modules/.pnpm/@jsr_std__assert@0.226.0/node_modules/@jsr/std__assert/assert_instance_of.js";
9
9
  import { test } from "../testing/mod.js";
10
10
  import { mockDocumentLoader } from "../testing/docloader.js";
11
- import { install, mock, uninstall } from "../node_modules/.pnpm/@jsr_hongminhee__deno-mock-fetch@0.3.2/node_modules/@jsr/hongminhee__deno-mock-fetch/mod.js";
11
+ import { esm_default } from "../node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/index.js";
12
12
 
13
13
  //#region vocab/lookup.test.ts
14
14
  test("lookupObject()", async (t) => {
15
- install();
16
- mock("GET@/.well-known/webfinger", (req) => {
17
- assertEquals(new URL(req.url).host, "example.com");
18
- return new Response(JSON.stringify({
19
- subject: "acct:johndoe@example.com",
20
- links: [
21
- {
22
- rel: "alternate",
23
- href: "https://example.com/object",
24
- type: "application/activity+json"
25
- },
26
- {
27
- rel: "self",
28
- href: "https://example.com/html/person",
29
- type: "text/html"
30
- },
31
- {
32
- rel: "self",
33
- href: "https://example.com/person",
34
- type: "application/activity+json"
35
- }
36
- ]
37
- }));
15
+ esm_default.spyGlobal();
16
+ esm_default.get("begin:https://example.com/.well-known/webfinger", {
17
+ subject: "acct:johndoe@example.com",
18
+ links: [
19
+ {
20
+ rel: "alternate",
21
+ href: "https://example.com/object",
22
+ type: "application/activity+json"
23
+ },
24
+ {
25
+ rel: "self",
26
+ href: "https://example.com/html/person",
27
+ type: "text/html"
28
+ },
29
+ {
30
+ rel: "self",
31
+ href: "https://example.com/person",
32
+ type: "application/activity+json"
33
+ }
34
+ ]
38
35
  });
39
36
  const options = {
40
37
  documentLoader: mockDocumentLoader,
@@ -64,22 +61,20 @@ test("lookupObject()", async (t) => {
64
61
  name: "Hong Gildong"
65
62
  }));
66
63
  });
67
- mock("GET@/.well-known/webfinger", (req) => {
68
- assertEquals(new URL(req.url).host, "example.com");
69
- return new Response(JSON.stringify({
70
- subject: "acct:janedoe@example.com",
71
- links: [{
72
- rel: "self",
73
- href: "https://example.com/404",
74
- type: "application/activity+json"
75
- }]
76
- }));
64
+ esm_default.removeRoutes();
65
+ esm_default.get("begin:https://example.com/.well-known/webfinger", {
66
+ subject: "acct:janedoe@example.com",
67
+ links: [{
68
+ rel: "self",
69
+ href: "https://example.com/404",
70
+ type: "application/activity+json"
71
+ }]
77
72
  });
78
73
  await t.step("not found", async () => {
79
74
  assertEquals(await lookupObject("janedoe@example.com", options), null);
80
75
  assertEquals(await lookupObject("https://example.com/404", options), null);
81
76
  });
82
- uninstall();
77
+ esm_default.hardReset();
83
78
  });
84
79
  test("traverseCollection()", async () => {
85
80
  const options = {