npm.io
0.2.1 • Published yesterday

@faiber/faiber-idp

Licence
Version
0.2.1
Deps
1
Size
29 kB
Vulns
0
Weekly
0

@faiber/faiber-idp

Typed, framework-neutral TypeScript client for Faiber identity, authentication, users, roles, and permissions.

Install

npm install @faiber/faiber-idp

Create a client

import { FaiberClient, MemoryTokenProvider } from "@faiber/sdk-core";
import { IdpApi } from "@faiber/faiber-idp";

const tokens = new MemoryTokenProvider();
const client = new FaiberClient("idp", {
  domains: { idp: process.env.FAIBER_IDP_URL! },
  tokenProvider: tokens,
  axios: { timeout: 15_000, withCredentials: true },
});
const api = new IdpApi(client);

const result = await api.login({ email, password });

All methods return a full Axios AxiosResponse. Entities, named request inputs, response envelopes, pagination models, and shared core types are exported from the package. Use client.request<TResponse, TBody>() for project-specific endpoints.

Authentication

Pass a TokenProvider for bearer authentication, or set withCredentials: true for secure cookie sessions. The SDK never reads browser storage or environment variables implicitly.

Errors and cancellation

Axios errors are preserved so callers can inspect response.status, structured API error bodies, headers, and request IDs. Pass normal Axios options as the final argument:

await api.client.get("/health", undefined , { signal: AbortSignal.timeout(5_000) });

Complete SDK

Install @faiber/faiber-ts-sdk when an application uses multiple Faiber services. The complete package provides shared configuration, authentication, uploads, and error handling across services.