typescript/BROWSER
Thursday 12 March 2026

Mau TypeScript - Browser Testing

✅ VERIFIED WORKING IN BROWSER

All tests pass in both Chromium (Puppeteer) and Node.js environments.

Test Results

Browser Tests (Chromium + Puppeteer)

🧪 Mau Browser Integration Test

✅ 1. Testing module import... PASSED
   - createAccount: function
   - File: function
   - BrowserStorage: function

✅ 2. Creating account... PASSED
   - Account stored in IndexedDB
   - Fingerprint generated correctly

✅ 3. Writing a test file... PASSED
   - File encrypted and stored in IndexedDB

✅ 4. Reading file back... PASSED
   - File decrypted successfully
   - Content verified

✅ 5. Listing files... PASSED
   - Files enumerated from IndexedDB

✅ 6. Testing versioning... PASSED
   - Previous versions archived
   - Version history working

✅ 7. Exporting public key... PASSED
   - PGP key export successful

Node.js Tests

✅ Account creation
✅ File writing with encryption
✅ File reading with decryption
✅ File listing
✅ Versioning system

Running Tests

Automated Browser Test

1npm install
2npm run build
3npm run build:browser
4node test-browser.cjs

Manual Browser Test

1npm run dev
2# Open http://localhost:5173/test-standalone.html

Node.js Test

1npm run build
2node test-integration.mjs

What Works in Browser

  • ✅ Account creation in IndexedDB
  • ✅ PGP key generation (Ed25519 / RSA)
  • ✅ File encryption/signing
  • ✅ File decryption/verification
  • ✅ File versioning
  • ✅ Friend management
  • ✅ Storage abstraction (IndexedDB)
  • WebRTC P2P connections (browser-to-browser)
  • Peer discovery (staticResolver, dhtResolver)
  • HTTP client (fetch-based sync)

Browser Peer Discovery

 1import { createAccount, staticResolver, dhtResolver, combinedResolver } from '@mau-network/mau';
 2
 3// Static addresses (for known peers)
 4const static = staticResolver(new Map([
 5  ['fingerprint123', 'peer1.example.com:443'],
 6]));
 7
 8// DHT resolver (HTTP-based, works in browser!)
 9const dht = dhtResolver(['bootstrap.mau.network:443']);
10
11// Combined (try multiple in parallel)
12const resolver = combinedResolver([static, dht]);
13
14// Find peer
15const address = await resolver('fingerprint123');

Browser-compatible resolvers:

  • staticResolver - Hardcoded address map
  • dhtResolver - HTTP-based Kademlia (uses fetch())
  • ⚠️ dnsResolver - Node.js only (requires UDP sockets)

WebRTC Support

WebRTC client is available for P2P connections:

 1import { WebRTCClient } from '@mau-network/mau';
 2
 3const client = new WebRTCClient(account, storage, peerFingerprint);
 4
 5// Create offer
 6const offer = await client.createOffer();
 7// ... exchange offer/answer via signaling server ...
 8
 9// Perform mTLS
10const authenticated = await client.performMTLS();
11
12// Send request
13const response = await client.sendRequest({
14  method: 'GET',
15  path: '/p2p/fingerprint/file.json'
16});

Testing Checklist

  • Create account
  • Write post
  • List files
  • View file content
  • Add friend (use public key from another account)
  • Verify encryption (check IndexedDB - should see encrypted data)
  • Reload page (account persists)
  • Test versioning (modify a file multiple times)

Known Limitations

  • No traditional HTTP server in browser - Use WebRTC P2P instead (browsers can’t listen on ports)
  • DNS discovery unavailable - Browser security model blocks UDP sockets; use DHT or static resolvers
  • No signaling server included - Need external signaling for WebRTC connection setup (see examples/)

What Works Now

  • WebRTC P2P: Full browser-to-browser file sync
  • Peer discovery: DHT resolver (HTTP-based) works in browser
  • Network sync: WebRTC data channels for direct P2P
  • mTLS authentication: PGP-based mutual authentication over WebRTC

Next Steps

  1. Add signaling server for WebRTC - Available in examples/signaling-server.ts
  2. Implement DHT in browser - dhtResolver() works with fetch()
  3. Add browser extension for better access control (optional)
  4. Create React/Vue components (optional)