Skip to content

Cannot generateSecret due to Buffer not being found #499

@robecole1

Description

@robecole1

I am trying to use the generateSecret function, but I am getting this error whenever it is ran. I am running this on React v17.0.2 and am using node 16.17.0. I have tried doing npm install buffer, and have tried importing Buffer into this file, but the issue still persists.

ReferenceError: Can't find variable: Buffer
generateSecret
node_modules/time2fa/dist/index.mjs:179
  176 |   };
  177 | };
  178 | const generateSecret = (secretSize = DEFAULT_TOTP_SECRET_SIZE) => {
> 179 |   const bytes = Buffer.from(crypto.randomBytes(secretSize));
  180 |   return Encode32(bytes);
  181 | };
  182 | const generateBackupCodes = (numCodes = 10, codeLength = DEFAULT_TOTP_DIGITS) => {

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions