Files
buzz/desktop/src/shared/api/inviteHelpers.ts
Bradley Axen 2e529aab75 feat: relay invite links (mint + claim + landing page + deep link) (#1668)
Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
Signed-off-by: npub1k766u8wq088nkr9vy94uqlh9kmw5956g593a7xk7cks7frhgctmsr00p27 <b7b5ae1dc079cf3b0cac216bc07ee5b6dd42d348a163df1adec5a1e48ee8c2f7@sprout-oss.stage.blox.sqprod.co>
Co-authored-by: npub1k766u8wq088nkr9vy94uqlh9kmw5956g593a7xk7cks7frhgctmsr00p27 <b7b5ae1dc079cf3b0cac216bc07ee5b6dd42d348a163df1adec5a1e48ee8c2f7@sprout-oss.stage.blox.sqprod.co>
Co-authored-by: Will Pfleger <pfleger.will@gmail.com>
2026-07-10 12:06:35 -07:00

17 lines
638 B
TypeScript

export const INVITE_EXPIRED_ERROR = "invite_expired";
/** Convert a ws(s) relay URL to its http(s) equivalent. */
export function relayHttpFromWs(wsUrl: string): string {
if (wsUrl.startsWith("wss://")) return `https://${wsUrl.slice(6)}`;
if (wsUrl.startsWith("ws://")) return `http://${wsUrl.slice(5)}`;
throw new Error(`Expected ws:// or wss:// relay URL, got: ${wsUrl}`);
}
export function inviteErrorMessage(error: unknown): string {
return error instanceof Error ? error.message : `${error}`;
}
export function isInviteExpiredError(error: unknown): boolean {
return inviteErrorMessage(error) === INVITE_EXPIRED_ERROR;
}