@unilim/cas (1.0.0)

Published 2026-08-14 06:45:12 +00:00 by Mikkel ALMONTE--RINGAUD in unilim/cas

Installation

@unilim:registry=
npm install @unilim/cas@1.0.0
"@unilim/cas": "1.0.0"

About this package

@unilim/cas

CAS (Central Authentication Service) bindings for Unilim, compiled from Rust to WebAssembly.

This package owns the CAS client and exposes the CAS session object that the other Unilim service packages (@unilim/biome, @unilim/signatures) consume across the JS boundary.

Install

npm install @unilim/cas

Usage

import { CAS } from "@unilim/cas";

// 1. with 2FA (email or TOTP)
const pending = await CAS.initialize(username, password);
if (pending.isTotpAvailable) await pending.solveWithTotp(code);
// (PendingAuth.finish() is internal; restore() below is the persistent path)

// 2. restore a persistent session
const cas = await CAS.restore(username, password, connection, key);

// 3. hand the CAS object to a service package
//    import { Biome } from "@unilim/biome";
//    const biome = await Biome.fromCAS(cas);

Sharing the CAS object across packages

Service packages receive this CAS object directly rather than a cookie string, and source the type from this crate (Cargo features):

  • wasm - unilim_cas::wasm, wasm-bindgen extern declarations of the JS classes (#[wasm_bindgen(module = "@unilim/cas")]). A consumer calls the object's methods across the JS boundary; the object lives on the JS heap and never crosses wasm-module memory. Pulls no client code.
  • client - unilim_cas::{CAS, OAuth2, ...}, the real native client, so native consumers can call the same methods directly.
[target.'cfg(target_arch = "wasm32")'.dependencies]
unilim-cas = { version = "...", default-features = false, features = ["wasm"] }
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
unilim-cas = { version = "...", default-features = false, features = ["client"] }

Examples

  • examples/login.ts / examples/service.ts — TS, against the built package.
  • examples/login.rs / examples/service.rs — native Rust (cargo run --example login).

Development

cargo test                  # totp + 2FA-parse unit tests
cargo run --example login   # interactive CAS login (native)
bun x @mentor/wasm          # build the @unilim/cas package into exported/
bun examples/login.ts       # TS example (needs the package installed/linked)

License

GPL-3.0-or-later — see LICENSE.md. Not affiliated with the University of Limoges.

Keywords

unilim cas authentication api wrapper
Details
npm
2026-08-14 06:45:12 +00:00
2
Mikkel ALMONTE--RINGAUD
GPL-3.0-or-later
491 KiB
Assets (1)
cas-1.0.0.tgz 491 KiB
Versions (2) View all
1.0.1 2026-08-15
1.0.0 2026-08-14