open-index/open-npm huggingface dataset:
npm package: @otech_eng/sso-backend
Description: Production-ready backend SSO token service for OTech ERP integration, enabling client JavaScript applications to act as trusted identity providers.
Author: Latit Tibabu @ OTech Engineering
Latest version: 1.0.0

# @otech_eng/sso-backend

Backend token generation for OTech ERP SSO, where a client's JavaScript application acts as the identity provider.

## Installation

```bash
npm install @otech_eng/sso-backend
```

## Tests

```bash
npm test
```

Test files live in `backend/tests`.

## CommonJS Usage

```javascript
const ssoService = require("@otech_eng/sso-backend");

const token = ssoService.generateToken(
  user,
  accessControls,
  process.env.SSO_AUDIENCE || "otech-erp",
  process.env.SSO_SHARED_SECRET,
  process.env.SSO_ISSUER || "otech-auth"
);
```

## ESM Usage

```javascript
import ssoService, { generateToken } from "@otech_eng/sso-backend";

const tokenA = ssoService.generateToken(user, [], "otech-erp", secret, "otech-auth");
const tokenB = generateToken(user, [], "otech-erp", secret, "otech-auth");
```

## API

### `generateToken(user, accessControls, audience, secret, issuer?, options?)`

- Validates required input (`user`, `audience`, `secret`, `user.id/sub`)
- Signs HS256 JWT with issuer/audience/subject
- Adds `jti` and short TTL by default

`options` supports `expiresIn` and overrides default TTL behavior.

## ERP Trust Alignment

For successful SSO into OTech ERP, the following values must match between the client app and ERP setup:

- `secret` (signing/verification)
- `issuer` (`iss`)
- `audience` (`aud`)
npm package: @otech_eng/sso-frontend
Description: Production-ready frontend SSO handoff utilities for OTech ERP integration, allowing client JavaScript applications to authenticate users into ERP.
Author: Latit Tibabu @ OTech Engineering
Latest version: 1.0.0

# @otech_eng/sso-frontend

Framework-agnostic frontend utilities for handing off authenticated users from a client JavaScript app to OTech ERP.

## Installation

```bash
npm install @otech_eng/sso-frontend
```

## Tests

```bash
npm test
```

Test files live in `frontend/tests`.

## Works In

- Plain browser JavaScript
- React, Vue, Angular, Svelte
- Bundlers and runtimes using either ESM (`import`) or CommonJS (`require`)

## API

### `triggerSSO(apiEndpoint, targetBaseUrl, authToken, options?)`

Fetches an SSO token from your client backend and submits it to `${targetBaseUrl}/auth/sso/callback` via hidden form POST.

### `createSSOClient(defaults?)`

Creates a reusable client with defaults (`apiEndpoint`, `targetBaseUrl`, `authToken`, `options`).

### `useSSO()`

Compatibility helper that returns `{ triggerSSO }`. This is not React-specific and can be used anywhere.

## ESM Usage

```javascript
import { triggerSSO, createSSOClient } from "@otech_eng/sso-frontend";

await triggerSSO(apiEndpoint, targetBaseUrl, authToken, {
  allowedTargetOrigins: [new URL(targetBaseUrl).origin],
});

const sso = createSSOClient({
  apiEndpoint,
  targetBaseUrl,
  options: { timeoutMs: 10000 },
});
await sso.triggerSSO(undefined, undefined, authToken);
```

## CommonJS Usage

```javascript
const { triggerSSO } = require("@otech_eng/sso-frontend");

await triggerSSO(apiEndpoint, targetBaseUrl, authToken);
```

## Integration Context

- Your client JavaScript application remains the identity provider.
- OTech ERP accepts the signed token and creates the ERP session.
- `issuer`, `audience`, and shared secret must match ERP-side configuration.