Cerbos JavaScript SDK
    Preparing search index...

    Interface AutoUpdateOptions

    Options for creating a new AutoUpdatingLoader.

    interface AutoUpdateOptions {
        activateOnLoad?: boolean;
        decodeJWTPayload?: DecodeJWTPayload;
        defaultPolicyVersion?: string;
        globals?: Record<string, Value>;
        headers?: HeadersInit | (() => Awaitable<HeadersInit>);
        interval?: number;
        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

    activateOnLoad?: boolean

    Whether to activate updated embedded policy decision point 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 AutoUpdatingLoader.activate. This might be useful if you want to activate updates only on page transitions to avoid layout shifts in your application.

    To detect whether an update is available to activate, provide an Options.onLoad callback or check the AutoUpdatingLoader.pending property.

    true

    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

    interval?: number

    The delay (in milliseconds) between successive requests to check for new embedded policy decision point bundles.

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

    60_000 (1 minute)

    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