Skip to content
This repository has been archived by the owner on Nov 17, 2024. It is now read-only.

Commit

Permalink
Repo // Clean-up obsolete codes.
Browse files Browse the repository at this point in the history
  • Loading branch information
ShikiSuen committed Sep 25, 2024
1 parent 5cb88f8 commit 75e8008
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 132 deletions.
12 changes: 6 additions & 6 deletions GenshinPizzaHelper.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
5BD1C62C2A2A1FC90043C2B1 /* RecoveryTimeTextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFE42541289E520A00FEFA49 /* RecoveryTimeTextView.swift */; };
5BD1C62D2A2A1FC90043C2B1 /* InAppMaterialNavigator.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA9EA04528B77DED00000227 /* InAppMaterialNavigator.swift */; };
5BD1C62E2A2A1FC90043C2B1 /* TapticSupport.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF70210C28B3967A00A6BBA9 /* TapticSupport.swift */; };
5BD1C6312A2A1FC90043C2B1 /* GachaKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA025C8729D287970075F780 /* GachaKey.swift */; };
5BD1C6312A2A1FC90043C2B1 /* GachaGenAuthKeyResult.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA025C8729D287970075F780 /* GachaGenAuthKeyResult.swift */; };
5BD1C6322A2A1FC90043C2B1 /* EachExpeditionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAFC5CD128B5190500770BBB /* EachExpeditionView.swift */; };
5BD1C6332A2A1FC90043C2B1 /* MaterialChoices.swift in Sources */ = {isa = PBXBuildFile; fileRef = EABE606028D9F6970018CAF6 /* MaterialChoices.swift */; };
5BD1C6342A2A1FC90043C2B1 /* AboutView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFE4258728A0AE2700FEFA49 /* AboutView.swift */; };
Expand Down Expand Up @@ -360,7 +360,7 @@
EA025C8229D280FD0075F780 /* GachaModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA025C8129D280FD0075F780 /* GachaModel.swift */; };
EA025C8429D2834E0075F780 /* GachaItemManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA025C8329D2834E0075F780 /* GachaItemManager.swift */; };
EA025C8629D286540075F780 /* GachaViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA025C8529D286540075F780 /* GachaViewModel.swift */; };
EA025C8829D287970075F780 /* GachaKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA025C8729D287970075F780 /* GachaKey.swift */; };
EA025C8829D287970075F780 /* GachaGenAuthKeyResult.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA025C8729D287970075F780 /* GachaGenAuthKeyResult.swift */; };
EA025C8A29D2883A0075F780 /* GachaURL.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA025C8929D2883A0075F780 /* GachaURL.swift */; };
EA025C8E29D28D150075F780 /* APIGetGachaView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA025C8D29D28D150075F780 /* APIGetGachaView.swift */; };
EA025C9029D28D3D0075F780 /* GachaView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA025C8F29D28D3D0075F780 /* GachaView.swift */; };
Expand Down Expand Up @@ -935,7 +935,7 @@
EA025C8129D280FD0075F780 /* GachaModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GachaModel.swift; sourceTree = "<group>"; };
EA025C8329D2834E0075F780 /* GachaItemManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GachaItemManager.swift; sourceTree = "<group>"; };
EA025C8529D286540075F780 /* GachaViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GachaViewModel.swift; sourceTree = "<group>"; };
EA025C8729D287970075F780 /* GachaKey.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GachaKey.swift; sourceTree = "<group>"; };
EA025C8729D287970075F780 /* GachaGenAuthKeyResult.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GachaGenAuthKeyResult.swift; sourceTree = "<group>"; };
EA025C8929D2883A0075F780 /* GachaURL.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GachaURL.swift; sourceTree = "<group>"; };
EA025C8D29D28D150075F780 /* APIGetGachaView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = APIGetGachaView.swift; sourceTree = "<group>"; };
EA025C8F29D28D3D0075F780 /* GachaView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GachaView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1510,7 +1510,7 @@
EA025C8129D280FD0075F780 /* GachaModel.swift */,
EA025C8329D2834E0075F780 /* GachaItemManager.swift */,
EA025C8529D286540075F780 /* GachaViewModel.swift */,
EA025C8729D287970075F780 /* GachaKey.swift */,
EA025C8729D287970075F780 /* GachaGenAuthKeyResult.swift */,
EA025C8929D2883A0075F780 /* GachaURL.swift */,
EAAD03E529D2FD88007D5C80 /* GachaItem.swift */,
EA4C005829D2FFD100637B19 /* GachaFetch.swift */,
Expand Down Expand Up @@ -2525,7 +2525,7 @@
5BD1C62C2A2A1FC90043C2B1 /* RecoveryTimeTextView.swift in Sources */,
5BD1C62D2A2A1FC90043C2B1 /* InAppMaterialNavigator.swift in Sources */,
5BD1C62E2A2A1FC90043C2B1 /* TapticSupport.swift in Sources */,
5BD1C6312A2A1FC90043C2B1 /* GachaKey.swift in Sources */,
5BD1C6312A2A1FC90043C2B1 /* GachaGenAuthKeyResult.swift in Sources */,
5BD1C6322A2A1FC90043C2B1 /* EachExpeditionView.swift in Sources */,
5BEF4B872B60D78C007FB100 /* StaggeredGrid.swift in Sources */,
5BD1C6332A2A1FC90043C2B1 /* MaterialChoices.swift in Sources */,
Expand Down Expand Up @@ -2918,7 +2918,7 @@
5BCBAEF52C29BC4D00BAF156 /* GetCookieQRCodeView_Genshin.swift in Sources */,
EA9EA04628B77DED00000227 /* InAppMaterialNavigator.swift in Sources */,
BF70210D28B3967A00A6BBA9 /* TapticSupport.swift in Sources */,
EA025C8829D287970075F780 /* GachaKey.swift in Sources */,
EA025C8829D287970075F780 /* GachaGenAuthKeyResult.swift in Sources */,
EAFC5CD228B5190500770BBB /* EachExpeditionView.swift in Sources */,
EABE606128D9F6970018CAF6 /* MaterialChoices.swift in Sources */,
5BEF4B862B60D711007FB100 /* StaggeredGrid.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,65 +111,6 @@ extension MihoyoAPI {
return t + "," + r + "," + c
}
}

public static func getCookieToken(
cookieContainStoken: String,
completion: @escaping (
(Result<(cookieToken: String, uid: String), GetGachaError>) -> ()
)
) {
var urlComponents = URLComponents()
urlComponents.scheme = "https"
urlComponents.host = "passport-api.mihoyo.com"
// switch account.server.region {
// case .cn: urlComponents.host = "api-takumi.mihoyo.com"
// case .global: urlComponents.host = "???"
// }
urlComponents.path = "/account/auth/api/getCookieAccountInfoBySToken"

let url = urlComponents.url!

var request = URLRequest(url: url)
request.allHTTPHeaderFields = [
"Cookie": cookieContainStoken,
]

print(request)

URLSession.shared.dataTask(with: request) { data, _, error in
// print(error ?? "ErrorInfo nil")
guard error == nil
else {
completion(.failure(.genAuthKeyError(
message: error!
.localizedDescription
))); return
}
// print(respond)
// print(String(data: data!, encoding: .utf8))
let decoder = JSONDecoder()
decoder.keyDecodingStrategy = .convertFromSnakeCase
do {
let result = try decoder.decode(
GetCookieTokenResult.self,
from: data!
)
if let data = result.data {
completion(.success((data.cookieToken, data.uid)))
} else {
completion(.failure(.genAuthKeyError(
message: result
.message
)))
}
} catch {
completion(.failure(.genAuthKeyError(
message: error
.localizedDescription
)))
}
}.resume()
}
}

// MARK: - GetCookieTokenResult
Expand Down Expand Up @@ -211,60 +152,3 @@ public struct GenAuthKeyResult: Codable {
let message: String
let data: GenAuthKeyData?
}

extension UUID {
enum UUIDVersion: Int {
case v3 = 3
case v5 = 5
}

enum UUIDv5NameSpace: String {
case dns = "6ba7b810-9dad-11d1-80b4-00c04fd430c8"
case url = "6ba7b811-9dad-11d1-80b4-00c04fd430c8"
case oid = "6ba7b812-9dad-11d1-80b4-00c04fd430c8"
case x500 = "6ba7b814-9dad-11d1-80b4-00c04fd430c8"
}

/// Unused constructor for UUID. Might be unusable. See "remarks" section.
/// - Remark: This constructor has recently upgraded using CryptoKit WITHOUT Usability Tests!!!!!!!!
init(version: UUIDVersion, name: String, nameSpace: UUIDv5NameSpace) {
// Get UUID bytes from name space:
var spaceUID = UUID(uuidString: nameSpace.rawValue)!.uuid
var data =
withUnsafePointer(to: &spaceUID) { [count = MemoryLayout.size(ofValue: spaceUID)] in
Data(bytes: $0, count: count)
}

// Append name string in UTF-8 encoding:
data.append(contentsOf: name.utf8)

// Compute digest (MD5 or SHA1, depending on the version):
var digest = [UInt8](repeating: 0, count: Int(CC_SHA1_DIGEST_LENGTH))
data.withUnsafeBytes { (_: UnsafeRawBufferPointer) in
switch version {
case .v3:
digest = Insecure.MD5.hash(data: Data(name.utf8)).map { UInt8($0) }
case .v5:
digest = Insecure.SHA1.hash(data: Data(name.utf8)).map { UInt8($0) }
}
}
if digest.count < Int(CC_SHA1_DIGEST_LENGTH) {
let delta = Int(CC_SHA1_DIGEST_LENGTH) - digest.count
for _ in 0 ..< delta {
digest.insert(0, at: 0)
}
}

// Set version bits:
digest[6] &= 0x0F
digest[6] |= UInt8(version.rawValue) << 4
// Set variant bits:
digest[8] &= 0x3F
digest[8] |= 0x80

// Create UUID from digest:
self = NSUUID(uuidBytes: digest) as UUID
}
}

let NAMESPACE_URL = UUID(uuidString: "6ba7b812-9dad-11d1-80b4-00c04fd430c8")!
10 changes: 0 additions & 10 deletions Model/GachaModel/GachaItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,6 @@
import Charts
import Foundation

// public func getGacha(url: String) throws -> GetGachaResult {
// let decoder = JSONDecoder()
// decoder.keyDecodingStrategy = .convertFromSnakeCase
// if let data = try? decoder.decode(ConvertToGetGacha.self, from: get_gacha(url).toString().data(using: .utf8)!) {
// return GetGachaResult.from(data)
// } else {
// return .failure(.decodeError)
// }
// }

public typealias GetGachaResult = Result<[GachaItem], GetGachaError>

// MARK: - GachaItem
Expand Down

0 comments on commit 75e8008

Please sign in to comment.