gemi 0.4.53 → 0.4.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app/index.js +1 -1
- package/dist/auth/AuthenticationServiceProvider.d.ts.map +1 -1
- package/dist/chunk-01ffccc19e8ef862.js +3 -0
- package/dist/chunk-16dbe3a15379140b.js +2 -0
- package/dist/chunk-2279c382943fca51.js +2 -0
- package/dist/chunk-2335866508ec8b1b.js +2 -0
- package/dist/chunk-2e34b856e195c353.js +2 -0
- package/dist/chunk-2e447b50094b2862.js +2 -0
- package/dist/chunk-40111275eef9f7b3.js +6 -0
- package/dist/chunk-40942fb138dcd780.js +9 -0
- package/dist/chunk-4f5b07a6a6fd5cc6.js +2 -0
- package/dist/chunk-52e76204b898931e.js +18 -0
- package/dist/chunk-53b7d6267c9172bc.js +2 -0
- package/dist/chunk-53c39aca36ece018.js +2 -0
- package/dist/chunk-545989119755857f.js +2 -0
- package/dist/chunk-56f6f8c2162dcf1c.js +2 -0
- package/dist/chunk-59980167a4c574b3.js +2 -0
- package/dist/chunk-77d1b26236f5feec.js +2 -0
- package/dist/chunk-795a1bd1d89efce1.js +2 -0
- package/dist/chunk-7fef11f59982b1f6.js +2 -0
- package/dist/chunk-a10ae1a06a28aaab.js +2 -0
- package/dist/chunk-a991fdce275f1256.js +2 -0
- package/dist/chunk-adb4e1e222eb1d20.js +2 -0
- package/dist/chunk-b97189ea9588db36.js +9 -0
- package/dist/chunk-ba051a98cd651063.js +1 -0
- package/dist/chunk-bdf4f2b1862899bb.js +2 -0
- package/dist/chunk-c83b39b7178003da.js +2 -0
- package/dist/chunk-cdfa2adeddc1a8e1.js +2 -0
- package/dist/chunk-d16ef78d852a6856.js +1 -0
- package/dist/chunk-d3033805e98482dc.js +6 -0
- package/dist/chunk-d43b3f444e738dd1.js +1 -0
- package/dist/chunk-dc23bfb4fd92e2f0.js +2 -0
- package/dist/chunk-de3ec02f9d17c2c9.js +2 -0
- package/dist/chunk-f0d3ed16a520ecf1.js +18 -0
- package/dist/chunk-f316793e4ec0f386.js +2 -0
- package/dist/chunk-f67aa3e46d73674e.js +2 -0
- package/dist/client/index.js +35 -17
- package/dist/client/useMutation.d.ts.map +1 -1
- package/dist/client/useQuery.d.ts +2 -2
- package/dist/client/useQuery.d.ts.map +1 -1
- package/dist/facades/index.js +1 -1
- package/dist/http/index.js +1 -1
- package/dist/kernel/index.js +2 -2
- package/dist/server/index.js +1 -1
- package/dist/storage/index.js +1 -10
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useQuery.d.ts","sourceRoot":"","sources":["../../client/useQuery.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,KAAK,EACV,QAAQ,
|
|
1
|
+
{"version":3,"file":"useQuery.d.ts","sourceRoot":"","sources":["../../client/useQuery.ts"],"names":[],"mappings":"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"}
|
package/dist/facades/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{f as p,
|
|
2
|
+
import{f as p,h as c,l as s,n} from"../http/index.js";import"../chunk-7ce930fe69575c87.js";class i{static async user(){const r=c.getStore(),a=r.req.cookies.get("access_token");let t=r.user;if(!t)t=(await s.getStore().authenticationServiceProvider.adapter.findSession({token:a,userAgent:r.req.headers.get("User-Agent")}))?.user,r.setUser(t);if(t)return t;return null}static async guard(r){const a=await i.user();if(!a)throw new n;try{if(!await r(a))throw new n}catch(t){throw new n}}static async guardSafe(r){const a=await i.user();if(!a)return!1;try{return await r(a)}catch(t){return!1}}}class l extends p{constructor(r){super("Redirect error");this.name="RedirectError",this.payload={api:{status:302,data:{error:"Redirect error"}},view:{status:302,headers:{"Cache-Control":"private, no-cache, no-store, max-age=0, must-revalidate",Location:r}}}}}class m{static to(r){throw new l(r)}}function d(r,a){return r.replace(/{{([^}]+)}}/g,(t,o)=>{const e=a[o];if(e===void 0)throw new Error(`Missing parameter: ${o}`);return e})}class g{static scope(r){return r}static translate(r,...a){const t=s.getStore().i18nServiceContainer,o=t.detectLocale(c.getStore().req),e=t.translations.get(`${o}.server`)?.[r];if(!e)return r;return d(e,a[0])}}export{m as Redirect,g as I18n,i as Auth};export{i as q};
|
package/dist/http/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"../chunk-7ce930fe69575c87.js";class P{requests={};static kind="controller";constructor(){}}class f extends P{constructor(){super(...arguments)}}function H(e){return typeof e==="function"&&e.prototype!==void 0}var L=function(e){return H(e)};class u{e;t;n;middlewares=[];constructor(e,t,n){this.method=e;this.handler=t;this.methodName=n;this.handler=t,this.methodName=n,this.method=e}run(e){let t=e;if(L(this.handler)){const n=new this.handler,r=n[this.methodName].bind(n);return t=n.requests[this.methodName]?new n.requests[this.methodName](e.rawRequest,e.params):t,r(t)}else return this.handler(e)}middleware(e){return this.middlewares=e,this}}class K{constructor(...e){return new u(...e)}}class h{routes={};middlewares=[];middleware(e){}get(e,t){return new u("GET",e,t)}post(e,t){return new u("POST",e,t)}put(e,t){return new u("PUT",e,t)}patch(e,t){return new u("PATCH",e,t)}delete(e,t){return new u("DELETE",e,t)}resource(e){class t extends h{constructor(){super(...arguments)}routes={"/":{list:this.get(e,"list"),create:this.post(e,"create")},"/:id":{show:this.get(e,"show"),update:this.put(e,"update"),delete:this.delete(e,"delete")}}}return t}file(e,t){return new K("GET",e,t)}}class g{e;middlewares=[];handler;constructor(e,t){this.viewPath=e;if(!t)this.handler=()=>({});else if(typeof t==="function")this.handler=t;else{const[n,r]=t,s=new n,o=s[r].bind(s);this.handler=(i)=>{let a=i;return a=s.requests[r]?new s.requests[r](i.rawRequest,i.params):a,o(i)}}}async run(e){return{[this.viewPath]:await this.handler(e)}}middleware(e){return this.middlewares=e,this}}class O{e;children;middlewares=[];handler=()=>({});constructor(e,t,n){this.viewPath=e;if(typeof t==="function")this.handler=t,this.children=class extends p{routes=n??{}};else if(Array.isArray(t)){const[r,s]=t,o=new r,i=o[s].bind(o);this.handler=(a)=>{let d=a;return d=o.requests[s]?new o.requests[s](a.rawRequest,a.params):d,i(a)},this.children=class extends p{routes=n??{}}}else this.children=class extends p{routes=t},this.handler=()=>({})}async run(e){return{[this.viewPath]:await this.handler(e)}}middleware(e){return this.middlewares=e,this}}class p{middlewares=[];routes={};view(e,t){return new g(e,t)}layout(e,t,n){return new O(e,t,n)}}var Z="GEMI_REQUEST_BREAKER_ERROR";class l extends Error{constructor(){super(...arguments)}kind="GEMI_REQUEST_BREAKER_ERROR";payload={api:{},view:{}}}class c extends l{errors={};constructor(e){super("Validation error");this.name="ValidationError",this.errors=e,this.payload={api:{status:400,data:{error:{kind:"validation_error",messages:e}},headers:{"Content-Type":"application/json"}},view:{status:400}}}}import{AsyncLocalStorage as U} from"async_hooks";class m{e;t;n;constructor(e,t,n={}){this.name=e;this.value=t;this.options=n}toString(){return[`${this.name}=${this.value}`,this.options.maxAge?`Max-Age=${this.options.maxAge}`:"",this.options.httpOnly?"HttpOnly":"",this.options.secure?"Secure":"",this.options.sameSite?`SameSite=${this.options.sameSite}`:"SameSite=Strict",this.options.path?`Path=${this.options.path}`:"Path=/",this.options.domain?`Domain=${this.options.domain}`:"",this.options.expires?`Expires=${this.options.expires.toUTCString()}`:"",this.options.partitioned?"Partitioned":""].filter((e)=>e!=="").join("; ")}}var R=new U;class I{cookies=new Set;headers=new Headers;user=null;req=null;constructor(){}setCookie(e,t,n={}){this.cookies.add(new m(e,t,n))}setHeaders(e,t){this.headers.set(e,t)}setUser(e){this.user=e}setRequest(e){this.req=e}}class y{static getStore(){return R.getStore()}static setRequest(e){R.getStore().req=e}static async run(e){return R.run(new I,e)}}var v=function(e){const[t,n]=e.match(/\d+|\D+/g)??[];if(!t||!n)return 0;const r=parseInt(t);switch(n){case"B":return r;case"KB":return r*1024;case"MB":return r*1024*1024;case"GB":return r*1024*1024*1024;case"TB":return r*1024*1024*1024*1024;default:return 0}},D=function(e){switch(e){case"image":return"image";case"png":return"image/png";case"jpg":return"image/jpeg";case"jpeg":return"image/jpeg";case"ttf":return"font/ttf";case"excel":return"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";case"csv":return"text/csv";case"word":return"application/vnd.openxmlformats-officedocument.wordprocessingml.document";case"pdf":return"application/pdf";case"json":return"application/json";default:return e}},G=function(e){const[t,n]=e.split(":");switch(t){case"required":return(r)=>{if(r instanceof Blob)return r.size>0;return r!==null&&r!==void 0&&r?.length>0};case"password":return(r)=>{return/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9]).{8,}$/.test(r)};case"number":return(r)=>{if(typeof r!=="number")return!1;return!isNaN(r)};case"min":return(r)=>{return r?.length>=parseInt(n)};case"max":return(r)=>{return r?.length<=parseInt(n)};case"email":return(r)=>{return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(r)};case"file":return(r)=>{return r instanceof Blob};case"fileType":return(r)=>{if(r instanceof Blob){const s=D(n);return r.type.startsWith(s)}};case"fileSize":return(r)=>{if(r instanceof Blob){const s=v(n);return r.size<=s}};default:return()=>!0}};class w{e;constructor(e){this.data=e}get(e){return this.data[e]}set(e,t){this.data[e]=t}has(e){return this.data[e]!==void 0}toJSON(){return this.data}}class M{rawRequest;headers;cookies;schema={};params;ctx=y.getStore();constructor(e,t){this.params=t,this.rawRequest=e,this.headers=e.headers;const n=this.rawRequest.headers.get("Cookie"),r=new Map;if(n){const s=n.split(";");for(let o of s){const[i,a]=o.split("=");r.set(i.trim(),a.trim())}}this.cookies=r}refine(e){return{}}async parseBody(){const e=new w({});if(this.rawRequest.headers.get("Content-Type")==="application/json"){const t=await this.rawRequest.json();for(let[n,r]of Object.entries(t))e.set(n,r)}if(this.rawRequest.headers.get("Content-Type")==="application/x-www-form-urlencoded"){const t=await this.rawRequest.formData();for(let[n,r]of t)e.set(n,r)}if(this.rawRequest.headers.get("Content-Type").startsWith("multipart/form-data")){const t=await this.rawRequest.formData();for(let[n,r]of t)if(e.has(n)){const s=e.get(n);if(Array.isArray(s))s.push(r),e.set(n,s);else e.set(n,[s,r])}else e.set(n,r)}return e}validateInput(e){const t={};for(let[n,r]of Object.entries(this.schema))for(let[s,o]of Object.entries(r)){const i=G(s);let a=o,d=!1;if(typeof o==="function")a=o(e.get(n)),d=typeof a==="undefined";else d=i(e.get(n));if(d)continue;if(!t[n])t[n]=[];if(s==="required"){t[n]=[String(a)];break}else t[n].push(String(a))}for(let[n,r]of Object.entries(this.refine(e.toJSON())??{})){if(!t[n])t[n]=[];t[n]=[...t[n],r]}if(Object.keys(t).length>0)throw new c(t);else return e}async input(){if(this.rawRequest.method==="GET"){const e=new URL(this.rawRequest.url),t=Object.fromEntries(e.searchParams.entries());return this.validateInput(new w(t))}return this.validateInput(await this.parseBody())}async safeInput(){const e=await this.parseBody();try{return this.validateInput(e),{isValid:!0,errors:{},input:e}}catch(t){if(!(t instanceof c))throw t;return{isValid:!1,errors:t.errors,input:e}}}async terminate(e){throw"not implemented"}}class T{async run(e){return{}}}function N(e){const t=e.headers.get("cookie");if(!t)return new Map;const n=new Map,r=t.split(";");for(let s of r){const[o,i]=s.split("=");n.set(o.trim(),i)}return n}class q{aliases={}}import{AsyncLocalStorage as _} from"async_hooks";var b=new _;class C{static getStore=()=>b.getStore()}class E extends l{error;constructor(e="Not authorized"){super("Authentication error");this.name="AuthenticationError",this.error=e,this.payload={api:{status:401,data:{error:this.error}},view:{}}}}class A extends l{error;constructor(e="Insufficient permissions"){super("Authentication error");this.name="AuthenticationError",this.error=e,this.payload={api:{status:401,data:{error:this.error}},view:{}}}}class x extends l{constructor(){super("Authentication error");this.name="AuthenticationError"}payload={api:{status:401,data:{error:"Authentication error"}},view:{status:302,headers:{"Cache-Control":"private, no-cache, no-store, max-age=0, must-revalidate",Location:"/auth/sign-in"}}}}class V extends T{constructor(){super(...arguments)}async run(e){const t=y.getStore(),n=t.req.cookies.get("access_token");if(!n)throw new x;let r=t.user;if(!r){const s=await C.getStore().authenticationServiceProvider.adapter.findSession({token:n,userAgent:t.req.headers.get("User-Agent")});if(!s)throw new x;r=s?.user,t.setUser(r)}return{}}}class ${policiesList={};constructor(){const e=this.register();for(let t of e){const n=new t;this.policiesList[t.name]=n}}register(){return[]}}class k{all(e,t){return!0}}class S{dictionary={};supportedLocales=[];defaultLocale="en-US";async init(){}detectLocale(e){return this.defaultLocale}}export{N as getCookies,p as ViewRouter,c as ValidationError,f as ResourceController,l as RequestBreakerError,$ as PoliciesServiceProvider,k as Policies,q as MiddlewareServiceProvider,T as Middleware,A as InsufficientPermissionsError,S as I18nServiceProvider,M as HttpRequest,P as Controller,E as AuthorizationError,V as AuthenticationMiddleware,x as AuthenticationError,h as ApiRouter};export{P as a,H as b,h as c,p as d,Z as e,l as f,
|
|
2
|
+
import"../chunk-7ce930fe69575c87.js";class P{requests={};static kind="controller";constructor(){}}class f extends P{constructor(){super(...arguments)}}function H(e){return typeof e==="function"&&e.prototype!==void 0}var L=function(e){return H(e)};class u{e;t;n;middlewares=[];constructor(e,t,n){this.method=e;this.handler=t;this.methodName=n;this.handler=t,this.methodName=n,this.method=e}run(e){let t=e;if(L(this.handler)){const n=new this.handler,r=n[this.methodName].bind(n);return t=n.requests[this.methodName]?new n.requests[this.methodName](e.rawRequest,e.params):t,r(t)}else return this.handler(e)}middleware(e){return this.middlewares=e,this}}class K{constructor(...e){return new u(...e)}}class h{routes={};middlewares=[];middleware(e){}get(e,t){return new u("GET",e,t)}post(e,t){return new u("POST",e,t)}put(e,t){return new u("PUT",e,t)}patch(e,t){return new u("PATCH",e,t)}delete(e,t){return new u("DELETE",e,t)}resource(e){class t extends h{constructor(){super(...arguments)}routes={"/":{list:this.get(e,"list"),create:this.post(e,"create")},"/:id":{show:this.get(e,"show"),update:this.put(e,"update"),delete:this.delete(e,"delete")}}}return t}file(e,t){return new K("GET",e,t)}}class g{e;middlewares=[];handler;constructor(e,t){this.viewPath=e;if(!t)this.handler=()=>({});else if(typeof t==="function")this.handler=t;else{const[n,r]=t,s=new n,o=s[r].bind(s);this.handler=(i)=>{let a=i;return a=s.requests[r]?new s.requests[r](i.rawRequest,i.params):a,o(i)}}}async run(e){return{[this.viewPath]:await this.handler(e)}}middleware(e){return this.middlewares=e,this}}class O{e;children;middlewares=[];handler=()=>({});constructor(e,t,n){this.viewPath=e;if(typeof t==="function")this.handler=t,this.children=class extends p{routes=n??{}};else if(Array.isArray(t)){const[r,s]=t,o=new r,i=o[s].bind(o);this.handler=(a)=>{let d=a;return d=o.requests[s]?new o.requests[s](a.rawRequest,a.params):d,i(a)},this.children=class extends p{routes=n??{}}}else this.children=class extends p{routes=t},this.handler=()=>({})}async run(e){return{[this.viewPath]:await this.handler(e)}}middleware(e){return this.middlewares=e,this}}class p{middlewares=[];routes={};view(e,t){return new g(e,t)}layout(e,t,n){return new O(e,t,n)}}var Z="GEMI_REQUEST_BREAKER_ERROR";class l extends Error{constructor(){super(...arguments)}kind="GEMI_REQUEST_BREAKER_ERROR";payload={api:{},view:{}}}class c extends l{errors={};constructor(e){super("Validation error");this.name="ValidationError",this.errors=e,this.payload={api:{status:400,data:{error:{kind:"validation_error",messages:e}},headers:{"Content-Type":"application/json"}},view:{status:400}}}}import{AsyncLocalStorage as U} from"async_hooks";class m{e;t;n;constructor(e,t,n={}){this.name=e;this.value=t;this.options=n}toString(){return[`${this.name}=${this.value}`,this.options.maxAge?`Max-Age=${this.options.maxAge}`:"",this.options.httpOnly?"HttpOnly":"",this.options.secure?"Secure":"",this.options.sameSite?`SameSite=${this.options.sameSite}`:"SameSite=Strict",this.options.path?`Path=${this.options.path}`:"Path=/",this.options.domain?`Domain=${this.options.domain}`:"",this.options.expires?`Expires=${this.options.expires.toUTCString()}`:"",this.options.partitioned?"Partitioned":""].filter((e)=>e!=="").join("; ")}}var R=new U;class I{cookies=new Set;headers=new Headers;user=null;req=null;constructor(){}setCookie(e,t,n={}){this.cookies.add(new m(e,t,n))}setHeaders(e,t){this.headers.set(e,t)}setUser(e){this.user=e}setRequest(e){this.req=e}}class y{static getStore(){return R.getStore()}static setRequest(e){R.getStore().req=e}static async run(e){return R.run(new I,e)}}var v=function(e){const[t,n]=e.match(/\d+|\D+/g)??[];if(!t||!n)return 0;const r=parseInt(t);switch(n){case"B":return r;case"KB":return r*1024;case"MB":return r*1024*1024;case"GB":return r*1024*1024*1024;case"TB":return r*1024*1024*1024*1024;default:return 0}},D=function(e){switch(e){case"image":return"image";case"png":return"image/png";case"jpg":return"image/jpeg";case"jpeg":return"image/jpeg";case"ttf":return"font/ttf";case"excel":return"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";case"csv":return"text/csv";case"word":return"application/vnd.openxmlformats-officedocument.wordprocessingml.document";case"pdf":return"application/pdf";case"json":return"application/json";default:return e}},G=function(e){const[t,n]=e.split(":");switch(t){case"required":return(r)=>{if(r instanceof Blob)return r.size>0;return r!==null&&r!==void 0&&r?.length>0};case"password":return(r)=>{return/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9]).{8,}$/.test(r)};case"number":return(r)=>{if(typeof r!=="number")return!1;return!isNaN(r)};case"min":return(r)=>{return r?.length>=parseInt(n)};case"max":return(r)=>{return r?.length<=parseInt(n)};case"email":return(r)=>{return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(r)};case"file":return(r)=>{return r instanceof Blob};case"fileType":return(r)=>{if(r instanceof Blob){const s=D(n);return r.type.startsWith(s)}};case"fileSize":return(r)=>{if(r instanceof Blob){const s=v(n);return r.size<=s}};default:return()=>!0}};class w{e;constructor(e){this.data=e}get(e){return this.data[e]}set(e,t){this.data[e]=t}has(e){return this.data[e]!==void 0}toJSON(){return this.data}}class M{rawRequest;headers;cookies;schema={};params;ctx=y.getStore();constructor(e,t){this.params=t,this.rawRequest=e,this.headers=e.headers;const n=this.rawRequest.headers.get("Cookie"),r=new Map;if(n){const s=n.split(";");for(let o of s){const[i,a]=o.split("=");r.set(i.trim(),a.trim())}}this.cookies=r}refine(e){return{}}async parseBody(){const e=new w({});if(this.rawRequest.headers.get("Content-Type")==="application/json"){const t=await this.rawRequest.json();for(let[n,r]of Object.entries(t))e.set(n,r)}if(this.rawRequest.headers.get("Content-Type")==="application/x-www-form-urlencoded"){const t=await this.rawRequest.formData();for(let[n,r]of t)e.set(n,r)}if(this.rawRequest.headers.get("Content-Type").startsWith("multipart/form-data")){const t=await this.rawRequest.formData();for(let[n,r]of t)if(e.has(n)){const s=e.get(n);if(Array.isArray(s))s.push(r),e.set(n,s);else e.set(n,[s,r])}else e.set(n,r)}return e}validateInput(e){const t={};for(let[n,r]of Object.entries(this.schema))for(let[s,o]of Object.entries(r)){const i=G(s);let a=o,d=!1;if(typeof o==="function")a=o(e.get(n)),d=typeof a==="undefined";else d=i(e.get(n));if(d)continue;if(!t[n])t[n]=[];if(s==="required"){t[n]=[String(a)];break}else t[n].push(String(a))}for(let[n,r]of Object.entries(this.refine(e.toJSON())??{})){if(!t[n])t[n]=[];t[n]=[...t[n],r]}if(Object.keys(t).length>0)throw new c(t);else return e}async input(){if(this.rawRequest.method==="GET"){const e=new URL(this.rawRequest.url),t=Object.fromEntries(e.searchParams.entries());return this.validateInput(new w(t))}return this.validateInput(await this.parseBody())}async safeInput(){const e=await this.parseBody();try{return this.validateInput(e),{isValid:!0,errors:{},input:e}}catch(t){if(!(t instanceof c))throw t;return{isValid:!1,errors:t.errors,input:e}}}async terminate(e){throw"not implemented"}}class T{async run(e){return{}}}function N(e){const t=e.headers.get("cookie");if(!t)return new Map;const n=new Map,r=t.split(";");for(let s of r){const[o,i]=s.split("=");n.set(o.trim(),i)}return n}class q{aliases={}}import{AsyncLocalStorage as _} from"async_hooks";var b=new _;class C{static getStore=()=>b.getStore()}class E extends l{error;constructor(e="Not authorized"){super("Authentication error");this.name="AuthenticationError",this.error=e,this.payload={api:{status:401,data:{error:this.error}},view:{}}}}class A extends l{error;constructor(e="Insufficient permissions"){super("Authentication error");this.name="AuthenticationError",this.error=e,this.payload={api:{status:401,data:{error:this.error}},view:{}}}}class x extends l{constructor(){super("Authentication error");this.name="AuthenticationError"}payload={api:{status:401,data:{error:"Authentication error"}},view:{status:302,headers:{"Cache-Control":"private, no-cache, no-store, max-age=0, must-revalidate",Location:"/auth/sign-in"}}}}class V extends T{constructor(){super(...arguments)}async run(e){const t=y.getStore(),n=t.req.cookies.get("access_token");if(!n)throw new x;let r=t.user;if(!r){const s=await C.getStore().authenticationServiceProvider.adapter.findSession({token:n,userAgent:t.req.headers.get("User-Agent")});if(!s)throw new x;r=s?.user,t.setUser(r)}return{}}}class ${policiesList={};constructor(){const e=this.register();for(let t of e){const n=new t;this.policiesList[t.name]=n}}register(){return[]}}class k{all(e,t){return!0}}class S{dictionary={};supportedLocales=[];defaultLocale="en-US";async init(){}detectLocale(e){return this.defaultLocale}}export{N as getCookies,p as ViewRouter,c as ValidationError,f as ResourceController,l as RequestBreakerError,$ as PoliciesServiceProvider,k as Policies,q as MiddlewareServiceProvider,T as Middleware,A as InsufficientPermissionsError,S as I18nServiceProvider,M as HttpRequest,P as Controller,E as AuthorizationError,V as AuthenticationMiddleware,x as AuthenticationError,h as ApiRouter};export{P as a,H as b,h as c,p as d,Z as e,l as f,c as g,y as h,M as i,q as j,b as k,C as l,E as m,A as n,$ as o,S as p};
|