@@ -49,7 +49,6 @@ public struct GitHubCopilotCodeSuggestion: Codable, Equatable {
4949 public var displayText : String
5050}
5151
52-
5352enum GitHubCopilotRequest {
5453 struct SetEditorInfo : GitHubCopilotRequestType {
5554 struct Response : Codable { }
@@ -81,22 +80,58 @@ enum GitHubCopilotRequest {
8180 }
8281 }
8382
84- var request : ClientRequest {
85- if let networkProxy {
86- return . custom( " setEditorInfo " , . hash( [
87- " editorInfo " : . hash( [
88- " name " : " Xcode " ,
89- " version " : " " ,
90- ] ) ,
91- " editorPluginInfo " : . hash( [
92- " name " : " Copilot for Xcode " ,
93- " version " : " " ,
94- ] ) ,
95- " networkProxy " : networkProxy,
96- ] ) )
83+ var http : JSONValue ? {
84+ var dict : [ String : JSONValue ] = [ : ]
85+ let host = UserDefaults . shared. value ( for: \. gitHubCopilotProxyHost)
86+ if host. isEmpty { return nil }
87+ var port = UserDefaults . shared. value ( for: \. gitHubCopilotProxyPort)
88+ if port. isEmpty { port = " 80 " }
89+ let username = UserDefaults . shared. value ( for: \. gitHubCopilotProxyUsername)
90+ let password = UserDefaults . shared. value ( for: \. gitHubCopilotProxyPassword)
91+ let strictSSL = UserDefaults . shared. value ( for: \. gitHubCopilotUseStrictSSL)
92+
93+ let url = if !username. isEmpty {
94+ " http:// \( username) : \( password) @ \( host) : \( port) "
95+ } else {
96+ " http:// \( host) : \( port) "
9797 }
9898
99- return . custom( " setEditorInfo " , . hash( [
99+ dict [ " proxy " ] = . string( url)
100+ dict [ " proxyStrictSSL " ] = . bool( strictSSL)
101+
102+ if dict. isEmpty { return nil }
103+
104+ return . hash( dict)
105+ }
106+
107+ var editorConfiguration : JSONValue ? {
108+ var dict : [ String : JSONValue ] = [ : ]
109+ dict [ " http " ] = http
110+
111+ let enterpriseURI = UserDefaults . shared. value ( for: \. gitHubCopilotEnterpriseURI)
112+ if !enterpriseURI. isEmpty {
113+ dict [ " github-enterprise " ] = . hash( [
114+ " uri " : . string( enterpriseURI) ,
115+ ] )
116+ }
117+
118+ if dict. isEmpty { return nil }
119+ return . hash( dict)
120+ }
121+
122+ var authProvider : JSONValue ? {
123+ var dict : [ String : JSONValue ] = [ : ]
124+ let enterpriseURI = UserDefaults . shared. value ( for: \. gitHubCopilotEnterpriseURI)
125+ if !enterpriseURI. isEmpty {
126+ dict [ " url " ] = . string( enterpriseURI)
127+ }
128+
129+ if dict. isEmpty { return nil }
130+ return . hash( dict)
131+ }
132+
133+ var request : ClientRequest {
134+ var dict : [ String : JSONValue ] = [
100135 " editorInfo " : . hash( [
101136 " name " : " Xcode " ,
102137 " version " : " " ,
@@ -105,7 +140,13 @@ enum GitHubCopilotRequest {
105140 " name " : " Copilot for Xcode " ,
106141 " version " : " " ,
107142 ] ) ,
108- ] ) )
143+ ]
144+
145+ dict [ " editorConfiguration " ] = editorConfiguration
146+ dict [ " authProvider " ] = authProvider
147+ dict [ " networkProxy " ] = networkProxy
148+
149+ return . custom( " setEditorInfo " , . hash( dict) )
109150 }
110151 }
111152
0 commit comments