Separate parser and helpers from Password class for better testability
This commit is contained in:
parent
2abbceb2e9
commit
7c12263458
17 changed files with 913 additions and 537 deletions
30
passKit/Helpers/PasswordHelpers.swift
Normal file
30
passKit/Helpers/PasswordHelpers.swift
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
//
|
||||
// PasswordHelpers.swift
|
||||
// passKit
|
||||
//
|
||||
// Created by Danny Moesch on 17.08.18.
|
||||
// Copyright © 2018 Bob Sun. All rights reserved.
|
||||
//
|
||||
|
||||
import OneTimePassword
|
||||
|
||||
public enum OtpType {
|
||||
case totp, hotp, none
|
||||
|
||||
init(token: Token?) {
|
||||
switch token?.generator.factor {
|
||||
case .some(.counter):
|
||||
self = .hotp
|
||||
case .some(.timer):
|
||||
self = .totp
|
||||
default:
|
||||
self = .none
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum PasswordChange: Int {
|
||||
case path = 0x01
|
||||
case content = 0x02
|
||||
case none = 0x00
|
||||
}
|
||||
|
|
@ -16,3 +16,9 @@ public extension String {
|
|||
return addingPercentEncoding(withAllowedCharacters: allowed)
|
||||
}
|
||||
}
|
||||
|
||||
extension String {
|
||||
static func | (left: String, right: String) -> String {
|
||||
return right.isEmpty ? left : left + "\n" + right
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue