critique 0.0.23 → 0.0.24
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/CHANGELOG.md +6 -0
- package/package.json +1 -1
- package/src/worker.ts +5 -5
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
package/src/worker.ts
CHANGED
|
@@ -35,8 +35,8 @@ app.post("/upload", async (c) => {
|
|
|
35
35
|
const hashArray = Array.from(new Uint8Array(hashBuffer))
|
|
36
36
|
const hashHex = hashArray.map(b => b.toString(16).padStart(2, "0")).join("")
|
|
37
37
|
|
|
38
|
-
// Use first
|
|
39
|
-
const id = hashHex.slice(0,
|
|
38
|
+
// Use first 32 chars of hash as ID (128 bits, secure against guessing)
|
|
39
|
+
const id = hashHex.slice(0, 32)
|
|
40
40
|
|
|
41
41
|
// Store in KV with 7 day expiration
|
|
42
42
|
await c.env.CRITIQUE_KV.put(id, body.html, {
|
|
@@ -57,7 +57,7 @@ app.post("/upload", async (c) => {
|
|
|
57
57
|
app.get("/view/:id", async (c) => {
|
|
58
58
|
const id = c.req.param("id")
|
|
59
59
|
|
|
60
|
-
if (!id || !/^[a-f0-9]{16}$/.test(id)) {
|
|
60
|
+
if (!id || !/^[a-f0-9]{16,32}$/.test(id)) {
|
|
61
61
|
return c.text("Invalid ID", 400)
|
|
62
62
|
}
|
|
63
63
|
|
|
@@ -90,7 +90,7 @@ app.get("/view/:id", async (c) => {
|
|
|
90
90
|
app.get("/raw/:id", async (c) => {
|
|
91
91
|
const id = c.req.param("id")
|
|
92
92
|
|
|
93
|
-
if (!id || !/^[a-f0-9]{16}$/.test(id)) {
|
|
93
|
+
if (!id || !/^[a-f0-9]{16,32}$/.test(id)) {
|
|
94
94
|
return c.json({ error: "Invalid ID" }, 400)
|
|
95
95
|
}
|
|
96
96
|
|
|
@@ -110,7 +110,7 @@ app.get("/raw/:id", async (c) => {
|
|
|
110
110
|
app.on("HEAD", "/view/:id", async (c) => {
|
|
111
111
|
const id = c.req.param("id")
|
|
112
112
|
|
|
113
|
-
if (!id || !/^[a-f0-9]{16}$/.test(id)) {
|
|
113
|
+
if (!id || !/^[a-f0-9]{16,32}$/.test(id)) {
|
|
114
114
|
return c.body(null, 400)
|
|
115
115
|
}
|
|
116
116
|
|