MacBookPro.lan 2026-7-5:20:1:24

This commit is contained in:
oskar
2026-07-05 20:01:25 +02:00
parent 471b0aa399
commit 236ceccda4
50 changed files with 14364 additions and 6929 deletions
+8 -27
View File
@@ -1233,26 +1233,6 @@ var StatusMessage = class extends import_obsidian2.Notice {
};
// src/crypto.ts
async function _generateKey(seed) {
const keyMaterial = await window.crypto.subtle.importKey(
"raw",
seed,
{ name: "PBKDF2" },
false,
["deriveBits"]
);
const masterKey = await window.crypto.subtle.deriveBits(
{
name: "PBKDF2",
salt: new Uint8Array(16),
iterations: 1e5,
hash: "SHA-256"
},
keyMaterial,
256
);
return new Uint8Array(masterKey);
}
function masterKeyToString(masterKey) {
return arrayBufferToBase64(masterKey);
}
@@ -1284,7 +1264,7 @@ async function encryptString(plaintext, existingKey) {
if (existingKey) {
key = base64ToArrayBuffer(existingKey);
} else {
key = await _generateKey(window.crypto.getRandomValues(new Uint8Array(64)).buffer);
key = window.crypto.getRandomValues(new Uint8Array(16)).buffer;
}
const aesKey = await _getAesGcmKey(key);
const ciphertext = [];
@@ -1308,7 +1288,11 @@ async function encryptString(plaintext, existingKey) {
return {
ciphertext,
ivs,
key: masterKeyToString(key).slice(0, 43)
// Strip base64 padding rather than slicing to a fixed length: a fresh
// 16-byte key yields 22 chars, while an older reused 32-byte key still
// yields its full 43 chars. Hardcoding 22 would truncate (and break)
// re-shares of notes that were first encrypted with a 256-bit key.
key: masterKeyToString(key).replace(/=+$/, "")
};
}
async function sha(algorithm, data) {
@@ -3429,18 +3413,15 @@ async function captureRenderedNote(leaf, options = {}) {
elements.push(getElementStyle("pusher", renderer.pusherEl));
const html = await sampleRenderedHtml(view);
const contentDom = new DOMParser().parseFromString(html, "text/html");
const mjxStyleEl = contentDom.querySelector("mjx-container") ? activeDocument.getElementById("MJX-CHTML-styles") : null;
const mjxText = (_c = mjxStyleEl == null ? void 0 : mjxStyleEl.textContent) == null ? void 0 : _c.trim();
const cssRules = [];
for (const sheet of Array.from(activeDocument.styleSheets)) {
if (mjxText && sheet.ownerNode === mjxStyleEl) continue;
if (((_c = sheet.ownerNode) == null ? void 0 : _c.id) === "MJX-CHTML-styles") continue;
for (const rule of Array.from(sheet.cssRules)) cssRules.push(rule);
}
let css = cssRules.filter((rule) => {
const css = cssRules.filter((rule) => {
var _a2;
return ((_a2 = rule.media) == null ? void 0 : _a2[0]) !== "print";
}).map((rule) => rule.cssText).join("").replace(/\n/g, "");
if (mjxText) css += mjxText.replace(/\n/g, "");
return { contentDom, cssRules, css, elements };
}
var RENDER_POLL_MAX_TICKS = 40;