Skip to content

Commit

Permalink
fix function namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnzhou committed Feb 12, 2024
1 parent 6944b0c commit 0113d4c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/swift.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ jobs:
name: Swift ${{ matrix.swift }} on ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
swift: ["5.8", "5.9"]
os: ubuntu-latest
swift: "5.9"
runs-on: ${{ matrix.os }}
steps:
- uses: swift-actions/setup-swift@v1
Expand Down
10 changes: 7 additions & 3 deletions Sources/LCLPingAuth/Auth/Authenticate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@

import Foundation

public func validate(credential: Data) throws -> AuthenticationResult {
guard let qrCode = try? JSONDecoder().decode(Keys.self, from: credential) else {
public func deserialize<T: Decodable>(json: Dat, as: T) throws -> T? {
return try JSONDecoder().decode(T.self, from: json)
}

public func validate(credential: Data) throws -> ValidationResult {
guard let qrCode: Keys = try? deserialize(json: credential) else {
throw LCLPingAuthError.invalidCredential
}

Expand Down Expand Up @@ -57,5 +61,5 @@ public func validate(credential: Data) throws -> AuthenticationResult {
h_pkr = digest(data: outputData, algorithm: .SHA256)
outputData.removeAll()

return AuthenticationResult(R: r, skT: skT, hPKR: h_pkr)
return ValidationResult(R: r, skT: skT, hPKR: h_pkr)
}
8 changes: 4 additions & 4 deletions Sources/LCLPingAuth/Models.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ extension Keys {
}
}

public struct AuthenticationResult {
let R: Data
let skT: Data
let hPKR: Data
public struct ValidationResult {
public let R: Data
public let skT: Data
public let hPKR: Data
}

0 comments on commit 0113d4c

Please sign in to comment.