@dfinity/ckbtc 3.1.14 → 3.2.0

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/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import{a as Ft,b as jt,c as dt}from"./chunk-ABDCS67G.js";import{a as Dt,b as Wt,c as St,d as Vt,e as $t,f as qt,g as Gt,h as zt,i as Xt,j as Kt,k as Jt,l as Qt,m as Yt,n as bt}from"./chunk-HAU7JR75.js";import{a as y,b as G}from"./chunk-FW4363Y4.js";var O=y((pe,Z)=>{"use strict";var At="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";Z.exports=At});var et=y((xe,tt)=>{"use strict";var _t=O(),Et=e=>{if(!e||typeof e!="string")throw new Error(`Expected base58 string but got \u201C${e}\u201D`);if(e.match(/[IOl0]/gmu))throw new Error(`Invalid base58 character \u201C${e.match(/[IOl0]/gmu)}\u201D`);let t=e.match(/^1+/gmu),o=t?t[0].length:0,n=(e.length-o)*(Math.log(58)/Math.log(256))+1>>>0;return new Uint8Array([...new Uint8Array(o),...e.match(/.{1}/gmu).map(s=>_t.indexOf(s)).reduce((s,c)=>(s=s.map(r=>{let i=r*58+c;return c=i>>8,i}),s),new Uint8Array(n)).reverse().filter((s=>c=>s=s||c)(!1))])};tt.exports=Et});var ot=y((le,rt)=>{"use strict";var nt=O(),kt=()=>{let e=Array(256).fill(-1);for(let t=0;t<nt.length;++t)e[nt.charCodeAt(t)]=t;return e};rt.exports=kt});var it=y((de,ct)=>{"use strict";var st=O(),Ct=ot(),Ut=Ct(),Bt=e=>{let t=[];for(let o of e){let n=o;for(let s=0;s<t.length;++s){let c=(Ut[t[s]]<<8)+n;t[s]=st.charCodeAt(c%58),n=c/58|0}for(;n;)t.push(st.charCodeAt(n%58)),n=n/58|0}for(let o of e){if(o)break;t.push(49)}return t.reverse(),String.fromCharCode(...t)};ct.exports=Bt});var ft=y($=>{"use strict";$.base58_to_binary=et();$.binary_to_base58=it()});var pt=y(E=>{"use strict";Object.defineProperty(E,"__esModule",{value:!0});E.bech32m=E.bech32=void 0;var F="qpzry9x8gf2tvdw0s3jn54khce6mua7l",ht={};for(let e=0;e<F.length;e++){let t=F.charAt(e);ht[t]=e}function _(e){let t=e>>25;return(e&33554431)<<5^-(t>>0&1)&996825010^-(t>>1&1)&642813549^-(t>>2&1)&513874426^-(t>>3&1)&1027748829^-(t>>4&1)&705979059}function at(e){let t=1;for(let o=0;o<e.length;++o){let n=e.charCodeAt(o);if(n<33||n>126)return"Invalid prefix ("+e+")";t=_(t)^n>>5}t=_(t);for(let o=0;o<e.length;++o){let n=e.charCodeAt(o);t=_(t)^n&31}return t}function q(e,t,o,n){let s=0,c=0,r=(1<<o)-1,i=[];for(let a=0;a<e.length;++a)for(s=s<<t|e[a],c+=t;c>=o;)c-=o,i.push(s>>c&r);if(n)c>0&&i.push(s<<o-c&r);else{if(c>=t)return"Excess padding";if(s<<o-c&r)return"Non-zero padding"}return i}function Lt(e){return q(e,8,5,!0)}function Pt(e){let t=q(e,5,8,!1);if(Array.isArray(t))return t}function Tt(e){let t=q(e,5,8,!1);if(Array.isArray(t))return t;throw new Error(t)}function ut(e){let t;e==="bech32"?t=1:t=734539939;function o(r,i,a){if(a=a||90,r.length+7+i.length>a)throw new TypeError("Exceeds length limit");r=r.toLowerCase();let u=at(r);if(typeof u=="string")throw new Error(u);let h=r+"1";for(let f=0;f<i.length;++f){let p=i[f];if(p>>5!==0)throw new Error("Non 5-bit word");u=_(u)^p,h+=F.charAt(p)}for(let f=0;f<6;++f)u=_(u);u^=t;for(let f=0;f<6;++f){let p=u>>(5-f)*5&31;h+=F.charAt(p)}return h}function n(r,i){if(i=i||90,r.length<8)return r+" too short";if(r.length>i)return"Exceeds length limit";let a=r.toLowerCase(),u=r.toUpperCase();if(r!==a&&r!==u)return"Mixed-case string "+r;r=a;let h=r.lastIndexOf("1");if(h===-1)return"No separator character for "+r;if(h===0)return"Missing prefix for "+r;let f=r.slice(0,h),p=r.slice(h+1);if(p.length<6)return"Data too short";let x=at(f);if(typeof x=="string")return x;let w=[];for(let l=0;l<p.length;++l){let L=p.charAt(l),k=ht[L];if(k===void 0)return"Unknown character "+L;x=_(x)^k,!(l+6>=p.length)&&w.push(k)}return x!==t?"Invalid checksum for "+r:{prefix:f,words:w}}function s(r,i){let a=n(r,i);if(typeof a=="object")return a}function c(r,i){let a=n(r,i);if(typeof a=="object")return a;throw new Error(a)}return{decodeUnsafe:s,decode:c,encode:o,toWords:Lt,fromWordsUnsafe:Pt,fromWords:Tt}}E.bech32=ut("bech32");E.bech32m=ut("bech32m")});var z=(n=>(n[n.Mainnet=0]="Mainnet",n[n.Regtest=1]="Regtest",n[n.Testnet=2]="Testnet",n))(z||{}),X=(c=>(c[c.P2wpkhV0=0]="P2wpkhV0",c[c.P2pkh=1]="P2pkh",c[c.P2sh=2]="P2sh",c[c.P2wsh=3]="P2wsh",c[c.P2tr=4]="P2tr",c))(X||{});var b=class extends Error{},C=class extends b{},P=class extends b{},U=class extends b{},T=class extends b{},v=class extends b{},I=class extends b{},A=class extends b{},N=class extends b{};import{isNullish as xt}from"@dfinity/utils";function wt(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function j(e,...t){if(!wt(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function D(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function K(e,t){j(e);let o=t.outputLen;if(e.length<o)throw new Error(`digestInto() expects output buffer of length at least ${o}`)}var H=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),d=(e,t)=>e<<32-t|e>>>t;var re=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function gt(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function W(e){return typeof e=="string"&&(e=gt(e)),j(e),e}var R=class{clone(){return this._cloneInto()}},oe={}.toString;function J(e){let t=n=>e().update(W(n)).digest(),o=e();return t.outputLen=o.outputLen,t.blockLen=o.blockLen,t.create=()=>e(),t}function mt(e,t,o,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,o,n);let s=BigInt(32),c=BigInt(4294967295),r=Number(o>>s&c),i=Number(o&c),a=n?4:0,u=n?0:4;e.setUint32(t+a,r,n),e.setUint32(t+u,i,n)}var Q=(e,t,o)=>e&t^~e&o,Y=(e,t,o)=>e&t^e&o^t&o,M=class extends R{constructor(t,o,n,s){super(),this.blockLen=t,this.outputLen=o,this.padOffset=n,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=H(this.buffer)}update(t){D(this);let{view:o,buffer:n,blockLen:s}=this;t=W(t);let c=t.length;for(let r=0;r<c;){let i=Math.min(s-this.pos,c-r);if(i===s){let a=H(t);for(;s<=c-r;r+=s)this.process(a,r);continue}n.set(t.subarray(r,r+i),this.pos),this.pos+=i,r+=i,this.pos===s&&(this.process(o,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){D(this),K(t,this),this.finished=!0;let{buffer:o,view:n,blockLen:s,isLE:c}=this,{pos:r}=this;o[r++]=128,this.buffer.subarray(r).fill(0),this.padOffset>s-r&&(this.process(n,0),r=0);for(let f=r;f<s;f++)o[f]=0;mt(n,s-8,BigInt(this.length*8),c),this.process(n,0);let i=H(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let u=a/4,h=this.get();if(u>h.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<u;f++)i.setUint32(4*f,h[f],c)}digest(){let{buffer:t,outputLen:o}=this;this.digestInto(t);let n=t.slice(0,o);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:o,buffer:n,length:s,finished:c,destroyed:r,pos:i}=this;return t.length=s,t.pos=i,t.finished=c,t.destroyed=r,s%o&&t.buffer.set(n),t}};var yt=new Uint32Array([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]),g=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),m=new Uint32Array(64),S=class extends M{constructor(){super(64,32,8,!1),this.A=g[0]|0,this.B=g[1]|0,this.C=g[2]|0,this.D=g[3]|0,this.E=g[4]|0,this.F=g[5]|0,this.G=g[6]|0,this.H=g[7]|0}get(){let{A:t,B:o,C:n,D:s,E:c,F:r,G:i,H:a}=this;return[t,o,n,s,c,r,i,a]}set(t,o,n,s,c,r,i,a){this.A=t|0,this.B=o|0,this.C=n|0,this.D=s|0,this.E=c|0,this.F=r|0,this.G=i|0,this.H=a|0}process(t,o){for(let f=0;f<16;f++,o+=4)m[f]=t.getUint32(o,!1);for(let f=16;f<64;f++){let p=m[f-15],x=m[f-2],w=d(p,7)^d(p,18)^p>>>3,l=d(x,17)^d(x,19)^x>>>10;m[f]=l+m[f-7]+w+m[f-16]|0}let{A:n,B:s,C:c,D:r,E:i,F:a,G:u,H:h}=this;for(let f=0;f<64;f++){let p=d(i,6)^d(i,11)^d(i,25),x=h+p+Q(i,a,u)+yt[f]+m[f]|0,l=(d(n,2)^d(n,13)^d(n,22))+Y(n,s,c)|0;h=u,u=a,a=i,i=r+x|0,r=c,c=s,s=n,n=x+l|0}n=n+this.A|0,s=s+this.B|0,c=c+this.C|0,r=r+this.D|0,i=i+this.E|0,a=a+this.F|0,u=u+this.G|0,h=h+this.H|0,this.set(n,s,c,r,i,a,u,h)}roundClean(){m.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var V=J(()=>new S);var lt=G(ft()),B=G(pt());var vt=0,It=5,Nt=111,Rt=196,Ht={[vt]:{type:1,networks:[0]},[Nt]:{type:1,networks:[2,1]},[It]:{type:2,networks:[0]},[Rt]:{type:2,networks:[2,1]}},Mt=({address:e,network:t})=>{let n=(h=>{try{return(0,lt.base58_to_binary)(h)}catch{throw new C}})(e),{length:s}=n;if(s!==25)throw new A(`Expected the address to be 25 bytes, got ${s}.`);(h=>{let f=h.slice(s-4,s),p=h.slice(0,s-4),x=V.create();x.update(p);let w=V.create();w.update(x.digest());let l=w.digest().slice(0,4);if(f.some((L,k)=>L!==l[k]))throw new A(`Checksum mismatch expected ${f}, got ${l}.`)})(n);let[r]=n,i=Ht[r];if(xt(i))throw new U;let{type:a,networks:u}=i;if(!u.includes(t))throw new N;return{address:e,network:t,type:a,parser:"base58"}},Ot=({address:e,network:t})=>{let o=h=>{try{return h.startsWith("bc1p")||h.startsWith("tb1p")||h.startsWith("bcrt1p")?B.bech32m.decode(h):B.bech32.decode(h)}catch{throw new A}},{prefix:n,words:s}=o(e),r={bc:0,tb:2,bcrt:1}[n];if(xt(r))throw new C;if(r!==t)throw new I;let[i,...a]=s;if(i>1)throw new v;switch(B.bech32.fromWords(a).length){case 20:return{address:e,network:t,type:0,parser:"bip-173"};case 32:return{address:e,network:t,type:i===0?3:4,parser:"bip-173"};default:throw new T}},_e=({address:e,network:t=0})=>{switch(e.charAt(0)){case"1":case"2":case"3":case"m":case"n":return Mt({address:e,network:t});case"b":case"B":case"t":case"T":return Ot({address:e,network:t});case"":throw new P;default:throw new U}};export{dt as BitcoinCanister,X as BtcAddressType,z as BtcNetwork,bt as CkBTCMinterCanister,St as MinterAlreadyProcessingError,zt as MinterAmountTooLowError,Dt as MinterGenericError,Kt as MinterInsufficientAllowanceError,Xt as MinterInsufficientFundsError,Gt as MinterMalformedAddressError,$t as MinterNoNewUtxosError,qt as MinterRetrieveBtcError,Wt as MinterTemporaryUnavailableError,Vt as MinterUpdateBalanceError,T as ParseBtcAddressBadWitnessLengthError,b as ParseBtcAddressError,C as ParseBtcAddressInvalidError,A as ParseBtcAddressMalformedAddressError,P as ParseBtcAddressNoDataError,I as ParseBtcAddressUnexpectedHumanReadablePartError,U as ParseBtcAddressUnsupportedAddressTypeError,v as ParseBtcAddressUnsupportedWitnessVersionError,N as ParseBtcAddressWrongNetworkError,Qt as createRetrieveBtcError,Yt as createRetrieveBtcWithApprovalError,Jt as createUpdateBalanceError,_e as parseBtcAddress,jt as toGetBalanceParams,Ft as toGetUtxosParams};
1
+ import{a as Et,b as Bt,c as st}from"./chunk-ABDCS67G.js";import{a as _t,b as Ct,c as Ut,d as Lt,e as kt,f as It,g as St,h as Ft,i as Dt,j as Tt,k as Pt,l as Gt,m as Vt,n as ct}from"./chunk-HAU7JR75.js";import{a as nt,b as ot}from"./chunk-FW4363Y4.js";var et=nt(H=>{"use strict";Object.defineProperty(H,"__esModule",{value:!0});H.bech32m=H.bech32=void 0;var M="qpzry9x8gf2tvdw0s3jn54khce6mua7l",Z={};for(let e=0;e<M.length;e++){let t=M.charAt(e);Z[t]=e}function A(e){let t=e>>25;return(e&33554431)<<5^-(t>>0&1)&996825010^-(t>>1&1)&642813549^-(t>>2&1)&513874426^-(t>>3&1)&1027748829^-(t>>4&1)&705979059}function Y(e){let t=1;for(let o=0;o<e.length;++o){let n=e.charCodeAt(o);if(n<33||n>126)return"Invalid prefix ("+e+")";t=A(t)^n>>5}t=A(t);for(let o=0;o<e.length;++o){let n=e.charCodeAt(o);t=A(t)^n&31}return t}function j(e,t,o,n){let s=0,c=0,r=(1<<o)-1,i=[];for(let h=0;h<e.length;++h)for(s=s<<t|e[h],c+=t;c>=o;)c-=o,i.push(s>>c&r);if(n)c>0&&i.push(s<<o-c&r);else{if(c>=t)return"Excess padding";if(s<<o-c&r)return"Non-zero padding"}return i}function ut(e){return j(e,8,5,!0)}function lt(e){let t=j(e,5,8,!1);if(Array.isArray(t))return t}function bt(e){let t=j(e,5,8,!1);if(Array.isArray(t))return t;throw new Error(t)}function tt(e){let t;e==="bech32"?t=1:t=734539939;function o(r,i,h){if(h=h||90,r.length+7+i.length>h)throw new TypeError("Exceeds length limit");r=r.toLowerCase();let x=Y(r);if(typeof x=="string")throw new Error(x);let a=r+"1";for(let f=0;f<i.length;++f){let d=i[f];if(d>>5!==0)throw new Error("Non 5-bit word");x=A(x)^d,a+=M.charAt(d)}for(let f=0;f<6;++f)x=A(x);x^=t;for(let f=0;f<6;++f){let d=x>>(5-f)*5&31;a+=M.charAt(d)}return a}function n(r,i){if(i=i||90,r.length<8)return r+" too short";if(r.length>i)return"Exceeds length limit";let h=r.toLowerCase(),x=r.toUpperCase();if(r!==h&&r!==x)return"Mixed-case string "+r;r=h;let a=r.lastIndexOf("1");if(a===-1)return"No separator character for "+r;if(a===0)return"Missing prefix for "+r;let f=r.slice(0,a),d=r.slice(a+1);if(d.length<6)return"Data too short";let u=Y(f);if(typeof u=="string")return u;let g=[];for(let l=0;l<d.length;++l){let L=d.charAt(l),E=Z[L];if(E===void 0)return"Unknown character "+L;u=A(u)^E,!(l+6>=d.length)&&g.push(E)}return u!==t?"Invalid checksum for "+r:{prefix:f,words:g}}function s(r,i){let h=n(r,i);if(typeof h=="object")return h}function c(r,i){let h=n(r,i);if(typeof h=="object")return h;throw new Error(h)}return{decodeUnsafe:s,decode:c,encode:o,toWords:ut,fromWordsUnsafe:lt,fromWords:bt}}H.bech32=tt("bech32");H.bech32m=tt("bech32m")});var z=(n=>(n[n.Mainnet=0]="Mainnet",n[n.Regtest=1]="Regtest",n[n.Testnet=2]="Testnet",n))(z||{}),X=(c=>(c[c.P2wpkhV0=0]="P2wpkhV0",c[c.P2pkh=1]="P2pkh",c[c.P2sh=2]="P2sh",c[c.P2wsh=3]="P2wsh",c[c.P2tr=4]="P2tr",c))(X||{});var p=class extends Error{},B=class extends p{},k=class extends p{},_=class extends p{},I=class extends p{},S=class extends p{},F=class extends p{},y=class extends p{},D=class extends p{};import{isNullish as rt}from"@dfinity/utils";function it(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function P(e,...t){if(!it(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function W(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function K(e,t){P(e);let o=t.outputLen;if(e.length<o)throw new Error("digestInto() expects output buffer of length at least "+o)}function C(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function G(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function b(e,t){return e<<32-t|e>>>t}function ft(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function v(e){return typeof e=="string"&&(e=ft(e)),P(e),e}var T=class{};function $(e){let t=n=>e().update(v(n)).digest(),o=e();return t.outputLen=o.outputLen,t.blockLen=o.blockLen,t.create=()=>e(),t}function ht(e,t,o,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,o,n);let s=BigInt(32),c=BigInt(4294967295),r=Number(o>>s&c),i=Number(o&c),h=n?4:0,x=n?0:4;e.setUint32(t+h,r,n),e.setUint32(t+x,i,n)}function q(e,t,o){return e&t^~e&o}function J(e,t,o){return e&t^e&o^t&o}var V=class extends T{constructor(t,o,n,s){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=o,this.padOffset=n,this.isLE=s,this.buffer=new Uint8Array(t),this.view=G(this.buffer)}update(t){W(this),t=v(t),P(t);let{view:o,buffer:n,blockLen:s}=this,c=t.length;for(let r=0;r<c;){let i=Math.min(s-this.pos,c-r);if(i===s){let h=G(t);for(;s<=c-r;r+=s)this.process(h,r);continue}n.set(t.subarray(r,r+i),this.pos),this.pos+=i,r+=i,this.pos===s&&(this.process(o,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){W(this),K(t,this),this.finished=!0;let{buffer:o,view:n,blockLen:s,isLE:c}=this,{pos:r}=this;o[r++]=128,C(this.buffer.subarray(r)),this.padOffset>s-r&&(this.process(n,0),r=0);for(let f=r;f<s;f++)o[f]=0;ht(n,s-8,BigInt(this.length*8),c),this.process(n,0);let i=G(t),h=this.outputLen;if(h%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let x=h/4,a=this.get();if(x>a.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<x;f++)i.setUint32(4*f,a[f],c)}digest(){let{buffer:t,outputLen:o}=this;this.digestInto(t);let n=t.slice(0,o);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:o,buffer:n,length:s,finished:c,destroyed:r,pos:i}=this;return t.destroyed=r,t.finished=c,t.length=s,t.pos=i,s%o&&t.buffer.set(n),t}clone(){return this._cloneInto()}},w=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var at=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]),m=new Uint32Array(64),N=class extends V{constructor(t=32){super(64,t,8,!1),this.A=w[0]|0,this.B=w[1]|0,this.C=w[2]|0,this.D=w[3]|0,this.E=w[4]|0,this.F=w[5]|0,this.G=w[6]|0,this.H=w[7]|0}get(){let{A:t,B:o,C:n,D:s,E:c,F:r,G:i,H:h}=this;return[t,o,n,s,c,r,i,h]}set(t,o,n,s,c,r,i,h){this.A=t|0,this.B=o|0,this.C=n|0,this.D=s|0,this.E=c|0,this.F=r|0,this.G=i|0,this.H=h|0}process(t,o){for(let f=0;f<16;f++,o+=4)m[f]=t.getUint32(o,!1);for(let f=16;f<64;f++){let d=m[f-15],u=m[f-2],g=b(d,7)^b(d,18)^d>>>3,l=b(u,17)^b(u,19)^u>>>10;m[f]=l+m[f-7]+g+m[f-16]|0}let{A:n,B:s,C:c,D:r,E:i,F:h,G:x,H:a}=this;for(let f=0;f<64;f++){let d=b(i,6)^b(i,11)^b(i,25),u=a+d+q(i,h,x)+at[f]+m[f]|0,l=(b(n,2)^b(n,13)^b(n,22))+J(n,s,c)|0;a=x,x=h,h=i,i=r+u|0,r=c,c=s,s=n,n=u+l|0}n=n+this.A|0,s=s+this.B|0,c=c+this.C|0,r=r+this.D|0,i=i+this.E|0,h=h+this.F|0,x=x+this.G|0,a=a+this.H|0,this.set(n,s,c,r,i,h,x,a)}roundClean(){C(m)}destroy(){this.set(0,0,0,0,0,0,0,0),C(this.buffer)}};var O=$(()=>new N);var xt="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",Q=xt;function dt(e){if(!e||typeof e!="string")throw new Error(`Expected base58 string but got \u201C${e}\u201D`);if(e.match(/[IOl0]/gmu))throw new Error(`Invalid base58 character \u201C${e.match(/[IOl0]/gmu)}\u201D`);let t=e.match(/^1+/gmu),o=t?t[0].length:0,n=(e.length-o)*(Math.log(58)/Math.log(256))+1>>>0;return new Uint8Array([...new Uint8Array(o),...e.match(/.{1}/gmu).map(s=>Q.indexOf(s)).reduce((s,c)=>(s=s.map(r=>{let i=r*58+c;return c=i>>8,i}),s),new Uint8Array(n)).reverse().filter((s=>c=>s=s||c)(!1))])}var R=dt;var U=ot(et());var pt=0,wt=5,gt=111,mt=196,yt={[pt]:{type:1,networks:[0]},[gt]:{type:1,networks:[2,1]},[wt]:{type:2,networks:[0]},[mt]:{type:2,networks:[2,1]}},At=({address:e,network:t})=>{let n=(a=>{try{return R(a)}catch{throw new B}})(e),{length:s}=n;if(s!==25)throw new y(`Expected the address to be 25 bytes, got ${s}.`);(a=>{let f=a.slice(s-4,s),d=a.slice(0,s-4),u=O.create();u.update(d);let g=O.create();g.update(u.digest());let l=g.digest().slice(0,4);if(f.some((L,E)=>L!==l[E]))throw new y(`Checksum mismatch expected ${f}, got ${l}.`)})(n);let[r]=n,i=yt[r];if(rt(i))throw new _;let{type:h,networks:x}=i;if(!x.includes(t))throw new D;return{address:e,network:t,type:h,parser:"base58"}},Ht=({address:e,network:t})=>{let o=a=>{try{return a.startsWith("bc1p")||a.startsWith("tb1p")||a.startsWith("bcrt1p")?U.bech32m.decode(a):U.bech32.decode(a)}catch{throw new y}},{prefix:n,words:s}=o(e),r={bc:0,tb:2,bcrt:1}[n];if(rt(r))throw new B;if(r!==t)throw new F;let[i,...h]=s;if(i>1)throw new S;switch(U.bech32.fromWords(h).length){case 20:return{address:e,network:t,type:0,parser:"bip-173"};case 32:return{address:e,network:t,type:i===0?3:4,parser:"bip-173"};default:throw new I}},ce=({address:e,network:t=0})=>{switch(e.charAt(0)){case"1":case"2":case"3":case"m":case"n":return At({address:e,network:t});case"b":case"B":case"t":case"T":return Ht({address:e,network:t});case"":throw new k;default:throw new _}};export{st as BitcoinCanister,X as BtcAddressType,z as BtcNetwork,ct as CkBTCMinterCanister,Ut as MinterAlreadyProcessingError,Ft as MinterAmountTooLowError,_t as MinterGenericError,Tt as MinterInsufficientAllowanceError,Dt as MinterInsufficientFundsError,St as MinterMalformedAddressError,kt as MinterNoNewUtxosError,It as MinterRetrieveBtcError,Ct as MinterTemporaryUnavailableError,Lt as MinterUpdateBalanceError,I as ParseBtcAddressBadWitnessLengthError,p as ParseBtcAddressError,B as ParseBtcAddressInvalidError,y as ParseBtcAddressMalformedAddressError,k as ParseBtcAddressNoDataError,F as ParseBtcAddressUnexpectedHumanReadablePartError,_ as ParseBtcAddressUnsupportedAddressTypeError,S as ParseBtcAddressUnsupportedWitnessVersionError,D as ParseBtcAddressWrongNetworkError,Gt as createRetrieveBtcError,Vt as createRetrieveBtcWithApprovalError,Pt as createUpdateBalanceError,ce as parseBtcAddress,Bt as toGetBalanceParams,Et as toGetUtxosParams};
2
2
  /*! Bundled license information:
3
3
 
4
4
  @noble/hashes/esm/utils.js:
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../../../node_modules/base58-js/private/base58_chars.js", "../../../../node_modules/base58-js/public/base58_to_binary.js", "../../../../node_modules/base58-js/private/create_base58_map.js", "../../../../node_modules/base58-js/public/binary_to_base58.js", "../../../../node_modules/base58-js/public/index.js", "../../../../node_modules/bech32/dist/index.js", "../../src/enums/btc.enums.ts", "../../src/errors/btc.errors.ts", "../../src/utils/btc.utils.ts", "../../../../node_modules/@noble/hashes/src/_assert.ts", "../../../../node_modules/@noble/hashes/src/utils.ts", "../../../../node_modules/@noble/hashes/src/_md.ts", "../../../../node_modules/@noble/hashes/src/sha256.ts"],
4
- "sourcesContent": ["'use strict'\n/**\n * Base58 characters must only include numbers 123456789, uppercase ABCDEFGHJKLMNPQRSTUVWXYZ and lowercase abcdefghijkmnopqrstuvwxyz.\n * @kind namespace\n * @name base58_chars\n * @type {string}\n */\nconst base58_chars =\n '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'\n\nmodule.exports = base58_chars\n", "'use strict'\n\nconst base58_chars = require('../private/base58_chars.js')\n\n/**\n * Converts a `base58` string to its corresponding binary representation.\n * @kind function\n * @name base58_to_binary\n * @param {base58_chars} base58String base58 encoded string\n * @returns {Uint8Array} binary representation for the base58 string.\n * @example <caption>Ways to `import`.</caption>\n * ```js\n * import { base58_to_binary } from 'base58-js'\n * ```\n * @example <caption>Ways to `require`.</caption>\n * ```js\n * const { base58_to_binary } = require('base58-js')\n * ```\n * @example <caption>Usage.</caption>\n * ```js\n * const bin = base58_to_binary(\"6MRy\")\n * console.log(bin)\n * ```\n * Logged output will be Uint8Array(3) [15, 239, 64].\n */\nconst base58_to_binary = base58String => {\n if (!base58String || typeof base58String !== 'string')\n throw new Error(`Expected base58 string but got \u201C${base58String}\u201D`)\n if (base58String.match(/[IOl0]/gmu))\n throw new Error(\n `Invalid base58 character \u201C${base58String.match(/[IOl0]/gmu)}\u201D`\n )\n const lz = base58String.match(/^1+/gmu)\n const psz = lz ? lz[0].length : 0\n const size =\n ((base58String.length - psz) * (Math.log(58) / Math.log(256)) + 1) >>> 0\n\n return new Uint8Array([\n ...new Uint8Array(psz),\n ...base58String\n .match(/.{1}/gmu)\n .map(i => base58_chars.indexOf(i))\n .reduce((acc, i) => {\n acc = acc.map(j => {\n const x = j * 58 + i\n i = x >> 8\n return x\n })\n return acc\n }, new Uint8Array(size))\n .reverse()\n .filter(\n (\n lastValue => value =>\n (lastValue = lastValue || value)\n )(false)\n )\n ])\n}\n\nmodule.exports = base58_to_binary\n", "'use strict'\nconst base58_chars = require('./base58_chars.js')\n\n/**\n * Generates a mapping between base58 and ascii.\n * @name create_base58_map\n * @kind function\n * @returns {Array} mapping between ascii and base58.\n * @ignore\n */\nconst create_base58_map = () => {\n const base58M = Array(256).fill(-1)\n for (let i = 0; i < base58_chars.length; ++i)\n base58M[base58_chars.charCodeAt(i)] = i\n\n return base58M\n}\n\nmodule.exports = create_base58_map\n", "'use strict'\n\nconst base58_chars = require('../private/base58_chars.js')\nconst create_base58_map = require('../private/create_base58_map.js')\n\nconst base58Map = create_base58_map()\n\n/**\n * Converts a [Uint8Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) into a base58 string.\n * @kind function\n * @name binary_to_base58\n * @param {Uint8Array | Array} uint8array Unsigned integer.\n * @returns {base58_chars} The base58 string representation of the binary array.\n * @example <caption>Ways to `require`.</caption>\n * ```js\n * const { binary_to_base58 } = require(\"base58-js\")\n * ```\n * @example <caption>Ways to `import`.</caption>\n * ```js\n * import { binary_to_base58 } from 'base58-js'\n * ```\n * @example <caption>Usage.</caption>\n * ```js\n * const str = binary_to_base58([15, 239, 64])\n * console.log(str)\n * ```\n * Logged output will be 6MRy.\n */\nconst binary_to_base58 = uint8array => {\n const result = []\n\n for (const byte of uint8array) {\n let carry = byte\n for (let j = 0; j < result.length; ++j) {\n const x = (base58Map[result[j]] << 8) + carry\n result[j] = base58_chars.charCodeAt(x % 58)\n carry = (x / 58) | 0\n }\n while (carry) {\n result.push(base58_chars.charCodeAt(carry % 58))\n carry = (carry / 58) | 0\n }\n }\n\n for (const byte of uint8array)\n if (byte) break\n else result.push('1'.charCodeAt(0))\n\n result.reverse()\n\n return String.fromCharCode(...result)\n}\n\nmodule.exports = binary_to_base58\n", "'use strict'\n\nexports.base58_to_binary = require('./base58_to_binary.js')\nexports.binary_to_base58 = require('./binary_to_base58.js')\n", "'use strict';\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.bech32m = exports.bech32 = void 0;\nconst ALPHABET = 'qpzry9x8gf2tvdw0s3jn54khce6mua7l';\nconst ALPHABET_MAP = {};\nfor (let z = 0; z < ALPHABET.length; z++) {\n const x = ALPHABET.charAt(z);\n ALPHABET_MAP[x] = z;\n}\nfunction polymodStep(pre) {\n const b = pre >> 25;\n return (((pre & 0x1ffffff) << 5) ^\n (-((b >> 0) & 1) & 0x3b6a57b2) ^\n (-((b >> 1) & 1) & 0x26508e6d) ^\n (-((b >> 2) & 1) & 0x1ea119fa) ^\n (-((b >> 3) & 1) & 0x3d4233dd) ^\n (-((b >> 4) & 1) & 0x2a1462b3));\n}\nfunction prefixChk(prefix) {\n let chk = 1;\n for (let i = 0; i < prefix.length; ++i) {\n const c = prefix.charCodeAt(i);\n if (c < 33 || c > 126)\n return 'Invalid prefix (' + prefix + ')';\n chk = polymodStep(chk) ^ (c >> 5);\n }\n chk = polymodStep(chk);\n for (let i = 0; i < prefix.length; ++i) {\n const v = prefix.charCodeAt(i);\n chk = polymodStep(chk) ^ (v & 0x1f);\n }\n return chk;\n}\nfunction convert(data, inBits, outBits, pad) {\n let value = 0;\n let bits = 0;\n const maxV = (1 << outBits) - 1;\n const result = [];\n for (let i = 0; i < data.length; ++i) {\n value = (value << inBits) | data[i];\n bits += inBits;\n while (bits >= outBits) {\n bits -= outBits;\n result.push((value >> bits) & maxV);\n }\n }\n if (pad) {\n if (bits > 0) {\n result.push((value << (outBits - bits)) & maxV);\n }\n }\n else {\n if (bits >= inBits)\n return 'Excess padding';\n if ((value << (outBits - bits)) & maxV)\n return 'Non-zero padding';\n }\n return result;\n}\nfunction toWords(bytes) {\n return convert(bytes, 8, 5, true);\n}\nfunction fromWordsUnsafe(words) {\n const res = convert(words, 5, 8, false);\n if (Array.isArray(res))\n return res;\n}\nfunction fromWords(words) {\n const res = convert(words, 5, 8, false);\n if (Array.isArray(res))\n return res;\n throw new Error(res);\n}\nfunction getLibraryFromEncoding(encoding) {\n let ENCODING_CONST;\n if (encoding === 'bech32') {\n ENCODING_CONST = 1;\n }\n else {\n ENCODING_CONST = 0x2bc830a3;\n }\n function encode(prefix, words, LIMIT) {\n LIMIT = LIMIT || 90;\n if (prefix.length + 7 + words.length > LIMIT)\n throw new TypeError('Exceeds length limit');\n prefix = prefix.toLowerCase();\n // determine chk mod\n let chk = prefixChk(prefix);\n if (typeof chk === 'string')\n throw new Error(chk);\n let result = prefix + '1';\n for (let i = 0; i < words.length; ++i) {\n const x = words[i];\n if (x >> 5 !== 0)\n throw new Error('Non 5-bit word');\n chk = polymodStep(chk) ^ x;\n result += ALPHABET.charAt(x);\n }\n for (let i = 0; i < 6; ++i) {\n chk = polymodStep(chk);\n }\n chk ^= ENCODING_CONST;\n for (let i = 0; i < 6; ++i) {\n const v = (chk >> ((5 - i) * 5)) & 0x1f;\n result += ALPHABET.charAt(v);\n }\n return result;\n }\n function __decode(str, LIMIT) {\n LIMIT = LIMIT || 90;\n if (str.length < 8)\n return str + ' too short';\n if (str.length > LIMIT)\n return 'Exceeds length limit';\n // don't allow mixed case\n const lowered = str.toLowerCase();\n const uppered = str.toUpperCase();\n if (str !== lowered && str !== uppered)\n return 'Mixed-case string ' + str;\n str = lowered;\n const split = str.lastIndexOf('1');\n if (split === -1)\n return 'No separator character for ' + str;\n if (split === 0)\n return 'Missing prefix for ' + str;\n const prefix = str.slice(0, split);\n const wordChars = str.slice(split + 1);\n if (wordChars.length < 6)\n return 'Data too short';\n let chk = prefixChk(prefix);\n if (typeof chk === 'string')\n return chk;\n const words = [];\n for (let i = 0; i < wordChars.length; ++i) {\n const c = wordChars.charAt(i);\n const v = ALPHABET_MAP[c];\n if (v === undefined)\n return 'Unknown character ' + c;\n chk = polymodStep(chk) ^ v;\n // not in the checksum?\n if (i + 6 >= wordChars.length)\n continue;\n words.push(v);\n }\n if (chk !== ENCODING_CONST)\n return 'Invalid checksum for ' + str;\n return { prefix, words };\n }\n function decodeUnsafe(str, LIMIT) {\n const res = __decode(str, LIMIT);\n if (typeof res === 'object')\n return res;\n }\n function decode(str, LIMIT) {\n const res = __decode(str, LIMIT);\n if (typeof res === 'object')\n return res;\n throw new Error(res);\n }\n return {\n decodeUnsafe,\n decode,\n encode,\n toWords,\n fromWordsUnsafe,\n fromWords,\n };\n}\nexports.bech32 = getLibraryFromEncoding('bech32');\nexports.bech32m = getLibraryFromEncoding('bech32m');\n", "// As defined on Bitcoin network.\n// e.g. https://developer.bitcoin.org/examples/testing.html\nexport enum BtcNetwork {\n Mainnet,\n Regtest,\n Testnet,\n}\n\n// See https://github.com/dfinity/ic/blob/a8da3aa23dc6f8f4708cb0cb8edce84c5bd8f225/rs/bitcoin/ckbtc/minter/src/address.rs#L18\nexport enum BtcAddressType {\n P2wpkhV0,\n P2pkh,\n P2sh,\n P2wsh,\n P2tr,\n}\n", "export class ParseBtcAddressError extends Error {}\nexport class ParseBtcAddressInvalidError extends ParseBtcAddressError {}\nexport class ParseBtcAddressNoDataError extends ParseBtcAddressError {}\nexport class ParseBtcAddressUnsupportedAddressTypeError extends ParseBtcAddressError {}\nexport class ParseBtcAddressBadWitnessLengthError extends ParseBtcAddressError {}\nexport class ParseBtcAddressUnsupportedWitnessVersionError extends ParseBtcAddressError {}\nexport class ParseBtcAddressUnexpectedHumanReadablePartError extends ParseBtcAddressError {}\nexport class ParseBtcAddressMalformedAddressError extends ParseBtcAddressError {}\nexport class ParseBtcAddressWrongNetworkError extends ParseBtcAddressError {}\n", "import { isNullish } from \"@dfinity/utils\";\nimport { sha256 } from \"@noble/hashes/sha256\";\nimport { base58_to_binary } from \"base58-js\";\nimport { bech32, bech32m, type Decoded } from \"bech32\";\nimport { BtcAddressType, BtcNetwork } from \"../enums/btc.enums\";\nimport {\n ParseBtcAddressBadWitnessLengthError,\n ParseBtcAddressInvalidError,\n ParseBtcAddressMalformedAddressError,\n ParseBtcAddressNoDataError,\n ParseBtcAddressUnexpectedHumanReadablePartError,\n ParseBtcAddressUnsupportedAddressTypeError,\n ParseBtcAddressUnsupportedWitnessVersionError,\n ParseBtcAddressWrongNetworkError,\n} from \"../errors/btc.errors\";\nimport type { BtcAddress, BtcAddressInfo } from \"../types/btc\";\n\n// See https://en.bitcoin.it/wiki/List_of_address_prefixes\nconst BTC_MAINNET_PREFIX = 0; // or 0x00\nconst BTC_MAINNET_P2SH_PREFIX = 5; // or 0x05\nconst BTC_TESTNET_PREFIX = 111; // or 0x6f\nconst BTC_TESTNET_P2SH_PREFIX = 196; // or 0xc4\n\nconst Base58AddressTypes: Record<\n number,\n { type: BtcAddressType; networks: BtcNetwork[] }\n> = {\n [BTC_MAINNET_PREFIX]: {\n type: BtcAddressType.P2pkh,\n networks: [BtcNetwork.Mainnet],\n },\n\n [BTC_TESTNET_PREFIX]: {\n type: BtcAddressType.P2pkh,\n networks: [BtcNetwork.Testnet, BtcNetwork.Regtest],\n },\n\n [BTC_MAINNET_P2SH_PREFIX]: {\n type: BtcAddressType.P2sh,\n networks: [BtcNetwork.Mainnet],\n },\n\n [BTC_TESTNET_P2SH_PREFIX]: {\n type: BtcAddressType.P2sh,\n networks: [BtcNetwork.Testnet, BtcNetwork.Regtest],\n },\n};\n\nconst parseBase58Address = ({\n address,\n network,\n}: Required<BtcAddress>): BtcAddressInfo => {\n const decodeBase58 = (address: string): Uint8Array => {\n try {\n return base58_to_binary(address);\n } catch (_error: unknown) {\n throw new ParseBtcAddressInvalidError();\n }\n };\n\n const decoded: Uint8Array = decodeBase58(address);\n\n const { length } = decoded;\n\n if (length !== 25) {\n throw new ParseBtcAddressMalformedAddressError(\n `Expected the address to be 25 bytes, got ${length}.`,\n );\n }\n\n const validateBase58Checksum = (decoded: Uint8Array) => {\n const expectedChecksum = decoded.slice(length - 4, length);\n const body = decoded.slice(0, length - 4);\n\n const bodyHash = sha256.create();\n bodyHash.update(body);\n\n const checksumHash = sha256.create();\n checksumHash.update(bodyHash.digest());\n\n const checksum = checksumHash.digest().slice(0, 4);\n\n if (\n expectedChecksum.some(\n (value: number, index: number) => value !== checksum[index],\n )\n ) {\n throw new ParseBtcAddressMalformedAddressError(\n `Checksum mismatch expected ${expectedChecksum}, got ${checksum}.`,\n );\n }\n };\n\n validateBase58Checksum(decoded);\n\n const [version] = decoded;\n\n const versionNetwork = Base58AddressTypes[version];\n\n if (isNullish(versionNetwork)) {\n throw new ParseBtcAddressUnsupportedAddressTypeError();\n }\n\n const { type, networks } = versionNetwork;\n\n if (!networks.includes(network)) {\n throw new ParseBtcAddressWrongNetworkError();\n }\n\n return {\n address,\n network,\n type,\n parser: \"base58\",\n };\n};\n\nconst parseBip173Address = ({\n address,\n network,\n}: Required<BtcAddress>): BtcAddressInfo => {\n const decodeBech32 = (address: string): Decoded => {\n try {\n if (\n address.startsWith(\"bc1p\") ||\n address.startsWith(\"tb1p\") ||\n address.startsWith(\"bcrt1p\")\n ) {\n return bech32m.decode(address);\n }\n\n return bech32.decode(address);\n } catch (_error: unknown) {\n throw new ParseBtcAddressMalformedAddressError();\n }\n };\n\n const { prefix, words } = decodeBech32(address);\n\n const mapPrefixToNetwork: Record<string, BtcNetwork> = {\n bc: BtcNetwork.Mainnet,\n tb: BtcNetwork.Testnet,\n bcrt: BtcNetwork.Regtest,\n };\n\n const decodedNetwork: BtcNetwork | undefined = mapPrefixToNetwork[prefix];\n\n if (isNullish(decodedNetwork)) {\n throw new ParseBtcAddressInvalidError();\n }\n\n if (decodedNetwork !== network) {\n throw new ParseBtcAddressUnexpectedHumanReadablePartError();\n }\n\n const [witnessVersion, ...rest] = words;\n\n if (witnessVersion > 1) {\n throw new ParseBtcAddressUnsupportedWitnessVersionError();\n }\n\n const data = bech32.fromWords(rest);\n\n switch (data.length) {\n case 20:\n return {\n address,\n network,\n type: BtcAddressType.P2wpkhV0,\n parser: \"bip-173\",\n };\n case 32:\n return {\n address,\n network,\n type: witnessVersion === 0 ? BtcAddressType.P2wsh : BtcAddressType.P2tr,\n parser: \"bip-173\",\n };\n default:\n throw new ParseBtcAddressBadWitnessLengthError();\n }\n};\n\n/**\n * Parse a Bitcoin address.\n *\n * Parse implementation follows strategy implemented in [Minter canister](https://github.com/dfinity/ic/blob/a8da3aa23dc6f8f4708cb0cb8edce84c5bd8f225/rs/bitcoin/ckbtc/minter/src/address.rs#L54).\n *\n * Credits: Parts of JavaScript code and test values from [bitcoin-address-validation](https://github.com/ruigomeseu/bitcoin-address-validation).\n *\n * @param {BtcAddress} params The Bitcoin address and network to parse\n * @param {string} params.address\n * @param {BtcNetwork} params.network Optional. Default BtcNetwork is Mainnet\n */\nexport const parseBtcAddress = ({\n address,\n network = BtcNetwork.Mainnet,\n}: BtcAddress): BtcAddressInfo => {\n switch (address.charAt(0)) {\n case \"1\":\n case \"2\":\n case \"3\":\n case \"m\":\n case \"n\":\n return parseBase58Address({ address, network });\n case \"b\":\n case \"B\":\n case \"t\":\n case \"T\":\n return parseBip173Address({ address, network });\n case \"\":\n throw new ParseBtcAddressNoDataError();\n default:\n throw new ParseBtcAddressUnsupportedAddressTypeError();\n }\n};\n", "function number(n: number) {\n if (!Number.isSafeInteger(n) || n < 0) throw new Error(`positive integer expected, not ${n}`);\n}\n\nfunction bool(b: boolean) {\n if (typeof b !== 'boolean') throw new Error(`boolean expected, not ${b}`);\n}\n\n// copied from utils\nexport function isBytes(a: unknown): a is Uint8Array {\n return (\n a instanceof Uint8Array ||\n (a != null && typeof a === 'object' && a.constructor.name === 'Uint8Array')\n );\n}\n\nfunction bytes(b: Uint8Array | undefined, ...lengths: number[]) {\n if (!isBytes(b)) throw new Error('Uint8Array expected');\n if (lengths.length > 0 && !lengths.includes(b.length))\n throw new Error(`Uint8Array expected of length ${lengths}, not of length=${b.length}`);\n}\n\ntype Hash = {\n (data: Uint8Array): Uint8Array;\n blockLen: number;\n outputLen: number;\n create: any;\n};\nfunction hash(h: Hash) {\n if (typeof h !== 'function' || typeof h.create !== 'function')\n throw new Error('Hash should be wrapped by utils.wrapConstructor');\n number(h.outputLen);\n number(h.blockLen);\n}\n\nfunction exists(instance: any, checkFinished = true) {\n if (instance.destroyed) throw new Error('Hash instance has been destroyed');\n if (checkFinished && instance.finished) throw new Error('Hash#digest() has already been called');\n}\nfunction output(out: any, instance: any) {\n bytes(out);\n const min = instance.outputLen;\n if (out.length < min) {\n throw new Error(`digestInto() expects output buffer of length at least ${min}`);\n }\n}\n\nexport { number, bool, bytes, hash, exists, output };\n\nconst assert = { number, bool, bytes, hash, exists, output };\nexport default assert;\n", "/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */\n\n// We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+.\n// node.js versions earlier than v19 don't declare it in global scope.\n// For node.js, package.json#exports field mapping rewrites import\n// from `crypto` to `cryptoNode`, which imports native module.\n// Makes the utils un-importable in browsers without a bundler.\n// Once node.js 18 is deprecated (2025-04-30), we can just drop the import.\nimport { crypto } from '@noble/hashes/crypto';\nimport { bytes as abytes } from './_assert.js';\n// export { isBytes } from './_assert.js';\n// We can't reuse isBytes from _assert, because somehow this causes huge perf issues\nexport function isBytes(a: unknown): a is Uint8Array {\n return (\n a instanceof Uint8Array ||\n (a != null && typeof a === 'object' && a.constructor.name === 'Uint8Array')\n );\n}\n\n// prettier-ignore\nexport type TypedArray = Int8Array | Uint8ClampedArray | Uint8Array |\n Uint16Array | Int16Array | Uint32Array | Int32Array;\n\n// Cast array to different type\nexport const u8 = (arr: TypedArray) => new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);\nexport const u32 = (arr: TypedArray) =>\n new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));\n\n// Cast array to view\nexport const createView = (arr: TypedArray) =>\n new DataView(arr.buffer, arr.byteOffset, arr.byteLength);\n\n// The rotate right (circular right shift) operation for uint32\nexport const rotr = (word: number, shift: number) => (word << (32 - shift)) | (word >>> shift);\n// The rotate left (circular left shift) operation for uint32\nexport const rotl = (word: number, shift: number) =>\n (word << shift) | ((word >>> (32 - shift)) >>> 0);\n\nexport const isLE = new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44;\n// The byte swap operation for uint32\nexport const byteSwap = (word: number) =>\n ((word << 24) & 0xff000000) |\n ((word << 8) & 0xff0000) |\n ((word >>> 8) & 0xff00) |\n ((word >>> 24) & 0xff);\n// Conditionally byte swap if on a big-endian platform\nexport const byteSwapIfBE = isLE ? (n: number) => n : (n: number) => byteSwap(n);\n\n// In place byte swap for Uint32Array\nexport function byteSwap32(arr: Uint32Array) {\n for (let i = 0; i < arr.length; i++) {\n arr[i] = byteSwap(arr[i]);\n }\n}\n\n// Array where index 0xf0 (240) is mapped to string 'f0'\nconst hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) =>\n i.toString(16).padStart(2, '0')\n);\n/**\n * @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123'\n */\nexport function bytesToHex(bytes: Uint8Array): string {\n abytes(bytes);\n // pre-caching improves the speed 6x\n let hex = '';\n for (let i = 0; i < bytes.length; i++) {\n hex += hexes[bytes[i]];\n }\n return hex;\n}\n\n// We use optimized technique to convert hex string to byte array\nconst asciis = { _0: 48, _9: 57, _A: 65, _F: 70, _a: 97, _f: 102 } as const;\nfunction asciiToBase16(char: number): number | undefined {\n if (char >= asciis._0 && char <= asciis._9) return char - asciis._0;\n if (char >= asciis._A && char <= asciis._F) return char - (asciis._A - 10);\n if (char >= asciis._a && char <= asciis._f) return char - (asciis._a - 10);\n return;\n}\n\n/**\n * @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23])\n */\nexport function hexToBytes(hex: string): Uint8Array {\n if (typeof hex !== 'string') throw new Error('hex string expected, got ' + typeof hex);\n const hl = hex.length;\n const al = hl / 2;\n if (hl % 2) throw new Error('padded hex string expected, got unpadded hex of length ' + hl);\n const array = new Uint8Array(al);\n for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {\n const n1 = asciiToBase16(hex.charCodeAt(hi));\n const n2 = asciiToBase16(hex.charCodeAt(hi + 1));\n if (n1 === undefined || n2 === undefined) {\n const char = hex[hi] + hex[hi + 1];\n throw new Error('hex string expected, got non-hex character \"' + char + '\" at index ' + hi);\n }\n array[ai] = n1 * 16 + n2;\n }\n return array;\n}\n\n// There is no setImmediate in browser and setTimeout is slow.\n// call of async fn will return Promise, which will be fullfiled only on\n// next scheduler queue processing step and this is exactly what we need.\nexport const nextTick = async () => {};\n\n// Returns control to thread each 'tick' ms to avoid blocking\nexport async function asyncLoop(iters: number, tick: number, cb: (i: number) => void) {\n let ts = Date.now();\n for (let i = 0; i < iters; i++) {\n cb(i);\n // Date.now() is not monotonic, so in case if clock goes backwards we return return control too\n const diff = Date.now() - ts;\n if (diff >= 0 && diff < tick) continue;\n await nextTick();\n ts += diff;\n }\n}\n\n// Global symbols in both browsers and Node.js since v11\n// See https://github.com/microsoft/TypeScript/issues/31535\ndeclare const TextEncoder: any;\n\n/**\n * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])\n */\nexport function utf8ToBytes(str: string): Uint8Array {\n if (typeof str !== 'string') throw new Error(`utf8ToBytes expected string, got ${typeof str}`);\n return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809\n}\n\nexport type Input = Uint8Array | string;\n/**\n * Normalizes (non-hex) string or Uint8Array to Uint8Array.\n * Warning: when Uint8Array is passed, it would NOT get copied.\n * Keep in mind for future mutable operations.\n */\nexport function toBytes(data: Input): Uint8Array {\n if (typeof data === 'string') data = utf8ToBytes(data);\n abytes(data);\n return data;\n}\n\n/**\n * Copies several Uint8Arrays into one.\n */\nexport function concatBytes(...arrays: Uint8Array[]): Uint8Array {\n let sum = 0;\n for (let i = 0; i < arrays.length; i++) {\n const a = arrays[i];\n abytes(a);\n sum += a.length;\n }\n const res = new Uint8Array(sum);\n for (let i = 0, pad = 0; i < arrays.length; i++) {\n const a = arrays[i];\n res.set(a, pad);\n pad += a.length;\n }\n return res;\n}\n\n// For runtime check if class implements interface\nexport abstract class Hash<T extends Hash<T>> {\n abstract blockLen: number; // Bytes per block\n abstract outputLen: number; // Bytes in output\n abstract update(buf: Input): this;\n // Writes digest into buf\n abstract digestInto(buf: Uint8Array): void;\n abstract digest(): Uint8Array;\n /**\n * Resets internal state. Makes Hash instance unusable.\n * Reset is impossible for keyed hashes if key is consumed into state. If digest is not consumed\n * by user, they will need to manually call `destroy()` when zeroing is necessary.\n */\n abstract destroy(): void;\n /**\n * Clones hash instance. Unsafe: doesn't check whether `to` is valid. Can be used as `clone()`\n * when no options are passed.\n * Reasons to use `_cloneInto` instead of clone: 1) performance 2) reuse instance => all internal\n * buffers are overwritten => causes buffer overwrite which is used for digest in some cases.\n * There are no guarantees for clean-up because it's impossible in JS.\n */\n abstract _cloneInto(to?: T): T;\n // Safe version that clones internal state\n clone(): T {\n return this._cloneInto();\n }\n}\n\n/**\n * XOF: streaming API to read digest in chunks.\n * Same as 'squeeze' in keccak/k12 and 'seek' in blake3, but more generic name.\n * When hash used in XOF mode it is up to user to call '.destroy' afterwards, since we cannot\n * destroy state, next call can require more bytes.\n */\nexport type HashXOF<T extends Hash<T>> = Hash<T> & {\n xof(bytes: number): Uint8Array; // Read 'bytes' bytes from digest stream\n xofInto(buf: Uint8Array): Uint8Array; // read buf.length bytes from digest stream into buf\n};\n\nconst toStr = {}.toString;\ntype EmptyObj = {};\nexport function checkOpts<T1 extends EmptyObj, T2 extends EmptyObj>(\n defaults: T1,\n opts?: T2\n): T1 & T2 {\n if (opts !== undefined && toStr.call(opts) !== '[object Object]')\n throw new Error('Options should be object or undefined');\n const merged = Object.assign(defaults, opts);\n return merged as T1 & T2;\n}\n\nexport type CHash = ReturnType<typeof wrapConstructor>;\n\nexport function wrapConstructor<T extends Hash<T>>(hashCons: () => Hash<T>) {\n const hashC = (msg: Input): Uint8Array => hashCons().update(toBytes(msg)).digest();\n const tmp = hashCons();\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = () => hashCons();\n return hashC;\n}\n\nexport function wrapConstructorWithOpts<H extends Hash<H>, T extends Object>(\n hashCons: (opts?: T) => Hash<H>\n) {\n const hashC = (msg: Input, opts?: T): Uint8Array => hashCons(opts).update(toBytes(msg)).digest();\n const tmp = hashCons({} as T);\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = (opts: T) => hashCons(opts);\n return hashC;\n}\n\nexport function wrapXOFConstructorWithOpts<H extends HashXOF<H>, T extends Object>(\n hashCons: (opts?: T) => HashXOF<H>\n) {\n const hashC = (msg: Input, opts?: T): Uint8Array => hashCons(opts).update(toBytes(msg)).digest();\n const tmp = hashCons({} as T);\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = (opts: T) => hashCons(opts);\n return hashC;\n}\n\n/**\n * Secure PRNG. Uses `crypto.getRandomValues`, which defers to OS.\n */\nexport function randomBytes(bytesLength = 32): Uint8Array {\n if (crypto && typeof crypto.getRandomValues === 'function') {\n return crypto.getRandomValues(new Uint8Array(bytesLength));\n }\n // Legacy Node.js compatibility\n if (crypto && typeof crypto.randomBytes === 'function') {\n return crypto.randomBytes(bytesLength);\n }\n throw new Error('crypto.getRandomValues must be defined');\n}\n", "import { exists, output } from './_assert.js';\nimport { Hash, createView, Input, toBytes } from './utils.js';\n\n/**\n * Polyfill for Safari 14\n */\nfunction setBigUint64(view: DataView, byteOffset: number, value: bigint, isLE: boolean): void {\n if (typeof view.setBigUint64 === 'function') return view.setBigUint64(byteOffset, value, isLE);\n const _32n = BigInt(32);\n const _u32_max = BigInt(0xffffffff);\n const wh = Number((value >> _32n) & _u32_max);\n const wl = Number(value & _u32_max);\n const h = isLE ? 4 : 0;\n const l = isLE ? 0 : 4;\n view.setUint32(byteOffset + h, wh, isLE);\n view.setUint32(byteOffset + l, wl, isLE);\n}\n\n/**\n * Choice: a ? b : c\n */\nexport const Chi = (a: number, b: number, c: number) => (a & b) ^ (~a & c);\n\n/**\n * Majority function, true if any two inputs is true\n */\nexport const Maj = (a: number, b: number, c: number) => (a & b) ^ (a & c) ^ (b & c);\n\n/**\n * Merkle-Damgard hash construction base class.\n * Could be used to create MD5, RIPEMD, SHA1, SHA2.\n */\nexport abstract class HashMD<T extends HashMD<T>> extends Hash<T> {\n protected abstract process(buf: DataView, offset: number): void;\n protected abstract get(): number[];\n protected abstract set(...args: number[]): void;\n abstract destroy(): void;\n protected abstract roundClean(): void;\n // For partial updates less than block size\n protected buffer: Uint8Array;\n protected view: DataView;\n protected finished = false;\n protected length = 0;\n protected pos = 0;\n protected destroyed = false;\n\n constructor(\n readonly blockLen: number,\n public outputLen: number,\n readonly padOffset: number,\n readonly isLE: boolean\n ) {\n super();\n this.buffer = new Uint8Array(blockLen);\n this.view = createView(this.buffer);\n }\n update(data: Input): this {\n exists(this);\n const { view, buffer, blockLen } = this;\n data = toBytes(data);\n const len = data.length;\n for (let pos = 0; pos < len; ) {\n const take = Math.min(blockLen - this.pos, len - pos);\n // Fast path: we have at least one block in input, cast it to view and process\n if (take === blockLen) {\n const dataView = createView(data);\n for (; blockLen <= len - pos; pos += blockLen) this.process(dataView, pos);\n continue;\n }\n buffer.set(data.subarray(pos, pos + take), this.pos);\n this.pos += take;\n pos += take;\n if (this.pos === blockLen) {\n this.process(view, 0);\n this.pos = 0;\n }\n }\n this.length += data.length;\n this.roundClean();\n return this;\n }\n digestInto(out: Uint8Array) {\n exists(this);\n output(out, this);\n this.finished = true;\n // Padding\n // We can avoid allocation of buffer for padding completely if it\n // was previously not allocated here. But it won't change performance.\n const { buffer, view, blockLen, isLE } = this;\n let { pos } = this;\n // append the bit '1' to the message\n buffer[pos++] = 0b10000000;\n this.buffer.subarray(pos).fill(0);\n // we have less than padOffset left in buffer, so we cannot put length in\n // current block, need process it and pad again\n if (this.padOffset > blockLen - pos) {\n this.process(view, 0);\n pos = 0;\n }\n // Pad until full block byte with zeros\n for (let i = pos; i < blockLen; i++) buffer[i] = 0;\n // Note: sha512 requires length to be 128bit integer, but length in JS will overflow before that\n // You need to write around 2 exabytes (u64_max / 8 / (1024**6)) for this to happen.\n // So we just write lowest 64 bits of that value.\n setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);\n this.process(view, 0);\n const oview = createView(out);\n const len = this.outputLen;\n // NOTE: we do division by 4 later, which should be fused in single op with modulo by JIT\n if (len % 4) throw new Error('_sha2: outputLen should be aligned to 32bit');\n const outLen = len / 4;\n const state = this.get();\n if (outLen > state.length) throw new Error('_sha2: outputLen bigger than state');\n for (let i = 0; i < outLen; i++) oview.setUint32(4 * i, state[i], isLE);\n }\n digest() {\n const { buffer, outputLen } = this;\n this.digestInto(buffer);\n const res = buffer.slice(0, outputLen);\n this.destroy();\n return res;\n }\n _cloneInto(to?: T): T {\n to ||= new (this.constructor as any)() as T;\n to.set(...this.get());\n const { blockLen, buffer, length, finished, destroyed, pos } = this;\n to.length = length;\n to.pos = pos;\n to.finished = finished;\n to.destroyed = destroyed;\n if (length % blockLen) to.buffer.set(buffer);\n return to;\n }\n}\n", "import { HashMD, Chi, Maj } from './_md.js';\nimport { rotr, wrapConstructor } from './utils.js';\n\n// SHA2-256 need to try 2^128 hashes to execute birthday attack.\n// BTC network is doing 2^67 hashes/sec as per early 2023.\n\n// Round constants:\n// first 32 bits of the fractional parts of the cube roots of the first 64 primes 2..311)\n// prettier-ignore\nconst SHA256_K = /* @__PURE__ */ new Uint32Array([\n 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,\n 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,\n 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,\n 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,\n 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,\n 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,\n 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,\n 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2\n]);\n\n// Initial state:\n// first 32 bits of the fractional parts of the square roots of the first 8 primes 2..19\n// prettier-ignore\nconst SHA256_IV = /* @__PURE__ */ new Uint32Array([\n 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19\n]);\n\n// Temporary buffer, not used to store anything between runs\n// Named this way because it matches specification.\nconst SHA256_W = /* @__PURE__ */ new Uint32Array(64);\nexport class SHA256 extends HashMD<SHA256> {\n // We cannot use array here since array allows indexing by variable\n // which means optimizer/compiler cannot use registers.\n A = SHA256_IV[0] | 0;\n B = SHA256_IV[1] | 0;\n C = SHA256_IV[2] | 0;\n D = SHA256_IV[3] | 0;\n E = SHA256_IV[4] | 0;\n F = SHA256_IV[5] | 0;\n G = SHA256_IV[6] | 0;\n H = SHA256_IV[7] | 0;\n\n constructor() {\n super(64, 32, 8, false);\n }\n protected get(): [number, number, number, number, number, number, number, number] {\n const { A, B, C, D, E, F, G, H } = this;\n return [A, B, C, D, E, F, G, H];\n }\n // prettier-ignore\n protected set(\n A: number, B: number, C: number, D: number, E: number, F: number, G: number, H: number\n ) {\n this.A = A | 0;\n this.B = B | 0;\n this.C = C | 0;\n this.D = D | 0;\n this.E = E | 0;\n this.F = F | 0;\n this.G = G | 0;\n this.H = H | 0;\n }\n protected process(view: DataView, offset: number): void {\n // Extend the first 16 words into the remaining 48 words w[16..63] of the message schedule array\n for (let i = 0; i < 16; i++, offset += 4) SHA256_W[i] = view.getUint32(offset, false);\n for (let i = 16; i < 64; i++) {\n const W15 = SHA256_W[i - 15];\n const W2 = SHA256_W[i - 2];\n const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ (W15 >>> 3);\n const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ (W2 >>> 10);\n SHA256_W[i] = (s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16]) | 0;\n }\n // Compression function main loop, 64 rounds\n let { A, B, C, D, E, F, G, H } = this;\n for (let i = 0; i < 64; i++) {\n const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);\n const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0;\n const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22);\n const T2 = (sigma0 + Maj(A, B, C)) | 0;\n H = G;\n G = F;\n F = E;\n E = (D + T1) | 0;\n D = C;\n C = B;\n B = A;\n A = (T1 + T2) | 0;\n }\n // Add the compressed chunk to the current hash value\n A = (A + this.A) | 0;\n B = (B + this.B) | 0;\n C = (C + this.C) | 0;\n D = (D + this.D) | 0;\n E = (E + this.E) | 0;\n F = (F + this.F) | 0;\n G = (G + this.G) | 0;\n H = (H + this.H) | 0;\n this.set(A, B, C, D, E, F, G, H);\n }\n protected roundClean() {\n SHA256_W.fill(0);\n }\n destroy() {\n this.set(0, 0, 0, 0, 0, 0, 0, 0);\n this.buffer.fill(0);\n }\n}\n// Constants from https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf\nclass SHA224 extends SHA256 {\n A = 0xc1059ed8 | 0;\n B = 0x367cd507 | 0;\n C = 0x3070dd17 | 0;\n D = 0xf70e5939 | 0;\n E = 0xffc00b31 | 0;\n F = 0x68581511 | 0;\n G = 0x64f98fa7 | 0;\n H = 0xbefa4fa4 | 0;\n constructor() {\n super();\n this.outputLen = 28;\n }\n}\n\n/**\n * SHA2-256 hash function\n * @param message - data that would be hashed\n */\nexport const sha256 = /* @__PURE__ */ wrapConstructor(() => new SHA256());\n/**\n * SHA2-224 hash function\n */\nexport const sha224 = /* @__PURE__ */ wrapConstructor(() => new SHA224());\n"],
5
- "mappings": "yPAAA,IAAAA,EAAAC,EAAA,CAAAC,GAAAC,IAAA,cAOA,IAAMC,GACJ,6DAEFD,EAAO,QAAUC,KCVjB,IAAAC,GAAAC,EAAA,CAAAC,GAAAC,KAAA,cAEA,IAAMC,GAAe,IAuBfC,GAAmBC,GAAgB,CACvC,GAAI,CAACA,GAAgB,OAAOA,GAAiB,SAC3C,MAAM,IAAI,MAAM,wCAAmCA,CAAY,QAAG,EACpE,GAAIA,EAAa,MAAM,WAAW,EAChC,MAAM,IAAI,MACR,kCAA6BA,EAAa,MAAM,WAAW,CAAC,QAC9D,EACF,IAAMC,EAAKD,EAAa,MAAM,QAAQ,EAChCE,EAAMD,EAAKA,EAAG,CAAC,E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,CAAE,QAAArB,EAAS,QAAAC,CAAQ,CAAC,EAChD,IAAK,GACH,MAAM,IAAI+B,EACZ,QACE,MAAM,IAAIf,CACd,CACF",
6
- "names": ["require_base58_chars", "__commonJSMin", "exports", "module", "base58_chars", "require_base58_to_binary", "__commonJSMin", "exports", "module", "base58_chars", "base58_to_binary", "base58String", "lz", "psz", "size", "i", "acc", "j", "x", "lastValue", "value", "require_create_base58_map", "__commonJSMin", "exports", "module", "base58_chars", "create_base58_map", "base58M", "i", "require_binary_to_base58", "__commonJSMin", "exports", "module", "base58_chars", "create_base58_map", "base58Map", "binary_to_base58", "uint8array", "result", "byte", "carry", "j", "x", "require_public", "__commonJSMin", "exports", "require_dist", "__commonJSMin", "exports", "ALPHABET", "ALPHABET_MAP", "z", "x", "polymodStep", "pre", "b", "prefixChk", "prefix", "chk", "i", "c", "v", "convert", "data", "inBits", "outBits", "pad", "value", "bits", "maxV", "result", "toWords", "bytes", "fromWordsUnsafe", "words", "res", "fromWords", "getLibraryFromEncoding", "encoding", "ENCODING_CONST", "encode", "LIMIT", "__decode", "str", "lowered", "uppered", "split", "wordChars", "decodeUnsafe", "decode", "BtcNetwork", "BtcAddressType", "ParseBtcAddressError", "ParseBtcAddressInvalidError", "ParseBtcAddressNoDataError", "ParseBtcAddressUnsupportedAddressTypeError", "ParseBtcAddressBadWitnessLengthError", "ParseBtcAddressUnsupportedWitnessVersionError", "ParseBtcAddressUnexpectedHumanReadablePartError", "ParseBtcAddressMalformedAddressError", "ParseBtcAddressWrongNetworkError", "isNullish", "isBytes", "a", "bytes", "b", "lengths", "exists", "instance", "checkFinished", "output", "out", "bytes", "min", "createView", "arr", "rotr", "word", "shift", "isLE", "utf8ToBytes", "str", "toBytes", "data", "bytes", "Hash", "toStr", "wrapConstructor", "hashCons", "hashC", "msg", "toBytes", "tmp", "setBigUint64", "view", "byteOffset", "value", "isLE", "_32n", "_u32_max", "wh", "wl", "h", "l", "Chi", "a", "b", "c", "Maj", "HashMD", "Hash", "blockLen", "outputLen", "padOffset", "createView", "data", "exists", "buffer", "toBytes", "len", "pos", "take", "dataView", "out", "output", "i", "oview", "outLen", "state", "res", "to", "length", "finished", "destroyed", "SHA256_K", "SHA256_IV", "SHA256_W", "SHA256", "HashMD", "A", "B", "C", "D", "E", "F", "G", "H", "view", "offset", "i", "W15", "W2", "s0", "rotr", "s1", "sigma1", "T1", "Chi", "T2", "Maj", "sha256", "wrapConstructor", "SHA256", "import_base58_js", "import_bech32", "BTC_MAINNET_PREFIX", "BTC_MAINNET_P2SH_PREFIX", "BTC_TESTNET_PREFIX", "BTC_TESTNET_P2SH_PREFIX", "Base58AddressTypes", "parseBase58Address", "address", "network", "decoded", "ParseBtcAddressInvalidError", "length", "ParseBtcAddressMalformedAddressError", "expectedChecksum", "body", "bodyHash", "sha256", "checksumHash", "checksum", "value", "index", "version", "versionNetwork", "isNullish", "ParseBtcAddressUnsupportedAddressTypeError", "type", "networks", "ParseBtcAddressWrongNetworkError", "parseBip173Address", "decodeBech32", "prefix", "words", "decodedNetwork", "ParseBtcAddressUnexpectedHumanReadablePartError", "witnessVersion", "rest", "ParseBtcAddressUnsupportedWitnessVersionError", "ParseBtcAddressBadWitnessLengthError", "parseBtcAddress", "ParseBtcAddressNoDataError"]
3
+ "sources": ["../../../../node_modules/bech32/dist/index.js", "../../src/enums/btc.enums.ts", "../../src/errors/btc.errors.ts", "../../src/utils/btc.utils.ts", "../../node_modules/@noble/hashes/src/utils.ts", "../../node_modules/@noble/hashes/src/_md.ts", "../../node_modules/@noble/hashes/src/sha2.ts", "../../node_modules/base58-js/base58_chars.js", "../../node_modules/base58-js/base58_to_binary.js"],
4
+ "sourcesContent": ["'use strict';\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.bech32m = exports.bech32 = void 0;\nconst ALPHABET = 'qpzry9x8gf2tvdw0s3jn54khce6mua7l';\nconst ALPHABET_MAP = {};\nfor (let z = 0; z < ALPHABET.length; z++) {\n const x = ALPHABET.charAt(z);\n ALPHABET_MAP[x] = z;\n}\nfunction polymodStep(pre) {\n const b = pre >> 25;\n return (((pre & 0x1ffffff) << 5) ^\n (-((b >> 0) & 1) & 0x3b6a57b2) ^\n (-((b >> 1) & 1) & 0x26508e6d) ^\n (-((b >> 2) & 1) & 0x1ea119fa) ^\n (-((b >> 3) & 1) & 0x3d4233dd) ^\n (-((b >> 4) & 1) & 0x2a1462b3));\n}\nfunction prefixChk(prefix) {\n let chk = 1;\n for (let i = 0; i < prefix.length; ++i) {\n const c = prefix.charCodeAt(i);\n if (c < 33 || c > 126)\n return 'Invalid prefix (' + prefix + ')';\n chk = polymodStep(chk) ^ (c >> 5);\n }\n chk = polymodStep(chk);\n for (let i = 0; i < prefix.length; ++i) {\n const v = prefix.charCodeAt(i);\n chk = polymodStep(chk) ^ (v & 0x1f);\n }\n return chk;\n}\nfunction convert(data, inBits, outBits, pad) {\n let value = 0;\n let bits = 0;\n const maxV = (1 << outBits) - 1;\n const result = [];\n for (let i = 0; i < data.length; ++i) {\n value = (value << inBits) | data[i];\n bits += inBits;\n while (bits >= outBits) {\n bits -= outBits;\n result.push((value >> bits) & maxV);\n }\n }\n if (pad) {\n if (bits > 0) {\n result.push((value << (outBits - bits)) & maxV);\n }\n }\n else {\n if (bits >= inBits)\n return 'Excess padding';\n if ((value << (outBits - bits)) & maxV)\n return 'Non-zero padding';\n }\n return result;\n}\nfunction toWords(bytes) {\n return convert(bytes, 8, 5, true);\n}\nfunction fromWordsUnsafe(words) {\n const res = convert(words, 5, 8, false);\n if (Array.isArray(res))\n return res;\n}\nfunction fromWords(words) {\n const res = convert(words, 5, 8, false);\n if (Array.isArray(res))\n return res;\n throw new Error(res);\n}\nfunction getLibraryFromEncoding(encoding) {\n let ENCODING_CONST;\n if (encoding === 'bech32') {\n ENCODING_CONST = 1;\n }\n else {\n ENCODING_CONST = 0x2bc830a3;\n }\n function encode(prefix, words, LIMIT) {\n LIMIT = LIMIT || 90;\n if (prefix.length + 7 + words.length > LIMIT)\n throw new TypeError('Exceeds length limit');\n prefix = prefix.toLowerCase();\n // determine chk mod\n let chk = prefixChk(prefix);\n if (typeof chk === 'string')\n throw new Error(chk);\n let result = prefix + '1';\n for (let i = 0; i < words.length; ++i) {\n const x = words[i];\n if (x >> 5 !== 0)\n throw new Error('Non 5-bit word');\n chk = polymodStep(chk) ^ x;\n result += ALPHABET.charAt(x);\n }\n for (let i = 0; i < 6; ++i) {\n chk = polymodStep(chk);\n }\n chk ^= ENCODING_CONST;\n for (let i = 0; i < 6; ++i) {\n const v = (chk >> ((5 - i) * 5)) & 0x1f;\n result += ALPHABET.charAt(v);\n }\n return result;\n }\n function __decode(str, LIMIT) {\n LIMIT = LIMIT || 90;\n if (str.length < 8)\n return str + ' too short';\n if (str.length > LIMIT)\n return 'Exceeds length limit';\n // don't allow mixed case\n const lowered = str.toLowerCase();\n const uppered = str.toUpperCase();\n if (str !== lowered && str !== uppered)\n return 'Mixed-case string ' + str;\n str = lowered;\n const split = str.lastIndexOf('1');\n if (split === -1)\n return 'No separator character for ' + str;\n if (split === 0)\n return 'Missing prefix for ' + str;\n const prefix = str.slice(0, split);\n const wordChars = str.slice(split + 1);\n if (wordChars.length < 6)\n return 'Data too short';\n let chk = prefixChk(prefix);\n if (typeof chk === 'string')\n return chk;\n const words = [];\n for (let i = 0; i < wordChars.length; ++i) {\n const c = wordChars.charAt(i);\n const v = ALPHABET_MAP[c];\n if (v === undefined)\n return 'Unknown character ' + c;\n chk = polymodStep(chk) ^ v;\n // not in the checksum?\n if (i + 6 >= wordChars.length)\n continue;\n words.push(v);\n }\n if (chk !== ENCODING_CONST)\n return 'Invalid checksum for ' + str;\n return { prefix, words };\n }\n function decodeUnsafe(str, LIMIT) {\n const res = __decode(str, LIMIT);\n if (typeof res === 'object')\n return res;\n }\n function decode(str, LIMIT) {\n const res = __decode(str, LIMIT);\n if (typeof res === 'object')\n return res;\n throw new Error(res);\n }\n return {\n decodeUnsafe,\n decode,\n encode,\n toWords,\n fromWordsUnsafe,\n fromWords,\n };\n}\nexports.bech32 = getLibraryFromEncoding('bech32');\nexports.bech32m = getLibraryFromEncoding('bech32m');\n", "// As defined on Bitcoin network.\n// e.g. https://developer.bitcoin.org/examples/testing.html\nexport enum BtcNetwork {\n Mainnet,\n Regtest,\n Testnet,\n}\n\n// See https://github.com/dfinity/ic/blob/a8da3aa23dc6f8f4708cb0cb8edce84c5bd8f225/rs/bitcoin/ckbtc/minter/src/address.rs#L18\nexport enum BtcAddressType {\n P2wpkhV0,\n P2pkh,\n P2sh,\n P2wsh,\n P2tr,\n}\n", "export class ParseBtcAddressError extends Error {}\nexport class ParseBtcAddressInvalidError extends ParseBtcAddressError {}\nexport class ParseBtcAddressNoDataError extends ParseBtcAddressError {}\nexport class ParseBtcAddressUnsupportedAddressTypeError extends ParseBtcAddressError {}\nexport class ParseBtcAddressBadWitnessLengthError extends ParseBtcAddressError {}\nexport class ParseBtcAddressUnsupportedWitnessVersionError extends ParseBtcAddressError {}\nexport class ParseBtcAddressUnexpectedHumanReadablePartError extends ParseBtcAddressError {}\nexport class ParseBtcAddressMalformedAddressError extends ParseBtcAddressError {}\nexport class ParseBtcAddressWrongNetworkError extends ParseBtcAddressError {}\n", "import { isNullish } from \"@dfinity/utils\";\nimport { sha256 } from \"@noble/hashes/sha2\";\nimport { base58_to_binary } from \"base58-js\";\nimport { bech32, bech32m, type Decoded } from \"bech32\";\nimport { BtcAddressType, BtcNetwork } from \"../enums/btc.enums\";\nimport {\n ParseBtcAddressBadWitnessLengthError,\n ParseBtcAddressInvalidError,\n ParseBtcAddressMalformedAddressError,\n ParseBtcAddressNoDataError,\n ParseBtcAddressUnexpectedHumanReadablePartError,\n ParseBtcAddressUnsupportedAddressTypeError,\n ParseBtcAddressUnsupportedWitnessVersionError,\n ParseBtcAddressWrongNetworkError,\n} from \"../errors/btc.errors\";\nimport type { BtcAddress, BtcAddressInfo } from \"../types/btc\";\n\n// See https://en.bitcoin.it/wiki/List_of_address_prefixes\nconst BTC_MAINNET_PREFIX = 0; // or 0x00\nconst BTC_MAINNET_P2SH_PREFIX = 5; // or 0x05\nconst BTC_TESTNET_PREFIX = 111; // or 0x6f\nconst BTC_TESTNET_P2SH_PREFIX = 196; // or 0xc4\n\nconst Base58AddressTypes: Record<\n number,\n { type: BtcAddressType; networks: BtcNetwork[] }\n> = {\n [BTC_MAINNET_PREFIX]: {\n type: BtcAddressType.P2pkh,\n networks: [BtcNetwork.Mainnet],\n },\n\n [BTC_TESTNET_PREFIX]: {\n type: BtcAddressType.P2pkh,\n networks: [BtcNetwork.Testnet, BtcNetwork.Regtest],\n },\n\n [BTC_MAINNET_P2SH_PREFIX]: {\n type: BtcAddressType.P2sh,\n networks: [BtcNetwork.Mainnet],\n },\n\n [BTC_TESTNET_P2SH_PREFIX]: {\n type: BtcAddressType.P2sh,\n networks: [BtcNetwork.Testnet, BtcNetwork.Regtest],\n },\n};\n\nconst parseBase58Address = ({\n address,\n network,\n}: Required<BtcAddress>): BtcAddressInfo => {\n const decodeBase58 = (address: string): Uint8Array => {\n try {\n return base58_to_binary(address);\n } catch (_error: unknown) {\n throw new ParseBtcAddressInvalidError();\n }\n };\n\n const decoded: Uint8Array = decodeBase58(address);\n\n const { length } = decoded;\n\n if (length !== 25) {\n throw new ParseBtcAddressMalformedAddressError(\n `Expected the address to be 25 bytes, got ${length}.`,\n );\n }\n\n const validateBase58Checksum = (decoded: Uint8Array) => {\n const expectedChecksum = decoded.slice(length - 4, length);\n const body = decoded.slice(0, length - 4);\n\n const bodyHash = sha256.create();\n bodyHash.update(body);\n\n const checksumHash = sha256.create();\n checksumHash.update(bodyHash.digest());\n\n const checksum = checksumHash.digest().slice(0, 4);\n\n if (\n expectedChecksum.some(\n (value: number, index: number) => value !== checksum[index],\n )\n ) {\n throw new ParseBtcAddressMalformedAddressError(\n `Checksum mismatch expected ${expectedChecksum}, got ${checksum}.`,\n );\n }\n };\n\n validateBase58Checksum(decoded);\n\n const [version] = decoded;\n\n const versionNetwork = Base58AddressTypes[version];\n\n if (isNullish(versionNetwork)) {\n throw new ParseBtcAddressUnsupportedAddressTypeError();\n }\n\n const { type, networks } = versionNetwork;\n\n if (!networks.includes(network)) {\n throw new ParseBtcAddressWrongNetworkError();\n }\n\n return {\n address,\n network,\n type,\n parser: \"base58\",\n };\n};\n\nconst parseBip173Address = ({\n address,\n network,\n}: Required<BtcAddress>): BtcAddressInfo => {\n const decodeBech32 = (address: string): Decoded => {\n try {\n if (\n address.startsWith(\"bc1p\") ||\n address.startsWith(\"tb1p\") ||\n address.startsWith(\"bcrt1p\")\n ) {\n return bech32m.decode(address);\n }\n\n return bech32.decode(address);\n } catch (_error: unknown) {\n throw new ParseBtcAddressMalformedAddressError();\n }\n };\n\n const { prefix, words } = decodeBech32(address);\n\n const mapPrefixToNetwork: Record<string, BtcNetwork> = {\n bc: BtcNetwork.Mainnet,\n tb: BtcNetwork.Testnet,\n bcrt: BtcNetwork.Regtest,\n };\n\n const decodedNetwork: BtcNetwork | undefined = mapPrefixToNetwork[prefix];\n\n if (isNullish(decodedNetwork)) {\n throw new ParseBtcAddressInvalidError();\n }\n\n if (decodedNetwork !== network) {\n throw new ParseBtcAddressUnexpectedHumanReadablePartError();\n }\n\n const [witnessVersion, ...rest] = words;\n\n if (witnessVersion > 1) {\n throw new ParseBtcAddressUnsupportedWitnessVersionError();\n }\n\n const data = bech32.fromWords(rest);\n\n switch (data.length) {\n case 20:\n return {\n address,\n network,\n type: BtcAddressType.P2wpkhV0,\n parser: \"bip-173\",\n };\n case 32:\n return {\n address,\n network,\n type: witnessVersion === 0 ? BtcAddressType.P2wsh : BtcAddressType.P2tr,\n parser: \"bip-173\",\n };\n default:\n throw new ParseBtcAddressBadWitnessLengthError();\n }\n};\n\n/**\n * Parse a Bitcoin address.\n *\n * Parse implementation follows strategy implemented in [Minter canister](https://github.com/dfinity/ic/blob/a8da3aa23dc6f8f4708cb0cb8edce84c5bd8f225/rs/bitcoin/ckbtc/minter/src/address.rs#L54).\n *\n * Credits: Parts of JavaScript code and test values from [bitcoin-address-validation](https://github.com/ruigomeseu/bitcoin-address-validation).\n *\n * @param {BtcAddress} params The Bitcoin address and network to parse\n * @param {string} params.address\n * @param {BtcNetwork} params.network Optional. Default BtcNetwork is Mainnet\n */\nexport const parseBtcAddress = ({\n address,\n network = BtcNetwork.Mainnet,\n}: BtcAddress): BtcAddressInfo => {\n switch (address.charAt(0)) {\n case \"1\":\n case \"2\":\n case \"3\":\n case \"m\":\n case \"n\":\n return parseBase58Address({ address, network });\n case \"b\":\n case \"B\":\n case \"t\":\n case \"T\":\n return parseBip173Address({ address, network });\n case \"\":\n throw new ParseBtcAddressNoDataError();\n default:\n throw new ParseBtcAddressUnsupportedAddressTypeError();\n }\n};\n", "/**\n * Utilities for hex, bytes, CSPRNG.\n * @module\n */\n/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */\n\n// We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+.\n// node.js versions earlier than v19 don't declare it in global scope.\n// For node.js, package.json#exports field mapping rewrites import\n// from `crypto` to `cryptoNode`, which imports native module.\n// Makes the utils un-importable in browsers without a bundler.\n// Once node.js 18 is deprecated (2025-04-30), we can just drop the import.\nimport { crypto } from '@noble/hashes/crypto';\n\n/** Checks if something is Uint8Array. Be careful: nodejs Buffer will return true. */\nexport function isBytes(a: unknown): a is Uint8Array {\n return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array');\n}\n\n/** Asserts something is positive integer. */\nexport function anumber(n: number): void {\n if (!Number.isSafeInteger(n) || n < 0) throw new Error('positive integer expected, got ' + n);\n}\n\n/** Asserts something is Uint8Array. */\nexport function abytes(b: Uint8Array | undefined, ...lengths: number[]): void {\n if (!isBytes(b)) throw new Error('Uint8Array expected');\n if (lengths.length > 0 && !lengths.includes(b.length))\n throw new Error('Uint8Array expected of length ' + lengths + ', got length=' + b.length);\n}\n\n/** Asserts something is hash */\nexport function ahash(h: IHash): void {\n if (typeof h !== 'function' || typeof h.create !== 'function')\n throw new Error('Hash should be wrapped by utils.createHasher');\n anumber(h.outputLen);\n anumber(h.blockLen);\n}\n\n/** Asserts a hash instance has not been destroyed / finished */\nexport function aexists(instance: any, checkFinished = true): void {\n if (instance.destroyed) throw new Error('Hash instance has been destroyed');\n if (checkFinished && instance.finished) throw new Error('Hash#digest() has already been called');\n}\n\n/** Asserts output is properly-sized byte array */\nexport function aoutput(out: any, instance: any): void {\n abytes(out);\n const min = instance.outputLen;\n if (out.length < min) {\n throw new Error('digestInto() expects output buffer of length at least ' + min);\n }\n}\n\n/** Generic type encompassing 8/16/32-byte arrays - but not 64-byte. */\n// prettier-ignore\nexport type TypedArray = Int8Array | Uint8ClampedArray | Uint8Array |\n Uint16Array | Int16Array | Uint32Array | Int32Array;\n\n/** Cast u8 / u16 / u32 to u8. */\nexport function u8(arr: TypedArray): Uint8Array {\n return new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);\n}\n\n/** Cast u8 / u16 / u32 to u32. */\nexport function u32(arr: TypedArray): Uint32Array {\n return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));\n}\n\n/** Zeroize a byte array. Warning: JS provides no guarantees. */\nexport function clean(...arrays: TypedArray[]): void {\n for (let i = 0; i < arrays.length; i++) {\n arrays[i].fill(0);\n }\n}\n\n/** Create DataView of an array for easy byte-level manipulation. */\nexport function createView(arr: TypedArray): DataView {\n return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);\n}\n\n/** The rotate right (circular right shift) operation for uint32 */\nexport function rotr(word: number, shift: number): number {\n return (word << (32 - shift)) | (word >>> shift);\n}\n\n/** The rotate left (circular left shift) operation for uint32 */\nexport function rotl(word: number, shift: number): number {\n return (word << shift) | ((word >>> (32 - shift)) >>> 0);\n}\n\n/** Is current platform little-endian? Most are. Big-Endian platform: IBM */\nexport const isLE: boolean = /* @__PURE__ */ (() =>\n new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44)();\n\n/** The byte swap operation for uint32 */\nexport function byteSwap(word: number): number {\n return (\n ((word << 24) & 0xff000000) |\n ((word << 8) & 0xff0000) |\n ((word >>> 8) & 0xff00) |\n ((word >>> 24) & 0xff)\n );\n}\n/** Conditionally byte swap if on a big-endian platform */\nexport const swap8IfBE: (n: number) => number = isLE\n ? (n: number) => n\n : (n: number) => byteSwap(n);\n\n/** @deprecated */\nexport const byteSwapIfBE: typeof swap8IfBE = swap8IfBE;\n/** In place byte swap for Uint32Array */\nexport function byteSwap32(arr: Uint32Array): Uint32Array {\n for (let i = 0; i < arr.length; i++) {\n arr[i] = byteSwap(arr[i]);\n }\n return arr;\n}\n\nexport const swap32IfBE: (u: Uint32Array) => Uint32Array = isLE\n ? (u: Uint32Array) => u\n : byteSwap32;\n\n// Built-in hex conversion https://caniuse.com/mdn-javascript_builtins_uint8array_fromhex\nconst hasHexBuiltin: boolean = /* @__PURE__ */ (() =>\n // @ts-ignore\n typeof Uint8Array.from([]).toHex === 'function' && typeof Uint8Array.fromHex === 'function')();\n\n// Array where index 0xf0 (240) is mapped to string 'f0'\nconst hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) =>\n i.toString(16).padStart(2, '0')\n);\n\n/**\n * Convert byte array to hex string. Uses built-in function, when available.\n * @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123'\n */\nexport function bytesToHex(bytes: Uint8Array): string {\n abytes(bytes);\n // @ts-ignore\n if (hasHexBuiltin) return bytes.toHex();\n // pre-caching improves the speed 6x\n let hex = '';\n for (let i = 0; i < bytes.length; i++) {\n hex += hexes[bytes[i]];\n }\n return hex;\n}\n\n// We use optimized technique to convert hex string to byte array\nconst asciis = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 } as const;\nfunction asciiToBase16(ch: number): number | undefined {\n if (ch >= asciis._0 && ch <= asciis._9) return ch - asciis._0; // '2' => 50-48\n if (ch >= asciis.A && ch <= asciis.F) return ch - (asciis.A - 10); // 'B' => 66-(65-10)\n if (ch >= asciis.a && ch <= asciis.f) return ch - (asciis.a - 10); // 'b' => 98-(97-10)\n return;\n}\n\n/**\n * Convert hex string to byte array. Uses built-in function, when available.\n * @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23])\n */\nexport function hexToBytes(hex: string): Uint8Array {\n if (typeof hex !== 'string') throw new Error('hex string expected, got ' + typeof hex);\n // @ts-ignore\n if (hasHexBuiltin) return Uint8Array.fromHex(hex);\n const hl = hex.length;\n const al = hl / 2;\n if (hl % 2) throw new Error('hex string expected, got unpadded hex of length ' + hl);\n const array = new Uint8Array(al);\n for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {\n const n1 = asciiToBase16(hex.charCodeAt(hi));\n const n2 = asciiToBase16(hex.charCodeAt(hi + 1));\n if (n1 === undefined || n2 === undefined) {\n const char = hex[hi] + hex[hi + 1];\n throw new Error('hex string expected, got non-hex character \"' + char + '\" at index ' + hi);\n }\n array[ai] = n1 * 16 + n2; // multiply first octet, e.g. 'a3' => 10*16+3 => 160 + 3 => 163\n }\n return array;\n}\n\n/**\n * There is no setImmediate in browser and setTimeout is slow.\n * Call of async fn will return Promise, which will be fullfiled only on\n * next scheduler queue processing step and this is exactly what we need.\n */\nexport const nextTick = async (): Promise<void> => {};\n\n/** Returns control to thread each 'tick' ms to avoid blocking. */\nexport async function asyncLoop(\n iters: number,\n tick: number,\n cb: (i: number) => void\n): Promise<void> {\n let ts = Date.now();\n for (let i = 0; i < iters; i++) {\n cb(i);\n // Date.now() is not monotonic, so in case if clock goes backwards we return return control too\n const diff = Date.now() - ts;\n if (diff >= 0 && diff < tick) continue;\n await nextTick();\n ts += diff;\n }\n}\n\n// Global symbols, but ts doesn't see them: https://github.com/microsoft/TypeScript/issues/31535\ndeclare const TextEncoder: any;\ndeclare const TextDecoder: any;\n\n/**\n * Converts string to bytes using UTF8 encoding.\n * @example utf8ToBytes('abc') // Uint8Array.from([97, 98, 99])\n */\nexport function utf8ToBytes(str: string): Uint8Array {\n if (typeof str !== 'string') throw new Error('string expected');\n return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809\n}\n\n/**\n * Converts bytes to string using UTF8 encoding.\n * @example bytesToUtf8(Uint8Array.from([97, 98, 99])) // 'abc'\n */\nexport function bytesToUtf8(bytes: Uint8Array): string {\n return new TextDecoder().decode(bytes);\n}\n\n/** Accepted input of hash functions. Strings are converted to byte arrays. */\nexport type Input = string | Uint8Array;\n/**\n * Normalizes (non-hex) string or Uint8Array to Uint8Array.\n * Warning: when Uint8Array is passed, it would NOT get copied.\n * Keep in mind for future mutable operations.\n */\nexport function toBytes(data: Input): Uint8Array {\n if (typeof data === 'string') data = utf8ToBytes(data);\n abytes(data);\n return data;\n}\n\n/** KDFs can accept string or Uint8Array for user convenience. */\nexport type KDFInput = string | Uint8Array;\n/**\n * Helper for KDFs: consumes uint8array or string.\n * When string is passed, does utf8 decoding, using TextDecoder.\n */\nexport function kdfInputToBytes(data: KDFInput): Uint8Array {\n if (typeof data === 'string') data = utf8ToBytes(data);\n abytes(data);\n return data;\n}\n\n/** Copies several Uint8Arrays into one. */\nexport function concatBytes(...arrays: Uint8Array[]): Uint8Array {\n let sum = 0;\n for (let i = 0; i < arrays.length; i++) {\n const a = arrays[i];\n abytes(a);\n sum += a.length;\n }\n const res = new Uint8Array(sum);\n for (let i = 0, pad = 0; i < arrays.length; i++) {\n const a = arrays[i];\n res.set(a, pad);\n pad += a.length;\n }\n return res;\n}\n\ntype EmptyObj = {};\nexport function checkOpts<T1 extends EmptyObj, T2 extends EmptyObj>(\n defaults: T1,\n opts?: T2\n): T1 & T2 {\n if (opts !== undefined && {}.toString.call(opts) !== '[object Object]')\n throw new Error('options should be object or undefined');\n const merged = Object.assign(defaults, opts);\n return merged as T1 & T2;\n}\n\n/** Hash interface. */\nexport type IHash = {\n (data: Uint8Array): Uint8Array;\n blockLen: number;\n outputLen: number;\n create: any;\n};\n\n/** For runtime check if class implements interface */\nexport abstract class Hash<T extends Hash<T>> {\n abstract blockLen: number; // Bytes per block\n abstract outputLen: number; // Bytes in output\n abstract update(buf: Input): this;\n // Writes digest into buf\n abstract digestInto(buf: Uint8Array): void;\n abstract digest(): Uint8Array;\n /**\n * Resets internal state. Makes Hash instance unusable.\n * Reset is impossible for keyed hashes if key is consumed into state. If digest is not consumed\n * by user, they will need to manually call `destroy()` when zeroing is necessary.\n */\n abstract destroy(): void;\n /**\n * Clones hash instance. Unsafe: doesn't check whether `to` is valid. Can be used as `clone()`\n * when no options are passed.\n * Reasons to use `_cloneInto` instead of clone: 1) performance 2) reuse instance => all internal\n * buffers are overwritten => causes buffer overwrite which is used for digest in some cases.\n * There are no guarantees for clean-up because it's impossible in JS.\n */\n abstract _cloneInto(to?: T): T;\n // Safe version that clones internal state\n abstract clone(): T;\n}\n\n/**\n * XOF: streaming API to read digest in chunks.\n * Same as 'squeeze' in keccak/k12 and 'seek' in blake3, but more generic name.\n * When hash used in XOF mode it is up to user to call '.destroy' afterwards, since we cannot\n * destroy state, next call can require more bytes.\n */\nexport type HashXOF<T extends Hash<T>> = Hash<T> & {\n xof(bytes: number): Uint8Array; // Read 'bytes' bytes from digest stream\n xofInto(buf: Uint8Array): Uint8Array; // read buf.length bytes from digest stream into buf\n};\n\n/** Hash function */\nexport type CHash = ReturnType<typeof createHasher>;\n/** Hash function with output */\nexport type CHashO = ReturnType<typeof createOptHasher>;\n/** XOF with output */\nexport type CHashXO = ReturnType<typeof createXOFer>;\n\n/** Wraps hash function, creating an interface on top of it */\nexport function createHasher<T extends Hash<T>>(\n hashCons: () => Hash<T>\n): {\n (msg: Input): Uint8Array;\n outputLen: number;\n blockLen: number;\n create(): Hash<T>;\n} {\n const hashC = (msg: Input): Uint8Array => hashCons().update(toBytes(msg)).digest();\n const tmp = hashCons();\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = () => hashCons();\n return hashC;\n}\n\nexport function createOptHasher<H extends Hash<H>, T extends Object>(\n hashCons: (opts?: T) => Hash<H>\n): {\n (msg: Input, opts?: T): Uint8Array;\n outputLen: number;\n blockLen: number;\n create(opts?: T): Hash<H>;\n} {\n const hashC = (msg: Input, opts?: T): Uint8Array => hashCons(opts).update(toBytes(msg)).digest();\n const tmp = hashCons({} as T);\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = (opts?: T) => hashCons(opts);\n return hashC;\n}\n\nexport function createXOFer<H extends HashXOF<H>, T extends Object>(\n hashCons: (opts?: T) => HashXOF<H>\n): {\n (msg: Input, opts?: T): Uint8Array;\n outputLen: number;\n blockLen: number;\n create(opts?: T): HashXOF<H>;\n} {\n const hashC = (msg: Input, opts?: T): Uint8Array => hashCons(opts).update(toBytes(msg)).digest();\n const tmp = hashCons({} as T);\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = (opts?: T) => hashCons(opts);\n return hashC;\n}\nexport const wrapConstructor: typeof createHasher = createHasher;\nexport const wrapConstructorWithOpts: typeof createOptHasher = createOptHasher;\nexport const wrapXOFConstructorWithOpts: typeof createXOFer = createXOFer;\n\n/** Cryptographically secure PRNG. Uses internal OS-level `crypto.getRandomValues`. */\nexport function randomBytes(bytesLength = 32): Uint8Array {\n if (crypto && typeof crypto.getRandomValues === 'function') {\n return crypto.getRandomValues(new Uint8Array(bytesLength));\n }\n // Legacy Node.js compatibility\n if (crypto && typeof crypto.randomBytes === 'function') {\n return Uint8Array.from(crypto.randomBytes(bytesLength));\n }\n throw new Error('crypto.getRandomValues must be defined');\n}\n", "/**\n * Internal Merkle-Damgard hash utils.\n * @module\n */\nimport { type Input, Hash, abytes, aexists, aoutput, clean, createView, toBytes } from './utils.ts';\n\n/** Polyfill for Safari 14. https://caniuse.com/mdn-javascript_builtins_dataview_setbiguint64 */\nexport function setBigUint64(\n view: DataView,\n byteOffset: number,\n value: bigint,\n isLE: boolean\n): void {\n if (typeof view.setBigUint64 === 'function') return view.setBigUint64(byteOffset, value, isLE);\n const _32n = BigInt(32);\n const _u32_max = BigInt(0xffffffff);\n const wh = Number((value >> _32n) & _u32_max);\n const wl = Number(value & _u32_max);\n const h = isLE ? 4 : 0;\n const l = isLE ? 0 : 4;\n view.setUint32(byteOffset + h, wh, isLE);\n view.setUint32(byteOffset + l, wl, isLE);\n}\n\n/** Choice: a ? b : c */\nexport function Chi(a: number, b: number, c: number): number {\n return (a & b) ^ (~a & c);\n}\n\n/** Majority function, true if any two inputs is true. */\nexport function Maj(a: number, b: number, c: number): number {\n return (a & b) ^ (a & c) ^ (b & c);\n}\n\n/**\n * Merkle-Damgard hash construction base class.\n * Could be used to create MD5, RIPEMD, SHA1, SHA2.\n */\nexport abstract class HashMD<T extends HashMD<T>> extends Hash<T> {\n protected abstract process(buf: DataView, offset: number): void;\n protected abstract get(): number[];\n protected abstract set(...args: number[]): void;\n abstract destroy(): void;\n protected abstract roundClean(): void;\n\n readonly blockLen: number;\n readonly outputLen: number;\n readonly padOffset: number;\n readonly isLE: boolean;\n\n // For partial updates less than block size\n protected buffer: Uint8Array;\n protected view: DataView;\n protected finished = false;\n protected length = 0;\n protected pos = 0;\n protected destroyed = false;\n\n constructor(blockLen: number, outputLen: number, padOffset: number, isLE: boolean) {\n super();\n this.blockLen = blockLen;\n this.outputLen = outputLen;\n this.padOffset = padOffset;\n this.isLE = isLE;\n this.buffer = new Uint8Array(blockLen);\n this.view = createView(this.buffer);\n }\n update(data: Input): this {\n aexists(this);\n data = toBytes(data);\n abytes(data);\n const { view, buffer, blockLen } = this;\n const len = data.length;\n for (let pos = 0; pos < len; ) {\n const take = Math.min(blockLen - this.pos, len - pos);\n // Fast path: we have at least one block in input, cast it to view and process\n if (take === blockLen) {\n const dataView = createView(data);\n for (; blockLen <= len - pos; pos += blockLen) this.process(dataView, pos);\n continue;\n }\n buffer.set(data.subarray(pos, pos + take), this.pos);\n this.pos += take;\n pos += take;\n if (this.pos === blockLen) {\n this.process(view, 0);\n this.pos = 0;\n }\n }\n this.length += data.length;\n this.roundClean();\n return this;\n }\n digestInto(out: Uint8Array): void {\n aexists(this);\n aoutput(out, this);\n this.finished = true;\n // Padding\n // We can avoid allocation of buffer for padding completely if it\n // was previously not allocated here. But it won't change performance.\n const { buffer, view, blockLen, isLE } = this;\n let { pos } = this;\n // append the bit '1' to the message\n buffer[pos++] = 0b10000000;\n clean(this.buffer.subarray(pos));\n // we have less than padOffset left in buffer, so we cannot put length in\n // current block, need process it and pad again\n if (this.padOffset > blockLen - pos) {\n this.process(view, 0);\n pos = 0;\n }\n // Pad until full block byte with zeros\n for (let i = pos; i < blockLen; i++) buffer[i] = 0;\n // Note: sha512 requires length to be 128bit integer, but length in JS will overflow before that\n // You need to write around 2 exabytes (u64_max / 8 / (1024**6)) for this to happen.\n // So we just write lowest 64 bits of that value.\n setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);\n this.process(view, 0);\n const oview = createView(out);\n const len = this.outputLen;\n // NOTE: we do division by 4 later, which should be fused in single op with modulo by JIT\n if (len % 4) throw new Error('_sha2: outputLen should be aligned to 32bit');\n const outLen = len / 4;\n const state = this.get();\n if (outLen > state.length) throw new Error('_sha2: outputLen bigger than state');\n for (let i = 0; i < outLen; i++) oview.setUint32(4 * i, state[i], isLE);\n }\n digest(): Uint8Array {\n const { buffer, outputLen } = this;\n this.digestInto(buffer);\n const res = buffer.slice(0, outputLen);\n this.destroy();\n return res;\n }\n _cloneInto(to?: T): T {\n to ||= new (this.constructor as any)() as T;\n to.set(...this.get());\n const { blockLen, buffer, length, finished, destroyed, pos } = this;\n to.destroyed = destroyed;\n to.finished = finished;\n to.length = length;\n to.pos = pos;\n if (length % blockLen) to.buffer.set(buffer);\n return to;\n }\n clone(): T {\n return this._cloneInto();\n }\n}\n\n/**\n * Initial SHA-2 state: fractional parts of square roots of first 16 primes 2..53.\n * Check out `test/misc/sha2-gen-iv.js` for recomputation guide.\n */\n\n/** Initial SHA256 state. Bits 0..32 of frac part of sqrt of primes 2..19 */\nexport const SHA256_IV: Uint32Array = /* @__PURE__ */ Uint32Array.from([\n 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19,\n]);\n\n/** Initial SHA224 state. Bits 32..64 of frac part of sqrt of primes 23..53 */\nexport const SHA224_IV: Uint32Array = /* @__PURE__ */ Uint32Array.from([\n 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939, 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4,\n]);\n\n/** Initial SHA384 state. Bits 0..64 of frac part of sqrt of primes 23..53 */\nexport const SHA384_IV: Uint32Array = /* @__PURE__ */ Uint32Array.from([\n 0xcbbb9d5d, 0xc1059ed8, 0x629a292a, 0x367cd507, 0x9159015a, 0x3070dd17, 0x152fecd8, 0xf70e5939,\n 0x67332667, 0xffc00b31, 0x8eb44a87, 0x68581511, 0xdb0c2e0d, 0x64f98fa7, 0x47b5481d, 0xbefa4fa4,\n]);\n\n/** Initial SHA512 state. Bits 0..64 of frac part of sqrt of primes 2..19 */\nexport const SHA512_IV: Uint32Array = /* @__PURE__ */ Uint32Array.from([\n 0x6a09e667, 0xf3bcc908, 0xbb67ae85, 0x84caa73b, 0x3c6ef372, 0xfe94f82b, 0xa54ff53a, 0x5f1d36f1,\n 0x510e527f, 0xade682d1, 0x9b05688c, 0x2b3e6c1f, 0x1f83d9ab, 0xfb41bd6b, 0x5be0cd19, 0x137e2179,\n]);\n", "/**\n * SHA2 hash function. A.k.a. sha256, sha384, sha512, sha512_224, sha512_256.\n * SHA256 is the fastest hash implementable in JS, even faster than Blake3.\n * Check out [RFC 4634](https://datatracker.ietf.org/doc/html/rfc4634) and\n * [FIPS 180-4](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf).\n * @module\n */\nimport { Chi, HashMD, Maj, SHA224_IV, SHA256_IV, SHA384_IV, SHA512_IV } from './_md.ts';\nimport * as u64 from './_u64.ts';\nimport { type CHash, clean, createHasher, rotr } from './utils.ts';\n\n/**\n * Round constants:\n * First 32 bits of fractional parts of the cube roots of the first 64 primes 2..311)\n */\n// prettier-ignore\nconst SHA256_K = /* @__PURE__ */ Uint32Array.from([\n 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,\n 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,\n 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,\n 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,\n 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,\n 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,\n 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,\n 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2\n]);\n\n/** Reusable temporary buffer. \"W\" comes straight from spec. */\nconst SHA256_W = /* @__PURE__ */ new Uint32Array(64);\nexport class SHA256 extends HashMD<SHA256> {\n // We cannot use array here since array allows indexing by variable\n // which means optimizer/compiler cannot use registers.\n protected A: number = SHA256_IV[0] | 0;\n protected B: number = SHA256_IV[1] | 0;\n protected C: number = SHA256_IV[2] | 0;\n protected D: number = SHA256_IV[3] | 0;\n protected E: number = SHA256_IV[4] | 0;\n protected F: number = SHA256_IV[5] | 0;\n protected G: number = SHA256_IV[6] | 0;\n protected H: number = SHA256_IV[7] | 0;\n\n constructor(outputLen: number = 32) {\n super(64, outputLen, 8, false);\n }\n protected get(): [number, number, number, number, number, number, number, number] {\n const { A, B, C, D, E, F, G, H } = this;\n return [A, B, C, D, E, F, G, H];\n }\n // prettier-ignore\n protected set(\n A: number, B: number, C: number, D: number, E: number, F: number, G: number, H: number\n ): void {\n this.A = A | 0;\n this.B = B | 0;\n this.C = C | 0;\n this.D = D | 0;\n this.E = E | 0;\n this.F = F | 0;\n this.G = G | 0;\n this.H = H | 0;\n }\n protected process(view: DataView, offset: number): void {\n // Extend the first 16 words into the remaining 48 words w[16..63] of the message schedule array\n for (let i = 0; i < 16; i++, offset += 4) SHA256_W[i] = view.getUint32(offset, false);\n for (let i = 16; i < 64; i++) {\n const W15 = SHA256_W[i - 15];\n const W2 = SHA256_W[i - 2];\n const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ (W15 >>> 3);\n const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ (W2 >>> 10);\n SHA256_W[i] = (s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16]) | 0;\n }\n // Compression function main loop, 64 rounds\n let { A, B, C, D, E, F, G, H } = this;\n for (let i = 0; i < 64; i++) {\n const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);\n const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0;\n const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22);\n const T2 = (sigma0 + Maj(A, B, C)) | 0;\n H = G;\n G = F;\n F = E;\n E = (D + T1) | 0;\n D = C;\n C = B;\n B = A;\n A = (T1 + T2) | 0;\n }\n // Add the compressed chunk to the current hash value\n A = (A + this.A) | 0;\n B = (B + this.B) | 0;\n C = (C + this.C) | 0;\n D = (D + this.D) | 0;\n E = (E + this.E) | 0;\n F = (F + this.F) | 0;\n G = (G + this.G) | 0;\n H = (H + this.H) | 0;\n this.set(A, B, C, D, E, F, G, H);\n }\n protected roundClean(): void {\n clean(SHA256_W);\n }\n destroy(): void {\n this.set(0, 0, 0, 0, 0, 0, 0, 0);\n clean(this.buffer);\n }\n}\n\nexport class SHA224 extends SHA256 {\n protected A: number = SHA224_IV[0] | 0;\n protected B: number = SHA224_IV[1] | 0;\n protected C: number = SHA224_IV[2] | 0;\n protected D: number = SHA224_IV[3] | 0;\n protected E: number = SHA224_IV[4] | 0;\n protected F: number = SHA224_IV[5] | 0;\n protected G: number = SHA224_IV[6] | 0;\n protected H: number = SHA224_IV[7] | 0;\n constructor() {\n super(28);\n }\n}\n\n// SHA2-512 is slower than sha256 in js because u64 operations are slow.\n\n// Round contants\n// First 32 bits of the fractional parts of the cube roots of the first 80 primes 2..409\n// prettier-ignore\nconst K512 = /* @__PURE__ */ (() => u64.split([\n '0x428a2f98d728ae22', '0x7137449123ef65cd', '0xb5c0fbcfec4d3b2f', '0xe9b5dba58189dbbc',\n '0x3956c25bf348b538', '0x59f111f1b605d019', '0x923f82a4af194f9b', '0xab1c5ed5da6d8118',\n '0xd807aa98a3030242', '0x12835b0145706fbe', '0x243185be4ee4b28c', '0x550c7dc3d5ffb4e2',\n '0x72be5d74f27b896f', '0x80deb1fe3b1696b1', '0x9bdc06a725c71235', '0xc19bf174cf692694',\n '0xe49b69c19ef14ad2', '0xefbe4786384f25e3', '0x0fc19dc68b8cd5b5', '0x240ca1cc77ac9c65',\n '0x2de92c6f592b0275', '0x4a7484aa6ea6e483', '0x5cb0a9dcbd41fbd4', '0x76f988da831153b5',\n '0x983e5152ee66dfab', '0xa831c66d2db43210', '0xb00327c898fb213f', '0xbf597fc7beef0ee4',\n '0xc6e00bf33da88fc2', '0xd5a79147930aa725', '0x06ca6351e003826f', '0x142929670a0e6e70',\n '0x27b70a8546d22ffc', '0x2e1b21385c26c926', '0x4d2c6dfc5ac42aed', '0x53380d139d95b3df',\n '0x650a73548baf63de', '0x766a0abb3c77b2a8', '0x81c2c92e47edaee6', '0x92722c851482353b',\n '0xa2bfe8a14cf10364', '0xa81a664bbc423001', '0xc24b8b70d0f89791', '0xc76c51a30654be30',\n '0xd192e819d6ef5218', '0xd69906245565a910', '0xf40e35855771202a', '0x106aa07032bbd1b8',\n '0x19a4c116b8d2d0c8', '0x1e376c085141ab53', '0x2748774cdf8eeb99', '0x34b0bcb5e19b48a8',\n '0x391c0cb3c5c95a63', '0x4ed8aa4ae3418acb', '0x5b9cca4f7763e373', '0x682e6ff3d6b2b8a3',\n '0x748f82ee5defb2fc', '0x78a5636f43172f60', '0x84c87814a1f0ab72', '0x8cc702081a6439ec',\n '0x90befffa23631e28', '0xa4506cebde82bde9', '0xbef9a3f7b2c67915', '0xc67178f2e372532b',\n '0xca273eceea26619c', '0xd186b8c721c0c207', '0xeada7dd6cde0eb1e', '0xf57d4f7fee6ed178',\n '0x06f067aa72176fba', '0x0a637dc5a2c898a6', '0x113f9804bef90dae', '0x1b710b35131c471b',\n '0x28db77f523047d84', '0x32caab7b40c72493', '0x3c9ebe0a15c9bebc', '0x431d67c49c100d4c',\n '0x4cc5d4becb3e42b6', '0x597f299cfc657e2a', '0x5fcb6fab3ad6faec', '0x6c44198c4a475817'\n].map(n => BigInt(n))))();\nconst SHA512_Kh = /* @__PURE__ */ (() => K512[0])();\nconst SHA512_Kl = /* @__PURE__ */ (() => K512[1])();\n\n// Reusable temporary buffers\nconst SHA512_W_H = /* @__PURE__ */ new Uint32Array(80);\nconst SHA512_W_L = /* @__PURE__ */ new Uint32Array(80);\n\nexport class SHA512 extends HashMD<SHA512> {\n // We cannot use array here since array allows indexing by variable\n // which means optimizer/compiler cannot use registers.\n // h -- high 32 bits, l -- low 32 bits\n protected Ah: number = SHA512_IV[0] | 0;\n protected Al: number = SHA512_IV[1] | 0;\n protected Bh: number = SHA512_IV[2] | 0;\n protected Bl: number = SHA512_IV[3] | 0;\n protected Ch: number = SHA512_IV[4] | 0;\n protected Cl: number = SHA512_IV[5] | 0;\n protected Dh: number = SHA512_IV[6] | 0;\n protected Dl: number = SHA512_IV[7] | 0;\n protected Eh: number = SHA512_IV[8] | 0;\n protected El: number = SHA512_IV[9] | 0;\n protected Fh: number = SHA512_IV[10] | 0;\n protected Fl: number = SHA512_IV[11] | 0;\n protected Gh: number = SHA512_IV[12] | 0;\n protected Gl: number = SHA512_IV[13] | 0;\n protected Hh: number = SHA512_IV[14] | 0;\n protected Hl: number = SHA512_IV[15] | 0;\n\n constructor(outputLen: number = 64) {\n super(128, outputLen, 16, false);\n }\n // prettier-ignore\n protected get(): [\n number, number, number, number, number, number, number, number,\n number, number, number, number, number, number, number, number\n ] {\n const { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;\n return [Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl];\n }\n // prettier-ignore\n protected set(\n Ah: number, Al: number, Bh: number, Bl: number, Ch: number, Cl: number, Dh: number, Dl: number,\n Eh: number, El: number, Fh: number, Fl: number, Gh: number, Gl: number, Hh: number, Hl: number\n ): void {\n this.Ah = Ah | 0;\n this.Al = Al | 0;\n this.Bh = Bh | 0;\n this.Bl = Bl | 0;\n this.Ch = Ch | 0;\n this.Cl = Cl | 0;\n this.Dh = Dh | 0;\n this.Dl = Dl | 0;\n this.Eh = Eh | 0;\n this.El = El | 0;\n this.Fh = Fh | 0;\n this.Fl = Fl | 0;\n this.Gh = Gh | 0;\n this.Gl = Gl | 0;\n this.Hh = Hh | 0;\n this.Hl = Hl | 0;\n }\n protected process(view: DataView, offset: number): void {\n // Extend the first 16 words into the remaining 64 words w[16..79] of the message schedule array\n for (let i = 0; i < 16; i++, offset += 4) {\n SHA512_W_H[i] = view.getUint32(offset);\n SHA512_W_L[i] = view.getUint32((offset += 4));\n }\n for (let i = 16; i < 80; i++) {\n // s0 := (w[i-15] rightrotate 1) xor (w[i-15] rightrotate 8) xor (w[i-15] rightshift 7)\n const W15h = SHA512_W_H[i - 15] | 0;\n const W15l = SHA512_W_L[i - 15] | 0;\n const s0h = u64.rotrSH(W15h, W15l, 1) ^ u64.rotrSH(W15h, W15l, 8) ^ u64.shrSH(W15h, W15l, 7);\n const s0l = u64.rotrSL(W15h, W15l, 1) ^ u64.rotrSL(W15h, W15l, 8) ^ u64.shrSL(W15h, W15l, 7);\n // s1 := (w[i-2] rightrotate 19) xor (w[i-2] rightrotate 61) xor (w[i-2] rightshift 6)\n const W2h = SHA512_W_H[i - 2] | 0;\n const W2l = SHA512_W_L[i - 2] | 0;\n const s1h = u64.rotrSH(W2h, W2l, 19) ^ u64.rotrBH(W2h, W2l, 61) ^ u64.shrSH(W2h, W2l, 6);\n const s1l = u64.rotrSL(W2h, W2l, 19) ^ u64.rotrBL(W2h, W2l, 61) ^ u64.shrSL(W2h, W2l, 6);\n // SHA256_W[i] = s0 + s1 + SHA256_W[i - 7] + SHA256_W[i - 16];\n const SUMl = u64.add4L(s0l, s1l, SHA512_W_L[i - 7], SHA512_W_L[i - 16]);\n const SUMh = u64.add4H(SUMl, s0h, s1h, SHA512_W_H[i - 7], SHA512_W_H[i - 16]);\n SHA512_W_H[i] = SUMh | 0;\n SHA512_W_L[i] = SUMl | 0;\n }\n let { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;\n // Compression function main loop, 80 rounds\n for (let i = 0; i < 80; i++) {\n // S1 := (e rightrotate 14) xor (e rightrotate 18) xor (e rightrotate 41)\n const sigma1h = u64.rotrSH(Eh, El, 14) ^ u64.rotrSH(Eh, El, 18) ^ u64.rotrBH(Eh, El, 41);\n const sigma1l = u64.rotrSL(Eh, El, 14) ^ u64.rotrSL(Eh, El, 18) ^ u64.rotrBL(Eh, El, 41);\n //const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0;\n const CHIh = (Eh & Fh) ^ (~Eh & Gh);\n const CHIl = (El & Fl) ^ (~El & Gl);\n // T1 = H + sigma1 + Chi(E, F, G) + SHA512_K[i] + SHA512_W[i]\n // prettier-ignore\n const T1ll = u64.add5L(Hl, sigma1l, CHIl, SHA512_Kl[i], SHA512_W_L[i]);\n const T1h = u64.add5H(T1ll, Hh, sigma1h, CHIh, SHA512_Kh[i], SHA512_W_H[i]);\n const T1l = T1ll | 0;\n // S0 := (a rightrotate 28) xor (a rightrotate 34) xor (a rightrotate 39)\n const sigma0h = u64.rotrSH(Ah, Al, 28) ^ u64.rotrBH(Ah, Al, 34) ^ u64.rotrBH(Ah, Al, 39);\n const sigma0l = u64.rotrSL(Ah, Al, 28) ^ u64.rotrBL(Ah, Al, 34) ^ u64.rotrBL(Ah, Al, 39);\n const MAJh = (Ah & Bh) ^ (Ah & Ch) ^ (Bh & Ch);\n const MAJl = (Al & Bl) ^ (Al & Cl) ^ (Bl & Cl);\n Hh = Gh | 0;\n Hl = Gl | 0;\n Gh = Fh | 0;\n Gl = Fl | 0;\n Fh = Eh | 0;\n Fl = El | 0;\n ({ h: Eh, l: El } = u64.add(Dh | 0, Dl | 0, T1h | 0, T1l | 0));\n Dh = Ch | 0;\n Dl = Cl | 0;\n Ch = Bh | 0;\n Cl = Bl | 0;\n Bh = Ah | 0;\n Bl = Al | 0;\n const All = u64.add3L(T1l, sigma0l, MAJl);\n Ah = u64.add3H(All, T1h, sigma0h, MAJh);\n Al = All | 0;\n }\n // Add the compressed chunk to the current hash value\n ({ h: Ah, l: Al } = u64.add(this.Ah | 0, this.Al | 0, Ah | 0, Al | 0));\n ({ h: Bh, l: Bl } = u64.add(this.Bh | 0, this.Bl | 0, Bh | 0, Bl | 0));\n ({ h: Ch, l: Cl } = u64.add(this.Ch | 0, this.Cl | 0, Ch | 0, Cl | 0));\n ({ h: Dh, l: Dl } = u64.add(this.Dh | 0, this.Dl | 0, Dh | 0, Dl | 0));\n ({ h: Eh, l: El } = u64.add(this.Eh | 0, this.El | 0, Eh | 0, El | 0));\n ({ h: Fh, l: Fl } = u64.add(this.Fh | 0, this.Fl | 0, Fh | 0, Fl | 0));\n ({ h: Gh, l: Gl } = u64.add(this.Gh | 0, this.Gl | 0, Gh | 0, Gl | 0));\n ({ h: Hh, l: Hl } = u64.add(this.Hh | 0, this.Hl | 0, Hh | 0, Hl | 0));\n this.set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl);\n }\n protected roundClean(): void {\n clean(SHA512_W_H, SHA512_W_L);\n }\n destroy(): void {\n clean(this.buffer);\n this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);\n }\n}\n\nexport class SHA384 extends SHA512 {\n protected Ah: number = SHA384_IV[0] | 0;\n protected Al: number = SHA384_IV[1] | 0;\n protected Bh: number = SHA384_IV[2] | 0;\n protected Bl: number = SHA384_IV[3] | 0;\n protected Ch: number = SHA384_IV[4] | 0;\n protected Cl: number = SHA384_IV[5] | 0;\n protected Dh: number = SHA384_IV[6] | 0;\n protected Dl: number = SHA384_IV[7] | 0;\n protected Eh: number = SHA384_IV[8] | 0;\n protected El: number = SHA384_IV[9] | 0;\n protected Fh: number = SHA384_IV[10] | 0;\n protected Fl: number = SHA384_IV[11] | 0;\n protected Gh: number = SHA384_IV[12] | 0;\n protected Gl: number = SHA384_IV[13] | 0;\n protected Hh: number = SHA384_IV[14] | 0;\n protected Hl: number = SHA384_IV[15] | 0;\n\n constructor() {\n super(48);\n }\n}\n\n/**\n * Truncated SHA512/256 and SHA512/224.\n * SHA512_IV is XORed with 0xa5a5a5a5a5a5a5a5, then used as \"intermediary\" IV of SHA512/t.\n * Then t hashes string to produce result IV.\n * See `test/misc/sha2-gen-iv.js`.\n */\n\n/** SHA512/224 IV */\nconst T224_IV = /* @__PURE__ */ Uint32Array.from([\n 0x8c3d37c8, 0x19544da2, 0x73e19966, 0x89dcd4d6, 0x1dfab7ae, 0x32ff9c82, 0x679dd514, 0x582f9fcf,\n 0x0f6d2b69, 0x7bd44da8, 0x77e36f73, 0x04c48942, 0x3f9d85a8, 0x6a1d36c8, 0x1112e6ad, 0x91d692a1,\n]);\n\n/** SHA512/256 IV */\nconst T256_IV = /* @__PURE__ */ Uint32Array.from([\n 0x22312194, 0xfc2bf72c, 0x9f555fa3, 0xc84c64c2, 0x2393b86b, 0x6f53b151, 0x96387719, 0x5940eabd,\n 0x96283ee2, 0xa88effe3, 0xbe5e1e25, 0x53863992, 0x2b0199fc, 0x2c85b8aa, 0x0eb72ddc, 0x81c52ca2,\n]);\n\nexport class SHA512_224 extends SHA512 {\n protected Ah: number = T224_IV[0] | 0;\n protected Al: number = T224_IV[1] | 0;\n protected Bh: number = T224_IV[2] | 0;\n protected Bl: number = T224_IV[3] | 0;\n protected Ch: number = T224_IV[4] | 0;\n protected Cl: number = T224_IV[5] | 0;\n protected Dh: number = T224_IV[6] | 0;\n protected Dl: number = T224_IV[7] | 0;\n protected Eh: number = T224_IV[8] | 0;\n protected El: number = T224_IV[9] | 0;\n protected Fh: number = T224_IV[10] | 0;\n protected Fl: number = T224_IV[11] | 0;\n protected Gh: number = T224_IV[12] | 0;\n protected Gl: number = T224_IV[13] | 0;\n protected Hh: number = T224_IV[14] | 0;\n protected Hl: number = T224_IV[15] | 0;\n\n constructor() {\n super(28);\n }\n}\n\nexport class SHA512_256 extends SHA512 {\n protected Ah: number = T256_IV[0] | 0;\n protected Al: number = T256_IV[1] | 0;\n protected Bh: number = T256_IV[2] | 0;\n protected Bl: number = T256_IV[3] | 0;\n protected Ch: number = T256_IV[4] | 0;\n protected Cl: number = T256_IV[5] | 0;\n protected Dh: number = T256_IV[6] | 0;\n protected Dl: number = T256_IV[7] | 0;\n protected Eh: number = T256_IV[8] | 0;\n protected El: number = T256_IV[9] | 0;\n protected Fh: number = T256_IV[10] | 0;\n protected Fl: number = T256_IV[11] | 0;\n protected Gh: number = T256_IV[12] | 0;\n protected Gl: number = T256_IV[13] | 0;\n protected Hh: number = T256_IV[14] | 0;\n protected Hl: number = T256_IV[15] | 0;\n\n constructor() {\n super(32);\n }\n}\n\n/**\n * SHA2-256 hash function from RFC 4634.\n *\n * It is the fastest JS hash, even faster than Blake3.\n * To break sha256 using birthday attack, attackers need to try 2^128 hashes.\n * BTC network is doing 2^70 hashes/sec (2^95 hashes/year) as per 2025.\n */\nexport const sha256: CHash = /* @__PURE__ */ createHasher(() => new SHA256());\n/** SHA2-224 hash function from RFC 4634 */\nexport const sha224: CHash = /* @__PURE__ */ createHasher(() => new SHA224());\n\n/** SHA2-512 hash function from RFC 4634. */\nexport const sha512: CHash = /* @__PURE__ */ createHasher(() => new SHA512());\n/** SHA2-384 hash function from RFC 4634. */\nexport const sha384: CHash = /* @__PURE__ */ createHasher(() => new SHA384());\n\n/**\n * SHA2-512/256 \"truncated\" hash function, with improved resistance to length extension attacks.\n * See the paper on [truncated SHA512](https://eprint.iacr.org/2010/548.pdf).\n */\nexport const sha512_256: CHash = /* @__PURE__ */ createHasher(() => new SHA512_256());\n/**\n * SHA2-512/224 \"truncated\" hash function, with improved resistance to length extension attacks.\n * See the paper on [truncated SHA512](https://eprint.iacr.org/2010/548.pdf).\n */\nexport const sha512_224: CHash = /* @__PURE__ */ createHasher(() => new SHA512_224());\n", "// @ts-check\n\n/**\n * A string containing all valid Base58 characters:\n * - Digits: 1\u20139 (excluding 0)\n * - Uppercase: A\u2013Z (excluding I and O)\n * - Lowercase: a\u2013z (excluding l)\n *\n * @typedef {string} base58_chars\n * @see https://en.wikipedia.org/wiki/Base58\n */\n\n/** @type {base58_chars} */\nconst base58_chars =\n \"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz\";\n\nexport default base58_chars;\n", "// @ts-check\nimport base58_chars from \"./base58_chars.js\";\n\n/**\n * Converts a base58 string to the corresponding binary representation.\n * @param {string} base58String base58 encoded string.\n * @returns {Uint8Array} Binary representation for the base58 string.\n * @example\n * ```js\n * const bin = base58_to_binary(\"6MRy\")\n * console.log(bin)\n * ```\n * Logged output will be Uint8Array(3) [15, 239, 64].\n */\nfunction base58_to_binary(base58String) {\n if (!base58String || typeof base58String !== \"string\")\n throw new Error(`Expected base58 string but got \u201C${base58String}\u201D`);\n if (base58String.match(/[IOl0]/gmu))\n throw new Error(\n `Invalid base58 character \u201C${base58String.match(/[IOl0]/gmu)}\u201D`\n );\n const lz = base58String.match(/^1+/gmu);\n const psz = lz ? lz[0].length : 0;\n const size =\n ((base58String.length - psz) * (Math.log(58) / Math.log(256)) + 1) >>> 0;\n\n return new Uint8Array([\n ...new Uint8Array(psz),\n ...base58String\n .match(/.{1}/gmu)\n .map((i) => base58_chars.indexOf(i))\n .reduce((acc, i) => {\n acc = acc.map((j) => {\n const x = j * 58 + i;\n i = x >> 8;\n return x;\n });\n return acc;\n }, new Uint8Array(size))\n .reverse()\n .filter(\n (\n (lastValue) => (value) =>\n // @ts-ignore\n (lastValue = lastValue || value)\n )(false)\n ),\n ]);\n}\n\nexport default base58_to_binary;\n"],
5
+ "mappings": "2PAAA,IAAAA,GAAAC,GAAAC,GAAA,cACA,OAAO,eAAeA,EAAS,aAAc,CAAE,MAAO,EAAK,CAAC,EAC5DA,EAAQ,QAAUA,EAAQ,OAAS,OACnC,IAAMC,EAAW,mCACXC,EAAe,CAAC,EACtB,QAASC,EAAI,EAAGA,EAAIF,EAAS,OAAQE,IAAK,CACtC,IAAMC,EAAIH,EAAS,OAAOE,CAAC,EAC3BD,EAAaE,CAAC,EAAID,CACtB,CACA,SAASE,EAAYC,EAAK,CACtB,IAAMC,EAAID,GAAO,GACjB,OAAUA,EAAM,WAAc,EACzB,EAAGC,GAAK,EAAK,GAAK,UAClB,EAAGA,GAAK,EAAK,GAAK,UAClB,EAAGA,GAAK,EAAK,GAAK,UAClB,EAAGA,GAAK,EAAK,GAAK,WAClB,EAAGA,GAAK,EAAK,GAAK,SAC3B,CACA,SAASC,EAAUC,EAAQ,CACvB,IAAIC,EAAM,EACV,QAASC,EAAI,EAAGA,EAAIF,EAAO,OAAQ,EAAEE,EAAG,CACpC,IAAMC,EAAIH,EAAO,WAAWE,CAAC,EAC7B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MAAM,IAAIf,CACd,CACF",
6
+ "names": ["require_dist", "__commonJSMin", "exports", "ALPHABET", "ALPHABET_MAP", "z", "x", "polymodStep", "pre", "b", "prefixChk", "prefix", "chk", "i", "c", "v", "convert", "data", "inBits", "outBits", "pad", "value", "bits", "maxV", "result", "toWords", "bytes", "fromWordsUnsafe", "words", "res", "fromWords", "getLibraryFromEncoding", "encoding", "ENCODING_CONST", "encode", "LIMIT", "__decode", "str", "lowered", "uppered", "split", "wordChars", "decodeUnsafe", "decode", "BtcNetwork", "BtcAddressType", "ParseBtcAddressError", "ParseBtcAddressInvalidError", "ParseBtcAddressNoDataError", "ParseBtcAddressUnsupportedAddressTypeError", "ParseBtcAddressBadWitnessLengthError", "ParseBtcAddressUnsupportedWitnessVersionError", "ParseBtcAddressUnexpectedHumanReadablePartError", "ParseBtcAddressMalformedAddressError", "ParseBtcAddressWrongNetworkError", "isNullish", "isBytes", "a", "abytes", "b", "lengths", "isBytes", "aexists", "instance", "checkFinished", "aoutput", "out", "abytes", "min", "clean", "arrays", "i", "createView", "arr", "rotr", "word", "shift", "utf8ToBytes", "str", "toBytes", "data", "utf8ToBytes", "abytes", "Hash", "createHasher", "hashCons", "hashC", "msg", "toBytes", "tmp", "setBigUint64", "view", "byteOffset", "value", "isLE", "_32n", "_u32_max", "wh", "wl", "l", "Chi", "a", "b", "c", "Maj", "HashMD", "Hash", "blockLen", "outputLen", "padOffset", "createView", "data", "aexists", "toBytes", "abytes", "buffer", "len", "pos", "take", "dataView", "out", "aoutput", "clean", "i", "oview", "outLen", "state", "res", "to", "length", "finished", "destroyed", "SHA256_IV", "SHA256_K", "SHA256_W", "SHA256", "HashMD", "outputLen", "SHA256_IV", "A", "B", "C", "D", "E", "F", "G", "H", "view", "offset", "i", "W15", "W2", "s0", "rotr", "s1", "sigma1", "T1", "Chi", "T2", "Maj", "clean", "sha256", "createHasher", "SHA256", "base58_chars", "base58_chars_default", "base58_to_binary", "base58String", "lz", "psz", "size", "i", "base58_chars_default", "acc", "j", "x", "lastValue", "value", "base58_to_binary_default", "import_bech32", "BTC_MAINNET_PREFIX", "BTC_MAINNET_P2SH_PREFIX", "BTC_TESTNET_PREFIX", "BTC_TESTNET_P2SH_PREFIX", "Base58AddressTypes", "parseBase58Address", "address", "network", "decoded", "base58_to_binary_default", "ParseBtcAddressInvalidError", "length", "ParseBtcAddressMalformedAddressError", "expectedChecksum", "body", "bodyHash", "sha256", "checksumHash", "checksum", "value", "index", "version", "versionNetwork", "isNullish", "ParseBtcAddressUnsupportedAddressTypeError", "type", "networks", "ParseBtcAddressWrongNetworkError", "parseBip173Address", "decodeBech32", "prefix", "words", "decodedNetwork", "ParseBtcAddressUnexpectedHumanReadablePartError", "witnessVersion", "rest", "ParseBtcAddressUnsupportedWitnessVersionError", "ParseBtcAddressBadWitnessLengthError", "parseBtcAddress", "ParseBtcAddressNoDataError"]
7
7
  }
@@ -15,11 +15,11 @@ export type RetrieveBtcWithApprovalResponse = {
15
15
  } | {
16
16
  Err: RetrieveBtcWithApprovalError;
17
17
  };
18
- export type EstimateWithdrawalFee = {
18
+ export interface EstimateWithdrawalFee {
19
19
  minter_fee: bigint;
20
20
  bitcoin_fee: bigint;
21
- };
22
- export type RetrieveBtcStatusV2WithId = {
21
+ }
22
+ export interface RetrieveBtcStatusV2WithId {
23
23
  id: bigint;
24
24
  status: RetrieveBtcStatusV2 | undefined;
25
- };
25
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dfinity/ckbtc",
3
- "version": "3.1.14",
3
+ "version": "3.2.0",
4
4
  "description": "A library for interfacing with ckBTC.",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/cjs/index.cjs.js",
@@ -41,11 +41,11 @@
41
41
  "@dfinity/agent": "^2.0.0",
42
42
  "@dfinity/candid": "^2.0.0",
43
43
  "@dfinity/principal": "^2.0.0",
44
- "@dfinity/utils": "^2.13.0"
44
+ "@dfinity/utils": "^2.14.0"
45
45
  },
46
46
  "dependencies": {
47
- "@noble/hashes": "^1.3.2",
48
- "base58-js": "^1.0.5",
47
+ "@noble/hashes": "^1.8.0",
48
+ "base58-js": "^3.0.3",
49
49
  "bech32": "^2.0.0"
50
50
  }
51
51
  }
@@ -1 +0,0 @@
1
- //# sourceMappingURL=base58.d.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": [],
4
- "sourcesContent": [],
5
- "mappings": "",
6
- "names": []
7
- }