this.me 2.4.6 β 2.4.8
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/README.md +16 -5
- package/hash/hashWorker.js +11 -0
- package/hash/hashing.js +43 -0
- package/main.js +13 -30
- package/package.json +3 -1
- package/testHashIt.js +3 -0
- package/tab.js +0 -29
package/README.md
CHANGED
|
@@ -25,9 +25,19 @@ npm install this.me
|
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
# Setting up your Context. ππ»ππΌππ½ππΎππΏ
|
|
29
29
|
Defining the environment and context in which your code runs, especially when you're interacting with intelligent agents or services likeΒ me.
|
|
30
|
-
Having a clear declaration of the environment and the context can have a series of implications for security, interoperability, and clarity.
|
|
30
|
+
Having a clear declaration of the environment and the context can have a series of implications for security, interoperability, and clarity.
|
|
31
|
+
|
|
32
|
+
The codebase is often vast, dynamic, and continually evolving.
|
|
33
|
+
|
|
34
|
+
Given the dynamic nature of such environments, ensuring the integrity of the code and data becomes paramount. You wouldn't want an agent to execute or rely on code that has been tampered with or is different from the expected version. This is where hashing comes into play.
|
|
35
|
+
|
|
36
|
+
The **SHA256 cryptographic hash function** is used to produce a unique, fixed-length sequence of characters (a hash) for the data. This setup does a thorough job of hashing the content of files or entire directories.
|
|
37
|
+
Even a tiny change in the content will result in a completely different hash.
|
|
38
|
+
[Read More.](https://www.neurons.me/this-me#h.sg59uu9ka8i8)
|
|
39
|
+
|
|
40
|
+
Let's delve into the importance of such declarations:
|
|
31
41
|
|
|
32
42
|
### Security Context:
|
|
33
43
|
Defining the environment ensures that both the user and the IA have a clear understanding of the boundary within which interactions take place.
|
|
@@ -42,6 +52,10 @@ Declaring the environment or context helps ensure that all systems are on the "s
|
|
|
42
52
|
For industries or applications where audit trails and compliance are important, having a clear declaration of the environment ensures that every interaction and operation can be traced back to a defined context.
|
|
43
53
|
Such clear demarcations can aid in forensic analysis if something goes wrong or if there's a need to understand the context of an interaction.
|
|
44
54
|
|
|
55
|
+
### Conclusion:
|
|
56
|
+
|
|
57
|
+
In the broader context of a dynamic and interactive environment like the one you're building, hashing becomes a powerful tool. It's not just about verifying code; it's about ensuring the entire ecosystem's security, integrity, and seamless operation. By employing a hashing mechanism, you're taking a proactive step towards establishing trust in the code and data that powers your system.
|
|
58
|
+
|
|
45
59
|
### Dependencies:
|
|
46
60
|
```json
|
|
47
61
|
"dependencies": {
|
|
@@ -62,7 +76,6 @@ Such clear demarcations can aid in forensic analysis if something goes wrong or
|
|
|
62
76
|
```
|
|
63
77
|
|
|
64
78
|
|
|
65
|
-
|
|
66
79
|
# Context of Abstraction for Machine Learning Standardization
|
|
67
80
|
|
|
68
81
|
Traditional web development elements, from images to audio, are designed mainly for display and interaction. But what if they could be seamlessly converted into standardized formats primed for machine learning? That's the vision behind the **this.** modules.
|
|
@@ -83,8 +96,6 @@ Rooted in JavaScript, the this. library builds upon public web development stand
|
|
|
83
96
|
|
|
84
97
|
The this. library champions open standards. By leveraging public web standards, it invites collaboration, hoping to create a community that continually refines and enhances the bridge between web development and machine learning.
|
|
85
98
|
|
|
86
|
-
|
|
87
|
-
|
|
88
99
|
[neurons.me](https://www.neurons.me)
|
|
89
100
|
|
|
90
101
|
[neurons.me/this](https://www.neurons.me/this)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const { getAllFiles, hashThis } = require('./path-to-your-main-file');
|
|
2
|
+
|
|
3
|
+
process.on('message', (directory) => {
|
|
4
|
+
try {
|
|
5
|
+
const files = getAllFiles(directory);
|
|
6
|
+
const hash = hashThis(files);
|
|
7
|
+
process.send({ success: true, hash });
|
|
8
|
+
} catch (error) {
|
|
9
|
+
process.send({ success: false, error: error.message });
|
|
10
|
+
}
|
|
11
|
+
});
|
package/hash/hashing.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
//hashing.js
|
|
2
|
+
//.. THIS SECTION IS FOR HASHING PURPOSES ...//
|
|
3
|
+
/* Create a function that computes the hash of the @src directory.
|
|
4
|
+
'hash-src') to handle hashing when the relevant command is passed to the script.*/
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const path = require('path');
|
|
7
|
+
const crypto = require('crypto');
|
|
8
|
+
|
|
9
|
+
function getAllFiles(directory) {
|
|
10
|
+
const stack = [directory];
|
|
11
|
+
const visited = new Set();
|
|
12
|
+
const filesList = [];
|
|
13
|
+
while (stack.length) {
|
|
14
|
+
const currentDir = stack.pop();
|
|
15
|
+
if (visited.has(currentDir)) continue;
|
|
16
|
+
visited.add(currentDir);
|
|
17
|
+
const contents = fs.readdirSync(currentDir, { withFileTypes: true });
|
|
18
|
+
for (const item of contents) {
|
|
19
|
+
const fullPath = path.join(currentDir, item.name);
|
|
20
|
+
if (item.isDirectory()) {
|
|
21
|
+
stack.push(fullPath);
|
|
22
|
+
} else if (item.isFile()) {
|
|
23
|
+
filesList.push(fullPath);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return filesList;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function hashThis(directory) {
|
|
31
|
+
const files = getAllFiles(directory);
|
|
32
|
+
const hash = crypto.createHash('sha256');
|
|
33
|
+
for (const file of files) {
|
|
34
|
+
const fileData = fs.readFileSync(file);
|
|
35
|
+
hash.update(fileData);
|
|
36
|
+
}
|
|
37
|
+
return hash.digest('hex');
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
module.exports = {
|
|
41
|
+
getAllFiles,
|
|
42
|
+
hashThis
|
|
43
|
+
};
|
package/main.js
CHANGED
|
@@ -28,6 +28,10 @@ Welcome to .me - Your AI Playground
|
|
|
28
28
|
give me one sec please...
|
|
29
29
|
`);
|
|
30
30
|
};
|
|
31
|
+
|
|
32
|
+
//User Context.
|
|
33
|
+
const os = require('os');
|
|
34
|
+
console.log(`Running as user: ${os.userInfo().username}`);
|
|
31
35
|
//ATOMS ELECTRONS AND PARTICLES IN PROGRESS...
|
|
32
36
|
//WE WILL RUN OUR NODE PROCCESSES IN ELECTRON WINDOWS AND EACH ATOM WILL HOLD ELECTRONS WHICH HOLDS THE PROCESSES
|
|
33
37
|
//THUS WE WILL KNOW HOW CHARGED AN ATOM IS BY THE NUMBER OF ELECTRONS IT HAS AND HOW MANY PROCESSES IT IS RUNNING.
|
|
@@ -63,35 +67,14 @@ function handleAtomCommand() {
|
|
|
63
67
|
|
|
64
68
|
//.. THIS SECTION IS FOR HASHING PURPOSES ...//
|
|
65
69
|
/* Create a function that computes the hash of the @src directory.
|
|
66
|
-
'
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const folders = entries.filter(folderDirent => folderDirent.isDirectory());
|
|
71
|
-
for (const folder of folders) {
|
|
72
|
-
files.push(...getAllFilesFromSourceCode(path.join(directory, folder.name)));
|
|
73
|
-
}
|
|
74
|
-
return files;
|
|
75
|
-
}
|
|
76
|
-
function hashSourceCode(directoryPath) {
|
|
77
|
-
// Ensure path is absolute
|
|
78
|
-
if (!path.isAbsolute(directoryPath)) {
|
|
79
|
-
throw new Error('Directory path must be absolute.');
|
|
80
|
-
}
|
|
81
|
-
// Get all files from the directory recursively
|
|
82
|
-
const allFiles = getAllFilesFromSourceCode(directoryPath);
|
|
83
|
-
// Read all file content and concatenate it
|
|
84
|
-
const allContent = allFiles.map(file => fs.readFileSync(file)).join('');
|
|
85
|
-
// Hash the content using SHA256 (or another hashing algorithm)
|
|
86
|
-
const hash = crypto.createHash('sha256').update(allContent).digest('hex');
|
|
87
|
-
return hash;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function HashSrc() {
|
|
70
|
+
'hashSrc') to handle hashing when the relevant command is passed to the script.*/
|
|
71
|
+
const { fork } = require('child_process');
|
|
72
|
+
const { getAllFiles, hashThis } = require('./hash/hashing');
|
|
73
|
+
function hashSrc() {
|
|
91
74
|
try {
|
|
92
75
|
// Adjust this to the exact location of your @src directory
|
|
93
76
|
const srcDirPath = path.resolve(__dirname, '@src');
|
|
94
|
-
const hash =
|
|
77
|
+
const hash = hashThis(srcDirPath);
|
|
95
78
|
console.log(`Hash of @src directory: ${hash}`);
|
|
96
79
|
} catch (error) {
|
|
97
80
|
console.error('Error hashing @src directory:', error.message);
|
|
@@ -104,7 +87,7 @@ displayWelcomeMessage();
|
|
|
104
87
|
// COMMAND HANDLERS
|
|
105
88
|
switch(args[0]) {
|
|
106
89
|
case 'hash-src':
|
|
107
|
-
|
|
90
|
+
hashSrc();
|
|
108
91
|
break;
|
|
109
92
|
case 'viewer':
|
|
110
93
|
handleViewerCommand();
|
|
@@ -120,7 +103,7 @@ module.exports = {
|
|
|
120
103
|
cleaker,
|
|
121
104
|
neurons,
|
|
122
105
|
Atom,
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
106
|
+
getAllFiles,
|
|
107
|
+
hashThis,
|
|
108
|
+
hashSrc
|
|
126
109
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "this.me",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.8",
|
|
4
4
|
"description": "This.me should This.be",
|
|
5
5
|
"bin": {
|
|
6
6
|
".me": "./main.js"
|
|
@@ -25,6 +25,8 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"be.this": "^1.1.3",
|
|
27
27
|
"cleaker": "^2.2.9",
|
|
28
|
+
"crypto": "^1.0.1",
|
|
29
|
+
"fs": "^0.0.1-security",
|
|
28
30
|
"i.mlearning": "^2.1.7",
|
|
29
31
|
"netget": "^2.1.6",
|
|
30
32
|
"neurons.me": "^2.6.3",
|
package/testHashIt.js
ADDED
package/tab.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
const { app, BrowserWindow, ipcMain } = require('electron');
|
|
2
|
-
let win;
|
|
3
|
-
app.on('ready', () => {
|
|
4
|
-
win = new BrowserWindow({
|
|
5
|
-
width: 377,
|
|
6
|
-
height: 244,
|
|
7
|
-
webPreferences: {
|
|
8
|
-
nodeIntegration: true,
|
|
9
|
-
contextIsolation: false, // Add this line
|
|
10
|
-
},
|
|
11
|
-
frame: false,
|
|
12
|
-
transparent: true,
|
|
13
|
-
//opacity: 0.5
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
win.on('closed', () => {
|
|
17
|
-
win = null;
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
win.loadFile('./atom/view.html');
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
ipcMain.on('minimize-window', () => {
|
|
24
|
-
win.minimize();
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
ipcMain.on('close-window', () => {
|
|
28
|
-
win.close();
|
|
29
|
-
});
|