lesca-node-bunnycdn 0.0.5 → 0.0.6

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/lib/index.cjs CHANGED
@@ -19,4 +19,4 @@ https://github.com/browserify/crypto-browserify`)},cryptoBrowserify.constants={D
19
19
  `+oe.prev+oe.base;return Oe+ie.call(re,","+Oe)+`
20
20
  `+oe.prev}function pe(re,oe){var Oe=A(re),ce=[];if(Oe){ce.length=re.length;for(var we=0;we<re.length;we++)ce[we]=Pe(re,we)?oe(re[we],re):""}var Ce=typeof e=="function"?e(re):[],qe;if(n){qe={};for(var Te=0;Te<Ce.length;Te++)qe["$"+Ce[Te]]=Ce[Te]}for(var je in re)Pe(re,je)&&(Oe&&String(Number(je))===je&&je<re.length||n&&qe["$"+je]instanceof Symbol||(X.call(/[^\w$]/,je)?ce.push(oe(je,re)+": "+oe(re[je],re)):ce.push(je+": "+oe(re[je],re))));if(typeof e=="function")for(var Be=0;Be<Ce.length;Be++)s.call(re,Ce[Be])&&ce.push("["+oe(Ce[Be])+"]: "+oe(re[Ce[Be]],re));return ce}return objectInspect}var sideChannelList,hasRequiredSideChannelList;function requireSideChannelList(){if(hasRequiredSideChannelList)return sideChannelList;hasRequiredSideChannelList=1;var g=requireObjectInspect(),_=requireType(),S=function(v,y,m){for(var d=v,b;(b=d.next)!=null;d=b)if(b.key===y)return d.next=b.next,m||(b.next=v.next,v.next=b),b},p=function(v,y){if(v){var m=S(v,y);return m&&m.value}},E=function(v,y,m){var d=S(v,y);d?d.value=m:v.next={key:y,next:v.next,value:m}},a=function(v,y){return v?!!S(v,y):!1},w=function(v,y){if(v)return S(v,y,!0)};return sideChannelList=function(){var y,m={assert:function(d){if(!m.has(d))throw new _("Side channel does not contain "+g(d))},delete:function(d){var b=y&&y.next,x=w(y,d);return x&&b&&b===x&&(y=void 0),!!x},get:function(d){return p(y,d)},has:function(d){return a(y,d)},set:function(d,b){y||(y={next:void 0}),E(y,d,b)}};return m},sideChannelList}var sideChannelMap,hasRequiredSideChannelMap;function requireSideChannelMap(){if(hasRequiredSideChannelMap)return sideChannelMap;hasRequiredSideChannelMap=1;var g=requireGetIntrinsic(),_=requireCallBound(),S=requireObjectInspect(),p=requireType(),E=g("%Map%",!0),a=_("Map.prototype.get",!0),w=_("Map.prototype.set",!0),v=_("Map.prototype.has",!0),y=_("Map.prototype.delete",!0),m=_("Map.prototype.size",!0);return sideChannelMap=!!E&&function(){var b,x={assert:function(R){if(!x.has(R))throw new p("Side channel does not contain "+S(R))},delete:function(R){if(b){var q=y(b,R);return m(b)===0&&(b=void 0),q}return!1},get:function(R){if(b)return a(b,R)},has:function(R){return b?v(b,R):!1},set:function(R,q){b||(b=new E),w(b,R,q)}};return x},sideChannelMap}var sideChannelWeakmap,hasRequiredSideChannelWeakmap;function requireSideChannelWeakmap(){if(hasRequiredSideChannelWeakmap)return sideChannelWeakmap;hasRequiredSideChannelWeakmap=1;var g=requireGetIntrinsic(),_=requireCallBound(),S=requireObjectInspect(),p=requireSideChannelMap(),E=requireType(),a=g("%WeakMap%",!0),w=_("WeakMap.prototype.get",!0),v=_("WeakMap.prototype.set",!0),y=_("WeakMap.prototype.has",!0),m=_("WeakMap.prototype.delete",!0);return sideChannelWeakmap=a?function(){var b,x,R={assert:function(q){if(!R.has(q))throw new E("Side channel does not contain "+S(q))},delete:function(q){if(a&&q&&(typeof q=="object"||typeof q=="function")){if(b)return m(b,q)}else if(p&&x)return x.delete(q);return!1},get:function(q){return a&&q&&(typeof q=="object"||typeof q=="function")&&b?w(b,q):x&&x.get(q)},has:function(q){return a&&q&&(typeof q=="object"||typeof q=="function")&&b?y(b,q):!!x&&x.has(q)},set:function(q,B){a&&q&&(typeof q=="object"||typeof q=="function")?(b||(b=new a),v(b,q,B)):p&&(x||(x=p()),x.set(q,B))}};return R}:p,sideChannelWeakmap}var sideChannel,hasRequiredSideChannel;function requireSideChannel(){if(hasRequiredSideChannel)return sideChannel;hasRequiredSideChannel=1;var g=requireType(),_=requireObjectInspect(),S=requireSideChannelList(),p=requireSideChannelMap(),E=requireSideChannelWeakmap(),a=E||p||S;return sideChannel=function(){var v,y={assert:function(m){if(!y.has(m))throw new g("Side channel does not contain "+_(m))},delete:function(m){return!!v&&v.delete(m)},get:function(m){return v&&v.get(m)},has:function(m){return!!v&&v.has(m)},set:function(m,d){v||(v=a()),v.set(m,d)}};return y},sideChannel}var formats,hasRequiredFormats;function requireFormats(){if(hasRequiredFormats)return formats;hasRequiredFormats=1;var g=String.prototype.replace,_=/%20/g,S={RFC1738:"RFC1738",RFC3986:"RFC3986"};return formats={default:S.RFC3986,formatters:{RFC1738:function(p){return g.call(p,_,"+")},RFC3986:function(p){return String(p)}},RFC1738:S.RFC1738,RFC3986:S.RFC3986},formats}var utils,hasRequiredUtils;function requireUtils(){if(hasRequiredUtils)return utils;hasRequiredUtils=1;var g=requireFormats(),_=requireSideChannel(),S=Object.prototype.hasOwnProperty,p=Array.isArray,E=_(),a=function(te,ie){return E.set(te,ie),te},w=function(te){return E.has(te)},v=function(te){return E.get(te)},y=function(te,ie){E.set(te,ie)},m=(function(){for(var X=[],te=0;te<256;++te)X.push("%"+((te<16?"0":"")+te.toString(16)).toUpperCase());return X})(),d=function(te){for(;te.length>1;){var ie=te.pop(),ee=ie.obj[ie.prop];if(p(ee)){for(var ue=[],c=0;c<ee.length;++c)typeof ee[c]<"u"&&ue.push(ee[c]);ie.obj[ie.prop]=ue}}},b=function(te,ie){for(var ee=ie&&ie.plainObjects?{__proto__:null}:{},ue=0;ue<te.length;++ue)typeof te[ue]<"u"&&(ee[ue]=te[ue]);return ee},x=function X(te,ie,ee){if(!ie)return te;if(typeof ie!="object"&&typeof ie!="function"){if(p(te))te.push(ie);else if(te&&typeof te=="object")if(w(te)){var ue=v(te)+1;te[ue]=ie,y(te,ue)}else(ee&&(ee.plainObjects||ee.allowPrototypes)||!S.call(Object.prototype,ie))&&(te[ie]=!0);else return[te,ie];return te}if(!te||typeof te!="object"){if(w(ie)){for(var c=Object.keys(ie),e=ee&&ee.plainObjects?{__proto__:null,0:te}:{0:te},t=0;t<c.length;t++){var n=parseInt(c[t],10);e[n+1]=ie[c[t]]}return a(e,v(ie)+1)}return[te].concat(ie)}var f=te;return p(te)&&!p(ie)&&(f=b(te,ee)),p(te)&&p(ie)?(ie.forEach(function(s,u){if(S.call(te,u)){var l=te[u];l&&typeof l=="object"&&s&&typeof s=="object"?te[u]=X(l,s,ee):te.push(s)}else te[u]=s}),te):Object.keys(ie).reduce(function(s,u){var l=ie[u];return S.call(s,u)?s[u]=X(s[u],l,ee):s[u]=l,s},f)},R=function(te,ie){return Object.keys(ie).reduce(function(ee,ue){return ee[ue]=ie[ue],ee},te)},q=function(X,te,ie){var ee=X.replace(/\+/g," ");if(ie==="iso-8859-1")return ee.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(ee)}catch{return ee}},B=1024,$=function(te,ie,ee,ue,c){if(te.length===0)return te;var e=te;if(typeof te=="symbol"?e=Symbol.prototype.toString.call(te):typeof te!="string"&&(e=String(te)),ee==="iso-8859-1")return escape(e).replace(/%u[0-9a-f]{4}/gi,function(o){return"%26%23"+parseInt(o.slice(2),16)+"%3B"});for(var t="",n=0;n<e.length;n+=B){for(var f=e.length>=B?e.slice(n,n+B):e,s=[],u=0;u<f.length;++u){var l=f.charCodeAt(u);if(l===45||l===46||l===95||l===126||l>=48&&l<=57||l>=65&&l<=90||l>=97&&l<=122||c===g.RFC1738&&(l===40||l===41)){s[s.length]=f.charAt(u);continue}if(l<128){s[s.length]=m[l];continue}if(l<2048){s[s.length]=m[192|l>>6]+m[128|l&63];continue}if(l<55296||l>=57344){s[s.length]=m[224|l>>12]+m[128|l>>6&63]+m[128|l&63];continue}u+=1,l=65536+((l&1023)<<10|f.charCodeAt(u)&1023),s[s.length]=m[240|l>>18]+m[128|l>>12&63]+m[128|l>>6&63]+m[128|l&63]}t+=s.join("")}return t},k=function(te){for(var ie=[{obj:{o:te},prop:"o"}],ee=[],ue=0;ue<ie.length;++ue)for(var c=ie[ue],e=c.obj[c.prop],t=Object.keys(e),n=0;n<t.length;++n){var f=t[n],s=e[f];typeof s=="object"&&s!==null&&ee.indexOf(s)===-1&&(ie.push({obj:e,prop:f}),ee.push(s))}return d(ie),te},I=function(te){return Object.prototype.toString.call(te)==="[object RegExp]"},L=function(te){return!te||typeof te!="object"?!1:!!(te.constructor&&te.constructor.isBuffer&&te.constructor.isBuffer(te))},D=function(te,ie,ee,ue){if(w(te)){var c=v(te)+1;return te[c]=ie,y(te,c),te}var e=[].concat(te,ie);return e.length>ee?a(b(e,{plainObjects:ue}),e.length-1):e},G=function(te,ie){if(p(te)){for(var ee=[],ue=0;ue<te.length;ue+=1)ee.push(ie(te[ue]));return ee}return ie(te)};return utils={arrayToObject:b,assign:R,combine:D,compact:k,decode:q,encode:$,isBuffer:L,isOverflow:w,isRegExp:I,maybeMap:G,merge:x},utils}var stringify_1,hasRequiredStringify;function requireStringify(){if(hasRequiredStringify)return stringify_1;hasRequiredStringify=1;var g=requireSideChannel(),_=requireUtils(),S=requireFormats(),p=Object.prototype.hasOwnProperty,E={brackets:function($){return $+"[]"},comma:"comma",indices:function($,k){return $+"["+k+"]"},repeat:function($){return $}},a=Array.isArray,w=Array.prototype.push,v=function(B,$){w.apply(B,a($)?$:[$])},y=Date.prototype.toISOString,m=S.default,d={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,commaRoundTrip:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:_.encode,encodeValuesOnly:!1,filter:void 0,format:m,formatter:S.formatters[m],indices:!1,serializeDate:function($){return y.call($)},skipNulls:!1,strictNullHandling:!1},b=function($){return typeof $=="string"||typeof $=="number"||typeof $=="boolean"||typeof $=="symbol"||typeof $=="bigint"},x={},R=function B($,k,I,L,D,G,X,te,ie,ee,ue,c,e,t,n,f,s,u){for(var l=$,o=u,r=0,h=!1;(o=o.get(x))!==void 0&&!h;){var M=o.get($);if(r+=1,typeof M<"u"){if(M===r)throw new RangeError("Cyclic object value");h=!0}typeof o.get(x)>"u"&&(r=0)}if(typeof ee=="function"?l=ee(k,l):l instanceof Date?l=e(l):I==="comma"&&a(l)&&(l=_.maybeMap(l,function(le){return le instanceof Date?e(le):le})),l===null){if(G)return ie&&!f?ie(k,d.encoder,s,"key",t):k;l=""}if(b(l)||_.isBuffer(l)){if(ie){var T=f?k:ie(k,d.encoder,s,"key",t);return[n(T)+"="+n(ie(l,d.encoder,s,"value",t))]}return[n(k)+"="+n(String(l))]}var N=[];if(typeof l>"u")return N;var Q;if(I==="comma"&&a(l))f&&ie&&(l=_.maybeMap(l,ie)),Q=[{value:l.length>0?l.join(",")||null:void 0}];else if(a(ee))Q=ee;else{var K=Object.keys(l);Q=ue?K.sort(ue):K}var A=te?String(k).replace(/\./g,"%2E"):String(k),O=L&&a(l)&&l.length===1?A+"[]":A;if(D&&a(l)&&l.length===0)return O+"[]";for(var W=0;W<Q.length;++W){var J=Q[W],Z=typeof J=="object"&&J&&typeof J.value<"u"?J.value:l[J];if(!(X&&Z===null)){var j=c&&te?String(J).replace(/\./g,"%2E"):String(J),ne=a(l)?typeof I=="function"?I(O,j):O:O+(c?"."+j:"["+j+"]");u.set($,r);var Re=g();Re.set(x,u),v(N,B(Z,ne,I,L,D,G,X,te,I==="comma"&&f&&a(l)?null:ie,ee,ue,c,e,t,n,f,s,Re))}}return N},q=function($){if(!$)return d;if(typeof $.allowEmptyArrays<"u"&&typeof $.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof $.encodeDotInKeys<"u"&&typeof $.encodeDotInKeys!="boolean")throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if($.encoder!==null&&typeof $.encoder<"u"&&typeof $.encoder!="function")throw new TypeError("Encoder has to be a function.");var k=$.charset||d.charset;if(typeof $.charset<"u"&&$.charset!=="utf-8"&&$.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var I=S.default;if(typeof $.format<"u"){if(!p.call(S.formatters,$.format))throw new TypeError("Unknown format option provided.");I=$.format}var L=S.formatters[I],D=d.filter;(typeof $.filter=="function"||a($.filter))&&(D=$.filter);var G;if($.arrayFormat in E?G=$.arrayFormat:"indices"in $?G=$.indices?"indices":"repeat":G=d.arrayFormat,"commaRoundTrip"in $&&typeof $.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var X=typeof $.allowDots>"u"?$.encodeDotInKeys===!0?!0:d.allowDots:!!$.allowDots;return{addQueryPrefix:typeof $.addQueryPrefix=="boolean"?$.addQueryPrefix:d.addQueryPrefix,allowDots:X,allowEmptyArrays:typeof $.allowEmptyArrays=="boolean"?!!$.allowEmptyArrays:d.allowEmptyArrays,arrayFormat:G,charset:k,charsetSentinel:typeof $.charsetSentinel=="boolean"?$.charsetSentinel:d.charsetSentinel,commaRoundTrip:!!$.commaRoundTrip,delimiter:typeof $.delimiter>"u"?d.delimiter:$.delimiter,encode:typeof $.encode=="boolean"?$.encode:d.encode,encodeDotInKeys:typeof $.encodeDotInKeys=="boolean"?$.encodeDotInKeys:d.encodeDotInKeys,encoder:typeof $.encoder=="function"?$.encoder:d.encoder,encodeValuesOnly:typeof $.encodeValuesOnly=="boolean"?$.encodeValuesOnly:d.encodeValuesOnly,filter:D,format:I,formatter:L,serializeDate:typeof $.serializeDate=="function"?$.serializeDate:d.serializeDate,skipNulls:typeof $.skipNulls=="boolean"?$.skipNulls:d.skipNulls,sort:typeof $.sort=="function"?$.sort:null,strictNullHandling:typeof $.strictNullHandling=="boolean"?$.strictNullHandling:d.strictNullHandling}};return stringify_1=function(B,$){var k=B,I=q($),L,D;typeof I.filter=="function"?(D=I.filter,k=D("",k)):a(I.filter)&&(D=I.filter,L=D);var G=[];if(typeof k!="object"||k===null)return"";var X=E[I.arrayFormat],te=X==="comma"&&I.commaRoundTrip;L||(L=Object.keys(k)),I.sort&&L.sort(I.sort);for(var ie=g(),ee=0;ee<L.length;++ee){var ue=L[ee],c=k[ue];I.skipNulls&&c===null||v(G,R(c,ue,X,te,I.allowEmptyArrays,I.strictNullHandling,I.skipNulls,I.encodeDotInKeys,I.encode?I.encoder:null,I.filter,I.sort,I.allowDots,I.serializeDate,I.format,I.formatter,I.encodeValuesOnly,I.charset,ie))}var e=G.join(I.delimiter),t=I.addQueryPrefix===!0?"?":"";return I.charsetSentinel&&(I.charset==="iso-8859-1"?t+="utf8=%26%2310003%3B&":t+="utf8=%E2%9C%93&"),e.length>0?t+e:""},stringify_1}var parse$1,hasRequiredParse;function requireParse(){if(hasRequiredParse)return parse$1;hasRequiredParse=1;var g=requireUtils(),_=Object.prototype.hasOwnProperty,S=Array.isArray,p={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decodeDotInKeys:!1,decoder:g.decode,delimiter:"&",depth:5,duplicates:"combine",ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictDepth:!1,strictNullHandling:!1,throwOnLimitExceeded:!1},E=function(R){return R.replace(/&#(\d+);/g,function(q,B){return String.fromCharCode(parseInt(B,10))})},a=function(R,q,B){if(R&&typeof R=="string"&&q.comma&&R.indexOf(",")>-1)return R.split(",");if(q.throwOnLimitExceeded&&B>=q.arrayLimit)throw new RangeError("Array limit exceeded. Only "+q.arrayLimit+" element"+(q.arrayLimit===1?"":"s")+" allowed in an array.");return R},w="utf8=%26%2310003%3B",v="utf8=%E2%9C%93",y=function(q,B){var $={__proto__:null},k=B.ignoreQueryPrefix?q.replace(/^\?/,""):q;k=k.replace(/%5B/gi,"[").replace(/%5D/gi,"]");var I=B.parameterLimit===1/0?void 0:B.parameterLimit,L=k.split(B.delimiter,B.throwOnLimitExceeded?I+1:I);if(B.throwOnLimitExceeded&&L.length>I)throw new RangeError("Parameter limit exceeded. Only "+I+" parameter"+(I===1?"":"s")+" allowed.");var D=-1,G,X=B.charset;if(B.charsetSentinel)for(G=0;G<L.length;++G)L[G].indexOf("utf8=")===0&&(L[G]===v?X="utf-8":L[G]===w&&(X="iso-8859-1"),D=G,G=L.length);for(G=0;G<L.length;++G)if(G!==D){var te=L[G],ie=te.indexOf("]="),ee=ie===-1?te.indexOf("="):ie+1,ue,c;if(ee===-1?(ue=B.decoder(te,p.decoder,X,"key"),c=B.strictNullHandling?null:""):(ue=B.decoder(te.slice(0,ee),p.decoder,X,"key"),ue!==null&&(c=g.maybeMap(a(te.slice(ee+1),B,S($[ue])?$[ue].length:0),function(t){return B.decoder(t,p.decoder,X,"value")}))),c&&B.interpretNumericEntities&&X==="iso-8859-1"&&(c=E(String(c))),te.indexOf("[]=")>-1&&(c=S(c)?[c]:c),ue!==null){var e=_.call($,ue);e&&B.duplicates==="combine"?$[ue]=g.combine($[ue],c,B.arrayLimit,B.plainObjects):(!e||B.duplicates==="last")&&($[ue]=c)}}return $},m=function(R,q,B,$){var k=0;if(R.length>0&&R[R.length-1]==="[]"){var I=R.slice(0,-1).join("");k=Array.isArray(q)&&q[I]?q[I].length:0}for(var L=$?q:a(q,B,k),D=R.length-1;D>=0;--D){var G,X=R[D];if(X==="[]"&&B.parseArrays)g.isOverflow(L)?G=L:G=B.allowEmptyArrays&&(L===""||B.strictNullHandling&&L===null)?[]:g.combine([],L,B.arrayLimit,B.plainObjects);else{G=B.plainObjects?{__proto__:null}:{};var te=X.charAt(0)==="["&&X.charAt(X.length-1)==="]"?X.slice(1,-1):X,ie=B.decodeDotInKeys?te.replace(/%2E/g,"."):te,ee=parseInt(ie,10);!B.parseArrays&&ie===""?G={0:L}:!isNaN(ee)&&X!==ie&&String(ee)===ie&&ee>=0&&B.parseArrays&&ee<=B.arrayLimit?(G=[],G[ee]=L):ie!=="__proto__"&&(G[ie]=L)}L=G}return L},d=function(q,B){var $=B.allowDots?q.replace(/\.([^.[]+)/g,"[$1]"):q;if(B.depth<=0)return!B.plainObjects&&_.call(Object.prototype,$)&&!B.allowPrototypes?void 0:[$];var k=/(\[[^[\]]*])/,I=/(\[[^[\]]*])/g,L=k.exec($),D=L?$.slice(0,L.index):$,G=[];if(D){if(!B.plainObjects&&_.call(Object.prototype,D)&&!B.allowPrototypes)return;G.push(D)}for(var X=0;(L=I.exec($))!==null&&X<B.depth;){X+=1;var te=L[1].slice(1,-1);if(!B.plainObjects&&_.call(Object.prototype,te)&&!B.allowPrototypes)return;G.push(L[1])}if(L){if(B.strictDepth===!0)throw new RangeError("Input depth exceeded depth option of "+B.depth+" and strictDepth is true");G.push("["+$.slice(L.index)+"]")}return G},b=function(q,B,$,k){if(q){var I=d(q,$);if(I)return m(I,B,$,k)}},x=function(q){if(!q)return p;if(typeof q.allowEmptyArrays<"u"&&typeof q.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof q.decodeDotInKeys<"u"&&typeof q.decodeDotInKeys!="boolean")throw new TypeError("`decodeDotInKeys` option can only be `true` or `false`, when provided");if(q.decoder!==null&&typeof q.decoder<"u"&&typeof q.decoder!="function")throw new TypeError("Decoder has to be a function.");if(typeof q.charset<"u"&&q.charset!=="utf-8"&&q.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");if(typeof q.throwOnLimitExceeded<"u"&&typeof q.throwOnLimitExceeded!="boolean")throw new TypeError("`throwOnLimitExceeded` option must be a boolean");var B=typeof q.charset>"u"?p.charset:q.charset,$=typeof q.duplicates>"u"?p.duplicates:q.duplicates;if($!=="combine"&&$!=="first"&&$!=="last")throw new TypeError("The duplicates option must be either combine, first, or last");var k=typeof q.allowDots>"u"?q.decodeDotInKeys===!0?!0:p.allowDots:!!q.allowDots;return{allowDots:k,allowEmptyArrays:typeof q.allowEmptyArrays=="boolean"?!!q.allowEmptyArrays:p.allowEmptyArrays,allowPrototypes:typeof q.allowPrototypes=="boolean"?q.allowPrototypes:p.allowPrototypes,allowSparse:typeof q.allowSparse=="boolean"?q.allowSparse:p.allowSparse,arrayLimit:typeof q.arrayLimit=="number"?q.arrayLimit:p.arrayLimit,charset:B,charsetSentinel:typeof q.charsetSentinel=="boolean"?q.charsetSentinel:p.charsetSentinel,comma:typeof q.comma=="boolean"?q.comma:p.comma,decodeDotInKeys:typeof q.decodeDotInKeys=="boolean"?q.decodeDotInKeys:p.decodeDotInKeys,decoder:typeof q.decoder=="function"?q.decoder:p.decoder,delimiter:typeof q.delimiter=="string"||g.isRegExp(q.delimiter)?q.delimiter:p.delimiter,depth:typeof q.depth=="number"||q.depth===!1?+q.depth:p.depth,duplicates:$,ignoreQueryPrefix:q.ignoreQueryPrefix===!0,interpretNumericEntities:typeof q.interpretNumericEntities=="boolean"?q.interpretNumericEntities:p.interpretNumericEntities,parameterLimit:typeof q.parameterLimit=="number"?q.parameterLimit:p.parameterLimit,parseArrays:q.parseArrays!==!1,plainObjects:typeof q.plainObjects=="boolean"?q.plainObjects:p.plainObjects,strictDepth:typeof q.strictDepth=="boolean"?!!q.strictDepth:p.strictDepth,strictNullHandling:typeof q.strictNullHandling=="boolean"?q.strictNullHandling:p.strictNullHandling,throwOnLimitExceeded:typeof q.throwOnLimitExceeded=="boolean"?q.throwOnLimitExceeded:!1}};return parse$1=function(R,q){var B=x(q);if(R===""||R===null||typeof R>"u")return B.plainObjects?{__proto__:null}:{};for(var $=typeof R=="string"?y(R,B):R,k=B.plainObjects?{__proto__:null}:{},I=Object.keys($),L=0;L<I.length;++L){var D=I[L],G=b(D,$[D],B,typeof R=="string");k=g.merge(k,G,B)}return B.allowSparse===!0?k:g.compact(k)},parse$1}var lib,hasRequiredLib;function requireLib(){if(hasRequiredLib)return lib;hasRequiredLib=1;var g=requireStringify(),_=requireParse(),S=requireFormats();return lib={formats:S,parse:_,stringify:g},lib}var libExports=requireLib();const require$$1$1=getDefaultExportFromCjs$1(libExports);var punycode=require$$0$1;function Url(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}var protocolPattern=/^([a-z0-9.+-]+:)/i,portPattern=/:[0-9]*$/,simplePathPattern=/^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/,delims=["<",">",'"',"`"," ","\r",`
