@allservices/sdk-core
v1.3.0
Published
Type-safe universal client for the AllServices API (browser, node, edge, workers)
Maintainers
Readme
@allservices/sdk-core
Universal TypeScript client for the AllServices API. Runs in browsers, Node, edge, and workers.
Status: alpha. Public API may change between minors until
1.0.0.
Install
pnpm add @allservices/sdk-core @allservices/contracts zodUsage
import { AllServicesClient } from '@allservices/sdk-core';
const client = new AllServicesClient({
region: 'eu',
bearerToken: process.env.ALLSERVICES_PAT,
});
const me = await client.auth.me();
const licenses = await client.licensing.list();In browsers, swap bearerToken for credentials: 'include' to use the AllServices session cookie. Constructing with bearerToken in a browser environment throws EnvironmentError unless allowBrowserBearerToken: true is set explicitly.
Errors
Every API error is a typed subclass of AllServicesApiError: BadRequestError, UnauthorizedError, ForbiddenError, SudoRequiredError, NotFoundError, ConflictError, ValidationError, RateLimitedError, ServerError, BadGatewayError, ServiceUnavailable, TimeoutAtGateway. Each carries code, statusCode, requestId, headers, and retryable.
import { isSudoRequiredError, isRateLimitedError } from '@allservices/sdk-core';
try {
await client.auth.changePassword({ ... });
} catch (err) {
if (isSudoRequiredError(err)) {
// prompt the user to step up via client.auth.grantSudo
}
}Hooks
onRequest, onResponse, onError, onRetry for observability. Sensitive headers and body fields are redacted by default. Extend via redact: { headers, bodyFields }.
Documentation
See the main README and SECURITY.md.
License
UNLICENSED — internal AllServices use only.
