
# COWAC WEB

![Cowac's logo](./assets/ps5_logo_cowac.jpg)

## Description

COWAC (Climbing Over WebAssembly Arithmetic Capabilities) is a _JavaScript_ library, powered by [Wail](https://github.com/Qwokka/WAIL)
and inspired by [Cojac](https://github.com/Cojac/Cojac), that instrument WebAssembly modules in
order to add a **numerical sniffer**. This sniffer is able to **track and signal arithmetic anomalies**.

Currently, COWAC is able to detect the following anomalies:

- Overflow of integers addition and subtraction
- Overflow of floating point numbers addition and subtraction

## Disponibility

Cowac is available as a [npm package](https://www.npmjs.com/package/cowac_web), and can be install with the
following command:

```bash
npm i cowac_web
```

The tools is also available from the [JSDeliver CDN](https://www.jsdelivr.com/package/npm/cowac_web):

```html
<script src=" https://cdn.jsdelivr.net/npm/cowac_web@1.0.40/index.min.js "></script>
```

## Use

To use the library, no need to install it ! The script can be used via the plugin [Tampermonkey](https://www.tampermonkey.net/?locale=en).

First, install the plugin. Then, you can use the _userscript_ available in the project's `userscript` folder or
directly from the [npm repositorry](https://www.npmjs.com/package/cowac_web?activeTab=code). Just add the script to Tampermonkey. The script is configured to target every
website. If you want to target only specific websites, you can modify the `@match` directive script header. You can
as well change the Cowac version by modifying the import URL. Don't forget to activate the script.

```js
// ==UserScript==
// @name         Cowac Web
// @namespace    Cowac
// @version      2025-01-26
// @description  Instrument WebAssembly (add a numerical sniffer, find and signal overflow in running time)
// @author       Dimitri Julmy
// @match        ==> CHANGE HERE <==
// @grant        none
// @run-at       document-start
// ==/UserScript==

...
var module
try {
    // ==> CHANGE HERE <==
    module = await import('https://cdn.jsdelivr.net/npm/cowac_web@x.x.x/index.js')
} catch (error) {
    console.error("Failed to load Cowac Web module:", error)
    return
}
```
