Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (!argv.username) {
const { username } = await inquirer.prompt({
name: "username",
message: "Instagram Username: "
});
_username = username;
} else {
_username = argv.username;
}
device = new Client.Device(`instagram.com/${_username}`);
storage = argv.persist
? new Client.CookieFileStorage(
__dirname + ("/ig-cookie." + _username + ".json")
)
: new Client.CookieMemoryStorage();
let _password;
if (!argv.password) {
const { password } = await inquirer.prompt({
name: "password",
message: "Instagram password: ",
type: "password"
});
_password = password;
} else {
_password = argv.password;
}
const loginSpinner = ora(`Logging in as ${_username}`).start();
let session;
const getCookieStorage = (filePath) => {
let storage;
let username;
if (canUseFileStorage()) {
if (!filePath && (username = guessUsername())) {
filePath = `${username}.json`
}
if (filePath) storage = new Client.CookieFileStorage(`${buildAndGetStoragePath()}/${filePath}`);
} else {
storage = new Client.CookieMemoryStorage();
}
return storage;
}