26 lines
810 B
JavaScript
26 lines
810 B
JavaScript
|
"use strict";
|
||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||
|
exports.assign = void 0;
|
||
|
const promisified_functions_1 = require("../../utils/promisified-functions");
|
||
|
let cached = null;
|
||
|
async function queryOSForCredential(cmd) {
|
||
|
try {
|
||
|
const { stdout } = await (0, promisified_functions_1.exec)(cmd);
|
||
|
return stdout.replace(/\s/g, '');
|
||
|
}
|
||
|
catch (err) {
|
||
|
return '';
|
||
|
}
|
||
|
}
|
||
|
async function assign(credentials) {
|
||
|
if (!cached) {
|
||
|
cached = {
|
||
|
domain: await queryOSForCredential('echo %userdomain%'),
|
||
|
workstation: await queryOSForCredential('hostname'),
|
||
|
};
|
||
|
}
|
||
|
credentials.domain = credentials.domain || cached.domain;
|
||
|
credentials.workstation = credentials.workstation || cached.workstation;
|
||
|
}
|
||
|
exports.assign = assign;
|