yisbug / whatsapp-nodejs

This is a library based on whatsapp androd latest version, you can use it build your own app.
36 stars 12 forks source link

thanks for great job! But can I login by the andorid client keypaire and server_pub key? #1

Closed andersling closed 1 year ago

andersling commented 1 year ago

hi, sir, thanks for your great job! by the way ,how to logon whatsapp with andorid device keypaire and the server_pub key?

thanks!

yisbug commented 1 year ago
const accountStore = require('../src/store/account');
const db = require('../src/db');
const Whatsapp = require('../src/Whatsapp');

const main = async () => {
  //
  const mobile = '123123123123';
  const keyPair = {
    private: Buffer.alloc(32),
    public: Buffer.alloc(32),
  };

  const whatsapp = new Whatsapp({
    mongodb: 'mongodb://localhost:27017/whatsapp',
  });
  await whatsapp.init({
    mobile,
  });

  // insert into db
  await accountStore.initAccount({ mobile });
  await db.account.findOneAndUpdate(
    { mobile },
    {
      clientStaticKeypair: Buffer.concat([keyPair.private, keyPair.public]).toString('base64'),
    }
  );

  await whatsapp.login();
};

main();