@wisdomai/node
v0.1.0
Published
Server-side Node SDK for Wisdom AI
Keywords
Readme
@wisdomai/node
Server-side Node SDK for Wisdom AI. Exchange a long-lived access token for a short-lived JWT that a browser frontend can use to authenticate against Wisdom's API.
Consumed inside this monorepo via the @wisdomai/node TypeScript path alias in javascript/tsconfig.base.json (same pattern as delta and utils).
Usage
import { WisdomAI } from '@wisdomai/node';
const wisdom = new WisdomAI({
accessToken: process.env.WISDOM_ACCESS_TOKEN!,
baseUrl: process.env.WISDOM_BASE_URL!,
});
const { jwt, baseUrl } = await wisdom.getAuthToken();
// Hand `jwt` (and `baseUrl`) to your frontend. The JWT is short-lived.baseUrl is your Wisdom tenant origin — include the protocol, no path.
- ✅
https://your-tenant.wisdom.ai - ❌
https://your-tenant.wisdom.ai/graphql(the SDK appends/graphqlitself) - ❌
your-tenant.wisdom.ai(missing protocol)
Trailing slashes are stripped automatically.
Never call this SDK from a browser. The access token is a long-lived credential. The constructor throws if it detects both window and document in the global scope.
Errors
Two classes:
WisdomAuthError— the access token was rejected (invalid, expired, revoked, or the deployment has Descope disabled). Surface as 401.WisdomError— everything else (network failure, timeout, 4xx/5xx, malformed response). Surface as 502/500.
Both preserve the original failure on a cause property. cause is a plain class field (not the ES2022 Error.cause option on Error), so it behaves the same at runtime regardless of the compile target.
Running unit tests
nx test node-sdkTypecheck
nx typecheck node-sdk