Skip to content

Commit 8e8d6d4

Browse files
committed
Add some demo code
Signed-off-by: Joseph Mattiello <[email protected]>
1 parent 1f0ed65 commit 8e8d6d4

File tree

10 files changed

+933
-63
lines changed

10 files changed

+933
-63
lines changed

PVSupport/Keychain/Keychain.swift

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
//
2+
// Keychain.swift
3+
// AltStore
4+
//
5+
// Created by Riley Testut on 6/4/19.
6+
// Copyright © 2019 Riley Testut. All rights reserved.
7+
//
8+
9+
import Foundation
10+
import KeychainAccess
11+
12+
//import AltSign
13+
14+
@propertyWrapper
15+
public struct KeychainItem<Value>
16+
{
17+
public let key: String
18+
19+
public var wrappedValue: Value? {
20+
get {
21+
switch Value.self
22+
{
23+
case is Data.Type: return try? Keychain.shared.keychain.getData(self.key) as? Value
24+
case is String.Type: return try? Keychain.shared.keychain.getString(self.key) as? Value
25+
default: return nil
26+
}
27+
}
28+
set {
29+
switch Value.self
30+
{
31+
case is Data.Type: Keychain.shared.keychain[data: self.key] = newValue as? Data
32+
case is String.Type: Keychain.shared.keychain[self.key] = newValue as? String
33+
default: break
34+
}
35+
}
36+
}
37+
38+
public init(key: String)
39+
{
40+
self.key = key
41+
}
42+
}
43+
44+
public class Keychain
45+
{
46+
public static let shared = Keychain()
47+
48+
fileprivate let keychain = KeychainAccess.Keychain(service: "org.provenance-emu.provenance").accessibility(.afterFirstUnlock).synchronizable(true)
49+
50+
// @KeychainItem(key: "appleIDEmailAddress")
51+
// public var appleIDEmailAddress: String?
52+
//
53+
// @KeychainItem(key: "appleIDPassword")
54+
// public var appleIDPassword: String?
55+
//
56+
// @KeychainItem(key: "signingCertificatePrivateKey")
57+
// public var signingCertificatePrivateKey: Data?
58+
//
59+
// @KeychainItem(key: "signingCertificateSerialNumber")
60+
// public var signingCertificateSerialNumber: String?
61+
//
62+
// @KeychainItem(key: "signingCertificate")
63+
// public var signingCertificate: Data?
64+
//
65+
// @KeychainItem(key: "signingCertificatePassword")
66+
// public var signingCertificatePassword: String?
67+
68+
@KeychainItem(key: "patreonAccessToken")
69+
public var patreonAccessToken: String?
70+
71+
@KeychainItem(key: "patreonRefreshToken")
72+
public var patreonRefreshToken: String?
73+
74+
@KeychainItem(key: "patreonCreatorAccessToken")
75+
public var patreonCreatorAccessToken: String?
76+
77+
private init()
78+
{
79+
}
80+
81+
public func reset()
82+
{
83+
// self.appleIDEmailAddress = nil
84+
// self.appleIDPassword = nil
85+
// self.signingCertificatePrivateKey = nil
86+
// self.signingCertificateSerialNumber = nil
87+
}
88+
}

