Skip to content

Commit e3d6f63

Browse files
authored
chore: kickoff release
2 parents 7fa7abd + c15cf28 commit e3d6f63

File tree

8 files changed

+251
-3
lines changed

8 files changed

+251
-3
lines changed

AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/ASF/ASFAppInfo.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// SPDX-License-Identifier: Apache-2.0
66
//
77

8+
import AmplifyAvailability
89
import Foundation
910

1011
struct ASFAppInfo: ASFAppInfoBehavior {
@@ -16,9 +17,9 @@ struct ASFAppInfo: ASFAppInfoBehavior {
1617
var targetSDK: String {
1718
var targetSDK: String = ""
1819
#if os(iOS) || os(watchOS) || os(tvOS)
19-
targetSDK = "\(__IPHONE_OS_VERSION_MIN_REQUIRED)"
20+
targetSDK = "\(getIOSVersionMinRequired())"
2021
#elseif os(macOS)
21-
targetSDK = "\(__MAC_OS_X_VERSION_MIN_REQUIRED)"
22+
targetSDK = "\(getMACOSXVersionMinRequired())"
2223
#else
2324
targetSDK = "Unknown"
2425
#endif

AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/CredentialStorage/AWSCognitoAuthCredentialStore.swift

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,9 @@ struct AWSCognitoAuthCredentialStore {
8383
let oldUserPoolConfiguration = oldAuthConfigData.getUserPoolConfiguration()
8484
let oldIdentityPoolConfiguration = oldAuthConfigData.getIdentityPoolConfiguration()
8585
let newIdentityConfigData = currentAuthConfig.getIdentityPoolConfiguration()
86+
let newUserPoolConfiguration = currentAuthConfig.getUserPoolConfiguration()
8687

87-
/// Only migrate if
88+
/// Migrate if
8889
/// - Old User Pool Config didn't exist
8990
/// - New Identity Config Data exists
9091
/// - Old Identity Pool Config == New Identity Pool Config
@@ -95,6 +96,19 @@ struct AWSCognitoAuthCredentialStore {
9596
if let oldCognitoCredentialsData = try? keychain._getData(oldNameSpace) {
9697
try? keychain._set(oldCognitoCredentialsData, key: newNameSpace)
9798
}
99+
/// Migrate if
100+
/// - Old config and new config are different
101+
/// - Old Userpool Existed
102+
/// - Old and new user pool namespacing is the same
103+
} else if oldAuthConfigData != currentAuthConfig &&
104+
oldUserPoolConfiguration != nil &&
105+
UserPoolConfigurationData.isNamespacingEqual(
106+
lhs: oldUserPoolConfiguration,
107+
rhs: newUserPoolConfiguration) {
108+
// retrieve data from the old namespace and save with the new namespace
109+
if let oldCognitoCredentialsData = try? keychain._getData(oldNameSpace) {
110+
try? keychain._set(oldCognitoCredentialsData, key: newNameSpace)
111+
}
98112
} else if oldAuthConfigData != currentAuthConfig &&
99113
oldNameSpace != newNameSpace {
100114
// Clear the old credentials

AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/StateMachine/CodeGen/Data/UserPoolConfigurationData.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ struct UserPoolConfigurationData: Equatable {
5757
func getIdentityProviderName() -> String {
5858
return "cognito-idp.\(region).amazonaws.com/\(poolId)"
5959
}
60+
61+
static func isNamespacingEqual(
62+
lhs: UserPoolConfigurationData?,
63+
rhs: UserPoolConfigurationData?) -> Bool {
64+
return lhs?.poolId == rhs?.poolId
65+
&& lhs?.clientId == rhs?.clientId
66+
&& lhs?.region == rhs?.region
67+
}
6068
}
6169

6270
extension UserPoolConfigurationData: Codable { }
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//
2+
// Copyright Amazon.com Inc. or its affiliates.
3+
// All Rights Reserved.
4+
//
5+
// SPDX-License-Identifier: Apache-2.0
6+
//
7+
8+
#include "include/AmplifyAvailability.h"
9+
#include <Availability.h>
10+
11+
#if TARGET_OS_IOS || TARGET_OS_WATCH || TARGET_OS_TV
12+
int getIOSVersionMinRequired(void) {
13+
return __IPHONE_OS_VERSION_MIN_REQUIRED;
14+
}
15+
#endif
16+
17+
#if TARGET_OS_OSX
18+
int getMACOSXVersionMinRequired(void) {
19+
return __MAC_OS_X_VERSION_MIN_REQUIRED;
20+
}
21+
#endif
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//
2+
// Copyright Amazon.com Inc. or its affiliates.
3+
// All Rights Reserved.
4+
//
5+
// SPDX-License-Identifier: Apache-2.0
6+
//
7+
8+
#ifndef AmplifyAvailability_h
9+
#define AmplifyAvailability_h
10+
11+
#include <TargetConditionals.h>
12+
13+
#if TARGET_OS_IOS || TARGET_OS_WATCH || TARGET_OS_TV
14+
int getIOSVersionMinRequired(void);
15+
#endif
16+
17+
#if TARGET_OS_OSX
18+
int getMACOSXVersionMinRequired(void);
19+
#endif
20+
21+
#endif /* AmplifyAvailability_h */
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module AmplifyAvailability {
2+
header "include/AmplifyAvailability.h"
3+
export *
4+
}

MobileSDK_To_AmplifySwift_Guidance.md

Lines changed: 173 additions & 0 deletions
Large diffs are not rendered by default.

Package.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ let authTargets: [Target] = [
179179
name: "AWSCognitoAuthPlugin",
180180
dependencies: [
181181
.target(name: "Amplify"),
182+
.target(name: "AmplifyAvailability"),
182183
.target(name: "AmplifySRP"),
183184
.target(name: "AWSPluginsCore"),
184185
.target(name: "InternalAmplifyCredentials"),
@@ -191,6 +192,11 @@ let authTargets: [Target] = [
191192
.copy("Resources/PrivacyInfo.xcprivacy")
192193
]
193194
),
195+
.target(
196+
name: "AmplifyAvailability",
197+
path: "AmplifyPlugins/Auth/Sources/AmplifyAvailability",
198+
publicHeadersPath: "include"
199+
),
194200
.target(
195201
name: "libtommathAmplify",
196202
path: "AmplifyPlugins/Auth/Sources/libtommath",

0 commit comments

Comments
 (0)