eptaadmin-sdk 0.1.6 → 0.1.10

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/README.md CHANGED
@@ -76,11 +76,11 @@ If your project needs row-aligned records, build them yourself from the columns
76
76
 
77
77
  ## Image values
78
78
 
79
- A column of type "image" stores each value as a URL. The SDK automatically rewrites these to absolute, API-key-authenticated URLs (`{baseUrl}/api/v1/workspaces/{slug}/uploads/{file}`) before returning them, so they're directly usable outside a browser session you never see or depend on the internal browser-app route these are stored against:
79
+ A column of type "image" stores each value as a URL. The server rewrites these to absolute, **signed** URLs before returning them (`{baseUrl}/api/v1/workspaces/{slug}/uploads/{file}?sig=...`) safe to drop straight into an `<img>`/`<video>` src, since the signature (not your personal API key) is what authorizes the request. A leaked link only ever exposes that one file, never your account's broader read access — but unlike a short-lived token, it doesn't expire on its own (revoking it means rotating the server's signing secret, which invalidates every signed link at once):
80
80
 
81
81
  ```js
82
82
  const avatars = await client.getValue("acme/clients/avatar");
83
- // ["https://your-eptaadmin-instance.example.com/api/v1/workspaces/acme/uploads/6f2dff985af5d290.png"]
83
+ // ["https://your-eptaadmin-instance.example.com/api/v1/workspaces/acme/uploads/6f2dff985af5d290.png?sig=..."]
84
84
  ```
85
85
 
86
86
  ## Build-time prefetch (for static/SPA builds)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eptaadmin-sdk",
3
- "version": "0.1.6",
3
+ "version": "0.1.10",
4
4
  "description": "Client SDK for reading your EptaAdmin workspace data from your own project.",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
package/src/index.js CHANGED
@@ -11,20 +11,14 @@ export class EptaAdminError extends Error {
11
11
  }
12
12
  }
13
13
 
14
- // Image column values are stored as the same URL the browser UI uses
15
- // (/workspaces/{slug}/uploads/{file}), which only accepts a session
16
- // cookie useless to an external caller like this SDK, which has none.
17
- // Rewrite matching values to the API-key-authenticated equivalent instead
18
- // of just prefixing baseUrl onto the internal route, so callers get a
19
- // working absolute URL without depending on (or seeing) that internal
20
- // browser-route shape.
21
- const uploadUrlPattern = /^\/workspaces\/([^/]+)\/uploads\/(.+)$/;
22
-
14
+ // Image column values arrive from the API already rewritten server-side
15
+ // into a self-contained, signed public path (see upload_signing.go) — a
16
+ // personal API key is never embedded in it, so it stays safe to drop
17
+ // straight into an <img>/<video> src, unlike the account's actual API key.
18
+ // This just needs to turn that relative path into an absolute URL.
23
19
  function resolveImageURL(value, baseUrl) {
24
- if (typeof value !== "string") return value;
25
- const match = value.match(uploadUrlPattern);
26
- if (!match) return value;
27
- return `${baseUrl}/api/v1/workspaces/${match[1]}/uploads/${match[2]}`;
20
+ if (typeof value !== "string" || !value.startsWith("/")) return value;
21
+ return baseUrl + value;
28
22
  }
29
23
 
30
24
  function resolveImageURLs(value, baseUrl) {