Skip to content

Commit

Permalink
allow user to enter existing session id
Browse files Browse the repository at this point in the history
  • Loading branch information
hfxbse committed May 1, 2024
1 parent 119ae1d commit 0850f13
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,26 @@ async function twoFactor({verification, info}: {
}
}

async function readExistingSessionId(): Promise<SessionData> {
const sessionId = await prompt.password({message: "Session id: "})

return {
id: sessionId,
user: {
id: parseInt(sessionId.split("%")[0], 10)
}
}
}


try {
console.dir(await authenticate())
const existingSession = await prompt.confirm({message: "Use an existing session id?", default: false});

const session: SessionData = await (!existingSession ? authenticate() : readExistingSessionId())

if (await prompt.confirm({message: "Show session data?", default: false})) {
console.dir({session})
}
} catch (e) {
if (!(e instanceof ExitPromptError)) {
console.error(e)
Expand Down

0 comments on commit 0850f13

Please sign in to comment.