speakeasyjs / speakeasy

**NOT MAINTAINED** Two-factor authentication for Node.js. One-time passcode generator (HOTP/TOTP) with support for Google Authenticator.
MIT License
2.68k stars 229 forks source link

can't read property generateSecretASCII of undefined #145

Open edugrip opened 1 year ago

edugrip commented 1 year ago

When I try to create the image, with the following code, var secret = generateSecret({ name: "mySecret", })
The line 458 in index.js generates an error .... var key = this.generateSecretASCII(length, symbols);

this is undefined here. (I get an error can't read property generateSecretASCII of undefined) When I change this to exports, it works. team, kindly find out and guide to fix the issue.

kauebkf commented 1 year ago

If you are using import syntax, change it to express one. Like this: const speakeasy = require('speakeasy');

edugrip commented 1 year ago

Quick solution: go to the source of this and change this.generateSecretASCII to exports.generateSecretASCII. But later, if it gets overwritten, the problem will recur, so I suggest creating a pull request for this, and fix it permanently.