From 0850f139a2bced3597ba148d7ff5da43fa9f37c5 Mon Sep 17 00:00:00 2001 From: Fabian Haas <29468630+hfxbse@users.noreply.github.com> Date: Thu, 25 Apr 2024 16:33:14 +0200 Subject: [PATCH] allow user to enter existing session id --- src/index.ts | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index e9de4e3..1fcccb4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -48,8 +48,26 @@ async function twoFactor({verification, info}: { } } +async function readExistingSessionId(): Promise { + 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)