Cerbos JavaScript SDK
    Preparing search index...

    Interface PolicyLoaderOptions

    Options for creating a PolicyLoader.

    interface PolicyLoaderOptions {
        activateOnLoad?: boolean;
        baseUrl?: string;
        credentials?: Credentials;
        headers?: HeadersInit | (() => Awaitable<HeadersInit>);
        interval?: number;
        onUpdate?: (error: NotOK | undefined) => Awaitable<void>;
        ruleId: string;
        scopes?: string[];
        userAgent?: string;
    }

    Hierarchy

    Index

    Properties

    activateOnLoad?: boolean

    Whether to activate updated policy bundles as soon as they are downloaded.

    If false, new bundles will be downloaded automatically but not used to evaluate policy decisions until you call PolicyLoader.activate. This might be useful if you want to activate updates only on page transitions to avoid layout shifts in your application.

    true

    baseUrl?: string

    Base URL of the Cerbos Hub server.

    "https://api.cerbos.cloud"

    credentials?: Credentials

    Client credentials to authenticate with Cerbos Hub.

    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

    interval?: number

    The delay (in seconds) between successive requests to check for policy bundle updates.

    Set to 0 to disable policy bundle update checks.

    The interval will be increased to the minimum of 10 seconds if a smaller value is specified.

    60 (1 minute)

    onUpdate?: (error: NotOK | undefined) => Awaitable<void>

    A callback to invoke when a policy bundle update has finished.

    The callback receives an error if the update failed to load. These failures are silently ignored by default.

    (no-op)
    
    ruleId: string
    scopes?: string[]

    Scopes to include in the policy bundle.

    (all scopes)
    
    userAgent?: string

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

    undefined