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

Re-enable linter rules #26

Merged
merged 3 commits into from
Aug 13, 2024
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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ Derived/
DerivedData/
.swiftpm/configuration/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.swiftpm/xcode/xcshareddata/xcschemes/SpruceIDMobileSdk.xcscheme
.netrc
WalletSdk.xcodeproj
MobileSdk.xcodeproj
build/
*~
Info.plist
12 changes: 0 additions & 12 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
excluded:
- .build
disabled_rules:
- colon
- cyclomatic_complexity
- todo
- force_cast

identifier_name:
min_length: 1

line_length:
warning: 200
error: 250
ignores_function_declarations: true
ignores_comments: true
ignores_urls: true
24 changes: 0 additions & 24 deletions Info.plist

This file was deleted.

12 changes: 7 additions & 5 deletions Sources/MobileSdk/KeyManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ public class KeyManager: NSObject {

guard status == errSecSuccess else { return nil }

// swiftlint:disable force_cast
let key = item as! SecKey
// swiftlint:enable force_cast

return key
}
Expand Down Expand Up @@ -103,14 +105,14 @@ public class KeyManager: NSObject {
let xDataRaw: Data = fullData.subdata(in: 0..<32)
let yDataRaw: Data = fullData.subdata(in: 32..<64)

let x = xDataRaw.base64EncodedUrlSafe
let y = yDataRaw.base64EncodedUrlSafe
let xCoordinate = xDataRaw.base64EncodedUrlSafe
let yCoordinate = yDataRaw.base64EncodedUrlSafe

let jsonObject: [String: Any] = [
"kty": "EC",
"crv": "P-256",
"x": x,
"y": y
"x": xCoordinate,
"y": yCoordinate
]

guard let jsonData = try? JSONSerialization.data(withJSONObject: jsonObject, options: []) else { return nil }
Expand Down Expand Up @@ -206,7 +208,7 @@ public class KeyManager: NSObject {
/**
* Decrypts the provided payload by a key id and initialization vector.
*/
public static func decryptPayload(id: String, iv: [UInt8], payload: [UInt8]) -> [UInt8]? {
public static func decryptPayload(id: String, payload: [UInt8]) -> [UInt8]? {
guard let key = getSecretKey(id: id) else { return nil }

guard let data = CFDataCreate(kCFAllocatorDefault, payload, payload.count) else {
Expand Down
5 changes: 3 additions & 2 deletions Sources/MobileSdk/PlatformContext.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// File: PlatformContext
//
// Store and retrieve sensitive data. Data is stored in the Application Support directory of the app, encrypted in place
// via the .completeFileProtection option, and marked as excluded from backups so it will not be included in iCloud backps.
// Store and retrieve sensitive data. Data is stored in the Application Support directory of the app, encrypted in
// place via the .completeFileProtection option, and marked as excluded from backups so it will not be included in
// iCloud backups.

//
// Imports
Expand Down
23 changes: 12 additions & 11 deletions Sources/MobileSdk/StorageManager.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// File: Storage Manager
//
// Store and retrieve sensitive data. Data is stored in the Application Support directory of the app, encrypted in place
// via the .completeFileProtection option, and marked as excluded from backups so it will not be included in iCloud backps.
// Store and retrieve sensitive data. Data is stored in the Application Support directory of the app, encrypted in
// place via the .completeFileProtection option, and marked as excluded from backups so it will not be included in
// iCloud backps.

//
// Imports
Expand All @@ -18,8 +19,8 @@ import Foundation

class StorageManager: NSObject {
// Local-Method: path()
// Get the path to the application support dir, appending the given file name to it. We use the application support
// directory because its contents are not shared.
// Get the path to the application support dir, appending the given file name to it. We use the application
// support directory because its contents are not shared.
//
// Arguments:
// file - the name of the file
Expand All @@ -29,13 +30,13 @@ class StorageManager: NSObject {

private func path(file: String) -> URL? {
do {
// Get the applications support dir, and tack the name of the thing we're storing on the end of it. This does
// imply that `file` should be a valid filename.
// Get the applications support dir, and tack the name of the thing we're storing on the end of it.
// This does imply that `file` should be a valid filename.

let asdir = try FileManager.default.url(for: .applicationSupportDirectory,
in: .userDomainMask,
let asdir = try FileManager.default.url(for: .applicationSupportDirectory,
in: .userDomainMask,
appropriateFor: nil, // Ignored
create: true) // May not exist, make if necessary.
create: true) // May not exist, make if necessary.

return asdir.appendingPathComponent(file)
} catch { // Did the attempt to get the application support dir fail?
Expand Down Expand Up @@ -80,8 +81,8 @@ class StorageManager: NSObject {
guard let file = path(file: key) else { return nil }

do {
let d = try Data(contentsOf: file)
return d
let data = try Data(contentsOf: file)
return data
} catch {
print("Failed to read '\(file)'.")
}
Expand Down
3 changes: 1 addition & 2 deletions Sources/MobileSdk/ui/QRCodeScanner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,7 @@ public struct QRCodeScanner: View {

public var body: some View {
ZStack(alignment: .top) {
GeometryReader {
let viewSize = $0.size
GeometryReader {_ in
let size = UIScreen.screenSize
ZStack {
CameraView(frameSize: CGSize(width: size.width, height: size.height), session: $session)
Expand Down
2 changes: 2 additions & 0 deletions Tests/MobileSdkTests/DataConversions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ final class DataConversions: XCTestCase {
let base64 = sampleData.base64EncodedUrlSafe

// Generated independently
// swiftlint:disable line_length
let expectedBase64String = "QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVowMTIzNDU2Nzg5Ky89K0FCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWFlaMDEyMzQ1Njc4OSsvPQ"
// swiftlint:enable line_length

XCTAssertEqual(base64, expectedBase64String)
}
Expand Down
1 change: 1 addition & 0 deletions project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ targets:
path: Info.plist
properties:
NSBluetoothAlwaysUsageDescription: "Secure transmission of mobile DL data"
NSCameraUsageDescription: "QR Code Scanner"
buildToolPlugins:
- plugin: SwiftLintPlugin
package: SwiftLint
Expand Down
Loading