@coreframe/dashboard 0.3.24 → 0.3.25

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.
@@ -1 +1 @@
1
- import{createDashboardPluginDispatcher as e}from"./api/dispatcher.js";import{getDashboardRequestId as t,isSameOriginDashboardMutation as n}from"./host-policy.js";const r=`/__dashboard`,i=`${r}/api`,a=new WeakMap;function o(n){let r=e(n.plugins,{getRequestId:t});return(e,t)=>{let n=new URL(e.url);return!d(n.pathname)||!t.DEPLOY_ENV?null:c(e,t,n,t.DEPLOY_ENV,r)}}function s(e,t,n){if(!d(new URL(e.url).pathname)||!t.DEPLOY_ENV)return null;let r=n.plugins,i=a.get(r);return i||(i=o(n),a.set(r,i)),i(e,t)}async function c(e,t,a,o,s){if(!t.DASHBOARD_PASSWORD)return new Response(`Dashboard unavailable`,{headers:{"cache-control":`no-store`},status:503});let c=m(e.headers.get(`authorization`));if(!c||!await h(c,t.DASHBOARD_PASSWORD))return new Response(`Authentication required`,{headers:{"cache-control":`no-store`,"www-authenticate":`Basic realm="Coreframe dashboard", charset="UTF-8"`},status:401});if(a.pathname.startsWith(`${i}/plugins/`))return n(e.method,e.headers.get(`origin`),a.origin)?s(e,l(e,t,o)):p({error:{code:`invalid_input`}},403);if(a.pathname===i||a.pathname.startsWith(`${i}/`))return p({error:`Not found`},404);if(a.pathname===r)return a.pathname=`${r}/`,Response.redirect(a,302);if(e.method!==`GET`&&e.method!==`HEAD`)return new Response(`Method not allowed`,{headers:{"cache-control":`no-store`},status:405});if(!t.ASSETS)return new Response(`Dashboard unavailable`,{headers:{"cache-control":`no-store`},status:503});(a.pathname===`${r}/`||!a.pathname.slice(13).includes(`.`))&&(a.pathname=`${r}/index.html`);let u=await t.ASSETS.fetch(new Request(a,e)),d=new Headers(u.headers);return d.set(`cache-control`,a.pathname.endsWith(`/index.html`)?`no-store`:`public, max-age=31536000, immutable`),new Response(e.method===`HEAD`?null:u.body,{headers:d,status:u.status,statusText:u.statusText})}function l(e,t,n){let r=u(),i=t,a=r.configuration.filter(e=>e.requiredIn.includes(n)).map(e=>({description:e.description,kind:e.kind,name:e.name,status:f(i[e.name])?`configured`:`missing`})),o=[],s=r.deployUrls[n];return s?o.push({href:s,id:`application`,label:`Application`}):o.push({href:new URL(`/`,e.url).href,id:`application`,label:`Application`}),{environment:n,release:{applicationName:r.applicationName,applicationVersion:r.applicationVersion,cloudflareVersionId:t.CF_VERSION_METADATA?.id,cloudflareVersionTag:t.CF_VERSION_METADATA?.tag,cloudflareVersionTimestamp:t.CF_VERSION_METADATA?.timestamp,commit:r.commit,coreframeVersion:r.coreframeVersion,releaseName:t.POSTHOG_RELEASE},configuration:a,links:o}}function u(){return typeof __COREFRAME_DASHBOARD_BUILD__<`u`?__COREFRAME_DASHBOARD_BUILD__:{applicationName:`Coreframe application`,configuration:[],deployUrls:{}}}function d(e){return e===r||e.startsWith(`${r}/`)}function f(e){return typeof e==`string`?e.trim().length>0:e!=null}function p(e,t=200){return Response.json(e,{headers:{"cache-control":`no-store`},status:t})}function m(e){if(e?.startsWith(`Basic `))try{let t=Uint8Array.from(atob(e.slice(6)),e=>e.charCodeAt(0)),n=new TextDecoder().decode(t),r=n.indexOf(`:`);return r===-1||n.slice(0,r)!==`coreframe`?void 0:n.slice(r+1)}catch{return}}async function h(e,t){let n=new TextEncoder,[r,i]=await Promise.all([crypto.subtle.digest(`SHA-256`,n.encode(e)),crypto.subtle.digest(`SHA-256`,n.encode(t))]),a=new Uint8Array(r),o=new Uint8Array(i),s=0;for(let e=0;e<a.length;e+=1)s|=a[e]^o[e];return s===0}export{o as createWorkerHandler,s as handleDashboardRequest};
1
+ import{createDashboardPluginDispatcher as e}from"./api/dispatcher.js";import{getDashboardRequestId as t,isSameOriginDashboardMutation as n}from"./host-policy.js";const r=`/__dashboard`,i=`${r}/api`,a=new WeakMap;function o(n){let r=e(n.plugins,{getRequestId:t});return(e,t)=>{let n=new URL(e.url);return!d(n.pathname)||!t.DEPLOY_ENV?null:c(e,t,n,t.DEPLOY_ENV,r)}}function s(e,t,n){if(!d(new URL(e.url).pathname)||!t.DEPLOY_ENV)return null;let r=n.plugins,i=a.get(r);return i||(i=o(n),a.set(r,i)),i(e,t)}async function c(e,t,a,o,s){if(!t.DASHBOARD_PASSWORD)return new Response(`Dashboard unavailable`,{headers:{"cache-control":`no-store`},status:503});let c=m(e.headers.get(`authorization`));if(!c||!await h(c,t.DASHBOARD_PASSWORD))return new Response(`Authentication required`,{headers:{"cache-control":`no-store`,"www-authenticate":`Basic realm="Coreframe dashboard", charset="UTF-8"`},status:401});if(a.pathname.startsWith(`${i}/plugins/`))return n(e.method,e.headers.get(`origin`),a.origin)?s(e,l(e,t,o)):p({error:{code:`invalid_input`}},403);if(a.pathname===i||a.pathname.startsWith(`${i}/`))return p({error:`Not found`},404);if(a.pathname===r)return a.pathname=`${r}/`,Response.redirect(a,302);if(e.method!==`GET`&&e.method!==`HEAD`)return new Response(`Method not allowed`,{headers:{"cache-control":`no-store`},status:405});if(!t.ASSETS)return new Response(`Dashboard unavailable`,{headers:{"cache-control":`no-store`},status:503});(a.pathname===`${r}/`||!a.pathname.slice(13).includes(`.`))&&(a.pathname=`${r}/index.html`);let u=await t.ASSETS.fetch(new Request(a,e));if(a.pathname===`${r}/index.html`&&u.status===307){let n=u.headers.get(`location`),i=n?new URL(n,a):void 0;i?.origin===a.origin&&(i.pathname===r||i.pathname===`${r}/`)&&(await u.body?.cancel(),u=await t.ASSETS.fetch(new Request(i,e)))}let d=new Headers(u.headers);return d.set(`cache-control`,a.pathname.endsWith(`/index.html`)?`no-store`:`public, max-age=31536000, immutable`),new Response(e.method===`HEAD`?null:u.body,{headers:d,status:u.status,statusText:u.statusText})}function l(e,t,n){let r=u(),i=t,a=r.configuration.filter(e=>e.requiredIn.includes(n)).map(e=>({description:e.description,kind:e.kind,name:e.name,status:f(i[e.name])?`configured`:`missing`})),o=[],s=r.deployUrls[n];return s?o.push({href:s,id:`application`,label:`Application`}):o.push({href:new URL(`/`,e.url).href,id:`application`,label:`Application`}),{environment:n,release:{applicationName:r.applicationName,applicationVersion:r.applicationVersion,cloudflareVersionId:t.CF_VERSION_METADATA?.id,cloudflareVersionTag:t.CF_VERSION_METADATA?.tag,cloudflareVersionTimestamp:t.CF_VERSION_METADATA?.timestamp,commit:r.commit,coreframeVersion:r.coreframeVersion,releaseName:t.POSTHOG_RELEASE},configuration:a,links:o}}function u(){return typeof __COREFRAME_DASHBOARD_BUILD__<`u`?__COREFRAME_DASHBOARD_BUILD__:{applicationName:`Coreframe application`,configuration:[],deployUrls:{}}}function d(e){return e===r||e.startsWith(`${r}/`)}function f(e){return typeof e==`string`?e.trim().length>0:e!=null}function p(e,t=200){return Response.json(e,{headers:{"cache-control":`no-store`},status:t})}function m(e){if(e?.startsWith(`Basic `))try{let t=Uint8Array.from(atob(e.slice(6)),e=>e.charCodeAt(0)),n=new TextDecoder().decode(t),r=n.indexOf(`:`);return r===-1||n.slice(0,r)!==`coreframe`?void 0:n.slice(r+1)}catch{return}}async function h(e,t){let n=new TextEncoder,[r,i]=await Promise.all([crypto.subtle.digest(`SHA-256`,n.encode(e)),crypto.subtle.digest(`SHA-256`,n.encode(t))]),a=new Uint8Array(r),o=new Uint8Array(i),s=0;for(let e=0;e<a.length;e+=1)s|=a[e]^o[e];return s===0}export{o as createWorkerHandler,s as handleDashboardRequest};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coreframe/dashboard",
3
- "version": "0.3.24",
3
+ "version": "0.3.25",
4
4
  "description": "Reusable dashboard composition, shell, plugin, and authenticated runtime for Coreframe apps",
5
5
  "repository": {
6
6
  "type": "git",
@@ -99,6 +99,7 @@
99
99
  "@types/react": "19.2.18",
100
100
  "@types/react-dom": "19.2.4",
101
101
  "jsdom": "^29.1.1",
102
+ "miniflare": "4.20260710.0",
102
103
  "tsdown": "0.22.3",
103
104
  "typescript": "6.0.3",
104
105
  "vite": "^8.1.4",