21
21
  `," "],unwise=["{","}","|","\\","^","`"].concat(delims),autoEscape=["'"].concat(unwise),nonHostChars=["%","/","?",";","#"].concat(autoEscape),hostEndingChars=["/","?","#"],hostnameMaxLen=255,hostnamePartPattern=/^[+a-z0-9A-Z_-]{0,63}$/,hostnamePartStart=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,unsafeProtocol={javascript:!0,"javascript:":!0},hostlessProtocol={javascript:!0,"javascript:":!0},slashedProtocol={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},querystring=require$$1$1;function urlParse(g,_,S){if(g&&typeof g=="object"&&g instanceof Url)return g;var p=new Url;return p.parse(g,_,S),p}Url.prototype.parse=function(g,_,S){if(typeof g!="string")throw new TypeError("Parameter 'url' must be a string, not "+typeof g);var p=g.indexOf("?"),E=p!==-1&&p<g.indexOf("#")?"?":"#",a=g.split(E),w=/\\/g;a[0]=a[0].replace(w,"/"),g=a.join(E);var v=g;if(v=v.trim(),!S&&g.split("#").length===1){var y=simplePathPattern.exec(v);if(y)return this.path=v,this.href=v,this.pathname=y[1],y[2]?(this.search=y[2],_?this.query=querystring.parse(this.search.substr(1)):this.query=this.search.substr(1)):_&&(this.search="",this.query={}),this}var m=protocolPattern.exec(v);if(m){m=m[0];var d=m.toLowerCase();this.protocol=d,v=v.substr(m.length)}if(S||m||v.match(/^\/\/[^@/]+@[^@/]+/)){var b=v.substr(0,2)==="//";b&&!(m&&hostlessProtocol[m])&&(v=v.substr(2),this.slashes=!0)}if(!hostlessProtocol[m]&&(b||m&&!slashedProtocol[m])){for(var x=-1,R=0;R<hostEndingChars.length;R++){var q=v.indexOf(hostEndingChars[R]);q!==-1&&(x===-1||q<x)&&(x=q)}var B,$;x===-1?$=v.lastIndexOf("@"):$=v.lastIndexOf("@",x),$!==-1&&(B=v.slice(0,$),v=v.slice($+1),this.auth=decodeURIComponent(B)),x=-1;for(var R=0;R<nonHostChars.length;R++){var q=v.indexOf(nonHostChars[R]);q!==-1&&(x===-1||q<x)&&(x=q)}x===-1&&(x=v.length),this.host=v.slice(0,x),v=v.slice(x),this.parseHost(),this.hostname=this.hostname||"";var k=this.hostname[0]==="["&&this.hostname[this.hostname.length-1]==="]";if(!k)for(var I=this.hostname.split(/\./),R=0,L=I.length;R<L;R++){var D=I[R];if(D&&!D.match(hostnamePartPattern)){for(var G="",X=0,te=D.length;X<te;X++)D.charCodeAt(X)>127?G+="x":G+=D[X];if(!G.match(hostnamePartPattern)){var ie=I.slice(0,R),ee=I.slice(R+1),ue=D.match(hostnamePartStart);ue&&(ie.push(ue[1]),ee.unshift(ue[2])),ee.length&&(v="/"+ee.join(".")+v),this.hostname=ie.join(".");break}}}this.hostname.length>hostnameMaxLen?this.hostname="":this.hostname=this.hostname.toLowerCase(),k||(this.hostname=punycode.toASCII(this.hostname));var c=this.port?":"+this.port:"",e=this.hostname||"";this.host=e+c,this.href+=this.host,k&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),v[0]!=="/"&&(v="/"+v))}if(!unsafeProtocol[d])for(var R=0,L=autoEscape.length;R<L;R++){var t=autoEscape[R];if(v.indexOf(t)!==-1){var n=encodeURIComponent(t);n===t&&(n=escape(t)),v=v.split(t).join(n)}}var f=v.indexOf("#");f!==-1&&(this.hash=v.substr(f),v=v.slice(0,f));var s=v.indexOf("?");if(s!==-1?(this.search=v.substr(s),this.query=v.substr(s+1),_&&(this.query=querystring.parse(this.query)),v=v.slice(0,s)):_&&(this.search="",this.query={}),v&&(this.pathname=v),slashedProtocol[d]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var c=this.pathname||"",u=this.search||"";this.path=c+u}return this.href=this.format(),this};function urlFormat(g){return typeof g=="string"&&(g=urlParse(g)),g instanceof Url?g.format():Url.prototype.format.call(g)}Url.prototype.format=function(){var g=this.auth||"";g&&(g=encodeURIComponent(g),g=g.replace(/%3A/i,":"),g+="@");var _=this.protocol||"",S=this.pathname||"",p=this.hash||"",E=!1,a="";this.host?E=g+this.host:this.hostname&&(E=g+(this.hostname.indexOf(":")===-1?this.hostname:"["+this.hostname+"]"),this.port&&(E+=":"+this.port)),this.query&&typeof this.query=="object"&&Object.keys(this.query).length&&(a=querystring.stringify(this.query,{arrayFormat:"repeat",addQueryPrefix:!1}));var w=this.search||a&&"?"+a||"";return _&&_.substr(-1)!==":"&&(_+=":"),this.slashes||(!_||slashedProtocol[_])&&E!==!1?(E="//"+(E||""),S&&S.charAt(0)!=="/"&&(S="/"+S)):E||(E=""),p&&p.charAt(0)!=="#"&&(p="#"+p),w&&w.charAt(0)!=="?"&&(w="?"+w),S=S.replace(/[?#]/g,function(v){return encodeURIComponent(v)}),w=w.replace("#","%23"),_+E+S+w+p};function urlResolve(g,_){return urlParse(g,!1,!0).resolve(_)}Url.prototype.resolve=function(g){return this.resolveObject(urlParse(g,!1,!0)).format()};function urlResolveObject(g,_){return g?urlParse(g,!1,!0).resolveObject(_):_}Url.prototype.resolveObject=function(g){if(typeof g=="string"){var _=new Url;_.parse(g,!1,!0),g=_}for(var S=new Url,p=Object.keys(this),E=0;E<p.length;E++){var a=p[E];S[a]=this[a]}if(S.hash=g.hash,g.href==="")return S.href=S.format(),S;if(g.slashes&&!g.protocol){for(var w=Object.keys(g),v=0;v<w.length;v++){var y=w[v];y!=="protocol"&&(S[y]=g[y])}return slashedProtocol[S.protocol]&&S.hostname&&!S.pathname&&(S.pathname="/",S.path=S.pathname),S.href=S.format(),S}if(g.protocol&&g.protocol!==S.protocol){if(!slashedProtocol[g.protocol]){for(var m=Object.keys(g),d=0;d<m.length;d++){var b=m[d];S[b]=g[b]}return S.href=S.format(),S}if(S.protocol=g.protocol,!g.host&&!hostlessProtocol[g.protocol]){for(var L=(g.pathname||"").split("/");L.length&&!(g.host=L.shift()););g.host||(g.host=""),g.hostname||(g.hostname=""),L[0]!==""&&L.unshift(""),L.length<2&&L.unshift(""),S.pathname=L.join("/")}else S.pathname=g.pathname;if(S.search=g.search,S.query=g.query,S.host=g.host||"",S.auth=g.auth,S.hostname=g.hostname||g.host,S.port=g.port,S.pathname||S.search){var x=S.pathname||"",R=S.search||"";S.path=x+R}return S.slashes=S.slashes||g.slashes,S.href=S.format(),S}var q=S.pathname&&S.pathname.charAt(0)==="/",B=g.host||g.pathname&&g.pathname.charAt(0)==="/",$=B||q||S.host&&g.pathname,k=$,I=S.pathname&&S.pathname.split("/")||[],L=g.pathname&&g.pathname.split("/")||[],D=S.protocol&&!slashedProtocol[S.protocol];if(D&&(S.hostname="",S.port=null,S.host&&(I[0]===""?I[0]=S.host:I.unshift(S.host)),S.host="",g.protocol&&(g.hostname=null,g.port=null,g.host&&(L[0]===""?L[0]=g.host:L.unshift(g.host)),g.host=null),$=$&&(L[0]===""||I[0]==="")),B)S.host=g.host||g.host===""?g.host:S.host,S.hostname=g.hostname||g.hostname===""?g.hostname:S.hostname,S.search=g.search,S.query=g.query,I=L;else if(L.length)I||(I=[]),I.pop(),I=I.concat(L),S.search=g.search,S.query=g.query;else if(g.search!=null){if(D){S.host=I.shift(),S.hostname=S.host;var G=S.host&&S.host.indexOf("@")>0?S.host.split("@"):!1;G&&(S.auth=G.shift(),S.hostname=G.shift(),S.host=S.hostname)}return S.search=g.search,S.query=g.query,(S.pathname!==null||S.search!==null)&&(S.path=(S.pathname?S.pathname:"")+(S.search?S.search:"")),S.href=S.format(),S}if(!I.length)return S.pathname=null,S.search?S.path="/"+S.search:S.path=null,S.href=S.format(),S;for(var X=I.slice(-1)[0],te=(S.host||g.host||I.length>1)&&(X==="."||X==="..")||X==="",ie=0,ee=I.length;ee>=0;ee--)X=I[ee],X==="."?I.splice(ee,1):X===".."?(I.splice(ee,1),ie++):ie&&(I.splice(ee,1),ie--);if(!$&&!k)for(;ie--;ie)I.unshift("..");$&&I[0]!==""&&(!I[0]||I[0].charAt(0)!=="/")&&I.unshift(""),te&&I.join("/").substr(-1)!=="/"&&I.push("");var ue=I[0]===""||I[0]&&I[0].charAt(0)==="/";if(D){S.hostname=ue?"":I.length?I.shift():"",S.host=S.hostname;var G=S.host&&S.host.indexOf("@")>0?S.host.split("@"):!1;G&&(S.auth=G.shift(),S.hostname=G.shift(),S.host=S.hostname)}return $=$||S.host&&I.length,$&&!ue&&I.unshift(""),I.length>0?S.pathname=I.join("/"):(S.pathname=null,S.path=null),(S.pathname!==null||S.search!==null)&&(S.path=(S.pathname?S.pathname:"")+(S.search?S.search:"")),S.auth=g.auth||S.auth,S.slashes=S.slashes||g.slashes,S.href=S.format(),S};Url.prototype.parseHost=function(){var g=this.host,_=portPattern.exec(g);_&&(_=_[0],_!==":"&&(this.port=_.substr(1)),g=g.substr(0,g.length-_.length)),g&&(this.hostname=g)};var parse=urlParse,resolve$1=urlResolve,resolveObject=urlResolveObject,format=urlFormat,Url_1=Url;function normalizeArray(g,_){for(var S=0,p=g.length-1;p>=0;p--){var E=g[p];E==="."?g.splice(p,1):E===".."?(g.splice(p,1),S++):S&&(g.splice(p,1),S--)}if(_)for(;S--;S)g.unshift("..");return g}function resolve(){for(var g="",_=!1,S=arguments.length-1;S>=-1&&!_;S--){var p=S>=0?arguments[S]:"/";if(typeof p!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!p)continue;g=p+"/"+g,_=p.charAt(0)==="/"}return g=normalizeArray(filter(g.split("/"),function(E){return!!E}),!_).join("/"),(_?"/":"")+g||"."}function filter(g,_){if(g.filter)return g.filter(_);for(var S=[],p=0;p<g.length;p++)_(g[p],p,g)&&S.push(g[p]);return S}var _globalThis=(function(g){function _(){var p=this||self;return delete g.prototype.__magic__,p}if(typeof globalThis=="object")return globalThis;if(this)return _();g.defineProperty(g.prototype,"__magic__",{configurable:!0,get:_});var S=__magic__;return S})(Object),formatImport=format,parseImport=parse,resolveImport=resolve$1,UrlImport=Url_1,URL=_globalThis.URL,URLSearchParams=_globalThis.URLSearchParams,percentRegEx=/%/g,backslashRegEx=/\\/g,newlineRegEx=/\n/g,carriageReturnRegEx=/\r/g,tabRegEx=/\t/g,CHAR_FORWARD_SLASH=47;function isURLInstance(g){var _=g??null;return!!(_!==null&&_?.href&&_?.origin)}function getPathFromURLPosix(g){if(g.hostname!=="")throw new TypeError('File URL host must be "localhost" or empty on browser');for(var _=g.pathname,S=0;S<_.length;S++)if(_[S]==="%"){var p=_.codePointAt(S+2)|32;if(_[S+1]==="2"&&p===102)throw new TypeError("File URL path must not include encoded / characters")}return decodeURIComponent(_)}function encodePathChars(g){return g.includes("%")&&(g=g.replace(percentRegEx,"%25")),g.includes("\\")&&(g=g.replace(backslashRegEx,"%5C")),g.includes(`
