summary refs log tree commit diff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/sd.js9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/sd.js b/lib/sd.js
index ea3fba9..e66b7b3 100644
--- a/lib/sd.js
+++ b/lib/sd.js
@@ -9,7 +9,6 @@ export default class SoktDeer {
     ws;
     /** @type {import("node:events").EventEmitter} */
     wsEvents = new EventEmitter3();
-
     /** @type {any[]} */
     messages = [];
     constructor(wsUri = "wss://sokt.meltland.dev") {
@@ -34,6 +33,7 @@ export default class SoktDeer {
         })
         this.ws.onopen = () => setInterval(()=>this.ping.call(this), 5000)
     }
+
     login(username, password) {
         return new Promise((resolve, reject) => {
             this.ws.send(JSON.stringify({
@@ -41,7 +41,7 @@ export default class SoktDeer {
                 username,
                 password
             }))
-            this.wsEvents.once('token', token => {
+            this.wsEvents.once('token', ({token}) => {
                 this.token = token;
                 resolve(token)
             })
@@ -54,11 +54,12 @@ export default class SoktDeer {
     }
 
     //TODO - implement this
-    loginToken(token) {
+    loginToken(token, username) {
         return new Promise((resolve, reject) => {
             this.ws.send(JSON.stringify({
                 command: "login_token",
-                token
+                token,
+                username
             }))
             this.wsEvents.once('error', error => {
                 if (error.error) reject(error.code)