55// Created by s s on 2025/3/15.
66//
77import SwiftUI
8+ import Foundation
89import StosSign_API_NoCertificate
910import StosSign_Auth
1011
@@ -35,6 +36,8 @@ class AppIDModel : ObservableObject, Hashable {
3536
3637 try await AppleAPI . shared. refreshAnisetteDataIfNeeded ( for: session)
3738
39+ let enableExtendedVirtualAddressing = UserDefaults . standard. bool ( forKey: " enableExtendedVirtualAddressing " )
40+
3841 let dateFormatter = ISO8601DateFormatter ( )
3942 let httpHeaders = [
4043 " Content-Type " : " application/vnd.api+json " ,
@@ -56,10 +59,67 @@ class AppIDModel : ObservableObject, Hashable {
5659 " X-Apple-I-TimeZone " : session. anisetteData. timeZone. abbreviation ( ) !
5760 ] as [ String : String ] ;
5861
62+ // Build capabilities array based on settings
63+ var capabilities : [ [ String : Any ] ] = [
64+ [
65+ " relationships " : [
66+ " capability " : [
67+ " data " : [
68+ " id " : " INCREASED_MEMORY_LIMIT " ,
69+ " type " : " capabilities "
70+ ]
71+ ]
72+ ] ,
73+ " type " : " bundleIdCapabilities " ,
74+ " attributes " : [
75+ " settings " : [ ] ,
76+ " enabled " : true
77+ ]
78+ ]
79+ ]
80+
81+ if enableExtendedVirtualAddressing {
82+ capabilities. append ( [
83+ " relationships " : [
84+ " capability " : [
85+ " data " : [
86+ " id " : " EXTENDED_VIRTUAL_ADDRESSING " ,
87+ " type " : " capabilities "
88+ ]
89+ ]
90+ ] ,
91+ " type " : " bundleIdCapabilities " ,
92+ " attributes " : [
93+ " settings " : [ ] ,
94+ " enabled " : true
95+ ]
96+ ] )
97+ }
98+
99+ let requestBody : [ String : Any ] = [
100+ " data " : [
101+ " relationships " : [
102+ " bundleIdCapabilities " : [
103+ " data " : capabilities
104+ ]
105+ ] ,
106+ " id " : appID. identifier,
107+ " attributes " : [
108+ " hasExclusiveManagedCapabilities " : false ,
109+ " teamId " : team. identifier,
110+ " bundleType " : " bundle " ,
111+ " identifier " : appID. bundleIdentifier,
112+ " seedId " : team. identifier,
113+ " name " : appID. name
114+ ] ,
115+ " type " : " bundleIds "
116+ ]
117+ ]
118+
59119 var request = URLRequest ( url: URL ( string: " https://developerservices2.apple.com/services/v1/bundleIds/ \( appID. identifier) " ) !)
60120 request. httpMethod = " PATCH "
61121 request. allHTTPHeaderFields = httpHeaders
62- request. httpBody = " { \" data \" :{ \" relationships \" :{ \" bundleIdCapabilities \" :{ \" data \" :[{ \" relationships \" :{ \" capability \" :{ \" data \" :{ \" id \" : \" INCREASED_MEMORY_LIMIT \" , \" type \" : \" capabilities \" }}}, \" type \" : \" bundleIdCapabilities \" , \" attributes \" :{ \" settings \" :[], \" enabled \" :true}}]}}, \" id \" : \" \( appID . identifier ) \" , \" attributes \" :{ \" hasExclusiveManagedCapabilities \" :false, \" teamId \" : \" \( team . identifier ) \" , \" bundleType \" : \" bundle \" , \" identifier \" : \" \( appID . bundleIdentifier ) \" , \" seedId \" : \" \( team . identifier ) \" , \" name \" : \" \( appID . name ) \" }, \" type \" : \" bundleIds \" }} " . data ( using : . utf8 )
122+ request. httpBody = try JSONSerialization . data ( withJSONObject : requestBody )
63123
64124 let ( data, response) = try await URLSession . shared. data ( for: request)
65125 let responseString = String ( data: data, encoding: . utf8) ?? " Unable to decode response. "
@@ -70,7 +130,12 @@ class AppIDModel : ObservableObject, Hashable {
70130 }
71131
72132 await MainActor . run {
73- result = " ✅ Success! Increased Memory Limit capability has been enabled. \n \n API Response: \n \( responseString) "
133+ var successMessage = " ✅ Success! Increased Memory Limit capability has been enabled. "
134+ if enableExtendedVirtualAddressing {
135+ successMessage += " \n \n Extended Virtual Addressing capability has also been enabled. "
136+ }
137+ successMessage += " \n \n API Response: \n \( responseString) "
138+ result = successMessage
74139 }
75140
76141 }
0 commit comments