Installation
Packages, entry points, runtimes, and peer dependencies.
The Rolebook engine is one package, rolebook, with no runtime dependencies.
Not on npm yet
The Rolebook packages are not on npm yet. The npm package named rolebook is an unrelated project, so do not install it.
Add the sharing packages only when you need resource sharing: the module itself, one
storage adapter, and the identity adapter for your provider. For example, sharing on PostgreSQL with
Better Auth uses rolebook, @rolebook/sharing, @rolebook/sharing-postgres and
@rolebook/sharing-better-auth.
To answer checks for other services, or on a device without a connection, add the
decision service or offline snapshots. Both evaluate with
rolebook, which they declare as a peer, and both bring in @rolebook/scalars-p1 as their own
dependency, so you add it yourself only to call the parser directly.
Not sure which packages you need? Choose how decisions run compares them.
Packages and entry points
Every package is ECMAScript modules only ("type": "module", import exports) and ships its own
TypeScript declarations. There is no CommonJS build.
| Package | Version | Entry points | Peer dependencies |
|---|---|---|---|
rolebook | 4.0.0 | rolebook, /authoring, /middleware/hono, /middleware/express, /middleware/fastify | All optional, each only for its own middleware: hono >=4.12.34 <5, express >=5.1.0 <6, fastify >=5.0.0 <6 |
@rolebook/sharing | 0.1.0 | @rolebook/sharing, /checkpoints | rolebook ^4.0.0 |
@rolebook/sharing-postgres | 0.1.0 | @rolebook/sharing-postgres | @rolebook/sharing ^0.1.0, rolebook ^4.0.0 |
@rolebook/sharing-sqlite | 0.1.0 | @rolebook/sharing-sqlite, /bun, /bun-query (Bun only), /libsql | @rolebook/sharing ^0.1.0, rolebook ^4.0.0; @libsql/client >=0.17.0 <1, optional (only for /libsql) |
@rolebook/teams | 0.1.0 | @rolebook/teams, /sql, /better-auth, /sqlite | @rolebook/sharing ^0.1.0, rolebook ^4.0.0; @rolebook/sharing-postgres ^0.1.0 and @rolebook/sharing-sqlite ^0.1.0, each optional |
@rolebook/sharing-better-auth | 0.1.0 | @rolebook/sharing-better-auth | @rolebook/sharing ^0.1.0, rolebook ^4.0.0, better-auth >=1.7.7 <2 |
@rolebook/better-auth | 0.1.0 | @rolebook/better-auth, /postgres, /sqlite, /client, /react | @rolebook/sharing ^0.1.0, rolebook ^4.0.0, better-auth >=1.7.14 <1.8; optional peers per entry: @rolebook/sharing-postgres, @rolebook/sharing-sqlite, @rolebook/teams, @rolebook/client, @rolebook/react, nanostores, react |
@rolebook/sharing-clerk | 0.1.0 | @rolebook/sharing-clerk | @rolebook/sharing ^0.1.0, rolebook ^4.0.0, @clerk/backend >=3.17.0 <4 |
@rolebook/sharing-workos | 0.1.0 | @rolebook/sharing-workos | @rolebook/sharing ^0.1.0, rolebook ^4.0.0, @workos-inc/node >=11.0.0 <12 |
@rolebook/sharing-testkit | 0.1.0 | @rolebook/sharing-testkit | @rolebook/sharing ^0.1.0 |
@rolebook/http | 0.1.0 | @rolebook/http, /webhooks, @rolebook/http/openapi.json | @rolebook/sharing ^0.1.0 |
@rolebook/server | 0.1.0 | @rolebook/server, /webhooks, /hono, /next, /core | @rolebook/sharing ^0.1.0; hono >=4.12.34 <5, optional (only for /hono) |
@rolebook/client | 0.1.0 | @rolebook/client | @rolebook/sharing ^0.1.0 |
@rolebook/react | 0.1.0 | @rolebook/react, /core | @rolebook/client ^0.1.0, @rolebook/sharing ^0.1.0, react >=18.3.0 <20 |
@rolebook/cli | 0.1.0 | @rolebook/cli (rolebook binary) | rolebook ^4.0.0, @rolebook/sharing ^0.1.0 |
@rolebook/decision-service | 0.1.0 | @rolebook/decision-service | rolebook ^4.0.0 |
@rolebook/offline | 0.1.0 | @rolebook/offline | rolebook ^4.0.0 |
@rolebook/scalars-p1 | 0.1.0 | @rolebook/scalars-p1, @rolebook/scalars-p1/fixtures/p1-v1.json | None |
@rolebook/migrate | 0.1.0 | @rolebook/migrate | rolebook ^4.0.0 |
@rolebook/server and @rolebook/client depend on @rolebook/http, and @rolebook/decision-service and
@rolebook/offline depend on @rolebook/scalars-p1; your package manager installs those for you.
The decision service and offline packages are independent of Sharing. They ship no adapters, so each needs code from you before it can answer:
| Package | You supply |
|---|---|
@rolebook/decision-service | A credential verifier, an authority provider for each scope, a clock, a random source, and the HTTP host that mounts the handler. |
@rolebook/offline | Root keys, a qualified clock, a trusted state store, and Ed25519 functions; an issuer also needs a durable sequence allocator. |
@rolebook/scalars-p1 | Explicit limits on every call. It has no defaults. |
The storage adapters do not depend on a database driver. They take a small parameterized executor that
you build over the driver you already use (pg, postgres.js, bun:sqlite, better-sqlite3,
node:sqlite, libSQL). The SQLite package ships executors for bun:sqlite and @libsql/client.
Runtime
rolebook declares Node.js 24 or later in its engines field. The core imports no Node.js built-in
module, so it also runs on other runtimes that load ES modules. The sharing packages import
node:crypto (invitation tokens, sealed cursors, policy digests), so they need Node.js, Bun, or a
runtime with Node.js compatibility. @rolebook/migrate hashes with node:crypto too, so it needs
Node.js or Bun. The SQLite /bun executor also uses node:async_hooks and expects
a bun:sqlite database.
@rolebook/offline imports node:crypto for SHA-256 and runs on Node.js 24 or later or on Bun; a
browser is not a supported runtime for it. Ed25519 signing and verification come from the adapter you
inject. @rolebook/decision-service is a web-standard fetch handler: mount it in a host that provides
Request and Response, such as Bun.serve, a Node.js adapter, or a framework route.
TypeScript
The declarations use const type parameters and template literal types, so permissions are
checked at compile time. Use a current TypeScript release with strict enabled. The packages are
built and tested with exactOptionalPropertyTypes and noUncheckedIndexedAccess on, and the code
samples in these docs are type-checked with the same settings.
Development of Rolebook itself
The repository pins Bun 1.4.3. From a checkout:
bun ci
bun run verify bun run build builds the core into dist/, and bun run build:packages builds every package in
dependency order. See the repository README for the coverage gates and the PostgreSQL test database.