grantex enforce test lets you dry-run scope enforcement against a real grant token without writing any code. Pass a token, connector, and tool name to see whether the call would be allowed or denied, and why.
npm install -g @grantex/cli
Prefer a secret-safe token source for agent automation:
Scope Enforcement Test ─────────────────────────────────────────── Result ALLOWED Connector salesforce Tool create_lead Permission write (from manifest) Token Scopes └ tool:salesforce:write:* Grant ID grnt_01HXYZ Agent DID did:grantex:ag_01HXYZ ─────────────────────────────────────────────
Scope Enforcement Test ─────────────────────────────────────────── Result DENIED Connector salesforce Tool delete_contact Permission delete (from manifest) Token Scopes └ tool:salesforce:write:* Reason write scope does not permit delete operations Grant ID grnt_01HXYZ Agent DID did:grantex:ag_01HXYZ ─────────────────────────────────────────────
Use the --amount flag to test enforcement against capped scopes. From the
next SDK release, a capped scope denies a test without --amount
(amount_missing):
Available in @grantex/cli@0.4.0 with SDK 0.8.0. Node.js 22.12+
is required; audience binding and default online revocation are breaking changes.
A grant token requested with an audience carries it in the aud claim, and
enforce() denies it unless the relying party expects that audience (see
Grant token audience). Pass
the audience your service is issued tokens for with --audience:
Without --audience, a token that carries aud is reported as denied with
token_invalid / audience_unconfigured; a token whose aud does not contain
the --audience value is denied with token_invalid / audience_mismatch.
--audience-check off ignores aud, as earlier releases did:
grantex enforce test \ --token "eyJ..." \ --connector salesforce \ --tool create_lead \ --audience-check off
--audience-check takes on (the default) or off; any other value is
refused. --audience cannot be empty or combined with --audience-check off,
and both options are refused when the installed @grantex/sdk does not check
the audience, instead of being ignored.