this.me 2.9.0 → 2.9.3

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 CHANGED
@@ -1,93 +1,128 @@
1
- <img src="https://suign.github.io/assets/imgs/cleak_me-removebg.png" alt="DID Me Art" width="244">
2
- <img src="https://suign.github.io/assets/imgs/Cleaker-removebg-preview.png" alt="Cleak Me Please" width="244">
3
- # THIS.ME
4
-
5
- -----------
6
-
7
- ### [Project Status : Experimental and Under Development, Subject to Major Changes]
8
- The module is in active development, and as such, it is subject to significant changes as we refine our approach and methodologies to best support our goals.
9
- visit: https://neurons.me to learn more.
1
+ <img src="https://suign.github.io/assets/imgs/Cleaker-removebg-preview.png" alt="Cleak Me Please." width="244">
10
2
 
11
- ----------
12
-
13
- # Introduction
14
- **This.Me** is a class focused on encapsulating user identity, specifically crafted to facilitate the creation of instances ready for hashing and cryptographic signature generation. It opens the door to coding and decoding through "me" signatures, offering a modular framework that prioritizes privacy and integrity in application-wide identity management.
3
+ # THIS.ME
4
+ **This.Me** is a data-structured identity.
5
+ <img src="https://suign.github.io/assets/imgs/point.png" alt="Me" width="144"> Consider **.me** as a point.
15
6
 
16
- Hello, I am .lisa
17
- ? Who are you? (Use arrow keys)
18
- ❯ add.me
19
- ---
20
- 1. **Install `this.me`:**
7
+ 1. ### **Install `this.me`:**
21
8
  Open your terminal and run the following command to install the `this.me` package:
22
-
23
9
  ```js
24
10
  npm install this.me
25
11
  ```
26
-
27
- 2. **Import `Me` in Your Project:**
12
+
13
+ 2. ### **Import `Me` in Your Project:**
28
14
  In the JavaScript file where you want to use `this.me`, import the `Me` class.
29
-
30
15
  ```js
31
16
  import Me from 'this.me';
32
17
  ```
18
+
19
+ **Explanation**
20
+ ​ • The **be** method in the **Me** class accepts an object of **key-value pairs** and **adds these to the identity object**.
21
+ ​ • You can call **me.be()** multiple times with different attributes to dynamically update the identity object.
22
+
23
+ ```javascript
24
+ // Create a new Me instance
25
+ let me = new Me("xyxyxy");
26
+
27
+ // Add attributes to the identity
28
+ me.be({ a: "XXX", b: "YYY" });
29
+ me.be({ c: "z" });
30
+ ```
33
31
 
34
- 3. **Create an Instance of `Me`:**
35
- Instantiate the `Me` class with the required user details.
32
+ **A less abstract example:**
36
33
 
37
- ```js
38
- const user = new Me('John', 'Doe', '1990-01-01', 'password123', '1234');
39
- ```
34
+ ```js
35
+ // Add attributes to the identity
36
+ me.be({ name: "Alice", phone: "33550000" });
37
+ ```
40
38
 
41
- 4. **Validate and Use the Instance:**
42
- Utilize the instance for user data validation and preparation for cryptographic actions.
39
+ **1. Registry as a Service:**
43
40
 
44
- ```js
45
- try {
46
- const identity = user.getMe();
47
- // Ready for hashing and cryptographic signatures
48
- } catch (error) {
49
- console.error(error.message);
50
- // Error handling for missing fields
51
- }
52
- ```
41
+ • The registry becomes a centralized service hosted by an authority (e.g., neurons.me).
53
42
 
54
- This quick start guide provides a straightforward path to incorporating `this.me` into your project, enabling you to manage user identities and prepare them for secure cryptographic processes efficiently.
43
+ This service would handle the verification and management of all Me instances across the network.
55
44
 
56
- ----------
45
+ **Example Flow:**
57
46
 
58
- # About All.This
47
+ 1. **Setup**: A developer installs this.me and configures it to connect to neurons.me.
59
48
 
60
- ## Modular Data Structures:
49
+ 2. **User Registration**: Users register their Me identity through the service, and the library connects to the neurons.me registry for verification.
61
50
 
