Skip to content
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

Issues deploying code to AWS Lambda #8

Closed
kldeb opened this issue Aug 28, 2024 · 3 comments
Closed

Issues deploying code to AWS Lambda #8

kldeb opened this issue Aug 28, 2024 · 3 comments
Labels

Comments

@kldeb
Copy link
Contributor

kldeb commented Aug 28, 2024

For some reason this code will not execute properly using node v20 running on aws lambda deployed using sst.

I was able to fix this issue by replacing this package:

import * as base32 from 'thirty-two'

with

import base32Encode from 'base32-encode'
import base32Decode from 'base32-decode'

and updating the code to use those 2 functions.

While preparing a PR for this change I broke the tests. I want to make sure that modifying the tests to support this change will not break any existing implementations. Could someone give me a hand with the test cases?

I was able to get all the tests working again except Fail to verify an invalid TOTP. I had to modify options can be customized like so:

test('options can be customized', () => {
	const options = {
		algorithm: 'SHA256',
		period: 60,
		digits: 8,
		secret: base32Encode(
			new TextEncoder().encode(Math.random().toString(16).slice(2)),
			'RFC4648'
		).toString(),
		charSet: 'abcdef',
	}
	const { otp, ...config } = generateTOTP(options)
	assert.deepStrictEqual(config, options)
	const result = verifyTOTP({ otp, ...config })
	assert.deepStrictEqual(result, { delta: 0 })
})

Edit: I don't think this change will affect existing implementations but I want to be sure.

@kentcdodds
Copy link
Member

Hi @kldeb,

Go ahead and open the PR and I'll give it a look. Thanks!

@dev-xo
Copy link

dev-xo commented Aug 28, 2024

Hi @kentcdodds!

@kldeb was kind enough to notify us about remix-auth-totp, which also relies on @epicweb-dev/totp. In order to allow users to successfully deploy to AWS Lambda using Node 20, it seems like we also need to find an alternative for thirty-two in @epicweb-dev/totp.

Hopefully, @kldeb is able to pass the tests, and we can improve a bit @epicweb-dev/totp and, with that, remix-auth-totp!

Copy link

🎉 This issue has been resolved in version 1.1.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants