A command-line tool to generate JWT tokens with PromptQL-specific claims.
Ensure you have Node.js installed, then install dependencies:
npm install
Generate a JWT token by running:
node jwt.mjs
From the base hasura folder, call ddn run jwt-gen for a default token for user 7 as role customer. Pass -u to change user and -r to change role. Example:
ddn run jwt-gen -- -u 8 -r editor
-u, --userId <userId>: User ID (default:7).-r, --roles <roles>: Comma-separated list of roles (default:customer).-k, --key <key>: JWT secret key (can be set via.envfile).-e, --env <path>: Path to.envfile containingJWT_SECRET.-c, --context <context>: Context to auto-find.envfile defined in.hasura/context.yaml.-l, --local: Use localEnvFile rather than cloudEnvFile fromcontext.yaml.
Using an alternate context from .hasura/context.yaml
node jwt.mjs -u 8 -r admin,editor -c axiom-test
Using localEnvFile option from context in .hasura/context.yaml
node jwt.mjs -u 8 -r admin,editor -c axiom-test --local
Using a custom .env file:
node jwt.mjs -u 123 -r admin,editor -e ../../.env
Passing a key to the script
node jwt.mjs -u 123 -r admin,editor -k "qG7zP4cZK9B5vN5fjYcLr1Jq3RZqP+R/B5fXzP3aLqY="
# Alternate method
JWT_SECRET=qG7zP4cZK9B5vN5fjYcLr1Jq3RZqP+R/B5fXzP3aLqY= node jwt.mjs -u 123 -r admin,editor
The generated JWT token is printed to the console along with its decoded content.
MIT