@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ik-firewall/core",
3
- "version": "1.0.2",
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": "MIT",
40
+ "license": "BSL-1.1",
39
41
  "devDependencies": {
40
42
  "@types/node": "^25.0.10",
41
43
  "tsup": "^8.0.0",
@@ -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 RUNTIME_NAME = process.platform === 'win32' ? 'ik-runtime.exe' : 'ik-runtime';
11
- const MODEL_NAME = 'ik-local-1b-v1.gguf';
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
- if (process.env.CI || process.env.VERCEL) {
15
- console.log('ā­ļø IK_FIREWALL: CI/Vercel environment detected. Skipping local runtime setup.');
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 directory
21
- if (!fs.existsSync(BIN_DIR)) {
22
- fs.mkdirSync(BIN_DIR, { recursive: true });
23
- console.log(`āœ… Created directory: ${BIN_DIR}`);
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
- // 2. Detect OS & Architecture
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
- // 3. Inform user about the Emulator (since binary is OS-dependent)
32
- const emulatorPath = path.join(__dirname, 'runtime-emulator.js');
33
- console.log(`\nšŸ’” TIP: For this prototype on Windows, use the Node.js Emulator instead of the .exe:`);
34
- console.log(` node scripts/runtime-emulator.js`);
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(1);
84
+ process.exit(0); // Don't block install on setup error
44
85
  });