Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
9818DEA329239C1C004C72AE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
9818DEA529239C1C004C72AE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
9818DEAB29239C87004C72AE /* ResponseStructs.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ResponseStructs.swift; sourceTree = "<group>"; };
9818DEAF29239CD0004C72AE /* ExampleTokenProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ExampleTokenProvider.swift; path = ../../Upsert/Upsert/ExampleTokenProvider.swift; sourceTree = "<group>"; };
9818DEB129239CD9004C72AE /* ExampleAPICallback.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ExampleAPICallback.swift; path = ../../Upsert/Upsert/ExampleAPICallback.swift; sourceTree = "<group>"; };
9818DEAF29239CD0004C72AE /* ExampleTokenProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExampleTokenProvider.swift; sourceTree = "<group>"; };
9818DEB129239CD9004C72AE /* ExampleAPICallback.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExampleAPICallback.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright (c) 2022 Skyflow
*/

import Foundation
import Skyflow

public class ExampleAPICallback: Skyflow.Callback {
private var updateSuccess: ((SuccessResponse) -> Void)?
private var updateFailure: (() -> Void)?
private var decoder: JSONDecoder?

internal init(updateSuccess: @escaping (SuccessResponse) -> Void, updateFailure: @escaping () -> Void) {
self.updateSuccess = updateSuccess
self.updateFailure = updateFailure
self.decoder = JSONDecoder()
}

internal init() {
}

public func onSuccess(_ responseBody: Any) {
if updateSuccess == nil {
print("success:", responseBody)
return
}
do {
let dataString = String(data: try! JSONSerialization.data(withJSONObject: responseBody), encoding: .utf8)
let responseData = Data(dataString!.utf8)
let jsonResponse = try decoder!.decode(SuccessResponse.self, from: responseData)

updateSuccess!(jsonResponse)

print("success:", jsonResponse)
} catch {
print("error deserializing", error)
}
}

public func onFailure(_ error: Any) {
print(error)
if let updateFailure = updateFailure {
updateFailure()
return
}
print("onfailure", error)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright (c) 2022 Skyflow
*/

import Foundation
import Skyflow

public class ExampleTokenProvider: TokenProvider {
public func getBearerToken(_ apiCallback: Skyflow.Callback) {
if let url = URL(string: "<YOUR_TOKEN_PROVIDER_ENDPOINT>") {
let session = URLSession(configuration: .default)
let task = session.dataTask(with: url) { data, _, error in
if error != nil {
print(error!)
return
}
if let safeData = data {
do {
let x = try JSONSerialization.jsonObject(with: safeData, options: []) as? [String: String]
if let accessToken = x?["accessToken"] {
apiCallback.onSuccess(accessToken)
}
} catch {
print("access token wrong format")
}
}
}
task.resume()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class ViewController: UIViewController {
textAlignment: .left,
textColor: .blue
)
let focusStyle = Skyflow.Style(borderColor: .blue) ̰
let focusStyle = Skyflow.Style(borderColor: .blue)
let completedStyle = Skyflow.Style(borderColor: UIColor.green, textColor: UIColor.green)
let invalidStyle = Skyflow.Style(borderColor: UIColor.red, textColor: UIColor.red)
let styles = Skyflow.Styles(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
965D96070B64549FC9188C80 /* ExampleTokenProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C27061F816370F5D626963B /* ExampleTokenProvider.swift */; };
F1030006274E0A0D008F614B /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1030005274E0A0D008F614B /* AppDelegate.swift */; };
F1030008274E0A0D008F614B /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1030007274E0A0D008F614B /* SceneDelegate.swift */; };
F103000A274E0A0D008F614B /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1030009274E0A0D008F614B /* ViewController.swift */; };
Expand All @@ -16,6 +17,7 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
7C27061F816370F5D626963B /* ExampleTokenProvider.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = ExampleTokenProvider.swift; sourceTree = "<group>"; };
F1030002274E0A0D008F614B /* Validations.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Validations.app; sourceTree = BUILT_PRODUCTS_DIR; };
F1030005274E0A0D008F614B /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
F1030007274E0A0D008F614B /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -55,6 +57,7 @@
F103000E274E0A12008F614B /* Assets.xcassets */,
F1030010274E0A12008F614B /* LaunchScreen.storyboard */,
F1030013274E0A12008F614B /* Info.plist */,
7C27061F816370F5D626963B /* ExampleTokenProvider.swift */,
);
path = Validations;
sourceTree = "<group>";
Expand Down Expand Up @@ -140,6 +143,7 @@
F103000A274E0A0D008F614B /* ViewController.swift in Sources */,
F1030006274E0A0D008F614B /* AppDelegate.swift in Sources */,
F1030008274E0A0D008F614B /* SceneDelegate.swift in Sources */,
965D96070B64549FC9188C80 /* ExampleTokenProvider.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
26 changes: 0 additions & 26 deletions Skyflow/Samples/Validations/Validations/ExampleAPICallback.swift

This file was deleted.

26 changes: 0 additions & 26 deletions Skyflow/Samples/Validations/Validations/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ class ViewController: UIViewController {
private var skyflowClient: Skyflow.Client?
private var container: Skyflow.Container<Skyflow.CollectContainer>?
private var b: UIButton?
private var confirmPasswordElement: Skyflow.TextField?

private var stackView: UIStackView!

override func loadView() {
Expand Down Expand Up @@ -99,15 +97,9 @@ class ViewController: UIViewController {
validations: ValidationSet(rules: [strongPasswordRule, lengthRule, elementValueMatchRule])
)
let confirmPassword = container?.create(input: confirmPasswordInput, options: collectElementOptions)
self.confirmPasswordElement = confirmPassword
// mount elements on screen - errors will be shown if any of the validaitons fail
stackView.addArrangedSubview(password!)
stackView.addArrangedSubview(confirmPassword!)
let resetButton = UIButton(frame: CGRect(x: 100, y: 400, width: 100, height: 40))
resetButton.backgroundColor = .blue
resetButton.setTitle("Reset Password", for: .normal)
resetButton.addTarget(self, action: #selector(resetPassword), for: .touchUpInside)
stackView.addArrangedSubview(resetButton)
stackView.axis = .vertical
stackView.distribution = .fill
stackView.spacing = 10
Expand All @@ -119,22 +111,4 @@ class ViewController: UIViewController {
stackView.rightAnchor.constraint(equalTo: self.view.rightAnchor, constant: -10).isActive = true
}
}

@objc func resetPassword() {
let url = ""
let requestHeaders = ["Content-Type": "application/json ", "Authorization": ""]
let requestBody: [String: Any] = [
// Other fields...
"password": self.confirmPasswordElement!
]
let responseBody: [String: Any] = [:]
let connectionConfig = ConnectionConfig(
connectionURL: url,
method: .POST,
requestBody: requestBody,
requestHeader: requestHeaders,
responseBody: responseBody
)
self.skyflowClient?.invokeConnection(config: connectionConfig, callback: ExampleAPICallback())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
6CAC82BEF157325DE8024E2E /* libPods-CollectAndRevealSample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7F5C5B124A49D66E3C560B0D /* libPods-CollectAndRevealSample.a */; };
7C2C89D82C89C9520076C641 /* CardBrandChoiceSampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C2C89D72C89C9520076C641 /* CardBrandChoiceSampleViewController.swift */; };
7C2C89DE2C8F23C30076C641 /* CollectAndRevealViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C2C89DD2C8F23C30076C641 /* CollectAndRevealViewController.swift */; };
7C2C89E52C8F25C50076C641 /* libSkyflow.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7C2C89E42C8F25C50076C641 /* libSkyflow.a */; };
F1613E50272565CF0042C130 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1613E4F272565CF0042C130 /* AppDelegate.swift */; };
F1613E52272565CF0042C130 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1613E51272565CF0042C130 /* SceneDelegate.swift */; };
F1613E54272565CF0042C130 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1613E53272565CF0042C130 /* ViewController.swift */; };
Expand All @@ -24,8 +23,6 @@
267485426163B1ACCD8ED25D /* Pods-CollectAndRevealSample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CollectAndRevealSample.debug.xcconfig"; path = "Target Support Files/Pods-CollectAndRevealSample/Pods-CollectAndRevealSample.debug.xcconfig"; sourceTree = "<group>"; };
7C2C89D72C89C9520076C641 /* CardBrandChoiceSampleViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CardBrandChoiceSampleViewController.swift; sourceTree = "<group>"; };
7C2C89DD2C8F23C30076C641 /* CollectAndRevealViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollectAndRevealViewController.swift; sourceTree = "<group>"; };
7C2C89E22C8F25BC0076C641 /* libSkyflow.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libSkyflow.a; sourceTree = BUILT_PRODUCTS_DIR; };
7C2C89E42C8F25C50076C641 /* libSkyflow.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libSkyflow.a; sourceTree = BUILT_PRODUCTS_DIR; };
7F5C5B124A49D66E3C560B0D /* libPods-CollectAndRevealSample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-CollectAndRevealSample.a"; sourceTree = BUILT_PRODUCTS_DIR; };
F1613E4C272565CF0042C130 /* CollectAndRevealSample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CollectAndRevealSample.app; sourceTree = BUILT_PRODUCTS_DIR; };
F1613E4F272565CF0042C130 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
Expand All @@ -44,7 +41,6 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
7C2C89E52C8F25C50076C641 /* libSkyflow.a in Frameworks */,
6CAC82BEF157325DE8024E2E /* libPods-CollectAndRevealSample.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -55,8 +51,6 @@
A94C3CD833597CC577C83A7A /* Frameworks */ = {
isa = PBXGroup;
children = (
7C2C89E42C8F25C50076C641 /* libSkyflow.a */,
7C2C89E22C8F25BC0076C641 /* libSkyflow.a */,
7F5C5B124A49D66E3C560B0D /* libPods-CollectAndRevealSample.a */,
);
name = Frameworks;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class CardBrandChoiceSampleViewController: UIViewController {
let iconStyles = SkyflowFlowVault.Styles(base: Style(cardIconAlignment: .right))

// create card number element
let collectCardNumberInput = SkyflowFlowVault.CollectElementInput(table: "<TABLE_NAME>", column: "<COLUMN_NAME>", inputStyles: inputStyles, iconStyles: Styles(base: Style(cardIconAlignment: .right)),label: "Card Number", placeholder: "XXXXXXXXXXXXX", type: SkyflowFlowVault.ElementType.CARD_NUMBER)
let collectCardNumberInput = SkyflowFlowVault.CollectElementInput(tableName: "<TABLE_NAME>", column: "<COLUMN_NAME>", inputStyles: inputStyles, iconStyles: Styles(base: Style(cardIconAlignment: .right)),label: "Card Number", placeholder: "XXXXXXXXXXXXX", type: SkyflowFlowVault.ElementType.CARD_NUMBER)
let requiredOption = SkyflowFlowVault.CollectElementOptions(required: true, enableCardIcon: true, enableCopy: false)

collectCardNumberElement = container?.create(input: collectCardNumberInput, options: requiredOption)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ class CollectAndRevealViewController: UIViewController {
private var skyflow: SkyflowFlowVault.Client?
private var container: SkyflowFlowVault.Container<SkyflowFlowVault.CollectContainer>?
private var revealContainer: SkyflowFlowVault.Container<SkyflowFlowVault.RevealContainer>?
private var b: UIButton?

private var stackView: UIStackView!

Expand All @@ -23,7 +22,6 @@ class CollectAndRevealViewController: UIViewController {

private var revealed = false


override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .white
Expand Down Expand Up @@ -67,39 +65,39 @@ class CollectAndRevealViewController: UIViewController {
)

let collectCardNumberInput = SkyflowFlowVault.CollectElementInput(
table: "credit_cards",
tableName: "credit_cards",
column: "card_number",
inputStyles: styles,
label: "Card Number",
placeholder: "4111-1111-1111-1111",
type: SkyflowFlowVault.ElementType.CARD_NUMBER
)
let collectNameInput = SkyflowFlowVault.CollectElementInput(
table: "credit_cards",
tableName: "credit_cards",
column: "cardholder_name",
inputStyles: styles,
label: "Card Holder Name",
placeholder: "John Doe",
type: SkyflowFlowVault.ElementType.CARDHOLDER_NAME
)
let collectCVVInput = SkyflowFlowVault.CollectElementInput(
table: "credit_cards",
tableName: "credit_cards",
column: "cvv",
inputStyles: styles,
label: "CVV",
placeholder: "***",
type: .CVV
)
let collectExpMonthInput = SkyflowFlowVault.CollectElementInput(
table: "credit_cards",
tableName: "credit_cards",
column: "expiry_month",
inputStyles: styles,
label: "Expiration Month",
placeholder: "MM",
type: .EXPIRATION_MONTH
)
let collectExpYearInput = SkyflowFlowVault.CollectElementInput(
table: "credit_cards",
tableName: "credit_cards",
column: "expiry_year",
inputStyles: styles,
label: "Expiration Year",
Expand Down Expand Up @@ -157,7 +155,10 @@ class CollectAndRevealViewController: UIViewController {
callback: RevealCallback(
onSuccess: { (response: RevealResponse) in print("success:", response) },
onFailure: { (error: SkyflowError) in print("failure:", error) }
)
),
options: SkyflowFlowVault.RevealOptions(tokenGroupRedactions: [
SkyflowFlowVault.TokenGroupRedaction(tokenGroupName: "<TOKEN_GROUP_NAME>", redaction: "<REDACTION_TYPE>")
])
)
}
@objc func submitForm() {
Expand All @@ -166,7 +167,7 @@ class CollectAndRevealViewController: UIViewController {
onSuccess: { [weak self] (response: CollectResponse) in self?.updateSuccess(response) },
onFailure: { [weak self] (error: SkyflowError) in self?.updateFailure(error: error) }
),
options: SkyflowFlowVault.CollectOptions(tokens: true)
options: SkyflowFlowVault.CollectOptions()
)
}
internal func updateSuccess(_ response: CollectResponse) {
Expand Down Expand Up @@ -208,8 +209,7 @@ class CollectAndRevealViewController: UIViewController {
let revealCardNumberInput = SkyflowFlowVault.RevealElementInput(
token: token(for: "card_number"),
inputStyles: revealStyles,
label: "Card Number",
redaction: .REDACTED
label: "Card Number"
)
self.revealCardNumber = self.revealContainer?.create(
input: revealCardNumberInput,
Expand All @@ -218,23 +218,19 @@ class CollectAndRevealViewController: UIViewController {
let revealCVVtInput = SkyflowFlowVault.RevealElementInput(
token: token(for: "cvv"),
inputStyles: revealStyles,
label: "CVV",
redaction: .MASKED
label: "CVV"
)
self.revealCVV = self.revealContainer?.create(input: revealCVVtInput)
let revealNameInput = SkyflowFlowVault.RevealElementInput(
token: token(for: "cardholder_name"),
inputStyles: revealStyles,
label: "Card Holder Name",
redaction: .DEFAULT

label: "Card Holder Name"
)
self.revealName = self.revealContainer?.create(input: revealNameInput)
let revealExpirationMonthInput = SkyflowFlowVault.RevealElementInput(
token: token(for: "expiry_month"),
inputStyles: revealStyles,
label: "Expiration Month",
redaction: .PLAIN_TEXT
label: "Expiration Month"
)
self.revealExpirationMonth = self.revealContainer?.create(input: revealExpirationMonthInput)
let revealExpirationYearInput = SkyflowFlowVault.RevealElementInput(
Expand Down
Loading
Loading