this.me 2.5.6 → 2.5.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.
Files changed (5) hide show
  1. package/README.md +65 -0
  2. package/demo.js +17 -0
  3. package/main.js +22 -18
  4. package/me.js +34 -9
  5. package/package.json +1 -1
package/README.md CHANGED
@@ -7,6 +7,12 @@ For every recursive action, there's a repercussion.
7
7
  npm install this.me
8
8
  ```
9
9
 
10
+ Add to your project:
11
+
12
+ ```js
13
+ let me = require('this.me');
14
+ ```
15
+
10
16
  **Docs:** [this.me](https://www.neurons.me/this-me)
11
17
 
12
18
  ### Conceptual Flow:
@@ -37,6 +43,65 @@ The **SHA256 cryptographic hash function** is used to produce a unique, fixed-le
37
43
  Even a tiny change in the content will result in a completely different hash.
38
44
  [Read More.](https://www.neurons.me/this-me#h.sg59uu9ka8i8)
39
45
 
46
+ ## Quickstart Guide: Understanding `Me`
47
+
48
+ ### Introduction:
49
+
50
+ Run node demo.js for quick example.const Me = require('./me.js');
51
+
52
+ ```js
53
+ // Create a new Me instance
54
+ const suign = new Me('Suign Name', 'suign@email.com', '01/01/1990', { city: 'SampleCity', country: 'SampleCountry' }, { theme: 'dark', notifications: true });
55
+ // Print out the public key (for demonstration purposes)
56
+ console.log("Suign's Public Key:", suign.getPublicKey());
57
+ // Example: Sign some data
58
+ const dataToSign = "Hello, World!";
59
+ const signature = suign.signData(dataToSign);
60
+ console.log("Signature for 'Hello, World!':", signature.toString('base64')); // Base64 encoding just to make the signature more readable in console.
61
+ // Example: Verify the signature
62
+ const isValidSignature = suign.verifySignature(dataToSign, signature);
63
+ console.log("Is the signature valid?", isValidSignature);
64
+ ```
65
+
66
+ **`Me`** is a digital identity representation within a network. Rather than relying on traditional methods like username-password combinations, `Me` encapsulates the essence of an entity with cryptographic guarantees.
67
+
68
+ ### Key Features:
69
+
70
+ 1. **Cryptographic Identity**:
71
+ - Every instance of `Me` has a private and public key pair.
72
+ - These keys provide cryptographic proof of identity, allowing entities to sign and verify messages securely.
73
+ 2. **Profile Management**:
74
+ - `Me` contains information attributes such as name, email, birthdate, location, and preferences.
75
+ - These attributes can be updated and managed within the entity's lifecycle.
76
+ 3. **Network Interactions**:
77
+ - Being cryptographically unique, `Me` can safely interact with services on a network.
78
+ - It can register, authenticate, and perform actions with a guarantee of its identity.
79
+
80
+ ### Purpose:
81
+
82
+ 1. Enhanced Security
83
+ - Traditional authentication systems have vulnerabilities (e.g., password breaches). `Me` ensures that without the private key, impersonation is nearly impossible.
84
+ 2. Decentralization Ready
85
+ - `Me` fits perfectly in a decentralized environment, where trust is established not by central entities, but by cryptographic proofs.
86
+ 3. User Centricity
87
+ - The user has full control over their `Me` entity. They manage their keys and therefore their identity, making it resistant to censorship and external control.
88
+ 4. Simplicity
89
+ - Instead of managing multiple credentials for different services, `Me` offers a unified identity that's recognized across the network.
90
+
91
+ ### Getting Started:
92
+
93
+ 1. **Initialization**:
94
+ - Create an instance: `const myProfile = new Me('Name', 'email@email.com', 'birthdate', {location}, {preferences});`
95
+ 2. **Key Management**:
96
+ - Use integrated cryptographic methods to sign and verify data.
97
+ - Always ensure the private key remains confidential.
98
+ 3. **Interactions**:
99
+ - With the public key as an identifier, use `Me` to interact with services, sign transactions, or prove identity in network communications.
100
+
101
+ ------
102
+
103
+ Remember, while `Me` provides enhanced security, the principle of key management is paramount. Losing access to the private key might mean losing access to the associated identity.
104
+
40
105
  Let's delve into the importance of such declarations:
41
106
 
42
107
  ### Security Context:
package/demo.js ADDED
@@ -0,0 +1,17 @@
1
+ const Me = require('./me.js');
2
+
3
+ // Create a new Me instance
4
+ const suign = new Me('Suign Name', 'suign@email.com', '01/01/1990', { city: 'SampleCity', country: 'SampleCountry' }, { theme: 'dark', notifications: true });
5
+
6
+ // Print out the public key (for demonstration purposes)
7
+ console.log("Suign's Public Key:", suign.getPublicKey());
8
+
9
+ // Example: Sign some data
10
+ const dataToSign = "Hello, World!";
11
+ const signature = suign.signData(dataToSign);
12
+
13
+ console.log("Signature for 'Hello, World!':", signature.toString('base64')); // Base64 encoding just to make the signature more readable in console.
14
+
15
+ // Example: Verify the signature
16
+ const isValidSignature = suign.verifySignature(dataToSign, signature);
17
+ console.log("Is the signature valid?", isValidSignature);
package/main.js CHANGED
@@ -7,11 +7,19 @@ const fs = require('fs');
7
7
  const args = process.argv.slice(2);
8
8
  const neurons = require("neurons.me");
9
9
  const cleaker = require("cleaker");
10
- let netget;
11
- if (needNetget) {
12
- netget = require("netget");
13
- }
10
+ const netget = require("netget");
14
11
  const Atom = require("this.atom");
12
+ //User Context.
13
+ const Me = require("./me");
14
+ const os = require('os');
15
+ const me = new Me(
16
+ 'Me',
17
+ 'replace@email.me',
18
+ 'replaceDateOfBirth',
19
+ { city: 'replaceCity',
20
+ country: 'replaceCountry' },
21
+ { theme: 'dark' }
22
+ );
15
23
  // Your CLI logic goes here, display welcome message, handle other commands, etc.
16
24
  function displayWelcomeMessage() {
17
25
  console.log(`
