@@ -10,8 +10,6 @@ import { AuthError } from './errors'
1010import { getSetting } from './settings'
1111import constants from '../constants'
1212
13- import type { SocketSdkOptions } from '@socketsecurity/sdk'
14-
1513// The API server that should be used for operations.
1614function getDefaultAPIBaseUrl ( ) : string | undefined {
1715 const baseUrl =
@@ -29,10 +27,10 @@ function getDefaultHTTPProxy(): string | undefined {
2927// This API key should be stored globally for the duration of the CLI execution.
3028let _defaultToken : string | undefined
3129export function getDefaultToken ( ) : string | undefined {
32- // Keep 'SOCKET_SECURITY_API_KEY' as an alias of 'SOCKET_SECURITY_API_TOKEN' for now.
33- // TODO: Remove 'SOCKET_SECURITY_API_KEY' alias.
3430 const key =
3531 process . env [ 'SOCKET_SECURITY_API_TOKEN' ] ||
32+ // Keep 'SOCKET_SECURITY_API_KEY' as an alias of 'SOCKET_SECURITY_API_TOKEN'.
33+ // TODO: Remove 'SOCKET_SECURITY_API_KEY' alias.
3634 process . env [ 'SOCKET_SECURITY_API_KEY' ] ||
3735 // TODO: Rename the 'apiKey' setting to 'apiToken'.
3836 getSetting ( 'apiKey' ) ||
@@ -57,25 +55,18 @@ export async function setupSdk(
5755 } )
5856 _defaultToken = apiToken
5957 }
60-
6158 if ( ! apiToken ) {
6259 throw new AuthError ( 'You need to provide an API key' )
6360 }
64-
65- let agent : SocketSdkOptions [ 'agent' ] | undefined
66- if ( proxy ) {
67- agent = {
68- http : new HttpProxyAgent ( { proxy } ) ,
69- https : new HttpsProxyAgent ( { proxy } )
70- }
71- }
72-
73- const sdkOptions : SocketSdkOptions = {
74- agent,
61+ return new SocketSdk ( apiToken , {
62+ agent : proxy
63+ ? {
64+ http : new HttpProxyAgent ( { proxy } ) ,
65+ https : new HttpsProxyAgent ( { proxy } )
66+ }
67+ : undefined ,
7568 baseUrl : apiBaseUrl ,
7669 // Lazily access constants.rootPkgJsonPath.
7770 userAgent : createUserAgentFromPkgJson ( require ( constants . rootPkgJsonPath ) )
78- }
79-
80- return new SocketSdk ( apiToken || '' , sdkOptions )
71+ } )
8172}
0 commit comments