@helia/dag-cbor 4.0.2 → 4.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.min.js +1 -1
- package/package.json +3 -3
package/dist/index.min.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.HeliaDagCbor = factory()}(typeof self !== 'undefined' ? self : this, function () {
|
|
2
|
-
"use strict";var HeliaDagCbor=(()=>{var Ce=Object.defineProperty;var Er=Object.getOwnPropertyDescriptor;var Ur=Object.getOwnPropertyNames;var vr=Object.prototype.hasOwnProperty;var Ar=(e,t)=>{for(var r in t)Ce(e,r,{get:t[r],enumerable:!0})},Tr=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ur(t))!vr.call(e,o)&&o!==r&&Ce(e,o,{get:()=>t[o],enumerable:!(n=Er(t,o))||n.enumerable});return e};var kr=e=>Tr(Ce({},"__esModule",{value:!0}),e);var Vn={};Ar(Vn,{dagCbor:()=>Fn});var Sr=["string","number","bigint","symbol"],Br=["Function","Generator","AsyncGenerator","GeneratorFunction","AsyncGeneratorFunction","AsyncFunction","Observable","Array","Buffer","Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function He(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0||e===!1)return"boolean";let t=typeof e;if(Sr.includes(t))return t;if(t==="function")return"Function";if(Array.isArray(e))return"Array";if(Cr(e))return"Buffer";let r=Ir(e);return r||"Object"}function Cr(e){return e&&e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer.call(null,e)}function Ir(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(Br.includes(t))return t}var i=class{constructor(t,r,n){this.major=t,this.majorEncoded=t<<5,this.name=r,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(t){return this.major<t.major?-1:this.major>t.major?1:0}};i.uint=new i(0,"uint",!0);i.negint=new i(1,"negint",!0);i.bytes=new i(2,"bytes",!0);i.string=new i(3,"string",!0);i.array=new i(4,"array",!1);i.map=new i(5,"map",!1);i.tag=new i(6,"tag",!1);i.float=new i(7,"float",!0);i.false=new i(7,"false",!0);i.true=new i(7,"true",!0);i.null=new i(7,"null",!0);i.undefined=new i(7,"undefined",!0);i.break=new i(7,"break",!0);var a=class{constructor(t,r,n){this.type=t,this.value=r,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var J=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",_r=new TextDecoder,Nr=new TextEncoder;function me(e){return J&&globalThis.Buffer.isBuffer(e)}function Ie(e){return e instanceof Uint8Array?me(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var Ye=J?(e,t,r)=>r-t>64?globalThis.Buffer.from(e.subarray(t,r)).toString("utf8"):We(e,t,r):(e,t,r)=>r-t>64?_r.decode(e.subarray(t,r)):We(e,t,r),et=J?e=>e.length>64?globalThis.Buffer.from(e):Qe(e):e=>e.length>64?Nr.encode(e):Qe(e),M=e=>Uint8Array.from(e),K=J?(e,t,r)=>me(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),tt=J?(e,t)=>(e=e.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),Ie(globalThis.Buffer.concat(e,t))):(e,t)=>{let r=new Uint8Array(t),n=0;for(let o of e)n+o.length>r.length&&(o=o.subarray(0,r.length-n)),r.set(o,n),n+=o.length;return r},rt=J?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function nt(e,t){if(me(e)&&me(t))return e.compare(t);for(let r=0;r<e.length;r++)if(e[r]!==t[r])return e[r]<t[r]?-1:1;return 0}function Qe(e){let t=[],r=0;for(let n=0;n<e.length;n++){let o=e.charCodeAt(n);o<128?t[r++]=o:o<2048?(t[r++]=o>>6|192,t[r++]=o&63|128):(o&64512)===55296&&n+1<e.length&&(e.charCodeAt(n+1)&64512)===56320?(o=65536+((o&1023)<<10)+(e.charCodeAt(++n)&1023),t[r++]=o>>18|240,t[r++]=o>>12&63|128,t[r++]=o>>6&63|128,t[r++]=o&63|128):(t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=o&63|128)}return t}function We(e,t,r){let n=[];for(;t<r;){let o=e[t],s=null,u=o>239?4:o>223?3:o>191?2:1;if(t+u<=r){let f,p,g,h;switch(u){case 1:o<128&&(s=o);break;case 2:f=e[t+1],(f&192)===128&&(h=(o&31)<<6|f&63,h>127&&(s=h));break;case 3:f=e[t+1],p=e[t+2],(f&192)===128&&(p&192)===128&&(h=(o&15)<<12|(f&63)<<6|p&63,h>2047&&(h<55296||h>57343)&&(s=h));break;case 4:f=e[t+1],p=e[t+2],g=e[t+3],(f&192)===128&&(p&192)===128&&(g&192)===128&&(h=(o&15)<<18|(f&63)<<12|(p&63)<<6|g&63,h>65535&&h<1114112&&(s=h))}}s===null?(s=65533,u=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|s&1023),n.push(s),t+=u}return $r(n)}var Ze=4096;function $r(e){let t=e.length;if(t<=Ze)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=Ze));return r}var Mr=256,ne=class{constructor(t=Mr){this.chunkSize=t,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.cursor=0,this.maxCursor=-1,this.chunks.length&&(this.chunks=[]),this._initReuseChunk!==null&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}push(t){let r=this.chunks[this.chunks.length-1];if(this.cursor+t.length<=this.maxCursor+1){let o=r.length-(this.maxCursor-this.cursor)-1;r.set(t,o)}else{if(r){let o=r.length-(this.maxCursor-this.cursor)-1;o<r.length&&(this.chunks[this.chunks.length-1]=r.subarray(0,o),this.maxCursor=this.cursor-1)}t.length<64&&t.length<this.chunkSize?(r=rt(this.chunkSize),this.chunks.push(r),this.maxCursor+=r.length,this._initReuseChunk===null&&(this._initReuseChunk=r),r.set(t,0)):(this.chunks.push(t),this.maxCursor+=t.length)}this.cursor+=t.length}toBytes(t=!1){let r;if(this.chunks.length===1){let n=this.chunks[0];t&&this.cursor>n.length/2?(r=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):r=K(n,0,this.cursor)}else r=tt(this.chunks,this.cursor);return t&&this.reset(),r}};var d="CBOR decode error:",_e="CBOR encode error:",oe=[];oe[23]=1;oe[24]=2;oe[25]=3;oe[26]=5;oe[27]=9;function O(e,t,r){if(e.length-t<r)throw new Error(`${d} not enough data for type`)}var x=[24,256,65536,4294967296,BigInt("18446744073709551616")];function b(e,t,r){O(e,t,1);let n=e[t];if(r.strict===!0&&n<x[0])throw new Error(`${d} integer encoded in more bytes than necessary (strict decode)`);return n}function E(e,t,r){O(e,t,2);let n=e[t]<<8|e[t+1];if(r.strict===!0&&n<x[1])throw new Error(`${d} integer encoded in more bytes than necessary (strict decode)`);return n}function U(e,t,r){O(e,t,4);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(r.strict===!0&&n<x[2])throw new Error(`${d} integer encoded in more bytes than necessary (strict decode)`);return n}function v(e,t,r){O(e,t,8);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3],o=e[t+4]*16777216+(e[t+5]<<16)+(e[t+6]<<8)+e[t+7],s=(BigInt(n)<<BigInt(32))+BigInt(o);if(r.strict===!0&&s<x[3])throw new Error(`${d} integer encoded in more bytes than necessary (strict decode)`);if(s<=Number.MAX_SAFE_INTEGER)return Number(s);if(r.allowBigInt===!0)return s;throw new Error(`${d} integers outside of the safe integer range are not supported`)}function ot(e,t,r,n){return new a(i.uint,b(e,t+1,n),2)}function it(e,t,r,n){return new a(i.uint,E(e,t+1,n),3)}function st(e,t,r,n){return new a(i.uint,U(e,t+1,n),5)}function ct(e,t,r,n){return new a(i.uint,v(e,t+1,n),9)}function T(e,t){return y(e,0,t.value)}function y(e,t,r){if(r<x[0]){let n=Number(r);e.push([t|n])}else if(r<x[1]){let n=Number(r);e.push([t|24,n])}else if(r<x[2]){let n=Number(r);e.push([t|25,n>>>8,n&255])}else if(r<x[3]){let n=Number(r);e.push([t|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(r);if(n<x[4]){let o=[t|27,0,0,0,0,0,0,0],s=Number(n&BigInt(4294967295)),u=Number(n>>BigInt(32)&BigInt(4294967295));o[8]=s&255,s=s>>8,o[7]=s&255,s=s>>8,o[6]=s&255,s=s>>8,o[5]=s&255,o[4]=u&255,u=u>>8,o[3]=u&255,u=u>>8,o[2]=u&255,u=u>>8,o[1]=u&255,e.push(o)}else throw new Error(`${d} encountered BigInt larger than allowable range`)}}T.encodedSize=function(t){return y.encodedSize(t.value)};y.encodedSize=function(t){return t<x[0]?1:t<x[1]?2:t<x[2]?3:t<x[3]?5:9};T.compareTokens=function(t,r){return t.value<r.value?-1:t.value>r.value?1:0};function at(e,t,r,n){return new a(i.negint,-1-b(e,t+1,n),2)}function ut(e,t,r,n){return new a(i.negint,-1-E(e,t+1,n),3)}function ft(e,t,r,n){return new a(i.negint,-1-U(e,t+1,n),5)}var Ne=BigInt(-1),dt=BigInt(1);function lt(e,t,r,n){let o=v(e,t+1,n);if(typeof o!="bigint"){let s=-1-o;if(s>=Number.MIN_SAFE_INTEGER)return new a(i.negint,s,9)}if(n.allowBigInt!==!0)throw new Error(`${d} integers outside of the safe integer range are not supported`);return new a(i.negint,Ne-BigInt(o),9)}function xe(e,t){let r=t.value,n=typeof r=="bigint"?r*Ne-dt:r*-1-1;y(e,t.type.majorEncoded,n)}xe.encodedSize=function(t){let r=t.value,n=typeof r=="bigint"?r*Ne-dt:r*-1-1;return n<x[0]?1:n<x[1]?2:n<x[2]?3:n<x[3]?5:9};xe.compareTokens=function(t,r){return t.value<r.value?1:t.value>r.value?-1:0};function ie(e,t,r,n){O(e,t,r+n);let o=K(e,t+r,t+r+n);return new a(i.bytes,o,r+n)}function pt(e,t,r,n){return ie(e,t,1,r)}function ht(e,t,r,n){return ie(e,t,2,b(e,t+1,n))}function mt(e,t,r,n){return ie(e,t,3,E(e,t+1,n))}function xt(e,t,r,n){return ie(e,t,5,U(e,t+1,n))}function yt(e,t,r,n){let o=v(e,t+1,n);if(typeof o=="bigint")throw new Error(`${d} 64-bit integer bytes lengths not supported`);return ie(e,t,9,o)}function ye(e){return e.encodedBytes===void 0&&(e.encodedBytes=e.type===i.string?et(e.value):e.value),e.encodedBytes}function X(e,t){let r=ye(t);y(e,t.type.majorEncoded,r.length),e.push(r)}X.encodedSize=function(t){let r=ye(t);return y.encodedSize(r.length)+r.length};X.compareTokens=function(t,r){return zr(ye(t),ye(r))};function zr(e,t){return e.length<t.length?-1:e.length>t.length?1:nt(e,t)}function se(e,t,r,n,o){let s=r+n;O(e,t,s);let u=new a(i.string,Ye(e,t+r,t+s),s);return o.retainStringBytes===!0&&(u.byteValue=K(e,t+r,t+s)),u}function gt(e,t,r,n){return se(e,t,1,r,n)}function wt(e,t,r,n){return se(e,t,2,b(e,t+1,n),n)}function bt(e,t,r,n){return se(e,t,3,E(e,t+1,n),n)}function Et(e,t,r,n){return se(e,t,5,U(e,t+1,n),n)}function Ut(e,t,r,n){let o=v(e,t+1,n);if(typeof o=="bigint")throw new Error(`${d} 64-bit integer string lengths not supported`);return se(e,t,9,o,n)}var vt=X;function H(e,t,r,n){return new a(i.array,n,r)}function At(e,t,r,n){return H(e,t,1,r)}function Tt(e,t,r,n){return H(e,t,2,b(e,t+1,n))}function kt(e,t,r,n){return H(e,t,3,E(e,t+1,n))}function St(e,t,r,n){return H(e,t,5,U(e,t+1,n))}function Bt(e,t,r,n){let o=v(e,t+1,n);if(typeof o=="bigint")throw new Error(`${d} 64-bit integer array lengths not supported`);return H(e,t,9,o)}function Ct(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${d} indefinite length items not allowed`);return H(e,t,1,1/0)}function ge(e,t){y(e,i.array.majorEncoded,t.value)}ge.compareTokens=T.compareTokens;ge.encodedSize=function(t){return y.encodedSize(t.value)};function Q(e,t,r,n){return new a(i.map,n,r)}function It(e,t,r,n){return Q(e,t,1,r)}function _t(e,t,r,n){return Q(e,t,2,b(e,t+1,n))}function Nt(e,t,r,n){return Q(e,t,3,E(e,t+1,n))}function $t(e,t,r,n){return Q(e,t,5,U(e,t+1,n))}function Mt(e,t,r,n){let o=v(e,t+1,n);if(typeof o=="bigint")throw new Error(`${d} 64-bit integer map lengths not supported`);return Q(e,t,9,o)}function Dt(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${d} indefinite length items not allowed`);return Q(e,t,1,1/0)}function we(e,t){y(e,i.map.majorEncoded,t.value)}we.compareTokens=T.compareTokens;we.encodedSize=function(t){return y.encodedSize(t.value)};function zt(e,t,r,n){return new a(i.tag,r,1)}function Ot(e,t,r,n){return new a(i.tag,b(e,t+1,n),2)}function Ft(e,t,r,n){return new a(i.tag,E(e,t+1,n),3)}function Vt(e,t,r,n){return new a(i.tag,U(e,t+1,n),5)}function Lt(e,t,r,n){return new a(i.tag,v(e,t+1,n),9)}function be(e,t){y(e,i.tag.majorEncoded,t.value)}be.compareTokens=T.compareTokens;be.encodedSize=function(t){return y.encodedSize(t.value)};var Pr=20,jr=21,qr=22,Gr=23;function Rt(e,t,r,n){if(n.allowUndefined===!1)throw new Error(`${d} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new a(i.null,null,1):new a(i.undefined,void 0,1)}function Pt(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${d} indefinite length items not allowed`);return new a(i.break,void 0,1)}function $e(e,t,r){if(r){if(r.allowNaN===!1&&Number.isNaN(e))throw new Error(`${d} NaN values are not supported`);if(r.allowInfinity===!1&&(e===1/0||e===-1/0))throw new Error(`${d} Infinity values are not supported`)}return new a(i.float,e,t)}function jt(e,t,r,n){return $e(Me(e,t+1),3,n)}function qt(e,t,r,n){return $e(De(e,t+1),5,n)}function Gt(e,t,r,n){return $e(Ht(e,t+1),9,n)}function Ee(e,t,r){let n=t.value;if(n===!1)e.push([i.float.majorEncoded|Pr]);else if(n===!0)e.push([i.float.majorEncoded|jr]);else if(n===null)e.push([i.float.majorEncoded|qr]);else if(n===void 0)e.push([i.float.majorEncoded|Gr]);else{let o,s=!1;(!r||r.float64!==!0)&&(Kt(n),o=Me(C,1),n===o||Number.isNaN(n)?(C[0]=249,e.push(C.slice(0,3)),s=!0):(Xt(n),o=De(C,1),n===o&&(C[0]=250,e.push(C.slice(0,5)),s=!0))),s||(Jr(n),o=Ht(C,1),C[0]=251,e.push(C.slice(0,9)))}}Ee.encodedSize=function(t,r){let n=t.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!r||r.float64!==!0){Kt(n);let o=Me(C,1);if(n===o||Number.isNaN(n))return 3;if(Xt(n),o=De(C,1),n===o)return 5}return 9};var Jt=new ArrayBuffer(9),k=new DataView(Jt,1),C=new Uint8Array(Jt,0);function Kt(e){if(e===1/0)k.setUint16(0,31744,!1);else if(e===-1/0)k.setUint16(0,64512,!1);else if(Number.isNaN(e))k.setUint16(0,32256,!1);else{k.setFloat32(0,e);let t=k.getUint32(0),r=(t&2139095040)>>23,n=t&8388607;if(r===255)k.setUint16(0,31744,!1);else if(r===0)k.setUint16(0,(e&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?k.setUint16(0,0):o<-14?k.setUint16(0,(t&2147483648)>>16|1<<24+o,!1):k.setUint16(0,(t&2147483648)>>16|o+15<<10|n>>13,!1)}}}function Me(e,t){if(e.length-t<2)throw new Error(`${d} not enough data for float16`);let r=(e[t]<<8)+e[t+1];if(r===31744)return 1/0;if(r===64512)return-1/0;if(r===32256)return NaN;let n=r>>10&31,o=r&1023,s;return n===0?s=o*2**-24:n!==31?s=(o+1024)*2**(n-25):s=o===0?1/0:NaN,r&32768?-s:s}function Xt(e){k.setFloat32(0,e,!1)}function De(e,t){if(e.length-t<4)throw new Error(`${d} not enough data for float32`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,4).getFloat32(0,!1)}function Jr(e){k.setFloat64(0,e,!1)}function Ht(e,t){if(e.length-t<8)throw new Error(`${d} not enough data for float64`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,8).getFloat64(0,!1)}Ee.compareTokens=T.compareTokens;function l(e,t,r){throw new Error(`${d} encountered invalid minor (${r}) for major ${e[t]>>>5}`)}function Ue(e){return()=>{throw new Error(`${d} ${e}`)}}var c=[];for(let e=0;e<=23;e++)c[e]=l;c[24]=ot;c[25]=it;c[26]=st;c[27]=ct;c[28]=l;c[29]=l;c[30]=l;c[31]=l;for(let e=32;e<=55;e++)c[e]=l;c[56]=at;c[57]=ut;c[58]=ft;c[59]=lt;c[60]=l;c[61]=l;c[62]=l;c[63]=l;for(let e=64;e<=87;e++)c[e]=pt;c[88]=ht;c[89]=mt;c[90]=xt;c[91]=yt;c[92]=l;c[93]=l;c[94]=l;c[95]=Ue("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)c[e]=gt;c[120]=wt;c[121]=bt;c[122]=Et;c[123]=Ut;c[124]=l;c[125]=l;c[126]=l;c[127]=Ue("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)c[e]=At;c[152]=Tt;c[153]=kt;c[154]=St;c[155]=Bt;c[156]=l;c[157]=l;c[158]=l;c[159]=Ct;for(let e=160;e<=183;e++)c[e]=It;c[184]=_t;c[185]=Nt;c[186]=$t;c[187]=Mt;c[188]=l;c[189]=l;c[190]=l;c[191]=Dt;for(let e=192;e<=215;e++)c[e]=zt;c[216]=Ot;c[217]=Ft;c[218]=Vt;c[219]=Lt;c[220]=l;c[221]=l;c[222]=l;c[223]=l;for(let e=224;e<=243;e++)c[e]=Ue("simple values are not supported");c[244]=l;c[245]=l;c[246]=l;c[247]=Rt;c[248]=Ue("simple values are not supported");c[249]=jt;c[250]=qt;c[251]=Gt;c[252]=l;c[253]=l;c[254]=l;c[255]=Pt;var I=[];for(let e=0;e<24;e++)I[e]=new a(i.uint,e,1);for(let e=-1;e>=-24;e--)I[31-e]=new a(i.negint,e,1);I[64]=new a(i.bytes,new Uint8Array(0),1);I[96]=new a(i.string,"",1);I[128]=new a(i.array,0,1);I[160]=new a(i.map,0,1);I[244]=new a(i.false,!1,1);I[245]=new a(i.true,!0,1);I[246]=new a(i.null,null,1);function Qt(e){switch(e.type){case i.false:return M([244]);case i.true:return M([245]);case i.null:return M([246]);case i.bytes:return e.value.length?void 0:M([64]);case i.string:return e.value===""?M([96]):void 0;case i.array:return e.value===0?M([128]):void 0;case i.map:return e.value===0?M([160]):void 0;case i.uint:return e.value<24?M([Number(e.value)]):void 0;case i.negint:if(e.value>=-24)return M([31-Number(e.value)])}}var Xr={float64:!1,mapSorter:Wr,quickEncodeToken:Qt};function Hr(){let e=[];return e[i.uint.major]=T,e[i.negint.major]=xe,e[i.bytes.major]=X,e[i.string.major]=vt,e[i.array.major]=ge,e[i.map.major]=we,e[i.tag.major]=be,e[i.float.major]=Ee,e}var Wt=Hr(),ze=new ne,Ae=class e{constructor(t,r){this.obj=t,this.parent=r}includes(t){let r=this;do if(r.obj===t)return!0;while(r=r.parent);return!1}static createCheck(t,r){if(t&&t.includes(r))throw new Error(`${_e} object contains circular references`);return new e(r,t)}},L={null:new a(i.null,null),undefined:new a(i.undefined,void 0),true:new a(i.true,!0),false:new a(i.false,!1),emptyArray:new a(i.array,0),emptyMap:new a(i.map,0)},R={number(e,t,r,n){return!Number.isInteger(e)||!Number.isSafeInteger(e)?new a(i.float,e):e>=0?new a(i.uint,e):new a(i.negint,e)},bigint(e,t,r,n){return e>=BigInt(0)?new a(i.uint,e):new a(i.negint,e)},Uint8Array(e,t,r,n){return new a(i.bytes,e)},string(e,t,r,n){return new a(i.string,e)},boolean(e,t,r,n){return e?L.true:L.false},null(e,t,r,n){return L.null},undefined(e,t,r,n){return L.undefined},ArrayBuffer(e,t,r,n){return new a(i.bytes,new Uint8Array(e))},DataView(e,t,r,n){return new a(i.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength))},Array(e,t,r,n){if(!e.length)return r.addBreakTokens===!0?[L.emptyArray,new a(i.break)]:L.emptyArray;n=Ae.createCheck(n,e);let o=[],s=0;for(let u of e)o[s++]=ve(u,r,n);return r.addBreakTokens?[new a(i.array,e.length),o,new a(i.break)]:[new a(i.array,e.length),o]},Object(e,t,r,n){let o=t!=="Object",s=o?e.keys():Object.keys(e),u=o?e.size:s.length;if(!u)return r.addBreakTokens===!0?[L.emptyMap,new a(i.break)]:L.emptyMap;n=Ae.createCheck(n,e);let f=[],p=0;for(let g of s)f[p++]=[ve(g,r,n),ve(o?e.get(g):e[g],r,n)];return Qr(f,r),r.addBreakTokens?[new a(i.map,u),f,new a(i.break)]:[new a(i.map,u),f]}};R.Map=R.Object;R.Buffer=R.Uint8Array;for(let e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))R[`${e}Array`]=R.DataView;function ve(e,t={},r){let n=He(e),o=t&&t.typeEncoders&&t.typeEncoders[n]||R[n];if(typeof o=="function"){let u=o(e,n,t,r);if(u!=null)return u}let s=R[n];if(!s)throw new Error(`${_e} unsupported type: ${n}`);return s(e,n,t,r)}function Qr(e,t){t.mapSorter&&e.sort(t.mapSorter)}function Wr(e,t){let r=Array.isArray(e[0])?e[0][0]:e[0],n=Array.isArray(t[0])?t[0][0]:t[0];if(r.type!==n.type)return r.type.compare(n.type);let o=r.type.major,s=Wt[o].compareTokens(r,n);return s===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),s}function Zt(e,t,r,n){if(Array.isArray(t))for(let o of t)Zt(e,o,r,n);else r[t.type.major](e,t,n)}function Zr(e,t,r){let n=ve(e,r);if(!Array.isArray(n)&&r.quickEncodeToken){let o=r.quickEncodeToken(n);if(o)return o;let s=t[n.type.major];if(s.encodedSize){let u=s.encodedSize(n,r),f=new ne(u);if(s(f,n,r),f.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return Ie(f.chunks[0])}}return ze.reset(),Zt(ze,n,t,r),ze.toBytes(!0)}function Oe(e,t){return t=Object.assign({},Xr,t),Zr(e,Wt,t)}var Yr={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},Te=class{constructor(t,r={}){this._pos=0,this.data=t,this.options=r}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let t=this.data[this._pos],r=I[t];if(r===void 0){let n=c[t];if(!n)throw new Error(`${d} no decoder for major type ${t>>>5} (byte 0x${t.toString(16).padStart(2,"0")})`);let o=t&31;r=n(this.data,this._pos,o,this.options)}return this._pos+=r.encodedLength,r}},ce=Symbol.for("DONE"),ke=Symbol.for("BREAK");function en(e,t,r){let n=[];for(let o=0;o<e.value;o++){let s=W(t,r);if(s===ke){if(e.value===1/0)break;throw new Error(`${d} got unexpected break to lengthed array`)}if(s===ce)throw new Error(`${d} found array but not enough entries (got ${o}, expected ${e.value})`);n[o]=s}return n}function tn(e,t,r){let n=r.useMaps===!0,o=n?void 0:{},s=n?new Map:void 0;for(let u=0;u<e.value;u++){let f=W(t,r);if(f===ke){if(e.value===1/0)break;throw new Error(`${d} got unexpected break to lengthed map`)}if(f===ce)throw new Error(`${d} found map but not enough entries (got ${u} [no key], expected ${e.value})`);if(n!==!0&&typeof f!="string")throw new Error(`${d} non-string keys not supported (got ${typeof f})`);if(r.rejectDuplicateMapKeys===!0&&(n&&s.has(f)||!n&&f in o))throw new Error(`${d} found repeat map key "${f}"`);let p=W(t,r);if(p===ce)throw new Error(`${d} found map but not enough entries (got ${u} [no value], expected ${e.value})`);n?s.set(f,p):o[f]=p}return n?s:o}function W(e,t){if(e.done())return ce;let r=e.next();if(r.type===i.break)return ke;if(r.type.terminal)return r.value;if(r.type===i.array)return en(r,e,t);if(r.type===i.map)return tn(r,e,t);if(r.type===i.tag){if(t.tags&&typeof t.tags[r.value]=="function"){let n=W(e,t);return t.tags[r.value](n)}throw new Error(`${d} tag not supported (${r.value})`)}throw new Error("unsupported")}function Yt(e,t){if(!(e instanceof Uint8Array))throw new Error(`${d} data to decode must be a Uint8Array`);t=Object.assign({},Yr,t);let r=t.tokenizer||new Te(e,t),n=W(r,t);if(n===ce)throw new Error(`${d} did not find any content to decode`);if(n===ke)throw new Error(`${d} got unexpected break`);return[n,e.subarray(r.pos())]}function Fe(e,t){let[r,n]=Yt(e,t);if(n.length>0)throw new Error(`${d} too many terminals, data makes no sense`);return r}var Vo=new Uint8Array(0);function er(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function Z(e){if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}function nn(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<e.length;o++){var s=e.charAt(o),u=s.charCodeAt(0);if(r[u]!==255)throw new TypeError(s+" is ambiguous");r[u]=o}var f=e.length,p=e.charAt(0),g=Math.log(f)/Math.log(256),h=Math.log(256)/Math.log(f);function G(m){if(m instanceof Uint8Array||(ArrayBuffer.isView(m)?m=new Uint8Array(m.buffer,m.byteOffset,m.byteLength):Array.isArray(m)&&(m=Uint8Array.from(m))),!(m instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(m.length===0)return"";for(var w=0,P=0,S=0,_=m.length;S!==_&&m[S]===0;)S++,w++;for(var N=(_-S)*h+1>>>0,A=new Uint8Array(N);S!==_;){for(var $=m[S],V=0,B=N-1;($!==0||V<P)&&B!==-1;B--,V++)$+=256*A[B]>>>0,A[B]=$%f>>>0,$=$/f>>>0;if($!==0)throw new Error("Non-zero carry");P=V,S++}for(var z=N-P;z!==N&&A[z]===0;)z++;for(var he=p.repeat(w);z<N;++z)he+=e.charAt(A[z]);return he}function pe(m){if(typeof m!="string")throw new TypeError("Expected String");if(m.length===0)return new Uint8Array;var w=0;if(m[w]!==" "){for(var P=0,S=0;m[w]===p;)P++,w++;for(var _=(m.length-w)*g+1>>>0,N=new Uint8Array(_);m[w];){var A=r[m.charCodeAt(w)];if(A===255)return;for(var $=0,V=_-1;(A!==0||$<S)&&V!==-1;V--,$++)A+=f*N[V]>>>0,N[V]=A%256>>>0,A=A/256>>>0;if(A!==0)throw new Error("Non-zero carry");S=$,w++}if(m[w]!==" "){for(var B=_-S;B!==_&&N[B]===0;)B++;for(var z=new Uint8Array(P+(_-B)),he=P;B!==_;)z[he++]=N[B++];return z}}}function br(m){var w=pe(m);if(w)return w;throw new Error(`Non-${t} character`)}return{encode:G,decodeUnsafe:pe,decode:br}}var on=nn,sn=on,tr=sn;var Ve=class{name;prefix;baseEncode;constructor(t,r,n){this.name=t,this.prefix=r,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},Le=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,r,n){this.name=t,this.prefix=r;let o=r.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return rr(this,t)}},Re=class{decoders;constructor(t){this.decoders=t}or(t){return rr(this,t)}decode(t){let r=t[0],n=this.decoders[r];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function rr(e,t){return new Re({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var Pe=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,r,n,o){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new Ve(t,r,n),this.decoder=new Le(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function nr({name:e,prefix:t,encode:r,decode:n}){return new Pe(e,t,r,n)}function Y({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=tr(r,e);return nr({prefix:t,name:e,encode:n,decode:s=>Z(o(s))})}function cn(e,t,r,n){let o={};for(let h=0;h<t.length;++h)o[t[h]]=h;let s=e.length;for(;e[s-1]==="=";)--s;let u=new Uint8Array(s*r/8|0),f=0,p=0,g=0;for(let h=0;h<s;++h){let G=o[e[h]];if(G===void 0)throw new SyntaxError(`Non-${n} character`);p=p<<r|G,f+=r,f>=8&&(f-=8,u[g++]=255&p>>f)}if(f>=r||255&p<<8-f)throw new SyntaxError("Unexpected end of data");return u}function an(e,t,r){let n=t[t.length-1]==="=",o=(1<<r)-1,s="",u=0,f=0;for(let p=0;p<e.length;++p)for(f=f<<8|e[p],u+=8;u>r;)u-=r,s+=t[o&f>>u];if(u!==0&&(s+=t[o&f<<r-u]),n)for(;s.length*r&7;)s+="=";return s}function D({name:e,prefix:t,bitsPerChar:r,alphabet:n}){return nr({prefix:t,name:e,encode(o){return an(o,n,r)},decode(o){return cn(o,n,r,e)}})}var ae=D({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Jo=D({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Ko=D({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Xo=D({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Ho=D({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Qo=D({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Wo=D({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Zo=D({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Yo=D({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Se=Y({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),ri=Y({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var F=Y({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),ii=Y({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var un=sr,or=128,fn=127,dn=~fn,ln=Math.pow(2,31);function sr(e,t,r){t=t||[],r=r||0;for(var n=r;e>=ln;)t[r++]=e&255|or,e/=128;for(;e&dn;)t[r++]=e&255|or,e>>>=7;return t[r]=e|0,sr.bytes=r-n+1,t}var pn=je,hn=128,ir=127;function je(e,n){var r=0,n=n||0,o=0,s=n,u,f=e.length;do{if(s>=f)throw je.bytes=0,new RangeError("Could not decode varint");u=e[s++],r+=o<28?(u&ir)<<o:(u&ir)*Math.pow(2,o),o+=7}while(u>=hn);return je.bytes=s-n,r}var mn=Math.pow(2,7),xn=Math.pow(2,14),yn=Math.pow(2,21),gn=Math.pow(2,28),wn=Math.pow(2,35),bn=Math.pow(2,42),En=Math.pow(2,49),Un=Math.pow(2,56),vn=Math.pow(2,63),An=function(e){return e<mn?1:e<xn?2:e<yn?3:e<gn?4:e<wn?5:e<bn?6:e<En?7:e<Un?8:e<vn?9:10},Tn={encode:un,decode:pn,encodingLength:An},kn=Tn,ue=kn;function fe(e,t=0){return[ue.decode(e,t),ue.decode.bytes]}function ee(e,t,r=0){return ue.encode(e,t,r),t}function te(e){return ue.encodingLength(e)}function de(e,t){let r=t.byteLength,n=te(e),o=n+te(r),s=new Uint8Array(o+r);return ee(e,s,0),ee(r,s,n),s.set(t,o),new re(e,r,t,s)}function ar(e){let t=Z(e),[r,n]=fe(t),[o,s]=fe(t.subarray(n)),u=t.subarray(n+s);if(u.byteLength!==o)throw new Error("Incorrect length");return new re(r,o,u,t)}function ur(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&er(e.bytes,r.bytes)}}var re=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};function dr(e,t){let{bytes:r,version:n}=e;switch(n){case 0:return Bn(r,qe(e),t??F.encoder);default:return Cn(r,qe(e),t??ae.encoder)}}var lr=new WeakMap;function qe(e){let t=lr.get(e);if(t==null){let r=new Map;return lr.set(e,r),r}return t}var q=class e{code;version;multihash;bytes;"/";constructor(t,r,n,o){this.code=r,this.version=t,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:t,multihash:r}=this;if(t!==le)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==In)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return e.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:r}=this.multihash,n=de(t,r);return e.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(t){return e.equals(this,t)}static equals(t,r){let n=r;return n!=null&&t.code===n.code&&t.version===n.version&&ur(t.multihash,n.multihash)}toString(t){return dr(this,t)}toJSON(){return{"/":dr(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let r=t;if(r instanceof e)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:s,bytes:u}=r;return new e(n,o,s,u??pr(n,o,s.bytes))}else if(r[_n]===!0){let{version:n,multihash:o,code:s}=r,u=ar(o);return e.create(n,s,u)}else return null}static create(t,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(r!==le)throw new Error(`Version 0 CID must use dag-pb (code: ${le}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=pr(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,le,t)}static createV1(t,r){return e.create(1,t,r)}static decode(t){let[r,n]=e.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(t){let r=e.inspectBytes(t),n=r.size-r.multihashSize,o=Z(t.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let s=o.subarray(r.multihashSize-r.digestSize),u=new re(r.multihashCode,r.digestSize,s,o);return[r.version===0?e.createV0(u):e.createV1(r.codec,u),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[G,pe]=fe(t.subarray(r));return r+=pe,G},o=n(),s=le;if(o===18?(o=0,r=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let u=r,f=n(),p=n(),g=r+p,h=g-u;return{version:o,codec:s,multihashCode:f,digestSize:p,multihashSize:h,size:g}}static parse(t,r){let[n,o]=Sn(t,r),s=e.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return qe(s).set(n,t),s}};function Sn(e,t){switch(e[0]){case"Q":{let r=t??F;return[F.prefix,r.decode(`${F.prefix}${e}`)]}case F.prefix:{let r=t??F;return[F.prefix,r.decode(e)]}case ae.prefix:{let r=t??ae;return[ae.prefix,r.decode(e)]}case Se.prefix:{let r=t??Se;return[Se.prefix,r.decode(e)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}}function Bn(e,t,r){let{prefix:n}=r;if(n!==F.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=t.get(n);if(o==null){let s=r.encode(e).slice(1);return t.set(n,s),s}else return o}function Cn(e,t,r){let{prefix:n}=r,o=t.get(n);if(o==null){let s=r.encode(e);return t.set(n,s),s}else return o}var le=112,In=18;function pr(e,t,r){let n=te(e),o=n+te(t),s=new Uint8Array(o+r.byteLength);return ee(e,s,0),ee(t,s,n),s.set(r,o),s}var _n=Symbol.for("@ipld/js-cid/CID");var hr=42;function Nn(e){return e instanceof ArrayBuffer?new Uint8Array(e,0,e.byteLength):e}function $n(e){if(e.asCID!==e&&e["/"]!==e.bytes)return null;let t=q.asCID(e);if(!t)return null;let r=new Uint8Array(t.bytes.byteLength+1);return r.set(t.bytes,1),[new a(i.tag,hr),new a(i.bytes,r)]}function Mn(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")}function Dn(e){if(Number.isNaN(e))throw new Error("`NaN` is not supported by the IPLD Data Model and cannot be encoded");if(e===1/0||e===-1/0)throw new Error("`Infinity` and `-Infinity` is not supported by the IPLD Data Model and cannot be encoded");return null}var Ge={float64:!0,typeEncoders:{Object:$n,undefined:Mn,number:Dn}},yi={...Ge,typeEncoders:{...Ge.typeEncoders}};function zn(e){if(e[0]!==0)throw new Error("Invalid CID for CBOR tag 42; expected leading 0x00");return q.decode(e.subarray(1))}var Be={allowIndefinite:!1,coerceUndefinedToNull:!0,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,rejectDuplicateMapKeys:!0,tags:[]};Be.tags[hr]=zn;var gi={...Be,tags:Be.tags.slice()};var mr=113,xr=e=>Oe(e,Ge),yr=e=>Fe(Nn(e),Be);function Ke({name:e,code:t,encode:r}){return new Je(e,t,r)}var Je=class{name;code;encode;constructor(t,r,n){this.name=t,this.code=r,this.encode=n}digest(t){if(t instanceof Uint8Array){let r=this.encode(t);return r instanceof Uint8Array?de(this.code,r):r.then(n=>de(this.code,n))}else throw Error("Unknown type, must be binary type")}};function gr(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}var wr=Ke({name:"sha2-256",code:18,encode:gr("SHA-256")}),Ei=Ke({name:"sha2-512",code:19,encode:gr("SHA-512")});var Xe=class{components;constructor(t){this.components=t}async add(t,r={}){let n=xr(t),o=await(r.hasher??wr).digest(n),s=q.createV1(mr,o);return await this.components.blockstore.put(s,n,r),s}async get(t,r={}){let n=await this.components.blockstore.get(t,r);return yr(n)}};function Fn(e){return new Xe(e)}return kr(Vn);})();
|
|
2
|
+
"use strict";var HeliaDagCbor=(()=>{var Ce=Object.defineProperty;var Er=Object.getOwnPropertyDescriptor;var Ur=Object.getOwnPropertyNames;var vr=Object.prototype.hasOwnProperty;var Ar=(e,t)=>{for(var r in t)Ce(e,r,{get:t[r],enumerable:!0})},Tr=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ur(t))!vr.call(e,o)&&o!==r&&Ce(e,o,{get:()=>t[o],enumerable:!(n=Er(t,o))||n.enumerable});return e};var kr=e=>Tr(Ce({},"__esModule",{value:!0}),e);var Vn={};Ar(Vn,{dagCbor:()=>Fn});var Sr=["string","number","bigint","symbol"],Br=["Function","Generator","AsyncGenerator","GeneratorFunction","AsyncGeneratorFunction","AsyncFunction","Observable","Array","Buffer","Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function He(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0||e===!1)return"boolean";let t=typeof e;if(Sr.includes(t))return t;if(t==="function")return"Function";if(Array.isArray(e))return"Array";if(Cr(e))return"Buffer";let r=Ir(e);return r||"Object"}function Cr(e){return e&&e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer.call(null,e)}function Ir(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(Br.includes(t))return t}var i=class{constructor(t,r,n){this.major=t,this.majorEncoded=t<<5,this.name=r,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(t){return this.major<t.major?-1:this.major>t.major?1:0}};i.uint=new i(0,"uint",!0);i.negint=new i(1,"negint",!0);i.bytes=new i(2,"bytes",!0);i.string=new i(3,"string",!0);i.array=new i(4,"array",!1);i.map=new i(5,"map",!1);i.tag=new i(6,"tag",!1);i.float=new i(7,"float",!0);i.false=new i(7,"false",!0);i.true=new i(7,"true",!0);i.null=new i(7,"null",!0);i.undefined=new i(7,"undefined",!0);i.break=new i(7,"break",!0);var a=class{constructor(t,r,n){this.type=t,this.value=r,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var J=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",_r=new TextDecoder,Nr=new TextEncoder;function me(e){return J&&globalThis.Buffer.isBuffer(e)}function Ie(e){return e instanceof Uint8Array?me(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var Ye=J?(e,t,r)=>r-t>64?globalThis.Buffer.from(e.subarray(t,r)).toString("utf8"):We(e,t,r):(e,t,r)=>r-t>64?_r.decode(e.subarray(t,r)):We(e,t,r),et=J?e=>e.length>64?globalThis.Buffer.from(e):Qe(e):e=>e.length>64?Nr.encode(e):Qe(e),M=e=>Uint8Array.from(e),K=J?(e,t,r)=>me(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),tt=J?(e,t)=>(e=e.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),Ie(globalThis.Buffer.concat(e,t))):(e,t)=>{let r=new Uint8Array(t),n=0;for(let o of e)n+o.length>r.length&&(o=o.subarray(0,r.length-n)),r.set(o,n),n+=o.length;return r},rt=J?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function nt(e,t){if(me(e)&&me(t))return e.compare(t);for(let r=0;r<e.length;r++)if(e[r]!==t[r])return e[r]<t[r]?-1:1;return 0}function Qe(e){let t=[],r=0;for(let n=0;n<e.length;n++){let o=e.charCodeAt(n);o<128?t[r++]=o:o<2048?(t[r++]=o>>6|192,t[r++]=o&63|128):(o&64512)===55296&&n+1<e.length&&(e.charCodeAt(n+1)&64512)===56320?(o=65536+((o&1023)<<10)+(e.charCodeAt(++n)&1023),t[r++]=o>>18|240,t[r++]=o>>12&63|128,t[r++]=o>>6&63|128,t[r++]=o&63|128):(t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=o&63|128)}return t}function We(e,t,r){let n=[];for(;t<r;){let o=e[t],s=null,u=o>239?4:o>223?3:o>191?2:1;if(t+u<=r){let f,p,g,h;switch(u){case 1:o<128&&(s=o);break;case 2:f=e[t+1],(f&192)===128&&(h=(o&31)<<6|f&63,h>127&&(s=h));break;case 3:f=e[t+1],p=e[t+2],(f&192)===128&&(p&192)===128&&(h=(o&15)<<12|(f&63)<<6|p&63,h>2047&&(h<55296||h>57343)&&(s=h));break;case 4:f=e[t+1],p=e[t+2],g=e[t+3],(f&192)===128&&(p&192)===128&&(g&192)===128&&(h=(o&15)<<18|(f&63)<<12|(p&63)<<6|g&63,h>65535&&h<1114112&&(s=h))}}s===null?(s=65533,u=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|s&1023),n.push(s),t+=u}return $r(n)}var Ze=4096;function $r(e){let t=e.length;if(t<=Ze)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=Ze));return r}var Mr=256,ne=class{constructor(t=Mr){this.chunkSize=t,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.cursor=0,this.maxCursor=-1,this.chunks.length&&(this.chunks=[]),this._initReuseChunk!==null&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}push(t){let r=this.chunks[this.chunks.length-1];if(this.cursor+t.length<=this.maxCursor+1){let o=r.length-(this.maxCursor-this.cursor)-1;r.set(t,o)}else{if(r){let o=r.length-(this.maxCursor-this.cursor)-1;o<r.length&&(this.chunks[this.chunks.length-1]=r.subarray(0,o),this.maxCursor=this.cursor-1)}t.length<64&&t.length<this.chunkSize?(r=rt(this.chunkSize),this.chunks.push(r),this.maxCursor+=r.length,this._initReuseChunk===null&&(this._initReuseChunk=r),r.set(t,0)):(this.chunks.push(t),this.maxCursor+=t.length)}this.cursor+=t.length}toBytes(t=!1){let r;if(this.chunks.length===1){let n=this.chunks[0];t&&this.cursor>n.length/2?(r=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):r=K(n,0,this.cursor)}else r=tt(this.chunks,this.cursor);return t&&this.reset(),r}};var d="CBOR decode error:",_e="CBOR encode error:",oe=[];oe[23]=1;oe[24]=2;oe[25]=3;oe[26]=5;oe[27]=9;function O(e,t,r){if(e.length-t<r)throw new Error(`${d} not enough data for type`)}var x=[24,256,65536,4294967296,BigInt("18446744073709551616")];function b(e,t,r){O(e,t,1);let n=e[t];if(r.strict===!0&&n<x[0])throw new Error(`${d} integer encoded in more bytes than necessary (strict decode)`);return n}function E(e,t,r){O(e,t,2);let n=e[t]<<8|e[t+1];if(r.strict===!0&&n<x[1])throw new Error(`${d} integer encoded in more bytes than necessary (strict decode)`);return n}function U(e,t,r){O(e,t,4);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(r.strict===!0&&n<x[2])throw new Error(`${d} integer encoded in more bytes than necessary (strict decode)`);return n}function v(e,t,r){O(e,t,8);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3],o=e[t+4]*16777216+(e[t+5]<<16)+(e[t+6]<<8)+e[t+7],s=(BigInt(n)<<BigInt(32))+BigInt(o);if(r.strict===!0&&s<x[3])throw new Error(`${d} integer encoded in more bytes than necessary (strict decode)`);if(s<=Number.MAX_SAFE_INTEGER)return Number(s);if(r.allowBigInt===!0)return s;throw new Error(`${d} integers outside of the safe integer range are not supported`)}function ot(e,t,r,n){return new a(i.uint,b(e,t+1,n),2)}function it(e,t,r,n){return new a(i.uint,E(e,t+1,n),3)}function st(e,t,r,n){return new a(i.uint,U(e,t+1,n),5)}function ct(e,t,r,n){return new a(i.uint,v(e,t+1,n),9)}function T(e,t){return y(e,0,t.value)}function y(e,t,r){if(r<x[0]){let n=Number(r);e.push([t|n])}else if(r<x[1]){let n=Number(r);e.push([t|24,n])}else if(r<x[2]){let n=Number(r);e.push([t|25,n>>>8,n&255])}else if(r<x[3]){let n=Number(r);e.push([t|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(r);if(n<x[4]){let o=[t|27,0,0,0,0,0,0,0],s=Number(n&BigInt(4294967295)),u=Number(n>>BigInt(32)&BigInt(4294967295));o[8]=s&255,s=s>>8,o[7]=s&255,s=s>>8,o[6]=s&255,s=s>>8,o[5]=s&255,o[4]=u&255,u=u>>8,o[3]=u&255,u=u>>8,o[2]=u&255,u=u>>8,o[1]=u&255,e.push(o)}else throw new Error(`${d} encountered BigInt larger than allowable range`)}}T.encodedSize=function(t){return y.encodedSize(t.value)};y.encodedSize=function(t){return t<x[0]?1:t<x[1]?2:t<x[2]?3:t<x[3]?5:9};T.compareTokens=function(t,r){return t.value<r.value?-1:t.value>r.value?1:0};function at(e,t,r,n){return new a(i.negint,-1-b(e,t+1,n),2)}function ut(e,t,r,n){return new a(i.negint,-1-E(e,t+1,n),3)}function ft(e,t,r,n){return new a(i.negint,-1-U(e,t+1,n),5)}var Ne=BigInt(-1),dt=BigInt(1);function lt(e,t,r,n){let o=v(e,t+1,n);if(typeof o!="bigint"){let s=-1-o;if(s>=Number.MIN_SAFE_INTEGER)return new a(i.negint,s,9)}if(n.allowBigInt!==!0)throw new Error(`${d} integers outside of the safe integer range are not supported`);return new a(i.negint,Ne-BigInt(o),9)}function xe(e,t){let r=t.value,n=typeof r=="bigint"?r*Ne-dt:r*-1-1;y(e,t.type.majorEncoded,n)}xe.encodedSize=function(t){let r=t.value,n=typeof r=="bigint"?r*Ne-dt:r*-1-1;return n<x[0]?1:n<x[1]?2:n<x[2]?3:n<x[3]?5:9};xe.compareTokens=function(t,r){return t.value<r.value?1:t.value>r.value?-1:0};function ie(e,t,r,n){O(e,t,r+n);let o=K(e,t+r,t+r+n);return new a(i.bytes,o,r+n)}function pt(e,t,r,n){return ie(e,t,1,r)}function ht(e,t,r,n){return ie(e,t,2,b(e,t+1,n))}function mt(e,t,r,n){return ie(e,t,3,E(e,t+1,n))}function xt(e,t,r,n){return ie(e,t,5,U(e,t+1,n))}function yt(e,t,r,n){let o=v(e,t+1,n);if(typeof o=="bigint")throw new Error(`${d} 64-bit integer bytes lengths not supported`);return ie(e,t,9,o)}function ye(e){return e.encodedBytes===void 0&&(e.encodedBytes=e.type===i.string?et(e.value):e.value),e.encodedBytes}function X(e,t){let r=ye(t);y(e,t.type.majorEncoded,r.length),e.push(r)}X.encodedSize=function(t){let r=ye(t);return y.encodedSize(r.length)+r.length};X.compareTokens=function(t,r){return zr(ye(t),ye(r))};function zr(e,t){return e.length<t.length?-1:e.length>t.length?1:nt(e,t)}function se(e,t,r,n,o){let s=r+n;O(e,t,s);let u=new a(i.string,Ye(e,t+r,t+s),s);return o.retainStringBytes===!0&&(u.byteValue=K(e,t+r,t+s)),u}function gt(e,t,r,n){return se(e,t,1,r,n)}function wt(e,t,r,n){return se(e,t,2,b(e,t+1,n),n)}function bt(e,t,r,n){return se(e,t,3,E(e,t+1,n),n)}function Et(e,t,r,n){return se(e,t,5,U(e,t+1,n),n)}function Ut(e,t,r,n){let o=v(e,t+1,n);if(typeof o=="bigint")throw new Error(`${d} 64-bit integer string lengths not supported`);return se(e,t,9,o,n)}var vt=X;function H(e,t,r,n){return new a(i.array,n,r)}function At(e,t,r,n){return H(e,t,1,r)}function Tt(e,t,r,n){return H(e,t,2,b(e,t+1,n))}function kt(e,t,r,n){return H(e,t,3,E(e,t+1,n))}function St(e,t,r,n){return H(e,t,5,U(e,t+1,n))}function Bt(e,t,r,n){let o=v(e,t+1,n);if(typeof o=="bigint")throw new Error(`${d} 64-bit integer array lengths not supported`);return H(e,t,9,o)}function Ct(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${d} indefinite length items not allowed`);return H(e,t,1,1/0)}function ge(e,t){y(e,i.array.majorEncoded,t.value)}ge.compareTokens=T.compareTokens;ge.encodedSize=function(t){return y.encodedSize(t.value)};function Q(e,t,r,n){return new a(i.map,n,r)}function It(e,t,r,n){return Q(e,t,1,r)}function _t(e,t,r,n){return Q(e,t,2,b(e,t+1,n))}function Nt(e,t,r,n){return Q(e,t,3,E(e,t+1,n))}function $t(e,t,r,n){return Q(e,t,5,U(e,t+1,n))}function Mt(e,t,r,n){let o=v(e,t+1,n);if(typeof o=="bigint")throw new Error(`${d} 64-bit integer map lengths not supported`);return Q(e,t,9,o)}function Dt(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${d} indefinite length items not allowed`);return Q(e,t,1,1/0)}function we(e,t){y(e,i.map.majorEncoded,t.value)}we.compareTokens=T.compareTokens;we.encodedSize=function(t){return y.encodedSize(t.value)};function zt(e,t,r,n){return new a(i.tag,r,1)}function Ot(e,t,r,n){return new a(i.tag,b(e,t+1,n),2)}function Ft(e,t,r,n){return new a(i.tag,E(e,t+1,n),3)}function Vt(e,t,r,n){return new a(i.tag,U(e,t+1,n),5)}function Lt(e,t,r,n){return new a(i.tag,v(e,t+1,n),9)}function be(e,t){y(e,i.tag.majorEncoded,t.value)}be.compareTokens=T.compareTokens;be.encodedSize=function(t){return y.encodedSize(t.value)};var Pr=20,jr=21,qr=22,Gr=23;function Rt(e,t,r,n){if(n.allowUndefined===!1)throw new Error(`${d} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new a(i.null,null,1):new a(i.undefined,void 0,1)}function Pt(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${d} indefinite length items not allowed`);return new a(i.break,void 0,1)}function $e(e,t,r){if(r){if(r.allowNaN===!1&&Number.isNaN(e))throw new Error(`${d} NaN values are not supported`);if(r.allowInfinity===!1&&(e===1/0||e===-1/0))throw new Error(`${d} Infinity values are not supported`)}return new a(i.float,e,t)}function jt(e,t,r,n){return $e(Me(e,t+1),3,n)}function qt(e,t,r,n){return $e(De(e,t+1),5,n)}function Gt(e,t,r,n){return $e(Ht(e,t+1),9,n)}function Ee(e,t,r){let n=t.value;if(n===!1)e.push([i.float.majorEncoded|Pr]);else if(n===!0)e.push([i.float.majorEncoded|jr]);else if(n===null)e.push([i.float.majorEncoded|qr]);else if(n===void 0)e.push([i.float.majorEncoded|Gr]);else{let o,s=!1;(!r||r.float64!==!0)&&(Kt(n),o=Me(C,1),n===o||Number.isNaN(n)?(C[0]=249,e.push(C.slice(0,3)),s=!0):(Xt(n),o=De(C,1),n===o&&(C[0]=250,e.push(C.slice(0,5)),s=!0))),s||(Jr(n),o=Ht(C,1),C[0]=251,e.push(C.slice(0,9)))}}Ee.encodedSize=function(t,r){let n=t.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!r||r.float64!==!0){Kt(n);let o=Me(C,1);if(n===o||Number.isNaN(n))return 3;if(Xt(n),o=De(C,1),n===o)return 5}return 9};var Jt=new ArrayBuffer(9),k=new DataView(Jt,1),C=new Uint8Array(Jt,0);function Kt(e){if(e===1/0)k.setUint16(0,31744,!1);else if(e===-1/0)k.setUint16(0,64512,!1);else if(Number.isNaN(e))k.setUint16(0,32256,!1);else{k.setFloat32(0,e);let t=k.getUint32(0),r=(t&2139095040)>>23,n=t&8388607;if(r===255)k.setUint16(0,31744,!1);else if(r===0)k.setUint16(0,(e&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?k.setUint16(0,0):o<-14?k.setUint16(0,(t&2147483648)>>16|1<<24+o,!1):k.setUint16(0,(t&2147483648)>>16|o+15<<10|n>>13,!1)}}}function Me(e,t){if(e.length-t<2)throw new Error(`${d} not enough data for float16`);let r=(e[t]<<8)+e[t+1];if(r===31744)return 1/0;if(r===64512)return-1/0;if(r===32256)return NaN;let n=r>>10&31,o=r&1023,s;return n===0?s=o*2**-24:n!==31?s=(o+1024)*2**(n-25):s=o===0?1/0:NaN,r&32768?-s:s}function Xt(e){k.setFloat32(0,e,!1)}function De(e,t){if(e.length-t<4)throw new Error(`${d} not enough data for float32`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,4).getFloat32(0,!1)}function Jr(e){k.setFloat64(0,e,!1)}function Ht(e,t){if(e.length-t<8)throw new Error(`${d} not enough data for float64`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,8).getFloat64(0,!1)}Ee.compareTokens=T.compareTokens;function l(e,t,r){throw new Error(`${d} encountered invalid minor (${r}) for major ${e[t]>>>5}`)}function Ue(e){return()=>{throw new Error(`${d} ${e}`)}}var c=[];for(let e=0;e<=23;e++)c[e]=l;c[24]=ot;c[25]=it;c[26]=st;c[27]=ct;c[28]=l;c[29]=l;c[30]=l;c[31]=l;for(let e=32;e<=55;e++)c[e]=l;c[56]=at;c[57]=ut;c[58]=ft;c[59]=lt;c[60]=l;c[61]=l;c[62]=l;c[63]=l;for(let e=64;e<=87;e++)c[e]=pt;c[88]=ht;c[89]=mt;c[90]=xt;c[91]=yt;c[92]=l;c[93]=l;c[94]=l;c[95]=Ue("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)c[e]=gt;c[120]=wt;c[121]=bt;c[122]=Et;c[123]=Ut;c[124]=l;c[125]=l;c[126]=l;c[127]=Ue("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)c[e]=At;c[152]=Tt;c[153]=kt;c[154]=St;c[155]=Bt;c[156]=l;c[157]=l;c[158]=l;c[159]=Ct;for(let e=160;e<=183;e++)c[e]=It;c[184]=_t;c[185]=Nt;c[186]=$t;c[187]=Mt;c[188]=l;c[189]=l;c[190]=l;c[191]=Dt;for(let e=192;e<=215;e++)c[e]=zt;c[216]=Ot;c[217]=Ft;c[218]=Vt;c[219]=Lt;c[220]=l;c[221]=l;c[222]=l;c[223]=l;for(let e=224;e<=243;e++)c[e]=Ue("simple values are not supported");c[244]=l;c[245]=l;c[246]=l;c[247]=Rt;c[248]=Ue("simple values are not supported");c[249]=jt;c[250]=qt;c[251]=Gt;c[252]=l;c[253]=l;c[254]=l;c[255]=Pt;var I=[];for(let e=0;e<24;e++)I[e]=new a(i.uint,e,1);for(let e=-1;e>=-24;e--)I[31-e]=new a(i.negint,e,1);I[64]=new a(i.bytes,new Uint8Array(0),1);I[96]=new a(i.string,"",1);I[128]=new a(i.array,0,1);I[160]=new a(i.map,0,1);I[244]=new a(i.false,!1,1);I[245]=new a(i.true,!0,1);I[246]=new a(i.null,null,1);function Qt(e){switch(e.type){case i.false:return M([244]);case i.true:return M([245]);case i.null:return M([246]);case i.bytes:return e.value.length?void 0:M([64]);case i.string:return e.value===""?M([96]):void 0;case i.array:return e.value===0?M([128]):void 0;case i.map:return e.value===0?M([160]):void 0;case i.uint:return e.value<24?M([Number(e.value)]):void 0;case i.negint:if(e.value>=-24)return M([31-Number(e.value)])}}var Xr={float64:!1,mapSorter:Wr,quickEncodeToken:Qt};function Hr(){let e=[];return e[i.uint.major]=T,e[i.negint.major]=xe,e[i.bytes.major]=X,e[i.string.major]=vt,e[i.array.major]=ge,e[i.map.major]=we,e[i.tag.major]=be,e[i.float.major]=Ee,e}var Wt=Hr(),ze=new ne,Ae=class e{constructor(t,r){this.obj=t,this.parent=r}includes(t){let r=this;do if(r.obj===t)return!0;while(r=r.parent);return!1}static createCheck(t,r){if(t&&t.includes(r))throw new Error(`${_e} object contains circular references`);return new e(r,t)}},L={null:new a(i.null,null),undefined:new a(i.undefined,void 0),true:new a(i.true,!0),false:new a(i.false,!1),emptyArray:new a(i.array,0),emptyMap:new a(i.map,0)},R={number(e,t,r,n){return!Number.isInteger(e)||!Number.isSafeInteger(e)?new a(i.float,e):e>=0?new a(i.uint,e):new a(i.negint,e)},bigint(e,t,r,n){return e>=BigInt(0)?new a(i.uint,e):new a(i.negint,e)},Uint8Array(e,t,r,n){return new a(i.bytes,e)},string(e,t,r,n){return new a(i.string,e)},boolean(e,t,r,n){return e?L.true:L.false},null(e,t,r,n){return L.null},undefined(e,t,r,n){return L.undefined},ArrayBuffer(e,t,r,n){return new a(i.bytes,new Uint8Array(e))},DataView(e,t,r,n){return new a(i.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength))},Array(e,t,r,n){if(!e.length)return r.addBreakTokens===!0?[L.emptyArray,new a(i.break)]:L.emptyArray;n=Ae.createCheck(n,e);let o=[],s=0;for(let u of e)o[s++]=ve(u,r,n);return r.addBreakTokens?[new a(i.array,e.length),o,new a(i.break)]:[new a(i.array,e.length),o]},Object(e,t,r,n){let o=t!=="Object",s=o?e.keys():Object.keys(e),u=o?e.size:s.length;if(!u)return r.addBreakTokens===!0?[L.emptyMap,new a(i.break)]:L.emptyMap;n=Ae.createCheck(n,e);let f=[],p=0;for(let g of s)f[p++]=[ve(g,r,n),ve(o?e.get(g):e[g],r,n)];return Qr(f,r),r.addBreakTokens?[new a(i.map,u),f,new a(i.break)]:[new a(i.map,u),f]}};R.Map=R.Object;R.Buffer=R.Uint8Array;for(let e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))R[`${e}Array`]=R.DataView;function ve(e,t={},r){let n=He(e),o=t&&t.typeEncoders&&t.typeEncoders[n]||R[n];if(typeof o=="function"){let u=o(e,n,t,r);if(u!=null)return u}let s=R[n];if(!s)throw new Error(`${_e} unsupported type: ${n}`);return s(e,n,t,r)}function Qr(e,t){t.mapSorter&&e.sort(t.mapSorter)}function Wr(e,t){let r=Array.isArray(e[0])?e[0][0]:e[0],n=Array.isArray(t[0])?t[0][0]:t[0];if(r.type!==n.type)return r.type.compare(n.type);let o=r.type.major,s=Wt[o].compareTokens(r,n);return s===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),s}function Zt(e,t,r,n){if(Array.isArray(t))for(let o of t)Zt(e,o,r,n);else r[t.type.major](e,t,n)}function Zr(e,t,r){let n=ve(e,r);if(!Array.isArray(n)&&r.quickEncodeToken){let o=r.quickEncodeToken(n);if(o)return o;let s=t[n.type.major];if(s.encodedSize){let u=s.encodedSize(n,r),f=new ne(u);if(s(f,n,r),f.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return Ie(f.chunks[0])}}return ze.reset(),Zt(ze,n,t,r),ze.toBytes(!0)}function Oe(e,t){return t=Object.assign({},Xr,t),Zr(e,Wt,t)}var Yr={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},Te=class{constructor(t,r={}){this._pos=0,this.data=t,this.options=r}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let t=this.data[this._pos],r=I[t];if(r===void 0){let n=c[t];if(!n)throw new Error(`${d} no decoder for major type ${t>>>5} (byte 0x${t.toString(16).padStart(2,"0")})`);let o=t&31;r=n(this.data,this._pos,o,this.options)}return this._pos+=r.encodedLength,r}},ce=Symbol.for("DONE"),ke=Symbol.for("BREAK");function en(e,t,r){let n=[];for(let o=0;o<e.value;o++){let s=W(t,r);if(s===ke){if(e.value===1/0)break;throw new Error(`${d} got unexpected break to lengthed array`)}if(s===ce)throw new Error(`${d} found array but not enough entries (got ${o}, expected ${e.value})`);n[o]=s}return n}function tn(e,t,r){let n=r.useMaps===!0,o=n?void 0:{},s=n?new Map:void 0;for(let u=0;u<e.value;u++){let f=W(t,r);if(f===ke){if(e.value===1/0)break;throw new Error(`${d} got unexpected break to lengthed map`)}if(f===ce)throw new Error(`${d} found map but not enough entries (got ${u} [no key], expected ${e.value})`);if(n!==!0&&typeof f!="string")throw new Error(`${d} non-string keys not supported (got ${typeof f})`);if(r.rejectDuplicateMapKeys===!0&&(n&&s.has(f)||!n&&f in o))throw new Error(`${d} found repeat map key "${f}"`);let p=W(t,r);if(p===ce)throw new Error(`${d} found map but not enough entries (got ${u} [no value], expected ${e.value})`);n?s.set(f,p):o[f]=p}return n?s:o}function W(e,t){if(e.done())return ce;let r=e.next();if(r.type===i.break)return ke;if(r.type.terminal)return r.value;if(r.type===i.array)return en(r,e,t);if(r.type===i.map)return tn(r,e,t);if(r.type===i.tag){if(t.tags&&typeof t.tags[r.value]=="function"){let n=W(e,t);return t.tags[r.value](n)}throw new Error(`${d} tag not supported (${r.value})`)}throw new Error("unsupported")}function Yt(e,t){if(!(e instanceof Uint8Array))throw new Error(`${d} data to decode must be a Uint8Array`);t=Object.assign({},Yr,t);let r=t.tokenizer||new Te(e,t),n=W(r,t);if(n===ce)throw new Error(`${d} did not find any content to decode`);if(n===ke)throw new Error(`${d} got unexpected break`);return[n,e.subarray(r.pos())]}function Fe(e,t){let[r,n]=Yt(e,t);if(n.length>0)throw new Error(`${d} too many terminals, data makes no sense`);return r}var Vo=new Uint8Array(0);function er(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function Z(e){if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}function nn(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<e.length;o++){var s=e.charAt(o),u=s.charCodeAt(0);if(r[u]!==255)throw new TypeError(s+" is ambiguous");r[u]=o}var f=e.length,p=e.charAt(0),g=Math.log(f)/Math.log(256),h=Math.log(256)/Math.log(f);function G(m){if(m instanceof Uint8Array||(ArrayBuffer.isView(m)?m=new Uint8Array(m.buffer,m.byteOffset,m.byteLength):Array.isArray(m)&&(m=Uint8Array.from(m))),!(m instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(m.length===0)return"";for(var w=0,P=0,S=0,_=m.length;S!==_&&m[S]===0;)S++,w++;for(var N=(_-S)*h+1>>>0,A=new Uint8Array(N);S!==_;){for(var $=m[S],V=0,B=N-1;($!==0||V<P)&&B!==-1;B--,V++)$+=256*A[B]>>>0,A[B]=$%f>>>0,$=$/f>>>0;if($!==0)throw new Error("Non-zero carry");P=V,S++}for(var z=N-P;z!==N&&A[z]===0;)z++;for(var he=p.repeat(w);z<N;++z)he+=e.charAt(A[z]);return he}function pe(m){if(typeof m!="string")throw new TypeError("Expected String");if(m.length===0)return new Uint8Array;var w=0;if(m[w]!==" "){for(var P=0,S=0;m[w]===p;)P++,w++;for(var _=(m.length-w)*g+1>>>0,N=new Uint8Array(_);m[w];){var A=r[m.charCodeAt(w)];if(A===255)return;for(var $=0,V=_-1;(A!==0||$<S)&&V!==-1;V--,$++)A+=f*N[V]>>>0,N[V]=A%256>>>0,A=A/256>>>0;if(A!==0)throw new Error("Non-zero carry");S=$,w++}if(m[w]!==" "){for(var B=_-S;B!==_&&N[B]===0;)B++;for(var z=new Uint8Array(P+(_-B)),he=P;B!==_;)z[he++]=N[B++];return z}}}function br(m){var w=pe(m);if(w)return w;throw new Error(`Non-${t} character`)}return{encode:G,decodeUnsafe:pe,decode:br}}var on=nn,sn=on,tr=sn;var Ve=class{name;prefix;baseEncode;constructor(t,r,n){this.name=t,this.prefix=r,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},Le=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,r,n){this.name=t,this.prefix=r;let o=r.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return rr(this,t)}},Re=class{decoders;constructor(t){this.decoders=t}or(t){return rr(this,t)}decode(t){let r=t[0],n=this.decoders[r];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function rr(e,t){return new Re({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var Pe=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,r,n,o){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new Ve(t,r,n),this.decoder=new Le(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function nr({name:e,prefix:t,encode:r,decode:n}){return new Pe(e,t,r,n)}function Y({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=tr(r,e);return nr({prefix:t,name:e,encode:n,decode:s=>Z(o(s))})}function cn(e,t,r,n){let o={};for(let h=0;h<t.length;++h)o[t[h]]=h;let s=e.length;for(;e[s-1]==="=";)--s;let u=new Uint8Array(s*r/8|0),f=0,p=0,g=0;for(let h=0;h<s;++h){let G=o[e[h]];if(G===void 0)throw new SyntaxError(`Non-${n} character`);p=p<<r|G,f+=r,f>=8&&(f-=8,u[g++]=255&p>>f)}if(f>=r||(255&p<<8-f)!==0)throw new SyntaxError("Unexpected end of data");return u}function an(e,t,r){let n=t[t.length-1]==="=",o=(1<<r)-1,s="",u=0,f=0;for(let p=0;p<e.length;++p)for(f=f<<8|e[p],u+=8;u>r;)u-=r,s+=t[o&f>>u];if(u!==0&&(s+=t[o&f<<r-u]),n)for(;(s.length*r&7)!==0;)s+="=";return s}function D({name:e,prefix:t,bitsPerChar:r,alphabet:n}){return nr({prefix:t,name:e,encode(o){return an(o,n,r)},decode(o){return cn(o,n,r,e)}})}var ae=D({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Jo=D({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Ko=D({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Xo=D({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Ho=D({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Qo=D({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Wo=D({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Zo=D({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Yo=D({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Se=Y({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),ri=Y({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var F=Y({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),ii=Y({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var un=sr,or=128,fn=127,dn=~fn,ln=Math.pow(2,31);function sr(e,t,r){t=t||[],r=r||0;for(var n=r;e>=ln;)t[r++]=e&255|or,e/=128;for(;e&dn;)t[r++]=e&255|or,e>>>=7;return t[r]=e|0,sr.bytes=r-n+1,t}var pn=je,hn=128,ir=127;function je(e,n){var r=0,n=n||0,o=0,s=n,u,f=e.length;do{if(s>=f)throw je.bytes=0,new RangeError("Could not decode varint");u=e[s++],r+=o<28?(u&ir)<<o:(u&ir)*Math.pow(2,o),o+=7}while(u>=hn);return je.bytes=s-n,r}var mn=Math.pow(2,7),xn=Math.pow(2,14),yn=Math.pow(2,21),gn=Math.pow(2,28),wn=Math.pow(2,35),bn=Math.pow(2,42),En=Math.pow(2,49),Un=Math.pow(2,56),vn=Math.pow(2,63),An=function(e){return e<mn?1:e<xn?2:e<yn?3:e<gn?4:e<wn?5:e<bn?6:e<En?7:e<Un?8:e<vn?9:10},Tn={encode:un,decode:pn,encodingLength:An},kn=Tn,ue=kn;function fe(e,t=0){return[ue.decode(e,t),ue.decode.bytes]}function ee(e,t,r=0){return ue.encode(e,t,r),t}function te(e){return ue.encodingLength(e)}function de(e,t){let r=t.byteLength,n=te(e),o=n+te(r),s=new Uint8Array(o+r);return ee(e,s,0),ee(r,s,n),s.set(t,o),new re(e,r,t,s)}function ar(e){let t=Z(e),[r,n]=fe(t),[o,s]=fe(t.subarray(n)),u=t.subarray(n+s);if(u.byteLength!==o)throw new Error("Incorrect length");return new re(r,o,u,t)}function ur(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&er(e.bytes,r.bytes)}}var re=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};function dr(e,t){let{bytes:r,version:n}=e;switch(n){case 0:return Bn(r,qe(e),t??F.encoder);default:return Cn(r,qe(e),t??ae.encoder)}}var lr=new WeakMap;function qe(e){let t=lr.get(e);if(t==null){let r=new Map;return lr.set(e,r),r}return t}var q=class e{code;version;multihash;bytes;"/";constructor(t,r,n,o){this.code=r,this.version=t,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:t,multihash:r}=this;if(t!==le)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==In)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return e.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:r}=this.multihash,n=de(t,r);return e.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(t){return e.equals(this,t)}static equals(t,r){let n=r;return n!=null&&t.code===n.code&&t.version===n.version&&ur(t.multihash,n.multihash)}toString(t){return dr(this,t)}toJSON(){return{"/":dr(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let r=t;if(r instanceof e)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:s,bytes:u}=r;return new e(n,o,s,u??pr(n,o,s.bytes))}else if(r[_n]===!0){let{version:n,multihash:o,code:s}=r,u=ar(o);return e.create(n,s,u)}else return null}static create(t,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(r!==le)throw new Error(`Version 0 CID must use dag-pb (code: ${le}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=pr(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,le,t)}static createV1(t,r){return e.create(1,t,r)}static decode(t){let[r,n]=e.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(t){let r=e.inspectBytes(t),n=r.size-r.multihashSize,o=Z(t.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let s=o.subarray(r.multihashSize-r.digestSize),u=new re(r.multihashCode,r.digestSize,s,o);return[r.version===0?e.createV0(u):e.createV1(r.codec,u),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[G,pe]=fe(t.subarray(r));return r+=pe,G},o=n(),s=le;if(o===18?(o=0,r=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let u=r,f=n(),p=n(),g=r+p,h=g-u;return{version:o,codec:s,multihashCode:f,digestSize:p,multihashSize:h,size:g}}static parse(t,r){let[n,o]=Sn(t,r),s=e.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return qe(s).set(n,t),s}};function Sn(e,t){switch(e[0]){case"Q":{let r=t??F;return[F.prefix,r.decode(`${F.prefix}${e}`)]}case F.prefix:{let r=t??F;return[F.prefix,r.decode(e)]}case ae.prefix:{let r=t??ae;return[ae.prefix,r.decode(e)]}case Se.prefix:{let r=t??Se;return[Se.prefix,r.decode(e)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}}function Bn(e,t,r){let{prefix:n}=r;if(n!==F.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=t.get(n);if(o==null){let s=r.encode(e).slice(1);return t.set(n,s),s}else return o}function Cn(e,t,r){let{prefix:n}=r,o=t.get(n);if(o==null){let s=r.encode(e);return t.set(n,s),s}else return o}var le=112,In=18;function pr(e,t,r){let n=te(e),o=n+te(t),s=new Uint8Array(o+r.byteLength);return ee(e,s,0),ee(t,s,n),s.set(r,o),s}var _n=Symbol.for("@ipld/js-cid/CID");var hr=42;function Nn(e){return e instanceof ArrayBuffer?new Uint8Array(e,0,e.byteLength):e}function $n(e){if(e.asCID!==e&&e["/"]!==e.bytes)return null;let t=q.asCID(e);if(!t)return null;let r=new Uint8Array(t.bytes.byteLength+1);return r.set(t.bytes,1),[new a(i.tag,hr),new a(i.bytes,r)]}function Mn(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")}function Dn(e){if(Number.isNaN(e))throw new Error("`NaN` is not supported by the IPLD Data Model and cannot be encoded");if(e===1/0||e===-1/0)throw new Error("`Infinity` and `-Infinity` is not supported by the IPLD Data Model and cannot be encoded");return null}var Ge={float64:!0,typeEncoders:{Object:$n,undefined:Mn,number:Dn}},yi={...Ge,typeEncoders:{...Ge.typeEncoders}};function zn(e){if(e[0]!==0)throw new Error("Invalid CID for CBOR tag 42; expected leading 0x00");return q.decode(e.subarray(1))}var Be={allowIndefinite:!1,coerceUndefinedToNull:!0,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,rejectDuplicateMapKeys:!0,tags:[]};Be.tags[hr]=zn;var gi={...Be,tags:Be.tags.slice()};var mr=113,xr=e=>Oe(e,Ge),yr=e=>Fe(Nn(e),Be);function Ke({name:e,code:t,encode:r}){return new Je(e,t,r)}var Je=class{name;code;encode;constructor(t,r,n){this.name=t,this.code=r,this.encode=n}digest(t){if(t instanceof Uint8Array){let r=this.encode(t);return r instanceof Uint8Array?de(this.code,r):r.then(n=>de(this.code,n))}else throw Error("Unknown type, must be binary type")}};function gr(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}var wr=Ke({name:"sha2-256",code:18,encode:gr("SHA-256")}),Ei=Ke({name:"sha2-512",code:19,encode:gr("SHA-512")});var Xe=class{components;constructor(t){this.components=t}async add(t,r={}){let n=xr(t),o=await(r.hasher??wr).digest(n),s=q.createV1(mr,o);return await this.components.blockstore.put(s,n,r),s}async get(t,r={}){let n=await this.components.blockstore.get(t,r);return yr(n)}};function Fn(e){return new Xe(e)}return kr(Vn);})();
|
|
3
3
|
return HeliaDagCbor}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@helia/dag-cbor",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.3",
|
|
4
4
|
"description": "Add/get IPLD blocks containing dag-cbor with your Helia node",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/ipfs/helia/tree/main/packages/dag-cbor#readme",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"test:electron-main": "aegir test -t electron-main"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@helia/interface": "^5.2.
|
|
58
|
+
"@helia/interface": "^5.2.1",
|
|
59
59
|
"@ipld/dag-cbor": "^9.2.2",
|
|
60
60
|
"@libp2p/interface": "^2.2.1",
|
|
61
61
|
"interface-blockstore": "^5.3.1",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"progress-events": "^1.0.1"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
|
-
"aegir": "^45.
|
|
66
|
+
"aegir": "^45.1.1",
|
|
67
67
|
"blockstore-core": "^5.0.2"
|
|
68
68
|
},
|
|
69
69
|
"sideEffects": false
|