Skip to main content
The @gateway/shared package provides JWT token creation/verification utilities and shared TypeScript types used across the gateway system.

Package Structure

ProjectRoute Enum

Defines the available route types:

GatewayErrorSchema

Unified error response schema using Zod:

Error Response Example

GatewayTokenClaimsSchema

JWT token claims schema:

JWT Functions

createGatewayToken

Creates a signed JWT token for downstream service authentication.

Options

Default Values

  • Issuer: gateway.metacogna.ai
  • Audience: metacogna-clients
  • Algorithm: HS256
  • Expiration: 1h

verifyGatewayToken

Verifies and decodes a JWT token.

Options

Usage Examples

Creating an Admin Token

Creating a Guest Token

Verifying a Token

Dependencies

The shared package uses:
  • jose - JWT signing and verification
  • zod - Schema validation

Building the Package

The shared package is built as part of the workspace: