Skip to content

Commit d2e9366

Browse files
committed
initial commit
1 parent 70f56f6 commit d2e9366

File tree

13 files changed

+72
-61
lines changed

13 files changed

+72
-61
lines changed

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

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import Foundation
99
import Amplify
1010

11-
@MainActor
1211
struct ASFDeviceInfo: ASFDeviceBehavior {
1312

1413
let id: String
@@ -18,46 +17,69 @@ struct ASFDeviceInfo: ASFDeviceBehavior {
1817
}
1918

2019
var model: String {
21-
DeviceInfo.current.model
20+
get async {
21+
await MainActor.run { DeviceInfo.current.model }
22+
}
2223
}
2324

2425
var name: String {
25-
DeviceInfo.current.name
26+
get async {
27+
await MainActor.run { DeviceInfo.current.name }
28+
}
2629
}
2730

2831
var type: String {
29-
var systemInfo = utsname()
30-
uname(&systemInfo)
31-
return String(bytes: Data(bytes: &systemInfo.machine,
32-
count: Int(_SYS_NAMELEN)),
33-
encoding: .utf8) ?? DeviceInfo.current.hostName
32+
get async {
33+
await MainActor.run {
34+
var systemInfo = utsname()
35+
uname(&systemInfo)
36+
return String(bytes: Data(bytes: &systemInfo.machine,
37+
count: Int(_SYS_NAMELEN)),
38+
encoding: .utf8) ?? DeviceInfo.current.hostName
39+
}
40+
}
3441
}
3542

3643
var platform: String {
37-
DeviceInfo.current.operatingSystem.name
44+
get async {
45+
await MainActor.run { DeviceInfo.current.operatingSystem.name }
46+
}
3847
}
3948

4049
var version: String {
41-
DeviceInfo.current.operatingSystem.version
50+
get async {
51+
await MainActor.run { DeviceInfo.current.operatingSystem.version }
52+
}
4253
}
4354

4455
var thirdPartyId: String? {
45-
DeviceInfo.current.identifierForVendor?.uuidString
56+
get async {
57+
await MainActor.run { DeviceInfo.current.identifierForVendor?.uuidString }
58+
}
4659
}
4760

4861
var height: String {
49-
String(format: "%.0f", DeviceInfo.current.screenBounds.height)
62+
get async {
63+
await MainActor.run { String(format: "%.0f", DeviceInfo.current.screenBounds.height) }
64+
}
5065
}
5166

5267
var width: String {
53-
String(format: "%.0f", DeviceInfo.current.screenBounds.width)
68+
get async {
69+
await MainActor.run { String(format: "%.0f", DeviceInfo.current.screenBounds.width) }
70+
}
5471
}
5572

5673
var locale: String {
57-
return Locale.preferredLanguages[0]
74+
get async {
75+
await MainActor.run { Locale.preferredLanguages[0] }
76+
}
5877
}
5978

60-
func deviceInfo() -> String {
79+
func deviceInfo() async -> String {
80+
let model = await self.model
81+
let type = await self.type
82+
let version = await self.version
6183
var build = "release"
6284
#if DEBUG
6385
build = "debug"

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,32 @@ protocol AdvancedSecurityBehavior {
1212
func userContextData(for username: String,
1313
deviceInfo: ASFDeviceBehavior,
1414
appInfo: ASFAppInfoBehavior,
15-
configuration: UserPoolConfigurationData) throws -> String
15+
configuration: UserPoolConfigurationData) async throws -> String
1616
}
1717

1818
protocol ASFDeviceBehavior: Sendable {
1919

2020
var id: String { get }
2121

22-
var model: String { get }
22+
var model: String { get async }
2323

24-
var name: String { get }
24+
var name: String { get async }
2525

26-
var platform: String { get }
26+
var platform: String { get async }
2727

28-
var version: String { get }
28+
var version: String { get async }
2929

30-
var thirdPartyId: String? { get }
30+
var thirdPartyId: String? { get async }
3131

32-
var height: String { get }
32+
var height: String { get async }
3333

34-
var width: String { get }
34+
var width: String { get async }
3535

36-
var locale: String { get }
36+
var locale: String { get async }
3737

38-
var type: String { get }
38+
var type: String { get async }
3939

40-
func deviceInfo() -> String
40+
func deviceInfo() async -> String
4141
}
4242

4343
protocol ASFAppInfoBehavior {

AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/ASF/CognitoUserPoolASF+KeyChain.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ extension CognitoUserPoolASF {
3737
let appInfo: ASFAppInfoBehavior = ASFAppInfo()
3838

3939
do {
40-
return try asfClient.userContextData(
40+
return try await asfClient.userContextData(
4141
for: username,
4242
deviceInfo: deviceInfo,
4343
appInfo: appInfo,

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ struct CognitoUserPoolASF: AdvancedSecurityBehavior {
3030
func userContextData(for username: String = "unknown",
3131
deviceInfo: ASFDeviceBehavior,
3232
appInfo: ASFAppInfoBehavior,
33-
configuration: UserPoolConfigurationData) throws -> String {
33+
configuration: UserPoolConfigurationData) async throws -> String {
3434

35-
let contextData = prepareUserContextData(deviceInfo: deviceInfo, appInfo: appInfo)
35+
let contextData = await prepareUserContextData(deviceInfo: deviceInfo, appInfo: appInfo)
3636
let payload = try prepareJsonPayload(username: username,
3737
contextData: contextData,
3838
userPoolId: configuration.poolId)
@@ -43,31 +43,31 @@ struct CognitoUserPoolASF: AdvancedSecurityBehavior {
4343
}
4444

4545
func prepareUserContextData(deviceInfo: ASFDeviceBehavior,
46-
appInfo: ASFAppInfoBehavior) -> [String: String] {
46+
appInfo: ASFAppInfoBehavior) async -> [String: String] {
4747
var build = "release"
4848
#if DEBUG
4949
build = "debug"
5050
#endif
51-
let fingerPrint = deviceInfo.deviceInfo()
51+
let fingerPrint = await deviceInfo.deviceInfo()
5252
var contextData: [String: String] = [
5353
Self.targetSDKKey: appInfo.targetSDK,
5454
Self.appVersionKey: appInfo.version,
55-
Self.deviceNameKey: deviceInfo.name,
56-
Self.phoneTypeKey: deviceInfo.type,
55+
Self.deviceNameKey: await deviceInfo.name,
56+
Self.phoneTypeKey: await deviceInfo.type,
5757
Self.deviceIdKey: deviceInfo.id,
58-
Self.releaseVersionKey: deviceInfo.version,
59-
Self.platformKey: deviceInfo.platform,
58+
Self.releaseVersionKey: await deviceInfo.version,
59+
Self.platformKey: await deviceInfo.platform,
6060
Self.buildTypeKey: build,
6161
Self.timezoneKey: timeZoneOffet(),
62-
Self.deviceHeightKey: deviceInfo.height,
63-
Self.deviceWidthKey: deviceInfo.width,
64-
Self.deviceLanguageKey: deviceInfo.locale,
62+
Self.deviceHeightKey: await deviceInfo.height,
63+
Self.deviceWidthKey: await deviceInfo.width,
64+
Self.deviceLanguageKey: await deviceInfo.locale,
6565
Self.deviceFingerPrintKey: fingerPrint
6666
]
6767
if let appName = appInfo.name {
6868
contextData[Self.appNameKey] = appName
6969
}
70-
if let thirdPartyDeviceIdKey = deviceInfo.thirdPartyId {
70+
if let thirdPartyDeviceIdKey = await deviceInfo.thirdPartyId {
7171
contextData[Self.thirdPartyDeviceIdKey] = thirdPartyDeviceIdKey
7272
}
7373
return contextData

AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Actions/SignIn/CustomSignIn/InitiateCustomAuth.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ struct InitiateCustomAuth: Action {
6767
logVerbose("\(#fileID) Starting execution", environment: environment)
6868

6969
let response = try await cognitoClient.initiateAuth(input: request)
70-
return try UserPoolSignInHelper.parseResponse(response,
71-
for: username,
72-
signInMethod: .apiBased(.customWithoutSRP))
70+
return UserPoolSignInHelper.parseResponse(response,
71+
for: username,
72+
signInMethod: .apiBased(.customWithoutSRP))
7373
}
7474

7575
}

AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Actions/SignUp/ConfirmSignUp.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ extension ConfirmSignUp: CustomDebugDictionaryConvertible {
6666
"identifier": identifier,
6767
"signUpEventData": data.debugDictionary,
6868
"confirmationCode": confirmationCode.masked(),
69-
"forceAliasCreation": forceAliasCreation
69+
"forceAliasCreation": forceAliasCreation as Any
7070
]
7171
}
7272
}

AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Actions/SignUp/InitiateSignUp.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ extension InitiateSignUp: CustomDebugDictionaryConvertible {
8282
[
8383
"identifier": identifier,
8484
"signUpEventData": data.debugDictionary,
85-
"attributes": attributes
85+
"attributes": attributes as Any
8686
]
8787
}
8888
}

AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Models/AWSAuthCognitoSession.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,7 @@ public struct AWSAuthCognitoSession: AuthSession,
6464
return .failure(AuthError.signedOut(
6565
AuthPluginErrorConstants.userSubSignOutError.errorDescription,
6666
AuthPluginErrorConstants.userSubSignOutError.recoverySuggestion))
67-
} catch let error as AuthError {
68-
return .failure(error)
6967
} catch {
70-
let error = AuthError.unknown("""
71-
Could not retreive user sub from the fetched Cognito tokens.
72-
""")
7368
return .failure(error)
7469
}
7570
}

AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Operations/AuthConfigureOperation.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ typealias ConfigureOperation = AmplifyOperation<
1616
Void,
1717
AuthError>
1818

19-
class AuthConfigureOperation: ConfigureOperation {
19+
class AuthConfigureOperation: ConfigureOperation, @unchecked Sendable {
2020

2121
let authConfiguration: AuthConfiguration
2222
let authStateMachine: AuthStateMachine

AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/StateMachine/Resolvers/SRP/SRPSignInState+Resolver.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ extension SRPSignInState {
3232
switch oldState {
3333
case .notStarted:
3434
return resolveNotStarted(byApplying: srpSignInEvent)
35-
case .initiatingSRPA(let signInEventData):
35+
case .initiatingSRPA(_):
3636
return resolveInitiatingSRPA(
3737
byApplying: srpSignInEvent,
3838
from: oldState)

AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Support/HostedUI/HostedUIASWebAuthenticationSession.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import Foundation
99
import Amplify
1010
#if os(iOS) || os(macOS) || os(visionOS)
11-
import AuthenticationServices
11+
@preconcurrency import AuthenticationServices
1212
#endif
1313

1414
class HostedUIASWebAuthenticationSession: NSObject, HostedUISessionBehavior {

AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Task/Helpers/AWSAuthTaskHelper.swift

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,8 @@ class AWSAuthTaskHelper: DefaultLogger {
7272
throw AuthError.unknown("Unable to fetch auth session", nil)
7373
}
7474

75-
do {
76-
let tokens = try cognitoTokenProvider.getCognitoTokens().get()
77-
return tokens.accessToken
78-
} catch let error as AuthError {
79-
throw error
80-
} catch {
81-
throw AuthError.unknown("Unable to fetch auth session", error)
82-
}
75+
let tokens = try cognitoTokenProvider.getCognitoTokens().get()
76+
return tokens.accessToken
8377
}
8478

8579
func getCurrentUser() async throws -> AuthUser {

AmplifyPlugins/Core/AWSPluginsCore/WebSocket/WebSocketClient.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public final actor WebSocketClient: NSObject {
2828
/// Interceptor for appending additional info before makeing the connection
2929
private var interceptor: WebSocketInterceptor?
3030
/// Internal wriable WebSocketEvent data stream
31-
private let subject = PassthroughSubject<WebSocketEvent, Never>()
31+
nonisolated private let subject = PassthroughSubject<WebSocketEvent, Never>()
3232

3333
private let retryWithJitter = RetryWithJitter()
3434

0 commit comments

Comments
 (0)