22
- `)&&(g=g.replace(newlineRegEx,"%0A")),g.includes("\r")&&(g=g.replace(carriageReturnRegEx,"%0D")),g.includes(" ")&&(g=g.replace(tabRegEx,"%09")),g}var domainToASCII=function g(_){if(typeof _>"u")throw new TypeError('The "domain" argument must be specified');return new URL("http://"+_).hostname},domainToUnicode=function g(_){if(typeof _>"u")throw new TypeError('The "domain" argument must be specified');return new URL("http://"+_).hostname},pathToFileURL=function g(_){var S=new URL("file://"),p=resolve(_),E=_.charCodeAt(_.length-1);return E===CHAR_FORWARD_SLASH&&p[p.length-1]!=="/"&&(p+="/"),S.pathname=encodePathChars(p),S},fileURLToPath=function g(_){if(!isURLInstance(_)&&typeof _!="string")throw new TypeError('The "path" argument must be of type string or an instance of URL. Received type '+typeof _+" ("+_+")");var S=new URL(_);if(S.protocol!=="file:")throw new TypeError("The URL must be of scheme file");return getPathFromURLPosix(S)},formatImportWithOverloads=function g(_,S){var p,E,a,w;if(S===void 0&&(S={}),!(_ instanceof URL))return formatImport(_);if(typeof S!="object"||S===null)throw new TypeError('The "options" argument must be of type object.');var v=(p=S.auth)!=null?p:!0,y=(E=S.fragment)!=null?E:!0,m=(a=S.search)!=null?a:!0;(w=S.unicode)!=null;var d=new URL(_.toString());return v||(d.username="",d.password=""),y||(d.hash=""),m||(d.search=""),d.toString()},api={format:formatImportWithOverloads,parse:parseImport,resolve:resolveImport,resolveObject,Url:UrlImport,URL,URLSearchParams,domainToASCII,domainToUnicode,pathToFileURL,fileURLToPath};const url=Object.freeze(Object.defineProperty({__proto__:null,URL,URLSearchParams,Url:UrlImport,default:api,domainToASCII,domainToUnicode,fileURLToPath,format:formatImportWithOverloads,parse:parseImport,pathToFileURL,resolve:resolveImport,resolveObject},Symbol.toStringTag,{value:"Module"})),require$$1=getAugmentedNamespace(url);var hasRequiredStreamHttp;function requireStreamHttp(){return hasRequiredStreamHttp||(hasRequiredStreamHttp=1,(function(g){var _=requireRequest(),S=requireResponse(),p=requireImmutable(),E=requireBrowser(),a=require$$1,w=g;w.request=function(v,y){typeof v=="string"?v=a.parse(v):v=p(v);var m=commonjsGlobal.location.protocol.search(/^https?:$/)===-1?"http:":"",d=v.protocol||m,b=v.hostname||v.host,x=v.port,R=v.path||"/";b&&b.indexOf(":")!==-1&&(b="["+b+"]"),v.url=(b?d+"//"+b:"")+(x?":"+x:"")+R,v.method=(v.method||"GET").toUpperCase(),v.headers=v.headers||{};var q=new _(v);return y&&q.on("response",y),q},w.get=function(y,m){var d=w.request(y,m);return d.end(),d},w.ClientRequest=_,w.IncomingMessage=S.IncomingMessage,w.Agent=function(){},w.Agent.defaultMaxSockets=4,w.globalAgent=new w.Agent,w.STATUS_CODES=E,w.METHODS=["CHECKOUT","CONNECT","COPY","DELETE","GET","HEAD","LOCK","M-SEARCH","MERGE","MKACTIVITY","MKCOL","MOVE","NOTIFY","OPTIONS","PATCH","POST","PROPFIND","PROPPATCH","PURGE","PUT","REPORT","SEARCH","SUBSCRIBE","TRACE","UNLOCK","UNSUBSCRIBE"]})(streamHttp)),streamHttp}var hasRequiredHttpsBrowserify;function requireHttpsBrowserify(){return hasRequiredHttpsBrowserify||(hasRequiredHttpsBrowserify=1,(function(g){var _=requireStreamHttp(),S=require$$1,p=g.exports;for(var E in _)_.hasOwnProperty(E)&&(p[E]=_[E]);p.request=function(w,v){return w=a(w),_.request.call(this,w,v)},p.get=function(w,v){return w=a(w),_.get.call(this,w,v)};function a(w){if(typeof w=="string"&&(w=S.parse(w)),w.protocol||(w.protocol="https:"),w.protocol!=="https:")throw new Error('Protocol "'+w.protocol+'" not supported. Expected "https:"');return w}})(httpsBrowserify)),httpsBrowserify.exports}var httpsBrowserifyExports=requireHttpsBrowserify();const https=getDefaultExportFromCjs$1(httpsBrowserifyExports),config={region:"SG",baseHostName:"storage.bunnycdn.com",folderName:"",storageZone:"unset",password:"unset"},install=({storageZone:g,password:_,region:S,folderName:p})=>{config.region=S||config.region,config.folderName=p||config.folderName,config.storageZone=g||config.storageZone,config.password=_},upload=async({file:g,buffer:_})=>new Promise(async(S,p)=>{try{!_&&!g&&p({res:!1,message:"No file uploaded"});const E=`${cryptoBrowserifyExports.randomUUID()}.webp`,a=_?_.length:g.buffer.length,w={method:"PUT",hostname:config.region?`${config.region}.${config.baseHostName}`:config.baseHostName,port:443,path:`/${config.storageZone}/${config.folderName}/${E}`,headers:{AccessKey:config.password,"Content-Type":"application/octet-stream","Content-Length":a}},v=https.request(w,y=>{if(y.statusCode===201){const m=config.folderName?`${config.folderName}/`:"",d=`https://${config.storageZone}.b-cdn.net/${m}${E}`;S({res:!0,message:"upload success",url:d})}else p({res:!1,message:"Upload failed"})});v.on("error",y=>{p({res:!1,message:"Upload failed",error:y})}),v.write(_||g.buffer),v.end()}catch{p({res:!1,message:"Server error"})}}),list=async()=>new Promise((g,_)=>{try{const S=config.region?`${config.region}.${config.baseHostName}`:config.baseHostName,p=config.folderName?`${config.folderName}/`:"",E=`https://${S}/${config.storageZone}/${p}`,a={AccessKey:config.password};console.log(a,p,E,S),https.get(E,{headers:a},w=>{let v="";w.on("data",y=>{v+=y}),w.on("end",()=>{try{const m=JSON.parse(v).map(d=>{const b=`https://${config.storageZone}.b-cdn.net/${p}${d.ObjectName}`;return{...d,Url:b}});g({res:!0,message:"List retrieved successfully",files:m})}catch{_({res:!1,message:"Failed to parse response"})}})}).on("error",w=>{_({res:!1,message:"Network error",error:w})})}catch{_({res:!1,message:"Server error"})}}),deleteFile=({ObjectName:g,href:_})=>new Promise((S,p)=>{if(!g&&!_){p({res:!1,message:"No file specified for deletion"});return}try{const E=config.region?`${config.region}.${config.baseHostName}`:config.baseHostName,a=_?decodeURIComponent(_.split("/")[_.split("/").length-1]):g;https.request({method:"DELETE",hostname:E,path:`/${config.storageZone}/${config.folderName}/${a}`,headers:{AccessKey:config.password}},w=>{w.statusCode===200?S({res:!0,message:"File deleted successfully"}):S({res:!1,message:"Failed to delete file"})}).end()}catch{p({res:!1,message:"Server error"})}}),BunnyCDN={install,upload,list,deleteFile};exports.default=BunnyCDN;exports.deleteFile=deleteFile;exports.install=install;exports.list=list;exports.upload=upload;
22
+ `)&&(g=g.replace(newlineRegEx,"%0A")),g.includes("\r")&&(g=g.replace(carriageReturnRegEx,"%0D")),g.includes(" ")&&(g=g.replace(tabRegEx,"%09")),g}var domainToASCII=function g(_){if(typeof _>"u")throw new TypeError('The "domain" argument must be specified');return new URL("http://"+_).hostname},domainToUnicode=function g(_){if(typeof _>"u")throw new TypeError('The "domain" argument must be specified');return new URL("http://"+_).hostname},pathToFileURL=function g(_){var S=new URL("file://"),p=resolve(_),E=_.charCodeAt(_.length-1);return E===CHAR_FORWARD_SLASH&&p[p.length-1]!=="/"&&(p+="/"),S.pathname=encodePathChars(p),S},fileURLToPath=function g(_){if(!isURLInstance(_)&&typeof _!="string")throw new TypeError('The "path" argument must be of type string or an instance of URL. Received type '+typeof _+" ("+_+")");var S=new URL(_);if(S.protocol!=="file:")throw new TypeError("The URL must be of scheme file");return getPathFromURLPosix(S)},formatImportWithOverloads=function g(_,S){var p,E,a,w;if(S===void 0&&(S={}),!(_ instanceof URL))return formatImport(_);if(typeof S!="object"||S===null)throw new TypeError('The "options" argument must be of type object.');var v=(p=S.auth)!=null?p:!0,y=(E=S.fragment)!=null?E:!0,m=(a=S.search)!=null?a:!0;(w=S.unicode)!=null;var d=new URL(_.toString());return v||(d.username="",d.password=""),y||(d.hash=""),m||(d.search=""),d.toString()},api={format:formatImportWithOverloads,parse:parseImport,resolve:resolveImport,resolveObject,Url:UrlImport,URL,URLSearchParams,domainToASCII,domainToUnicode,pathToFileURL,fileURLToPath};const url=Object.freeze(Object.defineProperty({__proto__:null,URL,URLSearchParams,Url:UrlImport,default:api,domainToASCII,domainToUnicode,fileURLToPath,format:formatImportWithOverloads,parse:parseImport,pathToFileURL,resolve:resolveImport,resolveObject},Symbol.toStringTag,{value:"Module"})),require$$1=getAugmentedNamespace(url);var hasRequiredStreamHttp;function requireStreamHttp(){return hasRequiredStreamHttp||(hasRequiredStreamHttp=1,(function(g){var _=requireRequest(),S=requireResponse(),p=requireImmutable(),E=requireBrowser(),a=require$$1,w=g;w.request=function(v,y){typeof v=="string"?v=a.parse(v):v=p(v);var m=commonjsGlobal.location.protocol.search(/^https?:$/)===-1?"http:":"",d=v.protocol||m,b=v.hostname||v.host,x=v.port,R=v.path||"/";b&&b.indexOf(":")!==-1&&(b="["+b+"]"),v.url=(b?d+"//"+b:"")+(x?":"+x:"")+R,v.method=(v.method||"GET").toUpperCase(),v.headers=v.headers||{};var q=new _(v);return y&&q.on("response",y),q},w.get=function(y,m){var d=w.request(y,m);return d.end(),d},w.ClientRequest=_,w.IncomingMessage=S.IncomingMessage,w.Agent=function(){},w.Agent.defaultMaxSockets=4,w.globalAgent=new w.Agent,w.STATUS_CODES=E,w.METHODS=["CHECKOUT","CONNECT","COPY","DELETE","GET","HEAD","LOCK","M-SEARCH","MERGE","MKACTIVITY","MKCOL","MOVE","NOTIFY","OPTIONS","PATCH","POST","PROPFIND","PROPPATCH","PURGE","PUT","REPORT","SEARCH","SUBSCRIBE","TRACE","UNLOCK","UNSUBSCRIBE"]})(streamHttp)),streamHttp}var hasRequiredHttpsBrowserify;function requireHttpsBrowserify(){return hasRequiredHttpsBrowserify||(hasRequiredHttpsBrowserify=1,(function(g){var _=requireStreamHttp(),S=require$$1,p=g.exports;for(var E in _)_.hasOwnProperty(E)&&(p[E]=_[E]);p.request=function(w,v){return w=a(w),_.request.call(this,w,v)},p.get=function(w,v){return w=a(w),_.get.call(this,w,v)};function a(w){if(typeof w=="string"&&(w=S.parse(w)),w.protocol||(w.protocol="https:"),w.protocol!=="https:")throw new Error('Protocol "'+w.protocol+'" not supported. Expected "https:"');return w}})(httpsBrowserify)),httpsBrowserify.exports}var httpsBrowserifyExports=requireHttpsBrowserify();const https=getDefaultExportFromCjs$1(httpsBrowserifyExports);class BunnyCDNClient{config={region:"SG",baseHostName:"storage.bunnycdn.com",folderName:"",storageZone:"unset",password:"unset"};constructor({storageZone:_,password:S,region:p,folderName:E}){return this.config.region=p||this.config.region,this.config.folderName=E||this.config.folderName,this.config.storageZone=_||this.config.storageZone,this.config.password=S,this}async upload({file:_,buffer:S}){return new Promise(async(p,E)=>{try{!S&&!_&&E({res:!1,message:"No file uploaded"});const a=`${cryptoBrowserifyExports.randomUUID()}.webp`,w=S?S.length:_.buffer.length,v={method:"PUT",hostname:this.config.region?`${this.config.region}.${this.config.baseHostName}`:this.config.baseHostName,port:443,path:`/${this.config.storageZone}/${this.config.folderName}/${a}`,headers:{AccessKey:this.config.password,"Content-Type":"application/octet-stream","Content-Length":w}},y=https.request(v,m=>{if(m.statusCode===201){const d=this.config.folderName?`${this.config.folderName}/`:"",b=`https://${this.config.storageZone}.b-cdn.net/${d}${a}`;p({res:!0,message:"upload success",url:b})}else E({res:!1,message:"Upload failed"})});y.on("error",m=>{E({res:!1,message:"Upload failed",error:m})}),y.write(S||_.buffer),y.end()}catch{E({res:!1,message:"Server error"})}})}async list(){return new Promise((_,S)=>{try{const p=this.config.region?`${this.config.region}.${this.config.baseHostName}`:this.config.baseHostName,E=this.config.folderName?`${this.config.folderName}/`:"",a=`https://${p}/${this.config.storageZone}/${E}`,w={AccessKey:this.config.password};console.log(w,E,a,p),https.get(a,{headers:w},v=>{let y="";v.on("data",m=>{y+=m}),v.on("end",()=>{try{const d=JSON.parse(y).map(b=>{const x=`https://${this.config.storageZone}.b-cdn.net/${E}${b.ObjectName}`;return{...b,Url:x}});_({res:!0,message:"List retrieved successfully",files:d})}catch{S({res:!1,message:"Failed to parse response"})}})}).on("error",v=>{S({res:!1,message:"Network error",error:v})})}catch{S({res:!1,message:"Server error"})}})}async deleteFile({ObjectName:_,href:S}){return new Promise((p,E)=>{if(!_&&!S){E({res:!1,message:"No file specified for deletion"});return}try{const a=this.config.region?`${this.config.region}.${this.config.baseHostName}`:this.config.baseHostName,w=S?decodeURIComponent(S.split("/")[S.split("/").length-1]):_;https.request({method:"DELETE",hostname:a,path:`/${this.config.storageZone}/${this.config.folderName}/${w}`,headers:{AccessKey:this.config.password}},v=>{v.statusCode===200?p({res:!0,message:"File deleted successfully"}):p({res:!1,message:"Failed to delete file"})}).end()}catch{E({res:!1,message:"Server error"})}})}}exports.default=BunnyCDNClient;
package/lib/index.d.ts CHANGED
@@ -1,42 +1,23 @@
1
1
  import { File, InstallParams, UploadParams } from './type';
