Skip to content

Refactor API routes and implement HMAC security - #43

Merged
ccocoa merged 1 commit into
mainfrom
feat-refactor-api-routes-and-hmac
Jun 28, 2026
Merged

Refactor API routes and implement HMAC security#43
ccocoa merged 1 commit into
mainfrom
feat-refactor-api-routes-and-hmac

Conversation

@ccocoa

@ccocoa ccocoa commented Jun 28, 2026

Copy link
Copy Markdown
Owner

This PR refactors the API routes from the legacy functions/ directory to Astro's src/pages/api/ structure. It also implements a secure HMAC-based flag generation and verification system using crypto.subtle.


Kokoa Dev Agent Report
Original Instruction:
Lakukan pembersihan dan penyempurnaan kode pada PR #42:

  1. Hapus direktori functions/ karena Astro API routes (src/pages/api/) sudah cukup.
  2. Implementasikan logika HMAC yang benar menggunakan crypto module (via crypto.subtle) untuk get-flag.js dan verify-flag.js.
    • Gunakan context.locals.runtime.env.FLAG_SECRET sebagai key.
    • Pastikan normalizedUsername (trim + toLowerCase) digunakan dalam proses hashing.
  3. Pastikan export const prerender = false; ada di kedua file tersebut.
    Target repo: ccocoa/ccocoa.github.io

- Remove legacy functions/ directory.
- Implement HMAC SHA-256 using crypto.subtle in get-flag.js and verify-flag.js.
- Use context.locals.runtime.env.FLAG_SECRET for security.
- Ensure normalizedUsername (trim + toLowerCase) is used.
- Set prerender = false for API routes.

Co-authored-by: thirapi <132630759+thirapi@users.noreply.github.com>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 28, 2026

Copy link
Copy Markdown

Deploying ccocoa-github-io with  Cloudflare Pages  Cloudflare Pages

Latest commit: 6164231
Status: ✅  Deploy successful!
Preview URL: https://5642cd2b.ccocoa-github-io.pages.dev
Branch Preview URL: https://feat-refactor-api-routes-and.ccocoa-github-io.pages.dev

View logs

@ccocoa
ccocoa merged commit e2b94f9 into main Jun 28, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant