Skip to main content

apps/web/lib/portal-session.ts

Metadata

Indexed Symbols

  • decodeBase64Url (line 35, function) - Implements decode base64 url for module behavior.
  • parsePortalClaims (line 41, function) - Implements parse portal claims for module behavior.
  • readPortalSession (line 80, function) - Implements read portal session for module behavior.
  • setPortalSessionToken (line 101, function) - Implements set portal session token for module behavior.
  • clearPortalSessionToken (line 112, function) - Implements clear portal session token for module behavior.
  • resolvePortalAuthToken (line 117, function) - Implements resolve portal auth token for module behavior.
  • exchangePortalInviteToken (line 132, function) - Implements exchange portal invite token for module behavior.
  • terminatePortalSession (line 165, function) - Implements terminate portal session for module behavior.

Markdown Headings (if applicable)

No markdown headings detected.

Source Preview

import "server-only";

import { cookies } from "next/headers";
import { resolveOperatorAuthToken } from "./operator-session";
import { isWorkspaceId } from "./workspace-context";

const apiBaseUrl = process.env.API_BASE_URL ?? process.env.NEXT_PUBLIC_API_BASE_URL ?? "http://localhost:8080";
const portalSessionCookieName = "anchor_portal_session";

type PortalSessionClaims = {
sub: string;
roles: string[];
workspaceIds: string[];
clientId?: string;
email?: string;
exp?: number;
};

export type PortalSession = {
token: string;
claims: PortalSessionClaims;
};

type ExchangeResponse = {
data?: {