mirror of
https://github.com/block/buzz.git
synced 2026-10-27 12:40:30 +00:00
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>
17 lines
638 B
TypeScript
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;
|
|
}
|