Add JAMS option when creating account

With JAMS, we do not use SFL's database to store account credentials. We
rather pass the credentials directly to jami. It internally checks the
credentials with the server, and returns ERROR_GENERIC if it fails.
Multiple jami accounts can be created with the same JAMS account. That's
why I store the credentials in accounts.json too. I splitted it into two
fields: local and jams.

GitLab: #72
Change-Id: Icc925936fb47748133637837462016c4ecbbe79e
diff --git a/server/src/storage/accounts.ts b/server/src/storage/accounts.ts
index 77a8d9d..efcd014 100644
--- a/server/src/storage/accounts.ts
+++ b/server/src/storage/accounts.ts
@@ -20,10 +20,15 @@
 
 import { Service } from 'typedi';
 
+interface AccountsFormat {
+  local: Record<string, string>;
+  jams: Record<string, string>;
+}
+
 @Service()
 export class Accounts {
   private readonly filename = 'accounts.json';
-  private accounts: Record<string, string>;
+  private accounts: AccountsFormat;
 
   constructor() {
     let buffer: Buffer;
@@ -31,18 +36,18 @@
     try {
       buffer = readFileSync(this.filename);
     } catch (e) {
-      buffer = Buffer.from('{}');
+      buffer = Buffer.from('{"local":{}},"jams":{}}}');
     }
 
     this.accounts = JSON.parse(buffer.toString());
   }
 
-  get(username: string): string | undefined {
-    return this.accounts[username];
+  get(username: string, isJams = false): string | undefined {
+    return this.accounts[isJams ? 'jams' : 'local'][username];
   }
 
-  set(username: string, password: string): void {
-    this.accounts[username] = password;
+  set(username: string, password: string, isJams = false): void {
+    this.accounts[isJams ? 'jams' : 'local'][username] = password;
   }
 
   async save(): Promise<void> {