hexo-blog-encrypt 4.1.0 → 4.2.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.
@@ -15,14 +15,14 @@ const CSS_PATH = path.join(REPO_ROOT, 'lib', 'hbe.style.css');
15
15
  const BUNDLE_PATH = path.join(REPO_ROOT, 'lib', 'hbe.bundle.js');
16
16
  const BUNDLE_SOURCEMAP_PATH = path.join(REPO_ROOT, 'lib', 'hbe.bundle.js.map');
17
17
 
18
- const FORMAT_VERSION = '4';
19
- const STABLE_SALT_NAMESPACE = 'hexo-blog-encrypt:v4:stableSalt:';
18
+ const FORMAT_VERSION = '5';
19
+ const STABLE_SALT_NAMESPACE = 'hexo-blog-encrypt:v5:stableSalt:';
20
20
 
21
21
  // Per-instance Symbol so user front-matter keys can never collide with our
22
22
  // idempotence marker. We deliberately do NOT use Symbol.for(...) (a global
23
23
  // registry) — a per-process Symbol guarantees external code cannot fabricate
24
24
  // the marker even by accident.
25
- const HBE_ENCRYPTED = Symbol('hexo-blog-encrypt.v4.encrypted');
25
+ const HBE_ENCRYPTED = Symbol('hexo-blog-encrypt.v5.encrypted');
26
26
 
27
27
  function normalizeRoot(root) {
28
28
  if (typeof root !== 'string') return '/';
@@ -91,7 +91,7 @@ function register(hexo) {
91
91
  sourcemapPath: BUNDLE_SOURCEMAP_PATH,
92
92
  });
93
93
 
94
- hexo.extend.filter.register('after_post_render', async function v4Filter(data) {
94
+ hexo.extend.filter.register('after_post_render', async function v5Filter(data) {
95
95
  // Idempotence: stamp a per-instance Symbol on `data` after a successful
96
96
  // pass so re-entry on the same object is a no-op. We deliberately do NOT
97
97
  // use `data.encrypt === true` (a user-set "please encrypt" front-matter
@@ -154,7 +154,7 @@ function register(hexo) {
154
154
  && typeof data.permalink === 'string'
155
155
  && data.permalink.length > 0;
156
156
  const { salt, nonce, ciphertext } = await encrypt(plaintext, cfg.password, {
157
- iterations: cfg.kdf.iterations,
157
+ kdf: cfg.kdf,
158
158
  salt: stableSaltEnabled ? stableSaltFromPermalink(data.permalink) : undefined,
159
159
  });
160
160
 
@@ -175,20 +175,18 @@ function register(hexo) {
175
175
  whm: cfg.wrong_hash_message,
176
176
  buttonClass: buttonShow ? '' : ' hbe-button-hidden',
177
177
  buttonText,
178
- kdfIterations: cfg.kdf.iterations,
178
+ kdfIterations: cfg.kdf.N ?? cfg.kdf.iterations,
179
179
  autoSave: !!cfg.autoSave,
180
180
  });
181
181
 
182
182
  const root = normalizeRoot(hexo.config && hexo.config.root);
183
- const routes = assetGenerator();
184
- const jsRoute = routes.find((r) => /^lib\/hbe\.[0-9a-f]{10}\.js$/.test(r.path));
185
- const cssRoute = routes.find((r) => r.path === 'css/hbe.style.css');
183
+ const [cssRoute, jsRoute] = assetGenerator();
186
184
  const jsHref = root + jsRoute.path;
187
185
  const cssHref = root + cssRoute.path;
188
186
 
189
187
  data.content = rendered +
190
- `<script data-pjax src="${jsHref}"></script>` +
191
- `<link href="${cssHref}" rel="stylesheet" type="text/css">`;
188
+ `<script data-pjax src="${jsHref}" integrity="${jsRoute.integrity}" crossorigin="anonymous"></script>` +
189
+ `<link href="${cssHref}" rel="stylesheet" type="text/css" integrity="${cssRoute.integrity}" crossorigin="anonymous">`;
192
190
  data.encrypt = true;
193
191
  data.excerpt = data.more = cfg.abstract;
194
192
  data[HBE_ENCRYPTED] = true;