Registry / devops / zerotier-rule-compiler

zerotier-rule-compiler

JSON →
library1.2.2-2jsnpmunverified

A tool to compile human-readable ZeroTier rule scripts into the binary format required by ZeroTier network controllers. Current stable version is 1.2.2-2. This package is part of the ZeroTier ecosystem and is used internally by ZeroTier Central's rules editor. It provides both a library API and a CLI interface. Unlike manual rule construction, this compiler validates syntax and ensures correct encoding. The package is available on npm and has minimal dependencies. Release cadence is irregular, tied to ZeroTierOne updates.

npm install zerotier-rule-compiler
INSTALL
IMPORT
SIG · ZEROTIER-RULE-COMP
Z
zerotier-rule-compiler
devopsjavascriptv1.2.2-2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

compile
import { compile } from 'zerotier-rule-compiler'
const compile = require('zerotier-rule-compiler').compile
ESM-only since v1.0.0, no CJS support.
stringify
import { stringify } from 'zerotier-rule-compiler'
import { stringify } from 'zerotier-rule-compiler' (no common mistake)
Utility to convert binary rules back to human-readable format.
parseError
import { parseError } from 'zerotier-rule-compiler'
const parseError = require('zerotier-rule-compiler').parseError
Type error for debugging rule compilation failures.

Compiles a simple ZeroTier rule script and then stringifies the result back to human-readable format.

import { compile, stringify } from 'zerotier-rule-compiler'; const script = `# accept all traffic on VLAN 1 drop accept`; try { const binaryRules = compile(script); console.log('Binary rules:', binaryRules); const reString = stringify(binaryRules); console.log('Stringified:', reString); } catch (err) { console.error('Compilation error:', err); }
zerotier-rule-compiler --version
Debug
Known issues
gotchaThe compile function throws on invalid syntax; always use try/catch.
fix
Wrap calls to compile in try/catch blocks.
affects: >=1.0.0
deprecatedThe CLI script cli.js uses synchronous file reading; may block event loop on large files.
fix
Use the programmatic API with async I/O for large scripts.
affects: <=1.2.2-2
breakingVersions prior to 1.0.0 used a different AST representation; compatibility broken.
fix
Upgrade to >=1.0.0 and update imports to ESM.
affects: <1.0.0
Errors
Common errors & fixes
SyntaxError: Unexpected token at line 3: 'accept'
Rule scripts require line breaks or semicolons between statements; missing newline.
fix
Ensure each rule statement is on its own line or separated by semicolons.
TypeError: compile is not a function
Using CommonJS require instead of ESM import; package is ESM-only.
fix
Use 'import' syntax, or if using Node <13, set 'type': 'module' in package.json.
RangeError: Rule length exceeds 4096 bytes
Compiled rule set too large for ZeroTier network controller limit.
fix
Optimize rules by reducing complexity or combining conditions.
Upgrade
Version history
1.2.2-2latest on npm
Audit
Dependencies
zerotier-rule-compilerrequiredThe package is self-contained, no external runtime dependencies.
Agent activity
34 hits · last 30 days
node
28
OpenAI (training)
1
Resources
zerotier-rule-compiler — npm install zerotier-rule-compiler · libregistry