unilim-cas (1.0.0)

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

Installation

[registries.forgejo]
index = "sparse+" # Sparse index
# index = "" # Git

[net]
git-fetch-with-cli = true
cargo add unilim-cas@1.0.0 --registry forgejo

About this package

A purrfect CAS authentication wrapper for Unilim.

@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.

Dependencies

ID Version
rikka ^0.1
scraper ^0.21
serde ^1
thiserror ^2
totp-rs ^5
url ^2
web-time ^1
anyhow ^1
dotenvy ^0.15
inquire ^0.7
tokio ^1
getrandom ^0.3
js-sys ^0.3
lol_alloc ^0.4
tsify-next ^0.5
wasm-bindgen ^0.2
wasm-bindgen-futures ^0.4

Keywords

unilim cas authentication api wrapper
Details
Cargo
2026-08-14 06:45:42 +00:00
4
Mikkel ALMONTE--RINGAUD <contact@vexcited.com>
GPL-3.0-or-later
43 KiB
Assets (1)
Versions (2) View all
1.0.1 2026-08-15
1.0.0 2026-08-14