diff --git a/Sources/WebAuthn/Helpers/ChallengeGenerator.swift b/Sources/WebAuthn/Helpers/ChallengeGenerator.swift index ecbaa69..c1b0b15 100644 --- a/Sources/WebAuthn/Helpers/ChallengeGenerator.swift +++ b/Sources/WebAuthn/Helpers/ChallengeGenerator.swift @@ -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 } + } diff --git a/Sources/WebAuthn/Helpers/KeyedDecodingContainer+decodeURLEncoded.swift b/Sources/WebAuthn/Helpers/KeyedDecodingContainer+decodeURLEncoded.swift index e6af1b5..3a93451 100644 --- a/Sources/WebAuthn/Helpers/KeyedDecodingContainer+decodeURLEncoded.swift +++ b/Sources/WebAuthn/Helpers/KeyedDecodingContainer+decodeURLEncoded.swift @@ -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 @@ -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 diff --git a/Sources/WebAuthn/WebAuthnManager.swift b/Sources/WebAuthn/WebAuthnManager.swift index feebb20..2241e75 100644 --- a/Sources/WebAuthn/WebAuthnManager.swift +++ b/Sources/WebAuthn/WebAuthnManager.swift @@ -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 }