mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 08:13:47 +00:00
global update of passport
This commit is contained in:
parent
1dc3ce2fb5
commit
e0bf67d8f9
@ -6,7 +6,8 @@
|
|||||||
|
|
||||||
* `Common`:
|
* `Common`:
|
||||||
* `Version`:
|
* `Version`:
|
||||||
* `MicroUtils`: `0.4.16` -> `0.4.21`
|
* `MicroUtils`: `0.4.16` -> `0.4.23`
|
||||||
|
* `Klock`: `0.2.3` -> `0.2.4`
|
||||||
* `Core`:
|
* `Core`:
|
||||||
* **BREAKING CHANGE** Now `MediaGroupMessage` have a generic type related to `MediaGroupContent`
|
* **BREAKING CHANGE** Now `MediaGroupMessage` have a generic type related to `MediaGroupContent`
|
||||||
* Methods and types related to `MediaGroupMessage` have been modified according to their meanings
|
* Methods and types related to `MediaGroupMessage` have been modified according to their meanings
|
||||||
|
@ -8,11 +8,11 @@ kotlin.incremental.js=true
|
|||||||
kotlin_version=1.4.21
|
kotlin_version=1.4.21
|
||||||
kotlin_coroutines_version=1.4.2
|
kotlin_coroutines_version=1.4.2
|
||||||
kotlin_serialisation_runtime_version=1.0.1
|
kotlin_serialisation_runtime_version=1.0.1
|
||||||
klock_version=2.0.3
|
klock_version=2.0.4
|
||||||
uuid_version=0.2.3
|
uuid_version=0.2.3
|
||||||
ktor_version=1.5.0
|
ktor_version=1.5.0
|
||||||
|
|
||||||
micro_utils_version=0.4.21
|
micro_utils_version=0.4.23
|
||||||
|
|
||||||
javax_activation_version=1.1.1
|
javax_activation_version=1.1.1
|
||||||
|
|
||||||
|
@ -1,23 +1,23 @@
|
|||||||
package dev.inmo.tgbotapi.types.passport
|
package dev.inmo.tgbotapi.types.passport
|
||||||
|
|
||||||
import dev.inmo.micro_utils.serialization.base64.Base64StringSerializer
|
import dev.inmo.micro_utils.crypto.SourceBytes
|
||||||
|
import dev.inmo.micro_utils.serialization.base64.Base64BytesToFromStringSerializer
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
typealias EncryptedAndBase64EncodedData = String
|
typealias EncryptedByBotPublicKeyData = SourceBytes
|
||||||
typealias EncryptedByBotPublicKeyData = String
|
typealias EncryptedData = SourceBytes
|
||||||
typealias EncryptedData = String
|
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class EncryptedCredentials(
|
data class EncryptedCredentials(
|
||||||
@SerialName(dataField)
|
@SerialName(dataField)
|
||||||
@Serializable(Base64StringSerializer::class)
|
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||||
val data: EncryptedData,
|
val data: EncryptedData,
|
||||||
@SerialName(hashField)
|
@SerialName(hashField)
|
||||||
@Serializable(Base64StringSerializer::class)
|
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||||
val hash: String,
|
val hash: SourceBytes,
|
||||||
@SerialName(secretField)
|
@SerialName(secretField)
|
||||||
@Serializable(Base64StringSerializer::class)
|
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||||
val secret: EncryptedByBotPublicKeyData
|
val secret: EncryptedByBotPublicKeyData
|
||||||
)
|
)
|
||||||
|
@ -4,7 +4,7 @@ package dev.inmo.tgbotapi.types.passport
|
|||||||
|
|
||||||
import dev.inmo.micro_utils.crypto.MD5
|
import dev.inmo.micro_utils.crypto.MD5
|
||||||
import dev.inmo.micro_utils.crypto.md5
|
import dev.inmo.micro_utils.crypto.md5
|
||||||
import dev.inmo.micro_utils.serialization.base64.Base64StringSerializer
|
import dev.inmo.micro_utils.serialization.base64.Base64BytesToFromStringSerializer
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts.*
|
import dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts.*
|
||||||
import dev.inmo.tgbotapi.types.passport.encrypted_data.type
|
import dev.inmo.tgbotapi.types.passport.encrypted_data.type
|
||||||
@ -70,12 +70,12 @@ object PassportElementErrorSerializer : KSerializer<PassportElementError> {
|
|||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
sealed class PassportSingleElementError : PassportElementError() {
|
sealed class PassportSingleElementError : PassportElementError() {
|
||||||
abstract val elementHash: String
|
abstract val elementHash: PassportElementHash
|
||||||
}
|
}
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
sealed class PassportMultipleElementsError : PassportElementError() {
|
sealed class PassportMultipleElementsError : PassportElementError() {
|
||||||
abstract val elementsHashes: List<String>
|
abstract val elementsHashes: List<PassportElementHash>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
@ -91,8 +91,8 @@ data class PassportElementErrorDataField(
|
|||||||
@SerialName(fieldNameField)
|
@SerialName(fieldNameField)
|
||||||
val fieldName: String,
|
val fieldName: String,
|
||||||
@SerialName(dataHashField)
|
@SerialName(dataHashField)
|
||||||
@Serializable(Base64StringSerializer::class)
|
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||||
override val elementHash: String,
|
override val elementHash: PassportElementHash,
|
||||||
@SerialName(messageField)
|
@SerialName(messageField)
|
||||||
override val message: String
|
override val message: String
|
||||||
) : PassportSingleElementError() {
|
) : PassportSingleElementError() {
|
||||||
@ -112,8 +112,8 @@ data class PassportElementErrorFrontSide(
|
|||||||
@SerialName(typeField)
|
@SerialName(typeField)
|
||||||
override val type: String,
|
override val type: String,
|
||||||
@SerialName(fileHashField)
|
@SerialName(fileHashField)
|
||||||
@Serializable(Base64StringSerializer::class)
|
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||||
override val elementHash: String,
|
override val elementHash: PassportElementHash,
|
||||||
@SerialName(messageField)
|
@SerialName(messageField)
|
||||||
override val message: String
|
override val message: String
|
||||||
) : PassportElementFileError() {
|
) : PassportElementFileError() {
|
||||||
@ -121,7 +121,7 @@ data class PassportElementErrorFrontSide(
|
|||||||
@Required
|
@Required
|
||||||
override val source: String = frontSideField
|
override val source: String = frontSideField
|
||||||
}
|
}
|
||||||
fun WithFrontSide.createFrontSideError(message: String, unencryptedFileHash: String) = PassportElementErrorFrontSide(
|
fun WithFrontSide.createFrontSideError(message: String, unencryptedFileHash: PassportElementHash) = PassportElementErrorFrontSide(
|
||||||
type,
|
type,
|
||||||
unencryptedFileHash,
|
unencryptedFileHash,
|
||||||
message
|
message
|
||||||
@ -132,8 +132,8 @@ data class PassportElementErrorReverseSide(
|
|||||||
@SerialName(typeField)
|
@SerialName(typeField)
|
||||||
override val type: String,
|
override val type: String,
|
||||||
@SerialName(fileHashField)
|
@SerialName(fileHashField)
|
||||||
@Serializable(Base64StringSerializer::class)
|
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||||
override val elementHash: String,
|
override val elementHash: PassportElementHash,
|
||||||
@SerialName(messageField)
|
@SerialName(messageField)
|
||||||
override val message: String
|
override val message: String
|
||||||
) : PassportElementFileError() {
|
) : PassportElementFileError() {
|
||||||
@ -141,7 +141,7 @@ data class PassportElementErrorReverseSide(
|
|||||||
@Required
|
@Required
|
||||||
override val source: String = reverseSideField
|
override val source: String = reverseSideField
|
||||||
}
|
}
|
||||||
fun WithReverseSide.createReverseSideError(message: String, unencryptedFileHash: String) = PassportElementErrorReverseSide(
|
fun WithReverseSide.createReverseSideError(message: String, unencryptedFileHash: PassportElementHash) = PassportElementErrorReverseSide(
|
||||||
type,
|
type,
|
||||||
unencryptedFileHash,
|
unencryptedFileHash,
|
||||||
message
|
message
|
||||||
@ -151,8 +151,8 @@ data class PassportElementErrorSelfie(
|
|||||||
@SerialName(typeField)
|
@SerialName(typeField)
|
||||||
override val type: String,
|
override val type: String,
|
||||||
@SerialName(fileHashField)
|
@SerialName(fileHashField)
|
||||||
@Serializable(Base64StringSerializer::class)
|
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||||
override val elementHash: String,
|
override val elementHash: PassportElementHash,
|
||||||
@SerialName(messageField)
|
@SerialName(messageField)
|
||||||
override val message: String
|
override val message: String
|
||||||
) : PassportElementFileError() {
|
) : PassportElementFileError() {
|
||||||
@ -160,7 +160,7 @@ data class PassportElementErrorSelfie(
|
|||||||
@Required
|
@Required
|
||||||
override val source: String = selfieField
|
override val source: String = selfieField
|
||||||
}
|
}
|
||||||
fun WithSelfie.createSelfieError(message: String, unencryptedFileHash: String) = PassportElementErrorSelfie(
|
fun WithSelfie.createSelfieError(message: String, unencryptedFileHash: PassportElementHash) = PassportElementErrorSelfie(
|
||||||
type,
|
type,
|
||||||
unencryptedFileHash,
|
unencryptedFileHash,
|
||||||
message
|
message
|
||||||
@ -172,8 +172,8 @@ data class PassportElementErrorFile(
|
|||||||
@SerialName(typeField)
|
@SerialName(typeField)
|
||||||
override val type: String,
|
override val type: String,
|
||||||
@SerialName(fileHashField)
|
@SerialName(fileHashField)
|
||||||
@Serializable(Base64StringSerializer::class)
|
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||||
override val elementHash: String,
|
override val elementHash: PassportElementHash,
|
||||||
@SerialName(messageField)
|
@SerialName(messageField)
|
||||||
override val message: String
|
override val message: String
|
||||||
) : PassportElementFileError() {
|
) : PassportElementFileError() {
|
||||||
@ -181,7 +181,7 @@ data class PassportElementErrorFile(
|
|||||||
@Required
|
@Required
|
||||||
override val source: String = fileField
|
override val source: String = fileField
|
||||||
}
|
}
|
||||||
fun FilesCollection.createFileError(message: String, unencryptedFileHash: String) = PassportElementErrorFile(
|
fun FilesCollection.createFileError(message: String, unencryptedFileHash: PassportElementHash) = PassportElementErrorFile(
|
||||||
type,
|
type,
|
||||||
unencryptedFileHash,
|
unencryptedFileHash,
|
||||||
message
|
message
|
||||||
@ -192,7 +192,7 @@ data class PassportElementErrorFiles(
|
|||||||
@SerialName(typeField)
|
@SerialName(typeField)
|
||||||
override val type: String,
|
override val type: String,
|
||||||
@SerialName(fileHashesField)
|
@SerialName(fileHashesField)
|
||||||
override val elementsHashes: List<@Serializable(Base64StringSerializer::class) String>,
|
override val elementsHashes: List<@Serializable(Base64BytesToFromStringSerializer::class) PassportElementHash>,
|
||||||
@SerialName(messageField)
|
@SerialName(messageField)
|
||||||
override val message: String
|
override val message: String
|
||||||
) : PassportElementFilesError() {
|
) : PassportElementFilesError() {
|
||||||
@ -200,7 +200,7 @@ data class PassportElementErrorFiles(
|
|||||||
@Required
|
@Required
|
||||||
override val source: String = filesField
|
override val source: String = filesField
|
||||||
}
|
}
|
||||||
fun FilesCollection.createFilesError(message: String, unencryptedFileHashes: List<String>) = PassportElementErrorFiles(
|
fun FilesCollection.createFilesError(message: String, unencryptedFileHashes: List<PassportElementHash>) = PassportElementErrorFiles(
|
||||||
type,
|
type,
|
||||||
unencryptedFileHashes,
|
unencryptedFileHashes,
|
||||||
message
|
message
|
||||||
@ -212,8 +212,8 @@ data class PassportElementErrorTranslationFile(
|
|||||||
@SerialName(typeField)
|
@SerialName(typeField)
|
||||||
override val type: String,
|
override val type: String,
|
||||||
@SerialName(fileHashField)
|
@SerialName(fileHashField)
|
||||||
@Serializable(Base64StringSerializer::class)
|
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||||
override val elementHash: String,
|
override val elementHash: PassportElementHash,
|
||||||
@SerialName(messageField)
|
@SerialName(messageField)
|
||||||
override val message: String
|
override val message: String
|
||||||
) : PassportElementFileError() {
|
) : PassportElementFileError() {
|
||||||
@ -221,7 +221,7 @@ data class PassportElementErrorTranslationFile(
|
|||||||
@Required
|
@Required
|
||||||
override val source: String = translationFileField
|
override val source: String = translationFileField
|
||||||
}
|
}
|
||||||
fun Translatable.createFileError(message: String, unencryptedFileHash: String) = PassportElementErrorTranslationFile(
|
fun Translatable.createFileError(message: String, unencryptedFileHash: PassportElementHash) = PassportElementErrorTranslationFile(
|
||||||
type,
|
type,
|
||||||
unencryptedFileHash,
|
unencryptedFileHash,
|
||||||
message
|
message
|
||||||
@ -231,7 +231,7 @@ data class PassportElementErrorTranslationFiles(
|
|||||||
@SerialName(typeField)
|
@SerialName(typeField)
|
||||||
override val type: String,
|
override val type: String,
|
||||||
@SerialName(fileHashesField)
|
@SerialName(fileHashesField)
|
||||||
override val elementsHashes: List<@Serializable(Base64StringSerializer::class) String>,
|
override val elementsHashes: List<@Serializable(Base64BytesToFromStringSerializer::class) PassportElementHash>,
|
||||||
@SerialName(messageField)
|
@SerialName(messageField)
|
||||||
override val message: String
|
override val message: String
|
||||||
) : PassportElementFilesError() {
|
) : PassportElementFilesError() {
|
||||||
@ -239,7 +239,7 @@ data class PassportElementErrorTranslationFiles(
|
|||||||
@Required
|
@Required
|
||||||
override val source: String = translationFilesField
|
override val source: String = translationFilesField
|
||||||
}
|
}
|
||||||
fun Translatable.createFilesError(message: String, unencryptedFileHashes: List<String>) = PassportElementErrorTranslationFiles(
|
fun Translatable.createFilesError(message: String, unencryptedFileHashes: List<PassportElementHash>) = PassportElementErrorTranslationFiles(
|
||||||
type,
|
type,
|
||||||
unencryptedFileHashes,
|
unencryptedFileHashes,
|
||||||
message
|
message
|
||||||
@ -250,8 +250,8 @@ data class PassportElementErrorUnspecified(
|
|||||||
@SerialName(typeField)
|
@SerialName(typeField)
|
||||||
override val type: String,
|
override val type: String,
|
||||||
@SerialName(fileHashField)
|
@SerialName(fileHashField)
|
||||||
@Serializable(Base64StringSerializer::class)
|
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||||
override val elementHash: String,
|
override val elementHash: PassportElementHash,
|
||||||
@SerialName(messageField)
|
@SerialName(messageField)
|
||||||
override val message: String
|
override val message: String
|
||||||
) : PassportElementFileError() {
|
) : PassportElementFileError() {
|
||||||
@ -259,7 +259,7 @@ data class PassportElementErrorUnspecified(
|
|||||||
@Required
|
@Required
|
||||||
override val source: String = unspecifiedField
|
override val source: String = unspecifiedField
|
||||||
}
|
}
|
||||||
fun EncryptedPassportElement.createUnspecifiedError(message: String, elementHash: String) = PassportElementErrorUnspecified(
|
fun EncryptedPassportElement.createUnspecifiedError(message: String, elementHash: PassportElementHash) = PassportElementErrorUnspecified(
|
||||||
type,
|
type,
|
||||||
elementHash,
|
elementHash,
|
||||||
message
|
message
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
package dev.inmo.tgbotapi.types.passport.encrypted_data
|
package dev.inmo.tgbotapi.types.passport.encrypted_data
|
||||||
|
|
||||||
import dev.inmo.micro_utils.serialization.base64.Base64StringSerializer
|
import dev.inmo.micro_utils.serialization.base64.Base64BytesToFromStringSerializer
|
||||||
import dev.inmo.tgbotapi.types.emailField
|
import dev.inmo.tgbotapi.types.emailField
|
||||||
import dev.inmo.tgbotapi.types.hashField
|
import dev.inmo.tgbotapi.types.hashField
|
||||||
|
import dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts.PassportElementHash
|
||||||
import dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts.WithEmail
|
import dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts.WithEmail
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
@ -12,7 +13,7 @@ data class Email(
|
|||||||
@SerialName(emailField)
|
@SerialName(emailField)
|
||||||
override val email: String,
|
override val email: String,
|
||||||
@SerialName(hashField)
|
@SerialName(hashField)
|
||||||
@Serializable(Base64StringSerializer::class)
|
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||||
override val hash: String
|
override val hash: PassportElementHash
|
||||||
) : WithEmail {
|
) : WithEmail {
|
||||||
}
|
}
|
@ -1,8 +1,9 @@
|
|||||||
package dev.inmo.tgbotapi.types.passport.encrypted_data
|
package dev.inmo.tgbotapi.types.passport.encrypted_data
|
||||||
|
|
||||||
import dev.inmo.micro_utils.serialization.base64.Base64StringSerializer
|
import dev.inmo.micro_utils.serialization.base64.Base64BytesToFromStringSerializer
|
||||||
import dev.inmo.tgbotapi.types.dataField
|
import dev.inmo.tgbotapi.types.dataField
|
||||||
import dev.inmo.tgbotapi.types.passport.EncryptedData
|
import dev.inmo.tgbotapi.types.passport.EncryptedData
|
||||||
|
import dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts.PassportElementHash
|
||||||
import dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts.WithData
|
import dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts.WithData
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
@ -10,8 +11,8 @@ import kotlinx.serialization.Serializable
|
|||||||
@Serializable
|
@Serializable
|
||||||
data class EncryptedAddress(
|
data class EncryptedAddress(
|
||||||
@SerialName(dataField)
|
@SerialName(dataField)
|
||||||
@Serializable(Base64StringSerializer::class)
|
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||||
override val data: EncryptedData,
|
override val data: EncryptedData,
|
||||||
@Serializable(Base64StringSerializer::class)
|
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||||
override val hash: String
|
override val hash: PassportElementHash
|
||||||
) : WithData
|
) : WithData
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package dev.inmo.tgbotapi.types.passport.encrypted_data
|
package dev.inmo.tgbotapi.types.passport.encrypted_data
|
||||||
|
|
||||||
|
import dev.inmo.micro_utils.crypto.decodeBase64
|
||||||
import dev.inmo.micro_utils.serialization.encapsulator.Encapsulator
|
import dev.inmo.micro_utils.serialization.encapsulator.Encapsulator
|
||||||
import dev.inmo.tgbotapi.types.hashField
|
import dev.inmo.tgbotapi.types.hashField
|
||||||
import dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts.EncryptedPassportElement
|
import dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts.EncryptedPassportElement
|
||||||
@ -45,7 +46,7 @@ object EncryptedElementSerializer : KSerializer<EncryptedPassportElement> {
|
|||||||
encryptedElementsClassesByTypes[type] ?.serializer ?.let { deserializer ->
|
encryptedElementsClassesByTypes[type] ?.serializer ?.let { deserializer ->
|
||||||
nonstrictJsonFormat.decodeFromJsonElement(deserializer, json)
|
nonstrictJsonFormat.decodeFromJsonElement(deserializer, json)
|
||||||
}
|
}
|
||||||
} ?: UnknownEncryptedPassportElement(json, json[hashField] ?.jsonPrimitive ?.content ?: "")
|
} ?: UnknownEncryptedPassportElement(json, json[hashField] ?.jsonPrimitive ?.content ?.decodeBase64() ?: byteArrayOf())
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun serialize(encoder: Encoder, value: EncryptedPassportElement) {
|
override fun serialize(encoder: Encoder, value: EncryptedPassportElement) {
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
package dev.inmo.tgbotapi.types.passport.encrypted_data
|
package dev.inmo.tgbotapi.types.passport.encrypted_data
|
||||||
|
|
||||||
import dev.inmo.micro_utils.serialization.base64.Base64StringSerializer
|
import dev.inmo.micro_utils.serialization.base64.Base64BytesToFromStringSerializer
|
||||||
import dev.inmo.tgbotapi.types.dataField
|
import dev.inmo.tgbotapi.types.dataField
|
||||||
import dev.inmo.tgbotapi.types.passport.EncryptedData
|
import dev.inmo.tgbotapi.types.passport.EncryptedData
|
||||||
|
import dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts.PassportElementHash
|
||||||
import dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts.WithData
|
import dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts.WithData
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
@ -10,8 +11,8 @@ import kotlinx.serialization.Serializable
|
|||||||
@Serializable
|
@Serializable
|
||||||
data class EncryptedPersonalDetails(
|
data class EncryptedPersonalDetails(
|
||||||
@SerialName(dataField)
|
@SerialName(dataField)
|
||||||
@Serializable(Base64StringSerializer::class)
|
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||||
override val data: EncryptedData,
|
override val data: EncryptedData,
|
||||||
@Serializable(Base64StringSerializer::class)
|
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||||
override val hash: String
|
override val hash: PassportElementHash
|
||||||
) : WithData
|
) : WithData
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package dev.inmo.tgbotapi.types.passport.encrypted_data
|
package dev.inmo.tgbotapi.types.passport.encrypted_data
|
||||||
|
|
||||||
import dev.inmo.micro_utils.serialization.base64.Base64StringSerializer
|
import dev.inmo.micro_utils.serialization.base64.Base64BytesToFromStringSerializer
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.passport.EncryptedData
|
import dev.inmo.tgbotapi.types.passport.EncryptedData
|
||||||
import dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts.*
|
import dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts.*
|
||||||
@ -13,7 +13,7 @@ sealed class Passport : WithData, WithFrontSide, WithSelfie, Translatable
|
|||||||
@Serializable
|
@Serializable
|
||||||
data class CommonPassport(
|
data class CommonPassport(
|
||||||
@SerialName(dataField)
|
@SerialName(dataField)
|
||||||
@Serializable(Base64StringSerializer::class)
|
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||||
override val data: EncryptedData,
|
override val data: EncryptedData,
|
||||||
@SerialName(frontSideField)
|
@SerialName(frontSideField)
|
||||||
override val frontSide: PassportFile? = null,
|
override val frontSide: PassportFile? = null,
|
||||||
@ -22,13 +22,13 @@ data class CommonPassport(
|
|||||||
@SerialName(translationField)
|
@SerialName(translationField)
|
||||||
override val translations: List<PassportFile> = emptyList(),
|
override val translations: List<PassportFile> = emptyList(),
|
||||||
@SerialName(hashField)
|
@SerialName(hashField)
|
||||||
@Serializable(Base64StringSerializer::class)
|
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||||
override val hash: String
|
override val hash: PassportElementHash
|
||||||
) : Passport()
|
) : Passport()
|
||||||
@Serializable
|
@Serializable
|
||||||
data class InternalPassport(
|
data class InternalPassport(
|
||||||
@SerialName(dataField)
|
@SerialName(dataField)
|
||||||
@Serializable(Base64StringSerializer::class)
|
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||||
override val data: EncryptedData,
|
override val data: EncryptedData,
|
||||||
@SerialName(frontSideField)
|
@SerialName(frontSideField)
|
||||||
override val frontSide: PassportFile? = null,
|
override val frontSide: PassportFile? = null,
|
||||||
@ -37,6 +37,6 @@ data class InternalPassport(
|
|||||||
@SerialName(translationField)
|
@SerialName(translationField)
|
||||||
override val translations: List<PassportFile> = emptyList(),
|
override val translations: List<PassportFile> = emptyList(),
|
||||||
@SerialName(hashField)
|
@SerialName(hashField)
|
||||||
@Serializable(Base64StringSerializer::class)
|
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||||
override val hash: String
|
override val hash: PassportElementHash
|
||||||
) : Passport()
|
) : Passport()
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
package dev.inmo.tgbotapi.types.passport.encrypted_data
|
package dev.inmo.tgbotapi.types.passport.encrypted_data
|
||||||
|
|
||||||
import dev.inmo.micro_utils.serialization.base64.Base64StringSerializer
|
import dev.inmo.micro_utils.serialization.base64.Base64BytesToFromStringSerializer
|
||||||
import dev.inmo.tgbotapi.types.hashField
|
import dev.inmo.tgbotapi.types.hashField
|
||||||
|
import dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts.PassportElementHash
|
||||||
import dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts.WithPhoneNumber
|
import dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts.WithPhoneNumber
|
||||||
import dev.inmo.tgbotapi.types.phoneNumberField
|
import dev.inmo.tgbotapi.types.phoneNumberField
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
@ -12,7 +13,7 @@ data class PhoneNumber(
|
|||||||
@SerialName(phoneNumberField)
|
@SerialName(phoneNumberField)
|
||||||
override val phoneNumber: String,
|
override val phoneNumber: String,
|
||||||
@SerialName(hashField)
|
@SerialName(hashField)
|
||||||
@Serializable(Base64StringSerializer::class)
|
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||||
override val hash: String
|
override val hash: PassportElementHash
|
||||||
) : WithPhoneNumber {
|
) : WithPhoneNumber {
|
||||||
}
|
}
|
@ -1,9 +1,8 @@
|
|||||||
package dev.inmo.tgbotapi.types.passport.encrypted_data
|
package dev.inmo.tgbotapi.types.passport.encrypted_data
|
||||||
|
|
||||||
import dev.inmo.micro_utils.serialization.base64.Base64StringSerializer
|
import dev.inmo.micro_utils.serialization.base64.Base64BytesToFromStringSerializer
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts.FilesCollection
|
import dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts.*
|
||||||
import dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts.Translatable
|
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
@ -17,8 +16,8 @@ data class UtilityBill(
|
|||||||
@SerialName(translationField)
|
@SerialName(translationField)
|
||||||
override val translations: List<PassportFile> = emptyList(),
|
override val translations: List<PassportFile> = emptyList(),
|
||||||
@SerialName(hashField)
|
@SerialName(hashField)
|
||||||
@Serializable(Base64StringSerializer::class)
|
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||||
override val hash: String
|
override val hash: PassportElementHash
|
||||||
) : TranslatableFilesCollection()
|
) : TranslatableFilesCollection()
|
||||||
@Serializable
|
@Serializable
|
||||||
data class BankStatement(
|
data class BankStatement(
|
||||||
@ -27,8 +26,8 @@ data class BankStatement(
|
|||||||
@SerialName(translationField)
|
@SerialName(translationField)
|
||||||
override val translations: List<PassportFile> = emptyList(),
|
override val translations: List<PassportFile> = emptyList(),
|
||||||
@SerialName(hashField)
|
@SerialName(hashField)
|
||||||
@Serializable(Base64StringSerializer::class)
|
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||||
override val hash: String
|
override val hash: PassportElementHash
|
||||||
) : TranslatableFilesCollection()
|
) : TranslatableFilesCollection()
|
||||||
@Serializable
|
@Serializable
|
||||||
data class RentalAgreement(
|
data class RentalAgreement(
|
||||||
@ -37,8 +36,8 @@ data class RentalAgreement(
|
|||||||
@SerialName(translationField)
|
@SerialName(translationField)
|
||||||
override val translations: List<PassportFile> = emptyList(),
|
override val translations: List<PassportFile> = emptyList(),
|
||||||
@SerialName(hashField)
|
@SerialName(hashField)
|
||||||
@Serializable(Base64StringSerializer::class)
|
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||||
override val hash: String
|
override val hash: PassportElementHash
|
||||||
) : TranslatableFilesCollection()
|
) : TranslatableFilesCollection()
|
||||||
@Serializable
|
@Serializable
|
||||||
data class PassportRegistration(
|
data class PassportRegistration(
|
||||||
@ -47,8 +46,8 @@ data class PassportRegistration(
|
|||||||
@SerialName(translationField)
|
@SerialName(translationField)
|
||||||
override val translations: List<PassportFile> = emptyList(),
|
override val translations: List<PassportFile> = emptyList(),
|
||||||
@SerialName(hashField)
|
@SerialName(hashField)
|
||||||
@Serializable(Base64StringSerializer::class)
|
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||||
override val hash: String
|
override val hash: PassportElementHash
|
||||||
) : TranslatableFilesCollection()
|
) : TranslatableFilesCollection()
|
||||||
@Serializable
|
@Serializable
|
||||||
data class TemporaryRegistration(
|
data class TemporaryRegistration(
|
||||||
@ -57,7 +56,7 @@ data class TemporaryRegistration(
|
|||||||
@SerialName(translationField)
|
@SerialName(translationField)
|
||||||
override val translations: List<PassportFile> = emptyList(),
|
override val translations: List<PassportFile> = emptyList(),
|
||||||
@SerialName(hashField)
|
@SerialName(hashField)
|
||||||
@Serializable(Base64StringSerializer::class)
|
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||||
override val hash: String
|
override val hash: PassportElementHash
|
||||||
) : TranslatableFilesCollection()
|
) : TranslatableFilesCollection()
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package dev.inmo.tgbotapi.types.passport.encrypted_data
|
package dev.inmo.tgbotapi.types.passport.encrypted_data
|
||||||
|
|
||||||
import dev.inmo.micro_utils.serialization.base64.Base64StringSerializer
|
import dev.inmo.micro_utils.serialization.base64.Base64BytesToFromStringSerializer
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.passport.EncryptedData
|
import dev.inmo.tgbotapi.types.passport.EncryptedData
|
||||||
import dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts.*
|
import dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts.*
|
||||||
@ -13,7 +13,7 @@ sealed class TranslatableIDDocument : WithData, WithFrontSide, WithReverseSide,
|
|||||||
@Serializable
|
@Serializable
|
||||||
data class DriverLicense(
|
data class DriverLicense(
|
||||||
@SerialName(dataField)
|
@SerialName(dataField)
|
||||||
@Serializable(Base64StringSerializer::class)
|
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||||
override val data: EncryptedData,
|
override val data: EncryptedData,
|
||||||
@SerialName(frontSideField)
|
@SerialName(frontSideField)
|
||||||
override val frontSide: PassportFile? = null,
|
override val frontSide: PassportFile? = null,
|
||||||
@ -24,14 +24,14 @@ data class DriverLicense(
|
|||||||
@SerialName(translationField)
|
@SerialName(translationField)
|
||||||
override val translations: List<PassportFile> = emptyList(),
|
override val translations: List<PassportFile> = emptyList(),
|
||||||
@SerialName(hashField)
|
@SerialName(hashField)
|
||||||
@Serializable(Base64StringSerializer::class)
|
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||||
override val hash: String
|
override val hash: PassportElementHash
|
||||||
) : TranslatableIDDocument()
|
) : TranslatableIDDocument()
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class IdentityCard(
|
data class IdentityCard(
|
||||||
@SerialName(dataField)
|
@SerialName(dataField)
|
||||||
@Serializable(Base64StringSerializer::class)
|
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||||
override val data: EncryptedData,
|
override val data: EncryptedData,
|
||||||
@SerialName(frontSideField)
|
@SerialName(frontSideField)
|
||||||
override val frontSide: PassportFile? = null,
|
override val frontSide: PassportFile? = null,
|
||||||
@ -42,6 +42,6 @@ data class IdentityCard(
|
|||||||
@SerialName(translationField)
|
@SerialName(translationField)
|
||||||
override val translations: List<PassportFile> = emptyList(),
|
override val translations: List<PassportFile> = emptyList(),
|
||||||
@SerialName(hashField)
|
@SerialName(hashField)
|
||||||
@Serializable(Base64StringSerializer::class)
|
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||||
override val hash: String
|
override val hash: PassportElementHash
|
||||||
) : TranslatableIDDocument()
|
) : TranslatableIDDocument()
|
||||||
|
@ -1,18 +1,21 @@
|
|||||||
package dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts
|
package dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts
|
||||||
|
|
||||||
import dev.inmo.micro_utils.serialization.base64.Base64StringSerializer
|
import dev.inmo.micro_utils.crypto.SourceBytes
|
||||||
|
import dev.inmo.micro_utils.serialization.base64.Base64BytesToFromStringSerializer
|
||||||
import dev.inmo.tgbotapi.types.passport.encrypted_data.EncryptedElementSerializer
|
import dev.inmo.tgbotapi.types.passport.encrypted_data.EncryptedElementSerializer
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import kotlinx.serialization.json.JsonObject
|
import kotlinx.serialization.json.JsonObject
|
||||||
|
|
||||||
|
typealias PassportElementHash = SourceBytes
|
||||||
|
|
||||||
@Serializable(EncryptedElementSerializer::class)
|
@Serializable(EncryptedElementSerializer::class)
|
||||||
interface EncryptedPassportElement {
|
interface EncryptedPassportElement {
|
||||||
val hash: String
|
val hash: PassportElementHash
|
||||||
}
|
}
|
||||||
|
|
||||||
@Serializable(EncryptedElementSerializer::class)
|
@Serializable(EncryptedElementSerializer::class)
|
||||||
data class UnknownEncryptedPassportElement(
|
data class UnknownEncryptedPassportElement(
|
||||||
val rawJson: JsonObject,
|
val rawJson: JsonObject,
|
||||||
@Serializable(Base64StringSerializer::class)
|
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||||
override val hash: String
|
override val hash: PassportElementHash
|
||||||
) : EncryptedPassportElement
|
) : EncryptedPassportElement
|
||||||
|
@ -29,5 +29,5 @@ fun Decryptor.decryptData(
|
|||||||
data: EncryptedCredentials
|
data: EncryptedCredentials
|
||||||
) = nonstrictJsonFormat.decodeFromString(
|
) = nonstrictJsonFormat.decodeFromString(
|
||||||
JsonObject.serializer(),
|
JsonObject.serializer(),
|
||||||
data.data.encodeToByteArray().decrypt().decodeToString()
|
data.data.decrypt().decodeToString()
|
||||||
)
|
)
|
||||||
|
@ -18,7 +18,7 @@ class PKCS8Decryptor (key: String): Decryptor {
|
|||||||
private val chunkSize: Int = privateKey.modulus.bitLength() / 8
|
private val chunkSize: Int = privateKey.modulus.bitLength() / 8
|
||||||
|
|
||||||
override fun ByteArray.decrypt(): ByteArray {
|
override fun ByteArray.decrypt(): ByteArray {
|
||||||
return Cipher.getInstance("RSA/ECB/PKCS1Padding").run {
|
return Cipher.getInstance("RSA/ECB/OAEPWITHSHA-256ANDMGF1PADDING").run {
|
||||||
init(Cipher.DECRYPT_MODE, privateKey)
|
init(Cipher.DECRYPT_MODE, privateKey)
|
||||||
(0 until size step chunkSize).flatMap {
|
(0 until size step chunkSize).flatMap {
|
||||||
val firstIndex = it
|
val firstIndex = it
|
||||||
|
@ -36,7 +36,7 @@ OEg9BHa+Du8jSv0vL/fCN2s/2TcvSa9uEnv8KHz59JHevvxoDNbQYlN8Ge8adFv4
|
|||||||
xZYQ3h/qh2ohnTUfrG4hcFUVBuv5HBdwgWhVFm5v98KQsqVzGfKorN2DemEv3/au
|
xZYQ3h/qh2ohnTUfrG4hcFUVBuv5HBdwgWhVFm5v98KQsqVzGfKorN2DemEv3/au
|
||||||
PFGkuu4lCPeDqu5u0dBojoA=
|
PFGkuu4lCPeDqu5u0dBojoA=
|
||||||
-----END PRIVATE KEY-----"""
|
-----END PRIVATE KEY-----"""
|
||||||
val encryptedLoremIpsum = "KeuPVezTbMW4MvOGJFTAt34PRaL9iepGb1g4QEi5EQYjKXeXo7RytFOCVx6pW9O/uoMWhl+cX32kNqJVWyK7a22kuhnNT2+aiXqEpuh+madx+LK1zUvGDR1A1Mrf3fFOugcnadCQKICiqvl9cFdqsBkJQOFEs9qj5wiu1F57kekuHLWI7ZnHOojkRNq7l1aCHL0DxcLCfZW5CtWAi8g/zUE5WnGd+vUZ+hqc1vnehDul8JE8YUQbAiIxetzba9XoWouTHYZRZcNCztDbrRBYnq2UCcI5adEwQ3VNcES0lIjRuwn1BBWpvk7VOjqh+4c2tSebDX5AkqrO8XwQYwo8OwvZF+hUXFRK6QLHd4B1JQIdygCaEODG0X353upiEKJXDBqv/ZMXR9KqYZBZEfu48ZM/J6heNjVSOP4TSDrXywJgIOieu8mrQ4d7Or7Twnsu/B+bqS37PvVlfU4wHLl7ehXFj4Kusat6cIrb0R4F/Y3fL4+FcfEsk4ioEAndYBFrc1S11vo/TkcuFnXtqrr181gC5JD5LtsUH6sst36vE/JdL/UwTGqhu+rDUcgvr7FiunkasWBnzCtFs58JJrRycUKPzyKINS16GkY8yYtp7xJXBGPYOFM+J7npcKW7P41j1KceDaUArjph2yIELEXCr8qUZzWXZdrw96Te8gLi99c="
|
val encryptedLoremIpsum = "F57wnFj3PTQ+xNgDFLCNRIHVf8Kp7YiaQdYOOEpuWMuICFBvVDrTst82jxhRuKj8w9qDZ0ys9pQ30QjnmCP0h/d8HhmLcG3sYY9fnDgd4hegY0D917Xhc0F5KwheFxNgHFn5uRuTdAoyBVUeAzclpR7XoEO8Zp+kYvNty7eOpLVC2jXBTiTBClXmxM15M48Pw7ClZr2lvjFf7r+4Bh8UAYM8IIKctV/Vk1iR7SIilHOw/GNhgBB1zy0SYlwSuvPEIPfZnEPL4zS9VqDN4Di53Zt7ZLhySBMDi1qA4V6OnjSoF6nexCrytMqIsLHrTbfin5ni20F+vIITFxa7kJU2+AVQFTsYrquL5zN9ms56kkLd3HMv/fdrz9Ry19vSaIjyajipoWPM6BvzNccYk2xnZx+5qzpZUQjsh+Xr+HD7GcpdGwavcz7WqGlx9qKBPwU0rq0+QCRpDz/hnl2gdChk+bjTAfuRWJDoUUetVV283BG8UY5SENH7EjOhtaMsEgog6VI2yyiei6azxZ+MTqkREnHWmjefsBHmbAbf2EEZag+nSjIZhNT62FkhWq5jBghjduoKixS5OUvWniY3wSx0RSXsJPVg9C80EyeO8wyOop7x0wN5zxKoXrniX6AGruEt74SJt9RZamniog2X5CJ27D94HvoF2qXSv9QeqK+qUj9XxGhn0AtqFnvg/yU/jUp6z4yGQ7CkIMHEMbq4ylRA87ydhu3HbqdrW3q8aRXtvo+VFQ8jmsOq+ssj2q7y2WegBMNCBMRjn197S/eBW4EweIqh9+3VsDRoabfUUuCDXBlA+qFOAYEB44TGiaXqneHjUwhDahKlui8556ILcUP4yNnFNA6wx/tgRiW40cEa6vs4CF4UPtzKrVgWwS8/hRd7OBaK/jU3KnMGKZej9AtV28ErDmBTcixMzpflPmUFQABwH7IhUzJMVlqDifZuVjthGZ3FWuPaFOcesQoScQ1q93pohz1vjwtyT5fU36JzyhYpEpmN6h3GiAFV6qT0VDiE"
|
||||||
|
|
||||||
|
|
||||||
class DecryptionTest {
|
class DecryptionTest {
|
||||||
|
Loading…
Reference in New Issue
Block a user