@flaghoist/server 0.3.0 → 0.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/dist/index.cjs CHANGED
@@ -479,17 +479,19 @@ async function safeEqual(a, b) {
479
479
  }
480
480
  var MIN_SECRET_LENGTH = 16;
481
481
  var warnedWeakSecrets = /* @__PURE__ */ new Set();
482
+ function weakSecretKey(secret) {
483
+ let hash = 5381;
484
+ for (let i = 0; i < secret.length; i++) hash = (hash << 5) + hash ^ secret.charCodeAt(i);
485
+ return hash >>> 0;
486
+ }
482
487
  function warnIfWeakSecret(kind, secret) {
483
488
  if (secret.length >= MIN_SECRET_LENGTH) return;
484
- void (async () => {
485
- const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(secret));
486
- const id = Array.from(new Uint8Array(digest).slice(0, 6)).map((b) => b.toString(16).padStart(2, "0")).join("");
487
- if (warnedWeakSecrets.has(id)) return;
488
- warnedWeakSecrets.add(id);
489
- console.warn(
490
- `[flaghoist] the ${kind} is ${secret.length} characters. Use a long random value (for example \`openssl rand -hex 32\`); a short secret is guessable, especially since Flaghoist does not rate limit authentication.`
491
- );
492
- })();
489
+ const key = weakSecretKey(secret);
490
+ if (warnedWeakSecrets.has(key)) return;
491
+ warnedWeakSecrets.add(key);
492
+ console.warn(
493
+ `[flaghoist] the ${kind} is ${secret.length} characters. Use a long random value (for example \`openssl rand -hex 32\`); a short secret is guessable, especially since Flaghoist does not rate limit authentication.`
494
+ );
493
495
  }
494
496
  function apiKey(expected) {
495
497
  warnIfWeakSecret("read API key", expected);
package/dist/index.js CHANGED
@@ -449,17 +449,19 @@ async function safeEqual(a, b) {
449
449
  }
450
450
  var MIN_SECRET_LENGTH = 16;
451
451
  var warnedWeakSecrets = /* @__PURE__ */ new Set();
452
+ function weakSecretKey(secret) {
453
+ let hash = 5381;
454
+ for (let i = 0; i < secret.length; i++) hash = (hash << 5) + hash ^ secret.charCodeAt(i);
455
+ return hash >>> 0;
456
+ }
452
457
  function warnIfWeakSecret(kind, secret) {
453
458
  if (secret.length >= MIN_SECRET_LENGTH) return;
454
- void (async () => {
455
- const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(secret));
456
- const id = Array.from(new Uint8Array(digest).slice(0, 6)).map((b) => b.toString(16).padStart(2, "0")).join("");
457
- if (warnedWeakSecrets.has(id)) return;
458
- warnedWeakSecrets.add(id);
459
- console.warn(
460
- `[flaghoist] the ${kind} is ${secret.length} characters. Use a long random value (for example \`openssl rand -hex 32\`); a short secret is guessable, especially since Flaghoist does not rate limit authentication.`
461
- );
462
- })();
459
+ const key = weakSecretKey(secret);
460
+ if (warnedWeakSecrets.has(key)) return;
461
+ warnedWeakSecrets.add(key);
462
+ console.warn(
463
+ `[flaghoist] the ${kind} is ${secret.length} characters. Use a long random value (for example \`openssl rand -hex 32\`); a short secret is guessable, especially since Flaghoist does not rate limit authentication.`
464
+ );
463
465
  }
464
466
  function apiKey(expected) {
465
467
  warnIfWeakSecret("read API key", expected);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flaghoist/server",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Hono app factory for Flaghoist: OFREP evaluate, admin CRUD, and pluggable auth.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -49,8 +49,8 @@
49
49
  "@flaghoist/core": "0.1.2"
50
50
  },
51
51
  "devDependencies": {
52
- "@flaghoist/dashboard": "0.0.0",
53
- "@flaghoist/adapter-memory": "0.1.2"
52
+ "@flaghoist/adapter-memory": "0.1.2",
53
+ "@flaghoist/dashboard": "0.0.0"
54
54
  },
55
55
  "publishConfig": {
56
56
  "access": "public"