Skip to content

Commit

Permalink
swiftlint: use identifier_name instead of deprecated variable_name
Browse files Browse the repository at this point in the history
  • Loading branch information
phimage authored and e-marchand committed Apr 29, 2021
1 parent efda1f3 commit ef2815d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ included:
disabled_rules:
- file_length
- cyclomatic_complexity
- variable_name
- identifier_name
- todo
- line_length
- type_body_length
Expand Down
14 changes: 7 additions & 7 deletions Sources/Utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,31 +37,31 @@ public func generateCodeVerifier() -> String? {
.replacingOccurrences(of: "/", with: "_")
.replacingOccurrences(of: "=", with: "")
.trimmingCharacters(in: .whitespaces)

return codeVerifier
}

/// Generating a code challenge for PKCE
public func generateCodeChallenge(codeVerifier: String?) -> String? {
guard let verifier = codeVerifier, let data = verifier.data(using: .utf8) else { return nil }

#if !os(Linux)
var buffer = [UInt8](repeating: 0, count: Int(CC_SHA256_DIGEST_LENGTH))
var buffer = [UInt8](repeating: 0, count: Int(CC_SHA256_DIGEST_LENGTH))
data.withUnsafeBytes {
_ = CC_SHA256($0.baseAddress, CC_LONG(data.count), &buffer)
}
let hash = Data(buffer)
#else
let buffer = [UInt8](repeating: 0, count: SHA256.byteCount)
let buffer = [UInt8](repeating: 0, count: SHA256.byteCount)
let sha = Array(HMAC<SHA256>.authenticationCode(for: buffer, using: SymmetricKey(size: .bits256)))
let hash = Data(sha)
#endif

let challenge = hash.base64EncodedString()
.replacingOccurrences(of: "+", with: "-")
.replacingOccurrences(of: "/", with: "_")
.replacingOccurrences(of: "=", with: "")
.trimmingCharacters(in: .whitespaces)

return challenge
}
}

0 comments on commit ef2815d

Please sign in to comment.