fedipod-server 0.12.1 → 0.13.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.
- package/README.md +7 -0
- package/dist/claims.d.ts +8 -0
- package/dist/claims.js +10 -0
- package/dist/handler.d.ts +7 -0
- package/dist/handler.js +33 -1
- package/dist/handler.jsonld +4 -0
- package/lib/client/c2s.mjs +6 -4
- package/lib/core/as2.mjs +64 -18
- package/lib/core/graphview.mjs +269 -0
- package/lib/core/intake/index.mjs +4 -4
- package/lib/core/intake/verify.mjs +4 -3
- package/lib/core/publisher/restore.mjs +7 -4
- package/lib/server/embed.mjs +59 -1
- package/package.json +1 -1
- package/web/app/agent.mjs +2 -4
- package/web/app/boot.mjs +2 -3
- package/web/app/dist/boot.js +22 -3
- package/web/app/dist/boot.js.map +2 -2
- package/web/app/dist/sw.js +240 -42
- package/web/app/dist/sw.js.map +4 -4
- package/web/app/keys-browser.mjs +27 -4
- package/web/app/signup.mjs +2 -3
- package/web/app/site/boot.js +22 -3
- package/web/app/site/sw.js +240 -42
package/web/app/dist/sw.js
CHANGED
|
@@ -27444,10 +27444,10 @@ var require_fromRdf = __commonJS({
|
|
|
27444
27444
|
var {
|
|
27445
27445
|
// RDF,
|
|
27446
27446
|
RDF_LIST,
|
|
27447
|
-
RDF_FIRST,
|
|
27448
|
-
RDF_REST,
|
|
27449
|
-
RDF_NIL,
|
|
27450
|
-
RDF_TYPE,
|
|
27447
|
+
RDF_FIRST: RDF_FIRST2,
|
|
27448
|
+
RDF_REST: RDF_REST2,
|
|
27449
|
+
RDF_NIL: RDF_NIL2,
|
|
27450
|
+
RDF_TYPE: RDF_TYPE2,
|
|
27451
27451
|
// RDF_PLAIN_LITERAL,
|
|
27452
27452
|
// RDF_XML_LITERAL,
|
|
27453
27453
|
RDF_JSON_LITERAL,
|
|
@@ -27506,14 +27506,14 @@ var require_fromRdf = __commonJS({
|
|
|
27506
27506
|
if (objectIsNode && !(objectNodeId in nodeMap)) {
|
|
27507
27507
|
nodeMap[objectNodeId] = { "@id": objectNodeId };
|
|
27508
27508
|
}
|
|
27509
|
-
if (p ===
|
|
27509
|
+
if (p === RDF_TYPE2 && !useRdfType && objectIsNode) {
|
|
27510
27510
|
_addValue(node, "@type", objectNodeId, { propertyIsArray: true });
|
|
27511
27511
|
continue;
|
|
27512
27512
|
}
|
|
27513
27513
|
const value = _RDFToObject(o, useNativeTypes, rdfDirection, options);
|
|
27514
27514
|
_addValue(node, p, value, { propertyIsArray: true });
|
|
27515
27515
|
if (objectIsNode) {
|
|
27516
|
-
if (objectNodeId ===
|
|
27516
|
+
if (objectNodeId === RDF_NIL2) {
|
|
27517
27517
|
const object = nodeMap[objectNodeId];
|
|
27518
27518
|
if (!("usages" in object)) {
|
|
27519
27519
|
object.usages = [];
|
|
@@ -27536,10 +27536,10 @@ var require_fromRdf = __commonJS({
|
|
|
27536
27536
|
}
|
|
27537
27537
|
for (const name in graphMap) {
|
|
27538
27538
|
const graphObject = graphMap[name];
|
|
27539
|
-
if (!(
|
|
27539
|
+
if (!(RDF_NIL2 in graphObject)) {
|
|
27540
27540
|
continue;
|
|
27541
27541
|
}
|
|
27542
|
-
const nil = graphObject[
|
|
27542
|
+
const nil = graphObject[RDF_NIL2];
|
|
27543
27543
|
if (!nil.usages) {
|
|
27544
27544
|
continue;
|
|
27545
27545
|
}
|
|
@@ -27550,8 +27550,8 @@ var require_fromRdf = __commonJS({
|
|
|
27550
27550
|
const list3 = [];
|
|
27551
27551
|
const listNodes = [];
|
|
27552
27552
|
let nodeKeyCount = Object.keys(node).length;
|
|
27553
|
-
while (property ===
|
|
27554
|
-
list3.push(node[
|
|
27553
|
+
while (property === RDF_REST2 && types.isObject(referencedOnce[node["@id"]]) && types.isArray(node[RDF_FIRST2]) && node[RDF_FIRST2].length === 1 && types.isArray(node[RDF_REST2]) && node[RDF_REST2].length === 1 && (nodeKeyCount === 3 || nodeKeyCount === 4 && types.isArray(node["@type"]) && node["@type"].length === 1 && node["@type"][0] === RDF_LIST)) {
|
|
27554
|
+
list3.push(node[RDF_FIRST2][0]);
|
|
27555
27555
|
listNodes.push(node["@id"]);
|
|
27556
27556
|
usage = referencedOnce[node["@id"]];
|
|
27557
27557
|
node = usage.node;
|
|
@@ -27752,10 +27752,10 @@ var require_toRdf = __commonJS({
|
|
|
27752
27752
|
var {
|
|
27753
27753
|
// RDF,
|
|
27754
27754
|
// RDF_LIST,
|
|
27755
|
-
RDF_FIRST,
|
|
27756
|
-
RDF_REST,
|
|
27757
|
-
RDF_NIL,
|
|
27758
|
-
RDF_TYPE,
|
|
27755
|
+
RDF_FIRST: RDF_FIRST2,
|
|
27756
|
+
RDF_REST: RDF_REST2,
|
|
27757
|
+
RDF_NIL: RDF_NIL2,
|
|
27758
|
+
RDF_TYPE: RDF_TYPE2,
|
|
27759
27759
|
// RDF_PLAIN_LITERAL,
|
|
27760
27760
|
// RDF_XML_LITERAL,
|
|
27761
27761
|
RDF_JSON_LITERAL,
|
|
@@ -27813,7 +27813,7 @@ var require_toRdf = __commonJS({
|
|
|
27813
27813
|
for (let property of properties) {
|
|
27814
27814
|
const items = node[property];
|
|
27815
27815
|
if (property === "@type") {
|
|
27816
|
-
property =
|
|
27816
|
+
property = RDF_TYPE2;
|
|
27817
27817
|
} else if (isKeyword(property)) {
|
|
27818
27818
|
continue;
|
|
27819
27819
|
}
|
|
@@ -27893,9 +27893,9 @@ var require_toRdf = __commonJS({
|
|
|
27893
27893
|
}
|
|
27894
27894
|
}
|
|
27895
27895
|
function _listToRDF(list3, issuer, dataset2, graphTerm, rdfDirection, options) {
|
|
27896
|
-
const first = { termType: "NamedNode", value:
|
|
27897
|
-
const rest = { termType: "NamedNode", value:
|
|
27898
|
-
const nil = { termType: "NamedNode", value:
|
|
27896
|
+
const first = { termType: "NamedNode", value: RDF_FIRST2 };
|
|
27897
|
+
const rest = { termType: "NamedNode", value: RDF_REST2 };
|
|
27898
|
+
const nil = { termType: "NamedNode", value: RDF_NIL2 };
|
|
27899
27899
|
const last = list3.pop();
|
|
27900
27900
|
const result = last ? {
|
|
27901
27901
|
termType: "BlankNode",
|
|
@@ -55467,6 +55467,181 @@ var CONTEXTS = {
|
|
|
55467
55467
|
"https://purl.archive.org/miscellany": miscellany_default
|
|
55468
55468
|
};
|
|
55469
55469
|
|
|
55470
|
+
// lib/core/graphview.mjs
|
|
55471
|
+
init_wire();
|
|
55472
|
+
var RDF_TYPE = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type";
|
|
55473
|
+
var RDF_FIRST = "http://www.w3.org/1999/02/22-rdf-syntax-ns#first";
|
|
55474
|
+
var RDF_REST = "http://www.w3.org/1999/02/22-rdf-syntax-ns#rest";
|
|
55475
|
+
var RDF_NIL = "http://www.w3.org/1999/02/22-rdf-syntax-ns#nil";
|
|
55476
|
+
var MAX_DEPTH = 12;
|
|
55477
|
+
var ALWAYS_LIST = /* @__PURE__ */ new Set([
|
|
55478
|
+
"items",
|
|
55479
|
+
"orderedItems",
|
|
55480
|
+
"to",
|
|
55481
|
+
"cc",
|
|
55482
|
+
"bto",
|
|
55483
|
+
"bcc",
|
|
55484
|
+
"tag",
|
|
55485
|
+
"attachment",
|
|
55486
|
+
"anyOf",
|
|
55487
|
+
"oneOf",
|
|
55488
|
+
"audience",
|
|
55489
|
+
"attributedTo",
|
|
55490
|
+
"alsoKnownAs"
|
|
55491
|
+
]);
|
|
55492
|
+
function expandIri(value, prefixes) {
|
|
55493
|
+
if (typeof value !== "string") return null;
|
|
55494
|
+
if (/^https?:\/\//.test(value)) return value;
|
|
55495
|
+
const colon = value.indexOf(":");
|
|
55496
|
+
if (colon < 1) return null;
|
|
55497
|
+
const base = prefixes[value.slice(0, colon)];
|
|
55498
|
+
return base ? base + value.slice(colon + 1) : null;
|
|
55499
|
+
}
|
|
55500
|
+
function buildTerms() {
|
|
55501
|
+
const terms = /* @__PURE__ */ new Map();
|
|
55502
|
+
const order = [AS_CTX, ...Object.keys(CONTEXTS).filter((u) => u !== AS_CTX)];
|
|
55503
|
+
for (const url of order) {
|
|
55504
|
+
const ctx = CONTEXTS[url]?.["@context"];
|
|
55505
|
+
if (!ctx || typeof ctx !== "object") continue;
|
|
55506
|
+
const prefixes = {};
|
|
55507
|
+
for (const [k, v] of Object.entries(ctx)) {
|
|
55508
|
+
if (typeof v === "string" && /^https?:\/\//.test(v)) prefixes[k] = v;
|
|
55509
|
+
}
|
|
55510
|
+
for (const [name, def] of Object.entries(ctx)) {
|
|
55511
|
+
if (name.startsWith("@") || terms.has(name)) continue;
|
|
55512
|
+
const raw = typeof def === "string" ? def : def?.["@id"];
|
|
55513
|
+
const iri = expandIri(raw, prefixes);
|
|
55514
|
+
if (!iri) continue;
|
|
55515
|
+
terms.set(name, { iri, list: def?.["@container"] === "@list", container: def?.["@container"] ?? null });
|
|
55516
|
+
}
|
|
55517
|
+
}
|
|
55518
|
+
return terms;
|
|
55519
|
+
}
|
|
55520
|
+
var TERMS = buildTerms();
|
|
55521
|
+
var BY_IRI = (() => {
|
|
55522
|
+
const m = /* @__PURE__ */ new Map();
|
|
55523
|
+
for (const [name, { iri }] of TERMS) {
|
|
55524
|
+
const held = m.get(iri);
|
|
55525
|
+
if (!held || name.length < held.length) m.set(iri, name);
|
|
55526
|
+
}
|
|
55527
|
+
return m;
|
|
55528
|
+
})();
|
|
55529
|
+
var NAMES_BY_IRI = (() => {
|
|
55530
|
+
const m = /* @__PURE__ */ new Map();
|
|
55531
|
+
for (const [name, { iri, container }] of TERMS) {
|
|
55532
|
+
if (container === "@language" || container === "@index") continue;
|
|
55533
|
+
const held = m.get(iri);
|
|
55534
|
+
if (held) held.push(name);
|
|
55535
|
+
else m.set(iri, [name]);
|
|
55536
|
+
}
|
|
55537
|
+
return m;
|
|
55538
|
+
})();
|
|
55539
|
+
function indexQuads(quads) {
|
|
55540
|
+
const bySubject = /* @__PURE__ */ new Map();
|
|
55541
|
+
const objects = /* @__PURE__ */ new Set();
|
|
55542
|
+
const blanks = /* @__PURE__ */ new Set();
|
|
55543
|
+
for (const q of quads) {
|
|
55544
|
+
if (q.subject.termType === "BlankNode") blanks.add(q.subject.value);
|
|
55545
|
+
if (q.object.termType === "BlankNode") blanks.add(q.object.value);
|
|
55546
|
+
const s = q.subject.value;
|
|
55547
|
+
let preds = bySubject.get(s);
|
|
55548
|
+
if (!preds) bySubject.set(s, preds = /* @__PURE__ */ new Map());
|
|
55549
|
+
let vals = preds.get(q.predicate.value);
|
|
55550
|
+
if (!vals) preds.set(q.predicate.value, vals = []);
|
|
55551
|
+
vals.push(q.object);
|
|
55552
|
+
if (q.object.termType === "NamedNode" || q.object.termType === "BlankNode") {
|
|
55553
|
+
objects.add(q.object.value);
|
|
55554
|
+
}
|
|
55555
|
+
}
|
|
55556
|
+
return { bySubject, objects, blanks };
|
|
55557
|
+
}
|
|
55558
|
+
function findRoot({ bySubject, objects }) {
|
|
55559
|
+
for (const s of bySubject.keys()) if (!objects.has(s)) return s;
|
|
55560
|
+
for (const [s, preds] of bySubject) if (preds.has(RDF_TYPE)) return s;
|
|
55561
|
+
return bySubject.keys().next().value ?? null;
|
|
55562
|
+
}
|
|
55563
|
+
function readList(head, ctx, depth, path) {
|
|
55564
|
+
const out = [];
|
|
55565
|
+
const walked = /* @__PURE__ */ new Set();
|
|
55566
|
+
let node = head;
|
|
55567
|
+
while (node && node !== RDF_NIL && !walked.has(node)) {
|
|
55568
|
+
walked.add(node);
|
|
55569
|
+
const preds = ctx.bySubject.get(node);
|
|
55570
|
+
if (!preds) break;
|
|
55571
|
+
const first = preds.get(RDF_FIRST)?.[0];
|
|
55572
|
+
if (first) {
|
|
55573
|
+
const value = toValue(first, ctx, depth, path);
|
|
55574
|
+
if (value !== null) out.push(value);
|
|
55575
|
+
}
|
|
55576
|
+
node = preds.get(RDF_REST)?.[0]?.value ?? null;
|
|
55577
|
+
}
|
|
55578
|
+
return out;
|
|
55579
|
+
}
|
|
55580
|
+
function isListHead(term3, ctx) {
|
|
55581
|
+
if (term3.termType !== "BlankNode" && term3.termType !== "NamedNode") return false;
|
|
55582
|
+
return !!ctx.bySubject.get(term3.value)?.has(RDF_FIRST);
|
|
55583
|
+
}
|
|
55584
|
+
function toValue(term3, ctx, depth, path) {
|
|
55585
|
+
if (term3.termType === "Literal") return term3.value;
|
|
55586
|
+
if (isListHead(term3, ctx)) return readList(term3.value, ctx, depth, path);
|
|
55587
|
+
const preds = ctx.bySubject.get(term3.value);
|
|
55588
|
+
if (preds && preds.size) return makeView(term3.value, ctx, depth + 1, path);
|
|
55589
|
+
return term3.termType === "BlankNode" ? null : term3.value;
|
|
55590
|
+
}
|
|
55591
|
+
function readProperty(subject, name, ctx, depth = 0, path = /* @__PURE__ */ new Set()) {
|
|
55592
|
+
const preds = ctx.bySubject.get(subject);
|
|
55593
|
+
if (!preds) return void 0;
|
|
55594
|
+
if (name === "id") return ctx.blanks.has(subject) ? void 0 : subject;
|
|
55595
|
+
if (name === "type") {
|
|
55596
|
+
const types = (preds.get(RDF_TYPE) ?? []).map((t) => BY_IRI.get(t.value) ?? t.value);
|
|
55597
|
+
if (!types.length) return void 0;
|
|
55598
|
+
return types.length === 1 ? types[0] : types;
|
|
55599
|
+
}
|
|
55600
|
+
const term3 = TERMS.get(name);
|
|
55601
|
+
if (!term3) return void 0;
|
|
55602
|
+
const values = preds.get(term3.iri);
|
|
55603
|
+
if (!values || !values.length) return void 0;
|
|
55604
|
+
const listed = values.filter((v) => isListHead(v, ctx));
|
|
55605
|
+
if (term3.list) {
|
|
55606
|
+
if (!listed.length) return void 0;
|
|
55607
|
+
return readList(listed[0].value, ctx, depth, path);
|
|
55608
|
+
}
|
|
55609
|
+
if (listed.length === values.length && listed.length === 1) return readList(listed[0].value, ctx, depth, path);
|
|
55610
|
+
const out = values.map((v) => toValue(v, ctx, depth, path)).filter((v) => v !== null);
|
|
55611
|
+
if (ALWAYS_LIST.has(name)) return out.flat();
|
|
55612
|
+
return out.length === 1 ? out[0] : out;
|
|
55613
|
+
}
|
|
55614
|
+
function makeView(subject, ctx, depth = 0, seen = /* @__PURE__ */ new Set()) {
|
|
55615
|
+
if (depth > MAX_DEPTH || seen.has(subject)) {
|
|
55616
|
+
return ctx.blanks.has(subject) ? null : subject;
|
|
55617
|
+
}
|
|
55618
|
+
const preds = ctx.bySubject.get(subject);
|
|
55619
|
+
if (!preds) return ctx.blanks.has(subject) ? null : subject;
|
|
55620
|
+
const path = new Set(seen).add(subject);
|
|
55621
|
+
const out = {};
|
|
55622
|
+
const id = readProperty(subject, "id", ctx, depth, path);
|
|
55623
|
+
if (id !== void 0) out.id = id;
|
|
55624
|
+
const type = readProperty(subject, "type", ctx, depth, path);
|
|
55625
|
+
if (type !== void 0) out.type = type;
|
|
55626
|
+
for (const predicate of preds.keys()) {
|
|
55627
|
+
if (predicate === RDF_TYPE || predicate === RDF_FIRST || predicate === RDF_REST) continue;
|
|
55628
|
+
for (const name of NAMES_BY_IRI.get(predicate) ?? []) {
|
|
55629
|
+
if (name === "id" || name === "type") continue;
|
|
55630
|
+
const value = readProperty(subject, name, ctx, depth, path);
|
|
55631
|
+
if (value !== void 0) out[name] = value;
|
|
55632
|
+
}
|
|
55633
|
+
}
|
|
55634
|
+
return out;
|
|
55635
|
+
}
|
|
55636
|
+
function graphView(quads, { root = null } = {}) {
|
|
55637
|
+
if (!quads || !quads.length) return null;
|
|
55638
|
+
const ctx = indexQuads(quads);
|
|
55639
|
+
const subject = root ?? findRoot(ctx);
|
|
55640
|
+
if (!subject) return null;
|
|
55641
|
+
const view = makeView(subject, ctx);
|
|
55642
|
+
return view && typeof view === "object" ? view : null;
|
|
55643
|
+
}
|
|
55644
|
+
|
|
55470
55645
|
// lib/core/as2.mjs
|
|
55471
55646
|
var AS2Error = class extends Error {
|
|
55472
55647
|
constructor(reason, { context = null } = {}) {
|
|
@@ -55509,17 +55684,33 @@ async function parseAS2(raw) {
|
|
|
55509
55684
|
}
|
|
55510
55685
|
return { doc, graph: graph2 };
|
|
55511
55686
|
}
|
|
55687
|
+
function groundContext(input) {
|
|
55688
|
+
const ctx = input["@context"];
|
|
55689
|
+
const held = (c) => typeof c === "string" ? Object.hasOwn(CONTEXTS, c) : c && typeof c === "object";
|
|
55690
|
+
let kept;
|
|
55691
|
+
if (ctx === void 0 || ctx === null) kept = [];
|
|
55692
|
+
else if (Array.isArray(ctx)) kept = ctx.filter(held);
|
|
55693
|
+
else kept = held(ctx) ? [ctx] : [];
|
|
55694
|
+
if (!kept.some((c) => c === AS_CTX)) kept.unshift(AS_CTX);
|
|
55695
|
+
return { ...input, "@context": kept.length === 1 ? kept[0] : kept };
|
|
55696
|
+
}
|
|
55512
55697
|
async function readLenient(raw) {
|
|
55513
55698
|
try {
|
|
55514
55699
|
const { doc, graph: graph2 } = await parseAS2(raw);
|
|
55515
|
-
return { doc, graph: graph2, degraded: null };
|
|
55700
|
+
return { doc, graph: graph2, view: graphView(graph2), degraded: null };
|
|
55516
55701
|
} catch (e) {
|
|
55517
|
-
let
|
|
55702
|
+
let input = null;
|
|
55518
55703
|
try {
|
|
55519
|
-
|
|
55704
|
+
input = typeof raw === "string" ? JSON.parse(raw) : raw ?? null;
|
|
55520
55705
|
} catch {
|
|
55521
55706
|
}
|
|
55522
|
-
|
|
55707
|
+
if (!input || typeof input !== "object") return { doc: null, graph: null, view: null, degraded: e.message };
|
|
55708
|
+
try {
|
|
55709
|
+
const { graph: graph2 } = await parseAS2(groundContext(input));
|
|
55710
|
+
return { doc: input, graph: graph2, view: graphView(graph2), degraded: e.message };
|
|
55711
|
+
} catch (inner) {
|
|
55712
|
+
return { doc: input, graph: null, view: null, degraded: `${e.message}; grounded read also failed: ${inner.message}` };
|
|
55713
|
+
}
|
|
55523
55714
|
}
|
|
55524
55715
|
}
|
|
55525
55716
|
|
|
@@ -55542,13 +55733,14 @@ async function reconcileFollowers(publisher, contacts) {
|
|
|
55542
55733
|
try {
|
|
55543
55734
|
const res = await publisher.deliverer.signedFetch(actor, { headers: { accept: ACCEPT_AP } });
|
|
55544
55735
|
if (!res.ok) continue;
|
|
55545
|
-
const { doc, degraded } = await readLenient(await res.json());
|
|
55546
|
-
|
|
55547
|
-
if (
|
|
55736
|
+
const { doc, view, degraded } = await readLenient(await res.json());
|
|
55737
|
+
const actorDoc2 = view ?? doc;
|
|
55738
|
+
if (degraded) publisher.log?.(`actor ${actor} grounded to read: ${degraded}`);
|
|
55739
|
+
if (!actorDoc2?.inbox) continue;
|
|
55548
55740
|
contacts.followers.push({
|
|
55549
55741
|
actor,
|
|
55550
|
-
inbox:
|
|
55551
|
-
sharedInbox:
|
|
55742
|
+
inbox: actorDoc2.inbox,
|
|
55743
|
+
sharedInbox: actorDoc2.endpoints?.sharedInbox || null,
|
|
55552
55744
|
recovered: true,
|
|
55553
55745
|
// Said explicitly, because onUndo reads it: the pod publishes WHO
|
|
55554
55746
|
// follows, never the id of the Follow that did it, so a recovered
|
|
@@ -56822,8 +57014,8 @@ async function fetchAP(intake, url) {
|
|
|
56822
57014
|
let doc = null;
|
|
56823
57015
|
try {
|
|
56824
57016
|
const read2 = await readLenient(await readCapped3(res));
|
|
56825
|
-
if (read2.degraded) intake.log(`fetch ${url}
|
|
56826
|
-
doc = read2.doc;
|
|
57017
|
+
if (read2.degraded) intake.log(`fetch ${url} grounded to read: ${read2.degraded}`);
|
|
57018
|
+
doc = read2.view ?? read2.doc;
|
|
56827
57019
|
} catch (e) {
|
|
56828
57020
|
intake.log(`fetch ${url}: unreadable \u2014 ${e.message}`);
|
|
56829
57021
|
return null;
|
|
@@ -56886,7 +57078,8 @@ async function isGone(intake, url) {
|
|
|
56886
57078
|
if (res.status < 400) {
|
|
56887
57079
|
try {
|
|
56888
57080
|
const { readCapped: readCapped3 } = await Promise.resolve().then(() => (init_safefetch(), safefetch_exports));
|
|
56889
|
-
|
|
57081
|
+
const read2 = await readLenient(await readCapped3(res));
|
|
57082
|
+
return (read2.view ?? read2.doc)?.type === "Tombstone";
|
|
56890
57083
|
} catch {
|
|
56891
57084
|
return false;
|
|
56892
57085
|
}
|
|
@@ -62658,8 +62851,8 @@ var Intake = class {
|
|
|
62658
62851
|
} else {
|
|
62659
62852
|
const got = await readItem(this.remote, item.url, { maxBytes: MAX_ITEM_BYTES, readCapped });
|
|
62660
62853
|
const read2 = got.raw === null ? null : await readLenient(got.raw);
|
|
62661
|
-
if (read2?.degraded) this.log(`inbox item ${item.url}
|
|
62662
|
-
const activity = read2?.doc ?? null;
|
|
62854
|
+
if (read2?.degraded) this.log(`inbox item ${item.url} grounded to read: ${read2.degraded}`);
|
|
62855
|
+
const activity = read2?.view ?? read2?.doc ?? null;
|
|
62663
62856
|
if (keepConcerning) {
|
|
62664
62857
|
const rejection = activity ? await this.handle(activity) : "unparsable JSON";
|
|
62665
62858
|
if (rejection) out.dropped++;
|
|
@@ -62799,8 +62992,8 @@ var Intake = class {
|
|
|
62799
62992
|
const got = await readItem(this.remote, url, { maxBytes: MAX_ITEM_BYTES, readCapped });
|
|
62800
62993
|
const raw = got.raw;
|
|
62801
62994
|
const read2 = raw ? await readLenient(raw) : null;
|
|
62802
|
-
if (read2?.degraded) this.log(`inbox item ${url}
|
|
62803
|
-
activity = read2?.doc ?? null;
|
|
62995
|
+
if (read2?.degraded) this.log(`inbox item ${url} grounded to read: ${read2.degraded}`);
|
|
62996
|
+
activity = read2?.view ?? read2?.doc ?? null;
|
|
62804
62997
|
if (read2?.graph) {
|
|
62805
62998
|
const failure = await checkShapes(read2.graph);
|
|
62806
62999
|
if (failure) {
|
|
@@ -66829,21 +67022,28 @@ async function importSigningKey(keysRecord) {
|
|
|
66829
67022
|
"pkcs8",
|
|
66830
67023
|
pemToDer(keysRecord.rsa.privatePem),
|
|
66831
67024
|
{ name: "RSASSA-PKCS1-v1_5", hash: "SHA-256" },
|
|
66832
|
-
|
|
67025
|
+
false,
|
|
66833
67026
|
["sign"]
|
|
66834
67027
|
);
|
|
66835
67028
|
return { rsaPrivate, rsaPublicPem: keysRecord.rsa.publicPem, edPrivate: null, edPublicMultibase: null };
|
|
66836
67029
|
}
|
|
67030
|
+
var fromCache = (c) => ({ rsaPrivate: c.rsaPrivate, rsaPublicPem: c.rsaPublicPem, edPrivate: null, edPublicMultibase: null });
|
|
67031
|
+
var isOpenedKey = (c) => c?.rsaPrivate?.type === "private" && typeof c.rsaPublicPem === "string";
|
|
67032
|
+
async function cacheOpenedKeys(actorUrl, keysRecord) {
|
|
67033
|
+
const keys = await importSigningKey(keysRecord);
|
|
67034
|
+
await kvPut(keyCacheKey(actorUrl), { rsaPrivate: keys.rsaPrivate, rsaPublicPem: keys.rsaPublicPem }).catch(() => {
|
|
67035
|
+
});
|
|
67036
|
+
return keys;
|
|
67037
|
+
}
|
|
66837
67038
|
var keyCacheKey = (actorUrl) => `signing-keys:${actorUrl}`;
|
|
66838
67039
|
async function loadKeysFromPod(remote, urls) {
|
|
66839
67040
|
const cached = await kvGet(keyCacheKey(urls.actor)).catch(() => null);
|
|
66840
|
-
if (cached
|
|
67041
|
+
if (isOpenedKey(cached)) return fromCache(cached);
|
|
67042
|
+
if (cached?.rsa?.privatePem) return cacheOpenedKeys(urls.actor, cached);
|
|
66841
67043
|
const doc = await readWrappedKeys(remote, urls);
|
|
66842
67044
|
if (isKeyEnvelope(doc)) throw new KeyPasswordNeeded();
|
|
66843
67045
|
if (!doc || !doc.rsa) throw new Error("no signing key on the pod \u2014 sign up did not finish");
|
|
66844
|
-
|
|
66845
|
-
});
|
|
66846
|
-
return importSigningKey(doc);
|
|
67046
|
+
return cacheOpenedKeys(urls.actor, doc);
|
|
66847
67047
|
}
|
|
66848
67048
|
|
|
66849
67049
|
// lib/core/deliver.mjs
|
|
@@ -69525,9 +69725,7 @@ var BrowserAgent = class _BrowserAgent {
|
|
|
69525
69725
|
const rec = await generateKeys();
|
|
69526
69726
|
rec.mintedFor = this.urls.actor;
|
|
69527
69727
|
await writeWrappedKeys(this.remote, this.urls, await wrapKeys(rec, password));
|
|
69528
|
-
await
|
|
69529
|
-
});
|
|
69530
|
-
const keys = await importSigningKey(rec);
|
|
69728
|
+
const keys = await cacheOpenedKeys(this.urls.actor, rec);
|
|
69531
69729
|
this.publisher.publicKeyPem = keys.rsaPublicPem;
|
|
69532
69730
|
this.deliverer.rsaPrivate = keys.rsaPrivate;
|
|
69533
69731
|
await this.publisher.publishProfile();
|