Merge pull request #5744 from vector-im/feature/bma/dokka
Set up dokka to generate SDK documentation and cleanup the API
This commit is contained in:
commit
5075775c56
|
@ -22,6 +22,7 @@ buildscript {
|
||||||
classpath 'com.google.android.gms:oss-licenses-plugin:0.10.5'
|
classpath 'com.google.android.gms:oss-licenses-plugin:0.10.5'
|
||||||
classpath "com.likethesalad.android:stem-plugin:2.0.0"
|
classpath "com.likethesalad.android:stem-plugin:2.0.0"
|
||||||
classpath 'org.owasp:dependency-check-gradle:7.0.4.1'
|
classpath 'org.owasp:dependency-check-gradle:7.0.4.1'
|
||||||
|
classpath "org.jetbrains.dokka:dokka-gradle-plugin:1.6.10"
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
// in the individual module build.gradle files
|
// in the individual module build.gradle files
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Setup Dokka to be able to generate documentation of the SDK module. Run `./gradlew matrix-sdk-android:dokkaHtml` to do it.
|
|
@ -0,0 +1,3 @@
|
||||||
|
A lot of classes which were exposed to the clients and were located in the package `org.matrix.android.sdk.internal` have been moved to the package `org.matrix.android.sdk.api`.
|
||||||
|
All the classes which are in the package `org.matrix.android.sdk.internal` should now be declared `internal`.
|
||||||
|
Some unused code and classes have been removed.
|
|
@ -59,6 +59,9 @@ ext.groups = [
|
||||||
'com.fasterxml',
|
'com.fasterxml',
|
||||||
'com.fasterxml.jackson',
|
'com.fasterxml.jackson',
|
||||||
'com.fasterxml.jackson.core',
|
'com.fasterxml.jackson.core',
|
||||||
|
'com.fasterxml.jackson.dataformat',
|
||||||
|
'com.fasterxml.jackson.module',
|
||||||
|
'com.fasterxml.woodstox',
|
||||||
'com.gabrielittner.threetenbp',
|
'com.gabrielittner.threetenbp',
|
||||||
'com.getkeepsafe.relinker',
|
'com.getkeepsafe.relinker',
|
||||||
'com.github.bumptech.glide',
|
'com.github.bumptech.glide',
|
||||||
|
@ -157,12 +160,14 @@ ext.groups = [
|
||||||
'org.codehaus',
|
'org.codehaus',
|
||||||
'org.codehaus.groovy',
|
'org.codehaus.groovy',
|
||||||
'org.codehaus.mojo',
|
'org.codehaus.mojo',
|
||||||
|
'org.codehaus.woodstox',
|
||||||
'org.eclipse.ee4j',
|
'org.eclipse.ee4j',
|
||||||
'org.ec4j.core',
|
'org.ec4j.core',
|
||||||
'org.glassfish.jaxb',
|
'org.glassfish.jaxb',
|
||||||
'org.hamcrest',
|
'org.hamcrest',
|
||||||
'org.jacoco',
|
'org.jacoco',
|
||||||
'org.jetbrains',
|
'org.jetbrains',
|
||||||
|
'org.jetbrains.dokka',
|
||||||
'org.jetbrains.intellij.deps',
|
'org.jetbrains.intellij.deps',
|
||||||
'org.jetbrains.kotlin',
|
'org.jetbrains.kotlin',
|
||||||
'org.jetbrains.kotlinx',
|
'org.jetbrains.kotlinx',
|
||||||
|
@ -208,4 +213,3 @@ ext.groups = [
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,6 @@ import kotlinx.coroutines.channels.produce
|
||||||
import kotlinx.coroutines.coroutineScope
|
import kotlinx.coroutines.coroutineScope
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.flow.collect
|
|
||||||
import kotlinx.coroutines.flow.consumeAsFlow
|
import kotlinx.coroutines.flow.consumeAsFlow
|
||||||
import kotlinx.coroutines.flow.flow
|
import kotlinx.coroutines.flow.flow
|
||||||
import kotlinx.coroutines.isActive
|
import kotlinx.coroutines.isActive
|
||||||
|
|
|
@ -21,7 +21,15 @@ package name.fraser.neil.plaintext;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.URLDecoder;
|
import java.net.URLDecoder;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.util.*;
|
import java.util.ArrayDeque;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Deque;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.ListIterator;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,9 @@ import org.matrix.android.sdk.api.query.QueryStringValue
|
||||||
import org.matrix.android.sdk.api.session.Session
|
import org.matrix.android.sdk.api.session.Session
|
||||||
import org.matrix.android.sdk.api.session.accountdata.UserAccountDataEvent
|
import org.matrix.android.sdk.api.session.accountdata.UserAccountDataEvent
|
||||||
import org.matrix.android.sdk.api.session.crypto.crosssigning.MXCrossSigningInfo
|
import org.matrix.android.sdk.api.session.crypto.crosssigning.MXCrossSigningInfo
|
||||||
|
import org.matrix.android.sdk.api.session.crypto.crosssigning.PrivateKeysInfo
|
||||||
|
import org.matrix.android.sdk.api.session.crypto.model.CryptoDeviceInfo
|
||||||
|
import org.matrix.android.sdk.api.session.crypto.model.DeviceInfo
|
||||||
import org.matrix.android.sdk.api.session.group.GroupSummaryQueryParams
|
import org.matrix.android.sdk.api.session.group.GroupSummaryQueryParams
|
||||||
import org.matrix.android.sdk.api.session.group.model.GroupSummary
|
import org.matrix.android.sdk.api.session.group.model.GroupSummary
|
||||||
import org.matrix.android.sdk.api.session.identity.ThreePid
|
import org.matrix.android.sdk.api.session.identity.ThreePid
|
||||||
|
@ -39,9 +42,6 @@ import org.matrix.android.sdk.api.session.user.model.User
|
||||||
import org.matrix.android.sdk.api.session.widgets.model.Widget
|
import org.matrix.android.sdk.api.session.widgets.model.Widget
|
||||||
import org.matrix.android.sdk.api.util.Optional
|
import org.matrix.android.sdk.api.util.Optional
|
||||||
import org.matrix.android.sdk.api.util.toOptional
|
import org.matrix.android.sdk.api.util.toOptional
|
||||||
import org.matrix.android.sdk.internal.crypto.model.CryptoDeviceInfo
|
|
||||||
import org.matrix.android.sdk.internal.crypto.model.rest.DeviceInfo
|
|
||||||
import org.matrix.android.sdk.internal.crypto.store.PrivateKeysInfo
|
|
||||||
|
|
||||||
class FlowSession(private val session: Session) {
|
class FlowSession(private val session: Session) {
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ apply plugin: 'kotlin-android'
|
||||||
apply plugin: 'kotlin-kapt'
|
apply plugin: 'kotlin-kapt'
|
||||||
apply plugin: 'kotlin-parcelize'
|
apply plugin: 'kotlin-parcelize'
|
||||||
apply plugin: 'realm-android'
|
apply plugin: 'realm-android'
|
||||||
|
apply plugin: "org.jetbrains.dokka"
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
|
@ -73,6 +74,10 @@ android {
|
||||||
|
|
||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
jvmTarget = "11"
|
jvmTarget = "11"
|
||||||
|
freeCompilerArgs += [
|
||||||
|
// Disabled for now, there are too many errors. Could be handled in another dedicated PR
|
||||||
|
// '-Xexplicit-api=strict', // or warning
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
|
|
|
@ -27,8 +27,12 @@ import org.matrix.android.sdk.api.auth.UIABaseAuth
|
||||||
import org.matrix.android.sdk.api.auth.UserInteractiveAuthInterceptor
|
import org.matrix.android.sdk.api.auth.UserInteractiveAuthInterceptor
|
||||||
import org.matrix.android.sdk.api.auth.UserPasswordAuth
|
import org.matrix.android.sdk.api.auth.UserPasswordAuth
|
||||||
import org.matrix.android.sdk.api.auth.registration.RegistrationFlowResponse
|
import org.matrix.android.sdk.api.auth.registration.RegistrationFlowResponse
|
||||||
|
import org.matrix.android.sdk.api.crypto.MXCRYPTO_ALGORITHM_MEGOLM
|
||||||
|
import org.matrix.android.sdk.api.crypto.MXCRYPTO_ALGORITHM_MEGOLM_BACKUP
|
||||||
import org.matrix.android.sdk.api.extensions.orFalse
|
import org.matrix.android.sdk.api.extensions.orFalse
|
||||||
import org.matrix.android.sdk.api.session.Session
|
import org.matrix.android.sdk.api.session.Session
|
||||||
|
import org.matrix.android.sdk.api.session.crypto.keysbackup.MegolmBackupAuthData
|
||||||
|
import org.matrix.android.sdk.api.session.crypto.keysbackup.MegolmBackupCreationInfo
|
||||||
import org.matrix.android.sdk.api.session.crypto.verification.IncomingSasVerificationTransaction
|
import org.matrix.android.sdk.api.session.crypto.verification.IncomingSasVerificationTransaction
|
||||||
import org.matrix.android.sdk.api.session.crypto.verification.OutgoingSasVerificationTransaction
|
import org.matrix.android.sdk.api.session.crypto.verification.OutgoingSasVerificationTransaction
|
||||||
import org.matrix.android.sdk.api.session.crypto.verification.VerificationMethod
|
import org.matrix.android.sdk.api.session.crypto.verification.VerificationMethod
|
||||||
|
@ -42,10 +46,6 @@ import org.matrix.android.sdk.api.session.room.model.RoomSummary
|
||||||
import org.matrix.android.sdk.api.session.room.model.create.CreateRoomParams
|
import org.matrix.android.sdk.api.session.room.model.create.CreateRoomParams
|
||||||
import org.matrix.android.sdk.api.session.room.roomSummaryQueryParams
|
import org.matrix.android.sdk.api.session.room.roomSummaryQueryParams
|
||||||
import org.matrix.android.sdk.api.util.Optional
|
import org.matrix.android.sdk.api.util.Optional
|
||||||
import org.matrix.android.sdk.internal.crypto.MXCRYPTO_ALGORITHM_MEGOLM
|
|
||||||
import org.matrix.android.sdk.internal.crypto.MXCRYPTO_ALGORITHM_MEGOLM_BACKUP
|
|
||||||
import org.matrix.android.sdk.internal.crypto.keysbackup.model.MegolmBackupAuthData
|
|
||||||
import org.matrix.android.sdk.internal.crypto.keysbackup.model.MegolmBackupCreationInfo
|
|
||||||
import java.util.UUID
|
import java.util.UUID
|
||||||
import kotlin.coroutines.Continuation
|
import kotlin.coroutines.Continuation
|
||||||
import kotlin.coroutines.resume
|
import kotlin.coroutines.resume
|
||||||
|
|
|
@ -26,6 +26,7 @@ import org.matrix.android.sdk.internal.di.MatrixModule
|
||||||
import org.matrix.android.sdk.internal.di.MatrixScope
|
import org.matrix.android.sdk.internal.di.MatrixScope
|
||||||
import org.matrix.android.sdk.internal.di.NetworkModule
|
import org.matrix.android.sdk.internal.di.NetworkModule
|
||||||
import org.matrix.android.sdk.internal.raw.RawModule
|
import org.matrix.android.sdk.internal.raw.RawModule
|
||||||
|
import org.matrix.android.sdk.internal.settings.SettingsModule
|
||||||
import org.matrix.android.sdk.internal.util.system.SystemModule
|
import org.matrix.android.sdk.internal.util.system.SystemModule
|
||||||
|
|
||||||
@Component(modules = [
|
@Component(modules = [
|
||||||
|
@ -34,6 +35,7 @@ import org.matrix.android.sdk.internal.util.system.SystemModule
|
||||||
NetworkModule::class,
|
NetworkModule::class,
|
||||||
AuthModule::class,
|
AuthModule::class,
|
||||||
RawModule::class,
|
RawModule::class,
|
||||||
|
SettingsModule::class,
|
||||||
SystemModule::class
|
SystemModule::class
|
||||||
])
|
])
|
||||||
@MatrixScope
|
@MatrixScope
|
||||||
|
|
|
@ -25,10 +25,10 @@ import org.junit.FixMethodOrder
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.junit.runners.MethodSorters
|
import org.junit.runners.MethodSorters
|
||||||
|
import org.matrix.android.sdk.api.session.crypto.attachments.toElementToDecrypt
|
||||||
|
import org.matrix.android.sdk.api.session.crypto.model.EncryptedFileInfo
|
||||||
|
import org.matrix.android.sdk.api.session.crypto.model.EncryptedFileKey
|
||||||
import org.matrix.android.sdk.internal.crypto.attachments.MXEncryptedAttachments
|
import org.matrix.android.sdk.internal.crypto.attachments.MXEncryptedAttachments
|
||||||
import org.matrix.android.sdk.internal.crypto.attachments.toElementToDecrypt
|
|
||||||
import org.matrix.android.sdk.internal.crypto.model.rest.EncryptedFileInfo
|
|
||||||
import org.matrix.android.sdk.internal.crypto.model.rest.EncryptedFileKey
|
|
||||||
import java.io.ByteArrayOutputStream
|
import java.io.ByteArrayOutputStream
|
||||||
import java.io.InputStream
|
import java.io.InputStream
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,13 @@ import org.junit.runners.MethodSorters
|
||||||
import org.matrix.android.sdk.InstrumentedTest
|
import org.matrix.android.sdk.InstrumentedTest
|
||||||
import org.matrix.android.sdk.api.session.Session
|
import org.matrix.android.sdk.api.session.Session
|
||||||
import org.matrix.android.sdk.api.session.crypto.MXCryptoError
|
import org.matrix.android.sdk.api.session.crypto.MXCryptoError
|
||||||
|
import org.matrix.android.sdk.api.session.crypto.keysbackup.KeysVersion
|
||||||
|
import org.matrix.android.sdk.api.session.crypto.keysbackup.KeysVersionResult
|
||||||
|
import org.matrix.android.sdk.api.session.crypto.keysbackup.MegolmBackupCreationInfo
|
||||||
|
import org.matrix.android.sdk.api.session.crypto.model.ImportRoomKeysResult
|
||||||
|
import org.matrix.android.sdk.api.session.crypto.model.OlmDecryptionResult
|
||||||
import org.matrix.android.sdk.api.session.events.model.EventType
|
import org.matrix.android.sdk.api.session.events.model.EventType
|
||||||
|
import org.matrix.android.sdk.api.session.events.model.content.EncryptedEventContent
|
||||||
import org.matrix.android.sdk.api.session.events.model.toModel
|
import org.matrix.android.sdk.api.session.events.model.toModel
|
||||||
import org.matrix.android.sdk.api.session.room.Room
|
import org.matrix.android.sdk.api.session.room.Room
|
||||||
import org.matrix.android.sdk.api.session.room.failure.JoinRoomFailure
|
import org.matrix.android.sdk.api.session.room.failure.JoinRoomFailure
|
||||||
|
@ -43,12 +49,6 @@ import org.matrix.android.sdk.common.CryptoTestHelper
|
||||||
import org.matrix.android.sdk.common.SessionTestParams
|
import org.matrix.android.sdk.common.SessionTestParams
|
||||||
import org.matrix.android.sdk.common.TestConstants
|
import org.matrix.android.sdk.common.TestConstants
|
||||||
import org.matrix.android.sdk.common.TestMatrixCallback
|
import org.matrix.android.sdk.common.TestMatrixCallback
|
||||||
import org.matrix.android.sdk.internal.crypto.algorithms.olm.OlmDecryptionResult
|
|
||||||
import org.matrix.android.sdk.internal.crypto.keysbackup.model.MegolmBackupCreationInfo
|
|
||||||
import org.matrix.android.sdk.internal.crypto.keysbackup.model.rest.KeysVersion
|
|
||||||
import org.matrix.android.sdk.internal.crypto.keysbackup.model.rest.KeysVersionResult
|
|
||||||
import org.matrix.android.sdk.internal.crypto.model.ImportRoomKeysResult
|
|
||||||
import org.matrix.android.sdk.internal.crypto.model.event.EncryptedEventContent
|
|
||||||
|
|
||||||
@RunWith(JUnit4::class)
|
@RunWith(JUnit4::class)
|
||||||
@FixMethodOrder(MethodSorters.JVM)
|
@FixMethodOrder(MethodSorters.JVM)
|
||||||
|
|
|
@ -26,11 +26,11 @@ import org.junit.runner.RunWith
|
||||||
import org.junit.runners.MethodSorters
|
import org.junit.runners.MethodSorters
|
||||||
import org.matrix.android.sdk.InstrumentedTest
|
import org.matrix.android.sdk.InstrumentedTest
|
||||||
import org.matrix.android.sdk.api.session.events.model.EventType
|
import org.matrix.android.sdk.api.session.events.model.EventType
|
||||||
|
import org.matrix.android.sdk.api.session.events.model.content.EncryptedEventContent
|
||||||
|
import org.matrix.android.sdk.api.session.events.model.content.RoomKeyContent
|
||||||
import org.matrix.android.sdk.api.session.events.model.toModel
|
import org.matrix.android.sdk.api.session.events.model.toModel
|
||||||
import org.matrix.android.sdk.common.CommonTestHelper
|
import org.matrix.android.sdk.common.CommonTestHelper
|
||||||
import org.matrix.android.sdk.common.CryptoTestHelper
|
import org.matrix.android.sdk.common.CryptoTestHelper
|
||||||
import org.matrix.android.sdk.internal.crypto.model.event.EncryptedEventContent
|
|
||||||
import org.matrix.android.sdk.internal.crypto.model.event.RoomKeyContent
|
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
@FixMethodOrder(MethodSorters.JVM)
|
@FixMethodOrder(MethodSorters.JVM)
|
||||||
|
@ -90,7 +90,7 @@ class PreShareKeysTest : InstrumentedTest {
|
||||||
// Just send a real message as test
|
// Just send a real message as test
|
||||||
val sentEvent = testHelper.sendTextMessage(aliceSession.getRoom(e2eRoomID)!!, "Allo", 1).first()
|
val sentEvent = testHelper.sendTextMessage(aliceSession.getRoom(e2eRoomID)!!, "Allo", 1).first()
|
||||||
|
|
||||||
assertEquals("Unexpected megolm session", megolmSessionId, sentEvent.root.content.toModel<EncryptedEventContent>()?.sessionId,)
|
assertEquals("Unexpected megolm session", megolmSessionId, sentEvent.root.content.toModel<EncryptedEventContent>()?.sessionId)
|
||||||
testHelper.waitWithLatch { latch ->
|
testHelper.waitWithLatch { latch ->
|
||||||
testHelper.retryPeriodicallyWithLatch(latch) {
|
testHelper.retryPeriodicallyWithLatch(latch) {
|
||||||
bobSession.getRoom(e2eRoomID)?.getTimelineEvent(sentEvent.eventId)?.root?.getClearType() == EventType.MESSAGE
|
bobSession.getRoom(e2eRoomID)?.getTimelineEvent(sentEvent.eventId)?.root?.getClearType() == EventType.MESSAGE
|
||||||
|
|
|
@ -32,6 +32,7 @@ import org.matrix.android.sdk.api.auth.registration.RegistrationFlowResponse
|
||||||
import org.matrix.android.sdk.api.extensions.tryOrNull
|
import org.matrix.android.sdk.api.extensions.tryOrNull
|
||||||
import org.matrix.android.sdk.api.session.crypto.MXCryptoError
|
import org.matrix.android.sdk.api.session.crypto.MXCryptoError
|
||||||
import org.matrix.android.sdk.api.session.events.model.EventType
|
import org.matrix.android.sdk.api.session.events.model.EventType
|
||||||
|
import org.matrix.android.sdk.api.session.events.model.content.EncryptedEventContent
|
||||||
import org.matrix.android.sdk.api.session.events.model.toModel
|
import org.matrix.android.sdk.api.session.events.model.toModel
|
||||||
import org.matrix.android.sdk.api.session.room.timeline.Timeline
|
import org.matrix.android.sdk.api.session.room.timeline.Timeline
|
||||||
import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent
|
import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent
|
||||||
|
@ -40,7 +41,6 @@ import org.matrix.android.sdk.common.CommonTestHelper
|
||||||
import org.matrix.android.sdk.common.CryptoTestHelper
|
import org.matrix.android.sdk.common.CryptoTestHelper
|
||||||
import org.matrix.android.sdk.common.TestConstants
|
import org.matrix.android.sdk.common.TestConstants
|
||||||
import org.matrix.android.sdk.internal.crypto.model.OlmSessionWrapper
|
import org.matrix.android.sdk.internal.crypto.model.OlmSessionWrapper
|
||||||
import org.matrix.android.sdk.internal.crypto.model.event.EncryptedEventContent
|
|
||||||
import org.matrix.android.sdk.internal.crypto.store.db.deserializeFromRealm
|
import org.matrix.android.sdk.internal.crypto.store.db.deserializeFromRealm
|
||||||
import org.matrix.android.sdk.internal.crypto.store.db.serializeForRealm
|
import org.matrix.android.sdk.internal.crypto.store.db.serializeForRealm
|
||||||
import org.matrix.olm.OlmSession
|
import org.matrix.olm.OlmSession
|
||||||
|
|
|
@ -19,6 +19,7 @@ package org.matrix.android.sdk.internal.crypto.crosssigning
|
||||||
import org.amshove.kluent.shouldBeNull
|
import org.amshove.kluent.shouldBeNull
|
||||||
import org.amshove.kluent.shouldBeTrue
|
import org.amshove.kluent.shouldBeTrue
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
import org.matrix.android.sdk.api.util.fromBase64
|
||||||
|
|
||||||
@Suppress("SpellCheckingInspection")
|
@Suppress("SpellCheckingInspection")
|
||||||
class ExtensionsKtTest {
|
class ExtensionsKtTest {
|
||||||
|
|
|
@ -34,12 +34,14 @@ import org.matrix.android.sdk.api.auth.UIABaseAuth
|
||||||
import org.matrix.android.sdk.api.auth.UserInteractiveAuthInterceptor
|
import org.matrix.android.sdk.api.auth.UserInteractiveAuthInterceptor
|
||||||
import org.matrix.android.sdk.api.auth.UserPasswordAuth
|
import org.matrix.android.sdk.api.auth.UserPasswordAuth
|
||||||
import org.matrix.android.sdk.api.auth.registration.RegistrationFlowResponse
|
import org.matrix.android.sdk.api.auth.registration.RegistrationFlowResponse
|
||||||
|
import org.matrix.android.sdk.api.session.crypto.crosssigning.isCrossSignedVerified
|
||||||
|
import org.matrix.android.sdk.api.session.crypto.crosssigning.isVerified
|
||||||
|
import org.matrix.android.sdk.api.session.crypto.model.CryptoDeviceInfo
|
||||||
|
import org.matrix.android.sdk.api.session.crypto.model.MXUsersDevicesMap
|
||||||
import org.matrix.android.sdk.common.CommonTestHelper
|
import org.matrix.android.sdk.common.CommonTestHelper
|
||||||
import org.matrix.android.sdk.common.CryptoTestHelper
|
import org.matrix.android.sdk.common.CryptoTestHelper
|
||||||
import org.matrix.android.sdk.common.SessionTestParams
|
import org.matrix.android.sdk.common.SessionTestParams
|
||||||
import org.matrix.android.sdk.common.TestConstants
|
import org.matrix.android.sdk.common.TestConstants
|
||||||
import org.matrix.android.sdk.internal.crypto.model.CryptoDeviceInfo
|
|
||||||
import org.matrix.android.sdk.internal.crypto.model.MXUsersDevicesMap
|
|
||||||
import kotlin.coroutines.Continuation
|
import kotlin.coroutines.Continuation
|
||||||
import kotlin.coroutines.resume
|
import kotlin.coroutines.resume
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,9 @@ import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.junit.runners.MethodSorters
|
import org.junit.runners.MethodSorters
|
||||||
import org.matrix.android.sdk.InstrumentedTest
|
import org.matrix.android.sdk.InstrumentedTest
|
||||||
|
import org.matrix.android.sdk.api.crypto.MXCRYPTO_ALGORITHM_MEGOLM
|
||||||
import org.matrix.android.sdk.api.session.events.model.EventType
|
import org.matrix.android.sdk.api.session.events.model.EventType
|
||||||
|
import org.matrix.android.sdk.api.session.events.model.content.EncryptionEventContent
|
||||||
import org.matrix.android.sdk.api.session.events.model.toContent
|
import org.matrix.android.sdk.api.session.events.model.toContent
|
||||||
import org.matrix.android.sdk.api.session.room.Room
|
import org.matrix.android.sdk.api.session.room.Room
|
||||||
import org.matrix.android.sdk.api.session.room.send.SendState
|
import org.matrix.android.sdk.api.session.room.send.SendState
|
||||||
|
@ -33,8 +35,6 @@ import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent
|
||||||
import org.matrix.android.sdk.api.session.room.timeline.TimelineSettings
|
import org.matrix.android.sdk.api.session.room.timeline.TimelineSettings
|
||||||
import org.matrix.android.sdk.common.CommonTestHelper
|
import org.matrix.android.sdk.common.CommonTestHelper
|
||||||
import org.matrix.android.sdk.common.CryptoTestHelper
|
import org.matrix.android.sdk.common.CryptoTestHelper
|
||||||
import org.matrix.android.sdk.internal.crypto.MXCRYPTO_ALGORITHM_MEGOLM
|
|
||||||
import org.matrix.android.sdk.internal.crypto.model.event.EncryptionEventContent
|
|
||||||
import java.util.concurrent.CountDownLatch
|
import java.util.concurrent.CountDownLatch
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
|
|
|
@ -35,12 +35,20 @@ import org.matrix.android.sdk.api.auth.UserInteractiveAuthInterceptor
|
||||||
import org.matrix.android.sdk.api.auth.UserPasswordAuth
|
import org.matrix.android.sdk.api.auth.UserPasswordAuth
|
||||||
import org.matrix.android.sdk.api.auth.registration.RegistrationFlowResponse
|
import org.matrix.android.sdk.api.auth.registration.RegistrationFlowResponse
|
||||||
import org.matrix.android.sdk.api.extensions.tryOrNull
|
import org.matrix.android.sdk.api.extensions.tryOrNull
|
||||||
|
import org.matrix.android.sdk.api.session.crypto.crosssigning.DeviceTrustLevel
|
||||||
|
import org.matrix.android.sdk.api.session.crypto.keysbackup.KeysVersion
|
||||||
|
import org.matrix.android.sdk.api.session.crypto.keysbackup.MegolmBackupCreationInfo
|
||||||
|
import org.matrix.android.sdk.api.session.crypto.model.CryptoDeviceInfo
|
||||||
|
import org.matrix.android.sdk.api.session.crypto.model.GossipingRequestState
|
||||||
|
import org.matrix.android.sdk.api.session.crypto.model.MXUsersDevicesMap
|
||||||
|
import org.matrix.android.sdk.api.session.crypto.model.OutgoingGossipingRequestState
|
||||||
import org.matrix.android.sdk.api.session.crypto.verification.IncomingSasVerificationTransaction
|
import org.matrix.android.sdk.api.session.crypto.verification.IncomingSasVerificationTransaction
|
||||||
import org.matrix.android.sdk.api.session.crypto.verification.SasVerificationTransaction
|
import org.matrix.android.sdk.api.session.crypto.verification.SasVerificationTransaction
|
||||||
import org.matrix.android.sdk.api.session.crypto.verification.VerificationMethod
|
import org.matrix.android.sdk.api.session.crypto.verification.VerificationMethod
|
||||||
import org.matrix.android.sdk.api.session.crypto.verification.VerificationService
|
import org.matrix.android.sdk.api.session.crypto.verification.VerificationService
|
||||||
import org.matrix.android.sdk.api.session.crypto.verification.VerificationTransaction
|
import org.matrix.android.sdk.api.session.crypto.verification.VerificationTransaction
|
||||||
import org.matrix.android.sdk.api.session.crypto.verification.VerificationTxState
|
import org.matrix.android.sdk.api.session.crypto.verification.VerificationTxState
|
||||||
|
import org.matrix.android.sdk.api.session.events.model.content.EncryptedEventContent
|
||||||
import org.matrix.android.sdk.api.session.events.model.toModel
|
import org.matrix.android.sdk.api.session.events.model.toModel
|
||||||
import org.matrix.android.sdk.api.session.room.model.RoomDirectoryVisibility
|
import org.matrix.android.sdk.api.session.room.model.RoomDirectoryVisibility
|
||||||
import org.matrix.android.sdk.api.session.room.model.create.CreateRoomParams
|
import org.matrix.android.sdk.api.session.room.model.create.CreateRoomParams
|
||||||
|
@ -48,14 +56,6 @@ import org.matrix.android.sdk.api.session.room.model.message.MessageContent
|
||||||
import org.matrix.android.sdk.common.CommonTestHelper
|
import org.matrix.android.sdk.common.CommonTestHelper
|
||||||
import org.matrix.android.sdk.common.SessionTestParams
|
import org.matrix.android.sdk.common.SessionTestParams
|
||||||
import org.matrix.android.sdk.common.TestConstants
|
import org.matrix.android.sdk.common.TestConstants
|
||||||
import org.matrix.android.sdk.internal.crypto.GossipingRequestState
|
|
||||||
import org.matrix.android.sdk.internal.crypto.OutgoingGossipingRequestState
|
|
||||||
import org.matrix.android.sdk.internal.crypto.crosssigning.DeviceTrustLevel
|
|
||||||
import org.matrix.android.sdk.internal.crypto.keysbackup.model.MegolmBackupCreationInfo
|
|
||||||
import org.matrix.android.sdk.internal.crypto.keysbackup.model.rest.KeysVersion
|
|
||||||
import org.matrix.android.sdk.internal.crypto.model.CryptoDeviceInfo
|
|
||||||
import org.matrix.android.sdk.internal.crypto.model.MXUsersDevicesMap
|
|
||||||
import org.matrix.android.sdk.internal.crypto.model.event.EncryptedEventContent
|
|
||||||
import kotlin.coroutines.Continuation
|
import kotlin.coroutines.Continuation
|
||||||
import kotlin.coroutines.resume
|
import kotlin.coroutines.resume
|
||||||
|
|
||||||
|
|
|
@ -30,14 +30,14 @@ import org.matrix.android.sdk.api.NoOpMatrixCallback
|
||||||
import org.matrix.android.sdk.api.extensions.tryOrNull
|
import org.matrix.android.sdk.api.extensions.tryOrNull
|
||||||
import org.matrix.android.sdk.api.session.crypto.MXCryptoError
|
import org.matrix.android.sdk.api.session.crypto.MXCryptoError
|
||||||
import org.matrix.android.sdk.api.session.events.model.EventType
|
import org.matrix.android.sdk.api.session.events.model.EventType
|
||||||
|
import org.matrix.android.sdk.api.session.events.model.content.EncryptedEventContent
|
||||||
|
import org.matrix.android.sdk.api.session.events.model.content.WithHeldCode
|
||||||
import org.matrix.android.sdk.api.session.events.model.toModel
|
import org.matrix.android.sdk.api.session.events.model.toModel
|
||||||
import org.matrix.android.sdk.common.CommonTestHelper
|
import org.matrix.android.sdk.common.CommonTestHelper
|
||||||
import org.matrix.android.sdk.common.CryptoTestHelper
|
import org.matrix.android.sdk.common.CryptoTestHelper
|
||||||
import org.matrix.android.sdk.common.MockOkHttpInterceptor
|
import org.matrix.android.sdk.common.MockOkHttpInterceptor
|
||||||
import org.matrix.android.sdk.common.SessionTestParams
|
import org.matrix.android.sdk.common.SessionTestParams
|
||||||
import org.matrix.android.sdk.common.TestConstants
|
import org.matrix.android.sdk.common.TestConstants
|
||||||
import org.matrix.android.sdk.internal.crypto.model.event.EncryptedEventContent
|
|
||||||
import org.matrix.android.sdk.internal.crypto.model.event.WithHeldCode
|
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
@FixMethodOrder(MethodSorters.JVM)
|
@FixMethodOrder(MethodSorters.JVM)
|
||||||
|
|
|
@ -24,10 +24,12 @@ import org.matrix.android.sdk.internal.crypto.model.OlmInboundGroupSessionWrappe
|
||||||
/**
|
/**
|
||||||
* Data class to store result of [KeysBackupTestHelper.createKeysBackupScenarioWithPassword]
|
* Data class to store result of [KeysBackupTestHelper.createKeysBackupScenarioWithPassword]
|
||||||
*/
|
*/
|
||||||
data class KeysBackupScenarioData(val cryptoTestData: CryptoTestData,
|
internal data class KeysBackupScenarioData(
|
||||||
|
val cryptoTestData: CryptoTestData,
|
||||||
val aliceKeys: List<OlmInboundGroupSessionWrapper2>,
|
val aliceKeys: List<OlmInboundGroupSessionWrapper2>,
|
||||||
val prepareKeysBackupDataResult: PrepareKeysBackupDataResult,
|
val prepareKeysBackupDataResult: PrepareKeysBackupDataResult,
|
||||||
val aliceSession2: Session) {
|
val aliceSession2: Session
|
||||||
|
) {
|
||||||
fun cleanUp(testHelper: CommonTestHelper) {
|
fun cleanUp(testHelper: CommonTestHelper) {
|
||||||
cryptoTestData.cleanUp(testHelper)
|
cryptoTestData.cleanUp(testHelper)
|
||||||
testHelper.signOutAndClose(aliceSession2)
|
testHelper.signOutAndClose(aliceSession2)
|
||||||
|
|
|
@ -29,22 +29,22 @@ import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.junit.runners.MethodSorters
|
import org.junit.runners.MethodSorters
|
||||||
import org.matrix.android.sdk.InstrumentedTest
|
import org.matrix.android.sdk.InstrumentedTest
|
||||||
|
import org.matrix.android.sdk.api.crypto.MXCRYPTO_ALGORITHM_MEGOLM_BACKUP
|
||||||
import org.matrix.android.sdk.api.listeners.ProgressListener
|
import org.matrix.android.sdk.api.listeners.ProgressListener
|
||||||
import org.matrix.android.sdk.api.listeners.StepProgressListener
|
import org.matrix.android.sdk.api.listeners.StepProgressListener
|
||||||
|
import org.matrix.android.sdk.api.session.crypto.crosssigning.DeviceTrustLevel
|
||||||
|
import org.matrix.android.sdk.api.session.crypto.keysbackup.KeysBackupLastVersionResult
|
||||||
import org.matrix.android.sdk.api.session.crypto.keysbackup.KeysBackupState
|
import org.matrix.android.sdk.api.session.crypto.keysbackup.KeysBackupState
|
||||||
import org.matrix.android.sdk.api.session.crypto.keysbackup.KeysBackupStateListener
|
import org.matrix.android.sdk.api.session.crypto.keysbackup.KeysBackupStateListener
|
||||||
|
import org.matrix.android.sdk.api.session.crypto.keysbackup.KeysBackupVersionTrust
|
||||||
|
import org.matrix.android.sdk.api.session.crypto.keysbackup.KeysVersion
|
||||||
|
import org.matrix.android.sdk.api.session.crypto.keysbackup.MegolmBackupCreationInfo
|
||||||
|
import org.matrix.android.sdk.api.session.crypto.keysbackup.toKeysVersionResult
|
||||||
|
import org.matrix.android.sdk.api.session.crypto.model.ImportRoomKeysResult
|
||||||
import org.matrix.android.sdk.common.CommonTestHelper
|
import org.matrix.android.sdk.common.CommonTestHelper
|
||||||
import org.matrix.android.sdk.common.CryptoTestHelper
|
import org.matrix.android.sdk.common.CryptoTestHelper
|
||||||
import org.matrix.android.sdk.common.TestConstants
|
import org.matrix.android.sdk.common.TestConstants
|
||||||
import org.matrix.android.sdk.common.TestMatrixCallback
|
import org.matrix.android.sdk.common.TestMatrixCallback
|
||||||
import org.matrix.android.sdk.internal.crypto.MXCRYPTO_ALGORITHM_MEGOLM_BACKUP
|
|
||||||
import org.matrix.android.sdk.internal.crypto.crosssigning.DeviceTrustLevel
|
|
||||||
import org.matrix.android.sdk.internal.crypto.keysbackup.model.KeysBackupLastVersionResult
|
|
||||||
import org.matrix.android.sdk.internal.crypto.keysbackup.model.KeysBackupVersionTrust
|
|
||||||
import org.matrix.android.sdk.internal.crypto.keysbackup.model.MegolmBackupCreationInfo
|
|
||||||
import org.matrix.android.sdk.internal.crypto.keysbackup.model.rest.KeysVersion
|
|
||||||
import org.matrix.android.sdk.internal.crypto.keysbackup.model.toKeysVersionResult
|
|
||||||
import org.matrix.android.sdk.internal.crypto.model.ImportRoomKeysResult
|
|
||||||
import java.util.Collections
|
import java.util.Collections
|
||||||
import java.util.concurrent.CountDownLatch
|
import java.util.concurrent.CountDownLatch
|
||||||
|
|
||||||
|
|
|
@ -22,16 +22,16 @@ import org.matrix.android.sdk.api.session.Session
|
||||||
import org.matrix.android.sdk.api.session.crypto.keysbackup.KeysBackupService
|
import org.matrix.android.sdk.api.session.crypto.keysbackup.KeysBackupService
|
||||||
import org.matrix.android.sdk.api.session.crypto.keysbackup.KeysBackupState
|
import org.matrix.android.sdk.api.session.crypto.keysbackup.KeysBackupState
|
||||||
import org.matrix.android.sdk.api.session.crypto.keysbackup.KeysBackupStateListener
|
import org.matrix.android.sdk.api.session.crypto.keysbackup.KeysBackupStateListener
|
||||||
|
import org.matrix.android.sdk.api.session.crypto.keysbackup.KeysVersion
|
||||||
|
import org.matrix.android.sdk.api.session.crypto.keysbackup.MegolmBackupCreationInfo
|
||||||
import org.matrix.android.sdk.common.CommonTestHelper
|
import org.matrix.android.sdk.common.CommonTestHelper
|
||||||
import org.matrix.android.sdk.common.CryptoTestHelper
|
import org.matrix.android.sdk.common.CryptoTestHelper
|
||||||
import org.matrix.android.sdk.common.assertDictEquals
|
import org.matrix.android.sdk.common.assertDictEquals
|
||||||
import org.matrix.android.sdk.common.assertListEquals
|
import org.matrix.android.sdk.common.assertListEquals
|
||||||
import org.matrix.android.sdk.internal.crypto.MegolmSessionData
|
import org.matrix.android.sdk.internal.crypto.MegolmSessionData
|
||||||
import org.matrix.android.sdk.internal.crypto.keysbackup.model.MegolmBackupCreationInfo
|
|
||||||
import org.matrix.android.sdk.internal.crypto.keysbackup.model.rest.KeysVersion
|
|
||||||
import java.util.concurrent.CountDownLatch
|
import java.util.concurrent.CountDownLatch
|
||||||
|
|
||||||
class KeysBackupTestHelper(
|
internal class KeysBackupTestHelper(
|
||||||
private val testHelper: CommonTestHelper,
|
private val testHelper: CommonTestHelper,
|
||||||
private val cryptoTestHelper: CryptoTestHelper) {
|
private val cryptoTestHelper: CryptoTestHelper) {
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
package org.matrix.android.sdk.internal.crypto.keysbackup
|
package org.matrix.android.sdk.internal.crypto.keysbackup
|
||||||
|
|
||||||
import org.matrix.android.sdk.internal.crypto.keysbackup.model.MegolmBackupCreationInfo
|
import org.matrix.android.sdk.api.session.crypto.keysbackup.MegolmBackupCreationInfo
|
||||||
|
|
||||||
data class PrepareKeysBackupDataResult(val megolmBackupCreationInfo: MegolmBackupCreationInfo,
|
data class PrepareKeysBackupDataResult(val megolmBackupCreationInfo: MegolmBackupCreationInfo,
|
||||||
val version: String)
|
val version: String)
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.junit.runners.MethodSorters
|
import org.junit.runners.MethodSorters
|
||||||
import org.matrix.android.sdk.InstrumentedTest
|
import org.matrix.android.sdk.InstrumentedTest
|
||||||
|
import org.matrix.android.sdk.api.crypto.SSSS_ALGORITHM_AES_HMAC_SHA2
|
||||||
import org.matrix.android.sdk.api.session.Session
|
import org.matrix.android.sdk.api.session.Session
|
||||||
import org.matrix.android.sdk.api.session.accountdata.UserAccountDataEvent
|
import org.matrix.android.sdk.api.session.accountdata.UserAccountDataEvent
|
||||||
import org.matrix.android.sdk.api.session.securestorage.EncryptedSecretContent
|
import org.matrix.android.sdk.api.session.securestorage.EncryptedSecretContent
|
||||||
|
@ -37,11 +38,10 @@ import org.matrix.android.sdk.api.session.securestorage.SharedSecretStorageError
|
||||||
import org.matrix.android.sdk.api.session.securestorage.SharedSecretStorageService
|
import org.matrix.android.sdk.api.session.securestorage.SharedSecretStorageService
|
||||||
import org.matrix.android.sdk.api.session.securestorage.SsssKeyCreationInfo
|
import org.matrix.android.sdk.api.session.securestorage.SsssKeyCreationInfo
|
||||||
import org.matrix.android.sdk.api.util.Optional
|
import org.matrix.android.sdk.api.util.Optional
|
||||||
|
import org.matrix.android.sdk.api.util.toBase64NoPadding
|
||||||
import org.matrix.android.sdk.common.CommonTestHelper
|
import org.matrix.android.sdk.common.CommonTestHelper
|
||||||
import org.matrix.android.sdk.common.SessionTestParams
|
import org.matrix.android.sdk.common.SessionTestParams
|
||||||
import org.matrix.android.sdk.common.TestConstants
|
import org.matrix.android.sdk.common.TestConstants
|
||||||
import org.matrix.android.sdk.internal.crypto.SSSS_ALGORITHM_AES_HMAC_SHA2
|
|
||||||
import org.matrix.android.sdk.internal.crypto.crosssigning.toBase64NoPadding
|
|
||||||
import org.matrix.android.sdk.internal.crypto.secrets.DefaultSharedSecretStorageService
|
import org.matrix.android.sdk.internal.crypto.secrets.DefaultSharedSecretStorageService
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
|
|
|
@ -31,6 +31,8 @@ import org.junit.runner.RunWith
|
||||||
import org.junit.runners.MethodSorters
|
import org.junit.runners.MethodSorters
|
||||||
import org.matrix.android.sdk.InstrumentedTest
|
import org.matrix.android.sdk.InstrumentedTest
|
||||||
import org.matrix.android.sdk.api.session.Session
|
import org.matrix.android.sdk.api.session.Session
|
||||||
|
import org.matrix.android.sdk.api.session.crypto.model.CryptoDeviceInfo
|
||||||
|
import org.matrix.android.sdk.api.session.crypto.model.MXUsersDevicesMap
|
||||||
import org.matrix.android.sdk.api.session.crypto.verification.CancelCode
|
import org.matrix.android.sdk.api.session.crypto.verification.CancelCode
|
||||||
import org.matrix.android.sdk.api.session.crypto.verification.IncomingSasVerificationTransaction
|
import org.matrix.android.sdk.api.session.crypto.verification.IncomingSasVerificationTransaction
|
||||||
import org.matrix.android.sdk.api.session.crypto.verification.OutgoingSasVerificationTransaction
|
import org.matrix.android.sdk.api.session.crypto.verification.OutgoingSasVerificationTransaction
|
||||||
|
@ -44,8 +46,6 @@ import org.matrix.android.sdk.api.session.events.model.Event
|
||||||
import org.matrix.android.sdk.api.session.events.model.toModel
|
import org.matrix.android.sdk.api.session.events.model.toModel
|
||||||
import org.matrix.android.sdk.common.CommonTestHelper
|
import org.matrix.android.sdk.common.CommonTestHelper
|
||||||
import org.matrix.android.sdk.common.CryptoTestHelper
|
import org.matrix.android.sdk.common.CryptoTestHelper
|
||||||
import org.matrix.android.sdk.internal.crypto.model.CryptoDeviceInfo
|
|
||||||
import org.matrix.android.sdk.internal.crypto.model.MXUsersDevicesMap
|
|
||||||
import org.matrix.android.sdk.internal.crypto.model.rest.KeyVerificationCancel
|
import org.matrix.android.sdk.internal.crypto.model.rest.KeyVerificationCancel
|
||||||
import org.matrix.android.sdk.internal.crypto.model.rest.KeyVerificationStart
|
import org.matrix.android.sdk.internal.crypto.model.rest.KeyVerificationStart
|
||||||
import org.matrix.android.sdk.internal.crypto.model.rest.toValue
|
import org.matrix.android.sdk.internal.crypto.model.rest.toValue
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.junit.runner.RunWith
|
||||||
import org.junit.runners.MethodSorters
|
import org.junit.runners.MethodSorters
|
||||||
import org.matrix.android.sdk.InstrumentedTest
|
import org.matrix.android.sdk.InstrumentedTest
|
||||||
import org.matrix.android.sdk.api.MatrixConfiguration
|
import org.matrix.android.sdk.api.MatrixConfiguration
|
||||||
|
import org.matrix.android.sdk.api.util.TextContent
|
||||||
import org.matrix.android.sdk.common.TestRoomDisplayNameFallbackProvider
|
import org.matrix.android.sdk.common.TestRoomDisplayNameFallbackProvider
|
||||||
import org.matrix.android.sdk.internal.session.displayname.DisplayNameResolver
|
import org.matrix.android.sdk.internal.session.displayname.DisplayNameResolver
|
||||||
import org.matrix.android.sdk.internal.session.room.send.pills.MentionLinkSpecComparator
|
import org.matrix.android.sdk.internal.session.room.send.pills.MentionLinkSpecComparator
|
||||||
|
|
|
@ -24,8 +24,8 @@ import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.junit.runners.MethodSorters
|
import org.junit.runners.MethodSorters
|
||||||
import org.matrix.android.sdk.InstrumentedTest
|
import org.matrix.android.sdk.InstrumentedTest
|
||||||
import org.matrix.android.sdk.internal.crypto.crosssigning.fromBase64
|
import org.matrix.android.sdk.api.util.fromBase64
|
||||||
import org.matrix.android.sdk.internal.crypto.crosssigning.toBase64NoPadding
|
import org.matrix.android.sdk.api.util.toBase64NoPadding
|
||||||
import java.io.ByteArrayOutputStream
|
import java.io.ByteArrayOutputStream
|
||||||
import java.util.UUID
|
import java.util.UUID
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ import org.json.JSONException
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
|
|
||||||
class FormattedJsonHttpLogger : HttpLoggingInterceptor.Logger {
|
internal class FormattedJsonHttpLogger : HttpLoggingInterceptor.Logger {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val INDENT_SPACE = 2
|
private const val INDENT_SPACE = 2
|
||||||
|
|
|
@ -17,7 +17,7 @@ package org.commonmark.ext.maths
|
||||||
|
|
||||||
import org.commonmark.node.CustomBlock
|
import org.commonmark.node.CustomBlock
|
||||||
|
|
||||||
class DisplayMaths(private val delimiter: DisplayDelimiter) : CustomBlock() {
|
internal class DisplayMaths(private val delimiter: DisplayDelimiter) : CustomBlock() {
|
||||||
enum class DisplayDelimiter {
|
enum class DisplayDelimiter {
|
||||||
DOUBLE_DOLLAR,
|
DOUBLE_DOLLAR,
|
||||||
SQUARE_BRACKET_ESCAPED
|
SQUARE_BRACKET_ESCAPED
|
||||||
|
|
|
@ -18,7 +18,7 @@ package org.commonmark.ext.maths
|
||||||
import org.commonmark.node.CustomNode
|
import org.commonmark.node.CustomNode
|
||||||
import org.commonmark.node.Delimited
|
import org.commonmark.node.Delimited
|
||||||
|
|
||||||
class InlineMaths(private val delimiter: InlineDelimiter) : CustomNode(), Delimited {
|
internal class InlineMaths(private val delimiter: InlineDelimiter) : CustomNode(), Delimited {
|
||||||
enum class InlineDelimiter {
|
enum class InlineDelimiter {
|
||||||
SINGLE_DOLLAR,
|
SINGLE_DOLLAR,
|
||||||
ROUND_BRACKET_ESCAPED
|
ROUND_BRACKET_ESCAPED
|
||||||
|
|
|
@ -21,7 +21,7 @@ import org.commonmark.ext.maths.internal.MathsHtmlNodeRenderer
|
||||||
import org.commonmark.parser.Parser
|
import org.commonmark.parser.Parser
|
||||||
import org.commonmark.renderer.html.HtmlRenderer
|
import org.commonmark.renderer.html.HtmlRenderer
|
||||||
|
|
||||||
class MathsExtension private constructor() : Parser.ParserExtension, HtmlRenderer.HtmlRendererExtension {
|
internal class MathsExtension private constructor() : Parser.ParserExtension, HtmlRenderer.HtmlRendererExtension {
|
||||||
override fun extend(parserBuilder: Parser.Builder) {
|
override fun extend(parserBuilder: Parser.Builder) {
|
||||||
parserBuilder.customDelimiterProcessor(DollarMathsDelimiterProcessor())
|
parserBuilder.customDelimiterProcessor(DollarMathsDelimiterProcessor())
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ import org.commonmark.node.Text
|
||||||
import org.commonmark.parser.delimiter.DelimiterProcessor
|
import org.commonmark.parser.delimiter.DelimiterProcessor
|
||||||
import org.commonmark.parser.delimiter.DelimiterRun
|
import org.commonmark.parser.delimiter.DelimiterRun
|
||||||
|
|
||||||
class DollarMathsDelimiterProcessor : DelimiterProcessor {
|
internal class DollarMathsDelimiterProcessor : DelimiterProcessor {
|
||||||
override fun getOpeningCharacter() = '$'
|
override fun getOpeningCharacter() = '$'
|
||||||
|
|
||||||
override fun getClosingCharacter() = '$'
|
override fun getClosingCharacter() = '$'
|
||||||
|
|
|
@ -22,7 +22,7 @@ import org.commonmark.renderer.html.HtmlNodeRendererContext
|
||||||
import org.commonmark.renderer.html.HtmlWriter
|
import org.commonmark.renderer.html.HtmlWriter
|
||||||
import java.util.Collections
|
import java.util.Collections
|
||||||
|
|
||||||
class MathsHtmlNodeRenderer(private val context: HtmlNodeRendererContext) : MathsNodeRenderer() {
|
internal class MathsHtmlNodeRenderer(private val context: HtmlNodeRendererContext) : MathsNodeRenderer() {
|
||||||
private val html: HtmlWriter = context.writer
|
private val html: HtmlWriter = context.writer
|
||||||
override fun render(node: Node) {
|
override fun render(node: Node) {
|
||||||
val display = node.javaClass == DisplayMaths::class.java
|
val display = node.javaClass == DisplayMaths::class.java
|
||||||
|
|
|
@ -19,9 +19,8 @@ import org.commonmark.ext.maths.DisplayMaths
|
||||||
import org.commonmark.ext.maths.InlineMaths
|
import org.commonmark.ext.maths.InlineMaths
|
||||||
import org.commonmark.node.Node
|
import org.commonmark.node.Node
|
||||||
import org.commonmark.renderer.NodeRenderer
|
import org.commonmark.renderer.NodeRenderer
|
||||||
import java.util.HashSet
|
|
||||||
|
|
||||||
abstract class MathsNodeRenderer : NodeRenderer {
|
internal abstract class MathsNodeRenderer : NodeRenderer {
|
||||||
override fun getNodeTypes(): Set<Class<out Node>> {
|
override fun getNodeTypes(): Set<Class<out Node>> {
|
||||||
val types: MutableSet<Class<out Node>> = HashSet()
|
val types: MutableSet<Class<out Node>> = HashSet()
|
||||||
types.add(InlineMaths::class.java)
|
types.add(InlineMaths::class.java)
|
||||||
|
|
|
@ -29,6 +29,7 @@ import org.matrix.android.sdk.api.legacy.LegacySessionImporter
|
||||||
import org.matrix.android.sdk.api.network.ApiInterceptorListener
|
import org.matrix.android.sdk.api.network.ApiInterceptorListener
|
||||||
import org.matrix.android.sdk.api.network.ApiPath
|
import org.matrix.android.sdk.api.network.ApiPath
|
||||||
import org.matrix.android.sdk.api.raw.RawService
|
import org.matrix.android.sdk.api.raw.RawService
|
||||||
|
import org.matrix.android.sdk.api.settings.LightweightSettingsStorage
|
||||||
import org.matrix.android.sdk.internal.SessionManager
|
import org.matrix.android.sdk.internal.SessionManager
|
||||||
import org.matrix.android.sdk.internal.di.DaggerMatrixComponent
|
import org.matrix.android.sdk.internal.di.DaggerMatrixComponent
|
||||||
import org.matrix.android.sdk.internal.network.ApiInterceptor
|
import org.matrix.android.sdk.internal.network.ApiInterceptor
|
||||||
|
@ -56,6 +57,7 @@ class Matrix private constructor(context: Context, matrixConfiguration: MatrixCo
|
||||||
@Inject internal lateinit var homeServerHistoryService: HomeServerHistoryService
|
@Inject internal lateinit var homeServerHistoryService: HomeServerHistoryService
|
||||||
@Inject internal lateinit var apiInterceptor: ApiInterceptor
|
@Inject internal lateinit var apiInterceptor: ApiInterceptor
|
||||||
@Inject internal lateinit var matrixWorkerFactory: MatrixWorkerFactory
|
@Inject internal lateinit var matrixWorkerFactory: MatrixWorkerFactory
|
||||||
|
@Inject internal lateinit var lightweightSettingsStorage: LightweightSettingsStorage
|
||||||
|
|
||||||
init {
|
init {
|
||||||
Monarchy.init(context)
|
Monarchy.init(context)
|
||||||
|
@ -78,6 +80,8 @@ class Matrix private constructor(context: Context, matrixConfiguration: MatrixCo
|
||||||
|
|
||||||
fun rawService() = rawService
|
fun rawService() = rawService
|
||||||
|
|
||||||
|
fun lightweightSettingsStorage() = lightweightSettingsStorage
|
||||||
|
|
||||||
fun homeServerHistoryService() = homeServerHistoryService
|
fun homeServerHistoryService() = homeServerHistoryService
|
||||||
|
|
||||||
fun legacySessionImporter(): LegacySessionImporter {
|
fun legacySessionImporter(): LegacySessionImporter {
|
||||||
|
|
|
@ -20,10 +20,19 @@ package org.matrix.android.sdk.api.auth
|
||||||
* A simple service to remember homeservers you already connected to.
|
* A simple service to remember homeservers you already connected to.
|
||||||
*/
|
*/
|
||||||
interface HomeServerHistoryService {
|
interface HomeServerHistoryService {
|
||||||
|
/**
|
||||||
|
* Get a list of stored homeserver urls.
|
||||||
|
*/
|
||||||
fun getKnownServersUrls(): List<String>
|
fun getKnownServersUrls(): List<String>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a homeserver url to the list of stored homeserver urls.
|
||||||
|
* Will not be added again if already present in the list.
|
||||||
|
*/
|
||||||
fun addHomeServerToHistory(url: String)
|
fun addHomeServerToHistory(url: String)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete the list of stored homeserver urls.
|
||||||
|
*/
|
||||||
fun clearHistory()
|
fun clearHistory()
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ package org.matrix.android.sdk.api.auth.data
|
||||||
|
|
||||||
import com.squareup.moshi.Json
|
import com.squareup.moshi.Json
|
||||||
import com.squareup.moshi.JsonClass
|
import com.squareup.moshi.JsonClass
|
||||||
import org.matrix.android.sdk.internal.util.md5
|
import org.matrix.android.sdk.api.util.md5
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This data class hold credentials user data.
|
* This data class hold credentials user data.
|
||||||
|
|
|
@ -22,7 +22,7 @@ import okhttp3.CipherSuite
|
||||||
import okhttp3.ConnectionSpec
|
import okhttp3.ConnectionSpec
|
||||||
import okhttp3.TlsVersion
|
import okhttp3.TlsVersion
|
||||||
import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig.Builder
|
import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig.Builder
|
||||||
import org.matrix.android.sdk.internal.network.ssl.Fingerprint
|
import org.matrix.android.sdk.api.network.ssl.Fingerprint
|
||||||
import org.matrix.android.sdk.internal.util.ensureTrailingSlash
|
import org.matrix.android.sdk.internal.util.ensureTrailingSlash
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.matrix.android.sdk.internal.auth.registration
|
package org.matrix.android.sdk.api.auth.data
|
||||||
|
|
||||||
import android.os.Parcelable
|
import android.os.Parcelable
|
||||||
import kotlinx.parcelize.Parcelize
|
import kotlinx.parcelize.Parcelize
|
|
@ -19,8 +19,8 @@ package org.matrix.android.sdk.api.auth.registration
|
||||||
import com.squareup.moshi.Json
|
import com.squareup.moshi.Json
|
||||||
import com.squareup.moshi.JsonClass
|
import com.squareup.moshi.JsonClass
|
||||||
import org.matrix.android.sdk.api.auth.data.LoginFlowTypes
|
import org.matrix.android.sdk.api.auth.data.LoginFlowTypes
|
||||||
|
import org.matrix.android.sdk.api.session.uia.InteractiveAuthenticationFlow
|
||||||
import org.matrix.android.sdk.api.util.JsonDict
|
import org.matrix.android.sdk.api.util.JsonDict
|
||||||
import org.matrix.android.sdk.internal.auth.data.InteractiveAuthenticationFlow
|
|
||||||
|
|
||||||
@JsonClass(generateAdapter = true)
|
@JsonClass(generateAdapter = true)
|
||||||
data class RegistrationFlowResponse(
|
data class RegistrationFlowResponse(
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.matrix.android.sdk.internal.crypto
|
package org.matrix.android.sdk.api.crypto
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Matrix algorithm value for olm.
|
* Matrix algorithm value for olm.
|
|
@ -16,8 +16,8 @@
|
||||||
|
|
||||||
package org.matrix.android.sdk.api.extensions
|
package org.matrix.android.sdk.api.extensions
|
||||||
|
|
||||||
import org.matrix.android.sdk.internal.crypto.model.CryptoDeviceInfo
|
import org.matrix.android.sdk.api.session.crypto.model.CryptoDeviceInfo
|
||||||
import org.matrix.android.sdk.internal.crypto.model.rest.DeviceInfo
|
import org.matrix.android.sdk.api.session.crypto.model.DeviceInfo
|
||||||
|
|
||||||
/* ==========================================================================================
|
/* ==========================================================================================
|
||||||
* MXDeviceInfo
|
* MXDeviceInfo
|
||||||
|
|
|
@ -17,8 +17,8 @@
|
||||||
package org.matrix.android.sdk.api.failure
|
package org.matrix.android.sdk.api.failure
|
||||||
|
|
||||||
import org.matrix.android.sdk.api.auth.registration.RegistrationFlowResponse
|
import org.matrix.android.sdk.api.auth.registration.RegistrationFlowResponse
|
||||||
|
import org.matrix.android.sdk.api.network.ssl.Fingerprint
|
||||||
import org.matrix.android.sdk.api.session.crypto.MXCryptoError
|
import org.matrix.android.sdk.api.session.crypto.MXCryptoError
|
||||||
import org.matrix.android.sdk.internal.network.ssl.Fingerprint
|
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
package org.matrix.android.sdk.api.failure
|
package org.matrix.android.sdk.api.failure
|
||||||
|
|
||||||
import org.matrix.android.sdk.internal.network.ssl.Fingerprint
|
import org.matrix.android.sdk.api.network.ssl.Fingerprint
|
||||||
|
|
||||||
// This class will be sent to the bus
|
// This class will be sent to the bus
|
||||||
sealed class GlobalError {
|
sealed class GlobalError {
|
||||||
|
|
|
@ -18,8 +18,8 @@ package org.matrix.android.sdk.api.failure
|
||||||
|
|
||||||
import com.squareup.moshi.Json
|
import com.squareup.moshi.Json
|
||||||
import com.squareup.moshi.JsonClass
|
import com.squareup.moshi.JsonClass
|
||||||
|
import org.matrix.android.sdk.api.session.uia.InteractiveAuthenticationFlow
|
||||||
import org.matrix.android.sdk.api.util.JsonDict
|
import org.matrix.android.sdk.api.util.JsonDict
|
||||||
import org.matrix.android.sdk.internal.auth.data.InteractiveAuthenticationFlow
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This data class holds the error defined by the matrix specifications.
|
* This data class holds the error defined by the matrix specifications.
|
||||||
|
|
|
@ -14,10 +14,11 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.matrix.android.sdk.internal.network.ssl
|
package org.matrix.android.sdk.api.network.ssl
|
||||||
|
|
||||||
import com.squareup.moshi.Json
|
import com.squareup.moshi.Json
|
||||||
import com.squareup.moshi.JsonClass
|
import com.squareup.moshi.JsonClass
|
||||||
|
import org.matrix.android.sdk.internal.network.ssl.CertUtil
|
||||||
import java.security.cert.CertificateException
|
import java.security.cert.CertificateException
|
||||||
import java.security.cert.X509Certificate
|
import java.security.cert.X509Certificate
|
||||||
|
|
|
@ -16,8 +16,8 @@
|
||||||
|
|
||||||
package org.matrix.android.sdk.api.session
|
package org.matrix.android.sdk.api.session
|
||||||
|
|
||||||
|
import org.matrix.android.sdk.api.session.crypto.model.MXUsersDevicesMap
|
||||||
import org.matrix.android.sdk.api.session.events.model.Content
|
import org.matrix.android.sdk.api.session.events.model.Content
|
||||||
import org.matrix.android.sdk.internal.crypto.model.MXUsersDevicesMap
|
|
||||||
import java.util.UUID
|
import java.util.UUID
|
||||||
|
|
||||||
interface ToDeviceService {
|
interface ToDeviceService {
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
package org.matrix.android.sdk.api.session.content
|
package org.matrix.android.sdk.api.session.content
|
||||||
|
|
||||||
import org.matrix.android.sdk.internal.crypto.attachments.ElementToDecrypt
|
import org.matrix.android.sdk.api.session.crypto.attachments.ElementToDecrypt
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This interface defines methods for accessing content from the current session.
|
* This interface defines methods for accessing content from the current session.
|
||||||
|
|
|
@ -17,8 +17,8 @@
|
||||||
package org.matrix.android.sdk.api.session.contentscanner
|
package org.matrix.android.sdk.api.session.contentscanner
|
||||||
|
|
||||||
import androidx.lifecycle.LiveData
|
import androidx.lifecycle.LiveData
|
||||||
|
import org.matrix.android.sdk.api.session.crypto.attachments.ElementToDecrypt
|
||||||
import org.matrix.android.sdk.api.util.Optional
|
import org.matrix.android.sdk.api.util.Optional
|
||||||
import org.matrix.android.sdk.internal.crypto.attachments.ElementToDecrypt
|
|
||||||
|
|
||||||
interface ContentScannerService {
|
interface ContentScannerService {
|
||||||
|
|
||||||
|
|
|
@ -23,25 +23,24 @@ import org.matrix.android.sdk.api.MatrixCallback
|
||||||
import org.matrix.android.sdk.api.auth.UserInteractiveAuthInterceptor
|
import org.matrix.android.sdk.api.auth.UserInteractiveAuthInterceptor
|
||||||
import org.matrix.android.sdk.api.listeners.ProgressListener
|
import org.matrix.android.sdk.api.listeners.ProgressListener
|
||||||
import org.matrix.android.sdk.api.session.crypto.crosssigning.CrossSigningService
|
import org.matrix.android.sdk.api.session.crypto.crosssigning.CrossSigningService
|
||||||
|
import org.matrix.android.sdk.api.session.crypto.crosssigning.DeviceTrustLevel
|
||||||
import org.matrix.android.sdk.api.session.crypto.keysbackup.KeysBackupService
|
import org.matrix.android.sdk.api.session.crypto.keysbackup.KeysBackupService
|
||||||
import org.matrix.android.sdk.api.session.crypto.keyshare.GossipingRequestListener
|
import org.matrix.android.sdk.api.session.crypto.keyshare.GossipingRequestListener
|
||||||
|
import org.matrix.android.sdk.api.session.crypto.model.CryptoDeviceInfo
|
||||||
|
import org.matrix.android.sdk.api.session.crypto.model.DeviceInfo
|
||||||
|
import org.matrix.android.sdk.api.session.crypto.model.DevicesListResponse
|
||||||
|
import org.matrix.android.sdk.api.session.crypto.model.ImportRoomKeysResult
|
||||||
|
import org.matrix.android.sdk.api.session.crypto.model.IncomingRoomKeyRequest
|
||||||
|
import org.matrix.android.sdk.api.session.crypto.model.MXDeviceInfo
|
||||||
|
import org.matrix.android.sdk.api.session.crypto.model.MXEncryptEventContentResult
|
||||||
|
import org.matrix.android.sdk.api.session.crypto.model.MXEventDecryptionResult
|
||||||
|
import org.matrix.android.sdk.api.session.crypto.model.MXUsersDevicesMap
|
||||||
|
import org.matrix.android.sdk.api.session.crypto.model.OutgoingRoomKeyRequest
|
||||||
|
import org.matrix.android.sdk.api.session.crypto.model.RoomKeyRequestBody
|
||||||
import org.matrix.android.sdk.api.session.crypto.verification.VerificationService
|
import org.matrix.android.sdk.api.session.crypto.verification.VerificationService
|
||||||
import org.matrix.android.sdk.api.session.events.model.Content
|
import org.matrix.android.sdk.api.session.events.model.Content
|
||||||
import org.matrix.android.sdk.api.session.events.model.Event
|
import org.matrix.android.sdk.api.session.events.model.Event
|
||||||
import org.matrix.android.sdk.internal.crypto.IncomingRoomKeyRequest
|
import org.matrix.android.sdk.api.session.events.model.content.RoomKeyWithHeldContent
|
||||||
import org.matrix.android.sdk.internal.crypto.MXEventDecryptionResult
|
|
||||||
import org.matrix.android.sdk.internal.crypto.NewSessionListener
|
|
||||||
import org.matrix.android.sdk.internal.crypto.OutgoingRoomKeyRequest
|
|
||||||
import org.matrix.android.sdk.internal.crypto.crosssigning.DeviceTrustLevel
|
|
||||||
import org.matrix.android.sdk.internal.crypto.model.CryptoDeviceInfo
|
|
||||||
import org.matrix.android.sdk.internal.crypto.model.ImportRoomKeysResult
|
|
||||||
import org.matrix.android.sdk.internal.crypto.model.MXDeviceInfo
|
|
||||||
import org.matrix.android.sdk.internal.crypto.model.MXEncryptEventContentResult
|
|
||||||
import org.matrix.android.sdk.internal.crypto.model.MXUsersDevicesMap
|
|
||||||
import org.matrix.android.sdk.internal.crypto.model.event.RoomKeyWithHeldContent
|
|
||||||
import org.matrix.android.sdk.internal.crypto.model.rest.DeviceInfo
|
|
||||||
import org.matrix.android.sdk.internal.crypto.model.rest.DevicesListResponse
|
|
||||||
import org.matrix.android.sdk.internal.crypto.model.rest.RoomKeyRequestBody
|
|
||||||
|
|
||||||
interface CryptoService {
|
interface CryptoService {
|
||||||
|
|
||||||
|
@ -113,6 +112,7 @@ interface CryptoService {
|
||||||
|
|
||||||
fun isRoomEncrypted(roomId: String): Boolean
|
fun isRoomEncrypted(roomId: String): Boolean
|
||||||
|
|
||||||
|
// TODO This could be removed from this interface
|
||||||
fun encryptEventContent(eventContent: Content,
|
fun encryptEventContent(eventContent: Content,
|
||||||
eventType: String,
|
eventType: String,
|
||||||
roomId: String,
|
roomId: String,
|
||||||
|
|
|
@ -16,8 +16,8 @@
|
||||||
|
|
||||||
package org.matrix.android.sdk.api.session.crypto
|
package org.matrix.android.sdk.api.session.crypto
|
||||||
|
|
||||||
import org.matrix.android.sdk.internal.crypto.model.CryptoDeviceInfo
|
import org.matrix.android.sdk.api.session.crypto.model.CryptoDeviceInfo
|
||||||
import org.matrix.android.sdk.internal.crypto.model.MXUsersDevicesMap
|
import org.matrix.android.sdk.api.session.crypto.model.MXUsersDevicesMap
|
||||||
import org.matrix.olm.OlmException
|
import org.matrix.olm.OlmException
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2020 The Matrix.org Foundation C.I.C.
|
* Copyright (c) 2022 The Matrix.org Foundation C.I.C.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -13,7 +13,8 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.matrix.android.sdk.internal.crypto
|
|
||||||
|
package org.matrix.android.sdk.api.session.crypto
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This listener notifies on new Megolm sessions being created
|
* This listener notifies on new Megolm sessions being created
|
|
@ -14,11 +14,11 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.matrix.android.sdk.internal.crypto.attachments
|
package org.matrix.android.sdk.api.session.crypto.attachments
|
||||||
|
|
||||||
import android.os.Parcelable
|
import android.os.Parcelable
|
||||||
import kotlinx.parcelize.Parcelize
|
import kotlinx.parcelize.Parcelize
|
||||||
import org.matrix.android.sdk.internal.crypto.model.rest.EncryptedFileInfo
|
import org.matrix.android.sdk.api.session.crypto.model.EncryptedFileInfo
|
||||||
|
|
||||||
fun EncryptedFileInfo.toElementToDecrypt(): ElementToDecrypt? {
|
fun EncryptedFileInfo.toElementToDecrypt(): ElementToDecrypt? {
|
||||||
// Check the validity of some fields
|
// Check the validity of some fields
|
|
@ -20,9 +20,6 @@ import androidx.lifecycle.LiveData
|
||||||
import org.matrix.android.sdk.api.MatrixCallback
|
import org.matrix.android.sdk.api.MatrixCallback
|
||||||
import org.matrix.android.sdk.api.auth.UserInteractiveAuthInterceptor
|
import org.matrix.android.sdk.api.auth.UserInteractiveAuthInterceptor
|
||||||
import org.matrix.android.sdk.api.util.Optional
|
import org.matrix.android.sdk.api.util.Optional
|
||||||
import org.matrix.android.sdk.internal.crypto.crosssigning.DeviceTrustResult
|
|
||||||
import org.matrix.android.sdk.internal.crypto.crosssigning.UserTrustResult
|
|
||||||
import org.matrix.android.sdk.internal.crypto.store.PrivateKeysInfo
|
|
||||||
|
|
||||||
interface CrossSigningService {
|
interface CrossSigningService {
|
||||||
|
|
||||||
|
|
|
@ -14,9 +14,10 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.matrix.android.sdk.internal.crypto.model
|
package org.matrix.android.sdk.api.session.crypto.crosssigning
|
||||||
|
|
||||||
import org.matrix.android.sdk.internal.crypto.crosssigning.DeviceTrustLevel
|
import org.matrix.android.sdk.internal.crypto.model.CryptoInfo
|
||||||
|
import org.matrix.android.sdk.internal.crypto.model.CryptoInfoMapper
|
||||||
import org.matrix.android.sdk.internal.crypto.model.rest.RestKeyInfo
|
import org.matrix.android.sdk.internal.crypto.model.rest.RestKeyInfo
|
||||||
|
|
||||||
data class CryptoCrossSigningKey(
|
data class CryptoCrossSigningKey(
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2020 The Matrix.org Foundation C.I.C.
|
* Copyright (c) 2022 The Matrix.org Foundation C.I.C.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -13,7 +13,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.matrix.android.sdk.internal.crypto.crosssigning
|
package org.matrix.android.sdk.api.session.crypto.crosssigning
|
||||||
|
|
||||||
data class DeviceTrustLevel(
|
data class DeviceTrustLevel(
|
||||||
val crossSigningVerified: Boolean,
|
val crossSigningVerified: Boolean,
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2020 The Matrix.org Foundation C.I.C.
|
* Copyright (c) 2022 The Matrix.org Foundation C.I.C.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -13,9 +13,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.matrix.android.sdk.internal.crypto.crosssigning
|
package org.matrix.android.sdk.api.session.crypto.crosssigning
|
||||||
|
|
||||||
import org.matrix.android.sdk.api.session.crypto.crosssigning.MXCrossSigningInfo
|
|
||||||
|
|
||||||
sealed class DeviceTrustResult {
|
sealed class DeviceTrustResult {
|
||||||
data class Success(val level: DeviceTrustLevel) : DeviceTrustResult()
|
data class Success(val level: DeviceTrustLevel) : DeviceTrustResult()
|
|
@ -16,9 +16,6 @@
|
||||||
|
|
||||||
package org.matrix.android.sdk.api.session.crypto.crosssigning
|
package org.matrix.android.sdk.api.session.crypto.crosssigning
|
||||||
|
|
||||||
import org.matrix.android.sdk.internal.crypto.model.CryptoCrossSigningKey
|
|
||||||
import org.matrix.android.sdk.internal.crypto.model.KeyUsage
|
|
||||||
|
|
||||||
data class MXCrossSigningInfo(
|
data class MXCrossSigningInfo(
|
||||||
val userId: String,
|
val userId: String,
|
||||||
val crossSigningKeys: List<CryptoCrossSigningKey>
|
val crossSigningKeys: List<CryptoCrossSigningKey>
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.matrix.android.sdk.internal.crypto.store
|
package org.matrix.android.sdk.api.session.crypto.crosssigning
|
||||||
|
|
||||||
data class PrivateKeysInfo(
|
data class PrivateKeysInfo(
|
||||||
val master: String? = null,
|
val master: String? = null,
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2020 The Matrix.org Foundation C.I.C.
|
* Copyright (c) 2022 The Matrix.org Foundation C.I.C.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -14,10 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.matrix.android.sdk.internal.crypto.crosssigning
|
package org.matrix.android.sdk.api.session.crypto.crosssigning
|
||||||
|
|
||||||
import org.matrix.android.sdk.api.session.crypto.crosssigning.MXCrossSigningInfo
|
|
||||||
import org.matrix.android.sdk.internal.crypto.model.CryptoCrossSigningKey
|
|
||||||
|
|
||||||
sealed class UserTrustResult {
|
sealed class UserTrustResult {
|
||||||
object Success : UserTrustResult()
|
object Success : UserTrustResult()
|
|
@ -14,9 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.matrix.android.sdk.internal.crypto.keysbackup.model
|
package org.matrix.android.sdk.api.session.crypto.keysbackup
|
||||||
|
|
||||||
import org.matrix.android.sdk.internal.crypto.keysbackup.model.rest.KeysVersionResult
|
|
||||||
|
|
||||||
sealed interface KeysBackupLastVersionResult {
|
sealed interface KeysBackupLastVersionResult {
|
||||||
// No Keys backup found (404 error)
|
// No Keys backup found (404 error)
|
|
@ -19,13 +19,7 @@ package org.matrix.android.sdk.api.session.crypto.keysbackup
|
||||||
import org.matrix.android.sdk.api.MatrixCallback
|
import org.matrix.android.sdk.api.MatrixCallback
|
||||||
import org.matrix.android.sdk.api.listeners.ProgressListener
|
import org.matrix.android.sdk.api.listeners.ProgressListener
|
||||||
import org.matrix.android.sdk.api.listeners.StepProgressListener
|
import org.matrix.android.sdk.api.listeners.StepProgressListener
|
||||||
import org.matrix.android.sdk.internal.crypto.keysbackup.model.KeysBackupLastVersionResult
|
import org.matrix.android.sdk.api.session.crypto.model.ImportRoomKeysResult
|
||||||
import org.matrix.android.sdk.internal.crypto.keysbackup.model.KeysBackupVersionTrust
|
|
||||||
import org.matrix.android.sdk.internal.crypto.keysbackup.model.MegolmBackupCreationInfo
|
|
||||||
import org.matrix.android.sdk.internal.crypto.keysbackup.model.rest.KeysVersion
|
|
||||||
import org.matrix.android.sdk.internal.crypto.keysbackup.model.rest.KeysVersionResult
|
|
||||||
import org.matrix.android.sdk.internal.crypto.model.ImportRoomKeysResult
|
|
||||||
import org.matrix.android.sdk.internal.crypto.store.SavedKeyBackupKeyInfo
|
|
||||||
|
|
||||||
interface KeysBackupService {
|
interface KeysBackupService {
|
||||||
/**
|
/**
|
||||||
|
@ -220,4 +214,9 @@ interface KeysBackupService {
|
||||||
fun getKeyBackupRecoveryKeyInfo(): SavedKeyBackupKeyInfo?
|
fun getKeyBackupRecoveryKeyInfo(): SavedKeyBackupKeyInfo?
|
||||||
|
|
||||||
fun isValidRecoveryKeyForCurrentVersion(recoveryKey: String, callback: MatrixCallback<Boolean>)
|
fun isValidRecoveryKeyForCurrentVersion(recoveryKey: String, callback: MatrixCallback<Boolean>)
|
||||||
|
|
||||||
|
fun computePrivateKey(passphrase: String,
|
||||||
|
privateKeySalt: String,
|
||||||
|
privateKeyIterations: Int,
|
||||||
|
progressListener: ProgressListener): ByteArray
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,10 +14,11 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.matrix.android.sdk.internal.crypto.keysbackup.model
|
package org.matrix.android.sdk.api.session.crypto.keysbackup
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Data model for response to [KeysBackup.getKeysBackupTrust()].
|
* Data model for response to [KeysBackup.getKeysBackupTrust()].
|
||||||
|
* TODO Members should be only val
|
||||||
*/
|
*/
|
||||||
data class KeysBackupVersionTrust(
|
data class KeysBackupVersionTrust(
|
||||||
/**
|
/**
|
|
@ -14,12 +14,13 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.matrix.android.sdk.internal.crypto.keysbackup.model
|
package org.matrix.android.sdk.api.session.crypto.keysbackup
|
||||||
|
|
||||||
import org.matrix.android.sdk.internal.crypto.model.CryptoDeviceInfo
|
import org.matrix.android.sdk.api.session.crypto.model.CryptoDeviceInfo
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A signature in a `KeysBackupVersionTrust` object.
|
* A signature in a `KeysBackupVersionTrust` object.
|
||||||
|
* TODO Make it a data class with only val
|
||||||
*/
|
*/
|
||||||
class KeysBackupVersionTrustSignature {
|
class KeysBackupVersionTrustSignature {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2020 The Matrix.org Foundation C.I.C.
|
* Copyright (c) 2022 The Matrix.org Foundation C.I.C.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.matrix.android.sdk.internal.crypto.keysbackup.model.rest
|
package org.matrix.android.sdk.api.session.crypto.keysbackup
|
||||||
|
|
||||||
import com.squareup.moshi.Json
|
import com.squareup.moshi.Json
|
||||||
import com.squareup.moshi.JsonClass
|
import com.squareup.moshi.JsonClass
|
|
@ -14,11 +14,12 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.matrix.android.sdk.internal.crypto.keysbackup.model.rest
|
package org.matrix.android.sdk.api.session.crypto.keysbackup
|
||||||
|
|
||||||
import com.squareup.moshi.Json
|
import com.squareup.moshi.Json
|
||||||
import com.squareup.moshi.JsonClass
|
import com.squareup.moshi.JsonClass
|
||||||
import org.matrix.android.sdk.api.util.JsonDict
|
import org.matrix.android.sdk.api.util.JsonDict
|
||||||
|
import org.matrix.android.sdk.internal.crypto.keysbackup.model.rest.KeysAlgorithmAndData
|
||||||
|
|
||||||
@JsonClass(generateAdapter = true)
|
@JsonClass(generateAdapter = true)
|
||||||
data class KeysVersionResult(
|
data class KeysVersionResult(
|
|
@ -14,11 +14,12 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.matrix.android.sdk.internal.crypto.keysbackup.model
|
package org.matrix.android.sdk.api.session.crypto.keysbackup
|
||||||
|
|
||||||
import com.squareup.moshi.Json
|
import com.squareup.moshi.Json
|
||||||
import com.squareup.moshi.JsonClass
|
import com.squareup.moshi.JsonClass
|
||||||
import org.matrix.android.sdk.api.util.JsonDict
|
import org.matrix.android.sdk.api.util.JsonDict
|
||||||
|
import org.matrix.android.sdk.internal.crypto.keysbackup.model.SignalableMegolmBackupAuthData
|
||||||
import org.matrix.android.sdk.internal.di.MoshiProvider
|
import org.matrix.android.sdk.internal.di.MoshiProvider
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -54,7 +55,7 @@ data class MegolmBackupAuthData(
|
||||||
val signatures: Map<String, Map<String, String>>? = null
|
val signatures: Map<String, Map<String, String>>? = null
|
||||||
) {
|
) {
|
||||||
|
|
||||||
fun toJsonDict(): JsonDict {
|
internal fun toJsonDict(): JsonDict {
|
||||||
val moshi = MoshiProvider.providesMoshi()
|
val moshi = MoshiProvider.providesMoshi()
|
||||||
val adapter = moshi.adapter(Map::class.java)
|
val adapter = moshi.adapter(Map::class.java)
|
||||||
|
|
||||||
|
@ -67,7 +68,7 @@ data class MegolmBackupAuthData(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun signalableJSONDictionary(): JsonDict {
|
internal fun signalableJSONDictionary(): JsonDict {
|
||||||
return SignalableMegolmBackupAuthData(
|
return SignalableMegolmBackupAuthData(
|
||||||
publicKey = publicKey,
|
publicKey = publicKey,
|
||||||
privateKeySalt = privateKeySalt,
|
privateKeySalt = privateKeySalt,
|
||||||
|
@ -76,20 +77,3 @@ data class MegolmBackupAuthData(
|
||||||
.signalableJSONDictionary()
|
.signalableJSONDictionary()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal data class SignalableMegolmBackupAuthData(
|
|
||||||
val publicKey: String,
|
|
||||||
val privateKeySalt: String? = null,
|
|
||||||
val privateKeyIterations: Int? = null
|
|
||||||
) {
|
|
||||||
fun signalableJSONDictionary(): JsonDict = HashMap<String, Any>().apply {
|
|
||||||
put("public_key", publicKey)
|
|
||||||
|
|
||||||
privateKeySalt?.let {
|
|
||||||
put("private_key_salt", it)
|
|
||||||
}
|
|
||||||
privateKeyIterations?.let {
|
|
||||||
put("private_key_iterations", it)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.matrix.android.sdk.internal.crypto.keysbackup.model
|
package org.matrix.android.sdk.api.session.crypto.keysbackup
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Data retrieved from Olm library. algorithm and authData will be send to the homeserver, and recoveryKey will be displayed to the user
|
* Data retrieved from Olm library. algorithm and authData will be send to the homeserver, and recoveryKey will be displayed to the user
|
|
@ -14,8 +14,10 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.matrix.android.sdk.internal.crypto.keysbackup.util
|
package org.matrix.android.sdk.api.session.crypto.keysbackup
|
||||||
|
|
||||||
|
import org.matrix.android.sdk.internal.crypto.keysbackup.util.base58decode
|
||||||
|
import org.matrix.android.sdk.internal.crypto.keysbackup.util.base58encode
|
||||||
import kotlin.experimental.xor
|
import kotlin.experimental.xor
|
||||||
|
|
||||||
/**
|
/**
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.matrix.android.sdk.internal.crypto.store
|
package org.matrix.android.sdk.api.session.crypto.keysbackup
|
||||||
|
|
||||||
data class SavedKeyBackupKeyInfo(
|
data class SavedKeyBackupKeyInfo(
|
||||||
val recoveryKey: String,
|
val recoveryKey: String,
|
|
@ -16,9 +16,9 @@
|
||||||
|
|
||||||
package org.matrix.android.sdk.api.session.crypto.keyshare
|
package org.matrix.android.sdk.api.session.crypto.keyshare
|
||||||
|
|
||||||
import org.matrix.android.sdk.internal.crypto.IncomingRequestCancellation
|
import org.matrix.android.sdk.api.session.crypto.model.IncomingRequestCancellation
|
||||||
import org.matrix.android.sdk.internal.crypto.IncomingRoomKeyRequest
|
import org.matrix.android.sdk.api.session.crypto.model.IncomingRoomKeyRequest
|
||||||
import org.matrix.android.sdk.internal.crypto.IncomingSecretShareRequest
|
import org.matrix.android.sdk.api.session.crypto.model.IncomingSecretShareRequest
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Room keys events listener
|
* Room keys events listener
|
||||||
|
|
|
@ -0,0 +1,75 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2020 The Matrix.org Foundation C.I.C.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.matrix.android.sdk.api.session.crypto.model
|
||||||
|
|
||||||
|
import org.matrix.android.sdk.api.session.crypto.crosssigning.DeviceTrustLevel
|
||||||
|
import org.matrix.android.sdk.internal.crypto.model.CryptoInfo
|
||||||
|
|
||||||
|
data class CryptoDeviceInfo(
|
||||||
|
val deviceId: String,
|
||||||
|
override val userId: String,
|
||||||
|
var algorithms: List<String>? = null,
|
||||||
|
override val keys: Map<String, String>? = null,
|
||||||
|
override val signatures: Map<String, Map<String, String>>? = null,
|
||||||
|
val unsigned: UnsignedDeviceInfo? = null,
|
||||||
|
var trustLevel: DeviceTrustLevel? = null,
|
||||||
|
var isBlocked: Boolean = false,
|
||||||
|
val firstTimeSeenLocalTs: Long? = null
|
||||||
|
) : CryptoInfo {
|
||||||
|
|
||||||
|
val isVerified: Boolean
|
||||||
|
get() = trustLevel?.isVerified() == true
|
||||||
|
|
||||||
|
val isUnknown: Boolean
|
||||||
|
get() = trustLevel == null
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the fingerprint
|
||||||
|
*/
|
||||||
|
fun fingerprint(): String? {
|
||||||
|
return keys
|
||||||
|
?.takeIf { deviceId.isNotBlank() }
|
||||||
|
?.get("ed25519:$deviceId")
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the identity key
|
||||||
|
*/
|
||||||
|
fun identityKey(): String? {
|
||||||
|
return keys
|
||||||
|
?.takeIf { deviceId.isNotBlank() }
|
||||||
|
?.get("curve25519:$deviceId")
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the display name
|
||||||
|
*/
|
||||||
|
fun displayName(): String? {
|
||||||
|
return unsigned?.deviceDisplayName
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun signalableJSONDictionary(): Map<String, Any> {
|
||||||
|
val map = HashMap<String, Any>()
|
||||||
|
map["device_id"] = deviceId
|
||||||
|
map["user_id"] = userId
|
||||||
|
algorithms?.let { map["algorithms"] = it }
|
||||||
|
keys?.let { map["keys"] = it }
|
||||||
|
return map
|
||||||
|
}
|
||||||
|
|
||||||
|
fun shortDebugString() = "$userId|$deviceId"
|
||||||
|
}
|
|
@ -13,7 +13,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.matrix.android.sdk.internal.crypto.model.rest
|
package org.matrix.android.sdk.api.session.crypto.model
|
||||||
|
|
||||||
import com.squareup.moshi.Json
|
import com.squareup.moshi.Json
|
||||||
import com.squareup.moshi.JsonClass
|
import com.squareup.moshi.JsonClass
|
|
@ -13,7 +13,8 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.matrix.android.sdk.internal.crypto.model.rest
|
|
||||||
|
package org.matrix.android.sdk.api.session.crypto.model
|
||||||
|
|
||||||
import com.squareup.moshi.Json
|
import com.squareup.moshi.Json
|
||||||
import com.squareup.moshi.JsonClass
|
import com.squareup.moshi.JsonClass
|
|
@ -13,7 +13,8 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.matrix.android.sdk.internal.crypto.model.rest
|
|
||||||
|
package org.matrix.android.sdk.api.session.crypto.model
|
||||||
|
|
||||||
import com.squareup.moshi.Json
|
import com.squareup.moshi.Json
|
||||||
import com.squareup.moshi.JsonClass
|
import com.squareup.moshi.JsonClass
|
|
@ -13,7 +13,8 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.matrix.android.sdk.internal.crypto.model.rest
|
|
||||||
|
package org.matrix.android.sdk.api.session.crypto.model
|
||||||
|
|
||||||
import com.squareup.moshi.Json
|
import com.squareup.moshi.Json
|
||||||
import com.squareup.moshi.JsonClass
|
import com.squareup.moshi.JsonClass
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2020 The Matrix.org Foundation C.I.C.
|
* Copyright (c) 2022 The Matrix.org Foundation C.I.C.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -13,7 +13,8 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.matrix.android.sdk.internal.crypto.model.rest
|
|
||||||
|
package org.matrix.android.sdk.api.session.crypto.model
|
||||||
|
|
||||||
import com.squareup.moshi.Json
|
import com.squareup.moshi.Json
|
||||||
import com.squareup.moshi.JsonClass
|
import com.squareup.moshi.JsonClass
|
|
@ -14,12 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.matrix.android.sdk.internal.crypto
|
package org.matrix.android.sdk.api.session.crypto.model
|
||||||
|
|
||||||
enum class GossipRequestType {
|
|
||||||
KEY,
|
|
||||||
SECRET
|
|
||||||
}
|
|
||||||
|
|
||||||
enum class GossipingRequestState {
|
enum class GossipingRequestState {
|
||||||
NONE,
|
NONE,
|
||||||
|
@ -34,13 +29,3 @@ enum class GossipingRequestState {
|
||||||
CANCELLED_BY_REQUESTER,
|
CANCELLED_BY_REQUESTER,
|
||||||
RE_REQUESTED
|
RE_REQUESTED
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class OutgoingGossipingRequestState {
|
|
||||||
UNSENT,
|
|
||||||
SENDING,
|
|
||||||
SENT,
|
|
||||||
CANCELLING,
|
|
||||||
CANCELLED,
|
|
||||||
FAILED_TO_SEND,
|
|
||||||
FAILED_TO_CANCEL
|
|
||||||
}
|
|
|
@ -13,10 +13,8 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.matrix.android.sdk.internal.crypto.model.rest
|
|
||||||
|
|
||||||
import com.squareup.moshi.Json
|
package org.matrix.android.sdk.api.session.crypto.model
|
||||||
import com.squareup.moshi.JsonClass
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface representing an room key action request
|
* Interface representing an room key action request
|
||||||
|
@ -35,10 +33,3 @@ interface GossipingToDeviceObject : SendToDeviceObject {
|
||||||
const val ACTION_SHARE_CANCELLATION = "request_cancellation"
|
const val ACTION_SHARE_CANCELLATION = "request_cancellation"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonClass(generateAdapter = true)
|
|
||||||
data class GossipingDefaultContent(
|
|
||||||
@Json(name = "action") override val action: String?,
|
|
||||||
@Json(name = "requesting_device_id") override val requestingDeviceId: String?,
|
|
||||||
@Json(name = "m.request_id") override val requestId: String? = null
|
|
||||||
) : GossipingToDeviceObject
|
|
|
@ -14,7 +14,9 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.matrix.android.sdk.internal.crypto.model
|
package org.matrix.android.sdk.api.session.crypto.model
|
||||||
|
|
||||||
data class ImportRoomKeysResult(val totalNumberOfKeys: Int,
|
data class ImportRoomKeysResult(
|
||||||
val successfullyNumberOfImportedKeys: Int)
|
val totalNumberOfKeys: Int,
|
||||||
|
val successfullyNumberOfImportedKeys: Int
|
||||||
|
)
|
|
@ -14,10 +14,11 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.matrix.android.sdk.internal.crypto
|
package org.matrix.android.sdk.api.session.crypto.model
|
||||||
|
|
||||||
import org.matrix.android.sdk.api.session.events.model.Event
|
import org.matrix.android.sdk.api.session.events.model.Event
|
||||||
import org.matrix.android.sdk.api.session.events.model.toModel
|
import org.matrix.android.sdk.api.session.events.model.toModel
|
||||||
|
import org.matrix.android.sdk.internal.crypto.IncomingShareRequestCommon
|
||||||
import org.matrix.android.sdk.internal.crypto.model.rest.ShareRequestCancellation
|
import org.matrix.android.sdk.internal.crypto.model.rest.ShareRequestCancellation
|
||||||
|
|
||||||
/**
|
/**
|
|
@ -14,12 +14,11 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.matrix.android.sdk.internal.crypto
|
package org.matrix.android.sdk.api.session.crypto.model
|
||||||
|
|
||||||
import org.matrix.android.sdk.api.session.events.model.Event
|
import org.matrix.android.sdk.api.session.events.model.Event
|
||||||
import org.matrix.android.sdk.api.session.events.model.toModel
|
import org.matrix.android.sdk.api.session.events.model.toModel
|
||||||
import org.matrix.android.sdk.internal.crypto.model.rest.RoomKeyRequestBody
|
import org.matrix.android.sdk.internal.crypto.IncomingShareRequestCommon
|
||||||
import org.matrix.android.sdk.internal.crypto.model.rest.RoomKeyShareRequest
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IncomingRoomKeyRequest class defines the incoming room keys request.
|
* IncomingRoomKeyRequest class defines the incoming room keys request.
|
|
@ -14,11 +14,11 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.matrix.android.sdk.internal.crypto
|
package org.matrix.android.sdk.api.session.crypto.model
|
||||||
|
|
||||||
import org.matrix.android.sdk.api.session.events.model.Event
|
import org.matrix.android.sdk.api.session.events.model.Event
|
||||||
import org.matrix.android.sdk.api.session.events.model.toModel
|
import org.matrix.android.sdk.api.session.events.model.toModel
|
||||||
import org.matrix.android.sdk.internal.crypto.model.rest.SecretShareRequest
|
import org.matrix.android.sdk.internal.crypto.IncomingShareRequestCommon
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IncomingSecretShareRequest class defines the incoming secret keys request.
|
* IncomingSecretShareRequest class defines the incoming secret keys request.
|
|
@ -14,12 +14,11 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.matrix.android.sdk.internal.crypto.model
|
package org.matrix.android.sdk.api.session.crypto.model
|
||||||
|
|
||||||
import com.squareup.moshi.Json
|
import com.squareup.moshi.Json
|
||||||
import com.squareup.moshi.JsonClass
|
import com.squareup.moshi.JsonClass
|
||||||
import org.matrix.android.sdk.api.util.JsonDict
|
import org.matrix.android.sdk.api.util.JsonDict
|
||||||
import org.matrix.android.sdk.internal.crypto.model.rest.DeviceKeys
|
|
||||||
import java.io.Serializable
|
import java.io.Serializable
|
||||||
|
|
||||||
@JsonClass(generateAdapter = true)
|
@JsonClass(generateAdapter = true)
|
||||||
|
@ -144,19 +143,6 @@ data class MXDeviceInfo(
|
||||||
return map
|
return map
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return a dictionary of the parameters
|
|
||||||
*/
|
|
||||||
fun toDeviceKeys(): DeviceKeys {
|
|
||||||
return DeviceKeys(
|
|
||||||
userId = userId,
|
|
||||||
deviceId = deviceId,
|
|
||||||
algorithms = algorithms!!,
|
|
||||||
keys = keys!!,
|
|
||||||
signatures = signatures!!
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun toString(): String {
|
override fun toString(): String {
|
||||||
return "MXDeviceInfo $userId:$deviceId"
|
return "MXDeviceInfo $userId:$deviceId"
|
||||||
}
|
}
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.matrix.android.sdk.internal.crypto.model
|
package org.matrix.android.sdk.api.session.crypto.model
|
||||||
|
|
||||||
import org.matrix.android.sdk.api.session.events.model.Content
|
import org.matrix.android.sdk.api.session.events.model.Content
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.matrix.android.sdk.internal.crypto
|
package org.matrix.android.sdk.api.session.crypto.model
|
||||||
|
|
||||||
import org.matrix.android.sdk.api.util.JsonDict
|
import org.matrix.android.sdk.api.util.JsonDict
|
||||||
|
|
||||||
|
@ -22,7 +22,6 @@ import org.matrix.android.sdk.api.util.JsonDict
|
||||||
* The result of a (successful) call to decryptEvent.
|
* The result of a (successful) call to decryptEvent.
|
||||||
*/
|
*/
|
||||||
data class MXEventDecryptionResult(
|
data class MXEventDecryptionResult(
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The plaintext payload for the event (typically containing "type" and "content" fields).
|
* The plaintext payload for the event (typically containing "type" and "content" fields).
|
||||||
*/
|
*/
|
|
@ -0,0 +1,131 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2020 The Matrix.org Foundation C.I.C.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.matrix.android.sdk.api.session.crypto.model
|
||||||
|
|
||||||
|
class MXUsersDevicesMap<E> {
|
||||||
|
|
||||||
|
// A map of maps (userId -> (deviceId -> Object)).
|
||||||
|
val map = HashMap<String /* userId */, HashMap<String /* deviceId */, E>>()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the user Ids
|
||||||
|
*/
|
||||||
|
val userIds: List<String>
|
||||||
|
get() = map.keys.toList()
|
||||||
|
|
||||||
|
val isEmpty: Boolean
|
||||||
|
get() = map.isEmpty()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides the device ids list for a user id
|
||||||
|
* FIXME Should maybe return emptyList and not null, to avoid many !! in the code
|
||||||
|
*
|
||||||
|
* @param userId the user id
|
||||||
|
* @return the device ids list
|
||||||
|
*/
|
||||||
|
fun getUserDeviceIds(userId: String?): List<String>? {
|
||||||
|
return if (!userId.isNullOrBlank() && map.containsKey(userId)) {
|
||||||
|
map[userId]!!.keys.toList()
|
||||||
|
} else null
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides the object for a device id and a user Id
|
||||||
|
*
|
||||||
|
* @param deviceId the device id
|
||||||
|
* @param userId the object id
|
||||||
|
* @return the object
|
||||||
|
*/
|
||||||
|
fun getObject(userId: String?, deviceId: String?): E? {
|
||||||
|
return if (!userId.isNullOrBlank() && !deviceId.isNullOrBlank()) {
|
||||||
|
map[userId]?.get(deviceId)
|
||||||
|
} else null
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set an object for a dedicated user Id and device Id
|
||||||
|
*
|
||||||
|
* @param userId the user Id
|
||||||
|
* @param deviceId the device id
|
||||||
|
* @param o the object to set
|
||||||
|
*/
|
||||||
|
fun setObject(userId: String?, deviceId: String?, o: E?) {
|
||||||
|
if (null != o && userId?.isNotBlank() == true && deviceId?.isNotBlank() == true) {
|
||||||
|
val devices = map.getOrPut(userId) { HashMap() }
|
||||||
|
devices[deviceId] = o
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines the objects map for a user Id
|
||||||
|
*
|
||||||
|
* @param objectsPerDevices the objects maps
|
||||||
|
* @param userId the user id
|
||||||
|
*/
|
||||||
|
fun setObjects(userId: String?, objectsPerDevices: Map<String, E>?) {
|
||||||
|
if (!userId.isNullOrBlank()) {
|
||||||
|
if (null == objectsPerDevices) {
|
||||||
|
map.remove(userId)
|
||||||
|
} else {
|
||||||
|
map[userId] = HashMap(objectsPerDevices)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes objects for a dedicated user
|
||||||
|
*
|
||||||
|
* @param userId the user id.
|
||||||
|
*/
|
||||||
|
fun removeUserObjects(userId: String?) {
|
||||||
|
if (!userId.isNullOrBlank()) {
|
||||||
|
map.remove(userId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear the internal dictionary
|
||||||
|
*/
|
||||||
|
fun removeAllObjects() {
|
||||||
|
map.clear()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add entries from another MXUsersDevicesMap
|
||||||
|
*
|
||||||
|
* @param other the other one
|
||||||
|
*/
|
||||||
|
fun addEntriesFromMap(other: MXUsersDevicesMap<E>?) {
|
||||||
|
if (null != other) {
|
||||||
|
map.putAll(other.map)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun toString(): String {
|
||||||
|
return "MXUsersDevicesMap $map"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline fun <T> MXUsersDevicesMap<T>.forEach(action: (String, String, T) -> Unit) {
|
||||||
|
userIds.forEach { userId ->
|
||||||
|
getUserDeviceIds(userId)?.forEach { deviceId ->
|
||||||
|
getObject(userId, deviceId)?.let {
|
||||||
|
action(userId, deviceId, it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2020 The Matrix.org Foundation C.I.C.
|
* Copyright (c) 2022 The Matrix.org Foundation C.I.C.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.matrix.android.sdk.internal.crypto.algorithms.olm
|
package org.matrix.android.sdk.api.session.crypto.model
|
||||||
|
|
||||||
import com.squareup.moshi.Json
|
import com.squareup.moshi.Json
|
||||||
import com.squareup.moshi.JsonClass
|
import com.squareup.moshi.JsonClass
|
|
@ -13,17 +13,15 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.matrix.android.sdk.internal.crypto.model.rest
|
|
||||||
|
|
||||||
import org.matrix.olm.OlmPkMessage
|
package org.matrix.android.sdk.api.session.crypto.model
|
||||||
|
|
||||||
/**
|
enum class OutgoingGossipingRequestState {
|
||||||
* Build from a OlmPkMessage object
|
UNSENT,
|
||||||
*
|
SENDING,
|
||||||
* @param olmPkMessage OlmPkMessage
|
SENT,
|
||||||
*/
|
CANCELLING,
|
||||||
class EncryptedBodyFileInfo(olmPkMessage: OlmPkMessage) {
|
CANCELLED,
|
||||||
var ciphertext = olmPkMessage.mCipherText
|
FAILED_TO_SEND,
|
||||||
var mac = olmPkMessage.mMac
|
FAILED_TO_CANCEL
|
||||||
var ephemeral = olmPkMessage.mEphemeralKey
|
|
||||||
}
|
}
|
|
@ -14,10 +14,10 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.matrix.android.sdk.internal.crypto
|
package org.matrix.android.sdk.api.session.crypto.model
|
||||||
|
|
||||||
import com.squareup.moshi.JsonClass
|
import com.squareup.moshi.JsonClass
|
||||||
import org.matrix.android.sdk.internal.crypto.model.rest.RoomKeyRequestBody
|
import org.matrix.android.sdk.internal.crypto.OutgoingGossipingRequest
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an outgoing room key request
|
* Represents an outgoing room key request
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.matrix.android.sdk.api.crypto
|
package org.matrix.android.sdk.api.session.crypto.model
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RoomEncryptionTrustLevel represents the trust level in an encrypted room.
|
* RoomEncryptionTrustLevel represents the trust level in an encrypted room.
|
|
@ -13,7 +13,8 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.matrix.android.sdk.internal.crypto.model.rest
|
|
||||||
|
package org.matrix.android.sdk.api.session.crypto.model
|
||||||
|
|
||||||
import com.squareup.moshi.Json
|
import com.squareup.moshi.Json
|
||||||
import com.squareup.moshi.JsonClass
|
import com.squareup.moshi.JsonClass
|
|
@ -13,7 +13,8 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.matrix.android.sdk.internal.crypto.model.rest
|
|
||||||
|
package org.matrix.android.sdk.api.session.crypto.model
|
||||||
|
|
||||||
import com.squareup.moshi.Json
|
import com.squareup.moshi.Json
|
||||||
import com.squareup.moshi.JsonClass
|
import com.squareup.moshi.JsonClass
|
|
@ -13,7 +13,8 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.matrix.android.sdk.internal.crypto.model.rest
|
|
||||||
|
package org.matrix.android.sdk.api.session.crypto.model
|
||||||
|
|
||||||
import com.squareup.moshi.Json
|
import com.squareup.moshi.Json
|
||||||
import com.squareup.moshi.JsonClass
|
import com.squareup.moshi.JsonClass
|
|
@ -14,6 +14,6 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.matrix.android.sdk.internal.crypto.model.rest
|
package org.matrix.android.sdk.api.session.crypto.model
|
||||||
|
|
||||||
interface SendToDeviceObject
|
interface SendToDeviceObject
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.matrix.android.sdk.internal.crypto.model.rest
|
package org.matrix.android.sdk.api.session.crypto.model
|
||||||
|
|
||||||
import com.squareup.moshi.Json
|
import com.squareup.moshi.Json
|
||||||
import com.squareup.moshi.JsonClass
|
import com.squareup.moshi.JsonClass
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2021 The Matrix.org Foundation C.I.C.
|
* Copyright (c) 2022 The Matrix.org Foundation C.I.C.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.matrix.android.sdk.api.crypto
|
package org.matrix.android.sdk.api.session.crypto.verification
|
||||||
|
|
||||||
enum class VerificationState {
|
enum class VerificationState {
|
||||||
REQUEST,
|
REQUEST,
|
|
@ -22,6 +22,8 @@ import org.json.JSONObject
|
||||||
import org.matrix.android.sdk.api.extensions.tryOrNull
|
import org.matrix.android.sdk.api.extensions.tryOrNull
|
||||||
import org.matrix.android.sdk.api.failure.MatrixError
|
import org.matrix.android.sdk.api.failure.MatrixError
|
||||||
import org.matrix.android.sdk.api.session.crypto.MXCryptoError
|
import org.matrix.android.sdk.api.session.crypto.MXCryptoError
|
||||||
|
import org.matrix.android.sdk.api.session.crypto.model.OlmDecryptionResult
|
||||||
|
import org.matrix.android.sdk.api.session.events.model.content.EncryptedEventContent
|
||||||
import org.matrix.android.sdk.api.session.room.model.Membership
|
import org.matrix.android.sdk.api.session.room.model.Membership
|
||||||
import org.matrix.android.sdk.api.session.room.model.RoomMemberContent
|
import org.matrix.android.sdk.api.session.room.model.RoomMemberContent
|
||||||
import org.matrix.android.sdk.api.session.room.model.message.MessageContent
|
import org.matrix.android.sdk.api.session.room.model.message.MessageContent
|
||||||
|
@ -34,8 +36,7 @@ import org.matrix.android.sdk.api.session.room.send.SendState
|
||||||
import org.matrix.android.sdk.api.session.threads.ThreadDetails
|
import org.matrix.android.sdk.api.session.threads.ThreadDetails
|
||||||
import org.matrix.android.sdk.api.util.ContentUtils
|
import org.matrix.android.sdk.api.util.ContentUtils
|
||||||
import org.matrix.android.sdk.api.util.JsonDict
|
import org.matrix.android.sdk.api.util.JsonDict
|
||||||
import org.matrix.android.sdk.internal.crypto.algorithms.olm.OlmDecryptionResult
|
import org.matrix.android.sdk.api.util.MatrixJsonParser
|
||||||
import org.matrix.android.sdk.internal.crypto.model.event.EncryptedEventContent
|
|
||||||
import org.matrix.android.sdk.internal.di.MoshiProvider
|
import org.matrix.android.sdk.internal.di.MoshiProvider
|
||||||
import org.matrix.android.sdk.internal.session.presence.model.PresenceContent
|
import org.matrix.android.sdk.internal.session.presence.model.PresenceContent
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
|
@ -46,7 +47,7 @@ typealias Content = JsonDict
|
||||||
* This methods is a facility method to map a json content to a model.
|
* This methods is a facility method to map a json content to a model.
|
||||||
*/
|
*/
|
||||||
inline fun <reified T> Content?.toModel(catchError: Boolean = true): T? {
|
inline fun <reified T> Content?.toModel(catchError: Boolean = true): T? {
|
||||||
val moshi = MoshiProvider.providesMoshi()
|
val moshi = MatrixJsonParser.getMoshi()
|
||||||
val moshiAdapter = moshi.adapter(T::class.java)
|
val moshiAdapter = moshi.adapter(T::class.java)
|
||||||
return try {
|
return try {
|
||||||
moshiAdapter.fromJsonValue(this)
|
moshiAdapter.fromJsonValue(this)
|
||||||
|
@ -65,7 +66,7 @@ inline fun <reified T> Content?.toModel(catchError: Boolean = true): T? {
|
||||||
*/
|
*/
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
inline fun <reified T> T.toContent(): Content {
|
inline fun <reified T> T.toContent(): Content {
|
||||||
val moshi = MoshiProvider.providesMoshi()
|
val moshi = MatrixJsonParser.getMoshi()
|
||||||
val moshiAdapter = moshi.adapter(T::class.java)
|
val moshiAdapter = moshi.adapter(T::class.java)
|
||||||
return moshiAdapter.toJsonValue(this) as Content
|
return moshiAdapter.toJsonValue(this) as Content
|
||||||
}
|
}
|
||||||
|
@ -412,7 +413,7 @@ fun Event.isEdition(): Boolean {
|
||||||
return getRelationContentForType(RelationType.REPLACE)?.eventId != null
|
return getRelationContentForType(RelationType.REPLACE)?.eventId != null
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Event.getPresenceContent(): PresenceContent? {
|
internal fun Event.getPresenceContent(): PresenceContent? {
|
||||||
return content.toModel<PresenceContent>()
|
return content.toModel<PresenceContent>()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2020 The Matrix.org Foundation C.I.C.
|
* Copyright (c) 2022 The Matrix.org Foundation C.I.C.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -13,7 +13,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.matrix.android.sdk.internal.crypto.model.event
|
package org.matrix.android.sdk.api.session.events.model.content
|
||||||
|
|
||||||
import com.squareup.moshi.Json
|
import com.squareup.moshi.Json
|
||||||
import com.squareup.moshi.JsonClass
|
import com.squareup.moshi.JsonClass
|
|
@ -13,7 +13,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.matrix.android.sdk.internal.crypto.model.event
|
package org.matrix.android.sdk.api.session.events.model.content
|
||||||
|
|
||||||
import com.squareup.moshi.Json
|
import com.squareup.moshi.Json
|
||||||
import com.squareup.moshi.JsonClass
|
import com.squareup.moshi.JsonClass
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue