@lunora/storage 1.0.0-alpha.52 → 1.0.0-alpha.53

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{createBucketStorage as o}from"./packem_shared/createBucketStorage-D9fBoaEi.mjs";import{createStorage as i,scopeKey as d}from"./packem_shared/createStorage-C5wU9cbC.mjs";import{buildPresignedUrl as g}from"./packem_shared/buildPresignedUrl-U55ktL8x.mjs";import{buildSignedUrl as p,verifySignedUrl as a}from"./packem_shared/buildSignedUrl-czz1xjLU.mjs";export{g as buildPresignedUrl,p as buildSignedUrl,o as createBucketStorage,i as createStorage,d as scopeKey,a as verifySignedUrl};
1
+ import{createBucketStorage as o}from"./packem_shared/createBucketStorage-AqIMq050.mjs";import{createStorage as i,scopeKey as d}from"./packem_shared/createStorage-C5wU9cbC.mjs";import{buildPresignedUrl as g}from"./packem_shared/buildPresignedUrl-U55ktL8x.mjs";import{buildSignedUrl as p,verifySignedUrl as a}from"./packem_shared/buildSignedUrl-czz1xjLU.mjs";export{g as buildPresignedUrl,p as buildSignedUrl,o as createBucketStorage,i as createStorage,d as scopeKey,a as verifySignedUrl};
@@ -0,0 +1 @@
1
+ import{Rest as u,Multipart as l,Tus as h}from"@visulima/storage/handler/http/fetch";import{AwsLightStorage as p}from"@visulima/storage/provider/aws-light";const m=100*1024*1024,f="1.0.0",d=(e,t,r)=>{const o={"content-type":"application/json"};return e==="tus"&&(o["Tus-Resumable"]=f),Response.json({error:r},{headers:o,status:t})},i=e=>d(e,403,{code:"FORBIDDEN",message:"Upload denied by authorization policy",name:"ForbiddenError"}),g=e=>d(e,413,{code:"REQUEST_ENTITY_TOO_LARGE",message:"Upload exceeds the configured maxFileSize",name:"RequestEntityTooLargeError"}),S=(e,t)=>{if(t==="multipart")return;let r;for(const o of["Upload-Length","X-Total-Size","Content-Length"]){const c=e.headers.get(o);if(c===null)continue;const n=Number(c);Number.isFinite(n)&&(r===void 0||n>r)&&(r=n)}return r},R=(e,t)=>e==="chunked-rest"?new u(t):e==="multipart"?new l(t):new h(t),E=e=>{const t=e.protocol??"tus",r=e.maxFileSize??m,o={maxFileSize:r,storage:e.storage},c=R(t,o),{authorize:n}=e;return n===void 0&&!e.silent&&!e.public&&console.warn("@lunora/storage: createUploadHandler() has no `authorize` — this mounts an unauthenticated, unbounded-write endpoint. Pass an RLS `authorize` gate, or set `public: true` (or `silent: true`) to confirm this bucket is intentionally open."),{fetch:async a=>{const s=S(a,t);if(s!==void 0&&s>r)return g(t);if(n!==void 0)try{if(await n({method:a.method,protocol:t,request:a,url:new URL(a.url)})!==!0)return i(t)}catch{return i(t)}return c.fetch(a)},protocol:t}},b=e=>new p({accessKeyId:e.accessKeyId,bucket:e.bucket,endpoint:e.endpoint??`https://${e.accountId}.r2.cloudflarestorage.com`,path:e.path??"/",region:"auto",secretAccessKey:e.secretAccessKey,...e.partSize===void 0?{}:{partSize:e.partSize}});export{m as DEFAULT_MAX_UPLOAD_BYTES,b as createR2UploadStorage,E as createUploadHandler};
@@ -0,0 +1 @@
1
+ import{LunoraError as n}from"@lunora/errors";const g=(e,a={})=>{const o=Object.keys(e),[u]=o;if(u===void 0)throw new n("INTERNAL","@lunora/storage: createBucketStorage requires at least one bucket");if(a.default!==void 0&&!Object.hasOwn(e,a.default))throw new n("INTERNAL",`@lunora/storage: default bucket "${a.default}" is not in the bucket map (have: ${o.join(", ")})`);const t=a.default??(e.default?"default":u),c=e[t];if(c===void 0)throw new n("INTERNAL",`@lunora/storage: default bucket "${t}" is not in the bucket map (have: ${o.join(", ")})`);const s=[...new Set([t,...o])],d=r=>{const f=Object.hasOwn(e,r)?e[r]:void 0,i=r===t?c:f;if(!i)throw new n("INTERNAL",`@lunora/storage: no bucket registered for "${r}". Known buckets: ${s.join(", ")}`);return{...i,bucket:l=>d(l),bucketName:r}};return d(t)};export{g as createBucketStorage};
package/dist/upload.d.mts CHANGED
@@ -43,8 +43,9 @@ interface CreateUploadHandlerOptions {
43
43
  /**
44
44
  * Maximum accepted file size in bytes. Forwarded to the multipart parser
45
45
  * (protocol `"multipart"`) and, for `"tus"`/`"chunked-rest"`, enforced by
46
- * this handler itself against the request's declared size (`Upload-Length`
47
- * / `Content-Length`) — see {@link declaredUploadSize}. Defaults to
46
+ * this handler itself against the largest size the request declares across
47
+ * `Upload-Length` (TUS), `X-Total-Size` (chunked REST) and `Content-Length`
48
+ * — see {@link declaredUploadSize}. Defaults to
48
49
  * {@link DEFAULT_MAX_UPLOAD_BYTES} (100 MiB) — pass this to raise or lower
49
50
  * the ceiling; there is no unbounded option.
50
51
  */
package/dist/upload.d.ts CHANGED
@@ -43,8 +43,9 @@ interface CreateUploadHandlerOptions {
43
43
  /**
44
44
  * Maximum accepted file size in bytes. Forwarded to the multipart parser
45
45
  * (protocol `"multipart"`) and, for `"tus"`/`"chunked-rest"`, enforced by
46
- * this handler itself against the request's declared size (`Upload-Length`
47
- * / `Content-Length`) — see {@link declaredUploadSize}. Defaults to
46
+ * this handler itself against the largest size the request declares across
47
+ * `Upload-Length` (TUS), `X-Total-Size` (chunked REST) and `Content-Length`
48
+ * — see {@link declaredUploadSize}. Defaults to
48
49
  * {@link DEFAULT_MAX_UPLOAD_BYTES} (100 MiB) — pass this to raise or lower
49
50
  * the ceiling; there is no unbounded option.
50
51
  */
package/dist/upload.mjs CHANGED
@@ -1 +1 @@
1
- import{DEFAULT_MAX_UPLOAD_BYTES as r,createR2UploadStorage as o,createUploadHandler as t}from"./packem_shared/DEFAULT_MAX_UPLOAD_BYTES-Dhj02auN.mjs";export{r as DEFAULT_MAX_UPLOAD_BYTES,o as createR2UploadStorage,t as createUploadHandler};
1
+ import{DEFAULT_MAX_UPLOAD_BYTES as r,createR2UploadStorage as o,createUploadHandler as t}from"./packem_shared/DEFAULT_MAX_UPLOAD_BYTES-l43E2slu.mjs";export{r as DEFAULT_MAX_UPLOAD_BYTES,o as createR2UploadStorage,t as createUploadHandler};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/storage",
3
- "version": "1.0.0-alpha.52",
3
+ "version": "1.0.0-alpha.53",
4
4
  "description": "R2-backed storage for Lunora: typed buckets and signed URLs",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -50,7 +50,7 @@
50
50
  "access": "public"
51
51
  },
52
52
  "dependencies": {
53
- "@lunora/errors": "1.0.0-alpha.32",
53
+ "@lunora/errors": "1.0.0-alpha.33",
54
54
  "@lunora/platform": "1.0.0-alpha.27",
55
55
  "@visulima/storage": "2.0.0",
56
56
  "aws4fetch": "1.0.20"
@@ -1 +0,0 @@
1
- import{Rest as u,Multipart as l,Tus as h}from"@visulima/storage/handler/http/fetch";import{AwsLightStorage as p}from"@visulima/storage/provider/aws-light";const m=100*1024*1024,g="1.0.0",i=(e,t,r)=>{const n={"content-type":"application/json"};return e==="tus"&&(n["Tus-Resumable"]=g),Response.json({error:r},{headers:n,status:t})},s=e=>i(e,403,{code:"FORBIDDEN",message:"Upload denied by authorization policy",name:"ForbiddenError"}),f=e=>i(e,413,{code:"REQUEST_ENTITY_TOO_LARGE",message:"Upload exceeds the configured maxFileSize",name:"RequestEntityTooLargeError"}),S=(e,t)=>{if(t==="multipart")return;const r=e.headers.get("Upload-Length")??e.headers.get("Content-Length");if(r===null)return;const n=Number(r);return Number.isFinite(n)?n:void 0},R=(e,t)=>e==="chunked-rest"?new u(t):e==="multipart"?new l(t):new h(t),E=e=>{const t=e.protocol??"tus",r=e.maxFileSize??m,n={maxFileSize:r,storage:e.storage},d=R(t,n),{authorize:o}=e;return o===void 0&&!e.silent&&!e.public&&console.warn("@lunora/storage: createUploadHandler() has no `authorize` — this mounts an unauthenticated, unbounded-write endpoint. Pass an RLS `authorize` gate, or set `public: true` (or `silent: true`) to confirm this bucket is intentionally open."),{fetch:async a=>{const c=S(a,t);if(c!==void 0&&c>r)return f(t);if(o!==void 0)try{if(await o({method:a.method,protocol:t,request:a,url:new URL(a.url)})!==!0)return s(t)}catch{return s(t)}return d.fetch(a)},protocol:t}},b=e=>new p({accessKeyId:e.accessKeyId,bucket:e.bucket,endpoint:e.endpoint??`https://${e.accountId}.r2.cloudflarestorage.com`,path:e.path??"/",region:"auto",secretAccessKey:e.secretAccessKey,...e.partSize===void 0?{}:{partSize:e.partSize}});export{m as DEFAULT_MAX_UPLOAD_BYTES,b as createR2UploadStorage,E as createUploadHandler};
@@ -1 +0,0 @@
1
- import{LunoraError as n}from"@lunora/errors";const g=(e,r={})=>{const a=Object.keys(e),[u]=a;if(u===void 0)throw new n("INTERNAL","@lunora/storage: createBucketStorage requires at least one bucket");if(r.default!==void 0&&!e[r.default])throw new n("INTERNAL",`@lunora/storage: default bucket "${r.default}" is not in the bucket map (have: ${a.join(", ")})`);const t=r.default??(e.default?"default":u),c=e[t];if(c===void 0)throw new n("INTERNAL",`@lunora/storage: default bucket "${t}" is not in the bucket map (have: ${a.join(", ")})`);const i=[...new Set([t,...a])],d=o=>{const f=o===t?c:e[o];if(!f)throw new n("INTERNAL",`@lunora/storage: no bucket registered for "${o}". Known buckets: ${i.join(", ")}`);return{...f,bucket:l=>d(l),bucketName:o}};return d(t)};export{g as createBucketStorage};