@hobenakicoffee/libraries 1.20.0 → 1.21.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hobenakicoffee/libraries",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.21.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"types": "src/index.ts",
|
|
6
6
|
"exports": {
|
|
@@ -48,7 +48,8 @@
|
|
|
48
48
|
"./moderation": "./src/moderation/index.ts",
|
|
49
49
|
"./providers/theme-provider": "./src/providers/theme-provider.tsx",
|
|
50
50
|
"./types": "./src/types/index.ts",
|
|
51
|
-
"./utils": "./src/utils/index.ts"
|
|
51
|
+
"./utils": "./src/utils/index.ts",
|
|
52
|
+
"./scripts": "./src/scripts/index.ts"
|
|
52
53
|
},
|
|
53
54
|
"files": [
|
|
54
55
|
"src",
|
|
@@ -70,6 +71,7 @@
|
|
|
70
71
|
"prepublishOnly": "bun run test",
|
|
71
72
|
"check": "ultracite check",
|
|
72
73
|
"fix": "ultracite fix",
|
|
74
|
+
"check:env": "bun run src/scripts/check-env-encryption.ts",
|
|
73
75
|
"prepare": "lefthook install"
|
|
74
76
|
},
|
|
75
77
|
"devDependencies": {
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
|
|
3
|
+
export function checkEnvEncryption(
|
|
4
|
+
envFiles: string[] = [".env", ".env.production"]
|
|
5
|
+
) {
|
|
6
|
+
const ALLOWED = new Set([
|
|
7
|
+
"DOTENV_PUBLIC_KEY",
|
|
8
|
+
"DOTENV_PUBLIC_KEY_PRODUCTION",
|
|
9
|
+
]);
|
|
10
|
+
let hasError = false;
|
|
11
|
+
|
|
12
|
+
for (const file of envFiles) {
|
|
13
|
+
if (!existsSync(file)) {
|
|
14
|
+
console.warn(`⚠️ Skipping missing file: ${file}`);
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const text = readFileSync(file, "utf-8");
|
|
19
|
+
const lines = text.split("\n");
|
|
20
|
+
|
|
21
|
+
for (const line of lines) {
|
|
22
|
+
const trimmed = line.trim();
|
|
23
|
+
if (!trimmed || trimmed.startsWith("#")) continue;
|
|
24
|
+
const [key, ...rest] = trimmed.split("=");
|
|
25
|
+
if (!key || rest.length === 0) continue;
|
|
26
|
+
let value = rest.join("=").trim();
|
|
27
|
+
value = value.replace(/^['"]|['"]$/g, "");
|
|
28
|
+
if (ALLOWED.has(key)) continue;
|
|
29
|
+
if (!value.startsWith("encrypted:")) {
|
|
30
|
+
console.error(`❌ ${file} -> ${key} is not encrypted`);
|
|
31
|
+
hasError = true;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (hasError) {
|
|
37
|
+
console.error("\n🚨 Env encryption validation failed");
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
console.log("✅ All env variables are encrypted");
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// CLI support — works in both Bun and Node
|
|
44
|
+
const isMain =
|
|
45
|
+
process.argv[1] === import.meta.url.replace("file://", "") ||
|
|
46
|
+
// biome-ignore lint/correctness/noUndeclaredVariables: <optional check>
|
|
47
|
+
(typeof Bun !== "undefined" && import.meta.main);
|
|
48
|
+
|
|
49
|
+
if (isMain) {
|
|
50
|
+
checkEnvEncryption();
|
|
51
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./check-env-encryption";
|