-
-
Notifications
You must be signed in to change notification settings - Fork 690
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Joseph Mattiello <[email protected]> Signed-off-by: Joseph Mattello <[email protected]> patreon: move to pvlib Signed-off-by: Joseph Mattello <[email protected]>
- Loading branch information
Showing
7 changed files
with
777 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
// | ||
// Keychain.swift | ||
// AltStore | ||
// | ||
// Created by Riley Testut on 6/4/19. | ||
// Copyright © 2019 Riley Testut. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import KeychainAccess | ||
|
||
//import AltSign | ||
|
||
@propertyWrapper | ||
public struct KeychainItem<Value> | ||
{ | ||
public let key: String | ||
|
||
public var wrappedValue: Value? { | ||
get { | ||
switch Value.self | ||
{ | ||
case is Data.Type: return try? Keychain.shared.keychain.getData(self.key) as? Value | ||
case is String.Type: return try? Keychain.shared.keychain.getString(self.key) as? Value | ||
default: return nil | ||
} | ||
} | ||
set { | ||
switch Value.self | ||
{ | ||
case is Data.Type: Keychain.shared.keychain[data: self.key] = newValue as? Data | ||
case is String.Type: Keychain.shared.keychain[self.key] = newValue as? String | ||
default: break | ||
} | ||
} | ||
} | ||
|
||
public init(key: String) | ||
{ | ||
self.key = key | ||
} | ||
} | ||
|
||
public class Keychain | ||
{ | ||
public static let shared = Keychain() | ||
|
||
fileprivate let keychain = KeychainAccess.Keychain(service: "org.provenance-emu.provenance").accessibility(.afterFirstUnlock).synchronizable(true) | ||
|
||
// @KeychainItem(key: "appleIDEmailAddress") | ||
// public var appleIDEmailAddress: String? | ||
// | ||
// @KeychainItem(key: "appleIDPassword") | ||
// public var appleIDPassword: String? | ||
// | ||
// @KeychainItem(key: "signingCertificatePrivateKey") | ||
// public var signingCertificatePrivateKey: Data? | ||
// | ||
// @KeychainItem(key: "signingCertificateSerialNumber") | ||
// public var signingCertificateSerialNumber: String? | ||
// | ||
// @KeychainItem(key: "signingCertificate") | ||
// public var signingCertificate: Data? | ||
// | ||
// @KeychainItem(key: "signingCertificatePassword") | ||
// public var signingCertificatePassword: String? | ||
|
||
@KeychainItem(key: "patreonAccessToken") | ||
public var patreonAccessToken: String? | ||
|
||
@KeychainItem(key: "patreonRefreshToken") | ||
public var patreonRefreshToken: String? | ||
|
||
@KeychainItem(key: "patreonCreatorAccessToken") | ||
public var patreonCreatorAccessToken: String? | ||
|
||
@KeychainItem(key: "patreonAccountID") | ||
public var patreonAccountID: String? | ||
|
||
private init() | ||
{ | ||
} | ||
|
||
public func reset() | ||
{ | ||
// self.appleIDEmailAddress = nil | ||
// self.appleIDPassword = nil | ||
// self.signingCertificatePrivateKey = nil | ||
// self.signingCertificateSerialNumber = nil | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// | ||
// Benefit.swift | ||
// AltStore | ||
// | ||
// Created by Riley Testut on 8/21/19. | ||
// Copyright © 2019 Riley Testut. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
public enum PVPatreonBenefitType: String { | ||
case betaAccess = "7585304" | ||
case credit = "8490206" | ||
} | ||
|
||
@available(iOS 12.0, tvOS 12.0, *) | ||
extension PatreonAPI | ||
{ | ||
struct BenefitResponse: Decodable | ||
{ | ||
var id: String | ||
} | ||
} | ||
|
||
@available(iOS 12.0, tvOS 12.0, *) | ||
public struct Benefit: Hashable | ||
{ | ||
public var type: PVPatreonBenefitType | ||
|
||
init?(response: PatreonAPI.BenefitResponse) | ||
{ | ||
guard let type = PVPatreonBenefitType(rawValue: response.id) else { | ||
ELOG("Unknown benefit id \(response.id)") | ||
return nil | ||
} | ||
self.type = type | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// | ||
// Campaign.swift | ||
// AltStore | ||
// | ||
// Created by Riley Testut on 8/21/19. | ||
// Copyright © 2019 Riley Testut. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
@available(iOS 12.0, tvOS 12.0, *) | ||
extension PatreonAPI | ||
{ | ||
struct CampaignResponse: Decodable | ||
{ | ||
var id: String | ||
} | ||
} | ||
|
||
@available(iOS 12.0, tvOS 12.0, *) | ||
public struct Campaign | ||
{ | ||
public var identifier: String | ||
|
||
init(response: PatreonAPI.CampaignResponse) | ||
{ | ||
self.identifier = response.id | ||
} | ||
} |
Oops, something went wrong.