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 +2 -2
- package/package.json +1 -1
- package/src/index.js +7 -13
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
|
|
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
package/src/index.js
CHANGED
|
@@ -11,20 +11,14 @@ export class EptaAdminError extends Error {
|
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
// Image column values
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
//
|
|
18
|
-
//
|
|
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
|
-
|
|
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) {
|