this.me 2.8.1 → 2.8.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.
Files changed (59) hide show
  1. package/README.md +44 -55
  2. package/index.js +15 -0
  3. package/jsdoc.json +21 -13
  4. package/nino.js +2 -0
  5. package/package.json +3 -7
  6. package/src/cli/CLI.md +20 -0
  7. package/src/cli/ascii_art/welcome.js +1 -1
  8. package/src/cli/commands.js +17 -0
  9. package/src/cli/main.js +23 -167
  10. package/src/cli/shell.js +201 -0
  11. package/src/hash.js +24 -0
  12. package/src/me.html +0 -19
  13. package/src/me.js +6 -4
  14. package/src/searchImages.js +31 -0
  15. package/Cleaker-removebg-preview (1).png +0 -0
  16. package/docs/Me.html +0 -697
  17. package/docs/README.md +0 -77
  18. package/docs/ThisMe.html +0 -690
  19. package/docs/cli_main.js.html +0 -382
  20. package/docs/fonts/OpenSans-Bold-webfont.eot +0 -0
  21. package/docs/fonts/OpenSans-Bold-webfont.svg +0 -1830
  22. package/docs/fonts/OpenSans-Bold-webfont.woff +0 -0
  23. package/docs/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
  24. package/docs/fonts/OpenSans-BoldItalic-webfont.svg +0 -1830
  25. package/docs/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
  26. package/docs/fonts/OpenSans-Italic-webfont.eot +0 -0
  27. package/docs/fonts/OpenSans-Italic-webfont.svg +0 -1830
  28. package/docs/fonts/OpenSans-Italic-webfont.woff +0 -0
  29. package/docs/fonts/OpenSans-Light-webfont.eot +0 -0
  30. package/docs/fonts/OpenSans-Light-webfont.svg +0 -1831
  31. package/docs/fonts/OpenSans-Light-webfont.woff +0 -0
  32. package/docs/fonts/OpenSans-LightItalic-webfont.eot +0 -0
  33. package/docs/fonts/OpenSans-LightItalic-webfont.svg +0 -1835
  34. package/docs/fonts/OpenSans-LightItalic-webfont.woff +0 -0
  35. package/docs/fonts/OpenSans-Regular-webfont.eot +0 -0
  36. package/docs/fonts/OpenSans-Regular-webfont.svg +0 -1831
  37. package/docs/fonts/OpenSans-Regular-webfont.woff +0 -0
  38. package/docs/global.html +0 -454
  39. package/docs/index.html +0 -257
  40. package/docs/me.js.html +0 -211
  41. package/docs/module-CLI.html +0 -1117
  42. package/docs/neurons_logo.png +0 -0
  43. package/docs/scripts/app.min.js +0 -1
  44. package/docs/scripts/linenumber.js +0 -26
  45. package/docs/scripts/prettify/Apache-License-2.0.txt +0 -202
  46. package/docs/scripts/prettify/lang-css.js +0 -2
  47. package/docs/scripts/prettify/prettify.js +0 -28
  48. package/docs/scripts/search.js +0 -39
  49. package/docs/styles/app.min.css +0 -1
  50. package/docs/styles/iframe.css +0 -13
  51. package/docs/styles/jsdoc-default.css +0 -358
  52. package/docs/styles/prettify-jsdoc.css +0 -111
  53. package/docs/styles/prettify-tomorrow.css +0 -132
  54. package/docs/styles/reset.css +0 -44
  55. package/src/os/unix/install_me.sh +0 -5
  56. package/src/this/dir.js +0 -0
  57. package/src/this/file.js +0 -0
  58. package/src/this/url.js +0 -0
  59. package/src/this/video.js +0 -0
