Libraries
    Preparing search index...

    Class Principal<T>

    Principal — represents an authenticated (or anonymous) user identity.

    Generic over T — the user-defined principal shape, typically declared as a @cleverbrush/schema object schema.

    Type Parameters

    • T = unknown
    Index

    Constructors

    • Type Parameters

      • T = unknown

      Parameters

      • isAuthenticated: boolean
      • value: T | undefined
      • Optionalclaims: Map<string, string | string[]>

      Returns Principal<T>

    Properties

    claims: Map<string, string | string[]>
    isAuthenticated: boolean
    value: T | undefined

    Methods

    • Returns true if the principal has a claim with the given type. If value is provided, also checks the claim value matches.

      Parameters

      • type: string
      • Optionalvalue: string

      Returns boolean

    • Returns true if the principal has the given role. Checks the "role" claim by default; supports both single-value and array-value claims.

      Parameters

      • role: string
      • claimKey: string = 'role'

      Returns boolean