Skip to content

Commit

Permalink
Add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Hopsaheysa committed Nov 10, 2023
1 parent 0ef03b0 commit de3bf05
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import PackageDescription
let package = Package(
name: "WultraMobileTokenSDK",
platforms: [
.iOS(.v11)
.iOS(.v12)
],
products: [
.library(name: "WultraMobileTokenSDK", targets: ["WultraMobileTokenSDK"])
Expand Down
1 change: 1 addition & 0 deletions docs/Error-Handling.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Every error produced by this library is of a `WMTError` type. This error contain
|`operationAlreadyFailed`|Operation is already failed|
|`operationAlreadyCancelled`|Operation is canceled|
|`operationExpired`|Operation is expired|
|`operationFailed`|Default operation action failure|

## WMTErrorReason

Expand Down
13 changes: 7 additions & 6 deletions docs/SDK-Integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Requirements

- iOS 10.0+
- iOS 12.0+
- [PowerAuth Mobile SDK](https://github.com/wultra/powerauth-mobile-sdk) needs to be available in your project

## Swift Package Manager
Expand All @@ -17,7 +17,7 @@ import PackageDescription
let package = Package(
name: "YourLibrary",
platforms: [
.iOS(.v11)
.iOS(.v12)
],
products: [
.library(
Expand All @@ -26,7 +26,7 @@ let package = Package(
),
],
dependencies: [
.package(url: "https://github.com/wultra/mtoken-sdk-ios.git", .from("1.4.1"))
.package(url: "https://github.com/wultra/mtoken-sdk-ios.git", .from("1.7.0"))
],
targets: [
.target(
Expand All @@ -39,15 +39,16 @@ let package = Package(

## Cocoapods

Ddd the following dependencies to your Podfile:
Add the following dependencies to your Podfile:

```rb
pod 'WultraMobileTokenSDK/Operations'
pod 'WultraMobileTokenSDK/Push'
pod 'WultraMobileTokenSDK/Inbox'
```

<!-- begin box info -->
Note: If you want to use only operations, you can omit the Push dependency.
Note: If you want to use only operations, you can omit the Push dependency & Inbox dependency.
<!-- end -->

## Guaranteed PowerAuth Compatibility
Expand All @@ -60,4 +61,4 @@ Note: If you want to use only operations, you can omit the Push dependency.

## Xcode Compatibility

We recommend using Xcode version 13.2 or newer.
We recommend using Xcode version 14.3 or newer.
63 changes: 62 additions & 1 deletion docs/Using-Operations-Service.md
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,9 @@ class WMTUserOperation: WMTOperation {
///
/// Additional UI data such as Pre-Approval Screen or Post-Approval Screen should be presented.
public let ui: WMTOperationUIData?

/// Proximity Check Data to be passed when OTP is handed to the app
public var proximityCheck: WMTProximityCheck?
}
```

Expand Down Expand Up @@ -492,7 +495,7 @@ PreApprovalScreen types:

- `WARNING`
- `INFO`
- `QR_SCAN`
- `QR_SCAN` this type indicates that the `WMTProximityCheck` must be used
- `UNKNOWN`

PostApprovalScreen types:
Expand All @@ -502,6 +505,50 @@ PostApprovalScreen types:
- `REDIRECT` providing text for button, countdown, and redirection URL
- `GENERIC` may contain any object

Definition of `WMTProximityCheck`:

```swift
public class WMTProximityCheck: Codable {
/// Tha actual Time-based one time password
public let totp: String
/// Type of the Proximity check
public let type: WMTProximityCheckType
/// Timestamp when the operation was scanned (QR Code) or delivered to the device (Deeplink)
public let timestampRequested: Date
}
```

WMTProximityCheckType types:

- `qrCode` TOTP was scanned from QR code
- `deeplink` TOTP was delivered to the app via Deeplink


## TOTP WMTProximityCheck

Two-Factor Authentication (2FA) using Time-Based One-Time Passwords (TOTP) in the Operations Service is facilitated through the use of WMTProximityCheck. This allows secure approval of operations through QR code scanning or deeplink handling.

This TOTP-based WMTProximityCheck enhances the security of the approval process, providing a robust mechanism for 2FA in the Operations Service.

- QR Code Flow:

When the `WMTUserOperation` contains a `WMTPreApprovalScreen.qr`, the app should open the camera to scan the QR code before confirming the operation. Use the camera to scan the QR code containing the necessary data payload for the operation.

- Deeplink Flow:

When the app is launched via a deeplink, preserve the data from the deeplink to extract the relevant information. When operations are loaded compare the operation ID from the deeplink data to the operations within the app to find a match.

- Assign TOTP and Type for the Operation
Once the QR code is scanned or match from deeplink is found, create a `WMTProximityCheck` with:
- `totp`: The actual Time-Based One-Time Password.
- `type`: Set to `WMTProximityCheckType.qrCode` or `WMTProximityCheckType.deeplink`.
- `timestampRequested`: The timestamp when the QR code was scanned (by default, it is created as the current timestamp).

- Authorizing the WMTProximityCheck
When authorization, the SDK will by default add `timestampSigned` to the `WMTProximityCheck` object. This timestamp indicates when the operation was signed.

This TOTP-based WMTProximityCheck enhances the security of the approval process, providing a robust mechanism for 2FA in the Operations Service.

### Subclassing WMTUserOperation

`WMTUserOperation` class is `open` and can be subclassed. This is useful when your backend adds additional properties to operations retrieved via the `getOperations` API.
Expand Down Expand Up @@ -561,6 +608,20 @@ public protocol WMTOperation {

/// Data for signing
var data: String { get }

/// Additional information with proximity check data
var proximityCheck: WMTProximityCheck? { get }
}
```

### Utilizing the Proximity Check
When creating custom operations, you can now include proximity check data by conforming to the updated WMTOperation protocol. This enables you to enhance the security of your operations by considering proximity information during the authorization process.

To maintain backward compatibility, a public extension has been added to the WMTOperation protocol. If your existing codebase does not require the use of the proximity check feature, the extension ensures seamless integration:

```swift
public extension WMTOperation {
var proximityCheck: WMTProximityCheck? { nil }
}
```

Expand Down

0 comments on commit de3bf05

Please sign in to comment.