All files authGuard.ts

100% Statements 4/4
100% Branches 2/2
100% Functions 2/2
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17                5x 22x       5x 18x    
/**
 * Shared auth helpers for callable functions. A user starts anonymous and must
 * "connect" a real provider (Google / Apple / email) before pairing, so the
 * trust-sensitive callables (createInvite, pairWithCode) reject anonymous callers.
 */
type CallableAuth = { token?: { firebase?: { sign_in_provider?: string } } } | undefined;
 
/** The provider used for the current session ("anonymous" when not yet connected). */
export function signInProvider(auth: CallableAuth): string {
  return auth?.token?.firebase?.sign_in_provider ?? "anonymous";
}
 
/** True when the caller has not connected a recoverable provider yet. */
export function isAnonymous(auth: CallableAuth): boolean {
  return signInProvider(auth) === "anonymous";
}