this.me 3.0.27 → 3.0.29

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/dist/me.umd.js CHANGED
@@ -1,8 +1,8 @@
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:{}};/**
1
+ (function(K,D){typeof exports=="object"&&typeof module<"u"?D(exports):typeof define=="function"&&define.amd?define(["exports"],D):(K=typeof globalThis<"u"?globalThis:K||self,D(K.Me={}))})(this,(function(K){"use strict";var D=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ne(E){return E&&E.__esModule&&Object.prototype.hasOwnProperty.call(E,"default")?E.default:E}var mt={exports:{}};/**
2
2
  * [js-sha3]{@link https://github.com/emn178/js-sha3}
3
3
  *
4
4
  * @version 0.9.3
5
5
  * @author Chen, Yi-Cyuan [emn178@gmail.com]
6
6
  * @copyright Chen, Yi-Cyuan 2015-2023
7
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"}})}));
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&gt,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&lt,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"})}));
package/dist/src/me.d.ts CHANGED
@@ -1,53 +1,104 @@
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 {
1
+ interface MeDeclaration {
13
2
  key: string;
14
3
  value: any;
15
4
  signature: string;
16
5
  timestamp: number;
17
6
  }
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;
7
+ export type MEProxy = ME & {
8
+ [key: string]: any;
9
+ (...args: any[]): MEProxy;
10
+ };
11
+ export declare class ME {
12
+ [key: string]: any;
13
+ username: string;
29
14
  secret: string;
15
+ identityRoot: string;
30
16
  publicKey: string;
31
- namespace: string;
32
17
  identityHash: string;
18
+ payload: any;
33
19
  declarations: MeDeclaration[];
34
- [key: string]: any;
35
- constructor(secret: string, namespace: string);
20
+ private secrets;
21
+ private branchVersions;
22
+ constructor(username: string, secret: string);
23
+ /**
24
+ * Create a proxy bound to a specific path, e.g. ["wallet", "income"]
25
+ * The proxy itself is callable (function) and also expandable via property access.
26
+ */
27
+ private createProxy;
28
+ /**
29
+ * Handle a call at a given path.
30
+ * Examples:
31
+ * me.wallet.income(200) → set encrypted payload at wallet.income
32
+ * me.wallet.secret("abc123") → set secret for path "wallet"
33
+ * me.wallet.ptr() → return pointer object { __ptr: "wallet" }
34
+ */
35
+ private handleCall;
36
+ /**
37
+ * Secret scope resolution with path:
38
+ * - Find the most specific path that has a secret.
39
+ * - Return both the secret and the path at which it was defined.
40
+ * - If none, fall back to root secret with empty path.
41
+ */
42
+ private resolveSecretWithPath;
43
+ /**
44
+ * Backwards-compatible helper: only return the secret string.
45
+ */
46
+ private resolveSecret;
47
+ /**
48
+ * Encrypt and store the value at the given path inside `payload`.
49
+ *
50
+ * If there is a non-root secret defined for some ancestor path P of `path`,
51
+ * we treat that ancestor path P as the "branch root" and store the ENTIRE
52
+ * subtree under P as ONE encrypted blob at that location.
53
+ *
54
+ * This means that to re-enter that channel you need both:
55
+ * - the full expression for P, and
56
+ * - the secret used at P.
57
+ */
58
+ private ensurePath;
59
+ /**
60
+ * Set a value at a nested path inside `payload`.
61
+ */
62
+ private setSubPayload;
63
+ /**
64
+ * Find the nearest ancestor path that represents an encrypted branch blob.
65
+ */
66
+ private findNearestBranchAncestor;
67
+ /**
68
+ * Write an encrypted branch blob while preserving any encrypted ancestor branches.
69
+ */
70
+ private writeBranchBlob;
71
+ private getSubPayload;
72
+ /**
73
+ * Recursively decrypt a node of the encrypted payload tree.
74
+ */
75
+ private decryptTree;
76
+ /**
77
+ * Encrypt a value (object or primitive) using the secret resolved for the given path.
78
+ * Produces a hex string compatible with decryptForPath().
79
+ */
80
+ private encryptForPath;
36
81
  /**
37
- * Firma genérica de mensajes si se necesita fuera de las declaraciones.
82
+ * Decrypt a single encrypted blob using the secret resolved for the given path.
38
83
  */
39
- sign(message: string): string;
84
+ private decryptForPath;
85
+ private asciiToBytes;
86
+ private hexToBytes;
87
+ private isHexString;
40
88
  /**
41
- * Exportar el snapshot de ME para mandarlo a Cleaker (ledger, graph, etc.).
89
+ * Export the encrypted payload and declaration metadata.
42
90
  */
43
91
  export(): {
44
92
  identityRoot: string;
45
93
  publicKey: string;
46
- namespace: string;
47
94
  identityHash: string;
48
95
  declarations: MeDeclaration[];
96
+ payload: any;
49
97
  };
50
- ptr(declaration: MeDeclaration): {
51
- __pointer: string;
52
- };
98
+ /**
99
+ * Export and decrypt a specific branch using the currently active secret
100
+ * resolved for that path.
101
+ */
102
+ exportBranch(path: string): any;
53
103
  }
104
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "this.me",
3
- "version": "3.0.27",
3
+ "version": "3.0.29",
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",
@@ -14,7 +14,11 @@
14
14
  "scripts": {
15
15
  "dev": "vite",
16
16
  "build": "vite build",
17
- "preview": "vite preview"
17
+ "preview": "vite preview",
18
+ "test:esm": "node tests/test-esm.mjs",
19
+ "test:cjs": "node tests/test-cjs.cjs",
20
+ "test:ts": "tsc --noEmit",
21
+ "test:build": "npm run build && npm run test:esm && npm run test:cjs && npm run test:ts"
18
22
  },
19
23
  "type": "module",
20
24
  "keywords": [
package/dist/me.cjs.js DELETED
@@ -1,8 +0,0 @@
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;
@@ -1 +0,0 @@
1
- export {};