Skip to content

Commit 367b864

Browse files
authored
chore: improve error messages (#132)
1 parent 690d7c2 commit 367b864

File tree

6 files changed

+20
-3
lines changed

6 files changed

+20
-3
lines changed

HostApp/HostApp/Views/ExampleLivenessView.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ struct ExampleLivenessView: View {
4343
viewModel.presentationState = .error(.socketClosed)
4444
case .failure(.countdownNoFace), .failure(.countdownFaceTooClose), .failure(.countdownMultipleFaces):
4545
viewModel.presentationState = .error(.countdownFaceTooClose)
46+
case .failure(.invalidSignature):
47+
viewModel.presentationState = .error(.invalidSignature)
4648
default:
4749
viewModel.presentationState = .liveness
4850
}
@@ -70,6 +72,8 @@ struct ExampleLivenessView: View {
7072
LivenessCheckErrorContentView.faceMatchTimeOut
7173
case .countdownNoFace, .countdownFaceTooClose, .countdownMultipleFaces:
7274
LivenessCheckErrorContentView.failedDuringCountdown
75+
case .invalidSignature:
76+
LivenessCheckErrorContentView.invalidSignature
7377
default:
7478
LivenessCheckErrorContentView.unexpected
7579
}

HostApp/HostApp/Views/LivenessCheckErrorContentView.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ extension LivenessCheckErrorContentView {
5050
name: "Check failed during countdown",
5151
description: "Avoid moving closer during countdown and ensure only one face is in front of camera."
5252
)
53+
54+
static let invalidSignature = LivenessCheckErrorContentView(
55+
name: "The signature on the request is invalid.",
56+
description: "Ensure the device time is correct and try again."
57+
)
5358
}
5459

5560
struct LivenessCheckErrorContentView_Previews: PreviewProvider {

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ let package = Package(
1313
targets: ["FaceLiveness"]),
1414
],
1515
dependencies: [
16-
.package(url: "https://github.com/aws-amplify/amplify-swift", exact: "2.29.1")
16+
.package(url: "https://github.com/aws-amplify/amplify-swift", exact: "2.29.3")
1717
],
1818
targets: [
1919
.target(

Sources/FaceLiveness/Views/Liveness/FaceLivenessDetectionError.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,12 @@ public struct FaceLivenessDetectionError: Error, Equatable {
120120
recoverySuggestion: ""
121121
)
122122

123+
public static let invalidSignature = FaceLivenessDetectionError(
124+
code: 17,
125+
message: "The signature on the request is invalid.",
126+
recoverySuggestion: "Ensure the device time is correct and try again."
127+
)
128+
123129
public static func == (lhs: FaceLivenessDetectionError, rhs: FaceLivenessDetectionError) -> Bool {
124130
lhs.code == rhs.code
125131
}

Sources/FaceLiveness/Views/Liveness/FaceLivenessDetectionView.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ public struct FaceLivenessDetectorView: View {
202202
case .userCancelled:
203203
return .userCancelled
204204
case .timedOut:
205-
return .sessionTimedOut
205+
return .faceInOvalMatchExceededTimeLimitError
206206
case .socketClosed:
207207
return .socketClosed
208208
default:
@@ -273,6 +273,8 @@ private func map(detectionCompletion: @escaping (Result<Void, FaceLivenessDetect
273273
detectionCompletion(.failure(.serviceUnavailable))
274274
case .failure(.sessionNotFound):
275275
detectionCompletion(.failure(.sessionNotFound))
276+
case .failure(.invalidSignature):
277+
detectionCompletion(.failure(.invalidSignature))
276278
default:
277279
detectionCompletion(.failure(.unknown))
278280
}

Tests/IntegrationTestApp/IntegrationTestApp/Extension/MockLivenessCaptureSession.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ final class MockLivenessCaptureSession: LivenessCaptureSession {
3030
displayLink?.invalidate()
3131
}
3232

33-
override func startSession(frame: CGRect) throws -> CALayer {
33+
override func configureCamera(frame: CGRect) throws -> CALayer {
3434
videoRenderView = VideoRenderView(frame: frame)
3535
let asset = AVAsset(url: inputFile)
3636
// Setup display link

0 commit comments

Comments
 (0)