Delete obsolete OTPScannerController
This commit is contained in:
parent
97368eb8a8
commit
c48fe3755e
3 changed files with 11 additions and 216 deletions
|
|
@ -1,11 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14313.18" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="YoR-iB-XAd">
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="YoR-iB-XAd">
|
||||
<device id="retina5_5" orientation="portrait">
|
||||
<adaptation id="fullscreen"/>
|
||||
</device>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14283.14"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
|
|
@ -667,7 +667,7 @@
|
|||
<!--Scan OTP QR Codes-->
|
||||
<scene sceneID="AuR-rQ-G3V">
|
||||
<objects>
|
||||
<viewController id="A9p-Qb-WmU" customClass="OTPScannerController" customModule="pass" customModuleProvider="target" sceneMemberID="viewController">
|
||||
<viewController id="A9p-Qb-WmU" customClass="QRScannerController" customModule="pass" customModuleProvider="target" sceneMemberID="viewController">
|
||||
<layoutGuides>
|
||||
<viewControllerLayoutGuide type="top" id="75M-B3-rK2"/>
|
||||
<viewControllerLayoutGuide type="bottom" id="eYa-Io-fXF"/>
|
||||
|
|
@ -694,13 +694,7 @@
|
|||
<constraint firstItem="lOI-p4-BGb" firstAttribute="centerX" secondItem="a0T-JY-UcS" secondAttribute="centerX" id="IVH-ax-fJ3"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<navigationItem key="navigationItem" title="Scan OTP QR Codes" id="Hlb-5I-bfE">
|
||||
<barButtonItem key="leftBarButtonItem" systemItem="cancel" id="KBZ-N2-OGE">
|
||||
<connections>
|
||||
<action selector="pressCancel:" destination="A9p-Qb-WmU" id="SYK-Qh-Cs7"/>
|
||||
</connections>
|
||||
</barButtonItem>
|
||||
</navigationItem>
|
||||
<navigationItem key="navigationItem" title="Scan OTP QR Codes" id="Hlb-5I-bfE"/>
|
||||
<connections>
|
||||
<outlet property="scannerOutput" destination="lOI-p4-BGb" id="LZa-eC-1Lc"/>
|
||||
</connections>
|
||||
|
|
@ -1548,92 +1542,14 @@ Cgo
|
|||
<attributes>
|
||||
<color key="NSColor" white="0.40782000000000002" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<font key="NSFont" size="14" name="HelveticaNeue"/>
|
||||
<paragraphStyle key="NSParagraphStyle" alignment="left" lineBreakMode="wordWrapping" baseWritingDirection="natural" tighteningFactorForTruncation="0.0" allowsDefaultTighteningForTruncation="NO">
|
||||
<tabStops>
|
||||
<textTab alignment="left" location="28">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="56">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="84">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="112">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="140">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="168">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="196">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="224">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="252">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="280">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="308">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="336">
|
||||
<options/>
|
||||
</textTab>
|
||||
</tabStops>
|
||||
</paragraphStyle>
|
||||
<paragraphStyle key="NSParagraphStyle" alignment="left" lineBreakMode="wordWrapping" baseWritingDirection="natural" tighteningFactorForTruncation="0.0" allowsDefaultTighteningForTruncation="NO"/>
|
||||
</attributes>
|
||||
</fragment>
|
||||
<fragment content=" $ cat ~/.ssh/id_rsa">
|
||||
<attributes>
|
||||
<color key="NSColor" white="0.40782000000000002" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<font key="NSFont" size="13" name="Menlo-Regular"/>
|
||||
<paragraphStyle key="NSParagraphStyle" alignment="left" lineBreakMode="wordWrapping" baseWritingDirection="natural" tighteningFactorForTruncation="0.0" allowsDefaultTighteningForTruncation="NO">
|
||||
<tabStops>
|
||||
<textTab alignment="left" location="28">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="56">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="84">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="112">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="140">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="168">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="196">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="224">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="252">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="280">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="308">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="336">
|
||||
<options/>
|
||||
</textTab>
|
||||
</tabStops>
|
||||
</paragraphStyle>
|
||||
<paragraphStyle key="NSParagraphStyle" alignment="left" lineBreakMode="wordWrapping" baseWritingDirection="natural" tighteningFactorForTruncation="0.0" allowsDefaultTighteningForTruncation="NO"/>
|
||||
</attributes>
|
||||
</fragment>
|
||||
<fragment>
|
||||
|
|
@ -1643,46 +1559,7 @@ The clipboard will be cleared 45s after pasting.</string>
|
|||
<attributes>
|
||||
<color key="NSColor" white="0.40782000000000002" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
<font key="NSFont" size="14" name="HelveticaNeue"/>
|
||||
<paragraphStyle key="NSParagraphStyle" alignment="left" lineBreakMode="wordWrapping" baseWritingDirection="natural" tighteningFactorForTruncation="0.0" allowsDefaultTighteningForTruncation="NO">
|
||||
<tabStops>
|
||||
<textTab alignment="left" location="28">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="56">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="84">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="112">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="140">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="168">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="196">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="224">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="252">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="280">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="308">
|
||||
<options/>
|
||||
</textTab>
|
||||
<textTab alignment="left" location="336">
|
||||
<options/>
|
||||
</textTab>
|
||||
</tabStops>
|
||||
</paragraphStyle>
|
||||
<paragraphStyle key="NSParagraphStyle" alignment="left" lineBreakMode="wordWrapping" baseWritingDirection="natural" tighteningFactorForTruncation="0.0" allowsDefaultTighteningForTruncation="NO"/>
|
||||
</attributes>
|
||||
</fragment>
|
||||
</attributedString>
|
||||
|
|
@ -1987,11 +1864,11 @@ The clipboard will be cleared 45s after pasting.</string>
|
|||
</scene>
|
||||
</scenes>
|
||||
<resources>
|
||||
<image name="Lock" width="25" height="25"/>
|
||||
<image name="Settings" width="25" height="25"/>
|
||||
<image name="Lock" width="75" height="75"/>
|
||||
<image name="Settings" width="75" height="75"/>
|
||||
</resources>
|
||||
<inferredMetricsTieBreakers>
|
||||
<segue reference="iCM-Fy-hkk"/>
|
||||
<segue reference="UfP-k3-XeR"/>
|
||||
<segue reference="yyD-4H-pLE"/>
|
||||
</inferredMetricsTieBreakers>
|
||||
</document>
|
||||
|
|
|
|||
|
|
@ -1,78 +0,0 @@
|
|||
//
|
||||
// QRScannerController.swift
|
||||
// pass
|
||||
//
|
||||
// Created by Yishi Lin on 10/4/17.
|
||||
// Copyright © 2017 Yishi Lin. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import AVFoundation
|
||||
import passKit
|
||||
|
||||
class OTPScannerController: QRScannerController {
|
||||
|
||||
var scannedOTP: String?
|
||||
|
||||
@IBAction func pressCancel(_ sender: UIBarButtonItem) {
|
||||
navigationController?.popViewController(animated: true)
|
||||
}
|
||||
// MARK: - AVCaptureMetadataOutputObjectsDelegate Methods
|
||||
func captureOutput(_ captureOutput: AVCaptureOutput!, didOutputMetadataObjects metadataObjects: [Any]!, from connection: AVCaptureConnection!) {
|
||||
|
||||
if let metadataObj = metadataObjects.first as? AVMetadataMachineReadableCodeObject,
|
||||
supportedCodeTypes.contains(metadataObj.type),
|
||||
let barCodeObject = videoPreviewLayer?.transformedMetadataObject(for: metadataObj) {
|
||||
|
||||
// draw a bounds on the found QR code
|
||||
qrCodeFrameView?.frame = barCodeObject.bounds
|
||||
|
||||
// check whether it is a valid result
|
||||
if let scannedString = metadataObj.stringValue {
|
||||
if let (accept, message) = delegate?.checkScannedOutput(line: scannedString) {
|
||||
scannerOutput.text = message
|
||||
if accept == true {
|
||||
captureSession?.stopRunning()
|
||||
scannedOTP = scannedString
|
||||
presentSaveAlert()
|
||||
}
|
||||
} else {
|
||||
// no delegate, show the scanned result
|
||||
scannerOutput.text = scannedString
|
||||
}
|
||||
} else {
|
||||
scannerOutput.text = "No string value"
|
||||
}
|
||||
|
||||
} else {
|
||||
qrCodeFrameView?.frame = CGRect.zero
|
||||
scannerOutput.text = "No QR code detected"
|
||||
}
|
||||
}
|
||||
|
||||
private func presentSaveAlert() {
|
||||
// initialize alert
|
||||
// XXX: use Password class for now, we need to come up a better structure to oranize this
|
||||
let password = Password(name: "empty", url: URL(string: ".")!, plainText: scannedOTP!)
|
||||
let (title, content) = password.getOtpStrings()!
|
||||
let alert = UIAlertController(title: "Success", message: "\(title): \(content)", preferredStyle: UIAlertControllerStyle.alert)
|
||||
alert.addAction(UIAlertAction(title: "Save", style: UIAlertActionStyle.default, handler: {[unowned self] (action) -> Void in
|
||||
self.delegate?.handleScannedOutput(line: self.scannedOTP!)
|
||||
self.navigationController?.popViewController(animated: true)
|
||||
}))
|
||||
|
||||
if password.otpType == .hotp {
|
||||
// hotp, no need to refresh
|
||||
self.present(alert, animated: true, completion: nil)
|
||||
} else if password.otpType == .totp {
|
||||
// totp, refresh otp
|
||||
self.present(alert, animated: true) {
|
||||
let alertController = self.presentedViewController as! UIAlertController
|
||||
Timer.scheduledTimer(withTimeInterval: 1, repeats: true) {_ in
|
||||
let (title, content) = password.getOtpStrings()!
|
||||
alertController.message = "\(title): \(content)"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue