fedipod-server 0.14.1 → 0.16.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.
@@ -141,6 +141,13 @@ function apUrls(remotePod, root, { publicBase = null } = {}) {
141
141
  }
142
142
  return urls;
143
143
  }
144
+ function podBaseOfWebId(webId) {
145
+ const u = new URL(webId);
146
+ u.hash = "";
147
+ u.search = "";
148
+ const dir = u.pathname.replace(/profile\/card$/u, "").replace(/[^/]*$/u, "");
149
+ return `${u.origin}${dir.endsWith("/") ? dir : dir + "/"}`;
150
+ }
144
151
  function webfingerHost(podUrl) {
145
152
  const u = new URL(podUrl);
146
153
  return u.pathname === "/" ? u.host : null;
@@ -9651,9 +9658,10 @@ function hostMeta(base) {
9651
9658
  </XRD>
9652
9659
  `;
9653
9660
  }
9654
- function jrd({ handle: handle7, host, actor }) {
9661
+ function jrd({ handle: handle7, host, actor, aliases = [] }) {
9655
9662
  return {
9656
9663
  subject: `acct:${handle7}@${host}`,
9664
+ ...aliases.length ? { aliases } : {},
9657
9665
  links: [{ rel: "self", type: "application/activity+json", href: actor }]
9658
9666
  };
9659
9667
  }
@@ -56499,7 +56507,7 @@ var Publisher = class {
56499
56507
  }
56500
56508
  const pubName = publicHandle(this.config);
56501
56509
  const pubHost = this.config.gateway?.frontActor ? new URL(this.config.gateway.frontActor).host : host;
56502
- this.log(this.config.gateway?.frontActor || webfingerHost(urls.base) ? `profile published: @${pubName}@${pubHost} \u2192 ${urls.actor}` : `profile published \u2192 ${urls.actor} \u2014 NOT discoverable as @${pubName}@${pubHost}: this pod is a path on a shared host, and WebFinger is only answered at a host root`);
56510
+ this.log(this.config.gateway?.frontActor || webfingerHost(urls.base) ? `profile published: @${pubName}@${pubHost} \u2192 ${urls.actor}` : `profile published \u2192 ${urls.actor} \u2014 NOT discoverable as @${pubName}@${pubHost}: this pod is a suffix-based host, and WebFinger is only answered at a host root`);
56503
56511
  return { unreachable, updated };
56504
56512
  }
56505
56513
  // Fires when the document differs from the one last published — including
@@ -66231,8 +66239,11 @@ var MastoApi = class _MastoApi {
66231
66239
  });
66232
66240
  return this._push;
66233
66241
  }
66242
+ // The host in the owner's own address: the gateway's when the identity is
66243
+ // fronted (its documents still live on the pod, but its name does not).
66234
66244
  get host() {
66235
- return this.urls ? new URL(this.urls.base).host : "unconfigured.invalid";
66245
+ if (!this.urls) return "unconfigured.invalid";
66246
+ return new URL(this.urls.publicHome || this.urls.base).host;
66236
66247
  }
66237
66248
  // Where the live feed is, as the CLIENT must address it: this agent's own
66238
66249
  // origin, taken from the request, not the pod's host. An instance document
@@ -66846,9 +66857,10 @@ var PodTransport = class {
66846
66857
  return serialize(doc, g, url, "text/turtle");
66847
66858
  }
66848
66859
  async setAcl(targetUrl, publicModes, opts = {}) {
66849
- const url = await this.aclUrlFor(targetUrl);
66860
+ const podTarget = this.toPod ? this.toPod(targetUrl) : targetUrl;
66861
+ const url = await this.aclUrlFor(podTarget);
66850
66862
  if (!await this.aclWritable(url)) return null;
66851
- return this.put(url, this.aclDoc(targetUrl, publicModes, { ...opts, aclUrl: url }), "text/turtle");
66863
+ return this.put(url, this.aclDoc(podTarget, publicModes, { ...opts, aclUrl: url }), "text/turtle");
66852
66864
  }
66853
66865
  // Child documents of an LDP container (URLs under it, excluding aux docs).
66854
66866
  // Revalidated: the inbox is polled every couple of minutes and is usually
@@ -67166,14 +67178,16 @@ async function cacheOpenedKeys(actorUrl, keysRecord) {
67166
67178
  return keys;
67167
67179
  }
67168
67180
  var keyCacheKey = (actorUrl) => `signing-keys:${actorUrl}`;
67181
+ var podActorOf = (urls) => urls.toPod ? urls.toPod(urls.actor) : urls.actor;
67169
67182
  async function loadKeysFromPod(remote, urls) {
67170
- const cached = await kvGet(keyCacheKey(urls.actor)).catch(() => null);
67183
+ const podActor = podActorOf(urls);
67184
+ const cached = await kvGet(keyCacheKey(podActor)).catch(() => null);
67171
67185
  if (isOpenedKey(cached)) return fromCache(cached);
67172
- if (cached?.rsa?.privatePem) return cacheOpenedKeys(urls.actor, cached);
67186
+ if (cached?.rsa?.privatePem) return cacheOpenedKeys(podActor, cached);
67173
67187
  const doc = await readWrappedKeys(remote, urls);
67174
67188
  if (isKeyEnvelope(doc)) throw new KeyPasswordNeeded();
67175
67189
  if (!doc || !doc.rsa) throw new Error("no signing key on the pod \u2014 sign up did not finish");
67176
- return cacheOpenedKeys(urls.actor, doc);
67190
+ return cacheOpenedKeys(podActor, doc);
67177
67191
  }
67178
67192
 
67179
67193
  // lib/core/deliver.mjs
@@ -68259,7 +68273,7 @@ var AdminFacade = class {
68259
68273
  const aliases = [...cfg.aliases || []];
68260
68274
  if (body.add) {
68261
68275
  if (!webfingerHost(urls.base) && !cfg.gateway?.frontActor) {
68262
- return json2(400, { error: "this pod is a path on a shared host, so other servers could never resolve it as a Move target" });
68276
+ return json2(400, { error: "this pod is a suffix-based host, so other servers could never resolve it as a Move target" });
68263
68277
  }
68264
68278
  const id = await this.resolveActor(body.add);
68265
68279
  if (!id) return json2(400, { error: `could not fetch the old account (${body.add}) \u2014 enter its URL or @user@host, and it must answer` });
@@ -69602,6 +69616,7 @@ var AcctFeed = class {
69602
69616
  };
69603
69617
 
69604
69618
  // web/app/agent.mjs
69619
+ init_urls();
69605
69620
  var originAuthorities = (host) => ({
69606
69621
  set: /* @__PURE__ */ new Set([String(host || "").toLowerCase()]),
69607
69622
  has(authority) {
@@ -69726,7 +69741,7 @@ var BrowserAgent = class _BrowserAgent {
69726
69741
  if (oidc) {
69727
69742
  session = { fetch: (u, i) => oidc.fetch(u, i) };
69728
69743
  webId = oidc.webId;
69729
- remotePod = new URL(webId).origin + "/";
69744
+ remotePod = podBaseOfWebId(webId);
69730
69745
  } else {
69731
69746
  const dpop = await makeDpopSession(credential);
69732
69747
  session = { fetch: (u, i) => dpop.fetch(u, i) };
@@ -69744,8 +69759,11 @@ var BrowserAgent = class _BrowserAgent {
69744
69759
  const cfg = config || this.store.getConfig();
69745
69760
  if (!cfg) throw new Error("no account config on this pod \u2014 sign up first");
69746
69761
  this.store.setConfig({ ...this.store.getConfig() || {}, ...cfg, root });
69747
- const keys = keysRecord ? await importSigningKey(keysRecord) : await loadKeysFromPod(this.remote, this.urls);
69748
69762
  config = this.store.getConfig();
69763
+ const publicBase = config.gateway?.frontActor ? config.gateway.frontActor.replace(/ap\/actor\/?$/, "") : null;
69764
+ this.urls = apUrls2(remotePod, root, { publicBase });
69765
+ if (this.urls.toPod) this.remote.setUrlMap(this.urls.toPod);
69766
+ const keys = keysRecord ? await importSigningKey(keysRecord) : await loadKeysFromPod(this.remote, this.urls);
69749
69767
  this.deliverer = new RelayDeliverer({
69750
69768
  passive: true,
69751
69769
  store: this.store,
@@ -69767,7 +69785,7 @@ var BrowserAgent = class _BrowserAgent {
69767
69785
  publicKeyPem: keys.rsaPublicPem,
69768
69786
  assertionKey: null,
69769
69787
  log: this.log,
69770
- // Who a post names, resolved — the same lookup the installed agent
69788
+ // Who a post names, resolved — the same lookup the DeviceAgent
69771
69789
  // gives its publisher. Without it no mention from the browser ever
69772
69790
  // resolved: a direct message went to nobody, a mention notified no one.
69773
69791
  resolveMention: (h) => resolveHandle(this, h)
@@ -69870,7 +69888,7 @@ var BrowserAgent = class _BrowserAgent {
69870
69888
  const rec = await generateKeys();
69871
69889
  rec.mintedFor = this.urls.actor;
69872
69890
  await writeWrappedKeys(this.remote, this.urls, await wrapKeys(rec, password));
69873
- const keys = await cacheOpenedKeys(this.urls.actor, rec);
69891
+ const keys = await cacheOpenedKeys(podActorOf(this.urls), rec);
69874
69892
  this.publisher.publicKeyPem = keys.rsaPublicPem;
69875
69893
  this.deliverer.rsaPrivate = keys.rsaPrivate;
69876
69894
  await this.publisher.publishProfile();