Browse Source

Added TOTP Feature

master
Yiğit Çolakoğlu 4 years ago
parent
commit
1bb8e824c9
4 changed files with 2796 additions and 2 deletions
  1. +0
    -1
      bin/cli.js
  2. +2776
    -0
      package-lock.json
  3. +4
    -1
      package.json
  4. +16
    -0
      src/index.js

+ 0
- 1
bin/cli.js View File

@ -106,7 +106,6 @@ async function runBitwardenDmenu() {
oldestAllowedVaultSync, oldestAllowedVaultSync,
unsafeDebug unsafeDebug
}) })
return { lockBitwardenAfter: sessionTimeout, clearClipboardAfter } return { lockBitwardenAfter: sessionTimeout, clearClipboardAfter }
} catch (e) { } catch (e) {
if (e instanceof CancelError) { if (e instanceof CancelError) {


+ 2776
- 0
package-lock.json
File diff suppressed because it is too large
View File


+ 4
- 1
package.json View File

@ -24,8 +24,11 @@
}, },
"dependencies": { "dependencies": {
"@bitwarden/cli": "^1.12.1", "@bitwarden/cli": "^1.12.1",
"bitwarden-dmenu": "^1.5.9",
"clipboardy": "^1.2.3", "clipboardy": "^1.2.3",
"minimist": "^1.2.5"
"minimist": "^1.2.5",
"otpauth": "^6.2.3",
"otpauth-uri-parser": "^1.0.1"
}, },
"engines": { "engines": {
"node": ">=8" "node": ">=8"


+ 16
- 0
src/index.js View File

@ -5,6 +5,8 @@ const dmenuRun = require('./executable-wrappers/dmenu')
const bwRun = require('./executable-wrappers/bitwarden-cli') const bwRun = require('./executable-wrappers/bitwarden-cli')
const obfuscate = require('./util/obfuscate/object') const obfuscate = require('./util/obfuscate/object')
const packageJson = require('../package.json') const packageJson = require('../package.json')
const parseOtpauthURI = require('otpauth-uri-parser');
const OTPAuth = require('otpauth')
class BitwardenDmenu { class BitwardenDmenu {
constructor(args) { constructor(args) {
@ -91,6 +93,19 @@ const getAccounts = ({ bwListArgs }, session) => {
return list return list
} }
const getTOTP = (totpURL) => {
if(!totpURL){
return ""
}
const parsed = parseOtpauthURI(totpURL);
let totp = new OTPAuth.TOTP({
...parsed.label,
...parsed.query,
});
return totp.generate()
}
/** /**
* choose one account with dmenu * choose one account with dmenu
*/ */
@ -116,6 +131,7 @@ const chooseField = async ({ dmenuArgs }, selectedAccount) => {
password: selectedAccount.login.password, password: selectedAccount.login.password,
username: selectedAccount.login.username, username: selectedAccount.login.username,
notes: selectedAccount.notes, notes: selectedAccount.notes,
TOTP: getTOTP(selectedAccount.login.totp),
...(selectedAccount.fields || []).reduce( ...(selectedAccount.fields || []).reduce(
(acc, f) => ({ (acc, f) => ({
...acc, ...acc,


Loading…
Cancel
Save