Skip to content

Securely reveal data from VGS and display it via forms without having to have that data pass through your systems

License

Notifications You must be signed in to change notification settings

verygoodsecurity/vgs-show-ios

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

UT license swift

VGS Show iOS SDK

VGS Show - is a product suite that allows customers to reveal and show information securely without possession of it. VGSShow iOS SDK allows you to securely reveal data from VGS and display it via forms without having to have that data pass through your systems. The form UI Elements behave like traditional labels while securing access to the unsecured data.

VGS Show iOS SDK Aliases VGS Show iOS SDK Revealed Data

Table of contents

Before you start

You should have your organization registered at the VGS Dashboard. Sandbox vault will be pre-created for you. You should use your and have already created aliases to start revealing data. If you need to create aliases, you can use VGSCollecSDK with same to create some, or try one of the methods described in our docs.

Integration

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate VGSShowSDK into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'VGSShowSDK'

Swift Package Manager, Xcode 12+

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler.

Once you have your Swift package set up, add VGSShowSDK dependency.

dependencies: [
    .package(url: "https://github.com/verygoodsecurity/vgs-show-ios", .upToNextMajor(from: "1.0.0"))
]

Usage

Import SDK

import VGSShowSDK

Create VGSShow instance and VGS UI Elements

Use your <vaultId> to initialize VGSShow instance. You can get it in your organisation dashboard.

Code example

/// VGSShow instance.
let vgsShow = VGSShow(id: "<VAULT_ID>", environment: .sandbox)

/// VGSShow views.
let cardNumberLabel = VGSLabel()
let expDateLabel = VGSLabel()

override func viewDidLoad() {
    super.viewDidLoad()
    
    /// ...
    
    // Setup content path in reveal response
    cardNumberLabel.contentPath = "cardData.cardNumber"
    expDateLabel.contentPath = "cardData.expDate"

    // Register VGSShow views in vgsShow instance.
    vgsShow.subscribe(cardNumberLabel)
    vgsShow.subscribe(expDateLabel)

    // Configure UI.
    configureUI()
    
    /// ...
}

// Configure VGS Show UI Elements.
private func configureUI() {
    let paddings = UIEdgeInsets.init(top: 8, left: 8, bottom: 8, right: 8)
    let textColor = UIColor.white
    let borderColor = UIColor.clear
    let font = UIFont.systemFont(ofSize: 20)
    let backgroundColor = UIColor.systemBlue
    let cornerRadius: CGFloat = 0

    cardNumberLabel.textColor = textColor
    cardNumberLabel.paddings = paddings
    cardNumberLabel.borderColor = borderColor
    cardNumberLabel.font = font
    cardNumberLabel.backgroundColor = backgroundColor
    cardNumberLabel.layer.cornerRadius = cornerRadius

    expDateLabel.textColor = textColor
    expDateLabel.paddings = paddings
    expDateLabel.borderColor = borderColor
    expDateLabel.font = font
    expDateLabel.backgroundColor = backgroundColor
    expDateLabel.layer.cornerRadius = cornerRadius
    expDateLabel.characterSpacing = 0.83
}
...

Make reveal data request

In order to change aliases to the real data, you need to make reveal request. The aliases data will be revealed when the response goes through VGS proxy. If the request is success, revealed data will be automatically displayed in subscribed VGS Show UI Elements. You also can send any additional data in the request payload.

func revealData() {

  /// set custom headers
  vgsShow.customHeaders = [
      "custom-header": "custom data"
  ]

  /// send any additional data to your backend
  let customPayload = ["CustomKey" : "CustomValue"]()

  /// make a reveal request
  vgsShow.request(path: "post",
                method: .post,
               payload: customPayload) { (requestResult) in

      switch requestResult {
      case .success(let code):
          self.copyCardNumberButton.isEnabled = true
          print("vgsshow success, code: \(code)")
      case .failure(let code, let error):
          print("vgsshow failed, code: \(code), error: \(error)")
      }
  }
}

Demo Application

Demo application for collecting card data on iOS is here.

Also you can reveal PDF files with VGShow iOS SDK. Check our demo with redact and reveal pdf file use case.

Releases

To follow VGSShowSDK updates and changes check the releases page.

Metrics

VGSShow tracks a few key metrics to understand SDK features usage help us know what areas need improvement. No personal/sensitive information is collected. You can easily opt-out of metrics collection in VGSAnalyticsClient:

VGSAnalyticsClient.shared.shouldCollectAnalytics = false

Dependencies

  • iOS 13+
  • Swift 5

License

VGSShow iOS SDK is released under the MIT license. See LICENSE for details.