Restore wallet URI validation helper

This commit is contained in:
thePR0M3TH3AN committed 2025-10-08 07:03:56 -04:00
1 parent a43f8e634d
commit 8855fac640
1 file changed
+25
+25
View File
@@ -2747,6 +2747,31 @@ class Application {
return candidate.length > 0;
}
validateWalletUri(uri, { requireValue = false } = {}) {
const value = typeof uri === "string" ? uri.trim() : "";
if (!value) {
if (requireValue) {
return {
valid: false,
sanitized: "",
message: "Enter a wallet connect URI before continuing.",
};
}
return { valid: true, sanitized: "" };
}
if (!value.toLowerCase().startsWith(NWC_URI_SCHEME)) {
return {
valid: false,
sanitized: value,
message: `Wallet URI must start with ${NWC_URI_SCHEME}.`,
};
}
return { valid: true, sanitized: value };
}
isUserLoggedIn() {
return Boolean(this.normalizeHexPubkey(this.pubkey));
}