stigmergy 1.0.97 → 1.0.98

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.
@@ -3,7 +3,7 @@
3
3
  * Provides secure data encryption and decryption functions using AES-256-GCM
4
4
  */
5
5
 
6
- const crypto = require("crypto");
6
+ const crypto = require('crypto');
7
7
 
8
8
  /**
9
9
  * Encrypts data using AES-256-GCM authenticated encryption
@@ -32,26 +32,26 @@ const crypto = require("crypto");
32
32
  function encryptData(data, secretKey) {
33
33
  // Validate inputs
34
34
  if (!data) {
35
- throw new Error("Data to encrypt cannot be empty");
35
+ throw new Error('Data to encrypt cannot be empty');
36
36
  }
37
37
 
38
38
  if (!secretKey) {
39
- throw new Error("Secret key is required");
39
+ throw new Error('Secret key is required');
40
40
  }
41
41
 
42
42
  // Generate a random initialization vector
43
43
  const iv = crypto.randomBytes(16);
44
44
 
45
45
  // Create cipher using AES-256-GCM
46
- const cipher = crypto.createCipherGCM("aes-256-gcm", secretKey, iv);
46
+ const cipher = crypto.createCipherGCM('aes-256-gcm', secretKey, iv);
47
47
 
48
48
  // Encrypt the data
49
49
  let encrypted;
50
- if (typeof data === "string") {
51
- encrypted = cipher.update(data, "utf8", "hex");
50
+ if (typeof data === 'string') {
51
+ encrypted = cipher.update(data, 'utf8', 'hex');
52
52
  } else {
53
53
  encrypted = cipher.update(data);
54
- encrypted = encrypted.toString("hex");
54
+ encrypted = encrypted.toString('hex');
55
55
  }
56
56
  cipher.final();
57
57
 
@@ -61,8 +61,8 @@ function encryptData(data, secretKey) {
61
61
  // Return encrypted data with IV and auth tag
62
62
  return {
63
63
  encryptedData: encrypted,
64
- iv: iv.toString("base64"),
65
- authTag: authTag.toString("base64"),
64
+ iv: iv.toString('base64'),
65
+ authTag: authTag.toString('base64'),
66
66
  };
67
67
  }
68
68
 
@@ -90,30 +90,30 @@ function decryptData(encryptedObj, secretKey) {
90
90
  !encryptedObj.iv ||
91
91
  !encryptedObj.authTag
92
92
  ) {
93
- throw new Error("Invalid encrypted object");
93
+ throw new Error('Invalid encrypted object');
94
94
  }
95
95
 
96
96
  if (!secretKey) {
97
- throw new Error("Secret key is required");
97
+ throw new Error('Secret key is required');
98
98
  }
99
99
 
100
100
  // Decode base64 encoded values
101
- const iv = Buffer.from(encryptedObj.iv, "base64");
102
- const authTag = Buffer.from(encryptedObj.authTag, "base64");
101
+ const iv = Buffer.from(encryptedObj.iv, 'base64');
102
+ const authTag = Buffer.from(encryptedObj.authTag, 'base64');
103
103
 
104
104
  // Create decipher using AES-256-GCM
105
- const decipher = crypto.createDecipherGCM("aes-256-gcm", secretKey, iv);
105
+ const decipher = crypto.createDecipherGCM('aes-256-gcm', secretKey, iv);
106
106
 
107
107
  // Set the authentication tag
108
108
  decipher.setAuthTag(authTag);
109
109
 
110
110
  // Decrypt the data
111
111
  let decrypted;
112
- if (typeof encryptedObj.encryptedData === "string") {
113
- decrypted = decipher.update(encryptedObj.encryptedData, "hex", "utf8");
112
+ if (typeof encryptedObj.encryptedData === 'string') {
113
+ decrypted = decipher.update(encryptedObj.encryptedData, 'hex', 'utf8');
114
114
  } else {
115
115
  decrypted = decipher.update(encryptedObj.encryptedData);
116
- decrypted = decrypted.toString("utf8");
116
+ decrypted = decrypted.toString('utf8');
117
117
  }
118
118
  decipher.final();
119
119
 
@@ -11,13 +11,13 @@ class HashTable {
11
11
  * @param {number} size - Initial size of the hash table
12
12
  * @param {string} collisionStrategy - Collision handling strategy ('chaining' or 'openAddressing')
13
13
  */
