diff --git a/CircleModularWalletsCore/Resources/Info.plist b/CircleModularWalletsCore/Resources/Info.plist index 9a9591a..4f49406 100644 --- a/CircleModularWalletsCore/Resources/Info.plist +++ b/CircleModularWalletsCore/Resources/Info.plist @@ -3,7 +3,7 @@ CFBundleShortVersionString - 1.0.5 + 1.0.6 CFBundleIdentifier $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleName diff --git a/CircleModularWalletsCore/Sources/Helpers/Extensions/Bundle+Extension.swift b/CircleModularWalletsCore/Sources/Helpers/Extensions/Bundle+Extension.swift index 3e04fa0..9522c00 100644 --- a/CircleModularWalletsCore/Sources/Helpers/Extensions/Bundle+Extension.swift +++ b/CircleModularWalletsCore/Sources/Helpers/Extensions/Bundle+Extension.swift @@ -21,7 +21,7 @@ import Foundation #if SWIFT_PACKAGE extension Bundle { public enum SDK { - public static let version = "1.0.5" + public static let version = "1.0.6" } } #else diff --git a/CircleModularWalletsCore/Sources/Helpers/WebAuthn/WebAuthnHandler.swift b/CircleModularWalletsCore/Sources/Helpers/WebAuthn/WebAuthnHandler.swift index 6d423a3..cf383ac 100644 --- a/CircleModularWalletsCore/Sources/Helpers/WebAuthn/WebAuthnHandler.swift +++ b/CircleModularWalletsCore/Sources/Helpers/WebAuthn/WebAuthnHandler.swift @@ -120,11 +120,22 @@ extension WebAuthnHandler: ASAuthorizationControllerDelegate { // The attestationObject contains the user's new public key to store and use for subsequent sign-ins. let attestationObjectData = asCredentialRegistration.rawAttestationObject let clientDataJSON = asCredentialRegistration.rawClientDataJSON + var attachment: AuthenticatorAttachment = .platform + if #available(iOS 16.6, *) { + switch asCredentialRegistration.attachment { + case .platform: + attachment = .platform + case .crossPlatform: + attachment = .crossPlatform + @unknown default: + attachment = .platform + } + } let credential = RegistrationCredential( id: asCredentialRegistration.credentialID.base64URLEncodedString().asString(), type: CredentialType.publicKey, - authenticatorAttachment: .platform, + authenticatorAttachment: attachment, rawID: asCredentialRegistration.credentialID.base64URLEncodedString(), response: AuthenticatorAttestationResponse( rawClientDataJSON: clientDataJSON.bytes, @@ -144,11 +155,22 @@ extension WebAuthnHandler: ASAuthorizationControllerDelegate { let signature = asCredentialAssertion.signature let clientDataJSON = asCredentialAssertion.rawClientDataJSON let authenticatorData = asCredentialAssertion.rawAuthenticatorData + var attachment: AuthenticatorAttachment = .platform + if #available(iOS 16.6, *) { + switch asCredentialAssertion.attachment { + case .platform: + attachment = .platform + case .crossPlatform: + attachment = .crossPlatform + @unknown default: + attachment = .platform + } + } let credential = AuthenticationCredential( id: asCredentialAssertion.credentialID.base64URLEncodedString().asString(), type: CredentialType.publicKey, - authenticatorAttachment: .platform, + authenticatorAttachment: attachment, rawID: asCredentialAssertion.credentialID.base64URLEncodedString(), response: AuthenticatorAssertionResponse( clientDataJSON: clientDataJSON.bytes.base64URLEncodedString(), diff --git a/CircleModularWalletsCore/Sources/Models/Token.swift b/CircleModularWalletsCore/Sources/Models/Token.swift index 3e28650..0791925 100644 --- a/CircleModularWalletsCore/Sources/Models/Token.swift +++ b/CircleModularWalletsCore/Sources/Models/Token.swift @@ -45,7 +45,7 @@ public enum MainnetToken: String { } public var name: String { - return "\(Mainnet.chainId)_\(self.rawValue)" + return "Mainnet_\(self.rawValue)" } } @@ -75,7 +75,7 @@ public enum PolygonToken: String { } public var name: String { - return "\(Polygon.chainId)_\(self.rawValue)" + return "Polygon_\(self.rawValue)" } } @@ -106,7 +106,7 @@ public enum ArbitrumToken: String { } public var name: String { - return "\(Arbitrum.chainId)_\(self.rawValue)" + return "Arbitrum_\(self.rawValue)" } } @@ -118,7 +118,7 @@ public enum SepoliaToken: String { } public var name: String { - return "\(Sepolia.chainId)_\(self.rawValue)" + return "Sepolia_\(self.rawValue)" } } @@ -130,7 +130,7 @@ public enum PolygonAmoyToken: String { } public var name: String { - return "\(PolygonAmoy.chainId)_\(self.rawValue)" + return "PolygonAmoy_\(self.rawValue)" } } @@ -142,6 +142,6 @@ public enum ArbitrumSepoliaToken: String { } public var name: String { - return "\(ArbitrumSepolia.chainId)_\(self.rawValue)" + return "ArbitrumSepolia_\(self.rawValue)" } } diff --git a/CircleModularWalletsCore/Sources/Transports/Http/HttpTransport.swift b/CircleModularWalletsCore/Sources/Transports/Http/HttpTransport.swift index 49cfaa2..f5bb677 100644 --- a/CircleModularWalletsCore/Sources/Transports/Http/HttpTransport.swift +++ b/CircleModularWalletsCore/Sources/Transports/Http/HttpTransport.swift @@ -58,8 +58,9 @@ public class HttpTransport: Transport { extension HttpTransport { func send(_ urlRequest: URLRequest) async throws -> T { + var data: Data = .init(), response: URLResponse? do { - let (data, response) = try await session.data(for: urlRequest) + (data, response) = try await session.data(for: urlRequest) try processResponse(data: data, response: response) if let errorResult = try? decodeData(data: data) as JsonRpcErrorResult { @@ -72,6 +73,8 @@ extension HttpTransport { return try decodeData(data: data) as T } + } catch let error as BaseError { + throw error } catch let error as HttpError { var _details: String? var _cause: Error? @@ -85,7 +88,12 @@ extension HttpTransport { _details = "Decoding Failed." _cause = error case .unknownError(let statusCode): - _details = "Request failed: \(statusCode)" + if let errorResult = try? decodeData(data: data) as JsonRpcErrorResult { + _details = errorResult.error.message + } else { + let message = String(data: data, encoding: .utf8) ?? "" + _details = "Request failed: \(message)" + } _statusCode = statusCode default: _details = String(describing: error)