@cavicode/sso-webclient (0.4.0)

Published 2026-09-06 14:16:20 +03:00 by CaviCode

Installation

@cavicode:registry=
npm install @cavicode/sso-webclient@0.4.0
"@cavicode/sso-webclient": "0.4.0"

About this package

CaviCode.SSO.WebClient

Версия 0.4.0: breaking release, согласована с NetClient 0.4.0. См. PROJECT.md, миграцию и индекс документации.

SSO BFF web client for CaviCode Network panels.

Consumes the /auth/* endpoints exposed by CaviCode.SSO.NetClient (server-side BFF). Does NOT handle OIDC directly — the BFF does all OIDC. This client just consumes the session.

Install

npm install @cavicode/sso-webclient

Usage

import { createPanelAuthApi, type PanelAuthHttpClient } from '@cavicode/sso-webclient'

// http implements get(path), post(path, undefined, { headers }) and rejects non-2xx
const auth = createPanelAuthApi(http)

// Get current user
const user = await auth.getCurrentUser()
// { subject, email, displayName, roles, role }

// Build login URL
const loginUrl = auth.buildLoginUrl('/dashboard')

// Refresh session
const refreshedUser = await auth.refreshSession()

// Logout
const endSessionUrl = await auth.logout(true)

API

  • createPanelAuthApi(http, options?) — options: rolePriority and paths
  • getCurrentUser()GET /auth/me
  • buildLoginUrl(returnUrl?, forceLogin?) — builds /auth/login?returnUrl=...
  • refreshSession()POST /auth/refresh-session
  • logout(federated?)POST /auth/logout?federated=...
  • pickPrimaryRole(roles, priority?) — pick primary role by priority
  • normalizePanelUser(payload, rolePriority?) — normalize user payload

Пустые roles дают role=null. POST refresh/logout передают X-CaviCode-CSRF: 1; adapter обязан сохранить этот заголовок и cookies. Параллельные refresh одного instance объединяются. Пути можно настроить через options.paths.

Dependencies

Development dependencies

ID Version
typescript ^5.7.0

Keywords

cavicode sso oidc bff auth
Details
npm
2026-09-06 14:16:20 +03:00
2
MIT
latest
4.3 KiB
Assets (1)
Versions (2) View all
0.4.0 2026-09-06
0.3.2 2026-07-25