mirror of
https://github.com/djdevin/recflare.git
synced 2026-09-08 14:41:28 -07:00
testing generic deploy
This commit is contained in:
+3
-3
@@ -1,6 +1,6 @@
|
||||
# img
|
||||
|
||||
Image-delivery worker served at `img.rec.djdevin.net`.
|
||||
Image-delivery worker served on the `img` subdomain.
|
||||
|
||||
Images are stored as objects in the **`rec-img` R2 bucket** and streamed back by
|
||||
key:
|
||||
@@ -12,8 +12,8 @@ key:
|
||||
conditional requests via `If-None-Match` (returns `304`). Missing keys `404`.
|
||||
- `GET /<key>?sig=p1` — same, but the response body is RSA-SHA1 signed and the
|
||||
signature returned in a `Content-Signature: key-id=KEY:RSA:p1.rec.net; data=<base64>`
|
||||
header (mirrors the C# `ImageController` / `Signatures`). The client uses this
|
||||
to verify image integrity. Signing buffers the whole object.
|
||||
header. The client uses this to verify image integrity. Signing buffers the
|
||||
whole object.
|
||||
|
||||
The bucket is bound in the Worker as `env.IMAGES` (see `wrangler.jsonc`).
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ function getSigningKey(env: Env): Promise<CryptoKey | null> {
|
||||
return signingKey
|
||||
}
|
||||
|
||||
/** RSA-SHA1 sign the bytes, base64-encoded — matches the C# `Signatures.Sign`. */
|
||||
/** RSA-SHA1 sign the bytes, base64-encoded. */
|
||||
async function signImage(env: Env, bytes: ArrayBuffer): Promise<string | null> {
|
||||
const key = await getSigningKey(env)
|
||||
if (!key) return null
|
||||
@@ -60,8 +60,8 @@ const app = new Hono<App>()
|
||||
// objects. Supports conditional requests via If-None-Match.
|
||||
//
|
||||
// When the client appends `?sig=p1`, the response body is RSA-SHA1 signed and
|
||||
// the signature returned in a `Content-Signature` header (mirrors the C#
|
||||
// ImageController). Signing requires the full body, so the object is buffered.
|
||||
// the signature returned in a `Content-Signature` header. Signing requires the
|
||||
// full body, so the object is buffered.
|
||||
.get('/:key{.+}', async (c) => {
|
||||
const key = c.req.param('key')
|
||||
if (key.includes('..')) return c.body(null, 400)
|
||||
|
||||
@@ -9,7 +9,7 @@ declare module 'cloudflare:test' {
|
||||
interface ProvidedEnv extends Env {}
|
||||
}
|
||||
|
||||
const ORIGIN = 'https://img.rec.djdevin.net'
|
||||
const ORIGIN = 'https://example.com'
|
||||
|
||||
// A tiny valid JPEG magic-number blob — enough to assert round-tripping.
|
||||
const IMAGE_BYTES = new Uint8Array([0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46])
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"compatibility_flags": ["nodejs_compat"],
|
||||
"routes": [
|
||||
{
|
||||
"pattern": "img.rec.djdevin.net",
|
||||
"pattern": "img.rec.example.com",
|
||||
"custom_domain": true
|
||||
}
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user