@inka-project/inka-evidence 0.0.0-stage → 0.0.2

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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Shunsuke Shimomura
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/pkg/README.md ADDED
@@ -0,0 +1,137 @@
1
+ # @inka-project/inka-evidence
2
+
3
+ The JavaScript/TypeScript binding of the shared [inka test
4
+ evidence](https://github.com/ut-issl/inka/blob/main/docs/en/design/test-evidence.md) emission layer (a wasm
5
+ build of the Rust crate `inka-evidence`), plus the Vitest adapter built on
6
+ top of it. Validation and serialization live in the Rust crate; this
7
+ package never restates the wire schema.
8
+
9
+ ## Install
10
+
11
+ ```console
12
+ npm install --save-dev @inka-project/inka-evidence
13
+ ```
14
+
15
+ The package is on [npm](https://www.npmjs.com/package/@inka-project/inka-evidence)
16
+ and its tarball is attached to every
17
+ [GitHub Release](https://github.com/ut-issl/inka/releases). It ships the
18
+ wasm module, so no Rust toolchain is needed.
19
+
20
+ ## Emission API
21
+
22
+ ```js
23
+ const { EvidenceBuilder } = require("@inka-project/inka-evidence");
24
+
25
+ const builder = new EvidenceBuilder();
26
+ builder.capsulaRunId(process.env.CAPSULA_RUN_ID);
27
+ builder.addTest("suite > case", 'test("x", () => {})', [
28
+ { case: "default", outcome: "pass" },
29
+ ]);
30
+ const text = builder.finish();
31
+ ```
32
+
33
+ ## Vitest adapter
34
+
35
+ A custom reporter exported as `@inka-project/inka-evidence/vitest`. Task
36
+ locations must be enabled so contract bodies can be sliced from source:
37
+
38
+ ```ts
39
+ export default defineConfig({
40
+ test: {
41
+ includeTaskLocation: true,
42
+ reporters: [
43
+ ["default"],
44
+ [
45
+ "@inka-project/inka-evidence/vitest",
46
+ { output: "evidence.json", provenance: { source_revision: "..." } },
47
+ ],
48
+ ],
49
+ },
50
+ });
51
+ ```
52
+
53
+ The run itself is untouched: test failures keep Vitest's own exit status,
54
+ and the evidence file is written for every completed run, failures
55
+ included. The `CAPSULA_RUN_ID` environment variable that `capsula run`
56
+ exports fills the `capsula_run_id` provenance entry unless an explicit
57
+ `provenance` entry already claimed it.
58
+
59
+ ### What is declared and what is reported
60
+
61
+ The required execution set is the run's collected tests, never inferred
62
+ from results:
63
+
64
+ - a test that ran reports `pass` or `fail`;
65
+ - a `test.skip` / `test.todo` reports `skip`;
66
+ - a declared test the run never reported — `--bail`, an interrupt —
67
+ keeps a missing outcome, which never establishes a bind;
68
+ - a test excluded by a name filter (`-t`, `.only`) stays declared and
69
+ reports `skip` (Vitest still collects it); only file-level selection
70
+ removes tests from the declaration entirely;
71
+ - a run with unhandled errors outside the tests suppresses emission: the
72
+ recorded outcomes would be untrustworthy.
73
+
74
+ Each run records one execution per test, labeled by the `case` option
75
+ (default `default`); runs under other configurations are separate
76
+ evidence files with distinct case labels, merged later in the delivery
77
+ flow. The output path is removed when the run starts and written
78
+ atomically at the end, so after a suppressed emission (a test file that
79
+ failed to collect, an empty selection) the path is absent — a stale file
80
+ can never pass for the run's evidence.
81
+
82
+ ### Test-id construction
83
+
84
+ ```text
85
+ [project] <path relative to the vitest root> > <describe chain> > <name>
86
+ ```
87
+
88
+ The `[project]` prefix (with its trailing space) appears only when the
89
+ project is named, matching
90
+ Vitest's own display. Each `test.each` instance is its own test under its
91
+ formatted name: changing the table changes the declared set. Dynamically
92
+ declared tests (loops, conditions) are declared exactly as collected in
93
+ this run; nondeterministic names produce new, unapproved test-ids rather
94
+ than silent reuse. Duplicate names at the same position collide and fail
95
+ explicitly.
96
+
97
+ ### Contract bodies
98
+
99
+ The body is the whole test call expression — declaration and callback,
100
+ for `test.each` the full chain including the table — sliced verbatim from
101
+ the original source at the task's reported location (parsed with
102
+ `@babel/parser`; TypeScript and JSX included). Helper functions and
103
+ fixtures outside the call stay excluded: the contract assigns dependency
104
+ capture elsewhere. The resolved call is cross-checked against the task —
105
+ a literal test name must match (each patterns placeholder-wise) — and a
106
+ location the slicer cannot resolve or verify is an explicit error. A
107
+ dynamic test name (a variable, a template with substitutions) cannot be
108
+ cross-checked and is recorded as collected.
109
+
110
+ ### Merging run configurations
111
+
112
+ The package exports `merge(inputs, options?)` and ships an
113
+ `inka-evidence-merge` bin that unions per-configuration evidence files
114
+ into one declared set; a `label=file` input prefixes that file's case ids
115
+ as `label/case`. Give each Vitest run a distinct `case` option instead
116
+ when the case axis is free.
117
+
118
+ ### Topology and version limits
119
+
120
+ - Vitest >= 5 on Node ^22.18 or >= 24.11 (the `--target nodejs` wasm
121
+ build; `@babel/parser` is loaded through `require(esm)`).
122
+ - `includeTaskLocation: true` is required; its absence is an explicit
123
+ error.
124
+ - The tagged-template form of `each` is rejected explicitly: Vitest
125
+ reports untrustworthy locations for it, which could slice a neighboring
126
+ test's body. Use the array form.
127
+ - Watch mode and filtered re-runs are unsupported: every re-run rewrites
128
+ the file, so partial evidence would replace full evidence. Run the
129
+ evidence pass as a one-shot `vitest run`.
130
+ - Retries (`retry`) record the final result.
131
+ - Multi-project workspaces are supported through the `[project]` prefix;
132
+ an unnamed project in more than one config colliding on the same file
133
+ fails explicitly as a duplicate id.
134
+ - `--merge-reports` and blob reports are unsupported (untested paths;
135
+ run the evidence pass as a plain `vitest run`).
136
+ - Tests that wrap subprocesses or browsers appear only as the outer
137
+ Vitest test.
@@ -0,0 +1,117 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /**
5
+ * One declared execution: its case id and, when a result was reported, the
6
+ * observed outcome. Omit `outcome` for a declared-but-missing result (at
7
+ * runtime a `null` outcome is read the same way). The runtime vocabulary is
8
+ * the `inka-evidence` crate's; this type mirrors it for editor support.
9
+ */
10
+ export interface ExecutionInit {
11
+ case: string;
12
+ outcome?: "pass" | "fail" | "skip" | "cancelled";
13
+ }
14
+
15
+
16
+
17
+ /**
18
+ * One input to `merge`: an evidence file's text and an optional label
19
+ * prefixed onto its case ids as `label/case`.
20
+ */
21
+ export interface MergeInput {
22
+ label?: string;
23
+ text: string;
24
+ /** A display name (typically the file name) used in error messages. */
25
+ name?: string;
26
+ }
27
+
28
+ /** Options for `merge`. */
29
+ export interface MergeOptions {
30
+ /** Extra provenance entries for the merged file. */
31
+ provenance?: Record<string, string>;
32
+ /**
33
+ * Fills the `capsula_run_id` provenance entry — typically
34
+ * `process.env.CAPSULA_RUN_ID` — unless an explicit entry claimed it.
35
+ */
36
+ capsulaRunId?: string;
37
+ }
38
+
39
+
40
+
41
+ /**
42
+ * Assembles one test evidence v1 file, validating as it goes. Invalid
43
+ * input throws an `Error` named `InvalidEvidenceError` and leaves the
44
+ * builder unchanged, so whatever `finish` returns is guaranteed to load.
45
+ */
46
+ export class EvidenceBuilder {
47
+ free(): void;
48
+ [Symbol.dispose](): void;
49
+ /**
50
+ * Records one test and its declared required executions, given as plain
51
+ * `{ case, outcome? }` objects.
52
+ *
53
+ * A `null` outcome is treated exactly like an omitted one: a declared
54
+ * result that is missing. `JSON.stringify` already folds the JS-only
55
+ * non-values (`NaN` becomes `null`, an `undefined` property vanishes),
56
+ * and the wire deserializer reads both spellings as "no result".
57
+ *
58
+ * # Errors
59
+ *
60
+ * Throws a `TypeError` when `executions` does not serialize to JSON
61
+ * text (`undefined`, a function, a `BigInt`, a cycle) or is not an
62
+ * array of objects the wire format's serde definitions accept (an
63
+ * unknown outcome spelling or a stray field included), and an
64
+ * `InvalidEvidenceError` on a blank test or case id, an empty body, an
65
+ * empty execution list, or a duplicate case or test id. Every error
66
+ * leaves the builder unchanged and usable.
67
+ */
68
+ addTest(id: string, body: string, executions: ReadonlyArray<ExecutionInit>): void;
69
+ /**
70
+ * Fills `capsula_run_id` with `runId` — typically
71
+ * `process.env.CAPSULA_RUN_ID`, which `capsula run` exports — unless it
72
+ * is `undefined` or blank or an explicit provenance entry already
73
+ * claimed the key.
74
+ */
75
+ capsulaRunId(run_id?: string | null): void;
76
+ /**
77
+ * Serializes the file: pretty-printed v1 JSON ending in a newline,
78
+ * guaranteed to be accepted by the consumer.
79
+ */
80
+ finish(): string;
81
+ /**
82
+ * An empty file: no provenance, no tests.
83
+ */
84
+ constructor();
85
+ /**
86
+ * Records one descriptive provenance entry, replacing an earlier value
87
+ * under the same key. Rejects a blank key or value.
88
+ *
89
+ * # Errors
90
+ *
91
+ * Throws an `InvalidEvidenceError` when the key or the value is blank.
92
+ */
93
+ provenance(key: string, value: string): void;
94
+ }
95
+
96
+ /**
97
+ * Merges per-configuration evidence file texts into one evidence file's
98
+ * text. Each input may carry a label, which prefixes its case ids as
99
+ * `label/case`; see the shared crate's merge module for the semantics.
100
+ *
101
+ * # Errors
102
+ *
103
+ * Throws a `TypeError` when the arguments do not have the declared shape,
104
+ * and an `Error` named `InvalidEvidenceError` when the inputs cannot
105
+ * merge (an unreadable input, differing bodies, a case declared twice,
106
+ * disagreeing `source_revision` entries, no inputs).
107
+ */
108
+ export function merge(inputs: ReadonlyArray<MergeInput>, options?: MergeOptions | null): string;
109
+
110
+ /**
111
+ * The evidence format version this binding writes.
112
+ *
113
+ * # Panics
114
+ *
115
+ * Never in practice: the crate's version constant fits in a `u32`.
116
+ */
117
+ export function version(): number;
@@ -0,0 +1,354 @@
1
+ /* @ts-self-types="./inka_evidence_wasm.d.ts" */
2
+
3
+ /**
4
+ * Assembles one test evidence v1 file, validating as it goes. Invalid
5
+ * input throws an `Error` named `InvalidEvidenceError` and leaves the
6
+ * builder unchanged, so whatever `finish` returns is guaranteed to load.
7
+ */
8
+ class EvidenceBuilder {
9
+ __destroy_into_raw() {
10
+ const ptr = this.__wbg_ptr;
11
+ this.__wbg_ptr = 0;
12
+ EvidenceBuilderFinalization.unregister(this);
13
+ return ptr;
14
+ }
15
+ free() {
16
+ const ptr = this.__destroy_into_raw();
17
+ wasm.__wbg_evidencebuilder_free(ptr, 0);
18
+ }
19
+ /**
20
+ * Records one test and its declared required executions, given as plain
21
+ * `{ case, outcome? }` objects.
22
+ *
23
+ * A `null` outcome is treated exactly like an omitted one: a declared
24
+ * result that is missing. `JSON.stringify` already folds the JS-only
25
+ * non-values (`NaN` becomes `null`, an `undefined` property vanishes),
26
+ * and the wire deserializer reads both spellings as "no result".
27
+ *
28
+ * # Errors
29
+ *
30
+ * Throws a `TypeError` when `executions` does not serialize to JSON
31
+ * text (`undefined`, a function, a `BigInt`, a cycle) or is not an
32
+ * array of objects the wire format's serde definitions accept (an
33
+ * unknown outcome spelling or a stray field included), and an
34
+ * `InvalidEvidenceError` on a blank test or case id, an empty body, an
35
+ * empty execution list, or a duplicate case or test id. Every error
36
+ * leaves the builder unchanged and usable.
37
+ * @param {string} id
38
+ * @param {string} body
39
+ * @param {ReadonlyArray<ExecutionInit>} executions
40
+ */
41
+ addTest(id, body, executions) {
42
+ let ptr0, len0, ptr1, len1;
43
+ try {
44
+ ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
45
+ len0 = WASM_VECTOR_LEN;
46
+ ptr1 = passStringToWasm0(body, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
47
+ len1 = WASM_VECTOR_LEN;
48
+ } catch (e) {
49
+ if (ptr1) { wasm.__wbindgen_free(ptr1, len1 * 1, 1); }
50
+ if (ptr0) { wasm.__wbindgen_free(ptr0, len0 * 1, 1); }
51
+ throw e;
52
+ }
53
+ const ret = wasm.evidencebuilder_addTest(this.__wbg_ptr, ptr0, len0, ptr1, len1, executions);
54
+ if (ret[1]) {
55
+ throw takeFromExternrefTable0(ret[0]);
56
+ }
57
+ }
58
+ /**
59
+ * Fills `capsula_run_id` with `runId` — typically
60
+ * `process.env.CAPSULA_RUN_ID`, which `capsula run` exports — unless it
61
+ * is `undefined` or blank or an explicit provenance entry already
62
+ * claimed the key.
63
+ * @param {string | null} [run_id]
64
+ */
65
+ capsulaRunId(run_id) {
66
+ var ptr0 = isLikeNone(run_id) ? 0 : passStringToWasm0(run_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
67
+ var len0 = WASM_VECTOR_LEN;
68
+ wasm.evidencebuilder_capsulaRunId(this.__wbg_ptr, ptr0, len0);
69
+ }
70
+ /**
71
+ * Serializes the file: pretty-printed v1 JSON ending in a newline,
72
+ * guaranteed to be accepted by the consumer.
73
+ * @returns {string}
74
+ */
75
+ finish() {
76
+ let deferred1_0;
77
+ let deferred1_1;
78
+ try {
79
+ const ret = wasm.evidencebuilder_finish(this.__wbg_ptr);
80
+ deferred1_0 = ret[0];
81
+ deferred1_1 = ret[1];
82
+ return getStringFromWasm0(ret[0], ret[1]);
83
+ } finally {
84
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
85
+ }
86
+ }
87
+ /**
88
+ * An empty file: no provenance, no tests.
89
+ */
90
+ constructor() {
91
+ const ret = wasm.evidencebuilder_new();
92
+ this.__wbg_ptr = ret;
93
+ EvidenceBuilderFinalization.register(this, this.__wbg_ptr, this);
94
+ return this;
95
+ }
96
+ /**
97
+ * Records one descriptive provenance entry, replacing an earlier value
98
+ * under the same key. Rejects a blank key or value.
99
+ *
100
+ * # Errors
101
+ *
102
+ * Throws an `InvalidEvidenceError` when the key or the value is blank.
103
+ * @param {string} key
104
+ * @param {string} value
105
+ */
106
+ provenance(key, value) {
107
+ let ptr0, len0, ptr1, len1;
108
+ try {
109
+ ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
110
+ len0 = WASM_VECTOR_LEN;
111
+ ptr1 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
112
+ len1 = WASM_VECTOR_LEN;
113
+ } catch (e) {
114
+ if (ptr1) { wasm.__wbindgen_free(ptr1, len1 * 1, 1); }
115
+ if (ptr0) { wasm.__wbindgen_free(ptr0, len0 * 1, 1); }
116
+ throw e;
117
+ }
118
+ const ret = wasm.evidencebuilder_provenance(this.__wbg_ptr, ptr0, len0, ptr1, len1);
119
+ if (ret[1]) {
120
+ throw takeFromExternrefTable0(ret[0]);
121
+ }
122
+ }
123
+ }
124
+ if (Symbol.dispose) EvidenceBuilder.prototype[Symbol.dispose] = EvidenceBuilder.prototype.free;
125
+ exports.EvidenceBuilder = EvidenceBuilder;
126
+
127
+ /**
128
+ * Merges per-configuration evidence file texts into one evidence file's
129
+ * text. Each input may carry a label, which prefixes its case ids as
130
+ * `label/case`; see the shared crate's merge module for the semantics.
131
+ *
132
+ * # Errors
133
+ *
134
+ * Throws a `TypeError` when the arguments do not have the declared shape,
135
+ * and an `Error` named `InvalidEvidenceError` when the inputs cannot
136
+ * merge (an unreadable input, differing bodies, a case declared twice,
137
+ * disagreeing `source_revision` entries, no inputs).
138
+ * @param {ReadonlyArray<MergeInput>} inputs
139
+ * @param {MergeOptions | null} [options]
140
+ * @returns {string}
141
+ */
142
+ function merge(inputs, options) {
143
+ let deferred2_0;
144
+ let deferred2_1;
145
+ try {
146
+ const ret = wasm.merge(inputs, isLikeNone(options) ? 0 : addToExternrefTable0(options));
147
+ var ptr1 = ret[0];
148
+ var len1 = ret[1];
149
+ if (ret[3]) {
150
+ ptr1 = 0; len1 = 0;
151
+ throw takeFromExternrefTable0(ret[2]);
152
+ }
153
+ deferred2_0 = ptr1;
154
+ deferred2_1 = len1;
155
+ return getStringFromWasm0(ptr1, len1);
156
+ } finally {
157
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
158
+ }
159
+ }
160
+ exports.merge = merge;
161
+
162
+ /**
163
+ * The evidence format version this binding writes.
164
+ *
165
+ * # Panics
166
+ *
167
+ * Never in practice: the crate's version constant fits in a `u32`.
168
+ * @returns {number}
169
+ */
170
+ function version() {
171
+ const ret = wasm.version();
172
+ return ret >>> 0;
173
+ }
174
+ exports.version = version;
175
+ function __wbg_get_imports() {
176
+ const import0 = {
177
+ __proto__: null,
178
+ __wbg___wbindgen_is_null_c22311b1cc228e3a: function(arg0) {
179
+ const ret = arg0 === null;
180
+ return ret;
181
+ },
182
+ __wbg___wbindgen_is_undefined_be5b34249ff1fc15: function(arg0) {
183
+ const ret = arg0 === undefined;
184
+ return ret;
185
+ },
186
+ __wbg___wbindgen_string_get_7ce8eee7fd327545: function(arg0, arg1) {
187
+ const obj = arg1;
188
+ const ret = typeof(obj) === 'string' ? obj : undefined;
189
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
190
+ var len1 = WASM_VECTOR_LEN;
191
+ getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 1, len1, true);
192
+ getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 0, ptr1, true);
193
+ },
194
+ __wbg___wbindgen_throw_4c88d8bf264fd984: function(arg0, arg1) {
195
+ throw new Error(getStringFromWasm0(arg0, arg1));
196
+ },
197
+ __wbg_instanceof_Error_74e3cca0c4a69161: function(arg0) {
198
+ let result;
199
+ try {
200
+ result = arg0 instanceof Error;
201
+ } catch (_) {
202
+ result = false;
203
+ }
204
+ const ret = result;
205
+ return ret;
206
+ },
207
+ __wbg_message_43d8c8f1d543a349: function(arg0) {
208
+ const ret = arg0.message;
209
+ return ret;
210
+ },
211
+ __wbg_new_4416a2fe2fac9c65: function(arg0, arg1) {
212
+ const ret = new TypeError(getStringFromWasm0(arg0, arg1));
213
+ return ret;
214
+ },
215
+ __wbg_new_787b9fb330d55d78: function(arg0, arg1) {
216
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
217
+ return ret;
218
+ },
219
+ __wbg_set_name_822e3903f3184979: function(arg0, arg1, arg2) {
220
+ arg0.name = getStringFromWasm0(arg1, arg2);
221
+ },
222
+ __wbg_stringify_0a0fbf2ef722380a: function() { return handleError(function (arg0) {
223
+ const ret = JSON.stringify(arg0);
224
+ return ret;
225
+ }, arguments); },
226
+ __wbindgen_init_externref_table: function() {
227
+ const table = wasm.__wbindgen_externrefs;
228
+ table.set(0, undefined);
229
+ table.set(1024, undefined);
230
+ table.set(1025, null);
231
+ table.set(1026, true);
232
+ table.set(1027, false);
233
+ },
234
+ };
235
+ return {
236
+ __proto__: null,
237
+ "./inka_evidence_wasm_bg.js": import0,
238
+ };
239
+ }
240
+
241
+ const EvidenceBuilderFinalization = (typeof FinalizationRegistry === 'undefined')
242
+ ? { register: () => {}, unregister: () => {} }
243
+ : new FinalizationRegistry(ptr => wasm.__wbg_evidencebuilder_free(ptr, 1));
244
+
245
+ function addToExternrefTable0(obj) {
246
+ const idx = wasm.__externref_table_alloc();
247
+ wasm.__wbindgen_externrefs.set(idx, obj);
248
+ return idx;
249
+ }
250
+
251
+ let cachedDataViewMemory0 = null;
252
+ function getDataViewMemory0() {
253
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
254
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
255
+ }
256
+ return cachedDataViewMemory0;
257
+ }
258
+
259
+ function getStringFromWasm0(ptr, len) {
260
+ ptr = ptr >>> 0;
261
+ return decodeText(getUint8ArrayMemory0().subarray(ptr, ptr + len));
262
+ }
263
+
264
+ let cachedUint8ArrayMemory0 = null;
265
+ function getUint8ArrayMemory0() {
266
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
267
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
268
+ }
269
+ return cachedUint8ArrayMemory0;
270
+ }
271
+
272
+ function handleError(f, args) {
273
+ try {
274
+ return f.apply(this, args);
275
+ } catch (e) {
276
+ const idx = addToExternrefTable0(e);
277
+ wasm.__wbindgen_exn_store(idx);
278
+ }
279
+ }
280
+
281
+ function isLikeNone(x) {
282
+ return x === undefined || x === null;
283
+ }
284
+
285
+ function passStringToWasm0(arg, malloc, realloc) {
286
+ if (realloc === undefined) {
287
+ const buf = cachedTextEncoder.encode(arg);
288
+ const ptr = malloc(buf.length, 1) >>> 0;
289
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
290
+ WASM_VECTOR_LEN = buf.length;
291
+ return ptr;
292
+ }
293
+
294
+ let len = arg.length;
295
+ let ptr = malloc(len, 1) >>> 0;
296
+
297
+ const mem = getUint8ArrayMemory0();
298
+
299
+ let offset = 0;
300
+
301
+ for (; offset < len; offset++) {
302
+ const code = arg.charCodeAt(offset);
303
+ if (code > 0x7F) break;
304
+ mem[ptr + offset] = code;
305
+ }
306
+ if (offset !== len) {
307
+ if (offset !== 0) {
308
+ arg = arg.slice(offset);
309
+ }
310
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
311
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
312
+ const ret = cachedTextEncoder.encodeInto(arg, view);
313
+
314
+ offset += ret.written;
315
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
316
+ }
317
+
318
+ WASM_VECTOR_LEN = offset;
319
+ return ptr;
320
+ }
321
+
322
+ function takeFromExternrefTable0(idx) {
323
+ const value = wasm.__wbindgen_externrefs.get(idx);
324
+ wasm.__externref_table_dealloc(idx);
325
+ return value;
326
+ }
327
+
328
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true });
329
+ cachedTextDecoder.decode();
330
+ function decodeText(bytes) {
331
+ return cachedTextDecoder.decode(bytes);
332
+ }
333
+
334
+ const cachedTextEncoder = new TextEncoder();
335
+
336
+ if (!('encodeInto' in cachedTextEncoder)) {
337
+ cachedTextEncoder.encodeInto = function (arg, view) {
338
+ const buf = cachedTextEncoder.encode(arg);
339
+ view.set(buf);
340
+ return {
341
+ read: arg.length,
342
+ written: buf.length
343
+ };
344
+ };
345
+ }
346
+
347
+ let WASM_VECTOR_LEN = 0;
348
+
349
+ const wasmPath = `${__dirname}/inka_evidence_wasm_bg.wasm`;
350
+ const wasmBytes = require('fs').readFileSync(wasmPath);
351
+ const wasmModule = new WebAssembly.Module(wasmBytes);
352
+ let wasmInstance = new WebAssembly.Instance(wasmModule, __wbg_get_imports());
353
+ let wasm = wasmInstance.exports;
354
+ wasm.__wbindgen_start();
Binary file
@@ -0,0 +1,19 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export const __wbg_evidencebuilder_free: (a: number, b: number) => void;
5
+ export const evidencebuilder_addTest: (a: number, b: number, c: number, d: number, e: number, f: any) => [number, number];
6
+ export const evidencebuilder_capsulaRunId: (a: number, b: number, c: number) => void;
7
+ export const evidencebuilder_finish: (a: number) => [number, number];
8
+ export const evidencebuilder_new: () => number;
9
+ export const evidencebuilder_provenance: (a: number, b: number, c: number, d: number, e: number) => [number, number];
10
+ export const merge: (a: any, b: number) => [number, number, number, number];
11
+ export const version: () => number;
12
+ export const __wbindgen_malloc: (a: number, b: number) => number;
13
+ export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
14
+ export const __wbindgen_free: (a: number, b: number, c: number) => void;
15
+ export const __wbindgen_exn_store: (a: number) => void;
16
+ export const __externref_table_alloc: () => number;
17
+ export const __wbindgen_externrefs: WebAssembly.Table;
18
+ export const __externref_table_dealloc: (a: number) => void;
19
+ export const __wbindgen_start: () => void;
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "inka-evidence-wasm",
3
+ "description": "TypeScript (wasm) binding over the inka-evidence emission layer",
4
+ "version": "0.0.2",
5
+ "license": "MIT OR Apache-2.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/ut-issl/inka"
9
+ },
10
+ "files": [
11
+ "inka_evidence_wasm_bg.wasm",
12
+ "inka_evidence_wasm.js",
13
+ "inka_evidence_wasm.d.ts"
14
+ ],
15
+ "main": "inka_evidence_wasm.js",
16
+ "types": "inka_evidence_wasm.d.ts"
17
+ }