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`:
|
||||
* `Version`:
|
||||
* `MicroUtils`: `0.4.16` -> `0.4.21`
|
||||
* `MicroUtils`: `0.4.16` -> `0.4.23`
|
||||
* `Klock`: `0.2.3` -> `0.2.4`
|
||||
* `Core`:
|
||||
* **BREAKING CHANGE** Now `MediaGroupMessage` have a generic type related to `MediaGroupContent`
|
||||
* 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_coroutines_version=1.4.2
|
||||
kotlin_serialisation_runtime_version=1.0.1
|
||||
klock_version=2.0.3
|
||||
klock_version=2.0.4
|
||||
uuid_version=0.2.3
|
||||
ktor_version=1.5.0
|
||||
|
||||
micro_utils_version=0.4.21
|
||||
micro_utils_version=0.4.23
|
||||
|
||||
javax_activation_version=1.1.1
|
||||
|
||||
|
@ -1,23 +1,23 @@
|
||||
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 kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
typealias EncryptedAndBase64EncodedData = String
|
||||
typealias EncryptedByBotPublicKeyData = String
|
||||
typealias EncryptedData = String
|
||||
typealias EncryptedByBotPublicKeyData = SourceBytes
|
||||
typealias EncryptedData = SourceBytes
|
||||
|
||||
@Serializable
|
||||
data class EncryptedCredentials(
|
||||
@SerialName(dataField)
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||
val data: EncryptedData,
|
||||
@SerialName(hashField)
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
val hash: String,
|
||||
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||
val hash: SourceBytes,
|
||||
@SerialName(secretField)
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||
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.serialization.base64.Base64StringSerializer
|
||||
import dev.inmo.micro_utils.serialization.base64.Base64BytesToFromStringSerializer
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts.*
|
||||
import dev.inmo.tgbotapi.types.passport.encrypted_data.type
|
||||
@ -70,12 +70,12 @@ object PassportElementErrorSerializer : KSerializer<PassportElementError> {
|
||||
|
||||
@Serializable
|
||||
sealed class PassportSingleElementError : PassportElementError() {
|
||||
abstract val elementHash: String
|
||||
abstract val elementHash: PassportElementHash
|
||||
}
|
||||
|
||||
@Serializable
|
||||
sealed class PassportMultipleElementsError : PassportElementError() {
|
||||
abstract val elementsHashes: List<String>
|
||||
abstract val elementsHashes: List<PassportElementHash>
|
||||
}
|
||||
|
||||
@Serializable
|
||||
@ -91,8 +91,8 @@ data class PassportElementErrorDataField(
|
||||
@SerialName(fieldNameField)
|
||||
val fieldName: String,
|
||||
@SerialName(dataHashField)
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
override val elementHash: String,
|
||||
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||
override val elementHash: PassportElementHash,
|
||||
@SerialName(messageField)
|
||||
override val message: String
|
||||
) : PassportSingleElementError() {
|
||||
@ -112,8 +112,8 @@ data class PassportElementErrorFrontSide(
|
||||
@SerialName(typeField)
|
||||
override val type: String,
|
||||
@SerialName(fileHashField)
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
override val elementHash: String,
|
||||
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||
override val elementHash: PassportElementHash,
|
||||
@SerialName(messageField)
|
||||
override val message: String
|
||||
) : PassportElementFileError() {
|
||||
@ -121,7 +121,7 @@ data class PassportElementErrorFrontSide(
|
||||
@Required
|
||||
override val source: String = frontSideField
|
||||
}
|
||||
fun WithFrontSide.createFrontSideError(message: String, unencryptedFileHash: String) = PassportElementErrorFrontSide(
|
||||
fun WithFrontSide.createFrontSideError(message: String, unencryptedFileHash: PassportElementHash) = PassportElementErrorFrontSide(
|
||||
type,
|
||||
unencryptedFileHash,
|
||||
message
|
||||
@ -132,8 +132,8 @@ data class PassportElementErrorReverseSide(
|
||||
@SerialName(typeField)
|
||||
override val type: String,
|
||||
@SerialName(fileHashField)
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
override val elementHash: String,
|
||||
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||
override val elementHash: PassportElementHash,
|
||||
@SerialName(messageField)
|
||||
override val message: String
|
||||
) : PassportElementFileError() {
|
||||
@ -141,7 +141,7 @@ data class PassportElementErrorReverseSide(
|
||||
@Required
|
||||
override val source: String = reverseSideField
|
||||
}
|
||||
fun WithReverseSide.createReverseSideError(message: String, unencryptedFileHash: String) = PassportElementErrorReverseSide(
|
||||
fun WithReverseSide.createReverseSideError(message: String, unencryptedFileHash: PassportElementHash) = PassportElementErrorReverseSide(
|
||||
type,
|
||||
unencryptedFileHash,
|
||||
message
|
||||
@ -151,8 +151,8 @@ data class PassportElementErrorSelfie(
|
||||
@SerialName(typeField)
|
||||
override val type: String,
|
||||
@SerialName(fileHashField)
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
override val elementHash: String,
|
||||
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||
override val elementHash: PassportElementHash,
|
||||
@SerialName(messageField)
|
||||
override val message: String
|
||||
) : PassportElementFileError() {
|
||||
@ -160,7 +160,7 @@ data class PassportElementErrorSelfie(
|
||||
@Required
|
||||
override val source: String = selfieField
|
||||
}
|
||||
fun WithSelfie.createSelfieError(message: String, unencryptedFileHash: String) = PassportElementErrorSelfie(
|
||||
fun WithSelfie.createSelfieError(message: String, unencryptedFileHash: PassportElementHash) = PassportElementErrorSelfie(
|
||||
type,
|
||||
unencryptedFileHash,
|
||||
message
|
||||
@ -172,8 +172,8 @@ data class PassportElementErrorFile(
|
||||
@SerialName(typeField)
|
||||
override val type: String,
|
||||
@SerialName(fileHashField)
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
override val elementHash: String,
|
||||
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||
override val elementHash: PassportElementHash,
|
||||
@SerialName(messageField)
|
||||
override val message: String
|
||||
) : PassportElementFileError() {
|
||||
@ -181,7 +181,7 @@ data class PassportElementErrorFile(
|
||||
@Required
|
||||
override val source: String = fileField
|
||||
}
|
||||
fun FilesCollection.createFileError(message: String, unencryptedFileHash: String) = PassportElementErrorFile(
|
||||
fun FilesCollection.createFileError(message: String, unencryptedFileHash: PassportElementHash) = PassportElementErrorFile(
|
||||
type,
|
||||
unencryptedFileHash,
|
||||
message
|
||||
@ -192,7 +192,7 @@ data class PassportElementErrorFiles(
|
||||
@SerialName(typeField)
|
||||
override val type: String,
|
||||
@SerialName(fileHashesField)
|
||||
override val elementsHashes: List<@Serializable(Base64StringSerializer::class) String>,
|
||||
override val elementsHashes: List<@Serializable(Base64BytesToFromStringSerializer::class) PassportElementHash>,
|
||||
@SerialName(messageField)
|
||||
override val message: String
|
||||
) : PassportElementFilesError() {
|
||||
@ -200,7 +200,7 @@ data class PassportElementErrorFiles(
|
||||
@Required
|
||||
override val source: String = filesField
|
||||
}
|
||||
fun FilesCollection.createFilesError(message: String, unencryptedFileHashes: List<String>) = PassportElementErrorFiles(
|
||||
fun FilesCollection.createFilesError(message: String, unencryptedFileHashes: List<PassportElementHash>) = PassportElementErrorFiles(
|
||||
type,
|
||||
unencryptedFileHashes,
|
||||
message
|
||||
@ -212,8 +212,8 @@ data class PassportElementErrorTranslationFile(
|
||||
@SerialName(typeField)
|
||||
override val type: String,
|
||||
@SerialName(fileHashField)
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
override val elementHash: String,
|
||||
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||
override val elementHash: PassportElementHash,
|
||||
@SerialName(messageField)
|
||||
override val message: String
|
||||
) : PassportElementFileError() {
|
||||
@ -221,7 +221,7 @@ data class PassportElementErrorTranslationFile(
|
||||
@Required
|
||||
override val source: String = translationFileField
|
||||
}
|
||||
fun Translatable.createFileError(message: String, unencryptedFileHash: String) = PassportElementErrorTranslationFile(
|
||||
fun Translatable.createFileError(message: String, unencryptedFileHash: PassportElementHash) = PassportElementErrorTranslationFile(
|
||||
type,
|
||||
unencryptedFileHash,
|
||||
message
|
||||
@ -231,7 +231,7 @@ data class PassportElementErrorTranslationFiles(
|
||||
@SerialName(typeField)
|
||||
override val type: String,
|
||||
@SerialName(fileHashesField)
|
||||
override val elementsHashes: List<@Serializable(Base64StringSerializer::class) String>,
|
||||
override val elementsHashes: List<@Serializable(Base64BytesToFromStringSerializer::class) PassportElementHash>,
|
||||
@SerialName(messageField)
|
||||
override val message: String
|
||||
) : PassportElementFilesError() {
|
||||
@ -239,7 +239,7 @@ data class PassportElementErrorTranslationFiles(
|
||||
@Required
|
||||
override val source: String = translationFilesField
|
||||
}
|
||||
fun Translatable.createFilesError(message: String, unencryptedFileHashes: List<String>) = PassportElementErrorTranslationFiles(
|
||||
fun Translatable.createFilesError(message: String, unencryptedFileHashes: List<PassportElementHash>) = PassportElementErrorTranslationFiles(
|
||||
type,
|
||||
unencryptedFileHashes,
|
||||
message
|
||||
@ -250,8 +250,8 @@ data class PassportElementErrorUnspecified(
|
||||
@SerialName(typeField)
|
||||
override val type: String,
|
||||
@SerialName(fileHashField)
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
override val elementHash: String,
|
||||
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||
override val elementHash: PassportElementHash,
|
||||
@SerialName(messageField)
|
||||
override val message: String
|
||||
) : PassportElementFileError() {
|
||||
@ -259,7 +259,7 @@ data class PassportElementErrorUnspecified(
|
||||
@Required
|
||||
override val source: String = unspecifiedField
|
||||
}
|
||||
fun EncryptedPassportElement.createUnspecifiedError(message: String, elementHash: String) = PassportElementErrorUnspecified(
|
||||
fun EncryptedPassportElement.createUnspecifiedError(message: String, elementHash: PassportElementHash) = PassportElementErrorUnspecified(
|
||||
type,
|
||||
elementHash,
|
||||
message
|
||||
|
@ -1,8 +1,9 @@
|
||||
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.hashField
|
||||
import dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts.PassportElementHash
|
||||
import dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts.WithEmail
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
@ -12,7 +13,7 @@ data class Email(
|
||||
@SerialName(emailField)
|
||||
override val email: String,
|
||||
@SerialName(hashField)
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
override val hash: String
|
||||
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||
override val hash: PassportElementHash
|
||||
) : WithEmail {
|
||||
}
|
@ -1,8 +1,9 @@
|
||||
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.passport.EncryptedData
|
||||
import dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts.PassportElementHash
|
||||
import dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts.WithData
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
@ -10,8 +11,8 @@ import kotlinx.serialization.Serializable
|
||||
@Serializable
|
||||
data class EncryptedAddress(
|
||||
@SerialName(dataField)
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||
override val data: EncryptedData,
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
override val hash: String
|
||||
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||
override val hash: PassportElementHash
|
||||
) : WithData
|
||||
|
@ -1,5 +1,6 @@
|
||||
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.tgbotapi.types.hashField
|
||||
import dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts.EncryptedPassportElement
|
||||
@ -45,7 +46,7 @@ object EncryptedElementSerializer : KSerializer<EncryptedPassportElement> {
|
||||
encryptedElementsClassesByTypes[type] ?.serializer ?.let { deserializer ->
|
||||
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) {
|
||||
|
@ -1,8 +1,9 @@
|
||||
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.passport.EncryptedData
|
||||
import dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts.PassportElementHash
|
||||
import dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts.WithData
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
@ -10,8 +11,8 @@ import kotlinx.serialization.Serializable
|
||||
@Serializable
|
||||
data class EncryptedPersonalDetails(
|
||||
@SerialName(dataField)
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||
override val data: EncryptedData,
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
override val hash: String
|
||||
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||
override val hash: PassportElementHash
|
||||
) : WithData
|
||||
|
@ -1,6 +1,6 @@
|
||||
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.passport.EncryptedData
|
||||
import dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts.*
|
||||
@ -13,7 +13,7 @@ sealed class Passport : WithData, WithFrontSide, WithSelfie, Translatable
|
||||
@Serializable
|
||||
data class CommonPassport(
|
||||
@SerialName(dataField)
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||
override val data: EncryptedData,
|
||||
@SerialName(frontSideField)
|
||||
override val frontSide: PassportFile? = null,
|
||||
@ -22,13 +22,13 @@ data class CommonPassport(
|
||||
@SerialName(translationField)
|
||||
override val translations: List<PassportFile> = emptyList(),
|
||||
@SerialName(hashField)
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
override val hash: String
|
||||
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||
override val hash: PassportElementHash
|
||||
) : Passport()
|
||||
@Serializable
|
||||
data class InternalPassport(
|
||||
@SerialName(dataField)
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||
override val data: EncryptedData,
|
||||
@SerialName(frontSideField)
|
||||
override val frontSide: PassportFile? = null,
|
||||
@ -37,6 +37,6 @@ data class InternalPassport(
|
||||
@SerialName(translationField)
|
||||
override val translations: List<PassportFile> = emptyList(),
|
||||
@SerialName(hashField)
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
override val hash: String
|
||||
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||
override val hash: PassportElementHash
|
||||
) : Passport()
|
||||
|
@ -1,7 +1,8 @@
|
||||
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.passport.encrypted_data.abstracts.PassportElementHash
|
||||
import dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts.WithPhoneNumber
|
||||
import dev.inmo.tgbotapi.types.phoneNumberField
|
||||
import kotlinx.serialization.SerialName
|
||||
@ -12,7 +13,7 @@ data class PhoneNumber(
|
||||
@SerialName(phoneNumberField)
|
||||
override val phoneNumber: String,
|
||||
@SerialName(hashField)
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
override val hash: String
|
||||
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||
override val hash: PassportElementHash
|
||||
) : WithPhoneNumber {
|
||||
}
|
@ -1,9 +1,8 @@
|
||||
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.passport.encrypted_data.abstracts.FilesCollection
|
||||
import dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts.Translatable
|
||||
import dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts.*
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@ -17,8 +16,8 @@ data class UtilityBill(
|
||||
@SerialName(translationField)
|
||||
override val translations: List<PassportFile> = emptyList(),
|
||||
@SerialName(hashField)
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
override val hash: String
|
||||
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||
override val hash: PassportElementHash
|
||||
) : TranslatableFilesCollection()
|
||||
@Serializable
|
||||
data class BankStatement(
|
||||
@ -27,8 +26,8 @@ data class BankStatement(
|
||||
@SerialName(translationField)
|
||||
override val translations: List<PassportFile> = emptyList(),
|
||||
@SerialName(hashField)
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
override val hash: String
|
||||
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||
override val hash: PassportElementHash
|
||||
) : TranslatableFilesCollection()
|
||||
@Serializable
|
||||
data class RentalAgreement(
|
||||
@ -37,8 +36,8 @@ data class RentalAgreement(
|
||||
@SerialName(translationField)
|
||||
override val translations: List<PassportFile> = emptyList(),
|
||||
@SerialName(hashField)
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
override val hash: String
|
||||
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||
override val hash: PassportElementHash
|
||||
) : TranslatableFilesCollection()
|
||||
@Serializable
|
||||
data class PassportRegistration(
|
||||
@ -47,8 +46,8 @@ data class PassportRegistration(
|
||||
@SerialName(translationField)
|
||||
override val translations: List<PassportFile> = emptyList(),
|
||||
@SerialName(hashField)
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
override val hash: String
|
||||
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||
override val hash: PassportElementHash
|
||||
) : TranslatableFilesCollection()
|
||||
@Serializable
|
||||
data class TemporaryRegistration(
|
||||
@ -57,7 +56,7 @@ data class TemporaryRegistration(
|
||||
@SerialName(translationField)
|
||||
override val translations: List<PassportFile> = emptyList(),
|
||||
@SerialName(hashField)
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
override val hash: String
|
||||
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||
override val hash: PassportElementHash
|
||||
) : TranslatableFilesCollection()
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
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.passport.EncryptedData
|
||||
import dev.inmo.tgbotapi.types.passport.encrypted_data.abstracts.*
|
||||
@ -13,7 +13,7 @@ sealed class TranslatableIDDocument : WithData, WithFrontSide, WithReverseSide,
|
||||
@Serializable
|
||||
data class DriverLicense(
|
||||
@SerialName(dataField)
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||
override val data: EncryptedData,
|
||||
@SerialName(frontSideField)
|
||||
override val frontSide: PassportFile? = null,
|
||||
@ -24,14 +24,14 @@ data class DriverLicense(
|
||||
@SerialName(translationField)
|
||||
override val translations: List<PassportFile> = emptyList(),
|
||||
@SerialName(hashField)
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
override val hash: String
|
||||
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||
override val hash: PassportElementHash
|
||||
) : TranslatableIDDocument()
|
||||
|
||||
@Serializable
|
||||
data class IdentityCard(
|
||||
@SerialName(dataField)
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||
override val data: EncryptedData,
|
||||
@SerialName(frontSideField)
|
||||
override val frontSide: PassportFile? = null,
|
||||
@ -42,6 +42,6 @@ data class IdentityCard(
|
||||
@SerialName(translationField)
|
||||
override val translations: List<PassportFile> = emptyList(),
|
||||
@SerialName(hashField)
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
override val hash: String
|
||||
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||
override val hash: PassportElementHash
|
||||
) : TranslatableIDDocument()
|
||||
|
@ -1,18 +1,21 @@
|
||||
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 kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
|
||||
typealias PassportElementHash = SourceBytes
|
||||
|
||||
@Serializable(EncryptedElementSerializer::class)
|
||||
interface EncryptedPassportElement {
|
||||
val hash: String
|
||||
val hash: PassportElementHash
|
||||
}
|
||||
|
||||
@Serializable(EncryptedElementSerializer::class)
|
||||
data class UnknownEncryptedPassportElement(
|
||||
val rawJson: JsonObject,
|
||||
@Serializable(Base64StringSerializer::class)
|
||||
override val hash: String
|
||||
@Serializable(Base64BytesToFromStringSerializer::class)
|
||||
override val hash: PassportElementHash
|
||||
) : EncryptedPassportElement
|
||||
|
@ -29,5 +29,5 @@ fun Decryptor.decryptData(
|
||||
data: EncryptedCredentials
|
||||
) = nonstrictJsonFormat.decodeFromString(
|
||||
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
|
||||
|
||||
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)
|
||||
(0 until size step chunkSize).flatMap {
|
||||
val firstIndex = it
|
||||
|
@ -36,7 +36,7 @@ OEg9BHa+Du8jSv0vL/fCN2s/2TcvSa9uEnv8KHz59JHevvxoDNbQYlN8Ge8adFv4
|
||||
xZYQ3h/qh2ohnTUfrG4hcFUVBuv5HBdwgWhVFm5v98KQsqVzGfKorN2DemEv3/au
|
||||
PFGkuu4lCPeDqu5u0dBojoA=
|
||||
-----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 {
|
||||
|
Loading…
Reference in New Issue
Block a user