@multiformats/murmur3
Advanced tools
Comparing version 2.1.2 to 2.1.3
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.MultiformatsMurmur3 = factory()}(typeof self !== 'undefined' ? self : this, function () { | ||
"use strict";var MultiformatsMurmur3=(()=>{var Ee=Object.create;var P=Object.defineProperty;var Ue=Object.getOwnPropertyDescriptor;var ze=Object.getOwnPropertyNames;var ye=Object.getPrototypeOf,Ce=Object.prototype.hasOwnProperty;var ae=(n,r)=>()=>(r||n((r={exports:{}}).exports,r),r.exports),se=(n,r)=>{for(var e in r)P(n,e,{get:r[e],enumerable:!0})},ce=(n,r,e,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of ze(r))!Ce.call(n,a)&&a!==e&&P(n,a,{get:()=>r[a],enumerable:!(s=Ue(r,a))||s.enumerable});return n};var Me=(n,r,e)=>(e=n!=null?Ee(ye(n)):{},ce(r||!n||!n.__esModule?P(e,"default",{value:n,enumerable:!0}):e,n)),Ne=n=>ce(P({},"__esModule",{value:!0}),n);var be=ae((q,j)=>{(function(n,r){"use strict";var e={version:"3.0.0",x86:{},x64:{},inputValidation:!0};function s(t){if(!Array.isArray(t)&&!ArrayBuffer.isView(t))return!1;for(var o=0;o<t.length;o++)if(!Number.isInteger(t[o])||t[o]<0||t[o]>255)return!1;return!0}function a(t,o){return(t&65535)*o+(((t>>>16)*o&65535)<<16)}function d(t,o){return t<<o|t>>>32-o}function x(t){return t^=t>>>16,t=a(t,2246822507),t^=t>>>13,t=a(t,3266489909),t^=t>>>16,t}function w(t,o){t=[t[0]>>>16,t[0]&65535,t[1]>>>16,t[1]&65535],o=[o[0]>>>16,o[0]&65535,o[1]>>>16,o[1]&65535];var c=[0,0,0,0];return c[3]+=t[3]+o[3],c[2]+=c[3]>>>16,c[3]&=65535,c[2]+=t[2]+o[2],c[1]+=c[2]>>>16,c[2]&=65535,c[1]+=t[1]+o[1],c[0]+=c[1]>>>16,c[1]&=65535,c[0]+=t[0]+o[0],c[0]&=65535,[c[0]<<16|c[1],c[2]<<16|c[3]]}function S(t,o){t=[t[0]>>>16,t[0]&65535,t[1]>>>16,t[1]&65535],o=[o[0]>>>16,o[0]&65535,o[1]>>>16,o[1]&65535];var c=[0,0,0,0];return c[3]+=t[3]*o[3],c[2]+=c[3]>>>16,c[3]&=65535,c[2]+=t[2]*o[3],c[1]+=c[2]>>>16,c[2]&=65535,c[2]+=t[3]*o[2],c[1]+=c[2]>>>16,c[2]&=65535,c[1]+=t[1]*o[3],c[0]+=c[1]>>>16,c[1]&=65535,c[1]+=t[2]*o[2],c[0]+=c[1]>>>16,c[1]&=65535,c[1]+=t[3]*o[1],c[0]+=c[1]>>>16,c[1]&=65535,c[0]+=t[0]*o[3]+t[1]*o[2]+t[2]*o[1]+t[3]*o[0],c[0]&=65535,[c[0]<<16|c[1],c[2]<<16|c[3]]}function U(t,o){return o%=64,o===32?[t[1],t[0]]:o<32?[t[0]<<o|t[1]>>>32-o,t[1]<<o|t[0]>>>32-o]:(o-=32,[t[1]<<o|t[0]>>>32-o,t[0]<<o|t[1]>>>32-o])}function A(t,o){return o%=64,o===0?t:o<32?[t[0]<<o|t[1]>>>32-o,t[1]<<o]:[t[1]<<o-32,0]}function m(t,o){return[t[0]^o[0],t[1]^o[1]]}function N(t){return t=m(t,[0,t[0]>>>1]),t=S(t,[4283543511,3981806797]),t=m(t,[0,t[0]>>>1]),t=S(t,[3301882366,444984403]),t=m(t,[0,t[0]>>>1]),t}e.x86.hash32=function(t,o){if(e.inputValidation&&!s(t))return r;o=o||0;for(var c=t.length%4,z=t.length-c,i=o,f=0,u=3432918353,l=461845907,p=0;p<z;p=p+4)f=t[p]|t[p+1]<<8|t[p+2]<<16|t[p+3]<<24,f=a(f,u),f=d(f,15),f=a(f,l),i^=f,i=d(i,13),i=a(i,5)+3864292196;switch(f=0,c){case 3:f^=t[p+2]<<16;case 2:f^=t[p+1]<<8;case 1:f^=t[p],f=a(f,u),f=d(f,15),f=a(f,l),i^=f}return i^=t.length,i=x(i),i>>>0},e.x86.hash128=function(t,o){if(e.inputValidation&&!s(t))return r;o=o||0;for(var c=t.length%16,z=t.length-c,i=o,f=o,u=o,l=o,p=0,v=0,h=0,b=0,C=597399067,R=2869860233,H=951274213,J=2716044179,g=0;g<z;g=g+16)p=t[g]|t[g+1]<<8|t[g+2]<<16|t[g+3]<<24,v=t[g+4]|t[g+5]<<8|t[g+6]<<16|t[g+7]<<24,h=t[g+8]|t[g+9]<<8|t[g+10]<<16|t[g+11]<<24,b=t[g+12]|t[g+13]<<8|t[g+14]<<16|t[g+15]<<24,p=a(p,C),p=d(p,15),p=a(p,R),i^=p,i=d(i,19),i+=f,i=a(i,5)+1444728091,v=a(v,R),v=d(v,16),v=a(v,H),f^=v,f=d(f,17),f+=u,f=a(f,5)+197830471,h=a(h,H),h=d(h,17),h=a(h,J),u^=h,u=d(u,15),u+=l,u=a(u,5)+2530024501,b=a(b,J),b=d(b,18),b=a(b,C),l^=b,l=d(l,13),l+=i,l=a(l,5)+850148119;switch(p=0,v=0,h=0,b=0,c){case 15:b^=t[g+14]<<16;case 14:b^=t[g+13]<<8;case 13:b^=t[g+12],b=a(b,J),b=d(b,18),b=a(b,C),l^=b;case 12:h^=t[g+11]<<24;case 11:h^=t[g+10]<<16;case 10:h^=t[g+9]<<8;case 9:h^=t[g+8],h=a(h,H),h=d(h,17),h=a(h,J),u^=h;case 8:v^=t[g+7]<<24;case 7:v^=t[g+6]<<16;case 6:v^=t[g+5]<<8;case 5:v^=t[g+4],v=a(v,R),v=d(v,16),v=a(v,H),f^=v;case 4:p^=t[g+3]<<24;case 3:p^=t[g+2]<<16;case 2:p^=t[g+1]<<8;case 1:p^=t[g],p=a(p,C),p=d(p,15),p=a(p,R),i^=p}return i^=t.length,f^=t.length,u^=t.length,l^=t.length,i+=f,i+=u,i+=l,f+=i,u+=i,l+=i,i=x(i),f=x(f),u=x(u),l=x(l),i+=f,i+=u,i+=l,f+=i,u+=i,l+=i,("00000000"+(i>>>0).toString(16)).slice(-8)+("00000000"+(f>>>0).toString(16)).slice(-8)+("00000000"+(u>>>0).toString(16)).slice(-8)+("00000000"+(l>>>0).toString(16)).slice(-8)},e.x64.hash128=function(t,o){if(e.inputValidation&&!s(t))return r;o=o||0;for(var c=t.length%16,z=t.length-c,i=[0,o],f=[0,o],u=[0,0],l=[0,0],p=[2277735313,289559509],v=[1291169091,658871167],h=0;h<z;h=h+16)u=[t[h+4]|t[h+5]<<8|t[h+6]<<16|t[h+7]<<24,t[h]|t[h+1]<<8|t[h+2]<<16|t[h+3]<<24],l=[t[h+12]|t[h+13]<<8|t[h+14]<<16|t[h+15]<<24,t[h+8]|t[h+9]<<8|t[h+10]<<16|t[h+11]<<24],u=S(u,p),u=U(u,31),u=S(u,v),i=m(i,u),i=U(i,27),i=w(i,f),i=w(S(i,[0,5]),[0,1390208809]),l=S(l,v),l=U(l,33),l=S(l,p),f=m(f,l),f=U(f,31),f=w(f,i),f=w(S(f,[0,5]),[0,944331445]);switch(u=[0,0],l=[0,0],c){case 15:l=m(l,A([0,t[h+14]],48));case 14:l=m(l,A([0,t[h+13]],40));case 13:l=m(l,A([0,t[h+12]],32));case 12:l=m(l,A([0,t[h+11]],24));case 11:l=m(l,A([0,t[h+10]],16));case 10:l=m(l,A([0,t[h+9]],8));case 9:l=m(l,[0,t[h+8]]),l=S(l,v),l=U(l,33),l=S(l,p),f=m(f,l);case 8:u=m(u,A([0,t[h+7]],56));case 7:u=m(u,A([0,t[h+6]],48));case 6:u=m(u,A([0,t[h+5]],40));case 5:u=m(u,A([0,t[h+4]],32));case 4:u=m(u,A([0,t[h+3]],24));case 3:u=m(u,A([0,t[h+2]],16));case 2:u=m(u,A([0,t[h+1]],8));case 1:u=m(u,[0,t[h]]),u=S(u,p),u=U(u,31),u=S(u,v),i=m(i,u)}return i=m(i,[0,t.length]),f=m(f,[0,t.length]),i=w(i,f),f=w(f,i),i=N(i),f=N(f),i=w(i,f),f=w(f,i),("00000000"+(i[0]>>>0).toString(16)).slice(-8)+("00000000"+(i[1]>>>0).toString(16)).slice(-8)+("00000000"+(f[0]>>>0).toString(16)).slice(-8)+("00000000"+(f[1]>>>0).toString(16)).slice(-8)},typeof q<"u"?(typeof j<"u"&&j.exports&&(q=j.exports=e),q.murmurHash3=e):typeof define=="function"&&define.amd?define([],function(){return e}):(e._murmurHash3=n.murmurHash3,e.noConflict=function(){return n.murmurHash3=e._murmurHash3,e._murmurHash3=r,e.noConflict=r,e},n.murmurHash3=e)})(q)});var Ae=ae((Pr,Se)=>{Se.exports=be()});var pr={};se(pr,{murmur3128:()=>ur,murmur332:()=>dr,murmur364:()=>lr});var L={};se(L,{coerce:()=>V,empty:()=>ie,equals:()=>G,fromHex:()=>ke,fromString:()=>Be,isBinary:()=>Oe,toHex:()=>Ve,toString:()=>Le});var ie=new Uint8Array(0),Ve=n=>n.reduce((r,e)=>r+e.toString(16).padStart(2,"0"),""),ke=n=>{let r=n.match(/../g);return r?new Uint8Array(r.map(e=>parseInt(e,16))):ie},G=(n,r)=>{if(n===r)return!0;if(n.byteLength!==r.byteLength)return!1;for(let e=0;e<n.byteLength;e++)if(n[e]!==r[e])return!1;return!0},V=n=>{if(n instanceof Uint8Array&&n.constructor.name==="Uint8Array")return n;if(n instanceof ArrayBuffer)return new Uint8Array(n);if(ArrayBuffer.isView(n))return new Uint8Array(n.buffer,n.byteOffset,n.byteLength);throw new Error("Unknown type, must be binary type")},Oe=n=>n instanceof ArrayBuffer||ArrayBuffer.isView(n),Be=n=>new TextEncoder().encode(n),Le=n=>new TextDecoder().decode(n);var Te=de,fe=128,De=127,$e=~De,Fe=Math.pow(2,31);function de(n,r,e){r=r||[],e=e||0;for(var s=e;n>=Fe;)r[e++]=n&255|fe,n/=128;for(;n&$e;)r[e++]=n&255|fe,n>>>=7;return r[e]=n|0,de.bytes=e-s+1,r}var Ie=Q,qe=128,he=127;function Q(n,s){var e=0,s=s||0,a=0,d=s,x,w=n.length;do{if(d>=w)throw Q.bytes=0,new RangeError("Could not decode varint");x=n[d++],e+=a<28?(x&he)<<a:(x&he)*Math.pow(2,a),a+=7}while(x>=qe);return Q.bytes=d-s,e}var Re=Math.pow(2,7),He=Math.pow(2,14),Je=Math.pow(2,21),Pe=Math.pow(2,28),_e=Math.pow(2,35),je=Math.pow(2,42),Xe=Math.pow(2,49),Ge=Math.pow(2,56),Qe=Math.pow(2,63),Ke=function(n){return n<Re?1:n<He?2:n<Je?3:n<Pe?4:n<_e?5:n<je?6:n<Xe?7:n<Ge?8:n<Qe?9:10},We={encode:Te,decode:Ie,encodingLength:Ke},Ze=We,T=Ze;var D=(n,r=0)=>[T.decode(n,r),T.decode.bytes],k=(n,r,e=0)=>(T.encode(n,r,e),r),O=n=>T.encodingLength(n);var $=(n,r)=>{let e=r.byteLength,s=O(n),a=s+O(e),d=new Uint8Array(a+e);return k(n,d,0),k(e,d,s),d.set(r,a),new B(n,e,r,d)},ue=n=>{let r=V(n),[e,s]=D(r),[a,d]=D(r.subarray(s)),x=r.subarray(s+d);if(x.byteLength!==a)throw new Error("Incorrect length");return new B(e,a,x,r)},le=(n,r)=>{if(n===r)return!0;{let e=r;return n.code===e.code&&n.size===e.size&&e.bytes instanceof Uint8Array&&G(n.bytes,e.bytes)}},B=class{constructor(r,e,s,a){this.code=r,this.size=e,this.digest=s,this.bytes=a}};var _=({name:n,code:r,encode:e})=>new Z(n,r,e),Z=class{constructor(r,e,s){this.name=r,this.code=e,this.encode=s}digest(r){if(r instanceof Uint8Array){let e=this.encode(r);return e instanceof Uint8Array?$(this.code,e):e.then(s=>$(this.code,s))}else throw Error("Unknown type, must be binary type")}};function er(n,r){if(n.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),s=0;s<e.length;s++)e[s]=255;for(var a=0;a<n.length;a++){var d=n.charAt(a),x=d.charCodeAt(0);if(e[x]!==255)throw new TypeError(d+" is ambiguous");e[x]=a}var w=n.length,S=n.charAt(0),U=Math.log(w)/Math.log(256),A=Math.log(256)/Math.log(w);function m(o){if(o instanceof Uint8Array||(ArrayBuffer.isView(o)?o=new Uint8Array(o.buffer,o.byteOffset,o.byteLength):Array.isArray(o)&&(o=Uint8Array.from(o))),!(o instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(o.length===0)return"";for(var c=0,z=0,i=0,f=o.length;i!==f&&o[i]===0;)i++,c++;for(var u=(f-i)*A+1>>>0,l=new Uint8Array(u);i!==f;){for(var p=o[i],v=0,h=u-1;(p!==0||v<z)&&h!==-1;h--,v++)p+=256*l[h]>>>0,l[h]=p%w>>>0,p=p/w>>>0;if(p!==0)throw new Error("Non-zero carry");z=v,i++}for(var b=u-z;b!==u&&l[b]===0;)b++;for(var C=S.repeat(c);b<u;++b)C+=n.charAt(l[b]);return C}function N(o){if(typeof o!="string")throw new TypeError("Expected String");if(o.length===0)return new Uint8Array;var c=0;if(o[c]!==" "){for(var z=0,i=0;o[c]===S;)z++,c++;for(var f=(o.length-c)*U+1>>>0,u=new Uint8Array(f);o[c];){var l=e[o.charCodeAt(c)];if(l===255)return;for(var p=0,v=f-1;(l!==0||p<i)&&v!==-1;v--,p++)l+=w*u[v]>>>0,u[v]=l%256>>>0,l=l/256>>>0;if(l!==0)throw new Error("Non-zero carry");i=p,c++}if(o[c]!==" "){for(var h=f-i;h!==f&&u[h]===0;)h++;for(var b=new Uint8Array(z+(f-h)),C=z;h!==f;)b[C++]=u[h++];return b}}}function t(o){var c=N(o);if(c)return c;throw new Error(`Non-${r} character`)}return{encode:m,decodeUnsafe:N,decode:t}}var rr=er,tr=rr,pe=tr;var Y=class{constructor(r,e,s){this.name=r,this.prefix=e,this.baseEncode=s}encode(r){if(r instanceof Uint8Array)return`${this.prefix}${this.baseEncode(r)}`;throw Error("Unknown type, must be binary type")}},ee=class{constructor(r,e,s){if(this.name=r,this.prefix=e,e.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=e.codePointAt(0),this.baseDecode=s}decode(r){if(typeof r=="string"){if(r.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(r)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(r.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(r){return xe(this,r)}},re=class{constructor(r){this.decoders=r}or(r){return xe(this,r)}decode(r){let e=r[0],s=this.decoders[e];if(s)return s.decode(r);throw RangeError(`Unable to decode multibase string ${JSON.stringify(r)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},xe=(n,r)=>new re({...n.decoders||{[n.prefix]:n},...r.decoders||{[r.prefix]:r}}),te=class{constructor(r,e,s,a){this.name=r,this.prefix=e,this.baseEncode=s,this.baseDecode=a,this.encoder=new Y(r,e,s),this.decoder=new ee(r,e,a)}encode(r){return this.encoder.encode(r)}decode(r){return this.decoder.decode(r)}},ve=({name:n,prefix:r,encode:e,decode:s})=>new te(n,r,e,s),ne=({prefix:n,name:r,alphabet:e})=>{let{encode:s,decode:a}=pe(e,r);return ve({prefix:n,name:r,encode:s,decode:d=>V(a(d))})},nr=(n,r,e,s)=>{let a={};for(let A=0;A<r.length;++A)a[r[A]]=A;let d=n.length;for(;n[d-1]==="=";)--d;let x=new Uint8Array(d*e/8|0),w=0,S=0,U=0;for(let A=0;A<d;++A){let m=a[n[A]];if(m===void 0)throw new SyntaxError(`Non-${s} character`);S=S<<e|m,w+=e,w>=8&&(w-=8,x[U++]=255&S>>w)}if(w>=e||255&S<<8-w)throw new SyntaxError("Unexpected end of data");return x},or=(n,r,e)=>{let s=r[r.length-1]==="=",a=(1<<e)-1,d="",x=0,w=0;for(let S=0;S<n.length;++S)for(w=w<<8|n[S],x+=8;x>e;)x-=e,d+=r[a&w>>x];if(x&&(d+=r[a&w<<e-x]),s)for(;d.length*e&7;)d+="=";return d},y=({name:n,prefix:r,bitsPerChar:e,alphabet:s})=>ve({prefix:r,name:n,encode(a){return or(a,s,e)},decode(a){return nr(a,s,e,n)}});var M=ne({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ur=ne({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var F=y({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Cr=y({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Mr=y({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Nr=y({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Vr=y({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),kr=y({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Or=y({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Br=y({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Lr=y({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var ge=(n,r)=>{let{bytes:e,version:s}=n;switch(s){case 0:return sr(e,oe(n),r||M.encoder);default:return cr(e,oe(n),r||F.encoder)}};var we=new WeakMap,oe=n=>{let r=we.get(n);if(r==null){let e=new Map;return we.set(n,e),e}return r},E=class{constructor(r,e,s,a){this.code=e,this.version=r,this.multihash=s,this.bytes=a,this["/"]=a}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:r,multihash:e}=this;if(r!==I)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==ir)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return E.createV0(e)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:r,digest:e}=this.multihash,s=$(r,e);return E.createV1(this.code,s)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(r){return E.equals(this,r)}static equals(r,e){let s=e;return s&&r.code===s.code&&r.version===s.version&&le(r.multihash,s.multihash)}toString(r){return ge(this,r)}toJSON(){return{"/":ge(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(r){if(r==null)return null;let e=r;if(e instanceof E)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:s,code:a,multihash:d,bytes:x}=e;return new E(s,a,d,x||me(s,a,d.bytes))}else if(e[fr]===!0){let{version:s,multihash:a,code:d}=e,x=ue(a);return E.create(s,d,x)}else return null}static create(r,e,s){if(typeof e!="number")throw new Error("String codecs are no longer supported");if(!(s.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(r){case 0:{if(e!==I)throw new Error(`Version 0 CID must use dag-pb (code: ${I}) block encoding`);return new E(r,e,s,s.bytes)}case 1:{let a=me(r,e,s.bytes);return new E(r,e,s,a)}default:throw new Error("Invalid version")}}static createV0(r){return E.create(0,I,r)}static createV1(r,e){return E.create(1,r,e)}static decode(r){let[e,s]=E.decodeFirst(r);if(s.length)throw new Error("Incorrect length");return e}static decodeFirst(r){let e=E.inspectBytes(r),s=e.size-e.multihashSize,a=V(r.subarray(s,s+e.multihashSize));if(a.byteLength!==e.multihashSize)throw new Error("Incorrect length");let d=a.subarray(e.multihashSize-e.digestSize),x=new B(e.multihashCode,e.digestSize,d,a);return[e.version===0?E.createV0(x):E.createV1(e.codec,x),r.subarray(e.size)]}static inspectBytes(r){let e=0,s=()=>{let[m,N]=D(r.subarray(e));return e+=N,m},a=s(),d=I;if(a===18?(a=0,e=0):d=s(),a!==0&&a!==1)throw new RangeError(`Invalid CID version ${a}`);let x=e,w=s(),S=s(),U=e+S,A=U-x;return{version:a,codec:d,multihashCode:w,digestSize:S,multihashSize:A,size:U}}static parse(r,e){let[s,a]=ar(r,e),d=E.decode(a);return oe(d).set(s,r),d}},ar=(n,r)=>{switch(n[0]){case"Q":{let e=r||M;return[M.prefix,e.decode(`${M.prefix}${n}`)]}case M.prefix:{let e=r||M;return[M.prefix,e.decode(n)]}case F.prefix:{let e=r||F;return[F.prefix,e.decode(n)]}default:{if(r==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[n[0],r.decode(n)]}}},sr=(n,r,e)=>{let{prefix:s}=e;if(s!==M.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let a=r.get(s);if(a==null){let d=e.encode(n).slice(1);return r.set(s,d),d}else return a},cr=(n,r,e)=>{let{prefix:s}=e,a=r.get(s);if(a==null){let d=e.encode(n);return r.set(s,d),d}else return a},I=112,ir=18,me=(n,r,e)=>{let s=O(n),a=s+O(r),d=new Uint8Array(a+e.byteLength);return k(n,d,0),k(r,d,s),d.set(e,a),d},fr=Symbol.for("@ipld/js-cid/CID");var X=Me(Ae(),1);function hr(n){let r=new Array(4);for(let e=0;e<4;e++)r[e]=n&255,n=n>>8;return new Uint8Array(r)}var dr=_({name:"murmur3-32",code:35,encode:n=>hr(X.default.x86.hash32(n))}),ur=_({name:"murmur3-128",code:34,encode:n=>L.fromHex(X.default.x64.hash128(n))}),lr=_({name:"murmur3-x64-64",code:34,encode:n=>L.fromHex(X.default.x64.hash128(n)).subarray(0,8)});return Ne(pr);})(); | ||
"use strict";var MultiformatsMurmur3=(()=>{var Ee=Object.create;var P=Object.defineProperty;var Ue=Object.getOwnPropertyDescriptor;var ze=Object.getOwnPropertyNames;var ye=Object.getPrototypeOf,Ce=Object.prototype.hasOwnProperty;var ae=(n,r)=>()=>(r||n((r={exports:{}}).exports,r),r.exports),se=(n,r)=>{for(var e in r)P(n,e,{get:r[e],enumerable:!0})},ce=(n,r,e,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of ze(r))!Ce.call(n,a)&&a!==e&&P(n,a,{get:()=>r[a],enumerable:!(s=Ue(r,a))||s.enumerable});return n};var Me=(n,r,e)=>(e=n!=null?Ee(ye(n)):{},ce(r||!n||!n.__esModule?P(e,"default",{value:n,enumerable:!0}):e,n)),Ve=n=>ce(P({},"__esModule",{value:!0}),n);var be=ae((q,j)=>{(function(n,r){"use strict";var e={version:"3.0.0",x86:{},x64:{},inputValidation:!0};function s(t){if(!Array.isArray(t)&&!ArrayBuffer.isView(t))return!1;for(var o=0;o<t.length;o++)if(!Number.isInteger(t[o])||t[o]<0||t[o]>255)return!1;return!0}function a(t,o){return(t&65535)*o+(((t>>>16)*o&65535)<<16)}function h(t,o){return t<<o|t>>>32-o}function x(t){return t^=t>>>16,t=a(t,2246822507),t^=t>>>13,t=a(t,3266489909),t^=t>>>16,t}function w(t,o){t=[t[0]>>>16,t[0]&65535,t[1]>>>16,t[1]&65535],o=[o[0]>>>16,o[0]&65535,o[1]>>>16,o[1]&65535];var c=[0,0,0,0];return c[3]+=t[3]+o[3],c[2]+=c[3]>>>16,c[3]&=65535,c[2]+=t[2]+o[2],c[1]+=c[2]>>>16,c[2]&=65535,c[1]+=t[1]+o[1],c[0]+=c[1]>>>16,c[1]&=65535,c[0]+=t[0]+o[0],c[0]&=65535,[c[0]<<16|c[1],c[2]<<16|c[3]]}function S(t,o){t=[t[0]>>>16,t[0]&65535,t[1]>>>16,t[1]&65535],o=[o[0]>>>16,o[0]&65535,o[1]>>>16,o[1]&65535];var c=[0,0,0,0];return c[3]+=t[3]*o[3],c[2]+=c[3]>>>16,c[3]&=65535,c[2]+=t[2]*o[3],c[1]+=c[2]>>>16,c[2]&=65535,c[2]+=t[3]*o[2],c[1]+=c[2]>>>16,c[2]&=65535,c[1]+=t[1]*o[3],c[0]+=c[1]>>>16,c[1]&=65535,c[1]+=t[2]*o[2],c[0]+=c[1]>>>16,c[1]&=65535,c[1]+=t[3]*o[1],c[0]+=c[1]>>>16,c[1]&=65535,c[0]+=t[0]*o[3]+t[1]*o[2]+t[2]*o[1]+t[3]*o[0],c[0]&=65535,[c[0]<<16|c[1],c[2]<<16|c[3]]}function U(t,o){return o%=64,o===32?[t[1],t[0]]:o<32?[t[0]<<o|t[1]>>>32-o,t[1]<<o|t[0]>>>32-o]:(o-=32,[t[1]<<o|t[0]>>>32-o,t[0]<<o|t[1]>>>32-o])}function A(t,o){return o%=64,o===0?t:o<32?[t[0]<<o|t[1]>>>32-o,t[1]<<o]:[t[1]<<o-32,0]}function m(t,o){return[t[0]^o[0],t[1]^o[1]]}function V(t){return t=m(t,[0,t[0]>>>1]),t=S(t,[4283543511,3981806797]),t=m(t,[0,t[0]>>>1]),t=S(t,[3301882366,444984403]),t=m(t,[0,t[0]>>>1]),t}e.x86.hash32=function(t,o){if(e.inputValidation&&!s(t))return r;o=o||0;for(var c=t.length%4,z=t.length-c,i=o,f=0,u=3432918353,l=461845907,p=0;p<z;p=p+4)f=t[p]|t[p+1]<<8|t[p+2]<<16|t[p+3]<<24,f=a(f,u),f=h(f,15),f=a(f,l),i^=f,i=h(i,13),i=a(i,5)+3864292196;switch(f=0,c){case 3:f^=t[p+2]<<16;case 2:f^=t[p+1]<<8;case 1:f^=t[p],f=a(f,u),f=h(f,15),f=a(f,l),i^=f}return i^=t.length,i=x(i),i>>>0},e.x86.hash128=function(t,o){if(e.inputValidation&&!s(t))return r;o=o||0;for(var c=t.length%16,z=t.length-c,i=o,f=o,u=o,l=o,p=0,v=0,d=0,b=0,C=597399067,R=2869860233,H=951274213,J=2716044179,g=0;g<z;g=g+16)p=t[g]|t[g+1]<<8|t[g+2]<<16|t[g+3]<<24,v=t[g+4]|t[g+5]<<8|t[g+6]<<16|t[g+7]<<24,d=t[g+8]|t[g+9]<<8|t[g+10]<<16|t[g+11]<<24,b=t[g+12]|t[g+13]<<8|t[g+14]<<16|t[g+15]<<24,p=a(p,C),p=h(p,15),p=a(p,R),i^=p,i=h(i,19),i+=f,i=a(i,5)+1444728091,v=a(v,R),v=h(v,16),v=a(v,H),f^=v,f=h(f,17),f+=u,f=a(f,5)+197830471,d=a(d,H),d=h(d,17),d=a(d,J),u^=d,u=h(u,15),u+=l,u=a(u,5)+2530024501,b=a(b,J),b=h(b,18),b=a(b,C),l^=b,l=h(l,13),l+=i,l=a(l,5)+850148119;switch(p=0,v=0,d=0,b=0,c){case 15:b^=t[g+14]<<16;case 14:b^=t[g+13]<<8;case 13:b^=t[g+12],b=a(b,J),b=h(b,18),b=a(b,C),l^=b;case 12:d^=t[g+11]<<24;case 11:d^=t[g+10]<<16;case 10:d^=t[g+9]<<8;case 9:d^=t[g+8],d=a(d,H),d=h(d,17),d=a(d,J),u^=d;case 8:v^=t[g+7]<<24;case 7:v^=t[g+6]<<16;case 6:v^=t[g+5]<<8;case 5:v^=t[g+4],v=a(v,R),v=h(v,16),v=a(v,H),f^=v;case 4:p^=t[g+3]<<24;case 3:p^=t[g+2]<<16;case 2:p^=t[g+1]<<8;case 1:p^=t[g],p=a(p,C),p=h(p,15),p=a(p,R),i^=p}return i^=t.length,f^=t.length,u^=t.length,l^=t.length,i+=f,i+=u,i+=l,f+=i,u+=i,l+=i,i=x(i),f=x(f),u=x(u),l=x(l),i+=f,i+=u,i+=l,f+=i,u+=i,l+=i,("00000000"+(i>>>0).toString(16)).slice(-8)+("00000000"+(f>>>0).toString(16)).slice(-8)+("00000000"+(u>>>0).toString(16)).slice(-8)+("00000000"+(l>>>0).toString(16)).slice(-8)},e.x64.hash128=function(t,o){if(e.inputValidation&&!s(t))return r;o=o||0;for(var c=t.length%16,z=t.length-c,i=[0,o],f=[0,o],u=[0,0],l=[0,0],p=[2277735313,289559509],v=[1291169091,658871167],d=0;d<z;d=d+16)u=[t[d+4]|t[d+5]<<8|t[d+6]<<16|t[d+7]<<24,t[d]|t[d+1]<<8|t[d+2]<<16|t[d+3]<<24],l=[t[d+12]|t[d+13]<<8|t[d+14]<<16|t[d+15]<<24,t[d+8]|t[d+9]<<8|t[d+10]<<16|t[d+11]<<24],u=S(u,p),u=U(u,31),u=S(u,v),i=m(i,u),i=U(i,27),i=w(i,f),i=w(S(i,[0,5]),[0,1390208809]),l=S(l,v),l=U(l,33),l=S(l,p),f=m(f,l),f=U(f,31),f=w(f,i),f=w(S(f,[0,5]),[0,944331445]);switch(u=[0,0],l=[0,0],c){case 15:l=m(l,A([0,t[d+14]],48));case 14:l=m(l,A([0,t[d+13]],40));case 13:l=m(l,A([0,t[d+12]],32));case 12:l=m(l,A([0,t[d+11]],24));case 11:l=m(l,A([0,t[d+10]],16));case 10:l=m(l,A([0,t[d+9]],8));case 9:l=m(l,[0,t[d+8]]),l=S(l,v),l=U(l,33),l=S(l,p),f=m(f,l);case 8:u=m(u,A([0,t[d+7]],56));case 7:u=m(u,A([0,t[d+6]],48));case 6:u=m(u,A([0,t[d+5]],40));case 5:u=m(u,A([0,t[d+4]],32));case 4:u=m(u,A([0,t[d+3]],24));case 3:u=m(u,A([0,t[d+2]],16));case 2:u=m(u,A([0,t[d+1]],8));case 1:u=m(u,[0,t[d]]),u=S(u,p),u=U(u,31),u=S(u,v),i=m(i,u)}return i=m(i,[0,t.length]),f=m(f,[0,t.length]),i=w(i,f),f=w(f,i),i=V(i),f=V(f),i=w(i,f),f=w(f,i),("00000000"+(i[0]>>>0).toString(16)).slice(-8)+("00000000"+(i[1]>>>0).toString(16)).slice(-8)+("00000000"+(f[0]>>>0).toString(16)).slice(-8)+("00000000"+(f[1]>>>0).toString(16)).slice(-8)},typeof q<"u"?(typeof j<"u"&&j.exports&&(q=j.exports=e),q.murmurHash3=e):typeof define=="function"&&define.amd?define([],function(){return e}):(e._murmurHash3=n.murmurHash3,e.noConflict=function(){return n.murmurHash3=e._murmurHash3,e._murmurHash3=r,e.noConflict=r,e},n.murmurHash3=e)})(q)});var Ae=ae((Pr,Se)=>{Se.exports=be()});var pr={};se(pr,{murmur3128:()=>ur,murmur332:()=>dr,murmur364:()=>lr});var L={};se(L,{coerce:()=>N,empty:()=>ie,equals:()=>X,fromHex:()=>ke,fromString:()=>Be,isBinary:()=>Oe,toHex:()=>Ne,toString:()=>Le});var ie=new Uint8Array(0),Ne=n=>n.reduce((r,e)=>r+e.toString(16).padStart(2,"0"),""),ke=n=>{let r=n.match(/../g);return r?new Uint8Array(r.map(e=>parseInt(e,16))):ie},X=(n,r)=>{if(n===r)return!0;if(n.byteLength!==r.byteLength)return!1;for(let e=0;e<n.byteLength;e++)if(n[e]!==r[e])return!1;return!0},N=n=>{if(n instanceof Uint8Array&&n.constructor.name==="Uint8Array")return n;if(n instanceof ArrayBuffer)return new Uint8Array(n);if(ArrayBuffer.isView(n))return new Uint8Array(n.buffer,n.byteOffset,n.byteLength);throw new Error("Unknown type, must be binary type")},Oe=n=>n instanceof ArrayBuffer||ArrayBuffer.isView(n),Be=n=>new TextEncoder().encode(n),Le=n=>new TextDecoder().decode(n);var Te=de,fe=128,De=127,Ie=~De,$e=Math.pow(2,31);function de(n,r,e){r=r||[],e=e||0;for(var s=e;n>=$e;)r[e++]=n&255|fe,n/=128;for(;n&Ie;)r[e++]=n&255|fe,n>>>=7;return r[e]=n|0,de.bytes=e-s+1,r}var Fe=G,qe=128,he=127;function G(n,s){var e=0,s=s||0,a=0,h=s,x,w=n.length;do{if(h>=w)throw G.bytes=0,new RangeError("Could not decode varint");x=n[h++],e+=a<28?(x&he)<<a:(x&he)*Math.pow(2,a),a+=7}while(x>=qe);return G.bytes=h-s,e}var Re=Math.pow(2,7),He=Math.pow(2,14),Je=Math.pow(2,21),Pe=Math.pow(2,28),_e=Math.pow(2,35),je=Math.pow(2,42),Qe=Math.pow(2,49),Xe=Math.pow(2,56),Ge=Math.pow(2,63),Ke=function(n){return n<Re?1:n<He?2:n<Je?3:n<Pe?4:n<_e?5:n<je?6:n<Qe?7:n<Xe?8:n<Ge?9:10},We={encode:Te,decode:Fe,encodingLength:Ke},Ze=We,T=Ze;var D=(n,r=0)=>[T.decode(n,r),T.decode.bytes],k=(n,r,e=0)=>(T.encode(n,r,e),r),O=n=>T.encodingLength(n);var I=(n,r)=>{let e=r.byteLength,s=O(n),a=s+O(e),h=new Uint8Array(a+e);return k(n,h,0),k(e,h,s),h.set(r,a),new B(n,e,r,h)},ue=n=>{let r=N(n),[e,s]=D(r),[a,h]=D(r.subarray(s)),x=r.subarray(s+h);if(x.byteLength!==a)throw new Error("Incorrect length");return new B(e,a,x,r)},le=(n,r)=>{if(n===r)return!0;{let e=r;return n.code===e.code&&n.size===e.size&&e.bytes instanceof Uint8Array&&X(n.bytes,e.bytes)}},B=class{constructor(r,e,s,a){this.code=r,this.size=e,this.digest=s,this.bytes=a}};var _=({name:n,code:r,encode:e})=>new Z(n,r,e),Z=class{constructor(r,e,s){this.name=r,this.code=e,this.encode=s}digest(r){if(r instanceof Uint8Array){let e=this.encode(r);return e instanceof Uint8Array?I(this.code,e):e.then(s=>I(this.code,s))}else throw Error("Unknown type, must be binary type")}};function er(n,r){if(n.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),s=0;s<e.length;s++)e[s]=255;for(var a=0;a<n.length;a++){var h=n.charAt(a),x=h.charCodeAt(0);if(e[x]!==255)throw new TypeError(h+" is ambiguous");e[x]=a}var w=n.length,S=n.charAt(0),U=Math.log(w)/Math.log(256),A=Math.log(256)/Math.log(w);function m(o){if(o instanceof Uint8Array||(ArrayBuffer.isView(o)?o=new Uint8Array(o.buffer,o.byteOffset,o.byteLength):Array.isArray(o)&&(o=Uint8Array.from(o))),!(o instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(o.length===0)return"";for(var c=0,z=0,i=0,f=o.length;i!==f&&o[i]===0;)i++,c++;for(var u=(f-i)*A+1>>>0,l=new Uint8Array(u);i!==f;){for(var p=o[i],v=0,d=u-1;(p!==0||v<z)&&d!==-1;d--,v++)p+=256*l[d]>>>0,l[d]=p%w>>>0,p=p/w>>>0;if(p!==0)throw new Error("Non-zero carry");z=v,i++}for(var b=u-z;b!==u&&l[b]===0;)b++;for(var C=S.repeat(c);b<u;++b)C+=n.charAt(l[b]);return C}function V(o){if(typeof o!="string")throw new TypeError("Expected String");if(o.length===0)return new Uint8Array;var c=0;if(o[c]!==" "){for(var z=0,i=0;o[c]===S;)z++,c++;for(var f=(o.length-c)*U+1>>>0,u=new Uint8Array(f);o[c];){var l=e[o.charCodeAt(c)];if(l===255)return;for(var p=0,v=f-1;(l!==0||p<i)&&v!==-1;v--,p++)l+=w*u[v]>>>0,u[v]=l%256>>>0,l=l/256>>>0;if(l!==0)throw new Error("Non-zero carry");i=p,c++}if(o[c]!==" "){for(var d=f-i;d!==f&&u[d]===0;)d++;for(var b=new Uint8Array(z+(f-d)),C=z;d!==f;)b[C++]=u[d++];return b}}}function t(o){var c=V(o);if(c)return c;throw new Error(`Non-${r} character`)}return{encode:m,decodeUnsafe:V,decode:t}}var rr=er,tr=rr,pe=tr;var Y=class{constructor(r,e,s){this.name=r,this.prefix=e,this.baseEncode=s}encode(r){if(r instanceof Uint8Array)return`${this.prefix}${this.baseEncode(r)}`;throw Error("Unknown type, must be binary type")}},ee=class{constructor(r,e,s){if(this.name=r,this.prefix=e,e.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=e.codePointAt(0),this.baseDecode=s}decode(r){if(typeof r=="string"){if(r.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(r)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(r.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(r){return xe(this,r)}},re=class{constructor(r){this.decoders=r}or(r){return xe(this,r)}decode(r){let e=r[0],s=this.decoders[e];if(s)return s.decode(r);throw RangeError(`Unable to decode multibase string ${JSON.stringify(r)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},xe=(n,r)=>new re({...n.decoders||{[n.prefix]:n},...r.decoders||{[r.prefix]:r}}),te=class{constructor(r,e,s,a){this.name=r,this.prefix=e,this.baseEncode=s,this.baseDecode=a,this.encoder=new Y(r,e,s),this.decoder=new ee(r,e,a)}encode(r){return this.encoder.encode(r)}decode(r){return this.decoder.decode(r)}},ve=({name:n,prefix:r,encode:e,decode:s})=>new te(n,r,e,s),ne=({prefix:n,name:r,alphabet:e})=>{let{encode:s,decode:a}=pe(e,r);return ve({prefix:n,name:r,encode:s,decode:h=>N(a(h))})},nr=(n,r,e,s)=>{let a={};for(let A=0;A<r.length;++A)a[r[A]]=A;let h=n.length;for(;n[h-1]==="=";)--h;let x=new Uint8Array(h*e/8|0),w=0,S=0,U=0;for(let A=0;A<h;++A){let m=a[n[A]];if(m===void 0)throw new SyntaxError(`Non-${s} character`);S=S<<e|m,w+=e,w>=8&&(w-=8,x[U++]=255&S>>w)}if(w>=e||255&S<<8-w)throw new SyntaxError("Unexpected end of data");return x},or=(n,r,e)=>{let s=r[r.length-1]==="=",a=(1<<e)-1,h="",x=0,w=0;for(let S=0;S<n.length;++S)for(w=w<<8|n[S],x+=8;x>e;)x-=e,h+=r[a&w>>x];if(x&&(h+=r[a&w<<e-x]),s)for(;h.length*e&7;)h+="=";return h},y=({name:n,prefix:r,bitsPerChar:e,alphabet:s})=>ve({prefix:r,name:n,encode(a){return or(a,s,e)},decode(a){return nr(a,s,e,n)}});var M=ne({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ur=ne({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var $=y({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Cr=y({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Mr=y({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Vr=y({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Nr=y({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),kr=y({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Or=y({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Br=y({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Lr=y({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var ge=(n,r)=>{let{bytes:e,version:s}=n;switch(s){case 0:return sr(e,oe(n),r||M.encoder);default:return cr(e,oe(n),r||$.encoder)}};var we=new WeakMap,oe=n=>{let r=we.get(n);if(r==null){let e=new Map;return we.set(n,e),e}return r},E=class{constructor(r,e,s,a){this.code=e,this.version=r,this.multihash=s,this.bytes=a,this["/"]=a}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:r,multihash:e}=this;if(r!==F)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==ir)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return E.createV0(e)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:r,digest:e}=this.multihash,s=I(r,e);return E.createV1(this.code,s)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(r){return E.equals(this,r)}static equals(r,e){let s=e;return s&&r.code===s.code&&r.version===s.version&&le(r.multihash,s.multihash)}toString(r){return ge(this,r)}toJSON(){return{"/":ge(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(r){if(r==null)return null;let e=r;if(e instanceof E)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:s,code:a,multihash:h,bytes:x}=e;return new E(s,a,h,x||me(s,a,h.bytes))}else if(e[fr]===!0){let{version:s,multihash:a,code:h}=e,x=ue(a);return E.create(s,h,x)}else return null}static create(r,e,s){if(typeof e!="number")throw new Error("String codecs are no longer supported");if(!(s.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(r){case 0:{if(e!==F)throw new Error(`Version 0 CID must use dag-pb (code: ${F}) block encoding`);return new E(r,e,s,s.bytes)}case 1:{let a=me(r,e,s.bytes);return new E(r,e,s,a)}default:throw new Error("Invalid version")}}static createV0(r){return E.create(0,F,r)}static createV1(r,e){return E.create(1,r,e)}static decode(r){let[e,s]=E.decodeFirst(r);if(s.length)throw new Error("Incorrect length");return e}static decodeFirst(r){let e=E.inspectBytes(r),s=e.size-e.multihashSize,a=N(r.subarray(s,s+e.multihashSize));if(a.byteLength!==e.multihashSize)throw new Error("Incorrect length");let h=a.subarray(e.multihashSize-e.digestSize),x=new B(e.multihashCode,e.digestSize,h,a);return[e.version===0?E.createV0(x):E.createV1(e.codec,x),r.subarray(e.size)]}static inspectBytes(r){let e=0,s=()=>{let[m,V]=D(r.subarray(e));return e+=V,m},a=s(),h=F;if(a===18?(a=0,e=0):h=s(),a!==0&&a!==1)throw new RangeError(`Invalid CID version ${a}`);let x=e,w=s(),S=s(),U=e+S,A=U-x;return{version:a,codec:h,multihashCode:w,digestSize:S,multihashSize:A,size:U}}static parse(r,e){let[s,a]=ar(r,e),h=E.decode(a);if(h.version===0&&r[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return oe(h).set(s,r),h}},ar=(n,r)=>{switch(n[0]){case"Q":{let e=r||M;return[M.prefix,e.decode(`${M.prefix}${n}`)]}case M.prefix:{let e=r||M;return[M.prefix,e.decode(n)]}case $.prefix:{let e=r||$;return[$.prefix,e.decode(n)]}default:{if(r==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[n[0],r.decode(n)]}}},sr=(n,r,e)=>{let{prefix:s}=e;if(s!==M.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let a=r.get(s);if(a==null){let h=e.encode(n).slice(1);return r.set(s,h),h}else return a},cr=(n,r,e)=>{let{prefix:s}=e,a=r.get(s);if(a==null){let h=e.encode(n);return r.set(s,h),h}else return a},F=112,ir=18,me=(n,r,e)=>{let s=O(n),a=s+O(r),h=new Uint8Array(a+e.byteLength);return k(n,h,0),k(r,h,s),h.set(e,a),h},fr=Symbol.for("@ipld/js-cid/CID");var Q=Me(Ae(),1);function hr(n){let r=new Array(4);for(let e=0;e<4;e++)r[e]=n&255,n=n>>8;return new Uint8Array(r)}var dr=_({name:"murmur3-32",code:35,encode:n=>hr(Q.default.x86.hash32(n))}),ur=_({name:"murmur3-128",code:34,encode:n=>L.fromHex(Q.default.x64.hash128(n))}),lr=_({name:"murmur3-x64-64",code:34,encode:n=>L.fromHex(Q.default.x64.hash128(n)).subarray(0,8)});return Ve(pr);})(); | ||
return MultiformatsMurmur3})); |
{ | ||
"name": "@multiformats/murmur3", | ||
"version": "2.1.2", | ||
"version": "2.1.3", | ||
"description": "Multiformats Murmur3 implementations", | ||
@@ -169,4 +169,4 @@ "author": "Mikeal Rogers <mikeal.rogers@gmail.com> (https://www.mikealrogers.com/)", | ||
"@ipld/dag-cbor": "^9.0.0", | ||
"aegir": "^37.5.6" | ||
"aegir": "^38.1.2" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
25824
38369