Socket
Socket
Sign inDemoInstall

multicodec

Package Overview
Dependencies
Maintainers
5
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

multicodec - npm Package Compare versions

Comparing version 2.0.2 to 2.0.3

dist/src/base-table.d.ts

9

CHANGELOG.md

@@ -0,1 +1,10 @@

## [2.0.3](https://github.com/multiformats/js-multicodec/compare/v2.0.2...v2.0.3) (2020-12-11)
### Features
* add ts types ([#70](https://github.com/multiformats/js-multicodec/issues/70)) ([25cf33f](https://github.com/multiformats/js-multicodec/commit/25cf33fdc392da21d776f6f4e85b678101724364))
## [2.0.2](https://github.com/multiformats/js-multicodec/compare/v2.0.1...v2.0.2) (2020-12-11)

@@ -2,0 +11,0 @@

2

dist/index.min.js

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

!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.Multicodec=n():e.Multicodec=n()}(self,(function(){return function(e){var n={};function t(s){if(n[s])return n[s].exports;var i=n[s]={i:s,l:!1,exports:{}};return e[s].call(i.exports,i,i.exports,t),i.l=!0,i.exports}return t.m=e,t.c=n,t.d=function(e,n,s){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:s})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var s=Object.create(null);if(t.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var i in e)t.d(s,i,function(n){return e[n]}.bind(null,i));return s},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="",t(t.s=6)}([function(e){e.exports=JSON.parse('{"identity":0,"cidv1":1,"cidv2":2,"cidv3":3,"ip4":4,"tcp":6,"sha1":17,"sha2-256":18,"sha2-512":19,"sha3-512":20,"sha3-384":21,"sha3-256":22,"sha3-224":23,"shake-128":24,"shake-256":25,"keccak-224":26,"keccak-256":27,"keccak-384":28,"keccak-512":29,"blake3":30,"dccp":33,"murmur3-128":34,"murmur3-32":35,"ip6":41,"ip6zone":42,"path":47,"multicodec":48,"multihash":49,"multiaddr":50,"multibase":51,"dns":53,"dns4":54,"dns6":55,"dnsaddr":56,"protobuf":80,"cbor":81,"raw":85,"dbl-sha2-256":86,"rlp":96,"bencode":99,"dag-pb":112,"dag-cbor":113,"libp2p-key":114,"git-raw":120,"torrent-info":123,"torrent-file":124,"leofcoin-block":129,"leofcoin-tx":130,"leofcoin-pr":131,"sctp":132,"dag-jose":133,"dag-cose":134,"eth-block":144,"eth-block-list":145,"eth-tx-trie":146,"eth-tx":147,"eth-tx-receipt-trie":148,"eth-tx-receipt":149,"eth-state-trie":150,"eth-account-snapshot":151,"eth-storage-trie":152,"bitcoin-block":176,"bitcoin-tx":177,"bitcoin-witness-commitment":178,"zcash-block":192,"zcash-tx":193,"docid":206,"stellar-block":208,"stellar-tx":209,"md4":212,"md5":213,"bmt":214,"decred-block":224,"decred-tx":225,"ipld-ns":226,"ipfs-ns":227,"swarm-ns":228,"ipns-ns":229,"zeronet":230,"secp256k1-pub":231,"bls12_381-g1-pub":234,"bls12_381-g2-pub":235,"x25519-pub":236,"ed25519-pub":237,"bls12_381-g1g2-pub":238,"dash-block":240,"dash-tx":241,"swarm-manifest":250,"swarm-feed":251,"udp":273,"p2p-webrtc-star":275,"p2p-webrtc-direct":276,"p2p-stardust":277,"p2p-circuit":290,"dag-json":297,"udt":301,"utp":302,"unix":400,"p2p":421,"ipfs":421,"https":443,"onion":444,"onion3":445,"garlic64":446,"garlic32":447,"tls":448,"quic":460,"ws":477,"wss":478,"p2p-websocket-star":479,"http":480,"json":512,"messagepack":513,"libp2p-peer-record":769,"sha2-256-trunc254-padded":4114,"ripemd-128":4178,"ripemd-160":4179,"ripemd-256":4180,"ripemd-320":4181,"x11":4352,"p256-pub":4608,"p384-pub":4609,"p521-pub":4610,"ed448-pub":4611,"x448-pub":4612,"ed25519-priv":4864,"kangarootwelve":7425,"sm3-256":21325,"blake2b-8":45569,"blake2b-16":45570,"blake2b-24":45571,"blake2b-32":45572,"blake2b-40":45573,"blake2b-48":45574,"blake2b-56":45575,"blake2b-64":45576,"blake2b-72":45577,"blake2b-80":45578,"blake2b-88":45579,"blake2b-96":45580,"blake2b-104":45581,"blake2b-112":45582,"blake2b-120":45583,"blake2b-128":45584,"blake2b-136":45585,"blake2b-144":45586,"blake2b-152":45587,"blake2b-160":45588,"blake2b-168":45589,"blake2b-176":45590,"blake2b-184":45591,"blake2b-192":45592,"blake2b-200":45593,"blake2b-208":45594,"blake2b-216":45595,"blake2b-224":45596,"blake2b-232":45597,"blake2b-240":45598,"blake2b-248":45599,"blake2b-256":45600,"blake2b-264":45601,"blake2b-272":45602,"blake2b-280":45603,"blake2b-288":45604,"blake2b-296":45605,"blake2b-304":45606,"blake2b-312":45607,"blake2b-320":45608,"blake2b-328":45609,"blake2b-336":45610,"blake2b-344":45611,"blake2b-352":45612,"blake2b-360":45613,"blake2b-368":45614,"blake2b-376":45615,"blake2b-384":45616,"blake2b-392":45617,"blake2b-400":45618,"blake2b-408":45619,"blake2b-416":45620,"blake2b-424":45621,"blake2b-432":45622,"blake2b-440":45623,"blake2b-448":45624,"blake2b-456":45625,"blake2b-464":45626,"blake2b-472":45627,"blake2b-480":45628,"blake2b-488":45629,"blake2b-496":45630,"blake2b-504":45631,"blake2b-512":45632,"blake2s-8":45633,"blake2s-16":45634,"blake2s-24":45635,"blake2s-32":45636,"blake2s-40":45637,"blake2s-48":45638,"blake2s-56":45639,"blake2s-64":45640,"blake2s-72":45641,"blake2s-80":45642,"blake2s-88":45643,"blake2s-96":45644,"blake2s-104":45645,"blake2s-112":45646,"blake2s-120":45647,"blake2s-128":45648,"blake2s-136":45649,"blake2s-144":45650,"blake2s-152":45651,"blake2s-160":45652,"blake2s-168":45653,"blake2s-176":45654,"blake2s-184":45655,"blake2s-192":45656,"blake2s-200":45657,"blake2s-208":45658,"blake2s-216":45659,"blake2s-224":45660,"blake2s-232":45661,"blake2s-240":45662,"blake2s-248":45663,"blake2s-256":45664,"skein256-8":45825,"skein256-16":45826,"skein256-24":45827,"skein256-32":45828,"skein256-40":45829,"skein256-48":45830,"skein256-56":45831,"skein256-64":45832,"skein256-72":45833,"skein256-80":45834,"skein256-88":45835,"skein256-96":45836,"skein256-104":45837,"skein256-112":45838,"skein256-120":45839,"skein256-128":45840,"skein256-136":45841,"skein256-144":45842,"skein256-152":45843,"skein256-160":45844,"skein256-168":45845,"skein256-176":45846,"skein256-184":45847,"skein256-192":45848,"skein256-200":45849,"skein256-208":45850,"skein256-216":45851,"skein256-224":45852,"skein256-232":45853,"skein256-240":45854,"skein256-248":45855,"skein256-256":45856,"skein512-8":45857,"skein512-16":45858,"skein512-24":45859,"skein512-32":45860,"skein512-40":45861,"skein512-48":45862,"skein512-56":45863,"skein512-64":45864,"skein512-72":45865,"skein512-80":45866,"skein512-88":45867,"skein512-96":45868,"skein512-104":45869,"skein512-112":45870,"skein512-120":45871,"skein512-128":45872,"skein512-136":45873,"skein512-144":45874,"skein512-152":45875,"skein512-160":45876,"skein512-168":45877,"skein512-176":45878,"skein512-184":45879,"skein512-192":45880,"skein512-200":45881,"skein512-208":45882,"skein512-216":45883,"skein512-224":45884,"skein512-232":45885,"skein512-240":45886,"skein512-248":45887,"skein512-256":45888,"skein512-264":45889,"skein512-272":45890,"skein512-280":45891,"skein512-288":45892,"skein512-296":45893,"skein512-304":45894,"skein512-312":45895,"skein512-320":45896,"skein512-328":45897,"skein512-336":45898,"skein512-344":45899,"skein512-352":45900,"skein512-360":45901,"skein512-368":45902,"skein512-376":45903,"skein512-384":45904,"skein512-392":45905,"skein512-400":45906,"skein512-408":45907,"skein512-416":45908,"skein512-424":45909,"skein512-432":45910,"skein512-440":45911,"skein512-448":45912,"skein512-456":45913,"skein512-464":45914,"skein512-472":45915,"skein512-480":45916,"skein512-488":45917,"skein512-496":45918,"skein512-504":45919,"skein512-512":45920,"skein1024-8":45921,"skein1024-16":45922,"skein1024-24":45923,"skein1024-32":45924,"skein1024-40":45925,"skein1024-48":45926,"skein1024-56":45927,"skein1024-64":45928,"skein1024-72":45929,"skein1024-80":45930,"skein1024-88":45931,"skein1024-96":45932,"skein1024-104":45933,"skein1024-112":45934,"skein1024-120":45935,"skein1024-128":45936,"skein1024-136":45937,"skein1024-144":45938,"skein1024-152":45939,"skein1024-160":45940,"skein1024-168":45941,"skein1024-176":45942,"skein1024-184":45943,"skein1024-192":45944,"skein1024-200":45945,"skein1024-208":45946,"skein1024-216":45947,"skein1024-224":45948,"skein1024-232":45949,"skein1024-240":45950,"skein1024-248":45951,"skein1024-256":45952,"skein1024-264":45953,"skein1024-272":45954,"skein1024-280":45955,"skein1024-288":45956,"skein1024-296":45957,"skein1024-304":45958,"skein1024-312":45959,"skein1024-320":45960,"skein1024-328":45961,"skein1024-336":45962,"skein1024-344":45963,"skein1024-352":45964,"skein1024-360":45965,"skein1024-368":45966,"skein1024-376":45967,"skein1024-384":45968,"skein1024-392":45969,"skein1024-400":45970,"skein1024-408":45971,"skein1024-416":45972,"skein1024-424":45973,"skein1024-432":45974,"skein1024-440":45975,"skein1024-448":45976,"skein1024-456":45977,"skein1024-464":45978,"skein1024-472":45979,"skein1024-480":45980,"skein1024-488":45981,"skein1024-496":45982,"skein1024-504":45983,"skein1024-512":45984,"skein1024-520":45985,"skein1024-528":45986,"skein1024-536":45987,"skein1024-544":45988,"skein1024-552":45989,"skein1024-560":45990,"skein1024-568":45991,"skein1024-576":45992,"skein1024-584":45993,"skein1024-592":45994,"skein1024-600":45995,"skein1024-608":45996,"skein1024-616":45997,"skein1024-624":45998,"skein1024-632":45999,"skein1024-640":46000,"skein1024-648":46001,"skein1024-656":46002,"skein1024-664":46003,"skein1024-672":46004,"skein1024-680":46005,"skein1024-688":46006,"skein1024-696":46007,"skein1024-704":46008,"skein1024-712":46009,"skein1024-720":46010,"skein1024-728":46011,"skein1024-736":46012,"skein1024-744":46013,"skein1024-752":46014,"skein1024-760":46015,"skein1024-768":46016,"skein1024-776":46017,"skein1024-784":46018,"skein1024-792":46019,"skein1024-800":46020,"skein1024-808":46021,"skein1024-816":46022,"skein1024-824":46023,"skein1024-832":46024,"skein1024-840":46025,"skein1024-848":46026,"skein1024-856":46027,"skein1024-864":46028,"skein1024-872":46029,"skein1024-880":46030,"skein1024-888":46031,"skein1024-896":46032,"skein1024-904":46033,"skein1024-912":46034,"skein1024-920":46035,"skein1024-928":46036,"skein1024-936":46037,"skein1024-944":46038,"skein1024-952":46039,"skein1024-960":46040,"skein1024-968":46041,"skein1024-976":46042,"skein1024-984":46043,"skein1024-992":46044,"skein1024-1000":46045,"skein1024-1008":46046,"skein1024-1016":46047,"skein1024-1024":46048,"poseidon-bls12_381-a2-fc1":46081,"poseidon-bls12_381-a2-fc1-sc":46082,"zeroxcert-imprint-256":52753,"fil-commitment-unsealed":61697,"fil-commitment-sealed":61698,"holochain-adr-v0":8417572,"holochain-adr-v1":8483108,"holochain-key-v0":9728292,"holochain-key-v1":9793828,"holochain-sig-v0":10645796,"holochain-sig-v1":10711332,"skynet-ns":11639056}')},function(e,n,t){"use strict";n.TextEncoder=TextEncoder,n.TextDecoder=TextDecoder},function(e,n,t){"use strict";e.exports={encode:t(8),decode:t(9),encodingLength:t(10)}},function(e,n,t){"use strict";const s=t(2),i=t(13),r=t(17);function o(e){return parseInt(i(e,"base16"),16)}e.exports={numberToUint8Array:function(e){let n=e.toString(16);n.length%2==1&&(n="0"+n);return r(n,"base16")},uint8ArrayToNumber:o,varintUint8ArrayEncode:function(e){return Uint8Array.from(s.encode(o(e)))},varintEncode:function(e){return Uint8Array.from(s.encode(e))}}},function(e,n,t){"use strict";const s=t(14),i=t(15),{rfc4648:r}=t(16),{decodeText:o,encodeText:k}=t(5),a=[["identity","\0",()=>({encode:o,decode:k}),""],["base2","0",r(1),"01"],["base8","7",r(3),"01234567"],["base10","9",s,"0123456789"],["base16","f",r(4),"0123456789abcdef"],["base16upper","F",r(4),"0123456789ABCDEF"],["base32hex","v",r(5),"0123456789abcdefghijklmnopqrstuv"],["base32hexupper","V",r(5),"0123456789ABCDEFGHIJKLMNOPQRSTUV"],["base32hexpad","t",r(5),"0123456789abcdefghijklmnopqrstuv="],["base32hexpadupper","T",r(5),"0123456789ABCDEFGHIJKLMNOPQRSTUV="],["base32","b",r(5),"abcdefghijklmnopqrstuvwxyz234567"],["base32upper","B",r(5),"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"],["base32pad","c",r(5),"abcdefghijklmnopqrstuvwxyz234567="],["base32padupper","C",r(5),"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567="],["base32z","h",r(5),"ybndrfg8ejkmcpqxot1uwisza345h769"],["base36","k",s,"0123456789abcdefghijklmnopqrstuvwxyz"],["base36upper","K",s,"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"],["base58btc","z",s,"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"],["base58flickr","Z",s,"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"],["base64","m",r(6),"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"],["base64pad","M",r(6),"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="],["base64url","u",r(6),"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"],["base64urlpad","U",r(6),"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_="]],c=a.reduce((e,n)=>(e[n[0]]=new i(n[0],n[1],n[2],n[3]),e),{}),b=a.reduce((e,n)=>(e[n[1]]=c[n[0]],e),{});e.exports={names:c,codes:b}},function(e,n,t){"use strict";const{TextEncoder:s,TextDecoder:i}=t(1),r=new i,o=new s;e.exports={decodeText:e=>r.decode(e),encodeText:e=>o.encode(e),concat:function(e,n){const t=new Uint8Array(n);let s=0;for(const i of e)t.set(i,s),s+=i.length;return t}}},function(e,n,t){e.exports=t(7)},function(e,n,t){"use strict";const s=t(2),i=t(11),r=t(12),o=t(3),k=t(18);(n=e.exports).addPrefix=(e,n)=>{let t;if(e instanceof Uint8Array)t=o.varintUint8ArrayEncode(e);else{if(!r[e])throw new Error("multicodec not recognized");t=r[e]}return k([t,n],t.length+n.length)},n.rmPrefix=e=>(s.decode(e),e.slice(s.decode.bytes)),n.getCodec=e=>{const n=s.decode(e),t=i.get(n);if(void 0===t)throw new Error(`Code ${n} not found`);return t},n.getName=e=>i.get(e),n.getNumber=e=>{const n=r[e];if(void 0===n)throw new Error("Codec `"+e+"` not found");return s.decode(n)},n.getCode=e=>s.decode(e),n.getCodeVarint=e=>{const n=r[e];if(void 0===n)throw new Error("Codec `"+e+"` not found");return n},n.getVarint=e=>s.encode(e);const a=t(19);Object.assign(n,a),n.print=t(20)},function(e,n,t){"use strict";e.exports=function e(n,t,i){if(Number.MAX_SAFE_INTEGER&&n>Number.MAX_SAFE_INTEGER)throw e.bytes=0,new RangeError("Could not encode varint");t=t||[];var r=i=i||0;for(;n>=s;)t[i++]=255&n|128,n/=128;for(;-128&n;)t[i++]=255&n|128,n>>>=7;return t[i]=0|n,e.bytes=i-r+1,t};var s=Math.pow(2,31)},function(e,n,t){"use strict";e.exports=function e(n,t){var s,i=0,r=0,o=t=t||0,k=n.length;do{if(o>=k||r>49)throw e.bytes=0,new RangeError("Could not decode varint");s=n[o++],i+=r<28?(127&s)<<r:(127&s)*Math.pow(2,r),r+=7}while(s>=128);return e.bytes=o-t,i}},function(e,n,t){"use strict";var s=Math.pow(2,7),i=Math.pow(2,14),r=Math.pow(2,21),o=Math.pow(2,28),k=Math.pow(2,35),a=Math.pow(2,42),c=Math.pow(2,49),b=Math.pow(2,56),l=Math.pow(2,63);e.exports=function(e){return e<s?1:e<i?2:e<r?3:e<o?4:e<k?5:e<a?6:e<c?7:e<b?8:e<l?9:10}},function(e,n,t){"use strict";const s=t(0),i=new Map;for(const r in s){const e=s[r];i.set(e,r)}e.exports=Object.freeze(i)},function(e,n,t){"use strict";const s=t(0),i=t(3).varintEncode,r={};for(const o in s){const e=s[o];r[o]=i(e)}e.exports=Object.freeze(r)},function(e,n,t){"use strict";const{names:s}=t(4),{TextDecoder:i}=t(1),r=new i("utf8");e.exports=function(e,n="utf8"){if("utf8"===n||"utf-8"===n)return r.decode(e);if("ascii"===n)return function(e){let n="";for(let t=0;t<e.length;t++)n+=String.fromCharCode(e[t]);return n}(e);const t=s[n];if(!t)throw new Error("Unknown base");return t.encode(e)}},function(e,n,t){"use strict";e.exports=function(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var n=new Uint8Array(256),t=0;t<n.length;t++)n[t]=255;for(var s=0;s<e.length;s++){var i=e.charAt(s),r=i.charCodeAt(0);if(255!==n[r])throw new TypeError(i+" is ambiguous");n[r]=s}var o=e.length,k=e.charAt(0),a=Math.log(o)/Math.log(256),c=Math.log(256)/Math.log(o);function b(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var s=0,i=0;e[t]===k;)s++,t++;for(var r=(e.length-t)*a+1>>>0,c=new Uint8Array(r);e[t];){var b=n[e.charCodeAt(t)];if(255===b)return;for(var l=0,u=r-1;(0!==b||l<i)&&-1!==u;u--,l++)b+=o*c[u]>>>0,c[u]=b%256>>>0,b=b/256>>>0;if(0!==b)throw new Error("Non-zero carry");i=l,t++}if(" "!==e[t]){for(var d=r-i;d!==r&&0===c[d];)d++;for(var f=new Uint8Array(s+(r-d)),p=s;d!==r;)f[p++]=c[d++];return f}}}return{encode:function(n){if(n instanceof Uint8Array||(ArrayBuffer.isView(n)?n=new Uint8Array(n.buffer,n.byteOffset,n.byteLength):Array.isArray(n)&&(n=Uint8Array.from(n))),!(n instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===n.length)return"";for(var t=0,s=0,i=0,r=n.length;i!==r&&0===n[i];)i++,t++;for(var a=(r-i)*c+1>>>0,b=new Uint8Array(a);i!==r;){for(var l=n[i],u=0,d=a-1;(0!==l||u<s)&&-1!==d;d--,u++)l+=256*b[d]>>>0,b[d]=l%o>>>0,l=l/o>>>0;if(0!==l)throw new Error("Non-zero carry");s=u,i++}for(var f=a-s;f!==a&&0===b[f];)f++;for(var p=k.repeat(t);f<a;++f)p+=e.charAt(b[f]);return p},decodeUnsafe:b,decode:function(e){var n=b(e);if(n)return n;throw new Error("Non-base"+o+" character")}}}},function(e,n,t){"use strict";const{encodeText:s}=t(5);e.exports=class{constructor(e,n,t,i){this.name=e,this.code=n,this.codeBuf=s(this.code),this.alphabet=i,this.codec=t(i)}encode(e){return this.codec.encode(e)}decode(e){for(const n of e)if(this.alphabet&&this.alphabet.indexOf(n)<0)throw new Error(`invalid character '${n}' in '${e}'`);return this.codec.decode(e)}}},function(e,n,t){"use strict";e.exports={rfc4648:e=>n=>({encode:t=>((e,n,t)=>{const s="="===n[n.length-1],i=(1<<t)-1;let r="",o=0,k=0;for(let a=0;a<e.length;++a)for(k=k<<8|e[a],o+=8;o>t;)o-=t,r+=n[i&k>>o];if(o&&(r+=n[i&k<<t-o]),s)for(;r.length*t&7;)r+="=";return r})(t,n,e),decode:t=>((e,n,t)=>{const s={};for(let c=0;c<n.length;++c)s[n[c]]=c;let i=e.length;for(;"="===e[i-1];)--i;const r=new Uint8Array(i*t/8|0);let o=0,k=0,a=0;for(let c=0;c<i;++c){const n=s[e[c]];if(void 0===n)throw new SyntaxError("Invalid character "+e[c]);k=k<<t|n,o+=t,o>=8&&(o-=8,r[a++]=255&k>>o)}if(o>=t||255&k<<8-o)throw new SyntaxError("Unexpected end of data");return r})(t,n,e)})}},function(e,n,t){"use strict";const{names:s}=t(4),{TextEncoder:i}=t(1),r=new i;e.exports=function(e,n="utf8"){if("utf8"===n||"utf-8"===n)return r.encode(e);if("ascii"===n)return function(e){const n=new Uint8Array(e.length);for(let t=0;t<e.length;t++)n[t]=e.charCodeAt(t);return n}(e);const t=s[n];if(!t)throw new Error("Unknown base");return t.decode(e)}},function(e,n,t){"use strict";e.exports=function(e,n){n||(n=e.reduce((e,n)=>e+n.length,0));const t=new Uint8Array(n);let s=0;for(const i of e)t.set(i,s),s+=i.length;return t}},function(e,n,t){"use strict";const s=t(0),i={};for(const[r,o]of Object.entries(s))i[r.toUpperCase().replace(/-/g,"_")]=o;e.exports=Object.freeze(i)},function(e,n,t){"use strict";const s=t(0),i={};for(const[r,o]of Object.entries(s))void 0===i[o]&&(i[o]=r);e.exports=Object.freeze(i)}])}));
!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.Multicodec=n():e.Multicodec=n()}(self,(function(){return function(e){var n={};function t(s){if(n[s])return n[s].exports;var i=n[s]={i:s,l:!1,exports:{}};return e[s].call(i.exports,i,i.exports,t),i.l=!0,i.exports}return t.m=e,t.c=n,t.d=function(e,n,s){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:s})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var s=Object.create(null);if(t.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var i in e)t.d(s,i,function(n){return e[n]}.bind(null,i));return s},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="",t(t.s=6)}([function(e,n,t){"use strict";const s=Object.freeze({identity:0,cidv1:1,cidv2:2,cidv3:3,ip4:4,tcp:6,sha1:17,"sha2-256":18,"sha2-512":19,"sha3-512":20,"sha3-384":21,"sha3-256":22,"sha3-224":23,"shake-128":24,"shake-256":25,"keccak-224":26,"keccak-256":27,"keccak-384":28,"keccak-512":29,blake3:30,dccp:33,"murmur3-128":34,"murmur3-32":35,ip6:41,ip6zone:42,path:47,multicodec:48,multihash:49,multiaddr:50,multibase:51,dns:53,dns4:54,dns6:55,dnsaddr:56,protobuf:80,cbor:81,raw:85,"dbl-sha2-256":86,rlp:96,bencode:99,"dag-pb":112,"dag-cbor":113,"libp2p-key":114,"git-raw":120,"torrent-info":123,"torrent-file":124,"leofcoin-block":129,"leofcoin-tx":130,"leofcoin-pr":131,sctp:132,"dag-jose":133,"dag-cose":134,"eth-block":144,"eth-block-list":145,"eth-tx-trie":146,"eth-tx":147,"eth-tx-receipt-trie":148,"eth-tx-receipt":149,"eth-state-trie":150,"eth-account-snapshot":151,"eth-storage-trie":152,"bitcoin-block":176,"bitcoin-tx":177,"bitcoin-witness-commitment":178,"zcash-block":192,"zcash-tx":193,docid:206,"stellar-block":208,"stellar-tx":209,md4:212,md5:213,bmt:214,"decred-block":224,"decred-tx":225,"ipld-ns":226,"ipfs-ns":227,"swarm-ns":228,"ipns-ns":229,zeronet:230,"secp256k1-pub":231,"bls12_381-g1-pub":234,"bls12_381-g2-pub":235,"x25519-pub":236,"ed25519-pub":237,"bls12_381-g1g2-pub":238,"dash-block":240,"dash-tx":241,"swarm-manifest":250,"swarm-feed":251,udp:273,"p2p-webrtc-star":275,"p2p-webrtc-direct":276,"p2p-stardust":277,"p2p-circuit":290,"dag-json":297,udt:301,utp:302,unix:400,p2p:421,ipfs:421,https:443,onion:444,onion3:445,garlic64:446,garlic32:447,tls:448,quic:460,ws:477,wss:478,"p2p-websocket-star":479,http:480,json:512,messagepack:513,"libp2p-peer-record":769,"sha2-256-trunc254-padded":4114,"ripemd-128":4178,"ripemd-160":4179,"ripemd-256":4180,"ripemd-320":4181,x11:4352,"p256-pub":4608,"p384-pub":4609,"p521-pub":4610,"ed448-pub":4611,"x448-pub":4612,"ed25519-priv":4864,kangarootwelve:7425,"sm3-256":21325,"blake2b-8":45569,"blake2b-16":45570,"blake2b-24":45571,"blake2b-32":45572,"blake2b-40":45573,"blake2b-48":45574,"blake2b-56":45575,"blake2b-64":45576,"blake2b-72":45577,"blake2b-80":45578,"blake2b-88":45579,"blake2b-96":45580,"blake2b-104":45581,"blake2b-112":45582,"blake2b-120":45583,"blake2b-128":45584,"blake2b-136":45585,"blake2b-144":45586,"blake2b-152":45587,"blake2b-160":45588,"blake2b-168":45589,"blake2b-176":45590,"blake2b-184":45591,"blake2b-192":45592,"blake2b-200":45593,"blake2b-208":45594,"blake2b-216":45595,"blake2b-224":45596,"blake2b-232":45597,"blake2b-240":45598,"blake2b-248":45599,"blake2b-256":45600,"blake2b-264":45601,"blake2b-272":45602,"blake2b-280":45603,"blake2b-288":45604,"blake2b-296":45605,"blake2b-304":45606,"blake2b-312":45607,"blake2b-320":45608,"blake2b-328":45609,"blake2b-336":45610,"blake2b-344":45611,"blake2b-352":45612,"blake2b-360":45613,"blake2b-368":45614,"blake2b-376":45615,"blake2b-384":45616,"blake2b-392":45617,"blake2b-400":45618,"blake2b-408":45619,"blake2b-416":45620,"blake2b-424":45621,"blake2b-432":45622,"blake2b-440":45623,"blake2b-448":45624,"blake2b-456":45625,"blake2b-464":45626,"blake2b-472":45627,"blake2b-480":45628,"blake2b-488":45629,"blake2b-496":45630,"blake2b-504":45631,"blake2b-512":45632,"blake2s-8":45633,"blake2s-16":45634,"blake2s-24":45635,"blake2s-32":45636,"blake2s-40":45637,"blake2s-48":45638,"blake2s-56":45639,"blake2s-64":45640,"blake2s-72":45641,"blake2s-80":45642,"blake2s-88":45643,"blake2s-96":45644,"blake2s-104":45645,"blake2s-112":45646,"blake2s-120":45647,"blake2s-128":45648,"blake2s-136":45649,"blake2s-144":45650,"blake2s-152":45651,"blake2s-160":45652,"blake2s-168":45653,"blake2s-176":45654,"blake2s-184":45655,"blake2s-192":45656,"blake2s-200":45657,"blake2s-208":45658,"blake2s-216":45659,"blake2s-224":45660,"blake2s-232":45661,"blake2s-240":45662,"blake2s-248":45663,"blake2s-256":45664,"skein256-8":45825,"skein256-16":45826,"skein256-24":45827,"skein256-32":45828,"skein256-40":45829,"skein256-48":45830,"skein256-56":45831,"skein256-64":45832,"skein256-72":45833,"skein256-80":45834,"skein256-88":45835,"skein256-96":45836,"skein256-104":45837,"skein256-112":45838,"skein256-120":45839,"skein256-128":45840,"skein256-136":45841,"skein256-144":45842,"skein256-152":45843,"skein256-160":45844,"skein256-168":45845,"skein256-176":45846,"skein256-184":45847,"skein256-192":45848,"skein256-200":45849,"skein256-208":45850,"skein256-216":45851,"skein256-224":45852,"skein256-232":45853,"skein256-240":45854,"skein256-248":45855,"skein256-256":45856,"skein512-8":45857,"skein512-16":45858,"skein512-24":45859,"skein512-32":45860,"skein512-40":45861,"skein512-48":45862,"skein512-56":45863,"skein512-64":45864,"skein512-72":45865,"skein512-80":45866,"skein512-88":45867,"skein512-96":45868,"skein512-104":45869,"skein512-112":45870,"skein512-120":45871,"skein512-128":45872,"skein512-136":45873,"skein512-144":45874,"skein512-152":45875,"skein512-160":45876,"skein512-168":45877,"skein512-176":45878,"skein512-184":45879,"skein512-192":45880,"skein512-200":45881,"skein512-208":45882,"skein512-216":45883,"skein512-224":45884,"skein512-232":45885,"skein512-240":45886,"skein512-248":45887,"skein512-256":45888,"skein512-264":45889,"skein512-272":45890,"skein512-280":45891,"skein512-288":45892,"skein512-296":45893,"skein512-304":45894,"skein512-312":45895,"skein512-320":45896,"skein512-328":45897,"skein512-336":45898,"skein512-344":45899,"skein512-352":45900,"skein512-360":45901,"skein512-368":45902,"skein512-376":45903,"skein512-384":45904,"skein512-392":45905,"skein512-400":45906,"skein512-408":45907,"skein512-416":45908,"skein512-424":45909,"skein512-432":45910,"skein512-440":45911,"skein512-448":45912,"skein512-456":45913,"skein512-464":45914,"skein512-472":45915,"skein512-480":45916,"skein512-488":45917,"skein512-496":45918,"skein512-504":45919,"skein512-512":45920,"skein1024-8":45921,"skein1024-16":45922,"skein1024-24":45923,"skein1024-32":45924,"skein1024-40":45925,"skein1024-48":45926,"skein1024-56":45927,"skein1024-64":45928,"skein1024-72":45929,"skein1024-80":45930,"skein1024-88":45931,"skein1024-96":45932,"skein1024-104":45933,"skein1024-112":45934,"skein1024-120":45935,"skein1024-128":45936,"skein1024-136":45937,"skein1024-144":45938,"skein1024-152":45939,"skein1024-160":45940,"skein1024-168":45941,"skein1024-176":45942,"skein1024-184":45943,"skein1024-192":45944,"skein1024-200":45945,"skein1024-208":45946,"skein1024-216":45947,"skein1024-224":45948,"skein1024-232":45949,"skein1024-240":45950,"skein1024-248":45951,"skein1024-256":45952,"skein1024-264":45953,"skein1024-272":45954,"skein1024-280":45955,"skein1024-288":45956,"skein1024-296":45957,"skein1024-304":45958,"skein1024-312":45959,"skein1024-320":45960,"skein1024-328":45961,"skein1024-336":45962,"skein1024-344":45963,"skein1024-352":45964,"skein1024-360":45965,"skein1024-368":45966,"skein1024-376":45967,"skein1024-384":45968,"skein1024-392":45969,"skein1024-400":45970,"skein1024-408":45971,"skein1024-416":45972,"skein1024-424":45973,"skein1024-432":45974,"skein1024-440":45975,"skein1024-448":45976,"skein1024-456":45977,"skein1024-464":45978,"skein1024-472":45979,"skein1024-480":45980,"skein1024-488":45981,"skein1024-496":45982,"skein1024-504":45983,"skein1024-512":45984,"skein1024-520":45985,"skein1024-528":45986,"skein1024-536":45987,"skein1024-544":45988,"skein1024-552":45989,"skein1024-560":45990,"skein1024-568":45991,"skein1024-576":45992,"skein1024-584":45993,"skein1024-592":45994,"skein1024-600":45995,"skein1024-608":45996,"skein1024-616":45997,"skein1024-624":45998,"skein1024-632":45999,"skein1024-640":46e3,"skein1024-648":46001,"skein1024-656":46002,"skein1024-664":46003,"skein1024-672":46004,"skein1024-680":46005,"skein1024-688":46006,"skein1024-696":46007,"skein1024-704":46008,"skein1024-712":46009,"skein1024-720":46010,"skein1024-728":46011,"skein1024-736":46012,"skein1024-744":46013,"skein1024-752":46014,"skein1024-760":46015,"skein1024-768":46016,"skein1024-776":46017,"skein1024-784":46018,"skein1024-792":46019,"skein1024-800":46020,"skein1024-808":46021,"skein1024-816":46022,"skein1024-824":46023,"skein1024-832":46024,"skein1024-840":46025,"skein1024-848":46026,"skein1024-856":46027,"skein1024-864":46028,"skein1024-872":46029,"skein1024-880":46030,"skein1024-888":46031,"skein1024-896":46032,"skein1024-904":46033,"skein1024-912":46034,"skein1024-920":46035,"skein1024-928":46036,"skein1024-936":46037,"skein1024-944":46038,"skein1024-952":46039,"skein1024-960":46040,"skein1024-968":46041,"skein1024-976":46042,"skein1024-984":46043,"skein1024-992":46044,"skein1024-1000":46045,"skein1024-1008":46046,"skein1024-1016":46047,"skein1024-1024":46048,"poseidon-bls12_381-a2-fc1":46081,"poseidon-bls12_381-a2-fc1-sc":46082,"zeroxcert-imprint-256":52753,"fil-commitment-unsealed":61697,"fil-commitment-sealed":61698,"holochain-adr-v0":8417572,"holochain-adr-v1":8483108,"holochain-key-v0":9728292,"holochain-key-v1":9793828,"holochain-sig-v0":10645796,"holochain-sig-v1":10711332,"skynet-ns":11639056});e.exports={baseTable:s}},function(e,n,t){"use strict";n.TextEncoder=TextEncoder,n.TextDecoder=TextDecoder},function(e,n,t){"use strict";e.exports={encode:t(8),decode:t(9),encodingLength:t(10)}},function(e,n,t){"use strict";const s=t(2),i=t(13),r=t(17);function o(e){return parseInt(i(e,"base16"),16)}e.exports={numberToUint8Array:function(e){let n=e.toString(16);n.length%2==1&&(n="0"+n);return r(n,"base16")},uint8ArrayToNumber:o,varintUint8ArrayEncode:function(e){return Uint8Array.from(s.encode(o(e)))},varintEncode:function(e){return Uint8Array.from(s.encode(e))}}},function(e,n,t){"use strict";const s=t(14),i=t(15),{rfc4648:r}=t(16),{decodeText:o,encodeText:k}=t(5),a=[["identity","\0",()=>({encode:o,decode:k}),""],["base2","0",r(1),"01"],["base8","7",r(3),"01234567"],["base10","9",s,"0123456789"],["base16","f",r(4),"0123456789abcdef"],["base16upper","F",r(4),"0123456789ABCDEF"],["base32hex","v",r(5),"0123456789abcdefghijklmnopqrstuv"],["base32hexupper","V",r(5),"0123456789ABCDEFGHIJKLMNOPQRSTUV"],["base32hexpad","t",r(5),"0123456789abcdefghijklmnopqrstuv="],["base32hexpadupper","T",r(5),"0123456789ABCDEFGHIJKLMNOPQRSTUV="],["base32","b",r(5),"abcdefghijklmnopqrstuvwxyz234567"],["base32upper","B",r(5),"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"],["base32pad","c",r(5),"abcdefghijklmnopqrstuvwxyz234567="],["base32padupper","C",r(5),"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567="],["base32z","h",r(5),"ybndrfg8ejkmcpqxot1uwisza345h769"],["base36","k",s,"0123456789abcdefghijklmnopqrstuvwxyz"],["base36upper","K",s,"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"],["base58btc","z",s,"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"],["base58flickr","Z",s,"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"],["base64","m",r(6),"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"],["base64pad","M",r(6),"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="],["base64url","u",r(6),"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"],["base64urlpad","U",r(6),"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_="]],c=a.reduce((e,n)=>(e[n[0]]=new i(n[0],n[1],n[2],n[3]),e),{}),b=a.reduce((e,n)=>(e[n[1]]=c[n[0]],e),{});e.exports={names:c,codes:b}},function(e,n,t){"use strict";const{TextEncoder:s,TextDecoder:i}=t(1),r=new i,o=new s;e.exports={decodeText:e=>r.decode(e),encodeText:e=>o.encode(e),concat:function(e,n){const t=new Uint8Array(n);let s=0;for(const i of e)t.set(i,s),s+=i.length;return t}}},function(e,n,t){e.exports=t(7)},function(e,n,t){"use strict";const s=t(2),i=t(11),r=t(12),o=t(3),k=t(18);const a=t(19),c=t(20);e.exports={addPrefix:function(e,n){let t;if(e instanceof Uint8Array)t=o.varintUint8ArrayEncode(e);else{if(!r[e])throw new Error("multicodec not recognized");t=r[e]}return k([t,n],t.length+n.length)},rmPrefix:function(e){return s.decode(e),e.slice(s.decode.bytes)},getCodec:function(e){const n=s.decode(e),t=i.get(n);if(void 0===t)throw new Error(`Code ${n} not found`);return t},getName:function(e){return i.get(e)},getNumber:function(e){const n=r[e];if(void 0===n)throw new Error("Codec `"+e+"` not found");return s.decode(n)},getCode:function(e){return s.decode(e)},getCodeVarint:function(e){const n=r[e];if(void 0===n)throw new Error("Codec `"+e+"` not found");return n},getVarint:function(e){return s.encode(e)},print:c,...a}},function(e,n,t){"use strict";e.exports=function e(n,t,i){if(Number.MAX_SAFE_INTEGER&&n>Number.MAX_SAFE_INTEGER)throw e.bytes=0,new RangeError("Could not encode varint");t=t||[];var r=i=i||0;for(;n>=s;)t[i++]=255&n|128,n/=128;for(;-128&n;)t[i++]=255&n|128,n>>>=7;return t[i]=0|n,e.bytes=i-r+1,t};var s=Math.pow(2,31)},function(e,n,t){"use strict";e.exports=function e(n,t){var s,i=0,r=0,o=t=t||0,k=n.length;do{if(o>=k||r>49)throw e.bytes=0,new RangeError("Could not decode varint");s=n[o++],i+=r<28?(127&s)<<r:(127&s)*Math.pow(2,r),r+=7}while(s>=128);return e.bytes=o-t,i}},function(e,n,t){"use strict";var s=Math.pow(2,7),i=Math.pow(2,14),r=Math.pow(2,21),o=Math.pow(2,28),k=Math.pow(2,35),a=Math.pow(2,42),c=Math.pow(2,49),b=Math.pow(2,56),l=Math.pow(2,63);e.exports=function(e){return e<s?1:e<i?2:e<r?3:e<o?4:e<k?5:e<a?6:e<c?7:e<b?8:e<l?9:10}},function(e,n,t){"use strict";const{baseTable:s}=t(0),i=new Map;for(const r in s){const e=s[r];i.set(e,r)}e.exports=Object.freeze(i)},function(e,n,t){"use strict";const{baseTable:s}=t(0),i=t(3).varintEncode,r={};for(const o in s){const e=s[o];r[o]=i(e)}e.exports=Object.freeze(r)},function(e,n,t){"use strict";const{names:s}=t(4),{TextDecoder:i}=t(1),r=new i("utf8");e.exports=function(e,n="utf8"){if("utf8"===n||"utf-8"===n)return r.decode(e);if("ascii"===n)return function(e){let n="";for(let t=0;t<e.length;t++)n+=String.fromCharCode(e[t]);return n}(e);const t=s[n];if(!t)throw new Error("Unknown base");return t.encode(e)}},function(e,n,t){"use strict";e.exports=function(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var n=new Uint8Array(256),t=0;t<n.length;t++)n[t]=255;for(var s=0;s<e.length;s++){var i=e.charAt(s),r=i.charCodeAt(0);if(255!==n[r])throw new TypeError(i+" is ambiguous");n[r]=s}var o=e.length,k=e.charAt(0),a=Math.log(o)/Math.log(256),c=Math.log(256)/Math.log(o);function b(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var s=0,i=0;e[t]===k;)s++,t++;for(var r=(e.length-t)*a+1>>>0,c=new Uint8Array(r);e[t];){var b=n[e.charCodeAt(t)];if(255===b)return;for(var l=0,u=r-1;(0!==b||l<i)&&-1!==u;u--,l++)b+=o*c[u]>>>0,c[u]=b%256>>>0,b=b/256>>>0;if(0!==b)throw new Error("Non-zero carry");i=l,t++}if(" "!==e[t]){for(var f=r-i;f!==r&&0===c[f];)f++;for(var d=new Uint8Array(s+(r-f)),p=s;f!==r;)d[p++]=c[f++];return d}}}return{encode:function(n){if(n instanceof Uint8Array||(ArrayBuffer.isView(n)?n=new Uint8Array(n.buffer,n.byteOffset,n.byteLength):Array.isArray(n)&&(n=Uint8Array.from(n))),!(n instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===n.length)return"";for(var t=0,s=0,i=0,r=n.length;i!==r&&0===n[i];)i++,t++;for(var a=(r-i)*c+1>>>0,b=new Uint8Array(a);i!==r;){for(var l=n[i],u=0,f=a-1;(0!==l||u<s)&&-1!==f;f--,u++)l+=256*b[f]>>>0,b[f]=l%o>>>0,l=l/o>>>0;if(0!==l)throw new Error("Non-zero carry");s=u,i++}for(var d=a-s;d!==a&&0===b[d];)d++;for(var p=k.repeat(t);d<a;++d)p+=e.charAt(b[d]);return p},decodeUnsafe:b,decode:function(e){var n=b(e);if(n)return n;throw new Error("Non-base"+o+" character")}}}},function(e,n,t){"use strict";const{encodeText:s}=t(5);e.exports=class{constructor(e,n,t,i){this.name=e,this.code=n,this.codeBuf=s(this.code),this.alphabet=i,this.codec=t(i)}encode(e){return this.codec.encode(e)}decode(e){for(const n of e)if(this.alphabet&&this.alphabet.indexOf(n)<0)throw new Error(`invalid character '${n}' in '${e}'`);return this.codec.decode(e)}}},function(e,n,t){"use strict";e.exports={rfc4648:e=>n=>({encode:t=>((e,n,t)=>{const s="="===n[n.length-1],i=(1<<t)-1;let r="",o=0,k=0;for(let a=0;a<e.length;++a)for(k=k<<8|e[a],o+=8;o>t;)o-=t,r+=n[i&k>>o];if(o&&(r+=n[i&k<<t-o]),s)for(;r.length*t&7;)r+="=";return r})(t,n,e),decode:t=>((e,n,t)=>{const s={};for(let c=0;c<n.length;++c)s[n[c]]=c;let i=e.length;for(;"="===e[i-1];)--i;const r=new Uint8Array(i*t/8|0);let o=0,k=0,a=0;for(let c=0;c<i;++c){const n=s[e[c]];if(void 0===n)throw new SyntaxError("Invalid character "+e[c]);k=k<<t|n,o+=t,o>=8&&(o-=8,r[a++]=255&k>>o)}if(o>=t||255&k<<8-o)throw new SyntaxError("Unexpected end of data");return r})(t,n,e)})}},function(e,n,t){"use strict";const{names:s}=t(4),{TextEncoder:i}=t(1),r=new i;e.exports=function(e,n="utf8"){if("utf8"===n||"utf-8"===n)return r.encode(e);if("ascii"===n)return function(e){const n=new Uint8Array(e.length);for(let t=0;t<e.length;t++)n[t]=e.charCodeAt(t);return n}(e);const t=s[n];if(!t)throw new Error("Unknown base");return t.decode(e)}},function(e,n,t){"use strict";e.exports=function(e,n){n||(n=e.reduce((e,n)=>e+n.length,0));const t=new Uint8Array(n);let s=0;for(const i of e)t.set(i,s),s+=i.length;return t}},function(e,n,t){"use strict";const{baseTable:s}=t(0),i={};for(const[r,o]of Object.entries(s)){i[r.toUpperCase().replace(/-/g,"_")]=o}e.exports=Object.freeze(i)},function(e,n,t){"use strict";const{baseTable:s}=t(0),i={};for(const[r,o]of Object.entries(s))void 0===i[o]&&(i[o]=r);e.exports=Object.freeze(i)}])}));
{
"name": "multicodec",
"version": "2.0.2",
"version": "2.0.3",
"description": "JavaScript implementation of the multicodec specification",
"leadMaintainer": "Henrique Dias <hacdias@gmail.com>",
"main": "src/index.js",
"types": "dist/src/index.d.ts",
"typesVersions": {
"*": {
"src/*": [
"dist/src/*",
"dist/src/*/index"
]
}
},
"scripts": {

@@ -8,0 +17,0 @@ "lint": "aegir lint",

@@ -32,8 +32,2 @@ # js-multicodec <!-- omit in toc -->

The type definitions for this package are available on http://definitelytyped.org/. To install just use:
```sh
$ npm install -D @types/multicodec
```
## Usage

@@ -40,0 +34,0 @@

'use strict'
const table = require('./base-table.json')
/** @typedef {import('./generated-types').ConstantNumberMap} ConstantNumberMap */
// map for codecConstant -> code
const constants = {}
const { baseTable } = require('./base-table')
for (const [name, code] of Object.entries(table)) {
constants[name.toUpperCase().replace(/-/g, '_')] = code
const constants = /** @type {ConstantNumberMap} */({})
for (const [name, code] of Object.entries(baseTable)) {
const constant = name.toUpperCase().replace(/-/g, '_')
constants[constant] = code
}
module.exports = Object.freeze(constants)

@@ -14,2 +14,5 @@ /**

/** @typedef {import('./generated-types').CodecName} CodecName */
/** @typedef {import('./generated-types').CodecNumber} CodecNumber */
const varint = require('varint')

@@ -21,12 +24,10 @@ const intTable = require('./int-table')

exports = module.exports
/**
* Prefix a buffer with a multicodec-packed.
*
* @param {string|number} multicodecStrOrCode
* @param {CodecName|Uint8Array} multicodecStrOrCode
* @param {Uint8Array} data
* @returns {Uint8Array}
*/
exports.addPrefix = (multicodecStrOrCode, data) => {
function addPrefix (multicodecStrOrCode, data) {
let prefix

@@ -52,3 +53,3 @@

*/
exports.rmPrefix = (data) => {
function rmPrefix (data) {
varint.decode(data)

@@ -62,5 +63,5 @@ return data.slice(varint.decode.bytes)

* @param {Uint8Array} prefixedData
* @returns {string}
* @returns {CodecName}
*/
exports.getCodec = (prefixedData) => {
function getCodec (prefixedData) {
const code = varint.decode(prefixedData)

@@ -77,6 +78,6 @@ const codecName = intTable.get(code)

*
* @param {number} codec
* @returns {string}
* @param {CodecNumber} codec
* @returns {CodecName|undefined}
*/
exports.getName = (codec) => {
function getName (codec) {
return intTable.get(codec)

@@ -88,6 +89,6 @@ }

*
* @param {string} name
* @returns {number}
* @param {CodecName} name
* @returns {CodecNumber}
*/
exports.getNumber = (name) => {
function getNumber (name) {
const code = codecNameToCodeVarint[name]

@@ -104,5 +105,5 @@ if (code === undefined) {

* @param {Uint8Array} prefixedData
* @returns {number}
* @returns {CodecNumber}
*/
exports.getCode = (prefixedData) => {
function getCode (prefixedData) {
return varint.decode(prefixedData)

@@ -114,6 +115,6 @@ }

*
* @param {string} codecName
* @param {CodecName} codecName
* @returns {Uint8Array}
*/
exports.getCodeVarint = (codecName) => {
function getCodeVarint (codecName) {
const code = codecNameToCodeVarint[codecName]

@@ -129,6 +130,6 @@ if (code === undefined) {

*
* @param {number} code
* @param {CodecNumber} code
* @returns {Array.<number>}
*/
exports.getVarint = (code) => {
function getVarint (code) {
return varint.encode(code)

@@ -139,5 +140,17 @@ }

const constants = require('./constants')
Object.assign(exports, constants)
// Human friendly names for printing, e.g. in error messages
exports.print = require('./print')
const print = require('./print')
module.exports = {
addPrefix,
rmPrefix,
getCodec,
getName,
getNumber,
getCode,
getCodeVarint,
getVarint,
print,
...constants
}
'use strict'
const baseTable = require('./base-table.json')
// map for hexString -> codecName
/** @typedef {import('./generated-types').CodecName} CodecName */
/** @typedef {import('./generated-types').CodecNumber} CodecNumber */
const { baseTable } = require('./base-table')
/**
* @type {Map<CodecNumber,CodecName>}
*/
const nameTable = new Map()

@@ -9,5 +15,5 @@

const code = baseTable[encodingName]
nameTable.set(code, encodingName)
nameTable.set(code, /** @type {CodecName} */(encodingName))
}
module.exports = Object.freeze(nameTable)
'use strict'
const table = require('./base-table.json')
/** @typedef {import('./generated-types').CodecName} CodecName */
/** @typedef {import('./generated-types').NumberNameMap} NumberNameMap */
// map for code -> print friendly name
const tableByCode = {}
const { baseTable } = require('./base-table')
for (const [name, code] of Object.entries(table)) {
if (tableByCode[code] === undefined) tableByCode[code] = name
const tableByCode = /** @type {NumberNameMap} */({})
for (const [name, code] of Object.entries(baseTable)) {
if (tableByCode[code] === undefined) {
tableByCode[code] = /** @type {CodecName} **/(name)
}
}
module.exports = Object.freeze(tableByCode)
module.exports = /** @type {NumberNameMap} */(Object.freeze(tableByCode))
'use strict'
const baseTable = require('./base-table.json')
/** @typedef {import('./generated-types').NameUint8ArrayMap} NameUint8ArrayMap */
const { baseTable } = require('./base-table')
const varintEncode = require('./util').varintEncode
// map for codecName -> codeVarintUint8Array
const varintTable = {}
const varintTable = /** @type {NameUint8ArrayMap} */ ({})

@@ -9,0 +10,0 @@ for (const encodingName in baseTable) {

'use strict'
const bent = require('bent')
const fs = require('fs')
const path = require('path')
const get = bent('string')
const http = require('ipfs-utils/src/http')
const url = 'https://raw.githubusercontent.com/multiformats/multicodec/master/table.csv'
const fs = require('fs')
const parse = async function * () {
const str = await get(url)
const lines = str.split('\n')
lines.shift()
for (const line of lines) {
if (!line.length) continue
const [name, tag, code] = line.split(',')
yield { name: name.trim(), tag: tag.trim(), code: parseInt(code.trim(), 16) }
}
}
const run = async () => {
const table = {}
const rsp = await http.get(url)
const lines = (await rsp.text()).split('\n')
const names = []
const codes = []
const processed = lines
.slice(1, lines.length - 1)
.map(l => {
const [name, tag, code] = l.split(',')
return [name.trim(), tag.trim(), code.trim()]
})
.reduce((acc, l, index, arr) => {
names.push(`'${l[0]}'`)
codes.push(`${l[2].replace('\'', '')}`)
acc += ` '${l[0]}': ${l[2].replace('\'', '')}`
for await (const { name, code } of parse()) {
table[name] = code
}
if (index !== arr.length - 1) {
acc += ',\n'
}
return acc
}, '')
fs.writeFileSync(path.join(__dirname, '../src/base-table.json'), JSON.stringify(table, null, 2))
const typesTemplate = `// DO NOT CHANGE THIS FILE MANUALLY. IT IS GENERATED BY tools/update-table.js
/**
* Constant names for all available codecs
*/
export type CodecConstant = ${names.map(n => `${n.toUpperCase().replace(/-/g, '_')}`).join(' | ')};
/**
* Names for all available codecs
*/
export type CodecName = ${names.join(' | ')};
/**
* Number for all available codecs
*/
export type CodecNumber = ${codes.join(' | ')};
export type ConstantNumberMap = Record<CodecConstant, CodecNumber>
export type NameUint8ArrayMap = Record<CodecName, Uint8Array>
export type NumberNameMap = Record<CodecNumber, CodecName>
export type NameNumberMap = Record<CodecName, CodecNumber>
`
const tableTemplate = `// DO NOT CHANGE THIS FILE. IT IS GENERATED BY tools/update-table.js
/* eslint quote-props: off */
'use strict'
/**
* @type {import('./generated-types').NameNumberMap}
*/
const baseTable = Object.freeze({
${processed}
})
module.exports = { baseTable }
`
fs.writeFileSync(path.join(__dirname, '../src/generated-types.ts'), typesTemplate)
fs.writeFileSync(path.join(__dirname, '../src/base-table.js'), tableTemplate)
}
run()

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc