@fedify/cli 2.5.0-dev.2440 → 2.5.0-dev.2448
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/deno.js +1 -1
- package/dist/webfinger/action.js +14 -3
- package/dist/webfinger/error.js +23 -2
- package/package.json +9 -9
package/dist/deno.js
CHANGED
package/dist/webfinger/action.js
CHANGED
|
@@ -2,7 +2,7 @@ import "temporal-polyfill";
|
|
|
2
2
|
import { createPortableObjectVerifier, getIriKey, getPortableLookupProblem, isPortableReference } from "../portable.js";
|
|
3
3
|
import { formatObject } from "../utils.js";
|
|
4
4
|
import { getContextLoader, getDocumentLoader as getDocumentLoader$1 } from "../docloader.js";
|
|
5
|
-
import { NotFoundError, PortableActorError, UnlinkedPortableActorError, getErrorMessage } from "./error.js";
|
|
5
|
+
import { NotFoundError, PortableActorError, UnlinkedPortableActorError, WebFingerLookupError, getErrorMessage } from "./error.js";
|
|
6
6
|
import { convertUrlIfHandle } from "./lib.js";
|
|
7
7
|
import { print } from "@optique/run";
|
|
8
8
|
import { formatIri } from "@fedify/vocab-runtime";
|
|
@@ -28,7 +28,11 @@ function getLookupWebFingerOptions(options) {
|
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
30
|
async function lookupSingleWebFinger(options) {
|
|
31
|
-
|
|
31
|
+
const outcome = await lookupWebFinger(convertUrlIfHandle(options.resource), {
|
|
32
|
+
...getLookupWebFingerOptions(options),
|
|
33
|
+
withDiagnostics: true
|
|
34
|
+
});
|
|
35
|
+
return outcome.resource ?? (outcome.result === "not_found" ? new NotFoundError(options.resource).throw() : new WebFingerLookupError(options.resource, outcome.result).throw());
|
|
32
36
|
}
|
|
33
37
|
/**
|
|
34
38
|
* Looks up the WebFinger address of an [FEP-ef61] portable actor by its ID,
|
|
@@ -46,6 +50,9 @@ async function lookupSingleWebFinger(options) {
|
|
|
46
50
|
* @throws {PortableActorError} If the actor cannot be looked up, or does
|
|
47
51
|
* not have a WebFinger address.
|
|
48
52
|
* @throws {NotFoundError} If the WebFinger address is not found.
|
|
53
|
+
* @throws {WebFingerLookupError} If the WebFinger lookup failed for another
|
|
54
|
+
* reason, such as a network failure or a
|
|
55
|
+
* malformed response.
|
|
49
56
|
*/
|
|
50
57
|
async function lookupPortableWebFinger(options) {
|
|
51
58
|
const { resource, gateways } = options;
|
|
@@ -73,8 +80,12 @@ async function lookupPortableWebFinger(options) {
|
|
|
73
80
|
const username = actor.preferredUsername?.toString();
|
|
74
81
|
if (gateway == null || username == null) throw new PortableActorError(resource, "it has no preferredUsername or gateways");
|
|
75
82
|
const address = `acct:${username}@${gateway.host}`;
|
|
83
|
+
const outcome = await lookupWebFinger(address, {
|
|
84
|
+
...getLookupWebFingerOptions(options),
|
|
85
|
+
withDiagnostics: true
|
|
86
|
+
});
|
|
76
87
|
return {
|
|
77
|
-
descriptor:
|
|
88
|
+
descriptor: outcome.resource ?? (outcome.result === "not_found" ? new NotFoundError(address).throw() : new WebFingerLookupError(address, outcome.result).throw()),
|
|
78
89
|
address,
|
|
79
90
|
actorId: actor.id
|
|
80
91
|
};
|
package/dist/webfinger/error.js
CHANGED
|
@@ -8,7 +8,7 @@ import { message } from "@optique/core";
|
|
|
8
8
|
* @param {unknown} error The error encountered.
|
|
9
9
|
* @returns {string} A descriptive error message.
|
|
10
10
|
*/
|
|
11
|
-
const getErrorMessage = (resource, error) => error instanceof InvalidHandleError ? message`Invalid handle format: ${error.handle}` : error instanceof PortableActorError ? message`Failed to look up the portable actor ${error.resource}, as ${error.reason}.` : error instanceof UnlinkedPortableActorError ? message`${error.address} does not link back to the portable actor ${error.actorId}, so it is not verified to be the actor's WebFinger address:` : error instanceof NotFoundError ? message`Resource not found: ${error.resource}` : error instanceof Error ? message`Failed to look up WebFinger for ${resource}: ${error.message}` : message`Failed to look up WebFinger for ${resource}: ${String(error)}`;
|
|
11
|
+
const getErrorMessage = (resource, error) => error instanceof InvalidHandleError ? message`Invalid handle format: ${error.handle}` : error instanceof PortableActorError ? message`Failed to look up the portable actor ${error.resource}, as ${error.reason}.` : error instanceof UnlinkedPortableActorError ? message`${error.address} does not link back to the portable actor ${error.actorId}, so it is not verified to be the actor's WebFinger address:` : error instanceof NotFoundError ? message`Resource not found: ${error.resource}` : error instanceof WebFingerLookupError ? error.result === "network_error" ? message`Failed to look up WebFinger for ${error.resource}: a network error occurred.` : error.result === "invalid" ? message`Failed to look up WebFinger for ${error.resource}: the server returned a response Fedify could not understand.` : message`Failed to look up WebFinger for ${error.resource}: the server returned an unexpected error.` : error instanceof Error ? message`Failed to look up WebFinger for ${resource}: ${error.message}` : message`Failed to look up WebFinger for ${resource}: ${String(error)}`;
|
|
12
12
|
/**
|
|
13
13
|
* Custom error class for invalid handle formats.
|
|
14
14
|
* @param {string} handle The invalid handle that caused the error.
|
|
@@ -42,6 +42,27 @@ var NotFoundError = class extends Error {
|
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
44
|
/**
|
|
45
|
+
* Custom error class for a WebFinger lookup that failed for a reason other
|
|
46
|
+
* than the resource simply not existing, such as a network failure, a
|
|
47
|
+
* server error, or a response Fedify could not parse.
|
|
48
|
+
* @param resource The resource that could not be looked up.
|
|
49
|
+
* @param result Why the lookup failed.
|
|
50
|
+
* @extends {Error}
|
|
51
|
+
*/
|
|
52
|
+
var WebFingerLookupError = class extends Error {
|
|
53
|
+
resource;
|
|
54
|
+
result;
|
|
55
|
+
constructor(resource, result) {
|
|
56
|
+
super(`Failed to look up WebFinger for ${resource}: result was "${result}".`);
|
|
57
|
+
this.resource = resource;
|
|
58
|
+
this.result = result;
|
|
59
|
+
this.name = "WebFingerLookupError";
|
|
60
|
+
}
|
|
61
|
+
throw() {
|
|
62
|
+
throw this;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
45
66
|
* Custom error class for [FEP-ef61] portable actors whose WebFinger address
|
|
46
67
|
* cannot be determined.
|
|
47
68
|
*
|
|
@@ -80,4 +101,4 @@ var UnlinkedPortableActorError = class extends Error {
|
|
|
80
101
|
}
|
|
81
102
|
};
|
|
82
103
|
//#endregion
|
|
83
|
-
export { InvalidHandleError, NotFoundError, PortableActorError, UnlinkedPortableActorError, getErrorMessage };
|
|
104
|
+
export { InvalidHandleError, NotFoundError, PortableActorError, UnlinkedPortableActorError, WebFingerLookupError, getErrorMessage };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fedify/cli",
|
|
3
|
-
"version": "2.5.0-dev.
|
|
3
|
+
"version": "2.5.0-dev.2448+756933d0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"README.md",
|
|
@@ -88,14 +88,14 @@
|
|
|
88
88
|
"temporal-polyfill": "^1.0.1",
|
|
89
89
|
"valibot": "^1.4.0",
|
|
90
90
|
"yaml": "^2.9.0",
|
|
91
|
-
"@fedify/fedify": "2.5.0-dev.
|
|
92
|
-
"@fedify/relay": "2.5.0-dev.
|
|
93
|
-
"@fedify/
|
|
94
|
-
"@fedify/vocab": "2.5.0-dev.
|
|
95
|
-
"@fedify/
|
|
96
|
-
"@fedify/vocab-
|
|
97
|
-
"@fedify/
|
|
98
|
-
"@fedify/
|
|
91
|
+
"@fedify/fedify": "2.5.0-dev.2448+756933d0",
|
|
92
|
+
"@fedify/relay": "2.5.0-dev.2448+756933d0",
|
|
93
|
+
"@fedify/sqlite": "2.5.0-dev.2448+756933d0",
|
|
94
|
+
"@fedify/vocab": "2.5.0-dev.2448+756933d0",
|
|
95
|
+
"@fedify/init": "2.5.0-dev.2448+756933d0",
|
|
96
|
+
"@fedify/vocab-runtime": "2.5.0-dev.2448+756933d0",
|
|
97
|
+
"@fedify/webfinger": "2.5.0-dev.2448+756933d0",
|
|
98
|
+
"@fedify/vocab-tools": "2.5.0-dev.2448+756933d0"
|
|
99
99
|
},
|
|
100
100
|
"devDependencies": {
|
|
101
101
|
"@types/bun": "^1.2.23",
|