Skip to content

Commit

Permalink
fix: Fixing compilation issues with new Amplify version.
Browse files Browse the repository at this point in the history
  • Loading branch information
ruisebas committed Sep 18, 2024
1 parent 7274230 commit e35a171
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 15 deletions.
16 changes: 8 additions & 8 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"repositoryURL": "https://github.com/aws-amplify/amplify-swift.git",
"state": {
"branch": null,
"revision": "99c72db23217c8944dda92a9be26f7c0d0d5de3f",
"version": "2.37.0"
"revision": "9a4ce09141d5045b8dfe55cb301b0691e3341a00",
"version": "2.41.0"
}
},
{
Expand All @@ -24,17 +24,17 @@
"repositoryURL": "https://github.com/awslabs/aws-crt-swift",
"state": {
"branch": null,
"revision": "0d0a0cf2e2cb780ceeceac190b4ede94f4f96902",
"version": "0.26.0"
"revision": "7b42e0343f28b3451aab20840dc670abd12790bd",
"version": "0.36.0"
}
},
{
"package": "aws-sdk-swift",
"repositoryURL": "https://github.com/awslabs/aws-sdk-swift.git",
"state": {
"branch": null,
"revision": "47922c05dd66be717c7bce424651a534456717b7",
"version": "0.36.2"
"revision": "828358a2c39d138325b0f87a2d813f4b972e5f4f",
"version": "1.0.0"
}
},
{
Expand All @@ -51,8 +51,8 @@
"repositoryURL": "https://github.com/smithy-lang/smithy-swift",
"state": {
"branch": null,
"revision": "8a5b0105c1b8a1d26a9435fb0af3959a7f5de578",
"version": "0.41.1"
"revision": "0ed3440f8c41e27a0937364d5035d2d4fefb8aa3",
"version": "0.71.0"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ let package = Package(
.package(
name: "Amplify",
url: "https://github.com/aws-amplify/amplify-swift.git",
.upToNextMajor(from: "2.2.0")
.upToNextMajor(from: "2.41.0")
),

// MapLibre
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
import Foundation
import Amplify
import AWSLocationGeoPlugin
import AWSClientRuntime
import InternalAmplifyCredentials
import SmithyIdentity

extension AWSMapURLProtocol {
struct GeoConfig {
let regionName: String
let credentialsProvider: CredentialsProviding
let identityResolver: any AWSCredentialIdentityResolver
let hostName: String

init?() {
Expand All @@ -25,7 +25,7 @@ extension AWSMapURLProtocol {
guard let credentiaslProvider = plugin.authService as? AWSAuthCredentialsProviderBehavior else {
return nil
}
self.credentialsProvider = credentiaslProvider.getCredentialsProvider()
self.identityResolver = credentiaslProvider.getCredentialIdentityResolver()
self.regionName = plugin.pluginConfig.regionName
self.hostName = "maps.geo.\(regionName).amazonaws.com"
}
Expand Down
9 changes: 6 additions & 3 deletions Sources/AmplifyMapLibreAdapter/AWSMapURLProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ import Foundation
import ClientRuntime
import AWSClientRuntime
import AwsCommonRuntimeKit
import AWSSDKHTTPAuth
import SmithyHTTPAPI

class AWSMapURLProtocol: URLProtocol {
private var urlSession = URLSession(configuration: .default)
private var dataTask: URLSessionDataTask?
private static var globallyRegistered = false
private static var geoConfig = GeoConfig()
private static let signer = AWSSigV4Signer()

/// Register the custom URL Protocol.
/// - Parameter sessionConfig: Optional URLSessionConfiguration for URLSession you want to proxy.
Expand Down Expand Up @@ -86,7 +89,7 @@ class AWSMapURLProtocol: URLProtocol {
return
}

let requestBuilder = SdkHttpRequestBuilder()
let requestBuilder = HTTPRequestBuilder()
.withHost(host)
.withPath(originalURLComponents.path.urlPercentEncoding(encodeForwardSlash: false))
.withMethod(.get)
Expand All @@ -98,9 +101,9 @@ class AWSMapURLProtocol: URLProtocol {
var signedRequest = request
signedRequest.url = originalURLComponents.url
signedRequest.addValue(host, forHTTPHeaderField: "host")
guard let url = await AWSSigV4Signer.sigV4SignedURL(
guard let url = await Self.signer.sigV4SignedURL(
requestBuilder: requestBuilder,
credentialsProvider: geoConfig.credentialsProvider,
awsCredentialIdentityResolver: geoConfig.identityResolver,
signingName: "geo",
signingRegion: geoConfig.regionName,
date: Date(),
Expand Down

0 comments on commit e35a171

Please sign in to comment.