fedipod 1.2.0 → 1.3.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.
@@ -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 kvPut(keyCacheKey(actorUrl), keys).catch(() => {
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 kvPut(keyCacheKey(actorUrl), rec);
33690
+ await cacheOpenedKeys(actorUrl, rec);
33672
33691
  await bootWorker();
33673
33692
  };
33674
33693
  window.fedipodSignup = async ({ onStep, ...answers }) => {