noordstar/elm-matrix-sdk-beta/3.4.0

NOTE: the latest version is 3.6.1

Matrix.Settings

The Matrix Vault has lots of configurable variables that you rarely want to interact with. Usually, you configure these variables only when creating a new Vault, or when a user explicitly changes one of their preferred settings.

Access token

The Vault is able to log in on its own, but sometimes you would rather have the Vault use an access token than log in to get one on its own. For this case, you can use this option to insert an access token into the Vault.

As long as the access token remains valid, the Vault will use this provided access token.

setAccessToken : String -> Vault -> Vault

Insert a suggested access token.

removeAccessToken : Vault -> Vault

Remove an access token that has been inserted using the setAccessToken function.

This should generally not be necessary, but it can be nice security-wise.

Device name

The default device name that is being communicated with the Matrix API.

This is mostly useful for users who are logged in with multiple sessions. They will see device names like "Element for Android" or "Element on iOS". For the Elm SDK, they will by default see the Elm SDK with its version included. If you are writing a custom client, however, you are free to change this to something more meaningful to the user.

getDeviceName : Vault -> String

Determine the device name.

setDeviceName : String -> Vault -> Vault

Override the device name.

Sync time

Whenever the Matrix API has nothing new to report, the Elm SDK is kept on hold until something new happens. The syncTime indicates a timeout to how long the Elm SDK tolerates being held on hold.

  • ↗️ A high value is good because it significantly reduces traffic between the user and the homeserver.
  • ↘️ A low value is good because it reduces the risk of the connection ending abruptly or unexpectedly.

Nowadays, most libraries use 30 seconds as the standard, as does the Elm SDK. The value is in miliseconds, so it is set at 30,000.

getSyncTime : Vault -> Int

Determine the sync timeout value.

setSyncTime : Int -> Vault -> Vault

Override the sync timeout value.

Password

When a Vault wants to access the Matrix API, it needs an access token. This can either be provided directly, or the Vault can get one itself by using a password to log in.

setPassword : String -> Vault -> Vault

Set a password for the given user.

For security reasons, it is not possible to read whatever password is stored in the Vault. An attacker with access to the memory might be able to find it, however, so the Vault offers ways to remove the password from memory.

removePassword : Vault -> Vault

Remove a password that is stored in the Matrix Vault.

removePasswordOnLogin : Bool -> Vault -> Vault

Remove password from the Vault as soon as a valid access token has been received from the Matrix API.