-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
51 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,29 @@ | ||
import * as prompt from '@inquirer/prompts'; | ||
import {encryptPassword, fetchVerification, login} from "./instagram"; | ||
import {ExitPromptError} from "@inquirer/prompts"; | ||
|
||
|
||
async function authenticate() { | ||
const verification = await fetchVerification() | ||
|
||
while (true) { | ||
try { | ||
const user = await prompt.input({message: "Instagram username, phone number, or email: "}) | ||
const password = await prompt.password({message: "Password: "}) | ||
const user = await prompt.input({message: "Instagram username, phone number, or email: "}) | ||
const password = await prompt.password({message: "Password: "}) | ||
|
||
const encryptedPassword = await encryptPassword({password, key: verification.key}) | ||
const encryptedPassword = await encryptPassword({password, key: verification.key}) | ||
|
||
try { | ||
return await login({user, password: encryptedPassword, verification}) | ||
} catch (e) { | ||
console.error((e as Error).message) | ||
} | ||
} | ||
} | ||
|
||
const sessionId = await authenticate() | ||
console.dir({sessionId}) | ||
try { | ||
console.dir({sessionId: await authenticate()}) | ||
} catch (e) { | ||
if (!(e instanceof ExitPromptError)) { | ||
console.error(e) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters