Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

519 B
Raw Blame
import { z } from 'zod';

/** Read a claim only. SyncService must verify this same token before any model or write runs. */
export function tokenAccessLevel(token: string): string | undefined {
  try {
    const payload = token.split('.')[1] ?? '';
    const claims = z
      .object({ access_level: z.string() })
      .safeParse(
        JSON.parse(atob(payload.replace(/-/g, '+').replace(/_/g, '/')))
      );
    return claims.success ? claims.data.access_level : undefined;
  } catch {
    return undefined;
  }
}