@fedify/cli 2.1.0 → 2.1.2
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/cache.js +7 -16
- package/dist/config.js +5 -13
- package/dist/deno.js +3 -79
- package/dist/docloader.js +3 -8
- package/dist/generate-vocab/action.js +4 -8
- package/dist/generate-vocab/command.js +2 -7
- package/dist/generate-vocab/mod.js +4 -5
- package/dist/imagerenderer.js +10 -20
- package/dist/inbox/rendercode.js +3 -8
- package/dist/inbox/view.js +7 -13
- package/dist/inbox.js +25 -29
- package/dist/init/mod.js +2 -5
- package/dist/kv.bun.js +4 -10
- package/dist/kv.node.js +4 -10
- package/dist/log.js +5 -9
- package/dist/lookup.js +95 -107
- package/dist/mod.js +16 -30
- package/dist/nodeinfo.js +35 -45
- package/dist/options.js +9 -26
- package/dist/relay.js +20 -25
- package/dist/table.js +2 -5
- package/dist/tempserver.js +13 -20
- package/dist/tunnel.js +9 -13
- package/dist/utils.js +7 -13
- package/dist/webfinger/action.js +5 -11
- package/dist/webfinger/command.js +2 -6
- package/dist/webfinger/error.js +2 -6
- package/dist/webfinger/lib.js +3 -8
- package/dist/webfinger/mod.js +4 -5
- package/package.json +11 -11
package/dist/cache.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
-
|
|
4
|
-
import { join } from "node:path";
|
|
5
|
-
import { mkdir } from "node:fs/promises";
|
|
1
|
+
import "@js-temporal/polyfill";
|
|
6
2
|
import { homedir } from "node:os";
|
|
3
|
+
import { join } from "node:path";
|
|
7
4
|
import process from "node:process";
|
|
8
|
-
|
|
5
|
+
import { mkdir } from "node:fs/promises";
|
|
9
6
|
//#region src/cache.ts
|
|
10
7
|
/**
|
|
11
8
|
* Returns the default cache directory path.
|
|
@@ -13,19 +10,13 @@ import process from "node:process";
|
|
|
13
10
|
* - Windows: `%LOCALAPPDATA%\fedify`
|
|
14
11
|
*/
|
|
15
12
|
function getDefaultCacheDir() {
|
|
16
|
-
if (process.platform === "win32")
|
|
17
|
-
|
|
18
|
-
return join(localAppData, "fedify");
|
|
19
|
-
}
|
|
20
|
-
const xdgCacheHome = process.env.XDG_CACHE_HOME || join(homedir(), ".cache");
|
|
21
|
-
return join(xdgCacheHome, "fedify");
|
|
13
|
+
if (process.platform === "win32") return join(process.env.LOCALAPPDATA || join(homedir(), "AppData", "Local"), "fedify");
|
|
14
|
+
return join(process.env.XDG_CACHE_HOME || join(homedir(), ".cache"), "fedify");
|
|
22
15
|
}
|
|
23
|
-
|
|
24
|
-
let currentCacheDir = DEFAULT_CACHE_DIR;
|
|
16
|
+
let currentCacheDir = getDefaultCacheDir();
|
|
25
17
|
async function getCacheDir() {
|
|
26
18
|
await mkdir(currentCacheDir, { recursive: true });
|
|
27
19
|
return currentCacheDir;
|
|
28
20
|
}
|
|
29
|
-
|
|
30
21
|
//#endregion
|
|
31
|
-
export { getCacheDir };
|
|
22
|
+
export { getCacheDir };
|
package/dist/config.js
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
-
|
|
1
|
+
import "@js-temporal/polyfill";
|
|
4
2
|
import { message } from "@optique/core";
|
|
5
3
|
import { printError } from "@optique/run";
|
|
6
4
|
import { readFileSync } from "node:fs";
|
|
7
5
|
import { parse } from "smol-toml";
|
|
8
6
|
import { createConfigContext } from "@optique/config";
|
|
9
7
|
import { array, boolean, check, forward, integer as integer$1, minValue, number, object as object$1, optional as optional$1, picklist, pipe, string as string$1 } from "valibot";
|
|
10
|
-
|
|
11
8
|
//#region src/config.ts
|
|
12
9
|
/**
|
|
13
10
|
* Schema for the webfinger command configuration.
|
|
@@ -77,9 +74,9 @@ const nodeinfoSchema = object$1({
|
|
|
77
74
|
showMetadata: optional$1(boolean())
|
|
78
75
|
});
|
|
79
76
|
/**
|
|
80
|
-
*
|
|
77
|
+
* Config context for use with bindConfig().
|
|
81
78
|
*/
|
|
82
|
-
const
|
|
79
|
+
const configContext = createConfigContext({ schema: object$1({
|
|
83
80
|
debug: optional$1(boolean()),
|
|
84
81
|
userAgent: optional$1(string$1()),
|
|
85
82
|
tunnelService: optional$1(picklist([
|
|
@@ -92,11 +89,7 @@ const configSchema = object$1({
|
|
|
92
89
|
inbox: optional$1(inboxSchema),
|
|
93
90
|
relay: optional$1(relaySchema),
|
|
94
91
|
nodeinfo: optional$1(nodeinfoSchema)
|
|
95
|
-
});
|
|
96
|
-
/**
|
|
97
|
-
* Config context for use with bindConfig().
|
|
98
|
-
*/
|
|
99
|
-
const configContext = createConfigContext({ schema: configSchema });
|
|
92
|
+
}) });
|
|
100
93
|
/**
|
|
101
94
|
* Try to load and parse a TOML config file.
|
|
102
95
|
* Returns an empty object if the file doesn't exist.
|
|
@@ -111,6 +104,5 @@ function tryLoadToml(filePath) {
|
|
|
111
104
|
return {};
|
|
112
105
|
}
|
|
113
106
|
}
|
|
114
|
-
|
|
115
107
|
//#endregion
|
|
116
|
-
export { configContext, tryLoadToml };
|
|
108
|
+
export { configContext, tryLoadToml };
|
package/dist/deno.js
CHANGED
|
@@ -1,81 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
-
|
|
1
|
+
import "@js-temporal/polyfill";
|
|
4
2
|
//#region deno.json
|
|
5
|
-
var
|
|
6
|
-
var version = "2.1.0";
|
|
7
|
-
var license = "MIT";
|
|
8
|
-
var exports = "./src/mod.ts";
|
|
9
|
-
var imports = {
|
|
10
|
-
"@hongminhee/localtunnel": "jsr:@hongminhee/localtunnel@^0.3.0",
|
|
11
|
-
"@inquirer/prompts": "npm:@inquirer/prompts@^7.8.4",
|
|
12
|
-
"@jimp/core": "npm:@jimp/core@^1.6.0",
|
|
13
|
-
"@jimp/wasm-webp": "npm:@jimp/wasm-webp@^1.6.0",
|
|
14
|
-
"@poppanator/http-constants": "npm:@poppanator/http-constants@^1.1.1",
|
|
15
|
-
"chalk": "npm:chalk@^5.6.2",
|
|
16
|
-
"cli-table3": "npm:cli-table3@^0.6.5",
|
|
17
|
-
"fetch-mock": "npm:fetch-mock@^12.5.4",
|
|
18
|
-
"hono": "jsr:@hono/hono@^4.8.3",
|
|
19
|
-
"icojs": "npm:icojs@^0.19.5",
|
|
20
|
-
"inquirer-toggle": "npm:inquirer-toggle@^1.0.1",
|
|
21
|
-
"ora": "npm:ora@^8.2.0",
|
|
22
|
-
"shiki": "npm:shiki@^1.6.4",
|
|
23
|
-
"smol-toml": "npm:smol-toml@^1.6.0",
|
|
24
|
-
"srvx": "npm:srvx@^0.8.7",
|
|
25
|
-
"valibot": "jsr:@valibot/valibot@^1.2.0",
|
|
26
|
-
"#kv": "./src/kv.node.ts"
|
|
27
|
-
};
|
|
28
|
-
var exclude = [
|
|
29
|
-
"dist/",
|
|
30
|
-
"fedify-cli-*.tar.xz",
|
|
31
|
-
"fedify-cli-*.tgz",
|
|
32
|
-
"fedify-cli-*.zip"
|
|
33
|
-
];
|
|
34
|
-
var publish = { "exclude": [
|
|
35
|
-
"**/*.test.ts",
|
|
36
|
-
"tsdown.config.ts",
|
|
37
|
-
"scripts/"
|
|
38
|
-
] };
|
|
39
|
-
var tasks = {
|
|
40
|
-
"codegen": "deno task -f @fedify/vocab compile",
|
|
41
|
-
"check": {
|
|
42
|
-
"command": "deno fmt --check && deno lint && deno check src/**/*.ts",
|
|
43
|
-
"dependencies": ["codegen"]
|
|
44
|
-
},
|
|
45
|
-
"run": {
|
|
46
|
-
"command": "deno run --allow-all src/mod.ts",
|
|
47
|
-
"dependencies": ["codegen"]
|
|
48
|
-
},
|
|
49
|
-
"runi": "deno run --allow-all src/mod.ts",
|
|
50
|
-
"pack": {
|
|
51
|
-
"command": "deno run -A scripts/pack.ts",
|
|
52
|
-
"dependencies": ["codegen"]
|
|
53
|
-
},
|
|
54
|
-
"test": {
|
|
55
|
-
"command": "deno test --allow-all",
|
|
56
|
-
"dependencies": ["codegen"]
|
|
57
|
-
},
|
|
58
|
-
"test-init": {
|
|
59
|
-
"command": "FEDIFY_TEST_MODE=true deno run --allow-all src/init/test/mod.ts test-init",
|
|
60
|
-
"dependencies": ["codegen"]
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
var fmt = { "exclude": ["src/init/templates/**"] };
|
|
64
|
-
var lint = { "exclude": ["src/init/templates/**"] };
|
|
65
|
-
var test = { "exclude": ["src/init/test/**"] };
|
|
66
|
-
var deno_default = {
|
|
67
|
-
name,
|
|
68
|
-
version,
|
|
69
|
-
license,
|
|
70
|
-
exports,
|
|
71
|
-
imports,
|
|
72
|
-
exclude,
|
|
73
|
-
publish,
|
|
74
|
-
tasks,
|
|
75
|
-
fmt,
|
|
76
|
-
lint,
|
|
77
|
-
test
|
|
78
|
-
};
|
|
79
|
-
|
|
3
|
+
var version = "2.1.2";
|
|
80
4
|
//#endregion
|
|
81
|
-
export {
|
|
5
|
+
export { version };
|
package/dist/docloader.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
-
|
|
1
|
+
import "@js-temporal/polyfill";
|
|
4
2
|
import { kvCache } from "@fedify/fedify";
|
|
5
3
|
import { getDocumentLoader } from "@fedify/vocab-runtime";
|
|
6
4
|
import { getKvStore } from "#kv";
|
|
7
|
-
|
|
8
5
|
//#region src/docloader.ts
|
|
9
6
|
const documentLoaders = {};
|
|
10
7
|
/**
|
|
@@ -23,9 +20,8 @@ function getDocumentLoaderCachePrefix(userAgent, allowPrivateAddress) {
|
|
|
23
20
|
async function getDocumentLoader$1({ userAgent, allowPrivateAddress = false } = {}) {
|
|
24
21
|
const cacheKey = `${userAgent ?? ""}:${allowPrivateAddress}`;
|
|
25
22
|
if (documentLoaders[cacheKey]) return documentLoaders[cacheKey];
|
|
26
|
-
const kv = await getKvStore();
|
|
27
23
|
return documentLoaders[cacheKey] = kvCache({
|
|
28
|
-
kv,
|
|
24
|
+
kv: await getKvStore(),
|
|
29
25
|
prefix: getDocumentLoaderCachePrefix(userAgent, allowPrivateAddress),
|
|
30
26
|
rules: [
|
|
31
27
|
[new URLPattern({
|
|
@@ -62,6 +58,5 @@ async function getDocumentLoader$1({ userAgent, allowPrivateAddress = false } =
|
|
|
62
58
|
function getContextLoader(options = {}) {
|
|
63
59
|
return getDocumentLoader$1(options);
|
|
64
60
|
}
|
|
65
|
-
|
|
66
61
|
//#endregion
|
|
67
|
-
export { getContextLoader, getDocumentLoader$1 as getDocumentLoader };
|
|
62
|
+
export { getContextLoader, getDocumentLoader$1 as getDocumentLoader };
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
-
|
|
4
|
-
import { stat } from "node:fs/promises";
|
|
5
|
-
import process from "node:process";
|
|
1
|
+
import "@js-temporal/polyfill";
|
|
6
2
|
import { printError } from "@optique/run";
|
|
3
|
+
import process from "node:process";
|
|
7
4
|
import { generateVocab } from "@fedify/vocab-tools";
|
|
8
5
|
import { message } from "@optique/core/message";
|
|
9
|
-
|
|
6
|
+
import { stat } from "node:fs/promises";
|
|
10
7
|
//#region src/generate-vocab/action.ts
|
|
11
8
|
async function runGenerateVocab({ schemaDir, generatedPath }) {
|
|
12
9
|
if (!(await stat(schemaDir)).isDirectory()) {
|
|
@@ -15,6 +12,5 @@ async function runGenerateVocab({ schemaDir, generatedPath }) {
|
|
|
15
12
|
}
|
|
16
13
|
await generateVocab(schemaDir, generatedPath);
|
|
17
14
|
}
|
|
18
|
-
|
|
19
15
|
//#endregion
|
|
20
|
-
export { runGenerateVocab };
|
|
16
|
+
export { runGenerateVocab as default };
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
-
|
|
1
|
+
import "@js-temporal/polyfill";
|
|
4
2
|
import { argument, command, constant, message, object, option, withDefault } from "@optique/core";
|
|
5
3
|
import { path } from "@optique/run";
|
|
6
|
-
|
|
7
4
|
//#region src/generate-vocab/command.ts
|
|
8
5
|
const schemaDir = withDefault(option("-i", "--input", path({
|
|
9
6
|
metavar: "DIR",
|
|
@@ -20,7 +17,5 @@ const generateVocabCommand = command("generate-vocab", object("Generation option
|
|
|
20
17
|
schemaDir,
|
|
21
18
|
generatedPath
|
|
22
19
|
}), { description: message`Generate vocabulary classes from schema files.` });
|
|
23
|
-
var command_default = generateVocabCommand;
|
|
24
|
-
|
|
25
20
|
//#endregion
|
|
26
|
-
export {
|
|
21
|
+
export { generateVocabCommand as default };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import command_default from "./command.js";
|
|
1
|
+
import "@js-temporal/polyfill";
|
|
2
|
+
import "./action.js";
|
|
3
|
+
import "./command.js";
|
|
4
|
+
export {};
|
package/dist/imagerenderer.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
-
|
|
1
|
+
import "@js-temporal/polyfill";
|
|
4
2
|
import { Jimp } from "./nodeinfo.js";
|
|
5
|
-
import path from "node:path";
|
|
6
|
-
import fs from "node:fs/promises";
|
|
7
3
|
import os from "node:os";
|
|
4
|
+
import path from "node:path";
|
|
8
5
|
import process from "node:process";
|
|
6
|
+
import fs from "node:fs/promises";
|
|
9
7
|
import { validatePublicUrl } from "@fedify/vocab-runtime";
|
|
10
8
|
import { encodeBase64 } from "byte-encodings/base64";
|
|
11
|
-
|
|
12
9
|
//#region src/imagerenderer.ts
|
|
13
10
|
const KITTY_IDENTIFIERS = [
|
|
14
11
|
"kitty",
|
|
@@ -62,27 +59,22 @@ function serializeGrCommand(cmd, payload) {
|
|
|
62
59
|
return result;
|
|
63
60
|
}
|
|
64
61
|
async function renderImageKitty(imagePath, cmd) {
|
|
65
|
-
|
|
66
|
-
const base64Data = encodeBase64(imageData);
|
|
67
|
-
let remaining = base64Data;
|
|
62
|
+
let remaining = encodeBase64(await fs.readFile(imagePath));
|
|
68
63
|
let isFirst = true;
|
|
69
64
|
while (remaining.length > 0) {
|
|
70
65
|
const chunk = remaining.slice(0, 4096);
|
|
71
66
|
remaining = remaining.slice(4096);
|
|
72
|
-
const
|
|
67
|
+
const command = serializeGrCommand({
|
|
73
68
|
...isFirst ? cmd : {},
|
|
74
69
|
m: remaining.length > 0 ? 1 : 0
|
|
75
|
-
};
|
|
76
|
-
const command = serializeGrCommand(chunkCmd, chunk);
|
|
70
|
+
}, chunk);
|
|
77
71
|
process.stderr.write(command);
|
|
78
72
|
isFirst = false;
|
|
79
73
|
}
|
|
80
74
|
}
|
|
81
75
|
async function renderImageITerm2(imagePath) {
|
|
82
|
-
const
|
|
83
|
-
const
|
|
84
|
-
const encoder = new TextEncoder();
|
|
85
|
-
const command = encoder.encode(`\x1b]1337;File=inline=1preserveAspectRatio=1:${base64Data}\x07\n`);
|
|
76
|
+
const base64Data = encodeBase64(await fs.readFile(imagePath));
|
|
77
|
+
const command = new TextEncoder().encode(`\x1b]1337;File=inline=1preserveAspectRatio=1:${base64Data}\x07\n`);
|
|
86
78
|
process.stderr.write(command);
|
|
87
79
|
}
|
|
88
80
|
async function downloadImage(url) {
|
|
@@ -132,8 +124,7 @@ async function renderImages(imageUrls) {
|
|
|
132
124
|
const tempPath = await downloadImage(url.href);
|
|
133
125
|
if (!tempPath) continue;
|
|
134
126
|
const convertedImagePath = `${tempPath}.converted.png`;
|
|
135
|
-
|
|
136
|
-
await image.write(convertedImagePath);
|
|
127
|
+
await (await Jimp.read(tempPath)).write(convertedImagePath);
|
|
137
128
|
await fs.rm(tempPath);
|
|
138
129
|
console.error();
|
|
139
130
|
if (graphicsProtocol === "kitty") await renderImageKitty(convertedImagePath, {
|
|
@@ -145,6 +136,5 @@ async function renderImages(imageUrls) {
|
|
|
145
136
|
console.error();
|
|
146
137
|
}
|
|
147
138
|
}
|
|
148
|
-
|
|
149
139
|
//#endregion
|
|
150
|
-
export { renderImages };
|
|
140
|
+
export { renderImages };
|
package/dist/inbox/rendercode.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
-
|
|
1
|
+
import "@js-temporal/polyfill";
|
|
4
2
|
import { getContextLoader } from "../docloader.js";
|
|
5
3
|
import { getStatusText } from "@poppanator/http-constants";
|
|
6
|
-
|
|
7
4
|
//#region src/inbox/rendercode.ts
|
|
8
5
|
function renderRequest(request) {
|
|
9
6
|
request = request.clone();
|
|
@@ -12,8 +9,7 @@ function renderRequest(request) {
|
|
|
12
9
|
}
|
|
13
10
|
function renderResponse(response) {
|
|
14
11
|
response = response.clone();
|
|
15
|
-
|
|
16
|
-
return renderMessage(code, response.headers, response);
|
|
12
|
+
return renderMessage(`${response.status} ${response.statusText === "" ? getStatusText(response.status) : response.statusText}`, response.headers, response);
|
|
17
13
|
}
|
|
18
14
|
async function renderMessage(code, headers, body) {
|
|
19
15
|
code += "\n";
|
|
@@ -42,6 +38,5 @@ async function renderActivity(activity, expand = false) {
|
|
|
42
38
|
function capitalize(name) {
|
|
43
39
|
return name.replace(/(^|-)./g, (match) => match.toUpperCase());
|
|
44
40
|
}
|
|
45
|
-
|
|
46
41
|
//#endregion
|
|
47
|
-
export { renderActivity, renderRawActivity, renderRequest, renderResponse };
|
|
42
|
+
export { renderActivity, renderRawActivity, renderRequest, renderResponse };
|
package/dist/inbox/view.js
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
-
|
|
1
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
4
2
|
import { renderActivity, renderRawActivity, renderRequest, renderResponse } from "./rendercode.js";
|
|
5
3
|
import { getStatusText } from "@poppanator/http-constants";
|
|
6
4
|
import { Fragment } from "hono/jsx";
|
|
7
5
|
import { getSingletonHighlighter } from "shiki";
|
|
8
6
|
import util from "node:util";
|
|
9
7
|
import { jsx, jsxs } from "hono/jsx/jsx-runtime";
|
|
10
|
-
|
|
11
8
|
//#region src/inbox/view.tsx
|
|
12
9
|
const Layout = (props) => {
|
|
13
10
|
return /* @__PURE__ */ jsxs("html", { children: [/* @__PURE__ */ jsxs("head", { children: [
|
|
@@ -291,12 +288,11 @@ await highlighter.loadTheme("github-light");
|
|
|
291
288
|
await highlighter.loadLanguage("http");
|
|
292
289
|
await highlighter.loadLanguage("json");
|
|
293
290
|
const CodeBlock = ({ language, code }) => {
|
|
294
|
-
const result = highlighter.codeToHtml(code, {
|
|
295
|
-
lang: language,
|
|
296
|
-
theme: "github-light"
|
|
297
|
-
});
|
|
298
291
|
return /* @__PURE__ */ jsx("div", {
|
|
299
|
-
dangerouslySetInnerHTML: { __html:
|
|
292
|
+
dangerouslySetInnerHTML: { __html: highlighter.codeToHtml(code, {
|
|
293
|
+
lang: language,
|
|
294
|
+
theme: "github-light"
|
|
295
|
+
}) },
|
|
300
296
|
class: "m-3"
|
|
301
297
|
});
|
|
302
298
|
};
|
|
@@ -452,8 +448,7 @@ const ActivityList = ({ entries }) => {
|
|
|
452
448
|
return /* @__PURE__ */ jsx("div", {
|
|
453
449
|
class: "list-group",
|
|
454
450
|
children: entries.map((entry, i) => {
|
|
455
|
-
const
|
|
456
|
-
const itemClass = failed ? "list-group-item-danger" : "";
|
|
451
|
+
const itemClass = entry.activity == null || entry.response == null || !entry.response.ok || entry.request.method !== "POST" ? "list-group-item-danger" : "";
|
|
457
452
|
const url = new URL(entry.request.url);
|
|
458
453
|
return /* @__PURE__ */ jsxs("a", {
|
|
459
454
|
class: "list-group-item list-group-item-action d-flex w-100 justify-content-between " + itemClass,
|
|
@@ -503,6 +498,5 @@ const ActivityListPage = ({ handle, entries }) => {
|
|
|
503
498
|
}), /* @__PURE__ */ jsx(ActivityList, { entries })]
|
|
504
499
|
});
|
|
505
500
|
};
|
|
506
|
-
|
|
507
501
|
//#endregion
|
|
508
|
-
export { ActivityEntryPage, ActivityListPage };
|
|
502
|
+
export { ActivityEntryPage, ActivityListPage };
|
package/dist/inbox.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
-
|
|
1
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
4
2
|
import { configContext } from "./config.js";
|
|
5
|
-
import
|
|
3
|
+
import { version } from "./deno.js";
|
|
6
4
|
import { getDocumentLoader } from "./docloader.js";
|
|
7
5
|
import { ActivityEntryPage, ActivityListPage } from "./inbox/view.js";
|
|
8
6
|
import { configureLogging, recordingSink } from "./log.js";
|
|
@@ -10,8 +8,8 @@ import { createTunnelOption } from "./options.js";
|
|
|
10
8
|
import { tableStyle } from "./table.js";
|
|
11
9
|
import { spawnTemporaryServer } from "./tempserver.js";
|
|
12
10
|
import { colors, matchesActor } from "./utils.js";
|
|
13
|
-
import process from "node:process";
|
|
14
11
|
import { command, constant, group, merge, message, multiple, object, option, string } from "@optique/core";
|
|
12
|
+
import process from "node:process";
|
|
15
13
|
import { bindConfig } from "@optique/config";
|
|
16
14
|
import { MemoryKvStore, createFederation, generateCryptoKeyPair } from "@fedify/fedify";
|
|
17
15
|
import { Accept, Activity, Application, Delete, Endpoints, Follow, Image, PUBLIC_COLLECTION, isActor, lookupObject } from "@fedify/vocab";
|
|
@@ -20,8 +18,9 @@ import Table from "cli-table3";
|
|
|
20
18
|
import { Hono } from "hono";
|
|
21
19
|
import ora from "ora";
|
|
22
20
|
import { jsx } from "hono/jsx/jsx-runtime";
|
|
23
|
-
|
|
24
21
|
//#region src/inbox.tsx
|
|
22
|
+
/** @jsx react-jsx */
|
|
23
|
+
/** @jsxImportSource hono/jsx */
|
|
25
24
|
const logger = getLogger([
|
|
26
25
|
"fedify",
|
|
27
26
|
"cli",
|
|
@@ -62,14 +61,14 @@ const activities = [];
|
|
|
62
61
|
const acceptFollows = [];
|
|
63
62
|
const peers = {};
|
|
64
63
|
const followers = {};
|
|
65
|
-
async function runInbox(command
|
|
64
|
+
async function runInbox(command) {
|
|
66
65
|
activities.length = 0;
|
|
67
66
|
acceptFollows.length = 0;
|
|
68
67
|
for (const key of Object.keys(peers)) delete peers[key];
|
|
69
68
|
for (const key of Object.keys(followers)) delete followers[key];
|
|
70
|
-
if (command
|
|
69
|
+
if (command.debug) await configureLogging();
|
|
71
70
|
const federationDocumentLoader = await getDocumentLoader();
|
|
72
|
-
const authorizedFetchEnabled = command
|
|
71
|
+
const authorizedFetchEnabled = command.authorizedFetch ?? false;
|
|
73
72
|
const authorize = async (ctx) => {
|
|
74
73
|
if (!authorizedFetchEnabled) return true;
|
|
75
74
|
return await ctx.getSignedKey() != null;
|
|
@@ -132,8 +131,7 @@ async function runInbox(command$1) {
|
|
|
132
131
|
const { identifier } = parsed;
|
|
133
132
|
const follower = await activity.getActor();
|
|
134
133
|
if (!isActor(follower)) return;
|
|
135
|
-
|
|
136
|
-
if (!accepts || activity.id == null) {
|
|
134
|
+
if (!await matchesActor(follower, acceptFollows) || activity.id == null) {
|
|
137
135
|
logger.debug("Does not accept follow from {actor}.", { actor: follower.id?.href });
|
|
138
136
|
return;
|
|
139
137
|
}
|
|
@@ -164,7 +162,7 @@ async function runInbox(command$1) {
|
|
|
164
162
|
return {
|
|
165
163
|
software: {
|
|
166
164
|
name: "fedify-cli",
|
|
167
|
-
version
|
|
165
|
+
version,
|
|
168
166
|
repository: new URL("https://github.com/fedify-dev/fedify")
|
|
169
167
|
},
|
|
170
168
|
protocols: ["activitypub"],
|
|
@@ -180,20 +178,20 @@ async function runInbox(command$1) {
|
|
|
180
178
|
};
|
|
181
179
|
});
|
|
182
180
|
const fetch = createFetchHandler(federation, {
|
|
183
|
-
actorName: command
|
|
184
|
-
actorSummary: command
|
|
181
|
+
actorName: command.actorName,
|
|
182
|
+
actorSummary: command.actorSummary
|
|
185
183
|
});
|
|
186
184
|
const sendDeleteToPeers = createSendDeleteToPeers(federation, {
|
|
187
|
-
actorName: command
|
|
188
|
-
actorSummary: command
|
|
185
|
+
actorName: command.actorName,
|
|
186
|
+
actorSummary: command.actorSummary
|
|
189
187
|
});
|
|
190
188
|
const spinner = ora({
|
|
191
189
|
text: "Spinning up an ephemeral ActivityPub server...",
|
|
192
190
|
discardStdin: false
|
|
193
191
|
}).start();
|
|
194
192
|
const server = await spawnTemporaryServer(fetch, {
|
|
195
|
-
noTunnel: !command
|
|
196
|
-
...command
|
|
193
|
+
noTunnel: !command.tunnel,
|
|
194
|
+
...command.tunnel && { service: command.tunnelService }
|
|
197
195
|
});
|
|
198
196
|
spinner.succeed(`The ephemeral ActivityPub server is up and running: ${colors.green(server.url.href)}`);
|
|
199
197
|
process.on("SIGINT", () => {
|
|
@@ -211,14 +209,14 @@ async function runInbox(command$1) {
|
|
|
211
209
|
spinner.start();
|
|
212
210
|
const fedCtx = federation.createContext(server.url, {
|
|
213
211
|
activityIndex: -1,
|
|
214
|
-
actorName: command
|
|
215
|
-
actorSummary: command
|
|
212
|
+
actorName: command.actorName,
|
|
213
|
+
actorSummary: command.actorSummary
|
|
216
214
|
});
|
|
217
|
-
if (command
|
|
218
|
-
if (command
|
|
215
|
+
if (command.acceptFollow != null && command.acceptFollow.length > 0) acceptFollows.push(...command.acceptFollow ?? []);
|
|
216
|
+
if (command.follow != null && command.follow.length > 0) {
|
|
219
217
|
spinner.text = "Following actors...";
|
|
220
218
|
const documentLoader = await fedCtx.getDocumentLoader({ identifier: "i" });
|
|
221
|
-
for (const uri of command
|
|
219
|
+
for (const uri of command.follow) {
|
|
222
220
|
spinner.text = `Following ${colors.green(uri)}...`;
|
|
223
221
|
const actor = await lookupObject(uri, { documentLoader });
|
|
224
222
|
if (!isActor(actor)) {
|
|
@@ -275,7 +273,7 @@ async function printActivityEntry(idx, entry) {
|
|
|
275
273
|
const response = entry.response?.clone();
|
|
276
274
|
const url = new URL(request.url);
|
|
277
275
|
const activity = entry.activity;
|
|
278
|
-
const object
|
|
276
|
+
const object = await activity?.getObject();
|
|
279
277
|
const table = new Table({
|
|
280
278
|
chars: tableStyle,
|
|
281
279
|
style: {
|
|
@@ -283,12 +281,11 @@ async function printActivityEntry(idx, entry) {
|
|
|
283
281
|
border: []
|
|
284
282
|
}
|
|
285
283
|
});
|
|
286
|
-
table.push({ "Request #:": colors.bold(idx.toString()) }, { "Activity type:": activity == null ? colors.red("failed to parse") : colors.green(`${activity.constructor.name}(${object
|
|
284
|
+
table.push({ "Request #:": colors.bold(idx.toString()) }, { "Activity type:": activity == null ? colors.red("failed to parse") : colors.green(`${activity.constructor.name}(${object?.constructor.name})`) }, { "HTTP request:": `${request.method === "POST" ? colors.green("POST") : colors.red(request.method)} ${url.pathname + url.search}` }, ...response == null ? [] : [{ "HTTP response:": `${response.ok ? colors.green(response.status.toString()) : colors.red(response.status.toString())} ${response.statusText}` }], { "Details": new URL(`/r/${idx}`, url).href });
|
|
287
285
|
console.log(table.toString());
|
|
288
286
|
}
|
|
289
287
|
function getHandle(c) {
|
|
290
|
-
|
|
291
|
-
return `@i@${url.host}`;
|
|
288
|
+
return `@i@${new URL(c.req.url).host}`;
|
|
292
289
|
}
|
|
293
290
|
const app = new Hono();
|
|
294
291
|
app.get("/", (c) => c.redirect("/r"));
|
|
@@ -343,6 +340,5 @@ function createFetchHandler(federation, actorOptions) {
|
|
|
343
340
|
return response;
|
|
344
341
|
};
|
|
345
342
|
}
|
|
346
|
-
|
|
347
343
|
//#endregion
|
|
348
|
-
export { inboxCommand, runInbox };
|
|
344
|
+
export { inboxCommand, runInbox };
|
package/dist/init/mod.js
CHANGED
package/dist/kv.bun.js
CHANGED
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
-
|
|
1
|
+
import "@js-temporal/polyfill";
|
|
4
2
|
import { getCacheDir } from "./cache.js";
|
|
3
|
+
import { join } from "node:path";
|
|
5
4
|
import { SqliteKvStore } from "@fedify/sqlite";
|
|
6
5
|
import { Database } from "bun:sqlite";
|
|
7
|
-
import { join } from "node:path";
|
|
8
|
-
|
|
9
6
|
//#region src/kv.bun.ts
|
|
10
7
|
async function getKvStore() {
|
|
11
|
-
|
|
12
|
-
const sqlite = new Database(path$1);
|
|
13
|
-
return new SqliteKvStore(sqlite);
|
|
8
|
+
return new SqliteKvStore(new Database(join(await getCacheDir(), "sqlite")));
|
|
14
9
|
}
|
|
15
|
-
|
|
16
10
|
//#endregion
|
|
17
|
-
export { getKvStore };
|
|
11
|
+
export { getKvStore };
|
package/dist/kv.node.js
CHANGED
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
-
|
|
1
|
+
import "@js-temporal/polyfill";
|
|
4
2
|
import { getCacheDir } from "./cache.js";
|
|
5
|
-
import { SqliteKvStore } from "@fedify/sqlite";
|
|
6
3
|
import { join } from "node:path";
|
|
4
|
+
import { SqliteKvStore } from "@fedify/sqlite";
|
|
7
5
|
import { DatabaseSync } from "node:sqlite";
|
|
8
|
-
|
|
9
6
|
//#region src/kv.node.ts
|
|
10
7
|
async function getKvStore() {
|
|
11
|
-
|
|
12
|
-
const sqlite = new DatabaseSync(path$1);
|
|
13
|
-
return new SqliteKvStore(sqlite);
|
|
8
|
+
return new SqliteKvStore(new DatabaseSync(join(await getCacheDir(), "sqlite")));
|
|
14
9
|
}
|
|
15
|
-
|
|
16
10
|
//#endregion
|
|
17
|
-
export { getKvStore };
|
|
11
|
+
export { getKvStore };
|
package/dist/log.js
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
-
|
|
1
|
+
import "@js-temporal/polyfill";
|
|
4
2
|
import { dirname } from "node:path";
|
|
5
|
-
import { mkdir } from "node:fs/promises";
|
|
6
3
|
import process from "node:process";
|
|
4
|
+
import { mkdir } from "node:fs/promises";
|
|
7
5
|
import { configure, getConsoleSink } from "@logtape/logtape";
|
|
8
6
|
import { getFileSink } from "@logtape/file";
|
|
9
7
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
10
|
-
|
|
11
8
|
//#region src/log.ts
|
|
12
9
|
function getRecordingSink() {
|
|
13
10
|
let records = [];
|
|
@@ -48,12 +45,12 @@ await configure({
|
|
|
48
45
|
reset: true
|
|
49
46
|
});
|
|
50
47
|
async function configureLogging() {
|
|
51
|
-
const logFile
|
|
48
|
+
const logFile = process.env["FEDIFY_LOG_FILE"];
|
|
52
49
|
await configure({
|
|
53
50
|
sinks: {
|
|
54
51
|
console: getConsoleSink(),
|
|
55
52
|
recording: recordingSink,
|
|
56
|
-
file: logFile
|
|
53
|
+
file: logFile == null ? () => void 0 : getFileSink(logFile)
|
|
57
54
|
},
|
|
58
55
|
filters: {},
|
|
59
56
|
loggers: [
|
|
@@ -81,6 +78,5 @@ async function configureLogging() {
|
|
|
81
78
|
contextLocalStorage: new AsyncLocalStorage()
|
|
82
79
|
});
|
|
83
80
|
}
|
|
84
|
-
|
|
85
81
|
//#endregion
|
|
86
|
-
export { configureLogging, recordingSink };
|
|
82
|
+
export { configureLogging, recordingSink };
|