@fedify/adonisjs 2.4.0-dev.0
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/LICENSE +20 -0
- package/README.md +420 -0
- package/dist/configure.cjs +108 -0
- package/dist/configure.cjs.map +1 -0
- package/dist/configure.d.cts +14 -0
- package/dist/configure.d.ts +14 -0
- package/dist/configure.js +107 -0
- package/dist/configure.js.map +1 -0
- package/dist/index.cjs +19 -0
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +8 -0
- package/dist/package.cjs +121 -0
- package/dist/package.cjs.map +1 -0
- package/dist/package.js +115 -0
- package/dist/package.js.map +1 -0
- package/dist/providers/fedify_provider.cjs +270 -0
- package/dist/providers/fedify_provider.cjs.map +1 -0
- package/dist/providers/fedify_provider.d.cts +54 -0
- package/dist/providers/fedify_provider.d.ts +55 -0
- package/dist/providers/fedify_provider.js +269 -0
- package/dist/providers/fedify_provider.js.map +1 -0
- package/dist/services/builder.cjs +9 -0
- package/dist/services/builder.cjs.map +1 -0
- package/dist/services/builder.d.cts +7 -0
- package/dist/services/builder.d.ts +8 -0
- package/dist/services/builder.js +8 -0
- package/dist/services/builder.js.map +1 -0
- package/dist/src/builder.cjs +55 -0
- package/dist/src/builder.cjs.map +1 -0
- package/dist/src/builder.d.cts +14 -0
- package/dist/src/builder.d.ts +14 -0
- package/dist/src/builder.js +54 -0
- package/dist/src/builder.js.map +1 -0
- package/dist/src/define_config.cjs +114 -0
- package/dist/src/define_config.cjs.map +1 -0
- package/dist/src/define_config.d.cts +30 -0
- package/dist/src/define_config.d.ts +30 -0
- package/dist/src/define_config.js +113 -0
- package/dist/src/define_config.js.map +1 -0
- package/dist/src/errors.cjs +77 -0
- package/dist/src/errors.cjs.map +1 -0
- package/dist/src/errors.d.cts +56 -0
- package/dist/src/errors.d.ts +56 -0
- package/dist/src/errors.js +73 -0
- package/dist/src/errors.js.map +1 -0
- package/dist/src/fedify_middleware.cjs +507 -0
- package/dist/src/fedify_middleware.cjs.map +1 -0
- package/dist/src/fedify_middleware.d.cts +85 -0
- package/dist/src/fedify_middleware.d.ts +85 -0
- package/dist/src/fedify_middleware.js +505 -0
- package/dist/src/fedify_middleware.js.map +1 -0
- package/dist/src/http_context.cjs +79 -0
- package/dist/src/http_context.cjs.map +1 -0
- package/dist/src/http_context.d.cts +31 -0
- package/dist/src/http_context.d.ts +31 -0
- package/dist/src/http_context.js +76 -0
- package/dist/src/http_context.js.map +1 -0
- package/dist/src/logging.cjs +106 -0
- package/dist/src/logging.cjs.map +1 -0
- package/dist/src/logging.d.cts +45 -0
- package/dist/src/logging.d.ts +45 -0
- package/dist/src/logging.js +106 -0
- package/dist/src/logging.js.map +1 -0
- package/dist/src/types.cjs +1 -0
- package/dist/src/types.d.cts +269 -0
- package/dist/src/types.d.ts +269 -0
- package/dist/src/types.js +1 -0
- package/dist/src/unusable_authority.cjs +79 -0
- package/dist/src/unusable_authority.cjs.map +1 -0
- package/dist/src/unusable_authority.js +76 -0
- package/dist/src/unusable_authority.js.map +1 -0
- package/dist/stubs/config/fedify.stub +105 -0
- package/dist/stubs/federation/main.stub +64 -0
- package/dist/stubs/main.cjs +16 -0
- package/dist/stubs/main.cjs.map +1 -0
- package/dist/stubs/main.d.cts +11 -0
- package/dist/stubs/main.d.ts +11 -0
- package/dist/stubs/main.js +15 -0
- package/dist/stubs/main.js.map +1 -0
- package/dist/stubs/start/federation.stub +20 -0
- package/package.json +124 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
//#region src/unusable_authority.ts
|
|
2
|
+
/**
|
|
3
|
+
* The host used when the request carries no usable authority.
|
|
4
|
+
*
|
|
5
|
+
* `FederationOptions.origin` covers the URLs Fedify *mints* — actor URIs,
|
|
6
|
+
* activity IDs, collection URLs — so the placeholder never reaches a peer
|
|
7
|
+
* through them, and only the path has to survive for routing. It does not
|
|
8
|
+
* cover verification: RFC 9421's `@authority`, `@target-uri` and `@scheme`
|
|
9
|
+
* are derived from this URL, so a request signed over `@authority` fails to
|
|
10
|
+
* verify while the placeholder stands in. That is the cost of answering
|
|
11
|
+
* instead of failing, and why the fallback is logged.
|
|
12
|
+
*/
|
|
13
|
+
const PLACEHOLDER_HOST = "localhost";
|
|
14
|
+
/**
|
|
15
|
+
* Unusable authorities already warned about in the current window. Any
|
|
16
|
+
* client can trigger the warning through `Host`, so each distinct value is
|
|
17
|
+
* reported once and the set is capped, leaving neither it nor the log
|
|
18
|
+
* unbounded. The key is the whole value, since two hostile values can share
|
|
19
|
+
* a 128-character prefix.
|
|
20
|
+
*/
|
|
21
|
+
const warnedAuthorities = new Set();
|
|
22
|
+
/**
|
|
23
|
+
* How many distinct values one window reports.
|
|
24
|
+
*/
|
|
25
|
+
const WARNED_AUTHORITIES_LIMIT = 16;
|
|
26
|
+
/**
|
|
27
|
+
* How long the cap holds before the budget starts over.
|
|
28
|
+
*
|
|
29
|
+
* Without a window the cap is spent for the life of the process, and the
|
|
30
|
+
* values that spend it are the client's to choose: sixteen junk `Host`
|
|
31
|
+
* headers would silence the warning for good, so a proxy misconfigured an
|
|
32
|
+
* hour later—every request falling back to {@link PLACEHOLDER_HOST}, every
|
|
33
|
+
* signature over `@authority` failing to verify—would never be reported.
|
|
34
|
+
* Starting over bounds the log at {@link WARNED_AUTHORITIES_LIMIT} lines per
|
|
35
|
+
* window instead of over all time, which is what the log has to be protected
|
|
36
|
+
* from, and leaves a standing misconfiguration visible.
|
|
37
|
+
*/
|
|
38
|
+
const WARNED_AUTHORITIES_WINDOW_MS = 60 * 60 * 1e3;
|
|
39
|
+
/**
|
|
40
|
+
* When the current window began; `0` so the first warning opens one. It
|
|
41
|
+
* advances lazily, on the first warning after the window has elapsed, rather
|
|
42
|
+
* than from a timer that would hold the event loop open on a quiet process.
|
|
43
|
+
*/
|
|
44
|
+
let warnedAuthoritiesWindowStart = 0;
|
|
45
|
+
/**
|
|
46
|
+
* Whether the cap has already been reported in this window. Reaching it
|
|
47
|
+
* silences every later distinct value, which should not happen invisibly.
|
|
48
|
+
*/
|
|
49
|
+
let warnedAuthoritiesCapReported = false;
|
|
50
|
+
/**
|
|
51
|
+
* Reports an authority the request URL could not be built from, once per
|
|
52
|
+
* distinct value and window.
|
|
53
|
+
*/
|
|
54
|
+
function warnUnusableAuthority(logger, host) {
|
|
55
|
+
const now = Date.now();
|
|
56
|
+
if (now < warnedAuthoritiesWindowStart || now - warnedAuthoritiesWindowStart >= 36e5) {
|
|
57
|
+
warnedAuthoritiesWindowStart = now;
|
|
58
|
+
warnedAuthorities.clear();
|
|
59
|
+
warnedAuthoritiesCapReported = false;
|
|
60
|
+
}
|
|
61
|
+
if (warnedAuthorities.has(host)) return;
|
|
62
|
+
if (warnedAuthorities.size >= 16) {
|
|
63
|
+
if (warnedAuthoritiesCapReported) return;
|
|
64
|
+
warnedAuthoritiesCapReported = true;
|
|
65
|
+
logger.warn("Reached %d distinct unusable request authorities within %d minutes; " + "further distinct values are not reported until that window ends", 16, WARNED_AUTHORITIES_WINDOW_MS / 6e4);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
warnedAuthorities.add(host);
|
|
69
|
+
const points = Array.from(host);
|
|
70
|
+
const shown = points.length > 128 ? `${points.slice(0, 128).join("")}…` : host;
|
|
71
|
+
logger.warn("Unusable request authority \"%s\"; the URL Fedify sees falls back to " + "\"%s\", so signatures covering the authority will not verify. Behind a " + "proxy this is a misbehaving X-Forwarded-Host; otherwise a client sent " + "it directly. Each distinct value is reported once per %d minutes, up " + "to %d values in that window", shown, PLACEHOLDER_HOST, WARNED_AUTHORITIES_WINDOW_MS / 6e4, 16);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
//#endregion
|
|
75
|
+
export { PLACEHOLDER_HOST, WARNED_AUTHORITIES_WINDOW_MS, warnUnusableAuthority };
|
|
76
|
+
//# sourceMappingURL=unusable_authority.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unusable_authority.js","names":[],"sources":["../../src/unusable_authority.ts"],"sourcesContent":["/**\n * The warning for a request whose authority cannot be used, and the budget\n * that keeps it from flooding the log.\n *\n * Internal to the package: this module is reachable through none of the\n * published subpaths. The two constants are exported for the tests, which\n * have to spend exactly this budget.\n *\n * @module\n */\nimport type { HttpContext } from \"@adonisjs/core/http\";\n\n/**\n * The host used when the request carries no usable authority.\n *\n * `FederationOptions.origin` covers the URLs Fedify *mints* — actor URIs,\n * activity IDs, collection URLs — so the placeholder never reaches a peer\n * through them, and only the path has to survive for routing. It does not\n * cover verification: RFC 9421's `@authority`, `@target-uri` and `@scheme`\n * are derived from this URL, so a request signed over `@authority` fails to\n * verify while the placeholder stands in. That is the cost of answering\n * instead of failing, and why the fallback is logged.\n */\nexport const PLACEHOLDER_HOST: string = \"localhost\";\n\n/**\n * Unusable authorities already warned about in the current window. Any\n * client can trigger the warning through `Host`, so each distinct value is\n * reported once and the set is capped, leaving neither it nor the log\n * unbounded. The key is the whole value, since two hostile values can share\n * a 128-character prefix.\n */\nconst warnedAuthorities = new Set<string>();\n\n/**\n * How many distinct values one window reports.\n */\nexport const WARNED_AUTHORITIES_LIMIT: number = 16;\n\n/**\n * How long the cap holds before the budget starts over.\n *\n * Without a window the cap is spent for the life of the process, and the\n * values that spend it are the client's to choose: sixteen junk `Host`\n * headers would silence the warning for good, so a proxy misconfigured an\n * hour later—every request falling back to {@link PLACEHOLDER_HOST}, every\n * signature over `@authority` failing to verify—would never be reported.\n * Starting over bounds the log at {@link WARNED_AUTHORITIES_LIMIT} lines per\n * window instead of over all time, which is what the log has to be protected\n * from, and leaves a standing misconfiguration visible.\n */\nexport const WARNED_AUTHORITIES_WINDOW_MS: number = 60 * 60 * 1000;\n\n/**\n * When the current window began; `0` so the first warning opens one. It\n * advances lazily, on the first warning after the window has elapsed, rather\n * than from a timer that would hold the event loop open on a quiet process.\n */\nlet warnedAuthoritiesWindowStart = 0;\n\n/**\n * Whether the cap has already been reported in this window. Reaching it\n * silences every later distinct value, which should not happen invisibly.\n */\nlet warnedAuthoritiesCapReported = false;\n\n/**\n * Reports an authority the request URL could not be built from, once per\n * distinct value and window.\n */\nexport function warnUnusableAuthority(\n logger: HttpContext[\"logger\"],\n host: string,\n): void {\n const now = Date.now();\n // `<` as well as the elapsed check: a backwards clock step (an NTP\n // correction) would otherwise freeze the window until real time caught up\n // with a start that lies in the future.\n if (\n now < warnedAuthoritiesWindowStart ||\n now - warnedAuthoritiesWindowStart >= WARNED_AUTHORITIES_WINDOW_MS\n ) {\n warnedAuthoritiesWindowStart = now;\n warnedAuthorities.clear();\n warnedAuthoritiesCapReported = false;\n }\n\n if (warnedAuthorities.has(host)) return;\n if (warnedAuthorities.size >= WARNED_AUTHORITIES_LIMIT) {\n if (warnedAuthoritiesCapReported) return;\n warnedAuthoritiesCapReported = true;\n logger.warn(\n \"Reached %d distinct unusable request authorities within %d minutes; \" +\n \"further distinct values are not reported until that window ends\",\n WARNED_AUTHORITIES_LIMIT,\n WARNED_AUTHORITIES_WINDOW_MS / 60_000,\n );\n return;\n }\n warnedAuthorities.add(host);\n // By code point, so an emoji straddling the boundary cannot leave a lone\n // surrogate in the key or the log line.\n const points = Array.from(host);\n const shown = points.length > 128\n ? `${points.slice(0, 128).join(\"\")}…`\n : host;\n logger.warn(\n 'Unusable request authority \"%s\"; the URL Fedify sees falls back to ' +\n '\"%s\", so signatures covering the authority will not verify. Behind a ' +\n \"proxy this is a misbehaving X-Forwarded-Host; otherwise a client sent \" +\n \"it directly. Each distinct value is reported once per %d minutes, up \" +\n \"to %d values in that window\",\n shown,\n PLACEHOLDER_HOST,\n WARNED_AUTHORITIES_WINDOW_MS / 60_000,\n WARNED_AUTHORITIES_LIMIT,\n );\n}\n"],"mappings":";;;;;;;;;;;;AAuBA,MAAa,mBAA2B;;;;;;;;AASxC,MAAM,oBAAoB,IAAI,IAAY;;;;AAK1C,MAAa,2BAAmC;;;;;;;;;;;;;AAchD,MAAa,+BAAuC,KAAK,KAAK;;;;;;AAO9D,IAAI,+BAA+B;;;;;AAMnC,IAAI,+BAA+B;;;;;AAMnC,SAAgB,sBACd,QACA,MACM;CACN,MAAM,MAAM,KAAK,IAAI;CAIrB,IACE,MAAM,gCACN,MAAM,sCACN;EACA,+BAA+B;EAC/B,kBAAkB,MAAM;EACxB,+BAA+B;CACjC;CAEA,IAAI,kBAAkB,IAAI,IAAI,GAAG;CACjC,IAAI,kBAAkB,YAAkC;EACtD,IAAI,8BAA8B;EAClC,+BAA+B;EAC/B,OAAO,KACL,yEACE,uEAEF,+BAA+B,GACjC;EACA;CACF;CACA,kBAAkB,IAAI,IAAI;CAG1B,MAAM,SAAS,MAAM,KAAK,IAAI;CAC9B,MAAM,QAAQ,OAAO,SAAS,MAC1B,GAAG,OAAO,MAAM,GAAG,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,KACjC;CACJ,OAAO,KACL,0EACE,4EACA,2EACA,0EACA,+BACF,OACA,kBACA,+BAA+B,OAEjC;AACF"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
{{{
|
|
2
|
+
exports({ to: app.configPath('fedify.ts') })
|
|
3
|
+
}}}
|
|
4
|
+
import { defineConfig } from '@fedify/adonisjs'
|
|
5
|
+
import env from '#start/env'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The domain that fediverse handles live on, if it differs from the web origin.
|
|
9
|
+
* Leave FEDERATION_HANDLE_HOST unset when handles and pages share a domain.
|
|
10
|
+
*/
|
|
11
|
+
const handleHost = env.get('FEDERATION_HANDLE_HOST')
|
|
12
|
+
|
|
13
|
+
export default defineConfig({
|
|
14
|
+
/**
|
|
15
|
+
* The canonical public origin of this server.
|
|
16
|
+
*
|
|
17
|
+
* Fedify builds actor URIs, activity IDs and collection URLs from this value,
|
|
18
|
+
* so it must be the address remote servers can reach. When developing behind
|
|
19
|
+
* "fedify tunnel" or ngrok, set PUBLIC_URL to the tunnel URL.
|
|
20
|
+
*/
|
|
21
|
+
origin: handleHost
|
|
22
|
+
? { handleHost, webOrigin: env.get('PUBLIC_URL') }
|
|
23
|
+
: env.get('PUBLIC_URL'),
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Where Fedify caches remote documents, tracks inbox idempotency and keeps
|
|
27
|
+
* outbox state.
|
|
28
|
+
*
|
|
29
|
+
* Defaults to an in-memory store, which is fine for development but is lost
|
|
30
|
+
* on restart and cannot be shared between processes. Install one of
|
|
31
|
+
* "@fedify/sqlite", "@fedify/postgres", "@fedify/redis" or "@fedify/mysql"
|
|
32
|
+
* before going to production, then uncomment the lines below:
|
|
33
|
+
*
|
|
34
|
+
* import { DatabaseSync } from 'node:sqlite'
|
|
35
|
+
* import { SqliteKvStore, SqliteMessageQueue } from '@fedify/sqlite'
|
|
36
|
+
* import app from '@adonisjs/core/services/app'
|
|
37
|
+
*
|
|
38
|
+
* const database = new DatabaseSync(app.tmpPath('fedify.sqlite3'))
|
|
39
|
+
*/
|
|
40
|
+
// kv: new SqliteKvStore(database),
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* The queue used to deliver outgoing activities and to process incoming ones.
|
|
44
|
+
*
|
|
45
|
+
* Without a queue, delivery happens inline: the request that triggered it
|
|
46
|
+
* blocks until every recipient server has answered, and a failed delivery is
|
|
47
|
+
* never retried. Production deployments should always configure one.
|
|
48
|
+
*
|
|
49
|
+
* A "queue" needs "queueContextData" below to say who drains it, and is
|
|
50
|
+
* refused at boot without it.
|
|
51
|
+
*/
|
|
52
|
+
// queue: new SqliteMessageQueue(database),
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Who drains the queue.
|
|
56
|
+
*
|
|
57
|
+
* A callback means this process does, and the context data it returns is what
|
|
58
|
+
* background jobs see -- there is no HTTP request behind them. Use "false"
|
|
59
|
+
* when a separate worker process owns the queue.
|
|
60
|
+
*
|
|
61
|
+
* A callback without a "queue" above is accepted with a warning: unless a
|
|
62
|
+
* task registers its own queue through defineTask(), there is nothing to
|
|
63
|
+
* drain. "false" is accepted either way, since "this process does not drain
|
|
64
|
+
* the queue" stays true when there is none -- which is what enabling the
|
|
65
|
+
* queue in production only needs:
|
|
66
|
+
*
|
|
67
|
+
* queue: app.inProduction ? new SqliteMessageQueue(database) : undefined,
|
|
68
|
+
* queueContextData: app.inProduction ? () => null : false,
|
|
69
|
+
*/
|
|
70
|
+
// queueContextData: () => null,
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* URL path prefixes that skip Fedify entirely.
|
|
74
|
+
*
|
|
75
|
+
* A pure performance escape hatch for paths that can never be federation
|
|
76
|
+
* endpoints. Accessing "ctx.federation" on such a request throws.
|
|
77
|
+
*/
|
|
78
|
+
ignoreRoutePrefixes: ['/@vite/', '/resources/', '/node_modules/'],
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* The value Fedify threads through every dispatcher and inbox listener as
|
|
83
|
+
* "ctx.data".
|
|
84
|
+
*
|
|
85
|
+
* It defaults to "HttpContext | null" -- null when Fedify is working outside a
|
|
86
|
+
* request, such as in a queue worker. Augment it here to carry something more
|
|
87
|
+
* specific, and set "contextDataFactory" above to build it -- the option becomes
|
|
88
|
+
* required once you do:
|
|
89
|
+
*
|
|
90
|
+
* declare module '@fedify/adonisjs/types' {
|
|
91
|
+
* interface FedifyTypes {
|
|
92
|
+
* contextData: { requestId: string | undefined }
|
|
93
|
+
* }
|
|
94
|
+
* }
|
|
95
|
+
*
|
|
96
|
+
* contextDataFactory: (ctx) => ({ requestId: ctx.request.id() }),
|
|
97
|
+
*
|
|
98
|
+
* The factory runs in the server middleware stack, before route matching and
|
|
99
|
+
* before every router middleware, so only "ctx.request", "ctx.response",
|
|
100
|
+
* "ctx.logger" and "ctx.containerResolver" are available to it. "ctx.auth",
|
|
101
|
+
* "ctx.session", "ctx.bouncer", "ctx.params" and "ctx.route" are still
|
|
102
|
+
* undefined there ("ctx.params" is "{}"). Look users up inside the
|
|
103
|
+
* dispatcher that needs them instead -- a federation request comes from a
|
|
104
|
+
* remote server and has no session behind it.
|
|
105
|
+
*/
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{{{
|
|
2
|
+
exports({ to: app.makePath('app/federation/main.ts') })
|
|
3
|
+
}}}
|
|
4
|
+
/*
|
|
5
|
+
|--------------------------------------------------------------------------
|
|
6
|
+
| Federation dispatchers
|
|
7
|
+
|--------------------------------------------------------------------------
|
|
8
|
+
|
|
|
9
|
+
| Registered on the Fedify builder while the application boots, from the
|
|
10
|
+
| "start/federation.ts" preload file.
|
|
11
|
+
|
|
|
12
|
+
| Registration happens exactly once per process. Do not add this directory
|
|
13
|
+
| to "hotHook.boundaries" in package.json: re-importing the module on a hot
|
|
14
|
+
| reload would register the same dispatcher twice and Fedify would throw.
|
|
15
|
+
| Restart the dev server after changing a dispatcher.
|
|
16
|
+
|
|
|
17
|
+
| See https://fedify.dev/manual/actor and https://fedify.dev/manual/inbox
|
|
18
|
+
|
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import federation from '@fedify/adonisjs/services/builder'
|
|
22
|
+
import { Endpoints, Person } from '@fedify/vocab'
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Serves the actor document at "/actors/<identifier>", and -- through the key
|
|
26
|
+
* pairs dispatcher -- the keys that sign this actor's outgoing activities.
|
|
27
|
+
*/
|
|
28
|
+
federation
|
|
29
|
+
.setActorDispatcher('/actors/{identifier}', async (ctx, identifier) => {
|
|
30
|
+
// Look the actor up in your database and return null when it is unknown.
|
|
31
|
+
if (identifier !== 'me') return null
|
|
32
|
+
|
|
33
|
+
const keys = await ctx.getActorKeyPairs(identifier)
|
|
34
|
+
|
|
35
|
+
return new Person({
|
|
36
|
+
id: ctx.getActorUri(identifier),
|
|
37
|
+
preferredUsername: identifier,
|
|
38
|
+
name: 'Me',
|
|
39
|
+
inbox: ctx.getInboxUri(identifier),
|
|
40
|
+
endpoints: new Endpoints({ sharedInbox: ctx.getInboxUri() }),
|
|
41
|
+
url: new URL('/', ctx.url),
|
|
42
|
+
|
|
43
|
+
// Two keys, two purposes: the RSA key signs HTTP Signatures (what
|
|
44
|
+
// Mastodon verifies), the Ed25519 key signs Object Integrity Proofs.
|
|
45
|
+
publicKeys: keys.map((keyPair) => keyPair.cryptographicKey),
|
|
46
|
+
assertionMethods: keys.map((keyPair) => keyPair.multikey),
|
|
47
|
+
})
|
|
48
|
+
})
|
|
49
|
+
.setKeyPairsDispatcher(async (_ctx, _identifier) => {
|
|
50
|
+
// Load the actor's key pairs from your database, generating and persisting
|
|
51
|
+
// them the first time. Private keys are secrets: never log them, never
|
|
52
|
+
// expose them through an endpoint.
|
|
53
|
+
//
|
|
54
|
+
// See https://fedify.dev/manual/actor#public-keys-of-an-actor
|
|
55
|
+
return []
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Receives activities from other servers.
|
|
60
|
+
*
|
|
61
|
+
* The second path is the shared inbox, which servers use to deliver one
|
|
62
|
+
* activity destined for many local actors.
|
|
63
|
+
*/
|
|
64
|
+
federation.setInboxListeners('/actors/{identifier}/inbox', '/inbox')
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
let node_path = require("node:path");
|
|
3
|
+
let node_url = require("node:url");
|
|
4
|
+
|
|
5
|
+
//#region stubs/main.ts
|
|
6
|
+
/**
|
|
7
|
+
* The root of the stub templates shipped with this package.
|
|
8
|
+
*
|
|
9
|
+
* Used by `configure.ts` and by `node ace eject <stub> --pkg=@fedify/adonisjs`
|
|
10
|
+
* when an application wants to customise a generated file.
|
|
11
|
+
*/
|
|
12
|
+
const stubsRoot = (0, node_path.dirname)((0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href));
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
exports.stubsRoot = stubsRoot;
|
|
16
|
+
//# sourceMappingURL=main.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.cjs","names":[],"sources":["../../stubs/main.ts"],"sourcesContent":["import { dirname } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\n/**\n * The root of the stub templates shipped with this package.\n *\n * Used by `configure.ts` and by `node ace eject <stub> --pkg=@fedify/adonisjs`\n * when an application wants to customise a generated file.\n */\nexport const stubsRoot: string = dirname(fileURLToPath(import.meta.url));\n"],"mappings":";;;;;;;;;;;AASA,MAAa,4GAAyD,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region stubs/main.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* The root of the stub templates shipped with this package.
|
|
4
|
+
*
|
|
5
|
+
* Used by `configure.ts` and by `node ace eject <stub> --pkg=@fedify/adonisjs`
|
|
6
|
+
* when an application wants to customise a generated file.
|
|
7
|
+
*/
|
|
8
|
+
declare const stubsRoot: string;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { stubsRoot };
|
|
11
|
+
//# sourceMappingURL=main.d.cts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region stubs/main.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* The root of the stub templates shipped with this package.
|
|
4
|
+
*
|
|
5
|
+
* Used by `configure.ts` and by `node ace eject <stub> --pkg=@fedify/adonisjs`
|
|
6
|
+
* when an application wants to customise a generated file.
|
|
7
|
+
*/
|
|
8
|
+
declare const stubsRoot: string;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { stubsRoot };
|
|
11
|
+
//# sourceMappingURL=main.d.ts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { dirname } from "node:path";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
|
|
4
|
+
//#region stubs/main.ts
|
|
5
|
+
/**
|
|
6
|
+
* The root of the stub templates shipped with this package.
|
|
7
|
+
*
|
|
8
|
+
* Used by `configure.ts` and by `node ace eject <stub> --pkg=@fedify/adonisjs`
|
|
9
|
+
* when an application wants to customise a generated file.
|
|
10
|
+
*/
|
|
11
|
+
const stubsRoot = dirname(fileURLToPath(import.meta.url));
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
export { stubsRoot };
|
|
15
|
+
//# sourceMappingURL=main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.js","names":[],"sources":["../../stubs/main.ts"],"sourcesContent":["import { dirname } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\n/**\n * The root of the stub templates shipped with this package.\n *\n * Used by `configure.ts` and by `node ace eject <stub> --pkg=@fedify/adonisjs`\n * when an application wants to customise a generated file.\n */\nexport const stubsRoot: string = dirname(fileURLToPath(import.meta.url));\n"],"mappings":";;;;;;;;;;AASA,MAAa,YAAoB,QAAQ,cAAc,OAAO,KAAK,GAAG,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{{{
|
|
2
|
+
exports({ to: app.makePath('start/federation.ts') })
|
|
3
|
+
}}}
|
|
4
|
+
/*
|
|
5
|
+
|--------------------------------------------------------------------------
|
|
6
|
+
| Federation preload file
|
|
7
|
+
|--------------------------------------------------------------------------
|
|
8
|
+
|
|
|
9
|
+
| Imported while the application boots, after every service provider has
|
|
10
|
+
| booted and before the HTTP server starts accepting connections. This is
|
|
11
|
+
| where Fedify's actor dispatchers, collection dispatchers and inbox
|
|
12
|
+
| listeners get registered.
|
|
13
|
+
|
|
|
14
|
+
| Import each of your federation modules here. They register themselves on
|
|
15
|
+
| the builder exported by "@fedify/adonisjs/services/builder", and the
|
|
16
|
+
| builder is sealed into a Federation object once this file has run.
|
|
17
|
+
|
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import '../app/federation/main.js'
|
package/package.json
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@fedify/adonisjs",
|
|
3
|
+
"version": "2.4.0-dev.0",
|
|
4
|
+
"description": "Integration package for Fedify with AdonisJS",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"Fedify",
|
|
7
|
+
"Federation",
|
|
8
|
+
"ActivityPub",
|
|
9
|
+
"AdonisJS",
|
|
10
|
+
"fediverse"
|
|
11
|
+
],
|
|
12
|
+
"author": {
|
|
13
|
+
"name": "scammo",
|
|
14
|
+
"email": "pfannkuchensack.ae@gmail.com"
|
|
15
|
+
},
|
|
16
|
+
"homepage": "https://fedify.dev/",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/fedify-dev/fedify.git",
|
|
20
|
+
"directory": "packages/adonisjs"
|
|
21
|
+
},
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://github.com/fedify-dev/fedify/issues"
|
|
24
|
+
},
|
|
25
|
+
"funding": [
|
|
26
|
+
"https://opencollective.com/fedify",
|
|
27
|
+
"https://github.com/sponsors/dahlia"
|
|
28
|
+
],
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"type": "module",
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">=24.0.0"
|
|
33
|
+
},
|
|
34
|
+
"main": "./dist/index.cjs",
|
|
35
|
+
"module": "./dist/index.js",
|
|
36
|
+
"types": "./dist/index.d.ts",
|
|
37
|
+
"exports": {
|
|
38
|
+
".": {
|
|
39
|
+
"types": {
|
|
40
|
+
"import": "./dist/index.d.ts",
|
|
41
|
+
"require": "./dist/index.d.cts",
|
|
42
|
+
"default": "./dist/index.d.ts"
|
|
43
|
+
},
|
|
44
|
+
"import": "./dist/index.js",
|
|
45
|
+
"require": "./dist/index.cjs",
|
|
46
|
+
"default": "./dist/index.js"
|
|
47
|
+
},
|
|
48
|
+
"./types": {
|
|
49
|
+
"types": {
|
|
50
|
+
"import": "./dist/src/types.d.ts",
|
|
51
|
+
"require": "./dist/src/types.d.cts",
|
|
52
|
+
"default": "./dist/src/types.d.ts"
|
|
53
|
+
},
|
|
54
|
+
"import": "./dist/src/types.js",
|
|
55
|
+
"require": "./dist/src/types.cjs",
|
|
56
|
+
"default": "./dist/src/types.js"
|
|
57
|
+
},
|
|
58
|
+
"./fedify_provider": {
|
|
59
|
+
"types": {
|
|
60
|
+
"import": "./dist/providers/fedify_provider.d.ts",
|
|
61
|
+
"require": "./dist/providers/fedify_provider.d.cts",
|
|
62
|
+
"default": "./dist/providers/fedify_provider.d.ts"
|
|
63
|
+
},
|
|
64
|
+
"import": "./dist/providers/fedify_provider.js",
|
|
65
|
+
"require": "./dist/providers/fedify_provider.cjs",
|
|
66
|
+
"default": "./dist/providers/fedify_provider.js"
|
|
67
|
+
},
|
|
68
|
+
"./fedify_middleware": {
|
|
69
|
+
"types": {
|
|
70
|
+
"import": "./dist/src/fedify_middleware.d.ts",
|
|
71
|
+
"require": "./dist/src/fedify_middleware.d.cts",
|
|
72
|
+
"default": "./dist/src/fedify_middleware.d.ts"
|
|
73
|
+
},
|
|
74
|
+
"import": "./dist/src/fedify_middleware.js",
|
|
75
|
+
"require": "./dist/src/fedify_middleware.cjs",
|
|
76
|
+
"default": "./dist/src/fedify_middleware.js"
|
|
77
|
+
},
|
|
78
|
+
"./services/builder": {
|
|
79
|
+
"types": {
|
|
80
|
+
"import": "./dist/services/builder.d.ts",
|
|
81
|
+
"require": "./dist/services/builder.d.cts",
|
|
82
|
+
"default": "./dist/services/builder.d.ts"
|
|
83
|
+
},
|
|
84
|
+
"import": "./dist/services/builder.js",
|
|
85
|
+
"require": "./dist/services/builder.cjs",
|
|
86
|
+
"default": "./dist/services/builder.js"
|
|
87
|
+
},
|
|
88
|
+
"./package.json": "./package.json"
|
|
89
|
+
},
|
|
90
|
+
"files": [
|
|
91
|
+
"dist/",
|
|
92
|
+
"package.json"
|
|
93
|
+
],
|
|
94
|
+
"peerDependencies": {
|
|
95
|
+
"@adonisjs/assembler": "^8.0.0",
|
|
96
|
+
"@adonisjs/core": "^7.4.0",
|
|
97
|
+
"@fedify/fedify": "^2.4.0"
|
|
98
|
+
},
|
|
99
|
+
"peerDependenciesMeta": {
|
|
100
|
+
"@adonisjs/assembler": {
|
|
101
|
+
"optional": true
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
"dependencies": {
|
|
105
|
+
"@logtape/logtape": "^2.2.0"
|
|
106
|
+
},
|
|
107
|
+
"devDependencies": {
|
|
108
|
+
"@adonisjs/assembler": "^8.0.0",
|
|
109
|
+
"@adonisjs/core": "^7.4.0",
|
|
110
|
+
"@types/node": "^22.17.0",
|
|
111
|
+
"tsdown": "^0.22.0",
|
|
112
|
+
"typescript": "^6.0.0",
|
|
113
|
+
"@fedify/fedify": "^2.4.0",
|
|
114
|
+
"@fedify/vocab": "^2.4.0"
|
|
115
|
+
},
|
|
116
|
+
"scripts": {
|
|
117
|
+
"build:self": "tsdown",
|
|
118
|
+
"build": "pnpm --filter @fedify/adonisjs... run build:self",
|
|
119
|
+
"prepublish": "pnpm build",
|
|
120
|
+
"pretest": "pnpm run build:self",
|
|
121
|
+
"typecheck": "tsc --noEmit",
|
|
122
|
+
"test": "node --test \"src/**/*.test.ts\""
|
|
123
|
+
}
|
|
124
|
+
}
|