argus/src/web/libauth-entry.js
Local Dev a45320db7d Initial commit — Silent Mode baseline (2026-07-29)
Snapshot of the decentralized-web stack at the point of the resolver+Theseus
rebuild deploy. Includes:

- Argus (BNS engine + resolver daemon + Sia gateway)
- AriadneResolver (Windows Inno installer bundle + Android APK sources +
  Firefox extension)
- TheseusNavigator (Electron browser)
- site/ (silentmode.st content, deployed to Sia at bns/silentmode/)
- design docs, roadmap, protocol spec

Secrets excluded via .gitignore: Argus/sia-s3.json, Argus/wallets.json,
Argus/ca/*.key,*.crt. Build outputs, node_modules, and bundled runtimes
also excluded.

Shipped hashes on dl.silentmode.st at this commit:
  AriadneResolver-Setup-0.1.0.exe    5bcb216eef31ea28ed767e4134ab74bd5ac69dfbd365fd249e9e6938e55c986a
  TheseusNavigator-Setup-0.0.1.exe   7c735e88bad2da3347145adba3016c8f626a18b8422289c8c6ba471972e2952b
  TheseusNavigator-0.0.1-portable.exe 008fd84445babeabb401b2bca40ea9466b24b0e6d6c85104da7640c5c5c84521
  ariadne-v0.2.apk                   635c8f04d44ef855a8390b9eeddb8cd2d50622e81cc4e5004e8daffc1bb0425c
2026-07-29 13:54:34 +02:00

77 lines
2.6 KiB
JavaScript

// A single shared libauth for the whole page.
//
// WHY THIS FILE EXISTS
// libauth initialises its WASM crypto (secp256k1, sha256, ripemd160, …) with a
// TOP-LEVEL AWAIT. If two bundles each carry their own copy, each has its own
// unsettled init, and esbuild's inlined dynamic imports can hand out a bundle's
// exports before that init completes. Symptom, observed on cold load:
//
// TypeError: Cannot read properties of undefined
// (reading 'derivePublicKeyCompressed')
// at deriveNostrPublicKey (wizardconnect.js)
// at generateKeyExchangeCredentials
// at initiateDappRelay
//
// — failing 65 ms in, then "working" on every retry once the WASM had warmed.
// A bug that disappears when you look at it twice is exactly the kind that
// ships.
//
// So libauth becomes a real, separate ES module that every other bundle imports
// by bare specifier, resolved through the import map in register.html. The
// browser's module loader guarantees a dependency's top-level await settles
// before any importer evaluates — the ordering we need — and the page downloads
// libauth once instead of three times.
//
// WHY THE EXPORTS ARE LISTED BY HAND
// `export *` would defeat tree-shaking and ship all ~1 MB of libauth. This list
// is the union of what our own modules use and what @wizardconnect/core and
// /dapp import (they resolve to this module too, via the import map). Missing a
// name would be a runtime failure in a path we cannot unit-test, so
// build-web.mjs verifies this list against the imports every other bundle
// actually emits, and fails the build if anything is absent. Add freely; the
// check will tell you if you remove something still in use.
export {
// ---- used by @wizardconnect/core and @wizardconnect/dapp ----
bech32PaddedToBin,
binToBech32Padded,
decodeHdPublicKey,
deriveHdPublicNodeChild,
generatePrivateKey,
hash256,
secp256k1,
// ---- encoding ----
binToHex,
hexToBin,
utf8ToBin,
binToUtf8,
binToBase64,
base64ToBin,
// The WalletConnect / WizardConnect wire format: "<Uint8Array: 0x..>" and
// "<bigint: ..n>". Wallets validate these strictly.
stringify,
// ---- addresses ----
cashAddressToLockingBytecode,
lockingBytecodeToCashAddress,
encodeCashAddress,
decodeCashAddress,
// ---- hashing ----
sha256,
hash160,
ripemd160,
// ---- transactions ----
encodeTransaction,
decodeTransaction,
generateSigningSerializationBCH,
// ---- keys / HD wallets (the built-in wallet) ----
generateBip39Mnemonic,
deriveSeedFromBip39Mnemonic,
deriveHdPrivateNodeFromSeed,
deriveHdPath,
deriveHdPublicNode,
} from "@bitauth/libauth";