PVSupport/PVSupport.xcodeproj/project.pbxproj

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,22 @@
190190
B3702312287256DA00B3F6DA /* retro_inline.h in Headers */ = {isa = PBXBuildFile; fileRef = B34DC6C02867202D00B60497 /* retro_inline.h */; settings = {ATTRIBUTES = (Public, ); }; };
191191
B372638426EA015700E95488 /* CocoaLumberjack+swift-log.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3296E8326C67F420088AC32 /* CocoaLumberjack+swift-log.swift */; };
192192
B372638526EA015800E95488 /* CocoaLumberjack+swift-log.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3296E8326C67F420088AC32 /* CocoaLumberjack+swift-log.swift */; };
193+
B3A29774270952D800DDBF37 /* Benefit.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3A2976F270952D800DDBF37 /* Benefit.swift */; };
194+
B3A29775270952D800DDBF37 /* Benefit.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3A2976F270952D800DDBF37 /* Benefit.swift */; };
195+
B3A29776270952D800DDBF37 /* PatreonAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3A29770270952D800DDBF37 /* PatreonAPI.swift */; };
196+
B3A29777270952D800DDBF37 /* PatreonAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3A29770270952D800DDBF37 /* PatreonAPI.swift */; };
197+
B3A29778270952D800DDBF37 /* Campaign.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3A29771270952D800DDBF37 /* Campaign.swift */; };
198+
B3A29779270952D800DDBF37 /* Campaign.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3A29771270952D800DDBF37 /* Campaign.swift */; };
199+
B3A2977A270952D800DDBF37 /* Patron.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3A29772270952D800DDBF37 /* Patron.swift */; };
200+
B3A2977B270952D800DDBF37 /* Patron.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3A29772270952D800DDBF37 /* Patron.swift */; };
201+
B3A2977C270952D800DDBF37 /* Tier.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3A29773270952D800DDBF37 /* Tier.swift */; };
202+
B3A2977D270952D800DDBF37 /* Tier.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3A29773270952D800DDBF37 /* Tier.swift */; };
203+
B3A2978027095C4200DDBF37 /* Keychain.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3A2977F27095C4200DDBF37 /* Keychain.swift */; };
204+
B3A2978127095C4200DDBF37 /* Keychain.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3A2977F27095C4200DDBF37 /* Keychain.swift */; };
205+
B3A2978427095CAC00DDBF37 /* KeychainAccess in Frameworks */ = {isa = PBXBuildFile; productRef = B3A2978327095CAC00DDBF37 /* KeychainAccess */; };
206+
B3A2978627095CB700DDBF37 /* KeychainAccess in Frameworks */ = {isa = PBXBuildFile; productRef = B3A2978527095CB700DDBF37 /* KeychainAccess */; };
207+
B3A297892709600400DDBF37 /* PatreonAccount.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3A297882709600400DDBF37 /* PatreonAccount.swift */; };
208+
B3A2978A2709600400DDBF37 /* PatreonAccount.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3A297882709600400DDBF37 /* PatreonAccount.swift */; };
193209
B392849128670348003BAC21 /* PVLibRetro.h in Headers */ = {isa = PBXBuildFile; fileRef = B392849028670348003BAC21 /* PVLibRetro.h */; settings = {ATTRIBUTES = (Public, ); }; };
194210
B3928499286703CD003BAC21 /* PVLibRetroCore.h in Headers */ = {isa = PBXBuildFile; fileRef = B3928497286703CD003BAC21 /* PVLibRetroCore.h */; settings = {ATTRIBUTES = (Public, ); }; };
195211
B392849A286703CD003BAC21 /* PVLibRetroCore.m in Sources */ = {isa = PBXBuildFile; fileRef = B3928498286703CD003BAC21 /* PVLibRetroCore.m */; };
@@ -1211,6 +1227,13 @@
12111227
B3532B3E21A7B753006CDA0F /* PVSettingsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PVSettingsTests.swift; sourceTree = "<group>"; };
12121228
B3532C3521A925C1006CDA0F /* SortOption.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SortOption.swift; sourceTree = "<group>"; };
12131229
B35E6C36207EE15D0040709A /* CoreOptions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CoreOptions.swift; sourceTree = "<group>"; };
1230+
B3A2976F270952D800DDBF37 /* Benefit.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Benefit.swift; sourceTree = "<group>"; };
1231+
B3A29770270952D800DDBF37 /* PatreonAPI.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PatreonAPI.swift; sourceTree = "<group>"; };
1232+
B3A29771270952D800DDBF37 /* Campaign.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Campaign.swift; sourceTree = "<group>"; };
1233+
B3A29772270952D800DDBF37 /* Patron.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Patron.swift; sourceTree = "<group>"; };
1234+
B3A29773270952D800DDBF37 /* Tier.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Tier.swift; sourceTree = "<group>"; };
1235+
B3A2977F27095C4200DDBF37 /* Keychain.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Keychain.swift; sourceTree = "<group>"; };
1236+
B3A297882709600400DDBF37 /* PatreonAccount.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PatreonAccount.swift; sourceTree = "<group>"; };
12141237
B36C41012898776C00EAEF59 /* libretro-netplay.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libretro-netplay.a"; sourceTree = BUILT_PRODUCTS_DIR; };
12151238
B36C41032898776C00EAEF59 /* retro_netplay.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = retro_netplay.h; sourceTree = "<group>"; };
12161239
B36C41042898776C00EAEF59 /* retro_netplay.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = retro_netplay.m; sourceTree = "<group>"; };
@@ -1340,6 +1363,7 @@
13401363
B324C3162191963B009F4EDC /* AVFoundation.framework in Frameworks */,
13411364
B3CA5B5126E9E4D500687B27 /* CocoaLumberjack in Frameworks */,
13421365
B3296E8926C67F6B0088AC32 /* CocoaLumberjackSwiftLogBackend in Frameworks */,
1366+
B3A2978627095CB700DDBF37 /* KeychainAccess in Frameworks */,
13431367
B3CEC5C3279521EC004A7CC1 /* NSLogger in Frameworks */,
13441368
B3AF6FDF219161C0000FA7F9 /* GameController.framework in Frameworks */,
13451369
B3AF6FDD219161BC000FA7F9 /* Foundation.framework in Frameworks */,
@@ -1358,6 +1382,7 @@
13581382
B3AF6FDA2191616C000FA7F9 /* Foundation.framework in Frameworks */,
13591383
B3CEC5C127952165004A7CC1 /* NSLogger in Frameworks */,
13601384
B3AF6FD821916168000FA7F9 /* GameController.framework in Frameworks */,
1385+
B3A2978427095CAC00DDBF37 /* KeychainAccess in Frameworks */,
13611386
B3296E8726C67F660088AC32 /* CocoaLumberjackSwiftLogBackend in Frameworks */,
13621387
B3FFF02D26E9E65800A33143 /* AVFoundation.framework in Frameworks */,
13631388
B336B8F126B3985B00960A81 /* CocoaLumberjackSwift in Frameworks */,
@@ -1379,6 +1404,17 @@
13791404
1ACEA63B17F7467D0031B1C9 = {
13801405
isa = PBXGroup;
13811406
children = (
1407+
B3A2978727095D0200DDBF37 /* Keychain */,
1408+
B3A2976E270952D800DDBF37 /* Patreon */,
1409+
B3CDEEB821D4C394000C55F7 /* EmulatorCore */,
1410+
B3447F99218C1CBE00557ACE /* Settings */,
1411+
B3AB37F721882119009D9244 /* CoreOptions */,
1412+
B3AB36DC2187F4C4009D9244 /* Controller */,
1413+
B302F89420B71C2300C5E502 /* Logging */,
1414+
1A4E718B1A6C693A005CA80F /* DebugUtils */,
1415+
1ACEA69017F748F80031B1C9 /* Audio */,
1416+
1ACEA64917F7467D0031B1C9 /* PVSupport */,
1417+
B3532B3321A7B736006CDA0F /* PVSupportTests */,
13821418
B3173802278419A2002D3ACD /* Build.xcconfig */,
13831419
B3A4FB58278FE2F200A65248 /* Sources */,
13841420
B3532B3321A7B736006CDA0F /* Tests */,
@@ -3449,6 +3485,27 @@
34493485
path = Sources;
34503486
sourceTree = "<group>";
34513487
};
3488+
B3A2976E270952D800DDBF37 /* Patreon */ = {
3489+
isa = PBXGroup;
3490+
children = (
3491+
B3A297882709600400DDBF37 /* PatreonAccount.swift */,
3492+
B3A2976F270952D800DDBF37 /* Benefit.swift */,
3493+
B3A29770270952D800DDBF37 /* PatreonAPI.swift */,
3494+
B3A29771270952D800DDBF37 /* Campaign.swift */,
3495+
B3A29772270952D800DDBF37 /* Patron.swift */,
3496+
B3A29773270952D800DDBF37 /* Tier.swift */,
3497+
);
3498+
path = Patreon;
3499+
sourceTree = "<group>";
3500+
};
3501+
B3A2978727095D0200DDBF37 /* Keychain */ = {
3502+
isa = PBXGroup;
3503+
children = (
3504+
B3A2977F27095C4200DDBF37 /* Keychain.swift */,
3505+
);
3506+
path = Keychain;
3507+
sourceTree = "<group>";
3508+
};
34523509
B3AB36DC2187F4C4009D9244 /* Controller */ = {
34533510
isa = PBXGroup;
34543511
children = (
@@ -3814,6 +3871,7 @@
38143871
B3B492CA26B3A96B000B426B /* Reachability */,
38153872
B3296E8826C67F6B0088AC32 /* CocoaLumberjackSwiftLogBackend */,
38163873
B3CA5B5026E9E4D500687B27 /* CocoaLumberjack */,
3874+
B3A2978527095CB700DDBF37 /* KeychainAccess */,
38173875
B3CEC5C2279521EC004A7CC1 /* NSLogger */,
38183876
);
38193877
productName = "PVSupportTV Framework";
@@ -3843,6 +3901,7 @@
38433901
B336B8F326B398A900960A81 /* Reachability */,
38443902
B3296E8626C67F660088AC32 /* CocoaLumberjackSwiftLogBackend */,
38453903
B3CA5B5226E9E4DC00687B27 /* CocoaLumberjack */,
3904+
B3A2978327095CAC00DDBF37 /* KeychainAccess */,
38463905
B3CEC5C027952165004A7CC1 /* NSLogger */,
38473906
);
38483907
productName = "PVSupportTV Framework";
@@ -3896,6 +3955,7 @@
38963955
packageReferences = (
38973956
B336B8EF26B3985B00960A81 /* XCRemoteSwiftPackageReference "CocoaLumberjack" */,
38983957
B336B8F226B398A900960A81 /* XCRemoteSwiftPackageReference "Reachability.swift" */,
3958+
B3A2978227095CAC00DDBF37 /* XCRemoteSwiftPackageReference "KeychainAccess" */,
38993959
B3CEC5BF27952163004A7CC1 /* XCRemoteSwiftPackageReference "NSLogger" */,
39003960
);
39013961
productRefGroup = 1ACEA64517F7467D0031B1C9 /* Products */;
@@ -4113,6 +4173,7 @@
41134173
B39C29CD27A10EE40078D028 /* OEGameAudio.m in Sources */,
41144174
B3AB37E421881A83009D9244 /* PViCadeGamepad.swift in Sources */,
41154175
B35E6C38207EE15D0040709A /* CoreOptions.swift in Sources */,
4176+
B3A2977B270952D800DDBF37 /* Patron.swift in Sources */,
41164177
B3AB37EC21881B7B009D9244 /* PViCade8BitdoController.swift in Sources */,
41174178
B3AB37DD21881869009D9244 /* PViCadeInputAxis.swift in Sources */,
41184179
B3296EA026C685450088AC32 /* DDLogLevel+CustomStringConvertable.swift in Sources */,
@@ -4142,21 +4203,28 @@
41424203
B33FB2EC279BE0CC0013AAD8 /* CoreOptions+Serialization.swift in Sources */,
41434204
B3FA5D661D6B90BD00060D71 /* PVEmulatorCore.m in Sources */,
41444205
B3447E8B218B7E4B00557ACE /* CARingBuffer.cpp in Sources */,
4206+
B3A29777270952D800DDBF37 /* PatreonAPI.swift in Sources */,
41454207
B3D73D401EA15BB20023925B /* NSFileManager+OEHashingAdditions.m in Sources */,
41464208
B3CDEEC021D4C41D000C55F7 /* DiscSwappable.swift in Sources */,
4209+
B3A2977D270952D800DDBF37 /* Tier.swift in Sources */,
41474210
B3F0846D2188CA7A00FF39EE /* CocoaLumberExtensions.swift in Sources */,
4211+
B3A2978127095C4200DDBF37 /* Keychain.swift in Sources */,
41484212
B3D0EE21277FE85F002DC0A5 /* HapticsManager.swift in Sources */,
41494213
B302F8AD20B73D6500C5E502 /* PVLogging.m in Sources */,
41504214
B3447E91218B7E4B00557ACE /* CAAudioTimeStamp.cpp in Sources */,
4215+
B3C96EA91D62C3C3003F1E93 /* OEGameAudio.m in Sources */,
4216+
B3A2978A2709600400DDBF37 /* PatreonAccount.swift in Sources */,
41514217
B3447F9C218C1CD200557ACE /* PVSettingsModel.swift in Sources */,
41524218
0592894F1DC194FD0012644D /* RealTimeThread.m in Sources */,
4219+
B3A29775270952D800DDBF37 /* Benefit.swift in Sources */,
41534220
B33FB2FD279BE18F0013AAD8 /* CoreOptionEnumValue.swift in Sources */,
41544221
B39C29C827A0FADF0078D028 /* OERingBuffer.m in Sources */,
41554222
B33FB301279BE1E40013AAD8 /* OptionDependency.swift in Sources */,
41564223
B302F8A320B73D6500C5E502 /* PVLogEntry.m in Sources */,
41574224
B3AB37ED21881B7B009D9244 /* PViCadeMocuteController.swift in Sources */,
41584225
B3AB37BE218812BC009D9244 /* iCadeReaderView.swift in Sources */,
41594226
B3E6DADF20B7BF8600454DD4 /* UIDeviceExtension.swift in Sources */,
4227+
B3A29779270952D800DDBF37 /* Campaign.swift in Sources */,
41604228
B302F8AB20B73D6500C5E502 /* PVProvenanceLogging.m in Sources */,
41614229
B3296EA326C68CCE0088AC32 /* PVCocoaLumberJackLogging.swift in Sources */,
41624230
);
@@ -4169,6 +4237,9 @@
41694237
B34AB57F2106DC6100C45F09 /* PVEmulatorCore.swift in Sources */,
41704238
B3AB37EB21881B7A009D9244 /* PViCadeSteelSeriesController.swift in Sources */,
41714239
B3CDEEBC21D4C3E6000C55F7 /* ArchiveSupport.swift in Sources */,
4240+
B34AB5782106DC5300C45F09 /* OERingBuffer.m in Sources */,
4241+
B34AB5772106DC5300C45F09 /* OEGameAudio.m in Sources */,
4242+
B3A2977A270952D800DDBF37 /* Patron.swift in Sources */,
41724243
B39C29CE27A10EE50078D028 /* OEGameAudio.m in Sources */,
41734244
B33FB30D279BE2710013AAD8 /* CoreOptional.swift in Sources */,
41744245
B3AB37E921881B7A009D9244 /* PViCade8BitdoController.swift in Sources */,
@@ -4201,21 +4272,28 @@
42014272
B3447E90218B7E4B00557ACE /* CAAudioTimeStamp.cpp in Sources */,
42024273
B34AB5732106DC3700C45F09 /* PVProvenanceLogging.m in Sources */,
42034274
B3AB37BF218814A7009D9244 /* PViCadeReader.swift in Sources */,
4275+
B3A29776270952D800DDBF37 /* PatreonAPI.swift in Sources */,
42044276
B34AB57D2106DC6100C45F09 /* RealTimeThread.m in Sources */,
42054277
B3CDEEBF21D4C41D000C55F7 /* DiscSwappable.swift in Sources */,
4278+
B3A2977C270952D800DDBF37 /* Tier.swift in Sources */,
42064279
B34AB57B2106DC6100C45F09 /* NSObject+PVAbstractAdditions.m in Sources */,
4280+
B3A2978027095C4200DDBF37 /* Keychain.swift in Sources */,
42074281
B3D0EE20277FE85F002DC0A5 /* HapticsManager.swift in Sources */,
42084282
B34AB57E2106DC6100C45F09 /* PVEmulatorCore.m in Sources */,
42094283
B34AB5742106DC4100C45F09 /* PVLogEntry.m in Sources */,
42104284
B34AB5792106DC5300C45F09 /* TPCircularBuffer.c in Sources */,
4285+
B3A297892709600400DDBF37 /* PatreonAccount.swift in Sources */,
4286+
B34AB5802106DC6100C45F09 /* PVGameControllerUtilities.m in Sources */,
42114287
B34AB5752106DC4100C45F09 /* PVLogging.m in Sources */,
4288+
B3A29774270952D800DDBF37 /* Benefit.swift in Sources */,
42124289
B33FB2FC279BE18F0013AAD8 /* CoreOptionEnumValue.swift in Sources */,
42134290
B39C29C727A0FADF0078D028 /* OERingBuffer.m in Sources */,
42144291
B33FB300279BE1E40013AAD8 /* OptionDependency.swift in Sources */,
42154292
B3AB37EA21881B7A009D9244 /* PViCadeMocuteController.swift in Sources */,
42164293
B3F0846C2188CA7A00FF39EE /* CocoaLumberExtensions.swift in Sources */,
42174294
B3AB37BD218812BB009D9244 /* iCadeReaderView.swift in Sources */,
42184295
B3AB37E321881A82009D9244 /* PViCadeGamepad.swift in Sources */,
4296+
B3A29778270952D800DDBF37 /* Campaign.swift in Sources */,
42194297
B3296EA226C68CCE0088AC32 /* PVCocoaLumberJackLogging.swift in Sources */,
42204298
B3447F9B218C1CD200557ACE /* PVSettingsModel.swift in Sources */,
42214299
);
@@ -5728,6 +5806,14 @@
57285806
minimumVersion = 5.1.0;
57295807
};
57305808
};
5809+
B3A2978227095CAC00DDBF37 /* XCRemoteSwiftPackageReference "KeychainAccess" */ = {
5810+
isa = XCRemoteSwiftPackageReference;
5811+
repositoryURL = "https://github.com/kishikawakatsumi/KeychainAccess.git";
5812+
requirement = {
5813+
kind = upToNextMajorVersion;
5814+
minimumVersion = 4.0.0;
5815+
};
5816+
};
57315817
B3CEC5BF27952163004A7CC1 /* XCRemoteSwiftPackageReference "NSLogger" */ = {
57325818
isa = XCRemoteSwiftPackageReference;
57335819
repositoryURL = "https://github.com/fpillet/NSLogger";
@@ -5819,6 +5905,16 @@
58195905
package = B336B8F226B398A900960A81 /* XCRemoteSwiftPackageReference "Reachability.swift" */;
58205906
productName = Reachability;
58215907
};
5908+
B3A2978327095CAC00DDBF37 /* KeychainAccess */ = {
5909+
isa = XCSwiftPackageProductDependency;
5910+
package = B3A2978227095CAC00DDBF37 /* XCRemoteSwiftPackageReference "KeychainAccess" */;
5911+
productName = KeychainAccess;
5912+
};
5913+
B3A2978527095CB700DDBF37 /* KeychainAccess */ = {
5914+
isa = XCSwiftPackageProductDependency;
5915+
package = B3A2978227095CAC00DDBF37 /* XCRemoteSwiftPackageReference "KeychainAccess" */;
5916+
productName = KeychainAccess;
5917+
};
58225918
B3B492CA26B3A96B000B426B /* Reachability */ = {
58235919
isa = XCSwiftPackageProductDependency;
58245920
package = B336B8F226B398A900960A81 /* XCRemoteSwiftPackageReference "Reachability.swift" */;

PVSupport/Patreon/Benefit.swift

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//
2+
// Benefit.swift
3+
// AltStore
4+
//
5+
// Created by Riley Testut on 8/21/19.
6+
// Copyright © 2019 Riley Testut. All rights reserved.
7+
//
8+
9+
import Foundation
10+
11+
public enum PVPatreonBenefitType: String {
12+
case betaAccess = "7585304"
13+
case credit = "8490206"
14+
}
15+
16+
@available(iOS 12.0, tvOS 12.0, *)
17+
extension PatreonAPI
18+
{
19+
struct BenefitResponse: Decodable
20+
{
21+
var id: String
22+
}
23+
}
24+
25+
@available(iOS 12.0, tvOS 12.0, *)
26+
public struct Benefit: Hashable
27+
{
28+
public var type: PVPatreonBenefitType
29+
30+
init?(response: PatreonAPI.BenefitResponse)
31+
{
32+
guard let type = PVPatreonBenefitType(rawValue: response.id) else {
33+
ELOG("Unknown benefit id \(response.id)")
34+
return nil
35+
}
36+
self.type = type
37+
}
38+
}

PVSupport/Patreon/Campaign.swift

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//
2+
// Campaign.swift
3+
// AltStore
4+
//
5+
// Created by Riley Testut on 8/21/19.
6+
// Copyright © 2019 Riley Testut. All rights reserved.
7+
//
8+
9+
import Foundation
10+
11+
@available(iOS 12.0, tvOS 12.0, *)
12+
extension PatreonAPI
13+
{
14+
struct CampaignResponse: Decodable
15+
{
16+
var id: String
17+
}
18+
}
19+
20+
@available(iOS 12.0, tvOS 12.0, *)
21+
public struct Campaign
22+
{
23+
public var identifier: String
24+
25+
init(response: PatreonAPI.CampaignResponse)
26+
{
27+
self.identifier = response.id
28+
}
29+
}

0 commit comments

Comments
 (0)