this.me 2.9.51 → 3.0.2
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 +76 -106
- package/dist/this-me.cjs.js +34 -0
- package/dist/this-me.es.js +142 -0
- package/dist/this-me.umd.js +34 -0
- package/package.json +27 -19
- package/bin/me.cli.js +0 -99
- package/index.js +0 -12
- package/jsdoc.json +0 -41
- package/notes/Entonces_Que_es_me.md +0 -9
- package/notes/Index of this.me Structure.md +0 -154
- package/notes/Index.md +0 -134
- package/notes/Inmutabilidad_de_la_Identidad_basica.md +0 -44
- package/notes/Questions.md +0 -62
- package/notes/Summary.md +0 -125
- package/notes/The Problem: Decentralized Yet Trustworthy.md +0 -13
- package/notes/Understanding me && you && himContext.md +0 -11
- package/notes/hot_encoding.md +0 -44
- package/src/example.js +0 -25
- package/src/me.js +0 -148
- package/src/methods/attributes.js +0 -79
- package/src/methods/identity.js +0 -31
- package/src/methods/properties.js +0 -73
- package/src/methods/reactions.js +0 -31
- package/src/methods/relationships.js +0 -26
- package/src/scripts/setup.js +0 -19
- package/src/scripts/setup_validation.js +0 -31
package/README.md
CHANGED
|
@@ -1,72 +1,106 @@
|
|
|
1
|
-
<img src="https://
|
|
1
|
+
<img src="https://res.cloudinary.com/dkwnxf6gm/image/upload/v1761149332/this.me-removebg-preview_2_j1eoiy.png" alt="57b0b83e8518fecf9b3e2d06457421c7da70e0663f7490fab98f9ecbdbe5db6e-removebg-preview" style="zoom:55%;" />
|
|
2
2
|
|
|
3
|
-
#
|
|
4
|
-
> **This.Me** is a data-structured identity designed to generate and manage identities, attributes, properties and more. It combines privacy, user control, and secure interoperability.
|
|
3
|
+
# .ME
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
You can use **.me** both in **browser** and **Node** environments.
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
#### **1. Installation**
|
|
8
|
+
Using **npm**:
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
```bash
|
|
11
|
+
npm install this.me
|
|
12
|
+
```
|
|
11
13
|
|
|
12
|
-
|
|
13
|
-
1. ##### **Install `this.me`:**
|
|
14
|
-
Open your terminal and run the following command to install the `this.me` package:
|
|
15
|
-
```js
|
|
16
|
-
npm i -g this.me
|
|
17
|
-
```
|
|
14
|
+
Or load it directly in the **browser** (build):
|
|
18
15
|
|
|
19
|
-
|
|
16
|
+
```html
|
|
17
|
+
<script src="this.me.umd.js"></script>
|
|
18
|
+
<script>
|
|
19
|
+
// Global instance automatically attached to `window.me`
|
|
20
|
+
console.log(me); // Ready to use after initialization
|
|
21
|
+
</script>
|
|
22
|
+
```
|
|
20
23
|
|
|
21
|
-
|
|
22
|
-
me
|
|
23
|
-
```
|
|
24
|
+
---
|
|
24
25
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
- Keys (private/public — currently placeholders)
|
|
28
|
-
- User-defined attributes
|
|
29
|
-
- Relationships and other social elements (reactions, attributies, properties, endorsements...)
|
|
26
|
+
#### **2. Initialization**
|
|
27
|
+
You need to initialize the `.me` instance before using it:
|
|
30
28
|
|
|
31
|
-
|
|
29
|
+
```js
|
|
30
|
+
import me from "this.me";
|
|
32
31
|
|
|
33
|
-
|
|
32
|
+
await me.init({
|
|
33
|
+
monadEndpoint: "http://localhost:7777" // optional, defaults to 7777
|
|
34
|
+
});
|
|
35
|
+
```
|
|
34
36
|
|
|
35
|
-
|
|
37
|
+
Once initialized, the `me` instance will maintain its state (status, loaded identities, etc.) globally.
|
|
36
38
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
#### **3. Checking Daemon Status**
|
|
42
|
+
You can verify if the local daemon is running:
|
|
43
|
+
|
|
44
|
+
```js
|
|
45
|
+
const status = await me.status();
|
|
46
|
+
console.log("Daemon active:", status.active);
|
|
39
47
|
```
|
|
40
48
|
|
|
41
|
-
|
|
42
|
-
- **Flow**: Prompts for username and hash (secret key), then saves an encrypted file at ~/.this/me/username.me.
|
|
49
|
+
The floating components or any GUI indicators (green/red) can rely directly on `me.status()`.
|
|
43
50
|
|
|
44
|
-
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
#### **4. Listing Identities**
|
|
54
|
+
```js
|
|
55
|
+
const list = await me.listUs();
|
|
56
|
+
console.log(list);
|
|
57
|
+
```
|
|
45
58
|
|
|
46
59
|
```bash
|
|
47
|
-
|
|
60
|
+
[
|
|
61
|
+
{ alias: "suign", path: "/Users/abellae/.this/me/suign" }
|
|
62
|
+
]
|
|
48
63
|
```
|
|
49
64
|
|
|
50
|
-
- **Description**: Shows the decrypted contents of an identity.
|
|
51
|
-
- **Flow**:
|
|
52
|
-
- If [username] is not provided, it prompts for it.
|
|
53
|
-
- Always prompts for the hash to unlock the identity.
|
|
54
|
-
- If successful, prints the identity as JSON.
|
|
55
65
|
|
|
56
|
-
------
|
|
57
66
|
|
|
58
|
-
|
|
59
|
-
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
#### **5. Loading an Identity**
|
|
70
|
+
|
|
71
|
+
```js
|
|
72
|
+
await me.load("abellae", "mySecretHash");
|
|
73
|
+
console.log(me.active); // true if identity is successfully loaded
|
|
60
74
|
```
|
|
61
75
|
|
|
62
|
-
|
|
63
|
-
|
|
76
|
+
After loading, you can use all available methods (`be`, `have`, `do`, etc.).
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
#### **6. Example in the Browser Console**
|
|
81
|
+
|
|
82
|
+
If you include the UMD bundle:
|
|
83
|
+
|
|
84
|
+
```html
|
|
85
|
+
<script src="this.me.umd.js"></script>
|
|
86
|
+
<script>
|
|
87
|
+
(async () => {
|
|
88
|
+
await me.init();
|
|
89
|
+
console.log(await me.status());
|
|
90
|
+
console.log(await me.listUs());
|
|
91
|
+
})();
|
|
92
|
+
</script>
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
- `me` is a **singleton instance** that lives in memory once initialized.
|
|
96
|
+
- Works in both browser and Node.
|
|
97
|
+
- Provides methods for status, identity management, and attribute handling.
|
|
64
98
|
|
|
65
99
|
------
|
|
66
100
|
|
|
67
|
-
|
|
101
|
+
### How this.me **Works (Simplified)**
|
|
68
102
|
|
|
69
|
-
The Me class creates and manages a **local, encrypted identity file** based on a username and a secret hash.
|
|
103
|
+
The **Me** class creates and manages a **local, encrypted identity file** based on a username and a secret hash.
|
|
70
104
|
|
|
71
105
|
#### **Creating a new identity**
|
|
72
106
|
|
|
@@ -76,15 +110,6 @@ When you run:
|
|
|
76
110
|
Me.create('abellae', 'mySecretHash');
|
|
77
111
|
```
|
|
78
112
|
|
|
79
|
-
It does the following:
|
|
80
|
-
|
|
81
|
-
- Builds a .me file path: ~/.this/me/abellae.me.
|
|
82
|
-
- Creates some **identity data** (username, keys, attributes, etc.).
|
|
83
|
-
- Uses the hash to **encrypt** that data with AES-256-CBC:
|
|
84
|
-
- It generates a random iv (initialization vector).
|
|
85
|
-
- Derives a key from the hash (sha256(hash)).
|
|
86
|
-
- Stores the encrypted result as iv + encryptedData.
|
|
87
|
-
|
|
88
113
|
> 🔒 The hash is **never saved** — it’s just used as a secret key.
|
|
89
114
|
|
|
90
115
|
------
|
|
@@ -118,18 +143,6 @@ Once unlocked, you can:
|
|
|
118
143
|
|
|
119
144
|
------
|
|
120
145
|
|
|
121
|
-
#### Locking the identity
|
|
122
|
-
|
|
123
|
-
You can clear the identity from memory with:
|
|
124
|
-
|
|
125
|
-
```js
|
|
126
|
-
me.lock();
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
This keeps the encrypted file on disk but removes all data from RAM.
|
|
130
|
-
|
|
131
|
-
------
|
|
132
|
-
|
|
133
146
|
### **Summary**
|
|
134
147
|
|
|
135
148
|
- Your identity is encrypted on your own machine.
|
|
@@ -150,25 +163,6 @@ Let me know if you’d like a diagram or visual flow to go with this explanation
|
|
|
150
163
|
3. **Local Ownership**
|
|
151
164
|
All sensitive data (including private keys) stays on the user's machine.
|
|
152
165
|
|
|
153
|
-
---
|
|
154
|
-
### 📁 File Structure
|
|
155
|
-
* `~/.this/me/username.me.json` — Encrypted identity file
|
|
156
|
-
* `.me` includes:
|
|
157
|
-
|
|
158
|
-
* `username`
|
|
159
|
-
* `publicKey`, `privateKey` (encrypted)
|
|
160
|
-
* `attributes`, `relationships`, `reactions`, `properties`, `relationships`
|
|
161
|
-
* `endorsements`
|
|
162
|
-
|
|
163
|
-
---
|
|
164
|
-
### 🔐 Cryptographic Model
|
|
165
|
-
* Identity is unlocked using a user-defined `hash` (password).
|
|
166
|
-
* This hash decrypts the local `.me` file.
|
|
167
|
-
* The identity includes:
|
|
168
|
-
|
|
169
|
-
* A **key pair** (public/private) for signing and verification.
|
|
170
|
-
* Optional **endorsements** signed by Cleaker or other authorities.
|
|
171
|
-
|
|
172
166
|
---
|
|
173
167
|
### 🛡️ Security Model
|
|
174
168
|
* No private key ever leaves the local `.me` file.
|
|
@@ -180,17 +174,6 @@ Let me know if you’d like a diagram or visual flow to go with this explanation
|
|
|
180
174
|
* `.me` can be restored using a seed phrase or backup.
|
|
181
175
|
* New devices can be authorized using signatures from old devices.
|
|
182
176
|
|
|
183
|
-
---
|
|
184
|
-
## ⚖️ Responsibilities
|
|
185
|
-
* **this.me**
|
|
186
|
-
* Local file management, encryption, signing.
|
|
187
|
-
* CLI + API for usage.
|
|
188
|
-
|
|
189
|
-
* **Cleaker / Authorities**
|
|
190
|
-
|
|
191
|
-
* Store trusted records of `username` + `publicKey`
|
|
192
|
-
* Provide validation/endorsement services.
|
|
193
|
-
|
|
194
177
|
---
|
|
195
178
|
## 🌍 Use Cases
|
|
196
179
|
* Digital signature of documents
|
|
@@ -199,23 +182,10 @@ Let me know if you’d like a diagram or visual flow to go with this explanation
|
|
|
199
182
|
* Group identity and shared contexts (`me && you && them in context/friends`)
|
|
200
183
|
|
|
201
184
|
---
|
|
202
|
-
By default, **this.me** uses the **local file system (~/.this/me/)** to store and manage identity data.
|
|
203
|
-
No external service is required.
|
|
204
|
-
|
|
205
185
|
<img src="https://suign.github.io/assets/imgs/monads.png" alt="Cleak Me Please" width="244">Hello, I am **.me**
|
|
206
186
|
|
|
207
|
-
### ❯ add.me
|
|
208
187
|
----
|
|
209
188
|
|
|
210
|
-
# What is All.This?
|
|
211
|
-
###### Modular Data Structures:
|
|
212
|
-
**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.**
|
|
213
|
-
|
|
214
|
-
**[this.me](https://docs.neurons.me/this.me/index.html) - [this.audio](https://docs.neurons.me/this.audio/index.html) - [this.text](https://docs.neurons.me/this.text/index.html) - [this.wallet](https://docs.neurons.me/this.wallet/index.html) - [this.img](https://docs.neurons.me/this.img/index.html) - [this.pixel](https://docs.neurons.me/this.pixel/index.html) - [be.this](https://docs.neurons.me/be.this/index.html) - [this.DOM](https://docs.neurons.me/this.DOM/index.html) - [this.env](https://docs.neurons.me/this.env/index.html) - [this.GUI](https://docs.neurons.me/this.GUI/index.html) - [this.be](https://docs.neurons.me/this.be/index.html) - [this.video](https://docs.neurons.me/this.video/index.html) - [this.dictionaries](https://docs.neurons.me/this.dictionaries/index.html)**
|
|
215
|
-
|
|
216
|
-
#### Contribution
|
|
217
|
-
If you are interested in collaborating or wish to share your insights, please feel free to reach out or contribute to the project.
|
|
218
|
-
|
|
219
189
|
#### License & Policies
|
|
220
190
|
- **License**: MIT License.
|
|
221
191
|
- **Learn more** at **https://neurons.me**
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});class o{constructor(t="http://localhost:7777/graphql"){this.endpoint=t,this.state={status:{active:!1,error:!1,loading:!0,data:null},listUs:[]},this.subscribers=new Set,this.socket=null}async status(){const t=`
|
|
2
|
+
query {
|
|
3
|
+
monadStatus {
|
|
4
|
+
active
|
|
5
|
+
version
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
`;try{const e=(await this.#e(t)).monadStatus??{active:!1,version:null};return this.#s({status:{...this.state.status,active:e.active,data:e}}),e}catch{return this.#s({status:{...this.state.status,error:!0,data:null}}),{active:!1,version:null}}}async publicInfo(t){const s=`
|
|
9
|
+
query($username: String!) {
|
|
10
|
+
publicInfo(username: $username) {
|
|
11
|
+
username
|
|
12
|
+
publicKey
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
`;try{const r=(await this.#e(s,{username:t})).publicInfo;return r&&r.username&&r.publicKey?r:null}catch{return null}}async listIdentities(){const t=`
|
|
16
|
+
query {
|
|
17
|
+
listIdentities {
|
|
18
|
+
username
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
`;try{const s=await this.#e(t),e=Array.isArray(s.listIdentities)?s.listIdentities.map(r=>({username:r.username,path:null})):[];return this.#s({listUs:e}),e}catch{return this.#s({listUs:[]}),[]}}async get(t,s,e={}){const r=`
|
|
22
|
+
query($username: String!, $password: String!, $filter: GetFilter!) {
|
|
23
|
+
get(username: $username, password: $password, filter: $filter) {
|
|
24
|
+
verb
|
|
25
|
+
key
|
|
26
|
+
value
|
|
27
|
+
timestamp
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
`;try{return(await this.#e(r,{username:t,password:s,filter:e})).get||[]}catch{return[]}}async#t(t,s,e,r,a,n=null){const c=`
|
|
31
|
+
mutation($username: String!, $password: String!, $key: String!, $value: String!, $context_id: String) {
|
|
32
|
+
${t}(username: $username, password: $password, key: $key, value: $value, context_id: $context_id)
|
|
33
|
+
}
|
|
34
|
+
`;try{return!!(await this.#e(c,{username:s,password:e,key:r,value:a,context_id:n}))[t]}catch{return!1}}async be(t,s,e,r,a=null){return this.#t("be",t,s,e,r,a)}async have(t,s,e,r,a=null){return this.#t("have",t,s,e,r,a)}async do(t,s,e,r,a=null){return this.#t("do",t,s,e,r,a)}async at(t,s,e,r,a=null){return this.#t("at",t,s,e,r,a)}async relate(t,s,e,r,a=null){return this.#t("relate",t,s,e,r,a)}async react(t,s,e,r,a=null){return this.#t("react",t,s,e,r,a)}async communicate(t,s,e,r,a=null){return this.#t("communicate",t,s,e,r,a)}setEndpoint(t){t.trim()&&(this.endpoint=t)}getState(){return this.state}subscribe(t){return this.subscribers.add(t),()=>this.subscribers.delete(t)}#s(t){this.state={...this.state,...t},this.subscribers.forEach(s=>s(this.state))}async#e(t,s={}){const e=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:t,variables:s})});if(!e.ok)throw new Error(`GraphQL error: ${e.status}`);const{data:r,errors:a}=await e.json();if(a)throw new Error(a.map(n=>n.message).join(", "));return r}}const l=new o,i=new Proxy(l,{get(u,t,s){const e=Reflect.get(u,t,s);return typeof e!="function"?e:(...r)=>{const a=e.apply(u,r);return a instanceof Promise&&a.then(n=>console.log(`[this.me] ${String(t)} ✓`,n)).catch(n=>console.error(`[this.me] ${String(t)} ✗`,n)),a}}});typeof window<"u"&&(window.me=i,i.help=()=>console.table(Object.getOwnPropertyNames(o.prototype)));exports.default=i;exports.me=i;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
class o {
|
|
2
|
+
constructor(t = "http://localhost:7777/graphql") {
|
|
3
|
+
this.endpoint = t, this.state = {
|
|
4
|
+
status: { active: !1, error: !1, loading: !0, data: null },
|
|
5
|
+
listUs: []
|
|
6
|
+
}, this.subscribers = /* @__PURE__ */ new Set(), this.socket = null;
|
|
7
|
+
}
|
|
8
|
+
async status() {
|
|
9
|
+
const t = `
|
|
10
|
+
query {
|
|
11
|
+
monadStatus {
|
|
12
|
+
active
|
|
13
|
+
version
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
`;
|
|
17
|
+
try {
|
|
18
|
+
const e = (await this.#e(t)).monadStatus ?? { active: !1, version: null };
|
|
19
|
+
return this.#s({ status: { ...this.state.status, active: e.active, data: e } }), e;
|
|
20
|
+
} catch {
|
|
21
|
+
return this.#s({ status: { ...this.state.status, error: !0, data: null } }), { active: !1, version: null };
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
async publicInfo(t) {
|
|
25
|
+
const s = `
|
|
26
|
+
query($username: String!) {
|
|
27
|
+
publicInfo(username: $username) {
|
|
28
|
+
username
|
|
29
|
+
publicKey
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
`;
|
|
33
|
+
try {
|
|
34
|
+
const r = (await this.#e(s, { username: t })).publicInfo;
|
|
35
|
+
return r && r.username && r.publicKey ? r : null;
|
|
36
|
+
} catch {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
async listIdentities() {
|
|
41
|
+
const t = `
|
|
42
|
+
query {
|
|
43
|
+
listIdentities {
|
|
44
|
+
username
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
`;
|
|
48
|
+
try {
|
|
49
|
+
const s = await this.#e(t), e = Array.isArray(s.listIdentities) ? s.listIdentities.map((r) => ({ username: r.username, path: null })) : [];
|
|
50
|
+
return this.#s({ listUs: e }), e;
|
|
51
|
+
} catch {
|
|
52
|
+
return this.#s({ listUs: [] }), [];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
async get(t, s, e = {}) {
|
|
56
|
+
const r = `
|
|
57
|
+
query($username: String!, $password: String!, $filter: GetFilter!) {
|
|
58
|
+
get(username: $username, password: $password, filter: $filter) {
|
|
59
|
+
verb
|
|
60
|
+
key
|
|
61
|
+
value
|
|
62
|
+
timestamp
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
`;
|
|
66
|
+
try {
|
|
67
|
+
return (await this.#e(r, { username: t, password: s, filter: e })).get || [];
|
|
68
|
+
} catch {
|
|
69
|
+
return [];
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
async #t(t, s, e, r, a, n = null) {
|
|
73
|
+
const c = `
|
|
74
|
+
mutation($username: String!, $password: String!, $key: String!, $value: String!, $context_id: String) {
|
|
75
|
+
${t}(username: $username, password: $password, key: $key, value: $value, context_id: $context_id)
|
|
76
|
+
}
|
|
77
|
+
`;
|
|
78
|
+
try {
|
|
79
|
+
return !!(await this.#e(c, { username: s, password: e, key: r, value: a, context_id: n }))[t];
|
|
80
|
+
} catch {
|
|
81
|
+
return !1;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
async be(t, s, e, r, a = null) {
|
|
85
|
+
return this.#t("be", t, s, e, r, a);
|
|
86
|
+
}
|
|
87
|
+
async have(t, s, e, r, a = null) {
|
|
88
|
+
return this.#t("have", t, s, e, r, a);
|
|
89
|
+
}
|
|
90
|
+
async do(t, s, e, r, a = null) {
|
|
91
|
+
return this.#t("do", t, s, e, r, a);
|
|
92
|
+
}
|
|
93
|
+
async at(t, s, e, r, a = null) {
|
|
94
|
+
return this.#t("at", t, s, e, r, a);
|
|
95
|
+
}
|
|
96
|
+
async relate(t, s, e, r, a = null) {
|
|
97
|
+
return this.#t("relate", t, s, e, r, a);
|
|
98
|
+
}
|
|
99
|
+
async react(t, s, e, r, a = null) {
|
|
100
|
+
return this.#t("react", t, s, e, r, a);
|
|
101
|
+
}
|
|
102
|
+
async communicate(t, s, e, r, a = null) {
|
|
103
|
+
return this.#t("communicate", t, s, e, r, a);
|
|
104
|
+
}
|
|
105
|
+
setEndpoint(t) {
|
|
106
|
+
t.trim() && (this.endpoint = t);
|
|
107
|
+
}
|
|
108
|
+
getState() {
|
|
109
|
+
return this.state;
|
|
110
|
+
}
|
|
111
|
+
subscribe(t) {
|
|
112
|
+
return this.subscribers.add(t), () => this.subscribers.delete(t);
|
|
113
|
+
}
|
|
114
|
+
#s(t) {
|
|
115
|
+
this.state = { ...this.state, ...t }, this.subscribers.forEach((s) => s(this.state));
|
|
116
|
+
}
|
|
117
|
+
async #e(t, s = {}) {
|
|
118
|
+
const e = await fetch(this.endpoint, {
|
|
119
|
+
method: "POST",
|
|
120
|
+
headers: { "Content-Type": "application/json" },
|
|
121
|
+
body: JSON.stringify({ query: t, variables: s })
|
|
122
|
+
});
|
|
123
|
+
if (!e.ok) throw new Error(`GraphQL error: ${e.status}`);
|
|
124
|
+
const { data: r, errors: a } = await e.json();
|
|
125
|
+
if (a) throw new Error(a.map((n) => n.message).join(", "));
|
|
126
|
+
return r;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
const l = new o(), u = new Proxy(l, {
|
|
130
|
+
get(i, t, s) {
|
|
131
|
+
const e = Reflect.get(i, t, s);
|
|
132
|
+
return typeof e != "function" ? e : (...r) => {
|
|
133
|
+
const a = e.apply(i, r);
|
|
134
|
+
return a instanceof Promise && a.then((n) => console.log(`[this.me] ${String(t)} ✓`, n)).catch((n) => console.error(`[this.me] ${String(t)} ✗`, n)), a;
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
typeof window < "u" && (window.me = u, u.help = () => console.table(Object.getOwnPropertyNames(o.prototype)));
|
|
139
|
+
export {
|
|
140
|
+
u as default,
|
|
141
|
+
u as me
|
|
142
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
(function(a,u){typeof exports=="object"&&typeof module<"u"?u(exports):typeof define=="function"&&define.amd?define(["exports"],u):(a=typeof globalThis<"u"?globalThis:a||self,u(a.Me={}))})(this,(function(a){"use strict";class u{constructor(t="http://localhost:7777/graphql"){this.endpoint=t,this.state={status:{active:!1,error:!1,loading:!0,data:null},listUs:[]},this.subscribers=new Set,this.socket=null}async status(){const t=`
|
|
2
|
+
query {
|
|
3
|
+
monadStatus {
|
|
4
|
+
active
|
|
5
|
+
version
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
`;try{const e=(await this.#e(t)).monadStatus??{active:!1,version:null};return this.#s({status:{...this.state.status,active:e.active,data:e}}),e}catch{return this.#s({status:{...this.state.status,error:!0,data:null}}),{active:!1,version:null}}}async publicInfo(t){const s=`
|
|
9
|
+
query($username: String!) {
|
|
10
|
+
publicInfo(username: $username) {
|
|
11
|
+
username
|
|
12
|
+
publicKey
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
`;try{const n=(await this.#e(s,{username:t})).publicInfo;return n&&n.username&&n.publicKey?n:null}catch{return null}}async listIdentities(){const t=`
|
|
16
|
+
query {
|
|
17
|
+
listIdentities {
|
|
18
|
+
username
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
`;try{const s=await this.#e(t),e=Array.isArray(s.listIdentities)?s.listIdentities.map(n=>({username:n.username,path:null})):[];return this.#s({listUs:e}),e}catch{return this.#s({listUs:[]}),[]}}async get(t,s,e={}){const n=`
|
|
22
|
+
query($username: String!, $password: String!, $filter: GetFilter!) {
|
|
23
|
+
get(username: $username, password: $password, filter: $filter) {
|
|
24
|
+
verb
|
|
25
|
+
key
|
|
26
|
+
value
|
|
27
|
+
timestamp
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
`;try{return(await this.#e(n,{username:t,password:s,filter:e})).get||[]}catch{return[]}}async#t(t,s,e,n,r,i=null){const d=`
|
|
31
|
+
mutation($username: String!, $password: String!, $key: String!, $value: String!, $context_id: String) {
|
|
32
|
+
${t}(username: $username, password: $password, key: $key, value: $value, context_id: $context_id)
|
|
33
|
+
}
|
|
34
|
+
`;try{return!!(await this.#e(d,{username:s,password:e,key:n,value:r,context_id:i}))[t]}catch{return!1}}async be(t,s,e,n,r=null){return this.#t("be",t,s,e,n,r)}async have(t,s,e,n,r=null){return this.#t("have",t,s,e,n,r)}async do(t,s,e,n,r=null){return this.#t("do",t,s,e,n,r)}async at(t,s,e,n,r=null){return this.#t("at",t,s,e,n,r)}async relate(t,s,e,n,r=null){return this.#t("relate",t,s,e,n,r)}async react(t,s,e,n,r=null){return this.#t("react",t,s,e,n,r)}async communicate(t,s,e,n,r=null){return this.#t("communicate",t,s,e,n,r)}setEndpoint(t){t.trim()&&(this.endpoint=t)}getState(){return this.state}subscribe(t){return this.subscribers.add(t),()=>this.subscribers.delete(t)}#s(t){this.state={...this.state,...t},this.subscribers.forEach(s=>s(this.state))}async#e(t,s={}){const e=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:t,variables:s})});if(!e.ok)throw new Error(`GraphQL error: ${e.status}`);const{data:n,errors:r}=await e.json();if(r)throw new Error(r.map(i=>i.message).join(", "));return n}}const l=new u,o=new Proxy(l,{get(c,t,s){const e=Reflect.get(c,t,s);return typeof e!="function"?e:(...n)=>{const r=e.apply(c,n);return r instanceof Promise&&r.then(i=>console.log(`[this.me] ${String(t)} ✓`,i)).catch(i=>console.error(`[this.me] ${String(t)} ✗`,i)),r}}});typeof window<"u"&&(window.me=o,o.help=()=>console.table(Object.getOwnPropertyNames(u.prototype))),a.default=o,a.me=o,Object.defineProperties(a,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|
package/package.json
CHANGED
|
@@ -1,34 +1,42 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "this.me",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
3
|
+
"version": "3.0.2",
|
|
4
|
+
"description": ".me is your identity decentralized trust through cryptographic signatures.",
|
|
5
|
+
"main": "dist/index.cjs.js",
|
|
6
|
+
"module": "dist/index.es.js",
|
|
7
|
+
"browser": "dist/index.umd.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.es.js",
|
|
11
|
+
"require": "./dist/index.cjs.js"
|
|
12
|
+
}
|
|
13
13
|
},
|
|
14
|
+
"type": "module",
|
|
14
15
|
"keywords": [
|
|
15
16
|
"this.me",
|
|
16
|
-
"
|
|
17
|
+
"identity",
|
|
18
|
+
"decentralized",
|
|
19
|
+
"cryptographic",
|
|
20
|
+
"trust",
|
|
21
|
+
"signature",
|
|
22
|
+
"local",
|
|
23
|
+
"self-sovereign",
|
|
24
|
+
"monad"
|
|
17
25
|
],
|
|
18
26
|
"repository": {
|
|
19
27
|
"type": "git",
|
|
20
28
|
"url": "git+https://github.com/neurons-me/this.me.git"
|
|
21
29
|
},
|
|
22
30
|
"homepage": "https://www.npmjs.com/package/this.me",
|
|
23
|
-
"docs": "https://suiGn.github.io/this.me",
|
|
24
|
-
"type": "module",
|
|
25
31
|
"author": "suiGn",
|
|
26
32
|
"license": "MIT",
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
"files": [
|
|
34
|
+
"dist"
|
|
35
|
+
],
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "vite build"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"vite": "^7.0.6"
|
|
33
41
|
}
|
|
34
42
|
}
|
package/bin/me.cli.js
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// ./bin/me.cli.js
|
|
3
|
-
import { Command } from 'commander';
|
|
4
|
-
import inquirer from 'inquirer';
|
|
5
|
-
import chalk from 'chalk';
|
|
6
|
-
import { existsSync } from 'fs';
|
|
7
|
-
import path from 'path';
|
|
8
|
-
import os from 'os';
|
|
9
|
-
import Me from '../src/me.js';
|
|
10
|
-
import { validateSetup } from '../src/scripts/setup_validation.js';
|
|
11
|
-
validateSetup(); // Asegura que ~/.this y ~/.this/me existen antes de usar el CLI
|
|
12
|
-
const program = new Command();
|
|
13
|
-
const ME_DIR = path.join(os.homedir(), '.this', 'me');
|
|
14
|
-
// Utilidad para obtener ruta de archivo `.me`
|
|
15
|
-
const getMeFilePath = (username) => path.join(ME_DIR, `${username}.me`);
|
|
16
|
-
program
|
|
17
|
-
.name('me')
|
|
18
|
-
.description('CLI to manage this.me identities')
|
|
19
|
-
.version('1.0.0');
|
|
20
|
-
// Comando: crear una identidad .me
|
|
21
|
-
program
|
|
22
|
-
.command('create')
|
|
23
|
-
.description('Create new .me identity')
|
|
24
|
-
.action(async () => {
|
|
25
|
-
const { username, hash } = await inquirer.prompt([
|
|
26
|
-
{
|
|
27
|
-
type: 'input',
|
|
28
|
-
name: 'username',
|
|
29
|
-
message: 'Enter a username:',
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
type: 'password',
|
|
33
|
-
name: 'hash',
|
|
34
|
-
message: 'Define your hash (secret key):',
|
|
35
|
-
mask: '*',
|
|
36
|
-
}
|
|
37
|
-
]);
|
|
38
|
-
const mePath = getMeFilePath(username);
|
|
39
|
-
if (existsSync(mePath)) {
|
|
40
|
-
console.log(chalk.red(`❌ Identity '${username}' already exists.`));
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
const me = await Me.create(username, hash);
|
|
44
|
-
console.log(chalk.green(`✅ Identity '${me.username}' created and saved as ${mePath}`));
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
// Command: show identity contents
|
|
48
|
-
program
|
|
49
|
-
.command('show')
|
|
50
|
-
.description('Show contents of a .me identity')
|
|
51
|
-
.argument('[username]', 'Username of the identity to show')
|
|
52
|
-
.action(async (usernameArg) => {
|
|
53
|
-
const { username, hash } = await inquirer.prompt([
|
|
54
|
-
{
|
|
55
|
-
type: 'input',
|
|
56
|
-
name: 'username',
|
|
57
|
-
message: 'Enter username to view:',
|
|
58
|
-
when: () => !usernameArg,
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
type: 'password',
|
|
62
|
-
name: 'hash',
|
|
63
|
-
message: 'Enter your hash to unlock:',
|
|
64
|
-
mask: '*',
|
|
65
|
-
}
|
|
66
|
-
]);
|
|
67
|
-
|
|
68
|
-
const finalUsername = usernameArg || username;
|
|
69
|
-
|
|
70
|
-
try {
|
|
71
|
-
const me = await Me.load(finalUsername, hash);
|
|
72
|
-
console.log(chalk.cyan(`\n📂 Identity '${finalUsername}':\n`));
|
|
73
|
-
console.log(JSON.stringify(me, null, 2));
|
|
74
|
-
} catch (err) {
|
|
75
|
-
console.log(chalk.red(`Error: ${err.message}`));
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
// Comando: listar identidades locales
|
|
80
|
-
program
|
|
81
|
-
.command('list')
|
|
82
|
-
.description('List available local .me identities')
|
|
83
|
-
.action(async () => {
|
|
84
|
-
const fs = await import('fs/promises');
|
|
85
|
-
fs.readdir(ME_DIR)
|
|
86
|
-
.then(files => {
|
|
87
|
-
const meFiles = files.filter(file => file.endsWith('.me'));
|
|
88
|
-
if (meFiles.length === 0) {
|
|
89
|
-
console.log(chalk.yellow('⚠️ No registered identities found.'));
|
|
90
|
-
} else {
|
|
91
|
-
console.log(chalk.cyan('📇 Available identities:'));
|
|
92
|
-
meFiles.forEach(file => console.log('•', file.replace('.me', '')));
|
|
93
|
-
console.log(chalk.gray('\nTip: Use `me show` or `me show <username>` to view identity contents.'));
|
|
94
|
-
}
|
|
95
|
-
})
|
|
96
|
-
.catch(err => console.log(chalk.red(`Error: ${err.message}`)));
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
program.parse(process.argv);
|
package/index.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
// index.js
|
|
2
|
-
/**
|
|
3
|
-
* @module This.Me
|
|
4
|
-
* @description
|
|
5
|
-
* This.Me is a data-structured identity...
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { validateSetup } from './src/scripts/setup_validation.js';
|
|
9
|
-
validateSetup(); // Asegura que ~/.this y ~/.this/me existen antes de continuar
|
|
10
|
-
import Me from './src/me.js';
|
|
11
|
-
// when a user declares "I am %.me," their digital existence is affirmed and recorded in the system.
|
|
12
|
-
export default Me;
|