-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ Feat ]: Support Cloudflare Runtime #28
Comments
Hello @mw10013, thanks for reporting this. I recently released Previously, with Despite this, I must admit I haven't had the chance to get deeper into the specifics of Cloudflare's systems, which makes it challenging to understand what could be happening (the library works as expected outside of it). I'm considering reaching out to Sergio Xalambrí, the creator of Let me know if you have more information or a specific error that could lead us to a solution! |
Update: I had a talk with Sergio, who pointed out a possible case that could be causing the Cloudflare issues. Compatibility Issue with Cloudflare:
Specific Package Problems:The Potential Solutions:Replacing I'll check this out @mw10013. I'll definitely find some time to look into it and come up with a solution. I'll leave the issue open and update you on any changes. |
https://github.com/mw10013/remix-auth-totp-sandbox/blob/epic-totp/app/routes/_index.tsx export function loader() {
const { otp, secret, digits, period, algorithm } = generateTOTP({
algorithm: "SHA256",
period: 10 * 60,
});
const isValid = verifyTOTP({ otp, secret, digits, period, algorithm });
return { otp, secret, period, digits, algorithm, isValid };
} |
Cloudflare definitely supports the Web Crypto API. https://github.com/mw10013/remix-auth-totp-sandbox/tree/jsonwebtoken "The Workers runtime implements the full surface of this API, but with some differences in the supported algorithms compared to those implemented in most browsers." I'm unable to get
Runtime error starting up. |
Alright, so we can mostly confirm that the issue could be the implementation of I'll need to review the source-code from the Strategy to confirm if I'll look into it, @mw10013. |
Jose may be another option, https://github.com/panva/jose " |
I'm currently integrating Could you please give it a try to |
All right @mw10013, could you try this implementation of Feel free to give it a try and let me know if it works as expected or if you encounter any new errors that we can address. The tests passes successfully, although I will have to fix some minor incompatibilities with expiration periods, between strings and numbers, due to the new |
Thanks for turning this around so quickly! I'm now able to get my non-functional skeletal sandbox to compile and load with tweak to remix.config.js. serverNodeBuiltinsPolyfill: {
modules: { buffer: true, crypto: true },
globals: {
Buffer: true,
},
}, I'll be working on a functional version and will report back here. |
With the remix-auth-totp-dev package, I'm getting a "Code is no longer active" error when I submit the code in a verify form. As a sanity check, I forked https://github.com/dev-xo/totp-starter-example, created a branch named For reference, the branch is https://github.com/mw10013/totp-starter-example/tree/remix-auth-totp-dev |
Hello @mw10013. Could you please give it another try with the updated Also, here's my Discord username ( |
|
Does that mean we have support for Cloudflare, @mw10013? In that case, would you like to create a Also, tomorrow I will publish these changes to the official |
Yes, I can confirm the basics work in Cloudflare local dev with wrangler/miniflare. Need to get further along in the example program I'm working on to cover more cases and then get it running in Cloudflare production. I would like the example program to help folks get started and will circle back with you for review and inclusion when it's further along. |
All code has been moved to the main repository @mw10013. Feel free to try out the Again, thank you for reporting this. Closing this for now, but we can keep the talk on here. |
Cloudflare wrangler reports an error when an Authenticator uses TOTPStrategy. The error seems to be reported during load time so the authenticator does not execute.
https://github.com/mw10013/remix-auth-totp-sandbox demonstrates the error.
pnpm create remix@latest --template remix-run/remix/templates/cloudflare-page
node:process
"start": "wrangler pages dev ./public --compatibility-date=2023-12-13 --compatibility-flags=\"nodejs_compat\""
The text was updated successfully, but these errors were encountered: