this.me 2.7.7 → 2.7.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 +82 -58
- package/docs/Me.html +697 -0
- package/docs/README.md +91 -0
- package/docs/ThisMe.html +690 -0
- package/docs/cli_main.js.html +340 -0
- package/docs/fonts/OpenSans-Bold-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Bold-webfont.svg +1830 -0
- package/docs/fonts/OpenSans-Bold-webfont.woff +0 -0
- package/docs/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
- package/docs/fonts/OpenSans-BoldItalic-webfont.svg +1830 -0
- package/docs/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
- package/docs/fonts/OpenSans-Italic-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Italic-webfont.svg +1830 -0
- package/docs/fonts/OpenSans-Italic-webfont.woff +0 -0
- package/docs/fonts/OpenSans-Light-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Light-webfont.svg +1831 -0
- package/docs/fonts/OpenSans-Light-webfont.woff +0 -0
- package/docs/fonts/OpenSans-LightItalic-webfont.eot +0 -0
- package/docs/fonts/OpenSans-LightItalic-webfont.svg +1835 -0
- package/docs/fonts/OpenSans-LightItalic-webfont.woff +0 -0
- package/docs/fonts/OpenSans-Regular-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Regular-webfont.svg +1831 -0
- package/docs/fonts/OpenSans-Regular-webfont.woff +0 -0
- package/docs/global.html +454 -0
- package/docs/index.html +258 -0
- package/docs/me.js.html +211 -0
- package/docs/module-CLI.html +963 -0
- package/docs/neurons_logo.png +0 -0
- package/docs/scripts/app.min.js +1 -0
- package/docs/scripts/linenumber.js +26 -0
- package/docs/scripts/prettify/Apache-License-2.0.txt +202 -0
- package/docs/scripts/prettify/lang-css.js +2 -0
- package/docs/scripts/prettify/prettify.js +28 -0
- package/docs/scripts/search.js +39 -0
- package/docs/styles/app.min.css +1 -0
- package/docs/styles/iframe.css +13 -0
- package/docs/styles/jsdoc-default.css +358 -0
- package/docs/styles/prettify-jsdoc.css +111 -0
- package/docs/styles/prettify-tomorrow.css +132 -0
- package/docs/styles/reset.css +44 -0
- package/jsdoc.json +43 -0
- package/package.json +22 -29
- package/src/cli/main.js +176 -0
- package/src/env.js +8 -0
- package/{me.html → src/me.html} +1 -0
- package/src/me.js +47 -0
- package/src/os/unix/install_me.sh +5 -0
- package/src/this/video.js +0 -0
- package/Me.js +0 -71
- package/crypto/crypto-browser.js +0 -20
- package/crypto/crypto-node.js +0 -16
- package/crypto/hash/hashWorker.js +0 -11
- package/crypto/hash/hashing.js +0 -43
- package/demo.js +0 -12
- package/main.js +0 -77
- package/me2.js +0 -57
- package/src/errorHandler.js +0 -9
- package/test.js +0 -36
- package/testHashIt.js +0 -3
- package/webpack.config.js +0 -18
- /package/{this/dir.js → index.js} +0 -0
- /package/{this/file.js → src/this/dir.js} +0 -0
- /package/{this/url.js → src/this/file.js} +0 -0
- /package/{this/video.js → src/this/url.js} +0 -0
package/package.json
CHANGED
|
@@ -1,44 +1,37 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "this.me",
|
|
3
|
-
"version": "2.7.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "2.7.8",
|
|
4
|
+
"description": "A package to setup a user-centric system identity. Starts by creating a .me object, you can add your own properties to it. This is me. This.me who is here",
|
|
5
5
|
"bin": {
|
|
6
|
-
".me": "./main.js"
|
|
6
|
+
".me": "./src/cli/main.js"
|
|
7
7
|
},
|
|
8
|
-
"
|
|
8
|
+
"type": "module",
|
|
9
|
+
"main": "index.js",
|
|
9
10
|
"scripts": {
|
|
10
|
-
"start": "node
|
|
11
|
+
"start": "node index.js",
|
|
11
12
|
"test": "test"
|
|
12
13
|
},
|
|
14
|
+
"build": "browserify src/me.js -s Me -o dist/me.bundle.js",
|
|
15
|
+
"keywords": [
|
|
16
|
+
"this.me",
|
|
17
|
+
"user",
|
|
18
|
+
"user-centric system",
|
|
19
|
+
"Data Sovereignty"
|
|
20
|
+
],
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"browserify": "^17.0.0",
|
|
23
|
+
"jsdoc": "^4.0.2"
|
|
24
|
+
},
|
|
13
25
|
"repository": {
|
|
14
26
|
"type": "git",
|
|
15
27
|
"url": "git+https://github.com/suiGn/this.me.git"
|
|
16
28
|
},
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
"DeepLearning",
|
|
20
|
-
"neuralnetworks",
|
|
21
|
-
"uthopias"
|
|
22
|
-
],
|
|
29
|
+
"homepage": "https://www.npmjs.com/package/this.me",
|
|
30
|
+
"docs": "https://suiGn.github.io/this.me",
|
|
23
31
|
"author": "suiGn",
|
|
24
32
|
"license": "MIT",
|
|
33
|
+
"repoType": "NPM Package",
|
|
25
34
|
"dependencies": {
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
"fs": "^0.0.1-security",
|
|
29
|
-
"i.mlearning": "^2.2.0",
|
|
30
|
-
"netget": "^2.2.3",
|
|
31
|
-
"neurons.me": "^2.7.1",
|
|
32
|
-
"this.atom":"^1.3.2",
|
|
33
|
-
"this.audio": "^1.0.6",
|
|
34
|
-
"this.be": "^2.1.6",
|
|
35
|
-
"this.dom": "^1.0.4",
|
|
36
|
-
"this.pixel": "^3.3.6",
|
|
37
|
-
"this.wallet":"^1.0.2",
|
|
38
|
-
"this.pixelgrid": "^3.3.2",
|
|
39
|
-
"this.text": "^1.0.5",
|
|
40
|
-
"this.video":"^1.0.0",
|
|
41
|
-
"v.path": "^2.2.0"
|
|
42
|
-
},
|
|
43
|
-
"homepage": "https://github.com/suiGn/this.me#readme"
|
|
35
|
+
"inquirer": "^9.2.12"
|
|
36
|
+
}
|
|
44
37
|
}
|
package/src/cli/main.js
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* @module CLI
|
|
4
|
+
* @description Command Line Interface Functionalities for .me
|
|
5
|
+
* Author: SuiGn
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import os from 'os';
|
|
9
|
+
import Me from '../me.js';
|
|
10
|
+
import program from 'commander';
|
|
11
|
+
import inquirer from 'inquirer';
|
|
12
|
+
import fs from 'fs';
|
|
13
|
+
import path from 'path';
|
|
14
|
+
import crypto from 'crypto';
|
|
15
|
+
|
|
16
|
+
program
|
|
17
|
+
.command('user <username> <pin>')
|
|
18
|
+
.description('Authenticate and start a session for a given user')
|
|
19
|
+
.action((username, pin) => {
|
|
20
|
+
console.log(`Attempting to authenticate user: ${username}`);
|
|
21
|
+
// Authentication logic here
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
program
|
|
25
|
+
.option('-o, --options', 'View options and commands');
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Display a welcome message to the user.
|
|
29
|
+
*/
|
|
30
|
+
function welcomeToMe() {
|
|
31
|
+
console.log(`
|
|
32
|
+
___________
|
|
33
|
+
[------------]
|
|
34
|
+
| .--------. |
|
|
35
|
+
| |01010101| | __________
|
|
36
|
+
| |11010101| | /__________\
|
|
37
|
+
[--------| -------- |------| --*-- |-------]
|
|
38
|
+
| [----_-.-----] |o ====== | |
|
|
39
|
+
| ______|_|_______ |__________| |
|
|
40
|
+
| / %%%%%%%%%%%% \ |
|
|
41
|
+
| / %%%%%%%%%%%%%% \ |
|
|
42
|
+
| ^^^^^^^^^^^^^^^^^^^^ |
|
|
43
|
+
[---------------------------------.me-----------]
|
|
44
|
+
-^^^^^^^^...
|
|
45
|
+
Welcome to .me.
|
|
46
|
+
`);
|
|
47
|
+
console.log(`Host_Session@ ${os.userInfo().username}`);
|
|
48
|
+
console.log(`v.path@ ${os.homedir()}/this.me`);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Prompts the user to select an action and returns their choice.
|
|
53
|
+
* @returns {Promise<string>} The user's choice.
|
|
54
|
+
*/
|
|
55
|
+
async function getUserChoice() {
|
|
56
|
+
const choices = ['View Existing Profiles', 'Create New Profile', 'Exit'];
|
|
57
|
+
const answer = await inquirer.prompt([{
|
|
58
|
+
type: 'list',
|
|
59
|
+
name: 'action',
|
|
60
|
+
message: 'What would you like to do?',
|
|
61
|
+
choices: choices
|
|
62
|
+
}]);
|
|
63
|
+
return answer.action;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Prompts the user for details to create a new profile.
|
|
68
|
+
* @returns {Promise<Me>} The new Me object with user details.
|
|
69
|
+
*/
|
|
70
|
+
async function getNewProfileDetails() {
|
|
71
|
+
const questions = [
|
|
72
|
+
{
|
|
73
|
+
type: 'input',
|
|
74
|
+
name: 'name',
|
|
75
|
+
message: 'What is your first name?',
|
|
76
|
+
// Add validation as needed
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
type: 'input',
|
|
80
|
+
name: 'lastname',
|
|
81
|
+
message: 'What is your last name?',
|
|
82
|
+
// Add validation as needed
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
type: 'input',
|
|
86
|
+
name: 'birthday',
|
|
87
|
+
message: 'What is your birthday? (YYYY-MM-DD)',
|
|
88
|
+
// Add validation as needed
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
type: 'password',
|
|
92
|
+
name: 'password',
|
|
93
|
+
message: 'Choose a password:',
|
|
94
|
+
// Add validation as needed
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
type: 'input',
|
|
98
|
+
name: 'pin',
|
|
99
|
+
message: 'Choose a PIN:',
|
|
100
|
+
// Add validation as needed
|
|
101
|
+
},
|
|
102
|
+
// ... Add more questions as needed
|
|
103
|
+
];
|
|
104
|
+
const userDetails = await inquirer.prompt(questions);
|
|
105
|
+
return new Me(
|
|
106
|
+
userDetails.name,
|
|
107
|
+
userDetails.lastname,
|
|
108
|
+
userDetails.birthday,
|
|
109
|
+
userDetails.password,
|
|
110
|
+
userDetails.pin
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Writes the .me object to the filesystem.
|
|
116
|
+
* @param {Me} meObject - The Me object to be saved.
|
|
117
|
+
*/
|
|
118
|
+
function writeMeObjectToFile(meObject) {
|
|
119
|
+
const meDirectory = path.join(os.homedir(), '.thisme');
|
|
120
|
+
if (!fs.existsSync(meDirectory)) {
|
|
121
|
+
fs.mkdirSync(meDirectory, { recursive: true });
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const filePath = path.join(meDirectory, `${meObject.name}.me`);
|
|
125
|
+
// Consider encrypting the data here before writing to the filesystem
|
|
126
|
+
fs.writeFileSync(filePath, JSON.stringify(meObject.getIdentityObject()));
|
|
127
|
+
console.log('Profile created successfully.');
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Function to display options and commands.
|
|
132
|
+
*/
|
|
133
|
+
function displayOptionsAndCommands() {
|
|
134
|
+
console.log(program.helpInformation());
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Main function to handle the CLI interactions.
|
|
139
|
+
* Continuously prompts the user for actions until an exit command is given.
|
|
140
|
+
*/
|
|
141
|
+
async function main() {
|
|
142
|
+
welcomeToMe();
|
|
143
|
+
let exit = false;
|
|
144
|
+
while (!exit) {
|
|
145
|
+
const choice = await getUserChoice();
|
|
146
|
+
switch (choice) {
|
|
147
|
+
case 'View Existing Profiles':
|
|
148
|
+
console.log('Existing profiles will be displayed here.');
|
|
149
|
+
break;
|
|
150
|
+
case 'Create New Profile':
|
|
151
|
+
const meObject = await getNewProfileDetails();
|
|
152
|
+
writeMeObjectToFile(meObject);
|
|
153
|
+
break;
|
|
154
|
+
case 'Exit':
|
|
155
|
+
console.log('Exiting .me CLI.');
|
|
156
|
+
exit = true;
|
|
157
|
+
break;
|
|
158
|
+
default:
|
|
159
|
+
console.log('Invalid choice. Please try again.');
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (process.argv.length > 2) {
|
|
165
|
+
program.parse(process.argv);
|
|
166
|
+
} else {
|
|
167
|
+
main();
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// Error handling for CLI
|
|
171
|
+
process.on('uncaughtException', (err) => {
|
|
172
|
+
console.error('An error occurred in the CLI:', err.message);
|
|
173
|
+
process.exit(1);
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
|
package/src/env.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// env.js
|
|
2
|
+
// Detect if running in Node.js or Browser
|
|
3
|
+
let isNodeEnvironment = (typeof process !== 'undefined' && process.versions && process.versions.node);
|
|
4
|
+
if (isNodeEnvironment) {
|
|
5
|
+
module.exports = require('./me-node');
|
|
6
|
+
} else {
|
|
7
|
+
module.exports = require('./me-browser');
|
|
8
|
+
}
|
package/{me.html → src/me.html}
RENAMED
package/src/me.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a user identity in the this.me system.
|
|
3
|
+
*/
|
|
4
|
+
class Me {
|
|
5
|
+
/**
|
|
6
|
+
* Create a ThisMe instance.
|
|
7
|
+
* @param {string} name - The first name of the user.
|
|
8
|
+
* @param {string} lastname - The last name of the user.
|
|
9
|
+
* @param {string} birthday - The birthday of the user in YYYY-MM-DD format.
|
|
10
|
+
* @param {string} password - The password chosen by the user.
|
|
11
|
+
* @param {string} pin - The personal identification number chosen by the user.
|
|
12
|
+
*/
|
|
13
|
+
constructor(name, lastname, birthday, password, pin) {
|
|
14
|
+
this.name = name;
|
|
15
|
+
this.lastname = lastname;
|
|
16
|
+
this.birthday = birthday;
|
|
17
|
+
this.password = password;
|
|
18
|
+
this.pin = pin;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Validates the user data. Throws an error if any field is empty.
|
|
23
|
+
* @throws Will throw an error if a required field is missing.
|
|
24
|
+
*/
|
|
25
|
+
validateData() {
|
|
26
|
+
if (!this.name || !this.lastname || !this.birthday || !this.password || !this.pin) {
|
|
27
|
+
throw new Error("All fields must be filled");
|
|
28
|
+
}
|
|
29
|
+
// Further validation rules can be added here
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Prepares and returns the identity object for hashing.
|
|
34
|
+
* @returns {Object} The identity object with user data.
|
|
35
|
+
*/
|
|
36
|
+
getIdentityObject() {
|
|
37
|
+
this.validateData();
|
|
38
|
+
return {
|
|
39
|
+
name: this.name,
|
|
40
|
+
lastname: this.lastname,
|
|
41
|
+
birthday: this.birthday,
|
|
42
|
+
credentials: `${this.password}:${this.pin}` // Combining password and pin
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export default Me;
|
|
File without changes
|
package/Me.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
//Me.js
|
|
2
|
-
let cryptoModule;
|
|
3
|
-
if (typeof window !== 'undefined' && typeof window.crypto !== 'undefined') {
|
|
4
|
-
cryptoModule = require('./crypto/crypto-browser');
|
|
5
|
-
} else {
|
|
6
|
-
cryptoModule = require('./crypto/crypto-node');
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
class Me {
|
|
10
|
-
constructor(name, email, birthDate, location = {}, preferences = {}) {
|
|
11
|
-
this.name = name;
|
|
12
|
-
this.email = email;
|
|
13
|
-
this.birthDate = birthDate;
|
|
14
|
-
this.location = location;
|
|
15
|
-
this.preferences = preferences;
|
|
16
|
-
// Social Media Accounts
|
|
17
|
-
this.socialMedia = {
|
|
18
|
-
facebook: {
|
|
19
|
-
appId: 'YOUR_FACEBOOK_APP_ID', // Replace with your actual Facebook App ID
|
|
20
|
-
token: null
|
|
21
|
-
}
|
|
22
|
-
// ... You can add more platforms here
|
|
23
|
-
};
|
|
24
|
-
// Generate key pair upon instantiation
|
|
25
|
-
this.keyPair = cryptoModule.generateKeyPair();
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
connectFacebook(token) {
|
|
29
|
-
this.socialMedia.facebook.token = token;
|
|
30
|
-
// You can expand this function to do more, like fetch the user's profile data using the token.
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
getFacebookToken() {
|
|
34
|
-
return this.socialMedia.facebook.token;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// the public key can be shared for verification
|
|
38
|
-
getPublicKey() {
|
|
39
|
-
return this.keyPair.publicKey;
|
|
40
|
-
}
|
|
41
|
-
// Use the private key for signing data.
|
|
42
|
-
signData(data) {
|
|
43
|
-
try {
|
|
44
|
-
const sign = cryptoModule.createSign('SHA256');
|
|
45
|
-
sign.update(data);
|
|
46
|
-
sign.end();
|
|
47
|
-
return sign.sign(this.keyPair.privateKey);
|
|
48
|
-
} catch (err) {
|
|
49
|
-
console.error("Error during signing data: ", err);
|
|
50
|
-
return null;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
verifySignature(data, signature) {
|
|
55
|
-
try {
|
|
56
|
-
const verify = cryptoModule.createVerify('SHA256');
|
|
57
|
-
verify.update(data);
|
|
58
|
-
verify.end();
|
|
59
|
-
return verify.verify(this.keyPair.publicKey, signature);
|
|
60
|
-
} catch (err) {
|
|
61
|
-
console.error("Error during verifying signature: ", err);
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
updateLocation(newLocation) {
|
|
67
|
-
this.location = newLocation;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
module.exports = Me;
|
package/crypto/crypto-browser.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
// crypto-browser.js
|
|
2
|
-
async function generateKeyPair() {
|
|
3
|
-
const keyPair = await window.crypto.subtle.generateKey(
|
|
4
|
-
{
|
|
5
|
-
name: "RSASSA-PKCS1-v1_5",
|
|
6
|
-
modulusLength: 2048,
|
|
7
|
-
publicExponent: new Uint8Array([1, 0, 1]),
|
|
8
|
-
hash: "SHA-256"
|
|
9
|
-
},
|
|
10
|
-
true,
|
|
11
|
-
["sign", "verify"]
|
|
12
|
-
);
|
|
13
|
-
return keyPair;
|
|
14
|
-
}
|
|
15
|
-
// ... other cryptographic operations using the Web Cryptography API ...
|
|
16
|
-
module.exports = {
|
|
17
|
-
generateKeyPair,
|
|
18
|
-
// ... export other cryptographic functions ...
|
|
19
|
-
};
|
|
20
|
-
|
package/crypto/crypto-node.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
// crypto-node.js
|
|
2
|
-
const crypto = require('crypto');
|
|
3
|
-
function generateKeyPair() {
|
|
4
|
-
const { privateKey, publicKey } = crypto.generateKeyPairSync('rsa', {
|
|
5
|
-
modulusLength: 2048,
|
|
6
|
-
});
|
|
7
|
-
return {
|
|
8
|
-
privateKey: privateKey.export({ type: 'pkcs1', format: 'pem' }),
|
|
9
|
-
publicKey: publicKey.export({ type: 'pkcs1', format: 'pem' }),
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
// ... other cryptographic operations using Node's crypto module ...
|
|
13
|
-
module.exports = {
|
|
14
|
-
generateKeyPair,
|
|
15
|
-
// ... export other cryptographic functions ...
|
|
16
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
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/crypto/hash/hashing.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
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/demo.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
const Me = require('./me2.js');
|
|
2
|
-
// Create a new Me instance
|
|
3
|
-
const suign = new Me('Suign Name', 'suign@email.com', '01/01/1990', { city: 'SampleCity', country: 'SampleCountry' }, { theme: 'dark', notifications: true });
|
|
4
|
-
// Print out the public key (for demonstration purposes)
|
|
5
|
-
console.log("Suign's Public Key:", suign.getPublicKey());
|
|
6
|
-
// Example: Sign some data
|
|
7
|
-
const dataToSign = "Hello, World!";
|
|
8
|
-
const signature = suign.signData(dataToSign);
|
|
9
|
-
console.log("Signature for 'Hello, World!':", signature.toString('base64')); // Base64 encoding just to make the signature more readable in console.
|
|
10
|
-
// Example: Verify the signature
|
|
11
|
-
const isValidSignature = suign.verifySignature(dataToSign, signature);
|
|
12
|
-
console.log("Is the signature valid?", isValidSignature);
|
package/main.js
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
//main.js
|
|
3
|
-
const { exec } = require("child_process");
|
|
4
|
-
const path = require("path");
|
|
5
|
-
const crypto = require('crypto');
|
|
6
|
-
const fs = require('fs');
|
|
7
|
-
const args = process.argv.slice(2);
|
|
8
|
-
//User Context.
|
|
9
|
-
const os = require('os');
|
|
10
|
-
const Me = require('./Me');
|
|
11
|
-
const me = new Me(
|
|
12
|
-
'Me',
|
|
13
|
-
'enter your email.',
|
|
14
|
-
'replaceDateOfBirth',
|
|
15
|
-
{ city: 'replaceCity',
|
|
16
|
-
country: 'replaceCountry' },
|
|
17
|
-
{ theme: 'dark' }
|
|
18
|
-
);
|
|
19
|
-
//CLI LOGIC
|
|
20
|
-
function displayWelcomeMessage() {
|
|
21
|
-
console.log(`
|
|
22
|
-
___________
|
|
23
|
-
[------------]
|
|
24
|
-
| .--------. |
|
|
25
|
-
| |01010101| | __________
|
|
26
|
-
| |11010101| | /__________\
|
|
27
|
-
[--------| -------- |------| --*-- |-------]
|
|
28
|
-
| [----_-.-----] |o ====== | |
|
|
29
|
-
| ______|_|_______ |__________| |
|
|
30
|
-
| / %%%%%%%%%%%% \ |
|
|
31
|
-
| / %%%%%%%%%%%%%% \ |
|
|
32
|
-
| ^^^^^^^^^^^^^^^^^^^^ |
|
|
33
|
-
[---------------------------------.me-----------]
|
|
34
|
-
-^^^^^^^^zzzz...
|
|
35
|
-
Welcome to .me.
|
|
36
|
-
`);
|
|
37
|
-
console.log(`Host_Session@ ${os.userInfo().username}`);
|
|
38
|
-
console.log(`v.path@ ${os.homedir()}`);
|
|
39
|
-
};
|
|
40
|
-
//.. THIS SECTION IS FOR HASHING PURPOSES ...//
|
|
41
|
-
/* Create a function that computes the hash of the @src directory.
|
|
42
|
-
'hashSrc') to handle hashing when the relevant command is passed to the script.*/
|
|
43
|
-
const { fork } = require('child_process');
|
|
44
|
-
const { getAllFiles, hashThis } = require('./crypto/hash/hashing');
|
|
45
|
-
function hashSrc() {
|
|
46
|
-
try {
|
|
47
|
-
// Adjust this to the exact location of your @src directory
|
|
48
|
-
const srcDirPath = path.resolve(__dirname, '@me');
|
|
49
|
-
const hash = hashThis(srcDirPath);
|
|
50
|
-
console.log(`Hash of @src directory: ${hash}`);
|
|
51
|
-
} catch (error) {
|
|
52
|
-
console.error('Error hashing @src directory:', error.message);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
// COMMAND HANDLERS
|
|
56
|
-
switch(args[0]) {
|
|
57
|
-
case 'hash-src':
|
|
58
|
-
hashSrc();
|
|
59
|
-
break;
|
|
60
|
-
case 'viewer':
|
|
61
|
-
handleViewerCommand();
|
|
62
|
-
break;
|
|
63
|
-
case 'atom':
|
|
64
|
-
console.log("Atom");
|
|
65
|
-
break;
|
|
66
|
-
default:
|
|
67
|
-
// Here you can define what you'd like to happen when no arguments are passed.
|
|
68
|
-
displayWelcomeMessage();
|
|
69
|
-
// And any other functionality you'd like to execute
|
|
70
|
-
break;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
module.exports = {
|
|
74
|
-
getAllFiles,
|
|
75
|
-
hashThis,
|
|
76
|
-
hashSrc
|
|
77
|
-
};
|
package/me2.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
//me.js
|
|
2
|
-
const crypto = require('crypto');
|
|
3
|
-
class Me {
|
|
4
|
-
constructor(name, email, birthDate, location = {}, preferences = {}) {
|
|
5
|
-
this.name = name;
|
|
6
|
-
this.email = email;
|
|
7
|
-
this.birthDate = birthDate;
|
|
8
|
-
this.location = location;
|
|
9
|
-
this.preferences = preferences;
|
|
10
|
-
// Generate key pair upon instantiation
|
|
11
|
-
this.keyPair = this.generateKeyPair();
|
|
12
|
-
}
|
|
13
|
-
generateKeyPair() {
|
|
14
|
-
const { privateKey, publicKey } = crypto.generateKeyPairSync('rsa', {
|
|
15
|
-
modulusLength: 2048,
|
|
16
|
-
});
|
|
17
|
-
return {
|
|
18
|
-
privateKey: privateKey.export({ type: 'pkcs1', format: 'pem' }),
|
|
19
|
-
publicKey: publicKey.export({ type: 'pkcs1', format: 'pem' }),
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
getPublicKey() {
|
|
23
|
-
return this.keyPair.publicKey;
|
|
24
|
-
}
|
|
25
|
-
// Use the private key for signing data, and the public key can be shared for verification
|
|
26
|
-
signData(data) {
|
|
27
|
-
const sign = crypto.createSign('SHA256');
|
|
28
|
-
sign.update(data);
|
|
29
|
-
sign.end();
|
|
30
|
-
return sign.sign(this.keyPair.privateKey);
|
|
31
|
-
}
|
|
32
|
-
verifySignature(data, signature) {
|
|
33
|
-
const verify = crypto.createVerify('SHA256');
|
|
34
|
-
verify.update(data);
|
|
35
|
-
verify.end();
|
|
36
|
-
return verify.verify(this.keyPair.publicKey, signature);
|
|
37
|
-
}
|
|
38
|
-
updateLocation(newLocation) {
|
|
39
|
-
this.location = newLocation;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
module.exports = Me;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
/*
|
|
47
|
-
Face Recognition:
|
|
48
|
-
async recognizeFace(imageData): This method would use an API or library to recognize the user's face. This can be useful for biometric-based authentication.
|
|
49
|
-
Connect Social Media:
|
|
50
|
-
|
|
51
|
-
connectSocialMedia(platform, credentials): This method would handle integration with various social media platforms. The platform parameter would specify which platform (e.g., "Facebook", "Twitter", "LinkedIn"), and the credentials would contain the necessary authentication details.
|
|
52
|
-
Password Management:
|
|
53
|
-
|
|
54
|
-
addPassword(website, password): Store a password for a particular website.
|
|
55
|
-
getPassword(website): Retrieve the stored password for a specific website.
|
|
56
|
-
generateStrongPassword(): Generate a random, strong password based on certain criteria.
|
|
57
|
-
*/
|
package/src/errorHandler.js
DELETED
package/test.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
const neurons = require('neurons.me');
|
|
2
|
-
//cleaking
|
|
3
|
-
const Cleaker = require('cleaker');
|
|
4
|
-
let cleaked = new Cleaker();
|
|
5
|
-
console.log('printing cleaked');
|
|
6
|
-
console.log(cleaked);
|
|
7
|
-
//cleaked completed
|
|
8
|
-
console.log('printing neurons.me module functionality');
|
|
9
|
-
console.log(neurons);
|
|
10
|
-
|
|
11
|
-
console.log('Creating a new neuron with neurons.createNeuron()');
|
|
12
|
-
let neuron = neurons.createNeuron();
|
|
13
|
-
console.log(neuron);
|
|
14
|
-
|
|
15
|
-
// Custom options for the neuron
|
|
16
|
-
let options = {
|
|
17
|
-
name: 'x', // Custom name for the neuron
|
|
18
|
-
color: 'rgb', // Custom color
|
|
19
|
-
activationFunction: x => x * 2 // Custom activation function
|
|
20
|
-
};
|
|
21
|
-
// Create a neuron with custom options
|
|
22
|
-
let neuron2 = new neurons.createNeuron({ options: options });
|
|
23
|
-
console.log(neuron2);
|
|
24
|
-
// Create Layer
|
|
25
|
-
console.log('creating layer');
|
|
26
|
-
let layer = new neurons.Layer();
|
|
27
|
-
console.log('printing layer');
|
|
28
|
-
console.log(layer);
|
|
29
|
-
//adding neurons to layer
|
|
30
|
-
layer.addNeurons(neuron, neuron2);
|
|
31
|
-
console.log('printing layer.neurons');
|
|
32
|
-
console.log(layer.neurons);
|
|
33
|
-
console.log('printing layer.map');
|
|
34
|
-
console.log(layer.map);
|
|
35
|
-
|
|
36
|
-
|
package/testHashIt.js
DELETED