This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Quickly and dirty generatte EC256 Key Pair, export as base64 Data/String, and then import from base64 Data/String. | |
// Perfect when you need an in-memory key pair for mocks/unit testing. | |
// | |
import CryptoKit | |
// Generate EC256 Key Pair and export as base64 String/Data | |
let attributes = [ | |
kSecAttrKeyType as String: kSecAttrKeyTypeECSECPrimeRandom, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
public extension URLRequest { | |
var curlRepresentation: String { | |
guard let url = url?.absoluteString else { | |
return "could not create curl command" | |
} | |
var components = ["curl \(url)"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
/// A general storage for data required to be backed by a secure storage. | |
public protocol SecureDataStorage { | |
func string(for key: String) throws -> String? | |
func set(_ string: String, for key: String) throws | |
func value<Value: Decodable>(for key: String) throws -> Value? | |
func set<Value: Encodable>(_ value: Value, for key: String) throws | |
func data(for key: String) throws -> Data? | |
func set(_ data: Data, for key: String) throws |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
/// A general storage for Cryptographic Key Pairs generated on device. | |
/// | |
/// The generated and stored keys are protected by Secure Enclave, | |
/// hence only NIST P-256 elliptic curve key pairs are supported. | |
/// | |
/// These keys can only be used for creating and verifying cryptographic signatures, or for elliptic curve Diffie-Hellman key exchange (and by extension, symmetric encryption). | |
public protocol CryptographicKeyStorageProtocol { | |
/// Generate a NIST P-256 elliptic curve key pair. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// DefaultHTTPClient+HTTPClient.swift | |
// | |
import Foundation | |
/// A context for interceptors to get a hold on the ``URLSession``, ``JSONEncoder`` and ``JSONDecoder`` the associated ``HTTPClient`` uses. | |
/// | |
/// These properties can be used to decode/encode or do intermediate network request before/after outgoing network request. | |
public struct HTTPClientContext { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// AppInfoProvider.swift | |
// | |
import Foundation | |
protocol AppInfoProvider: AnyObject { | |
var bundleDisplayName: String { get } // Your app's name. | |
var bundleVersion: String { get } // The current build number, e.g 137 | |
var bundleShortVersionString: String { get } // The current app version, e.g 1.2.0. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# Find all project.pbxproj files with staged changes and make sure they do not specify any DEVELOPMENT_TEAM. | |
matches=$(git grep --cached -E -o 'DEVELOPMENT_TEAM = .{3,};$') | |
if [ ! -z "${matches}" ]; then | |
echo "One or more project files specify DEVELOPMENT_TEAM:" | |
echo "$matches" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ScrollableContentViewController.swift | |
// | |
import UIKit | |
class ScrollableContentViewController: UIViewController { | |
private lazy var scrollView: UIScrollView = { | |
let scrollView = UIScrollView() | |
scrollView.translatesAutoresizingMaskIntoConstraints = false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// KeyboardAvoidanceViewController.swift | |
// | |
import UIKit | |
class KeyboardAvoidanceViewController: UIViewController { | |
private lazy var scrollView: UIScrollView = { | |
let scrollView = UIScrollView() | |
scrollView.translatesAutoresizingMaskIntoConstraints = false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
/// Simple wrapper enum for decoding JSON with optional or unknown/shifting values. | |
/// | |
/// If decoding of the Value type fails, the value is decoded as a string. | |
/// | |
/// ```swift | |
/// enum State { case idle; case running; case stopped } | |
/// try JSONDecoder().decode(ValueOrUnknown<State>.self, from: "waiting") // == .unknown("waiting") | |
/// ``` |