-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Detailed encoder errors (#4705)
* Update @entur-private+abt-token-state-react-native-lib+2.1.6.patch * Update @entur-private+abt-token-state-react-native-lib+2.1.6.patch
- Loading branch information
1 parent
9fee0ee
commit 4fcb47d
Showing
1 changed file
with
57 additions
and
4 deletions.
There are no files selected for viewing
61 changes: 57 additions & 4 deletions
61
patches/@entur-private+abt-token-state-react-native-lib+2.1.6.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,66 @@ | ||
diff --git a/node_modules/@entur-private/abt-token-state-react-native-lib/ios/TokenCoreModule.swift b/node_modules/@entur-private/abt-token-state-react-native-lib/ios/TokenCoreModule.swift | ||
index a41752b..03e7b5d 100644 | ||
index a41752b..b558fda 100644 | ||
--- a/node_modules/@entur-private/abt-token-state-react-native-lib/ios/TokenCoreModule.swift | ||
+++ b/node_modules/@entur-private/abt-token-state-react-native-lib/ios/TokenCoreModule.swift | ||
@@ -443,7 +443,7 @@ public class TokenCoreModule: NSObject { | ||
@@ -131,6 +131,39 @@ extension TokenCoreModuleError: IdentifiableError { | ||
} | ||
} | ||
|
||
+extension TokenEncoderError: LocalizedError { | ||
+ public var errorDescription: String? { | ||
+ switch self { | ||
+ case .errorUnableToGetClockTime: | ||
+ return NSLocalizedString( | ||
+ "Unable to get the current time", | ||
+ comment: "" | ||
+ ) | ||
+ case .errorSigning: | ||
+ return NSLocalizedString( | ||
+ "There was an error signing the token", | ||
+ comment: "" | ||
+ ) | ||
+ case .errorCreatingSecureContainer(let message): | ||
+ let format = NSLocalizedString( | ||
+ "There was an error creating the secure container: '%@'", | ||
+ comment: "" | ||
+ ) | ||
+ | ||
+ if let message = message { | ||
+ return String(format: format, message) | ||
+ } | ||
+ | ||
+ return String(format: format, "unknown error") | ||
+ case .errorInvalidSignaturePrivateKey: | ||
+ return NSLocalizedString( | ||
+ "Invalid signature private key", | ||
+ comment: "" | ||
+ ) | ||
+ } | ||
+ } | ||
+} | ||
+ | ||
|
||
@objc(TokenCoreModule) | ||
public class TokenCoreModule: NSObject { | ||
@@ -442,8 +475,8 @@ public class TokenCoreModule: NSObject { | ||
let tokenEncodingRequest = TokenEncodingRequest(deviceDetails: deviceDetailsProvider.deviceDetails, challenges: decodedChallenges, tokenActions: tokenPayloadActions, includeCertificate: includeCertificate) | ||
|
||
token.encodeAsSecureContainer(tokenEncodingRequest: tokenEncodingRequest) { secureContainerWrapper, error in | ||
if let error = error { | ||
- if let error = error { | ||
- return reject(self.mapErrorCode(error).code, "Error while generating the secure container", error) | ||
+ return reject(self.mapErrorCode(error).code, "Error while generating the secure container: \(error.localizedDescription)", error) | ||
+ if let error = error, let errorDescription = error.errorDescription { | ||
+ return reject(self.mapErrorCode(error).code, errorDescription, error) | ||
} | ||
|
||
guard let base64EncodedSecureContainer = secureContainerWrapper?.base64EncodedString else { | ||
@@ -597,8 +630,8 @@ public class TokenCoreModule: NSObject { | ||
includeCertificate: includeCertificate | ||
) | ||
token.encodeAsSecureContainer(tokenEncodingRequest: tokenEncodingRequest) { [self] secureContainerWrapper, error in | ||
- if let error = error { | ||
- reject(self.mapErrorCode(error).code, "Error while generating the secure container", error) | ||
+ if let error = error, let errorDescription = error.errorDescription { | ||
+ reject(self.mapErrorCode(error).code, errorDescription, error) | ||
} | ||
|
||
if base64EncodedBarcode { |