Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IOS-8509 Update auth flow #4283

Merged
merged 10 commits into from
Dec 9, 2024
Merged

Conversation

Andoran90
Copy link
Contributor

Изменился порядок запроса токенов доступа, теперь они запрашиваются перед стартом сессии в онбординге, подписываются и отправляются.
Сделал почти все на протоколах, чтобы потом можно было покрыть по максимуму юнитами, думаю тут это очень понадобится. Пока что добавляю логи везде где тестирую, думаю ближе к финалу подчищу и наведу марафет, но сейчас надо по максимуму чтобы все было покрыто логами

if accessCode.count < 4 {
throw ValidationError.accessCodeTooShort
}
try accessCodeValidator.validateAccessCode(accessCode: accessCode)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

лучше валидировать ошибки в одном месте, поэтому перенес в TangemVisa

viewModel.log("Failed to use selected access code. Reason: \(error)")
/// We need to show alert in parent view, otherwise it won't be shown
await viewModel.delegate?.showAlert(error.alertBinder)
if !error.isCancellationError {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

если была отмена - можно ничего не показывать

@@ -250,10 +228,18 @@ extension VisaOnboardingViewModel {
onboardingStepsBuilderFactory: cardMockConfig,
pushNotificationsInteractor: PushNotificationsInteractorMock()
)
guard let cardInput = inputFactory.makeOnboardingInput() else {
fatalError("Failed to generate card input for visa onboarding")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

моки, ничего страшного что тут будет фалаточка

@@ -16,6 +17,16 @@ public struct VisaUtilities {
self.isTestnet = isTestnet
}

public var batchId: [String] {
[
"AF05",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

мой бы батч сразу добавить

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ошибся, изменил на правильный


enum DefaultWalletData: Codable {
case file(WalletData)
case legacy(WalletData)
case twin(WalletData, TwinData)
case visa(accessToken: String, refreshToken: String)
case visa(activationInput: VisaCardActivationInput, tokens: VisaAuthorizationTokens?)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

это все с карты считывается?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

это все результат сканирования карточки, токены конечно не с карты читаются. Но не знаю куда приложить это. Складывать в AppScanTaskResponse - странно что у всех будет это поле, оно супер-специфично. Создавать и где-то хранить какую-то сущность по активации - тоже не канает, т.к. это не обязательно ведет на активацию, при сканировании виза карты можно получить сразу боевые токены авторизации, когда карта активирована полностью.

)
return CommonVisaActivationManager(authorizationTokenHandler: tokenHandler)
do {
cardSession = try await startCardSession()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

жестко конфузит, cardSession у нас в сдк, а тут еще и TangemSdkError внизу, может visaactivationsession или что-то типа того?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

обновил

let challenge = try await getAuthorizationChallenge(for: input)

log("Attempting to start NFC session")
let cardSession: CardSession = try await withCheckedThrowingContinuation { continuation in
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

я не знаю, чет с асинками прям сильно хуже все выглядит

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

обновил

@Andoran90 Andoran90 marked this pull request as draft November 27, 2024 09:31
@Andoran90 Andoran90 marked this pull request as ready for review December 6, 2024 09:22
Comment on lines +63 to +66
guard card.cardId.caseInsensitiveCompare(activationInput.cardId) == .orderedSame else {
completion(.failure(.underlying(error: VisaActivationError.wrongCard)))
return
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

думаю пока так ок, но в целом это можно будет вынести в кастомный префлайт фильтр

@Andoran90 Andoran90 merged commit b726bab into develop Dec 9, 2024
5 checks passed
@Andoran90 Andoran90 deleted the feature/visa/IOS-8509-update_auth_flow branch December 9, 2024 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants