Cerbos JavaScript SDK
    Preparing search index...

    Interface Options

    Options for creating a new Embedded client or Loader.

    interface Options {
        decodeJWTPayload?: DecodeJWTPayload;
        defaultPolicyVersion?: string;
        globals?: Record<string, Value>;
        headers?: HeadersInit | (() => Awaitable<HeadersInit>);
        lenientScopeSearch?: boolean;
        now?: () => number | Date;
        onDecision?: (entry: DecisionLogEntry) => Awaitable<void>;
        onError?: (error: LoadError) => Awaitable<void>;
        onLoad?: (metadata: BundleMetadata) => Awaitable<void>;
        userAgent?: string;
    }

    Hierarchy (View Summary)

    Index

    Properties

    decodeJWTPayload?: DecodeJWTPayload

    A function to verify and decode JWTs passed as auxiliary data, returning the JWT payload.

    (throw an error when a JWT is passed)
    
    defaultPolicyVersion?: string

    Default policy version to apply to requests that do not specify one.

    "default"

    globals?: Record<string, Value>

    Global variables to pass environment-specific information to policy conditions.

    {}

    headers?: HeadersInit | (() => Awaitable<HeadersInit>)

    Headers to add to every request to the policy decision point.

    Headers can be included in the policy decision point's audit logs by setting the includeMetadataKeys or excludeMetadataKeys fields in the audit configuration block.

    The User-Agent header is set using Options.userAgent.

    undefined

    lenientScopeSearch?: boolean

    Enable lenient scope search?

    By default, when a request specifies a scope of a.b.c then a policy must exist with that exact scope. If lenient scope search is enabled, then the policy decision point will fall back to trying scopes a.b, a, and "" if a policy with scope a.b.c does not exist.

    false

    now?: () => number | Date

    A function returning the current time, to be used when evaluating policy conditions.

    The function can either return a Date or a number of milliseconds elapsed since the Unix epoch.

    Date.now

    onDecision?: (entry: DecisionLogEntry) => Awaitable<void>

    A callback to invoke when a decision is made by the embedded policy decision point.

    (no-op)
    
    onError?: (error: LoadError) => Awaitable<void>

    A callback to invoke when the embedded policy decision point bundle has failed to load.

    (no-op)
    
    onLoad?: (metadata: BundleMetadata) => Awaitable<void>

    A callback to invoke when the embedded policy decision point bundle has been loaded.

    (no-op)
    
    userAgent?: string

    Custom user agent to prepend to the built-in value.

    undefined