update to Webpack 5

Change-Id: Icc238a9f981ecaf5c5802c9a3a4f0bcb89e7d42b
diff --git a/app.js b/app.js
index 861409e..065724b 100644
--- a/app.js
+++ b/app.js
@@ -183,10 +183,10 @@
 
 /* GET React App */
 
-app.use(express.static(path.join(__dirname, 'public')))
+app.use(express.static(path.join(__dirname, 'client', 'dist')))
 
 app.use((req, res, next) => {
-    res.sendFile(path.join(__dirname, 'public', 'index.html'));
+    res.sendFile(path.join(__dirname, 'client', 'dist', 'index.html'));
 });
 
 const server = http.Server(app);
diff --git a/jaas-client/README.md b/client/README.md
similarity index 100%
rename from jaas-client/README.md
rename to client/README.md
diff --git a/jaas-client/package.json b/client/package.json
similarity index 68%
rename from jaas-client/package.json
rename to client/package.json
index 2a4a3c8..2cc5732 100644
--- a/jaas-client/package.json
+++ b/client/package.json
@@ -1,5 +1,5 @@
 {
-  "name": "jaas-client",
+  "name": "jami-web-client",
   "version": "0.1.0",
   "private": true,
   "dependencies": {
@@ -13,15 +13,22 @@
     "react-dom": "^16.13.1",
     "react-emoji-render": "^1.2.4",
     "react-router-dom": "^5.2.0",
-    "react-scripts": "^4.0.3",
     "react-sound": "^1.2.0",
     "socket.io-client": "^2.3.0"
   },
+  "devDependencies": {
+    "@babel/core": "^7.13.14",
+    "@babel/preset-env": "^7.13.12",
+    "@babel/preset-react": "^7.13.13",
+    "babel-loader": "^8.2.2",
+    "css-loader": "^5.2.0",
+    "html-webpack-plugin": "^5.3.1",
+    "style-loader": "^2.0.0",
+    "webpack": "^5.31.0",
+    "webpack-cli": "^4.6.0"
+  },
   "scripts": {
-    "start": "react-scripts start",
-    "build": "react-scripts build",
-    "test": "react-scripts test",
-    "eject": "react-scripts eject"
+    "build": "npx webpack"
   },
   "eslintConfig": {
     "extends": "react-app"
diff --git a/jaas-client/public/Jami-logo-gnu-package_rainbowHD.svg b/client/public/Jami-logo-gnu-package_rainbowHD.svg
similarity index 100%
rename from jaas-client/public/Jami-logo-gnu-package_rainbowHD.svg
rename to client/public/Jami-logo-gnu-package_rainbowHD.svg
diff --git a/jaas-client/public/baseline_send_black_18dp.png b/client/public/baseline_send_black_18dp.png
similarity index 100%
rename from jaas-client/public/baseline_send_black_18dp.png
rename to client/public/baseline_send_black_18dp.png
Binary files differ
diff --git a/jaas-client/public/deduction.mp3 b/client/public/deduction.mp3
similarity index 100%
rename from jaas-client/public/deduction.mp3
rename to client/public/deduction.mp3
Binary files differ
diff --git a/jaas-client/public/favicon.ico b/client/public/favicon.ico
similarity index 100%
rename from jaas-client/public/favicon.ico
rename to client/public/favicon.ico
Binary files differ
diff --git a/jaas-client/public/logo192.png b/client/public/logo192.png
similarity index 100%
rename from jaas-client/public/logo192.png
rename to client/public/logo192.png
Binary files differ
diff --git a/jaas-client/public/logo512.png b/client/public/logo512.png
similarity index 100%
rename from jaas-client/public/logo512.png
rename to client/public/logo512.png
Binary files differ
diff --git a/jaas-client/public/manifest.json b/client/public/manifest.json
similarity index 100%
rename from jaas-client/public/manifest.json
rename to client/public/manifest.json
diff --git a/jaas-client/public/robots.txt b/client/public/robots.txt
similarity index 100%
rename from jaas-client/public/robots.txt
rename to client/public/robots.txt
diff --git a/jaas-client/public/stairs.mp3 b/client/public/stairs.mp3
similarity index 100%
rename from jaas-client/public/stairs.mp3
rename to client/public/stairs.mp3
Binary files differ
diff --git a/jaas-client/src/App.css b/client/src/App.css
similarity index 100%
rename from jaas-client/src/App.css
rename to client/src/App.css
diff --git a/jaas-client/src/App.js b/client/src/App.js
similarity index 100%
rename from jaas-client/src/App.js
rename to client/src/App.js
diff --git a/jaas-client/src/App.test.js b/client/src/App.test.js
similarity index 100%
rename from jaas-client/src/App.test.js
rename to client/src/App.test.js
diff --git a/jaas-client/src/AuthManager.js b/client/src/AuthManager.js
similarity index 100%
rename from jaas-client/src/AuthManager.js
rename to client/src/AuthManager.js
diff --git a/jaas-client/src/components/AccountList.js b/client/src/components/AccountList.js
similarity index 100%
rename from jaas-client/src/components/AccountList.js
rename to client/src/components/AccountList.js
diff --git a/jaas-client/src/components/AccountPreferences.js b/client/src/components/AccountPreferences.js
similarity index 100%
rename from jaas-client/src/components/AccountPreferences.js
rename to client/src/components/AccountPreferences.js
diff --git a/jaas-client/src/components/ContactList.js b/client/src/components/ContactList.js
similarity index 100%
rename from jaas-client/src/components/ContactList.js
rename to client/src/components/ContactList.js
diff --git a/jaas-client/src/components/Header.js b/client/src/components/Header.js
similarity index 100%
rename from jaas-client/src/components/Header.js
rename to client/src/components/Header.js
diff --git a/jaas-client/src/components/JamiIdCard.js b/client/src/components/JamiIdCard.js
similarity index 100%
rename from jaas-client/src/components/JamiIdCard.js
rename to client/src/components/JamiIdCard.js
diff --git a/jaas-client/src/components/Message.js b/client/src/components/Message.js
similarity index 100%
rename from jaas-client/src/components/Message.js
rename to client/src/components/Message.js
diff --git a/jaas-client/src/components/MessageList.js b/client/src/components/MessageList.js
similarity index 100%
rename from jaas-client/src/components/MessageList.js
rename to client/src/components/MessageList.js
diff --git a/jaas-client/src/components/NewContactForm.js b/client/src/components/NewContactForm.js
similarity index 100%
rename from jaas-client/src/components/NewContactForm.js
rename to client/src/components/NewContactForm.js
diff --git a/jaas-client/src/components/SendMessageForm.js b/client/src/components/SendMessageForm.js
similarity index 100%
rename from jaas-client/src/components/SendMessageForm.js
rename to client/src/components/SendMessageForm.js
diff --git a/jaas-client/src/index.css b/client/src/index.css
similarity index 100%
rename from jaas-client/src/index.css
rename to client/src/index.css
diff --git a/jaas-client/public/index.html b/client/src/index.ejs
similarity index 80%
rename from jaas-client/public/index.html
rename to client/src/index.ejs
index d2e2225..f1cd060 100644
--- a/jaas-client/public/index.html
+++ b/client/src/index.ejs
@@ -8,6 +8,7 @@
   <meta name="theme-color" content="#000000" />
   <meta name="description" content="Web site created using create-react-app" />
   <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
+  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" />
   <title>Jaas Web Client App</title>
 </head>
 
diff --git a/jaas-client/src/index.js b/client/src/index.js
similarity index 83%
rename from jaas-client/src/index.js
rename to client/src/index.js
index f5185c1..42d2abd 100644
--- a/jaas-client/src/index.js
+++ b/client/src/index.js
@@ -2,7 +2,7 @@
 import ReactDOM from 'react-dom';
 import './index.css';
 import App from './App';
-import * as serviceWorker from './serviceWorker';
+//import * as serviceWorker from './serviceWorker';
 
 ReactDOM.render(
   <React.StrictMode>
@@ -14,4 +14,4 @@
 // If you want your app to work offline and load faster, you can change
 // unregister() to register() below. Note this comes with some pitfalls.
 // Learn more about service workers: https://bit.ly/CRA-PWA
-serviceWorker.unregister();
+//serviceWorker.unregister();
diff --git a/jaas-client/src/logo.svg b/client/src/logo.svg
similarity index 100%
rename from jaas-client/src/logo.svg
rename to client/src/logo.svg
diff --git a/jaas-client/src/pages/404.jsx b/client/src/pages/404.jsx
similarity index 100%
rename from jaas-client/src/pages/404.jsx
rename to client/src/pages/404.jsx
diff --git a/jaas-client/src/pages/accountSelection.jsx b/client/src/pages/accountSelection.jsx
similarity index 100%
rename from jaas-client/src/pages/accountSelection.jsx
rename to client/src/pages/accountSelection.jsx
diff --git a/jaas-client/src/pages/accountSettings.jsx b/client/src/pages/accountSettings.jsx
similarity index 100%
rename from jaas-client/src/pages/accountSettings.jsx
rename to client/src/pages/accountSettings.jsx
diff --git a/jaas-client/src/pages/loginDialog.jsx b/client/src/pages/loginDialog.jsx
similarity index 100%
rename from jaas-client/src/pages/loginDialog.jsx
rename to client/src/pages/loginDialog.jsx
diff --git a/jaas-client/src/pages/messenger.jsx b/client/src/pages/messenger.jsx
similarity index 100%
rename from jaas-client/src/pages/messenger.jsx
rename to client/src/pages/messenger.jsx
diff --git a/jaas-client/src/serviceWorker.js b/client/src/serviceWorker.js
similarity index 100%
rename from jaas-client/src/serviceWorker.js
rename to client/src/serviceWorker.js
diff --git a/jaas-client/src/setupTests.js b/client/src/setupTests.js
similarity index 100%
rename from jaas-client/src/setupTests.js
rename to client/src/setupTests.js
diff --git a/client/webpack.config.js b/client/webpack.config.js
new file mode 100644
index 0000000..84ff411
--- /dev/null
+++ b/client/webpack.config.js
@@ -0,0 +1,35 @@
+const path = require('path')
+const HtmlWebpackPlugin = require('html-webpack-plugin')
+
+module.exports = {
+    entry: path.resolve(__dirname, 'src', 'index.js'),
+    output: {
+        path: path.resolve(__dirname, 'dist'),
+        filename: 'bundle.js',
+        publicPath: '/'
+    },
+    mode: 'development',
+    module: {
+        rules: [
+            {
+                test: /\.jsx?/,
+                exclude: /node_modules/,
+                use: {
+                    loader: 'babel-loader',
+                    options: {
+                        presets: ['@babel/preset-env', '@babel/preset-react']
+                    }
+                }
+            },
+            {
+                test: /\.css$/i,
+                use: ['style-loader', 'css-loader'],
+            }
+        ]
+    },
+    plugins: [
+        new HtmlWebpackPlugin({
+            template: path.resolve(__dirname, 'src', 'index.ejs')
+        })
+    ]
+}
\ No newline at end of file
diff --git a/jaas-client/dist/index.html b/jaas-client/dist/index.html
deleted file mode 100644
index 3353d9d..0000000
--- a/jaas-client/dist/index.html
+++ /dev/null
@@ -1,15 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-
-<head>
-    <meta charset="UTF-8">
-    <meta name="viewport" content="width=device-width, initial-scale=1.0">
-    <title>Jass Client</title>
-</head>
-
-<body>
-    <div id="root"></div>
-    <script src="/bundle.js"></script>
-</body>
-
-</html>
\ No newline at end of file
diff --git a/model/Conversation.js b/model/Conversation.js
new file mode 100644
index 0000000..d5c41de
--- /dev/null
+++ b/model/Conversation.js
@@ -0,0 +1,42 @@
+class Conversation {
+    constructor(id, members) {
+        this.id = id
+        this.members = members
+        this.messages = []
+    }
+
+    static from(object) {
+        return new Conversation(object.id, object.members)
+    }
+
+    getId() { return this.id }
+
+    getDisplayName() {
+        return this.details["Account.displayName"] || this.getDisplayUri()
+    }
+
+    getUri() { return this.details["Account.username"] }
+
+    getRegisteredName() { return this.volatileDetails["Account.registeredName"] }
+
+    getObject() {
+        return {
+            id: this.id,
+            members: this.members
+        }
+    }
+
+    getSummary() {
+        return this.getObject()
+    }
+
+    getDisplayUri() {
+        return this.getRegisteredName() || this.getUri()
+    }
+
+    addMessage(message) {
+        this.messages.push(message)
+    }
+}
+
+module.exports = Conversation;
diff --git a/package.json b/package.json
index 811145d..32cb111 100644
--- a/package.json
+++ b/package.json
@@ -1,5 +1,5 @@
 {
-  "name": "jaas-server",
+  "name": "jami-web-server",
   "version": "1.0.0",
   "description": "Jaas Web API that handles client requests to Jami daemon",
   "main": "index.js",
@@ -8,7 +8,6 @@
     "connect-redis": "^4.0.4",
     "cookie-parser": "^1.4.5",
     "cors": "^2.8.5",
-    "css-loader": "^3.6.0",
     "dotenv": "^8.2.0",
     "env": "0.0.2",
     "express": "^4.17.1",
@@ -16,7 +15,7 @@
     "express-ws": "^4.0.0",
     "fast-xml-parser": "^3.17.4",
     "faye": "^1.3.0",
-    "jaas-client": "file:jaas-client",
+    "jami-web-client": "file:client",
     "mongoose": "^5.9.19",
     "passport": "^0.4.1",
     "passport-local": "^1.0.0",
@@ -24,19 +23,15 @@
     "passport.socketio": "^3.7.0",
     "path": "^0.12.7",
     "redis-url": "^1.2.1",
-    "socket.io": "^2.3.0",
-    "style-loader": "^1.2.1"
+    "socket.io": "^2.3.0"
   },
   "devDependencies": {
-    "@babel/core": "^7.10.3",
-    "@babel/preset-react": "^7.10.1",
-    "babel-loader": "8.1.0",
-    "webpack": "4.43.0",
-    "webpack-cli": "3.3.12"
+    "llnode": "^3.2.0",
+    "nodemon": "^2.0.7"
   },
   "scripts": {
     "start": "node app.js",
-    "build": "npx webpack && cp -R jaas-client/dist/*  public/"
+    "build": "cd client && npx webpack"
   },
   "author": "Larbi Gharib",
   "license": "ISC"
diff --git a/public/index.html b/public/index.html
deleted file mode 100644
index 3353d9d..0000000
--- a/public/index.html
+++ /dev/null
@@ -1,15 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-
-<head>
-    <meta charset="UTF-8">
-    <meta name="viewport" content="width=device-width, initial-scale=1.0">
-    <title>Jass Client</title>
-</head>
-
-<body>
-    <div id="root"></div>
-    <script src="/bundle.js"></script>
-</body>
-
-</html>
\ No newline at end of file
diff --git a/public/stairs.mp3 b/public/stairs.mp3
deleted file mode 100644
index a108abc..0000000
--- a/public/stairs.mp3
+++ /dev/null
Binary files differ
diff --git a/webpack.config.js b/webpack.config.js
deleted file mode 100644
index 2917248..0000000
--- a/webpack.config.js
+++ /dev/null
@@ -1,30 +0,0 @@
-const path = require('path')
-
-module.exports = {
-    entry: path.resolve(__dirname, 'jaas-client', 'src', 'index.js'),
-    output: {
-        path: path.resolve(__dirname, 'jaas-client', 'dist'),
-        filename: 'bundle.js'
-    },
-    mode: 'development',
-    module: {
-        rules: [
-            {
-                test: /\.jsx?/,
-                exclude: /node_modules/,
-                loader: [
-                    {
-                        loader: 'babel-loader',
-                        query: {
-                            presets: ['@babel/preset-react']
-                        }
-                    }
-                ]
-            },
-            {
-                test: /\.css$/i,
-                use: ['style-loader', 'css-loader'],
-            }
-        ]
-    },
-}
\ No newline at end of file