this.me 3.0.29 β 3.0.30
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 +23 -48
- package/dist/me.cjs +1 -1
- package/dist/me.es.js +92 -92
- package/dist/me.umd.js +1 -1
- package/dist/src/me.d.ts +2 -1
- package/package.json +3 -6
package/README.md
CHANGED
|
@@ -7,28 +7,25 @@
|
|
|
7
7
|
npm install this.me
|
|
8
8
|
```
|
|
9
9
|
|
|
10
|
-
##### **2. Browser:**
|
|
11
|
-
|
|
12
|
-
```html
|
|
13
|
-
<script src="me.umd.js"></script>
|
|
14
|
-
<script>
|
|
15
|
-
const me = new Me.ME("secret");
|
|
16
|
-
</script>
|
|
17
|
-
```
|
|
18
|
-
|
|
19
10
|
<img src="https://suign.github.io/assets/imgs/monads.png" alt="Cleak Me Please" width="244">Hello, I am **.me**
|
|
20
11
|
----
|
|
21
12
|
|
|
22
|
-
## Declarative Identity Language
|
|
23
|
-
|
|
13
|
+
## A Declarative Identity Language
|
|
14
|
+
|
|
15
|
+
###### me(username, secret, blockchain) β
|
|
16
|
+
> π **Update:** `.me` now includes the `blockchain` parameter as part of its identity derivation surface.
|
|
17
|
+
This allows identities to exist deterministically across different ledgers while preserving parallel universes of meaning.
|
|
18
|
+
Each blockchain becomes a **jurisdiction of identity**, enabling global usernames (via cleaker.me) and local identities (via any host), all verifiable and mathematically consistent.
|
|
19
|
+
|
|
20
|
+
Minimal, expressive and infinitely nested identity calculus.
|
|
24
21
|
|
|
25
22
|
`.me` is a **language** β a semantic engine that builds identity, meaning, structure, and **encrypted universes** through simple expressions.
|
|
26
23
|
|
|
27
24
|
Everything emerges from two primitives:
|
|
28
25
|
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
```text
|
|
27
|
+
Declare meaning
|
|
28
|
+
Resolve meaning
|
|
32
29
|
```
|
|
33
30
|
|
|
34
31
|
---
|
|
@@ -56,7 +53,7 @@ if (me("profile.age") > 18) {
|
|
|
56
53
|
|
|
57
54
|
---
|
|
58
55
|
|
|
59
|
-
|
|
56
|
+
## π³ Infinite Semantic Trees
|
|
60
57
|
**.me** supports infinite nesting:
|
|
61
58
|
|
|
62
59
|
```ts
|
|
@@ -77,7 +74,7 @@ me("synth.moog.grandmother.osc1.wave");
|
|
|
77
74
|
|
|
78
75
|
---
|
|
79
76
|
|
|
80
|
-
|
|
77
|
+
## π Secrets: Encrypted Universes
|
|
81
78
|
Secrets create private branches:
|
|
82
79
|
|
|
83
80
|
```ts
|
|
@@ -129,7 +126,7 @@ root
|
|
|
129
126
|
|
|
130
127
|
Everything below wallet is encrypted **as one block**.
|
|
131
128
|
|
|
132
|
-
|
|
129
|
+
## π Declaring another secret inside creates a nested universe
|
|
133
130
|
You do:
|
|
134
131
|
```
|
|
135
132
|
me.wallet.private.secret("DEEP");
|
|
@@ -148,7 +145,7 @@ root
|
|
|
148
145
|
βββ ...nodes...
|
|
149
146
|
```
|
|
150
147
|
|
|
151
|
-
|
|
148
|
+
## π Accessing nested secrets requires walking the secret chain
|
|
152
149
|
To read the inner content:
|
|
153
150
|
|
|
154
151
|
```js
|
|
@@ -162,7 +159,7 @@ Then:
|
|
|
162
159
|
me("wallet.private") // returns decrypted inner structure
|
|
163
160
|
```
|
|
164
161
|
|
|
165
|
-
|
|
162
|
+
## **π You can nest as many secrets as you want**
|
|
166
163
|
|
|
167
164
|
```js
|
|
168
165
|
me.x.secret("A");
|
|
@@ -205,31 +202,7 @@ me.cars.keys.secret("X");
|
|
|
205
202
|
β encrypted under "X"
|
|
206
203
|
|
|
207
204
|
##### **β Exactly that.**
|
|
208
|
-
|
|
209
|
-
The part confusing is this:
|
|
210
|
-
|
|
211
|
-
```
|
|
212
|
-
me.wallet.balance(500).secret("ABC");
|
|
213
|
-
me.wallet.transactions.list([1,2,3]).secret("ABC");
|
|
214
|
-
```
|
|
215
|
-
|
|
216
|
-
You thought:
|
|
217
|
-
|
|
218
|
-
> βSecret should attach to the position and encrypt everything coming after it.β
|
|
219
|
-
YES β that is what ME does.
|
|
220
|
-
But because each declaration is on a different line, you call .secret twice.
|
|
221
|
-
ME then merges both values under the same secret scope.
|
|
222
|
-
If you want **position-based secrets**, you can also do:
|
|
223
|
-
|
|
224
|
-
```
|
|
225
|
-
me.wallet.secret("ABC");
|
|
226
|
-
me.wallet.balance(500);
|
|
227
|
-
me.wallet.transactions.list([1,2,3]);
|
|
228
|
-
```
|
|
229
|
-
|
|
230
|
-
Same result.
|
|
231
|
-
|
|
232
|
-
# **π§ So to answer common questions:**
|
|
205
|
+
### **π§ So to answer common questions:**
|
|
233
206
|
##### **β Yes β you can declare secrets at specific positions.**
|
|
234
207
|
##### **β Yes β everything under that branch becomes encrypted.**
|
|
235
208
|
##### **β Yes β you can put another secret deeper.**
|
|
@@ -237,7 +210,7 @@ Same result.
|
|
|
237
210
|
|
|
238
211
|
---
|
|
239
212
|
|
|
240
|
-
|
|
213
|
+
### 𧬠Why ME Works
|
|
241
214
|
|
|
242
215
|
- Proxies β infinite language surface
|
|
243
216
|
- Path strings β universal query interface
|
|
@@ -249,7 +222,7 @@ Same result.
|
|
|
249
222
|
|
|
250
223
|
---
|
|
251
224
|
|
|
252
|
-
|
|
225
|
+
### π¦ Export Identity
|
|
253
226
|
|
|
254
227
|
```ts
|
|
255
228
|
console.log(me.export());
|
|
@@ -271,7 +244,7 @@ Produces a deterministic structure:
|
|
|
271
244
|
|
|
272
245
|
---
|
|
273
246
|
|
|
274
|
-
|
|
247
|
+
### π§ Full Example
|
|
275
248
|
|
|
276
249
|
```ts
|
|
277
250
|
import { ME } from "this.me";
|
|
@@ -307,9 +280,11 @@ console.log(JSON.stringify(me.export(), null, 2));
|
|
|
307
280
|
|
|
308
281
|
---
|
|
309
282
|
|
|
310
|
-
|
|
283
|
+
## β΅ The Philosophy
|
|
311
284
|
A semantic language for identity, built from recursive declarations and symbolic paths.
|
|
285
|
+
|
|
312
286
|
`me` is β΅ **meaning** β΅ **identities** β΅ **universes** β΅ **meaning.**
|
|
287
|
+
|
|
313
288
|
With one primitive:
|
|
314
289
|
|
|
315
290
|
```
|
package/dist/me.cjs
CHANGED
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* @author Chen, Yi-Cyuan [emn178@gmail.com]
|
|
6
6
|
* @copyright Chen, Yi-Cyuan 2015-2023
|
|
7
7
|
* @license MIT
|
|
8
|
-
*/var te;function he(){return te||(te=1,(function(E){(function(){var i="input is invalid type",o="finalize already called",l=typeof window=="object",a=l?window:{};a.JS_SHA3_NO_WINDOW&&(l=!1);var y=!l&&typeof self=="object",b=!a.JS_SHA3_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;b?a=ce:y&&(a=self);for(var B=!a.JS_SHA3_NO_COMMON_JS&&!0&&E.exports,p=!a.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",d="0123456789abcdef".split(""),P=[31,7936,2031616,520093696],k=[4,1024,262144,67108864],F=[1,256,65536,16777216],w=[6,1536,393216,100663296],v=[0,8,16,24],_=[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],j=[224,256,384,512],C=[128,256],A=["hex","buffer","arrayBuffer","array","digest"],K={128:168,256:136},ee=a.JS_SHA3_NO_NODE_JS||!Array.isArray?function(t){return Object.prototype.toString.call(t)==="[object Array]"}:Array.isArray,re=p&&(a.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)?function(t){return typeof t=="object"&&t.buffer&&t.buffer.constructor===ArrayBuffer}:ArrayBuffer.isView,Vt=function(t){var e=typeof t;if(e==="string")return[t,!0];if(e!=="object"||t===null)throw new Error(i);if(p&&t.constructor===ArrayBuffer)return[new Uint8Array(t),!1];if(!ee(t)&&!re(t))throw new Error(i);return[t,!1]},Gt=function(t){return Vt(t)[0].length===0},Jt=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 g(t,e,t).update(n)[r]()}},qt=function(t,e,r){return function(n,c){return new g(t,e,c).update(n)[r]()}},$t=function(t,e,r){return function(n,c,h,u){return T["cshake"+t].update(n,c,h,u)[r]()}},Lt=function(t,e,r){return function(n,c,h,u){return T["kmac"+t].update(n,c,h,u)[r]()}},I=function(t,e,r,n){for(var c=0;c<A.length;++c){var h=A[c];t[h]=e(r,n,h)}return t},Xt=function(t,e){var r=Yt(t,e,"hex");return r.create=function(){return new g(t,e,t)},r.update=function(n){return r.create().update(n)},I(r,Yt,t,e)},ne=function(t,e){var r=qt(t,e,"hex");return r.create=function(n){return new g(t,e,n)},r.update=function(n,c){return r.create(c).update(n)},I(r,qt,t,e)},oe=function(t,e){var r=K[t],n=$t(t,e,"hex");return n.create=function(c,h,u){return Gt(h)&&Gt(u)?T["shake"+t].create(c):new g(t,e,c).bytepad([h,u],r)},n.update=function(c,h,u,f){return n.create(h,u,f).update(c)},I(n,$t,t,e)},ie=function(t,e){var r=K[t],n=Lt(t,e,"hex");return n.create=function(c,h,u){return new Wt(t,e,h).bytepad(["KMAC",u],r).bytepad([c],r)},n.update=function(c,h,u,f){return n.create(c,u,f).update(h)},I(n,Lt,t,e)},Zt=[{name:"keccak",padding:F,bits:j,createMethod:Xt},{name:"sha3",padding:w,bits:j,createMethod:Xt},{name:"shake",padding:P,bits:C,createMethod:ne},{name:"cshake",padding:k,bits:C,createMethod:oe},{name:"kmac",padding:k,bits:C,createMethod:ie}],T={},N=[],R=0;R<Zt.length;++R)for(var M=Zt[R],V=M.bits,D=0;D<V.length;++D){var zt=M.name+"_"+V[D];if(N.push(zt),T[zt]=M.createMethod(V[D],M.padding),M.name!=="sha3"){var Qt=M.name+V[D];N.push(Qt),T[Qt]=T[zt]}}function g(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}g.prototype.update=function(t){if(this.finalized)throw new Error(o);var e=Vt(t);t=e[0];for(var r=e[1],n=this.blocks,c=this.byteCount,h=t.length,u=this.blockCount,f=0,S=this.s,s,x;f<h;){if(this.reset)for(this.reset=!1,n[0]=this.block,s=1;s<u+1;++s)n[s]=0;if(r)for(s=this.start;f<h&&s<c;++f)x=t.charCodeAt(f),x<128?n[s>>2]|=x<<v[s++&3]:x<2048?(n[s>>2]|=(192|x>>6)<<v[s++&3],n[s>>2]|=(128|x&63)<<v[s++&3]):x<55296||x>=57344?(n[s>>2]|=(224|x>>12)<<v[s++&3],n[s>>2]|=(128|x>>6&63)<<v[s++&3],n[s>>2]|=(128|x&63)<<v[s++&3]):(x=65536+((x&1023)<<10|t.charCodeAt(++f)&1023),n[s>>2]|=(240|x>>18)<<v[s++&3],n[s>>2]|=(128|x>>12&63)<<v[s++&3],n[s>>2]|=(128|x>>6&63)<<v[s++&3],n[s>>2]|=(128|x&63)<<v[s++&3]);else for(s=this.start;f<h&&s<c;++f)n[s>>2]|=t[f]<<v[s++&3];if(this.lastByteIndex=s,s>=c){for(this.start=s-c,this.block=n[u],s=0;s<u;++s)S[s]^=n[s];H(S),this.reset=!0}else this.start=s}return this},g.prototype.encode=function(t,e){var r=t&255,n=1,c=[r];for(t=t>>8,r=t&255;r>0;)c.unshift(r),t=t>>8,r=t&255,++n;return e?c.push(n):c.unshift(n),this.update(c),c.length},g.prototype.encodeString=function(t){var e=Vt(t);t=e[0];var r=e[1],n=0,c=t.length;if(r)for(var h=0;h<t.length;++h){var u=t.charCodeAt(h);u<128?n+=1:u<2048?n+=2:u<55296||u>=57344?n+=3:(u=65536+((u&1023)<<10|t.charCodeAt(++h)&1023),n+=4)}else n=c;return n+=this.encode(n*8),this.update(t),n},g.prototype.bytepad=function(t,e){for(var r=this.encode(e),n=0;n<t.length;++n)r+=this.encodeString(t[n]);var c=(e-r%e)%e,h=[];return h.length=c,this.update(h),this},g.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];H(n)}},g.prototype.toString=g.prototype.hex=function(){this.finalize();for(var t=this.blockCount,e=this.s,r=this.outputBlocks,n=this.extraBytes,c=0,h=0,u="",f;h<r;){for(c=0;c<t&&h<r;++c,++h)f=e[c],u+=d[f>>4&15]+d[f&15]+d[f>>12&15]+d[f>>8&15]+d[f>>20&15]+d[f>>16&15]+d[f>>28&15]+d[f>>24&15];h%t===0&&(e=Jt(e),H(e),c=0)}return n&&(f=e[c],u+=d[f>>4&15]+d[f&15],n>1&&(u+=d[f>>12&15]+d[f>>8&15]),n>2&&(u+=d[f>>20&15]+d[f>>16&15])),u},g.prototype.arrayBuffer=function(){this.finalize();var t=this.blockCount,e=this.s,r=this.outputBlocks,n=this.extraBytes,c=0,h=0,u=this.outputBits>>3,f;n?f=new ArrayBuffer(r+1<<2):f=new ArrayBuffer(u);for(var S=new Uint32Array(f);h<r;){for(c=0;c<t&&h<r;++c,++h)S[h]=e[c];h%t===0&&(e=Jt(e),H(e))}return n&&(S[h]=e[c],f=f.slice(0,u)),f},g.prototype.buffer=g.prototype.arrayBuffer,g.prototype.digest=g.prototype.array=function(){this.finalize();for(var t=this.blockCount,e=this.s,r=this.outputBlocks,n=this.extraBytes,c=0,h=0,u=[],f,S;h<r;){for(c=0;c<t&&h<r;++c,++h)f=h<<2,S=e[c],u[f]=S&255,u[f+1]=S>>8&255,u[f+2]=S>>16&255,u[f+3]=S>>24&255;h%t===0&&(e=Jt(e),H(e))}return n&&(f=h<<2,S=e[c],u[f]=S&255,n>1&&(u[f+1]=S>>8&255),n>2&&(u[f+2]=S>>16&255)),u};function Wt(t,e,r){g.call(this,t,e,r)}Wt.prototype=new g,Wt.prototype.finalize=function(){return this.encode(this.outputBits,!0),g.prototype.finalize.call(this)};var H=function(t){var e,r,n,c,h,u,f,S,s,x,J,z,W,U,m,G,Y,q,$,L,X,Z,Q,tt,et,rt,nt,ot,it,ct,at,ht,ft,lt,ut,st,yt,dt,bt,pt,vt,xt,gt,St,Pt,Bt,kt,At,Ft,wt,_t,jt,Ct,Ot,Et,Tt,Rt,Kt,Mt,Nt,Dt,Ht,It;for(n=0;n<48;n+=2)c=t[0]^t[10]^t[20]^t[30]^t[40],h=t[1]^t[11]^t[21]^t[31]^t[41],u=t[2]^t[12]^t[22]^t[32]^t[42],f=t[3]^t[13]^t[23]^t[33]^t[43],S=t[4]^t[14]^t[24]^t[34]^t[44],s=t[5]^t[15]^t[25]^t[35]^t[45],x=t[6]^t[16]^t[26]^t[36]^t[46],J=t[7]^t[17]^t[27]^t[37]^t[47],z=t[8]^t[18]^t[28]^t[38]^t[48],W=t[9]^t[19]^t[29]^t[39]^t[49],e=z^(u<<1|f>>>31),r=W^(f<<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=c^(S<<1|s>>>31),r=h^(s<<1|S>>>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^(x<<1|J>>>31),r=f^(J<<1|x>>>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=S^(z<<1|W>>>31),r=s^(W<<1|z>>>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=x^(c<<1|h>>>31),r=J^(h<<1|c>>>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,U=t[0],m=t[1],Bt=t[11]<<4|t[10]>>>28,kt=t[10]<<4|t[11]>>>28,ot=t[20]<<3|t[21]>>>29,it=t[21]<<3|t[20]>>>29,Nt=t[31]<<9|t[30]>>>23,Dt=t[30]<<9|t[31]>>>23,xt=t[40]<<18|t[41]>>>14,gt=t[41]<<18|t[40]>>>14,lt=t[2]<<1|t[3]>>>31,ut=t[3]<<1|t[2]>>>31,G=t[13]<<12|t[12]>>>20,Y=t[12]<<12|t[13]>>>20,At=t[22]<<10|t[23]>>>22,Ft=t[23]<<10|t[22]>>>22,ct=t[33]<<13|t[32]>>>19,at=t[32]<<13|t[33]>>>19,Ht=t[42]<<2|t[43]>>>30,It=t[43]<<2|t[42]>>>30,Ot=t[5]<<30|t[4]>>>2,Et=t[4]<<30|t[5]>>>2,st=t[14]<<6|t[15]>>>26,yt=t[15]<<6|t[14]>>>26,q=t[25]<<11|t[24]>>>21,$=t[24]<<11|t[25]>>>21,wt=t[34]<<15|t[35]>>>17,_t=t[35]<<15|t[34]>>>17,ht=t[45]<<29|t[44]>>>3,ft=t[44]<<29|t[45]>>>3,tt=t[6]<<28|t[7]>>>4,et=t[7]<<28|t[6]>>>4,Tt=t[17]<<23|t[16]>>>9,Rt=t[16]<<23|t[17]>>>9,dt=t[26]<<25|t[27]>>>7,bt=t[27]<<25|t[26]>>>7,L=t[36]<<21|t[37]>>>11,X=t[37]<<21|t[36]>>>11,jt=t[47]<<24|t[46]>>>8,Ct=t[46]<<24|t[47]>>>8,St=t[8]<<27|t[9]>>>5,Pt=t[9]<<27|t[8]>>>5,rt=t[18]<<20|t[19]>>>12,nt=t[19]<<20|t[18]>>>12,Kt=t[29]<<7|t[28]>>>25,Mt=t[28]<<7|t[29]>>>25,pt=t[38]<<8|t[39]>>>24,vt=t[39]<<8|t[38]>>>24,Z=t[48]<<14|t[49]>>>18,Q=t[49]<<14|t[48]>>>18,t[0]=U^~G&q,t[1]=m^~Y&$,t[10]=tt^~rt&ot,t[11]=et^~nt&it,t[20]=lt^~st&dt,t[21]=ut^~yt&bt,t[30]=St^~Bt&At,t[31]=Pt^~kt&Ft,t[40]=Ot^~Tt&Kt,t[41]=Et^~Rt&Mt,t[2]=G^~q&L,t[3]=Y^~$&X,t[12]=rt^~ot&ct,t[13]=nt^~it&at,t[22]=st^~dt&pt,t[23]=yt^~bt&vt,t[32]=Bt^~At&wt,t[33]=kt^~Ft&_t,t[42]=Tt^~Kt&Nt,t[43]=Rt^~Mt&Dt,t[4]=q^~L&Z,t[5]=$^~X&Q,t[14]=ot^~ct&ht,t[15]=it^~at&ft,t[24]=dt^~pt&xt,t[25]=bt^~vt>,t[34]=At^~wt&jt,t[35]=Ft^~_t&Ct,t[44]=Kt^~Nt&Ht,t[45]=Mt^~Dt&It,t[6]=L^~Z&U,t[7]=X^~Q&m,t[16]=ct^~ht&tt,t[17]=at^~ft&et,t[26]=pt^~xt<,t[27]=vt^~gt&ut,t[36]=wt^~jt&St,t[37]=_t^~Ct&Pt,t[46]=Nt^~Ht&Ot,t[47]=Dt^~It&Et,t[8]=Z^~U&G,t[9]=Q^~m&Y,t[18]=ht^~tt&rt,t[19]=ft^~et&nt,t[28]=xt^~lt&st,t[29]=gt^~ut&yt,t[38]=jt^~St&Bt,t[39]=Ct^~Pt&kt,t[48]=Ht^~Ot&Tt,t[49]=It^~Et&Rt,t[0]^=_[n],t[1]^=_[n+1]};if(B)E.exports=T;else for(R=0;R<N.length;++R)a[N[R]]=T[N[R]]})()})(Ut)),Ut.exports}var fe=he();const le=ae(fe),{keccak256:O}=le;class mt{constructor(i,o){this.payload={},this.declarations=[],this.secrets={},this.branchVersions={},this.username=i,this.secret=o,this.identityRoot="0x"+O(o),this.publicKey="0x"+O("public:"+o),this.identityHash="0x"+O(this.publicKey+this.username),this.secrets[""]=o;const l=this.createProxy([]);return Object.setPrototypeOf(l,mt.prototype),Object.assign(l,this),l}createProxy(i){const o=this,l=(...a)=>o.handleCall(i,a);return new Proxy(l,{get(a,y){if(typeof y=="symbol")return a[y];if(y==="secret")return o.createProxy([...i,String(y)]);if(y in o)return o[y];const b=[...i,String(y)];return o.createProxy(b)},apply(a,y,b){return o.handleCall(i,b)}})}handleCall(i,o){if(i.length===0){if(o.length===1&&typeof o[0]=="string"){const p=o[0].split(".").filter(Boolean);return this.exportBranch(p.join("."))}return this.createProxy([])}const l=i[i.length-1];if(l==="secret"){const p=i.slice(0,-1),d=p.join("."),P=String(o[0]??"");if(!P)return this.createProxy(p);this.secrets[d]=P;const k="0x"+O(this.secret+d+"::secret-set");return this.declarations.push({key:d+".secret",value:"<secret-set>",signature:k,timestamp:Date.now()}),this.createProxy(p)}if(l==="ptr")return{__ptr:i.slice(0,-1).join(".")};const a=i.join(".");let y;o.length===0?y=void 0:o.length===1?y=o[0]:y=o,this.ensurePath(i,y);const b=this.resolveSecret(i),B="0x"+O(b+a+JSON.stringify(y));return this.declarations.push({key:a,value:y,signature:B,timestamp:Date.now()}),this.createProxy(i)}resolveSecretWithPath(i){for(let o=i.length;o>=0;o--){const l=i.slice(0,o).join(".");if(this.secrets[l])return{secret:this.secrets[l],secretPath:i.slice(0,o)}}return{secret:this.secret,secretPath:[]}}resolveSecret(i){return this.resolveSecretWithPath(i).secret}ensurePath(i,o){const{secret:l,secretPath:a}=this.resolveSecretWithPath(i),y=a.join("."),b=O(l);if(a.length>0){let k={};const F=this.branchVersions[y]?.[b],w=this.getSubPayload(a);if(F){const A=this.decryptForPath(a,F);A&&typeof A=="object"&&(k=A)}else if(typeof w=="string"){const A=this.decryptForPath(a,w);A&&typeof A=="object"&&(k=A)}else w&&typeof w=="object"&&(k=w);const v=i.slice(a.length);let _=k;for(let A=0;A<v.length-1;A++){const K=v[A];(!_[K]||typeof _[K]!="object")&&(_[K]={}),_=_[K]}const j=v[v.length-1];_[j]=o;const C=this.encryptForPath(a,k);this.branchVersions[y]||(this.branchVersions[y]={}),this.branchVersions[y][b]=C,this.writeBranchBlob(a,C);return}const p=this.encryptForPath(i,o);let d=this.payload;for(let k=0;k<i.length-1;k++){const F=i[k];(!d[F]||typeof d[F]!="object")&&(d[F]={}),d=d[F]}const P=i[i.length-1];d[P]=p}setSubPayload(i,o){if(i.length===0){this.payload=o;return}let l=this.payload;for(let y=0;y<i.length-1;y++){const b=i[y];(!l[b]||typeof l[b]!="object")&&(l[b]={}),l=l[b]}const a=i[i.length-1];l[a]=o}findNearestBranchAncestor(i){for(let o=i.length-1;o>=1;o--){const l=i.slice(0,o),a=l.join(".");if(this.branchVersions[a])return{path:l,secret:this.resolveSecret(l)}}return null}writeBranchBlob(i,o){let l=i,a=o;for(;;){const y=this.findNearestBranchAncestor(l);if(!y){this.setSubPayload(l,a);return}const{path:b,secret:B}=y,p=b.join("."),d=O(B),P=this.getSubPayload(b),k=this.branchVersions[p]?.[d]??(typeof P=="string"?P:void 0);let F={};if(k){const j=this.decryptForPath(b,k);j&&typeof j=="object"&&(F=j)}const w=l.slice(b.length);let v=F;for(let j=0;j<w.length-1;j++){const C=w[j];(!v[C]||typeof v[C]!="object")&&(v[C]={}),v=v[C]}v[w[w.length-1]]=a;const _=this.encryptForPath(b,F);this.branchVersions[p]||(this.branchVersions[p]={}),this.branchVersions[p][d]=_,l=b,a=_}}getSubPayload(i){let o=this.payload;for(const l of i){if(!o||typeof o!="object")return;o=o[l]}return o}decryptTree(i,o){if(o==null)return o;if(typeof o=="string"){if(!this.isHexString(o))return o;const a=this.decryptForPath(i,o);return a===null?o:a}if(typeof o!="object")return o;const l=Array.isArray(o)?[]:{};for(const a of Object.keys(o)){const y=[...i,a];l[a]=this.decryptTree(y,o[a])}return l}encryptForPath(i,o){const l=this.resolveSecret(i),a=JSON.stringify(o),y=new TextEncoder().encode(a),b=O(l+":"+i.join(".")),B=this.asciiToBytes(b),p=new Uint8Array(y.length);for(let P=0;P<y.length;P++)p[P]=y[P]^B[P%B.length];let d="";for(let P=0;P<p.length;P++)d+=p[P].toString(16).padStart(2,"0");return d}decryptForPath(i,o){const l=this.resolveSecret(i);try{const a=this.hexToBytes(o),y=O(l+":"+i.join(".")),b=this.asciiToBytes(y),B=new Uint8Array(a.length);for(let d=0;d<a.length;d++)B[d]=a[d]^b[d%b.length];const p=new TextDecoder().decode(B);return JSON.parse(p)}catch{return null}}asciiToBytes(i){return new TextEncoder().encode(i)}hexToBytes(i){const o=i.startsWith("0x")?i.slice(2):i,l=new Uint8Array(o.length/2);for(let a=0;a<l.length;a++)l[a]=parseInt(o.substr(a*2,2),16);return l}isHexString(i){const o=i.startsWith("0x")?i.slice(2):i;return o.length>0&&o.length%2===0&&/^[0-9a-fA-F]+$/.test(o)}export(){return{identityRoot:this.identityRoot,publicKey:this.publicKey,identityHash:this.identityHash,declarations:this.declarations,payload:this.payload}}exportBranch(i){const o=i?i.split(".").filter(Boolean):[],l=o.join("."),a=this.resolveSecret(o),y=O(a),b=this.branchVersions[l]?.[y];if(b){const p=this.decryptForPath(o,b);return this.decryptTree(o,p)}const B=this.getSubPayload(o);if(B!==void 0){if(typeof B=="string"){const p=this.decryptForPath(o,B);return this.decryptTree(o,p)}return this.decryptTree(o,B)}}}exports.ME=mt;
|
|
8
|
+
*/var te;function he(){return te||(te=1,(function(E){(function(){var i="input is invalid type",o="finalize already called",l=typeof window=="object",c=l?window:{};c.JS_SHA3_NO_WINDOW&&(l=!1);var y=!l&&typeof self=="object",b=!c.JS_SHA3_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;b?c=ce:y&&(c=self);for(var B=!c.JS_SHA3_NO_COMMON_JS&&!0&&E.exports,p=!c.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",d="0123456789abcdef".split(""),P=[31,7936,2031616,520093696],k=[4,1024,262144,67108864],F=[1,256,65536,16777216],w=[6,1536,393216,100663296],v=[0,8,16,24],_=[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],j=[224,256,384,512],C=[128,256],A=["hex","buffer","arrayBuffer","array","digest"],K={128:168,256:136},ee=c.JS_SHA3_NO_NODE_JS||!Array.isArray?function(t){return Object.prototype.toString.call(t)==="[object Array]"}:Array.isArray,re=p&&(c.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)?function(t){return typeof t=="object"&&t.buffer&&t.buffer.constructor===ArrayBuffer}:ArrayBuffer.isView,Vt=function(t){var e=typeof t;if(e==="string")return[t,!0];if(e!=="object"||t===null)throw new Error(i);if(p&&t.constructor===ArrayBuffer)return[new Uint8Array(t),!1];if(!ee(t)&&!re(t))throw new Error(i);return[t,!1]},Gt=function(t){return Vt(t)[0].length===0},Jt=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 g(t,e,t).update(n)[r]()}},qt=function(t,e,r){return function(n,a){return new g(t,e,a).update(n)[r]()}},$t=function(t,e,r){return function(n,a,h,u){return T["cshake"+t].update(n,a,h,u)[r]()}},Lt=function(t,e,r){return function(n,a,h,u){return T["kmac"+t].update(n,a,h,u)[r]()}},I=function(t,e,r,n){for(var a=0;a<A.length;++a){var h=A[a];t[h]=e(r,n,h)}return t},Xt=function(t,e){var r=Yt(t,e,"hex");return r.create=function(){return new g(t,e,t)},r.update=function(n){return r.create().update(n)},I(r,Yt,t,e)},ne=function(t,e){var r=qt(t,e,"hex");return r.create=function(n){return new g(t,e,n)},r.update=function(n,a){return r.create(a).update(n)},I(r,qt,t,e)},oe=function(t,e){var r=K[t],n=$t(t,e,"hex");return n.create=function(a,h,u){return Gt(h)&&Gt(u)?T["shake"+t].create(a):new g(t,e,a).bytepad([h,u],r)},n.update=function(a,h,u,f){return n.create(h,u,f).update(a)},I(n,$t,t,e)},ie=function(t,e){var r=K[t],n=Lt(t,e,"hex");return n.create=function(a,h,u){return new Wt(t,e,h).bytepad(["KMAC",u],r).bytepad([a],r)},n.update=function(a,h,u,f){return n.create(a,u,f).update(h)},I(n,Lt,t,e)},Zt=[{name:"keccak",padding:F,bits:j,createMethod:Xt},{name:"sha3",padding:w,bits:j,createMethod:Xt},{name:"shake",padding:P,bits:C,createMethod:ne},{name:"cshake",padding:k,bits:C,createMethod:oe},{name:"kmac",padding:k,bits:C,createMethod:ie}],T={},N=[],R=0;R<Zt.length;++R)for(var M=Zt[R],V=M.bits,D=0;D<V.length;++D){var zt=M.name+"_"+V[D];if(N.push(zt),T[zt]=M.createMethod(V[D],M.padding),M.name!=="sha3"){var Qt=M.name+V[D];N.push(Qt),T[Qt]=T[zt]}}function g(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}g.prototype.update=function(t){if(this.finalized)throw new Error(o);var e=Vt(t);t=e[0];for(var r=e[1],n=this.blocks,a=this.byteCount,h=t.length,u=this.blockCount,f=0,S=this.s,s,x;f<h;){if(this.reset)for(this.reset=!1,n[0]=this.block,s=1;s<u+1;++s)n[s]=0;if(r)for(s=this.start;f<h&&s<a;++f)x=t.charCodeAt(f),x<128?n[s>>2]|=x<<v[s++&3]:x<2048?(n[s>>2]|=(192|x>>6)<<v[s++&3],n[s>>2]|=(128|x&63)<<v[s++&3]):x<55296||x>=57344?(n[s>>2]|=(224|x>>12)<<v[s++&3],n[s>>2]|=(128|x>>6&63)<<v[s++&3],n[s>>2]|=(128|x&63)<<v[s++&3]):(x=65536+((x&1023)<<10|t.charCodeAt(++f)&1023),n[s>>2]|=(240|x>>18)<<v[s++&3],n[s>>2]|=(128|x>>12&63)<<v[s++&3],n[s>>2]|=(128|x>>6&63)<<v[s++&3],n[s>>2]|=(128|x&63)<<v[s++&3]);else for(s=this.start;f<h&&s<a;++f)n[s>>2]|=t[f]<<v[s++&3];if(this.lastByteIndex=s,s>=a){for(this.start=s-a,this.block=n[u],s=0;s<u;++s)S[s]^=n[s];H(S),this.reset=!0}else this.start=s}return this},g.prototype.encode=function(t,e){var r=t&255,n=1,a=[r];for(t=t>>8,r=t&255;r>0;)a.unshift(r),t=t>>8,r=t&255,++n;return e?a.push(n):a.unshift(n),this.update(a),a.length},g.prototype.encodeString=function(t){var e=Vt(t);t=e[0];var r=e[1],n=0,a=t.length;if(r)for(var h=0;h<t.length;++h){var u=t.charCodeAt(h);u<128?n+=1:u<2048?n+=2:u<55296||u>=57344?n+=3:(u=65536+((u&1023)<<10|t.charCodeAt(++h)&1023),n+=4)}else n=a;return n+=this.encode(n*8),this.update(t),n},g.prototype.bytepad=function(t,e){for(var r=this.encode(e),n=0;n<t.length;++n)r+=this.encodeString(t[n]);var a=(e-r%e)%e,h=[];return h.length=a,this.update(h),this},g.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];H(n)}},g.prototype.toString=g.prototype.hex=function(){this.finalize();for(var t=this.blockCount,e=this.s,r=this.outputBlocks,n=this.extraBytes,a=0,h=0,u="",f;h<r;){for(a=0;a<t&&h<r;++a,++h)f=e[a],u+=d[f>>4&15]+d[f&15]+d[f>>12&15]+d[f>>8&15]+d[f>>20&15]+d[f>>16&15]+d[f>>28&15]+d[f>>24&15];h%t===0&&(e=Jt(e),H(e),a=0)}return n&&(f=e[a],u+=d[f>>4&15]+d[f&15],n>1&&(u+=d[f>>12&15]+d[f>>8&15]),n>2&&(u+=d[f>>20&15]+d[f>>16&15])),u},g.prototype.arrayBuffer=function(){this.finalize();var t=this.blockCount,e=this.s,r=this.outputBlocks,n=this.extraBytes,a=0,h=0,u=this.outputBits>>3,f;n?f=new ArrayBuffer(r+1<<2):f=new ArrayBuffer(u);for(var S=new Uint32Array(f);h<r;){for(a=0;a<t&&h<r;++a,++h)S[h]=e[a];h%t===0&&(e=Jt(e),H(e))}return n&&(S[h]=e[a],f=f.slice(0,u)),f},g.prototype.buffer=g.prototype.arrayBuffer,g.prototype.digest=g.prototype.array=function(){this.finalize();for(var t=this.blockCount,e=this.s,r=this.outputBlocks,n=this.extraBytes,a=0,h=0,u=[],f,S;h<r;){for(a=0;a<t&&h<r;++a,++h)f=h<<2,S=e[a],u[f]=S&255,u[f+1]=S>>8&255,u[f+2]=S>>16&255,u[f+3]=S>>24&255;h%t===0&&(e=Jt(e),H(e))}return n&&(f=h<<2,S=e[a],u[f]=S&255,n>1&&(u[f+1]=S>>8&255),n>2&&(u[f+2]=S>>16&255)),u};function Wt(t,e,r){g.call(this,t,e,r)}Wt.prototype=new g,Wt.prototype.finalize=function(){return this.encode(this.outputBits,!0),g.prototype.finalize.call(this)};var H=function(t){var e,r,n,a,h,u,f,S,s,x,J,z,W,U,m,G,Y,q,$,L,X,Z,Q,tt,et,rt,nt,ot,it,ct,at,ht,ft,lt,ut,st,yt,dt,bt,pt,vt,xt,gt,St,Pt,Bt,kt,At,Ft,wt,_t,jt,Ct,Ot,Et,Tt,Rt,Kt,Mt,Nt,Dt,Ht,It;for(n=0;n<48;n+=2)a=t[0]^t[10]^t[20]^t[30]^t[40],h=t[1]^t[11]^t[21]^t[31]^t[41],u=t[2]^t[12]^t[22]^t[32]^t[42],f=t[3]^t[13]^t[23]^t[33]^t[43],S=t[4]^t[14]^t[24]^t[34]^t[44],s=t[5]^t[15]^t[25]^t[35]^t[45],x=t[6]^t[16]^t[26]^t[36]^t[46],J=t[7]^t[17]^t[27]^t[37]^t[47],z=t[8]^t[18]^t[28]^t[38]^t[48],W=t[9]^t[19]^t[29]^t[39]^t[49],e=z^(u<<1|f>>>31),r=W^(f<<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=a^(S<<1|s>>>31),r=h^(s<<1|S>>>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^(x<<1|J>>>31),r=f^(J<<1|x>>>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=S^(z<<1|W>>>31),r=s^(W<<1|z>>>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=x^(a<<1|h>>>31),r=J^(h<<1|a>>>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,U=t[0],m=t[1],Bt=t[11]<<4|t[10]>>>28,kt=t[10]<<4|t[11]>>>28,ot=t[20]<<3|t[21]>>>29,it=t[21]<<3|t[20]>>>29,Nt=t[31]<<9|t[30]>>>23,Dt=t[30]<<9|t[31]>>>23,xt=t[40]<<18|t[41]>>>14,gt=t[41]<<18|t[40]>>>14,lt=t[2]<<1|t[3]>>>31,ut=t[3]<<1|t[2]>>>31,G=t[13]<<12|t[12]>>>20,Y=t[12]<<12|t[13]>>>20,At=t[22]<<10|t[23]>>>22,Ft=t[23]<<10|t[22]>>>22,ct=t[33]<<13|t[32]>>>19,at=t[32]<<13|t[33]>>>19,Ht=t[42]<<2|t[43]>>>30,It=t[43]<<2|t[42]>>>30,Ot=t[5]<<30|t[4]>>>2,Et=t[4]<<30|t[5]>>>2,st=t[14]<<6|t[15]>>>26,yt=t[15]<<6|t[14]>>>26,q=t[25]<<11|t[24]>>>21,$=t[24]<<11|t[25]>>>21,wt=t[34]<<15|t[35]>>>17,_t=t[35]<<15|t[34]>>>17,ht=t[45]<<29|t[44]>>>3,ft=t[44]<<29|t[45]>>>3,tt=t[6]<<28|t[7]>>>4,et=t[7]<<28|t[6]>>>4,Tt=t[17]<<23|t[16]>>>9,Rt=t[16]<<23|t[17]>>>9,dt=t[26]<<25|t[27]>>>7,bt=t[27]<<25|t[26]>>>7,L=t[36]<<21|t[37]>>>11,X=t[37]<<21|t[36]>>>11,jt=t[47]<<24|t[46]>>>8,Ct=t[46]<<24|t[47]>>>8,St=t[8]<<27|t[9]>>>5,Pt=t[9]<<27|t[8]>>>5,rt=t[18]<<20|t[19]>>>12,nt=t[19]<<20|t[18]>>>12,Kt=t[29]<<7|t[28]>>>25,Mt=t[28]<<7|t[29]>>>25,pt=t[38]<<8|t[39]>>>24,vt=t[39]<<8|t[38]>>>24,Z=t[48]<<14|t[49]>>>18,Q=t[49]<<14|t[48]>>>18,t[0]=U^~G&q,t[1]=m^~Y&$,t[10]=tt^~rt&ot,t[11]=et^~nt&it,t[20]=lt^~st&dt,t[21]=ut^~yt&bt,t[30]=St^~Bt&At,t[31]=Pt^~kt&Ft,t[40]=Ot^~Tt&Kt,t[41]=Et^~Rt&Mt,t[2]=G^~q&L,t[3]=Y^~$&X,t[12]=rt^~ot&ct,t[13]=nt^~it&at,t[22]=st^~dt&pt,t[23]=yt^~bt&vt,t[32]=Bt^~At&wt,t[33]=kt^~Ft&_t,t[42]=Tt^~Kt&Nt,t[43]=Rt^~Mt&Dt,t[4]=q^~L&Z,t[5]=$^~X&Q,t[14]=ot^~ct&ht,t[15]=it^~at&ft,t[24]=dt^~pt&xt,t[25]=bt^~vt>,t[34]=At^~wt&jt,t[35]=Ft^~_t&Ct,t[44]=Kt^~Nt&Ht,t[45]=Mt^~Dt&It,t[6]=L^~Z&U,t[7]=X^~Q&m,t[16]=ct^~ht&tt,t[17]=at^~ft&et,t[26]=pt^~xt<,t[27]=vt^~gt&ut,t[36]=wt^~jt&St,t[37]=_t^~Ct&Pt,t[46]=Nt^~Ht&Ot,t[47]=Dt^~It&Et,t[8]=Z^~U&G,t[9]=Q^~m&Y,t[18]=ht^~tt&rt,t[19]=ft^~et&nt,t[28]=xt^~lt&st,t[29]=gt^~ut&yt,t[38]=jt^~St&Bt,t[39]=Ct^~Pt&kt,t[48]=Ht^~Ot&Tt,t[49]=It^~Et&Rt,t[0]^=_[n],t[1]^=_[n+1]};if(B)E.exports=T;else for(R=0;R<N.length;++R)c[N[R]]=T[N[R]]})()})(Ut)),Ut.exports}var fe=he();const le=ae(fe),{keccak256:O}=le;class mt{constructor(i,o,l){this.payload={},this.declarations=[],this.secrets={},this.branchVersions={},this.username=i,this.secret=o,this.blockchain=l,this.identityRoot="0x"+O(o),this.publicKey="0x"+O("public:"+o),this.identityHash="0x"+O(this.publicKey+this.username),this.secrets[""]=o;const c=this.createProxy([]);return Object.setPrototypeOf(c,mt.prototype),Object.assign(c,this),c}createProxy(i){const o=this,l=(...c)=>o.handleCall(i,c);return new Proxy(l,{get(c,y){if(typeof y=="symbol")return c[y];if(y==="secret")return o.createProxy([...i,String(y)]);if(y in o)return o[y];const b=[...i,String(y)];return o.createProxy(b)},apply(c,y,b){return o.handleCall(i,b)}})}handleCall(i,o){if(i.length===0){if(o.length===1&&typeof o[0]=="string"){const p=o[0].split(".").filter(Boolean);return this.exportBranch(p.join("."))}return this.createProxy([])}const l=i[i.length-1];if(l==="secret"){const p=i.slice(0,-1),d=p.join("."),P=String(o[0]??"");if(!P)return this.createProxy(p);this.secrets[d]=P;const k="0x"+O(this.secret+d+"::secret-set");return this.declarations.push({key:d+".secret",value:"<secret-set>",signature:k,timestamp:Date.now()}),this.createProxy(p)}if(l==="ptr")return{__ptr:i.slice(0,-1).join(".")};const c=i.join(".");let y;o.length===0?y=void 0:o.length===1?y=o[0]:y=o,this.ensurePath(i,y);const b=this.resolveSecret(i),B="0x"+O(b+c+JSON.stringify(y));return this.declarations.push({key:c,value:y,signature:B,timestamp:Date.now()}),this.createProxy(i)}resolveSecretWithPath(i){for(let o=i.length;o>=0;o--){const l=i.slice(0,o).join(".");if(this.secrets[l])return{secret:this.secrets[l],secretPath:i.slice(0,o)}}return{secret:this.secret,secretPath:[]}}resolveSecret(i){return this.resolveSecretWithPath(i).secret}ensurePath(i,o){const{secret:l,secretPath:c}=this.resolveSecretWithPath(i),y=c.join("."),b=O(l);if(c.length>0){let k={};const F=this.branchVersions[y]?.[b],w=this.getSubPayload(c);if(F){const A=this.decryptForPath(c,F);A&&typeof A=="object"&&(k=A)}else if(typeof w=="string"){const A=this.decryptForPath(c,w);A&&typeof A=="object"&&(k=A)}else w&&typeof w=="object"&&(k=w);const v=i.slice(c.length);let _=k;for(let A=0;A<v.length-1;A++){const K=v[A];(!_[K]||typeof _[K]!="object")&&(_[K]={}),_=_[K]}const j=v[v.length-1];_[j]=o;const C=this.encryptForPath(c,k);this.branchVersions[y]||(this.branchVersions[y]={}),this.branchVersions[y][b]=C,this.writeBranchBlob(c,C);return}const p=this.encryptForPath(i,o);let d=this.payload;for(let k=0;k<i.length-1;k++){const F=i[k];(!d[F]||typeof d[F]!="object")&&(d[F]={}),d=d[F]}const P=i[i.length-1];d[P]=p}setSubPayload(i,o){if(i.length===0){this.payload=o;return}let l=this.payload;for(let y=0;y<i.length-1;y++){const b=i[y];(!l[b]||typeof l[b]!="object")&&(l[b]={}),l=l[b]}const c=i[i.length-1];l[c]=o}findNearestBranchAncestor(i){for(let o=i.length-1;o>=1;o--){const l=i.slice(0,o),c=l.join(".");if(this.branchVersions[c])return{path:l,secret:this.resolveSecret(l)}}return null}writeBranchBlob(i,o){let l=i,c=o;for(;;){const y=this.findNearestBranchAncestor(l);if(!y){this.setSubPayload(l,c);return}const{path:b,secret:B}=y,p=b.join("."),d=O(B),P=this.getSubPayload(b),k=this.branchVersions[p]?.[d]??(typeof P=="string"?P:void 0);let F={};if(k){const j=this.decryptForPath(b,k);j&&typeof j=="object"&&(F=j)}const w=l.slice(b.length);let v=F;for(let j=0;j<w.length-1;j++){const C=w[j];(!v[C]||typeof v[C]!="object")&&(v[C]={}),v=v[C]}v[w[w.length-1]]=c;const _=this.encryptForPath(b,F);this.branchVersions[p]||(this.branchVersions[p]={}),this.branchVersions[p][d]=_,l=b,c=_}}getSubPayload(i){let o=this.payload;for(const l of i){if(!o||typeof o!="object")return;o=o[l]}return o}decryptTree(i,o){if(o==null)return o;if(typeof o=="string"){if(!this.isHexString(o))return o;const c=this.decryptForPath(i,o);return c===null?o:c}if(typeof o!="object")return o;const l=Array.isArray(o)?[]:{};for(const c of Object.keys(o)){const y=[...i,c];l[c]=this.decryptTree(y,o[c])}return l}encryptForPath(i,o){const l=this.resolveSecret(i),c=JSON.stringify(o),y=new TextEncoder().encode(c),b=O(l+":"+i.join(".")),B=this.asciiToBytes(b),p=new Uint8Array(y.length);for(let P=0;P<y.length;P++)p[P]=y[P]^B[P%B.length];let d="";for(let P=0;P<p.length;P++)d+=p[P].toString(16).padStart(2,"0");return d}decryptForPath(i,o){const l=this.resolveSecret(i);try{const c=this.hexToBytes(o),y=O(l+":"+i.join(".")),b=this.asciiToBytes(y),B=new Uint8Array(c.length);for(let d=0;d<c.length;d++)B[d]=c[d]^b[d%b.length];const p=new TextDecoder().decode(B);return JSON.parse(p)}catch{return null}}asciiToBytes(i){return new TextEncoder().encode(i)}hexToBytes(i){const o=i.startsWith("0x")?i.slice(2):i,l=new Uint8Array(o.length/2);for(let c=0;c<l.length;c++)l[c]=parseInt(o.substr(c*2,2),16);return l}isHexString(i){const o=i.startsWith("0x")?i.slice(2):i;return o.length>0&&o.length%2===0&&/^[0-9a-fA-F]+$/.test(o)}export(){return{identityRoot:this.identityRoot,publicKey:this.publicKey,identityHash:this.identityHash,declarations:this.declarations,payload:this.payload}}exportBranch(i){const o=i?i.split(".").filter(Boolean):[],l=o.join("."),c=this.resolveSecret(o),y=O(c),b=this.branchVersions[l]?.[y];if(b){const p=this.decryptForPath(o,b);return this.decryptTree(o,p)}const B=this.getSubPayload(o);if(B!==void 0){if(typeof B=="string"){const p=this.decryptForPath(o,B);return this.decryptTree(o,p)}return this.decryptTree(o,B)}}}exports.ME=mt;
|
package/dist/me.es.js
CHANGED
|
@@ -15,11 +15,11 @@ var Qt;
|
|
|
15
15
|
function he() {
|
|
16
16
|
return Qt || (Qt = 1, (function(E) {
|
|
17
17
|
(function() {
|
|
18
|
-
var i = "input is invalid type", o = "finalize already called", l = typeof window == "object",
|
|
19
|
-
|
|
20
|
-
var y = !l && typeof self == "object", b = !
|
|
21
|
-
b ?
|
|
22
|
-
for (var P = !
|
|
18
|
+
var i = "input is invalid type", o = "finalize already called", l = typeof window == "object", c = l ? window : {};
|
|
19
|
+
c.JS_SHA3_NO_WINDOW && (l = !1);
|
|
20
|
+
var y = !l && typeof self == "object", b = !c.JS_SHA3_NO_NODE_JS && typeof process == "object" && process.versions && process.versions.node;
|
|
21
|
+
b ? c = ce : y && (c = self);
|
|
22
|
+
for (var P = !c.JS_SHA3_NO_COMMON_JS && !0 && E.exports, p = !c.JS_SHA3_NO_ARRAY_BUFFER && typeof ArrayBuffer < "u", d = "0123456789abcdef".split(""), B = [31, 7936, 2031616, 520093696], k = [4, 1024, 262144, 67108864], F = [1, 256, 65536, 16777216], w = [6, 1536, 393216, 100663296], v = [0, 8, 16, 24], _ = [
|
|
23
23
|
1,
|
|
24
24
|
0,
|
|
25
25
|
32898,
|
|
@@ -71,9 +71,9 @@ function he() {
|
|
|
71
71
|
], j = [224, 256, 384, 512], C = [128, 256], A = ["hex", "buffer", "arrayBuffer", "array", "digest"], K = {
|
|
72
72
|
128: 168,
|
|
73
73
|
256: 136
|
|
74
|
-
}, ee =
|
|
74
|
+
}, ee = c.JS_SHA3_NO_NODE_JS || !Array.isArray ? function(t) {
|
|
75
75
|
return Object.prototype.toString.call(t) === "[object Array]";
|
|
76
|
-
} : Array.isArray, re = p && (
|
|
76
|
+
} : Array.isArray, re = p && (c.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView) ? function(t) {
|
|
77
77
|
return typeof t == "object" && t.buffer && t.buffer.constructor === ArrayBuffer;
|
|
78
78
|
} : ArrayBuffer.isView, Vt = function(t) {
|
|
79
79
|
var e = typeof t;
|
|
@@ -97,20 +97,20 @@ function he() {
|
|
|
97
97
|
return new g(t, e, t).update(n)[r]();
|
|
98
98
|
};
|
|
99
99
|
}, Yt = function(t, e, r) {
|
|
100
|
-
return function(n,
|
|
101
|
-
return new g(t, e,
|
|
100
|
+
return function(n, a) {
|
|
101
|
+
return new g(t, e, a).update(n)[r]();
|
|
102
102
|
};
|
|
103
103
|
}, qt = function(t, e, r) {
|
|
104
|
-
return function(n,
|
|
105
|
-
return T["cshake" + t].update(n,
|
|
104
|
+
return function(n, a, h, u) {
|
|
105
|
+
return T["cshake" + t].update(n, a, h, u)[r]();
|
|
106
106
|
};
|
|
107
107
|
}, $t = function(t, e, r) {
|
|
108
|
-
return function(n,
|
|
109
|
-
return T["kmac" + t].update(n,
|
|
108
|
+
return function(n, a, h, u) {
|
|
109
|
+
return T["kmac" + t].update(n, a, h, u)[r]();
|
|
110
110
|
};
|
|
111
111
|
}, I = function(t, e, r, n) {
|
|
112
|
-
for (var
|
|
113
|
-
var h = A[
|
|
112
|
+
for (var a = 0; a < A.length; ++a) {
|
|
113
|
+
var h = A[a];
|
|
114
114
|
t[h] = e(r, n, h);
|
|
115
115
|
}
|
|
116
116
|
return t;
|
|
@@ -125,22 +125,22 @@ function he() {
|
|
|
125
125
|
var r = Yt(t, e, "hex");
|
|
126
126
|
return r.create = function(n) {
|
|
127
127
|
return new g(t, e, n);
|
|
128
|
-
}, r.update = function(n,
|
|
129
|
-
return r.create(
|
|
128
|
+
}, r.update = function(n, a) {
|
|
129
|
+
return r.create(a).update(n);
|
|
130
130
|
}, I(r, Yt, t, e);
|
|
131
131
|
}, oe = function(t, e) {
|
|
132
132
|
var r = K[t], n = qt(t, e, "hex");
|
|
133
|
-
return n.create = function(
|
|
134
|
-
return mt(h) && mt(u) ? T["shake" + t].create(
|
|
135
|
-
}, n.update = function(
|
|
136
|
-
return n.create(h, u, f).update(
|
|
133
|
+
return n.create = function(a, h, u) {
|
|
134
|
+
return mt(h) && mt(u) ? T["shake" + t].create(a) : new g(t, e, a).bytepad([h, u], r);
|
|
135
|
+
}, n.update = function(a, h, u, f) {
|
|
136
|
+
return n.create(h, u, f).update(a);
|
|
137
137
|
}, I(n, qt, t, e);
|
|
138
138
|
}, ie = function(t, e) {
|
|
139
139
|
var r = K[t], n = $t(t, e, "hex");
|
|
140
|
-
return n.create = function(
|
|
141
|
-
return new Wt(t, e, h).bytepad(["KMAC", u], r).bytepad([
|
|
142
|
-
}, n.update = function(
|
|
143
|
-
return n.create(
|
|
140
|
+
return n.create = function(a, h, u) {
|
|
141
|
+
return new Wt(t, e, h).bytepad(["KMAC", u], r).bytepad([a], r);
|
|
142
|
+
}, n.update = function(a, h, u, f) {
|
|
143
|
+
return n.create(a, u, f).update(h);
|
|
144
144
|
}, I(n, $t, t, e);
|
|
145
145
|
}, Xt = [
|
|
146
146
|
{ name: "keccak", padding: F, bits: j, createMethod: Lt },
|
|
@@ -166,18 +166,18 @@ function he() {
|
|
|
166
166
|
throw new Error(o);
|
|
167
167
|
var e = Vt(t);
|
|
168
168
|
t = e[0];
|
|
169
|
-
for (var r = e[1], n = this.blocks,
|
|
169
|
+
for (var r = e[1], n = this.blocks, a = this.byteCount, h = t.length, u = this.blockCount, f = 0, S = this.s, s, x; f < h; ) {
|
|
170
170
|
if (this.reset)
|
|
171
171
|
for (this.reset = !1, n[0] = this.block, s = 1; s < u + 1; ++s)
|
|
172
172
|
n[s] = 0;
|
|
173
173
|
if (r)
|
|
174
|
-
for (s = this.start; f < h && s <
|
|
174
|
+
for (s = this.start; f < h && s < a; ++f)
|
|
175
175
|
x = t.charCodeAt(f), x < 128 ? n[s >> 2] |= x << v[s++ & 3] : x < 2048 ? (n[s >> 2] |= (192 | x >> 6) << v[s++ & 3], n[s >> 2] |= (128 | x & 63) << v[s++ & 3]) : x < 55296 || x >= 57344 ? (n[s >> 2] |= (224 | x >> 12) << v[s++ & 3], n[s >> 2] |= (128 | x >> 6 & 63) << v[s++ & 3], n[s >> 2] |= (128 | x & 63) << v[s++ & 3]) : (x = 65536 + ((x & 1023) << 10 | t.charCodeAt(++f) & 1023), n[s >> 2] |= (240 | x >> 18) << v[s++ & 3], n[s >> 2] |= (128 | x >> 12 & 63) << v[s++ & 3], n[s >> 2] |= (128 | x >> 6 & 63) << v[s++ & 3], n[s >> 2] |= (128 | x & 63) << v[s++ & 3]);
|
|
176
176
|
else
|
|
177
|
-
for (s = this.start; f < h && s <
|
|
177
|
+
for (s = this.start; f < h && s < a; ++f)
|
|
178
178
|
n[s >> 2] |= t[f] << v[s++ & 3];
|
|
179
|
-
if (this.lastByteIndex = s, s >=
|
|
180
|
-
for (this.start = s -
|
|
179
|
+
if (this.lastByteIndex = s, s >= a) {
|
|
180
|
+
for (this.start = s - a, this.block = n[u], s = 0; s < u; ++s)
|
|
181
181
|
S[s] ^= n[s];
|
|
182
182
|
H(S), this.reset = !0;
|
|
183
183
|
} else
|
|
@@ -185,27 +185,27 @@ function he() {
|
|
|
185
185
|
}
|
|
186
186
|
return this;
|
|
187
187
|
}, g.prototype.encode = function(t, e) {
|
|
188
|
-
var r = t & 255, n = 1,
|
|
188
|
+
var r = t & 255, n = 1, a = [r];
|
|
189
189
|
for (t = t >> 8, r = t & 255; r > 0; )
|
|
190
|
-
|
|
191
|
-
return e ?
|
|
190
|
+
a.unshift(r), t = t >> 8, r = t & 255, ++n;
|
|
191
|
+
return e ? a.push(n) : a.unshift(n), this.update(a), a.length;
|
|
192
192
|
}, g.prototype.encodeString = function(t) {
|
|
193
193
|
var e = Vt(t);
|
|
194
194
|
t = e[0];
|
|
195
|
-
var r = e[1], n = 0,
|
|
195
|
+
var r = e[1], n = 0, a = t.length;
|
|
196
196
|
if (r)
|
|
197
197
|
for (var h = 0; h < t.length; ++h) {
|
|
198
198
|
var u = t.charCodeAt(h);
|
|
199
199
|
u < 128 ? n += 1 : u < 2048 ? n += 2 : u < 55296 || u >= 57344 ? n += 3 : (u = 65536 + ((u & 1023) << 10 | t.charCodeAt(++h) & 1023), n += 4);
|
|
200
200
|
}
|
|
201
201
|
else
|
|
202
|
-
n =
|
|
202
|
+
n = a;
|
|
203
203
|
return n += this.encode(n * 8), this.update(t), n;
|
|
204
204
|
}, g.prototype.bytepad = function(t, e) {
|
|
205
205
|
for (var r = this.encode(e), n = 0; n < t.length; ++n)
|
|
206
206
|
r += this.encodeString(t[n]);
|
|
207
|
-
var
|
|
208
|
-
return h.length =
|
|
207
|
+
var a = (e - r % e) % e, h = [];
|
|
208
|
+
return h.length = a, this.update(h), this;
|
|
209
209
|
}, g.prototype.finalize = function() {
|
|
210
210
|
if (!this.finalized) {
|
|
211
211
|
this.finalized = !0;
|
|
@@ -219,30 +219,30 @@ function he() {
|
|
|
219
219
|
}
|
|
220
220
|
}, g.prototype.toString = g.prototype.hex = function() {
|
|
221
221
|
this.finalize();
|
|
222
|
-
for (var t = this.blockCount, e = this.s, r = this.outputBlocks, n = this.extraBytes,
|
|
223
|
-
for (
|
|
224
|
-
f = e[
|
|
225
|
-
h % t === 0 && (e = Jt(e), H(e),
|
|
222
|
+
for (var t = this.blockCount, e = this.s, r = this.outputBlocks, n = this.extraBytes, a = 0, h = 0, u = "", f; h < r; ) {
|
|
223
|
+
for (a = 0; a < t && h < r; ++a, ++h)
|
|
224
|
+
f = e[a], u += d[f >> 4 & 15] + d[f & 15] + d[f >> 12 & 15] + d[f >> 8 & 15] + d[f >> 20 & 15] + d[f >> 16 & 15] + d[f >> 28 & 15] + d[f >> 24 & 15];
|
|
225
|
+
h % t === 0 && (e = Jt(e), H(e), a = 0);
|
|
226
226
|
}
|
|
227
|
-
return n && (f = e[
|
|
227
|
+
return n && (f = e[a], u += d[f >> 4 & 15] + d[f & 15], n > 1 && (u += d[f >> 12 & 15] + d[f >> 8 & 15]), n > 2 && (u += d[f >> 20 & 15] + d[f >> 16 & 15])), u;
|
|
228
228
|
}, g.prototype.arrayBuffer = function() {
|
|
229
229
|
this.finalize();
|
|
230
|
-
var t = this.blockCount, e = this.s, r = this.outputBlocks, n = this.extraBytes,
|
|
230
|
+
var t = this.blockCount, e = this.s, r = this.outputBlocks, n = this.extraBytes, a = 0, h = 0, u = this.outputBits >> 3, f;
|
|
231
231
|
n ? f = new ArrayBuffer(r + 1 << 2) : f = new ArrayBuffer(u);
|
|
232
232
|
for (var S = new Uint32Array(f); h < r; ) {
|
|
233
|
-
for (
|
|
234
|
-
S[h] = e[
|
|
233
|
+
for (a = 0; a < t && h < r; ++a, ++h)
|
|
234
|
+
S[h] = e[a];
|
|
235
235
|
h % t === 0 && (e = Jt(e), H(e));
|
|
236
236
|
}
|
|
237
|
-
return n && (S[h] = e[
|
|
237
|
+
return n && (S[h] = e[a], f = f.slice(0, u)), f;
|
|
238
238
|
}, g.prototype.buffer = g.prototype.arrayBuffer, g.prototype.digest = g.prototype.array = function() {
|
|
239
239
|
this.finalize();
|
|
240
|
-
for (var t = this.blockCount, e = this.s, r = this.outputBlocks, n = this.extraBytes,
|
|
241
|
-
for (
|
|
242
|
-
f = h << 2, S = e[
|
|
240
|
+
for (var t = this.blockCount, e = this.s, r = this.outputBlocks, n = this.extraBytes, a = 0, h = 0, u = [], f, S; h < r; ) {
|
|
241
|
+
for (a = 0; a < t && h < r; ++a, ++h)
|
|
242
|
+
f = h << 2, S = e[a], u[f] = S & 255, u[f + 1] = S >> 8 & 255, u[f + 2] = S >> 16 & 255, u[f + 3] = S >> 24 & 255;
|
|
243
243
|
h % t === 0 && (e = Jt(e), H(e));
|
|
244
244
|
}
|
|
245
|
-
return n && (f = h << 2, S = e[
|
|
245
|
+
return n && (f = h << 2, S = e[a], u[f] = S & 255, n > 1 && (u[f + 1] = S >> 8 & 255), n > 2 && (u[f + 2] = S >> 16 & 255)), u;
|
|
246
246
|
};
|
|
247
247
|
function Wt(t, e, r) {
|
|
248
248
|
g.call(this, t, e, r);
|
|
@@ -251,41 +251,41 @@ function he() {
|
|
|
251
251
|
return this.encode(this.outputBits, !0), g.prototype.finalize.call(this);
|
|
252
252
|
};
|
|
253
253
|
var H = function(t) {
|
|
254
|
-
var e, r, n,
|
|
254
|
+
var e, r, n, a, h, u, f, S, s, x, J, z, W, U, m, G, Y, q, $, L, X, Z, Q, tt, et, rt, nt, ot, it, ct, at, ht, ft, lt, ut, st, yt, dt, bt, pt, vt, xt, gt, St, Bt, Pt, kt, At, Ft, wt, _t, jt, Ct, Ot, Et, Tt, Rt, Kt, Nt, Mt, Dt, Ht, It;
|
|
255
255
|
for (n = 0; n < 48; n += 2)
|
|
256
|
-
|
|
256
|
+
a = t[0] ^ t[10] ^ t[20] ^ t[30] ^ t[40], h = t[1] ^ t[11] ^ t[21] ^ t[31] ^ t[41], u = t[2] ^ t[12] ^ t[22] ^ t[32] ^ t[42], f = t[3] ^ t[13] ^ t[23] ^ t[33] ^ t[43], S = t[4] ^ t[14] ^ t[24] ^ t[34] ^ t[44], s = t[5] ^ t[15] ^ t[25] ^ t[35] ^ t[45], x = t[6] ^ t[16] ^ t[26] ^ t[36] ^ t[46], J = t[7] ^ t[17] ^ t[27] ^ t[37] ^ t[47], z = t[8] ^ t[18] ^ t[28] ^ t[38] ^ t[48], W = t[9] ^ t[19] ^ t[29] ^ t[39] ^ t[49], e = z ^ (u << 1 | f >>> 31), r = W ^ (f << 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 = a ^ (S << 1 | s >>> 31), r = h ^ (s << 1 | S >>> 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 ^ (x << 1 | J >>> 31), r = f ^ (J << 1 | x >>> 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 = S ^ (z << 1 | W >>> 31), r = s ^ (W << 1 | z >>> 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 = x ^ (a << 1 | h >>> 31), r = J ^ (h << 1 | a >>> 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, U = t[0], m = t[1], Pt = t[11] << 4 | t[10] >>> 28, kt = t[10] << 4 | t[11] >>> 28, ot = t[20] << 3 | t[21] >>> 29, it = t[21] << 3 | t[20] >>> 29, Mt = t[31] << 9 | t[30] >>> 23, Dt = t[30] << 9 | t[31] >>> 23, xt = t[40] << 18 | t[41] >>> 14, gt = t[41] << 18 | t[40] >>> 14, lt = t[2] << 1 | t[3] >>> 31, ut = t[3] << 1 | t[2] >>> 31, G = t[13] << 12 | t[12] >>> 20, Y = t[12] << 12 | t[13] >>> 20, At = t[22] << 10 | t[23] >>> 22, Ft = t[23] << 10 | t[22] >>> 22, ct = t[33] << 13 | t[32] >>> 19, at = t[32] << 13 | t[33] >>> 19, Ht = t[42] << 2 | t[43] >>> 30, It = t[43] << 2 | t[42] >>> 30, Ot = t[5] << 30 | t[4] >>> 2, Et = t[4] << 30 | t[5] >>> 2, st = t[14] << 6 | t[15] >>> 26, yt = t[15] << 6 | t[14] >>> 26, q = t[25] << 11 | t[24] >>> 21, $ = t[24] << 11 | t[25] >>> 21, wt = t[34] << 15 | t[35] >>> 17, _t = t[35] << 15 | t[34] >>> 17, ht = t[45] << 29 | t[44] >>> 3, ft = t[44] << 29 | t[45] >>> 3, tt = t[6] << 28 | t[7] >>> 4, et = t[7] << 28 | t[6] >>> 4, Tt = t[17] << 23 | t[16] >>> 9, Rt = t[16] << 23 | t[17] >>> 9, dt = t[26] << 25 | t[27] >>> 7, bt = t[27] << 25 | t[26] >>> 7, L = t[36] << 21 | t[37] >>> 11, X = t[37] << 21 | t[36] >>> 11, jt = t[47] << 24 | t[46] >>> 8, Ct = t[46] << 24 | t[47] >>> 8, St = t[8] << 27 | t[9] >>> 5, Bt = t[9] << 27 | t[8] >>> 5, rt = t[18] << 20 | t[19] >>> 12, nt = t[19] << 20 | t[18] >>> 12, Kt = t[29] << 7 | t[28] >>> 25, Nt = t[28] << 7 | t[29] >>> 25, pt = t[38] << 8 | t[39] >>> 24, vt = t[39] << 8 | t[38] >>> 24, Z = t[48] << 14 | t[49] >>> 18, Q = t[49] << 14 | t[48] >>> 18, t[0] = U ^ ~G & q, t[1] = m ^ ~Y & $, t[10] = tt ^ ~rt & ot, t[11] = et ^ ~nt & it, t[20] = lt ^ ~st & dt, t[21] = ut ^ ~yt & bt, t[30] = St ^ ~Pt & At, t[31] = Bt ^ ~kt & Ft, t[40] = Ot ^ ~Tt & Kt, t[41] = Et ^ ~Rt & Nt, t[2] = G ^ ~q & L, t[3] = Y ^ ~$ & X, t[12] = rt ^ ~ot & ct, t[13] = nt ^ ~it & at, t[22] = st ^ ~dt & pt, t[23] = yt ^ ~bt & vt, t[32] = Pt ^ ~At & wt, t[33] = kt ^ ~Ft & _t, t[42] = Tt ^ ~Kt & Mt, t[43] = Rt ^ ~Nt & Dt, t[4] = q ^ ~L & Z, t[5] = $ ^ ~X & Q, t[14] = ot ^ ~ct & ht, t[15] = it ^ ~at & ft, t[24] = dt ^ ~pt & xt, t[25] = bt ^ ~vt & gt, t[34] = At ^ ~wt & jt, t[35] = Ft ^ ~_t & Ct, t[44] = Kt ^ ~Mt & Ht, t[45] = Nt ^ ~Dt & It, t[6] = L ^ ~Z & U, t[7] = X ^ ~Q & m, t[16] = ct ^ ~ht & tt, t[17] = at ^ ~ft & et, t[26] = pt ^ ~xt & lt, t[27] = vt ^ ~gt & ut, t[36] = wt ^ ~jt & St, t[37] = _t ^ ~Ct & Bt, t[46] = Mt ^ ~Ht & Ot, t[47] = Dt ^ ~It & Et, t[8] = Z ^ ~U & G, t[9] = Q ^ ~m & Y, t[18] = ht ^ ~tt & rt, t[19] = ft ^ ~et & nt, t[28] = xt ^ ~lt & st, t[29] = gt ^ ~ut & yt, t[38] = jt ^ ~St & Pt, t[39] = Ct ^ ~Bt & kt, t[48] = Ht ^ ~Ot & Tt, t[49] = It ^ ~Et & Rt, t[0] ^= _[n], t[1] ^= _[n + 1];
|
|
257
257
|
};
|
|
258
258
|
if (P)
|
|
259
259
|
E.exports = T;
|
|
260
260
|
else
|
|
261
261
|
for (R = 0; R < M.length; ++R)
|
|
262
|
-
|
|
262
|
+
c[M[R]] = T[M[R]];
|
|
263
263
|
})();
|
|
264
264
|
})(Ut)), Ut.exports;
|
|
265
265
|
}
|
|
266
266
|
var fe = he();
|
|
267
267
|
const le = /* @__PURE__ */ ae(fe), { keccak256: O } = le;
|
|
268
268
|
class te {
|
|
269
|
-
constructor(i, o) {
|
|
270
|
-
this.payload = {}, this.declarations = [], this.secrets = {}, this.branchVersions = {}, this.username = i, this.secret = o, this.identityRoot = "0x" + O(o), this.publicKey = "0x" + O("public:" + o), this.identityHash = "0x" + O(this.publicKey + this.username), this.secrets[""] = o;
|
|
271
|
-
const
|
|
272
|
-
return Object.setPrototypeOf(
|
|
269
|
+
constructor(i, o, l) {
|
|
270
|
+
this.payload = {}, this.declarations = [], this.secrets = {}, this.branchVersions = {}, this.username = i, this.secret = o, this.blockchain = l, this.identityRoot = "0x" + O(o), this.publicKey = "0x" + O("public:" + o), this.identityHash = "0x" + O(this.publicKey + this.username), this.secrets[""] = o;
|
|
271
|
+
const c = this.createProxy([]);
|
|
272
|
+
return Object.setPrototypeOf(c, te.prototype), Object.assign(c, this), c;
|
|
273
273
|
}
|
|
274
274
|
/**
|
|
275
275
|
* Create a proxy bound to a specific path, e.g. ["wallet", "income"]
|
|
276
276
|
* The proxy itself is callable (function) and also expandable via property access.
|
|
277
277
|
*/
|
|
278
278
|
createProxy(i) {
|
|
279
|
-
const o = this, l = (...
|
|
279
|
+
const o = this, l = (...c) => o.handleCall(i, c);
|
|
280
280
|
return new Proxy(l, {
|
|
281
|
-
get(
|
|
282
|
-
if (typeof y == "symbol") return
|
|
281
|
+
get(c, y) {
|
|
282
|
+
if (typeof y == "symbol") return c[y];
|
|
283
283
|
if (y === "secret") return o.createProxy([...i, String(y)]);
|
|
284
284
|
if (y in o) return o[y];
|
|
285
285
|
const b = [...i, String(y)];
|
|
286
286
|
return o.createProxy(b);
|
|
287
287
|
},
|
|
288
|
-
apply(
|
|
288
|
+
apply(c, y, b) {
|
|
289
289
|
return o.handleCall(i, b);
|
|
290
290
|
}
|
|
291
291
|
});
|
|
@@ -320,14 +320,14 @@ class te {
|
|
|
320
320
|
}
|
|
321
321
|
if (l === "ptr")
|
|
322
322
|
return { __ptr: i.slice(0, -1).join(".") };
|
|
323
|
-
const
|
|
323
|
+
const c = i.join(".");
|
|
324
324
|
let y;
|
|
325
325
|
o.length === 0 ? y = void 0 : o.length === 1 ? y = o[0] : y = o, this.ensurePath(i, y);
|
|
326
326
|
const b = this.resolveSecret(i), P = "0x" + O(
|
|
327
|
-
b +
|
|
327
|
+
b + c + JSON.stringify(y)
|
|
328
328
|
);
|
|
329
329
|
return this.declarations.push({
|
|
330
|
-
key:
|
|
330
|
+
key: c,
|
|
331
331
|
value: y,
|
|
332
332
|
signature: P,
|
|
333
333
|
timestamp: Date.now()
|
|
@@ -365,18 +365,18 @@ class te {
|
|
|
365
365
|
* - the secret used at P.
|
|
366
366
|
*/
|
|
367
367
|
ensurePath(i, o) {
|
|
368
|
-
const { secret: l, secretPath:
|
|
369
|
-
if (
|
|
368
|
+
const { secret: l, secretPath: c } = this.resolveSecretWithPath(i), y = c.join("."), b = O(l);
|
|
369
|
+
if (c.length > 0) {
|
|
370
370
|
let k = {};
|
|
371
|
-
const F = this.branchVersions[y]?.[b], w = this.getSubPayload(
|
|
371
|
+
const F = this.branchVersions[y]?.[b], w = this.getSubPayload(c);
|
|
372
372
|
if (F) {
|
|
373
|
-
const A = this.decryptForPath(
|
|
373
|
+
const A = this.decryptForPath(c, F);
|
|
374
374
|
A && typeof A == "object" && (k = A);
|
|
375
375
|
} else if (typeof w == "string") {
|
|
376
|
-
const A = this.decryptForPath(
|
|
376
|
+
const A = this.decryptForPath(c, w);
|
|
377
377
|
A && typeof A == "object" && (k = A);
|
|
378
378
|
} else w && typeof w == "object" && (k = w);
|
|
379
|
-
const v = i.slice(
|
|
379
|
+
const v = i.slice(c.length);
|
|
380
380
|
let _ = k;
|
|
381
381
|
for (let A = 0; A < v.length - 1; A++) {
|
|
382
382
|
const K = v[A];
|
|
@@ -384,8 +384,8 @@ class te {
|
|
|
384
384
|
}
|
|
385
385
|
const j = v[v.length - 1];
|
|
386
386
|
_[j] = o;
|
|
387
|
-
const C = this.encryptForPath(
|
|
388
|
-
this.branchVersions[y] || (this.branchVersions[y] = {}), this.branchVersions[y][b] = C, this.writeBranchBlob(
|
|
387
|
+
const C = this.encryptForPath(c, k);
|
|
388
|
+
this.branchVersions[y] || (this.branchVersions[y] = {}), this.branchVersions[y][b] = C, this.writeBranchBlob(c, C);
|
|
389
389
|
return;
|
|
390
390
|
}
|
|
391
391
|
const p = this.encryptForPath(i, o);
|
|
@@ -410,16 +410,16 @@ class te {
|
|
|
410
410
|
const b = i[y];
|
|
411
411
|
(!l[b] || typeof l[b] != "object") && (l[b] = {}), l = l[b];
|
|
412
412
|
}
|
|
413
|
-
const
|
|
414
|
-
l[
|
|
413
|
+
const c = i[i.length - 1];
|
|
414
|
+
l[c] = o;
|
|
415
415
|
}
|
|
416
416
|
/**
|
|
417
417
|
* Find the nearest ancestor path that represents an encrypted branch blob.
|
|
418
418
|
*/
|
|
419
419
|
findNearestBranchAncestor(i) {
|
|
420
420
|
for (let o = i.length - 1; o >= 1; o--) {
|
|
421
|
-
const l = i.slice(0, o),
|
|
422
|
-
if (this.branchVersions[
|
|
421
|
+
const l = i.slice(0, o), c = l.join(".");
|
|
422
|
+
if (this.branchVersions[c])
|
|
423
423
|
return { path: l, secret: this.resolveSecret(l) };
|
|
424
424
|
}
|
|
425
425
|
return null;
|
|
@@ -428,11 +428,11 @@ class te {
|
|
|
428
428
|
* Write an encrypted branch blob while preserving any encrypted ancestor branches.
|
|
429
429
|
*/
|
|
430
430
|
writeBranchBlob(i, o) {
|
|
431
|
-
let l = i,
|
|
431
|
+
let l = i, c = o;
|
|
432
432
|
for (; ; ) {
|
|
433
433
|
const y = this.findNearestBranchAncestor(l);
|
|
434
434
|
if (!y) {
|
|
435
|
-
this.setSubPayload(l,
|
|
435
|
+
this.setSubPayload(l, c);
|
|
436
436
|
return;
|
|
437
437
|
}
|
|
438
438
|
const { path: b, secret: P } = y, p = b.join("."), d = O(P), B = this.getSubPayload(b), k = this.branchVersions[p]?.[d] ?? (typeof B == "string" ? B : void 0);
|
|
@@ -447,9 +447,9 @@ class te {
|
|
|
447
447
|
const C = w[j];
|
|
448
448
|
(!v[C] || typeof v[C] != "object") && (v[C] = {}), v = v[C];
|
|
449
449
|
}
|
|
450
|
-
v[w[w.length - 1]] =
|
|
450
|
+
v[w[w.length - 1]] = c;
|
|
451
451
|
const _ = this.encryptForPath(b, F);
|
|
452
|
-
this.branchVersions[p] || (this.branchVersions[p] = {}), this.branchVersions[p][d] = _, l = b,
|
|
452
|
+
this.branchVersions[p] || (this.branchVersions[p] = {}), this.branchVersions[p][d] = _, l = b, c = _;
|
|
453
453
|
}
|
|
454
454
|
}
|
|
455
455
|
getSubPayload(i) {
|
|
@@ -467,15 +467,15 @@ class te {
|
|
|
467
467
|
if (o == null) return o;
|
|
468
468
|
if (typeof o == "string") {
|
|
469
469
|
if (!this.isHexString(o)) return o;
|
|
470
|
-
const
|
|
471
|
-
return
|
|
470
|
+
const c = this.decryptForPath(i, o);
|
|
471
|
+
return c === null ? o : c;
|
|
472
472
|
}
|
|
473
473
|
if (typeof o != "object")
|
|
474
474
|
return o;
|
|
475
475
|
const l = Array.isArray(o) ? [] : {};
|
|
476
|
-
for (const
|
|
477
|
-
const y = [...i,
|
|
478
|
-
l[
|
|
476
|
+
for (const c of Object.keys(o)) {
|
|
477
|
+
const y = [...i, c];
|
|
478
|
+
l[c] = this.decryptTree(y, o[c]);
|
|
479
479
|
}
|
|
480
480
|
return l;
|
|
481
481
|
}
|
|
@@ -484,7 +484,7 @@ class te {
|
|
|
484
484
|
* Produces a hex string compatible with decryptForPath().
|
|
485
485
|
*/
|
|
486
486
|
encryptForPath(i, o) {
|
|
487
|
-
const l = this.resolveSecret(i),
|
|
487
|
+
const l = this.resolveSecret(i), c = JSON.stringify(o), y = new TextEncoder().encode(c), b = O(l + ":" + i.join(".")), P = this.asciiToBytes(b), p = new Uint8Array(y.length);
|
|
488
488
|
for (let B = 0; B < y.length; B++)
|
|
489
489
|
p[B] = y[B] ^ P[B % P.length];
|
|
490
490
|
let d = "";
|
|
@@ -498,9 +498,9 @@ class te {
|
|
|
498
498
|
decryptForPath(i, o) {
|
|
499
499
|
const l = this.resolveSecret(i);
|
|
500
500
|
try {
|
|
501
|
-
const
|
|
502
|
-
for (let d = 0; d <
|
|
503
|
-
P[d] =
|
|
501
|
+
const c = this.hexToBytes(o), y = O(l + ":" + i.join(".")), b = this.asciiToBytes(y), P = new Uint8Array(c.length);
|
|
502
|
+
for (let d = 0; d < c.length; d++)
|
|
503
|
+
P[d] = c[d] ^ b[d % b.length];
|
|
504
504
|
const p = new TextDecoder().decode(P);
|
|
505
505
|
return JSON.parse(p);
|
|
506
506
|
} catch {
|
|
@@ -512,8 +512,8 @@ class te {
|
|
|
512
512
|
}
|
|
513
513
|
hexToBytes(i) {
|
|
514
514
|
const o = i.startsWith("0x") ? i.slice(2) : i, l = new Uint8Array(o.length / 2);
|
|
515
|
-
for (let
|
|
516
|
-
l[
|
|
515
|
+
for (let c = 0; c < l.length; c++)
|
|
516
|
+
l[c] = parseInt(o.substr(c * 2, 2), 16);
|
|
517
517
|
return l;
|
|
518
518
|
}
|
|
519
519
|
isHexString(i) {
|
|
@@ -537,7 +537,7 @@ class te {
|
|
|
537
537
|
* resolved for that path.
|
|
538
538
|
*/
|
|
539
539
|
exportBranch(i) {
|
|
540
|
-
const o = i ? i.split(".").filter(Boolean) : [], l = o.join("."),
|
|
540
|
+
const o = i ? i.split(".").filter(Boolean) : [], l = o.join("."), c = this.resolveSecret(o), y = O(c), b = this.branchVersions[l]?.[y];
|
|
541
541
|
if (b) {
|
|
542
542
|
const p = this.decryptForPath(o, b);
|
|
543
543
|
return this.decryptTree(o, p);
|
package/dist/me.umd.js
CHANGED
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* @author Chen, Yi-Cyuan [emn178@gmail.com]
|
|
6
6
|
* @copyright Chen, Yi-Cyuan 2015-2023
|
|
7
7
|
* @license MIT
|
|
8
|
-
*/var qt;function oe(){return qt||(qt=1,(function(E){(function(){var i="input is invalid type",o="finalize already called",l=typeof window=="object",a=l?window:{};a.JS_SHA3_NO_WINDOW&&(l=!1);var y=!l&&typeof self=="object",p=!a.JS_SHA3_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;p?a=D:y&&(a=self);for(var B=!a.JS_SHA3_NO_COMMON_JS&&!0&&E.exports,b=!a.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",d="0123456789abcdef".split(""),P=[31,7936,2031616,520093696],k=[4,1024,262144,67108864],F=[1,256,65536,16777216],w=[6,1536,393216,100663296],v=[0,8,16,24],_=[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],j=[224,256,384,512],C=[128,256],A=["hex","buffer","arrayBuffer","array","digest"],R={128:168,256:136},ae=a.JS_SHA3_NO_NODE_JS||!Array.isArray?function(t){return Object.prototype.toString.call(t)==="[object Array]"}:Array.isArray,he=b&&(a.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)?function(t){return typeof t=="object"&&t.buffer&&t.buffer.constructor===ArrayBuffer}:ArrayBuffer.isView,Wt=function(t){var e=typeof t;if(e==="string")return[t,!0];if(e!=="object"||t===null)throw new Error(i);if(b&&t.constructor===ArrayBuffer)return[new Uint8Array(t),!1];if(!ae(t)&&!he(t))throw new Error(i);return[t,!1]},$t=function(t){return Wt(t)[0].length===0},Ut=function(t){for(var e=[],r=0;r<t.length;++r)e[r]=t[r];return e},Lt=function(t,e,r){return function(n){return new g(t,e,t).update(n)[r]()}},Xt=function(t,e,r){return function(n,c){return new g(t,e,c).update(n)[r]()}},Zt=function(t,e,r){return function(n,c,h,u){return T["cshake"+t].update(n,c,h,u)[r]()}},Qt=function(t,e,r){return function(n,c,h,u){return T["kmac"+t].update(n,c,h,u)[r]()}},J=function(t,e,r,n){for(var c=0;c<A.length;++c){var h=A[c];t[h]=e(r,n,h)}return t},te=function(t,e){var r=Lt(t,e,"hex");return r.create=function(){return new g(t,e,t)},r.update=function(n){return r.create().update(n)},J(r,Lt,t,e)},fe=function(t,e){var r=Xt(t,e,"hex");return r.create=function(n){return new g(t,e,n)},r.update=function(n,c){return r.create(c).update(n)},J(r,Xt,t,e)},le=function(t,e){var r=R[t],n=Zt(t,e,"hex");return n.create=function(c,h,u){return $t(h)&&$t(u)?T["shake"+t].create(c):new g(t,e,c).bytepad([h,u],r)},n.update=function(c,h,u,f){return n.create(h,u,f).update(c)},J(n,Zt,t,e)},ue=function(t,e){var r=R[t],n=Qt(t,e,"hex");return n.create=function(c,h,u){return new Yt(t,e,h).bytepad(["KMAC",u],r).bytepad([c],r)},n.update=function(c,h,u,f){return n.create(c,u,f).update(h)},J(n,Qt,t,e)},ee=[{name:"keccak",padding:F,bits:j,createMethod:te},{name:"sha3",padding:w,bits:j,createMethod:te},{name:"shake",padding:P,bits:C,createMethod:fe},{name:"cshake",padding:k,bits:C,createMethod:le},{name:"kmac",padding:k,bits:C,createMethod:ue}],T={},H=[],M=0;M<ee.length;++M)for(var N=ee[M],m=N.bits,I=0;I<m.length;++I){var Gt=N.name+"_"+m[I];if(H.push(Gt),T[Gt]=N.createMethod(m[I],N.padding),N.name!=="sha3"){var re=N.name+m[I];H.push(re),T[re]=T[Gt]}}function g(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}g.prototype.update=function(t){if(this.finalized)throw new Error(o);var e=Wt(t);t=e[0];for(var r=e[1],n=this.blocks,c=this.byteCount,h=t.length,u=this.blockCount,f=0,S=this.s,s,x;f<h;){if(this.reset)for(this.reset=!1,n[0]=this.block,s=1;s<u+1;++s)n[s]=0;if(r)for(s=this.start;f<h&&s<c;++f)x=t.charCodeAt(f),x<128?n[s>>2]|=x<<v[s++&3]:x<2048?(n[s>>2]|=(192|x>>6)<<v[s++&3],n[s>>2]|=(128|x&63)<<v[s++&3]):x<55296||x>=57344?(n[s>>2]|=(224|x>>12)<<v[s++&3],n[s>>2]|=(128|x>>6&63)<<v[s++&3],n[s>>2]|=(128|x&63)<<v[s++&3]):(x=65536+((x&1023)<<10|t.charCodeAt(++f)&1023),n[s>>2]|=(240|x>>18)<<v[s++&3],n[s>>2]|=(128|x>>12&63)<<v[s++&3],n[s>>2]|=(128|x>>6&63)<<v[s++&3],n[s>>2]|=(128|x&63)<<v[s++&3]);else for(s=this.start;f<h&&s<c;++f)n[s>>2]|=t[f]<<v[s++&3];if(this.lastByteIndex=s,s>=c){for(this.start=s-c,this.block=n[u],s=0;s<u;++s)S[s]^=n[s];V(S),this.reset=!0}else this.start=s}return this},g.prototype.encode=function(t,e){var r=t&255,n=1,c=[r];for(t=t>>8,r=t&255;r>0;)c.unshift(r),t=t>>8,r=t&255,++n;return e?c.push(n):c.unshift(n),this.update(c),c.length},g.prototype.encodeString=function(t){var e=Wt(t);t=e[0];var r=e[1],n=0,c=t.length;if(r)for(var h=0;h<t.length;++h){var u=t.charCodeAt(h);u<128?n+=1:u<2048?n+=2:u<55296||u>=57344?n+=3:(u=65536+((u&1023)<<10|t.charCodeAt(++h)&1023),n+=4)}else n=c;return n+=this.encode(n*8),this.update(t),n},g.prototype.bytepad=function(t,e){for(var r=this.encode(e),n=0;n<t.length;++n)r+=this.encodeString(t[n]);var c=(e-r%e)%e,h=[];return h.length=c,this.update(h),this},g.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];V(n)}},g.prototype.toString=g.prototype.hex=function(){this.finalize();for(var t=this.blockCount,e=this.s,r=this.outputBlocks,n=this.extraBytes,c=0,h=0,u="",f;h<r;){for(c=0;c<t&&h<r;++c,++h)f=e[c],u+=d[f>>4&15]+d[f&15]+d[f>>12&15]+d[f>>8&15]+d[f>>20&15]+d[f>>16&15]+d[f>>28&15]+d[f>>24&15];h%t===0&&(e=Ut(e),V(e),c=0)}return n&&(f=e[c],u+=d[f>>4&15]+d[f&15],n>1&&(u+=d[f>>12&15]+d[f>>8&15]),n>2&&(u+=d[f>>20&15]+d[f>>16&15])),u},g.prototype.arrayBuffer=function(){this.finalize();var t=this.blockCount,e=this.s,r=this.outputBlocks,n=this.extraBytes,c=0,h=0,u=this.outputBits>>3,f;n?f=new ArrayBuffer(r+1<<2):f=new ArrayBuffer(u);for(var S=new Uint32Array(f);h<r;){for(c=0;c<t&&h<r;++c,++h)S[h]=e[c];h%t===0&&(e=Ut(e),V(e))}return n&&(S[h]=e[c],f=f.slice(0,u)),f},g.prototype.buffer=g.prototype.arrayBuffer,g.prototype.digest=g.prototype.array=function(){this.finalize();for(var t=this.blockCount,e=this.s,r=this.outputBlocks,n=this.extraBytes,c=0,h=0,u=[],f,S;h<r;){for(c=0;c<t&&h<r;++c,++h)f=h<<2,S=e[c],u[f]=S&255,u[f+1]=S>>8&255,u[f+2]=S>>16&255,u[f+3]=S>>24&255;h%t===0&&(e=Ut(e),V(e))}return n&&(f=h<<2,S=e[c],u[f]=S&255,n>1&&(u[f+1]=S>>8&255),n>2&&(u[f+2]=S>>16&255)),u};function Yt(t,e,r){g.call(this,t,e,r)}Yt.prototype=new g,Yt.prototype.finalize=function(){return this.encode(this.outputBits,!0),g.prototype.finalize.call(this)};var V=function(t){var e,r,n,c,h,u,f,S,s,x,z,W,U,G,Y,q,$,L,X,Z,Q,tt,et,rt,nt,ot,it,ct,at,ht,ft,lt,ut,st,yt,dt,pt,bt,vt,xt,gt,St,Pt,Bt,kt,At,Ft,wt,_t,jt,Ct,Ot,Et,Tt,Mt,Rt,Kt,Nt,Dt,Ht,It,Vt,Jt;for(n=0;n<48;n+=2)c=t[0]^t[10]^t[20]^t[30]^t[40],h=t[1]^t[11]^t[21]^t[31]^t[41],u=t[2]^t[12]^t[22]^t[32]^t[42],f=t[3]^t[13]^t[23]^t[33]^t[43],S=t[4]^t[14]^t[24]^t[34]^t[44],s=t[5]^t[15]^t[25]^t[35]^t[45],x=t[6]^t[16]^t[26]^t[36]^t[46],z=t[7]^t[17]^t[27]^t[37]^t[47],W=t[8]^t[18]^t[28]^t[38]^t[48],U=t[9]^t[19]^t[29]^t[39]^t[49],e=W^(u<<1|f>>>31),r=U^(f<<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=c^(S<<1|s>>>31),r=h^(s<<1|S>>>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^(x<<1|z>>>31),r=f^(z<<1|x>>>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=S^(W<<1|U>>>31),r=s^(U<<1|W>>>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=x^(c<<1|h>>>31),r=z^(h<<1|c>>>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,G=t[0],Y=t[1],At=t[11]<<4|t[10]>>>28,Ft=t[10]<<4|t[11]>>>28,ct=t[20]<<3|t[21]>>>29,at=t[21]<<3|t[20]>>>29,Ht=t[31]<<9|t[30]>>>23,It=t[30]<<9|t[31]>>>23,St=t[40]<<18|t[41]>>>14,Pt=t[41]<<18|t[40]>>>14,st=t[2]<<1|t[3]>>>31,yt=t[3]<<1|t[2]>>>31,q=t[13]<<12|t[12]>>>20,$=t[12]<<12|t[13]>>>20,wt=t[22]<<10|t[23]>>>22,_t=t[23]<<10|t[22]>>>22,ht=t[33]<<13|t[32]>>>19,ft=t[32]<<13|t[33]>>>19,Vt=t[42]<<2|t[43]>>>30,Jt=t[43]<<2|t[42]>>>30,Tt=t[5]<<30|t[4]>>>2,Mt=t[4]<<30|t[5]>>>2,dt=t[14]<<6|t[15]>>>26,pt=t[15]<<6|t[14]>>>26,L=t[25]<<11|t[24]>>>21,X=t[24]<<11|t[25]>>>21,jt=t[34]<<15|t[35]>>>17,Ct=t[35]<<15|t[34]>>>17,lt=t[45]<<29|t[44]>>>3,ut=t[44]<<29|t[45]>>>3,rt=t[6]<<28|t[7]>>>4,nt=t[7]<<28|t[6]>>>4,Rt=t[17]<<23|t[16]>>>9,Kt=t[16]<<23|t[17]>>>9,bt=t[26]<<25|t[27]>>>7,vt=t[27]<<25|t[26]>>>7,Z=t[36]<<21|t[37]>>>11,Q=t[37]<<21|t[36]>>>11,Ot=t[47]<<24|t[46]>>>8,Et=t[46]<<24|t[47]>>>8,Bt=t[8]<<27|t[9]>>>5,kt=t[9]<<27|t[8]>>>5,ot=t[18]<<20|t[19]>>>12,it=t[19]<<20|t[18]>>>12,Nt=t[29]<<7|t[28]>>>25,Dt=t[28]<<7|t[29]>>>25,xt=t[38]<<8|t[39]>>>24,gt=t[39]<<8|t[38]>>>24,tt=t[48]<<14|t[49]>>>18,et=t[49]<<14|t[48]>>>18,t[0]=G^~q&L,t[1]=Y^~$&X,t[10]=rt^~ot&ct,t[11]=nt^~it&at,t[20]=st^~dt&bt,t[21]=yt^~pt&vt,t[30]=Bt^~At&wt,t[31]=kt^~Ft&_t,t[40]=Tt^~Rt&Nt,t[41]=Mt^~Kt&Dt,t[2]=q^~L&Z,t[3]=$^~X&Q,t[12]=ot^~ct&ht,t[13]=it^~at&ft,t[22]=dt^~bt&xt,t[23]=pt^~vt>,t[32]=At^~wt&jt,t[33]=Ft^~_t&Ct,t[42]=Rt^~Nt&Ht,t[43]=Kt^~Dt&It,t[4]=L^~Z&tt,t[5]=X^~Q&et,t[14]=ct^~ht<,t[15]=at^~ft&ut,t[24]=bt^~xt&St,t[25]=vt^~gt&Pt,t[34]=wt^~jt&Ot,t[35]=_t^~Ct&Et,t[44]=Nt^~Ht&Vt,t[45]=Dt^~It&Jt,t[6]=Z^~tt&G,t[7]=Q^~et&Y,t[16]=ht^~lt&rt,t[17]=ft^~ut&nt,t[26]=xt^~St&st,t[27]=gt^~Pt&yt,t[36]=jt^~Ot&Bt,t[37]=Ct^~Et&kt,t[46]=Ht^~Vt&Tt,t[47]=It^~Jt&Mt,t[8]=tt^~G&q,t[9]=et^~Y&$,t[18]=lt^~rt&ot,t[19]=ut^~nt&it,t[28]=St^~st&dt,t[29]=Pt^~yt&pt,t[38]=Ot^~Bt&At,t[39]=Et^~kt&Ft,t[48]=Vt^~Tt&Rt,t[49]=Jt^~Mt&Kt,t[0]^=_[n],t[1]^=_[n+1]};if(B)E.exports=T;else for(M=0;M<H.length;++M)a[H[M]]=T[H[M]]})()})(mt)),mt.exports}var ie=oe();const ce=ne(ie),{keccak256:O}=ce;class zt{constructor(i,o){this.payload={},this.declarations=[],this.secrets={},this.branchVersions={},this.username=i,this.secret=o,this.identityRoot="0x"+O(o),this.publicKey="0x"+O("public:"+o),this.identityHash="0x"+O(this.publicKey+this.username),this.secrets[""]=o;const l=this.createProxy([]);return Object.setPrototypeOf(l,zt.prototype),Object.assign(l,this),l}createProxy(i){const o=this,l=(...a)=>o.handleCall(i,a);return new Proxy(l,{get(a,y){if(typeof y=="symbol")return a[y];if(y==="secret")return o.createProxy([...i,String(y)]);if(y in o)return o[y];const p=[...i,String(y)];return o.createProxy(p)},apply(a,y,p){return o.handleCall(i,p)}})}handleCall(i,o){if(i.length===0){if(o.length===1&&typeof o[0]=="string"){const b=o[0].split(".").filter(Boolean);return this.exportBranch(b.join("."))}return this.createProxy([])}const l=i[i.length-1];if(l==="secret"){const b=i.slice(0,-1),d=b.join("."),P=String(o[0]??"");if(!P)return this.createProxy(b);this.secrets[d]=P;const k="0x"+O(this.secret+d+"::secret-set");return this.declarations.push({key:d+".secret",value:"<secret-set>",signature:k,timestamp:Date.now()}),this.createProxy(b)}if(l==="ptr")return{__ptr:i.slice(0,-1).join(".")};const a=i.join(".");let y;o.length===0?y=void 0:o.length===1?y=o[0]:y=o,this.ensurePath(i,y);const p=this.resolveSecret(i),B="0x"+O(p+a+JSON.stringify(y));return this.declarations.push({key:a,value:y,signature:B,timestamp:Date.now()}),this.createProxy(i)}resolveSecretWithPath(i){for(let o=i.length;o>=0;o--){const l=i.slice(0,o).join(".");if(this.secrets[l])return{secret:this.secrets[l],secretPath:i.slice(0,o)}}return{secret:this.secret,secretPath:[]}}resolveSecret(i){return this.resolveSecretWithPath(i).secret}ensurePath(i,o){const{secret:l,secretPath:a}=this.resolveSecretWithPath(i),y=a.join("."),p=O(l);if(a.length>0){let k={};const F=this.branchVersions[y]?.[p],w=this.getSubPayload(a);if(F){const A=this.decryptForPath(a,F);A&&typeof A=="object"&&(k=A)}else if(typeof w=="string"){const A=this.decryptForPath(a,w);A&&typeof A=="object"&&(k=A)}else w&&typeof w=="object"&&(k=w);const v=i.slice(a.length);let _=k;for(let A=0;A<v.length-1;A++){const R=v[A];(!_[R]||typeof _[R]!="object")&&(_[R]={}),_=_[R]}const j=v[v.length-1];_[j]=o;const C=this.encryptForPath(a,k);this.branchVersions[y]||(this.branchVersions[y]={}),this.branchVersions[y][p]=C,this.writeBranchBlob(a,C);return}const b=this.encryptForPath(i,o);let d=this.payload;for(let k=0;k<i.length-1;k++){const F=i[k];(!d[F]||typeof d[F]!="object")&&(d[F]={}),d=d[F]}const P=i[i.length-1];d[P]=b}setSubPayload(i,o){if(i.length===0){this.payload=o;return}let l=this.payload;for(let y=0;y<i.length-1;y++){const p=i[y];(!l[p]||typeof l[p]!="object")&&(l[p]={}),l=l[p]}const a=i[i.length-1];l[a]=o}findNearestBranchAncestor(i){for(let o=i.length-1;o>=1;o--){const l=i.slice(0,o),a=l.join(".");if(this.branchVersions[a])return{path:l,secret:this.resolveSecret(l)}}return null}writeBranchBlob(i,o){let l=i,a=o;for(;;){const y=this.findNearestBranchAncestor(l);if(!y){this.setSubPayload(l,a);return}const{path:p,secret:B}=y,b=p.join("."),d=O(B),P=this.getSubPayload(p),k=this.branchVersions[b]?.[d]??(typeof P=="string"?P:void 0);let F={};if(k){const j=this.decryptForPath(p,k);j&&typeof j=="object"&&(F=j)}const w=l.slice(p.length);let v=F;for(let j=0;j<w.length-1;j++){const C=w[j];(!v[C]||typeof v[C]!="object")&&(v[C]={}),v=v[C]}v[w[w.length-1]]=a;const _=this.encryptForPath(p,F);this.branchVersions[b]||(this.branchVersions[b]={}),this.branchVersions[b][d]=_,l=p,a=_}}getSubPayload(i){let o=this.payload;for(const l of i){if(!o||typeof o!="object")return;o=o[l]}return o}decryptTree(i,o){if(o==null)return o;if(typeof o=="string"){if(!this.isHexString(o))return o;const a=this.decryptForPath(i,o);return a===null?o:a}if(typeof o!="object")return o;const l=Array.isArray(o)?[]:{};for(const a of Object.keys(o)){const y=[...i,a];l[a]=this.decryptTree(y,o[a])}return l}encryptForPath(i,o){const l=this.resolveSecret(i),a=JSON.stringify(o),y=new TextEncoder().encode(a),p=O(l+":"+i.join(".")),B=this.asciiToBytes(p),b=new Uint8Array(y.length);for(let P=0;P<y.length;P++)b[P]=y[P]^B[P%B.length];let d="";for(let P=0;P<b.length;P++)d+=b[P].toString(16).padStart(2,"0");return d}decryptForPath(i,o){const l=this.resolveSecret(i);try{const a=this.hexToBytes(o),y=O(l+":"+i.join(".")),p=this.asciiToBytes(y),B=new Uint8Array(a.length);for(let d=0;d<a.length;d++)B[d]=a[d]^p[d%p.length];const b=new TextDecoder().decode(B);return JSON.parse(b)}catch{return null}}asciiToBytes(i){return new TextEncoder().encode(i)}hexToBytes(i){const o=i.startsWith("0x")?i.slice(2):i,l=new Uint8Array(o.length/2);for(let a=0;a<l.length;a++)l[a]=parseInt(o.substr(a*2,2),16);return l}isHexString(i){const o=i.startsWith("0x")?i.slice(2):i;return o.length>0&&o.length%2===0&&/^[0-9a-fA-F]+$/.test(o)}export(){return{identityRoot:this.identityRoot,publicKey:this.publicKey,identityHash:this.identityHash,declarations:this.declarations,payload:this.payload}}exportBranch(i){const o=i?i.split(".").filter(Boolean):[],l=o.join("."),a=this.resolveSecret(o),y=O(a),p=this.branchVersions[l]?.[y];if(p){const b=this.decryptForPath(o,p);return this.decryptTree(o,b)}const B=this.getSubPayload(o);if(B!==void 0){if(typeof B=="string"){const b=this.decryptForPath(o,B);return this.decryptTree(o,b)}return this.decryptTree(o,B)}}}K.ME=zt,Object.defineProperty(K,Symbol.toStringTag,{value:"Module"})}));
|
|
8
|
+
*/var qt;function oe(){return qt||(qt=1,(function(E){(function(){var i="input is invalid type",o="finalize already called",l=typeof window=="object",c=l?window:{};c.JS_SHA3_NO_WINDOW&&(l=!1);var y=!l&&typeof self=="object",b=!c.JS_SHA3_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;b?c=D:y&&(c=self);for(var B=!c.JS_SHA3_NO_COMMON_JS&&!0&&E.exports,p=!c.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",d="0123456789abcdef".split(""),P=[31,7936,2031616,520093696],k=[4,1024,262144,67108864],F=[1,256,65536,16777216],w=[6,1536,393216,100663296],v=[0,8,16,24],_=[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],j=[224,256,384,512],C=[128,256],A=["hex","buffer","arrayBuffer","array","digest"],R={128:168,256:136},ae=c.JS_SHA3_NO_NODE_JS||!Array.isArray?function(t){return Object.prototype.toString.call(t)==="[object Array]"}:Array.isArray,he=p&&(c.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)?function(t){return typeof t=="object"&&t.buffer&&t.buffer.constructor===ArrayBuffer}:ArrayBuffer.isView,Wt=function(t){var e=typeof t;if(e==="string")return[t,!0];if(e!=="object"||t===null)throw new Error(i);if(p&&t.constructor===ArrayBuffer)return[new Uint8Array(t),!1];if(!ae(t)&&!he(t))throw new Error(i);return[t,!1]},$t=function(t){return Wt(t)[0].length===0},Ut=function(t){for(var e=[],r=0;r<t.length;++r)e[r]=t[r];return e},Lt=function(t,e,r){return function(n){return new g(t,e,t).update(n)[r]()}},Xt=function(t,e,r){return function(n,a){return new g(t,e,a).update(n)[r]()}},Zt=function(t,e,r){return function(n,a,h,u){return T["cshake"+t].update(n,a,h,u)[r]()}},Qt=function(t,e,r){return function(n,a,h,u){return T["kmac"+t].update(n,a,h,u)[r]()}},J=function(t,e,r,n){for(var a=0;a<A.length;++a){var h=A[a];t[h]=e(r,n,h)}return t},te=function(t,e){var r=Lt(t,e,"hex");return r.create=function(){return new g(t,e,t)},r.update=function(n){return r.create().update(n)},J(r,Lt,t,e)},fe=function(t,e){var r=Xt(t,e,"hex");return r.create=function(n){return new g(t,e,n)},r.update=function(n,a){return r.create(a).update(n)},J(r,Xt,t,e)},le=function(t,e){var r=R[t],n=Zt(t,e,"hex");return n.create=function(a,h,u){return $t(h)&&$t(u)?T["shake"+t].create(a):new g(t,e,a).bytepad([h,u],r)},n.update=function(a,h,u,f){return n.create(h,u,f).update(a)},J(n,Zt,t,e)},ue=function(t,e){var r=R[t],n=Qt(t,e,"hex");return n.create=function(a,h,u){return new Yt(t,e,h).bytepad(["KMAC",u],r).bytepad([a],r)},n.update=function(a,h,u,f){return n.create(a,u,f).update(h)},J(n,Qt,t,e)},ee=[{name:"keccak",padding:F,bits:j,createMethod:te},{name:"sha3",padding:w,bits:j,createMethod:te},{name:"shake",padding:P,bits:C,createMethod:fe},{name:"cshake",padding:k,bits:C,createMethod:le},{name:"kmac",padding:k,bits:C,createMethod:ue}],T={},H=[],M=0;M<ee.length;++M)for(var N=ee[M],m=N.bits,I=0;I<m.length;++I){var Gt=N.name+"_"+m[I];if(H.push(Gt),T[Gt]=N.createMethod(m[I],N.padding),N.name!=="sha3"){var re=N.name+m[I];H.push(re),T[re]=T[Gt]}}function g(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}g.prototype.update=function(t){if(this.finalized)throw new Error(o);var e=Wt(t);t=e[0];for(var r=e[1],n=this.blocks,a=this.byteCount,h=t.length,u=this.blockCount,f=0,S=this.s,s,x;f<h;){if(this.reset)for(this.reset=!1,n[0]=this.block,s=1;s<u+1;++s)n[s]=0;if(r)for(s=this.start;f<h&&s<a;++f)x=t.charCodeAt(f),x<128?n[s>>2]|=x<<v[s++&3]:x<2048?(n[s>>2]|=(192|x>>6)<<v[s++&3],n[s>>2]|=(128|x&63)<<v[s++&3]):x<55296||x>=57344?(n[s>>2]|=(224|x>>12)<<v[s++&3],n[s>>2]|=(128|x>>6&63)<<v[s++&3],n[s>>2]|=(128|x&63)<<v[s++&3]):(x=65536+((x&1023)<<10|t.charCodeAt(++f)&1023),n[s>>2]|=(240|x>>18)<<v[s++&3],n[s>>2]|=(128|x>>12&63)<<v[s++&3],n[s>>2]|=(128|x>>6&63)<<v[s++&3],n[s>>2]|=(128|x&63)<<v[s++&3]);else for(s=this.start;f<h&&s<a;++f)n[s>>2]|=t[f]<<v[s++&3];if(this.lastByteIndex=s,s>=a){for(this.start=s-a,this.block=n[u],s=0;s<u;++s)S[s]^=n[s];V(S),this.reset=!0}else this.start=s}return this},g.prototype.encode=function(t,e){var r=t&255,n=1,a=[r];for(t=t>>8,r=t&255;r>0;)a.unshift(r),t=t>>8,r=t&255,++n;return e?a.push(n):a.unshift(n),this.update(a),a.length},g.prototype.encodeString=function(t){var e=Wt(t);t=e[0];var r=e[1],n=0,a=t.length;if(r)for(var h=0;h<t.length;++h){var u=t.charCodeAt(h);u<128?n+=1:u<2048?n+=2:u<55296||u>=57344?n+=3:(u=65536+((u&1023)<<10|t.charCodeAt(++h)&1023),n+=4)}else n=a;return n+=this.encode(n*8),this.update(t),n},g.prototype.bytepad=function(t,e){for(var r=this.encode(e),n=0;n<t.length;++n)r+=this.encodeString(t[n]);var a=(e-r%e)%e,h=[];return h.length=a,this.update(h),this},g.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];V(n)}},g.prototype.toString=g.prototype.hex=function(){this.finalize();for(var t=this.blockCount,e=this.s,r=this.outputBlocks,n=this.extraBytes,a=0,h=0,u="",f;h<r;){for(a=0;a<t&&h<r;++a,++h)f=e[a],u+=d[f>>4&15]+d[f&15]+d[f>>12&15]+d[f>>8&15]+d[f>>20&15]+d[f>>16&15]+d[f>>28&15]+d[f>>24&15];h%t===0&&(e=Ut(e),V(e),a=0)}return n&&(f=e[a],u+=d[f>>4&15]+d[f&15],n>1&&(u+=d[f>>12&15]+d[f>>8&15]),n>2&&(u+=d[f>>20&15]+d[f>>16&15])),u},g.prototype.arrayBuffer=function(){this.finalize();var t=this.blockCount,e=this.s,r=this.outputBlocks,n=this.extraBytes,a=0,h=0,u=this.outputBits>>3,f;n?f=new ArrayBuffer(r+1<<2):f=new ArrayBuffer(u);for(var S=new Uint32Array(f);h<r;){for(a=0;a<t&&h<r;++a,++h)S[h]=e[a];h%t===0&&(e=Ut(e),V(e))}return n&&(S[h]=e[a],f=f.slice(0,u)),f},g.prototype.buffer=g.prototype.arrayBuffer,g.prototype.digest=g.prototype.array=function(){this.finalize();for(var t=this.blockCount,e=this.s,r=this.outputBlocks,n=this.extraBytes,a=0,h=0,u=[],f,S;h<r;){for(a=0;a<t&&h<r;++a,++h)f=h<<2,S=e[a],u[f]=S&255,u[f+1]=S>>8&255,u[f+2]=S>>16&255,u[f+3]=S>>24&255;h%t===0&&(e=Ut(e),V(e))}return n&&(f=h<<2,S=e[a],u[f]=S&255,n>1&&(u[f+1]=S>>8&255),n>2&&(u[f+2]=S>>16&255)),u};function Yt(t,e,r){g.call(this,t,e,r)}Yt.prototype=new g,Yt.prototype.finalize=function(){return this.encode(this.outputBits,!0),g.prototype.finalize.call(this)};var V=function(t){var e,r,n,a,h,u,f,S,s,x,z,W,U,G,Y,q,$,L,X,Z,Q,tt,et,rt,nt,ot,it,ct,at,ht,ft,lt,ut,st,yt,dt,bt,pt,vt,xt,gt,St,Pt,Bt,kt,At,Ft,wt,_t,jt,Ct,Ot,Et,Tt,Mt,Rt,Kt,Nt,Dt,Ht,It,Vt,Jt;for(n=0;n<48;n+=2)a=t[0]^t[10]^t[20]^t[30]^t[40],h=t[1]^t[11]^t[21]^t[31]^t[41],u=t[2]^t[12]^t[22]^t[32]^t[42],f=t[3]^t[13]^t[23]^t[33]^t[43],S=t[4]^t[14]^t[24]^t[34]^t[44],s=t[5]^t[15]^t[25]^t[35]^t[45],x=t[6]^t[16]^t[26]^t[36]^t[46],z=t[7]^t[17]^t[27]^t[37]^t[47],W=t[8]^t[18]^t[28]^t[38]^t[48],U=t[9]^t[19]^t[29]^t[39]^t[49],e=W^(u<<1|f>>>31),r=U^(f<<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=a^(S<<1|s>>>31),r=h^(s<<1|S>>>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^(x<<1|z>>>31),r=f^(z<<1|x>>>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=S^(W<<1|U>>>31),r=s^(U<<1|W>>>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=x^(a<<1|h>>>31),r=z^(h<<1|a>>>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,G=t[0],Y=t[1],At=t[11]<<4|t[10]>>>28,Ft=t[10]<<4|t[11]>>>28,ct=t[20]<<3|t[21]>>>29,at=t[21]<<3|t[20]>>>29,Ht=t[31]<<9|t[30]>>>23,It=t[30]<<9|t[31]>>>23,St=t[40]<<18|t[41]>>>14,Pt=t[41]<<18|t[40]>>>14,st=t[2]<<1|t[3]>>>31,yt=t[3]<<1|t[2]>>>31,q=t[13]<<12|t[12]>>>20,$=t[12]<<12|t[13]>>>20,wt=t[22]<<10|t[23]>>>22,_t=t[23]<<10|t[22]>>>22,ht=t[33]<<13|t[32]>>>19,ft=t[32]<<13|t[33]>>>19,Vt=t[42]<<2|t[43]>>>30,Jt=t[43]<<2|t[42]>>>30,Tt=t[5]<<30|t[4]>>>2,Mt=t[4]<<30|t[5]>>>2,dt=t[14]<<6|t[15]>>>26,bt=t[15]<<6|t[14]>>>26,L=t[25]<<11|t[24]>>>21,X=t[24]<<11|t[25]>>>21,jt=t[34]<<15|t[35]>>>17,Ct=t[35]<<15|t[34]>>>17,lt=t[45]<<29|t[44]>>>3,ut=t[44]<<29|t[45]>>>3,rt=t[6]<<28|t[7]>>>4,nt=t[7]<<28|t[6]>>>4,Rt=t[17]<<23|t[16]>>>9,Kt=t[16]<<23|t[17]>>>9,pt=t[26]<<25|t[27]>>>7,vt=t[27]<<25|t[26]>>>7,Z=t[36]<<21|t[37]>>>11,Q=t[37]<<21|t[36]>>>11,Ot=t[47]<<24|t[46]>>>8,Et=t[46]<<24|t[47]>>>8,Bt=t[8]<<27|t[9]>>>5,kt=t[9]<<27|t[8]>>>5,ot=t[18]<<20|t[19]>>>12,it=t[19]<<20|t[18]>>>12,Nt=t[29]<<7|t[28]>>>25,Dt=t[28]<<7|t[29]>>>25,xt=t[38]<<8|t[39]>>>24,gt=t[39]<<8|t[38]>>>24,tt=t[48]<<14|t[49]>>>18,et=t[49]<<14|t[48]>>>18,t[0]=G^~q&L,t[1]=Y^~$&X,t[10]=rt^~ot&ct,t[11]=nt^~it&at,t[20]=st^~dt&pt,t[21]=yt^~bt&vt,t[30]=Bt^~At&wt,t[31]=kt^~Ft&_t,t[40]=Tt^~Rt&Nt,t[41]=Mt^~Kt&Dt,t[2]=q^~L&Z,t[3]=$^~X&Q,t[12]=ot^~ct&ht,t[13]=it^~at&ft,t[22]=dt^~pt&xt,t[23]=bt^~vt>,t[32]=At^~wt&jt,t[33]=Ft^~_t&Ct,t[42]=Rt^~Nt&Ht,t[43]=Kt^~Dt&It,t[4]=L^~Z&tt,t[5]=X^~Q&et,t[14]=ct^~ht<,t[15]=at^~ft&ut,t[24]=pt^~xt&St,t[25]=vt^~gt&Pt,t[34]=wt^~jt&Ot,t[35]=_t^~Ct&Et,t[44]=Nt^~Ht&Vt,t[45]=Dt^~It&Jt,t[6]=Z^~tt&G,t[7]=Q^~et&Y,t[16]=ht^~lt&rt,t[17]=ft^~ut&nt,t[26]=xt^~St&st,t[27]=gt^~Pt&yt,t[36]=jt^~Ot&Bt,t[37]=Ct^~Et&kt,t[46]=Ht^~Vt&Tt,t[47]=It^~Jt&Mt,t[8]=tt^~G&q,t[9]=et^~Y&$,t[18]=lt^~rt&ot,t[19]=ut^~nt&it,t[28]=St^~st&dt,t[29]=Pt^~yt&bt,t[38]=Ot^~Bt&At,t[39]=Et^~kt&Ft,t[48]=Vt^~Tt&Rt,t[49]=Jt^~Mt&Kt,t[0]^=_[n],t[1]^=_[n+1]};if(B)E.exports=T;else for(M=0;M<H.length;++M)c[H[M]]=T[H[M]]})()})(mt)),mt.exports}var ie=oe();const ce=ne(ie),{keccak256:O}=ce;class zt{constructor(i,o,l){this.payload={},this.declarations=[],this.secrets={},this.branchVersions={},this.username=i,this.secret=o,this.blockchain=l,this.identityRoot="0x"+O(o),this.publicKey="0x"+O("public:"+o),this.identityHash="0x"+O(this.publicKey+this.username),this.secrets[""]=o;const c=this.createProxy([]);return Object.setPrototypeOf(c,zt.prototype),Object.assign(c,this),c}createProxy(i){const o=this,l=(...c)=>o.handleCall(i,c);return new Proxy(l,{get(c,y){if(typeof y=="symbol")return c[y];if(y==="secret")return o.createProxy([...i,String(y)]);if(y in o)return o[y];const b=[...i,String(y)];return o.createProxy(b)},apply(c,y,b){return o.handleCall(i,b)}})}handleCall(i,o){if(i.length===0){if(o.length===1&&typeof o[0]=="string"){const p=o[0].split(".").filter(Boolean);return this.exportBranch(p.join("."))}return this.createProxy([])}const l=i[i.length-1];if(l==="secret"){const p=i.slice(0,-1),d=p.join("."),P=String(o[0]??"");if(!P)return this.createProxy(p);this.secrets[d]=P;const k="0x"+O(this.secret+d+"::secret-set");return this.declarations.push({key:d+".secret",value:"<secret-set>",signature:k,timestamp:Date.now()}),this.createProxy(p)}if(l==="ptr")return{__ptr:i.slice(0,-1).join(".")};const c=i.join(".");let y;o.length===0?y=void 0:o.length===1?y=o[0]:y=o,this.ensurePath(i,y);const b=this.resolveSecret(i),B="0x"+O(b+c+JSON.stringify(y));return this.declarations.push({key:c,value:y,signature:B,timestamp:Date.now()}),this.createProxy(i)}resolveSecretWithPath(i){for(let o=i.length;o>=0;o--){const l=i.slice(0,o).join(".");if(this.secrets[l])return{secret:this.secrets[l],secretPath:i.slice(0,o)}}return{secret:this.secret,secretPath:[]}}resolveSecret(i){return this.resolveSecretWithPath(i).secret}ensurePath(i,o){const{secret:l,secretPath:c}=this.resolveSecretWithPath(i),y=c.join("."),b=O(l);if(c.length>0){let k={};const F=this.branchVersions[y]?.[b],w=this.getSubPayload(c);if(F){const A=this.decryptForPath(c,F);A&&typeof A=="object"&&(k=A)}else if(typeof w=="string"){const A=this.decryptForPath(c,w);A&&typeof A=="object"&&(k=A)}else w&&typeof w=="object"&&(k=w);const v=i.slice(c.length);let _=k;for(let A=0;A<v.length-1;A++){const R=v[A];(!_[R]||typeof _[R]!="object")&&(_[R]={}),_=_[R]}const j=v[v.length-1];_[j]=o;const C=this.encryptForPath(c,k);this.branchVersions[y]||(this.branchVersions[y]={}),this.branchVersions[y][b]=C,this.writeBranchBlob(c,C);return}const p=this.encryptForPath(i,o);let d=this.payload;for(let k=0;k<i.length-1;k++){const F=i[k];(!d[F]||typeof d[F]!="object")&&(d[F]={}),d=d[F]}const P=i[i.length-1];d[P]=p}setSubPayload(i,o){if(i.length===0){this.payload=o;return}let l=this.payload;for(let y=0;y<i.length-1;y++){const b=i[y];(!l[b]||typeof l[b]!="object")&&(l[b]={}),l=l[b]}const c=i[i.length-1];l[c]=o}findNearestBranchAncestor(i){for(let o=i.length-1;o>=1;o--){const l=i.slice(0,o),c=l.join(".");if(this.branchVersions[c])return{path:l,secret:this.resolveSecret(l)}}return null}writeBranchBlob(i,o){let l=i,c=o;for(;;){const y=this.findNearestBranchAncestor(l);if(!y){this.setSubPayload(l,c);return}const{path:b,secret:B}=y,p=b.join("."),d=O(B),P=this.getSubPayload(b),k=this.branchVersions[p]?.[d]??(typeof P=="string"?P:void 0);let F={};if(k){const j=this.decryptForPath(b,k);j&&typeof j=="object"&&(F=j)}const w=l.slice(b.length);let v=F;for(let j=0;j<w.length-1;j++){const C=w[j];(!v[C]||typeof v[C]!="object")&&(v[C]={}),v=v[C]}v[w[w.length-1]]=c;const _=this.encryptForPath(b,F);this.branchVersions[p]||(this.branchVersions[p]={}),this.branchVersions[p][d]=_,l=b,c=_}}getSubPayload(i){let o=this.payload;for(const l of i){if(!o||typeof o!="object")return;o=o[l]}return o}decryptTree(i,o){if(o==null)return o;if(typeof o=="string"){if(!this.isHexString(o))return o;const c=this.decryptForPath(i,o);return c===null?o:c}if(typeof o!="object")return o;const l=Array.isArray(o)?[]:{};for(const c of Object.keys(o)){const y=[...i,c];l[c]=this.decryptTree(y,o[c])}return l}encryptForPath(i,o){const l=this.resolveSecret(i),c=JSON.stringify(o),y=new TextEncoder().encode(c),b=O(l+":"+i.join(".")),B=this.asciiToBytes(b),p=new Uint8Array(y.length);for(let P=0;P<y.length;P++)p[P]=y[P]^B[P%B.length];let d="";for(let P=0;P<p.length;P++)d+=p[P].toString(16).padStart(2,"0");return d}decryptForPath(i,o){const l=this.resolveSecret(i);try{const c=this.hexToBytes(o),y=O(l+":"+i.join(".")),b=this.asciiToBytes(y),B=new Uint8Array(c.length);for(let d=0;d<c.length;d++)B[d]=c[d]^b[d%b.length];const p=new TextDecoder().decode(B);return JSON.parse(p)}catch{return null}}asciiToBytes(i){return new TextEncoder().encode(i)}hexToBytes(i){const o=i.startsWith("0x")?i.slice(2):i,l=new Uint8Array(o.length/2);for(let c=0;c<l.length;c++)l[c]=parseInt(o.substr(c*2,2),16);return l}isHexString(i){const o=i.startsWith("0x")?i.slice(2):i;return o.length>0&&o.length%2===0&&/^[0-9a-fA-F]+$/.test(o)}export(){return{identityRoot:this.identityRoot,publicKey:this.publicKey,identityHash:this.identityHash,declarations:this.declarations,payload:this.payload}}exportBranch(i){const o=i?i.split(".").filter(Boolean):[],l=o.join("."),c=this.resolveSecret(o),y=O(c),b=this.branchVersions[l]?.[y];if(b){const p=this.decryptForPath(o,b);return this.decryptTree(o,p)}const B=this.getSubPayload(o);if(B!==void 0){if(typeof B=="string"){const p=this.decryptForPath(o,B);return this.decryptTree(o,p)}return this.decryptTree(o,B)}}}K.ME=zt,Object.defineProperty(K,Symbol.toStringTag,{value:"Module"})}));
|
package/dist/src/me.d.ts
CHANGED
|
@@ -15,11 +15,12 @@ export declare class ME {
|
|
|
15
15
|
identityRoot: string;
|
|
16
16
|
publicKey: string;
|
|
17
17
|
identityHash: string;
|
|
18
|
+
blockchain: string;
|
|
18
19
|
payload: any;
|
|
19
20
|
declarations: MeDeclaration[];
|
|
20
21
|
private secrets;
|
|
21
22
|
private branchVersions;
|
|
22
|
-
constructor(username: string, secret: string);
|
|
23
|
+
constructor(username: string, secret: string, blockchain: string);
|
|
23
24
|
/**
|
|
24
25
|
* Create a proxy bound to a specific path, e.g. ["wallet", "income"]
|
|
25
26
|
* The proxy itself is callable (function) and also expandable via property access.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "this.me",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.30",
|
|
4
4
|
"description": ".me is your identity trust through cryptographic signatures.",
|
|
5
5
|
"main": "dist/me.cjs.js",
|
|
6
6
|
"module": "dist/me.es.js",
|
|
@@ -22,14 +22,11 @@
|
|
|
22
22
|
},
|
|
23
23
|
"type": "module",
|
|
24
24
|
"keywords": [
|
|
25
|
-
"
|
|
25
|
+
".me",
|
|
26
26
|
"identity",
|
|
27
27
|
"decentralized",
|
|
28
28
|
"cryptographic",
|
|
29
|
-
"
|
|
30
|
-
"signature",
|
|
31
|
-
"local",
|
|
32
|
-
"monad"
|
|
29
|
+
"signature"
|
|
33
30
|
],
|
|
34
31
|
"repository": {
|
|
35
32
|
"type": "git",
|