open-index/open-npm huggingface dataset:
npm package: @shoojs/auth
Description: Framework-agnostic Shoo auth client for browser apps.
Latest version: 0.2.2

# @shoojs/auth

Framework-agnostic Shoo auth client for browser apps.

## Install

```bash
npm install @shoojs/auth
```

## Usage (Vanilla)

```ts
import { createShooAuth } from "@shoojs/auth";

const auth = createShooAuth({
  shooBaseUrl: "https://shoo.dev",
  callbackPath: "/auth/callback"
});

// Start login
await auth.startSignIn();

// Safe to run on every page load
await auth.handleCallback();

// Read identity
const identity = auth.getIdentity();
console.log(identity.pairwiseSub);

// Explicit revocation/session check
const session = await auth.checkSession();
if (session.status === "login_required") {
  auth.clearIdentity();
}

// Optional automatic monitor (default 60s)
const monitor = auth.startSessionMonitor({
  intervalMs: 60_000,
  onLoginRequired: () => {
    auth.clearIdentity();
  }
});

// Later: monitor.stop();
```

## Notes

- `@shoojs/auth` is browser-only.
- Browser token exchange does not accept `clientSecret`; use a server-side exchange for confidential clients.
- `checkSession()` returns `active`, `login_required`, or `unsupported` (for older Shoo servers without `/session/check`).
npm package: @shoojs/react
Description: React hooks wrapper for `@shoojs/auth`.
Latest version: 0.2.2

# @shoojs/react

React hooks wrapper for `@shoojs/auth`.

## Install

```bash
npm install @shoojs/react @shoojs/auth
```

## Usage

```tsx
import { useShooAuth } from "@shoojs/react";

export function App() {
  const auth = useShooAuth({
    shooBaseUrl: "https://shoo.dev",
    callbackPath: "/auth/callback",
    autoSessionMonitor: true,
    sessionMonitorIntervalMs: 60_000
  });

  return (
    <div>
      <button onClick={() => void auth.signIn()}>Sign In</button>
      <button onClick={() => void auth.checkSession()}>Check Session</button>
      <p>{auth.identity.userId ?? "Signed out"}</p>
      <p>Session state: {auth.sessionState}</p>
    </div>
  );
}
```

## Session checks

- `useShooAuth` exposes `checkSession()` for explicit revocation/session validation.
- When `autoSessionMonitor` is enabled (default), the hook runs periodic background checks and clears local identity on `login_required`.