The open-source AI receptionist for businesses. Answers every call, books the appointment and hands over to a person when needed. You own the code and the data.
TypeScript ai-receptionistanswering-serviceappointment-bookinglivekitlocal-firstmcpopen-sourceself-hostedsiptelephonytypescriptvoice-agentvoice-ai
import { createHash } from 'node:crypto'
import { describe, expect, it } from 'vitest'
// The PKCE check of the app's sign-in hand-back (app-sign-in.ts): the same S256 the web app computes (native/sign-in/appSignIn.ts).
const s256 = (verifier: string) => createHash('sha256').update(verifier).digest('base64url')
import { START_TTL_S, sessionFitsStart, verifierFits } from './app-sign-in-pkce.ts'
describe('verifierFits', () => {
const verifier = 'dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk'
it('accepts the verifier whose SHA-256 is the challenge', () => {
expect(verifierFits(verifier, s256(verifier))).toBe(true)
})
it('refuses any other verifier', () => {
expect(verifierFits(`${verifier.slice(0, -1)}A`, s256(verifier))).toBe(false)
})
})
describe('sessionFitsStart', () => {
const start = { challenge: 'c', at: 1_000_000 }
it('takes only a session made after the start (the provider sign-in of this flow)', () => {
expect(sessionFitsStart(new Date(1_000_500), start, 1_001_000)).toBe(true)
// The browser's session from before: never handed to the app.
expect(sessionFitsStart(new Date(999_999), start, 1_001_000)).toBe(false)
})
it('not after the start ran out', () => {
expect(sessionFitsStart(new Date(1_000_500), start, start.at + START_TTL_S * 1000 + 1)).toBe(false)
})
})