File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change 1
- import { SocketSdk } from '@socketsecurity/sdk'
1
+ import { readFile } from 'node:fs/promises'
2
+ import { dirname , join } from 'node:path'
3
+ import { fileURLToPath } from 'node:url'
4
+
5
+ import { SocketSdk , createUserAgentFromPkgJson } from '@socketsecurity/sdk'
2
6
import isInteractive from 'is-interactive'
3
7
import prompts from 'prompts'
4
8
@@ -34,11 +38,14 @@ export async function setupSdk () {
34
38
https : new HttpsProxyAgent ( { proxy : process . env [ 'SOCKET_SECURITY_API_PROXY' ] } ) ,
35
39
}
36
40
}
41
+ const packageJsonPath = join ( dirname ( fileURLToPath ( import . meta. url ) ) , '../../package.json' )
42
+ const packageJson = await readFile ( packageJsonPath , 'utf8' )
37
43
38
44
/** @type {import('@socketsecurity/sdk').SocketSdkOptions } */
39
45
const sdkOptions = {
40
46
agent,
41
47
baseUrl : process . env [ 'SOCKET_SECURITY_API_BASE_URL' ] ,
48
+ userAgent : createUserAgentFromPkgJson ( JSON . parse ( packageJson ) )
42
49
}
43
50
44
51
return new SocketSdk ( apiKey || '' , sdkOptions )
You can’t perform that action at this time.
0 commit comments