declare const ACTIVE_ORG_COOKIE = "politogy_active_org"; declare const ACTIVE_ORG_QUERY_PARAM = "org"; declare function isOrgId(v: unknown): v is string; /** * Read the shared active-org cookie (browser only; null on server or unset). * @deprecated v2 apps read the org from the token claims (`orgClaimsFromToken`). * The cookie stays written during rollout for apps not yet on the token path. */ declare function readActiveOrgCookie(): string | null; declare function writeActiveOrgCookie(orgId: string): void; /** * Read the `?org=` selector from a URL search string (full UUID only). Accepts a * `location.search`-style string or a full URL. */ declare function readActiveOrgFromUrl(search: string | null | undefined): string | null; /** * Resolve the active org with the cross-app precedence: * 1. `?org=` in the current URL (explicit per-request selector) * 2. the `.politogyvrm.com` cookie (last used, cross-subdomain) * 3. null → let the app fall back to the chrome-API default (earliest-joined) * Pass `search` on the server (from the request URL); it defaults to * `window.location.search` in the browser. * @deprecated v2 apps use the token `org_id` claim plus `readOrgSelectorFromUrl` * as a per-tab override only. */ declare function resolveActiveOrg(search?: string | null): string | null; /** The canonical `?org=` query fragment for a full org id (no leading `?`/`&`). */ declare function activeOrgParam(orgId: string | null | undefined): string; /** * Return `url` with `?org=` set/replaced. Used by the shared chrome to * stamp the active org onto every route so it is always present in the address * bar. Leaves the URL unchanged when `orgId` is not a valid id. */ declare function withActiveOrgParam(url: string, orgId: string | null | undefined): string; declare const ORG_ID_QUERY_PARAM = "org_id"; declare const ORG_ID_TAIL_LENGTH = 7; /** The URL form of an org id: the last 7 chars of the uuid, lower case. */ declare function orgIdTail(orgId: string | null | undefined): string | null; /** A full uuid, the 7-char tail, or the legacy 6-char tail. */ declare function isOrgSelector(v: unknown): v is string; /** * Resolve a selector against the user's own org list: exact uuid first, then a * unique 7-char tail, then a unique 6-char tail. Ambiguous or no match → null * (the IdP selector rules, so the shell never picks an org the IdP would not). */ declare function matchOrgSelector(selector: string | null | undefined, orgs: readonly T[]): T | null; /** * Read the per-tab org override from a URL: `org_id` (spec), else the legacy * `org`. Returns the raw selector (uuid or tail), or null. Never a source for * the shared active org. */ declare function readOrgSelectorFromUrl(search: string | null | undefined): string | null; /** * Return `url` with `org_id=<7-char tail>` set and any legacy `org=` removed. * Leaves the URL unchanged when `orgId` is not a full uuid. */ declare function withOrgIdParam(url: string, orgId: string | null | undefined): string; type OrgClaims = { orgId: string; orgRole: string | null; }; /** Pick `org_id` / `org_role` out of a token claim set. */ declare function orgClaimsFrom(claims: unknown): OrgClaims | null; /** * Read `org_id` / `org_role` from a JWT payload WITHOUT verifying it. For * display and routing only: the app server verifies the token (JWKS) and every * authorization decision keys on the verified claim, never on this. */ declare function orgClaimsFromToken(token: string | null | undefined): OrgClaims | null; /** The IdP base for the current environment (staging host → staging IdP). */ declare function authBaseUrl(): string; /** * The Settings app base for the current environment (staging host → staging * Settings). Organization settings, onboarding, activation and subscription & * billing live here (Reference/UI-Platform "Retirement of app.politogyvrm.com"). */ declare function settingsBaseUrl(): string; declare class ActiveOrgSwitchError extends Error { readonly status: number; constructor(status: number, message: string); } /** * Switch the SHARED active org on the IdP: `POST {auth}/api/active-org`. The * IdP checks membership against VRM Core and updates the SSO session; the * caller then re-exchanges (server) for tokens carrying the new `org_id`. * Also mirrors the legacy cookie so apps not yet on v2 follow the switch. * Throws `ActiveOrgSwitchError` (403 = not a member, 401 = no SSO session). */ declare function switchActiveOrg(orgId: string, opts?: { authBaseUrl?: string; fetch?: typeof fetch; }): Promise; /** * URL-sync rule for the address-bar org selector. Returns the new href, or * null when nothing should be written. A bare URL (no `org_id`, no legacy * `org`) stays bare: the shell must never inject `org_id` on its own, because * a self-injected selector then acts as a per-tab override and beats the token * org and the cross-app `politogy_active_org` trigger. Only a selector the user * brought (or a real switch put there) is canonicalized to the current org. */ declare function syncOrgIdInUrl(href: string, orgId: string | null | undefined): string | null; export { ACTIVE_ORG_COOKIE, ACTIVE_ORG_QUERY_PARAM, ActiveOrgSwitchError, ORG_ID_QUERY_PARAM, ORG_ID_TAIL_LENGTH, type OrgClaims, activeOrgParam, authBaseUrl, isOrgId, isOrgSelector, matchOrgSelector, orgClaimsFrom, orgClaimsFromToken, orgIdTail, readActiveOrgCookie, readActiveOrgFromUrl, readOrgSelectorFromUrl, resolveActiveOrg, settingsBaseUrl, switchActiveOrg, syncOrgIdInUrl, withActiveOrgParam, withOrgIdParam, writeActiveOrgCookie };