Skip to content

Commit

Permalink
chore: resolve swiftlint errors and warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
phantumcode committed Jan 2, 2024
1 parent 09403e5 commit bb692b0
Show file tree
Hide file tree
Showing 84 changed files with 135 additions and 147 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ extension AWSCognitoAuthPlugin {
}

if let maxRetryUnwrapped = networkPreferences?.maxRetryCount {
configuration.retryStrategyOptions = RetryStrategyOptions(maxRetriesBase: Int(maxRetryUnwrapped))
configuration.retryStrategyOptions = RetryStrategyOptions(maxRetriesBase: Int(maxRetryUnwrapped))
}

return CognitoIdentityProviderClient(config: configuration)
Expand All @@ -131,7 +131,7 @@ extension AWSCognitoAuthPlugin {
}

if let maxRetryUnwrapped = networkPreferences?.maxRetryCount {
configuration.retryStrategyOptions = RetryStrategyOptions(maxRetriesBase: Int(maxRetryUnwrapped))
configuration.retryStrategyOptions = RetryStrategyOptions(maxRetriesBase: Int(maxRetryUnwrapped))
}

return CognitoIdentityClient(config: configuration)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@ public extension AWSCognitoAuthPlugin {
userPoolFactory: authEnvironment.cognitoUserPoolFactory)
return try await task.value
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,9 @@ struct InitializeAuthConfiguration: Action {
if case .amplifyCredentials(let fetchedCredentials) = data {
credentials = fetchedCredentials
}
}
catch KeychainStoreError.itemNotFound {
} catch KeychainStoreError.itemNotFound {
logInfo("No existing session found.", environment: environment)
}
catch {
} catch {
logError("Error when loading amplify credentials: \(error)", environment: environment)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Foundation
import Amplify
@_spi(KeychainStore) import AWSPluginsCore

// swiftlint:disable identifier_name
struct MigrateLegacyCredentialStore: Action {

let identifier = "MigrateLegacyCredentialStore"
Expand Down Expand Up @@ -361,7 +362,7 @@ extension MigrateLegacyCredentialStore: DefaultLogger {
public static var log: Logger {
Amplify.Logging.logger(forCategory: CategoryType.auth.displayName, forNamespace: String(describing: self))
}

public var log: Logger {
Self.log
}
Expand All @@ -380,3 +381,4 @@ extension MigrateLegacyCredentialStore: CustomDebugStringConvertible {
debugDictionary.debugDescription
}
}
// swiftlint:enable identifier_name
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ extension InformUserDeletedAndSignedOut: DefaultLogger {
public static var log: Logger {
Amplify.Logging.logger(forCategory: CategoryType.auth.displayName, forNamespace: String(describing: self))
}

public var log: Logger {
Self.log
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ extension InformSessionError: DefaultLogger {
public static var log: Logger {
Amplify.Logging.logger(forCategory: CategoryType.auth.displayName, forNamespace: String(describing: self))
}

public var log: Logger {
Self.log
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ extension InformSessionFetched: DefaultLogger {
public static var log: Logger {
Amplify.Logging.logger(forCategory: CategoryType.auth.displayName, forNamespace: String(describing: self))
}

public var log: Logger {
Self.log
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ extension InitializeFetchAuthSessionWithUserPool: DefaultLogger {
public static var log: Logger {
Amplify.Logging.logger(forCategory: CategoryType.auth.displayName, forNamespace: String(describing: self))
}

public var log: Logger {
Self.log
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ extension InitializeFetchUnAuthSession: DefaultLogger {
public static var log: Logger {
Amplify.Logging.logger(forCategory: CategoryType.auth.displayName, forNamespace: String(describing: self))
}

public var log: Logger {
Self.log
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ extension PersistCredentials: DefaultLogger {
public static var log: Logger {
Amplify.Logging.logger(forCategory: CategoryType.auth.displayName, forNamespace: String(describing: self))
}

public var log: Logger {
Self.log
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ extension InformSessionRefreshed: DefaultLogger {
public static var log: Logger {
Amplify.Logging.logger(forCategory: CategoryType.auth.displayName, forNamespace: String(describing: self))
}

public var log: Logger {
Self.log
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ extension InitializeRefreshSession: DefaultLogger {
public static var log: Logger {
Amplify.Logging.logger(forCategory: CategoryType.auth.displayName, forNamespace: String(describing: self))
}

public var log: Logger {
Self.log
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ extension RefreshHostedUITokens: DefaultLogger {
public static var log: Logger {
Amplify.Logging.logger(forCategory: CategoryType.auth.displayName, forNamespace: String(describing: self))
}

public var log: Logger {
Self.log
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ extension RefreshUserPoolTokens: DefaultLogger {
public static var log: Logger {
Amplify.Logging.logger(forCategory: CategoryType.auth.displayName, forNamespace: String(describing: self))
}

public var log: Logger {
Self.log
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ extension InitiateCustomAuth: DefaultLogger {
public static var log: Logger {
Amplify.Logging.logger(forCategory: CategoryType.auth.displayName, forNamespace: String(describing: self))
}

public var log: Logger {
Self.log
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ struct InitiateAuthDeviceSRP: Action {
_ response: SignInResponseBehavior,
with stateData: SRPStateData) -> StateMachineEvent {
guard case .devicePasswordVerifier = response.challengeName else {
let message = "Unsupported challenge response during DeviceSRPAuth \(response.challengeName ?? .sdkUnknown("Response did not contain challenge info"))"
let message = """
Unsupported challenge response during DeviceSRPAuth
\(response.challengeName ?? .sdkUnknown("Response did not contain challenge info"))
"""
let error = SignInError.unknown(message: message)
return SignInEvent(eventType: .throwAuthError(error))
}
Expand All @@ -99,7 +102,7 @@ extension InitiateAuthDeviceSRP: DefaultLogger {
public static var log: Logger {
Amplify.Logging.logger(forCategory: CategoryType.auth.displayName, forNamespace: String(describing: self))
}

public var log: Logger {
Self.log
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import CryptoKit

extension VerifyDevicePasswordSRP {

// swiftlint:disable:next function_parameter_count identifier_name
func signature(deviceGroupKey: String,
deviceKey: String,
deviceSecret: String,
Expand All @@ -28,6 +29,7 @@ extension VerifyDevicePasswordSRP {
do {
let dateStr = stateData.clientTimestamp.utcString
let clientClass = type(of: srpClient)
// swiftlint:disable:next identifier_name
let u = try clientClass.calculateUHexValue(
clientPublicKeyHexValue: stateData.srpKeyPair.publicKeyHexValue,
serverPublicKeyHexValue: serverPublicBHexString)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ extension VerifyDevicePasswordSRP: DefaultLogger {
public static var log: Logger {
Amplify.Logging.logger(forCategory: CategoryType.auth.displayName, forNamespace: String(describing: self))
}

public var log: Logger {
Self.log
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ struct InitializeSignInFlow: Action {
let event = SignInEvent(eventType: .throwAuthError(.configuration(message: message)))
return event
}

var deviceMetadata = DeviceMetadata.noData
if let username = signInEventData.username {
deviceMetadata = await DeviceMetadataHelper.getDeviceMetadata(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ extension InitiateMigrateAuth: DefaultLogger {
public static var log: Logger {
Amplify.Logging.logger(forCategory: CategoryType.auth.displayName, forNamespace: String(describing: self))
}

public var log: Logger {
Self.log
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ extension CancelSignIn: DefaultLogger {
public static var log: Logger {
Amplify.Logging.logger(forCategory: CategoryType.auth.displayName, forNamespace: String(describing: self))
}

public var log: Logger {
Self.log
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ extension InitiateAuthSRP: DefaultLogger {
public static var log: Logger {
Amplify.Logging.logger(forCategory: CategoryType.auth.displayName, forNamespace: String(describing: self))
}

public var log: Logger {
Self.log
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ extension ThrowSignInError: DefaultLogger {
public static var log: Logger {
Amplify.Logging.logger(forCategory: CategoryType.auth.displayName, forNamespace: String(describing: self))
}

public var log: Logger {
Self.log
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import CryptoKit

extension VerifyPasswordSRP {

// swiftlint:disable:next function_parameter_count
func signature(userIdForSRP: String,
saltHex: String,
secretBlock: Data,
Expand All @@ -28,6 +29,7 @@ extension VerifyPasswordSRP {
let strippedPoolId = strippedPoolId(poolId)
let dateStr = stateData.clientTimestamp.utcString
let clientClass = type(of: srpClient)
// swiftlint:disable:next identifier_name
let u = try clientClass.calculateUHexValue(
clientPublicKeyHexValue: stateData.srpKeyPair.publicKeyHexValue,
serverPublicKeyHexValue: serverPublicBHexString)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ extension VerifyPasswordSRP: DefaultLogger {
public static var log: Logger {
Amplify.Logging.logger(forCategory: CategoryType.auth.displayName, forNamespace: String(describing: self))
}

public var log: Logger {
Self.log
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Foundation
import Amplify
import AuthenticationServices

// swiftlint:disable force_cast
extension AWSCognitoAuthPlugin: AuthCategoryBehavior {

public func signUp(username: String,
Expand All @@ -27,7 +28,7 @@ extension AWSCognitoAuthPlugin: AuthCategoryBehavior {
public func confirmSignUp(for username: String,
confirmationCode: String,
options: AuthConfirmSignUpRequest.Options?)
async throws-> AuthSignUpResult {
async throws -> AuthSignUpResult {
let options = options ?? AuthConfirmSignUpRequest.Options()
let request = AuthConfirmSignUpRequest(username: username,
code: confirmationCode,
Expand Down Expand Up @@ -176,7 +177,6 @@ extension AWSCognitoAuthPlugin: AuthCategoryBehavior {
} as! TOTPSetupDetails
}


public func verifyTOTPSetup(
code: String,
options: VerifyTOTPSetupRequest.Options?
Expand All @@ -194,3 +194,4 @@ extension AWSCognitoAuthPlugin: AuthCategoryBehavior {
}
}
}
// swiftlint:enable force_cast
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ extension AWSCognitoAuthPlugin: AuthCategoryDeviceBehavior {
userPoolFactory: authEnvironment.cognitoUserPoolFactory)
return try await taskQueue.sync {
return try await task.value
} as! [AuthDevice]
} as! [AuthDevice] // swiftlint:disable:this force_cast
}

public func forgetDevice(_ device: AuthDevice? = nil,
options: AuthForgetDeviceRequest.Options? = nil) async throws {
public func forgetDevice(
_ device: AuthDevice? = nil,
options: AuthForgetDeviceRequest.Options? = nil
) async throws {
let options = options ?? AuthForgetDeviceRequest.Options()
let request = AuthForgetDeviceRequest(device: device, options: options)
let task = AWSAuthForgetDeviceTask(request,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import Foundation
import Amplify

// swiftlint:disable force_cast
public extension AWSCognitoAuthPlugin {

func fetchUserAttributes(options: AuthFetchUserAttributesRequest.Options? = nil) async throws -> [AuthUserAttribute] {
Expand Down Expand Up @@ -50,7 +51,11 @@ public extension AWSCognitoAuthPlugin {
let options = options ?? AuthAttributeResendConfirmationCodeRequest.Options()
let request = AuthAttributeResendConfirmationCodeRequest(
attributeKey: userAttributeKey, options: options)
let task = AWSAuthAttributeResendConfirmationCodeTask(request, authStateMachine: authStateMachine, userPoolFactory: authEnvironment.cognitoUserPoolFactory)
let task = AWSAuthAttributeResendConfirmationCodeTask(
request,
authStateMachine: authStateMachine,
userPoolFactory: authEnvironment.cognitoUserPoolFactory
)
return try await taskQueue.sync {
return try await task.value
} as! AuthCodeDeliveryDetails
Expand Down Expand Up @@ -98,3 +103,4 @@ public extension AWSCognitoAuthPlugin {
return try await taskHelper.getCurrentUser()
}
}
// swiftlint:enable force_cast
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class AuthHubEventHandler: AuthHubEventBehavior {
}
self?.handleSignInEvent(result)
#endif

case HubPayload.EventName.Auth.deleteUserAPI:
guard let event = payload.data as? AWSAuthDeleteUserTask.AmplifyAuthTaskResult,
case .success = event else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public struct AWSCognitoUserPoolTokens: AuthCognitoTokens {
@available(*, deprecated, message: "Use of `expiration` is deprecated, use `exp` claim in the `idToken` or `accessToken` for expiries")
public let expiration: Date

// swiftlint:disable:next line_length
@available(*, deprecated, message: "Use of `init(idToken,accessToken,refreshToken:expiresIn)` is deprecated, use `exp` claim in the `idToken` or `accessToken` instead")
public init(idToken: String,
accessToken: String,
Expand All @@ -30,6 +31,7 @@ public struct AWSCognitoUserPoolTokens: AuthCognitoTokens {
self.expiration = Date().addingTimeInterval(TimeInterval(expiresIn))
}

// swiftlint:disable:next line_length
@available(*, deprecated, message: "Use of `init(idToken,accessToken,refreshToken:expiration)` is deprecated, use `exp` claim in the `idToken` or `accessToken` instead")
public init(idToken: String,
accessToken: String,
Expand Down Expand Up @@ -71,7 +73,7 @@ public struct AWSCognitoUserPoolTokens: AuthCognitoTokens {
self.expiration = Date(timeIntervalSince1970: TimeInterval(expirationDoubleValue))
}
}

}

extension AWSCognitoUserPoolTokens: Equatable { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Foundation

/// Input for updating the MFA preference for a MFA Type
public enum MFAPreference {

// enabled: false
case disabled

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ public struct AWSAuthConfirmResetPasswordOptions {
self.metadata = metadata
}
}

Loading

0 comments on commit bb692b0

Please sign in to comment.