@fedify/fedify 0.6.0-dev.112 → 0.6.0

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
@@ -6,7 +6,7 @@ Fedify changelog
6
6
  Version 0.6.0
7
7
  -------------
8
8
 
9
- To be released.
9
+ Released on April 9, 2024.
10
10
 
11
11
  - `DocumentLoader` is now propagated to the loaded remote objects from
12
12
  Activity Vocabulary objects. [[#27]]
@@ -34,6 +34,9 @@ To be released.
34
34
  - `Context.sendActivity()` method now throws `TypeError` instead of silently
35
35
  failing when the given `Activity` object lacks the actor property.
36
36
 
37
+ - `Context.sendActivity()` method now uses an authenticated document
38
+ loader under the hood.
39
+
37
40
  - Added outbox error handler to `Federation`.
38
41
 
39
42
  - Added `onOutboxError` option to `new Federation()` constructor.
package/README.md CHANGED
@@ -51,7 +51,7 @@ join our [Matrix chat space][Matrix] or [GitHub Discussions].
51
51
  [Mastodon], [Lemmy], [Pixelfed], [PeerTube], and so on.
52
52
 
53
53
  [JSR]: https://jsr.io/@fedify/fedify
54
- [JSR badge]: https://jsr.io/badges/@fedify/fedify?_v=0.5.1
54
+ [JSR badge]: https://jsr.io/badges/@fedify/fedify?v=0.6.0
55
55
  [npm]: https://www.npmjs.com/package/@fedify/fedify
56
56
  [npm badge]: https://img.shields.io/npm/v/@fedify/fedify?logo=npm
57
57
  [GitHub Actions]: https://github.com/dahlia/fedify/actions/workflows/build.yaml
@@ -72,15 +72,18 @@ export class Federation {
72
72
  async #listenQueue(message) {
73
73
  let activity = null;
74
74
  try {
75
+ const keyId = new URL(message.keyId);
76
+ const privateKey = await importJwk(message.privateKey, "private");
77
+ const documentLoader = this.#authenticatedDocumentLoaderFactory({ keyId, privateKey });
75
78
  activity = await Activity.fromJsonLd(message.activity, {
76
- documentLoader: this.#documentLoader,
79
+ documentLoader,
77
80
  });
78
81
  await sendActivity({
79
- keyId: new URL(message.keyId),
80
- privateKey: await importJwk(message.privateKey, "private"),
82
+ keyId,
83
+ privateKey,
81
84
  activity,
82
85
  inbox: new URL(message.inbox),
83
- documentLoader: this.#documentLoader,
86
+ documentLoader,
84
87
  });
85
88
  }
86
89
  catch (e) {
@@ -500,6 +503,7 @@ export class Federation {
500
503
  preferSharedInbox,
501
504
  });
502
505
  if (immediate || this.#queue == null) {
506
+ const documentLoader = this.#authenticatedDocumentLoaderFactory({ keyId, privateKey });
503
507
  const promises = [];
504
508
  for (const inbox of inboxes) {
505
509
  promises.push(sendActivity({
@@ -507,7 +511,7 @@ export class Federation {
507
511
  privateKey,
508
512
  activity,
509
513
  inbox,
510
- documentLoader: this.#documentLoader,
514
+ documentLoader,
511
515
  }));
512
516
  }
513
517
  await Promise.all(promises);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/fedify",
3
- "version": "0.6.0-dev.112+5540b5ce",
3
+ "version": "0.6.0",
4
4
  "description": "An ActivityPub server framework",
5
5
  "keywords": [
6
6
  "ActivityPub",
@@ -49,8 +49,9 @@ export interface FederationParameters {
49
49
  treatHttps?: boolean;
50
50
  /**
51
51
  * A callback that handles errors during outbox processing. Note that this
52
- * callback can be called multiple times for the same error, because failed
53
- * deliveries are retried.
52
+ * callback can be called multiple times for the same activity, because
53
+ * the delivery is retried according to the backoff schedule until it
54
+ * succeeds or reaches the maximum retry count.
54
55
  *
55
56
  * If any errors are thrown in this callback, they are ignored.
56
57
  *
@@ -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;AAGjD,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,EAA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