From 02161b8f7fe5316f6d1b53fefcc79ce9668806eb Mon Sep 17 00:00:00 2001 From: Ed Paulosky Date: Wed, 21 Dec 2022 16:02:50 -0500 Subject: [PATCH] fix: Various fixes to help aws-swift-sdk update to 0.5.0+ (#130) * Removes `AnyObject` constraint from `CredentialsProviding` * Makes sha156 public and exposes encodeToHexString * Removes encodeToHexString function from ByteBuffer --- .../auth/credentials/CredentialsProvider.swift | 2 +- Source/AwsCommonRuntimeKit/crt/ByteBuffer.swift | 6 ------ Source/AwsCommonRuntimeKit/crt/Utilities.swift | 6 +++++- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Source/AwsCommonRuntimeKit/auth/credentials/CredentialsProvider.swift b/Source/AwsCommonRuntimeKit/auth/credentials/CredentialsProvider.swift index 0d85f371b..34cea7c65 100644 --- a/Source/AwsCommonRuntimeKit/auth/credentials/CredentialsProvider.swift +++ b/Source/AwsCommonRuntimeKit/auth/credentials/CredentialsProvider.swift @@ -6,7 +6,7 @@ import AwsCIo import AwsCHttp import Foundation -public protocol CredentialsProviding: AnyObject { +public protocol CredentialsProviding { func getCredentials() async throws -> Credentials } diff --git a/Source/AwsCommonRuntimeKit/crt/ByteBuffer.swift b/Source/AwsCommonRuntimeKit/crt/ByteBuffer.swift index fda12b827..3aee4f332 100644 --- a/Source/AwsCommonRuntimeKit/crt/ByteBuffer.swift +++ b/Source/AwsCommonRuntimeKit/crt/ByteBuffer.swift @@ -70,9 +70,3 @@ extension ByteBuffer: IStreamable { return dataSlice.count } } - -extension ByteBuffer { - func encodeToHexString() -> String { - data.map { String(format: "%02x", $0) }.joined() - } -} diff --git a/Source/AwsCommonRuntimeKit/crt/Utilities.swift b/Source/AwsCommonRuntimeKit/crt/Utilities.swift index 7ca980162..22a4ed110 100644 --- a/Source/AwsCommonRuntimeKit/crt/Utilities.swift +++ b/Source/AwsCommonRuntimeKit/crt/Utilities.swift @@ -41,7 +41,7 @@ extension String { extension Data { /// Computes the sha256 hash over data. - func sha256(truncate: Int = 0, allocator: Allocator = defaultAllocator) throws -> Data { + public func sha256(truncate: Int = 0, allocator: Allocator = defaultAllocator) throws -> Data { try self.withUnsafeBytes { bufferPointer in var byteCursor = aws_byte_cursor_from_array(bufferPointer.baseAddress, count) let bufferSize = Int(AWS_SHA256_LEN) @@ -55,6 +55,10 @@ extension Data { return bufferData } } + + public func encodeToHexString() -> String { + map { String(format: "%02x", $0) }.joined() + } } extension aws_date_time {