@@ -0,0 +1,201 @@
1
+ import inquirer from 'inquirer';
2
+ import path from 'path';
3
+ import os from 'os';
4
+ import fs from 'fs';
5
+ import Me from 'this.me';
6
+
7
+ /***Interactive Shell:
8
+ * Leverages the `inquirer` package to provide an interactive shell experience with prompts.
9
+ * The `main` function orchestrates the CLI interactions.
10
+ */
11
+
12
+ /**
13
+ * View Existing Profiles, Create New Profile, Exit.
14
+ * @returns {Promise<string>} The user's choice.
15
+ */
16
+ async function selectMe() {
17
+ const choices = ['View Existing Profiles', 'Create New Profile', 'Exit'];
18
+ const answer = await inquirer.prompt([{
19
+ type: 'list',
20
+ name: 'action',
21
+ message: 'What would you like to do?',
22
+ choices: choices
23
+ }]);
24
+ return answer.action;
25
+ }
26
+
27
+ /**
28
+ * Prompts the user for details to create a new profile.
29
+ * @returns {Promise<Me>} The new Me object with user details.
30
+ */
31
+ async function createMe() {
32
+ const questions = [
33
+ {
34
+ type: 'input',
35
+ name: 'name',
36
+ message: 'What is your first name?',
37
+ // Add validation as needed
38
+ },
39
+ {
40
+ type: 'input',
41
+ name: 'lastname',
42
+ message: 'What is your last name?',
43
+ // Add validation as needed
44
+ },
45
+ {
46
+ type: 'input',
47
+ name: 'birthday',
48
+ message: 'What is your birthday? (YYYY-MM-DD)',
49
+ validate: function(value) {
50
+ const pass = value.match(
51
+ /^\d{4}-\d{2}-\d{2}$/
52
+ );
53
+ if (pass) {
54
+ return true;
55
+ }
56
+ return 'Please enter a valid date (YYYY-MM-DD)';
57
+ }
58
+ },
59
+ {
60
+ type: 'password',
61
+ name: 'password',
62
+ message: 'Choose a password:',
63
+ // Add validation as needed
64
+ },
65
+ {
66
+ type: 'input',
67
+ name: 'pin',
68
+ message: 'Choose a PIN:',
69
+ // Add validation as needed
70
+ },
71
+ // ... Add more questions as needed
72
+ ];
73
+ const userDetails = await inquirer.prompt(questions);
74
+ return new Me(
75
+ userDetails.name,
76
+ userDetails.lastname,
77
+ userDetails.birthday,
78
+ userDetails.password,
79
+ userDetails.pin
80
+ );
81
+ }
82
+
83
+ /**
84
+ * Writes the .me object to the filesystem.
85
+ * @param {Me} meProfile - The Me object to be saved.
86
+ */
87
+ function writeMe(meProfile) {
88
+ const meDirectory = path.join(os.homedir(), '.me');
89
+ if (!fs.existsSync(meDirectory)) {
90
+ fs.mkdirSync(meDirectory, { recursive: true });
91
+ }
92
+
93
+ const filePath = path.join(meDirectory, `${meProfile.name}.me`);
94
+ // Encrypting the data here before writing to the filesystem
95
+ //fs.writeFileSync(filePath, JSON.stringify(meProfile.getIdentityObject()));
96
+ //console.log('Profile created successfully.');
97
+ fs.writeFileSync(filePath, JSON.stringify(meProfile.getMe()));
98
+ console.log('Profile created successfully.');
99
+ }
100
+
101
+ /**
102
+ * Lists all the .me profile file paths in the user's .me directory.
103
+ * @returns {string[]} An array of full file paths for each .me profile.
104
+ */
105
+ function listMeProfiles() {
106
+ const meDirectory = path.join(os.homedir(), '.me');
107
+ if (fs.existsSync(meDirectory)) {
108
+ const profileFiles = fs.readdirSync(meDirectory)
109
+ .filter(file => file.endsWith('.me'));
110
+ return profileFiles.map(file => path.join(meDirectory, file));
111
+ } else {
112
+ console.log('No profiles found.');
113
+ return [];
114
+ }
115
+ }
116
+
117
+ /**
118
+ * Asks the user to verify their PIN.
119
+ * @param {Object} profile - The user's profile object containing their data, including the PIN.
120
+ * @returns {Promise<string>} Returns 'success' if the PIN is correct, 'back' to return to the previous menu.
121
+ */
122
+ async function verifyPin(profile) {
123
+ while (true) {
124
+ const answer = await inquirer.prompt([{
125
+ type: 'password',
126
+ name: 'pin',
127
+ message: 'Enter your PIN to proceed:',
128
+ }]);
129
+
130
+ if (answer.pin === profile.pin) {
131
+ // Correct PIN
132
+ //console.log('Profile Data:', profile);
133
+ console.log(`Welcome ${profile.name}!`);
134
+ return 'success';
135
+ } else {
136
+ // Incorrect PIN
137
+ console.log('Incorrect PIN.');
138
+ const retryChoice = await inquirer.prompt([{
139
+ type: 'list',
140
+ name: 'action',
141
+ message: 'What would you like to do?',
142
+ choices: ['Try Again', 'Go Back']
143
+ }]);
144
+ if (retryChoice.action === 'Go Back') {
145
+ return 'back';
146
+ }
147
+ }
148
+ }
149
+ }
150
+
151
+ /**
152
+ * Allows the user to select a .me profile from a list or go back to the main menu.
153
+ * After selecting a profile, the user is asked to verify their PIN.
154
+ * @returns {Promise<Object|string>} Returns the selected profile object upon successful PIN verification, or 'back' to indicate returning to the main menu.
155
+ */
156
+ async function selectProfile() {
157
+ const profiles = listMeProfiles();
158
+ if (profiles.length === 0) {
159
+ console.log('No profiles found.');
160
+ return 'back';
161
+ }
162
+
163
+ const choices = profiles.map(file => ({
164
+ name: path.basename(file, '.me'),
165
+ value: file
166
+ })).concat([{ name: 'Go Back to Main Menu', value: 'back' }]);
167
+
168
+ const answer = await inquirer.prompt([{
169
+ type: 'list',
170
+ name: 'selectedProfile',
171
+ message: 'Select a profile to view or go back:',
172
+ choices: choices
173
+ }]);
174
+
175
+ if (answer.selectedProfile === 'back') {
176
+ return 'back';
177
+ } else {
178
+ const profileData = fs.readFileSync(answer.selectedProfile, 'utf8');
179
+ const profile = JSON.parse(profileData);
180
+
181
+ const pinVerified = await verifyPin(profile);
182
+ if (!pinVerified) {
183
+ console.log('PIN verification failed. Returning to main menu.');
184
+ return 'back';
185
+ }
186
+
187
+ // After successful PIN verification, proceed to a different section of the CLI.
188
+ // ... Transition to different CLI section logic goes here ...
189
+
190
+ return profile; // Return the profile data for further processing if needed.
191
+ }
192
+ }
193
+
194
+
195
+ export const shell = {
196
+ selectMe,
197
+ createMe,
198
+ writeMe,
199
+ listMeProfiles,
200
+ selectProfile,
201
+ };
package/src/hash.js ADDED
@@ -0,0 +1,24 @@
1
+ const crypto = require('crypto');
2
+
3
+ function generateKeyPair() {
4
+ const { publicKey, privateKey } = crypto.generateKeyPairSync('rsa', {
5
+ modulusLength: 2048,
6
+ publicKeyEncoding: {
7
+ type: 'spki',
8
+ format: 'pem',
9
+ },
10
+ privateKeyEncoding: {
11
+ type: 'pkcs8',
12
+ format: 'pem',
13
+ },
14
+ });
15
+
16
+ // Store the keys securely (e.g., in files or secure storage).
17
+
18
+ return { publicKey, privateKey };
19
+ }
20
+
21
+ // Example usage:
22
+ const { publicKey, privateKey } = generateKeyPair();
23
+ console.log('Public Key:', publicKey);
24
+ console.log('Private Key:', privateKey);
package/src/me.html CHANGED
@@ -4,24 +4,5 @@
4
4
  </head>
