fedipod 1.2.0 → 1.3.1
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/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 +87 -11
- package/package.json +1 -1
- package/web/app/agent.mjs +2 -4
- package/web/app/boot.mjs +2 -3
- package/web/app/deliver-relay.mjs +4 -1
- package/web/app/dist/boot.js +22 -3
- package/web/app/dist/boot.js.map +2 -2
- package/web/app/dist/sw.js +241 -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 +241 -42
|
@@ -28,10 +28,13 @@ export class RelayDeliverer extends Deliverer {
|
|
|
28
28
|
async signedFetch(url, init = {}) {
|
|
29
29
|
const body = typeof init.body === 'string' ? init.body : (init.body ? new TextDecoder().decode(init.body) : '');
|
|
30
30
|
const s = await sign({ url, method: init.method || 'GET', headers: init.headers || {}, body }, this.rsaPrivate, this.keyId);
|
|
31
|
+
// Every signed header goes to the relay, `accept` included: the signature
|
|
32
|
+
// covers it, so a relay request missing it carries an invalid signature —
|
|
33
|
+
// and a read without it gets the HTML page instead of the document.
|
|
31
34
|
const relayReq = {
|
|
32
35
|
url: s.url, method: s.method, body,
|
|
33
36
|
headers: {
|
|
34
|
-
date: s.headers.date, digest: s.headers.digest,
|
|
37
|
+
date: s.headers.date, digest: s.headers.digest, accept: s.headers.accept,
|
|
35
38
|
'content-type': s.headers['content-type'], signature: s.headers.signature,
|
|
36
39
|
},
|
|
37
40
|
};
|
package/web/app/dist/boot.js
CHANGED
|
@@ -33231,6 +33231,26 @@ async function kvPut(key, val) {
|
|
|
33231
33231
|
}
|
|
33232
33232
|
|
|
33233
33233
|
// web/app/keys-browser.mjs
|
|
33234
|
+
var pemToDer = (pem) => Uint8Array.from(
|
|
33235
|
+
atob(pem.replace(/-----[^-]+-----/g, "").replace(/\s+/g, "")),
|
|
33236
|
+
(c) => c.charCodeAt(0)
|
|
33237
|
+
);
|
|
33238
|
+
async function importSigningKey(keysRecord) {
|
|
33239
|
+
const rsaPrivate = await crypto.subtle.importKey(
|
|
33240
|
+
"pkcs8",
|
|
33241
|
+
pemToDer(keysRecord.rsa.privatePem),
|
|
33242
|
+
{ name: "RSASSA-PKCS1-v1_5", hash: "SHA-256" },
|
|
33243
|
+
false,
|
|
33244
|
+
["sign"]
|
|
33245
|
+
);
|
|
33246
|
+
return { rsaPrivate, rsaPublicPem: keysRecord.rsa.publicPem, edPrivate: null, edPublicMultibase: null };
|
|
33247
|
+
}
|
|
33248
|
+
async function cacheOpenedKeys(actorUrl, keysRecord) {
|
|
33249
|
+
const keys = await importSigningKey(keysRecord);
|
|
33250
|
+
await kvPut(keyCacheKey(actorUrl), { rsaPrivate: keys.rsaPrivate, rsaPublicPem: keys.rsaPublicPem }).catch(() => {
|
|
33251
|
+
});
|
|
33252
|
+
return keys;
|
|
33253
|
+
}
|
|
33234
33254
|
var keyCacheKey = (actorUrl) => `signing-keys:${actorUrl}`;
|
|
33235
33255
|
|
|
33236
33256
|
// web/app/signup.mjs
|
|
@@ -33321,8 +33341,7 @@ async function signUp(answers, { onStep = () => {
|
|
|
33321
33341
|
} catch (e) {
|
|
33322
33342
|
throw new Error(`could not store the signing key on the pod (${e.message}). The credential is for ${credential.webId} \u2014 that WebID must own ${pod} and its ${AP_ROOT} must be writable by it.`);
|
|
33323
33343
|
}
|
|
33324
|
-
await
|
|
33325
|
-
});
|
|
33344
|
+
await cacheOpenedKeys(actorUrl, keys);
|
|
33326
33345
|
prog.keys = keys;
|
|
33327
33346
|
prog.keysStored = true;
|
|
33328
33347
|
keysStep.ok();
|
|
@@ -33668,7 +33687,7 @@ window.fedipodUnlock = async (password) => {
|
|
|
33668
33687
|
if (!isKeyEnvelope(doc)) throw new Error("this account's key is not locked \u2014 nothing to unlock");
|
|
33669
33688
|
const rec = await unwrapKeys(doc, password);
|
|
33670
33689
|
const actorUrl = `${cfg.remotePod}${cfg.root || AP_ROOT}ap/actor`;
|
|
33671
|
-
await
|
|
33690
|
+
await cacheOpenedKeys(actorUrl, rec);
|
|
33672
33691
|
await bootWorker();
|
|
33673
33692
|
};
|
|
33674
33693
|
window.fedipodSignup = async ({ onStep, ...answers }) => {
|