ankr-trust-constants
v1.0.2
Published
ANKR 32-bit trust bitmask constants — single source of truth for all ANKR service permissions
Downloads
27
Maintainers
Readme
ankr-trust-constants
ANKR 32-bit trust bitmask — single source of truth for AI-native service permissions.
Zero dependencies. Import at build time. One integer encodes the full permission surface of any service.
Install
npm install ankr-trust-constantsWhy a Bitmask?
String arrays require parsing, matching, and interpretation. At 200+ services, interpretation equals hallucination.
// String array — requires parsing
can_do: ["CREATE_BOOKING", "CLOSE_MANIFEST", "ISSUE_BL"]
// Bitmask — binary truth
trust_mask: 0x00000707
(mask & BOOK) !== 0 // either true or false. no ambiguity.A bitmask AND across 200 services: sub-millisecond. Zero interpretation. Zero hallucination possible.
Usage
import { TRUST_PERM, ROLE_MASK, MARITIME_ROLE_MASK, hasPerm } from 'ankr-trust-constants'
// Check a single permission
const canBook = hasPerm(user.trust_mask, TRUST_PERM.BOOK)
// Check AI autonomy tier
const isAutonomous = hasPerm(agent.trust_mask, TRUST_PERM.AUTONOMOUS)
// Build a role mask
const shipperMask = MARITIME_ROLE_MASK.SHIPPER
// = READ | QUERY | WRITE | BOOKThe 32-bit Allocation
Bits 0-7 — Universal Forja
READ (bit 0) — read/fetch data
QUERY (bit 1) — query/search
WRITE (bit 2) — create/update records
EXECUTE (bit 3) — trigger operations
APPROVE (bit 4) — approve/reject workflows
AUDIT (bit 5) — access audit logs
ADMIN (bit 6) — admin operations
SUPER (bit 7) — superuser / unrestricted
Bits 8-15 — Maritime block
BOOK (bit 8) — create bookings
MANIFEST (bit 9) — close/amend manifests
BL_ISSUE (bit 10) — issue bills of lading
RATE_DESK (bit 11) — manage freight rates
FEEDER_OPS (bit 12) — feeder vessel operations
NETWORK_PLAN (bit 13) — network planning
VESSEL_OPS (bit 14) — vessel deployment/ops
COMPLIANCE_OVERRIDE (bit 15)
Bits 16-23 — Logistics block
GATE_IN, TRACK, FTA_CHECK, ALERT_ACK, PORT_OPS
Bits 24-31 — AGI autonomy tier
AI_READ, AI_QUERY, AI_SUGGEST, AI_EXECUTE, AI_APPROVE, AUTONOMOUSBit allocation is append-only — once assigned, a bit position never changes.
Role Presets
import { ROLE_MASK, MARITIME_ROLE_MASK } from 'ankr-trust-constants'
ROLE_MASK.VIEWER // READ | QUERY
ROLE_MASK.WRITER // READ | QUERY | WRITE
ROLE_MASK.APPROVER // READ | QUERY | WRITE | APPROVE
ROLE_MASK.ADMIN // all universal bits (0-7)
MARITIME_ROLE_MASK.SHIPPER // READ | QUERY | WRITE | BOOK
MARITIME_ROLE_MASK.MANIFEST_CLERK // + MANIFEST
MARITIME_ROLE_MASK.VESSEL_MASTER // + VESSEL_OPS
MARITIME_ROLE_MASK.COMPLIANCE_OFFICERHelpers
hasPerm(mask, perm) // mask includes permission?
hasAllPerms(mask, ...perms) // mask includes ALL of these?
hasAnyPerm(mask, ...perms) // mask includes ANY of these?
describePerms(mask) // → ['READ', 'QUERY', 'BOOK', ...]Used In Production
205+ services across the ANKR maritime platform use this bitmask — VTS systems, electronic Bill of Lading, charter party management, voyage intelligence, port congestion analytics.
Pair With
ankr-forja— wires STATE + TRUST + SENSE + PROOF endpoints. The TRUST endpoint returns this bitmask.
License
Apache 2.0
Built by ANKR Labs | PowerPbox IT Solutions Pvt Ltd
