IDENTITY / API REFERENCE

One SDK.
A clear contract.

Browser-side authentication built on oidc-client-ts with authorization code + PKCE.

@magnexis/identity · LOCAL PACKAGE

Client configuration

Construct MagnexisAuth with the exact identity issuer and redirect URI registered for your client. The SDK uses OIDC discovery and PKCE automatically.

JAVASCRIPT
import { MagnexisAuth } from '@magnexis/identity';

const auth = new MagnexisAuth({
  issuer: 'https://YOUR_AUTH_HOST/realms/magnexis',
  clientId: 'client-id-from-magnexis',
  redirectUri: 'https://your-website.example/auth/callback',
  postLogoutRedirectUri: 'https://your-website.example/',
  scope: 'openid profile email',
});

Core methods

REDIRECTauth.signIn()
CALLBACKauth.handleCallback()
SESSIONauth.getUser()
ACCESS TOKENauth.getAccessToken()
LOGOUTauth.signOut()
LOCAL CLEANUPauth.clearLocalSession()

Render a sign-in control

Initiate sign-in only after user interaction. Sign-in sends the browser to the identity provider; the current app never collects Magnexis passwords.

JAVASCRIPT
const button = document.getElementById('magnexis-signin');
button.addEventListener('click', async () => {
  try {
    await auth.signIn();
  } catch (error) {
    console.error('Could not begin sign-in', error);
  }
});
// Your callback route executes await auth.handleCallback().

Session safety

For the browser demonstration, the SDK stores transient authorization state and session data in sessionStorage, not permanent localStorage. Tokens remain accessible to JavaScript, so an XSS flaw can compromise a session. For sensitive systems, prefer a backend-for-frontend exchanging codes on a trusted server and issuing HttpOnly, Secure, SameSite cookies. Never treat a decoded ID token as authorization for a backend API; validate tokens server-side against issuer, audience, signature, and expiry.

◈
Package status: Source code is included with this website release but not published to npm, and production compatibility and release testing are pending.
SDK REFERENCE / INTEGRATION NOTES

Build a resilient sign-in experience.

A short API can still have important operational edges.

CONFIG

Keep metadata trustworthy

Use a fixed provider issuer and registered client identifier. Fetch discovery documents over HTTPS in production and never turn arbitrary user-supplied issuer URLs into authentication requests.

RETURN FLOW

Bind requests to responses

The SDK uses authorization code with PKCE. Applications should preserve their state and nonce validation requirements and avoid exposing tokens in logs, URL query strings, or third-party analytics.

STORAGE & LOGOUT

Handle session lifecycle

Prefer secure, short-lived sessions and bounded refresh behavior. Clear stale local state during sign-out and plan for a revoked or expired provider session.