# @algorandfoundation/liquid-client

> Connect to a Liquid Auth service

Latest version **1.0.0-canary.3** (published 2024-12-18) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @algorandfoundation/liquid-client
pnpm add @algorandfoundation/liquid-client
yarn add @algorandfoundation/liquid-client
bun add @algorandfoundation/liquid-client
```

## Health

**Score 40/100 (D)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: insecure dependencies; stale.

## Facts

| | |
|---|---|
| Version | 1.0.0-canary.3 |
| Published | 2024-12-18 |
| First published | 2024-12-18 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 6 |
| Unpacked size | 251.1 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | yes |
| Author | Algorand Foundation |
| Maintainers | bruno.martins.algorand.foundation, dev_algorand.foundation, shane-at-algo, loedn, hmd2v, joe-p |

## Links

- npm: https://www.npmjs.com/package/@algorandfoundation/liquid-client
- npm.io page: https://npm.io/package/@algorandfoundation/liquid-client

## Dependencies (6)

- [uuid](https://npm.io/package/uuid.md) ^10.0.0
- [canvas](https://npm.io/package/canvas.md) ^2.11.2
- [tweetnacl](https://npm.io/package/tweetnacl.md) ^1.0.3
- [eventemitter3](https://npm.io/package/eventemitter3.md) ^5.0.1
- [socket.io-client](https://npm.io/package/socket.io-client.md) ^4.7.5
- [@algorandfoundation/qr-code-styling](https://npm.io/package/@algorandfoundation/qr-code-styling.md) github:algorandfoundation/qr-code-styling

## Recent versions

- 1.0.0-canary.3 (latest) — 2024-12-18
- 1.0.0-canary.10 (main) — 2026-08-13
- 0.0.1-beta.0 (beta) — 2026-06-04
- 1.0.0-canary.9 — 2026-06-10
- 1.0.0-canary.8 — 2026-06-08
- 1.0.0-canary.7 — 2026-06-08
- 1.0.0-canary.6 — 2026-04-16
- 1.0.0-canary.5 — 2026-03-20
- 1.0.0-canary.4 — 2026-03-20

## README

# Overview

This project is an example Client for TypeScript for using the Liquid-Auth API.

# Getting Started

## Install

```bash
npm install algorandfoundation/liquid-auth-js --save
````

# Usage

```typescript
import {SignalClient} from '@algorandfoundation/liquid-client';
const client = new SignalClient(window.origin);
```

See the [liquid-auth documentation](https://liquidauth.com/clients/browser/introduction/) for more information on the API.

## Browser Wallet Integration

#### Create a new account and passkey
```typescript
const testAccount = algosdk.generateAccount();
// Sign in to the service with a new credential and wallet
await client.attestation(async (challenge: Uint8Array) => ({
    type: 'algorand', // The type of signature and public key
    address: testAccount.addr, // The address of the account
    signature: toBase64URL(nacl.sign.detached(challenge, testAccount.sk)), // The signature of the challenge
    requestId: '019097ff-bb8d-7f68-9062-89543625aca5', // Optionally authenticate a remote peer
    device: 'Demo Web Wallet' // Optional device name
}))
```
#### Sign in with an existing account
```typescript
await client.assertion(
    credentialId, // Some known credential ID
    {requestId: '019097ff-bb8d-7f68-9062-89543625aca5'} // Optional requestId to link
)
```
#### Peering with a remote client

```typescript
// Create the Peer Connection and await the remote client's answer
client.peer('019097ff-bb8d-7f68-9062-89543625aca5', 'answer').then((dataChannel: RTCDataChannel)=>{
    // Handle the data channel
    dataChannel.onmessage = (event: MessageEvent) => {
        console.log(event.data)
    }
})
```

## Dapp Integration

```typescript
const requestId = SignalClient.generateRequestId();
client
    .peer(requestId, 'offer')
    .then((dataChannel: RTCDataChannel)=>{
        // Handle the data channel
        dataChannel.onmessage = (event: MessageEvent) => {
            console.log(event.data)
        }
    })
const blob = await client.qrCode()
```

## Interfaces

```typescript
interface SignalClient {
  readonly url: string; // Origin of the service
  type: "offer" | "answer" // Type of client
  peerClient: RTCPeerConnection | PeerClient // Native WebRTC Wrapper/Interface
  socket: Socket // The socket to the service

  readonly authenticated: boolean; // State of authentication
  readonly requestId?: string; // The current request being signaled

  /**
   * Generate a Request ID
   */
  generateRequestId(): string;

  attestation(...args: any[]): Promise<any>;
  assertion(...args: any[]): Promise<any>;
  
  /**
   * Top level Friendly interface for signaling
   * @param args
   */
  peer(requestId: string, type: 'offer' | 'answer', config?: RTCConfiguration): Promise<void>;

  /**
   * Link a Request ID to this client
   * @param args
   */
  link(...args: any[]): Promise<LinkMessage>;

  /**
   * Wait for a desciption signal
   * @param args
   */
  signal(...args: any[]): Promise<string>;

  /**
   * Terminate the signaling session
   */
  close(): void
  
  
  /**
   * Listen to Interface events
   * @param args
   */
  on(...args: any[]): void;

  /**
   * Emit an event to the interface
   * @param channel
   * @param callback
   */
  emit(channel: string, callback: (...args: any[])=>void)

}
```

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