Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions Sources/WebAuthn/Helpers/ChallengeGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,17 @@
//
//===----------------------------------------------------------------------===//

package struct ChallengeGenerator: Sendable {
public struct ChallengeGenerator: Sendable {
static let challengeSize: Int = 32

var generate: @Sendable () -> [UInt8]

package static var live: Self {
.init(generate: { [UInt8].random(count: 32) })
.init(generate: { [UInt8].random(count: challengeSize) })
}

public init(generate: @escaping @Sendable () -> [UInt8]) {
self.generate = generate
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import Foundation

extension KeyedDecodingContainer {
func decodeBytesFromURLEncodedBase64(forKey key: KeyedDecodingContainer.Key) throws -> [UInt8] {
public func decodeBytesFromURLEncodedBase64(forKey key: KeyedDecodingContainer.Key) throws -> [UInt8] {
guard let bytes = try decode(
URLEncodedBase64.self,
forKey: key
Expand All @@ -28,7 +28,7 @@ extension KeyedDecodingContainer {
return bytes
}

func decodeBytesFromURLEncodedBase64IfPresent(forKey key: KeyedDecodingContainer.Key) throws -> [UInt8]? {
public func decodeBytesFromURLEncodedBase64IfPresent(forKey key: KeyedDecodingContainer.Key) throws -> [UInt8]? {
guard let bytes = try decodeIfPresent(
URLEncodedBase64.self,
forKey: key
Expand Down
2 changes: 1 addition & 1 deletion Sources/WebAuthn/WebAuthnManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public struct WebAuthnManager: Sendable {
self.init(configuration: configuration, challengeGenerator: .live)
}

package init(configuration: Configuration, challengeGenerator: ChallengeGenerator) {
public init(configuration: Configuration, challengeGenerator: ChallengeGenerator) {
self.configuration = configuration
self.challengeGenerator = challengeGenerator
}
Expand Down