diff --git a/package.json b/package.json index a6fba92..cc8152b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@dashlane/cli", - "version": "6.2447.1", + "version": "6.2447.2", "description": "Manage your Dashlane vault through a CLI tool", "type": "module", "main": "dist/index.cjs", diff --git a/src/cliVersion.ts b/src/cliVersion.ts index d94bd6c..28dd277 100644 --- a/src/cliVersion.ts +++ b/src/cliVersion.ts @@ -1,6 +1,6 @@ import { CliVersion } from './types.js'; -export const CLI_VERSION: CliVersion = { major: 6, minor: 2447, patch: 1 }; +export const CLI_VERSION: CliVersion = { major: 6, minor: 2447, patch: 2 }; export const breakingChangesVersions: CliVersion[] = []; export const cliVersionToString = (version: CliVersion): string => { diff --git a/src/command-handlers/passwords.ts b/src/command-handlers/passwords.ts index b2def9b..662e4ad 100644 --- a/src/command-handlers/passwords.ts +++ b/src/command-handlers/passwords.ts @@ -48,7 +48,7 @@ export const runPassword = async ( result = selectedCredential.password; break; case 'otp': - if (!selectedCredential.otpSecret || !selectedCredential.otpUrl) { + if (!selectedCredential.otpSecret && !selectedCredential.otpUrl) { throw new Error('No OTP found for this credential.'); } if (selectedCredential.otpSecret) { diff --git a/src/index.ts b/src/index.ts index 6e6ba32..972dca4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,11 +1,14 @@ #!/usr/bin/env node import { Command } from 'commander'; +import process from 'process'; import { cliVersionToString, CLI_VERSION } from './cliVersion.js'; import { rootCommands } from './commands/index.js'; import { initDeviceCredentials, initStagingCheck, initTeamDeviceCredentials } from './utils/index.js'; import { errorColor, initLogger } from './logger.js'; +process.removeAllListeners('warning'); + const debugLevel = process.argv.indexOf('--debug') !== -1 ? 'debug' : 'info'; initLogger({ debugLevel }); diff --git a/src/modules/crypto/otpauth.ts b/src/modules/crypto/otpauth.ts index c34d3ed..6de4b85 100644 --- a/src/modules/crypto/otpauth.ts +++ b/src/modules/crypto/otpauth.ts @@ -13,8 +13,8 @@ interface Otpauth { secret: string; algorithm: HashAlgorithms; digits: number; - period: number; - counter: number; + period?: number; + counter?: number; } const matchAlgorithm = (algorithm: string): HashAlgorithms => { @@ -40,9 +40,9 @@ const parseOtpauth = (uri: string): Otpauth => { issuer: searchParams.get('issuer') ?? '', secret: searchParams.get('secret') ?? '', algorithm: matchAlgorithm(searchParams.get('algorithm') ?? 'SHA1'), - digits: Number(searchParams.get('digits') ?? 0), - period: Number(searchParams.get('period') ?? 0), - counter: Number(searchParams.get('counter') ?? 0), + digits: Number(searchParams.get('digits') ?? 6), + period: Number(searchParams.get('period')), + counter: Number(searchParams.get('counter')), }; }; @@ -66,6 +66,9 @@ export const generateOtpFromUri = (uri: string): GenerateOtpOutput => { }; return { token: authenticator.generate(otpauth.secret), remainingTime: authenticator.timeRemaining() }; case 'hotp': + if (otpauth.counter === undefined) { + throw new Error('Counter is required for HOTP'); + } hotp.options = { algorithm: otpauth.algorithm, digits: otpauth.digits }; return { token: hotp.generate(otpauth.secret, otpauth.counter), remainingTime: null }; default: