add https validation

This commit is contained in:
Blake Kaufman
2026-05-12 07:59:31 -04:00
parent f985fc07a8
commit f13e593495
4 changed files with 20 additions and 4 deletions
@@ -1,4 +1,5 @@
import { InputTypes } from 'bitcoin-address-parser';
import { isHTTPS } from '../../../../../functions/lnurl/ishttps';
export async function getLNAddressForLiquidPayment(
paymentInfo,
@@ -24,6 +25,8 @@ export async function getLNAddressForLiquidPayment(
console.log('Generated URL:', url);
if (!isHTTPS(url)) throw new Error('LNURL must use HTTPS');
const response = await fetch(url);
if (!response.ok) {
@@ -1,6 +1,7 @@
import { crashlyticsLogReport } from '../../../../../functions/crashlyticsLogs';
import { sparkReceivePaymentWrapper } from '../../../../../functions/spark/payments';
import { getSparkLightningPaymentStatus } from '../../../../../functions/spark';
import { isHTTPS } from '../../../../../functions/lnurl/ishttps';
export default async function processLNUrlWithdraw(input, context) {
const { setLoadingMessage, currentWalletMnemoinc, t, sendWebViewRequest } =
@@ -29,6 +30,8 @@ export default async function processLNUrlWithdraw(input, context) {
callbackUrl.searchParams.set('k1', input.data.k1);
callbackUrl.searchParams.set('pr', invoice.invoice);
if (!isHTTPS(callbackUrl.toString())) throw new Error('LNURL must use HTTPS');
const callbackResponse = await fetch(callbackUrl.toString());
const responseData = await callbackResponse.json();
+6 -4
View File
@@ -1,17 +1,19 @@
import {decodeLNURL} from './bench32Formmater';
import { decodeLNURL } from './bench32Formmater';
import { isHTTPS } from './ishttps';
export default async function getLNURLDetails(lnurl) {
try {
let fetchString = '';
const decodedLNURL = decodeLNURL(lnurl);
if (decodedLNURL) fetchString = decodedLNURL;
else {
if (decodedLNURL) {
if (!isHTTPS(decodedLNURL)) throw new Error('LNURL must use HTTPS');
fetchString = decodedLNURL;
} else {
const [username, domain] = lnurl.split('@');
console.log(username, domain);
fetchString = `https://${domain}/.well-known/lnurlp/${username}`;
}
console.log(fetchString);
const response = await fetch(fetchString);
const data = await response.json();
+8
View File
@@ -0,0 +1,8 @@
export function isHTTPS(fetchString) {
try {
return fetchString.startsWith('https://');
} catch (err) {
console.log('Error deternimming if url is https');
return false;
}
}