-
Notifications
You must be signed in to change notification settings - Fork 3
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
5 changed files
with
39 additions
and
14 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,30 @@ | ||
import { masa } from "../../helpers/masa"; | ||
import * as readline from "readline"; | ||
import { stdin as input, stdout as output } from "process"; | ||
|
||
const read = (question: string): Promise<string> => { | ||
const rl = readline.createInterface({ input, output }); | ||
|
||
return new Promise((resolve) => { | ||
rl.question(question, (result) => { | ||
rl.close(); | ||
return resolve(result); | ||
}); | ||
}); | ||
}; | ||
|
||
export const create = async (phoneNumber: string) => { | ||
await masa.twofa.create(phoneNumber); | ||
if (await masa.session.checkLogin()) { | ||
const address = await masa.config.wallet.getAddress(); | ||
console.log(`Creating 2FA for phone number: '${phoneNumber}'`); | ||
|
||
const identityId = await masa.identity.load(address); | ||
if (!identityId) return; | ||
|
||
await masa.twofa.generate(phoneNumber); | ||
const code = await read( | ||
"The code that has been sent to your Phonenumber: " | ||
); | ||
await masa.twofa.create(phoneNumber, code); | ||
} | ||
}; |
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