Repository navigation
Quickstart · Docs · npm · Go · Discussions
theAuth 1.2.0
Open-source authentication and authorization for AI agents, MCP servers and apps. Agent identity, delegation, an OAuth 2.1 authorization server for MCP, DPoP, passkeys, SSO and SCIM in TypeScript. Self-hosted and MIT licensed.
Features and changes
- Agent accountability, enforced before the action runs. (details in the package changelog)
agent.revoke()now revokes every active delegation chain where the agent is the source or the target, and the chains downstream of them. It returns the revoked chain ids asrevokedDelegationsand writes oneagent.cascade.revokedaudit row that joins the hash chain.- Added
guardToolandguardTools, which put the policy engine in front of any agent tool with anexecutefunction, with no framework dependency. A denied call throwsToolDeniedError, a call that needs a human throwsToolApprovalRequiredErrorwith the approval request id and tier, and a failed check throwsToolGuardFailedError. The tool never runs in those cases. Pass theapprovalIdoption to retry an approved call: the guard hands it toevaluate, which spends it once. ThePolicyEngineConfigtype is now exported from the package root. - Added signed audit checkpoints and portable receipts.
createCheckpointbuilds an RFC 6962 style Merkle tree over the chained audit rows and signs the tree head with Ed25519.createInclusionProof,createConsistencyProofandcreateReceiptproduce proofs thatverifyInclusionProof,verifyConsistencyProofandverifyReceiptcheck offline with only a public key. A receipt reveals the decision fields you pick and keeps the rest as salted commitments. IncludesgenerateCheckpointKeyPair,createEd25519Signer, and aCheckpointStoreinterface withcreateMemoryCheckpointStore. authorize()andpolicy.evaluate()now accept an optionalapprovalId. When the matched permission requires approval, the call verifies that the approval request is approved, belongs to the same agent, matches the action and resource exactly, is not expired and was not used, then spends it with a single conditional update and allows the call. Failures are denied withAPPROVAL_NOT_FOUND,APPROVAL_NOT_APPROVED,APPROVAL_MISMATCH,APPROVAL_EXPIREDorAPPROVAL_ALREADY_USED. The audit row recordsapprover_idand the approval id. A nullableconsumed_atcolumn is added to the approval requests table automatically.- Added
resolveActorAgentIdandallowUnmappedActorsto the MCP config. The live delegation check can now map each actor in a token'sactchain (and the token subject) to the agent id used in delegation records before it looks up the link, so the built-increateDbDelegationStoreworks when token exchange setsact.subto a user or client id. An actor the mapper returnsundefinedfor rejects the token withINVALID_TOKEN("unmapped actor") unlessallowUnmappedActorsis true, and a mapper that throws always rejects. Without a mapper nothing changes.checkLiveDelegationnow takes an options object as its fourth argument in place of thenowdate. - MCP: new opt-in
delegationStoreconfig that re-checks a token'sactdelegation chain against live link records invalidateAccessToken. A missing, revoked or expired link rejects the token withINVALID_TOKEN, so revoking a parent grant no longer leaves tokens minted down the chain valid untilexp. AddscreateDbDelegationStore(db)and theMcpDelegationStoreandMcpDelegationLinktypes. Default behaviour is unchanged when not configured. - Add policy shrink:
analyzeUsagecompares an agent's effective permissions (including active delegations) with its recorded decisions,suggestShrinkproposes a smaller set (with optional, bounded generalization), andverifyShrinkandpreviewPolicyChangereport which recorded decisions would flip for any proposed permission change. Reads audit rows in pages and never changes permissions. - Added a taint-aware (information flow) tool guard. Tool arguments can carry provenance labels, given through the new
provenanceandtrackeroptions ofguardTool/guardTools, throughtainted()values, or through aProvenanceTrackerthat registers tool results astool_output:<tool>. A newpolicy.taintconfig restricts which labels may flow into which tools withforbidandrequirerules, per tool or per argument, and either escalates for approval (reusing the single useapprovalIdflow) or denies withPOLICY_TAINT_VIOLATION. The labels and the verdict are written to the hash chained decision record'sinput_provenanceautomatically. Behavior with no labels supplied is unchanged. New helpers:tainted,untaint,labelsOf,deriveLabels,matchLabel,ProvenanceTracker.
Fixes
- Delegation constraints now fail closed when a child's argument patterns, IP allowlist or time window do not overlap the parent's. Before, the parent's wider value was kept and the child's restriction was silently dropped. The narrowed result now denies every call. Overnight time windows that are not identical to the other window also deny instead of falling back to the parent's.
policy.evaluatenow denies revoked, suspended and expired agents withPOLICY_AGENT_INACTIVE. Requests that arrive with an agent token were already rejected once the agent was revoked, butevaluatetakes an agent id directly and never read the agent's status, so a revoked agent could still be allowed by a matching permission. If you gate actions withevaluate, upgrade.- Security fix: the policy engine now fails closed on several constraint edge cases.
maxCallsPerHour: 0denies every call instead of meaning no limit. IPv4 allowlist parsing rejects octets such as1abc.allowedArgPatternschecks strings nested in objects and arrays, and an invalid pattern denies instead of throwing. Time windows must beHH:MM, support overnight ranges (start after end), and a malformed window denies.policy.evaluatedenies an agent id with no matching row withPOLICY_AGENT_NOT_FOUND. A throwingafterAuthorizeoronViolationhook no longer causes an unhandled rejection. Delegation chain limits no longer spread large arrays intoMath.min. - Session and audit correctness fixes. Session refresh now creates the replacement before deleting the old session, and a concurrent refresh that loses the race no longer leaves two live sessions.
maxConcurrentis re-checked after insert, so concurrent sign-ins cannot exceed the cap (a racer that loses is dropped andcreate()throwsMultiSessionLimitError). A failing audit write no longer makesauthorize()throw. When the delegated fallback runs, one audit row is written for the final result instead of an orphan row per path.canonicalJsonrejects reference cycles and serializes BigInt. Rate limit windows are parsed once at construction, a zero window is rejected, and theclient_idbody scan reads at most 8 KB.
Packages in this release
| Package | Version | Changelog |
|---|---|---|
@glinr/theauth |
1.1.2 to 1.2.0 | CHANGELOG |
@glinr/theauth-cli |
1.1.2 to 1.1.3 | CHANGELOG |
theauth |
0.2.4 to 0.2.5 | CHANGELOG |
Install
npm install @glinr/theauth@1.2.0
pnpm add @glinr/theauth@1.2.0
yarn add @glinr/theauth@1.2.0
bun add @glinr/theauth@1.2.0Resources
- Quickstart and agent identity
- MCP OAuth 2.1 and DPoP
- Stability and versioning
- Migration guides
- Go library (releases)
- Questions and ideas: GitHub Discussions
- Security reports: SECURITY.md
Full changelog: v1.1.2...v1.2.0