@@ -29,17 +37,13 @@ function displayWelcomeMessage() {
29
37
  [---------------------------------.me-----------]
30
38
  -^^^^^^^^zzzz...
31
39
  Welcome to .me - Your AI Playground
32
- give me one sec please...
33
40
  `);
41
+ console.log(me.getPublicKey());
42
+ const cleaked = new cleaker();
43
+ console.log(`Host_Session@ ${os.userInfo().username}`);
44
+ console.log("System Role: ", cleaked.role);
34
45
  };
35
46
 
36
- //User Context.
37
- const Me = require("./me");
38
- const me = new Me();
39
- const os = require('os');
40
- console.log(`Host_Session@ ${os.userInfo().username}`);
41
- const cleaked = new cleaker();
42
- console.log(cleaked.role);
43
47
  //ATOMS ELECTRONS AND PARTICLES IN PROGRESS...
44
48
  //WE WILL RUN OUR NODE PROCCESSES IN ELECTRON WINDOWS AND EACH ATOM WILL HOLD ELECTRONS WHICH HOLDS THE PROCESSES
45
49
  //THUS WE WILL KNOW HOW CHARGED AN ATOM IS BY THE NUMBER OF ELECTRONS IT HAS AND HOW MANY PROCESSES IT IS RUNNING.
@@ -89,14 +93,11 @@ function handleAtomCommand() {
89
93
  }
90
94
  }
91
95
 
92
- // Display the welcome message
93
- displayWelcomeMessage();
94
-
95
96
  // COMMAND HANDLERS
96
97
  switch(args[0]) {
97
98
  case 'hash-src':
98
- hashSrc();
99
- break;
99
+ hashSrc();
100
+ break;
100
101
  case 'viewer':
101
102
  handleViewerCommand();
102
103
  break;
@@ -104,7 +105,10 @@ switch(args[0]) {
104
105
  handleAtomCommand();
105
106
  break;
106
107
  default:
107
- console.log('Command not recognized. Use "viewer" or "atom" as arguments.');
108
+ // Here you can define what you'd like to happen when no arguments are passed.
109
+ displayWelcomeMessage();
110
+ // And any other functionality you'd like to execute
111
+ break;
108
112
  }
109
113
 
110
114
  module.exports = {
package/me.js CHANGED
@@ -1,18 +1,43 @@
1
1
  // me.js
2
+ const crypto = require('crypto');
2
3
  class Me {
3
4
  constructor(name, email, birthDate, location = {}, preferences = {}) {
4
- this.name = name; // Full name
5
- this.email = email; // Email address
6
- this.birthDate = birthDate; // Birthdate
7
- this.location = location; // Location object { city: '...', country: '...', ...}
8
- this.preferences = preferences; // User's preferences or settings, it could be an object { theme: 'dark', notifications: true, ...}
9
- // Add other attributes pertinent to the profile as needed.
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);
10
37
  }
11
- // Method to update location
12
38
  updateLocation(newLocation) {
13
39
  this.location = newLocation;
14
40
  }
15
- // Add other methods to get, set, or update profile details as needed.
41
+ // Add other methods as required.
16
42
  }
17
-
18
43
  module.exports = Me;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "this.me",
3
- "version": "2.5.6",
3
+ "version": "2.5.8",
4
4
  "description": "This.me should This.be",
5
5
  "bin": {
6
6
  ".me": "./main.js"