@bunbase-ae/js 3.3.0 → 3.3.1-next.420.2c6b78c

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/storage.ts +14 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bunbase-ae/js",
3
- "version": "3.3.0",
3
+ "version": "3.3.1-next.420.2c6b78c",
4
4
  "type": "module",
5
5
  "description": "TypeScript/JavaScript SDK for BunBase",
6
6
  "license": "UNLICENSED",
package/src/storage.ts CHANGED
@@ -201,6 +201,20 @@ export class StorageClient {
201
201
  return filename ? `${base}/${encodeURIComponent(filename)}` : base;
202
202
  }
203
203
 
204
+ // Get a time-limited signed download URL for a file id (issue #699).
205
+ // Works for private files: the returned URL carries a `?token=` (local
206
+ // provider) or is an S3 presigned-GET URL, so it can be used directly in an
207
+ // `<img src>` without an Authorization header. Gated server-side by the
208
+ // bucket's access_read policy plus the file's owner/tenant rules.
209
+ async signedUrl(id: string, options: { expiresIn?: number } = {}): Promise<string> {
210
+ const res = await this.http.request<{ id: string; key: string; url: string }>(
211
+ "POST",
212
+ "/api/v1/storage/sign",
213
+ { body: { id, method: "GET", expires_in: options.expiresIn } },
214
+ );
215
+ return res.url;
216
+ }
217
+
204
218
  async list(): Promise<FileRecord[]> {
205
219
  const res = await this.http.request<{ items: FileRecord[]; total: number }>(
206
220
  "GET",