Socket
Socket
Sign inDemoInstall

multiformats

Package Overview
Dependencies
0
Maintainers
2
Versions
147
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 12.1.3 to 13.0.0

dist/src/bases/base.d.ts

2

dist/index.min.js
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Multiformats = factory()}(typeof self !== 'undefined' ? self : this, function () {
"use strict";var Multiformats=(()=>{var R=Object.defineProperty;var fe=Object.getOwnPropertyDescriptor;var pe=Object.getOwnPropertyNames;var le=Object.prototype.hasOwnProperty;var N=(r,e)=>{for(var t in e)R(r,t,{get:e[t],enumerable:!0})},ue=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of pe(e))!le.call(r,o)&&o!==t&&R(r,o,{get:()=>e[o],enumerable:!(n=fe(e,o))||n.enumerable});return r};var we=r=>ue(R({},"__esModule",{value:!0}),r);var Ze={};N(Ze,{CID:()=>F,bytes:()=>P,digest:()=>T,hasher:()=>_,varint:()=>L});var P={};N(P,{coerce:()=>S,empty:()=>ee,equals:()=>J,fromHex:()=>ge,fromString:()=>ye,isBinary:()=>me,toHex:()=>be,toString:()=>xe});var ee=new Uint8Array(0),be=r=>r.reduce((e,t)=>e+t.toString(16).padStart(2,"0"),""),ge=r=>{let e=r.match(/../g);return e?new Uint8Array(e.map(t=>parseInt(t,16))):ee},J=(r,e)=>{if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0},S=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")},me=r=>r instanceof ArrayBuffer||ArrayBuffer.isView(r),ye=r=>new TextEncoder().encode(r),xe=r=>new TextDecoder().decode(r);function ve(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),i=s.charCodeAt(0);if(t[i]!==255)throw new TypeError(s+" is ambiguous");t[i]=o}var c=r.length,h=r.charAt(0),D=Math.log(c)/Math.log(256),f=Math.log(256)/Math.log(c);function z(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 d=0,A=0,l=0,w=a.length;l!==w&&a[l]===0;)l++,d++;for(var b=(w-l)*f+1>>>0,p=new Uint8Array(b);l!==w;){for(var g=a[l],v=0,u=b-1;(g!==0||v<A)&&u!==-1;u--,v++)g+=256*p[u]>>>0,p[u]=g%c>>>0,g=g/c>>>0;if(g!==0)throw new Error("Non-zero carry");A=v,l++}for(var y=b-A;y!==b&&p[y]===0;)y++;for(var k=h.repeat(d);y<b;++y)k+=r.charAt(p[y]);return k}function $(a){if(typeof a!="string")throw new TypeError("Expected String");if(a.length===0)return new Uint8Array;var d=0;if(a[d]!==" "){for(var A=0,l=0;a[d]===h;)A++,d++;for(var w=(a.length-d)*D+1>>>0,b=new Uint8Array(w);a[d];){var p=t[a.charCodeAt(d)];if(p===255)return;for(var g=0,v=w-1;(p!==0||g<l)&&v!==-1;v--,g++)p+=c*b[v]>>>0,b[v]=p%256>>>0,p=p/256>>>0;if(p!==0)throw new Error("Non-zero carry");l=g,d++}if(a[d]!==" "){for(var u=w-l;u!==w&&b[u]===0;)u++;for(var y=new Uint8Array(A+(w-u)),k=A;u!==w;)y[k++]=b[u++];return y}}}function de(a){var d=$(a);if(d)return d;throw new Error(`Non-${e} character`)}return{encode:z,decodeUnsafe:$,decode:de}}var Ae=ve,Se=Ae,te=Se;var j=class{constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},Q=class{constructor(e,t,n){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=n}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 re(this,e)}},G=class{constructor(e){this.decoders=e}or(e){return re(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},re=(r,e)=>new G({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),X=class{constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new j(e,t,n),this.decoder=new Q(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},ne=({name:r,prefix:e,encode:t,decode:n})=>new X(r,e,t,n),K=({prefix:r,name:e,alphabet:t})=>{let{encode:n,decode:o}=te(t,e);return ne({prefix:r,name:e,encode:n,decode:s=>S(o(s))})},Ee=(r,e,t,n)=>{let o={};for(let f=0;f<e.length;++f)o[e[f]]=f;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*t/8|0),c=0,h=0,D=0;for(let f=0;f<s;++f){let z=o[r[f]];if(z===void 0)throw new SyntaxError(`Non-${n} character`);h=h<<t|z,c+=t,c>=8&&(c-=8,i[D++]=255&h>>c)}if(c>=t||255&h<<8-c)throw new SyntaxError("Unexpected end of data");return i},Ce=(r,e,t)=>{let n=e[e.length-1]==="=",o=(1<<t)-1,s="",i=0,c=0;for(let h=0;h<r.length;++h)for(c=c<<8|r[h],i+=8;i>t;)i-=t,s+=e[o&c>>i];if(i&&(s+=e[o&c<<t-i]),n)for(;s.length*t&7;)s+="=";return s},m=({name:r,prefix:e,bitsPerChar:t,alphabet:n})=>ne({prefix:e,name:r,encode(o){return Ce(o,n,t)},decode(o){return Ee(o,n,t,r)}});var O=m({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),nt=m({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),ot=m({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),st=m({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),it=m({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),at=m({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),ct=m({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),ht=m({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),dt=m({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var x=K({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),lt=K({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var T={};N(T,{Digest:()=>U,create:()=>M,decode:()=>Z,equals:()=>Y});var L={};N(L,{decode:()=>I,encodeTo:()=>E,encodingLength:()=>C});var Ue=ie,oe=128,De=127,ze=~De,Ie=Math.pow(2,31);function ie(r,e,t){e=e||[],t=t||0;for(var n=t;r>=Ie;)e[t++]=r&255|oe,r/=128;for(;r&ze;)e[t++]=r&255|oe,r>>>=7;return e[t]=r|0,ie.bytes=t-n+1,e}var Me=W,Ne=128,se=127;function W(r,n){var t=0,n=n||0,o=0,s=n,i,c=r.length;do{if(s>=c)throw W.bytes=0,new RangeError("Could not decode varint");i=r[s++],t+=o<28?(i&se)<<o:(i&se)*Math.pow(2,o),o+=7}while(i>=Ne);return W.bytes=s-n,t}var Oe=Math.pow(2,7),Ve=Math.pow(2,14),Le=Math.pow(2,21),Te=Math.pow(2,28),Be=Math.pow(2,35),$e=Math.pow(2,42),ke=Math.pow(2,49),Fe=Math.pow(2,56),qe=Math.pow(2,63),Re=function(r){return r<Oe?1:r<Ve?2:r<Le?3:r<Te?4:r<Be?5:r<$e?6:r<ke?7:r<Fe?8:r<qe?9:10},Je={encode:Ue,decode:Me,encodingLength:Re},Pe=Je,V=Pe;var I=(r,e=0)=>[V.decode(r,e),V.decode.bytes],E=(r,e,t=0)=>(V.encode(r,e,t),e),C=r=>V.encodingLength(r);var M=(r,e)=>{let t=e.byteLength,n=C(r),o=n+C(t),s=new Uint8Array(o+t);return E(r,s,0),E(t,s,n),s.set(e,o),new U(r,t,e,s)},Z=r=>{let e=S(r),[t,n]=I(e),[o,s]=I(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new U(t,o,i,e)},Y=(r,e)=>{if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&J(r.bytes,t.bytes)}},U=class{constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};var ae=(r,e)=>{let{bytes:t,version:n}=r;switch(n){case 0:return Qe(t,H(r),e||x.encoder);default:return Ge(t,H(r),e||O.encoder)}};var ce=new WeakMap,H=r=>{let e=ce.get(r);if(e==null){let t=new Map;return ce.set(r,t),t}return e},F=class r{constructor(e,t,n,o){this.code=t,this.version=e,this.multihash=n,this.bytes=o,this["/"]=o}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:t}=this;if(e!==B)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==Xe)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(t)}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:t}=this.multihash,n=M(e,t);return r.createV1(this.code,n)}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 r.equals(this,e)}static equals(e,t){let n=t;return n&&e.code===n.code&&e.version===n.version&&Y(e.multihash,n.multihash)}toString(e){return ae(this,e)}toJSON(){return{"/":ae(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 t=e;if(t instanceof r)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:o,multihash:s,bytes:i}=t;return new r(n,o,s,i||he(n,o,s.bytes))}else if(t[Ke]===!0){let{version:n,multihash:o,code:s}=t,i=Z(o);return r.create(n,s,i)}else return null}static create(e,t,n){if(typeof t!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(t!==B)throw new Error(`Version 0 CID must use dag-pb (code: ${B}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let o=he(e,t,n.bytes);return new r(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,B,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,n]=r.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),n=t.size-t.multihashSize,o=S(e.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=o.subarray(t.multihashSize-t.digestSize),i=new U(t.multihashCode,t.digestSize,s,o);return[t.version===0?r.createV0(i):r.createV1(t.codec,i),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[z,$]=I(e.subarray(t));return t+=$,z},o=n(),s=B;if(o===18?(o=0,t=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=t,c=n(),h=n(),D=t+h,f=D-i;return{version:o,codec:s,multihashCode:c,digestSize:h,multihashSize:f,size:D}}static parse(e,t){let[n,o]=je(e,t),s=r.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return H(s).set(n,e),s}},je=(r,e)=>{switch(r[0]){case"Q":{let t=e||x;return[x.prefix,t.decode(`${x.prefix}${r}`)]}case x.prefix:{let t=e||x;return[x.prefix,t.decode(r)]}case O.prefix:{let t=e||O;return[O.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}},Qe=(r,e,t)=>{let{prefix:n}=t;if(n!==x.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(n);if(o==null){let s=t.encode(r).slice(1);return e.set(n,s),s}else return o},Ge=(r,e,t)=>{let{prefix:n}=t,o=e.get(n);if(o==null){let s=t.encode(r);return e.set(n,s),s}else return o},B=112,Xe=18,he=(r,e,t)=>{let n=C(r),o=n+C(e),s=new Uint8Array(o+t.byteLength);return E(r,s,0),E(e,s,n),s.set(t,o),s},Ke=Symbol.for("@ipld/js-cid/CID");var _={};N(_,{Hasher:()=>q,from:()=>We});var We=({name:r,code:e,encode:t})=>new q(r,e,t),q=class{constructor(e,t,n){this.name=e,this.code=t,this.encode=n}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?M(this.code,t):t.then(n=>M(this.code,n))}else throw Error("Unknown type, must be binary type")}};return we(Ze);})();
"use strict";var Multiformats=(()=>{var R=Object.defineProperty;var he=Object.getOwnPropertyDescriptor;var pe=Object.getOwnPropertyNames;var ue=Object.prototype.hasOwnProperty;var N=(r,e)=>{for(var t in e)R(r,t,{get:e[t],enumerable:!0})},le=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of pe(e))!ue.call(r,o)&&o!==t&&R(r,o,{get:()=>e[o],enumerable:!(n=he(e,o))||n.enumerable});return r};var be=r=>le(R({},"__esModule",{value:!0}),r);var Ze={};N(Ze,{CID:()=>F,bytes:()=>P,digest:()=>T,hasher:()=>_,varint:()=>L});var P={};N(P,{coerce:()=>S,empty:()=>ee,equals:()=>J,fromHex:()=>xe,fromString:()=>me,isBinary:()=>ge,toHex:()=>we,toString:()=>ye});var ee=new Uint8Array(0);function we(r){return r.reduce((e,t)=>e+t.toString(16).padStart(2,"0"),"")}function xe(r){let e=r.match(/../g);return e!=null?new Uint8Array(e.map(t=>parseInt(t,16))):ee}function J(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function S(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}function ge(r){return r instanceof ArrayBuffer||ArrayBuffer.isView(r)}function me(r){return new TextEncoder().encode(r)}function ye(r){return new TextDecoder().decode(r)}function ve(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var o=0;o<r.length;o++){var i=r.charAt(o),s=i.charCodeAt(0);if(t[s]!==255)throw new TypeError(i+" is ambiguous");t[s]=o}var c=r.length,d=r.charAt(0),U=Math.log(c)/Math.log(256),h=Math.log(256)/Math.log(c);function z(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 f=0,E=0,u=0,b=a.length;u!==b&&a[u]===0;)u++,f++;for(var w=(b-u)*h+1>>>0,p=new Uint8Array(w);u!==b;){for(var x=a[u],v=0,l=w-1;(x!==0||v<E)&&l!==-1;l--,v++)x+=256*p[l]>>>0,p[l]=x%c>>>0,x=x/c>>>0;if(x!==0)throw new Error("Non-zero carry");E=v,u++}for(var m=w-E;m!==w&&p[m]===0;)m++;for(var k=d.repeat(f);m<w;++m)k+=r.charAt(p[m]);return k}function $(a){if(typeof a!="string")throw new TypeError("Expected String");if(a.length===0)return new Uint8Array;var f=0;if(a[f]!==" "){for(var E=0,u=0;a[f]===d;)E++,f++;for(var b=(a.length-f)*U+1>>>0,w=new Uint8Array(b);a[f];){var p=t[a.charCodeAt(f)];if(p===255)return;for(var x=0,v=b-1;(p!==0||x<u)&&v!==-1;v--,x++)p+=c*w[v]>>>0,w[v]=p%256>>>0,p=p/256>>>0;if(p!==0)throw new Error("Non-zero carry");u=x,f++}if(a[f]!==" "){for(var l=b-u;l!==b&&w[l]===0;)l++;for(var m=new Uint8Array(E+(b-l)),k=E;l!==b;)m[k++]=w[l++];return m}}}function fe(a){var f=$(a);if(f)return f;throw new Error(`Non-${e} character`)}return{encode:z,decodeUnsafe:$,decode:fe}}var Ee=ve,Se=Ee,te=Se;var j=class{name;prefix;baseEncode;constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},Q=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,n){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=n}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 re(this,e)}},G=class{decoders;constructor(e){this.decoders=e}or(e){return re(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function re(r,e){return new G({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var X=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new j(e,t,n),this.decoder=new Q(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function ne({name:r,prefix:e,encode:t,decode:n}){return new X(r,e,t,n)}function K({name:r,prefix:e,alphabet:t}){let{encode:n,decode:o}=te(t,r);return ne({prefix:e,name:r,encode:n,decode:i=>S(o(i))})}function Ae(r,e,t,n){let o={};for(let h=0;h<e.length;++h)o[e[h]]=h;let i=r.length;for(;r[i-1]==="=";)--i;let s=new Uint8Array(i*t/8|0),c=0,d=0,U=0;for(let h=0;h<i;++h){let z=o[r[h]];if(z===void 0)throw new SyntaxError(`Non-${n} character`);d=d<<t|z,c+=t,c>=8&&(c-=8,s[U++]=255&d>>c)}if(c>=t||255&d<<8-c)throw new SyntaxError("Unexpected end of data");return s}function Ce(r,e,t){let n=e[e.length-1]==="=",o=(1<<t)-1,i="",s=0,c=0;for(let d=0;d<r.length;++d)for(c=c<<8|r[d],s+=8;s>t;)s-=t,i+=e[o&c>>s];if(s!==0&&(i+=e[o&c<<t-s]),n)for(;i.length*t&7;)i+="=";return i}function g({name:r,prefix:e,bitsPerChar:t,alphabet:n}){return ne({prefix:e,name:r,encode(o){return Ce(o,n,t)},decode(o){return Ae(o,n,t,r)}})}var O=g({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),nt=g({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),ot=g({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),it=g({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),st=g({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),at=g({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),ct=g({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),dt=g({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),ft=g({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var y=K({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),ut=K({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var T={};N(T,{Digest:()=>D,create:()=>M,decode:()=>Z,equals:()=>Y});var L={};N(L,{decode:()=>I,encodeTo:()=>A,encodingLength:()=>C});var De=se,oe=128,Ue=127,ze=~Ue,Ie=Math.pow(2,31);function se(r,e,t){e=e||[],t=t||0;for(var n=t;r>=Ie;)e[t++]=r&255|oe,r/=128;for(;r&ze;)e[t++]=r&255|oe,r>>>=7;return e[t]=r|0,se.bytes=t-n+1,e}var Me=W,Ne=128,ie=127;function W(r,n){var t=0,n=n||0,o=0,i=n,s,c=r.length;do{if(i>=c)throw W.bytes=0,new RangeError("Could not decode varint");s=r[i++],t+=o<28?(s&ie)<<o:(s&ie)*Math.pow(2,o),o+=7}while(s>=Ne);return W.bytes=i-n,t}var Oe=Math.pow(2,7),Ve=Math.pow(2,14),Le=Math.pow(2,21),Te=Math.pow(2,28),Be=Math.pow(2,35),$e=Math.pow(2,42),ke=Math.pow(2,49),Fe=Math.pow(2,56),qe=Math.pow(2,63),Re=function(r){return r<Oe?1:r<Ve?2:r<Le?3:r<Te?4:r<Be?5:r<$e?6:r<ke?7:r<Fe?8:r<qe?9:10},Je={encode:De,decode:Me,encodingLength:Re},Pe=Je,V=Pe;function I(r,e=0){return[V.decode(r,e),V.decode.bytes]}function A(r,e,t=0){return V.encode(r,e,t),e}function C(r){return V.encodingLength(r)}function M(r,e){let t=e.byteLength,n=C(r),o=n+C(t),i=new Uint8Array(o+t);return A(r,i,0),A(t,i,n),i.set(e,o),new D(r,t,e,i)}function Z(r){let e=S(r),[t,n]=I(e),[o,i]=I(e.subarray(n)),s=e.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new D(t,o,s,e)}function Y(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&J(r.bytes,t.bytes)}}var D=class{code;size;digest;bytes;constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};function ae(r,e){let{bytes:t,version:n}=r;switch(n){case 0:return Qe(t,H(r),e??y.encoder);default:return Ge(t,H(r),e??O.encoder)}}var ce=new WeakMap;function H(r){let e=ce.get(r);if(e==null){let t=new Map;return ce.set(r,t),t}return e}var F=class r{code;version;multihash;bytes;"/";constructor(e,t,n,o){this.code=t,this.version=e,this.multihash=n,this.bytes=o,this["/"]=o}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:t}=this;if(e!==B)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==Xe)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(t)}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:t}=this.multihash,n=M(e,t);return r.createV1(this.code,n)}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 r.equals(this,e)}static equals(e,t){let n=t;return n!=null&&e.code===n.code&&e.version===n.version&&Y(e.multihash,n.multihash)}toString(e){return ae(this,e)}toJSON(){return{"/":ae(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let t=e;if(t instanceof r)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:o,multihash:i,bytes:s}=t;return new r(n,o,i,s??de(n,o,i.bytes))}else if(t[Ke]===!0){let{version:n,multihash:o,code:i}=t,s=Z(o);return r.create(n,i,s)}else return null}static create(e,t,n){if(typeof t!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(t!==B)throw new Error(`Version 0 CID must use dag-pb (code: ${B}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let o=de(e,t,n.bytes);return new r(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,B,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,n]=r.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),n=t.size-t.multihashSize,o=S(e.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let i=o.subarray(t.multihashSize-t.digestSize),s=new D(t.multihashCode,t.digestSize,i,o);return[t.version===0?r.createV0(s):r.createV1(t.codec,s),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[z,$]=I(e.subarray(t));return t+=$,z},o=n(),i=B;if(o===18?(o=0,t=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=t,c=n(),d=n(),U=t+d,h=U-s;return{version:o,codec:i,multihashCode:c,digestSize:d,multihashSize:h,size:U}}static parse(e,t){let[n,o]=je(e,t),i=r.decode(o);if(i.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return H(i).set(n,e),i}};function je(r,e){switch(r[0]){case"Q":{let t=e??y;return[y.prefix,t.decode(`${y.prefix}${r}`)]}case y.prefix:{let t=e??y;return[y.prefix,t.decode(r)]}case O.prefix:{let t=e??O;return[O.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}}function Qe(r,e,t){let{prefix:n}=t;if(n!==y.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(n);if(o==null){let i=t.encode(r).slice(1);return e.set(n,i),i}else return o}function Ge(r,e,t){let{prefix:n}=t,o=e.get(n);if(o==null){let i=t.encode(r);return e.set(n,i),i}else return o}var B=112,Xe=18;function de(r,e,t){let n=C(r),o=n+C(e),i=new Uint8Array(o+t.byteLength);return A(r,i,0),A(e,i,n),i.set(t,o),i}var Ke=Symbol.for("@ipld/js-cid/CID");var _={};N(_,{Hasher:()=>q,from:()=>We});function We({name:r,code:e,encode:t}){return new q(r,e,t)}var q=class{name;code;encode;constructor(e,t,n){this.name=e,this.code=t,this.encode=n}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?M(this.code,t):t.then(n=>M(this.code,n))}else throw Error("Unknown type, must be binary type")}};return be(Ze);})();
return Multiformats}));

@@ -50,2 +50,20 @@ {

"./bases/identity:identity": "https://multiformats.github.io/js-multiformats/variables/bases_identity.identity.html",
"BaseCodec": "https://multiformats.github.io/js-multiformats/interfaces/bases_interface.BaseCodec.html",
"./bases/interface:BaseCodec": "https://multiformats.github.io/js-multiformats/interfaces/bases_interface.BaseCodec.html",
"BaseDecoder": "https://multiformats.github.io/js-multiformats/interfaces/bases_interface.BaseDecoder.html",
"./bases/interface:BaseDecoder": "https://multiformats.github.io/js-multiformats/interfaces/bases_interface.BaseDecoder.html",
"BaseEncoder": "https://multiformats.github.io/js-multiformats/interfaces/bases_interface.BaseEncoder.html",
"./bases/interface:BaseEncoder": "https://multiformats.github.io/js-multiformats/interfaces/bases_interface.BaseEncoder.html",
"CombobaseDecoder": "https://multiformats.github.io/js-multiformats/interfaces/bases_interface.CombobaseDecoder.html",
"./bases/interface:CombobaseDecoder": "https://multiformats.github.io/js-multiformats/interfaces/bases_interface.CombobaseDecoder.html",
"MultibaseCodec": "https://multiformats.github.io/js-multiformats/interfaces/bases_interface.MultibaseCodec.html",
"./bases/interface:MultibaseCodec": "https://multiformats.github.io/js-multiformats/interfaces/bases_interface.MultibaseCodec.html",
"MultibaseDecoder": "https://multiformats.github.io/js-multiformats/interfaces/bases_interface.MultibaseDecoder.html",
"./bases/interface:MultibaseDecoder": "https://multiformats.github.io/js-multiformats/interfaces/bases_interface.MultibaseDecoder.html",
"MultibaseEncoder": "https://multiformats.github.io/js-multiformats/interfaces/bases_interface.MultibaseEncoder.html",
"./bases/interface:MultibaseEncoder": "https://multiformats.github.io/js-multiformats/interfaces/bases_interface.MultibaseEncoder.html",
"UnibaseDecoder": "https://multiformats.github.io/js-multiformats/interfaces/bases_interface.UnibaseDecoder.html",
"./bases/interface:UnibaseDecoder": "https://multiformats.github.io/js-multiformats/interfaces/bases_interface.UnibaseDecoder.html",
"Multibase": "https://multiformats.github.io/js-multiformats/types/bases_interface.Multibase.html",
"./bases/interface:Multibase": "https://multiformats.github.io/js-multiformats/types/bases_interface.Multibase.html",
"bases": "https://multiformats.github.io/js-multiformats/variables/basics.bases.html",

@@ -59,4 +77,2 @@ "./basics:bases": "https://multiformats.github.io/js-multiformats/variables/basics.bases.html",

"./block:Block": "https://multiformats.github.io/js-multiformats/classes/block.Block.html",
"RequiredCreateOptions": "https://multiformats.github.io/js-multiformats/interfaces/block.RequiredCreateOptions.html",
"./block:RequiredCreateOptions": "https://multiformats.github.io/js-multiformats/interfaces/block.RequiredCreateOptions.html",
"create": "https://multiformats.github.io/js-multiformats/functions/block.create.html",

@@ -70,2 +86,11 @@ "./block:create": "https://multiformats.github.io/js-multiformats/functions/block.create.html",

"./block:encode": "https://multiformats.github.io/js-multiformats/functions/block.encode.html",
"./block/interface:Block": "https://multiformats.github.io/js-multiformats/interfaces/block_interface.Block.html",
"BlockView": "https://multiformats.github.io/js-multiformats/interfaces/block_interface.BlockView.html",
"./block/interface:BlockView": "https://multiformats.github.io/js-multiformats/interfaces/block_interface.BlockView.html",
"ByteView": "https://multiformats.github.io/js-multiformats/interfaces/block_interface.ByteView.html",
"./block/interface:ByteView": "https://multiformats.github.io/js-multiformats/interfaces/block_interface.ByteView.html",
"Phantom": "https://multiformats.github.io/js-multiformats/interfaces/block_interface.Phantom.html",
"./block/interface:Phantom": "https://multiformats.github.io/js-multiformats/interfaces/block_interface.Phantom.html",
"BlockCursorView": "https://multiformats.github.io/js-multiformats/types/block_interface.BlockCursorView.html",
"./block/interface:BlockCursorView": "https://multiformats.github.io/js-multiformats/types/block_interface.BlockCursorView.html",
"empty": "https://multiformats.github.io/js-multiformats/variables/bytes.empty.html",

@@ -94,4 +119,8 @@ "./bytes:empty": "https://multiformats.github.io/js-multiformats/variables/bytes.empty.html",

"./cid:toJSON": "https://multiformats.github.io/js-multiformats/functions/cid.toJSON.html",
"ByteView": "https://multiformats.github.io/js-multiformats/types/codecs_json.ByteView.html",
"./codecs/json:ByteView": "https://multiformats.github.io/js-multiformats/types/codecs_json.ByteView.html",
"BlockCodec": "https://multiformats.github.io/js-multiformats/interfaces/codecs_interface.BlockCodec.html",
"./codecs/interface:BlockCodec": "https://multiformats.github.io/js-multiformats/interfaces/codecs_interface.BlockCodec.html",
"BlockDecoder": "https://multiformats.github.io/js-multiformats/interfaces/codecs_interface.BlockDecoder.html",
"./codecs/interface:BlockDecoder": "https://multiformats.github.io/js-multiformats/interfaces/codecs_interface.BlockDecoder.html",
"BlockEncoder": "https://multiformats.github.io/js-multiformats/interfaces/codecs_interface.BlockEncoder.html",
"./codecs/interface:BlockEncoder": "https://multiformats.github.io/js-multiformats/interfaces/codecs_interface.BlockEncoder.html",
"code": "https://multiformats.github.io/js-multiformats/variables/codecs_json.code.html",

@@ -103,3 +132,2 @@ "./codecs/json:code": "https://multiformats.github.io/js-multiformats/variables/codecs_json.code.html",

"./codecs/json:encode": "https://multiformats.github.io/js-multiformats/functions/codecs_json.encode.html",
"./codecs/raw:ByteView": "https://multiformats.github.io/js-multiformats/types/codecs_raw.ByteView.html",
"./codecs/raw:code": "https://multiformats.github.io/js-multiformats/variables/codecs_raw.code.html",

@@ -111,4 +139,2 @@ "./codecs/raw:name": "https://multiformats.github.io/js-multiformats/variables/codecs_raw.name.html",

"./hashes/digest:Digest": "https://multiformats.github.io/js-multiformats/classes/hashes_digest.Digest.html",
"MultihashDigest": "https://multiformats.github.io/js-multiformats/types/hashes_digest.MultihashDigest.html",
"./hashes/digest:MultihashDigest": "https://multiformats.github.io/js-multiformats/types/hashes_digest.MultihashDigest.html",
"./hashes/digest:create": "https://multiformats.github.io/js-multiformats/functions/hashes_digest.create.html",

@@ -119,8 +145,11 @@ "./hashes/digest:decode": "https://multiformats.github.io/js-multiformats/functions/hashes_digest.decode.html",

"./hashes/hasher:Hasher": "https://multiformats.github.io/js-multiformats/classes/hashes_hasher.Hasher.html",
"MultihashHasher": "https://multiformats.github.io/js-multiformats/interfaces/hashes_hasher.MultihashHasher.html",
"Await": "https://multiformats.github.io/js-multiformats/types/hashes_hasher.Await.html",
"./hashes/hasher:Await": "https://multiformats.github.io/js-multiformats/types/hashes_hasher.Await.html",
"from": "https://multiformats.github.io/js-multiformats/functions/hashes_hasher.from.html",
"./hashes/hasher:from": "https://multiformats.github.io/js-multiformats/functions/hashes_hasher.from.html",
"./hashes/identity:identity": "https://multiformats.github.io/js-multiformats/variables/hashes_identity.identity.html",
"MultihashDigest": "https://multiformats.github.io/js-multiformats/interfaces/hashes_interface.MultihashDigest.html",
"./hashes/interface:MultihashDigest": "https://multiformats.github.io/js-multiformats/interfaces/hashes_interface.MultihashDigest.html",
"MultihashHasher": "https://multiformats.github.io/js-multiformats/interfaces/hashes_interface.MultihashHasher.html",
"./hashes/interface:MultihashHasher": "https://multiformats.github.io/js-multiformats/interfaces/hashes_interface.MultihashHasher.html",
"SyncMultihashHasher": "https://multiformats.github.io/js-multiformats/interfaces/hashes_interface.SyncMultihashHasher.html",
"./hashes/interface:SyncMultihashHasher": "https://multiformats.github.io/js-multiformats/interfaces/hashes_interface.SyncMultihashHasher.html",
"sha1": "https://multiformats.github.io/js-multiformats/variables/hashes_sha1.sha1.html",

@@ -134,26 +163,2 @@ "./hashes/sha1:sha1": "https://multiformats.github.io/js-multiformats/variables/hashes_sha1.sha1.html",

"encodingLength": "https://multiformats.github.io/js-multiformats/functions/index.varint.encodingLength.html",
"BaseCodec": "https://multiformats.github.io/js-multiformats/interfaces/index.BaseCodec.html",
"BaseDecoder": "https://multiformats.github.io/js-multiformats/interfaces/index.BaseDecoder.html",
"BaseEncoder": "https://multiformats.github.io/js-multiformats/interfaces/index.BaseEncoder.html",
"BlockCodec": "https://multiformats.github.io/js-multiformats/interfaces/index.BlockCodec.html",
"BlockDecoder": "https://multiformats.github.io/js-multiformats/interfaces/index.BlockDecoder.html",
"BlockEncoder": "https://multiformats.github.io/js-multiformats/interfaces/index.BlockEncoder.html",
"BlockView": "https://multiformats.github.io/js-multiformats/interfaces/index.BlockView.html",
"CombobaseDecoder": "https://multiformats.github.io/js-multiformats/interfaces/index.CombobaseDecoder.html",
"LegacyLink": "https://multiformats.github.io/js-multiformats/interfaces/index.LegacyLink.html",
"Link": "https://multiformats.github.io/js-multiformats/interfaces/index.Link.html",
"LinkJSON": "https://multiformats.github.io/js-multiformats/interfaces/index.LinkJSON.html",
"MultibaseCodec": "https://multiformats.github.io/js-multiformats/interfaces/index.MultibaseCodec.html",
"MultibaseDecoder": "https://multiformats.github.io/js-multiformats/interfaces/index.MultibaseDecoder.html",
"MultibaseEncoder": "https://multiformats.github.io/js-multiformats/interfaces/index.MultibaseEncoder.html",
"Phantom": "https://multiformats.github.io/js-multiformats/interfaces/index.Phantom.html",
"SyncMultihashHasher": "https://multiformats.github.io/js-multiformats/interfaces/index.SyncMultihashHasher.html",
"UnibaseDecoder": "https://multiformats.github.io/js-multiformats/interfaces/index.UnibaseDecoder.html",
"BlockCursorView": "https://multiformats.github.io/js-multiformats/types/index.BlockCursorView.html",
"DAG_PB": "https://multiformats.github.io/js-multiformats/types/index.DAG_PB.html",
"Multibase": "https://multiformats.github.io/js-multiformats/types/index.Multibase.html",
"SHA_256": "https://multiformats.github.io/js-multiformats/types/index.SHA_256.html",
"ToString": "https://multiformats.github.io/js-multiformats/types/index.ToString.html",
"UnknownLink": "https://multiformats.github.io/js-multiformats/types/index.UnknownLink.html",
"Version": "https://multiformats.github.io/js-multiformats/types/index.Version.html",
"./link:create": "https://multiformats.github.io/js-multiformats/functions/link.create.html",

@@ -167,6 +172,20 @@ "createLegacy": "https://multiformats.github.io/js-multiformats/functions/link.createLegacy.html",

"./link:parse": "https://multiformats.github.io/js-multiformats/functions/link.parse.html",
"./traversal:BlockView": "https://multiformats.github.io/js-multiformats/types/traversal.BlockView.html",
"./traversal:CID": "https://multiformats.github.io/js-multiformats/types/traversal.CID.html",
"LegacyLink": "https://multiformats.github.io/js-multiformats/interfaces/link_interface.LegacyLink.html",
"./link/interface:LegacyLink": "https://multiformats.github.io/js-multiformats/interfaces/link_interface.LegacyLink.html",
"Link": "https://multiformats.github.io/js-multiformats/interfaces/link_interface.Link.html",
"./link/interface:Link": "https://multiformats.github.io/js-multiformats/interfaces/link_interface.Link.html",
"LinkJSON": "https://multiformats.github.io/js-multiformats/interfaces/link_interface.LinkJSON.html",
"./link/interface:LinkJSON": "https://multiformats.github.io/js-multiformats/interfaces/link_interface.LinkJSON.html",
"DAG_PB": "https://multiformats.github.io/js-multiformats/types/link_interface.DAG_PB.html",
"./link/interface:DAG_PB": "https://multiformats.github.io/js-multiformats/types/link_interface.DAG_PB.html",
"SHA_256": "https://multiformats.github.io/js-multiformats/types/link_interface.SHA_256.html",
"./link/interface:SHA_256": "https://multiformats.github.io/js-multiformats/types/link_interface.SHA_256.html",
"ToString": "https://multiformats.github.io/js-multiformats/types/link_interface.ToString.html",
"./link/interface:ToString": "https://multiformats.github.io/js-multiformats/types/link_interface.ToString.html",
"UnknownLink": "https://multiformats.github.io/js-multiformats/types/link_interface.UnknownLink.html",
"./link/interface:UnknownLink": "https://multiformats.github.io/js-multiformats/types/link_interface.UnknownLink.html",
"Version": "https://multiformats.github.io/js-multiformats/types/link_interface.Version.html",
"./link/interface:Version": "https://multiformats.github.io/js-multiformats/types/link_interface.Version.html",
"walk": "https://multiformats.github.io/js-multiformats/functions/traversal.walk.html",
"./traversal:walk": "https://multiformats.github.io/js-multiformats/functions/traversal.walk.html"
}
{
"name": "multiformats",
"version": "12.1.3",
"version": "13.0.0",
"description": "Interface for multihash, multicodec, multibase and CID",

@@ -20,8 +20,4 @@ "author": "Mikeal Rogers <mikeal.rogers@gmail.com> (https://www.mikealrogers.com/)",

],
"engines": {
"node": ">=16.0.0",
"npm": ">=7.0.0"
},
"type": "module",
"types": "./dist/types/src/index.d.ts",
"types": "./dist/src/index.d.ts",
"typesVersions": {

@@ -31,11 +27,11 @@ "*": {

"*",
"dist/types/*",
"dist/types/src/*",
"dist/types/src/*/index"
"dist/*",
"dist/src/*",
"dist/src/*/index"
],
"src/*": [
"*",
"dist/types/*",
"dist/types/src/*",
"dist/types/src/*/index"
"dist/*",
"dist/src/*",
"dist/src/*/index"
]

@@ -45,146 +41,135 @@ }

"files": [
"CHANGELOG.md",
"examples",
"LICENSE*",
"src",
"test",
"tsconfig.json",
"dist",
"vendor",
"!**/*.tsbuildinfo",
"!test/ts-use/node_modules"
"!dist/test",
"!**/*.tsbuildinfo"
],
"exports": {
".": {
"types": "./dist/types/src/index.d.ts",
"import": "./src/index.js"
"types": "./dist/src/index.d.ts",
"import": "./dist/src/index.js"
},
"./bases/base10": {
"types": "./dist/types/src/bases/base10.d.ts",
"import": "./src/bases/base10.js"
"types": "./dist/src/bases/base10.d.ts",
"import": "./dist/src/bases/base10.js"
},
"./bases/base16": {
"types": "./dist/types/src/bases/base16.d.ts",
"import": "./src/bases/base16.js"
"types": "./dist/src/bases/base16.d.ts",
"import": "./dist/src/bases/base16.js"
},
"./bases/base2": {
"types": "./dist/types/src/bases/base2.d.ts",
"import": "./src/bases/base2.js"
"types": "./dist/src/bases/base2.d.ts",
"import": "./dist/src/bases/base2.js"
},
"./bases/base256emoji": {
"types": "./dist/types/src/bases/base256emoji.d.ts",
"import": "./src/bases/base256emoji.js"
"types": "./dist/src/bases/base256emoji.d.ts",
"import": "./dist/src/bases/base256emoji.js"
},
"./bases/base32": {
"types": "./dist/types/src/bases/base32.d.ts",
"import": "./src/bases/base32.js"
"types": "./dist/src/bases/base32.d.ts",
"import": "./dist/src/bases/base32.js"
},
"./bases/base36": {
"types": "./dist/types/src/bases/base36.d.ts",
"import": "./src/bases/base36.js"
"types": "./dist/src/bases/base36.d.ts",
"import": "./dist/src/bases/base36.js"
},
"./bases/base58": {
"types": "./dist/types/src/bases/base58.d.ts",
"import": "./src/bases/base58.js"
"types": "./dist/src/bases/base58.d.ts",
"import": "./dist/src/bases/base58.js"
},
"./bases/base64": {
"types": "./dist/types/src/bases/base64.d.ts",
"import": "./src/bases/base64.js"
"types": "./dist/src/bases/base64.d.ts",
"import": "./dist/src/bases/base64.js"
},
"./bases/base8": {
"types": "./dist/types/src/bases/base8.d.ts",
"import": "./src/bases/base8.js"
"types": "./dist/src/bases/base8.d.ts",
"import": "./dist/src/bases/base8.js"
},
"./bases/identity": {
"types": "./dist/types/src/bases/identity.d.ts",
"import": "./src/bases/identity.js"
"types": "./dist/src/bases/identity.d.ts",
"import": "./dist/src/bases/identity.js"
},
"./bases/interface": {
"types": "./dist/types/src/bases/interface.d.ts",
"import": "./src/bases/interface.js"
"types": "./dist/src/bases/interface.d.ts",
"import": "./dist/src/bases/interface.js"
},
"./basics": {
"types": "./dist/types/src/basics.d.ts",
"import": "./src/basics.js"
"types": "./dist/src/basics.d.ts",
"import": "./dist/src/basics.js"
},
"./block": {
"types": "./dist/types/src/block.d.ts",
"import": "./src/block.js"
"types": "./dist/src/block.d.ts",
"import": "./dist/src/block.js"
},
"./block/interface": {
"types": "./dist/types/src/block/interface.d.ts",
"import": "./src/block/interface.js"
"types": "./dist/src/block/interface.d.ts",
"import": "./dist/src/block/interface.js"
},
"./bytes": {
"types": "./dist/types/src/bytes.d.ts",
"import": "./src/bytes.js"
"types": "./dist/src/bytes.d.ts",
"import": "./dist/src/bytes.js"
},
"./cid": {
"types": "./dist/types/src/cid.d.ts",
"import": "./src/cid.js"
"types": "./dist/src/cid.d.ts",
"import": "./dist/src/cid.js"
},
"./codecs/interface": {
"types": "./dist/types/src/codecs/interface.d.ts",
"import": "./src/codecs/interface.js"
"types": "./dist/src/codecs/interface.d.ts",
"import": "./dist/src/codecs/interface.js"
},
"./codecs/json": {
"types": "./dist/types/src/codecs/json.d.ts",
"import": "./src/codecs/json.js"
"types": "./dist/src/codecs/json.d.ts",
"import": "./dist/src/codecs/json.js"
},
"./codecs/raw": {
"types": "./dist/types/src/codecs/raw.d.ts",
"import": "./src/codecs/raw.js"
"types": "./dist/src/codecs/raw.d.ts",
"import": "./dist/src/codecs/raw.js"
},
"./hashes/digest": {
"types": "./dist/types/src/hashes/digest.d.ts",
"import": "./src/hashes/digest.js"
"types": "./dist/src/hashes/digest.d.ts",
"import": "./dist/src/hashes/digest.js"
},
"./hashes/hasher": {
"types": "./dist/types/src/hashes/hasher.d.ts",
"import": "./src/hashes/hasher.js"
"types": "./dist/src/hashes/hasher.d.ts",
"import": "./dist/src/hashes/hasher.js"
},
"./hashes/identity": {
"types": "./dist/types/src/hashes/identity.d.ts",
"import": "./src/hashes/identity.js"
"types": "./dist/src/hashes/identity.d.ts",
"import": "./dist/src/hashes/identity.js"
},
"./hashes/interface": {
"types": "./dist/types/src/hashes/interface.d.ts",
"import": "./src/hashes/interface.js"
"types": "./dist/src/hashes/interface.d.ts",
"import": "./dist/src/hashes/interface.js"
},
"./hashes/sha1": {
"types": "./dist/types/src/hashes/sha1.d.ts",
"browser": "./src/hashes/sha1-browser.js",
"import": "./src/hashes/sha1.js"
"browser": "./dist/src/hashes/sha1-browser.js",
"import": "./dist/src/hashes/sha1.js"
},
"./hashes/sha2": {
"types": "./dist/types/src/hashes/sha2.d.ts",
"browser": "./src/hashes/sha2-browser.js",
"import": "./src/hashes/sha2.js"
"types": "./dist/src/hashes/sha2.d.ts",
"browser": "./dist/src/hashes/sha2-browser.js",
"import": "./dist/src/hashes/sha2.js"
},
"./interface": {
"types": "./dist/types/src/interface.d.ts",
"import": "./src/interface.js"
"types": "./dist/src/interface.d.ts",
"import": "./dist/src/interface.js"
},
"./link": {
"types": "./dist/types/src/link.d.ts",
"import": "./src/link.js"
"types": "./dist/src/link.d.ts",
"import": "./dist/src/link.js"
},
"./link/interface": {
"types": "./dist/types/src/link/interface.d.ts",
"import": "./src/link/interface.js"
"types": "./dist/src/link/interface.d.ts",
"import": "./dist/src/link/interface.js"
},
"./traversal": {
"types": "./dist/types/src/traversal.d.ts",
"import": "./src/traversal.js"
"types": "./dist/src/traversal.d.ts",
"import": "./dist/src/traversal.js"
}
},
"browser": {
"./hashes/sha1": "./src/hashes/sha1-browser.js",
"./src/hashes/sha1.js": "./src/hashes/sha1-browser.js",
"./hashes/sha2": "./src/hashes/sha2-browser.js",
"./src/hashes/sha2.js": "./src/hashes/sha2-browser.js"
},
"eslintConfig": {
"extends": "ipfs",
"parserOptions": {
"project": true,
"sourceType": "module"

@@ -284,4 +269,3 @@ }

"docs": "aegir docs",
"test": "npm run lint && npm run test:node && npm run test:chrome && npm run test:ts",
"test:ts": "npm run test --prefix test/ts-use",
"test": "npm run lint && npm run test:node && npm run test:chrome",
"test:node": "aegir test -t node --cov",

@@ -310,3 +294,9 @@ "test:chrome": "aegir test -t browser --cov",

}
},
"browser": {
"./hashes/sha1": "./dist/src/hashes/sha1-browser.js",
"./dist/src/hashes/sha1.js": "./dist/src/hashes/sha1-browser.js",
"./hashes/sha2": "./dist/src/hashes/sha2-browser.js",
"./dist/src/hashes/sha2.js": "./dist/src/hashes/sha2-browser.js"
}
}

@@ -1,3 +0,1 @@

# multiformats <!-- omit in toc -->
[![multiformats.io](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://multiformats.io)

@@ -9,37 +7,4 @@ [![codecov](https://img.shields.io/codecov/c/github/multiformats/js-multiformats.svg?style=flat-square)](https://codecov.io/gh/multiformats/js-multiformats)

## Table of contents <!-- omit in toc -->
# About
- [Install](#install)
- [Browser `<script>` tag](#browser-script-tag)
- [Interfaces](#interfaces)
- [Creating Blocks](#creating-blocks)
- [Multibase Encoders / Decoders / Codecs](#multibase-encoders--decoders--codecs)
- [Multicodec Encoders / Decoders / Codecs](#multicodec-encoders--decoders--codecs)
- [Multihash Hashers](#multihash-hashers)
- [Traversal](#traversal)
- [Legacy interface](#legacy-interface)
- [Implementations](#implementations)
- [Multibase codecs](#multibase-codecs)
- [Multihash hashers](#multihash-hashers-1)
- [IPLD codecs (multicodec)](#ipld-codecs-multicodec)
- [API Docs](#api-docs)
- [License](#license)
- [Contribution](#contribution)
## Install
```console
$ npm i multiformats
```
### Browser `<script>` tag
Loading this module through a script tag will make it's exports available as `Multiformats` in the global namespace.
```html
<script src="https://unpkg.com/multiformats/dist/index.min.js"></script>
```
## Interfaces
This library defines common interfaces and low level building blocks for various interrelated multiformat technologies (multicodec, multihash, multibase, and CID). They can be used to implement custom base encoders / decoders / codecs, codec encoders /decoders and multihash hashers that comply to the interface that layers above assume.

@@ -49,3 +14,3 @@

```js
```TypeScript
import { CID } from 'multiformats/cid'

@@ -62,5 +27,5 @@ import * as json from 'multiformats/codecs/json'

### Creating Blocks
## Creating Blocks
```js
```TypeScript
import * as Block from 'multiformats/block'

@@ -86,7 +51,7 @@ import * as codec from '@ipld/dag-cbor'

### Multibase Encoders / Decoders / Codecs
## Multibase Encoders / Decoders / Codecs
CIDs can be serialized to string representation using multibase encoders that implement [`MultibaseEncoder`](https://github.com/multiformats/js-multiformats/blob/master/src/bases/interface.ts) interface. This library provides quite a few implementations that can be imported:
```js
```TypeScript
import { base64 } from "multiformats/bases/base64"

@@ -99,3 +64,3 @@ cid.toString(base64.encoder)

```js
```TypeScript
CID.parse('mAYAEEiCTojlxqRTl6svwqNJRVM2jCcPBxy+7mRTUfGDzy2gViA', base64.decoder)

@@ -110,3 +75,3 @@ //> CID(bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea)

```js
```TypeScript
cid.toString(base64)

@@ -120,3 +85,3 @@ CID.parse(cid.toString(base64), base64)

```js
```TypeScript
const v1 = CID.parse('bagaaierasords4njcts6vs7qvdjfcvgnume4hqohf65zsfguprqphs3icwea')

@@ -133,3 +98,3 @@ v1.toString()

### Multicodec Encoders / Decoders / Codecs
## Multicodec Encoders / Decoders / Codecs

@@ -140,7 +105,3 @@ This library defines [`BlockEncoder`, `BlockDecoder` and `BlockCodec` interfaces](https://github.com/multiformats/js-multiformats/blob/master/src/codecs/interface.ts).

```js
/**
* @template T
* @type {BlockCodec<0x0200, T>}
*/
```TypeScript
export const { name, code, encode, decode } = {

@@ -154,7 +115,7 @@ name: 'json',

### Multihash Hashers
## Multihash Hashers
This library defines [`MultihashHasher` and `MultihashDigest` interfaces](https://github.com/multiformats/js-multiformats/blob/master/src/hashes/interface.ts) and convinient function for implementing them:
```js
```TypeScript
import * as hasher from 'multiformats/hashes/hasher'

@@ -177,3 +138,3 @@

### Traversal
## Traversal

@@ -184,3 +145,3 @@ This library contains higher-order functions for traversing graphs of data easily.

```js
```TypeScript
import { walk } from 'multiformats/traversal'

@@ -258,7 +219,21 @@ import * as Block from 'multiformats/block'

## API Docs
# Install
```console
$ npm i multiformats
```
## Browser `<script>` tag
Loading this module through a script tag will make it's exports available as `Multiformats` in the global namespace.
```html
<script src="https://unpkg.com/multiformats/dist/index.min.js"></script>
```
# API Docs
- <https://multiformats.github.io/js-multiformats>
## License
# License

@@ -270,4 +245,4 @@ Licensed under either of

## Contribution
# Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

@@ -11,4 +11,2 @@ // Base encoders / decoders just base encode / decode between binary and

* `encode` no multibase prefix is added.
*
* @param bytes
*/

@@ -25,4 +23,2 @@ baseEncode(bytes: Uint8Array): string

* decode
*
* @param text
*/

@@ -78,4 +74,2 @@ baseDecode(text: string): Uint8Array

* If prefix does not match
*
* @param multibase
*/

@@ -82,0 +76,0 @@ decode(multibase: Multibase<Prefix>): Uint8Array

@@ -1,4 +0,1 @@

/* eslint-disable @typescript-eslint/no-unnecessary-type-constraint */
/* eslint-disable no-use-before-define */
import type { CID } from '../cid.js'

@@ -58,3 +55,3 @@ import type { Link, Version } from '../link/interface.js'

export type BlockCursorView<T extends unknown = unknown> =
export type BlockCursorView<T = unknown> =
| { value: T, remaining?: undefined }

@@ -61,0 +58,0 @@ | { value: CID, remaining: string }

@@ -44,4 +44,2 @@ // # Multihash

* await is needed.
*
* @param {Uint8Array} input
*/

@@ -48,0 +46,0 @@ digest(input: Uint8Array): Promise<MultihashDigest<Code>> | MultihashDigest<Code>

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