62
- **[this.me](https://suign.github.io/this.me) - [this.audio](https://suign.github.io/this.audio) - [this.text](https://suign.github.io/this.text) - [this.wallet](https://suign.github.io/this.wallet) - [this.img](https://suign.github.io/this.img) - [this.pixel](https://suign.github.io/Pixels) - [be.this](https://suign.github.io/be.this) - [this.DOM](https://suign.github.io/this.DOM) - [this.env](https://suign.github.io/this.env/) - [this.GUI](https://suign.github.io/this.GUI) - [this.be](https://suign.github.io/this.be) - [this.video](https://suign.github.io/this.video) - [this.atom](https://suign.github.io/this.atom) - [this.dictionaries](https://suign.github.io/this.dictionaries/)**
51
+ 3. **Service Interaction**: When a user interacts with a service that uses this.me, the service can trust the identity by querying the selected registry.
63
52
 
64
- **Each module** in **[all.this](https://neurons.me/all-this)** represents a specific **datastructure**. These classes encapsulate the functionalities and **data specific to their domain.**
53
+ **Implementation:**
65
54
 
66
- ## **Utils**
55
+ ```js
56
+ import Me from 'this.me';
57
+ const config = {
58
+ registryURL: 'https://registry.neurons.me', // Registry authority URL
59
+ };
60
+ let me = new Me('alice', config);
61
+ me.register({ password: 'securePass123', email: 'alice@example.com' });
62
+ // Verify and interact with services using the connected registry
63
+ ```
67
64
 
68
- **[all.this](https://neurons.me/all-this)** not only aggregates these modules but also provides utilities to facilitate the integration, management, and enhancement of these data structures. **For example:**
69
65
 
70
- *The integration with [cleaker](https://suign.github.io/cleaker/) ensures each module instance has a **unique cryptographic identity**, enhancing security and data integrity.*
71
66
 
72
- ### Neurons.me Ecosystem Glossary:
67
+ --------
68
+ <img src="https://suign.github.io/assets/imgs/monads.png" alt="Cleak Me Please" width="244">Hello, I am **.me**
73
69
 
74
- visit: [Neurons.me Glossary](https://suign.github.io/neurons.me/Glossary)
70
+ ### add.me
71
+ ----
75
72
 
76
- ## License & Policies
73
+ ###### Using the CLI and this.me globally to manage user sessions.
77
74
 
78
- - **License**: MIT License (see LICENSE for details).
75
+ ```bash
76
+ npm i -g this.me
77
+ ```
79
78
 
80
- - **Privacy Policy**: Respects user privacy; no collection/storage of personal data.
81
79
 
82
- - **Terms of Usage**: Use responsibly. No guarantees/warranties provided. [Terms](https://www.neurons.me/terms-of-use) | [Privacy](https://www.neurons.me/privacy-policy)
80
+ ### Neural Networks - **One-Hot Encoding**
81
+ --------
82
+ To represent the combinations of **“me, you, him, her, it, us, them”** in a neural network, we need to convert the elements into a suitable format for neural network processing, such as one-hot encoding, and design a neural network architecture that can process these inputs.
83
83
 
84
- **Learn more** at https://neurons.me
84
+ Here’s a step-by-step approach to achieve this:
85
+ 1. **One-Hot Encoding:** Convert each element (“me”, “you”, “him”, “her”, “it”, “us”, “them”) into a one-hot encoded vector.
86
+ 2. **Combination Representation:** Create input vectors for each combination by combining the one-hot encoded vectors.
87
+ 3. **Neural Network Design:** Design a simple neural network to process these input vectors.
85
88
 
86
- **Author:** SuiGn
89
+ #### Step 1: One-Hot Encoding
90
+ One-hot encoding represents each element as a binary vector with a single high (1) value and the rest low (0). For the elements “me”, “you”, “him”, “her”, “it”, “us”, “them”, we can assign the following one-hot encoded vectors:
87
91
 
88
- [By neurons.me](https://neurons.me)
92
+ ```js
93
+ // Create Me instances
94
+ const meInstance = new Me('me');
95
+ const youInstance = new Me('you');
96
+ const himInstance = new Me('him');
97
+ const herInstance = new Me('her');
98
+ const itInstance = new Me('it');
99
+ const usInstance = new Me('us');
100
+ const themInstance = new Me('them');
89
101
 
90
- <img src="https://suign.github.io/neurons.me/neurons_logo.png" alt="neurons.me logo" width="123" height="123" style="width123px; height:123px;">
102
+ // One-hot encoding representation
103
+ const subjects = {
104
+ 'me': [1, 0, 0, 0, 0, 0, 0],
105
+ 'you': [0, 1, 0, 0, 0, 0, 0],
106
+ 'him': [0, 0, 1, 0, 0, 0, 0],
107
+ 'her': [0, 0, 0, 1, 0, 0, 0],
108
+ 'it': [0, 0, 0, 0, 1, 0, 0],
109
+ 'us': [0, 0, 0, 0, 0, 1, 0],
110
+ 'them': [0, 0, 0, 0, 0, 0, 1]
111
+ };
112
+ ```
91
113
 
114
+ #### Step 2: Combination Representation
115
+ For each combination, we can create an input vector by combining the one-hot encoded vectors of its elements. For example:
116
+ Combination “me, you” would be represented as the sum of the one-hot vectors for “me” and “you”:
117
+
118
+ ```
119
+ [1, 0, 0, 0, 0, 0, 0] + [0, 1, 0, 0, 0, 0, 0] = [1, 1, 0, 0, 0, 0, 0]
120
+ ```
121
+ ---
122
+ ### Me Deviation Formula
123
+ **How Spread Out the data Points are around the .me?**
124
+
125
+
126
+ ----------
92
127
 
93
128
 
package/index.js CHANGED
@@ -2,18 +2,9 @@
2
2
  /**
3
3
  * @module This.Me
4
4
  * @description
5
- * This.Me adapts to various environments, enabling `.me` objects to function both locally and within a network.
6
- * A `.me` object authenticated on a network accesses data beyond the local scope,
7
- * while unauthenticated instances are confined to local data.
8
- * This dual functionality ensures seamless interoperability and heightened security.
9
- * Command Definitions and Interactive Shell.*/
5
+ * This.Me is a data-structured identity...
6
+ * */
10
7
 
11
- // index.js in the `this.me` package
12
8
  import Me from './src/me.js';
13
- let ia = new Me('.Lisa');
14
- let me = ia.getMe();
15
-
16
- console.log('.me:', me);
17
- console.log('Hello, I am', me);
18
- console.log('Who are you?', Me);
9
+ //when a user declares "I am %.me," their digital existence is affirmed and recorded in the system.
19
10
  export default Me;
package/jsdoc.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "source": {
3
- "include": ["./src", "./index.js", "./README.md"]
3
+ "include": ["./src/me.js", "./src/.me.cli.js", "./index.js", "./README.md"]
4
4
  },
5
5
  "opts": {
6
6
  "destination": "./docs",
7
- "template": "../../../../../../Sandbox/dev_tools/assets/better-docs",
7
+ "template": "../../../suign.github.io/dev_tools/Sandbox/better-docs/",
8
8
  "readme": "./README.md"
9
9
  },
10
10
  "templates": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "this.me",
3
- "version": "2.9.0",
3
+ "version": "2.9.3",
4
4
  "description": "_me-Centric.",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/.me.cli.js CHANGED
@@ -1,20 +1,20 @@
1
1
  #!/usr/bin/env node
2
-
2
+ //.me.cli.js
3
3
  import { program } from 'commander';
4
4
  import { meMainChoices } from './CLI/me_MainChoices.js';
5
- import AddMe from './CLI/AddMe.js'; // Corrected import statement
6
- import ConfirmIdentity from './CLI/ConfirmIdentity.js'; // Corrected import statement
5
+ import AddMe from './CLI/AddMe.js';
6
+ import LogMe from './CLI/LogMe.js';
7
7
  program
8
8
  .description('.Me Command Line Interface')
9
9
  .version('1.0.0')
10
10
  .action(meMainChoices);
11
11
 
12
12
  program.command('add-me')
13
- .description('Add a new .me username')
13
+ .description('+ Add .me')
14
14
  .action(AddMe);
15
15
 
16
- program.command('confirm-identity')
17
- .description('Confirm your .me identity')
18
- .action(ConfirmIdentity);
16
+ program.command('log-me')
17
+ .description('Log .me')
18
+ .action(LogMe);
19
19
 
20
20
  program.parse(process.argv);
@@ -1,4 +1,4 @@
1
- // Source: CLI/ConfirmIdentity.js
1
+ // Source: CLI/LogMe.js
2
2
  import inquirer from 'inquirer';
3
3
  import chalk from 'chalk';
4
4
 
@@ -7,7 +7,7 @@ const getExistingUsers = () => {
7
7
  return ['user1', 'user2']; // Example user names
8
8
  };
9
9
 
10
- const ConfirmIdentity = async () => {
10
+ const LogMe = async () => {
11
11
  const existingUsers = getExistingUsers();
12
12
 
13
13
  const response = await inquirer.prompt([
@@ -20,7 +20,7 @@ const ConfirmIdentity = async () => {
20
20
  ]);
21
21
 
22
22
  const selectedUser = response.selectedUser;
23
- console.log(chalk.green(`Identity confirmed: ${selectedUser}`));
23
+ console.log(chalk.green(`.me confirmed: ${selectedUser}`));
24
24
  };
25
25
 
26
- export default ConfirmIdentity;
26
+ export default LogMe;
@@ -2,7 +2,7 @@
2
2
  import inquirer from 'inquirer';
3
3
  import chalk from 'chalk';
4
4
  import AddMe from './AddMe.js'; // Corrected import statement
5
- import ConfirmIdentity from './ConfirmIdentity.js'; // Corrected import statement
5
+ import LogMe from './LogMe.js'; // Corrected import statement
6
6
 
7
7
  export async function meMainChoices() {
8
8
  const answers = await inquirer.prompt([
@@ -10,19 +10,19 @@ export async function meMainChoices() {
10
10
  type: 'list',
11
11
  name: 'action',
12
12
  message: 'Choose an action:',
13
- choices: ['Add new .me username', 'Confirm existing .me identity', new inquirer.Separator(), 'Exit'],
13
+ choices: ['Add .me', 'Log .me', new inquirer.Separator(), 'Exit'],
14
14
  },
15
15
  ]);
16
16
 
17
17
  switch (answers.action) {
18
- case 'Add new .me username':
18
+ case 'Add .me':
19
19
  AddMe();
20
20
  break;
21
- case 'Confirm existing .me identity':
22
- ConfirmIdentity();
21
+ case 'Log .me':
22
+ LogMe();
23
23
  break;
24
24
  case 'Exit':
25
- console.log(chalk.green('Exiting .Me CLI.'));
25
+ console.log(chalk.green('Exiting...'));
26
26
  process.exit();
27
27
  }
28
28
  }
package/src/example.js ADDED
@@ -0,0 +1,23 @@
1
+ import Me from './me.js';
2
+ import chalk from 'chalk';
3
+
4
+ // Create a new Me instance
5
+ let me = new Me('suign');
6
+ // Add attributes to the identity
7
+ me.be({ fullName: "Jose", lastName: "Abella" });
8
+ me.be({ xy: "z" });
9
+ console.log(me);
10
+ // Examplconsole.log(me.identity());e with another instance
11
+ let anotherMe = new Me('anotherUser');
12
+ anotherMe.be({ nickname: "hero", favoriteColor: "blue" });
13
+ console.log(anotherMe);
14
+ // Create a new Me instance with dynamic property name
15
+ let user = 'suign';
16
+ let users = {};
17
+ users[user] = new Me(user);
18
+ // Add attributes to the identity
19
+ users[user].be({ fullName: "ZZZ", lastName: "WWW" });
20
+ users[user].be({ xy: "axax" });
21
+ console.log(users[user]);
22
+
23
+
package/src/me.js CHANGED
@@ -1,13 +1,54 @@
1
- // define .me class usrme
1
+ //this.me/src/me.js
2
+ import crypto from 'crypto';
3
+ import os from 'os';
2
4
 
3
5
  // Define the .me class
4
6
  class Me {
5
- constructor(usrme) {
6
- this.usrme = usrme;
7
+ // Static property to keep track of all users globally
8
+ static registry = {};
9
+
10
+ constructor(username = 'monad') {
11
+ if (Me.registry[username]) {
12
+ throw new Error(`Username ${username} already exists in the registry.`);
13
+ }
14
+ this.username = this.validateMe(username);
15
+ this.identity = {
16
+ username: this.username,
17
+ hash: this.sha256(),
18
+ host: this.getHostInfo()
19
+ };
20
+ Me.registry[username] = this; // Add to global registry
7
21
  }
8
- getMe() {
9
- return this.usrme;
22
+
23
+ validateMe(username) {
24
+ const regex = /^[a-zA-Z0-9]{1,21}$/;
25
+ if (regex.test(username)) {
26
+ return username;
27
+ } else {
28
+ throw new Error('Incorrect username. Only letters and numbers are allowed, and it must be between 1 and 21 characters.');
29
+ }
10
30
  }
11
- }
12
31
 
13
- export default Me;
32
+ sha256() {
33
+ return crypto.createHash('sha256').update(this.username).digest('hex');
34
+ }
35
+
36
+ getHostInfo() {
37
+ return {
38
+ hostname: os.hostname(),
39
+ platform: os.platform(),
40
+ networkInterfaces: os.networkInterfaces()
41
+ };
42
+ }
43
+
44
+ be(attributes) {
45
+ for (const [key, value] of Object.entries(attributes)) {
46
+ this.identity[key] = value;
47
+ }
48
+ }
49
+
50
+ // Static method to retrieve all users
51
+ static getAllUsers() {
52
+ return Me.registry;
53
+ }
54
+ }