diff --git a/.gitignore b/.gitignore index 6ad79d79..8d306b2c 100644 --- a/.gitignore +++ b/.gitignore @@ -6,5 +6,6 @@ dist-ssr *.local .idea/ public/config.json +backend/synapse_tmp/* /coverage yarn-error.log diff --git a/README.md b/README.md index 9ff4e156..f05c2d2d 100644 --- a/README.md +++ b/README.md @@ -3,17 +3,24 @@ [![Chat](https://img.shields.io/matrix/webrtc:matrix.org)](https://matrix.to/#/#webrtc:matrix.org) [![Localazy](https://img.shields.io/endpoint?url=https%3A%2F%2Fconnect.localazy.com%2Fstatus%2Felement-call%2Fdata%3Fcontent%3Dall%26title%3Dlocalazy%26logo%3Dtrue)](https://localazy.com/p/element-call) -Group calls with WebRTC that leverage [Matrix](https://matrix.org) and an open-source WebRTC toolkit from [LiveKit](https://livekit.io/). +Group calls with WebRTC that leverage [Matrix](https://matrix.org) and an +open-source WebRTC toolkit from [LiveKit](https://livekit.io/). -For prior version of the Element Call that relied solely on full-mesh logic, check [`full-mesh`](https://github.com/element-hq/element-call/tree/full-mesh) branch. +For prior version of the Element Call that relied solely on full-mesh logic, +check [`full-mesh`](https://github.com/element-hq/element-call/tree/full-mesh) +branch. ![A demo of Element Call with six people](demo.jpg) -To try it out, visit our hosted version at [call.element.io](https://call.element.io). You can also find the latest development version continuously deployed to [call.element.dev](https://call.element.dev/). +To try it out, visit our hosted version at +[call.element.io](https://call.element.io). You can also find the latest +development version continuously deployed to +[call.element.dev](https://call.element.dev/). ## Host it yourself -Until prebuilt tarballs are available, you'll need to build Element Call from source. First, clone and install the package: +Until prebuilt tarballs are available, you'll need to build Element Call from +source. First, clone and install the package: ``` git clone https://github.com/element-hq/element-call.git @@ -22,17 +29,23 @@ yarn yarn build ``` -If all went well, you can now find the build output under `dist` as a series of static files. These can be hosted using any web server that can be configured with custom routes (see below). +If all went well, you can now find the build output under `dist` as a series of +static files. These can be hosted using any web server that can be configured +with custom routes (see below). -You may also wish to add a configuration file (Element Call uses the domain it's hosted on as a Homeserver URL by default, -but you can change this in the config file). This goes in `public/config.json` - you can use the sample as a starting point: +You may also wish to add a configuration file (Element Call uses the domain it's +hosted on as a Homeserver URL by default, but you can change this in the config +file). This goes in `public/config.json` - you can use the sample as a starting +point: ``` cp config/config.sample.json public/config.json # edit public/config.json ``` -Because Element Call uses client-side routing, your server must be able to route any requests to non-existing paths back to `/index.html`. For example, in Nginx you can achieve this with the `try_files` directive: +Because Element Call uses client-side routing, your server must be able to route +any requests to non-existing paths back to `/index.html`. For example, in Nginx +you can achieve this with the `try_files` directive: ``` server { @@ -44,28 +57,63 @@ server { } ``` -By default, the app expects you to have a Matrix homeserver (such as [Synapse](https://element-hq.github.io/synapse/latest/setup/installation.html)) installed locally and running on port 8008. If you wish to use a homeserver on a different URL or one that is hosted on a different server, you can add a config file as above, and include the homeserver URL that you'd like to use. +By default, the app expects you to have a Matrix homeserver (such as +[Synapse](https://element-hq.github.io/synapse/latest/setup/installation.html)) +installed locally and running on port 8008. If you wish to use a homeserver on a +different URL or one that is hosted on a different server, you can add a config +file as above, and include the homeserver URL that you'd like to use. -Element Call requires a homeserver with registration enabled without any 3pid or token requirements, if you want it to be used by unregistered users. Furthermore, it is not recommended to use it with an existing homeserver where user accounts have joined normal rooms, as it may not be able to handle those yet and it may behave unreliably. +Element Call requires a homeserver with registration enabled without any 3pid or +token requirements, if you want it to be used by unregistered users. +Furthermore, it is not recommended to use it with an existing homeserver where +user accounts have joined normal rooms, as it may not be able to handle those +yet and it may behave unreliably. -Therefore, to use a self-hosted homeserver, this is recommended to be a new server where any user account created has not joined any normal rooms anywhere in the Matrix federated network. The homeserver used can be setup to disable federation, so as to prevent spam registrations (if you keep registrations open) and to ensure Element Call continues to work in case any user decides to log in to their Element Call account using the standard Element app and joins normal rooms that Element Call cannot handle. +Therefore, to use a self-hosted homeserver, this is recommended to be a new +server where any user account created has not joined any normal rooms anywhere +in the Matrix federated network. The homeserver used can be setup to disable +federation, so as to prevent spam registrations (if you keep registrations open) +and to ensure Element Call continues to work in case any user decides to log in +to their Element Call account using the standard Element app and joins normal +rooms that Element Call cannot handle. ## Configuration -There are currently two different config files. `.env` holds variables that are used at build time, while `public/config.json` holds variables that are used at runtime. Documentation and default values for `public/config.json` can be found in [ConfigOptions.ts](src/config/ConfigOptions.ts). +There are currently two different config files. `.env` holds variables that are +used at build time, while `public/config.json` holds variables that are used at +runtime. Documentation and default values for `public/config.json` can be found +in [ConfigOptions.ts](src/config/ConfigOptions.ts). -If you're using [Synapse](https://github.com/element-hq/synapse/), you'll need to additionally add the following to `homeserver.yaml` or Element Call won't work: +If you're using [Synapse](https://github.com/element-hq/synapse/), you'll need +to additionally add the following to `homeserver.yaml` or Element Call won't +work: ``` experimental_features: + # MSC3266: Room summary API. Used for knocking over federation msc3266_enabled: true + +# The maximum allowed duration by which sent events can be delayed, as +# per MSC4140. +max_event_delay_duration: 24h + +rc_message: + # This needs to match at least the heart-beat frequency plus a bit of headroom + # Currently the heart-beat is every 5 seconds which translates into a rate of 0.2s + per_second: 0.5 + burst_count: 30 ``` -MSC3266 allows to request a room summary of rooms you are not joined. -The summary contains the room join rules. We need that to decide if the user gets prompted with the option to knock ("ask to join"), a cannot join error or the join view. +MSC3266 allows to request a room summary of rooms you are not joined. The +summary contains the room join rules. We need that to decide if the user gets +prompted with the option to knock ("ask to join"), a cannot join error or the +join view. -Element Call requires a Livekit SFU behind a Livekit jwt service to work. The url to the Livekit jwt service can either be configured in the config of Element Call (fallback/legacy configuration) or be configured by your homeserver via the `.well-known`. -This is the recommended method. +Element Call requires a Livekit SFU alongside a [Livekit JWT +service](https://github.com/element-hq/lk-jwt-service) to work. The url to the +Livekit JWT service can either be configured in the config of Element Call +(fallback/legacy configuration) or be configured by your homeserver via the +`.well-known/matrix/client`. This is the recommended method. The configuration is a list of Foci configs: @@ -88,13 +136,18 @@ The configuration is a list of Foci configs: ## Translation -If you'd like to help translate Element Call, head over to [Localazy](https://localazy.com/p/element-call). You're also encouraged to join the [Element Translators](https://matrix.to/#/#translators:element.io) space to discuss and coordinate translation efforts. +If you'd like to help translate Element Call, head over to +[Localazy](https://localazy.com/p/element-call). You're also encouraged to join +the [Element Translators](https://matrix.to/#/#translators:element.io) space to +discuss and coordinate translation efforts. ## Development ### Frontend -Element Call is built against [matrix-js-sdk](https://github.com/matrix-org/matrix-js-sdk/pull/2553). To get started, clone, install, and link the package: +Element Call is built against +[matrix-js-sdk](https://github.com/matrix-org/matrix-js-sdk/pull/2553). To get +started, clone, install, and link the package: ``` git clone https://github.com/matrix-org/matrix-js-sdk.git @@ -112,6 +165,15 @@ yarn yarn link matrix-js-sdk ``` +To use it, create a local config by, e.g., `cp ./config/config.devenv.json +./public/config.json` and adapt it if necessary. The `config.devenv.json` config +should work with the backend development environment as outlined in the next +section out of box. + +(Be aware, that this `config.devenv.json` is exposing a deprecated fallback +LiveKit config key. If the homeserver advertises SFU backend via +`.well-known/matrix/client` this has precedence.) + You're now ready to launch the development server: ``` @@ -120,25 +182,25 @@ yarn dev ### Backend -A docker compose file is provided to start a LiveKit server and auth -service for development. These use a test 'secret' published in this -repository, so this must be used only for local development and -**_never be exposed to the public Internet._** +A docker compose file `dev-backend-docker-compose.yml` is provided to start the +whole stack of components which is required for a local development environment: -To use it, add a SFU parameter in your local config `./public/config.json`: -(Be aware, that this is only the fallback Livekit SFU. If the homeserver -advertises one in the client well-known, this will not be used.) +- Minimum Synapse Setup (servername: synapse.localhost) +- LiveKit JWT Service (Note requires Federation API and hence a TLS reverse proxy) +- Minimum TLS reverse proxy (servername: synapse.localhost) Note certificates + are valid for at least 10 years from now +- Minimum LiveKit SFU Setup using dev defaults for config +- Redis db for completness -```json -"livekit": { - "livekit_service_url": "http://localhost:7881" -}, -``` +These use a test 'secret' published in this repository, so this must be used +only for local development and **_never be exposed to the public Internet._** Run backend components: ``` yarn backend +# or for podman-compose +# podman-compose -f dev-backend-docker-compose.yml up ``` ### Test Coverage @@ -150,7 +212,8 @@ yarn backend To add a new translation key you can do these steps: 1. Add the new key entry to the code where the new key is used: `t("some_new_key")` -1. Run `yarn i18n` to extract the new key and update the translation files. This will add a skeleton entry to the `public/locales/en-GB/app.json` file: +1. Run `yarn i18n` to extract the new key and update the translation files. This + will add a skeleton entry to the `public/locales/en-GB/app.json` file: ```jsonc { ... @@ -158,14 +221,16 @@ To add a new translation key you can do these steps: ... } ``` -1. Update the skeleton entry in the `public/locales/en-GB/app.json` file with the English translation: - ```jsonc +1. Update the skeleton entry in the `public/locales/en-GB/app.json` file with + the English translation: + +```jsonc { ... "some_new_key": "Some new key", ... } - ``` +``` ## Documentation diff --git a/backend-docker-compose.yml b/backend-docker-compose.yml deleted file mode 100644 index b0dbe822..00000000 --- a/backend-docker-compose.yml +++ /dev/null @@ -1,52 +0,0 @@ -version: "3.9" - -networks: - lkbackend: - -services: - auth-service: - image: ghcr.io/element-hq/lk-jwt-service:latest-ci - hostname: auth-server - # Use host network in case the configured homeserver runs on localhost - network_mode: host - environment: - - LK_JWT_PORT=8881 - - LIVEKIT_URL=ws://localhost:7880 - - LIVEKIT_KEY=devkey - - LIVEKIT_SECRET=secret - # If the configured homeserver runs on localhost, it'll probably be using - # a self-signed certificate - - LIVEKIT_INSECURE_SKIP_VERIFY_TLS=YES_I_KNOW_WHAT_I_AM_DOING - deploy: - restart_policy: - condition: on-failure - networks: - - lkbackend - - livekit: - image: livekit/livekit-server:latest - command: --dev --config /etc/livekit.yaml - restart: unless-stopped - # The SFU seems to work far more reliably when we let it share the host - # network rather than opening specific ports (but why?? we're not missing - # any…) - network_mode: host - # ports: - # - "7880:7880/tcp" - # - "7881:7881/tcp" - # - "7882:7882/tcp" - # - "50100-50200:50100-50200/udp" - volumes: - - ./backend/livekit.yaml:/etc/livekit.yaml - networks: - - lkbackend - - redis: - image: redis:6-alpine - command: redis-server /etc/redis.conf - ports: - - 6379:6379 - volumes: - - ./backend/redis.conf:/etc/redis.conf - networks: - - lkbackend diff --git a/backend/dev_homeserver.yaml b/backend/dev_homeserver.yaml new file mode 100644 index 00000000..b41de45b --- /dev/null +++ b/backend/dev_homeserver.yaml @@ -0,0 +1,51 @@ +server_name: "synapse.localhost" +public_baseurl: http://synapse.localhost:8008/ + +pid_file: /data/homeserver.pid + +listeners: + - port: 8008 + tls: false + type: http + x_forwarded: true + resources: + - names: [client, federation, openid] + compress: false + +database: + name: sqlite3 + args: + database: /data/homeserver.db + +media_store_path: /data/media_store +signing_key_path: "/data/SERVERNAME.signing.key" +trusted_key_servers: + - server_name: "matrix.org" + +experimental_features: + # MSC3266: Room summary API. Used for knocking over federation + msc3266_enabled: true + +# The maximum allowed duration by which sent events can be delayed, as +# per MSC4140. Must be a positive value if set. Defaults to no +# duration (null), which disallows sending delayed events. +max_event_delay_duration: 24h + +# Ratelimiting settings for client actions (registration, login, messaging). +# +# Each ratelimiting configuration is made of two parameters: +# - per_second: number of requests a client can send per second. +# - burst_count: number of requests a client can send before being throttled. + +rc_message: + # This needs to match at least the heart-beat frequency plus a bit of headroom + # Currently the heart-beat is every 5 seconds which translates into a rate of 0.2s + per_second: 0.5 + burst_count: 30 + +# Required for Element Call in Single Page Mode due to on-the-fly user registration +enable_registration: true +enable_registration_without_verification: true + +report_stats: false +serve_server_wellknown: true diff --git a/backend/livekit.yaml b/backend/dev_livekit.yaml similarity index 100% rename from backend/livekit.yaml rename to backend/dev_livekit.yaml diff --git a/backend/tls_localhost_cert.pem b/backend/tls_localhost_cert.pem new file mode 100644 index 00000000..267ce0d5 --- /dev/null +++ b/backend/tls_localhost_cert.pem @@ -0,0 +1,22 @@ +-----BEGIN CERTIFICATE----- +MIIDtzCCAp+gAwIBAgIUCmJjl3HAeLmrPwRg+/OzikW6peQwDQYJKoZIhvcNAQEL +BQAwazELMAkGA1UEBhMCR0IxDzANBgNVBAgMBkxvbmRvbjEPMA0GA1UEBwwGTG9u +ZG9uMQ4wDAYDVQQKDAVBbHJvczEWMBQGA1UECwwNSVQgRGVwYXJ0bWVudDESMBAG +A1UEAwwJbG9jYWxob3N0MB4XDTI0MTEwNDIxNDcwMFoXDTM0MTEwMjIxNDcwMFow +azELMAkGA1UEBhMCR0IxDzANBgNVBAgMBkxvbmRvbjEPMA0GA1UEBwwGTG9uZG9u +MQ4wDAYDVQQKDAVBbHJvczEWMBQGA1UECwwNSVQgRGVwYXJ0bWVudDESMBAGA1UE +AwwJbG9jYWxob3N0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAs368 +ExLSudP8luNoY5UfaPqBSVJUPYBi+JGyd36tyN75p5OI7xSfHTttQxuD4KrExBFP +C8mAhE1eoZPBVBOZJ4FYWBJfMaQnCjeqU+laP36td65kSJYbUYlKYH1WpxEpCdgx +wWOKkP/kPX5YXbYqODx9aBJXgoT3yAJW7AniIoL+eLFnS9Xo86TPqCDBTJU9ocwK +gPIDLhDv60724rhZT1kbGp7ECqRovndoDTQjuws2D3yNMfQ+4rrQGPXHGmP5PcaR +0R7uueB+6APyC7MJbuhbxxg/+DFHrRi3lJsgwxuh2hi/+vWw8zgKlgYIwHFA9X0l +cX0UlQdENMH3bgcGIwIDAQABo1MwUTAdBgNVHQ4EFgQUUFGxw7zoiHXGwRqtagjZ +RPYc85cwHwYDVR0jBBgwFoAUUFGxw7zoiHXGwRqtagjZRPYc85cwDwYDVR0TAQH/ +BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEALokb1z2lu3qW141b2wm14ilZQKCZ +reNNuUR95Uom96FXPH4QVEH+mYTXXJ5UrfNhQYKQFpdE+5S4HL/UqEOxtWvbAHpK +nsLQ62J8m+0+uwiJGqeQpWr03KJgXDAVE9X3XwMlp/+buxSLhc+GIHWuXW56itV2 +jiZJYjhO5SnhhgTWNoVZk93qXuuWEN0yacw7c3Fr1IvFYYYWufbXTk70dbZihPDK +VD141o8tpp6FerSKHNYDqkVFDyTz3DVOhQQJ59zfMre7bFr+PpTTl4vIuGzXEY+E +HPjUSlOzwkCoh5fu7Fs3qG55rJt8akhTEoKpiBTaLucgAjVWNHeci1+Yxg== +-----END CERTIFICATE----- diff --git a/backend/tls_localhost_key.pem b/backend/tls_localhost_key.pem new file mode 100644 index 00000000..32801b3c --- /dev/null +++ b/backend/tls_localhost_key.pem @@ -0,0 +1,28 @@ +-----BEGIN PRIVATE KEY----- +MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCzfrwTEtK50/yW +42hjlR9o+oFJUlQ9gGL4kbJ3fq3I3vmnk4jvFJ8dO21DG4PgqsTEEU8LyYCETV6h +k8FUE5kngVhYEl8xpCcKN6pT6Vo/fq13rmRIlhtRiUpgfVanESkJ2DHBY4qQ/+Q9 +flhdtio4PH1oEleChPfIAlbsCeIigv54sWdL1ejzpM+oIMFMlT2hzAqA8gMuEO/r +TvbiuFlPWRsansQKpGi+d2gNNCO7CzYPfI0x9D7iutAY9ccaY/k9xpHRHu654H7o +A/ILswlu6FvHGD/4MUetGLeUmyDDG6HaGL/69bDzOAqWBgjAcUD1fSVxfRSVB0Q0 +wfduBwYjAgMBAAECggEACTqdSExxzJ+LX5ARFaWyOBSWly2GKqSyR14+aInOklhx +9QgkmfOxJrCf3TvJ8RWhXloW0Aqr8qGDxG0Ixgjn7rG7gskXCey1xn8MNppLS0kj +ztaG+NB3AR89ABm8XdoHsSY45geh3/Ni9I0i1VardGQafUJhgNLTZqjwIodzkBtJ +S/bi4uFk1lGNfuvWQvWqzGXUvd1l1YupV6iA4GfhXlUvrSBZwftLBD6xEvQaSqsA +pHvBxTfMXG4RMAkNPDIElkuQ8++CGi1gIRkJfmrv4OgbbitteMnxqqqGYV0zSNCg +R/5FG6umIV7lDLBHZCSCk7wmfmq2UUvzhHThHy4yMQKBgQDu4TwFJCIcVIj7Wj4r +DUBFvz6Lgbltqb+YAMUBtpiDcAQxDJWmedh6dK04ts5CFAFRlRjjuz2uFn7qlVBm +uye9R7tL+tOv5viqDXU78a4snFywoXub6yzpbxrW8B4W1pdIUvQmhwCcDwvO1V24 +7Vj2vxcM5I9dsk1aCQSi3VY5yQKBgQDAW/VoTRwhU6OUc6sji5Z5dnkMjkP6NZK9 +CSrTWLAMGaLPY+g6fFS7JMNSvfWm/okypD6rcN7p0cxMK3mfFKmMiyPRde0wdrci +sGFjGxM/2d2D7KTMC9iMYwA0K17UIna+UiYPfhR/muIg/dCyjlkKDFs9Z4jk//r1 +91bmznt2iwKBgFdiYXhn/Wprqih4nKFXGZnqGdEixVhObl4GegrkZuo+AeqHdf8O +N5ikMfG7PbyCYPEdH5u/FRMn+4mI0X6jHChroyJqQSHp1jEu9yHUiSicknOyvusM +nsNN932FHRyxp2m3nsSxQhHUlzc0ajKJ8K9iu+XlfmSCIzW6cs25Nh+xAoGBAJro +M0wIdPPdsCj3sUVRvx8XqknTM6kGhaIYBNXoYPWNm5BaC4U15OJEq8sxUOdnqcMP +g6x6m/k+S8C3bh0O/a9Bydl/l0BlCfw0gGjYP/s2ju4Tn272xy/e9iYNGzPIgUmp +TB9D0GwmpZ4d6HgyrD+sTbm4bATGpCp6QhBjDggbAoGBAJVMMtZ4pF8D6mLMRZGR +pQjNPy+MH13XYmDRc/BSF8KJ4yKk3tohr9LSXzxR0SEB43NoL1bHkucZrNjGyL8x +jktnwkoIs96kO2mPrl1TqWkXs5RjGkkSTbAJovIcvkRU31SWap/WzN2kHpmRVcQc +KEFKXT5fUYZCLLWxhgZFlGPp +-----END PRIVATE KEY----- diff --git a/backend/tls_localhost_nginx.conf b/backend/tls_localhost_nginx.conf new file mode 100644 index 00000000..2a593210 --- /dev/null +++ b/backend/tls_localhost_nginx.conf @@ -0,0 +1,40 @@ +server { + listen 80; + listen [::]:80; + listen 443 ssl; + listen 8448 ssl; + listen [::]:443 ssl; + listen [::]:8448 ssl; + server_name synapse.localhost; + ssl_certificate /root/ssl/cert.pem; + ssl_certificate_key /root/ssl/key.pem; + + # well-known config adding rtc_foci backend + # Note well-known is currently not effective due to: + # https://spec.matrix.org/v1.12/client-server-api/#well-known-uri the spec + # says it must be at https://$server_name/... (implied port 443) Hence, we + # currently rely for local development environment on deprecated config.json + # setting for livekit_service_url + location /.well-known/matrix/client { + return 200 '{"m.homeserver": {"base_url": "http://synapse.localhost:8008"}, "org.matrix.msc4143.rtc_foci": [{"type": "livekit", "livekit_service_url": "http://localhost:8080"}]}'; + default_type application/json; + add_header Access-Control-Allow-Origin *; + } + + # Reverse proxy for Matrix Synapse Homeserver + # This is also required for development environment. + # Reason: the lk-jwt-service uses the federation API for the openid token + # verification, which requires TLS + location / { + proxy_pass "http://homeserver:8008"; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $remote_addr; + proxy_set_header X-Forwarded-Proto $scheme; + } + + error_page 500 502 503 504 /50x.html; + +} diff --git a/config/config.devenv.json b/config/config.devenv.json new file mode 100644 index 00000000..b39cc628 --- /dev/null +++ b/config/config.devenv.json @@ -0,0 +1,15 @@ +{ + "default_server_config": { + "m.homeserver": { + "base_url": "http://synapse.localhost:8008", + "server_name": "synapse.localhost" + } + }, + "livekit": { + "livekit_service_url": "http://localhost:8009" + }, + "features": { + "feature_use_device_session_member_events": true + }, + "eula": "https://static.element.io/legal/online-EULA.pdf" +} diff --git a/config/config.sample.json b/config/config.sample.json index 12381a66..80d774c8 100644 --- a/config/config.sample.json +++ b/config/config.sample.json @@ -1,13 +1,10 @@ { "default_server_config": { "m.homeserver": { - "base_url": "https://call.ems.host", - "server_name": "call.ems.host" + "base_url": "http://synapse.localhost:8008", + "server_name": "synapse.localhost" } }, - "livekit": { - "livekit_service_url": "http://localhost:7881" - }, "features": { "feature_use_device_session_member_events": true }, diff --git a/config/nginx.conf b/config/nginx.conf index 5dc69b2f..ca4ac4c6 100644 --- a/config/nginx.conf +++ b/config/nginx.conf @@ -13,7 +13,7 @@ server { # and may or may not bear any resemblance to when the resource changed add_header Last-Modified ""; - try_files $uri /$uri /index.html; + try_files $uri $uri/ /index.html; } # assets can be cached because they have hashed filenames diff --git a/dev-backend-docker-compose.yml b/dev-backend-docker-compose.yml new file mode 100644 index 00000000..dcfb8d66 --- /dev/null +++ b/dev-backend-docker-compose.yml @@ -0,0 +1,86 @@ +networks: + ecbackend: + +services: + auth-service: + image: ghcr.io/element-hq/lk-jwt-service:latest-ci + hostname: auth-server + environment: + - LK_JWT_PORT=8080 + - LIVEKIT_URL=ws://localhost:7880 + - LIVEKIT_KEY=devkey + - LIVEKIT_SECRET=secret + # If the configured homeserver runs on localhost, it'll probably be using + # a self-signed certificate + - LIVEKIT_INSECURE_SKIP_VERIFY_TLS=YES_I_KNOW_WHAT_I_AM_DOING + deploy: + restart_policy: + condition: on-failure + ports: + # HOST_PORT:CONTAINER_PORT + - 8009:8080 + networks: + - ecbackend + + livekit: + image: livekit/livekit-server:latest + command: --dev --config /etc/livekit.yaml + restart: unless-stopped + # The SFU seems to work far more reliably when we let it share the host + # network rather than opening specific ports (but why?? we're not missing + # any…) + ports: + # HOST_PORT:CONTAINER_PORT + - 7880:7880/tcp + - 7881:7881/tcp + - 7882:7882/tcp + - 50100-50200:50100-50200/udp + volumes: + - ./backend/dev_livekit.yaml:/etc/livekit.yaml:Z + networks: + - ecbackend + + redis: + image: redis:6-alpine + command: redis-server /etc/redis.conf + ports: + # HOST_PORT:CONTAINER_PORT + - 6379:6379 + volumes: + - ./backend/redis.conf:/etc/redis.conf:Z + networks: + - ecbackend + + synapse: + hostname: homeserver + image: docker.io/matrixdotorg/synapse:latest + environment: + - SYNAPSE_CONFIG_PATH=/data/cfg/homeserver.yaml + # Needed for rootless podman-compose such that the uid/gid mapping does + # fit local user uid. If the container runs as root (uid 0) it is fine as + # it actually maps to your non-root user on the host (e.g. 1000). + # Otherwise uid mapping will not match your non-root user. + - UID=0 + - GID=0 + volumes: + - ./backend/synapse_tmp:/data:Z + - ./backend/dev_homeserver.yaml:/data/cfg/homeserver.yaml:Z + networks: + - ecbackend + + nginx: + # openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout tls_localhost_key.pem -out tls_localhost_cert.pem -subj "/C=GB/ST=London/L=London/O=Alros/OU=IT Department/CN=localhost" + hostname: synapse.localhost + image: nginx:latest + volumes: + - ./backend/tls_localhost_nginx.conf:/etc/nginx/conf.d/default.conf:Z + - ./backend/tls_localhost_key.pem:/root/ssl/key.pem:Z + - ./backend/tls_localhost_cert.pem:/root/ssl/cert.pem:Z + ports: + # HOST_PORT:CONTAINER_PORT + - "8008:80" + - "4443:443" + depends_on: + - synapse + networks: + - ecbackend diff --git a/package.json b/package.json index 7fdeb803..5f54702f 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "i18n:check": "i18next --fail-on-warnings --fail-on-update", "test": "vitest", "test:coverage": "vitest --coverage", - "backend": "docker-compose -f backend-docker-compose.yml up" + "backend": "docker-compose -f dev-backend-docker-compose.yml up" }, "devDependencies": { "@babel/core": "^7.16.5", @@ -25,6 +25,7 @@ "@babel/preset-react": "^7.22.15", "@babel/preset-typescript": "^7.23.0", "@formatjs/intl-durationformat": "^0.6.1", + "@formatjs/intl-segmenter": "^11.7.3", "@livekit/components-core": "^0.11.0", "@livekit/components-react": "^2.0.0", "@opentelemetry/api": "^1.4.0", @@ -57,8 +58,8 @@ "@typescript-eslint/eslint-plugin": "^8.0.0", "@typescript-eslint/parser": "^8.0.0", "@use-gesture/react": "^10.2.11", - "@vector-im/compound-design-tokens": "^1.0.0", - "@vector-im/compound-web": "^6.0.0", + "@vector-im/compound-design-tokens": "^1.9.1", + "@vector-im/compound-web": "element-hq/compound-web#46cf2d94d9c9b6d25e80ef0e785f3a929ed040ea", "@vitejs/plugin-basic-ssl": "^1.0.1", "@vitejs/plugin-react": "^4.0.1", "@vitest/coverage-v8": "^2.0.5", @@ -86,7 +87,7 @@ "livekit-client": "^2.5.7", "lodash": "^4.17.21", "loglevel": "^1.9.1", - "matrix-js-sdk": "matrix-org/matrix-js-sdk#e11f9defb9b9603ee2d982a8fd2b0c9577fbf48c", + "matrix-js-sdk": "matrix-org/matrix-js-sdk#6971e7bebaad643c233e5057da7a0d42441c0789", "matrix-widget-api": "^1.8.2", "normalize.css": "^8.0.1", "observable-hooks": "^4.2.3", diff --git a/public/locales/de/app.json b/public/locales/de/app.json index 004983c2..ba88955f 100644 --- a/public/locales/de/app.json +++ b/public/locales/de/app.json @@ -4,11 +4,17 @@ }, "action": { "close": "Schließen", + "close_search": "Suche beenden", "copy_link": "Link kopieren", "edit": "Bearbeiten", "go": "Los geht’s", "invite": "Einladen", + "lower_hand": "Handmeldung zurücknehmen", "no": "Nein", + "open_search": "Suchen", + "pick_reaction": "Reaktion auswählen", + "raise_hand": "Handmeldung", + "raise_hand_or_send_reaction": "Handmeldung oder Reaktion senden", "register": "Registrieren", "remove": "Entfernen", "sign_in": "Anmelden", @@ -55,8 +61,10 @@ "password": "Passwort", "preferences": "Einstellungen", "profile": "Profil", - "raise_hand": "Hand heben", + "reaction": "Reaktion", + "search": "Suche", "settings": "Einstellungen", + "something_went_wrong": "Etwas ist schief gelaufen", "unencrypted": "Nicht verschlüsselt", "username": "Benutzername", "video": "Video" @@ -64,12 +72,6 @@ "crypto_version": "Krypto-Version:{{version}}", "device_id": "Geräte-ID: {{id}}", "disconnected_banner": "Die Verbindung zum Server wurde getrennt.", - "e2ee_encryption_status": { - "connecting": "Verbinden...", - "key_invalid": "Der Medien-Krypto-Schlüssel für diese Person ist ungültig", - "key_missing": "Aktueller Medien-Krypto-Schlüssel für diese Person noch nicht erhalten", - "password_invalid": "Diese Person verwendet ein anderes Passwort, sodass Sie nicht mit ihr kommunizieren können" - }, "full_screen_view_description": "<0>Übermittelte Problemberichte helfen uns, Fehler zu beheben.", "full_screen_view_h1": "<0>Hoppla, etwas ist schiefgelaufen.", "group_call_loader": { @@ -126,6 +128,7 @@ "rageshake_sending": "Senden …", "rageshake_sending_logs": "Sende Debug-Protokolle …", "rageshake_sent": "Danke!", + "reaction_search": "Reaktionen suchen...", "recaptcha_caption": "Diese Seite wird durch reCAPTCHA geschützt und es gelten Googles <2>Datenschutzerklärung und <6>Nutzungsbedingungen. <9>Mit einem Klick auf „Registrieren“ akzeptierst du unseren <2>Endbenutzer-Lizenzvertrag (EULA)", "recaptcha_dismissed": "Recaptcha abgelehnt", "recaptcha_not_loaded": "Recaptcha nicht geladen", @@ -141,6 +144,10 @@ "room_auth_view_eula_caption": "Mit einem Klick auf „Weiter“ akzeptierst du unseren <2>Endbenutzer-Lizenzvertrag (EULA)", "screenshare_button_label": "Bildschirm teilen", "settings": { + "audio_tab": { + "effect_volume_description": "Lautstärke anpassen, mit der Reaktionen und Handmeldungen abgespielt werden", + "effect_volume_label": "Lautstärke der Soundeffekte" + }, "developer_settings_label": "Entwicklereinstellungen", "developer_settings_label_description": "Zeige die Entwicklereinstellungen im Einstellungsfenster.", "developer_tab_title": "Entwickler", @@ -153,10 +160,17 @@ "feedback_tab_title": "Rückmeldung", "more_tab_title": "Mehr", "opt_in_description": "<0><1>Du kannst deine Zustimmung durch Abwählen dieses Kästchens zurückziehen. Falls du dich aktuell in einem Anruf befindest, wird diese Einstellung nach dem Ende des Anrufs wirksam.", + "preferences_tab": { + "reactions_play_sound_description": "Einen Soundeffekt abspielen, wenn jemand eine Reaktion sendet", + "reactions_play_sound_label": "Reaktionstöne abspielen", + "reactions_show_description": "Reaktionen anzeigen", + "reactions_show_label": "Zeige eine Animation, wenn jemand eine Reaktion sendet.", + "reactions_title": "Reaktionen" + }, "preferences_tab_body": "Hier können zusätzliche Optionen für individuelle Anforderungen eingestellt werden", "preferences_tab_h4": "Einstellungen", - "preferences_tab_show_hand_raised_timer_description": "Einen Timer anzeigen, wenn ein Teilnehmer seine Hand hebt", - "preferences_tab_show_hand_raised_timer_label": "Dauer des Handhebens anzeigen", + "preferences_tab_show_hand_raised_timer_description": "Einen Timer zur Handmeldung anzeigen", + "preferences_tab_show_hand_raised_timer_label": "Dauer der Handmeldung anzeigen", "speaker_device_selection_label": "Lautsprecher" }, "star_rating_input_label_one": "{{count}} Stern", diff --git a/public/locales/en-GB/app.json b/public/locales/en-GB/app.json index 467824c3..a0e41746 100644 --- a/public/locales/en-GB/app.json +++ b/public/locales/en-GB/app.json @@ -4,11 +4,17 @@ }, "action": { "close": "Close", + "close_search": "Close search", "copy_link": "Copy link", "edit": "Edit", "go": "Go", "invite": "Invite", + "lower_hand": "Lower hand", "no": "No", + "open_search": "Open search", + "pick_reaction": "Pick reaction", + "raise_hand": "Raise hand", + "raise_hand_or_send_reaction": "Raise hand or send reaction", "register": "Register", "remove": "Remove", "sign_in": "Sign in", @@ -55,8 +61,10 @@ "password": "Password", "preferences": "Preferences", "profile": "Profile", - "raise_hand": "Raise hand", + "reaction": "Reaction", + "search": "Search", "settings": "Settings", + "something_went_wrong": "Something went wrong", "unencrypted": "Not encrypted", "username": "Username", "video": "Video" @@ -64,12 +72,6 @@ "crypto_version": "Crypto version: {{version}}", "device_id": "Device ID: {{id}}", "disconnected_banner": "Connectivity to the server has been lost.", - "e2ee_encryption_status": { - "connecting": "Connecting...", - "key_invalid": "The end-to-end encrypted media key for this person is invalid", - "key_missing": "You haven't received the current end-to-end encrypted media key for this person yet", - "password_invalid": "This person is using a different password so you won't be able to communicate with them" - }, "full_screen_view_description": "<0>Submitting debug logs will help us track down the problem.", "full_screen_view_h1": "<0>Oops, something's gone wrong.", "group_call_loader": { @@ -126,6 +128,7 @@ "rageshake_sending": "Sending…", "rageshake_sending_logs": "Sending debug logs…", "rageshake_sent": "Thanks!", + "reaction_search": "Search reactions…", "recaptcha_caption": "This site is protected by ReCAPTCHA and the Google <2>Privacy Policy and <6>Terms of Service apply.<9>By clicking \"Register\", you agree to our <12>End User Licensing Agreement (EULA)", "recaptcha_dismissed": "Recaptcha dismissed", "recaptcha_not_loaded": "Recaptcha not loaded", @@ -141,6 +144,10 @@ "room_auth_view_eula_caption": "By clicking \"Continue\", you agree to our <2>End User Licensing Agreement (EULA)", "screenshare_button_label": "Share screen", "settings": { + "audio_tab": { + "effect_volume_description": "Adjust the volume at which reactions and hand raised effects play", + "effect_volume_label": "Sound effect volume" + }, "developer_settings_label": "Developer Settings", "developer_settings_label_description": "Expose developer settings in the settings window.", "developer_tab_title": "Developer", @@ -153,6 +160,13 @@ "feedback_tab_title": "Feedback", "more_tab_title": "More", "opt_in_description": "<0><1>You may withdraw consent by unchecking this box. If you are currently in a call, this setting will take effect at the end of the call.", + "preferences_tab": { + "reactions_play_sound_description": "Play a sound effect when anyone sends a reaction into a call.", + "reactions_play_sound_label": "Play reaction sounds", + "reactions_show_description": "Show reactions", + "reactions_show_label": "Show an animation when anyone sends a reaction.", + "reactions_title": "Reactions" + }, "preferences_tab_body": "Here you can configure extra options for an improved experience", "preferences_tab_h4": "Preferences", "preferences_tab_show_hand_raised_timer_description": "Show a timer when a participant raises their hand", diff --git a/src/@types/matrix-js-sdk.d.ts b/src/@types/matrix-js-sdk.d.ts new file mode 100644 index 00000000..dc27b1ef --- /dev/null +++ b/src/@types/matrix-js-sdk.d.ts @@ -0,0 +1,18 @@ +/* +Copyright 2024 New Vector Ltd. + +SPDX-License-Identifier: AGPL-3.0-only +Please see LICENSE in the repository root for full details. +*/ + +import { + ElementCallReactionEventType, + ECallReactionEventContent, +} from "../reactions"; + +// Extend Matrix JS SDK types via Typescript declaration merging to support unspecced event fields and types +declare module "matrix-js-sdk/src/types" { + export interface TimelineEvents { + [ElementCallReactionEventType]: ECallReactionEventContent; + } +} diff --git a/src/Modal.test.tsx b/src/Modal.test.tsx new file mode 100644 index 00000000..41bd7bbe --- /dev/null +++ b/src/Modal.test.tsx @@ -0,0 +1,73 @@ +/* +Copyright 2024 New Vector Ltd. + +SPDX-License-Identifier: AGPL-3.0-only +Please see LICENSE in the repository root for full details. +*/ + +import { expect, test } from "vitest"; +import { render } from "@testing-library/react"; +import { ReactNode, useState } from "react"; +import { afterEach } from "node:test"; +import userEvent from "@testing-library/user-event"; + +import { Modal } from "./Modal"; + +const originalMatchMedia = window.matchMedia; +afterEach(() => { + window.matchMedia = originalMatchMedia; +}); + +test("that nothing is rendered when the modal is closed", () => { + const { queryByRole } = render( + +

