mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-05 14:02:48 +00:00
no message
This commit is contained in:
parent
95c47f013c
commit
844392f644
@ -160,15 +160,15 @@ public enum SecureIdAccessError {
|
||||
case secretPasswordMismatch
|
||||
}
|
||||
|
||||
public func accessSecureId(network: Network, password: String) -> Signal<SecureIdAccessContext, SecureIdAccessError> {
|
||||
public func accessSecureId(network: Network, password: String) -> Signal<(context: SecureIdAccessContext, settings: TwoStepVerificationSettings), SecureIdAccessError> {
|
||||
return requestTwoStepVerifiationSettings(network: network, password: password)
|
||||
|> mapError { error -> SecureIdAccessError in
|
||||
return .passwordError(error)
|
||||
}
|
||||
|> mapToSignal { settings -> Signal<SecureIdAccessContext, SecureIdAccessError> in
|
||||
|> mapToSignal { settings -> Signal<(context: SecureIdAccessContext, settings: TwoStepVerificationSettings), SecureIdAccessError> in
|
||||
if let secureSecret = settings.secureSecret {
|
||||
if let decryptedSecret = decryptedSecureSecret(encryptedSecretData: secureSecret.data, password: password, derivation: secureSecret.derivation, id: secureSecret.id) {
|
||||
return .single(SecureIdAccessContext(secret: decryptedSecret, id: secureSecret.id))
|
||||
return .single((SecureIdAccessContext(secret: decryptedSecret, id: secureSecret.id), settings))
|
||||
} else {
|
||||
return .fail(.secretPasswordMismatch)
|
||||
}
|
||||
@ -183,7 +183,7 @@ public func accessSecureId(network: Network, password: String) -> Signal<SecureI
|
||||
secretHashData.withUnsafeBytes { (bytes: UnsafePointer<Int8>) -> Void in
|
||||
memcpy(&secretId, bytes, 8)
|
||||
}
|
||||
return SecureIdAccessContext(secret: decryptedSecret, id: secretId)
|
||||
return (SecureIdAccessContext(secret: decryptedSecret, id: secretId), settings)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -61,9 +61,15 @@ public func requestTwoStepVerifiationSettings(network: Network, password: String
|
||||
}
|
||||
|
||||
return network.request(Api.functions.account.getPasswordSettings(password: .inputCheckPasswordSRP(srpId: kdfResult.id, A: Buffer(data: kdfResult.A), M1: Buffer(data: kdfResult.M1))), automaticFloodWait: false)
|
||||
|> mapError { _ -> AuthorizationPasswordVerificationError in
|
||||
|> mapError { error -> AuthorizationPasswordVerificationError in
|
||||
if error.errorDescription.hasPrefix("FLOOD_WAIT") {
|
||||
return .limitExceeded
|
||||
} else if error.errorDescription == "PASSWORD_HASH_INVALID" {
|
||||
return .invalidPassword
|
||||
} else {
|
||||
return .generic
|
||||
}
|
||||
}
|
||||
|> mapToSignal { result -> Signal<TwoStepVerificationSettings, AuthorizationPasswordVerificationError> in
|
||||
switch result {
|
||||
case let .passwordSettings(_, email, secureSettings):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user