@xelluxofficial/auth
v0.2.0
Published
Official JavaScript/TypeScript SDK for Xellux ID — drop-in OAuth 2.0 / OIDC authentication plus the read-only Account API.
Downloads
139
Maintainers
Readme
@xelluxofficial/auth
Official JavaScript / TypeScript SDK for Xellux ID. Works anywhere fetch() works: browsers, Node, Next.js, React, Vite, Vue.
Requirements
- Node ≥ 18 (native
fetch), or any modern browser. - Optional peer deps:
react >= 17for/react,next >= 13for/nextjs.
Install
npm install @xelluxofficial/authQuick usage
import { XelluxAuth } from '@xelluxofficial/auth';
const xellux = new XelluxAuth({
clientId: process.env.XELLUX_CLIENT_ID!,
clientSecret: process.env.XELLUX_CLIENT_SECRET,
redirectUri: 'https://app.example.com/auth/callback',
});
// Start flow
await xellux.login();
// Callback
const tokens = await xellux.exchange({ code, state });
const user = await xellux.userInfo(tokens.access_token);React
import { XelluxProvider, useXelluxAuth } from '@xelluxofficial/auth/react';
<XelluxProvider clientId={CLIENT_ID} redirectUri={REDIRECT_URI}>
<App />
</XelluxProvider>Next.js
// app/auth/[...xellux]/route.ts
export { GET, POST } from '@xelluxofficial/auth/nextjs/handlers';
// middleware.ts
import { xelluxMiddleware } from '@xelluxofficial/auth/nextjs';
export default xelluxMiddleware({ protectedPaths: ['/dashboard/:path*'] });Account API (read-only)
Authenticate with a personal API key (xlx_sk_…) created in the dashboard's
API Keys tab. A key unlocks the owner's own profile and activity only —
realm, client and user administration stays in the dashboard.
import { XelluxAccount } from '@xelluxofficial/auth';
const xellux = new XelluxAccount({ apiKey: process.env.XELLUX_API_KEY! });
const me = await xellux.account.get(); // requires the account:read scope
const recent = await xellux.account.activity({ limit: 25 }); // activity:readLinks
License
MIT
