You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

@smithery/biscuit

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@smithery/biscuit

Cloudflare Workers adapter for @biscuit-auth/biscuit-wasm

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

@smithery/biscuit

npm version

Biscuit authorization tokens for Cloudflare Workers and Node.js.

This package wraps @biscuit-auth/biscuit-wasm with runtime-specific WASM shims so you can use Biscuit tokens in Cloudflare Workers (which require synchronous WebAssembly.Module instantiation) and Node.js without any extra configuration.

Install

pnpm add @smithery/biscuit

Usage

import {
  biscuit,
  block,
  authorizer,
  generateKeyPair,
} from "@smithery/biscuit"

// Generate keys
const { privateKey, publicKey } = generateKeyPair()

// Mint a token with Datalog using tagged template helpers
const token = biscuit`
  user("alice");
  check if time($t), $t <= ${new Date(Date.now() + 3600_000)};
`.build(privateKey)

// Attenuate — restrictions can only narrow, never widen
const restricted = token.appendBlock(
  block`check if operation($op), ["read"].contains($op);`
)

// Verify
const auth = authorizer`
  time(${new Date()});
  operation("read");
  allow if true;
`
auth.buildAuthenticated(restricted).authorize() // throws if checks fail

The tagged template helpers (biscuit, block, authorizer) automatically convert JS values into Datalog terms — Date becomes a timestamp, Uint8Array becomes hex bytes, Set and Map are supported, and any object with a toDatalogParameter() method works as a custom term.

Exports

PathContents
@smithery/biscuitAll biscuit-wasm classes, tagged template helpers, generateKeyPair()
@smithery/biscuit/shimRaw WASM shim re-exports only

The package uses conditional exports: the workerd condition resolves to the Cloudflare Workers shim, and default resolves to the Node.js shim.

How it works

The upstream package targets bundlers (wasm-pack --target bundler), which expect the bundler to handle WASM instantiation. Cloudflare Workers import .wasm files as pre-compiled WebAssembly.Module objects instead, so this package manually instantiates the module and wires it to the JS glue code.

The shim (src/shim.ts) does three things:

  • Imports the .wasm binary as a CF Workers WebAssembly.Module
  • Collects __wbg_* / __wbindgen_* glue functions from the JS bindings
  • Synchronously instantiates the WASM module and connects it to the glue

Upstream patch

The shim imports internal files from @biscuit-auth/biscuit-wasm (module/biscuit_bg.js and module/biscuit_bg.wasm) that are not listed in the package's exports field. Modern bundlers (including Wrangler's esbuild) enforce exports strictly and refuse to resolve these subpaths.

A pnpm patch at patches/@biscuit-auth__biscuit-wasm@0.6.0.patch adds the missing subpath exports. If you upgrade @biscuit-auth/biscuit-wasm, regenerate the patch with pnpm patch and verify the shim still bundles under wrangler dev.

License

MIT

FAQs

Package last updated on 11 Mar 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts