Callcium
API

PolicyCoder

Encode and decode binary policies.

PolicyCoder

Encode policies in canonical form, and decode and inspect policy blobs.

Git Source

Methods

encode

Encode the canonical form of a policy: each group normalized, its rules and the groups sorted by their size-free bytes, repeats dropped.

function encode(data: PolicyData): `0x${string}`;

Parameters

NameTypeDescription
dataPolicyDataThe policy.

Returns

`0x${string}` — The policy blob as a 0x-prefixed hex string.

decode

Decode a policy blob into the policy it states.

function decode(blob: `0x${string}`): PolicyData;

Parameters

NameTypeDescription
blob`0x${string}`The policy blob.

Returns

PolicyData — The decoded policy, each operand loaded to its 32-byte word.

inspect

Inspect a policy blob: every field it stores with the bytes that contain it. The descriptor is a node tree, the hints are split into their fields and the operators are parsed.

function inspect(blob: `0x${string}`): DecodedPolicy;

Parameters

NameTypeDescription
blob`0x${string}`The policy blob.

Returns

DecodedPolicy — The inspected policy, each operand loaded to its 32-byte word.

On this page