Socket
Socket
Sign inDemoInstall

uint8arrays

Package Overview
Dependencies
1
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.0.10 to 5.0.0

2

dist/index.min.js
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Uint8Arrays = factory()}(typeof self !== 'undefined' ? self : this, function () {
"use strict";var Uint8Arrays=(()=>{var X=Object.defineProperty;var je=Object.getOwnPropertyDescriptor;var Re=Object.getOwnPropertyNames;var Je=Object.prototype.hasOwnProperty;var d=(t,e)=>{for(var r in e)X(t,r,{get:e[r],enumerable:!0})},Xe=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Re(e))!Je.call(t,n)&&n!==r&&X(t,n,{get:()=>e[n],enumerable:!(o=je(e,n))||o.enumerable});return t};var Qe=t=>Xe(X({},"__esModule",{value:!0}),t);var tr={};d(tr,{compare:()=>le,concat:()=>me,equals:()=>be,fromString:()=>$e,toString:()=>Fe,xor:()=>ke});function le(t,e){if(globalThis.Buffer!=null)return globalThis.Buffer.compare(t,e);for(let r=0;r<t.byteLength;r++){if(t[r]<e[r])return-1;if(t[r]>e[r])return 1}return t.byteLength>e.byteLength?1:t.byteLength<e.byteLength?-1:0}function S(t){return globalThis.Buffer!=null?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t}function I(t=0){return globalThis.Buffer?.allocUnsafe!=null?S(globalThis.Buffer.allocUnsafe(t)):new Uint8Array(t)}function me(t,e){e==null&&(e=t.reduce((n,s)=>n+s.length,0));let r=I(e),o=0;for(let n of t)r.set(n,o),o+=n.length;return S(r)}function be(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}var W={};d(W,{base10:()=>Ye});function Ge(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),o=0;o<r.length;o++)r[o]=255;for(var n=0;n<t.length;n++){var s=t.charAt(n),i=s.charCodeAt(0);if(r[i]!==255)throw new TypeError(s+" is ambiguous");r[i]=n}var c=t.length,h=t.charAt(0),T=Math.log(c)/Math.log(256),u=Math.log(256)/Math.log(c);function B(a){if(a instanceof Uint8Array||(ArrayBuffer.isView(a)?a=new Uint8Array(a.buffer,a.byteOffset,a.byteLength):Array.isArray(a)&&(a=Uint8Array.from(a))),!(a instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(a.length===0)return"";for(var p=0,E=0,m=0,x=a.length;m!==x&&a[m]===0;)m++,p++;for(var g=(x-m)*u+1>>>0,l=new Uint8Array(g);m!==x;){for(var w=a[m],C=0,b=g-1;(w!==0||C<E)&&b!==-1;b--,C++)w+=256*l[b]>>>0,l[b]=w%c>>>0,w=w/c>>>0;if(w!==0)throw new Error("Non-zero carry");E=C,m++}for(var v=g-E;v!==g&&l[v]===0;)v++;for(var q=h.repeat(p);v<g;++v)q+=t.charAt(l[v]);return q}function k(a){if(typeof a!="string")throw new TypeError("Expected String");if(a.length===0)return new Uint8Array;var p=0;if(a[p]!==" "){for(var E=0,m=0;a[p]===h;)E++,p++;for(var x=(a.length-p)*T+1>>>0,g=new Uint8Array(x);a[p];){var l=r[a.charCodeAt(p)];if(l===255)return;for(var w=0,C=x-1;(l!==0||w<m)&&C!==-1;C--,w++)l+=c*g[C]>>>0,g[C]=l%256>>>0,l=l/256>>>0;if(l!==0)throw new Error("Non-zero carry");m=w,p++}if(a[p]!==" "){for(var b=x-m;b!==x&&g[b]===0;)b++;for(var v=new Uint8Array(E+(x-b)),q=E;b!==x;)v[q++]=g[b++];return v}}}function qe(a){var p=k(a);if(p)return p;throw new Error(`Non-${e} character`)}return{encode:B,decodeUnsafe:k,decode:qe}}var Ke=Ge,He=Ke,xe=He;var dr=new Uint8Array(0);var ge=(t,e)=>{if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0},A=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")};var we=t=>new TextEncoder().encode(t),ye=t=>new TextDecoder().decode(t);var Q=class{constructor(e,r,o){this.name=e,this.prefix=r,this.baseEncode=o}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},G=class{constructor(e,r,o){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=o}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Ae(this,e)}},K=class{constructor(e){this.decoders=e}or(e){return Ae(this,e)}decode(e){let r=e[0],o=this.decoders[r];if(o)return o.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},Ae=(t,e)=>new K({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}}),H=class{constructor(e,r,o,n){this.name=e,this.prefix=r,this.baseEncode=o,this.baseDecode=n,this.encoder=new Q(e,r,o),this.decoder=new G(e,r,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},z=({name:t,prefix:e,encode:r,decode:o})=>new H(t,e,r,o),U=({prefix:t,name:e,alphabet:r})=>{let{encode:o,decode:n}=xe(r,e);return z({prefix:t,name:e,encode:o,decode:s=>A(n(s))})},We=(t,e,r,o)=>{let n={};for(let u=0;u<e.length;++u)n[e[u]]=u;let s=t.length;for(;t[s-1]==="=";)--s;let i=new Uint8Array(s*r/8|0),c=0,h=0,T=0;for(let u=0;u<s;++u){let B=n[t[u]];if(B===void 0)throw new SyntaxError(`Non-${o} character`);h=h<<r|B,c+=r,c>=8&&(c-=8,i[T++]=255&h>>c)}if(c>=r||255&h<<8-c)throw new SyntaxError("Unexpected end of data");return i},Ze=(t,e,r)=>{let o=e[e.length-1]==="=",n=(1<<r)-1,s="",i=0,c=0;for(let h=0;h<t.length;++h)for(c=c<<8|t[h],i+=8;i>r;)i-=r,s+=e[n&c>>i];if(i&&(s+=e[n&c<<r-i]),o)for(;s.length*r&7;)s+="=";return s},f=({name:t,prefix:e,bitsPerChar:r,alphabet:o})=>z({prefix:e,name:t,encode(n){return Ze(n,o,r)},decode(n){return We(n,o,r,t)}});var Ye=U({prefix:"9",name:"base10",alphabet:"0123456789"});var Z={};d(Z,{base16:()=>_e,base16upper:()=>et});var _e=f({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),et=f({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Y={};d(Y,{base2:()=>tt});var tt=f({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var _={};d(_,{base256emoji:()=>it});var Ce=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),rt=Ce.reduce((t,e,r)=>(t[r]=e,t),[]),ot=Ce.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function nt(t){return t.reduce((e,r)=>(e+=rt[r],e),"")}function st(t){let e=[];for(let r of t){let o=ot[r.codePointAt(0)];if(o===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(o)}return new Uint8Array(e)}var it=z({prefix:"\u{1F680}",name:"base256emoji",encode:nt,decode:st});var ee={};d(ee,{base32:()=>L,base32hex:()=>ht,base32hexpad:()=>dt,base32hexpadupper:()=>ut,base32hexupper:()=>pt,base32pad:()=>ct,base32padupper:()=>ft,base32upper:()=>at,base32z:()=>lt});var L=f({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),at=f({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),ct=f({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),ft=f({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),ht=f({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),pt=f({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),dt=f({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),ut=f({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),lt=f({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var te={};d(te,{base36:()=>mt,base36upper:()=>bt});var mt=U({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),bt=U({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var re={};d(re,{base58btc:()=>y,base58flickr:()=>xt});var y=U({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),xt=U({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var oe={};d(oe,{base64:()=>gt,base64pad:()=>wt,base64url:()=>yt,base64urlpad:()=>vt});var gt=f({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),wt=f({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),yt=f({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),vt=f({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var ne={};d(ne,{base8:()=>At});var At=f({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var se={};d(se,{identity:()=>Ct});var Ct=z({prefix:"\0",name:"identity",encode:t=>ye(t),decode:t=>we(t)});var Dr=new TextEncoder,Tr=new TextDecoder;var ae={};d(ae,{identity:()=>Qt});var Et=Ee,Se=128,Dt=127,Tt=~Dt,Bt=Math.pow(2,31);function Ee(t,e,r){e=e||[],r=r||0;for(var o=r;t>=Bt;)e[r++]=t&255|Se,t/=128;for(;t&Tt;)e[r++]=t&255|Se,t>>>=7;return e[r]=t|0,Ee.bytes=r-o+1,e}var It=ie,zt=128,Ue=127;function ie(t,o){var r=0,o=o||0,n=0,s=o,i,c=t.length;do{if(s>=c)throw ie.bytes=0,new RangeError("Could not decode varint");i=t[s++],r+=n<28?(i&Ue)<<n:(i&Ue)*Math.pow(2,n),n+=7}while(i>=zt);return ie.bytes=s-o,r}var Lt=Math.pow(2,7),Ot=Math.pow(2,14),Mt=Math.pow(2,21),Nt=Math.pow(2,28),Vt=Math.pow(2,35),Pt=Math.pow(2,42),$t=Math.pow(2,49),Ft=Math.pow(2,56),kt=Math.pow(2,63),qt=function(t){return t<Lt?1:t<Ot?2:t<Mt?3:t<Nt?4:t<Vt?5:t<Pt?6:t<$t?7:t<Ft?8:t<kt?9:10},jt={encode:Et,decode:It,encodingLength:qt},Rt=jt,V=Rt;var P=(t,e=0)=>[V.decode(t,e),V.decode.bytes],O=(t,e,r=0)=>(V.encode(t,e,r),e),M=t=>V.encodingLength(t);var D=(t,e)=>{let r=e.byteLength,o=M(t),n=o+M(r),s=new Uint8Array(n+r);return O(t,s,0),O(r,s,o),s.set(e,n),new N(t,r,e,s)},De=t=>{let e=A(t),[r,o]=P(e),[n,s]=P(e.subarray(o)),i=e.subarray(o+s);if(i.byteLength!==n)throw new Error("Incorrect length");return new N(r,n,i,e)},Te=(t,e)=>{if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&ge(t.bytes,r.bytes)}},N=class{constructor(e,r,o,n){this.code=e,this.size=r,this.digest=o,this.bytes=n}};var Be=0,Jt="identity",Ie=A,Xt=t=>D(Be,Ie(t)),Qt={code:Be,name:Jt,encode:Ie,digest:Xt};var he={};d(he,{sha256:()=>Gt,sha512:()=>Kt});var fe=({name:t,code:e,encode:r})=>new ce(t,e,r),ce=class{constructor(e,r,o){this.name=e,this.code=r,this.encode=o}digest(e){if(e instanceof Uint8Array){let r=this.encode(e);return r instanceof Uint8Array?D(this.code,r):r.then(o=>D(this.code,o))}else throw Error("Unknown type, must be binary type")}};var Le=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),Gt=fe({name:"sha2-256",code:18,encode:Le("SHA-256")}),Kt=fe({name:"sha2-512",code:19,encode:Le("SHA-512")});var Oe=(t,e)=>{let{bytes:r,version:o}=t;switch(o){case 0:return Wt(r,pe(t),e||y.encoder);default:return Zt(r,pe(t),e||L.encoder)}};var Me=new WeakMap,pe=t=>{let e=Me.get(t);if(e==null){let r=new Map;return Me.set(t,r),r}return e},R=class t{constructor(e,r,o,n){this.code=r,this.version=e,this.multihash=o,this.bytes=n,this["/"]=n}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:e,multihash:r}=this;if(e!==F)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Yt)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return t.createV0(r)}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:e,digest:r}=this.multihash,o=D(e,r);return t.createV1(this.code,o)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return t.equals(this,e)}static equals(e,r){let o=r;return o&&e.code===o.code&&e.version===o.version&&Te(e.multihash,o.multihash)}toString(e){return Oe(this,e)}toJSON(){return{"/":Oe(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let r=e;if(r instanceof t)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:o,code:n,multihash:s,bytes:i}=r;return new t(o,n,s,i||Ne(o,n,s.bytes))}else if(r[_t]===!0){let{version:o,multihash:n,code:s}=r,i=De(n);return t.create(o,s,i)}else return null}static create(e,r,o){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(o.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(r!==F)throw new Error(`Version 0 CID must use dag-pb (code: ${F}) block encoding`);return new t(e,r,o,o.bytes)}case 1:{let n=Ne(e,r,o.bytes);return new t(e,r,o,n)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,F,e)}static createV1(e,r){return t.create(1,e,r)}static decode(e){let[r,o]=t.decodeFirst(e);if(o.length)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=t.inspectBytes(e),o=r.size-r.multihashSize,n=A(e.subarray(o,o+r.multihashSize));if(n.byteLength!==r.multihashSize)throw new Error("Incorrect length");let s=n.subarray(r.multihashSize-r.digestSize),i=new N(r.multihashCode,r.digestSize,s,n);return[r.version===0?t.createV0(i):t.createV1(r.codec,i),e.subarray(r.size)]}static inspectBytes(e){let r=0,o=()=>{let[B,k]=P(e.subarray(r));return r+=k,B},n=o(),s=F;if(n===18?(n=0,r=0):s=o(),n!==0&&n!==1)throw new RangeError(`Invalid CID version ${n}`);let i=r,c=o(),h=o(),T=r+h,u=T-i;return{version:n,codec:s,multihashCode:c,digestSize:h,multihashSize:u,size:T}}static parse(e,r){let[o,n]=Ht(e,r),s=t.decode(n);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return pe(s).set(o,e),s}},Ht=(t,e)=>{switch(t[0]){case"Q":{let r=e||y;return[y.prefix,r.decode(`${y.prefix}${t}`)]}case y.prefix:{let r=e||y;return[y.prefix,r.decode(t)]}case L.prefix:{let r=e||L;return[L.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}},Wt=(t,e,r)=>{let{prefix:o}=r;if(o!==y.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let n=e.get(o);if(n==null){let s=r.encode(t).slice(1);return e.set(o,s),s}else return n},Zt=(t,e,r)=>{let{prefix:o}=r,n=e.get(o);if(n==null){let s=r.encode(t);return e.set(o,s),s}else return n},F=112,Yt=18,Ne=(t,e,r)=>{let o=M(t),n=o+M(e),s=new Uint8Array(n+r.byteLength);return O(t,s,0),O(e,s,o),s.set(r,n),s},_t=Symbol.for("@ipld/js-cid/CID");var de={...se,...Y,...ne,...W,...Z,...ee,...te,...re,...oe,..._},Jr={...he,...ae};function Pe(t,e,r,o){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:o}}}var Ve=Pe("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),ue=Pe("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);let e=I(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),er={utf8:Ve,"utf-8":Ve,hex:de.base16,latin1:ue,ascii:ue,binary:ue,...de},J=er;function $e(t,e="utf8"){let r=J[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?S(globalThis.Buffer.from(t,"utf-8")):r.decoder.decode(`${r.prefix}${t}`)}function Fe(t,e="utf8"){let r=J[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):r.encoder.encode(t).substring(1)}function ke(t,e){if(t.length!==e.length)throw new Error("Inputs should have the same length");let r=I(t.length);for(let o=0;o<t.length;o++)r[o]=t[o]^e[o];return S(r)}return Qe(tr);})();
"use strict";var Uint8Arrays=(()=>{var X=Object.defineProperty;var je=Object.getOwnPropertyDescriptor;var Re=Object.getOwnPropertyNames;var Je=Object.prototype.hasOwnProperty;var d=(t,e)=>{for(var r in e)X(t,r,{get:e[r],enumerable:!0})},Xe=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Re(e))!Je.call(t,n)&&n!==r&&X(t,n,{get:()=>e[n],enumerable:!(o=je(e,n))||o.enumerable});return t};var Qe=t=>Xe(X({},"__esModule",{value:!0}),t);var tr={};d(tr,{compare:()=>le,concat:()=>me,equals:()=>be,fromString:()=>$e,toString:()=>Fe,xor:()=>ke});function le(t,e){if(globalThis.Buffer!=null)return globalThis.Buffer.compare(t,e);for(let r=0;r<t.byteLength;r++){if(t[r]<e[r])return-1;if(t[r]>e[r])return 1}return t.byteLength>e.byteLength?1:t.byteLength<e.byteLength?-1:0}function A(t){return globalThis.Buffer!=null?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t}function I(t=0){return globalThis.Buffer?.allocUnsafe!=null?A(globalThis.Buffer.allocUnsafe(t)):new Uint8Array(t)}function me(t,e){if(globalThis.Buffer!=null)return A(globalThis.Buffer.concat(t,e));e==null&&(e=t.reduce((n,s)=>n+s.length,0));let r=I(e),o=0;for(let n of t)r.set(n,o),o+=n.length;return A(r)}function be(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}var W={};d(W,{base10:()=>Ye});function Ge(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),o=0;o<r.length;o++)r[o]=255;for(var n=0;n<t.length;n++){var s=t.charAt(n),i=s.charCodeAt(0);if(r[i]!==255)throw new TypeError(s+" is ambiguous");r[i]=n}var c=t.length,h=t.charAt(0),T=Math.log(c)/Math.log(256),u=Math.log(256)/Math.log(c);function B(a){if(a instanceof Uint8Array||(ArrayBuffer.isView(a)?a=new Uint8Array(a.buffer,a.byteOffset,a.byteLength):Array.isArray(a)&&(a=Uint8Array.from(a))),!(a instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(a.length===0)return"";for(var p=0,E=0,m=0,x=a.length;m!==x&&a[m]===0;)m++,p++;for(var g=(x-m)*u+1>>>0,l=new Uint8Array(g);m!==x;){for(var w=a[m],S=0,b=g-1;(w!==0||S<E)&&b!==-1;b--,S++)w+=256*l[b]>>>0,l[b]=w%c>>>0,w=w/c>>>0;if(w!==0)throw new Error("Non-zero carry");E=S,m++}for(var v=g-E;v!==g&&l[v]===0;)v++;for(var q=h.repeat(p);v<g;++v)q+=t.charAt(l[v]);return q}function k(a){if(typeof a!="string")throw new TypeError("Expected String");if(a.length===0)return new Uint8Array;var p=0;if(a[p]!==" "){for(var E=0,m=0;a[p]===h;)E++,p++;for(var x=(a.length-p)*T+1>>>0,g=new Uint8Array(x);a[p];){var l=r[a.charCodeAt(p)];if(l===255)return;for(var w=0,S=x-1;(l!==0||w<m)&&S!==-1;S--,w++)l+=c*g[S]>>>0,g[S]=l%256>>>0,l=l/256>>>0;if(l!==0)throw new Error("Non-zero carry");m=w,p++}if(a[p]!==" "){for(var b=x-m;b!==x&&g[b]===0;)b++;for(var v=new Uint8Array(E+(x-b)),q=E;b!==x;)v[q++]=g[b++];return v}}}function qe(a){var p=k(a);if(p)return p;throw new Error(`Non-${e} character`)}return{encode:B,decodeUnsafe:k,decode:qe}}var Ke=Ge,He=Ke,xe=He;var dr=new Uint8Array(0);var ge=(t,e)=>{if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0},C=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")};var we=t=>new TextEncoder().encode(t),ye=t=>new TextDecoder().decode(t);var Q=class{constructor(e,r,o){this.name=e,this.prefix=r,this.baseEncode=o}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},G=class{constructor(e,r,o){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=o}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Ae(this,e)}},K=class{constructor(e){this.decoders=e}or(e){return Ae(this,e)}decode(e){let r=e[0],o=this.decoders[r];if(o)return o.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},Ae=(t,e)=>new K({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}}),H=class{constructor(e,r,o,n){this.name=e,this.prefix=r,this.baseEncode=o,this.baseDecode=n,this.encoder=new Q(e,r,o),this.decoder=new G(e,r,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},z=({name:t,prefix:e,encode:r,decode:o})=>new H(t,e,r,o),U=({prefix:t,name:e,alphabet:r})=>{let{encode:o,decode:n}=xe(r,e);return z({prefix:t,name:e,encode:o,decode:s=>C(n(s))})},We=(t,e,r,o)=>{let n={};for(let u=0;u<e.length;++u)n[e[u]]=u;let s=t.length;for(;t[s-1]==="=";)--s;let i=new Uint8Array(s*r/8|0),c=0,h=0,T=0;for(let u=0;u<s;++u){let B=n[t[u]];if(B===void 0)throw new SyntaxError(`Non-${o} character`);h=h<<r|B,c+=r,c>=8&&(c-=8,i[T++]=255&h>>c)}if(c>=r||255&h<<8-c)throw new SyntaxError("Unexpected end of data");return i},Ze=(t,e,r)=>{let o=e[e.length-1]==="=",n=(1<<r)-1,s="",i=0,c=0;for(let h=0;h<t.length;++h)for(c=c<<8|t[h],i+=8;i>r;)i-=r,s+=e[n&c>>i];if(i&&(s+=e[n&c<<r-i]),o)for(;s.length*r&7;)s+="=";return s},f=({name:t,prefix:e,bitsPerChar:r,alphabet:o})=>z({prefix:e,name:t,encode(n){return Ze(n,o,r)},decode(n){return We(n,o,r,t)}});var Ye=U({prefix:"9",name:"base10",alphabet:"0123456789"});var Z={};d(Z,{base16:()=>_e,base16upper:()=>et});var _e=f({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),et=f({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Y={};d(Y,{base2:()=>tt});var tt=f({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var _={};d(_,{base256emoji:()=>it});var Ce=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),rt=Ce.reduce((t,e,r)=>(t[r]=e,t),[]),ot=Ce.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function nt(t){return t.reduce((e,r)=>(e+=rt[r],e),"")}function st(t){let e=[];for(let r of t){let o=ot[r.codePointAt(0)];if(o===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(o)}return new Uint8Array(e)}var it=z({prefix:"\u{1F680}",name:"base256emoji",encode:nt,decode:st});var ee={};d(ee,{base32:()=>L,base32hex:()=>ht,base32hexpad:()=>dt,base32hexpadupper:()=>ut,base32hexupper:()=>pt,base32pad:()=>ct,base32padupper:()=>ft,base32upper:()=>at,base32z:()=>lt});var L=f({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),at=f({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),ct=f({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),ft=f({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),ht=f({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),pt=f({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),dt=f({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),ut=f({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),lt=f({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var te={};d(te,{base36:()=>mt,base36upper:()=>bt});var mt=U({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),bt=U({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var re={};d(re,{base58btc:()=>y,base58flickr:()=>xt});var y=U({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),xt=U({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var oe={};d(oe,{base64:()=>gt,base64pad:()=>wt,base64url:()=>yt,base64urlpad:()=>vt});var gt=f({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),wt=f({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),yt=f({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),vt=f({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var ne={};d(ne,{base8:()=>At});var At=f({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var se={};d(se,{identity:()=>Ct});var Ct=z({prefix:"\0",name:"identity",encode:t=>ye(t),decode:t=>we(t)});var Dr=new TextEncoder,Tr=new TextDecoder;var ae={};d(ae,{identity:()=>Qt});var Et=Ee,Se=128,Dt=127,Tt=~Dt,Bt=Math.pow(2,31);function Ee(t,e,r){e=e||[],r=r||0;for(var o=r;t>=Bt;)e[r++]=t&255|Se,t/=128;for(;t&Tt;)e[r++]=t&255|Se,t>>>=7;return e[r]=t|0,Ee.bytes=r-o+1,e}var It=ie,zt=128,Ue=127;function ie(t,o){var r=0,o=o||0,n=0,s=o,i,c=t.length;do{if(s>=c)throw ie.bytes=0,new RangeError("Could not decode varint");i=t[s++],r+=n<28?(i&Ue)<<n:(i&Ue)*Math.pow(2,n),n+=7}while(i>=zt);return ie.bytes=s-o,r}var Lt=Math.pow(2,7),Ot=Math.pow(2,14),Mt=Math.pow(2,21),Nt=Math.pow(2,28),Vt=Math.pow(2,35),Pt=Math.pow(2,42),$t=Math.pow(2,49),Ft=Math.pow(2,56),kt=Math.pow(2,63),qt=function(t){return t<Lt?1:t<Ot?2:t<Mt?3:t<Nt?4:t<Vt?5:t<Pt?6:t<$t?7:t<Ft?8:t<kt?9:10},jt={encode:Et,decode:It,encodingLength:qt},Rt=jt,V=Rt;var P=(t,e=0)=>[V.decode(t,e),V.decode.bytes],O=(t,e,r=0)=>(V.encode(t,e,r),e),M=t=>V.encodingLength(t);var D=(t,e)=>{let r=e.byteLength,o=M(t),n=o+M(r),s=new Uint8Array(n+r);return O(t,s,0),O(r,s,o),s.set(e,n),new N(t,r,e,s)},De=t=>{let e=C(t),[r,o]=P(e),[n,s]=P(e.subarray(o)),i=e.subarray(o+s);if(i.byteLength!==n)throw new Error("Incorrect length");return new N(r,n,i,e)},Te=(t,e)=>{if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&ge(t.bytes,r.bytes)}},N=class{constructor(e,r,o,n){this.code=e,this.size=r,this.digest=o,this.bytes=n}};var Be=0,Jt="identity",Ie=C,Xt=t=>D(Be,Ie(t)),Qt={code:Be,name:Jt,encode:Ie,digest:Xt};var he={};d(he,{sha256:()=>Gt,sha512:()=>Kt});var fe=({name:t,code:e,encode:r})=>new ce(t,e,r),ce=class{constructor(e,r,o){this.name=e,this.code=r,this.encode=o}digest(e){if(e instanceof Uint8Array){let r=this.encode(e);return r instanceof Uint8Array?D(this.code,r):r.then(o=>D(this.code,o))}else throw Error("Unknown type, must be binary type")}};var Le=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),Gt=fe({name:"sha2-256",code:18,encode:Le("SHA-256")}),Kt=fe({name:"sha2-512",code:19,encode:Le("SHA-512")});var Oe=(t,e)=>{let{bytes:r,version:o}=t;switch(o){case 0:return Wt(r,pe(t),e||y.encoder);default:return Zt(r,pe(t),e||L.encoder)}};var Me=new WeakMap,pe=t=>{let e=Me.get(t);if(e==null){let r=new Map;return Me.set(t,r),r}return e},R=class t{constructor(e,r,o,n){this.code=r,this.version=e,this.multihash=o,this.bytes=n,this["/"]=n}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:e,multihash:r}=this;if(e!==F)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Yt)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return t.createV0(r)}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:e,digest:r}=this.multihash,o=D(e,r);return t.createV1(this.code,o)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return t.equals(this,e)}static equals(e,r){let o=r;return o&&e.code===o.code&&e.version===o.version&&Te(e.multihash,o.multihash)}toString(e){return Oe(this,e)}toJSON(){return{"/":Oe(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let r=e;if(r instanceof t)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:o,code:n,multihash:s,bytes:i}=r;return new t(o,n,s,i||Ne(o,n,s.bytes))}else if(r[_t]===!0){let{version:o,multihash:n,code:s}=r,i=De(n);return t.create(o,s,i)}else return null}static create(e,r,o){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(o.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(r!==F)throw new Error(`Version 0 CID must use dag-pb (code: ${F}) block encoding`);return new t(e,r,o,o.bytes)}case 1:{let n=Ne(e,r,o.bytes);return new t(e,r,o,n)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,F,e)}static createV1(e,r){return t.create(1,e,r)}static decode(e){let[r,o]=t.decodeFirst(e);if(o.length)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=t.inspectBytes(e),o=r.size-r.multihashSize,n=C(e.subarray(o,o+r.multihashSize));if(n.byteLength!==r.multihashSize)throw new Error("Incorrect length");let s=n.subarray(r.multihashSize-r.digestSize),i=new N(r.multihashCode,r.digestSize,s,n);return[r.version===0?t.createV0(i):t.createV1(r.codec,i),e.subarray(r.size)]}static inspectBytes(e){let r=0,o=()=>{let[B,k]=P(e.subarray(r));return r+=k,B},n=o(),s=F;if(n===18?(n=0,r=0):s=o(),n!==0&&n!==1)throw new RangeError(`Invalid CID version ${n}`);let i=r,c=o(),h=o(),T=r+h,u=T-i;return{version:n,codec:s,multihashCode:c,digestSize:h,multihashSize:u,size:T}}static parse(e,r){let[o,n]=Ht(e,r),s=t.decode(n);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return pe(s).set(o,e),s}},Ht=(t,e)=>{switch(t[0]){case"Q":{let r=e||y;return[y.prefix,r.decode(`${y.prefix}${t}`)]}case y.prefix:{let r=e||y;return[y.prefix,r.decode(t)]}case L.prefix:{let r=e||L;return[L.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}},Wt=(t,e,r)=>{let{prefix:o}=r;if(o!==y.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let n=e.get(o);if(n==null){let s=r.encode(t).slice(1);return e.set(o,s),s}else return n},Zt=(t,e,r)=>{let{prefix:o}=r,n=e.get(o);if(n==null){let s=r.encode(t);return e.set(o,s),s}else return n},F=112,Yt=18,Ne=(t,e,r)=>{let o=M(t),n=o+M(e),s=new Uint8Array(n+r.byteLength);return O(t,s,0),O(e,s,o),s.set(r,n),s},_t=Symbol.for("@ipld/js-cid/CID");var de={...se,...Y,...ne,...W,...Z,...ee,...te,...re,...oe,..._},Jr={...he,...ae};function Pe(t,e,r,o){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:o}}}var Ve=Pe("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),ue=Pe("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);let e=I(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),er={utf8:Ve,"utf-8":Ve,hex:de.base16,latin1:ue,ascii:ue,binary:ue,...de},J=er;function $e(t,e="utf8"){let r=J[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?A(globalThis.Buffer.from(t,"utf-8")):r.decoder.decode(`${r.prefix}${t}`)}function Fe(t,e="utf8"){let r=J[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):r.encoder.encode(t).substring(1)}function ke(t,e){if(t.length!==e.length)throw new Error("Inputs should have the same length");let r=I(t.length);for(let o=0;o<t.length;o++)r[o]=t[o]^e[o];return A(r)}return Qe(tr);})();
return Uint8Arrays}));
/**
* Returns a new Uint8Array created by concatenating the passed ArrayLikes
* Returns a new Uint8Array created by concatenating the passed Uint8Arrays
*/
export declare function concat(arrays: Array<ArrayLike<number>>, length?: number): Uint8Array;
export declare function concat(arrays: Uint8Array[], length?: number): Uint8Array;
//# sourceMappingURL=concat.d.ts.map
import { allocUnsafe } from './alloc.js';
import { asUint8Array } from './util/as-uint8array.js';
/**
* Returns a new Uint8Array created by concatenating the passed ArrayLikes
* Returns a new Uint8Array created by concatenating the passed Uint8Arrays
*/
export function concat(arrays, length) {
if (globalThis.Buffer != null) {
return asUint8Array(globalThis.Buffer.concat(arrays, length));
}
if (length == null) {

@@ -8,0 +11,0 @@ length = arrays.reduce((acc, curr) => acc + curr.length, 0);

{
"name": "uint8arrays",
"version": "4.0.10",
"version": "5.0.0",
"description": "Utility functions to make dealing with Uint8Arrays easier",

@@ -15,2 +15,6 @@ "author": "Alex Potsides <alex@achingbrain.net>",

},
"publishConfig": {
"access": "public",
"provenance": true
},
"type": "module",

@@ -17,0 +21,0 @@ "types": "./dist/src/index.d.ts",

@@ -5,5 +5,9 @@ import { allocUnsafe } from './alloc.js'

/**
* Returns a new Uint8Array created by concatenating the passed ArrayLikes
* Returns a new Uint8Array created by concatenating the passed Uint8Arrays
*/
export function concat (arrays: Array<ArrayLike<number>>, length?: number): Uint8Array {
export function concat (arrays: Uint8Array[], length?: number): Uint8Array {
if (globalThis.Buffer != null) {
return asUint8Array(globalThis.Buffer.concat(arrays, length))
}
if (length == null) {

@@ -10,0 +14,0 @@ length = arrays.reduce((acc, curr) => acc + curr.length, 0)

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc