mirror of
https://github.com/shuaiplus/nodewarden.git
synced 2026-06-20 21:00:41 +00:00
feat: add uriChecksum handling and sha256Base64 function for enhanced security
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { base64ToBytes, decryptBw, decryptBwFileData, decryptStr, encryptBw, encryptBwFileData } from '../crypto';
|
||||
import { base64ToBytes, decryptBw, decryptBwFileData, decryptStr, encryptBw, encryptBwFileData, sha256Base64 } from '../crypto';
|
||||
import type {
|
||||
Cipher,
|
||||
CipherPasswordHistoryEntry,
|
||||
@@ -574,12 +574,18 @@ async function encryptUris(
|
||||
entry?.extra && typeof entry.extra === 'object'
|
||||
? { ...entry.extra }
|
||||
: {};
|
||||
if (String(entry?.originalUri || '').trim() !== trimmed) {
|
||||
const canReuseChecksum = String(entry?.originalUri || '').trim() === trimmed;
|
||||
if (!canReuseChecksum) {
|
||||
delete preservedExtra.uriChecksum;
|
||||
}
|
||||
const preservedChecksum = typeof preservedExtra.uriChecksum === 'string' && looksLikeCipherString(preservedExtra.uriChecksum)
|
||||
? preservedExtra.uriChecksum
|
||||
: null;
|
||||
const uriChecksum = preservedChecksum || await encryptTextValue(await sha256Base64(trimmed), enc, mac);
|
||||
out.push({
|
||||
...preservedExtra,
|
||||
uri: await encryptTextValue(trimmed, enc, mac),
|
||||
uriChecksum,
|
||||
match: typeof entry?.match === 'number' && Number.isFinite(entry.match) ? entry.match : null,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user