Closed bradyjoslin closed 4 years ago
Noticed PR https://github.com/cloudflare/template-registry/pull/46 is already open for adding web crypto examples after submitting this one. However, that appears to be for a new snippet instead of updating signed_request.js
. Nevertheless, if you don't believe it makes sense to have two examples showing how to sign/verify using web crypto and want to use the other one instead, I'd understand. Would recommend at minimum referring to the web crypto example from the comments for this existing snippet to make it clear there's another way.
Was reviewing the new docs site this morning and saw there are a few pages that do a great job describing signing requests:
Since this topic seems very well covered, I'm going to go ahead and close this PR.
Update the signed_requested.js snippet that demonstrates signing and verifying HMAC tokens to use the Web Crypto API instead of
require("crypto")
.Web Crypto is natively supported by the Workers Runtime and allows you to sign and verify with plain JavaScript workers instead of needing to use webpack.
Additionally, the developer documentation on the Web Crypto API for Workers mentions using the API for signing and verifying:
But that link just redirects to the home page for the Cloudflare Workers documentation. This snippet could provide a landing spot for that link for those interested in learning more.