export const AUDIENCE = 'https://solmate.io'; // Kept separate from every HTTPS origin so a previous grant can never become universal. export const ALL_APPS = 'urn:solmate:delegation:all-apps:v1'; export const LEGACY_MAIL = 'https://wagmimail.io'; export function siteOrigin(value) { let url; try { url = new URL(String(value).trim()); } catch {} if (!url || url.protocol !== 'https:' || url.username || url.password || url.pathname !== '/' || url.href !== url.origin + '/') { throw new Error('Enter an HTTPS website origin such as https://your-app.example, without a page path.'); } return url.origin; } export function grantAudience(origin = ALL_APPS) { return origin === ALL_APPS ? ALL_APPS : siteOrigin(origin); } export function audienceLabel(origin) { return origin === ALL_APPS ? 'All integrated apps' : origin; } export function appPath(value = '/access') { if (value === '/') return value; if (typeof value !== 'string' || !/^\/[a-zA-Z0-9_-]+(?:\/[a-zA-Z0-9_-]+)*$/.test(value)) { throw new Error('Use a page path such as /access or /members/enter.'); } return value; }