@fedify/relay 2.0.0-dev.150 → 2.0.0-dev.159

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/mod.cjs CHANGED
@@ -25,7 +25,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
25
25
 
26
26
  //#endregion
27
27
  const __fedify_fedify = __toESM(require("@fedify/fedify"));
28
- const __fedify_fedify_vocab = __toESM(require("@fedify/fedify/vocab"));
28
+ const __fedify_vocab = __toESM(require("@fedify/vocab"));
29
29
  const __logtape_logtape = __toESM(require("@logtape/logtape"));
30
30
 
31
31
  //#region src/types.ts
@@ -50,7 +50,7 @@ const relayBuilder = (0, __fedify_fedify.createFederationBuilder)();
50
50
  relayBuilder.setActorDispatcher("/users/{identifier}", async (ctx, identifier) => {
51
51
  if (identifier !== RELAY_SERVER_ACTOR) return null;
52
52
  const keys = await ctx.getActorKeyPairs(identifier);
53
- return new __fedify_fedify_vocab.Application({
53
+ return new __fedify_vocab.Application({
54
54
  id: ctx.getActorUri(identifier),
55
55
  preferredUsername: identifier,
56
56
  name: ctx.data.name ?? "ActivityPub Relay",
@@ -109,8 +109,8 @@ async function getFollowerActors(ctx) {
109
109
  for await (const { value } of ctx.data.kv.list(["follower"])) {
110
110
  if (!isRelayFollowerData(value)) continue;
111
111
  if (value.state !== "accepted") continue;
112
- const actor = await __fedify_fedify_vocab.Object.fromJsonLd(value.actor);
113
- if (!(0, __fedify_fedify_vocab.isActor)(actor)) continue;
112
+ const actor = await __fedify_vocab.Object.fromJsonLd(value.actor);
113
+ if (!(0, __fedify_vocab.isActor)(actor)) continue;
114
114
  actors.push(actor);
115
115
  }
116
116
  return actors;
@@ -153,8 +153,8 @@ var BaseRelay = class {
153
153
  */
154
154
  async parseFollowerData(actorId, data) {
155
155
  if (!isRelayFollowerData(data)) return null;
156
- const actor = await __fedify_fedify_vocab.Object.fromJsonLd(data.actor);
157
- if (!(0, __fedify_fedify_vocab.isActor)(actor)) return null;
156
+ const actor = await __fedify_vocab.Object.fromJsonLd(data.actor);
157
+ if (!(0, __fedify_vocab.isActor)(actor)) return null;
158
158
  return {
159
159
  actorId,
160
160
  actor,
@@ -277,7 +277,7 @@ async function validateFollowActivity(ctx, follow) {
277
277
  */
278
278
  async function sendFollowResponse(ctx, follow, follower, approved) {
279
279
  const relayActorUri = ctx.getActorUri(RELAY_SERVER_ACTOR);
280
- const Activity = approved ? __fedify_fedify.Accept : __fedify_fedify.Reject;
280
+ const Activity = approved ? __fedify_vocab.Accept : __fedify_vocab.Reject;
281
281
  const action = approved ? "accepts" : "rejects";
282
282
  await ctx.sendActivity({ identifier: RELAY_SERVER_ACTOR }, follower, new Activity({
283
283
  id: new URL(`#${action}`, relayActorUri),
@@ -298,7 +298,7 @@ async function handleUndoFollow(ctx, undo, logger$2) {
298
298
  crossOrigin: "trust",
299
299
  ...ctx
300
300
  });
301
- if (activity instanceof __fedify_fedify.Follow) {
301
+ if (activity instanceof __fedify_vocab.Follow) {
302
302
  if (activity.id == null || activity.actorId == null) return;
303
303
  await ctx.data.kv.delete(["follower", activity.actorId.href]);
304
304
  } else logger$2.warn("Unsupported object type ({type}) for Undo activity: {object}", {
@@ -325,11 +325,11 @@ var LitePubRelay = class extends BaseRelay {
325
325
  async #announceToFollowers(ctx, activity) {
326
326
  const sender = await activity.getActor(ctx);
327
327
  const excludeBaseUris = sender?.id ? [new URL(sender.id)] : [];
328
- const announce = new __fedify_fedify.Announce({
328
+ const announce = new __fedify_vocab.Announce({
329
329
  id: new URL(`/announce#${crypto.randomUUID()}`, ctx.origin),
330
330
  actor: ctx.getActorUri(RELAY_SERVER_ACTOR),
331
331
  object: activity.objectId,
332
- to: __fedify_fedify.PUBLIC_COLLECTION,
332
+ to: __fedify_vocab.PUBLIC_COLLECTION,
333
333
  published: Temporal.Now.instant()
334
334
  });
335
335
  await ctx.sendActivity({ identifier: RELAY_SERVER_ACTOR }, "followers", announce, {
@@ -338,7 +338,7 @@ var LitePubRelay = class extends BaseRelay {
338
338
  });
339
339
  }
340
340
  setupInboxListeners() {
341
- if (this.federation != null) this.federation.setInboxListeners("/users/{identifier}/inbox", "/inbox").on(__fedify_fedify.Follow, async (ctx, follow) => {
341
+ if (this.federation != null) this.federation.setInboxListeners("/users/{identifier}/inbox", "/inbox").on(__fedify_vocab.Follow, async (ctx, follow) => {
342
342
  const follower = await validateFollowActivity(ctx, follow);
343
343
  if (!follower || !follower.id) return;
344
344
  const existingFollow = await ctx.data.kv.get(["follower", follower.id.href]);
@@ -351,22 +351,22 @@ var LitePubRelay = class extends BaseRelay {
351
351
  });
352
352
  await sendFollowResponse(ctx, follow, follower, approved);
353
353
  const relayActorUri = ctx.getActorUri(RELAY_SERVER_ACTOR);
354
- await ctx.sendActivity({ identifier: RELAY_SERVER_ACTOR }, follower, new __fedify_fedify.Follow({
354
+ await ctx.sendActivity({ identifier: RELAY_SERVER_ACTOR }, follower, new __fedify_vocab.Follow({
355
355
  actor: relayActorUri,
356
356
  object: follower.id,
357
357
  to: follower.id
358
358
  }));
359
359
  } else await sendFollowResponse(ctx, follow, follower, approved);
360
- }).on(__fedify_fedify.Accept, async (ctx, accept) => {
360
+ }).on(__fedify_vocab.Accept, async (ctx, accept) => {
361
361
  const follow = await accept.getObject({
362
362
  crossOrigin: "trust",
363
363
  ...ctx
364
364
  });
365
- if (!(follow instanceof __fedify_fedify.Follow)) return;
365
+ if (!(follow instanceof __fedify_vocab.Follow)) return;
366
366
  const relayActorId = follow.actorId;
367
367
  if (relayActorId == null) return;
368
368
  const followerActor = await accept.getActor();
369
- if (!(0, __fedify_fedify.isActor)(followerActor) || !followerActor.id) return;
369
+ if (!(0, __fedify_vocab.isActor)(followerActor) || !followerActor.id) return;
370
370
  const parsed = ctx.parseUri(relayActorId);
371
371
  if (parsed == null || parsed.type !== "actor") return;
372
372
  const followerData = await ctx.data.kv.get(["follower", followerActor.id.href]);
@@ -376,7 +376,7 @@ var LitePubRelay = class extends BaseRelay {
376
376
  state: "accepted"
377
377
  };
378
378
  await ctx.data.kv.set(["follower", followerActor.id.href], updatedFollowerData);
379
- }).on(__fedify_fedify.Undo, async (ctx, undo) => await handleUndoFollow(ctx, undo, logger$1)).on(__fedify_fedify.Create, async (ctx, create) => await this.#announceToFollowers(ctx, create)).on(__fedify_fedify.Update, async (ctx, update) => await this.#announceToFollowers(ctx, update)).on(__fedify_fedify.Move, async (ctx, move) => await this.#announceToFollowers(ctx, move)).on(__fedify_fedify.Delete, async (ctx, deleteActivity) => await this.#announceToFollowers(ctx, deleteActivity)).on(__fedify_fedify.Announce, async (ctx, announce) => await this.#announceToFollowers(ctx, announce));
379
+ }).on(__fedify_vocab.Undo, async (ctx, undo) => await handleUndoFollow(ctx, undo, logger$1)).on(__fedify_vocab.Create, async (ctx, create) => await this.#announceToFollowers(ctx, create)).on(__fedify_vocab.Update, async (ctx, update) => await this.#announceToFollowers(ctx, update)).on(__fedify_vocab.Move, async (ctx, move) => await this.#announceToFollowers(ctx, move)).on(__fedify_vocab.Delete, async (ctx, deleteActivity) => await this.#announceToFollowers(ctx, deleteActivity)).on(__fedify_vocab.Announce, async (ctx, announce) => await this.#announceToFollowers(ctx, announce));
380
380
  }
381
381
  };
382
382
 
@@ -405,7 +405,7 @@ var MastodonRelay = class extends BaseRelay {
405
405
  });
406
406
  }
407
407
  setupInboxListeners() {
408
- if (this.federation != null) this.federation.setInboxListeners("/users/{identifier}/inbox", "/inbox").on(__fedify_fedify.Follow, async (ctx, follow) => {
408
+ if (this.federation != null) this.federation.setInboxListeners("/users/{identifier}/inbox", "/inbox").on(__fedify_vocab.Follow, async (ctx, follow) => {
409
409
  const follower = await validateFollowActivity(ctx, follow);
410
410
  if (!follower || !follower.id) return;
411
411
  const approved = await this.options.subscriptionHandler(ctx, follower);
@@ -414,7 +414,7 @@ var MastodonRelay = class extends BaseRelay {
414
414
  state: "accepted"
415
415
  });
416
416
  await sendFollowResponse(ctx, follow, follower, approved);
417
- }).on(__fedify_fedify.Undo, async (ctx, undo) => await handleUndoFollow(ctx, undo, logger)).on(__fedify_fedify.Create, async (ctx, create) => await this.#forwardToFollowers(ctx, create)).on(__fedify_fedify.Delete, async (ctx, deleteActivity) => await this.#forwardToFollowers(ctx, deleteActivity)).on(__fedify_fedify.Move, async (ctx, move) => await this.#forwardToFollowers(ctx, move)).on(__fedify_fedify.Update, async (ctx, update) => await this.#forwardToFollowers(ctx, update)).on(__fedify_fedify.Announce, async (ctx, announce) => await this.#forwardToFollowers(ctx, announce));
417
+ }).on(__fedify_vocab.Undo, async (ctx, undo) => await handleUndoFollow(ctx, undo, logger)).on(__fedify_vocab.Create, async (ctx, create) => await this.#forwardToFollowers(ctx, create)).on(__fedify_vocab.Delete, async (ctx, deleteActivity) => await this.#forwardToFollowers(ctx, deleteActivity)).on(__fedify_vocab.Move, async (ctx, move) => await this.#forwardToFollowers(ctx, move)).on(__fedify_vocab.Update, async (ctx, update) => await this.#forwardToFollowers(ctx, update)).on(__fedify_vocab.Announce, async (ctx, announce) => await this.#forwardToFollowers(ctx, announce));
418
418
  }
419
419
  };
420
420
 
package/dist/mod.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Context, KvStore, MessageQueue } from "@fedify/fedify";
2
- import { Actor } from "@fedify/fedify/vocab";
2
+ import { Actor } from "@fedify/vocab";
3
3
  import { AuthenticatedDocumentLoaderFactory, DocumentLoaderFactory } from "@fedify/vocab-runtime";
4
4
 
5
5
  //#region src/types.d.ts
package/dist/mod.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import { Context, KvStore, MessageQueue } from "@fedify/fedify";
3
- import { Actor } from "@fedify/fedify/vocab";
3
+ import { Actor } from "@fedify/vocab";
4
4
  import { AuthenticatedDocumentLoaderFactory, DocumentLoaderFactory } from "@fedify/vocab-runtime";
5
5
 
6
6
  //#region src/types.d.ts
package/dist/mod.js CHANGED
@@ -1,8 +1,8 @@
1
1
 
2
2
  import { Temporal } from "@js-temporal/polyfill";
3
3
 
4
- import { Accept, Announce, Create, Delete, Follow, Move, PUBLIC_COLLECTION, Reject, Undo, Update, createFederationBuilder, exportJwk, generateCryptoKeyPair, importJwk, isActor } from "@fedify/fedify";
5
- import { Application, Object as Object$1, isActor as isActor$1 } from "@fedify/fedify/vocab";
4
+ import { createFederationBuilder, exportJwk, generateCryptoKeyPair, importJwk } from "@fedify/fedify";
5
+ import { Accept, Announce, Application, Create, Delete, Follow, Move, Object as Object$1, PUBLIC_COLLECTION, Reject, Undo, Update, isActor } from "@fedify/vocab";
6
6
  import { getLogger } from "@logtape/logtape";
7
7
 
8
8
  //#region src/types.ts
@@ -87,7 +87,7 @@ async function getFollowerActors(ctx) {
87
87
  if (!isRelayFollowerData(value)) continue;
88
88
  if (value.state !== "accepted") continue;
89
89
  const actor = await Object$1.fromJsonLd(value.actor);
90
- if (!isActor$1(actor)) continue;
90
+ if (!isActor(actor)) continue;
91
91
  actors.push(actor);
92
92
  }
93
93
  return actors;
@@ -131,7 +131,7 @@ var BaseRelay = class {
131
131
  async parseFollowerData(actorId, data) {
132
132
  if (!isRelayFollowerData(data)) return null;
133
133
  const actor = await Object$1.fromJsonLd(data.actor);
134
- if (!isActor$1(actor)) return null;
134
+ if (!isActor(actor)) return null;
135
135
  return {
136
136
  actorId,
137
137
  actor,