@cerbos/embedded
Version:
Client library for interacting with embedded Cerbos policy decision points generated by Cerbos Hub from server-side Node.js and browser-based applications
23 lines • 823 B
JavaScript
import { CerbosService as cerbos } from "@cerbos/api/cerbos/svc/v1/svc_pb";
import { NotOK, Status } from "@cerbos/core";
import { methodName } from "@cerbos/core/~internal";
export class Transport {
bundle;
constructor(bundle) {
this.bundle = bundle;
}
async unary(method, request, headers) {
if (methodName(method) === methodName(cerbos.method.checkResources)) {
const bundle = await this.bundle();
return (await bundle.checkResources(request, headers));
}
notImplemented(method);
}
serverStream(method) {
notImplemented(method);
}
}
function notImplemented(method) {
throw new NotOK(Status.UNIMPLEMENTED, `${methodName(method)} is not implemented in embedded policy decision points`);
}
//# sourceMappingURL=transport.js.map