mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-09 06:43:25 +01:00
Fetches Patreon creator access token from AltStore source
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
BF1E315F22A0635900370A3C /* libAltKit.a in Frameworks */ = {isa = PBXBuildFile; fileRef = BF1E315022A0616100370A3C /* libAltKit.a */; };
|
||||
BF1E316022A0636400370A3C /* libAltKit.a in Frameworks */ = {isa = PBXBuildFile; fileRef = BF1E315022A0616100370A3C /* libAltKit.a */; };
|
||||
BF258CE322EBAE2800023032 /* AppProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF258CE222EBAE2800023032 /* AppProtocol.swift */; };
|
||||
BF26A0E12370C5D400F53F9F /* ALTSourceUserInfoKey.m in Sources */ = {isa = PBXBuildFile; fileRef = BF26A0E02370C5D400F53F9F /* ALTSourceUserInfoKey.m */; };
|
||||
BF29012F2318F6B100D88A45 /* AppBannerView.xib in Resources */ = {isa = PBXBuildFile; fileRef = BF29012E2318F6B100D88A45 /* AppBannerView.xib */; };
|
||||
BF2901312318F7A800D88A45 /* AppBannerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF2901302318F7A800D88A45 /* AppBannerView.swift */; };
|
||||
BF3D648822E79A3700E9056B /* AppPermission.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF3D648722E79A3700E9056B /* AppPermission.swift */; };
|
||||
@@ -304,6 +305,8 @@
|
||||
BF1E315022A0616100370A3C /* libAltKit.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libAltKit.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
BF219A7E22CAC431007676A6 /* AltStore.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = AltStore.entitlements; sourceTree = "<group>"; };
|
||||
BF258CE222EBAE2800023032 /* AppProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppProtocol.swift; sourceTree = "<group>"; };
|
||||
BF26A0DF2370C5D400F53F9F /* ALTSourceUserInfoKey.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ALTSourceUserInfoKey.h; sourceTree = "<group>"; };
|
||||
BF26A0E02370C5D400F53F9F /* ALTSourceUserInfoKey.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ALTSourceUserInfoKey.m; sourceTree = "<group>"; };
|
||||
BF29012E2318F6B100D88A45 /* AppBannerView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = AppBannerView.xib; sourceTree = "<group>"; };
|
||||
BF2901302318F7A800D88A45 /* AppBannerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppBannerView.swift; sourceTree = "<group>"; };
|
||||
BF3D648722E79A3700E9056B /* AppPermission.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppPermission.swift; sourceTree = "<group>"; };
|
||||
@@ -613,6 +616,8 @@
|
||||
BF3D648C22E79AC800E9056B /* ALTAppPermission.m */,
|
||||
BF54E81F2315EF0D000AE0D8 /* ALTPatreonBenefitType.h */,
|
||||
BF54E8202315EF0D000AE0D8 /* ALTPatreonBenefitType.m */,
|
||||
BF26A0DF2370C5D400F53F9F /* ALTSourceUserInfoKey.h */,
|
||||
BF26A0E02370C5D400F53F9F /* ALTSourceUserInfoKey.m */,
|
||||
BF41B807233433C100C593A3 /* LoadingState.swift */,
|
||||
);
|
||||
path = Types;
|
||||
@@ -1459,6 +1464,7 @@
|
||||
BFD2478F2284C8F900981D42 /* Button.swift in Sources */,
|
||||
BFD5D6F6230DDB12007955AB /* Tier.swift in Sources */,
|
||||
BFB11692229322E400BB457C /* DatabaseManager.swift in Sources */,
|
||||
BF26A0E12370C5D400F53F9F /* ALTSourceUserInfoKey.m in Sources */,
|
||||
BFC1F38D22AEE3A4003AC21A /* DownloadAppOperation.swift in Sources */,
|
||||
BF54E8212315EF0D000AE0D8 /* ALTPatreonBenefitType.m in Sources */,
|
||||
BFBBE2E122931F81002097FA /* InstalledApp.swift in Sources */,
|
||||
|
||||
@@ -5,3 +5,4 @@
|
||||
#import "NSError+ALTServerError.h"
|
||||
#import "ALTAppPermission.h"
|
||||
#import "ALTPatreonBenefitType.h"
|
||||
#import "ALTSourceUserInfoKey.h"
|
||||
|
||||
@@ -71,6 +71,9 @@ class Keychain
|
||||
@KeychainItem(key: "patreonRefreshToken")
|
||||
var patreonRefreshToken: String?
|
||||
|
||||
@KeychainItem(key: "patreonCreatorAccessToken")
|
||||
var patreonCreatorAccessToken: String?
|
||||
|
||||
private init()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -27,6 +27,9 @@ class Source: NSManagedObject, Fetchable, Decodable
|
||||
@NSManaged var identifier: String
|
||||
@NSManaged var sourceURL: URL
|
||||
|
||||
/* Non-Core Data Properties */
|
||||
var userInfo: [ALTSourceUserInfoKey: String]?
|
||||
|
||||
/* Relationships */
|
||||
@objc(apps) @NSManaged private(set) var _apps: NSOrderedSet
|
||||
@objc(newsItems) @NSManaged private(set) var _newsItems: NSOrderedSet
|
||||
@@ -54,6 +57,7 @@ class Source: NSManagedObject, Fetchable, Decodable
|
||||
case name
|
||||
case identifier
|
||||
case sourceURL
|
||||
case userInfo
|
||||
case apps
|
||||
case news
|
||||
}
|
||||
@@ -74,6 +78,9 @@ class Source: NSManagedObject, Fetchable, Decodable
|
||||
self.identifier = try container.decode(String.self, forKey: .identifier)
|
||||
self.sourceURL = try container.decode(URL.self, forKey: .sourceURL)
|
||||
|
||||
let userInfo = try container.decodeIfPresent([String: String].self, forKey: .userInfo)
|
||||
self.userInfo = userInfo?.reduce(into: [:]) { $0[ALTSourceUserInfoKey($1.key)] = $1.value }
|
||||
|
||||
let apps = try container.decodeIfPresent([StoreApp].self, forKey: .apps) ?? []
|
||||
for (index, app) in apps.enumerated()
|
||||
{
|
||||
|
||||
@@ -68,6 +68,11 @@ class FetchSourceOperation: ResultOperation<Source>
|
||||
|
||||
let source = try decoder.decode(Source.self, from: data)
|
||||
|
||||
if let patreonAccessToken = source.userInfo?[.patreonAccessToken]
|
||||
{
|
||||
Keychain.shared.patreonCreatorAccessToken = patreonAccessToken
|
||||
}
|
||||
|
||||
#if STAGING
|
||||
source.sourceURL = self.sourceURL
|
||||
#endif
|
||||
|
||||
@@ -11,7 +11,6 @@ import AuthenticationServices
|
||||
|
||||
private let clientID = "ZMx0EGUWe4TVWYXNZZwK_fbIK5jHFVWoUf1Qb-sqNXmT-YzAGwDPxxq7ak3_W5Q2"
|
||||
private let clientSecret = "1hktsZB89QyN69cB4R0tu55R4TCPQGXxvebYUUh7Y-5TLSnRswuxs6OUjdJ74IJt"
|
||||
private let creatorAccessToken = "NSX1ts9Rf9IzKRCu8GjbwsZ6wll8bDtoJxNbPbp2eZo"
|
||||
|
||||
private let campaignID = "2863968"
|
||||
|
||||
@@ -348,7 +347,9 @@ private extension PatreonAPI
|
||||
{
|
||||
case .none: break
|
||||
case .creator:
|
||||
guard let creatorAccessToken = Keychain.shared.patreonCreatorAccessToken else { return completion(.failure(Error.invalidAccessToken)) }
|
||||
request.setValue("Bearer " + creatorAccessToken, forHTTPHeaderField: "Authorization")
|
||||
|
||||
case .user:
|
||||
guard let accessToken = Keychain.shared.patreonAccessToken else { return completion(.failure(Error.notAuthenticated)) }
|
||||
request.setValue("Bearer " + accessToken, forHTTPHeaderField: "Authorization")
|
||||
|
||||
@@ -202,5 +202,8 @@
|
||||
"date": "2019-10-09",
|
||||
"notify": false
|
||||
}
|
||||
]
|
||||
],
|
||||
"userInfo": {
|
||||
"patreonAccessToken": "lb2Sq14mVCejEtITnlGfszbYXDhXmrdpiOMCEZjlfFk"
|
||||
}
|
||||
}
|
||||
|
||||
12
AltStore/Types/ALTSourceUserInfoKey.h
Normal file
12
AltStore/Types/ALTSourceUserInfoKey.h
Normal file
@@ -0,0 +1,12 @@
|
||||
//
|
||||
// ALTSourceUserInfoKey.h
|
||||
// AltStore
|
||||
//
|
||||
// Created by Riley Testut on 11/4/19.
|
||||
// Copyright © 2019 Riley Testut. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
typedef NSString *ALTSourceUserInfoKey NS_TYPED_EXTENSIBLE_ENUM;
|
||||
extern ALTSourceUserInfoKey const ALTSourceUserInfoKeyPatreonAccessToken;
|
||||
11
AltStore/Types/ALTSourceUserInfoKey.m
Normal file
11
AltStore/Types/ALTSourceUserInfoKey.m
Normal file
@@ -0,0 +1,11 @@
|
||||
//
|
||||
// ALTSourceUserInfoKey.m
|
||||
// AltStore
|
||||
//
|
||||
// Created by Riley Testut on 11/4/19.
|
||||
// Copyright © 2019 Riley Testut. All rights reserved.
|
||||
//
|
||||
|
||||
#import "ALTSourceUserInfoKey.h"
|
||||
|
||||
ALTSourceUserInfoKey const ALTSourceUserInfoKeyPatreonAccessToken = @"patreonAccessToken";
|
||||
Reference in New Issue
Block a user