npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@algorandfoundation/liquid-client

v1.0.0-canary.3

Published

Connect to a Liquid Auth service

Downloads

56

Readme

Overview

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

Getting Started

Install

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

Usage

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

See the liquid-auth documentation for more information on the API.

Browser Wallet Integration

Create a new account and passkey

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

await client.assertion(
    credentialId, // Some known credential ID
    {requestId: '019097ff-bb8d-7f68-9062-89543625aca5'} // Optional requestId to link
)

Peering with a remote client

// 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

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

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)

}