This is a demo for building endpoints that can sign and verify a url request using HMAC and SHA-256 Algorithms. Powered by Worktop's Router and the cryptographic interface Web Crypto.
Built using this example on Cloudflare Docs.
Takes in a url parameter and returns a signed version of the URL, ready to be verified by the /verify
end point.
Expiry time is configurable.
Takes in a signed url parameter and verifies its signature and expiry date.
- Make sure you have
wrangler
andnvm
installed. - Run
nvm install
to install the correct Nodejs version. - Create a
.env
file and addSECRET_KEY=YOUR SECRET KEY
- Run
npm run dev
- Make sure you have
wrangler
andnvm
installed. - Run
nvm install
to install the correct Nodejs version. - Go to the Workers dashboard, create a new project called
sign-verify-url
- Run
wrangler secret put SECRET_KEY
and type in your secret key - Run
wrangler publish