@gooclaim/aiveth is the Aiveth by Gooclaim SDK for Node servers. Use it to check ID tokens, access tokens, machine tokens and AI agent tokens, to verify webhooks, and to call the admin API.
Install
Requires Node 18.17 or later. CommonJS (require) and ES modules (import) both work.
Configure
Each environment has its own keys:
aiveth_sk_test_... for Development and aiveth_sk_live_... for production.
Tokens
tokens.verifyIdToken(token, { clientId })
Checks an app’s ID token offline, against Aiveth’s published keys: signed by Aiveth, for this app, and not expired. Returns the claims.
tokens.userFromAccessToken(accessToken)
An app’s access token is opaque. Aiveth says who it stands for. Returns the claims, or null when the token has ended.
tokens.verifyMachineToken(token, { orgId })
Checks a machine app’s token meant for your organization’s services.
tokens.verifyMcpToken(token, { resource, scopes? })
Checks an AI agent’s token for your MCP server. resource is the server’s address as registered in Aiveth. A token for any other server is refused. Missing scopes throw InsufficientScopeError.
tokens.connectedToken({ accessToken, connection, clientId, clientSecret })
Gets the Google, Microsoft or GitHub token a person connected for your organization’s apps. Server only: it needs your app’s secret, and the app must have Connected accounts turned on.
tokens.discover()
Returns Aiveth’s OpenID Connect discovery document. The other token methods call it for you.
hasFlag(claims, key)
Is a feature flag on for this person? Aiveth puts the flags that are on for the person in the ID token as feature_flags.
Webhooks
verifyWebhook(rawBody, headers, secret, options?)
Checks that Aiveth signed exactly these bytes, recently, and returns the parsed message. Throws WebhookVerificationError otherwise. secret is the whsec_... secret the console showed once.
Pass the raw body. Parsing and re-serialising JSON changes the bytes.
webhook-id, webhook-timestamp and webhook-signature headers (Standard Webhooks). The timestamp may be up to 5 minutes (TOLERANCE_SECONDS) from now, or set { toleranceSeconds }. A message may arrive twice: keep the webhook-ids you have handled and skip repeats. See Webhooks.
Admin API
These need an API key with the right power. Every refusal throwsAivethError with Aiveth’s message and status.
People
Invitations and roles
Organization fields
Fine-grained permissions
Make types of part and their roles in the console first. See Fine-grained authorization.Consent
For apps that ask for consent on their own screen. See Consent.allows each time rather than storing the answer.
Events
events.list({ types?, after?, limit?, rangeStart? })
Reads your organization’s events, oldest first. Page on with list_metadata.after. Needs events:read.
Protect an MCP server
Register your MCP server in the console under AI agents with its address and permissions. Then serve the protected resource metadata and check each request’s token:
An agent token is for one MCP server (its
aud). It lasts 10 minutes, and the agent renews it. See MCP servers.
Errors
All of them extend
AivethError. An outage while checking a token throws AivethError, never TokenVerificationError, so you can tell a bad token from a network problem.