Restaq
Reference

@restaq/plugin

Plugin authoring kit with signature verification helpers and definePlugin.

Install

pnpm add @restaq/plugin

Peer dependency: @restaq/core

Exports

ExportKindDescription
definePluginFunctionIdentity helper for authoring plugins with full type inference.
hmacSha256HexFunctionHMAC-SHA256 signature generation used by Stripe, GitHub, and other providers.
safeEqualHexFunctionConstant-time hex signature comparison to prevent timing attacks.
NormalizedEventTypeRe-exported from @restaq/core.
RelayPluginTypeRe-exported from @restaq/core.

Functions

definePlugin

function definePlugin<TEventMap extends Record<string, unknown> = {}>(
  plugin: RelayPlugin<TEventMap>,
): RelayPlugin<TEventMap>;

An identity helper for authoring plugins. Acts like defineConfig in other frameworks: it gives full inference and type checking of the plugin shape and pins the plugin's typed event map so it survives through restaq's plugins array without widening to any. Use this when building custom provider plugins.

hmacSha256Hex

function hmacSha256Hex(secret: string, payload: string): string;

Computes the HMAC-SHA256 signature of a payload (the standard scheme used by Stripe, GitHub, and others). Returns a hex-encoded string.

safeEqualHex

function safeEqualHex(expectedHex: string, actualHex: string): boolean;

Constant-time comparison of two hex-encoded signatures. Returns false (instead of throwing) on length mismatch or non-hex input, preventing malformed attacker-supplied signatures from crashing verification. Always use this instead of simple string equality to avoid timing attacks.

See also

On this page