plasalid 0.3.2 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -4,7 +4,7 @@ import type { StoredPassword } from "./password-store.js";
|
|
|
4
4
|
* (mupdf calls, prompts, DB reads) live in the orchestrator; this module only
|
|
5
5
|
* encodes the transition logic so it can be exhaustively unit-tested.
|
|
6
6
|
*/
|
|
7
|
-
export declare const MAX_PASSWORD_ATTEMPTS =
|
|
7
|
+
export declare const MAX_PASSWORD_ATTEMPTS = 10;
|
|
8
8
|
export type UnlockOutcome = {
|
|
9
9
|
kind: "plaintext";
|
|
10
10
|
} | {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* (mupdf calls, prompts, DB reads) live in the orchestrator; this module only
|
|
4
4
|
* encodes the transition logic so it can be exhaustively unit-tested.
|
|
5
5
|
*/
|
|
6
|
-
export const MAX_PASSWORD_ATTEMPTS =
|
|
6
|
+
export const MAX_PASSWORD_ATTEMPTS = 10;
|
|
7
7
|
export function isTerminal(state) {
|
|
8
8
|
return state.kind === "done" || state.kind === "failed";
|
|
9
9
|
}
|
package/dist/scanner/unlock.js
CHANGED
|
@@ -3,7 +3,7 @@ import { basename } from "path";
|
|
|
3
3
|
import { config } from "../config.js";
|
|
4
4
|
import { statusSpinner } from "../cli/ux.js";
|
|
5
5
|
import { findCandidates, savePassword, recordUse, suggestPattern, } from "./password-store.js";
|
|
6
|
-
import { transition, isTerminal, } from "./state-machine.js";
|
|
6
|
+
import { transition, isTerminal, MAX_PASSWORD_ATTEMPTS, } from "./state-machine.js";
|
|
7
7
|
import { isEncrypted, unlock } from "./pdf-unlock.js";
|
|
8
8
|
/**
|
|
9
9
|
* Drive the pure unlock state machine to a terminal state, returning the
|
|
@@ -59,7 +59,7 @@ async function stepUnlock(state, ctx) {
|
|
|
59
59
|
spinner.succeed("Decrypted.");
|
|
60
60
|
return { kind: "UNLOCK_OK", decrypted: result.decrypted, password };
|
|
61
61
|
}
|
|
62
|
-
spinner.fail(`Incorrect password (attempt ${state.attempt}
|
|
62
|
+
spinner.fail(`Incorrect password (attempt ${state.attempt}/${MAX_PASSWORD_ATTEMPTS}).`);
|
|
63
63
|
return { kind: "UNLOCK_FAIL" };
|
|
64
64
|
}
|
|
65
65
|
default:
|
|
@@ -90,7 +90,7 @@ async function tryStoredPasswords(bytes, candidates) {
|
|
|
90
90
|
async function promptForPassword(fileName, attempt) {
|
|
91
91
|
const message = attempt === 1
|
|
92
92
|
? `This PDF is encrypted. Password for ${fileName}:`
|
|
93
|
-
: `Password for ${fileName} (attempt ${attempt}
|
|
93
|
+
: `Password for ${fileName} (attempt ${attempt}/${MAX_PASSWORD_ATTEMPTS}):`;
|
|
94
94
|
const { password } = await inquirer.prompt([
|
|
95
95
|
{ type: "password", name: "password", mask: "*", message },
|
|
96
96
|
]);
|