🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

@meistrari/data-token

Package Overview
Dependencies
Maintainers
5
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@meistrari/data-token

Internal library to verify and decode the API Gateway data token

latest
Source
npmnpm
Version
1.2.0
Version published
Weekly downloads
4.5K
7.25%
Maintainers
5
Weekly downloads
 
Created
Source

@meistrari/data-token

Internal library to verify and decode the API Gateway data token.

Installation

pnpm install @meistrari/data-token

Usage

Basic Usage (No Adapter)

import { getValidator } from '@meistrari/data-token'

const validator = getValidator('https://some.api.com/well-known/jwks.json')

async function validateToken(token: string): Promise<DataToken> {
  return await validator(token)
}

Usage with Hono

import { Hono } from 'hono'
import { DataTokenContext, createDataTokenMiddleware } from '@meistrari/data-token/hono'

// Combine DataTokenContext with your own context type
type Env = {
  Variables: {
    customProp: string
  }
}
type AppContext = Env & DataTokenContext

const app = new Hono<AppContext>()
const dataToken = createDataTokenMiddleware('https://some.api.com/well-known/jwks.json')

app.use(dataToken)

app.get('/', (c) => {
  const authData = c.get('authData')
  return c.json({ data: authData })
})

Usage with Elysia

import { Elysia } from 'elysia'
import { createDataTokenPlugin } from '@meistrari/data-token/elysia'

const app = new Elysia()

const dataToken = createDataTokenPlugin('https://some.api.com/well-known/jwks.json')

app
  .use(dataToken)
  .get('/', ({ authData }) => ({ authData }))

API Reference

getValidator(jwksUrl: string, options?: { algorithms?: string[] })

Creates a validator function that can be used to validate and decode tokens.

createDataTokenMiddleware(url: string, getToken?: (c: Context) => string)

Creates a Hono middleware for token validation.

createDataTokenPlugin(url: string, getToken?: (c: Context) => string)

Creates an Elysia plugin for token validation.

Types

The DataToken type, as well as a Zod schema for the token payload is available from the /types entrypoint, both under the name of DataToken:

import { DataToken } from '@meistrari/data-token/types'

This type represents the structure of the decoded token data.

FAQs

Package last updated on 20 Oct 2025

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