fedipod 1.6.0 → 1.7.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.
@@ -33208,6 +33208,47 @@ async function provisionKey(pod, { stateUrl, keysUrl, envelope }) {
33208
33208
  await pod.putJson(keysUrl, envelope, "application/json");
33209
33209
  }
33210
33210
 
33211
+ // lib/pod/root.mjs
33212
+ var OWNER_LOOKUP_MS = 5e3;
33213
+ var PUBLIC_DOC_MAX_BYTES = 1024 * 1024;
33214
+ async function podLayout(fetchImpl, providerOrigin, { timeoutMs = OWNER_LOOKUP_MS } = {}) {
33215
+ let origin;
33216
+ try {
33217
+ origin = new URL(providerOrigin).origin;
33218
+ } catch {
33219
+ return null;
33220
+ }
33221
+ let res;
33222
+ try {
33223
+ res = await fetchImpl(
33224
+ `${origin}/.well-known/solid`,
33225
+ { headers: { accept: "text/turtle" }, signal: AbortSignal.timeout(timeoutMs) }
33226
+ );
33227
+ } catch {
33228
+ return null;
33229
+ }
33230
+ if (res.status === 501) return "host";
33231
+ if (res.status !== 200) return null;
33232
+ let body = "";
33233
+ try {
33234
+ body = await readCapped(res, 64 * 1024);
33235
+ } catch {
33236
+ return null;
33237
+ }
33238
+ return /ns\/pim\/space#Storage|pim:Storage/u.test(body) ? "path" : null;
33239
+ }
33240
+ async function resourceExists(fetchImpl, url, { timeoutMs = OWNER_LOOKUP_MS } = {}) {
33241
+ try {
33242
+ const res = await fetchImpl(
33243
+ url,
33244
+ { headers: { accept: "application/activity+json" }, signal: AbortSignal.timeout(timeoutMs) }
33245
+ );
33246
+ return !!res && res.status === 200;
33247
+ } catch {
33248
+ return false;
33249
+ }
33250
+ }
33251
+
33211
33252
  // web/app/idb-kv.mjs
33212
33253
  var DB = "fedipod-accounts";
33213
33254
  function open() {
@@ -33310,6 +33351,7 @@ async function signUp(answers, { onStep = () => {
33310
33351
  acct.running("checking your pod");
33311
33352
  const head = await fetch(brought, { method: "HEAD" }).catch(() => null);
33312
33353
  if (!head || head.status >= 400) throw new Error(`the pod at ${brought} did not answer (HTTP ${head?.status || "no response"})`);
33354
+ if (await resourceExists(fetch, actorUrlFor(brought))) throw new Error("The pod already hosts a FediPod account. If you want a second account, put it on a different pod.");
33313
33355
  prog.pod = brought;
33314
33356
  acct.skip("using the pod you brought");
33315
33357
  }
@@ -33450,36 +33492,6 @@ function podBaseOfWebId(webId) {
33450
33492
  return `${u.origin}${dir.endsWith("/") ? dir : dir + "/"}`;
33451
33493
  }
33452
33494
 
33453
- // lib/pod/root.mjs
33454
- var OWNER_LOOKUP_MS = 5e3;
33455
- var PUBLIC_DOC_MAX_BYTES = 1024 * 1024;
33456
- async function podLayout(fetchImpl, providerOrigin, { timeoutMs = OWNER_LOOKUP_MS } = {}) {
33457
- let origin;
33458
- try {
33459
- origin = new URL(providerOrigin).origin;
33460
- } catch {
33461
- return null;
33462
- }
33463
- let res;
33464
- try {
33465
- res = await fetchImpl(
33466
- `${origin}/.well-known/solid`,
33467
- { headers: { accept: "text/turtle" }, signal: AbortSignal.timeout(timeoutMs) }
33468
- );
33469
- } catch {
33470
- return null;
33471
- }
33472
- if (res.status === 501) return "host";
33473
- if (res.status !== 200) return null;
33474
- let body = "";
33475
- try {
33476
- body = await readCapped(res, 64 * 1024);
33477
- } catch {
33478
- return null;
33479
- }
33480
- return /ns\/pim\/space#Storage|pim:Storage/u.test(body) ? "path" : null;
33481
- }
33482
-
33483
33495
  // web/app/oidc-session.mjs
33484
33496
  var DB2 = "fedipod-oidc";
33485
33497
  var STORE = "session";