This is port of only part of get_cncryption_key script from pySwitchbot, just rewrite code on NodeJS.
How to install:
$ npm install switchbot-get-encryption-keyUsage:
$ npx switchbot-get-encryption-key MAC USERNAME
Key ID: xx
Encryption key: xxxxxxxxxxxxxxxxMAC need to be without colon and upper case (e.g. ABCDE1234567).
Data obtained by this script would be used by WoSmartLock.setKey() function in node-switchbot library, or custom implementation of BLE central which directly communicates to SwitchBot Lock / Lock Pro by encrypted BLE commands.
You can refer to my blog (sorry, in Japanese!) for more detail of SwitchBot Smartlock BLE control. It will show you about BLE protocol and how above data is used to control Smartlock.