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'
26import isInteractive from 'is-interactive'
37import prompts from 'prompts'
48
@@ -34,11 +38,14 @@ export async function setupSdk () {
3438 https : new HttpsProxyAgent ( { proxy : process . env [ 'SOCKET_SECURITY_API_PROXY' ] } ) ,
3539 }
3640 }
41+ const packageJsonPath = join ( dirname ( fileURLToPath ( import . meta. url ) ) , '../../package.json' )
42+ const packageJson = await readFile ( packageJsonPath , 'utf8' )
3743
3844 /** @type {import('@socketsecurity/sdk').SocketSdkOptions } */
3945 const sdkOptions = {
4046 agent,
4147 baseUrl : process . env [ 'SOCKET_SECURITY_API_BASE_URL' ] ,
48+ userAgent : createUserAgentFromPkgJson ( JSON . parse ( packageJson ) )
4249 }
4350
4451 return new SocketSdk ( apiKey || '' , sdkOptions )
You can’t perform that action at this time.
0 commit comments