Skip to content

Commit

Permalink
Changes for 2.6.20. Add UserPools Async Auth provider. Fix Travis Bui…
Browse files Browse the repository at this point in the history
…ld. (#63)
  • Loading branch information
rohandubal authored Sep 8, 2018
1 parent 1e245b9 commit bf057a3
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 17 deletions.
24 changes: 12 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ before_deploy:
- carthage archive $FRAMEWORK_NAME
script:
- xcodebuild -workspace AWSAppSyncClient.xcworkspace -scheme AWSAppSync build
- provider: releases
api_key:
secure: grQ0iwgJczU2OQuoXM4TkYrWtPBEwaG5WSPwtQ4OeNJT/S9u/NsB8UWlkqr7w0dzgJhZC0rYX8qDHT8UH8LoGUYPvtORBz+0ktoOFxGHR1Xf7diEKrsDFYJ0Tou7zrgLzzVEY3t+vlLZAmd8POavQsfNKWx5xeOvsmfJgHSuJic1eAaH6R9LsJgXnqhiUF6DT2nDdFEy2cDYL8fro98WXoek7Z+fG4nx5oJQSOmhiNmdSIcTcFMFWJ9TFMlsNJom6pMDJR6FL1AgCz3/zSvYW4ZNpkq1WIQjIJAidiKEPue0tmVPwXvP5fmOsGTneu72O/uSyIoTdkPnt0QZXFofA+g4ScwhI8GQNPjF4muUrJauOVzInExm/RS1gI4Z5AwLV/DDouNtyMRIuCjCr/cPUpzllUyWTguTl7YVyt0/rK7QjCVX4U46N1QSmXNpP6Qa8EWQam5MMi0bcTa0drjNMqPaRjRP+F0O/x9wnbSfJElRueSexw5Uvn/+nh0upxo6kbIttVHZRjJuw5mN0iiEUIdL08nem9BWRLjg/hA1t6Lo94QCHu6BGeHi5AyddTFmiM0vsMnnNNSKB+q1RSMCCqMMjGtcGZJw5YtZybcn5AvIrhPjGLcMOpSPQ2BTWToKMHKlkzefaF0e9gPbC4PDBGIAVEqx8qKkUqDsCuSZb60=
file: "$FRAMEWORK_NAME.framework.zip"
skip_cleanup: true
on:
repo: awslabs/aws-mobile-appsync-sdk-ios
tags: true
deploy:
- provider: script
script: "./cocoapods_release.sh"
on:
tags: true
- provider: releases
api_key:
secure: grQ0iwgJczU2OQuoXM4TkYrWtPBEwaG5WSPwtQ4OeNJT/S9u/NsB8UWlkqr7w0dzgJhZC0rYX8qDHT8UH8LoGUYPvtORBz+0ktoOFxGHR1Xf7diEKrsDFYJ0Tou7zrgLzzVEY3t+vlLZAmd8POavQsfNKWx5xeOvsmfJgHSuJic1eAaH6R9LsJgXnqhiUF6DT2nDdFEy2cDYL8fro98WXoek7Z+fG4nx5oJQSOmhiNmdSIcTcFMFWJ9TFMlsNJom6pMDJR6FL1AgCz3/zSvYW4ZNpkq1WIQjIJAidiKEPue0tmVPwXvP5fmOsGTneu72O/uSyIoTdkPnt0QZXFofA+g4ScwhI8GQNPjF4muUrJauOVzInExm/RS1gI4Z5AwLV/DDouNtyMRIuCjCr/cPUpzllUyWTguTl7YVyt0/rK7QjCVX4U46N1QSmXNpP6Qa8EWQam5MMi0bcTa0drjNMqPaRjRP+F0O/x9wnbSfJElRueSexw5Uvn/+nh0upxo6kbIttVHZRjJuw5mN0iiEUIdL08nem9BWRLjg/hA1t6Lo94QCHu6BGeHi5AyddTFmiM0vsMnnNNSKB+q1RSMCCqMMjGtcGZJw5YtZybcn5AvIrhPjGLcMOpSPQ2BTWToKMHKlkzefaF0e9gPbC4PDBGIAVEqx8qKkUqDsCuSZb60=
file: "$FRAMEWORK_NAME.framework.zip"
skip_cleanup: true
on:
repo: awslabs/aws-mobile-appsync-sdk-ios
tags: true
- provider: script
script: bash cocoapods_release.sh
on:
tags: true
2 changes: 1 addition & 1 deletion AWSAppSync.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'AWSAppSync'
s.version = '2.6.19'
s.version = '2.6.20'
s.author = 'AWS'
s.homepage = 'http://aws.amazon.com/mobile/sdk'
s.license = { :type => 'Amazon Software License', :file => 'LICENSE' }
Expand Down
11 changes: 11 additions & 0 deletions AWSAppSyncClient/AWSAppSyncAuthProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@ extension AWSOIDCAuthProviderAsync {
public func getLatestAuthToken() -> String { fatalError("Callback method required") }
}

// For using User Pool based authorization, this protocol needs to be implemented and passed to configuration object.
// Use this for cases where the UserPool auth token needs to be fetched asynchronously and requires a callback
public protocol AWSCognitoUserPoolsAuthProviderAsync: AWSCognitoUserPoolsAuthProvider {
func getLatestAuthToken(_ callback: @escaping (String?, Error?) -> Void)
}

// For CognitoUserPoolAuthProviders that use a callback, the getLatestAuthToken is defaulted to return an empty string
extension AWSCognitoUserPoolsAuthProviderAsync {
public func getLatestAuthToken() -> String { fatalError("Callback method required") }
}

// For using OIDC based authorization, this protocol needs to be implemented and passed to configuration object.
public protocol AWSOIDCAuthProvider {
/// The method should fetch the token and return it to the client for using in header request.
Expand Down
4 changes: 2 additions & 2 deletions AWSAppSyncClient/AWSAppSyncHTTPNetworkTransport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public class AWSAppSyncHTTPNetworkTransport: AWSNetworkTransport {
request.httpMethod = "POST"
request.setValue(NSDate().aws_stringValue(AWSDateISO8601DateFormat2), forHTTPHeaderField: "X-Amz-Date")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.setValue("aws-sdk-ios/2.6.18 AppSyncClient", forHTTPHeaderField: "User-Agent")
request.setValue("aws-sdk-ios/2.6.20 AppSyncClient", forHTTPHeaderField: "User-Agent")
}

/// Send a data payload to a server and return a response.
Expand Down Expand Up @@ -222,7 +222,7 @@ public class AWSAppSyncHTTPNetworkTransport: AWSNetworkTransport {
fatalError("Authentication provider not set")
}
case .amazonCognitoUserPools:
if let provider = self.userPoolsAuthProvider as? AWSOIDCAuthProviderAsync {
if let provider = self.userPoolsAuthProvider as? AWSCognitoUserPoolsAuthProviderAsync {

provider.getLatestAuthToken { (token, error) in
if let error = error {
Expand Down
2 changes: 1 addition & 1 deletion AWSAppSyncClient/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>2.6.19</string>
<string>2.6.20</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
Expand Down
2 changes: 1 addition & 1 deletion AWSAppSyncTests/AuthProviderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class AuthProviderTests: XCTestCase {
}
}

class CognitoUserPoolsAuthProviderAsync: AWSCognitoUserPoolsAuthProvider, AWSOIDCAuthProviderAsync {
class CognitoUserPoolsAuthProviderAsync: AWSCognitoUserPoolsAuthProviderAsync {

var expectation: XCTestExpectation?
init(_ expectation: XCTestExpectation){
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

The AWS AppSync SDK for iOS enables you to access your AWS AppSync backend and perform operations like `Queries`, `Mutations` and `Subscriptions`. The SDK also includes support for offline operations.

## 2.6.20

### Enhancements

* Allow asynchronous fetching of User Pools / OIDC auth token. [See PR#62](https://github.com/awslabs/aws-mobile-appsync-sdk-ios/pull/62) Thanks @JohnRbk 🎉
* Integrate logging with `AWSDDLog`. To print logs from the SDK, follow instructions mentioned [here](https://github.com/aws/aws-sdk-ios#logging).

### Bug Fixes

* Fixed a bug in loading configuration from `awsconfiguration.json`
* Fixed a bug where receiving a non String or JSON object would cause SDK to crash. The SDK would now instead log an error message.

## 2.6.19

### New Features
Expand Down

0 comments on commit bf057a3

Please sign in to comment.