OPAClient is the starting point for using the high-level API.

Use OpaApiClient if you need some low-level customization.

Constructors

Methods

  • evaluate is used to evaluate the policy at the specified path with optional input.

    Type Parameters

    Parameters

    • path: string

      The path to the policy, without /v1/data: use authz/allow to evaluate policy data.authz.allow.

    • Optionalinput: In

      The input to the policy, if needed.

    • Optionalopts: RequestOptions<Res>

      Per-request options to control how the policy evaluation result is to be transformed into Res (via fromResult), and low-level fetch options.

    Returns Promise<Res>

  • evaluateBatch is used to evaluate the policy at the specified path, for a batch of many inputs.

    Type Parameters

    Parameters

    • path: string

      The path to the policy, without /v1/batch/data: use authz/allow to evaluate policy data.authz.allow.

    • inputs: {
          [k: string]: In;
      }

      The inputs to the policy.

      • [k: string]: In
    • Optionalopts: BatchRequestOptions<Res>

      Per-request options to control how the policy evaluation result is to be transformed into Res (via fromResult), if any failures in the batch result should reject the promose (via rejectMixed), and low-level fetch options.

    Returns Promise<{
        [k: string]: Res | ServerErrorWithStatusCode;
    }>

  • evaluateDefault is used to evaluate the server's default policy with optional input.

    Type Parameters

    Parameters

    • Optionalinput: In

      The input to the default policy, defaults to {}.

    • Optionalopts: RequestOptions<Res>

      Per-request options to control how the policy evaluation result is to be transformed into Res (via fromResult), and low-level fetch options.

    Returns Promise<Res>