@edge-base/server 0.2.8 → 0.2.9
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/admin-build/_app/immutable/chunks/{Bt4AyT3o.js → 0M5txo3l.js} +3 -3
- package/admin-build/_app/immutable/chunks/{DPgR4-0v.js → 39YMyjjq.js} +1 -1
- package/admin-build/_app/immutable/chunks/{CKVjMXZi.js → B0zJ5_Wk.js} +1 -1
- package/admin-build/_app/immutable/chunks/{BMXWUTG-.js → BN-pHKcH.js} +1 -1
- package/admin-build/_app/immutable/chunks/{zl2AUKMP.js → BfhqI0W8.js} +1 -1
- package/admin-build/_app/immutable/chunks/{B9efkx2V.js → C5nMidnK.js} +1 -1
- package/admin-build/_app/immutable/chunks/{j4jxnAKj.js → CI1lKBjB.js} +1 -1
- package/admin-build/_app/immutable/chunks/{DYtrHeVQ.js → CPLcjNR9.js} +1 -1
- package/admin-build/_app/immutable/chunks/{CMYgGhZR.js → DBkor_jM.js} +1 -1
- package/admin-build/_app/immutable/chunks/{fPy6xmgG.js → DBniE7GN.js} +1 -1
- package/admin-build/_app/immutable/chunks/{DGAHkap7.js → DUhE3Ynq.js} +1 -1
- package/admin-build/_app/immutable/chunks/{Djnkhy-S.js → DZo4s3wn.js} +1 -1
- package/admin-build/_app/immutable/chunks/{CwyE59Yt.js → DllVADtt.js} +1 -1
- package/admin-build/_app/immutable/chunks/{DcVb45Ds.js → DncT8xH5.js} +1 -1
- package/admin-build/_app/immutable/chunks/{CTRjWhGs.js → YGUb3X-Q.js} +1 -1
- package/admin-build/_app/immutable/chunks/{D8aeTKry.js → _xa30BOD.js} +1 -1
- package/admin-build/_app/immutable/entry/{app.Cmz0WjMl.js → app.BW-Ac3jY.js} +2 -2
- package/admin-build/_app/immutable/entry/start.Bcf0SjPV.js +1 -0
- package/admin-build/_app/immutable/nodes/{0.y6D_QyUb.js → 0.CRSQPtos.js} +1 -1
- package/admin-build/_app/immutable/nodes/{1.CndRxhbH.js → 1.HmStNbZP.js} +1 -1
- package/admin-build/_app/immutable/nodes/{10.CdA5FmXy.js → 10.BVlz13nr.js} +1 -1
- package/admin-build/_app/immutable/nodes/{11.DG8SzMp_.js → 11.VwQdbWwH.js} +1 -1
- package/admin-build/_app/immutable/nodes/{12.CvmQqpFa.js → 12.BFAAgi1f.js} +1 -1
- package/admin-build/_app/immutable/nodes/{13.BbGNdswT.js → 13.DDdauC84.js} +1 -1
- package/admin-build/_app/immutable/nodes/{14.CZKsN7-O.js → 14.D_rXaafJ.js} +1 -1
- package/admin-build/_app/immutable/nodes/{15.A7-CYgkG.js → 15.rfFjjiZc.js} +1 -1
- package/admin-build/_app/immutable/nodes/{16.hgJT9H-x.js → 16.DDEpGJ4Z.js} +1 -1
- package/admin-build/_app/immutable/nodes/{17.DkWZbcN2.js → 17.ChQWNtRN.js} +1 -1
- package/admin-build/_app/immutable/nodes/{18.sX3Fb5gh.js → 18.Rir_JwlF.js} +1 -1
- package/admin-build/_app/immutable/nodes/{19.VAZUW-1K.js → 19.CF76nxk1.js} +1 -1
- package/admin-build/_app/immutable/nodes/{20.DkIKxacG.js → 20.JQer3KPM.js} +1 -1
- package/admin-build/_app/immutable/nodes/21.CzGYxjpu.js +1 -0
- package/admin-build/_app/immutable/nodes/{22.BDaHvtaw.js → 22.DUw7X6z_.js} +1 -1
- package/admin-build/_app/immutable/nodes/{23.BVRzw_pD.js → 23.DS3svA-a.js} +1 -1
- package/admin-build/_app/immutable/nodes/{24.CVhSJyG0.js → 24.BYOsQM6B.js} +1 -1
- package/admin-build/_app/immutable/nodes/{25.Bme-9bZn.js → 25.n0pyDBRv.js} +1 -1
- package/admin-build/_app/immutable/nodes/{26.Dsx7RIIs.js → 26.C-Oo8sYK.js} +1 -1
- package/admin-build/_app/immutable/nodes/{27.DMGQnzFM.js → 27.BfxbFNkk.js} +1 -1
- package/admin-build/_app/immutable/nodes/{28.GGwFmEhZ.js → 28.DyHSN1q7.js} +1 -1
- package/admin-build/_app/immutable/nodes/{29.Dnghr0nk.js → 29.CUAmZbCc.js} +1 -1
- package/admin-build/_app/immutable/nodes/{3.Cg7zZJP1.js → 3.KQm4VJJg.js} +1 -1
- package/admin-build/_app/immutable/nodes/{30.C0J24z3I.js → 30.CQdPre5F.js} +1 -1
- package/admin-build/_app/immutable/nodes/{31.MdxFI8v6.js → 31.BP6raetq.js} +1 -1
- package/admin-build/_app/immutable/nodes/{4.DCAOVzGE.js → 4.Glf2jJHB.js} +1 -1
- package/admin-build/_app/immutable/nodes/{5.DzUQ-cTc.js → 5.BdFtj_-X.js} +1 -1
- package/admin-build/_app/immutable/nodes/{6.CptBYTVj.js → 6.JfnwWq8s.js} +1 -1
- package/admin-build/_app/immutable/nodes/{7.DfeeQ0Rg.js → 7.C-rw9qDh.js} +1 -1
- package/admin-build/_app/immutable/nodes/{8.CIcvctW7.js → 8.CA7r1Sjs.js} +1 -1
- package/admin-build/_app/immutable/nodes/{9.QKrvq4RA.js → 9.B2jgJDkH.js} +1 -1
- package/admin-build/_app/version.json +1 -1
- package/admin-build/index.html +7 -7
- package/package.json +3 -3
- package/src/durable-objects/room-runtime-base.ts +78 -6
- package/admin-build/_app/immutable/entry/start.JE7dcbK1.js +0 -1
- package/admin-build/_app/immutable/nodes/21.DOjJlQKc.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../chunks/CWj6FrbW.js";import{o as U}from"../chunks/Bn2NtlTj.js";import{p as j,a as z,f as G,c as b,g as t,s as m,r as g,u as n,b as y,d as D,t as J}from"../chunks/BdTBlfLy.js";import{d as K,s as N,a as O}from"../chunks/DtZk82gG.js";import{a as Q,t as V,e as W,i as X}from"../chunks/
|
|
1
|
+
import"../chunks/CWj6FrbW.js";import{o as U}from"../chunks/Bn2NtlTj.js";import{p as j,a as z,f as G,c as b,g as t,s as m,r as g,u as n,b as y,d as D,t as J}from"../chunks/BdTBlfLy.js";import{d as K,s as N,a as O}from"../chunks/DtZk82gG.js";import{a as Q,t as V,e as W,i as X}from"../chunks/DncT8xH5.js";import{a as F,f as I}from"../chunks/DEELgv7K.js";import{d as Y,s as Z}from"../chunks/CjcrXziO.js";import{P as tt}from"../chunks/BkZCgsc3.js";import{a as et}from"../chunks/Q2nPFxS6.js";import{M as _,T as at}from"../chunks/YGUb3X-Q.js";import{D as rt,T as nt}from"../chunks/DBkor_jM.js";var st=I("<button> </button>"),ot=I('<div class="range-selector"></div>'),lt=I('<div class="analytics-grid"><!> <!> <!> <!></div> <div class="analytics-chart"><!></div> <div class="analytics-bottom"><!> <!></div>',1);function yt(w,A){j(A,!0);let s=D(!0),o=D(null),p=D("24h");const M=[{value:"1h",label:"1H"},{value:"6h",label:"6H"},{value:"24h",label:"24H"},{value:"7d",label:"7D"},{value:"30d",label:"30D"}],T=n(()=>()=>{switch(t(p)){case"1h":return"minute";case"6h":case"24h":return"hour";default:return"day"}});async function $(){try{const e=await Q.fetch(`data/analytics?range=${t(p)}&category=function&metric=overview&groupBy=${t(T)()}`);y(o,e,!0)}catch(e){V(Y(e,"Failed to load functions analytics."))}finally{y(s,!1)}}function k(e){y(p,e,!0),y(s,!0),$()}U(()=>{$();const e=setInterval($,3e4);return()=>clearInterval(e)});const H=n(()=>()=>{var c;if(!((c=t(o))!=null&&c.summary))return 0;const{totalRequests:e,totalErrors:a}=t(o).summary;return e>0?a/e*100:0}),B=n(()=>()=>{var e;return(((e=t(o))==null?void 0:e.timeSeries)||[]).map(a=>({timestamp:a.timestamp,value:a.requests??a.value??0}))}),C=n(()=>()=>{var e;return(((e=t(o))==null?void 0:e.breakdown)||[]).map(a=>({label:a.label||"other",value:a.count}))}),E=n(()=>()=>{var e;return(((e=t(o))==null?void 0:e.topItems)||[]).map(a=>({label:a.label,count:a.count,secondary:`${Math.round(a.avgLatency)}ms · ${a.errorRate.toFixed(1)}% 5xx`}))});tt(w,{title:"Functions Analytics",description:"Serverless function execution and performance metrics",get docsHref(){return et},actions:a=>{var c=ot();W(c,21,()=>M,X,(f,d)=>{var l=st();let v;var h=b(l,!0);g(l),J(()=>{v=Z(l,1,"range-btn",null,v,{"range-btn--active":t(p)===t(d).value}),N(h,t(d).label)}),O("click",l,()=>k(t(d).value)),F(f,l)}),g(c),F(a,c)},children:(a,c)=>{var f=lt(),d=G(f),l=b(d);{let r=n(()=>{var i,u;return((u=(i=t(o))==null?void 0:i.summary)==null?void 0:u.totalRequests)??0});_(l,{label:"Invocations",get value(){return t(r)},get loading(){return t(s)}})}var v=m(l,2);{let r=n(()=>{var i,u;return((u=(i=t(o))==null?void 0:i.summary)==null?void 0:u.uniqueUsers)??0});_(v,{label:"Unique Users",get value(){return t(r)},get loading(){return t(s)}})}var h=m(v,2);{let r=n(()=>t(H)().toFixed(1));_(h,{label:"5xx Rate",get value(){return t(r)},unit:"%",get loading(){return t(s)}})}var L=m(h,2);{let r=n(()=>{var i,u;return Math.round(((u=(i=t(o))==null?void 0:i.summary)==null?void 0:u.avgLatency)??0)});_(L,{label:"Avg Duration",get value(){return t(r)},unit:"ms",get loading(){return t(s)}})}g(d);var x=m(d,2),P=b(x);{let r=n(()=>t(B)());at(P,{get data(){return t(r)},type:"bar",height:240,label:"Function invocations over time",get loading(){return t(s)},color:"#dc2626"})}g(x);var R=m(x,2),q=b(R);{let r=n(()=>t(C)());rt(q,{get items(){return t(r)},title:"Functions by invocation count",get loading(){return t(s)}})}var S=m(q,2);{let r=n(()=>t(E)());nt(S,{get items(){return t(r)},title:"Top Functions",get loading(){return t(s)}})}g(R),F(a,f)}}),z()}K(["click"]);export{yt as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"
|
|
1
|
+
{"version":"1775689125712"}
|
package/admin-build/index.html
CHANGED
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
6
|
<title>EdgeBase Admin</title>
|
|
7
7
|
<link rel="icon" href="/admin/favicon.svg" type="image/svg+xml" />
|
|
8
|
-
<link href="/admin/_app/immutable/entry/start.
|
|
9
|
-
<link href="/admin/_app/immutable/chunks/
|
|
8
|
+
<link href="/admin/_app/immutable/entry/start.Bcf0SjPV.js" rel="modulepreload">
|
|
9
|
+
<link href="/admin/_app/immutable/chunks/B0zJ5_Wk.js" rel="modulepreload">
|
|
10
10
|
<link href="/admin/_app/immutable/chunks/BdTBlfLy.js" rel="modulepreload">
|
|
11
11
|
<link href="/admin/_app/immutable/chunks/Bn2NtlTj.js" rel="modulepreload">
|
|
12
|
-
<link href="/admin/_app/immutable/chunks/
|
|
13
|
-
<link href="/admin/_app/immutable/entry/app.
|
|
12
|
+
<link href="/admin/_app/immutable/chunks/DZo4s3wn.js" rel="modulepreload">
|
|
13
|
+
<link href="/admin/_app/immutable/entry/app.BW-Ac3jY.js" rel="modulepreload">
|
|
14
14
|
<link href="/admin/_app/immutable/chunks/B2bEC_Hm.js" rel="modulepreload">
|
|
15
15
|
<link href="/admin/_app/immutable/chunks/Bb0e0sAP.js" rel="modulepreload">
|
|
16
16
|
<link href="/admin/_app/immutable/chunks/DtZk82gG.js" rel="modulepreload">
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
<div style="display: contents">
|
|
27
27
|
<script>
|
|
28
28
|
{
|
|
29
|
-
|
|
29
|
+
__sveltekit_1iz3xys = {
|
|
30
30
|
base: "/admin",
|
|
31
31
|
assets: "/admin"
|
|
32
32
|
};
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
const element = document.currentScript.parentElement;
|
|
35
35
|
|
|
36
36
|
Promise.all([
|
|
37
|
-
import("/admin/_app/immutable/entry/start.
|
|
38
|
-
import("/admin/_app/immutable/entry/app.
|
|
37
|
+
import("/admin/_app/immutable/entry/start.Bcf0SjPV.js"),
|
|
38
|
+
import("/admin/_app/immutable/entry/app.BW-Ac3jY.js")
|
|
39
39
|
]).then(([kit, app]) => {
|
|
40
40
|
kit.start(app, element);
|
|
41
41
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@edge-base/server",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.9",
|
|
4
4
|
"description": "EdgeBase runtime assets consumed by the EdgeBase CLI",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"jose": "^6.0.0",
|
|
35
35
|
"pg": "^8.16.3",
|
|
36
36
|
"zod": "^4.3.6",
|
|
37
|
-
"@edge-base/core": "0.2.
|
|
38
|
-
"@edge-base/shared": "0.2.
|
|
37
|
+
"@edge-base/core": "0.2.9",
|
|
38
|
+
"@edge-base/shared": "0.2.9"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@cloudflare/vitest-pool-workers": "^0.8.71",
|
|
@@ -52,6 +52,33 @@ export interface RoomWSMeta {
|
|
|
52
52
|
lastSeenAt?: number;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
function normalizeAnonymousRoomAuthPayload(value: unknown): SharedAuthContext | null {
|
|
56
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const typed = value as Record<string, unknown>;
|
|
61
|
+
if (typed.type !== 'anonymous' || typeof typed.subject !== 'string' || typed.subject.trim().length === 0) {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const subject = typed.subject.trim();
|
|
66
|
+
return {
|
|
67
|
+
id: subject,
|
|
68
|
+
role: typeof typed.role === 'string' && typed.role.trim().length > 0 ? typed.role.trim() : undefined,
|
|
69
|
+
email: typeof typed.email === 'string' && typed.email.trim().length > 0 ? typed.email.trim() : undefined,
|
|
70
|
+
isAnonymous: typed.isAnonymous !== false,
|
|
71
|
+
custom:
|
|
72
|
+
typed.custom && typeof typed.custom === 'object' && !Array.isArray(typed.custom)
|
|
73
|
+
? (typed.custom as Record<string, unknown>)
|
|
74
|
+
: undefined,
|
|
75
|
+
meta:
|
|
76
|
+
typed.meta && typeof typed.meta === 'object' && !Array.isArray(typed.meta)
|
|
77
|
+
? (typed.meta as Record<string, unknown>)
|
|
78
|
+
: undefined,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
55
82
|
interface PersistedRoomWSAttachment {
|
|
56
83
|
version: 1;
|
|
57
84
|
meta: RoomWSMeta;
|
|
@@ -489,7 +516,12 @@ export class RoomRuntimeBaseDO extends DurableObject<RoomDOEnv> {
|
|
|
489
516
|
|
|
490
517
|
// Auth must be first
|
|
491
518
|
if (type === 'auth') {
|
|
492
|
-
await this.handleAuth(
|
|
519
|
+
await this.handleAuth(
|
|
520
|
+
ws,
|
|
521
|
+
meta,
|
|
522
|
+
typeof msg.token === 'string' ? msg.token : undefined,
|
|
523
|
+
msg.authPayload,
|
|
524
|
+
);
|
|
493
525
|
return;
|
|
494
526
|
}
|
|
495
527
|
|
|
@@ -765,15 +797,53 @@ export class RoomRuntimeBaseDO extends DurableObject<RoomDOEnv> {
|
|
|
765
797
|
|
|
766
798
|
// ─── Auth Handler ───
|
|
767
799
|
|
|
768
|
-
private async handleAuth(
|
|
800
|
+
private async handleAuth(
|
|
801
|
+
ws: WebSocket,
|
|
802
|
+
meta: RoomWSMeta,
|
|
803
|
+
token?: string,
|
|
804
|
+
authPayload?: unknown,
|
|
805
|
+
): Promise<void> {
|
|
769
806
|
const isReAuth = meta.authenticated;
|
|
770
807
|
|
|
771
|
-
|
|
808
|
+
const anonymousAuth = !token ? normalizeAnonymousRoomAuthPayload(authPayload) : null;
|
|
809
|
+
if (!token && !anonymousAuth) {
|
|
772
810
|
this.safeSend(ws, { type: 'error', code: 'AUTH_FAILED', message: 'Token required' });
|
|
773
811
|
ws.close(4002, 'Authentication failed');
|
|
774
812
|
return;
|
|
775
813
|
}
|
|
776
814
|
|
|
815
|
+
if (anonymousAuth) {
|
|
816
|
+
meta.authenticated = true;
|
|
817
|
+
meta.authStateLost = false;
|
|
818
|
+
meta.lastSeenAt = Date.now();
|
|
819
|
+
meta.userId = anonymousAuth.id;
|
|
820
|
+
meta.role = anonymousAuth.role;
|
|
821
|
+
meta.auth = anonymousAuth;
|
|
822
|
+
this.setWSMeta(ws, meta);
|
|
823
|
+
|
|
824
|
+
if (this.pendingAuth.delete(meta.connectionId)) {
|
|
825
|
+
this.syncEphemeralTimersToStorage();
|
|
826
|
+
this._scheduleNextAlarm();
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
if (!isReAuth && meta.userId) {
|
|
830
|
+
if (this.disconnectTimers.delete(meta.userId)) {
|
|
831
|
+
this.syncEphemeralTimersToStorage();
|
|
832
|
+
this._scheduleNextAlarm();
|
|
833
|
+
}
|
|
834
|
+
this.addPlayer(meta.connectionId, meta.userId);
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
this.safeSend(ws, {
|
|
838
|
+
type: isReAuth ? 'auth_refreshed' : 'auth_success',
|
|
839
|
+
userId: anonymousAuth.id,
|
|
840
|
+
connectionId: meta.connectionId,
|
|
841
|
+
});
|
|
842
|
+
this.syncRoomMonitoringSnapshot();
|
|
843
|
+
await this.recoverStateIfNeeded();
|
|
844
|
+
return;
|
|
845
|
+
}
|
|
846
|
+
|
|
777
847
|
const secret = this.env.JWT_USER_SECRET;
|
|
778
848
|
if (!secret) {
|
|
779
849
|
this.safeSend(ws, { type: 'error', code: 'SERVER_ERROR', message: 'JWT secret not configured' });
|
|
@@ -782,14 +852,15 @@ export class RoomRuntimeBaseDO extends DurableObject<RoomDOEnv> {
|
|
|
782
852
|
}
|
|
783
853
|
|
|
784
854
|
try {
|
|
855
|
+
const accessToken = token as string;
|
|
785
856
|
const headers = new Headers();
|
|
786
857
|
if (meta.ip) headers.set('CF-Connecting-IP', meta.ip);
|
|
787
858
|
if (meta.userAgent) headers.set('User-Agent', meta.userAgent);
|
|
788
|
-
headers.set('Authorization', `Bearer ${
|
|
859
|
+
headers.set('Authorization', `Bearer ${accessToken}`);
|
|
789
860
|
const { resolveAuthContextFromToken } = await import('../middleware/auth.js');
|
|
790
861
|
const auth = await resolveAuthContextFromToken(
|
|
791
862
|
this.env,
|
|
792
|
-
|
|
863
|
+
accessToken,
|
|
793
864
|
new Request('http://internal/api/room/auth', { headers }),
|
|
794
865
|
);
|
|
795
866
|
meta.authenticated = true;
|
|
@@ -1345,7 +1416,8 @@ export class RoomRuntimeBaseDO extends DurableObject<RoomDOEnv> {
|
|
|
1345
1416
|
userId: meta.userId!,
|
|
1346
1417
|
connectionId: meta.connectionId,
|
|
1347
1418
|
role: meta.role,
|
|
1348
|
-
|
|
1419
|
+
auth: this.buildAuthFromMeta(meta),
|
|
1420
|
+
} as RoomSender;
|
|
1349
1421
|
}
|
|
1350
1422
|
|
|
1351
1423
|
protected buildAuthFromMeta(meta: RoomWSMeta): SharedAuthContext {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as r}from"../chunks/CKVjMXZi.js";import{w as t}from"../chunks/Djnkhy-S.js";export{t as load_css,r as start};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{_ as m}from"../chunks/Bt4AyT3o.js";export{m as component};
|