diff --git a/.gitmodules b/.gitmodules index b22feb37..bd07bd3d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "Carthage/Checkouts/OneTimePassword"] path = Carthage/Checkouts/OneTimePassword - url = https://github.com/mattrubin/OneTimePassword.git + url = https://github.com/bmwalters/OneTimePassword.git [submodule "Carthage/Checkouts/xcconfigs"] path = Carthage/Checkouts/xcconfigs url = https://github.com/jspahrsummers/xcconfigs.git diff --git a/Authenticator/Source/TokenEntryForm.swift b/Authenticator/Source/TokenEntryForm.swift index b25a8491..bf5cb809 100644 --- a/Authenticator/Source/TokenEntryForm.swift +++ b/Authenticator/Source/TokenEntryForm.swift @@ -29,6 +29,7 @@ import Base32 private let defaultTimerFactor = Generator.Factor.timer(period: 30) private let defaultCounterFactor = Generator.Factor.counter(0) +private let steamguardFactor = Generator.Factor.timer(period: 30) struct TokenEntryForm: Component { private var issuer: String = "" @@ -91,9 +92,10 @@ extension TokenEntryForm { rows: !showsAdvancedOptions ? [] : [ tokenTypeRowModel, + ] + (tokenType == .steamguard ? [] : [ digitCountRowModel, algorithmRowModel, - ] + ]) ), ], doneKeyAction: .submit @@ -190,8 +192,16 @@ extension TokenEntryForm { self.name = name case let .secret(secret): self.secret = secret + case .tokenType(.steamguard): + self.tokenType = .steamguard + // All Steam Guard tokens use the following settings. + self.algorithm = .sha1 + self.digitCount = 5 case let .tokenType(tokenType): self.tokenType = tokenType + // The digit count may have been lowered by + // switching to Steam Guard, so clamp it. + self.digitCount = max(self.digitCount, 6) case let .digitCount(digitCount): self.digitCount = digitCount case let .algorithm(algorithm): @@ -217,18 +227,25 @@ extension TokenEntryForm { } let factor: Generator.Factor + let representation: Generator.Representation switch tokenType { case .counter: factor = defaultCounterFactor + representation = .numeric case .timer: factor = defaultTimerFactor + representation = .numeric + case .steamguard: + factor = steamguardFactor + representation = .steamguard } guard let generator = Generator( factor: factor, secret: secretData, algorithm: algorithm, - digits: digitCount + digits: digitCount, + representation: representation ) else { // This UI doesn't allow the user to create an invalid period or digit count, // so a generic error message is acceptable here. diff --git a/Authenticator/Source/TokenFormModels.swift b/Authenticator/Source/TokenFormModels.swift index 88558bab..8b3d9467 100644 --- a/Authenticator/Source/TokenFormModels.swift +++ b/Authenticator/Source/TokenFormModels.swift @@ -47,7 +47,7 @@ enum TokenFormRowModel: Identifiable { } enum TokenType { - case counter, timer + case counter, timer, steamguard } extension TextFieldRowViewModel { @@ -96,6 +96,7 @@ extension SegmentedControlRowViewModel { let options = [ (title: "Time Based", value: TokenType.timer), (title: "Counter Based", value: TokenType.counter), + (title: "Steam Guard", value: TokenType.steamguard), ] self.init(options: options, value: value, changeAction: changeAction) } diff --git a/Cartfile b/Cartfile index 6dc032ec..1d8ab00d 100644 --- a/Cartfile +++ b/Cartfile @@ -1,4 +1,4 @@ # Configuration for Carthage (https://github.com/Carthage/Carthage) -github "mattrubin/OneTimePassword" ~> 3.1.4 +github "bmwalters/OneTimePassword" "feature/steamguard" github "SVProgressHUD/SVProgressHUD" ~> 2.0 diff --git a/Cartfile.resolved b/Cartfile.resolved index 54abe02f..fbaf8858 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,5 +1,5 @@ github "SVProgressHUD/SVProgressHUD" "2.2.5" +github "bmwalters/OneTimePassword" "d00dd01e81d89d0dafd4770e4d50141733007584" github "jspahrsummers/xcconfigs" "1.0" github "mattrubin/Base32" "1.1.2+xcode10.2" -github "mattrubin/OneTimePassword" "3.1.5" github "shinydevelopment/SimulatorStatusMagic" "2.4.1" diff --git a/Carthage/Checkouts/OneTimePassword b/Carthage/Checkouts/OneTimePassword index 8e325177..d00dd01e 160000 --- a/Carthage/Checkouts/OneTimePassword +++ b/Carthage/Checkouts/OneTimePassword @@ -1 +1 @@ -Subproject commit 8e32517705c140360b2b09e655ccd70f63e15fdc +Subproject commit d00dd01e81d89d0dafd4770e4d50141733007584