@hot-updater/cloudflare 0.36.1 → 0.36.2
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/worker/index.cjs +1 -1
- package/dist/worker/index.mjs +2 -2
- package/package.json +7 -7
- package/src/r2Storage.spec.ts +45 -0
- package/src/r2WorkerStorage.spec.ts +23 -0
- package/src/r2WorkerStorage.ts +2 -1
- package/worker/dist/README.md +1 -1
- package/worker/dist/index.js +2489 -2480
- package/worker/dist/index.js.map +4 -4
- package/worker/src/index.integration.spec.ts +19 -0
- package/worker/src/index.ts +3 -2
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
type GetBundlesArgs,
|
|
5
5
|
NIL_UUID,
|
|
6
6
|
} from "@hot-updater/core";
|
|
7
|
+
import { signToken } from "@hot-updater/js";
|
|
7
8
|
import {
|
|
8
9
|
setupBsdiffManifestUpdateInfoTestSuite,
|
|
9
10
|
setupGetUpdateInfoTestSuite,
|
|
@@ -337,6 +338,24 @@ describe.sequential("cloudflare worker runtime acceptance", () => {
|
|
|
337
338
|
});
|
|
338
339
|
});
|
|
339
340
|
|
|
341
|
+
it("serves signed R2 URLs for percent-encoded object keys", async () => {
|
|
342
|
+
const encodedKey = "bundles/assets/bootsplash/logo-ios%402x.png";
|
|
343
|
+
await putR2Object(
|
|
344
|
+
"assets/bootsplash/logo-ios@2x.png",
|
|
345
|
+
"asset",
|
|
346
|
+
"text/plain",
|
|
347
|
+
);
|
|
348
|
+
const token = await signToken(encodedKey, env.JWT_SECRET);
|
|
349
|
+
|
|
350
|
+
const response = await worker.fetch(
|
|
351
|
+
new Request(`${PUBLIC_BASE_URL}/${encodedKey}?token=${token}`),
|
|
352
|
+
env,
|
|
353
|
+
);
|
|
354
|
+
|
|
355
|
+
expect(response.status).toBe(200);
|
|
356
|
+
await expect(response.text()).resolves.toBe("asset");
|
|
357
|
+
});
|
|
358
|
+
|
|
340
359
|
it("does not support the legacy exact path", async () => {
|
|
341
360
|
const response = await worker.fetch(
|
|
342
361
|
new Request(`${PUBLIC_BASE_URL}${HOT_UPDATER_BASE_PATH}`),
|
package/worker/src/index.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { decodeStorageObjectKey } from "@hot-updater/plugin-core";
|
|
1
2
|
import { createHotUpdater } from "@hot-updater/server";
|
|
2
3
|
import { Hono } from "hono";
|
|
3
4
|
|
|
@@ -61,11 +62,11 @@ app.mount(
|
|
|
61
62
|
|
|
62
63
|
app.get("*", async (c) => {
|
|
63
64
|
const result = await verifyJwtSignedUrl({
|
|
64
|
-
path: c.req.
|
|
65
|
+
path: new URL(c.req.url).pathname,
|
|
65
66
|
token: c.req.query("token"),
|
|
66
67
|
jwtSecret: c.env.JWT_SECRET,
|
|
67
68
|
handler: async (storageUri) => {
|
|
68
|
-
const [, ...key] = storageUri.split("/");
|
|
69
|
+
const [, ...key] = decodeStorageObjectKey(storageUri).split("/");
|
|
69
70
|
const object = await c.env.BUCKET.get(key.join("/"));
|
|
70
71
|
if (!object) {
|
|
71
72
|
return null;
|