@fedify/cli 2.0.0-dev.1908 → 2.0.0-dev.1961

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/cli",
3
- "version": "2.0.0-dev.1908+c31cc639",
3
+ "version": "2.0.0-dev.1961+c3dff60a",
4
4
  "license": "MIT",
5
5
  "exports": "./src/mod.ts",
6
6
  "imports": {
package/dist/deno.js CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  //#region deno.json
5
5
  var name = "@fedify/cli";
6
- var version = "2.0.0-dev.1908+c31cc639";
6
+ var version = "2.0.0-dev.1961+c3dff60a";
7
7
  var license = "MIT";
8
8
  var exports = "./src/mod.ts";
9
9
  var imports = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/cli",
3
- "version": "2.0.0-dev.1908+c31cc639",
3
+ "version": "2.0.0-dev.1961+c3dff60a",
4
4
  "description": "CLI toolchain for Fedify and debugging ActivityPub",
5
5
  "keywords": [
6
6
  "fedify",
@@ -71,10 +71,10 @@
71
71
  "ora": "^8.2.0",
72
72
  "shiki": "^1.6.4",
73
73
  "srvx": "^0.8.7",
74
- "@fedify/fedify": "2.0.0-dev.1908+c31cc639",
75
- "@fedify/vocab-runtime": "2.0.0-dev.1908+c31cc639",
76
- "@fedify/vocab-tools": "2.0.0-dev.1908+c31cc639",
77
- "@fedify/sqlite": "2.0.0-dev.1908+c31cc639"
74
+ "@fedify/fedify": "2.0.0-dev.1961+c3dff60a",
75
+ "@fedify/sqlite": "2.0.0-dev.1961+c3dff60a",
76
+ "@fedify/vocab-runtime": "2.0.0-dev.1961+c3dff60a",
77
+ "@fedify/vocab-tools": "2.0.0-dev.1961+c3dff60a"
78
78
  },
79
79
  "devDependencies": {
80
80
  "@types/bun": "^1.2.23",
@@ -16,23 +16,19 @@ const ALIASES = [
16
16
  ];
17
17
 
18
18
  test("Test webFingerCommand", () => {
19
- // Resources only
20
19
  const argsWithResourcesOnly = [COMMAND, ...RESOURCES];
21
- assert.deepEqual(
22
- parse(webFingerCommand, argsWithResourcesOnly),
23
- {
24
- success: true,
25
- value: {
26
- debug: false,
27
- command: COMMAND,
28
- resources: RESOURCES,
29
- allowPrivateAddresses: undefined,
30
- maxRedirection: 5,
31
- userAgent: undefined,
32
- },
20
+ assert.deepEqual(parse(webFingerCommand, argsWithResourcesOnly), {
21
+ success: true,
22
+ value: {
23
+ debug: false,
24
+ command: COMMAND,
25
+ resources: RESOURCES,
26
+ allowPrivateAddresses: undefined,
27
+ maxRedirection: 5,
28
+ userAgent: undefined,
33
29
  },
34
- );
35
- // With options
30
+ });
31
+
36
32
  const maxRedirection = 10;
37
33
  assert.deepEqual(
38
34
  parse(webFingerCommand, [
@@ -56,13 +52,13 @@ test("Test webFingerCommand", () => {
56
52
  },
57
53
  },
58
54
  );
59
- // Wrong option
55
+
60
56
  const wrongOptionResult = parse(webFingerCommand, [
61
57
  ...argsWithResourcesOnly,
62
58
  "-Q",
63
59
  ]);
64
60
  assert.ok(!wrongOptionResult.success);
65
- // Wrong option value
61
+
66
62
  const wrongOptionValueResult = parse(
67
63
  webFingerCommand,
68
64
  [...argsWithResourcesOnly, "--max-redirection", "-10"],
@@ -70,10 +66,71 @@ test("Test webFingerCommand", () => {
70
66
  assert.ok(!wrongOptionValueResult.success);
71
67
  });
72
68
 
73
- test("Test lookupSingleWebFinger", async () => {
74
- const aliases = (await Array.fromAsync(
75
- RESOURCES,
76
- (resource) => lookupSingleWebFinger({ resource }),
77
- )).map((w) => w?.aliases?.[0]);
78
- assert.deepEqual(aliases, ALIASES);
69
+ // ----------------------------------------------------------------------
70
+ // FIX FOR ISSUE #480 – MOCK FETCH TO REMOVE EXTERNAL DEPENDENCY
71
+ // ----------------------------------------------------------------------
72
+
73
+ test("Test lookupSingleWebFinger", async (): Promise<void> => {
74
+ const originalFetch = globalThis.fetch;
75
+
76
+ const mockResponses: Record<string, unknown> = {
77
+ "https://hackers.pub/.well-known/webfinger?resource=acct%3Ahongminhee%40hackers.pub":
78
+ {
79
+ subject: "acct:hongminhee@hackers.pub",
80
+ aliases: [ALIASES[0]],
81
+ links: [
82
+ {
83
+ rel: "self",
84
+ type: "application/activity+json",
85
+ href: ALIASES[0],
86
+ },
87
+ ],
88
+ },
89
+
90
+ "https://hollo.social/.well-known/webfinger?resource=acct%3Afedify%40hollo.social":
91
+ {
92
+ subject: "acct:fedify@hollo.social",
93
+ aliases: [ALIASES[1]],
94
+ links: [
95
+ {
96
+ rel: "self",
97
+ type: "application/activity+json",
98
+ href: ALIASES[1],
99
+ },
100
+ ],
101
+ },
102
+ };
103
+
104
+ // Correct async fetch mock returning Promise<Response>
105
+ globalThis.fetch = async (
106
+ input: RequestInfo | URL,
107
+ ): Promise<Response> => {
108
+ await Promise.resolve();
109
+
110
+ const url = String(input);
111
+ const responseData = mockResponses[url];
112
+
113
+ if (responseData) {
114
+ return new Response(JSON.stringify(responseData), {
115
+ status: 200,
116
+ headers: {
117
+ "Content-Type": "application/jrd+json",
118
+ },
119
+ });
120
+ }
121
+
122
+ throw new Error(`Unexpected URL: ${url}`);
123
+ };
124
+
125
+ try {
126
+ const results = await Array.fromAsync(
127
+ RESOURCES,
128
+ (resource) => lookupSingleWebFinger({ resource }),
129
+ );
130
+
131
+ const aliases = results.map((w) => w?.aliases?.[0]);
132
+ assert.deepEqual(aliases, ALIASES);
133
+ } finally {
134
+ globalThis.fetch = originalFetch;
135
+ }
79
136
  });