niba-api 0.3.0 → 0.4.0

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.
Files changed (2) hide show
  1. package/index.js +1 -1
  2. package/package.json +3 -2
package/index.js CHANGED
@@ -1 +1 @@
1
- import e from"http";import t from"koa";import r from"koa-bodyparser";import n from"@babel/runtime/helpers/asyncToGenerator";import a from"@babel/runtime/helpers/typeof";import u from"@babel/runtime/helpers/defineProperty";import i from"@babel/runtime/helpers/slicedToArray";import o from"@babel/runtime/helpers/classCallCheck";import c from"@babel/runtime/helpers/createClass";import s from"@babel/runtime/regenerator";import f from"@babel/runtime/helpers/possibleConstructorReturn";import l from"@babel/runtime/helpers/getPrototypeOf";import p from"@babel/runtime/helpers/inherits";import h from"@babel/runtime/helpers/wrapNativeSuper";import{promisify as v}from"node:util";import{scryptSync as d,createDecipheriv as b,randomBytes as m,createCipheriv as y,scrypt as g}from"node:crypto";import x from"cacache";import w from"path";import k from"os";var O=console;function S(e){O=e}function j(e,t,r){return t=l(t),f(e,C()?Reflect.construct(t,r||[],l(e).constructor):t.apply(e,r))}function C(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(C=function(){return!!e})()}var A=function(e){function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:500;return o(this,t),(r=j(this,t,[e])).code=n,r}return p(t,e),c(t)}(h(Error)),z=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Bad Request";return o(this,e),j(this,e,[t,400])}return p(e,A),c(e)}(),P=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Unauthorized";return o(this,e),j(this,e,[t,401])}return p(e,A),c(e)}(),E=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Forbidden";return o(this,e),j(this,e,[t,403])}return p(e,A),c(e)}(),B=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Not Found";return o(this,e),j(this,e,[t,404])}return p(e,A),c(e)}(),I=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Method Not Allowed";return o(this,e),j(this,e,[t,405])}return p(e,A),c(e)}(),D=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Not Acceptable";return o(this,e),j(this,e,[t,406])}return p(e,A),c(e)}(),q=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Proxy Authentication Required";return o(this,e),j(this,e,[t,407])}return p(e,A),c(e)}(),G=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Time-out";return o(this,e),j(this,e,[t,408])}return p(e,A),c(e)}(),L=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Conflict";return o(this,e),j(this,e,[t,409])}return p(e,A),c(e)}(),N=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Internal Server Error";return o(this,e),j(this,e,[t,500])}return p(e,A),c(e)}(),R=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Not Implemented";return o(this,e),j(this,e,[t,501])}return p(e,A),c(e)}(),T=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Bad Gateway";return o(this,e),j(this,e,[t,502])}return p(e,A),c(e)}(),M=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Service Unavailable";return o(this,e),j(this,e,[t,503])}return p(e,A),c(e)}();function U(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function _(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?U(Object(r),!0).forEach(function(t){u(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):U(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function F(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return $(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?$(e,t):void 0}}(e))||t){r&&(e=r);var n=0,a=function(){};return{s:a,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var u,i=!0,o=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return i=e.done,e},e:function(e){o=!0,u=e},f:function(){try{i||null==r.return||r.return()}finally{if(o)throw u}}}}function $(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var Q=/\((.*?)\)/g,J=/(\(\?)?:\w+/g,W=/\*\w+/g,Y=/[\-{}\[\]+?.,\\\^$|#\s]/g,H={maxSize:1e3,ttl:3e5,enabled:!0},V=function(){return c(function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:H.maxSize,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:H.ttl;o(this,e),this.maxSize=t,this.ttl=r,this.cache=new Map,this.accessOrder=[],this.lastCleanup=Date.now()},[{key:"get",value:function(e){if(!this.cache.has(e))return null;var t=this.cache.get(e);return this.ttl>0&&Date.now()-t.timestamp>this.ttl?(this.delete(e),null):(this.updateAccessOrder(e),t.value)}},{key:"set",value:function(e,t){return this.cleanupIfNeeded(),this.cache.size>=this.maxSize&&!this.cache.has(e)&&this.evictOldest(),this.cache.set(e,{value:t,timestamp:Date.now()}),this.updateAccessOrder(e),t}},{key:"delete",value:function(e){var t=this.accessOrder.indexOf(e);return t>-1&&this.accessOrder.splice(t,1),this.cache.delete(e)}},{key:"clear",value:function(){this.cache.clear(),this.accessOrder=[],this.lastCleanup=Date.now()}},{key:"size",value:function(){return this.cache.size}},{key:"updateAccessOrder",value:function(e){var t=this.accessOrder.indexOf(e);t>-1&&this.accessOrder.splice(t,1),this.accessOrder.push(e)}},{key:"evictOldest",value:function(){for(;this.accessOrder.length>0;){var e=this.accessOrder.shift();if(this.cache.has(e)){this.cache.delete(e);break}}}},{key:"cleanupIfNeeded",value:function(){if(!(this.ttl<=0||this.cache.size<100&&Date.now()-this.lastCleanup<6e4)){var e,t=Date.now(),r=0,n=F(this.cache.entries());try{for(n.s();!(e=n.n()).done;){var a=i(e.value,2),u=a[0];t-a[1].timestamp>this.ttl&&(this.delete(u),r++)}}catch(e){n.e(e)}finally{n.f()}this.lastCleanup=t,r>0&&O.debug("清理了 ".concat(r," 个过期缓存条目"))}}}])}(),X=new V,K=new V,Z=new V;function ee(e){if("string"!=typeof e)return e;var t=e.trim();if(t.length>1e4)throw new A("Input too large",400);return t.indexOf(",")<0?t:t.split(",").map(function(e){var t=e.trim();if(t.length>1e3)throw new A("CSV item too large",400);return/^\d+(\.\d+)?$/g.test(t)?parseFloat(t):t}).filter(function(e){return null!=e&&""!==e})}function te(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];H.enabled=e}function re(e){H.maxSize=e,X.maxSize=e,K.maxSize=e,Z.maxSize=e}function ne(e){H.ttl=e,X.ttl=e,K.ttl=e,Z.ttl=e}function ae(){X.clear(),K.clear(),Z.clear()}function ue(){return{routeRegexCache:X.size(),routeMatchCache:K.size(),paramExtractCache:Z.size(),config:_({},H)}}function ie(e){var t=e.replace(Y,"\\$&").replace(Q,function(e,t){return"(?:"+t+")?"}).replace(J,function(e,t){return t?e:"([^/?]+)"}).replace(W,"([^?]*?)");return new RegExp("^"+t+"(?:\\?([\\s\\S]*))?$")}function oe(e,t){var r=e.exec(t).slice(1);return r.map(function(e,t){return t===r.length-1?e||null:e?decodeURIComponent(e):null})}function ce(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";if(!H.enabled)return se(e,t,r,n);var a="".concat(t,":").concat(n,":").concat(r),u=K.get(a);if(void 0!==u)return u;var i=se(e,t,r,n);return K.set(a,i)}function se(e,t,r){var n,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",i=t.toLowerCase(),o=F(e);try{var c,s=function(){var e=n.value;if(e.method)if(Array.isArray(e.method)){if(!e.method.some(function(e){return e.toLowerCase()===i}))return 0}else{if("string"!=typeof e.method)return 0;if(e.method.toLowerCase()!==i)return 0}var t="".concat(a).concat(e.path),o=function(e){if(!H.enabled)return ie(e);var t=e,r=X.get(t);if(r)return r;var n=ie(e);return X.set(t,n)}(t);if(!o.test(r))return 0;var c={},s=t.match(J);if(!s)return{v:{route:e,patterns:c}};var f=function(e,t){if(!H.enabled)return oe(e,t);var r="".concat(e.source,":").concat(t),n=Z.get(r);if(n)return n;var a=oe(e,t);return Z.set(r,a)}(o,r);return s.forEach(function(e,t){Object.assign(c,u({},e.slice(1),ee(f[t])))}),{v:{route:e,patterns:c}}};for(o.s();!(n=o.n()).done;)if(0!==(c=s())&&c)return c.v}catch(e){o.e(e)}finally{o.f()}return null}function fe(e,t){var r={},n={};Array.isArray(t)?t.forEach(function(e){n[e]=e}):t&&"object"===a(t)&&Object.assign(n,t);var u={};Object.entries(n).forEach(function(e){var t=i(e,2),r=t[0],n=t[1];u[n]=r});for(var o=0,c=Object.entries(e);o<c.length;o++){var s=i(c[o],2),f=s[0],l=ee(s[1]);r[u[f]||f]=l}return r}function le(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return function(){var r=n(s.mark(function r(n,i){var o,c,f,l,p,h,v,d,b,m,y;return s.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:if(c=n.path,f=ce(e,n.method,c,t)){r.next=1;break}return n.status=404,n.body={error:"Not Found"},r.abrupt("return");case 1:if(l=f.route,p=f.patterns,O.debug("--\x3e route %o, patterns: %o",l,p),h=l.handler,O.debug("--\x3e handler: %o, type: %o",h,a(h)),h&&"function"==typeof h){r.next=2;break}return n.throw(500,"The handler cannot be found"),r.abrupt("return");case 2:if(v=n.state.USER,O.debug("--\x3e current user: %o",v),!l.auth||v){r.next=3;break}return n.throw(401),r.abrupt("return");case 3:if(d=null!==(o=n.state.ACL)&&void 0!==o?o:[],"string"!=typeof l.auth||d.includes(l.auth)){r.next=4;break}return n.throw(403),r.abrupt("return");case 4:return b=_(_({request:n.request,response:n.response},p),{},{_user:v}),"string"==typeof l.body?Object.assign(b,u({},l.body,n.request.body)):Object.assign(b,{body:n.request.body}),l.header&&Object.assign(b,fe(n.request.header,l.header)),l.query&&Object.assign(b,fe(n.request.query,l.query)),m={},r.prev=5,r.next=6,h(b);case 6:m=r.sent,r.next=8;break;case 7:r.prev=7,y=r.catch(5),O.error("Handler error: %s",y.message,{stack:y.stack}),y instanceof A?n.throw(y.code,y.message):n.throw(500,"Internal Server Error");case 8:if(!(n.status>=300&&n.status<400)){r.next=10;break}return r.next=9,i();case 9:return r.abrupt("return");case 10:return null!=m?n.body=m:(n.body=null,200!==n.status&&404!==n.status||(n.status=204)),r.next=11,i();case 11:case"end":return r.stop()}},r,null,[[5,7]])}));return function(e,t){return r.apply(this,arguments)}}()}var pe="aes-192-cbc",he="bmliYW5pYmFsYW5uaWJhIQ==",ve=new Map;function de(e){return be.apply(this,arguments)}function be(){return(be=n(s.mark(function e(t){var r;return s.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!ve.has(t)){e.next=1;break}return e.abrupt("return",ve.get(t));case 1:return e.next=2,v(g)(t,he,24);case 2:return r=e.sent,ve.set(t,r),e.abrupt("return",r);case 3:case"end":return e.stop()}},e)}))).apply(this,arguments)}function me(e,t){return ye.apply(this,arguments)}function ye(){return(ye=n(s.mark(function e(t,r){var n,a,u,i,o;return s.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,de(r);case 1:return n=e.sent,a=m(16),u=y(pe,n,a),i=u.update(t),o=u.final(),e.abrupt("return",Buffer.concat([a,i,o]));case 2:case"end":return e.stop()}},e)}))).apply(this,arguments)}function ge(e,t){return xe.apply(this,arguments)}function xe(){return(xe=n(s.mark(function e(t,r){var n,a,u,i,o,c;return s.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,de(r);case 1:return n=e.sent,a=t.subarray(0,16),u=t.subarray(16),i=b(pe,n,a),o=i.update(u),c=i.final(),e.abrupt("return",Buffer.concat([o,c]));case 2:case"end":return e.stop()}},e)}))).apply(this,arguments)}function we(e,t){return ke.apply(this,arguments)}function ke(){return(ke=n(s.mark(function e(t,r){var n;return s.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,me(Buffer.from(t,"utf8"),r);case 1:return n=e.sent,e.abrupt("return",n.toString("base64url"));case 2:case"end":return e.stop()}},e)}))).apply(this,arguments)}function Oe(e,t){return Se.apply(this,arguments)}function Se(){return(Se=n(s.mark(function e(t,r){var n;return s.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,ge(Buffer.from(t,"base64url"),r);case 1:return n=e.sent,e.abrupt("return",n.toString("utf8"));case 2:case"end":return e.stop()}},e)}))).apply(this,arguments)}function je(e,t){var r=d(t,he,24),n=m(16),a=y(pe,r,n),u=a.update(e),i=a.final();return Buffer.concat([n,u,i])}function Ce(e,t){var r=d(t,he,24),n=e.subarray(0,16),a=e.subarray(16),u=b(pe,r,n),i=u.update(a),o=u.final();return Buffer.concat([i,o])}function Ae(){return ze.apply(this,arguments)}function ze(){return(ze=n(s.mark(function e(){return s.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:ve.clear();case 1:case"end":return e.stop()}},e)}))).apply(this,arguments)}var Pe=w.resolve(k.tmpdir(),"niba_cache");function Ee(){return(Ee=n(s.mark(function e(){return s.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=1,x.ls(Pe);case 1:return e.abrupt("return",e.sent);case 2:e.prev=2,e.catch(0);case 3:case"end":return e.stop()}},e,null,[[0,2]])}))).apply(this,arguments)}function Be(e){return Ie.apply(this,arguments)}function Ie(){return(Ie=n(s.mark(function e(t){var r,n;return s.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=1,x.get(Pe,t);case 1:return r=e.sent,n=r.data,e.abrupt("return",n.toString("utf-8"));case 2:return e.prev=2,e.catch(0),e.abrupt("return",null);case 3:case"end":return e.stop()}},e,null,[[0,2]])}))).apply(this,arguments)}function De(){return(De=n(s.mark(function e(t){var r;return s.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,Be(t);case 1:return r=e.sent,e.prev=2,e.abrupt("return",r&&JSON.parse(r));case 3:return e.prev=3,e.catch(2),e.abrupt("return",null);case 4:case"end":return e.stop()}},e,null,[[2,3]])}))).apply(this,arguments)}function qe(e,t){return Ge.apply(this,arguments)}function Ge(){return(Ge=n(s.mark(function e(t,r){return s.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=1,x.put(Pe,t,r+"");case 1:e.next=3;break;case 2:e.prev=2,e.catch(0);case 3:case"end":return e.stop()}},e,null,[[0,2]])}))).apply(this,arguments)}function Le(){return(Le=n(s.mark(function e(t,r){return s.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,qe(t,JSON.stringify(r));case 1:case"end":return e.stop()}},e)}))).apply(this,arguments)}function Ne(){return(Ne=n(s.mark(function e(t){return s.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=1,x.rm.entry(Pe,t);case 1:e.next=3;break;case 2:e.prev=2,e.catch(0);case 3:case"end":return e.stop()}},e,null,[[0,2]])}))).apply(this,arguments)}function Re(){return(Re=n(s.mark(function e(){return s.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=1,x.rm.all(Pe);case 1:e.next=3;break;case 2:e.prev=2,e.catch(0);case 3:case"end":return e.stop()}},e,null,[[0,2]])}))).apply(this,arguments)}var Te=Object.freeze({__proto__:null,clear:function(){return Re.apply(this,arguments)},evict:function(e){return Ne.apply(this,arguments)},getObject:function(e){return De.apply(this,arguments)},getText:Be,ls:function(){return Ee.apply(this,arguments)},setObject:function(e,t){return Le.apply(this,arguments)},setPath:function(e){Pe=e},setText:qe}),Me="eD300Ezu9r4Q3CPM7XQt-Q";function Ue(e){return _e.apply(this,arguments)}function _e(){return(_e=n(s.mark(function e(t){var r,n,a,u,i,o,c,f,l,p,h,d;return s.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.uid,n=t.device,a=void 0===n?"unknow":n,u=t.key,i=void 0===u?Me:u,o=t.timeout,c=void 0===o?30:o,f=(new Date).getTime(),e.next=1,v(m)(16);case 1:return l=e.sent,p=Buffer.from(f+60*c*1e3+"","ascii"),h=Buffer.concat([p,Buffer.from("".concat(r,"<=>").concat(a,"<=>").concat(f)),l]),e.next=2,me(h,i);case 2:return d=e.sent,e.next=3,qe("".concat(r,"@").concat(a),f);case 3:return e.abrupt("return",d.toString("base64url"));case 4:case"end":return e.stop()}},e)}))).apply(this,arguments)}function Fe(e){return $e.apply(this,arguments)}function $e(){return($e=n(s.mark(function e(t){var r,n,a,u,o,c,f,l,p,h,v,d;return s.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.token,n=t.key,a=void 0===n?Me:n,u=Buffer.from(r,"base64url"),e.next=1,ge(u,a);case 1:if(o=e.sent,c=o.subarray(0,o.length-16).toString("utf8"),!(parseInt(c.slice(0,13))<(new Date).getTime())){e.next=2;break}return e.abrupt("return",null);case 2:return f=c.slice(13).split("<=>"),l=i(f,3),p=l[0],h=l[1],v=l[2],e.next=3,Be("".concat(p,"@").concat(h));case 3:if(d=e.sent,!(parseInt(v)<parseInt(d))){e.next=4;break}return e.abrupt("return",null);case 4:return e.abrupt("return",{uid:p,device:h});case 5:case"end":return e.stop()}},e)}))).apply(this,arguments)}function Qe(e){var t=e.userGetter,r=e.ACLGetter,a=e.tokenParser,u=void 0===a?Fe:a;return function(){var e=n(s.mark(function e(n,a){var i,o,c,f,l,p,h,v,d;return s.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if((i=null)||(c=null===(o=n.headers)||void 0===o?void 0:o.authorization,i=null==c?void 0:c.substring(7).trim()),i||(i=null===(f=n.query)||void 0===f?void 0:f.token),O.debug("--\x3e token: %s",i),i){e.next=2;break}return e.next=1,a();case 1:return e.abrupt("return");case 2:return e.prev=2,e.next=3,u({token:i});case 3:if(l=e.sent,p=l.uid,h=l.device,O.debug("uid: %s, device: %s",p,h),!t||"function"!=typeof t){e.next=5;break}return e.next=4,t({uid:p,device:h});case 4:v=e.sent,n.state.USER=v;case 5:if(!r||"function"!=typeof r){e.next=7;break}return e.next=6,r({uid:p,device:h});case 6:d=e.sent,n.state.ACL=d;case 7:e.next=9;break;case 8:e.prev=8,e.catch(2),n.throw(401);case 9:return e.next=10,a();case 10:case"end":return e.stop()}},e,null,[[2,8]])}));return function(t,r){return e.apply(this,arguments)}}()}function Je(){return function(){var e=n(s.mark(function e(t,r){var n;return s.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,r();case 1:(n=t.accepts("*/*","text/*","application/json"))&&(t.type="".concat(n,"; charset=utf-8"));case 2:case"end":return e.stop()}},e)}));return function(t,r){return e.apply(this,arguments)}}()}function We(n){var a=n.context,u=void 0===a?"":a,i=n.routes,o=void 0===i?[]:i,c=n.plugins,s=void 0===c?[]:c,f=n.userGetter,l=void 0===f?null:f,p=n.ACLGetter,h=void 0===p?null:p,v=n.tokenParser,d=void 0===v?null:v,b=n.logger,m=void 0===b?null:b;m&&S(m);var y=new t;return y.use(r({enableTypes:["json","form","text"]})),y.use(Qe({userGetter:l,ACLGetter:h,tokenParser:d})),y.use(le(o,u)),y.use(Je()),s.forEach(function(e){y.use(e)}),e.createServer(y.callback())}function Ye(e){var t=e.context,r=void 0===t?"":t,n=e.routes,a=void 0===n?[]:n,u=e.plugins,i=void 0===u?[]:u,o=e.hostname,c=void 0===o?"localhost":o,s=e.port,f=void 0===s?9090:s,l=e.userGetter,p=void 0===l?null:l,h=e.ACLGetter,v=void 0===h?null:h,d=e.tokenParser,b=void 0===d?null:d,m=e.logger,y=We({context:r,routes:a,plugins:i,logger:void 0===m?null:m,userGetter:p,ACLGetter:v,tokenParser:b});O.info("--\x3e niba is listening at http://".concat(c,":").concat(f)),y.listen(f,c)}export{T as BadGateway,z as BadRequest,L as Conflict,E as Forbidden,N as InternalServerError,I as MethodNotAllowed,A as NBError,D as NotAcceptable,B as NotFound,R as NotImplemented,q as ProxyAuthenticationRequired,M as ServiceUnavailable,G as Timeout,P as Unauthorized,Qe as authentication,Te as cache,ae as clearCache,Ae as clearKeyCache,We as createServer,Ue as createToken,ge as decrypt,Ce as decryptSync,Oe as decryptText,le as dispatcher,te as enableCache,me as encrypt,je as encryptSync,we as encryptText,ue as getCacheStats,O as logger,Fe as parseToken,Je as rjson,Ye as serve,re as setCacheMaxSize,ne as setCacheTTL,S as setLogger};
1
+ import t from"http";import r from"koa";import e from"koa-bodyparser";import n from"@babel/runtime/helpers/asyncToGenerator";import u from"@babel/runtime/helpers/slicedToArray";import a from"@babel/runtime/helpers/typeof";import o from"@babel/runtime/helpers/defineProperty";import i from"@babel/runtime/regenerator";import c from"@babel/runtime/helpers/createClass";import s from"@babel/runtime/helpers/classCallCheck";import f from"@babel/runtime/helpers/possibleConstructorReturn";import p from"@babel/runtime/helpers/getPrototypeOf";import l from"@babel/runtime/helpers/inherits";import h from"@babel/runtime/helpers/wrapNativeSuper";import{LRUCache as v}from"lru-cache";import{promisify as d}from"node:util";import{scryptSync as b,createDecipheriv as m,randomBytes as y,createCipheriv as g,scrypt as x}from"node:crypto";import w from"cacache";import k from"path";import O from"os";var S=console;function j(t){S=t}var A=S;function C(t,r,e){return r=p(r),f(t,P()?Reflect.construct(r,e||[],p(t).constructor):r.apply(t,e))}function P(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(P=function(){return!!t})()}var E=function(t){function r(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:500;return s(this,r),(e=C(this,r,[t])).code=n,e}return l(r,t),c(r)}(h(Error)),G=function(){function t(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Bad Request";return s(this,t),C(this,t,[r,400])}return l(t,E),c(t)}(),B=function(){function t(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Unauthorized";return s(this,t),C(this,t,[r,401])}return l(t,E),c(t)}(),q=function(){function t(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Forbidden";return s(this,t),C(this,t,[r,403])}return l(t,E),c(t)}(),z=function(){function t(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Not Found";return s(this,t),C(this,t,[r,404])}return l(t,E),c(t)}(),I=function(){function t(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Method Not Allowed";return s(this,t),C(this,t,[r,405])}return l(t,E),c(t)}(),L=function(){function t(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Not Acceptable";return s(this,t),C(this,t,[r,406])}return l(t,E),c(t)}(),R=function(){function t(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Proxy Authentication Required";return s(this,t),C(this,t,[r,407])}return l(t,E),c(t)}(),T=function(){function t(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Time-out";return s(this,t),C(this,t,[r,408])}return l(t,E),c(t)}(),N=function(){function t(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Conflict";return s(this,t),C(this,t,[r,409])}return l(t,E),c(t)}(),D=function(){function t(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Internal Server Error";return s(this,t),C(this,t,[r,500])}return l(t,E),c(t)}(),U=function(){function t(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Not Implemented";return s(this,t),C(this,t,[r,501])}return l(t,E),c(t)}(),_=function(){function t(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Bad Gateway";return s(this,t),C(this,t,[r,502])}return l(t,E),c(t)}(),F=function(){function t(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Service Unavailable";return s(this,t),C(this,t,[r,503])}return l(t,E),c(t)}();function M(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=function(t,r){if(t){if("string"==typeof t)return $(t,r);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?$(t,r):void 0}}(t))||r){e&&(t=e);var n=0,u=function(){};return{s:u,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:u}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,i=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return o=t.done,t},e:function(t){i=!0,a=t},f:function(){try{o||null==e.return||e.return()}finally{if(i)throw a}}}}function $(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}function Q(t,r){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),e.push.apply(e,n)}return e}function J(t){for(var r=1;r<arguments.length;r++){var e=null!=arguments[r]?arguments[r]:{};r%2?Q(Object(e),!0).forEach(function(r){o(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):Q(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}var W=/\((.*?)\)/g,Y=/(\(\?)?:\w+/g,H=/\*\w+/g,V=/[\-{}\[\]+?.,\\\^$|#\s]/g,X={maxSize:1e3,ttl:3e5,enabled:!0},K=new v({max:X.maxSize,ttl:X.ttl,updateAgeOnGet:!0}),Z=new v({max:X.maxSize,ttl:X.ttl,updateAgeOnGet:!0}),tt=new v({max:X.maxSize,ttl:X.ttl,updateAgeOnGet:!0});function rt(t){if("string"!=typeof t)return t;var r=t.trim();if(r.length>1e4)throw new E("Input too large",400);return r.indexOf(",")<0?r:r.split(",").map(function(t){var r=t.trim();if(r.length>1e3)throw new E("CSV item too large",400);return/^\d+(\.\d+)?$/g.test(r)?parseFloat(r):r}).filter(function(t){return null!=t&&""!==t})}function et(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];X.enabled=t}function nt(t){X.maxSize=t}function ut(t){X.ttl=t,K.ttl=t,Z.ttl=t,tt.ttl=t}function at(){K.clear(),Z.clear(),tt.clear()}function ot(t,r,e){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";if(!X.enabled)return ft(t,r,e,n);var u="".concat(r,":").concat(n,":").concat(e),a=Z.get(u);if(void 0!==a)return a;var o=ft(t,r,e,n);return null!==o&&Z.set(u,o),o}function it(){return{routeRegexCache:K.size,routeMatchCache:Z.size,paramExtractCache:tt.size,config:J({},X)}}function ct(t){var r=t.replace(V,"\\$&").replace(W,function(t,r){return"(?:"+r+")?"}).replace(Y,function(t,r){return r?t:"([^/?]+)"}).replace(H,"([^?]*?)");return new RegExp("^"+r+"(?:\\?([\\s\\S]*))?$")}function st(t,r){var e=t.exec(r).slice(1);return e.map(function(t,r){return r===e.length-1?t||null:t?decodeURIComponent(t):null})}function ft(t,r,e){var n,u=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",a=r.toLowerCase(),i=M(t);try{var c,s=function(){var t=n.value;if(t.method)if(Array.isArray(t.method)){if(!t.method.some(function(t){return t.toLowerCase()===a}))return 0}else{if("string"!=typeof t.method)return 0;if(t.method.toLowerCase()!==a)return 0}var r="".concat(u).concat(t.path),i=function(t){if(!X.enabled)return ct(t);var r=t,e=K.get(r);if(void 0!==e)return e;var n=ct(t);return K.set(r,n),n}(r);if(!i.test(e))return 0;var c={},s=r.match(Y);if(!s)return{v:{route:t,patterns:c}};var f=function(t,r){if(!X.enabled)return st(t,r);var e="".concat(t.source,":").concat(r),n=tt.get(e);if(void 0!==n)return n;var u=st(t,r);return tt.set(e,u),u}(i,e);return s.forEach(function(t,r){Object.assign(c,o({},t.slice(1),rt(f[r])))}),{v:{route:t,patterns:c}}};for(i.s();!(n=i.n()).done;)if(0!==(c=s())&&c)return c.v}catch(t){i.e(t)}finally{i.f()}return null}function pt(t,r){var e={},n={};Array.isArray(r)?r.forEach(function(t){n[t]=t}):r&&"object"===a(r)&&Object.assign(n,r);var o={};Object.entries(n).forEach(function(t){var r=u(t,2),e=r[0],n=r[1];o[n]=e});for(var i=0,c=Object.entries(t);i<c.length;i++){var s=u(c[i],2),f=s[0],p=rt(s[1]);e[o[f]||f]=p}return e}function lt(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return function(){var e=n(i.mark(function e(n,u){var c,s,f,p,l,h,v,d,b,m,y;return i.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(s=n.path,f=ot(t,n.method,s,r)){e.next=1;break}return n.status=404,n.body={error:"Not Found"},e.abrupt("return");case 1:if(p=f.route,l=f.patterns,A.debug("--\x3e route %o, patterns: %o",p,l),h=p.handler,A.debug("--\x3e handler: %o, type: %o",h,a(h)),h&&"function"==typeof h){e.next=2;break}return n.throw(500,"The handler cannot be found"),e.abrupt("return");case 2:if(v=n.state.USER,A.debug("--\x3e current user: %o",v),!p.auth||v){e.next=3;break}return n.throw(401),e.abrupt("return");case 3:if(d=null!==(c=n.state.ACL)&&void 0!==c?c:[],"string"!=typeof p.auth||d.includes(p.auth)){e.next=4;break}return n.throw(403),e.abrupt("return");case 4:return b=J(J({request:n.request,response:n.response},l),{},{_user:v}),"string"==typeof p.body?Object.assign(b,o({},p.body,n.request.body)):Object.assign(b,{body:n.request.body}),p.header&&Object.assign(b,pt(n.request.header,p.header)),p.query&&Object.assign(b,pt(n.request.query,p.query)),m={},e.prev=5,e.next=6,h(b);case 6:m=e.sent,e.next=8;break;case 7:e.prev=7,y=e.catch(5),A.error("Handler error: %s",y.message,{stack:y.stack}),y instanceof E?n.throw(y.code,y.message):n.throw(500,"Internal Server Error");case 8:if(!(n.status>=300&&n.status<400)){e.next=10;break}return e.next=9,u();case 9:return e.abrupt("return");case 10:return null!=m?n.body=m:(n.body=null,200!==n.status&&404!==n.status||(n.status=204)),e.next=11,u();case 11:case"end":return e.stop()}},e,null,[[5,7]])}));return function(t,r){return e.apply(this,arguments)}}()}var ht="aes-192-cbc",vt="bmliYW5pYmFsYW5uaWJhIQ==",dt=new Map;function bt(t){return mt.apply(this,arguments)}function mt(){return(mt=n(i.mark(function t(r){var e;return i.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(!dt.has(r)){t.next=1;break}return t.abrupt("return",dt.get(r));case 1:return t.next=2,d(x)(r,vt,24);case 2:return e=t.sent,dt.set(r,e),t.abrupt("return",e);case 3:case"end":return t.stop()}},t)}))).apply(this,arguments)}function yt(t,r){return gt.apply(this,arguments)}function gt(){return(gt=n(i.mark(function t(r,e){var n,u,a,o,c;return i.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=1,bt(e);case 1:return n=t.sent,u=y(16),a=g(ht,n,u),o=a.update(r),c=a.final(),t.abrupt("return",Buffer.concat([u,o,c]));case 2:case"end":return t.stop()}},t)}))).apply(this,arguments)}function xt(t,r){return wt.apply(this,arguments)}function wt(){return(wt=n(i.mark(function t(r,e){var n,u,a,o,c,s;return i.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=1,bt(e);case 1:return n=t.sent,u=r.subarray(0,16),a=r.subarray(16),o=m(ht,n,u),c=o.update(a),s=o.final(),t.abrupt("return",Buffer.concat([c,s]));case 2:case"end":return t.stop()}},t)}))).apply(this,arguments)}function kt(t,r){return Ot.apply(this,arguments)}function Ot(){return(Ot=n(i.mark(function t(r,e){var n;return i.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=1,yt(Buffer.from(r,"utf8"),e);case 1:return n=t.sent,t.abrupt("return",n.toString("base64url"));case 2:case"end":return t.stop()}},t)}))).apply(this,arguments)}function St(t,r){return jt.apply(this,arguments)}function jt(){return(jt=n(i.mark(function t(r,e){var n;return i.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=1,xt(Buffer.from(r,"base64url"),e);case 1:return n=t.sent,t.abrupt("return",n.toString("utf8"));case 2:case"end":return t.stop()}},t)}))).apply(this,arguments)}function At(t,r){var e=b(r,vt,24),n=y(16),u=g(ht,e,n),a=u.update(t),o=u.final();return Buffer.concat([n,a,o])}function Ct(t,r){var e=b(r,vt,24),n=t.subarray(0,16),u=t.subarray(16),a=m(ht,e,n),o=a.update(u),i=a.final();return Buffer.concat([o,i])}function Pt(){return Et.apply(this,arguments)}function Et(){return(Et=n(i.mark(function t(){return i.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:dt.clear();case 1:case"end":return t.stop()}},t)}))).apply(this,arguments)}var Gt=k.resolve(O.tmpdir(),"niba_cache");function Bt(){return(Bt=n(i.mark(function t(){return i.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=1,w.ls(Gt);case 1:return t.abrupt("return",t.sent);case 2:t.prev=2,t.catch(0);case 3:case"end":return t.stop()}},t,null,[[0,2]])}))).apply(this,arguments)}function qt(t){return zt.apply(this,arguments)}function zt(){return(zt=n(i.mark(function t(r){var e,n;return i.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=1,w.get(Gt,r);case 1:return e=t.sent,n=e.data,t.abrupt("return",n.toString("utf-8"));case 2:return t.prev=2,t.catch(0),t.abrupt("return",null);case 3:case"end":return t.stop()}},t,null,[[0,2]])}))).apply(this,arguments)}function It(){return(It=n(i.mark(function t(r){var e;return i.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=1,qt(r);case 1:return e=t.sent,t.prev=2,t.abrupt("return",e&&JSON.parse(e));case 3:return t.prev=3,t.catch(2),t.abrupt("return",null);case 4:case"end":return t.stop()}},t,null,[[2,3]])}))).apply(this,arguments)}function Lt(t,r){return Rt.apply(this,arguments)}function Rt(){return(Rt=n(i.mark(function t(r,e){return i.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=1,w.put(Gt,r,e+"");case 1:t.next=3;break;case 2:t.prev=2,t.catch(0);case 3:case"end":return t.stop()}},t,null,[[0,2]])}))).apply(this,arguments)}function Tt(){return(Tt=n(i.mark(function t(r,e){return i.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=1,Lt(r,JSON.stringify(e));case 1:case"end":return t.stop()}},t)}))).apply(this,arguments)}function Nt(){return(Nt=n(i.mark(function t(r){return i.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=1,w.rm.entry(Gt,r);case 1:t.next=3;break;case 2:t.prev=2,t.catch(0);case 3:case"end":return t.stop()}},t,null,[[0,2]])}))).apply(this,arguments)}function Dt(){return(Dt=n(i.mark(function t(){return i.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=1,w.rm.all(Gt);case 1:t.next=3;break;case 2:t.prev=2,t.catch(0);case 3:case"end":return t.stop()}},t,null,[[0,2]])}))).apply(this,arguments)}var Ut=Object.freeze({__proto__:null,clear:function(){return Dt.apply(this,arguments)},evict:function(t){return Nt.apply(this,arguments)},getObject:function(t){return It.apply(this,arguments)},getText:qt,ls:function(){return Bt.apply(this,arguments)},setObject:function(t,r){return Tt.apply(this,arguments)},setPath:function(t){Gt=t},setText:Lt}),_t="eD300Ezu9r4Q3CPM7XQt-Q";function Ft(t){return Mt.apply(this,arguments)}function Mt(){return(Mt=n(i.mark(function t(r){var e,n,u,a,o,c,s,f,p,l,h,v;return i.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return e=r.uid,n=r.device,u=void 0===n?"unknow":n,a=r.key,o=void 0===a?_t:a,c=r.timeout,s=void 0===c?30:c,f=(new Date).getTime(),t.next=1,d(y)(16);case 1:return p=t.sent,l=Buffer.from(f+60*s*1e3+"","ascii"),h=Buffer.concat([l,Buffer.from("".concat(e,"<=>").concat(u,"<=>").concat(f)),p]),t.next=2,yt(h,o);case 2:return v=t.sent,t.next=3,Lt("".concat(e,"@").concat(u),f);case 3:return t.abrupt("return",v.toString("base64url"));case 4:case"end":return t.stop()}},t)}))).apply(this,arguments)}function $t(t){return Qt.apply(this,arguments)}function Qt(){return(Qt=n(i.mark(function t(r){var e,n,a,o,c,s,f,p,l,h,v,d;return i.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return e=r.token,n=r.key,a=void 0===n?_t:n,o=Buffer.from(e,"base64url"),t.next=1,xt(o,a);case 1:if(c=t.sent,s=c.subarray(0,c.length-16).toString("utf8"),!(parseInt(s.slice(0,13))<(new Date).getTime())){t.next=2;break}return t.abrupt("return",null);case 2:return f=s.slice(13).split("<=>"),p=u(f,3),l=p[0],h=p[1],v=p[2],t.next=3,qt("".concat(l,"@").concat(h));case 3:if(d=t.sent,!(parseInt(v)<parseInt(d))){t.next=4;break}return t.abrupt("return",null);case 4:return t.abrupt("return",{uid:l,device:h});case 5:case"end":return t.stop()}},t)}))).apply(this,arguments)}function Jt(t){var r=t.userGetter,e=t.ACLGetter,u=t.tokenParser,a=void 0===u?$t:u;return function(){var t=n(i.mark(function t(n,u){var o,c,s,f,p,l,h,v,d;return i.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if((o=null)||(s=null===(c=n.headers)||void 0===c?void 0:c.authorization,o=null==s?void 0:s.substring(7).trim()),o||(o=null===(f=n.query)||void 0===f?void 0:f.token),A.debug("--\x3e token: %s",o),o){t.next=2;break}return t.next=1,u();case 1:return t.abrupt("return");case 2:return t.prev=2,t.next=3,a({token:o});case 3:if(p=t.sent,l=p.uid,h=p.device,A.debug("uid: %s, device: %s",l,h),!r||"function"!=typeof r){t.next=5;break}return t.next=4,r({uid:l,device:h});case 4:v=t.sent,n.state.USER=v;case 5:if(!e||"function"!=typeof e){t.next=7;break}return t.next=6,e({uid:l,device:h});case 6:d=t.sent,n.state.ACL=d;case 7:t.next=9;break;case 8:t.prev=8,t.catch(2),n.throw(401);case 9:return t.next=10,u();case 10:case"end":return t.stop()}},t,null,[[2,8]])}));return function(r,e){return t.apply(this,arguments)}}()}function Wt(){return function(){var t=n(i.mark(function t(r,e){var n;return i.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=1,e();case 1:(n=r.accepts("*/*","text/*","application/json"))&&(r.type="".concat(n,"; charset=utf-8"));case 2:case"end":return t.stop()}},t)}));return function(r,e){return t.apply(this,arguments)}}()}function Yt(n){var u=n.context,a=void 0===u?"":u,o=n.routes,i=void 0===o?[]:o,c=n.plugins,s=void 0===c?[]:c,f=n.userGetter,p=void 0===f?null:f,l=n.ACLGetter,h=void 0===l?null:l,v=n.tokenParser,d=void 0===v?null:v,b=n.logger,m=void 0===b?null:b;m&&j(m);var y=new r;return y.use(e({enableTypes:["json","form","text"]})),y.use(Jt({userGetter:p,ACLGetter:h,tokenParser:d})),y.use(lt(i,a)),y.use(Wt()),s.forEach(function(t){y.use(t)}),t.createServer(y.callback())}function Ht(t){var r=t.context,e=void 0===r?"":r,n=t.routes,u=void 0===n?[]:n,a=t.plugins,o=void 0===a?[]:a,i=t.hostname,c=void 0===i?"localhost":i,s=t.port,f=void 0===s?9090:s,p=t.userGetter,l=void 0===p?null:p,h=t.ACLGetter,v=void 0===h?null:h,d=t.tokenParser,b=void 0===d?null:d,m=t.logger,y=Yt({context:e,routes:u,plugins:o,logger:void 0===m?null:m,userGetter:l,ACLGetter:v,tokenParser:b});A.info("--\x3e niba is listening at http://".concat(c,":").concat(f)),y.listen(f,c)}export{_ as BadGateway,G as BadRequest,N as Conflict,q as Forbidden,D as InternalServerError,I as MethodNotAllowed,E as NBError,L as NotAcceptable,z as NotFound,U as NotImplemented,R as ProxyAuthenticationRequired,F as ServiceUnavailable,T as Timeout,B as Unauthorized,Jt as authentication,Ut as cache,at as clearCache,Pt as clearKeyCache,Yt as createServer,Ft as createToken,xt as decrypt,Ct as decryptSync,St as decryptText,lt as dispatcher,et as enableCache,yt as encrypt,At as encryptSync,kt as encryptText,it as getCacheStats,A as logger,$t as parseToken,Wt as rjson,Ht as serve,nt as setCacheMaxSize,ut as setCacheTTL,j as setLogger};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "niba-api",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "An easy-to-use RESTful API development framework",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -41,7 +41,8 @@
41
41
  "@babel/runtime": "^7.23.5",
42
42
  "cacache": "^17.1.4",
43
43
  "koa": "^2.14.2",
44
- "koa-bodyparser": "^4.4.1"
44
+ "koa-bodyparser": "^4.4.1",
45
+ "lru-cache": "^11.2.5"
45
46
  },
46
47
  "publishConfig": {
47
48
  "directory": "dist"