@ik-firewall/core 1.0.2 ā 2.3.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/dist/index.cjs +381 -97
- package/dist/index.d.cts +18 -3
- package/dist/index.d.ts +18 -3
- package/dist/index.js +371 -97
- package/package.json +6 -4
- package/scripts/setup-runtime.js +60 -19
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ik-firewall/core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "The core IK Firewall engine for semantic-driven AI optimization.",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -8,18 +8,20 @@
|
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
11
12
|
"import": "./dist/index.js",
|
|
12
|
-
"require": "./dist/index.cjs"
|
|
13
|
-
"types": "./dist/index.d.ts"
|
|
13
|
+
"require": "./dist/index.cjs"
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"files": [
|
|
17
17
|
"dist",
|
|
18
18
|
"scripts"
|
|
19
19
|
],
|
|
20
|
+
"api_endpoint": "https://ik-firewall.vercel.app/api/v1",
|
|
20
21
|
"scripts": {
|
|
21
22
|
"prepare": "npm run build",
|
|
22
23
|
"build": "tsup src/index.ts --format cjs,esm --dts --clean",
|
|
24
|
+
"build:wasm": "cd wasm-core && wasm-pack build --target nodejs",
|
|
23
25
|
"dev": "tsup src/index.ts --format cjs,esm --watch --dts",
|
|
24
26
|
"lint": "eslint src/**/*.ts",
|
|
25
27
|
"test": "jest",
|
|
@@ -35,7 +37,7 @@
|
|
|
35
37
|
"optimization"
|
|
36
38
|
],
|
|
37
39
|
"author": "Stefan Vasic",
|
|
38
|
-
"license": "
|
|
40
|
+
"license": "BSL-1.1",
|
|
39
41
|
"devDependencies": {
|
|
40
42
|
"@types/node": "^25.0.10",
|
|
41
43
|
"tsup": "^8.0.0",
|
package/scripts/setup-runtime.js
CHANGED
|
@@ -1,44 +1,85 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { fileURLToPath } from 'url';
|
|
4
|
+
import readline from 'node:readline';
|
|
4
5
|
|
|
5
6
|
const __filename = fileURLToPath(import.meta.url);
|
|
6
7
|
const __dirname = path.dirname(__filename);
|
|
7
8
|
|
|
8
9
|
// Constants
|
|
9
10
|
const BIN_DIR = path.join(__dirname, '..', '.bin');
|
|
10
|
-
const
|
|
11
|
-
const
|
|
11
|
+
const REGISTRY_DIR = path.join(process.cwd(), '.ik-adapter');
|
|
12
|
+
const REGISTRY_FILE = path.join(REGISTRY_DIR, 'registry.json');
|
|
13
|
+
|
|
14
|
+
async function askEmail() {
|
|
15
|
+
if (process.env.IK_EMAIL) return process.env.IK_EMAIL;
|
|
16
|
+
|
|
17
|
+
const rl = readline.createInterface({
|
|
18
|
+
input: process.stdin,
|
|
19
|
+
output: process.stdout
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const prompt = (query) => new Promise((resolve) => rl.question(query, resolve));
|
|
23
|
+
|
|
24
|
+
let email = "";
|
|
25
|
+
while (!email || !email.includes('@')) {
|
|
26
|
+
email = await prompt('\nš§ IK_FIREWALL: [MANDATORY] Please enter your email to activate your account: ');
|
|
27
|
+
if (!email || !email.includes('@')) {
|
|
28
|
+
console.log('ā ļø Invalid email. Email is required for license generation.');
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
rl.close();
|
|
32
|
+
return email;
|
|
33
|
+
}
|
|
12
34
|
|
|
13
35
|
async function setup() {
|
|
14
|
-
|
|
15
|
-
|
|
36
|
+
// Vercel / Netlify / AWS Lambda often have read-only file systems
|
|
37
|
+
if (process.env.VERCEL || process.env.RENDER || process.env.AWS_LAMBDA_FUNCTION_NAME) {
|
|
38
|
+
console.log('\nāļø IK_FIREWALL: Read-only Serverless environment detected.');
|
|
39
|
+
console.log('š” NOTE: Registry & Local Binary setup will be bypassed. Ensure you set "centralReportEndpoint" via code config.');
|
|
16
40
|
return;
|
|
17
41
|
}
|
|
18
|
-
console.log('š IK_FIREWALL: Initiating Zero-Config Runtime Setup...');
|
|
42
|
+
console.log('\nš IK_FIREWALL: Initiating Zero-Config Runtime Setup...');
|
|
19
43
|
|
|
20
|
-
// 1. Create .bin
|
|
21
|
-
|
|
22
|
-
fs.
|
|
23
|
-
|
|
44
|
+
// 1. Create .bin and .ik-adapter directories
|
|
45
|
+
[BIN_DIR, REGISTRY_DIR].forEach(dir => {
|
|
46
|
+
if (!fs.existsSync(dir)) {
|
|
47
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// 2. Initialize Trial Registry
|
|
52
|
+
if (!fs.existsSync(REGISTRY_FILE)) {
|
|
53
|
+
const email = await askEmail();
|
|
54
|
+
const initialRegistry = {
|
|
55
|
+
"default": {
|
|
56
|
+
"licenseKey": "TRIAL-" + Math.random().toString(36).substring(7).toUpperCase(),
|
|
57
|
+
"billingStatus": "trial",
|
|
58
|
+
"isVerified": true,
|
|
59
|
+
"firstUseDate": new Date().toISOString(),
|
|
60
|
+
"ownerEmail": email,
|
|
61
|
+
"isEnabled": true
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
const jsonStr = JSON.stringify(initialRegistry, null, 2);
|
|
65
|
+
const obfuscated = Buffer.from(jsonStr).toString('base64');
|
|
66
|
+
fs.writeFileSync(REGISTRY_FILE, obfuscated, 'utf8');
|
|
67
|
+
console.log(`⨠Trial activated for: ${email}`);
|
|
24
68
|
}
|
|
25
69
|
|
|
26
|
-
//
|
|
70
|
+
// 3. Detect OS & Architecture
|
|
27
71
|
const platform = process.platform;
|
|
28
72
|
const arch = process.arch;
|
|
29
73
|
console.log(`š Detected environment: ${platform}-${arch}`);
|
|
30
74
|
|
|
31
|
-
//
|
|
32
|
-
|
|
33
|
-
console.log(
|
|
34
|
-
console.log(
|
|
35
|
-
|
|
36
|
-
// Create a helper dev script in package.json context or similar
|
|
37
|
-
console.log('\nš¦ IK-Runtime environment prepared.');
|
|
38
|
-
console.log('⨠IK Adapter is now ready for local escalation testing!');
|
|
75
|
+
// 4. Usage Tips
|
|
76
|
+
console.log(`\nš¦ IK-Runtime environment prepared.`);
|
|
77
|
+
console.log('š” TIP: For local optimization (Sidecar), use "npm run start-ai".');
|
|
78
|
+
console.log('š ļø DEV: If building locally, you can use the Node.js Emulator: node scripts/runtime-emulator.js');
|
|
79
|
+
console.log('⨠IK Adapter is now ready for production-grade AI protection!\n');
|
|
39
80
|
}
|
|
40
81
|
|
|
41
82
|
setup().catch(err => {
|
|
42
83
|
console.error('ā IK_FIREWALL Setup Failed:', err.message);
|
|
43
|
-
process.exit(
|
|
84
|
+
process.exit(0); // Don't block install on setup error
|
|
44
85
|
});
|