Skip to content

hazae41/latrine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

137 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Latrine

Secure and private WalletConnect client

npm i @hazae41/latrine

NPM 📦

Features

Current features

  • Uses web standards
  • Supply-chain hardened
  • No trackable identifiers
  • Auditable cryptography
  • Minimalist and reliable
  • Can work on Deno/Node

Usage

const jwk = crypto.getRandomValues(new Uint8Array(32))
const client = await IrnClient.open(WalletConnect.RELAY, jwk, "c6c9bacd35afa3eb9e6cccf6d8464395")

App-side

const pairing = await WcPairing.generate(client)

pairing.addEventListener("upgrade", async e => {
  const session = e.data

  session.addEventListener("settle", e => console.log("Session ready to use"))
  session.addEventListener("event", e => console.log(e.data))
  session.addEventListener("close", () => console.log("Session closed"))

  await session.open()
})

await pairing.open()

console.log(pairing.url)

await pairing.propose(...)

See ./run/mod.ts for a full example

Wallet-side

const pairing = await WcPairing.from(client, WcPairingParams.parse(url))

pairing.addEventListener("propose", event => {
  event.respondWith(pairing.respond(event.data))
})

pairing.addEventListener("upgrade", async e => {
  const session = e.data

  session.addEventListener("request", e => e.respondWith(...))
  session.addEventListener("close", () => console.log("Session closed"))

  await session.open()
  
  const relay = session.channel.client.relay

  const { requiredNamespaces, optionalNamespaces } = proposal

  const controller = { metadata, publicKey: new Uint8Array(await crypto.subtle.exportKey("raw", pairing.keypair.publicKey)).toHex() }

  const expiry = Math.floor(Date.now() / 1000) + (365 * 24 * 60 * 60)

  await session.settle({ relay, namespaces, requiredNamespaces, optionalNamespaces, pairingTopic: pairing.channel.topic, controller, expiry })

  console.log("Session ready to use")
})

await pairing.open()

See ./run/mod.ts for a full example

About

Secure and private WalletConnect client

Resources

License

Stars

Watchers

Forks

Sponsor this project

Packages

 
 
 

Contributors