A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/agree-able/invite below:

agree-able/invite: simplify the room invitation flow

Agreeable Room Invitations

A utility for loading and configuring room settings with support for invites, domain-based configuration, and identity verification through Keybase.

npm install @agree-able/invite
import { load } from '@agree-able/invite'

// Simple usage with direct invite
const config = { invite: 'your-invite-code' }
const result = await load(config, confirmEnterRoom)

// Domain-based configuration with DID lookup
const config = { 
  domain: 'example.com',
  loadDid: true
}
const result = await load(config, confirmEnterRoom)

// With Keybase verification
const config = {
  domain: 'example.com',
  keybaseUsername: 'username',
  privateKeyArmored: 'your-pgp-key'
}
const result = await load(config, confirmEnterRoom)
The confirmEnterRoom Function

The confirmEnterRoom function is required and must handle room entry expectations. It receives room expectations and host details, and should return an acceptance object.

const confirmEnterRoom = async (expectations, hostDetails) => {
  // expectations contains room requirements
  // hostDetails may contain verification details if whoami is enabled
  
  console.log('room rules', expectations.rules)
  console.log('room reason', expectations.reason)

  // Example of checking whoami verification
  if (hostDetails?.whoami?.keybase) {
    const { verified, username } = hostDetails.whoami.keybase
    if (!verified) {
      throw new Error(`Keybase verification failed for ${username}`)
    }
  }

  // you must return the acceptance object back to the server
  return {
    reason: true, // 'agree to the reason for the room'
    rules: true // 'agree to the rules for the room'
  }
}

The load function accepts a configuration object with the following options:

The function returns a Promise resolving to an object containing:

MIT


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4