Skip to content
This repository was archived by the owner on Jan 28, 2025. It is now read-only.
This repository was archived by the owner on Jan 28, 2025. It is now read-only.

Login needs 2FA #5

@MaEscalanteHe

Description

@MaEscalanteHe

Hi!

When I try to log in it never asks me for the 2FA code I have set up in my account.

I had to edit the "getTokens" function in the "login.js" file to make it ask me for the code so I can use the CLI. I would like to be able to open a PR with the modified changes, but given the structure of the project I don't know how to approach it in the best way.

I leave you the piece of code I made:

// (in line 10)
const TFA = 'https://bambulab.com/api/sign-in/tfa'; 

// (in line 138)
if (code === 200) {
            res.on('data', d => {
                const json = JSON.parse(d);
                logger.debug(`JSON`, JSON.stringify(json, null, 4));
                if (json.tfaKey) {
                    const tfa = rl.question(`[bambulab.com] 2FA code: `);
                    const tfaPayload = JSON.stringify({ tfaKey: json.tfaKey, tfaCode: tfa });
                    const tfaEndpoint = parse(TFA);
                    tfaEndpoint.method = 'POST';
                    tfaEndpoint.headers = {
                        'content-type':   'application/json',
                        'content-length': tfaPayload.length
                    };
                    const tfaReq = https.request(tfaEndpoint, (tfaRes) => {
                      ...
                    });
                    tfaReq.write(tfaPayload);
                    tfaReq.end();
                }
            });
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions