
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
@sourceregistry/node-opa
Advanced tools
A minimal, dependency-free TypeScript client for interacting with the Open Policy Agent (OPA) REST API
@sourceregistry/node-opa – Lightweight TypeScript Client for OPA REST APIA minimal, dependency-free TypeScript client for interacting with the Open Policy Agent (OPA) REST API. Built with native fetch, supports modern browser and Node.js environments (v18+), and includes optional gzip compression for large payloads.
Note: This library is still a work in progress
fetch and CompressionStreamnpm install @sourceregistry/node-opa
Note: Requires a runtime that supports
fetchand (optionally)CompressionStream. In Node.js, use version 18+ or polyfillfetch.
import { OPAClient, OpenPolicyAgent } from '@sourceregistry/node-opa';
// Initialize client
const opa = new OPAClient({
baseUrl: 'http://localhost:8181',
headers: {
// Optional: add auth or custom headers
// 'Authorization': 'Bearer <token>'
}
});
// List all policies
const policies = await opa.policy.list();
console.log(policies.result);
// Evaluate a policy decision
const result = await opa.data.post('example/allow', {
input: { user: 'alice', action: 'read' }
});
console.log(result.result); // true / false / data
// Add a new policy
await opa.policy.put('authz.rego', `
package example
allow if {
input.user == "admin"
}
`);
// Typed error handling
try {
await opa.policy.get('missing.rego');
} catch (error) {
if (error instanceof OpenPolicyAgent.ClientError) {
console.error(error.code, error.message);
console.error(error.errors); // OPAError[]
}
}
The client exposes grouped methods under intuitive namespaces:
opa.policy.list() – list all policiesopa.policy.get(id) – retrieve a policy by IDopa.policy.put(id, rego) – create or update a policyopa.policy.delete(id) – remove a policyopa.data.get(path, options) – read a document (GET with query params)opa.data.post(path, { input }) – read with input in body (POST)opa.data.webhook(path, input) – webhook-style evaluation (/v0)opa.data.put(path, doc) – create/overwrite a documentopa.data.patch(path, ops) – apply JSON Patch (RFC 6902)opa.data.delete(path) – delete a documentopa.query.default(input) – evaluate default decision (POST /)opa.query.adhoc(query, input?) – run ad-hoc Rego queryopa.compile.partialEval(req) – partial evaluation for optimizationopa.compile.filter(path, req, accept) – compile to SQL or other filtersopa.health.check() – standard health checkopa.health.custom('ready') – custom /health/<name> endpointsopa.config.get() – retrieve active configurationopa.status.get() – get operational statusSee OPA REST API docs for full endpoint details.
new OPAClient({
baseUrl: 'http://opa:8181', // required
headers: {
// Custom headers (avoid overriding Content-Type, Accept, etc.)
'X-Custom-Header': 'value'
}
})
Warning: Avoid setting
Accept,Content-Typeor encoding headers inheadersthey are managed internally.
If your OPA instance uses token authentication:
const opa = new OPAClient({
baseUrl: 'https://opa.example.com',
headers: {
'Authorization': 'Bearer your-secret-token'
}
});
Ensure OPA is started with --authentication=token.
All responses are strongly typed. Common types include:
Document = any – generic JSON-like dataPolicyModule – policy metadata with raw and astGetDataResponse<T> – includes result, metrics, provenance, etc.OPAError – structured OPA error details (code, message, location, details)ClientError – thrown on non-2xx responses (code, message, errors, response)type OPAError = {
readonly code: string;
readonly message: string;
readonly location: { file: string; row: number; col: number };
readonly details: { line: string; idx: number };
};
class ClientError extends Error {
readonly code: string;
readonly errors: OPAError[];
readonly response: Response;
}
CompressionStream is unavailablePromisesMIT
Note: This client is community-maintained and not officially affiliated with the Open Policy Agent project. Refer to OPA’s official documentation for API semantics and behavior.
FAQs
A minimal, dependency-free TypeScript client for interacting with the Open Policy Agent (OPA) REST API
We found that @sourceregistry/node-opa demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.