this.me 2.9.0 → 2.9.1
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 +135 -38
- package/index.js +12 -6
- package/package.json +1 -1
- package/src/.me.cli.js +7 -7
- package/src/CLI/{ConfirmIdentity.js → LogMe.js} +4 -4
- package/src/CLI/me_MainChoices.js +6 -6
- package/src/example.js +23 -0
- package/src/me.js +45 -5
package/README.md
CHANGED
|
@@ -1,22 +1,24 @@
|
|
|
1
|
-
<img src="https://suign.github.io/assets/imgs/cleak_me-removebg.png" alt="DID Me Art" width="
|
|
2
|
-
<img src="https://suign.github.io/assets/imgs/Cleaker-removebg-preview.png" alt="Cleak Me Please" width="
|
|
3
|
-
# THIS.ME
|
|
1
|
+
<img src="https://suign.github.io/assets/imgs/cleak_me-removebg.png" alt="DID Me Art" width="69" align="right">
|
|
2
|
+
<img src="https://suign.github.io/assets/imgs/Cleaker-removebg-preview.png" alt="Cleak Me Please" width="277" align="right">
|
|
4
3
|
|
|
5
|
-
-----------
|
|
6
4
|
|
|
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.
|
|
10
5
|
|
|
11
|
-
----------
|
|
12
6
|
|
|
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.
|
|
15
7
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
# THIS.ME
|
|
19
|
+
|
|
20
|
+
**This.Me** is a data-structured identity.
|
|
21
|
+
|
|
20
22
|
1. **Install `this.me`:**
|
|
21
23
|
Open your terminal and run the following command to install the `this.me` package:
|
|
22
24
|
|
|
@@ -31,16 +33,130 @@ Hello, I am .lisa
|
|
|
31
33
|
import Me from 'this.me';
|
|
32
34
|
```
|
|
33
35
|
|
|
36
|
+
**Explanation**
|
|
37
|
+
|
|
38
|
+
1. **Dynamic Identity Addition**:
|
|
39
|
+
|
|
40
|
+
• The **be** method in the **Me** class accepts an object of **key-value pairs** and **adds these to the identity object**.
|
|
41
|
+
|
|
42
|
+
2. **Flexible Attribute Addition**:
|
|
43
|
+
|
|
44
|
+
• You can call **me.be()** multiple times with different attributes to dynamically update the identity object.
|
|
45
|
+
|
|
46
|
+
```javascript
|
|
47
|
+
// Create a new Me instance
|
|
48
|
+
let me = new Me("xyxyxy");
|
|
49
|
+
|
|
50
|
+
// Add attributes to the identity
|
|
51
|
+
me.be({ a: "XXX", b: "YYY" });
|
|
52
|
+
me.be({ c: "z" });
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
**A less abstract example:**
|
|
56
|
+
|
|
57
|
+
```js
|
|
58
|
+
// Add attributes to the identity
|
|
59
|
+
me.be({ name: "XXXY WWC", phone: "33550000" });
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
**Dynamic Property Assignment**:
|
|
63
|
+
|
|
64
|
+
• We use an object users to store Me instances, with each key being the username.
|
|
65
|
+
|
|
66
|
+
• `users[username] = new Me(username)` dynamically assigns the Me instance to a key that matches the username.
|
|
67
|
+
|
|
68
|
+
**Accessing Instances**:
|
|
69
|
+
|
|
70
|
+
• You can access the Me instance using the username as the key: `users['suign']`.
|
|
71
|
+
|
|
72
|
+
**Adding Attributes**:
|
|
73
|
+
|
|
74
|
+
• The **be()** method is used to add attributes to the identity object.
|
|
75
|
+
|
|
76
|
+
. **Example Usage**:
|
|
77
|
+
|
|
78
|
+
• Two users, user1 and user2, are created and their identities are dynamically managed within the **users** object.
|
|
79
|
+
|
|
80
|
+
--------
|
|
81
|
+
|
|
82
|
+
### Neural Networks - **One-Hot Encoding**
|
|
83
|
+
|
|
84
|
+
------
|
|
85
|
+
|
|
86
|
+
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.
|
|
87
|
+
|
|
88
|
+
Here’s a step-by-step approach to achieve this:
|
|
89
|
+
|
|
90
|
+
1. **One-Hot Encoding:** Convert each element (“me”, “you”, “him”, “her”, “it”, “us”, “them”) into a one-hot encoded vector.
|
|
91
|
+
2. **Combination Representation:** Create input vectors for each combination by combining the one-hot encoded vectors.
|
|
92
|
+
3. **Neural Network Design:** Design a simple neural network to process these input vectors.
|
|
93
|
+
|
|
94
|
+
#### Step 1: One-Hot Encoding
|
|
95
|
+
|
|
96
|
+
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:
|
|
97
|
+
|
|
98
|
+
```js
|
|
99
|
+
// Create Me instances
|
|
100
|
+
const meInstance = new Me('me');
|
|
101
|
+
const youInstance = new Me('you');
|
|
102
|
+
const himInstance = new Me('him');
|
|
103
|
+
const herInstance = new Me('her');
|
|
104
|
+
const itInstance = new Me('it');
|
|
105
|
+
const usInstance = new Me('us');
|
|
106
|
+
const themInstance = new Me('them');
|
|
107
|
+
|
|
108
|
+
// One-hot encoding representation
|
|
109
|
+
const subjects = {
|
|
110
|
+
'me': [1, 0, 0, 0, 0, 0, 0],
|
|
111
|
+
'you': [0, 1, 0, 0, 0, 0, 0],
|
|
112
|
+
'him': [0, 0, 1, 0, 0, 0, 0],
|
|
113
|
+
'her': [0, 0, 0, 1, 0, 0, 0],
|
|
114
|
+
'it': [0, 0, 0, 0, 1, 0, 0],
|
|
115
|
+
'us': [0, 0, 0, 0, 0, 1, 0],
|
|
116
|
+
'them': [0, 0, 0, 0, 0, 0, 1]
|
|
117
|
+
};
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
#### Step 2: Combination Representation
|
|
121
|
+
|
|
122
|
+
For each combination, we can create an input vector by combining the one-hot encoded vectors of its elements. For example:
|
|
123
|
+
|
|
124
|
+
Combination “me, you” would be represented as the sum of the one-hot vectors for “me” and “you”:
|
|
125
|
+
|
|
126
|
+
```
|
|
127
|
+
[1, 0, 0, 0, 0, 0, 0] + [0, 1, 0, 0, 0, 0, 0] = [1, 1, 0, 0, 0, 0, 0]
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
Hello, I am .me
|
|
132
|
+
? Who are you? (Use arrow keys)
|
|
133
|
+
❯ add.me
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
1. **Install `this.me`:**
|
|
137
|
+
Open your terminal and run the following command to install the `this.me` package:
|
|
138
|
+
|
|
139
|
+
```js
|
|
140
|
+
npm install this.me
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
2. **Import `Me` in Your Project:**
|
|
144
|
+
In the JavaScript file where you want to use `this.me`, import the `Me` class.
|
|
145
|
+
|
|
146
|
+
```js
|
|
147
|
+
import Me from 'this.me';
|
|
148
|
+
```
|
|
149
|
+
|
|
34
150
|
3. **Create an Instance of `Me`:**
|
|
35
151
|
Instantiate the `Me` class with the required user details.
|
|
36
|
-
|
|
152
|
+
|
|
37
153
|
```js
|
|
38
154
|
const user = new Me('John', 'Doe', '1990-01-01', 'password123', '1234');
|
|
39
155
|
```
|
|
40
|
-
|
|
156
|
+
|
|
41
157
|
4. **Validate and Use the Instance:**
|
|
42
158
|
Utilize the instance for user data validation and preparation for cryptographic actions.
|
|
43
|
-
|
|
159
|
+
In other words. Log In.
|
|
44
160
|
```js
|
|
45
161
|
try {
|
|
46
162
|
const identity = user.getMe();
|
|
@@ -56,35 +172,16 @@ This quick start guide provides a straightforward path to incorporating `this.me
|
|
|
56
172
|
----------
|
|
57
173
|
|
|
58
174
|
# About All.This
|
|
59
|
-
|
|
60
175
|
## Modular Data Structures:
|
|
61
|
-
|
|
62
176
|
**[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/)**
|
|
63
177
|
|
|
64
178
|
**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.**
|
|
65
179
|
|
|
66
|
-
##
|
|
67
|
-
|
|
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
|
-
|
|
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
|
-
|
|
72
|
-
### Neurons.me Ecosystem Glossary:
|
|
73
|
-
|
|
74
|
-
visit: [Neurons.me Glossary](https://suign.github.io/neurons.me/Glossary)
|
|
75
|
-
|
|
76
|
-
## License & Policies
|
|
77
|
-
|
|
180
|
+
## Neurons.me
|
|
181
|
+
### License & Policies
|
|
78
182
|
- **License**: MIT License (see LICENSE for details).
|
|
79
|
-
|
|
80
183
|
- **Privacy Policy**: Respects user privacy; no collection/storage of personal data.
|
|
81
|
-
|
|
82
184
|
- **Terms of Usage**: Use responsibly. No guarantees/warranties provided. [Terms](https://www.neurons.me/terms-of-use) | [Privacy](https://www.neurons.me/privacy-policy)
|
|
83
|
-
|
|
84
|
-
**Learn more** at https://neurons.me
|
|
85
|
-
|
|
86
|
-
**Author:** SuiGn
|
|
87
|
-
|
|
88
185
|
[By neurons.me](https://neurons.me)
|
|
89
186
|
|
|
90
187
|
<img src="https://suign.github.io/neurons.me/neurons_logo.png" alt="neurons.me logo" width="123" height="123" style="width123px; height:123px;">
|
package/index.js
CHANGED
|
@@ -8,12 +8,18 @@
|
|
|
8
8
|
* This dual functionality ensures seamless interoperability and heightened security.
|
|
9
9
|
* Command Definitions and Interactive Shell.*/
|
|
10
10
|
|
|
11
|
-
//
|
|
11
|
+
//index.js in the `this.me` package
|
|
12
12
|
import Me from './src/me.js';
|
|
13
|
-
let ia = new Me('.Lisa');
|
|
14
|
-
let me = ia.getMe();
|
|
15
13
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
//when a user declares "I am," their digital existence is affirmed and recorded in the system.
|
|
15
|
+
//The user's `.me` object is then retrieved and displayed.
|
|
16
|
+
//The user is greeted with their `.me` object, and the system is queried about its own identity.
|
|
17
|
+
/*
|
|
18
|
+
User Instance Hash: Anchoring each user’s identity and space is a cryptographic hash, providing a secure and unique foundation.
|
|
19
|
+
This unique space not only encapsulates its creator but can also forge Inter-Space Connections with others, manifesting in:
|
|
20
|
+
Relative Paths: Tailoring interactions within a user’s space, relative paths connect varied datasets, objects, and interactions in a user-oriented manner.
|
|
21
|
+
Cross Paths: Creating conduits between user spaces, allowing permissioned access to specific datasets and interactions.
|
|
22
|
+
Dual Endpoints: Curating diverse experiences through endpoints that exhibit varied interactions or representations based on user permissions and contexts.
|
|
23
|
+
*/
|
|
24
|
+
|
|
19
25
|
export default Me;
|
package/package.json
CHANGED
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';
|
|
6
|
-
import
|
|
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
|
|
13
|
+
.description('+ Add .me')
|
|
14
14
|
.action(AddMe);
|
|
15
15
|
|
|
16
|
-
program.command('
|
|
17
|
-
.description('
|
|
18
|
-
.action(
|
|
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/
|
|
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
|
|
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(
|
|
23
|
+
console.log(chalk.green(`.me confirmed: ${selectedUser}`));
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
export default
|
|
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
|
|
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
|
|
13
|
+
choices: ['Add .me', 'Log .me', new inquirer.Separator(), 'Exit'],
|
|
14
14
|
},
|
|
15
15
|
]);
|
|
16
16
|
|
|
17
17
|
switch (answers.action) {
|
|
18
|
-
case 'Add
|
|
18
|
+
case 'Add .me':
|
|
19
19
|
AddMe();
|
|
20
20
|
break;
|
|
21
|
-
case '
|
|
22
|
-
|
|
21
|
+
case 'Log .me':
|
|
22
|
+
LogMe();
|
|
23
23
|
break;
|
|
24
24
|
case 'Exit':
|
|
25
|
-
console.log(chalk.green('Exiting
|
|
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.identify());
|
|
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.identify());
|
|
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,12 +1,52 @@
|
|
|
1
|
-
//
|
|
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(
|
|
6
|
-
this.
|
|
7
|
+
constructor(username = 'monad') {
|
|
8
|
+
this.username = this.validateUsername(username);
|
|
9
|
+
this.identity = {
|
|
10
|
+
username: this.username,
|
|
11
|
+
hash: this.sha256(),
|
|
12
|
+
host: this.getHostInfo()
|
|
13
|
+
};
|
|
7
14
|
}
|
|
8
|
-
|
|
9
|
-
|
|
15
|
+
|
|
16
|
+
// Method to validate the username
|
|
17
|
+
validateUsername(username) {
|
|
18
|
+
const regex = /^[a-zA-Z0-9]+$/; // Only letters and numbers
|
|
19
|
+
if (regex.test(username)) {
|
|
20
|
+
return username;
|
|
21
|
+
} else {
|
|
22
|
+
throw new Error('Incorrect username. Only letters and numbers are allowed.');
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Method to generate a cryptographic hash of the username
|
|
27
|
+
sha256() {
|
|
28
|
+
return crypto.createHash('sha256').update(this.username).digest('hex');
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Method to get host information
|
|
32
|
+
getHostInfo() {
|
|
33
|
+
return {
|
|
34
|
+
hostname: os.hostname(),
|
|
35
|
+
platform: os.platform(),
|
|
36
|
+
networkInterfaces: os.networkInterfaces()
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Method to add key-value pairs to the identity object
|
|
41
|
+
be(attributes) {
|
|
42
|
+
for (const [key, value] of Object.entries(attributes)) {
|
|
43
|
+
this.identity[key] = value;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Method to get the identity object
|
|
48
|
+
identify() {
|
|
49
|
+
return this.be;
|
|
10
50
|
}
|
|
11
51
|
}
|
|
12
52
|
|