this.me 2.5.7 β†’ 2.5.9

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 +70 -5
  2. package/demo.js +17 -0
  3. package/main.js +21 -14
  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:
@@ -24,19 +30,78 @@ npm install this.me
24
30
  - [ ] Keep [i.mlearning](https://www.npmjs.com/package/i.mlearning).
25
31
 
26
32
 
33
+
34
+ This model turns the traditional web model on its head. Users no longer depend on centralized authorities for identity or data management. They hold the keys (literally) to their identity and data. Services become more user-centric, providing services based on cryptographic proofs rather than centralized databases.
35
+
36
+ While this approach offers many benefits, including enhanced privacy and user sovereignty, it's still nascent and requires a paradigm shift in development, deployment, and user education.
27
37
 
28
38
  # Setting up your Context. πŸ‘‹πŸ»πŸ‘‹πŸΌπŸ‘‹πŸ½πŸ‘‹πŸΎπŸ‘‹πŸΏ
29
39
  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.
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.
40
+ Having a clear declaration of the environment and the context can have a series of implications for security, interoperability, and clarity. The codebase is often vast, dynamic, and continually evolving. 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
41
 
36
42
  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
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
@@ -9,6 +9,17 @@ const neurons = require("neurons.me");
9
9
  const cleaker = require("cleaker");
10
10
  const netget = require("netget");
11
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
+ );
12
23
  // Your CLI logic goes here, display welcome message, handle other commands, etc.
13
24
  function displayWelcomeMessage() {
14
25
  console.log(`
@@ -26,17 +37,13 @@ function displayWelcomeMessage() {
26
37
  [---------------------------------.me-----------]
27
38
  -^^^^^^^^zzzz...
28
39
  Welcome to .me - Your AI Playground
29
- give me one sec please...
30
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);
31
45
  };
32
46
 
33
- //User Context.
34
- const Me = require("./me");
35
- const me = new Me();
36
- const os = require('os');
37
- console.log(`Host_Session@ ${os.userInfo().username}`);
38
- const cleaked = new cleaker();
39
- console.log(cleaked.role);
40
47
  //ATOMS ELECTRONS AND PARTICLES IN PROGRESS...
41
48
  //WE WILL RUN OUR NODE PROCCESSES IN ELECTRON WINDOWS AND EACH ATOM WILL HOLD ELECTRONS WHICH HOLDS THE PROCESSES
42
49
  //THUS WE WILL KNOW HOW CHARGED AN ATOM IS BY THE NUMBER OF ELECTRONS IT HAS AND HOW MANY PROCESSES IT IS RUNNING.
@@ -86,14 +93,11 @@ function handleAtomCommand() {
86
93
  }
87
94
  }
88
95
 
89
- // Display the welcome message
90
- displayWelcomeMessage();
91
-
92
96
  // COMMAND HANDLERS
93
97
  switch(args[0]) {
94
98
  case 'hash-src':
95
- hashSrc();
96
- break;
99
+ hashSrc();
100
+ break;
97
101
  case 'viewer':
98
102
  handleViewerCommand();
99
103
  break;
@@ -101,7 +105,10 @@ switch(args[0]) {
101
105
  handleAtomCommand();
102
106
  break;
103
107
  default:
104
- 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;
105
112
  }
106
113
 
107
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.7",
3
+ "version": "2.5.9",
4
4
  "description": "This.me should This.be",
5
5
  "bin": {
6
6
  ".me": "./main.js"