Great question — answering as the UphillTech team:
You can check this example https://github.com/signalapp/libsignal-protocol-java/pull/21/commits/3496ed996359f6d3d8ee52dcecb8f8b0d45b3cbc This is Java based project but it might help you in your JS code https://github.com/lvijay/DemoSignal
Full answer by Muhammad Ahmed: https://stackoverflow.stackexchange.com/a/68989652 (CC BY-SA 3.0).
Need it done for your business? UphillTech.