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.
- package/README.md +44 -55
- package/index.js +15 -0
- package/jsdoc.json +21 -13
- package/nino.js +2 -0
- package/package.json +3 -7
- package/src/cli/CLI.md +20 -0
- package/src/cli/ascii_art/welcome.js +1 -1
- package/src/cli/commands.js +17 -0
- package/src/cli/main.js +23 -167
- package/src/cli/shell.js +201 -0
- package/src/hash.js +24 -0
- package/src/me.html +0 -19
- package/src/me.js +6 -4
- package/src/searchImages.js +31 -0
- package/Cleaker-removebg-preview (1).png +0 -0
- package/docs/Me.html +0 -697
- package/docs/README.md +0 -77
- package/docs/ThisMe.html +0 -690
- package/docs/cli_main.js.html +0 -382
- package/docs/fonts/OpenSans-Bold-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Bold-webfont.svg +0 -1830
- package/docs/fonts/OpenSans-Bold-webfont.woff +0 -0
- package/docs/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
- package/docs/fonts/OpenSans-BoldItalic-webfont.svg +0 -1830
- package/docs/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
- package/docs/fonts/OpenSans-Italic-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Italic-webfont.svg +0 -1830
- package/docs/fonts/OpenSans-Italic-webfont.woff +0 -0
- package/docs/fonts/OpenSans-Light-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Light-webfont.svg +0 -1831
- package/docs/fonts/OpenSans-Light-webfont.woff +0 -0
- package/docs/fonts/OpenSans-LightItalic-webfont.eot +0 -0
- package/docs/fonts/OpenSans-LightItalic-webfont.svg +0 -1835
- package/docs/fonts/OpenSans-LightItalic-webfont.woff +0 -0
- package/docs/fonts/OpenSans-Regular-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Regular-webfont.svg +0 -1831
- package/docs/fonts/OpenSans-Regular-webfont.woff +0 -0
- package/docs/global.html +0 -454
- package/docs/index.html +0 -257
- package/docs/me.js.html +0 -211
- package/docs/module-CLI.html +0 -1117
- package/docs/neurons_logo.png +0 -0
- package/docs/scripts/app.min.js +0 -1
- package/docs/scripts/linenumber.js +0 -26
- package/docs/scripts/prettify/Apache-License-2.0.txt +0 -202
- package/docs/scripts/prettify/lang-css.js +0 -2
- package/docs/scripts/prettify/prettify.js +0 -28
- package/docs/scripts/search.js +0 -39
- package/docs/styles/app.min.css +0 -1
- package/docs/styles/iframe.css +0 -13
- package/docs/styles/jsdoc-default.css +0 -358
- package/docs/styles/prettify-jsdoc.css +0 -111
- package/docs/styles/prettify-tomorrow.css +0 -132
- package/docs/styles/reset.css +0 -44
- package/src/os/unix/install_me.sh +0 -5
- package/src/this/dir.js +0 -0
- package/src/this/file.js +0 -0
- package/src/this/url.js +0 -0
- package/src/this/video.js +0 -0
package/README.md
CHANGED
|
@@ -1,77 +1,66 @@
|
|
|
1
|
-
<img src="https://suign.github.io/this.me/neurons_logo.png" alt="SVG Image" width="123" height="123" style="width123px; height:123px;">
|
|
2
|
-
|
|
3
1
|
# This.Me
|
|
2
|
+
<img src="./cleak_me-removebg.png" alt="SVG Image" style="width:89px;">
|
|
3
|
+
<img src="./this.me.png" alt="SVG Image" style="width:89px;">
|
|
4
4
|
|
|
5
|
-
**This.Me**
|
|
6
|
-
Users no longer depend on centralized authorities for **identity and data management**. They hold the keys (literally) to their identity and data.
|
|
7
|
-
Services become more **user-centric,** providing services based on cryptographic proofs rather than centralized authorities.
|
|
8
|
-
Here, you don't just own your identity; you seal it with cryptographic brilliance, untouched and ungoverned by any other.
|
|
5
|
+
**This.Me** defines a digital identity through a cryptographic lens. Each user is equipped with a unique **'Me'** identity, secured by public-private key cryptography, enabling robust autonomous identity verification and transactional security.
|
|
9
6
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
**This.Me** incorporates hashing for unimpeachable data integrity and digital signatures for undeniable authenticity. Users gain unparalleled control over their digital footprint, marking a shift towards a user-centric model of data management.
|
|
8
|
+
|
|
9
|
+
In essence, **This.Me** grants users a self-sovereign digital identity, fully within their control and independent from external entities.
|
|
10
|
+
|
|
11
|
+
### CLI Usage:
|
|
12
|
+
Install globally to use `this.me` as a CLI tool:
|
|
14
13
|
|
|
15
|
-
### Require it:
|
|
16
14
|
```js
|
|
17
|
-
|
|
15
|
+
npm install -g this.me
|
|
18
16
|
```
|
|
19
17
|
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
Then, interact with `this.me` directly from your command line.
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Usage in Node.js:
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm install this.me
|
|
27
|
+
```
|
|
22
28
|
|
|
23
29
|
```js
|
|
24
30
|
const ThisMe = require('this.me');
|
|
31
|
+
// Create a new user identity
|
|
25
32
|
const user = new ThisMe('John', 'Doe', '1990-01-01', 'mypassword123', '1234');
|
|
33
|
+
// Retrieve the user's identity object
|
|
26
34
|
const identityObject = user.getIdentityObject();
|
|
27
|
-
// identityObject can now be passed to Cleaker for hashing
|
|
28
35
|
```
|
|
29
36
|
|
|
30
|
-
##
|
|
37
|
+
## Core Principles
|
|
38
|
+
|
|
39
|
+
- The `Me` class encapsulates personal information:
|
|
40
|
+
|
|
41
|
+
name,
|
|
42
|
+
last name,
|
|
43
|
+
birthday,
|
|
44
|
+
password,
|
|
45
|
+
PIN
|
|
46
|
+
|
|
47
|
+
This serves as the identity representation in our system.
|
|
31
48
|
|
|
32
|
-
|
|
49
|
+
The `all.this` collection of packages, along with the proposed `cleaker` functionality, is an approach to create a modular system where each module (like `this.text`, `this.video`, `this.img`, etc.) (all.this family) represents a distinct data structure or class. These modules, when combined with `cleaker`, generate unique **public and private key pairs**, essentially giving each instance its cryptographic identity.
|
|
33
50
|
|
|
34
|
-
|
|
35
|
-
**Data Validation:** Functions to validate the input data.
|
|
36
|
-
**Data Processing:** Preparing data for hashing (by Cleaker).
|
|
37
|
-
**Exporting Data:** A method to export the processed data in a format that Cleaker can accept.
|
|
51
|
+
### Hashing and Digital Signatures
|
|
38
52
|
|
|
53
|
+
**This.Me** leverages hashing to protect data integrity, with each transaction generating a unique, tamper-proof hash. Digital signatures, created using private keys, provide a layer of authenticity and non-repudiation, linking data unmistakably to its owner.
|
|
54
|
+
|
|
55
|
+
## Contextual Environment
|
|
56
|
+
|
|
57
|
+
**This.Me** adapts to various environments, enabling `.me` objects to function both locally and within a network. A `.me` object authenticated on a network accesses data beyond the local scope, while unauthenticated instances are confined to local data. This dual functionality ensures seamless interoperability and heightened security.
|
|
58
|
+
|
|
59
|
+
## Setting up your Context. 👋🏻👋🏼👋🏽👋🏾👋🏿
|
|
39
60
|
|
|
40
|
-
# Setting up your Context. 👋🏻👋🏼👋🏽👋🏾👋🏿
|
|
41
61
|
Defining the **environment** and context in which your code runs, especially when you're interacting with intelligent agents or services like **me.**
|
|
42
62
|
|
|
43
63
|
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.
|
|
44
64
|
|
|
45
|
-
`.me` objects to serve as both a local identity on the user's host machine and as an identity within a larger network. When a `.me` object is authenticated on a network, it can access data not only on the local host but also from other nodes within that network. Conversely, if it's not authenticated or recognized by the network, it should only access local data.
|
|
46
|
-
|
|
47
|
-
### Local and Network Identity Management
|
|
48
|
-
|
|
49
|
-
1. **Local Identity**:
|
|
50
|
-
- When a `.me` object is created, it's initially configured with access to local host resources.
|
|
51
|
-
- Users can manage their local profile, which includes their personal settings, preferences, and local data access permissions.
|
|
52
|
-
2. **Network Identity**:
|
|
53
|
-
- To access resources on the network, a `.me` object must be authenticated against the network.
|
|
54
|
-
- Once authenticated, the `.me` object's hash is recognized across the network, granting the user access to network resources according to their permissions.
|
|
55
|
-
3. **Access Control**:
|
|
56
|
-
- Both local and network resources use access control lists (ACLs) that are tied to the `.me` object's hash.
|
|
57
|
-
- These ACLs determine what resources the `.me` object can access and the level of interaction permitted (read, write, execute).
|
|
58
|
-
4. **Data Fetching**:
|
|
59
|
-
- When fetching data, the system checks if the `.me` object is authenticated within the network.
|
|
60
|
-
- If authenticated, the `.me` object can retrieve data from across the network based on the established ACLs.
|
|
61
|
-
- If not authenticated, the `.me` object is limited to retrieving data from the local host.
|
|
62
|
-
5. **CLI Functionality**:
|
|
63
|
-
- The CLI tool facilitates the creation of `.me` objects, management of profiles, and authentication processes.
|
|
64
|
-
- It includes commands to "login" to the network, "logout", or "sync" local profiles with network profiles.
|
|
65
|
-
6. **Data Sharing and Security**:
|
|
66
|
-
- Data sharing across the network should be secure, with encryption mechanisms in place to protect data in transit and at rest.
|
|
67
|
-
- The `.me` object's unique hash can be part of the encryption key, ensuring that only the intended `.me` object can decrypt and access the shared data.
|
|
68
|
-
|
|
69
|
-
### CLI Commands
|
|
70
|
-
|
|
71
|
-
- `me init`: Initializes a new `.me` object on the local host.
|
|
72
|
-
- `me login`: Authenticates the `.me` object against the network to access network resources.
|
|
73
|
-
- `me logout`: De-authenticates the `.me` object from the network, reverting to local-only access.
|
|
74
|
-
- `me sync`: Synchronizes local `.me` object data with the network profile.
|
|
75
|
-
- `me fetch`: Retrieves data from the local host or network based on authentication status.
|
|
76
|
-
|
|
77
|
-
By implementing this dual identity system, you enable a seamless transition for users between operating solely on their local device and engaging with a broader network, all while maintaining strict control over their data access rights.
|
|
65
|
+
`.me` objects to serve as both a local identity on the user's host machine and as an identity within a larger network. When a `.me` object is authenticated on a network, it can access data not only on the local host but also from other nodes within that network. Conversely, if it's not authenticated or recognized by the network, it should only access local data.
|
|
66
|
+
|
package/index.js
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//index.js
|
|
2
|
+
/**
|
|
3
|
+
* @module This.Me
|
|
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.*/
|
|
10
|
+
|
|
11
|
+
// index.js in the `this.me` package
|
|
12
|
+
export { default } from './src/me.js';
|
|
13
|
+
console.log('this.me loaded successfully.');
|
|
14
|
+
// this.me/index.js
|
|
15
|
+
export { shell } from './src/cli/shell.js';
|
package/jsdoc.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"source": {
|
|
3
|
-
"include": ["./src", "./index.js", "./src/cli"]
|
|
3
|
+
"include": ["./src", "./index.js", "./src/cli", "./src/cli/commands.js", "./src/cli/shell.js"]
|
|
4
4
|
},
|
|
5
5
|
"opts": {
|
|
6
6
|
"destination": "./docs",
|
|
7
|
-
"template": "
|
|
7
|
+
"template": "../../../../../Sandbox/dev_tools/assets/better-docs",
|
|
8
8
|
"readme": "./README.md"
|
|
9
9
|
},
|
|
10
10
|
"templates": {
|
|
@@ -24,18 +24,26 @@
|
|
|
24
24
|
"hideGenerator": false,
|
|
25
25
|
"navLinks": [
|
|
26
26
|
{
|
|
27
|
-
"label": "
|
|
27
|
+
"label": "All.This",
|
|
28
28
|
"href": "https://suign.github.io/all.this/"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"label": "@Source",
|
|
32
|
+
"href": "https://suign.github.io/"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"label": "Github",
|
|
36
|
+
"href": "https://github.com/suiGn/cleaker"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"label": "Cleaker.me",
|
|
40
|
+
"href": "https://cleaker.me"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"label": "What is all.this?",
|
|
44
|
+
"href": "https://www.neurons.me/this"
|
|
45
|
+
}
|
|
38
46
|
]
|
|
39
|
-
|
|
47
|
+
}
|
|
40
48
|
}
|
|
41
49
|
}
|
package/nino.js
ADDED
package/package.json
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "this.me",
|
|
3
|
-
"version": "2.8.
|
|
4
|
-
"description": "User-Centric
|
|
5
|
-
"bin": {
|
|
6
|
-
".me": "./src/cli/main.js"
|
|
7
|
-
},
|
|
3
|
+
"version": "2.8.3",
|
|
4
|
+
"description": "User-Centric.",
|
|
8
5
|
"type": "module",
|
|
9
6
|
"main": "index.js",
|
|
10
7
|
"scripts": {
|
|
@@ -30,7 +27,6 @@
|
|
|
30
27
|
"repoType": "NPM Package",
|
|
31
28
|
"dependencies": {
|
|
32
29
|
"commander": "^11.1.0",
|
|
33
|
-
"inquirer": "^9.2.12"
|
|
34
|
-
"taffydb": "^2.7.3"
|
|
30
|
+
"inquirer": "^9.2.12"
|
|
35
31
|
}
|
|
36
32
|
}
|
package/src/cli/CLI.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Main CLI Application (main.ts)
|
|
2
|
+
|
|
3
|
+
This is the entry point for your CLI application.
|
|
4
|
+
It displays a welcome message and user information (host session and path).
|
|
5
|
+
It imports the CLI commands (commands.ts) and the interactive shell (shell.ts).
|
|
6
|
+
CLI Commands (commands.ts)
|
|
7
|
+
|
|
8
|
+
This part defines the CLI commands and options using the commander package.
|
|
9
|
+
Currently, it defines the commands: 'View Existing Profiles,' 'Create New Profile,' and 'Exit.'
|
|
10
|
+
Interactive Shell (shell.ts)
|
|
11
|
+
|
|
12
|
+
The interactive shell provides a user-friendly interface for interacting with the CLI.
|
|
13
|
+
selectMe: Presents a list of actions for the user to choose from.
|
|
14
|
+
createMe: Prompts the user for details to create a new Me profile.
|
|
15
|
+
writeMe: Writes the Me profile to the filesystem.
|
|
16
|
+
listMeProfiles: Lists all existing Me profiles.
|
|
17
|
+
selectProfile: Prompts the user to select a Me profile or go back to the main menu.
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// src/cli/commands.js
|
|
2
|
+
|
|
3
|
+
import { Command } from 'commander';
|
|
4
|
+
const program = new Command();
|
|
5
|
+
|
|
6
|
+
program
|
|
7
|
+
.option('-o, --options', 'View options and commands.');
|
|
8
|
+
|
|
9
|
+
program
|
|
10
|
+
.command('user <username> <pin>')
|
|
11
|
+
.description('Authenticate and start a .me session.')
|
|
12
|
+
.action((username, pin) => {
|
|
13
|
+
console.log(`Attempting to authenticate user: ${username}`);
|
|
14
|
+
// Authentication logic here
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export default program;
|
package/src/cli/main.js
CHANGED
|
@@ -1,193 +1,45 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import os from 'os';
|
|
3
|
-
|
|
4
|
-
import { Command } from 'commander';
|
|
5
|
-
const program = new Command();
|
|
6
|
-
import inquirer from 'inquirer';
|
|
7
|
-
import fs from 'fs';
|
|
8
|
-
import path from 'path';
|
|
3
|
+
/** Welcome. */
|
|
9
4
|
import printWelcome from './ascii_art/welcome.js';
|
|
10
|
-
|
|
5
|
+
printWelcome();
|
|
6
|
+
console.log(`Host_Session@ ${os.userInfo().username}`);
|
|
7
|
+
console.log(`v.path@ ${os.homedir()}/.me`);
|
|
11
8
|
/**
|
|
12
9
|
* @module CLI
|
|
13
10
|
* @description
|
|
14
|
-
* .Me Command Line Interface
|
|
11
|
+
* .Me - Command Line Interface.
|
|
15
12
|
* The CLI application's code structure is categorized into two main parts:
|
|
16
13
|
* Command Definitions and Interactive Shell.*/
|
|
17
|
-
|
|
18
|
-
/***
|
|
19
|
-
|
|
20
|
-
*
|
|
21
|
-
|
|
22
|
-
program
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
console.log(`Attempting to authenticate user: ${username}`);
|
|
27
|
-
// Authentication logic here
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
program
|
|
31
|
-
.option('-o, --options', 'View options and commands');
|
|
32
|
-
|
|
33
|
-
/***Welcome message.*/
|
|
34
|
-
function welcomeToMe() {
|
|
35
|
-
printWelcome();
|
|
36
|
-
console.log(`Host_Session@ ${os.userInfo().username}`);
|
|
37
|
-
console.log(`v.path@ ${os.homedir()}/.me`);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Prompts the user to select an action and returns their choice.
|
|
42
|
-
* @returns {Promise<string>} The user's choice.
|
|
14
|
+
|
|
15
|
+
/***
|
|
16
|
+
* Command Definitions:
|
|
17
|
+
* Leverages the `commander` package to define the CLI commands and options.
|
|
18
|
+
**/
|
|
19
|
+
import program from './commands.js';
|
|
20
|
+
/***Interactive Shell:
|
|
21
|
+
* Leverages the `inquirer` package to provide an interactive shell experience with prompts.
|
|
22
|
+
* The `main` function orchestrates the CLI interactions.
|
|
43
23
|
*/
|
|
44
|
-
|
|
45
|
-
const choices = ['View Existing Profiles', 'Create New Profile', 'Exit'];
|
|
46
|
-
const answer = await inquirer.prompt([{
|
|
47
|
-
type: 'list',
|
|
48
|
-
name: 'action',
|
|
49
|
-
message: 'What would you like to do?',
|
|
50
|
-
choices: choices
|
|
51
|
-
}]);
|
|
52
|
-
return answer.action;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Prompts the user for details to create a new profile.
|
|
57
|
-
* @returns {Promise<Me>} The new Me object with user details.
|
|
58
|
-
*/
|
|
59
|
-
async function getNewProfileDetails() {
|
|
60
|
-
const questions = [
|
|
61
|
-
{
|
|
62
|
-
type: 'input',
|
|
63
|
-
name: 'name',
|
|
64
|
-
message: 'What is your first name?',
|
|
65
|
-
// Add validation as needed
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
type: 'input',
|
|
69
|
-
name: 'lastname',
|
|
70
|
-
message: 'What is your last name?',
|
|
71
|
-
// Add validation as needed
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
type: 'input',
|
|
75
|
-
name: 'birthday',
|
|
76
|
-
message: 'What is your birthday? (YYYY-MM-DD)',
|
|
77
|
-
validate: function(value) {
|
|
78
|
-
const pass = value.match(
|
|
79
|
-
/^\d{4}-\d{2}-\d{2}$/
|
|
80
|
-
);
|
|
81
|
-
if (pass) {
|
|
82
|
-
return true;
|
|
83
|
-
}
|
|
84
|
-
return 'Please enter a valid date (YYYY-MM-DD)';
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
type: 'password',
|
|
89
|
-
name: 'password',
|
|
90
|
-
message: 'Choose a password:',
|
|
91
|
-
// Add validation as needed
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
type: 'input',
|
|
95
|
-
name: 'pin',
|
|
96
|
-
message: 'Choose a PIN:',
|
|
97
|
-
// Add validation as needed
|
|
98
|
-
},
|
|
99
|
-
// ... Add more questions as needed
|
|
100
|
-
];
|
|
101
|
-
const userDetails = await inquirer.prompt(questions);
|
|
102
|
-
return new Me(
|
|
103
|
-
userDetails.name,
|
|
104
|
-
userDetails.lastname,
|
|
105
|
-
userDetails.birthday,
|
|
106
|
-
userDetails.password,
|
|
107
|
-
userDetails.pin
|
|
108
|
-
);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Writes the .me object to the filesystem.
|
|
113
|
-
* @param {Me} meProfile - The Me object to be saved.
|
|
114
|
-
*/
|
|
115
|
-
function writeMeObjectToFile(meProfile) {
|
|
116
|
-
const meDirectory = path.join(os.homedir(), '.me');
|
|
117
|
-
if (!fs.existsSync(meDirectory)) {
|
|
118
|
-
fs.mkdirSync(meDirectory, { recursive: true });
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
const filePath = path.join(meDirectory, `${meProfile.name}.me`);
|
|
122
|
-
// Consider encrypting the data here before writing to the filesystem
|
|
123
|
-
fs.writeFileSync(filePath, JSON.stringify(meProfile.getIdentityObject()));
|
|
124
|
-
console.log('Profile created successfully.');
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Function to display options and commands.
|
|
129
|
-
*/
|
|
130
|
-
function displayOptionsAndCommands() {
|
|
131
|
-
console.log(program.helpInformation());
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* Lists all the .me profile file paths in the user's .me directory.
|
|
136
|
-
* @returns {string[]} An array of full file paths for each .me profile.
|
|
137
|
-
*/
|
|
138
|
-
function listMeProfiles() {
|
|
139
|
-
const meDirectory = path.join(os.homedir(), '.me');
|
|
140
|
-
if (fs.existsSync(meDirectory)) {
|
|
141
|
-
const profileFiles = fs.readdirSync(meDirectory)
|
|
142
|
-
.filter(file => file.endsWith('.me'));
|
|
143
|
-
return profileFiles.map(file => path.join(meDirectory, file));
|
|
144
|
-
} else {
|
|
145
|
-
console.log('No profiles found.');
|
|
146
|
-
return [];
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* Prompts the user to select a .me profile or go back to the main menu.
|
|
152
|
-
* @returns {Promise<string>} The file path of the selected profile or 'back' to go to the main menu.
|
|
153
|
-
*/
|
|
154
|
-
async function selectProfile() {
|
|
155
|
-
const profiles = listMeProfiles();
|
|
156
|
-
if (profiles.length === 0) {
|
|
157
|
-
console.log('No profiles found.');
|
|
158
|
-
return 'back';
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
const choices = profiles.map(file => ({
|
|
162
|
-
name: path.basename(file, '.me'),
|
|
163
|
-
value: file
|
|
164
|
-
})).concat([{ name: 'Go Back to Main Menu', value: 'back' }]);
|
|
165
|
-
|
|
166
|
-
const answer = await inquirer.prompt([{
|
|
167
|
-
type: 'list',
|
|
168
|
-
name: 'selectedProfile',
|
|
169
|
-
message: 'Select a profile to view or go back:',
|
|
170
|
-
choices: choices
|
|
171
|
-
}]);
|
|
172
|
-
return answer.selectedProfile;
|
|
173
|
-
}
|
|
24
|
+
import { shell } from './shell.js';
|
|
174
25
|
|
|
175
26
|
/**
|
|
176
27
|
* Main function to handle the CLI interactions.
|
|
177
28
|
* Continuously prompts the user for actions until an exit command is given.
|
|
178
29
|
*/
|
|
30
|
+
|
|
179
31
|
async function main() {
|
|
180
|
-
|
|
32
|
+
printWelcome();
|
|
181
33
|
let exit = false;
|
|
182
34
|
while (!exit) {
|
|
183
|
-
const choice = await
|
|
35
|
+
const choice = await shell.selectMe();
|
|
184
36
|
switch (choice) {
|
|
185
37
|
/**
|
|
186
38
|
* Handles the 'View Existing Profiles' choice.
|
|
187
39
|
* Lists and displays all existing .me profiles.
|
|
188
40
|
*/
|
|
189
41
|
case 'View Existing Profiles':
|
|
190
|
-
const selectedProfile = await selectProfile();
|
|
42
|
+
const selectedProfile = await shell.selectProfile();
|
|
191
43
|
if (selectedProfile === 'back') {
|
|
192
44
|
break;
|
|
193
45
|
}
|
|
@@ -195,6 +47,10 @@ async function main() {
|
|
|
195
47
|
console.log(`Selected profile: ${selectedProfile}`);
|
|
196
48
|
// Add logic to handle the selected profile
|
|
197
49
|
break;
|
|
50
|
+
case 'Create New Profile':
|
|
51
|
+
const newProfile = await shell.createMe(); // Or createMe if that's the name you're using
|
|
52
|
+
shell.writeMe(newProfile);
|
|
53
|
+
break;
|
|
198
54
|
case 'Exit':
|
|
199
55
|
console.log('Exiting .me CLI.');
|
|
200
56
|
exit = true;
|