Skip to content

Commit

Permalink
Add some demo code
Browse files Browse the repository at this point in the history
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
JoeMatt committed Dec 16, 2022
1 parent 3fbc4ac commit fc1f208
Show file tree
Hide file tree
Showing 7 changed files with 777 additions and 0 deletions.
91 changes: 91 additions & 0 deletions PVLibrary/PVLibrary/Keychain/Keychain.swift
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
}
}
38 changes: 38 additions & 0 deletions PVLibrary/PVLibrary/Patreon/Benefit.swift
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
}
}
29 changes: 29 additions & 0 deletions PVLibrary/PVLibrary/Patreon/Campaign.swift
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
}
}
Loading

0 comments on commit fc1f208

Please sign in to comment.