{"version":3,"file":"974.index.js","mappings":";;;;;;;AAAA,eAAe,mBAAO,CAAC,KAAU;;AAEjC;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,gBAAgB;AAChB,IAAI;AACJ;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA,mBAAmB,mBAAO,CAAC,KAAiB;;AAE5C;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA,eAAe;;;;;;;;;ACnIF;AACb,WAAW,mBAAO,CAAC,KAAI;;AAEvB;;AAEA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;;;;;;;;AC5Ba;AACb,WAAW,mBAAO,CAAC,KAAI;AACvB,WAAW,mBAAO,CAAC,KAAI;AACvB,iBAAiB,mBAAO,CAAC,KAAW;;AAEpC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA,EAAE;AACF;AACA;;;;;;;;;AC9Ba;AACb,OAAO,WAAW,EAAE,mBAAO,CAAC,KAAM;AAClC,aAAa,mBAAO,CAAC,KAAM;AAC3B,qBAAqB,mBAAO,CAAC,KAAe;AAC5C,WAAW,mBAAO,CAAC,KAAI;AACvB,cAAc,mBAAO,CAAC,KAAQ;AAC9B,iBAAiB,mBAAO,CAAC,KAAW;;AAEpC;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA,UAAU,QAAQ;AAClB;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,IAAI;;AAEJ;AACA;AACA;;AAEA,yDAAyD,iBAAiB;AAC1E;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,CAAC;;AAED;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,MAAM,KAAK;AACX;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,GAAG;AACH;;AAEA;AACA,MAAM,WAAW;AACjB,MAAM,uBAAuB;;AAE7B;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,gCAAgC,IAAI;AACpC;AACA,IAAI;AACJ,6BAA6B,OAAO;AACpC;;AAEA;AACA,iDAAiD,IAAI;AACrD;AACA;;AAEA;AACA;AACA,GAAG;AACH;AACA;AACA,IAAI;AACJ;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,0CAA0C,SAAS;AACnD;AACA;;AAEA;AACA,IAAI;AACJ,GAAG;AACH;;AAEA;;AAEA;AACA;;;;;;;;;;;AClMA,wCAA6B;AAC7B,0CAAoC;AACpC,yCAA+B;AAC/B,iDAAsC;AACtC,uCAAqC;AACrC,+CAAwC;AACxC,2CAA0C;AAC1C,+CAAkD;AAClD,0CAA6C;AAC7C,4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yBAAyB,IAAI,+BAAqB,CAAC,IAAI,CAAC,CAAC;IACvE,MAAM,MAAM,SAAG,EAAE,CAAC,IAAI,EAAE,0CAAE,WAAW,EAAE,CAAC;IACxC,MAAM,MAAM,GAAG,oBAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC;IAErC,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,eAAe,CAAC;QAC1C,UAAU;QACV,UAAU;QACV,YAAY;QACZ,oBAAoB;QACpB,EAAE,EAAE,MAAM;QACV,MAAM;KACP,CAAC,CAAC;IAEH,0EAA0E;IAC1E,IAAI,CAAC,oBAAoB,EAAE;QACzB,WAAW,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAC;KAC5C;IAED,OAAO,WAAW,CAAC,QAAQ,EAAE,CAAC;AAChC,CAAC;AAzBD,wDAyBC","sources":["webpack://snyk/./node_modules/cli-spinner/index.js","webpack://snyk/./node_modules/is-docker/index.js","webpack://snyk/./node_modules/is-wsl/index.js","webpack://snyk/./node_modules/open/index.js","webpack://snyk/./src/cli/commands/auth/index.ts","webpack://snyk/./src/cli/commands/auth/is-authed.ts","webpack://snyk/./src/lib/errors/misconfigured-auth-in-ci-error.ts","webpack://snyk/./src/lib/errors/token-expired-error.ts","webpack://snyk/./src/lib/is-docker.ts","webpack://snyk/./src/lib/query-strings.ts"],"sourcesContent":["var readline = require('readline');\n\nvar defaultSpinnerString = 0;\nvar defaultSpinnerDelay = 60;\n\nfunction defaultOnTick(msg) {\n this.clearLine(this.stream);\n this.stream.write(msg);\n};\n\nvar Spinner = function(options){\n if(!(this instanceof Spinner)) return new Spinner(options)\n\n if(typeof options === \"string\"){\n options = { text: options };\n } else if(!options){\n options = {};\n }\n\n this.text = options.text || '';\n this.setSpinnerString(defaultSpinnerString);\n this.setSpinnerDelay(defaultSpinnerDelay);\n this.onTick = options.onTick || defaultOnTick;\n this.stream = options.stream || process.stdout;\n};\n\nSpinner.spinners = require('./spinners.json');\n\nSpinner.setDefaultSpinnerString = function(value) {\n defaultSpinnerString = value;\n\n return this;\n};\n\nSpinner.setDefaultSpinnerDelay = function(value) {\n defaultSpinnerDelay = value;\n\n return this;\n};\n\nSpinner.prototype.start = function() {\n if(this.stream === process.stdout && this.stream.isTTY !== true) {\n return this;\n }\n\n var current = 0;\n var self = this;\n\n var iteration = function() {\n var msg = self.text.indexOf('%s') > -1\n ? self.text.replace('%s', self.chars[current])\n : self.chars[current] + ' ' + self.text;\n\n self.onTick(msg);\n\n current = ++current % self.chars.length;\n };\n\n iteration();\n this.id = setInterval(iteration, this.delay);\n\n return this;\n};\n\nSpinner.prototype.isSpinning = function() {\n return this.id !== undefined;\n}\n\nSpinner.prototype.setSpinnerDelay = function(n) {\n this.delay = n;\n\n return this;\n};\n\nSpinner.prototype.setSpinnerString = function(str) {\n const map = mapToSpinner(str, this.spinners);\n this.chars = Array.isArray(map) ? map : map.split('');\n\n return this;\n};\n\nSpinner.prototype.setSpinnerTitle = function(str) {\n this.text = str;\n\n return this;\n}\n\nSpinner.prototype.stop = function(clear) {\n if(this.isSpinning === false) {\n return this;\n }\n\n clearInterval(this.id);\n this.id = undefined;\n\n if (clear) {\n this.clearLine(this.stream);\n }\n\n return this;\n};\n\nSpinner.prototype.clearLine = function(stream) {\n readline.clearLine(stream, 0);\n readline.cursorTo(stream, 0);\n\n return this;\n}\n\n// Helpers\n\nfunction isInt(value) {\n return (typeof value==='number' && (value%1)===0);\n}\n\nfunction mapToSpinner(value, spinners) {\n // Not an integer, return as strng\n if (!isInt(value)) {\n return value + '';\n }\n\n var length = Spinner.spinners.length;\n\n // Check if index is within bounds\n value = (value >= length) ? 0 : value;\n // If negative, count from the end\n value = (value < 0) ? length + value : value;\n\n return Spinner.spinners[value];\n}\n\nexports.Spinner = Spinner;\n","'use strict';\nconst fs = require('fs');\n\nlet isDocker;\n\nfunction hasDockerEnv() {\n\ttry {\n\t\tfs.statSync('/.dockerenv');\n\t\treturn true;\n\t} catch (_) {\n\t\treturn false;\n\t}\n}\n\nfunction hasDockerCGroup() {\n\ttry {\n\t\treturn fs.readFileSync('/proc/self/cgroup', 'utf8').includes('docker');\n\t} catch (_) {\n\t\treturn false;\n\t}\n}\n\nmodule.exports = () => {\n\tif (isDocker === undefined) {\n\t\tisDocker = hasDockerEnv() || hasDockerCGroup();\n\t}\n\n\treturn isDocker;\n};\n","'use strict';\nconst os = require('os');\nconst fs = require('fs');\nconst isDocker = require('is-docker');\n\nconst isWsl = () => {\n\tif (process.platform !== 'linux') {\n\t\treturn false;\n\t}\n\n\tif (os.release().toLowerCase().includes('microsoft')) {\n\t\tif (isDocker()) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t}\n\n\ttry {\n\t\treturn fs.readFileSync('/proc/version', 'utf8').toLowerCase().includes('microsoft') ?\n\t\t\t!isDocker() : false;\n\t} catch (_) {\n\t\treturn false;\n\t}\n};\n\nif (process.env.__IS_WSL_TEST__) {\n\tmodule.exports = isWsl;\n} else {\n\tmodule.exports = isWsl();\n}\n","'use strict';\nconst {promisify} = require('util');\nconst path = require('path');\nconst childProcess = require('child_process');\nconst fs = require('fs');\nconst isWsl = require('is-wsl');\nconst isDocker = require('is-docker');\n\nconst pAccess = promisify(fs.access);\nconst pReadFile = promisify(fs.readFile);\n\n// Path to included `xdg-open`.\nconst localXdgOpenPath = path.join(__dirname, 'xdg-open');\n\n/**\nGet the mount point for fixed drives in WSL.\n\n@inner\n@returns {string} The mount point.\n*/\nconst getWslDrivesMountPoint = (() => {\n\t// Default value for \"root\" param\n\t// according to https://docs.microsoft.com/en-us/windows/wsl/wsl-config\n\tconst defaultMountPoint = '/mnt/';\n\n\tlet mountPoint;\n\n\treturn async function () {\n\t\tif (mountPoint) {\n\t\t\t// Return memoized mount point value\n\t\t\treturn mountPoint;\n\t\t}\n\n\t\tconst configFilePath = '/etc/wsl.conf';\n\n\t\tlet isConfigFileExists = false;\n\t\ttry {\n\t\t\tawait pAccess(configFilePath, fs.constants.F_OK);\n\t\t\tisConfigFileExists = true;\n\t\t} catch (_) {}\n\n\t\tif (!isConfigFileExists) {\n\t\t\treturn defaultMountPoint;\n\t\t}\n\n\t\tconst configContent = await pReadFile(configFilePath, {encoding: 'utf8'});\n\t\tconst configMountPoint = /root\\s*=\\s*(.*)/g.exec(configContent);\n\n\t\tif (!configMountPoint) {\n\t\t\treturn defaultMountPoint;\n\t\t}\n\n\t\tmountPoint = configMountPoint[1].trim();\n\t\tmountPoint = mountPoint.endsWith('/') ? mountPoint : mountPoint + '/';\n\n\t\treturn mountPoint;\n\t};\n})();\n\nmodule.exports = async (target, options) => {\n\tif (typeof target !== 'string') {\n\t\tthrow new TypeError('Expected a `target`');\n\t}\n\n\toptions = {\n\t\twait: false,\n\t\tbackground: false,\n\t\tallowNonzeroExitCode: false,\n\t\t...options\n\t};\n\n\tlet command;\n\tlet {app} = options;\n\tlet appArguments = [];\n\tconst cliArguments = [];\n\tconst childProcessOptions = {};\n\n\tif (Array.isArray(app)) {\n\t\tappArguments = app.slice(1);\n\t\tapp = app[0];\n\t}\n\n\tif (process.platform === 'darwin') {\n\t\tcommand = 'open';\n\n\t\tif (options.wait) {\n\t\t\tcliArguments.push('--wait-apps');\n\t\t}\n\n\t\tif (options.background) {\n\t\t\tcliArguments.push('--background');\n\t\t}\n\n\t\tif (app) {\n\t\t\tcliArguments.push('-a', app);\n\t\t}\n\t} else if (process.platform === 'win32' || (isWsl && !isDocker())) {\n\t\tconst mountPoint = await getWslDrivesMountPoint();\n\n\t\tcommand = isWsl ?\n\t\t\t`${mountPoint}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe` :\n\t\t\t`${process.env.SYSTEMROOT}\\\\System32\\\\WindowsPowerShell\\\\v1.0\\\\powershell`;\n\n\t\tcliArguments.push(\n\t\t\t'-NoProfile',\n\t\t\t'-NonInteractive',\n\t\t\t'–ExecutionPolicy',\n\t\t\t'Bypass',\n\t\t\t'-EncodedCommand'\n\t\t);\n\n\t\tif (!isWsl) {\n\t\t\tchildProcessOptions.windowsVerbatimArguments = true;\n\t\t}\n\n\t\tconst encodedArguments = ['Start'];\n\n\t\tif (options.wait) {\n\t\t\tencodedArguments.push('-Wait');\n\t\t}\n\n\t\tif (app) {\n\t\t\t// Double quote with double quotes to ensure the inner quotes are passed through.\n\t\t\t// Inner quotes are delimited for PowerShell interpretation with backticks.\n\t\t\tencodedArguments.push(`\"\\`\"${app}\\`\"\"`, '-ArgumentList');\n\t\t\tappArguments.unshift(target);\n\t\t} else {\n\t\t\tencodedArguments.push(`\"${target}\"`);\n\t\t}\n\n\t\tif (appArguments.length > 0) {\n\t\t\tappArguments = appArguments.map(arg => `\"\\`\"${arg}\\`\"\"`);\n\t\t\tencodedArguments.push(appArguments.join(','));\n\t\t}\n\n\t\t// Using Base64-encoded command, accepted by PowerShell, to allow special characters.\n\t\ttarget = Buffer.from(encodedArguments.join(' '), 'utf16le').toString('base64');\n\t} else {\n\t\tif (app) {\n\t\t\tcommand = app;\n\t\t} else {\n\t\t\t// When bundled by Webpack, there's no actual package file path and no local `xdg-open`.\n\t\t\tconst isBundled = !__dirname || __dirname === '/';\n\n\t\t\t// Check if local `xdg-open` exists and is executable.\n\t\t\tlet exeLocalXdgOpen = false;\n\t\t\ttry {\n\t\t\t\tawait pAccess(localXdgOpenPath, fs.constants.X_OK);\n\t\t\t\texeLocalXdgOpen = true;\n\t\t\t} catch (_) {}\n\n\t\t\tconst useSystemXdgOpen = process.versions.electron ||\n\t\t\t\tprocess.platform === 'android' || isBundled || !exeLocalXdgOpen;\n\t\t\tcommand = useSystemXdgOpen ? 'xdg-open' : localXdgOpenPath;\n\t\t}\n\n\t\tif (appArguments.length > 0) {\n\t\t\tcliArguments.push(...appArguments);\n\t\t}\n\n\t\tif (!options.wait) {\n\t\t\t// `xdg-open` will block the process unless stdio is ignored\n\t\t\t// and it's detached from the parent even if it's unref'd.\n\t\t\tchildProcessOptions.stdio = 'ignore';\n\t\t\tchildProcessOptions.detached = true;\n\t\t}\n\t}\n\n\tcliArguments.push(target);\n\n\tif (process.platform === 'darwin' && appArguments.length > 0) {\n\t\tcliArguments.push('--args', ...appArguments);\n\t}\n\n\tconst subprocess = childProcess.spawn(command, cliArguments, childProcessOptions);\n\n\tif (options.wait) {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tsubprocess.once('error', reject);\n\n\t\t\tsubprocess.once('close', exitCode => {\n\t\t\t\tif (options.allowNonzeroExitCode && exitCode > 0) {\n\t\t\t\t\treject(new Error(`Exited with code ${exitCode}`));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tresolve(subprocess);\n\t\t\t});\n\t\t});\n\t}\n\n\tsubprocess.unref();\n\n\treturn subprocess;\n};\n","import * as open from 'open';\nimport { v4 as uuidv4 } from 'uuid';\nimport * as Debug from 'debug';\nimport { Spinner } from 'cli-spinner';\nimport * as snyk from '../../../lib';\nimport { verifyAPI } from './is-authed';\nimport { isCI } from '../../../lib/is-ci';\nimport { isDocker } from '../../../lib/is-docker';\nimport { args as argsLib } from '../../args';\nimport config from '../../../lib/config';\nimport { makeRequest } from '../../../lib/request';\nimport { CustomError } from '../../../lib/errors';\nimport { AuthFailedError } from '../../../lib/errors';\nimport { TokenExpiredError } from '../../../lib/errors/token-expired-error';\nimport { MisconfiguredAuthInCI } from '../../../lib/errors/misconfigured-auth-in-ci-error';\nimport { Payload } from '../../../lib/request/types';\nimport { getQueryParamsAsString } from '../../../lib/query-strings';\n\nconst apiUrl = new URL(config.API);\n// Ensure user gets redirected to the login page\nif (apiUrl.host.startsWith('api.')) {\n apiUrl.host = apiUrl.host.replace(/^api\\./, 'app.');\n}\nconst debug = Debug('snyk-auth');\nlet attemptsLeft = 0;\n\nfunction resetAttempts() {\n attemptsLeft = isDocker() ? 60 : 3 * 60;\n}\n\nasync function webAuth() {\n const token = uuidv4(); // generate a random key\n\n apiUrl.pathname = '/login';\n apiUrl.searchParams.append('token', token);\n let urlStr = apiUrl.toString();\n\n // It's not optimal, but I have to parse args again here. Alternative is reworking everything about how we parse args\n const args = [argsLib(process.argv).options];\n const utmParams = getQueryParamsAsString(args);\n if (utmParams) {\n urlStr += '&' + utmParams;\n }\n\n // suppress this message in CI\n if (!isCI()) {\n console.log(browserAuthPrompt(isDocker(), urlStr));\n } else {\n return Promise.reject(MisconfiguredAuthInCI());\n }\n const spinner = new Spinner('Waiting...');\n spinner.setSpinnerString('|/-\\\\');\n\n const ipFamily = await getIpFamily();\n\n try {\n spinner.start();\n if (!isDocker()) {\n await setTimeout(() => {\n open(urlStr);\n }, 0);\n }\n\n return await testAuthComplete(token, ipFamily);\n } finally {\n spinner.stop(true);\n }\n}\n\nasync function testAuthComplete(\n token: string,\n ipFamily?: number,\n): Promise<{ res; body }> {\n const payload: Partial = {\n body: {\n token,\n },\n url: config.API + '/verify/callback',\n json: true,\n method: 'post',\n };\n\n if (ipFamily) {\n payload.family = ipFamily;\n }\n\n return new Promise((resolve, reject) => {\n debug(payload);\n makeRequest(payload, (error, res, body) => {\n debug(error, (res || {}).statusCode, body);\n if (error) {\n return reject(error);\n }\n\n if (res.statusCode !== 200) {\n return reject(errorForFailedAuthAttempt(res, body));\n }\n\n // we have success\n if (body.api) {\n return resolve({\n res,\n body,\n });\n }\n\n // we need to wait and poll again in a moment\n setTimeout(() => {\n attemptsLeft--;\n if (attemptsLeft > 0) {\n return resolve(testAuthComplete(token, ipFamily));\n }\n\n reject(TokenExpiredError());\n }, 1000);\n });\n });\n}\n\nexport default async function auth(apiToken: string): Promise {\n let promise;\n resetAttempts();\n if (apiToken) {\n // user is manually setting the API token on the CLI - let's trust them\n promise = verifyAPI(apiToken);\n } else {\n promise = webAuth();\n }\n\n return promise.then((data) => {\n const res = data.res;\n const body = res.body;\n debug(body);\n\n if (res.statusCode === 200 || res.statusCode === 201) {\n snyk.config.set('api', body.api);\n return (\n '\\nYour account has been authenticated. Snyk is now ready to ' +\n 'be used.\\n'\n );\n }\n throw errorForFailedAuthAttempt(res, body);\n });\n}\n\n/**\n * Resolve an appropriate error for a failed attempt to authenticate\n *\n * @param res The response from the API\n * @param body The body of the failed authentication request\n */\nfunction errorForFailedAuthAttempt(res, body) {\n if (res.statusCode === 401 || res.statusCode === 403) {\n return AuthFailedError(body.userMessage, res.statusCode);\n } else {\n const userMessage = body && body.userMessage;\n const error = new CustomError(userMessage || 'Auth request failed');\n if (userMessage) {\n error.userMessage = userMessage;\n }\n error.code = res.statusCode;\n return error;\n }\n}\n\nasync function getIpFamily(): Promise<6 | undefined> {\n const family = 6;\n try {\n // Dispatch a FORCED IPv6 request to test client's ISP and network capability\n await makeRequest({\n url: config.API + '/verify/callback',\n family, // family param forces the handler to dispatch a request using IP at \"family\" version\n method: 'post',\n });\n return family;\n } catch (e) {\n return undefined;\n }\n}\n\nfunction browserAuthPrompt(isDocker: boolean, urlStr: string): string {\n if (isDocker) {\n return (\n '\\nTo authenticate your account, open the below URL in your browser.\\n' +\n 'After your authentication is complete, return to this prompt to ' +\n 'start using Snyk.\\n\\n' +\n urlStr +\n '\\n'\n );\n } else {\n return (\n '\\nNow redirecting you to our auth page, go ahead and log in,\\n' +\n \"and once the auth is complete, return to this prompt and you'll\\n\" +\n \"be ready to start using snyk.\\n\\nIf you can't wait use this url:\\n\" +\n urlStr +\n '\\n'\n );\n }\n}\n","import * as snyk from '../../../lib';\nimport config from '../../../lib/config';\nimport { makeRequest } from '../../../lib/request';\n\nexport function isAuthed() {\n const token = snyk.config.get('api');\n return verifyAPI(token).then((res: any) => {\n return res.body.ok;\n });\n}\n\nexport function verifyAPI(api) {\n const payload = {\n body: {\n api,\n },\n method: 'POST',\n url: config.API + '/verify/token',\n json: true,\n };\n\n return new Promise((resolve, reject) => {\n makeRequest(payload, (error, res, body) => {\n if (error) {\n return reject(error);\n }\n\n resolve({\n res,\n body,\n });\n });\n });\n}\n","import { CustomError } from './custom-error';\n\nexport function MisconfiguredAuthInCI() {\n const errorMsg =\n 'Snyk is missing auth token in order to run inside CI. You must include ' +\n 'your API token as an environment value: `SNYK_TOKEN=12345678`';\n\n const error = new CustomError(errorMsg);\n error.code = 401;\n error.strCode = 'noAuthInCI';\n error.userMessage = errorMsg;\n return error;\n}\n","import { CustomError } from './custom-error';\n\nexport function TokenExpiredError() {\n const errorMsg =\n 'Sorry, but your authentication token has now' +\n ' expired.\\nPlease try to authenticate again.';\n\n const error = new CustomError(errorMsg);\n error.code = 401;\n error.strCode = 'AUTH_TIMEOUT';\n error.userMessage = errorMsg;\n return error;\n}\n","const fs = require('fs');\n\nexport function isDocker(): boolean {\n return hasDockerEnv() || hasDockerCGroup();\n}\nfunction hasDockerEnv() {\n try {\n fs.statSync('/.dockerenv');\n return true;\n } catch (_) {\n return false;\n }\n}\n\nfunction hasDockerCGroup() {\n try {\n return fs.readFileSync('/proc/self/cgroup', 'utf8').includes('docker');\n } catch (_) {\n return false;\n }\n}\n","import * as url from 'url';\nimport * as os from 'os';\nimport { ArgsOptions } from './../cli/args';\nimport { isDocker } from './is-docker';\nimport { getIntegrationName, getIntegrationVersion } from './analytics/sources';\n\nexport function getQueryParamsAsString(args: ArgsOptions[]): string {\n const utm_source = process.env.SNYK_UTM_SOURCE || 'cli';\n const utm_medium = process.env.SNYK_UTM_MEDIUM || 'cli';\n const utm_campaign =\n process.env.SNYK_UTM_CAMPAIGN || getIntegrationName(args) || 'cli';\n const utm_campaign_content =\n process.env.SNYK_UTM_CAMPAIGN_CONTENT || getIntegrationVersion(args);\n const osType = os.type()?.toLowerCase();\n const docker = isDocker().toString();\n\n const queryParams = new url.URLSearchParams({\n utm_medium,\n utm_source,\n utm_campaign,\n utm_campaign_content,\n os: osType,\n docker,\n });\n\n // It may not be set and URLSearchParams won't filter out undefined values\n if (!utm_campaign_content) {\n queryParams.delete('utm_campaign_content');\n }\n\n return queryParams.toString();\n}\n"],"names":[],"sourceRoot":""}