Skip to content

ChiaChat/matrix-kt

 
 

Repository files navigation

GitHub license

Matrix in Kotlin

Kotlin multiplatform libraries for Matrix.

  • Http Client
  • olm
  • SDK

Join the support room at #matrix-kt:matrix.org.

Supported platforms

  • JVM
  • Android
  • JavaScript
  • LinuxX64
  • MingwX64
  • MacosX64
  • IosArm32
  • IosArm64
  • IosX64

Usage

repositories {
    maven("https://maven.pkg.github.com/Dominaezzz/matrix-kt") {
        credentials {
            username = System.getenv("GITHUB_USER") // Your GitHub username.
            password = System.getenv("GITHUB_TOKEN") // A GitHub token with `read:packages`.
        }
    }
}

dependencies {
    implementation("io.github.matrixkt:client:$version")
    implementation("io.github.matrixkt:olm:$version")
}

Sample

Client

val client = HttpClient(Apache) {
    MatrixConfig(baseUrl = Url("matrix.org"))
}
val accessToken = "Super secure Token"

val roomId = "!QtykxKocfZaZOUrTwp:matrix.org"

val response = client.rpc(SendMessage(
    SendMessage.Url(roomId, "m.room.message", "nonce"),
    buildJsonObject {
        put("msgtype", "m.text")
        put("body", "Hello World!")
    }
), accessToken)
val eventId = response.eventId

client.rpc(RedactEvent(
    RedactEvent.Url(roomId, eventId, "nonce2"),
    RedactEvent.Body(reason = "Was a bot!")
), accessToken)

Olm

val account = Account()
upload(account.identityKeys)
val signature = account.sign("""{"key":"super secure key for security things"}""")

val session = Session.createInboundSession(account, "PREKEY message")
val message = session.decrypt(Message.PreKey("oun02024f=ocnaowincd;53tnv024ok/7u"))

session.clear()
account.clear()

Packages

No packages published

Languages

  • Kotlin 100.0%