passforios/pass/Services/PasswordManager.swift
Danny Mösch 763cddf540
Show notification with OTP after providing password through extension (#509)
* Allow to do something with a password after providing it in the extension
* Make fields non-nil
* Show OTP in notification after providing a password through extension
2021-09-20 00:50:05 -07:00

38 lines
1.2 KiB
Swift

//
// PasswordManager.swift
// pass
//
// Created by Mingshen Sun on 17/1/2021.
// Copyright © 2021 Bob Sun. All rights reserved.
//
import passKit
import SVProgressHUD
import UIKit
class PasswordManager {
private let viewController: UIViewController
init(viewController: UIViewController) {
self.viewController = viewController
}
func providePasswordPasteboard(with passwordPath: String) {
decryptPassword(in: viewController, with: passwordPath) { password in
SecurePasteboard.shared.copy(textToCopy: password.password)
SVProgressHUD.setDefaultMaskType(.black)
SVProgressHUD.setDefaultStyle(.dark)
SVProgressHUD.showSuccess(withStatus: "PasswordCopiedToPasteboard.".localize())
SVProgressHUD.dismiss(withDelay: 1)
}
}
func addPassword(with password: Password) {
encryptPassword(in: viewController, with: password) {
SVProgressHUD.setDefaultMaskType(.black)
SVProgressHUD.setDefaultStyle(.light)
SVProgressHUD.showSuccess(withStatus: "Done".localize())
SVProgressHUD.dismiss(withDelay: 1)
}
}
}