frameassembly-wasm 2.0.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -21
- package/frameassembly_wasm.d.ts +61 -6
- package/frameassembly_wasm.js +140 -6
- package/frameassembly_wasm_bg.wasm +0 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# FrameAssembly WebAssembly Compiler (`frameassembly-wasm`
|
|
1
|
+
# FrameAssembly WebAssembly Compiler (`frameassembly-wasm` v3.1.0)
|
|
2
2
|
|
|
3
3
|
[](https://frameassembly.ai.studio/)
|
|
4
4
|
[](https://www.npmjs.com/package/frameassembly-wasm)
|
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
|
|
7
7
|
[**Try in Browser (`frameassembly.ai.studio`)**](https://frameassembly.ai.studio/) • [**Installation**](#installation) • [**Vite, React & Next.js**](#initialization-vite-react-nextjs--google-ai-studio) • [**API Reference**](#api-reference)
|
|
8
8
|
|
|
9
|
-
WebAssembly compiler, `.pcap`/`.pcapng`-to-`.
|
|
9
|
+
WebAssembly compiler, `.pcap`/`.pcapng`-to-`.frasm` decompiler, packet ladder inspector, and UTF-16 IDE diagnostics for **FrameAssembly (`.frasm` v3.1.0)** — compiling `.frasm` code into classic `.pcap` and `.pcapng` packet captures and decompiling existing captures back into `.frasm` code across 81 L2–L7 protocols in browser applications, VS Code Desktop & Web extensions, web cyber ranges, and Node.js test suites. Powers the official FrameAssembly interactive browser playground at [**frameassembly.ai.studio**](https://frameassembly.ai.studio/) and the official VS Code extension (`SteveWinschel.frameassembly-vscode`). *(Note: FrameAssembly is a network packet specification compiler, not x86 Flat Assembler).*
|
|
10
10
|
|
|
11
11
|
---
|
|
12
12
|
|
|
13
|
-
## Client-Side `.
|
|
13
|
+
## Client-Side `.frasm` to `.pcapng` Compilation & PCAP Decompilation in the Browser & Node.js
|
|
14
14
|
|
|
15
|
-
`frameassembly-wasm` compiles the FrameAssembly Rust engine to WebAssembly, turning `.
|
|
15
|
+
`frameassembly-wasm` compiles the FrameAssembly Rust engine to WebAssembly, turning `.frasm` code into classic `.pcap` (`compileFrasmToPcap` / `compile_frasm_to_pcap`) or `.pcapng` (`compile_fasm_to_pcapng` / `compileFrasm`) byte streams, decompiling binary `.pcap` and `.pcapng` captures into strict-lowercase `.frasm` code via `reverse_pcap(pcapBytes)` / `reversePcap(pcapBytes)`, and emitting real-time Monaco, CodeMirror, and VS Code diagnostics directly in the browser or Node.js without a backend server:
|
|
16
16
|
|
|
17
17
|
```frameassembly
|
|
18
18
|
host client { ip 192.168.1.10 mac 00:11:22:33:44:55 }
|
|
@@ -63,9 +63,9 @@ if (diagnostics.length === 0) {
|
|
|
63
63
|
const blob = new Blob([pcapngBytes], { type: "application/vnd.tcpdump.pcap" });
|
|
64
64
|
console.log(`Generated PCAPNG: ${blob.size} bytes`);
|
|
65
65
|
|
|
66
|
-
// 4. Decompile binary PCAP/PCAPNG bytes back into strict-lowercase .
|
|
66
|
+
// 4. Decompile binary PCAP/PCAPNG bytes back into strict-lowercase .frasm code
|
|
67
67
|
const reversed = reversePcap(pcapngBytes);
|
|
68
|
-
console.log(`Reversed ${reversed.packetCount} frames across ${reversed.hostCount} hosts:\n${reversed.
|
|
68
|
+
console.log(`Reversed ${reversed.packetCount} frames across ${reversed.hostCount} hosts:\n${reversed.frasm}`);
|
|
69
69
|
}
|
|
70
70
|
```
|
|
71
71
|
|
|
@@ -90,10 +90,10 @@ npm install frameassembly-wasm
|
|
|
90
90
|
inspect_fasm,
|
|
91
91
|
compile_fasm_to_pcapng,
|
|
92
92
|
reversePcap,
|
|
93
|
-
} from "https://cdn.jsdelivr.net/npm/frameassembly-wasm@
|
|
93
|
+
} from "https://cdn.jsdelivr.net/npm/frameassembly-wasm@3.1.0/frameassembly_wasm.js";
|
|
94
94
|
|
|
95
95
|
await init();
|
|
96
|
-
console.log("FrameAssembly WebAssembly engine
|
|
96
|
+
console.log("FrameAssembly WebAssembly engine v3.1.0 loaded successfully.");
|
|
97
97
|
</script>
|
|
98
98
|
```
|
|
99
99
|
|
|
@@ -123,8 +123,10 @@ await init({ module_or_path: wasmUrl });
|
|
|
123
123
|
|
|
124
124
|
## API Reference
|
|
125
125
|
|
|
126
|
-
|
|
127
|
-
|
|
126
|
+
> **3.0.0 naming:** FrameAssembly 3.0 renamed its source files from `.fasm` to `.frasm`. Every export has a `*_frasm` / `*Frasm` name (`validate_frasm`, `inspect_frasm`, `compile_frasm_to_pcapng`, `validateFrasm`, `inspectFrasm`, `compileFrasm`). The 2.x names (`validate_fasm`, `inspect_fasm`, `compile_fasm_to_pcapng`, `validateFasm`, `compileFasm`) stay available as identical aliases, so existing integrations keep working without changes. `reverse_pcap` / `reversePcap` return the decompiled code in `frasm` and, for compatibility, `fasm`.
|
|
127
|
+
|
|
128
|
+
### `validate_fasm(source: string): IdeDiagnostic[]` / `validateFasm(source: string): IdeDiagnostic[]` (alias: `validate_frasm` / `validateFrasm`)
|
|
129
|
+
Parses, validates, and test-compiles `.frasm` source code, returning zero-based UTF-16 line and column spans ready for Monaco Editor, CodeMirror 6, or VS Code diagnostic markers (including v3.0.0 strict-lowercase quick-fix remediation hints in `help`). Returns an empty array `[]` when the source compiles cleanly.
|
|
128
130
|
|
|
129
131
|
```ts
|
|
130
132
|
interface IdeDiagnostic {
|
|
@@ -137,8 +139,8 @@ interface IdeDiagnostic {
|
|
|
137
139
|
}
|
|
138
140
|
```
|
|
139
141
|
|
|
140
|
-
### `inspect_fasm(source: string): PacketPreview[]`
|
|
141
|
-
Compiles `.
|
|
142
|
+
### `inspect_fasm(source: string): PacketPreview[]` (alias: `inspect_frasm` / `inspectFrasm`)
|
|
143
|
+
Compiles `.frasm` source code into an array of packet ladder inspection entries, including relative millisecond timestamps, endpoint pairs (`source_dest`), protocol labels (`protocol`), decoded Ethernet/VLAN/QinQ/MPLS/L3/L4/L7 summaries (`summary`), frame lengths, and lowercase space-delimited hex byte dumps. Throws a JavaScript `Error` if compilation fails.
|
|
142
144
|
|
|
143
145
|
```ts
|
|
144
146
|
interface PacketPreview {
|
|
@@ -152,16 +154,20 @@ interface PacketPreview {
|
|
|
152
154
|
}
|
|
153
155
|
```
|
|
154
156
|
|
|
155
|
-
### `
|
|
156
|
-
Compiles `.
|
|
157
|
+
### `compileFrasmToPcap(source: string): Uint8Array` / `compile_frasm_to_pcap(source: string): Uint8Array`
|
|
158
|
+
Compiles `.frasm` source code into a binary `Uint8Array` containing a valid classic libpcap (`.pcap`) byte stream (`LINKTYPE_ETHERNET`, `snaplen = 65535`, automatic microsecond or nanosecond timestamp header selection). Throws a JavaScript `Error` with diagnostic context if compilation fails.
|
|
159
|
+
|
|
160
|
+
### `compile_fasm_to_pcapng(source: string): Uint8Array` / `compileFasm(source: string): Uint8Array` (alias: `compile_frasm_to_pcapng` / `compileFrasm`)
|
|
161
|
+
Compiles `.frasm` source code into a binary `Uint8Array` containing a valid, standards-compliant PCAPNG byte stream with nanosecond timestamp precision (`IfTsResol = 9`). Throws a JavaScript `Error` with diagnostic context if compilation fails.
|
|
157
162
|
|
|
158
163
|
### `reverse_pcap(pcap_bytes: Uint8Array): ReverseJsResult` / `reversePcap(pcap_bytes: Uint8Array): ReverseJsResult`
|
|
159
|
-
Decompiles an in-memory `.pcap` or `.pcapng` byte array (`Uint8Array`) across all 81 native Layer 2 through Layer 7 protocols into strict-lowercase `.
|
|
164
|
+
Decompiles an in-memory `.pcap` or `.pcapng` byte array (`Uint8Array`) across all 81 native Layer 2 through Layer 7 protocols into strict-lowercase `.frasm` code (`host1`, `host2`, ... declarations and an inline `compile` block), returning summary statistics (`packetCount`, `hostCount`). Throws a structured error object (`{ success: false, error, message }`) if `pcap_bytes` is not a valid packet capture.
|
|
160
165
|
|
|
161
166
|
```ts
|
|
162
167
|
interface ReversePcapResult {
|
|
163
168
|
success: boolean; // true when decompilation succeeds
|
|
164
|
-
|
|
169
|
+
frasm: string; // Strict-lowercase .frasm source code
|
|
170
|
+
fasm: string; // Backward-compatible 2.x alias of frasm
|
|
165
171
|
packetCount: number; // Total number of reversed packets
|
|
166
172
|
hostCount: number; // Total number of host1, host2, ... declarations emitted
|
|
167
173
|
}
|
|
@@ -176,15 +182,15 @@ type ReverseJsResult = ReversePcapResult;
|
|
|
176
182
|
```ts
|
|
177
183
|
import init, { compile_fasm_to_pcapng, reversePcap, validate_fasm } from "frameassembly-wasm";
|
|
178
184
|
|
|
179
|
-
export async function downloadCapture(
|
|
185
|
+
export async function downloadCapture(frasmCode: string, filename = "capture.pcapng") {
|
|
180
186
|
await init();
|
|
181
187
|
|
|
182
|
-
const errors = validate_fasm(
|
|
188
|
+
const errors = validate_fasm(frasmCode);
|
|
183
189
|
if (errors.length > 0) {
|
|
184
190
|
throw new Error(`Compilation error: ${errors[0].message}`);
|
|
185
191
|
}
|
|
186
192
|
|
|
187
|
-
const pcapng = compile_fasm_to_pcapng(
|
|
193
|
+
const pcapng = compile_fasm_to_pcapng(frasmCode);
|
|
188
194
|
const blob = new Blob([pcapng], { type: "application/vnd.tcpdump.pcap" });
|
|
189
195
|
const url = URL.createObjectURL(blob);
|
|
190
196
|
|
|
@@ -201,7 +207,7 @@ export async function importCaptureFile(file: File): Promise<string> {
|
|
|
201
207
|
await init();
|
|
202
208
|
const bytes = new Uint8Array(await file.arrayBuffer());
|
|
203
209
|
const result = reversePcap(bytes);
|
|
204
|
-
return result.
|
|
210
|
+
return result.frasm;
|
|
205
211
|
}
|
|
206
212
|
```
|
|
207
213
|
|
|
@@ -218,6 +224,6 @@ export async function importCaptureFile(file: File): Promise<string> {
|
|
|
218
224
|
|
|
219
225
|
## Disambiguation: FrameAssembly vs. Flat Assembler
|
|
220
226
|
|
|
221
|
-
**FrameAssembly** (`.
|
|
227
|
+
**FrameAssembly** (`.frasm`, media type `text/vnd.frameassembly`) is a network packet specification compiler for generating and decompiling `.pcap` and `.pcapng` packet captures. It is completely unrelated to x86 Flat Assembler (`fasm.net`, which uses `.asm`/`.fasm` files) and SymbiFlow / F4PGA FPGA bitstream FASM tools.
|
|
222
228
|
|
|
223
229
|
Full documentation, interactive browser playground ([https://frameassembly.ai.studio/](https://frameassembly.ai.studio/)), grammar specifications, and 2,611 verified examples: https://github.com/SteveWinschel/FrameAssembly
|
package/frameassembly_wasm.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export interface PacketPreview {
|
|
|
22
22
|
|
|
23
23
|
export interface ReversePcapResult {
|
|
24
24
|
success: boolean;
|
|
25
|
+
frasm: string;
|
|
25
26
|
fasm: string;
|
|
26
27
|
packetCount: number;
|
|
27
28
|
hostCount: number;
|
|
@@ -38,20 +39,56 @@ export interface ReversePcapError {
|
|
|
38
39
|
|
|
39
40
|
|
|
40
41
|
/**
|
|
41
|
-
* Compiles `.
|
|
42
|
+
* Compiles `.frasm` source into a standards-compliant PCAPNG byte array (`compileFasm` 2.x alias).
|
|
42
43
|
*/
|
|
43
44
|
export function compileFasm(source: string): Uint8Array;
|
|
44
45
|
|
|
45
46
|
/**
|
|
46
|
-
* Compiles `.
|
|
47
|
+
* Compiles `.frasm` source into a standards-compliant PCAPNG byte array (`compileFrasm` alias).
|
|
48
|
+
*/
|
|
49
|
+
export function compileFrasm(source: string): Uint8Array;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Compiles `.frasm` source into a classic libpcap (`.pcap`) byte array (`compileFrasmToPcap` JS `Uint8Array`).
|
|
53
|
+
*
|
|
54
|
+
* # Errors
|
|
55
|
+
* Returns a JavaScript `JsValue` error if parsing, validation, or serialization fails.
|
|
56
|
+
*/
|
|
57
|
+
export function compileFrasmToPcap(source: string): Uint8Array;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Compiles `.frasm` source into a standards-compliant PCAPNG byte array (JS `Uint8Array`).
|
|
47
61
|
*/
|
|
48
62
|
export function compile_fasm_to_pcapng(source: string): Uint8Array;
|
|
49
63
|
|
|
64
|
+
/**
|
|
65
|
+
* Compiles `.frasm` source into a classic libpcap (`.pcap`) byte array (`compile_frasm_to_pcap` JS alias).
|
|
66
|
+
*
|
|
67
|
+
* # Errors
|
|
68
|
+
* Returns a JavaScript `JsValue` error if parsing, validation, or serialization fails.
|
|
69
|
+
*/
|
|
70
|
+
export function compile_frasm_to_pcap(source: string): Uint8Array;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Compiles `.frasm` source into a standards-compliant PCAPNG byte array (JS `Uint8Array`).
|
|
74
|
+
*/
|
|
75
|
+
export function compile_frasm_to_pcapng(source: string): Uint8Array;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Returns decoded frame metadata for `.frasm` source (`inspectFrasm` camelCase alias).
|
|
79
|
+
*/
|
|
80
|
+
export function inspectFrasm(source: string): PacketPreview[];
|
|
81
|
+
|
|
50
82
|
/**
|
|
51
83
|
* Returns decoded frame metadata, endpoint/protocol summaries, and hex strings for packet ladder inspectors.
|
|
52
84
|
*/
|
|
53
85
|
export function inspect_fasm(source: string): PacketPreview[];
|
|
54
86
|
|
|
87
|
+
/**
|
|
88
|
+
* Returns decoded frame metadata, endpoint/protocol summaries, and hex strings for `.frasm` source.
|
|
89
|
+
*/
|
|
90
|
+
export function inspect_frasm(source: string): PacketPreview[];
|
|
91
|
+
|
|
55
92
|
/**
|
|
56
93
|
* Decompiles an in-memory `.pcap` or `.pcapng` capture (`reversePcap` camelCase alias).
|
|
57
94
|
*
|
|
@@ -62,8 +99,8 @@ export function inspect_fasm(source: string): PacketPreview[];
|
|
|
62
99
|
export function reversePcap(pcap_bytes: Uint8Array | number[]): ReversePcapResult;
|
|
63
100
|
|
|
64
101
|
/**
|
|
65
|
-
* Decompiles an in-memory `.pcap` or `.pcapng` capture (`Uint8Array`) into canonical `.
|
|
66
|
-
* source code and summary counts (`{ success: true, fasm, packetCount, hostCount }`).
|
|
102
|
+
* Decompiles an in-memory `.pcap` or `.pcapng` capture (`Uint8Array`) into canonical `.frasm`
|
|
103
|
+
* source code and summary counts (`{ success: true, frasm, fasm, packetCount, hostCount }`).
|
|
67
104
|
*
|
|
68
105
|
* # Errors
|
|
69
106
|
* Returns a structured `JsValue` error object (`{ success: false, error, message }`) if
|
|
@@ -72,26 +109,44 @@ export function reversePcap(pcap_bytes: Uint8Array | number[]): ReversePcapResul
|
|
|
72
109
|
export function reverse_pcap(pcap_bytes: Uint8Array | number[]): ReversePcapResult;
|
|
73
110
|
|
|
74
111
|
/**
|
|
75
|
-
* Validates `.
|
|
112
|
+
* Validates `.frasm` source and returns UTF-16 line/column diagnostics (`validateFasm` 2.x alias).
|
|
76
113
|
*/
|
|
77
114
|
export function validateFasm(source: string): IdeDiagnostic[];
|
|
78
115
|
|
|
79
116
|
/**
|
|
80
|
-
* Validates `.
|
|
117
|
+
* Validates `.frasm` source and returns UTF-16 line/column diagnostics (`validateFrasm` camelCase alias).
|
|
118
|
+
*/
|
|
119
|
+
export function validateFrasm(source: string): IdeDiagnostic[];
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Validates `.frasm` source and returns UTF-16 line/column diagnostics for Monaco, CodeMirror, and VS Code.
|
|
81
123
|
*/
|
|
82
124
|
export function validate_fasm(source: string): IdeDiagnostic[];
|
|
83
125
|
|
|
126
|
+
/**
|
|
127
|
+
* Validates `.frasm` source and returns UTF-16 line/column diagnostics for Monaco, CodeMirror, and VS Code.
|
|
128
|
+
*/
|
|
129
|
+
export function validate_frasm(source: string): IdeDiagnostic[];
|
|
130
|
+
|
|
84
131
|
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
85
132
|
|
|
86
133
|
export interface InitOutput {
|
|
87
134
|
readonly memory: WebAssembly.Memory;
|
|
88
135
|
readonly compileFasm: (a: number, b: number) => [number, number, number, number];
|
|
136
|
+
readonly compileFrasm: (a: number, b: number) => [number, number, number, number];
|
|
137
|
+
readonly compileFrasmToPcap: (a: number, b: number) => [number, number, number, number];
|
|
89
138
|
readonly compile_fasm_to_pcapng: (a: number, b: number) => [number, number, number, number];
|
|
139
|
+
readonly compile_frasm_to_pcap: (a: number, b: number) => [number, number, number, number];
|
|
140
|
+
readonly compile_frasm_to_pcapng: (a: number, b: number) => [number, number, number, number];
|
|
141
|
+
readonly inspectFrasm: (a: number, b: number) => [number, number, number];
|
|
90
142
|
readonly inspect_fasm: (a: number, b: number) => [number, number, number];
|
|
143
|
+
readonly inspect_frasm: (a: number, b: number) => [number, number, number];
|
|
91
144
|
readonly reversePcap: (a: number, b: number) => [number, number, number];
|
|
92
145
|
readonly reverse_pcap: (a: number, b: number) => [number, number, number];
|
|
93
146
|
readonly validateFasm: (a: number, b: number) => [number, number, number];
|
|
147
|
+
readonly validateFrasm: (a: number, b: number) => [number, number, number];
|
|
94
148
|
readonly validate_fasm: (a: number, b: number) => [number, number, number];
|
|
149
|
+
readonly validate_frasm: (a: number, b: number) => [number, number, number];
|
|
95
150
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
96
151
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
97
152
|
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
package/frameassembly_wasm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* @ts-self-types="./frameassembly_wasm.d.ts" */
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Compiles `.
|
|
4
|
+
* Compiles `.frasm` source into a standards-compliant PCAPNG byte array (`compileFasm` 2.x alias).
|
|
5
5
|
* @param {string} source
|
|
6
6
|
* @returns {Uint8Array}
|
|
7
7
|
*/
|
|
@@ -18,7 +18,44 @@ export function compileFasm(source) {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
|
-
* Compiles `.
|
|
21
|
+
* Compiles `.frasm` source into a standards-compliant PCAPNG byte array (`compileFrasm` alias).
|
|
22
|
+
* @param {string} source
|
|
23
|
+
* @returns {Uint8Array}
|
|
24
|
+
*/
|
|
25
|
+
export function compileFrasm(source) {
|
|
26
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
27
|
+
const len0 = WASM_VECTOR_LEN;
|
|
28
|
+
const ret = wasm.compileFrasm(ptr0, len0);
|
|
29
|
+
if (ret[3]) {
|
|
30
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
31
|
+
}
|
|
32
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
33
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
34
|
+
return v2;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Compiles `.frasm` source into a classic libpcap (`.pcap`) byte array (`compileFrasmToPcap` JS `Uint8Array`).
|
|
39
|
+
*
|
|
40
|
+
* # Errors
|
|
41
|
+
* Returns a JavaScript `JsValue` error if parsing, validation, or serialization fails.
|
|
42
|
+
* @param {string} source
|
|
43
|
+
* @returns {Uint8Array}
|
|
44
|
+
*/
|
|
45
|
+
export function compileFrasmToPcap(source) {
|
|
46
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
47
|
+
const len0 = WASM_VECTOR_LEN;
|
|
48
|
+
const ret = wasm.compileFrasmToPcap(ptr0, len0);
|
|
49
|
+
if (ret[3]) {
|
|
50
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
51
|
+
}
|
|
52
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
53
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
54
|
+
return v2;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Compiles `.frasm` source into a standards-compliant PCAPNG byte array (JS `Uint8Array`).
|
|
22
59
|
* @param {string} source
|
|
23
60
|
* @returns {Uint8Array}
|
|
24
61
|
*/
|
|
@@ -34,6 +71,58 @@ export function compile_fasm_to_pcapng(source) {
|
|
|
34
71
|
return v2;
|
|
35
72
|
}
|
|
36
73
|
|
|
74
|
+
/**
|
|
75
|
+
* Compiles `.frasm` source into a classic libpcap (`.pcap`) byte array (`compile_frasm_to_pcap` JS alias).
|
|
76
|
+
*
|
|
77
|
+
* # Errors
|
|
78
|
+
* Returns a JavaScript `JsValue` error if parsing, validation, or serialization fails.
|
|
79
|
+
* @param {string} source
|
|
80
|
+
* @returns {Uint8Array}
|
|
81
|
+
*/
|
|
82
|
+
export function compile_frasm_to_pcap(source) {
|
|
83
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
84
|
+
const len0 = WASM_VECTOR_LEN;
|
|
85
|
+
const ret = wasm.compile_frasm_to_pcap(ptr0, len0);
|
|
86
|
+
if (ret[3]) {
|
|
87
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
88
|
+
}
|
|
89
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
90
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
91
|
+
return v2;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Compiles `.frasm` source into a standards-compliant PCAPNG byte array (JS `Uint8Array`).
|
|
96
|
+
* @param {string} source
|
|
97
|
+
* @returns {Uint8Array}
|
|
98
|
+
*/
|
|
99
|
+
export function compile_frasm_to_pcapng(source) {
|
|
100
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
101
|
+
const len0 = WASM_VECTOR_LEN;
|
|
102
|
+
const ret = wasm.compile_frasm_to_pcapng(ptr0, len0);
|
|
103
|
+
if (ret[3]) {
|
|
104
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
105
|
+
}
|
|
106
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
107
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
108
|
+
return v2;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Returns decoded frame metadata for `.frasm` source (`inspectFrasm` camelCase alias).
|
|
113
|
+
* @param {string} source
|
|
114
|
+
* @returns {PacketPreview[]}
|
|
115
|
+
*/
|
|
116
|
+
export function inspectFrasm(source) {
|
|
117
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
118
|
+
const len0 = WASM_VECTOR_LEN;
|
|
119
|
+
const ret = wasm.inspectFrasm(ptr0, len0);
|
|
120
|
+
if (ret[2]) {
|
|
121
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
122
|
+
}
|
|
123
|
+
return takeFromExternrefTable0(ret[0]);
|
|
124
|
+
}
|
|
125
|
+
|
|
37
126
|
/**
|
|
38
127
|
* Returns decoded frame metadata, endpoint/protocol summaries, and hex strings for packet ladder inspectors.
|
|
39
128
|
* @param {string} source
|
|
@@ -49,6 +138,21 @@ export function inspect_fasm(source) {
|
|
|
49
138
|
return takeFromExternrefTable0(ret[0]);
|
|
50
139
|
}
|
|
51
140
|
|
|
141
|
+
/**
|
|
142
|
+
* Returns decoded frame metadata, endpoint/protocol summaries, and hex strings for `.frasm` source.
|
|
143
|
+
* @param {string} source
|
|
144
|
+
* @returns {PacketPreview[]}
|
|
145
|
+
*/
|
|
146
|
+
export function inspect_frasm(source) {
|
|
147
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
148
|
+
const len0 = WASM_VECTOR_LEN;
|
|
149
|
+
const ret = wasm.inspect_frasm(ptr0, len0);
|
|
150
|
+
if (ret[2]) {
|
|
151
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
152
|
+
}
|
|
153
|
+
return takeFromExternrefTable0(ret[0]);
|
|
154
|
+
}
|
|
155
|
+
|
|
52
156
|
/**
|
|
53
157
|
* Decompiles an in-memory `.pcap` or `.pcapng` capture (`reversePcap` camelCase alias).
|
|
54
158
|
*
|
|
@@ -69,8 +173,8 @@ export function reversePcap(pcap_bytes) {
|
|
|
69
173
|
}
|
|
70
174
|
|
|
71
175
|
/**
|
|
72
|
-
* Decompiles an in-memory `.pcap` or `.pcapng` capture (`Uint8Array`) into canonical `.
|
|
73
|
-
* source code and summary counts (`{ success: true, fasm, packetCount, hostCount }`).
|
|
176
|
+
* Decompiles an in-memory `.pcap` or `.pcapng` capture (`Uint8Array`) into canonical `.frasm`
|
|
177
|
+
* source code and summary counts (`{ success: true, frasm, fasm, packetCount, hostCount }`).
|
|
74
178
|
*
|
|
75
179
|
* # Errors
|
|
76
180
|
* Returns a structured `JsValue` error object (`{ success: false, error, message }`) if
|
|
@@ -89,7 +193,7 @@ export function reverse_pcap(pcap_bytes) {
|
|
|
89
193
|
}
|
|
90
194
|
|
|
91
195
|
/**
|
|
92
|
-
* Validates `.
|
|
196
|
+
* Validates `.frasm` source and returns UTF-16 line/column diagnostics (`validateFasm` 2.x alias).
|
|
93
197
|
* @param {string} source
|
|
94
198
|
* @returns {IdeDiagnostic[]}
|
|
95
199
|
*/
|
|
@@ -104,7 +208,22 @@ export function validateFasm(source) {
|
|
|
104
208
|
}
|
|
105
209
|
|
|
106
210
|
/**
|
|
107
|
-
* Validates `.
|
|
211
|
+
* Validates `.frasm` source and returns UTF-16 line/column diagnostics (`validateFrasm` camelCase alias).
|
|
212
|
+
* @param {string} source
|
|
213
|
+
* @returns {IdeDiagnostic[]}
|
|
214
|
+
*/
|
|
215
|
+
export function validateFrasm(source) {
|
|
216
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
217
|
+
const len0 = WASM_VECTOR_LEN;
|
|
218
|
+
const ret = wasm.validateFrasm(ptr0, len0);
|
|
219
|
+
if (ret[2]) {
|
|
220
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
221
|
+
}
|
|
222
|
+
return takeFromExternrefTable0(ret[0]);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Validates `.frasm` source and returns UTF-16 line/column diagnostics for Monaco, CodeMirror, and VS Code.
|
|
108
227
|
* @param {string} source
|
|
109
228
|
* @returns {IdeDiagnostic[]}
|
|
110
229
|
*/
|
|
@@ -117,6 +236,21 @@ export function validate_fasm(source) {
|
|
|
117
236
|
}
|
|
118
237
|
return takeFromExternrefTable0(ret[0]);
|
|
119
238
|
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Validates `.frasm` source and returns UTF-16 line/column diagnostics for Monaco, CodeMirror, and VS Code.
|
|
242
|
+
* @param {string} source
|
|
243
|
+
* @returns {IdeDiagnostic[]}
|
|
244
|
+
*/
|
|
245
|
+
export function validate_frasm(source) {
|
|
246
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
247
|
+
const len0 = WASM_VECTOR_LEN;
|
|
248
|
+
const ret = wasm.validate_frasm(ptr0, len0);
|
|
249
|
+
if (ret[2]) {
|
|
250
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
251
|
+
}
|
|
252
|
+
return takeFromExternrefTable0(ret[0]);
|
|
253
|
+
}
|
|
120
254
|
function __wbg_get_imports() {
|
|
121
255
|
const import0 = {
|
|
122
256
|
__proto__: null,
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
"collaborators": [
|
|
5
5
|
"Steve Winschel"
|
|
6
6
|
],
|
|
7
|
-
"description": "Compile .
|
|
8
|
-
"version": "
|
|
7
|
+
"description": "Compile .frasm network traffic code to .pcapng and decompile .pcap/.pcapng packet captures in WebAssembly across 81 L2-L7 protocols with live IDE diagnostics and frame inspection.",
|
|
8
|
+
"version": "3.1.0",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
],
|
|
25
25
|
"keywords": [
|
|
26
26
|
"frameassembly",
|
|
27
|
-
"
|
|
27
|
+
"frasm",
|
|
28
28
|
"pcap",
|
|
29
29
|
"pcapng",
|
|
30
30
|
"wasm",
|