2
- export declare const install: ({ storageZone, password, region, folderName }: InstallParams) => void;
3
- export declare const upload: ({ file, buffer }: UploadParams) => Promise<{
4
- res: boolean;
5
- message: string;
6
- url?: string;
7
- error?: any;
8
- }>;
9
- export declare const list: () => Promise<{
10
- res: boolean;
11
- message: string;
12
- files?: File[];
13
- }>;
14
- export declare const deleteFile: ({ ObjectName, href }: {
15
- ObjectName?: string;
16
- href?: string;
17
- }) => Promise<{
18
- res: boolean;
19
- message: string;
20
- }>;
21
- declare const BunnyCDN: {
22
- install: ({ storageZone, password, region, folderName }: InstallParams) => void;
23
- upload: ({ file, buffer }: UploadParams) => Promise<{
2
+ export default class BunnyCDNClient {
3
+ private config;
4
+ constructor({ storageZone, password, region, folderName }: InstallParams);
5
+ upload({ file, buffer }: UploadParams): Promise<{
24
6
  res: boolean;
25
7
  message: string;
26
8
  url?: string;
27
9
  error?: any;
28
10
  }>;
29
- list: () => Promise<{
11
+ list(): Promise<{
30
12
  res: boolean;
31
13
  message: string;
32
14
  files?: File[];
33
15
  }>;
34
- deleteFile: ({ ObjectName, href }: {
16
+ deleteFile({ ObjectName, href }: {
35
17
  ObjectName?: string;
36
18
  href?: string;
37
- }) => Promise<{
19
+ }): Promise<{
38
20
  res: boolean;
39
21
  message: string;
40
22
  }>;
41
- };
42
- export default BunnyCDN;
23
+ }
package/lib/index.js CHANGED
@@ -25676,91 +25676,100 @@ function requireHttpsBrowserify() {
25676
25676
  })(httpsBrowserify)), httpsBrowserify.exports;
25677
25677
  }
