Skip to content

Instantly share code, notes, and snippets.

View wesmatlock's full-sized avatar

Wes Matlock wesmatlock

View GitHub Profile
@wesmatlock
wesmatlock / NetworkSecurityManager.swift
Created October 28, 2025 14:38
NetworkSecurityManager.swift
import Foundation
import CryptoKit
import Network
public final class NetworkSecurityManager {
public static let shared = NetworkSecurityManager()
private let monitor = NWPathMonitor()
private let queue = DispatchQueue(label: "NetworkMonitor")
@wesmatlock
wesmatlock / SecureStorageManager.swift
Created October 28, 2025 14:29
SecureStorageManager
import Foundation
import CryptoKit
import LocalAuthentication
public final class SecureStorageManager {
public static let shared = SecureStorageManager()
private let keychainService = "com.flightbooking.secure"
private let encryptionKey = SymmetricKey(size: .bits256)
@wesmatlock
wesmatlock / CertificatePinner.swift
Created October 28, 2025 14:27
CertificatePinner
import Foundation
import CryptoKit
import CommonCrypto
public final class CertificatePinner: NSObject {
public static let shared = CertificatePinner()
private var pinnedCertificates: [String: [Data]] = [:]
private var pinnedPublicKeys: [String: [String]] = [:]
@wesmatlock
wesmatlock / RASPManager.swift
Created October 28, 2025 14:25
RASPManager
import Foundation
import CryptoKit
import UIKit
import os.log
import Darwin
public final class RASPManager {
public static let shared = RASPManager()
private let logger = Logger(subsystem: "com.app.security", category: "RASP")
@wesmatlock
wesmatlock / DeviceFingerprinter.swift
Created October 28, 2025 14:20
DeviceFingerprinter
import Foundation
import UIKit
import CryptoKit
import CoreTelephony
import AdSupport
import AppTrackingTransparency
import Network
public final class DeviceFingerprinter {
@wesmatlock
wesmatlock / JailbreakDetector.swift
Created October 28, 2025 14:09
JailbreakDetector
import Foundation
import UIKit
import Darwin
public final class JailbreakDetector {
public static let shared = JailbreakDetector()
private init() {}
@wesmatlock
wesmatlock / gist:b8c15d071043a05f83bd6364372a03f0
Created March 26, 2024 18:19
Swift Collections Safe Subscript
extension Collection {
/// Returns the element at the specified index if it exists, otherwise nil.
subscript (safe index: Index) -> Element? {
return indices.contains(index) ? self[index] : nil
}
}
@wesmatlock
wesmatlock / URLSession+decodeJson.swift
Last active March 19, 2021 11:36
URLSession extension to easily decode JSON files.
extension URLSession {
func decodeJson <T:Decodable> (_ type: T.Type , urlString: String ,
completion: @escaping (Result<T, Error>)->Void,
dateDecodingStrategy: JSONDecoder.DateDecodingStrategy = .deferredToDate,
keyDecodingStrategy: JSONDecoder.KeyDecodingStrategy = .useDefaultKeys) {
guard let url = URL(string: urlString) else { return }
let task = self.dataTask(with: url, completionHandler: { data, response, error in
@wesmatlock
wesmatlock / Bundle+decodeJson.swift
Last active March 19, 2021 11:30
Bundle extension to decode json bundled with the app.
extension Bundle {
func decodeJson <T:Decodable> (_ type: T.Type , fileName: String,
dateDecodingStrategy: JSONDecoder.DateDecodingStrategy = .deferredToDate,
keyDecodingStrategy: JSONDecoder.KeyDecodingStrategy = .useDefaultKeys) -> T {
guard let url = self.url(forResource: fileName, withExtension: nil) else {
fatalError("Failed to load file ") // Handle for production code.
}
do {
@wesmatlock
wesmatlock / GitCommitEmoji.md
Last active March 11, 2020 12:48 — forked from parmentf/GitCommitEmoji.md
Git Commit message Emoji
Commit type Emoji
Initial commit 🎉 :tada:
Version tag 🔖 :bookmark:
Ship/Relesse :shipit: :shipit:
New feature :sparkles:
Bugfix 🐛 :bug:
Metadata 📇 :card_index:
Documentation 📚 :books:
Documenting source code 💡 :bulb: