@actioncodes/protocol 2.0.10 → 2.0.11
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/ActionCodesProtocol.d.ts +1 -1
- package/dist/ActionCodesProtocol.d.ts.map +1 -1
- package/dist/adapters/SolanaAdapter.d.ts.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +8 -8
- package/dist/index.js +2 -2
- package/dist/index.js.map +8 -8
- package/dist/strategy/DelegationStrategy.d.ts +2 -2
- package/dist/strategy/DelegationStrategy.d.ts.map +1 -1
- package/dist/strategy/WalletStrategy.d.ts +2 -2
- package/dist/strategy/WalletStrategy.d.ts.map +1 -1
- package/dist/types.d.ts +1 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/canonical.d.ts +1 -1
- package/dist/utils/canonical.d.ts.map +1 -1
- package/dist/utils/crypto.d.ts +0 -1
- package/dist/utils/crypto.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
class w8{}/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function D0(Q){return Q instanceof Uint8Array||ArrayBuffer.isView(Q)&&Q.constructor.name==="Uint8Array"}function J8(Q,$=""){if(!Number.isSafeInteger(Q)||Q<0){let q=$&&`"${$}" `;throw Error(`${q}expected integer >= 0, got ${Q}`)}}function y(Q,$,q=""){let Z=D0(Q),X=Q?.length,J=$!==void 0;if(!Z||J&&X!==$){let Y=q&&`"${q}" `,z=J?` of length ${$}`:"",U=Z?`length=${X}`:`type=${typeof Q}`;throw Error(Y+"expected Uint8Array"+z+", got "+U)}return Q}function n(Q){if(typeof Q!=="function"||typeof Q.create!=="function")throw Error("Hash must wrapped by utils.createHasher");J8(Q.outputLen),J8(Q.blockLen)}function A(Q,$=!0){if(Q.destroyed)throw Error("Hash instance has been destroyed");if($&&Q.finished)throw Error("Hash#digest() has already been called")}function _8(Q,$){y(Q,void 0,"digestInto() output");let q=$.outputLen;if(Q.length<q)throw Error('"digestInto() output" expected to be of length >='+q)}function M(...Q){for(let $=0;$<Q.length;$++)Q[$].fill(0)}function Y8(Q){return new DataView(Q.buffer,Q.byteOffset,Q.byteLength)}function T(Q,$){return Q<<32-$|Q>>>$}function p8(Q,$={}){let q=(X,J)=>Q(J).update(X).digest(),Z=Q(void 0);return q.outputLen=Z.outputLen,q.blockLen=Z.blockLen,q.create=(X)=>Q(X),Object.assign(q,$),Object.freeze(q)}var S8=(Q)=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,Q])});function A8(Q,$,q){return Q&$^~Q&q}function u8(Q,$,q){return Q&$^Q&q^$&q}class R8{blockLen;outputLen;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(Q,$,q,Z){this.blockLen=Q,this.outputLen=$,this.padOffset=q,this.isLE=Z,this.buffer=new Uint8Array(Q),this.view=Y8(this.buffer)}update(Q){A(this),y(Q);let{view:$,buffer:q,blockLen:Z}=this,X=Q.length;for(let J=0;J<X;){let Y=Math.min(Z-this.pos,X-J);if(Y===Z){let z=Y8(Q);for(;Z<=X-J;J+=Z)this.process(z,J);continue}if(q.set(Q.subarray(J,J+Y),this.pos),this.pos+=Y,J+=Y,this.pos===Z)this.process($,0),this.pos=0}return this.length+=Q.length,this.roundClean(),this}digestInto(Q){A(this),_8(Q,this),this.finished=!0;let{buffer:$,view:q,blockLen:Z,isLE:X}=this,{pos:J}=this;if($[J++]=128,M(this.buffer.subarray(J)),this.padOffset>Z-J)this.process(q,0),J=0;for(let R=J;R<Z;R++)$[R]=0;q.setBigUint64(Z-8,BigInt(this.length*8),X),this.process(q,0);let Y=Y8(Q),z=this.outputLen;if(z%4)throw Error("_sha2: outputLen must be aligned to 32bit");let U=z/4,K=this.get();if(U>K.length)throw Error("_sha2: outputLen bigger than state");for(let R=0;R<U;R++)Y.setUint32(4*R,K[R],X)}digest(){let{buffer:Q,outputLen:$}=this;this.digestInto(Q);let q=Q.slice(0,$);return this.destroy(),q}_cloneInto(Q){Q||=new this.constructor,Q.set(...this.get());let{blockLen:$,buffer:q,length:Z,finished:X,destroyed:J,pos:Y}=this;if(Q.destroyed=J,Q.finished=X,Q.length=Z,Q.pos=Y,Z%$)Q.buffer.set(q);return Q}clone(){return this._cloneInto()}}var E=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),x=Uint32Array.from([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]),F=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),w=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var z8=BigInt(4294967295),g8=BigInt(32);function G0(Q,$=!1){if($)return{h:Number(Q&z8),l:Number(Q>>g8&z8)};return{h:Number(Q>>g8&z8)|0,l:Number(Q&z8)|0}}function c8(Q,$=!1){let q=Q.length,Z=new Uint32Array(q),X=new Uint32Array(q);for(let J=0;J<q;J++){let{h:Y,l:z}=G0(Q[J],$);[Z[J],X[J]]=[Y,z]}return[Z,X]}var k8=(Q,$,q)=>Q>>>q,L8=(Q,$,q)=>Q<<32-q|$>>>q,p=(Q,$,q)=>Q>>>q|$<<32-q,S=(Q,$,q)=>Q<<32-q|$>>>q,r=(Q,$,q)=>Q<<64-q|$>>>q-32,s=(Q,$,q)=>Q>>>q-32|$<<64-q;function V(Q,$,q,Z){let X=($>>>0)+(Z>>>0);return{h:Q+q+(X/4294967296|0)|0,l:X|0}}var h8=(Q,$,q)=>(Q>>>0)+($>>>0)+(q>>>0),d8=(Q,$,q,Z)=>$+q+Z+(Q/4294967296|0)|0,l8=(Q,$,q,Z)=>(Q>>>0)+($>>>0)+(q>>>0)+(Z>>>0),n8=(Q,$,q,Z,X)=>$+q+Z+X+(Q/4294967296|0)|0,r8=(Q,$,q,Z,X)=>(Q>>>0)+($>>>0)+(q>>>0)+(Z>>>0)+(X>>>0),s8=(Q,$,q,Z,X,J)=>$+q+Z+X+J+(Q/4294967296|0)|0;var v0=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),B=new Uint32Array(64);class P8 extends R8{constructor(Q){super(64,Q,8,!1)}get(){let{A:Q,B:$,C:q,D:Z,E:X,F:J,G:Y,H:z}=this;return[Q,$,q,Z,X,J,Y,z]}set(Q,$,q,Z,X,J,Y,z){this.A=Q|0,this.B=$|0,this.C=q|0,this.D=Z|0,this.E=X|0,this.F=J|0,this.G=Y|0,this.H=z|0}process(Q,$){for(let R=0;R<16;R++,$+=4)B[R]=Q.getUint32($,!1);for(let R=16;R<64;R++){let j=B[R-15],W=B[R-2],v=T(j,7)^T(j,18)^j>>>3,O=T(W,17)^T(W,19)^W>>>10;B[R]=O+B[R-7]+v+B[R-16]|0}let{A:q,B:Z,C:X,D:J,E:Y,F:z,G:U,H:K}=this;for(let R=0;R<64;R++){let j=T(Y,6)^T(Y,11)^T(Y,25),W=K+j+A8(Y,z,U)+v0[R]+B[R]|0,O=(T(q,2)^T(q,13)^T(q,22))+u8(q,Z,X)|0;K=U,U=z,z=Y,Y=J+W|0,J=X,X=Z,Z=q,q=W+O|0}q=q+this.A|0,Z=Z+this.B|0,X=X+this.C|0,J=J+this.D|0,Y=Y+this.E|0,z=z+this.F|0,U=U+this.G|0,K=K+this.H|0,this.set(q,Z,X,J,Y,z,U,K)}roundClean(){M(B)}destroy(){this.set(0,0,0,0,0,0,0,0),M(this.buffer)}}class i8 extends P8{A=E[0]|0;B=E[1]|0;C=E[2]|0;D=E[3]|0;E=E[4]|0;F=E[5]|0;G=E[6]|0;H=E[7]|0;constructor(){super(32)}}class F0 extends P8{A=x[0]|0;B=x[1]|0;C=x[2]|0;D=x[3]|0;E=x[4]|0;F=x[5]|0;G=x[6]|0;H=x[7]|0;constructor(){super(28)}}var o8=(()=>c8(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map((Q)=>BigInt(Q))))(),w0=(()=>o8[0])(),k0=(()=>o8[1])(),f=new Uint32Array(80),H=new Uint32Array(80);class i extends R8{constructor(Q){super(128,Q,16,!1)}get(){let{Ah:Q,Al:$,Bh:q,Bl:Z,Ch:X,Cl:J,Dh:Y,Dl:z,Eh:U,El:K,Fh:R,Fl:j,Gh:W,Gl:v,Hh:O,Hl:P}=this;return[Q,$,q,Z,X,J,Y,z,U,K,R,j,W,v,O,P]}set(Q,$,q,Z,X,J,Y,z,U,K,R,j,W,v,O,P){this.Ah=Q|0,this.Al=$|0,this.Bh=q|0,this.Bl=Z|0,this.Ch=X|0,this.Cl=J|0,this.Dh=Y|0,this.Dl=z|0,this.Eh=U|0,this.El=K|0,this.Fh=R|0,this.Fl=j|0,this.Gh=W|0,this.Gl=v|0,this.Hh=O|0,this.Hl=P|0}process(Q,$){for(let D=0;D<16;D++,$+=4)f[D]=Q.getUint32($),H[D]=Q.getUint32($+=4);for(let D=16;D<80;D++){let C=f[D-15]|0,m=H[D-15]|0,G8=p(C,m,1)^p(C,m,8)^k8(C,m,7),O8=S(C,m,1)^S(C,m,8)^L8(C,m,7),I=f[D-2]|0,b=H[D-2]|0,Z8=p(I,b,19)^r(I,b,61)^k8(I,b,6),v8=S(I,b,19)^s(I,b,61)^L8(I,b,6),X8=l8(O8,v8,H[D-7],H[D-16]),F8=n8(X8,G8,Z8,f[D-7],f[D-16]);f[D]=F8|0,H[D]=X8|0}let{Ah:q,Al:Z,Bh:X,Bl:J,Ch:Y,Cl:z,Dh:U,Dl:K,Eh:R,El:j,Fh:W,Fl:v,Gh:O,Gl:P,Hh:G,Hl:l}=this;for(let D=0;D<80;D++){let C=p(R,j,14)^p(R,j,18)^r(R,j,41),m=S(R,j,14)^S(R,j,18)^s(R,j,41),G8=R&W^~R&O,O8=j&v^~j&P,I=r8(l,m,O8,k0[D],H[D]),b=s8(I,G,C,G8,w0[D],f[D]),Z8=I|0,v8=p(q,Z,28)^r(q,Z,34)^r(q,Z,39),X8=S(q,Z,28)^s(q,Z,34)^s(q,Z,39),F8=q&X^q&Y^X&Y,W0=Z&J^Z&z^J&z;G=O|0,l=P|0,O=W|0,P=v|0,W=R|0,v=j|0,{h:R,l:j}=V(U|0,K|0,b|0,Z8|0),U=Y|0,K=z|0,Y=X|0,z=J|0,X=q|0,J=Z|0;let H8=h8(Z8,X8,W0);q=d8(H8,b,v8,F8),Z=H8|0}({h:q,l:Z}=V(this.Ah|0,this.Al|0,q|0,Z|0)),{h:X,l:J}=V(this.Bh|0,this.Bl|0,X|0,J|0),{h:Y,l:z}=V(this.Ch|0,this.Cl|0,Y|0,z|0),{h:U,l:K}=V(this.Dh|0,this.Dl|0,U|0,K|0),{h:R,l:j}=V(this.Eh|0,this.El|0,R|0,j|0),{h:W,l:v}=V(this.Fh|0,this.Fl|0,W|0,v|0),{h:O,l:P}=V(this.Gh|0,this.Gl|0,O|0,P|0),{h:G,l}=V(this.Hh|0,this.Hl|0,G|0,l|0),this.set(q,Z,X,J,Y,z,U,K,R,j,W,v,O,P,G,l)}roundClean(){M(f,H)}destroy(){M(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class L0 extends i{Ah=w[0]|0;Al=w[1]|0;Bh=w[2]|0;Bl=w[3]|0;Ch=w[4]|0;Cl=w[5]|0;Dh=w[6]|0;Dl=w[7]|0;Eh=w[8]|0;El=w[9]|0;Fh=w[10]|0;Fl=w[11]|0;Gh=w[12]|0;Gl=w[13]|0;Hh=w[14]|0;Hl=w[15]|0;constructor(){super(64)}}class P0 extends i{Ah=F[0]|0;Al=F[1]|0;Bh=F[2]|0;Bl=F[3]|0;Ch=F[4]|0;Cl=F[5]|0;Dh=F[6]|0;Dl=F[7]|0;Eh=F[8]|0;El=F[9]|0;Fh=F[10]|0;Fl=F[11]|0;Gh=F[12]|0;Gl=F[13]|0;Hh=F[14]|0;Hl=F[15]|0;constructor(){super(48)}}var k=Uint32Array.from([2352822216,424955298,1944164710,2312950998,502970286,855612546,1738396948,1479516111,258812777,2077511080,2011393907,79989058,1067287976,1780299464,286451373,2446758561]),L=Uint32Array.from([573645204,4230739756,2673172387,3360449730,596883563,1867755857,2520282905,1497426621,2519219938,2827943907,3193839141,1401305490,721525244,746961066,246885852,2177182882]);class M0 extends i{Ah=k[0]|0;Al=k[1]|0;Bh=k[2]|0;Bl=k[3]|0;Ch=k[4]|0;Cl=k[5]|0;Dh=k[6]|0;Dl=k[7]|0;Eh=k[8]|0;El=k[9]|0;Fh=k[10]|0;Fl=k[11]|0;Gh=k[12]|0;Gl=k[13]|0;Hh=k[14]|0;Hl=k[15]|0;constructor(){super(28)}}class T0 extends i{Ah=L[0]|0;Al=L[1]|0;Bh=L[2]|0;Bl=L[3]|0;Ch=L[4]|0;Cl=L[5]|0;Dh=L[6]|0;Dl=L[7]|0;Eh=L[8]|0;El=L[9]|0;Fh=L[10]|0;Fl=L[11]|0;Gh=L[12]|0;Gl=L[13]|0;Hh=L[14]|0;Hl=L[15]|0;constructor(){super(32)}}var U8=p8(()=>new i8,S8(1));class M8{oHash;iHash;blockLen;outputLen;finished=!1;destroyed=!1;constructor(Q,$){if(n(Q),y($,void 0,"key"),this.iHash=Q.create(),typeof this.iHash.update!=="function")throw Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let q=this.blockLen,Z=new Uint8Array(q);Z.set($.length>q?Q.create().update($).digest():$);for(let X=0;X<Z.length;X++)Z[X]^=54;this.iHash.update(Z),this.oHash=Q.create();for(let X=0;X<Z.length;X++)Z[X]^=106;this.oHash.update(Z),M(Z)}update(Q){return A(this),this.iHash.update(Q),this}digestInto(Q){A(this),y(Q,this.outputLen,"output"),this.finished=!0,this.iHash.digestInto(Q),this.oHash.update(Q),this.oHash.digestInto(Q),this.destroy()}digest(){let Q=new Uint8Array(this.oHash.outputLen);return this.digestInto(Q),Q}_cloneInto(Q){Q||=Object.create(Object.getPrototypeOf(this),{});let{oHash:$,iHash:q,finished:Z,destroyed:X,blockLen:J,outputLen:Y}=this;return Q=Q,Q.finished=Z,Q.destroyed=X,Q.blockLen=J,Q.outputLen=Y,Q.oHash=$._cloneInto(Q.oHash),Q.iHash=q._cloneInto(Q.iHash),Q}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}var u=(Q,$,q)=>new M8(Q,$).update(q).digest();u.create=(Q,$)=>new M8(Q,$);function V0(Q,$,q){if(n(Q),q===void 0)q=new Uint8Array(Q.outputLen);return u(Q,q,$)}var T8=Uint8Array.of(0),a8=Uint8Array.of();function I0(Q,$,q,Z=32){n(Q),J8(Z,"length");let X=Q.outputLen;if(Z>255*X)throw Error("Length must be <= 255*HashLen");let J=Math.ceil(Z/X);if(q===void 0)q=a8;else y(q,void 0,"info");let Y=new Uint8Array(J*X),z=u.create(Q,$),U=z._cloneInto(),K=new Uint8Array(z.outputLen);for(let R=0;R<J;R++)T8[0]=R+1,U.update(R===0?a8:K).update(q).update(T8).digestInto(K),Y.set(K,X*R),z._cloneInto(U);return z.destroy(),U.destroy(),M(K,T8),Y.slice(0,Z)}var e8=(Q,$,q,Z,X)=>I0(Q,V0(Q,$,q),Z,X);function g(Q){if(typeof Q==="string")return new TextEncoder().encode(Q);return Q}function K8(Q){return U8(g(Q))}function o(Q,$){return u(U8,g(Q),g($))}function n0(Q,$,{salt:q,info:Z}={}){let X=q?g(q):new Uint8Array(32),J=g(Q),Y=Z?g(Z):new Uint8Array(0);return e8(U8,J,X,Y,$)}var t8="0123456789ABCDEFGHJKMNPQRSTVWXYZ";function r0(Q){let $=0,q=0,Z="";for(let X=0;X<Q.length;X++){q=q<<8|Q[X],$+=8;while($>=5)Z+=t8[q>>>$-5&31],$-=5}if($>0)Z+=t8[q<<5-$&31];return Z}function V8(Q,$){let q=Math.ceil($/8),Z=new Uint8Array(q),X=Math.min(q,Q.length);Z.set(Q.subarray(0,X));let J=q*8-$;if(J>0){let Y=255<<J;Z[q-1]=Z[q-1]&Y}return Z}function I8(Q,$){if(Q.length===0)throw Error("digestToDigits: empty digest");let q="",Z=Q[Q.length-1]&15;for(let X=0;q.length<$;X++){let J=(Z+X*4)%Math.max(1,Q.length-4),U=(((Q[J]&127)<<24|Q[J+1]<<16|Q[J+2]<<8|Q[J+3])%1e9).toString().padStart(9,"0");q+=U}return q.slice(0,$)}function Q0(Q){let $=K8(Q);return Array.from($).map((q)=>q.toString(16).padStart(2,"0")).join("")}function s0(){let Q=new Uint8Array(32);return crypto.getRandomValues(Q),btoa(String.fromCharCode(...Q))}var o0=1,a0="actioncodes",e0="actioncodes-revoke";function c(Q){let $=JSON.stringify({id:"actioncodes",ver:1,pubkey:Q.pubkey,windowStart:Q.windowStart,...Q.secret&&{secret:Q.secret}});return new TextEncoder().encode($)}function b8(Q){let $=JSON.stringify({id:"actioncodes-revoke",ver:1,pubkey:Q.pubkey,codeHash:Q.codeHash,windowStart:Q.windowStart});return new TextEncoder().encode($)}function a(Q,$,q){let Z=Math.floor(Date.now()/$)*$;return c({pubkey:Q,windowStart:Z,secret:q})}function E8(Q){let $=JSON.stringify({walletPubkey:Q.walletPubkey,delegatedPubkey:Q.delegatedPubkey,expiresAt:Q.expiresAt});return new TextEncoder().encode($)}var x8="NFC",e=256,C8=6,m8=24,QQ=8,$Q="0123456789",qQ=["solana"];var y8="actioncodes:";function B8(Q){let $=$0(Q);if($.int!=null)N8($.int);let q=[`ver=${$.ver}`,`id=${encodeURIComponent($.id)}`,`int=${encodeURIComponent($.int)}`];if($.p!=null&&Object.keys($.p).length>0){let X=JSON.stringify($.p);N8(X),q.push(`p=${encodeURIComponent(X)}`)}let Z=y8+q.join("&");return q0(Z),Z}function j8(Q){if(!Q.startsWith(y8))throw Error("protocol meta must start with actioncodes:");let q=Q.slice(y8.length).split("&").filter(Boolean),Z=new Map;for(let W of q){let[v,O]=W.split("=",2);if(!v)continue;let P=O!=null?decodeURIComponent(O):"";Z.set(v,P)}let X=Z.get("ver"),J=Z.get("id"),Y=Z.get("int"),z=Z.get("p");if(X==null||J==null||Y==null)throw Error("protocol meta missing required fields ver or id or int");let U=Number(X);if(!Number.isInteger(U)||U<=0)throw Error("protocol meta ver must be positive integer");let K;if(z!=null&&z!=="")try{if(K=JSON.parse(z),typeof K!=="object"||K===null||Array.isArray(K))throw Error("protocol meta p must be a JSON object")}catch{throw Error("protocol meta p must be valid JSON")}let R=$0({ver:U,id:J,int:Y,p:K});if(R.int!=null)N8(R.int);if(R.p!=null)N8(JSON.stringify(R.p));if([...Z.keys()].filter((W)=>W!=="ver"&&W!=="id"&&W!=="int"&&W!=="p").length>0)throw Error("protocol meta contains unsupported keys");return q0(B8(R)),R}function JQ(Q){try{return j8(Q),{ok:!0}}catch($){return{ok:!1,reason:String($)}}}function $0(Q){let $=Q.id.normalize(x8).trim(),q={ver:Q.ver,id:$,int:Q.int};if(Q.int!=null)q.int=Q.int.normalize(x8).trim();if(Q.p!=null)q.p=Q.p;return q}function q0(Q){if(new TextEncoder().encode(Q).length>e)throw Error(`protocol meta exceeds ${e} bytes`)}function N8(Q){if(new TextEncoder().encode(Q).length>e)throw Error(`protocol meta params exceed ${e} bytes`)}var b0;((G)=>{G.EXPIRED_CODE="EXPIRED_CODE";G.INVALID_CODE="INVALID_CODE";G.INVALID_CODE_FORMAT="INVALID_CODE_FORMAT";G.INVALID_SIGNATURE="INVALID_SIGNATURE";G.MISSING_META="MISSING_META";G.INVALID_META_FORMAT="INVALID_META_FORMAT";G.META_MISMATCH="META_MISMATCH";G.META_TOO_LARGE="META_TOO_LARGE";G.TRANSACTION_NOT_SIGNED_BY_INTENDED_OWNER="TRANSACTION_NOT_SIGNED_BY_INTENDED_OWNER";G.INVALID_TRANSACTION_FORMAT="INVALID_TRANSACTION_FORMAT";G.INVALID_PUBKEY_FORMAT="INVALID_PUBKEY_FORMAT";G.INVALID_INPUT="INVALID_INPUT";G.MISSING_REQUIRED_FIELD="MISSING_REQUIRED_FIELD";G.CRYPTO_ERROR="CRYPTO_ERROR";G.INVALID_DIGEST="INVALID_DIGEST";G.INVALID_ADAPTER="INVALID_ADAPTER"})(b0||={});class N extends Error{code;details;constructor(Q,$,q){super($);this.code=Q;this.details=q;this.name="ProtocolError"}static expiredCode(Q,$,q){return new Z0(Q,$,q)}static invalidCode(Q,$){return new N("INVALID_CODE",`Invalid code: expected '${Q}', got '${$}'`,{expected:Q,actual:$})}static invalidCodeFormat(Q,$){return new U0(Q,$)}static invalidSignature(Q){return new z0(Q)}static missingMeta(){return new X0}static invalidMetaFormat(Q){return new N("INVALID_META_FORMAT",`Invalid protocol meta format: ${Q}`,{reason:Q})}static metaMismatch(Q,$,q){return new J0(Q,$,q)}static metaTooLarge(Q,$){return new N("META_TOO_LARGE",`Protocol meta too large: ${$} bytes (max: ${Q})`,{maxBytes:Q,actualBytes:$})}static transactionNotSignedByIntendedOwner(Q,$){return new Y0(Q,$)}static invalidTransactionFormat(Q){return new N("INVALID_TRANSACTION_FORMAT",`Invalid transaction format: ${Q}`,{reason:Q})}static invalidPubkeyFormat(Q,$){return new R0(Q,$)}static invalidInput(Q,$,q){return new N("INVALID_INPUT",`Invalid ${Q}: ${q}`,{field:Q,value:$,reason:q})}static missingRequiredField(Q){return new N("MISSING_REQUIRED_FIELD",`Missing required field: ${Q}`,{field:Q})}static cryptoError(Q,$){return new N("CRYPTO_ERROR",`Crypto error in ${Q}: ${$}`,{operation:Q,reason:$})}static invalidDigest(Q){return new N("INVALID_DIGEST",`Invalid digest: ${Q}`,{reason:Q})}static invalidAdapter(Q){return new K0(Q)}static create(Q,$,q){return new N(Q,$,q)}}class Z0 extends N{constructor(Q,$,q){super("EXPIRED_CODE",`Action code '${Q}' expired at ${$}, current time: ${q}`,{code:Q,expiresAt:$,currentTime:q});this.name="ExpiredCodeError"}}class X0 extends N{constructor(){super("MISSING_META","Transaction does not contain valid protocol meta");this.name="MissingMetaError"}}class J0 extends N{constructor(Q,$,q){super("META_MISMATCH",`Meta ${q} mismatch: expected '${Q}', got '${$}'`,{expected:Q,actual:$,field:q});this.name="MetaMismatchError"}}class Y0 extends N{constructor(Q,$){super("TRANSACTION_NOT_SIGNED_BY_INTENDED_OWNER",`Transaction not signed by intended owner '${Q}'. Actual signers: [${$.join(", ")}]`,{intended:Q,actualSigners:$});this.name="TransactionNotSignedByIntendedOwnerError"}}class R0 extends N{constructor(Q,$){super("INVALID_PUBKEY_FORMAT",`Invalid public key format '${Q}': ${$}`,{pubkey:Q,reason:$});this.name="InvalidPubkeyFormatError"}}class z0 extends N{constructor(Q){super("INVALID_SIGNATURE",`Invalid signature: ${Q}`,{reason:Q});this.name="InvalidSignatureError"}}class U0 extends N{constructor(Q,$){super("INVALID_CODE_FORMAT",`Invalid code format '${Q}': ${$}`,{code:Q,reason:$});this.name="InvalidCodeFormatError"}}class K0 extends N{constructor(Q){super("INVALID_ADAPTER",`Invalid adapter: ${Q}`,{adapter:Q});this.name="InvalidAdapterError"}}import N0 from"bs58";class t{config;constructor(Q){this.config=Q}generateCode(Q,$,q){let Z=Q,X=JSON.parse(new TextDecoder().decode(Z)),J=X.pubkey,Y=X.windowStart,z=q,U;if($){let O=N0.decode($);U=o(O,Z)}else if(z)U=o(z,Z);else U=K8(Z);let K=Math.max(C8,Math.min(m8,this.config.codeLength)),R=8*Math.ceil(K/2),j=V8(U,R);return{actionCode:{code:I8(j,K),pubkey:J,timestamp:Y,expiresAt:Y+this.config.ttlMs,...$&&{signature:$},...z&&{secret:z}},canonicalMessage:Z}}validateCode(Q){let $=Date.now();if($>Q.expiresAt+(this.config.clockSkewMs??0))throw N.expiredCode(Q.code,Q.expiresAt,$);let q=c({pubkey:Q.pubkey,windowStart:Q.timestamp,secret:Q.secret}),Z;if(Q.signature){let z=N0.decode(Q.signature);Z=o(z,q)}else if(Q.secret)Z=o(Q.secret,q);else Z=K8(q);let X=Math.max(C8,Math.min(m8,this.config.codeLength)),J=V8(Z,8*Math.ceil(X/2)),Y=I8(J,X);if(Y!==Q.code)throw N.invalidCode(Y,Q.code)}getCanonicalMessageParts(Q,$){return a(Q,this.config.ttlMs,$)}}class f8{walletStrategy;config;constructor(Q){this.config=Q,this.walletStrategy=new t(Q)}generateDelegatedCode(Q,$){this.validateDelegationProof(Q);let q=a(Q.delegatedPubkey,this.config.ttlMs);return{actionCode:{...this.walletStrategy.generateCode(q,$).actionCode,delegationProof:Q,delegatedSignature:$}}}validateDelegatedCode(Q,$){if(this.walletStrategy.validateCode(Q),this.validateDelegationProof($),Q.delegationProof.walletPubkey!==$.walletPubkey)throw Error("Action code wallet pubkey does not match delegation proof");if(Q.delegationProof.delegatedPubkey!==$.delegatedPubkey)throw Error("Action code delegated pubkey does not match delegation proof");if(Q.delegationProof.expiresAt!==$.expiresAt)throw Error("Action code delegation expiration does not match delegation proof");if(Q.delegationProof.signature!==$.signature)throw Error("Action code delegation signature does not match delegation proof");if(!Q.delegatedSignature)throw Error("Delegated signature is required")}validateDelegationProof(Q){if(!Q.walletPubkey)throw Error("Wallet pubkey is required");if(!Q.delegatedPubkey)throw Error("Delegated pubkey is required");if(!Q.expiresAt)throw Error("Expiration time is required");if(!Q.signature)throw Error("Delegation signature is required");if(Q.expiresAt<Date.now())throw Error("Delegation proof has expired")}getWalletStrategy(){return this.walletStrategy}getCanonicalMessageParts(Q,$){return a(Q,this.config.ttlMs,$)}}import _ from"tweetnacl";import h from"bs58";import{PublicKey as j0,Transaction as d,VersionedTransaction as W8,TransactionInstruction as E0,MessageV0 as Q8}from"@solana/web3.js";import{createMemoInstruction as x0,MEMO_PROGRAM_ID as $8}from"@solana/spl-memo";var D8="solana";class q8 extends w8{normalizePubkey(Q){if(typeof Q==="string")return new j0(Q);return Q}verifyWithWallet(Q){if(Q.chain!==D8)return!1;if(!Q.message||!Q.message.pubkey||!Q.walletSignature)return!1;try{let $=c(Q.message),q=this.normalizePubkey(Q.message.pubkey),Z=h.decode(Q.walletSignature),X=q.toBytes();if(Z.length!==64||X.length!==32)return!1;return _.sign.detached.verify($,Z,X)}catch{return!1}}verifyWithDelegation(Q){if(Q.chain!==D8)return!1;if(!Q.message.pubkey||!Q.delegatedSignature||!Q.delegationProof)return!1;let $=Q.delegationProof;if(!$.walletPubkey||!$.delegatedPubkey||!$.expiresAt||!$.signature)return!1;if($.delegatedPubkey!==Q.message.pubkey)return!1;if($.expiresAt<Date.now())return!1;try{let q=E8($),Z=this.normalizePubkey($.walletPubkey),X=h.decode($.signature),J=Z.toBytes();if(X.length!==64||J.length!==32)return!1;if(!_.sign.detached.verify(q,X,J))return!1;let z=c(Q.message),U=this.normalizePubkey($.delegatedPubkey),K=h.decode(Q.delegatedSignature),R=U.toBytes();if(K.length!==64||R.length!==32)return!1;return _.sign.detached.verify(z,K,R)}catch{return!1}}verifyRevokeWithWallet(Q){if(Q.chain!==D8)return!1;if(!Q.message||!Q.message.pubkey||!Q.walletSignature)return!1;try{let $=b8(Q.message),q=this.normalizePubkey(Q.message.pubkey),Z=h.decode(Q.walletSignature),X=q.toBytes();if(Z.length!==64||X.length!==32)return!1;return _.sign.detached.verify($,Z,X)}catch{return!1}}verifyRevokeWithDelegation(Q){if(Q.chain!==D8)return!1;if(!Q.message||!Q.message.pubkey||!Q.delegatedSignature||!Q.delegationProof)return!1;let $=Q.delegationProof;if(!$.walletPubkey||!$.delegatedPubkey||!$.expiresAt||!$.signature)return!1;if($.delegatedPubkey!==Q.message.pubkey)return!1;if($.expiresAt<Date.now())return!1;try{let q=E8($),Z=this.normalizePubkey($.walletPubkey),X=h.decode($.signature),J=Z.toBytes();if(X.length!==64||J.length!==32)return!1;if(!_.sign.detached.verify(q,X,J))return!1;let z=b8(Q.message),U=this.normalizePubkey($.delegatedPubkey),K=h.decode(Q.delegatedSignature),R=U.toBytes();if(K.length!==64||R.length!==32)return!1;return _.sign.detached.verify(z,K,R)}catch{return!1}}static createProtocolMetaIx(Q){let $=B8(Q);return x0($)}getProtocolMeta(Q){try{let $=this.deserializeTransaction(Q);for(let q of this.getMemoInstructions($)){let Z=q.data;try{let X=new TextDecoder().decode(Z);if(j8(X))return X}catch{}}return null}catch{return null}}deserializeTransaction(Q){try{let $=W8.deserialize(Buffer.from(Q,"base64"));if($.message instanceof Q8)return $;else return d.from(Buffer.from(Q,"base64"))}catch{try{return d.from(Buffer.from(Q,"base64"))}catch{throw N.invalidTransactionFormat("Invalid base64 transaction format")}}}parseMeta(Q){let $=this.getProtocolMeta(Q);if(!$)return null;return j8($)}getMemoInstructions(Q){if(Q instanceof d)return Q.instructions.filter(($)=>$.programId.equals($8));else{let q=Q.message;if(q instanceof Q8){let Z=[];for(let X of q.compiledInstructions){let J=q.staticAccountKeys[X.programIdIndex];if(J&&J.equals($8)){let Y=X.accountKeyIndexes.map((z)=>({pubkey:q.staticAccountKeys[z],isSigner:!1,isWritable:!1}));Z.push(new E0({keys:Y,programId:J,data:X.data}))}}return Z}return[]}}verifyTransactionMatchesCode(Q,$){let q=Date.now();if(q>Q.expiresAt)throw N.expiredCode(Q.code,Q.expiresAt,q);let Z=this.parseMeta($);if(!Z)throw N.missingMeta();if(Z.ver!==2)throw N.metaMismatch("2",String(Z.ver),"ver");let X=Q0(Q.code);if(Z.id!==X)throw N.metaMismatch(X,Z.id,"id");if(Z.int!==Q.pubkey)throw N.metaMismatch(Q.pubkey,Z.int,"int")}verifyTransactionSignedByIntentOwner(Q){let $=this.parseMeta(Q);if(!$)throw N.missingMeta();let q=$.int;if(!q)throw N.invalidMetaFormat("Missing 'int' (intendedFor) field");let Z;try{Z=new j0(q)}catch{throw N.invalidPubkeyFormat(q,"Invalid public key format")}let X=this.deserializeTransaction(Q),J=[];if(X instanceof d){if(!X.signatures.some((z)=>{if(!z.signature)return!1;return J.push(z.publicKey.toString()),z.publicKey.equals(Z)}))throw N.transactionNotSignedByIntendedOwner(q,J);return}if(X instanceof W8){let Y=X.message;if(Y instanceof Q8){let z=Y.header.numRequiredSignatures;for(let U=0;U<z;U++){let K=Y.staticAccountKeys[U];if(K){if(J.push(K.toString()),K.equals(Z))return}}throw N.transactionNotSignedByIntendedOwner(q,J)}}throw N.invalidTransactionFormat("Unsupported transaction format")}static attachProtocolMeta(Q,$){if(new q8().getProtocolMeta(Q))throw N.invalidTransactionFormat("Transaction already contains protocol meta. Cannot attach additional protocol meta.");let X=q8.createProtocolMetaIx($);try{let J=W8.deserialize(Buffer.from(Q,"base64"));if(J.message instanceof Q8){let Y=J.message,z=[...Y.staticAccountKeys];if(!z.some((W)=>W.equals($8)))z.push($8);let K={programIdIndex:z.findIndex((W)=>W.equals($8)),accountKeyIndexes:[],data:X.data},R=new Q8({header:Y.header,staticAccountKeys:z,recentBlockhash:Y.recentBlockhash,compiledInstructions:[...Y.compiledInstructions,K],addressTableLookups:Y.addressTableLookups}),j=new W8(R);return j.signatures=J.signatures,Buffer.from(j.serialize()).toString("base64")}else{let Y=d.from(Buffer.from(Q,"base64"));return Y.add(X),Buffer.from(Y.serialize({requireAllSignatures:!1})).toString("base64")}}catch{try{let J=d.from(Buffer.from(Q,"base64"));return J.add(X),Buffer.from(J.serialize({requireAllSignatures:!1})).toString("base64")}catch{throw N.invalidTransactionFormat("Invalid base64 transaction format")}}}}class C0{config;adapters={};_walletStrategy;_delegationStrategy;constructor(Q){this.config=Q;this.adapters.solana=new q8,this._walletStrategy=new t(Q),this._delegationStrategy=new f8(Q)}getConfig(){return this.config}registerAdapter(Q,$){this.adapters[Q]=$}getAdapter(Q){return this.adapters[Q]}get adapter(){return{solana:this.adapters.solana}}get walletStrategy(){return this._walletStrategy}get delegationStrategy(){return this._delegationStrategy}generateCode(Q,$,q,Z){if(Q==="wallet"){if(!q)throw N.invalidSignature("Missing signature over canonical message");return this.walletStrategy.generateCode($,q,Z)}else{if(!q)throw N.invalidSignature("Missing delegated signature");return this.delegationStrategy.generateDelegatedCode($,q)}}validateCode(Q,$,q){if(Q==="wallet"){if(this.walletStrategy.validateCode($),!q)return;let Z=q,X=this.getAdapter(Z.chain);if(!X)throw N.invalidAdapter(Z.chain);if(!X.verifyWithWallet({...Z,message:{pubkey:$.pubkey,windowStart:$.timestamp}}))throw Error("Signature verification failed")}else{let Z=q;this.delegationStrategy.validateDelegatedCode($,Z.delegationProof);let X=this.getAdapter(Z.chain);if(!X)throw N.invalidAdapter(Z.chain);if(!X.verifyWithDelegation({...Z,message:{pubkey:$.pubkey,windowStart:$.timestamp}}))throw Error("Signature verification failed")}}}export{JQ as validateProtocolMetaFormat,V8 as truncateBits,K8 as sha256,E8 as serializeDelegationProof,b8 as serializeCanonicalRevoke,c as serializeCanonical,j8 as parseProtocolMeta,o as hmacSha256,n0 as hkdfSha256,a as getCanonicalMessageParts,s0 as generateRandomSecret,I8 as digestToDigits,Q0 as codeHash,B8 as buildProtocolMeta,r0 as base32EncodeCrockford,t as WalletStrategy,Y0 as TransactionNotSignedByIntendedOwnerError,q8 as SolanaAdapter,qQ as SUPPORTED_CHAINS,y8 as SCHEME,b0 as ProtocolErrorCode,N as ProtocolError,x8 as PROTOCOL_NORMALIZATION,e as PROTOCOL_META_MAX_BYTES,X0 as MissingMetaError,J0 as MetaMismatchError,z0 as InvalidSignatureError,R0 as InvalidPubkeyFormatError,U0 as InvalidCodeFormatError,K0 as InvalidAdapterError,Z0 as ExpiredCodeError,f8 as DelegationStrategy,C8 as CODE_MIN_LENGTH,m8 as CODE_MAX_LENGTH,QQ as CODE_DEFAULT_LENGTH,$Q as CODE_CHARSET_DIGITS,e0 as CANONICAL_REVOKE_MESSAGE_PREFIX,o0 as CANONICAL_MESSAGE_VERSION,a0 as CANONICAL_MESSAGE_PREFIX,w8 as BaseChainAdapter,C0 as ActionCodesProtocol,D8 as ADAPTER_CHAIN_NAME};
|
1
|
+
class G8{}/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function O0(Q){return Q instanceof Uint8Array||ArrayBuffer.isView(Q)&&Q.constructor.name==="Uint8Array"}function J8(Q,X=""){if(!Number.isSafeInteger(Q)||Q<0){let $=X&&`"${X}" `;throw Error(`${$}expected integer >= 0, got ${Q}`)}}function B(Q,X,$=""){let Z=O0(Q),q=Q?.length,J=X!==void 0;if(!Z||J&&q!==X){let R=$&&`"${$}" `,N=J?` of length ${X}`:"",U=Z?`length=${q}`:`type=${typeof Q}`;throw Error(R+"expected Uint8Array"+N+", got "+U)}return Q}function s(Q){if(typeof Q!=="function"||typeof Q.create!=="function")throw Error("Hash must wrapped by utils.createHasher");J8(Q.outputLen),J8(Q.blockLen)}function A(Q,X=!0){if(Q.destroyed)throw Error("Hash instance has been destroyed");if(X&&Q.finished)throw Error("Hash#digest() has already been called")}function S8(Q,X){B(Q,void 0,"digestInto() output");let $=X.outputLen;if(Q.length<$)throw Error('"digestInto() output" expected to be of length >='+$)}function V(...Q){for(let X=0;X<Q.length;X++)Q[X].fill(0)}function R8(Q){return new DataView(Q.buffer,Q.byteOffset,Q.byteLength)}function T(Q,X){return Q<<32-X|Q>>>X}function H8(Q,X={}){let $=(q,J)=>Q(J).update(q).digest(),Z=Q(void 0);return $.outputLen=Z.outputLen,$.blockLen=Z.blockLen,$.create=(q)=>Q(q),Object.assign($,X),Object.freeze($)}var _8=(Q)=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,Q])});function f8(Q,X,$){return Q&X^~Q&$}function A8(Q,X,$){return Q&X^Q&$^X&$}class Y8{blockLen;outputLen;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(Q,X,$,Z){this.blockLen=Q,this.outputLen=X,this.padOffset=$,this.isLE=Z,this.buffer=new Uint8Array(Q),this.view=R8(this.buffer)}update(Q){A(this),B(Q);let{view:X,buffer:$,blockLen:Z}=this,q=Q.length;for(let J=0;J<q;){let R=Math.min(Z-this.pos,q-J);if(R===Z){let N=R8(Q);for(;Z<=q-J;J+=Z)this.process(N,J);continue}if($.set(Q.subarray(J,J+R),this.pos),this.pos+=R,J+=R,this.pos===Z)this.process(X,0),this.pos=0}return this.length+=Q.length,this.roundClean(),this}digestInto(Q){A(this),S8(Q,this),this.finished=!0;let{buffer:X,view:$,blockLen:Z,isLE:q}=this,{pos:J}=this;if(X[J++]=128,V(this.buffer.subarray(J)),this.padOffset>Z-J)this.process($,0),J=0;for(let Y=J;Y<Z;Y++)X[Y]=0;$.setBigUint64(Z-8,BigInt(this.length*8),q),this.process($,0);let R=R8(Q),N=this.outputLen;if(N%4)throw Error("_sha2: outputLen must be aligned to 32bit");let U=N/4,j=this.get();if(U>j.length)throw Error("_sha2: outputLen bigger than state");for(let Y=0;Y<U;Y++)R.setUint32(4*Y,j[Y],q)}digest(){let{buffer:Q,outputLen:X}=this;this.digestInto(Q);let $=Q.slice(0,X);return this.destroy(),$}_cloneInto(Q){Q||=new this.constructor,Q.set(...this.get());let{blockLen:X,buffer:$,length:Z,finished:q,destroyed:J,pos:R}=this;if(Q.destroyed=J,Q.finished=q,Q.length=Z,Q.pos=R,Z%X)Q.buffer.set($);return Q}clone(){return this._cloneInto()}}var x=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),E=Uint32Array.from([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]),G=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),F=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var N8=BigInt(4294967295),u8=BigInt(32);function W0(Q,X=!1){if(X)return{h:Number(Q&N8),l:Number(Q>>u8&N8)};return{h:Number(Q>>u8&N8)|0,l:Number(Q&N8)|0}}function g8(Q,X=!1){let $=Q.length,Z=new Uint32Array($),q=new Uint32Array($);for(let J=0;J<$;J++){let{h:R,l:N}=W0(Q[J],X);[Z[J],q[J]]=[R,N]}return[Z,q]}var F8=(Q,X,$)=>Q>>>$,w8=(Q,X,$)=>Q<<32-$|X>>>$,H=(Q,X,$)=>Q>>>$|X<<32-$,_=(Q,X,$)=>Q<<32-$|X>>>$,i=(Q,X,$)=>Q<<64-$|X>>>$-32,r=(Q,X,$)=>Q>>>$-32|X<<64-$;function I(Q,X,$,Z){let q=(X>>>0)+(Z>>>0);return{h:Q+$+(q/4294967296|0)|0,l:q|0}}var c8=(Q,X,$)=>(Q>>>0)+(X>>>0)+($>>>0),h8=(Q,X,$,Z)=>X+$+Z+(Q/4294967296|0)|0,d8=(Q,X,$,Z)=>(Q>>>0)+(X>>>0)+($>>>0)+(Z>>>0),n8=(Q,X,$,Z,q)=>X+$+Z+q+(Q/4294967296|0)|0,l8=(Q,X,$,Z,q)=>(Q>>>0)+(X>>>0)+($>>>0)+(Z>>>0)+(q>>>0),s8=(Q,X,$,Z,q,J)=>X+$+Z+q+J+(Q/4294967296|0)|0;var G0=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),P=new Uint32Array(64);class k8 extends Y8{constructor(Q){super(64,Q,8,!1)}get(){let{A:Q,B:X,C:$,D:Z,E:q,F:J,G:R,H:N}=this;return[Q,X,$,Z,q,J,R,N]}set(Q,X,$,Z,q,J,R,N){this.A=Q|0,this.B=X|0,this.C=$|0,this.D=Z|0,this.E=q|0,this.F=J|0,this.G=R|0,this.H=N|0}process(Q,X){for(let Y=0;Y<16;Y++,X+=4)P[Y]=Q.getUint32(X,!1);for(let Y=16;Y<64;Y++){let v=P[Y-15],K=P[Y-2],w=T(v,7)^T(v,18)^v>>>3,D=T(K,17)^T(K,19)^K>>>10;P[Y]=D+P[Y-7]+w+P[Y-16]|0}let{A:$,B:Z,C:q,D:J,E:R,F:N,G:U,H:j}=this;for(let Y=0;Y<64;Y++){let v=T(R,6)^T(R,11)^T(R,25),K=j+v+f8(R,N,U)+G0[Y]+P[Y]|0,D=(T($,2)^T($,13)^T($,22))+A8($,Z,q)|0;j=U,U=N,N=R,R=J+K|0,J=q,q=Z,Z=$,$=K+D|0}$=$+this.A|0,Z=Z+this.B|0,q=q+this.C|0,J=J+this.D|0,R=R+this.E|0,N=N+this.F|0,U=U+this.G|0,j=j+this.H|0,this.set($,Z,q,J,R,N,U,j)}roundClean(){V(P)}destroy(){this.set(0,0,0,0,0,0,0,0),V(this.buffer)}}class i8 extends k8{A=x[0]|0;B=x[1]|0;C=x[2]|0;D=x[3]|0;E=x[4]|0;F=x[5]|0;G=x[6]|0;H=x[7]|0;constructor(){super(32)}}class F0 extends k8{A=E[0]|0;B=E[1]|0;C=E[2]|0;D=E[3]|0;E=E[4]|0;F=E[5]|0;G=E[6]|0;H=E[7]|0;constructor(){super(28)}}var r8=(()=>g8(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map((Q)=>BigInt(Q))))(),w0=(()=>r8[0])(),k0=(()=>r8[1])(),p=new Uint32Array(80),S=new Uint32Array(80);class a extends Y8{constructor(Q){super(128,Q,16,!1)}get(){let{Ah:Q,Al:X,Bh:$,Bl:Z,Ch:q,Cl:J,Dh:R,Dl:N,Eh:U,El:j,Fh:Y,Fl:v,Gh:K,Gl:w,Hh:D,Hl:L}=this;return[Q,X,$,Z,q,J,R,N,U,j,Y,v,K,w,D,L]}set(Q,X,$,Z,q,J,R,N,U,j,Y,v,K,w,D,L){this.Ah=Q|0,this.Al=X|0,this.Bh=$|0,this.Bl=Z|0,this.Ch=q|0,this.Cl=J|0,this.Dh=R|0,this.Dl=N|0,this.Eh=U|0,this.El=j|0,this.Fh=Y|0,this.Fl=v|0,this.Gh=K|0,this.Gl=w|0,this.Hh=D|0,this.Hl=L|0}process(Q,X){for(let O=0;O<16;O++,X+=4)p[O]=Q.getUint32(X),S[O]=Q.getUint32(X+=4);for(let O=16;O<80;O++){let y=p[O-15]|0,m=S[O-15]|0,K8=H(y,m,1)^H(y,m,8)^F8(y,m,7),O8=_(y,m,1)^_(y,m,8)^w8(y,m,7),b=p[O-2]|0,C=S[O-2]|0,Z8=H(b,C,19)^i(b,C,61)^F8(b,C,6),W8=_(b,C,19)^r(b,C,61)^w8(b,C,6),q8=d8(O8,W8,S[O-7],S[O-16]),D8=n8(q8,K8,Z8,p[O-7],p[O-16]);p[O]=D8|0,S[O]=q8|0}let{Ah:$,Al:Z,Bh:q,Bl:J,Ch:R,Cl:N,Dh:U,Dl:j,Eh:Y,El:v,Fh:K,Fl:w,Gh:D,Gl:L,Hh:W,Hl:l}=this;for(let O=0;O<80;O++){let y=H(Y,v,14)^H(Y,v,18)^i(Y,v,41),m=_(Y,v,14)^_(Y,v,18)^r(Y,v,41),K8=Y&K^~Y&D,O8=v&w^~v&L,b=l8(l,m,O8,k0[O],S[O]),C=s8(b,W,y,K8,w0[O],p[O]),Z8=b|0,W8=H($,Z,28)^i($,Z,34)^i($,Z,39),q8=_($,Z,28)^r($,Z,34)^r($,Z,39),D8=$&q^$&R^q&R,K0=Z&J^Z&N^J&N;W=D|0,l=L|0,D=K|0,L=w|0,K=Y|0,w=v|0,{h:Y,l:v}=I(U|0,j|0,C|0,Z8|0),U=R|0,j=N|0,R=q|0,N=J|0,q=$|0,J=Z|0;let p8=c8(Z8,q8,K0);$=h8(p8,C,W8,D8),Z=p8|0}({h:$,l:Z}=I(this.Ah|0,this.Al|0,$|0,Z|0)),{h:q,l:J}=I(this.Bh|0,this.Bl|0,q|0,J|0),{h:R,l:N}=I(this.Ch|0,this.Cl|0,R|0,N|0),{h:U,l:j}=I(this.Dh|0,this.Dl|0,U|0,j|0),{h:Y,l:v}=I(this.Eh|0,this.El|0,Y|0,v|0),{h:K,l:w}=I(this.Fh|0,this.Fl|0,K|0,w|0),{h:D,l:L}=I(this.Gh|0,this.Gl|0,D|0,L|0),{h:W,l}=I(this.Hh|0,this.Hl|0,W|0,l|0),this.set($,Z,q,J,R,N,U,j,Y,v,K,w,D,L,W,l)}roundClean(){V(p,S)}destroy(){V(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class M0 extends a{Ah=F[0]|0;Al=F[1]|0;Bh=F[2]|0;Bl=F[3]|0;Ch=F[4]|0;Cl=F[5]|0;Dh=F[6]|0;Dl=F[7]|0;Eh=F[8]|0;El=F[9]|0;Fh=F[10]|0;Fl=F[11]|0;Gh=F[12]|0;Gl=F[13]|0;Hh=F[14]|0;Hl=F[15]|0;constructor(){super(64)}}class L0 extends a{Ah=G[0]|0;Al=G[1]|0;Bh=G[2]|0;Bl=G[3]|0;Ch=G[4]|0;Cl=G[5]|0;Dh=G[6]|0;Dl=G[7]|0;Eh=G[8]|0;El=G[9]|0;Fh=G[10]|0;Fl=G[11]|0;Gh=G[12]|0;Gl=G[13]|0;Hh=G[14]|0;Hl=G[15]|0;constructor(){super(48)}}var k=Uint32Array.from([2352822216,424955298,1944164710,2312950998,502970286,855612546,1738396948,1479516111,258812777,2077511080,2011393907,79989058,1067287976,1780299464,286451373,2446758561]),M=Uint32Array.from([573645204,4230739756,2673172387,3360449730,596883563,1867755857,2520282905,1497426621,2519219938,2827943907,3193839141,1401305490,721525244,746961066,246885852,2177182882]);class V0 extends a{Ah=k[0]|0;Al=k[1]|0;Bh=k[2]|0;Bl=k[3]|0;Ch=k[4]|0;Cl=k[5]|0;Dh=k[6]|0;Dl=k[7]|0;Eh=k[8]|0;El=k[9]|0;Fh=k[10]|0;Fl=k[11]|0;Gh=k[12]|0;Gl=k[13]|0;Hh=k[14]|0;Hl=k[15]|0;constructor(){super(28)}}class T0 extends a{Ah=M[0]|0;Al=M[1]|0;Bh=M[2]|0;Bl=M[3]|0;Ch=M[4]|0;Cl=M[5]|0;Dh=M[6]|0;Dl=M[7]|0;Eh=M[8]|0;El=M[9]|0;Fh=M[10]|0;Fl=M[11]|0;Gh=M[12]|0;Gl=M[13]|0;Hh=M[14]|0;Hl=M[15]|0;constructor(){super(32)}}var z8=H8(()=>new i8,_8(1));class M8{oHash;iHash;blockLen;outputLen;finished=!1;destroyed=!1;constructor(Q,X){if(s(Q),B(X,void 0,"key"),this.iHash=Q.create(),typeof this.iHash.update!=="function")throw Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let $=this.blockLen,Z=new Uint8Array($);Z.set(X.length>$?Q.create().update(X).digest():X);for(let q=0;q<Z.length;q++)Z[q]^=54;this.iHash.update(Z),this.oHash=Q.create();for(let q=0;q<Z.length;q++)Z[q]^=106;this.oHash.update(Z),V(Z)}update(Q){return A(this),this.iHash.update(Q),this}digestInto(Q){A(this),B(Q,this.outputLen,"output"),this.finished=!0,this.iHash.digestInto(Q),this.oHash.update(Q),this.oHash.digestInto(Q),this.destroy()}digest(){let Q=new Uint8Array(this.oHash.outputLen);return this.digestInto(Q),Q}_cloneInto(Q){Q||=Object.create(Object.getPrototypeOf(this),{});let{oHash:X,iHash:$,finished:Z,destroyed:q,blockLen:J,outputLen:R}=this;return Q=Q,Q.finished=Z,Q.destroyed=q,Q.blockLen=J,Q.outputLen=R,Q.oHash=X._cloneInto(Q.oHash),Q.iHash=$._cloneInto(Q.iHash),Q}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}var u=(Q,X,$)=>new M8(Q,X).update($).digest();u.create=(Q,X)=>new M8(Q,X);function I0(Q,X,$){if(s(Q),$===void 0)$=new Uint8Array(Q.outputLen);return u(Q,$,X)}var L8=Uint8Array.of(0),a8=Uint8Array.of();function b0(Q,X,$,Z=32){s(Q),J8(Z,"length");let q=Q.outputLen;if(Z>255*q)throw Error("Length must be <= 255*HashLen");let J=Math.ceil(Z/q);if($===void 0)$=a8;else B($,void 0,"info");let R=new Uint8Array(J*q),N=u.create(Q,X),U=N._cloneInto(),j=new Uint8Array(N.outputLen);for(let Y=0;Y<J;Y++)L8[0]=Y+1,U.update(Y===0?a8:j).update($).update(L8).digestInto(j),R.set(j,q*Y),N._cloneInto(U);return N.destroy(),U.destroy(),V(j,L8),R.slice(0,Z)}var e8=(Q,X,$,Z,q)=>b0(Q,I0(Q,X,$),Z,q);function g(Q){if(typeof Q==="string")return new TextEncoder().encode(Q);return Q}function C0(Q){return z8(g(Q))}function V8(Q,X){return u(z8,g(Q),g(X))}function s0(Q,X,{salt:$,info:Z}={}){let q=$?g($):new Uint8Array(32),J=g(Q),R=Z?g(Z):new Uint8Array(0);return e8(z8,J,q,R,X)}var t8="0123456789ABCDEFGHJKMNPQRSTVWXYZ";function i0(Q){let X=0,$=0,Z="";for(let q=0;q<Q.length;q++){$=$<<8|Q[q],X+=8;while(X>=5)Z+=t8[$>>>X-5&31],X-=5}if(X>0)Z+=t8[$<<5-X&31];return Z}function T8(Q,X){let $=Math.ceil(X/8),Z=new Uint8Array($),q=Math.min($,Q.length);Z.set(Q.subarray(0,q));let J=$*8-X;if(J>0){let R=255<<J;Z[$-1]=Z[$-1]&R}return Z}function I8(Q,X){if(Q.length===0)throw Error("digestToDigits: empty digest");let $="",Z=Q[Q.length-1]&15;for(let q=0;$.length<X;q++){let J=(Z+q*4)%Math.max(1,Q.length-4),U=(((Q[J]&127)<<24|Q[J+1]<<16|Q[J+2]<<8|Q[J+3])%1e9).toString().padStart(9,"0");$+=U}return $.slice(0,X)}function o8(Q){let X=C0(Q);return Array.from(X).map(($)=>$.toString(16).padStart(2,"0")).join("")}var a0=1,e0="actioncodes",t0="actioncodes-revoke";function c(Q){let X=JSON.stringify({id:"actioncodes",ver:1,pubkey:Q.pubkey,windowStart:Q.windowStart});return new TextEncoder().encode(X)}function b8(Q){let X=JSON.stringify({id:"actioncodes-revoke",ver:1,pubkey:Q.pubkey,codeHash:Q.codeHash,windowStart:Q.windowStart});return new TextEncoder().encode(X)}function e(Q,X){let $=Math.floor(Date.now()/X)*X;return c({pubkey:Q,windowStart:$})}function C8(Q){let X=JSON.stringify({walletPubkey:Q.walletPubkey,delegatedPubkey:Q.delegatedPubkey,expiresAt:Q.expiresAt,chain:Q.chain});return new TextEncoder().encode(X)}var x8="NFC",t=256,E8=6,y8=24,QQ=8,XQ="0123456789",$Q=["solana"];var m8="actioncodes:";function B8(Q){let X=Q0(Q);if(X.int!=null)U8(X.int);let $=[`ver=${X.ver}`,`id=${encodeURIComponent(X.id)}`,`int=${encodeURIComponent(X.int)}`];if(X.p!=null&&Object.keys(X.p).length>0){let q=JSON.stringify(X.p);U8(q),$.push(`p=${encodeURIComponent(q)}`)}let Z=m8+$.join("&");return X0(Z),Z}function j8(Q){if(!Q.startsWith(m8))throw Error("protocol meta must start with actioncodes:");let $=Q.slice(m8.length).split("&").filter(Boolean),Z=new Map;for(let K of $){let[w,D]=K.split("=",2);if(!w)continue;let L=D!=null?decodeURIComponent(D):"";Z.set(w,L)}let q=Z.get("ver"),J=Z.get("id"),R=Z.get("int"),N=Z.get("p");if(q==null||J==null||R==null)throw Error("protocol meta missing required fields ver or id or int");let U=Number(q);if(!Number.isInteger(U)||U<=0)throw Error("protocol meta ver must be positive integer");let j;if(N!=null&&N!=="")try{if(j=JSON.parse(N),typeof j!=="object"||j===null||Array.isArray(j))throw Error("protocol meta p must be a JSON object")}catch{throw Error("protocol meta p must be valid JSON")}let Y=Q0({ver:U,id:J,int:R,p:j});if(Y.int!=null)U8(Y.int);if(Y.p!=null)U8(JSON.stringify(Y.p));if([...Z.keys()].filter((K)=>K!=="ver"&&K!=="id"&&K!=="int"&&K!=="p").length>0)throw Error("protocol meta contains unsupported keys");return X0(B8(Y)),Y}function JQ(Q){try{return j8(Q),{ok:!0}}catch(X){return{ok:!1,reason:String(X)}}}function Q0(Q){let X=Q.id.normalize(x8).trim(),$={ver:Q.ver,id:X,int:Q.int};if(Q.int!=null)$.int=Q.int.normalize(x8).trim();if(Q.p!=null)$.p=Q.p;return $}function X0(Q){if(new TextEncoder().encode(Q).length>t)throw Error(`protocol meta exceeds ${t} bytes`)}function U8(Q){if(new TextEncoder().encode(Q).length>t)throw Error(`protocol meta params exceed ${t} bytes`)}var x0;((W)=>{W.EXPIRED_CODE="EXPIRED_CODE";W.INVALID_CODE="INVALID_CODE";W.INVALID_CODE_FORMAT="INVALID_CODE_FORMAT";W.INVALID_SIGNATURE="INVALID_SIGNATURE";W.MISSING_META="MISSING_META";W.INVALID_META_FORMAT="INVALID_META_FORMAT";W.META_MISMATCH="META_MISMATCH";W.META_TOO_LARGE="META_TOO_LARGE";W.TRANSACTION_NOT_SIGNED_BY_INTENDED_OWNER="TRANSACTION_NOT_SIGNED_BY_INTENDED_OWNER";W.INVALID_TRANSACTION_FORMAT="INVALID_TRANSACTION_FORMAT";W.INVALID_PUBKEY_FORMAT="INVALID_PUBKEY_FORMAT";W.INVALID_INPUT="INVALID_INPUT";W.MISSING_REQUIRED_FIELD="MISSING_REQUIRED_FIELD";W.CRYPTO_ERROR="CRYPTO_ERROR";W.INVALID_DIGEST="INVALID_DIGEST";W.INVALID_ADAPTER="INVALID_ADAPTER"})(x0||={});class z extends Error{code;details;constructor(Q,X,$){super(X);this.code=Q;this.details=$;this.name="ProtocolError"}static expiredCode(Q,X,$){return new $0(Q,X,$)}static invalidCode(Q,X){return new z("INVALID_CODE",`Invalid code: expected '${Q}', got '${X}'`,{expected:Q,actual:X})}static invalidCodeFormat(Q,X){return new N0(Q,X)}static invalidSignature(Q){return new Y0(Q)}static missingMeta(){return new Z0}static invalidMetaFormat(Q){return new z("INVALID_META_FORMAT",`Invalid protocol meta format: ${Q}`,{reason:Q})}static metaMismatch(Q,X,$){return new q0(Q,X,$)}static metaTooLarge(Q,X){return new z("META_TOO_LARGE",`Protocol meta too large: ${X} bytes (max: ${Q})`,{maxBytes:Q,actualBytes:X})}static transactionNotSignedByIntendedOwner(Q,X){return new J0(Q,X)}static invalidTransactionFormat(Q){return new z("INVALID_TRANSACTION_FORMAT",`Invalid transaction format: ${Q}`,{reason:Q})}static invalidPubkeyFormat(Q,X){return new R0(Q,X)}static invalidInput(Q,X,$){return new z("INVALID_INPUT",`Invalid ${Q}: ${$}`,{field:Q,value:X,reason:$})}static missingRequiredField(Q){return new z("MISSING_REQUIRED_FIELD",`Missing required field: ${Q}`,{field:Q})}static cryptoError(Q,X){return new z("CRYPTO_ERROR",`Crypto error in ${Q}: ${X}`,{operation:Q,reason:X})}static invalidDigest(Q){return new z("INVALID_DIGEST",`Invalid digest: ${Q}`,{reason:Q})}static invalidAdapter(Q){return new z0(Q)}static create(Q,X,$){return new z(Q,X,$)}}class $0 extends z{constructor(Q,X,$){super("EXPIRED_CODE",`Action code '${Q}' expired at ${X}, current time: ${$}`,{code:Q,expiresAt:X,currentTime:$});this.name="ExpiredCodeError"}}class Z0 extends z{constructor(){super("MISSING_META","Transaction does not contain valid protocol meta");this.name="MissingMetaError"}}class q0 extends z{constructor(Q,X,$){super("META_MISMATCH",`Meta ${$} mismatch: expected '${Q}', got '${X}'`,{expected:Q,actual:X,field:$});this.name="MetaMismatchError"}}class J0 extends z{constructor(Q,X){super("TRANSACTION_NOT_SIGNED_BY_INTENDED_OWNER",`Transaction not signed by intended owner '${Q}'. Actual signers: [${X.join(", ")}]`,{intended:Q,actualSigners:X});this.name="TransactionNotSignedByIntendedOwnerError"}}class R0 extends z{constructor(Q,X){super("INVALID_PUBKEY_FORMAT",`Invalid public key format '${Q}': ${X}`,{pubkey:Q,reason:X});this.name="InvalidPubkeyFormatError"}}class Y0 extends z{constructor(Q){super("INVALID_SIGNATURE",`Invalid signature: ${Q}`,{reason:Q});this.name="InvalidSignatureError"}}class N0 extends z{constructor(Q,X){super("INVALID_CODE_FORMAT",`Invalid code format '${Q}': ${X}`,{code:Q,reason:X});this.name="InvalidCodeFormatError"}}class z0 extends z{constructor(Q){super("INVALID_ADAPTER",`Invalid adapter: ${Q}`,{adapter:Q});this.name="InvalidAdapterError"}}import U0 from"bs58";class o{config;constructor(Q){this.config=Q}generateCode(Q,X){let $=Q,Z=JSON.parse(new TextDecoder().decode($)),q=Z.pubkey,J=Z.windowStart,R=U0.decode(X),N=V8(R,$),U=Math.max(E8,Math.min(y8,this.config.codeLength)),j=8*Math.ceil(U/2),Y=T8(N,j);return{actionCode:{code:I8(Y,U),pubkey:q,timestamp:J,expiresAt:J+this.config.ttlMs,signature:X},canonicalMessage:$}}validateCode(Q){let X=Date.now();if(X>Q.expiresAt+(this.config.clockSkewMs??0))throw z.expiredCode(Q.code,Q.expiresAt,X);let $=c({pubkey:Q.pubkey,windowStart:Q.timestamp});if(!Q.signature)throw z.missingRequiredField("signature");let Z=U0.decode(Q.signature),q=V8(Z,$),J=Math.max(E8,Math.min(y8,this.config.codeLength)),R=T8(q,8*Math.ceil(J/2)),N=I8(R,J);if(N!==Q.code)throw z.invalidCode(N,Q.code)}getCanonicalMessageParts(Q){return e(Q,this.config.ttlMs)}}import{PublicKey as j0}from"@solana/web3.js";class P8{walletStrategy;config;constructor(Q){this.config=Q,this.walletStrategy=new o(Q)}generateDelegatedCode(Q,X){this.validateDelegationProof(Q);let $=e(Q.delegatedPubkey,this.config.ttlMs);return{actionCode:{...this.walletStrategy.generateCode($,X).actionCode,delegationProof:Q,delegatedSignature:X}}}validateDelegatedCode(Q,X){if(this.walletStrategy.validateCode(Q),this.validateDelegationProof(X),Q.delegationProof.walletPubkey!==X.walletPubkey)throw z.invalidInput("walletPubkey",Q.delegationProof.walletPubkey,"Action code wallet pubkey does not match delegation proof");if(Q.delegationProof.delegatedPubkey!==X.delegatedPubkey)throw z.invalidInput("delegatedPubkey",Q.delegationProof.delegatedPubkey,"Invalid delegatedPubkey: Action code delegated pubkey does not match delegation proof");if(Q.delegationProof.expiresAt!==X.expiresAt)throw z.invalidInput("expiresAt",Q.delegationProof.expiresAt,"Action code delegation expiration does not match delegation proof");if(Q.delegationProof.signature!==X.signature)throw z.invalidInput("signature",Q.delegationProof.signature,"Invalid signature: Action code delegation signature does not match delegation proof");if(!Q.delegatedSignature)throw z.missingRequiredField("delegatedSignature")}validateDelegationProof(Q){if(!Q.walletPubkey||typeof Q.walletPubkey!=="string")throw z.invalidInput("walletPubkey",Q.walletPubkey,"Wallet pubkey is required and must be a string");try{new j0(Q.walletPubkey)}catch{throw z.invalidInput("walletPubkey",Q.walletPubkey,"Invalid wallet pubkey format")}if(!Q.delegatedPubkey||typeof Q.delegatedPubkey!=="string")throw z.invalidInput("delegatedPubkey",Q.delegatedPubkey,"Delegated pubkey is required and must be a string");try{new j0(Q.delegatedPubkey)}catch{throw z.invalidInput("delegatedPubkey",Q.delegatedPubkey,"Invalid delegated pubkey format")}if(!Q.chain||typeof Q.chain!=="string")throw z.invalidInput("chain",Q.chain,"Chain is required and must be a string");if(Q.chain.length===0||Q.chain.length>50)throw z.invalidInput("chain",Q.chain,"Chain must be between 1 and 50 characters");if(!/^[a-z0-9-]+$/.test(Q.chain))throw z.invalidInput("chain",Q.chain,"Chain contains invalid characters (only lowercase letters, numbers, and hyphens allowed)");if(typeof Q.expiresAt!=="number"||!Number.isInteger(Q.expiresAt))throw z.invalidInput("expiresAt",Q.expiresAt,"Expiration time must be a valid integer timestamp");if(Q.expiresAt<=0)throw z.invalidInput("expiresAt",Q.expiresAt,"Expiration time must be positive");let X=Date.now(),$=31536000000;if(Q.expiresAt>X+$)throw z.invalidInput("expiresAt",Q.expiresAt,"Expiration time is too far in the future");if(Q.expiresAt<X)throw z.expiredCode("Delegation proof has expired",Q.expiresAt,X);if(!Q.signature||typeof Q.signature!=="string")throw z.invalidInput("signature",Q.signature,"Delegation signature is required and must be a string");if(Q.signature.length===0||Q.signature.length>200)throw z.invalidInput("signature",Q.signature,"Delegation signature must be between 1 and 200 characters")}getWalletStrategy(){return this.walletStrategy}getCanonicalMessageParts(Q){return e(Q,this.config.ttlMs)}}import f from"tweetnacl";import h from"bs58";import{PublicKey as v0,Transaction as d,VersionedTransaction as v8,TransactionInstruction as E0,MessageV0 as Q8}from"@solana/web3.js";import{createMemoInstruction as y0,MEMO_PROGRAM_ID as X8}from"@solana/spl-memo";var n="solana";class $8 extends G8{normalizePubkey(Q){if(typeof Q==="string")return new v0(Q);return Q}verifyWithWallet(Q){if(Q.chain!==n)return!1;if(!Q.message||!Q.message.pubkey||!Q.walletSignature)return!1;try{let X=c(Q.message),$=this.normalizePubkey(Q.message.pubkey),Z=h.decode(Q.walletSignature),q=$.toBytes();if(Z.length!==64||q.length!==32)return!1;return f.sign.detached.verify(X,Z,q)}catch{return!1}}verifyWithDelegation(Q){if(Q.chain!==n)return!1;if(!Q.message.pubkey||!Q.delegatedSignature||!Q.delegationProof)return!1;let X=Q.delegationProof;if(!X.walletPubkey||!X.delegatedPubkey||!X.chain||!X.expiresAt||!X.signature)return!1;if(X.chain!==n)return!1;if(X.delegatedPubkey!==Q.message.pubkey)return!1;if(X.expiresAt<Date.now())return!1;try{let $=C8(X),Z=this.normalizePubkey(X.walletPubkey),q=h.decode(X.signature),J=Z.toBytes(),R=c(Q.message),N=this.normalizePubkey(X.delegatedPubkey),U=h.decode(Q.delegatedSignature),j=N.toBytes();if(q.length!==64||J.length!==32)return!1;if(U.length!==64||j.length!==32)return!1;let Y=f.sign.detached.verify($,q,J),v=f.sign.detached.verify(R,U,j);return Y&&v}catch{return!1}}verifyRevokeWithWallet(Q){if(Q.chain!==n)return!1;if(!Q.message||!Q.message.pubkey||!Q.walletSignature)return!1;try{let X=b8(Q.message),$=this.normalizePubkey(Q.message.pubkey),Z=h.decode(Q.walletSignature),q=$.toBytes();if(Z.length!==64||q.length!==32)return!1;return f.sign.detached.verify(X,Z,q)}catch{return!1}}verifyRevokeWithDelegation(Q){if(Q.chain!==n)return!1;if(!Q.message||!Q.message.pubkey||!Q.delegatedSignature||!Q.delegationProof)return!1;let X=Q.delegationProof;if(!X.walletPubkey||!X.delegatedPubkey||!X.chain||!X.expiresAt||!X.signature)return!1;if(X.chain!==n)return!1;if(X.delegatedPubkey!==Q.message.pubkey)return!1;if(X.expiresAt<Date.now())return!1;try{let $=C8(X),Z=this.normalizePubkey(X.walletPubkey),q=h.decode(X.signature),J=Z.toBytes();if(q.length!==64||J.length!==32)return!1;if(!f.sign.detached.verify($,q,J))return!1;let N=b8(Q.message),U=this.normalizePubkey(X.delegatedPubkey),j=h.decode(Q.delegatedSignature),Y=U.toBytes();if(j.length!==64||Y.length!==32)return!1;return f.sign.detached.verify(N,j,Y)}catch{return!1}}static createProtocolMetaIx(Q){let X=B8(Q);return y0(X)}getProtocolMeta(Q){try{let X=this.deserializeTransaction(Q);for(let $ of this.getMemoInstructions(X)){let Z=$.data;try{let q=new TextDecoder().decode(Z);if(j8(q))return q}catch{}}return null}catch{return null}}deserializeTransaction(Q){try{let X=v8.deserialize(Buffer.from(Q,"base64"));if(X.message instanceof Q8)return X;else return d.from(Buffer.from(Q,"base64"))}catch{try{return d.from(Buffer.from(Q,"base64"))}catch{throw z.invalidTransactionFormat("Invalid base64 transaction format")}}}parseMeta(Q){let X=this.getProtocolMeta(Q);if(!X)return null;return j8(X)}getMemoInstructions(Q){if(Q instanceof d)return Q.instructions.filter((X)=>X.programId.equals(X8));else{let $=Q.message;if($ instanceof Q8){let Z=[];for(let q of $.compiledInstructions){let J=$.staticAccountKeys[q.programIdIndex];if(J&&J.equals(X8)){let R=q.accountKeyIndexes.map((N)=>({pubkey:$.staticAccountKeys[N],isSigner:!1,isWritable:!1}));Z.push(new E0({keys:R,programId:J,data:q.data}))}}return Z}return[]}}verifyTransactionMatchesCode(Q,X){let $=Date.now();if($>Q.expiresAt)throw z.expiredCode(Q.code,Q.expiresAt,$);let Z=this.parseMeta(X);if(!Z)throw z.missingMeta();if(Z.ver!==2)throw z.metaMismatch("2",String(Z.ver),"ver");let q=o8(Q.code);if(Z.id!==q)throw z.metaMismatch(q,Z.id,"id");if(Z.int!==Q.pubkey)throw z.metaMismatch(Q.pubkey,Z.int,"int")}verifyTransactionSignedByIntentOwner(Q){let X=this.parseMeta(Q);if(!X)throw z.missingMeta();let $=X.int;if(!$)throw z.invalidMetaFormat("Missing 'int' (intendedFor) field");let Z;try{Z=new v0($)}catch{throw z.invalidPubkeyFormat($,"Invalid public key format")}let q=this.deserializeTransaction(Q),J=[];if(q instanceof d){if(!q.signatures.some((N)=>{if(!N.signature)return!1;return J.push(N.publicKey.toString()),N.publicKey.equals(Z)}))throw z.transactionNotSignedByIntendedOwner($,J);return}if(q instanceof v8){let R=q.message;if(R instanceof Q8){let N=R.header.numRequiredSignatures;for(let U=0;U<N;U++){let j=R.staticAccountKeys[U];if(j){if(J.push(j.toString()),j.equals(Z))return}}throw z.transactionNotSignedByIntendedOwner($,J)}}throw z.invalidTransactionFormat("Unsupported transaction format")}static attachProtocolMeta(Q,X){if(new $8().getProtocolMeta(Q))throw z.invalidTransactionFormat("Transaction already contains protocol meta. Cannot attach additional protocol meta.");let q=$8.createProtocolMetaIx(X);try{let J=v8.deserialize(Buffer.from(Q,"base64"));if(J.message instanceof Q8){let R=J.message,N=[...R.staticAccountKeys];if(!N.some((K)=>K.equals(X8)))N.push(X8);let j={programIdIndex:N.findIndex((K)=>K.equals(X8)),accountKeyIndexes:[],data:q.data},Y=new Q8({header:R.header,staticAccountKeys:N,recentBlockhash:R.recentBlockhash,compiledInstructions:[...R.compiledInstructions,j],addressTableLookups:R.addressTableLookups}),v=new v8(Y);return v.signatures=J.signatures,Buffer.from(v.serialize()).toString("base64")}else{let R=d.from(Buffer.from(Q,"base64"));return R.add(q),Buffer.from(R.serialize({requireAllSignatures:!1})).toString("base64")}}catch{try{let J=d.from(Buffer.from(Q,"base64"));return J.add(q),Buffer.from(J.serialize({requireAllSignatures:!1})).toString("base64")}catch{throw z.invalidTransactionFormat("Invalid base64 transaction format")}}}}class m0{config;adapters={};_walletStrategy;_delegationStrategy;constructor(Q){this.config=Q;this.adapters.solana=new $8,this._walletStrategy=new o(Q),this._delegationStrategy=new P8(Q)}getConfig(){return this.config}registerAdapter(Q,X){this.adapters[Q]=X}getAdapter(Q){return this.adapters[Q]}get adapter(){return{solana:this.adapters.solana}}get walletStrategy(){return this._walletStrategy}get delegationStrategy(){return this._delegationStrategy}generateCode(Q,X,$){if(Q==="wallet"){if(!$)throw z.invalidSignature("Missing signature over canonical message");return this.walletStrategy.generateCode(X,$)}else{if(!$)throw z.invalidSignature("Missing delegated signature");return this.delegationStrategy.generateDelegatedCode(X,$)}}validateCode(Q,X,$){if(Q==="wallet"){if(this.walletStrategy.validateCode(X),!$)return;let Z=$,q=this.getAdapter(Z.chain);if(!q)throw z.invalidAdapter(Z.chain);if(!q.verifyWithWallet({...Z,message:{pubkey:X.pubkey,windowStart:X.timestamp}}))throw z.invalidSignature("Wallet signature verification failed")}else{let Z=$;this.delegationStrategy.validateDelegatedCode(X,Z.delegationProof);let q=this.getAdapter(Z.chain);if(!q)throw z.invalidAdapter(Z.chain);if(!q.verifyWithDelegation({...Z,message:{pubkey:X.pubkey,windowStart:X.timestamp}}))throw z.invalidSignature("Delegation signature verification failed")}}}export{JQ as validateProtocolMetaFormat,T8 as truncateBits,C0 as sha256,C8 as serializeDelegationProof,b8 as serializeCanonicalRevoke,c as serializeCanonical,j8 as parseProtocolMeta,V8 as hmacSha256,s0 as hkdfSha256,e as getCanonicalMessageParts,I8 as digestToDigits,o8 as codeHash,B8 as buildProtocolMeta,i0 as base32EncodeCrockford,o as WalletStrategy,J0 as TransactionNotSignedByIntendedOwnerError,$8 as SolanaAdapter,$Q as SUPPORTED_CHAINS,m8 as SCHEME,x0 as ProtocolErrorCode,z as ProtocolError,x8 as PROTOCOL_NORMALIZATION,t as PROTOCOL_META_MAX_BYTES,Z0 as MissingMetaError,q0 as MetaMismatchError,Y0 as InvalidSignatureError,R0 as InvalidPubkeyFormatError,N0 as InvalidCodeFormatError,z0 as InvalidAdapterError,$0 as ExpiredCodeError,P8 as DelegationStrategy,E8 as CODE_MIN_LENGTH,y8 as CODE_MAX_LENGTH,QQ as CODE_DEFAULT_LENGTH,XQ as CODE_CHARSET_DIGITS,t0 as CANONICAL_REVOKE_MESSAGE_PREFIX,a0 as CANONICAL_MESSAGE_VERSION,e0 as CANONICAL_MESSAGE_PREFIX,G8 as BaseChainAdapter,m0 as ActionCodesProtocol,n as ADAPTER_CHAIN_NAME};
|
2
2
|
|
3
|
-
//# debugId=
|
3
|
+
//# debugId=856032EB4655E73B64756E2164756E21
|