Skip to content

Commit 5c38be7

Browse files
agviegasclaude
andauthored
feat(client): add getHiddenFileSignedUrl for ranged streaming (#22)
* feat(client): add getHiddenFileSignedUrl for ranged streaming Adds EngineServicesClient.getHiddenFileSignedUrl(hiddenId, expiresIn?), which returns a short-lived signed URL ({ url, expiresAt }) for a hidden file. This lets the browser fetch large hidden files directly with native HTTP Range requests (e.g. streaming a point cloud's octree.bin) instead of downloading the whole object. Re-call to refresh the URL when it nears expiry. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * chore(release): @thatopen/services 0.3.6 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * fix: sync yarn.lock with the three >=0.182.0 range package.json declares three (dep + peer) as >=0.182.0, but the committed lockfile was keyed three@^0.182.0 at 0.182.0 — a pre-existing mismatch that makes `yarn install --frozen-lockfile` fail on CI. Regenerates the lockfile so the key matches and three resolves to 0.185.0 (latest satisfying the range). three is a peer dep, so this only affects the repo's own build/test, not consumers. tsc stays green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 7551d28 commit 5c38be7

4 files changed

Lines changed: 36 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# thatopen-services
22

3+
## 0.3.6
4+
5+
### Patch Changes
6+
7+
- Add `getHiddenFileSignedUrl(hiddenId, expiresIn?)` to the client — returns a short-lived signed URL so large hidden files (e.g. a point cloud's `octree.bin`) can be fetched directly with native HTTP `Range` requests instead of downloading the whole object.
8+
39
## 0.2.0
410

511
### Minor Changes

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"access": "public"
1616
},
1717
"private": false,
18-
"version": "0.3.5",
18+
"version": "0.3.6",
1919
"main": "dist/index.cjs.js",
2020
"module": "dist/index.es.js",
2121
"types": "dist/index.d.ts",

src/core/client.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,6 +1257,31 @@ export class EngineServicesClient {
12571257
);
12581258
}
12591259

1260+
/**
1261+
* Mints a short-lived presigned URL for a hidden file so the browser can
1262+
* stream it directly from storage with native HTTP `Range` requests (e.g. a
1263+
* point-cloud `octree.bin`), instead of proxying the whole object through the
1264+
* API. Re-call to re-mint when the URL nears/passes `expiresAt`; coalesce
1265+
* concurrent re-mints into a single in-flight call.
1266+
*
1267+
* The storage bucket's CORS must allow the `Range` request header and expose
1268+
* `Content-Range`, `Accept-Ranges` and `Content-Length` for the ranged fetch
1269+
* to succeed cross-origin.
1270+
*
1271+
* @param hiddenId - The hidden file's unique identifier.
1272+
* @param expiresIn - Desired URL lifetime in seconds (60–3600). Defaults to
1273+
* 900 (15 min) server-side; values are clamped to that range.
1274+
* @returns `{ url, expiresAt }` — `url` is the presigned GET URL, `expiresAt`
1275+
* an ISO timestamp when it stops working.
1276+
*/
1277+
async getHiddenFileSignedUrl(hiddenId: string, expiresIn?: number) {
1278+
return await this.#requestApi<{ url: string; expiresAt: string }>(
1279+
'GET',
1280+
`${ITEM_PATH}/${HIDDEN_PATH}/${hiddenId}/signed-url`,
1281+
{ ...(expiresIn != null && { query: { expiresIn } }) },
1282+
);
1283+
}
1284+
12601285
/**
12611286
* Lists all hidden files attached to a parent item.
12621287
* @param parentFileId - The parent item's unique identifier.

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3026,10 +3026,10 @@ three-mesh-bvh@0.9.9:
30263026
resolved "https://registry.yarnpkg.com/three-mesh-bvh/-/three-mesh-bvh-0.9.9.tgz#273be4a3d4a4a287e6be2d947237e47657f84183"
30273027
integrity sha512-FJKitcjvbALmeQRK+Sc+nLGorCpkrZBrbgJZFzhdyWboak37DZikn46hvQkNqSbJPm227ahYmS6k3N/GXaAyXw==
30283028

3029-
three@^0.182.0:
3030-
version "0.182.0"
3031-
resolved "https://registry.npmjs.org/three/-/three-0.182.0.tgz"
3032-
integrity sha512-GbHabT+Irv+ihI1/f5kIIsZ+Ef9Sl5A1Y7imvS5RQjWgtTPfPnZ43JmlYI7NtCRDK9zir20lQpfg8/9Yd02OvQ==
3029+
three@>=0.182.0:
3030+
version "0.185.0"
3031+
resolved "https://registry.yarnpkg.com/three/-/three-0.185.0.tgz#1b60dc42a042712a79961b2a654617fd6bb2503b"
3032+
integrity sha512-+yRrcRO2iZa8uzvNNl0d7cL4huhgKgBvVJ0njcTe8xFqZ6DMAFZdCKDP91SEAuj25bNAj7k1QQdf+srZywVK6w==
30333033

30343034
tinybench@^2.9.0:
30353035
version "2.9.0"

0 commit comments

Comments
 (0)