@fedify/fedify 0.7.0-dev.129 → 0.7.0-dev.131
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of @fedify/fedify might be problematic. Click here for more details.
package/CHANGES.md
CHANGED
@@ -25,8 +25,17 @@ To be released.
|
|
25
25
|
- The default implementation of `FederationFetchOptions.onNotAcceptable`
|
26
26
|
option now responds with `Vary: Accept, Signature` header.
|
27
27
|
|
28
|
+
- Added log messages using the [LogTape] library. Currently the below
|
29
|
+
categories are used:
|
30
|
+
|
31
|
+
- `["fedify"]`
|
32
|
+
- `["fedify", "federation"]`
|
33
|
+
- `["fedify", "federation", "inbox"]`
|
34
|
+
- `["fedify", "federation", "outbox"]`
|
35
|
+
|
28
36
|
[public addressing]: https://www.w3.org/TR/activitypub/#public-addressing
|
29
37
|
[authorized fetch]: https://swicg.github.io/activitypub-http-signature/#authorized-fetch
|
38
|
+
[LogTape]: https://github.com/dahlia/logtape
|
30
39
|
|
31
40
|
|
32
41
|
Version 0.6.1
|
@@ -74,13 +74,20 @@ export class Federation {
|
|
74
74
|
}
|
75
75
|
#startQueue() {
|
76
76
|
if (this.#queue != null && !this.#queueStarted) {
|
77
|
-
getLogger(["fedify", "federation", "outbox"])
|
78
|
-
|
77
|
+
const logger = getLogger(["fedify", "federation", "outbox"]);
|
78
|
+
logger.debug("Starting an outbox queue.");
|
79
79
|
this.#queue?.listen(this.#listenQueue.bind(this));
|
80
80
|
this.#queueStarted = true;
|
81
81
|
}
|
82
82
|
}
|
83
83
|
async #listenQueue(message) {
|
84
|
+
const logger = getLogger(["fedify", "federation", "outbox"]);
|
85
|
+
const logData = {
|
86
|
+
keyId: message.keyId,
|
87
|
+
inbox: message.inbox,
|
88
|
+
activity: message.activity,
|
89
|
+
trial: message.trial,
|
90
|
+
};
|
84
91
|
let activity = null;
|
85
92
|
try {
|
86
93
|
const keyId = new URL(message.keyId);
|
@@ -97,20 +104,28 @@ export class Federation {
|
|
97
104
|
documentLoader,
|
98
105
|
});
|
99
106
|
}
|
100
|
-
catch (
|
107
|
+
catch (error) {
|
101
108
|
try {
|
102
|
-
this.#onOutboxError?.(
|
109
|
+
this.#onOutboxError?.(error, activity);
|
103
110
|
}
|
104
|
-
catch (
|
105
|
-
|
111
|
+
catch (error) {
|
112
|
+
logger.error("An unexpected error occurred in onError handler:\n{error}", { ...logData, error, activityId: activity?.id?.href });
|
106
113
|
}
|
107
114
|
if (message.trial < this.#backoffSchedule.length) {
|
115
|
+
logger.error("Failed to send activity {activityId} to {inbox} (trial #{trial})" +
|
116
|
+
"; retry...:\n{error}", { ...logData, error, activityId: activity?.id?.href });
|
108
117
|
this.#queue?.enqueue({
|
109
118
|
...message,
|
110
119
|
trial: message.trial + 1,
|
111
120
|
}, { delay: this.#backoffSchedule[message.trial] });
|
112
121
|
}
|
122
|
+
else {
|
123
|
+
logger.error("Failed to send activity {activityId} to {inbox} after {trial} " +
|
124
|
+
"trials; giving up:\n{error}", { ...logData, error, activityId: activity?.id?.href });
|
125
|
+
}
|
126
|
+
return;
|
113
127
|
}
|
128
|
+
logger.info("Successfully sent activity {activityId} to {inbox}.", { ...logData, activityId: activity?.id?.href });
|
114
129
|
}
|
115
130
|
createContext(urlOrRequest, contextData) {
|
116
131
|
const request = urlOrRequest instanceof Request ? urlOrRequest : null;
|
@@ -547,7 +562,12 @@ export class Federation {
|
|
547
562
|
recipients: Array.isArray(recipients) ? recipients : [recipients],
|
548
563
|
preferSharedInbox,
|
549
564
|
});
|
550
|
-
logger.debug("Sending activity {activityId} to inboxes:\n{inboxes}", {
|
565
|
+
logger.debug("Sending activity {activityId} to inboxes:\n{inboxes}", {
|
566
|
+
inboxes: [...inboxes].map((u) => u.href),
|
567
|
+
activityId: activity.id?.href,
|
568
|
+
activity,
|
569
|
+
});
|
570
|
+
const documentLoader = this.#authenticatedDocumentLoaderFactory({ keyId, privateKey });
|
551
571
|
if (immediate || this.#queue == null) {
|
552
572
|
if (immediate) {
|
553
573
|
logger.debug("Sending activity immediately without queue since immediate option " +
|
@@ -556,7 +576,6 @@ export class Federation {
|
|
556
576
|
else {
|
557
577
|
logger.debug("Sending activity immediately without queue since queue is not set.", { activityId: activity.id?.href, activity });
|
558
578
|
}
|
559
|
-
const documentLoader = this.#authenticatedDocumentLoaderFactory({ keyId, privateKey });
|
560
579
|
const promises = [];
|
561
580
|
for (const inbox of inboxes) {
|
562
581
|
promises.push(sendActivity({
|
@@ -572,7 +591,7 @@ export class Federation {
|
|
572
591
|
}
|
573
592
|
logger.debug("Enqueuing activity {activityId} to send later.", { activityId: activity.id?.href, activity });
|
574
593
|
const privateKeyJwk = await exportJwk(privateKey);
|
575
|
-
const activityJson = await activity.toJsonLd({
|
594
|
+
const activityJson = await activity.toJsonLd({ documentLoader });
|
576
595
|
for (const inbox of inboxes) {
|
577
596
|
const message = {
|
578
597
|
type: "outbox",
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@fedify/fedify",
|
3
|
-
"version": "0.7.0-dev.
|
3
|
+
"version": "0.7.0-dev.131+e571d4c4",
|
4
4
|
"description": "An ActivityPub server framework",
|
5
5
|
"keywords": [
|
6
6
|
"ActivityPub",
|
@@ -77,7 +77,7 @@
|
|
77
77
|
},
|
78
78
|
"dependencies": {
|
79
79
|
"@js-temporal/polyfill": "^0.4.4",
|
80
|
-
"@logtape/logtape": "^0.2.
|
80
|
+
"@logtape/logtape": "^0.2.2",
|
81
81
|
"@phensley/language-tag": "^1.8.0",
|
82
82
|
"jsonld": "^8.3.2",
|
83
83
|
"uri-template-router": "^0.0.16",
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/federation/middleware.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAKjD,OAAO,EACL,KAAK,kCAAkC,EACvC,KAAK,cAAc,EAIpB,MAAM,yBAAyB,CA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AAkC,EAClC,UAAU,EACV,aAAa,EACb,eAAe,GAChB,EAAE,oBAAoB;
|
1
|
+
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/federation/middleware.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAKjD,OAAO,EACL,KAAK,kCAAkC,EACvC,KAAK,cAAc,EAIpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAoB,MAAM,iBAAiB,CAAC;AAE7D,OAAO,KAAK,EACV,eAAe,EACf,sBAAsB,EACtB,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,EACjB,aAAa,EACb,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EACV,OAAO,EACP,cAAc,EACd,mBAAmB,EACpB,MAAM,cAAc,CAAC;AAOtB,OAAO,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAK5C;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,EAAE,EAAE,OAAO,CAAC;IAEZ;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAE3C;;;;OAIG;IACH,KAAK,CAAC,EAAE,YAAY,CAAC;IAErB;;;OAGG;IACH,cAAc,CAAC,EAAE,cAAc,CAAC;IAEhC;;;;;;OAMG;IACH,kCAAkC,CAAC,EAAE,kCAAkC,CAAC;IAExE;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;;;;;;;;OASG;IACH,aAAa,CAAC,EAAE,kBAAkB,CAAC;IAIn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