1
- import { Agent } from "node:http" ;
2
- import axios , { type AxiosInstance } from "axios" ;
3
1
import { GraphQLClient } from "graphql-request" ;
4
2
import { v4 } from "uuid" ;
5
3
@@ -127,30 +125,12 @@ export class EVaultClient {
127
125
private client : GraphQLClient | null = null ;
128
126
private endpoint : string | null = null ;
129
127
private tokenInfo : TokenInfo | null = null ;
130
- private httpClient : AxiosInstance ;
131
128
private isDisposed = false ;
132
129
133
130
constructor (
134
131
private registryUrl : string ,
135
132
private platform : string ,
136
- ) {
137
- // Configure axios with connection pooling and timeouts
138
- this . httpClient = axios . create ( {
139
- timeout : CONFIG . REQUEST_TIMEOUT ,
140
- maxRedirects : 3 ,
141
- // Connection pooling configuration
142
- httpAgent : new Agent ( {
143
- keepAlive : true ,
144
- maxSockets : CONFIG . CONNECTION_POOL_SIZE ,
145
- timeout : CONFIG . CONNECTION_TIMEOUT ,
146
- } ) ,
147
- httpsAgent : new Agent ( {
148
- keepAlive : true ,
149
- maxSockets : CONFIG . CONNECTION_POOL_SIZE ,
150
- timeout : CONFIG . CONNECTION_TIMEOUT ,
151
- } ) ,
152
- } ) ;
153
- }
133
+ ) { }
154
134
155
135
/**
156
136
* Cleanup method to properly dispose of resources
@@ -162,14 +142,6 @@ export class EVaultClient {
162
142
this . client = null ;
163
143
this . endpoint = null ;
164
144
this . tokenInfo = null ;
165
-
166
- // Close HTTP agents to free connections
167
- if ( this . httpClient . defaults . httpAgent ) {
168
- this . httpClient . defaults . httpAgent . destroy ( ) ;
169
- }
170
- if ( this . httpClient . defaults . httpsAgent ) {
171
- this . httpClient . defaults . httpsAgent . destroy ( ) ;
172
- }
173
145
}
174
146
175
147
/**
@@ -217,25 +189,27 @@ export class EVaultClient {
217
189
*/
218
190
private async requestPlatformToken ( ) : Promise < TokenInfo > {
219
191
try {
220
- const response = await this . httpClient . post < PlatformTokenResponse > (
221
- new URL (
222
- "/platforms/certification" ,
223
- this . registryUrl ,
224
- ) . toString ( ) ,
225
- { platform : this . platform } ,
192
+ const response = await fetch (
193
+ new URL ( "/platforms/certification" , this . registryUrl ) . toString ( ) ,
226
194
{
195
+ method : "POST" ,
227
196
headers : {
228
197
"Content-Type" : "application/json" ,
229
198
} ,
230
- timeout : CONFIG . REQUEST_TIMEOUT ,
199
+ body : JSON . stringify ( { platform : this . platform } ) ,
231
200
} ,
232
201
) ;
233
202
203
+ if ( ! response . ok ) {
204
+ throw new Error ( `HTTP error! status: ${ response . status } ` ) ;
205
+ }
206
+
207
+ const data = await response . json ( ) as PlatformTokenResponse ;
234
208
const now = Date . now ( ) ;
235
- const expiresAt = response . data . expiresAt || now + 3600000 ; // Default 1 hour
209
+ const expiresAt = data . expiresAt || now + 3600000 ; // Default 1 hour
236
210
237
211
return {
238
- token : response . data . token ,
212
+ token : data . token ,
239
213
expiresAt,
240
214
obtainedAt : now ,
241
215
} ;
0 commit comments