hexo-blog-encrypt 4.0.3 → 4.1.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 +252 -256
- package/ReadMe.zh.md +218 -237
- package/lib/hbe.blink.html +1 -1
- package/lib/hbe.bundle.js +1 -1
- package/lib/hbe.bundle.js.map +4 -4
- package/lib/hbe.default.html +1 -1
- package/lib/hbe.flip.html +1 -1
- package/lib/hbe.shrink.html +1 -1
- package/lib/hbe.style.css +50 -20
- package/lib/hbe.surge.html +1 -1
- package/lib/hbe.up.html +1 -1
- package/lib/hbe.wave.html +1 -1
- package/lib/hbe.xray.html +1 -1
- package/package.json +11 -9
- package/src/server/config.js +104 -4
- package/src/server/crypto.js +10 -5
- package/src/server/generator.js +18 -2
- package/src/server/index.js +12 -5
- package/src/server/template.js +2 -1
package/lib/hbe.bundle.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/browser/ui.js", "../src/browser/crypto.js", "../src/browser/dom.js", "../src/browser/storage.js", "../src/browser/main.js"],
|
|
4
|
-
"sourcesContent": ["'use strict';\n\n// Wires the encrypted-post UI: form submit (Enter + click both fire),\n// `aria-busy` during async derivation, and an inline `[role=\"alert\"]` for\n// errors (NO `alert()` calls \u2014 feature-crew critique blocked dialog UX).\n\nfunction setBusy(form, busy) {\n if (!form) return;\n form.setAttribute('aria-busy', busy ? 'true' : 'false');\n const button = form.querySelector('.hbe-button');\n if (button) {\n button.disabled = !!busy;\n }\n const input = form.querySelector('#hbePass');\n if (input) {\n input.disabled = !!busy;\n }\n}\n\nfunction showError(mainElement, message) {\n let alert = mainElement.querySelector('[role=\"alert\"]');\n if (!alert) {\n alert = document.createElement('div');\n alert.setAttribute('role', 'alert');\n alert.className = 'hbe hbe-error';\n const form = mainElement.querySelector('#hbeForm');\n if (form) form.parentNode.insertBefore(alert, form.nextSibling);\n else mainElement.appendChild(alert);\n }\n alert.textContent = message;\n}\n\nfunction clearError(mainElement) {\n const alert = mainElement.querySelector('[role=\"alert\"]');\n if (alert) alert.textContent = '';\n}\n\nfunction readPassword(form) {\n const input = form.querySelector('#hbePass');\n return input ? input.value : '';\n}\n\nfunction attachSubmit(form, handler) {\n if (!form) return;\n form.addEventListener('submit', (event) => {\n event.preventDefault();\n handler();\n });\n}\n\nmodule.exports = {\n setBusy,\n showError,\n clearError,\n readPassword,\n attachSubmit,\n};\n", "'use strict';\n\n// Browser-side AES-256-GCM decryption with PBKDF2-SHA256 key derivation.\n// Mirrors the server-side parameters in `src/server/crypto.js`:\n// - PBKDF2: SHA-256, configurable iterations (read from data-kdf-iterations)\n// - AES: 256-bit key, GCM mode, 12-byte nonce, 16-byte auth tag\n//\n// Unified failure path: ANY thrown value (DOMException OperationError,\n// TypeError, etc.) collapses to {ok: false}. Wrong-password and\n// tampered-ciphertext are indistinguishable under GCM by design.\n\nconst KEY_BITS = 256;\nconst TAG_BITS = 128;\nconst TAG_BYTES = TAG_BITS / 8;\nconst TEXT_DECODER = new TextDecoder('utf-8', { fatal: true });\nconst TEXT_ENCODER = new TextEncoder();\n\nfunction hexToBytes(hex) {\n const len = hex.length;\n if (len % 2 !== 0) {\n throw new Error('hexo-blog-encrypt: hex string has odd length');\n }\n const out = new Uint8Array(len / 2);\n for (let i = 0; i < out.length; i++) {\n out[i] = parseInt(hex.substr(i * 2, 2), 16);\n }\n return out;\n}\n\nasync function deriveKey(password, salt, iterations) {\n const baseKey = await crypto.subtle.importKey(\n 'raw',\n TEXT_ENCODER.encode(password),\n { name: 'PBKDF2' },\n false,\n ['deriveKey']\n );\n return crypto.subtle.deriveKey(\n {\n name: 'PBKDF2',\n salt,\n iterations,\n hash: 'SHA-256',\n },\n baseKey,\n { name: 'AES-GCM', length: KEY_BITS },\n true, // extractable=true so storage.js can persist the raw key bytes when autoSave is on\n ['decrypt']\n );\n}\n\nasync function decryptWithKey(key, nonce, ciphertextWithTag) {\n // Web Crypto AES-GCM expects ciphertext||tag as a single buffer (same as Node's\n // `decipher.update + setAuthTag(tag); decipher.final()` flow when concatenated).\n const plainBuf = await crypto.subtle.decrypt(\n { name: 'AES-GCM', iv: nonce, tagLength: TAG_BITS },\n key,\n ciphertextWithTag\n );\n return TEXT_DECODER.decode(plainBuf);\n}\n\n// High-level: derive a key from the password + decrypt in one shot.\n// Returns {ok: true, plaintext, key} or {ok: false}.\nasync function tryDecryptWithPassword({ password, saltHex, nonceHex, ciphertextHex, iterations }) {\n try {\n const salt = hexToBytes(saltHex);\n const nonce = hexToBytes(nonceHex);\n const ciphertext = hexToBytes(ciphertextHex);\n if (ciphertext.length < TAG_BYTES) return { ok: false };\n const key = await deriveKey(password, salt, iterations);\n const plaintext = await decryptWithKey(key, nonce, ciphertext);\n return { ok: true, plaintext, key };\n } catch (_e) {\n return { ok: false };\n }\n}\n\n// Same shape, but reuses an already-derived key (autosave fast path).\nasync function tryDecryptWithKey({ key, nonceHex, ciphertextHex }) {\n try {\n const nonce = hexToBytes(nonceHex);\n const ciphertext = hexToBytes(ciphertextHex);\n if (ciphertext.length < TAG_BYTES) return { ok: false };\n const plaintext = await decryptWithKey(key, nonce, ciphertext);\n return { ok: true, plaintext };\n } catch (_e) {\n return { ok: false };\n }\n}\n\nmodule.exports = {\n tryDecryptWithPassword,\n tryDecryptWithKey,\n deriveKey,\n decryptWithKey,\n hexToBytes,\n};\n", "'use strict';\n\n// innerHTML leaves scripts inert. Attach the complete decrypted DOM first, then\n// restore executable scripts so initializers can find both content and libraries.\nconst SCRIPT_LOAD_TIMEOUT = 15000;\nconst JAVASCRIPT_TYPE = /^(?:application|text)\\/(?:x-)?(?:java|ecma)script$|^text\\/(?:javascript1\\.[0-5]|jscript|livescript)$/i;\n\nfunction getExecutableScript(oldScriptElement) {\n const newScript = document.createElement('script');\n for (const attr of oldScriptElement.attributes) {\n newScript.setAttribute(attr.name, attr.value);\n }\n // CSP hides the nonce attribute after attachment; the property retains it.\n if (oldScriptElement.nonce) newScript.nonce = oldScriptElement.nonce;\n newScript.text = oldScriptElement.text;\n return newScript;\n}\n\nfunction convertHTMLToElement(htmlString) {\n const wrapper = document.createElement('div');\n wrapper.innerHTML = htmlString;\n return wrapper;\n}\n\nfunction scriptType(script) {\n let type = script.getAttribute('type');\n if (type === null) {\n const language = script.getAttribute('language');\n type = language ? 'text/' + language : '';\n }\n const keyword = type.toLowerCase();\n if (keyword === 'module') return 'module';\n if (keyword === 'importmap' || keyword === 'speculationrules') return 'declarative';\n const mime = type.replace(/^[\\t\\n\\f\\r ]+|[\\t\\n\\f\\r ]+$/g, '');\n if (type === '' || JAVASCRIPT_TYPE.test(mime)) return 'classic';\n return 'data';\n}\n\nfunction restoreScript(oldScript, newScript, waitForLoad) {\n if (!waitForLoad) {\n oldScript.parentNode.replaceChild(newScript, oldScript);\n return Promise.resolve();\n }\n return new Promise((resolve) => {\n const finish = () => {\n clearTimeout(timer);\n newScript.removeEventListener('load', finish);\n newScript.removeEventListener('error', finish);\n resolve();\n };\n // A broken third-party dependency must not prevent the decrypt callback\n // forever. A timed-out script can still execute later; this is not a cancel.\n const timer = setTimeout(() => {\n console.warn('hexo-blog-encrypt: timed out waiting for a decrypted script to load.');\n finish();\n }, SCRIPT_LOAD_TIMEOUT);\n // Do not overwrite onload/onerror attributes copied from the original tag.\n newScript.addEventListener('load', finish);\n newScript.addEventListener('error', finish);\n oldScript.parentNode.replaceChild(newScript, oldScript);\n });\n}\n\nasync function restoreScripts(container) {\n const pending = [];\n const supportsModules = 'noModule' in document.createElement('script');\n for (const oldScript of container.querySelectorAll('script')) {\n // Earlier user scripts may remove later nodes. Do not execute detached ones.\n if (!container.contains(oldScript)) continue;\n const type = scriptType(oldScript);\n if (type === 'data' || (type === 'classic' && oldScript.noModule && supportsModules)) continue;\n if (type === 'module' && !supportsModules) continue;\n\n const newScript = getExecutableScript(oldScript);\n // Inline modules have no native load event. Keep their native async\n // semantics instead of adding a false timeout or rewriting their source.\n const waitForLoad = type !== 'declarative' && newScript.hasAttribute('src');\n const independent = waitForLoad && newScript.hasAttribute('async');\n // Dynamically created classics default to async even without the attribute.\n if (type === 'classic' && waitForLoad && !independent) newScript.async = false;\n const loaded = restoreScript(oldScript, newScript, waitForLoad);\n if (independent) pending.push(loaded);\n else await loaded;\n }\n await Promise.all(pending);\n}\n\n// Resolve after restored scripts load, fail, or time out. Native module load\n// events do not await arbitrary async work such as top-level await continuations.\nasync function swapInDecryptedDOM(mainElement, plaintextHTML) {\n const decrypted = convertHTMLToElement(plaintextHTML);\n decrypted.id = 'hexo-blog-encrypt';\n decrypted.classList.add('hbe', 'hbe-decrypted-content');\n mainElement.parentNode.replaceChild(decrypted, mainElement);\n await restoreScripts(decrypted);\n return decrypted;\n}\n\nmodule.exports = {\n getExecutableScript,\n convertHTMLToElement,\n swapInDecryptedDOM,\n};\n", "'use strict';\n\n// Per-post localStorage entry storing the derived AES key + the salt/nonce that\n// produced the corresponding ciphertext. On reload we re-import the key and\n// attempt decryption silently; the user is never re-prompted.\n//\n// Schema (v4):\n// {\n// version: 4,\n// dk: base64(rawKeyBytes), // 32 bytes\n// salt: <hex64>, // matches data-salt\n// nonce: <hex24>, // retained for v4 schema compatibility\n// }\n//\n// IMPORTANT: when `autoSave` is false, save() is a no-op. When reading, any\n// entry with a non-4 version (or v3 leftovers like `hmk`/`hmacDigest`) is\n// purged + ignored.\n\nconst STORAGE_KEY_PREFIX = 'hbe.v4.';\nconst SCHEMA_VERSION = 4;\n\nfunction storageKey(pageKey) {\n return STORAGE_KEY_PREFIX + pageKey;\n}\n\nfunction bytesToBase64(bytes) {\n let bin = '';\n for (let i = 0; i < bytes.length; i++) bin += String.fromCharCode(bytes[i]);\n return btoa(bin);\n}\n\nfunction base64ToBytes(b64) {\n const bin = atob(b64);\n const out = new Uint8Array(bin.length);\n for (let i = 0; i < bin.length; i++) out[i] = bin.charCodeAt(i);\n return out;\n}\n\nasync function save({ pageKey, key, saltHex, nonceHex, autoSave }) {\n if (!autoSave) return;\n try {\n const raw = await crypto.subtle.exportKey('raw', key);\n const entry = {\n version: SCHEMA_VERSION,\n dk: bytesToBase64(new Uint8Array(raw)),\n salt: saltHex,\n nonce: nonceHex,\n };\n localStorage.setItem(storageKey(pageKey), JSON.stringify(entry));\n } catch (_e) {\n // localStorage.setItem can throw QuotaExceededError or SecurityError\n // (private mode, disabled storage). Silently ignore \u2014 autoSave is\n // best-effort UX.\n }\n}\n\nasync function load({ pageKey, expectedSaltHex }) {\n let entry;\n try {\n const raw = localStorage.getItem(storageKey(pageKey));\n if (!raw) return null;\n entry = JSON.parse(raw);\n } catch (_e) {\n return null;\n }\n\n // Purge stale or v3 entries.\n if (\n !entry\n || entry.version !== SCHEMA_VERSION\n || typeof entry.dk !== 'string'\n || typeof entry.salt !== 'string'\n || typeof entry.nonce !== 'string'\n || 'hmk' in entry\n || 'hmacDigest' in entry\n ) {\n try { localStorage.removeItem(storageKey(pageKey)); } catch (_e) { /* ignore */ }\n return null;\n }\n\n // If the encrypted page's salt changed, the cached key is stale. Nonce is\n // not part of PBKDF2 key derivation; decrypt still uses the current page's\n // nonce and ciphertext, and failure clears the cache in main.js.\n if (entry.salt !== expectedSaltHex) {\n try { localStorage.removeItem(storageKey(pageKey)); } catch (_e) { /* ignore */ }\n return null;\n }\n\n try {\n const rawBytes = base64ToBytes(entry.dk);\n const key = await crypto.subtle.importKey(\n 'raw',\n rawBytes,\n { name: 'AES-GCM' },\n true,\n ['decrypt']\n );\n return key;\n } catch (_e) {\n try { localStorage.removeItem(storageKey(pageKey)); } catch (_e2) { /* ignore */ }\n return null;\n }\n}\n\nfunction clear(pageKey) {\n try { localStorage.removeItem(storageKey(pageKey)); } catch (_e) { /* ignore */ }\n}\n\nmodule.exports = {\n save,\n load,\n clear,\n STORAGE_KEY_PREFIX,\n SCHEMA_VERSION,\n};\n", "'use strict';\n\n// Browser entry point. Reads the wire-format from the encrypted-post wrapper,\n// drives the UI via `ui.js`, derives & decrypts via `crypto.js`, and persists\n// the derived key (when autoSave is on) via `storage.js`.\n\nconst ui = require('./ui');\nconst cryptoMod = require('./crypto');\nconst dom = require('./dom');\nconst storage = require('./storage');\n\nconst SUPPORTED_FORMAT = '4';\n\nfunction readWireFormat(mainElement) {\n const ds = mainElement.dataset;\n const ciphertextNode = mainElement.querySelector('script#hbeData');\n return {\n format: ds.hbeFormat,\n wpm: ds.wpm || 'Wrong password.',\n whm: ds.whm || ds.wpm || 'Wrong password.',\n saltHex: ds.salt,\n nonceHex: ds.nonce,\n iterations: parseInt(ds.kdfIterations, 10) || 250000,\n autoSave: ds.autoSave === 'true',\n ciphertextHex: ciphertextNode ? ciphertextNode.textContent.trim() : '',\n };\n}\n\nfunction dispatchDecryptEvent(mode) {\n // Fire on `window` for v3 back-compat \u2014 both READMEs document\n // `window.addEventListener('hexo-blog-decrypt', fn)` as the public API.\n // Old listeners that only access `e.type` continue to work; new listeners\n // can additionally read `e.detail.mode` ('manual' | 'cached').\n try {\n window.dispatchEvent(new CustomEvent('hexo-blog-decrypt', { detail: { mode } }));\n } catch (_e) {\n // CustomEvent constructor unavailable on very old browsers \u2014 fall back\n // to plain Event (no detail).\n try {\n window.dispatchEvent(new Event('hexo-blog-decrypt'));\n } catch (_e2) { /* ignore \u2014 no event API at all */ }\n }\n}\n\nfunction pageKey() {\n // Per-URL bucket so different encrypted posts don't collide in localStorage.\n return location.pathname + location.search;\n}\n\nasync function reveal(mainElement, plaintext, mode) {\n await dom.swapInDecryptedDOM(mainElement, plaintext);\n dispatchDecryptEvent(mode);\n}\n\nasync function tryAutoDecrypt(mainElement, wire, guardedReveal) {\n if (!wire.autoSave) return false;\n const cachedKey = await storage.load({\n pageKey: pageKey(),\n expectedSaltHex: wire.saltHex,\n });\n if (!cachedKey) return false;\n const result = await cryptoMod.tryDecryptWithKey({\n key: cachedKey,\n nonceHex: wire.nonceHex,\n ciphertextHex: wire.ciphertextHex,\n });\n if (!result.ok) {\n storage.clear(pageKey());\n return false;\n }\n await guardedReveal(result.plaintext, 'cached');\n return true;\n}\n\nasync function handleSubmit(mainElement, wire, form, guardedReveal) {\n ui.clearError(mainElement);\n ui.setBusy(form, true);\n const password = ui.readPassword(form);\n if (!password) {\n ui.setBusy(form, false);\n ui.showError(mainElement, wire.wpm);\n return;\n }\n let result;\n try {\n result = await cryptoMod.tryDecryptWithPassword({\n password,\n saltHex: wire.saltHex,\n nonceHex: wire.nonceHex,\n ciphertextHex: wire.ciphertextHex,\n iterations: wire.iterations,\n });\n } finally {\n ui.setBusy(form, false);\n }\n if (!result.ok) {\n ui.showError(mainElement, wire.wpm);\n return;\n }\n if (wire.autoSave) {\n await storage.save({\n pageKey: pageKey(),\n key: result.key,\n saltHex: wire.saltHex,\n nonceHex: wire.nonceHex,\n autoSave: true,\n });\n }\n await guardedReveal(result.plaintext, 'manual');\n}\n\nasync function bootstrap() {\n const mainElement = document.getElementById('hexo-blog-encrypt');\n if (!mainElement) return;\n const wire = readWireFormat(mainElement);\n\n if (wire.format !== SUPPORTED_FORMAT) {\n ui.showError(\n mainElement,\n 'hexo-blog-encrypt: this page was built with an incompatible plugin version. ' +\n 'Rebuild the site after upgrading the plugin.'\n );\n return;\n }\n\n // Single-shot reveal guard: with autoSave on, `tryAutoDecrypt` runs in\n // parallel with the form submit handler. If the user types fast enough\n // to submit BEFORE auto-decrypt resolves, both paths can call `reveal`\n // on the same `mainElement` \u2014 the second `replaceChild` would throw\n // because the wrapper is already detached. The guard makes whoever\n // wins the race the sole DOM-mutator.\n let revealed = false;\n const guardedReveal = async (plaintext, mode) => {\n if (revealed) return;\n revealed = true;\n await reveal(mainElement, plaintext, mode);\n };\n\n const form = mainElement.querySelector('#hbeForm');\n ui.attachSubmit(form, () => handleSubmit(mainElement, wire, form, guardedReveal));\n\n const auto = await tryAutoDecrypt(mainElement, wire, guardedReveal);\n if (!auto && !revealed) {\n const input = mainElement.querySelector('#hbePass');\n if (input) input.focus();\n }\n}\n\nif (document.readyState === 'loading') {\n document.addEventListener('DOMContentLo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AAAsB,EACA,QAASN,EAAK,QACd,SAAUA,EAAK,SACf,cAAeA,EAAK,cACpB,WAAYA,EAAK,UACnB,CAAC,CACH,QAAE,CACAjB,EAAG,QAAQsB,EAAM,EAAK,CACxB,CACA,GAAI,CAACF,EAAO,GAAI,CACdpB,EAAG,UAAUM,EAAaW,EAAK,GAAG,EAClC,MACF,CACIA,EAAK,UACP,MAAMd,EAAQ,KAAK,CACjB,QAASU,EAAQ,EACjB,IAAKO,EAAO,IACZ,QAASH,EAAK,QACd,SAAUA,EAAK,SACf,SAAU,EACZ,CAAC,EAEH,MAAMC,EAAcE,EAAO,UAAW,QAAQ,CAChD,CAEA,eAAeI,GAAY,CACzB,IAAMlB,EAAc,SAAS,eAAe,mBAAmB,EAC/D,GAAI,CAACA,EAAa,OAClB,IAAMW,EAAOZ,EAAeC,CAAW,EAEvC,GAAIW,EAAK,SAAWb,EAAkB,CACpCJ,EAAG,UACDM,EACA,0HAEF,EACA,MACF,CAQA,IAAImB,EAAW,GACTP,EAAgB,MAAOH,EAAWL,IAAS,CAC3Ce,IACJA,EAAW,GACX,MAAMX,EAAOR,EAAaS,EAAWL,CAAI,EAC3C,EAEMY,EAAOhB,EAAY,cAAc,UAAU,EAIjD,GAHAN,EAAG,aAAasB,EAAM,IAAMD,GAAaf,EAAaW,EAAMK,EAAMJ,CAAa,CAAC,EAG5E,CADS,MAAMF,GAAeV,EAAaW,EAAMC,CAAa,GACrD,CAACO,EAAU,CACtB,IAAMC,EAAQpB,EAAY,cAAc,UAAU,EAC9CoB,GAAOA,EAAM,MAAM,CACzB,CACF,CAEI,SAAS,aAAe,UAC1B,SAAS,iBAAiB,mBAAoBF,CAAS,EAEvDA,EAAU",
|
|
6
|
-
"names": ["require_ui", "__commonJSMin", "exports", "module", "setBusy", "form", "busy", "button", "
|
|
3
|
+
"sources": ["../src/browser/ui.js", "../src/browser/crypto.js", "../src/browser/dom.js", "../src/browser/storage.js", "../src/browser/i18n.js", "../src/browser/main.js"],
|
|
4
|
+
"sourcesContent": ["'use strict';\n\n// Wires the encrypted-post UI: form submit (Enter + click both fire),\n// `aria-busy` during async derivation, and an inline `[role=\"alert\"]` for\n// errors (NO `alert()` calls). Every lookup is scoped to one post's wrapper,\n// so several encrypted posts can share a page even when their themes repeat\n// the same element ids.\n\nfunction findForm(el) {\n return el.querySelector('#hbeForm,.hbe-form,form');\n}\n\nfunction findInput(el) {\n return el.querySelector('#hbePass,.hbe-input-field,input[type=\"password\"]');\n}\n\n// Keep the <label for> / <input id> pair unique per wrapper. The first post\n// keeps `hbePass` (themes and user CSS may target it); later duplicates are\n// renamed and their own label is re-pointed.\nlet idCounter = 0;\nfunction ensureUniqueId(el, input) {\n if (!input) return;\n const oldId = input.id;\n if (oldId && document.getElementById(oldId) === input) return;\n let newId;\n do {\n newId = (oldId || 'hbePass') + '-' + (++idCounter);\n } while (document.getElementById(newId));\n const labels = el.querySelectorAll('label');\n for (let i = 0; i < labels.length; i++) {\n if (oldId && labels[i].htmlFor === oldId) labels[i].htmlFor = newId;\n }\n input.id = newId;\n}\n\nfunction setBusy(form, input, busy) {\n if (form) {\n form.setAttribute('aria-busy', busy ? 'true' : 'false');\n const button = form.querySelector('.hbe-button');\n if (button) button.disabled = !!busy;\n }\n if (input) input.disabled = !!busy;\n}\n\n// Themes style the \"has a value\" state via `.hbe-input--filled` on the\n// `.hbe-input` wrapper (some hide an unfocused, empty field). Keep it in sync\n// on load (browser autofill / restored form state) and on every edit.\nfunction trackFilled(input) {\n if (!input) return;\n const box = input.closest('.hbe-input') || input.parentNode;\n const sync = () => box.classList.toggle('hbe-input--filled', input.value !== '');\n input.addEventListener('input', sync);\n input.addEventListener('change', sync);\n sync();\n}\n\n// After a failed attempt, put the caret back with the old value selected so\n// the reader can retype immediately.\nfunction refocus(input) {\n if (!input) return;\n input.focus();\n input.select();\n}\n\nfunction showError(el, message) {\n let alert = el.querySelector('[role=\"alert\"]');\n if (!alert) {\n alert = document.createElement('div');\n alert.setAttribute('role', 'alert');\n alert.className = 'hbe hbe-error';\n const form = findForm(el);\n if (form) form.parentNode.insertBefore(alert, form.nextSibling);\n else el.appendChild(alert);\n }\n alert.textContent = message;\n}\n\nfunction clearError(el) {\n const alert = el.querySelector('[role=\"alert\"]');\n if (alert) alert.textContent = '';\n}\n\nfunction attachSubmit(form, handler) {\n if (!form) return;\n form.addEventListener('submit', (event) => {\n event.preventDefault();\n handler();\n });\n}\n\n// \"Forget saved key\" control, inserted just before a post that was revealed\n// with a saved key. Clicking runs `onForget`, then replaces the button with a\n// focused status message (so keyboard focus is not lost).\nfunction addForgetButton(decrypted, labels, onForget) {\n const box = document.createElement('div');\n box.className = 'hbe hbe-forget';\n const button = document.createElement('button');\n button.type = 'button';\n button.className = 'hbe hbe-forget-button';\n button.textContent = labels.forget;\n const status = document.createElement('span');\n status.setAttribute('role', 'status');\n status.tabIndex = -1;\n button.addEventListener('click', () => {\n onForget();\n box.removeChild(button);\n status.textContent = labels.forgotten;\n status.focus();\n });\n box.appendChild(button);\n box.appendChild(status);\n decrypted.parentNode.insertBefore(box, decrypted);\n}\n\nmodule.exports = {\n findForm,\n findInput,\n ensureUniqueId,\n setBusy,\n trackFilled,\n refocus,\n showError,\n clearError,\n attachSubmit,\n addForgetButton,\n};\n", "'use strict';\n\n// Browser-side AES-256-GCM decryption with PBKDF2-SHA256 key derivation.\n// Mirrors the server-side parameters in `src/server/crypto.js`:\n// - PBKDF2: SHA-256, configurable iterations (read from data-kdf-iterations)\n// - AES: 256-bit key, GCM mode, 12-byte nonce, 16-byte auth tag\n//\n// Unified failure path: ANY thrown value (DOMException OperationError,\n// TypeError, etc.) collapses to {ok: false}. Wrong-password and\n// tampered-ciphertext are indistinguishable under GCM by design.\n\nconst KEY_BITS = 256;\nconst TAG_BITS = 128;\nconst TAG_BYTES = TAG_BITS / 8;\nconst TEXT_DECODER = new TextDecoder('utf-8', { fatal: true });\nconst TEXT_ENCODER = new TextEncoder();\n\nfunction hexToBytes(hex) {\n const len = hex.length;\n if (len % 2 !== 0) {\n throw new Error('hexo-blog-encrypt: hex string has odd length');\n }\n const out = new Uint8Array(len / 2);\n for (let i = 0; i < out.length; i++) {\n out[i] = parseInt(hex.substr(i * 2, 2), 16);\n }\n return out;\n}\n\nasync function deriveKey(password, salt, iterations) {\n const baseKey = await crypto.subtle.importKey(\n 'raw',\n TEXT_ENCODER.encode(password),\n { name: 'PBKDF2' },\n false,\n ['deriveKey']\n );\n return crypto.subtle.deriveKey(\n {\n name: 'PBKDF2',\n salt,\n iterations,\n hash: 'SHA-256',\n },\n baseKey,\n { name: 'AES-GCM', length: KEY_BITS },\n true, // extractable=true so storage.js can persist the raw key bytes when autoSave is on\n ['decrypt']\n );\n}\n\nasync function decryptWithKey(key, nonce, ciphertextWithTag) {\n // Web Crypto AES-GCM expects ciphertext||tag as a single buffer (same as Node's\n // `decipher.update + setAuthTag(tag); decipher.final()` flow when concatenated).\n const plainBuf = await crypto.subtle.decrypt(\n { name: 'AES-GCM', iv: nonce, tagLength: TAG_BITS },\n key,\n ciphertextWithTag\n );\n return TEXT_DECODER.decode(plainBuf);\n}\n\n// High-level: derive a key from the password + decrypt in one shot.\n// Returns {ok: true, plaintext, key} or {ok: false}.\nasync function tryDecryptWithPassword({ password, saltHex, nonceHex, ciphertextHex, iterations }) {\n try {\n const salt = hexToBytes(saltHex);\n const nonce = hexToBytes(nonceHex);\n const ciphertext = hexToBytes(ciphertextHex);\n if (ciphertext.length < TAG_BYTES) return { ok: false };\n const key = await deriveKey(password, salt, iterations);\n const plaintext = await decryptWithKey(key, nonce, ciphertext);\n return { ok: true, plaintext, key };\n } catch (_e) {\n return { ok: false };\n }\n}\n\n// Same shape, but reuses an already-derived key (autosave fast path).\nasync function tryDecryptWithKey({ key, nonceHex, ciphertextHex }) {\n try {\n const nonce = hexToBytes(nonceHex);\n const ciphertext = hexToBytes(ciphertextHex);\n if (ciphertext.length < TAG_BYTES) return { ok: false };\n const plaintext = await decryptWithKey(key, nonce, ciphertext);\n return { ok: true, plaintext };\n } catch (_e) {\n return { ok: false };\n }\n}\n\nmodule.exports = {\n tryDecryptWithPassword,\n tryDecryptWithKey,\n deriveKey,\n decryptWithKey,\n hexToBytes,\n};\n", "'use strict';\n\n// innerHTML leaves scripts inert. Attach the complete decrypted DOM first, then\n// restore executable scripts so initializers can find both content and libraries.\nconst SCRIPT_LOAD_TIMEOUT = 15000;\nconst JAVASCRIPT_TYPE = /^(?:application|text)\\/(?:x-)?(?:java|ecma)script$|^text\\/(?:javascript1\\.[0-5]|jscript|livescript)$/i;\n\nfunction getExecutableScript(oldScriptElement) {\n const newScript = document.createElement('script');\n for (const attr of oldScriptElement.attributes) {\n newScript.setAttribute(attr.name, attr.value);\n }\n // CSP hides the nonce attribute after attachment; the property retains it.\n if (oldScriptElement.nonce) newScript.nonce = oldScriptElement.nonce;\n newScript.text = oldScriptElement.text;\n return newScript;\n}\n\nfunction convertHTMLToElement(htmlString) {\n const wrapper = document.createElement('div');\n wrapper.innerHTML = htmlString;\n return wrapper;\n}\n\nfunction scriptType(script) {\n let type = script.getAttribute('type');\n if (type === null) {\n const language = script.getAttribute('language');\n type = language ? 'text/' + language : '';\n }\n const keyword = type.toLowerCase();\n if (keyword === 'module') return 'module';\n if (keyword === 'importmap' || keyword === 'speculationrules') return 'declarative';\n const mime = type.replace(/^[\\t\\n\\f\\r ]+|[\\t\\n\\f\\r ]+$/g, '');\n if (type === '' || JAVASCRIPT_TYPE.test(mime)) return 'classic';\n return 'data';\n}\n\nfunction restoreScript(oldScript, newScript, waitForLoad) {\n if (!waitForLoad) {\n oldScript.parentNode.replaceChild(newScript, oldScript);\n return Promise.resolve();\n }\n return new Promise((resolve) => {\n const finish = () => {\n clearTimeout(timer);\n newScript.removeEventListener('load', finish);\n newScript.removeEventListener('error', finish);\n resolve();\n };\n // A broken third-party dependency must not prevent the decrypt callback\n // forever. A timed-out script can still execute later; this is not a cancel.\n const timer = setTimeout(() => {\n console.warn('hexo-blog-encrypt: timed out waiting for a decrypted script to load.');\n finish();\n }, SCRIPT_LOAD_TIMEOUT);\n // Do not overwrite onload/onerror attributes copied from the original tag.\n newScript.addEventListener('load', finish);\n newScript.addEventListener('error', finish);\n oldScript.parentNode.replaceChild(newScript, oldScript);\n });\n}\n\nasync function restoreScripts(container) {\n const pending = [];\n const supportsModules = 'noModule' in document.createElement('script');\n for (const oldScript of container.querySelectorAll('script')) {\n // Earlier user scripts may remove later nodes. Do not execute detached ones.\n if (!container.contains(oldScript)) continue;\n const type = scriptType(oldScript);\n if (type === 'data' || (type === 'classic' && oldScript.noModule && supportsModules)) continue;\n if (type === 'module' && !supportsModules) continue;\n\n const newScript = getExecutableScript(oldScript);\n // Inline modules have no native load event. Keep their native async\n // semantics instead of adding a false timeout or rewriting their source.\n const waitForLoad = type !== 'declarative' && newScript.hasAttribute('src');\n const independent = waitForLoad && newScript.hasAttribute('async');\n // Dynamically created classics default to async even without the attribute.\n if (type === 'classic' && waitForLoad && !independent) newScript.async = false;\n const loaded = restoreScript(oldScript, newScript, waitForLoad);\n if (independent) pending.push(loaded);\n else await loaded;\n }\n await Promise.all(pending);\n}\n\n// Resolve after restored scripts load, fail, or time out. Native module load\n// events do not await arbitrary async work such as top-level await continuations.\nasync function swapInDecryptedDOM(mainElement, plaintextHTML) {\n const decrypted = convertHTMLToElement(plaintextHTML);\n decrypted.id = 'hexo-blog-encrypt';\n decrypted.classList.add('hbe', 'hbe-decrypted-content');\n mainElement.parentNode.replaceChild(decrypted, mainElement);\n await restoreScripts(decrypted);\n return decrypted;\n}\n\nmodule.exports = {\n getExecutableScript,\n convertHTMLToElement,\n swapInDecryptedDOM,\n};\n", "'use strict';\n\n// Per-post localStorage entry storing the derived AES key + the salt/nonce that\n// produced the corresponding ciphertext. On reload we re-import the key and\n// attempt decryption silently; the user is never re-prompted.\n//\n// Key: `hbe.v4.` + id, where id is the page path (+ `#<n>` for the 2nd+\n// encrypted post on the same page; see main.js#storageId).\n//\n// Schema (v4):\n// {\n// version: 4,\n// dk: base64(rawKeyBytes), // 32 bytes\n// salt: <hex64>, // matches data-salt\n// nonce: <hex24>, // retained for v4 schema compatibility\n// }\n//\n// IMPORTANT: when `autoSave` is false, save() is a no-op. When reading, any\n// entry with a non-4 version (or v3 leftovers like `hmk`/`hmacDigest`) is\n// purged + ignored.\n\nconst STORAGE_KEY_PREFIX = 'hbe.v4.';\nconst SCHEMA_VERSION = 4;\n\nfunction storageKey(id) {\n return STORAGE_KEY_PREFIX + id;\n}\n\nfunction bytesToBase64(bytes) {\n let bin = '';\n for (let i = 0; i < bytes.length; i++) bin += String.fromCharCode(bytes[i]);\n return btoa(bin);\n}\n\nfunction base64ToBytes(b64) {\n const bin = atob(b64);\n const out = new Uint8Array(bin.length);\n for (let i = 0; i < bin.length; i++) out[i] = bin.charCodeAt(i);\n return out;\n}\n\nasync function save({ id, key, saltHex, nonceHex, autoSave }) {\n if (!autoSave) return;\n try {\n const raw = await crypto.subtle.exportKey('raw', key);\n const entry = {\n version: SCHEMA_VERSION,\n dk: bytesToBase64(new Uint8Array(raw)),\n salt: saltHex,\n nonce: nonceHex,\n };\n localStorage.setItem(storageKey(id), JSON.stringify(entry));\n } catch (_e) {\n // localStorage.setItem can throw QuotaExceededError or SecurityError\n // (private mode, disabled storage). Silently ignore \u2014 autoSave is\n // best-effort UX.\n }\n}\n\nasync function load({ id, expectedSaltHex }) {\n let entry;\n try {\n const raw = localStorage.getItem(storageKey(id));\n if (!raw) return null;\n entry = JSON.parse(raw);\n } catch (_e) {\n return null;\n }\n\n // Purge stale or v3 entries.\n if (\n !entry\n || entry.version !== SCHEMA_VERSION\n || typeof entry.dk !== 'string'\n || typeof entry.salt !== 'string'\n || typeof entry.nonce !== 'string'\n || 'hmk' in entry\n || 'hmacDigest' in entry\n ) {\n try { localStorage.removeItem(storageKey(id)); } catch (_e) { /* ignore */ }\n return null;\n }\n\n // If the encrypted page's salt changed, the cached key is stale. Nonce is\n // not part of PBKDF2 key derivation; decrypt still uses the current page's\n // nonce and ciphertext, and failure clears the cache in main.js.\n if (entry.salt !== expectedSaltHex) {\n try { localStorage.removeItem(storageKey(id)); } catch (_e) { /* ignore */ }\n return null;\n }\n\n try {\n const rawBytes = base64ToBytes(entry.dk);\n const key = await crypto.subtle.importKey(\n 'raw',\n rawBytes,\n { name: 'AES-GCM' },\n true,\n ['decrypt']\n );\n return key;\n } catch (_e) {\n try { localStorage.removeItem(storageKey(id)); } catch (_e2) { /* ignore */ }\n return null;\n }\n}\n\nfunction clear(id) {\n try { localStorage.removeItem(storageKey(id)); } catch (_e) { /* ignore */ }\n}\n\n// v3 stored decrypted keys under `hexo-blog-encrypt:#<path>`. v4 never reads\n// them; remove them once per page load. Scoped to that exact prefix so\n// unrelated entries (other apps, similarly named keys) are left alone.\nconst LEGACY_V3_PREFIX = 'hexo-blog-encrypt:#';\nfunction purgeLegacy() {\n try {\n for (let i = localStorage.length - 1; i >= 0; i--) {\n const k = localStorage.key(i);\n if (k && k.indexOf(LEGACY_V3_PREFIX) === 0) localStorage.removeItem(k);\n }\n } catch (_e) { /* storage disabled \u2014 nothing to clean */ }\n}\n\nmodule.exports = {\n save,\n load,\n clear,\n purgeLegacy,\n STORAGE_KEY_PREFIX,\n SCHEMA_VERSION,\n};\n", "'use strict';\n\n// Browser-only messages (the configurable ones \u2014 wrong password, prompt,\n// button text \u2014 come from the server via data-* attributes). Language is\n// read from <html lang>: any `zh*` tag gets Chinese, everything else English.\n\nconst MESSAGES = {\n en: {\n incompatible: 'hexo-blog-encrypt: this page was built with an incompatible plugin version. ' +\n 'Rebuild the site after upgrading the plugin.',\n noCrypto: 'hexo-blog-encrypt: this browser cannot decrypt here because Web Crypto is unavailable. ' +\n 'Open the page over HTTPS (or localhost) in an up-to-date browser.',\n forget: 'Forget saved key',\n forgotten: 'Saved key forgotten.',\n },\n zh: {\n incompatible: 'hexo-blog-encrypt: \u6B64\u9875\u9762\u7531\u63D2\u4EF6\u7248\u672C\u4E0D\u517C\u5BB9\u7684\u6784\u5EFA\u751F\u6210. \u5347\u7EA7\u63D2\u4EF6\u540E\u8BF7\u91CD\u65B0\u6784\u5EFA\u7AD9\u70B9.',\n noCrypto: 'hexo-blog-encrypt: Web Crypto \u4E0D\u53EF\u7528, \u5F53\u524D\u6D4F\u89C8\u5668\u65E0\u6CD5\u5728\u6B64\u89E3\u5BC6. ' +\n '\u8BF7\u901A\u8FC7 HTTPS (\u6216 localhost) \u4F7F\u7528\u6700\u65B0\u7248\u6D4F\u89C8\u5668\u6253\u5F00\u6B64\u9875\u9762.',\n forget: '\u5FD8\u8BB0\u5DF2\u4FDD\u5B58\u7684\u5BC6\u94A5',\n forgotten: '\u5DF2\u5FD8\u8BB0\u4FDD\u5B58\u7684\u5BC6\u94A5.',\n },\n};\n\nfunction messages() {\n const lang = (document.documentElement.getAttribute('lang') || '').toLowerCase();\n return lang.indexOf('zh') === 0 ? MESSAGES.zh : MESSAGES.en;\n}\n\nmodule.exports = { messages };\n", "'use strict';\n\n// Browser entry point. Finds every encrypted-post wrapper on the page, drives\n// the UI via `ui.js`, derives & decrypts via `crypto.js`, and persists the\n// derived key (when autoSave is on) via `storage.js`.\n//\n// The bundle is injected once per encrypted post, so it may execute several\n// times on one page (index/archive pages, PJAX). Every wrapper is therefore\n// initialised exactly once, guarded by a flag on the element itself (shared by\n// all bundle executions), and every lookup is scoped to its wrapper.\n\nconst ui = require('./ui');\nconst cryptoMod = require('./crypto');\nconst dom = require('./dom');\nconst storage = require('./storage');\nconst i18n = require('./i18n');\n\nconst SUPPORTED_FORMAT = '4';\n// The iteration count always comes from `data-kdf-iterations`, which the\n// server writes for every post from its single default\n// (`DEFAULT_ITERATIONS` in src/server/crypto.js). This fallback only applies\n// to a hand-written theme that omits the attribute; a server unit test keeps\n// it equal to the server default.\nconst FALLBACK_KDF_ITERATIONS = 250000;\n// Any element a theme may use as the wrapper. Decrypted containers keep\n// id=\"hexo-blog-encrypt\", so they also match: that keeps each post's\n// position (and storage id) stable after earlier posts are revealed.\nconst WRAPPER = '[data-hbe-format],.hbe-container,#hexo-blog-encrypt';\nconst INIT_FLAG = '__hbeInit';\n\nfunction webCryptoAvailable() {\n return !!(window.isSecureContext && window.crypto && window.crypto.subtle);\n}\n\nfunction readWireFormat(el) {\n const ds = el.dataset;\n const ciphertextNode = el.querySelector('script#hbeData,script[type=\"hbeData\"]');\n return {\n format: ds.hbeFormat,\n wpm: ds.wpm || 'Wrong password.',\n whm: ds.whm || ds.wpm || 'Wrong password.',\n saltHex: ds.salt,\n nonceHex: ds.nonce,\n iterations: parseInt(ds.kdfIterations, 10) || FALLBACK_KDF_ITERATIONS,\n autoSave: ds.autoSave === 'true',\n ciphertextHex: ciphertextNode ? ciphertextNode.textContent.trim() : '',\n };\n}\n\nfunction dispatchDecryptEvent(mode, element) {\n // Fire on `window` for v3 back-compat \u2014 both READMEs document\n // `window.addEventListener('hexo-blog-decrypt', fn)` as the public API.\n // `detail.mode` is 'manual' | 'cached'; `detail.element` is the revealed\n // container, so pages with several encrypted posts can tell them apart.\n try {\n window.dispatchEvent(new CustomEvent('hexo-blog-decrypt', { detail: { mode, element } }));\n } catch (_e) {\n try {\n window.dispatchEvent(new Event('hexo-blog-decrypt'));\n } catch (_e2) { /* ignore \u2014 no event API at all */ }\n }\n}\n\n// Per-post storage id: the page URL, plus the post's position for the 2nd+\n// post on a page. The first post keeps the bare URL, so keys saved before\n// multi-post support keep working. The salt stored with each entry guards\n// against a post moving position (mismatch => entry dropped, re-prompt).\nfunction storageId(el) {\n const base = location.pathname + location.search;\n const index = Array.prototype.indexOf.call(document.querySelectorAll(WRAPPER), el);\n return index > 0 ? base + '#' + index : base;\n}\n\nfunction setup(el) {\n if (el[INIT_FLAG] || el.classList.contains('hbe-decrypted-content')) return;\n el[INIT_FLAG] = true;\n const wire = readWireFormat(el);\n const text = i18n.messages();\n\n if (wire.format !== SUPPORTED_FORMAT) {\n ui.showError(el, text.incompatible);\n return;\n }\n\n const form = ui.findForm(el);\n const input = ui.findInput(el);\n ui.ensureUniqueId(el, input);\n ui.trackFilled(input);\n const id = storageId(el);\n // autoSave turned off for this post (e.g. after a rebuild): forget any key\n // saved while it was on, so it stops unlocking on this device.\n if (!wire.autoSave) storage.clear(id);\n\n // Web Crypto only exists in secure contexts (HTTPS / localhost). Without\n // it every attempt would fail, so say why instead of \"wrong password\",\n // and never attempt a derivation.\n if (!webCryptoAvailable()) {\n ui.showError(el, text.noCrypto);\n ui.attachSubmit(form, () => ui.showError(el, text.noCrypto));\n return;\n }\n\n // Single-shot reveal guard: with autoSave on, the cached-key attempt runs\n // in parallel with the submit handler; whichever wins mutates the DOM.\n let revealed = false;\n const reveal = async (plaintext, mode) => {\n if (revealed) return;\n revealed = true;\n const decrypted = await dom.swapInDecryptedDOM(el, plaintext);\n if (mode === 'cached') {\n ui.addForgetButton(decrypted, text, () => storage.clear(id));\n }\n dispatchDecryptEvent(mode, decrypted);\n };\n\n ui.attachSubmit(form, async () => {\n ui.clearError(el);\n const password = input ? input.value : '';\n if (!password) {\n ui.showError(el, wire.wpm);\n ui.refocus(input);\n return;\n }\n ui.setBusy(form, input, true);\n let result;\n try {\n result = await cryptoMod.tryDecryptWithPassword({\n password,\n saltHex: wire.saltHex,\n nonceHex: wire.nonceHex,\n ciphertextHex: wire.ciphertextHex,\n iterations: wire.iterations,\n });\n } finally {\n ui.setBusy(form, input, false);\n }\n if (!result.ok) {\n ui.showError(el, wire.wpm);\n // Re-enabled by setBusy above, so focus/select work again.\n ui.refocus(input);\n return;\n }\n if (wire.autoSave) {\n await storage.save({ id, key: result.key, saltHex: wire.saltHex, nonceHex: wire.nonceHex, autoSave: true });\n }\n await reveal(result.plaintext, 'manual');\n });\n\n tryAutoDecrypt(wire, id, reveal).then((auto) => {\n // Focus the first locked post only; never steal focus from the reader.\n const active = document.activeElement;\n if (!auto && !revealed && input && (!active || active === document.body)) input.focus();\n });\n}\n\nasync function tryAutoDecrypt(wire, id, reveal) {\n if (!wire.autoSave) return false;\n const cachedKey = await storage.load({ id, expectedSaltHex: wire.saltHex });\n if (!cachedKey) return false;\n const result = await cryptoMod.tryDecryptWithKey({\n key: cachedKey,\n nonceHex: wire.nonceHex,\n ciphertextHex: wire.ciphertextHex,\n });\n if (!result.ok) {\n storage.clear(id);\n return false;\n }\n await reveal(result.plaintext, 'cached');\n return true;\n}\n\n// Public, idempotent initializer: sets up every not-yet-initialized wrapper\n// inside `root` (default: the whole document). Safe to call any number of\n// times, e.g. from a PJAX/SPA theme after swapping page content.\nfunction init(root) {\n root = root || document;\n const wrappers = Array.prototype.slice.call(root.querySelectorAll(WRAPPER));\n if (root.matches && root.matches(WRAPPER)) wrappers.unshift(root);\n for (let i = 0; i < wrappers.length; i++) setup(wrappers[i]);\n}\n\n// The bundle may execute once per post and again on every PJAX navigation.\n// Only the first execution exposes the API and registers listeners; later\n// ones just run init (wrappers are guarded per element).\nif (!window.hexoBlogEncrypt) {\n window.hexoBlogEncrypt = { init };\n storage.purgeLegacy();\n const rerun = () => window.hexoBlogEncrypt.init();\n ['pjax:complete', 'pjax:success', 'swup:contentReplaced', 'turbo:load'].forEach((name) => {\n document.addEventListener(name, rerun);\n });\n}\n\nif (document.readyState === 'loading') {\n document.addEventListener('DOMContentLoaded', () => init());\n} else {\n init();\n}\n"],
|
|
5
|
+
"mappings": "kHAAA,IAAAA,EAAAC,EAAA,CAAAC,GAAAC,IAAA,cAQA,SAASC,EAASC,EAAI,CACpB,OAAOA,EAAG,cAAc,yBAAyB,CACnD,CAEA,SAASC,EAAUD,EAAI,CACrB,OAAOA,EAAG,cAAc,kDAAkD,CAC5E,CAKA,IAAIE,EAAY,EAChB,SAASC,EAAeH,EAAII,EAAO,CACjC,GAAI,CAACA,EAAO,OACZ,IAAMC,EAAQD,EAAM,GACpB,GAAIC,GAAS,SAAS,eAAeA,CAAK,IAAMD,EAAO,OACvD,IAAIE,EACJ,GACEA,GAASD,GAAS,WAAa,KAAO,EAAEH,QACjC,SAAS,eAAeI,CAAK,GACtC,IAAMC,EAASP,EAAG,iBAAiB,OAAO,EAC1C,QAAS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EAAMD,CAAK,CACvC,CAAC,CACH,CAEI,SAAS,aAAe,UAC1B,SAAS,iBAAiB,mBAAoB,IAAMJ,EAAK,CAAC,EAE1DA,EAAK",
|
|
6
|
+
"names": ["require_ui", "__commonJSMin", "exports", "module", "findForm", "el", "findInput", "idCounter", "ensureUniqueId", "input", "oldId", "newId", "labels", "i", "setBusy", "form", "busy", "button", "trackFilled", "box", "sync", "refocus", "showError", "message", "alert", "clearError", "attachSubmit", "handler", "event", "addForgetButton", "decrypted", "onForget", "status", "require_crypto", "__commonJSMin", "exports", "module", "TEXT_DECODER", "TEXT_ENCODER", "hexToBytes", "hex", "len", "out", "i", "deriveKey", "password", "salt", "iterations", "baseKey", "decryptWithKey", "key", "nonce", "ciphertextWithTag", "plainBuf", "tryDecryptWithPassword", "saltHex", "nonceHex", "ciphertextHex", "ciphertext", "_e", "tryDecryptWithKey", "require_dom", "__commonJSMin", "exports", "module", "JAVASCRIPT_TYPE", "getExecutableScript", "oldScriptElement", "newScript", "attr", "convertHTMLToElement", "htmlString", "wrapper", "scriptType", "script", "type", "language", "keyword", "mime", "restoreScript", "oldScript", "waitForLoad", "resolve", "finish", "timer", "restoreScripts", "container", "pending", "supportsModules", "independent", "loaded", "swapInDecryptedDOM", "mainElement", "plaintextHTML", "decrypted", "require_storage", "__commonJSMin", "exports", "module", "STORAGE_KEY_PREFIX", "storageKey", "id", "bytesToBase64", "bytes", "bin", "i", "base64ToBytes", "b64", "out", "save", "key", "saltHex", "nonceHex", "autoSave", "raw", "entry", "_e", "load", "expectedSaltHex", "rawBytes", "_e2", "clear", "LEGACY_V3_PREFIX", "purgeLegacy", "k", "require_i18n", "__commonJSMin", "exports", "module", "MESSAGES", "messages", "ui", "cryptoMod", "dom", "storage", "i18n", "SUPPORTED_FORMAT", "FALLBACK_KDF_ITERATIONS", "WRAPPER", "INIT_FLAG", "webCryptoAvailable", "readWireFormat", "el", "ds", "ciphertextNode", "dispatchDecryptEvent", "mode", "element", "_e", "_e2", "storageId", "base", "index", "setup", "wire", "text", "form", "input", "id", "revealed", "reveal", "plaintext", "decrypted", "password", "result", "tryAutoDecrypt", "auto", "active", "cachedKey", "init", "root", "wrappers", "i", "rerun", "name"]
|
|
7
7
|
}
|
package/lib/hbe.default.html
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
{{hbeEncryptedData}}
|
|
11
11
|
</script>
|
|
12
12
|
<div class="hbe hbe-content">
|
|
13
|
-
<form id="hbeForm" class="hbe hbe-form"
|
|
13
|
+
<form id="hbeForm" class="hbe hbe-form">
|
|
14
14
|
<div class="hbe hbe-input hbe-input-default">
|
|
15
15
|
<input class="hbe hbe-input-field hbe-input-field-default" type="password" id="hbePass">
|
|
16
16
|
<label class="hbe hbe-input-label hbe-input-label-default" for="hbePass">
|
package/lib/hbe.flip.html
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
{{hbeEncryptedData}}
|
|
11
11
|
</script>
|
|
12
12
|
<div class="hbe hbe-content">
|
|
13
|
-
<form id="hbeForm" class="hbe hbe-form"
|
|
13
|
+
<form id="hbeForm" class="hbe hbe-form">
|
|
14
14
|
<div class="hbe hbe-input hbe-input-flip">
|
|
15
15
|
<input class="hbe hbe-input-field hbe-input-field-flip" type="password" id="hbePass">
|
|
16
16
|
<label class="hbe hbe-input-label hbe-input-label-flip" for="hbePass">
|
package/lib/hbe.shrink.html
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
{{hbeEncryptedData}}
|
|
11
11
|
</script>
|
|
12
12
|
<div class="hbe hbe-content">
|
|
13
|
-
<form id="hbeForm" class="hbe hbe-form"
|
|
13
|
+
<form id="hbeForm" class="hbe hbe-form">
|
|
14
14
|
<div class="hbe hbe-input hbe-input-shrink">
|
|
15
15
|
<input class="hbe hbe-input-field hbe-input-field-shrink" type="password" id="hbePass">
|
|
16
16
|
<label class="hbe hbe-input-label hbe-input-label-shrink" for="hbePass">
|
package/lib/hbe.style.css
CHANGED
|
@@ -272,7 +272,7 @@
|
|
|
272
272
|
}
|
|
273
273
|
|
|
274
274
|
.hbe-input-field-up:focus,
|
|
275
|
-
.input--filled .hbe-input-field-up {
|
|
275
|
+
.hbe-input--filled .hbe-input-field-up {
|
|
276
276
|
cursor: text;
|
|
277
277
|
opacity: 1;
|
|
278
278
|
-webkit-transition: opacity 0s 0.4s;
|
|
@@ -280,7 +280,7 @@
|
|
|
280
280
|
}
|
|
281
281
|
|
|
282
282
|
.hbe-input-field-up:focus + .hbe-input-label-up::before,
|
|
283
|
-
.input--filled .hbe-input-label-up::before {
|
|
283
|
+
.hbe-input--filled .hbe-input-label-up::before {
|
|
284
284
|
-webkit-transition-delay: 0.05s;
|
|
285
285
|
transition-delay: 0.05s;
|
|
286
286
|
-webkit-transform: translate3d(0, -3.3em, 0);
|
|
@@ -288,7 +288,7 @@
|
|
|
288
288
|
}
|
|
289
289
|
|
|
290
290
|
.hbe-input-field-up:focus + .hbe-input-label-up .hbe-input-label-content-up,
|
|
291
|
-
.input--filled .hbe-input-label-content-up {
|
|
291
|
+
.hbe-input--filled .hbe-input-label-content-up {
|
|
292
292
|
color: #6B6E6E;
|
|
293
293
|
-webkit-transform: translate3d(0, -3.3em, 0) scale3d(0.81, 0.81, 1);
|
|
294
294
|
transform: translate3d(0, -3.3em, 0) scale3d(0.81, 0.81, 1);
|
|
@@ -337,14 +337,14 @@
|
|
|
337
337
|
}
|
|
338
338
|
|
|
339
339
|
.hbe-input-field-wave:focus + .hbe-input-label-wave,
|
|
340
|
-
.input--filled .hbe-input-label-wave {
|
|
340
|
+
.hbe-input--filled .hbe-input-label-wave {
|
|
341
341
|
color: #333;
|
|
342
342
|
-webkit-transform: translate3d(0, -1.25em, 0) scale3d(0.75, 0.75, 1);
|
|
343
343
|
transform: translate3d(0, -1.25em, 0) scale3d(0.75, 0.75, 1);
|
|
344
344
|
}
|
|
345
345
|
|
|
346
346
|
.hbe-input-field-wave:focus ~ .hbe-graphic-wave,
|
|
347
|
-
.input--filled .graphic-wave {
|
|
347
|
+
.hbe-input--filled .hbe-graphic-wave {
|
|
348
348
|
stroke: #333;
|
|
349
349
|
-webkit-transform: translate3d(-66.6%, 0, 0);
|
|
350
350
|
transform: translate3d(-66.6%, 0, 0);
|
|
@@ -400,19 +400,19 @@
|
|
|
400
400
|
}
|
|
401
401
|
|
|
402
402
|
.hbe-input-field-flip:focus + .hbe-input-label-flip,
|
|
403
|
-
.input--filled .hbe-input-label-flip {
|
|
403
|
+
.hbe-input--filled .hbe-input-label-flip {
|
|
404
404
|
-webkit-transform: translate3d(0, 0, 0);
|
|
405
405
|
transform: translate3d(0, 0, 0);
|
|
406
406
|
}
|
|
407
407
|
|
|
408
408
|
.hbe-input-field-flip:focus + .hbe-input-label-flip .hbe-input-label-content-flip,
|
|
409
|
-
.input--filled .hbe-input-label-content-flip {
|
|
409
|
+
.hbe-input--filled .hbe-input-label-content-flip {
|
|
410
410
|
-webkit-transform: translate3d(0, 100%, 0);
|
|
411
411
|
transform: translate3d(0, 100%, 0);
|
|
412
412
|
}
|
|
413
413
|
|
|
414
|
-
.hbe-input-field-flip:focus
|
|
415
|
-
.input--filled .hbe-input-field-flip {
|
|
414
|
+
.hbe-input-field-flip:focus,
|
|
415
|
+
.hbe-input--filled .hbe-input-field-flip {
|
|
416
416
|
background-color: transparent;
|
|
417
417
|
border-color: #666666;
|
|
418
418
|
}
|
|
@@ -466,14 +466,14 @@
|
|
|
466
466
|
}
|
|
467
467
|
|
|
468
468
|
.hbe-input-field-xray:focus + .hbe-input-label-xray,
|
|
469
|
-
.input--filled .hbe-input-label-xray {
|
|
469
|
+
.hbe-input--filled .hbe-input-label-xray {
|
|
470
470
|
color: #84AF9B ;
|
|
471
471
|
-webkit-transform: translate3d(0, 3.5em, 0) scale3d(0.85, 0.85, 1);
|
|
472
472
|
transform: translate3d(0, 3.5em, 0) scale3d(0.85, 0.85, 1);
|
|
473
473
|
}
|
|
474
474
|
|
|
475
475
|
.hbe-input-field-xray:focus ~ .hbe-graphic-xray,
|
|
476
|
-
.input--filled .graphic-xray {
|
|
476
|
+
.hbe-input--filled .hbe-graphic-xray {
|
|
477
477
|
stroke: #84AF9B ;
|
|
478
478
|
-webkit-transform: translate3d(-66.6%, 0, 0);
|
|
479
479
|
transform: translate3d(-66.6%, 0, 0);
|
|
@@ -523,18 +523,18 @@
|
|
|
523
523
|
}
|
|
524
524
|
|
|
525
525
|
.hbe-input-field-blink:focus,
|
|
526
|
-
.input--filled .hbe-input-field-blink {
|
|
526
|
+
.hbe-input--filled .hbe-input-field-blink {
|
|
527
527
|
border-color: #8781bd ;
|
|
528
528
|
}
|
|
529
529
|
|
|
530
530
|
.hbe-input-field-blink:focus + .hbe-input-label-blink,
|
|
531
|
-
.input--filled .hbe-input-label-blink {
|
|
531
|
+
.hbe-input--filled .hbe-input-label-blink {
|
|
532
532
|
-webkit-animation: anim-blink-1 0.25s forwards;
|
|
533
533
|
animation: anim-blink-1 0.25s forwards;
|
|
534
534
|
}
|
|
535
535
|
|
|
536
536
|
.hbe-input-field-blink:focus + .hbe-input-label-blink .hbe-input-label-content-blink,
|
|
537
|
-
.input--filled .hbe-input-label-content-blink {
|
|
537
|
+
.hbe-input--filled .hbe-input-label-content-blink {
|
|
538
538
|
-webkit-animation: anim-blink-2 0.25s forwards ease-in;
|
|
539
539
|
animation: anim-blink-2 0.25s forwards ease-in;
|
|
540
540
|
}
|
|
@@ -663,14 +663,14 @@
|
|
|
663
663
|
}
|
|
664
664
|
|
|
665
665
|
.hbe-input-field-surge:focus,
|
|
666
|
-
.input--filled .hbe-input-field-surge {
|
|
666
|
+
.hbe-input--filled .hbe-input-field-surge {
|
|
667
667
|
-webkit-transition: opacity 0s 0.35s;
|
|
668
668
|
transition: opacity 0s 0.35s;
|
|
669
669
|
opacity: 1;
|
|
670
670
|
}
|
|
671
671
|
|
|
672
672
|
.hbe-input-field-surge:focus + .hbe-input-label-surge,
|
|
673
|
-
.input--filled .hbe-input-label-surge {
|
|
673
|
+
.hbe-input--filled .hbe-input-label-surge {
|
|
674
674
|
-webkit-transition-delay: 0.15s;
|
|
675
675
|
transition-delay: 0.15s;
|
|
676
676
|
-webkit-transform: translate3d(0, 0, 0);
|
|
@@ -678,7 +678,7 @@
|
|
|
678
678
|
}
|
|
679
679
|
|
|
680
680
|
.hbe-input-field-surge:focus + .hbe-input-label-surge .hbe-input-label-content-surge,
|
|
681
|
-
.input--filled .hbe-input-label-content-surge {
|
|
681
|
+
.hbe-input--filled .hbe-input-label-content-surge {
|
|
682
682
|
-webkit-transition-delay: 0.15s;
|
|
683
683
|
transition-delay: 0.15s;
|
|
684
684
|
-webkit-transform: translate3d(0, -100%, 0);
|
|
@@ -686,7 +686,7 @@
|
|
|
686
686
|
}
|
|
687
687
|
|
|
688
688
|
.hbe-input-field-surge:focus ~ .hbe-graphic-surge,
|
|
689
|
-
.input--filled .graphic-surge {
|
|
689
|
+
.hbe-input--filled .hbe-graphic-surge {
|
|
690
690
|
fill: #2C3E50;
|
|
691
691
|
-webkit-transform: translate3d(-66.6%, 0, 0);
|
|
692
692
|
transform: translate3d(-66.6%, 0, 0);
|
|
@@ -734,14 +734,14 @@
|
|
|
734
734
|
}
|
|
735
735
|
|
|
736
736
|
.hbe-input-field-shrink:focus + .hbe-input-label-shrink::after,
|
|
737
|
-
.input--filled .hbe-input-label-shrink::after {
|
|
737
|
+
.hbe-input--filled .hbe-input-label-shrink::after {
|
|
738
738
|
background: #84AF9B;
|
|
739
739
|
-webkit-transform: scale3d(1, 0.25, 1);
|
|
740
740
|
transform: scale3d(1, 0.25, 1);
|
|
741
741
|
}
|
|
742
742
|
|
|
743
743
|
.hbe-input-field-shrink:focus + .hbe-input-label-shrink .hbe-input-label-content-shrink,
|
|
744
|
-
.input--filled .hbe-input-label-shrink .hbe-input-label-content-shrink {
|
|
744
|
+
.hbe-input--filled .hbe-input-label-shrink .hbe-input-label-content-shrink {
|
|
745
745
|
color: #84AF9B;
|
|
746
746
|
-webkit-transform: translate3d(0, 2em, 0) scale3d(0.655, 0.655, 1);
|
|
747
747
|
transform: translate3d(0, 2em, 0) scale3d(0.655, 0.655, 1);
|
|
@@ -851,6 +851,36 @@ background: rgba(176, 0, 32, 0.08);
|
|
|
851
851
|
border-radius: 4px;
|
|
852
852
|
}
|
|
853
853
|
|
|
854
|
+
/* "Forget saved key" control, shown above a post revealed with a saved key. */
|
|
855
|
+
.hbe-forget {
|
|
856
|
+
margin: 0 0 1em;
|
|
857
|
+
font-size: 0.85rem;
|
|
858
|
+
font-family: "Avenir Next", "Helvetica Neue", Helvetica, Arial, sans-serif;
|
|
859
|
+
text-align: right;
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
.hbe-forget-button {
|
|
863
|
+
padding: 0.3em 0.8em;
|
|
864
|
+
font: inherit;
|
|
865
|
+
color: inherit;
|
|
866
|
+
background: transparent;
|
|
867
|
+
border: 1px solid currentColor;
|
|
868
|
+
border-radius: 4px;
|
|
869
|
+
opacity: 0.75;
|
|
870
|
+
cursor: pointer;
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
.hbe-forget-button:hover,
|
|
874
|
+
.hbe-forget-button:focus {
|
|
875
|
+
opacity: 1;
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
.hbe-forget-button:focus-visible,
|
|
879
|
+
.hbe-forget [role="status"]:focus-visible {
|
|
880
|
+
outline: 2px solid #2a7ae2;
|
|
881
|
+
outline-offset: 2px;
|
|
882
|
+
}
|
|
883
|
+
|
|
854
884
|
@media (prefers-color-scheme: dark) {
|
|
855
885
|
.hbe-input-field {
|
|
856
886
|
background: #2a2f36;
|
package/lib/hbe.surge.html
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
{{hbeEncryptedData}}
|
|
11
11
|
</script>
|
|
12
12
|
<div class="hbe hbe-content">
|
|
13
|
-
<form id="hbeForm" class="hbe hbe-form"
|
|
13
|
+
<form id="hbeForm" class="hbe hbe-form">
|
|
14
14
|
<div class="hbe hbe-input hbe-input-surge">
|
|
15
15
|
<input class="hbe hbe-input-field hbe-input-field-surge" type="password" id="hbePass">
|
|
16
16
|
<label class="hbe hbe-input-label hbe-input-label-surge" for="hbePass">
|
package/lib/hbe.up.html
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
{{hbeEncryptedData}}
|
|
11
11
|
</script>
|
|
12
12
|
<div class="hbe hbe-content">
|
|
13
|
-
<form id="hbeForm" class="hbe hbe-form"
|
|
13
|
+
<form id="hbeForm" class="hbe hbe-form">
|
|
14
14
|
<div class="hbe hbe-input hbe-input-up">
|
|
15
15
|
<input class="hbe hbe-input-field hbe-input-field-up" type="password" id="hbePass">
|
|
16
16
|
<label class="hbe hbe-input-label hbe-input-label-up" for="hbePass">
|
package/lib/hbe.wave.html
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
{{hbeEncryptedData}}
|
|
11
11
|
</script>
|
|
12
12
|
<div class="hbe hbe-content">
|
|
13
|
-
<form id="hbeForm" class="hbe hbe-form"
|
|
13
|
+
<form id="hbeForm" class="hbe hbe-form">
|
|
14
14
|
<div class="hbe hbe-input hbe-input-wave">
|
|
15
15
|
<input class="hbe hbe-input-field hbe-input-field-wave" type="password" id="hbePass">
|
|
16
16
|
<label class="hbe hbe-input-label hbe-input-label-wave" for="hbePass">
|
package/lib/hbe.xray.html
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
{{hbeEncryptedData}}
|
|
11
11
|
</script>
|
|
12
12
|
<div class="hbe hbe-content">
|
|
13
|
-
<form id="hbeForm" class="hbe hbe-form"
|
|
13
|
+
<form id="hbeForm" class="hbe hbe-form">
|
|
14
14
|
<div class="hbe hbe-input hbe-input-xray">
|
|
15
15
|
<input class="hbe hbe-input-field hbe-input-field-xray" type="password" id="hbePass">
|
|
16
16
|
<label class="hbe hbe-input-label hbe-input-label-xray" for="hbePass">
|
package/package.json
CHANGED
|
@@ -36,12 +36,12 @@
|
|
|
36
36
|
"prepare": "node build/prepare.js",
|
|
37
37
|
"pretest:server": "npm run build",
|
|
38
38
|
"test": "npm run lint && npm run test:server && npm run test:e2e",
|
|
39
|
-
"test:server": "node tests/helpers/install-fixture.js && c8 --reporter=text --reporter=lcov --include=index.js --include=src/server/**/*.js --check-coverage --lines=100 --functions=100 --branches=100 --statements=100 node --test tests/server/*.test.js tests/docs.test.js",
|
|
40
|
-
"test:e2e": "cd tests/fixtures/hexo-site && (test -d node_modules || npm install --no-audit --no-fund) && cd ../../.. && playwright install --with-deps chromium && playwright test --config tests/e2e/playwright.config.js",
|
|
41
|
-
"test:docs": "node --test tests/docs.test.js",
|
|
42
|
-
"lint": "eslint
|
|
39
|
+
"test:server": "node tests/helpers/install-fixture.js && c8 --reporter=text --reporter=lcov --include=index.js --include=src/server/**/*.js --check-coverage --lines=100 --functions=100 --branches=100 --statements=100 node --test tests/server/*.test.js tests/docs.test.js tests/skills.test.js",
|
|
40
|
+
"test:e2e": "cd tests/fixtures/hexo-site && (test -d node_modules || npm install --no-audit --no-fund) && cd ../../.. && playwright install --with-deps chromium firefox webkit && playwright test --config tests/e2e/playwright.config.js",
|
|
41
|
+
"test:docs": "node --test tests/docs.test.js tests/skills.test.js",
|
|
42
|
+
"lint": "eslint ."
|
|
43
43
|
},
|
|
44
|
-
"version": "4.0
|
|
44
|
+
"version": "4.1.0",
|
|
45
45
|
"engines": {
|
|
46
46
|
"node": ">=18"
|
|
47
47
|
},
|
|
@@ -49,10 +49,12 @@
|
|
|
49
49
|
"hexo": ">=5"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
52
|
+
"@eslint/js": "^10.0.1",
|
|
53
|
+
"@playwright/test": "^1.64.0",
|
|
54
|
+
"c8": "^12.0.0",
|
|
55
|
+
"esbuild": "^0.28.2",
|
|
56
|
+
"eslint": "^10.12.0",
|
|
57
|
+
"globals": "^17.13.0",
|
|
56
58
|
"hexo": "^7",
|
|
57
59
|
"hexo-renderer-marked": "^7"
|
|
58
60
|
}
|
package/src/server/config.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const { DEFAULT_ITERATIONS } = require('./crypto');
|
|
4
|
+
|
|
3
5
|
const FLOOR = 100000;
|
|
4
6
|
const RECOMMENDED = 600000;
|
|
5
7
|
|
|
@@ -19,10 +21,43 @@ const DEFAULTS = Object.freeze({
|
|
|
19
21
|
text: 'Decrypt',
|
|
20
22
|
}),
|
|
21
23
|
kdf: Object.freeze({
|
|
22
|
-
iterations:
|
|
24
|
+
iterations: DEFAULT_ITERATIONS, // single server-side default (#260)
|
|
25
|
+
}),
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// Localized user-facing defaults (#259). English lives in DEFAULTS; other
|
|
29
|
+
// locales override only these strings. Explicit config always wins.
|
|
30
|
+
const LOCALIZED_DEFAULTS = Object.freeze({
|
|
31
|
+
'zh-CN': Object.freeze({
|
|
32
|
+
abstract: '有东西被加密了, 请输入密码查看.',
|
|
33
|
+
message: '您好, 这里需要密码.',
|
|
34
|
+
wrong_pass_message: '抱歉, 这个密码看着不太对, 请再试试.',
|
|
35
|
+
decryptButton: Object.freeze({ text: '解密' }),
|
|
23
36
|
}),
|
|
24
37
|
});
|
|
25
38
|
|
|
39
|
+
// Map a language tag to a supported locale key. `zh`, `zh-CN`, `zh_CN` and
|
|
40
|
+
// `zh-Hans` select Simplified Chinese; everything else falls back to English.
|
|
41
|
+
function pickLocale(lang) {
|
|
42
|
+
const tag = typeof lang === 'string' ? lang.trim().toLowerCase().replace(/_/g, '-') : '';
|
|
43
|
+
if (tag === 'zh' || tag === 'zh-cn' || tag === 'zh-hans' || tag.startsWith('zh-hans-')) return 'zh-CN';
|
|
44
|
+
return 'en';
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Post `lang` / `language` front matter wins over the site `language`
|
|
48
|
+
// (which Hexo allows to be a list; the first entry is the primary language).
|
|
49
|
+
function languageOf(hexoConfig, post) {
|
|
50
|
+
if (typeof post.lang === 'string' && post.lang) return post.lang;
|
|
51
|
+
if (typeof post.language === 'string' && post.language) return post.language;
|
|
52
|
+
const site = hexoConfig && hexoConfig.language;
|
|
53
|
+
return Array.isArray(site) ? site[0] : site;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function localizedDefaults(hexoConfig, post) {
|
|
57
|
+
const locale = pickLocale(languageOf(hexoConfig, post));
|
|
58
|
+
return locale === 'en' ? DEFAULTS : deepMerge(DEFAULTS, LOCALIZED_DEFAULTS[locale]);
|
|
59
|
+
}
|
|
60
|
+
|
|
26
61
|
function clone(value) {
|
|
27
62
|
if (value === null || typeof value !== 'object') return value;
|
|
28
63
|
if (typeof structuredClone === 'function') return structuredClone(value);
|
|
@@ -81,6 +116,71 @@ const KNOWN_KEYS = [
|
|
|
81
116
|
'tags',
|
|
82
117
|
];
|
|
83
118
|
|
|
119
|
+
const BOOLEAN_KEYS = ['autoSave', 'stableSalt', 'silent'];
|
|
120
|
+
|
|
121
|
+
// Strict boolean parsing (#249). YAML `autoSave: "false"` is a truthy string;
|
|
122
|
+
// treating it by truthiness would silently enable key storage.
|
|
123
|
+
function toBoolean(value, label, log) {
|
|
124
|
+
if (typeof value === 'boolean') return value;
|
|
125
|
+
if (typeof value === 'string') {
|
|
126
|
+
const s = value.trim().toLowerCase();
|
|
127
|
+
if (s === 'true' || s === 'false') {
|
|
128
|
+
log.warn(
|
|
129
|
+
`hexo-blog-encrypt: ${label} is the string ${JSON.stringify(value)}; ` +
|
|
130
|
+
`treating it as ${s}. Remove the quotes to use a YAML boolean.`
|
|
131
|
+
);
|
|
132
|
+
return s === 'true';
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
throw new Error(
|
|
136
|
+
`hexo-blog-encrypt: ${label} must be a boolean (true or false), got ${JSON.stringify(value)}.`
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Returns a shallow copy of `picked` with boolean options validated.
|
|
141
|
+
// `prefix` names the config layer in messages ("encrypt." or "front-matter ").
|
|
142
|
+
function normalizeBooleans(picked, prefix, log) {
|
|
143
|
+
const out = Object.assign({}, picked);
|
|
144
|
+
for (const key of BOOLEAN_KEYS) {
|
|
145
|
+
if (out[key] !== undefined && out[key] !== null) {
|
|
146
|
+
out[key] = toBoolean(out[key], `${prefix}${key}`, log);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
const btn = out.decryptButton;
|
|
150
|
+
if (btn && typeof btn === 'object' && !Array.isArray(btn)
|
|
151
|
+
&& btn.show !== undefined && btn.show !== null) {
|
|
152
|
+
out.decryptButton = Object.assign({}, btn, {
|
|
153
|
+
show: toBoolean(btn.show, `${prefix}decryptButton.show`, log),
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
return out;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// Resolve a password value (#251). Literals (string/number/boolean) are used
|
|
160
|
+
// as-is; `{ env: NAME }` reads process.env[NAME] at build time. A missing or
|
|
161
|
+
// empty variable fails the build. Error messages name the variable, never the
|
|
162
|
+
// value, and the resolved value is never logged.
|
|
163
|
+
function resolvePasswordRef(value, postTitle) {
|
|
164
|
+
if (typeof value !== 'object') return String(value);
|
|
165
|
+
if (Array.isArray(value) || typeof value.env !== 'string' || value.env === '') {
|
|
166
|
+
throw new Error(
|
|
167
|
+
'hexo-blog-encrypt: password must be a string, a number, or { env: NAME } ' +
|
|
168
|
+
'(an object with a non-empty "env" variable name).'
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
const secret = process.env[value.env];
|
|
172
|
+
if (typeof secret !== 'string' || secret === '') {
|
|
173
|
+
const where = typeof postTitle === 'string' && postTitle.trim()
|
|
174
|
+
? ` for post "${postTitle.trim()}"`
|
|
175
|
+
: '';
|
|
176
|
+
throw new Error(
|
|
177
|
+
`hexo-blog-encrypt: password references environment variable ${value.env}${where}, ` +
|
|
178
|
+
'but it is not set or is empty. Set it in the build environment.'
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
return secret;
|
|
182
|
+
}
|
|
183
|
+
|
|
84
184
|
function resolve(hexoConfig, postData, logger) {
|
|
85
185
|
// Only `warn` is ever called from this module; keep the no-op default minimal.
|
|
86
186
|
const log = logger || { warn: () => {} };
|
|
@@ -97,13 +197,13 @@ function resolve(hexoConfig, postData, logger) {
|
|
|
97
197
|
const post = postData || {};
|
|
98
198
|
|
|
99
199
|
// Layer 1: defaults → hexo encrypt block (for top-level shared keys, NOT password/theme overrides per-post).
|
|
100
|
-
let merged = deepMerge(
|
|
200
|
+
let merged = deepMerge(localizedDefaults(hexoConfig, post), normalizeBooleans(shallowPickKnown(hexoEncrypt, KNOWN_KEYS), 'encrypt.', log));
|
|
101
201
|
|
|
102
202
|
// Layer 2: post front-matter wins. Use POST_KNOWN_KEYS (which excludes
|
|
103
203
|
// `tags`) to avoid pulling Hexo's Warehouse Query for `post.tags` into
|
|
104
204
|
// the deep-merge — `structuredClone` would throw DataCloneError on the
|
|
105
205
|
// function-bearing internals.
|
|
106
|
-
merged = deepMerge(merged, shallowPickKnown(post, POST_KNOWN_KEYS));
|
|
206
|
+
merged = deepMerge(merged, normalizeBooleans(shallowPickKnown(post, POST_KNOWN_KEYS), 'front-matter ', log));
|
|
107
207
|
|
|
108
208
|
// Deprecation: template → theme.
|
|
109
209
|
if (merged.template !== undefined && merged.template !== null) {
|
|
@@ -119,7 +219,7 @@ function resolve(hexoConfig, postData, logger) {
|
|
|
119
219
|
|
|
120
220
|
// Password: undefined or empty-string disables encryption (caller short-circuits).
|
|
121
221
|
if (merged.password === undefined || merged.password === null) return null;
|
|
122
|
-
merged.password =
|
|
222
|
+
merged.password = resolvePasswordRef(merged.password, post.title);
|
|
123
223
|
if (merged.password === '') return null;
|
|
124
224
|
|
|
125
225
|
// KDF iteration floor + warn band. (deepMerge always populates merged.kdf
|