14
- constructor(size = 53, collisionStrategy = "chaining") {
14
+ constructor(size = 53, collisionStrategy = 'chaining') {
15
15
  this.size = size;
16
16
  this.collisionStrategy = collisionStrategy;
17
17
 
18
- if (collisionStrategy === "chaining") {
18
+ if (collisionStrategy === 'chaining') {
19
19
  this.buckets = new Array(size).fill(null).map(() => []);
20
- } else if (collisionStrategy === "openAddressing") {
20
+ } else if (collisionStrategy === 'openAddressing') {
21
21
  this.buckets = new Array(size).fill(null);
22
22
  this.deleted = new Array(size).fill(false);
23
23
  } else {
@@ -36,7 +36,7 @@ class HashTable {
36
36
  * @returns {number} Index in the hash table
37
37
  */
38
38
  _hash(key) {
39
- if (typeof key === "number") {
39
+ if (typeof key === 'number') {
40
40
  return key % this.size;
41
41
  }
42
42
 
@@ -56,7 +56,7 @@ class HashTable {
56
56
  * @returns {number} Secondary hash value
57
57
  */
58
58
  _hash2(key) {
59
- if (typeof key === "number") {
59
+ if (typeof key === 'number') {
60
60
  return 7 - (key % 7);
61
61
  }
62
62
 
@@ -80,7 +80,7 @@ class HashTable {
80
80
  this.size *= 2;
81
81
  this.count = 0;
82
82
 
83
- if (this.collisionStrategy === "chaining") {
83
+ if (this.collisionStrategy === 'chaining') {
84
84
  this.buckets = new Array(this.size).fill(null).map(() => []);
85
85
  } else {
86
86
  this.buckets = new Array(this.size).fill(null);
@@ -88,7 +88,7 @@ class HashTable {
88
88
  }
89
89
 
90
90
  // Rehash all existing elements
91
- if (this.collisionStrategy === "chaining") {
91
+ if (this.collisionStrategy === 'chaining') {
92
92
  for (let i = 0; i < oldSize; i++) {
93
93
  const bucket = oldBuckets[i];
94
94
  if (bucket) {
@@ -118,7 +118,7 @@ class HashTable {
118
118
  this._resize();
119
119
  }
120
120
 
121
- if (this.collisionStrategy === "chaining") {
121
+ if (this.collisionStrategy === 'chaining') {
122
122
  return this._setChaining(key, value);
123
123
  } else {
124
124
  return this._setOpenAddressing(key, value);
@@ -196,7 +196,7 @@ class HashTable {
196
196
  * @returns {*} The value associated with the key, or undefined if not found
197
197
  */
198
198
  get(key) {
199
- if (this.collisionStrategy === "chaining") {
199
+ if (this.collisionStrategy === 'chaining') {
200
200
  return this._getChaining(key);
201
201
  } else {
202
202
  return this._getOpenAddressing(key);
@@ -252,7 +252,7 @@ class HashTable {
252
252
  * @returns {boolean} True if the key was found and deleted, false otherwise
253
253
  */
254
254
  delete(key) {
255
- if (this.collisionStrategy === "chaining") {
255
+ if (this.collisionStrategy === 'chaining') {
256
256
  return this._deleteChaining(key);
257
257
  } else {
258
258
  return this._deleteOpenAddressing(key);
@@ -322,7 +322,7 @@ class HashTable {
322
322
  keys() {
323
323
  const keysArr = [];
324
324
 
325
- if (this.collisionStrategy === "chaining") {
325
+ if (this.collisionStrategy === 'chaining') {
326
326
  for (let i = 0; i < this.size; i++) {
327
327
  const bucket = this.buckets[i];
328
328
  if (bucket) {
@@ -349,7 +349,7 @@ class HashTable {
349
349
  values() {
350
350
  const valuesArr = [];
351
351
 
352
- if (this.collisionStrategy === "chaining") {
352
+ if (this.collisionStrategy === 'chaining') {
353
353
  for (let i = 0; i < this.size; i++) {
354
354
  const bucket = this.buckets[i];
355
355
  if (bucket) {
@@ -376,7 +376,7 @@ class HashTable {
376
376
  entries() {
377
377
  const entriesArr = [];
378
378
 
379
- if (this.collisionStrategy === "chaining") {
379
+ if (this.collisionStrategy === 'chaining') {
380
380
  for (let i = 0; i < this.size; i++) {
381
381
  const bucket = this.buckets[i];
382
382
  if (bucket) {
@@ -400,7 +400,7 @@ class HashTable {
400
400
  * Clear the hash table
401
401
  */
402
402
  clear() {
403
- if (this.collisionStrategy === "chaining") {
403
+ if (this.collisionStrategy === 'chaining') {
404
404
  this.buckets = new Array(this.size).fill(null).map(() => []);
405
405
  } else {
406
406
  this.buckets = new Array(this.size).fill(null);
package/src/deploy.js CHANGED
@@ -5,38 +5,38 @@
5
5
  * This script deploys hooks and integrations for all available CLI tools
6
6
  */
7
7
 
8
- const fs = require("fs").promises;
9
- const path = require("path");
10
- const os = require("os");
8
+ const fs = require('fs').promises;
9
+ const path = require('path');
10
+ const os = require('os');
11
11
 
12
12
  // Import the main Stigmergy installer
13
- const { StigmergyInstaller } = require("./main_english.js");
13
+ const { StigmergyInstaller } = require('./main_english.js');
14
14
 
15
15
  // Set up global error handlers using our error handler module
16
- const { setupGlobalErrorHandlers } = require("./core/error_handler");
16
+ const { setupGlobalErrorHandlers } = require('./core/error_handler');
17
17
  setupGlobalErrorHandlers();
18
18
 
19
19
  async function deploy() {
20
- console.log("Stigmergy Deployment Script");
21
- console.log("==========================");
20
+ console.log('Stigmergy Deployment Script');
21
+ console.log('==========================');
22
22
 
23
23
  try {
24
24
  // Create installer instance
25
25
  const installer = new StigmergyInstaller();
26
26
 
27
27
  // Scan for available tools
28
- console.log("[SCAN] Scanning for available CLI tools...");
28
+ console.log('[SCAN] Scanning for available CLI tools...');
29
29
  const scanResult = await installer.scanCLI();
30
30
  const available = scanResult.available;
31
31
 
32
32
  // Deploy hooks for all available tools
33
- console.log("[DEPLOY] Deploying hooks for all available tools...");
33
+ console.log('[DEPLOY] Deploying hooks for all available tools...');
34
34
  await installer.deployHooks(available);
35
35
 
36
- console.log("\n[SUCCESS] Deployment completed successfully!");
36
+ console.log('\n[SUCCESS] Deployment completed successfully!');
37
37
  return true;
38
38
  } catch (error) {
39
- console.error("[ERROR] Deployment failed:", error.message);
39
+ console.error('[ERROR] Deployment failed:', error.message);
40
40
  return false;
41
41
  }
42
42
  }
@@ -48,7 +48,7 @@ if (require.main === module) {
48
48
  process.exit(success ? 0 : 1);
49
49
  })
50
50
  .catch((error) => {
51
- console.error("[FATAL ERROR]:", error.message);
51
+ console.error('[FATAL ERROR]:', error.message);
52
52
  process.exit(1);
53
53
  });
54
54
  }
package/src/index.js CHANGED
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  // Import and export the main functionality from main.js
9
- require("./main.js");
9
+ require('./main.js');