# juicebox-sdk

> Register and recover PIN-protected secrets on behalf of a particular user.

Latest version **0.3.7** (published 2026-08-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install juicebox-sdk
pnpm add juicebox-sdk
yarn add juicebox-sdk
bun add juicebox-sdk
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.3.7 |
| Published | 2026-08-01 |
| First published | 2023-07-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 2.9 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | imperiopolis |

## Links

- npm: https://www.npmjs.com/package/juicebox-sdk
- npm.io page: https://npm.io/package/juicebox-sdk

## Recent versions

- 0.3.7 (latest) — 2026-08-01
- 0.3.6 — 2026-03-13
- 0.3.5 — 2026-03-07
- 0.3.4 — 2025-10-15
- 0.3.3 — 2025-10-15
- 0.3.2 — 2024-08-14
- 0.3.1 — 2024-08-14
- 0.3.0 — 2024-02-07
- 0.2.2 — 2023-12-05
- 0.2.2-alpha.12 — 2023-12-05
- 0.2.2-alpha.11 — 2023-12-05
- 0.2.1 — 2023-10-24
- 0.2.1-alpha.5 — 2023-10-23
- 0.2.1-alpha.4 — 2023-10-20
- 0.2.1-alpha.3 — 2023-10-17
- … 5 more at https://npm.io/package/juicebox-sdk/versions

## README

## JavaScript

Register and recover PIN-protected secrets on behalf of a particular user.

### Install

```
npm install -s juicebox-sdk
```

### Usage

Instantiate a `Client` with the appropriate `Realm`s you wish to communicate with.

The auth tokens should be acquired out-of-band from a server you run and specific to each realm id. All of the realms must be set up to accept this server's tokens.

For maximum security, we recommend utilizing multiple realms with a register and recover threshold greater than 1.

```typescript
import { Client, Configuration, Realm, PinHashingMode } from 'juicebox-sdk';

const client = new Client(
    // You should receive the realm parameters from your realm provider,
    // or configure them yourself for your self-hosted realm.
    new Configuration({
        realms: [
            {
                "address": "https://juicebox.hsm.realm.address",
                "id": "0102030405060708090a0b0c0d0e0f10",
                "public_key": "0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20"
            },
            {
                "address": "https://your.software.realm.address",
                "id": "2102030405060708090a0b0c0d0e0f10"
            },
            {
                "address": "https://juicebox.software.realm.address",
                "id": "3102030405060708090a0b0c0d0e0f10"
            }
        ],
        register_threshold: 3,
        recover_threshold: 3,
        pin_hashing_mode: "Standard2019"
    }),
    []
);

// fetch or read the correct token for the `realmId`
window.JuiceboxGetAuthToken = async (realmId) => authTokens[realmId];
```

Once you've created a client, you can register a secret for the `authToken`'s user by calling:

```typescript
await client.register(encoder.encode("1234"), encoder.encode("secret"), encoder.encode("info"), 2);
```

To recover the secret you just registered, you can call:

```typescript
const secret = await client.recover(encoder.encode("1234"), encoder.encode("info"));
```

And when you're ready to delete any secret from the remote store, simply call:

```typescript
await client.delete();
```

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