# @obsigil/client

> Front-end client for obsigil mandate tokens: open the manifest, forward the mandate

Latest version **0.1.0** (published 2026-07-02) · MIT OR Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @obsigil/client
pnpm add @obsigil/client
yarn add @obsigil/client
bun add @obsigil/client
```

## Health

**Score 55/100 (C)** — status: active.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2026-07-02 |
| First published | 2026-07-02 |
| Weekly downloads | 0 |
| License | MIT OR Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=20 |
| Dependencies | 1 |
| Unpacked size | 38.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Bojan Đuričković |
| Maintainers | deyanovich |
| Keywords | obsigil, mandate, token, jwt, credential, frontend |

## Links

- npm: https://www.npmjs.com/package/@obsigil/client
- Repository: https://gitlab.com/obsigil/obsigil-ts
- Homepage: https://obsigil.org
- Issues: https://gitlab.com/obsigil/obsigil-ts/-/issues
- npm.io page: https://npm.io/package/@obsigil/client

## Dependencies (1)

- [@obsigil/core](https://npm.io/package/@obsigil/core.md) ^0.1.0

## Alternatives

- [@pothos/plugin-authz](https://npm.io/package/@pothos/plugin-authz.md) — 12.4K weekly downloads
- [@bounded-sh/client](https://npm.io/package/@bounded-sh/client.md) — 3.2K weekly downloads
- [@luigi-project/plugin-auth-oauth2](https://npm.io/package/@luigi-project/plugin-auth-oauth2.md) — 2.3K weekly downloads
- [@nocobase/plugin-verification](https://npm.io/package/@nocobase/plugin-verification.md) — 2.0K weekly downloads
- [escher-request](https://npm.io/package/escher-request.md) — 545 weekly downloads

## Recent versions

- 0.1.0 (latest) — 2026-07-02

## README

# @obsigil/client

Front-end client for [obsigil](https://obsigil.org) mandate tokens.
A front end does two things, and holds **no mandate key**:

1. **Read the manifest claims** for display — keyless, advisory.
2. **Forward the mandate** to the backend for enforcement.

## Install

```sh
pnpm add @obsigil/client
```

ESM-only; requires Node ≥ 20 (or a browser / edge runtime with
global WebCrypto).

## API

```ts
import {
  claims,
  manifest,
  manifestPlaintext,
  mandate,
  authorizationHeader,
  MANIFEST_KEY,
} from "@obsigil/client";

// 1. Read the manifest claims (keyless, advisory — never authoritative; the
//    manifest-is-non-authoritative rule of the Security Considerations, §16.7)
const c = claims(token); // Claims | null
if (c) renderUserChrome(c.iss);

// 2. Send the mandate to the backend (the manifest-absent form; forwarding
//    the mandate, Audiences, §9)
const auth = authorizationHeader(token); // "Bearer .0mandate" | null
if (auth) fetch("/api", { headers: { Authorization: auth } });
else reauthenticate();
```

- **`claims(token): Claims | null`** — decrypts the manifest with
  the public `MANIFEST_KEY` under algorithm code `0` (AES-SIV) or
  `1` (AES-GCM-SIV) and strictly decodes its canonical CBOR map
  (Serialization, spec §7). Returns `null` — "display nothing" — on
  anything untrustworthy: no manifest, malformed token, bad
  encoding, an oversized half, auth failure, unsupported algorithm,
  non-canonical CBOR, or a manifest missing its required `iss` (the
  iss reserved field, spec §8.6). Never throws, never an oracle.
- **`manifest(token): string \| null`** — the encoded manifest half
  on its own, as the manifest-only token form `"<manifest>0."` (the
  mirror of `mandate`). Pure string work; no key.
- **`manifestPlaintext(token): Uint8Array \| null`** — the manifest
  half's raw canonical-CBOR octets, decrypted keyless under
  `MANIFEST_KEY` (the byte-level mirror of `claims`). Advisory
  only.
- **`mandate(token): string \| null`** — the manifest-absent
  `.0mandate` token to hand the backend (forwarding the mandate,
  Audiences, spec §9). Pure string work; no key, no decryption;
  forwards even a mandate the client cannot open.
- **`authorizationHeader(token, scheme?): string \| null`** —
  `mandate()` prefixed with a scheme (default `Bearer`; the
  bearer-credential rule of the Security Considerations, spec
  §16.9). Pass `""` for the bare token.
- **`MANIFEST_KEY: Uint8Array`** — the 64-byte public manifest key
  pinned by the spec (the published manifest key, Construction,
  §5.2), baked in.

## Trust model

Manifest claims are **advisory only** and attacker-forgeable: the
manifest is sealed keyless (the published manifest key §5.2; the
manifest-is-non-authoritative rule of the Security Considerations
§16.7). Never make an access-control decision from them.
Authoritative subject/role/issuer come from the backend after it
verifies the mandate. A manifest `exp`, if present, is a refresh
hint — never enforcement (the exp reserved field, spec §8.3).

## Bundle

Supporting both algorithm codes pulls in noble's `aessiv` and
`gcmsiv` + HKDF-SHA-256, the b64url/hex decoders, and the strict
canonical-CBOR decoder. No minting, no mandate decryption.

## License

Licensed under either of

- Apache License, Version 2.0
  ([LICENSE-APACHE](LICENSE-APACHE) or
  <https://www.apache.org/licenses/LICENSE-2.0>)
- MIT license ([LICENSE-MIT](LICENSE-MIT) or
  <https://opensource.org/licenses/MIT>)

at your option.

### Contribution

Unless you explicitly state otherwise, any contribution
intentionally submitted for inclusion in the work by you, as
defined in the Apache-2.0 license, shall be dual licensed as
above, without any additional terms or conditions.

---
_Source: https://npm.io/package/@obsigil/client · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
