New:Socket for Asana Is Now Available.Learn more
Get Started

@grantex/strands

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

@grantex/strands

Strands Agents SDK integration for the Grantex delegated authorization protocol

latest
Source
npmnpm
Version
0.1.1
Version published
Weekly downloads
21
250%
Maintainers
1
Weekly downloads
 
Created
Source

@grantex/strands

Strands Agents SDK integration for the Grantex delegated authorization protocol.

Create Strands tools that verify Grantex grant tokens and enforce scopes before tool execution.

Homepage | Docs | GitHub

Install

npm install @grantex/strands @grantex/sdk @strands-agents/sdk zod

Quick Start

import { Agent } from '@strands-agents/sdk';
import { createGrantexTool } from '@grantex/strands';
import { z } from 'zod';

const readCalendar = createGrantexTool({
  name: 'read_calendar',
  description: 'Read upcoming calendar events',
  inputSchema: z.object({
    date: z.string().describe('Date in YYYY-MM-DD format'),
  }),
  grantToken,
  requiredScope: 'calendar:read',
  callback: async ({ date }) => {
    return `events for ${date}`;
  },
});

const agent = new Agent({
  tools: [readCalendar],
});

If the verified grant token does not include the required scope, the tool throws GrantexScopeError before invoking your callback.

Enforcement Modes

Verified mode is the default. It verifies the grant token against JWKS and checks the verified scp claim:

const tool = createGrantexTool({
  name: 'read_calendar',
  description: 'Read upcoming calendar events',
  inputSchema: z.object({ date: z.string() }),
  grantToken,
  requiredScope: 'calendar:read',
  callback: async ({ date }) => getCalendarEvents(date),
});

Online mode delegates enforcement to a Grantex client:

const tool = createGrantexTool({
  name: 'read_calendar',
  description: 'Read upcoming calendar events',
  inputSchema: z.object({ date: z.string() }),
  grantToken,
  requiredScope: 'calendar:read',
  client: grantexClient,
  connector: 'calendar',
  online: true,
  callback: async ({ date }) => getCalendarEvents(date),
});

API Reference

createGrantexTool(options)

Creates a Strands-compatible tool with Grantex scope enforcement.

OptionTypeDescription
namestringTool name
descriptionstringTool description
inputSchemaz.ZodTypeZod schema for tool input
grantTokenstringJWT grant token from Grantex
requiredScopestringScope that must be present in the token
callback(input, context?) => Promise<Result> | ResultTool implementation
jwksUristringJWKS URL used to verify the grant token
issuer, issuerDid, audiencestringOptional JWT claim validation settings
clockTolerancenumberClock tolerance in seconds for token verification
clientGrantexEnforcerGrantex client instance for online mode
connectorstringConnector name for online mode
onlinebooleanUse client.enforce() instead of JWKS-backed local verification
amountnumberOptional capped-amount value for online enforcement

getGrantScopes(grantToken)

Returns the scopes embedded in a grant token. Invalid tokens return an empty array. This helper decodes the token payload only; it does not verify the signature.

GrantexScopeError

Error thrown when the verified grant token is missing the required scope.

Requirements

  • Node.js 20+
  • @grantex/sdk >= 0.3.11
  • @strands-agents/sdk >= 1.6.0
  • zod >= 4.1.12

Grantex Ecosystem

This package is part of the Grantex ecosystem. See also:

License

Apache 2.0

Keywords

grantex

FAQs

Package last updated on 25 Jun 2026

Related posts