otp icon indicating copy to clipboard operation
otp copied to clipboard

[Solution included] OTP breaking change after version 1.1.1 (Deployed Jan 5, 2024)

Open ohmaseclaro opened this issue 1 year ago • 3 comments

After my project automatically upgraded from [email protected] to [email protected], my project stopped working.

Apparently, some change on hoow node internal packages are served broke the main function of the codebase: generateKey().

Issue happens on this line: https://github.com/pipobscure/otp/blob/0bc5a3818a5ab80198c7cb5e3933397369967b24/lib/otp.ts#L93C6-L93C6

globalThis.crypto.getRandomValues(bytes);

apparently globalThis.crypto is not defined. checking other changes on the app, I found that we should actually be using:

import { getRandomValues } from 'node:crypto';

For those who want a quick work around, just put the fixed version 1.1.0 in package.json and clear the installation.

I have a PR ready to fix this if the maintainers want the help

ohmaseclaro avatar Jan 09 '24 12:01 ohmaseclaro

This is interesting as globalThis.crypto.getRandomValues is defined both in current Chrome as well as current NodeJS.

Can you tel me what environment you are operating in?

pipobscure avatar Jan 16 '24 13:01 pipobscure

I see that v18.5 does not have it.

pipobscure avatar Jan 16 '24 13:01 pipobscure

Any updates?

suiramdev avatar Jun 26 '24 09:06 suiramdev