This is the content.

+
, + ); + expect(queryByRole("dialog")).toBeNull(); +}); + +test("the content is rendered when the modal is open", () => { + const { queryByRole } = render( + +

This is the content.

+
, + ); + expect(queryByRole("dialog")).toMatchSnapshot(); +}); + +test("the modal can be closed by clicking the close button", async () => { + function ModalFn(): ReactNode { + const [isOpen, setOpen] = useState(true); + return ( + setOpen(false)}> +

This is the content.

+
+ ); + } + const user = userEvent.setup(); + const { queryByRole, getByRole } = render(); + await user.click(getByRole("button", { name: "action.close" })); + expect(queryByRole("dialog")).toBeNull(); +}); + +test("the modal renders as a drawer in mobile viewports", () => { + window.matchMedia = function (query): MediaQueryList { + return { + matches: query.includes("hover: none"), + addEventListener(): MediaQueryList { + return this as MediaQueryList; + }, + removeEventListener(): MediaQueryList { + return this as MediaQueryList; + }, + } as unknown as MediaQueryList; + }; + + const { queryByRole } = render( + +

This is the content.

+
, + ); + expect(queryByRole("dialog")).toMatchSnapshot(); +}); diff --git a/src/Modal.tsx b/src/Modal.tsx index deef7635..63d5c50a 100644 --- a/src/Modal.tsx +++ b/src/Modal.tsx @@ -27,8 +27,21 @@ import { useMediaQuery } from "./useMediaQuery"; export interface Props { title: string; + /** + * Hide the modal header. Used for smaller popups where the context is readily apparent. + * A title should still be specified for users using assistive technology. + */ + hideHeader?: boolean; children: ReactNode; className?: string; + /** + * Class name to be used when in drawer mode (touchscreen). + */ + classNameDrawer?: string; + /** + * Class name to be used when in modal mode (desktop). + */ + classNameModal?: string; /** * The controlled open state of the modal. */ @@ -54,8 +67,11 @@ export interface Props { */ export const Modal: FC = ({ title, + hideHeader, children, className, + classNameDrawer, + classNameModal, open, onDismiss, tabbed, @@ -84,11 +100,13 @@ export const Modal: FC = ({ = ({ ); } else { + const titleNode = ( + + + {title} + + + ); + const header = ( +
+ {titleNode} + {onDismiss !== undefined && ( + + + + )} +
+ ); + return ( - {/* Suppress the warning about there being no description; the modal - has an accessible title */} - + = ({ )} >
-
- - - {title} - - - {onDismiss !== undefined && ( - - - - )} -
+ {!hideHeader ? header : null} + {hideHeader ? ( + {titleNode} + ) : null}
{children}
diff --git a/src/__snapshots__/Modal.test.tsx.snap b/src/__snapshots__/Modal.test.tsx.snap new file mode 100644 index 00000000..6b7091e5 --- /dev/null +++ b/src/__snapshots__/Modal.test.tsx.snap @@ -0,0 +1,75 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`the content is rendered when the modal is open 1`] = ` + +`; + +exports[`the modal renders as a drawer in mobile viewports 1`] = ` +