Run some sanity checks/validations on the private key input. Cannot save it unless the field is valid.

This commit is contained in:
Ryan Breen
2023-02-06 00:06:27 -05:00
parent 843278faef
commit 2aabd443e1
4 changed files with 22 additions and 3 deletions

View File

@@ -206,3 +206,10 @@ export function humanPermission(p) {
return 'Unknown';
}
}
export function validateKey(key) {
const hexMatch = /^[\da-f]{64}$/i.test(key);
const b32Match = /^nsec1[qpzry9x8gf2tvdw0s3jn54khce6mua7l]{58}$/.test(key);
return hexMatch || b32Match;
}