Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

blockstore-idb

Package Overview
Dependencies
Maintainers
0
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

blockstore-idb - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

2

dist/index.min.js
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.BlockstoreIdb = factory()}(typeof self !== 'undefined' ? self : this, function () {
"use strict";var BlockstoreIdb=(()=>{var Q=Object.defineProperty;var Te=Object.getOwnPropertyDescriptor;var je=Object.getOwnPropertyNames;var Re=Object.prototype.hasOwnProperty;var qe=(t,e)=>{for(var r in e)Q(t,r,{get:e[r],enumerable:!0})},Je=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of je(e))!Re.call(t,o)&&o!==r&&Q(t,o,{get:()=>e[o],enumerable:!(n=Te(e,o))||n.enumerable});return t};var Ke=t=>Je(Q({},"__esModule",{value:!0}),t);var Wt={};qe(Wt,{IDBBlockstore:()=>le});var D=class{has(e,r){return Promise.reject(new Error(".has is not implemented"))}put(e,r,n){return Promise.reject(new Error(".put is not implemented"))}async*putMany(e,r){for await(let{cid:n,block:o}of e)await this.put(n,o,r),yield n}get(e,r){return Promise.reject(new Error(".get is not implemented"))}async*getMany(e,r){for await(let n of e)yield{cid:n,block:await this.get(n,r)}}delete(e,r){return Promise.reject(new Error(".delete is not implemented"))}async*deleteMany(e,r){for await(let n of e)await this.delete(n,r),yield n}async*getAll(e){throw new Error(".getAll is not implemented")}};var q=class extends Error{constructor(e="Open failed"){super(e),this.name="OpenFailedError"}};var A=class extends Error{constructor(e="Put failed"){super(e),this.name="PutFailedError"}};var B=class extends Error{constructor(e="Not Found"){super(e),this.name="NotFoundError"}};var _t=new Uint8Array(0);function he(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}function L(t){if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")}function We(t,e){if(t.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<t.length;o++){var s=t.charAt(o),a=s.charCodeAt(0);if(r[a]!==255)throw new TypeError(s+" is ambiguous");r[a]=o}var u=t.length,d=t.charAt(0),y=Math.log(u)/Math.log(256),i=Math.log(256)/Math.log(u);function c(f){if(f instanceof Uint8Array||(ArrayBuffer.isView(f)?f=new Uint8Array(f.buffer,f.byteOffset,f.byteLength):Array.isArray(f)&&(f=Uint8Array.from(f))),!(f instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(f.length===0)return"";for(var l=0,p=0,m=0,w=f.length;m!==w&&f[m]===0;)m++,l++;for(var v=(w-m)*i+1>>>0,b=new Uint8Array(v);m!==w;){for(var S=f[m],E=0,x=v-1;(S!==0||E<p)&&x!==-1;x--,E++)S+=256*b[x]>>>0,b[x]=S%u>>>0,S=S/u>>>0;if(S!==0)throw new Error("Non-zero carry");p=E,m++}for(var F=v-p;F!==v&&b[F]===0;)F++;for(var P=d.repeat(l);F<v;++F)P+=t.charAt(b[F]);return P}function h(f){if(typeof f!="string")throw new TypeError("Expected String");if(f.length===0)return new Uint8Array;var l=0;if(f[l]!==" "){for(var p=0,m=0;f[l]===d;)p++,l++;for(var w=(f.length-l)*y+1>>>0,v=new Uint8Array(w);f[l];){var b=r[f.charCodeAt(l)];if(b===255)return;for(var S=0,E=w-1;(b!==0||S<m)&&E!==-1;E--,S++)b+=u*v[E]>>>0,v[E]=b%256>>>0,b=b/256>>>0;if(b!==0)throw new Error("Non-zero carry");m=S,l++}if(f[l]!==" "){for(var x=w-m;x!==w&&v[x]===0;)x++;for(var F=new Uint8Array(p+(w-x)),P=p;x!==w;)F[P++]=v[x++];return F}}}function z(f){var l=h(f);if(l)return l;throw new Error(`Non-${e} character`)}return{encode:c,decodeUnsafe:h,decode:z}}var Ge=We,Qe=Ge,pe=Qe;var X=class{name;prefix;baseEncode;constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},Z=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,r,n){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return me(this,e)}},H=class{decoders;constructor(e){this.decoders=e}or(e){return me(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function me(t,e){return new H({...t.decoders??{[t.prefix]:t},...e.decoders??{[e.prefix]:e}})}var _=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,r,n,o){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new X(e,r,n),this.decoder=new Z(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function be({name:t,prefix:e,encode:r,decode:n}){return new _(t,e,r,n)}function Y({name:t,prefix:e,alphabet:r}){let{encode:n,decode:o}=pe(r,t);return be({prefix:e,name:t,encode:n,decode:s=>L(o(s))})}function Xe(t,e,r,n){let o={};for(let i=0;i<e.length;++i)o[e[i]]=i;let s=t.length;for(;t[s-1]==="=";)--s;let a=new Uint8Array(s*r/8|0),u=0,d=0,y=0;for(let i=0;i<s;++i){let c=o[t[i]];if(c===void 0)throw new SyntaxError(`Non-${n} character`);d=d<<r|c,u+=r,u>=8&&(u-=8,a[y++]=255&d>>u)}if(u>=r||255&d<<8-u)throw new SyntaxError("Unexpected end of data");return a}function Ze(t,e,r){let n=e[e.length-1]==="=",o=(1<<r)-1,s="",a=0,u=0;for(let d=0;d<t.length;++d)for(u=u<<8|t[d],a+=8;a>r;)a-=r,s+=e[o&u>>a];if(a!==0&&(s+=e[o&u<<r-a]),n)for(;s.length*r&7;)s+="=";return s}function g({name:t,prefix:e,bitsPerChar:r,alphabet:n}){return be({prefix:e,name:t,encode(o){return Ze(o,n,r)},decode(o){return Xe(o,n,r,t)}})}var M=g({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),ye=g({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),sr=g({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),ir=g({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),ar=g({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),cr=g({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),ur=g({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),dr=g({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),fr=g({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var I=Y({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),pr=Y({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var He=xe,we=128,_e=127,Ye=~_e,et=Math.pow(2,31);function xe(t,e,r){e=e||[],r=r||0;for(var n=r;t>=et;)e[r++]=t&255|we,t/=128;for(;t&Ye;)e[r++]=t&255|we,t>>>=7;return e[r]=t|0,xe.bytes=r-n+1,e}var tt=ee,rt=128,ge=127;function ee(t,n){var r=0,n=n||0,o=0,s=n,a,u=t.length;do{if(s>=u)throw ee.bytes=0,new RangeError("Could not decode varint");a=t[s++],r+=o<28?(a&ge)<<o:(a&ge)*Math.pow(2,o),o+=7}while(a>=rt);return ee.bytes=s-n,r}var nt=Math.pow(2,7),ot=Math.pow(2,14),st=Math.pow(2,21),it=Math.pow(2,28),at=Math.pow(2,35),ct=Math.pow(2,42),ut=Math.pow(2,49),dt=Math.pow(2,56),ft=Math.pow(2,63),lt=function(t){return t<nt?1:t<ot?2:t<st?3:t<it?4:t<at?5:t<ct?6:t<ut?7:t<dt?8:t<ft?9:10},ht={encode:He,decode:tt,encodingLength:lt},pt=ht,U=pt;function V(t,e=0){return[U.decode(t,e),U.decode.bytes]}function N(t,e,r=0){return U.encode(t,e,r),e}function O(t){return U.encodingLength(t)}function ve(t,e){let r=e.byteLength,n=O(t),o=n+O(r),s=new Uint8Array(o+r);return N(t,s,0),N(r,s,n),s.set(e,o),new $(t,r,e,s)}function T(t){let e=L(t),[r,n]=V(e),[o,s]=V(e.subarray(n)),a=e.subarray(n+s);if(a.byteLength!==o)throw new Error("Incorrect length");return new $(r,o,a,e)}function Ee(t,e){if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&he(t.bytes,r.bytes)}}var $=class{code;size;digest;bytes;constructor(e,r,n,o){this.code=e,this.size=r,this.digest=n,this.bytes=o}};function Fe(t,e){let{bytes:r,version:n}=t;switch(n){case 0:return bt(r,re(t),e??I.encoder);default:return yt(r,re(t),e??M.encoder)}}var Se=new WeakMap;function re(t){let e=Se.get(t);if(e==null){let r=new Map;return Se.set(t,r),r}return e}var R=class t{code;version;multihash;bytes;"/";constructor(e,r,n,o){this.code=r,this.version=e,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:r}=this;if(e!==j)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==wt)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return t.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:r}=this.multihash,n=ve(e,r);return t.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return t.equals(this,e)}static equals(e,r){let n=r;return n!=null&&e.code===n.code&&e.version===n.version&&Ee(e.multihash,n.multihash)}toString(e){return Fe(this,e)}toJSON(){return{"/":Fe(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let r=e;if(r instanceof t)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:s,bytes:a}=r;return new t(n,o,s,a??Ie(n,o,s.bytes))}else if(r[gt]===!0){let{version:n,multihash:o,code:s}=r,a=T(o);return t.create(n,s,a)}else return null}static create(e,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(e){case 0:{if(r!==j)throw new Error(`Version 0 CID must use dag-pb (code: ${j}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let o=Ie(e,r,n.bytes);return new t(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,j,e)}static createV1(e,r){return t.create(1,e,r)}static decode(e){let[r,n]=t.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=t.inspectBytes(e),n=r.size-r.multihashSize,o=L(e.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let s=o.subarray(r.multihashSize-r.digestSize),a=new $(r.multihashCode,r.digestSize,s,o);return[r.version===0?t.createV0(a):t.createV1(r.codec,a),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[c,h]=V(e.subarray(r));return r+=h,c},o=n(),s=j;if(o===18?(o=0,r=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let a=r,u=n(),d=n(),y=r+d,i=y-a;return{version:o,codec:s,multihashCode:u,digestSize:d,multihashSize:i,size:y}}static parse(e,r){let[n,o]=mt(e,r),s=t.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return re(s).set(n,e),s}};function mt(t,e){switch(t[0]){case"Q":{let r=e??I;return[I.prefix,r.decode(`${I.prefix}${t}`)]}case I.prefix:{let r=e??I;return[I.prefix,r.decode(t)]}case M.prefix:{let r=e??M;return[M.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}}function bt(t,e,r){let{prefix:n}=r;if(n!==I.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=e.get(n);if(o==null){let s=r.encode(t).slice(1);return e.set(n,s),s}else return o}function yt(t,e,r){let{prefix:n}=r,o=e.get(n);if(o==null){let s=r.encode(t);return e.set(n,s),s}else return o}var j=112,wt=18;function Ie(t,e,r){let n=O(t),o=n+O(e),s=new Uint8Array(o+r.byteLength);return N(t,s,0),N(e,s,n),s.set(r,o),s}var gt=Symbol.for("@ipld/js-cid/CID");var ne=85;var Ae=g({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Pr=g({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Nr=g({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Or=g({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function xt(t,e){try{if(typeof t=="string"&&t.length>0)return Ct(t);if(typeof t=="number"&&isFinite(t))return e?.long?Et(t):vt(t);throw new Error("Value is not a string or number.")}catch(r){let n=Ft(r)?`${r.message}. value=${JSON.stringify(t)}`:"An unknown error has occured.";throw new Error(n)}}function Ct(t){if(t=String(t),t.length>100)throw new Error("Value exceeds the maximum length of 100 characters.");let e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(t);if(!e)return NaN;let r=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return r*315576e5;case"weeks":case"week":case"w":return r*6048e5;case"days":case"day":case"d":return r*864e5;case"hours":case"hour":case"hrs":case"hr":case"h":return r*36e5;case"minutes":case"minute":case"mins":case"min":case"m":return r*6e4;case"seconds":case"second":case"secs":case"sec":case"s":return r*1e3;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:throw new Error(`The unit ${n} was matched, but no matching case exists.`)}}var K=xt;function vt(t){let e=Math.abs(t);return e>=864e5?`${Math.round(t/864e5)}d`:e>=36e5?`${Math.round(t/36e5)}h`:e>=6e4?`${Math.round(t/6e4)}m`:e>=1e3?`${Math.round(t/1e3)}s`:`${t}ms`}function Et(t){let e=Math.abs(t);return e>=864e5?J(t,e,864e5,"day"):e>=36e5?J(t,e,36e5,"hour"):e>=6e4?J(t,e,6e4,"minute"):e>=1e3?J(t,e,1e3,"second"):`${t} ms`}function J(t,e,r,n){let o=e>=r*1.5;return`${Math.round(t/r)} ${n}${o?"s":""}`}function Ft(t){return typeof t=="object"&&t!==null&&"message"in t}function oe(t){r.debug=r,r.default=r,r.coerce=d,r.disable=s,r.enable=o,r.enabled=a,r.humanize=K,r.destroy=y,Object.keys(t).forEach(i=>{r[i]=t[i]}),r.names=[],r.skips=[],r.formatters={};function e(i){let c=0;for(let h=0;h<i.length;h++)c=(c<<5)-c+i.charCodeAt(h),c|=0;return r.colors[Math.abs(c)%r.colors.length]}r.selectColor=e;function r(i){let c,h=null,z,f;function l(...p){if(!l.enabled)return;let m=l,w=Number(new Date),v=w-(c||w);m.diff=v,m.prev=c,m.curr=w,c=w,p[0]=r.coerce(p[0]),typeof p[0]!="string"&&p.unshift("%O");let b=0;p[0]=p[0].replace(/%([a-zA-Z%])/g,(E,x)=>{if(E==="%%")return"%";b++;let F=r.formatters[x];if(typeof F=="function"){let P=p[b];E=F.call(m,P),p.splice(b,1),b--}return E}),r.formatArgs.call(m,p),(m.log||r.log).apply(m,p)}return l.namespace=i,l.useColors=r.useColors(),l.color=r.selectColor(i),l.extend=n,l.destroy=r.destroy,Object.defineProperty(l,"enabled",{enumerable:!0,configurable:!1,get:()=>h!==null?h:(z!==r.namespaces&&(z=r.namespaces,f=r.enabled(i)),f),set:p=>{h=p}}),typeof r.init=="function"&&r.init(l),l}function n(i,c){let h=r(this.namespace+(typeof c>"u"?":":c)+i);return h.log=this.log,h}function o(i){r.save(i),r.namespaces=i,r.names=[],r.skips=[];let c,h=(typeof i=="string"?i:"").split(/[\s,]+/),z=h.length;for(c=0;c<z;c++)h[c]&&(i=h[c].replace(/\*/g,".*?"),i[0]==="-"?r.skips.push(new RegExp("^"+i.substr(1)+"$")):r.names.push(new RegExp("^"+i+"$")))}function s(){let i=[...r.names.map(u),...r.skips.map(u).map(c=>"-"+c)].join(",");return r.enable(""),i}function a(i){if(i[i.length-1]==="*")return!0;let c,h;for(c=0,h=r.skips.length;c<h;c++)if(r.skips[c].test(i))return!1;for(c=0,h=r.names.length;c<h;c++)if(r.names[c].test(i))return!0;return!1}function u(i){return i.toString().substring(2,i.toString().length-2).replace(/\.\*\?$/,"*")}function d(i){return i instanceof Error?i.stack??i.message:i}function y(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.setupFormatters(r.formatters),r.enable(r.load()),r}var W=Bt(),St=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function It(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent?.toLowerCase().match(/(edge|trident)\/(\d+)/)!=null?!1:typeof document<"u"&&document.documentElement?.style?.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent?.toLowerCase().match(/firefox\/(\d+)/)!=null&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent?.toLowerCase().match(/applewebkit\/(\d+)/)}function Dt(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+K(this.diff),!this.useColors)return;let e="color: "+this.color;t.splice(1,0,e,"color: inherit");let r=0,n=0;t[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(r++,o==="%c"&&(n=r))}),t.splice(n,0,e)}var At=console.debug??console.log??(()=>{});function Mt(t){try{t?W?.setItem("debug",t):W?.removeItem("debug")}catch{}}function kt(){let t;try{t=W?.getItem("debug")}catch{}return!t&&typeof process<"u"&&"env"in process&&(t=process.env.DEBUG),t}function Bt(){try{return localStorage}catch{}}function Lt(t){t.j=function(e){try{return JSON.stringify(e)}catch(r){return"[UnexpectedJSONParseError]: "+r.message}}}var Me=oe({formatArgs:Dt,save:Mt,load:kt,useColors:It,setupFormatters:Lt,colors:St,storage:W,log:At});var C=Me;C.formatters.b=t=>t==null?"undefined":I.baseEncode(t);C.formatters.t=t=>t==null?"undefined":M.baseEncode(t);C.formatters.m=t=>t==null?"undefined":Ae.baseEncode(t);C.formatters.p=t=>t==null?"undefined":t.toString();C.formatters.c=t=>t==null?"undefined":t.toString();C.formatters.k=t=>t==null?"undefined":t.toString();C.formatters.a=t=>t==null?"undefined":t.toString();function zt(t){let e=()=>{};return e.enabled=!1,e.color="",e.diff=0,e.log=()=>{},e.namespace=t,e.destroy=()=>!0,e.extend=()=>e,e}function ke(t){let e=zt(`${t}:trace`);return C.enabled(`${t}:trace`)&&C.names.map(r=>r.toString()).find(r=>r.includes(":trace"))!=null&&(e=C(`${t}:trace`)),Object.assign(C(t),{error:C(`${t}:error`),trace:e})}var xn=ke("blockstore:core:tiered");var ae=(t,e)=>e.some(r=>t instanceof r),Be,Le;function Nt(){return Be||(Be=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Ot(){return Le||(Le=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var ce=new WeakMap,se=new WeakMap,G=new WeakMap;function $t(t){let e=new Promise((r,n)=>{let o=()=>{t.removeEventListener("success",s),t.removeEventListener("error",a)},s=()=>{r(k(t.result)),o()},a=()=>{n(t.error),o()};t.addEventListener("success",s),t.addEventListener("error",a)});return G.set(e,t),e}function Ut(t){if(ce.has(t))return;let e=new Promise((r,n)=>{let o=()=>{t.removeEventListener("complete",s),t.removeEventListener("error",a),t.removeEventListener("abort",a)},s=()=>{r(),o()},a=()=>{n(t.error||new DOMException("AbortError","AbortError")),o()};t.addEventListener("complete",s),t.addEventListener("error",a),t.addEventListener("abort",a)});ce.set(t,e)}var ue={get(t,e,r){if(t instanceof IDBTransaction){if(e==="done")return ce.get(t);if(e==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return k(t[e])},set(t,e,r){return t[e]=r,!0},has(t,e){return t instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in t}};function Oe(t){ue=t(ue)}function Vt(t){return Ot().includes(t)?function(...e){return t.apply(de(this),e),k(this.request)}:function(...e){return k(t.apply(de(this),e))}}function Tt(t){return typeof t=="function"?Vt(t):(t instanceof IDBTransaction&&Ut(t),ae(t,Nt())?new Proxy(t,ue):t)}function k(t){if(t instanceof IDBRequest)return $t(t);if(se.has(t))return se.get(t);let e=Tt(t);return e!==t&&(se.set(t,e),G.set(e,t)),e}var de=t=>G.get(t);function $e(t,e,{blocked:r,upgrade:n,blocking:o,terminated:s}={}){let a=indexedDB.open(t,e),u=k(a);return n&&a.addEventListener("upgradeneeded",d=>{n(k(a.result),d.oldVersion,d.newVersion,k(a.transaction),d)}),r&&a.addEventListener("blocked",d=>r(d.oldVersion,d.newVersion,d)),u.then(d=>{s&&d.addEventListener("close",()=>s()),o&&d.addEventListener("versionchange",y=>o(y.oldVersion,y.newVersion,y))}).catch(()=>{}),u}function Ue(t,{blocked:e}={}){let r=indexedDB.deleteDatabase(t);return e&&r.addEventListener("blocked",n=>e(n.oldVersion,n)),k(r).then(()=>{})}var jt=["get","getKey","getAll","getAllKeys","count"],Rt=["put","add","delete","clear"],ie=new Map;function ze(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e=="string"))return;if(ie.get(e))return ie.get(e);let r=e.replace(/FromIndex$/,""),n=e!==r,o=Rt.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!(o||jt.includes(r)))return;let s=async function(a,...u){let d=this.transaction(a,o?"readwrite":"readonly"),y=d.store;return n&&(y=y.index(u.shift())),(await Promise.all([y[r](...u),o&&d.done]))[0]};return ie.set(e,s),s}Oe(t=>({...t,get:(e,r,n)=>ze(e,r)||t.get(e,r,n),has:(e,r)=>!!ze(e,r)||t.has(e,r)}));var qt=["continue","continuePrimaryKey","advance"],Pe={},fe=new WeakMap,Ve=new WeakMap,Jt={get(t,e){if(!qt.includes(e))return t[e];let r=Pe[e];return r||(r=Pe[e]=function(...n){fe.set(this,Ve.get(this)[e](...n))}),r}};async function*Kt(...t){let e=this;if(e instanceof IDBCursor||(e=await e.openCursor(...t)),!e)return;e=e;let r=new Proxy(e,Jt);for(Ve.set(r,e),G.set(r,de(e));e;)yield r,e=await(fe.get(r)||e.continue()),fe.delete(r)}function Ne(t,e){return e===Symbol.asyncIterator&&ae(t,[IDBIndex,IDBObjectStore,IDBCursor])||e==="iterate"&&ae(t,[IDBIndex,IDBObjectStore])}Oe(t=>({...t,get(e,r,n){return Ne(e,r)?Kt:t.get(e,r,n)},has(e,r){return Ne(e,r)||t.has(e,r)}}));var le=class extends D{location;version;db;base;constructor(e,r={}){super(),this.location=`${r.prefix??""}${e}`,this.version=r.version??1,this.base=r.base??ye}#e(e){return`/${this.base.encoder.encode(e.multihash.bytes)}`}#t(e){return R.createV1(ne,T(this.base.decoder.decode(e.substring(1))))}async open(){try{let e=this.location;this.db=await $e(e,this.version,{upgrade(r){r.createObjectStore(e)}})}catch(e){throw new q(String(e))}}async close(){this.db?.close()}async put(e,r){if(this.db==null)throw new Error("Blockstore needs to be opened.");try{return await this.db.put(this.location,r,this.#e(e)),e}catch(n){throw new A(String(n))}}async get(e){if(this.db==null)throw new Error("Blockstore needs to be opened.");let r;try{r=await this.db.get(this.location,this.#e(e))}catch(n){throw new A(String(n))}if(r===void 0)throw new B;return r}async delete(e){if(this.db==null)throw new Error("Blockstore needs to be opened.");try{await this.db.delete(this.location,this.#e(e))}catch(r){throw new A(String(r))}}async has(e){if(this.db==null)throw new Error("Blockstore needs to be opened.");try{return!!await this.db.getKey(this.location,this.#e(e))}catch(r){throw new A(String(r))}}async*getAll(e){if(this.db==null)throw new Error("Blockstore needs to be opened.");for(let r of await this.db.getAllKeys(this.location)){let n=this.#t(r.toString()),o=await this.get(n);yield{cid:n,block:o}}}async destroy(){await Ue(this.location)}};return Ke(Wt);})();
"use strict";var BlockstoreIdb=(()=>{var Z=Object.defineProperty;var je=Object.getOwnPropertyDescriptor;var Re=Object.getOwnPropertyNames;var qe=Object.prototype.hasOwnProperty;var Je=(t,e)=>{for(var r in e)Z(t,r,{get:e[r],enumerable:!0})},Ke=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Re(e))!qe.call(t,o)&&o!==r&&Z(t,o,{get:()=>e[o],enumerable:!(n=je(e,o))||n.enumerable});return t};var We=t=>Ke(Z({},"__esModule",{value:!0}),t);var Gt={};Je(Gt,{IDBBlockstore:()=>he});var D=class{has(e,r){return Promise.reject(new Error(".has is not implemented"))}put(e,r,n){return Promise.reject(new Error(".put is not implemented"))}async*putMany(e,r){for await(let{cid:n,block:o}of e)await this.put(n,o,r),yield n}get(e,r){return Promise.reject(new Error(".get is not implemented"))}async*getMany(e,r){for await(let n of e)yield{cid:n,block:await this.get(n,r)}}delete(e,r){return Promise.reject(new Error(".delete is not implemented"))}async*deleteMany(e,r){for await(let n of e)await this.delete(n,r),yield n}async*getAll(e){throw new Error(".getAll is not implemented")}};var J=class extends Error{constructor(e="Open failed"){super(e),this.name="OpenFailedError"}};var A=class extends Error{constructor(e="Put failed"){super(e),this.name="PutFailedError"}};var B=class extends Error{constructor(e="Not Found"){super(e),this.name="NotFoundError"}};var _t=new Uint8Array(0);function pe(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}function L(t){if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")}function Ge(t,e){if(t.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<t.length;o++){var s=t.charAt(o),a=s.charCodeAt(0);if(r[a]!==255)throw new TypeError(s+" is ambiguous");r[a]=o}var u=t.length,d=t.charAt(0),y=Math.log(u)/Math.log(256),i=Math.log(256)/Math.log(u);function c(f){if(f instanceof Uint8Array||(ArrayBuffer.isView(f)?f=new Uint8Array(f.buffer,f.byteOffset,f.byteLength):Array.isArray(f)&&(f=Uint8Array.from(f))),!(f instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(f.length===0)return"";for(var l=0,p=0,m=0,w=f.length;m!==w&&f[m]===0;)m++,l++;for(var v=(w-m)*i+1>>>0,b=new Uint8Array(v);m!==w;){for(var S=f[m],E=0,x=v-1;(S!==0||E<p)&&x!==-1;x--,E++)S+=256*b[x]>>>0,b[x]=S%u>>>0,S=S/u>>>0;if(S!==0)throw new Error("Non-zero carry");p=E,m++}for(var F=v-p;F!==v&&b[F]===0;)F++;for(var P=d.repeat(l);F<v;++F)P+=t.charAt(b[F]);return P}function h(f){if(typeof f!="string")throw new TypeError("Expected String");if(f.length===0)return new Uint8Array;var l=0;if(f[l]!==" "){for(var p=0,m=0;f[l]===d;)p++,l++;for(var w=(f.length-l)*y+1>>>0,v=new Uint8Array(w);f[l];){var b=r[f.charCodeAt(l)];if(b===255)return;for(var S=0,E=w-1;(b!==0||S<m)&&E!==-1;E--,S++)b+=u*v[E]>>>0,v[E]=b%256>>>0,b=b/256>>>0;if(b!==0)throw new Error("Non-zero carry");m=S,l++}if(f[l]!==" "){for(var x=w-m;x!==w&&v[x]===0;)x++;for(var F=new Uint8Array(p+(w-x)),P=p;x!==w;)F[P++]=v[x++];return F}}}function z(f){var l=h(f);if(l)return l;throw new Error(`Non-${e} character`)}return{encode:c,decodeUnsafe:h,decode:z}}var Qe=Ge,Xe=Qe,me=Xe;var H=class{name;prefix;baseEncode;constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},Y=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,r,n){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return be(this,e)}},_=class{decoders;constructor(e){this.decoders=e}or(e){return be(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function be(t,e){return new _({...t.decoders??{[t.prefix]:t},...e.decoders??{[e.prefix]:e}})}var ee=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,r,n,o){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new H(e,r,n),this.decoder=new Y(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function ye({name:t,prefix:e,encode:r,decode:n}){return new ee(t,e,r,n)}function N({name:t,prefix:e,alphabet:r}){let{encode:n,decode:o}=me(r,t);return ye({prefix:e,name:t,encode:n,decode:s=>L(o(s))})}function Ze(t,e,r,n){let o={};for(let i=0;i<e.length;++i)o[e[i]]=i;let s=t.length;for(;t[s-1]==="=";)--s;let a=new Uint8Array(s*r/8|0),u=0,d=0,y=0;for(let i=0;i<s;++i){let c=o[t[i]];if(c===void 0)throw new SyntaxError(`Non-${n} character`);d=d<<r|c,u+=r,u>=8&&(u-=8,a[y++]=255&d>>u)}if(u>=r||255&d<<8-u)throw new SyntaxError("Unexpected end of data");return a}function He(t,e,r){let n=e[e.length-1]==="=",o=(1<<r)-1,s="",a=0,u=0;for(let d=0;d<t.length;++d)for(u=u<<8|t[d],a+=8;a>r;)a-=r,s+=e[o&u>>a];if(a!==0&&(s+=e[o&u<<r-a]),n)for(;s.length*r&7;)s+="=";return s}function g({name:t,prefix:e,bitsPerChar:r,alphabet:n}){return ye({prefix:e,name:t,encode(o){return He(o,n,r)},decode(o){return Ze(o,n,r,t)}})}var M=g({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),we=g({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),ir=g({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),ar=g({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),cr=g({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),ur=g({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),dr=g({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),fr=g({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),lr=g({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var K=N({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),mr=N({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var I=N({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),wr=N({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ye=Ce,ge=128,_e=127,et=~_e,tt=Math.pow(2,31);function Ce(t,e,r){e=e||[],r=r||0;for(var n=r;t>=tt;)e[r++]=t&255|ge,t/=128;for(;t&et;)e[r++]=t&255|ge,t>>>=7;return e[r]=t|0,Ce.bytes=r-n+1,e}var rt=te,nt=128,xe=127;function te(t,n){var r=0,n=n||0,o=0,s=n,a,u=t.length;do{if(s>=u)throw te.bytes=0,new RangeError("Could not decode varint");a=t[s++],r+=o<28?(a&xe)<<o:(a&xe)*Math.pow(2,o),o+=7}while(a>=nt);return te.bytes=s-n,r}var ot=Math.pow(2,7),st=Math.pow(2,14),it=Math.pow(2,21),at=Math.pow(2,28),ct=Math.pow(2,35),ut=Math.pow(2,42),dt=Math.pow(2,49),ft=Math.pow(2,56),lt=Math.pow(2,63),ht=function(t){return t<ot?1:t<st?2:t<it?3:t<at?4:t<ct?5:t<ut?6:t<dt?7:t<ft?8:t<lt?9:10},pt={encode:Ye,decode:rt,encodingLength:ht},mt=pt,V=mt;function T(t,e=0){return[V.decode(t,e),V.decode.bytes]}function O(t,e,r=0){return V.encode(t,e,r),e}function $(t){return V.encodingLength(t)}function Ee(t,e){let r=e.byteLength,n=$(t),o=n+$(r),s=new Uint8Array(o+r);return O(t,s,0),O(r,s,n),s.set(e,o),new U(t,r,e,s)}function j(t){let e=L(t),[r,n]=T(e),[o,s]=T(e.subarray(n)),a=e.subarray(n+s);if(a.byteLength!==o)throw new Error("Incorrect length");return new U(r,o,a,e)}function Fe(t,e){if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&pe(t.bytes,r.bytes)}}var U=class{code;size;digest;bytes;constructor(e,r,n,o){this.code=e,this.size=r,this.digest=n,this.bytes=o}};function Se(t,e){let{bytes:r,version:n}=t;switch(n){case 0:return yt(r,ne(t),e??I.encoder);default:return wt(r,ne(t),e??M.encoder)}}var Ie=new WeakMap;function ne(t){let e=Ie.get(t);if(e==null){let r=new Map;return Ie.set(t,r),r}return e}var q=class t{code;version;multihash;bytes;"/";constructor(e,r,n,o){this.code=r,this.version=e,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:r}=this;if(e!==R)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==gt)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return t.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:r}=this.multihash,n=Ee(e,r);return t.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return t.equals(this,e)}static equals(e,r){let n=r;return n!=null&&e.code===n.code&&e.version===n.version&&Fe(e.multihash,n.multihash)}toString(e){return Se(this,e)}toJSON(){return{"/":Se(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let r=e;if(r instanceof t)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:s,bytes:a}=r;return new t(n,o,s,a??De(n,o,s.bytes))}else if(r[xt]===!0){let{version:n,multihash:o,code:s}=r,a=j(o);return t.create(n,s,a)}else return null}static create(e,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(e){case 0:{if(r!==R)throw new Error(`Version 0 CID must use dag-pb (code: ${R}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let o=De(e,r,n.bytes);return new t(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,R,e)}static createV1(e,r){return t.create(1,e,r)}static decode(e){let[r,n]=t.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=t.inspectBytes(e),n=r.size-r.multihashSize,o=L(e.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let s=o.subarray(r.multihashSize-r.digestSize),a=new U(r.multihashCode,r.digestSize,s,o);return[r.version===0?t.createV0(a):t.createV1(r.codec,a),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[c,h]=T(e.subarray(r));return r+=h,c},o=n(),s=R;if(o===18?(o=0,r=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let a=r,u=n(),d=n(),y=r+d,i=y-a;return{version:o,codec:s,multihashCode:u,digestSize:d,multihashSize:i,size:y}}static parse(e,r){let[n,o]=bt(e,r),s=t.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return ne(s).set(n,e),s}};function bt(t,e){switch(t[0]){case"Q":{let r=e??I;return[I.prefix,r.decode(`${I.prefix}${t}`)]}case I.prefix:{let r=e??I;return[I.prefix,r.decode(t)]}case M.prefix:{let r=e??M;return[M.prefix,r.decode(t)]}case K.prefix:{let r=e??K;return[K.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}}function yt(t,e,r){let{prefix:n}=r;if(n!==I.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=e.get(n);if(o==null){let s=r.encode(t).slice(1);return e.set(n,s),s}else return o}function wt(t,e,r){let{prefix:n}=r,o=e.get(n);if(o==null){let s=r.encode(t);return e.set(n,s),s}else return o}var R=112,gt=18;function De(t,e,r){let n=$(t),o=n+$(e),s=new Uint8Array(o+r.byteLength);return O(t,s,0),O(e,s,n),s.set(r,o),s}var xt=Symbol.for("@ipld/js-cid/CID");var oe=85;var Me=g({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Vr=g({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Tr=g({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),jr=g({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function Ct(t,e){try{if(typeof t=="string"&&t.length>0)return vt(t);if(typeof t=="number"&&isFinite(t))return e?.long?Ft(t):Et(t);throw new Error("Value is not a string or number.")}catch(r){let n=St(r)?`${r.message}. value=${JSON.stringify(t)}`:"An unknown error has occured.";throw new Error(n)}}function vt(t){if(t=String(t),t.length>100)throw new Error("Value exceeds the maximum length of 100 characters.");let e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(t);if(!e)return NaN;let r=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return r*315576e5;case"weeks":case"week":case"w":return r*6048e5;case"days":case"day":case"d":return r*864e5;case"hours":case"hour":case"hrs":case"hr":case"h":return r*36e5;case"minutes":case"minute":case"mins":case"min":case"m":return r*6e4;case"seconds":case"second":case"secs":case"sec":case"s":return r*1e3;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:throw new Error(`The unit ${n} was matched, but no matching case exists.`)}}var G=Ct;function Et(t){let e=Math.abs(t);return e>=864e5?`${Math.round(t/864e5)}d`:e>=36e5?`${Math.round(t/36e5)}h`:e>=6e4?`${Math.round(t/6e4)}m`:e>=1e3?`${Math.round(t/1e3)}s`:`${t}ms`}function Ft(t){let e=Math.abs(t);return e>=864e5?W(t,e,864e5,"day"):e>=36e5?W(t,e,36e5,"hour"):e>=6e4?W(t,e,6e4,"minute"):e>=1e3?W(t,e,1e3,"second"):`${t} ms`}function W(t,e,r,n){let o=e>=r*1.5;return`${Math.round(t/r)} ${n}${o?"s":""}`}function St(t){return typeof t=="object"&&t!==null&&"message"in t}function se(t){r.debug=r,r.default=r,r.coerce=d,r.disable=s,r.enable=o,r.enabled=a,r.humanize=G,r.destroy=y,Object.keys(t).forEach(i=>{r[i]=t[i]}),r.names=[],r.skips=[],r.formatters={};function e(i){let c=0;for(let h=0;h<i.length;h++)c=(c<<5)-c+i.charCodeAt(h),c|=0;return r.colors[Math.abs(c)%r.colors.length]}r.selectColor=e;function r(i){let c,h=null,z,f;function l(...p){if(!l.enabled)return;let m=l,w=Number(new Date),v=w-(c||w);m.diff=v,m.prev=c,m.curr=w,c=w,p[0]=r.coerce(p[0]),typeof p[0]!="string"&&p.unshift("%O");let b=0;p[0]=p[0].replace(/%([a-zA-Z%])/g,(E,x)=>{if(E==="%%")return"%";b++;let F=r.formatters[x];if(typeof F=="function"){let P=p[b];E=F.call(m,P),p.splice(b,1),b--}return E}),r.formatArgs.call(m,p),(m.log||r.log).apply(m,p)}return l.namespace=i,l.useColors=r.useColors(),l.color=r.selectColor(i),l.extend=n,l.destroy=r.destroy,Object.defineProperty(l,"enabled",{enumerable:!0,configurable:!1,get:()=>h!==null?h:(z!==r.namespaces&&(z=r.namespaces,f=r.enabled(i)),f),set:p=>{h=p}}),typeof r.init=="function"&&r.init(l),l}function n(i,c){let h=r(this.namespace+(typeof c>"u"?":":c)+i);return h.log=this.log,h}function o(i){r.save(i),r.namespaces=i,r.names=[],r.skips=[];let c,h=(typeof i=="string"?i:"").split(/[\s,]+/),z=h.length;for(c=0;c<z;c++)h[c]&&(i=h[c].replace(/\*/g,".*?"),i[0]==="-"?r.skips.push(new RegExp("^"+i.substr(1)+"$")):r.names.push(new RegExp("^"+i+"$")))}function s(){let i=[...r.names.map(u),...r.skips.map(u).map(c=>"-"+c)].join(",");return r.enable(""),i}function a(i){if(i[i.length-1]==="*")return!0;let c,h;for(c=0,h=r.skips.length;c<h;c++)if(r.skips[c].test(i))return!1;for(c=0,h=r.names.length;c<h;c++)if(r.names[c].test(i))return!0;return!1}function u(i){return i.toString().substring(2,i.toString().length-2).replace(/\.\*\?$/,"*")}function d(i){return i instanceof Error?i.stack??i.message:i}function y(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.setupFormatters(r.formatters),r.enable(r.load()),r}var Q=Lt(),It=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function Dt(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent?.toLowerCase().match(/(edge|trident)\/(\d+)/)!=null?!1:typeof document<"u"&&document.documentElement?.style?.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent?.toLowerCase().match(/firefox\/(\d+)/)!=null&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent?.toLowerCase().match(/applewebkit\/(\d+)/)}function At(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+G(this.diff),!this.useColors)return;let e="color: "+this.color;t.splice(1,0,e,"color: inherit");let r=0,n=0;t[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(r++,o==="%c"&&(n=r))}),t.splice(n,0,e)}var Mt=console.debug??console.log??(()=>{});function kt(t){try{t?Q?.setItem("debug",t):Q?.removeItem("debug")}catch{}}function Bt(){let t;try{t=Q?.getItem("debug")}catch{}return!t&&typeof process<"u"&&"env"in process&&(t=process.env.DEBUG),t}function Lt(){try{return localStorage}catch{}}function zt(t){t.j=function(e){try{return JSON.stringify(e)}catch(r){return"[UnexpectedJSONParseError]: "+r.message}}}var ke=se({formatArgs:At,save:kt,load:Bt,useColors:Dt,setupFormatters:zt,colors:It,storage:Q,log:Mt});var C=ke;C.formatters.b=t=>t==null?"undefined":I.baseEncode(t);C.formatters.t=t=>t==null?"undefined":M.baseEncode(t);C.formatters.m=t=>t==null?"undefined":Me.baseEncode(t);C.formatters.p=t=>t==null?"undefined":t.toString();C.formatters.c=t=>t==null?"undefined":t.toString();C.formatters.k=t=>t==null?"undefined":t.toString();C.formatters.a=t=>t==null?"undefined":t.toString();function Pt(t){let e=()=>{};return e.enabled=!1,e.color="",e.diff=0,e.log=()=>{},e.namespace=t,e.destroy=()=>!0,e.extend=()=>e,e}function Be(t){let e=Pt(`${t}:trace`);return C.enabled(`${t}:trace`)&&C.names.map(r=>r.toString()).find(r=>r.includes(":trace"))!=null&&(e=C(`${t}:trace`)),Object.assign(C(t),{error:C(`${t}:error`),trace:e})}var Sn=Be("blockstore:core:tiered");var ce=(t,e)=>e.some(r=>t instanceof r),Le,ze;function Ot(){return Le||(Le=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function $t(){return ze||(ze=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var ue=new WeakMap,ie=new WeakMap,X=new WeakMap;function Ut(t){let e=new Promise((r,n)=>{let o=()=>{t.removeEventListener("success",s),t.removeEventListener("error",a)},s=()=>{r(k(t.result)),o()},a=()=>{n(t.error),o()};t.addEventListener("success",s),t.addEventListener("error",a)});return X.set(e,t),e}function Vt(t){if(ue.has(t))return;let e=new Promise((r,n)=>{let o=()=>{t.removeEventListener("complete",s),t.removeEventListener("error",a),t.removeEventListener("abort",a)},s=()=>{r(),o()},a=()=>{n(t.error||new DOMException("AbortError","AbortError")),o()};t.addEventListener("complete",s),t.addEventListener("error",a),t.addEventListener("abort",a)});ue.set(t,e)}var de={get(t,e,r){if(t instanceof IDBTransaction){if(e==="done")return ue.get(t);if(e==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return k(t[e])},set(t,e,r){return t[e]=r,!0},has(t,e){return t instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in t}};function $e(t){de=t(de)}function Tt(t){return $t().includes(t)?function(...e){return t.apply(fe(this),e),k(this.request)}:function(...e){return k(t.apply(fe(this),e))}}function jt(t){return typeof t=="function"?Tt(t):(t instanceof IDBTransaction&&Vt(t),ce(t,Ot())?new Proxy(t,de):t)}function k(t){if(t instanceof IDBRequest)return Ut(t);if(ie.has(t))return ie.get(t);let e=jt(t);return e!==t&&(ie.set(t,e),X.set(e,t)),e}var fe=t=>X.get(t);function Ue(t,e,{blocked:r,upgrade:n,blocking:o,terminated:s}={}){let a=indexedDB.open(t,e),u=k(a);return n&&a.addEventListener("upgradeneeded",d=>{n(k(a.result),d.oldVersion,d.newVersion,k(a.transaction),d)}),r&&a.addEventListener("blocked",d=>r(d.oldVersion,d.newVersion,d)),u.then(d=>{s&&d.addEventListener("close",()=>s()),o&&d.addEventListener("versionchange",y=>o(y.oldVersion,y.newVersion,y))}).catch(()=>{}),u}function Ve(t,{blocked:e}={}){let r=indexedDB.deleteDatabase(t);return e&&r.addEventListener("blocked",n=>e(n.oldVersion,n)),k(r).then(()=>{})}var Rt=["get","getKey","getAll","getAllKeys","count"],qt=["put","add","delete","clear"],ae=new Map;function Pe(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e=="string"))return;if(ae.get(e))return ae.get(e);let r=e.replace(/FromIndex$/,""),n=e!==r,o=qt.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!(o||Rt.includes(r)))return;let s=async function(a,...u){let d=this.transaction(a,o?"readwrite":"readonly"),y=d.store;return n&&(y=y.index(u.shift())),(await Promise.all([y[r](...u),o&&d.done]))[0]};return ae.set(e,s),s}$e(t=>({...t,get:(e,r,n)=>Pe(e,r)||t.get(e,r,n),has:(e,r)=>!!Pe(e,r)||t.has(e,r)}));var Jt=["continue","continuePrimaryKey","advance"],Ne={},le=new WeakMap,Te=new WeakMap,Kt={get(t,e){if(!Jt.includes(e))return t[e];let r=Ne[e];return r||(r=Ne[e]=function(...n){le.set(this,Te.get(this)[e](...n))}),r}};async function*Wt(...t){let e=this;if(e instanceof IDBCursor||(e=await e.openCursor(...t)),!e)return;e=e;let r=new Proxy(e,Kt);for(Te.set(r,e),X.set(r,fe(e));e;)yield r,e=await(le.get(r)||e.continue()),le.delete(r)}function Oe(t,e){return e===Symbol.asyncIterator&&ce(t,[IDBIndex,IDBObjectStore,IDBCursor])||e==="iterate"&&ce(t,[IDBIndex,IDBObjectStore])}$e(t=>({...t,get(e,r,n){return Oe(e,r)?Wt:t.get(e,r,n)},has(e,r){return Oe(e,r)||t.has(e,r)}}));var he=class extends D{location;version;db;base;constructor(e,r={}){super(),this.location=`${r.prefix??""}${e}`,this.version=r.version??1,this.base=r.base??we}#e(e){return`/${this.base.encoder.encode(e.multihash.bytes)}`}#t(e){return q.createV1(oe,j(this.base.decoder.decode(e.substring(1))))}async open(){try{let e=this.location;this.db=await Ue(e,this.version,{upgrade(r){r.createObjectStore(e)}})}catch(e){throw new J(String(e))}}async close(){this.db?.close()}async put(e,r){if(this.db==null)throw new Error("Blockstore needs to be opened.");try{return await this.db.put(this.location,r,this.#e(e)),e}catch(n){throw new A(String(n))}}async get(e){if(this.db==null)throw new Error("Blockstore needs to be opened.");let r;try{r=await this.db.get(this.location,this.#e(e))}catch(n){throw new A(String(n))}if(r===void 0)throw new B;return r}async delete(e){if(this.db==null)throw new Error("Blockstore needs to be opened.");try{await this.db.delete(this.location,this.#e(e))}catch(r){throw new A(String(r))}}async has(e){if(this.db==null)throw new Error("Blockstore needs to be opened.");try{return!!await this.db.getKey(this.location,this.#e(e))}catch(r){throw new A(String(r))}}async*getAll(e){if(this.db==null)throw new Error("Blockstore needs to be opened.");for(let r of await this.db.getAllKeys(this.location)){let n=this.#t(r.toString()),o=await this.get(n);yield{cid:n,block:o}}}async destroy(){await Ve(this.location)}};return We(Gt);})();
return BlockstoreIdb}));
{
"name": "blockstore-idb",
"version": "2.0.0",
"version": "2.0.1",
"description": "Blockstore implementation with IndexedDB backend",

@@ -47,2 +47,87 @@ "license": "Apache-2.0 OR MIT",

},
"release": {
"branches": [
"main"
],
"plugins": [
[
"@semantic-release/commit-analyzer",
{
"preset": "conventionalcommits",
"releaseRules": [
{
"breaking": true,
"release": "major"
},
{
"revert": true,
"release": "patch"
},
{
"type": "feat",
"release": "minor"
},
{
"type": "fix",
"release": "patch"
},
{
"type": "docs",
"release": "patch"
},
{
"type": "test",
"release": "patch"
},
{
"type": "deps",
"release": "patch"
},
{
"scope": "no-release",
"release": false
}
]
}
],
[
"@semantic-release/release-notes-generator",
{
"preset": "conventionalcommits",
"presetConfig": {
"types": [
{
"type": "feat",
"section": "Features"
},
{
"type": "fix",
"section": "Bug Fixes"
},
{
"type": "chore",
"section": "Trivial Changes"
},
{
"type": "docs",
"section": "Documentation"
},
{
"type": "deps",
"section": "Dependencies"
},
{
"type": "test",
"section": "Tests"
}
]
}
}
],
"@semantic-release/changelog",
"@semantic-release/npm",
"@semantic-release/github",
"@semantic-release/git"
]
},
"scripts": {

@@ -57,15 +142,16 @@ "clean": "aegir clean",

"test:firefox-webworker": "aegir test -t webworker -- --browser firefox",
"dep-check": "aegir dep-check"
"dep-check": "aegir dep-check",
"release": "aegir release"
},
"dependencies": {
"blockstore-core": "5.0.0",
"blockstore-core": "^5.0.0",
"idb": "^8.0.0",
"interface-blockstore": "^5.0.0",
"interface-store": "6.0.0",
"multiformats": "^13.0.1"
"interface-store": "^6.0.0",
"multiformats": "^13.2.3"
},
"devDependencies": {
"aegir": "^42.2.3",
"interface-blockstore-tests": "7.0.0"
"aegir": "^44.1.1",
"interface-blockstore-tests": "^7.0.0"
}
}

@@ -45,3 +45,3 @@ # blockstore-idb

Loading this module through a script tag will make it's exports available as `BlockstoreIdb` in the global namespace.
Loading this module through a script tag will make its exports available as `BlockstoreIdb` in the global namespace.

@@ -60,4 +60,4 @@ ```html

- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
- MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)
- Apache 2.0, ([LICENSE-APACHE](https://github.com/ipfs/js-stores/blob/main/packages/blockstore-idb/LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
- MIT ([LICENSE-MIT](https://github.com/ipfs/js-stores/blob/main/packages/blockstore-idb/LICENSE-MIT) / <http://opensource.org/licenses/MIT>)

@@ -64,0 +64,0 @@ # Contribute

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