Reorganize server files and address TODO comments

Changes:
- Remove unneeded dependencies from package.json
- Remove unneeded async build() methods from services
    - Use constructor as often as possible
- Rename and move storage services for clarity
    - creds.ts -> accounts.ts, and creds.json -> accounts.json
    - admin-config.ts -> admin-account.ts
    - vault.ts -> signing-keys.ts
- Rename ws.ts to websocket-server.ts for clarity and consistency
- Make WebSocketServer initialize using constructor and bind server upgrade to WebSocketServer.upgrade
- Remove unused send-account-message endpoint from account-router.ts
- Set issuer and audience claims for JWT
- Create new utils/jwt.ts file to remove code duplication for JWT signing and verifying
- Delete utils.ts and merge it with jami-swig.ts
- Handle potentially undefined types in jami-swig.ts
- Replace hard to read one-liners with functions in jami-swig.ts
- Rename types in jami-swig.ts for consistency with daemon
- Remove handled/answered TODO comments
- Remove TODO comment about using .env for jamid.node as it does not work for require()

GitLab: #87
Change-Id: I1e5216ffa79ea34dd7e9b61540fb7e37d1f66c9f
24 files changed
tree: 49465cf6b00f6e95aff5f3d05c5c15c5cce04ffb
  1. .hooks/
  2. client/
  3. common/
  4. cypress/
  5. routes/
  6. server/
  7. test/
  8. .dockerignore
  9. .env.development
  10. .env.production
  11. .eslintrc.cjs
  12. .gitignore
  13. .gitmodules
  14. .gitreview
  15. .prettierignore
  16. .prettierrc.json
  17. app.ts
  18. cypress-test.sh
  19. cypress.config.ts
  20. docker-compose.yml
  21. Dockerfile
  22. JamiDaemon.ts
  23. jamiServerConfig.json
  24. Jenkinsfile
  25. package-lock.json
  26. package.json
  27. README.md
  28. rollup.config.js
  29. sentry.js
  30. tsconfig.json
README.md

Jami-web

Jami-web is a web server that starts a Dameon on NodeJS express server and serve a React web client.

The first milestone is to allow user with LDAP credentials to connect to the account using JAMS service and start chatting with their contacts using instant messaging.

Next step will be to implement a video protocol such as WebRTC to allow audio and video calls from the users browser to another Jami contact allowing cross-platform communications.

Main dependencies

  • Swig 4.1.0

How to start the server

After building the Jami daemon you can use the following command to start the node js server using the LD_LIBRARY_PATH

Where $PATH_TO_JAMI_PROJECT is the path to the shared library of your Jami daemon

LD_LIBRARY_PATH=$PATH_TO_JAMI_PROJECT/ring-project/install/daemon/lib node

To build the dring.node Javascript interface to talk to the daemon api go to the daemon repo and use ./configure --with-nodejs then execute make -j4 to build the daemon

Create a symbolic link to jamid.node at the root of jami-web and inside server/:

ln -s daemon/bin/nodejs/build/Release/jamid.node jamid.node
ln -s daemon/bin/nodejs/build/Release/jamid.node server/jamid.node

Then, start the servers:

# Install the package dependencies
npm install

# Start the client and backend servers
npm start

You may also start the servers individually:

npm start --workspace client
npm start --workspace server

How to build for production

# Build the client app and the server. The resulting files are available in `client/dist` and `server/dist` respectively
npm run build

# Preview the production build locally
npm run start:prod

Docker

You may run the web server in a Docker container. This will automatically build the daemon and do the necessary linking.

1. Build the daemon

cd daemon
docker build --build-arg config_args="--with-nodejs" -t jami-daemon .
cd ..

2. Build and run the web server and client

docker build --target development --tag jami-web .
docker run -it \
  -p 3001:3001 \
  -p 3000:3000 \
  -p 5000:5000 \
  --volume $(pwd)/client/src:/web-client/client/src \
  --volume $(pwd)/server/src:/web-client/server/src \
  --volume $(pwd)/client/.env.development:/web-client/client/.env.development \
  --volume $(pwd)/server/.env:/web-client/server/.env \
  jami-web

Using [docker-compose](docker run -p 3000:3000 -it jami-project)

This will use a Docker Volume to enable auto-refresh when you change a file.

# First build the daemon if necessary
docker-compose build jami-daemon

# Then build the project and start the container
docker-compose build
docker-compose up

Sentry

  • uncomment the line // import config from "./sentry-server.config.json" assert { type: "json" }; in ./sentry.js

  • uncomment the line // import config from "../sentry-client.config.json" and the init configSentry.init(... in ./client/index.js

  • uncomment the lines // import { sentrySetUp } from './sentry.js' and sentrySetUp(app) in ./app.ts

  • add sentry-client.config.json file in client and sentry-server.config.json (ask them to an admin) in your project root

Tests

  • Cypress: run the following script sh ./cypress-test.sh