Skip to content

Commit

Permalink
Handle new otp exceeded attempts error code.
Browse files Browse the repository at this point in the history
  • Loading branch information
rickycpadilla committed Nov 29, 2023
1 parent 0052e81 commit 4d5f22c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import id.passage.android.Passage
import id.passage.android.PassageToken
import id.passage.android.exceptions.AddDevicePasskeyCancellationException
import id.passage.android.exceptions.LoginWithPasskeyCancellationException
import id.passage.android.exceptions.OneTimePasscodeActivateExceededAttemptsException
import id.passage.android.exceptions.PassageUserUnauthorizedException
import id.passage.android.exceptions.RegisterWithPasskeyCancellationException

Expand Down Expand Up @@ -121,6 +122,8 @@ class PassageReactNativeModule(reactContext: ReactApplicationContext) :
val authResult = passage.oneTimePasscodeActivate(otp, otpId)
val jsonString = Gson().toJson(authResult)
promise.resolve(jsonString)
} catch (e: OneTimePasscodeActivateExceededAttemptsException) {
promise.reject("OTP_ACTIVATION_EXCEEDED_ATTEMPTS", e.message, e)
} catch (e: Exception) {
promise.reject("OTP_ERROR", e.message, e)
}
Expand Down
10 changes: 5 additions & 5 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ PODS:
- hermes-engine/Pre-built (0.71.10)
- libevent (2.1.12)
- OpenSSL-Universal (1.1.1100)
- Passage (1.2.0):
- Passage (1.4.0):
- SwiftKeychainWrapper
- passage-react-native (0.1.4):
- Passage (= 1.2.0)
- passage-react-native (0.4.0):
- Passage (= 1.4.0)
- React-Core
- RCT-Folly (2021.07.22.00):
- boost
Expand Down Expand Up @@ -598,8 +598,8 @@ SPEC CHECKSUMS:
hermes-engine: d27603b55a48402501ad1928c05411dae9cd6b85
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c
Passage: 623d579acf6cf9949f6c16c777b7efe6f6902d93
passage-react-native: 96089329c8205f9c49013af37f592506ccd74fe6
Passage: 4b543698ee5cfac577d9fce473f75587315269e5
passage-react-native: 035fe2564bf099c3aed0543f5c1158dfc4c6b0ea
RCT-Folly: 424b8c9a7a0b9ab2886ffe9c3b041ef628fd4fb1
RCTRequired: 8ef706f91e2b643cd32c26a57700b5f24fab0585
RCTTypeSafety: 5fbddd8eb9242b91ac0d901c01da3673f358b1b7
Expand Down
6 changes: 5 additions & 1 deletion ios/PassageReactNative.swift
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,11 @@ class PassageReactNative: NSObject {
let authResult = try await passage.oneTimePasscodeActivate(otp: otp, otpId: otpId)
resolve(authResult.toJsonString())
} catch {
reject("OTP_ERROR", "\(error)", nil)
var errorCode = "OTP_ERROR"
if case PassageOTPError.exceededAttempts = error {
errorCode = "OTP_ACTIVATION_EXCEEDED_ATTEMPTS"
}
reject(errorCode, "\(error)", nil)
}
}
}
Expand Down

0 comments on commit 4d5f22c

Please sign in to comment.