Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// SPDX-License-Identifier: Apache-2.0
//

import AmplifyAvailability
import Foundation

struct ASFAppInfo: ASFAppInfoBehavior {
Expand All @@ -16,9 +17,9 @@ struct ASFAppInfo: ASFAppInfoBehavior {
var targetSDK: String {
var targetSDK: String = ""
#if os(iOS) || os(watchOS) || os(tvOS)
targetSDK = "\(__IPHONE_OS_VERSION_MIN_REQUIRED)"
targetSDK = "\(getIOSVersionMinRequired())"
#elseif os(macOS)
targetSDK = "\(__MAC_OS_X_VERSION_MIN_REQUIRED)"
targetSDK = "\(getMACOSXVersionMinRequired())"
#else
targetSDK = "Unknown"
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ struct AWSCognitoAuthCredentialStore {
let oldUserPoolConfiguration = oldAuthConfigData.getUserPoolConfiguration()
let oldIdentityPoolConfiguration = oldAuthConfigData.getIdentityPoolConfiguration()
let newIdentityConfigData = currentAuthConfig.getIdentityPoolConfiguration()
let newUserPoolConfiguration = currentAuthConfig.getUserPoolConfiguration()

/// Only migrate if
/// Migrate if
/// - Old User Pool Config didn't exist
/// - New Identity Config Data exists
/// - Old Identity Pool Config == New Identity Pool Config
Expand All @@ -95,6 +96,19 @@ struct AWSCognitoAuthCredentialStore {
if let oldCognitoCredentialsData = try? keychain._getData(oldNameSpace) {
try? keychain._set(oldCognitoCredentialsData, key: newNameSpace)
}
/// Migrate if
/// - Old config and new config are different
/// - Old Userpool Existed
/// - Old and new user pool namespacing is the same
} else if oldAuthConfigData != currentAuthConfig &&
oldUserPoolConfiguration != nil &&
UserPoolConfigurationData.isNamespacingEqual(
lhs: oldUserPoolConfiguration,
rhs: newUserPoolConfiguration) {
// retrieve data from the old namespace and save with the new namespace
if let oldCognitoCredentialsData = try? keychain._getData(oldNameSpace) {
try? keychain._set(oldCognitoCredentialsData, key: newNameSpace)
}
} else if oldAuthConfigData != currentAuthConfig &&
oldNameSpace != newNameSpace {
// Clear the old credentials
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ struct UserPoolConfigurationData: Equatable {
func getIdentityProviderName() -> String {
return "cognito-idp.\(region).amazonaws.com/\(poolId)"
}

static func isNamespacingEqual(
lhs: UserPoolConfigurationData?,
rhs: UserPoolConfigurationData?) -> Bool {
return lhs?.poolId == rhs?.poolId
&& lhs?.clientId == rhs?.clientId
&& lhs?.region == rhs?.region
}
}

extension UserPoolConfigurationData: Codable { }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// Copyright Amazon.com Inc. or its affiliates.
// All Rights Reserved.
//
// SPDX-License-Identifier: Apache-2.0
//

#include "include/AmplifyAvailability.h"
#include <Availability.h>

#if TARGET_OS_IOS || TARGET_OS_WATCH || TARGET_OS_TV
int getIOSVersionMinRequired(void) {
return __IPHONE_OS_VERSION_MIN_REQUIRED;
}
#endif

#if TARGET_OS_OSX
int getMACOSXVersionMinRequired(void) {
return __MAC_OS_X_VERSION_MIN_REQUIRED;
}
#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// Copyright Amazon.com Inc. or its affiliates.
// All Rights Reserved.
//
// SPDX-License-Identifier: Apache-2.0
//

#ifndef AmplifyAvailability_h
#define AmplifyAvailability_h

#include <TargetConditionals.h>

#if TARGET_OS_IOS || TARGET_OS_WATCH || TARGET_OS_TV
int getIOSVersionMinRequired(void);
#endif

#if TARGET_OS_OSX
int getMACOSXVersionMinRequired(void);
#endif

#endif /* AmplifyAvailability_h */
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module AmplifyAvailability {
header "include/AmplifyAvailability.h"
export *
}
173 changes: 173 additions & 0 deletions MobileSDK_To_AmplifySwift_Guidance.md

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ let authTargets: [Target] = [
name: "AWSCognitoAuthPlugin",
dependencies: [
.target(name: "Amplify"),
.target(name: "AmplifyAvailability"),
.target(name: "AmplifySRP"),
.target(name: "AWSPluginsCore"),
.target(name: "InternalAmplifyCredentials"),
Expand All @@ -191,6 +192,11 @@ let authTargets: [Target] = [
.copy("Resources/PrivacyInfo.xcprivacy")
]
),
.target(
name: "AmplifyAvailability",
path: "AmplifyPlugins/Auth/Sources/AmplifyAvailability",
publicHeadersPath: "include"
),
.target(
name: "libtommathAmplify",
path: "AmplifyPlugins/Auth/Sources/libtommath",
Expand Down
Loading