mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-03-17 19:58:57 +03:00
Identity: Add some doc
This commit is contained in:
parent
1535f3e2e5
commit
756b0febe6
7 changed files with 39 additions and 17 deletions
|
@ -28,8 +28,8 @@ import im.vector.matrix.android.internal.di.UserId
|
|||
import im.vector.matrix.android.internal.network.executeRequest
|
||||
import im.vector.matrix.android.internal.session.identity.db.IdentityServiceStore
|
||||
import im.vector.matrix.android.internal.session.identity.model.IdentityHashDetailResponse
|
||||
import im.vector.matrix.android.internal.session.identity.model.IdentityLookUpV2Params
|
||||
import im.vector.matrix.android.internal.session.identity.model.IdentityLookUpV2Response
|
||||
import im.vector.matrix.android.internal.session.identity.model.IdentityLookUpParams
|
||||
import im.vector.matrix.android.internal.session.identity.model.IdentityLookUpResponse
|
||||
import im.vector.matrix.android.internal.task.Task
|
||||
import java.util.Locale
|
||||
import javax.inject.Inject
|
||||
|
@ -81,10 +81,10 @@ internal class DefaultBulkLookupTask @Inject constructor(
|
|||
private suspend fun lookUpInternal(identityAPI: IdentityAPI,
|
||||
hashedAddresses: List<String>,
|
||||
hashDetailResponse: IdentityHashDetailResponse,
|
||||
canRetry: Boolean): IdentityLookUpV2Response {
|
||||
canRetry: Boolean): IdentityLookUpResponse {
|
||||
return try {
|
||||
executeRequest(null) {
|
||||
apiCall = identityAPI.bulkLookupV2(IdentityLookUpV2Params(
|
||||
apiCall = identityAPI.lookup(IdentityLookUpParams(
|
||||
hashedAddresses,
|
||||
"sha256",
|
||||
hashDetailResponse.pepper
|
||||
|
@ -125,9 +125,9 @@ internal class DefaultBulkLookupTask @Inject constructor(
|
|||
.also { identityServiceStore.setHashDetails(it) }
|
||||
}
|
||||
|
||||
private fun handleSuccess(threePids: List<ThreePid>, hashedAddresses: List<String>, identityLookUpV2Response: IdentityLookUpV2Response): List<FoundThreePid> {
|
||||
return identityLookUpV2Response.mappings.keys.map { hashedAddress ->
|
||||
FoundThreePid(threePids[hashedAddresses.indexOf(hashedAddress)], identityLookUpV2Response.mappings[hashedAddress] ?: error(""))
|
||||
private fun handleSuccess(threePids: List<ThreePid>, hashedAddresses: List<String>, identityLookUpResponse: IdentityLookUpResponse): List<FoundThreePid> {
|
||||
return identityLookUpResponse.mappings.keys.map { hashedAddress ->
|
||||
FoundThreePid(threePids[hashedAddresses.indexOf(hashedAddress)], identityLookUpResponse.mappings[hashedAddress] ?: error(""))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,13 +16,11 @@
|
|||
|
||||
package im.vector.matrix.android.internal.session.identity
|
||||
|
||||
import im.vector.matrix.android.internal.auth.registration.SuccessResult
|
||||
import im.vector.matrix.android.internal.network.NetworkConstants
|
||||
import im.vector.matrix.android.internal.session.identity.model.IdentityAccountResponse
|
||||
import im.vector.matrix.android.internal.session.identity.model.IdentityHashDetailResponse
|
||||
import im.vector.matrix.android.internal.session.identity.model.IdentityLookUpV2Params
|
||||
import im.vector.matrix.android.internal.session.identity.model.IdentityLookUpV2Response
|
||||
import im.vector.matrix.android.internal.session.identity.model.IdentityRequestOwnershipParams
|
||||
import im.vector.matrix.android.internal.session.identity.model.IdentityLookUpParams
|
||||
import im.vector.matrix.android.internal.session.identity.model.IdentityLookUpResponse
|
||||
import im.vector.matrix.android.internal.session.identity.model.IdentityRequestTokenForEmailBody
|
||||
import im.vector.matrix.android.internal.session.identity.model.IdentityRequestTokenForMsisdnBody
|
||||
import im.vector.matrix.android.internal.session.identity.model.IdentityRequestTokenResponse
|
||||
|
@ -30,7 +28,6 @@ import retrofit2.Call
|
|||
import retrofit2.http.Body
|
||||
import retrofit2.http.GET
|
||||
import retrofit2.http.POST
|
||||
import retrofit2.http.Path
|
||||
|
||||
/**
|
||||
* Ref: https://matrix.org/docs/spec/identity_service/latest
|
||||
|
@ -40,6 +37,7 @@ internal interface IdentityAPI {
|
|||
/**
|
||||
* Gets information about what user owns the access token used in the request.
|
||||
* Will return a 403 for when terms are not signed
|
||||
* Ref: https://matrix.org/docs/spec/identity_service/latest#get-matrix-identity-v2-account
|
||||
*/
|
||||
@GET(NetworkConstants.URI_IDENTITY_PATH_V2 + "account")
|
||||
fun getAccount(): Call<IdentityAccountResponse>
|
||||
|
@ -52,17 +50,19 @@ internal interface IdentityAPI {
|
|||
|
||||
/**
|
||||
* Request the hash detail to request a bunch of 3PIDs
|
||||
* Ref: https://matrix.org/docs/spec/identity_service/latest#get-matrix-identity-v2-hash-details
|
||||
*/
|
||||
@GET(NetworkConstants.URI_IDENTITY_PATH_V2 + "hash_details")
|
||||
fun hashDetails(): Call<IdentityHashDetailResponse>
|
||||
|
||||
/**
|
||||
* Request a bunch of 3PIDs
|
||||
* Ref: https://matrix.org/docs/spec/identity_service/latest#post-matrix-identity-v2-lookup
|
||||
*
|
||||
* @param body the body request
|
||||
*/
|
||||
@POST(NetworkConstants.URI_IDENTITY_PATH_V2 + "lookup")
|
||||
fun bulkLookupV2(@Body body: IdentityLookUpV2Params): Call<IdentityLookUpV2Response>
|
||||
fun lookup(@Body body: IdentityLookUpParams): Call<IdentityLookUpResponse>
|
||||
|
||||
/**
|
||||
* Create a session to change the bind status of an email to an identity server
|
||||
|
|
|
@ -21,6 +21,9 @@ import com.squareup.moshi.JsonClass
|
|||
|
||||
@JsonClass(generateAdapter = true)
|
||||
internal data class IdentityAccountResponse(
|
||||
/**
|
||||
* Required. The user ID which registered the token.
|
||||
*/
|
||||
@Json(name = "user_id")
|
||||
val userId: String
|
||||
)
|
||||
|
|
|
@ -24,11 +24,16 @@ import com.squareup.moshi.JsonClass
|
|||
*/
|
||||
@JsonClass(generateAdapter = true)
|
||||
internal data class IdentityHashDetailResponse(
|
||||
/**
|
||||
* Required. The pepper the client MUST use in hashing identifiers, and MUST supply to the /lookup endpoint when performing lookups.
|
||||
* Servers SHOULD rotate this string often.
|
||||
*/
|
||||
@Json(name = "lookup_pepper")
|
||||
val pepper: String,
|
||||
|
||||
/**
|
||||
* "sha256" must be supported by client. "none" can be another possible value.
|
||||
* Required. The algorithms the server supports. Must contain at least "sha256".
|
||||
* "none" can be another possible value.
|
||||
*/
|
||||
@Json(name = "algorithms")
|
||||
val algorithms: List<String>
|
||||
|
|
|
@ -23,14 +23,24 @@ import com.squareup.moshi.JsonClass
|
|||
* Ref: https://github.com/matrix-org/matrix-doc/blob/hs/hash-identity/proposals/2134-identity-hash-lookup.md
|
||||
*/
|
||||
@JsonClass(generateAdapter = true)
|
||||
internal data class IdentityLookUpV2Params(
|
||||
internal data class IdentityLookUpParams(
|
||||
/**
|
||||
* Required. The addresses to look up. The format of the entries here depend on the algorithm used.
|
||||
* Note that queries which have been incorrectly hashed or formatted will lead to no matches.
|
||||
*/
|
||||
@Json(name = "addresses")
|
||||
val hashedAddresses: List<String>,
|
||||
|
||||
/**
|
||||
* Required. The algorithm the client is using to encode the addresses. This should be one of the available options from /hash_details.
|
||||
*/
|
||||
@JvmField
|
||||
@Json(name = "algorithm")
|
||||
val algorithm: String,
|
||||
|
||||
/**
|
||||
* Required. The pepper from /hash_details. This is required even when the algorithm does not make use of it.
|
||||
*/
|
||||
@JvmField
|
||||
@Json(name = "pepper")
|
||||
val pepper: String
|
|
@ -23,7 +23,11 @@ import com.squareup.moshi.JsonClass
|
|||
* Ref: https://github.com/matrix-org/matrix-doc/blob/hs/hash-identity/proposals/2134-identity-hash-lookup.md
|
||||
*/
|
||||
@JsonClass(generateAdapter = true)
|
||||
internal data class IdentityLookUpV2Response(
|
||||
internal data class IdentityLookUpResponse(
|
||||
/**
|
||||
* Required. Any applicable mappings of addresses to Matrix User IDs. Addresses which do not have associations will
|
||||
* not be included, which can make this property be an empty object.
|
||||
*/
|
||||
@Json(name = "mappings")
|
||||
val mappings: Map<String, String>
|
||||
)
|
|
@ -22,7 +22,7 @@ import com.squareup.moshi.JsonClass
|
|||
@JsonClass(generateAdapter = true)
|
||||
internal data class IdentityRegisterResponse(
|
||||
/**
|
||||
* A token which can be used to authenticate future requests to the identity server.
|
||||
* Required. An opaque string representing the token to authenticate future requests to the identity server with.
|
||||
*/
|
||||
@Json(name = "token")
|
||||
val token: String
|
||||
|
|
Loading…
Add table
Reference in a new issue