inbox-auth.test.ts (768B)
1 import { describe, it, expect } from 'vitest'; 2 import { PRIVATE_AUTH_BUDGETS } from '../../src/lib/config/budgets.ts'; 3 import { 4 inboxAuthSnapshot, 5 respondInboxAuthentication, 6 closeInboxAuthentication 7 } from '../../src/lib/nostr/inbox-auth.ts'; 8 describe('connection AUTH admission', () => { 9 it('retains the exact two-response authority', () => { 10 expect(PRIVATE_AUTH_BUDGETS.responsesPerConnectionAction).toBe(2); 11 }); 12 it('forged actions never become signer or transport authority', async () => { 13 const forged = {} as never; 14 expect(inboxAuthSnapshot(forged)).toBeUndefined(); 15 expect(await respondInboxAuthentication(forged)).toEqual({ 16 status: 'invalid' 17 }); 18 expect(() => closeInboxAuthentication(forged)).not.toThrow(); 19 }); 20 });