Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop -> Master (SonarCloud Warnings Fixes) #295

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
6 changes: 3 additions & 3 deletions OmiseSDK/Resources/Assets.xcassets/Credit Card/Contents.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
"author" : "xcode",
"version" : 1
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images": [
{
"filename": "Discover.pdf",
"idiom": "universal"
}
],
"info": {
"author": "xcode",
"version": 1
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images": [
{
"filename": "UnionPay.pdf",
"idiom": "universal"
}
],
"info": {
"author": "xcode",
"version": 1
}
}
Binary file not shown.
30 changes: 18 additions & 12 deletions OmiseSDK/Sources/3DS/NetceteraThreeDSController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@
key: decryptionKey
)

// swiftlint:disable:next non_optional_string_data_conversion
if let apiKey = String(data: encrypted, encoding: .utf8) {

Check failure on line 108 in OmiseSDK/Sources/3DS/NetceteraThreeDSController.swift

View workflow job for this annotation

GitHub Actions / lint

Superfluous Disable Command Violation: SwiftLint rule 'non_optional_string_data_conversion' did not trigger a violation in the disabled region; remove the disable command (superfluous_disable_command)

Check failure on line 108 in OmiseSDK/Sources/3DS/NetceteraThreeDSController.swift

View workflow job for this annotation

GitHub Actions / lint

Superfluous Disable Command Violation: SwiftLint rule 'non_optional_string_data_conversion' did not trigger a violation in the disabled region; remove the disable command (superfluous_disable_command)
return apiKey
} else {
throw Errors.apiKeyInvalid
Expand Down Expand Up @@ -148,7 +149,6 @@
ThreeDSSDKAppDelegate.shared.appOpened(url: url)
}

// swiftlint:disable:next function_body_length
func processAuthorizedURL(
_ authorizeUrl: URL,
threeDSRequestorAppURL: String?,
Expand Down Expand Up @@ -186,18 +186,8 @@
return
}

switch response.status {
case .success:
onComplete(.success(()))
guard !Self.processAuthenticationResponse(response, onComplete: onComplete) else {
return
case .failed:
onComplete(.failure(NetceteraThreeDSController.Errors.authResStatusFailed))
return
case .unknown:
onComplete(.failure(NetceteraThreeDSController.Errors.authResStatusUnknown(response.serverStatus)))
return
case .challenge:
break
}

DispatchQueue.main.async {
Expand All @@ -221,6 +211,22 @@
}
}

static func processAuthenticationResponse(_ response: AuthResponse, onComplete: ((Result<Void, Error>) -> Void)) -> Bool {
switch response.status {
case .success:
onComplete(.success(()))
return true
case .failed:
onComplete(.failure(NetceteraThreeDSController.Errors.authResStatusFailed))
return true
case .unknown:
onComplete(.failure(NetceteraThreeDSController.Errors.authResStatusUnknown(response.serverStatus)))
return true
case .challenge:
return false
}
}

func prepareChallengeParameters(
aRes: AuthResponse.ARes,
threeDSRequestorAppURL: String?
Expand Down
13 changes: 10 additions & 3 deletions OmiseSDK/Sources/Models/CardBrand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public enum CardBrand: String, CustomStringConvertible, Codable {
case laser = "Laser"
/// Maestro card newtwork brand
case maestro = "Maestro"
/// UnionPay card network brand
case unionPay = "UnionPay"
/// Discover card newtwork brand
case discover = "Discover"

Expand All @@ -28,7 +30,8 @@ public enum CardBrand: String, CustomStringConvertible, Codable {
diners,
laser,
maestro,
discover
discover,
unionPay
]

/// Regular expression pattern that can detect cards issued by the brand.
Expand All @@ -48,8 +51,10 @@ public enum CardBrand: String, CustomStringConvertible, Codable {
return "^(6304|670[69]|6771)"
case .maestro:
return "^(5[0,6-8]|6304|6759|676[1-3])"
case .unionPay:
return "^62\\d{14,17}$"
case .discover:
return "^(6011|622(12[6-9]|1[3-9][0-9]|[2-8][0-9]{2}|9[0-1][0-9]|92[0-5]|64[4-9])|65)"
return "^(6011\\d{12,15}|65\\d{14,17}|64[4-9]\\d{13,16}|6221[2-9]\\d{11,14}|622[3-9]\\d{12,15})$"
}
}

Expand All @@ -70,8 +75,10 @@ public enum CardBrand: String, CustomStringConvertible, Codable {
return 16...19
case .maestro:
return 12...19
case .unionPay:
return 16...19
case .discover:
return 16...16
return 16...19
}
}

Expand Down
Loading
Loading