5
5
  <body>
6
6
  Hello, me!
7
- <script>
8
- window.fbAsyncInit = function() {
9
- FB.init({
10
- appId : '{your-app-id}',
11
- cookie : true,
12
- xfbml : true,
13
- version : '{api-version}'
14
- });
15
- FB.AppEvents.logPageView();
16
- };
17
-
18
- (function(d, s, id){
19
- var js, fjs = d.getElementsByTagName(s)[0];
20
- if (d.getElementById(id)) {return;}
21
- js = d.createElement(s); js.id = id;
22
- js.src = "https://connect.facebook.net/en_US/sdk.js";
23
- fjs.parentNode.insertBefore(js, fjs);
24
- }(document, 'script', 'facebook-jssdk'));
25
- </script>
26
7
  </body>
27
8
  </html>
package/src/me.js CHANGED
@@ -1,3 +1,4 @@
1
+ //src/me.js
1
2
  /**
2
3
  * Represents a user identity in the this.me system.
3
4
  */
@@ -30,16 +31,17 @@ class Me {
30
31
  }
31
32
 
32
33
  /**
33
- * Prepares and returns the identity object for hashing.
34
- * @returns {Object} The identity object with user data.
34
+ * Prepares and returns the identity object for hashing .me.
35
+ * @returns {Object} The identity object (.me) with user data.
35
36
  */
36
- getIdentityObject() {
37
+ getMe() {
37
38
  this.validateData();
38
39
  return {
39
40
  name: this.name,
40
41
  lastname: this.lastname,
41
42
  birthday: this.birthday,
42
- credentials: `${this.password}:${this.pin}` // Combining password and pin
43
+ password: this.password, // Password as a separate field
44
+ pin: this.pin // Pin as a separate field
43
45
  };
44
46
  }
45
47
  }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Filters and displays images based on the user's search input.
3
+ * It searches through the filenames of the images in each gallery.
4
+ * The function is case-insensitive and matches any part of the filename.
5
+ *
6
+ * @example
7
+ * // Assuming there's an input field with id 'searchInput' and images in galleries.
8
+ * // User types 'example' in the search input.
9
+ * searchImages();
10
+ * // Images with 'example' in their filenames will be displayed.
11
+ */
12
+ function searchImages() {
13
+ var input, filter, gallery, img, src, i;
14
+ input = document.getElementById("searchInput");
15
+ filter = input.value.toUpperCase();
16
+ gallery = document.getElementsByClassName("gallery");
17
+
18
+ for (var g = 0; g < gallery.length; g++) {
19
+ img = gallery[g].getElementsByTagName("img");
20
+
21
+ for (i = 0; i < img.length; i++) {
22
+ src = img[i].src;
23
+ var fileName = src.substring(src.lastIndexOf('/') + 1);
24
+ if (fileName.toUpperCase().indexOf(filter) > -1) {
25
+ img[i].style.display = "";
26
+ } else {
27
+ img[i].style.display = "none";
28
+ }
29
+ }
30
+ }
31
+ }
Binary file