@lunora/do 1.0.0-alpha.176 → 1.0.0-alpha.178
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/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{serveRelationFanout as a}from"./packem_shared/serveRelationFanout-DcSjzAZv.mjs";import{SESSION_DO_TTL_DEFAULT as t,SessionDO as c}from"./packem_shared/SESSION_DO_TTL_DEFAULT-
|
|
1
|
+
import{serveRelationFanout as a}from"./packem_shared/serveRelationFanout-DcSjzAZv.mjs";import{SESSION_DO_TTL_DEFAULT as t,SessionDO as c}from"./packem_shared/SESSION_DO_TTL_DEFAULT-DSvTwRjc.mjs";import{ROOT_DO_SIZE_WARN_BYTES as i,ROOT_SHARD_NAME as s,ShardDO as l}from"./packem_shared/ROOT_DO_SIZE_WARN_BYTES-DVYn-PSJ.mjs";import{SHARD_REGISTRY_DO_NAME as d,ShardRegistryDO as R}from"./packem_shared/SHARD_REGISTRY_DO_NAME-DvxEa7qM.mjs";import{createShardAlarms as h,createShardDirectory as D,createShardHost as O,createShardKvStore as _,createShardPlatform as E,createSocketHost as m,createWorkerPlatform as u}from"@lunora/platform-cloudflare";import{REPROJECTION_MIGRATION_PREFIX as x,UNVOUCHABLE_DEP as I,applyCdcChanges as f,assertShapeShardable as b,backfillSearchIndexes as A,backfillVectorIndexes as M,buildReprojectionMigration as g,clearMemoryTables as k,countLegacyRows as N,createReadFootprint as y,createShardCtxDb as C,exportShardRows as H,importShardRows as L,isSourceDue as P,markUnvouchableReads as F,pullExternalSourceIncrementalTick as U,pullExternalSourceTick as j,reprojectionMigrationId as v,reprojectionTables as w,runDataMigration as B,runShardMigrations as G,subscriptionListDeltas as V}from"@lunora/shard-engine";export{x as REPROJECTION_MIGRATION_PREFIX,i as ROOT_DO_SIZE_WARN_BYTES,s as ROOT_SHARD_NAME,t as SESSION_DO_TTL_DEFAULT,d as SHARD_REGISTRY_DO_NAME,c as SessionDO,l as ShardDO,R as ShardRegistryDO,I as UNVOUCHABLE_DEP,f as applyCdcChanges,b as assertShapeShardable,A as backfillSearchIndexes,M as backfillVectorIndexes,g as buildReprojectionMigration,k as clearMemoryTables,N as countLegacyRows,y as createReadFootprint,h as createShardAlarms,C as createShardCtxDb,D as createShardDirectory,O as createShardHost,_ as createShardKvStore,E as createShardPlatform,m as createSocketHost,u as createWorkerPlatform,H as exportShardRows,L as importShardRows,P as isSourceDue,F as markUnvouchableReads,U as pullExternalSourceIncrementalTick,j as pullExternalSourceTick,v as reprojectionMigrationId,w as reprojectionTables,B as runDataMigration,G as runShardMigrations,a as serveRelationFanout,V as subscriptionListDeltas};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createShardKvStore as h,createShardAlarms as u}from"@lunora/platform-cloudflare";import{c as f}from"./constant-time-equal-BRh9yUCr.mjs";import{j as n}from"./json-response-0Bq2ky0N.mjs";const m=10080*60,S=2160*60*60,d=1440*60*1e3,E="x-lunora-session-do-secret",l="x-lunora-session-token",_=/^[\w-]+$/,g=32,N=256,T=256,v=(s,e)=>{const t=e.SESSION_DO_SECRET;if(typeof t!="string"||t.length===0)return!1;const r=s.headers.get(E);return typeof r!="string"||r.length===0?!1:f(t,r)},p=s=>{let e;if(s==null)e=m;else if(typeof s=="number")e=s;else return;if(!(!Number.isFinite(e)||!Number.isInteger(e)||e<=0||e>S))return e},k=s=>{if(typeof s=="string"&&!(s.length<g||s.length>N)&&_.test(s))return s};class A{state;env;kv;alarms;constructor(e,t){this.state=e,this.env=t,this.kv=h(e.storage),this.alarms=u(e.storage)}async fetch(e){const t=this.env??{};if(!v(e,t))return n({error:{code:"UNAUTHORIZED",message:"missing or invalid SessionDO secret"}},401);const r=new URL(e.url);return e.method==="POST"&&r.pathname==="/create"?this.handleCreate(e):e.method==="GET"&&r.pathname==="/get"?this.handleGet(e):e.method==="DELETE"&&r.pathname==="/revoke"?this.handleRevoke(e):n({error:{code:"NOT_FOUND",message:"no such session route"}},404)}async alarm(){if(typeof this.state.storage.list!="function")return;const e=Date.now(),t=await this.kv.list({prefix:"s:"}),r=[];let o=0;for(const[i,a]of t)a.expiresAt<e?r.push(i):o+=1;for(const i of r)await this.kv.delete(i);o>0&&await this.alarms.set(e+d)}async handleCreate(e){let t;try{t=await e.json()}catch{return n({error:"invalid_request"},400)}const r=k(t.token);if(r===void 0)return n({error:"invalid_request"},400);const{userId:o}=t;if(typeof o!="string"||o.length===0||o.length>T)return n({error:"invalid_request"},400);const i=p(t.ttlSeconds);if(i===void 0)return n({error:"invalid_request"},400);const a=Date.now(),c={createdAt:a,expiresAt:a+i*1e3,userId:o};return await this.kv.put(`s:${r}`,c),await this.armGcAlarm(),n({token:r,...c},201)}async armGcAlarm(){await this.alarms.get()===null&&await this.alarms.set(Date.now()+d)}async handleGet(e){const t=e.headers.get(l);if(!t)return n({error:{code:"INVALID_INPUT",message:"token required"}},400);const r=await this.kv.get(`s:${t}`);return r?r.expiresAt<Date.now()?(await this.kv.delete(`s:${t}`),n({error:{code:"EXPIRED",message:"session expired"}},404)):n({token:t,...r},200):n({error:{code:"NOT_FOUND",message:"session not found"}},404)}async handleRevoke(e){const t=e.headers.get(l);return t?(await this.kv.delete(`s:${t}`),n({ok:!0},200)):n({error:{code:"INVALID_INPUT",message:"token required"}},400)}}export{m as SESSION_DO_TTL_DEFAULT,
|
|
1
|
+
import{createShardKvStore as h,createShardAlarms as u}from"@lunora/platform-cloudflare";import{c as f}from"./constant-time-equal-BRh9yUCr.mjs";import{j as n}from"./json-response-0Bq2ky0N.mjs";const m=10080*60,S=2160*60*60,d=1440*60*1e3,E="x-lunora-session-do-secret",l="x-lunora-session-token",_=/^[\w-]+$/,g=32,N=256,T=256,v=(s,e)=>{const t=e.SESSION_DO_SECRET;if(typeof t!="string"||t.length===0)return!1;const r=s.headers.get(E);return typeof r!="string"||r.length===0?!1:f(t,r)},p=s=>{let e;if(s==null)e=m;else if(typeof s=="number")e=s;else return;if(!(!Number.isFinite(e)||!Number.isInteger(e)||e<=0||e>S))return e},k=s=>{if(typeof s=="string"&&!(s.length<g||s.length>N)&&_.test(s))return s};class A{state;env;kv;alarms;constructor(e,t){this.state=e,this.env=t,this.kv=h(e.storage),this.alarms=u(e.storage)}async fetch(e){const t=this.env??{};if(!v(e,t))return n({error:{code:"UNAUTHORIZED",message:"missing or invalid SessionDO secret"}},401);const r=new URL(e.url);return e.method==="POST"&&r.pathname==="/create"?this.handleCreate(e):e.method==="GET"&&r.pathname==="/get"?this.handleGet(e):e.method==="DELETE"&&r.pathname==="/revoke"?this.handleRevoke(e):n({error:{code:"NOT_FOUND",message:"no such session route"}},404)}async alarm(){if(typeof this.state.storage.list!="function")return;const e=Date.now(),t=await this.kv.list({prefix:"s:"}),r=[];let o=0;for(const[i,a]of t)a.expiresAt<e?r.push(i):o+=1;for(const i of r)await this.kv.delete(i);o>0&&await this.alarms.set(e+d)}async handleCreate(e){let t;try{t=await e.json()}catch{return n({error:"invalid_request"},400)}const r=k(t.token);if(r===void 0)return n({error:"invalid_request"},400);const{userId:o}=t;if(typeof o!="string"||o.length===0||o.length>T)return n({error:"invalid_request"},400);const i=p(t.ttlSeconds);if(i===void 0)return n({error:"invalid_request"},400);const a=Date.now(),c={createdAt:a,expiresAt:a+i*1e3,userId:o};return await this.kv.put(`s:${r}`,c),await this.armGcAlarm(),n({token:r,...c},201)}async armGcAlarm(){await this.alarms.get()===null&&await this.alarms.set(Date.now()+d)}async handleGet(e){const t=e.headers.get(l);if(!t)return n({error:{code:"INVALID_INPUT",message:"token required"}},400);const r=await this.kv.get(`s:${t}`);return r?r.expiresAt<Date.now()?(await this.kv.delete(`s:${t}`),n({error:{code:"EXPIRED",message:"session expired"}},404)):n({token:t,...r},200):n({error:{code:"NOT_FOUND",message:"session not found"}},404)}async handleRevoke(e){const t=e.headers.get(l);return t?(await this.kv.delete(`s:${t}`),n({ok:!0},200)):n({error:{code:"INVALID_INPUT",message:"token required"}},400)}}export{m as SESSION_DO_TTL_DEFAULT,A as SessionDO};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/do",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.178",
|
|
4
4
|
"description": "Lunora Durable Objects: ShardDO (SQLite, OCC, hibernated WebSocket subscriptions) and SessionDO",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -46,10 +46,10 @@
|
|
|
46
46
|
"access": "public"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@lunora/errors": "1.0.0-alpha.
|
|
50
|
-
"@lunora/observability": "1.0.0-alpha.
|
|
51
|
-
"@lunora/platform-cloudflare": "1.0.0-alpha.
|
|
52
|
-
"@lunora/shard-engine": "1.0.0-alpha.
|
|
49
|
+
"@lunora/errors": "1.0.0-alpha.47",
|
|
50
|
+
"@lunora/observability": "1.0.0-alpha.106",
|
|
51
|
+
"@lunora/platform-cloudflare": "1.0.0-alpha.61",
|
|
52
|
+
"@lunora/shard-engine": "1.0.0-alpha.97",
|
|
53
53
|
"drizzle-orm": "^0.45.2"
|
|
54
54
|
},
|
|
55
55
|
"engines": {
|