diff --git a/NightscoutServiceKit/OTPManager.swift b/NightscoutServiceKit/OTPManager.swift index 1e2bf78..b938929 100644 --- a/NightscoutServiceKit/OTPManager.swift +++ b/NightscoutServiceKit/OTPManager.swift @@ -70,7 +70,8 @@ public class OTPManager { private var secretStore: OTPSecretStore private var nowDateSource: () -> Date - let algorithm: Generator.Algorithm = .sha512 + let algorithm: Generator.Algorithm = .sha1 + let issuerName = "Loop" var tokenPeriod: TimeInterval var passwordDigitCount = 6 public static var defaultTokenPeriod: TimeInterval = 30 @@ -143,7 +144,7 @@ public class OTPManager { } let generator = Generator(factor: .timer(period: TimeInterval(self.tokenPeriod)), secret: secretKeyData, algorithm: algorithm, digits: passwordDigitCount)! - return Token(name: "\(secretKeyName)", issuer: "Loop", generator: generator) + return Token(name: secretKeyName, issuer: issuerName, generator: generator) } public func getLastPasswordsAscending(count: Int) -> [String] { @@ -179,16 +180,18 @@ public class OTPManager { guard let secretKey = secretStore.tokenSecretKey(), let tokenName = secretStore.tokenSecretKeyName() else { return nil } - + //otpauth://totp/blah:1630787634876?secret=V45JRIB4TC37FUACFN2YZFKC54EIV7C2&issuer=Loop&algorithm=SHA1&digits=6&period=30 let queryItems = [ URLQueryItem(name: "algorithm", value: algorithm.otpURLStringComponent()), URLQueryItem(name: "digits", value: "\(passwordDigitCount)"), - URLQueryItem(name: "issuer", value: "Loop"), + URLQueryItem(name: "issuer", value: issuerName), URLQueryItem(name: "period", value: "\(Int(tokenPeriod))"), URLQueryItem(name: "secret", value: secretKey), ] - + //otpauth://totp/Loop:1630787634876?secret=V45JRIB4TC37FUACFN2YZFK\C54EIV7C2&issuer=Loop&algorithm=SHA1&digits=6&period=30 + //otpauth://totp/Loop:1630787634876?secret=V45JRIB4TC37FUACFN2YZFKC54EIV7C2&issuer=Loop&algorithm=SHA1&digits=6&period=30 let components = URLComponents(scheme: "otpauth", host: "totp", path: "/" + tokenName, queryItems: queryItems) + print(components.url?.absoluteString) return components.url?.absoluteString }