Decode your first web packet
Open web/ in your installed SDK directory, or extract the static web ZIP. Both contain a ready-to-run module, the Rust decoder binary, TypeScript declarations, and the same example.klv as the native SDK. Start with no token set.
- Node.js
- Browser
Use Node.js 22 or later for these commands. In the extracted directory run:
node example.mjs
import {createDecoder} from './index.mjs';
import {readFile} from 'node:fs/promises';
const decoder = await createDecoder({licenseToken: process.env.LIBMISB_WEB_TOKEN});
try {
const packet = await readFile(process.argv[2] ?? new URL('./example.klv', import.meta.url));
console.log(decoder.licenseStatus().mode);
console.log(decoder.requestJSON(packet));
} finally {
await decoder.close();
}
To use the npm distribution in your own application, run the following from the directory containing its package.json. For a new application, create the directory and run npm init -y there first. Substitute the path to your supplied tarball.
npm install --offline ./impleotv-libmisb-wasm-VERSION.tgz
node node_modules/@impleotv/libmisb-wasm/example.mjs
The package entrypoint is import {createDecoder} from '@impleotv/libmisb-wasm'. Its loader resolves the bundled binary relative to the module.
From the extracted directory, start the supplied static server with Node.js. Open the printed address. The page loads example.klv automatically and also accepts a packet from your computer.
node serve.mjs
<!doctype html>
<html lang="en"><meta charset="utf-8"><title>ST 0601 decoder</title>
<label>Decode an ST 0601 packet <input type="file" id="packet"></label>
<pre id="result"></pre>
<script type="module">
import {createDecoder} from './index.mjs';
const decoder = await createDecoder();
const output = document.querySelector('#result');
function show(bytes) { output.textContent = decoder.licenseStatus().mode + '\n' + decoder.requestJSON(bytes); }
show(new Uint8Array(await (await fetch('./example.klv')).arrayBuffer()));
document.querySelector('#packet').onchange = async event => {
const file = event.target.files[0];
if (file) show(new Uint8Array(await file.arrayBuffer()));
};
addEventListener('pagehide', () => decoder.close(), {once:true});
</script></html>
The first line shows demo. The JSON envelope has status ok and its value contains PrecisionTimestamp: 9007199254740993, Version: 19, and Checksum: 23503. Keep that envelope as text when forwarding exact integer values. Next, decode a stream in TypeScript.