Files
InfiniteAPI/src/Utils/wasm-bridge.ts
T
Claude 4b02652369 style: auto-fix lint errors and formatting issues
Applied yarn lint --fix to auto-correct:
- Import spacing and sorting across multiple files
- Trailing commas
- Arrow function formatting
- Object literal formatting
- Indentation consistency
- Removed unused imports (BaileysEventType, jest from tests)

This commit addresses the linting errors reported in GitHub Actions:
- Fixed import ordering in libsignal.ts
- Fixed trailing commas in Defaults/index.ts
- Cleaned up formatting across 63 files
- Reduced line count by ~220 lines through formatting optimization

Note: Some lint errors remain (75 errors, 239 warnings) mainly:
- @typescript-eslint/no-unused-vars (variables assigned but not used)
- @typescript-eslint/no-explicit-any (type safety warnings)

These remaining issues are non-blocking and can be addressed incrementally.

https://claude.ai/code/session_015R3U3kiprQiNTTNNt31Sg6
2026-02-13 21:59:35 +00:00

41 lines
1.2 KiB
TypeScript

type WasmBridgeModule = typeof import('whatsapp-rust-bridge')
let _bridge: WasmBridgeModule | undefined
// Start loading eagerly using .then() instead of top-level await.
// This prevents the whatsapp-rust-bridge top-level await from propagating
// through the ESM graph, which would break CJS require() consumers.
const _bridgeReady = import('whatsapp-rust-bridge').then(m => {
_bridge = m
return m
})
export { _bridgeReady as wasmBridgeReady }
function getBridge(): WasmBridgeModule {
if (!_bridge) {
throw new Error(
'whatsapp-rust-bridge not yet loaded. ' + 'Ensure async operations have started before calling crypto functions.'
)
}
return _bridge
}
export const hkdf: WasmBridgeModule['hkdf'] = (...args) => getBridge().hkdf(...args)
export const md5: WasmBridgeModule['md5'] = (...args) => getBridge().md5(...args)
export const expandAppStateKeys: WasmBridgeModule['expandAppStateKeys'] = (...args) =>
getBridge().expandAppStateKeys(...args)
let _ltHash: InstanceType<WasmBridgeModule['LTHashAntiTampering']> | undefined
export function getLTHashAntiTampering(): InstanceType<WasmBridgeModule['LTHashAntiTampering']> {
if (!_ltHash) {
_ltHash = new (getBridge().LTHashAntiTampering)()
}
return _ltHash
}