-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change
WMTTOTPUtils
name to WMTPACUtils
and change the parsers to…
… work only with deeplink url formats with normal query items instead of JWT
- Loading branch information
1 parent
5ab04f7
commit b6b5ec2
Showing
6 changed files
with
78 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ | |
// | ||
|
||
// SWIFT | ||
SWIFT_VERSION = 5.7 | ||
SWIFT_VERSION = 5.9 | ||
SWIFT_SWIFT3_OBJC_INFERENCE = Off | ||
|
||
// SDK | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// | ||
// Copyright 2023 Wultra s.r.o. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions | ||
// and limitations under the License. | ||
// | ||
|
||
import Foundation | ||
|
||
/// Utility class used for handling Proximity Antifraud Check | ||
public class WMTPACUtils { | ||
|
||
/// Method accepts deeplink URL and returns PAC data | ||
public static func parseDeeplink(url: URL) -> WMTPACData? { | ||
|
||
guard let components = URLComponents(string: url.absoluteString) else { | ||
D.error("Failed to get URLComponents: URLString is malformed") | ||
return nil | ||
} | ||
|
||
guard let queryItems = components.queryItems else { | ||
D.error("Failed to get URLComponents queryItems") | ||
return nil | ||
} | ||
|
||
if let operationId = queryItems.first(where: { $0.name == "oid" })?.value { | ||
let totp = queryItems.first(where: { $0.name == "totp" })?.value | ||
return WMTPACData(operationId: operationId, totp: totp) | ||
} else { | ||
D.error("Failed to get operationId from query items") | ||
return nil | ||
} | ||
} | ||
|
||
/// Method accepts scanned code as a String and returns PAC data | ||
public static func parseQRCode(code: String) -> WMTPACData? { | ||
if let encodedURLString = code.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed), let url = URL(string: encodedURLString) { | ||
return parseDeeplink(url: url) | ||
} else { | ||
D.error("Failed to created URL from QR code String.") | ||
return nil | ||
} | ||
} | ||
} | ||
|
||
/// Data which is return after parsing PAC code | ||
public struct WMTPACData { | ||
|
||
/// The ID of the operation associated with the PAC | ||
public let operationId: String | ||
|
||
/// Time-based one time password used for Proximity antifraud check | ||
public let totp: String? | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters