this.me 3.0.25 → 3.0.26

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
@@ -21,156 +21,109 @@ npm install this.me
21
21
 
22
22
  ---
23
23
 
24
- #### **Initialization**
25
- You need to initialize the `.me` instance before using it:
26
-
27
- ```js
28
- import me from "this.me";
29
- await me.init({
30
- monadEndpoint: "http://localhost:7777" // optional, defaults to 7777
31
- });
32
- ```
33
-
34
- Once initialized, the `me` instance will maintain its state (status, loaded identities, etc.) globally.
35
24
 
36
- ---
37
25
 
38
- #### **Checking Daemon Status**
39
- You can verify if the local daemon is running:
26
+ <img src="https://suign.github.io/assets/imgs/monads.png" alt="Cleak Me Please" width="244">Hello, I am **.me**
27
+ ----
40
28
 
41
- ```js
42
- const status = await me.status();
43
- console.log("Daemon active:", status.active);
44
- ```
29
+ # .ME — Declarative Identity Engine
45
30
 
46
- The floating components or any GUI indicators (green/red) can rely directly on `me.status()`.
31
+ `.me` is a minimal declarative identity model designed for universal use in **Node.js** and **browser** environments.
32
+ It generates **signed identity declarations** without predefined schemas or semantic constraints.
33
+ The output is a deterministic identity structure suitable for storage in ledgers, graphs, or distributed systems.
47
34
 
48
35
  ---
49
36
 
50
- #### **Listing Identities**
51
- ```js
52
- const list = await me.listUs();
53
- console.log(list);
54
- ```
37
+ ## 1. Installation (Node.js)
55
38
 
56
39
  ```bash
57
- [
58
- { alias: "suign", path: "/Users/abellae/.this/me/suign" }
59
- ]
40
+ npm install this.me
60
41
  ```
61
42
 
43
+ Import and initialize:
62
44
 
45
+ ```ts
46
+ import { ME } from "this.me";
63
47
 
64
- ---
65
-
66
- #### **Loading an Identity**
67
- ```js
68
- await me.load("abellae", "mySecretHash");
69
- console.log(me.active); // true if identity is successfully loaded
48
+ const me = new ME("secret", "namespace");
49
+ me.instrumento("Moog Matriarch");
50
+ console.log(me.export());
70
51
  ```
71
52
 
72
- After loading, you can use all available methods (`be`, `have`, `do`, etc.).
73
-
74
53
  ---
75
54
 
76
- # **Example in the Browser Console**
77
- If you include the UMD bundle:
55
+ ## 2. Browser Usage (UMD Build)
78
56
 
79
57
  ```html
80
58
  <script src="this.me.umd.js"></script>
81
59
  <script>
82
- (async () => {
83
- await me.init();
84
- console.log(await me.status());
85
- console.log(await me.listUs());
86
- })();
60
+ const me = new window.Me.ME("secret", "namespace");
61
+ me.color("blue");
62
+ console.log(me.export());
87
63
  </script>
88
64
  ```
89
65
 
90
- - `me` is a **singleton instance** that lives in memory once initialized.
91
- - Works in both browser and node.
92
- - Provides methods for status, identity management, and attribute handling.
66
+ ---
93
67
 
94
- ------
68
+ ## 3. Core Behavior
95
69
 
96
- ### How .me **Works (Simplified)**
97
- The **Me** class creates and manages a **local, encrypted identity file** based on a username and a secret hash.
98
- #### **Creating a new identity**
99
- When you run:
70
+ ### 3.1 Dynamic Declarations
71
+ Any property access on `me` becomes a declaration:
100
72
 
101
- ```js
102
- Me.create('abellae', 'mySecretHash');
73
+ ```ts
74
+ me.instrument("guitar");
75
+ me.device("laptop");
103
76
  ```
104
77
 
105
- > 🔒 The hash is **never saved** — it’s just used as a secret key.
78
+ Each call produces:
106
79
 
107
- ------
108
-
109
- #### Loading an existing identity
110
- When you run:
111
-
112
- ```js
113
- Me.load('abellae', 'mySecretHash');
80
+ ```json
81
+ {
82
+ "key": "...",
83
+ "value": "...",
84
+ "signature": "0x...",
85
+ "timestamp": 0000
86
+ }
114
87
  ```
115
88
 
116
- It:
117
- - Reads the **encrypted .me** file.
118
- - Extracts the first 16 bytes as iv.
119
- - Recomputes the key from the given hash.
120
- - Tries to decrypt the file.
121
- - If it works, it unlocks the identity and loads the data into memory.
89
+ ### 3.2 Pointer Support
90
+ Declarations may reference previous declarations using pointers:
122
91
 
123
- ------
92
+ ```ts
93
+ const d = me.instrument("Moog One");
94
+ me.tengo(me.ptr(d));
95
+ ```
124
96
 
125
- #### **Using the unlocked identity**
126
- Once unlocked, you can:
127
- - Set attributes: me.be('developer', true)
128
- - Add endorsements: me.addEndorsement(...)
129
- - View attributes: me.getAttributes()
130
- - Save updates with: me.save('mySecretHash')
97
+ Pointers resolve to the declaration signature.
131
98
 
132
- ------
99
+ ### 3.3 Export
100
+ All identity data can be exported for persistence:
133
101
 
134
- ### **Summary**
135
- - Your identity is encrypted on your own machine.
136
- - Only the correct hash can unlock it.
137
- - No third parties are involved.
138
- - The **.me** file is secure, portable, and self-owned.
102
+ ```ts
103
+ me.export();
104
+ ```
139
105
 
140
106
  ---
141
107
 
142
- ### 🔍 Core Principles
143
- 1. **Freedom to Declare**
144
- Anyone can generate a `.me` identity locally without external approval.
145
- 2. **Trusted Endorsements**
146
- Authorities (e.g., Cleaker) can endorse `.me` identities without controlling them.
147
- 3. **Local Ownership**
148
- All sensitive data (including private keys) stays on the user's machine.
108
+ ## 4. Output Structure
149
109
 
150
- ---
151
- ### 🛡️ Security Model
152
- * No private key ever leaves the local `.me` file.
153
- * Endorsements are public and verifiable using the **public key.**
154
- * If compromised, user can rotate keys and notify authorities.
110
+ `me.export()` returns:
155
111
 
156
- ---
157
- ## 🌐 Multi-Device Support
158
- * `.me` can be restored using a seed phrase or backup.
159
- * New devices can be authorized using signatures from old devices.
112
+ ```json
113
+ {
114
+ "identityRoot": "...",
115
+ "publicKey": "...",
116
+ "namespace": "...",
117
+ "identityHash": "...",
118
+ "declarations": [ ... ]
119
+ }
120
+ ```
160
121
 
161
- ---
162
- ## 🌍 Use Cases
163
- * Digital signature of documents
164
- * Smart contract interaction
165
- * Federated profiles with trust anchors
166
- * Group identity and shared contexts (`me && you && them in context/friends`)
122
+ The structure is deterministic and signature-based.
167
123
 
168
124
  ---
169
- <img src="https://suign.github.io/assets/imgs/monads.png" alt="Cleak Me Please" width="244">Hello, I am **.me**
170
- ----
171
125
 
172
- #### License & Policies
173
- - **License**: MIT License.
174
- - **Learn more** at **https://neurons.me**
175
- [Terms](https://neurons.me/terms-and-conditions) | [Privacy](https://neurons.me/privacy-policy)
176
- <img src="https://docs.neurons.me/neurons.me.webp" alt="neurons.me logo" width="89" height="89">
126
+ ## 5. License
127
+
128
+ MIT License
129
+ Documentation: https://neurons.me
@@ -0,0 +1,3 @@
1
+ import { ME } from './src/me.js';
2
+ export { ME };
3
+ export default ME;
package/dist/me.cjs.js CHANGED
@@ -1,34 +1,8 @@
1
- "use strict";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,n,a=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:n,context_id:a}))[t]}catch{return!1}}async be(t,s,e,r,n=null){return this.#t("be",t,s,e,r,n)}async have(t,s,e,r,n=null){return this.#t("have",t,s,e,r,n)}async do(t,s,e,r,n=null){return this.#t("do",t,s,e,r,n)}async at(t,s,e,r,n=null){return this.#t("at",t,s,e,r,n)}async relate(t,s,e,r,n=null){return this.#t("relate",t,s,e,r,n)}async react(t,s,e,r,n=null){return this.#t("react",t,s,e,r,n)}async communicate(t,s,e,r,n=null){return this.#t("communicate",t,s,e,r,n)}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:n}=await e.json();if(n)throw new Error(n.map(a=>a.message).join(", "));return r}}const l=new o,u=new Proxy(l,{get(i,t,s){const e=Reflect.get(i,t,s);return typeof e!="function"?e:(...r)=>{const n=e.apply(i,r);return n instanceof Promise&&n.then(a=>console.log(`[this.me] ${String(t)} ✓`,a)).catch(a=>console.error(`[this.me] ${String(t)} ✗`,a)),n}}});typeof window<"u"&&(window.me=u,u.help=()=>console.table(Object.getOwnPropertyNames(o.prototype)));module.exports=u;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var ae=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ue(v){return v&&v.__esModule&&Object.prototype.hasOwnProperty.call(v,"default")?v.default:v}var Pt={exports:{}};/**
2
+ * [js-sha3]{@link https://github.com/emn178/js-sha3}
3
+ *
4
+ * @version 0.9.3
5
+ * @author Chen, Yi-Cyuan [emn178@gmail.com]
6
+ * @copyright Chen, Yi-Cyuan 2015-2023
7
+ * @license MIT
8
+ */var Qt;function fe(){return Qt||(Qt=1,(function(v){(function(){var y="input is invalid type",M="finalize already called",R=typeof window=="object",b=R?window:{};b.JS_SHA3_NO_WINDOW&&(R=!1);var F=!R&&typeof self=="object",k=!b.JS_SHA3_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;k?b=ae:F&&(b=self);for(var g=!b.JS_SHA3_NO_COMMON_JS&&!0&&v.exports,w=!b.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",h="0123456789abcdef".split(""),Dt=[31,7936,2031616,520093696],N=[4,1024,262144,67108864],x=[1,256,65536,16777216],te=[6,1536,393216,100663296],d=[0,8,16,24],Tt=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],mt=[224,256,384,512],Ht=[128,256],Ut=["hex","buffer","arrayBuffer","array","digest"],Wt={128:168,256:136},ee=b.JS_SHA3_NO_NODE_JS||!Array.isArray?function(t){return Object.prototype.toString.call(t)==="[object Array]"}:Array.isArray,re=w&&(b.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)?function(t){return typeof t=="object"&&t.buffer&&t.buffer.constructor===ArrayBuffer}:ArrayBuffer.isView,Kt=function(t){var e=typeof t;if(e==="string")return[t,!0];if(e!=="object"||t===null)throw new Error(y);if(w&&t.constructor===ArrayBuffer)return[new Uint8Array(t),!1];if(!ee(t)&&!re(t))throw new Error(y);return[t,!1]},Gt=function(t){return Kt(t)[0].length===0},zt=function(t){for(var e=[],r=0;r<t.length;++r)e[r]=t[r];return e},Yt=function(t,e,r){return function(n){return new l(t,e,t).update(n)[r]()}},Vt=function(t,e,r){return function(n,o){return new l(t,e,o).update(n)[r]()}},qt=function(t,e,r){return function(n,o,i,u){return _["cshake"+t].update(n,o,i,u)[r]()}},Lt=function(t,e,r){return function(n,o,i,u){return _["kmac"+t].update(n,o,i,u)[r]()}},I=function(t,e,r,n){for(var o=0;o<Ut.length;++o){var i=Ut[o];t[i]=e(r,n,i)}return t},Xt=function(t,e){var r=Yt(t,e,"hex");return r.create=function(){return new l(t,e,t)},r.update=function(n){return r.create().update(n)},I(r,Yt,t,e)},ne=function(t,e){var r=Vt(t,e,"hex");return r.create=function(n){return new l(t,e,n)},r.update=function(n,o){return r.create(o).update(n)},I(r,Vt,t,e)},oe=function(t,e){var r=Wt[t],n=qt(t,e,"hex");return n.create=function(o,i,u){return Gt(i)&&Gt(u)?_["shake"+t].create(o):new l(t,e,o).bytepad([i,u],r)},n.update=function(o,i,u,a){return n.create(i,u,a).update(o)},I(n,qt,t,e)},ie=function(t,e){var r=Wt[t],n=Lt(t,e,"hex");return n.create=function(o,i,u){return new jt(t,e,i).bytepad(["KMAC",u],r).bytepad([o],r)},n.update=function(o,i,u,a){return n.create(o,u,a).update(i)},I(n,Lt,t,e)},Zt=[{name:"keccak",padding:x,bits:mt,createMethod:Xt},{name:"sha3",padding:te,bits:mt,createMethod:Xt},{name:"shake",padding:Dt,bits:Ht,createMethod:ne},{name:"cshake",padding:N,bits:Ht,createMethod:oe},{name:"kmac",padding:N,bits:Ht,createMethod:ie}],_={},B=[],A=0;A<Zt.length;++A)for(var S=Zt[A],D=S.bits,C=0;C<D.length;++C){var Jt=S.name+"_"+D[C];if(B.push(Jt),_[Jt]=S.createMethod(D[C],S.padding),S.name!=="sha3"){var $t=S.name+D[C];B.push($t),_[$t]=_[Jt]}}function l(t,e,r){this.blocks=[],this.s=[],this.padding=e,this.outputBits=r,this.reset=!0,this.finalized=!1,this.block=0,this.start=0,this.blockCount=1600-(t<<1)>>5,this.byteCount=this.blockCount<<2,this.outputBlocks=r>>5,this.extraBytes=(r&31)>>3;for(var n=0;n<50;++n)this.s[n]=0}l.prototype.update=function(t){if(this.finalized)throw new Error(M);var e=Kt(t);t=e[0];for(var r=e[1],n=this.blocks,o=this.byteCount,i=t.length,u=this.blockCount,a=0,p=this.s,f,c;a<i;){if(this.reset)for(this.reset=!1,n[0]=this.block,f=1;f<u+1;++f)n[f]=0;if(r)for(f=this.start;a<i&&f<o;++a)c=t.charCodeAt(a),c<128?n[f>>2]|=c<<d[f++&3]:c<2048?(n[f>>2]|=(192|c>>6)<<d[f++&3],n[f>>2]|=(128|c&63)<<d[f++&3]):c<55296||c>=57344?(n[f>>2]|=(224|c>>12)<<d[f++&3],n[f>>2]|=(128|c>>6&63)<<d[f++&3],n[f>>2]|=(128|c&63)<<d[f++&3]):(c=65536+((c&1023)<<10|t.charCodeAt(++a)&1023),n[f>>2]|=(240|c>>18)<<d[f++&3],n[f>>2]|=(128|c>>12&63)<<d[f++&3],n[f>>2]|=(128|c>>6&63)<<d[f++&3],n[f>>2]|=(128|c&63)<<d[f++&3]);else for(f=this.start;a<i&&f<o;++a)n[f>>2]|=t[a]<<d[f++&3];if(this.lastByteIndex=f,f>=o){for(this.start=f-o,this.block=n[u],f=0;f<u;++f)p[f]^=n[f];O(p),this.reset=!0}else this.start=f}return this},l.prototype.encode=function(t,e){var r=t&255,n=1,o=[r];for(t=t>>8,r=t&255;r>0;)o.unshift(r),t=t>>8,r=t&255,++n;return e?o.push(n):o.unshift(n),this.update(o),o.length},l.prototype.encodeString=function(t){var e=Kt(t);t=e[0];var r=e[1],n=0,o=t.length;if(r)for(var i=0;i<t.length;++i){var u=t.charCodeAt(i);u<128?n+=1:u<2048?n+=2:u<55296||u>=57344?n+=3:(u=65536+((u&1023)<<10|t.charCodeAt(++i)&1023),n+=4)}else n=o;return n+=this.encode(n*8),this.update(t),n},l.prototype.bytepad=function(t,e){for(var r=this.encode(e),n=0;n<t.length;++n)r+=this.encodeString(t[n]);var o=(e-r%e)%e,i=[];return i.length=o,this.update(i),this},l.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var t=this.blocks,e=this.lastByteIndex,r=this.blockCount,n=this.s;if(t[e>>2]|=this.padding[e&3],this.lastByteIndex===this.byteCount)for(t[0]=t[r],e=1;e<r+1;++e)t[e]=0;for(t[r-1]|=2147483648,e=0;e<r;++e)n[e]^=t[e];O(n)}},l.prototype.toString=l.prototype.hex=function(){this.finalize();for(var t=this.blockCount,e=this.s,r=this.outputBlocks,n=this.extraBytes,o=0,i=0,u="",a;i<r;){for(o=0;o<t&&i<r;++o,++i)a=e[o],u+=h[a>>4&15]+h[a&15]+h[a>>12&15]+h[a>>8&15]+h[a>>20&15]+h[a>>16&15]+h[a>>28&15]+h[a>>24&15];i%t===0&&(e=zt(e),O(e),o=0)}return n&&(a=e[o],u+=h[a>>4&15]+h[a&15],n>1&&(u+=h[a>>12&15]+h[a>>8&15]),n>2&&(u+=h[a>>20&15]+h[a>>16&15])),u},l.prototype.arrayBuffer=function(){this.finalize();var t=this.blockCount,e=this.s,r=this.outputBlocks,n=this.extraBytes,o=0,i=0,u=this.outputBits>>3,a;n?a=new ArrayBuffer(r+1<<2):a=new ArrayBuffer(u);for(var p=new Uint32Array(a);i<r;){for(o=0;o<t&&i<r;++o,++i)p[i]=e[o];i%t===0&&(e=zt(e),O(e))}return n&&(p[i]=e[o],a=a.slice(0,u)),a},l.prototype.buffer=l.prototype.arrayBuffer,l.prototype.digest=l.prototype.array=function(){this.finalize();for(var t=this.blockCount,e=this.s,r=this.outputBlocks,n=this.extraBytes,o=0,i=0,u=[],a,p;i<r;){for(o=0;o<t&&i<r;++o,++i)a=i<<2,p=e[o],u[a]=p&255,u[a+1]=p>>8&255,u[a+2]=p>>16&255,u[a+3]=p>>24&255;i%t===0&&(e=zt(e),O(e))}return n&&(a=i<<2,p=e[o],u[a]=p&255,n>1&&(u[a+1]=p>>8&255),n>2&&(u[a+2]=p>>16&255)),u};function jt(t,e,r){l.call(this,t,e,r)}jt.prototype=new l,jt.prototype.finalize=function(){return this.encode(this.outputBits,!0),l.prototype.finalize.call(this)};var O=function(t){var e,r,n,o,i,u,a,p,f,c,H,K,z,J,j,P,T,m,U,W,G,Y,V,q,L,X,Z,$,Q,s,tt,et,rt,nt,ot,it,at,ut,ft,ct,ht,lt,pt,bt,dt,yt,vt,xt,_t,At,kt,St,Ft,wt,Bt,Ct,Ot,Et,Mt,Rt,gt,Nt,It;for(n=0;n<48;n+=2)o=t[0]^t[10]^t[20]^t[30]^t[40],i=t[1]^t[11]^t[21]^t[31]^t[41],u=t[2]^t[12]^t[22]^t[32]^t[42],a=t[3]^t[13]^t[23]^t[33]^t[43],p=t[4]^t[14]^t[24]^t[34]^t[44],f=t[5]^t[15]^t[25]^t[35]^t[45],c=t[6]^t[16]^t[26]^t[36]^t[46],H=t[7]^t[17]^t[27]^t[37]^t[47],K=t[8]^t[18]^t[28]^t[38]^t[48],z=t[9]^t[19]^t[29]^t[39]^t[49],e=K^(u<<1|a>>>31),r=z^(a<<1|u>>>31),t[0]^=e,t[1]^=r,t[10]^=e,t[11]^=r,t[20]^=e,t[21]^=r,t[30]^=e,t[31]^=r,t[40]^=e,t[41]^=r,e=o^(p<<1|f>>>31),r=i^(f<<1|p>>>31),t[2]^=e,t[3]^=r,t[12]^=e,t[13]^=r,t[22]^=e,t[23]^=r,t[32]^=e,t[33]^=r,t[42]^=e,t[43]^=r,e=u^(c<<1|H>>>31),r=a^(H<<1|c>>>31),t[4]^=e,t[5]^=r,t[14]^=e,t[15]^=r,t[24]^=e,t[25]^=r,t[34]^=e,t[35]^=r,t[44]^=e,t[45]^=r,e=p^(K<<1|z>>>31),r=f^(z<<1|K>>>31),t[6]^=e,t[7]^=r,t[16]^=e,t[17]^=r,t[26]^=e,t[27]^=r,t[36]^=e,t[37]^=r,t[46]^=e,t[47]^=r,e=c^(o<<1|i>>>31),r=H^(i<<1|o>>>31),t[8]^=e,t[9]^=r,t[18]^=e,t[19]^=r,t[28]^=e,t[29]^=r,t[38]^=e,t[39]^=r,t[48]^=e,t[49]^=r,J=t[0],j=t[1],yt=t[11]<<4|t[10]>>>28,vt=t[10]<<4|t[11]>>>28,$=t[20]<<3|t[21]>>>29,Q=t[21]<<3|t[20]>>>29,Rt=t[31]<<9|t[30]>>>23,gt=t[30]<<9|t[31]>>>23,lt=t[40]<<18|t[41]>>>14,pt=t[41]<<18|t[40]>>>14,nt=t[2]<<1|t[3]>>>31,ot=t[3]<<1|t[2]>>>31,P=t[13]<<12|t[12]>>>20,T=t[12]<<12|t[13]>>>20,xt=t[22]<<10|t[23]>>>22,_t=t[23]<<10|t[22]>>>22,s=t[33]<<13|t[32]>>>19,tt=t[32]<<13|t[33]>>>19,Nt=t[42]<<2|t[43]>>>30,It=t[43]<<2|t[42]>>>30,wt=t[5]<<30|t[4]>>>2,Bt=t[4]<<30|t[5]>>>2,it=t[14]<<6|t[15]>>>26,at=t[15]<<6|t[14]>>>26,m=t[25]<<11|t[24]>>>21,U=t[24]<<11|t[25]>>>21,At=t[34]<<15|t[35]>>>17,kt=t[35]<<15|t[34]>>>17,et=t[45]<<29|t[44]>>>3,rt=t[44]<<29|t[45]>>>3,q=t[6]<<28|t[7]>>>4,L=t[7]<<28|t[6]>>>4,Ct=t[17]<<23|t[16]>>>9,Ot=t[16]<<23|t[17]>>>9,ut=t[26]<<25|t[27]>>>7,ft=t[27]<<25|t[26]>>>7,W=t[36]<<21|t[37]>>>11,G=t[37]<<21|t[36]>>>11,St=t[47]<<24|t[46]>>>8,Ft=t[46]<<24|t[47]>>>8,bt=t[8]<<27|t[9]>>>5,dt=t[9]<<27|t[8]>>>5,X=t[18]<<20|t[19]>>>12,Z=t[19]<<20|t[18]>>>12,Et=t[29]<<7|t[28]>>>25,Mt=t[28]<<7|t[29]>>>25,ct=t[38]<<8|t[39]>>>24,ht=t[39]<<8|t[38]>>>24,Y=t[48]<<14|t[49]>>>18,V=t[49]<<14|t[48]>>>18,t[0]=J^~P&m,t[1]=j^~T&U,t[10]=q^~X&$,t[11]=L^~Z&Q,t[20]=nt^~it&ut,t[21]=ot^~at&ft,t[30]=bt^~yt&xt,t[31]=dt^~vt&_t,t[40]=wt^~Ct&Et,t[41]=Bt^~Ot&Mt,t[2]=P^~m&W,t[3]=T^~U&G,t[12]=X^~$&s,t[13]=Z^~Q&tt,t[22]=it^~ut&ct,t[23]=at^~ft&ht,t[32]=yt^~xt&At,t[33]=vt^~_t&kt,t[42]=Ct^~Et&Rt,t[43]=Ot^~Mt&gt,t[4]=m^~W&Y,t[5]=U^~G&V,t[14]=$^~s&et,t[15]=Q^~tt&rt,t[24]=ut^~ct&lt,t[25]=ft^~ht&pt,t[34]=xt^~At&St,t[35]=_t^~kt&Ft,t[44]=Et^~Rt&Nt,t[45]=Mt^~gt&It,t[6]=W^~Y&J,t[7]=G^~V&j,t[16]=s^~et&q,t[17]=tt^~rt&L,t[26]=ct^~lt&nt,t[27]=ht^~pt&ot,t[36]=At^~St&bt,t[37]=kt^~Ft&dt,t[46]=Rt^~Nt&wt,t[47]=gt^~It&Bt,t[8]=Y^~J&P,t[9]=V^~j&T,t[18]=et^~q&X,t[19]=rt^~L&Z,t[28]=lt^~nt&it,t[29]=pt^~ot&at,t[38]=St^~bt&yt,t[39]=Ft^~dt&vt,t[48]=Nt^~wt&Ct,t[49]=It^~Bt&Ot,t[0]^=Tt[n],t[1]^=Tt[n+1]};if(g)v.exports=_;else for(A=0;A<B.length;++A)b[B[A]]=_[B[A]]})()})(Pt)),Pt.exports}var ce=fe();const he=ue(ce),{keccak256:E}=he;class st{constructor(y,M){return this.declarations=[],this.secret=y,this.namespace=M,this.identityRoot="0x"+E(y),this.publicKey="0x"+E("public:"+y),this.identityHash="0x"+E(this.publicKey+M),new Proxy(this,{get:(b,F)=>F in b?b[F]:(...k)=>{const g=String(F),w=x=>x&&typeof x=="object"&&"__pointer"in x?x.__pointer:x;let h;k.length===0?h=void 0:k.length===1?h=w(k[0]):h=k.map(x=>w(x));const Dt="0x"+E(b.secret+g+JSON.stringify(h)+b.namespace),N={key:g,value:h,signature:Dt,timestamp:Date.now()};return b.declarations.push(N),b}})}sign(y){return"0x"+E(this.secret+y)}export(){return{identityRoot:this.identityRoot,publicKey:this.publicKey,namespace:this.namespace,identityHash:this.identityHash,declarations:this.declarations}}ptr(y){return{__pointer:y.signature}}}exports.ME=st;exports.default=st;
@@ -0,0 +1,6 @@
1
+ export * from './index'
2
+ export {}
3
+ import Me from './index'
4
+ export default Me
5
+ export * from './index'
6
+ export {}
package/dist/me.es.js CHANGED
@@ -1,141 +1,312 @@
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
1
+ var ae = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
2
+ function ie(v) {
3
+ return v && v.__esModule && Object.prototype.hasOwnProperty.call(v, "default") ? v.default : v;
4
+ }
5
+ var Pt = { exports: {} };
6
+ /**
7
+ * [js-sha3]{@link https://github.com/emn178/js-sha3}
8
+ *
9
+ * @version 0.9.3
10
+ * @author Chen, Yi-Cyuan [emn178@gmail.com]
11
+ * @copyright Chen, Yi-Cyuan 2015-2023
12
+ * @license MIT
13
+ */
14
+ var Qt;
15
+ function ue() {
16
+ return Qt || (Qt = 1, (function(v) {
17
+ (function() {
18
+ var y = "input is invalid type", R = "finalize already called", M = typeof window == "object", b = M ? window : {};
19
+ b.JS_SHA3_NO_WINDOW && (M = !1);
20
+ var F = !M && typeof self == "object", k = !b.JS_SHA3_NO_NODE_JS && typeof process == "object" && process.versions && process.versions.node;
21
+ k ? b = ae : F && (b = self);
22
+ for (var g = !b.JS_SHA3_NO_COMMON_JS && !0 && v.exports, w = !b.JS_SHA3_NO_ARRAY_BUFFER && typeof ArrayBuffer < "u", h = "0123456789abcdef".split(""), Dt = [31, 7936, 2031616, 520093696], N = [4, 1024, 262144, 67108864], x = [1, 256, 65536, 16777216], st = [6, 1536, 393216, 100663296], d = [0, 8, 16, 24], Tt = [
23
+ 1,
24
+ 0,
25
+ 32898,
26
+ 0,
27
+ 32906,
28
+ 2147483648,
29
+ 2147516416,
30
+ 2147483648,
31
+ 32907,
32
+ 0,
33
+ 2147483649,
34
+ 0,
35
+ 2147516545,
36
+ 2147483648,
37
+ 32777,
38
+ 2147483648,
39
+ 138,
40
+ 0,
41
+ 136,
42
+ 0,
43
+ 2147516425,
44
+ 0,
45
+ 2147483658,
46
+ 0,
47
+ 2147516555,
48
+ 0,
49
+ 139,
50
+ 2147483648,
51
+ 32905,
52
+ 2147483648,
53
+ 32771,
54
+ 2147483648,
55
+ 32770,
56
+ 2147483648,
57
+ 128,
58
+ 2147483648,
59
+ 32778,
60
+ 0,
61
+ 2147483658,
62
+ 2147483648,
63
+ 2147516545,
64
+ 2147483648,
65
+ 32896,
66
+ 2147483648,
67
+ 2147483649,
68
+ 0,
69
+ 2147516424,
70
+ 2147483648
71
+ ], mt = [224, 256, 384, 512], Ht = [128, 256], Ut = ["hex", "buffer", "arrayBuffer", "array", "digest"], Wt = {
72
+ 128: 168,
73
+ 256: 136
74
+ }, te = b.JS_SHA3_NO_NODE_JS || !Array.isArray ? function(t) {
75
+ return Object.prototype.toString.call(t) === "[object Array]";
76
+ } : Array.isArray, ee = w && (b.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView) ? function(t) {
77
+ return typeof t == "object" && t.buffer && t.buffer.constructor === ArrayBuffer;
78
+ } : ArrayBuffer.isView, Kt = function(t) {
79
+ var e = typeof t;
80
+ if (e === "string")
81
+ return [t, !0];
82
+ if (e !== "object" || t === null)
83
+ throw new Error(y);
84
+ if (w && t.constructor === ArrayBuffer)
85
+ return [new Uint8Array(t), !1];
86
+ if (!te(t) && !ee(t))
87
+ throw new Error(y);
88
+ return [t, !1];
89
+ }, Gt = function(t) {
90
+ return Kt(t)[0].length === 0;
91
+ }, zt = function(t) {
92
+ for (var e = [], r = 0; r < t.length; ++r)
93
+ e[r] = t[r];
94
+ return e;
95
+ }, Yt = function(t, e, r) {
96
+ return function(n) {
97
+ return new l(t, e, t).update(n)[r]();
98
+ };
99
+ }, Vt = function(t, e, r) {
100
+ return function(n, o) {
101
+ return new l(t, e, o).update(n)[r]();
102
+ };
103
+ }, qt = function(t, e, r) {
104
+ return function(n, o, a, u) {
105
+ return _["cshake" + t].update(n, o, a, u)[r]();
106
+ };
107
+ }, Lt = function(t, e, r) {
108
+ return function(n, o, a, u) {
109
+ return _["kmac" + t].update(n, o, a, u)[r]();
110
+ };
111
+ }, I = function(t, e, r, n) {
112
+ for (var o = 0; o < Ut.length; ++o) {
113
+ var a = Ut[o];
114
+ t[a] = e(r, n, a);
14
115
  }
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
116
+ return t;
117
+ }, Xt = function(t, e) {
118
+ var r = Yt(t, e, "hex");
119
+ return r.create = function() {
120
+ return new l(t, e, t);
121
+ }, r.update = function(n) {
122
+ return r.create().update(n);
123
+ }, I(r, Yt, t, e);
124
+ }, re = function(t, e) {
125
+ var r = Vt(t, e, "hex");
126
+ return r.create = function(n) {
127
+ return new l(t, e, n);
128
+ }, r.update = function(n, o) {
129
+ return r.create(o).update(n);
130
+ }, I(r, Vt, t, e);
131
+ }, ne = function(t, e) {
132
+ var r = Wt[t], n = qt(t, e, "hex");
133
+ return n.create = function(o, a, u) {
134
+ return Gt(a) && Gt(u) ? _["shake" + t].create(o) : new l(t, e, o).bytepad([a, u], r);
135
+ }, n.update = function(o, a, u, i) {
136
+ return n.create(a, u, i).update(o);
137
+ }, I(n, qt, t, e);
138
+ }, oe = function(t, e) {
139
+ var r = Wt[t], n = Lt(t, e, "hex");
140
+ return n.create = function(o, a, u) {
141
+ return new jt(t, e, a).bytepad(["KMAC", u], r).bytepad([o], r);
142
+ }, n.update = function(o, a, u, i) {
143
+ return n.create(o, u, i).update(a);
144
+ }, I(n, Lt, t, e);
145
+ }, Zt = [
146
+ { name: "keccak", padding: x, bits: mt, createMethod: Xt },
147
+ { name: "sha3", padding: st, bits: mt, createMethod: Xt },
148
+ { name: "shake", padding: Dt, bits: Ht, createMethod: re },
149
+ { name: "cshake", padding: N, bits: Ht, createMethod: ne },
150
+ { name: "kmac", padding: N, bits: Ht, createMethod: oe }
151
+ ], _ = {}, B = [], A = 0; A < Zt.length; ++A)
152
+ for (var S = Zt[A], D = S.bits, C = 0; C < D.length; ++C) {
153
+ var Jt = S.name + "_" + D[C];
154
+ if (B.push(Jt), _[Jt] = S.createMethod(D[C], S.padding), S.name !== "sha3") {
155
+ var $t = S.name + D[C];
156
+ B.push($t), _[$t] = _[Jt];
157
+ }
30
158
  }
159
+ function l(t, e, r) {
160
+ this.blocks = [], this.s = [], this.padding = e, this.outputBits = r, this.reset = !0, this.finalized = !1, this.block = 0, this.start = 0, this.blockCount = 1600 - (t << 1) >> 5, this.byteCount = this.blockCount << 2, this.outputBlocks = r >> 5, this.extraBytes = (r & 31) >> 3;
161
+ for (var n = 0; n < 50; ++n)
162
+ this.s[n] = 0;
31
163
  }
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
164
+ l.prototype.update = function(t) {
165
+ if (this.finalized)
166
+ throw new Error(R);
167
+ var e = Kt(t);
168
+ t = e[0];
169
+ for (var r = e[1], n = this.blocks, o = this.byteCount, a = t.length, u = this.blockCount, i = 0, p = this.s, f, c; i < a; ) {
170
+ if (this.reset)
171
+ for (this.reset = !1, n[0] = this.block, f = 1; f < u + 1; ++f)
172
+ n[f] = 0;
173
+ if (r)
174
+ for (f = this.start; i < a && f < o; ++i)
175
+ c = t.charCodeAt(i), c < 128 ? n[f >> 2] |= c << d[f++ & 3] : c < 2048 ? (n[f >> 2] |= (192 | c >> 6) << d[f++ & 3], n[f >> 2] |= (128 | c & 63) << d[f++ & 3]) : c < 55296 || c >= 57344 ? (n[f >> 2] |= (224 | c >> 12) << d[f++ & 3], n[f >> 2] |= (128 | c >> 6 & 63) << d[f++ & 3], n[f >> 2] |= (128 | c & 63) << d[f++ & 3]) : (c = 65536 + ((c & 1023) << 10 | t.charCodeAt(++i) & 1023), n[f >> 2] |= (240 | c >> 18) << d[f++ & 3], n[f >> 2] |= (128 | c >> 12 & 63) << d[f++ & 3], n[f >> 2] |= (128 | c >> 6 & 63) << d[f++ & 3], n[f >> 2] |= (128 | c & 63) << d[f++ & 3]);
176
+ else
177
+ for (f = this.start; i < a && f < o; ++i)
178
+ n[f >> 2] |= t[i] << d[f++ & 3];
179
+ if (this.lastByteIndex = f, f >= o) {
180
+ for (this.start = f - o, this.block = n[u], f = 0; f < u; ++f)
181
+ p[f] ^= n[f];
182
+ O(p), this.reset = !0;
183
+ } else
184
+ this.start = f;
45
185
  }
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
186
+ return this;
187
+ }, l.prototype.encode = function(t, e) {
188
+ var r = t & 255, n = 1, o = [r];
189
+ for (t = t >> 8, r = t & 255; r > 0; )
190
+ o.unshift(r), t = t >> 8, r = t & 255, ++n;
191
+ return e ? o.push(n) : o.unshift(n), this.update(o), o.length;
192
+ }, l.prototype.encodeString = function(t) {
193
+ var e = Kt(t);
194
+ t = e[0];
195
+ var r = e[1], n = 0, o = t.length;
196
+ if (r)
197
+ for (var a = 0; a < t.length; ++a) {
198
+ var u = t.charCodeAt(a);
199
+ u < 128 ? n += 1 : u < 2048 ? n += 2 : u < 55296 || u >= 57344 ? n += 3 : (u = 65536 + ((u & 1023) << 10 | t.charCodeAt(++a) & 1023), n += 4);
200
+ }
201
+ else
202
+ n = o;
203
+ return n += this.encode(n * 8), this.update(t), n;
204
+ }, l.prototype.bytepad = function(t, e) {
205
+ for (var r = this.encode(e), n = 0; n < t.length; ++n)
206
+ r += this.encodeString(t[n]);
207
+ var o = (e - r % e) % e, a = [];
208
+ return a.length = o, this.update(a), this;
209
+ }, l.prototype.finalize = function() {
210
+ if (!this.finalized) {
211
+ this.finalized = !0;
212
+ var t = this.blocks, e = this.lastByteIndex, r = this.blockCount, n = this.s;
213
+ if (t[e >> 2] |= this.padding[e & 3], this.lastByteIndex === this.byteCount)
214
+ for (t[0] = t[r], e = 1; e < r + 1; ++e)
215
+ t[e] = 0;
216
+ for (t[r - 1] |= 2147483648, e = 0; e < r; ++e)
217
+ n[e] ^= t[e];
218
+ O(n);
63
219
  }
220
+ }, l.prototype.toString = l.prototype.hex = function() {
221
+ this.finalize();
222
+ for (var t = this.blockCount, e = this.s, r = this.outputBlocks, n = this.extraBytes, o = 0, a = 0, u = "", i; a < r; ) {
223
+ for (o = 0; o < t && a < r; ++o, ++a)
224
+ i = e[o], u += h[i >> 4 & 15] + h[i & 15] + h[i >> 12 & 15] + h[i >> 8 & 15] + h[i >> 20 & 15] + h[i >> 16 & 15] + h[i >> 28 & 15] + h[i >> 24 & 15];
225
+ a % t === 0 && (e = zt(e), O(e), o = 0);
226
+ }
227
+ return n && (i = e[o], u += h[i >> 4 & 15] + h[i & 15], n > 1 && (u += h[i >> 12 & 15] + h[i >> 8 & 15]), n > 2 && (u += h[i >> 20 & 15] + h[i >> 16 & 15])), u;
228
+ }, l.prototype.arrayBuffer = function() {
229
+ this.finalize();
230
+ var t = this.blockCount, e = this.s, r = this.outputBlocks, n = this.extraBytes, o = 0, a = 0, u = this.outputBits >> 3, i;
231
+ n ? i = new ArrayBuffer(r + 1 << 2) : i = new ArrayBuffer(u);
232
+ for (var p = new Uint32Array(i); a < r; ) {
233
+ for (o = 0; o < t && a < r; ++o, ++a)
234
+ p[a] = e[o];
235
+ a % t === 0 && (e = zt(e), O(e));
236
+ }
237
+ return n && (p[a] = e[o], i = i.slice(0, u)), i;
238
+ }, l.prototype.buffer = l.prototype.arrayBuffer, l.prototype.digest = l.prototype.array = function() {
239
+ this.finalize();
240
+ for (var t = this.blockCount, e = this.s, r = this.outputBlocks, n = this.extraBytes, o = 0, a = 0, u = [], i, p; a < r; ) {
241
+ for (o = 0; o < t && a < r; ++o, ++a)
242
+ i = a << 2, p = e[o], u[i] = p & 255, u[i + 1] = p >> 8 & 255, u[i + 2] = p >> 16 & 255, u[i + 3] = p >> 24 & 255;
243
+ a % t === 0 && (e = zt(e), O(e));
244
+ }
245
+ return n && (i = a << 2, p = e[o], u[i] = p & 255, n > 1 && (u[i + 1] = p >> 8 & 255), n > 2 && (u[i + 2] = p >> 16 & 255)), u;
246
+ };
247
+ function jt(t, e, r) {
248
+ l.call(this, t, e, r);
64
249
  }
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)
250
+ jt.prototype = new l(), jt.prototype.finalize = function() {
251
+ return this.encode(this.outputBits, !0), l.prototype.finalize.call(this);
252
+ };
253
+ var O = function(t) {
254
+ var e, r, n, o, a, u, i, p, f, c, H, K, z, J, j, P, T, m, U, W, G, Y, V, q, L, X, Z, $, Q, s, tt, et, rt, nt, ot, at, it, ut, ft, ct, ht, lt, pt, bt, dt, yt, vt, xt, _t, At, kt, St, Ft, wt, Bt, Ct, Ot, Et, Rt, Mt, gt, Nt, It;
255
+ for (n = 0; n < 48; n += 2)
256
+ o = t[0] ^ t[10] ^ t[20] ^ t[30] ^ t[40], a = t[1] ^ t[11] ^ t[21] ^ t[31] ^ t[41], u = t[2] ^ t[12] ^ t[22] ^ t[32] ^ t[42], i = t[3] ^ t[13] ^ t[23] ^ t[33] ^ t[43], p = t[4] ^ t[14] ^ t[24] ^ t[34] ^ t[44], f = t[5] ^ t[15] ^ t[25] ^ t[35] ^ t[45], c = t[6] ^ t[16] ^ t[26] ^ t[36] ^ t[46], H = t[7] ^ t[17] ^ t[27] ^ t[37] ^ t[47], K = t[8] ^ t[18] ^ t[28] ^ t[38] ^ t[48], z = t[9] ^ t[19] ^ t[29] ^ t[39] ^ t[49], e = K ^ (u << 1 | i >>> 31), r = z ^ (i << 1 | u >>> 31), t[0] ^= e, t[1] ^= r, t[10] ^= e, t[11] ^= r, t[20] ^= e, t[21] ^= r, t[30] ^= e, t[31] ^= r, t[40] ^= e, t[41] ^= r, e = o ^ (p << 1 | f >>> 31), r = a ^ (f << 1 | p >>> 31), t[2] ^= e, t[3] ^= r, t[12] ^= e, t[13] ^= r, t[22] ^= e, t[23] ^= r, t[32] ^= e, t[33] ^= r, t[42] ^= e, t[43] ^= r, e = u ^ (c << 1 | H >>> 31), r = i ^ (H << 1 | c >>> 31), t[4] ^= e, t[5] ^= r, t[14] ^= e, t[15] ^= r, t[24] ^= e, t[25] ^= r, t[34] ^= e, t[35] ^= r, t[44] ^= e, t[45] ^= r, e = p ^ (K << 1 | z >>> 31), r = f ^ (z << 1 | K >>> 31), t[6] ^= e, t[7] ^= r, t[16] ^= e, t[17] ^= r, t[26] ^= e, t[27] ^= r, t[36] ^= e, t[37] ^= r, t[46] ^= e, t[47] ^= r, e = c ^ (o << 1 | a >>> 31), r = H ^ (a << 1 | o >>> 31), t[8] ^= e, t[9] ^= r, t[18] ^= e, t[19] ^= r, t[28] ^= e, t[29] ^= r, t[38] ^= e, t[39] ^= r, t[48] ^= e, t[49] ^= r, J = t[0], j = t[1], yt = t[11] << 4 | t[10] >>> 28, vt = t[10] << 4 | t[11] >>> 28, $ = t[20] << 3 | t[21] >>> 29, Q = t[21] << 3 | t[20] >>> 29, Mt = t[31] << 9 | t[30] >>> 23, gt = t[30] << 9 | t[31] >>> 23, lt = t[40] << 18 | t[41] >>> 14, pt = t[41] << 18 | t[40] >>> 14, nt = t[2] << 1 | t[3] >>> 31, ot = t[3] << 1 | t[2] >>> 31, P = t[13] << 12 | t[12] >>> 20, T = t[12] << 12 | t[13] >>> 20, xt = t[22] << 10 | t[23] >>> 22, _t = t[23] << 10 | t[22] >>> 22, s = t[33] << 13 | t[32] >>> 19, tt = t[32] << 13 | t[33] >>> 19, Nt = t[42] << 2 | t[43] >>> 30, It = t[43] << 2 | t[42] >>> 30, wt = t[5] << 30 | t[4] >>> 2, Bt = t[4] << 30 | t[5] >>> 2, at = t[14] << 6 | t[15] >>> 26, it = t[15] << 6 | t[14] >>> 26, m = t[25] << 11 | t[24] >>> 21, U = t[24] << 11 | t[25] >>> 21, At = t[34] << 15 | t[35] >>> 17, kt = t[35] << 15 | t[34] >>> 17, et = t[45] << 29 | t[44] >>> 3, rt = t[44] << 29 | t[45] >>> 3, q = t[6] << 28 | t[7] >>> 4, L = t[7] << 28 | t[6] >>> 4, Ct = t[17] << 23 | t[16] >>> 9, Ot = t[16] << 23 | t[17] >>> 9, ut = t[26] << 25 | t[27] >>> 7, ft = t[27] << 25 | t[26] >>> 7, W = t[36] << 21 | t[37] >>> 11, G = t[37] << 21 | t[36] >>> 11, St = t[47] << 24 | t[46] >>> 8, Ft = t[46] << 24 | t[47] >>> 8, bt = t[8] << 27 | t[9] >>> 5, dt = t[9] << 27 | t[8] >>> 5, X = t[18] << 20 | t[19] >>> 12, Z = t[19] << 20 | t[18] >>> 12, Et = t[29] << 7 | t[28] >>> 25, Rt = t[28] << 7 | t[29] >>> 25, ct = t[38] << 8 | t[39] >>> 24, ht = t[39] << 8 | t[38] >>> 24, Y = t[48] << 14 | t[49] >>> 18, V = t[49] << 14 | t[48] >>> 18, t[0] = J ^ ~P & m, t[1] = j ^ ~T & U, t[10] = q ^ ~X & $, t[11] = L ^ ~Z & Q, t[20] = nt ^ ~at & ut, t[21] = ot ^ ~it & ft, t[30] = bt ^ ~yt & xt, t[31] = dt ^ ~vt & _t, t[40] = wt ^ ~Ct & Et, t[41] = Bt ^ ~Ot & Rt, t[2] = P ^ ~m & W, t[3] = T ^ ~U & G, t[12] = X ^ ~$ & s, t[13] = Z ^ ~Q & tt, t[22] = at ^ ~ut & ct, t[23] = it ^ ~ft & ht, t[32] = yt ^ ~xt & At, t[33] = vt ^ ~_t & kt, t[42] = Ct ^ ~Et & Mt, t[43] = Ot ^ ~Rt & gt, t[4] = m ^ ~W & Y, t[5] = U ^ ~G & V, t[14] = $ ^ ~s & et, t[15] = Q ^ ~tt & rt, t[24] = ut ^ ~ct & lt, t[25] = ft ^ ~ht & pt, t[34] = xt ^ ~At & St, t[35] = _t ^ ~kt & Ft, t[44] = Et ^ ~Mt & Nt, t[45] = Rt ^ ~gt & It, t[6] = W ^ ~Y & J, t[7] = G ^ ~V & j, t[16] = s ^ ~et & q, t[17] = tt ^ ~rt & L, t[26] = ct ^ ~lt & nt, t[27] = ht ^ ~pt & ot, t[36] = At ^ ~St & bt, t[37] = kt ^ ~Ft & dt, t[46] = Mt ^ ~Nt & wt, t[47] = gt ^ ~It & Bt, t[8] = Y ^ ~J & P, t[9] = V ^ ~j & T, t[18] = et ^ ~q & X, t[19] = rt ^ ~L & Z, t[28] = lt ^ ~nt & at, t[29] = pt ^ ~ot & it, t[38] = St ^ ~bt & yt, t[39] = Ft ^ ~dt & vt, t[48] = Nt ^ ~wt & Ct, t[49] = It ^ ~Bt & Ot, t[0] ^= Tt[n], t[1] ^= Tt[n + 1];
257
+ };
258
+ if (g)
259
+ v.exports = _;
260
+ else
261
+ for (A = 0; A < B.length; ++A)
262
+ b[B[A]] = _[B[A]];
263
+ })();
264
+ })(Pt)), Pt.exports;
265
+ }
266
+ var fe = ue();
267
+ const ce = /* @__PURE__ */ ie(fe), { keccak256: E } = ce;
268
+ class he {
269
+ constructor(y, R) {
270
+ return this.declarations = [], this.secret = y, this.namespace = R, this.identityRoot = "0x" + E(y), this.publicKey = "0x" + E("public:" + y), this.identityHash = "0x" + E(this.publicKey + R), new Proxy(this, {
271
+ get: (b, F) => F in b ? b[F] : (...k) => {
272
+ const g = String(F), w = (x) => x && typeof x == "object" && "__pointer" in x ? x.__pointer : x;
273
+ let h;
274
+ k.length === 0 ? h = void 0 : k.length === 1 ? h = w(k[0]) : h = k.map((x) => w(x));
275
+ const Dt = "0x" + E(
276
+ b.secret + g + JSON.stringify(h) + b.namespace
277
+ ), N = {
278
+ key: g,
279
+ value: h,
280
+ signature: Dt,
281
+ timestamp: Date.now()
282
+ };
283
+ return b.declarations.push(N), b;
76
284
  }
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;
285
+ });
110
286
  }
111
- subscribe(t) {
112
- return this.subscribers.add(t), () => this.subscribers.delete(t);
287
+ /**
288
+ * Firma genérica de mensajes si se necesita fuera de las declaraciones.
289
+ */
290
+ sign(y) {
291
+ return "0x" + E(this.secret + y);
113
292
  }
114
- #s(t) {
115
- this.state = { ...this.state, ...t }, this.subscribers.forEach((s) => s(this.state));
293
+ /**
294
+ * Exportar el snapshot de ME para mandarlo a Cleaker (ledger, graph, etc.).
295
+ */
296
+ export() {
297
+ return {
298
+ identityRoot: this.identityRoot,
299
+ publicKey: this.publicKey,
300
+ namespace: this.namespace,
301
+ identityHash: this.identityHash,
302
+ declarations: this.declarations
303
+ };
116
304
  }
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;
305
+ ptr(y) {
306
+ return { __pointer: y.signature };
127
307
  }
128
308
  }
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
309
  export {
140
- u as default
310
+ he as ME,
311
+ he as default
141
312
  };
package/dist/me.umd.js CHANGED
@@ -1,34 +1,8 @@
1
- (function(i,u){typeof exports=="object"&&typeof module<"u"?module.exports=u():typeof define=="function"&&define.amd?define(u):(i=typeof globalThis<"u"?globalThis:i||self,i.Me=u())})(this,(function(){"use strict";class i{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,a=null){const l=`
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(l,{username:s,password:e,key:n,value:r,context_id:a}))[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(a=>a.message).join(", "));return n}}const u=new i,o=new Proxy(u,{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(a=>console.log(`[this.me] ${String(t)} ✓`,a)).catch(a=>console.error(`[this.me] ${String(t)} ✗`,a)),r}}});return typeof window<"u"&&(window.me=o,o.help=()=>console.table(Object.getOwnPropertyNames(i.prototype))),o}));
1
+ (function(k,w){typeof exports=="object"&&typeof module<"u"?w(exports):typeof define=="function"&&define.amd?define(["exports"],w):(k=typeof globalThis<"u"?globalThis:k||self,w(k.Me={}))})(this,(function(k){"use strict";var w=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function re(v){return v&&v.__esModule&&Object.prototype.hasOwnProperty.call(v,"default")?v.default:v}var Kt={exports:{}};/**
2
+ * [js-sha3]{@link https://github.com/emn178/js-sha3}
3
+ *
4
+ * @version 0.9.3
5
+ * @author Chen, Yi-Cyuan [emn178@gmail.com]
6
+ * @copyright Chen, Yi-Cyuan 2015-2023
7
+ * @license MIT
8
+ */var Ut;function ne(){return Ut||(Ut=1,(function(v){(function(){var y="input is invalid type",g="finalize already called",N=typeof window=="object",d=N?window:{};d.JS_SHA3_NO_WINDOW&&(N=!1);var C=!N&&typeof self=="object",S=!d.JS_SHA3_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;S?d=w:C&&(d=self);for(var I=!d.JS_SHA3_NO_COMMON_JS&&!0&&v.exports,O=!d.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",h="0123456789abcdef".split(""),zt=[31,7936,2031616,520093696],D=[4,1024,262144,67108864],x=[1,256,65536,16777216],ae=[6,1536,393216,100663296],b=[0,8,16,24],Gt=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],Yt=[224,256,384,512],Tt=[128,256],Vt=["hex","buffer","arrayBuffer","array","digest"],qt={128:168,256:136},ue=d.JS_SHA3_NO_NODE_JS||!Array.isArray?function(t){return Object.prototype.toString.call(t)==="[object Array]"}:Array.isArray,fe=O&&(d.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)?function(t){return typeof t=="object"&&t.buffer&&t.buffer.constructor===ArrayBuffer}:ArrayBuffer.isView,jt=function(t){var e=typeof t;if(e==="string")return[t,!0];if(e!=="object"||t===null)throw new Error(y);if(O&&t.constructor===ArrayBuffer)return[new Uint8Array(t),!1];if(!ue(t)&&!fe(t))throw new Error(y);return[t,!1]},Lt=function(t){return jt(t)[0].length===0},mt=function(t){for(var e=[],r=0;r<t.length;++r)e[r]=t[r];return e},Xt=function(t,e,r){return function(n){return new l(t,e,t).update(n)[r]()}},Zt=function(t,e,r){return function(n,o){return new l(t,e,o).update(n)[r]()}},$t=function(t,e,r){return function(n,o,i,u){return _["cshake"+t].update(n,o,i,u)[r]()}},Qt=function(t,e,r){return function(n,o,i,u){return _["kmac"+t].update(n,o,i,u)[r]()}},H=function(t,e,r,n){for(var o=0;o<Vt.length;++o){var i=Vt[o];t[i]=e(r,n,i)}return t},st=function(t,e){var r=Xt(t,e,"hex");return r.create=function(){return new l(t,e,t)},r.update=function(n){return r.create().update(n)},H(r,Xt,t,e)},ce=function(t,e){var r=Zt(t,e,"hex");return r.create=function(n){return new l(t,e,n)},r.update=function(n,o){return r.create(o).update(n)},H(r,Zt,t,e)},he=function(t,e){var r=qt[t],n=$t(t,e,"hex");return n.create=function(o,i,u){return Lt(i)&&Lt(u)?_["shake"+t].create(o):new l(t,e,o).bytepad([i,u],r)},n.update=function(o,i,u,a){return n.create(i,u,a).update(o)},H(n,$t,t,e)},le=function(t,e){var r=qt[t],n=Qt(t,e,"hex");return n.create=function(o,i,u){return new Pt(t,e,i).bytepad(["KMAC",u],r).bytepad([o],r)},n.update=function(o,i,u,a){return n.create(o,u,a).update(i)},H(n,Qt,t,e)},te=[{name:"keccak",padding:x,bits:Yt,createMethod:st},{name:"sha3",padding:ae,bits:Yt,createMethod:st},{name:"shake",padding:zt,bits:Tt,createMethod:ce},{name:"cshake",padding:D,bits:Tt,createMethod:he},{name:"kmac",padding:D,bits:Tt,createMethod:le}],_={},E=[],A=0;A<te.length;++A)for(var F=te[A],K=F.bits,M=0;M<K.length;++M){var Jt=F.name+"_"+K[M];if(E.push(Jt),_[Jt]=F.createMethod(K[M],F.padding),F.name!=="sha3"){var ee=F.name+K[M];E.push(ee),_[ee]=_[Jt]}}function l(t,e,r){this.blocks=[],this.s=[],this.padding=e,this.outputBits=r,this.reset=!0,this.finalized=!1,this.block=0,this.start=0,this.blockCount=1600-(t<<1)>>5,this.byteCount=this.blockCount<<2,this.outputBlocks=r>>5,this.extraBytes=(r&31)>>3;for(var n=0;n<50;++n)this.s[n]=0}l.prototype.update=function(t){if(this.finalized)throw new Error(g);var e=jt(t);t=e[0];for(var r=e[1],n=this.blocks,o=this.byteCount,i=t.length,u=this.blockCount,a=0,p=this.s,f,c;a<i;){if(this.reset)for(this.reset=!1,n[0]=this.block,f=1;f<u+1;++f)n[f]=0;if(r)for(f=this.start;a<i&&f<o;++a)c=t.charCodeAt(a),c<128?n[f>>2]|=c<<b[f++&3]:c<2048?(n[f>>2]|=(192|c>>6)<<b[f++&3],n[f>>2]|=(128|c&63)<<b[f++&3]):c<55296||c>=57344?(n[f>>2]|=(224|c>>12)<<b[f++&3],n[f>>2]|=(128|c>>6&63)<<b[f++&3],n[f>>2]|=(128|c&63)<<b[f++&3]):(c=65536+((c&1023)<<10|t.charCodeAt(++a)&1023),n[f>>2]|=(240|c>>18)<<b[f++&3],n[f>>2]|=(128|c>>12&63)<<b[f++&3],n[f>>2]|=(128|c>>6&63)<<b[f++&3],n[f>>2]|=(128|c&63)<<b[f++&3]);else for(f=this.start;a<i&&f<o;++a)n[f>>2]|=t[a]<<b[f++&3];if(this.lastByteIndex=f,f>=o){for(this.start=f-o,this.block=n[u],f=0;f<u;++f)p[f]^=n[f];R(p),this.reset=!0}else this.start=f}return this},l.prototype.encode=function(t,e){var r=t&255,n=1,o=[r];for(t=t>>8,r=t&255;r>0;)o.unshift(r),t=t>>8,r=t&255,++n;return e?o.push(n):o.unshift(n),this.update(o),o.length},l.prototype.encodeString=function(t){var e=jt(t);t=e[0];var r=e[1],n=0,o=t.length;if(r)for(var i=0;i<t.length;++i){var u=t.charCodeAt(i);u<128?n+=1:u<2048?n+=2:u<55296||u>=57344?n+=3:(u=65536+((u&1023)<<10|t.charCodeAt(++i)&1023),n+=4)}else n=o;return n+=this.encode(n*8),this.update(t),n},l.prototype.bytepad=function(t,e){for(var r=this.encode(e),n=0;n<t.length;++n)r+=this.encodeString(t[n]);var o=(e-r%e)%e,i=[];return i.length=o,this.update(i),this},l.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var t=this.blocks,e=this.lastByteIndex,r=this.blockCount,n=this.s;if(t[e>>2]|=this.padding[e&3],this.lastByteIndex===this.byteCount)for(t[0]=t[r],e=1;e<r+1;++e)t[e]=0;for(t[r-1]|=2147483648,e=0;e<r;++e)n[e]^=t[e];R(n)}},l.prototype.toString=l.prototype.hex=function(){this.finalize();for(var t=this.blockCount,e=this.s,r=this.outputBlocks,n=this.extraBytes,o=0,i=0,u="",a;i<r;){for(o=0;o<t&&i<r;++o,++i)a=e[o],u+=h[a>>4&15]+h[a&15]+h[a>>12&15]+h[a>>8&15]+h[a>>20&15]+h[a>>16&15]+h[a>>28&15]+h[a>>24&15];i%t===0&&(e=mt(e),R(e),o=0)}return n&&(a=e[o],u+=h[a>>4&15]+h[a&15],n>1&&(u+=h[a>>12&15]+h[a>>8&15]),n>2&&(u+=h[a>>20&15]+h[a>>16&15])),u},l.prototype.arrayBuffer=function(){this.finalize();var t=this.blockCount,e=this.s,r=this.outputBlocks,n=this.extraBytes,o=0,i=0,u=this.outputBits>>3,a;n?a=new ArrayBuffer(r+1<<2):a=new ArrayBuffer(u);for(var p=new Uint32Array(a);i<r;){for(o=0;o<t&&i<r;++o,++i)p[i]=e[o];i%t===0&&(e=mt(e),R(e))}return n&&(p[i]=e[o],a=a.slice(0,u)),a},l.prototype.buffer=l.prototype.arrayBuffer,l.prototype.digest=l.prototype.array=function(){this.finalize();for(var t=this.blockCount,e=this.s,r=this.outputBlocks,n=this.extraBytes,o=0,i=0,u=[],a,p;i<r;){for(o=0;o<t&&i<r;++o,++i)a=i<<2,p=e[o],u[a]=p&255,u[a+1]=p>>8&255,u[a+2]=p>>16&255,u[a+3]=p>>24&255;i%t===0&&(e=mt(e),R(e))}return n&&(a=i<<2,p=e[o],u[a]=p&255,n>1&&(u[a+1]=p>>8&255),n>2&&(u[a+2]=p>>16&255)),u};function Pt(t,e,r){l.call(this,t,e,r)}Pt.prototype=new l,Pt.prototype.finalize=function(){return this.encode(this.outputBits,!0),l.prototype.finalize.call(this)};var R=function(t){var e,r,n,o,i,u,a,p,f,c,z,T,j,m,J,P,U,W,G,Y,V,q,L,X,Z,$,Q,s,tt,et,rt,nt,ot,it,at,ut,ft,ct,ht,lt,pt,dt,bt,yt,vt,xt,_t,At,kt,St,Ft,wt,Bt,Ct,Ot,Et,Mt,Rt,gt,Nt,It,Dt,Ht;for(n=0;n<48;n+=2)o=t[0]^t[10]^t[20]^t[30]^t[40],i=t[1]^t[11]^t[21]^t[31]^t[41],u=t[2]^t[12]^t[22]^t[32]^t[42],a=t[3]^t[13]^t[23]^t[33]^t[43],p=t[4]^t[14]^t[24]^t[34]^t[44],f=t[5]^t[15]^t[25]^t[35]^t[45],c=t[6]^t[16]^t[26]^t[36]^t[46],z=t[7]^t[17]^t[27]^t[37]^t[47],T=t[8]^t[18]^t[28]^t[38]^t[48],j=t[9]^t[19]^t[29]^t[39]^t[49],e=T^(u<<1|a>>>31),r=j^(a<<1|u>>>31),t[0]^=e,t[1]^=r,t[10]^=e,t[11]^=r,t[20]^=e,t[21]^=r,t[30]^=e,t[31]^=r,t[40]^=e,t[41]^=r,e=o^(p<<1|f>>>31),r=i^(f<<1|p>>>31),t[2]^=e,t[3]^=r,t[12]^=e,t[13]^=r,t[22]^=e,t[23]^=r,t[32]^=e,t[33]^=r,t[42]^=e,t[43]^=r,e=u^(c<<1|z>>>31),r=a^(z<<1|c>>>31),t[4]^=e,t[5]^=r,t[14]^=e,t[15]^=r,t[24]^=e,t[25]^=r,t[34]^=e,t[35]^=r,t[44]^=e,t[45]^=r,e=p^(T<<1|j>>>31),r=f^(j<<1|T>>>31),t[6]^=e,t[7]^=r,t[16]^=e,t[17]^=r,t[26]^=e,t[27]^=r,t[36]^=e,t[37]^=r,t[46]^=e,t[47]^=r,e=c^(o<<1|i>>>31),r=z^(i<<1|o>>>31),t[8]^=e,t[9]^=r,t[18]^=e,t[19]^=r,t[28]^=e,t[29]^=r,t[38]^=e,t[39]^=r,t[48]^=e,t[49]^=r,m=t[0],J=t[1],xt=t[11]<<4|t[10]>>>28,_t=t[10]<<4|t[11]>>>28,s=t[20]<<3|t[21]>>>29,tt=t[21]<<3|t[20]>>>29,Nt=t[31]<<9|t[30]>>>23,It=t[30]<<9|t[31]>>>23,dt=t[40]<<18|t[41]>>>14,bt=t[41]<<18|t[40]>>>14,it=t[2]<<1|t[3]>>>31,at=t[3]<<1|t[2]>>>31,P=t[13]<<12|t[12]>>>20,U=t[12]<<12|t[13]>>>20,At=t[22]<<10|t[23]>>>22,kt=t[23]<<10|t[22]>>>22,et=t[33]<<13|t[32]>>>19,rt=t[32]<<13|t[33]>>>19,Dt=t[42]<<2|t[43]>>>30,Ht=t[43]<<2|t[42]>>>30,Ct=t[5]<<30|t[4]>>>2,Ot=t[4]<<30|t[5]>>>2,ut=t[14]<<6|t[15]>>>26,ft=t[15]<<6|t[14]>>>26,W=t[25]<<11|t[24]>>>21,G=t[24]<<11|t[25]>>>21,St=t[34]<<15|t[35]>>>17,Ft=t[35]<<15|t[34]>>>17,nt=t[45]<<29|t[44]>>>3,ot=t[44]<<29|t[45]>>>3,X=t[6]<<28|t[7]>>>4,Z=t[7]<<28|t[6]>>>4,Et=t[17]<<23|t[16]>>>9,Mt=t[16]<<23|t[17]>>>9,ct=t[26]<<25|t[27]>>>7,ht=t[27]<<25|t[26]>>>7,Y=t[36]<<21|t[37]>>>11,V=t[37]<<21|t[36]>>>11,wt=t[47]<<24|t[46]>>>8,Bt=t[46]<<24|t[47]>>>8,yt=t[8]<<27|t[9]>>>5,vt=t[9]<<27|t[8]>>>5,$=t[18]<<20|t[19]>>>12,Q=t[19]<<20|t[18]>>>12,Rt=t[29]<<7|t[28]>>>25,gt=t[28]<<7|t[29]>>>25,lt=t[38]<<8|t[39]>>>24,pt=t[39]<<8|t[38]>>>24,q=t[48]<<14|t[49]>>>18,L=t[49]<<14|t[48]>>>18,t[0]=m^~P&W,t[1]=J^~U&G,t[10]=X^~$&s,t[11]=Z^~Q&tt,t[20]=it^~ut&ct,t[21]=at^~ft&ht,t[30]=yt^~xt&At,t[31]=vt^~_t&kt,t[40]=Ct^~Et&Rt,t[41]=Ot^~Mt&gt,t[2]=P^~W&Y,t[3]=U^~G&V,t[12]=$^~s&et,t[13]=Q^~tt&rt,t[22]=ut^~ct&lt,t[23]=ft^~ht&pt,t[32]=xt^~At&St,t[33]=_t^~kt&Ft,t[42]=Et^~Rt&Nt,t[43]=Mt^~gt&It,t[4]=W^~Y&q,t[5]=G^~V&L,t[14]=s^~et&nt,t[15]=tt^~rt&ot,t[24]=ct^~lt&dt,t[25]=ht^~pt&bt,t[34]=At^~St&wt,t[35]=kt^~Ft&Bt,t[44]=Rt^~Nt&Dt,t[45]=gt^~It&Ht,t[6]=Y^~q&m,t[7]=V^~L&J,t[16]=et^~nt&X,t[17]=rt^~ot&Z,t[26]=lt^~dt&it,t[27]=pt^~bt&at,t[36]=St^~wt&yt,t[37]=Ft^~Bt&vt,t[46]=Nt^~Dt&Ct,t[47]=It^~Ht&Ot,t[8]=q^~m&P,t[9]=L^~J&U,t[18]=nt^~X&$,t[19]=ot^~Z&Q,t[28]=dt^~it&ut,t[29]=bt^~at&ft,t[38]=wt^~yt&xt,t[39]=Bt^~vt&_t,t[48]=Dt^~Ct&Et,t[49]=Ht^~Ot&Mt,t[0]^=Gt[n],t[1]^=Gt[n+1]};if(I)v.exports=_;else for(A=0;A<E.length;++A)d[E[A]]=_[E[A]]})()})(Kt)),Kt.exports}var oe=ne();const ie=re(oe),{keccak256:B}=ie;class Wt{constructor(y,g){return this.declarations=[],this.secret=y,this.namespace=g,this.identityRoot="0x"+B(y),this.publicKey="0x"+B("public:"+y),this.identityHash="0x"+B(this.publicKey+g),new Proxy(this,{get:(d,C)=>C in d?d[C]:(...S)=>{const I=String(C),O=x=>x&&typeof x=="object"&&"__pointer"in x?x.__pointer:x;let h;S.length===0?h=void 0:S.length===1?h=O(S[0]):h=S.map(x=>O(x));const zt="0x"+B(d.secret+I+JSON.stringify(h)+d.namespace),D={key:I,value:h,signature:zt,timestamp:Date.now()};return d.declarations.push(D),d}})}sign(y){return"0x"+B(this.secret+y)}export(){return{identityRoot:this.identityRoot,publicKey:this.publicKey,namespace:this.namespace,identityHash:this.identityHash,declarations:this.declarations}}ptr(y){return{__pointer:y.signature}}}k.ME=Wt,k.default=Wt,Object.defineProperties(k,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
@@ -0,0 +1,53 @@
1
+ /**
2
+ * me.ts — ME Identity Atom + Declarative Model
3
+ * - Pure mathematical identity model for .me
4
+ * - Dynamic, user-centric declarative layer (ME Calculus)
5
+ */
6
+ export interface MeIdentity {
7
+ identityRoot: string;
8
+ publicKey: string;
9
+ namespace: string;
10
+ identityHash: string;
11
+ }
12
+ export interface MeDeclaration {
13
+ key: string;
14
+ value: any;
15
+ signature: string;
16
+ timestamp: number;
17
+ }
18
+ /**
19
+ * ME:
20
+ * - Construct with (secret, namespace)
21
+ * - Any unknown property access becomes a declarative method:
22
+ * me.password("abc")
23
+ * me.instrumentos("musicales", "Moog Matriarch")
24
+ * - Each call generates a signed declaration pushed into `declarations`.
25
+ * - No semántica: only key/value + signature.
26
+ */
27
+ export declare class ME implements MeIdentity {
28
+ identityRoot: string;
29
+ secret: string;
30
+ publicKey: string;
31
+ namespace: string;
32
+ identityHash: string;
33
+ declarations: MeDeclaration[];
34
+ [key: string]: any;
35
+ constructor(secret: string, namespace: string);
36
+ /**
37
+ * Firma genérica de mensajes si se necesita fuera de las declaraciones.
38
+ */
39
+ sign(message: string): string;
40
+ /**
41
+ * Exportar el snapshot de ME para mandarlo a Cleaker (ledger, graph, etc.).
42
+ */
43
+ export(): {
44
+ identityRoot: string;
45
+ publicKey: string;
46
+ namespace: string;
47
+ identityHash: string;
48
+ declarations: MeDeclaration[];
49
+ };
50
+ ptr(declaration: MeDeclaration): {
51
+ __pointer: string;
52
+ };
53
+ }
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "this.me",
3
- "version": "3.0.25",
3
+ "version": "3.0.26",
4
4
  "description": ".me is your identity trust through cryptographic signatures.",
5
- "main": "dist/me.cjs.js",
6
- "module": "dist/me.es.js",
5
+ "main": "dist/me.cjs.js",
6
+ "module": "dist/me.es.js",
7
7
  "browser": "dist/me.umd.js",
8
8
  "exports": {
9
9
  ".": {
10
10
  "import": "./dist/me.es.js",
11
11
  "require": "./dist/me.cjs.js"
12
12
  }
13
- },
13
+ },
14
14
  "scripts": {
15
15
  "dev": "vite",
16
16
  "build": "vite build",
@@ -18,8 +18,14 @@
18
18
  },
19
19
  "type": "module",
20
20
  "keywords": [
21
- "this.me", "identity", "decentralized", "cryptographic",
22
- "trust", "signature", "local", "monad"
21
+ "this.me",
22
+ "identity",
23
+ "decentralized",
24
+ "cryptographic",
25
+ "trust",
26
+ "signature",
27
+ "local",
28
+ "monad"
23
29
  ],
24
30
  "repository": {
25
31
  "type": "git",
@@ -34,5 +40,8 @@
34
40
  "devDependencies": {
35
41
  "vite": "^7.0.6",
36
42
  "vite-plugin-dts": "^4.5.4"
43
+ },
44
+ "dependencies": {
45
+ "js-sha3": "^0.9.3"
37
46
  }
38
47
  }