Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion showcase/compass-guarded-transfer/scripts/run-transfer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ export function normalizeInput(input) {
if (!Number.isFinite(amountUsd) || amountUsd < 0) stop("amountUsd policy input must be finite");
const lamports = solToLamports(input.amountSol);
if (lamports <= 0 || lamports > MAX_LAMPORTS) stop("amount must be greater than 0 and at most 0.001 SOL");
if (typeof input.compassUrl !== "string" || !input.compassUrl.startsWith("https://")) stop("Compass HTTPS URL is required");
let compassParsed;
try { compassParsed = new URL(input.compassUrl); } catch { stop("Compass HTTPS URL is required"); }
if (compassParsed.protocol !== "https:") stop("Compass HTTPS URL is required");
const compassHost = compassParsed.hostname;
if (/^(localhost|.*\.local)$/i.test(compassHost) || /^(127\.|10\.|192\.168\.|172\.(1[6-9]|2\d|3[01])\.|169\.254\.|0\.)/.test(compassHost) || compassHost === "[::1]") stop("Compass URL hostname is not allowed");
return { recipient: input.recipient, amountSol: String(input.amountSol), lamports, amountUsd, cluster: "devnet", compassUrl: input.compassUrl.replace(/\/$/, ""), apiKey: input.apiKey };
}

Expand Down
Loading