25678
25678
  var httpsBrowserifyExports = requireHttpsBrowserify();
25679
- const https = /* @__PURE__ */ getDefaultExportFromCjs$1(httpsBrowserifyExports), config = {
25680
- region: "SG",
25681
- baseHostName: "storage.bunnycdn.com",
25682
- folderName: "",
25683
- storageZone: "unset",
25684
- password: "unset"
25685
- }, install = ({ storageZone: g, password: _, region: S, folderName: p }) => {
25686
- config.region = S || config.region, config.folderName = p || config.folderName, config.storageZone = g || config.storageZone, config.password = _;
25687
- }, upload = async ({ file: g, buffer: _ }) => new Promise(
25688
- async (S, p) => {
25689
- try {
25690
- !_ && !g && p({ res: !1, message: "No file uploaded" });
25691
- const E = `${cryptoBrowserifyExports.randomUUID()}.webp`, a = _ ? _.length : g.buffer.length, w = {
25692
- method: "PUT",
25693
- hostname: config.region ? `${config.region}.${config.baseHostName}` : config.baseHostName,
25694
- port: 443,
25695
- path: `/${config.storageZone}/${config.folderName}/${E}`,
25696
- headers: {
25697
- AccessKey: config.password,
25698
- "Content-Type": "application/octet-stream",
25699
- "Content-Length": a
25700
- }
25701
- }, v = https.request(w, (y) => {
25702
- if (y.statusCode === 201) {
25703
- const m = config.folderName ? `${config.folderName}/` : "", d = `https://${config.storageZone}.b-cdn.net/${m}${E}`;
25704
- S({ res: !0, message: "upload success", url: d });
25705
- } else p({ res: !1, message: "Upload failed" });
25706
- });
25707
- v.on("error", (y) => {
25708
- p({ res: !1, message: "Upload failed", error: y });
25709
- }), v.write(_ || g.buffer), v.end();
25710
- } catch {
25711
- p({ res: !1, message: "Server error" });
25712
- }
25679
+ const https = /* @__PURE__ */ getDefaultExportFromCjs$1(httpsBrowserifyExports);
25680
+ class BunnyCDNClient {
25681
+ config = {
25682
+ region: "SG",
25683
+ baseHostName: "storage.bunnycdn.com",
25684
+ folderName: "",
25685
+ storageZone: "unset",
25686
+ password: "unset"
25687
+ };
25688
+ constructor({ storageZone: _, password: S, region: p, folderName: E }) {
25689
+ return this.config.region = p || this.config.region, this.config.folderName = E || this.config.folderName, this.config.storageZone = _ || this.config.storageZone, this.config.password = S, this;
25713
25690
  }
25714
- ), list = async () => new Promise((g, _) => {
25715
- try {
25716
- const S = config.region ? `${config.region}.${config.baseHostName}` : config.baseHostName, p = config.folderName ? `${config.folderName}/` : "", E = `https://${S}/${config.storageZone}/${p}`, a = { AccessKey: config.password };
25717
- console.log(a, p, E, S), https.get(E, { headers: a }, (w) => {
25718
- let v = "";
25719
- w.on("data", (y) => {
25720
- v += y;
25721
- }), w.on("end", () => {
25691
+ async upload({ file: _, buffer: S }) {
25692
+ return new Promise(
25693
+ async (p, E) => {
25722
25694
  try {
25723
- const m = JSON.parse(v).map((d) => {
25724
- const b = `https://${config.storageZone}.b-cdn.net/${p}${d.ObjectName}`;
25725
- return { ...d, Url: b };
25695
+ !S && !_ && E({ res: !1, message: "No file uploaded" });
25696
+ const a = `${cryptoBrowserifyExports.randomUUID()}.webp`, w = S ? S.length : _.buffer.length, v = {
25697
+ method: "PUT",
25698
+ hostname: this.config.region ? `${this.config.region}.${this.config.baseHostName}` : this.config.baseHostName,
25699
+ port: 443,
25700
+ path: `/${this.config.storageZone}/${this.config.folderName}/${a}`,
25701
+ headers: {
25702
+ AccessKey: this.config.password,
25703
+ "Content-Type": "application/octet-stream",
25704
+ "Content-Length": w
25705
+ }
25706
+ }, y = https.request(v, (m) => {
25707
+ if (m.statusCode === 201) {
25708
+ const d = this.config.folderName ? `${this.config.folderName}/` : "", b = `https://${this.config.storageZone}.b-cdn.net/${d}${a}`;
25709
+ p({ res: !0, message: "upload success", url: b });
25710
+ } else E({ res: !1, message: "Upload failed" });
25726
25711
  });
25727
- g({ res: !0, message: "List retrieved successfully", files: m });
25712
+ y.on("error", (m) => {
25713
+ E({ res: !1, message: "Upload failed", error: m });
25714
+ }), y.write(S || _.buffer), y.end();
25728
25715
  } catch {
25729
- _({ res: !1, message: "Failed to parse response" });
25716
+ E({ res: !1, message: "Server error" });
25730
25717
  }
25731
- });
25732
- }).on("error", (w) => {
25733
- _({ res: !1, message: "Network error", error: w });
25734
- });
25735
- } catch {
25736
- _({ res: !1, message: "Server error" });
25718
+ }
25719
+ );
25737
25720
  }
25738
- }), deleteFile = ({ ObjectName: g, href: _ }) => new Promise((S, p) => {
25739
- if (!g && !_) {
25740
- p({ res: !1, message: "No file specified for deletion" });
25741
- return;
25721
+ async list() {
25722
+ return new Promise((_, S) => {
25723
+ try {
25724
+ const p = this.config.region ? `${this.config.region}.${this.config.baseHostName}` : this.config.baseHostName, E = this.config.folderName ? `${this.config.folderName}/` : "", a = `https://${p}/${this.config.storageZone}/${E}`, w = { AccessKey: this.config.password };
25725
+ console.log(w, E, a, p), https.get(a, { headers: w }, (v) => {
25726
+ let y = "";
25727
+ v.on("data", (m) => {
25728
+ y += m;
25729
+ }), v.on("end", () => {
25730
+ try {
25731
+ const d = JSON.parse(y).map((b) => {
25732
+ const x = `https://${this.config.storageZone}.b-cdn.net/${E}${b.ObjectName}`;
25733
+ return { ...b, Url: x };
25734
+ });
25735
+ _({ res: !0, message: "List retrieved successfully", files: d });
25736
+ } catch {
25737
+ S({ res: !1, message: "Failed to parse response" });
25738
+ }
25739
+ });
25740
+ }).on("error", (v) => {
25741
+ S({ res: !1, message: "Network error", error: v });
25742
+ });
25743
+ } catch {
25744
+ S({ res: !1, message: "Server error" });
25745
+ }
25746
+ });
25742
25747
  }
25743
- try {
25744
- const E = config.region ? `${config.region}.${config.baseHostName}` : config.baseHostName, a = _ ? decodeURIComponent(_.split("/")[_.split("/").length - 1]) : g;
25745
- https.request(
25746
- {
25747
- method: "DELETE",
25748
- hostname: E,
25749
- path: `/${config.storageZone}/${config.folderName}/${a}`,
25750
- headers: { AccessKey: config.password }
25751
- },
25752
- (w) => {
25753
- w.statusCode === 200 ? S({ res: !0, message: "File deleted successfully" }) : S({ res: !1, message: "Failed to delete file" });
25748
+ async deleteFile({ ObjectName: _, href: S }) {
25749
+ return new Promise((p, E) => {
25750
+ if (!_ && !S) {
25751
+ E({ res: !1, message: "No file specified for deletion" });
25752
+ return;
25754
25753
  }
25755
- ).end();
25756
- } catch {
25757
- p({ res: !1, message: "Server error" });
25754
+ try {
25755
+ const a = this.config.region ? `${this.config.region}.${this.config.baseHostName}` : this.config.baseHostName, w = S ? decodeURIComponent(S.split("/")[S.split("/").length - 1]) : _;
25756
+ https.request(
25757
+ {
25758
+ method: "DELETE",
25759
+ hostname: a,
25760
+ path: `/${this.config.storageZone}/${this.config.folderName}/${w}`,
25761
+ headers: { AccessKey: this.config.password }
25762
+ },
25763
+ (v) => {
25764
+ v.statusCode === 200 ? p({ res: !0, message: "File deleted successfully" }) : p({ res: !1, message: "Failed to delete file" });
25765
+ }
25766
+ ).end();
25767
+ } catch {
25768
+ E({ res: !1, message: "Server error" });
25769
+ }
25770
+ });
25758
25771
  }
25759
- }), BunnyCDN = { install, upload, list, deleteFile };
25772
+ }
25760
25773
  export {
25761
- BunnyCDN as default,
25762
- deleteFile,
25763
- install,
25764
- list,
25765
- upload
25774
+ BunnyCDNClient as default
25766
25775
  };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "lesca-node-bunnycdn",
3
3
  "private": false,
4
4
  "description": "use bunny CDN api by node",
5
- "version": "0.0.5",
5
+ "version": "0.0.6",
6
6
  "type": "module",
7
7
  "keywords": [
8
8
  "bunnycdn",
package/readme.md CHANGED
@@ -18,67 +18,159 @@ npm install lesca-node-bunnycdn --save
18
18
 
19
19
  ## Usage
20
20
 
21
- As a Node module:
21
+ # Lesca Node BunnyCDN
22
22
 
23
- ```TS
23
+ A Node.js client library for BunnyCDN storage operations with TypeScript support.
24
+
25
+ ## Installation
26
+
27
+ ```bash
28
+ npm install lesca-node-bunnycdn
29
+ ```
30
+
31
+ ## Usage
32
+
33
+ ### Basic Usage with Constructor
34
+
35
+ ```typescript
24
36
  import BunnyCDN from 'lesca-node-bunnycdn';
25
- import multer from 'multer';
26
- import express from 'express';
27
-
28
- BunnyCDN.install({
29
- password: '7bcc3895-xxxx-xxxxxxxxxxxx-xxxx-xxxx', // storage key
30
- storageZone: 'npm-demo', // zone
31
- region: 'SG', // your region setting
32
- folderName: 'your-folder', // start with folder name
33
- });
34
37
 
35
- const uploadMulter = multer({
36
- storage: multer.memoryStorage(),
37
- limits: { fileSize: 5 * 1024 * 1024 },
38
+ // Initialize client with configuration
39
+ const client = new BunnyCDN({
40
+ storageZone: 'your-storage-zone',
41
+ password: 'your-password',
42
+ region: 'SG', // optional, defaults to 'SG'
43
+ folderName: 'uploads', // optional, defaults to ''
38
44
  });
39
45
 
40
- const app = express();
41
- const port = 3000;
46
+ // Upload a file
47
+ const uploadResult = await client.upload({
48
+ buffer: yourBuffer, // or file: yourFile
49
+ });
42
50
 
43
- app.use(express.json());
51
+ // List files
52
+ const listResult = await client.list();
44
53
 
45
- app.post('/upload', uploadMulter.single('file'), async (req, res) => {
46
- const response = await BunnyCDN.upload({
47
- file: req.file,
48
- sharpConfig: { format: 'webp', quality: 80 },
49
- });
50
- if (response) res.json(response);
51
- else res.json({ res: false, message: 'Upload error' });
54
+ // Delete a file
55
+ const deleteResult = await client.deleteFile({
56
+ ObjectName: 'filename.webp',
57
+ // or href: 'https://your-zone.b-cdn.net/uploads/filename.webp'
52
58
  });
59
+ ```
53
60
 
54
- app.get('/list', async (_, res) => {
55
- const response = await BunnyCDN.list();
61
+ ### Configuration Parameters
56
62
 
57
- if (response) res.json(response);
58
- else res.json({ res: false, message: 'List error' });
59
- });
63
+ | Parameter | Type | Required | Default | Description |
64
+ | ------------- | ------ | -------- | ------- | --------------------------------------------------- |
65
+ | `storageZone` | string | Yes | - | Your BunnyCDN storage zone name |
66
+ | `password` | string | Yes | - | Your BunnyCDN storage password |
67
+ | `region` | string | No | 'SG' | Storage region (e.g., 'SG', 'NY', 'LA', 'UK', 'DE') |
68
+ | `folderName` | string | No | '' | Folder path within the storage zone |
60
69
 
61
- app.post('/delete', async (req, res) => {
62
- const response = await BunnyCDN.deleteFile({ href: req.body.href });
70
+ ## API Reference
63
71
 
64
- if (response) res.json(response);
65
- else res.json({ res: false, message: 'Delete error' });
66
- });
72
+ ### Constructor
73
+
74
+ ```typescript
75
+ new BunnyCDNClient({
76
+ storageZone: string;
77
+ password: string;
78
+ region?: string;
79
+ folderName?: string;
80
+ })
81
+ ```
82
+
83
+ ### upload(params)
84
+
85
+ Uploads a file to BunnyCDN storage.
86
+
87
+ **Parameters:**
88
+
89
+ - `file`: Express multer file object (optional)
90
+ - `buffer`: Buffer containing file data (optional)
91
+
92
+ **Returns:**
93
+
94
+ ```typescript
95
+ Promise<{
96
+ res: boolean;
97
+ message: string;
98
+ url?: string;
99
+ error?: any;
100
+ }>;
101
+ ```
67
102
 
68
- app.listen(port, () => {
69
- console.log(`Example app listening on port ${port}`);
103
+ **Example:**
104
+
105
+ ```typescript
106
+ const result = await client.upload({
107
+ buffer: fs.readFileSync('image.jpg'),
70
108
  });
71
109
 
110
+ if (result.res) {
111
+ console.log('Upload successful:', result.url);
112
+ } else {
113
+ console.error('Upload failed:', result.message);
114
+ }
115
+ ```
116
+
117
+ ### list()
118
+
119
+ Lists all files in the configured storage zone and folder.
120
+
121
+ **Returns:**
122
+
123
+ ```typescript
124
+ Promise<{
125
+ res: boolean;
126
+ message: string;
127
+ files?: File[];
128
+ }>;
129
+ ```
130
+
131
+ **Example:**
132
+
133
+ ```typescript
134
+ const result = await client.list();
135
+
136
+ if (result.res && result.files) {
137
+ result.files.forEach((file) => {
138
+ console.log('File:', file.ObjectName, 'URL:', file.Url);
139
+ });
140
+ }
141
+ ```
142
+
143
+ ### deleteFile(params)
144
+
145
+ Deletes a file from BunnyCDN storage.
146
+
147
+ **Parameters:**
148
+
149
+ - `ObjectName`: File name to delete (optional)
150
+ - `href`: Full URL of the file to delete (optional)
151
+
152
+ **Returns:**
153
+
154
+ ```typescript
155
+ Promise<{
156
+ res: boolean;
157
+ message: string;
158
+ }>;
72
159
  ```
73
160
 
74
- ### Methods
161
+ **Example:**
162
+
163
+ ```typescript
164
+ // Delete by object name
165
+ const result = await client.deleteFile({
166
+ ObjectName: 'image.webp',
167
+ });
75
168
 
76
- | method | description | return |
77
- | :----------------------- | :----------------------: | -----: |
78
- | .**install**(options) | extend call func | void |
79
- | .**upload**(options) | continue calling func | void |
80
- | .**list**() | stop calling func | void |
81
- | .**deleteFile**(options) | reverse to last function | void |
169
+ // Or delete by URL
170
+ const result = await client.deleteFile({
171
+ href: 'https://your-zone.b-cdn.net/uploads/image.webp',
172
+ });
173
+ ```
82
174
 
83
175
  ### Features
84
176