const getUserInfo = () => { try { return os.userInfo(); } catch (e) { return {}; } }
test('get username using NSProcessInfo, convert to javascript string and compare the value to the username given by `os.userInfo()`', t => { const NSProcessInfo = objc.NSProcessInfo; const os = require('os'); const processInfo = NSProcessInfo.processInfo(); const username = processInfo.userName(); t.is(String(username), os.userInfo().username); });
router.get('/api/getUsername', (req, res) => { res.send({username: os.userInfo().username}); })
$('#send').click(() => { let textarea = $('#textarea').val(); console.log(os.userInfo().username); console.log(textarea); console.log(os.networkInterfaces().en0[1].address); http.get(`http://localhost:${port}/?message=${encodeURIComponent(textarea)}`, (res) => { res.setEncoding('utf8'); let rawData = ''; res.on('data', (chunk) => { rawData += chunk }); res.on('end', () => { console.log(rawData); }) }) });
function getSecretFromCredentialStore(ssoAppName) { try { switch (process.platform) { case "win32": console.log(`Getting application secret for ${ssoAppName} from Windows Credential Store`); const getSecretFromWindowsStoreCommand = `powershell -ExecutionPolicy Bypass -File "${defaults.getSecretCommandPath}" "${ssoAppName}" "${os.userInfo().username}"`; return childProcess.execSync(getSecretFromWindowsStoreCommand, { stdio: "pipe" }).toString(); case "darwin": console.log(`Getting application secret for ${ssoAppName} from Mac OS Keychain`); const getSecretFromMacStoreCommand = `sudo security find-generic-password -a ${os.userInfo().username} -s ${ssoAppName} -w`; return childProcess.execSync(getSecretFromMacStoreCommand, { stdio: "pipe" }).toString();; default: throw new Error(`Platform not supported: ${process.platform}`); } } catch (err) { throw new Error(`Unable to retrieve secret for ${ssoAppName} to Windows Credential Store. \n${err}`); } }
router.use('/', (req, res) => { const app = req.app let response = `<p>${app.get('dirName')}</p> <p>${app.get('ffmpegVersion')}</p> <p>${app.get('ffmpegPath')}</p> <p>${os.arch()}</p> <p>${os.cpus().length}</p> <p>${os.freemem}</p> <p>${os.loadavg()}</p> <p>${os.platform()}</p> <p>${os.release}</p> <p>${os.uptime}</p> <p>${util.inspect(os.userInfo())}</p> <p>${os.endianness()}</p> <p>${os.homedir}</p> <p>${os.hostname}</p> <p>${os.tmpdir()}</p> <p>${os.type}</p> <p>${os.totalmem}</p> <p>${(os.freemem - os.totalmem) / os.totalmem}</p> <p>${os.freemem / os.totalmem}</p>` res.status(200).send(response) })
/** * The EACCES fallback is a workaround for npm's `sudo` behavior, where * it drops the permissions before invoking any child processes (like * node-gyp). So what happens is the "nobody" user doesn't have * permission to create the dev dir. As a fallback, make the tmpdir() be * the dev dir for this installation. This is not ideal, but at least * the compilation will succeed... */ function eaccesFallback (err) { var noretry = '--node_gyp_internal_noretry' if (argv.indexOf(noretry) !== -1) { return cb(err) } var tmpdir = os.tmpdir() gyp.devDir = path.resolve(tmpdir, '.node-gyp') var userString = '' try { // os.userInfo can fail on some systems, it's not critical here userString = ` ("${os.userInfo().username}")` } catch (e) {} log.warn('EACCES', 'current user%s does not have permission to access the dev dir "%s"', userString, devDir) log.warn('EACCES', 'attempting to reinstall using temporary dev dir "%s"', gyp.devDir) if (process.cwd() === tmpdir) { log.verbose('tmpdir == cwd', 'automatically will remove dev files after to save disk space') gyp.todo.push({ name: 'remove', args: argv }) } gyp.commands.install([noretry].concat(argv), cb) }
function addSecretToCredentialStore(ssoAppName, secret) { try { switch (process.platform) { case "win32": console.log(`Adding application secret for ${ssoAppName} to Windows Credential Store`); const addSecretToWindowsStoreCommand = `powershell -ExecutionPolicy Bypass -File "${defaults.addSecretCommandPath}" "${ssoAppName}" "${os.userInfo().username}" "${secret}"`; childProcess.execSync(addSecretToWindowsStoreCommand, { stdio: "pipe" }); break; case "darwin": console.log(`Adding application secret for ${ssoAppName} to Mac OS Keychain`); const addSecretToMacStoreCommand = `sudo security add-generic-password -a ${os.userInfo().username} -s "${ssoAppName}" -w "${secret}"`; childProcess.execSync(addSecretToMacStoreCommand, { stdio: "pipe" }); break; default: throw new Error(`Platform not supported: ${process.platform}`); } } catch (err) { throw new Error(`Unable to add secret for ${ssoAppName} to Windows Credential Store. \n${err}`); } }
var info = void 0; try { info = os_2.userInfo();
let info; try { info = userInfo(); } catch (e) {
if (ego_helpers.isEmptyString(author)) { try { author = os.userInfo() .username; } catch { }
/** * Get OS user info (safe-mode) * * @returns */ function getUserInfo() { try { return os.userInfo(); } catch (e) { /* istanbul ignore next */ return {}; } }
// get OS username app.get('/api/getUsername', (req, res) => res.send({ username: os.userInfo().username }));
app.get('/api/getUsername', (req, res) => res.send({ username: os.userInfo().username }));